4 Commits

Author SHA1 Message Date
Advait Paliwal
1cd1a147f2 Remove runtime hygiene extension bloat 2026-04-17 11:47:18 -07:00
Advait Paliwal
92914acff7 Add Pi event guards for workflow state 2026-04-17 11:13:57 -07:00
Advait Paliwal
f0bbb25910 Use Pi runtime hooks for research context hygiene 2026-04-17 10:38:42 -07:00
Advait Paliwal
9841342866 Fix workflow continuation and provider setup gaps 2026-04-17 09:47:38 -07:00
29 changed files with 362 additions and 38 deletions

View File

@@ -25,7 +25,7 @@ curl -fsSL https://feynman.is/install | bash
irm https://feynman.is/install.ps1 | iex irm https://feynman.is/install.ps1 | iex
``` ```
The one-line installer fetches the latest tagged release. To pin a version, pass it explicitly, for example `curl -fsSL https://feynman.is/install | bash -s -- 0.2.24`. The one-line installer fetches the latest tagged release. To pin a version, pass it explicitly, for example `curl -fsSL https://feynman.is/install | bash -s -- 0.2.28`.
The installer downloads a standalone native bundle with its own Node.js runtime. The installer downloads a standalone native bundle with its own Node.js runtime.
@@ -33,7 +33,7 @@ To upgrade the standalone app later, rerun the installer. `feynman update` only
To uninstall the standalone app, remove the launcher and runtime bundle, then optionally remove `~/.feynman` if you also want to delete settings, sessions, and installed package state. If you also want to delete alphaXiv login state, remove `~/.ahub`. See the installation guide for platform-specific paths. To uninstall the standalone app, remove the launcher and runtime bundle, then optionally remove `~/.feynman` if you also want to delete settings, sessions, and installed package state. If you also want to delete alphaXiv login state, remove `~/.ahub`. See the installation guide for platform-specific paths.
Local models are supported through the setup flow. For LM Studio, run `feynman setup`, choose `LM Studio`, and keep the default `http://localhost:1234/v1` unless you changed the server port. For Ollama or vLLM, choose `Custom provider (baseUrl + API key)`, use `openai-completions`, and point it at the local `/v1` endpoint. Local models are supported through the setup flow. For LM Studio, run `feynman setup`, choose `LM Studio`, and keep the default `http://localhost:1234/v1` unless you changed the server port. For LiteLLM, choose `LiteLLM Proxy` and keep the default `http://localhost:4000/v1`. For Ollama or vLLM, choose `Custom provider (baseUrl + API key)`, use `openai-completions`, and point it at the local `/v1` endpoint.
### Skills Only ### Skills Only

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@companion-ai/feynman", "name": "@companion-ai/feynman",
"version": "0.2.24", "version": "0.2.28",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@companion-ai/feynman", "name": "@companion-ai/feynman",
"version": "0.2.24", "version": "0.2.28",
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@companion-ai/feynman", "name": "@companion-ai/feynman",
"version": "0.2.24", "version": "0.2.28",
"description": "Research-first CLI agent built on Pi and alphaXiv", "description": "Research-first CLI agent built on Pi and alphaXiv",
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",

View File

@@ -9,7 +9,7 @@ Audit the paper and codebase for: $@
Derive a short slug from the audit target (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run. Derive a short slug from the audit target (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run.
Requirements: Requirements:
- Before starting, outline the audit plan: which paper, which repo, which claims to check. Write the plan to `outputs/.plans/<slug>.md`. Present the plan to the user. If this is an unattended or one-shot run, continue automatically. If the user is actively interacting, give them a brief chance to request changes before proceeding. - Before starting, outline the audit plan: which paper, which repo, which claims to check. Write the plan to `outputs/.plans/<slug>.md`. Briefly summarize the plan to the user and continue immediately. Do not ask for confirmation or wait for a proceed response unless the user explicitly requested plan review.
- Use the `researcher` subagent for evidence gathering and the `verifier` subagent to verify sources and add inline citations when the audit is non-trivial. - Use the `researcher` subagent for evidence gathering and the `verifier` subagent to verify sources and add inline citations when the audit is non-trivial.
- Compare claimed methods, defaults, metrics, and data handling against the actual code. - Compare claimed methods, defaults, metrics, and data handling against the actual code.
- Call out missing code, mismatches, ambiguous defaults, and reproduction risks. - Call out missing code, mismatches, ambiguous defaults, and reproduction risks.

View File

@@ -9,7 +9,7 @@ Compare sources for: $@
Derive a short slug from the comparison topic (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run. Derive a short slug from the comparison topic (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run.
Requirements: Requirements:
- Before starting, outline the comparison plan: which sources to compare, which dimensions to evaluate, expected output structure. Write the plan to `outputs/.plans/<slug>.md`. Present the plan to the user. If this is an unattended or one-shot run, continue automatically. If the user is actively interacting, give them a brief chance to request changes before proceeding. - Before starting, outline the comparison plan: which sources to compare, which dimensions to evaluate, expected output structure. Write the plan to `outputs/.plans/<slug>.md`. Briefly summarize the plan to the user and continue immediately. Do not ask for confirmation or wait for a proceed response unless the user explicitly requested plan review.
- Use the `researcher` subagent to gather source material when the comparison set is broad, and the `verifier` subagent to verify sources and add inline citations to the final matrix. - Use the `researcher` subagent to gather source material when the comparison set is broad, and the `verifier` subagent to verify sources and add inline citations to the final matrix.
- Build a comparison matrix covering: source, key claim, evidence type, caveats, confidence. - Build a comparison matrix covering: source, key claim, evidence type, caveats, confidence.
- Generate charts with `pi-charts` when the comparison involves quantitative metrics. Use Mermaid for method or architecture comparisons. - Generate charts with `pi-charts` when the comparison involves quantitative metrics. Use Mermaid for method or architecture comparisons.

View File

@@ -51,7 +51,7 @@ If `CHANGELOG.md` exists, read the most recent relevant entries before finalizin
Also save the plan with `memory_remember` (type: `fact`, key: `deepresearch.<slug>.plan`) so it survives context truncation. Also save the plan with `memory_remember` (type: `fact`, key: `deepresearch.<slug>.plan`) so it survives context truncation.
Present the plan to the user. If this is an unattended or one-shot run, continue automatically. If the user is actively interacting in the terminal, give them a brief chance to request plan changes before proceeding. Briefly summarize the plan to the user and continue immediately. Do not ask for confirmation or wait for a proceed response unless the user explicitly requested plan review.
Do not stop after planning. If live search, subagents, web access, alphaXiv, or any other capability is unavailable, continue in degraded mode and write a durable blocked/partial report that records exactly which capabilities failed. Do not stop after planning. If live search, subagents, web access, alphaXiv, or any other capability is unavailable, continue in degraded mode and write a durable blocked/partial report that records exactly which capabilities failed.

View File

@@ -9,7 +9,7 @@ Write a paper-style draft for: $@
Derive a short slug from the topic (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run. Derive a short slug from the topic (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run.
Requirements: Requirements:
- Before writing, outline the draft structure: proposed title, sections, key claims to make, source material to draw from, and a verification log for the critical claims, figures, and calculations. Write the outline to `outputs/.plans/<slug>.md`. Present the outline to the user. If this is an unattended or one-shot run, continue automatically. If the user is actively interacting, give them a brief chance to request changes before proceeding. - Before writing, outline the draft structure: proposed title, sections, key claims to make, source material to draw from, and a verification log for the critical claims, figures, and calculations. Write the outline to `outputs/.plans/<slug>.md`. Briefly summarize the outline to the user and continue immediately. Do not ask for confirmation or wait for a proceed response unless the user explicitly requested outline review.
- Use the `writer` subagent when the draft should be produced from already-collected notes, then use the `verifier` subagent to add inline citations and verify sources. - Use the `writer` subagent when the draft should be produced from already-collected notes, then use the `verifier` subagent to add inline citations and verify sources.
- Include at minimum: title, abstract, problem statement, related work, method or synthesis, evidence or experiments, limitations, conclusion. - Include at minimum: title, abstract, problem statement, related work, method or synthesis, evidence or experiments, limitations, conclusion.
- Use clean Markdown with LaTeX where equations materially help. - Use clean Markdown with LaTeX where equations materially help.

View File

@@ -10,7 +10,7 @@ Derive a short slug from the topic (lowercase, hyphens, no filler words, ≤5 wo
## Workflow ## Workflow
1. **Plan** — Outline the scope: key questions, source types to search (papers, web, repos), time period, expected sections, and a small task ledger plus verification log. Write the plan to `outputs/.plans/<slug>.md`. Present the plan to the user. If this is an unattended or one-shot run, continue automatically. If the user is actively interacting, give them a brief chance to request changes before proceeding. 1. **Plan** — Outline the scope: key questions, source types to search (papers, web, repos), time period, expected sections, and a small task ledger plus verification log. Write the plan to `outputs/.plans/<slug>.md`. Briefly summarize the plan to the user and continue immediately. Do not ask for confirmation or wait for a proceed response unless the user explicitly requested plan review.
2. **Gather** — Use the `researcher` subagent when the sweep is wide enough to benefit from delegated paper triage before synthesis. For narrow topics, search directly. Researcher outputs go to `<slug>-research-*.md`. Do not silently skip assigned questions; mark them `done`, `blocked`, or `superseded`. 2. **Gather** — Use the `researcher` subagent when the sweep is wide enough to benefit from delegated paper triage before synthesis. For narrow topics, search directly. Researcher outputs go to `<slug>-research-*.md`. Do not silently skip assigned questions; mark them `done`, `blocked`, or `superseded`.
3. **Synthesize** — Separate consensus, disagreements, and open questions. When useful, propose concrete next experiments or follow-up reading. Generate charts with `pi-charts` for quantitative comparisons across papers and Mermaid diagrams for taxonomies or method pipelines. Before finishing the draft, sweep every strong claim against the verification log and downgrade anything that is inferred or single-source critical. 3. **Synthesize** — Separate consensus, disagreements, and open questions. When useful, propose concrete next experiments or follow-up reading. Generate charts with `pi-charts` for quantitative comparisons across papers and Mermaid diagrams for taxonomies or method pipelines. Before finishing the draft, sweep every strong claim against the verification log and downgrade anything that is inferred or single-source critical.
4. **Cite** — Spawn the `verifier` agent to add inline citations and verify every source URL in the draft. 4. **Cite** — Spawn the `verifier` agent to add inline citations and verify every source URL in the draft.

View File

@@ -9,7 +9,7 @@ Review this AI research artifact: $@
Derive a short slug from the artifact name (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run. Derive a short slug from the artifact name (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run.
Requirements: Requirements:
- Before starting, outline what will be reviewed, the review criteria (novelty, empirical rigor, baselines, reproducibility, etc.), and any verification-specific checks needed for claims, figures, and reported metrics. Present the plan to the user. If this is an unattended or one-shot run, continue automatically. If the user is actively interacting, give them a brief chance to request changes before proceeding. - Before starting, outline what will be reviewed, the review criteria (novelty, empirical rigor, baselines, reproducibility, etc.), and any verification-specific checks needed for claims, figures, and reported metrics. Briefly summarize the plan to the user and continue immediately. Do not ask for confirmation or wait for a proceed response unless the user explicitly requested plan review.
- Spawn a `researcher` subagent to gather evidence on the artifact — inspect the paper, code, cited work, and any linked experimental artifacts. Save to `<slug>-research.md`. - Spawn a `researcher` subagent to gather evidence on the artifact — inspect the paper, code, cited work, and any linked experimental artifacts. Save to `<slug>-research.md`.
- Spawn a `reviewer` subagent with `<slug>-research.md` to produce the final peer review with inline annotations. - Spawn a `reviewer` subagent with `<slug>-research.md` to produce the final peer review with inline annotations.
- For small or simple artifacts where evidence gathering is overkill, run the `reviewer` subagent directly instead. - For small or simple artifacts where evidence gathering is overkill, run the `reviewer` subagent directly instead.

View File

@@ -101,7 +101,7 @@ print(f"[summarize] chunks={len(chunks)} chunk_size={chunk_size} overlap={overla
### 3b. Confirm before spawning ### 3b. Confirm before spawning
If this is an unattended or one-shot run, continue automatically. Otherwise tell the user: "Source is ~<chars> chars -> <N> chunks -> <N> researcher subagents. This may take several minutes. Proceed?" Wait for confirmation before launching Tier 3. Briefly summarize: "Source is ~<chars> chars -> <N> chunks -> <N> researcher subagents. This may take several minutes." Then continue automatically. Do not ask for confirmation or wait for a proceed response unless the user explicitly requested review before launching.
### 3c. Dispatch researcher subagents ### 3c. Dispatch researcher subagents

View File

@@ -9,7 +9,7 @@ Create a research watch for: $@
Derive a short slug from the watch topic (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run. Derive a short slug from the watch topic (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run.
Requirements: Requirements:
- Before starting, outline the watch plan: what to monitor, what signals matter, what counts as a meaningful change, and the check frequency. Write the plan to `outputs/.plans/<slug>.md`. Present the plan to the user. If this is an unattended or one-shot run, continue automatically. If the user is actively interacting, give them a brief chance to request changes before proceeding. - Before starting, outline the watch plan: what to monitor, what signals matter, what counts as a meaningful change, and the check frequency. Write the plan to `outputs/.plans/<slug>.md`. Briefly summarize the plan to the user and continue immediately. Do not ask for confirmation or wait for a proceed response unless the user explicitly requested plan review.
- Start with a baseline sweep of the topic. - Start with a baseline sweep of the topic.
- Use `schedule_prompt` to create the recurring or delayed follow-up instead of merely promising to check later. - Use `schedule_prompt` to create the recurring or delayed follow-up instead of merely promising to check later.
- Save exactly one baseline artifact to `outputs/<slug>-baseline.md`. - Save exactly one baseline artifact to `outputs/<slug>-baseline.md`.

View File

@@ -110,7 +110,7 @@ This usually means the release exists, but not all platform bundles were uploade
Workarounds: Workarounds:
- try again after the release finishes publishing - try again after the release finishes publishing
- pass the latest published version explicitly, e.g.: - pass the latest published version explicitly, e.g.:
& ([scriptblock]::Create((irm https://feynman.is/install.ps1))) -Version 0.2.24 & ([scriptblock]::Create((irm https://feynman.is/install.ps1))) -Version 0.2.28
"@ "@
} }

View File

@@ -261,7 +261,7 @@ This usually means the release exists, but not all platform bundles were uploade
Workarounds: Workarounds:
- try again after the release finishes publishing - try again after the release finishes publishing
- pass the latest published version explicitly, e.g.: - pass the latest published version explicitly, e.g.:
curl -fsSL https://feynman.is/install | bash -s -- 0.2.24 curl -fsSL https://feynman.is/install | bash -s -- 0.2.28
EOF EOF
exit 1 exit 1
fi fi

View File

@@ -1,2 +1,3 @@
export const PI_SUBAGENTS_PATCH_TARGETS: string[]; export const PI_SUBAGENTS_PATCH_TARGETS: string[];
export function patchPiSubagentsSource(relativePath: string, source: string): string; export function patchPiSubagentsSource(relativePath: string, source: string): string;
export function stripPiSubagentBuiltinModelSource(source: string): string;

View File

@@ -66,6 +66,24 @@ function replaceAll(source, from, to) {
return source.split(from).join(to); return source.split(from).join(to);
} }
export function stripPiSubagentBuiltinModelSource(source) {
if (!source.startsWith("---\n")) {
return source;
}
const endIndex = source.indexOf("\n---", 4);
if (endIndex === -1) {
return source;
}
const frontmatter = source.slice(4, endIndex);
const nextFrontmatter = frontmatter
.split("\n")
.filter((line) => !/^\s*model\s*:/.test(line))
.join("\n");
return `---\n${nextFrontmatter}${source.slice(endIndex)}`;
}
export function patchPiSubagentsSource(relativePath, source) { export function patchPiSubagentsSource(relativePath, source) {
let patched = source; let patched = source;

View File

@@ -9,7 +9,7 @@ import { patchAlphaHubAuthSource } from "./lib/alpha-hub-auth-patch.mjs";
import { patchPiExtensionLoaderSource } from "./lib/pi-extension-loader-patch.mjs"; import { patchPiExtensionLoaderSource } from "./lib/pi-extension-loader-patch.mjs";
import { patchPiGoogleLegacySchemaSource } from "./lib/pi-google-legacy-schema-patch.mjs"; import { patchPiGoogleLegacySchemaSource } from "./lib/pi-google-legacy-schema-patch.mjs";
import { PI_WEB_ACCESS_PATCH_TARGETS, patchPiWebAccessSource } from "./lib/pi-web-access-patch.mjs"; import { PI_WEB_ACCESS_PATCH_TARGETS, patchPiWebAccessSource } from "./lib/pi-web-access-patch.mjs";
import { PI_SUBAGENTS_PATCH_TARGETS, patchPiSubagentsSource } from "./lib/pi-subagents-patch.mjs"; import { PI_SUBAGENTS_PATCH_TARGETS, patchPiSubagentsSource, stripPiSubagentBuiltinModelSource } from "./lib/pi-subagents-patch.mjs";
const here = dirname(fileURLToPath(import.meta.url)); const here = dirname(fileURLToPath(import.meta.url));
const appRoot = resolve(here, ".."); const appRoot = resolve(here, "..");
@@ -479,6 +479,19 @@ if (existsSync(piSubagentsRoot)) {
writeFileSync(entryPath, patched, "utf8"); writeFileSync(entryPath, patched, "utf8");
} }
} }
const builtinAgentsRoot = resolve(piSubagentsRoot, "agents");
if (existsSync(builtinAgentsRoot)) {
for (const entry of readdirSync(builtinAgentsRoot, { withFileTypes: true })) {
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
const entryPath = resolve(builtinAgentsRoot, entry.name);
const source = readFileSync(entryPath, "utf8");
const patched = stripPiSubagentBuiltinModelSource(source);
if (patched !== source) {
writeFileSync(entryPath, patched, "utf8");
}
}
}
} }
if (packageJsonPath && existsSync(packageJsonPath)) { if (packageJsonPath && existsSync(packageJsonPath)) {

View File

@@ -1,7 +1,9 @@
import { existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs"; import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
import { resolve } from "node:path"; import { resolve } from "node:path";
import { spawnSync } from "node:child_process"; import { spawnSync } from "node:child_process";
import { stripPiSubagentBuiltinModelSource } from "./lib/pi-subagents-patch.mjs";
const appRoot = resolve(import.meta.dirname, ".."); const appRoot = resolve(import.meta.dirname, "..");
const settingsPath = resolve(appRoot, ".feynman", "settings.json"); const settingsPath = resolve(appRoot, ".feynman", "settings.json");
const feynmanDir = resolve(appRoot, ".feynman"); const feynmanDir = resolve(appRoot, ".feynman");
@@ -10,7 +12,7 @@ const workspaceNodeModulesDir = resolve(workspaceDir, "node_modules");
const manifestPath = resolve(workspaceDir, ".runtime-manifest.json"); const manifestPath = resolve(workspaceDir, ".runtime-manifest.json");
const workspacePackageJsonPath = resolve(workspaceDir, "package.json"); const workspacePackageJsonPath = resolve(workspaceDir, "package.json");
const workspaceArchivePath = resolve(feynmanDir, "runtime-workspace.tgz"); const workspaceArchivePath = resolve(feynmanDir, "runtime-workspace.tgz");
const PRUNE_VERSION = 3; const PRUNE_VERSION = 4;
function readPackageSpecs() { function readPackageSpecs() {
const settings = JSON.parse(readFileSync(settingsPath, "utf8")); const settings = JSON.parse(readFileSync(settingsPath, "utf8"));
@@ -72,6 +74,17 @@ function writeWorkspacePackageJson() {
); );
} }
function childNpmInstallEnv() {
return {
...process.env,
// `npm pack --dry-run` exports dry-run config to lifecycle scripts. The
// vendored runtime workspace must still install real node_modules so the
// publish artifact can be validated without poisoning the archive.
npm_config_dry_run: "false",
NPM_CONFIG_DRY_RUN: "false",
};
}
function prepareWorkspace(packageSpecs) { function prepareWorkspace(packageSpecs) {
rmSync(workspaceDir, { recursive: true, force: true }); rmSync(workspaceDir, { recursive: true, force: true });
mkdirSync(workspaceDir, { recursive: true }); mkdirSync(workspaceDir, { recursive: true });
@@ -84,9 +97,9 @@ function prepareWorkspace(packageSpecs) {
const result = spawnSync( const result = spawnSync(
process.env.npm_execpath ? process.execPath : "npm", process.env.npm_execpath ? process.execPath : "npm",
process.env.npm_execpath process.env.npm_execpath
? [process.env.npm_execpath, "install", "--prefer-offline", "--no-audit", "--no-fund", "--loglevel", "error", "--prefix", workspaceDir, ...packageSpecs] ? [process.env.npm_execpath, "install", "--prefer-offline", "--no-audit", "--no-fund", "--no-dry-run", "--loglevel", "error", "--prefix", workspaceDir, ...packageSpecs]
: ["install", "--prefer-offline", "--no-audit", "--no-fund", "--loglevel", "error", "--prefix", workspaceDir, ...packageSpecs], : ["install", "--prefer-offline", "--no-audit", "--no-fund", "--no-dry-run", "--loglevel", "error", "--prefix", workspaceDir, ...packageSpecs],
{ stdio: "inherit" }, { stdio: "inherit", env: childNpmInstallEnv() },
); );
if (result.status !== 0) { if (result.status !== 0) {
process.exit(result.status ?? 1); process.exit(result.status ?? 1);
@@ -122,6 +135,25 @@ function pruneWorkspace() {
} }
} }
function stripBundledPiSubagentModelPins() {
const agentsRoot = resolve(workspaceNodeModulesDir, "pi-subagents", "agents");
if (!existsSync(agentsRoot)) {
return false;
}
let changed = false;
for (const entry of readdirSync(agentsRoot, { withFileTypes: true })) {
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
const entryPath = resolve(agentsRoot, entry.name);
const source = readFileSync(entryPath, "utf8");
const patched = stripPiSubagentBuiltinModelSource(source);
if (patched === source) continue;
writeFileSync(entryPath, patched, "utf8");
changed = true;
}
return changed;
}
function archiveIsCurrent() { function archiveIsCurrent() {
if (!existsSync(workspaceArchivePath) || !existsSync(manifestPath)) { if (!existsSync(workspaceArchivePath) || !existsSync(manifestPath)) {
return false; return false;
@@ -145,6 +177,10 @@ const packageSpecs = readPackageSpecs();
if (workspaceIsCurrent(packageSpecs)) { if (workspaceIsCurrent(packageSpecs)) {
console.log("[feynman] vendored runtime workspace already up to date"); console.log("[feynman] vendored runtime workspace already up to date");
if (stripBundledPiSubagentModelPins()) {
writeManifest(packageSpecs);
console.log("[feynman] stripped bundled pi-subagents model pins");
}
if (archiveIsCurrent()) { if (archiveIsCurrent()) {
process.exit(0); process.exit(0);
} }
@@ -157,6 +193,7 @@ if (workspaceIsCurrent(packageSpecs)) {
console.log("[feynman] preparing vendored runtime workspace..."); console.log("[feynman] preparing vendored runtime workspace...");
prepareWorkspace(packageSpecs); prepareWorkspace(packageSpecs);
pruneWorkspace(); pruneWorkspace();
stripBundledPiSubagentModelPins();
writeManifest(packageSpecs); writeManifest(packageSpecs);
createWorkspaceArchive(); createWorkspaceArchive();
console.log("[feynman] vendored runtime workspace ready"); console.log("[feynman] vendored runtime workspace ready");

View File

@@ -48,6 +48,7 @@ const PROVIDER_LABELS: Record<string, string> = {
huggingface: "Hugging Face", huggingface: "Hugging Face",
"amazon-bedrock": "Amazon Bedrock", "amazon-bedrock": "Amazon Bedrock",
"azure-openai-responses": "Azure OpenAI Responses", "azure-openai-responses": "Azure OpenAI Responses",
litellm: "LiteLLM Proxy",
}; };
const RESEARCH_MODEL_PREFERENCES = [ const RESEARCH_MODEL_PREFERENCES = [

View File

@@ -84,6 +84,7 @@ const API_KEY_PROVIDERS: ApiKeyProviderInfo[] = [
{ id: "anthropic", label: "Anthropic API", envVar: "ANTHROPIC_API_KEY" }, { id: "anthropic", label: "Anthropic API", envVar: "ANTHROPIC_API_KEY" },
{ id: "google", label: "Google Gemini API", envVar: "GEMINI_API_KEY" }, { id: "google", label: "Google Gemini API", envVar: "GEMINI_API_KEY" },
{ id: "lm-studio", label: "LM Studio (local OpenAI-compatible server)" }, { id: "lm-studio", label: "LM Studio (local OpenAI-compatible server)" },
{ id: "litellm", label: "LiteLLM Proxy (OpenAI-compatible gateway)" },
{ id: "__custom__", label: "Custom provider (local/self-hosted/proxy)" }, { id: "__custom__", label: "Custom provider (local/self-hosted/proxy)" },
{ id: "amazon-bedrock", label: "Amazon Bedrock (AWS credential chain)" }, { id: "amazon-bedrock", label: "Amazon Bedrock (AWS credential chain)" },
{ id: "openrouter", label: "OpenRouter", envVar: "OPENROUTER_API_KEY" }, { id: "openrouter", label: "OpenRouter", envVar: "OPENROUTER_API_KEY" },
@@ -127,15 +128,24 @@ export function resolveModelProviderForCommand(
return undefined; return undefined;
} }
function apiKeyProviderHint(provider: ApiKeyProviderInfo): string {
if (provider.id === "__custom__") {
return "Ollama, vLLM, LM Studio, proxies";
}
if (provider.id === "lm-studio") {
return "http://localhost:1234/v1";
}
if (provider.id === "litellm") {
return "http://localhost:4000/v1";
}
return provider.envVar ?? provider.id;
}
async function selectApiKeyProvider(): Promise<ApiKeyProviderInfo | undefined> { async function selectApiKeyProvider(): Promise<ApiKeyProviderInfo | undefined> {
const options: PromptSelectOption<ApiKeyProviderInfo | "cancel">[] = API_KEY_PROVIDERS.map((provider) => ({ const options: PromptSelectOption<ApiKeyProviderInfo | "cancel">[] = API_KEY_PROVIDERS.map((provider) => ({
value: provider, value: provider,
label: provider.label, label: provider.label,
hint: provider.id === "__custom__" hint: apiKeyProviderHint(provider),
? "Ollama, vLLM, LM Studio, proxies"
: provider.id === "lm-studio"
? "http://localhost:1234/v1"
: provider.envVar ?? provider.id,
})); }));
options.push({ value: "cancel", label: "Cancel" }); options.push({ value: "cancel", label: "Cancel" });
@@ -403,6 +413,65 @@ async function promptLmStudioProviderSetup(): Promise<CustomProviderSetup | unde
}; };
} }
async function promptLiteLlmProviderSetup(): Promise<CustomProviderSetup | undefined> {
printSection("LiteLLM Proxy");
printInfo("Start the LiteLLM proxy first. Feynman uses the OpenAI-compatible chat-completions API.");
const baseUrlRaw = await promptText("Base URL", "http://localhost:4000/v1");
const { baseUrl } = normalizeCustomProviderBaseUrl("openai-completions", baseUrlRaw);
if (!baseUrl) {
printWarning("Base URL is required.");
return undefined;
}
const keyChoices = [
"Yes (use LITELLM_MASTER_KEY and send Authorization: Bearer <key>)",
"No (proxy runs without authentication)",
"Cancel",
];
const keySelection = await promptChoice("Is the proxy protected by a master key?", keyChoices, 0);
if (keySelection >= 2) {
return undefined;
}
const hasKey = keySelection === 0;
const apiKeyConfig = hasKey ? "LITELLM_MASTER_KEY" : "local";
const authHeader = hasKey;
if (hasKey) {
printInfo("Set LITELLM_MASTER_KEY in your shell or .env before using Feynman.");
}
const resolvedKey = hasKey ? await resolveApiKeyConfig(apiKeyConfig) : apiKeyConfig;
const detectedModelIds = resolvedKey
? await bestEffortFetchOpenAiModelIds(baseUrl, resolvedKey, authHeader)
: undefined;
let modelIdsDefault = "gpt-4";
if (detectedModelIds && detectedModelIds.length > 0) {
const sample = detectedModelIds.slice(0, 10).join(", ");
printInfo(`Detected LiteLLM models: ${sample}${detectedModelIds.length > 10 ? ", ..." : ""}`);
modelIdsDefault = detectedModelIds[0]!;
} else {
printInfo("No models detected from /models. Enter the model id(s) from your LiteLLM config.");
}
const modelIdsRaw = await promptText("Model id(s) (comma-separated)", modelIdsDefault);
const modelIds = normalizeModelIds(modelIdsRaw);
if (modelIds.length === 0) {
printWarning("At least one model id is required.");
return undefined;
}
return {
providerId: "litellm",
modelIds,
baseUrl,
api: "openai-completions",
apiKeyConfig,
authHeader,
};
}
async function verifyCustomProvider(setup: CustomProviderSetup, authPath: string): Promise<void> { async function verifyCustomProvider(setup: CustomProviderSetup, authPath: string): Promise<void> {
const registry = createModelRegistry(authPath); const registry = createModelRegistry(authPath);
const modelsError = registry.getError(); const modelsError = registry.getError();
@@ -614,6 +683,31 @@ async function configureApiKeyProvider(authPath: string, providerId?: string): P
return true; return true;
} }
if (provider.id === "litellm") {
const setup = await promptLiteLlmProviderSetup();
if (!setup) {
printInfo("LiteLLM setup cancelled.");
return false;
}
const modelsJsonPath = getModelsJsonPath(authPath);
const result = upsertProviderConfig(modelsJsonPath, setup.providerId, {
baseUrl: setup.baseUrl,
apiKey: setup.apiKeyConfig,
api: setup.api,
authHeader: setup.authHeader,
models: setup.modelIds.map((id) => ({ id })),
});
if (!result.ok) {
printWarning(result.error);
return false;
}
printSuccess("Saved LiteLLM provider.");
await verifyCustomProvider(setup, authPath);
return true;
}
if (provider.id === "__custom__") { if (provider.id === "__custom__") {
const setup = await promptCustomProviderSetup(); const setup = await promptCustomProviderSetup();
if (!setup) { if (!setup) {

View File

@@ -169,6 +169,15 @@ function resolvePackageManagerCommand(settingsManager: SettingsManager): { comma
return { command: executable, args }; return { command: executable, args };
} }
function childPackageManagerEnv(): NodeJS.ProcessEnv {
return {
...process.env,
PATH: getPathWithCurrentNode(process.env.PATH),
npm_config_dry_run: "false",
NPM_CONFIG_DRY_RUN: "false",
};
}
async function runPackageManagerInstall( async function runPackageManagerInstall(
settingsManager: SettingsManager, settingsManager: SettingsManager,
workingDir: string, workingDir: string,
@@ -207,10 +216,7 @@ async function runPackageManagerInstall(
const child = spawn(packageManagerCommand.command, args, { const child = spawn(packageManagerCommand.command, args, {
cwd: scope === "user" ? agentDir : workingDir, cwd: scope === "user" ? agentDir : workingDir,
stdio: ["ignore", "pipe", "pipe"], stdio: ["ignore", "pipe", "pipe"],
env: { env: childPackageManagerEnv(),
...process.env,
PATH: getPathWithCurrentNode(process.env.PATH),
},
}); });
child.stdout?.on("data", (chunk) => relayFilteredOutput(chunk, process.stdout)); child.stdout?.on("data", (chunk) => relayFilteredOutput(chunk, process.stdout));

View File

@@ -69,3 +69,31 @@ test("deepresearch workflow requires durable artifacts even when blocked", () =>
assert.match(deepResearchPrompt, /Verification: BLOCKED/i); assert.match(deepResearchPrompt, /Verification: BLOCKED/i);
assert.match(deepResearchPrompt, /Never end with only an explanation in chat/i); assert.match(deepResearchPrompt, /Never end with only an explanation in chat/i);
}); });
test("workflow prompts do not introduce implicit confirmation gates", () => {
const workflowPrompts = [
"audit.md",
"compare.md",
"deepresearch.md",
"draft.md",
"lit.md",
"review.md",
"summarize.md",
"watch.md",
];
const bannedConfirmationGates = [
/Do you want to proceed/i,
/Wait for confirmation/i,
/wait for user confirmation/i,
/give them a brief chance/i,
/request changes before proceeding/i,
];
for (const fileName of workflowPrompts) {
const content = readFileSync(join(repoRoot, "prompts", fileName), "utf8");
assert.match(content, /continue (immediately|automatically)/i, `${fileName} should keep running after planning`);
for (const pattern of bannedConfirmationGates) {
assert.doesNotMatch(content, pattern, `${fileName} contains confirmation gate ${pattern}`);
}
}
});

View File

@@ -88,6 +88,15 @@ test("resolveModelProviderForCommand supports LM Studio as a first-class local p
assert.equal(resolved?.id, "lm-studio"); assert.equal(resolved?.id, "lm-studio");
}); });
test("resolveModelProviderForCommand supports LiteLLM as a first-class proxy provider", () => {
const authPath = createAuthPath({});
const resolved = resolveModelProviderForCommand(authPath, "litellm");
assert.equal(resolved?.kind, "api-key");
assert.equal(resolved?.id, "litellm");
});
test("resolveModelProviderForCommand prefers OAuth when a provider supports both auth modes", () => { test("resolveModelProviderForCommand prefers OAuth when a provider supports both auth modes", () => {
const authPath = createAuthPath({}); const authPath = createAuthPath({});

View File

@@ -30,3 +30,45 @@ test("upsertProviderConfig creates models.json and merges provider config", () =
assert.equal(parsed.providers.custom.authHeader, true); assert.equal(parsed.providers.custom.authHeader, true);
assert.deepEqual(parsed.providers.custom.models, [{ id: "llama3.1:8b" }]); assert.deepEqual(parsed.providers.custom.models, [{ id: "llama3.1:8b" }]);
}); });
test("upsertProviderConfig writes LiteLLM proxy config with master key", () => {
const dir = mkdtempSync(join(tmpdir(), "feynman-litellm-"));
const modelsPath = join(dir, "models.json");
const result = upsertProviderConfig(modelsPath, "litellm", {
baseUrl: "http://localhost:4000/v1",
apiKey: "LITELLM_MASTER_KEY",
api: "openai-completions",
authHeader: true,
models: [{ id: "gpt-4o" }],
});
assert.deepEqual(result, { ok: true });
const parsed = JSON.parse(readFileSync(modelsPath, "utf8")) as any;
assert.equal(parsed.providers.litellm.baseUrl, "http://localhost:4000/v1");
assert.equal(parsed.providers.litellm.apiKey, "LITELLM_MASTER_KEY");
assert.equal(parsed.providers.litellm.api, "openai-completions");
assert.equal(parsed.providers.litellm.authHeader, true);
assert.deepEqual(parsed.providers.litellm.models, [{ id: "gpt-4o" }]);
});
test("upsertProviderConfig writes LiteLLM proxy config without master key", () => {
const dir = mkdtempSync(join(tmpdir(), "feynman-litellm-"));
const modelsPath = join(dir, "models.json");
const result = upsertProviderConfig(modelsPath, "litellm", {
baseUrl: "http://localhost:4000/v1",
apiKey: "local",
api: "openai-completions",
authHeader: false,
models: [{ id: "llama3" }],
});
assert.deepEqual(result, { ok: true });
const parsed = JSON.parse(readFileSync(modelsPath, "utf8")) as any;
assert.equal(parsed.providers.litellm.baseUrl, "http://localhost:4000/v1");
assert.equal(parsed.providers.litellm.apiKey, "local");
assert.equal(parsed.providers.litellm.api, "openai-completions");
assert.equal(parsed.providers.litellm.authHeader, false);
assert.deepEqual(parsed.providers.litellm.models, [{ id: "llama3" }]);
});

View File

@@ -188,6 +188,46 @@ test("installPackageSources skips native packages on unsupported Node majors bef
} }
}); });
test("installPackageSources disables inherited npm dry-run config for child installs", async () => {
const root = mkdtempSync(join(tmpdir(), "feynman-package-ops-"));
const workingDir = resolve(root, "project");
const agentDir = resolve(root, "agent");
const markerPath = resolve(root, "install-env-ok.txt");
mkdirSync(workingDir, { recursive: true });
const scriptPath = writeFakeNpmScript(root, [
`import { writeFileSync } from "node:fs";`,
`if (process.env.npm_config_dry_run !== "false" || process.env.NPM_CONFIG_DRY_RUN !== "false") process.exit(42);`,
`writeFileSync(${JSON.stringify(markerPath)}, "ok\\n", "utf8");`,
"process.exit(0);",
].join("\n"));
writeSettings(agentDir, {
npmCommand: [process.execPath, scriptPath],
});
const originalLower = process.env.npm_config_dry_run;
const originalUpper = process.env.NPM_CONFIG_DRY_RUN;
process.env.npm_config_dry_run = "true";
process.env.NPM_CONFIG_DRY_RUN = "true";
try {
const result = await installPackageSources(workingDir, agentDir, ["npm:test-package"]);
assert.deepEqual(result.installed, ["npm:test-package"]);
assert.equal(existsSync(markerPath), true);
} finally {
if (originalLower === undefined) {
delete process.env.npm_config_dry_run;
} else {
process.env.npm_config_dry_run = originalLower;
}
if (originalUpper === undefined) {
delete process.env.NPM_CONFIG_DRY_RUN;
} else {
process.env.NPM_CONFIG_DRY_RUN = originalUpper;
}
}
});
test("updateConfiguredPackages batches multiple npm updates into a single install per scope", async () => { test("updateConfiguredPackages batches multiple npm updates into a single install per scope", async () => {
const root = mkdtempSync(join(tmpdir(), "feynman-package-ops-")); const root = mkdtempSync(join(tmpdir(), "feynman-package-ops-"));
const workingDir = resolve(root, "project"); const workingDir = resolve(root, "project");
@@ -218,7 +258,7 @@ test("updateConfiguredPackages batches multiple npm updates into a single instal
globalThis.fetch = (async () => ({ globalThis.fetch = (async () => ({
ok: true, ok: true,
json: async () => ({ version: "2.0.0" }), json: async () => ({ version: "2.0.0" }),
})) as typeof fetch; })) as unknown as typeof fetch;
try { try {
const result = await updateConfiguredPackages(workingDir, agentDir); const result = await updateConfiguredPackages(workingDir, agentDir);
@@ -266,7 +306,7 @@ test("updateConfiguredPackages skips native package updates on unsupported Node
globalThis.fetch = (async () => ({ globalThis.fetch = (async () => ({
ok: true, ok: true,
json: async () => ({ version: "2.0.0" }), json: async () => ({ version: "2.0.0" }),
})) as typeof fetch; })) as unknown as typeof fetch;
Object.defineProperty(process.versions, "node", { value: "25.0.0", configurable: true }); Object.defineProperty(process.versions, "node", { value: "25.0.0", configurable: true });
try { try {

View File

@@ -1,7 +1,7 @@
import test from "node:test"; import test from "node:test";
import assert from "node:assert/strict"; import assert from "node:assert/strict";
import { patchPiSubagentsSource } from "../scripts/lib/pi-subagents-patch.mjs"; import { patchPiSubagentsSource, stripPiSubagentBuiltinModelSource } from "../scripts/lib/pi-subagents-patch.mjs";
const CASES = [ const CASES = [
{ {
@@ -140,3 +140,22 @@ test("patchPiSubagentsSource rewrites modern agents.ts discovery paths", () => {
assert.ok(!patched.includes('loadChainsFromDir(userDirNew, "user")')); assert.ok(!patched.includes('loadChainsFromDir(userDirNew, "user")'));
assert.ok(!patched.includes('fs.existsSync(userDirNew) ? userDirNew : userDirOld')); assert.ok(!patched.includes('fs.existsSync(userDirNew) ? userDirNew : userDirOld'));
}); });
test("stripPiSubagentBuiltinModelSource removes built-in model pins", () => {
const input = [
"---",
"name: researcher",
"description: Web researcher",
"model: anthropic/claude-sonnet-4-6",
"tools: read, web_search",
"---",
"",
"Body",
].join("\n");
const patched = stripPiSubagentBuiltinModelSource(input);
assert.ok(!patched.includes("model: anthropic/claude-sonnet-4-6"));
assert.match(patched, /name: researcher/);
assert.match(patched, /tools: read, web_search/);
});

View File

@@ -261,7 +261,7 @@ This usually means the release exists, but not all platform bundles were uploade
Workarounds: Workarounds:
- try again after the release finishes publishing - try again after the release finishes publishing
- pass the latest published version explicitly, e.g.: - pass the latest published version explicitly, e.g.:
curl -fsSL https://feynman.is/install | bash -s -- 0.2.24 curl -fsSL https://feynman.is/install | bash -s -- 0.2.28
EOF EOF
exit 1 exit 1
fi fi

View File

@@ -110,7 +110,7 @@ This usually means the release exists, but not all platform bundles were uploade
Workarounds: Workarounds:
- try again after the release finishes publishing - try again after the release finishes publishing
- pass the latest published version explicitly, e.g.: - pass the latest published version explicitly, e.g.:
& ([scriptblock]::Create((irm https://feynman.is/install.ps1))) -Version 0.2.24 & ([scriptblock]::Create((irm https://feynman.is/install.ps1))) -Version 0.2.28
"@ "@
} }

View File

@@ -117,13 +117,13 @@ These installers download the bundled `skills/` and `prompts/` trees plus the re
The one-line installer already targets the latest tagged release. To pin an exact version, pass it explicitly: The one-line installer already targets the latest tagged release. To pin an exact version, pass it explicitly:
```bash ```bash
curl -fsSL https://feynman.is/install | bash -s -- 0.2.24 curl -fsSL https://feynman.is/install | bash -s -- 0.2.28
``` ```
On Windows: On Windows:
```powershell ```powershell
& ([scriptblock]::Create((irm https://feynman.is/install.ps1))) -Version 0.2.24 & ([scriptblock]::Create((irm https://feynman.is/install.ps1))) -Version 0.2.28
``` ```
## Post-install setup ## Post-install setup

View File

@@ -52,7 +52,7 @@ Amazon Bedrock (AWS credential chain)
Feynman verifies the same AWS credential chain Pi uses at runtime, including `AWS_PROFILE`, `~/.aws` credentials/config, SSO, ECS/IRSA, and EC2 instance roles. Once that check passes, Bedrock models become available in `feynman model list` without needing a traditional API key. Feynman verifies the same AWS credential chain Pi uses at runtime, including `AWS_PROFILE`, `~/.aws` credentials/config, SSO, ECS/IRSA, and EC2 instance roles. Once that check passes, Bedrock models become available in `feynman model list` without needing a traditional API key.
### Local models: LM Studio, Ollama, vLLM ### Local models: LM Studio, LiteLLM, Ollama, vLLM
If you want to use LM Studio, start the LM Studio local server, load a model, choose the API-key flow, and then select: If you want to use LM Studio, start the LM Studio local server, load a model, choose the API-key flow, and then select:
@@ -70,6 +70,22 @@ API key: lm-studio
Feynman attempts to read LM Studio's `/models` endpoint and prefill the loaded model id. Feynman attempts to read LM Studio's `/models` endpoint and prefill the loaded model id.
For LiteLLM, start the proxy, choose the API-key flow, and then select:
```text
LiteLLM Proxy (OpenAI-compatible gateway)
```
The default settings are:
```text
Base URL: http://localhost:4000/v1
API mode: openai-completions
Master key: optional, read from LITELLM_MASTER_KEY
```
Feynman attempts to read LiteLLM's `/models` endpoint and prefill model ids from the proxy config.
For Ollama, vLLM, or another OpenAI-compatible local server, choose: For Ollama, vLLM, or another OpenAI-compatible local server, choose:
```text ```text