@sayknow-cli/coding-agent 0.7.11 → 0.7.12
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 +10 -0
- package/dist/types/async/result-formatting.d.ts +2 -0
- package/dist/types/capability/fs.d.ts +22 -3
- package/dist/types/capability/mcp.d.ts +2 -0
- package/dist/types/cli/append-system-prompt.d.ts +6 -0
- package/dist/types/cli/update-cli.d.ts +3 -0
- package/dist/types/commands/contribution-prep.d.ts +0 -3
- package/dist/types/commands/migrate.d.ts +1 -1
- package/dist/types/commands/sdk.d.ts +9 -0
- package/dist/types/commit/changelog/index.d.ts +1 -0
- package/dist/types/config/settings-schema.d.ts +14 -0
- package/dist/types/config/settings.d.ts +7 -1
- package/dist/types/coordinator-mcp/session-reaper.d.ts +5 -0
- package/dist/types/cursor-delete-path.d.ts +1 -0
- package/dist/types/cursor-mcp-name.d.ts +8 -0
- package/dist/types/dap/config.d.ts +8 -4
- package/dist/types/dap/session.d.ts +11 -2
- package/dist/types/debug/report-bundle-parent.d.ts +2 -0
- package/dist/types/debug/system-info.d.ts +6 -1
- package/dist/types/discovery/helpers.d.ts +11 -3
- package/dist/types/discovery/mcp-json.d.ts +1 -0
- package/dist/types/edit/file-read-cache.d.ts +4 -0
- package/dist/types/edit/modes/patch.d.ts +14 -0
- package/dist/types/edit/modes/replace.d.ts +8 -0
- package/dist/types/eval/py/runtime.d.ts +9 -0
- package/dist/types/exa/mcp-client.d.ts +11 -6
- package/dist/types/exec/bash-executor.d.ts +18 -1
- package/dist/types/export/html/css-color.d.ts +2 -0
- package/dist/types/export/html/html-export-destination.d.ts +2 -0
- package/dist/types/export/html/template.generated.d.ts +1 -1
- package/dist/types/extensibility/custom-tools/loader.d.ts +3 -2
- package/dist/types/extensibility/custom-tools/types.d.ts +3 -1
- package/dist/types/extensibility/plugins/marketplace/cache.d.ts +2 -0
- package/dist/types/extensibility/plugins/plugin-link-path.d.ts +2 -0
- package/dist/types/goals/runtime.d.ts +6 -0
- package/dist/types/harness-control-plane/receipt-spool.d.ts +4 -0
- package/dist/types/hindsight/content.d.ts +5 -6
- package/dist/types/internal-urls/skill-path.d.ts +1 -0
- package/dist/types/internal-urls/types.d.ts +2 -0
- package/dist/types/lsp/clients/swiftlint-client.d.ts +0 -4
- package/dist/types/lsp/config.d.ts +8 -5
- package/dist/types/lsp/workspace-path.d.ts +1 -0
- package/dist/types/migrate/adapters/codex.d.ts +2 -1
- package/dist/types/migrate/adapters/index.d.ts +10 -1
- package/dist/types/migrate/executor.d.ts +3 -1
- package/dist/types/migrate/types.d.ts +15 -3
- package/dist/types/modes/components/custom-editor.d.ts +6 -0
- package/dist/types/modes/components/extensions/state-manager.d.ts +4 -3
- package/dist/types/modes/components/model-selector.d.ts +46 -0
- package/dist/types/modes/controllers/input-controller.d.ts +9 -0
- package/dist/types/modes/interactive-mode.d.ts +1 -0
- package/dist/types/modes/utils/macos-option-forwarding.d.ts +17 -0
- package/dist/types/runtime-mcp/content-limits.d.ts +4 -0
- package/dist/types/runtime-mcp/manager.d.ts +9 -1
- package/dist/types/runtime-mcp/mcp-redirect.d.ts +9 -0
- package/dist/types/runtime-mcp/oauth-public-url.d.ts +1 -0
- package/dist/types/runtime-mcp/plugin-mcp-name-filter.d.ts +22 -0
- package/dist/types/runtime-mcp/plugin-network-boundary.d.ts +1 -0
- package/dist/types/runtime-mcp/project-host-values.d.ts +33 -0
- package/dist/types/runtime-mcp/smithery-registry.d.ts +24 -0
- package/dist/types/runtime-mcp/tool-bridge.d.ts +4 -0
- package/dist/types/runtime-mcp/types.d.ts +6 -0
- package/dist/types/sdk/broker/ensure.d.ts +2 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +5 -1
- package/dist/types/sdk/broker/runtime.d.ts +1 -1
- package/dist/types/sdk/bus/chat-daemon-control.d.ts +3 -1
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +3 -1
- package/dist/types/sdk/bus/telegram-daemon.d.ts +1 -0
- package/dist/types/sdk/host/events.d.ts +4 -0
- package/dist/types/session/agent-session.d.ts +20 -1
- package/dist/types/session/messages.d.ts +5 -1
- package/dist/types/session/session-manager.d.ts +13 -0
- package/dist/types/session/session-storage.d.ts +8 -0
- package/dist/types/session/streaming-output.d.ts +11 -0
- package/dist/types/session-import/redact.d.ts +1 -1
- package/dist/types/skc-runtime/managed-owner-admission.d.ts +3 -0
- package/dist/types/skc-runtime/psmux-detect.d.ts +5 -4
- package/dist/types/skc-runtime/ralplan-runtime.d.ts +5 -0
- package/dist/types/skc-runtime/sidecar-bootstrap-env.d.ts +6 -0
- package/dist/types/skc-runtime/state-writer.d.ts +4 -1
- package/dist/types/skc-runtime/tmux-sessions.d.ts +24 -0
- package/dist/types/skc-runtime/ultragoal-runtime.d.ts +4 -0
- package/dist/types/skill-state/workflow-mutation-guard.d.ts +20 -1
- package/dist/types/slash-commands/helpers/mcp.d.ts +5 -0
- package/dist/types/ssh/ssh-executor.d.ts +3 -1
- package/dist/types/system-prompt.d.ts +5 -2
- package/dist/types/task/executor.d.ts +17 -3
- package/dist/types/task/isolation-dir.d.ts +26 -0
- package/dist/types/task/role-body.d.ts +11 -0
- package/dist/types/task/token-log-mode.test.d.ts +1 -0
- package/dist/types/tools/ask.d.ts +77 -254
- package/dist/types/tools/ast-edit-write-path.d.ts +23 -0
- package/dist/types/tools/atomic-file-write.d.ts +74 -0
- package/dist/types/tools/auto-generated-guard.d.ts +5 -2
- package/dist/types/tools/bash-allowed-prefixes.d.ts +16 -0
- package/dist/types/tools/bash-interactive.d.ts +2 -0
- package/dist/types/tools/bash-skill-urls.d.ts +5 -1
- package/dist/types/tools/bash.d.ts +1 -0
- package/dist/types/tools/browser/cdp-url.d.ts +2 -0
- package/dist/types/tools/browser/tab-worker.d.ts +2 -0
- package/dist/types/tools/debug.d.ts +2 -2
- package/dist/types/tools/explicit-artifact.d.ts +8 -0
- package/dist/types/tools/fetch.d.ts +7 -4
- package/dist/types/tools/github-side-effect.d.ts +22 -0
- package/dist/types/tools/index.d.ts +3 -0
- package/dist/types/tools/monitor-mutation.d.ts +9 -0
- package/dist/types/tools/recipe/index.d.ts +2 -0
- package/dist/types/tools/recipe/recipe-guard.d.ts +7 -0
- package/dist/types/tools/restricted-cwd.d.ts +1 -0
- package/dist/types/tools/reverse-engineer.d.ts +81 -0
- package/dist/types/tools/search-tool-bm25.d.ts +2 -0
- package/dist/types/tools/tmux-self-injection-guard.d.ts +17 -0
- package/dist/types/tools/untrusted-content.d.ts +12 -0
- package/dist/types/utils/file-mentions.d.ts +5 -0
- package/dist/types/utils/open.d.ts +0 -1
- package/dist/types/utils/shell-snapshot.d.ts +2 -0
- package/dist/types/utils/title-generator.d.ts +12 -2
- package/dist/types/utils/tools-checksum.d.ts +7 -0
- package/dist/types/utils/xml-escape.d.ts +2 -0
- package/dist/types/web/scrapers/types.d.ts +8 -1
- package/dist/types/web/search/providers/codex.d.ts +6 -7
- package/dist/types/web/search/providers/insane.d.ts +7 -1
- package/dist/types/web/search/providers/kimi.d.ts +2 -0
- package/dist/types/web/search/providers/searxng.d.ts +7 -0
- package/dist/types/web/search/providers/xai.d.ts +2 -0
- package/package.json +7 -7
- package/scripts/generate-sdk-operation-inventory.ts +4 -0
- package/src/async/job-manager.ts +23 -9
- package/src/async/result-formatting.ts +40 -0
- package/src/capability/fs.ts +78 -11
- package/src/capability/mcp.ts +2 -0
- package/src/cli/append-system-prompt.ts +12 -0
- package/src/cli/auth-broker-cli.ts +22 -12
- package/src/cli/config-cli.ts +8 -18
- package/src/cli/migrate-cli.ts +7 -5
- package/src/cli/ssh-cli.ts +6 -3
- package/src/cli/stats-cli.ts +9 -4
- package/src/cli/update-cli.ts +42 -0
- package/src/cli/web-search-cli.ts +9 -3
- package/src/cli.ts +5 -9
- package/src/commands/commit.ts +2 -2
- package/src/commands/contribution-prep.ts +1 -3
- package/src/commands/harness.ts +25 -15
- package/src/commands/launch.ts +1 -1
- package/src/commands/migrate.ts +3 -3
- package/src/commands/sdk.ts +115 -14
- package/src/commands/ultragoal.ts +14 -8
- package/src/commit/agentic/agent.ts +6 -6
- package/src/commit/analysis/conventional.ts +14 -5
- package/src/commit/changelog/index.ts +39 -1
- package/src/commit/message.ts +10 -3
- package/src/config/config-file.ts +106 -3
- package/src/config/keybindings.ts +154 -7
- package/src/config/mcp-schema.json +4 -0
- package/src/config/model-registry.ts +10 -2
- package/src/config/settings-schema.ts +18 -0
- package/src/config/settings.ts +32 -4
- package/src/coordinator-mcp/policy.ts +14 -4
- package/src/coordinator-mcp/server.ts +44 -4
- package/src/coordinator-mcp/session-reaper.ts +9 -1
- package/src/cursor-delete-path.ts +10 -0
- package/src/cursor-mcp-name.ts +15 -0
- package/src/cursor.ts +13 -2
- package/src/dap/client.ts +9 -2
- package/src/dap/config.ts +33 -13
- package/src/dap/defaults.json +1 -1
- package/src/dap/session.ts +161 -36
- package/src/debug/crash-diagnostics.ts +89 -6
- package/src/debug/report-bundle-parent.ts +22 -0
- package/src/debug/report-bundle.ts +100 -3
- package/src/debug/system-info.ts +21 -4
- package/src/defaults/skc/extensions/grok-cli-vendor/src/shared/base-url.ts +21 -7
- package/src/defaults/skc/skills/deep-interview/SKILL.md +1 -1
- package/src/discovery/agents-md.ts +3 -2
- package/src/discovery/agents.ts +3 -2
- package/src/discovery/builtin.ts +21 -11
- package/src/discovery/claude.ts +5 -4
- package/src/discovery/cline.ts +2 -2
- package/src/discovery/codex.ts +6 -5
- package/src/discovery/cursor.ts +11 -2
- package/src/discovery/gemini.ts +4 -3
- package/src/discovery/github.ts +2 -2
- package/src/discovery/helpers.ts +51 -11
- package/src/discovery/mcp-json.ts +28 -12
- package/src/discovery/opencode.ts +2 -1
- package/src/discovery/ssh.ts +11 -6
- package/src/discovery/substitute-plugin-root.ts +3 -1
- package/src/discovery/vscode.ts +3 -3
- package/src/edit/apply-patch/index.ts +12 -1
- package/src/edit/file-read-cache.ts +24 -6
- package/src/edit/index.ts +90 -20
- package/src/edit/modes/patch.ts +215 -9
- package/src/edit/modes/replace.ts +141 -0
- package/src/eval/js/context-manager.ts +29 -3
- package/src/eval/js/worker-entry.ts +51 -18
- package/src/eval/py/runner.py +144 -5
- package/src/eval/py/runtime.ts +44 -4
- package/src/eval/py/tool-bridge.ts +4 -0
- package/src/exa/mcp-client.ts +53 -11
- package/src/exec/bash-executor.ts +87 -4
- package/src/exec/non-interactive-env.ts +0 -1
- package/src/export/html/css-color.ts +9 -0
- package/src/export/html/html-export-destination.ts +16 -0
- package/src/export/html/index.ts +102 -8
- package/src/export/html/template.generated.ts +1 -1
- package/src/extensibility/custom-tools/loader.ts +13 -3
- package/src/extensibility/custom-tools/types.ts +3 -1
- package/src/extensibility/custom-tools/wrapper.ts +3 -1
- package/src/extensibility/plugins/manager.ts +3 -2
- package/src/extensibility/plugins/marketplace/cache.ts +15 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +2 -2
- package/src/extensibility/plugins/marketplace/manager.ts +5 -3
- package/src/extensibility/plugins/plugin-link-path.ts +12 -0
- package/src/extensibility/skc-plugins/mcp-policy.ts +2 -1
- package/src/goals/runtime.ts +30 -8
- package/src/harness-control-plane/finalize.ts +10 -0
- package/src/harness-control-plane/operate.ts +12 -4
- package/src/harness-control-plane/owner.ts +8 -1
- package/src/harness-control-plane/receipt-spool.ts +105 -28
- package/src/harness-control-plane/storage.ts +124 -6
- package/src/hashline/execute.ts +3 -3
- package/src/hashline/recovery.ts +85 -2
- package/src/hindsight/config.ts +9 -3
- package/src/hindsight/content.ts +116 -16
- package/src/hindsight/mental-models.ts +22 -10
- package/src/hindsight/state.ts +7 -4
- package/src/hooks/native-skill-hook.ts +17 -12
- package/src/i18n/messages/de.settings.ts +3 -0
- package/src/i18n/messages/es.settings.ts +3 -0
- package/src/i18n/messages/fr.settings.ts +3 -0
- package/src/i18n/messages/ja.settings.ts +3 -0
- package/src/i18n/messages/ko.settings.ts +3 -0
- package/src/i18n/messages/zh.settings.ts +3 -0
- package/src/internal-urls/artifact-protocol.ts +3 -1
- package/src/internal-urls/docs-index.generated.ts +10 -10
- package/src/internal-urls/local-protocol.ts +167 -8
- package/src/internal-urls/skill-path.ts +18 -0
- package/src/internal-urls/skill-protocol.ts +2 -0
- package/src/internal-urls/types.ts +2 -0
- package/src/lsp/client.ts +2 -1
- package/src/lsp/clients/biome-client.ts +2 -0
- package/src/lsp/clients/swiftlint-client.ts +2 -0
- package/src/lsp/config.ts +18 -62
- package/src/lsp/edits.ts +6 -0
- package/src/lsp/index.ts +29 -0
- package/src/lsp/workspace-path.ts +75 -0
- package/src/main.ts +33 -11
- package/src/memories/index.ts +141 -9
- package/src/migrate/action-planner.ts +57 -0
- package/src/migrate/adapters/claude-code.ts +23 -4
- package/src/migrate/adapters/codex.ts +22 -4
- package/src/migrate/adapters/index.ts +22 -4
- package/src/migrate/adapters/opencode.ts +6 -1
- package/src/migrate/executor.ts +84 -7
- package/src/migrate/report.ts +19 -2
- package/src/migrate/types.ts +14 -4
- package/src/modes/DESIGN.md +5 -0
- package/src/modes/acp/acp-agent.ts +35 -2
- package/src/modes/acp/permission-mode.ts +18 -1
- package/src/modes/components/custom-editor.ts +14 -0
- package/src/modes/components/extensions/extension-dashboard.ts +2 -2
- package/src/modes/components/extensions/inspector-panel.ts +9 -5
- package/src/modes/components/extensions/state-manager.ts +15 -5
- package/src/modes/components/model-selector.ts +144 -94
- package/src/modes/components/welcome.ts +3 -2
- package/src/modes/controllers/command-controller.ts +300 -9
- package/src/modes/controllers/event-controller.ts +1 -1
- package/src/modes/controllers/extension-ui-controller.ts +32 -19
- package/src/modes/controllers/input-controller.ts +62 -26
- package/src/modes/controllers/plan-mode-controller.ts +17 -7
- package/src/modes/controllers/runtime-mcp-command-controller.ts +25 -20
- package/src/modes/controllers/ssh-command-controller.ts +3 -1
- package/src/modes/interactive-mode.ts +10 -0
- package/src/modes/utils/macos-option-forwarding.ts +80 -0
- package/src/prompts/system/irc-incoming.md +3 -1
- package/src/prompts/system/project-prompt.md +19 -0
- package/src/prompts/system/system-prompt.md +3 -0
- package/src/prompts/tools/ask.md +2 -0
- package/src/prompts/tools/debug.md +1 -1
- package/src/prompts/tools/monitor.md +7 -5
- package/src/prompts/tools/reverse-engineer.md +29 -0
- package/src/runtime-credential-selector.ts +2 -2
- package/src/runtime-mcp/config-writer.ts +10 -6
- package/src/runtime-mcp/config.ts +1 -0
- package/src/runtime-mcp/content-limits.ts +7 -0
- package/src/runtime-mcp/json-rpc.ts +2 -1
- package/src/runtime-mcp/manager.ts +57 -9
- package/src/runtime-mcp/mcp-redirect.ts +73 -0
- package/src/runtime-mcp/oauth-flow.ts +43 -5
- package/src/runtime-mcp/oauth-public-url.ts +8 -0
- package/src/runtime-mcp/plugin-mcp-name-filter.ts +62 -0
- package/src/runtime-mcp/plugin-network-boundary.ts +4 -0
- package/src/runtime-mcp/project-host-values.ts +50 -0
- package/src/runtime-mcp/render.ts +16 -1
- package/src/runtime-mcp/smithery-registry.ts +22 -3
- package/src/runtime-mcp/tool-bridge.ts +194 -21
- package/src/runtime-mcp/transports/http.ts +4 -3
- package/src/runtime-mcp/transports/stdio.ts +2 -1
- package/src/runtime-mcp/types.ts +6 -0
- package/src/sdk/broker/broker.ts +11 -2
- package/src/sdk/broker/ensure.ts +131 -10
- package/src/sdk/broker/lifecycle-ledger.ts +18 -3
- package/src/sdk/broker/lifecycle.ts +21 -19
- package/src/sdk/broker/runtime.ts +1 -1
- package/src/sdk/bus/chat-daemon-cli.ts +38 -1
- package/src/sdk/bus/chat-daemon-control.ts +5 -3
- package/src/sdk/bus/index.ts +5 -3
- package/src/sdk/bus/lifecycle-control-runtime.ts +9 -2
- package/src/sdk/bus/session-control.ts +2 -0
- package/src/sdk/bus/slack-daemon.ts +8 -1
- package/src/sdk/bus/slack-live-provider.ts +3 -1
- package/src/sdk/bus/telegram-daemon-contract.ts +3 -1
- package/src/sdk/bus/telegram-daemon-control.ts +17 -12
- package/src/sdk/bus/telegram-daemon.ts +41 -1
- package/src/sdk/host/events.ts +67 -4
- package/src/sdk/mcp/server.ts +16 -3
- package/src/sdk/protocol/operation-inventory.generated.json +22 -0
- package/src/sdk/session.ts +18 -25
- package/src/secrets/obfuscator.ts +92 -12
- package/src/session/agent-session.ts +395 -79
- package/src/session/artifacts.ts +3 -1
- package/src/session/history-storage.ts +172 -8
- package/src/session/internal/managed-session-scope.ts +130 -52
- package/src/session/messages.ts +47 -6
- package/src/session/session-manager.ts +116 -8
- package/src/session/session-storage.ts +31 -1
- package/src/session/streaming-output.ts +263 -4
- package/src/session-import/redact.ts +76 -3
- package/src/setup/hermes-setup.ts +4 -1
- package/src/skc-runtime/gc-runtime.ts +26 -4
- package/src/skc-runtime/launch-tmux.ts +21 -11
- package/src/skc-runtime/launch-worktree.ts +42 -3
- package/src/skc-runtime/managed-owner-admission.ts +46 -2
- package/src/skc-runtime/psmux-detect.ts +29 -5
- package/src/skc-runtime/ralplan-runtime.ts +14 -1
- package/src/skc-runtime/session-resolution.ts +38 -6
- package/src/skc-runtime/sidecar-bootstrap-env.ts +19 -0
- package/src/skc-runtime/state-writer.ts +134 -16
- package/src/skc-runtime/tmux-sessions.ts +85 -4
- package/src/skc-runtime/ultragoal-change-set.ts +18 -2
- package/src/skc-runtime/ultragoal-guard.ts +9 -1
- package/src/skc-runtime/ultragoal-runtime.ts +26 -9
- package/src/skill-state/active-state.ts +13 -0
- package/src/skill-state/workflow-mutation-guard.ts +3297 -180
- package/src/slash-commands/builtin-registry.ts +14 -8
- package/src/slash-commands/helpers/mcp.ts +20 -7
- package/src/ssh/ssh-executor.ts +3 -1
- package/src/stt/recorder.ts +26 -9
- package/src/system-prompt.ts +65 -16
- package/src/task/commands.ts +3 -1
- package/src/task/executor.ts +52 -7
- package/src/task/index.ts +28 -0
- package/src/task/isolation-dir.ts +143 -0
- package/src/task/role-body.ts +84 -0
- package/src/task/token-log-mode.test.ts +162 -0
- package/src/task/token-log.ts +91 -2
- package/src/task/worktree.ts +16 -7
- package/src/tools/archive-reader.ts +653 -31
- package/src/tools/ask.ts +86 -14
- package/src/tools/ast-edit-write-path.ts +133 -0
- package/src/tools/ast-edit.ts +27 -1
- package/src/tools/ast-grep.ts +7 -2
- package/src/tools/atomic-file-write.ts +625 -0
- package/src/tools/auto-generated-guard.ts +28 -8
- package/src/tools/bash-allowed-prefixes.ts +225 -6
- package/src/tools/bash-interactive.ts +12 -0
- package/src/tools/bash-skill-urls.ts +113 -7
- package/src/tools/bash.ts +152 -20
- package/src/tools/browser/cdp-url.ts +18 -0
- package/src/tools/browser/tab-worker.ts +49 -14
- package/src/tools/browser.ts +25 -8
- package/src/tools/cron.ts +10 -1
- package/src/tools/debug.ts +16 -8
- package/src/tools/eval.ts +71 -34
- package/src/tools/explicit-artifact.ts +89 -0
- package/src/tools/fetch.ts +26 -17
- package/src/tools/gh.ts +40 -12
- package/src/tools/github-side-effect.ts +112 -0
- package/src/tools/image-gen.ts +24 -10
- package/src/tools/index.ts +6 -0
- package/src/tools/monitor-mutation.ts +27 -0
- package/src/tools/monitor.ts +28 -1
- package/src/tools/output-meta.ts +74 -5
- package/src/tools/read.ts +24 -36
- package/src/tools/recipe/index.ts +12 -0
- package/src/tools/recipe/recipe-guard.ts +19 -0
- package/src/tools/recipe/runner.ts +23 -12
- package/src/tools/render-utils.ts +2 -2
- package/src/tools/restricted-cwd.ts +10 -0
- package/src/tools/reverse-engineer.ts +497 -0
- package/src/tools/search-tool-bm25.ts +14 -3
- package/src/tools/search.ts +3 -2
- package/src/tools/ssh.ts +235 -8
- package/src/tools/subagent-render.ts +43 -7
- package/src/tools/subagent.ts +7 -3
- package/src/tools/tmux-self-injection-guard.ts +3538 -0
- package/src/tools/todo-write.ts +41 -3
- package/src/tools/untrusted-content.ts +23 -0
- package/src/tools/vim.ts +2 -2
- package/src/tools/write.ts +37 -4
- package/src/tui/tree-list.ts +15 -1
- package/src/utils/commit-message-generator.ts +9 -2
- package/src/utils/external-editor.ts +21 -7
- package/src/utils/file-mentions.ts +75 -7
- package/src/utils/git.ts +38 -7
- package/src/utils/open.ts +73 -4
- package/src/utils/shell-snapshot.ts +9 -1
- package/src/utils/title-generator.ts +61 -16
- package/src/utils/tools-checksum.ts +34 -0
- package/src/utils/tools-manager.ts +24 -6
- package/src/utils/xml-escape.ts +14 -0
- package/src/web/insane/url-guard.ts +2 -1
- package/src/web/scrapers/types.ts +8 -0
- package/src/web/scrapers/youtube.ts +3 -2
- package/src/web/search/index.ts +4 -3
- package/src/web/search/providers/anthropic.ts +4 -4
- package/src/web/search/providers/codex.ts +31 -34
- package/src/web/search/providers/insane.ts +145 -28
- package/src/web/search/providers/kimi.ts +15 -5
- package/src/web/search/providers/searxng.ts +47 -4
- package/src/web/search/providers/xai.ts +7 -2
- package/dist/types/cli/shell-cli.d.ts +0 -8
- package/dist/types/commands/shell.d.ts +0 -21
- package/src/cli/shell-cli.ts +0 -176
- package/src/commands/shell.ts +0 -29
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import type
|
|
2
|
+
import type * as nodeFs from "node:fs";
|
|
3
|
+
import { constants as fsConstants, type Stats } from "node:fs";
|
|
3
4
|
import * as fs from "node:fs/promises";
|
|
4
5
|
import * as path from "node:path";
|
|
5
6
|
import { type FileLockOptions, withFileLock } from "../config/file-lock";
|
|
@@ -279,19 +280,33 @@ export function stampWorkflowEnvelopeChecksum<T>(value: T, filePath: string, com
|
|
|
279
280
|
return envelope as T;
|
|
280
281
|
}
|
|
281
282
|
|
|
282
|
-
export
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
283
|
+
export type WorkflowEnvelopeChecksumStatus = "absent" | "match" | "mismatch";
|
|
284
|
+
|
|
285
|
+
/** Compare a parsed envelope to its writer-stamped `content_sha256`, when one is present. */
|
|
286
|
+
export function workflowEnvelopeChecksumStatus(value: unknown): WorkflowEnvelopeChecksumStatus {
|
|
287
|
+
const checksum = workflowEnvelopeChecksumPair(value);
|
|
288
|
+
if (!checksum) return "absent";
|
|
289
|
+
return checksum.actual === checksum.expected ? "match" : "mismatch";
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function workflowEnvelopeChecksumPair(value: unknown): { expected: string; actual: string } | undefined {
|
|
293
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return undefined;
|
|
294
|
+
const receipt = (value as Record<string, unknown>).receipt;
|
|
288
295
|
if (!receipt || typeof receipt !== "object" || Array.isArray(receipt)) return undefined;
|
|
289
296
|
const checksum = (receipt as Record<string, unknown>).content_sha256;
|
|
290
297
|
if (!checksum || typeof checksum !== "object" || Array.isArray(checksum)) return undefined;
|
|
291
298
|
const expected = (checksum as Record<string, unknown>).value;
|
|
292
299
|
if (typeof expected !== "string" || !expected) return undefined;
|
|
293
|
-
|
|
294
|
-
|
|
300
|
+
return { expected, actual: workflowEnvelopeContentSha256(value) };
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export async function detectWorkflowEnvelopeIntegrityMismatch(
|
|
304
|
+
filePath: string,
|
|
305
|
+
): Promise<WorkflowEnvelopeIntegrityMismatch | undefined> {
|
|
306
|
+
const current = await readJsonIfPresent(filePath);
|
|
307
|
+
const checksum = workflowEnvelopeChecksumPair(current);
|
|
308
|
+
if (!checksum || checksum.actual === checksum.expected) return undefined;
|
|
309
|
+
return { path: filePath, expected: checksum.expected, actual: checksum.actual };
|
|
295
310
|
}
|
|
296
311
|
|
|
297
312
|
function safeString(value: unknown): string {
|
|
@@ -807,10 +822,113 @@ export async function updateJsonAtomic<T = unknown>(
|
|
|
807
822
|
);
|
|
808
823
|
}
|
|
809
824
|
|
|
825
|
+
async function assertAppendRegularFile(filePath: string): Promise<void> {
|
|
826
|
+
try {
|
|
827
|
+
const stat = await fs.lstat(filePath);
|
|
828
|
+
if (stat.isSymbolicLink() || !stat.isFile()) throw new Error("state append path is not a regular file");
|
|
829
|
+
} catch (error) {
|
|
830
|
+
if (!isErrno(error, "ENOENT")) throw error;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Append bytes owner-only (shared with `appendAuditEntry`): mode 0600, `O_NOFOLLOW`
|
|
836
|
+
* when the path already exists, and `O_EXCL` when it does not. An existing mode 0666
|
|
837
|
+
* file, and any other group or other permission bits, is tightened to 0600 before the write.
|
|
838
|
+
*/
|
|
839
|
+
async function tightenReadOnlyAppendMode(filePath: string): Promise<void> {
|
|
840
|
+
if (process.platform === "win32") return;
|
|
841
|
+
const noFollow = fsConstants.O_NOFOLLOW ?? 0;
|
|
842
|
+
const initialStat = await fs.lstat(filePath, { bigint: true });
|
|
843
|
+
if (initialStat.isSymbolicLink() || !initialStat.isFile())
|
|
844
|
+
throw new Error("state append path is not a regular file");
|
|
845
|
+
// A duplicate idempotent append must not require a writable file. Owner-only
|
|
846
|
+
// modes such as 0400 stay as they are; only group or other bits are tightened.
|
|
847
|
+
const handle = await fs.open(filePath, fsConstants.O_RDONLY | noFollow);
|
|
848
|
+
try {
|
|
849
|
+
const openedStat = await handle.stat({ bigint: true });
|
|
850
|
+
const pathStat = await fs.lstat(filePath, { bigint: true });
|
|
851
|
+
const sameObject = (left: nodeFs.BigIntStats, right: nodeFs.BigIntStats) =>
|
|
852
|
+
left.dev === right.dev && left.ino === right.ino && left.nlink === right.nlink;
|
|
853
|
+
if (
|
|
854
|
+
openedStat.isSymbolicLink() ||
|
|
855
|
+
!openedStat.isFile() ||
|
|
856
|
+
pathStat.isSymbolicLink() ||
|
|
857
|
+
!pathStat.isFile() ||
|
|
858
|
+
!sameObject(initialStat, openedStat) ||
|
|
859
|
+
!sameObject(openedStat, pathStat)
|
|
860
|
+
)
|
|
861
|
+
throw new Error("state append path identity changed before append");
|
|
862
|
+
if ((Number(openedStat.mode) & 0o077) === 0) return;
|
|
863
|
+
await handle.chmod(0o600);
|
|
864
|
+
const tightened = await handle.stat({ bigint: true });
|
|
865
|
+
if ((Number(tightened.mode) & 0o777) !== 0o600)
|
|
866
|
+
throw new Error("state append path could not be tightened to mode 0600");
|
|
867
|
+
} finally {
|
|
868
|
+
await handle.close();
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
async function appendOwnerOnlyText(filePath: string, text: string): Promise<void> {
|
|
873
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
874
|
+
await assertAppendRegularFile(filePath);
|
|
875
|
+
const noFollow = process.platform === "win32" ? 0 : (fsConstants.O_NOFOLLOW ?? 0);
|
|
876
|
+
let handle: fs.FileHandle | undefined;
|
|
877
|
+
let initialStat: nodeFs.BigIntStats | undefined;
|
|
878
|
+
// O_EXCL matches appendAuditEntry for a missing path. Concurrent appends can
|
|
879
|
+
// create the same file together, so an EEXIST loser retries the existing-file
|
|
880
|
+
// open, which carries O_NOFOLLOW and will not follow a symlink.
|
|
881
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
882
|
+
initialStat = undefined;
|
|
883
|
+
try {
|
|
884
|
+
initialStat = await fs.lstat(filePath, { bigint: true });
|
|
885
|
+
if (initialStat.isSymbolicLink() || !initialStat.isFile())
|
|
886
|
+
throw new Error("state append path is not a regular file");
|
|
887
|
+
} catch (error) {
|
|
888
|
+
if (!isErrno(error, "ENOENT")) throw error;
|
|
889
|
+
}
|
|
890
|
+
const flags = initialStat
|
|
891
|
+
? fsConstants.O_WRONLY | fsConstants.O_APPEND | noFollow
|
|
892
|
+
: fsConstants.O_WRONLY | fsConstants.O_APPEND | fsConstants.O_CREAT | fsConstants.O_EXCL;
|
|
893
|
+
try {
|
|
894
|
+
handle = await fs.open(filePath, flags, 0o600);
|
|
895
|
+
break;
|
|
896
|
+
} catch (error) {
|
|
897
|
+
if (isErrno(error, "ELOOP")) throw new Error("state append path is not a regular file");
|
|
898
|
+
if (initialStat === undefined && isErrno(error, "EEXIST") && attempt === 0) continue;
|
|
899
|
+
throw error;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
if (!handle) throw new Error("state append path identity changed before append");
|
|
903
|
+
try {
|
|
904
|
+
const openedStat = await handle.stat({ bigint: true });
|
|
905
|
+
const pathStat = await fs.lstat(filePath, { bigint: true });
|
|
906
|
+
const sameObject = (left: nodeFs.BigIntStats, right: nodeFs.BigIntStats) =>
|
|
907
|
+
left.dev === right.dev && left.ino === right.ino && left.nlink === right.nlink;
|
|
908
|
+
if (
|
|
909
|
+
openedStat.isSymbolicLink() ||
|
|
910
|
+
!openedStat.isFile() ||
|
|
911
|
+
pathStat.isSymbolicLink() ||
|
|
912
|
+
!pathStat.isFile() ||
|
|
913
|
+
(initialStat !== undefined && !sameObject(initialStat, openedStat)) ||
|
|
914
|
+
!sameObject(openedStat, pathStat)
|
|
915
|
+
)
|
|
916
|
+
throw new Error("state append path identity changed before append");
|
|
917
|
+
if (process.platform !== "win32" && (Number(openedStat.mode) & 0o077) !== 0) {
|
|
918
|
+
await handle.chmod(0o600);
|
|
919
|
+
const tightened = await handle.stat({ bigint: true });
|
|
920
|
+
if ((Number(tightened.mode) & 0o777) !== 0o600)
|
|
921
|
+
throw new Error("state append path could not be tightened to mode 0600");
|
|
922
|
+
}
|
|
923
|
+
await handle.writeFile(text, "utf-8");
|
|
924
|
+
} finally {
|
|
925
|
+
await handle?.close();
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
810
929
|
export async function appendJsonl(targetPath: string, entry: unknown, options?: StateWriterOptions): Promise<string> {
|
|
811
930
|
const filePath = resolveSkcTarget(targetPath, cwdForOptions(options));
|
|
812
|
-
await
|
|
813
|
-
await fs.appendFile(filePath, `${JSON.stringify(entry)}\n`, "utf-8");
|
|
931
|
+
await appendOwnerOnlyText(filePath, `${JSON.stringify(entry)}\n`);
|
|
814
932
|
await maybeAudit(filePath, options);
|
|
815
933
|
return filePath;
|
|
816
934
|
}
|
|
@@ -908,12 +1026,14 @@ export async function appendJsonlIdempotent(
|
|
|
908
1026
|
return lockResolvedWorkflowTarget(
|
|
909
1027
|
filePath,
|
|
910
1028
|
async () => {
|
|
1029
|
+
await assertAppendRegularFile(filePath);
|
|
911
1030
|
const existing = await readJsonlEntries(filePath);
|
|
912
1031
|
const duplicate = findJsonlDuplicate(existing, entry, options);
|
|
913
1032
|
if (duplicate !== undefined) {
|
|
1033
|
+
await tightenReadOnlyAppendMode(filePath);
|
|
914
1034
|
return { path: filePath, appended: false, duplicate };
|
|
915
1035
|
}
|
|
916
|
-
await
|
|
1036
|
+
await appendOwnerOnlyText(filePath, `${JSON.stringify(entry)}\n`);
|
|
917
1037
|
await maybeAudit(filePath, options);
|
|
918
1038
|
return { path: filePath, appended: true };
|
|
919
1039
|
},
|
|
@@ -923,8 +1043,7 @@ export async function appendJsonlIdempotent(
|
|
|
923
1043
|
|
|
924
1044
|
export async function appendText(targetPath: string, text: string, options?: StateWriterOptions): Promise<string> {
|
|
925
1045
|
const filePath = resolveSkcTarget(targetPath, cwdForOptions(options));
|
|
926
|
-
await
|
|
927
|
-
await fs.appendFile(filePath, text, "utf-8");
|
|
1046
|
+
await appendOwnerOnlyText(filePath, text);
|
|
928
1047
|
await maybeAudit(filePath, options);
|
|
929
1048
|
return filePath;
|
|
930
1049
|
}
|
|
@@ -1228,8 +1347,7 @@ export async function appendAuditEntry(
|
|
|
1228
1347
|
const entry = typeof sessionIdOrEntry === "string" ? maybeEntry : sessionIdOrEntry;
|
|
1229
1348
|
if (!entry) throw new Error("audit entry is required");
|
|
1230
1349
|
const filePath = resolveSkcTarget(layoutAuditPath(cwd, sessionId), cwd);
|
|
1231
|
-
await
|
|
1232
|
-
await fs.appendFile(filePath, `${JSON.stringify(entry)}\n`, "utf-8");
|
|
1350
|
+
await appendOwnerOnlyText(filePath, `${JSON.stringify(entry)}\n`);
|
|
1233
1351
|
return filePath;
|
|
1234
1352
|
}
|
|
1235
1353
|
|
|
@@ -4,6 +4,8 @@ import * as fsSync from "node:fs";
|
|
|
4
4
|
import * as fs from "node:fs/promises";
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import { Process } from "@sayknow-cli/natives";
|
|
7
|
+
import { startupProjectEnvSnapshot } from "@sayknow-cli/utils/env";
|
|
8
|
+
import { canonicalEnvKey, type ProjectEnvSnapshot, projectEnvSnapshot } from "@sayknow-cli/utils/env-file";
|
|
7
9
|
import { readLinuxProcStartTime, readLinuxProcStartTimeSync } from "./linux-proc";
|
|
8
10
|
import { resolveSkcTmuxBinary } from "./psmux-detect";
|
|
9
11
|
import { tmuxRuntimeSessionPath } from "./session-layout";
|
|
@@ -14,6 +16,7 @@ import {
|
|
|
14
16
|
SKC_TMUX_OWNER_SERVER_KEY_ENV,
|
|
15
17
|
SKC_TMUX_OWNER_STATE_DIR_ENV,
|
|
16
18
|
} from "./session-state-sidecar";
|
|
19
|
+
import { trustedCoordinatorEnv } from "./sidecar-bootstrap-env";
|
|
17
20
|
import {
|
|
18
21
|
buildSkcTmuxExactOptionTarget,
|
|
19
22
|
buildSkcTmuxExactSessionTarget,
|
|
@@ -482,6 +485,81 @@ export function abandonedIdentityCensus(
|
|
|
482
485
|
};
|
|
483
486
|
}
|
|
484
487
|
|
|
488
|
+
const TMUX_LAUNCH_IDENTITY_ENV_NAMES = [
|
|
489
|
+
"SKC_SESSION_ID",
|
|
490
|
+
SKC_COORDINATOR_SESSION_ID_ENV,
|
|
491
|
+
SKC_COORDINATOR_SESSION_STATE_FILE_ENV,
|
|
492
|
+
"SKC_TMUX_SESSION",
|
|
493
|
+
] as const;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Drop project-dotenv copies of the tmux session name, coordinator id, and
|
|
497
|
+
* state-file path. A pin is kept only when every snapshot accepts it, so a
|
|
498
|
+
* declaration Bun loaded before `chdir` is refused even if the launch cwd no
|
|
499
|
+
* longer contains that file. Acceptance uses the shared helper, but the
|
|
500
|
+
* original string stays: callers trim at use, and a later check must see the
|
|
501
|
+
* same value that was accepted.
|
|
502
|
+
*/
|
|
503
|
+
export function trustedTmuxLaunchIdentityEnv(
|
|
504
|
+
env: NodeJS.ProcessEnv,
|
|
505
|
+
snapshots: readonly ProjectEnvSnapshot[],
|
|
506
|
+
): NodeJS.ProcessEnv {
|
|
507
|
+
const denied: string[] = [];
|
|
508
|
+
for (const name of TMUX_LAUNCH_IDENTITY_ENV_NAMES) {
|
|
509
|
+
if (!env[name]) continue;
|
|
510
|
+
for (const snapshot of snapshots) {
|
|
511
|
+
if (trustedCoordinatorEnv(name, env, snapshot) === undefined) {
|
|
512
|
+
denied.push(name);
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (denied.length === 0) return env;
|
|
518
|
+
const next: NodeJS.ProcessEnv = { ...env };
|
|
519
|
+
for (const name of denied) delete next[name];
|
|
520
|
+
return next;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
export function tmuxLaunchIdentityEnv(env: NodeJS.ProcessEnv, cwd: string): NodeJS.ProcessEnv {
|
|
524
|
+
return trustedTmuxLaunchIdentityEnv(env, [projectEnvSnapshot(cwd), startupProjectEnvSnapshot()]);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Session id the launched child must see. A trusted pin is passed through.
|
|
529
|
+
* A rejected project pin is replaced by the same fallback the launch plan uses
|
|
530
|
+
* for the session root, which also stops Bun from reloading that dotenv value
|
|
531
|
+
* (`SKC_TMUX_LAUNCHED=1` skips the planner filter). An omitted id stays omitted.
|
|
532
|
+
*/
|
|
533
|
+
export function resolvedChildSkcSessionId(input: {
|
|
534
|
+
trusted: string | undefined;
|
|
535
|
+
inherited: string | undefined;
|
|
536
|
+
projectDeclared: boolean;
|
|
537
|
+
fallback: string;
|
|
538
|
+
}): string | undefined {
|
|
539
|
+
const trusted = input.trusted?.trim();
|
|
540
|
+
if (trusted) return trusted;
|
|
541
|
+
if (!input.inherited?.trim() && !input.projectDeclared) return undefined;
|
|
542
|
+
const fallback = input.fallback.trim();
|
|
543
|
+
return fallback.length > 0 ? fallback : undefined;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
export function childSkcSessionIdAssignment(
|
|
547
|
+
env: NodeJS.ProcessEnv,
|
|
548
|
+
identityEnv: NodeJS.ProcessEnv,
|
|
549
|
+
cwd: string,
|
|
550
|
+
fallbackSessionId: string,
|
|
551
|
+
): Record<string, string> {
|
|
552
|
+
const snapshot = projectEnvSnapshot(cwd);
|
|
553
|
+
const key = canonicalEnvKey("SKC_SESSION_ID");
|
|
554
|
+
const value = resolvedChildSkcSessionId({
|
|
555
|
+
trusted: identityEnv.SKC_SESSION_ID,
|
|
556
|
+
inherited: env.SKC_SESSION_ID,
|
|
557
|
+
projectDeclared: snapshot.values[key] !== undefined || snapshot.dynamic.has(key),
|
|
558
|
+
fallback: fallbackSessionId,
|
|
559
|
+
});
|
|
560
|
+
return value === undefined ? {} : { SKC_SESSION_ID: value };
|
|
561
|
+
}
|
|
562
|
+
|
|
485
563
|
/**
|
|
486
564
|
* A lost reservation means another process already recovered this identity.
|
|
487
565
|
* The caller must perform no further tmux mutation.
|
|
@@ -496,12 +574,14 @@ export function createSkcTmuxSession(
|
|
|
496
574
|
): SkcTmuxSessionStatus {
|
|
497
575
|
const platform = options.platform ?? process.platform;
|
|
498
576
|
const tmuxCommand = resolveSkcTmuxCommand(env, platform);
|
|
499
|
-
const sessionName = buildSkcTmuxSessionName(env);
|
|
500
577
|
const cwd = options.cwd ?? process.cwd();
|
|
501
|
-
const
|
|
578
|
+
const identityEnv = tmuxLaunchIdentityEnv(env, cwd);
|
|
579
|
+
const sessionName = buildSkcTmuxSessionName(identityEnv);
|
|
580
|
+
const sessionId = identityEnv[SKC_COORDINATOR_SESSION_ID_ENV]?.trim() || sessionName;
|
|
581
|
+
const filteredSkcSessionId = identityEnv.SKC_SESSION_ID?.trim() || sessionId;
|
|
502
582
|
const stateFile =
|
|
503
|
-
|
|
504
|
-
tmuxRuntimeSessionPath(cwd,
|
|
583
|
+
identityEnv[SKC_COORDINATOR_SESSION_STATE_FILE_ENV]?.trim() ||
|
|
584
|
+
tmuxRuntimeSessionPath(cwd, filteredSkcSessionId, buildSkcTmuxSessionSlug(sessionName));
|
|
505
585
|
const stateDir = (platform === "win32" ? path.win32 : path).dirname(stateFile);
|
|
506
586
|
const generation = crypto.randomUUID();
|
|
507
587
|
const childEnvironment: Record<string, string> = {
|
|
@@ -511,6 +591,7 @@ export function createSkcTmuxSession(
|
|
|
511
591
|
[SKC_TMUX_OWNER_SERVER_KEY_ENV]: tmuxCommand,
|
|
512
592
|
[SKC_COORDINATOR_SESSION_ID_ENV]: sessionId,
|
|
513
593
|
[SKC_COORDINATOR_SESSION_STATE_FILE_ENV]: stateFile,
|
|
594
|
+
...childSkcSessionIdAssignment(env, identityEnv, cwd, filteredSkcSessionId),
|
|
514
595
|
};
|
|
515
596
|
const shellQuote = (value: string): string => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
516
597
|
const childArgs = options.childArgs ?? [];
|
|
@@ -38,11 +38,27 @@ export async function resolveGitBase(cwd: string, branch?: string): Promise<stri
|
|
|
38
38
|
// and mis-attributes other people's changes to this story (e.g. falsely
|
|
39
39
|
// tripping change-scoped gates). Among existing candidates, pick the one
|
|
40
40
|
// whose merge-base with HEAD is closest to HEAD (fewest commits ahead).
|
|
41
|
-
const candidates = [
|
|
41
|
+
const candidates = [
|
|
42
|
+
"origin/dev",
|
|
43
|
+
"dev",
|
|
44
|
+
"origin/develop",
|
|
45
|
+
"develop",
|
|
46
|
+
"origin/main",
|
|
47
|
+
"origin/master",
|
|
48
|
+
"main",
|
|
49
|
+
"master",
|
|
50
|
+
];
|
|
51
|
+
const currentBranch = await spawnText(["git", "symbolic-ref", "--quiet", "HEAD"], { cwd, timeoutMs: 3000 });
|
|
42
52
|
let best: { ref: string; ahead: number } | undefined;
|
|
43
53
|
for (const candidate of candidates) {
|
|
44
|
-
const exists = await spawnText(["git", "rev-parse", "--verify", candidate], {
|
|
54
|
+
const exists = await spawnText(["git", "rev-parse", "--symbolic-full-name", "--verify", candidate], {
|
|
55
|
+
cwd,
|
|
56
|
+
timeoutMs: 3000,
|
|
57
|
+
});
|
|
45
58
|
if (!exists.ok) continue;
|
|
59
|
+
// Exclude only the checked-out local ref, not distinct refs at the same
|
|
60
|
+
// commit or remote-tracking refs with the same branch name.
|
|
61
|
+
if (currentBranch.ok && exists.stdout.trim() === currentBranch.stdout.trim()) continue;
|
|
46
62
|
const mergeBase = await spawnText(["git", "merge-base", "HEAD", candidate], { cwd, timeoutMs: 3000 });
|
|
47
63
|
if (!mergeBase.ok || !mergeBase.stdout.trim()) continue;
|
|
48
64
|
const count = await spawnText(["git", "rev-list", "--count", `${mergeBase.stdout.trim()}..HEAD`], {
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type UltragoalPlan,
|
|
26
26
|
type UltragoalReceiptKind,
|
|
27
27
|
} from "./ultragoal-runtime";
|
|
28
|
+
import { readUltragoalSuccessionFence } from "./ultragoal-succession";
|
|
28
29
|
|
|
29
30
|
export type UltragoalGuardState =
|
|
30
31
|
| "inactive"
|
|
@@ -821,7 +822,14 @@ async function consumeUltragoalNudge(input: {
|
|
|
821
822
|
if (!sessionId) return { nudged: false };
|
|
822
823
|
const plan = await readUltragoalPlan(input.cwd, sessionId);
|
|
823
824
|
if (!plan) return { nudged: false };
|
|
824
|
-
const
|
|
825
|
+
const fence = await readUltragoalSuccessionFence(input.cwd, sessionId);
|
|
826
|
+
// A goal handed off to a successor run is not this run's resolvable work. Skip
|
|
827
|
+
// fenced goals while selecting, so a retained source-owned goal can still receive
|
|
828
|
+
// the nudge (and keep aggregate drop guarded) without spending budget on the handoff.
|
|
829
|
+
const target = selectUltragoalNudgeTarget(plan, {
|
|
830
|
+
currentGoalObjective: input.currentGoal?.objective,
|
|
831
|
+
excludedGoalIds: fence?.selectedGoalIds,
|
|
832
|
+
});
|
|
825
833
|
if (!target) return { nudged: false };
|
|
826
834
|
const { budget } = await resolveUltragoalNudgeBudget(input.cwd);
|
|
827
835
|
const outcome = await recordUltragoalNudgeIfBudgetRemaining({
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
import {
|
|
35
35
|
assertUltragoalAdoptionPublished,
|
|
36
36
|
assertUltragoalGoalNotFenced,
|
|
37
|
+
readUltragoalSuccessionFence,
|
|
37
38
|
runUltragoalSuccessionCommand,
|
|
38
39
|
} from "./ultragoal-succession";
|
|
39
40
|
|
|
@@ -512,22 +513,27 @@ export async function resolveUltragoalNudgeBudget(cwd: string): Promise<{ budget
|
|
|
512
513
|
*/
|
|
513
514
|
export function selectUltragoalNudgeTarget(
|
|
514
515
|
plan: UltragoalPlan,
|
|
515
|
-
options: { currentGoalObjective?: string; retryFailed?: boolean } = {},
|
|
516
|
+
options: { currentGoalObjective?: string; retryFailed?: boolean; excludedGoalIds?: readonly string[] } = {},
|
|
516
517
|
): UltragoalNudgeTarget | null {
|
|
517
518
|
const objective = options.currentGoalObjective?.trim();
|
|
519
|
+
const isExcluded = (goalId: string): boolean => options.excludedGoalIds?.includes(goalId) ?? false;
|
|
518
520
|
if (objective) {
|
|
519
521
|
const matched = plan.goals.find(
|
|
520
|
-
goal => goal.objective.trim() === objective && SCHEDULABLE_STATUSES.has(goal.status),
|
|
522
|
+
goal => goal.objective.trim() === objective && SCHEDULABLE_STATUSES.has(goal.status) && !isExcluded(goal.id),
|
|
521
523
|
);
|
|
522
524
|
if (matched) return { goalId: matched.id, targetKind: "story" };
|
|
523
525
|
}
|
|
524
|
-
const
|
|
526
|
+
const schedulableGoals = options.excludedGoalIds?.length
|
|
527
|
+
? plan.goals.filter(goal => !isExcluded(goal.id))
|
|
528
|
+
: plan.goals;
|
|
529
|
+
const next = selectNextSchedulableGoal(schedulableGoals, options.retryFailed === true);
|
|
525
530
|
if (next) return { goalId: next.id, targetKind: "story" };
|
|
526
531
|
const completion = getUltragoalRunCompletionState(plan, { retryFailed: options.retryFailed });
|
|
527
532
|
if (completion.needsFinalAggregateReceipt) {
|
|
528
533
|
const required = requiredUltragoalGoals(plan);
|
|
529
534
|
const finalGoal = required.at(-1);
|
|
530
|
-
if (finalGoal
|
|
535
|
+
if (finalGoal && !isExcluded(finalGoal.id))
|
|
536
|
+
return { goalId: finalGoal.id, targetKind: "final_aggregate_receipt" };
|
|
531
537
|
}
|
|
532
538
|
return null;
|
|
533
539
|
}
|
|
@@ -1448,7 +1454,11 @@ export async function getUltragoalStatus(cwd: string, sessionId?: string | null)
|
|
|
1448
1454
|
else if (counts.active > 0) status = "active";
|
|
1449
1455
|
else if (counts.failed > 0) status = "failed";
|
|
1450
1456
|
else if (counts.blocked > 0 || counts.review_blocked > 0) status = "blocked";
|
|
1451
|
-
const
|
|
1457
|
+
const fence = await readUltragoalSuccessionFence(cwd, resolvedSessionId);
|
|
1458
|
+
const nudgeTarget = selectUltragoalNudgeTarget(plan, {
|
|
1459
|
+
currentGoalObjective: currentGoal?.objective,
|
|
1460
|
+
excludedGoalIds: fence?.selectedGoalIds,
|
|
1461
|
+
});
|
|
1452
1462
|
let nudgeFields: Partial<UltragoalStatusSummary> = {};
|
|
1453
1463
|
if (nudgeTarget) {
|
|
1454
1464
|
const { budget } = await resolveUltragoalNudgeBudget(cwd);
|
|
@@ -1619,13 +1629,20 @@ export async function createUltragoalPlan(input: {
|
|
|
1619
1629
|
return plan;
|
|
1620
1630
|
}
|
|
1621
1631
|
|
|
1622
|
-
function
|
|
1632
|
+
export function selectNextSchedulableGoal<T extends { status: UltragoalGoalStatus }>(
|
|
1633
|
+
goals: readonly T[],
|
|
1634
|
+
retryFailed: boolean,
|
|
1635
|
+
): T | undefined {
|
|
1623
1636
|
return (
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
(retryFailed ?
|
|
1637
|
+
goals.find(goal => goal.status === "active") ??
|
|
1638
|
+
goals.find(goal => goal.status === "pending") ??
|
|
1639
|
+
(retryFailed ? goals.find(goal => goal.status === "failed") : undefined)
|
|
1627
1640
|
);
|
|
1628
1641
|
}
|
|
1642
|
+
|
|
1643
|
+
function chooseNextGoal(plan: UltragoalPlan, retryFailed: boolean): UltragoalGoal | undefined {
|
|
1644
|
+
return selectNextSchedulableGoal(plan.goals, retryFailed);
|
|
1645
|
+
}
|
|
1629
1646
|
export interface UltragoalRunCompletionState {
|
|
1630
1647
|
requiredGoals: UltragoalGoal[];
|
|
1631
1648
|
incompleteGoals: UltragoalGoal[];
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
rebuildActiveSnapshot,
|
|
15
15
|
removeActiveEntry,
|
|
16
16
|
setActiveStateCacheInvalidator,
|
|
17
|
+
workflowEnvelopeChecksumStatus,
|
|
17
18
|
writeActiveEntry,
|
|
18
19
|
} from "../skc-runtime/state-writer";
|
|
19
20
|
import { getSkillManifest } from "../skc-runtime/workflow-manifest";
|
|
@@ -447,6 +448,18 @@ async function readModeStatePhase(
|
|
|
447
448
|
const phase = safeString(record.current_phase).trim();
|
|
448
449
|
if (!phase) return undefined;
|
|
449
450
|
if (record.active === false && !getSkillManifest("ralplan").canonicalOverrides.includes(phase)) return undefined;
|
|
451
|
+
const claimedSession = safeString(record.session_id).trim();
|
|
452
|
+
if (claimedSession && claimedSession !== sessionId) return undefined;
|
|
453
|
+
// A mode-state phase may replace the active entry only when the writer
|
|
454
|
+
// stamp still matches. A checksum mismatch is an out-of-band edit. An
|
|
455
|
+
// unsigned releasing phase is not a seal and must not paint "complete"
|
|
456
|
+
// onto a planning entry. Non-releasing canonical phases (final, handoff)
|
|
457
|
+
// still overlay, and a matching stamp still overlays a releasing phase.
|
|
458
|
+
const checksum = workflowEnvelopeChecksumStatus(record);
|
|
459
|
+
if (checksum === "mismatch") return undefined;
|
|
460
|
+
if (checksum === "absent" && getSkillManifest(skill).stopReleasingPhases.includes(phase.trim().toLowerCase())) {
|
|
461
|
+
return undefined;
|
|
462
|
+
}
|
|
450
463
|
return phase;
|
|
451
464
|
} catch {
|
|
452
465
|
return undefined;
|