Fix extension repair and add Opus 4.7 overlay
This commit is contained in:
@@ -7,6 +7,7 @@ import { join } from "node:path";
|
||||
import { resolveInitialPrompt, shouldRunInteractiveSetup } from "../src/cli.js";
|
||||
import { buildModelStatusSnapshotFromRecords, chooseRecommendedModel } from "../src/model/catalog.js";
|
||||
import { resolveModelProviderForCommand, setDefaultModelSpec } from "../src/model/commands.js";
|
||||
import { createModelRegistry } from "../src/model/registry.js";
|
||||
|
||||
function createAuthPath(contents: Record<string, unknown>): string {
|
||||
const root = mkdtempSync(join(tmpdir(), "feynman-auth-"));
|
||||
@@ -26,6 +27,17 @@ test("chooseRecommendedModel prefers the strongest authenticated research model"
|
||||
assert.equal(recommendation?.spec, "anthropic/claude-opus-4-6");
|
||||
});
|
||||
|
||||
test("createModelRegistry overlays new Anthropic Opus model before upstream Pi updates", () => {
|
||||
const authPath = createAuthPath({
|
||||
anthropic: { type: "api_key", key: "anthropic-test-key" },
|
||||
});
|
||||
|
||||
const registry = createModelRegistry(authPath);
|
||||
|
||||
assert.ok(registry.find("anthropic", "claude-opus-4-7"));
|
||||
assert.equal(registry.getAvailable().some((model) => model.provider === "anthropic" && model.id === "claude-opus-4-7"), true);
|
||||
});
|
||||
|
||||
test("setDefaultModelSpec accepts a unique bare model id from authenticated models", () => {
|
||||
const authPath = createAuthPath({
|
||||
openai: { type: "api_key", key: "openai-test-key" },
|
||||
|
||||
@@ -6,13 +6,17 @@ import { join, resolve } from "node:path";
|
||||
|
||||
import { installPackageSources, seedBundledWorkspacePackages, updateConfiguredPackages } from "../src/pi/package-ops.js";
|
||||
|
||||
function createBundledWorkspace(appRoot: string, packageNames: string[]): void {
|
||||
function createBundledWorkspace(
|
||||
appRoot: string,
|
||||
packageNames: string[],
|
||||
dependenciesByPackage: Record<string, Record<string, string>> = {},
|
||||
): void {
|
||||
for (const packageName of packageNames) {
|
||||
const packageDir = resolve(appRoot, ".feynman", "npm", "node_modules", packageName);
|
||||
mkdirSync(packageDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(packageDir, "package.json"),
|
||||
JSON.stringify({ name: packageName, version: "1.0.0" }, null, 2) + "\n",
|
||||
JSON.stringify({ name: packageName, version: "1.0.0", dependencies: dependenciesByPackage[packageName] }, null, 2) + "\n",
|
||||
"utf8",
|
||||
);
|
||||
}
|
||||
@@ -76,6 +80,33 @@ test("seedBundledWorkspacePackages preserves existing installed packages", () =>
|
||||
assert.equal(lstatSync(existingPackageDir).isSymbolicLink(), false);
|
||||
});
|
||||
|
||||
test("seedBundledWorkspacePackages repairs broken existing bundled packages", () => {
|
||||
const appRoot = mkdtempSync(join(tmpdir(), "feynman-bundle-"));
|
||||
const homeRoot = mkdtempSync(join(tmpdir(), "feynman-home-"));
|
||||
const agentDir = resolve(homeRoot, "agent");
|
||||
const existingPackageDir = resolve(homeRoot, "npm-global", "lib", "node_modules", "pi-markdown-preview");
|
||||
|
||||
mkdirSync(agentDir, { recursive: true });
|
||||
createBundledWorkspace(appRoot, ["pi-markdown-preview", "puppeteer-core"], {
|
||||
"pi-markdown-preview": { "puppeteer-core": "^24.0.0" },
|
||||
});
|
||||
mkdirSync(existingPackageDir, { recursive: true });
|
||||
writeFileSync(
|
||||
resolve(existingPackageDir, "package.json"),
|
||||
JSON.stringify({ name: "pi-markdown-preview", version: "broken", dependencies: { "puppeteer-core": "^24.0.0" } }) + "\n",
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const seeded = seedBundledWorkspacePackages(agentDir, appRoot, ["npm:pi-markdown-preview"]);
|
||||
|
||||
assert.deepEqual(seeded, ["npm:pi-markdown-preview"]);
|
||||
assert.equal(lstatSync(existingPackageDir).isSymbolicLink(), true);
|
||||
assert.equal(
|
||||
readFileSync(resolve(existingPackageDir, "package.json"), "utf8").includes('"version": "1.0.0"'),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test("installPackageSources filters noisy npm chatter but preserves meaningful output", async () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "feynman-package-ops-"));
|
||||
const workingDir = resolve(root, "project");
|
||||
|
||||
Reference in New Issue
Block a user