From 94507a118669dcf2b73b6bbea04ad96f92ef5a54 Mon Sep 17 00:00:00 2001 From: Raghav Chari Date: Mon, 15 Jun 2026 11:58:44 -0400 Subject: [PATCH 1/9] feat(extension): rewrite AGENTS.md for D9/D10 script authoring; relocate to package root Co-Authored-By: Claude Opus 4.8 (1M context) --- AGENTS.md | 71 ----------------------- packages/extension/AGENTS.md | 56 ++++++++++++++++++ packages/extension/test/agents_md.test.ts | 23 ++++++++ 3 files changed, 79 insertions(+), 71 deletions(-) delete mode 100644 AGENTS.md create mode 100644 packages/extension/AGENTS.md create mode 100644 packages/extension/test/agents_md.test.ts diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index 1a1bc40a4..000000000 --- a/AGENTS.md +++ /dev/null @@ -1,71 +0,0 @@ -# Amicode project context - -This is the Amicode VS Code extension's per-session opencode project. You're -running here so a developer can iterate on quantum-optimal-control pulses -without leaving their editor. - -## Your tools (use bash, not MCP) - -There is **no MCP server** in this project. The single domain-specific tool -is a CLI binary you invoke via the `bash` tool: - -### `amico-run` - -Solves for an optimal control pulse using Piccolo / Piccolissimo (Julia). -Writes per-iteration PNGs + a final result.toml to disk; the VS Code Run -Inspector panel auto-refreshes as the solve runs. - -**Invoke via:** - -```bash -amico-run --system \ - --gate \ - --pulse \ - [--T-ns ] [--omega-cap ] [--max-iter ] -``` - -`amico-run --help` prints full usage. - -**Arg guidance** (pick sensible defaults if the user doesn't specify): - -- `--system`: `qubit` for textbook Pauli (X/Y/Z drift); `transmon` for the - physical 4-level Duffing model. Default `transmon` if the user mentions - "qubit hardware," "transmon," "leakage," or any GHz frequency. Default - `qubit` if they say "toy example" or "Pauli." -- `--gate`: literally what they asked for. `X`/`Y`/`Z`/`H`/`S`/`T` are 1q; - `CNOT`/`CZ`/`SWAP`/`iSWAP` are 2q. (`CNOT` and `CX` are aliases.) -- `--pulse`: `zero-order` (piecewise-constant) is the safe default and runs - faster. `linear-spline` for smoother controls when the user asks about - bandwidth, smoothness, or DRAG-style shaping. -- `--T-ns`: default 10 ns for `qubit`, 24 ns for `transmon` 1q gates, - ~150-300 ns for 2q gates. Don't pass if the user didn't specify. -- `--omega-cap`: transmon-only; default 0.05 (50 MHz). Above 0.15 GHz the - RWA / weak-anharmonic approximation degrades. -- `--max-iter`: leave off unless the user explicitly limits or extends. - -**Hazard checks** (call these out to the user *before* invoking the tool): - -- transmon + 1q + T < 20 ns → likely F ≲ 0.95; suggest T ~30-40 ns or higher ω cap. -- transmon + 2q + T < 150 ns → likely won't converge; suggest 150-300 ns. -- transmon + omega_cap > 0.15 GHz → expect leakage to |2⟩; rollout vs solver F will diverge. - -**Output**: - -Each run lands in `/tmp/amicode-runs//` and the symlink -`/tmp/amicode-runs/latest` points at it. The user sees the live iter PNGs -in the VS Code Run Inspector panel — you don't have to display them. - -When `amico-run` finishes, it prints a one-line `DONE` summary with the -fidelity. Quote that back to the user. If F ≥ 0.99, the extension will -automatically prompt them to promote the pulse to the catalog — you don't -need to ask. - -## Style - -- Be terse. The user is a quantum-control researcher; don't explain quantum - mechanics unless asked. -- Run `amico-run --help` first if you're unsure of an arg. -- If a run fails, read `/tmp/amicode-runs/latest/run.log` for the actual - julia traceback before guessing. -- Don't suggest installing new Julia packages. The dev environment is - pinned at `/tmp/amicode-spike-julia` and the user maintains it. diff --git a/packages/extension/AGENTS.md b/packages/extension/AGENTS.md new file mode 100644 index 000000000..e2584f13c --- /dev/null +++ b/packages/extension/AGENTS.md @@ -0,0 +1,56 @@ +# Amicode project context + +You help a quantum-control researcher synthesize optimal-control pulses with +Piccolo (Julia) without leaving VS Code. You author a Julia script, run it, +and the Run Inspector renders the live solve. + +## Workflow (this is the whole job) + +1. Read the bundled template `solve_template.jl` in this project dir. +2. Copy it to a working file (e.g. `solve.jl`) and fill in the `# FILL IN` + parameter block from the user's request: transmon frequency `ω` (GHz), + anharmonicity `δ` (GHz), `levels`, the target gate, gate time `T` (ns), + timesteps `N`, `max_iter`. **Parameters live in the script — never in this + file.** If the user gives a `lab.toml` path, read it in the script. +3. Run it via the `bash` tool: `amico-run --project solve.jl` + (use the project path provided below). `amico-run` takes only a script path + and runner flags — it parses **no** physics options; all the physics lives + in the script you wrote. +4. When it finishes, quote the final `DONE fidelity=…` line. If F ≥ 0.99 the + extension prompts promotion automatically — don't ask. + +There is **no MCP server**. The only tool is `amico-run` via bash. +`amico-run --help` prints usage. + +## The run-dir contract your script MUST emit + +`amico-run` writes `manifest.toml` (first) and `FINISHED` (last) itself. Your +script, running with cwd = the run dir, must emit: + +- `AMICODE_ITER iter= f= inf_pr=<…> inf_du=<…>` to stdout, flushed, + once per Ipopt iteration (drives the live stats row). +- `iter_.png` every few iterations (the live plot the Inspector shows). +- `result.toml`, written **atomically** (write `result.toml.tmp`, then `mv`), + with at least `fidelity` (float) and `iterations` (int). +- `pulse.jld2` (the solved pulse) via `JLD2.save`. +- a final `DONE fidelity=<…>` line. + +The template already does all of this — you only fill in numbers. + +## Warm-start idiom + +To seed from a previous solve: `traj = load_traj("path/to/pulse.jld2")` and +pass it as the initial guess to the problem constructor. `load_traj` is the +correct loader in this Piccolo. + +## Julia project + + The Julia project to pass as `--project` is: +**{{JULIA_PROJECT}}**. Always pass it. If it reads `UNSET`, omit `--project` +and tell the user `amicode.juliaProject` is not configured. + +## Style + +Terse — the user is a quantum-control researcher. On failure, read the run's +`run.log` for the Julia traceback before guessing. Don't suggest installing +Julia packages; the environment is provisioned. diff --git a/packages/extension/test/agents_md.test.ts b/packages/extension/test/agents_md.test.ts new file mode 100644 index 000000000..56fa288e7 --- /dev/null +++ b/packages/extension/test/agents_md.test.ts @@ -0,0 +1,23 @@ +import { describe, it, expect } from 'vitest' +import { readFileSync } from 'node:fs' +import { join } from 'node:path' + +const AGENTS = readFileSync(join(__dirname, '..', 'AGENTS.md'), 'utf8') + +describe('AGENTS.md teaches the D9/D10 script-authoring workflow', () => { + it('points at the bundled template and the amico-run