@jawcode-dev/coding-agent 1.1.0
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 +376 -0
- package/README.md +37 -0
- package/dist/types/async/index.d.ts +2 -0
- package/dist/types/async/job-manager.d.ts +294 -0
- package/dist/types/async/support.d.ts +2 -0
- package/dist/types/autoresearch/dashboard.d.ts +4 -0
- package/dist/types/autoresearch/git.d.ts +36 -0
- package/dist/types/autoresearch/helpers.d.ts +24 -0
- package/dist/types/autoresearch/index.d.ts +2 -0
- package/dist/types/autoresearch/state.d.ts +17 -0
- package/dist/types/autoresearch/storage.d.ts +142 -0
- package/dist/types/autoresearch/tools/init-experiment.d.ts +31 -0
- package/dist/types/autoresearch/tools/log-experiment.d.ts +23 -0
- package/dist/types/autoresearch/tools/run-experiment.d.ts +8 -0
- package/dist/types/autoresearch/tools/update-notes.d.ts +12 -0
- package/dist/types/autoresearch/types.d.ts +154 -0
- package/dist/types/capability/context-file.d.ts +17 -0
- package/dist/types/capability/extension-module.d.ts +15 -0
- package/dist/types/capability/extension.d.ts +28 -0
- package/dist/types/capability/fs.d.ts +20 -0
- package/dist/types/capability/hook.d.ts +19 -0
- package/dist/types/capability/index.d.ts +80 -0
- package/dist/types/capability/instruction.d.ts +17 -0
- package/dist/types/capability/mcp.d.ts +45 -0
- package/dist/types/capability/prompt.d.ts +15 -0
- package/dist/types/capability/rule.d.ts +61 -0
- package/dist/types/capability/settings.d.ts +15 -0
- package/dist/types/capability/skill.d.ts +36 -0
- package/dist/types/capability/slash-command.d.ts +17 -0
- package/dist/types/capability/ssh.d.ts +23 -0
- package/dist/types/capability/system-prompt.d.ts +15 -0
- package/dist/types/capability/tool.d.ts +19 -0
- package/dist/types/capability/types.d.ts +154 -0
- package/dist/types/cli/agents-cli.d.ts +12 -0
- package/dist/types/cli/args.d.ts +56 -0
- package/dist/types/cli/auth-broker-cli.d.ts +25 -0
- package/dist/types/cli/auth-gateway-cli.d.ts +18 -0
- package/dist/types/cli/classify-install-target.d.ts +18 -0
- package/dist/types/cli/commands/init-xdg.d.ts +1 -0
- package/dist/types/cli/config-cli.d.ts +22 -0
- package/dist/types/cli/fast-help.d.ts +1 -0
- package/dist/types/cli/file-processor.d.ts +11 -0
- package/dist/types/cli/grep-cli.d.ts +17 -0
- package/dist/types/cli/initial-message.d.ts +17 -0
- package/dist/types/cli/list-models.d.ts +30 -0
- package/dist/types/cli/notify-cli.d.ts +29 -0
- package/dist/types/cli/plugin-cli.d.ts +32 -0
- package/dist/types/cli/read-cli.d.ts +4 -0
- package/dist/types/cli/session-picker.d.ts +3 -0
- package/dist/types/cli/setup-cli.d.ts +45 -0
- package/dist/types/cli/shell-cli.d.ts +8 -0
- package/dist/types/cli/skills-cli.d.ts +9 -0
- package/dist/types/cli/ssh-cli.d.ts +21 -0
- package/dist/types/cli/stats-cli.d.ts +17 -0
- package/dist/types/cli/update-cli.d.ts +41 -0
- package/dist/types/cli/web-search-cli.d.ts +20 -0
- package/dist/types/cli/worktree-cli.d.ts +26 -0
- package/dist/types/cli.d.ts +4 -0
- package/dist/types/commands/acp.d.ts +12 -0
- package/dist/types/commands/agents.d.ts +34 -0
- package/dist/types/commands/auth-broker.d.ts +54 -0
- package/dist/types/commands/auth-gateway.d.ts +32 -0
- package/dist/types/commands/chat.d.ts +18 -0
- package/dist/types/commands/codex-native-hook.d.ts +6 -0
- package/dist/types/commands/commit.d.ts +27 -0
- package/dist/types/commands/config.d.ts +30 -0
- package/dist/types/commands/contribution-prep.d.ts +18 -0
- package/dist/types/commands/coordinator.d.ts +19 -0
- package/dist/types/commands/goal.d.ts +31 -0
- package/dist/types/commands/grep.d.ts +42 -0
- package/dist/types/commands/harness.d.ts +50 -0
- package/dist/types/commands/interview.d.ts +51 -0
- package/dist/types/commands/launch.d.ts +127 -0
- package/dist/types/commands/mcp-serve.d.ts +24 -0
- package/dist/types/commands/memory.d.ts +19 -0
- package/dist/types/commands/notify.d.ts +30 -0
- package/dist/types/commands/orchestrate.d.ts +48 -0
- package/dist/types/commands/planphase.d.ts +7 -0
- package/dist/types/commands/plugin.d.ts +52 -0
- package/dist/types/commands/ralplan.d.ts +7 -0
- package/dist/types/commands/read.d.ts +15 -0
- package/dist/types/commands/session.d.ts +24 -0
- package/dist/types/commands/setup.d.ts +95 -0
- package/dist/types/commands/shell.d.ts +21 -0
- package/dist/types/commands/skills.d.ts +26 -0
- package/dist/types/commands/ssh.d.ts +48 -0
- package/dist/types/commands/state.d.ts +7 -0
- package/dist/types/commands/stats.d.ts +25 -0
- package/dist/types/commands/team.d.ts +24 -0
- package/dist/types/commands/ultragoal.d.ts +8 -0
- package/dist/types/commands/update.d.ts +20 -0
- package/dist/types/commands/web-search.d.ts +33 -0
- package/dist/types/commands/worktree.d.ts +31 -0
- package/dist/types/commit/agentic/agent.d.ts +31 -0
- package/dist/types/commit/agentic/fallback.d.ts +5 -0
- package/dist/types/commit/agentic/index.d.ts +2 -0
- package/dist/types/commit/agentic/state.d.ts +58 -0
- package/dist/types/commit/agentic/tools/analyze-file.d.ts +19 -0
- package/dist/types/commit/agentic/tools/git-file-diff.d.ts +10 -0
- package/dist/types/commit/agentic/tools/git-hunk.d.ts +9 -0
- package/dist/types/commit/agentic/tools/git-overview.d.ts +9 -0
- package/dist/types/commit/agentic/tools/index.d.ts +16 -0
- package/dist/types/commit/agentic/tools/propose-changelog.d.ts +28 -0
- package/dist/types/commit/agentic/tools/propose-commit.d.ts +36 -0
- package/dist/types/commit/agentic/tools/recent-commits.d.ts +7 -0
- package/dist/types/commit/agentic/tools/schemas.d.ts +27 -0
- package/dist/types/commit/agentic/tools/split-commit.d.ts +53 -0
- package/dist/types/commit/agentic/topo-sort.d.ts +4 -0
- package/dist/types/commit/agentic/trivial.d.ts +7 -0
- package/dist/types/commit/agentic/validation.d.ts +20 -0
- package/dist/types/commit/analysis/conventional.d.ts +22 -0
- package/dist/types/commit/analysis/index.d.ts +4 -0
- package/dist/types/commit/analysis/scope.d.ts +6 -0
- package/dist/types/commit/analysis/summary.d.ts +19 -0
- package/dist/types/commit/analysis/validation.d.ts +8 -0
- package/dist/types/commit/changelog/detect.d.ts +2 -0
- package/dist/types/commit/changelog/generate.d.ts +30 -0
- package/dist/types/commit/changelog/index.d.ts +30 -0
- package/dist/types/commit/changelog/parse.d.ts +2 -0
- package/dist/types/commit/cli.d.ts +3 -0
- package/dist/types/commit/git/diff.d.ts +5 -0
- package/dist/types/commit/index.d.ts +4 -0
- package/dist/types/commit/map-reduce/index.d.ts +28 -0
- package/dist/types/commit/map-reduce/map-phase.d.ts +17 -0
- package/dist/types/commit/map-reduce/reduce-phase.d.ts +13 -0
- package/dist/types/commit/map-reduce/utils.d.ts +2 -0
- package/dist/types/commit/message.d.ts +2 -0
- package/dist/types/commit/model-selection.d.ts +15 -0
- package/dist/types/commit/pipeline.d.ts +5 -0
- package/dist/types/commit/shared-llm.d.ts +54 -0
- package/dist/types/commit/types.d.ts +78 -0
- package/dist/types/commit/utils/exclusions.d.ts +4 -0
- package/dist/types/commit/utils.d.ts +20 -0
- package/dist/types/config/config-file.d.ts +58 -0
- package/dist/types/config/file-lock.d.ts +6 -0
- package/dist/types/config/keybindings.d.ts +359 -0
- package/dist/types/config/model-equivalence.d.ts +24 -0
- package/dist/types/config/model-profile-activation.d.ts +36 -0
- package/dist/types/config/model-profiles.d.ts +19 -0
- package/dist/types/config/model-registry.d.ts +445 -0
- package/dist/types/config/model-resolver.d.ts +217 -0
- package/dist/types/config/models-config-schema.d.ts +652 -0
- package/dist/types/config/oauth-provider-aliases.d.ts +1 -0
- package/dist/types/config/prompt-templates.d.ts +32 -0
- package/dist/types/config/resolve-config-value.d.ts +17 -0
- package/dist/types/config/settings-schema.d.ts +3683 -0
- package/dist/types/config/settings.d.ts +134 -0
- package/dist/types/config/skill-settings-defaults.d.ts +21 -0
- package/dist/types/config.d.ts +66 -0
- package/dist/types/coordinator/contract.d.ts +4 -0
- package/dist/types/coordinator-mcp/policy.d.ts +24 -0
- package/dist/types/coordinator-mcp/safety.d.ts +26 -0
- package/dist/types/coordinator-mcp/server.d.ts +52 -0
- package/dist/types/cursor.d.ts +24 -0
- package/dist/types/dap/client.d.ts +38 -0
- package/dist/types/dap/config.d.ts +6 -0
- package/dist/types/dap/index.d.ts +4 -0
- package/dist/types/dap/session.d.ts +108 -0
- package/dist/types/dap/types.d.ts +524 -0
- package/dist/types/debug/crash-diagnostics.d.ts +45 -0
- package/dist/types/debug/index.d.ts +15 -0
- package/dist/types/debug/log-formatting.d.ts +4 -0
- package/dist/types/debug/log-viewer.d.ts +68 -0
- package/dist/types/debug/profiler.d.ts +24 -0
- package/dist/types/debug/raw-sse-buffer.d.ts +44 -0
- package/dist/types/debug/raw-sse.d.ts +16 -0
- package/dist/types/debug/report-bundle.d.ts +55 -0
- package/dist/types/debug/runtime-gauges.d.ts +6 -0
- package/dist/types/debug/system-info.d.ts +26 -0
- package/dist/types/defaults/jwc-defaults.d.ts +69 -0
- package/dist/types/discovery/agents-md.d.ts +1 -0
- package/dist/types/discovery/agents.d.ts +12 -0
- package/dist/types/discovery/builtin.d.ts +1 -0
- package/dist/types/discovery/claude-plugins.d.ts +1 -0
- package/dist/types/discovery/claude.d.ts +1 -0
- package/dist/types/discovery/cli-jaw.d.ts +1 -0
- package/dist/types/discovery/cline.d.ts +1 -0
- package/dist/types/discovery/codex.d.ts +1 -0
- package/dist/types/discovery/cursor.d.ts +16 -0
- package/dist/types/discovery/gemini.d.ts +1 -0
- package/dist/types/discovery/github.d.ts +1 -0
- package/dist/types/discovery/helpers.d.ts +278 -0
- package/dist/types/discovery/index.d.ts +49 -0
- package/dist/types/discovery/mcp-json.d.ts +1 -0
- package/dist/types/discovery/opencode.d.ts +1 -0
- package/dist/types/discovery/plugin-dir-roots.d.ts +15 -0
- package/dist/types/discovery/ssh.d.ts +1 -0
- package/dist/types/discovery/substitute-plugin-root.d.ts +5 -0
- package/dist/types/discovery/vscode.d.ts +1 -0
- package/dist/types/discovery/windsurf.d.ts +13 -0
- package/dist/types/edit/apply-patch/index.d.ts +35 -0
- package/dist/types/edit/apply-patch/parser.d.ts +34 -0
- package/dist/types/edit/diff.d.ts +75 -0
- package/dist/types/edit/file-read-cache.d.ts +25 -0
- package/dist/types/edit/index.d.ts +58 -0
- package/dist/types/edit/modes/apply-patch.d.ts +24 -0
- package/dist/types/edit/modes/patch.d.ts +99 -0
- package/dist/types/edit/modes/replace.d.ts +149 -0
- package/dist/types/edit/normalize.d.ts +43 -0
- package/dist/types/edit/notebook.d.ts +23 -0
- package/dist/types/edit/read-file.d.ts +2 -0
- package/dist/types/edit/renderer.d.ts +110 -0
- package/dist/types/edit/streaming.d.ts +66 -0
- package/dist/types/eval/backend.d.ts +40 -0
- package/dist/types/eval/index.d.ts +4 -0
- package/dist/types/eval/js/context-manager.d.ts +24 -0
- package/dist/types/eval/js/executor.d.ts +28 -0
- package/dist/types/eval/js/index.d.ts +10 -0
- package/dist/types/eval/js/shared/helpers.d.ts +38 -0
- package/dist/types/eval/js/shared/indirect-eval.d.ts +14 -0
- package/dist/types/eval/js/shared/prelude.d.ts +1 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +6 -0
- package/dist/types/eval/js/shared/runtime.d.ts +47 -0
- package/dist/types/eval/js/shared/types.d.ts +24 -0
- package/dist/types/eval/js/tool-bridge.d.ts +18 -0
- package/dist/types/eval/js/worker-core.d.ts +5 -0
- package/dist/types/eval/js/worker-entry.d.ts +1 -0
- package/dist/types/eval/js/worker-protocol.d.ts +77 -0
- package/dist/types/eval/py/display.d.ts +25 -0
- package/dist/types/eval/py/executor.d.ts +85 -0
- package/dist/types/eval/py/index.d.ts +10 -0
- package/dist/types/eval/py/kernel.d.ts +63 -0
- package/dist/types/eval/py/prelude.d.ts +1 -0
- package/dist/types/eval/py/runtime.d.ts +21 -0
- package/dist/types/eval/py/tool-bridge.d.ts +20 -0
- package/dist/types/eval/types.d.ts +52 -0
- package/dist/types/exa/factory.d.ts +13 -0
- package/dist/types/exa/index.d.ts +20 -0
- package/dist/types/exa/mcp-client.d.ts +45 -0
- package/dist/types/exa/render.d.ts +19 -0
- package/dist/types/exa/researcher.d.ts +9 -0
- package/dist/types/exa/search.d.ts +9 -0
- package/dist/types/exa/types.d.ts +155 -0
- package/dist/types/exa/websets.d.ts +9 -0
- package/dist/types/exec/bash-executor.d.ts +58 -0
- package/dist/types/exec/exec.d.ts +25 -0
- package/dist/types/exec/idle-timeout-watchdog.d.ts +18 -0
- package/dist/types/exec/non-interactive-env.d.ts +4 -0
- package/dist/types/export/custom-share.d.ts +20 -0
- package/dist/types/export/html/index.d.ts +10 -0
- package/dist/types/export/html/template.generated.d.ts +1 -0
- package/dist/types/export/html/template.macro.d.ts +5 -0
- package/dist/types/export/ttsr.d.ts +44 -0
- package/dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts +9 -0
- package/dist/types/extensibility/custom-commands/bundled/review/index.d.ts +10 -0
- package/dist/types/extensibility/custom-commands/index.d.ts +2 -0
- package/dist/types/extensibility/custom-commands/loader.d.ts +29 -0
- package/dist/types/extensibility/custom-commands/types.d.ts +106 -0
- package/dist/types/extensibility/custom-tools/index.d.ts +6 -0
- package/dist/types/extensibility/custom-tools/loader.d.ts +69 -0
- package/dist/types/extensibility/custom-tools/types.d.ts +227 -0
- package/dist/types/extensibility/custom-tools/wrapper.d.ts +23 -0
- package/dist/types/extensibility/extensions/compact-handler.d.ts +26 -0
- package/dist/types/extensibility/extensions/get-commands-handler.d.ts +29 -0
- package/dist/types/extensibility/extensions/index.d.ts +8 -0
- package/dist/types/extensibility/extensions/loader.d.ts +43 -0
- package/dist/types/extensibility/extensions/runner.d.ts +134 -0
- package/dist/types/extensibility/extensions/types.d.ts +916 -0
- package/dist/types/extensibility/extensions/wrapper.d.ts +54 -0
- package/dist/types/extensibility/hooks/index.d.ts +5 -0
- package/dist/types/extensibility/hooks/loader.d.ts +89 -0
- package/dist/types/extensibility/hooks/runner.d.ts +126 -0
- package/dist/types/extensibility/hooks/tool-wrapper.d.ts +25 -0
- package/dist/types/extensibility/hooks/types.d.ts +431 -0
- package/dist/types/extensibility/jwc-plugins/activation.d.ts +14 -0
- package/dist/types/extensibility/jwc-plugins/index.d.ts +9 -0
- package/dist/types/extensibility/jwc-plugins/injection.d.ts +31 -0
- package/dist/types/extensibility/jwc-plugins/loader.d.ts +3 -0
- package/dist/types/extensibility/jwc-plugins/paths.d.ts +8 -0
- package/dist/types/extensibility/jwc-plugins/schema.d.ts +3 -0
- package/dist/types/extensibility/jwc-plugins/state.d.ts +9 -0
- package/dist/types/extensibility/jwc-plugins/tools.d.ts +8 -0
- package/dist/types/extensibility/jwc-plugins/types.d.ts +64 -0
- package/dist/types/extensibility/jwc-plugins/validation.d.ts +4 -0
- package/dist/types/extensibility/plugins/doctor.d.ts +3 -0
- package/dist/types/extensibility/plugins/git-url.d.ts +34 -0
- package/dist/types/extensibility/plugins/index.d.ts +7 -0
- package/dist/types/extensibility/plugins/installer.d.ts +5 -0
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -0
- package/dist/types/extensibility/plugins/loader.d.ts +31 -0
- package/dist/types/extensibility/plugins/manager.d.ts +65 -0
- package/dist/types/extensibility/plugins/marketplace/cache.d.ts +41 -0
- package/dist/types/extensibility/plugins/marketplace/fetcher.d.ts +48 -0
- package/dist/types/extensibility/plugins/marketplace/index.d.ts +6 -0
- package/dist/types/extensibility/plugins/marketplace/manager.d.ts +57 -0
- package/dist/types/extensibility/plugins/marketplace/registry.d.ts +34 -0
- package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +28 -0
- package/dist/types/extensibility/plugins/marketplace/types.d.ts +130 -0
- package/dist/types/extensibility/plugins/parser.d.ts +52 -0
- package/dist/types/extensibility/plugins/types.d.ts +149 -0
- package/dist/types/extensibility/shared-events.d.ts +280 -0
- package/dist/types/extensibility/skills.d.ts +82 -0
- package/dist/types/extensibility/slash-commands.d.ts +49 -0
- package/dist/types/extensibility/tool-proxy.d.ts +4 -0
- package/dist/types/extensibility/typebox.d.ts +155 -0
- package/dist/types/extensibility/utils.d.ts +12 -0
- package/dist/types/goals/goal-planning-start.d.ts +7 -0
- package/dist/types/goals/index.d.ts +3 -0
- package/dist/types/goals/runtime.d.ts +62 -0
- package/dist/types/goals/state.d.ts +40 -0
- package/dist/types/goals/tools/goal-tool.d.ts +62 -0
- package/dist/types/harness-control-plane/classifier.d.ts +13 -0
- package/dist/types/harness-control-plane/control-endpoint.d.ts +31 -0
- package/dist/types/harness-control-plane/finalize.d.ts +55 -0
- package/dist/types/harness-control-plane/operate.d.ts +35 -0
- package/dist/types/harness-control-plane/owner.d.ts +46 -0
- package/dist/types/harness-control-plane/phase-rollup.d.ts +23 -0
- package/dist/types/harness-control-plane/preserve.d.ts +19 -0
- package/dist/types/harness-control-plane/receipt-ingest.d.ts +19 -0
- package/dist/types/harness-control-plane/receipt-spool.d.ts +26 -0
- package/dist/types/harness-control-plane/receipts.d.ts +132 -0
- package/dist/types/harness-control-plane/rpc-adapter.d.ts +66 -0
- package/dist/types/harness-control-plane/seams.d.ts +21 -0
- package/dist/types/harness-control-plane/session-lease.d.ts +65 -0
- package/dist/types/harness-control-plane/state-machine.d.ts +24 -0
- package/dist/types/harness-control-plane/storage.d.ts +60 -0
- package/dist/types/harness-control-plane/types.d.ts +179 -0
- package/dist/types/hashline/anchors.d.ts +20 -0
- package/dist/types/hashline/apply.d.ts +14 -0
- package/dist/types/hashline/constants.d.ts +19 -0
- package/dist/types/hashline/diff-preview.d.ts +2 -0
- package/dist/types/hashline/diff.d.ts +17 -0
- package/dist/types/hashline/execute.d.ts +4 -0
- package/dist/types/hashline/hash.d.ts +123 -0
- package/dist/types/hashline/index.d.ts +13 -0
- package/dist/types/hashline/input.d.ts +11 -0
- package/dist/types/hashline/parser.d.ts +7 -0
- package/dist/types/hashline/prefixes.d.ts +7 -0
- package/dist/types/hashline/recovery.d.ts +27 -0
- package/dist/types/hashline/stream.d.ts +2 -0
- package/dist/types/hashline/types.d.ts +77 -0
- package/dist/types/hindsight/backend.d.ts +13 -0
- package/dist/types/hindsight/bank.d.ts +54 -0
- package/dist/types/hindsight/client.d.ts +224 -0
- package/dist/types/hindsight/config.d.ts +51 -0
- package/dist/types/hindsight/content.d.ts +71 -0
- package/dist/types/hindsight/index.d.ts +8 -0
- package/dist/types/hindsight/mental-models.d.ts +125 -0
- package/dist/types/hindsight/state.d.ts +99 -0
- package/dist/types/hindsight/transcript.d.ts +28 -0
- package/dist/types/hooks/codex-native-hooks-config.d.ts +29 -0
- package/dist/types/hooks/native-skill-hook.d.ts +16 -0
- package/dist/types/hooks/skill-keywords.d.ts +18 -0
- package/dist/types/hooks/skill-state.d.ts +88 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/internal-urls/agent-protocol.d.ts +12 -0
- package/dist/types/internal-urls/artifact-protocol.d.ts +6 -0
- package/dist/types/internal-urls/docs-index.generated.d.ts +2 -0
- package/dist/types/internal-urls/index.d.ts +20 -0
- package/dist/types/internal-urls/issue-pr-protocol.d.ts +17 -0
- package/dist/types/internal-urls/json-query.d.ts +30 -0
- package/dist/types/internal-urls/jwc-protocol.d.ts +19 -0
- package/dist/types/internal-urls/local-protocol.d.ts +39 -0
- package/dist/types/internal-urls/mcp-protocol.d.ts +12 -0
- package/dist/types/internal-urls/memory-protocol.d.ts +23 -0
- package/dist/types/internal-urls/parse.d.ts +19 -0
- package/dist/types/internal-urls/registry-helpers.d.ts +11 -0
- package/dist/types/internal-urls/router.d.ts +14 -0
- package/dist/types/internal-urls/rule-protocol.d.ts +6 -0
- package/dist/types/internal-urls/skill-protocol.d.ts +13 -0
- package/dist/types/internal-urls/types.d.ts +109 -0
- package/dist/types/jaw-interview/structured-renderer.d.ts +20 -0
- package/dist/types/jwc-runtime/actor-registry.d.ts +76 -0
- package/dist/types/jwc-runtime/agent-identity.d.ts +6 -0
- package/dist/types/jwc-runtime/cli-jaw-home.d.ts +1 -0
- package/dist/types/jwc-runtime/cli-jaw-vocab.d.ts +15 -0
- package/dist/types/jwc-runtime/cli-write-receipt.d.ts +24 -0
- package/dist/types/jwc-runtime/goal-cli.d.ts +7 -0
- package/dist/types/jwc-runtime/goal-engine.d.ts +193 -0
- package/dist/types/jwc-runtime/goal-guard.d.ts +26 -0
- package/dist/types/jwc-runtime/goal-mode-request.d.ts +78 -0
- package/dist/types/jwc-runtime/jaw-interview-runtime.d.ts +41 -0
- package/dist/types/jwc-runtime/launch-tmux.d.ts +70 -0
- package/dist/types/jwc-runtime/launch-worktree.d.ts +46 -0
- package/dist/types/jwc-runtime/legacy-storage.d.ts +19 -0
- package/dist/types/jwc-runtime/memory-runtime.d.ts +16 -0
- package/dist/types/jwc-runtime/orchestrate-runtime.d.ts +12 -0
- package/dist/types/jwc-runtime/orchestrate-state.d.ts +246 -0
- package/dist/types/jwc-runtime/plan-writer.d.ts +26 -0
- package/dist/types/jwc-runtime/restricted-role-agent-bash.d.ts +2 -0
- package/dist/types/jwc-runtime/session-state-sidecar.d.ts +17 -0
- package/dist/types/jwc-runtime/stage-skill-map.d.ts +7 -0
- package/dist/types/jwc-runtime/state-graph.d.ts +4 -0
- package/dist/types/jwc-runtime/state-migrations.d.ts +34 -0
- package/dist/types/jwc-runtime/state-renderer.d.ts +65 -0
- package/dist/types/jwc-runtime/state-runtime.d.ts +37 -0
- package/dist/types/jwc-runtime/state-schema.d.ts +324 -0
- package/dist/types/jwc-runtime/state-validation.d.ts +6 -0
- package/dist/types/jwc-runtime/state-writer.d.ts +147 -0
- package/dist/types/jwc-runtime/team-runtime.d.ts +349 -0
- package/dist/types/jwc-runtime/tmux-common.d.ts +49 -0
- package/dist/types/jwc-runtime/tmux-sessions.d.ts +17 -0
- package/dist/types/jwc-runtime/workflow-command-ref.d.ts +43 -0
- package/dist/types/jwc-runtime/workflow-manifest.d.ts +54 -0
- package/dist/types/lsp/client.d.ts +66 -0
- package/dist/types/lsp/clients/biome-client.d.ts +16 -0
- package/dist/types/lsp/clients/index.d.ts +19 -0
- package/dist/types/lsp/clients/lsp-linter-client.d.ts +16 -0
- package/dist/types/lsp/clients/swiftlint-client.d.ts +20 -0
- package/dist/types/lsp/config.d.ts +65 -0
- package/dist/types/lsp/edits.d.ts +23 -0
- package/dist/types/lsp/index.d.ts +130 -0
- package/dist/types/lsp/lspmux.d.ts +58 -0
- package/dist/types/lsp/render.d.ts +32 -0
- package/dist/types/lsp/startup-events.d.ts +11 -0
- package/dist/types/lsp/types.d.ts +302 -0
- package/dist/types/lsp/utils.d.ts +108 -0
- package/dist/types/main.d.ts +72 -0
- package/dist/types/mem0/backend.d.ts +2 -0
- package/dist/types/mem0/client.d.ts +49 -0
- package/dist/types/mem0/config.d.ts +24 -0
- package/dist/types/mem0/index.d.ts +5 -0
- package/dist/types/mem0/scope.d.ts +12 -0
- package/dist/types/mem0/state.d.ts +36 -0
- package/dist/types/memories/index.d.ts +28 -0
- package/dist/types/memories/local-query.d.ts +112 -0
- package/dist/types/memories/memory-config.d.ts +46 -0
- package/dist/types/memories/memory-fts.d.ts +51 -0
- package/dist/types/memories/memory-model-resolution.d.ts +20 -0
- package/dist/types/memories/memory-quality.d.ts +27 -0
- package/dist/types/memories/storage.d.ts +110 -0
- package/dist/types/memory-backend/index.d.ts +4 -0
- package/dist/types/memory-backend/local-backend.d.ts +9 -0
- package/dist/types/memory-backend/off-backend.d.ts +7 -0
- package/dist/types/memory-backend/resolve.d.ts +16 -0
- package/dist/types/memory-backend/types.d.ts +64 -0
- package/dist/types/migrate-config-dir-startup.d.ts +1 -0
- package/dist/types/migrate-config-dir.d.ts +22 -0
- package/dist/types/modes/acp/acp-agent.d.ts +61 -0
- package/dist/types/modes/acp/acp-client-bridge.d.ts +9 -0
- package/dist/types/modes/acp/acp-event-mapper.d.ts +34 -0
- package/dist/types/modes/acp/acp-mode.d.ts +5 -0
- package/dist/types/modes/acp/index.d.ts +2 -0
- package/dist/types/modes/acp/terminal-auth.d.ts +6 -0
- package/dist/types/modes/background-row-model.d.ts +3 -0
- package/dist/types/modes/bridge/auth.d.ts +12 -0
- package/dist/types/modes/bridge/bridge-client-bridge.d.ts +9 -0
- package/dist/types/modes/bridge/bridge-mode.d.ts +46 -0
- package/dist/types/modes/bridge/bridge-ui-context.d.ts +88 -0
- package/dist/types/modes/bridge/event-stream.d.ts +8 -0
- package/dist/types/modes/components/_cli-jaw-entry.d.ts +31 -0
- package/dist/types/modes/components/agent-dashboard.d.ts +21 -0
- package/dist/types/modes/components/assistant-message.d.ts +33 -0
- package/dist/types/modes/components/background-footer-detail.d.ts +6 -0
- package/dist/types/modes/components/background-footer-panel-model.d.ts +18 -0
- package/dist/types/modes/components/background-footer-panel.d.ts +19 -0
- package/dist/types/modes/components/bash-execution.d.ts +37 -0
- package/dist/types/modes/components/bordered-loader.d.ts +11 -0
- package/dist/types/modes/components/branch-summary-message.d.ts +15 -0
- package/dist/types/modes/components/btw-panel.d.ts +16 -0
- package/dist/types/modes/components/compaction-summary-message.d.ts +15 -0
- package/dist/types/modes/components/composer-chrome.d.ts +7 -0
- package/dist/types/modes/components/composer-footer.d.ts +43 -0
- package/dist/types/modes/components/countdown-timer.d.ts +14 -0
- package/dist/types/modes/components/custom-editor.d.ts +80 -0
- package/dist/types/modes/components/custom-message.d.ts +17 -0
- package/dist/types/modes/components/custom-provider-wizard.d.ts +10 -0
- package/dist/types/modes/components/diff.d.ts +11 -0
- package/dist/types/modes/components/dynamic-border.d.ts +14 -0
- package/dist/types/modes/components/eval-execution.d.ts +31 -0
- package/dist/types/modes/components/execution-shared.d.ts +46 -0
- package/dist/types/modes/components/extensions/extension-dashboard.d.ts +26 -0
- package/dist/types/modes/components/extensions/extension-list.d.ts +39 -0
- package/dist/types/modes/components/extensions/index.d.ts +8 -0
- package/dist/types/modes/components/extensions/inspector-panel.d.ts +8 -0
- package/dist/types/modes/components/extensions/state-manager.d.ts +50 -0
- package/dist/types/modes/components/extensions/types.d.ts +151 -0
- package/dist/types/modes/components/footer.d.ts +30 -0
- package/dist/types/modes/components/full-transcript-overlay.d.ts +21 -0
- package/dist/types/modes/components/help-selector.d.ts +38 -0
- package/dist/types/modes/components/history-search.d.ts +7 -0
- package/dist/types/modes/components/hook-editor.d.ts +18 -0
- package/dist/types/modes/components/hook-input.d.ts +15 -0
- package/dist/types/modes/components/hook-message.d.ts +15 -0
- package/dist/types/modes/components/hook-selector.d.ts +64 -0
- package/dist/types/modes/components/index.d.ts +35 -0
- package/dist/types/modes/components/jobs-overlay-model.d.ts +31 -0
- package/dist/types/modes/components/jobs-overlay.d.ts +30 -0
- package/dist/types/modes/components/keybinding-hints.d.ts +40 -0
- package/dist/types/modes/components/login-dialog.d.ts +32 -0
- package/dist/types/modes/components/message-frame.d.ts +42 -0
- package/dist/types/modes/components/model-selector.d.ts +53 -0
- package/dist/types/modes/components/oauth-selector.d.ts +14 -0
- package/dist/types/modes/components/pabcd-border.d.ts +8 -0
- package/dist/types/modes/components/plugin-selector.d.ts +26 -0
- package/dist/types/modes/components/plugin-settings.d.ts +66 -0
- package/dist/types/modes/components/provider-onboarding-selector.d.ts +7 -0
- package/dist/types/modes/components/queue-mode-selector.d.ts +9 -0
- package/dist/types/modes/components/quota-panel.d.ts +21 -0
- package/dist/types/modes/components/read-tool-group.d.ts +34 -0
- package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +25 -0
- package/dist/types/modes/components/session-observer-overlay.d.ts +11 -0
- package/dist/types/modes/components/session-selector.d.ts +30 -0
- package/dist/types/modes/components/settings-defs.d.ts +50 -0
- package/dist/types/modes/components/settings-selector.d.ts +56 -0
- package/dist/types/modes/components/show-images-selector.d.ts +9 -0
- package/dist/types/modes/components/skill-hud/render.d.ts +2 -0
- package/dist/types/modes/components/skill-message.d.ts +11 -0
- package/dist/types/modes/components/status-line/context-thresholds.d.ts +4 -0
- package/dist/types/modes/components/status-line/git-utils.d.ts +22 -0
- package/dist/types/modes/components/status-line/index.d.ts +4 -0
- package/dist/types/modes/components/status-line/presets.d.ts +3 -0
- package/dist/types/modes/components/status-line/segments.d.ts +5 -0
- package/dist/types/modes/components/status-line/separators.d.ts +3 -0
- package/dist/types/modes/components/status-line/token-rate.d.ts +10 -0
- package/dist/types/modes/components/status-line/types.d.ts +92 -0
- package/dist/types/modes/components/status-line/workflow-readers.d.ts +21 -0
- package/dist/types/modes/components/status-line.d.ts +82 -0
- package/dist/types/modes/components/theme-selector.d.ts +10 -0
- package/dist/types/modes/components/thinking-selector.d.ts +10 -0
- package/dist/types/modes/components/todo-reminder.d.ts +13 -0
- package/dist/types/modes/components/tool-execution.d.ts +69 -0
- package/dist/types/modes/components/tool-transcript-overlay.d.ts +18 -0
- package/dist/types/modes/components/tree-selector.d.ts +31 -0
- package/dist/types/modes/components/ttsr-notification.d.ts +15 -0
- package/dist/types/modes/components/user-message-selector.d.ts +28 -0
- package/dist/types/modes/components/user-message.d.ts +8 -0
- package/dist/types/modes/components/visual-truncate.d.ts +19 -0
- package/dist/types/modes/components/welcome.d.ts +42 -0
- package/dist/types/modes/controllers/btw-controller.d.ts +10 -0
- package/dist/types/modes/controllers/command-controller-shared.d.ts +47 -0
- package/dist/types/modes/controllers/command-controller.d.ts +39 -0
- package/dist/types/modes/controllers/event-controller.d.ts +12 -0
- package/dist/types/modes/controllers/extension-ui-controller.d.ts +80 -0
- package/dist/types/modes/controllers/input-controller.d.ts +49 -0
- package/dist/types/modes/controllers/runtime-mcp-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +78 -0
- package/dist/types/modes/controllers/ssh-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/todo-command-controller.d.ts +7 -0
- package/dist/types/modes/emoji-autocomplete.d.ts +16 -0
- package/dist/types/modes/index.d.ts +10 -0
- package/dist/types/modes/interactive-mode.d.ts +295 -0
- package/dist/types/modes/jobs-observer.d.ts +67 -0
- package/dist/types/modes/oauth-manual-input.d.ts +8 -0
- package/dist/types/modes/print-mode.d.ts +27 -0
- package/dist/types/modes/prompt-action-autocomplete.d.ts +46 -0
- package/dist/types/modes/rpc/host-tools.d.ts +1 -0
- package/dist/types/modes/rpc/host-uris.d.ts +1 -0
- package/dist/types/modes/rpc/rpc-client.d.ts +267 -0
- package/dist/types/modes/rpc/rpc-mode.d.ts +67 -0
- package/dist/types/modes/rpc/rpc-types.d.ts +765 -0
- package/dist/types/modes/runtime-init.d.ts +21 -0
- package/dist/types/modes/session-observer-registry.d.ts +26 -0
- package/dist/types/modes/shared/agent-wire/approval-gate.d.ts +57 -0
- package/dist/types/modes/shared/agent-wire/command-contract.d.ts +18 -0
- package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +35 -0
- package/dist/types/modes/shared/agent-wire/command-validation.d.ts +2 -0
- package/dist/types/modes/shared/agent-wire/event-contract.d.ts +84 -0
- package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +38 -0
- package/dist/types/modes/shared/agent-wire/event-observation.d.ts +37 -0
- package/dist/types/modes/shared/agent-wire/handshake.d.ts +56 -0
- package/dist/types/modes/shared/agent-wire/host-tool-bridge.d.ts +16 -0
- package/dist/types/modes/shared/agent-wire/host-uri-bridge.d.ts +17 -0
- package/dist/types/modes/shared/agent-wire/jaw-interview-gate.d.ts +58 -0
- package/dist/types/modes/shared/agent-wire/protocol.d.ts +25 -0
- package/dist/types/modes/shared/agent-wire/responses.d.ts +4 -0
- package/dist/types/modes/shared/agent-wire/scopes.d.ts +18 -0
- package/dist/types/modes/shared/agent-wire/session-registry.d.ts +25 -0
- package/dist/types/modes/shared/agent-wire/ui-request-broker.d.ts +42 -0
- package/dist/types/modes/shared/agent-wire/ui-result.d.ts +27 -0
- package/dist/types/modes/shared/agent-wire/unattended-action-policy.d.ts +27 -0
- package/dist/types/modes/shared/agent-wire/unattended-audit.d.ts +68 -0
- package/dist/types/modes/shared/agent-wire/unattended-run-controller.d.ts +161 -0
- package/dist/types/modes/shared/agent-wire/unattended-session.d.ts +61 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +114 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-schema.d.ts +39 -0
- package/dist/types/modes/shared.d.ts +15 -0
- package/dist/types/modes/theme/defaults/index.d.ts +499 -0
- package/dist/types/modes/theme/mermaid-cache.d.ts +9 -0
- package/dist/types/modes/theme/shimmer.d.ts +38 -0
- package/dist/types/modes/theme/theme.d.ts +274 -0
- package/dist/types/modes/types.d.ts +311 -0
- package/dist/types/modes/utils/abort-message.d.ts +4 -0
- package/dist/types/modes/utils/compaction-progress.d.ts +20 -0
- package/dist/types/modes/utils/context-usage.d.ts +53 -0
- package/dist/types/modes/utils/help-markdown.d.ts +17 -0
- package/dist/types/modes/utils/hotkeys-markdown.d.ts +5 -0
- package/dist/types/modes/utils/keybinding-matchers.d.ts +10 -0
- package/dist/types/modes/utils/session-transcript-replay.d.ts +24 -0
- package/dist/types/modes/utils/tools-markdown.d.ts +5 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +77 -0
- package/dist/types/notifications/ask-bridge.d.ts +36 -0
- package/dist/types/notifications/config-command-parser.d.ts +27 -0
- package/dist/types/notifications/config.d.ts +37 -0
- package/dist/types/notifications/daemon-control.d.ts +29 -0
- package/dist/types/notifications/daemon-engine.d.ts +64 -0
- package/dist/types/notifications/daemon-inbound.d.ts +93 -0
- package/dist/types/notifications/daemon-loop.d.ts +28 -0
- package/dist/types/notifications/daemon-owner.d.ts +25 -0
- package/dist/types/notifications/daemon-runtime.d.ts +32 -0
- package/dist/types/notifications/discovery.d.ts +45 -0
- package/dist/types/notifications/index.d.ts +34 -0
- package/dist/types/notifications/lifecycle-audit.d.ts +60 -0
- package/dist/types/notifications/lifecycle-command-parser.d.ts +19 -0
- package/dist/types/notifications/lifecycle-control-runtime.d.ts +45 -0
- package/dist/types/notifications/notification-redaction.d.ts +36 -0
- package/dist/types/notifications/protocol.d.ts +43 -0
- package/dist/types/notifications/remote-answer.d.ts +78 -0
- package/dist/types/notifications/reply-bridge.d.ts +21 -0
- package/dist/types/notifications/server.d.ts +38 -0
- package/dist/types/notifications/session-lifecycle.d.ts +22 -0
- package/dist/types/notifications/session-registry.d.ts +31 -0
- package/dist/types/notifications/telegram-api.d.ts +93 -0
- package/dist/types/notifications/telegram-ask-keyboard.d.ts +57 -0
- package/dist/types/notifications/telegram-callback-ingest.d.ts +49 -0
- package/dist/types/notifications/telegram-inbound-router.d.ts +57 -0
- package/dist/types/notifications/telegram-media-policy.d.ts +27 -0
- package/dist/types/notifications/telegram-media-render.d.ts +29 -0
- package/dist/types/notifications/telegram-message-ingest.d.ts +54 -0
- package/dist/types/notifications/telegram-pairing.d.ts +21 -0
- package/dist/types/notifications/threaded-lifecycle.d.ts +23 -0
- package/dist/types/notifications/threaded-shutdown.d.ts +19 -0
- package/dist/types/notifications/threaded-surface.d.ts +71 -0
- package/dist/types/notifications/transport-shell.d.ts +47 -0
- package/dist/types/notifications/transport-state.d.ts +44 -0
- package/dist/types/notifications/workspace-path-confinement.d.ts +12 -0
- package/dist/types/plan-mode/approved-plan.d.ts +49 -0
- package/dist/types/plan-mode/state.d.ts +6 -0
- package/dist/types/registry/agent-registry.d.ts +62 -0
- package/dist/types/reminders/star-reminder.d.ts +115 -0
- package/dist/types/runtime-mcp/client.d.ts +74 -0
- package/dist/types/runtime-mcp/config-writer.d.ts +53 -0
- package/dist/types/runtime-mcp/config.d.ts +75 -0
- package/dist/types/runtime-mcp/discoverable-tool-metadata.d.ts +7 -0
- package/dist/types/runtime-mcp/index.d.ts +18 -0
- package/dist/types/runtime-mcp/json-rpc.d.ts +22 -0
- package/dist/types/runtime-mcp/loader.d.ts +43 -0
- package/dist/types/runtime-mcp/manager.d.ts +193 -0
- package/dist/types/runtime-mcp/oauth-discovery.d.ts +40 -0
- package/dist/types/runtime-mcp/oauth-flow.d.ts +59 -0
- package/dist/types/runtime-mcp/render.d.ts +25 -0
- package/dist/types/runtime-mcp/smithery-auth.d.ts +16 -0
- package/dist/types/runtime-mcp/smithery-connect.d.ts +38 -0
- package/dist/types/runtime-mcp/smithery-registry.d.ts +51 -0
- package/dist/types/runtime-mcp/tool-bridge.d.ts +86 -0
- package/dist/types/runtime-mcp/tool-cache.d.ts +8 -0
- package/dist/types/runtime-mcp/transports/http.d.ts +36 -0
- package/dist/types/runtime-mcp/transports/index.d.ts +5 -0
- package/dist/types/runtime-mcp/transports/stdio.d.ts +28 -0
- package/dist/types/runtime-mcp/types.d.ts +333 -0
- package/dist/types/sdk.d.ts +234 -0
- package/dist/types/secrets/index.d.ts +10 -0
- package/dist/types/secrets/obfuscator.d.ts +23 -0
- package/dist/types/secrets/regex.d.ts +2 -0
- package/dist/types/session/agent-session.d.ts +1052 -0
- package/dist/types/session/agent-storage.d.ts +100 -0
- package/dist/types/session/artifacts.d.ts +61 -0
- package/dist/types/session/auth-broker-config.d.ts +13 -0
- package/dist/types/session/auth-storage.d.ts +6 -0
- package/dist/types/session/blob-store.d.ts +112 -0
- package/dist/types/session/client-bridge.d.ts +88 -0
- package/dist/types/session/contribution-prep.d.ts +47 -0
- package/dist/types/session/history-storage.d.ts +16 -0
- package/dist/types/session/messages.d.ts +165 -0
- package/dist/types/session/pabcd-stage-header.d.ts +18 -0
- package/dist/types/session/session-dump-format.d.ts +22 -0
- package/dist/types/session/session-manager.d.ts +571 -0
- package/dist/types/session/session-storage.d.ts +88 -0
- package/dist/types/session/streaming-output.d.ts +196 -0
- package/dist/types/session/tool-choice-queue.d.ts +78 -0
- package/dist/types/session/yield-queue.d.ts +24 -0
- package/dist/types/setup/hermes-setup.d.ts +71 -0
- package/dist/types/setup/model-onboarding-guidance.d.ts +9 -0
- package/dist/types/setup/provider-onboarding.d.ts +52 -0
- package/dist/types/skill-state/active-state.d.ts +115 -0
- package/dist/types/skill-state/initial-phase.d.ts +12 -0
- package/dist/types/skill-state/jaw-interview-mutation-guard.d.ts +33 -0
- package/dist/types/skill-state/workflow-hud.d.ts +76 -0
- package/dist/types/skill-state/workflow-state-contract.d.ts +60 -0
- package/dist/types/skill-state/workflow-state-version.d.ts +3 -0
- package/dist/types/slash-commands/acp-builtins.d.ts +18 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +24 -0
- package/dist/types/slash-commands/helpers/context-report.d.ts +7 -0
- package/dist/types/slash-commands/helpers/format.d.ts +10 -0
- package/dist/types/slash-commands/helpers/mcp.d.ts +3 -0
- package/dist/types/slash-commands/helpers/parse.d.ts +33 -0
- package/dist/types/slash-commands/helpers/ssh.d.ts +3 -0
- package/dist/types/slash-commands/helpers/todo.d.ts +3 -0
- package/dist/types/slash-commands/helpers/usage-report.d.ts +11 -0
- package/dist/types/slash-commands/types.d.ts +120 -0
- package/dist/types/ssh/config-writer.d.ts +49 -0
- package/dist/types/ssh/connection-manager.d.ts +33 -0
- package/dist/types/ssh/ssh-executor.d.ts +37 -0
- package/dist/types/ssh/sshfs-mount.d.ts +6 -0
- package/dist/types/ssh/utils.d.ts +2 -0
- package/dist/types/stt/downloader.d.ts +9 -0
- package/dist/types/stt/index.d.ts +3 -0
- package/dist/types/stt/recorder.d.ts +13 -0
- package/dist/types/stt/setup.d.ts +18 -0
- package/dist/types/stt/stt-controller.d.ts +16 -0
- package/dist/types/stt/transcriber.d.ts +16 -0
- package/dist/types/system-prompt.d.ts +100 -0
- package/dist/types/task/agents.d.ts +28 -0
- package/dist/types/task/commands.d.ts +35 -0
- package/dist/types/task/discovery.d.ts +19 -0
- package/dist/types/task/executor.d.ts +113 -0
- package/dist/types/task/fork-context-advisory.d.ts +13 -0
- package/dist/types/task/id.d.ts +7 -0
- package/dist/types/task/index.d.ts +43 -0
- package/dist/types/task/jwc-command.d.ts +7 -0
- package/dist/types/task/model-presets.d.ts +17 -0
- package/dist/types/task/name-generator.d.ts +16 -0
- package/dist/types/task/output-manager.d.ts +36 -0
- package/dist/types/task/parallel.d.ts +34 -0
- package/dist/types/task/receipt.d.ts +86 -0
- package/dist/types/task/render.d.ts +28 -0
- package/dist/types/task/roi-reconciliation.d.ts +27 -0
- package/dist/types/task/simple-mode.d.ts +8 -0
- package/dist/types/task/spawn-gate.d.ts +38 -0
- package/dist/types/task/subprocess-tool-registry.d.ts +72 -0
- package/dist/types/task/types.d.ts +506 -0
- package/dist/types/task/worktree.d.ts +94 -0
- package/dist/types/thinking.d.ts +31 -0
- package/dist/types/tool-discovery/tool-index.d.ts +113 -0
- package/dist/types/tools/archive-reader.d.ts +40 -0
- package/dist/types/tools/ask.d.ts +152 -0
- package/dist/types/tools/ast-edit.d.ts +77 -0
- package/dist/types/tools/ast-grep.d.ts +69 -0
- package/dist/types/tools/auto-generated-guard.d.ts +17 -0
- package/dist/types/tools/background.d.ts +124 -0
- package/dist/types/tools/bash-allowed-prefixes.d.ts +5 -0
- package/dist/types/tools/bash-command-fixup.d.ts +11 -0
- package/dist/types/tools/bash-interactive.d.ts +16 -0
- package/dist/types/tools/bash-interceptor.d.ts +24 -0
- package/dist/types/tools/bash-pty-selection.d.ts +7 -0
- package/dist/types/tools/bash-skill-urls.d.ts +31 -0
- package/dist/types/tools/bash.d.ts +156 -0
- package/dist/types/tools/browser/actions.d.ts +54 -0
- package/dist/types/tools/browser/attach.d.ts +34 -0
- package/dist/types/tools/browser/launch.d.ts +62 -0
- package/dist/types/tools/browser/readable.d.ts +17 -0
- package/dist/types/tools/browser/registry.d.ts +42 -0
- package/dist/types/tools/browser/render.d.ts +50 -0
- package/dist/types/tools/browser/tab-protocol.d.ts +144 -0
- package/dist/types/tools/browser/tab-supervisor.d.ts +63 -0
- package/dist/types/tools/browser/tab-worker-entry.d.ts +1 -0
- package/dist/types/tools/browser/tab-worker.d.ts +19 -0
- package/dist/types/tools/browser.d.ts +194 -0
- package/dist/types/tools/calculator.d.ts +76 -0
- package/dist/types/tools/checkpoint.d.ts +63 -0
- package/dist/types/tools/computer-use-backend.d.ts +6 -0
- package/dist/types/tools/computer-use.d.ts +100 -0
- package/dist/types/tools/conflict-detect.d.ts +205 -0
- package/dist/types/tools/context.d.ts +19 -0
- package/dist/types/tools/cron.d.ts +116 -0
- package/dist/types/tools/debug.d.ts +209 -0
- package/dist/types/tools/eval.d.ts +108 -0
- package/dist/types/tools/fetch.d.ts +61 -0
- package/dist/types/tools/file-recorder.d.ts +13 -0
- package/dist/types/tools/find.d.ts +95 -0
- package/dist/types/tools/fs-cache-invalidation.d.ts +15 -0
- package/dist/types/tools/gh-format.d.ts +6 -0
- package/dist/types/tools/gh-renderer.d.ts +25 -0
- package/dist/types/tools/gh.d.ts +356 -0
- package/dist/types/tools/github-cache.d.ts +103 -0
- package/dist/types/tools/grouped-file-output.d.ts +36 -0
- package/dist/types/tools/hindsight-recall.d.ts +21 -0
- package/dist/types/tools/hindsight-reflect.d.ts +23 -0
- package/dist/types/tools/hindsight-retain.d.ts +27 -0
- package/dist/types/tools/image-gen.d.ts +79 -0
- package/dist/types/tools/index.d.ts +281 -0
- package/dist/types/tools/inspect-image-renderer.d.ts +26 -0
- package/dist/types/tools/inspect-image.d.ts +31 -0
- package/dist/types/tools/irc.d.ts +79 -0
- package/dist/types/tools/job.d.ts +65 -0
- package/dist/types/tools/json-tree.d.ts +23 -0
- package/dist/types/tools/jtd-to-json-schema.d.ts +29 -0
- package/dist/types/tools/jtd-to-typescript.d.ts +26 -0
- package/dist/types/tools/jtd-utils.d.ts +42 -0
- package/dist/types/tools/list-limit.d.ts +12 -0
- package/dist/types/tools/match-line-format.d.ts +11 -0
- package/dist/types/tools/monitor.d.ts +65 -0
- package/dist/types/tools/output-meta.d.ts +204 -0
- package/dist/types/tools/path-utils.d.ts +147 -0
- package/dist/types/tools/plan-mode-guard.d.ts +18 -0
- package/dist/types/tools/read.d.ts +85 -0
- package/dist/types/tools/recipe/index.d.ts +45 -0
- package/dist/types/tools/recipe/render.d.ts +36 -0
- package/dist/types/tools/recipe/runner.d.ts +60 -0
- package/dist/types/tools/recipe/runners/cargo.d.ts +16 -0
- package/dist/types/tools/recipe/runners/index.d.ts +2 -0
- package/dist/types/tools/recipe/runners/just.d.ts +2 -0
- package/dist/types/tools/recipe/runners/make.d.ts +2 -0
- package/dist/types/tools/recipe/runners/pkg.d.ts +2 -0
- package/dist/types/tools/recipe/runners/task.d.ts +2 -0
- package/dist/types/tools/render-mermaid.d.ts +37 -0
- package/dist/types/tools/render-utils.d.ts +158 -0
- package/dist/types/tools/renderers.d.ts +26 -0
- package/dist/types/tools/resolve.d.ts +90 -0
- package/dist/types/tools/review.d.ts +63 -0
- package/dist/types/tools/search-tool-bm25.d.ts +65 -0
- package/dist/types/tools/search.d.ts +93 -0
- package/dist/types/tools/skill.d.ts +47 -0
- package/dist/types/tools/sqlite-reader.d.ts +93 -0
- package/dist/types/tools/ssh.d.ts +67 -0
- package/dist/types/tools/subagent-render.d.ts +25 -0
- package/dist/types/tools/subagent.d.ts +87 -0
- package/dist/types/tools/telegram-send.d.ts +53 -0
- package/dist/types/tools/todo-write.d.ts +120 -0
- package/dist/types/tools/tool-errors.d.ts +33 -0
- package/dist/types/tools/tool-result.d.ts +30 -0
- package/dist/types/tools/tool-timeouts.d.ts +51 -0
- package/dist/types/tools/vim.d.ts +58 -0
- package/dist/types/tools/write.d.ts +59 -0
- package/dist/types/tools/yield.d.ts +25 -0
- package/dist/types/tui/code-cell.d.ts +32 -0
- package/dist/types/tui/file-list.d.ts +22 -0
- package/dist/types/tui/hyperlink.d.ts +42 -0
- package/dist/types/tui/index.d.ts +11 -0
- package/dist/types/tui/output-block.d.ts +28 -0
- package/dist/types/tui/status-line.d.ts +18 -0
- package/dist/types/tui/tree-list.d.ts +19 -0
- package/dist/types/tui/types.d.ts +13 -0
- package/dist/types/tui/utils.d.ts +36 -0
- package/dist/types/utils/changelog.d.ts +36 -0
- package/dist/types/utils/clipboard.d.ts +22 -0
- package/dist/types/utils/command-args.d.ts +9 -0
- package/dist/types/utils/commit-message-generator.d.ts +7 -0
- package/dist/types/utils/edit-mode.d.ts +13 -0
- package/dist/types/utils/event-bus.d.ts +6 -0
- package/dist/types/utils/external-editor.d.ts +17 -0
- package/dist/types/utils/file-display-mode.d.ts +27 -0
- package/dist/types/utils/file-mentions.d.ts +11 -0
- package/dist/types/utils/git.d.ts +361 -0
- package/dist/types/utils/image-loading.d.ts +26 -0
- package/dist/types/utils/image-resize.d.ts +39 -0
- package/dist/types/utils/lang-from-path.d.ts +8 -0
- package/dist/types/utils/markit.d.ts +7 -0
- package/dist/types/utils/open.d.ts +2 -0
- package/dist/types/utils/session-color.d.ts +10 -0
- package/dist/types/utils/shell-snapshot.d.ts +5 -0
- package/dist/types/utils/sixel.d.ts +21 -0
- package/dist/types/utils/title-generator.d.ts +31 -0
- package/dist/types/utils/tokenizer-download.d.ts +4 -0
- package/dist/types/utils/tokenizer-encoding.d.ts +7 -0
- package/dist/types/utils/tool-choice.d.ts +20 -0
- package/dist/types/utils/tools-manager.d.ts +9 -0
- package/dist/types/vim/buffer.d.ts +41 -0
- package/dist/types/vim/commands.d.ts +6 -0
- package/dist/types/vim/engine.d.ts +47 -0
- package/dist/types/vim/parser.d.ts +3 -0
- package/dist/types/vim/render.d.ts +25 -0
- package/dist/types/vim/types.d.ts +182 -0
- package/dist/types/web/kagi.d.ts +23 -0
- package/dist/types/web/parallel.d.ts +58 -0
- package/dist/types/web/public-fetch-url.d.ts +1 -0
- package/dist/types/web/scrapers/artifacthub.d.ts +6 -0
- package/dist/types/web/scrapers/arxiv.d.ts +5 -0
- package/dist/types/web/scrapers/aur.d.ts +5 -0
- package/dist/types/web/scrapers/biorxiv.d.ts +5 -0
- package/dist/types/web/scrapers/bluesky.d.ts +5 -0
- package/dist/types/web/scrapers/brew.d.ts +5 -0
- package/dist/types/web/scrapers/cheatsh.d.ts +8 -0
- package/dist/types/web/scrapers/chocolatey.d.ts +5 -0
- package/dist/types/web/scrapers/choosealicense.d.ts +2 -0
- package/dist/types/web/scrapers/cisa-kev.d.ts +5 -0
- package/dist/types/web/scrapers/clojars.d.ts +5 -0
- package/dist/types/web/scrapers/coingecko.d.ts +5 -0
- package/dist/types/web/scrapers/crates-io.d.ts +5 -0
- package/dist/types/web/scrapers/crossref.d.ts +2 -0
- package/dist/types/web/scrapers/devto.d.ts +5 -0
- package/dist/types/web/scrapers/discogs.d.ts +8 -0
- package/dist/types/web/scrapers/discourse.d.ts +5 -0
- package/dist/types/web/scrapers/dockerhub.d.ts +5 -0
- package/dist/types/web/scrapers/docs-rs.d.ts +2 -0
- package/dist/types/web/scrapers/fdroid.d.ts +5 -0
- package/dist/types/web/scrapers/firefox-addons.d.ts +2 -0
- package/dist/types/web/scrapers/flathub.d.ts +2 -0
- package/dist/types/web/scrapers/github-gist.d.ts +5 -0
- package/dist/types/web/scrapers/github.d.ts +12 -0
- package/dist/types/web/scrapers/gitlab.d.ts +5 -0
- package/dist/types/web/scrapers/go-pkg.d.ts +5 -0
- package/dist/types/web/scrapers/hackage.d.ts +5 -0
- package/dist/types/web/scrapers/hackernews.d.ts +2 -0
- package/dist/types/web/scrapers/hex.d.ts +5 -0
- package/dist/types/web/scrapers/huggingface.d.ts +2 -0
- package/dist/types/web/scrapers/iacr.d.ts +5 -0
- package/dist/types/web/scrapers/index.d.ts +84 -0
- package/dist/types/web/scrapers/jetbrains-marketplace.d.ts +2 -0
- package/dist/types/web/scrapers/lemmy.d.ts +2 -0
- package/dist/types/web/scrapers/lobsters.d.ts +5 -0
- package/dist/types/web/scrapers/mastodon.d.ts +5 -0
- package/dist/types/web/scrapers/maven.d.ts +6 -0
- package/dist/types/web/scrapers/mdn.d.ts +2 -0
- package/dist/types/web/scrapers/metacpan.d.ts +5 -0
- package/dist/types/web/scrapers/musicbrainz.d.ts +5 -0
- package/dist/types/web/scrapers/npm.d.ts +5 -0
- package/dist/types/web/scrapers/nuget.d.ts +5 -0
- package/dist/types/web/scrapers/nvd.d.ts +5 -0
- package/dist/types/web/scrapers/ollama.d.ts +2 -0
- package/dist/types/web/scrapers/open-vsx.d.ts +5 -0
- package/dist/types/web/scrapers/opencorporates.d.ts +5 -0
- package/dist/types/web/scrapers/openlibrary.d.ts +5 -0
- package/dist/types/web/scrapers/orcid.d.ts +5 -0
- package/dist/types/web/scrapers/osv.d.ts +5 -0
- package/dist/types/web/scrapers/packagist.d.ts +5 -0
- package/dist/types/web/scrapers/pub-dev.d.ts +5 -0
- package/dist/types/web/scrapers/pubmed.d.ts +5 -0
- package/dist/types/web/scrapers/pypi.d.ts +5 -0
- package/dist/types/web/scrapers/rawg.d.ts +2 -0
- package/dist/types/web/scrapers/readthedocs.d.ts +2 -0
- package/dist/types/web/scrapers/reddit.d.ts +5 -0
- package/dist/types/web/scrapers/repology.d.ts +5 -0
- package/dist/types/web/scrapers/rfc.d.ts +5 -0
- package/dist/types/web/scrapers/rubygems.d.ts +5 -0
- package/dist/types/web/scrapers/searchcode.d.ts +2 -0
- package/dist/types/web/scrapers/sec-edgar.d.ts +5 -0
- package/dist/types/web/scrapers/semantic-scholar.d.ts +2 -0
- package/dist/types/web/scrapers/snapcraft.d.ts +2 -0
- package/dist/types/web/scrapers/sourcegraph.d.ts +2 -0
- package/dist/types/web/scrapers/spdx.d.ts +5 -0
- package/dist/types/web/scrapers/spotify.d.ts +8 -0
- package/dist/types/web/scrapers/stackoverflow.d.ts +6 -0
- package/dist/types/web/scrapers/terraform.d.ts +5 -0
- package/dist/types/web/scrapers/tldr.d.ts +7 -0
- package/dist/types/web/scrapers/twitter.d.ts +5 -0
- package/dist/types/web/scrapers/types.d.ts +78 -0
- package/dist/types/web/scrapers/utils.d.ts +26 -0
- package/dist/types/web/scrapers/vimeo.d.ts +5 -0
- package/dist/types/web/scrapers/vscode-marketplace.d.ts +5 -0
- package/dist/types/web/scrapers/w3c.d.ts +2 -0
- package/dist/types/web/scrapers/wikidata.d.ts +5 -0
- package/dist/types/web/scrapers/wikipedia.d.ts +5 -0
- package/dist/types/web/scrapers/youtube.d.ts +5 -0
- package/dist/types/web/search/index.d.ts +95 -0
- package/dist/types/web/search/provider.d.ts +35 -0
- package/dist/types/web/search/providers/anthropic.d.ts +32 -0
- package/dist/types/web/search/providers/base.d.ts +90 -0
- package/dist/types/web/search/providers/brave.d.ts +27 -0
- package/dist/types/web/search/providers/codex.d.ts +35 -0
- package/dist/types/web/search/providers/duckduckgo.d.ts +57 -0
- package/dist/types/web/search/providers/exa.d.ts +52 -0
- package/dist/types/web/search/providers/gemini.d.ts +59 -0
- package/dist/types/web/search/providers/jina.d.ts +26 -0
- package/dist/types/web/search/providers/kagi.d.ts +24 -0
- package/dist/types/web/search/providers/kimi.d.ts +27 -0
- package/dist/types/web/search/providers/parallel.d.ts +15 -0
- package/dist/types/web/search/providers/perplexity.d.ts +38 -0
- package/dist/types/web/search/providers/searxng.d.ts +44 -0
- package/dist/types/web/search/providers/synthetic.d.ts +21 -0
- package/dist/types/web/search/providers/tavily.d.ts +29 -0
- package/dist/types/web/search/providers/utils.d.ts +52 -0
- package/dist/types/web/search/providers/xai.d.ts +62 -0
- package/dist/types/web/search/providers/zai.d.ts +28 -0
- package/dist/types/web/search/render.d.ts +35 -0
- package/dist/types/web/search/types.d.ts +348 -0
- package/dist/types/web/search/utils.d.ts +4 -0
- package/dist/types/workspace-tree.d.ts +42 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +104 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/extensions/README.md +120 -0
- package/examples/extensions/api-demo.ts +79 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +31 -0
- package/examples/extensions/pirate.ts +43 -0
- package/examples/extensions/plan-mode.ts +549 -0
- package/examples/extensions/reload-runtime.ts +38 -0
- package/examples/extensions/tools.ts +144 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +16 -0
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +48 -0
- package/examples/hooks/confirm-destructive.ts +58 -0
- package/examples/hooks/custom-compaction.ts +115 -0
- package/examples/hooks/dirty-repo-guard.ts +51 -0
- package/examples/hooks/file-trigger.ts +40 -0
- package/examples/hooks/git-checkpoint.ts +52 -0
- package/examples/hooks/handoff.ts +149 -0
- package/examples/hooks/permission-gate.ts +33 -0
- package/examples/hooks/protected-paths.ts +29 -0
- package/examples/hooks/qna.ts +118 -0
- package/examples/hooks/status-line.ts +39 -0
- package/examples/sdk/01-minimal.ts +21 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +46 -0
- package/examples/sdk/04-skills.ts +43 -0
- package/examples/sdk/06-extensions.ts +82 -0
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +35 -0
- package/examples/sdk/08-prompt-templates.ts +41 -0
- package/examples/sdk/08-slash-commands.ts +46 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
- package/examples/sdk/11-sessions.ts +47 -0
- package/examples/sdk/README.md +172 -0
- package/package.json +539 -0
- package/scripts/build-binary.ts +84 -0
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-docs-index.ts +71 -0
- package/scripts/generate-template.ts +33 -0
- package/src/async/index.ts +2 -0
- package/src/async/job-manager.ts +1299 -0
- package/src/async/support.ts +6 -0
- package/src/autoresearch/command-resume.md +14 -0
- package/src/autoresearch/dashboard.ts +446 -0
- package/src/autoresearch/git.ts +319 -0
- package/src/autoresearch/helpers.ts +218 -0
- package/src/autoresearch/index.ts +536 -0
- package/src/autoresearch/prompt-setup.md +43 -0
- package/src/autoresearch/prompt.md +103 -0
- package/src/autoresearch/resume-message.md +10 -0
- package/src/autoresearch/state.ts +273 -0
- package/src/autoresearch/storage.ts +699 -0
- package/src/autoresearch/tools/init-experiment.ts +272 -0
- package/src/autoresearch/tools/log-experiment.ts +524 -0
- package/src/autoresearch/tools/run-experiment.ts +475 -0
- package/src/autoresearch/tools/update-notes.ts +109 -0
- package/src/autoresearch/types.ts +168 -0
- package/src/bun-imports.d.ts +28 -0
- package/src/capability/context-file.ts +44 -0
- package/src/capability/extension-module.ts +34 -0
- package/src/capability/extension.ts +47 -0
- package/src/capability/fs.ts +107 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +436 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +74 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule.ts +244 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +56 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/ssh.ts +41 -0
- package/src/capability/system-prompt.ts +34 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +168 -0
- package/src/cli/agents-cli.ts +141 -0
- package/src/cli/args.ts +309 -0
- package/src/cli/auth-broker-cli.ts +747 -0
- package/src/cli/auth-gateway-cli.ts +411 -0
- package/src/cli/classify-install-target.ts +50 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/config-cli.ts +426 -0
- package/src/cli/fast-help.ts +80 -0
- package/src/cli/file-processor.ts +123 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/list-models.ts +194 -0
- package/src/cli/notify-cli.ts +135 -0
- package/src/cli/plugin-cli.ts +942 -0
- package/src/cli/read-cli.ts +57 -0
- package/src/cli/session-picker.ts +52 -0
- package/src/cli/setup-cli.ts +537 -0
- package/src/cli/shell-cli.ts +176 -0
- package/src/cli/skills-cli.ts +88 -0
- package/src/cli/ssh-cli.ts +179 -0
- package/src/cli/stats-cli.ts +238 -0
- package/src/cli/update-cli.ts +468 -0
- package/src/cli/web-search-cli.ts +133 -0
- package/src/cli/worktree-cli.ts +291 -0
- package/src/cli.ts +150 -0
- package/src/commands/acp.ts +24 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/auth-broker.ts +96 -0
- package/src/commands/auth-gateway.ts +63 -0
- package/src/commands/chat.ts +25 -0
- package/src/commands/codex-native-hook.ts +12 -0
- package/src/commands/commit.ts +46 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/contribution-prep.ts +41 -0
- package/src/commands/coordinator.ts +71 -0
- package/src/commands/goal.ts +37 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/harness.ts +1137 -0
- package/src/commands/interview.ts +42 -0
- package/src/commands/launch.ts +178 -0
- package/src/commands/mcp-serve.ts +63 -0
- package/src/commands/memory.ts +34 -0
- package/src/commands/notify.ts +45 -0
- package/src/commands/orchestrate.ts +55 -0
- package/src/commands/planphase.ts +19 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/ralplan.ts +25 -0
- package/src/commands/read.ts +35 -0
- package/src/commands/session.ts +151 -0
- package/src/commands/setup.ts +85 -0
- package/src/commands/shell.ts +29 -0
- package/src/commands/skills.ts +49 -0
- package/src/commands/ssh.ts +60 -0
- package/src/commands/state.ts +25 -0
- package/src/commands/stats.ts +29 -0
- package/src/commands/team.ts +217 -0
- package/src/commands/ultragoal.ts +40 -0
- package/src/commands/update.ts +21 -0
- package/src/commands/web-search.ts +42 -0
- package/src/commands/worktree.ts +57 -0
- package/src/commit/agentic/agent.ts +316 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +356 -0
- package/src/commit/agentic/prompts/analyze-file.md +22 -0
- package/src/commit/agentic/prompts/session-user.md +25 -0
- package/src/commit/agentic/prompts/split-confirm.md +1 -0
- package/src/commit/agentic/prompts/system.md +38 -0
- package/src/commit/agentic/state.ts +60 -0
- package/src/commit/agentic/tools/analyze-file.ts +127 -0
- package/src/commit/agentic/tools/git-file-diff.ts +191 -0
- package/src/commit/agentic/tools/git-hunk.ts +50 -0
- package/src/commit/agentic/tools/git-overview.ts +81 -0
- package/src/commit/agentic/tools/index.ts +54 -0
- package/src/commit/agentic/tools/propose-changelog.ts +144 -0
- package/src/commit/agentic/tools/propose-commit.ts +109 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +23 -0
- package/src/commit/agentic/tools/split-commit.ts +238 -0
- package/src/commit/agentic/topo-sort.ts +44 -0
- package/src/commit/agentic/trivial.ts +51 -0
- package/src/commit/agentic/validation.ts +183 -0
- package/src/commit/analysis/conventional.ts +64 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +105 -0
- package/src/commit/analysis/validation.ts +66 -0
- package/src/commit/changelog/detect.ts +40 -0
- package/src/commit/changelog/generate.ts +97 -0
- package/src/commit/changelog/index.ts +234 -0
- package/src/commit/changelog/parse.ts +44 -0
- package/src/commit/cli.ts +85 -0
- package/src/commit/git/diff.ts +148 -0
- package/src/commit/index.ts +5 -0
- package/src/commit/map-reduce/index.ts +69 -0
- package/src/commit/map-reduce/map-phase.ts +193 -0
- package/src/commit/map-reduce/reduce-phase.ts +49 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +51 -0
- package/src/commit/pipeline.ts +244 -0
- package/src/commit/prompts/analysis-system.md +148 -0
- package/src/commit/prompts/analysis-user.md +38 -0
- package/src/commit/prompts/changelog-system.md +50 -0
- package/src/commit/prompts/changelog-user.md +18 -0
- package/src/commit/prompts/file-observer-system.md +24 -0
- package/src/commit/prompts/file-observer-user.md +8 -0
- package/src/commit/prompts/reduce-system.md +50 -0
- package/src/commit/prompts/reduce-user.md +17 -0
- package/src/commit/prompts/summary-retry.md +3 -0
- package/src/commit/prompts/summary-system.md +38 -0
- package/src/commit/prompts/summary-user.md +13 -0
- package/src/commit/prompts/types-description.md +2 -0
- package/src/commit/shared-llm.ts +77 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +58 -0
- package/src/config/config-file.ts +232 -0
- package/src/config/file-lock.ts +121 -0
- package/src/config/keybindings.ts +553 -0
- package/src/config/mcp-schema.json +230 -0
- package/src/config/model-equivalence.ts +816 -0
- package/src/config/model-profile-activation.ts +165 -0
- package/src/config/model-profiles.ts +188 -0
- package/src/config/model-registry.ts +2751 -0
- package/src/config/model-resolver.ts +1355 -0
- package/src/config/models-config-schema.ts +254 -0
- package/src/config/oauth-provider-aliases.ts +49 -0
- package/src/config/prompt-templates.ts +310 -0
- package/src/config/resolve-config-value.ts +94 -0
- package/src/config/settings-schema.ts +3235 -0
- package/src/config/settings.ts +979 -0
- package/src/config/skill-settings-defaults.ts +35 -0
- package/src/config.ts +212 -0
- package/src/coordinator/contract.ts +20 -0
- package/src/coordinator-mcp/policy.ts +174 -0
- package/src/coordinator-mcp/safety.ts +80 -0
- package/src/coordinator-mcp/server.ts +1319 -0
- package/src/cursor.ts +372 -0
- package/src/dap/client.ts +689 -0
- package/src/dap/config.ts +150 -0
- package/src/dap/defaults.json +211 -0
- package/src/dap/index.ts +4 -0
- package/src/dap/session.ts +1306 -0
- package/src/dap/types.ts +600 -0
- package/src/debug/crash-diagnostics.ts +223 -0
- package/src/debug/index.ts +459 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +908 -0
- package/src/debug/profiler.ts +162 -0
- package/src/debug/raw-sse-buffer.ts +270 -0
- package/src/debug/raw-sse.ts +213 -0
- package/src/debug/report-bundle.ts +365 -0
- package/src/debug/runtime-gauges.ts +20 -0
- package/src/debug/system-info.ts +111 -0
- package/src/defaults/jwc/mcp-defaults.json +8 -0
- package/src/defaults/jwc/skill-fragments/browse/web-ai.md +130 -0
- package/src/defaults/jwc/skills/browse/SKILL.md +113 -0
- package/src/defaults/jwc/skills/goal/SKILL.md +323 -0
- package/src/defaults/jwc/skills/goal/ai-slop-cleaner.md +61 -0
- package/src/defaults/jwc/skills/jaw-interview/SKILL.md +891 -0
- package/src/defaults/jwc/skills/jaw-interview/auto-answer-uncertain.md +37 -0
- package/src/defaults/jwc/skills/jaw-interview/auto-research-greenfield.md +42 -0
- package/src/defaults/jwc/skills/plan/SKILL.md +201 -0
- package/src/defaults/jwc/skills/search/SKILL.md +120 -0
- package/src/defaults/jwc/skills/team/SKILL.md +441 -0
- package/src/defaults/jwc-defaults.ts +316 -0
- package/src/discovery/agents-md.ts +67 -0
- package/src/discovery/agents.ts +230 -0
- package/src/discovery/builtin.ts +932 -0
- package/src/discovery/claude-plugins.ts +407 -0
- package/src/discovery/claude.ts +313 -0
- package/src/discovery/cli-jaw.ts +36 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +330 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +383 -0
- package/src/discovery/github.ts +118 -0
- package/src/discovery/helpers.ts +1010 -0
- package/src/discovery/index.ts +77 -0
- package/src/discovery/mcp-json.ts +171 -0
- package/src/discovery/opencode.ts +398 -0
- package/src/discovery/plugin-dir-roots.ts +28 -0
- package/src/discovery/ssh.ts +153 -0
- package/src/discovery/substitute-plugin-root.ts +29 -0
- package/src/discovery/vscode.ts +105 -0
- package/src/discovery/windsurf.ts +147 -0
- package/src/edit/apply-patch/index.ts +87 -0
- package/src/edit/apply-patch/parser.ts +174 -0
- package/src/edit/diff.ts +873 -0
- package/src/edit/file-read-cache.ts +95 -0
- package/src/edit/index.ts +528 -0
- package/src/edit/modes/apply-patch.lark +19 -0
- package/src/edit/modes/apply-patch.ts +53 -0
- package/src/edit/modes/patch.ts +1835 -0
- package/src/edit/modes/replace.ts +1161 -0
- package/src/edit/normalize.ts +375 -0
- package/src/edit/notebook.ts +222 -0
- package/src/edit/read-file.ts +25 -0
- package/src/edit/renderer.ts +683 -0
- package/src/edit/streaming.ts +561 -0
- package/src/eval/backend.ts +43 -0
- package/src/eval/index.ts +4 -0
- package/src/eval/js/context-manager.ts +414 -0
- package/src/eval/js/executor.ts +134 -0
- package/src/eval/js/index.ts +46 -0
- package/src/eval/js/shared/helpers.ts +237 -0
- package/src/eval/js/shared/indirect-eval.ts +30 -0
- package/src/eval/js/shared/prelude.ts +2 -0
- package/src/eval/js/shared/prelude.txt +70 -0
- package/src/eval/js/shared/rewrite-imports.ts +415 -0
- package/src/eval/js/shared/runtime.ts +301 -0
- package/src/eval/js/shared/types.ts +18 -0
- package/src/eval/js/tool-bridge.ts +144 -0
- package/src/eval/js/worker-core.ts +146 -0
- package/src/eval/js/worker-entry.ts +24 -0
- package/src/eval/js/worker-protocol.ts +41 -0
- package/src/eval/py/display.ts +71 -0
- package/src/eval/py/executor.ts +622 -0
- package/src/eval/py/index.ts +58 -0
- package/src/eval/py/kernel.ts +683 -0
- package/src/eval/py/prelude.py +462 -0
- package/src/eval/py/prelude.ts +3 -0
- package/src/eval/py/runner.py +910 -0
- package/src/eval/py/runtime.ts +210 -0
- package/src/eval/py/tool-bridge.ts +137 -0
- package/src/eval/types.ts +48 -0
- package/src/exa/factory.ts +60 -0
- package/src/exa/index.ts +27 -0
- package/src/exa/mcp-client.ts +364 -0
- package/src/exa/render.ts +244 -0
- package/src/exa/researcher.ts +36 -0
- package/src/exa/search.ts +47 -0
- package/src/exa/types.ts +166 -0
- package/src/exa/websets.ts +248 -0
- package/src/exec/bash-executor.ts +362 -0
- package/src/exec/exec.ts +53 -0
- package/src/exec/idle-timeout-watchdog.ts +126 -0
- package/src/exec/non-interactive-env.ts +73 -0
- package/src/export/custom-share.ts +65 -0
- package/src/export/html/index.ts +168 -0
- package/src/export/html/template.css +1060 -0
- package/src/export/html/template.generated.ts +2 -0
- package/src/export/html/template.html +47 -0
- package/src/export/html/template.js +2268 -0
- package/src/export/html/template.macro.ts +25 -0
- package/src/export/html/vendor/highlight.min.js +1213 -0
- package/src/export/html/vendor/marked.min.js +6 -0
- package/src/export/ttsr.ts +444 -0
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +25 -0
- package/src/extensibility/custom-commands/bundled/review/index.ts +456 -0
- package/src/extensibility/custom-commands/index.ts +2 -0
- package/src/extensibility/custom-commands/loader.ts +238 -0
- package/src/extensibility/custom-commands/types.ts +113 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +245 -0
- package/src/extensibility/custom-tools/types.ts +255 -0
- package/src/extensibility/custom-tools/wrapper.ts +47 -0
- package/src/extensibility/extensions/compact-handler.ts +40 -0
- package/src/extensibility/extensions/get-commands-handler.ts +80 -0
- package/src/extensibility/extensions/index.ts +15 -0
- package/src/extensibility/extensions/loader.ts +555 -0
- package/src/extensibility/extensions/runner.ts +900 -0
- package/src/extensibility/extensions/types.ts +1314 -0
- package/src/extensibility/extensions/wrapper.ts +189 -0
- package/src/extensibility/hooks/index.ts +5 -0
- package/src/extensibility/hooks/loader.ts +257 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +107 -0
- package/src/extensibility/hooks/types.ts +599 -0
- package/src/extensibility/jwc-plugins/activation.ts +87 -0
- package/src/extensibility/jwc-plugins/index.ts +9 -0
- package/src/extensibility/jwc-plugins/injection.ts +114 -0
- package/src/extensibility/jwc-plugins/loader.ts +131 -0
- package/src/extensibility/jwc-plugins/paths.ts +66 -0
- package/src/extensibility/jwc-plugins/schema.ts +79 -0
- package/src/extensibility/jwc-plugins/state.ts +29 -0
- package/src/extensibility/jwc-plugins/tools.ts +47 -0
- package/src/extensibility/jwc-plugins/types.ts +97 -0
- package/src/extensibility/jwc-plugins/validation.ts +76 -0
- package/src/extensibility/plugins/doctor.ts +66 -0
- package/src/extensibility/plugins/git-url.ts +281 -0
- package/src/extensibility/plugins/index.ts +9 -0
- package/src/extensibility/plugins/installer.ts +192 -0
- package/src/extensibility/plugins/legacy-pi-compat.ts +336 -0
- package/src/extensibility/plugins/loader.ts +288 -0
- package/src/extensibility/plugins/manager.ts +739 -0
- package/src/extensibility/plugins/marketplace/cache.ts +136 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +317 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +770 -0
- package/src/extensibility/plugins/marketplace/registry.ts +196 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
- package/src/extensibility/plugins/marketplace/types.ts +191 -0
- package/src/extensibility/plugins/parser.ts +105 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/shared-events.ts +344 -0
- package/src/extensibility/skills.ts +449 -0
- package/src/extensibility/slash-commands.ts +249 -0
- package/src/extensibility/tool-proxy.ts +25 -0
- package/src/extensibility/typebox.ts +418 -0
- package/src/extensibility/utils.ts +44 -0
- package/src/goals/goal-planning-start.ts +21 -0
- package/src/goals/index.ts +3 -0
- package/src/goals/runtime.ts +418 -0
- package/src/goals/state.ts +70 -0
- package/src/goals/tools/goal-tool.ts +230 -0
- package/src/harness-control-plane/classifier.ts +128 -0
- package/src/harness-control-plane/control-endpoint.ts +148 -0
- package/src/harness-control-plane/finalize.ts +306 -0
- package/src/harness-control-plane/operate.ts +225 -0
- package/src/harness-control-plane/owner.ts +664 -0
- package/src/harness-control-plane/phase-rollup.ts +96 -0
- package/src/harness-control-plane/preserve.ts +102 -0
- package/src/harness-control-plane/receipt-ingest.ts +127 -0
- package/src/harness-control-plane/receipt-spool.ts +147 -0
- package/src/harness-control-plane/receipts.ts +320 -0
- package/src/harness-control-plane/rpc-adapter.ts +282 -0
- package/src/harness-control-plane/seams.ts +39 -0
- package/src/harness-control-plane/session-lease.ts +388 -0
- package/src/harness-control-plane/state-machine.ts +119 -0
- package/src/harness-control-plane/storage.ts +423 -0
- package/src/harness-control-plane/types.ts +240 -0
- package/src/hashline/anchors.ts +113 -0
- package/src/hashline/apply.ts +737 -0
- package/src/hashline/bigrams.json +649 -0
- package/src/hashline/constants.ts +25 -0
- package/src/hashline/diff-preview.ts +43 -0
- package/src/hashline/diff.ts +56 -0
- package/src/hashline/execute.ts +267 -0
- package/src/hashline/grammar.lark +21 -0
- package/src/hashline/hash.ts +196 -0
- package/src/hashline/index.ts +13 -0
- package/src/hashline/input.ts +130 -0
- package/src/hashline/parser.ts +246 -0
- package/src/hashline/prefixes.ts +101 -0
- package/src/hashline/recovery.ts +113 -0
- package/src/hashline/stream.ts +123 -0
- package/src/hashline/types.ts +68 -0
- package/src/hindsight/backend.ts +205 -0
- package/src/hindsight/bank.ts +131 -0
- package/src/hindsight/client.ts +598 -0
- package/src/hindsight/config.ts +175 -0
- package/src/hindsight/content.ts +211 -0
- package/src/hindsight/index.ts +8 -0
- package/src/hindsight/mental-models.ts +382 -0
- package/src/hindsight/seeds.json +32 -0
- package/src/hindsight/state.ts +469 -0
- package/src/hindsight/transcript.ts +71 -0
- package/src/hooks/codex-native-hooks-config.ts +143 -0
- package/src/hooks/native-skill-hook.ts +305 -0
- package/src/hooks/skill-keywords.ts +95 -0
- package/src/hooks/skill-state.ts +654 -0
- package/src/index.ts +56 -0
- package/src/internal-urls/agent-protocol.ts +176 -0
- package/src/internal-urls/artifact-protocol.ts +75 -0
- package/src/internal-urls/docs-index.generated.ts +92 -0
- package/src/internal-urls/index.ts +21 -0
- package/src/internal-urls/issue-pr-protocol.ts +577 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/jwc-protocol.ts +91 -0
- package/src/internal-urls/local-protocol.ts +249 -0
- package/src/internal-urls/mcp-protocol.ts +151 -0
- package/src/internal-urls/memory-protocol.ts +165 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/registry-helpers.ts +28 -0
- package/src/internal-urls/router.ts +79 -0
- package/src/internal-urls/rule-protocol.ts +38 -0
- package/src/internal-urls/skill-protocol.ts +103 -0
- package/src/internal-urls/types.ts +114 -0
- package/src/jaw-interview/structured-renderer.ts +83 -0
- package/src/jwc-runtime/actor-registry.ts +365 -0
- package/src/jwc-runtime/agent-identity.ts +16 -0
- package/src/jwc-runtime/cli-jaw-home.ts +14 -0
- package/src/jwc-runtime/cli-jaw-vocab.ts +69 -0
- package/src/jwc-runtime/cli-write-receipt.ts +31 -0
- package/src/jwc-runtime/goal-cli.ts +428 -0
- package/src/jwc-runtime/goal-engine.ts +2214 -0
- package/src/jwc-runtime/goal-guard.ts +300 -0
- package/src/jwc-runtime/goal-mode-request.ts +331 -0
- package/src/jwc-runtime/jaw-interview-runtime.ts +809 -0
- package/src/jwc-runtime/launch-tmux.ts +296 -0
- package/src/jwc-runtime/launch-worktree.ts +291 -0
- package/src/jwc-runtime/legacy-storage.ts +132 -0
- package/src/jwc-runtime/memory-runtime.ts +434 -0
- package/src/jwc-runtime/orchestrate-runtime.ts +612 -0
- package/src/jwc-runtime/orchestrate-state.ts +395 -0
- package/src/jwc-runtime/plan-writer.ts +661 -0
- package/src/jwc-runtime/restricted-role-agent-bash.ts +5 -0
- package/src/jwc-runtime/session-state-sidecar.ts +89 -0
- package/src/jwc-runtime/stage-skill-map.ts +48 -0
- package/src/jwc-runtime/state-graph.ts +86 -0
- package/src/jwc-runtime/state-migrations.ts +183 -0
- package/src/jwc-runtime/state-renderer.ts +340 -0
- package/src/jwc-runtime/state-runtime.ts +1978 -0
- package/src/jwc-runtime/state-schema.ts +218 -0
- package/src/jwc-runtime/state-validation.ts +50 -0
- package/src/jwc-runtime/state-writer.ts +765 -0
- package/src/jwc-runtime/team-runtime.ts +4181 -0
- package/src/jwc-runtime/tmux-common.ts +130 -0
- package/src/jwc-runtime/tmux-sessions.ts +169 -0
- package/src/jwc-runtime/workflow-command-ref.ts +240 -0
- package/src/jwc-runtime/workflow-manifest.generated.json +1606 -0
- package/src/jwc-runtime/workflow-manifest.ts +427 -0
- package/src/lsp/client.ts +974 -0
- package/src/lsp/clients/biome-client.ts +202 -0
- package/src/lsp/clients/index.ts +50 -0
- package/src/lsp/clients/lsp-linter-client.ts +93 -0
- package/src/lsp/clients/swiftlint-client.ts +120 -0
- package/src/lsp/config.ts +492 -0
- package/src/lsp/defaults.json +493 -0
- package/src/lsp/edits.ts +166 -0
- package/src/lsp/index.ts +2282 -0
- package/src/lsp/lspmux.ts +233 -0
- package/src/lsp/render.ts +692 -0
- package/src/lsp/startup-events.ts +13 -0
- package/src/lsp/types.ts +443 -0
- package/src/lsp/utils.ts +678 -0
- package/src/main.ts +1159 -0
- package/src/mem0/backend.ts +75 -0
- package/src/mem0/client.ts +122 -0
- package/src/mem0/config.ts +82 -0
- package/src/mem0/index.ts +5 -0
- package/src/mem0/scope.ts +54 -0
- package/src/mem0/state.ts +142 -0
- package/src/memories/index.ts +1111 -0
- package/src/memories/local-query.ts +699 -0
- package/src/memories/memory-config.ts +175 -0
- package/src/memories/memory-fts.ts +179 -0
- package/src/memories/memory-model-resolution.ts +84 -0
- package/src/memories/memory-quality.ts +163 -0
- package/src/memories/storage.ts +588 -0
- package/src/memory-backend/index.ts +4 -0
- package/src/memory-backend/local-backend.ts +50 -0
- package/src/memory-backend/off-backend.ts +16 -0
- package/src/memory-backend/resolve.ts +27 -0
- package/src/memory-backend/types.ts +82 -0
- package/src/migrate-config-dir-startup.ts +15 -0
- package/src/migrate-config-dir.ts +80 -0
- package/src/modes/acp/acp-agent.ts +2218 -0
- package/src/modes/acp/acp-client-bridge.ts +154 -0
- package/src/modes/acp/acp-event-mapper.ts +912 -0
- package/src/modes/acp/acp-mode.ts +23 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/acp/terminal-auth.ts +37 -0
- package/src/modes/background-row-model.ts +17 -0
- package/src/modes/bridge/auth.ts +41 -0
- package/src/modes/bridge/bridge-client-bridge.ts +47 -0
- package/src/modes/bridge/bridge-mode.ts +644 -0
- package/src/modes/bridge/bridge-ui-context.ts +200 -0
- package/src/modes/bridge/event-stream.ts +70 -0
- package/src/modes/components/_cli-jaw-entry.ts +36 -0
- package/src/modes/components/agent-dashboard.ts +1120 -0
- package/src/modes/components/assistant-message.ts +361 -0
- package/src/modes/components/background-footer-detail.ts +27 -0
- package/src/modes/components/background-footer-panel-model.ts +96 -0
- package/src/modes/components/background-footer-panel.ts +89 -0
- package/src/modes/components/bash-execution.ts +261 -0
- package/src/modes/components/bordered-loader.ts +41 -0
- package/src/modes/components/branch-summary-message.ts +65 -0
- package/src/modes/components/btw-panel.ts +104 -0
- package/src/modes/components/compaction-summary-message.ts +71 -0
- package/src/modes/components/composer-chrome.ts +42 -0
- package/src/modes/components/composer-footer.ts +113 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.ts +515 -0
- package/src/modes/components/custom-message.ts +85 -0
- package/src/modes/components/custom-provider-wizard.ts +318 -0
- package/src/modes/components/diff.ts +363 -0
- package/src/modes/components/dynamic-border.ts +25 -0
- package/src/modes/components/eval-execution.ts +196 -0
- package/src/modes/components/execution-shared.ts +112 -0
- package/src/modes/components/extensions/extension-dashboard.ts +350 -0
- package/src/modes/components/extensions/extension-list.ts +492 -0
- package/src/modes/components/extensions/index.ts +9 -0
- package/src/modes/components/extensions/inspector-panel.ts +317 -0
- package/src/modes/components/extensions/state-manager.ts +628 -0
- package/src/modes/components/extensions/types.ts +191 -0
- package/src/modes/components/footer.ts +270 -0
- package/src/modes/components/full-transcript-overlay.ts +133 -0
- package/src/modes/components/help-selector.ts +274 -0
- package/src/modes/components/history-search.ts +158 -0
- package/src/modes/components/hook-editor.ts +151 -0
- package/src/modes/components/hook-input.ts +79 -0
- package/src/modes/components/hook-message.ts +68 -0
- package/src/modes/components/hook-selector.ts +873 -0
- package/src/modes/components/index.ts +36 -0
- package/src/modes/components/jobs-overlay-model.ts +109 -0
- package/src/modes/components/jobs-overlay.ts +172 -0
- package/src/modes/components/keybinding-hints.ts +65 -0
- package/src/modes/components/login-dialog.ts +164 -0
- package/src/modes/components/message-frame.ts +88 -0
- package/src/modes/components/model-selector.ts +1653 -0
- package/src/modes/components/oauth-selector.ts +248 -0
- package/src/modes/components/pabcd-border.ts +98 -0
- package/src/modes/components/plugin-selector.ts +95 -0
- package/src/modes/components/plugin-settings.ts +489 -0
- package/src/modes/components/provider-onboarding-selector.ts +94 -0
- package/src/modes/components/queue-mode-selector.ts +56 -0
- package/src/modes/components/quota-panel.ts +101 -0
- package/src/modes/components/read-tool-group.ts +295 -0
- package/src/modes/components/runtime-mcp-add-wizard.ts +1341 -0
- package/src/modes/components/session-observer-overlay.ts +839 -0
- package/src/modes/components/session-selector.ts +343 -0
- package/src/modes/components/settings-defs.ts +175 -0
- package/src/modes/components/settings-selector.ts +644 -0
- package/src/modes/components/show-images-selector.ts +45 -0
- package/src/modes/components/skill-hud/render.ts +93 -0
- package/src/modes/components/skill-message.ts +110 -0
- package/src/modes/components/status-line/context-thresholds.ts +68 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/index.ts +4 -0
- package/src/modes/components/status-line/presets.ts +107 -0
- package/src/modes/components/status-line/segments.ts +657 -0
- package/src/modes/components/status-line/separators.ts +55 -0
- package/src/modes/components/status-line/token-rate.ts +66 -0
- package/src/modes/components/status-line/types.ts +102 -0
- package/src/modes/components/status-line/workflow-readers.ts +97 -0
- package/src/modes/components/status-line.ts +917 -0
- package/src/modes/components/theme-selector.ts +63 -0
- package/src/modes/components/thinking-selector.ts +52 -0
- package/src/modes/components/todo-reminder.ts +40 -0
- package/src/modes/components/tool-execution.ts +990 -0
- package/src/modes/components/tool-transcript-overlay.ts +81 -0
- package/src/modes/components/tree-selector.ts +930 -0
- package/src/modes/components/ttsr-notification.ts +100 -0
- package/src/modes/components/user-message-selector.ts +141 -0
- package/src/modes/components/user-message.ts +53 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome.ts +522 -0
- package/src/modes/controllers/btw-controller.ts +105 -0
- package/src/modes/controllers/command-controller-shared.ts +108 -0
- package/src/modes/controllers/command-controller.ts +1703 -0
- package/src/modes/controllers/event-controller.ts +1054 -0
- package/src/modes/controllers/extension-ui-controller.ts +1010 -0
- package/src/modes/controllers/input-controller.ts +1422 -0
- package/src/modes/controllers/runtime-mcp-command-controller.ts +1934 -0
- package/src/modes/controllers/selector-controller.ts +1605 -0
- package/src/modes/controllers/ssh-command-controller.ts +384 -0
- package/src/modes/controllers/todo-command-controller.ts +485 -0
- package/src/modes/data/emojis.json +1 -0
- package/src/modes/emoji-autocomplete.ts +285 -0
- package/src/modes/index.ts +35 -0
- package/src/modes/interactive-mode.ts +2938 -0
- package/src/modes/jobs-observer.ts +352 -0
- package/src/modes/oauth-manual-input.ts +42 -0
- package/src/modes/print-mode.ts +121 -0
- package/src/modes/prompt-action-autocomplete.ts +409 -0
- package/src/modes/rpc/host-tools.ts +1 -0
- package/src/modes/rpc/host-uris.ts +1 -0
- package/src/modes/rpc/rpc-client.ts +914 -0
- package/src/modes/rpc/rpc-mode.ts +784 -0
- package/src/modes/rpc/rpc-types.ts +601 -0
- package/src/modes/runtime-init.ts +116 -0
- package/src/modes/session-observer-registry.ts +146 -0
- package/src/modes/shared/agent-wire/approval-gate.ts +151 -0
- package/src/modes/shared/agent-wire/command-contract.ts +18 -0
- package/src/modes/shared/agent-wire/command-dispatch.ts +438 -0
- package/src/modes/shared/agent-wire/command-validation.ts +164 -0
- package/src/modes/shared/agent-wire/event-contract.ts +148 -0
- package/src/modes/shared/agent-wire/event-envelope.ts +141 -0
- package/src/modes/shared/agent-wire/event-observation.ts +424 -0
- package/src/modes/shared/agent-wire/handshake.ts +157 -0
- package/src/modes/shared/agent-wire/host-tool-bridge.ts +194 -0
- package/src/modes/shared/agent-wire/host-uri-bridge.ts +236 -0
- package/src/modes/shared/agent-wire/jaw-interview-gate.ts +253 -0
- package/src/modes/shared/agent-wire/protocol.ts +46 -0
- package/src/modes/shared/agent-wire/responses.ts +17 -0
- package/src/modes/shared/agent-wire/scopes.ts +91 -0
- package/src/modes/shared/agent-wire/session-registry.ts +109 -0
- package/src/modes/shared/agent-wire/ui-request-broker.ts +150 -0
- package/src/modes/shared/agent-wire/ui-result.ts +48 -0
- package/src/modes/shared/agent-wire/unattended-action-policy.ts +341 -0
- package/src/modes/shared/agent-wire/unattended-audit.ts +175 -0
- package/src/modes/shared/agent-wire/unattended-run-controller.ts +406 -0
- package/src/modes/shared/agent-wire/unattended-session.ts +180 -0
- package/src/modes/shared/agent-wire/workflow-gate-broker.ts +324 -0
- package/src/modes/shared/agent-wire/workflow-gate-schema.ts +331 -0
- package/src/modes/shared.ts +55 -0
- package/src/modes/theme/defaults/abyss-bite-light.json +124 -0
- package/src/modes/theme/defaults/abyss-bite.json +124 -0
- package/src/modes/theme/defaults/blue-crab.json +126 -0
- package/src/modes/theme/defaults/index.ts +11 -0
- package/src/modes/theme/defaults/red-claw.json +123 -0
- package/src/modes/theme/mermaid-cache.ts +29 -0
- package/src/modes/theme/shimmer.ts +219 -0
- package/src/modes/theme/theme-schema.json +429 -0
- package/src/modes/theme/theme.ts +2472 -0
- package/src/modes/types.ts +343 -0
- package/src/modes/utils/abort-message.ts +41 -0
- package/src/modes/utils/compaction-progress.ts +174 -0
- package/src/modes/utils/context-usage.ts +398 -0
- package/src/modes/utils/help-markdown.ts +50 -0
- package/src/modes/utils/hotkeys-markdown.ts +61 -0
- package/src/modes/utils/keybinding-matchers.ts +30 -0
- package/src/modes/utils/session-transcript-replay.ts +520 -0
- package/src/modes/utils/tools-markdown.ts +27 -0
- package/src/modes/utils/ui-helpers.ts +846 -0
- package/src/notifications/ask-bridge.ts +74 -0
- package/src/notifications/config-command-parser.ts +76 -0
- package/src/notifications/config.ts +102 -0
- package/src/notifications/daemon-control.ts +73 -0
- package/src/notifications/daemon-engine.ts +165 -0
- package/src/notifications/daemon-inbound.ts +220 -0
- package/src/notifications/daemon-loop.ts +60 -0
- package/src/notifications/daemon-owner.ts +53 -0
- package/src/notifications/daemon-runtime.ts +84 -0
- package/src/notifications/discovery.ts +119 -0
- package/src/notifications/index.ts +34 -0
- package/src/notifications/lifecycle-audit.ts +94 -0
- package/src/notifications/lifecycle-command-parser.ts +51 -0
- package/src/notifications/lifecycle-control-runtime.ts +127 -0
- package/src/notifications/notification-redaction.ts +57 -0
- package/src/notifications/protocol.ts +61 -0
- package/src/notifications/remote-answer.ts +241 -0
- package/src/notifications/reply-bridge.ts +85 -0
- package/src/notifications/server.ts +280 -0
- package/src/notifications/session-lifecycle.ts +46 -0
- package/src/notifications/session-registry.ts +164 -0
- package/src/notifications/telegram-api.ts +259 -0
- package/src/notifications/telegram-ask-keyboard.ts +137 -0
- package/src/notifications/telegram-callback-ingest.ts +126 -0
- package/src/notifications/telegram-inbound-router.ts +166 -0
- package/src/notifications/telegram-media-policy.ts +50 -0
- package/src/notifications/telegram-media-render.ts +40 -0
- package/src/notifications/telegram-message-ingest.ts +121 -0
- package/src/notifications/telegram-pairing.ts +69 -0
- package/src/notifications/threaded-lifecycle.ts +27 -0
- package/src/notifications/threaded-shutdown.ts +37 -0
- package/src/notifications/threaded-surface.ts +187 -0
- package/src/notifications/transport-shell.ts +152 -0
- package/src/notifications/transport-state.ts +161 -0
- package/src/notifications/workspace-path-confinement.ts +65 -0
- package/src/plan-mode/approved-plan.ts +163 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/prompts/agents/architect.md +95 -0
- package/src/prompts/agents/critic.md +68 -0
- package/src/prompts/agents/executor.md +64 -0
- package/src/prompts/agents/explore.md +58 -0
- package/src/prompts/agents/frontmatter.md +14 -0
- package/src/prompts/agents/init.md +34 -0
- package/src/prompts/agents/plan.md +49 -0
- package/src/prompts/agents/planner.md +63 -0
- package/src/prompts/agents/reviewer.md +141 -0
- package/src/prompts/agents/task.md +16 -0
- package/src/prompts/ci-green-request.md +36 -0
- package/src/prompts/goals/goal-continuation.md +33 -0
- package/src/prompts/goals/goal-mode-active.md +23 -0
- package/src/prompts/jaw/orchestrate-a.md +20 -0
- package/src/prompts/jaw/orchestrate-audit-architect.md +17 -0
- package/src/prompts/jaw/orchestrate-audit-planner.md +17 -0
- package/src/prompts/jaw/orchestrate-b.md +17 -0
- package/src/prompts/jaw/orchestrate-c.md +18 -0
- package/src/prompts/jaw/orchestrate-d.md +32 -0
- package/src/prompts/jaw/orchestrate-i.md +17 -0
- package/src/prompts/jaw/orchestrate-p.md +23 -0
- package/src/prompts/memories/consolidation.md +30 -0
- package/src/prompts/memories/read-path.md +10 -0
- package/src/prompts/memories/stage_one_input.md +6 -0
- package/src/prompts/memories/stage_one_system.md +21 -0
- package/src/prompts/memories/unavailable.md +9 -0
- package/src/prompts/review-request.md +70 -0
- package/src/prompts/system/agent-creation-architect.md +75 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-continue.md +1 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/commit-message-system.md +2 -0
- package/src/prompts/system/custom-system-prompt.md +64 -0
- package/src/prompts/system/eager-todo.md +13 -0
- package/src/prompts/system/executor-self-fork.md +3 -0
- package/src/prompts/system/irc-incoming.md +8 -0
- package/src/prompts/system/plan-mode-active.md +116 -0
- package/src/prompts/system/plan-mode-approved.md +28 -0
- package/src/prompts/system/plan-mode-compact-instructions.md +16 -0
- package/src/prompts/system/plan-mode-reference.md +14 -0
- package/src/prompts/system/plan-mode-subagent.md +34 -0
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
- package/src/prompts/system/project-prompt.md +46 -0
- package/src/prompts/system/subagent-system-prompt.md +89 -0
- package/src/prompts/system/subagent-user-prompt.md +3 -0
- package/src/prompts/system/subagent-yield-reminder.md +12 -0
- package/src/prompts/system/system-prompt.md +409 -0
- package/src/prompts/system/title-system.md +2 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/ttsr-tool-reminder.md +5 -0
- package/src/prompts/system/web-search.md +25 -0
- package/src/prompts/tools/apply-patch.md +65 -0
- package/src/prompts/tools/ask.md +29 -0
- package/src/prompts/tools/ast-edit.md +39 -0
- package/src/prompts/tools/ast-grep.md +42 -0
- package/src/prompts/tools/async-result.md +8 -0
- package/src/prompts/tools/background.md +19 -0
- package/src/prompts/tools/bash.md +50 -0
- package/src/prompts/tools/browser.md +14 -0
- package/src/prompts/tools/calculator.md +10 -0
- package/src/prompts/tools/checkpoint.md +16 -0
- package/src/prompts/tools/computer-use.md +15 -0
- package/src/prompts/tools/cron.md +25 -0
- package/src/prompts/tools/debug.md +33 -0
- package/src/prompts/tools/eval.md +75 -0
- package/src/prompts/tools/find.md +34 -0
- package/src/prompts/tools/github.md +20 -0
- package/src/prompts/tools/goal.md +20 -0
- package/src/prompts/tools/hashline.md +130 -0
- package/src/prompts/tools/image-gen.md +7 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +32 -0
- package/src/prompts/tools/irc.md +49 -0
- package/src/prompts/tools/job.md +22 -0
- package/src/prompts/tools/lsp.md +42 -0
- package/src/prompts/tools/monitor.md +32 -0
- package/src/prompts/tools/patch.md +70 -0
- package/src/prompts/tools/read.md +82 -0
- package/src/prompts/tools/recall.md +6 -0
- package/src/prompts/tools/recipe.md +16 -0
- package/src/prompts/tools/reflect.md +6 -0
- package/src/prompts/tools/render-mermaid.md +9 -0
- package/src/prompts/tools/replace.md +36 -0
- package/src/prompts/tools/resolve.md +9 -0
- package/src/prompts/tools/retain.md +7 -0
- package/src/prompts/tools/rewind.md +13 -0
- package/src/prompts/tools/search-tool-bm25.md +37 -0
- package/src/prompts/tools/search.md +25 -0
- package/src/prompts/tools/skill.md +28 -0
- package/src/prompts/tools/ssh.md +35 -0
- package/src/prompts/tools/subagent.md +56 -0
- package/src/prompts/tools/task-summary.md +22 -0
- package/src/prompts/tools/task.md +106 -0
- package/src/prompts/tools/todo-write.md +50 -0
- package/src/prompts/tools/vim.md +98 -0
- package/src/prompts/tools/web-search.md +10 -0
- package/src/prompts/tools/write.md +14 -0
- package/src/registry/agent-registry.ts +140 -0
- package/src/reminders/star-reminder.ts +422 -0
- package/src/runtime-mcp/client.ts +485 -0
- package/src/runtime-mcp/config-writer.ts +225 -0
- package/src/runtime-mcp/config.ts +365 -0
- package/src/runtime-mcp/discoverable-tool-metadata.ts +25 -0
- package/src/runtime-mcp/index.ts +29 -0
- package/src/runtime-mcp/json-rpc.ts +84 -0
- package/src/runtime-mcp/loader.ts +124 -0
- package/src/runtime-mcp/manager.ts +1211 -0
- package/src/runtime-mcp/oauth-discovery.ts +349 -0
- package/src/runtime-mcp/oauth-flow.ts +409 -0
- package/src/runtime-mcp/render.ts +123 -0
- package/src/runtime-mcp/smithery-auth.ts +104 -0
- package/src/runtime-mcp/smithery-connect.ts +145 -0
- package/src/runtime-mcp/smithery-registry.ts +477 -0
- package/src/runtime-mcp/tool-bridge.ts +416 -0
- package/src/runtime-mcp/tool-cache.ts +117 -0
- package/src/runtime-mcp/transports/http.ts +503 -0
- package/src/runtime-mcp/transports/index.ts +6 -0
- package/src/runtime-mcp/transports/stdio.ts +326 -0
- package/src/runtime-mcp/types.ts +423 -0
- package/src/sdk.ts +2248 -0
- package/src/secrets/index.ts +120 -0
- package/src/secrets/obfuscator.ts +352 -0
- package/src/secrets/regex.ts +21 -0
- package/src/session/agent-session.ts +10343 -0
- package/src/session/agent-storage.ts +466 -0
- package/src/session/artifacts.ts +135 -0
- package/src/session/auth-broker-config.ts +102 -0
- package/src/session/auth-storage.ts +23 -0
- package/src/session/blob-store.ts +372 -0
- package/src/session/client-bridge.ts +85 -0
- package/src/session/contribution-prep.ts +320 -0
- package/src/session/history-storage.ts +311 -0
- package/src/session/messages.ts +406 -0
- package/src/session/pabcd-stage-header.ts +77 -0
- package/src/session/session-dump-format.ts +209 -0
- package/src/session/session-manager.ts +3914 -0
- package/src/session/session-storage.ts +415 -0
- package/src/session/streaming-output.ts +1114 -0
- package/src/session/tool-choice-queue.ts +213 -0
- package/src/session/yield-queue.ts +155 -0
- package/src/setup/hermes/templates/operator-instructions.v1.md +29 -0
- package/src/setup/hermes-setup.ts +429 -0
- package/src/setup/model-onboarding-guidance.ts +41 -0
- package/src/setup/provider-onboarding.ts +358 -0
- package/src/skill-state/active-state.ts +788 -0
- package/src/skill-state/initial-phase.ts +21 -0
- package/src/skill-state/jaw-interview-mutation-guard.ts +490 -0
- package/src/skill-state/workflow-hud.ts +208 -0
- package/src/skill-state/workflow-state-contract.ts +167 -0
- package/src/skill-state/workflow-state-version.ts +3 -0
- package/src/slash-commands/acp-builtins.ts +55 -0
- package/src/slash-commands/builtin-registry.ts +1879 -0
- package/src/slash-commands/helpers/context-report.ts +149 -0
- package/src/slash-commands/helpers/format.ts +46 -0
- package/src/slash-commands/helpers/mcp.ts +532 -0
- package/src/slash-commands/helpers/parse.ts +85 -0
- package/src/slash-commands/helpers/ssh.ts +195 -0
- package/src/slash-commands/helpers/todo.ts +279 -0
- package/src/slash-commands/helpers/usage-report.ts +105 -0
- package/src/slash-commands/types.ts +127 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +482 -0
- package/src/ssh/ssh-executor.ts +133 -0
- package/src/ssh/sshfs-mount.ts +140 -0
- package/src/ssh/utils.ts +8 -0
- package/src/stt/downloader.ts +71 -0
- package/src/stt/index.ts +3 -0
- package/src/stt/recorder.ts +351 -0
- package/src/stt/setup.ts +52 -0
- package/src/stt/stt-controller.ts +160 -0
- package/src/stt/transcribe.py +70 -0
- package/src/stt/transcriber.ts +91 -0
- package/src/system-prompt.ts +661 -0
- package/src/task/agents.ts +189 -0
- package/src/task/commands.ts +131 -0
- package/src/task/discovery.ts +136 -0
- package/src/task/executor.ts +1664 -0
- package/src/task/fork-context-advisory.ts +99 -0
- package/src/task/id.ts +33 -0
- package/src/task/index.ts +2173 -0
- package/src/task/jwc-command.ts +26 -0
- package/src/task/model-presets.ts +53 -0
- package/src/task/name-generator.ts +1577 -0
- package/src/task/output-manager.ts +108 -0
- package/src/task/parallel.ts +116 -0
- package/src/task/receipt.ts +304 -0
- package/src/task/render.ts +1075 -0
- package/src/task/roi-reconciliation.ts +90 -0
- package/src/task/simple-mode.ts +27 -0
- package/src/task/spawn-gate.ts +132 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/types.ts +433 -0
- package/src/task/worktree.ts +506 -0
- package/src/thinking.ts +93 -0
- package/src/tool-discovery/tool-index.ts +408 -0
- package/src/tools/archive-reader.ts +321 -0
- package/src/tools/ask.ts +1011 -0
- package/src/tools/ast-edit.ts +555 -0
- package/src/tools/ast-grep.ts +424 -0
- package/src/tools/auto-generated-guard.ts +305 -0
- package/src/tools/background.ts +500 -0
- package/src/tools/bash-allowed-prefixes.ts +169 -0
- package/src/tools/bash-command-fixup.ts +37 -0
- package/src/tools/bash-interactive.ts +388 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-pty-selection.ts +15 -0
- package/src/tools/bash-skill-urls.ts +248 -0
- package/src/tools/bash.ts +1242 -0
- package/src/tools/browser/actions.ts +189 -0
- package/src/tools/browser/attach.ts +175 -0
- package/src/tools/browser/launch.ts +651 -0
- package/src/tools/browser/readable.ts +95 -0
- package/src/tools/browser/registry.ts +194 -0
- package/src/tools/browser/render.ts +212 -0
- package/src/tools/browser/tab-protocol.ts +105 -0
- package/src/tools/browser/tab-supervisor.ts +577 -0
- package/src/tools/browser/tab-worker-entry.ts +21 -0
- package/src/tools/browser/tab-worker.ts +1054 -0
- package/src/tools/browser.ts +380 -0
- package/src/tools/calculator.ts +540 -0
- package/src/tools/checkpoint.ts +134 -0
- package/src/tools/computer-use-backend.ts +75 -0
- package/src/tools/computer-use.ts +228 -0
- package/src/tools/conflict-detect.ts +672 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/cron.ts +713 -0
- package/src/tools/debug.ts +1014 -0
- package/src/tools/eval.ts +1101 -0
- package/src/tools/fetch.ts +1485 -0
- package/src/tools/file-recorder.ts +35 -0
- package/src/tools/find.ts +543 -0
- package/src/tools/fs-cache-invalidation.ts +28 -0
- package/src/tools/gh-format.ts +12 -0
- package/src/tools/gh-renderer.ts +428 -0
- package/src/tools/gh.ts +3737 -0
- package/src/tools/github-cache.ts +548 -0
- package/src/tools/grouped-file-output.ts +96 -0
- package/src/tools/hindsight-recall.ts +66 -0
- package/src/tools/hindsight-reflect.ts +55 -0
- package/src/tools/hindsight-retain.ts +54 -0
- package/src/tools/image-gen.ts +1284 -0
- package/src/tools/index.ts +580 -0
- package/src/tools/inspect-image-renderer.ts +103 -0
- package/src/tools/inspect-image.ts +167 -0
- package/src/tools/irc.ts +239 -0
- package/src/tools/job.ts +530 -0
- package/src/tools/json-tree.ts +243 -0
- package/src/tools/jtd-to-json-schema.ts +219 -0
- package/src/tools/jtd-to-typescript.ts +136 -0
- package/src/tools/jtd-utils.ts +102 -0
- package/src/tools/list-limit.ts +40 -0
- package/src/tools/match-line-format.ts +22 -0
- package/src/tools/monitor.ts +255 -0
- package/src/tools/output-meta.ts +754 -0
- package/src/tools/path-utils.ts +741 -0
- package/src/tools/plan-mode-guard.ts +68 -0
- package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
- package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
- package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
- package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
- package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
- package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
- package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
- package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
- package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
- package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
- package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
- package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
- package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
- package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
- package/src/tools/read.ts +2333 -0
- package/src/tools/recipe/index.ts +80 -0
- package/src/tools/recipe/render.ts +19 -0
- package/src/tools/recipe/runner.ts +219 -0
- package/src/tools/recipe/runners/cargo.ts +131 -0
- package/src/tools/recipe/runners/index.ts +8 -0
- package/src/tools/recipe/runners/just.ts +73 -0
- package/src/tools/recipe/runners/make.ts +101 -0
- package/src/tools/recipe/runners/pkg.ts +167 -0
- package/src/tools/recipe/runners/task.ts +72 -0
- package/src/tools/render-mermaid.ts +68 -0
- package/src/tools/render-utils.ts +774 -0
- package/src/tools/renderers.ts +79 -0
- package/src/tools/resolve.ts +258 -0
- package/src/tools/review.ts +252 -0
- package/src/tools/search-tool-bm25.ts +364 -0
- package/src/tools/search.ts +787 -0
- package/src/tools/skill.ts +170 -0
- package/src/tools/sqlite-reader.ts +736 -0
- package/src/tools/ssh.ts +310 -0
- package/src/tools/subagent-render.ts +160 -0
- package/src/tools/subagent.ts +698 -0
- package/src/tools/telegram-send.ts +178 -0
- package/src/tools/todo-write.ts +695 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +86 -0
- package/src/tools/tool-timeouts.ts +30 -0
- package/src/tools/vim.ts +949 -0
- package/src/tools/write.ts +953 -0
- package/src/tools/yield.ts +268 -0
- package/src/tui/code-cell.ts +201 -0
- package/src/tui/file-list.ts +55 -0
- package/src/tui/hyperlink.ts +126 -0
- package/src/tui/index.ts +12 -0
- package/src/tui/output-block.ts +150 -0
- package/src/tui/status-line.ts +39 -0
- package/src/tui/tree-list.ts +84 -0
- package/src/tui/types.ts +15 -0
- package/src/tui/utils.ts +103 -0
- package/src/utils/changelog.ts +121 -0
- package/src/utils/clipboard.ts +156 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +135 -0
- package/src/utils/edit-mode.ts +42 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +65 -0
- package/src/utils/file-display-mode.ts +45 -0
- package/src/utils/file-mentions.ts +376 -0
- package/src/utils/git.ts +1536 -0
- package/src/utils/image-loading.ts +102 -0
- package/src/utils/image-resize.ts +309 -0
- package/src/utils/lang-from-path.ts +239 -0
- package/src/utils/markit.ts +89 -0
- package/src/utils/open.ts +20 -0
- package/src/utils/session-color.ts +43 -0
- package/src/utils/shell-snapshot.ts +187 -0
- package/src/utils/sixel.ts +69 -0
- package/src/utils/title-generator.ts +237 -0
- package/src/utils/tokenizer-download.ts +106 -0
- package/src/utils/tokenizer-encoding.ts +29 -0
- package/src/utils/tool-choice.ts +62 -0
- package/src/utils/tools-manager.ts +363 -0
- package/src/vim/buffer.ts +309 -0
- package/src/vim/commands.ts +382 -0
- package/src/vim/engine.ts +2409 -0
- package/src/vim/parser.ts +134 -0
- package/src/vim/render.ts +252 -0
- package/src/vim/types.ts +197 -0
- package/src/web/kagi.ts +183 -0
- package/src/web/parallel.ts +349 -0
- package/src/web/public-fetch-url.ts +74 -0
- package/src/web/scrapers/artifacthub.ts +207 -0
- package/src/web/scrapers/arxiv.ts +83 -0
- package/src/web/scrapers/aur.ts +162 -0
- package/src/web/scrapers/biorxiv.ts +133 -0
- package/src/web/scrapers/bluesky.ts +262 -0
- package/src/web/scrapers/brew.ts +172 -0
- package/src/web/scrapers/cheatsh.ts +68 -0
- package/src/web/scrapers/chocolatey.ts +196 -0
- package/src/web/scrapers/choosealicense.ts +95 -0
- package/src/web/scrapers/cisa-kev.ts +87 -0
- package/src/web/scrapers/clojars.ts +154 -0
- package/src/web/scrapers/coingecko.ts +177 -0
- package/src/web/scrapers/crates-io.ts +97 -0
- package/src/web/scrapers/crossref.ts +136 -0
- package/src/web/scrapers/devto.ts +147 -0
- package/src/web/scrapers/discogs.ts +306 -0
- package/src/web/scrapers/discourse.ts +197 -0
- package/src/web/scrapers/dockerhub.ts +138 -0
- package/src/web/scrapers/docs-rs.ts +653 -0
- package/src/web/scrapers/fdroid.ts +134 -0
- package/src/web/scrapers/firefox-addons.ts +191 -0
- package/src/web/scrapers/flathub.ts +223 -0
- package/src/web/scrapers/github-gist.ts +58 -0
- package/src/web/scrapers/github.ts +452 -0
- package/src/web/scrapers/gitlab.ts +401 -0
- package/src/web/scrapers/go-pkg.ts +266 -0
- package/src/web/scrapers/hackage.ts +140 -0
- package/src/web/scrapers/hackernews.ts +189 -0
- package/src/web/scrapers/hex.ts +105 -0
- package/src/web/scrapers/huggingface.ts +321 -0
- package/src/web/scrapers/iacr.ts +89 -0
- package/src/web/scrapers/index.ts +252 -0
- package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
- package/src/web/scrapers/lemmy.ts +203 -0
- package/src/web/scrapers/lobsters.ts +175 -0
- package/src/web/scrapers/mastodon.ts +292 -0
- package/src/web/scrapers/maven.ts +138 -0
- package/src/web/scrapers/mdn.ts +173 -0
- package/src/web/scrapers/metacpan.ts +222 -0
- package/src/web/scrapers/musicbrainz.ts +250 -0
- package/src/web/scrapers/npm.ts +98 -0
- package/src/web/scrapers/nuget.ts +183 -0
- package/src/web/scrapers/nvd.ts +222 -0
- package/src/web/scrapers/ollama.ts +239 -0
- package/src/web/scrapers/open-vsx.ts +106 -0
- package/src/web/scrapers/opencorporates.ts +292 -0
- package/src/web/scrapers/openlibrary.ts +336 -0
- package/src/web/scrapers/orcid.ts +286 -0
- package/src/web/scrapers/osv.ts +176 -0
- package/src/web/scrapers/packagist.ts +160 -0
- package/src/web/scrapers/pub-dev.ts +143 -0
- package/src/web/scrapers/pubmed.ts +211 -0
- package/src/web/scrapers/pypi.ts +112 -0
- package/src/web/scrapers/rawg.ts +110 -0
- package/src/web/scrapers/readthedocs.ts +120 -0
- package/src/web/scrapers/reddit.ts +95 -0
- package/src/web/scrapers/repology.ts +251 -0
- package/src/web/scrapers/rfc.ts +201 -0
- package/src/web/scrapers/rubygems.ts +103 -0
- package/src/web/scrapers/searchcode.ts +189 -0
- package/src/web/scrapers/sec-edgar.ts +261 -0
- package/src/web/scrapers/semantic-scholar.ts +171 -0
- package/src/web/scrapers/snapcraft.ts +187 -0
- package/src/web/scrapers/sourcegraph.ts +336 -0
- package/src/web/scrapers/spdx.ts +108 -0
- package/src/web/scrapers/spotify.ts +198 -0
- package/src/web/scrapers/stackoverflow.ts +120 -0
- package/src/web/scrapers/terraform.ts +277 -0
- package/src/web/scrapers/tldr.ts +47 -0
- package/src/web/scrapers/twitter.ts +93 -0
- package/src/web/scrapers/types.ts +358 -0
- package/src/web/scrapers/utils.ts +133 -0
- package/src/web/scrapers/vimeo.ts +133 -0
- package/src/web/scrapers/vscode-marketplace.ts +187 -0
- package/src/web/scrapers/w3c.ts +156 -0
- package/src/web/scrapers/wikidata.ts +344 -0
- package/src/web/scrapers/wikipedia.ts +84 -0
- package/src/web/scrapers/youtube.ts +319 -0
- package/src/web/search/index.ts +416 -0
- package/src/web/search/provider.ts +236 -0
- package/src/web/search/providers/anthropic.ts +319 -0
- package/src/web/search/providers/base.ts +102 -0
- package/src/web/search/providers/brave.ts +149 -0
- package/src/web/search/providers/codex.ts +598 -0
- package/src/web/search/providers/duckduckgo.ts +279 -0
- package/src/web/search/providers/exa.ts +193 -0
- package/src/web/search/providers/gemini.ts +462 -0
- package/src/web/search/providers/jina.ts +101 -0
- package/src/web/search/providers/kagi.ts +75 -0
- package/src/web/search/providers/kimi.ts +171 -0
- package/src/web/search/providers/parallel.ts +210 -0
- package/src/web/search/providers/perplexity.ts +575 -0
- package/src/web/search/providers/searxng.ts +309 -0
- package/src/web/search/providers/synthetic.ts +108 -0
- package/src/web/search/providers/tavily.ts +173 -0
- package/src/web/search/providers/utils.ts +128 -0
- package/src/web/search/providers/xai.ts +174 -0
- package/src/web/search/providers/zai.ts +320 -0
- package/src/web/search/render.ts +299 -0
- package/src/web/search/types.ts +445 -0
- package/src/web/search/utils.ts +17 -0
- package/src/workspace-tree.ts +286 -0
|
@@ -0,0 +1,1978 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type { WorkflowHudSummary } from "../skill-state/active-state";
|
|
4
|
+
import {
|
|
5
|
+
applyHandoffToActiveState,
|
|
6
|
+
CANONICAL_JWC_WORKFLOW_SKILLS,
|
|
7
|
+
type CanonicalJwcWorkflowSkill,
|
|
8
|
+
listActiveSkills,
|
|
9
|
+
readSessionStrictSkillActiveState,
|
|
10
|
+
syncSkillActiveState,
|
|
11
|
+
} from "../skill-state/active-state";
|
|
12
|
+
import { initialPhaseForSkill } from "../skill-state/initial-phase";
|
|
13
|
+
import {
|
|
14
|
+
buildGoalHudSummary,
|
|
15
|
+
buildJawInterviewHudSummary,
|
|
16
|
+
buildPlanphaseHudSummary,
|
|
17
|
+
buildTeamHudSummary,
|
|
18
|
+
} from "../skill-state/workflow-hud";
|
|
19
|
+
import {
|
|
20
|
+
type AuditEntry,
|
|
21
|
+
buildWorkflowStateReceipt,
|
|
22
|
+
canonicalWorkflowSkill,
|
|
23
|
+
describeWorkflowStateContract,
|
|
24
|
+
WORKFLOW_STATE_VERSION,
|
|
25
|
+
type WorkflowStateMutationOwner,
|
|
26
|
+
type WorkflowStateReceipt,
|
|
27
|
+
} from "../skill-state/workflow-state-contract";
|
|
28
|
+
import { renderCliWriteReceipt } from "./cli-write-receipt";
|
|
29
|
+
import { canonicalModeStateFileName, readWorkflowModeStateJson, resolveModeStatePaths } from "./legacy-storage";
|
|
30
|
+
import { renderStateGraph, type StateGraphFormat } from "./state-graph";
|
|
31
|
+
import { migrateAndPersistLegacyState, migrateWorkflowState } from "./state-migrations";
|
|
32
|
+
import {
|
|
33
|
+
buildStateStatusSummary,
|
|
34
|
+
compactProjectStateJson,
|
|
35
|
+
projectStateFields,
|
|
36
|
+
renderContractMarkdown,
|
|
37
|
+
renderHistoryMarkdown,
|
|
38
|
+
renderStateMarkdown,
|
|
39
|
+
renderStateStatusLine,
|
|
40
|
+
STATE_FIELD_ALLOWLIST,
|
|
41
|
+
type StateProjectionField,
|
|
42
|
+
} from "./state-renderer";
|
|
43
|
+
import { normalizeWorkflowSkillSlug } from "./state-schema";
|
|
44
|
+
import { validateWorkflowStateEnvelope } from "./state-validation";
|
|
45
|
+
import {
|
|
46
|
+
appendAuditEntry,
|
|
47
|
+
beginWorkflowTransactionJournal,
|
|
48
|
+
completeWorkflowTransactionJournal,
|
|
49
|
+
detectWorkflowEnvelopeIntegrityMismatch,
|
|
50
|
+
type GenericHardPruneTarget,
|
|
51
|
+
hardPrune,
|
|
52
|
+
readExistingStateForMutation,
|
|
53
|
+
type StateWriterAuditContext,
|
|
54
|
+
softDelete,
|
|
55
|
+
updateWorkflowTransactionJournal,
|
|
56
|
+
writeWorkflowEnvelopeAtomic,
|
|
57
|
+
} from "./state-writer";
|
|
58
|
+
import { getSkillManifest, isKnownWorkflowState, isValidTransition, typedArgsFor } from "./workflow-manifest";
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Native implementation of the `jwc state read|write|clear` command surface.
|
|
62
|
+
*
|
|
63
|
+
* Simple file-receipt operations against `.jwc/state/[sessions/<id>/]<mode>-state.json` and
|
|
64
|
+
* `.jwc/state/[sessions/<id>/]skill-active-state.json`. This is the sanctioned CLI mediator for
|
|
65
|
+
* the mutation-guarded `.jwc/state` ACL — agents call it instead of editing those files directly.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
export interface StateCommandResult {
|
|
69
|
+
status: number;
|
|
70
|
+
stdout?: string;
|
|
71
|
+
stderr?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const SKILL_ACTIVE_STATE_FILE = "skill-active-state.json";
|
|
75
|
+
const PATH_COMPONENT_RE = /^[A-Za-z0-9_-][A-Za-z0-9._-]{0,63}$/;
|
|
76
|
+
const KNOWN_MODES: readonly string[] = CANONICAL_JWC_WORKFLOW_SKILLS;
|
|
77
|
+
|
|
78
|
+
class StateCommandError extends Error {
|
|
79
|
+
constructor(
|
|
80
|
+
public readonly exitStatus: number,
|
|
81
|
+
message: string,
|
|
82
|
+
) {
|
|
83
|
+
super(message);
|
|
84
|
+
this.name = "StateCommandError";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function flagValue(args: readonly string[], flag: string): string | undefined {
|
|
89
|
+
const index = args.indexOf(flag);
|
|
90
|
+
if (index < 0) return undefined;
|
|
91
|
+
return args[index + 1];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function hasFlag(args: readonly string[], flag: string): boolean {
|
|
95
|
+
return args.includes(flag);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const GRAPH_FORMATS = new Set(["ascii", "mermaid", "dot"]);
|
|
99
|
+
const FLAGS_WITH_VALUES = new Set([
|
|
100
|
+
"--input",
|
|
101
|
+
"--mode",
|
|
102
|
+
"--session-id",
|
|
103
|
+
"--thread-id",
|
|
104
|
+
"--turn-id",
|
|
105
|
+
"--to",
|
|
106
|
+
"--skill",
|
|
107
|
+
"--format",
|
|
108
|
+
"--older-than",
|
|
109
|
+
"--status",
|
|
110
|
+
"--fields",
|
|
111
|
+
"--since",
|
|
112
|
+
"--limit",
|
|
113
|
+
]);
|
|
114
|
+
const ACTION_NAMES = new Set([
|
|
115
|
+
"read",
|
|
116
|
+
"write",
|
|
117
|
+
"clear",
|
|
118
|
+
"contract",
|
|
119
|
+
"handoff",
|
|
120
|
+
"graph",
|
|
121
|
+
"prune",
|
|
122
|
+
"gc",
|
|
123
|
+
"migrate",
|
|
124
|
+
"status",
|
|
125
|
+
"doctor",
|
|
126
|
+
]);
|
|
127
|
+
const BOOLEAN_FLAGS = new Set([
|
|
128
|
+
"--json",
|
|
129
|
+
"--replace",
|
|
130
|
+
"--hard",
|
|
131
|
+
"--dry-run",
|
|
132
|
+
"--migrate",
|
|
133
|
+
"--compact",
|
|
134
|
+
"--history",
|
|
135
|
+
"--force",
|
|
136
|
+
]);
|
|
137
|
+
const VERB_SPECIFIC_FLAGS = new Set([
|
|
138
|
+
"--skill",
|
|
139
|
+
"--format",
|
|
140
|
+
"--older-than",
|
|
141
|
+
"--status",
|
|
142
|
+
"--fields",
|
|
143
|
+
"--since",
|
|
144
|
+
"--limit",
|
|
145
|
+
"--history",
|
|
146
|
+
]);
|
|
147
|
+
|
|
148
|
+
function flagName(arg: string): string | undefined {
|
|
149
|
+
if (!arg.startsWith("--")) return undefined;
|
|
150
|
+
const equalsIndex = arg.indexOf("=");
|
|
151
|
+
return equalsIndex >= 0 ? arg.slice(0, equalsIndex) : arg;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function manifestFlagNames(action: ParsedInvocation["action"], positionalSkill: string | undefined): Set<string> {
|
|
155
|
+
const names = new Set<string>();
|
|
156
|
+
const normalizedPositional = positionalSkill ? normalizeWorkflowSkillSlug(positionalSkill) : undefined;
|
|
157
|
+
const skills =
|
|
158
|
+
normalizedPositional && KNOWN_MODES.includes(normalizedPositional)
|
|
159
|
+
? [normalizedPositional as CanonicalJwcWorkflowSkill]
|
|
160
|
+
: CANONICAL_JWC_WORKFLOW_SKILLS;
|
|
161
|
+
for (const skill of skills) {
|
|
162
|
+
for (const arg of typedArgsFor(skill, action)) names.add(`--${arg.name}`);
|
|
163
|
+
}
|
|
164
|
+
return names;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function assertKnownFlags(args: readonly string[], parsed: ParsedInvocation): void {
|
|
168
|
+
const manifestFlags = manifestFlagNames(parsed.action, parsed.positionalSkill);
|
|
169
|
+
for (const arg of args) {
|
|
170
|
+
const flag = flagName(arg);
|
|
171
|
+
if (!flag) continue;
|
|
172
|
+
if (
|
|
173
|
+
FLAGS_WITH_VALUES.has(flag) ||
|
|
174
|
+
BOOLEAN_FLAGS.has(flag) ||
|
|
175
|
+
VERB_SPECIFIC_FLAGS.has(flag) ||
|
|
176
|
+
manifestFlags.has(flag)
|
|
177
|
+
) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
throw new StateCommandError(2, `unknown jwc state flag: ${flag}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface ParsedInvocation {
|
|
185
|
+
action:
|
|
186
|
+
| "read"
|
|
187
|
+
| "write"
|
|
188
|
+
| "clear"
|
|
189
|
+
| "contract"
|
|
190
|
+
| "handoff"
|
|
191
|
+
| "graph"
|
|
192
|
+
| "prune"
|
|
193
|
+
| "gc"
|
|
194
|
+
| "migrate"
|
|
195
|
+
| "status"
|
|
196
|
+
| "doctor";
|
|
197
|
+
positionalSkill?: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function parsePositionalArgs(args: readonly string[]): ParsedInvocation {
|
|
201
|
+
let skipNext = false;
|
|
202
|
+
const positional: string[] = [];
|
|
203
|
+
for (const arg of args) {
|
|
204
|
+
if (skipNext) {
|
|
205
|
+
skipNext = false;
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (FLAGS_WITH_VALUES.has(arg)) {
|
|
209
|
+
skipNext = true;
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (!arg.startsWith("-")) positional.push(arg);
|
|
213
|
+
}
|
|
214
|
+
// Documented argv shapes:
|
|
215
|
+
// gjc state read|write|clear|contract ...
|
|
216
|
+
// gjc state <skill> read|write|contract ...
|
|
217
|
+
const first = positional[0];
|
|
218
|
+
const second = positional[1];
|
|
219
|
+
if (first && ACTION_NAMES.has(first)) {
|
|
220
|
+
return { action: first as ParsedInvocation["action"], positionalSkill: second };
|
|
221
|
+
}
|
|
222
|
+
if (first && second && ACTION_NAMES.has(second)) {
|
|
223
|
+
return { action: second as ParsedInvocation["action"], positionalSkill: first };
|
|
224
|
+
}
|
|
225
|
+
// `jwc state <skill>` alone defaults to read for that skill.
|
|
226
|
+
if (first && !second) {
|
|
227
|
+
return { action: "read", positionalSkill: first };
|
|
228
|
+
}
|
|
229
|
+
return { action: "read" };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function assertSafePathComponent(value: string, label: string): void {
|
|
233
|
+
if (!PATH_COMPONENT_RE.test(value) || value.includes("..")) {
|
|
234
|
+
throw new StateCommandError(2, `invalid path component for --${label}: ${value}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function assertKnownMode(mode: string): asserts mode is CanonicalJwcWorkflowSkill {
|
|
239
|
+
if (!KNOWN_MODES.includes(mode)) {
|
|
240
|
+
throw new StateCommandError(2, `unknown --mode: ${mode}. Expected one of: ${KNOWN_MODES.join(", ")}.`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
async function readInputJson(value: string | undefined, cwd: string): Promise<Record<string, unknown> | undefined> {
|
|
245
|
+
if (value === undefined) return undefined;
|
|
246
|
+
const trimmed = value.trim();
|
|
247
|
+
if (!trimmed) return undefined;
|
|
248
|
+
let raw: string;
|
|
249
|
+
if (trimmed.startsWith("@")) {
|
|
250
|
+
const filePath = path.resolve(cwd, trimmed.slice(1));
|
|
251
|
+
try {
|
|
252
|
+
raw = await fs.readFile(filePath, "utf-8");
|
|
253
|
+
} catch (error) {
|
|
254
|
+
throw new StateCommandError(2, `failed to read --input file ${filePath}: ${(error as Error).message}`);
|
|
255
|
+
}
|
|
256
|
+
} else {
|
|
257
|
+
raw = trimmed;
|
|
258
|
+
}
|
|
259
|
+
let parsed: unknown;
|
|
260
|
+
try {
|
|
261
|
+
parsed = JSON.parse(raw);
|
|
262
|
+
} catch (error) {
|
|
263
|
+
throw new StateCommandError(2, `--input is not valid JSON: ${(error as Error).message}`);
|
|
264
|
+
}
|
|
265
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
266
|
+
throw new StateCommandError(2, "--input must be a JSON object");
|
|
267
|
+
}
|
|
268
|
+
return parsed as Record<string, unknown>;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
interface ResolvedSelectors {
|
|
272
|
+
mode: CanonicalJwcWorkflowSkill | undefined;
|
|
273
|
+
sessionId: string | undefined;
|
|
274
|
+
threadId: string | undefined;
|
|
275
|
+
turnId: string | undefined;
|
|
276
|
+
payload: Record<string, unknown> | undefined;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async function resolveSelectors(
|
|
280
|
+
args: readonly string[],
|
|
281
|
+
cwd: string,
|
|
282
|
+
positionalSkill: string | undefined,
|
|
283
|
+
): Promise<ResolvedSelectors> {
|
|
284
|
+
const payload = await readInputJson(flagValue(args, "--input"), cwd);
|
|
285
|
+
|
|
286
|
+
const candidates: Array<string | undefined> = [
|
|
287
|
+
flagValue(args, "--mode")?.trim() || undefined,
|
|
288
|
+
positionalSkill?.trim() || undefined,
|
|
289
|
+
typeof payload?.mode === "string" ? (payload.mode as string).trim() || undefined : undefined,
|
|
290
|
+
typeof payload?.skill === "string" ? (payload.skill as string).trim() || undefined : undefined,
|
|
291
|
+
];
|
|
292
|
+
let mode: string | undefined;
|
|
293
|
+
for (const candidate of candidates) {
|
|
294
|
+
if (candidate) {
|
|
295
|
+
mode = normalizeWorkflowSkillSlug(candidate);
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (mode) assertKnownMode(mode);
|
|
300
|
+
|
|
301
|
+
const explicitSessionId = flagValue(args, "--session-id");
|
|
302
|
+
// Session-id resolution order: explicit --session-id flag, then payload
|
|
303
|
+
// session_id, then GJC_SESSION_ID env var (set by AgentSession.sdk for
|
|
304
|
+
// agent-initiated CLI invocations). The env-var default keeps shell
|
|
305
|
+
// snippets in skill docs short while still routing writes/reads to the
|
|
306
|
+
// caller's session-scoped state files.
|
|
307
|
+
let sessionId = explicitSessionId !== undefined ? explicitSessionId.trim() || undefined : undefined;
|
|
308
|
+
if (!sessionId && payload && typeof payload.session_id === "string") {
|
|
309
|
+
sessionId = payload.session_id.trim() || undefined;
|
|
310
|
+
}
|
|
311
|
+
if (!sessionId && explicitSessionId === undefined) {
|
|
312
|
+
const envSessionId = process.env.GJC_SESSION_ID?.trim();
|
|
313
|
+
if (envSessionId) sessionId = envSessionId;
|
|
314
|
+
}
|
|
315
|
+
if (sessionId) assertSafePathComponent(sessionId, "session-id");
|
|
316
|
+
|
|
317
|
+
const threadId = flagValue(args, "--thread-id")?.trim() || undefined;
|
|
318
|
+
if (threadId) assertSafePathComponent(threadId, "thread-id");
|
|
319
|
+
const turnId = flagValue(args, "--turn-id")?.trim() || undefined;
|
|
320
|
+
if (turnId) assertSafePathComponent(turnId, "turn-id");
|
|
321
|
+
|
|
322
|
+
return { mode: mode as CanonicalJwcWorkflowSkill | undefined, sessionId, threadId, turnId, payload };
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
async function inferModeFromActiveState(
|
|
326
|
+
cwd: string,
|
|
327
|
+
sessionId: string | undefined,
|
|
328
|
+
): Promise<CanonicalJwcWorkflowSkill | undefined> {
|
|
329
|
+
const state = await readSessionStrictSkillActiveState(cwd, sessionId);
|
|
330
|
+
const entries = listActiveSkills(state);
|
|
331
|
+
const candidate = entries[0]?.skill ?? state?.skill;
|
|
332
|
+
if (!candidate) return undefined;
|
|
333
|
+
const canonical = canonicalWorkflowSkill(candidate);
|
|
334
|
+
return canonical ?? undefined;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function encodeSessionSegment(value: string): string {
|
|
338
|
+
return encodeURIComponent(value).replaceAll(".", "%2E");
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function stateDirFor(cwd: string, sessionId: string | undefined): string {
|
|
342
|
+
const base = path.join(cwd, ".jwc", "state");
|
|
343
|
+
if (!sessionId) return base;
|
|
344
|
+
return path.join(base, "sessions", encodeSessionSegment(sessionId));
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function modeStateFile(cwd: string, mode: string, sessionId: string | undefined): string {
|
|
348
|
+
const skill = canonicalWorkflowSkill(mode);
|
|
349
|
+
if (skill) {
|
|
350
|
+
return path.join(stateDirFor(cwd, sessionId), canonicalModeStateFileName(skill));
|
|
351
|
+
}
|
|
352
|
+
return path.join(stateDirFor(cwd, sessionId), `${mode}-state.json`);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function activeStateFile(cwd: string, sessionId: string | undefined): string {
|
|
356
|
+
return path.join(stateDirFor(cwd, sessionId), SKILL_ACTIVE_STATE_FILE);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
async function readJsonFile(filePath: string): Promise<Record<string, unknown> | null> {
|
|
360
|
+
try {
|
|
361
|
+
const raw = await fs.readFile(filePath, "utf-8");
|
|
362
|
+
const parsed = JSON.parse(raw);
|
|
363
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
364
|
+
return parsed as Record<string, unknown>;
|
|
365
|
+
}
|
|
366
|
+
return null;
|
|
367
|
+
} catch (error) {
|
|
368
|
+
const err = error as NodeJS.ErrnoException;
|
|
369
|
+
if (err.code === "ENOENT") return null;
|
|
370
|
+
process.stderr.write(`WARNING: failed to read ${filePath}; ignoring corrupt state: ${err.message}\n`);
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
async function readJsonValue(filePath: string): Promise<unknown | null> {
|
|
376
|
+
try {
|
|
377
|
+
return JSON.parse(await fs.readFile(filePath, "utf-8"));
|
|
378
|
+
} catch (error) {
|
|
379
|
+
const err = error as NodeJS.ErrnoException;
|
|
380
|
+
if (err.code === "ENOENT") return null;
|
|
381
|
+
process.stderr.write(`WARNING: failed to read ${filePath}; ignoring corrupt state: ${err.message}\n`);
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
type DoctorProblemType = "orphan_journal" | "checksum_mismatch" | "schema_violation" | "stale_active_state";
|
|
387
|
+
|
|
388
|
+
interface DoctorProblem {
|
|
389
|
+
type: DoctorProblemType;
|
|
390
|
+
skill?: CanonicalJwcWorkflowSkill;
|
|
391
|
+
path: string;
|
|
392
|
+
message: string;
|
|
393
|
+
fixCommand: string;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
interface DoctorSummary {
|
|
397
|
+
ok: boolean;
|
|
398
|
+
root: string;
|
|
399
|
+
summary: {
|
|
400
|
+
skills_scanned: number;
|
|
401
|
+
files_scanned: number;
|
|
402
|
+
journals_scanned: number;
|
|
403
|
+
findings_total: number;
|
|
404
|
+
by_kind: Record<DoctorProblemType, number>;
|
|
405
|
+
};
|
|
406
|
+
problems: DoctorProblem[];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
async function readRawJson(filePath: string): Promise<{ exists: boolean; value?: unknown; error?: string }> {
|
|
410
|
+
try {
|
|
411
|
+
return { exists: true, value: JSON.parse(await fs.readFile(filePath, "utf-8")) };
|
|
412
|
+
} catch (error) {
|
|
413
|
+
const err = error as NodeJS.ErrnoException;
|
|
414
|
+
if (err.code === "ENOENT") return { exists: false };
|
|
415
|
+
return { exists: true, error: err.message };
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
async function listJsonFiles(dir: string): Promise<string[]> {
|
|
420
|
+
let entries: string[];
|
|
421
|
+
try {
|
|
422
|
+
entries = await fs.readdir(dir);
|
|
423
|
+
} catch (error) {
|
|
424
|
+
const err = error as NodeJS.ErrnoException;
|
|
425
|
+
if (err.code === "ENOENT") return [];
|
|
426
|
+
throw error;
|
|
427
|
+
}
|
|
428
|
+
return entries
|
|
429
|
+
.filter(entry => entry.endsWith(".json"))
|
|
430
|
+
.sort()
|
|
431
|
+
.map(entry => path.join(dir, entry));
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function doctorProblem(
|
|
435
|
+
type: DoctorProblemType,
|
|
436
|
+
pathValue: string,
|
|
437
|
+
message: string,
|
|
438
|
+
fixCommand: string,
|
|
439
|
+
skill?: CanonicalJwcWorkflowSkill,
|
|
440
|
+
): DoctorProblem {
|
|
441
|
+
return skill
|
|
442
|
+
? { type, skill, path: pathValue, message, fixCommand }
|
|
443
|
+
: { type, path: pathValue, message, fixCommand };
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function activeEntryDir(cwd: string, sessionId: string | undefined): string {
|
|
447
|
+
return path.join(stateDirFor(cwd, sessionId), "active");
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function skillFromActiveValue(value: unknown): string | undefined {
|
|
451
|
+
return isPlainObject(value) && typeof value.skill === "string" ? value.skill : undefined;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function activeFlag(value: unknown): boolean {
|
|
455
|
+
return isPlainObject(value) && value.active !== false;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
async function collectDoctorSummary(
|
|
459
|
+
cwd: string,
|
|
460
|
+
skill: CanonicalJwcWorkflowSkill | undefined,
|
|
461
|
+
sessionId: string | undefined,
|
|
462
|
+
): Promise<DoctorSummary> {
|
|
463
|
+
const root = path.join(cwd, ".jwc", "state");
|
|
464
|
+
const skills = skill ? [skill] : [...CANONICAL_JWC_WORKFLOW_SKILLS];
|
|
465
|
+
const problems: DoctorProblem[] = [];
|
|
466
|
+
let filesScanned = 0;
|
|
467
|
+
let journalsScanned = 0;
|
|
468
|
+
|
|
469
|
+
for (const currentSkill of skills) {
|
|
470
|
+
const filePath = modeStateFile(cwd, currentSkill, sessionId);
|
|
471
|
+
const raw = await readRawJson(filePath);
|
|
472
|
+
if (!raw.exists) continue;
|
|
473
|
+
filesScanned += 1;
|
|
474
|
+
if (raw.error) {
|
|
475
|
+
problems.push(
|
|
476
|
+
doctorProblem(
|
|
477
|
+
"schema_violation",
|
|
478
|
+
filePath,
|
|
479
|
+
`mode-state JSON is unreadable: ${raw.error}`,
|
|
480
|
+
`jwc state ${currentSkill} migrate`,
|
|
481
|
+
currentSkill,
|
|
482
|
+
),
|
|
483
|
+
);
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
const validation = validateWorkflowStateEnvelope(currentSkill, raw.value);
|
|
487
|
+
if (!validation.valid) {
|
|
488
|
+
problems.push(
|
|
489
|
+
doctorProblem(
|
|
490
|
+
"schema_violation",
|
|
491
|
+
filePath,
|
|
492
|
+
validation.error ?? `invalid ${currentSkill} state envelope`,
|
|
493
|
+
`jwc state ${currentSkill} migrate`,
|
|
494
|
+
currentSkill,
|
|
495
|
+
),
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
const mismatch = await detectWorkflowEnvelopeIntegrityMismatch(filePath);
|
|
499
|
+
if (mismatch) {
|
|
500
|
+
problems.push(
|
|
501
|
+
doctorProblem(
|
|
502
|
+
"checksum_mismatch",
|
|
503
|
+
filePath,
|
|
504
|
+
`expected sha256 ${mismatch.expected} but found ${mismatch.actual}`,
|
|
505
|
+
`jwc state ${currentSkill} migrate`,
|
|
506
|
+
currentSkill,
|
|
507
|
+
),
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
const journalFiles = await listJsonFiles(path.join(root, "transactions"));
|
|
513
|
+
for (const journalPath of journalFiles) {
|
|
514
|
+
journalsScanned += 1;
|
|
515
|
+
const raw = await readRawJson(journalPath);
|
|
516
|
+
const value = raw.value;
|
|
517
|
+
const status = isPlainObject(value) && typeof value.status === "string" ? value.status : undefined;
|
|
518
|
+
const paths =
|
|
519
|
+
isPlainObject(value) && Array.isArray(value.paths) ? value.paths.filter(p => typeof p === "string") : [];
|
|
520
|
+
const hasLiveMutation = status === "pending" && paths.some(filePath => path.resolve(filePath).startsWith(root));
|
|
521
|
+
if (!hasLiveMutation) {
|
|
522
|
+
problems.push(
|
|
523
|
+
doctorProblem(
|
|
524
|
+
"orphan_journal",
|
|
525
|
+
journalPath,
|
|
526
|
+
"transaction journal has no matching live mutation",
|
|
527
|
+
"jwc state prune --hard",
|
|
528
|
+
),
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
const inspectActiveScope = async (scopeSessionId: string | undefined): Promise<void> => {
|
|
534
|
+
const snapshotPath = activeStateFile(cwd, scopeSessionId);
|
|
535
|
+
const snapshot = await readRawJson(snapshotPath);
|
|
536
|
+
if (snapshot.exists) filesScanned += 1;
|
|
537
|
+
const entryFiles = await listJsonFiles(activeEntryDir(cwd, scopeSessionId));
|
|
538
|
+
const entrySkills = new Set<string>();
|
|
539
|
+
for (const entryPath of entryFiles) {
|
|
540
|
+
filesScanned += 1;
|
|
541
|
+
const entry = await readRawJson(entryPath);
|
|
542
|
+
const entrySkill = skillFromActiveValue(entry.value) ?? path.basename(entryPath, ".json");
|
|
543
|
+
entrySkills.add(entrySkill);
|
|
544
|
+
const canonical = canonicalWorkflowSkill(entrySkill);
|
|
545
|
+
if (canonical && !skills.includes(canonical)) continue;
|
|
546
|
+
const statePath = canonical
|
|
547
|
+
? modeStateFile(cwd, canonical, scopeSessionId)
|
|
548
|
+
: path.join(root, `${entrySkill}-state.json`);
|
|
549
|
+
const state = await readRawJson(statePath);
|
|
550
|
+
if (activeFlag(entry.value) && (!state.exists || !activeFlag(state.value))) {
|
|
551
|
+
problems.push(
|
|
552
|
+
doctorProblem(
|
|
553
|
+
"stale_active_state",
|
|
554
|
+
entryPath,
|
|
555
|
+
`active entry for ${entrySkill} does not match a live active mode-state`,
|
|
556
|
+
canonical ? `jwc state ${canonical} clear` : "jwc state prune --hard",
|
|
557
|
+
canonical ?? undefined,
|
|
558
|
+
),
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
if (isPlainObject(snapshot.value)) {
|
|
563
|
+
const activeSkills = Array.isArray(snapshot.value.active_skills) ? snapshot.value.active_skills : [];
|
|
564
|
+
for (const entry of activeSkills) {
|
|
565
|
+
const entrySkill = skillFromActiveValue(entry);
|
|
566
|
+
if (!entrySkill) continue;
|
|
567
|
+
const canonical = canonicalWorkflowSkill(entrySkill);
|
|
568
|
+
if (canonical && !skills.includes(canonical)) continue;
|
|
569
|
+
if (activeFlag(entry) && !entrySkills.has(entrySkill)) {
|
|
570
|
+
problems.push(
|
|
571
|
+
doctorProblem(
|
|
572
|
+
"stale_active_state",
|
|
573
|
+
snapshotPath,
|
|
574
|
+
`active snapshot lists ${entrySkill} but no raw per-skill active entry exists`,
|
|
575
|
+
canonical ? `jwc state ${canonical} clear` : "jwc state prune --hard",
|
|
576
|
+
canonical ?? undefined,
|
|
577
|
+
),
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
await inspectActiveScope(sessionId);
|
|
585
|
+
if (!sessionId) {
|
|
586
|
+
const sessionsDir = path.join(root, "sessions");
|
|
587
|
+
let sessions: string[] = [];
|
|
588
|
+
try {
|
|
589
|
+
const entries = await fs.readdir(sessionsDir, { withFileTypes: true });
|
|
590
|
+
sessions = entries
|
|
591
|
+
.filter(entry => entry.isDirectory())
|
|
592
|
+
.map(entry => entry.name)
|
|
593
|
+
.sort();
|
|
594
|
+
} catch (error) {
|
|
595
|
+
const err = error as NodeJS.ErrnoException;
|
|
596
|
+
if (err.code !== "ENOENT") throw error;
|
|
597
|
+
}
|
|
598
|
+
for (const rawSession of sessions) await inspectActiveScope(decodeURIComponent(rawSession));
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
problems.sort(
|
|
602
|
+
(a, b) =>
|
|
603
|
+
a.type.localeCompare(b.type) || (a.skill ?? "").localeCompare(b.skill ?? "") || a.path.localeCompare(b.path),
|
|
604
|
+
);
|
|
605
|
+
const byKind: Record<DoctorProblemType, number> = {
|
|
606
|
+
orphan_journal: 0,
|
|
607
|
+
checksum_mismatch: 0,
|
|
608
|
+
schema_violation: 0,
|
|
609
|
+
stale_active_state: 0,
|
|
610
|
+
};
|
|
611
|
+
for (const problem of problems) byKind[problem.type] += 1;
|
|
612
|
+
return {
|
|
613
|
+
ok: problems.length === 0,
|
|
614
|
+
root,
|
|
615
|
+
summary: {
|
|
616
|
+
skills_scanned: skills.length,
|
|
617
|
+
files_scanned: filesScanned,
|
|
618
|
+
journals_scanned: journalsScanned,
|
|
619
|
+
findings_total: problems.length,
|
|
620
|
+
by_kind: byKind,
|
|
621
|
+
},
|
|
622
|
+
problems,
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function renderDoctorText(summary: DoctorSummary): string {
|
|
627
|
+
const lines = [
|
|
628
|
+
`ok: ${summary.ok}`,
|
|
629
|
+
`root: ${summary.root}`,
|
|
630
|
+
`skills_scanned: ${summary.summary.skills_scanned}`,
|
|
631
|
+
`files_scanned: ${summary.summary.files_scanned}`,
|
|
632
|
+
`journals_scanned: ${summary.summary.journals_scanned}`,
|
|
633
|
+
`findings_total: ${summary.summary.findings_total}`,
|
|
634
|
+
`counts: ${Object.entries(summary.summary.by_kind)
|
|
635
|
+
.map(([kind, count]) => `${kind}=${count}`)
|
|
636
|
+
.join(", ")}`,
|
|
637
|
+
];
|
|
638
|
+
for (const problem of summary.problems) {
|
|
639
|
+
lines.push(
|
|
640
|
+
`finding: kind=${problem.type} skill=${problem.skill ?? "-"} path=${problem.path} message=${problem.message} fix=${problem.fixCommand}`,
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
return `${lines.join("\n")}\n`;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
async function handleDoctor(
|
|
647
|
+
args: readonly string[],
|
|
648
|
+
cwd: string,
|
|
649
|
+
positionalSkill: string | undefined,
|
|
650
|
+
): Promise<StateCommandResult> {
|
|
651
|
+
const rawSkillInput =
|
|
652
|
+
flagValue(args, "--skill")?.trim() || flagValue(args, "--mode")?.trim() || positionalSkill?.trim();
|
|
653
|
+
const rawSkill = rawSkillInput ? normalizeWorkflowSkillSlug(rawSkillInput) : rawSkillInput;
|
|
654
|
+
if (rawSkill) assertKnownMode(rawSkill);
|
|
655
|
+
const sessionId = flagValue(args, "--session-id")?.trim() || undefined;
|
|
656
|
+
if (sessionId) assertSafePathComponent(sessionId, "session-id");
|
|
657
|
+
const summary = await collectDoctorSummary(cwd, rawSkill as CanonicalJwcWorkflowSkill | undefined, sessionId);
|
|
658
|
+
return {
|
|
659
|
+
status: summary.ok ? 0 : 1,
|
|
660
|
+
stdout: hasFlag(args, "--json") ? `${JSON.stringify(summary, null, 2)}\n` : renderDoctorText(summary),
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
async function warnAndAuditOutOfBandIfNeeded(
|
|
665
|
+
cwd: string,
|
|
666
|
+
filePath: string,
|
|
667
|
+
skill: CanonicalJwcWorkflowSkill,
|
|
668
|
+
options?: { mutationId?: string; forced?: boolean },
|
|
669
|
+
): Promise<string | undefined> {
|
|
670
|
+
let mismatch: Awaited<ReturnType<typeof detectWorkflowEnvelopeIntegrityMismatch>>;
|
|
671
|
+
try {
|
|
672
|
+
mismatch = await detectWorkflowEnvelopeIntegrityMismatch(filePath);
|
|
673
|
+
} catch {
|
|
674
|
+
// Unparseable/corrupt state has no recoverable checksum to compare; the strict
|
|
675
|
+
// mutation reader already gates unforced overwrites, so fail-open here.
|
|
676
|
+
return undefined;
|
|
677
|
+
}
|
|
678
|
+
if (!mismatch) return undefined;
|
|
679
|
+
const message = `WARNING: workflow mode-state out-of-band edit detected for ${skill}: ${filePath} expected sha256 ${mismatch.expected} but found ${mismatch.actual}`;
|
|
680
|
+
await appendAuditEntry(cwd, {
|
|
681
|
+
ts: new Date().toISOString(),
|
|
682
|
+
skill,
|
|
683
|
+
category: "state",
|
|
684
|
+
verb: "out_of_band_detected",
|
|
685
|
+
owner: "jwc-state-cli",
|
|
686
|
+
mutation_id: options?.mutationId ?? `${skill}:out-of-band:${new Date().toISOString()}`,
|
|
687
|
+
forced: options?.forced ?? false,
|
|
688
|
+
paths: [filePath],
|
|
689
|
+
expected_sha256: mismatch.expected,
|
|
690
|
+
actual_sha256: mismatch.actual,
|
|
691
|
+
} as AuditEntry);
|
|
692
|
+
return message;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
async function writeJsonAtomic(
|
|
696
|
+
cwd: string,
|
|
697
|
+
filePath: string,
|
|
698
|
+
value: unknown,
|
|
699
|
+
verb: "write" | "clear" | "handoff" | "reconcile" = "write",
|
|
700
|
+
options?: {
|
|
701
|
+
skill?: CanonicalJwcWorkflowSkill;
|
|
702
|
+
mutationId?: string;
|
|
703
|
+
force?: boolean;
|
|
704
|
+
fromPhase?: string;
|
|
705
|
+
toPhase?: string;
|
|
706
|
+
owner?: WorkflowStateMutationOwner;
|
|
707
|
+
},
|
|
708
|
+
): Promise<{ warning?: string; stamped: Record<string, unknown> }> {
|
|
709
|
+
const warning = options?.skill
|
|
710
|
+
? await warnAndAuditOutOfBandIfNeeded(cwd, filePath, options.skill, {
|
|
711
|
+
mutationId: options.mutationId,
|
|
712
|
+
forced: options.force ?? false,
|
|
713
|
+
})
|
|
714
|
+
: undefined;
|
|
715
|
+
if (warning && !options?.force) {
|
|
716
|
+
throw new StateCommandError(2, `${warning}; use --force to overwrite tampered mode-state`);
|
|
717
|
+
}
|
|
718
|
+
await writeWorkflowEnvelopeAtomic(filePath, value, {
|
|
719
|
+
cwd,
|
|
720
|
+
audit: {
|
|
721
|
+
category: "state",
|
|
722
|
+
verb,
|
|
723
|
+
owner: options?.owner ?? "jwc-state-cli",
|
|
724
|
+
skill: options?.skill,
|
|
725
|
+
mutationId: options?.mutationId,
|
|
726
|
+
fromPhase: options?.fromPhase,
|
|
727
|
+
toPhase: options?.toPhase,
|
|
728
|
+
forced: options?.force ?? false,
|
|
729
|
+
},
|
|
730
|
+
});
|
|
731
|
+
return { warning, stamped: (await readJsonFile(filePath)) ?? {} };
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
function parseFieldsFlag(args: readonly string[]): StateProjectionField[] | undefined {
|
|
735
|
+
const raw = flagValue(args, "--fields");
|
|
736
|
+
if (raw === undefined) return undefined;
|
|
737
|
+
const allowed = new Set<string>(STATE_FIELD_ALLOWLIST);
|
|
738
|
+
const fields = raw
|
|
739
|
+
.split(",")
|
|
740
|
+
.map(field => field.trim())
|
|
741
|
+
.filter(Boolean);
|
|
742
|
+
const unknown = fields.filter(field => !allowed.has(field));
|
|
743
|
+
if (unknown.length) {
|
|
744
|
+
throw new StateCommandError(
|
|
745
|
+
2,
|
|
746
|
+
`unknown --fields value(s): ${unknown.join(", ")}. Allowed fields: ${STATE_FIELD_ALLOWLIST.join(", ")}`,
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
return fields as StateProjectionField[];
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
function parseLimitFlag(args: readonly string[], defaultLimit = 50): number {
|
|
753
|
+
const raw = flagValue(args, "--limit");
|
|
754
|
+
if (raw === undefined) return defaultLimit;
|
|
755
|
+
const parsed = Number(raw);
|
|
756
|
+
if (!Number.isInteger(parsed) || parsed <= 0 || parsed > 500) {
|
|
757
|
+
throw new StateCommandError(2, "jwc state --limit requires an integer from 1 to 500");
|
|
758
|
+
}
|
|
759
|
+
return parsed;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
function parseSinceFlag(args: readonly string[]): string | undefined {
|
|
763
|
+
const raw = flagValue(args, "--since")?.trim();
|
|
764
|
+
if (!raw) return undefined;
|
|
765
|
+
const duration = raw.match(/^(\d+)(m|h|d)$/);
|
|
766
|
+
if (duration) {
|
|
767
|
+
const amount = Number(duration[1]);
|
|
768
|
+
const unit = duration[2];
|
|
769
|
+
const multiplier = unit === "m" ? 60_000 : unit === "h" ? 3_600_000 : 86_400_000;
|
|
770
|
+
return new Date(Date.now() - amount * multiplier).toISOString();
|
|
771
|
+
}
|
|
772
|
+
if (Number.isNaN(Date.parse(raw)))
|
|
773
|
+
throw new StateCommandError(2, "jwc state --since requires an ISO timestamp or duration like 30m, 6h, 7d");
|
|
774
|
+
return new Date(raw).toISOString();
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
async function readAuditWindow(
|
|
778
|
+
cwd: string,
|
|
779
|
+
args: readonly string[],
|
|
780
|
+
): Promise<{ entries: unknown[]; limit: number; since?: string; truncated: boolean }> {
|
|
781
|
+
const limit = parseLimitFlag(args);
|
|
782
|
+
const since = parseSinceFlag(args);
|
|
783
|
+
const auditPath = path.join(cwd, ".jwc", "state", "audit.jsonl");
|
|
784
|
+
let raw = "";
|
|
785
|
+
try {
|
|
786
|
+
raw = await fs.readFile(auditPath, "utf-8");
|
|
787
|
+
} catch (error) {
|
|
788
|
+
const err = error as NodeJS.ErrnoException;
|
|
789
|
+
if (err.code !== "ENOENT") throw error;
|
|
790
|
+
}
|
|
791
|
+
const selected: unknown[] = [];
|
|
792
|
+
let matched = 0;
|
|
793
|
+
const lines = raw.split(/\r?\n/).filter(line => line.trim().length > 0);
|
|
794
|
+
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
795
|
+
const line = lines[index];
|
|
796
|
+
let entry: unknown;
|
|
797
|
+
try {
|
|
798
|
+
entry = JSON.parse(line);
|
|
799
|
+
} catch {
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
if (since && isPlainObject(entry) && typeof entry.ts === "string" && Date.parse(entry.ts) < Date.parse(since))
|
|
803
|
+
break;
|
|
804
|
+
matched += 1;
|
|
805
|
+
if (selected.length < limit) selected.push(entry);
|
|
806
|
+
}
|
|
807
|
+
return { entries: selected.reverse(), limit, ...(since ? { since } : {}), truncated: matched > limit };
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
811
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Shallow-merge `source` into `target`, with the convention that a `source` key whose value is
|
|
816
|
+
* `null` deletes that key from `target`. Nested objects are replaced wholesale (not deep-merged)
|
|
817
|
+
* so callers retain explicit control over substructure semantics; pre-existing skills that want
|
|
818
|
+
* to merge nested fields can supply the full sub-object themselves.
|
|
819
|
+
*/
|
|
820
|
+
function mergeWithNullDelete(
|
|
821
|
+
target: Record<string, unknown>,
|
|
822
|
+
source: Record<string, unknown>,
|
|
823
|
+
): Record<string, unknown> {
|
|
824
|
+
const result: Record<string, unknown> = { ...target };
|
|
825
|
+
for (const [key, value] of Object.entries(source)) {
|
|
826
|
+
if (value === null) {
|
|
827
|
+
delete result[key];
|
|
828
|
+
} else {
|
|
829
|
+
result[key] = value;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
return result;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
function nowIso(): string {
|
|
836
|
+
return new Date().toISOString();
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
function buildHudForMode(
|
|
840
|
+
mode: CanonicalJwcWorkflowSkill,
|
|
841
|
+
payload: Record<string, unknown>,
|
|
842
|
+
): WorkflowHudSummary | undefined {
|
|
843
|
+
const updatedAt = new Date().toISOString();
|
|
844
|
+
const phase = typeof payload.current_phase === "string" ? payload.current_phase : undefined;
|
|
845
|
+
const stateField = isPlainObject(payload.state) ? (payload.state as Record<string, unknown>) : {};
|
|
846
|
+
switch (mode) {
|
|
847
|
+
case "jaw-interview": {
|
|
848
|
+
const pick = <T>(key: string, guard: (value: unknown) => value is T): T | undefined => {
|
|
849
|
+
const v = (stateField as Record<string, unknown>)[key] ?? (payload as Record<string, unknown>)[key];
|
|
850
|
+
return guard(v) ? v : undefined;
|
|
851
|
+
};
|
|
852
|
+
const isNumber = (v: unknown): v is number => typeof v === "number";
|
|
853
|
+
const isString = (v: unknown): v is string => typeof v === "string";
|
|
854
|
+
const isArray = (v: unknown): v is unknown[] => Array.isArray(v);
|
|
855
|
+
const ambiguity = pick("current_ambiguity", isNumber);
|
|
856
|
+
const threshold = pick("threshold", isNumber);
|
|
857
|
+
const rounds = pick("rounds", isArray);
|
|
858
|
+
const targetComponent = pick("last_targeted_component_id", isString);
|
|
859
|
+
const weakestDimension = pick("weakest_dimension", isString);
|
|
860
|
+
// 99.04.03 — rounds rows may carry { ambiguity, dimensions: {goal..ontology: 0..3} }.
|
|
861
|
+
const lastRound = isPlainObject(rounds?.at(-1)) ? (rounds.at(-1) as Record<string, unknown>) : undefined;
|
|
862
|
+
const prevRound = isPlainObject(rounds?.at(-2)) ? (rounds.at(-2) as Record<string, unknown>) : undefined;
|
|
863
|
+
const dimensions = isPlainObject(lastRound?.dimensions)
|
|
864
|
+
? (lastRound.dimensions as { goal?: number; constraint?: number; success?: number; ontology?: number })
|
|
865
|
+
: undefined;
|
|
866
|
+
const lastAmbiguity = isNumber(lastRound?.ambiguity) ? lastRound.ambiguity : undefined;
|
|
867
|
+
const prevAmbiguity = isNumber(prevRound?.ambiguity) ? prevRound.ambiguity : undefined;
|
|
868
|
+
const ambiguityDelta =
|
|
869
|
+
lastAmbiguity !== undefined && prevAmbiguity !== undefined ? lastAmbiguity - prevAmbiguity : undefined;
|
|
870
|
+
return buildJawInterviewHudSummary({
|
|
871
|
+
phase,
|
|
872
|
+
ambiguity,
|
|
873
|
+
threshold,
|
|
874
|
+
roundCount: rounds?.length,
|
|
875
|
+
targetComponent,
|
|
876
|
+
weakestDimension,
|
|
877
|
+
dimensions,
|
|
878
|
+
ambiguityDelta,
|
|
879
|
+
updatedAt,
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
case "plan": {
|
|
883
|
+
const stage =
|
|
884
|
+
typeof payload.current_phase === "string"
|
|
885
|
+
? (payload.current_phase as string)
|
|
886
|
+
: typeof payload.mode === "string"
|
|
887
|
+
? (payload.mode as string)
|
|
888
|
+
: undefined;
|
|
889
|
+
const verdict = typeof payload.verdict === "string" ? (payload.verdict as string) : undefined;
|
|
890
|
+
const iteration = typeof payload.iteration === "number" ? (payload.iteration as number) : undefined;
|
|
891
|
+
const pendingApproval = payload.pending_approval === true || stage === "final";
|
|
892
|
+
return buildPlanphaseHudSummary({
|
|
893
|
+
stage,
|
|
894
|
+
verdict,
|
|
895
|
+
iteration,
|
|
896
|
+
pendingApproval,
|
|
897
|
+
updatedAt,
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
case "goal": {
|
|
901
|
+
const goals = Array.isArray(payload.goals)
|
|
902
|
+
? (payload.goals as Array<{ id?: string; title?: string; status?: string }>).filter(
|
|
903
|
+
g => g && typeof g.id === "string" && typeof g.title === "string" && typeof g.status === "string",
|
|
904
|
+
)
|
|
905
|
+
: [];
|
|
906
|
+
const counts: Record<string, number> = {};
|
|
907
|
+
for (const goal of goals) {
|
|
908
|
+
const status = goal.status as string;
|
|
909
|
+
counts[status] = (counts[status] ?? 0) + 1;
|
|
910
|
+
}
|
|
911
|
+
const currentGoalRaw = goals.find(g => g.status === "active") ?? goals.find(g => g.status === "pending");
|
|
912
|
+
const status = typeof payload.status === "string" ? (payload.status as string) : (phase ?? "pending");
|
|
913
|
+
return buildGoalHudSummary({
|
|
914
|
+
status,
|
|
915
|
+
currentGoal: currentGoalRaw
|
|
916
|
+
? {
|
|
917
|
+
id: currentGoalRaw.id as string,
|
|
918
|
+
title: currentGoalRaw.title as string,
|
|
919
|
+
status: currentGoalRaw.status as string,
|
|
920
|
+
}
|
|
921
|
+
: undefined,
|
|
922
|
+
counts,
|
|
923
|
+
goals: goals.map(g => ({ id: g.id as string, title: g.title as string, status: g.status as string })),
|
|
924
|
+
updatedAt,
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
case "team": {
|
|
928
|
+
const teamPhase = typeof payload.phase === "string" ? (payload.phase as string) : (phase ?? "running");
|
|
929
|
+
const taskCounts =
|
|
930
|
+
typeof payload.task_counts === "object" && payload.task_counts && !Array.isArray(payload.task_counts)
|
|
931
|
+
? (payload.task_counts as Record<string, number>)
|
|
932
|
+
: {};
|
|
933
|
+
const taskTotal = typeof payload.task_total === "number" ? (payload.task_total as number) : 0;
|
|
934
|
+
const workers = Array.isArray(payload.workers)
|
|
935
|
+
? (payload.workers as Array<{ id?: string; status?: string }>)
|
|
936
|
+
.filter(w => w && typeof w.id === "string")
|
|
937
|
+
.map(w => ({
|
|
938
|
+
id: w.id as string,
|
|
939
|
+
status: typeof w.status === "string" ? (w.status as string) : undefined,
|
|
940
|
+
}))
|
|
941
|
+
: [];
|
|
942
|
+
return buildTeamHudSummary({
|
|
943
|
+
phase: teamPhase,
|
|
944
|
+
task_total: taskTotal,
|
|
945
|
+
task_counts: taskCounts,
|
|
946
|
+
workers,
|
|
947
|
+
updated_at: updatedAt,
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
default:
|
|
951
|
+
return undefined;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
async function syncWorkflowSkillState(options: {
|
|
956
|
+
cwd: string;
|
|
957
|
+
mode: CanonicalJwcWorkflowSkill;
|
|
958
|
+
sessionId: string | undefined;
|
|
959
|
+
threadId?: string;
|
|
960
|
+
turnId?: string;
|
|
961
|
+
active: boolean;
|
|
962
|
+
phase: string | undefined;
|
|
963
|
+
payload: Record<string, unknown>;
|
|
964
|
+
receipt?: WorkflowStateReceipt;
|
|
965
|
+
}): Promise<void> {
|
|
966
|
+
try {
|
|
967
|
+
await syncSkillActiveState({
|
|
968
|
+
cwd: options.cwd,
|
|
969
|
+
skill: options.mode,
|
|
970
|
+
active: options.active,
|
|
971
|
+
phase: options.phase,
|
|
972
|
+
sessionId: options.sessionId,
|
|
973
|
+
threadId: options.threadId,
|
|
974
|
+
turnId: options.turnId,
|
|
975
|
+
source: "jwc-state-cli",
|
|
976
|
+
hud: buildHudForMode(options.mode, options.payload),
|
|
977
|
+
...(options.receipt ? { receipt: options.receipt } : {}),
|
|
978
|
+
});
|
|
979
|
+
} catch {
|
|
980
|
+
// HUD sync is best-effort and must not change command semantics.
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Reconcile a workflow skill's mode-state + active-state/HUD from a caller-derived
|
|
986
|
+
* payload. Unlike `jwc state write`, this is a derived repair: callers reconcile from
|
|
987
|
+
* an authoritative source (e.g. the goal plan/ledger), where intermediate
|
|
988
|
+
* aggregate phases like goal `active -> pending` are legitimate, so it bypasses
|
|
989
|
+
* ONLY verb transition-edge validation while preserving schema validation,
|
|
990
|
+
* unknown-phase rejection, version/checksum stamping, and audit/out-of-band tamper
|
|
991
|
+
* detection. Receipts carry `owner: "jwc-runtime"` and `verb: "reconcile"` so the
|
|
992
|
+
* provenance is distinguishable from a user-initiated write.
|
|
993
|
+
*/
|
|
994
|
+
export async function reconcileWorkflowSkillState(options: {
|
|
995
|
+
cwd: string;
|
|
996
|
+
mode: CanonicalJwcWorkflowSkill;
|
|
997
|
+
sessionId: string | undefined;
|
|
998
|
+
threadId?: string;
|
|
999
|
+
turnId?: string;
|
|
1000
|
+
active: boolean;
|
|
1001
|
+
phase: string;
|
|
1002
|
+
payload: Record<string, unknown>;
|
|
1003
|
+
}): Promise<{ stateFile: string }> {
|
|
1004
|
+
const { cwd, mode, sessionId, threadId, turnId, active, payload } = options;
|
|
1005
|
+
const filePath = modeStateFile(cwd, mode, sessionId);
|
|
1006
|
+
const existingRead = await readExistingStateForMutation(filePath);
|
|
1007
|
+
const existingPayload = existingRead.kind === "valid" ? existingRead.value : {};
|
|
1008
|
+
const nowIsoStr = nowIso();
|
|
1009
|
+
const mutationId = `${mode}:reconcile:${nowIsoStr}`;
|
|
1010
|
+
|
|
1011
|
+
const trimmedPhase = options.phase.trim();
|
|
1012
|
+
const manifestStates = new Set(getSkillManifest(mode).states.map(state => state.id));
|
|
1013
|
+
if (!manifestStates.has(trimmedPhase)) {
|
|
1014
|
+
throw new StateCommandError(2, `unknown ${mode} phase "${trimmedPhase}" for reconciliation`);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
const fromPhase =
|
|
1018
|
+
typeof existingPayload.current_phase === "string" ? existingPayload.current_phase.trim() : undefined;
|
|
1019
|
+
const receipt = buildWorkflowStateReceipt({
|
|
1020
|
+
cwd,
|
|
1021
|
+
skill: mode,
|
|
1022
|
+
owner: "jwc-runtime",
|
|
1023
|
+
command: `jwc ${mode} (reconcile)`,
|
|
1024
|
+
sessionId,
|
|
1025
|
+
nowIso: nowIsoStr,
|
|
1026
|
+
mutationId,
|
|
1027
|
+
});
|
|
1028
|
+
receipt.verb = "reconcile";
|
|
1029
|
+
receipt.forced = true;
|
|
1030
|
+
receipt.from_phase = fromPhase;
|
|
1031
|
+
receipt.to_phase = trimmedPhase;
|
|
1032
|
+
|
|
1033
|
+
const merged = mergeWithNullDelete(existingPayload, payload);
|
|
1034
|
+
merged.skill = mode;
|
|
1035
|
+
merged.current_phase = trimmedPhase;
|
|
1036
|
+
merged.active = active;
|
|
1037
|
+
merged.version = WORKFLOW_STATE_VERSION;
|
|
1038
|
+
merged.updated_at = nowIsoStr;
|
|
1039
|
+
merged.receipt = receipt;
|
|
1040
|
+
if (sessionId && typeof merged.session_id !== "string") merged.session_id = sessionId;
|
|
1041
|
+
|
|
1042
|
+
const validation = validateWorkflowStateEnvelope(mode, merged);
|
|
1043
|
+
if (!validation.valid) throw new StateCommandError(2, validation.error ?? `invalid ${mode} state envelope`);
|
|
1044
|
+
|
|
1045
|
+
await writeJsonAtomic(cwd, filePath, merged, "reconcile", {
|
|
1046
|
+
skill: mode,
|
|
1047
|
+
mutationId,
|
|
1048
|
+
force: true,
|
|
1049
|
+
fromPhase,
|
|
1050
|
+
toPhase: trimmedPhase,
|
|
1051
|
+
owner: "jwc-runtime",
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
// Reconciliation drives the active-state/HUD update directly (not via the
|
|
1055
|
+
// best-effort syncWorkflowSkillState wrapper) so a failed HUD/active-state write
|
|
1056
|
+
// is surfaced to the caller and recorded as a reconcile failure, rather than
|
|
1057
|
+
// silently leaving a stale chip behind a freshly reconciled mode-state.
|
|
1058
|
+
await syncSkillActiveState({
|
|
1059
|
+
cwd,
|
|
1060
|
+
skill: mode,
|
|
1061
|
+
active,
|
|
1062
|
+
phase: trimmedPhase,
|
|
1063
|
+
sessionId,
|
|
1064
|
+
threadId,
|
|
1065
|
+
turnId,
|
|
1066
|
+
source: "gjc-runtime-reconcile",
|
|
1067
|
+
hud: buildHudForMode(mode, merged),
|
|
1068
|
+
receipt,
|
|
1069
|
+
});
|
|
1070
|
+
return { stateFile: filePath };
|
|
1071
|
+
}
|
|
1072
|
+
export async function readWorkflowStateJson(
|
|
1073
|
+
cwd: string,
|
|
1074
|
+
skill: CanonicalJwcWorkflowSkill,
|
|
1075
|
+
sessionId?: string,
|
|
1076
|
+
): Promise<Record<string, unknown>> {
|
|
1077
|
+
const { state } = await readWorkflowModeStateJson(cwd, skill, sessionId);
|
|
1078
|
+
return state;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
async function handleRead(
|
|
1082
|
+
args: readonly string[],
|
|
1083
|
+
cwd: string,
|
|
1084
|
+
positionalSkill: string | undefined,
|
|
1085
|
+
): Promise<StateCommandResult> {
|
|
1086
|
+
const selectors = await resolveSelectors(args, cwd, positionalSkill);
|
|
1087
|
+
const mode = selectors.mode ?? (await inferModeFromActiveState(cwd, selectors.sessionId));
|
|
1088
|
+
const fields = parseFieldsFlag(args);
|
|
1089
|
+
if (mode) {
|
|
1090
|
+
const { state, storagePath } = await readWorkflowModeStateJson(cwd, mode, selectors.sessionId);
|
|
1091
|
+
const existing = state;
|
|
1092
|
+
const filePath = storagePath;
|
|
1093
|
+
const envelope = { skill: mode, state: existing, storage_path: filePath };
|
|
1094
|
+
const manifest = getSkillManifest(mode);
|
|
1095
|
+
if (fields) {
|
|
1096
|
+
const projected = projectStateFields(mode, envelope, manifest, fields);
|
|
1097
|
+
return {
|
|
1098
|
+
status: 0,
|
|
1099
|
+
stdout: hasFlag(args, "--json")
|
|
1100
|
+
? `${JSON.stringify(projected, null, 2)}\n`
|
|
1101
|
+
: renderStateMarkdown(mode, projected, manifest),
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
if (hasFlag(args, "--compact")) {
|
|
1105
|
+
const compact = compactProjectStateJson(mode, envelope, manifest);
|
|
1106
|
+
return {
|
|
1107
|
+
status: 0,
|
|
1108
|
+
stdout: hasFlag(args, "--json")
|
|
1109
|
+
? `${JSON.stringify(compact, null, 2)}\n`
|
|
1110
|
+
: renderStateMarkdown(mode, envelope, manifest),
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
return {
|
|
1114
|
+
status: 0,
|
|
1115
|
+
stdout: hasFlag(args, "--json")
|
|
1116
|
+
? `${JSON.stringify(envelope, null, 2)}\n`
|
|
1117
|
+
: renderStateMarkdown(mode, envelope, manifest),
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
if (selectors.sessionId) {
|
|
1121
|
+
throw new StateCommandError(
|
|
1122
|
+
2,
|
|
1123
|
+
"jwc state read requires --mode <skill>, positional <skill>, input.skill, or an active workflow in .jwc/state/skill-active-state.json",
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
const filePath = activeStateFile(cwd, selectors.sessionId);
|
|
1127
|
+
const existingRaw = await readJsonValue(filePath);
|
|
1128
|
+
const existing = isPlainObject(existingRaw) ? existingRaw : null;
|
|
1129
|
+
return { status: 0, stdout: `${JSON.stringify(existing ?? {}, null, 2)}\n` };
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
async function handleStatus(
|
|
1133
|
+
args: readonly string[],
|
|
1134
|
+
cwd: string,
|
|
1135
|
+
positionalSkill: string | undefined,
|
|
1136
|
+
): Promise<StateCommandResult> {
|
|
1137
|
+
const selectors = await resolveSelectors(args, cwd, positionalSkill);
|
|
1138
|
+
const mode = selectors.mode ?? (await inferModeFromActiveState(cwd, selectors.sessionId));
|
|
1139
|
+
if (!mode) {
|
|
1140
|
+
throw new StateCommandError(
|
|
1141
|
+
2,
|
|
1142
|
+
"jwc state status requires --mode <skill>, positional <skill>, input.skill, or an active workflow in .jwc/state/skill-active-state.json",
|
|
1143
|
+
);
|
|
1144
|
+
}
|
|
1145
|
+
const filePath = modeStateFile(cwd, mode, selectors.sessionId);
|
|
1146
|
+
const existing = await readWorkflowStateJson(cwd, mode, selectors.sessionId);
|
|
1147
|
+
const summary = buildStateStatusSummary(
|
|
1148
|
+
mode,
|
|
1149
|
+
{ skill: mode, state: existing, storage_path: filePath },
|
|
1150
|
+
getSkillManifest(mode),
|
|
1151
|
+
filePath,
|
|
1152
|
+
);
|
|
1153
|
+
return {
|
|
1154
|
+
status: 0,
|
|
1155
|
+
stdout: hasFlag(args, "--json") ? `${JSON.stringify(summary, null, 2)}\n` : renderStateStatusLine(summary),
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
async function handleWrite(
|
|
1160
|
+
args: readonly string[],
|
|
1161
|
+
cwd: string,
|
|
1162
|
+
positionalSkill: string | undefined,
|
|
1163
|
+
): Promise<StateCommandResult> {
|
|
1164
|
+
const selectors = await resolveSelectors(args, cwd, positionalSkill);
|
|
1165
|
+
const { sessionId, threadId, turnId, payload } = selectors;
|
|
1166
|
+
if (!payload) throw new StateCommandError(2, "jwc state write requires --input '<json>'");
|
|
1167
|
+
const mode = selectors.mode ?? (await inferModeFromActiveState(cwd, sessionId));
|
|
1168
|
+
if (!mode)
|
|
1169
|
+
throw new StateCommandError(
|
|
1170
|
+
2,
|
|
1171
|
+
"jwc state write requires --mode <skill>, positional <skill>, input.skill, or an active workflow in .jwc/state/skill-active-state.json",
|
|
1172
|
+
);
|
|
1173
|
+
|
|
1174
|
+
const filePath = modeStateFile(cwd, mode, sessionId);
|
|
1175
|
+
const forced = hasFlag(args, "--force");
|
|
1176
|
+
const existingRead = await readExistingStateForMutation(filePath);
|
|
1177
|
+
if (existingRead.kind === "corrupt" && !forced) {
|
|
1178
|
+
throw new StateCommandError(
|
|
1179
|
+
2,
|
|
1180
|
+
`existing state for ${mode} is corrupt or tampered (${existingRead.error}); use --force to overwrite`,
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
const existingPayload = existingRead.kind === "valid" ? existingRead.value : {};
|
|
1184
|
+
const nowIsoStr = nowIso();
|
|
1185
|
+
const mutationId = `${mode}:${nowIsoStr}`;
|
|
1186
|
+
const receipt = buildWorkflowStateReceipt({
|
|
1187
|
+
cwd,
|
|
1188
|
+
skill: mode,
|
|
1189
|
+
owner: "jwc-state-cli",
|
|
1190
|
+
command: `jwc state ${mode} write`,
|
|
1191
|
+
sessionId,
|
|
1192
|
+
nowIso: nowIsoStr,
|
|
1193
|
+
mutationId,
|
|
1194
|
+
});
|
|
1195
|
+
const innerState = (payload.state as Record<string, unknown> | undefined) ?? {};
|
|
1196
|
+
const incomingPhase =
|
|
1197
|
+
typeof payload.current_phase === "string" && payload.current_phase.trim()
|
|
1198
|
+
? payload.current_phase.trim()
|
|
1199
|
+
: typeof payload.phase === "string" && payload.phase.trim()
|
|
1200
|
+
? payload.phase.trim()
|
|
1201
|
+
: typeof innerState.current_phase === "string" && (innerState.current_phase as string).trim()
|
|
1202
|
+
? (innerState.current_phase as string).trim()
|
|
1203
|
+
: undefined;
|
|
1204
|
+
let merged: Record<string, unknown>;
|
|
1205
|
+
if (hasFlag(args, "--replace")) {
|
|
1206
|
+
merged = { ...payload };
|
|
1207
|
+
} else {
|
|
1208
|
+
merged = mergeWithNullDelete(existingPayload, payload);
|
|
1209
|
+
// Flatten payload.state.* into the top-level envelope so downstream consumers
|
|
1210
|
+
// see a single canonical structure with the receipt at top level.
|
|
1211
|
+
if (payload.state && typeof payload.state === "object" && !Array.isArray(payload.state)) {
|
|
1212
|
+
merged = mergeWithNullDelete(merged, payload.state as Record<string, unknown>);
|
|
1213
|
+
delete merged.state;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
const preDefaultValidation = validateWorkflowStateEnvelope(mode, merged);
|
|
1217
|
+
if (!preDefaultValidation.valid) {
|
|
1218
|
+
throw new StateCommandError(2, preDefaultValidation.error ?? `invalid ${mode} state envelope`);
|
|
1219
|
+
}
|
|
1220
|
+
merged.skill = mode;
|
|
1221
|
+
if (incomingPhase) {
|
|
1222
|
+
merged.current_phase = incomingPhase;
|
|
1223
|
+
} else if (typeof merged.current_phase !== "string" || !merged.current_phase.trim()) {
|
|
1224
|
+
const retainedPhase =
|
|
1225
|
+
typeof existingPayload.current_phase === "string" ? existingPayload.current_phase.trim() : "";
|
|
1226
|
+
merged.current_phase = retainedPhase || initialPhaseForSkill(mode);
|
|
1227
|
+
} else {
|
|
1228
|
+
merged.current_phase = merged.current_phase.trim();
|
|
1229
|
+
}
|
|
1230
|
+
merged.version = WORKFLOW_STATE_VERSION;
|
|
1231
|
+
if (typeof merged.active !== "boolean") merged.active = true;
|
|
1232
|
+
merged.updated_at = nowIsoStr;
|
|
1233
|
+
merged.receipt = receipt;
|
|
1234
|
+
if (sessionId && typeof merged.session_id !== "string") merged.session_id = sessionId;
|
|
1235
|
+
|
|
1236
|
+
const fromPhase =
|
|
1237
|
+
typeof existingPayload.current_phase === "string" ? existingPayload.current_phase.trim() : undefined;
|
|
1238
|
+
const toPhase = merged.current_phase as string;
|
|
1239
|
+
const manifestStates = new Set(getSkillManifest(mode).states.map(state => state.id));
|
|
1240
|
+
if (!manifestStates.has(toPhase) && !forced) {
|
|
1241
|
+
throw new StateCommandError(2, `unknown ${mode} phase "${toPhase}"; use --force to bypass`);
|
|
1242
|
+
}
|
|
1243
|
+
if (fromPhase && toPhase && isKnownWorkflowState(mode, fromPhase) && isKnownWorkflowState(mode, toPhase)) {
|
|
1244
|
+
if (!isValidTransition(mode, fromPhase, toPhase) && !forced) {
|
|
1245
|
+
throw new StateCommandError(
|
|
1246
|
+
2,
|
|
1247
|
+
`invalid ${mode} phase transition from ${fromPhase} to ${toPhase}; use --force to bypass`,
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
const validation = validateWorkflowStateEnvelope(mode, merged);
|
|
1253
|
+
if (!validation.valid) throw new StateCommandError(2, validation.error ?? `invalid ${mode} state envelope`);
|
|
1254
|
+
|
|
1255
|
+
const { warning: outOfBandWarning, stamped } = await writeJsonAtomic(cwd, filePath, merged, "write", {
|
|
1256
|
+
skill: mode,
|
|
1257
|
+
mutationId,
|
|
1258
|
+
force: forced,
|
|
1259
|
+
fromPhase,
|
|
1260
|
+
toPhase,
|
|
1261
|
+
});
|
|
1262
|
+
const stampedReceipt = isPlainObject(stamped.receipt) ? stamped.receipt : {};
|
|
1263
|
+
|
|
1264
|
+
const phase = typeof merged.current_phase === "string" ? merged.current_phase : undefined;
|
|
1265
|
+
const active = merged.active !== false;
|
|
1266
|
+
await syncWorkflowSkillState({ cwd, mode, sessionId, threadId, turnId, active, phase, payload: merged, receipt });
|
|
1267
|
+
|
|
1268
|
+
return {
|
|
1269
|
+
status: 0,
|
|
1270
|
+
stdout: renderCliWriteReceipt({
|
|
1271
|
+
ok: true,
|
|
1272
|
+
skill: mode,
|
|
1273
|
+
state_path: filePath,
|
|
1274
|
+
current_phase: phase,
|
|
1275
|
+
active,
|
|
1276
|
+
mutation_id: typeof stampedReceipt.mutation_id === "string" ? stampedReceipt.mutation_id : mutationId,
|
|
1277
|
+
status: typeof stampedReceipt.status === "string" ? stampedReceipt.status : undefined,
|
|
1278
|
+
content_sha256: stampedReceipt.content_sha256,
|
|
1279
|
+
}),
|
|
1280
|
+
...(outOfBandWarning ? { stderr: `${outOfBandWarning}\n` } : {}),
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
async function handleClear(
|
|
1285
|
+
args: readonly string[],
|
|
1286
|
+
cwd: string,
|
|
1287
|
+
positionalSkill: string | undefined,
|
|
1288
|
+
): Promise<StateCommandResult> {
|
|
1289
|
+
const selectors = await resolveSelectors(args, cwd, positionalSkill);
|
|
1290
|
+
const { sessionId, threadId, turnId } = selectors;
|
|
1291
|
+
const mode = selectors.mode ?? (await inferModeFromActiveState(cwd, sessionId));
|
|
1292
|
+
if (!mode)
|
|
1293
|
+
throw new StateCommandError(
|
|
1294
|
+
2,
|
|
1295
|
+
"jwc state clear requires --mode <skill>, positional <skill>, input.skill, or an active workflow in .jwc/state/skill-active-state.json",
|
|
1296
|
+
);
|
|
1297
|
+
|
|
1298
|
+
const filePath = modeStateFile(cwd, mode, sessionId);
|
|
1299
|
+
const forced = hasFlag(args, "--force");
|
|
1300
|
+
const existingRead = await readExistingStateForMutation(filePath);
|
|
1301
|
+
if (existingRead.kind === "corrupt" && !forced) {
|
|
1302
|
+
throw new StateCommandError(
|
|
1303
|
+
2,
|
|
1304
|
+
`existing state for ${mode} is corrupt or tampered (${existingRead.error}); use --force to overwrite`,
|
|
1305
|
+
);
|
|
1306
|
+
}
|
|
1307
|
+
const existing = existingRead.kind === "valid" ? existingRead.value : {};
|
|
1308
|
+
const clearedAt = nowIso();
|
|
1309
|
+
const cleared: Record<string, unknown> = {
|
|
1310
|
+
skill: mode,
|
|
1311
|
+
...existing,
|
|
1312
|
+
active: false,
|
|
1313
|
+
current_phase: "complete",
|
|
1314
|
+
updated_at: clearedAt,
|
|
1315
|
+
version: WORKFLOW_STATE_VERSION,
|
|
1316
|
+
};
|
|
1317
|
+
cleared.skill = mode;
|
|
1318
|
+
const mutationId = `${mode}:clear:${clearedAt}`;
|
|
1319
|
+
const receipt = buildWorkflowStateReceipt({
|
|
1320
|
+
cwd,
|
|
1321
|
+
skill: mode,
|
|
1322
|
+
owner: "jwc-state-cli",
|
|
1323
|
+
command: `jwc state ${mode} clear`,
|
|
1324
|
+
sessionId,
|
|
1325
|
+
nowIso: clearedAt,
|
|
1326
|
+
mutationId,
|
|
1327
|
+
});
|
|
1328
|
+
cleared.receipt = receipt;
|
|
1329
|
+
const { warning: outOfBandWarning, stamped } = await writeJsonAtomic(cwd, filePath, cleared, "clear", {
|
|
1330
|
+
skill: mode,
|
|
1331
|
+
mutationId,
|
|
1332
|
+
force: forced,
|
|
1333
|
+
fromPhase: typeof existing.current_phase === "string" ? existing.current_phase : undefined,
|
|
1334
|
+
toPhase: "complete",
|
|
1335
|
+
});
|
|
1336
|
+
const stampedReceipt = isPlainObject(stamped.receipt) ? stamped.receipt : {};
|
|
1337
|
+
|
|
1338
|
+
await syncWorkflowSkillState({
|
|
1339
|
+
cwd,
|
|
1340
|
+
mode,
|
|
1341
|
+
sessionId,
|
|
1342
|
+
threadId,
|
|
1343
|
+
turnId,
|
|
1344
|
+
active: false,
|
|
1345
|
+
phase: "complete",
|
|
1346
|
+
payload: cleared,
|
|
1347
|
+
});
|
|
1348
|
+
return {
|
|
1349
|
+
status: 0,
|
|
1350
|
+
stdout: renderCliWriteReceipt({
|
|
1351
|
+
ok: true,
|
|
1352
|
+
skill: mode,
|
|
1353
|
+
state_path: filePath,
|
|
1354
|
+
active: false,
|
|
1355
|
+
current_phase: typeof cleared.current_phase === "string" ? cleared.current_phase : undefined,
|
|
1356
|
+
mutation_id: typeof stampedReceipt.mutation_id === "string" ? stampedReceipt.mutation_id : mutationId,
|
|
1357
|
+
status: typeof stampedReceipt.status === "string" ? stampedReceipt.status : undefined,
|
|
1358
|
+
content_sha256: stampedReceipt.content_sha256,
|
|
1359
|
+
}),
|
|
1360
|
+
...(outOfBandWarning ? { stderr: `${outOfBandWarning}\n` } : {}),
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* `handoff` exists in two distinct roles:
|
|
1366
|
+
* - As a verb: this CLI action, which atomically transitions caller→callee.
|
|
1367
|
+
* Writes the callee mode-state first, the caller mode-state second, then
|
|
1368
|
+
* syncs both `skill-active-state.json` files. Every intermediate crashed
|
|
1369
|
+
* state remains HUD-coherent: the active-state file either reflects the
|
|
1370
|
+
* old skill entirely or the new skill entirely, never both as active.
|
|
1371
|
+
* - As a phase: `current_phase: "handoff"` is set by this verb when demoting
|
|
1372
|
+
* the caller. Agents writing `current_phase: "handoff"` manually via
|
|
1373
|
+
* `jwc state <skill> write` are declaring "I am ready to be handed off";
|
|
1374
|
+
* the next agent-initiated `skill` tool call will then satisfy the phase
|
|
1375
|
+
* guard and may chain.
|
|
1376
|
+
*
|
|
1377
|
+
* `handoff` is in the terminal-phase set used by `isTerminalModeState` and by
|
|
1378
|
+
* the skill tool's chain guard. A manual `current_phase: "handoff"` write does
|
|
1379
|
+
* NOT mark `active: false` — only this verb does that — so a skill that wrote
|
|
1380
|
+
* the phase remains in `skill-active-state.json` until a chain call (or
|
|
1381
|
+
* explicit `clear`) demotes it.
|
|
1382
|
+
*/
|
|
1383
|
+
async function handleHandoff(
|
|
1384
|
+
args: readonly string[],
|
|
1385
|
+
cwd: string,
|
|
1386
|
+
positionalSkill: string | undefined,
|
|
1387
|
+
): Promise<StateCommandResult> {
|
|
1388
|
+
const selectors = await resolveSelectors(args, cwd, positionalSkill);
|
|
1389
|
+
const { sessionId, threadId, turnId } = selectors;
|
|
1390
|
+
const caller = selectors.mode ?? (await inferModeFromActiveState(cwd, sessionId));
|
|
1391
|
+
if (!caller) {
|
|
1392
|
+
throw new StateCommandError(
|
|
1393
|
+
2,
|
|
1394
|
+
"jwc state handoff requires --mode <caller>, positional <caller>, input.skill, or an active workflow in .jwc/state/skill-active-state.json",
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
const calleeRaw = flagValue(args, "--to")?.trim();
|
|
1398
|
+
if (!calleeRaw) {
|
|
1399
|
+
throw new StateCommandError(2, "jwc state handoff requires --to <callee>");
|
|
1400
|
+
}
|
|
1401
|
+
const calleeNormalized = normalizeWorkflowSkillSlug(calleeRaw);
|
|
1402
|
+
assertKnownMode(calleeNormalized);
|
|
1403
|
+
const callee = calleeNormalized;
|
|
1404
|
+
if (callee === caller) {
|
|
1405
|
+
throw new StateCommandError(2, `jwc state handoff: --to must differ from caller (both are "${caller}")`);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
const callerPath = modeStateFile(cwd, caller, sessionId);
|
|
1409
|
+
const calleePath = modeStateFile(cwd, callee, sessionId);
|
|
1410
|
+
const forced = hasFlag(args, "--force");
|
|
1411
|
+
const callerRead = await readExistingStateForMutation(callerPath);
|
|
1412
|
+
if (callerRead.kind === "corrupt" && !forced) {
|
|
1413
|
+
throw new StateCommandError(
|
|
1414
|
+
2,
|
|
1415
|
+
`existing state for ${caller} is corrupt or tampered (${callerRead.error}); use --force to overwrite`,
|
|
1416
|
+
);
|
|
1417
|
+
}
|
|
1418
|
+
if (callerRead.kind === "absent") {
|
|
1419
|
+
throw new StateCommandError(
|
|
1420
|
+
2,
|
|
1421
|
+
`jwc state ${caller} handoff: caller is not active (no mode-state file at ${callerPath})`,
|
|
1422
|
+
);
|
|
1423
|
+
}
|
|
1424
|
+
const calleeRead = await readExistingStateForMutation(calleePath);
|
|
1425
|
+
if (calleeRead.kind === "corrupt" && !forced) {
|
|
1426
|
+
throw new StateCommandError(
|
|
1427
|
+
2,
|
|
1428
|
+
`existing state for ${callee} is corrupt or tampered (${calleeRead.error}); use --force to overwrite`,
|
|
1429
|
+
);
|
|
1430
|
+
}
|
|
1431
|
+
const existingCaller = callerRead.kind === "valid" ? callerRead.value : {};
|
|
1432
|
+
const existingCallee = calleeRead.kind === "valid" ? calleeRead.value : {};
|
|
1433
|
+
|
|
1434
|
+
const handoffAt = nowIso();
|
|
1435
|
+
const mutationId = `${caller}:handoff:${callee}:${handoffAt}`;
|
|
1436
|
+
const callerReceipt = buildWorkflowStateReceipt({
|
|
1437
|
+
cwd,
|
|
1438
|
+
skill: caller,
|
|
1439
|
+
owner: "jwc-state-cli",
|
|
1440
|
+
command: `jwc state ${caller} handoff --to ${callee}`,
|
|
1441
|
+
sessionId,
|
|
1442
|
+
nowIso: handoffAt,
|
|
1443
|
+
mutationId,
|
|
1444
|
+
});
|
|
1445
|
+
const calleeReceipt = buildWorkflowStateReceipt({
|
|
1446
|
+
cwd,
|
|
1447
|
+
skill: callee,
|
|
1448
|
+
owner: "jwc-state-cli",
|
|
1449
|
+
command: `jwc state ${caller} handoff --to ${callee}`,
|
|
1450
|
+
sessionId,
|
|
1451
|
+
nowIso: handoffAt,
|
|
1452
|
+
mutationId,
|
|
1453
|
+
});
|
|
1454
|
+
|
|
1455
|
+
const calleeInitial = initialPhaseForSkill(callee);
|
|
1456
|
+
const normalizedCaller = migrateWorkflowState(existingCaller, caller).state;
|
|
1457
|
+
const normalizedCallee = migrateWorkflowState(existingCallee, callee).state;
|
|
1458
|
+
const mergedCalleeState: Record<string, unknown> = {
|
|
1459
|
+
...normalizedCallee,
|
|
1460
|
+
skill: callee,
|
|
1461
|
+
version: WORKFLOW_STATE_VERSION,
|
|
1462
|
+
active: true,
|
|
1463
|
+
current_phase: calleeInitial,
|
|
1464
|
+
handoff_from: caller,
|
|
1465
|
+
handoff_at: handoffAt,
|
|
1466
|
+
updated_at: handoffAt,
|
|
1467
|
+
receipt: calleeReceipt,
|
|
1468
|
+
};
|
|
1469
|
+
if (sessionId && typeof mergedCalleeState.session_id !== "string") {
|
|
1470
|
+
mergedCalleeState.session_id = sessionId;
|
|
1471
|
+
}
|
|
1472
|
+
const mergedCallerState: Record<string, unknown> = {
|
|
1473
|
+
...normalizedCaller,
|
|
1474
|
+
skill: caller,
|
|
1475
|
+
version: WORKFLOW_STATE_VERSION,
|
|
1476
|
+
active: false,
|
|
1477
|
+
current_phase: "handoff",
|
|
1478
|
+
handoff_to: callee,
|
|
1479
|
+
handoff_at: handoffAt,
|
|
1480
|
+
updated_at: handoffAt,
|
|
1481
|
+
receipt: callerReceipt,
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1484
|
+
await beginWorkflowTransactionJournal({
|
|
1485
|
+
cwd,
|
|
1486
|
+
mutationId,
|
|
1487
|
+
caller,
|
|
1488
|
+
callee,
|
|
1489
|
+
paths: [calleePath, callerPath, activeStateFile(cwd, sessionId)],
|
|
1490
|
+
});
|
|
1491
|
+
|
|
1492
|
+
// Atomic write order (architecture blocker AR-3): mode-state files first,
|
|
1493
|
+
// then a single atomic active-state mutation per file (session before root)
|
|
1494
|
+
// via applyHandoffToActiveState. The single-write transaction prevents the
|
|
1495
|
+
// HUD from observing a window where neither caller nor callee is active,
|
|
1496
|
+
// and write order keeps the session-scoped source of truth ahead of the
|
|
1497
|
+
// root aggregate. strict:true on the active-state read tolerates ENOENT
|
|
1498
|
+
// only; corrupt JSON / IO failures propagate as non-zero CLI status.
|
|
1499
|
+
const force = hasFlag(args, "--force");
|
|
1500
|
+
const calleeWrite = await writeJsonAtomic(cwd, calleePath, mergedCalleeState, "handoff", {
|
|
1501
|
+
skill: callee,
|
|
1502
|
+
mutationId,
|
|
1503
|
+
force,
|
|
1504
|
+
fromPhase: typeof existingCallee.current_phase === "string" ? existingCallee.current_phase : undefined,
|
|
1505
|
+
toPhase: calleeInitial,
|
|
1506
|
+
});
|
|
1507
|
+
await updateWorkflowTransactionJournal(cwd, mutationId, { steps: ["callee-mode-state"] });
|
|
1508
|
+
const callerWrite = await writeJsonAtomic(cwd, callerPath, mergedCallerState, "handoff", {
|
|
1509
|
+
skill: caller,
|
|
1510
|
+
mutationId,
|
|
1511
|
+
force,
|
|
1512
|
+
fromPhase: typeof existingCaller.current_phase === "string" ? existingCaller.current_phase : undefined,
|
|
1513
|
+
toPhase: "handoff",
|
|
1514
|
+
});
|
|
1515
|
+
await updateWorkflowTransactionJournal(cwd, mutationId, {
|
|
1516
|
+
steps: ["callee-mode-state", "caller-mode-state"],
|
|
1517
|
+
});
|
|
1518
|
+
const warnings = [calleeWrite.warning, callerWrite.warning].filter(
|
|
1519
|
+
(warning): warning is string => typeof warning === "string",
|
|
1520
|
+
);
|
|
1521
|
+
const stampedCallerReceipt = isPlainObject(callerWrite.stamped.receipt) ? callerWrite.stamped.receipt : {};
|
|
1522
|
+
const stampedCalleeReceipt = isPlainObject(calleeWrite.stamped.receipt) ? calleeWrite.stamped.receipt : {};
|
|
1523
|
+
for (const warning of warnings) process.stderr.write(`${warning}\n`);
|
|
1524
|
+
if (process.env.GJC_STATE_HANDOFF_FAIL_AFTER_CALLER === mutationId) {
|
|
1525
|
+
throw new StateCommandError(1, `injected handoff failure after caller write for ${mutationId}`);
|
|
1526
|
+
}
|
|
1527
|
+
await applyHandoffToActiveState({
|
|
1528
|
+
cwd,
|
|
1529
|
+
nowIso: handoffAt,
|
|
1530
|
+
strict: true,
|
|
1531
|
+
caller: {
|
|
1532
|
+
cwd,
|
|
1533
|
+
skill: caller,
|
|
1534
|
+
active: false,
|
|
1535
|
+
phase: "handoff",
|
|
1536
|
+
sessionId,
|
|
1537
|
+
threadId,
|
|
1538
|
+
turnId,
|
|
1539
|
+
source: "jwc-state-cli",
|
|
1540
|
+
hud: buildHudForMode(caller, mergedCallerState),
|
|
1541
|
+
handoff_to: callee,
|
|
1542
|
+
handoff_at: handoffAt,
|
|
1543
|
+
receipt: callerReceipt,
|
|
1544
|
+
},
|
|
1545
|
+
callee: {
|
|
1546
|
+
cwd,
|
|
1547
|
+
skill: callee,
|
|
1548
|
+
active: true,
|
|
1549
|
+
phase: calleeInitial,
|
|
1550
|
+
sessionId,
|
|
1551
|
+
threadId,
|
|
1552
|
+
turnId,
|
|
1553
|
+
source: "jwc-state-cli",
|
|
1554
|
+
hud: buildHudForMode(callee, mergedCalleeState),
|
|
1555
|
+
handoff_from: caller,
|
|
1556
|
+
handoff_at: handoffAt,
|
|
1557
|
+
receipt: calleeReceipt,
|
|
1558
|
+
},
|
|
1559
|
+
});
|
|
1560
|
+
await updateWorkflowTransactionJournal(cwd, mutationId, {
|
|
1561
|
+
steps: ["callee-mode-state", "caller-mode-state", "active-state"],
|
|
1562
|
+
});
|
|
1563
|
+
await completeWorkflowTransactionJournal(cwd, mutationId);
|
|
1564
|
+
|
|
1565
|
+
return {
|
|
1566
|
+
status: 0,
|
|
1567
|
+
stdout: renderCliWriteReceipt({
|
|
1568
|
+
ok: true,
|
|
1569
|
+
from: caller,
|
|
1570
|
+
to: callee,
|
|
1571
|
+
handoff_at: handoffAt,
|
|
1572
|
+
phases: {
|
|
1573
|
+
from: mergedCallerState.current_phase,
|
|
1574
|
+
to: mergedCalleeState.current_phase,
|
|
1575
|
+
},
|
|
1576
|
+
receipts: {
|
|
1577
|
+
from: {
|
|
1578
|
+
mutation_id: stampedCallerReceipt.mutation_id,
|
|
1579
|
+
status: stampedCallerReceipt.status,
|
|
1580
|
+
content_sha256: stampedCallerReceipt.content_sha256,
|
|
1581
|
+
},
|
|
1582
|
+
to: {
|
|
1583
|
+
mutation_id: stampedCalleeReceipt.mutation_id,
|
|
1584
|
+
status: stampedCalleeReceipt.status,
|
|
1585
|
+
content_sha256: stampedCalleeReceipt.content_sha256,
|
|
1586
|
+
},
|
|
1587
|
+
},
|
|
1588
|
+
paths: {
|
|
1589
|
+
from: callerPath,
|
|
1590
|
+
to: calleePath,
|
|
1591
|
+
active_state: activeStateFile(cwd, sessionId),
|
|
1592
|
+
},
|
|
1593
|
+
}),
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
async function handleContract(
|
|
1598
|
+
args: readonly string[],
|
|
1599
|
+
cwd: string,
|
|
1600
|
+
positionalSkill: string | undefined,
|
|
1601
|
+
): Promise<StateCommandResult> {
|
|
1602
|
+
const { mode } = await resolveSelectors(args, cwd, positionalSkill);
|
|
1603
|
+
if (!mode) {
|
|
1604
|
+
throw new StateCommandError(2, "jwc state contract requires --mode <skill>, positional <skill>, or input.skill");
|
|
1605
|
+
}
|
|
1606
|
+
const payload = { skill: mode, contract: describeWorkflowStateContract(mode) };
|
|
1607
|
+
return {
|
|
1608
|
+
status: 0,
|
|
1609
|
+
stdout: hasFlag(args, "--json")
|
|
1610
|
+
? `${JSON.stringify(payload, null, 2)}\n`
|
|
1611
|
+
: renderContractMarkdown(mode, payload.contract),
|
|
1612
|
+
};
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
function parseNonNegativeIntegerFlag(args: readonly string[], flag: string): number | undefined {
|
|
1616
|
+
const value = flagValue(args, flag);
|
|
1617
|
+
if (value === undefined) return undefined;
|
|
1618
|
+
const parsed = Number(value);
|
|
1619
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
1620
|
+
throw new StateCommandError(2, `jwc state ${flag} requires a non-negative integer value`);
|
|
1621
|
+
}
|
|
1622
|
+
return parsed;
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
function statusFromFile(value: unknown): string | undefined {
|
|
1626
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return undefined;
|
|
1627
|
+
const record = value as Record<string, unknown>;
|
|
1628
|
+
if (typeof record.status === "string") return record.status;
|
|
1629
|
+
if (record.receipt && typeof record.receipt === "object" && !Array.isArray(record.receipt)) {
|
|
1630
|
+
const receiptStatus = (record.receipt as Record<string, unknown>).status;
|
|
1631
|
+
if (typeof receiptStatus === "string") return receiptStatus;
|
|
1632
|
+
}
|
|
1633
|
+
return undefined;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
interface RetentionCandidate {
|
|
1637
|
+
path: string;
|
|
1638
|
+
relativePath: string;
|
|
1639
|
+
category: string;
|
|
1640
|
+
mtimeMs: number;
|
|
1641
|
+
policy: { keep?: number; maxAgeDays?: number };
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
interface GcSummary {
|
|
1645
|
+
skill: CanonicalJwcWorkflowSkill | "all";
|
|
1646
|
+
dry_run: boolean;
|
|
1647
|
+
eligible: string[];
|
|
1648
|
+
pruned: string[];
|
|
1649
|
+
counts: Record<string, number>;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
function categoryForStateRelativePath(relativePath: string): string | undefined {
|
|
1653
|
+
const normalized = relativePath.split(path.sep).join("/");
|
|
1654
|
+
if (normalized === "audit.jsonl") return undefined;
|
|
1655
|
+
if (normalized === SKILL_ACTIVE_STATE_FILE || normalized.endsWith(`/${SKILL_ACTIVE_STATE_FILE}`)) return undefined;
|
|
1656
|
+
if (normalized.startsWith("active/") || normalized.includes("/active/")) return undefined;
|
|
1657
|
+
if (
|
|
1658
|
+
/^[^/]+-state\.json$/.test(normalized) ||
|
|
1659
|
+
(normalized.includes("/sessions/") && /\/[^/]+-state\.json$/.test(normalized))
|
|
1660
|
+
)
|
|
1661
|
+
return undefined;
|
|
1662
|
+
if (normalized.startsWith("artifacts/") || normalized.includes("/artifacts/")) return "artifact";
|
|
1663
|
+
if (
|
|
1664
|
+
normalized.startsWith("logs/") ||
|
|
1665
|
+
normalized.includes("/logs/") ||
|
|
1666
|
+
normalized.endsWith(".log") ||
|
|
1667
|
+
normalized.endsWith(".jsonl")
|
|
1668
|
+
)
|
|
1669
|
+
return "log";
|
|
1670
|
+
if (normalized.startsWith("reports/") || normalized.includes("/reports/")) return "report";
|
|
1671
|
+
if (normalized.startsWith("ledgers/") || normalized.includes("/ledgers/")) return "ledger";
|
|
1672
|
+
if (normalized.startsWith("agents/") || normalized.includes("/agents/")) return "agents";
|
|
1673
|
+
if (normalized.startsWith("force/") || normalized.includes("/force/")) return "force";
|
|
1674
|
+
if (
|
|
1675
|
+
normalized.startsWith("prune/") ||
|
|
1676
|
+
normalized.includes("/prune/") ||
|
|
1677
|
+
normalized.startsWith("delete/") ||
|
|
1678
|
+
normalized.includes("/delete/")
|
|
1679
|
+
)
|
|
1680
|
+
return "prune/delete";
|
|
1681
|
+
if (normalized.startsWith("transactions/") || normalized.includes("/transactions/")) return "prune/delete";
|
|
1682
|
+
return undefined;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
async function collectRetentionCandidates(
|
|
1686
|
+
cwd: string,
|
|
1687
|
+
skills: readonly CanonicalJwcWorkflowSkill[],
|
|
1688
|
+
): Promise<RetentionCandidate[]> {
|
|
1689
|
+
const stateRoot = path.join(cwd, ".jwc", "state");
|
|
1690
|
+
const policies = new Map<string, { keep?: number; maxAgeDays?: number }>();
|
|
1691
|
+
for (const skill of skills) {
|
|
1692
|
+
for (const policy of getSkillManifest(skill).retention) {
|
|
1693
|
+
const existing = policies.get(policy.category);
|
|
1694
|
+
policies.set(policy.category, {
|
|
1695
|
+
keep: Math.max(existing?.keep ?? 0, policy.keep ?? 0) || undefined,
|
|
1696
|
+
maxAgeDays:
|
|
1697
|
+
existing?.maxAgeDays === undefined
|
|
1698
|
+
? policy.maxAgeDays
|
|
1699
|
+
: policy.maxAgeDays === undefined
|
|
1700
|
+
? existing.maxAgeDays
|
|
1701
|
+
: Math.max(existing.maxAgeDays, policy.maxAgeDays),
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
const candidates: RetentionCandidate[] = [];
|
|
1706
|
+
async function visit(dir: string): Promise<void> {
|
|
1707
|
+
let entries: string[];
|
|
1708
|
+
try {
|
|
1709
|
+
entries = await fs.readdir(dir);
|
|
1710
|
+
} catch (error) {
|
|
1711
|
+
const err = error as NodeJS.ErrnoException;
|
|
1712
|
+
if (err.code === "ENOENT") return;
|
|
1713
|
+
throw error;
|
|
1714
|
+
}
|
|
1715
|
+
for (const entry of entries) {
|
|
1716
|
+
const filePath = path.join(dir, entry);
|
|
1717
|
+
const stat = await fs.stat(filePath);
|
|
1718
|
+
if (stat.isDirectory()) {
|
|
1719
|
+
await visit(filePath);
|
|
1720
|
+
continue;
|
|
1721
|
+
}
|
|
1722
|
+
if (!stat.isFile()) continue;
|
|
1723
|
+
const relativePath = path.relative(stateRoot, filePath);
|
|
1724
|
+
const category = categoryForStateRelativePath(relativePath);
|
|
1725
|
+
if (!category) continue;
|
|
1726
|
+
const policy = policies.get(category);
|
|
1727
|
+
if (!policy) continue;
|
|
1728
|
+
candidates.push({ path: filePath, relativePath, category, mtimeMs: stat.mtimeMs, policy });
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
await visit(stateRoot);
|
|
1732
|
+
return candidates;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
function selectRetentionEligible(candidates: readonly RetentionCandidate[]): RetentionCandidate[] {
|
|
1736
|
+
const now = Date.now();
|
|
1737
|
+
const byCategory = new Map<string, RetentionCandidate[]>();
|
|
1738
|
+
for (const candidate of candidates) {
|
|
1739
|
+
const list = byCategory.get(candidate.category) ?? [];
|
|
1740
|
+
list.push(candidate);
|
|
1741
|
+
byCategory.set(candidate.category, list);
|
|
1742
|
+
}
|
|
1743
|
+
const eligible = new Set<RetentionCandidate>();
|
|
1744
|
+
for (const list of byCategory.values()) {
|
|
1745
|
+
list.sort((a, b) => b.mtimeMs - a.mtimeMs || a.relativePath.localeCompare(b.relativePath));
|
|
1746
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
1747
|
+
const candidate = list[index];
|
|
1748
|
+
const keep = candidate.policy.keep ?? 0;
|
|
1749
|
+
if (keep > 0 && index < keep) continue;
|
|
1750
|
+
if (candidate.policy.maxAgeDays !== undefined) {
|
|
1751
|
+
const maxAgeMs = candidate.policy.maxAgeDays * 24 * 60 * 60 * 1000;
|
|
1752
|
+
if (now - candidate.mtimeMs < maxAgeMs) continue;
|
|
1753
|
+
}
|
|
1754
|
+
if (candidate.policy.keep !== undefined || candidate.policy.maxAgeDays !== undefined) eligible.add(candidate);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
return [...eligible].sort((a, b) => a.relativePath.localeCompare(b.relativePath));
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
async function buildGcSummary(
|
|
1761
|
+
args: readonly string[],
|
|
1762
|
+
cwd: string,
|
|
1763
|
+
positionalSkill: string | undefined,
|
|
1764
|
+
dryRun: boolean,
|
|
1765
|
+
): Promise<GcSummary> {
|
|
1766
|
+
const rawSkillInput =
|
|
1767
|
+
flagValue(args, "--skill")?.trim() || flagValue(args, "--mode")?.trim() || positionalSkill?.trim() || "all";
|
|
1768
|
+
const rawSkill = rawSkillInput === "all" ? rawSkillInput : normalizeWorkflowSkillSlug(rawSkillInput);
|
|
1769
|
+
if (rawSkill !== "all") assertKnownMode(rawSkill);
|
|
1770
|
+
const skills = rawSkill === "all" ? CANONICAL_JWC_WORKFLOW_SKILLS : [rawSkill as CanonicalJwcWorkflowSkill];
|
|
1771
|
+
const eligible = selectRetentionEligible(await collectRetentionCandidates(cwd, skills));
|
|
1772
|
+
const counts: Record<string, number> = {};
|
|
1773
|
+
for (const candidate of eligible) counts[candidate.category] = (counts[candidate.category] ?? 0) + 1;
|
|
1774
|
+
const targets: GenericHardPruneTarget[] = eligible.map(candidate => ({
|
|
1775
|
+
path: candidate.path,
|
|
1776
|
+
category: candidate.category,
|
|
1777
|
+
}));
|
|
1778
|
+
let pruned: string[] = [];
|
|
1779
|
+
if (!dryRun && targets.length > 0) {
|
|
1780
|
+
const eligiblePaths = new Set(eligible.map(candidate => path.resolve(candidate.path)));
|
|
1781
|
+
pruned = await hardPrune(targets, context => eligiblePaths.has(path.resolve(context.path)), {
|
|
1782
|
+
cwd,
|
|
1783
|
+
audit: {
|
|
1784
|
+
cwd,
|
|
1785
|
+
skill: rawSkill,
|
|
1786
|
+
category: "prune",
|
|
1787
|
+
verb: "gc",
|
|
1788
|
+
owner: "jwc-state-cli",
|
|
1789
|
+
},
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
return {
|
|
1793
|
+
skill: rawSkill as CanonicalJwcWorkflowSkill | "all",
|
|
1794
|
+
dry_run: dryRun,
|
|
1795
|
+
eligible: eligible.map(candidate => candidate.relativePath),
|
|
1796
|
+
pruned: pruned.map(filePath => path.relative(path.join(cwd, ".jwc", "state"), filePath)),
|
|
1797
|
+
counts,
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
async function handleGraph(
|
|
1802
|
+
args: readonly string[],
|
|
1803
|
+
_cwd: string,
|
|
1804
|
+
positionalSkill: string | undefined,
|
|
1805
|
+
): Promise<StateCommandResult> {
|
|
1806
|
+
if (hasFlag(args, "--history")) {
|
|
1807
|
+
const history = await readAuditWindow(_cwd, args);
|
|
1808
|
+
return {
|
|
1809
|
+
status: 0,
|
|
1810
|
+
stdout: hasFlag(args, "--json") ? `${JSON.stringify(history, null, 2)}\n` : renderHistoryMarkdown(history),
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
1813
|
+
const rawSkillInput2 = flagValue(args, "--skill")?.trim() || positionalSkill?.trim() || "all";
|
|
1814
|
+
const rawSkill = rawSkillInput2 === "all" ? rawSkillInput2 : normalizeWorkflowSkillSlug(rawSkillInput2);
|
|
1815
|
+
if (rawSkill !== "all") assertKnownMode(rawSkill);
|
|
1816
|
+
const format = flagValue(args, "--format")?.trim() || "ascii";
|
|
1817
|
+
if (!GRAPH_FORMATS.has(format)) {
|
|
1818
|
+
throw new StateCommandError(2, `Invalid graph format: ${format}. Expected one of: ascii, mermaid, dot.`);
|
|
1819
|
+
}
|
|
1820
|
+
return {
|
|
1821
|
+
status: 0,
|
|
1822
|
+
stdout: renderStateGraph(rawSkill as CanonicalJwcWorkflowSkill | "all", format as StateGraphFormat),
|
|
1823
|
+
};
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
async function handlePrune(
|
|
1827
|
+
args: readonly string[],
|
|
1828
|
+
cwd: string,
|
|
1829
|
+
positionalSkill: string | undefined,
|
|
1830
|
+
): Promise<StateCommandResult> {
|
|
1831
|
+
const selectors = await resolveSelectors(args, cwd, positionalSkill);
|
|
1832
|
+
const mode = selectors.mode ?? (await inferModeFromActiveState(cwd, selectors.sessionId));
|
|
1833
|
+
if (!mode) {
|
|
1834
|
+
throw new StateCommandError(
|
|
1835
|
+
2,
|
|
1836
|
+
"jwc state prune requires --mode <skill>, positional <skill>, input.skill, or an active workflow in .jwc/state/skill-active-state.json",
|
|
1837
|
+
);
|
|
1838
|
+
}
|
|
1839
|
+
const filePath = modeStateFile(cwd, mode, selectors.sessionId);
|
|
1840
|
+
const olderThanDays = parseNonNegativeIntegerFlag(args, "--older-than");
|
|
1841
|
+
const status = flagValue(args, "--status")?.trim();
|
|
1842
|
+
const targets: GenericHardPruneTarget[] = [{ path: filePath, category: "prune" }];
|
|
1843
|
+
const audit: StateWriterAuditContext = {
|
|
1844
|
+
cwd,
|
|
1845
|
+
skill: mode,
|
|
1846
|
+
category: "prune",
|
|
1847
|
+
verb: hasFlag(args, "--hard") ? "hard-prune" : "soft-delete",
|
|
1848
|
+
owner: "jwc-state-cli",
|
|
1849
|
+
};
|
|
1850
|
+
const olderThanMs = olderThanDays === undefined ? undefined : olderThanDays * 24 * 60 * 60 * 1000;
|
|
1851
|
+
const matchesSelector = async (
|
|
1852
|
+
stat: { mtimeMs: number | bigint },
|
|
1853
|
+
readJson: () => Promise<unknown>,
|
|
1854
|
+
): Promise<boolean> => {
|
|
1855
|
+
const mtimeMs = typeof stat.mtimeMs === "bigint" ? Number(stat.mtimeMs) : stat.mtimeMs;
|
|
1856
|
+
if (olderThanMs !== undefined && Date.now() - mtimeMs < olderThanMs) return false;
|
|
1857
|
+
if (status) return statusFromFile(await readJson()) === status;
|
|
1858
|
+
return true;
|
|
1859
|
+
};
|
|
1860
|
+
if (hasFlag(args, "--hard")) {
|
|
1861
|
+
const pruned = await hardPrune(
|
|
1862
|
+
targets,
|
|
1863
|
+
context => (context.stat ? matchesSelector(context.stat, context.readJson) : false),
|
|
1864
|
+
{ cwd, audit },
|
|
1865
|
+
);
|
|
1866
|
+
return { status: 0, stdout: `${JSON.stringify({ skill: mode, hard: true, pruned }, null, 2)}\n` };
|
|
1867
|
+
}
|
|
1868
|
+
let deleted: string[] = [];
|
|
1869
|
+
try {
|
|
1870
|
+
const stat = await fs.stat(filePath);
|
|
1871
|
+
if (await matchesSelector(stat, async () => JSON.parse(await fs.readFile(filePath, "utf-8")))) {
|
|
1872
|
+
const archivedPath = await softDelete(
|
|
1873
|
+
filePath,
|
|
1874
|
+
{ skill: mode, reason: "jwc state prune", status: status ?? null, older_than_days: olderThanDays ?? null },
|
|
1875
|
+
{ cwd, audit },
|
|
1876
|
+
);
|
|
1877
|
+
deleted = [archivedPath];
|
|
1878
|
+
}
|
|
1879
|
+
} catch (error) {
|
|
1880
|
+
const err = error as NodeJS.ErrnoException;
|
|
1881
|
+
if (err.code !== "ENOENT") throw error;
|
|
1882
|
+
}
|
|
1883
|
+
return { status: 0, stdout: `${JSON.stringify({ skill: mode, hard: false, soft_deleted: deleted }, null, 2)}\n` };
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
async function handleGc(
|
|
1887
|
+
args: readonly string[],
|
|
1888
|
+
cwd: string,
|
|
1889
|
+
positionalSkill: string | undefined,
|
|
1890
|
+
): Promise<StateCommandResult> {
|
|
1891
|
+
const summary = await buildGcSummary(args, cwd, positionalSkill, hasFlag(args, "--dry-run"));
|
|
1892
|
+
return { status: 0, stdout: `${JSON.stringify(summary, null, 2)}\n` };
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
async function handleMigrate(
|
|
1896
|
+
args: readonly string[],
|
|
1897
|
+
cwd: string,
|
|
1898
|
+
positionalSkill: string | undefined,
|
|
1899
|
+
): Promise<StateCommandResult> {
|
|
1900
|
+
const selectors = await resolveSelectors(args, cwd, positionalSkill);
|
|
1901
|
+
const mode = selectors.mode ?? (await inferModeFromActiveState(cwd, selectors.sessionId));
|
|
1902
|
+
if (!mode) {
|
|
1903
|
+
throw new StateCommandError(
|
|
1904
|
+
2,
|
|
1905
|
+
"jwc state migrate requires --mode <skill>, positional <skill>, input.skill, or an active workflow in .jwc/state/skill-active-state.json",
|
|
1906
|
+
);
|
|
1907
|
+
}
|
|
1908
|
+
const resolved = await resolveModeStatePaths(cwd, mode, selectors.sessionId);
|
|
1909
|
+
let filePath = resolved.canonicalPath;
|
|
1910
|
+
try {
|
|
1911
|
+
await fs.access(filePath);
|
|
1912
|
+
} catch {
|
|
1913
|
+
if (resolved.readPath !== resolved.canonicalPath) {
|
|
1914
|
+
try {
|
|
1915
|
+
await fs.access(resolved.readPath);
|
|
1916
|
+
filePath = resolved.readPath;
|
|
1917
|
+
} catch {
|
|
1918
|
+
/* keep canonical for ENOENT */
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
const forced = hasFlag(args, "--force");
|
|
1923
|
+
const mismatchWarning = await warnAndAuditOutOfBandIfNeeded(cwd, filePath, mode, {
|
|
1924
|
+
forced,
|
|
1925
|
+
});
|
|
1926
|
+
if (mismatchWarning && !forced) {
|
|
1927
|
+
throw new StateCommandError(2, `${mismatchWarning}; use --force to migrate tampered mode-state`);
|
|
1928
|
+
}
|
|
1929
|
+
const result = await migrateAndPersistLegacyState({
|
|
1930
|
+
cwd,
|
|
1931
|
+
skill: mode,
|
|
1932
|
+
statePath: filePath,
|
|
1933
|
+
sessionId: selectors.sessionId,
|
|
1934
|
+
persistPath: resolved.canonicalPath,
|
|
1935
|
+
});
|
|
1936
|
+
return {
|
|
1937
|
+
status: 0,
|
|
1938
|
+
stdout: `${JSON.stringify({ skill: mode, ...result, integrity_mismatch: Boolean(mismatchWarning) }, null, 2)}\n`,
|
|
1939
|
+
...(mismatchWarning ? { stderr: `${mismatchWarning}\n` } : {}),
|
|
1940
|
+
};
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
export async function runNativeStateCommand(args: string[], cwd = process.cwd()): Promise<StateCommandResult> {
|
|
1944
|
+
try {
|
|
1945
|
+
const parsed = parsePositionalArgs(args);
|
|
1946
|
+
assertKnownFlags(args, parsed);
|
|
1947
|
+
switch (parsed.action) {
|
|
1948
|
+
case "read":
|
|
1949
|
+
if (hasFlag(args, "--migrate")) return await handleMigrate(args, cwd, parsed.positionalSkill);
|
|
1950
|
+
return await handleRead(args, cwd, parsed.positionalSkill);
|
|
1951
|
+
case "write":
|
|
1952
|
+
return await handleWrite(args, cwd, parsed.positionalSkill);
|
|
1953
|
+
case "clear":
|
|
1954
|
+
return await handleClear(args, cwd, parsed.positionalSkill);
|
|
1955
|
+
case "contract":
|
|
1956
|
+
return await handleContract(args, cwd, parsed.positionalSkill);
|
|
1957
|
+
case "status":
|
|
1958
|
+
return await handleStatus(args, cwd, parsed.positionalSkill);
|
|
1959
|
+
case "doctor":
|
|
1960
|
+
return await handleDoctor(args, cwd, parsed.positionalSkill);
|
|
1961
|
+
case "handoff":
|
|
1962
|
+
return await handleHandoff(args, cwd, parsed.positionalSkill);
|
|
1963
|
+
case "graph":
|
|
1964
|
+
return await handleGraph(args, cwd, parsed.positionalSkill);
|
|
1965
|
+
case "prune":
|
|
1966
|
+
return await handlePrune(args, cwd, parsed.positionalSkill);
|
|
1967
|
+
case "gc":
|
|
1968
|
+
return await handleGc(args, cwd, parsed.positionalSkill);
|
|
1969
|
+
case "migrate":
|
|
1970
|
+
return await handleMigrate(args, cwd, parsed.positionalSkill);
|
|
1971
|
+
default:
|
|
1972
|
+
return { status: 2, stderr: `Unknown jwc state command: ${parsed.action}\n` };
|
|
1973
|
+
}
|
|
1974
|
+
} catch (error) {
|
|
1975
|
+
if (error instanceof StateCommandError) return { status: error.exitStatus, stderr: `${error.message}\n` };
|
|
1976
|
+
return { status: 1, stderr: `${error instanceof Error ? error.message : String(error)}\n` };
|
|
1977
|
+
}
|
|
1978
|
+
}
|