micro-models-agent 0.6.4 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +286 -436
- package/dist/main.js +11706 -0
- package/dist/skills/builtin/git.md +36 -0
- package/dist/skills/builtin/typescript.md +35 -0
- package/package.json +41 -47
- package/dist/agent/context.d.ts +0 -73
- package/dist/agent/context.d.ts.map +0 -1
- package/dist/agent/context.js +0 -262
- package/dist/agent/context.js.map +0 -1
- package/dist/agent/error-escalation.d.ts +0 -19
- package/dist/agent/error-escalation.d.ts.map +0 -1
- package/dist/agent/error-escalation.js +0 -168
- package/dist/agent/error-escalation.js.map +0 -1
- package/dist/agent/loop.d.ts +0 -46
- package/dist/agent/loop.d.ts.map +0 -1
- package/dist/agent/loop.js +0 -1043
- package/dist/agent/loop.js.map +0 -1
- package/dist/agent/memory.d.ts +0 -40
- package/dist/agent/memory.d.ts.map +0 -1
- package/dist/agent/memory.js +0 -231
- package/dist/agent/memory.js.map +0 -1
- package/dist/agent/modes/applier.d.ts +0 -43
- package/dist/agent/modes/applier.d.ts.map +0 -1
- package/dist/agent/modes/applier.js +0 -30
- package/dist/agent/modes/applier.js.map +0 -1
- package/dist/agent/modes/registry.d.ts +0 -35
- package/dist/agent/modes/registry.d.ts.map +0 -1
- package/dist/agent/modes/registry.js +0 -169
- package/dist/agent/modes/registry.js.map +0 -1
- package/dist/agent/modes/types.d.ts +0 -61
- package/dist/agent/modes/types.d.ts.map +0 -1
- package/dist/agent/modes/types.js +0 -13
- package/dist/agent/modes/types.js.map +0 -1
- package/dist/agent/react-loop.d.ts +0 -65
- package/dist/agent/react-loop.d.ts.map +0 -1
- package/dist/agent/react-loop.js +0 -101
- package/dist/agent/react-loop.js.map +0 -1
- package/dist/agent/system-prompt.d.ts +0 -26
- package/dist/agent/system-prompt.d.ts.map +0 -1
- package/dist/agent/system-prompt.js +0 -478
- package/dist/agent/system-prompt.js.map +0 -1
- package/dist/agent/tool-executor.d.ts +0 -36
- package/dist/agent/tool-executor.d.ts.map +0 -1
- package/dist/agent/tool-executor.js +0 -346
- package/dist/agent/tool-executor.js.map +0 -1
- package/dist/agent/user-profile.d.ts +0 -26
- package/dist/agent/user-profile.d.ts.map +0 -1
- package/dist/agent/user-profile.js +0 -169
- package/dist/agent/user-profile.js.map +0 -1
- package/dist/agent/write-enforcer.d.ts +0 -7
- package/dist/agent/write-enforcer.d.ts.map +0 -1
- package/dist/agent/write-enforcer.js +0 -8
- package/dist/agent/write-enforcer.js.map +0 -1
- package/dist/cli/config.d.ts +0 -13
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js +0 -82
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/model.d.ts +0 -13
- package/dist/cli/model.d.ts.map +0 -1
- package/dist/cli/model.js +0 -170
- package/dist/cli/model.js.map +0 -1
- package/dist/cli/provider.d.ts +0 -12
- package/dist/cli/provider.d.ts.map +0 -1
- package/dist/cli/provider.js +0 -90
- package/dist/cli/provider.js.map +0 -1
- package/dist/cli/update.d.ts +0 -12
- package/dist/cli/update.d.ts.map +0 -1
- package/dist/cli/update.js +0 -69
- package/dist/cli/update.js.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -310
- package/dist/cli.js.map +0 -1
- package/dist/config/config.d.ts +0 -59
- package/dist/config/config.d.ts.map +0 -1
- package/dist/config/config.js +0 -232
- package/dist/config/config.js.map +0 -1
- package/dist/config/types.d.ts +0 -122
- package/dist/config/types.d.ts.map +0 -1
- package/dist/config/types.js +0 -13
- package/dist/config/types.js.map +0 -1
- package/dist/file-loader.d.ts +0 -20
- package/dist/file-loader.d.ts.map +0 -1
- package/dist/file-loader.js +0 -121
- package/dist/file-loader.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -11
- package/dist/index.js.map +0 -1
- package/dist/indexer/cache.d.ts +0 -34
- package/dist/indexer/cache.d.ts.map +0 -1
- package/dist/indexer/cache.js +0 -221
- package/dist/indexer/cache.js.map +0 -1
- package/dist/indexer/code-index.d.ts +0 -27
- package/dist/indexer/code-index.d.ts.map +0 -1
- package/dist/indexer/code-index.js +0 -219
- package/dist/indexer/code-index.js.map +0 -1
- package/dist/indexer/project-map.d.ts +0 -23
- package/dist/indexer/project-map.d.ts.map +0 -1
- package/dist/indexer/project-map.js +0 -264
- package/dist/indexer/project-map.js.map +0 -1
- package/dist/llm/lmstudio-native.d.ts +0 -10
- package/dist/llm/lmstudio-native.d.ts.map +0 -1
- package/dist/llm/lmstudio-native.js +0 -179
- package/dist/llm/lmstudio-native.js.map +0 -1
- package/dist/llm/openai-compat.d.ts +0 -11
- package/dist/llm/openai-compat.d.ts.map +0 -1
- package/dist/llm/openai-compat.js +0 -161
- package/dist/llm/openai-compat.js.map +0 -1
- package/dist/llm/provider.d.ts +0 -46
- package/dist/llm/provider.d.ts.map +0 -1
- package/dist/llm/provider.js +0 -13
- package/dist/llm/provider.js.map +0 -1
- package/dist/llm/token-counter.d.ts +0 -15
- package/dist/llm/token-counter.d.ts.map +0 -1
- package/dist/llm/token-counter.js +0 -51
- package/dist/llm/token-counter.js.map +0 -1
- package/dist/logger.d.ts +0 -24
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -156
- package/dist/logger.js.map +0 -1
- package/dist/plugins/adapters/hooks-adapter.d.ts +0 -12
- package/dist/plugins/adapters/hooks-adapter.d.ts.map +0 -1
- package/dist/plugins/adapters/hooks-adapter.js +0 -23
- package/dist/plugins/adapters/hooks-adapter.js.map +0 -1
- package/dist/plugins/builtin/lint-on-write/index.d.ts +0 -12
- package/dist/plugins/builtin/lint-on-write/index.d.ts.map +0 -1
- package/dist/plugins/builtin/lint-on-write/index.js +0 -98
- package/dist/plugins/builtin/lint-on-write/index.js.map +0 -1
- package/dist/plugins/builtin/lint-on-write/index.ts +0 -97
- package/dist/plugins/builtin/lint-on-write/manifest.json +0 -13
- package/dist/plugins/builtin/notify/index.d.ts +0 -11
- package/dist/plugins/builtin/notify/index.d.ts.map +0 -1
- package/dist/plugins/builtin/notify/index.js +0 -102
- package/dist/plugins/builtin/notify/index.js.map +0 -1
- package/dist/plugins/builtin/notify/index.ts +0 -105
- package/dist/plugins/builtin/notify/manifest.json +0 -16
- package/dist/plugins/loader.d.ts +0 -18
- package/dist/plugins/loader.d.ts.map +0 -1
- package/dist/plugins/loader.js +0 -182
- package/dist/plugins/loader.js.map +0 -1
- package/dist/plugins/manager.d.ts +0 -55
- package/dist/plugins/manager.d.ts.map +0 -1
- package/dist/plugins/manager.js +0 -190
- package/dist/plugins/manager.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -76
- package/dist/plugins/types.d.ts.map +0 -1
- package/dist/plugins/types.js +0 -8
- package/dist/plugins/types.js.map +0 -1
- package/dist/repl/commands.d.ts +0 -63
- package/dist/repl/commands.d.ts.map +0 -1
- package/dist/repl/commands.js +0 -1070
- package/dist/repl/commands.js.map +0 -1
- package/dist/repl/history.d.ts +0 -32
- package/dist/repl/history.d.ts.map +0 -1
- package/dist/repl/history.js +0 -40
- package/dist/repl/history.js.map +0 -1
- package/dist/repl/index.d.ts +0 -14
- package/dist/repl/index.d.ts.map +0 -1
- package/dist/repl/index.js +0 -235
- package/dist/repl/index.js.map +0 -1
- package/dist/session/store.d.ts +0 -46
- package/dist/session/store.d.ts.map +0 -1
- package/dist/session/store.js +0 -154
- package/dist/session/store.js.map +0 -1
- package/dist/setup-wizard.d.ts +0 -3
- package/dist/setup-wizard.d.ts.map +0 -1
- package/dist/setup-wizard.js +0 -410
- package/dist/setup-wizard.js.map +0 -1
- package/dist/skills/builtin/agent-test/SKILL.md +0 -68
- package/dist/skills/builtin/cli-expert/SKILL.md +0 -848
- package/dist/skills/builtin/code-review/SKILL.md +0 -424
- package/dist/skills/builtin/git-expert/SKILL.md +0 -522
- package/dist/skills/builtin/grill-me/SKILL.md +0 -46
- package/dist/skills/builtin/jest-testing-expert/SKILL.md +0 -957
- package/dist/skills/builtin/nodejs-expert/SKILL.md +0 -192
- package/dist/skills/builtin/systematic-debugging/SKILL.md +0 -296
- package/dist/skills/builtin/test-driven-development/SKILL.md +0 -371
- package/dist/skills/builtin/typescript-expert/SKILL.md +0 -429
- package/dist/skills/builtin/web-scraping/SKILL.md +0 -422
- package/dist/skills/loader.d.ts +0 -49
- package/dist/skills/loader.d.ts.map +0 -1
- package/dist/skills/loader.js +0 -401
- package/dist/skills/loader.js.map +0 -1
- package/dist/styling/engine.d.ts +0 -39
- package/dist/styling/engine.d.ts.map +0 -1
- package/dist/styling/engine.js +0 -122
- package/dist/styling/engine.js.map +0 -1
- package/dist/styling/index.d.ts +0 -15
- package/dist/styling/index.d.ts.map +0 -1
- package/dist/styling/index.js +0 -40
- package/dist/styling/index.js.map +0 -1
- package/dist/styling/loader.d.ts +0 -9
- package/dist/styling/loader.d.ts.map +0 -1
- package/dist/styling/loader.js +0 -169
- package/dist/styling/loader.js.map +0 -1
- package/dist/styling/types.d.ts +0 -64
- package/dist/styling/types.d.ts.map +0 -1
- package/dist/styling/types.js +0 -12
- package/dist/styling/types.js.map +0 -1
- package/dist/subagent/chat.d.ts +0 -19
- package/dist/subagent/chat.d.ts.map +0 -1
- package/dist/subagent/chat.js +0 -279
- package/dist/subagent/chat.js.map +0 -1
- package/dist/subagent/context.d.ts +0 -9
- package/dist/subagent/context.d.ts.map +0 -1
- package/dist/subagent/context.js +0 -75
- package/dist/subagent/context.js.map +0 -1
- package/dist/subagent/definition.d.ts +0 -7
- package/dist/subagent/definition.d.ts.map +0 -1
- package/dist/subagent/definition.js +0 -26
- package/dist/subagent/definition.js.map +0 -1
- package/dist/subagent/errors.d.ts +0 -24
- package/dist/subagent/errors.d.ts.map +0 -1
- package/dist/subagent/errors.js +0 -85
- package/dist/subagent/errors.js.map +0 -1
- package/dist/subagent/validation.d.ts +0 -17
- package/dist/subagent/validation.d.ts.map +0 -1
- package/dist/subagent/validation.js +0 -83
- package/dist/subagent/validation.js.map +0 -1
- package/dist/tools/adapters/bash-to-fs.d.ts +0 -20
- package/dist/tools/adapters/bash-to-fs.d.ts.map +0 -1
- package/dist/tools/adapters/bash-to-fs.js +0 -74
- package/dist/tools/adapters/bash-to-fs.js.map +0 -1
- package/dist/tools/adapters/content-sanitizer.d.ts +0 -13
- package/dist/tools/adapters/content-sanitizer.d.ts.map +0 -1
- package/dist/tools/adapters/content-sanitizer.js +0 -73
- package/dist/tools/adapters/content-sanitizer.js.map +0 -1
- package/dist/tools/adapters/grounding-fixer.d.ts +0 -15
- package/dist/tools/adapters/grounding-fixer.d.ts.map +0 -1
- package/dist/tools/adapters/grounding-fixer.js +0 -57
- package/dist/tools/adapters/grounding-fixer.js.map +0 -1
- package/dist/tools/adapters/index.d.ts +0 -6
- package/dist/tools/adapters/index.d.ts.map +0 -1
- package/dist/tools/adapters/index.js +0 -5
- package/dist/tools/adapters/index.js.map +0 -1
- package/dist/tools/adapters/pipeline.d.ts +0 -34
- package/dist/tools/adapters/pipeline.d.ts.map +0 -1
- package/dist/tools/adapters/pipeline.js +0 -58
- package/dist/tools/adapters/pipeline.js.map +0 -1
- package/dist/tools/adapters/types.d.ts +0 -46
- package/dist/tools/adapters/types.d.ts.map +0 -1
- package/dist/tools/adapters/types.js +0 -2
- package/dist/tools/adapters/types.js.map +0 -1
- package/dist/tools/approve.d.ts +0 -27
- package/dist/tools/approve.d.ts.map +0 -1
- package/dist/tools/approve.js +0 -45
- package/dist/tools/approve.js.map +0 -1
- package/dist/tools/bash.d.ts +0 -25
- package/dist/tools/bash.d.ts.map +0 -1
- package/dist/tools/bash.js +0 -292
- package/dist/tools/bash.js.map +0 -1
- package/dist/tools/fs/copy-file.d.ts +0 -13
- package/dist/tools/fs/copy-file.d.ts.map +0 -1
- package/dist/tools/fs/copy-file.js +0 -54
- package/dist/tools/fs/copy-file.js.map +0 -1
- package/dist/tools/fs/create-dir.d.ts +0 -13
- package/dist/tools/fs/create-dir.d.ts.map +0 -1
- package/dist/tools/fs/create-dir.js +0 -44
- package/dist/tools/fs/create-dir.js.map +0 -1
- package/dist/tools/fs/delete-file.d.ts +0 -13
- package/dist/tools/fs/delete-file.d.ts.map +0 -1
- package/dist/tools/fs/delete-file.js +0 -52
- package/dist/tools/fs/delete-file.js.map +0 -1
- package/dist/tools/fs/edit-file.d.ts +0 -15
- package/dist/tools/fs/edit-file.d.ts.map +0 -1
- package/dist/tools/fs/edit-file.js +0 -95
- package/dist/tools/fs/edit-file.js.map +0 -1
- package/dist/tools/fs/file-info.d.ts +0 -13
- package/dist/tools/fs/file-info.d.ts.map +0 -1
- package/dist/tools/fs/file-info.js +0 -50
- package/dist/tools/fs/file-info.js.map +0 -1
- package/dist/tools/fs/glob-search.d.ts +0 -13
- package/dist/tools/fs/glob-search.d.ts.map +0 -1
- package/dist/tools/fs/glob-search.js +0 -112
- package/dist/tools/fs/glob-search.js.map +0 -1
- package/dist/tools/fs/grep-search.d.ts +0 -14
- package/dist/tools/fs/grep-search.d.ts.map +0 -1
- package/dist/tools/fs/grep-search.js +0 -135
- package/dist/tools/fs/grep-search.js.map +0 -1
- package/dist/tools/fs/list-dir.d.ts +0 -13
- package/dist/tools/fs/list-dir.d.ts.map +0 -1
- package/dist/tools/fs/list-dir.js +0 -74
- package/dist/tools/fs/list-dir.js.map +0 -1
- package/dist/tools/fs/move-file.d.ts +0 -13
- package/dist/tools/fs/move-file.d.ts.map +0 -1
- package/dist/tools/fs/move-file.js +0 -54
- package/dist/tools/fs/move-file.js.map +0 -1
- package/dist/tools/fs/path-utils.d.ts +0 -51
- package/dist/tools/fs/path-utils.d.ts.map +0 -1
- package/dist/tools/fs/path-utils.js +0 -103
- package/dist/tools/fs/path-utils.js.map +0 -1
- package/dist/tools/fs/read-file.d.ts +0 -13
- package/dist/tools/fs/read-file.d.ts.map +0 -1
- package/dist/tools/fs/read-file.js +0 -64
- package/dist/tools/fs/read-file.js.map +0 -1
- package/dist/tools/fs/tree.d.ts +0 -13
- package/dist/tools/fs/tree.d.ts.map +0 -1
- package/dist/tools/fs/tree.js +0 -89
- package/dist/tools/fs/tree.js.map +0 -1
- package/dist/tools/fs/types.d.ts +0 -14
- package/dist/tools/fs/types.d.ts.map +0 -1
- package/dist/tools/fs/types.js +0 -11
- package/dist/tools/fs/types.js.map +0 -1
- package/dist/tools/fs/write-file.d.ts +0 -14
- package/dist/tools/fs/write-file.d.ts.map +0 -1
- package/dist/tools/fs/write-file.js +0 -83
- package/dist/tools/fs/write-file.js.map +0 -1
- package/dist/tools/hooks.d.ts +0 -44
- package/dist/tools/hooks.d.ts.map +0 -1
- package/dist/tools/hooks.js +0 -217
- package/dist/tools/hooks.js.map +0 -1
- package/dist/tools/id-gen.d.ts +0 -4
- package/dist/tools/id-gen.d.ts.map +0 -1
- package/dist/tools/id-gen.js +0 -12
- package/dist/tools/id-gen.js.map +0 -1
- package/dist/tools/mcp.d.ts +0 -36
- package/dist/tools/mcp.d.ts.map +0 -1
- package/dist/tools/mcp.js +0 -93
- package/dist/tools/mcp.js.map +0 -1
- package/dist/tools/native/approve.d.ts +0 -11
- package/dist/tools/native/approve.d.ts.map +0 -1
- package/dist/tools/native/approve.js +0 -39
- package/dist/tools/native/approve.js.map +0 -1
- package/dist/tools/native/plan.d.ts +0 -10
- package/dist/tools/native/plan.d.ts.map +0 -1
- package/dist/tools/native/plan.js +0 -115
- package/dist/tools/native/plan.js.map +0 -1
- package/dist/tools/native/project-map.d.ts +0 -15
- package/dist/tools/native/project-map.d.ts.map +0 -1
- package/dist/tools/native/project-map.js +0 -203
- package/dist/tools/native/project-map.js.map +0 -1
- package/dist/tools/native/question.d.ts +0 -11
- package/dist/tools/native/question.d.ts.map +0 -1
- package/dist/tools/native/question.js +0 -41
- package/dist/tools/native/question.js.map +0 -1
- package/dist/tools/native/scaffold.d.ts +0 -5
- package/dist/tools/native/scaffold.d.ts.map +0 -1
- package/dist/tools/native/scaffold.js +0 -246
- package/dist/tools/native/scaffold.js.map +0 -1
- package/dist/tools/native/theme.d.ts +0 -10
- package/dist/tools/native/theme.d.ts.map +0 -1
- package/dist/tools/native/theme.js +0 -101
- package/dist/tools/native/theme.js.map +0 -1
- package/dist/tools/native/todo.d.ts +0 -10
- package/dist/tools/native/todo.d.ts.map +0 -1
- package/dist/tools/native/todo.js +0 -58
- package/dist/tools/native/todo.js.map +0 -1
- package/dist/tools/native/user-profile.d.ts +0 -10
- package/dist/tools/native/user-profile.d.ts.map +0 -1
- package/dist/tools/native/user-profile.js +0 -58
- package/dist/tools/native/user-profile.js.map +0 -1
- package/dist/tools/parse-tool-call.d.ts +0 -11
- package/dist/tools/parse-tool-call.d.ts.map +0 -1
- package/dist/tools/parse-tool-call.js +0 -87
- package/dist/tools/parse-tool-call.js.map +0 -1
- package/dist/tools/plan.d.ts +0 -40
- package/dist/tools/plan.d.ts.map +0 -1
- package/dist/tools/plan.js +0 -143
- package/dist/tools/plan.js.map +0 -1
- package/dist/tools/question.d.ts +0 -33
- package/dist/tools/question.d.ts.map +0 -1
- package/dist/tools/question.js +0 -62
- package/dist/tools/question.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -37
- package/dist/tools/registry.d.ts.map +0 -1
- package/dist/tools/registry.js +0 -97
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/sanitizer.d.ts +0 -30
- package/dist/tools/sanitizer.d.ts.map +0 -1
- package/dist/tools/sanitizer.js +0 -77
- package/dist/tools/sanitizer.js.map +0 -1
- package/dist/tools/subagent.d.ts +0 -39
- package/dist/tools/subagent.d.ts.map +0 -1
- package/dist/tools/subagent.js +0 -225
- package/dist/tools/subagent.js.map +0 -1
- package/dist/tools/syntax-check.d.ts +0 -32
- package/dist/tools/syntax-check.d.ts.map +0 -1
- package/dist/tools/syntax-check.js +0 -272
- package/dist/tools/syntax-check.js.map +0 -1
- package/dist/tools/todo.d.ts +0 -28
- package/dist/tools/todo.d.ts.map +0 -1
- package/dist/tools/todo.js +0 -125
- package/dist/tools/todo.js.map +0 -1
- package/dist/tools/types.d.ts +0 -51
- package/dist/tools/types.d.ts.map +0 -1
- package/dist/tools/types.js +0 -2
- package/dist/tools/types.js.map +0 -1
- package/dist/tools/web-browse.d.ts +0 -5
- package/dist/tools/web-browse.d.ts.map +0 -1
- package/dist/tools/web-browse.js +0 -757
- package/dist/tools/web-browse.js.map +0 -1
- package/dist/tools/web-fetch.d.ts +0 -19
- package/dist/tools/web-fetch.d.ts.map +0 -1
- package/dist/tools/web-fetch.js +0 -90
- package/dist/tools/web-fetch.js.map +0 -1
- package/dist/tools/web-search.d.ts +0 -19
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/web-search.js +0 -97
- package/dist/tools/web-search.js.map +0 -1
- package/dist/ui/components/status-bar.d.ts +0 -11
- package/dist/ui/components/status-bar.d.ts.map +0 -1
- package/dist/ui/components/status-bar.js +0 -20
- package/dist/ui/components/status-bar.js.map +0 -1
- package/dist/ui/index.d.ts +0 -8
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js +0 -9
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/ink/components/App.d.ts +0 -98
- package/dist/ui/ink/components/App.d.ts.map +0 -1
- package/dist/ui/ink/components/App.js +0 -212
- package/dist/ui/ink/components/App.js.map +0 -1
- package/dist/ui/ink/components/Conversation.d.ts +0 -20
- package/dist/ui/ink/components/Conversation.d.ts.map +0 -1
- package/dist/ui/ink/components/Conversation.js +0 -15
- package/dist/ui/ink/components/Conversation.js.map +0 -1
- package/dist/ui/ink/components/MessageBlock.d.ts +0 -27
- package/dist/ui/ink/components/MessageBlock.d.ts.map +0 -1
- package/dist/ui/ink/components/MessageBlock.js +0 -41
- package/dist/ui/ink/components/MessageBlock.js.map +0 -1
- package/dist/ui/ink/components/PromptInput.d.ts +0 -25
- package/dist/ui/ink/components/PromptInput.d.ts.map +0 -1
- package/dist/ui/ink/components/PromptInput.js +0 -167
- package/dist/ui/ink/components/PromptInput.js.map +0 -1
- package/dist/ui/ink/components/SelectInput.d.ts +0 -9
- package/dist/ui/ink/components/SelectInput.d.ts.map +0 -1
- package/dist/ui/ink/components/SelectInput.js +0 -30
- package/dist/ui/ink/components/SelectInput.js.map +0 -1
- package/dist/ui/ink/components/StatusBar.d.ts +0 -14
- package/dist/ui/ink/components/StatusBar.d.ts.map +0 -1
- package/dist/ui/ink/components/StatusBar.js +0 -20
- package/dist/ui/ink/components/StatusBar.js.map +0 -1
- package/dist/ui/ink/components/StreamBlock.d.ts +0 -8
- package/dist/ui/ink/components/StreamBlock.d.ts.map +0 -1
- package/dist/ui/ink/components/StreamBlock.js +0 -15
- package/dist/ui/ink/components/StreamBlock.js.map +0 -1
- package/dist/ui/ink/components/Tags.d.ts +0 -26
- package/dist/ui/ink/components/Tags.d.ts.map +0 -1
- package/dist/ui/ink/components/Tags.js +0 -37
- package/dist/ui/ink/components/Tags.js.map +0 -1
- package/dist/ui/ink/components/ToolCallBlock.d.ts +0 -31
- package/dist/ui/ink/components/ToolCallBlock.d.ts.map +0 -1
- package/dist/ui/ink/components/ToolCallBlock.js +0 -17
- package/dist/ui/ink/components/ToolCallBlock.js.map +0 -1
- package/dist/ui/ink/renderer.d.ts +0 -69
- package/dist/ui/ink/renderer.d.ts.map +0 -1
- package/dist/ui/ink/renderer.js +0 -142
- package/dist/ui/ink/renderer.js.map +0 -1
- package/dist/ui/ink/theme.d.ts +0 -28
- package/dist/ui/ink/theme.d.ts.map +0 -1
- package/dist/ui/ink/theme.js +0 -45
- package/dist/ui/ink/theme.js.map +0 -1
- package/dist/ui/md-formatter.d.ts +0 -16
- package/dist/ui/md-formatter.d.ts.map +0 -1
- package/dist/ui/md-formatter.js +0 -448
- package/dist/ui/md-formatter.js.map +0 -1
- package/dist/ui/readline-renderer.d.ts +0 -45
- package/dist/ui/readline-renderer.d.ts.map +0 -1
- package/dist/ui/readline-renderer.js +0 -181
- package/dist/ui/readline-renderer.js.map +0 -1
- package/dist/ui/renderer.d.ts +0 -66
- package/dist/ui/renderer.d.ts.map +0 -1
- package/dist/ui/renderer.js +0 -16
- package/dist/ui/renderer.js.map +0 -1
- package/dist/ui/subagent-renderer.d.ts +0 -58
- package/dist/ui/subagent-renderer.d.ts.map +0 -1
- package/dist/ui/subagent-renderer.js +0 -100
- package/dist/ui/subagent-renderer.js.map +0 -1
- package/dist/updater.d.ts +0 -15
- package/dist/updater.d.ts.map +0 -1
- package/dist/updater.js +0 -166
- package/dist/updater.js.map +0 -1
package/dist/repl/commands.js
DELETED
|
@@ -1,1070 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync, } from "node:fs";
|
|
2
|
-
import { join, basename } from "node:path";
|
|
3
|
-
import { globSync } from "node:fs";
|
|
4
|
-
import { execSync } from "node:child_process";
|
|
5
|
-
import { executeBash } from "../tools/bash.js";
|
|
6
|
-
import { runAgentLoop } from "../agent/loop.js";
|
|
7
|
-
import { loadMemory, saveMemory, searchMemory, loadAllMemory, ensureMemoryDir, removeMemoryEntry, exportMemory, } from "../agent/memory.js";
|
|
8
|
-
import { loadProfile, appendNote, } from "../agent/user-profile.js";
|
|
9
|
-
import { listSkillsBySource } from "../skills/loader.js";
|
|
10
|
-
import { listSessions, loadSession, createNamedSession, createAutoSession, formatSessionList, } from "../session/store.js";
|
|
11
|
-
import { rebuildCodeIndex, rebuildProjectMap, getOrBuildCodeIndex, getOrBuildProjectMap, } from "../indexer/cache.js";
|
|
12
|
-
import { getTheme, listThemes, switchTheme } from "../styling/index.js";
|
|
13
|
-
import { loadThemeConfig, installTheme, removeTheme, } from "../styling/loader.js";
|
|
14
|
-
import { loadConfig, saveConfig } from "../config/config.js";
|
|
15
|
-
import { logInfo } from "../logger.js";
|
|
16
|
-
/** Возвращает список всех доступных слэш-команд */
|
|
17
|
-
export function getSlashCommands() {
|
|
18
|
-
return [
|
|
19
|
-
{ name: "exit", description: "exit MMA", handler: cmdExit },
|
|
20
|
-
{ name: "quit", description: "exit MMA", handler: cmdExit },
|
|
21
|
-
{ name: "help", description: "show help", handler: cmdHelp },
|
|
22
|
-
{ name: "bash", description: "run shell command", handler: cmdBash },
|
|
23
|
-
{ name: "read", description: "display file", handler: cmdRead },
|
|
24
|
-
{
|
|
25
|
-
name: "write",
|
|
26
|
-
description: "write file (end with EOF)",
|
|
27
|
-
handler: cmdWrite,
|
|
28
|
-
},
|
|
29
|
-
{ name: "edit", description: "replace line in file", handler: cmdEdit },
|
|
30
|
-
{ name: "find", description: "find files by glob", handler: cmdFind },
|
|
31
|
-
{ name: "search", description: "search file contents", handler: cmdSearch },
|
|
32
|
-
{ name: "git", description: "git operations", handler: cmdGit },
|
|
33
|
-
{ name: "memory", description: "memory management", handler: cmdMemory },
|
|
34
|
-
{ name: "skill", description: "list skills", handler: cmdSkill },
|
|
35
|
-
{ name: "sessions", description: "list sessions", handler: cmdSessions },
|
|
36
|
-
{ name: "resume", description: "resume session", handler: cmdResume },
|
|
37
|
-
{ name: "save", description: "save session", handler: cmdSave },
|
|
38
|
-
{
|
|
39
|
-
name: "clear",
|
|
40
|
-
description: "clear screen (visual only)",
|
|
41
|
-
handler: cmdClear,
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: "new",
|
|
45
|
-
description: "reset session (clear context)",
|
|
46
|
-
handler: cmdNew,
|
|
47
|
-
},
|
|
48
|
-
{ name: "stop", description: "stop agent loop", handler: cmdStop },
|
|
49
|
-
{
|
|
50
|
-
name: "init",
|
|
51
|
-
description: "initialize project & create AGENTS.md",
|
|
52
|
-
handler: cmdInit,
|
|
53
|
-
},
|
|
54
|
-
{ name: "index", description: "index management", handler: cmdIndex },
|
|
55
|
-
{
|
|
56
|
-
name: "theme",
|
|
57
|
-
description: "theme management (list/switch/show/install/create/remove)",
|
|
58
|
-
handler: cmdTheme,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: "profile",
|
|
62
|
-
description: "show/edit user profile",
|
|
63
|
-
handler: cmdProfile,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "tools",
|
|
67
|
-
description: "list available agent tools",
|
|
68
|
-
handler: cmdTools,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: "export",
|
|
72
|
-
description: "export session (normal or debug)",
|
|
73
|
-
handler: cmdExport,
|
|
74
|
-
},
|
|
75
|
-
];
|
|
76
|
-
}
|
|
77
|
-
/** Парсит строку ввода на слэш-команду и аргументы */
|
|
78
|
-
export function parseSlashCommand(line) {
|
|
79
|
-
if (!line.startsWith("/"))
|
|
80
|
-
return null;
|
|
81
|
-
const spaceIdx = line.indexOf(" ");
|
|
82
|
-
const cmd = spaceIdx === -1 ? line.slice(1) : line.slice(1, spaceIdx);
|
|
83
|
-
const args = spaceIdx === -1 ? "" : line.slice(spaceIdx + 1);
|
|
84
|
-
return { cmd, args };
|
|
85
|
-
}
|
|
86
|
-
function cmdExit(_args, ctx) {
|
|
87
|
-
if (ctx.conversationHistory.length > 0) {
|
|
88
|
-
createAutoSession(ctx.conversationHistory, ctx.modelLabel, process.cwd(), {
|
|
89
|
-
totalTokens: 0,
|
|
90
|
-
compactCount: 0,
|
|
91
|
-
});
|
|
92
|
-
ctx.renderer.writeSuccess("Session auto-saved.");
|
|
93
|
-
}
|
|
94
|
-
ctx.renderer.writeDim("Bye!");
|
|
95
|
-
ctx.renderer.destroy();
|
|
96
|
-
}
|
|
97
|
-
function formatHelpCmd(theme, cmd) {
|
|
98
|
-
const parts = cmd.split(/\s+/);
|
|
99
|
-
const cmdName = parts[0];
|
|
100
|
-
const rest = parts.slice(1).join(" ");
|
|
101
|
-
const styled = cmdName.startsWith("/")
|
|
102
|
-
? theme.toolName(cmdName)
|
|
103
|
-
: theme.toolName(cmdName);
|
|
104
|
-
if (!rest)
|
|
105
|
-
return styled;
|
|
106
|
-
return `${styled} ${theme.dim(rest)}`;
|
|
107
|
-
}
|
|
108
|
-
function cmdHelp(_args, ctx) {
|
|
109
|
-
const theme = getTheme();
|
|
110
|
-
const msgCount = ctx.conversationHistory.length;
|
|
111
|
-
const cwd = process.cwd();
|
|
112
|
-
ctx.renderer.writeDim(` в”Ђв”Ђ session info в”Ђв”Ђ`);
|
|
113
|
-
if (ctx.sessionId) {
|
|
114
|
-
ctx.renderer.writeDim(` session: ${ctx.sessionId}`);
|
|
115
|
-
}
|
|
116
|
-
ctx.renderer.writeDim(` model: ${ctx.modelLabel}`);
|
|
117
|
-
ctx.renderer.writeDim(` mode: ${ctx.currentMode || "base"}`);
|
|
118
|
-
ctx.renderer.writeDim(` messages: ${msgCount}`);
|
|
119
|
-
ctx.renderer.writeDim(` cwd: ${cwd}`);
|
|
120
|
-
ctx.renderer.writeNewline();
|
|
121
|
-
const slashHelp = [
|
|
122
|
-
{ cmd: "/bash <cmd>", desc: "run shell command" },
|
|
123
|
-
{ cmd: "/read <file>", desc: "display file with line numbers" },
|
|
124
|
-
{
|
|
125
|
-
cmd: "/edit <file> <n>",
|
|
126
|
-
desc: "replace line N in file with rest of args",
|
|
127
|
-
},
|
|
128
|
-
{ cmd: "/write <file>", desc: "write file (end with EOF on its own line)" },
|
|
129
|
-
{ cmd: "/find <pattern>", desc: "find files by glob pattern" },
|
|
130
|
-
{ cmd: "/search <pattern>", desc: "search file contents" },
|
|
131
|
-
{ cmd: "/git <args>", desc: "git operations" },
|
|
132
|
-
{
|
|
133
|
-
cmd: "/memory",
|
|
134
|
-
desc: "memory management (show/add/search/remove/export)",
|
|
135
|
-
},
|
|
136
|
-
{ cmd: "/skill", desc: "list installed skills" },
|
|
137
|
-
{ cmd: "/tools", desc: "list agent tools" },
|
|
138
|
-
{ cmd: "/sessions", desc: "list saved sessions" },
|
|
139
|
-
{ cmd: "/resume <id>", desc: "resume a session" },
|
|
140
|
-
{ cmd: "/save [name]", desc: "save current session" },
|
|
141
|
-
{ cmd: "/clear", desc: "clear screen (visual only)" },
|
|
142
|
-
{ cmd: "/new", desc: "reset session (clear history)" },
|
|
143
|
-
{ cmd: "/export [mode]", desc: "export session (normal or debug)" },
|
|
144
|
-
{ cmd: "/init", desc: "analyze project & create AGENTS.md" },
|
|
145
|
-
{ cmd: "/index [cmd]", desc: "index status/show/map/rebuild" },
|
|
146
|
-
{ cmd: "/profile [note]", desc: "show profile or add note" },
|
|
147
|
-
{ cmd: "/profile name <n>", desc: "save your name" },
|
|
148
|
-
{ cmd: "/profile show", desc: "show profile content" },
|
|
149
|
-
{ cmd: "/mode fast|base|pro", desc: "switch agent mode" },
|
|
150
|
-
{ cmd: "/stop", desc: "stop agent loop" },
|
|
151
|
-
{ cmd: "/exit", desc: "exit MMA" },
|
|
152
|
-
];
|
|
153
|
-
ctx.renderer.writeLine(` ${theme.highlight("/ commands")}`);
|
|
154
|
-
for (const entry of slashHelp) {
|
|
155
|
-
ctx.renderer.writeLine(` ${formatHelpCmd(theme, entry.cmd)} ${theme.dim(`— ${entry.desc}`)}`);
|
|
156
|
-
}
|
|
157
|
-
ctx.renderer.writeNewline();
|
|
158
|
-
const cliHelp = [
|
|
159
|
-
{ cmd: "mma provider list", desc: "list providers" },
|
|
160
|
-
{
|
|
161
|
-
cmd: "mma provider add <name> <url>",
|
|
162
|
-
desc: "add provider (Ollama, vLLM, Together...)",
|
|
163
|
-
},
|
|
164
|
-
{ cmd: "mma provider use <name>", desc: "switch active provider" },
|
|
165
|
-
{ cmd: "mma provider remove <name>", desc: "remove provider" },
|
|
166
|
-
{ cmd: "mma model list", desc: "list models" },
|
|
167
|
-
{
|
|
168
|
-
cmd: "mma model add <name> <id> <ctx>",
|
|
169
|
-
desc: "add model (e.g. qwen3.5-9b ... 32768)",
|
|
170
|
-
},
|
|
171
|
-
{ cmd: "mma model use <name>", desc: "switch active model" },
|
|
172
|
-
{ cmd: "mma model params [name]", desc: "show model parameters" },
|
|
173
|
-
{
|
|
174
|
-
cmd: "mma model set <name> k=v",
|
|
175
|
-
desc: "change parameter (temperature=0.3)",
|
|
176
|
-
},
|
|
177
|
-
{ cmd: "mma config show", desc: "show full configuration" },
|
|
178
|
-
{ cmd: "mma config reset", desc: "reset to defaults" },
|
|
179
|
-
{ cmd: "mma update", desc: "check for updates" },
|
|
180
|
-
{ cmd: "mma update install", desc: "install latest version" },
|
|
181
|
-
];
|
|
182
|
-
ctx.renderer.writeLine(` ${theme.highlight("CLI commands")} ${theme.dim("(exit REPL, then run)")}`);
|
|
183
|
-
for (const entry of cliHelp) {
|
|
184
|
-
ctx.renderer.writeLine(` ${formatHelpCmd(theme, entry.cmd)} ${theme.dim(`— ${entry.desc}`)}`);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
async function cmdBash(args, ctx) {
|
|
188
|
-
const result = await executeBash(args);
|
|
189
|
-
if (result.stdout)
|
|
190
|
-
ctx.renderer.write(result.stdout);
|
|
191
|
-
if (result.stderr)
|
|
192
|
-
ctx.renderer.writeError(result.stderr);
|
|
193
|
-
}
|
|
194
|
-
function cmdRead(args, ctx) {
|
|
195
|
-
try {
|
|
196
|
-
const content = readFileSync(args, "utf-8");
|
|
197
|
-
const lines = content.split("\n");
|
|
198
|
-
const maxLines = 200;
|
|
199
|
-
ctx.renderer.writeNewline();
|
|
200
|
-
const shown = lines.slice(0, maxLines);
|
|
201
|
-
ctx.renderer.writeFileOutput(shown);
|
|
202
|
-
if (lines.length > maxLines) {
|
|
203
|
-
ctx.renderer.writeDim(` ... (${lines.length - maxLines} more lines)`);
|
|
204
|
-
}
|
|
205
|
-
ctx.renderer.writeNewline();
|
|
206
|
-
}
|
|
207
|
-
catch (e) {
|
|
208
|
-
ctx.renderer.writeError(e.message);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
let _currentWritePath = null;
|
|
212
|
-
let _writeBuffer = [];
|
|
213
|
-
export function getWriteState() {
|
|
214
|
-
return { path: _currentWritePath, buffer: _writeBuffer };
|
|
215
|
-
}
|
|
216
|
-
export function clearWriteState() {
|
|
217
|
-
_currentWritePath = null;
|
|
218
|
-
_writeBuffer = [];
|
|
219
|
-
}
|
|
220
|
-
export function isWriteMode() {
|
|
221
|
-
return _currentWritePath !== null;
|
|
222
|
-
}
|
|
223
|
-
function cmdWrite(args, ctx) {
|
|
224
|
-
if (!args) {
|
|
225
|
-
ctx.renderer.writeInfo(" Usage: /write <file> (then type content, end with EOF)");
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
_currentWritePath = args;
|
|
229
|
-
ctx.renderer.writeDim(" Type your content. End with EOF on its own line:");
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
export function handleWriteLine(line, renderer) {
|
|
233
|
-
if (line.trim() === "EOF") {
|
|
234
|
-
const theme = getTheme();
|
|
235
|
-
try {
|
|
236
|
-
writeFileSync(_currentWritePath, _writeBuffer.join("\n"), "utf-8");
|
|
237
|
-
renderer.writeSuccess(`written to ${theme.filePath(_currentWritePath)}`);
|
|
238
|
-
}
|
|
239
|
-
catch (e) {
|
|
240
|
-
renderer.writeError(theme.error(e.message));
|
|
241
|
-
}
|
|
242
|
-
_currentWritePath = null;
|
|
243
|
-
_writeBuffer = [];
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
_writeBuffer.push(line);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
function cmdEdit(args, ctx) {
|
|
250
|
-
const parts = args.split(/\s+/);
|
|
251
|
-
if (parts.length < 3) {
|
|
252
|
-
ctx.renderer.writeInfo(" Usage: /edit <file> <line> <new content>");
|
|
253
|
-
ctx.renderer.writeInfo(" Example: /edit src/index.ts 5 const x = 1;");
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
const [filePath, lineStr, ...rest] = parts;
|
|
257
|
-
const lineNum = parseInt(lineStr, 10);
|
|
258
|
-
if (isNaN(lineNum) || lineNum < 1) {
|
|
259
|
-
ctx.renderer.writeDim(" Line number must be a positive integer");
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
const newContent = rest.join(" ");
|
|
263
|
-
try {
|
|
264
|
-
const content = readFileSync(filePath, "utf-8");
|
|
265
|
-
const lines = content.split("\n");
|
|
266
|
-
if (lineNum > lines.length) {
|
|
267
|
-
ctx.renderer.writeWarning(` File has only ${lines.length} lines`);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
lines[lineNum - 1] = newContent;
|
|
271
|
-
writeFileSync(filePath, lines.join("\n"), "utf-8");
|
|
272
|
-
const theme = getTheme();
|
|
273
|
-
ctx.renderer.writeSuccess(`Line ${lineNum} updated in ${theme.filePath(filePath)}`);
|
|
274
|
-
}
|
|
275
|
-
catch (e) {
|
|
276
|
-
ctx.renderer.writeError(e.message);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
function cmdFind(args, ctx) {
|
|
280
|
-
try {
|
|
281
|
-
const IGNORE = [
|
|
282
|
-
"node_modules",
|
|
283
|
-
".git",
|
|
284
|
-
"dist",
|
|
285
|
-
".mma",
|
|
286
|
-
"build",
|
|
287
|
-
"__pycache__",
|
|
288
|
-
];
|
|
289
|
-
const fixedPattern = args.includes("/") || args.includes("\\") ? args : `**/${args}`;
|
|
290
|
-
const results = globSync(fixedPattern).filter((f) => !f.split(/[/\\]/).some((p) => IGNORE.includes(p)));
|
|
291
|
-
if (results.length === 0) {
|
|
292
|
-
ctx.renderer.writeDim(" No matches");
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
const theme = getTheme();
|
|
296
|
-
for (const f of results) {
|
|
297
|
-
ctx.renderer.writeLine(`${theme.indent}${theme.filePath(f)}`);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
catch (e) {
|
|
301
|
-
ctx.renderer.writeError(e.message);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
function cmdSearch(args, ctx) {
|
|
305
|
-
try {
|
|
306
|
-
const result = execSync(`findstr /s /n /c:"${args}" *.ts *.js *.tsx *.jsx *.json *.md`, { encoding: "utf-8", timeout: 10000 });
|
|
307
|
-
const allLines = result.trim().split("\n");
|
|
308
|
-
const lines = allLines.slice(0, 30);
|
|
309
|
-
if (lines.length === 0 || (lines.length === 1 && lines[0] === "")) {
|
|
310
|
-
ctx.renderer.writeDim(" No matches");
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
const theme = getTheme();
|
|
314
|
-
for (const line of lines) {
|
|
315
|
-
const match = line.match(/^([^:]+):(\d+):(.*)/);
|
|
316
|
-
if (match) {
|
|
317
|
-
ctx.renderer.writeLine(` ${theme.filePath(match[1])}${theme.dim(":")}${theme.lineNumbers(match[2])}${theme.dim(":")}${match[3]}`);
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
ctx.renderer.writeLine(`${theme.indent}${line}`);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
if (allLines.length > 30) {
|
|
324
|
-
ctx.renderer.writeDim(` ... (${allLines.length - 30} more)`);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
catch (e) {
|
|
328
|
-
if (e.status === 1) {
|
|
329
|
-
ctx.renderer.writeDim(" No matches");
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
ctx.renderer.writeError(e.message);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
async function cmdGit(args, ctx) {
|
|
337
|
-
const result = await executeBash(`git ${args}`);
|
|
338
|
-
if (result.stdout)
|
|
339
|
-
ctx.renderer.write(result.stdout);
|
|
340
|
-
if (result.stderr)
|
|
341
|
-
ctx.renderer.writeError(result.stderr);
|
|
342
|
-
}
|
|
343
|
-
function cmdMemory(args, ctx) {
|
|
344
|
-
ensureMemoryDir();
|
|
345
|
-
const theme = getTheme();
|
|
346
|
-
if (!args.trim()) {
|
|
347
|
-
const summary = loadAllMemory();
|
|
348
|
-
if (summary) {
|
|
349
|
-
ctx.renderer.writeLine(summary);
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
ctx.renderer.writeDim(" Project memory is empty. Use /memory add <type> <text>");
|
|
353
|
-
}
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
const parts = args.trim().split(/\s+/);
|
|
357
|
-
const subcommand = parts[0];
|
|
358
|
-
const rest = parts.slice(1);
|
|
359
|
-
const type = rest[0] || "";
|
|
360
|
-
const text = rest.slice(1).join(" ") || "";
|
|
361
|
-
switch (subcommand) {
|
|
362
|
-
case "show": {
|
|
363
|
-
if (!type) {
|
|
364
|
-
ctx.renderer.writeInfo(" Usage: /memory show <type> (project|conventions|decisions|errors|history)");
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
const content = loadMemory(type);
|
|
368
|
-
ctx.renderer.writeNewline();
|
|
369
|
-
ctx.renderer.writeLine(content);
|
|
370
|
-
ctx.renderer.writeNewline();
|
|
371
|
-
break;
|
|
372
|
-
}
|
|
373
|
-
case "add": {
|
|
374
|
-
if (!type || !text) {
|
|
375
|
-
ctx.renderer.writeInfo(" Usage: /memory add <type> <text>");
|
|
376
|
-
ctx.renderer.writeInfo(" Types: project, conventions, decisions, errors, history");
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
saveMemory(type, text.slice(0, 60), text);
|
|
380
|
-
ctx.renderer.writeSuccess(`Saved to ${theme.filePath(`.mma/memory/${type}.md`)}`);
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
case "search": {
|
|
384
|
-
if (!type) {
|
|
385
|
-
ctx.renderer.writeInfo(" Usage: /memory search <query>");
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
const results = searchMemory(type);
|
|
389
|
-
if (results.length === 0) {
|
|
390
|
-
ctx.renderer.writeDim(" No matches");
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
ctx.renderer.writeInfo(` Found ${results.length} matches:`);
|
|
394
|
-
for (const r of results) {
|
|
395
|
-
ctx.renderer.writeLine(` ${theme.highlight(`[${r.type}]`)} ${theme.dim(r.match)}`);
|
|
396
|
-
}
|
|
397
|
-
break;
|
|
398
|
-
}
|
|
399
|
-
case "remove": {
|
|
400
|
-
if (!type) {
|
|
401
|
-
ctx.renderer.writeInfo(" Usage: /memory remove <type> <line-number>");
|
|
402
|
-
ctx.renderer.writeInfo(" First use /memory show <type> to see entries with line numbers.");
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
const lineNum = parseInt(text, 10);
|
|
406
|
-
if (isNaN(lineNum) || lineNum < 1) {
|
|
407
|
-
ctx.renderer.writeDim(" Line number must be a positive integer");
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
const removed = removeMemoryEntry(type, lineNum);
|
|
411
|
-
if (removed) {
|
|
412
|
-
ctx.renderer.writeSuccess(`Entry removed from ${theme.filePath(`${type}.md`)}`);
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
ctx.renderer.writeError(" Could not remove entry (line number out of range?)");
|
|
416
|
-
}
|
|
417
|
-
break;
|
|
418
|
-
}
|
|
419
|
-
case "export": {
|
|
420
|
-
const exported = exportMemory();
|
|
421
|
-
if (exported) {
|
|
422
|
-
ctx.renderer.writeSuccess(`Memory exported to ${theme.filePath(exported)}`);
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
ctx.renderer.writeDim(" No memory to export");
|
|
426
|
-
}
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
default: {
|
|
430
|
-
ctx.renderer.writeInfo(" Usage: /memory [show <type>|add <type> <text>|search <query>|remove <type> <line>|export]");
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
function cmdSkill(args, ctx) {
|
|
435
|
-
const subcmd = args.trim() || "list";
|
|
436
|
-
const theme = getTheme();
|
|
437
|
-
switch (subcmd) {
|
|
438
|
-
case "list": {
|
|
439
|
-
const bySource = listSkillsBySource(process.cwd());
|
|
440
|
-
const total = bySource.builtin.length +
|
|
441
|
-
bySource.project.length +
|
|
442
|
-
bySource.global.length;
|
|
443
|
-
if (total === 0) {
|
|
444
|
-
ctx.renderer.writeDim(" No skills available.");
|
|
445
|
-
ctx.renderer.writeDim(" Place skills in .claude/skills/<name>/SKILL.md or install via npm.");
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
ctx.renderer.writeInfo(` Skills (${total} total):`);
|
|
449
|
-
if (bySource.builtin.length > 0) {
|
|
450
|
-
ctx.renderer.writeLine(` ${theme.info("built-in:")}`);
|
|
451
|
-
for (const s of bySource.builtin)
|
|
452
|
-
ctx.renderer.writeLine(` ${theme.toolName(`@${s}`)}`);
|
|
453
|
-
}
|
|
454
|
-
if (bySource.project.length > 0) {
|
|
455
|
-
ctx.renderer.writeLine(` ${theme.info("project:")}`);
|
|
456
|
-
for (const s of bySource.project)
|
|
457
|
-
ctx.renderer.writeLine(` ${theme.toolName(`@${s}`)}`);
|
|
458
|
-
}
|
|
459
|
-
if (bySource.global.length > 0) {
|
|
460
|
-
ctx.renderer.writeLine(` ${theme.info("global:")}`);
|
|
461
|
-
for (const s of bySource.global)
|
|
462
|
-
ctx.renderer.writeLine(` ${theme.toolName(`@${s}`)}`);
|
|
463
|
-
}
|
|
464
|
-
ctx.renderer.writeDim(` ${theme.dim("Reference:")} ${theme.symbolName("@skill-name")}`);
|
|
465
|
-
break;
|
|
466
|
-
}
|
|
467
|
-
default:
|
|
468
|
-
ctx.renderer.writeInfo(" Usage: /skill [list]");
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
function cmdTools(_args, ctx) {
|
|
472
|
-
const defs = ctx.registry.getDefinitions();
|
|
473
|
-
const theme = getTheme();
|
|
474
|
-
const categories = {
|
|
475
|
-
native: {
|
|
476
|
-
names: new Set(["subagent", "scaffold", "project_map"]),
|
|
477
|
-
color: (s) => theme.toolName(s),
|
|
478
|
-
},
|
|
479
|
-
bash: { names: new Set(["bash"]), color: (s) => theme.symbolName(s) },
|
|
480
|
-
fs: {
|
|
481
|
-
names: new Set([
|
|
482
|
-
"read_file",
|
|
483
|
-
"write_file",
|
|
484
|
-
"edit_file",
|
|
485
|
-
"list_dir",
|
|
486
|
-
"create_dir",
|
|
487
|
-
"delete_file",
|
|
488
|
-
"copy_file",
|
|
489
|
-
"move_file",
|
|
490
|
-
"file_info",
|
|
491
|
-
"glob_search",
|
|
492
|
-
"grep_search",
|
|
493
|
-
"tree",
|
|
494
|
-
]),
|
|
495
|
-
color: (s) => theme.filePath(s),
|
|
496
|
-
},
|
|
497
|
-
web: {
|
|
498
|
-
names: new Set(["web_search", "web_fetch", "web_browse"]),
|
|
499
|
-
color: (s) => theme.link(s),
|
|
500
|
-
},
|
|
501
|
-
};
|
|
502
|
-
const categoryMeta = [
|
|
503
|
-
{ key: "native", label: "native" },
|
|
504
|
-
{ key: "bash", label: "exec" },
|
|
505
|
-
{ key: "fs", label: "files" },
|
|
506
|
-
{ key: "web", label: "web" },
|
|
507
|
-
];
|
|
508
|
-
ctx.renderer.writeNewline();
|
|
509
|
-
ctx.renderer.writeInfo(` tools (${defs.length}):`);
|
|
510
|
-
for (const meta of categoryMeta) {
|
|
511
|
-
const cat = categories[meta.key];
|
|
512
|
-
const items = defs.filter((d) => cat.names.has(d.function.name));
|
|
513
|
-
if (items.length === 0)
|
|
514
|
-
continue;
|
|
515
|
-
ctx.renderer.writeLine(` ${theme.dim(meta.label + ":")}`);
|
|
516
|
-
for (const d of items) {
|
|
517
|
-
const desc = d.function.description.split("\n")[0];
|
|
518
|
-
const shortDesc = desc.length > 55 ? desc.slice(0, 52) + "…" : desc;
|
|
519
|
-
ctx.renderer.writeLine(` ${cat.color(d.function.name)} ${theme.dim("—")} ${theme.dim(shortDesc)}`);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
ctx.renderer.writeNewline();
|
|
523
|
-
ctx.renderer.writeLine(theme.dim(` details: /help`));
|
|
524
|
-
}
|
|
525
|
-
function cmdSessions(_args, ctx) {
|
|
526
|
-
const sessions = listSessions();
|
|
527
|
-
ctx.renderer.writeLine(formatSessionList(sessions));
|
|
528
|
-
}
|
|
529
|
-
async function cmdResume(args, ctx) {
|
|
530
|
-
const theme = getTheme();
|
|
531
|
-
if (!args.trim()) {
|
|
532
|
-
ctx.renderer.writeInfo(" Usage: /resume <session-id>");
|
|
533
|
-
ctx.renderer.writeInfo(" Use /sessions to see available sessions.");
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
const session = loadSession(args.trim());
|
|
537
|
-
if (!session) {
|
|
538
|
-
ctx.renderer.writeError(` Session ${theme.highlight(args.trim())} not found.`);
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
ctx.renderer.clear();
|
|
542
|
-
ctx.renderer.writeInfo(` Resumed session: ${theme.highlight(session.id)} (${session.messages.length} messages)`);
|
|
543
|
-
ctx.renderer.writeDim(` Provider: ${session.provider}`);
|
|
544
|
-
ctx.renderer.writeNewline();
|
|
545
|
-
// Display previous conversation and rebuild history
|
|
546
|
-
ctx.history.length = 0;
|
|
547
|
-
const displayMsgs = session.messages.filter((m) => m.role !== "system");
|
|
548
|
-
for (const msg of displayMsgs) {
|
|
549
|
-
ctx.renderer.writeNewline();
|
|
550
|
-
ctx.renderer.writeDim("в”Ђ".repeat(40));
|
|
551
|
-
const tag = msg.role === "user" ? "user" : "assistant";
|
|
552
|
-
ctx.renderer.writeBracketTag(tag, ` ${msg.content.slice(0, 200)}${msg.content.length > 200 ? "…" : ""}`);
|
|
553
|
-
if (msg.content.length > 200) {
|
|
554
|
-
ctx.renderer.writeDim(" (message truncated, full content loaded)");
|
|
555
|
-
}
|
|
556
|
-
ctx.renderer.writeDim("в”Ђ".repeat(40));
|
|
557
|
-
ctx.renderer.writeNewline();
|
|
558
|
-
ctx.history.push({
|
|
559
|
-
role: msg.role === "tool" ? "assistant" : msg.role,
|
|
560
|
-
content: msg.content,
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
const lastUser = [...displayMsgs].reverse().find((m) => m.role === "user");
|
|
564
|
-
if (lastUser) {
|
|
565
|
-
// Feed history WITHOUT the last user message to avoid duplication
|
|
566
|
-
const prevMsgs = ctx.history.filter((m) => m.content !== lastUser.content || m.role !== "user");
|
|
567
|
-
const result = await runAgentLoop(ctx.provider, ctx.registry, lastUser.content, undefined, prevMsgs, ctx.renderer);
|
|
568
|
-
for (const msg of result.messages) {
|
|
569
|
-
if (msg.role !== "system") {
|
|
570
|
-
const dup = ctx.history.find((m) => m.content === msg.content && m.role === msg.role);
|
|
571
|
-
if (!dup)
|
|
572
|
-
ctx.history.push({
|
|
573
|
-
role: msg.role,
|
|
574
|
-
content: msg.content,
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
function cmdSave(args, ctx) {
|
|
581
|
-
if (ctx.history.length === 0) {
|
|
582
|
-
ctx.renderer.writeDim(" No conversation to save.");
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
const name = args.trim() || "";
|
|
586
|
-
const providerLabel = `${ctx.provider.model}`;
|
|
587
|
-
const filePath = createNamedSession(name, ctx.history, providerLabel, process.cwd(), { totalTokens: 0, compactCount: 0 });
|
|
588
|
-
const id = filePath.split(/[/\\]/).pop()?.replace(".json", "") || "";
|
|
589
|
-
const theme = getTheme();
|
|
590
|
-
ctx.renderer.writeSuccess(`Session saved: ${theme.highlight(id)}${name ? ` (${theme.dim(name)})` : ""}`);
|
|
591
|
-
}
|
|
592
|
-
function cmdClear(_args, ctx) {
|
|
593
|
-
ctx.renderer.clear();
|
|
594
|
-
}
|
|
595
|
-
function cmdNew(_args, ctx) {
|
|
596
|
-
ctx.history.length = 0;
|
|
597
|
-
ctx.renderer.clear();
|
|
598
|
-
ctx.renderer.writeInfo(" Context cleared. Starting new session.");
|
|
599
|
-
}
|
|
600
|
-
function cmdStop(_args, ctx) {
|
|
601
|
-
ctx.renderer.writeDim(" Stopping agent loop...");
|
|
602
|
-
ctx.renderer.destroy();
|
|
603
|
-
}
|
|
604
|
-
const AUTO_HEADERS = new Set([
|
|
605
|
-
"## Description",
|
|
606
|
-
"## Git",
|
|
607
|
-
"## Tech Stack",
|
|
608
|
-
"## Key Dependencies",
|
|
609
|
-
"## Commands",
|
|
610
|
-
"## Conventions",
|
|
611
|
-
"## Project Structure",
|
|
612
|
-
]);
|
|
613
|
-
export function stripAutoSections(content) {
|
|
614
|
-
const lines = content.split("\n");
|
|
615
|
-
const result = [];
|
|
616
|
-
let skip = false;
|
|
617
|
-
for (const line of lines) {
|
|
618
|
-
const m = line.match(/^##\s+(.+)/);
|
|
619
|
-
if (m)
|
|
620
|
-
skip = AUTO_HEADERS.has(`## ${m[1]}`);
|
|
621
|
-
if (!skip)
|
|
622
|
-
result.push(line);
|
|
623
|
-
}
|
|
624
|
-
return result.join("\n").trim();
|
|
625
|
-
}
|
|
626
|
-
export function getGitInfo() {
|
|
627
|
-
try {
|
|
628
|
-
const remote = execSync("git config --get remote.origin.url", {
|
|
629
|
-
encoding: "utf-8",
|
|
630
|
-
timeout: 5000,
|
|
631
|
-
stdio: "pipe",
|
|
632
|
-
}).trim();
|
|
633
|
-
const branch = execSync("git rev-parse --abbrev-ref HEAD", {
|
|
634
|
-
encoding: "utf-8",
|
|
635
|
-
timeout: 5000,
|
|
636
|
-
stdio: "pipe",
|
|
637
|
-
}).trim();
|
|
638
|
-
const lastCommit = execSync("git log --oneline -1", {
|
|
639
|
-
encoding: "utf-8",
|
|
640
|
-
timeout: 5000,
|
|
641
|
-
stdio: "pipe",
|
|
642
|
-
}).trim();
|
|
643
|
-
return { remote, branch, lastCommit };
|
|
644
|
-
}
|
|
645
|
-
catch {
|
|
646
|
-
return null;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
function cmdInit(_args, ctx) {
|
|
650
|
-
const theme = getTheme();
|
|
651
|
-
const cwd = process.cwd();
|
|
652
|
-
ctx.renderer.writeNewline();
|
|
653
|
-
ctx.renderer.writeInfo(" Analyzing project...");
|
|
654
|
-
const agentsPath = join(cwd, "AGENTS.md");
|
|
655
|
-
const existed = existsSync(agentsPath);
|
|
656
|
-
// Read existing AGENTS.md first to preserve custom sections
|
|
657
|
-
let preservedContent = "";
|
|
658
|
-
if (existed) {
|
|
659
|
-
const existingContent = readFileSync(agentsPath, "utf-8");
|
|
660
|
-
preservedContent = stripAutoSections(existingContent);
|
|
661
|
-
}
|
|
662
|
-
// Scan project
|
|
663
|
-
const projectName = basename(cwd);
|
|
664
|
-
let description = "";
|
|
665
|
-
let scripts = {};
|
|
666
|
-
let deps = [];
|
|
667
|
-
let devDeps = [];
|
|
668
|
-
const pkgPath = join(cwd, "package.json");
|
|
669
|
-
if (existsSync(pkgPath)) {
|
|
670
|
-
try {
|
|
671
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
672
|
-
description = pkg.description || "";
|
|
673
|
-
scripts = pkg.scripts || {};
|
|
674
|
-
deps = Object.keys(pkg.dependencies || {});
|
|
675
|
-
devDeps = Object.keys(pkg.devDependencies || {});
|
|
676
|
-
}
|
|
677
|
-
catch {
|
|
678
|
-
/* ignore */
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
const langCounts = {};
|
|
682
|
-
const exts = [
|
|
683
|
-
"ts",
|
|
684
|
-
"tsx",
|
|
685
|
-
"js",
|
|
686
|
-
"jsx",
|
|
687
|
-
"mjs",
|
|
688
|
-
"cjs",
|
|
689
|
-
"py",
|
|
690
|
-
"go",
|
|
691
|
-
"rs",
|
|
692
|
-
"java",
|
|
693
|
-
"rb",
|
|
694
|
-
"php",
|
|
695
|
-
"c",
|
|
696
|
-
"cpp",
|
|
697
|
-
"h",
|
|
698
|
-
"css",
|
|
699
|
-
"scss",
|
|
700
|
-
"html",
|
|
701
|
-
"vue",
|
|
702
|
-
"svelte",
|
|
703
|
-
"prisma",
|
|
704
|
-
];
|
|
705
|
-
try {
|
|
706
|
-
walkDirForLangs(cwd, exts, langCounts);
|
|
707
|
-
}
|
|
708
|
-
catch {
|
|
709
|
-
/* ignore */
|
|
710
|
-
}
|
|
711
|
-
const mainLang = Object.entries(langCounts)
|
|
712
|
-
.sort((a, b) => b[1] - a[1])
|
|
713
|
-
.slice(0, 3);
|
|
714
|
-
let stack = "";
|
|
715
|
-
if (existsSync(join(cwd, "tsconfig.json")))
|
|
716
|
-
stack += "TypeScript, ";
|
|
717
|
-
if (existsSync(join(cwd, "next.config.js")) ||
|
|
718
|
-
existsSync(join(cwd, "next.config.mjs")))
|
|
719
|
-
stack += "Next.js, ";
|
|
720
|
-
if (existsSync(join(cwd, "astro.config.mjs")))
|
|
721
|
-
stack += "Astro, ";
|
|
722
|
-
if (existsSync(join(cwd, "vite.config.ts")) ||
|
|
723
|
-
existsSync(join(cwd, "vite.config.js")))
|
|
724
|
-
stack += "Vite, ";
|
|
725
|
-
if (existsSync(join(cwd, "vitest.config.ts")) ||
|
|
726
|
-
existsSync(join(cwd, "vitest.config.js")))
|
|
727
|
-
stack += "Vitest, ";
|
|
728
|
-
if (existsSync(join(cwd, "jest.config.js")) ||
|
|
729
|
-
existsSync(join(cwd, "jest.config.ts")))
|
|
730
|
-
stack += "Jest, ";
|
|
731
|
-
if (existsSync(join(cwd, ".eslintrc.js")) ||
|
|
732
|
-
existsSync(join(cwd, "eslint.config.js")))
|
|
733
|
-
stack += "ESLint, ";
|
|
734
|
-
if (existsSync(join(cwd, "prisma/schema.prisma")))
|
|
735
|
-
stack += "Prisma, ";
|
|
736
|
-
if (existsSync(join(cwd, "Dockerfile")))
|
|
737
|
-
stack += "Docker, ";
|
|
738
|
-
if (existsSync(join(cwd, "docker-compose.yml")))
|
|
739
|
-
stack += "Docker Compose, ";
|
|
740
|
-
if (existsSync(join(cwd, ".github/workflows")))
|
|
741
|
-
stack += "GitHub Actions, ";
|
|
742
|
-
const buildCmd = scripts.build || scripts.compile || "";
|
|
743
|
-
const testCmd = scripts.test || "";
|
|
744
|
-
const devCmd = scripts.dev || scripts.start || scripts["dev:watch"] || "";
|
|
745
|
-
let agentsContent = `# ${projectName}\n\n`;
|
|
746
|
-
agentsContent += `LLM agent instructions for the project \`${projectName}\`.\n\n`;
|
|
747
|
-
if (description) {
|
|
748
|
-
agentsContent += `## Description\n\n${description}\n\n`;
|
|
749
|
-
}
|
|
750
|
-
// Git info
|
|
751
|
-
const gitInfo = getGitInfo();
|
|
752
|
-
if (gitInfo) {
|
|
753
|
-
agentsContent += "## Git\n\n";
|
|
754
|
-
agentsContent += `- **Remote**: ${gitInfo.remote}\n`;
|
|
755
|
-
agentsContent += `- **Branch**: ${gitInfo.branch}\n`;
|
|
756
|
-
agentsContent += `- **Last commit**: ${gitInfo.lastCommit}\n\n`;
|
|
757
|
-
}
|
|
758
|
-
if (stack || mainLang.length > 0) {
|
|
759
|
-
agentsContent += "## Tech Stack\n\n";
|
|
760
|
-
if (stack)
|
|
761
|
-
agentsContent += `- **Framework/Tools**: ${stack.replace(/, $/, "")}\n`;
|
|
762
|
-
for (const [lang, count] of mainLang) {
|
|
763
|
-
agentsContent += `- **${lang.toUpperCase()}**: ${count} files\n`;
|
|
764
|
-
}
|
|
765
|
-
agentsContent += "\n";
|
|
766
|
-
}
|
|
767
|
-
if (deps.length > 0 || devDeps.length > 0) {
|
|
768
|
-
agentsContent += "## Key Dependencies\n\n";
|
|
769
|
-
if (deps.length > 0) {
|
|
770
|
-
const core = deps.filter((d) => !d.startsWith("@types/")).slice(0, 10);
|
|
771
|
-
agentsContent += `- Runtime: ${core.join(", ")}\n`;
|
|
772
|
-
}
|
|
773
|
-
if (devDeps.length > 0) {
|
|
774
|
-
const tools = devDeps
|
|
775
|
-
.filter((d) => !d.startsWith("@types/"))
|
|
776
|
-
.slice(0, 10);
|
|
777
|
-
agentsContent += `- Dev: ${tools.join(", ")}\n`;
|
|
778
|
-
}
|
|
779
|
-
agentsContent += "\n";
|
|
780
|
-
}
|
|
781
|
-
if (buildCmd || testCmd || devCmd) {
|
|
782
|
-
agentsContent += "## Commands\n\n";
|
|
783
|
-
if (buildCmd)
|
|
784
|
-
agentsContent += `\`\`\`bash\n# build\nnpm run build\n\`\`\`\n\n`;
|
|
785
|
-
if (testCmd)
|
|
786
|
-
agentsContent += `\`\`\`bash\n# test\nnpm test\n\`\`\`\n\n`;
|
|
787
|
-
if (devCmd)
|
|
788
|
-
agentsContent += `\`\`\`bash\n# dev\nnpm run dev\n\`\`\`\n\n`;
|
|
789
|
-
}
|
|
790
|
-
agentsContent += `## Conventions\n\n`;
|
|
791
|
-
agentsContent += `- Use \`<tool_call>\` JSON format for tool invocation\n`;
|
|
792
|
-
agentsContent += `- Use filesystem tools for file operations, bash for npm/git only\n`;
|
|
793
|
-
if (existsSync(join(cwd, ".gitignore"))) {
|
|
794
|
-
try {
|
|
795
|
-
const gitignore = readFileSync(join(cwd, ".gitignore"), "utf-8");
|
|
796
|
-
const ignores = gitignore
|
|
797
|
-
.split("\n")
|
|
798
|
-
.filter((l) => l.trim() && !l.startsWith("#"))
|
|
799
|
-
.slice(0, 10);
|
|
800
|
-
if (ignores.length > 0) {
|
|
801
|
-
agentsContent += `- Ignored paths: \`${ignores.join("`, `")}\`\n`;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
catch {
|
|
805
|
-
/* ignore */
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
agentsContent += "\n";
|
|
809
|
-
agentsContent += `## Project Structure\n\n`;
|
|
810
|
-
try {
|
|
811
|
-
const top = readdirSync(cwd, { withFileTypes: true })
|
|
812
|
-
.filter((f) => !f.name.startsWith(".") &&
|
|
813
|
-
f.name !== "node_modules" &&
|
|
814
|
-
f.name !== "dist")
|
|
815
|
-
.slice(0, 20);
|
|
816
|
-
agentsContent += "```\n";
|
|
817
|
-
for (const f of top) {
|
|
818
|
-
agentsContent += f.isDirectory() ? `${f.name}/\n` : `${f.name}\n`;
|
|
819
|
-
}
|
|
820
|
-
agentsContent += "```\n\n";
|
|
821
|
-
}
|
|
822
|
-
catch {
|
|
823
|
-
/* ignore */
|
|
824
|
-
}
|
|
825
|
-
// Append preserved custom sections from existing AGENTS.md
|
|
826
|
-
if (preservedContent) {
|
|
827
|
-
agentsContent += preservedContent + "\n\n";
|
|
828
|
-
}
|
|
829
|
-
try {
|
|
830
|
-
writeFileSync(agentsPath, agentsContent, "utf-8");
|
|
831
|
-
const verb = existed ? "Updated" : "Created";
|
|
832
|
-
ctx.renderer.writeSuccess(` ${verb} ${theme.filePath("AGENTS.md")}`);
|
|
833
|
-
ctx.renderer.writeNewline();
|
|
834
|
-
ctx.renderer.writeLine(agentsContent);
|
|
835
|
-
logInfo("REPL", `AGENTS.md ${verb.toLowerCase()}d: ${agentsPath}`);
|
|
836
|
-
}
|
|
837
|
-
catch (e) {
|
|
838
|
-
ctx.renderer.writeError(` Failed to write AGENTS.md: ${e.message}`);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
function walkDirForLangs(dir, exts, counts) {
|
|
842
|
-
const IGNORE = new Set([
|
|
843
|
-
"node_modules",
|
|
844
|
-
".git",
|
|
845
|
-
".mma",
|
|
846
|
-
"dist",
|
|
847
|
-
"build",
|
|
848
|
-
"__pycache__",
|
|
849
|
-
"target",
|
|
850
|
-
".next",
|
|
851
|
-
".nuxt",
|
|
852
|
-
"coverage",
|
|
853
|
-
".cache",
|
|
854
|
-
"venv",
|
|
855
|
-
".venv",
|
|
856
|
-
"env",
|
|
857
|
-
]);
|
|
858
|
-
let entries;
|
|
859
|
-
try {
|
|
860
|
-
entries = readdirSync(dir, { withFileTypes: true });
|
|
861
|
-
}
|
|
862
|
-
catch {
|
|
863
|
-
return;
|
|
864
|
-
}
|
|
865
|
-
for (const entry of entries) {
|
|
866
|
-
if (IGNORE.has(entry.name) || entry.name.startsWith("."))
|
|
867
|
-
continue;
|
|
868
|
-
const fullPath = join(dir, entry.name);
|
|
869
|
-
if (entry.isDirectory()) {
|
|
870
|
-
walkDirForLangs(fullPath, exts, counts);
|
|
871
|
-
}
|
|
872
|
-
else {
|
|
873
|
-
const ext = entry.name.split(".").pop()?.toLowerCase() || "";
|
|
874
|
-
if (exts.includes(ext)) {
|
|
875
|
-
counts[ext] = (counts[ext] || 0) + 1;
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
function cmdIndex(args, ctx) {
|
|
881
|
-
const subcmd = args.trim() || "status";
|
|
882
|
-
switch (subcmd) {
|
|
883
|
-
case "rebuild": {
|
|
884
|
-
ctx.renderer.writeInfo(" Rebuilding code index...");
|
|
885
|
-
const { formatted } = rebuildCodeIndex(process.cwd());
|
|
886
|
-
ctx.renderer.writeLine(formatted);
|
|
887
|
-
ctx.renderer.writeSuccess("Code index rebuilt");
|
|
888
|
-
break;
|
|
889
|
-
}
|
|
890
|
-
case "map": {
|
|
891
|
-
ctx.renderer.writeInfo(" Rebuilding project map...");
|
|
892
|
-
const { formatted } = rebuildProjectMap(process.cwd());
|
|
893
|
-
ctx.renderer.writeLine(formatted);
|
|
894
|
-
ctx.renderer.writeSuccess("Project map rebuilt");
|
|
895
|
-
break;
|
|
896
|
-
}
|
|
897
|
-
case "show": {
|
|
898
|
-
const { formatted, fromCache } = getOrBuildProjectMap(process.cwd());
|
|
899
|
-
ctx.renderer.writeLine(formatted);
|
|
900
|
-
if (fromCache) {
|
|
901
|
-
ctx.renderer.writeDim(" (from cache)");
|
|
902
|
-
}
|
|
903
|
-
break;
|
|
904
|
-
}
|
|
905
|
-
case "status": {
|
|
906
|
-
const { formatted: mapFormatted } = getOrBuildProjectMap(process.cwd());
|
|
907
|
-
const { formatted: idxFormatted } = getOrBuildCodeIndex(process.cwd());
|
|
908
|
-
ctx.renderer.writeLine(mapFormatted.split("\n").slice(0, 3).join("\n"));
|
|
909
|
-
ctx.renderer.writeNewline();
|
|
910
|
-
ctx.renderer.writeLine(idxFormatted.split("\n").slice(0, 3).join("\n"));
|
|
911
|
-
break;
|
|
912
|
-
}
|
|
913
|
-
default:
|
|
914
|
-
ctx.renderer.writeInfo(" Usage: /index [status|show|map|rebuild]");
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
function cmdProfile(args, ctx) {
|
|
918
|
-
const theme = getTheme();
|
|
919
|
-
if (!args.trim()) {
|
|
920
|
-
const content = loadProfile();
|
|
921
|
-
if (content) {
|
|
922
|
-
ctx.renderer.writeNewline();
|
|
923
|
-
ctx.renderer.writeLine(content);
|
|
924
|
-
ctx.renderer.writeNewline();
|
|
925
|
-
}
|
|
926
|
-
else {
|
|
927
|
-
ctx.renderer.writeDim(" User profile is empty.");
|
|
928
|
-
ctx.renderer.writeDim(" It will be auto-populated as you work.");
|
|
929
|
-
}
|
|
930
|
-
return;
|
|
931
|
-
}
|
|
932
|
-
const parts = args.trim().split(/\s+/);
|
|
933
|
-
const subcmd = parts[0];
|
|
934
|
-
const rest = parts.slice(1).join(" ");
|
|
935
|
-
if (subcmd === "name" && rest) {
|
|
936
|
-
appendNote(`РРјСЏ пользователя: ${rest}`, "Notes");
|
|
937
|
-
ctx.renderer.writeSuccess(` Name saved: ${theme.highlight(rest)}`);
|
|
938
|
-
return;
|
|
939
|
-
}
|
|
940
|
-
if (subcmd === "show") {
|
|
941
|
-
const content = loadProfile();
|
|
942
|
-
if (content) {
|
|
943
|
-
ctx.renderer.writeNewline();
|
|
944
|
-
ctx.renderer.writeLine(content);
|
|
945
|
-
ctx.renderer.writeNewline();
|
|
946
|
-
}
|
|
947
|
-
else {
|
|
948
|
-
ctx.renderer.writeDim(" Profile is empty.");
|
|
949
|
-
}
|
|
950
|
-
return;
|
|
951
|
-
}
|
|
952
|
-
appendNote(args.trim(), "Notes");
|
|
953
|
-
ctx.renderer.writeSuccess("Note added to user profile.");
|
|
954
|
-
}
|
|
955
|
-
function cmdExport(args, ctx) {
|
|
956
|
-
const mode = args.trim() || "normal";
|
|
957
|
-
const history = ctx.conversationHistory;
|
|
958
|
-
if (history.length === 0) {
|
|
959
|
-
ctx.renderer.writeDim(" No conversation to export.");
|
|
960
|
-
return;
|
|
961
|
-
}
|
|
962
|
-
let output = "";
|
|
963
|
-
if (mode === "debug") {
|
|
964
|
-
output = `# Session Debug Export\n`;
|
|
965
|
-
output += `Model: ${ctx.modelLabel}\n`;
|
|
966
|
-
output += `Messages: ${history.length}\n`;
|
|
967
|
-
output += `---\n\n`;
|
|
968
|
-
for (const msg of history) {
|
|
969
|
-
const role = msg.role === "user" ? "## User" : "## Assistant";
|
|
970
|
-
output += `${role}\n\`\`\`\n${msg.content}\n\`\`\`\n\n`;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
else {
|
|
974
|
-
output = `# Session Export\n`;
|
|
975
|
-
output += `Model: ${ctx.modelLabel}\n\n`;
|
|
976
|
-
for (const msg of history) {
|
|
977
|
-
const role = msg.role === "user" ? "**You:**" : "**Assistant:**";
|
|
978
|
-
output += `${role} ${msg.content}\n\n`;
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
const filename = `.mma/export-${Date.now()}.md`;
|
|
982
|
-
mkdirSync(".mma", { recursive: true });
|
|
983
|
-
writeFileSync(filename, output, "utf-8");
|
|
984
|
-
const theme = getTheme();
|
|
985
|
-
ctx.renderer.writeSuccess(` Exported to ${theme.filePath(filename)}`);
|
|
986
|
-
}
|
|
987
|
-
async function cmdTheme(args, ctx) {
|
|
988
|
-
const theme = getTheme();
|
|
989
|
-
const parts = args.trim().split(/\s+/);
|
|
990
|
-
const subcmd = parts[0] || "list";
|
|
991
|
-
const name = parts.slice(1).join(" ");
|
|
992
|
-
switch (subcmd) {
|
|
993
|
-
case "list": {
|
|
994
|
-
const allThemes = listThemes();
|
|
995
|
-
const current = loadThemeConfig().name;
|
|
996
|
-
ctx.renderer.writeInfo(` Available themes (${allThemes.length}):`);
|
|
997
|
-
for (const t of allThemes) {
|
|
998
|
-
const marker = t === current ? theme.success(" в†ђ active") : "";
|
|
999
|
-
ctx.renderer.writeLine(` ${theme.highlight(t)}${marker}`);
|
|
1000
|
-
}
|
|
1001
|
-
break;
|
|
1002
|
-
}
|
|
1003
|
-
case "show": {
|
|
1004
|
-
const config = loadThemeConfig();
|
|
1005
|
-
ctx.renderer.writeInfo(` Current theme: ${theme.highlight(config.name)}`);
|
|
1006
|
-
ctx.renderer.writeLine(` ${theme.dim("Colors:")} ${theme.highlight(String(Object.keys(config.colors).length))} keys`);
|
|
1007
|
-
ctx.renderer.writeLine(` ${theme.dim("Icons:")} ${theme.highlight(String(Object.keys(config.icons).length))} keys`);
|
|
1008
|
-
break;
|
|
1009
|
-
}
|
|
1010
|
-
case "create": {
|
|
1011
|
-
if (!name) {
|
|
1012
|
-
ctx.renderer.writeInfo(" Usage: /theme create <name>");
|
|
1013
|
-
break;
|
|
1014
|
-
}
|
|
1015
|
-
const current = loadThemeConfig();
|
|
1016
|
-
current.name = name;
|
|
1017
|
-
const filePath = installTheme(name, JSON.stringify(current, null, 2));
|
|
1018
|
-
ctx.renderer.writeSuccess(` Theme ${theme.highlight(name)} created (${theme.filePath(filePath)})`);
|
|
1019
|
-
break;
|
|
1020
|
-
}
|
|
1021
|
-
case "install": {
|
|
1022
|
-
const [themeName, url] = parts.slice(1);
|
|
1023
|
-
if (!themeName || !url) {
|
|
1024
|
-
ctx.renderer.writeInfo(" Usage: /theme install <name> <url>");
|
|
1025
|
-
break;
|
|
1026
|
-
}
|
|
1027
|
-
ctx.renderer.writeDim(` Downloading from ${theme.link(url)}...`);
|
|
1028
|
-
try {
|
|
1029
|
-
const resp = execSync(`curl -s "${url}"`, {
|
|
1030
|
-
encoding: "utf-8",
|
|
1031
|
-
timeout: 10000,
|
|
1032
|
-
windowsHide: true,
|
|
1033
|
-
});
|
|
1034
|
-
JSON.parse(resp);
|
|
1035
|
-
const filePath = installTheme(themeName, resp);
|
|
1036
|
-
ctx.renderer.writeSuccess(` Theme ${theme.highlight(themeName)} installed (${theme.filePath(filePath)})`);
|
|
1037
|
-
}
|
|
1038
|
-
catch (e) {
|
|
1039
|
-
ctx.renderer.writeError(` Failed to install: ${e.message}`);
|
|
1040
|
-
}
|
|
1041
|
-
break;
|
|
1042
|
-
}
|
|
1043
|
-
case "remove": {
|
|
1044
|
-
if (!name) {
|
|
1045
|
-
ctx.renderer.writeInfo(" Usage: /theme remove <name>");
|
|
1046
|
-
break;
|
|
1047
|
-
}
|
|
1048
|
-
if (!removeTheme(name)) {
|
|
1049
|
-
ctx.renderer.writeError(` Theme ${theme.highlight(name)} not found`);
|
|
1050
|
-
break;
|
|
1051
|
-
}
|
|
1052
|
-
ctx.renderer.writeSuccess(` Theme ${theme.highlight(name)} removed`);
|
|
1053
|
-
break;
|
|
1054
|
-
}
|
|
1055
|
-
default: {
|
|
1056
|
-
const allThemes = listThemes();
|
|
1057
|
-
if (!allThemes.includes(subcmd)) {
|
|
1058
|
-
ctx.renderer.writeError(` Unknown theme ${theme.highlight(subcmd)}. Use /theme list`);
|
|
1059
|
-
break;
|
|
1060
|
-
}
|
|
1061
|
-
const config = loadConfig();
|
|
1062
|
-
config.theme = subcmd;
|
|
1063
|
-
saveConfig(config);
|
|
1064
|
-
switchTheme(subcmd);
|
|
1065
|
-
ctx.renderer.writeSuccess(` Theme switched to "${subcmd}"`);
|
|
1066
|
-
break;
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
//# sourceMappingURL=commands.js.map
|