@bastani/atomic 0.9.56-alpha.1 → 0.9.57-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +24 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/agent-desktop/SKILL.md +83 -0
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +12 -0
- package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
- package/dist/builtin/workflows/builtin/{chunk-49kkbdpr.js → chunk-2f1shjah.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-dcxscfnb.js → chunk-37gm3bzk.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-2jfst7e4.js → chunk-45fn5q5p.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-hx8v4p97.js → chunk-4ek3v2wm.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-z3pajrfs.js → chunk-8d40nyz9.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-qhm35ntx.js → chunk-g3b2zf8r.js} +2 -2
- package/dist/builtin/workflows/builtin/{chunk-6jpwc09k.js → chunk-h6bt0r0g.js} +2 -2
- package/dist/builtin/workflows/builtin/{chunk-9cm2ckq2.js → chunk-x25rjw4y.js} +4 -4
- package/dist/builtin/workflows/builtin/{chunk-apagcs4r.js → chunk-xqcy5nve.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-w4xp1w1f.js → chunk-yb55w6me.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-k5q3t7je.js → chunk-yjgfnbgd.js} +1 -1
- package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
- package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
- package/dist/builtin/workflows/builtin/goal.js +3 -3
- package/dist/builtin/workflows/builtin/index.js +11 -11
- package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
- package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +3 -3
- package/dist/builtin/workflows/builtin/steering-context.js +1 -1
- package/dist/builtin/workflows/builtin/tournament.js +3 -3
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +7 -7
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +4 -4
- package/dist/builtin/workflows/src/index.js +4 -4
- package/dist/builtin/workflows/src/local-worker-entry.mjs +4 -4
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +2 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/docs/computer-use.md +119 -98
- package/docs/getting-started/first-session.md +1 -1
- package/docs/skills.md +2 -2
- package/docs/usage.md +1 -1
- package/docs/workflows/authoring.md +105 -141
- package/docs/workflows/verification.md +14 -13
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
- package/dist/builtin/subagents/skills/cua-driver/BROWSER.md +0 -562
- package/dist/builtin/subagents/skills/cua-driver/EMBEDDING.md +0 -685
- package/dist/builtin/subagents/skills/cua-driver/LINUX.md +0 -412
- package/dist/builtin/subagents/skills/cua-driver/MACOS.md +0 -996
- package/dist/builtin/subagents/skills/cua-driver/README.md +0 -123
- package/dist/builtin/subagents/skills/cua-driver/RECORDING.md +0 -132
- package/dist/builtin/subagents/skills/cua-driver/RUNTIME.md +0 -115
- package/dist/builtin/subagents/skills/cua-driver/SKILL.md +0 -108
- package/dist/builtin/subagents/skills/cua-driver/VISUAL.md +0 -125
- package/dist/builtin/subagents/skills/cua-driver/WINDOWS.md +0 -832
- package/dist/builtin/subagents/skills/cua-driver/WORKFLOW.md +0 -226
|
@@ -56217,10 +56217,10 @@ var init_shared_prompts = __esm(() => {
|
|
|
56217
56217
|
`);
|
|
56218
56218
|
E2E_VERIFICATION_GUIDANCE = [
|
|
56219
56219
|
"Verify correctness end-to-end whenever practical for user-visible behavior; an executable scenario is stronger proof than code inspection, unit tests, or stage summaries alone.",
|
|
56220
|
-
'For web or frontend flows, including frontend changes whose correctness depends on backend/API behavior, use the agent-browser skill or delegate with `skill: "agent-browser"`; capture snapshot, screenshot, DOM, or network evidence suited to the objective. Prefer agent-browser for what its skill covers, because its text snapshots cost far fewer tokens than screenshot-driven
|
|
56220
|
+
'For web or frontend flows, including frontend changes whose correctness depends on backend/API behavior, use the agent-browser skill or delegate with `skill: "agent-browser"`; capture snapshot, screenshot, DOM, or network evidence suited to the objective. Prefer agent-browser for what its skill covers, because its text snapshots cost far fewer tokens than screenshot-driven computer use (websites and web apps in Chrome/Chromium, Mobile Safari in the iOS Simulator via `agent-browser -p ios`, Electron desktop apps and other CDP-exposing apps, Slack, cloud browsers); use agent-desktop for native desktop apps, OS dialogs and browser chrome outside the page, and whenever agent-browser hits a limitation. Native iOS apps in the iOS Simulator and Android emulators are outside agent-desktop: use `xcrun simctl`, Appium/XCUITest or `adb`/UI Automator, and report the gap when none is available.',
|
|
56221
56221
|
"For TUI/terminal automation/testing, prefer the herdr skill on macOS, Linux and Windows. Install Herdr if missing when network access and permissions permit; fall back to the tmux skill or native Windows psmux if installation or use is not possible. Preserve the pinned herdr skill's explicit-request and HERDR_ENV=1 requirements; never control a focused session from outside Herdr. Check installed help: psmux uses tmux-style commands, while herdr has its own CLI, not interchangeable flags. Exercise the actual interactive flow and retain pane/text or terminal recording evidence.",
|
|
56222
|
-
"For desktop and
|
|
56223
|
-
"Also
|
|
56222
|
+
"For native desktop apps and OS dialogs, use agent-desktop: when a model chooses the next action, as in this stage, load Atomic's bundled agent-desktop skill and run one-shot `agent-desktop` commands, following its snapshot -> act -> wait or fresh read -> verify loop; when workflow TypeScript code owns the sequence and the postcondition, call the `agent-desktop` CLI from inside `ctx.tool(name, args, fn, { timeoutMs })` instead, spawning one process per command, parsing its JSON envelope and forwarding `signal`. Before the first action, run `agent-desktop status`, `agent-desktop skills get desktop` and `agent-desktop skills get platform` and follow them; they are compiled into the binary, so they match the installed version. Ensure the executable (`agent-desktop version`; if missing, one bounded attempt with `npm install -g agent-desktop`, approving its install script if npm blocks it, and report its side effects). Atomic bundles the skill: never `npx skills add` it, and do not link or copy a skill into `~/.agents/skills` or other agent directories; leave any existing user-level skill alone. agent-desktop documents no telemetry, so no opt-out setting is needed. Ensure readiness with bounded attempts per docs/computer-use.md: on macOS `permissions.accessibility` granted (and `screen_recording` for screenshots), on Linux a non-empty `supported_surfaces`. Save the snapshot JSON, `screenshot` PNGs and, when a session traces, the `trace export` HTML to the artifacts directory as evidence. Verify each postcondition with `wait --element <ref> --predicate value --value <text>` or a fresh read, never a sleep; a successful action proves delivery, not the effect, and an action is retried only when `disposition.retry` is `safe`. Report a missing macOS permission, a Windows session that is not the interactive desktop, no graphical Linux session or AT-SPI bus, or a refused or failed install as the stage's blocked/needs_human finding with the exact fix (for macOS: `agent-desktop permissions --guide`, then the user approves it; for an install: `npm install -g agent-desktop`), and re-run `agent-desktop status` on resume. Use a dedicated desktop/session and controlled fixtures, inspect snapshots for other windows, and stop before destructive actions. agent-desktop reads accessibility trees and does not match pixels: for a UI that publishes none, a screenshot with `--headed` coordinate input is the only route and needs the user's permission, so say what stayed unverified. It does not drive native iOS or Android apps inside a simulator or emulator: use `xcrun simctl`, Appium/XCUITest or `adb`/UI Automator. Do not automate an arbitrary physical iPhone without an accessible simulator/emulator/mirroring or native automation setup, or label a Chrome recording as terminal or native iOS proof; an agent-browser `-p ios` session proves Mobile Safari behavior, not a native iOS app.",
|
|
56223
|
+
"Also never run `npx skills add` for agent-desktop or install a skill into other agent directories such as `~/.claude/skills`; updating the executable is separate from installing or updating a skill.",
|
|
56224
56224
|
"Choose tools from observed environment capabilities. Prefer installed/cached tools; install missing tools, runtimes or plugins when online access and permissions permit. Known offline/restricted installation is sufficient evidence not to attempt prohibited downloads; otherwise check capabilities or make one bounded setup attempt. Do not loop on blocked downloads, require production credentials, or take unsafe actions.",
|
|
56225
56225
|
"When execution or installation is unavailable, continue available authoritative repository checks and retain useful local evidence. Report the constraint or attempted command with observed output, what could not run, and the narrower validation performed. For non-UI tasks, use relevant executable checks rather than manufacturing a UI scenario. An unavailable optional mechanism is not itself failed implementation or permission to relax required project checks."
|
|
56226
56226
|
].join(`
|
|
@@ -56234,7 +56234,7 @@ var init_shared_prompts = __esm(() => {
|
|
|
56234
56234
|
`);
|
|
56235
56235
|
MEDIA_PUBLICATION_GUIDANCE = [
|
|
56236
56236
|
"Detect the repository provider and authorized PR/MR/issue/comment target before publishing media. Inspect and redact screenshots/video for secrets, personal information and unrelated windows; tie evidence to the verified commit and scenario. Local evidence collection does not authorize uploads.",
|
|
56237
|
-
"When creating the PR/MR, gather the image and video evidence the verification stages produced and attach it to the PR body when the provider supports uploads:
|
|
56237
|
+
"When creating the PR/MR, gather the image and video evidence the verification stages produced and attach it to the PR body when the provider supports uploads: agent-desktop `screenshot` before/after PNGs, agent-browser `screenshot` PNGs and `record` recordings, and any QA proof video. Reference each file in the body next to the scenario it proves (a before/after pair per verified postcondition, one recording per interaction) and keep the snapshot JSON as a local artifact the body cites by name. On supported GitHub, pass them at creation: gh pr create --body-file <body.md> --attach 'before.png#State before the action' --attach 'after.png#State after the action' --attach flow.webm; use gh pr edit/comment --attach for evidence produced later.",
|
|
56238
56238
|
"On GitHub, check gh --version and the chosen command's --help. GitHub CLI >=2.99.0 supports repeatable --attach on gh issue create/edit/comment and gh pr create/edit/comment. Use native attachments when supported, for example gh pr comment <number> --repo <owner/repo> --body-file <body.md> --attach <proof.mp4>. Attach each file once. Body-local path references are rewritten to hosted URLs; otherwise attachments append in flag order. Image path#alt text is supported; video alt text is not. A standalone  paragraph becomes an embedded player.",
|
|
56239
56239
|
"Check current GitHub limits: PNG/JPEG/GIF/WebP/SVG images and MP4/MOV/WebM videos; images/GIFs up to 10 MB, video 10 MB on Free or 100 MB paid. Native attachment upload requires repository write access and supported OAuth/classic PAT auth; GitHub Enterprise Server is unsupported in this release. See https://docs.github.com/en/github-cli/github-cli/attaching-files-with-github-cli.",
|
|
56240
56240
|
"Read back the returned PR/issue/comment and confirm usable GitHub-hosted links before claiming attachment success. Unsupported CLI versions, hosts, providers, auth or sizes require a truthful fallback: retain the local artifact and explain authorized manual attachment or supported provider options. Never claim file:// links are uploaded evidence, expose secrets, or upload automatically to unrelated third-party hosts."
|
|
@@ -106000,10 +106000,10 @@ var DEFAULT_PROMPT_GUIDANCE = [
|
|
|
106000
106000
|
- For transcripts, avoid whole-file reads. Get \`sessionFile\`/\`transcriptPath\` from \`stages\` or \`stage\`, preserve the exact path and platform separators, search with \`rg\`/\`grep\`, and read small relevant ranges; use explicit \`tail\` or \`limit\` only for a bounded preview.`,
|
|
106001
106001
|
`**Workflow authoring and handoffs**:
|
|
106002
106002
|
- When a user asks to create or edit a workflow, clarify only unresolved requirements that materially affect its purpose, inputs, stages, handoffs, validation, success criteria, or starter pattern. Read the workflow docs/examples, implement the TypeScript definition with normal coding tools, reload it, and run representative test inputs before presenting it. Use the create-spec skill when it adds value; it is not mandatory when context is already sufficient.
|
|
106003
|
-
- Author domain-appropriate verification and truthful evidence into worker, reviewer and final handoff prompts: agent-browser for what its skill covers (websites and web apps in Chrome/Chromium, Mobile Safari in the iOS Simulator via \`agent-browser -p ios\`, Electron desktop apps and other CDP-exposing apps, Slack, cloud browsers) and
|
|
106004
|
-
- Atomic bundles the
|
|
106003
|
+
- Author domain-appropriate verification and truthful evidence into worker, reviewer and final handoff prompts: agent-browser for what its skill covers (websites and web apps in Chrome/Chromium, Mobile Safari in the iOS Simulator via \`agent-browser -p ios\`, Electron desktop apps and other CDP-exposing apps, Slack, cloud browsers) and agent-desktop for native desktop apps, OS dialogs and browser chrome outside the page, or whenever agent-browser hits a limitation (native iOS apps in the Simulator and Android emulators are outside agent-desktop: use \`xcrun simctl\`, Appium/XCUITest or \`adb\`/UI Automator and report the gap when none is available); prefer herdr for terminal automation/testing on macOS, Linux and Windows, install it if missing when permitted, and fall back to tmux/native Windows psmux when installation or use is not possible. Preserve the herdr skill's explicit-request and HERDR_ENV=1 requirements. For native desktop apps use agent-desktop with one rule for the face: when a model chooses the next action (any workflow stage acting outside \`ctx.tool\`), use the agent-desktop skill and one-shot \`agent-desktop\` commands; when workflow TypeScript code owns the sequence and the postcondition, call the \`agent-desktop\` CLI from inside \`ctx.tool(name, args, fn, { timeoutMs })\`, spawning one process per command, parsing its JSON envelope, forwarding \`signal\` and setting a positive finite \`timeoutMs\`, and run the readiness preflight as its own \`ctx.tool\` that checks \`agent-desktop status\` and calls \`ctx.exit({ status: "blocked", reason })\` on a missing macOS permission or an absent Linux AT-SPI bus; a blocked author exit is terminal and not resumable, so after the user grants the permission start a new run, whose fresh preflight checks again. There is no TypeScript SDK; the CLI's JSON envelope is the contract. agent-desktop documents no telemetry, so no opt-out environment is needed; the install is \`npm install -g agent-desktop\` (node 18 or later), one bounded attempt, and a refused or failed install is reported as the limitation. Use dedicated sessions and permissions, and stop before destructive actions. Exercise actual scenarios, not Chrome recordings presented as terminal or native iOS proof. See docs/workflows/verification.md, docs/workflows/authoring.md and docs/computer-use.md for source-backed commands and safety.
|
|
106004
|
+
- Atomic bundles the agent-desktop skill. Do not run \`npx skills add\` for it, and do not link or copy another skill into user-level agent directories. Leave existing user-level skills alone.
|
|
106005
106005
|
- Choose verification tools from observed installed/cached capabilities. Install missing tools/plugins when online permissions permit; known offline/restricted environments need no prohibited download attempt, otherwise use a bounded setup check. Continue available authoritative repository checks and report what could not run. During authorized coding, initialize missing qlty config or hand-author .qlty/qlty.toml from bundled references; preserve existing/read-only config, select useful low-noise checks and baseline metrics, and distinguish prepared configuration from executed checks. Optional qlty installation is not a universal blocker.
|
|
106006
|
-
- For authorized media publication, detect the provider, inspect/redact commit-and-scenario evidence, and on supported GitHub use gh >=2.99.0 native repeatable --attach on issue/pr create/edit/comment after checking installed help. When a final stage creates the PR, attach the image and video evidence the run produced (
|
|
106006
|
+
- For authorized media publication, detect the provider, inspect/redact commit-and-scenario evidence, and on supported GitHub use gh >=2.99.0 native repeatable --attach on issue/pr create/edit/comment after checking installed help. When a final stage creates the PR, attach the image and video evidence the run produced (agent-desktop \`screenshot\` before/after PNGs, agent-browser screenshots and \`record\` recordings) to the PR body with \`gh pr create --body-file <body.md> --attach <file>\`, each referenced next to the scenario it proves. Read back hosted links before claiming success; unsupported hosts/versions/providers retain truthful local/manual fallback. Do not upload secrets or use unrelated hosts.
|
|
106007
106007
|
- After creating and reloading a newly authored custom workflow, close the loop by stating the folder containing the workflow file just written, for example \`.atomic/workflows/\`, in this shape: \`Custom workflow created. You can inspect its code at: <workflow-folder-path>\`. Do this only for newly created custom workflows, never builtin or pre-existing workflows.
|
|
106008
106008
|
- Keep a small, readable workflow in one entry file and write it for human maintainers. Keep the graph and control flow visible in the top-level workflow entry file, use stage names that state each stage's responsibility, and make its inputs, outputs, evidence, and success contract explicit. A developer reading the entry file from top to bottom should be able to identify the graph, branches, gates, artifacts, and stop conditions. Avoid both monolithic prompt blobs and gratuitous fragmentation. Do not split short one-use prompts, create one file per stage, add wrapper-only modules, hide the graph across files, or use line counts alone as a module boundary.
|
|
106009
106009
|
- When a meaningful source boundary improves clarity, reuse, ownership, or testability, keep the graph and control flow in the top-level workflow entry file and extract cohesive concerns such as long or reused prompt builders, shared TypeBox schemas and workflow-specific types, model-policy constants shared by several stages, deterministic helpers with their own testable behavior, or reusable child workflow definitions into a subdirectory below the top-level discovery directory — either one owned by a single workflow or a shared support directory. Project and user discovery scans only top-level \`.ts\`/\`.js\`/\`.mjs\`/\`.cjs\` files in the workflow directory, so those support modules are not scanned as extra top-level workflow candidates; use \`.js\` import extensions from TypeScript source.
|
|
@@ -52944,10 +52944,10 @@ var init_shared_prompts = __esm(() => {
|
|
|
52944
52944
|
`);
|
|
52945
52945
|
E2E_VERIFICATION_GUIDANCE = [
|
|
52946
52946
|
"Verify correctness end-to-end whenever practical for user-visible behavior; an executable scenario is stronger proof than code inspection, unit tests, or stage summaries alone.",
|
|
52947
|
-
'For web or frontend flows, including frontend changes whose correctness depends on backend/API behavior, use the agent-browser skill or delegate with `skill: "agent-browser"`; capture snapshot, screenshot, DOM, or network evidence suited to the objective. Prefer agent-browser for what its skill covers, because its text snapshots cost far fewer tokens than screenshot-driven
|
|
52947
|
+
'For web or frontend flows, including frontend changes whose correctness depends on backend/API behavior, use the agent-browser skill or delegate with `skill: "agent-browser"`; capture snapshot, screenshot, DOM, or network evidence suited to the objective. Prefer agent-browser for what its skill covers, because its text snapshots cost far fewer tokens than screenshot-driven computer use (websites and web apps in Chrome/Chromium, Mobile Safari in the iOS Simulator via `agent-browser -p ios`, Electron desktop apps and other CDP-exposing apps, Slack, cloud browsers); use agent-desktop for native desktop apps, OS dialogs and browser chrome outside the page, and whenever agent-browser hits a limitation. Native iOS apps in the iOS Simulator and Android emulators are outside agent-desktop: use `xcrun simctl`, Appium/XCUITest or `adb`/UI Automator, and report the gap when none is available.',
|
|
52948
52948
|
"For TUI/terminal automation/testing, prefer the herdr skill on macOS, Linux and Windows. Install Herdr if missing when network access and permissions permit; fall back to the tmux skill or native Windows psmux if installation or use is not possible. Preserve the pinned herdr skill's explicit-request and HERDR_ENV=1 requirements; never control a focused session from outside Herdr. Check installed help: psmux uses tmux-style commands, while herdr has its own CLI, not interchangeable flags. Exercise the actual interactive flow and retain pane/text or terminal recording evidence.",
|
|
52949
|
-
"For desktop and
|
|
52950
|
-
"Also
|
|
52949
|
+
"For native desktop apps and OS dialogs, use agent-desktop: when a model chooses the next action, as in this stage, load Atomic's bundled agent-desktop skill and run one-shot `agent-desktop` commands, following its snapshot -> act -> wait or fresh read -> verify loop; when workflow TypeScript code owns the sequence and the postcondition, call the `agent-desktop` CLI from inside `ctx.tool(name, args, fn, { timeoutMs })` instead, spawning one process per command, parsing its JSON envelope and forwarding `signal`. Before the first action, run `agent-desktop status`, `agent-desktop skills get desktop` and `agent-desktop skills get platform` and follow them; they are compiled into the binary, so they match the installed version. Ensure the executable (`agent-desktop version`; if missing, one bounded attempt with `npm install -g agent-desktop`, approving its install script if npm blocks it, and report its side effects). Atomic bundles the skill: never `npx skills add` it, and do not link or copy a skill into `~/.agents/skills` or other agent directories; leave any existing user-level skill alone. agent-desktop documents no telemetry, so no opt-out setting is needed. Ensure readiness with bounded attempts per docs/computer-use.md: on macOS `permissions.accessibility` granted (and `screen_recording` for screenshots), on Linux a non-empty `supported_surfaces`. Save the snapshot JSON, `screenshot` PNGs and, when a session traces, the `trace export` HTML to the artifacts directory as evidence. Verify each postcondition with `wait --element <ref> --predicate value --value <text>` or a fresh read, never a sleep; a successful action proves delivery, not the effect, and an action is retried only when `disposition.retry` is `safe`. Report a missing macOS permission, a Windows session that is not the interactive desktop, no graphical Linux session or AT-SPI bus, or a refused or failed install as the stage's blocked/needs_human finding with the exact fix (for macOS: `agent-desktop permissions --guide`, then the user approves it; for an install: `npm install -g agent-desktop`), and re-run `agent-desktop status` on resume. Use a dedicated desktop/session and controlled fixtures, inspect snapshots for other windows, and stop before destructive actions. agent-desktop reads accessibility trees and does not match pixels: for a UI that publishes none, a screenshot with `--headed` coordinate input is the only route and needs the user's permission, so say what stayed unverified. It does not drive native iOS or Android apps inside a simulator or emulator: use `xcrun simctl`, Appium/XCUITest or `adb`/UI Automator. Do not automate an arbitrary physical iPhone without an accessible simulator/emulator/mirroring or native automation setup, or label a Chrome recording as terminal or native iOS proof; an agent-browser `-p ios` session proves Mobile Safari behavior, not a native iOS app.",
|
|
52950
|
+
"Also never run `npx skills add` for agent-desktop or install a skill into other agent directories such as `~/.claude/skills`; updating the executable is separate from installing or updating a skill.",
|
|
52951
52951
|
"Choose tools from observed environment capabilities. Prefer installed/cached tools; install missing tools, runtimes or plugins when online access and permissions permit. Known offline/restricted installation is sufficient evidence not to attempt prohibited downloads; otherwise check capabilities or make one bounded setup attempt. Do not loop on blocked downloads, require production credentials, or take unsafe actions.",
|
|
52952
52952
|
"When execution or installation is unavailable, continue available authoritative repository checks and retain useful local evidence. Report the constraint or attempted command with observed output, what could not run, and the narrower validation performed. For non-UI tasks, use relevant executable checks rather than manufacturing a UI scenario. An unavailable optional mechanism is not itself failed implementation or permission to relax required project checks."
|
|
52953
52953
|
].join(`
|
|
@@ -52961,7 +52961,7 @@ var init_shared_prompts = __esm(() => {
|
|
|
52961
52961
|
`);
|
|
52962
52962
|
MEDIA_PUBLICATION_GUIDANCE = [
|
|
52963
52963
|
"Detect the repository provider and authorized PR/MR/issue/comment target before publishing media. Inspect and redact screenshots/video for secrets, personal information and unrelated windows; tie evidence to the verified commit and scenario. Local evidence collection does not authorize uploads.",
|
|
52964
|
-
"When creating the PR/MR, gather the image and video evidence the verification stages produced and attach it to the PR body when the provider supports uploads:
|
|
52964
|
+
"When creating the PR/MR, gather the image and video evidence the verification stages produced and attach it to the PR body when the provider supports uploads: agent-desktop `screenshot` before/after PNGs, agent-browser `screenshot` PNGs and `record` recordings, and any QA proof video. Reference each file in the body next to the scenario it proves (a before/after pair per verified postcondition, one recording per interaction) and keep the snapshot JSON as a local artifact the body cites by name. On supported GitHub, pass them at creation: gh pr create --body-file <body.md> --attach 'before.png#State before the action' --attach 'after.png#State after the action' --attach flow.webm; use gh pr edit/comment --attach for evidence produced later.",
|
|
52965
52965
|
"On GitHub, check gh --version and the chosen command's --help. GitHub CLI >=2.99.0 supports repeatable --attach on gh issue create/edit/comment and gh pr create/edit/comment. Use native attachments when supported, for example gh pr comment <number> --repo <owner/repo> --body-file <body.md> --attach <proof.mp4>. Attach each file once. Body-local path references are rewritten to hosted URLs; otherwise attachments append in flag order. Image path#alt text is supported; video alt text is not. A standalone  paragraph becomes an embedded player.",
|
|
52966
52966
|
"Check current GitHub limits: PNG/JPEG/GIF/WebP/SVG images and MP4/MOV/WebM videos; images/GIFs up to 10 MB, video 10 MB on Free or 100 MB paid. Native attachment upload requires repository write access and supported OAuth/classic PAT auth; GitHub Enterprise Server is unsupported in this release. See https://docs.github.com/en/github-cli/github-cli/attaching-files-with-github-cli.",
|
|
52967
52967
|
"Read back the returned PR/issue/comment and confirm usable GitHub-hosted links before claiming attachment success. Unsupported CLI versions, hosts, providers, auth or sizes require a truthful fallback: retain the local artifact and explain authorized manual attachment or supported provider options. Never claim file:// links are uploaded evidence, expose secrets, or upload automatically to unrelated third-party hosts."
|
|
@@ -53067,10 +53067,10 @@ var init_shared_prompts = __esm(() => {
|
|
|
53067
53067
|
`);
|
|
53068
53068
|
E2E_VERIFICATION_GUIDANCE = [
|
|
53069
53069
|
"Verify correctness end-to-end whenever practical for user-visible behavior; an executable scenario is stronger proof than code inspection, unit tests, or stage summaries alone.",
|
|
53070
|
-
'For web or frontend flows, including frontend changes whose correctness depends on backend/API behavior, use the agent-browser skill or delegate with `skill: "agent-browser"`; capture snapshot, screenshot, DOM, or network evidence suited to the objective. Prefer agent-browser for what its skill covers, because its text snapshots cost far fewer tokens than screenshot-driven
|
|
53070
|
+
'For web or frontend flows, including frontend changes whose correctness depends on backend/API behavior, use the agent-browser skill or delegate with `skill: "agent-browser"`; capture snapshot, screenshot, DOM, or network evidence suited to the objective. Prefer agent-browser for what its skill covers, because its text snapshots cost far fewer tokens than screenshot-driven computer use (websites and web apps in Chrome/Chromium, Mobile Safari in the iOS Simulator via `agent-browser -p ios`, Electron desktop apps and other CDP-exposing apps, Slack, cloud browsers); use agent-desktop for native desktop apps, OS dialogs and browser chrome outside the page, and whenever agent-browser hits a limitation. Native iOS apps in the iOS Simulator and Android emulators are outside agent-desktop: use `xcrun simctl`, Appium/XCUITest or `adb`/UI Automator, and report the gap when none is available.',
|
|
53071
53071
|
"For TUI/terminal automation/testing, prefer the herdr skill on macOS, Linux and Windows. Install Herdr if missing when network access and permissions permit; fall back to the tmux skill or native Windows psmux if installation or use is not possible. Preserve the pinned herdr skill's explicit-request and HERDR_ENV=1 requirements; never control a focused session from outside Herdr. Check installed help: psmux uses tmux-style commands, while herdr has its own CLI, not interchangeable flags. Exercise the actual interactive flow and retain pane/text or terminal recording evidence.",
|
|
53072
|
-
"For desktop and
|
|
53073
|
-
"Also
|
|
53072
|
+
"For native desktop apps and OS dialogs, use agent-desktop: when a model chooses the next action, as in this stage, load Atomic's bundled agent-desktop skill and run one-shot `agent-desktop` commands, following its snapshot -> act -> wait or fresh read -> verify loop; when workflow TypeScript code owns the sequence and the postcondition, call the `agent-desktop` CLI from inside `ctx.tool(name, args, fn, { timeoutMs })` instead, spawning one process per command, parsing its JSON envelope and forwarding `signal`. Before the first action, run `agent-desktop status`, `agent-desktop skills get desktop` and `agent-desktop skills get platform` and follow them; they are compiled into the binary, so they match the installed version. Ensure the executable (`agent-desktop version`; if missing, one bounded attempt with `npm install -g agent-desktop`, approving its install script if npm blocks it, and report its side effects). Atomic bundles the skill: never `npx skills add` it, and do not link or copy a skill into `~/.agents/skills` or other agent directories; leave any existing user-level skill alone. agent-desktop documents no telemetry, so no opt-out setting is needed. Ensure readiness with bounded attempts per docs/computer-use.md: on macOS `permissions.accessibility` granted (and `screen_recording` for screenshots), on Linux a non-empty `supported_surfaces`. Save the snapshot JSON, `screenshot` PNGs and, when a session traces, the `trace export` HTML to the artifacts directory as evidence. Verify each postcondition with `wait --element <ref> --predicate value --value <text>` or a fresh read, never a sleep; a successful action proves delivery, not the effect, and an action is retried only when `disposition.retry` is `safe`. Report a missing macOS permission, a Windows session that is not the interactive desktop, no graphical Linux session or AT-SPI bus, or a refused or failed install as the stage's blocked/needs_human finding with the exact fix (for macOS: `agent-desktop permissions --guide`, then the user approves it; for an install: `npm install -g agent-desktop`), and re-run `agent-desktop status` on resume. Use a dedicated desktop/session and controlled fixtures, inspect snapshots for other windows, and stop before destructive actions. agent-desktop reads accessibility trees and does not match pixels: for a UI that publishes none, a screenshot with `--headed` coordinate input is the only route and needs the user's permission, so say what stayed unverified. It does not drive native iOS or Android apps inside a simulator or emulator: use `xcrun simctl`, Appium/XCUITest or `adb`/UI Automator. Do not automate an arbitrary physical iPhone without an accessible simulator/emulator/mirroring or native automation setup, or label a Chrome recording as terminal or native iOS proof; an agent-browser `-p ios` session proves Mobile Safari behavior, not a native iOS app.",
|
|
53073
|
+
"Also never run `npx skills add` for agent-desktop or install a skill into other agent directories such as `~/.claude/skills`; updating the executable is separate from installing or updating a skill.",
|
|
53074
53074
|
"Choose tools from observed environment capabilities. Prefer installed/cached tools; install missing tools, runtimes or plugins when online access and permissions permit. Known offline/restricted installation is sufficient evidence not to attempt prohibited downloads; otherwise check capabilities or make one bounded setup attempt. Do not loop on blocked downloads, require production credentials, or take unsafe actions.",
|
|
53075
53075
|
"When execution or installation is unavailable, continue available authoritative repository checks and retain useful local evidence. Report the constraint or attempted command with observed output, what could not run, and the narrower validation performed. For non-UI tasks, use relevant executable checks rather than manufacturing a UI scenario. An unavailable optional mechanism is not itself failed implementation or permission to relax required project checks."
|
|
53076
53076
|
].join(`
|
|
@@ -53084,7 +53084,7 @@ var init_shared_prompts = __esm(() => {
|
|
|
53084
53084
|
`);
|
|
53085
53085
|
MEDIA_PUBLICATION_GUIDANCE = [
|
|
53086
53086
|
"Detect the repository provider and authorized PR/MR/issue/comment target before publishing media. Inspect and redact screenshots/video for secrets, personal information and unrelated windows; tie evidence to the verified commit and scenario. Local evidence collection does not authorize uploads.",
|
|
53087
|
-
"When creating the PR/MR, gather the image and video evidence the verification stages produced and attach it to the PR body when the provider supports uploads:
|
|
53087
|
+
"When creating the PR/MR, gather the image and video evidence the verification stages produced and attach it to the PR body when the provider supports uploads: agent-desktop `screenshot` before/after PNGs, agent-browser `screenshot` PNGs and `record` recordings, and any QA proof video. Reference each file in the body next to the scenario it proves (a before/after pair per verified postcondition, one recording per interaction) and keep the snapshot JSON as a local artifact the body cites by name. On supported GitHub, pass them at creation: gh pr create --body-file <body.md> --attach 'before.png#State before the action' --attach 'after.png#State after the action' --attach flow.webm; use gh pr edit/comment --attach for evidence produced later.",
|
|
53088
53088
|
"On GitHub, check gh --version and the chosen command's --help. GitHub CLI >=2.99.0 supports repeatable --attach on gh issue create/edit/comment and gh pr create/edit/comment. Use native attachments when supported, for example gh pr comment <number> --repo <owner/repo> --body-file <body.md> --attach <proof.mp4>. Attach each file once. Body-local path references are rewritten to hosted URLs; otherwise attachments append in flag order. Image path#alt text is supported; video alt text is not. A standalone  paragraph becomes an embedded player.",
|
|
53089
53089
|
"Check current GitHub limits: PNG/JPEG/GIF/WebP/SVG images and MP4/MOV/WebM videos; images/GIFs up to 10 MB, video 10 MB on Free or 100 MB paid. Native attachment upload requires repository write access and supported OAuth/classic PAT auth; GitHub Enterprise Server is unsupported in this release. See https://docs.github.com/en/github-cli/github-cli/attaching-files-with-github-cli.",
|
|
53090
53090
|
"Read back the returned PR/issue/comment and confirm usable GitHub-hosted links before claiming attachment success. Unsupported CLI versions, hosts, providers, auth or sizes require a truthful fallback: retain the local artifact and explain authorized manual attachment or supported provider options. Never claim file:// links are uploaded evidence, expose secrets, or upload automatically to unrelated third-party hosts."
|
|
@@ -52944,10 +52944,10 @@ var init_shared_prompts = __esm(() => {
|
|
|
52944
52944
|
`);
|
|
52945
52945
|
E2E_VERIFICATION_GUIDANCE = [
|
|
52946
52946
|
"Verify correctness end-to-end whenever practical for user-visible behavior; an executable scenario is stronger proof than code inspection, unit tests, or stage summaries alone.",
|
|
52947
|
-
'For web or frontend flows, including frontend changes whose correctness depends on backend/API behavior, use the agent-browser skill or delegate with `skill: "agent-browser"`; capture snapshot, screenshot, DOM, or network evidence suited to the objective. Prefer agent-browser for what its skill covers, because its text snapshots cost far fewer tokens than screenshot-driven
|
|
52947
|
+
'For web or frontend flows, including frontend changes whose correctness depends on backend/API behavior, use the agent-browser skill or delegate with `skill: "agent-browser"`; capture snapshot, screenshot, DOM, or network evidence suited to the objective. Prefer agent-browser for what its skill covers, because its text snapshots cost far fewer tokens than screenshot-driven computer use (websites and web apps in Chrome/Chromium, Mobile Safari in the iOS Simulator via `agent-browser -p ios`, Electron desktop apps and other CDP-exposing apps, Slack, cloud browsers); use agent-desktop for native desktop apps, OS dialogs and browser chrome outside the page, and whenever agent-browser hits a limitation. Native iOS apps in the iOS Simulator and Android emulators are outside agent-desktop: use `xcrun simctl`, Appium/XCUITest or `adb`/UI Automator, and report the gap when none is available.',
|
|
52948
52948
|
"For TUI/terminal automation/testing, prefer the herdr skill on macOS, Linux and Windows. Install Herdr if missing when network access and permissions permit; fall back to the tmux skill or native Windows psmux if installation or use is not possible. Preserve the pinned herdr skill's explicit-request and HERDR_ENV=1 requirements; never control a focused session from outside Herdr. Check installed help: psmux uses tmux-style commands, while herdr has its own CLI, not interchangeable flags. Exercise the actual interactive flow and retain pane/text or terminal recording evidence.",
|
|
52949
|
-
"For desktop and
|
|
52950
|
-
"Also
|
|
52949
|
+
"For native desktop apps and OS dialogs, use agent-desktop: when a model chooses the next action, as in this stage, load Atomic's bundled agent-desktop skill and run one-shot `agent-desktop` commands, following its snapshot -> act -> wait or fresh read -> verify loop; when workflow TypeScript code owns the sequence and the postcondition, call the `agent-desktop` CLI from inside `ctx.tool(name, args, fn, { timeoutMs })` instead, spawning one process per command, parsing its JSON envelope and forwarding `signal`. Before the first action, run `agent-desktop status`, `agent-desktop skills get desktop` and `agent-desktop skills get platform` and follow them; they are compiled into the binary, so they match the installed version. Ensure the executable (`agent-desktop version`; if missing, one bounded attempt with `npm install -g agent-desktop`, approving its install script if npm blocks it, and report its side effects). Atomic bundles the skill: never `npx skills add` it, and do not link or copy a skill into `~/.agents/skills` or other agent directories; leave any existing user-level skill alone. agent-desktop documents no telemetry, so no opt-out setting is needed. Ensure readiness with bounded attempts per docs/computer-use.md: on macOS `permissions.accessibility` granted (and `screen_recording` for screenshots), on Linux a non-empty `supported_surfaces`. Save the snapshot JSON, `screenshot` PNGs and, when a session traces, the `trace export` HTML to the artifacts directory as evidence. Verify each postcondition with `wait --element <ref> --predicate value --value <text>` or a fresh read, never a sleep; a successful action proves delivery, not the effect, and an action is retried only when `disposition.retry` is `safe`. Report a missing macOS permission, a Windows session that is not the interactive desktop, no graphical Linux session or AT-SPI bus, or a refused or failed install as the stage's blocked/needs_human finding with the exact fix (for macOS: `agent-desktop permissions --guide`, then the user approves it; for an install: `npm install -g agent-desktop`), and re-run `agent-desktop status` on resume. Use a dedicated desktop/session and controlled fixtures, inspect snapshots for other windows, and stop before destructive actions. agent-desktop reads accessibility trees and does not match pixels: for a UI that publishes none, a screenshot with `--headed` coordinate input is the only route and needs the user's permission, so say what stayed unverified. It does not drive native iOS or Android apps inside a simulator or emulator: use `xcrun simctl`, Appium/XCUITest or `adb`/UI Automator. Do not automate an arbitrary physical iPhone without an accessible simulator/emulator/mirroring or native automation setup, or label a Chrome recording as terminal or native iOS proof; an agent-browser `-p ios` session proves Mobile Safari behavior, not a native iOS app.",
|
|
52950
|
+
"Also never run `npx skills add` for agent-desktop or install a skill into other agent directories such as `~/.claude/skills`; updating the executable is separate from installing or updating a skill.",
|
|
52951
52951
|
"Choose tools from observed environment capabilities. Prefer installed/cached tools; install missing tools, runtimes or plugins when online access and permissions permit. Known offline/restricted installation is sufficient evidence not to attempt prohibited downloads; otherwise check capabilities or make one bounded setup attempt. Do not loop on blocked downloads, require production credentials, or take unsafe actions.",
|
|
52952
52952
|
"When execution or installation is unavailable, continue available authoritative repository checks and retain useful local evidence. Report the constraint or attempted command with observed output, what could not run, and the narrower validation performed. For non-UI tasks, use relevant executable checks rather than manufacturing a UI scenario. An unavailable optional mechanism is not itself failed implementation or permission to relax required project checks."
|
|
52953
52953
|
].join(`
|
|
@@ -52961,7 +52961,7 @@ var init_shared_prompts = __esm(() => {
|
|
|
52961
52961
|
`);
|
|
52962
52962
|
MEDIA_PUBLICATION_GUIDANCE = [
|
|
52963
52963
|
"Detect the repository provider and authorized PR/MR/issue/comment target before publishing media. Inspect and redact screenshots/video for secrets, personal information and unrelated windows; tie evidence to the verified commit and scenario. Local evidence collection does not authorize uploads.",
|
|
52964
|
-
"When creating the PR/MR, gather the image and video evidence the verification stages produced and attach it to the PR body when the provider supports uploads:
|
|
52964
|
+
"When creating the PR/MR, gather the image and video evidence the verification stages produced and attach it to the PR body when the provider supports uploads: agent-desktop `screenshot` before/after PNGs, agent-browser `screenshot` PNGs and `record` recordings, and any QA proof video. Reference each file in the body next to the scenario it proves (a before/after pair per verified postcondition, one recording per interaction) and keep the snapshot JSON as a local artifact the body cites by name. On supported GitHub, pass them at creation: gh pr create --body-file <body.md> --attach 'before.png#State before the action' --attach 'after.png#State after the action' --attach flow.webm; use gh pr edit/comment --attach for evidence produced later.",
|
|
52965
52965
|
"On GitHub, check gh --version and the chosen command's --help. GitHub CLI >=2.99.0 supports repeatable --attach on gh issue create/edit/comment and gh pr create/edit/comment. Use native attachments when supported, for example gh pr comment <number> --repo <owner/repo> --body-file <body.md> --attach <proof.mp4>. Attach each file once. Body-local path references are rewritten to hosted URLs; otherwise attachments append in flag order. Image path#alt text is supported; video alt text is not. A standalone  paragraph becomes an embedded player.",
|
|
52966
52966
|
"Check current GitHub limits: PNG/JPEG/GIF/WebP/SVG images and MP4/MOV/WebM videos; images/GIFs up to 10 MB, video 10 MB on Free or 100 MB paid. Native attachment upload requires repository write access and supported OAuth/classic PAT auth; GitHub Enterprise Server is unsupported in this release. See https://docs.github.com/en/github-cli/github-cli/attaching-files-with-github-cli.",
|
|
52967
52967
|
"Read back the returned PR/issue/comment and confirm usable GitHub-hosted links before claiming attachment success. Unsupported CLI versions, hosts, providers, auth or sizes require a truthful fallback: retain the local artifact and explain authorized manual attachment or supported provider options. Never claim file:// links are uploaded evidence, expose secrets, or upload automatically to unrelated third-party hosts."
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAIhE,MAAM,WAAW,iBAAiB;IACjC,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,IA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AAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAG1D,gGAAgG;AAChG,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,wBAAwB,GAAG,kCAAkC,CAoBrH;AAyED,6FAA6F;AAC7F,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,wBAAwB,GAAG,oBAAoB,CA8E/F;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,wBAAwB,GAAG;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CAChC,CAGA;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EACvC,OAAO,EAAE,oBAAoB,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,SAAS,CAS3C"}
|
|
@@ -68,7 +68,7 @@ function buildRules(selectedTools, toolGuidelines, promptGuidelines) {
|
|
|
68
68
|
addGuideline([
|
|
69
69
|
"**Execution history**: Leave a mineable record of how each task was executed and what the user prefers, and mine those records to calibrate later work. The records only accumulate value if every task writes them. If the user, a context file, or `APPEND_SYSTEM.md` asks you not to record some or all of these records, skip those records.",
|
|
70
70
|
" - When you author a commit, PR, issue, or issue/review comment for a task, record how it ran: `Assistant-workflow: <workflow name> (run <runId>)` for a registered or custom workflow, or `Assistant-workflow: inline` when no workflow was used; and `Assistant-duration: <elapsed> <converged|blocked|abandoned>, estimated <estimate>` (for example `Assistant-duration: 42m converged, estimated 30m`), measuring wall-clock time from launch or task start until acceptance was proven or work stopped, including resumes and repair rounds. Take elapsed time from workflow status timing or timestamps you recorded (for example `date` at task start); write `unmeasured` rather than guess. Put these as trailers alongside `Assistant-model` in commits (git trailers, or the equivalent commit-message metadata in the repository's version control system) and as the same `Key: value` lines in PR/merge request, issue, and comment bodies. For multi-commit work, record the workflow on each commit and the final duration once, in the last commit or the PR body.",
|
|
71
|
-
" - In the same artifacts, record how the result was verified with one `Assistant-verification: <method> <passed|failed|unavailable>: <what it proved or why>` line per method that actually ran or was attempted (for example `Assistant-verification: herdr terminal E2E passed: /tasks lists running tasks first at 80x24`, `Assistant-verification: vitest unit passed: npm run test:unit`, or `Assistant-verification:
|
|
71
|
+
" - In the same artifacts, record how the result was verified with one `Assistant-verification: <method> <passed|failed|unavailable>: <what it proved or why>` line per method that actually ran or was attempted (for example `Assistant-verification: herdr terminal E2E passed: /tasks lists running tasks first at 80x24`, `Assistant-verification: vitest unit passed: npm run test:unit`, or `Assistant-verification: agent-desktop unavailable: Accessibility permission not granted`). Name the concrete mechanism, such as unit, integration, or E2E tests, agent-browser, agent-desktop, herdr or tmux terminal automation, the qlty CLI, typecheck or lint, or a manual scenario, and the command or scenario it exercised. Record only checks that ran and their observed outcome; never record a skipped, mocked, or planned check as passed.",
|
|
72
72
|
" - When the user states or reveals a durable preference about how they work (a correction, a rejected approach, scope, review, tooling, or communication style), record it in the same artifacts as `User-preference: <one line, in the user's terms>`, and tie it to the requesting user with a `Co-authored-by: <name> <email>` trailer taken from their version control identity (for example `git config user.name`/`user.email`) unless that line is already present; in PR, issue, and comment bodies, add the same line or their hosting account (for example from `gh api user`). Record only what the user expressed or their own edits show; never record secrets, credentials, or personal details unrelated to the work. If repository rules restrict commit or PR formats, fit the records into what they allow.",
|
|
73
73
|
" - Before choosing between a workflow and inline work, choosing how to verify a change, estimating a duration, or interpreting an ambiguous request, mine these records with the rest of the history using the repository's version control system and its hosting CLI, for example `git log --format='%h %an <%ae> %s%n%(trailers:key=Assistant-workflow,key=Assistant-duration,key=Assistant-verification,key=User-preference,key=Co-authored-by)'` with `gh pr list --state all --search 'Assistant-workflow in:body'` on GitHub, or the equivalent commands for other systems and hosts (for example `glab` on GitLab). Compare tasks of similar kind and size, and state the sample size with the median and range. Treat fewer than five comparable records as anecdotal, and prefer the more recent record when two conflict. When choosing verification, start from the methods that proved comparable changes (the same files, subsystem, or kind of change), reuse their commands and scenarios, and do not retry a setup recorded as `unavailable` without a reason to expect a different result; past records never replace the project's required checks. Prioritize preferences tied to the requesting user by their co-author line, commit author, or hosting account. When the user has none that cover the situation, fall back to other contributors' relevant preferences as repository conventions; the user's own records and current request override them, so users can always encode their own preference. This history is a guide, not the decision: the current request, the task itself, and explicit user instructions decide between a workflow and inline work. Missing, sparse, or mostly inline workflow history is not evidence that the user prefers inline work: records exist only for tasks that wrote them, and past inline runs may reflect an earlier default rather than a choice. Without a recorded or stated preference that covers the situation, judge the task's shape yourself and choose a workflow when it would help, then let comparable records and the user's preferences refine that call.",
|
|
74
74
|
].join("\n"));
|
|
@@ -123,8 +123,7 @@ Atomic documentation (read when the user asks about model choice, computer use o
|
|
|
123
123
|
- When asked about: atomic workflows (docs/workflows.md), extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), atomic packages (docs/packages.md), codemode scripts and non-LLM models such as classifiers and image models (docs/codemode.md)
|
|
124
124
|
- Bundled integrations use the same docs root in npm and binary installations: MCP servers (docs/mcp-servers.md), web access (docs/web-access.md), intercom (docs/intercom.md), subagents (docs/subagents.md), workflows (docs/workflows.md). Read these guides rather than guessing paths inside builtin packages.
|
|
125
125
|
- When the user asks which model to choose for a task, read ${docsPath}/models/model-selection.md and ${docsPath}/models/evals.md, then consult https://artificialanalysis.ai/ for the relevant benchmark charts and methodology. Match the task to individual evaluations rather than an aggregate winner. Cite the benchmark, source date, exact model/effort and cost or latency tradeoff; distinguish measured results from recommendations. If live evidence is unavailable, label the dated docs snapshot instead of claiming a refresh. Check the configured catalog before giving an exact provider/model or thinking setting; catalog presence is not proof of live access.
|
|
126
|
-
- For computer use
|
|
127
|
-
- Also skip \`cua-driver skills update\` and any skill installation into other agent directories such as \`~/.claude/skills\`; updating the executable is separate from installing or updating a skill.
|
|
126
|
+
- For computer use on native desktop apps and OS dialogs on macOS, Windows and Linux, use the bundled agent-desktop skill and one-shot \`agent-desktop\` commands. Before the first action run \`agent-desktop status\`, \`agent-desktop skills get desktop\` and \`agent-desktop skills get platform\` and follow them; they match the installed binary. When workflow TypeScript code owns the sequence and postcondition, call the CLI from inside ctx.tool, one process per command, parsing its JSON envelope, forwarding the signal, with a finite timeoutMs. If \`agent-desktop version\` fails, make one bounded \`npm install -g agent-desktop\` attempt and report its side effects. Atomic bundles the skill: never run \`npx skills add\` for it or copy a skill into other agent directories, and leave existing user-level skills alone. Let the user grant permissions (\`agent-desktop permissions --guide\` on macOS; on Linux a graphical session with an AT-SPI bus); never script around a consent dialog. See ${docsPath}/computer-use.md. Prefer the agent-browser skill for what it covers, because its text snapshots cost far fewer tokens: websites and web apps in Chrome/Chromium, Mobile Safari in the iOS Simulator (\`agent-browser -p ios\`), Electron and other CDP-exposing apps, Slack, and cloud browsers. Use agent-desktop for everything native and whenever agent-browser hits a limitation. agent-desktop reads accessibility trees, not pixels, and has no native iOS or Android support: say what stayed unverified, and use \`xcrun simctl\`, Appium or \`adb\` for native mobile apps. For terminal automation/testing, prefer herdr on macOS, Linux and Windows; install it if missing when network access and permissions permit, and fall back to tmux or native Windows psmux if installation or use is not possible. Load the matching skill and ${docsPath}/workflows/verification.md. Preserve the pinned herdr skill's explicit-request and HERDR_ENV=1 requirements; never control a focused session from outside Herdr. Check installed capabilities, use dedicated sessions, respect desktop permissions, and stop before destructive actions. These CLIs are not interchangeable, and skills do not grant tools or authorization.
|
|
128
127
|
- When working on Atomic topics, read the docs and examples, and follow .md cross-references before implementing
|
|
129
128
|
- Always read Atomic .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;
|
|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AE,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC;AACpE,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,iBAAiB,CAAC,KAA+B;IAChE,OAAO,oBAAoB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,sBAAsB,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;AACjG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACvC,QAAuC,EACvC,OAA6B;IAE7B,MAAM,KAAK,GAAkC,EAAE,CAAC;IAChD,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjD,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1C,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getSystemMessageText } from \"@bastani/pi-ai\";\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.js\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nconst DEFAULT_PROMPT_TOOLS = [\"read\", \"bash\", \"edit\", \"write\", \"find\", \"search\", \"ask_user_question\", \"todo\"] as const;\n\nexport interface SystemPromptModel {\n\t/** Provider identifier for the selected model. */\n\tprovider: string;\n\t/** Stable provider-specific model identifier. */\n\tid: string;\n\t/** Human-readable model name, when available. */\n\tname?: string;\n}\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces the default prefix). */\n\tcustomPrompt?: string;\n\t/** Exact full prompt replacement set by a before_agent_start handler. */\n\tforceSystemPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write, find, search, ask_user_question, todo] */\n\tselectedTools?: string[];\n\t/** Active tools whose declarations are hidden by prepareLoadout and whose prompt rules are omitted. */\n\thiddenTools?: string[];\n\t/** Tool names explicitly excluded by the caller and omitted from generated guidance. */\n\texcludedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Guideline bullets contributed by each tool, keyed by tool name. */\n\ttoolGuidelines?: Record<string, string[]>;\n\t/** Additional guideline bullets appended to the default system prompt rules. */\n\tpromptGuidelines?: string[];\n\t/** Text appended from user configuration before project context, skills, and cwd. */\n\tappendSystemPrompt?: string;\n\t/** Additional XML-wrapped prompt sections keyed by tag name. */\n\tsections?: Record<string, string>;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Currently selected model, used for model-aware prompt metadata. */\n\tselectedModel?: SystemPromptModel;\n\t/** Current reasoning/thinking level for the selected model. */\n\tselectedThinkingLevel?: string;\n\t/** Pre-loaded context files. */\n\tcontextFiles?: Array<{ path: string; content: string }>;\n\t/** Pre-loaded skills. */\n\tskills?: Skill[];\n}\n\nexport type NormalizedBuildSystemPromptOptions = BuildSystemPromptOptions & {\n\tselectedTools: string[];\n\thiddenTools: string[];\n\ttoolSnippets: Record<string, string>;\n\ttoolGuidelines: Record<string, string[]>;\n\tpromptGuidelines: string[];\n\tappendSystemPrompt: string;\n\tsections: Record<string, string>;\n\tcontextFiles: Array<{ path: string; content: string }>;\n\tskills: Skill[];\n};\n\n/**\n * Ordered system prompt sections, keyed by name. `preamble` is untagged text; every other\n * section is wrapped in a tag of the same name so the model can match later updates to it.\n * These become `SystemMessage.sections` in the transcript.\n */\nexport type SystemPromptSections = Record<string, string>;\n\nconst SYSTEM_PROMPT_SECTION_NAME = /^[a-z][a-z0-9_-]*$/;\n/** Normalize prompt input into the mutable, collection-complete shape exposed to extensions. */\nexport function normalizeBuildSystemPromptOptions(input: BuildSystemPromptOptions): NormalizedBuildSystemPromptOptions {\n\treturn {\n\t\tcustomPrompt: input.customPrompt,\n\t\tforceSystemPrompt: input.forceSystemPrompt,\n\t\tselectedTools: [...(input.selectedTools ?? DEFAULT_PROMPT_TOOLS)],\n\t\thiddenTools: [...(input.hiddenTools ?? [])],\n\t\ttoolSnippets: { ...(input.toolSnippets ?? {}) },\n\t\ttoolGuidelines: Object.fromEntries(\n\t\t\tObject.entries(input.toolGuidelines ?? {}).map(([name, guidelines]) => [name, [...guidelines]]),\n\t\t),\n\t\tpromptGuidelines: [...(input.promptGuidelines ?? [])],\n\t\tappendSystemPrompt: input.appendSystemPrompt ?? \"\",\n\t\tsections: { ...(input.sections ?? {}) },\n\t\tcwd: input.cwd,\n\t\t...(input.excludedTools === undefined ? {} : { excludedTools: [...input.excludedTools] }),\n\t\t...(input.selectedModel === undefined ? {} : { selectedModel: { ...input.selectedModel } }),\n\t\t...(input.selectedThinkingLevel === undefined ? {} : { selectedThinkingLevel: input.selectedThinkingLevel }),\n\t\tcontextFiles: (input.contextFiles ?? []).map((file) => ({ ...file })),\n\t\tskills: (input.skills ?? []).map((skill) => ({ ...skill })),\n\t};\n}\n\nfunction renderProjectContext(contextFiles: Array<{ path: string; content: string }>): string {\n\treturn [\n\t\t\"Project-specific instructions and guidelines:\",\n\t\t...contextFiles.map(\n\t\t\t({ path, content }) => `<project_instructions path=\"${path}\">\\n${content}\\n</project_instructions>`,\n\t\t),\n\t].join(\"\\n\\n\");\n}\n\nfunction buildRules(\n\tselectedTools: string[],\n\ttoolGuidelines: Record<string, string[]>,\n\tpromptGuidelines: string[],\n): string {\n\tconst rules: string[] = [];\n\tconst seen = new Set<string>();\n\tconst addRule = (rule: string): void => {\n\t\tconst normalized = rule.trim();\n\t\tif (!normalized || seen.has(normalized)) return;\n\t\tseen.add(normalized);\n\t\trules.push(normalized);\n\t};\n\n\tconst tools = selectedTools;\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasPowerShell = tools.includes(\"powershell\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst shouldIncludeAskUserFallbackGuidance = tools.length > 0 && !tools.includes(\"ask_user_question\");\n\tconst addGuideline = addRule;\n\tif ((hasBash || hasPowerShell) && !hasFind && !hasLs) {\n\t\tif (hasBash && hasPowerShell) {\n\t\t\taddRule(\"Use bash or PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else if (hasPowerShell) {\n\t\t\taddRule(\"Use PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else {\n\t\t\taddRule(\"Use bash for file operations like ls, rg, find\");\n\t\t}\n\t}\n\tif (shouldIncludeAskUserFallbackGuidance) {\n\t\taddGuideline(\n\t\t\t\"If an equivalent user-question tool is available, use it for all questions to the user instead of plain text, including confirmations and approvals, following its supported schema. When no usable question tool or human-input channel exists, do not stall on a question: choose the interpretation best supported by the repository and the stated objective, state the assumption in your response, and continue fully autonomously on best judgment. Tool unavailability alone is not a blocker. Preserve safety and authorization constraints.\",\n\t\t);\n\t}\n\tif (hasBash || hasPowerShell) {\n\t\taddGuideline(\n\t\t\t\"**Repository intent**: When working in a repository, infer how its maintainers actually work before imposing defaults: review recent commits, open and merged PRs, issues and their comments, and project/board status when tooling allows (for example `git log` and the `gh` CLI) to learn conventions, priorities, and scope norms. Better, identify the requesting user (`git config user.name`/`user.email`, `gh api user`) and study their own commits, PRs, reviews, and issue comments so you interpret ambiguous requests the way they would, aligning style, scope, and process with their patterns.\",\n\t\t);\n\t\taddGuideline(\n\t\t\t[\n\t\t\t\t\"**Execution history**: Leave a mineable record of how each task was executed and what the user prefers, and mine those records to calibrate later work. The records only accumulate value if every task writes them. If the user, a context file, or `APPEND_SYSTEM.md` asks you not to record some or all of these records, skip those records.\",\n\t\t\t\t\" - When you author a commit, PR, issue, or issue/review comment for a task, record how it ran: `Assistant-workflow: <workflow name> (run <runId>)` for a registered or custom workflow, or `Assistant-workflow: inline` when no workflow was used; and `Assistant-duration: <elapsed> <converged|blocked|abandoned>, estimated <estimate>` (for example `Assistant-duration: 42m converged, estimated 30m`), measuring wall-clock time from launch or task start until acceptance was proven or work stopped, including resumes and repair rounds. Take elapsed time from workflow status timing or timestamps you recorded (for example `date` at task start); write `unmeasured` rather than guess. Put these as trailers alongside `Assistant-model` in commits (git trailers, or the equivalent commit-message metadata in the repository's version control system) and as the same `Key: value` lines in PR/merge request, issue, and comment bodies. For multi-commit work, record the workflow on each commit and the final duration once, in the last commit or the PR body.\",\n\t\t\t\t\" - In the same artifacts, record how the result was verified with one `Assistant-verification: <method> <passed|failed|unavailable>: <what it proved or why>` line per method that actually ran or was attempted (for example `Assistant-verification: herdr terminal E2E passed: /tasks lists running tasks first at 80x24`, `Assistant-verification: vitest unit passed: npm run test:unit`, or `Assistant-verification: cua-driver unavailable: Accessibility permission not granted`). Name the concrete mechanism, such as unit, integration, or E2E tests, agent-browser, Cua Driver, herdr or tmux terminal automation, the qlty CLI, typecheck or lint, or a manual scenario, and the command or scenario it exercised. Record only checks that ran and their observed outcome; never record a skipped, mocked, or planned check as passed.\",\n\t\t\t\t\" - When the user states or reveals a durable preference about how they work (a correction, a rejected approach, scope, review, tooling, or communication style), record it in the same artifacts as `User-preference: <one line, in the user's terms>`, and tie it to the requesting user with a `Co-authored-by: <name> <email>` trailer taken from their version control identity (for example `git config user.name`/`user.email`) unless that line is already present; in PR, issue, and comment bodies, add the same line or their hosting account (for example from `gh api user`). Record only what the user expressed or their own edits show; never record secrets, credentials, or personal details unrelated to the work. If repository rules restrict commit or PR formats, fit the records into what they allow.\",\n\t\t\t\t\" - Before choosing between a workflow and inline work, choosing how to verify a change, estimating a duration, or interpreting an ambiguous request, mine these records with the rest of the history using the repository's version control system and its hosting CLI, for example `git log --format='%h %an <%ae> %s%n%(trailers:key=Assistant-workflow,key=Assistant-duration,key=Assistant-verification,key=User-preference,key=Co-authored-by)'` with `gh pr list --state all --search 'Assistant-workflow in:body'` on GitHub, or the equivalent commands for other systems and hosts (for example `glab` on GitLab). Compare tasks of similar kind and size, and state the sample size with the median and range. Treat fewer than five comparable records as anecdotal, and prefer the more recent record when two conflict. When choosing verification, start from the methods that proved comparable changes (the same files, subsystem, or kind of change), reuse their commands and scenarios, and do not retry a setup recorded as `unavailable` without a reason to expect a different result; past records never replace the project's required checks. Prioritize preferences tied to the requesting user by their co-author line, commit author, or hosting account. When the user has none that cover the situation, fall back to other contributors' relevant preferences as repository conventions; the user's own records and current request override them, so users can always encode their own preference. This history is a guide, not the decision: the current request, the task itself, and explicit user instructions decide between a workflow and inline work. Missing, sparse, or mostly inline workflow history is not evidence that the user prefers inline work: records exist only for tasks that wrote them, and past inline runs may reflect an earlier default rather than a choice. Without a recorded or stated preference that covers the situation, judge the task's shape yourself and choose a workflow when it would help, then let comparable records and the user's preferences refine that call.\",\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t}\n\n\tfor (const name of selectedTools) {\n\t\tfor (const rule of toolGuidelines[name] ?? []) addRule(rule);\n\t}\n\tfor (const rule of promptGuidelines) addRule(rule);\n\taddRule(\n\t\t\"Write self-describing code and do not add comments unless the user explicitly asks for them or the task instructions call for them. Code that needs a comment to be understood is a smell: restructure it with clearer names, smaller units, or explicit types instead\",\n\t);\n\taddRule(\"Be concise in your responses\");\n\taddRule(\"Show file paths clearly when working with files\");\n\treturn rules.map((rule) => `- ${rule}`).join(\"\\n\");\n}\n\n/** Build the ordered, independently replaceable sections of the structured system prompt. */\nexport function buildSystemPromptSections(input: BuildSystemPromptOptions): SystemPromptSections {\n\tconst options = normalizeBuildSystemPromptOptions(input);\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\ttoolGuidelines,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tsections: customSections,\n\t\tcwd,\n\t\tcontextFiles,\n\t\tskills,\n\t} = options;\n\tconst explicitlyExcludedTools = new Set(options.excludedTools ?? []);\n\tconst tools = selectedTools.filter((name) => !explicitlyExcludedTools.has(name));\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\tconst modelName = options.selectedModel?.name?.trim() || options.selectedModel?.id || \"unknown\";\n\tconst modelReasoningLevel = options.selectedThinkingLevel?.trim() || \"off\";\n\tconst now = new Date();\n\tconst date = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}`;\n\n\tfor (const name of Object.keys(customSections)) {\n\t\tif (!SYSTEM_PROMPT_SECTION_NAME.test(name) || name === \"preamble\") {\n\t\t\tthrow new Error(`Invalid system prompt section name: ${name}`);\n\t\t}\n\t}\n\n\tconst declaredTools = tools.filter((name) => !options.hiddenTools.includes(name));\n\tconst promptSections: Record<string, string> = {};\n\tif (customPrompt) {\n\t\tpromptSections.preamble = customPrompt;\n\t} else {\n\t\tpromptSections.preamble =\n\t\t\t\"You are an expert coding assistant operating named Atomic, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\";\n\t\tconst visibleTools = declaredTools.filter((name) => !!toolSnippets[name]);\n\t\tconst toolsList =\n\t\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets[name]}`).join(\"\\n\") : \"(none)\";\n\t\tpromptSections.tools = `Available tools:\\n${toolsList}\\n\\nIn addition to the tools above, you may have access to other custom tools depending on the project.`;\n\t\tpromptSections.rules = `Guidelines:\\n${buildRules(declaredTools, toolGuidelines, promptGuidelines)}`;\n\t\tpromptSections.docs = `\nAtomic documentation (read when the user asks about model choice, computer use or automation, MCP, web access, intercom, subagents, or customizing Atomic itself, its SDK, creating workflows, packages, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- Docs/examples references above must be resolved against these absolute roots; e.g. docs/foo.md means ${docsPath}/foo.md and examples/bar means ${examplesPath}/bar.\n- When asked about: atomic workflows (docs/workflows.md), extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), atomic packages (docs/packages.md), codemode scripts and non-LLM models such as classifiers and image models (docs/codemode.md)\n- Bundled integrations use the same docs root in npm and binary installations: MCP servers (docs/mcp-servers.md), web access (docs/web-access.md), intercom (docs/intercom.md), subagents (docs/subagents.md), workflows (docs/workflows.md). Read these guides rather than guessing paths inside builtin packages.\n- When the user asks which model to choose for a task, read ${docsPath}/models/model-selection.md and ${docsPath}/models/evals.md, then consult https://artificialanalysis.ai/ for the relevant benchmark charts and methodology. Match the task to individual evaluations rather than an aggregate winner. Cite the benchmark, source date, exact model/effort and cost or latency tradeoff; distinguish measured results from recommendations. If live evidence is unavailable, label the dated docs snapshot instead of claiming a refresh. Check the configured catalog before giving an exact provider/model or thinking setting; catalog presence is not proof of live access.\n- For computer use (CUA) on desktop apps, simulators and emulators, use Cua Driver through the bundled cua-driver skill and one-shot \\`cua-driver call <tool>\\` commands: when a model chooses the next action (interactive sessions or any workflow stage acting outside ctx.tool), use the CLI; when workflow TypeScript code owns the sequence and postcondition, use the @trycua/cua-driver TypeScript SDK inside ctx.tool. If \\`cua-driver --version\\` fails, make one bounded attempt with upstream's one-line executable installer and report its side effects. The executable installer does not install an agent skill; ignore upstream README's optional skill-install steps, never run \\`cua-driver skills install\\` or \\`clawhub install @cua/driver\\`, and do not link or copy a skill into \\`~/.agents/skills/cua-driver\\`. Atomic already bundles it; leave any existing user-level skill alone. Run every cua-driver command with CUA_DRIVER_RS_TELEMETRY_ENABLED=false and follow ${docsPath}/computer-use.md for install, readiness and permissions. Prefer the agent-browser skill for what it covers, because its text snapshots cost far fewer tokens than screenshot-driven CUA: websites and web apps in Chrome/Chromium, Mobile Safari in the iOS Simulator or on a connected iPhone/iPad (\\`agent-browser -p ios\\`, macOS with Xcode and Appium), Electron desktop apps such as VS Code, Slack, Discord, Figma, Notion and Spotify and other apps exposing a CDP port, Slack workspaces, and cloud browsers. Use cua-driver for everything else (native desktop apps, native iOS apps in the iOS Simulator, Android emulators, OS dialogs and permission prompts, desktop Safari and other non-Chromium browsers) and whenever agent-browser hits a limitation. For terminal automation/testing, prefer herdr on macOS, Linux and Windows; install it if missing when network access and permissions permit, and fall back to tmux or native Windows psmux if installation or use is not possible. Load the matching skill and ${docsPath}/workflows/verification.md. Preserve the pinned herdr skill's explicit-request and HERDR_ENV=1 requirements; never control a focused session from outside Herdr. Check installed capabilities, use dedicated sessions, respect desktop permissions, and stop before destructive actions. These CLIs are not interchangeable, and skills do not grant tools or authorization.\n- Also skip \\`cua-driver skills update\\` and any skill installation into other agent directories such as \\`~/.claude/skills\\`; updating the executable is separate from installing or updating a skill.\n- When working on Atomic topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read Atomic .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\t}\n\n\tif (appendSystemPrompt) promptSections.addendum = appendSystemPrompt;\n\tif (contextFiles.length > 0) promptSections.project_context = renderProjectContext(contextFiles);\n\tconst readers = [\"read\", \"bash\"] as const;\n\tconst skillFileReadTool =\n\t\treaders.find((tool) => declaredTools.includes(tool)) ??\n\t\t(readers.some((tool) => tools.includes(tool)) ? \"indirect\" : undefined);\n\tif (skillFileReadTool && skills.length > 0) {\n\t\tconst skillsPrompt = formatSkillsForPrompt(skills, skillFileReadTool).trim();\n\t\tif (skillsPrompt) promptSections.skills = skillsPrompt;\n\t}\n\tpromptSections.model = `Model name (used for commit attribution): ${modelName}\\nModel reasoning level: ${modelReasoningLevel}`;\n\tpromptSections.date = `Current date: ${date}`;\n\tpromptSections.cwd = `Current working directory: ${cwd.replace(/\\\\/g, \"/\")}`;\n\tfor (const [name, content] of Object.entries(customSections)) {\n\t\tif (content) promptSections[name] = content;\n\t}\n\n\tconst sections: SystemPromptSections = { preamble: promptSections.preamble };\n\tfor (const [name, content] of Object.entries(promptSections)) {\n\t\tif (name !== \"preamble\") sections[name] = `<${name}>\\n${content}\\n</${name}>`;\n\t}\n\treturn sections;\n}\n\n/**\n * The complete prompt state for `input`. A forced prompt is opaque and lives in `content`\n * with no sections; otherwise `content` is empty and the structured sections carry the prompt.\n */\nexport function buildSystemPromptState(input: BuildSystemPromptOptions): {\n\tcontent: string;\n\tsections?: SystemPromptSections;\n} {\n\tif (input.forceSystemPrompt !== undefined) return { content: input.forceSystemPrompt };\n\treturn { content: \"\", sections: buildSystemPromptSections(input) };\n}\n\n/** Build the system prompt text, rendered exactly as the transcript's system message replays it. */\nexport function buildSystemPrompt(input: BuildSystemPromptOptions): string {\n\treturn getSystemMessageText({ role: \"system\", ...buildSystemPromptState(input), timestamp: 0 });\n}\n\n/**\n * Diff the sections the model currently has (replayed from the transcript, so never null)\n * against the desired ones. Returns a `SystemMessage.sections` patch, or undefined when\n * nothing changed.\n */\nexport function diffSystemPromptSections(\n\tprevious: Record<string, string | null>,\n\tcurrent: SystemPromptSections,\n): Record<string, string | null> | undefined {\n\tconst patch: Record<string, string | null> = {};\n\tfor (const [name, text] of Object.entries(current)) {\n\t\tif (previous[name] !== text) patch[name] = text;\n\t}\n\tfor (const name of Object.keys(previous)) {\n\t\tif (current[name] === undefined) patch[name] = null;\n\t}\n\treturn Object.keys(patch).length > 0 ? patch : undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa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C,QAAuC,EACvC,OAA6B;IAE7B,MAAM,KAAK,GAAkC,EAAE,CAAC;IAChD,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjD,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1C,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getSystemMessageText } from \"@bastani/pi-ai\";\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.js\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nconst DEFAULT_PROMPT_TOOLS = [\"read\", \"bash\", \"edit\", \"write\", \"find\", \"search\", \"ask_user_question\", \"todo\"] as const;\n\nexport interface SystemPromptModel {\n\t/** Provider identifier for the selected model. */\n\tprovider: string;\n\t/** Stable provider-specific model identifier. */\n\tid: string;\n\t/** Human-readable model name, when available. */\n\tname?: string;\n}\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces the default prefix). */\n\tcustomPrompt?: string;\n\t/** Exact full prompt replacement set by a before_agent_start handler. */\n\tforceSystemPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write, find, search, ask_user_question, todo] */\n\tselectedTools?: string[];\n\t/** Active tools whose declarations are hidden by prepareLoadout and whose prompt rules are omitted. */\n\thiddenTools?: string[];\n\t/** Tool names explicitly excluded by the caller and omitted from generated guidance. */\n\texcludedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Guideline bullets contributed by each tool, keyed by tool name. */\n\ttoolGuidelines?: Record<string, string[]>;\n\t/** Additional guideline bullets appended to the default system prompt rules. */\n\tpromptGuidelines?: string[];\n\t/** Text appended from user configuration before project context, skills, and cwd. */\n\tappendSystemPrompt?: string;\n\t/** Additional XML-wrapped prompt sections keyed by tag name. */\n\tsections?: Record<string, string>;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Currently selected model, used for model-aware prompt metadata. */\n\tselectedModel?: SystemPromptModel;\n\t/** Current reasoning/thinking level for the selected model. */\n\tselectedThinkingLevel?: string;\n\t/** Pre-loaded context files. */\n\tcontextFiles?: Array<{ path: string; content: string }>;\n\t/** Pre-loaded skills. */\n\tskills?: Skill[];\n}\n\nexport type NormalizedBuildSystemPromptOptions = BuildSystemPromptOptions & {\n\tselectedTools: string[];\n\thiddenTools: string[];\n\ttoolSnippets: Record<string, string>;\n\ttoolGuidelines: Record<string, string[]>;\n\tpromptGuidelines: string[];\n\tappendSystemPrompt: string;\n\tsections: Record<string, string>;\n\tcontextFiles: Array<{ path: string; content: string }>;\n\tskills: Skill[];\n};\n\n/**\n * Ordered system prompt sections, keyed by name. `preamble` is untagged text; every other\n * section is wrapped in a tag of the same name so the model can match later updates to it.\n * These become `SystemMessage.sections` in the transcript.\n */\nexport type SystemPromptSections = Record<string, string>;\n\nconst SYSTEM_PROMPT_SECTION_NAME = /^[a-z][a-z0-9_-]*$/;\n/** Normalize prompt input into the mutable, collection-complete shape exposed to extensions. */\nexport function normalizeBuildSystemPromptOptions(input: BuildSystemPromptOptions): NormalizedBuildSystemPromptOptions {\n\treturn {\n\t\tcustomPrompt: input.customPrompt,\n\t\tforceSystemPrompt: input.forceSystemPrompt,\n\t\tselectedTools: [...(input.selectedTools ?? DEFAULT_PROMPT_TOOLS)],\n\t\thiddenTools: [...(input.hiddenTools ?? [])],\n\t\ttoolSnippets: { ...(input.toolSnippets ?? {}) },\n\t\ttoolGuidelines: Object.fromEntries(\n\t\t\tObject.entries(input.toolGuidelines ?? {}).map(([name, guidelines]) => [name, [...guidelines]]),\n\t\t),\n\t\tpromptGuidelines: [...(input.promptGuidelines ?? [])],\n\t\tappendSystemPrompt: input.appendSystemPrompt ?? \"\",\n\t\tsections: { ...(input.sections ?? {}) },\n\t\tcwd: input.cwd,\n\t\t...(input.excludedTools === undefined ? {} : { excludedTools: [...input.excludedTools] }),\n\t\t...(input.selectedModel === undefined ? {} : { selectedModel: { ...input.selectedModel } }),\n\t\t...(input.selectedThinkingLevel === undefined ? {} : { selectedThinkingLevel: input.selectedThinkingLevel }),\n\t\tcontextFiles: (input.contextFiles ?? []).map((file) => ({ ...file })),\n\t\tskills: (input.skills ?? []).map((skill) => ({ ...skill })),\n\t};\n}\n\nfunction renderProjectContext(contextFiles: Array<{ path: string; content: string }>): string {\n\treturn [\n\t\t\"Project-specific instructions and guidelines:\",\n\t\t...contextFiles.map(\n\t\t\t({ path, content }) => `<project_instructions path=\"${path}\">\\n${content}\\n</project_instructions>`,\n\t\t),\n\t].join(\"\\n\\n\");\n}\n\nfunction buildRules(\n\tselectedTools: string[],\n\ttoolGuidelines: Record<string, string[]>,\n\tpromptGuidelines: string[],\n): string {\n\tconst rules: string[] = [];\n\tconst seen = new Set<string>();\n\tconst addRule = (rule: string): void => {\n\t\tconst normalized = rule.trim();\n\t\tif (!normalized || seen.has(normalized)) return;\n\t\tseen.add(normalized);\n\t\trules.push(normalized);\n\t};\n\n\tconst tools = selectedTools;\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasPowerShell = tools.includes(\"powershell\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst shouldIncludeAskUserFallbackGuidance = tools.length > 0 && !tools.includes(\"ask_user_question\");\n\tconst addGuideline = addRule;\n\tif ((hasBash || hasPowerShell) && !hasFind && !hasLs) {\n\t\tif (hasBash && hasPowerShell) {\n\t\t\taddRule(\"Use bash or PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else if (hasPowerShell) {\n\t\t\taddRule(\"Use PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else {\n\t\t\taddRule(\"Use bash for file operations like ls, rg, find\");\n\t\t}\n\t}\n\tif (shouldIncludeAskUserFallbackGuidance) {\n\t\taddGuideline(\n\t\t\t\"If an equivalent user-question tool is available, use it for all questions to the user instead of plain text, including confirmations and approvals, following its supported schema. When no usable question tool or human-input channel exists, do not stall on a question: choose the interpretation best supported by the repository and the stated objective, state the assumption in your response, and continue fully autonomously on best judgment. Tool unavailability alone is not a blocker. Preserve safety and authorization constraints.\",\n\t\t);\n\t}\n\tif (hasBash || hasPowerShell) {\n\t\taddGuideline(\n\t\t\t\"**Repository intent**: When working in a repository, infer how its maintainers actually work before imposing defaults: review recent commits, open and merged PRs, issues and their comments, and project/board status when tooling allows (for example `git log` and the `gh` CLI) to learn conventions, priorities, and scope norms. Better, identify the requesting user (`git config user.name`/`user.email`, `gh api user`) and study their own commits, PRs, reviews, and issue comments so you interpret ambiguous requests the way they would, aligning style, scope, and process with their patterns.\",\n\t\t);\n\t\taddGuideline(\n\t\t\t[\n\t\t\t\t\"**Execution history**: Leave a mineable record of how each task was executed and what the user prefers, and mine those records to calibrate later work. The records only accumulate value if every task writes them. If the user, a context file, or `APPEND_SYSTEM.md` asks you not to record some or all of these records, skip those records.\",\n\t\t\t\t\" - When you author a commit, PR, issue, or issue/review comment for a task, record how it ran: `Assistant-workflow: <workflow name> (run <runId>)` for a registered or custom workflow, or `Assistant-workflow: inline` when no workflow was used; and `Assistant-duration: <elapsed> <converged|blocked|abandoned>, estimated <estimate>` (for example `Assistant-duration: 42m converged, estimated 30m`), measuring wall-clock time from launch or task start until acceptance was proven or work stopped, including resumes and repair rounds. Take elapsed time from workflow status timing or timestamps you recorded (for example `date` at task start); write `unmeasured` rather than guess. Put these as trailers alongside `Assistant-model` in commits (git trailers, or the equivalent commit-message metadata in the repository's version control system) and as the same `Key: value` lines in PR/merge request, issue, and comment bodies. For multi-commit work, record the workflow on each commit and the final duration once, in the last commit or the PR body.\",\n\t\t\t\t\" - In the same artifacts, record how the result was verified with one `Assistant-verification: <method> <passed|failed|unavailable>: <what it proved or why>` line per method that actually ran or was attempted (for example `Assistant-verification: herdr terminal E2E passed: /tasks lists running tasks first at 80x24`, `Assistant-verification: vitest unit passed: npm run test:unit`, or `Assistant-verification: agent-desktop unavailable: Accessibility permission not granted`). Name the concrete mechanism, such as unit, integration, or E2E tests, agent-browser, agent-desktop, herdr or tmux terminal automation, the qlty CLI, typecheck or lint, or a manual scenario, and the command or scenario it exercised. Record only checks that ran and their observed outcome; never record a skipped, mocked, or planned check as passed.\",\n\t\t\t\t\" - When the user states or reveals a durable preference about how they work (a correction, a rejected approach, scope, review, tooling, or communication style), record it in the same artifacts as `User-preference: <one line, in the user's terms>`, and tie it to the requesting user with a `Co-authored-by: <name> <email>` trailer taken from their version control identity (for example `git config user.name`/`user.email`) unless that line is already present; in PR, issue, and comment bodies, add the same line or their hosting account (for example from `gh api user`). Record only what the user expressed or their own edits show; never record secrets, credentials, or personal details unrelated to the work. If repository rules restrict commit or PR formats, fit the records into what they allow.\",\n\t\t\t\t\" - Before choosing between a workflow and inline work, choosing how to verify a change, estimating a duration, or interpreting an ambiguous request, mine these records with the rest of the history using the repository's version control system and its hosting CLI, for example `git log --format='%h %an <%ae> %s%n%(trailers:key=Assistant-workflow,key=Assistant-duration,key=Assistant-verification,key=User-preference,key=Co-authored-by)'` with `gh pr list --state all --search 'Assistant-workflow in:body'` on GitHub, or the equivalent commands for other systems and hosts (for example `glab` on GitLab). Compare tasks of similar kind and size, and state the sample size with the median and range. Treat fewer than five comparable records as anecdotal, and prefer the more recent record when two conflict. When choosing verification, start from the methods that proved comparable changes (the same files, subsystem, or kind of change), reuse their commands and scenarios, and do not retry a setup recorded as `unavailable` without a reason to expect a different result; past records never replace the project's required checks. Prioritize preferences tied to the requesting user by their co-author line, commit author, or hosting account. When the user has none that cover the situation, fall back to other contributors' relevant preferences as repository conventions; the user's own records and current request override them, so users can always encode their own preference. This history is a guide, not the decision: the current request, the task itself, and explicit user instructions decide between a workflow and inline work. Missing, sparse, or mostly inline workflow history is not evidence that the user prefers inline work: records exist only for tasks that wrote them, and past inline runs may reflect an earlier default rather than a choice. Without a recorded or stated preference that covers the situation, judge the task's shape yourself and choose a workflow when it would help, then let comparable records and the user's preferences refine that call.\",\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t}\n\n\tfor (const name of selectedTools) {\n\t\tfor (const rule of toolGuidelines[name] ?? []) addRule(rule);\n\t}\n\tfor (const rule of promptGuidelines) addRule(rule);\n\taddRule(\n\t\t\"Write self-describing code and do not add comments unless the user explicitly asks for them or the task instructions call for them. Code that needs a comment to be understood is a smell: restructure it with clearer names, smaller units, or explicit types instead\",\n\t);\n\taddRule(\"Be concise in your responses\");\n\taddRule(\"Show file paths clearly when working with files\");\n\treturn rules.map((rule) => `- ${rule}`).join(\"\\n\");\n}\n\n/** Build the ordered, independently replaceable sections of the structured system prompt. */\nexport function buildSystemPromptSections(input: BuildSystemPromptOptions): SystemPromptSections {\n\tconst options = normalizeBuildSystemPromptOptions(input);\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\ttoolGuidelines,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tsections: customSections,\n\t\tcwd,\n\t\tcontextFiles,\n\t\tskills,\n\t} = options;\n\tconst explicitlyExcludedTools = new Set(options.excludedTools ?? []);\n\tconst tools = selectedTools.filter((name) => !explicitlyExcludedTools.has(name));\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\tconst modelName = options.selectedModel?.name?.trim() || options.selectedModel?.id || \"unknown\";\n\tconst modelReasoningLevel = options.selectedThinkingLevel?.trim() || \"off\";\n\tconst now = new Date();\n\tconst date = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}`;\n\n\tfor (const name of Object.keys(customSections)) {\n\t\tif (!SYSTEM_PROMPT_SECTION_NAME.test(name) || name === \"preamble\") {\n\t\t\tthrow new Error(`Invalid system prompt section name: ${name}`);\n\t\t}\n\t}\n\n\tconst declaredTools = tools.filter((name) => !options.hiddenTools.includes(name));\n\tconst promptSections: Record<string, string> = {};\n\tif (customPrompt) {\n\t\tpromptSections.preamble = customPrompt;\n\t} else {\n\t\tpromptSections.preamble =\n\t\t\t\"You are an expert coding assistant operating named Atomic, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\";\n\t\tconst visibleTools = declaredTools.filter((name) => !!toolSnippets[name]);\n\t\tconst toolsList =\n\t\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets[name]}`).join(\"\\n\") : \"(none)\";\n\t\tpromptSections.tools = `Available tools:\\n${toolsList}\\n\\nIn addition to the tools above, you may have access to other custom tools depending on the project.`;\n\t\tpromptSections.rules = `Guidelines:\\n${buildRules(declaredTools, toolGuidelines, promptGuidelines)}`;\n\t\tpromptSections.docs = `\nAtomic documentation (read when the user asks about model choice, computer use or automation, MCP, web access, intercom, subagents, or customizing Atomic itself, its SDK, creating workflows, packages, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- Docs/examples references above must be resolved against these absolute roots; e.g. docs/foo.md means ${docsPath}/foo.md and examples/bar means ${examplesPath}/bar.\n- When asked about: atomic workflows (docs/workflows.md), extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), atomic packages (docs/packages.md), codemode scripts and non-LLM models such as classifiers and image models (docs/codemode.md)\n- Bundled integrations use the same docs root in npm and binary installations: MCP servers (docs/mcp-servers.md), web access (docs/web-access.md), intercom (docs/intercom.md), subagents (docs/subagents.md), workflows (docs/workflows.md). Read these guides rather than guessing paths inside builtin packages.\n- When the user asks which model to choose for a task, read ${docsPath}/models/model-selection.md and ${docsPath}/models/evals.md, then consult https://artificialanalysis.ai/ for the relevant benchmark charts and methodology. Match the task to individual evaluations rather than an aggregate winner. Cite the benchmark, source date, exact model/effort and cost or latency tradeoff; distinguish measured results from recommendations. If live evidence is unavailable, label the dated docs snapshot instead of claiming a refresh. Check the configured catalog before giving an exact provider/model or thinking setting; catalog presence is not proof of live access.\n- For computer use on native desktop apps and OS dialogs on macOS, Windows and Linux, use the bundled agent-desktop skill and one-shot \\`agent-desktop\\` commands. Before the first action run \\`agent-desktop status\\`, \\`agent-desktop skills get desktop\\` and \\`agent-desktop skills get platform\\` and follow them; they match the installed binary. When workflow TypeScript code owns the sequence and postcondition, call the CLI from inside ctx.tool, one process per command, parsing its JSON envelope, forwarding the signal, with a finite timeoutMs. If \\`agent-desktop version\\` fails, make one bounded \\`npm install -g agent-desktop\\` attempt and report its side effects. Atomic bundles the skill: never run \\`npx skills add\\` for it or copy a skill into other agent directories, and leave existing user-level skills alone. Let the user grant permissions (\\`agent-desktop permissions --guide\\` on macOS; on Linux a graphical session with an AT-SPI bus); never script around a consent dialog. See ${docsPath}/computer-use.md. Prefer the agent-browser skill for what it covers, because its text snapshots cost far fewer tokens: websites and web apps in Chrome/Chromium, Mobile Safari in the iOS Simulator (\\`agent-browser -p ios\\`), Electron and other CDP-exposing apps, Slack, and cloud browsers. Use agent-desktop for everything native and whenever agent-browser hits a limitation. agent-desktop reads accessibility trees, not pixels, and has no native iOS or Android support: say what stayed unverified, and use \\`xcrun simctl\\`, Appium or \\`adb\\` for native mobile apps. For terminal automation/testing, prefer herdr on macOS, Linux and Windows; install it if missing when network access and permissions permit, and fall back to tmux or native Windows psmux if installation or use is not possible. Load the matching skill and ${docsPath}/workflows/verification.md. Preserve the pinned herdr skill's explicit-request and HERDR_ENV=1 requirements; never control a focused session from outside Herdr. Check installed capabilities, use dedicated sessions, respect desktop permissions, and stop before destructive actions. These CLIs are not interchangeable, and skills do not grant tools or authorization.\n- When working on Atomic topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read Atomic .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\t}\n\n\tif (appendSystemPrompt) promptSections.addendum = appendSystemPrompt;\n\tif (contextFiles.length > 0) promptSections.project_context = renderProjectContext(contextFiles);\n\tconst readers = [\"read\", \"bash\"] as const;\n\tconst skillFileReadTool =\n\t\treaders.find((tool) => declaredTools.includes(tool)) ??\n\t\t(readers.some((tool) => tools.includes(tool)) ? \"indirect\" : undefined);\n\tif (skillFileReadTool && skills.length > 0) {\n\t\tconst skillsPrompt = formatSkillsForPrompt(skills, skillFileReadTool).trim();\n\t\tif (skillsPrompt) promptSections.skills = skillsPrompt;\n\t}\n\tpromptSections.model = `Model name (used for commit attribution): ${modelName}\\nModel reasoning level: ${modelReasoningLevel}`;\n\tpromptSections.date = `Current date: ${date}`;\n\tpromptSections.cwd = `Current working directory: ${cwd.replace(/\\\\/g, \"/\")}`;\n\tfor (const [name, content] of Object.entries(customSections)) {\n\t\tif (content) promptSections[name] = content;\n\t}\n\n\tconst sections: SystemPromptSections = { preamble: promptSections.preamble };\n\tfor (const [name, content] of Object.entries(promptSections)) {\n\t\tif (name !== \"preamble\") sections[name] = `<${name}>\\n${content}\\n</${name}>`;\n\t}\n\treturn sections;\n}\n\n/**\n * The complete prompt state for `input`. A forced prompt is opaque and lives in `content`\n * with no sections; otherwise `content` is empty and the structured sections carry the prompt.\n */\nexport function buildSystemPromptState(input: BuildSystemPromptOptions): {\n\tcontent: string;\n\tsections?: SystemPromptSections;\n} {\n\tif (input.forceSystemPrompt !== undefined) return { content: input.forceSystemPrompt };\n\treturn { content: \"\", sections: buildSystemPromptSections(input) };\n}\n\n/** Build the system prompt text, rendered exactly as the transcript's system message replays it. */\nexport function buildSystemPrompt(input: BuildSystemPromptOptions): string {\n\treturn getSystemMessageText({ role: \"system\", ...buildSystemPromptState(input), timestamp: 0 });\n}\n\n/**\n * Diff the sections the model currently has (replayed from the transcript, so never null)\n * against the desired ones. Returns a `SystemMessage.sections` patch, or undefined when\n * nothing changed.\n */\nexport function diffSystemPromptSections(\n\tprevious: Record<string, string | null>,\n\tcurrent: SystemPromptSections,\n): Record<string, string | null> | undefined {\n\tconst patch: Record<string, string | null> = {};\n\tfor (const [name, text] of Object.entries(current)) {\n\t\tif (previous[name] !== text) patch[name] = text;\n\t}\n\tfor (const name of Object.keys(previous)) {\n\t\tif (current[name] === undefined) patch[name] = null;\n\t}\n\treturn Object.keys(patch).length > 0 ? patch : undefined;\n}\n"]}
|