How getcompanion-ai/feynman works
1. Top-level shape
- This repo is a two-part product: a Node-based CLI application at the root, and a separate Astro documentation website under website/.
- The CLI is the runtime product; the website is the public docs/install portal and mirrors the same workflows, agents, and tool references.
2. User-facing entry points
- The main executable is bin/feynman.js, which boots the CLI from src/index.ts and src/cli.ts.
- The CLI surface is organized around research workflows like deepresearch, lit, review, audit, replicate, compare, draft, autoresearch, and watch, with slash-command style shortcuts reflected in src/model/commands.ts and src/search/commands.ts.
3. Core runtime boundary: Pi
- The repository is built on Pi as the agent runtime. The src/pi/ subtree contains the integration layer for launching Pi, configuring settings, packaging presets, and web access.
- Several scripts/lib/pi-*patch.* files and scripts/patch-embedded-pi.mjs indicate the repo vendors and patches embedded Pi dependencies to control behavior like extension loading, subagents, legacy schema handling, and web-access hooks.
4. Research workflow engine
- The research behavior is mostly defined as skills and prompts, not hardcoded application logic.
- skills/ contains the reusable skill library; prompts/ contains workflow prompts; .feynman/agents/ contains agent role definitions; and extensions/research-tools/ provides tool-specific extensions used by those workflows.
- The data flow is: user command → CLI command dispatch → Pi agent runtime → skill/prompt selection → tool-enabled research execution → generated artifact in outputs/.
5. Agent roles
- The bundled roles are Researcher, Reviewer, Writer, and Verifier.
- These are not separate services; they are instructions and policies that shape how the same runtime behaves for evidence gathering, peer-review simulation, drafting, and citation verification.
6. Model and provider subsystem
- src/model/ handles model cataloging, registry resolution, service tiers, and the model metadata consumed by the CLI/setup flow.
- The README’s “custom provider” path shows the architecture supports OpenAI-compatible local or remote model endpoints via a base URL + API key model, which is how Ollama and similar providers can be plugged in.
7. Search and source acquisition
- src/web-search.ts and the extensions/research-tools/ layer provide the main external-source acquisition path.
- The repo explicitly integrates AlphaXiv, web search, and session search; these are the main ingestion boundaries for source-grounded research outputs.
- The important architectural boundary is that the CLI does not “own” the data sources; it orchestrates external retrieval tools and then synthesizes/cites them.
8. Execution and compute extensions
- Compute-heavy workflows are handled via skills and tools, not by the CLI itself.
- The repository supports Docker, Modal, and RunPod through dedicated skills, which means long-running or GPU-backed tasks are delegated to external execution environments rather than the local terminal process.
9. Setup, bootstrap, and environment control
- src/setup/ covers installation/doctor/preview/setup flows, while src/bootstrap/ handles sync-related startup work.
- src/system/ contains OS and runtime adapters like executable discovery, Node version checks, URL opening, and promise polyfills.
- These modules form the “environment boundary” around the CLI so it can reliably run across macOS/Linux/Windows and enforce the required Node/runtime constraints.
10. Skill distribution and installation
- The repo treats skills as a distributable artifact. scripts/install/ and scripts/sync-website-installers.mjs generate the public installer paths, while skills-lock.json pins what gets distributed.
- The README distinguishes between a full terminal app install and a skills-only install, which is important architecturally: skills are portable content, while the CLI includes runtime, auth storage, and bundled Pi packages.
11. Generated outputs and artifacts
- Research artifacts are written to outputs/, with supporting folders like notes/, papers/, and experiments/ used as working areas.
- This suggests a clear separation between input sources, working state, and published/generated deliverables.
12. Website as documentation and installer host
- website/ is a standalone Astro app that publishes the docs for commands, agents, tools, and workflows.
- It also serves the public installer assets under website/public/, making the website part of the delivery pipeline for the CLI and skills distribution.
13. Validation and release pipeline
- The tests under tests/ cover config paths, model catalog behavior, Pi patches, node-version checks, URL opening, and skill paths, which are the main architecture seams most likely to break.
- .github/workflows/publish.yml plus the build scripts indicate a release process that produces installable artifacts and likely the standalone bundled distribution referenced in the README.
14. What to draw in an architecture diagram
- A good diagram would show: User/terminal → CLI entrypoint → command dispatcher → Pi runtime + skills/prompts → external tools (search, AlphaXiv, session search, web, compute providers) → generated outputs.
- In parallel, show the docs website as a separate deployment that publishes documentation and installer scripts, and the skills installer path as a content-only distribution channel distinct from the full app.
Main entry points: runtime.ts Pi runtime · docs Docs content · cli.ts Commands · research-tools.ts Tools ext
Components 21
CLI runtime
Node-based application that boots the terminal product and orchestrates research workflows.
- CLI entry · Main executable that starts the terminal app.
bin/feynman.js - App bootstrap · CLI startup and top-level command wiring.
src/index.ts - Commands · Primary workflow command surface for research actions.
src/cli.ts - Search cmds · Slash-style search and source-acquisition commands.
src/search/commands.ts - Model cmds · Model-related command and setup surfaces.
src/model/commands.ts - Model core · Catalog, registry, and service-tier resolution for models.
src/model/catalog.ts - Pi runtime · Integration layer for launching and configuring the embedded Pi agent runtime.
src/pi/runtime.ts - Pi launch · Startup and packaging path for Pi execution.
src/pi/launch.ts - Setup · Doctor, preview, and installation flows for local readiness.
src/setup/setup.ts - System adapters · OS/runtime helpers for executables, Node checks, and URL opening.
src/system/executables.ts - Web search · External search and retrieval boundary for source-grounded research.
src/web-search.ts
Research content
Reusable prompts, skills, agent roles, and tool extensions that define behavior.
- Agents · Researcher, reviewer, writer, and verifier role instructions.
.feynman/agents - Skills · Reusable skill library that encodes research and compute workflows.
skills - Prompts · Prompt templates for deep research, review, drafting, and related flows.
prompts - Tools ext · Research tool extensions for alphaxiv, discovery, session search, and helpers.
extensions/research-tools.ts - Pi patches · Embedded Pi override layer for extension loading, web access, subagents, and schema compatibility.
.feynman/vendor-overrides - Outputs · Generated research artifacts and working outputs.
outputs - Installers · Scripts and generated installers for full app and skills-only distribution.
scripts/install
Docs website
Standalone Astro app that publishes documentation and installer assets.
- Docs site · Standalone documentation and installer portal.
website - Docs content · Published docs for commands, agents, tools, workflows, and setup.
website/src/content/docs - Public assets · Installer files and public downloadable assets served by the website.
website/public
Connections 24
- CLI entry → App bootstrap: starts · Executable boots the application runtime.
- App bootstrap → Commands: routes · Top-level CLI dispatches user actions into workflows.
- Commands → Model cmds: uses · Model-related commands feed setup and resolution flows.
- Commands → Search cmds: uses · Search and slash commands expose source-acquisition actions.
- Commands → Pi runtime: orchestrates · CLI delegates workflow execution to the embedded agent runtime.
- Pi runtime → Pi launch: launches · Runtime startup and packaging are handled through the launch layer.
- Pi runtime → Model core: selects models · Agent runtime depends on model catalog and service-tier resolution.
- Pi runtime → Agents: applies roles · Runtime behavior is shaped by agent instructions and policies.
- Pi runtime → Skills: executes · Skills supply the reusable workflow behavior.
- Pi runtime → Prompts: templates · Prompts steer each research workflow.
- Pi runtime → Tools ext: uses tools · Tool extensions provide external capabilities and source access.
- Tools ext → Web search: retrieves · Search tools connect to web and source providers.
- Tools ext → Outputs: writes · Research workflows produce artifacts in the outputs area.
- Setup → System adapters: checks · Setup flows validate the host environment and runtime constraints.
- Setup → Model core: configures · Setup and doctor flows use model metadata.
- Pi patches → Pi runtime: patches · Vendor overrides modify embedded Pi behavior and compatibility.
- Installers → Skills: packages · Skill distribution is separated from the full runtime.
- Installers → Docs site: publishes · Installer assets are synced into the website delivery path.
- Docs site → Docs content: renders · Astro site publishes docs content.
- Docs site → Public assets: serves · Website hosts public install artifacts.
- Docs content → Agents: documents · Docs describe the bundled agent roles.
- Docs content → Skills: documents · Docs describe the skill workflows and usage.
- Docs content → Tools ext: documents · Docs cover the key tool integrations.
- Docs content → Prompts: documents · Docs explain the workflow prompts and commands.