Tooling that extracts the system prompts baked into the
@sourcegraph/amp CLI bundle and
writes human-readable Markdown files under prompts/ and skills/.
The Amp bundle ships as a single minified dist/main.js. Each prompt is a
template literal that often takes feature-flag arguments (e.g. enableOracle,
enableDiagnostics) and references other minified identifiers like R4, V6,
AA. This repo:
- Pins
@sourcegraph/ampas a normal dependency so Dependabot can open a PR each time a new bundle is published. - Parses the installed bundle with
@babel/parser, locates every arrow function or template literal whose body looks like a prompt, and evaluates it inside anode:vmsandbox. - The sandbox's globals are a
Proxywhose backing map is built from everyname = "value"assignment in the bundle, so a reference toR4resolves to the string"finder",V6to"Read", and so on. Any identifier we can't resolve is filled in with a permissive proxy that coerces to""and is callable, so methods likedirs.map(...)don't throw. - Each prompt-builder function is invoked with all boolean flags forced to
true, so optional sections (oracle, diagnostics, check mode) are always included.
bun install
bun run extractThe script writes:
prompts/<name>.md— one file per prompt. The filename is derived from Amp's ownbasePromptTypeswitch when the bundle exposes one, then from a curated substring lookup table (seeKNOWN_PROMPTSinextract-amp-prompts.mjs), then from heuristics that read the first "You are …" line. This keeps public Amp names from the Owner's Manual and models page (smart,deep,rush,review,search,oracle,librarian) when a prompt can be tied back to Amp's mode/subagent wiring. Trivial prompts (single sentence, no real content) are dropped, as are exact-text duplicates.subagents/<name>.md— one file per extracted subagent prompt. These are specialized secondary-agent surfaces such as review, search, oracle, and librarian.skills/<name>.md— one file per extracted skill prompt. Skill-like prompts are separated from ordinary prompts so the generated catalog is easier to scan.- the generated catalog below — an index linking to every generated file, with the bundle version it was extracted from.
Source: node_modules/@sourcegraph/amp/dist/main.js Package: @sourcegraph/amp@0.0.1780827515-ga4daec
Notes:
- Extracted by parsing the bundle with
@babel/parser, locating prompt-producing arrow functions and template literals, then evaluating each in anode:vmsandbox. - Free identifiers (e.g.
R4,V6) are resolved through a Proxy whose backing map was built fromname = "value"assignments in the bundle. - Boolean feature-flag parameters (oracle/diagnostics/check-mode etc.) are forced
trueso all optional sections are included. - Main and utility prompts are written under
prompts/; subagent prompts undersubagents/; skill prompts underskills/.
- prompt — line 744
- subagent-summary — line 1527
- thread-reader — line 2473
- ai-assistant — line 2588
- review — line 1730
- code-review-skill — line 1040
@sourcegraph/amp is pinned exactly in package.json. The workflow at
.github/workflows/update-amp.yml runs daily, can also be triggered manually,
asks the npm registry for the latest published version with bun pm view,
updates the exact pin with bun add, runs bun run extract, and opens a PR
labelled amp-bump.
The workflow at .github/workflows/regenerate-prompts.yml also listens for
amp-bump PRs that touch package.json / bun.lock, runs bun run extract,
and pushes any regenerated prompt files back onto the same PR branch. This
keeps manual amp-bump PRs and workflow-created amp-bump PRs consistent. It
also enables auto-merge for amp-bump PRs opened by github-actions[bot] or
hearnadam.
extract-amp-prompts.mjs # the extractor
package.json # pins @sourcegraph/amp
.github/workflows/update-amp.yml
.github/workflows/regenerate-prompts.yml
prompts/ # generated; refreshed by the workflow
subagents/ # generated subagent prompts
skills/ # generated skill prompts
README.md # includes the generated catalog
- Heuristic naming will sometimes pick a wordy name for a brand-new prompt
Amp ships. When that happens, add a substring entry to
KNOWN_PROMPTSin the extractor and re-run. - A prompt whose body is shorter than ~200 characters is dropped on the
assumption that it's a trivial guard message rather than a real prompt.
Adjust
MIN_BODY_CHARSif that turns out to filter too aggressively. - Free identifiers that map to functions (rather than strings) fall back to
the permissive proxy. If a future Amp release hits a code path that
actually needs the real function, the extractor will silently render
""where that call would have produced text.