dal-code 1.0.38 → 1.0.40
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 +87 -0
- package/NOTICE +224 -0
- package/dal-docs/examples/extensions/LICENSE +21 -0
- package/dal-docs/examples/extensions/README.md +64 -0
- package/dal-docs/examples/extensions/bookmark.ts +52 -0
- package/dal-docs/examples/extensions/claude-rules.ts +88 -0
- package/dal-docs/examples/extensions/commands.ts +74 -0
- package/dal-docs/examples/extensions/custom-footer.ts +66 -0
- package/dal-docs/examples/extensions/dirty-repo-guard.ts +58 -0
- package/dal-docs/examples/extensions/dynamic-tools.ts +76 -0
- package/dal-docs/examples/extensions/hello.ts +49 -0
- package/dal-docs/examples/extensions/inline-bash.ts +96 -0
- package/dal-docs/examples/extensions/permission-gate.ts +36 -0
- package/dal-docs/examples/extensions/protected-paths.ts +32 -0
- package/dal-docs/examples/extensions/session-name.ts +29 -0
- package/dal-docs/examples/extensions/status-line.ts +34 -0
- package/dal-docs/examples/extensions/structured-output.ts +67 -0
- package/dal-docs/examples/extensions/tool-override.ts +146 -0
- package/dal-docs/examples/extensions/trigger-compact.ts +59 -0
- package/dal-docs/examples/extensions/truncated-tool.ts +197 -0
- package/dal-docs/extensions.md +27 -0
- package/dal-docs/settings.md +1 -1
- package/dist/cli/args.d.ts +3 -0
- package/dist/cli/args.js +17 -17
- package/dist/config.d.ts +1 -0
- package/dist/config.js +1 -1
- package/dist/core/agent-session.js +6 -6
- package/dist/core/compaction/compaction.js +31 -13
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/permission-surface.js +1 -1
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/extensions/types.d.ts +15 -1
- package/dist/core/model-registry.d.ts +1 -0
- package/dist/core/model-registry.js +1 -1
- package/dist/core/nested-tool-calls.js +2 -2
- package/dist/core/permissions/tool-policy.js +1 -1
- package/dist/core/project-facts.d.ts +16 -0
- package/dist/core/project-facts.js +2 -0
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/sandbox/policy.js +1 -1
- package/dist/core/sandbox/windows.js +1 -1
- package/dist/core/system-prompt.d.ts +1 -0
- package/dist/core/system-prompt.js +13 -12
- package/dist/core/tools/bash.js +13 -12
- package/dist/core/tools/path-utils.d.ts +5 -0
- package/dist/core/tools/process.d.ts +2 -0
- package/dist/core/tools/process.js +14 -13
- package/dist/core/workspace-lock.d.ts +29 -0
- package/dist/core/workspace-lock.js +3 -0
- package/dist/dal/extension-compat.d.ts +62 -0
- package/dist/dal/extension-compat.js +4 -0
- package/dist/dal/hooks/extension.js +2 -2
- package/dist/dal/i18n.js +1 -1
- package/dist/dal/manifest.js +1 -1
- package/dist/dal/reviewed/endorsed-cli.js +1 -1
- package/dist/dal/reviewed/endorsed.js +1 -1
- package/dist/dal/reviewed/market-keys.js +1 -0
- package/dist/dal/reviewed/market.d.ts +64 -0
- package/dist/dal/reviewed/market.js +2 -0
- package/dist/extensions/mcp/runtime.d.ts +2 -1
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/extensions/mcp/runtime.lazy.d.ts +1 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +1 -1
- package/dist/main.js +4 -4
- package/dist/modes/acp/acp-mode.js +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.js +14 -14
- package/dist/modes/print-mode.js +3 -3
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/node_modules/@dalcode/dal-advisor/LICENSE +45 -0
- package/dist/node_modules/@dalcode/dal-advisor/package.json +35 -0
- package/dist/node_modules/@dalcode/dal-advisor/src/index.js +22 -0
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/src/ask-user.js +1 -1
- package/dist/node_modules/@dalcode/dal-capabilities/LICENSE +21 -0
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +38 -0
- package/dist/node_modules/@dalcode/dal-capabilities/src/catalogue.js +1 -0
- package/dist/node_modules/@dalcode/dal-capabilities/src/index.js +11 -0
- package/dist/node_modules/@dalcode/dal-capabilities/src/install.js +4 -0
- package/dist/node_modules/@dalcode/dal-capabilities/src/match.js +1 -0
- package/dist/node_modules/@dalcode/dal-capabilities/src/state.js +3 -0
- package/dist/node_modules/@dalcode/dal-compat/LICENSE +21 -0
- package/dist/node_modules/@dalcode/dal-compat/package.json +32 -0
- package/dist/node_modules/@dalcode/dal-compat/src/claude-rules.js +3 -0
- package/dist/node_modules/@dalcode/dal-compat/src/index.js +7 -0
- package/dist/node_modules/@dalcode/dal-dap/LICENSE +47 -0
- package/dist/node_modules/@dalcode/dal-dap/package.json +38 -0
- package/dist/node_modules/@dalcode/dal-dap/src/adapters.js +1 -0
- package/dist/node_modules/@dalcode/dal-dap/src/client.js +5 -0
- package/dist/node_modules/@dalcode/dal-dap/src/index.js +9 -0
- package/dist/node_modules/@dalcode/dal-dap/src/install.js +2 -0
- package/dist/node_modules/@dalcode/dal-dap/src/session.js +2 -0
- package/dist/node_modules/@dalcode/dal-dap/src/types.js +0 -0
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +4 -3
- package/dist/node_modules/@dalcode/dal-goal/src/core.js +6 -6
- package/dist/node_modules/@dalcode/dal-goal/src/index.js +17 -7
- package/dist/node_modules/@dalcode/dal-goal/src/verify.js +26 -0
- package/dist/node_modules/@dalcode/dal-guard/package.json +6 -4
- package/dist/node_modules/@dalcode/dal-guard/src/attribution.js +1 -0
- package/dist/node_modules/@dalcode/dal-guard/src/credentials.js +1 -1
- package/dist/node_modules/@dalcode/dal-guard/src/edit-anchor-core.js +23 -0
- package/dist/node_modules/@dalcode/dal-guard/src/edit-anchor.js +4 -0
- package/dist/node_modules/@dalcode/dal-guard/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-guard/src/package-manager.js +1 -0
- package/dist/node_modules/@dalcode/dal-guard/src/workspace.js +2 -0
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/LICENSE +209 -0
- package/dist/node_modules/@dalcode/dal-interactive/package.json +4 -3
- package/dist/node_modules/@dalcode/dal-interactive/src/btw.js +25 -0
- package/dist/node_modules/@dalcode/dal-interactive/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/LICENSE +21 -0
- package/dist/node_modules/@dalcode/dal-learn/package.json +35 -0
- package/dist/node_modules/@dalcode/dal-learn/src/engine.js +8 -0
- package/dist/node_modules/@dalcode/dal-learn/src/extract.js +14 -0
- package/dist/node_modules/@dalcode/dal-learn/src/index.js +17 -0
- package/dist/node_modules/@dalcode/dal-learn/src/lessons.js +3 -0
- package/dist/node_modules/@dalcode/dal-learn/src/migrate.js +1 -0
- package/dist/node_modules/@dalcode/dal-learn/src/procedures.js +11 -0
- package/dist/node_modules/@dalcode/dal-learn/src/project-map.js +2 -0
- package/dist/node_modules/@dalcode/dal-learn/src/project.js +1 -0
- package/dist/node_modules/@dalcode/dal-learn/src/safety.js +2 -0
- package/dist/node_modules/@dalcode/dal-learn/src/signals.js +5 -0
- package/dist/node_modules/@dalcode/dal-learn/src/skill-actions.js +1 -0
- package/dist/node_modules/@dalcode/dal-learn/src/skill-evolution.js +16 -0
- package/dist/node_modules/@dalcode/dal-learn/src/store.js +2 -0
- package/dist/node_modules/@dalcode/dal-lsp/package.json +6 -4
- package/dist/node_modules/@dalcode/dal-lsp/src/client.js +3 -3
- package/dist/node_modules/@dalcode/dal-lsp/src/config.js +1 -1
- package/dist/node_modules/@dalcode/dal-lsp/src/format.js +8 -7
- package/dist/node_modules/@dalcode/dal-lsp/src/index.js +11 -8
- package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -5
- package/dist/node_modules/@dalcode/dal-mcp/src/config.d.ts +1 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/config.js +1 -1
- package/dist/node_modules/@dalcode/dal-mcp/src/http-client.d.ts +32 -1
- package/dist/node_modules/@dalcode/dal-mcp/src/http-client.js +2 -1
- package/dist/node_modules/@dalcode/dal-mcp/src/index.js +16 -16
- package/dist/node_modules/@dalcode/dal-mcp/src/oauth.js +2 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.d.ts +4 -2
- package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.js +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/src/types.d.ts +9 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/types.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-office/src/index.d.ts +6 -3
- package/dist/node_modules/@dalcode/dal-office/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/render/chart-theme.d.ts +13 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/chart-theme.js +1 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/chart.d.ts +16 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/chart.js +4 -2
- package/dist/node_modules/@dalcode/dal-office/src/render/docx.d.ts +4 -1
- package/dist/node_modules/@dalcode/dal-office/src/render/docx.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/render/drawio-style.d.ts +4 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/drawio-style.js +1 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/pptx.d.ts +52 -4
- package/dist/node_modules/@dalcode/dal-office/src/render/pptx.js +3 -2
- package/dist/node_modules/@dalcode/dal-office/src/render/thumbnails.d.ts +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/render/thumbnails.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/render/xlsx.d.ts +1 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/xlsx.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/scratchpad.d.ts +30 -1
- package/dist/node_modules/@dalcode/dal-office/src/scratchpad.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/themes.d.ts +35 -1
- package/dist/node_modules/@dalcode/dal-office/src/themes.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/tools/chart-generate.js +3 -3
- package/dist/node_modules/@dalcode/dal-office/src/tools/doc-generate.js +2 -2
- package/dist/node_modules/@dalcode/dal-office/src/tools/drawio-generate.js +3 -3
- package/dist/node_modules/@dalcode/dal-office/src/tools/ppt-generate.js +2 -2
- package/dist/node_modules/@dalcode/dal-office/src/tools/ppt-plan.js +2 -2
- package/dist/node_modules/@dalcode/dal-office/src/tools/sheet-generate.js +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +5 -3
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +5 -3
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -5
- package/dist/node_modules/@dalcode/dal-plugins/src/index.js +11 -11
- package/dist/node_modules/@dalcode/dal-plugins/src/manage.js +8 -10
- package/dist/node_modules/@dalcode/dal-plugins/src/npm-hook.js +1 -1
- package/dist/node_modules/@dalcode/dal-plugins/src/registry.js +2 -2
- package/dist/node_modules/@dalcode/dal-recall/LICENSE +45 -0
- package/dist/node_modules/@dalcode/dal-recall/package.json +34 -0
- package/dist/node_modules/@dalcode/dal-recall/src/index-db.js +57 -0
- package/dist/node_modules/@dalcode/dal-recall/src/index.js +1 -0
- package/dist/node_modules/@dalcode/dal-recall/src/query.js +1 -0
- package/dist/node_modules/@dalcode/dal-recall/src/redact.js +1 -0
- package/dist/node_modules/@dalcode/dal-recall/src/sqlite.js +1 -0
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-rewind/src/commands.js +2 -2
- package/dist/node_modules/@dalcode/dal-rewind/src/core.d.ts +21 -8
- package/dist/node_modules/@dalcode/dal-rewind/src/core.js +8 -3
- package/dist/node_modules/@dalcode/dal-rewind/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-rewind/src/state.js +1 -1
- package/dist/node_modules/@dalcode/dal-router/package.json +7 -5
- package/dist/node_modules/@dalcode/dal-router/src/advisor.js +1 -0
- package/dist/node_modules/@dalcode/dal-router/src/assist.js +4 -2
- package/dist/node_modules/@dalcode/dal-router/src/commands.js +8 -8
- package/dist/node_modules/@dalcode/dal-router/src/config.d.ts +5 -0
- package/dist/node_modules/@dalcode/dal-router/src/config.js +2 -2
- package/dist/node_modules/@dalcode/dal-router/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-router/src/jev.d.ts +2 -1
- package/dist/node_modules/@dalcode/dal-router/src/jev.js +4 -4
- package/dist/node_modules/@dalcode/dal-router/src/services.js +1 -1
- package/dist/node_modules/@dalcode/dal-router/src/subagent.js +1 -1
- package/dist/node_modules/@dalcode/dal-router/src/suggest.js +2 -0
- package/dist/node_modules/@dalcode/dal-skills/package.json +4 -3
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/browser-qa/SKILL.md +48 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/diagram-design/SKILL.md +81 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/poster-design/SKILL.md +50 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/print-design/SKILL.md +55 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/dashboard.html +177 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/diagram.html +39 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/echarts-dal.json +360 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/email/notice.html +46 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/landing.html +173 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/mermaid-dal.json +140 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/mindmap.html +65 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/event-poster.html +40 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/poster.css +41 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/square-card.html +25 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/wechat-cover.html +29 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/xhs-card.html +35 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/xhs-cover.html +26 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/print/letter.html +35 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/print/print.css +65 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/print/report.html +76 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/print/resume.html +72 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/render.mjs +18 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/tokens.css +264 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/web-design/SKILL.md +73 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled.js +1 -0
- package/dist/node_modules/@dalcode/dal-skills/src/catalog.js +2 -2
- package/dist/node_modules/@dalcode/dal-skills/src/index.js +16 -11
- package/dist/node_modules/@dalcode/dal-statusline/LICENSE +21 -0
- package/dist/node_modules/@dalcode/dal-statusline/package.json +31 -0
- package/dist/node_modules/@dalcode/dal-statusline/src/index.js +3 -0
- package/dist/node_modules/@dalcode/dal-structured/LICENSE +21 -0
- package/dist/node_modules/@dalcode/dal-structured/package.json +32 -0
- package/dist/node_modules/@dalcode/dal-structured/src/index.js +9 -0
- package/dist/node_modules/@dalcode/dal-subagent/LICENSE +24 -0
- package/dist/node_modules/@dalcode/dal-subagent/package.json +7 -6
- package/dist/node_modules/@dalcode/dal-subagent/src/background.js +13 -0
- package/dist/node_modules/@dalcode/dal-subagent/src/index.js +22 -14
- package/dist/node_modules/@dalcode/dal-subagent/src/inproc-runner.js +3 -0
- package/dist/node_modules/@dalcode/dal-subagent/src/pool.js +1 -0
- package/dist/node_modules/@dalcode/dal-subagent/src/process-runner.js +3 -3
- package/dist/node_modules/@dalcode/dal-subagent/src/tmux-runner.js +3 -0
- package/dist/node_modules/@dalcode/dal-subagent/src/worktree.js +2 -0
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/groups.js +1 -1
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/repair-hook.js +1 -0
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/repair.js +4 -0
- package/dist/node_modules/@dalcode/dal-usage/LICENSE +45 -0
- package/dist/node_modules/@dalcode/dal-usage/package.json +33 -0
- package/dist/node_modules/@dalcode/dal-usage/src/budget.d.ts +14 -0
- package/dist/node_modules/@dalcode/dal-usage/src/budget.js +3 -0
- package/dist/node_modules/@dalcode/dal-usage/src/data.d.ts +30 -0
- package/dist/node_modules/@dalcode/dal-usage/src/data.js +1 -0
- package/dist/node_modules/@dalcode/dal-usage/src/index.d.ts +12 -0
- package/dist/node_modules/@dalcode/dal-usage/src/index.js +2 -0
- package/dist/node_modules/@dalcode/dal-usage/src/report.d.ts +29 -0
- package/dist/node_modules/@dalcode/dal-usage/src/report.js +3 -0
- package/dist/node_modules/@dalcode/dal-web/package.json +6 -4
- package/dist/node_modules/@dalcode/dal-web/src/fetch.js +11 -5
- package/dist/node_modules/@dalcode/dal-web/src/index.js +2 -2
- package/dist/node_modules/@dalcode/dal-web/src/pdf.js +5 -0
- package/dist/node_modules/@dalcode/dal-workflow/LICENSE +24 -0
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/announce-check.js +1 -0
- package/dist/node_modules/@dalcode/dal-workflow/src/check-in.js +1 -1
- package/dist/node_modules/@dalcode/dal-workflow/src/completion-check.js +4 -0
- package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-workflow/src/lean-code.js +1 -0
- package/dist/node_modules/@dalcode/dal-workflow/src/ledger.js +3 -0
- package/dist/node_modules/@dalcode/dal-workflow/src/loop-guard.js +3 -0
- package/dist/node_modules/@dalcode/dal-workflow/src/shared.js +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +4 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/verify-check.js +2 -0
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/chord/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +0 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-server/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/package-manager-cli.js +61 -61
- package/dist/sdk/office.d.ts +1 -1
- package/dist/sdk/office.js +1 -1
- package/dist/sdk/rewind.d.ts +1 -1
- package/dist/sdk/rewind.js +1 -1
- package/dist/sdk/usage.d.ts +8 -0
- package/dist/sdk/usage.js +1 -0
- package/dist/utils/open-browser.d.ts +1 -0
- package/dist/utils/tools-manager.js +1 -1
- package/dist/utils/version-check.d.ts +1 -0
- package/dist/utils/version-check.js +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +57 -14
- package/package.json +9 -2
- package/dist/node_modules/@dalcode/dal-plugins/src/compat.js +0 -2
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands Extension
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates the getCommands() API by providing a /commands command
|
|
5
|
+
* that lists all available slash commands in the current session.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* 1. Copy this file to ~/.dal/agent/extensions/ or your project's .dal/extensions/
|
|
9
|
+
* 2. Use /commands to see available commands
|
|
10
|
+
* 3. Use /commands extensions to filter by source
|
|
11
|
+
*
|
|
12
|
+
* Registers: commands commands
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { ExtensionAPI, SlashCommandInfo } from "@earendil-works/pi-coding-agent";
|
|
16
|
+
|
|
17
|
+
export default function commandsExtension(api: ExtensionAPI) {
|
|
18
|
+
api.registerCommand("commands", {
|
|
19
|
+
description: "List available slash commands",
|
|
20
|
+
getArgumentCompletions: (prefix) => {
|
|
21
|
+
const sources = ["extension", "prompt", "skill"];
|
|
22
|
+
const filtered = sources.filter((s) => s.startsWith(prefix));
|
|
23
|
+
return filtered.length > 0 ? filtered.map((s) => ({ value: s, label: s })) : null;
|
|
24
|
+
},
|
|
25
|
+
handler: async (args, ctx) => {
|
|
26
|
+
const commands = api.getCommands();
|
|
27
|
+
const sourceFilter = args.trim() as "extension" | "prompt" | "skill" | "";
|
|
28
|
+
|
|
29
|
+
// Filter by source if specified
|
|
30
|
+
const filtered = sourceFilter ? commands.filter((c) => c.source === sourceFilter) : commands;
|
|
31
|
+
|
|
32
|
+
if (filtered.length === 0) {
|
|
33
|
+
ctx.ui.notify(sourceFilter ? `No ${sourceFilter} commands found` : "No commands found", "info");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Build selection items grouped by source
|
|
38
|
+
const formatCommand = (cmd: SlashCommandInfo): string => {
|
|
39
|
+
const desc = cmd.description ? ` - ${cmd.description}` : "";
|
|
40
|
+
return `/${cmd.name}${desc}`;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const items: string[] = [];
|
|
44
|
+
const sources: Array<{ key: "extension" | "prompt" | "skill"; label: string }> = [
|
|
45
|
+
{ key: "extension", label: "Extensions" },
|
|
46
|
+
{ key: "prompt", label: "Prompts" },
|
|
47
|
+
{ key: "skill", label: "Skills" },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
for (const { key, label } of sources) {
|
|
51
|
+
const cmds = filtered.filter((c) => c.source === key);
|
|
52
|
+
if (cmds.length > 0) {
|
|
53
|
+
items.push(`--- ${label} ---`);
|
|
54
|
+
items.push(...cmds.map(formatCommand));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Show in a selector (user can scroll and see all commands)
|
|
59
|
+
const selected = await ctx.ui.select("Available Commands", items);
|
|
60
|
+
|
|
61
|
+
// If user selected a command (not a header), offer to show its path
|
|
62
|
+
if (selected && !selected.startsWith("---")) {
|
|
63
|
+
const cmdName = selected.split(" - ")[0].slice(1); // Remove leading /
|
|
64
|
+
const cmd = commands.find((c) => c.name === cmdName);
|
|
65
|
+
if (cmd?.sourceInfo.path) {
|
|
66
|
+
const showPath = await ctx.ui.confirm(cmd.name, `View source path?\n${cmd.sourceInfo.path}`);
|
|
67
|
+
if (showPath) {
|
|
68
|
+
ctx.ui.notify(cmd.sourceInfo.path, "info");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Footer Extension - demonstrates ctx.ui.setFooter()
|
|
3
|
+
*
|
|
4
|
+
* footerData exposes data not otherwise accessible:
|
|
5
|
+
* - getGitBranch(): current git branch
|
|
6
|
+
* - getExtensionStatuses(): texts from ctx.ui.setStatus()
|
|
7
|
+
*
|
|
8
|
+
* Token stats come from ctx.sessionManager/ctx.model (already accessible).
|
|
9
|
+
*
|
|
10
|
+
* Registers: commands footer
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { AssistantMessage } from "@earendil-works/pi-ai";
|
|
14
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
15
|
+
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
16
|
+
|
|
17
|
+
export default function (api: ExtensionAPI) {
|
|
18
|
+
let enabled = false;
|
|
19
|
+
|
|
20
|
+
api.registerCommand("footer", {
|
|
21
|
+
description: "Toggle custom footer",
|
|
22
|
+
handler: async (_args, ctx) => {
|
|
23
|
+
enabled = !enabled;
|
|
24
|
+
|
|
25
|
+
if (enabled) {
|
|
26
|
+
ctx.ui.setFooter((tui, theme, footerData) => {
|
|
27
|
+
const unsub = footerData.onBranchChange(() => tui.requestRender());
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
dispose: unsub,
|
|
31
|
+
invalidate() {},
|
|
32
|
+
render(width: number): string[] {
|
|
33
|
+
// Compute tokens from ctx (already accessible to extensions)
|
|
34
|
+
let input = 0,
|
|
35
|
+
output = 0,
|
|
36
|
+
cost = 0;
|
|
37
|
+
for (const e of ctx.sessionManager.getBranch()) {
|
|
38
|
+
if (e.type === "message" && e.message.role === "assistant") {
|
|
39
|
+
const m = e.message as AssistantMessage;
|
|
40
|
+
input += m.usage.input;
|
|
41
|
+
output += m.usage.output;
|
|
42
|
+
cost += m.usage.cost.total;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Get git branch (not otherwise accessible)
|
|
47
|
+
const branch = footerData.getGitBranch();
|
|
48
|
+
const fmt = (n: number) => (n < 1000 ? `${n}` : `${(n / 1000).toFixed(1)}k`);
|
|
49
|
+
|
|
50
|
+
const left = theme.fg("dim", `↑${fmt(input)} ↓${fmt(output)} $${cost.toFixed(3)}`);
|
|
51
|
+
const branchStr = branch ? ` (${branch})` : "";
|
|
52
|
+
const right = theme.fg("dim", `${ctx.model?.id || "no-model"}${branchStr}`);
|
|
53
|
+
|
|
54
|
+
const pad = " ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(right)));
|
|
55
|
+
return [truncateToWidth(left + pad + right, width)];
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
ctx.ui.notify("Custom footer enabled", "info");
|
|
60
|
+
} else {
|
|
61
|
+
ctx.ui.setFooter(undefined);
|
|
62
|
+
ctx.ui.notify("Default footer restored", "info");
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dirty Repo Guard Extension
|
|
3
|
+
*
|
|
4
|
+
* Prevents session changes when there are uncommitted git changes.
|
|
5
|
+
* Useful to ensure work is committed before switching context.
|
|
6
|
+
*
|
|
7
|
+
* Registers: events session_before_fork, session_before_switch
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
11
|
+
|
|
12
|
+
async function checkDirtyRepo(
|
|
13
|
+
api: ExtensionAPI,
|
|
14
|
+
ctx: ExtensionContext,
|
|
15
|
+
action: string,
|
|
16
|
+
): Promise<{ cancel: boolean } | undefined> {
|
|
17
|
+
// Check for uncommitted changes
|
|
18
|
+
const { stdout, code } = await api.exec("git", ["status", "--porcelain"]);
|
|
19
|
+
|
|
20
|
+
if (code !== 0) {
|
|
21
|
+
// Not a git repo, allow the action
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const hasChanges = stdout.trim().length > 0;
|
|
26
|
+
if (!hasChanges) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!ctx.hasUI) {
|
|
31
|
+
// In non-interactive mode, block by default
|
|
32
|
+
return { cancel: true };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Count changed files
|
|
36
|
+
const changedFiles = stdout.trim().split("\n").filter(Boolean).length;
|
|
37
|
+
|
|
38
|
+
const choice = await ctx.ui.select(`You have ${changedFiles} uncommitted file(s). ${action} anyway?`, [
|
|
39
|
+
"Yes, proceed anyway",
|
|
40
|
+
"No, let me commit first",
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
if (choice !== "Yes, proceed anyway") {
|
|
44
|
+
ctx.ui.notify("Commit your changes first", "warning");
|
|
45
|
+
return { cancel: true };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default function (api: ExtensionAPI) {
|
|
50
|
+
api.on("session_before_switch", async (event, ctx) => {
|
|
51
|
+
const action = event.reason === "new" ? "new session" : "switch session";
|
|
52
|
+
return checkDirtyRepo(api, ctx, action);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
api.on("session_before_fork", async (_event, ctx) => {
|
|
56
|
+
return checkDirtyRepo(api, ctx, "fork");
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic Tools Extension
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates registering tools after session initialization.
|
|
5
|
+
*
|
|
6
|
+
* - Registers one tool during session_start
|
|
7
|
+
* - Registers additional tools at runtime via /add-echo-tool <name>
|
|
8
|
+
*
|
|
9
|
+
* Registers: commands add-echo-tool; events session_start
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
13
|
+
import { Type } from "typebox";
|
|
14
|
+
|
|
15
|
+
const ECHO_PARAMS = Type.Object({
|
|
16
|
+
message: Type.String({ description: "Message to echo" }),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function normalizeToolName(input: string): string | undefined {
|
|
20
|
+
const trimmed = input.trim().toLowerCase();
|
|
21
|
+
if (!trimmed) return undefined;
|
|
22
|
+
if (!/^[a-z0-9_]+$/.test(trimmed)) return undefined;
|
|
23
|
+
return trimmed;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default function dynamicToolsExtension(api: ExtensionAPI) {
|
|
27
|
+
const registeredToolNames = new Set<string>();
|
|
28
|
+
|
|
29
|
+
const registerEchoTool = (name: string, label: string, prefix: string): boolean => {
|
|
30
|
+
if (registeredToolNames.has(name)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
registeredToolNames.add(name);
|
|
35
|
+
api.registerTool({
|
|
36
|
+
name,
|
|
37
|
+
label,
|
|
38
|
+
description: `Echo a message with prefix: ${prefix}`,
|
|
39
|
+
promptSnippet: `Echo back user-provided text with ${prefix.trim()} prefix`,
|
|
40
|
+
promptGuidelines: ["Use echo_session when the user asks for exact echo output."],
|
|
41
|
+
parameters: ECHO_PARAMS,
|
|
42
|
+
async execute(_toolCallId, params) {
|
|
43
|
+
return {
|
|
44
|
+
content: [{ type: "text", text: `${prefix}${params.message}` }],
|
|
45
|
+
details: { tool: name, prefix },
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return true;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
api.on("session_start", (_event, ctx) => {
|
|
54
|
+
registerEchoTool("echo_session", "Echo Session", "[session] ");
|
|
55
|
+
ctx.ui.notify("Registered dynamic tool: echo_session", "info");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
api.registerCommand("add-echo-tool", {
|
|
59
|
+
description: "Register a new echo tool dynamically: /add-echo-tool <tool_name>",
|
|
60
|
+
handler: async (args, ctx) => {
|
|
61
|
+
const toolName = normalizeToolName(args);
|
|
62
|
+
if (!toolName) {
|
|
63
|
+
ctx.ui.notify("Usage: /add-echo-tool <tool_name> (lowercase, numbers, underscores)", "warning");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const created = registerEchoTool(toolName, `Echo ${toolName}`, `[${toolName}] `);
|
|
68
|
+
if (!created) {
|
|
69
|
+
ctx.ui.notify(`Tool already registered: ${toolName}`, "warning");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ctx.ui.notify(`Registered dynamic tool: ${toolName}`, "info");
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hello Extension - the smallest useful extension: one tool and one command.
|
|
3
|
+
*
|
|
4
|
+
* - The `hello` tool is something the model can call.
|
|
5
|
+
* - The `/hello [name]` command is something the user types. Its reply works
|
|
6
|
+
* both in the terminal UI (a notification) and in `dal -p "/hello Ada"`
|
|
7
|
+
* (a displayed message, which print mode writes to stdout).
|
|
8
|
+
*
|
|
9
|
+
* Usage: copy to ~/.dal/agent/extensions/ (all projects) or .dal/extensions/
|
|
10
|
+
* (this project), then /reload. Or try it once: dal -e ./hello.ts
|
|
11
|
+
*
|
|
12
|
+
* Registers: commands hello; tools hello
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { defineTool, type ExtensionAPI, type ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
16
|
+
import { Type } from "typebox";
|
|
17
|
+
|
|
18
|
+
const helloTool = defineTool({
|
|
19
|
+
name: "hello",
|
|
20
|
+
label: "Hello",
|
|
21
|
+
description: "Greet someone by name",
|
|
22
|
+
parameters: Type.Object({
|
|
23
|
+
name: Type.String({ description: "Name to greet" }),
|
|
24
|
+
}),
|
|
25
|
+
|
|
26
|
+
async execute(_toolCallId, params) {
|
|
27
|
+
return {
|
|
28
|
+
content: [{ type: "text", text: `Hello, ${params.name}!` }],
|
|
29
|
+
details: { greeted: params.name },
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/** Show a command's answer wherever the user is: a notification in the UI, stdout under `dal -p`. */
|
|
35
|
+
async function reply(api: ExtensionAPI, ctx: ExtensionCommandContext, text: string): Promise<void> {
|
|
36
|
+
if (ctx.hasUI) ctx.ui.notify(text, "info");
|
|
37
|
+
else api.sendMessage({ customType: "hello", content: text, display: true });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default function (api: ExtensionAPI) {
|
|
41
|
+
api.registerTool(helloTool);
|
|
42
|
+
|
|
43
|
+
api.registerCommand("hello", {
|
|
44
|
+
description: "Say hello (usage: /hello [name])",
|
|
45
|
+
handler: async (args, ctx) => {
|
|
46
|
+
await reply(api, ctx, `Hello, ${args.trim() || "world"}!`);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline Bash Extension - expands inline bash commands in user prompts.
|
|
3
|
+
*
|
|
4
|
+
* Start dal with this extension:
|
|
5
|
+
* dal -e ./inline-bash.ts
|
|
6
|
+
*
|
|
7
|
+
* Then type prompts with inline bash:
|
|
8
|
+
* What's in !{pwd}?
|
|
9
|
+
* The current branch is !{git branch --show-current} and status: !{git status --short}
|
|
10
|
+
* My node version is !{node --version}
|
|
11
|
+
*
|
|
12
|
+
* The !{command} patterns are executed and replaced with their output before
|
|
13
|
+
* the prompt is sent to the agent.
|
|
14
|
+
*
|
|
15
|
+
* Note: Regular !command syntax (whole-line bash) is preserved and works as before.
|
|
16
|
+
*
|
|
17
|
+
* Registers: events input
|
|
18
|
+
*/
|
|
19
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
20
|
+
|
|
21
|
+
export default function (api: ExtensionAPI) {
|
|
22
|
+
const PATTERN = /!\{([^}]+)\}/g;
|
|
23
|
+
const TIMEOUT_MS = 30000;
|
|
24
|
+
|
|
25
|
+
api.on("input", async (event, ctx) => {
|
|
26
|
+
const text = event.text;
|
|
27
|
+
|
|
28
|
+
// Don't process if it's a whole-line bash command (starts with !)
|
|
29
|
+
// This preserves the existing !command behavior
|
|
30
|
+
if (text.trimStart().startsWith("!") && !text.trimStart().startsWith("!{")) {
|
|
31
|
+
return { action: "continue" };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Check if there are any inline bash patterns
|
|
35
|
+
if (!PATTERN.test(text)) {
|
|
36
|
+
return { action: "continue" };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Reset regex state after test()
|
|
40
|
+
PATTERN.lastIndex = 0;
|
|
41
|
+
|
|
42
|
+
let result = text;
|
|
43
|
+
const expansions: Array<{ command: string; output: string; error?: string }> = [];
|
|
44
|
+
|
|
45
|
+
// Find all matches first (to avoid issues with replacing while iterating)
|
|
46
|
+
const matches: Array<{ full: string; command: string }> = [];
|
|
47
|
+
let match = PATTERN.exec(text);
|
|
48
|
+
while (match) {
|
|
49
|
+
matches.push({ full: match[0], command: match[1] });
|
|
50
|
+
match = PATTERN.exec(text);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Execute each command and collect results
|
|
54
|
+
for (const { full, command } of matches) {
|
|
55
|
+
try {
|
|
56
|
+
const bashResult = await api.exec("bash", ["-c", command], {
|
|
57
|
+
timeout: TIMEOUT_MS,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const output = bashResult.stdout || bashResult.stderr || "";
|
|
61
|
+
const trimmed = output.trim();
|
|
62
|
+
|
|
63
|
+
if (bashResult.code !== 0 && bashResult.stderr) {
|
|
64
|
+
expansions.push({
|
|
65
|
+
command,
|
|
66
|
+
output: trimmed,
|
|
67
|
+
error: `exit code ${bashResult.code}`,
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
expansions.push({ command, output: trimmed });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
result = result.replace(full, trimmed);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
76
|
+
expansions.push({ command, output: "", error: errorMsg });
|
|
77
|
+
result = result.replace(full, `[error: ${errorMsg}]`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Show what was expanded (if UI available)
|
|
82
|
+
if (ctx.hasUI && expansions.length > 0) {
|
|
83
|
+
const summary = expansions
|
|
84
|
+
.map((e) => {
|
|
85
|
+
const status = e.error ? ` (${e.error})` : "";
|
|
86
|
+
const preview = e.output.length > 50 ? `${e.output.slice(0, 50)}...` : e.output;
|
|
87
|
+
return `!{${e.command}}${status} -> "${preview}"`;
|
|
88
|
+
})
|
|
89
|
+
.join("\n");
|
|
90
|
+
|
|
91
|
+
ctx.ui.notify(`Expanded ${expansions.length} inline command(s):\n${summary}`, "info");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return { action: "transform", text: result, images: event.images };
|
|
95
|
+
});
|
|
96
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Permission Gate Extension
|
|
3
|
+
*
|
|
4
|
+
* Prompts for confirmation before running potentially dangerous bash commands.
|
|
5
|
+
* Patterns checked: rm -rf, sudo, chmod/chown 777
|
|
6
|
+
*
|
|
7
|
+
* Registers: events tool_call
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
11
|
+
|
|
12
|
+
export default function (api: ExtensionAPI) {
|
|
13
|
+
const dangerousPatterns = [/\brm\s+(-rf?|--recursive)/i, /\bsudo\b/i, /\b(chmod|chown)\b.*777/i];
|
|
14
|
+
|
|
15
|
+
api.on("tool_call", async (event, ctx) => {
|
|
16
|
+
if (event.toolName !== "bash") return undefined;
|
|
17
|
+
|
|
18
|
+
const command = event.input.command as string;
|
|
19
|
+
const isDangerous = dangerousPatterns.some((p) => p.test(command));
|
|
20
|
+
|
|
21
|
+
if (isDangerous) {
|
|
22
|
+
if (!ctx.hasUI) {
|
|
23
|
+
// In non-interactive mode, block by default
|
|
24
|
+
return { block: true, reason: "Dangerous command blocked (no UI for confirmation)" };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const choice = await ctx.ui.select(`⚠️ Dangerous command:\n\n ${command}\n\nAllow?`, ["Yes", "No"]);
|
|
28
|
+
|
|
29
|
+
if (choice !== "Yes") {
|
|
30
|
+
return { block: true, reason: "Blocked by user" };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return undefined;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protected Paths Extension
|
|
3
|
+
*
|
|
4
|
+
* Blocks write and edit operations to protected paths.
|
|
5
|
+
* Useful for preventing accidental modifications to sensitive files.
|
|
6
|
+
*
|
|
7
|
+
* Registers: events tool_call
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
11
|
+
|
|
12
|
+
export default function (api: ExtensionAPI) {
|
|
13
|
+
const protectedPaths = [".env", ".git/", "node_modules/"];
|
|
14
|
+
|
|
15
|
+
api.on("tool_call", async (event, ctx) => {
|
|
16
|
+
if (event.toolName !== "write" && event.toolName !== "edit") {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const path = event.input.path as string;
|
|
21
|
+
const isProtected = protectedPaths.some((p) => path.includes(p));
|
|
22
|
+
|
|
23
|
+
if (isProtected) {
|
|
24
|
+
if (ctx.hasUI) {
|
|
25
|
+
ctx.ui.notify(`Blocked write to protected path: ${path}`, "warning");
|
|
26
|
+
}
|
|
27
|
+
return { block: true, reason: `Path "${path}" is protected` };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return undefined;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session naming example.
|
|
3
|
+
*
|
|
4
|
+
* Shows setSessionName/getSessionName to give sessions friendly names
|
|
5
|
+
* that appear in the session selector instead of the first message.
|
|
6
|
+
*
|
|
7
|
+
* Usage: /session-name [name] - set or show session name
|
|
8
|
+
*
|
|
9
|
+
* Registers: commands session-name
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
13
|
+
|
|
14
|
+
export default function (api: ExtensionAPI) {
|
|
15
|
+
api.registerCommand("session-name", {
|
|
16
|
+
description: "Set or show session name (usage: /session-name [new name])",
|
|
17
|
+
handler: async (args, ctx) => {
|
|
18
|
+
const name = args.trim();
|
|
19
|
+
|
|
20
|
+
if (name) {
|
|
21
|
+
api.setSessionName(name);
|
|
22
|
+
ctx.ui.notify(`Session named: ${name}`, "info");
|
|
23
|
+
} else {
|
|
24
|
+
const current = api.getSessionName();
|
|
25
|
+
ctx.ui.notify(current ? `Session: ${current}` : "No session name set", "info");
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status Line Extension
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates ctx.ui.setStatus() for displaying persistent status text in the footer.
|
|
5
|
+
* Shows turn progress with themed colors.
|
|
6
|
+
*
|
|
7
|
+
* Registers: events session_start, turn_end, turn_start
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
11
|
+
|
|
12
|
+
export default function (api: ExtensionAPI) {
|
|
13
|
+
let turnCount = 0;
|
|
14
|
+
|
|
15
|
+
api.on("session_start", async (_event, ctx) => {
|
|
16
|
+
const theme = ctx.ui.theme;
|
|
17
|
+
ctx.ui.setStatus("status-demo", theme.fg("dim", "Ready"));
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
api.on("turn_start", async (_event, ctx) => {
|
|
21
|
+
turnCount++;
|
|
22
|
+
const theme = ctx.ui.theme;
|
|
23
|
+
const spinner = theme.fg("accent", "●");
|
|
24
|
+
const text = theme.fg("dim", ` Turn ${turnCount}...`);
|
|
25
|
+
ctx.ui.setStatus("status-demo", spinner + text);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
api.on("turn_end", async (_event, ctx) => {
|
|
29
|
+
const theme = ctx.ui.theme;
|
|
30
|
+
const check = theme.fg("success", "✓");
|
|
31
|
+
const text = theme.fg("dim", ` Turn ${turnCount} complete`);
|
|
32
|
+
ctx.ui.setStatus("status-demo", check + text);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Output Tool
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates `terminate: true` so the agent can end on a tool call
|
|
5
|
+
* without paying for an extra follow-up LLM turn.
|
|
6
|
+
*
|
|
7
|
+
* Registers: tools structured_output
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { defineTool, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
11
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
12
|
+
import { Type } from "typebox";
|
|
13
|
+
|
|
14
|
+
interface StructuredOutputDetails {
|
|
15
|
+
headline: string;
|
|
16
|
+
summary: string;
|
|
17
|
+
actionItems: string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const structuredOutputTool = defineTool({
|
|
21
|
+
name: "structured_output",
|
|
22
|
+
label: "Structured Output",
|
|
23
|
+
description:
|
|
24
|
+
"Return a final structured answer. Use this as your last action when the user asks for structured output or a machine-readable summary.",
|
|
25
|
+
promptSnippet: "Emit a final structured answer as a terminating tool result",
|
|
26
|
+
promptGuidelines: [
|
|
27
|
+
"Use structured_output as your final action when the user asks for structured output, JSON-like output, or a machine-readable summary.",
|
|
28
|
+
"After calling structured_output, do not emit another assistant response in the same turn.",
|
|
29
|
+
],
|
|
30
|
+
parameters: Type.Object({
|
|
31
|
+
headline: Type.String({ description: "Short title for the result" }),
|
|
32
|
+
summary: Type.String({ description: "One-paragraph summary" }),
|
|
33
|
+
actionItems: Type.Array(Type.String(), { description: "Concrete next steps or key bullets" }),
|
|
34
|
+
}),
|
|
35
|
+
|
|
36
|
+
async execute(_toolCallId, params) {
|
|
37
|
+
return {
|
|
38
|
+
content: [{ type: "text", text: `Saved structured output: ${params.headline}` }],
|
|
39
|
+
details: {
|
|
40
|
+
headline: params.headline,
|
|
41
|
+
summary: params.summary,
|
|
42
|
+
actionItems: params.actionItems,
|
|
43
|
+
} satisfies StructuredOutputDetails,
|
|
44
|
+
terminate: true,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
renderResult(result, _options, theme) {
|
|
49
|
+
const details = result.details as StructuredOutputDetails | undefined;
|
|
50
|
+
if (!details) {
|
|
51
|
+
const text = result.content[0];
|
|
52
|
+
return new Text(text?.type === "text" ? text.text : "", 0, 0);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const lines = [
|
|
56
|
+
theme.fg("toolTitle", theme.bold(details.headline)),
|
|
57
|
+
theme.fg("text", details.summary),
|
|
58
|
+
"",
|
|
59
|
+
...details.actionItems.map((item, index) => theme.fg("muted", `${index + 1}. ${item}`)),
|
|
60
|
+
];
|
|
61
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export default function (api: ExtensionAPI) {
|
|
66
|
+
api.registerTool(structuredOutputTool);
|
|
67
|
+
}
|