@sayknow-cli/coding-agent 0.7.10 → 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 +18 -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 +170 -10
- 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
|
@@ -9,7 +9,15 @@
|
|
|
9
9
|
|
|
10
10
|
export const IMPORT_REDACTED_PLACEHOLDER = "[REDACTED]";
|
|
11
11
|
/** Bumped when patterns change; persisted in import provenance. */
|
|
12
|
-
export const IMPORT_SANITIZER_VERSION =
|
|
12
|
+
export const IMPORT_SANITIZER_VERSION = 6;
|
|
13
|
+
|
|
14
|
+
// Terminal escapes and invisible/bidi controls never survive import: they can
|
|
15
|
+
// restyle or hide transcript text when the imported session is rendered.
|
|
16
|
+
const UNSAFE_CONTROL =
|
|
17
|
+
/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2060\u2066-\u2069\ufeff]/gu;
|
|
18
|
+
const HEADER_CREDENTIAL = /(\b(?:authorization|cookie|set-cookie)\b[ \t]*:[ \t]*)([^\r\n]*)/giu;
|
|
19
|
+
const JSON_AUTHORIZATION = /((?:\\?")authorization(?:\\?")\s*:\s*(?:\\?")?)([^",}\r\n]+)/giu;
|
|
20
|
+
|
|
13
21
|
interface RedactionRule {
|
|
14
22
|
readonly id: string;
|
|
15
23
|
readonly pattern: RegExp;
|
|
@@ -48,7 +56,8 @@ const REDACTION_RULES: readonly RedactionRule[] = [
|
|
|
48
56
|
{ id: "gitlab-token", pattern: /glpat-[A-Za-z0-9_-]{16,}/g },
|
|
49
57
|
{ id: "npm-token", pattern: /npm_[A-Za-z0-9]{20,}/g },
|
|
50
58
|
{ id: "google-oauth-token", pattern: /ya29\.[A-Za-z0-9_-]{16,}/g },
|
|
51
|
-
{ id: "stripe-
|
|
59
|
+
{ id: "stripe-key", pattern: /(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}/g },
|
|
60
|
+
{ id: "huggingface-token", pattern: /hf_[A-Za-z0-9]{20,}/g },
|
|
52
61
|
// Authorization values in headers, JSON, YAML, or diagnostic output.
|
|
53
62
|
{
|
|
54
63
|
id: "authorization-credential",
|
|
@@ -86,6 +95,58 @@ const REDACTION_RULES: readonly RedactionRule[] = [
|
|
|
86
95
|
},
|
|
87
96
|
];
|
|
88
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Linear CSI/OSC strip. An unterminated `ESC ]` used to make the global
|
|
100
|
+
* replace rescan every later suffix, which is quadratic in the prefix count.
|
|
101
|
+
*/
|
|
102
|
+
function stripImportedAnsiEscapes(input: string): string {
|
|
103
|
+
if (!input.includes("\u001b")) return input;
|
|
104
|
+
const parts: string[] = [];
|
|
105
|
+
let from = 0;
|
|
106
|
+
let i = 0;
|
|
107
|
+
let oscLive = true;
|
|
108
|
+
const n = input.length;
|
|
109
|
+
while (i < n) {
|
|
110
|
+
const esc = input.indexOf("\u001b", i);
|
|
111
|
+
if (esc < 0 || esc + 1 >= n) break;
|
|
112
|
+
const kind = input.charCodeAt(esc + 1);
|
|
113
|
+
let end = -1;
|
|
114
|
+
if (kind === 0x5b) end = csiSequenceEnd(input, esc + 2);
|
|
115
|
+
else if (kind === 0x5d && oscLive) end = oscSequenceEnd(input, esc + 2);
|
|
116
|
+
// No BEL and no ST anywhere after this prefix, so later OSC cannot terminate.
|
|
117
|
+
if (kind === 0x5d && end < 0) oscLive = false;
|
|
118
|
+
if (end < 0) {
|
|
119
|
+
i = esc + 1;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (esc > from) parts.push(input.slice(from, esc));
|
|
123
|
+
from = end;
|
|
124
|
+
i = end;
|
|
125
|
+
}
|
|
126
|
+
if (from === 0) return input;
|
|
127
|
+
if (from < n) parts.push(input.slice(from));
|
|
128
|
+
return parts.join("");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function csiSequenceEnd(input: string, j: number): number {
|
|
132
|
+
const n = input.length;
|
|
133
|
+
while (j < n && input.charCodeAt(j) >= 0x30 && input.charCodeAt(j) <= 0x3f) j++;
|
|
134
|
+
while (j < n && input.charCodeAt(j) >= 0x20 && input.charCodeAt(j) <= 0x2f) j++;
|
|
135
|
+
const finalByte = input.charCodeAt(j);
|
|
136
|
+
return finalByte >= 0x40 && finalByte <= 0x7e ? j + 1 : -1;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function oscSequenceEnd(input: string, index: number): number {
|
|
140
|
+
// One forward scan. A second search to the end of the suffix is quadratic for repeated OSC sequences.
|
|
141
|
+
const n = input.length;
|
|
142
|
+
for (let j = index; j < n; j++) {
|
|
143
|
+
const code = input.charCodeAt(j);
|
|
144
|
+
if (code === 0x07) return j + 1;
|
|
145
|
+
if (code === 0x1b && j + 1 < n && input.charCodeAt(j + 1) === 0x5c) return j + 2;
|
|
146
|
+
}
|
|
147
|
+
return -1;
|
|
148
|
+
}
|
|
149
|
+
|
|
89
150
|
export interface ImportRedactionResult {
|
|
90
151
|
value: string;
|
|
91
152
|
redacted: number;
|
|
@@ -97,9 +158,21 @@ export interface ImportRedactionResult {
|
|
|
97
158
|
* is used for all kinds so a partial pattern overlap cannot leak fragments.
|
|
98
159
|
*/
|
|
99
160
|
export function redactImportedText(input: string): ImportRedactionResult {
|
|
100
|
-
let value = input;
|
|
161
|
+
let value = stripImportedAnsiEscapes(input).replace(UNSAFE_CONTROL, "");
|
|
101
162
|
let redacted = 0;
|
|
102
163
|
const kinds = new Set<string>();
|
|
164
|
+
value = value.replace(HEADER_CREDENTIAL, (_match, prefix: string, raw: string) => {
|
|
165
|
+
if (!raw.trim()) return `${prefix}${raw}`;
|
|
166
|
+
redacted++;
|
|
167
|
+
kinds.add("credential-header");
|
|
168
|
+
return `${prefix}${IMPORT_REDACTED_PLACEHOLDER}`;
|
|
169
|
+
});
|
|
170
|
+
value = value.replace(JSON_AUTHORIZATION, (_match, prefix: string, raw: string) => {
|
|
171
|
+
if (!raw.trim()) return `${prefix}${raw}`;
|
|
172
|
+
redacted++;
|
|
173
|
+
kinds.add("authorization-json");
|
|
174
|
+
return `${prefix}${IMPORT_REDACTED_PLACEHOLDER}`;
|
|
175
|
+
});
|
|
103
176
|
for (const rule of REDACTION_RULES) {
|
|
104
177
|
rule.pattern.lastIndex = 0;
|
|
105
178
|
value = value.replace(rule.pattern, match => {
|
|
@@ -158,7 +158,10 @@ function parseMutationClasses(values: string[] | undefined): HermesMutationClass
|
|
|
158
158
|
function parseByteCap(value: string | undefined): number | undefined {
|
|
159
159
|
if (value === undefined) return undefined;
|
|
160
160
|
const parsed = Number(value);
|
|
161
|
-
|
|
161
|
+
// Safe integers only: the cap is serialized with String(), and the runtime policy
|
|
162
|
+
// parser accepts plain digits, so an unsafe integer such as 1e21 ("1e+21") would
|
|
163
|
+
// silently fall back to the default cap there.
|
|
164
|
+
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
|
|
162
165
|
throw new HermesSetupError("--artifact-byte-cap must be a positive integer.", 2);
|
|
163
166
|
}
|
|
164
167
|
return parsed;
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
* - Dry-run by default: nothing is deleted unless `--prune`/`--force`.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { getAgentDir } from "@sayknow-cli/utils";
|
|
16
|
+
import { getAgentDir, loadedProjectEnvSnapshot } from "@sayknow-cli/utils";
|
|
17
|
+
import { type ProjectEnvSnapshot, projectEnvSnapshot } from "@sayknow-cli/utils/env-file";
|
|
17
18
|
import { SessionIndex } from "../sdk/broker/session-index";
|
|
18
19
|
import { UnsupportedStateVersionError } from "../sdk/broker/state-version";
|
|
19
20
|
|
|
20
21
|
import { buildGcReportText } from "./gc-render";
|
|
22
|
+
import { trustedCoordinatorEnv } from "./sidecar-bootstrap-env";
|
|
21
23
|
|
|
22
24
|
export type GcStore =
|
|
23
25
|
| "harness_leases"
|
|
@@ -366,8 +368,21 @@ export function computeExitCode(report: GcReport): number {
|
|
|
366
368
|
return 0;
|
|
367
369
|
}
|
|
368
370
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
+
/**
|
|
372
|
+
* Operator override only. Same project-dotenv rule as `getAgentDir()`: a value
|
|
373
|
+
* the checkout declares is ignored, and an operator value it does not declare
|
|
374
|
+
* is kept. A repository `.env` must not choose the tree `skc gc` reclaims.
|
|
375
|
+
*
|
|
376
|
+
* `snapshot` is the dotenv provenance from when that environment was loaded.
|
|
377
|
+
* `process.env` uses the module-load snapshot. A separate env map uses the
|
|
378
|
+
* snapshot taken with it before awaited GC work. Neither path rereads files later.
|
|
379
|
+
*/
|
|
380
|
+
function resolveGcAgentDir(env: NodeJS.ProcessEnv, snapshot: ProjectEnvSnapshot): string {
|
|
381
|
+
return (
|
|
382
|
+
trustedCoordinatorEnv("SKC_CODING_AGENT_DIR", env, snapshot) ||
|
|
383
|
+
trustedCoordinatorEnv("PI_CODING_AGENT_DIR", env, snapshot) ||
|
|
384
|
+
getAgentDir()
|
|
385
|
+
);
|
|
371
386
|
}
|
|
372
387
|
|
|
373
388
|
async function collectSessionIndexHealth(repair: boolean, agentDir: string): Promise<GcSessionIndexHealth> {
|
|
@@ -406,6 +421,10 @@ export async function runSkcGcCommand(
|
|
|
406
421
|
env: NodeJS.ProcessEnv = process.env,
|
|
407
422
|
adapters?: GcStoreAdapter[],
|
|
408
423
|
): Promise<GcRunResult> {
|
|
424
|
+
// process.env was loaded before this module. Reusing that snapshot keeps a
|
|
425
|
+
// project value rejected after its declaration is removed or changed.
|
|
426
|
+
// A caller-supplied env is not that load: bind its cwd files once, here.
|
|
427
|
+
const loadedProjectEnv = env === process.env ? loadedProjectEnvSnapshot() : projectEnvSnapshot(cwd);
|
|
409
428
|
let parsed: ParsedGcArgs;
|
|
410
429
|
try {
|
|
411
430
|
parsed = parseGcArgs(argv);
|
|
@@ -422,7 +441,10 @@ export async function runSkcGcCommand(
|
|
|
422
441
|
const ctx: GcContext = { probe: gcPidProbe, force: parsed.prune, env, cwd };
|
|
423
442
|
const report = await collectGcReport(resolvedAdapters, ctx, parsed.prune);
|
|
424
443
|
report.operation = parsed.repairSessionIndex ? "repair_session_index" : parsed.prune ? "prune" : "dry_run";
|
|
425
|
-
report.session_index = await collectSessionIndexHealth(
|
|
444
|
+
report.session_index = await collectSessionIndexHealth(
|
|
445
|
+
parsed.repairSessionIndex,
|
|
446
|
+
resolveGcAgentDir(env, loadedProjectEnv),
|
|
447
|
+
);
|
|
426
448
|
const sessionIndexFailed =
|
|
427
449
|
report.session_index?.status === "corrupt" ||
|
|
428
450
|
report.session_index?.status === "unsupported" ||
|
|
@@ -26,7 +26,13 @@ import {
|
|
|
26
26
|
releaseIdentityCreate,
|
|
27
27
|
reserveIdentityCreate,
|
|
28
28
|
} from "./tmux-owner-isolation";
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
childSkcSessionIdAssignment,
|
|
31
|
+
findSkcTmuxSessionByName,
|
|
32
|
+
findSkcTmuxSessionByScope,
|
|
33
|
+
type SkcTmuxSessionStatus,
|
|
34
|
+
tmuxLaunchIdentityEnv,
|
|
35
|
+
} from "./tmux-sessions";
|
|
30
36
|
|
|
31
37
|
export {
|
|
32
38
|
buildSkcTmuxExactSessionTarget,
|
|
@@ -241,6 +247,8 @@ function buildWindowsPowerShellInnerCommand(context: CommandResolutionContext, r
|
|
|
241
247
|
|
|
242
248
|
export function applySkcTmuxProfile(context: SkcTmuxProfileContext): SkcTmuxProfileResult {
|
|
243
249
|
const env = context.env ?? process.env;
|
|
250
|
+
const cwd = context.cwd ?? process.cwd();
|
|
251
|
+
const identityEnv = tmuxLaunchIdentityEnv(env, cwd);
|
|
244
252
|
const branchSlug = context.branch ? buildSkcTmuxSessionSlug(context.branch) : (context.branchSlug ?? null);
|
|
245
253
|
// The psmux UX filter (mouse / set-clipboard / mode-style /
|
|
246
254
|
// set-window-option) now lives in buildSkcTmuxProfileCommands so every
|
|
@@ -256,15 +264,14 @@ export function applySkcTmuxProfile(context: SkcTmuxProfileContext): SkcTmuxProf
|
|
|
256
264
|
branch: context.branch ?? null,
|
|
257
265
|
branchSlug,
|
|
258
266
|
project: context.project ?? null,
|
|
259
|
-
sessionId: context.sessionId ??
|
|
260
|
-
sessionStateFile: context.sessionStateFile ??
|
|
267
|
+
sessionId: context.sessionId ?? identityEnv[SKC_COORDINATOR_SESSION_ID_ENV] ?? null,
|
|
268
|
+
sessionStateFile: context.sessionStateFile ?? identityEnv[SKC_COORDINATOR_SESSION_STATE_FILE_ENV] ?? null,
|
|
261
269
|
version: context.version ?? null,
|
|
262
270
|
},
|
|
263
271
|
{ tmuxCommand: context.tmuxCommand },
|
|
264
272
|
);
|
|
265
273
|
if (commands.length === 0) return { skipped: true, commands: [], failures: [] };
|
|
266
274
|
const spawnSync = context.spawnSync ?? defaultSpawnSync;
|
|
267
|
-
const cwd = context.cwd ?? process.cwd();
|
|
268
275
|
const options: TmuxSpawnOptions = { cwd, env, stdin: "inherit", stdout: "inherit", stderr: "inherit" };
|
|
269
276
|
const failures: SkcTmuxProfileResult["failures"] = [];
|
|
270
277
|
for (const command of commands) {
|
|
@@ -540,33 +547,35 @@ export function buildDefaultTmuxLaunchPlan(context: TmuxLaunchContext): TmuxLaun
|
|
|
540
547
|
if (policy === "tmux" && !isInteractiveRootLaunch(context.parsed, tty)) return undefined;
|
|
541
548
|
|
|
542
549
|
const cwd = context.cwd ?? process.cwd();
|
|
550
|
+
const identityEnv = tmuxLaunchIdentityEnv(env, cwd);
|
|
543
551
|
const branch = context.worktreeBranch ?? context.currentBranch ?? readCurrentBranch(cwd);
|
|
544
552
|
const project = context.project ?? cwd;
|
|
545
|
-
const sessionName = buildSkcTmuxSessionName(
|
|
553
|
+
const sessionName = buildSkcTmuxSessionName(identityEnv, { branch });
|
|
546
554
|
// Pick the most appropriate tmux binary for this platform. On native Windows
|
|
547
555
|
// the resolver walks psmux / pmux / tmux and uses the first one present on
|
|
548
556
|
// PATH, so the default `skc --tmux` flow lands on a real multiplexer even
|
|
549
557
|
// without an explicit SKC_TMUX_COMMAND override.
|
|
550
558
|
const resolvedBinary = resolveSkcTmuxBinary({ platform, env });
|
|
551
559
|
const tmuxCommand = resolvedBinary.command;
|
|
552
|
-
const sessionId =
|
|
560
|
+
const sessionId = identityEnv[SKC_COORDINATOR_SESSION_ID_ENV]?.trim() || sessionName;
|
|
553
561
|
// The session ROOT is keyed by the active SKC session (SKC_SESSION_ID), NOT the
|
|
554
562
|
// coordinator/tmux identity. Fall back to the coordinator id only for standalone
|
|
555
|
-
// tmux launches with no SKC session context.
|
|
556
|
-
|
|
563
|
+
// tmux launches with no SKC session context. Project dotenv pins are already
|
|
564
|
+
// removed from identityEnv.
|
|
565
|
+
const skcSessionId = identityEnv.SKC_SESSION_ID?.trim() || sessionId;
|
|
557
566
|
const sessionStateFile =
|
|
558
|
-
|
|
567
|
+
identityEnv[SKC_COORDINATOR_SESSION_STATE_FILE_ENV]?.trim() ||
|
|
559
568
|
tmuxRuntimeSessionPath(cwd, skcSessionId, buildSkcTmuxSessionSlug(sessionName));
|
|
560
569
|
const tmuxAvailable = context.tmuxAvailable ?? Bun.which(tmuxCommand) !== null;
|
|
561
570
|
if (!tmuxAvailable) {
|
|
562
571
|
(context.diagnosticWriter ?? safeStderrWrite)(formatTmuxUnavailableDiagnostic(platform, tmuxCommand));
|
|
563
572
|
return undefined;
|
|
564
573
|
}
|
|
565
|
-
const existingSessionName = allowsExistingTmuxAttach(context.parsed,
|
|
574
|
+
const existingSessionName = allowsExistingTmuxAttach(context.parsed, identityEnv)
|
|
566
575
|
? "existingBranchSessionName" in context
|
|
567
576
|
? (context.existingBranchSessionName ?? undefined)
|
|
568
577
|
: findExistingSessionForLaunch({
|
|
569
|
-
env,
|
|
578
|
+
env: identityEnv,
|
|
570
579
|
project,
|
|
571
580
|
branch,
|
|
572
581
|
})
|
|
@@ -577,6 +586,7 @@ export function buildDefaultTmuxLaunchPlan(context: TmuxLaunchContext): TmuxLaun
|
|
|
577
586
|
argv: context.argv ?? process.argv,
|
|
578
587
|
execPath: context.execPath ?? process.execPath,
|
|
579
588
|
extraEnv: {
|
|
589
|
+
...childSkcSessionIdAssignment(env, identityEnv, cwd, skcSessionId),
|
|
580
590
|
[SKC_COORDINATOR_SESSION_ID_ENV]: sessionId,
|
|
581
591
|
[SKC_COORDINATOR_SESSION_STATE_FILE_ENV]: sessionStateFile,
|
|
582
592
|
},
|
|
@@ -172,12 +172,52 @@ function isWorktreeDirty(worktreePath: string): boolean {
|
|
|
172
172
|
return runGit(worktreePath, ["status", "--porcelain"]).length > 0;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/** Porcelain status is clean when the only unique state is commits on this detached HEAD. */
|
|
176
|
+
function isCommitAncestor(cwd: string, ancestor: string, descendant: string): boolean {
|
|
177
|
+
const result = Bun.spawnSync(["git", "merge-base", "--is-ancestor", ancestor, descendant], {
|
|
178
|
+
cwd,
|
|
179
|
+
stdout: "ignore",
|
|
180
|
+
stderr: "pipe",
|
|
181
|
+
});
|
|
182
|
+
if (result.exitCode === 0) return true;
|
|
183
|
+
if (result.exitCode === 1) return false;
|
|
184
|
+
const stderr = result.stderr.toString().trim();
|
|
185
|
+
throw new Error(stderr || "git merge-base --is-ancestor failed");
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function formatWorktreeDiverged(worktreePath: string, existingHead: string, baseRef: string): string {
|
|
189
|
+
return [
|
|
190
|
+
`worktree_diverged:${worktreePath}`,
|
|
191
|
+
`SKC refused to move detached launch worktree ${existingHead} onto ${baseRef} because that commit is not an ancestor of the source HEAD.`,
|
|
192
|
+
`Path: ${worktreePath}`,
|
|
193
|
+
"Checking out the source HEAD would drop that commit from this worktree. Safe remediation: create a branch at HEAD so the commit stays reachable (git branch <name>), then retarget or remove the worktree yourself if a later launch should reuse this path. SKC did not change HEAD.",
|
|
194
|
+
].join("\n");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function reuseDetachedLaunchHead(plan: SkcLaunchWorktreePlan, existingHead: string, dirty: boolean): void {
|
|
198
|
+
if (dirty) throw new Error(`worktree_dirty:${plan.worktreePath}`);
|
|
199
|
+
if (!isCommitAncestor(plan.worktreePath, existingHead, plan.baseRef)) {
|
|
200
|
+
throw new Error(formatWorktreeDiverged(plan.worktreePath, existingHead, plan.baseRef));
|
|
201
|
+
}
|
|
202
|
+
runGit(plan.worktreePath, ["checkout", "--detach", plan.baseRef]);
|
|
203
|
+
}
|
|
204
|
+
|
|
175
205
|
function resolveOptionalWorktreeName(args: string[], index: number): { name: string | null; nextIndex: number } {
|
|
176
206
|
const next = args[index + 1];
|
|
177
207
|
if (!next) return { name: null, nextIndex: index };
|
|
178
208
|
if (next === "--") return { name: null, nextIndex: index + 1 };
|
|
179
209
|
if (next.startsWith("-")) return { name: null, nextIndex: index };
|
|
180
|
-
|
|
210
|
+
// A bare --worktree is the detached selector. Only consume the following
|
|
211
|
+
// positional token as a branch name when it is a valid ref; otherwise it is
|
|
212
|
+
// the launch prompt and must remain in the forwarded arguments.
|
|
213
|
+
const trimmed = next.trim();
|
|
214
|
+
if (!trimmed || /\s/.test(trimmed)) return { name: null, nextIndex: index };
|
|
215
|
+
const valid =
|
|
216
|
+
Bun.spawnSync(["git", "check-ref-format", "--branch", trimmed], {
|
|
217
|
+
stdout: "ignore",
|
|
218
|
+
stderr: "ignore",
|
|
219
|
+
}).exitCode === 0;
|
|
220
|
+
return valid ? { name: trimmed, nextIndex: index + 1 } : { name: null, nextIndex: index };
|
|
181
221
|
}
|
|
182
222
|
|
|
183
223
|
export function parseLaunchWorktreeMode(args: string[]): ParsedLaunchWorktreeMode {
|
|
@@ -296,8 +336,7 @@ export function ensureLaunchWorktree(
|
|
|
296
336
|
throw new Error(formatWorktreeTargetMismatch(plan, existingAtPath));
|
|
297
337
|
}
|
|
298
338
|
if (existingAtPath.head !== plan.baseRef) {
|
|
299
|
-
|
|
300
|
-
runGit(plan.worktreePath, ["checkout", "--detach", plan.baseRef]);
|
|
339
|
+
reuseDetachedLaunchHead(plan, existingAtPath.head, dirty);
|
|
301
340
|
dirty = false;
|
|
302
341
|
}
|
|
303
342
|
} else if (existingAtPath.branchRef !== expectedBranchRef) {
|
|
@@ -3,6 +3,7 @@ import * as crypto from "node:crypto";
|
|
|
3
3
|
import * as fs from "node:fs/promises";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import { openRecoveryFsRoot } from "@sayknow-cli/natives";
|
|
6
|
+
import { canonicalEnvKey, type ProjectEnvSnapshot, projectEnvSnapshot } from "@sayknow-cli/utils/env-file";
|
|
6
7
|
import {
|
|
7
8
|
MANAGED_OWNER_CHILD_TOKEN_ENV,
|
|
8
9
|
MANAGED_OWNER_GENERATION_ENV,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
type ManagedOwnerSigabrtReceipt,
|
|
15
16
|
} from "./managed-owner-supervisor";
|
|
16
17
|
import { assertSafePathComponent } from "./session-layout";
|
|
18
|
+
import { trustedCoordinatorEnv } from "./sidecar-bootstrap-env";
|
|
17
19
|
import { lifecyclePaths } from "./tmux-owner-isolation";
|
|
18
20
|
import {
|
|
19
21
|
persistUltragoalRecoveryDecision,
|
|
@@ -26,6 +28,48 @@ export const MANAGED_OWNER_PREDECESSOR_GENERATION_ENV = "SKC_MANAGED_OWNER_PREDE
|
|
|
26
28
|
export const MANAGED_OWNER_PREDECESSOR_RUN_ID_ENV = "SKC_MANAGED_OWNER_PREDECESSOR_RUN_ID";
|
|
27
29
|
export const MANAGED_OWNER_PREDECESSOR_INCARNATION_ENV = "SKC_MANAGED_OWNER_PREDECESSOR_INCARNATION";
|
|
28
30
|
export const MANAGED_OWNER_TRANSCRIPT_PATH_ENV = "SKC_MANAGED_OWNER_TRANSCRIPT_PATH";
|
|
31
|
+
const MANAGED_OWNER_SESSION_FILE_ENV = "SKC_SESSION_FILE";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Operator environment only. A project dotenv value, including a dynamic
|
|
35
|
+
* declaration, must not choose the recovery transcript. A static
|
|
36
|
+
* `SKC_SESSION_FILE` declaration is the same source: the launcher copies it
|
|
37
|
+
* into the transcript variable. The operator bytes are kept, including
|
|
38
|
+
* surrounding whitespace; provenance is not path normalization.
|
|
39
|
+
*/
|
|
40
|
+
function operatorOwnedEnvValue(name: string, raw: string | undefined, snapshot: ProjectEnvSnapshot): string {
|
|
41
|
+
if (!raw) return "";
|
|
42
|
+
const key = canonicalEnvKey(name);
|
|
43
|
+
const declared = snapshot.values[key];
|
|
44
|
+
if (declared !== undefined && (snapshot.dynamic.has(key) || declared === raw)) return "";
|
|
45
|
+
const verdict = trustedCoordinatorEnv(name, { [name]: raw }, snapshot);
|
|
46
|
+
if (verdict === undefined && raw.trim().length > 0) return "";
|
|
47
|
+
return raw;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function trustedManagedOwnerTranscriptPath(env: NodeJS.ProcessEnv = process.env, cwd = process.cwd()): string {
|
|
51
|
+
const snapshot = projectEnvSnapshot(cwd);
|
|
52
|
+
const raw = operatorOwnedEnvValue(
|
|
53
|
+
MANAGED_OWNER_TRANSCRIPT_PATH_ENV,
|
|
54
|
+
env[MANAGED_OWNER_TRANSCRIPT_PATH_ENV],
|
|
55
|
+
snapshot,
|
|
56
|
+
);
|
|
57
|
+
if (!raw) return "";
|
|
58
|
+
const sessionKey = canonicalEnvKey(MANAGED_OWNER_SESSION_FILE_ENV);
|
|
59
|
+
if (snapshot.dynamic.has(sessionKey)) return raw;
|
|
60
|
+
const declared = snapshot.values[sessionKey];
|
|
61
|
+
if (declared !== undefined && raw === declared) return "";
|
|
62
|
+
return raw;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Session file forwarded to a replacement child. Same provenance rule. */
|
|
66
|
+
export function trustedManagedOwnerLaunchSessionFile(env: NodeJS.ProcessEnv, cwd: string): string {
|
|
67
|
+
return operatorOwnedEnvValue(
|
|
68
|
+
MANAGED_OWNER_SESSION_FILE_ENV,
|
|
69
|
+
env[MANAGED_OWNER_SESSION_FILE_ENV],
|
|
70
|
+
projectEnvSnapshot(cwd),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
29
73
|
|
|
30
74
|
export interface ManagedOwnerRecoveryContext {
|
|
31
75
|
root: string;
|
|
@@ -273,7 +317,7 @@ export async function admitManagedOwnerBeforeCli(): Promise<ManagedOwnerAdmissio
|
|
|
273
317
|
},
|
|
274
318
|
receipt,
|
|
275
319
|
admission,
|
|
276
|
-
transcriptPath:
|
|
320
|
+
transcriptPath: trustedManagedOwnerTranscriptPath(),
|
|
277
321
|
});
|
|
278
322
|
await persistUltragoalRecoveryDecision({
|
|
279
323
|
cwd: process.cwd(),
|
|
@@ -312,7 +356,7 @@ export async function completeManagedOwnerRecovery(
|
|
|
312
356
|
binding: recoveryBinding,
|
|
313
357
|
receipt: context.receipt,
|
|
314
358
|
admission: context.admission,
|
|
315
|
-
transcriptPath:
|
|
359
|
+
transcriptPath: trustedManagedOwnerTranscriptPath(),
|
|
316
360
|
protectedPaths: context.decision.snapshot?.protectedPaths,
|
|
317
361
|
sanctionedDeltas: context.decision.snapshot?.sanctionedDeltas,
|
|
318
362
|
absentArtifacts: context.decision.snapshot?.absentArtifacts,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
|
+
import { canonicalEnvKey, projectEnvSnapshot } from "@sayknow-cli/utils/env-file";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Windows psmux detection and tmux-binary resolution.
|
|
@@ -272,17 +273,40 @@ export interface ResolvedTmuxBinary {
|
|
|
272
273
|
viaExplicitOverride: boolean;
|
|
273
274
|
}
|
|
274
275
|
|
|
276
|
+
/** Captured when this module loads, before a later `chdir` or dotenv delete. */
|
|
277
|
+
const startupTmuxCommandSnapshot = projectEnvSnapshot();
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Operator override only. Bun has already copied the project dotenv into the
|
|
281
|
+
* environment, so a value that matches `projectEnvSnapshot` — a static hit or
|
|
282
|
+
* a dynamic declaration — must not select the binary. An operator value the
|
|
283
|
+
* project does not declare is kept.
|
|
284
|
+
*/
|
|
285
|
+
function trustedTmuxCommand(env: NodeJS.ProcessEnv, name: string): string | undefined {
|
|
286
|
+
const raw = env[name];
|
|
287
|
+
if (!raw) return undefined;
|
|
288
|
+
const snapshot = startupTmuxCommandSnapshot;
|
|
289
|
+
const key = canonicalEnvKey(name);
|
|
290
|
+
const declared = snapshot.values[key];
|
|
291
|
+
const trimmed = raw.trim();
|
|
292
|
+
if (declared !== undefined && (snapshot.dynamic.has(key) || declared === raw || declared === trimmed)) {
|
|
293
|
+
return undefined;
|
|
294
|
+
}
|
|
295
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
296
|
+
}
|
|
297
|
+
|
|
275
298
|
/**
|
|
276
|
-
* Resolve the tmux command SKC should invoke. Honors
|
|
277
|
-
* SKC_TMUX_COMMAND / SKC_TEAM_TMUX_COMMAND
|
|
278
|
-
* override is set, psmux (installed as psmux,
|
|
279
|
-
* automatically so the default skc --tmux flow lands
|
|
299
|
+
* Resolve the tmux command SKC should invoke. Honors an operator
|
|
300
|
+
* SKC_TMUX_COMMAND / SKC_TEAM_TMUX_COMMAND override; a project dotenv value is
|
|
301
|
+
* ignored. On Windows when no override is set, psmux (installed as psmux,
|
|
302
|
+
* pmux, or tmux) is picked automatically so the default skc --tmux flow lands
|
|
303
|
+
* on a real multiplexer.
|
|
280
304
|
*/
|
|
281
305
|
export function resolveSkcTmuxBinary(options: ResolveSkcTmuxBinaryOptions = {}): ResolvedTmuxBinary {
|
|
282
306
|
const env = options.env ?? process.env;
|
|
283
307
|
const platform = options.platform ?? process.platform;
|
|
284
308
|
const runner = options.runner ?? readSpawnRunner();
|
|
285
|
-
const explicit = env
|
|
309
|
+
const explicit = trustedTmuxCommand(env, "SKC_TMUX_COMMAND") ?? trustedTmuxCommand(env, "SKC_TEAM_TMUX_COMMAND");
|
|
286
310
|
if (explicit) {
|
|
287
311
|
const isPsmux =
|
|
288
312
|
platform === "win32"
|
|
@@ -2,6 +2,7 @@ import { createHash, randomBytes } from "node:crypto";
|
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { getConfigRootDir } from "@sayknow-cli/utils";
|
|
5
|
+
import { sanitizeImportedString } from "../session-import/redact";
|
|
5
6
|
import { syncSkillActiveState } from "../skill-state/active-state";
|
|
6
7
|
import { buildRalplanHudSummary } from "../skill-state/workflow-hud";
|
|
7
8
|
import { WORKFLOW_STATE_VERSION } from "../skill-state/workflow-state-contract";
|
|
@@ -1492,6 +1493,16 @@ async function buildRalplanHud(options: {
|
|
|
1492
1493
|
});
|
|
1493
1494
|
}
|
|
1494
1495
|
|
|
1496
|
+
/**
|
|
1497
|
+
* Credential scrub for a ralplan stage body. The result is what
|
|
1498
|
+
* `skc ralplan --write` hashes and stores.
|
|
1499
|
+
*/
|
|
1500
|
+
export function scrubRalplanPersistedBody(content: string): string {
|
|
1501
|
+
const normalized = content.endsWith("\n") ? content : `${content}\n`;
|
|
1502
|
+
const scrubbed = sanitizeImportedString(normalized);
|
|
1503
|
+
return scrubbed.endsWith("\n") ? scrubbed : `${scrubbed}\n`;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1495
1506
|
async function handleArtifactWrite(args: readonly string[], cwd: string): Promise<RalplanCommandResult> {
|
|
1496
1507
|
const resolved = await resolveArtifactArgs(args, cwd);
|
|
1497
1508
|
const persistedRoleState = parsePersistedRoleStateArgs(args, resolved.stage);
|
|
@@ -1514,7 +1525,9 @@ async function handleArtifactWrite(args: readonly string[], cwd: string): Promis
|
|
|
1514
1525
|
// Non-file / missing path is inline content; resolveArtifactContent already handled it.
|
|
1515
1526
|
}
|
|
1516
1527
|
}
|
|
1517
|
-
|
|
1528
|
+
// Scrub before the content hash. The ledger, dedupe, and pending-approval copy
|
|
1529
|
+
// all trust this digest, so it has to name the bytes that actually land on disk.
|
|
1530
|
+
const content = scrubRalplanPersistedBody(resolved.artifact);
|
|
1518
1531
|
const sha256 = createHash("sha256").update(content).digest("hex");
|
|
1519
1532
|
|
|
1520
1533
|
// Read the ledger once before persistence. The dedupe guard and both gates
|
|
@@ -29,6 +29,14 @@ import {
|
|
|
29
29
|
/** Window within which two activity timestamps are treated as an ambiguous tie. */
|
|
30
30
|
export const LATEST_SESSION_TIE_WINDOW_MS = 1000;
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Local writers stamp `Date.now()`. A parsed `updated_at` further ahead than this
|
|
34
|
+
* is planted marker content, not activity, and is not a candidate. Marker mtime
|
|
35
|
+
* is not used in that case: a checkout or touch refreshes mtime without rewriting
|
|
36
|
+
* a future timestamp.
|
|
37
|
+
*/
|
|
38
|
+
const ACTIVITY_FUTURE_SKEW_MS = 2 * 60 * 1000;
|
|
39
|
+
|
|
32
40
|
export interface SessionIdSources {
|
|
33
41
|
/** Raw `--session-id` value: `undefined` = flag absent; `""` = present-but-blank (invalid). */
|
|
34
42
|
flagValue?: string | undefined;
|
|
@@ -46,8 +54,12 @@ export class SessionResolutionError extends Error {
|
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
|
|
57
|
+
function isUnsafeResolvedSessionId(sessionId: string): boolean {
|
|
58
|
+
return sessionId === "." || sessionId === ".." || /[/\\]/.test(sessionId);
|
|
59
|
+
}
|
|
60
|
+
|
|
49
61
|
function assertSafeResolvedSessionId(sessionId: string): void {
|
|
50
|
-
if (
|
|
62
|
+
if (isUnsafeResolvedSessionId(sessionId)) {
|
|
51
63
|
throw new SessionResolutionError(
|
|
52
64
|
"session id must be a single path component (no separators or traversal)",
|
|
53
65
|
"unsafe_session",
|
|
@@ -135,8 +147,17 @@ interface SessionCandidate {
|
|
|
135
147
|
* or an ambiguous tie.
|
|
136
148
|
*/
|
|
137
149
|
export async function detectLatestSession(cwd: string): Promise<SkcSessionContext> {
|
|
138
|
-
const
|
|
150
|
+
const found = await collectActiveSessionCandidates(cwd);
|
|
151
|
+
const candidates = found.candidates;
|
|
139
152
|
if (candidates.length === 0) {
|
|
153
|
+
// No safe session was selectable. Keep the unsafe-id error when a crafted
|
|
154
|
+
// directory was the reason nothing could be chosen, matching explicit ids.
|
|
155
|
+
if (found.sawUnsafe) {
|
|
156
|
+
throw new SessionResolutionError(
|
|
157
|
+
"session id must be a single path component (no separators or traversal)",
|
|
158
|
+
"unsafe_session",
|
|
159
|
+
);
|
|
160
|
+
}
|
|
140
161
|
throw new SessionResolutionError(
|
|
141
162
|
"no active SKC session found: pass --session-id or set SKC_SESSION_ID",
|
|
142
163
|
"no_session",
|
|
@@ -156,19 +177,27 @@ export async function detectLatestSession(cwd: string): Promise<SkcSessionContex
|
|
|
156
177
|
return { skcSessionId: first.skcSessionId, sessionRoot: first.sessionRoot, source: "latest" };
|
|
157
178
|
}
|
|
158
179
|
|
|
159
|
-
async function collectActiveSessionCandidates(
|
|
180
|
+
async function collectActiveSessionCandidates(
|
|
181
|
+
cwd: string,
|
|
182
|
+
): Promise<{ candidates: SessionCandidate[]; sawUnsafe: boolean }> {
|
|
160
183
|
const root = skcRoot(cwd);
|
|
161
184
|
let entries: import("node:fs").Dirent[];
|
|
162
185
|
try {
|
|
163
186
|
entries = await fs.readdir(root, { withFileTypes: true });
|
|
164
187
|
} catch {
|
|
165
|
-
return [];
|
|
188
|
+
return { candidates: [], sawUnsafe: false };
|
|
166
189
|
}
|
|
167
190
|
const candidates: SessionCandidate[] = [];
|
|
191
|
+
let sawUnsafe = false;
|
|
168
192
|
for (const entry of entries) {
|
|
169
193
|
if (!entry.isDirectory()) continue;
|
|
170
194
|
const skcSessionId = sessionIdFromDirName(entry.name);
|
|
171
195
|
if (!skcSessionId) continue;
|
|
196
|
+
// Skip; throwing here would stop discovery for every other session.
|
|
197
|
+
if (isUnsafeResolvedSessionId(skcSessionId)) {
|
|
198
|
+
sawUnsafe = true;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
172
201
|
assertSafeResolvedSessionId(skcSessionId);
|
|
173
202
|
const dir = path.join(root, entry.name);
|
|
174
203
|
const activityMs = await readActivityMs(path.join(dir, SKC_SESSION_ACTIVITY_FILE));
|
|
@@ -177,7 +206,7 @@ async function collectActiveSessionCandidates(cwd: string): Promise<SessionCandi
|
|
|
177
206
|
if (activityMs === undefined) continue;
|
|
178
207
|
candidates.push({ skcSessionId, sessionRoot: dir, activityMs });
|
|
179
208
|
}
|
|
180
|
-
return candidates;
|
|
209
|
+
return { candidates, sawUnsafe };
|
|
181
210
|
}
|
|
182
211
|
|
|
183
212
|
async function readActivityMs(markerPath: string): Promise<number | undefined> {
|
|
@@ -191,7 +220,10 @@ async function readActivityMs(markerPath: string): Promise<number | undefined> {
|
|
|
191
220
|
const parsed = JSON.parse(raw) as { updated_at?: unknown };
|
|
192
221
|
if (typeof parsed.updated_at === "string") {
|
|
193
222
|
const ms = Date.parse(parsed.updated_at);
|
|
194
|
-
if (!Number.isNaN(ms))
|
|
223
|
+
if (!Number.isNaN(ms)) {
|
|
224
|
+
if (ms > Date.now() + ACTIVITY_FUTURE_SKEW_MS) return undefined;
|
|
225
|
+
return ms;
|
|
226
|
+
}
|
|
195
227
|
}
|
|
196
228
|
} catch {
|
|
197
229
|
// fall through to mtime
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { canonicalEnvKey, type ProjectEnvSnapshot, projectEnvSnapshot } from "@sayknow-cli/utils/env-file";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Operator environment only. A value that matches the project dotenv snapshot
|
|
5
|
+
* was loaded by Bun from the repository and must not become signing material.
|
|
6
|
+
*/
|
|
7
|
+
export function trustedCoordinatorEnv(
|
|
8
|
+
name: string,
|
|
9
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
10
|
+
snapshot: ProjectEnvSnapshot = projectEnvSnapshot(),
|
|
11
|
+
): string | undefined {
|
|
12
|
+
const raw = env[name];
|
|
13
|
+
if (!raw) return undefined;
|
|
14
|
+
const key = canonicalEnvKey(name);
|
|
15
|
+
const declared = snapshot.values[key];
|
|
16
|
+
if (declared !== undefined && (snapshot.dynamic.has(key) || declared === raw)) return undefined;
|
|
17
|
+
const trimmed = raw.trim();
|
|
18
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
19
|
+
}
|