@edwardlee5423/magi 0.1.0-alpha.0
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/LICENSE +21 -0
- package/README.md +184 -0
- package/dist/agent/headless-agent.d.ts +15 -0
- package/dist/agent/headless-agent.js +105 -0
- package/dist/agent/headless-agent.js.map +1 -0
- package/dist/agent/local-plan.d.ts +20 -0
- package/dist/agent/local-plan.js +30 -0
- package/dist/agent/local-plan.js.map +1 -0
- package/dist/agent/query-engine.d.ts +71 -0
- package/dist/agent/query-engine.js +938 -0
- package/dist/agent/query-engine.js.map +1 -0
- package/dist/agent/query.d.ts +128 -0
- package/dist/agent/query.js +674 -0
- package/dist/agent/query.js.map +1 -0
- package/dist/agent/system-prompt.d.ts +12 -0
- package/dist/agent/system-prompt.js +104 -0
- package/dist/agent/system-prompt.js.map +1 -0
- package/dist/agent/tools.d.ts +71 -0
- package/dist/agent/tools.js +37 -0
- package/dist/agent/tools.js.map +1 -0
- package/dist/agents/roles.d.ts +9 -0
- package/dist/agents/roles.js +18 -0
- package/dist/agents/roles.js.map +1 -0
- package/dist/agents/task-queue.d.ts +13 -0
- package/dist/agents/task-queue.js +50 -0
- package/dist/agents/task-queue.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +1540 -0
- package/dist/cli.js.map +1 -0
- package/dist/colors.d.ts +20 -0
- package/dist/colors.js +92 -0
- package/dist/colors.js.map +1 -0
- package/dist/commands/agents.d.ts +9 -0
- package/dist/commands/agents.js +37 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/clear.d.ts +9 -0
- package/dist/commands/clear.js +20 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/commit.d.ts +8 -0
- package/dist/commands/commit.js +35 -0
- package/dist/commands/commit.js.map +1 -0
- package/dist/commands/compact.d.ts +8 -0
- package/dist/commands/compact.js +29 -0
- package/dist/commands/compact.js.map +1 -0
- package/dist/commands/copy.d.ts +8 -0
- package/dist/commands/copy.js +49 -0
- package/dist/commands/copy.js.map +1 -0
- package/dist/commands/cost.d.ts +8 -0
- package/dist/commands/cost.js +94 -0
- package/dist/commands/cost.js.map +1 -0
- package/dist/commands/diff.d.ts +8 -0
- package/dist/commands/diff.js +38 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/doctor.d.ts +8 -0
- package/dist/commands/doctor.js +23 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/export.d.ts +8 -0
- package/dist/commands/export.js +42 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/fork.d.ts +8 -0
- package/dist/commands/fork.js +20 -0
- package/dist/commands/fork.js.map +1 -0
- package/dist/commands/goal.d.ts +9 -0
- package/dist/commands/goal.js +54 -0
- package/dist/commands/goal.js.map +1 -0
- package/dist/commands/help.d.ts +8 -0
- package/dist/commands/help.js +65 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/hooks.d.ts +8 -0
- package/dist/commands/hooks.js +56 -0
- package/dist/commands/hooks.js.map +1 -0
- package/dist/commands/image.d.ts +17 -0
- package/dist/commands/image.js +74 -0
- package/dist/commands/image.js.map +1 -0
- package/dist/commands/init.d.ts +26 -0
- package/dist/commands/init.js +214 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +8 -0
- package/dist/commands/mcp.js +217 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/memory.d.ts +8 -0
- package/dist/commands/memory.js +79 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/model.d.ts +8 -0
- package/dist/commands/model.js +21 -0
- package/dist/commands/model.js.map +1 -0
- package/dist/commands/permissions.d.ts +9 -0
- package/dist/commands/permissions.js +30 -0
- package/dist/commands/permissions.js.map +1 -0
- package/dist/commands/proactive.d.ts +9 -0
- package/dist/commands/proactive.js +24 -0
- package/dist/commands/proactive.js.map +1 -0
- package/dist/commands/register-all.d.ts +1 -0
- package/dist/commands/register-all.js +68 -0
- package/dist/commands/register-all.js.map +1 -0
- package/dist/commands/registry.d.ts +64 -0
- package/dist/commands/registry.js +235 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/rename.d.ts +8 -0
- package/dist/commands/rename.js +16 -0
- package/dist/commands/rename.js.map +1 -0
- package/dist/commands/review.d.ts +8 -0
- package/dist/commands/review.js +13 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/rewind.d.ts +8 -0
- package/dist/commands/rewind.js +45 -0
- package/dist/commands/rewind.js.map +1 -0
- package/dist/commands/route.d.ts +9 -0
- package/dist/commands/route.js +83 -0
- package/dist/commands/route.js.map +1 -0
- package/dist/commands/sessions.d.ts +9 -0
- package/dist/commands/sessions.js +25 -0
- package/dist/commands/sessions.js.map +1 -0
- package/dist/commands/skill.d.ts +9 -0
- package/dist/commands/skill.js +46 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/status.d.ts +8 -0
- package/dist/commands/status.js +41 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/summary.d.ts +8 -0
- package/dist/commands/summary.js +39 -0
- package/dist/commands/summary.js.map +1 -0
- package/dist/commands/tasks.d.ts +9 -0
- package/dist/commands/tasks.js +70 -0
- package/dist/commands/tasks.js.map +1 -0
- package/dist/commands/todos.d.ts +9 -0
- package/dist/commands/todos.js +27 -0
- package/dist/commands/todos.js.map +1 -0
- package/dist/commands/tutorial.d.ts +8 -0
- package/dist/commands/tutorial.js +159 -0
- package/dist/commands/tutorial.js.map +1 -0
- package/dist/commands/upgrade.d.ts +9 -0
- package/dist/commands/upgrade.js +73 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/usage.d.ts +8 -0
- package/dist/commands/usage.js +54 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/vim.d.ts +10 -0
- package/dist/commands/vim.js +34 -0
- package/dist/commands/vim.js.map +1 -0
- package/dist/config.d.ts +104 -0
- package/dist/config.js +533 -0
- package/dist/config.js.map +1 -0
- package/dist/context/compaction.d.ts +66 -0
- package/dist/context/compaction.js +353 -0
- package/dist/context/compaction.js.map +1 -0
- package/dist/context/layers.d.ts +32 -0
- package/dist/context/layers.js +114 -0
- package/dist/context/layers.js.map +1 -0
- package/dist/context/token-budget.d.ts +21 -0
- package/dist/context/token-budget.js +70 -0
- package/dist/context/token-budget.js.map +1 -0
- package/dist/control/auth.d.ts +17 -0
- package/dist/control/auth.js +31 -0
- package/dist/control/auth.js.map +1 -0
- package/dist/control/daemon.d.ts +38 -0
- package/dist/control/daemon.js +135 -0
- package/dist/control/daemon.js.map +1 -0
- package/dist/control/mdns.d.ts +51 -0
- package/dist/control/mdns.js +344 -0
- package/dist/control/mdns.js.map +1 -0
- package/dist/control/peer-client.d.ts +49 -0
- package/dist/control/peer-client.js +170 -0
- package/dist/control/peer-client.js.map +1 -0
- package/dist/control/server.d.ts +30 -0
- package/dist/control/server.js +887 -0
- package/dist/control/server.js.map +1 -0
- package/dist/cost.d.ts +23 -0
- package/dist/cost.js +80 -0
- package/dist/cost.js.map +1 -0
- package/dist/doctor.d.ts +8 -0
- package/dist/doctor.js +22 -0
- package/dist/doctor.js.map +1 -0
- package/dist/env.d.ts +7 -0
- package/dist/env.js +70 -0
- package/dist/env.js.map +1 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +19 -0
- package/dist/events.js +236 -0
- package/dist/events.js.map +1 -0
- package/dist/fs-utils.d.ts +21 -0
- package/dist/fs-utils.js +48 -0
- package/dist/fs-utils.js.map +1 -0
- package/dist/goal.d.ts +32 -0
- package/dist/goal.js +172 -0
- package/dist/goal.js.map +1 -0
- package/dist/headless.d.ts +38 -0
- package/dist/headless.js +547 -0
- package/dist/headless.js.map +1 -0
- package/dist/history.d.ts +8 -0
- package/dist/history.js +77 -0
- package/dist/history.js.map +1 -0
- package/dist/hooks/events.d.ts +14 -0
- package/dist/hooks/events.js +37 -0
- package/dist/hooks/events.js.map +1 -0
- package/dist/hooks/runner.d.ts +73 -0
- package/dist/hooks/runner.js +256 -0
- package/dist/hooks/runner.js.map +1 -0
- package/dist/hooks/trigger.d.ts +9 -0
- package/dist/hooks/trigger.js +18 -0
- package/dist/hooks/trigger.js.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/interactions.d.ts +102 -0
- package/dist/interactions.js +250 -0
- package/dist/interactions.js.map +1 -0
- package/dist/logger.d.ts +32 -0
- package/dist/logger.js +115 -0
- package/dist/logger.js.map +1 -0
- package/dist/markdown.d.ts +18 -0
- package/dist/markdown.js +293 -0
- package/dist/markdown.js.map +1 -0
- package/dist/mcp/approval.d.ts +9 -0
- package/dist/mcp/approval.js +27 -0
- package/dist/mcp/approval.js.map +1 -0
- package/dist/mcp/client.d.ts +61 -0
- package/dist/mcp/client.js +276 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/connection-manager.d.ts +30 -0
- package/dist/mcp/connection-manager.js +126 -0
- package/dist/mcp/connection-manager.js.map +1 -0
- package/dist/mcp/oauth-callback.d.ts +23 -0
- package/dist/mcp/oauth-callback.js +108 -0
- package/dist/mcp/oauth-callback.js.map +1 -0
- package/dist/mcp/oauth-flow.d.ts +45 -0
- package/dist/mcp/oauth-flow.js +145 -0
- package/dist/mcp/oauth-flow.js.map +1 -0
- package/dist/mcp/oauth.d.ts +82 -0
- package/dist/mcp/oauth.js +169 -0
- package/dist/mcp/oauth.js.map +1 -0
- package/dist/mcp/tool-registry.d.ts +29 -0
- package/dist/mcp/tool-registry.js +207 -0
- package/dist/mcp/tool-registry.js.map +1 -0
- package/dist/mcp/transport.d.ts +33 -0
- package/dist/mcp/transport.js +493 -0
- package/dist/mcp/transport.js.map +1 -0
- package/dist/mcp/types.d.ts +57 -0
- package/dist/mcp/types.js +2 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/memdir.d.ts +58 -0
- package/dist/memdir.js +219 -0
- package/dist/memdir.js.map +1 -0
- package/dist/memory-selection.d.ts +30 -0
- package/dist/memory-selection.js +102 -0
- package/dist/memory-selection.js.map +1 -0
- package/dist/memory.d.ts +85 -0
- package/dist/memory.js +259 -0
- package/dist/memory.js.map +1 -0
- package/dist/paths.d.ts +25 -0
- package/dist/paths.js +99 -0
- package/dist/paths.js.map +1 -0
- package/dist/permissions.d.ts +17 -0
- package/dist/permissions.js +72 -0
- package/dist/permissions.js.map +1 -0
- package/dist/plugins/manifest.d.ts +17 -0
- package/dist/plugins/manifest.js +98 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/marketplace.d.ts +22 -0
- package/dist/plugins/marketplace.js +98 -0
- package/dist/plugins/marketplace.js.map +1 -0
- package/dist/proactive.d.ts +15 -0
- package/dist/proactive.js +49 -0
- package/dist/proactive.js.map +1 -0
- package/dist/providers/errors.d.ts +14 -0
- package/dist/providers/errors.js +66 -0
- package/dist/providers/errors.js.map +1 -0
- package/dist/providers/format-proxy.d.ts +100 -0
- package/dist/providers/format-proxy.js +235 -0
- package/dist/providers/format-proxy.js.map +1 -0
- package/dist/providers/http.d.ts +4 -0
- package/dist/providers/http.js +21 -0
- package/dist/providers/http.js.map +1 -0
- package/dist/providers/ir.d.ts +84 -0
- package/dist/providers/ir.js +76 -0
- package/dist/providers/ir.js.map +1 -0
- package/dist/providers/messages-compatible.d.ts +19 -0
- package/dist/providers/messages-compatible.js +592 -0
- package/dist/providers/messages-compatible.js.map +1 -0
- package/dist/providers/openai.d.ts +18 -0
- package/dist/providers/openai.js +430 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/registry.d.ts +10 -0
- package/dist/providers/registry.js +16 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/sse.d.ts +6 -0
- package/dist/providers/sse.js +104 -0
- package/dist/providers/sse.js.map +1 -0
- package/dist/routing/model-alias.d.ts +8 -0
- package/dist/routing/model-alias.js +23 -0
- package/dist/routing/model-alias.js.map +1 -0
- package/dist/routing/model-router.d.ts +55 -0
- package/dist/routing/model-router.js +233 -0
- package/dist/routing/model-router.js.map +1 -0
- package/dist/routing/router.d.ts +26 -0
- package/dist/routing/router.js +63 -0
- package/dist/routing/router.js.map +1 -0
- package/dist/rules/agents-loader.d.ts +12 -0
- package/dist/rules/agents-loader.js +61 -0
- package/dist/rules/agents-loader.js.map +1 -0
- package/dist/runner/client.d.ts +67 -0
- package/dist/runner/client.js +175 -0
- package/dist/runner/client.js.map +1 -0
- package/dist/session-store.d.ts +250 -0
- package/dist/session-store.js +629 -0
- package/dist/session-store.js.map +1 -0
- package/dist/skills/bundled.d.ts +14 -0
- package/dist/skills/bundled.js +148 -0
- package/dist/skills/bundled.js.map +1 -0
- package/dist/skills/loader.d.ts +11 -0
- package/dist/skills/loader.js +73 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/slash-menu.d.ts +14 -0
- package/dist/slash-menu.js +166 -0
- package/dist/slash-menu.js.map +1 -0
- package/dist/slash.d.ts +75 -0
- package/dist/slash.js +126 -0
- package/dist/slash.js.map +1 -0
- package/dist/spinner.d.ts +27 -0
- package/dist/spinner.js +68 -0
- package/dist/spinner.js.map +1 -0
- package/dist/ssh/exec.d.ts +20 -0
- package/dist/ssh/exec.js +39 -0
- package/dist/ssh/exec.js.map +1 -0
- package/dist/ssh/file.d.ts +32 -0
- package/dist/ssh/file.js +60 -0
- package/dist/ssh/file.js.map +1 -0
- package/dist/syntax-highlight.d.ts +19 -0
- package/dist/syntax-highlight.js +181 -0
- package/dist/syntax-highlight.js.map +1 -0
- package/dist/tools/agent-tool.d.ts +53 -0
- package/dist/tools/agent-tool.js +62 -0
- package/dist/tools/agent-tool.js.map +1 -0
- package/dist/tools/archive-create.d.ts +35 -0
- package/dist/tools/archive-create.js +37 -0
- package/dist/tools/archive-create.js.map +1 -0
- package/dist/tools/archive-extract.d.ts +28 -0
- package/dist/tools/archive-extract.js +36 -0
- package/dist/tools/archive-extract.js.map +1 -0
- package/dist/tools/base64.d.ts +27 -0
- package/dist/tools/base64.js +19 -0
- package/dist/tools/base64.js.map +1 -0
- package/dist/tools/browser.d.ts +125 -0
- package/dist/tools/browser.js +241 -0
- package/dist/tools/browser.js.map +1 -0
- package/dist/tools/config-tool.d.ts +31 -0
- package/dist/tools/config-tool.js +167 -0
- package/dist/tools/config-tool.js.map +1 -0
- package/dist/tools/cron.d.ts +110 -0
- package/dist/tools/cron.js +299 -0
- package/dist/tools/cron.js.map +1 -0
- package/dist/tools/date.d.ts +24 -0
- package/dist/tools/date.js +26 -0
- package/dist/tools/date.js.map +1 -0
- package/dist/tools/dir-create.d.ts +21 -0
- package/dist/tools/dir-create.js +19 -0
- package/dist/tools/dir-create.js.map +1 -0
- package/dist/tools/dir-list.d.ts +36 -0
- package/dist/tools/dir-list.js +47 -0
- package/dist/tools/dir-list.js.map +1 -0
- package/dist/tools/disk-usage.d.ts +30 -0
- package/dist/tools/disk-usage.js +22 -0
- package/dist/tools/disk-usage.js.map +1 -0
- package/dist/tools/download-file.d.ts +28 -0
- package/dist/tools/download-file.js +42 -0
- package/dist/tools/download-file.js.map +1 -0
- package/dist/tools/environment.d.ts +31 -0
- package/dist/tools/environment.js +33 -0
- package/dist/tools/environment.js.map +1 -0
- package/dist/tools/errors.d.ts +5 -0
- package/dist/tools/errors.js +9 -0
- package/dist/tools/errors.js.map +1 -0
- package/dist/tools/file-copy.d.ts +34 -0
- package/dist/tools/file-copy.js +45 -0
- package/dist/tools/file-copy.js.map +1 -0
- package/dist/tools/file-delete.d.ts +34 -0
- package/dist/tools/file-delete.js +42 -0
- package/dist/tools/file-delete.js.map +1 -0
- package/dist/tools/file-find.d.ts +46 -0
- package/dist/tools/file-find.js +33 -0
- package/dist/tools/file-find.js.map +1 -0
- package/dist/tools/file-move.d.ts +33 -0
- package/dist/tools/file-move.js +32 -0
- package/dist/tools/file-move.js.map +1 -0
- package/dist/tools/files.d.ts +38 -0
- package/dist/tools/files.js +123 -0
- package/dist/tools/files.js.map +1 -0
- package/dist/tools/git-branch-delete.d.ts +27 -0
- package/dist/tools/git-branch-delete.js +25 -0
- package/dist/tools/git-branch-delete.js.map +1 -0
- package/dist/tools/git-reset.d.ts +30 -0
- package/dist/tools/git-reset.js +28 -0
- package/dist/tools/git-reset.js.map +1 -0
- package/dist/tools/git-stash.d.ts +28 -0
- package/dist/tools/git-stash.js +24 -0
- package/dist/tools/git-stash.js.map +1 -0
- package/dist/tools/git.d.ts +77 -0
- package/dist/tools/git.js +300 -0
- package/dist/tools/git.js.map +1 -0
- package/dist/tools/github.d.ts +68 -0
- package/dist/tools/github.js +77 -0
- package/dist/tools/github.js.map +1 -0
- package/dist/tools/head-tail.d.ts +34 -0
- package/dist/tools/head-tail.js +23 -0
- package/dist/tools/head-tail.js.map +1 -0
- package/dist/tools/http-request.d.ts +44 -0
- package/dist/tools/http-request.js +57 -0
- package/dist/tools/http-request.js.map +1 -0
- package/dist/tools/json-query.d.ts +27 -0
- package/dist/tools/json-query.js +90 -0
- package/dist/tools/json-query.js.map +1 -0
- package/dist/tools/kill-process.d.ts +32 -0
- package/dist/tools/kill-process.js +51 -0
- package/dist/tools/kill-process.js.map +1 -0
- package/dist/tools/lsp.d.ts +98 -0
- package/dist/tools/lsp.js +398 -0
- package/dist/tools/lsp.js.map +1 -0
- package/dist/tools/monitor.d.ts +29 -0
- package/dist/tools/monitor.js +78 -0
- package/dist/tools/monitor.js.map +1 -0
- package/dist/tools/network-check.d.ts +34 -0
- package/dist/tools/network-check.js +57 -0
- package/dist/tools/network-check.js.map +1 -0
- package/dist/tools/notebook.d.ts +63 -0
- package/dist/tools/notebook.js +158 -0
- package/dist/tools/notebook.js.map +1 -0
- package/dist/tools/plan-mode.d.ts +48 -0
- package/dist/tools/plan-mode.js +57 -0
- package/dist/tools/plan-mode.js.map +1 -0
- package/dist/tools/process-list.d.ts +35 -0
- package/dist/tools/process-list.js +42 -0
- package/dist/tools/process-list.js.map +1 -0
- package/dist/tools/registry.d.ts +132 -0
- package/dist/tools/registry.js +2262 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/search.d.ts +38 -0
- package/dist/tools/search.js +327 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/shell.d.ts +18 -0
- package/dist/tools/shell.js +249 -0
- package/dist/tools/shell.js.map +1 -0
- package/dist/tools/skill-tool.d.ts +22 -0
- package/dist/tools/skill-tool.js +66 -0
- package/dist/tools/skill-tool.js.map +1 -0
- package/dist/tools/sleep.d.ts +16 -0
- package/dist/tools/sleep.js +24 -0
- package/dist/tools/sleep.js.map +1 -0
- package/dist/tools/snip.d.ts +26 -0
- package/dist/tools/snip.js +95 -0
- package/dist/tools/snip.js.map +1 -0
- package/dist/tools/system-info.d.ts +17 -0
- package/dist/tools/system-info.js +33 -0
- package/dist/tools/system-info.js.map +1 -0
- package/dist/tools/tasks.d.ts +191 -0
- package/dist/tools/tasks.js +348 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/text-stats.d.ts +25 -0
- package/dist/tools/text-stats.js +25 -0
- package/dist/tools/text-stats.js.map +1 -0
- package/dist/tools/todo.d.ts +69 -0
- package/dist/tools/todo.js +197 -0
- package/dist/tools/todo.js.map +1 -0
- package/dist/tools/tool-search.d.ts +29 -0
- package/dist/tools/tool-search.js +114 -0
- package/dist/tools/tool-search.js.map +1 -0
- package/dist/tools/tree-view.d.ts +34 -0
- package/dist/tools/tree-view.js +39 -0
- package/dist/tools/tree-view.js.map +1 -0
- package/dist/tools/user-message.d.ts +39 -0
- package/dist/tools/user-message.js +70 -0
- package/dist/tools/user-message.js.map +1 -0
- package/dist/tools/user-question.d.ts +88 -0
- package/dist/tools/user-question.js +236 -0
- package/dist/tools/user-question.js.map +1 -0
- package/dist/tools/web-browser.d.ts +53 -0
- package/dist/tools/web-browser.js +373 -0
- package/dist/tools/web-browser.js.map +1 -0
- package/dist/tools/web-fetch.d.ts +22 -0
- package/dist/tools/web-fetch.js +146 -0
- package/dist/tools/web-fetch.js.map +1 -0
- package/dist/tools/web-search.d.ts +51 -0
- package/dist/tools/web-search.js +198 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/which.d.ts +22 -0
- package/dist/tools/which.js +21 -0
- package/dist/tools/which.js.map +1 -0
- package/dist/tools/whoami.d.ts +17 -0
- package/dist/tools/whoami.js +24 -0
- package/dist/tools/whoami.js.map +1 -0
- package/dist/tools/workspace-diagnostics.d.ts +62 -0
- package/dist/tools/workspace-diagnostics.js +421 -0
- package/dist/tools/workspace-diagnostics.js.map +1 -0
- package/dist/tools/workspace.d.ts +14 -0
- package/dist/tools/workspace.js +65 -0
- package/dist/tools/workspace.js.map +1 -0
- package/dist/tools/worktree.d.ts +70 -0
- package/dist/tools/worktree.js +150 -0
- package/dist/tools/worktree.js.map +1 -0
- package/dist/tui/interactions.d.ts +25 -0
- package/dist/tui/interactions.js +232 -0
- package/dist/tui/interactions.js.map +1 -0
- package/dist/tui/multiline-input.d.ts +14 -0
- package/dist/tui/multiline-input.js +550 -0
- package/dist/tui/multiline-input.js.map +1 -0
- package/dist/tui/paste.d.ts +40 -0
- package/dist/tui/paste.js +113 -0
- package/dist/tui/paste.js.map +1 -0
- package/dist/tui/prompt-reader.d.ts +26 -0
- package/dist/tui/prompt-reader.js +553 -0
- package/dist/tui/prompt-reader.js.map +1 -0
- package/dist/tui/transcript.d.ts +34 -0
- package/dist/tui/transcript.js +275 -0
- package/dist/tui/transcript.js.map +1 -0
- package/dist/tui.d.ts +53 -0
- package/dist/tui.js +669 -0
- package/dist/tui.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/vim/lineEditor.d.ts +18 -0
- package/dist/vim/lineEditor.js +420 -0
- package/dist/vim/lineEditor.js.map +1 -0
- package/dist/web/panel-html.d.ts +1 -0
- package/dist/web/panel-html.js +532 -0
- package/dist/web/panel-html.js.map +1 -0
- package/dist/web/panel.d.ts +4 -0
- package/dist/web/panel.js +121 -0
- package/dist/web/panel.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundled built-in skills installed on first run if no user skill of the same
|
|
3
|
+
* name already exists. Users can override or remove these freely — the loader
|
|
4
|
+
* only writes when the destination doesn't exist.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
const SKILLS = [
|
|
9
|
+
{
|
|
10
|
+
name: "verify",
|
|
11
|
+
body: `# Verify implementation
|
|
12
|
+
|
|
13
|
+
Verify that recent code changes actually work, with concrete evidence.
|
|
14
|
+
|
|
15
|
+
## Steps
|
|
16
|
+
|
|
17
|
+
1. Identify what changed: \`git status\` and \`git diff\` (or ask the user if not in a repo)
|
|
18
|
+
2. Run the project's build, in this order, picking the one that exists:
|
|
19
|
+
- \`npm run build\` / \`pnpm build\` / \`yarn build\`
|
|
20
|
+
- \`cargo build\`
|
|
21
|
+
- \`go build ./...\`
|
|
22
|
+
- \`mvn compile\` / \`gradle build\`
|
|
23
|
+
3. Run the test suite the same way
|
|
24
|
+
4. Run any linter the project has
|
|
25
|
+
5. For each failure, read the error and the relevant file:line. Don't summarize away the actual message.
|
|
26
|
+
|
|
27
|
+
## Output
|
|
28
|
+
|
|
29
|
+
End with a structured verdict:
|
|
30
|
+
|
|
31
|
+
\`\`\`
|
|
32
|
+
VERDICT: <PASS | FAIL | PARTIAL>
|
|
33
|
+
|
|
34
|
+
EVIDENCE:
|
|
35
|
+
- <command>: <one-line result>
|
|
36
|
+
- ...
|
|
37
|
+
|
|
38
|
+
ISSUES (if any):
|
|
39
|
+
- <file:line>: <concrete problem>
|
|
40
|
+
- ...
|
|
41
|
+
|
|
42
|
+
NEXT STEPS (if FAIL/PARTIAL):
|
|
43
|
+
- <what the user should do to unblock>
|
|
44
|
+
\`\`\`
|
|
45
|
+
|
|
46
|
+
## Notes
|
|
47
|
+
|
|
48
|
+
- Don't fix the issues yourself unless the user asked. The verify skill reports.
|
|
49
|
+
- If the build/test commands aren't obvious, look at package.json scripts, Makefile, or just \`README.md\`.
|
|
50
|
+
- If you cannot run anything (no internet, missing tooling), say exactly what is uncertain.
|
|
51
|
+
`
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "debug",
|
|
55
|
+
body: `# Debug
|
|
56
|
+
|
|
57
|
+
Investigate a bug systematically, end with a minimal reproduction or root cause.
|
|
58
|
+
|
|
59
|
+
## Steps
|
|
60
|
+
|
|
61
|
+
1. **Restate the bug** in your own words. What is the observed behavior? What is expected?
|
|
62
|
+
2. **Find the entry point** — which command, endpoint, or user action triggers it? Use Grep for error messages, log lines, or the symptom.
|
|
63
|
+
3. **Read the call path** with Read. Don't skip files. Note assumptions in the code that the bug might violate.
|
|
64
|
+
4. **Form 2-3 hypotheses** about the cause. Rank them by likelihood.
|
|
65
|
+
5. **Test the top hypothesis** — add a log, run the failing case, read the output. If wrong, drop it and move to the next.
|
|
66
|
+
6. **Find the root cause**. State it precisely with file:line references.
|
|
67
|
+
7. **Propose a fix** — minimal, targeted. Show the diff.
|
|
68
|
+
|
|
69
|
+
## Anti-patterns
|
|
70
|
+
|
|
71
|
+
- Adding try/catch to swallow the error — that hides the bug, doesn't fix it.
|
|
72
|
+
- Patching symptoms instead of causes ("I'll just add a null check here").
|
|
73
|
+
- Long speculation without running anything.
|
|
74
|
+
|
|
75
|
+
## Output
|
|
76
|
+
|
|
77
|
+
\`\`\`
|
|
78
|
+
SYMPTOM: <one line>
|
|
79
|
+
ROOT CAUSE: <precise, with file:line>
|
|
80
|
+
FIX:
|
|
81
|
+
<diff or step-by-step>
|
|
82
|
+
\`\`\`
|
|
83
|
+
`
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "stuck",
|
|
87
|
+
body: `# Stuck — step back
|
|
88
|
+
|
|
89
|
+
When an approach has failed twice, do NOT keep tweaking it. Step back.
|
|
90
|
+
|
|
91
|
+
## Steps
|
|
92
|
+
|
|
93
|
+
1. **State what you tried.** Two attempts, what each was, what failed.
|
|
94
|
+
2. **Diagnose, don't tweak.** What assumption was wrong? Read the actual error or output (don't paraphrase).
|
|
95
|
+
3. **Consider 3 different approaches** at a higher level. Not "the same thing with one parameter changed" — fundamentally different paths.
|
|
96
|
+
4. **Pick one and explain why.** What about the failure mode makes this approach more likely to work?
|
|
97
|
+
5. **Or: ask the user.** If you can't see a path forward, say so. Show what you've tried, what you don't understand, and ask for direction.
|
|
98
|
+
|
|
99
|
+
## Triggers
|
|
100
|
+
|
|
101
|
+
- Same error after two attempts
|
|
102
|
+
- Tests still failing after two "fixes"
|
|
103
|
+
- Build still broken after two iterations
|
|
104
|
+
- Realizing partway through that the design doesn't fit
|
|
105
|
+
|
|
106
|
+
## Anti-patterns
|
|
107
|
+
|
|
108
|
+
- "Let me try the exact same thing one more time"
|
|
109
|
+
- "I'll add another retry/fallback/null check"
|
|
110
|
+
- Silently switching to a different language/framework/architecture without telling the user
|
|
111
|
+
- Pretending a partial result is the full thing
|
|
112
|
+
`
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
/**
|
|
116
|
+
* Install bundled skills into the user's skills root if not already present.
|
|
117
|
+
* Existing user skills with the same name are left untouched.
|
|
118
|
+
*/
|
|
119
|
+
export function installBundledSkills(paths) {
|
|
120
|
+
const installed = [];
|
|
121
|
+
const skipped = [];
|
|
122
|
+
if (!existsSync(paths.skillsRoot)) {
|
|
123
|
+
try {
|
|
124
|
+
mkdirSync(paths.skillsRoot, { recursive: true });
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return { installed, skipped };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
for (const skill of SKILLS) {
|
|
131
|
+
const dir = path.join(paths.skillsRoot, skill.name);
|
|
132
|
+
const file = path.join(dir, "SKILL.md");
|
|
133
|
+
if (existsSync(file)) {
|
|
134
|
+
skipped.push(skill.name);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
mkdirSync(dir, { recursive: true });
|
|
139
|
+
writeFileSync(file, skill.body, "utf8");
|
|
140
|
+
installed.push(skill.name);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
// best effort; if we can't write, just skip
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return { installed, skipped };
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=bundled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundled.js","sourceRoot":"","sources":["../../src/skills/bundled.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,MAAM,MAAM,GAAmB;IAC7B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCT;KACE;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BT;KACE;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;CAyBT;KACE;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAgB;IACnD,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACxC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzB,SAAS;QACX,CAAC;QACD,IAAI,CAAC;YACH,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACpC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACxC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,4CAA4C;QAC9C,CAAC;IACH,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MagiPaths } from "../paths.js";
|
|
2
|
+
export interface SkillRecord {
|
|
3
|
+
name: string;
|
|
4
|
+
root: string;
|
|
5
|
+
summary: string;
|
|
6
|
+
body?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function listSkills(paths: MagiPaths): SkillRecord[];
|
|
9
|
+
export declare function loadSkill(root: string, includeBody?: boolean): SkillRecord;
|
|
10
|
+
export declare function findSkill(paths: MagiPaths, name: string): SkillRecord | undefined;
|
|
11
|
+
export declare function formatSkillList(skills: SkillRecord[]): string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { MagiConfigError } from "../errors.js";
|
|
4
|
+
export function listSkills(paths) {
|
|
5
|
+
let entries;
|
|
6
|
+
try {
|
|
7
|
+
entries = readdirSync(paths.skillsRoot);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return entries
|
|
13
|
+
.sort()
|
|
14
|
+
.flatMap((name) => {
|
|
15
|
+
const root = path.join(paths.skillsRoot, name);
|
|
16
|
+
const file = path.join(root, "SKILL.md");
|
|
17
|
+
try {
|
|
18
|
+
if (!statSync(file).isFile()) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
return [loadSkill(root, false)];
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export function loadSkill(root, includeBody = true) {
|
|
29
|
+
const name = path.basename(root);
|
|
30
|
+
if (!/^[a-z0-9][a-z0-9._-]{1,63}$/.test(name)) {
|
|
31
|
+
throw new MagiConfigError(`Invalid skill directory name: ${name}`);
|
|
32
|
+
}
|
|
33
|
+
const body = readFileSync(path.join(root, "SKILL.md"), "utf8");
|
|
34
|
+
const summary = firstMeaningfulLine(body) ?? name;
|
|
35
|
+
return {
|
|
36
|
+
name,
|
|
37
|
+
root,
|
|
38
|
+
summary,
|
|
39
|
+
body: includeBody ? body : undefined
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function findSkill(paths, name) {
|
|
43
|
+
if (!/^[a-z0-9][a-z0-9._-]{1,63}$/.test(name)) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const root = path.resolve(paths.skillsRoot, name);
|
|
47
|
+
const skillsRoot = path.resolve(paths.skillsRoot);
|
|
48
|
+
if (root !== skillsRoot && !root.startsWith(`${skillsRoot}${path.sep}`)) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
return loadSkill(root, true);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function formatSkillList(skills) {
|
|
59
|
+
if (skills.length === 0) {
|
|
60
|
+
return "No skills installed\n";
|
|
61
|
+
}
|
|
62
|
+
return `${skills.map((skill) => `${skill.name}\t${skill.summary}\t${skill.root}`).join("\n")}\n`;
|
|
63
|
+
}
|
|
64
|
+
function firstMeaningfulLine(body) {
|
|
65
|
+
for (const line of body.split(/\r?\n/)) {
|
|
66
|
+
const trimmed = line.replace(/^#+\s*/, "").trim();
|
|
67
|
+
if (trimmed) {
|
|
68
|
+
return trimmed;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/skills/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAU/C,MAAM,UAAU,UAAU,CAAC,KAAgB;IACzC,IAAI,OAAiB,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,OAAO;SACX,IAAI,EAAE;SACN,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACzC,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC7B,OAAO,EAAE,CAAC;YACZ,CAAC;Y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AC;IACD,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAqB;IACnD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,uBAAuB,CAAC;IACjC,CAAC;IACD,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACnG,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAClD,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Readable, Writable } from "node:stream";
|
|
2
|
+
export interface SlashMenuItem {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function showSlashMenu(input: {
|
|
7
|
+
stdin: Readable & {
|
|
8
|
+
isTTY?: boolean;
|
|
9
|
+
setRawMode?: (mode: boolean) => void;
|
|
10
|
+
isRaw?: boolean;
|
|
11
|
+
};
|
|
12
|
+
stdout: Pick<Writable, "write">;
|
|
13
|
+
items: SlashMenuItem[];
|
|
14
|
+
}): Promise<string | undefined>;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
const WINDOW = 10; // max visible items
|
|
2
|
+
export async function showSlashMenu(input) {
|
|
3
|
+
const { stdin, stdout, items } = input;
|
|
4
|
+
if (items.length === 0)
|
|
5
|
+
return undefined;
|
|
6
|
+
let filter = "";
|
|
7
|
+
let filtered = items;
|
|
8
|
+
let selected = 0;
|
|
9
|
+
let scrollOffset = 0;
|
|
10
|
+
let lastRenderedLines = 0;
|
|
11
|
+
function getVisibleCount() {
|
|
12
|
+
return Math.min(WINDOW, filtered.length);
|
|
13
|
+
}
|
|
14
|
+
function getMaxName() {
|
|
15
|
+
return filtered.length > 0 ? Math.max(...filtered.map(i => i.name.length)) : 8;
|
|
16
|
+
}
|
|
17
|
+
function applyFilter() {
|
|
18
|
+
const q = filter.toLowerCase();
|
|
19
|
+
filtered = q
|
|
20
|
+
? items.filter(i => i.name.toLowerCase().includes(q) || i.description.toLowerCase().includes(q))
|
|
21
|
+
: items;
|
|
22
|
+
selected = 0;
|
|
23
|
+
scrollOffset = 0;
|
|
24
|
+
}
|
|
25
|
+
function render() {
|
|
26
|
+
const visibleCount = getVisibleCount();
|
|
27
|
+
const maxName = getMaxName();
|
|
28
|
+
// Clear previous render by moving up and erasing each line
|
|
29
|
+
if (lastRenderedLines > 0) {
|
|
30
|
+
stdout.write(`\x1b[${lastRenderedLines}A`);
|
|
31
|
+
for (let i = 0; i < lastRenderedLines; i++) {
|
|
32
|
+
stdout.write(`\x1b[2K\n`);
|
|
33
|
+
}
|
|
34
|
+
stdout.write(`\x1b[${lastRenderedLines}A`);
|
|
35
|
+
}
|
|
36
|
+
const lines = [];
|
|
37
|
+
// Input line showing what user typed
|
|
38
|
+
lines.push(`\x1b[2K> \x1b[36m/${filter}\x1b[39m\x1b[90m${filter ? "" : " type to filter"}\x1b[39m`);
|
|
39
|
+
// Filtered items
|
|
40
|
+
if (filtered.length === 0) {
|
|
41
|
+
lines.push(`\x1b[2K \x1b[90mNo matching commands\x1b[39m`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
for (let i = 0; i < visibleCount; i++) {
|
|
45
|
+
const idx = scrollOffset + i;
|
|
46
|
+
const item = filtered[idx];
|
|
47
|
+
const isSel = idx === selected;
|
|
48
|
+
const prefix = isSel ? "\x1b[36m❯\x1b[39m" : " ";
|
|
49
|
+
const name = isSel
|
|
50
|
+
? `\x1b[1m/${item.name.padEnd(maxName)}\x1b[22m`
|
|
51
|
+
: `\x1b[90m/${item.name.padEnd(maxName)}\x1b[39m`;
|
|
52
|
+
const desc = `\x1b[90m${item.description}\x1b[39m`;
|
|
53
|
+
const scroll = filtered.length > WINDOW ? ` \x1b[90m${idx + 1}/${filtered.length}\x1b[39m` : "";
|
|
54
|
+
lines.push(`\x1b[2K${prefix} ${name} ${desc}${scroll}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Hint line
|
|
58
|
+
lines.push(`\x1b[2K\x1b[90m ↑↓ navigate · enter select · esc cancel · type to filter\x1b[39m`);
|
|
59
|
+
// Each line ends with \n so cursor ends up below the menu
|
|
60
|
+
stdout.write(lines.map(l => l + "\n").join(""));
|
|
61
|
+
lastRenderedLines = lines.length;
|
|
62
|
+
}
|
|
63
|
+
function clear() {
|
|
64
|
+
if (lastRenderedLines > 0) {
|
|
65
|
+
stdout.write(`\x1b[${lastRenderedLines}A`);
|
|
66
|
+
for (let i = 0; i < lastRenderedLines; i++) {
|
|
67
|
+
stdout.write(`\x1b[2K\n`);
|
|
68
|
+
}
|
|
69
|
+
stdout.write(`\x1b[${lastRenderedLines}A\x1b[2K`);
|
|
70
|
+
}
|
|
71
|
+
stdout.write(`\x1b[?25h`);
|
|
72
|
+
}
|
|
73
|
+
// Hide cursor, then do first render (no extra newline needed)
|
|
74
|
+
stdout.write(`\x1b[?25l`);
|
|
75
|
+
lastRenderedLines = 0;
|
|
76
|
+
render();
|
|
77
|
+
return new Promise((resolve) => {
|
|
78
|
+
const wasRaw = stdin.isRaw;
|
|
79
|
+
if (stdin.setRawMode)
|
|
80
|
+
stdin.setRawMode(true);
|
|
81
|
+
function cleanup() {
|
|
82
|
+
stdin.removeListener("data", onData);
|
|
83
|
+
if (stdin.setRawMode)
|
|
84
|
+
stdin.setRawMode(wasRaw ?? false);
|
|
85
|
+
stdin.pause();
|
|
86
|
+
}
|
|
87
|
+
function move(delta) {
|
|
88
|
+
if (filtered.length === 0)
|
|
89
|
+
return;
|
|
90
|
+
selected = (selected + delta + filtered.length) % filtered.length;
|
|
91
|
+
const visibleCount = getVisibleCount();
|
|
92
|
+
if (selected < scrollOffset)
|
|
93
|
+
scrollOffset = selected;
|
|
94
|
+
if (selected >= scrollOffset + visibleCount)
|
|
95
|
+
scrollOffset = selected - visibleCount + 1;
|
|
96
|
+
render();
|
|
97
|
+
}
|
|
98
|
+
function onData(buf) {
|
|
99
|
+
const key = buf.toString();
|
|
100
|
+
// Escape or Ctrl+C: cancel
|
|
101
|
+
if (key === "\x1b" || key === "\x03") {
|
|
102
|
+
cleanup();
|
|
103
|
+
clear();
|
|
104
|
+
resolve(undefined);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// Enter: select current item, or submit typed text as command
|
|
108
|
+
if (key === "\r" || key === "\n") {
|
|
109
|
+
cleanup();
|
|
110
|
+
clear();
|
|
111
|
+
if (filtered.length > 0) {
|
|
112
|
+
resolve(`/${filtered[selected].name}`);
|
|
113
|
+
}
|
|
114
|
+
else if (filter) {
|
|
115
|
+
resolve(`/${filter}`);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
resolve(undefined);
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// Arrow up/down: navigate
|
|
123
|
+
if (key === "\x1b[A") {
|
|
124
|
+
move(-1);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (key === "\x1b[B") {
|
|
128
|
+
move(1);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// Backspace: remove last char from filter, or dismiss menu if empty
|
|
132
|
+
if (key === "\x7f" || key === "\b") {
|
|
133
|
+
if (filter.length > 0) {
|
|
134
|
+
filter = filter.slice(0, -1);
|
|
135
|
+
applyFilter();
|
|
136
|
+
render();
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// Filter empty — dismiss menu (same as Escape)
|
|
140
|
+
cleanup();
|
|
141
|
+
clear();
|
|
142
|
+
resolve(undefined);
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
// Tab: complete with selected item name
|
|
147
|
+
if (key === "\t") {
|
|
148
|
+
if (filtered.length > 0) {
|
|
149
|
+
filter = filtered[selected].name;
|
|
150
|
+
applyFilter();
|
|
151
|
+
render();
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// Printable characters: add to filter
|
|
156
|
+
if (key.length === 1 && key >= " " && key <= "~") {
|
|
157
|
+
filter += key;
|
|
158
|
+
applyFilter();
|
|
159
|
+
render();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
stdin.on("data", onData);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=slash-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slash-menu.js","sourceRoot":"","sources":["../src/slash-menu.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,oBAAoB;AAEvC,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAInC;IACC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACvC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAEzC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,iBAAiB,G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./config.js";
|
|
2
|
+
import { MemoryScope } from "./memory.js";
|
|
3
|
+
import { MagiPaths } from "./paths.js";
|
|
4
|
+
import { SessionStore } from "./session-store.js";
|
|
5
|
+
export { registry, parseCommandLine, formatModelTarget, formatModelPicker, resolveModelPickerSelection, formatSessionSearch, resolveSessionPickerSelection } from "./commands/registry.js";
|
|
6
|
+
export type { SlashCommandInput, SlashCommandModule } from "./commands/registry.js";
|
|
7
|
+
import { registerAllCommands } from "./commands/register-all.js";
|
|
8
|
+
export { registerAllCommands };
|
|
9
|
+
export type SlashCommand = {
|
|
10
|
+
type: "help";
|
|
11
|
+
} | {
|
|
12
|
+
type: "status";
|
|
13
|
+
} | {
|
|
14
|
+
type: "model";
|
|
15
|
+
alias?: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "resume";
|
|
18
|
+
sessionId?: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: "memory";
|
|
21
|
+
scope?: MemoryScope;
|
|
22
|
+
} | {
|
|
23
|
+
type: "review";
|
|
24
|
+
} | {
|
|
25
|
+
type: "sessions";
|
|
26
|
+
} | {
|
|
27
|
+
type: "clear";
|
|
28
|
+
} | {
|
|
29
|
+
type: "summary";
|
|
30
|
+
} | {
|
|
31
|
+
type: "cost";
|
|
32
|
+
} | {
|
|
33
|
+
type: "doctor";
|
|
34
|
+
} | {
|
|
35
|
+
type: "compact";
|
|
36
|
+
} | {
|
|
37
|
+
type: "goal";
|
|
38
|
+
args: string[];
|
|
39
|
+
} | {
|
|
40
|
+
type: "commit";
|
|
41
|
+
args: string[];
|
|
42
|
+
} | {
|
|
43
|
+
type: "diff";
|
|
44
|
+
args: string[];
|
|
45
|
+
} | {
|
|
46
|
+
type: "unknown";
|
|
47
|
+
name: string;
|
|
48
|
+
};
|
|
49
|
+
export interface SlashCommandSpec {
|
|
50
|
+
name: string;
|
|
51
|
+
usage: string;
|
|
52
|
+
group: string;
|
|
53
|
+
description: string;
|
|
54
|
+
}
|
|
55
|
+
export declare const SLASH_COMMANDS: SlashCommandSpec[];
|
|
56
|
+
/**
|
|
57
|
+
* Parse a /-prefixed input into a backward-compatible SlashCommand.
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseSlashCommand(input: string): SlashCommand | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Backward-compatible slash command dispatcher.
|
|
62
|
+
*/
|
|
63
|
+
export declare function runSlashCommand(input: {
|
|
64
|
+
command: SlashCommand;
|
|
65
|
+
config: MagiConfig;
|
|
66
|
+
store: SessionStore;
|
|
67
|
+
cwd: string;
|
|
68
|
+
paths?: MagiPaths;
|
|
69
|
+
sessionId?: string;
|
|
70
|
+
currentModel?: string;
|
|
71
|
+
}): string;
|
|
72
|
+
/**
|
|
73
|
+
* Backward-compatible slash suggestion formatter.
|
|
74
|
+
*/
|
|
75
|
+
export declare function formatSlashSuggestions(query?: string): string;
|
package/dist/slash.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Re-export layer for the modular slash command system.
|
|
2
|
+
// Maintains backward compatibility for existing code and tests.
|
|
3
|
+
import { registry } from "./commands/registry.js";
|
|
4
|
+
export { registry, parseCommandLine, formatModelTarget, formatModelPicker, resolveModelPickerSelection, formatSessionSearch, resolveSessionPickerSelection } from "./commands/registry.js";
|
|
5
|
+
import { registerAllCommands } from "./commands/register-all.js";
|
|
6
|
+
export { registerAllCommands };
|
|
7
|
+
registerAllCommands();
|
|
8
|
+
// --- Backward-compatible constants ---
|
|
9
|
+
export const SLASH_COMMANDS = [
|
|
10
|
+
{ name: "help", usage: "/help [command]", group: "Help", description: "Show command groups and shortcuts" },
|
|
11
|
+
{ name: "status", usage: "/status", group: "Session", description: "Show cwd, providers, aliases, and state" },
|
|
12
|
+
{ name: "sessions", usage: "/sessions", group: "Session", description: "List recent sessions" },
|
|
13
|
+
{ name: "resume", usage: "/resume [query]", group: "Session", description: "Search and resume a session" },
|
|
14
|
+
{ name: "model", usage: "/model [alias]", group: "Model", description: "Show or switch model alias" },
|
|
15
|
+
{ name: "memory", usage: "/memory [scope]", group: "Memory", description: "View memory loaded for this workspace" },
|
|
16
|
+
{ name: "review", usage: "/review [target]", group: "Tools", description: "Switch to review-oriented route" },
|
|
17
|
+
{ name: "commit", usage: "/commit [-m <msg>]", group: "Git", description: "Commit staged git changes" },
|
|
18
|
+
{ name: "diff", usage: "/diff [path]", group: "Git", description: "Show git diff" },
|
|
19
|
+
{ name: "clear", usage: "/clear", group: "Session", description: "Start a fresh session" },
|
|
20
|
+
{ name: "summary", usage: "/summary", group: "Session", description: "Show session summary" },
|
|
21
|
+
{ name: "goal", usage: "/goal <objective> | /goal", group: "Session", description: "Start or show the current session goal" },
|
|
22
|
+
{ name: "cost", usage: "/cost", group: "Session", description: "Show job and cost info" },
|
|
23
|
+
{ name: "doctor", usage: "/doctor", group: "Tools", description: "Run workspace diagnostics" },
|
|
24
|
+
{ name: "compact", usage: "/compact", group: "Session", description: "Trigger context compaction" },
|
|
25
|
+
{ name: "exit", usage: "/exit", group: "Help", description: "Exit the interactive terminal" }
|
|
26
|
+
];
|
|
27
|
+
// --- Backward-compatible functions ---
|
|
28
|
+
/**
|
|
29
|
+
* Parse a /-prefixed input into a backward-compatible SlashCommand.
|
|
30
|
+
*/
|
|
31
|
+
export function parseSlashCommand(input) {
|
|
32
|
+
const trimmed = input.trim();
|
|
33
|
+
if (!trimmed.startsWith("/"))
|
|
34
|
+
return undefined;
|
|
35
|
+
const [name, ...rest] = trimmed.slice(1).split(/\s+/);
|
|
36
|
+
const n = name?.toLowerCase() ?? "";
|
|
37
|
+
if (n === "" || n === "help")
|
|
38
|
+
return { type: "help" };
|
|
39
|
+
if (n === "status")
|
|
40
|
+
return { type: "status" };
|
|
41
|
+
if (n === "model")
|
|
42
|
+
return { type: "model", alias: rest[0] };
|
|
43
|
+
if (n === "sessions")
|
|
44
|
+
return { type: "sessions" };
|
|
45
|
+
if (n === "resume")
|
|
46
|
+
return { type: "resume", sessionId: rest[0] };
|
|
47
|
+
if (n === "memory") {
|
|
48
|
+
const scope = rest[0] === "user" || rest[0] === "project" || rest[0] === "session" ? rest[0] : undefined;
|
|
49
|
+
return { type: "memory", scope };
|
|
50
|
+
}
|
|
51
|
+
if (n === "review")
|
|
52
|
+
return { type: "review" };
|
|
53
|
+
if (n === "clear" || n === "reset" || n === "new")
|
|
54
|
+
return { type: "clear" };
|
|
55
|
+
if (n === "commit")
|
|
56
|
+
return { type: "commit", args: rest };
|
|
57
|
+
if (n === "diff")
|
|
58
|
+
return { type: "diff", args: rest };
|
|
59
|
+
if (n === "summary")
|
|
60
|
+
return { type: "summary" };
|
|
61
|
+
if (n === "cost")
|
|
62
|
+
return { type: "cost" };
|
|
63
|
+
if (n === "doctor")
|
|
64
|
+
return { type: "doctor" };
|
|
65
|
+
if (n === "compact")
|
|
66
|
+
return { type: "compact" };
|
|
67
|
+
if (n === "goal")
|
|
68
|
+
return { type: "goal", args: rest };
|
|
69
|
+
return { type: "unknown", name: n };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Backward-compatible slash command dispatcher.
|
|
73
|
+
*/
|
|
74
|
+
export function runSlashCommand(input) {
|
|
75
|
+
const { command, ...context } = input;
|
|
76
|
+
const cmd = command; // avoid shadowing the import
|
|
77
|
+
const registryContext = { config: context.config, store: context.store, cwd: context.cwd, paths: context.paths, sessionId: context.sessionId, currentModel: context.currentModel };
|
|
78
|
+
const name = cmd.type === "unknown" ? cmd.name : cmd.type;
|
|
79
|
+
let args = [];
|
|
80
|
+
if (cmd.type === "model")
|
|
81
|
+
args = cmd.alias ? [cmd.alias] : [];
|
|
82
|
+
else if (cmd.type === "resume")
|
|
83
|
+
args = cmd.sessionId ? [cmd.sessionId] : [];
|
|
84
|
+
else if (cmd.type === "memory")
|
|
85
|
+
args = cmd.scope ? [cmd.scope] : [];
|
|
86
|
+
else if (cmd.type === "goal")
|
|
87
|
+
args = cmd.args ?? [];
|
|
88
|
+
else if (cmd.type === "commit")
|
|
89
|
+
args = cmd.args ?? [];
|
|
90
|
+
else if (cmd.type === "diff")
|
|
91
|
+
args = cmd.args ?? [];
|
|
92
|
+
const result = registry.dispatch(name, args, registryContext);
|
|
93
|
+
if (result === undefined) {
|
|
94
|
+
return `Unknown slash command: /${command.type === "unknown" ? command.name : command.type}`;
|
|
95
|
+
}
|
|
96
|
+
if (typeof result === "string")
|
|
97
|
+
return result;
|
|
98
|
+
// Async dispatch result not supported in back-compat sync path
|
|
99
|
+
return `Slash command /${name} requires interactive mode (it returns asynchronously). Use the TUI to invoke it.`;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Backward-compatible slash suggestion formatter.
|
|
103
|
+
*/
|
|
104
|
+
export function formatSlashSuggestions(query = "") {
|
|
105
|
+
const normalized = query.replace(/^\//, "").trim().toLowerCase();
|
|
106
|
+
const matches = SLASH_COMMANDS.filter((cmd) => {
|
|
107
|
+
if (!normalized)
|
|
108
|
+
return true;
|
|
109
|
+
return cmd.name.includes(normalized)
|
|
110
|
+
|| cmd.usage.toLowerCase().includes(normalized)
|
|
111
|
+
|| cmd.description.toLowerCase().includes(normalized)
|
|
112
|
+
|| cmd.group.toLowerCase().includes(normalized);
|
|
113
|
+
});
|
|
114
|
+
if (matches.length === 0) {
|
|
115
|
+
return `No slash commands match /${normalized}\n`;
|
|
116
|
+
}
|
|
117
|
+
return [
|
|
118
|
+
`Slash commands${normalized ? ` matching /${normalized}` : ""}:`,
|
|
119
|
+
...matches.map((cmd, index) => {
|
|
120
|
+
const marker = index === 0 ? ">" : " ";
|
|
121
|
+
return `${marker} ${cmd.usage.padEnd(28)} ${cmd.group.padEnd(8)} ${cmd.description}`;
|
|
122
|
+
}),
|
|
123
|
+
"Use /help for groups, /resume <query> to search sessions, /exit to quit."
|
|
124
|
+
].join("\n");
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=slash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slash.js","sourceRoot":"","sources":["../src/slash.ts"],"names":[],"mappings":"AAA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