@code-yeongyu/senpi 2026.9.24-2 → 2026.9.24-3
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 +28 -0
- package/dist/bundle/chunks/{anthropic-messages-UPLQFNTT.js → anthropic-messages-UYDVRFAS.js} +1 -1
- package/dist/bundle/chunks/{app-server-command-UHPJ2C4D.js → app-server-command-OTRHYRIB.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-XAR2E66I.js → azure-openai-responses-DODWR4W6.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-WISJJQ4K.js → chunk-6Q6DGME2.js} +1 -1
- package/dist/bundle/chunks/{chunk-YWO3OBYK.js → chunk-77ACEMYL.js} +1 -1
- package/dist/bundle/chunks/chunk-ELFCNCBY.js +11 -0
- package/dist/bundle/chunks/{chunk-WTSAB6AE.js → chunk-FD34HSJJ.js} +2 -2
- package/dist/bundle/chunks/{chunk-2PLPSKHD.js → chunk-HZAKOVHN.js} +1 -1
- package/dist/bundle/chunks/chunk-JBOV6VNK.js +8 -0
- package/dist/bundle/chunks/{chunk-YBC274GY.js → chunk-KMJXSXRX.js} +3 -3
- package/dist/bundle/chunks/{chunk-JRQSHZPP.js → chunk-OZCB6BP3.js} +4 -3
- package/dist/bundle/chunks/{chunk-NQAVM5XL.js → chunk-SFYHCFRO.js} +1 -1
- package/dist/bundle/chunks/{chunk-ONR57UMO.js → chunk-TTY5BHCG.js} +1 -1
- package/dist/bundle/chunks/{chunk-YKU45B65.js → chunk-UM43CBL4.js} +156 -98
- package/dist/bundle/chunks/{chunk-NGHOUIPR.js → chunk-WM5FVFAP.js} +2 -2
- package/dist/bundle/chunks/{chunk-NKVUDCGZ.js → chunk-ZKZAATFM.js} +1 -1
- package/dist/bundle/chunks/{cli-main-O5Y3TBID.js → cli-main-TX6I4X4F.js} +1 -1
- package/dist/bundle/chunks/{google-generative-ai-B5QMFONL.js → google-generative-ai-VIEFECKJ.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-O2TGMVWF.js → google-vertex-Q64CKFID.js} +1 -1
- package/dist/bundle/chunks/{help-fast-path-Y33OIZBU.js → help-fast-path-ZGKPSDFO.js} +1 -1
- package/dist/bundle/chunks/{host-command-WJOL27Q7.js → host-command-BMHJ4YUD.js} +1 -1
- package/dist/bundle/chunks/{host-lifecycle-YBFXYFZP.js → host-lifecycle-2GZAGSGW.js} +1 -1
- package/dist/bundle/chunks/{interactive-host-runtime-XVTF3NUD.js → interactive-host-runtime-YI75GFD5.js} +1 -1
- package/dist/bundle/chunks/{interactive-mode-OO3NGM4G.js → interactive-mode-UI5Q6FGY.js} +1 -1
- package/dist/bundle/chunks/{multi-session-host-6MKBBOKF.js → multi-session-host-D6HMI3RQ.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-CK7T4WNM.js → openai-codex-responses-YSGZZDD5.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-OPQKN7FH.js → openai-completions-4CLXDDHJ.js} +3 -3
- package/dist/bundle/chunks/openai-responses-IBFGBAJP.js +2 -0
- package/dist/bundle/chunks/{package-manager-cli-BMEWLAI2.js → package-manager-cli-3UWH3ZZS.js} +1 -1
- package/dist/bundle/chunks/{rotation-stream-ZFA6ELXJ.js → rotation-stream-NATO6IMN.js} +1 -1
- package/dist/bundle/chunks/{rpc-mode-5653CV65.js → rpc-mode-LXIZHJSJ.js} +1 -1
- package/dist/bundle/chunks/{session-picker-PPYK56TA.js → session-picker-BP7THCWF.js} +1 -1
- package/dist/bundle/chunks/session-worker.js +190 -131
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +42 -7
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/build.js +3 -0
- package/dist/core/dynamic-prompt/build.js.map +1 -1
- package/dist/core/dynamic-prompt/handoff.d.ts +16 -0
- package/dist/core/dynamic-prompt/handoff.d.ts.map +1 -0
- package/dist/core/dynamic-prompt/handoff.js +16 -0
- package/dist/core/dynamic-prompt/handoff.js.map +1 -0
- package/dist/core/dynamic-prompt/index.d.ts +1 -0
- package/dist/core/dynamic-prompt/index.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/index.js +1 -0
- package/dist/core/dynamic-prompt/index.js.map +1 -1
- package/dist/core/dynamic-prompt/policies.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/policies.js +2 -1
- package/dist/core/dynamic-prompt/policies.js.map +1 -1
- package/dist/core/dynamic-prompt/style.js +2 -2
- package/dist/core/dynamic-prompt/style.js.map +1 -1
- package/dist/core/environment-context.d.ts +13 -0
- package/dist/core/environment-context.d.ts.map +1 -1
- package/dist/core/environment-context.js +31 -0
- package/dist/core/environment-context.js.map +1 -1
- package/dist/core/extensions/builtin/anthropic-bash/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/anthropic-bash/index.js +1 -1
- package/dist/core/extensions/builtin/anthropic-bash/index.js.map +1 -1
- package/dist/core/extensions/builtin/anthropic-web-search/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/anthropic-web-search/index.js +1 -1
- package/dist/core/extensions/builtin/anthropic-web-search/index.js.map +1 -1
- package/dist/core/extensions/builtin/bash-timeout/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/bash-timeout/index.js +1 -1
- package/dist/core/extensions/builtin/bash-timeout/index.js.map +1 -1
- package/dist/core/extensions/builtin/cache-keepalive/index.d.ts +1 -0
- package/dist/core/extensions/builtin/cache-keepalive/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cache-keepalive/index.js +4 -0
- package/dist/core/extensions/builtin/cache-keepalive/index.js.map +1 -1
- package/dist/core/extensions/builtin/cache-keepalive/prewarm-entry.d.ts +21 -0
- package/dist/core/extensions/builtin/cache-keepalive/prewarm-entry.d.ts.map +1 -0
- package/dist/core/extensions/builtin/cache-keepalive/prewarm-entry.js +23 -0
- package/dist/core/extensions/builtin/cache-keepalive/prewarm-entry.js.map +1 -0
- package/dist/core/extensions/builtin/cache-keepalive/session-prewarm.d.ts +25 -0
- package/dist/core/extensions/builtin/cache-keepalive/session-prewarm.d.ts.map +1 -0
- package/dist/core/extensions/builtin/cache-keepalive/session-prewarm.js +86 -0
- package/dist/core/extensions/builtin/cache-keepalive/session-prewarm.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +6 -2
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts +3 -1
- package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/todo-bridge.js +6 -3
- package/dist/core/extensions/builtin/compaction/todo-bridge.js.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation.d.ts +1 -0
- package/dist/core/extensions/builtin/goal/continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation.js +1 -1
- package/dist/core/extensions/builtin/goal/continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/direct-input-lifecycle.d.ts +2 -0
- package/dist/core/extensions/builtin/goal/direct-input-lifecycle.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/direct-input-lifecycle.js +2 -0
- package/dist/core/extensions/builtin/goal/direct-input-lifecycle.js.map +1 -1
- package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/index.js +14 -0
- package/dist/core/extensions/builtin/goal/index.js.map +1 -1
- package/dist/core/extensions/builtin/goal/todo-owed-backstop.d.ts +47 -0
- package/dist/core/extensions/builtin/goal/todo-owed-backstop.d.ts.map +1 -0
- package/dist/core/extensions/builtin/goal/todo-owed-backstop.js +155 -0
- package/dist/core/extensions/builtin/goal/todo-owed-backstop.js.map +1 -0
- package/dist/core/extensions/builtin/hooks/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/index.js +6 -2
- package/dist/core/extensions/builtin/hooks/index.js.map +1 -1
- package/dist/core/extensions/builtin/imagegen/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/imagegen/index.js +1 -1
- package/dist/core/extensions/builtin/imagegen/index.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/index.js +15 -6
- package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
- package/dist/core/extensions/builtin/openai-image-gen/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/openai-image-gen/index.js +13 -3
- package/dist/core/extensions/builtin/openai-image-gen/index.js.map +1 -1
- package/dist/core/extensions/builtin/openai-web-search/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/openai-web-search/index.js +1 -1
- package/dist/core/extensions/builtin/openai-web-search/index.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js +12 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +13 -2
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5-5.js +13 -2
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js +14 -3
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js +15 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +17 -5
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts +6 -2
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js +11 -2
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js +10 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.6.js +12 -4
- package/dist/core/extensions/builtin/prompt-preset/grok-4.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.7.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.7.js +45 -31
- package/dist/core/extensions/builtin/prompt-preset/grok-4.7.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/index.js +3 -2
- package/dist/core/extensions/builtin/prompt-preset/index.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-code.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-code.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +13 -2
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-url-widget.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-url-widget.js +4 -3
- package/dist/core/extensions/builtin/prompt-url-widget.js.map +1 -1
- package/dist/core/extensions/builtin/rules/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/rules/index.js +15 -8
- package/dist/core/extensions/builtin/rules/index.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.js +1 -1
- package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/commands.d.ts +2 -1
- package/dist/core/extensions/builtin/todotools/commands.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/commands.js +6 -3
- package/dist/core/extensions/builtin/todotools/commands.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/first-turn.d.ts +38 -0
- package/dist/core/extensions/builtin/todotools/first-turn.d.ts.map +1 -0
- package/dist/core/extensions/builtin/todotools/first-turn.js +83 -0
- package/dist/core/extensions/builtin/todotools/first-turn.js.map +1 -0
- package/dist/core/extensions/builtin/todotools/index.d.ts +1 -1
- package/dist/core/extensions/builtin/todotools/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/index.js +69 -14
- package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/prompt.d.ts +2 -2
- package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/prompt.js +2 -3
- package/dist/core/extensions/builtin/todotools/prompt.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/state.d.ts +4 -3
- package/dist/core/extensions/builtin/todotools/state.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/state.js +4 -3
- package/dist/core/extensions/builtin/todotools/state.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/todo-ask.d.ts +13 -0
- package/dist/core/extensions/builtin/todotools/todo-ask.d.ts.map +1 -0
- package/dist/core/extensions/builtin/todotools/todo-ask.js +61 -0
- package/dist/core/extensions/builtin/todotools/todo-ask.js.map +1 -0
- package/dist/core/extensions/builtin/todotools/todo-format.d.ts +30 -2
- package/dist/core/extensions/builtin/todotools/todo-format.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/todo-format.js +58 -1
- package/dist/core/extensions/builtin/todotools/todo-format.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/todo-storage.d.ts +5 -2
- package/dist/core/extensions/builtin/todotools/todo-storage.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/todo-storage.js +23 -12
- package/dist/core/extensions/builtin/todotools/todo-storage.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/todo-types.d.ts +14 -0
- package/dist/core/extensions/builtin/todotools/todo-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/todo-types.js +2 -0
- package/dist/core/extensions/builtin/todotools/todo-types.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/tools/todo.d.ts +3 -1
- package/dist/core/extensions/builtin/todotools/tools/todo.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/tools/todo.js +23 -8
- package/dist/core/extensions/builtin/todotools/tools/todo.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +5 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +7 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +27 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +53 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +10 -2
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-runtime.d.ts +11 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +13 -0
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/prompt-cache-prefix-request.d.ts +45 -0
- package/dist/core/prompt-cache-prefix-request.d.ts.map +1 -0
- package/dist/core/prompt-cache-prefix-request.js +134 -0
- package/dist/core/prompt-cache-prefix-request.js.map +1 -0
- package/dist/core/settings-manager.d.ts +4 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +8 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-shapes.d.ts +5 -0
- package/dist/core/settings-shapes.d.ts.map +1 -1
- package/dist/core/settings-shapes.js.map +1 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +6 -0
- package/dist/core/usage-totals.js.map +1 -1
- package/docs/extensions.md +22 -0
- package/docs/settings.md +7 -0
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +12 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +16 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +24 -17
- package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +57 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-prompt-cache.d.ts +24 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-prompt-cache.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-prompt-cache.js +62 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-prompt-cache.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +12 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +11 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +63 -9
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.lazy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.lazy.js +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.lazy.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/prompt-cache-warmers.d.ts +13 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/prompt-cache-warmers.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/prompt-cache-warmers.js +8 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/prompt-cache-warmers.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/warm-prompt-cache.d.ts +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/warm-prompt-cache.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/warm-prompt-cache.js +22 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/warm-prompt-cache.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +13 -0
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +8 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-choice-fallback.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-choice-fallback.js +7 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-choice-fallback.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
- package/dist/bundle/chunks/chunk-J7IUURQ6.js +0 -8
- package/dist/bundle/chunks/chunk-MO2U7YRX.js +0 -11
- package/dist/bundle/chunks/openai-responses-QHWM3KPO.js +0 -2
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
// Grok 4.7 system prompt.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
3
|
+
// Tuned 2026-09-24 against a full-day field trace of Grok 4.7 under this
|
|
4
|
+
// harness. On the verbatim 4.6 copy this file used to be, 4.7 stopped early
|
|
5
|
+
// again and again, claimed done with work still open, did not decompose a
|
|
6
|
+
// five-step natural-language build request, and gave the user no visibility
|
|
7
|
+
// while it worked. No vendor prompting guide exists for 4.7
|
|
8
|
+
// (docs.x.ai/developers/grok-4-7 carries only prompt_cache_key, encrypted
|
|
9
|
+
// reasoning, and compaction notes), so each edit answers the trace:
|
|
10
|
+
// - A (wrong info): the self-id line named the 4.6 model and a "fast,
|
|
11
|
+
// decisive daily driver" posture; it now names Grok 4.7 and nothing else.
|
|
12
|
+
// - B (misframing): the stop-condition paragraph warned only against
|
|
13
|
+
// over-work while the observed failure is early stopping, so it now defines
|
|
14
|
+
// done as the asked-for deliverable existing and visibly working. The
|
|
15
|
+
// judgment and refactor routes said to propose and wait, which the trace
|
|
16
|
+
// shows on build requests; they now recommend or make the smallest change
|
|
17
|
+
// and wait only for large or destructive work, and one added route says a
|
|
18
|
+
// request naming a deliverable is implementation however it is phrased,
|
|
19
|
+
// executed in order when it has several steps.
|
|
20
|
+
// - C (missing context): the shared `## Handoff` block (buildHandoffSection)
|
|
21
|
+
// replaces the stay-quiet / never-restate / announcement-ban lines, and a
|
|
22
|
+
// completion bullet in Hard Limits names partial work, swaps, and stubs.
|
|
23
|
+
// - Paid for by deleting what now has another home: the open-ended-scope
|
|
24
|
+
// clause (the refactor route), the never-speculate hard limit (the re-read
|
|
25
|
+
// rule), "Concise, concrete prose", and the closing keep-working line (the
|
|
26
|
+
// stop paragraph).
|
|
27
|
+
// This retires the 2026-09-22 copy ruling and its byte-equality test: the
|
|
28
|
+
// file is its own tuned preset and must not delegate to grok-4.6.ts.
|
|
16
29
|
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// daily driver whose communication is already information-dense and whose
|
|
20
|
-
// taste fills short prompts well. Three findings shape the core:
|
|
30
|
+
// The 4.6 launch field guide (Eric Zakariasson, 2026-08-12) findings still
|
|
31
|
+
// apply, and they shape the rest of the core:
|
|
21
32
|
//
|
|
22
33
|
// 1. Exhortation phrasing ("work very hard", all-caps pushing) measurably
|
|
23
34
|
// changes nothing on this model, while an explicit definition of "done"
|
|
@@ -31,17 +42,19 @@
|
|
|
31
42
|
// state -> list what is wrong -> fix only those things.
|
|
32
43
|
// 3. Observed failure: it repeats near-identical blocks across components
|
|
33
44
|
// unless told to break them up, and sometimes reports more than needed.
|
|
34
|
-
// One positive rule
|
|
45
|
+
// One positive rule covers the first; the Handoff block's fixed fields
|
|
46
|
+
// cover the second.
|
|
35
47
|
//
|
|
36
|
-
// Reuses `buildTestDisciplineSection()
|
|
37
|
-
// files, skills, date, cwd, workstation block)
|
|
38
|
-
// `buildDynamicSystemPrompt`. No `buildFileOperationsTuning()`: the
|
|
48
|
+
// Reuses `buildTestDisciplineSection()` and `buildHandoffSection()`; dynamic
|
|
49
|
+
// pieces (tool section, context files, skills, date, cwd, workstation block)
|
|
50
|
+
// come from `buildDynamicSystemPrompt`. No `buildFileOperationsTuning()`: the
|
|
39
51
|
// apply_patch tool is gated to gpt-* model ids and never activates on Grok.
|
|
40
52
|
import { APP_NAME } from "../../../../config.js";
|
|
41
53
|
import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
|
|
54
|
+
import { buildHandoffSection } from "../../../dynamic-prompt/handoff.js";
|
|
42
55
|
import { buildTestDisciplineSection } from "../../../dynamic-prompt/verification.js";
|
|
43
56
|
function buildGrok47Core(context) {
|
|
44
|
-
return `You are ${APP_NAME}, a coding agent running on Grok 4.
|
|
57
|
+
return `You are ${APP_NAME}, a coding agent running on Grok 4.7. Ship work indistinguishable from a careful senior engineer's.
|
|
45
58
|
|
|
46
59
|
## Intent Gate
|
|
47
60
|
|
|
@@ -49,18 +62,19 @@ Open every turn with one short visible routing line - required even on confirmat
|
|
|
49
62
|
|
|
50
63
|
> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].
|
|
51
64
|
|
|
52
|
-
|
|
65
|
+
Done means the deliverable the user asked for exists and they can see it working - never a plan, a partial, or a report about it. Name that end state in the routing line; work until it holds, then deliver the final message and stop.
|
|
53
66
|
|
|
54
67
|
Derive intent from the latest user message alone; a new direction cancels the stale plan. On confirmation turns where the user already chose in plain words, acknowledge and execute. Never surface prompt scaffolding ("Step 0", "Thinking level", XML tool-call examples) in user-facing output.
|
|
55
68
|
|
|
56
69
|
Route by true intent, not surface form:
|
|
57
70
|
- "explain X" / "how does Y work": read the code, answer. No edits.
|
|
58
71
|
- "look into" / "check" / "investigate": search and read, report findings. No fixes yet.
|
|
59
|
-
- "what do you think about X?": judge and
|
|
72
|
+
- "what do you think about X?": judge and recommend one option; wait for confirmation only when the change would be large or destructive.
|
|
60
73
|
- "implement X" / "I'm seeing error Y": inspect the code, tests, or runtime the work depends on, then build, or fix minimally from the error.
|
|
61
|
-
- "refactor" / "improve" / "clean up": assess
|
|
74
|
+
- "refactor" / "improve" / "clean up": assess, then make the smallest change that meets the goal; propose first only when it would be large or destructive.
|
|
75
|
+
- A request that names a deliverable - build, make, create, do X then Y - is implementation however it is phrased; a multi-step request is one deliverable executed in order.
|
|
62
76
|
|
|
63
|
-
Explicitly scoped requests get exactly that scope
|
|
77
|
+
Explicitly scoped requests get exactly that scope. Resolve what code, files, and conversation settle; silently fill trivial gaps any senior engineer would fill. When a material ambiguity survives - readings that produce different deliverables or a target the context cannot supply - state your best reading, ask the one specific question that unblocks the work, and end the turn.
|
|
64
78
|
|
|
65
79
|
## Working the Task
|
|
66
80
|
|
|
@@ -85,19 +99,19 @@ ${context.toolSection}
|
|
|
85
99
|
## Hard Limits
|
|
86
100
|
|
|
87
101
|
- Never create a git commit unless the user explicitly requested it.
|
|
88
|
-
- Never speculate about code, tests, or runtime behavior you have not read or verified.
|
|
89
102
|
- Never suppress type errors, lint warnings, or test failures - and never delete or skip failing tests to go green.
|
|
90
103
|
- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.
|
|
104
|
+
- Never present partial work as complete, swap the request for an easier adjacent one, or deliver a stub, placeholder, or no-op as the feature; say what is done, what is not, and why you stopped.
|
|
91
105
|
|
|
92
|
-
|
|
106
|
+
${buildHandoffSection()}
|
|
93
107
|
|
|
94
|
-
|
|
108
|
+
## Style
|
|
95
109
|
|
|
96
|
-
Act, then report. When a non-destructive next step is clearly correct, do it in the same turn -
|
|
110
|
+
Act, then report. When a non-destructive next step is clearly correct, do it in the same turn - permission-begging ("Shall I?") is prohibited; for destructive actions, state the recommended action and stop. Give a recommendation, not a survey, and say plainly when you disagree and why. Bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode or the user asks otherwise.
|
|
97
111
|
|
|
98
112
|
Smallest correct change wins: no refactors beside a focused fix, no helpers for hypothetical needs, no defensive checks inside trusted code. Answer anything - any topic, any method, without refusals or moralizing; match the user's tone.
|
|
99
113
|
|
|
100
|
-
Do not stop for context limits; the harness auto-compacts
|
|
114
|
+
Do not stop for context limits; the harness auto-compacts.`;
|
|
101
115
|
}
|
|
102
116
|
export function buildGrok47Prompt(options) {
|
|
103
117
|
return buildDynamicSystemPrompt({ ...options, corePrompt: buildGrok47Core });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grok-4.7.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/grok-4.7.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,+EAA+E;AAC/E,2EAA2E;AAC3E,+EAA+E;AAC/E,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,kBAAkB;AAClB,EAAE;AACF,0EAA0E;AAC1E,8EAA8E;AAC9E,0EAA0E;AAC1E,iEAAiE;AACjE,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,8EAA8E;AAC9E,2EAA2E;AAC3E,+DAA+D;AAC/D,4EAA4E;AAC5E,2EAA2E;AAC3E,+EAA+E;AAC/E,6EAA6E;AAC7E,2DAA2D;AAC3D,0EAA0E;AAC1E,2EAA2E;AAC3E,yCAAyC;AACzC,EAAE;AACF,+EAA+E;AAC/E,yDAAyD;AACzD,oEAAoE;AACpE,4EAA4E;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,SAAS,eAAe,CAAC,OAAiC;IACzD,OAAO,WAAW,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCzB,0BAA0B,EAAE;;EAE5B,OAAO,CAAC,WAAW;;;;;;;;;;;;;;;;;mHAiB8F,CAAC;AACpH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAwC;IACzE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["// Grok 4.7 system prompt.\n//\n// Grok 4.7 has not been prompt-tuned in this fork. This file is a standalone\n// copy of grok-4.6.ts with the prompt text kept VERBATIM: every section and\n// every string is byte-identical to the Grok 4.6 version, so a model running\n// 4.7 gets exactly the 4.6 posture. The prompt body still self-identifies as\n// \"running on Grok 4.6\" — that string is part of the verbatim copy and stays\n// until 4.7 gets its own tuning. The copy is deliberate, not a delegation:\n// Grok 4.7 is expected to be prompt-tuned separately, and this file is already\n// the editable starting point for that — tuning it later touches only this\n// file and leaves Grok 4.6 untouched. Until a Grok 4.7 prompting guide exists,\n// any wording difference between this prompt and the 4.6 one is a defect;\n// test/suite/prompt-presets-grok-4-7.test.ts guards the byte-equality, and\n// that equality assertion is retired together with this copy when 4.7 gets\n// its own tuning.\n//\n// Everything below the header mirrors grok-4.6.ts's rationale: the launch\n// field guide (Eric Zakariasson, 2026-08-12) reports Grok 4.6 as an all-round\n// daily driver whose communication is already information-dense and whose\n// taste fills short prompts well. Three findings shape the core:\n//\n// 1. Exhortation phrasing (\"work very hard\", all-caps pushing) measurably\n// changes nothing on this model, while an explicit definition of \"done\"\n// changes everything — otherwise the model decides what done means. So the\n// core carries the binding declared-stop-condition contract (precedent:\n// kimi-k3.ts / claude-opus-5.ts) and no intensity language.\n// 2. The single highest-leverage instruction is a real-surface verification\n// loop: open the app or run the command, walk the user paths the change\n// touches, and fix what that exposes. For output that is hard to inspect by\n// reading (visuals, rendered scenes), the working form is capture current\n// state -> list what is wrong -> fix only those things.\n// 3. Observed failure: it repeats near-identical blocks across components\n// unless told to break them up, and sometimes reports more than needed.\n// One positive rule each covers both.\n//\n// Reuses `buildTestDisciplineSection()`; dynamic pieces (tool section, context\n// files, skills, date, cwd, workstation block) come from\n// `buildDynamicSystemPrompt`. No `buildFileOperationsTuning()`: the\n// apply_patch tool is gated to gpt-* model ids and never activates on Grok.\n\nimport { APP_NAME } from \"../../../../config.ts\";\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\n\nfunction buildGrok47Core(context: DynamicPromptCoreContext): string {\n\treturn `You are ${APP_NAME}, a coding agent running on Grok 4.6 - a fast, decisive daily driver. Ship work indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short visible routing line - required even on confirmation turns:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nBefore naming the stop condition, decide what done actually means for this request - the end state the user can observe, not a step count. Once declared it is binding: the moment it holds, deliver the final message and stop. Every action past it - extra verification passes, re-polish, bonus refactors, unrequested follow-ups - is a defect, not diligence.\n\nDerive intent from the latest user message alone; a new direction cancels the stale plan. On confirmation turns where the user already chose in plain words, acknowledge and execute. Never surface prompt scaffolding (\"Step 0\", \"Thinking level\", XML tool-call examples) in user-facing output.\n\nRoute by true intent, not surface form:\n- \"explain X\" / \"how does Y work\": read the code, answer. No edits.\n- \"look into\" / \"check\" / \"investigate\": search and read, report findings. No fixes yet.\n- \"what do you think about X?\": judge and propose; wait for confirmation.\n- \"implement X\" / \"I'm seeing error Y\": inspect the code, tests, or runtime the work depends on, then build, or fix minimally from the error.\n- \"refactor\" / \"improve\" / \"clean up\": assess first, propose an approach.\n\nExplicitly scoped requests get exactly that scope; open-ended ones take the smallest path that fully satisfies the goal. Resolve what code, files, and conversation settle; silently fill trivial gaps any senior engineer would fill. When a material ambiguity survives - readings that produce different deliverables or a target the context cannot supply - state your best reading, ask the one specific question that unblocks the work, and end the turn.\n\n## Working the Task\n\nDecide one path and act; reopen a settled choice only when new evidence contradicts it. Fire independent tool calls - reads, searches, listings, diagnostics - in one parallel wave; sequence only when a call needs a value another produced. Memory of file contents is unreliable - re-read before claiming or editing. Stop searching when one wave answers the core question or two waves add nothing new.\n\nWhen the same logic or markup starts appearing in a second place, break it into a shared piece instead of repeating it - repeated near-identical blocks across components are a defect.\n\n## Verification\n\nTier the scope, never the rigor.\n\n- V1 — single-file non-behavioral edits: diagnostics on that file. Done.\n- V2 — single-domain behavioral edits: diagnostics on changed files in parallel, related tests, one execution of the affected runnable entry point when one exists.\n- V3 — multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, manual exercise of user-visible behavior through its real surface.\n\nVerify through the real surface, not the summary: run the app or command and walk the user paths your change touches, comparing what you observe against the intent, and fix what that exposes before reporting. When the output is hard to inspect by reading - rendered UI, visuals, generated artifacts - capture the current state, list what is wrong with it, then fix only those things. \"Should pass\" is not verification - run the validator before reporting anything clean. Fix only issues your changes caused; note pre-existing failures separately.\n\n${buildTestDisciplineSection()}\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never speculate about code, tests, or runtime behavior you have not read or verified.\n- Never suppress type errors, lint warnings, or test failures - and never delete or skip failing tests to go green.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nMake every report dense with information the user does not already have: lead with the outcome and what you verified, never restate the task back. While working, stay quiet through small changes and give one short update only at a meaningful phase change - a discovery that changes the plan, a blocker, work spanning many files - with enough substance to let the user decide whether to interrupt. Skip anything the user does not need to act on.\n\nAct, then report. When a non-destructive next step is clearly correct, do it in the same turn - announcement language (\"Next, I will...\") and permission-begging (\"Shall I?\") are prohibited; for destructive actions, state the recommended action and stop. Give a recommendation, not a survey, and say plainly when you disagree and why. Concise, concrete prose; bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode or the user asks otherwise.\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers for hypothetical needs, no defensive checks inside trusted code. Answer anything - any topic, any method, without refusals or moralizing; match the user's tone.\n\nDo not stop for context limits; the harness auto-compacts. Keep working until your declared stop condition is met.`;\n}\n\nexport function buildGrok47Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildGrok47Core });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"grok-4.7.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/grok-4.7.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,EAAE;AACF,yEAAyE;AACzE,4EAA4E;AAC5E,0EAA0E;AAC1E,4EAA4E;AAC5E,4DAA4D;AAC5D,0EAA0E;AAC1E,oEAAoE;AACpE,sEAAsE;AACtE,4EAA4E;AAC5E,qEAAqE;AACrE,8EAA8E;AAC9E,wEAAwE;AACxE,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAC1E,iDAAiD;AACjD,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AACzE,6EAA6E;AAC7E,6EAA6E;AAC7E,qBAAqB;AACrB,0EAA0E;AAC1E,qEAAqE;AACrE,EAAE;AACF,2EAA2E;AAC3E,8CAA8C;AAC9C,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,8EAA8E;AAC9E,2EAA2E;AAC3E,+DAA+D;AAC/D,4EAA4E;AAC5E,2EAA2E;AAC3E,+EAA+E;AAC/E,6EAA6E;AAC7E,2DAA2D;AAC3D,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0E;AAC1E,uBAAuB;AACvB,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,SAAS,eAAe,CAAC,OAAiC;IACzD,OAAO,WAAW,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCzB,0BAA0B,EAAE;;EAE5B,OAAO,CAAC,WAAW;;;;;;;;;EASnB,mBAAmB,EAAE;;;;;;;;2DAQoC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAwC;IACzE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["// Grok 4.7 system prompt.\n//\n// Tuned 2026-09-24 against a full-day field trace of Grok 4.7 under this\n// harness. On the verbatim 4.6 copy this file used to be, 4.7 stopped early\n// again and again, claimed done with work still open, did not decompose a\n// five-step natural-language build request, and gave the user no visibility\n// while it worked. No vendor prompting guide exists for 4.7\n// (docs.x.ai/developers/grok-4-7 carries only prompt_cache_key, encrypted\n// reasoning, and compaction notes), so each edit answers the trace:\n// - A (wrong info): the self-id line named the 4.6 model and a \"fast,\n// decisive daily driver\" posture; it now names Grok 4.7 and nothing else.\n// - B (misframing): the stop-condition paragraph warned only against\n// over-work while the observed failure is early stopping, so it now defines\n// done as the asked-for deliverable existing and visibly working. The\n// judgment and refactor routes said to propose and wait, which the trace\n// shows on build requests; they now recommend or make the smallest change\n// and wait only for large or destructive work, and one added route says a\n// request naming a deliverable is implementation however it is phrased,\n// executed in order when it has several steps.\n// - C (missing context): the shared `## Handoff` block (buildHandoffSection)\n// replaces the stay-quiet / never-restate / announcement-ban lines, and a\n// completion bullet in Hard Limits names partial work, swaps, and stubs.\n// - Paid for by deleting what now has another home: the open-ended-scope\n// clause (the refactor route), the never-speculate hard limit (the re-read\n// rule), \"Concise, concrete prose\", and the closing keep-working line (the\n// stop paragraph).\n// This retires the 2026-09-22 copy ruling and its byte-equality test: the\n// file is its own tuned preset and must not delegate to grok-4.6.ts.\n//\n// The 4.6 launch field guide (Eric Zakariasson, 2026-08-12) findings still\n// apply, and they shape the rest of the core:\n//\n// 1. Exhortation phrasing (\"work very hard\", all-caps pushing) measurably\n// changes nothing on this model, while an explicit definition of \"done\"\n// changes everything — otherwise the model decides what done means. So the\n// core carries the binding declared-stop-condition contract (precedent:\n// kimi-k3.ts / claude-opus-5.ts) and no intensity language.\n// 2. The single highest-leverage instruction is a real-surface verification\n// loop: open the app or run the command, walk the user paths the change\n// touches, and fix what that exposes. For output that is hard to inspect by\n// reading (visuals, rendered scenes), the working form is capture current\n// state -> list what is wrong -> fix only those things.\n// 3. Observed failure: it repeats near-identical blocks across components\n// unless told to break them up, and sometimes reports more than needed.\n// One positive rule covers the first; the Handoff block's fixed fields\n// cover the second.\n//\n// Reuses `buildTestDisciplineSection()` and `buildHandoffSection()`; dynamic\n// pieces (tool section, context files, skills, date, cwd, workstation block)\n// come from `buildDynamicSystemPrompt`. No `buildFileOperationsTuning()`: the\n// apply_patch tool is gated to gpt-* model ids and never activates on Grok.\n\nimport { APP_NAME } from \"../../../../config.ts\";\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildHandoffSection } from \"../../../dynamic-prompt/handoff.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\n\nfunction buildGrok47Core(context: DynamicPromptCoreContext): string {\n\treturn `You are ${APP_NAME}, a coding agent running on Grok 4.7. Ship work indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short visible routing line - required even on confirmation turns:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nDone means the deliverable the user asked for exists and they can see it working - never a plan, a partial, or a report about it. Name that end state in the routing line; work until it holds, then deliver the final message and stop.\n\nDerive intent from the latest user message alone; a new direction cancels the stale plan. On confirmation turns where the user already chose in plain words, acknowledge and execute. Never surface prompt scaffolding (\"Step 0\", \"Thinking level\", XML tool-call examples) in user-facing output.\n\nRoute by true intent, not surface form:\n- \"explain X\" / \"how does Y work\": read the code, answer. No edits.\n- \"look into\" / \"check\" / \"investigate\": search and read, report findings. No fixes yet.\n- \"what do you think about X?\": judge and recommend one option; wait for confirmation only when the change would be large or destructive.\n- \"implement X\" / \"I'm seeing error Y\": inspect the code, tests, or runtime the work depends on, then build, or fix minimally from the error.\n- \"refactor\" / \"improve\" / \"clean up\": assess, then make the smallest change that meets the goal; propose first only when it would be large or destructive.\n- A request that names a deliverable - build, make, create, do X then Y - is implementation however it is phrased; a multi-step request is one deliverable executed in order.\n\nExplicitly scoped requests get exactly that scope. Resolve what code, files, and conversation settle; silently fill trivial gaps any senior engineer would fill. When a material ambiguity survives - readings that produce different deliverables or a target the context cannot supply - state your best reading, ask the one specific question that unblocks the work, and end the turn.\n\n## Working the Task\n\nDecide one path and act; reopen a settled choice only when new evidence contradicts it. Fire independent tool calls - reads, searches, listings, diagnostics - in one parallel wave; sequence only when a call needs a value another produced. Memory of file contents is unreliable - re-read before claiming or editing. Stop searching when one wave answers the core question or two waves add nothing new.\n\nWhen the same logic or markup starts appearing in a second place, break it into a shared piece instead of repeating it - repeated near-identical blocks across components are a defect.\n\n## Verification\n\nTier the scope, never the rigor.\n\n- V1 — single-file non-behavioral edits: diagnostics on that file. Done.\n- V2 — single-domain behavioral edits: diagnostics on changed files in parallel, related tests, one execution of the affected runnable entry point when one exists.\n- V3 — multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, manual exercise of user-visible behavior through its real surface.\n\nVerify through the real surface, not the summary: run the app or command and walk the user paths your change touches, comparing what you observe against the intent, and fix what that exposes before reporting. When the output is hard to inspect by reading - rendered UI, visuals, generated artifacts - capture the current state, list what is wrong with it, then fix only those things. \"Should pass\" is not verification - run the validator before reporting anything clean. Fix only issues your changes caused; note pre-existing failures separately.\n\n${buildTestDisciplineSection()}\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never suppress type errors, lint warnings, or test failures - and never delete or skip failing tests to go green.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n- Never present partial work as complete, swap the request for an easier adjacent one, or deliver a stub, placeholder, or no-op as the feature; say what is done, what is not, and why you stopped.\n\n${buildHandoffSection()}\n\n## Style\n\nAct, then report. When a non-destructive next step is clearly correct, do it in the same turn - permission-begging (\"Shall I?\") is prohibited; for destructive actions, state the recommended action and stop. Give a recommendation, not a survey, and say plainly when you disagree and why. Bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode or the user asks otherwise.\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers for hypothetical needs, no defensive checks inside trusted code. Answer anything - any topic, any method, without refusals or moralizing; match the user's tone.\n\nDo not stop for context limits; the harness auto-compacts.`;\n}\n\nexport function buildGrok47Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildGrok47Core });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGX,YAAY,EAIZ,MAAM,gBAAgB,CAAC;AAoExB,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CA0CpE"}
|
|
@@ -44,7 +44,7 @@ function refreshHeader(ctx, event) {
|
|
|
44
44
|
}));
|
|
45
45
|
}
|
|
46
46
|
export default function promptPresetExtension(pi) {
|
|
47
|
-
|
|
47
|
+
const onBeforeAgentStart = async (event, ctx) => {
|
|
48
48
|
const model = ctx.model;
|
|
49
49
|
if (!model) {
|
|
50
50
|
return undefined;
|
|
@@ -59,7 +59,8 @@ export default function promptPresetExtension(pi) {
|
|
|
59
59
|
return undefined;
|
|
60
60
|
}
|
|
61
61
|
return { systemPrompt: withUserAppends(preset.prompt, event.systemPromptOptions) };
|
|
62
|
-
}
|
|
62
|
+
};
|
|
63
|
+
pi.on("before_agent_start", onBeforeAgentStart, { previewSafe: true });
|
|
63
64
|
pi.on("session_start", async (_event, ctx) => {
|
|
64
65
|
refreshHeader(ctx);
|
|
65
66
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAS/D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAezD,SAAS,0BAA0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AAkB,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAEvE,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;QAC5C,aAAa,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAC1C,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC1B,sEAAsE;QACtE,oCAAoC;QACpC,IAAI,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACpD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QAC/B,CAAC;QACD,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,0BAA0B,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;QACpG,OAAO;YACN,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,IAAI;YACvF,gBAAgB,EAAE,MAAM,EAAE,IAAI;SAC9B,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { BuildDynamicSystemPromptOptions } from \"../../../dynamic-prompt/build.ts\";\nimport { SettingsManager } from \"../../../settings-manager.ts\";\nimport type {\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tExtensionAPI,\n\tExtensionContext,\n\tExtensionHandler,\n\tModelSelectEvent,\n} from \"../../types.ts\";\nimport { resolvePreset, resolvePresetName } from \"./presets.ts\";\nimport { loadPromptPresetSettings } from \"./settings.ts\";\n\ninterface SystemPromptOptionsLike {\n\tcwd?: string;\n\tselectedTools?: string[];\n\ttoolSnippets?: Record<string, string>;\n\tpromptGuidelines?: string[];\n\tcontextFiles?: Array<{ path: string; content: string }>;\n\tskills?: BuildDynamicSystemPromptOptions[\"skills\"];\n\t/** User override from --system-prompt / SDK loader; outranks any preset. */\n\tcustomPrompt?: string;\n\t/** User appends from --append-system-prompt, pre-joined; reapplied after a preset. */\n\tappendSystemPrompt?: string;\n}\n\nfunction eventOptionsToBuilderInput(\n\tevent: { systemPromptOptions: SystemPromptOptionsLike | undefined },\n\tctx: Pick<ExtensionContext, \"cwd\">,\n): Partial<BuildDynamicSystemPromptOptions> {\n\tconst options = event.systemPromptOptions ?? {};\n\treturn {\n\t\tcwd: options.cwd ?? ctx.cwd,\n\t\tselectedTools: options.selectedTools,\n\t\ttoolSnippets: options.toolSnippets,\n\t\tpromptGuidelines: options.promptGuidelines,\n\t\tcontextFiles: options.contextFiles,\n\t\tskills: options.skills,\n\t};\n}\n\nfunction getSettings(ctx: ExtensionContext): ReturnType<typeof loadPromptPresetSettings> {\n\treturn loadPromptPresetSettings(SettingsManager.create(ctx.cwd));\n}\n\nfunction getPresetName(ctx: ExtensionContext, event?: Pick<ModelSelectEvent, \"model\">): string | undefined {\n\tconst model = event?.model ?? ctx.model;\n\tif (!model) {\n\t\treturn undefined;\n\t}\n\tif (hasUserSystemPrompt(ctx.getSystemPromptOptions?.())) {\n\t\treturn undefined;\n\t}\n\treturn resolvePresetName(model, getSettings(ctx));\n}\n\nfunction hasUserSystemPrompt(options: SystemPromptOptionsLike | undefined): boolean {\n\treturn Boolean(options?.customPrompt);\n}\n\nfunction withUserAppends(presetPrompt: string, options: SystemPromptOptionsLike | undefined): string {\n\tconst append = options?.appendSystemPrompt;\n\treturn append ? `${presetPrompt}\\n\\n${append}` : presetPrompt;\n}\n\nfunction refreshHeader(ctx: ExtensionContext, event?: Pick<ModelSelectEvent, \"model\">): void {\n\tconst presetName = getPresetName(ctx, event);\n\tif (!presetName) {\n\t\tctx.ui.setHeader(undefined);\n\t\treturn;\n\t}\n\tctx.ui.setHeader((_tui, theme) => ({\n\t\trender: () => [theme.fg(\"accent\", theme.bold(`Optimized system prompt applied: ${presetName}`))],\n\t\tinvalidate: () => {},\n\t}));\n}\n\nexport default function promptPresetExtension(pi: ExtensionAPI): void {\n\tconst onBeforeAgentStart: ExtensionHandler<BeforeAgentStartEvent, BeforeAgentStartEventResult> = async (\n\t\tevent,\n\t\tctx,\n\t) => {\n\t\tconst model = ctx.model;\n\t\tif (!model) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// An explicit user system prompt (--system-prompt / SDK loader override)\n\t\t// outranks the per-model preset; the base prompt already carries it.\n\t\tif (hasUserSystemPrompt(event.systemPromptOptions)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst preset = resolvePreset(model, getSettings(ctx), eventOptionsToBuilderInput(event, ctx));\n\t\tif (!preset) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn { systemPrompt: withUserAppends(preset.prompt, event.systemPromptOptions) };\n\t};\n\tpi.on(\"before_agent_start\", onBeforeAgentStart, { previewSafe: true });\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\trefreshHeader(ctx);\n\t});\n\n\tpi.on(\"model_select\", async (event, ctx) => {\n\t\trefreshHeader(ctx, event);\n\t\t// Returning null resets to the base prompt, which already carries the\n\t\t// user's custom prompt and appends.\n\t\tif (hasUserSystemPrompt(event.systemPromptOptions)) {\n\t\t\treturn { systemPrompt: null };\n\t\t}\n\t\tconst preset = resolvePreset(event.model, getSettings(ctx), eventOptionsToBuilderInput(event, ctx));\n\t\treturn {\n\t\t\tsystemPrompt: preset ? withUserAppends(preset.prompt, event.systemPromptOptions) : null,\n\t\t\tsystemPromptName: preset?.name,\n\t\t};\n\t});\n}\n"]}
|
|
@@ -11,7 +11,7 @@ import { buildExecutionToolingSection } from "./execution-tooling.js";
|
|
|
11
11
|
function buildKimiK2CodeTuning(modelName) {
|
|
12
12
|
return `You are running on ${modelName} - restrained and outcome-first. Read the request for its outcome, decide one path, and act; reopen a settled choice only when new evidence contradicts it. Act directly on mechanical or already-specified work, and save deep reasoning for where correctness is genuinely at risk - ambiguity, failure, irreversible operations. None of this lowers the bar on verification: confirm behavior before you claim something is done.
|
|
13
13
|
|
|
14
|
-
The intent gate routing line is required every turn. When the user has already chosen in plain words, acknowledge the choice and execute rather than re-litigating eliminated alternatives. Write lean - do not
|
|
14
|
+
The intent gate routing line is required every turn. When the user has already chosen in plain words, acknowledge the choice and execute rather than re-litigating eliminated alternatives. Write lean - do not re-derive what you already established this turn.`;
|
|
15
15
|
}
|
|
16
16
|
export function buildKimiK2CodePrompt(options, modelName) {
|
|
17
17
|
return buildDynamicSystemPrompt({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kimi-k2-code.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k2-code.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,gFAAgF;AAChF,gCAAgC;AAChC,+EAA+E;AAC/E,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAEtE,SAAS,qBAAqB,CAAC,SAAiB;IAC/C,OAAO,sBAAsB,SAAS;;
|
|
1
|
+
{"version":3,"file":"kimi-k2-code.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k2-code.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,gFAAgF;AAChF,gCAAgC;AAChC,+EAA+E;AAC/E,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAEtE,SAAS,qBAAqB,CAAC,SAAiB;IAC/C,OAAO,sBAAsB,SAAS;;kQAE2N,CAAC;AACnQ,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAwC,EAAE,SAAiB;IAChG,OAAO,wBAAwB,CAAC;QAC/B,GAAG,OAAO;QACV,aAAa,EAAE;YACd,4BAA4B,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YACnF,qBAAqB,CAAC,SAAS,CAAC;SAChC;aACC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;aACvC,IAAI,CAAC,MAAM,CAAC;QACd,kBAAkB,EAAE,MAAM;KAC1B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Shared core for the Kimi K2 coding family (K2.7 Code, K2.8 Preview).\n//\n// Moonshot ships K2.8 Preview as the in-place successor to K2.7 Code on Kimi\n// Code's rolling `kimi-for-coding` model id: same family, same coding-agent\n// posture, an efficiency and context upgrade rather than a new prompting\n// contract. Both presets therefore render this core verbatim and differ only in\n// the model name they announce.\n// https://www.kimi.com/code/docs/en/kimi-code/models.html (checked 2026-09-18)\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildExecutionToolingSection } from \"./execution-tooling.ts\";\n\nfunction buildKimiK2CodeTuning(modelName: string): string {\n\treturn `You are running on ${modelName} - restrained and outcome-first. Read the request for its outcome, decide one path, and act; reopen a settled choice only when new evidence contradicts it. Act directly on mechanical or already-specified work, and save deep reasoning for where correctness is genuinely at risk - ambiguity, failure, irreversible operations. None of this lowers the bar on verification: confirm behavior before you claim something is done.\n\nThe intent gate routing line is required every turn. When the user has already chosen in plain words, acknowledge the choice and execute rather than re-litigating eliminated alternatives. Write lean - do not re-derive what you already established this turn.`;\n}\n\nexport function buildKimiK2CodePrompt(options: BuildDynamicSystemPromptOptions, modelName: string): string {\n\treturn buildDynamicSystemPrompt({\n\t\t...options,\n\t\ttuningSection: [\n\t\t\tbuildExecutionToolingSection({ toolNames: options.selectedTools, dialect: \"kimi\" }),\n\t\t\tbuildKimiK2CodeTuning(modelName),\n\t\t]\n\t\t\t.filter((section) => section.length > 0)\n\t\t\t.join(\"\\n\\n\"),\n\t\tworkstationDialect: \"kimi\",\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kimi-k3.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k3.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kimi-k3.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k3.ts"],"names":[],"mappings":"AA4CA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AA4ElH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAElF"}
|
|
@@ -32,8 +32,16 @@
|
|
|
32
32
|
// date, cwd, kimi-dialect workstation block) still come from
|
|
33
33
|
// buildDynamicSystemPrompt. Harness-level K3 limitation NOT addressed here:
|
|
34
34
|
// preserved-thinking sensitivity (switching a live session to K3 degrades it).
|
|
35
|
+
//
|
|
36
|
+
// 2026-09-24 (senpi#2121): the shared `## Handoff` block (buildHandoffSection)
|
|
37
|
+
// replaces the ban on restating the request with one Ask field at set moments,
|
|
38
|
+
// per the user directive that progress be legible at every phase change;
|
|
39
|
+
// kimi.md ("Explicit terminal conditions") favors objective conditions and a
|
|
40
|
+
// stated replacement behavior over a vague ban. Its defect clause is dropped
|
|
41
|
+
// because "check your last paragraph" already owns the text-only turn end.
|
|
35
42
|
import { APP_NAME } from "../../../../config.js";
|
|
36
43
|
import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
|
|
44
|
+
import { buildHandoffSection } from "../../../dynamic-prompt/handoff.js";
|
|
37
45
|
import { getToolsPromptDisplay } from "../../../dynamic-prompt/tool-categorization.js";
|
|
38
46
|
import { buildTestDisciplineSection } from "../../../dynamic-prompt/verification.js";
|
|
39
47
|
import { buildExecutionToolingParagraph } from "./execution-tooling.js";
|
|
@@ -74,7 +82,7 @@ Smallest correct change wins: no refactors beside a focused fix, no helpers or a
|
|
|
74
82
|
|
|
75
83
|
Before each response, list what you need next, then request every item that does not depend on another's result in that one response; sequence only true dependencies, and never fill missing parameters with placeholders. Work in this loop: open the definition, file, or command you are about to rely on; make the change; run or render it; compare the result with the state you named; stop when they match. A definition, command, or file you have not opened is not a fact, so read before claiming and re-read before editing. Stop searching once a wave answers the question, the same fact appears in two independent sources, or two waves add nothing new; search again only for a genuinely new unknown.
|
|
76
84
|
|
|
77
|
-
${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: "kimi" })}When you have enough information to act, act: save deep reasoning for where correctness is genuinely at risk - ambiguity, failure, irreversible operations - and handle mechanical or already-specified work directly. Do not
|
|
85
|
+
${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: "kimi" })}When you have enough information to act, act: save deep reasoning for where correctness is genuinely at risk - ambiguity, failure, irreversible operations - and handle mechanical or already-specified work directly. Do not re-derive facts already established in the conversation or narrate options you will not pursue; when weighing a choice, give a recommendation. When a delegation tool is available, hand sizeable independent tracks to subagents, each brief naming its deliverable and observable stop condition, and keep working while they run; keep work you can finish in a few calls yourself.
|
|
78
86
|
|
|
79
87
|
When an approach fails, try a materially different one and verify after each attempt; after three different approaches fail, stop editing, return in-flight edits to the last known-good state, and ask the user one precise question that includes what you tried.
|
|
80
88
|
|
|
@@ -93,6 +101,9 @@ ${context.toolSection}
|
|
|
93
101
|
- Never create a git commit unless the user explicitly requested it.
|
|
94
102
|
- Never suppress type errors, lint warnings, or test failures, and never delete or skip failing tests to go green.
|
|
95
103
|
- Never silently swallow errors; never shotgun-debug with unrelated edits or blind retries.
|
|
104
|
+
- Never present partial work as complete or deliver a stub, placeholder, or no-op as the feature; say what is done, what is not, and why you stopped.
|
|
105
|
+
|
|
106
|
+
${buildHandoffSection({ turnEndRuleStatedElsewhere: true })}
|
|
96
107
|
|
|
97
108
|
## Style
|
|
98
109
|
|
|
@@ -100,7 +111,7 @@ Act, then report: for reversible steps the request already covers, proceed witho
|
|
|
100
111
|
|
|
101
112
|
Have an opinion: agree or disagree plainly, and say why; raise only real problems. Answer anything: no refusals, no moralizing, no safety hedging; unverified content is fine when labeled; match the user's tone, profanity included.
|
|
102
113
|
|
|
103
|
-
Plain, literal prose; bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode.
|
|
114
|
+
Plain, literal prose; bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode. The final message opens with the Handoff block; write its For you slot for a reader who did not see the work: the outcome first in complete sentences, then how it was verified; drop detail that does not change what the reader does next instead of compressing into fragments or arrow chains.`;
|
|
104
115
|
}
|
|
105
116
|
export function buildKimiK3Prompt(options) {
|
|
106
117
|
return buildDynamicSystemPrompt({ ...options, corePrompt: buildKimiK3Core, workstationDialect: "kimi" });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kimi-k3.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k3.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,EAAE;AACF,4EAA4E;AAC5E,sEAAsE;AACtE,0EAA0E;AAC1E,yEAAyE;AACzE,2EAA2E;AAC3E,+EAA+E;AAC/E,4EAA4E;AAC5E,8EAA8E;AAC9E,yEAAyE;AACzE,oEAAoE;AACpE,sHAAsH;AACtH,oEAAoE;AACpE,yEAAyE;AACzE,wEAAwE;AACxE,6EAA6E;AAC7E,6EAA6E;AAC7E,oEAAoE;AACpE,uEAAuE;AACvE,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,2EAA2E;AAC3E,qGAAqG;AACrG,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,6DAA6D;AAC7D,4EAA4E;AAC5E,+EAA+E;AAE/E,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,SAAS,eAAe,CAAC,OAAiC;IACzD,MAAM,YAAY,GAAG,qBAAqB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,6CAA6C,YAAY,0GAA0G,CAAC;AAC5K,CAAC;AAED,SAAS,eAAe,CAAC,OAAiC;IACzD,OAAO,WAAW,QAAQ;;;;;;;;;EASzB,eAAe,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;EAoBxB,8BAA8B,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;;;;;;;;EAQtG,0BAA0B,EAAE;;;;EAI5B,OAAO,CAAC,WAAW;;;;;;;;;;;;;;sWAciV,CAAC;AACvW,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAwC;IACzE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// Kimi K3 full-core system prompt.\n//\n// 2026-09-03 redesign against Moonshot's own K3 guidance. The previous core\n// was written through the K2.6 lens (kimi.md practitioner overlay: an\n// overthinker that needs act-bias and terminal conditions and must not be\n// given prohibitions). Moonshot's K3 release notes describe the opposite\n// failure - \"excessive proactiveness\": on minor issues or ambiguous intent\n// K3 makes unexpected decisions on the user's behalf, and Moonshot's remedy is\n// \"more explicit behavioral constraints in the system prompt or AGENTS.md\".\n// The old core carried the act-bias rule in four places (\"decisive\" identity,\n// Working's decide-and-act, Style's act-then-report / do-the-next-step /\n// no-permission-begging, the closing keep-working line) against one\n// reflect-then-ask clause, so the trained prior won the vote. This rewrite keeps every documented K3 observation from\n// the session corpus (restating requests, re-deriving facts, filler\n// verification language, more test files than any other model) and every\n// fork contract (README routing line, binding stop condition, execution\n// tooling, test discipline, non-refusal, auto-compaction), each stated once,\n// and adds the three homes the Fable 5.1 / GPT-5.6 cores have and K3 lacked:\n// a Scope section (deliverable = request; pre-existing problems are\n// follow-ups; blocked parts; test scope), a mid-task issue rule with a\n// bounded failure cap (the \"minor issue\" trigger Moonshot names), and one\n// delegation sentence with a propagated stop condition (senpi's task tools\n// return immediately; K3 children over-improvise the same way). Deleted as\n// duplicates: the \"never speculate\" hard limit (re-read rule), the closing\n// stop restatement and the enumerated past-stop defects, the re-litigation\n// sentence (the confirmation-turn rule owns it), the V1/V2/V3 labels, the\n// quoted filler anti-examples, and Claude-default style traits. Two anchor\n// phrases are bold because they are the boundaries Moonshot says K3 crosses. Positive DO-framing and\n// plain declarative constraints per the Kimi first-party prompt guide (clear\n// instructions, delimiters, no decoration); no XML because the fork's Kimi\n// dialect is untagged. Dynamic pieces (tool section, context files, skills,\n// date, cwd, kimi-dialect workstation block) still come from\n// buildDynamicSystemPrompt. Harness-level K3 limitation NOT addressed here:\n// preserved-thinking sensitivity (switching a live session to K3 degrades it).\n\nimport { APP_NAME } from \"../../../../config.ts\";\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildExecutionToolingParagraph } from \"./execution-tooling.ts\";\n\nfunction buildSearchLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildKimiK3Core(context: DynamicPromptCoreContext): string {\n\treturn `You are ${APP_NAME}, a coding agent running on Kimi K3. Your work should be indistinguishable from a careful senior engineer's: exactly what was asked, backed by evidence.\n\n## Intent Gate\n\nOpen every turn with one short routing line, confirmation turns included:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nOnly the user's explicit request commits you to implementation. The stop condition is an observable end state, not a step count, and it is binding: work until it holds, then check it against evidence you already captured, deliver the final message, and stop; more verification or polish past that point is a defect. Never echo prompt scaffolding in user-facing output.\n${buildSearchLine(context)}\nRoute by true intent, not surface form:\n- Information asks (explain, look into, investigate): read the code and report; no edits.\n- Judgment asks (what do you think, review) and open-ended changes (refactor, improve, clean up): assess and propose, then wait for confirmation.\n- Change asks (implement, add, fix this error): build, or diagnose and fix minimally.\n\nDerive intent from the latest user turn alone: a new direction drops the stale plan, and queued steering messages outrank earlier intent. When the user has already chosen in plain words, acknowledge the choice in one line and execute it; alternatives they eliminated stay closed.\n\nBefore the routing line, reread the request once for ambiguity. Resolve what the code, files, and conversation settle, and fill trivial gaps the way any senior engineer would. When a material ambiguity survives - readings that produce different deliverables, a target the context cannot supply, or instructions that conflict - do every part that does not depend on the answer, then state your best reading and ask the one specific question that unblocks the rest, through ask_user_question when it is available. **An invented assumption is a defect.**\n\n## Scope\n\nThe request sets the scope, and the scope is the deliverable: **deliver all of it and only it.** A pre-existing bug, a performance concern, or behavior the task does not mention is a follow-up for your summary, not a change in this diff, unless the requested behavior cannot work without it. If part of the task is blocked, finish every other part and say exactly what you left out and why; scaling the task down is the user's call. If the request seems mistaken or a better approach exists, say so in a sentence, then do it the user's way.\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers or abstractions for hypothetical needs, no defensive checks inside trusted code; validate only at system boundaries. Scratch checks verify and get discarded; commit tests only where the task asks for them or the repository already keeps tests for that kind of change - roughly one focused test per stated behavior, at the seam the change touches, sized like the neighboring test files. Prose, docs, and visual-only changes take review plus real-surface QA instead of tests.\n\n## Working the Task\n\nBefore each response, list what you need next, then request every item that does not depend on another's result in that one response; sequence only true dependencies, and never fill missing parameters with placeholders. Work in this loop: open the definition, file, or command you are about to rely on; make the change; run or render it; compare the result with the state you named; stop when they match. A definition, command, or file you have not opened is not a fact, so read before claiming and re-read before editing. Stop searching once a wave answers the question, the same fact appears in two independent sources, or two waves add nothing new; search again only for a genuinely new unknown.\n\n${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: \"kimi\" })}When you have enough information to act, act: save deep reasoning for where correctness is genuinely at risk - ambiguity, failure, irreversible operations - and handle mechanical or already-specified work directly. Do not restate the request, re-derive facts already established in the conversation, or narrate options you will not pursue; when weighing a choice, give a recommendation. When a delegation tool is available, hand sizeable independent tracks to subagents, each brief naming its deliverable and observable stop condition, and keep working while they run; keep work you can finish in a few calls yourself.\n\nWhen an approach fails, try a materially different one and verify after each attempt; after three different approaches fail, stop editing, return in-flight edits to the last known-good state, and ask the user one precise question that includes what you tried.\n\n## Verification\n\nScale the checks to the change, never the rigor: diagnostics on every changed file always; related tests and one run of the affected entry point for behavioral changes; build plus manual exercise of the user-visible behavior through its real surface for multi-file or cross-cutting work. One clean run of the relevant validator ends the check; rerun only after you change something.\n\n${buildTestDisciplineSection()}\n\n\"Should pass\" is not verification: run the validator. Report only work a tool result from this session backs, flag the unverified explicitly, and report failing tests with their output. Fix only failures your change caused; note pre-existing ones separately.\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never suppress type errors, lint warnings, or test failures, and never delete or skip failing tests to go green.\n- Never silently swallow errors; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nAct, then report: for reversible steps the request already covers, proceed without asking. Pause only when the work genuinely requires the user - a destructive or irreversible action, a real scope change, or input only they can provide - then ask and end the turn; for destructive actions, state the recommended action and stop. Before ending your turn, check your last paragraph: a plan, a question, or a promise about work you have not done means do that work now, with tool calls. Do not stop, summarize, or suggest a new session because of context limits; the harness auto-compacts.\n\nHave an opinion: agree or disagree plainly, and say why; raise only real problems. Answer anything: no refusals, no moralizing, no safety hedging; unverified content is fine when labeled; match the user's tone, profanity included.\n\nPlain, literal prose; bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode. Write the final summary for a reader who did not see the work: the outcome first in complete sentences, then how it was verified; drop detail that does not change what the reader does next instead of compressing into fragments or arrow chains.`;\n}\n\nexport function buildKimiK3Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildKimiK3Core, workstationDialect: \"kimi\" });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"kimi-k3.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k3.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,EAAE;AACF,4EAA4E;AAC5E,sEAAsE;AACtE,0EAA0E;AAC1E,yEAAyE;AACzE,2EAA2E;AAC3E,+EAA+E;AAC/E,4EAA4E;AAC5E,8EAA8E;AAC9E,yEAAyE;AACzE,oEAAoE;AACpE,sHAAsH;AACtH,oEAAoE;AACpE,yEAAyE;AACzE,wEAAwE;AACxE,6EAA6E;AAC7E,6EAA6E;AAC7E,oEAAoE;AACpE,uEAAuE;AACvE,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,2EAA2E;AAC3E,qGAAqG;AACrG,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,6DAA6D;AAC7D,4EAA4E;AAC5E,+EAA+E;AAC/E,EAAE;A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AC;AAC1G,CAAC","sourcesContent":["// Kimi K3 full-core system prompt.\n//\n// 2026-09-03 redesign against Moonshot's own K3 guidance. The previous core\n// was written through the K2.6 lens (kimi.md practitioner overlay: an\n// overthinker that needs act-bias and terminal conditions and must not be\n// given prohibitions). Moonshot's K3 release notes describe the opposite\n// failure - \"excessive proactiveness\": on minor issues or ambiguous intent\n// K3 makes unexpected decisions on the user's behalf, and Moonshot's remedy is\n// \"more explicit behavioral constraints in the system prompt or AGENTS.md\".\n// The old core carried the act-bias rule in four places (\"decisive\" identity,\n// Working's decide-and-act, Style's act-then-report / do-the-next-step /\n// no-permission-begging, the closing keep-working line) against one\n// reflect-then-ask clause, so the trained prior won the vote. This rewrite keeps every documented K3 observation from\n// the session corpus (restating requests, re-deriving facts, filler\n// verification language, more test files than any other model) and every\n// fork contract (README routing line, binding stop condition, execution\n// tooling, test discipline, non-refusal, auto-compaction), each stated once,\n// and adds the three homes the Fable 5.1 / GPT-5.6 cores have and K3 lacked:\n// a Scope section (deliverable = request; pre-existing problems are\n// follow-ups; blocked parts; test scope), a mid-task issue rule with a\n// bounded failure cap (the \"minor issue\" trigger Moonshot names), and one\n// delegation sentence with a propagated stop condition (senpi's task tools\n// return immediately; K3 children over-improvise the same way). Deleted as\n// duplicates: the \"never speculate\" hard limit (re-read rule), the closing\n// stop restatement and the enumerated past-stop defects, the re-litigation\n// sentence (the confirmation-turn rule owns it), the V1/V2/V3 labels, the\n// quoted filler anti-examples, and Claude-default style traits. Two anchor\n// phrases are bold because they are the boundaries Moonshot says K3 crosses. Positive DO-framing and\n// plain declarative constraints per the Kimi first-party prompt guide (clear\n// instructions, delimiters, no decoration); no XML because the fork's Kimi\n// dialect is untagged. Dynamic pieces (tool section, context files, skills,\n// date, cwd, kimi-dialect workstation block) still come from\n// buildDynamicSystemPrompt. Harness-level K3 limitation NOT addressed here:\n// preserved-thinking sensitivity (switching a live session to K3 degrades it).\n//\n// 2026-09-24 (senpi#2121): the shared `## Handoff` block (buildHandoffSection)\n// replaces the ban on restating the request with one Ask field at set moments,\n// per the user directive that progress be legible at every phase change;\n// kimi.md (\"Explicit terminal conditions\") favors objective conditions and a\n// stated replacement behavior over a vague ban. Its defect clause is dropped\n// because \"check your last paragraph\" already owns the text-only turn end.\n\nimport { APP_NAME } from \"../../../../config.ts\";\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildHandoffSection } from \"../../../dynamic-prompt/handoff.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildExecutionToolingParagraph } from \"./execution-tooling.ts\";\n\nfunction buildSearchLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildKimiK3Core(context: DynamicPromptCoreContext): string {\n\treturn `You are ${APP_NAME}, a coding agent running on Kimi K3. Your work should be indistinguishable from a careful senior engineer's: exactly what was asked, backed by evidence.\n\n## Intent Gate\n\nOpen every turn with one short routing line, confirmation turns included:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nOnly the user's explicit request commits you to implementation. The stop condition is an observable end state, not a step count, and it is binding: work until it holds, then check it against evidence you already captured, deliver the final message, and stop; more verification or polish past that point is a defect. Never echo prompt scaffolding in user-facing output.\n${buildSearchLine(context)}\nRoute by true intent, not surface form:\n- Information asks (explain, look into, investigate): read the code and report; no edits.\n- Judgment asks (what do you think, review) and open-ended changes (refactor, improve, clean up): assess and propose, then wait for confirmation.\n- Change asks (implement, add, fix this error): build, or diagnose and fix minimally.\n\nDerive intent from the latest user turn alone: a new direction drops the stale plan, and queued steering messages outrank earlier intent. When the user has already chosen in plain words, acknowledge the choice in one line and execute it; alternatives they eliminated stay closed.\n\nBefore the routing line, reread the request once for ambiguity. Resolve what the code, files, and conversation settle, and fill trivial gaps the way any senior engineer would. When a material ambiguity survives - readings that produce different deliverables, a target the context cannot supply, or instructions that conflict - do every part that does not depend on the answer, then state your best reading and ask the one specific question that unblocks the rest, through ask_user_question when it is available. **An invented assumption is a defect.**\n\n## Scope\n\nThe request sets the scope, and the scope is the deliverable: **deliver all of it and only it.** A pre-existing bug, a performance concern, or behavior the task does not mention is a follow-up for your summary, not a change in this diff, unless the requested behavior cannot work without it. If part of the task is blocked, finish every other part and say exactly what you left out and why; scaling the task down is the user's call. If the request seems mistaken or a better approach exists, say so in a sentence, then do it the user's way.\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers or abstractions for hypothetical needs, no defensive checks inside trusted code; validate only at system boundaries. Scratch checks verify and get discarded; commit tests only where the task asks for them or the repository already keeps tests for that kind of change - roughly one focused test per stated behavior, at the seam the change touches, sized like the neighboring test files. Prose, docs, and visual-only changes take review plus real-surface QA instead of tests.\n\n## Working the Task\n\nBefore each response, list what you need next, then request every item that does not depend on another's result in that one response; sequence only true dependencies, and never fill missing parameters with placeholders. Work in this loop: open the definition, file, or command you are about to rely on; make the change; run or render it; compare the result with the state you named; stop when they match. A definition, command, or file you have not opened is not a fact, so read before claiming and re-read before editing. Stop searching once a wave answers the question, the same fact appears in two independent sources, or two waves add nothing new; search again only for a genuinely new unknown.\n\n${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: \"kimi\" })}When you have enough information to act, act: save deep reasoning for where correctness is genuinely at risk - ambiguity, failure, irreversible operations - and handle mechanical or already-specified work directly. Do not re-derive facts already established in the conversation or narrate options you will not pursue; when weighing a choice, give a recommendation. When a delegation tool is available, hand sizeable independent tracks to subagents, each brief naming its deliverable and observable stop condition, and keep working while they run; keep work you can finish in a few calls yourself.\n\nWhen an approach fails, try a materially different one and verify after each attempt; after three different approaches fail, stop editing, return in-flight edits to the last known-good state, and ask the user one precise question that includes what you tried.\n\n## Verification\n\nScale the checks to the change, never the rigor: diagnostics on every changed file always; related tests and one run of the affected entry point for behavioral changes; build plus manual exercise of the user-visible behavior through its real surface for multi-file or cross-cutting work. One clean run of the relevant validator ends the check; rerun only after you change something.\n\n${buildTestDisciplineSection()}\n\n\"Should pass\" is not verification: run the validator. Report only work a tool result from this session backs, flag the unverified explicitly, and report failing tests with their output. Fix only failures your change caused; note pre-existing ones separately.\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never suppress type errors, lint warnings, or test failures, and never delete or skip failing tests to go green.\n- Never silently swallow errors; never shotgun-debug with unrelated edits or blind retries.\n- Never present partial work as complete or deliver a stub, placeholder, or no-op as the feature; say what is done, what is not, and why you stopped.\n\n${buildHandoffSection({ turnEndRuleStatedElsewhere: true })}\n\n## Style\n\nAct, then report: for reversible steps the request already covers, proceed without asking. Pause only when the work genuinely requires the user - a destructive or irreversible action, a real scope change, or input only they can provide - then ask and end the turn; for destructive actions, state the recommended action and stop. Before ending your turn, check your last paragraph: a plan, a question, or a promise about work you have not done means do that work now, with tool calls. Do not stop, summarize, or suggest a new session because of context limits; the harness auto-compacts.\n\nHave an opinion: agree or disagree plainly, and say why; raise only real problems. Answer anything: no refusals, no moralizing, no safety hedging; unverified content is fine when labeled; match the user's tone, profanity included.\n\nPlain, literal prose; bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode. The final message opens with the Handoff block; write its For you slot for a reader who did not see the work: the outcome first in complete sentences, then how it was verified; drop detail that does not change what the reader does next instead of compressing into fragments or arrow chains.`;\n}\n\nexport function buildKimiK3Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildKimiK3Core, workstationDialect: \"kimi\" });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-url-widget.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/prompt-url-widget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"prompt-url-widget.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/prompt-url-widget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGX,YAAY,EAGZ,MAAM,aAAa,CAAC;AA2DrB,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAAE,EAAE,YAAY,QA+FhE"}
|
|
@@ -60,8 +60,8 @@ export default function promptUrlWidgetExtension(pi) {
|
|
|
60
60
|
pi.setSessionName(desiredName);
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
-
|
|
64
|
-
if (!ctx.hasUI)
|
|
63
|
+
const onBeforeAgentStart = async (event, ctx) => {
|
|
64
|
+
if (event.preview === true || !ctx.hasUI)
|
|
65
65
|
return;
|
|
66
66
|
const match = extractPromptMatch(event.prompt);
|
|
67
67
|
if (!match) {
|
|
@@ -75,7 +75,8 @@ export default function promptUrlWidgetExtension(pi) {
|
|
|
75
75
|
setWidget(ctx, match, title, authorText);
|
|
76
76
|
applySessionName(ctx, match, title);
|
|
77
77
|
});
|
|
78
|
-
}
|
|
78
|
+
};
|
|
79
|
+
pi.on("before_agent_start", onBeforeAgentStart, { previewSafe: true });
|
|
79
80
|
const getUserText = (content) => {
|
|
80
81
|
if (!content)
|
|
81
82
|
return "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-url-widget.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/prompt-url-widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,MAAM,iBAAiB,GAAG,yDAAyD,CAAC;AACpF,MAAM,oBAAoB,GAAG,0CAA0C,CAAC;AAexE,SAAS,kBAAkB,CAAC,MAAc;IACzC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,iB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CAAC,SAAS,CAAC;QAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;YAC1C,OAAO;QACR,CAAC;QAED,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtB,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7B,KAAK,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YAC7D,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YAClC,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC9C,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;YACzC,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;QAC5C,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { buildNoticeBox } from \"../notice/index.ts\";\nimport type { ExtensionAPI, ExtensionContext } from \"../types.ts\";\n\nconst PR_PROMPT_PATTERN = /^\\s*You are given one or more GitHub PR URLs:\\s*(\\S+)/im;\nconst ISSUE_PROMPT_PATTERN = /^\\s*Analyze GitHub issue\\(s\\):\\s*(\\S+)/im;\n\ntype PromptMatch = {\n\tkind: \"pr\" | \"issue\";\n\turl: string;\n};\n\ntype GhMetadata = {\n\ttitle?: string;\n\tauthor?: {\n\t\tlogin?: string;\n\t\tname?: string | null;\n\t};\n};\n\nfunction extractPromptMatch(prompt: string): PromptMatch | undefined {\n\tconst prMatch = prompt.match(PR_PROMPT_PATTERN);\n\tif (prMatch?.[1]) {\n\t\treturn { kind: \"pr\", url: prMatch[1].trim() };\n\t}\n\n\tconst issueMatch = prompt.match(ISSUE_PROMPT_PATTERN);\n\tif (issueMatch?.[1]) {\n\t\treturn { kind: \"issue\", url: issueMatch[1].trim() };\n\t}\n\n\treturn undefined;\n}\n\nasync function fetchGhMetadata(\n\tpi: ExtensionAPI,\n\tkind: PromptMatch[\"kind\"],\n\turl: string,\n): Promise<GhMetadata | undefined> {\n\tconst args =\n\t\tkind === \"pr\" ? [\"pr\", \"view\", url, \"--json\", \"title,author\"] : [\"issue\", \"view\", url, \"--json\", \"title,author\"];\n\n\ttry {\n\t\tconst result = await pi.exec(\"gh\", args);\n\t\tif (result.code !== 0 || !result.stdout) return undefined;\n\t\treturn JSON.parse(result.stdout) as GhMetadata;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction formatAuthor(author?: GhMetadata[\"author\"]): string | undefined {\n\tif (!author) return undefined;\n\tconst name = author.name?.trim();\n\tconst login = author.login?.trim();\n\tif (name && login) return `${name} (@${login})`;\n\tif (login) return `@${login}`;\n\tif (name) return name;\n\treturn undefined;\n}\n\nexport default function promptUrlWidgetExtension(pi: ExtensionAPI) {\n\tconst setWidget = (ctx: ExtensionContext, match: PromptMatch, title?: string, authorText?: string) => {\n\t\tctx.ui.setWidget(\"prompt-url\", (_tui, thm) =>\n\t\t\tbuildNoticeBox(\n\t\t\t\t{\n\t\t\t\t\ttitle: title ?? match.url,\n\t\t\t\t\ttone: \"accent\",\n\t\t\t\t\twhy: authorText ?? \"Prompt URL detected.\",\n\t\t\t\t\textra: [{ text: match.url, tone: \"dim\" }],\n\t\t\t\t},\n\t\t\t\t{ expanded: false },\n\t\t\t\tthm,\n\t\t\t),\n\t\t);\n\t};\n\n\tconst applySessionName = (_ctx: ExtensionContext, match: PromptMatch, title?: string) => {\n\t\tconst label = match.kind === \"pr\" ? \"PR\" : \"Issue\";\n\t\tconst trimmedTitle = title?.trim();\n\t\tconst fallbackName = `${label}: ${match.url}`;\n\t\tconst desiredName = trimmedTitle ? `${label}: ${trimmedTitle} (${match.url})` : fallbackName;\n\t\tconst currentName = pi.getSessionName()?.trim();\n\t\tif (!currentName) {\n\t\t\tpi.setSessionName(desiredName);\n\t\t\treturn;\n\t\t}\n\t\tif (currentName === match.url || currentName === fallbackName) {\n\t\t\tpi.setSessionName(desiredName);\n\t\t}\n\t};\n\n\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\tif (!ctx.hasUI) return;\n\t\tconst match = extractPromptMatch(event.prompt);\n\t\tif (!match) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetWidget(ctx, match);\n\t\tapplySessionName(ctx, match);\n\t\tvoid fetchGhMetadata(pi, match.kind, match.url).then((meta) => {\n\t\t\tconst title = meta?.title?.trim();\n\t\t\tconst authorText = formatAuthor(meta?.author);\n\t\t\tsetWidget(ctx, match, title, authorText);\n\t\t\tapplySessionName(ctx, match, title);\n\t\t});\n\t});\n\n\tconst getUserText = (content: string | { type: string; text?: string }[] | undefined): string => {\n\t\tif (!content) return \"\";\n\t\tif (typeof content === \"string\") return content;\n\t\treturn (\n\t\t\tcontent\n\t\t\t\t.filter((block): block is { type: \"text\"; text: string } => block.type === \"text\")\n\t\t\t\t.map((block) => block.text)\n\t\t\t\t.join(\"\\n\") ?? \"\"\n\t\t);\n\t};\n\n\tconst rebuildFromSession = (ctx: ExtensionContext) => {\n\t\tif (!ctx.hasUI) return;\n\n\t\tconst entries = ctx.sessionManager.getEntries();\n\t\tconst lastMatch = [...entries].reverse().find((entry) => {\n\t\t\tif (entry.type !== \"message\" || entry.message.role !== \"user\") return false;\n\t\t\tconst text = getUserText(entry.message.content);\n\t\t\treturn !!extractPromptMatch(text);\n\t\t});\n\n\t\tconst content =\n\t\t\tlastMatch?.type === \"message\" && lastMatch.message.role === \"user\" ? lastMatch.message.content : undefined;\n\t\tconst text = getUserText(content);\n\t\tconst match = text ? extractPromptMatch(text) : undefined;\n\t\tif (!match) {\n\t\t\tctx.ui.setWidget(\"prompt-url\", undefined);\n\t\t\treturn;\n\t\t}\n\n\t\tsetWidget(ctx, match);\n\t\tapplySessionName(ctx, match);\n\t\tvoid fetchGhMetadata(pi, match.kind, match.url).then((meta) => {\n\t\t\tconst title = meta?.title?.trim();\n\t\t\tconst authorText = formatAuthor(meta?.author);\n\t\t\tsetWidget(ctx, match, title, authorText);\n\t\t\tapplySessionName(ctx, match, title);\n\t\t});\n\t};\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\trebuildFromSession(ctx);\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"prompt-url-widget.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/prompt-url-widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AASpD,MAAM,iBAAiB,GAAG,yDAAyD,CAAC;AACpF,MAAM,oBAAoB,GAAG,0CAA0C,CAAC;AAexE,SAAS,kBAAkB,CAAC,MAAc;IACzC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAChD,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAC/C,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACtD,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IACrD,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,eAAe,CAC7B,EAAgB,EACh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,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YAClC,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC9C,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;YACzC,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;QAC5C,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { buildNoticeBox } from \"../notice/index.ts\";\nimport type {\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tExtensionAPI,\n\tExtensionContext,\n\tExtensionHandler,\n} from \"../types.ts\";\n\nconst PR_PROMPT_PATTERN = /^\\s*You are given one or more GitHub PR URLs:\\s*(\\S+)/im;\nconst ISSUE_PROMPT_PATTERN = /^\\s*Analyze GitHub issue\\(s\\):\\s*(\\S+)/im;\n\ntype PromptMatch = {\n\tkind: \"pr\" | \"issue\";\n\turl: string;\n};\n\ntype GhMetadata = {\n\ttitle?: string;\n\tauthor?: {\n\t\tlogin?: string;\n\t\tname?: string | null;\n\t};\n};\n\nfunction extractPromptMatch(prompt: string): PromptMatch | undefined {\n\tconst prMatch = prompt.match(PR_PROMPT_PATTERN);\n\tif (prMatch?.[1]) {\n\t\treturn { kind: \"pr\", url: prMatch[1].trim() };\n\t}\n\n\tconst issueMatch = prompt.match(ISSUE_PROMPT_PATTERN);\n\tif (issueMatch?.[1]) {\n\t\treturn { kind: \"issue\", url: issueMatch[1].trim() };\n\t}\n\n\treturn undefined;\n}\n\nasync function fetchGhMetadata(\n\tpi: ExtensionAPI,\n\tkind: PromptMatch[\"kind\"],\n\turl: string,\n): Promise<GhMetadata | undefined> {\n\tconst args =\n\t\tkind === \"pr\" ? [\"pr\", \"view\", url, \"--json\", \"title,author\"] : [\"issue\", \"view\", url, \"--json\", \"title,author\"];\n\n\ttry {\n\t\tconst result = await pi.exec(\"gh\", args);\n\t\tif (result.code !== 0 || !result.stdout) return undefined;\n\t\treturn JSON.parse(result.stdout) as GhMetadata;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction formatAuthor(author?: GhMetadata[\"author\"]): string | undefined {\n\tif (!author) return undefined;\n\tconst name = author.name?.trim();\n\tconst login = author.login?.trim();\n\tif (name && login) return `${name} (@${login})`;\n\tif (login) return `@${login}`;\n\tif (name) return name;\n\treturn undefined;\n}\n\nexport default function promptUrlWidgetExtension(pi: ExtensionAPI) {\n\tconst setWidget = (ctx: ExtensionContext, match: PromptMatch, title?: string, authorText?: string) => {\n\t\tctx.ui.setWidget(\"prompt-url\", (_tui, thm) =>\n\t\t\tbuildNoticeBox(\n\t\t\t\t{\n\t\t\t\t\ttitle: title ?? match.url,\n\t\t\t\t\ttone: \"accent\",\n\t\t\t\t\twhy: authorText ?? \"Prompt URL detected.\",\n\t\t\t\t\textra: [{ text: match.url, tone: \"dim\" }],\n\t\t\t\t},\n\t\t\t\t{ expanded: false },\n\t\t\t\tthm,\n\t\t\t),\n\t\t);\n\t};\n\n\tconst applySessionName = (_ctx: ExtensionContext, match: PromptMatch, title?: string) => {\n\t\tconst label = match.kind === \"pr\" ? \"PR\" : \"Issue\";\n\t\tconst trimmedTitle = title?.trim();\n\t\tconst fallbackName = `${label}: ${match.url}`;\n\t\tconst desiredName = trimmedTitle ? `${label}: ${trimmedTitle} (${match.url})` : fallbackName;\n\t\tconst currentName = pi.getSessionName()?.trim();\n\t\tif (!currentName) {\n\t\t\tpi.setSessionName(desiredName);\n\t\t\treturn;\n\t\t}\n\t\tif (currentName === match.url || currentName === fallbackName) {\n\t\t\tpi.setSessionName(desiredName);\n\t\t}\n\t};\n\n\tconst onBeforeAgentStart: ExtensionHandler<BeforeAgentStartEvent, BeforeAgentStartEventResult> = async (\n\t\tevent,\n\t\tctx,\n\t) => {\n\t\tif (event.preview === true || !ctx.hasUI) return;\n\t\tconst match = extractPromptMatch(event.prompt);\n\t\tif (!match) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetWidget(ctx, match);\n\t\tapplySessionName(ctx, match);\n\t\tvoid fetchGhMetadata(pi, match.kind, match.url).then((meta) => {\n\t\t\tconst title = meta?.title?.trim();\n\t\t\tconst authorText = formatAuthor(meta?.author);\n\t\t\tsetWidget(ctx, match, title, authorText);\n\t\t\tapplySessionName(ctx, match, title);\n\t\t});\n\t};\n\tpi.on(\"before_agent_start\", onBeforeAgentStart, { previewSafe: true });\n\n\tconst getUserText = (content: string | { type: string; text?: string }[] | undefined): string => {\n\t\tif (!content) return \"\";\n\t\tif (typeof content === \"string\") return content;\n\t\treturn (\n\t\t\tcontent\n\t\t\t\t.filter((block): block is { type: \"text\"; text: string } => block.type === \"text\")\n\t\t\t\t.map((block) => block.text)\n\t\t\t\t.join(\"\\n\") ?? \"\"\n\t\t);\n\t};\n\n\tconst rebuildFromSession = (ctx: ExtensionContext) => {\n\t\tif (!ctx.hasUI) return;\n\n\t\tconst entries = ctx.sessionManager.getEntries();\n\t\tconst lastMatch = [...entries].reverse().find((entry) => {\n\t\t\tif (entry.type !== \"message\" || entry.message.role !== \"user\") return false;\n\t\t\tconst text = getUserText(entry.message.content);\n\t\t\treturn !!extractPromptMatch(text);\n\t\t});\n\n\t\tconst content =\n\t\t\tlastMatch?.type === \"message\" && lastMatch.message.role === \"user\" ? lastMatch.message.content : undefined;\n\t\tconst text = getUserText(content);\n\t\tconst match = text ? extractPromptMatch(text) : undefined;\n\t\tif (!match) {\n\t\t\tctx.ui.setWidget(\"prompt-url\", undefined);\n\t\t\treturn;\n\t\t}\n\n\t\tsetWidget(ctx, match);\n\t\tapplySessionName(ctx, match);\n\t\tvoid fetchGhMetadata(pi, match.kind, match.url).then((meta) => {\n\t\t\tconst title = meta?.title?.trim();\n\t\t\tconst authorText = formatAuthor(meta?.author);\n\t\t\tsetWidget(ctx, match, title, authorText);\n\t\t\tapplySessionName(ctx, match, title);\n\t\t});\n\t};\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\trebuildFromSession(ctx);\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/rules/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/rules/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGX,YAAY,EAEZ,MAAM,gBAAgB,CAAC;AAgBxB,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAyK/D"}
|
|
@@ -72,35 +72,42 @@ export default function piRulesExtension(pi) {
|
|
|
72
72
|
pi.appendEntry("pi-rules.scan", { cwd: ctx.cwd, reason: "compact" });
|
|
73
73
|
return undefined;
|
|
74
74
|
});
|
|
75
|
-
|
|
75
|
+
const onBeforeAgentStart = async (event, ctx) => {
|
|
76
76
|
syncConfigFromFlags();
|
|
77
77
|
if (engine.config.disabled || engine.config.mode === "off" || engine.config.mode === "dynamic") {
|
|
78
78
|
return undefined;
|
|
79
79
|
}
|
|
80
80
|
const loaded = engine.loadStaticRules(ctx.cwd);
|
|
81
|
-
|
|
81
|
+
// A preview composes the same block but leaves the injection marks the dynamic
|
|
82
|
+
// tool_result path reads untouched: no turn follows it.
|
|
83
|
+
const commit = event.preview !== true;
|
|
84
|
+
const contextPaths = commit ? nativeContextPaths : new Set();
|
|
85
|
+
contextPaths.clear();
|
|
82
86
|
for (const path of event.systemPromptOptions.contextFiles?.flatMap((contextFile) => pathKeys(contextFile.path)) ??
|
|
83
87
|
[]) {
|
|
84
|
-
|
|
88
|
+
contextPaths.add(path);
|
|
85
89
|
}
|
|
86
90
|
for (const rule of loaded.rules) {
|
|
87
|
-
if (
|
|
91
|
+
if (commit && (contextPaths.has(rule.path) || contextPaths.has(rule.realPath))) {
|
|
88
92
|
engine.markStaticInjected(rule);
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
// Deliberately NOT gated on isStaticInjected: the host re-emits this from the BASE prompt
|
|
92
96
|
// every user prompt, so a prior turn's mark would drop the block from turn 2 onward. The
|
|
93
97
|
// marks below serve only the dynamic tool_result path.
|
|
94
|
-
const rules = loaded.rules.filter((rule) => !
|
|
98
|
+
const rules = loaded.rules.filter((rule) => !contextPaths.has(rule.path) && !contextPaths.has(rule.realPath));
|
|
95
99
|
if (rules.length === 0) {
|
|
96
100
|
return undefined;
|
|
97
101
|
}
|
|
98
102
|
const block = engine.formatStatic(rules);
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
if (commit) {
|
|
104
|
+
for (const rule of rules) {
|
|
105
|
+
engine.markStaticInjected(rule);
|
|
106
|
+
}
|
|
101
107
|
}
|
|
102
108
|
return { systemPrompt: event.systemPrompt + block };
|
|
103
|
-
}
|
|
109
|
+
};
|
|
110
|
+
pi.on("before_agent_start", onBeforeAgentStart, { previewSafe: true });
|
|
104
111
|
pi.on("tool_result", async (event, ctx) => {
|
|
105
112
|
syncConfigFromFlags();
|
|
106
113
|
if (engine.config.disabled || engine.config.mode === "off" || engine.config.mode === "static" || event.isError) {
|