micro-models-agent 0.44.0 → 0.45.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.
Files changed (188) hide show
  1. package/README.md +312 -312
  2. package/bin/mma.mjs +41 -41
  3. package/dist/main.js +241 -56
  4. package/dist/skills/builtin/git.md +36 -36
  5. package/dist/skills/builtin/typescript.md +35 -35
  6. package/package.json +1 -1
  7. package/dist/cli/commands.js +0 -333
  8. package/dist/cli/completer.js +0 -168
  9. package/dist/cli/index.js +0 -2
  10. package/dist/cli/main.js +0 -140
  11. package/dist/cli/repl-commands.js +0 -633
  12. package/dist/cli/repl.js +0 -486
  13. package/dist/cli/security-commands.js +0 -166
  14. package/dist/cli/setup.js +0 -249
  15. package/dist/config/config.js +0 -202
  16. package/dist/config/defaults.js +0 -100
  17. package/dist/config/experts.js +0 -15
  18. package/dist/config/index.js +0 -3
  19. package/dist/config/security.js +0 -200
  20. package/dist/config/types.js +0 -1
  21. package/dist/core/agent-moe.js +0 -110
  22. package/dist/core/agent.js +0 -695
  23. package/dist/core/bootstrap.js +0 -337
  24. package/dist/core/index.js +0 -2
  25. package/dist/core/prompt-builder.js +0 -55
  26. package/dist/core/session-logger.js +0 -155
  27. package/dist/core/types.js +0 -1
  28. package/dist/core/workspace.js +0 -76
  29. package/dist/i18n/en.json +0 -525
  30. package/dist/i18n/index.js +0 -46
  31. package/dist/i18n/ru.json +0 -525
  32. package/dist/index.js +0 -22
  33. package/dist/llm/image-utils.js +0 -144
  34. package/dist/llm/index.js +0 -4
  35. package/dist/llm/model-loader.js +0 -78
  36. package/dist/llm/openai-compat.js +0 -353
  37. package/dist/llm/orchestrator.js +0 -194
  38. package/dist/llm/provider.js +0 -10
  39. package/dist/llm/response.js +0 -39
  40. package/dist/llm/token-counter.js +0 -39
  41. package/dist/llm/types.js +0 -1
  42. package/dist/logger/app-logger.js +0 -143
  43. package/dist/logger/file-log.js +0 -151
  44. package/dist/logger/index.js +0 -1
  45. package/dist/migration/backup.js +0 -45
  46. package/dist/migration/detect.js +0 -50
  47. package/dist/migration/index.js +0 -2
  48. package/dist/modules/browser/actions.js +0 -46
  49. package/dist/modules/browser/cookie-store.js +0 -24
  50. package/dist/modules/browser/index.js +0 -5
  51. package/dist/modules/browser/module.js +0 -28
  52. package/dist/modules/browser/session.js +0 -335
  53. package/dist/modules/browser/snapshot.js +0 -114
  54. package/dist/modules/browser/types.js +0 -9
  55. package/dist/modules/certification/cli.js +0 -176
  56. package/dist/modules/certification/fact-checker.js +0 -84
  57. package/dist/modules/certification/loader.js +0 -111
  58. package/dist/modules/certification/manifest.js +0 -50
  59. package/dist/modules/certification/runner.js +0 -162
  60. package/dist/modules/certification/scenarios.js +0 -124
  61. package/dist/modules/certification/types.js +0 -1
  62. package/dist/modules/context/index.js +0 -1
  63. package/dist/modules/context/manager.js +0 -349
  64. package/dist/modules/execution/auditor.js +0 -66
  65. package/dist/modules/execution/index.js +0 -8
  66. package/dist/modules/execution/module.js +0 -779
  67. package/dist/modules/execution/moe-executor.js +0 -266
  68. package/dist/modules/execution/plan-coverage.js +0 -68
  69. package/dist/modules/execution/plan-persister.js +0 -46
  70. package/dist/modules/execution/plan-store.js +0 -159
  71. package/dist/modules/execution/plan-validator.js +0 -153
  72. package/dist/modules/execution/planner.js +0 -85
  73. package/dist/modules/execution/stuck-detector.js +0 -347
  74. package/dist/modules/execution/tracker.js +0 -67
  75. package/dist/modules/execution/types.js +0 -1
  76. package/dist/modules/execution/verifier.js +0 -178
  77. package/dist/modules/hallucination/confidence.js +0 -59
  78. package/dist/modules/hallucination/consistency.js +0 -26
  79. package/dist/modules/hallucination/detector.js +0 -46
  80. package/dist/modules/hallucination/factual.js +0 -190
  81. package/dist/modules/hallucination/index.js +0 -5
  82. package/dist/modules/hallucination/js-identifiers.js +0 -72
  83. package/dist/modules/hallucination/llm-judge.js +0 -103
  84. package/dist/modules/index.js +0 -5
  85. package/dist/modules/indexer/cache.js +0 -38
  86. package/dist/modules/indexer/index.js +0 -3
  87. package/dist/modules/indexer/module.js +0 -192
  88. package/dist/modules/indexer/walker.js +0 -101
  89. package/dist/modules/lsp/client.js +0 -235
  90. package/dist/modules/lsp/config.js +0 -81
  91. package/dist/modules/lsp/index.js +0 -3
  92. package/dist/modules/lsp/module.js +0 -68
  93. package/dist/modules/lsp/types.js +0 -1
  94. package/dist/modules/mcp/client.js +0 -399
  95. package/dist/modules/mcp/index.js +0 -3
  96. package/dist/modules/mcp/module.js +0 -146
  97. package/dist/modules/mcp/registry.js +0 -15
  98. package/dist/modules/memory/index.js +0 -1
  99. package/dist/modules/memory/module.js +0 -48
  100. package/dist/modules/memory/search.js +0 -40
  101. package/dist/modules/memory/store.js +0 -69
  102. package/dist/modules/pipelines/engine.js +0 -60
  103. package/dist/modules/pipelines/index.js +0 -3
  104. package/dist/modules/pipelines/parser.js +0 -53
  105. package/dist/modules/pipelines/template.js +0 -14
  106. package/dist/modules/plugins/builtin/lint-on-write.js +0 -226
  107. package/dist/modules/plugins/builtin/notify.js +0 -8
  108. package/dist/modules/plugins/index.js +0 -1
  109. package/dist/modules/plugins/loader.js +0 -28
  110. package/dist/modules/plugins/manager.js +0 -161
  111. package/dist/modules/plugins/types.js +0 -1
  112. package/dist/modules/processes/index.js +0 -2
  113. package/dist/modules/processes/registry.js +0 -238
  114. package/dist/modules/processes/runner.js +0 -23
  115. package/dist/modules/registry.js +0 -45
  116. package/dist/modules/security/audit-log.js +0 -136
  117. package/dist/modules/security/audit-notifier.js +0 -292
  118. package/dist/modules/security/command-validator.js +0 -211
  119. package/dist/modules/security/content-scanner.js +0 -53
  120. package/dist/modules/security/data-sanitizer.js +0 -97
  121. package/dist/modules/security/encryption.js +0 -240
  122. package/dist/modules/security/index.js +0 -14
  123. package/dist/modules/security/network-validator.js +0 -79
  124. package/dist/modules/security/path-validator.js +0 -209
  125. package/dist/modules/security/rate-limiter.js +0 -119
  126. package/dist/modules/security/security-policies.js +0 -547
  127. package/dist/modules/security/session-encryption.js +0 -210
  128. package/dist/modules/security/session-isolation.js +0 -95
  129. package/dist/modules/session/index.js +0 -3
  130. package/dist/modules/session/manager.js +0 -172
  131. package/dist/modules/session/module.js +0 -24
  132. package/dist/modules/session/store.js +0 -228
  133. package/dist/modules/session/types.js +0 -1
  134. package/dist/modules/skills/index.js +0 -2
  135. package/dist/modules/skills/loader.js +0 -72
  136. package/dist/modules/skills/module.js +0 -130
  137. package/dist/modules/types.js +0 -1
  138. package/dist/modules/updater/checker.js +0 -32
  139. package/dist/modules/updater/index.js +0 -1
  140. package/dist/modules/user-profile/compressor.js +0 -16
  141. package/dist/modules/user-profile/index.js +0 -1
  142. package/dist/modules/user-profile/profile.js +0 -68
  143. package/dist/tools/approve.js +0 -32
  144. package/dist/tools/attach-image.js +0 -89
  145. package/dist/tools/bash.js +0 -337
  146. package/dist/tools/browser.js +0 -97
  147. package/dist/tools/create-dir.js +0 -55
  148. package/dist/tools/delete-file.js +0 -62
  149. package/dist/tools/edit-file.js +0 -79
  150. package/dist/tools/executor.js +0 -145
  151. package/dist/tools/file-info.js +0 -45
  152. package/dist/tools/filter-tools.js +0 -10
  153. package/dist/tools/glob-tool.js +0 -26
  154. package/dist/tools/grep-tool.js +0 -86
  155. package/dist/tools/index.js +0 -67
  156. package/dist/tools/list-dir.js +0 -47
  157. package/dist/tools/load-skill.js +0 -44
  158. package/dist/tools/mcp-call.js +0 -68
  159. package/dist/tools/move-file.js +0 -85
  160. package/dist/tools/path-utils.js +0 -51
  161. package/dist/tools/pipeline-run.js +0 -144
  162. package/dist/tools/preview.js +0 -2
  163. package/dist/tools/process-kill.js +0 -29
  164. package/dist/tools/process-list.js +0 -38
  165. package/dist/tools/process-log.js +0 -41
  166. package/dist/tools/question.js +0 -142
  167. package/dist/tools/read-file.js +0 -83
  168. package/dist/tools/recall.js +0 -110
  169. package/dist/tools/registry.js +0 -36
  170. package/dist/tools/remember.js +0 -67
  171. package/dist/tools/scope-check.js +0 -30
  172. package/dist/tools/search-history.js +0 -84
  173. package/dist/tools/subagent.js +0 -151
  174. package/dist/tools/types.js +0 -1
  175. package/dist/tools/user-input.js +0 -123
  176. package/dist/tools/web-browse.js +0 -86
  177. package/dist/tools/web-fetch.js +0 -98
  178. package/dist/tools/web-search.js +0 -78
  179. package/dist/tools/write-file.js +0 -83
  180. package/dist/ui/box.js +0 -81
  181. package/dist/ui/colors.js +0 -4
  182. package/dist/ui/diff.js +0 -178
  183. package/dist/ui/index.js +0 -6
  184. package/dist/ui/md-formatter.js +0 -212
  185. package/dist/ui/output.js +0 -13
  186. package/dist/ui/renderer.js +0 -204
  187. package/dist/ui/spinner.js +0 -70
  188. package/dist/ui/table.js +0 -144
@@ -1,36 +1,36 @@
1
- ---
2
- name: git-expert
3
- description: Git branching, merge conflicts, rebasing, workflow strategies
4
- keywords: [git, branch, merge, rebase, commit, conflict, workflow]
5
- mma_version: 2
6
- ---
7
-
8
- # Git Expert
9
-
10
- ## Branching Strategies
11
-
12
- - **Feature branches**: `feature/xxx` from `main`, merge via PR
13
- - **Hotfix**: `hotfix/xxx` from `main`, merge to both `main` and `develop`
14
- - **Release**: `release/xxx` from `develop`, merge to `main` + `develop`
15
-
16
- ## Conflict Resolution
17
-
18
- 1. `git fetch origin` — get latest
19
- 2. `git checkout your-branch`
20
- 3. `git rebase origin/main` — apply your commits on top
21
- 4. Resolve conflicts file by file
22
- 5. `git add <files>` then `git rebase --continue`
23
-
24
- ## Useful Commands
25
-
26
- - `git log --oneline --graph --all` — visualize history
27
- - `git diff --stat` — summary of changes
28
- - `git stash pop` — restore stashed changes
29
- - `git cherry-pick <commit>` — apply specific commit
30
-
31
- ## Best Practices
32
-
33
- - Commit often with clear messages
34
- - Keep commits atomic (one logical change)
35
- - Never force push to shared branches
36
- - Use `git rebase -i` to clean up before PR
1
+ ---
2
+ name: git-expert
3
+ description: Git branching, merge conflicts, rebasing, workflow strategies
4
+ keywords: [git, branch, merge, rebase, commit, conflict, workflow]
5
+ mma_version: 2
6
+ ---
7
+
8
+ # Git Expert
9
+
10
+ ## Branching Strategies
11
+
12
+ - **Feature branches**: `feature/xxx` from `main`, merge via PR
13
+ - **Hotfix**: `hotfix/xxx` from `main`, merge to both `main` and `develop`
14
+ - **Release**: `release/xxx` from `develop`, merge to `main` + `develop`
15
+
16
+ ## Conflict Resolution
17
+
18
+ 1. `git fetch origin` — get latest
19
+ 2. `git checkout your-branch`
20
+ 3. `git rebase origin/main` — apply your commits on top
21
+ 4. Resolve conflicts file by file
22
+ 5. `git add <files>` then `git rebase --continue`
23
+
24
+ ## Useful Commands
25
+
26
+ - `git log --oneline --graph --all` — visualize history
27
+ - `git diff --stat` — summary of changes
28
+ - `git stash pop` — restore stashed changes
29
+ - `git cherry-pick <commit>` — apply specific commit
30
+
31
+ ## Best Practices
32
+
33
+ - Commit often with clear messages
34
+ - Keep commits atomic (one logical change)
35
+ - Never force push to shared branches
36
+ - Use `git rebase -i` to clean up before PR
@@ -1,35 +1,35 @@
1
- ---
2
- name: typescript-expert
3
- description: TypeScript type system, generics, advanced patterns, compiler API
4
- keywords: [typescript, types, generics, tsconfig, compiler, interface, type]
5
- mma_version: 2
6
- ---
7
-
8
- # TypeScript Expert
9
-
10
- ## Key Patterns
11
-
12
- - Use `readonly` for immutable properties
13
- - Prefer `interface` over `type` for object shapes
14
- - Use `as const` for literal types
15
- - Prefer `unknown` over `any` for type safety
16
-
17
- ## Common Pitfalls
18
-
19
- - Avoid `any` — use `unknown` + type guards
20
- - Don't use `enum` — use `const` objects or union types
21
- - Avoid `namespace` — use ES modules
22
-
23
- ## Type Guards
24
-
25
- ```ts
26
- function isString(val: unknown): val is string {
27
- return typeof val === 'string'
28
- }
29
- ```
30
-
31
- ## Generics
32
-
33
- - Use `extends` for constraints
34
- - Use `infer` for conditional type extraction
35
- - Prefer explicit over implicit for complex cases
1
+ ---
2
+ name: typescript-expert
3
+ description: TypeScript type system, generics, advanced patterns, compiler API
4
+ keywords: [typescript, types, generics, tsconfig, compiler, interface, type]
5
+ mma_version: 2
6
+ ---
7
+
8
+ # TypeScript Expert
9
+
10
+ ## Key Patterns
11
+
12
+ - Use `readonly` for immutable properties
13
+ - Prefer `interface` over `type` for object shapes
14
+ - Use `as const` for literal types
15
+ - Prefer `unknown` over `any` for type safety
16
+
17
+ ## Common Pitfalls
18
+
19
+ - Avoid `any` — use `unknown` + type guards
20
+ - Don't use `enum` — use `const` objects or union types
21
+ - Avoid `namespace` — use ES modules
22
+
23
+ ## Type Guards
24
+
25
+ ```ts
26
+ function isString(val: unknown): val is string {
27
+ return typeof val === 'string'
28
+ }
29
+ ```
30
+
31
+ ## Generics
32
+
33
+ - Use `extends` for constraints
34
+ - Use `infer` for conditional type extraction
35
+ - Prefer explicit over implicit for complex cases
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "micro-models-agent",
3
- "version": "0.44.0",
3
+ "version": "0.45.0",
4
4
  "description": "Micro Models Agent (MMA) — LLM agent harness for small models (Qwen3.5-9B, 32K-64K context)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,333 +0,0 @@
1
- import { Command } from "commander";
2
- import { bootstrap } from "../core/bootstrap";
3
- import { saveConfig } from "../config/config";
4
- import { runSetup } from "./setup";
5
- import { t } from "../i18n/index";
6
- import { join, dirname } from "path";
7
- import { homedir } from "os";
8
- import { existsSync, readFileSync } from "fs";
9
- import { createSecurityCommand } from "./security-commands";
10
- import { fileURLToPath } from "url";
11
- function readVersion() {
12
- const here = dirname(fileURLToPath(import.meta.url));
13
- const candidates = [
14
- join(here, "..", "..", "package.json"),
15
- join(here, "..", "package.json"),
16
- ];
17
- for (const p of candidates) {
18
- if (existsSync(p)) {
19
- try {
20
- const raw = JSON.parse(readFileSync(p, "utf8"));
21
- if (raw.version)
22
- return raw.version;
23
- }
24
- catch {
25
- // Broken package.json — fall through to the next candidate
26
- }
27
- }
28
- }
29
- return "0.0.0";
30
- }
31
- const version = readVersion();
32
- export function createProgram() {
33
- const program = new Command()
34
- .name("mma")
35
- .description(t("cli.description"))
36
- .version(version)
37
- .option("--no-agents-md", t("cli.no_agents_md"))
38
- .option("-d, --dir <path>", t("cli.dir"))
39
- .option("-e, --exit-on-complete", t("cli.exit_on_complete"))
40
- .option("-j, --json", t("cli.json"));
41
- program
42
- .command("init")
43
- .description(t("cli.init"))
44
- .action(async () => {
45
- const answers = await runSetup();
46
- const configPath = join(homedir(), ".mma", "config.json");
47
- const { config } = await bootstrap();
48
- config.provider.type = answers.provider;
49
- config.provider.baseUrl = answers.apiBase;
50
- config.provider.apiKey = answers.apiKey;
51
- config.model = answers.model;
52
- config.contextWindow = answers.contextWindow;
53
- config.maxToolIterations = answers.maxToolIterations;
54
- config.locale = answers.locale;
55
- // Apply security settings from wizard
56
- if (config.security) {
57
- config.security.enabled =
58
- answers.securityBashBlock ||
59
- answers.securityFlagsBlock ||
60
- !answers.securityPathsDeny;
61
- config.security.bash.enabled = config.security.enabled;
62
- config.security.bash.blockDangerousFlags = answers.securityFlagsBlock;
63
- if (answers.securityBashBlock) {
64
- config.security.bash.blacklist = [
65
- ...new Set([
66
- ...config.security.bash.blacklist,
67
- "rm",
68
- "dd",
69
- "chmod",
70
- "wget",
71
- "curl",
72
- "scp",
73
- "ssh",
74
- "nc",
75
- "netcat",
76
- "sudo",
77
- "su",
78
- "kill",
79
- "pkill",
80
- "killall",
81
- "shutdown",
82
- "reboot",
83
- ]),
84
- ];
85
- }
86
- if (!answers.securityPathsDeny) {
87
- config.security.paths.denied = [];
88
- }
89
- }
90
- saveConfig(config, configPath);
91
- console.log(t("cli.config_saved"));
92
- });
93
- const configCmd = program
94
- .command("config")
95
- .description(t("cli.manage_config"));
96
- configCmd
97
- .command("set")
98
- .argument("<key>", t("cli.config_key"))
99
- .argument("<value>", "Config value")
100
- .description(t("cli.set_value"))
101
- .action(async (key, value) => {
102
- const configPath = join(homedir(), ".mma", "config.json");
103
- const { config } = await bootstrap();
104
- const keys = key.split(".");
105
- let obj = config;
106
- for (let i = 0; i < keys.length - 1; i++) {
107
- if (!(keys[i] in obj))
108
- obj[keys[i]] = {};
109
- obj = obj[keys[i]];
110
- }
111
- const lastKey = keys[keys.length - 1];
112
- if (value === "true")
113
- obj[lastKey] = true;
114
- else if (value === "false")
115
- obj[lastKey] = false;
116
- else if (/^\d+$/.test(value))
117
- obj[lastKey] = parseInt(value, 10);
118
- else if (/^\d+\.\d+$/.test(value))
119
- obj[lastKey] = parseFloat(value);
120
- else
121
- obj[lastKey] = value;
122
- saveConfig(config, configPath);
123
- console.log(t("cli.set_done", { key, value }));
124
- });
125
- configCmd
126
- .command("show")
127
- .description(t("cli.show_config"))
128
- .action(async () => {
129
- const { config } = await bootstrap();
130
- console.log(JSON.stringify(config, null, 2));
131
- });
132
- const model = program.command("model").description(t("cli.manage_models"));
133
- model
134
- .command("list")
135
- .description(t("cli.list_models"))
136
- .action(async () => {
137
- const { config } = await bootstrap();
138
- console.log(t("cli.current_model"), config.model);
139
- // Fetch available models from provider
140
- const { OpenAICompatProvider } = await import("../llm/openai-compat");
141
- const provider = new OpenAICompatProvider({
142
- model: config.model,
143
- baseUrl: config.provider.baseUrl,
144
- apiKey: config.provider.apiKey,
145
- contextWindow: config.contextWindow,
146
- });
147
- const spinner = (await import("../ui/spinner")).Spinner;
148
- const s = new spinner();
149
- s.start(t("cli.fetching_models"));
150
- try {
151
- const models = await provider.listModels();
152
- s.stop();
153
- if (models.length > 0) {
154
- console.log(t("cli.available_models"));
155
- const { getCertMark } = await import("../modules/certification/manifest");
156
- for (const m of models) {
157
- const marker = m === config.model ? "* " : " ";
158
- const mark = getCertMark(m, config.provider.baseUrl, version);
159
- const cert = mark === "certified" ? "✔" : mark === "stale" ? "○" : "·";
160
- console.log(` ${marker}${cert} ${m}`);
161
- }
162
- }
163
- else {
164
- console.log(t("cli.no_models_found"));
165
- }
166
- }
167
- catch (err) {
168
- s.stop();
169
- console.log(t("cli.model_fetch_failed", { error: String(err) }));
170
- }
171
- console.log(t("cli.model_hint"));
172
- });
173
- model
174
- .command("use")
175
- .argument("<name>", "Model name")
176
- .description(t("cli.set_model"))
177
- .action(async (name) => {
178
- const configPath = join(homedir(), ".mma", "config.json");
179
- const { config } = await bootstrap();
180
- config.model = name;
181
- saveConfig(config, configPath);
182
- console.log(t("cli.model_set", { name }));
183
- });
184
- model
185
- .command("certify")
186
- .argument("<name>", "Model name")
187
- .option("--provider-url <url>", t("cli.cert_provider_url"))
188
- .option("--provider-key <key>", t("cli.cert_provider_key"))
189
- .option("--context-window <n>", t("cli.cert_context_window"))
190
- .option("--tags <tags>", t("cli.cert_tags"), "core")
191
- .option("--reps <n>", t("cli.cert_reps"))
192
- .option("--force", t("cli.cert_force"))
193
- .option("--clean", t("cli.cert_clean"))
194
- .description(t("cli.certify"))
195
- .action(async (name, cmdOpts) => {
196
- const { config } = await bootstrap();
197
- const { certify, parseTags } = await import("../modules/certification/cli");
198
- await certify({
199
- name,
200
- providerUrl: cmdOpts.providerUrl,
201
- providerKey: cmdOpts.providerKey,
202
- contextWindow: cmdOpts.contextWindow
203
- ? parseInt(cmdOpts.contextWindow, 10)
204
- : undefined,
205
- tags: parseTags(cmdOpts.tags),
206
- reps: cmdOpts.reps ? parseInt(cmdOpts.reps, 10) : 3,
207
- force: cmdOpts.force === true,
208
- clean: cmdOpts.clean === true,
209
- config,
210
- });
211
- });
212
- model
213
- .command("cert-status")
214
- .argument("<name>", "Model name")
215
- .description(t("cli.cert_status"))
216
- .action(async (name) => {
217
- const { config } = await bootstrap();
218
- const { certStatus } = await import("../modules/certification/cli");
219
- await certStatus(name, config);
220
- });
221
- model
222
- .command("cert-list")
223
- .description(t("cli.cert_list"))
224
- .action(async () => {
225
- const { certList } = await import("../modules/certification/cli");
226
- await certList();
227
- });
228
- model
229
- .command("uncertify")
230
- .argument("<name>", "Model name")
231
- .description(t("cli.cert_uncertify"))
232
- .action(async (name) => {
233
- const { config } = await bootstrap();
234
- const { uncertify } = await import("../modules/certification/cli");
235
- await uncertify(name, config);
236
- });
237
- // Context window command
238
- program
239
- .command("context")
240
- .description(t("cli.manage_context"))
241
- .argument("<size>", "Context window size in tokens")
242
- .action(async (size) => {
243
- const configPath = join(homedir(), ".mma", "config.json");
244
- const { config } = await bootstrap();
245
- const contextWindow = parseInt(size, 10);
246
- if (isNaN(contextWindow) || contextWindow < 1024) {
247
- console.log(t("cli.invalid_context_size"));
248
- return;
249
- }
250
- config.contextWindow = contextWindow;
251
- saveConfig(config, configPath);
252
- console.log(t("cli.context_set", { size: contextWindow }));
253
- });
254
- const provider = program
255
- .command("provider")
256
- .description(t("cli.manage_providers"));
257
- provider
258
- .command("list")
259
- .description(t("cli.list_providers"))
260
- .action(async () => {
261
- const { config } = await bootstrap();
262
- console.log(t("cli.current_provider"), config.provider.type);
263
- console.log(t("cli.base_url"), config.provider.baseUrl);
264
- });
265
- provider
266
- .command("use")
267
- .argument("<name>", "Provider name")
268
- .description(t("cli.set_provider"))
269
- .action(async (name) => {
270
- const configPath = join(homedir(), ".mma", "config.json");
271
- const { config } = await bootstrap();
272
- config.provider.type = name;
273
- saveConfig(config, configPath);
274
- console.log(t("cli.provider_set", { name }));
275
- });
276
- const session = program
277
- .command("session")
278
- .description(t("cli.manage_sessions"));
279
- session
280
- .command("list")
281
- .description(t("cli.list_sessions"))
282
- .action(async () => {
283
- const { sessionManager } = await bootstrap();
284
- const sessions = sessionManager.list();
285
- if (sessions.length === 0) {
286
- console.log(t("session.no_sessions"));
287
- return;
288
- }
289
- const active = sessionManager.getActive();
290
- for (const s of sessions) {
291
- const marker = s.id === active ? "*" : " ";
292
- console.log(` ${marker} ${s.id.slice(0, 12)} ${s.name} ${s.messageCount} msgs ${s.updatedAt.slice(0, 10)}`);
293
- }
294
- });
295
- session
296
- .command("show")
297
- .argument("<id>", "Session id")
298
- .description(t("cli.show_details"))
299
- .action(async (id) => {
300
- const { sessionManager } = await bootstrap();
301
- const meta = sessionManager.get(id);
302
- if (!meta) {
303
- console.log(t("session.not_found", { id }));
304
- return;
305
- }
306
- console.log(`ID: ${meta.id}`);
307
- console.log(`Name: ${meta.name}`);
308
- console.log(`Created: ${meta.createdAt}`);
309
- console.log(`Updated: ${meta.updatedAt}`);
310
- console.log(`Messages: ${meta.messageCount}`);
311
- console.log(`Model: ${meta.model}`);
312
- console.log(`Context: ${meta.contextWindow}`);
313
- console.log(`Project: ${meta.projectDir}`);
314
- });
315
- session
316
- .command("delete")
317
- .argument("<id>", "Session id")
318
- .description(t("cli.delete_session"))
319
- .action(async (id) => {
320
- const { sessionManager } = await bootstrap();
321
- sessionManager.delete(id);
322
- console.log(t("session.deleted", { id }));
323
- });
324
- // Add security commands
325
- createSecurityCommand(program);
326
- program
327
- .argument("[prompt...]", "Prompt to execute")
328
- .description("Run a single prompt")
329
- .action((prompt) => {
330
- /* Handled by main.ts after program.parse() */
331
- });
332
- return program;
333
- }
@@ -1,168 +0,0 @@
1
- import { readdirSync, statSync } from 'fs';
2
- import { join } from 'path';
3
- export class SlashCommandProvider {
4
- name = 'slash-commands';
5
- commands;
6
- constructor(commands) {
7
- this.commands = commands;
8
- }
9
- match(ctx) {
10
- return ctx.tokenIndex === 0 && ctx.line.startsWith('/');
11
- }
12
- complete(ctx) {
13
- return this.commands
14
- .filter(c => c.startsWith(ctx.partial.slice(1)))
15
- .map(c => `/${c}`);
16
- }
17
- }
18
- export class SubcommandProvider {
19
- name = 'subcommands';
20
- command;
21
- subcommands;
22
- constructor(command, subcommands) {
23
- this.command = command;
24
- this.subcommands = subcommands;
25
- }
26
- match(ctx) {
27
- return ctx.tokenIndex === 1 && ctx.tokens[0] === `/${this.command}`;
28
- }
29
- complete(ctx) {
30
- return this.subcommands.filter(s => s.startsWith(ctx.partial));
31
- }
32
- }
33
- export class ModelArgProvider {
34
- name = 'model-args';
35
- models;
36
- constructor(models) {
37
- this.models = models;
38
- }
39
- match(ctx) {
40
- return ctx.tokenIndex === 2 && (ctx.tokens[0] === '/model' || ctx.tokens[0] === '/config');
41
- }
42
- complete(ctx) {
43
- return this.models.filter(m => m.startsWith(ctx.partial));
44
- }
45
- }
46
- export class ConfigKeyProvider {
47
- name = 'config-keys';
48
- keys;
49
- constructor(keys) {
50
- this.keys = keys;
51
- }
52
- match(ctx) {
53
- return ctx.tokenIndex >= 1 && ctx.tokens[0] === '/config' && ctx.tokens[1] === 'set';
54
- }
55
- complete(ctx) {
56
- return this.keys.filter(k => k.startsWith(ctx.partial));
57
- }
58
- }
59
- export class FilePathProvider {
60
- name = 'file-paths';
61
- match(ctx) {
62
- return ctx.partial.includes('/') || ctx.partial.includes('\\');
63
- }
64
- complete(ctx) {
65
- try {
66
- const cwd = process.cwd();
67
- const partialPath = ctx.partial;
68
- const lastSlash = Math.max(partialPath.lastIndexOf('/'), partialPath.lastIndexOf('\\'));
69
- const dirPath = lastSlash > 0 ? partialPath.slice(0, lastSlash) : '.';
70
- const prefix = lastSlash > 0 ? partialPath.slice(0, lastSlash + 1) : '';
71
- const fullPath = join(cwd, dirPath);
72
- const entries = readdirSync(fullPath);
73
- const matches = [];
74
- for (const entry of entries) {
75
- const entryPath = join(fullPath, entry);
76
- const stat = statSync(entryPath);
77
- const completion = prefix + entry + (stat.isDirectory() ? '/' : '');
78
- if (completion.startsWith(ctx.partial)) {
79
- matches.push(completion);
80
- }
81
- }
82
- return matches.slice(0, 20);
83
- }
84
- catch {
85
- return [];
86
- }
87
- }
88
- }
89
- export class ProviderArgProvider {
90
- name = 'provider-args';
91
- providers;
92
- constructor(providers) {
93
- this.providers = providers;
94
- }
95
- match(ctx) {
96
- return ctx.tokenIndex === 2 && ctx.tokens[0] === '/provider' && ctx.tokens[1] === 'use';
97
- }
98
- complete(ctx) {
99
- return this.providers.filter(p => p.startsWith(ctx.partial));
100
- }
101
- }
102
- export class SessionNameProvider {
103
- name = 'session-names';
104
- getNames;
105
- constructor(getNames) {
106
- this.getNames = getNames;
107
- }
108
- match(ctx) {
109
- return ctx.tokenIndex >= 1 && ctx.tokens[0] === '/resume';
110
- }
111
- complete(ctx) {
112
- const names = this.getNames();
113
- if (!ctx.partial)
114
- return names;
115
- return names.filter(n => n.toLowerCase().includes(ctx.partial.toLowerCase()));
116
- }
117
- }
118
- export class SkillNameProvider {
119
- name = 'skill-names';
120
- skillsModule;
121
- constructor(skillsModule) {
122
- this.skillsModule = skillsModule;
123
- }
124
- match(ctx) {
125
- return ctx.tokenIndex >= 2 && ctx.tokens[0] === '/skill' &&
126
- (ctx.tokens[1] === 'load' || ctx.tokens[1] === 'unload');
127
- }
128
- complete(ctx) {
129
- const subcmd = ctx.tokens[1];
130
- if (subcmd === 'load') {
131
- const available = this.skillsModule.getAvailable();
132
- const names = available.map(s => s.name);
133
- if (!ctx.partial)
134
- return names;
135
- return names.filter(n => n.toLowerCase().includes(ctx.partial.toLowerCase()));
136
- }
137
- if (subcmd === 'unload') {
138
- const loaded = this.skillsModule.getLoaded();
139
- const names = loaded.map(s => s.name);
140
- if (!ctx.partial)
141
- return names;
142
- return names.filter(n => n.toLowerCase().includes(ctx.partial.toLowerCase()));
143
- }
144
- return [];
145
- }
146
- }
147
- export class Completer {
148
- providers = [];
149
- registerProvider(provider) {
150
- this.providers.push(provider);
151
- }
152
- complete(line) {
153
- const cursor = line.length;
154
- const tokens = line.split(/\s+/);
155
- const partial = tokens[tokens.length - 1] || '';
156
- const tokenIndex = tokens.length - 1;
157
- const ctx = { line, cursor, tokens, partial, tokenIndex };
158
- for (const provider of this.providers) {
159
- if (provider.match(ctx)) {
160
- const results = provider.complete(ctx);
161
- if (results.length > 0) {
162
- return [results, partial];
163
- }
164
- }
165
- }
166
- return [[], partial];
167
- }
168
- }
package/dist/cli/index.js DELETED
@@ -1,2 +0,0 @@
1
- export { main } from './main';
2
- export { createProgram } from './commands';