@bastani/atomic 0.9.74 → 0.9.75-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 +68 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +8 -0
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/skills/agent-browser/SKILL.md +8 -10
- package/dist/builtin/subagents/skills/agent-desktop/SKILL.md +9 -5
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -1
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +32 -0
- package/dist/builtin/workflows/README.md +5 -2
- package/dist/builtin/workflows/builtin/{chunk-m8eg152f.js → chunk-89we7r4p.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-a4fdm2cw.js → chunk-8yfssw01.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-774myqzs.js → chunk-v8mb0005.js} +366 -45
- package/dist/builtin/workflows/builtin/{chunk-d5cxskkp.js → chunk-wh2p4qjg.js} +2 -2
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.d.ts +10 -0
- package/dist/builtin/workflows/builtin/index.js +4 -4
- package/dist/builtin/workflows/builtin/open-claude-design.d.ts +12 -0
- package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +3 -2
- package/dist/builtin/workflows/skills/impeccable/reference/distill.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/harden.md +19 -0
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +15 -8
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/live.md +8 -6
- package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +0 -1
- package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/command-metadata.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/engine-checksums.txt +9 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +98 -44
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +101 -34
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +6 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +4 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +444 -144
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +3 -1
- package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +13 -11
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +10 -8
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_2.md +143 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_haiku_5_5.md +11 -7
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +3 -3
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +6 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +7 -7
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5_5.md +3 -3
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +6 -5
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +4 -4
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_terra.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -3
- package/dist/builtin/workflows/skills/skill-creator/scripts/aggregate_benchmark.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/generate_report.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/improve_description.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/package_skill.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/quick_validate.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/run_eval.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/run_loop.py +0 -0
- package/dist/builtin/workflows/skills/unslop/SKILL.md +15 -34
- package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +1 -0
- package/dist/builtin/workflows/src/durable/journal/values.d.ts +2 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +809 -410
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +695 -305
- package/dist/builtin/workflows/src/index.js +685 -295
- package/dist/builtin/workflows/src/local-worker-entry.mjs +695 -305
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +6 -6
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +2 -2
- package/dist/builtin/workflows/src/shared/serializable-error-families.d.ts +2 -0
- package/dist/bun/app-host-modules.d.ts +1 -1
- package/dist/bun/app-host-modules.d.ts.map +1 -1
- package/dist/bun/app-host-modules.js.map +1 -1
- package/dist/bun/internal-workflow-worker.d.ts +2 -0
- package/dist/bun/internal-workflow-worker.d.ts.map +1 -1
- package/dist/bun/internal-workflow-worker.js +2 -1
- package/dist/bun/internal-workflow-worker.js.map +1 -1
- package/dist/codemode-worker.js +2 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +2 -1
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-blueprint-environment.d.ts +10 -0
- package/dist/core/agent-session-blueprint-environment.d.ts.map +1 -0
- package/dist/core/agent-session-blueprint-environment.js +28 -0
- package/dist/core/agent-session-blueprint-environment.js.map +1 -0
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +2 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +1 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +14 -4
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +20 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +55 -6
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +2 -1
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/async-scope.d.ts +13 -0
- package/dist/core/async-scope.d.ts.map +1 -0
- package/dist/core/async-scope.js +20 -0
- package/dist/core/async-scope.js.map +1 -0
- package/dist/core/cache-warmer.d.ts +3 -14
- package/dist/core/cache-warmer.d.ts.map +1 -1
- package/dist/core/cache-warmer.js +8 -60
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/extensions/extension-work.js +2 -2
- package/dist/core/extensions/extension-work.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +3 -1
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +2 -1
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/extensions/workflow-events.d.ts +1 -1
- package/dist/core/extensions/workflow-events.d.ts.map +1 -1
- package/dist/core/extensions/workflow-events.js.map +1 -1
- package/dist/core/extensions/workflow-run-control.d.ts +4 -2
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +6 -0
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +10 -1
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/preferred-providers.d.ts +19 -0
- package/dist/core/preferred-providers.d.ts.map +1 -0
- package/dist/core/preferred-providers.js +25 -0
- package/dist/core/preferred-providers.js.map +1 -0
- package/dist/core/provider-alias.d.ts.map +1 -1
- package/dist/core/provider-alias.js +4 -0
- package/dist/core/provider-alias.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +1 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +3 -0
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resume/blueprint/action-expressions.d.ts +32 -0
- package/dist/core/resume/blueprint/action-expressions.d.ts.map +1 -0
- package/dist/core/resume/blueprint/action-expressions.js +389 -0
- package/dist/core/resume/blueprint/action-expressions.js.map +1 -0
- package/dist/core/resume/blueprint/actions.d.ts +90 -0
- package/dist/core/resume/blueprint/actions.d.ts.map +1 -0
- package/dist/core/resume/blueprint/actions.js +818 -0
- package/dist/core/resume/blueprint/actions.js.map +1 -0
- package/dist/core/resume/blueprint/build.d.ts +102 -0
- package/dist/core/resume/blueprint/build.d.ts.map +1 -0
- package/dist/core/resume/blueprint/build.js +535 -0
- package/dist/core/resume/blueprint/build.js.map +1 -0
- package/dist/core/resume/blueprint/context.d.ts +11 -0
- package/dist/core/resume/blueprint/context.d.ts.map +1 -0
- package/dist/core/resume/blueprint/context.js +106 -0
- package/dist/core/resume/blueprint/context.js.map +1 -0
- package/dist/core/resume/blueprint/envrc.d.ts +19 -0
- package/dist/core/resume/blueprint/envrc.d.ts.map +1 -0
- package/dist/core/resume/blueprint/envrc.js +77 -0
- package/dist/core/resume/blueprint/envrc.js.map +1 -0
- package/dist/core/resume/blueprint/errors.d.ts +179 -0
- package/dist/core/resume/blueprint/errors.d.ts.map +1 -0
- package/dist/core/resume/blueprint/errors.js +169 -0
- package/dist/core/resume/blueprint/errors.js.map +1 -0
- package/dist/core/resume/blueprint/ledger.d.ts +51 -0
- package/dist/core/resume/blueprint/ledger.d.ts.map +1 -0
- package/dist/core/resume/blueprint/ledger.js +119 -0
- package/dist/core/resume/blueprint/ledger.js.map +1 -0
- package/dist/core/resume/blueprint/notices.d.ts +14 -0
- package/dist/core/resume/blueprint/notices.d.ts.map +1 -0
- package/dist/core/resume/blueprint/notices.js +44 -0
- package/dist/core/resume/blueprint/notices.js.map +1 -0
- package/dist/core/resume/blueprint/process.d.ts +44 -0
- package/dist/core/resume/blueprint/process.d.ts.map +1 -0
- package/dist/core/resume/blueprint/process.js +142 -0
- package/dist/core/resume/blueprint/process.js.map +1 -0
- package/dist/core/resume/blueprint/resume.d.ts +73 -0
- package/dist/core/resume/blueprint/resume.d.ts.map +1 -0
- package/dist/core/resume/blueprint/resume.js +206 -0
- package/dist/core/resume/blueprint/resume.js.map +1 -0
- package/dist/core/resume/blueprint/schema.d.ts +26 -0
- package/dist/core/resume/blueprint/schema.d.ts.map +1 -0
- package/dist/core/resume/blueprint/schema.js +243 -0
- package/dist/core/resume/blueprint/schema.js.map +1 -0
- package/dist/core/resume/blueprint/steps.d.ts +54 -0
- package/dist/core/resume/blueprint/steps.d.ts.map +1 -0
- package/dist/core/resume/blueprint/steps.js +155 -0
- package/dist/core/resume/blueprint/steps.js.map +1 -0
- package/dist/core/resume/blueprint/types.d.ts +63 -0
- package/dist/core/resume/blueprint/types.d.ts.map +1 -0
- package/dist/core/resume/blueprint/types.js +2 -0
- package/dist/core/resume/blueprint/types.js.map +1 -0
- package/dist/core/resume/errors.d.ts +7 -35
- package/dist/core/resume/errors.d.ts.map +1 -1
- package/dist/core/resume/errors.js +1 -21
- package/dist/core/resume/errors.js.map +1 -1
- package/dist/core/resume/index.d.ts +12 -4
- package/dist/core/resume/index.d.ts.map +1 -1
- package/dist/core/resume/index.js +11 -4
- package/dist/core/resume/index.js.map +1 -1
- package/dist/core/resume/run-setup.d.ts +36 -15
- package/dist/core/resume/run-setup.d.ts.map +1 -1
- package/dist/core/resume/run-setup.js +70 -54
- package/dist/core/resume/run-setup.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +34 -20
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +244 -106
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/retry-policy.d.ts +19 -1
- package/dist/core/retry-policy.d.ts.map +1 -1
- package/dist/core/retry-policy.js +26 -1
- package/dist/core/retry-policy.js.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.d.ts +56 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +94 -4
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +10 -5
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-worktree-snapshots.d.ts +11 -0
- package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
- package/dist/core/session-worktree-snapshots.js +10 -4
- package/dist/core/session-worktree-snapshots.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +1 -1
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +1 -1
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +3 -2
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +2 -1
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +4 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/storage/write-ahead-log.d.ts +2 -1
- package/dist/core/storage/write-ahead-log.d.ts.map +1 -1
- package/dist/core/storage/write-ahead-log.js +27 -6
- package/dist/core/storage/write-ahead-log.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +10 -0
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/file-tool-errors.d.ts +1 -1
- package/dist/core/tools/file-tool-errors.js +1 -1
- package/dist/core/tools/file-tool-errors.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +52 -26
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +2 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +10 -2
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/tool-concurrency.d.ts.map +1 -1
- package/dist/core/tools/tool-concurrency.js +2 -2
- package/dist/core/tools/tool-concurrency.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +12 -4
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +28 -4
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -8
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +5 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +6 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +34 -13
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/provider-brand.d.ts +16 -0
- package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
- package/dist/modes/interactive/components/provider-brand.js +67 -0
- package/dist/modes/interactive/components/provider-brand.js.map +1 -0
- package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +8 -6
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +4 -3
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +8 -3
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +59 -21
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +23 -12
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/login-provider-options.d.ts.map +1 -1
- package/dist/modes/interactive/login-provider-options.js +2 -1
- package/dist/modes/interactive/login-provider-options.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +8 -3
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +2 -1
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +0 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +2 -18
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +8 -2
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-error-decoding.d.ts +7 -0
- package/dist/modes/rpc/rpc-error-decoding.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-error-decoding.js +25 -0
- package/dist/modes/rpc/rpc-error-decoding.js.map +1 -0
- package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-responses.js +12 -0
- package/dist/modes/rpc/rpc-responses.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +11 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +12 -3
- package/dist/package-manager-cli.js.map +1 -1
- package/docs/background-tasks.md +1 -1
- package/docs/codemode.md +22 -0
- package/docs/extensions/api-reference.md +27 -1
- package/docs/extensions/authoring.md +1 -1
- package/docs/extensions/ui.md +1 -1
- package/docs/getting-started/first-session.md +1 -1
- package/docs/guides/resume-on-any-machine.md +72 -19
- package/docs/models/evals.md +85 -17
- package/docs/models/reference.md +1 -1
- package/docs/providers.md +38 -5
- package/docs/reference/cli.md +2 -0
- package/docs/rpc/protocol.md +11 -1
- package/docs/sdk/reference.md +36 -4
- package/docs/sdk.md +2 -2
- package/docs/sessions.md +11 -1
- package/docs/settings.md +7 -2
- package/docs/skills.md +3 -3
- package/docs/storage.md +1 -1
- package/docs/tools.md +3 -1
- package/docs/workflows/api-reference.md +14 -12
- package/docs/workflows/authoring.md +29 -1
- package/docs/workflows/builtins.md +9 -1
- package/docs/workflows/operations.md +8 -8
- package/docs/worktree-snapshots.md +3 -2
- package/npm-shrinkwrap.json +83 -67
- package/package.json +7 -7
- package/schemas/settings.schema.json +3 -2
- package/dist/core/resume/setup-hook.d.ts +0 -69
- package/dist/core/resume/setup-hook.d.ts.map +0 -1
- package/dist/core/resume/setup-hook.js +0 -261
- package/dist/core/resume/setup-hook.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.d.ts","sourceRoot":"","sources":["../../../../src/core/resume/blueprint/resume.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAIxB,MAAM,YAAY,CAAC;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AO,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAoCD;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAkBxG;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC5C,SAAS,EAAE,SAAS,iBAAiB,EAAE,EACvC,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAQ9B;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC3C,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,wHAAwH;AACxH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQ7E;AAwCD,sHAAsH;AACtH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK1F;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CAClD,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GACf,OAAO,CAAC,yBAAyB,GAAG,SAAS,CAAC,CAehD"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, isAbsolute, join, parse, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { describeBlueprints, needsRebuild, runBlueprintBuild, } from "./build.js";
|
|
5
|
+
import { BLUEPRINT_CONTEXT_TYPE, renderBlueprintContext } from "./context.js";
|
|
6
|
+
import { BlueprintBuildFailedError } from "./errors.js";
|
|
7
|
+
import { readLedger, rootKey } from "./ledger.js";
|
|
8
|
+
import { blueprintNotices } from "./notices.js";
|
|
9
|
+
/** The repository a checkout belongs to for the build ledger: its sorted remotes, else its own root. */
|
|
10
|
+
export function blueprintRepository(checkout) {
|
|
11
|
+
const identity = checkout.remotes.length === 0 ? checkout.root : [...checkout.remotes].sort().join("\n");
|
|
12
|
+
return { root: checkout.root, identity };
|
|
13
|
+
}
|
|
14
|
+
function latestRestoreInto(restores, root) {
|
|
15
|
+
for (let index = restores.length - 1; index >= 0; index--) {
|
|
16
|
+
const restore = restores[index];
|
|
17
|
+
if (resolve(restore.to) === root)
|
|
18
|
+
return restore;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The remotes that identify the repository of the checkout at `root` for the build ledger. A worktree Atomic restored
|
|
24
|
+
* comes from a store without remotes, so a snapshot captured inside it records none; the repository's remotes are then
|
|
25
|
+
* found by following the recorded restores back, from the worktree to the checkout it replaced, to the first snapshot
|
|
26
|
+
* that has some. `own` are the remotes of the checkout's own latest snapshot. Empty when the chain has none, in which
|
|
27
|
+
* case the repository is identified by its root.
|
|
28
|
+
*/
|
|
29
|
+
export function inheritedRemotes(root, own, restores, snapshots) {
|
|
30
|
+
if (own.length > 0)
|
|
31
|
+
return own;
|
|
32
|
+
let current = resolve(root);
|
|
33
|
+
for (let hop = 0; hop < restores.length; hop++) {
|
|
34
|
+
const link = latestRestoreInto(restores, current);
|
|
35
|
+
if (link === undefined)
|
|
36
|
+
break;
|
|
37
|
+
const remotes = snapshots.get(link.snapshotId)?.remotes ?? [];
|
|
38
|
+
if (remotes.length > 0)
|
|
39
|
+
return remotes;
|
|
40
|
+
current = resolve(link.from);
|
|
41
|
+
}
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Builds the blueprints of the worktrees a resume restored and describes every checkout the session works in.
|
|
46
|
+
*/
|
|
47
|
+
async function setUpAndDescribe(options) {
|
|
48
|
+
const restored = options.restored.map(blueprintRepository);
|
|
49
|
+
const outcome = restored.length === 0 ? undefined : await runBlueprintBuild(restored, options.config, options.signal);
|
|
50
|
+
const layers = [...(outcome?.layers ?? [])];
|
|
51
|
+
const described = [
|
|
52
|
+
[options.inPlace, "in-place"],
|
|
53
|
+
[options.earlier, "earlier"],
|
|
54
|
+
];
|
|
55
|
+
for (const [checkouts, reason] of described) {
|
|
56
|
+
if (checkouts === undefined || checkouts.length === 0)
|
|
57
|
+
continue;
|
|
58
|
+
const includeGlobal = !layers.some((layer) => layer.scope === "global");
|
|
59
|
+
layers.push(...(await describeBlueprints(checkouts.map(blueprintRepository), options.config, reason, includeGlobal)));
|
|
60
|
+
}
|
|
61
|
+
if (outcome === undefined && !layers.some((layer) => layer.scope === "global")) {
|
|
62
|
+
layers.unshift(...(await describeBlueprints([], options.config, "skipped")));
|
|
63
|
+
}
|
|
64
|
+
const notRemembered = await persistRootContexts(options.config.storeDir, restored, layers);
|
|
65
|
+
return {
|
|
66
|
+
outcome,
|
|
67
|
+
notices: [
|
|
68
|
+
...(outcome === undefined ? [] : blueprintNotices(outcome, Boolean(options.config.setupCommand?.trim()))),
|
|
69
|
+
...notRemembered,
|
|
70
|
+
],
|
|
71
|
+
layers,
|
|
72
|
+
context: renderBlueprintContext(layers),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Builds the blueprints of the worktrees a resume restored and describes every checkout the session works in. Never
|
|
77
|
+
* rejects for a blueprint or for the state it keeps: a failure is in the outcome and the notices, and an unexpected
|
|
78
|
+
* one becomes a warning that the session resumed anyway. Only `signal` aborting rejects, with its reason.
|
|
79
|
+
*/
|
|
80
|
+
export async function setUpResumedBlueprints(options) {
|
|
81
|
+
try {
|
|
82
|
+
return await setUpAndDescribe(options);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (options.signal?.aborted)
|
|
86
|
+
throw error;
|
|
87
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
88
|
+
return {
|
|
89
|
+
outcome: undefined,
|
|
90
|
+
notices: [
|
|
91
|
+
{
|
|
92
|
+
type: "warning",
|
|
93
|
+
message: `Blueprint setup stopped unexpectedly: ${failure.message.slice(0, 200)}. The session resumed anyway.`,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
layers: [],
|
|
97
|
+
context: undefined,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The restored worktrees of `checkouts` whose last build failed or never finished: they are built again. When the
|
|
103
|
+
* ledger cannot be read, none is known to be built, so all are; the build then reports the ledger as the failure.
|
|
104
|
+
*/
|
|
105
|
+
export async function checkoutsNeedingRebuild(checkouts, storeDir) {
|
|
106
|
+
let ledger;
|
|
107
|
+
try {
|
|
108
|
+
ledger = await readLedger(storeDir);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return [...checkouts];
|
|
112
|
+
}
|
|
113
|
+
return checkouts.filter((checkout) => needsRebuild(ledger, checkout.root));
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Puts `context` in the session so the agent sees it in its next turn, unless the latest blueprint context in the
|
|
117
|
+
* session already says the same. A session that resumes again before anything changed gets no duplicate.
|
|
118
|
+
*/
|
|
119
|
+
export async function recordBlueprintContext(sessionManager, context) {
|
|
120
|
+
if (context === undefined)
|
|
121
|
+
return;
|
|
122
|
+
const branch = sessionManager.getBranch();
|
|
123
|
+
for (let index = branch.length - 1; index >= 0; index--) {
|
|
124
|
+
const entry = branch[index];
|
|
125
|
+
if (entry.type === "custom_message" && entry.customType === BLUEPRINT_CONTEXT_TYPE) {
|
|
126
|
+
if (entry.content === context)
|
|
127
|
+
return;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
await sessionManager.appendCustomMessageEntry(BLUEPRINT_CONTEXT_TYPE, context, false);
|
|
132
|
+
}
|
|
133
|
+
/** The root of the repository `directory` is in, found by looking for `.git` upward; undefined outside a repository. */
|
|
134
|
+
export function enclosingRepositoryRoot(directory) {
|
|
135
|
+
let current = directory;
|
|
136
|
+
for (;;) {
|
|
137
|
+
if (existsSync(join(current, ".git")))
|
|
138
|
+
return current;
|
|
139
|
+
const parent = dirname(current);
|
|
140
|
+
if (parent === current || current === parse(current).root)
|
|
141
|
+
return undefined;
|
|
142
|
+
current = parent;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function contextFile(storeDir, root) {
|
|
146
|
+
return join(storeDir, "blueprint-context", `${rootKey(root)}.md`);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Keeps, for each worktree a build just set up, what the agent is told about it, so a session that starts in that
|
|
150
|
+
* worktree later without this resume (a stage of a resumed workflow run, a pooled child) is told the same.
|
|
151
|
+
*/
|
|
152
|
+
async function persistRootContexts(storeDir, restored, layers) {
|
|
153
|
+
try {
|
|
154
|
+
for (const repository of restored) {
|
|
155
|
+
const context = renderBlueprintContext(layers.filter((layer) => layer.scope === "global" || layer.root === repository.root));
|
|
156
|
+
const file = contextFile(storeDir, repository.root);
|
|
157
|
+
if (context === undefined) {
|
|
158
|
+
await rm(file, { force: true });
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
await mkdir(dirname(file), { recursive: true });
|
|
162
|
+
await writeFile(file, context, { mode: 0o600 });
|
|
163
|
+
}
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
168
|
+
return [
|
|
169
|
+
{
|
|
170
|
+
type: "warning",
|
|
171
|
+
message: `The blueprint context could not be kept for later sessions in these worktrees: ${reason.slice(0, 200)}.`,
|
|
172
|
+
},
|
|
173
|
+
];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** The worktree this machine restored that holds `directory`, under `storeDir`; undefined for any other directory. */
|
|
177
|
+
export function restoredWorktreeOf(storeDir, directory) {
|
|
178
|
+
const worktrees = resolve(storeDir, "worktrees");
|
|
179
|
+
const path = relative(worktrees, resolve(directory));
|
|
180
|
+
if (path === "" || path === ".." || path.startsWith(`..${sep}`) || isAbsolute(path))
|
|
181
|
+
return undefined;
|
|
182
|
+
return join(worktrees, path.split(sep)[0]);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Puts the blueprint context of the worktree `directory` is in into a session that starts there without a resume of
|
|
186
|
+
* its own, such as a stage of a resumed workflow run. A directory outside the restored worktrees adds nothing. Never
|
|
187
|
+
* rejects: a kept context that cannot be read is returned as the typed failure, for the caller to report once, and the
|
|
188
|
+
* session starts without it.
|
|
189
|
+
*/
|
|
190
|
+
export async function recordRestoredWorktreeContext(sessionManager, storeDir, directory) {
|
|
191
|
+
const root = restoredWorktreeOf(storeDir, directory);
|
|
192
|
+
if (root === undefined)
|
|
193
|
+
return undefined;
|
|
194
|
+
let context;
|
|
195
|
+
try {
|
|
196
|
+
context = await readFile(contextFile(storeDir, root), "utf8");
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
if (error.code === "ENOENT")
|
|
200
|
+
return undefined;
|
|
201
|
+
return new BlueprintBuildFailedError({ phase: "environment", detail: `the blueprint context kept for ${root} could not be read` }, error instanceof Error ? error : new Error(String(error)));
|
|
202
|
+
}
|
|
203
|
+
await recordBlueprintContext(sessionManager, context);
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.js","sourceRoot":"","sources":["../../../../src/core/resume/blueprint/resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAk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AAG,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAClD,cAA8B,EAC9B,QAAgB,EAChB,SAAiB;IAEjB,MAAM,IAAI,GAAG,kBAAkB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACrD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACJ,OAAO,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QACzE,OAAO,IAAI,yBAAyB,CACnC,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,kCAAkC,IAAI,oBAAoB,EAAE,EAC5F,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CACzD,CAAC;IACH,CAAC;IACD,MAAM,sBAAsB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACtD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, parse, relative, resolve, sep } from \"node:path\";\nimport type { SessionManager } from \"../../session-manager.ts\";\nimport {\n\ttype BlueprintBuildConfig,\n\ttype BlueprintBuildOutcome,\n\ttype BlueprintLayer,\n\ttype BlueprintRepository,\n\tdescribeBlueprints,\n\tneedsRebuild,\n\trunBlueprintBuild,\n} from \"./build.ts\";\nimport { BLUEPRINT_CONTEXT_TYPE, renderBlueprintContext } from \"./context.ts\";\nimport { BlueprintBuildFailedError } from \"./errors.ts\";\nimport { type BlueprintLedger, readLedger, rootKey } from \"./ledger.ts\";\nimport { type BlueprintNotice, blueprintNotices } from \"./notices.ts\";\n\n/** A checkout of a session's repository on this node, with the remotes its snapshot recorded. */\nexport interface BlueprintCheckout {\n\treadonly root: string;\n\treadonly remotes: readonly string[];\n}\n\n/** The repository a checkout belongs to for the build ledger: its sorted remotes, else its own root. */\nexport function blueprintRepository(checkout: BlueprintCheckout): BlueprintRepository {\n\tconst identity = checkout.remotes.length === 0 ? checkout.root : [...checkout.remotes].sort().join(\"\\n\");\n\treturn { root: checkout.root, identity };\n}\n\n/** A restore a session or run recorded: work under `from` continues under `to`. */\nexport interface RestoreLink {\n\treadonly from: string;\n\treadonly to: string;\n\treadonly snapshotId: string;\n}\n\nfunction latestRestoreInto(restores: readonly RestoreLink[], root: string): RestoreLink | undefined {\n\tfor (let index = restores.length - 1; index >= 0; index--) {\n\t\tconst restore = restores[index]!;\n\t\tif (resolve(restore.to) === root) return restore;\n\t}\n\treturn undefined;\n}\n\n/**\n * The remotes that identify the repository of the checkout at `root` for the build ledger. A worktree Atomic restored\n * comes from a store without remotes, so a snapshot captured inside it records none; the repository's remotes are then\n * found by following the recorded restores back, from the worktree to the checkout it replaced, to the first snapshot\n * that has some. `own` are the remotes of the checkout's own latest snapshot. Empty when the chain has none, in which\n * case the repository is identified by its root.\n */\nexport function inheritedRemotes(\n\troot: string,\n\town: readonly string[],\n\trestores: readonly RestoreLink[],\n\tsnapshots: ReadonlyMap<string, { readonly remotes: readonly string[] }>,\n): readonly string[] {\n\tif (own.length > 0) return own;\n\tlet current = resolve(root);\n\tfor (let hop = 0; hop < restores.length; hop++) {\n\t\tconst link = latestRestoreInto(restores, current);\n\t\tif (link === undefined) break;\n\t\tconst remotes = snapshots.get(link.snapshotId)?.remotes ?? [];\n\t\tif (remotes.length > 0) return remotes;\n\t\tcurrent = resolve(link.from);\n\t}\n\treturn [];\n}\n\n/** What a resume does with the blueprints: the outcome of the build, what the user is told, what the agent is told. */\nexport interface ResumedBlueprints {\n\t/** Undefined when no build was attempted. */\n\treadonly outcome: BlueprintBuildOutcome | undefined;\n\treadonly notices: readonly BlueprintNotice[];\n\treadonly layers: readonly BlueprintLayer[];\n\t/** The first-turn context for the agent; undefined when no blueprint has anything to say. */\n\treadonly context: string | undefined;\n}\n\nexport interface SetUpBlueprintsOptions {\n\t/** Worktrees Atomic restored for this resume, or earlier and then failed to build: built now. */\n\treadonly restored: readonly BlueprintCheckout[];\n\t/** Checkouts used as they are or restored earlier and built then: only described for the agent. */\n\treadonly inPlace?: readonly BlueprintCheckout[];\n\treadonly earlier?: readonly BlueprintCheckout[];\n\treadonly config: BlueprintBuildConfig;\n\treadonly signal?: AbortSignal;\n}\n\n/**\n * Builds the blueprints of the worktrees a resume restored and describes every checkout the session works in.\n */\nasync function setUpAndDescribe(options: SetUpBlueprintsOptions): Promise<ResumedBlueprints> {\n\tconst restored = options.restored.map(blueprintRepository);\n\tconst outcome =\n\t\trestored.length === 0 ? undefined : await runBlueprintBuild(restored, options.config, options.signal);\n\tconst layers: BlueprintLayer[] = [...(outcome?.layers ?? [])];\n\tconst described: [readonly BlueprintCheckout[] | undefined, \"in-place\" | \"earlier\"][] = [\n\t\t[options.inPlace, \"in-place\"],\n\t\t[options.earlier, \"earlier\"],\n\t];\n\tfor (const [checkouts, reason] of described) {\n\t\tif (checkouts === undefined || checkouts.length === 0) continue;\n\t\tconst includeGlobal = !layers.some((layer) => layer.scope === \"global\");\n\t\tlayers.push(\n\t\t\t...(await describeBlueprints(checkouts.map(blueprintRepository), options.config, reason, includeGlobal)),\n\t\t);\n\t}\n\tif (outcome === undefined && !layers.some((layer) => layer.scope === \"global\")) {\n\t\tlayers.unshift(...(await describeBlueprints([], options.config, \"skipped\")));\n\t}\n\tconst notRemembered = await persistRootContexts(options.config.storeDir, restored, layers);\n\treturn {\n\t\toutcome,\n\t\tnotices: [\n\t\t\t...(outcome === undefined ? [] : blueprintNotices(outcome, Boolean(options.config.setupCommand?.trim()))),\n\t\t\t...notRemembered,\n\t\t],\n\t\tlayers,\n\t\tcontext: renderBlueprintContext(layers),\n\t};\n}\n\n/**\n * Builds the blueprints of the worktrees a resume restored and describes every checkout the session works in. Never\n * rejects for a blueprint or for the state it keeps: a failure is in the outcome and the notices, and an unexpected\n * one becomes a warning that the session resumed anyway. Only `signal` aborting rejects, with its reason.\n */\nexport async function setUpResumedBlueprints(options: SetUpBlueprintsOptions): Promise<ResumedBlueprints> {\n\ttry {\n\t\treturn await setUpAndDescribe(options);\n\t} catch (error) {\n\t\tif (options.signal?.aborted) throw error;\n\t\tconst failure = error instanceof Error ? error : new Error(String(error));\n\t\treturn {\n\t\t\toutcome: undefined,\n\t\t\tnotices: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: `Blueprint setup stopped unexpectedly: ${failure.message.slice(0, 200)}. The session resumed anyway.`,\n\t\t\t\t},\n\t\t\t],\n\t\t\tlayers: [],\n\t\t\tcontext: undefined,\n\t\t};\n\t}\n}\n\n/**\n * The restored worktrees of `checkouts` whose last build failed or never finished: they are built again. When the\n * ledger cannot be read, none is known to be built, so all are; the build then reports the ledger as the failure.\n */\nexport async function checkoutsNeedingRebuild(\n\tcheckouts: readonly BlueprintCheckout[],\n\tstoreDir: string,\n): Promise<BlueprintCheckout[]> {\n\tlet ledger: BlueprintLedger;\n\ttry {\n\t\tledger = await readLedger(storeDir);\n\t} catch {\n\t\treturn [...checkouts];\n\t}\n\treturn checkouts.filter((checkout) => needsRebuild(ledger, checkout.root));\n}\n\n/**\n * Puts `context` in the session so the agent sees it in its next turn, unless the latest blueprint context in the\n * session already says the same. A session that resumes again before anything changed gets no duplicate.\n */\nexport async function recordBlueprintContext(\n\tsessionManager: SessionManager,\n\tcontext: string | undefined,\n): Promise<void> {\n\tif (context === undefined) return;\n\tconst branch = sessionManager.getBranch();\n\tfor (let index = branch.length - 1; index >= 0; index--) {\n\t\tconst entry = branch[index]!;\n\t\tif (entry.type === \"custom_message\" && entry.customType === BLUEPRINT_CONTEXT_TYPE) {\n\t\t\tif (entry.content === context) return;\n\t\t\tbreak;\n\t\t}\n\t}\n\tawait sessionManager.appendCustomMessageEntry(BLUEPRINT_CONTEXT_TYPE, context, false);\n}\n\n/** The root of the repository `directory` is in, found by looking for `.git` upward; undefined outside a repository. */\nexport function enclosingRepositoryRoot(directory: string): string | undefined {\n\tlet current = directory;\n\tfor (;;) {\n\t\tif (existsSync(join(current, \".git\"))) return current;\n\t\tconst parent = dirname(current);\n\t\tif (parent === current || current === parse(current).root) return undefined;\n\t\tcurrent = parent;\n\t}\n}\n\nfunction contextFile(storeDir: string, root: string): string {\n\treturn join(storeDir, \"blueprint-context\", `${rootKey(root)}.md`);\n}\n\n/**\n * Keeps, for each worktree a build just set up, what the agent is told about it, so a session that starts in that\n * worktree later without this resume (a stage of a resumed workflow run, a pooled child) is told the same.\n */\nasync function persistRootContexts(\n\tstoreDir: string,\n\trestored: readonly BlueprintRepository[],\n\tlayers: readonly BlueprintLayer[],\n): Promise<BlueprintNotice[]> {\n\ttry {\n\t\tfor (const repository of restored) {\n\t\t\tconst context = renderBlueprintContext(\n\t\t\t\tlayers.filter((layer) => layer.scope === \"global\" || layer.root === repository.root),\n\t\t\t);\n\t\t\tconst file = contextFile(storeDir, repository.root);\n\t\t\tif (context === undefined) {\n\t\t\t\tawait rm(file, { force: true });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tawait mkdir(dirname(file), { recursive: true });\n\t\t\tawait writeFile(file, context, { mode: 0o600 });\n\t\t}\n\t\treturn [];\n\t} catch (error) {\n\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: \"warning\",\n\t\t\t\tmessage: `The blueprint context could not be kept for later sessions in these worktrees: ${reason.slice(0, 200)}.`,\n\t\t\t},\n\t\t];\n\t}\n}\n\n/** The worktree this machine restored that holds `directory`, under `storeDir`; undefined for any other directory. */\nexport function restoredWorktreeOf(storeDir: string, directory: string): string | undefined {\n\tconst worktrees = resolve(storeDir, \"worktrees\");\n\tconst path = relative(worktrees, resolve(directory));\n\tif (path === \"\" || path === \"..\" || path.startsWith(`..${sep}`) || isAbsolute(path)) return undefined;\n\treturn join(worktrees, path.split(sep)[0]!);\n}\n\n/**\n * Puts the blueprint context of the worktree `directory` is in into a session that starts there without a resume of\n * its own, such as a stage of a resumed workflow run. A directory outside the restored worktrees adds nothing. Never\n * rejects: a kept context that cannot be read is returned as the typed failure, for the caller to report once, and the\n * session starts without it.\n */\nexport async function recordRestoredWorktreeContext(\n\tsessionManager: SessionManager,\n\tstoreDir: string,\n\tdirectory: string,\n): Promise<BlueprintBuildFailedError | undefined> {\n\tconst root = restoredWorktreeOf(storeDir, directory);\n\tif (root === undefined) return undefined;\n\tlet context: string;\n\ttry {\n\t\tcontext = await readFile(contextFile(storeDir, root), \"utf8\");\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n\t\treturn new BlueprintBuildFailedError(\n\t\t\t{ phase: \"environment\", detail: `the blueprint context kept for ${root} could not be read` },\n\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t);\n\t}\n\tawait recordBlueprintContext(sessionManager, context);\n\treturn undefined;\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type BlueprintScope } from "./errors.ts";
|
|
2
|
+
import type { BlueprintDocument, BlueprintPlatform, ParsedBlueprint } from "./types.ts";
|
|
3
|
+
/** The rule texts Devin words itself, which a blueprint error carries verbatim. */
|
|
4
|
+
export declare const BLUEPRINT_RULES: {
|
|
5
|
+
readonly usesInMaintenance: "'uses' steps are not supported in maintenance sections";
|
|
6
|
+
readonly shell: "shell: must be 'default', 'bash', or 'powershell'";
|
|
7
|
+
readonly documentSequence: "each YAML document must be a mapping, not a sequence; use '---' to separate multiple blocks";
|
|
8
|
+
readonly documentScalar: "each YAML document must be a mapping, not a scalar; use '---' to separate multiple blocks";
|
|
9
|
+
};
|
|
10
|
+
/** The blueprint `runs-on` platform that a Node.js `process.platform` value names. */
|
|
11
|
+
export declare function blueprintPlatformOf(nodePlatform: NodeJS.Platform): BlueprintPlatform;
|
|
12
|
+
/** The platform this process runs on, as blueprint `runs-on` labels name it. */
|
|
13
|
+
export declare function hostPlatform(): BlueprintPlatform;
|
|
14
|
+
/** The document of `blueprint` that targets `platform`, if any. Other documents are never run or surfaced. */
|
|
15
|
+
export declare function selectDocument(blueprint: ParsedBlueprint, platform?: BlueprintPlatform): BlueprintDocument | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Parses and validates a blueprint file, in Devin's schema. Throws {@link BlueprintInvalidError} for the first rule it
|
|
18
|
+
* breaks. Validation covers every document, whichever platform it targets, and ignores keys it does not know.
|
|
19
|
+
* `includes` is read in a repository's root blueprint only, ignored in the global one and rejected in a workspace
|
|
20
|
+
* blueprint; `post-build` is accepted in the global blueprint only; `clone` is accepted and reported as ignored.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseBlueprint(source: string, location: {
|
|
23
|
+
path: string;
|
|
24
|
+
scope: BlueprintScope;
|
|
25
|
+
}): ParsedBlueprint;
|
|
26
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/core/resume/blueprint/schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsD,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AACtG,OAAO,KAAK,EACX,iBAAiB,EACjB,iBAAiB,EAMjB,eAAe,EAEf,MAAM,YAAY,CAAC;AAOpB,mFAAmF;AACnF,eAAO,MAAM,eAAe;aAC3B,iBAAiB,EAAE,wDAAwD;aAC3E,KAAK,EAAE,mDAAmD;aAC1D,gBAAgB,EAAE,6FAA6F;aAC/G,cAAc,EAAE,2FAA2F;CAClG,CAAC;AAEX,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,GAAG,iBAAiB,CAIpF;AAED,gFAAgF;AAChF,wBAAgB,YAAY,IAAI,iBAAiB,CAEhD;AAED,8GAA8G;AAC9G,wBAAgB,cAAc,CAC7B,SAAS,EAAE,eAAe,EAC1B,QAAQ,GAAE,iBAAkC,GAC1C,iBAAiB,GAAG,SAAS,CAE/B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,GAAG,eAAe,CA6DjH"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
import { LineCounter, parseAllDocuments } from "yaml";
|
|
3
|
+
import { BLUEPRINT_FILE_NAME, CONFIG_DIR_NAME } from "../../../config.js";
|
|
4
|
+
import { BlueprintInvalidError } from "./errors.js";
|
|
5
|
+
const USES_REFERENCE = /^github\.com\/([^/@\s]+)\/([^/@\s]+)(?:\/([^@\s]+))?@(\S+)$/u;
|
|
6
|
+
/** The rule texts Devin words itself, which a blueprint error carries verbatim. */
|
|
7
|
+
export const BLUEPRINT_RULES = {
|
|
8
|
+
usesInMaintenance: "'uses' steps are not supported in maintenance sections",
|
|
9
|
+
shell: "shell: must be 'default', 'bash', or 'powershell'",
|
|
10
|
+
documentSequence: "each YAML document must be a mapping, not a sequence; use '---' to separate multiple blocks",
|
|
11
|
+
documentScalar: "each YAML document must be a mapping, not a scalar; use '---' to separate multiple blocks",
|
|
12
|
+
};
|
|
13
|
+
/** The blueprint `runs-on` platform that a Node.js `process.platform` value names. */
|
|
14
|
+
export function blueprintPlatformOf(nodePlatform) {
|
|
15
|
+
if (nodePlatform === "darwin")
|
|
16
|
+
return "macos";
|
|
17
|
+
if (nodePlatform === "win32")
|
|
18
|
+
return "windows";
|
|
19
|
+
return "linux";
|
|
20
|
+
}
|
|
21
|
+
/** The platform this process runs on, as blueprint `runs-on` labels name it. */
|
|
22
|
+
export function hostPlatform() {
|
|
23
|
+
return blueprintPlatformOf(process.platform);
|
|
24
|
+
}
|
|
25
|
+
/** The document of `blueprint` that targets `platform`, if any. Other documents are never run or surfaced. */
|
|
26
|
+
export function selectDocument(blueprint, platform = hostPlatform()) {
|
|
27
|
+
return blueprint.documents.find((document) => document.platforms.includes(platform));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Parses and validates a blueprint file, in Devin's schema. Throws {@link BlueprintInvalidError} for the first rule it
|
|
31
|
+
* breaks. Validation covers every document, whichever platform it targets, and ignores keys it does not know.
|
|
32
|
+
* `includes` is read in a repository's root blueprint only, ignored in the global one and rejected in a workspace
|
|
33
|
+
* blueprint; `post-build` is accepted in the global blueprint only; `clone` is accepted and reported as ignored.
|
|
34
|
+
*/
|
|
35
|
+
export function parseBlueprint(source, location) {
|
|
36
|
+
const invalid = (reason, rule, subject = null) => new BlueprintInvalidError({ blueprint: location.path, scope: location.scope, reason, rule, subject });
|
|
37
|
+
const warnings = [];
|
|
38
|
+
const documents = [];
|
|
39
|
+
const owners = new Map();
|
|
40
|
+
const lineCounter = new LineCounter();
|
|
41
|
+
for (const [index, parsed] of parseAllDocuments(source, { prettyErrors: false, lineCounter }).entries()) {
|
|
42
|
+
const failure = parsed.errors[0];
|
|
43
|
+
if (failure !== undefined) {
|
|
44
|
+
throw new BlueprintInvalidError({
|
|
45
|
+
blueprint: location.path,
|
|
46
|
+
scope: location.scope,
|
|
47
|
+
reason: "yaml-syntax",
|
|
48
|
+
rule: `YAML syntax error (${failure.code})`,
|
|
49
|
+
subject: `line ${lineCounter.linePos(failure.pos[0]).line}`,
|
|
50
|
+
}, failure);
|
|
51
|
+
}
|
|
52
|
+
let value;
|
|
53
|
+
try {
|
|
54
|
+
value = parsed.toJS();
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new BlueprintInvalidError({
|
|
58
|
+
blueprint: location.path,
|
|
59
|
+
scope: location.scope,
|
|
60
|
+
reason: "yaml-syntax",
|
|
61
|
+
rule: "YAML cannot be read: it has too many aliases",
|
|
62
|
+
subject: `document ${index + 1}`,
|
|
63
|
+
}, error);
|
|
64
|
+
}
|
|
65
|
+
if (value === null || value === undefined)
|
|
66
|
+
continue;
|
|
67
|
+
if (Array.isArray(value))
|
|
68
|
+
throw invalid("not-a-mapping", BLUEPRINT_RULES.documentSequence, `document ${index + 1}`);
|
|
69
|
+
if (typeof value !== "object")
|
|
70
|
+
throw invalid("not-a-mapping", BLUEPRINT_RULES.documentScalar, `document ${index + 1}`);
|
|
71
|
+
const document = readDocument(value, location.scope, invalid, (message) => warnings.push({ code: "clone-ignored", blueprint: location.path, message }));
|
|
72
|
+
for (const platform of document.platforms) {
|
|
73
|
+
if (owners.has(platform)) {
|
|
74
|
+
throw invalid("duplicate-platform", "two YAML documents cannot resolve to the same platform; this includes the 'default' and 'linux' aliases", platform);
|
|
75
|
+
}
|
|
76
|
+
owners.set(platform, index);
|
|
77
|
+
}
|
|
78
|
+
documents.push(document);
|
|
79
|
+
}
|
|
80
|
+
return { path: location.path, scope: location.scope, documents, warnings };
|
|
81
|
+
}
|
|
82
|
+
function readDocument(mapping, scope, invalid, warnClone) {
|
|
83
|
+
if (scope !== "global" && "post-build" in mapping) {
|
|
84
|
+
throw invalid("post-build-not-global", "'post-build' is only supported in the global blueprint", "post-build");
|
|
85
|
+
}
|
|
86
|
+
if (scope === "workspace" && "includes" in mapping) {
|
|
87
|
+
throw invalid("nested-includes", "'includes' is not allowed in an included workspace blueprint", "includes");
|
|
88
|
+
}
|
|
89
|
+
if ("clone" in mapping) {
|
|
90
|
+
warnClone("'clone' is ignored: a resume restores the recorded tree instead of cloning the repository");
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
platforms: readPlatforms(mapping["runs-on"], invalid),
|
|
94
|
+
shell: readShell(mapping.shell, invalid),
|
|
95
|
+
initialize: readSteps(mapping.initialize, "initialize", invalid),
|
|
96
|
+
maintenance: readMaintenance(mapping.maintenance, invalid),
|
|
97
|
+
knowledge: readKnowledge(mapping.knowledge, invalid),
|
|
98
|
+
postBuild: readSteps(mapping["post-build"], "post-build", invalid),
|
|
99
|
+
includes: scope === "repository" ? readIncludes(mapping.includes, invalid) : [],
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function isMapping(value) {
|
|
103
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
104
|
+
}
|
|
105
|
+
function isScalar(value) {
|
|
106
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
107
|
+
}
|
|
108
|
+
/** A YAML value as the string a process receives: scalars as written, `null` as empty, collections as JSON. */
|
|
109
|
+
function stringified(value) {
|
|
110
|
+
if (value === null || value === undefined)
|
|
111
|
+
return "";
|
|
112
|
+
if (typeof value === "string")
|
|
113
|
+
return value;
|
|
114
|
+
if (isScalar(value))
|
|
115
|
+
return String(value);
|
|
116
|
+
return JSON.stringify(value);
|
|
117
|
+
}
|
|
118
|
+
function readPlatforms(value, invalid) {
|
|
119
|
+
const labels = value === undefined || value === null ? [] : Array.isArray(value) ? value : [value];
|
|
120
|
+
if (labels.length === 0)
|
|
121
|
+
return ["linux"];
|
|
122
|
+
const platforms = new Set();
|
|
123
|
+
for (const label of labels) {
|
|
124
|
+
if (typeof label !== "string")
|
|
125
|
+
throw invalid("invalid-field", "'runs-on' must be a string or a list of strings", "runs-on");
|
|
126
|
+
const lowered = label.trim().toLowerCase();
|
|
127
|
+
platforms.add(lowered === "default" ? "linux" : lowered);
|
|
128
|
+
}
|
|
129
|
+
return [...platforms];
|
|
130
|
+
}
|
|
131
|
+
function readShell(value, invalid) {
|
|
132
|
+
if (value === undefined || value === null)
|
|
133
|
+
return "default";
|
|
134
|
+
const lowered = typeof value === "string" ? value.trim().toLowerCase() : undefined;
|
|
135
|
+
if (lowered === "default" || lowered === "bash")
|
|
136
|
+
return "default";
|
|
137
|
+
if (lowered === "powershell")
|
|
138
|
+
return "powershell";
|
|
139
|
+
throw invalid("invalid-shell", BLUEPRINT_RULES.shell, "shell");
|
|
140
|
+
}
|
|
141
|
+
function readStringMap(value, subject, invalid) {
|
|
142
|
+
if (value === undefined || value === null)
|
|
143
|
+
return {};
|
|
144
|
+
if (!isMapping(value))
|
|
145
|
+
throw invalid("invalid-field", `'${subject.split(".").pop()}' must be a mapping`, subject);
|
|
146
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, stringified(entry)]));
|
|
147
|
+
}
|
|
148
|
+
function readName(value, subject, invalid) {
|
|
149
|
+
if (value === undefined || value === null)
|
|
150
|
+
return undefined;
|
|
151
|
+
if (!isScalar(value))
|
|
152
|
+
throw invalid("invalid-field", "'name' must be a string", subject);
|
|
153
|
+
return String(value);
|
|
154
|
+
}
|
|
155
|
+
function readRunText(value, subject, invalid) {
|
|
156
|
+
if (!isScalar(value))
|
|
157
|
+
throw invalid("invalid-field", "'run' must be a string", subject);
|
|
158
|
+
return String(value);
|
|
159
|
+
}
|
|
160
|
+
function readStep(value, section, subject, invalid) {
|
|
161
|
+
if (typeof value === "string")
|
|
162
|
+
return { kind: "run", name: undefined, run: value, env: {} };
|
|
163
|
+
if (!isMapping(value))
|
|
164
|
+
throw invalid("invalid-field", "a step must be a string or a mapping", subject);
|
|
165
|
+
const hasUses = "uses" in value;
|
|
166
|
+
const hasRun = "run" in value;
|
|
167
|
+
if (hasUses && section === "maintenance") {
|
|
168
|
+
throw invalid("uses-in-maintenance", BLUEPRINT_RULES.usesInMaintenance, subject);
|
|
169
|
+
}
|
|
170
|
+
if (hasUses && hasRun)
|
|
171
|
+
throw invalid("run-and-uses", "a step must define 'run' or 'uses', but not both", subject);
|
|
172
|
+
if (!hasUses && !hasRun)
|
|
173
|
+
throw invalid("missing-run-or-uses", "a step must define 'run' or 'uses'", subject);
|
|
174
|
+
const name = readName(value.name, subject, invalid);
|
|
175
|
+
const env = readStringMap(value.env, `${subject}.env`, invalid);
|
|
176
|
+
if (hasRun) {
|
|
177
|
+
if ("with" in value)
|
|
178
|
+
throw invalid("with-without-uses", "'with' is only valid on 'uses' steps", subject);
|
|
179
|
+
return { kind: "run", name, run: readRunText(value.run, subject, invalid), env };
|
|
180
|
+
}
|
|
181
|
+
const uses = value.uses;
|
|
182
|
+
if (typeof uses !== "string" || !USES_REFERENCE.test(uses.trim())) {
|
|
183
|
+
throw invalid("invalid-uses-reference", "'uses' must be github.com/<owner>/<repo>[/<subpath>]@<ref>; the 'github.com/' prefix and the '@<ref>' suffix are required", subject);
|
|
184
|
+
}
|
|
185
|
+
return { kind: "uses", name, uses: uses.trim(), with: readStringMap(value.with, `${subject}.with`, invalid), env };
|
|
186
|
+
}
|
|
187
|
+
function readSteps(value, section, invalid) {
|
|
188
|
+
if (value === undefined || value === null)
|
|
189
|
+
return [];
|
|
190
|
+
if (typeof value === "string")
|
|
191
|
+
return [{ kind: "run", name: undefined, run: value, env: {} }];
|
|
192
|
+
const entries = Array.isArray(value) ? value : [value];
|
|
193
|
+
return entries.map((entry, index) => readStep(entry, section, Array.isArray(value) ? `${section}[${index}]` : section, invalid));
|
|
194
|
+
}
|
|
195
|
+
function readMaintenance(value, invalid) {
|
|
196
|
+
return readSteps(value, "maintenance", invalid).map((step) => step);
|
|
197
|
+
}
|
|
198
|
+
function readKnowledge(value, invalid) {
|
|
199
|
+
if (value === undefined || value === null)
|
|
200
|
+
return [];
|
|
201
|
+
if (!Array.isArray(value))
|
|
202
|
+
throw invalid("invalid-field", "'knowledge' must be a list of { name, contents } items", "knowledge");
|
|
203
|
+
return value.map((item, index) => {
|
|
204
|
+
if (!isMapping(item)) {
|
|
205
|
+
throw invalid("invalid-field", "a knowledge item must be { name, contents }", `knowledge[${index}]`);
|
|
206
|
+
}
|
|
207
|
+
return { name: stringified(item.name), contents: stringified(item.contents) };
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function readIncludes(value, invalid) {
|
|
211
|
+
if (value === undefined || value === null)
|
|
212
|
+
return [];
|
|
213
|
+
const entries = Array.isArray(value) ? value : [value];
|
|
214
|
+
const workspaces = [];
|
|
215
|
+
const seen = new Set();
|
|
216
|
+
for (const entry of entries) {
|
|
217
|
+
if (typeof entry !== "string")
|
|
218
|
+
throw invalid("invalid-field", "'includes' must be a string or a list of strings", "includes");
|
|
219
|
+
const normalized = entry
|
|
220
|
+
.replaceAll("\\", "/")
|
|
221
|
+
.split("/")
|
|
222
|
+
.filter((segment) => segment !== "" && segment !== ".");
|
|
223
|
+
if (normalized.includes(".."))
|
|
224
|
+
throw invalid("include-parent-path", "'includes' paths cannot contain '..'", entry);
|
|
225
|
+
const workspace = includedWorkspace(entry, normalized);
|
|
226
|
+
if (workspace.directory === "" || seen.has(workspace.directory)) {
|
|
227
|
+
throw invalid("duplicate-include", "each workspace path can appear only once in 'includes'", entry);
|
|
228
|
+
}
|
|
229
|
+
seen.add(workspace.directory);
|
|
230
|
+
workspaces.push(workspace);
|
|
231
|
+
}
|
|
232
|
+
return workspaces;
|
|
233
|
+
}
|
|
234
|
+
function includedWorkspace(entry, segments) {
|
|
235
|
+
const path = segments.join("/");
|
|
236
|
+
const isBlueprintFile = segments.at(-1) === BLUEPRINT_FILE_NAME && segments.at(-2) === CONFIG_DIR_NAME;
|
|
237
|
+
if (!isBlueprintFile) {
|
|
238
|
+
return { entry, directory: path, file: posix.join(path, CONFIG_DIR_NAME, BLUEPRINT_FILE_NAME) };
|
|
239
|
+
}
|
|
240
|
+
const workspace = posix.dirname(posix.dirname(path));
|
|
241
|
+
return { entry, directory: workspace === "." ? "" : workspace, file: path };
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/core/resume/blueprint/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,MAAM,CA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AAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,EAAE,mBAAmB,CAAC,EAAE,CAAC;IACjG,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["import { posix } from \"node:path\";\nimport { LineCounter, parseAllDocuments } from \"yaml\";\nimport { BLUEPRINT_FILE_NAME, CONFIG_DIR_NAME } from \"../../../config.js\";\nimport { BlueprintInvalidError, type BlueprintInvalidReason, type BlueprintScope } from \"./errors.ts\";\nimport type {\n\tBlueprintDocument,\n\tBlueprintPlatform,\n\tBlueprintShell,\n\tBlueprintStep,\n\tBlueprintWarning,\n\tIncludedWorkspace,\n\tKnowledgeItem,\n\tParsedBlueprint,\n\tRunStep,\n} from \"./types.ts\";\n\ntype YamlValue = unknown;\ntype YamlMapping = { readonly [key: string]: YamlValue };\n\nconst USES_REFERENCE = /^github\\.com\\/([^/@\\s]+)\\/([^/@\\s]+)(?:\\/([^@\\s]+))?@(\\S+)$/u;\n\n/** The rule texts Devin words itself, which a blueprint error carries verbatim. */\nexport const BLUEPRINT_RULES = {\n\tusesInMaintenance: \"'uses' steps are not supported in maintenance sections\",\n\tshell: \"shell: must be 'default', 'bash', or 'powershell'\",\n\tdocumentSequence: \"each YAML document must be a mapping, not a sequence; use '---' to separate multiple blocks\",\n\tdocumentScalar: \"each YAML document must be a mapping, not a scalar; use '---' to separate multiple blocks\",\n} as const;\n\n/** The blueprint `runs-on` platform that a Node.js `process.platform` value names. */\nexport function blueprintPlatformOf(nodePlatform: NodeJS.Platform): BlueprintPlatform {\n\tif (nodePlatform === \"darwin\") return \"macos\";\n\tif (nodePlatform === \"win32\") return \"windows\";\n\treturn \"linux\";\n}\n\n/** The platform this process runs on, as blueprint `runs-on` labels name it. */\nexport function hostPlatform(): BlueprintPlatform {\n\treturn blueprintPlatformOf(process.platform);\n}\n\n/** The document of `blueprint` that targets `platform`, if any. Other documents are never run or surfaced. */\nexport function selectDocument(\n\tblueprint: ParsedBlueprint,\n\tplatform: BlueprintPlatform = hostPlatform(),\n): BlueprintDocument | undefined {\n\treturn blueprint.documents.find((document) => document.platforms.includes(platform));\n}\n\n/**\n * Parses and validates a blueprint file, in Devin's schema. Throws {@link BlueprintInvalidError} for the first rule it\n * breaks. Validation covers every document, whichever platform it targets, and ignores keys it does not know.\n * `includes` is read in a repository's root blueprint only, ignored in the global one and rejected in a workspace\n * blueprint; `post-build` is accepted in the global blueprint only; `clone` is accepted and reported as ignored.\n */\nexport function parseBlueprint(source: string, location: { path: string; scope: BlueprintScope }): ParsedBlueprint {\n\tconst invalid = (\n\t\treason: BlueprintInvalidReason,\n\t\trule: string,\n\t\tsubject: string | null = null,\n\t): BlueprintInvalidError =>\n\t\tnew BlueprintInvalidError({ blueprint: location.path, scope: location.scope, reason, rule, subject });\n\tconst warnings: BlueprintWarning[] = [];\n\tconst documents: BlueprintDocument[] = [];\n\tconst owners = new Map<string, number>();\n\tconst lineCounter = new LineCounter();\n\tfor (const [index, parsed] of parseAllDocuments(source, { prettyErrors: false, lineCounter }).entries()) {\n\t\tconst failure = parsed.errors[0];\n\t\tif (failure !== undefined) {\n\t\t\tthrow new BlueprintInvalidError(\n\t\t\t\t{\n\t\t\t\t\tblueprint: location.path,\n\t\t\t\t\tscope: location.scope,\n\t\t\t\t\treason: \"yaml-syntax\",\n\t\t\t\t\trule: `YAML syntax error (${failure.code})`,\n\t\t\t\t\tsubject: `line ${lineCounter.linePos(failure.pos[0]).line}`,\n\t\t\t\t},\n\t\t\t\tfailure,\n\t\t\t);\n\t\t}\n\t\tlet value: YamlValue;\n\t\ttry {\n\t\t\tvalue = parsed.toJS();\n\t\t} catch (error) {\n\t\t\tthrow new BlueprintInvalidError(\n\t\t\t\t{\n\t\t\t\t\tblueprint: location.path,\n\t\t\t\t\tscope: location.scope,\n\t\t\t\t\treason: \"yaml-syntax\",\n\t\t\t\t\trule: \"YAML cannot be read: it has too many aliases\",\n\t\t\t\t\tsubject: `document ${index + 1}`,\n\t\t\t\t},\n\t\t\t\terror as Error,\n\t\t\t);\n\t\t}\n\t\tif (value === null || value === undefined) continue;\n\t\tif (Array.isArray(value))\n\t\t\tthrow invalid(\"not-a-mapping\", BLUEPRINT_RULES.documentSequence, `document ${index + 1}`);\n\t\tif (typeof value !== \"object\")\n\t\t\tthrow invalid(\"not-a-mapping\", BLUEPRINT_RULES.documentScalar, `document ${index + 1}`);\n\t\tconst document = readDocument(value as YamlMapping, location.scope, invalid, (message) =>\n\t\t\twarnings.push({ code: \"clone-ignored\", blueprint: location.path, message }),\n\t\t);\n\t\tfor (const platform of document.platforms) {\n\t\t\tif (owners.has(platform)) {\n\t\t\t\tthrow invalid(\n\t\t\t\t\t\"duplicate-platform\",\n\t\t\t\t\t\"two YAML documents cannot resolve to the same platform; this includes the 'default' and 'linux' aliases\",\n\t\t\t\t\tplatform,\n\t\t\t\t);\n\t\t\t}\n\t\t\towners.set(platform, index);\n\t\t}\n\t\tdocuments.push(document);\n\t}\n\treturn { path: location.path, scope: location.scope, documents, warnings };\n}\n\ntype Invalid = (reason: BlueprintInvalidReason, rule: string, subject?: string | null) => BlueprintInvalidError;\n\nfunction readDocument(\n\tmapping: YamlMapping,\n\tscope: BlueprintScope,\n\tinvalid: Invalid,\n\twarnClone: (message: string) => void,\n): BlueprintDocument {\n\tif (scope !== \"global\" && \"post-build\" in mapping) {\n\t\tthrow invalid(\"post-build-not-global\", \"'post-build' is only supported in the global blueprint\", \"post-build\");\n\t}\n\tif (scope === \"workspace\" && \"includes\" in mapping) {\n\t\tthrow invalid(\"nested-includes\", \"'includes' is not allowed in an included workspace blueprint\", \"includes\");\n\t}\n\tif (\"clone\" in mapping) {\n\t\twarnClone(\"'clone' is ignored: a resume restores the recorded tree instead of cloning the repository\");\n\t}\n\treturn {\n\t\tplatforms: readPlatforms(mapping[\"runs-on\"], invalid),\n\t\tshell: readShell(mapping.shell, invalid),\n\t\tinitialize: readSteps(mapping.initialize, \"initialize\", invalid),\n\t\tmaintenance: readMaintenance(mapping.maintenance, invalid),\n\t\tknowledge: readKnowledge(mapping.knowledge, invalid),\n\t\tpostBuild: readSteps(mapping[\"post-build\"], \"post-build\", invalid),\n\t\tincludes: scope === \"repository\" ? readIncludes(mapping.includes, invalid) : [],\n\t};\n}\n\nfunction isMapping(value: YamlValue): value is YamlMapping {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isScalar(value: YamlValue): value is string | number | boolean {\n\treturn typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n}\n\n/** A YAML value as the string a process receives: scalars as written, `null` as empty, collections as JSON. */\nfunction stringified(value: YamlValue): string {\n\tif (value === null || value === undefined) return \"\";\n\tif (typeof value === \"string\") return value;\n\tif (isScalar(value)) return String(value);\n\treturn JSON.stringify(value);\n}\n\nfunction readPlatforms(value: YamlValue, invalid: Invalid): string[] {\n\tconst labels = value === undefined || value === null ? [] : Array.isArray(value) ? value : [value];\n\tif (labels.length === 0) return [\"linux\"];\n\tconst platforms = new Set<string>();\n\tfor (const label of labels) {\n\t\tif (typeof label !== \"string\")\n\t\t\tthrow invalid(\"invalid-field\", \"'runs-on' must be a string or a list of strings\", \"runs-on\");\n\t\tconst lowered = label.trim().toLowerCase();\n\t\tplatforms.add(lowered === \"default\" ? \"linux\" : lowered);\n\t}\n\treturn [...platforms];\n}\n\nfunction readShell(value: YamlValue, invalid: Invalid): BlueprintShell {\n\tif (value === undefined || value === null) return \"default\";\n\tconst lowered = typeof value === \"string\" ? value.trim().toLowerCase() : undefined;\n\tif (lowered === \"default\" || lowered === \"bash\") return \"default\";\n\tif (lowered === \"powershell\") return \"powershell\";\n\tthrow invalid(\"invalid-shell\", BLUEPRINT_RULES.shell, \"shell\");\n}\n\nfunction readStringMap(value: YamlValue, subject: string, invalid: Invalid): Record<string, string> {\n\tif (value === undefined || value === null) return {};\n\tif (!isMapping(value)) throw invalid(\"invalid-field\", `'${subject.split(\".\").pop()}' must be a mapping`, subject);\n\treturn Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, stringified(entry)]));\n}\n\nfunction readName(value: YamlValue, subject: string, invalid: Invalid): string | undefined {\n\tif (value === undefined || value === null) return undefined;\n\tif (!isScalar(value)) throw invalid(\"invalid-field\", \"'name' must be a string\", subject);\n\treturn String(value);\n}\n\nfunction readRunText(value: YamlValue, subject: string, invalid: Invalid): string {\n\tif (!isScalar(value)) throw invalid(\"invalid-field\", \"'run' must be a string\", subject);\n\treturn String(value);\n}\n\nfunction readStep(value: YamlValue, section: string, subject: string, invalid: Invalid): BlueprintStep {\n\tif (typeof value === \"string\") return { kind: \"run\", name: undefined, run: value, env: {} };\n\tif (!isMapping(value)) throw invalid(\"invalid-field\", \"a step must be a string or a mapping\", subject);\n\tconst hasUses = \"uses\" in value;\n\tconst hasRun = \"run\" in value;\n\tif (hasUses && section === \"maintenance\") {\n\t\tthrow invalid(\"uses-in-maintenance\", BLUEPRINT_RULES.usesInMaintenance, subject);\n\t}\n\tif (hasUses && hasRun) throw invalid(\"run-and-uses\", \"a step must define 'run' or 'uses', but not both\", subject);\n\tif (!hasUses && !hasRun) throw invalid(\"missing-run-or-uses\", \"a step must define 'run' or 'uses'\", subject);\n\tconst name = readName(value.name, subject, invalid);\n\tconst env = readStringMap(value.env, `${subject}.env`, invalid);\n\tif (hasRun) {\n\t\tif (\"with\" in value) throw invalid(\"with-without-uses\", \"'with' is only valid on 'uses' steps\", subject);\n\t\treturn { kind: \"run\", name, run: readRunText(value.run, subject, invalid), env };\n\t}\n\tconst uses = value.uses;\n\tif (typeof uses !== \"string\" || !USES_REFERENCE.test(uses.trim())) {\n\t\tthrow invalid(\n\t\t\t\"invalid-uses-reference\",\n\t\t\t\"'uses' must be github.com/<owner>/<repo>[/<subpath>]@<ref>; the 'github.com/' prefix and the '@<ref>' suffix are required\",\n\t\t\tsubject,\n\t\t);\n\t}\n\treturn { kind: \"uses\", name, uses: uses.trim(), with: readStringMap(value.with, `${subject}.with`, invalid), env };\n}\n\nfunction readSteps(value: YamlValue, section: string, invalid: Invalid): BlueprintStep[] {\n\tif (value === undefined || value === null) return [];\n\tif (typeof value === \"string\") return [{ kind: \"run\", name: undefined, run: value, env: {} }];\n\tconst entries = Array.isArray(value) ? value : [value];\n\treturn entries.map((entry, index) =>\n\t\treadStep(entry, section, Array.isArray(value) ? `${section}[${index}]` : section, invalid),\n\t);\n}\n\nfunction readMaintenance(value: YamlValue, invalid: Invalid): RunStep[] {\n\treturn readSteps(value, \"maintenance\", invalid).map((step) => step as RunStep);\n}\n\nfunction readKnowledge(value: YamlValue, invalid: Invalid): KnowledgeItem[] {\n\tif (value === undefined || value === null) return [];\n\tif (!Array.isArray(value))\n\t\tthrow invalid(\"invalid-field\", \"'knowledge' must be a list of { name, contents } items\", \"knowledge\");\n\treturn value.map((item, index) => {\n\t\tif (!isMapping(item)) {\n\t\t\tthrow invalid(\"invalid-field\", \"a knowledge item must be { name, contents }\", `knowledge[${index}]`);\n\t\t}\n\t\treturn { name: stringified(item.name), contents: stringified(item.contents) };\n\t});\n}\n\nfunction readIncludes(value: YamlValue, invalid: Invalid): IncludedWorkspace[] {\n\tif (value === undefined || value === null) return [];\n\tconst entries = Array.isArray(value) ? value : [value];\n\tconst workspaces: IncludedWorkspace[] = [];\n\tconst seen = new Set<string>();\n\tfor (const entry of entries) {\n\t\tif (typeof entry !== \"string\")\n\t\t\tthrow invalid(\"invalid-field\", \"'includes' must be a string or a list of strings\", \"includes\");\n\t\tconst normalized = entry\n\t\t\t.replaceAll(\"\\\\\", \"/\")\n\t\t\t.split(\"/\")\n\t\t\t.filter((segment) => segment !== \"\" && segment !== \".\");\n\t\tif (normalized.includes(\"..\"))\n\t\t\tthrow invalid(\"include-parent-path\", \"'includes' paths cannot contain '..'\", entry);\n\t\tconst workspace = includedWorkspace(entry, normalized);\n\t\tif (workspace.directory === \"\" || seen.has(workspace.directory)) {\n\t\t\tthrow invalid(\"duplicate-include\", \"each workspace path can appear only once in 'includes'\", entry);\n\t\t}\n\t\tseen.add(workspace.directory);\n\t\tworkspaces.push(workspace);\n\t}\n\treturn workspaces;\n}\n\nfunction includedWorkspace(entry: string, segments: readonly string[]): IncludedWorkspace {\n\tconst path = segments.join(\"/\");\n\tconst isBlueprintFile = segments.at(-1) === BLUEPRINT_FILE_NAME && segments.at(-2) === CONFIG_DIR_NAME;\n\tif (!isBlueprintFile) {\n\t\treturn { entry, directory: path, file: posix.join(path, CONFIG_DIR_NAME, BLUEPRINT_FILE_NAME) };\n\t}\n\tconst workspace = posix.dirname(posix.dirname(path));\n\treturn { entry, directory: workspace === \".\" ? \"\" : workspace, file: path };\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ShellConfig } from "../../../utils/shell.ts";
|
|
2
|
+
import { type ActionFetcher } from "./actions.ts";
|
|
3
|
+
import { BlueprintError, type BlueprintScope, type BlueprintSection } from "./errors.ts";
|
|
4
|
+
import { type LoggedProcess } from "./process.ts";
|
|
5
|
+
import type { BlueprintPlatform, BlueprintShell, BlueprintStep, RunStep } from "./types.ts";
|
|
6
|
+
/** How long one step may run before it is stopped: 3 hours, as in Devin. */
|
|
7
|
+
export declare const BLUEPRINT_STEP_TIMEOUT_MS: number;
|
|
8
|
+
/** What a run of steps needs besides the steps themselves. */
|
|
9
|
+
export interface StepContext {
|
|
10
|
+
readonly blueprint: string;
|
|
11
|
+
readonly scope: BlueprintScope;
|
|
12
|
+
/** Home directory for the global blueprint; the repository root or workspace directory otherwise. */
|
|
13
|
+
readonly cwd: string;
|
|
14
|
+
readonly shell: BlueprintShell;
|
|
15
|
+
readonly platform: BlueprintPlatform;
|
|
16
|
+
/** The build's `$ENVRC` file. */
|
|
17
|
+
readonly envrcPath: string;
|
|
18
|
+
readonly logDirectory: string;
|
|
19
|
+
/** Makes this layer's log file names unique within the host's logs. */
|
|
20
|
+
readonly logPrefix: string;
|
|
21
|
+
readonly timeoutMs: number;
|
|
22
|
+
readonly environment: NodeJS.ProcessEnv;
|
|
23
|
+
readonly actionsCacheDir: string;
|
|
24
|
+
readonly fetchAction?: ActionFetcher;
|
|
25
|
+
readonly signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
/** The first step of a section that did not succeed. */
|
|
28
|
+
export interface StepFailure {
|
|
29
|
+
readonly error: BlueprintError;
|
|
30
|
+
/** Null when the step's log could not be created. */
|
|
31
|
+
readonly logPath: string | null;
|
|
32
|
+
/** The end of the step's output. */
|
|
33
|
+
readonly outputTail: string;
|
|
34
|
+
}
|
|
35
|
+
export interface SectionResult {
|
|
36
|
+
/** How many steps ran to completion. */
|
|
37
|
+
readonly completed: number;
|
|
38
|
+
/** Set when a step failed; the steps after it did not run. */
|
|
39
|
+
readonly failure?: StepFailure;
|
|
40
|
+
}
|
|
41
|
+
/** Whether a `run` step goes to PowerShell: only on Windows, and only when its blueprint asks for it. */
|
|
42
|
+
export declare function runsInPowerShell(shell: BlueprintShell, platform: BlueprintPlatform): boolean;
|
|
43
|
+
/** The PowerShell process of a `run` step. `evaluated` is the environment the build's `$ENVRC` gives the build's own. */
|
|
44
|
+
export declare function powerShellProcess(step: RunStep, context: StepContext, powerShell: ShellConfig, evaluated: NodeJS.ProcessEnv): LoggedProcess;
|
|
45
|
+
/** The bash process of a `run` step: its script is the last argument, or on stdin for a bash that cannot take it there. */
|
|
46
|
+
export declare function bashProcess(step: RunStep, context: StepContext, bash: ShellConfig): LoggedProcess;
|
|
47
|
+
/**
|
|
48
|
+
* Runs the steps of one section in order, each with its own log file, and stops at the first that fails: the steps
|
|
49
|
+
* after it do not run. A step fails when it exits non-zero, is stopped by a signal, cannot be started, times out, or
|
|
50
|
+
* is a `uses` step that cannot run. Nothing a step does throws, apart from `context.signal` aborting, which rejects
|
|
51
|
+
* with its reason: cancelling is not a failure.
|
|
52
|
+
*/
|
|
53
|
+
export declare function runSection(section: BlueprintSection, steps: readonly BlueprintStep[], context: StepContext): Promise<SectionResult>;
|
|
54
|
+
//# sourceMappingURL=steps.d.ts.map
|