dal-code 1.0.39 → 1.0.41
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 +111 -4
- package/NOTICE +298 -0
- package/PRIVACY.md +62 -2
- 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/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.d.ts +3 -0
- package/dist/core/agent-session.js +6 -6
- 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/resource-loader.js +1 -1
- package/dist/core/system-prompt.js +10 -9
- 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/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 +7 -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/components/status-indicator.d.ts +1 -1
- package/dist/modes/interactive/components/status-indicator.js +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode.js +14 -14
- package/dist/modes/print-mode.d.ts +1 -1
- package/dist/modes/print-mode.js +7 -6
- 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 +23 -0
- package/dist/node_modules/@dalcode/dal-awake/LICENSE +21 -0
- package/dist/node_modules/@dalcode/dal-awake/package.json +31 -0
- package/dist/node_modules/@dalcode/dal-awake/src/index.js +3 -0
- package/dist/node_modules/@dalcode/dal-awake/src/inhibitor.js +1 -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/at-imports.js +3 -0
- package/dist/node_modules/@dalcode/dal-compat/src/claude-rules.js +3 -0
- package/dist/node_modules/@dalcode/dal-compat/src/index.js +9 -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/credentials.js +1 -1
- package/dist/node_modules/@dalcode/dal-guard/src/edit-anchor-core.js +24 -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/workspace.js +2 -2
- 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 +38 -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/patches.js +10 -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 +4 -4
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +4 -4
- 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-review/src/core.d.ts +1 -0
- package/dist/node_modules/@dalcode/dal-review/src/core.js +1 -1
- package/dist/node_modules/@dalcode/dal-review/src/findings.js +2 -2
- package/dist/node_modules/@dalcode/dal-review/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-review/src/prompt.d.ts +1 -1
- package/dist/node_modules/@dalcode/dal-review/src/prompt.js +3 -2
- package/dist/node_modules/@dalcode/dal-review/src/runner.d.ts +2 -1
- package/dist/node_modules/@dalcode/dal-review/src/runner.js +2 -2
- package/dist/node_modules/@dalcode/dal-review/src/simplify.d.ts +5 -0
- package/dist/node_modules/@dalcode/dal-review/src/simplify.js +30 -0
- package/dist/node_modules/@dalcode/dal-review/src/types.d.ts +5 -0
- package/dist/node_modules/@dalcode/dal-review/src/types.js +1 -1
- 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 +6 -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 +3 -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-rtk/LICENSE +21 -0
- package/dist/node_modules/@dalcode/dal-rtk/package.json +31 -0
- package/dist/node_modules/@dalcode/dal-rtk/src/index.js +2 -0
- package/dist/node_modules/@dalcode/dal-skills/package.json +4 -3
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/bounded-code-repair/SKILL.md +45 -0
- 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/evidence-first-retrieval/SKILL.md +43 -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/validated-structured-output/SKILL.md +36 -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 +7 -2
- package/dist/node_modules/@dalcode/dal-telemetry/src/config.js +3 -2
- package/dist/node_modules/@dalcode/dal-telemetry/src/failure-queue.js +4 -0
- package/dist/node_modules/@dalcode/dal-telemetry/src/failure-reporting.js +5 -0
- package/dist/node_modules/@dalcode/dal-telemetry/src/failures.js +2 -0
- package/dist/node_modules/@dalcode/dal-telemetry/src/index.js +4 -3
- package/dist/node_modules/@dalcode/dal-telemetry/src/repro.js +1 -0
- 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/path-hint.js +1 -0
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/repair-hook.js +2 -0
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/repair.js +4 -0
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/tool-name.js +1 -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 +13 -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-usage/src/time-limit.d.ts +4 -0
- package/dist/node_modules/@dalcode/dal-usage/src/time-limit.js +2 -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 +2 -2
- 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 -3
- 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/dal-workflow/src/working-contract.js +1 -0
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@dalcode/deepailab/src/index.js +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/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/together.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/dist/utils/retry.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +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/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,64 @@
|
|
|
1
|
+
# Extension examples
|
|
2
|
+
|
|
3
|
+
Small, working extensions to copy from. Each file loads as is: try one with
|
|
4
|
+
`dal -e <file>`, or copy it to `~/.dal/agent/extensions/` (all projects) or
|
|
5
|
+
`.dal/extensions/` in a project, then `/reload`. The API is described in
|
|
6
|
+
[../../extensions.md](../../extensions.md). Each file's header lists what it
|
|
7
|
+
registers (`Registers:`).
|
|
8
|
+
|
|
9
|
+
When writing a new extension, start from the closest example below and keep
|
|
10
|
+
its structure: a default-exported function that receives `api: ExtensionAPI`.
|
|
11
|
+
|
|
12
|
+
## Tools the model can call
|
|
13
|
+
|
|
14
|
+
| File | Shows |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| [hello.ts](hello.ts) | The smallest extension: one tool and one `/hello` command whose reply also prints under `dal -p` |
|
|
17
|
+
| [structured-output.ts](structured-output.ts) | A tool that ends the turn (`terminate: true`) with a structured answer and a custom result renderer |
|
|
18
|
+
| [truncated-tool.ts](truncated-tool.ts) | Truncating large tool output to the built-in limits and saving the full text to a file |
|
|
19
|
+
| [tool-override.ts](tool-override.ts) | Replacing a built-in tool (`read`) to log and block access, plus a `/read-log` command |
|
|
20
|
+
| [dynamic-tools.ts](dynamic-tools.ts) | Registering tools after startup, from `session_start` and from a command |
|
|
21
|
+
|
|
22
|
+
## Commands
|
|
23
|
+
|
|
24
|
+
| File | Shows |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| [commands.ts](commands.ts) | Listing every slash command with `getCommands()`, argument completion, `ctx.ui.select` |
|
|
27
|
+
| [session-name.ts](session-name.ts) | Naming the session with `setSessionName` / `getSessionName` |
|
|
28
|
+
| [bookmark.ts](bookmark.ts) | Labelling conversation entries with `setLabel` for `/tree` |
|
|
29
|
+
| [trigger-compact.ts](trigger-compact.ts) | Compacting the context from a command or once usage crosses a threshold |
|
|
30
|
+
|
|
31
|
+
## Safety gates (event hooks)
|
|
32
|
+
|
|
33
|
+
| File | Shows |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| [permission-gate.ts](permission-gate.ts) | Asking before risky bash commands in `tool_call`, blocking when there is no UI |
|
|
36
|
+
| [protected-paths.ts](protected-paths.ts) | Blocking writes and edits to protected paths |
|
|
37
|
+
| [dirty-repo-guard.ts](dirty-repo-guard.ts) | Cancelling a session switch or fork while git has uncommitted changes |
|
|
38
|
+
|
|
39
|
+
## Prompt and input
|
|
40
|
+
|
|
41
|
+
| File | Shows |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| [claude-rules.ts](claude-rules.ts) | Listing `.claude/rules/*.md` in the system prompt from `before_agent_start` |
|
|
44
|
+
| [inline-bash.ts](inline-bash.ts) | Expanding `!{command}` in the user's message in the `input` event |
|
|
45
|
+
|
|
46
|
+
## Terminal UI
|
|
47
|
+
|
|
48
|
+
| File | Shows |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| [status-line.ts](status-line.ts) | Persistent footer status text with `ctx.ui.setStatus` |
|
|
51
|
+
| [custom-footer.ts](custom-footer.ts) | Replacing the footer with `ctx.ui.setFooter` (token totals, git branch) |
|
|
52
|
+
|
|
53
|
+
## Notes
|
|
54
|
+
|
|
55
|
+
- `ctx.hasUI` is false under `dal -p` and in the desktop backend: check it
|
|
56
|
+
before `ctx.ui.select` / `confirm`, and block (rather than allow) when a
|
|
57
|
+
safety decision cannot be asked.
|
|
58
|
+
- `ctx.ui.notify` shows nothing under `dal -p`; a command that must answer
|
|
59
|
+
there sends a displayed message (see `hello.ts`).
|
|
60
|
+
- Imports keep the engine's package names (`@earendil-works/pi-coding-agent`
|
|
61
|
+
and friends); they are resolved to DAL's own implementation at load time.
|
|
62
|
+
|
|
63
|
+
These examples are adapted from the example extensions of the MIT-licensed
|
|
64
|
+
open-source engine DAL is built on (copyright notice in [LICENSE](LICENSE)).
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry bookmarking example.
|
|
3
|
+
*
|
|
4
|
+
* Shows setLabel to mark entries with labels for easy navigation in /tree.
|
|
5
|
+
* Labels appear in the tree view and help you find important points.
|
|
6
|
+
*
|
|
7
|
+
* Usage: /bookmark [label] - bookmark the last assistant message
|
|
8
|
+
*
|
|
9
|
+
* Registers: commands bookmark, unbookmark
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
13
|
+
|
|
14
|
+
export default function (api: ExtensionAPI) {
|
|
15
|
+
api.registerCommand("bookmark", {
|
|
16
|
+
description: "Bookmark last message (usage: /bookmark [label])",
|
|
17
|
+
handler: async (args, ctx) => {
|
|
18
|
+
const label = args.trim() || `bookmark-${Date.now()}`;
|
|
19
|
+
|
|
20
|
+
// Find the last assistant message entry
|
|
21
|
+
const entries = ctx.sessionManager.getEntries();
|
|
22
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
23
|
+
const entry = entries[i];
|
|
24
|
+
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
25
|
+
api.setLabel(entry.id, label);
|
|
26
|
+
ctx.ui.notify(`Bookmarked as: ${label}`, "info");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ctx.ui.notify("No assistant message to bookmark", "warning");
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Remove bookmark
|
|
36
|
+
api.registerCommand("unbookmark", {
|
|
37
|
+
description: "Remove bookmark from last labeled entry",
|
|
38
|
+
handler: async (_args, ctx) => {
|
|
39
|
+
const entries = ctx.sessionManager.getEntries();
|
|
40
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
41
|
+
const entry = entries[i];
|
|
42
|
+
const label = ctx.sessionManager.getLabel(entry.id);
|
|
43
|
+
if (label) {
|
|
44
|
+
api.setLabel(entry.id, undefined);
|
|
45
|
+
ctx.ui.notify(`Removed bookmark: ${label}`, "info");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
ctx.ui.notify("No bookmarked entry found", "warning");
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Rules Extension
|
|
3
|
+
*
|
|
4
|
+
* Scans the project's .claude/rules/ folder for rule files and lists them
|
|
5
|
+
* in the system prompt. The agent can then use the read tool to load
|
|
6
|
+
* specific rules when needed.
|
|
7
|
+
*
|
|
8
|
+
* Best practices for .claude/rules/:
|
|
9
|
+
* - Keep rules focused: Each file should cover one topic (e.g., testing.md, api-design.md)
|
|
10
|
+
* - Use descriptive filenames: The filename should indicate what the rules cover
|
|
11
|
+
* - Use conditional rules sparingly: Only add paths frontmatter when rules truly apply to specific file types
|
|
12
|
+
* - Organize with subdirectories: Group related rules (e.g., frontend/, backend/)
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* 1. Copy this file to ~/.dal/agent/extensions/ or your project's .dal/extensions/
|
|
16
|
+
* 2. Create .claude/rules/ folder in your project root
|
|
17
|
+
* 3. Add .md files with your rules
|
|
18
|
+
*
|
|
19
|
+
* Registers: events before_agent_start, session_start
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import * as fs from "node:fs";
|
|
23
|
+
import * as path from "node:path";
|
|
24
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Recursively find all .md files in a directory
|
|
28
|
+
*/
|
|
29
|
+
function findMarkdownFiles(dir: string, basePath: string = ""): string[] {
|
|
30
|
+
const results: string[] = [];
|
|
31
|
+
|
|
32
|
+
if (!fs.existsSync(dir)) {
|
|
33
|
+
return results;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
37
|
+
|
|
38
|
+
for (const entry of entries) {
|
|
39
|
+
const relativePath = basePath ? `${basePath}/${entry.name}` : entry.name;
|
|
40
|
+
|
|
41
|
+
if (entry.isDirectory()) {
|
|
42
|
+
results.push(...findMarkdownFiles(path.join(dir, entry.name), relativePath));
|
|
43
|
+
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
44
|
+
results.push(relativePath);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return results;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default function claudeRulesExtension(api: ExtensionAPI) {
|
|
52
|
+
let ruleFiles: string[] = [];
|
|
53
|
+
let rulesDir: string = "";
|
|
54
|
+
|
|
55
|
+
// Scan for rules on session start
|
|
56
|
+
api.on("session_start", async (_event, ctx) => {
|
|
57
|
+
rulesDir = path.join(ctx.cwd, ".claude", "rules");
|
|
58
|
+
ruleFiles = findMarkdownFiles(rulesDir);
|
|
59
|
+
|
|
60
|
+
if (ruleFiles.length > 0) {
|
|
61
|
+
ctx.ui.notify(`Found ${ruleFiles.length} rule(s) in .claude/rules/`, "info");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Append available rules to system prompt
|
|
66
|
+
api.on("before_agent_start", async (event) => {
|
|
67
|
+
if (ruleFiles.length === 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const rulesList = ruleFiles.map((f) => `- .claude/rules/${f}`).join("\n");
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
systemPrompt:
|
|
75
|
+
event.systemPrompt +
|
|
76
|
+
`
|
|
77
|
+
|
|
78
|
+
## Project Rules
|
|
79
|
+
|
|
80
|
+
The following project rules are available in .claude/rules/:
|
|
81
|
+
|
|
82
|
+
${rulesList}
|
|
83
|
+
|
|
84
|
+
When working on tasks related to these rules, use the read tool to load the relevant rule files for guidance.
|
|
85
|
+
`,
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -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
|
+
}
|