@draht/coding-agent 2026.10.20 → 2026.10.23-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +138 -0
- package/agents/advisor.md +2 -2
- package/agents/architect.md +11 -33
- package/agents/debugger.md +13 -54
- package/agents/git-committer.md +18 -42
- package/agents/implementer.md +14 -36
- package/agents/investigator.md +12 -63
- package/agents/reviewer.md +16 -44
- package/agents/security-auditor.md +22 -56
- package/agents/spec-reviewer.md +13 -53
- package/agents/verifier.md +14 -33
- package/bin/drahtbank.mjs +4 -0
- package/dist/agents/advisor.md +2 -2
- package/dist/agents/architect.md +11 -33
- package/dist/agents/debugger.md +13 -54
- package/dist/agents/git-committer.md +18 -42
- package/dist/agents/implementer.md +14 -36
- package/dist/agents/investigator.md +12 -63
- package/dist/agents/reviewer.md +16 -44
- package/dist/agents/security-auditor.md +22 -56
- package/dist/agents/spec-reviewer.md +13 -53
- package/dist/agents/verifier.md +14 -33
- package/dist/bundle/chunks/anthropic-messages-G57VPNTF.js +6 -0
- package/dist/bundle/chunks/anthropic.js +1 -1
- package/dist/bundle/chunks/azure-openai-responses-AYUCZ5WN.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +31 -28
- package/dist/bundle/chunks/chunk-2JZLKNZ4.js +3 -0
- package/dist/bundle/chunks/chunk-3GDEPGTR.js +16 -0
- package/dist/bundle/chunks/chunk-5JW3NSTV.js +2 -0
- package/dist/bundle/chunks/{chunk-KVH4HR57.js → chunk-6WESOD4H.js} +1 -1
- package/dist/bundle/chunks/chunk-76YNMQ57.js +2 -0
- package/dist/bundle/chunks/chunk-AC3MSTC6.js +2 -0
- package/dist/bundle/chunks/chunk-ACLWH5WQ.js +2 -0
- package/dist/bundle/chunks/chunk-BL72B6LV.js +82 -0
- package/dist/bundle/chunks/chunk-CLKG6K6Z.js +7 -0
- package/dist/bundle/chunks/chunk-DN7SM3LX.js +479 -0
- package/dist/bundle/chunks/{chunk-D6TMD5Q2.js → chunk-DOUMZTXH.js} +10 -10
- package/dist/bundle/chunks/chunk-DQ4G4IS4.js +20 -0
- package/dist/bundle/chunks/chunk-E4VZJRJ2.js +9 -0
- package/dist/bundle/chunks/chunk-FOYIPAAD.js +6 -0
- package/dist/bundle/chunks/chunk-FXCTQRNN.js +2 -0
- package/dist/bundle/chunks/chunk-GBFVS2SF.js +12 -0
- package/dist/bundle/chunks/chunk-GQXRTK54.js +20 -0
- package/dist/bundle/chunks/chunk-IGO52ZOY.js +132 -0
- package/dist/bundle/chunks/chunk-IT4RIOZD.js +2 -0
- package/dist/bundle/chunks/chunk-JJKPUMH2.js +1424 -0
- package/dist/bundle/chunks/chunk-JNWRE5F4.js +2 -0
- package/dist/bundle/chunks/chunk-KSGHCBHT.js +2 -0
- package/dist/bundle/chunks/chunk-LO6CVU2L.js +6 -0
- package/dist/bundle/chunks/chunk-MBFTIGLS.js +2 -0
- package/dist/bundle/chunks/chunk-N26RGV3K.js +11 -0
- package/dist/bundle/chunks/{chunk-KPO5375S.js → chunk-RCRGGYLW.js} +1 -1
- package/dist/bundle/chunks/chunk-UCJ7FLSO.js +166 -0
- package/dist/bundle/chunks/chunk-USCN7R2E.js +2 -0
- package/dist/bundle/chunks/chunk-WFHH5SX6.js +4 -0
- package/dist/bundle/chunks/chunk-WYWBXNDO.js +6 -0
- package/dist/bundle/chunks/chunk-ZRPAOMVB.js +2 -0
- package/dist/bundle/chunks/{cli-PYJB6AQ3.js → cli-HTUB6WOG.js} +6 -6
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-RRSO6OXX.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +188 -21
- package/dist/bundle/chunks/execute-UUPNZJJG.js +31 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-VJSS5EBX.js +2 -0
- package/dist/bundle/chunks/google-vertex-K23DBWTT.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-WQIRL24U.js +13 -0
- package/dist/bundle/chunks/image-resize-worker.js +1 -1
- package/dist/bundle/chunks/lib-ULKZYRGD.js +9 -0
- package/dist/bundle/chunks/{llama-cpp-classify-EJ5XMSQL.js → llama-cpp-classify-3VDXTYVJ.js} +3 -3
- package/dist/bundle/chunks/mistral-conversations-SKVQJGFZ.js +5 -0
- package/dist/bundle/chunks/{multipart-parser-AZP5BX2W.js → multipart-parser-HMCXZ4BD.js} +1 -1
- package/dist/bundle/chunks/node-DXZFQBEO.js +16 -0
- package/dist/bundle/chunks/{node-C2JGH2OB.js → node-LBZLUIBE.js} +1 -1
- package/dist/bundle/chunks/openai-chatgpt.js +1 -1
- package/dist/bundle/chunks/openai-codex-responses-LV4RIZL3.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +1 -1
- package/dist/bundle/chunks/openai-completions-PUIR2V25.js +7 -0
- package/dist/bundle/chunks/openai-decisions-2DJLSYQF.js +5 -0
- package/dist/bundle/chunks/openai-responses-6ESQOXAF.js +4 -0
- package/dist/bundle/chunks/opencode-go.js +1 -1
- package/dist/bundle/chunks/openrouter-images-TVXBMY3V.js +2 -0
- package/dist/bundle/chunks/pi-messages-XS7FDWQI.js +8 -0
- package/dist/bundle/chunks/runtime-IB3XQ7E3.js +2 -0
- package/dist/bundle/chunks/runtime-LB35PK4J.js +3 -0
- package/dist/bundle/chunks/settings-manager-YNY5F4RU.js +2 -0
- package/dist/bundle/chunks/src-KDGO7EGF.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-67GAWZXE.js +2 -0
- package/dist/bundle/chunks/virtual-modules-U4CBGVMI.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts +2 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +30 -8
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +4 -4
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/config.d.ts +18 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +44 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +65 -8
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +240 -102
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +20 -13
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +42 -52
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/bug-report.d.ts +9 -1
- package/dist/core/bug-report.d.ts.map +1 -1
- package/dist/core/builtins/completion-checks.d.ts +3 -0
- package/dist/core/builtins/completion-checks.d.ts.map +1 -0
- package/dist/core/builtins/completion-checks.js +142 -0
- package/dist/core/builtins/completion-checks.js.map +1 -0
- package/dist/core/builtins/duet.d.ts.map +1 -1
- package/dist/core/builtins/duet.js +7 -5
- package/dist/core/builtins/duet.js.map +1 -1
- package/dist/core/builtins/git-safety.d.ts +3 -0
- package/dist/core/builtins/git-safety.d.ts.map +1 -0
- package/dist/core/builtins/git-safety.js +34 -0
- package/dist/core/builtins/git-safety.js.map +1 -0
- package/dist/core/builtins/index.d.ts.map +1 -1
- package/dist/core/builtins/index.js +4 -0
- package/dist/core/builtins/index.js.map +1 -1
- package/dist/core/client-identity.d.ts +8 -0
- package/dist/core/client-identity.d.ts.map +1 -0
- package/dist/core/client-identity.js +15 -0
- package/dist/core/client-identity.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +20 -15
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +6 -0
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +7 -8
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +2 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.html +1 -0
- package/dist/core/export-html/template.js +23 -17
- package/dist/core/export-html/tool-renderer.d.ts +3 -3
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +5 -3
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +30 -29
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +7 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +6 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +16 -4
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +61 -7
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +2 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/key-id-schema.d.ts +6 -0
- package/dist/core/key-id-schema.d.ts.map +1 -0
- package/dist/core/key-id-schema.js +16 -0
- package/dist/core/key-id-schema.js.map +1 -0
- package/dist/core/keybindings-schema.d.ts +4 -0
- package/dist/core/keybindings-schema.d.ts.map +1 -0
- package/dist/core/keybindings-schema.js +16 -0
- package/dist/core/keybindings-schema.js.map +1 -0
- package/dist/core/keybindings.d.ts +242 -75
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +30 -23
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +22 -0
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +72 -11
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/model-config.d.ts +1623 -74
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +70 -184
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +3 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +4 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +56 -43
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +253 -358
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +19 -10
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +1 -0
- package/dist/core/nested-tool-calls.d.ts.map +1 -1
- package/dist/core/nested-tool-calls.js +1 -0
- package/dist/core/nested-tool-calls.js.map +1 -1
- package/dist/core/package-manager.js +3 -3
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/polyphase/keyword.js +1 -1
- package/dist/core/polyphase/keyword.js.map +1 -1
- package/dist/core/polyphase/model-selection.d.ts.map +1 -1
- package/dist/core/polyphase/model-selection.js +15 -7
- package/dist/core/polyphase/model-selection.js.map +1 -1
- package/dist/core/polyphase/workflow/prelude.d.ts +2 -0
- package/dist/core/polyphase/workflow/prelude.d.ts.map +1 -1
- package/dist/core/polyphase/workflow/prelude.js +12 -16
- package/dist/core/polyphase/workflow/prelude.js.map +1 -1
- package/dist/core/polyphase/workflow/runtime.d.ts.map +1 -1
- package/dist/core/polyphase/workflow/runtime.js +2 -1
- package/dist/core/polyphase/workflow/runtime.js.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +2 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +7 -2
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +13 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +2 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +2 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +12 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +84 -24
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +3 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +7 -4
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +13 -4
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +27 -15
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +65 -0
- package/dist/core/settings-defaults.d.ts.map +1 -0
- package/dist/core/settings-defaults.js +66 -0
- package/dist/core/settings-defaults.js.map +1 -0
- package/dist/core/settings-manager.d.ts +17 -178
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +86 -57
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +269 -0
- package/dist/core/settings-schema.d.ts.map +1 -0
- package/dist/core/settings-schema.js +318 -0
- package/dist/core/settings-schema.js.map +1 -0
- package/dist/core/skills.d.ts +4 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +6 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +10 -5
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/grep.d.ts +8 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +19 -7
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +2 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +2 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +4 -10
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts +1 -1
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js +6 -6
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/read.d.ts +13 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +32 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +20 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +67 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +7 -35
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/renderers/edit.d.ts.map +1 -1
- package/dist/core/tools/renderers/edit.js +5 -4
- package/dist/core/tools/renderers/edit.js.map +1 -1
- package/dist/core/tools/renderers/index.d.ts +2 -2
- package/dist/core/tools/renderers/index.d.ts.map +1 -1
- package/dist/core/tools/renderers/index.js.map +1 -1
- package/dist/core/tools/renderers/read.d.ts.map +1 -1
- package/dist/core/tools/renderers/read.js +7 -11
- package/dist/core/tools/renderers/read.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +391 -80
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +3 -1
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/extensions/codemode/renderer.d.ts +2 -2
- package/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/dist/extensions/codemode/renderer.js +9 -3
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +22 -21
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +96 -123
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +34 -11
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts.map +1 -1
- package/dist/extensions/mcp/cli.js +27 -33
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts +15 -3
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +49 -12
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +4 -1
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +279 -129
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/oauth.d.ts +21 -11
- package/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/dist/extensions/mcp/oauth.js +166 -45
- package/dist/extensions/mcp/oauth.js.map +1 -1
- package/dist/extensions/mcp/resources.d.ts +3 -10
- package/dist/extensions/mcp/resources.d.ts.map +1 -1
- package/dist/extensions/mcp/resources.js +4 -5
- package/dist/extensions/mcp/resources.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +7 -7
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +31 -45
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts +7 -5
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +87 -29
- package/dist/extensions/mcp/tools.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts +3 -3
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +18 -6
- package/dist/extensions/mcp/ui.js.map +1 -1
- package/dist/extensions/tool-search/tool.d.ts +0 -2
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +2 -4
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/hooks/checks/checks-runtime.cjs +215 -0
- package/dist/hooks/checks/git-safety.cjs +198 -0
- package/dist/hooks/checks/git-safety.d.cts +1 -0
- package/dist/hooks/gsd/draht-post-task.js +78 -39
- package/dist/hooks/gsd/draht-quality-gate.js +210 -122
- package/dist/hooks/gsd/package.json +3 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +11 -3
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/auth-url.d.ts +14 -0
- package/dist/modes/interactive/components/auth-url.d.ts.map +1 -0
- package/dist/modes/interactive/components/auth-url.js +37 -0
- package/dist/modes/interactive/components/auth-url.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +5 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +17 -14
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +5 -2
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +2 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +5 -2
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +3 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +8 -2
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +3 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +38 -10
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +8 -2
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +24 -21
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.d.ts +15 -0
- package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/radius-login-selector.js +85 -0
- package/dist/modes/interactive/components/radius-login-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +9 -8
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +5 -2
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +2 -2
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +12 -13
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +32 -45
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +2 -9
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +5 -4
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +43 -48
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +362 -278
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/program-status-reporter.d.ts +34 -0
- package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -0
- package/dist/modes/interactive/program-status-reporter.js +110 -0
- package/dist/modes/interactive/program-status-reporter.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +1 -1
- package/dist/modes/interactive/theme/light.json +1 -1
- package/dist/modes/interactive/theme/system-theme.d.ts +2 -1
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/system-theme.js +16 -5
- package/dist/modes/interactive/theme/system-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.js +105 -0
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-tokens.js +94 -0
- package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts +13 -16
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +22 -29
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +4 -0
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +26 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/atomic-commit.md +8 -6
- package/dist/prompts/commands/brainstorm.md +5 -149
- package/dist/prompts/commands/create-verification-skill.md +8 -48
- package/dist/prompts/commands/discuss-phase.md +6 -10
- package/dist/prompts/commands/execute-phase.md +18 -45
- package/dist/prompts/commands/fix.md +16 -128
- package/dist/prompts/commands/grill.md +6 -53
- package/dist/prompts/commands/init-project.md +13 -18
- package/dist/prompts/commands/map-codebase.md +3 -3
- package/dist/prompts/commands/new-project.md +12 -17
- package/dist/prompts/commands/next-milestone.md +4 -8
- package/dist/prompts/commands/orchestrate-loop.md +12 -12
- package/dist/prompts/commands/orchestrate.md +12 -11
- package/dist/prompts/commands/pause-work.md +1 -1
- package/dist/prompts/commands/plan-phase.md +15 -37
- package/dist/prompts/commands/quick.md +11 -64
- package/dist/prompts/commands/resolve-conflicts.md +2 -15
- package/dist/prompts/commands/triage.md +3 -14
- package/dist/prompts/commands/verify-work.md +15 -63
- package/dist/prompts/commands/why.md +18 -118
- package/dist/skills/atomic-reasoning/SKILL.md +6 -105
- package/dist/skills/blast-radius/SKILL.md +1 -1
- package/dist/skills/epistemics/SKILL.md +12 -87
- package/dist/skills/explainers/SKILL.md +1 -1
- package/dist/skills/typescript-discipline/SKILL.md +12 -42
- package/dist/skills/typescript-discipline/references/patterns.md +25 -266
- package/dist/skills/unslop/SKILL.md +14 -105
- package/dist/utils/ansi.d.ts +8 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +30 -11
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts.map +1 -1
- package/dist/utils/clipboard-command.js +3 -0
- package/dist/utils/clipboard-command.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +18 -12
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/draht-user-agent.d.ts +1 -0
- package/dist/utils/draht-user-agent.d.ts.map +1 -1
- package/dist/utils/draht-user-agent.js +3 -2
- package/dist/utils/draht-user-agent.js.map +1 -1
- package/dist/utils/image-convert.d.ts +12 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +45 -6
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts +12 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +5 -0
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/image-resize-worker.js +3 -2
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +9 -10
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/output-files.d.ts +15 -0
- package/dist/utils/output-files.d.ts.map +1 -0
- package/dist/utils/output-files.js +30 -0
- package/dist/utils/output-files.js.map +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +43 -13
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +6 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +4 -3
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/cli-integration.md +1 -1
- package/docs/cli.md +30 -26
- package/docs/codemode.md +230 -0
- package/docs/compaction.md +5 -5
- package/docs/containerization.md +1 -1
- package/docs/custom-provider.md +53 -1
- package/docs/docs.json +17 -1
- package/docs/drahtbank.md +163 -0
- package/docs/environment-variables.md +5 -2
- package/docs/extensions.md +143 -13
- package/docs/index.md +1 -1
- package/docs/json.md +3 -3
- package/docs/keybindings.md +9 -5
- package/docs/llama-cpp.md +9 -2
- package/docs/mcp.md +59 -3
- package/docs/message-types.md +22 -4
- package/docs/models-configuration.md +187 -0
- package/docs/models.md +67 -4
- package/docs/nvidia-rtx-llama-cpp.md +96 -0
- package/docs/providers.md +70 -5
- package/docs/sdk.md +1 -1
- package/docs/settings.md +10 -8
- package/docs/terminal-setup.md +14 -0
- package/docs/themes.md +4 -2
- package/docs/tui.md +71 -1
- package/docs/usage.md +1 -1
- package/docs/windows.md +16 -2
- package/eval/drahtbank/adapters.d.mts +35 -0
- package/eval/drahtbank/adapters.mjs +192 -0
- package/eval/drahtbank/bank.d.mts +141 -0
- package/eval/drahtbank/bank.mjs +515 -0
- package/eval/drahtbank/cases-v2.d.mts +28 -0
- package/eval/drahtbank/cases-v2.mjs +164 -0
- package/eval/drahtbank/cases.d.mts +17 -0
- package/eval/drahtbank/cases.mjs +198 -0
- package/eval/drahtbank/cli.mjs +120 -0
- package/eval/drahtbank/grading-v2.d.mts +26 -0
- package/eval/drahtbank/grading-v2.mjs +227 -0
- package/eval/drahtbank/isolated-tools.ts +223 -0
- package/eval/drahtbank/isolation-worker.mjs +53 -0
- package/eval/drahtbank/isolation.d.mts +52 -0
- package/eval/drahtbank/isolation.mjs +345 -0
- package/eval/drahtbank/runtime-checks.d.mts +15 -0
- package/eval/drahtbank/runtime-checks.mjs +187 -0
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/minimal-mode.ts +4 -5
- package/examples/extensions/overlay-test.ts +2 -2
- package/examples/extensions/plan-mode/index.ts +6 -2
- package/examples/extensions/subagent/index.ts +4 -6
- package/hooks/checks/checks-runtime.cjs +215 -0
- package/hooks/checks/git-safety.cjs +198 -0
- package/hooks/checks/git-safety.d.cts +1 -0
- package/hooks/gsd/draht-post-task.js +78 -39
- package/hooks/gsd/draht-quality-gate.js +210 -122
- package/hooks/gsd/package.json +3 -0
- package/package.json +21 -16
- package/prompts/commands/atomic-commit.md +8 -6
- package/prompts/commands/brainstorm.md +5 -149
- package/prompts/commands/create-verification-skill.md +8 -48
- package/prompts/commands/discuss-phase.md +6 -10
- package/prompts/commands/execute-phase.md +18 -45
- package/prompts/commands/fix.md +16 -128
- package/prompts/commands/grill.md +6 -53
- package/prompts/commands/init-project.md +13 -18
- package/prompts/commands/map-codebase.md +3 -3
- package/prompts/commands/new-project.md +12 -17
- package/prompts/commands/next-milestone.md +4 -8
- package/prompts/commands/orchestrate-loop.md +12 -12
- package/prompts/commands/orchestrate.md +12 -11
- package/prompts/commands/pause-work.md +1 -1
- package/prompts/commands/plan-phase.md +15 -37
- package/prompts/commands/quick.md +11 -64
- package/prompts/commands/resolve-conflicts.md +2 -15
- package/prompts/commands/triage.md +3 -14
- package/prompts/commands/verify-work.md +15 -63
- package/prompts/commands/why.md +18 -118
- package/schemas/keybindings.schema.json +433 -0
- package/schemas/models.schema.json +1190 -0
- package/schemas/settings.schema.json +849 -0
- package/schemas/theme.schema.json +365 -0
- package/skills/atomic-reasoning/SKILL.md +6 -105
- package/skills/blast-radius/SKILL.md +1 -1
- package/skills/epistemics/SKILL.md +12 -87
- package/skills/explainers/SKILL.md +1 -1
- package/skills/typescript-discipline/SKILL.md +12 -42
- package/skills/typescript-discipline/references/patterns.md +25 -266
- package/skills/unslop/SKILL.md +14 -105
- package/dist/bundle/chunks/anthropic-messages-GAKYXF65.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-ZIXMK6JO.js +0 -2
- package/dist/bundle/chunks/chunk-2E5VODES.js +0 -2
- package/dist/bundle/chunks/chunk-2VAF4XJI.js +0 -146
- package/dist/bundle/chunks/chunk-4TVQYRQY.js +0 -2
- package/dist/bundle/chunks/chunk-6MSE6LZ3.js +0 -6
- package/dist/bundle/chunks/chunk-6ZJKIMU7.js +0 -2
- package/dist/bundle/chunks/chunk-736QBNUZ.js +0 -12
- package/dist/bundle/chunks/chunk-7TYCZN4Z.js +0 -137
- package/dist/bundle/chunks/chunk-BXSHCX3G.js +0 -11
- package/dist/bundle/chunks/chunk-GVXA72ZA.js +0 -2
- package/dist/bundle/chunks/chunk-I5OKY6RH.js +0 -11
- package/dist/bundle/chunks/chunk-IWTUBX6V.js +0 -4
- package/dist/bundle/chunks/chunk-KU5HAKZL.js +0 -4
- package/dist/bundle/chunks/chunk-MO3SCGBN.js +0 -18
- package/dist/bundle/chunks/chunk-N2QZNJT6.js +0 -65
- package/dist/bundle/chunks/chunk-PGJAHC3R.js +0 -107
- package/dist/bundle/chunks/chunk-QVFELZW2.js +0 -312
- package/dist/bundle/chunks/chunk-RZKPFWMH.js +0 -42
- package/dist/bundle/chunks/chunk-SDRCE6OP.js +0 -2
- package/dist/bundle/chunks/chunk-SVNWI7EV.js +0 -8
- package/dist/bundle/chunks/chunk-TIA2T6EO.js +0 -3
- package/dist/bundle/chunks/chunk-TOWVIJ2O.js +0 -1623
- package/dist/bundle/chunks/chunk-XBUEMKIY.js +0 -2
- package/dist/bundle/chunks/chunk-ZA4QNPJY.js +0 -82
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MJKOAE5S.js +0 -2
- package/dist/bundle/chunks/execute-6N7T7VLY.js +0 -18
- package/dist/bundle/chunks/google-generative-ai-RPUPQ6PM.js +0 -2
- package/dist/bundle/chunks/google-vertex-EZES5QVQ.js +0 -2
- package/dist/bundle/chunks/https-proxy-agent-O2PVUIOI.js +0 -13
- package/dist/bundle/chunks/lib-XOG5PI3Y.js +0 -9
- package/dist/bundle/chunks/mistral-conversations-AOYGU43Y.js +0 -5
- package/dist/bundle/chunks/node-LQ52KV6B.js +0 -16
- package/dist/bundle/chunks/openai-codex-responses-M2Y77JEQ.js +0 -10
- package/dist/bundle/chunks/openai-completions-A4OKYOYV.js +0 -7
- package/dist/bundle/chunks/openai-responses-6IXV53T3.js +0 -3
- package/dist/bundle/chunks/openrouter-images-LYV4NKFM.js +0 -2
- package/dist/bundle/chunks/pi-messages-KKMEUT3Z.js +0 -8
- package/dist/bundle/chunks/runtime-363BOYEO.js +0 -3
- package/dist/bundle/chunks/runtime-D3KV73AE.js +0 -2
- package/dist/bundle/chunks/settings-manager-GEOZJXFQ.js +0 -2
- package/dist/bundle/chunks/src-TIBHS42X.js +0 -4
- package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +0 -2
- package/dist/bundle/chunks/virtual-modules-RLC4Y5MX.js +0 -2
- package/dist/core/provider-attribution.d.ts +0 -4
- package/dist/core/provider-attribution.d.ts.map +0 -1
- package/dist/core/provider-attribution.js +0 -72
- package/dist/core/provider-attribution.js.map +0 -1
- package/dist/experimental/micro/api.d.ts +0 -81
- package/dist/experimental/micro/api.d.ts.map +0 -1
- package/dist/experimental/micro/api.js +0 -2
- package/dist/experimental/micro/api.js.map +0 -1
- package/dist/experimental/micro/main.d.ts +0 -3
- package/dist/experimental/micro/main.d.ts.map +0 -1
- package/dist/experimental/micro/main.js +0 -21
- package/dist/experimental/micro/main.js.map +0 -1
- package/dist/experimental/micro/models.d.ts +0 -11
- package/dist/experimental/micro/models.d.ts.map +0 -1
- package/dist/experimental/micro/models.js +0 -95
- package/dist/experimental/micro/models.js.map +0 -1
- package/dist/experimental/micro/runtime.d.ts +0 -12
- package/dist/experimental/micro/runtime.d.ts.map +0 -1
- package/dist/experimental/micro/runtime.js +0 -465
- package/dist/experimental/micro/runtime.js.map +0 -1
- package/dist/experimental/micro/sessions.d.ts +0 -10
- package/dist/experimental/micro/sessions.d.ts.map +0 -1
- package/dist/experimental/micro/sessions.js +0 -41
- package/dist/experimental/micro/sessions.js.map +0 -1
- package/dist/experimental/micro/tools.d.ts +0 -10
- package/dist/experimental/micro/tools.d.ts.map +0 -1
- package/dist/experimental/micro/tools.js +0 -96
- package/dist/experimental/micro/tools.js.map +0 -1
- package/dist/experimental/micro/tui.d.ts +0 -3
- package/dist/experimental/micro/tui.d.ts.map +0 -1
- package/dist/experimental/micro/tui.js +0 -510
- package/dist/experimental/micro/tui.js.map +0 -1
- package/dist/experimental/mini/main.d.ts +0 -7
- package/dist/experimental/mini/main.d.ts.map +0 -1
- package/dist/experimental/mini/main.js +0 -21
- package/dist/experimental/mini/main.js.map +0 -1
- package/dist/experimental/mini/server/entry.d.ts +0 -3
- package/dist/experimental/mini/server/entry.d.ts.map +0 -1
- package/dist/experimental/mini/server/entry.js +0 -11
- package/dist/experimental/mini/server/entry.js.map +0 -1
- package/dist/experimental/mini/server/run.d.ts +0 -13
- package/dist/experimental/mini/server/run.d.ts.map +0 -1
- package/dist/experimental/mini/server/run.js +0 -150
- package/dist/experimental/mini/server/run.js.map +0 -1
- package/dist/experimental/mini/shared/protocol.d.ts +0 -127
- package/dist/experimental/mini/shared/protocol.d.ts.map +0 -1
- package/dist/experimental/mini/shared/protocol.js +0 -13
- package/dist/experimental/mini/shared/protocol.js.map +0 -1
- package/dist/experimental/mini/shared/rpc.d.ts +0 -49
- package/dist/experimental/mini/shared/rpc.d.ts.map +0 -1
- package/dist/experimental/mini/shared/rpc.js +0 -171
- package/dist/experimental/mini/shared/rpc.js.map +0 -1
- package/dist/experimental/mini/shared/transport.d.ts +0 -35
- package/dist/experimental/mini/shared/transport.d.ts.map +0 -1
- package/dist/experimental/mini/shared/transport.js +0 -94
- package/dist/experimental/mini/shared/transport.js.map +0 -1
- package/dist/experimental/mini/tui/run.d.ts +0 -9
- package/dist/experimental/mini/tui/run.d.ts.map +0 -1
- package/dist/experimental/mini/tui/run.js +0 -62
- package/dist/experimental/mini/tui/run.js.map +0 -1
- package/dist/experimental/mini/tui/session.d.ts +0 -26
- package/dist/experimental/mini/tui/session.d.ts.map +0 -1
- package/dist/experimental/mini/tui/session.js +0 -94
- package/dist/experimental/mini/tui/session.js.map +0 -1
- package/dist/experimental/mini/tui/view.d.ts +0 -10
- package/dist/experimental/mini/tui/view.d.ts.map +0 -1
- package/dist/experimental/mini/tui/view.js +0 -461
- package/dist/experimental/mini/tui/view.js.map +0 -1
- package/dist/experimental/mini/worker/entry.d.ts +0 -3
- package/dist/experimental/mini/worker/entry.d.ts.map +0 -1
- package/dist/experimental/mini/worker/entry.js +0 -10
- package/dist/experimental/mini/worker/entry.js.map +0 -1
- package/dist/experimental/mini/worker/lane-service.d.ts +0 -44
- package/dist/experimental/mini/worker/lane-service.d.ts.map +0 -1
- package/dist/experimental/mini/worker/lane-service.js +0 -97
- package/dist/experimental/mini/worker/lane-service.js.map +0 -1
- package/dist/experimental/mini/worker/models-service.d.ts +0 -19
- package/dist/experimental/mini/worker/models-service.d.ts.map +0 -1
- package/dist/experimental/mini/worker/models-service.js +0 -136
- package/dist/experimental/mini/worker/models-service.js.map +0 -1
- package/dist/experimental/mini/worker/run.d.ts +0 -14
- package/dist/experimental/mini/worker/run.d.ts.map +0 -1
- package/dist/experimental/mini/worker/run.js +0 -88
- package/dist/experimental/mini/worker/run.js.map +0 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +0 -85
- package/dist/modes/interactive/theme/theme-json.d.ts.map +0 -1
- package/dist/modes/interactive/theme/theme-json.js +0 -132
- package/dist/modes/interactive/theme/theme-json.js.map +0 -1
- package/dist/modes/interactive/theme/theme-schema.json +0 -361
- /package/dist/bundle/chunks/{chunk-ZZD35WKM.js → chunk-MOOADNVS.js} +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// Canonical runtime. scripts/sync-checks-runtime.mjs copies this into each plugin.
|
|
5
|
+
const { execFileSync, spawnSync } = require("node:child_process");
|
|
6
|
+
const { createHash } = require("node:crypto");
|
|
7
|
+
const fs = require("node:fs");
|
|
8
|
+
const path = require("node:path");
|
|
9
|
+
|
|
10
|
+
const VERSION = 1;
|
|
11
|
+
const TOTAL_TIMEOUT_MS = 150000;
|
|
12
|
+
const MAX_OUTPUT = 4000;
|
|
13
|
+
|
|
14
|
+
function digest(value) {
|
|
15
|
+
return createHash("sha256").update(value).digest("hex");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function git(cwd, args) {
|
|
19
|
+
return execFileSync("git", args, { cwd, encoding: "utf8", timeout: 10000, maxBuffer: 32 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function findConfig(cwd) {
|
|
23
|
+
let directory = path.resolve(cwd);
|
|
24
|
+
while (true) {
|
|
25
|
+
const file = path.join(directory, ".draht", "checks.json");
|
|
26
|
+
if (fs.existsSync(file)) return { file, root: directory };
|
|
27
|
+
const parent = path.dirname(directory);
|
|
28
|
+
if (fs.existsSync(path.join(directory, ".git")) || parent === directory) return null;
|
|
29
|
+
directory = parent;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function relativePath(value, field) {
|
|
34
|
+
if (typeof value !== "string" || !value || path.isAbsolute(value) || value.includes("\0") || /[*?\[\]{}]/.test(value)) {
|
|
35
|
+
throw new Error(`${field} must be a relative file or directory path (no globs)`);
|
|
36
|
+
}
|
|
37
|
+
const normalized = path.normalize(value);
|
|
38
|
+
if (normalized === ".." || normalized.startsWith(`..${path.sep}`)) throw new Error(`${field} must stay inside the project`);
|
|
39
|
+
return normalized.split(path.sep).join("/").replace(/\/+$/, "");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function loadConfig(location) {
|
|
43
|
+
const source = fs.readFileSync(location.file, "utf8");
|
|
44
|
+
const raw = JSON.parse(source);
|
|
45
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new Error("checks.json must contain an object");
|
|
46
|
+
if (raw.enabled !== undefined && typeof raw.enabled !== "boolean") throw new Error("enabled must be a boolean");
|
|
47
|
+
if (raw.enabled === false) return { enabled: false, checks: [] };
|
|
48
|
+
if (!Array.isArray(raw.checks) || raw.checks.length === 0) throw new Error("checks must be a nonempty array");
|
|
49
|
+
const names = new Set();
|
|
50
|
+
const checks = raw.checks.map((check) => {
|
|
51
|
+
if (!check || typeof check !== "object" || typeof check.name !== "string" || !check.name.trim() || names.has(check.name)) {
|
|
52
|
+
throw new Error("each check needs a unique nonempty name");
|
|
53
|
+
}
|
|
54
|
+
names.add(check.name);
|
|
55
|
+
if (!Array.isArray(check.command) || check.command.length === 0 || check.command.some((part) => typeof part !== "string" || part.includes("\0")) || !check.command[0]) {
|
|
56
|
+
throw new Error(`${check.name}: command must be an argv array`);
|
|
57
|
+
}
|
|
58
|
+
if (check.timeoutMs !== undefined && (!Number.isInteger(check.timeoutMs) || check.timeoutMs < 1 || check.timeoutMs > TOTAL_TIMEOUT_MS)) {
|
|
59
|
+
throw new Error(`${check.name}: timeoutMs must be between 1 and ${TOTAL_TIMEOUT_MS}`);
|
|
60
|
+
}
|
|
61
|
+
if (check.cache !== undefined && typeof check.cache !== "boolean") throw new Error(`${check.name}: cache must be a boolean`);
|
|
62
|
+
if (check.inputs !== undefined && (!Array.isArray(check.inputs) || check.inputs.length === 0)) throw new Error(`${check.name}: inputs must be a nonempty array`);
|
|
63
|
+
return {
|
|
64
|
+
name: check.name,
|
|
65
|
+
command: check.command,
|
|
66
|
+
cwd: relativePath(check.cwd ?? ".", `${check.name}.cwd`),
|
|
67
|
+
inputs: (check.inputs ?? ["."]).map((input) => relativePath(input, `${check.name}.inputs`)),
|
|
68
|
+
timeoutMs: check.timeoutMs ?? 30000,
|
|
69
|
+
cache: check.cache !== false,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
return { enabled: true, checks, sourceHash: digest(source) };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function repository(root) {
|
|
76
|
+
// Outside Git, configured checks still run; there is no evidence cache.
|
|
77
|
+
let directory = root;
|
|
78
|
+
while (!fs.existsSync(path.join(directory, ".git"))) {
|
|
79
|
+
const parent = path.dirname(directory);
|
|
80
|
+
if (parent === directory) return null;
|
|
81
|
+
directory = parent;
|
|
82
|
+
}
|
|
83
|
+
const cachePath = git(root, ["rev-parse", "--path-format=absolute", "--git-path", `draht/checks/${digest(root)}.json`]).trim();
|
|
84
|
+
let revision = "unborn";
|
|
85
|
+
try { revision = git(root, ["rev-parse", "--verify", "HEAD"]).trim(); } catch { /* initial repository */ }
|
|
86
|
+
return { cachePath, revision };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function fingerprint(root, check, config, repo) {
|
|
90
|
+
if (!repo || !check.cache) return null;
|
|
91
|
+
const files = new Set(git(root, ["ls-files", "--cached", "--others", "--exclude-standard", "-z"]).split("\0").filter(Boolean));
|
|
92
|
+
for (const input of check.inputs) {
|
|
93
|
+
// Git may omit ignored symlinks; inspect every explicit input ancestor.
|
|
94
|
+
let absolute = root;
|
|
95
|
+
for (const component of input.split("/")) {
|
|
96
|
+
absolute = path.join(absolute, component);
|
|
97
|
+
try {
|
|
98
|
+
if (fs.lstatSync(absolute).isSymbolicLink()) return null;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (error.code !== "ENOENT") throw error;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Include explicit ignored files too (e.g. a generated schema).
|
|
105
|
+
try { if (!fs.statSync(path.join(root, input)).isDirectory()) files.add(input); } catch { files.add(input); }
|
|
106
|
+
}
|
|
107
|
+
const hash = createHash("sha256").update(JSON.stringify({ version: VERSION, root, check, config, node: process.version, platform: process.platform, arch: process.arch }));
|
|
108
|
+
hash.update(fs.readFileSync(path.join(root, ".draht", "checks.json")));
|
|
109
|
+
for (const file of [...files].sort()) {
|
|
110
|
+
if (!check.inputs.some((input) => input === "." || file === input || file.startsWith(`${input}/`) || input.startsWith(`${file}/`))) continue;
|
|
111
|
+
hash.update(`\0${file}\0`);
|
|
112
|
+
try {
|
|
113
|
+
const absolute = path.join(root, file);
|
|
114
|
+
const stat = fs.lstatSync(absolute);
|
|
115
|
+
// Submodules and symlinks can depend on content outside this snapshot.
|
|
116
|
+
if (!stat.isFile()) return null;
|
|
117
|
+
hash.update(`${stat.mode}\0`).update(fs.readFileSync(absolute));
|
|
118
|
+
} catch (error) {
|
|
119
|
+
if (error.code !== "ENOENT") throw error;
|
|
120
|
+
hash.update("missing");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return hash.digest("hex");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function readCache(repo) {
|
|
127
|
+
if (!repo) return {};
|
|
128
|
+
try {
|
|
129
|
+
const cached = JSON.parse(fs.readFileSync(repo.cachePath, "utf8"));
|
|
130
|
+
return cached.version === VERSION && cached.checks && typeof cached.checks === "object" ? cached.checks : {};
|
|
131
|
+
} catch { return {}; }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function writeCache(repo, checks) {
|
|
135
|
+
if (!repo) return;
|
|
136
|
+
fs.mkdirSync(path.dirname(repo.cachePath), { recursive: true });
|
|
137
|
+
const temporary = `${repo.cachePath}.${process.pid}.tmp`;
|
|
138
|
+
fs.writeFileSync(temporary, JSON.stringify({ version: VERSION, revision: repo.revision, checks }));
|
|
139
|
+
fs.renameSync(temporary, repo.cachePath);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function runChecks({ cwd = process.cwd(), force = false } = {}) {
|
|
143
|
+
const checks = [];
|
|
144
|
+
let configured = false;
|
|
145
|
+
try {
|
|
146
|
+
const location = findConfig(cwd);
|
|
147
|
+
if (!location) return { status: "skipped", configured, summary: "No .draht/checks.json configured", checks };
|
|
148
|
+
configured = true;
|
|
149
|
+
const config = loadConfig(location);
|
|
150
|
+
if (!config.enabled) return { status: "skipped", configured, summary: "Project checks explicitly disabled", checks };
|
|
151
|
+
const repo = repository(location.root);
|
|
152
|
+
const cache = readCache(repo);
|
|
153
|
+
const current = Object.create(null);
|
|
154
|
+
const snapshots = new Map();
|
|
155
|
+
const deadline = Date.now() + TOTAL_TIMEOUT_MS;
|
|
156
|
+
for (const check of config.checks) {
|
|
157
|
+
const before = fingerprint(location.root, check, config, repo);
|
|
158
|
+
snapshots.set(check.name, before);
|
|
159
|
+
if (!force && before && cache[check.name]?.fingerprint === before && cache[check.name]?.status === "passed") {
|
|
160
|
+
checks.push({ name: check.name, status: "cached", fingerprint: before });
|
|
161
|
+
current[check.name] = cache[check.name];
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const remaining = deadline - Date.now();
|
|
165
|
+
if (remaining <= 0) {
|
|
166
|
+
checks.push({ name: check.name, status: "failed", reason: "Total check time limit reached" });
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const started = Date.now();
|
|
170
|
+
let result;
|
|
171
|
+
try {
|
|
172
|
+
result = spawnSync(check.command[0], check.command.slice(1), {
|
|
173
|
+
cwd: path.resolve(location.root, check.cwd), encoding: "utf8", timeout: Math.min(check.timeoutMs, remaining),
|
|
174
|
+
killSignal: "SIGKILL", maxBuffer: 1024 * 1024, stdio: ["ignore", "pipe", "pipe"],
|
|
175
|
+
});
|
|
176
|
+
} catch (error) { result = { error }; }
|
|
177
|
+
const passed = !result.error && !result.signal && result.status === 0;
|
|
178
|
+
const reason = passed ? undefined : String(result.error?.code || result.signal || (typeof result.status === "number" ? `exit ${result.status}` : "unknown exit"));
|
|
179
|
+
const record = { name: check.name, status: passed ? "passed" : "failed", reason, durationMs: Date.now() - started,
|
|
180
|
+
output: [result.stdout, result.stderr, result.error?.message].filter(Boolean).join("\n").slice(0, MAX_OUTPUT), fingerprint: before };
|
|
181
|
+
checks.push(record);
|
|
182
|
+
current[check.name] = { ...record, checkedAt: new Date().toISOString() };
|
|
183
|
+
}
|
|
184
|
+
// A formatter or concurrent edit invalidates earlier evidence from this run.
|
|
185
|
+
const configChanged = digest(fs.readFileSync(location.file, "utf8")) !== config.sourceHash;
|
|
186
|
+
for (const check of config.checks) {
|
|
187
|
+
const record = checks.find((entry) => entry.name === check.name);
|
|
188
|
+
const before = snapshots.get(check.name);
|
|
189
|
+
if (record.status !== "failed" && (configChanged || (before && before !== fingerprint(location.root, check, config, repo)))) {
|
|
190
|
+
record.status = "failed";
|
|
191
|
+
record.reason = "Check inputs changed during verification; run again";
|
|
192
|
+
delete current[check.name];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
writeCache(repo, current);
|
|
196
|
+
const failed = checks.filter((check) => check.status === "failed");
|
|
197
|
+
return { status: failed.length ? "failed" : "passed", configured, checks,
|
|
198
|
+
summary: failed.length ? `Project checks failed: ${failed.map((check) => `${check.name} (${check.reason})`).join(", ")}` : `Project checks passed (${checks.filter((check) => check.status === "cached").length} reused, ${checks.filter((check) => check.status === "passed").length} run)` };
|
|
199
|
+
} catch (error) {
|
|
200
|
+
return { status: "failed", configured, checks, summary: `Project checks failed: ${error.message}` };
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
module.exports = { findConfig, runChecks };
|
|
205
|
+
|
|
206
|
+
if (require.main === module) {
|
|
207
|
+
const cwdIndex = process.argv.indexOf("--cwd");
|
|
208
|
+
const result = runChecks({ cwd: cwdIndex < 0 ? process.cwd() : process.argv[cwdIndex + 1], force: process.argv.includes("--force") });
|
|
209
|
+
if (process.argv.includes("--json")) console.log(JSON.stringify(result));
|
|
210
|
+
else {
|
|
211
|
+
console.log(result.summary);
|
|
212
|
+
for (const check of result.checks) if (check.output) console.log(`${check.name}: ${check.output}`);
|
|
213
|
+
}
|
|
214
|
+
process.exitCode = result.status === "failed" ? 1 : 0;
|
|
215
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// A guard for literal shell commands, not a sandbox or a shell interpreter.
|
|
4
|
+
// Keep this dependency-free so native and plugin hosts use the same policy.
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
function shellCommands(source, depth = 0) {
|
|
8
|
+
if (depth > 8 || source.length > 262144) return [];
|
|
9
|
+
const commands = [];
|
|
10
|
+
let words = [];
|
|
11
|
+
let word = "";
|
|
12
|
+
let started = false;
|
|
13
|
+
let quote = "";
|
|
14
|
+
const flushWord = () => {
|
|
15
|
+
if (started) words.push(word);
|
|
16
|
+
word = "";
|
|
17
|
+
started = false;
|
|
18
|
+
};
|
|
19
|
+
const flushCommand = () => {
|
|
20
|
+
flushWord();
|
|
21
|
+
if (words.length) commands.push(words);
|
|
22
|
+
words = [];
|
|
23
|
+
};
|
|
24
|
+
for (let i = 0; i < source.length; i++) {
|
|
25
|
+
const ch = source[i];
|
|
26
|
+
if (quote === "'") {
|
|
27
|
+
if (ch === "'") quote = "";
|
|
28
|
+
else word += ch;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (ch === "\\" && i + 1 < source.length) {
|
|
32
|
+
const next = source[++i];
|
|
33
|
+
if (next !== "\n") {
|
|
34
|
+
word += quote === '"' && !['$', '`', '"', "\\"].includes(next) ? `\\${next}` : next;
|
|
35
|
+
started = true;
|
|
36
|
+
}
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (ch === "`" || (ch === "$" && source[i + 1] === "(")) {
|
|
40
|
+
const start = i + (ch === "`" ? 1 : 2);
|
|
41
|
+
let end = start;
|
|
42
|
+
let nesting = 1;
|
|
43
|
+
let innerQuote = "";
|
|
44
|
+
for (; end < source.length; end++) {
|
|
45
|
+
const inner = source[end];
|
|
46
|
+
if (inner === "\\" && innerQuote !== "'") { end++; continue; }
|
|
47
|
+
if (innerQuote) { if (inner === innerQuote) innerQuote = ""; continue; }
|
|
48
|
+
if (inner === "'" || inner === '"') { innerQuote = inner; continue; }
|
|
49
|
+
if (ch === "`" && inner === "`") break;
|
|
50
|
+
if (ch === "$" && inner === "(") nesting++;
|
|
51
|
+
if (ch === "$" && inner === ")" && --nesting === 0) break;
|
|
52
|
+
}
|
|
53
|
+
commands.push(...shellCommands(source.slice(start, end), depth + 1));
|
|
54
|
+
word += "<substitution>";
|
|
55
|
+
started = true;
|
|
56
|
+
i = end;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (quote === '"') {
|
|
60
|
+
if (ch === '"') quote = "";
|
|
61
|
+
else word += ch;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (ch === "'" || ch === '"') { quote = ch; started = true; continue; }
|
|
65
|
+
if (ch === "#" && !started) {
|
|
66
|
+
while (i < source.length && source[i] !== "\n") i++;
|
|
67
|
+
flushCommand();
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (/[;&|()\n]/.test(ch)) { flushCommand(); continue; }
|
|
71
|
+
if (/\s/.test(ch)) { flushWord(); continue; }
|
|
72
|
+
word += ch;
|
|
73
|
+
started = true;
|
|
74
|
+
}
|
|
75
|
+
flushCommand();
|
|
76
|
+
return commands;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function executable(word) {
|
|
80
|
+
return path.posix.basename(word.replace(/\\/g, "/")).replace(/\.exe$/i, "");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function canonicalFlag(word) {
|
|
84
|
+
const equals = word.indexOf("=");
|
|
85
|
+
const option = equals < 0 ? word : word.slice(0, equals);
|
|
86
|
+
// Git accepts unambiguous long-option prefixes, including hook bypasses.
|
|
87
|
+
const guarded = ["--no-verify", "--force", "--force-with-lease", "--force-if-includes"];
|
|
88
|
+
const full = guarded.find((flag) => option.startsWith("--") && option.length > 2 && flag.startsWith(option));
|
|
89
|
+
return full ? full + (equals < 0 ? "" : word.slice(equals)) : word;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function gitArguments(words, subcommand) {
|
|
93
|
+
const flags = [];
|
|
94
|
+
const positional = [];
|
|
95
|
+
const takesValue = new Set([
|
|
96
|
+
"--message", "--file", "--reuse-message", "--reedit-message", "--template", "--author", "--date",
|
|
97
|
+
"--cleanup", "--fixup", "--squash", "--pathspec-from-file", "--push-option", "--receive-pack", "--exec", "--repo",
|
|
98
|
+
]);
|
|
99
|
+
const shortValues = subcommand === "push" ? "o" : "mFCct";
|
|
100
|
+
for (let i = 0; i < words.length; i++) {
|
|
101
|
+
const word = words[i];
|
|
102
|
+
if (word === "--") { positional.push(...words.slice(i + 1)); break; }
|
|
103
|
+
if (word.startsWith("--")) {
|
|
104
|
+
flags.push(canonicalFlag(word));
|
|
105
|
+
if (takesValue.has(word)) i++;
|
|
106
|
+
} else if (word.startsWith("-")) {
|
|
107
|
+
for (let j = 1; j < word.length; j++) {
|
|
108
|
+
if (shortValues.includes(word[j])) { if (j === word.length - 1) i++; break; }
|
|
109
|
+
flags.push(`-${word[j]}`);
|
|
110
|
+
}
|
|
111
|
+
} else positional.push(word);
|
|
112
|
+
}
|
|
113
|
+
return { flags, positional };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function inspectWords(original, depth) {
|
|
117
|
+
const words = [...original];
|
|
118
|
+
let bypassHooks = false;
|
|
119
|
+
while (words.length) {
|
|
120
|
+
if (["if", "then", "elif", "else", "while", "until", "do", "!"].includes(words[0])) {
|
|
121
|
+
words.shift();
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (/^[A-Za-z_][A-Za-z_0-9]*=/.test(words[0])) {
|
|
125
|
+
if (words[0] === "HUSKY=0") bypassHooks = true;
|
|
126
|
+
words.shift();
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const head = executable(words[0]);
|
|
130
|
+
if (["command", "builtin", "exec", "nohup"].includes(head)) {
|
|
131
|
+
words.shift();
|
|
132
|
+
if (words[0] === "--") words.shift();
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (head === "env") {
|
|
136
|
+
words.shift();
|
|
137
|
+
while (words[0]?.startsWith("-")) {
|
|
138
|
+
const flag = words.shift();
|
|
139
|
+
if (["-u", "--unset", "-C", "--chdir"].includes(flag)) words.shift();
|
|
140
|
+
}
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (head === "sudo") {
|
|
144
|
+
words.shift();
|
|
145
|
+
while (words[0]?.startsWith("-")) {
|
|
146
|
+
if (["-u", "-g", "-h", "-p"].includes(words.shift())) words.shift();
|
|
147
|
+
}
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
if (!words.length) return undefined;
|
|
153
|
+
const head = executable(words.shift());
|
|
154
|
+
if (["sh", "bash", "zsh", "dash", "ksh"].includes(head)) {
|
|
155
|
+
const commandFlag = words.findIndex((word) => /^-[^-]*c/.test(word));
|
|
156
|
+
return commandFlag >= 0 ? findGitSafetyViolation(words[commandFlag + 1] ?? "", depth + 1) : undefined;
|
|
157
|
+
}
|
|
158
|
+
if (head !== "git") return undefined;
|
|
159
|
+
while (words[0]?.startsWith("-")) {
|
|
160
|
+
const option = words.shift();
|
|
161
|
+
if (["-C", "-c", "--git-dir", "--work-tree", "--namespace", "--config-env"].includes(option)) {
|
|
162
|
+
const value = words.shift() ?? "";
|
|
163
|
+
if ((option === "-c" || option === "--config-env") && /^core\.hooksPath=/i.test(value)) bypassHooks = true;
|
|
164
|
+
} else if (/^-ccore\.hooksPath=|^--config-env=core\.hooksPath=/i.test(option)) bypassHooks = true;
|
|
165
|
+
}
|
|
166
|
+
const subcommand = words.shift();
|
|
167
|
+
if (!["commit", "push", "merge", "rebase", "am"].includes(subcommand)) return undefined;
|
|
168
|
+
const { flags, positional } = gitArguments(words, subcommand);
|
|
169
|
+
if (bypassHooks || flags.includes("--no-verify") || (subcommand === "commit" && flags.includes("-n"))) {
|
|
170
|
+
return "Git hook bypass is disabled. Run the required checks and keep commit/push hooks enabled.";
|
|
171
|
+
}
|
|
172
|
+
if (subcommand !== "push") return undefined;
|
|
173
|
+
if (positional.some((word) => word.startsWith("+"))) return "Forced Git refspecs are disabled. Use a normal push.";
|
|
174
|
+
for (const word of flags) {
|
|
175
|
+
if (word === "--force" || word === "--force-if-includes" || word === "-f") {
|
|
176
|
+
return "Forced Git updates are disabled. Reconcile the branch and use a normal push.";
|
|
177
|
+
}
|
|
178
|
+
if (word.startsWith("--force-with-lease")) {
|
|
179
|
+
// A named ref with an empty expectation creates only an absent ref;
|
|
180
|
+
// the saga lock uses this compare-and-set operation without rewriting history.
|
|
181
|
+
if (!/^--force-with-lease=refs\/[A-Za-z0-9_./-]+:$/.test(word)) {
|
|
182
|
+
return "Forced Git updates are disabled. Only an explicit create-if-absent ref lease is allowed.";
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function findGitSafetyViolation(command, depth = 0) {
|
|
190
|
+
if (typeof command !== "string" || depth > 8) return undefined;
|
|
191
|
+
for (const words of shellCommands(command, depth)) {
|
|
192
|
+
const violation = inspectWords(words, depth);
|
|
193
|
+
if (violation) return violation;
|
|
194
|
+
}
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
module.exports = { findGitSafetyViolation };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function findGitSafetyViolation(command: string): string | undefined;
|
|
@@ -89,54 +89,93 @@ if (commitHash) {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
function hasTypeConfig(directory) {
|
|
93
|
+
while (true) {
|
|
94
|
+
if (fs.existsSync(path.join(directory, "tsconfig.json"))) return true;
|
|
95
|
+
const parent = path.dirname(directory);
|
|
96
|
+
if (parent === directory) return false;
|
|
97
|
+
directory = parent;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function hasTestCommand() {
|
|
102
|
+
if (toolchain.pm === "bun") return true;
|
|
103
|
+
let directory = cwd;
|
|
104
|
+
while (true) {
|
|
105
|
+
const packagePath = path.join(directory, "package.json");
|
|
106
|
+
if (fs.existsSync(packagePath)) {
|
|
107
|
+
const pkg = JSON.parse(fs.readFileSync(packagePath, "utf-8"));
|
|
108
|
+
return typeof pkg.scripts?.test === "string" && pkg.scripts.test.trim().length > 0;
|
|
109
|
+
}
|
|
110
|
+
const parent = path.dirname(directory);
|
|
111
|
+
if (parent === directory) return false;
|
|
112
|
+
directory = parent;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function commandFailureReason(error) {
|
|
117
|
+
if (error.code === "ETIMEDOUT") return "timed out";
|
|
118
|
+
if (error.signal) return `signal ${error.signal}`;
|
|
119
|
+
if (typeof error.status === "number") return `exit ${error.status}`;
|
|
120
|
+
return error.code || error.message || "unknown process error";
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function verify(command, timeout) {
|
|
124
|
+
try {
|
|
125
|
+
execSync(command, { timeout, encoding: "utf-8", cwd, stdio: "pipe" });
|
|
126
|
+
return "pass";
|
|
127
|
+
} catch (error) {
|
|
128
|
+
const output = [error.stdout, error.stderr].filter(Boolean).join("\n").trim().slice(-4000);
|
|
129
|
+
console.error(`${command} failed (${commandFailureReason(error)})${output ? `:\n${output}` : ""}`);
|
|
130
|
+
return "fail";
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
let finalStatus = status;
|
|
135
|
+
let checks;
|
|
136
|
+
if (status === "pass") {
|
|
137
|
+
checks = { types: "skip", tests: "skip" };
|
|
138
|
+
if (hasTypeConfig(cwd)) {
|
|
139
|
+
const tsCmd = toolchain.pm === "bun" ? "bun run tsc --noEmit" : "npx tsc --noEmit";
|
|
140
|
+
checks.types = verify(tsCmd, 30000);
|
|
141
|
+
} else {
|
|
142
|
+
console.log("Type check skipped: no tsconfig.json.");
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
if (hasTestCommand()) {
|
|
146
|
+
checks.tests = verify(toolchain.testCmd, 60000);
|
|
147
|
+
} else {
|
|
148
|
+
console.log("Tests skipped: no configured test script.");
|
|
149
|
+
}
|
|
150
|
+
} catch (error) {
|
|
151
|
+
checks.tests = "fail";
|
|
152
|
+
console.error(`Cannot determine test command: ${error.message}`);
|
|
153
|
+
}
|
|
154
|
+
if (checks.types === "fail" || checks.tests === "fail") {
|
|
155
|
+
finalStatus = "fail";
|
|
156
|
+
if (hookConfig.qualityGateStrict) process.exitCode = 1;
|
|
157
|
+
}
|
|
158
|
+
console.log(`Task ${phaseNum}-${planNum}-${taskNum}: types=${checks.types}, tests=${checks.tests}`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Persist only the result after verification, including failures in advisory mode.
|
|
93
162
|
const entry = {
|
|
94
163
|
timestamp: new Date().toISOString(),
|
|
95
164
|
phase: parseInt(phaseNum, 10),
|
|
96
165
|
plan: parseInt(planNum, 10),
|
|
97
166
|
task: parseInt(taskNum, 10),
|
|
98
|
-
status,
|
|
167
|
+
status: finalStatus,
|
|
168
|
+
reportedStatus: status,
|
|
169
|
+
checks,
|
|
99
170
|
commit: commitHash || null,
|
|
100
171
|
};
|
|
101
172
|
|
|
102
173
|
fs.appendFileSync(LOG_FILE, JSON.stringify(entry) + "\n");
|
|
103
174
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const tsCmd = toolchain.pm === "bun" ? "bun run tsc --noEmit 2>&1" : "npx tsc --noEmit 2>&1";
|
|
109
|
-
execSync(tsCmd, { timeout: 30000, encoding: "utf-8", cwd });
|
|
110
|
-
// Run tests
|
|
111
|
-
try {
|
|
112
|
-
const testOutput = execSync(`${toolchain.testCmd} 2>&1`, { timeout: 60000, encoding: "utf-8", cwd });
|
|
113
|
-
const testMatch = testOutput.match(/(\d+) pass/);
|
|
114
|
-
const testCount = testMatch ? testMatch[1] : "?";
|
|
115
|
-
console.log(`✅ Task ${phaseNum}-${planNum}-${taskNum}: passed + types clean + ${testCount} tests pass`);
|
|
116
|
-
} catch (testErr) {
|
|
117
|
-
const testOut = testErr.stdout || testErr.stderr || "";
|
|
118
|
-
const failMatch = testOut.match(/(\d+) fail/);
|
|
119
|
-
if (failMatch) {
|
|
120
|
-
console.log(`⚠️ Task ${phaseNum}-${planNum}-${taskNum}: passed + types clean but ${failMatch[1]} test(s) failed`);
|
|
121
|
-
} else {
|
|
122
|
-
console.log(`✅ Task ${phaseNum}-${planNum}-${taskNum}: passed + types clean (no test runner found)`);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
} catch (error) {
|
|
126
|
-
const output = error.stdout || "";
|
|
127
|
-
const errorCount = (output.match(/error TS/g) || []).length;
|
|
128
|
-
if (errorCount > 0) {
|
|
129
|
-
console.log(`⚠️ Task ${phaseNum}-${planNum}-${taskNum}: passed but ${errorCount} type error(s) introduced`);
|
|
130
|
-
fs.appendFileSync(LOG_FILE, JSON.stringify({
|
|
131
|
-
...entry,
|
|
132
|
-
warning: `${errorCount} type errors introduced`,
|
|
133
|
-
}) + "\n");
|
|
134
|
-
} else {
|
|
135
|
-
console.log(`✅ Task ${phaseNum}-${planNum}-${taskNum}: passed`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
} else if (status === "fail") {
|
|
139
|
-
console.log(`❌ Task ${phaseNum}-${planNum}-${taskNum}: FAILED`);
|
|
175
|
+
if (finalStatus === "pass") {
|
|
176
|
+
console.log(`Task ${phaseNum}-${planNum}-${taskNum}: passed`);
|
|
177
|
+
} else if (finalStatus === "fail") {
|
|
178
|
+
console.log(`Task ${phaseNum}-${planNum}-${taskNum}: FAILED`);
|
|
140
179
|
|
|
141
180
|
// Check if we should create a fix plan
|
|
142
181
|
const logContent = fs.readFileSync(LOG_FILE, "utf-8");
|
|
@@ -147,7 +186,7 @@ if (status === "pass") {
|
|
|
147
186
|
|
|
148
187
|
if (taskFailures.length >= 3) {
|
|
149
188
|
console.log(`\n⚠️ Task has failed 3+ times. Consider creating a fix plan:`);
|
|
150
|
-
console.log(` draht create-fix-plan ${phaseNum} ${planNum} "Task ${taskNum} failed repeatedly"`);
|
|
189
|
+
console.log(` draht-tools create-fix-plan ${phaseNum} ${planNum} "Task ${taskNum} failed repeatedly"`);
|
|
151
190
|
}
|
|
152
191
|
} else {
|
|
153
192
|
console.log(`⏭️ Task ${phaseNum}-${planNum}-${taskNum}: skipped`);
|