@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
package/src/commands/sdk.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { type ChildProcess, spawn } from "node:child_process";
|
|
1
2
|
import { createHash } from "node:crypto";
|
|
2
3
|
import * as fs from "node:fs/promises";
|
|
3
4
|
import * as os from "node:os";
|
|
4
5
|
import * as path from "node:path";
|
|
5
6
|
import { Args, CliParseError, Command, Flags, renderCommandHelp } from "@sayknow-cli/utils/cli";
|
|
7
|
+
import { startupProjectEnvSnapshot } from "@sayknow-cli/utils/env";
|
|
8
|
+
import { type ProjectEnvSnapshot, projectEnvSnapshot } from "@sayknow-cli/utils/env-file";
|
|
6
9
|
import type { Args as ParsedArgs } from "../cli/args";
|
|
7
10
|
import { Settings } from "../config/settings";
|
|
8
11
|
import { applyStartupModelProfiles, createSessionManager } from "../main";
|
|
@@ -20,6 +23,7 @@ import {
|
|
|
20
23
|
} from "../sdk/broker/lifecycle";
|
|
21
24
|
import { exitIfSourceGone, startSessionHostGuard } from "../sdk/broker/process-guard";
|
|
22
25
|
import { processIncarnation } from "../sdk/broker/process-incarnation";
|
|
26
|
+
import { resolveSdkInternalSpawnCommand } from "../sdk/broker/runtime";
|
|
23
27
|
import { type CreateLifecycleAgentSessionResult, createLifecycleAgentSession } from "../sdk/lifecycle-session";
|
|
24
28
|
import { listManagedSessionCandidates, resolveManagedSessionScope } from "../sdk/session-directory";
|
|
25
29
|
import {
|
|
@@ -34,6 +38,7 @@ import {
|
|
|
34
38
|
type ResumeSessionIdentity,
|
|
35
39
|
SessionManager,
|
|
36
40
|
} from "../session/session-manager";
|
|
41
|
+
import { trustedCoordinatorEnv } from "../skc-runtime/sidecar-bootstrap-env";
|
|
37
42
|
|
|
38
43
|
export async function lifecycleArgs(
|
|
39
44
|
request: SessionLifecycleLaunchRequest,
|
|
@@ -198,6 +203,38 @@ export async function openLifecycleSessionManager(
|
|
|
198
203
|
return { parsed, sessionManager };
|
|
199
204
|
}
|
|
200
205
|
|
|
206
|
+
const SDK_CWD_EQUALITY_TEST_SEAMS = [
|
|
207
|
+
"SKC_SDK_TEST_HANG_MODEL_PROFILE",
|
|
208
|
+
"SKC_SDK_TEST_FAIL_AFTER_REGISTRATION",
|
|
209
|
+
] as const;
|
|
210
|
+
|
|
211
|
+
type SdkCwdEqualityTestSeam = (typeof SDK_CWD_EQUALITY_TEST_SEAMS)[number];
|
|
212
|
+
|
|
213
|
+
function isSdkCwdEqualityTestSeam(name: string): name is SdkCwdEqualityTestSeam {
|
|
214
|
+
return (SDK_CWD_EQUALITY_TEST_SEAMS as readonly string[]).includes(name);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function sdkCwdEqualitySnapshots(cwd: string): ProjectEnvSnapshot[] {
|
|
218
|
+
// The startup snapshot keeps a declaration Bun loaded before a later chdir.
|
|
219
|
+
return [projectEnvSnapshot(cwd), startupProjectEnvSnapshot()];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Cwd-equality test seams accept only an operator value. A project dotenv line,
|
|
224
|
+
* including one Bun expands from `$PWD`, never arms the seam.
|
|
225
|
+
*/
|
|
226
|
+
export function sdkCwdEqualityTestSeamActive(
|
|
227
|
+
name: string,
|
|
228
|
+
cwd: string,
|
|
229
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
230
|
+
snapshots: readonly ProjectEnvSnapshot[] = sdkCwdEqualitySnapshots(cwd),
|
|
231
|
+
): boolean {
|
|
232
|
+
if (!isSdkCwdEqualityTestSeam(name) || env[name] !== cwd) return false;
|
|
233
|
+
// Provenance only. trustedCoordinatorEnv trims, so a second compare to cwd
|
|
234
|
+
// would drop a trusted path that still matches exactly, including trailing space.
|
|
235
|
+
return snapshots.every(snapshot => trustedCoordinatorEnv(name, env, snapshot) !== undefined);
|
|
236
|
+
}
|
|
237
|
+
|
|
201
238
|
/** Runs the same persisted AgentSession bootstrap used by the production CLI. */
|
|
202
239
|
export async function runSessionHost(
|
|
203
240
|
timing: {
|
|
@@ -214,6 +251,9 @@ export async function runSessionHost(
|
|
|
214
251
|
const agentDir = process.env.SKC_AGENT_DIR;
|
|
215
252
|
if (!agentDir) throw new Error("SKC_AGENT_DIR is required for sdk session-host-internal.");
|
|
216
253
|
const cwd = timing.cwd ?? process.cwd();
|
|
254
|
+
const cwdSeamSnapshots = sdkCwdEqualitySnapshots(cwd);
|
|
255
|
+
const cwdEqualitySeam = (name: SdkCwdEqualityTestSeam): boolean =>
|
|
256
|
+
sdkCwdEqualityTestSeamActive(name, cwd, process.env, cwdSeamSnapshots);
|
|
217
257
|
if ((await fs.realpath(request.cwd)) !== (await fs.realpath(cwd)))
|
|
218
258
|
throw new Error(`Lifecycle worktree mismatch: expected ${request.cwd}, got ${cwd}.`);
|
|
219
259
|
if (
|
|
@@ -284,8 +324,7 @@ export async function runSessionHost(
|
|
|
284
324
|
},
|
|
285
325
|
absent.result,
|
|
286
326
|
);
|
|
287
|
-
|
|
288
|
-
throw new Error("SDK startup did not complete before readiness cutoff.");
|
|
327
|
+
return;
|
|
289
328
|
}
|
|
290
329
|
|
|
291
330
|
// Inlined rather than extracted to a helper: TypeScript's definite-assignment
|
|
@@ -461,15 +500,14 @@ export async function runSessionHost(
|
|
|
461
500
|
};
|
|
462
501
|
|
|
463
502
|
try {
|
|
464
|
-
const modelProfileStartup =
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
});
|
|
503
|
+
const modelProfileStartup = cwdEqualitySeam("SKC_SDK_TEST_HANG_MODEL_PROFILE")
|
|
504
|
+
? new Promise<void>(() => {})
|
|
505
|
+
: applyStartupModelProfiles({
|
|
506
|
+
session,
|
|
507
|
+
settings: session.settings,
|
|
508
|
+
modelRegistry: session.modelRegistry,
|
|
509
|
+
parsedArgs: parsed,
|
|
510
|
+
});
|
|
473
511
|
await beforeCutoff(modelProfileStartup);
|
|
474
512
|
throwIfCutoff();
|
|
475
513
|
await beforeCutoff(
|
|
@@ -487,7 +525,7 @@ export async function runSessionHost(
|
|
|
487
525
|
const startup = await beforeCutoff(capability.promise);
|
|
488
526
|
if (startup.status !== "started") throw startup.failure;
|
|
489
527
|
throwIfCutoff();
|
|
490
|
-
if (
|
|
528
|
+
if (cwdEqualitySeam("SKC_SDK_TEST_FAIL_AFTER_REGISTRATION"))
|
|
491
529
|
throw new Error("Lifecycle test failure after SDK host registration.");
|
|
492
530
|
|
|
493
531
|
await session.sessionManager.ensureOnDisk();
|
|
@@ -510,16 +548,75 @@ export async function runSessionHost(
|
|
|
510
548
|
await new Promise<void>(() => {});
|
|
511
549
|
}
|
|
512
550
|
|
|
513
|
-
export type SdkInternalArgv =
|
|
551
|
+
export type SdkInternalArgv =
|
|
552
|
+
| { action: "broker-internal"; agentDir: string }
|
|
553
|
+
| { action: "broker-trampoline-internal"; agentDir: string }
|
|
554
|
+
| { action: "session-host-internal" };
|
|
514
555
|
|
|
515
556
|
/** Parses the exact private argv contracts used by SDK child-process spawns. */
|
|
516
557
|
export function parseSdkInternalArgv(argv: readonly string[]): SdkInternalArgv {
|
|
517
558
|
if (argv[0] === "session-host-internal" && argv.length === 1) return { action: "session-host-internal" };
|
|
518
559
|
if (argv[0] === "broker-internal" && argv.length === 3 && argv[1] === "--agent-dir" && argv[2])
|
|
519
560
|
return { action: "broker-internal", agentDir: argv[2] };
|
|
561
|
+
if (argv[0] === "broker-trampoline-internal" && argv.length === 3 && argv[1] === "--agent-dir" && argv[2])
|
|
562
|
+
return { action: "broker-trampoline-internal", agentDir: argv[2] };
|
|
520
563
|
throw new CliParseError("Invalid internal SDK invocation.");
|
|
521
564
|
}
|
|
522
565
|
|
|
566
|
+
/**
|
|
567
|
+
* Detached trampoline for the shared broker (POSIX only): it starts the real
|
|
568
|
+
* broker, reports its exact `pid\tincarnation` on stdout, and exits so the
|
|
569
|
+
* broker reparents out of the spawner's process tree before that tree can be
|
|
570
|
+
* reaped. The spawner binds startup evidence to the reported identity, never to
|
|
571
|
+
* the trampoline.
|
|
572
|
+
*/
|
|
573
|
+
async function runBrokerTrampoline(agentDir: string): Promise<void> {
|
|
574
|
+
if (process.platform === "win32") throw new CliParseError("Broker trampoline is unavailable on Windows.");
|
|
575
|
+
const command = resolveSdkInternalSpawnCommand("broker-internal");
|
|
576
|
+
let child: ChildProcess;
|
|
577
|
+
try {
|
|
578
|
+
child = spawn(command.file, [...command.args, "--agent-dir", agentDir], {
|
|
579
|
+
detached: true,
|
|
580
|
+
stdio: ["ignore", "ignore", "inherit"],
|
|
581
|
+
env: command.env,
|
|
582
|
+
...(command.kind === "bun-source" ? { cwd: command.cwd } : {}),
|
|
583
|
+
});
|
|
584
|
+
} catch (error) {
|
|
585
|
+
throw new Error("Broker trampoline could not start broker.", { cause: error });
|
|
586
|
+
}
|
|
587
|
+
let spawnError: Error | undefined;
|
|
588
|
+
child.once("error", error => {
|
|
589
|
+
spawnError = error;
|
|
590
|
+
});
|
|
591
|
+
if (child.pid === undefined) throw new Error("Broker trampoline could not start broker.");
|
|
592
|
+
const incarnation = processIncarnation(child.pid);
|
|
593
|
+
if (!incarnation) {
|
|
594
|
+
try {
|
|
595
|
+
child.kill("SIGKILL");
|
|
596
|
+
} catch {
|
|
597
|
+
// The child may already have exited; either way identity was not established.
|
|
598
|
+
}
|
|
599
|
+
throw new Error("Broker trampoline could not observe broker identity.");
|
|
600
|
+
}
|
|
601
|
+
if (spawnError) throw new Error("Broker trampoline could not start broker.", { cause: spawnError });
|
|
602
|
+
const stdoutWrite = Promise.withResolvers<void>();
|
|
603
|
+
process.stdout.write(`${child.pid}\t${incarnation}\n`, error => {
|
|
604
|
+
if (error) stdoutWrite.reject(error);
|
|
605
|
+
else stdoutWrite.resolve();
|
|
606
|
+
});
|
|
607
|
+
try {
|
|
608
|
+
await stdoutWrite.promise;
|
|
609
|
+
} catch (error) {
|
|
610
|
+
try {
|
|
611
|
+
child.kill("SIGKILL");
|
|
612
|
+
} catch {
|
|
613
|
+
// The child may already have exited; reporting failure remains authoritative.
|
|
614
|
+
}
|
|
615
|
+
throw error;
|
|
616
|
+
}
|
|
617
|
+
child.unref();
|
|
618
|
+
}
|
|
619
|
+
|
|
523
620
|
class SdkServeHelp extends Command {
|
|
524
621
|
static description = "skc sdk serve --stdio | --socket <path> [--session <id>] [--pending-ceiling <bytes>]";
|
|
525
622
|
static flags = {
|
|
@@ -547,9 +644,13 @@ export default class Sdk extends Command {
|
|
|
547
644
|
await runSdkServe(this.argv.slice(1));
|
|
548
645
|
return;
|
|
549
646
|
}
|
|
550
|
-
if (action !== "broker-internal" && action !== "session-host-internal")
|
|
647
|
+
if (action !== "broker-internal" && action !== "broker-trampoline-internal" && action !== "session-host-internal")
|
|
551
648
|
throw new CliParseError("Expected action to be serve.");
|
|
552
649
|
const internal = parseSdkInternalArgv(this.argv);
|
|
650
|
+
if (internal.action === "broker-trampoline-internal") {
|
|
651
|
+
await runBrokerTrampoline(internal.agentDir);
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
553
654
|
if (internal.action === "session-host-internal") {
|
|
554
655
|
await runSessionHost();
|
|
555
656
|
return;
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
writeCurrentSessionGoalModeState,
|
|
8
8
|
writePendingGoalModeRequest,
|
|
9
9
|
} from "../skc-runtime/goal-mode-request";
|
|
10
|
+
import { trustedCoordinatorEnv } from "../skc-runtime/sidecar-bootstrap-env";
|
|
10
11
|
import { runNativeUltragoalCommand } from "../skc-runtime/ultragoal-runtime";
|
|
11
12
|
|
|
12
13
|
export default class Ultragoal extends Command {
|
|
@@ -29,16 +30,21 @@ export default class Ultragoal extends Command {
|
|
|
29
30
|
const { objective, goalsPath, provenance } = await readUltragoalSkcObjective(cwd);
|
|
30
31
|
|
|
31
32
|
await writeCurrentSessionGoalModeState({
|
|
32
|
-
sessionFile:
|
|
33
|
+
sessionFile: trustedCoordinatorEnv(SKC_SESSION_FILE_ENV),
|
|
33
34
|
objective,
|
|
34
35
|
provenance,
|
|
35
36
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
// A matching or dynamic project declaration must not select the session.
|
|
38
|
+
// Skip the write in that case: the helper falls back to the same env value.
|
|
39
|
+
const sessionId = trustedCoordinatorEnv(SKC_SESSION_ID_ENV);
|
|
40
|
+
if (sessionId !== undefined || !process.env[SKC_SESSION_ID_ENV]?.trim()) {
|
|
41
|
+
await writePendingGoalModeRequest({
|
|
42
|
+
cwd,
|
|
43
|
+
objective,
|
|
44
|
+
goalsPath,
|
|
45
|
+
provenance,
|
|
46
|
+
sessionId,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
43
49
|
}
|
|
44
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { INTENT_FIELD, type ThinkingLevel } from "@sayknow-cli/agent-core";
|
|
2
2
|
import type { Api, Model } from "@sayknow-cli/ai";
|
|
3
3
|
import { Markdown } from "@sayknow-cli/tui";
|
|
4
|
-
import { prompt } from "@sayknow-cli/utils";
|
|
4
|
+
import { prompt, sanitizeText } from "@sayknow-cli/utils";
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
import typesDescriptionPrompt from "../../commit/prompts/types-description.md" with { type: "text" };
|
|
7
7
|
import type { ModelRegistry } from "../../config/model-registry";
|
|
@@ -81,7 +81,7 @@ export async function runCommitAgentSession(input: CommitAgentInput): Promise<Co
|
|
|
81
81
|
const toolArgsById = new Map<string, { name: string; args?: Record<string, unknown> }>();
|
|
82
82
|
const writeThinkingLine = (text: string) => {
|
|
83
83
|
if (!process.stdout.isTTY) return;
|
|
84
|
-
const line = chalk.dim(`… ${text}`);
|
|
84
|
+
const line = chalk.dim(`… ${sanitizeText(text)}`);
|
|
85
85
|
process.stdout.write(`\r\x1b[2K${line}`);
|
|
86
86
|
thinkingLineActive = true;
|
|
87
87
|
};
|
|
@@ -118,7 +118,7 @@ export async function runCommitAgentSession(input: CommitAgentInput): Promise<Co
|
|
|
118
118
|
clearThinkingLine();
|
|
119
119
|
const assistantMessage = event.message as { stopReason?: string; errorMessage?: string };
|
|
120
120
|
if (assistantMessage.stopReason === "error" && assistantMessage.errorMessage) {
|
|
121
|
-
process.stdout.write(`● Error: ${assistantMessage.errorMessage}\n`);
|
|
121
|
+
process.stdout.write(`● Error: ${sanitizeText(assistantMessage.errorMessage)}\n`);
|
|
122
122
|
}
|
|
123
123
|
const messageText = extractMessageText(event.message?.content ?? []);
|
|
124
124
|
if (messageText) {
|
|
@@ -131,10 +131,10 @@ export async function runCommitAgentSession(input: CommitAgentInput): Promise<Co
|
|
|
131
131
|
const stored = toolArgsById.get(event.toolCallId) ?? { name: event.toolName };
|
|
132
132
|
toolArgsById.delete(event.toolCallId);
|
|
133
133
|
clearThinkingLine();
|
|
134
|
-
const toolLabel = formatToolLabel(stored.name);
|
|
134
|
+
const toolLabel = sanitizeText(formatToolLabel(stored.name));
|
|
135
135
|
const symbol = event.isError ? "" : "";
|
|
136
136
|
process.stdout.write(`${symbol} ${toolLabel}\n`);
|
|
137
|
-
const argsLines = formatToolArgs(stored.args);
|
|
137
|
+
const argsLines = formatToolArgs(stored.args).map(line => sanitizeText(line));
|
|
138
138
|
if (argsLines.length > 0) {
|
|
139
139
|
process.stdout.write(`${formatToolArgsBlock(argsLines)}\n`);
|
|
140
140
|
}
|
|
@@ -201,7 +201,7 @@ function extractMessageText(content: Array<{ type: string; text?: string }>): st
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
function writeAssistantMessage(message: string): void {
|
|
204
|
-
const lines = renderMarkdownLines(message);
|
|
204
|
+
const lines = renderMarkdownLines(sanitizeText(message));
|
|
205
205
|
if (lines.length === 0) return;
|
|
206
206
|
let firstContentIndex = lines.findIndex(line => line.trim().length > 0);
|
|
207
207
|
if (firstContentIndex === -1) {
|
|
@@ -5,6 +5,7 @@ import { prompt } from "@sayknow-cli/utils";
|
|
|
5
5
|
import analysisSystemPrompt from "../../commit/prompts/analysis-system.md" with { type: "text" };
|
|
6
6
|
import analysisUserPrompt from "../../commit/prompts/analysis-user.md" with { type: "text" };
|
|
7
7
|
import type { ConventionalAnalysis } from "../../commit/types";
|
|
8
|
+
import { escapePromptMetadata } from "../../session/messages";
|
|
8
9
|
import { toReasoningEffort } from "../../thinking";
|
|
9
10
|
import { createConventionalAnalysisTool, parseConventionalAnalysisResponse } from "../shared-llm";
|
|
10
11
|
|
|
@@ -41,13 +42,21 @@ export async function generateConventionalAnalysis({
|
|
|
41
42
|
diff,
|
|
42
43
|
}: ConventionalAnalysisInput): Promise<ConventionalAnalysis> {
|
|
43
44
|
const userContent = prompt.render(analysisUserPrompt, {
|
|
44
|
-
context_files:
|
|
45
|
+
context_files:
|
|
46
|
+
contextFiles && contextFiles.length > 0
|
|
47
|
+
? contextFiles.map(file => ({
|
|
48
|
+
path: escapePromptMetadata(file.path),
|
|
49
|
+
content: escapePromptMetadata(file.content, { preserveNewlines: true }),
|
|
50
|
+
}))
|
|
51
|
+
: undefined,
|
|
45
52
|
user_context: userContext,
|
|
46
53
|
types_description: typesDescription,
|
|
47
|
-
recent_commits: recentCommits
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
recent_commits: recentCommits
|
|
55
|
+
?.map(subject => escapePromptMetadata(subject, { preserveNewlines: true }))
|
|
56
|
+
.join("\n"),
|
|
57
|
+
scope_candidates: escapePromptMetadata(scopeCandidates, { preserveNewlines: true }),
|
|
58
|
+
stat: escapePromptMetadata(stat, { preserveNewlines: true }),
|
|
59
|
+
diff: escapePromptMetadata(diff, { preserveNewlines: true }),
|
|
51
60
|
});
|
|
52
61
|
|
|
53
62
|
const response = await completeSimple(
|
|
@@ -168,11 +168,49 @@ function applyChangelogEntries(
|
|
|
168
168
|
if (deletions) {
|
|
169
169
|
base = applyDeletions(base, deletions);
|
|
170
170
|
}
|
|
171
|
-
const merged = mergeEntries(base, entries);
|
|
171
|
+
const merged = mergeEntries(base, redactPersistedEntries(entries));
|
|
172
172
|
const sectionLines = renderUnreleasedSections(merged);
|
|
173
173
|
return [...before, ...sectionLines, ...after].join("\n");
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
function redactPersistedEntries(entries: Record<string, string[]>): Record<string, string[]> {
|
|
177
|
+
const redacted: Record<string, string[]> = {};
|
|
178
|
+
for (const [section, items] of Object.entries(entries)) {
|
|
179
|
+
redacted[section] = items.map(item => redactChangelogEntry(item));
|
|
180
|
+
}
|
|
181
|
+
return redacted;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const AWS_LABELED_KEY =
|
|
185
|
+
"(?:(?:aws[_-]?)?secret[_-]?access[_-]?key|(?:aws[_-]?)?session[_-]?token|x[_-]?amz[_-]?security[_-]?token)";
|
|
186
|
+
|
|
187
|
+
export function redactChangelogEntry(text: string): string {
|
|
188
|
+
let redacted = text.replace(/(^|[^0-9A-Za-z])(?:AKIA|ASIA)[0-9A-Z]{16}(?![0-9A-Za-z])/g, "$1[REDACTED_AWS_KEY_ID]");
|
|
189
|
+
redacted = redacted.replace(
|
|
190
|
+
new RegExp(
|
|
191
|
+
`(^|[^A-Za-z0-9_-])(["']?${AWS_LABELED_KEY}["']?\\s*[=:]\\s*)(\\$?)(["'\`])([^"'\`\\r\\n]{8,})\\4`,
|
|
192
|
+
"gi",
|
|
193
|
+
),
|
|
194
|
+
"$1$2$3$4[REDACTED_SECRET]$4",
|
|
195
|
+
);
|
|
196
|
+
redacted = redacted.replace(
|
|
197
|
+
new RegExp(`(^|[^A-Za-z0-9_-])(["']?${AWS_LABELED_KEY}["']?\\s*[=:]\\s*)[^\\s"'\`,;{}[\\]()&<>#]{8,}`, "gi"),
|
|
198
|
+
"$1$2[REDACTED_SECRET]",
|
|
199
|
+
);
|
|
200
|
+
redacted = redacted.replace(/\b(?:sk|pk|rk|xox[baprs])-[-_A-Za-z0-9]{12,}\b/g, "[REDACTED_TOKEN]");
|
|
201
|
+
redacted = redacted.replace(/(?<![A-Za-z0-9_-])AIza[0-9A-Za-z_-]{35}(?![A-Za-z0-9_-])/g, "[REDACTED_TOKEN]");
|
|
202
|
+
redacted = redacted.replace(/\b(?:gh[opsur]_[A-Za-z0-9_]{12,}|github_pat_[A-Za-z0-9_]{12,})\b/g, "[REDACTED_TOKEN]");
|
|
203
|
+
redacted = redacted.replace(
|
|
204
|
+
/\b((?:ANTHROPIC|OPENAI|GITHUB|GOOGLE|GEMINI|KAGI|TAVILY|EXA|PERPLEXITY|ZAI|KIMI|BRAVE|SEARXNG|AWS)_[A-Z0-9_]*(?:KEY|TOKEN|SECRET|COOKIE|PASSWORD))\s*=\s*[^\s\n]+/gi,
|
|
205
|
+
"$1=[REDACTED_SECRET]",
|
|
206
|
+
);
|
|
207
|
+
redacted = redacted.replace(
|
|
208
|
+
/\b(Authorization|Proxy-Authorization)\s*:\s*(?:Bearer|Basic|Token)\s+[^\s\n]+/gi,
|
|
209
|
+
"$1: [REDACTED_AUTH_HEADER]",
|
|
210
|
+
);
|
|
211
|
+
return redacted.replace(/\b(Cookie|Set-Cookie)\s*:\s*[^\n]+/gi, "$1: [REDACTED_COOKIE]");
|
|
212
|
+
}
|
|
213
|
+
|
|
176
214
|
function applyDeletions(
|
|
177
215
|
existing: Record<string, string[]>,
|
|
178
216
|
deletions: Record<string, string[]>,
|
package/src/commit/message.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { redactCrashSecrets } from "@sayknow-cli/utils";
|
|
2
|
+
import { redactChangelogEntry } from "./changelog";
|
|
1
3
|
import type { ConventionalAnalysis } from "./types";
|
|
2
4
|
|
|
5
|
+
/** Same order as generated task messages, so a second pass stays stable. */
|
|
6
|
+
function redactCommitText(text: string): string {
|
|
7
|
+
return redactCrashSecrets(redactChangelogEntry(text));
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
export function formatCommitMessage(analysis: ConventionalAnalysis, summary: string): string {
|
|
4
|
-
const scopePart = analysis.scope ? `(${analysis.scope})` : "";
|
|
5
|
-
const header = `${analysis.type}${scopePart}: ${summary}`;
|
|
6
|
-
const bodyLines = analysis.details.map(detail => `- ${detail.text.trim()}`);
|
|
11
|
+
const scopePart = analysis.scope ? `(${redactCommitText(analysis.scope)})` : "";
|
|
12
|
+
const header = `${analysis.type}${scopePart}: ${redactCommitText(summary)}`;
|
|
13
|
+
const bodyLines = analysis.details.map(detail => `- ${redactCommitText(detail.text.trim())}`);
|
|
7
14
|
if (bodyLines.length === 0) {
|
|
8
15
|
return header;
|
|
9
16
|
}
|
|
@@ -1,18 +1,121 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
1
2
|
import * as fs from "node:fs";
|
|
2
3
|
import * as path from "node:path";
|
|
3
|
-
import {
|
|
4
|
+
import { renameNoReplacePath } from "@sayknow-cli/natives";
|
|
5
|
+
import { getAgentDir, isEnoent, isFsError, logger } from "@sayknow-cli/utils";
|
|
4
6
|
import { JSONC, YAML } from "bun";
|
|
5
7
|
import type { ZodType } from "zod/v4";
|
|
6
8
|
|
|
9
|
+
// Volumes without hard links fail `link`. Windows maps FAT ERROR_INVALID_FUNCTION to EISDIR.
|
|
10
|
+
const HARD_LINK_UNAVAILABLE = new Set(["EACCES", "EISDIR", "ENOSYS", "ENOTSUP", "EOPNOTSUPP", "EPERM", "EXDEV"]);
|
|
11
|
+
|
|
7
12
|
/** Minimal subset of the AJV ConfigSchemaError shape this module actually relies on. */
|
|
8
13
|
interface ConfigSchemaError {
|
|
9
14
|
instancePath: string;
|
|
10
15
|
message: string | undefined;
|
|
11
16
|
}
|
|
12
17
|
|
|
18
|
+
/** True when the final path component exists, including a dangling symlink. */
|
|
19
|
+
function ymlPathPresent(ymlPath: string): boolean {
|
|
20
|
+
try {
|
|
21
|
+
fs.lstatSync(ymlPath);
|
|
22
|
+
return true;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (isEnoent(error)) return false;
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function hardLinkUnavailable(error: unknown): boolean {
|
|
30
|
+
return isFsError(error) && HARD_LINK_UNAVAILABLE.has(error.code);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function stagedRegularFile(tmpPath: string): boolean {
|
|
34
|
+
try {
|
|
35
|
+
return fs.lstatSync(tmpPath).isFile();
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function discardStaged(tmpPath: string): void {
|
|
42
|
+
try {
|
|
43
|
+
fs.unlinkSync(tmpPath);
|
|
44
|
+
} catch {
|
|
45
|
+
// Unpublished, or the no-replace rename already moved this name.
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Publish the completed private file when `link` is not supported. Never replaces `ymlPath`. */
|
|
50
|
+
function publishStagedWithoutHardLink(tmpPath: string, ymlPath: string): void {
|
|
51
|
+
const published = renameNoReplacePath(tmpPath, ymlPath);
|
|
52
|
+
if (!published.ok && published.reason !== "destination_exists") {
|
|
53
|
+
discardStaged(tmpPath);
|
|
54
|
+
throw new Error(`config migration could not publish without a hard link (${published.reason})`);
|
|
55
|
+
}
|
|
56
|
+
discardStaged(tmpPath);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Publish a new regular file as mode 0600. The bytes go to a private inode
|
|
61
|
+
* opened with O_EXCL and O_NOFOLLOW. `link` then attaches that inode to
|
|
62
|
+
* `ymlPath` and fails when the name exists, so a final-component symlink is
|
|
63
|
+
* not followed and an existing file is not replaced. A volume without hard
|
|
64
|
+
* links publishes that same completed file with a no-replace rename. The
|
|
65
|
+
* destination name stays absent until the bytes are complete.
|
|
66
|
+
*/
|
|
67
|
+
function writeNewOwnerOnlyNoFollow(ymlPath: string, content: string): void {
|
|
68
|
+
// Ancestor symlinks only. The final component stays unresolved so no-follow still applies.
|
|
69
|
+
ymlPath = path.join(fs.realpathSync(path.dirname(ymlPath)), path.basename(ymlPath));
|
|
70
|
+
const noFollow = process.platform === "win32" ? 0 : (fs.constants.O_NOFOLLOW ?? 0);
|
|
71
|
+
const tmpPath = path.join(
|
|
72
|
+
path.dirname(ymlPath),
|
|
73
|
+
`.${path.basename(ymlPath)}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`,
|
|
74
|
+
);
|
|
75
|
+
let fd: number | undefined;
|
|
76
|
+
try {
|
|
77
|
+
fd = fs.openSync(tmpPath, fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_EXCL | noFollow, 0o600);
|
|
78
|
+
if (process.platform !== "win32") fs.fchmodSync(fd, 0o600);
|
|
79
|
+
fs.writeFileSync(fd, content);
|
|
80
|
+
fs.fsyncSync(fd);
|
|
81
|
+
fs.closeSync(fd);
|
|
82
|
+
fd = undefined;
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (fd !== undefined) {
|
|
85
|
+
try {
|
|
86
|
+
fs.closeSync(fd);
|
|
87
|
+
} catch {
|
|
88
|
+
// The original failure is the one that must surface.
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
fs.unlinkSync(tmpPath);
|
|
92
|
+
} catch {
|
|
93
|
+
// The destination name was not published.
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
fs.linkSync(tmpPath, ymlPath);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
// The name is already present: a finished peer publish, or a file or symlink we must not replace.
|
|
102
|
+
if (isFsError(error) && (error.code === "EEXIST" || error.code === "ELOOP")) {
|
|
103
|
+
discardStaged(tmpPath);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (hardLinkUnavailable(error) && stagedRegularFile(tmpPath)) {
|
|
107
|
+
publishStagedWithoutHardLink(tmpPath, ymlPath);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
discardStaged(tmpPath);
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
discardStaged(tmpPath);
|
|
114
|
+
}
|
|
115
|
+
|
|
13
116
|
function migrateJsonToYml(jsonPath: string, ymlPath: string) {
|
|
14
117
|
try {
|
|
15
|
-
if (
|
|
118
|
+
if (ymlPathPresent(ymlPath)) return;
|
|
16
119
|
if (!fs.existsSync(jsonPath)) return;
|
|
17
120
|
|
|
18
121
|
const content = fs.readFileSync(jsonPath, "utf-8");
|
|
@@ -21,7 +124,7 @@ function migrateJsonToYml(jsonPath: string, ymlPath: string) {
|
|
|
21
124
|
logger.warn("migrateJsonToYml: invalid json structure", { path: jsonPath });
|
|
22
125
|
return;
|
|
23
126
|
}
|
|
24
|
-
|
|
127
|
+
writeNewOwnerOnlyNoFollow(ymlPath, YAML.stringify(parsed, null, 2));
|
|
25
128
|
} catch (error) {
|
|
26
129
|
logger.warn("migrateJsonToYml: migration failed", { error: String(error) });
|
|
27
130
|
}
|