micro-models-agent 0.23.0 → 0.24.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.
Files changed (171) hide show
  1. package/README.md +312 -312
  2. package/bin/mma.mjs +8 -8
  3. package/dist/main.js +8777 -864
  4. package/package.json +4 -3
  5. package/dist/cli/commands.js +0 -220
  6. package/dist/cli/completer.js +0 -168
  7. package/dist/cli/index.js +0 -2
  8. package/dist/cli/main.js +0 -113
  9. package/dist/cli/repl.js +0 -987
  10. package/dist/cli/security-commands.js +0 -166
  11. package/dist/cli/setup.js +0 -229
  12. package/dist/config/config.js +0 -186
  13. package/dist/config/defaults.js +0 -91
  14. package/dist/config/experts.js +0 -15
  15. package/dist/config/index.js +0 -3
  16. package/dist/config/security.js +0 -193
  17. package/dist/config/types.js +0 -1
  18. package/dist/core/agent-moe.js +0 -98
  19. package/dist/core/agent.js +0 -461
  20. package/dist/core/bootstrap.js +0 -321
  21. package/dist/core/index.js +0 -2
  22. package/dist/core/prompt-builder.js +0 -55
  23. package/dist/core/session-logger.js +0 -122
  24. package/dist/core/types.js +0 -1
  25. package/dist/i18n/en.json +0 -461
  26. package/dist/i18n/index.js +0 -43
  27. package/dist/i18n/ru.json +0 -461
  28. package/dist/index.js +0 -22
  29. package/dist/llm/image-utils.js +0 -144
  30. package/dist/llm/index.js +0 -4
  31. package/dist/llm/model-loader.js +0 -78
  32. package/dist/llm/openai-compat.js +0 -324
  33. package/dist/llm/orchestrator.js +0 -194
  34. package/dist/llm/provider.js +0 -10
  35. package/dist/llm/response.js +0 -39
  36. package/dist/llm/token-counter.js +0 -39
  37. package/dist/llm/types.js +0 -1
  38. package/dist/logger/app-logger.js +0 -76
  39. package/dist/logger/index.js +0 -1
  40. package/dist/migration/backup.js +0 -45
  41. package/dist/migration/detect.js +0 -50
  42. package/dist/migration/index.js +0 -2
  43. package/dist/modules/browser/actions.js +0 -46
  44. package/dist/modules/browser/cookie-store.js +0 -24
  45. package/dist/modules/browser/index.js +0 -5
  46. package/dist/modules/browser/module.js +0 -28
  47. package/dist/modules/browser/session.js +0 -287
  48. package/dist/modules/browser/snapshot.js +0 -114
  49. package/dist/modules/browser/types.js +0 -9
  50. package/dist/modules/context/history.js +0 -15
  51. package/dist/modules/context/index.js +0 -1
  52. package/dist/modules/context/manager.js +0 -240
  53. package/dist/modules/execution/auditor.js +0 -72
  54. package/dist/modules/execution/index.js +0 -6
  55. package/dist/modules/execution/module.js +0 -337
  56. package/dist/modules/execution/moe-executor.js +0 -209
  57. package/dist/modules/execution/plan-validator.js +0 -153
  58. package/dist/modules/execution/planner.js +0 -35
  59. package/dist/modules/execution/stuck-detector.js +0 -134
  60. package/dist/modules/execution/tracker.js +0 -53
  61. package/dist/modules/execution/types.js +0 -1
  62. package/dist/modules/execution/verifier.js +0 -149
  63. package/dist/modules/hallucination/confidence.js +0 -54
  64. package/dist/modules/hallucination/consistency.js +0 -60
  65. package/dist/modules/hallucination/detector.js +0 -41
  66. package/dist/modules/hallucination/factual.js +0 -170
  67. package/dist/modules/hallucination/index.js +0 -4
  68. package/dist/modules/index.js +0 -5
  69. package/dist/modules/indexer/cache.js +0 -38
  70. package/dist/modules/indexer/index.js +0 -3
  71. package/dist/modules/indexer/module.js +0 -192
  72. package/dist/modules/indexer/walker.js +0 -101
  73. package/dist/modules/mcp/client.js +0 -393
  74. package/dist/modules/mcp/index.js +0 -3
  75. package/dist/modules/mcp/module.js +0 -146
  76. package/dist/modules/mcp/registry.js +0 -15
  77. package/dist/modules/memory/index.js +0 -1
  78. package/dist/modules/memory/module.js +0 -48
  79. package/dist/modules/memory/search.js +0 -40
  80. package/dist/modules/memory/store.js +0 -65
  81. package/dist/modules/pipelines/engine.js +0 -60
  82. package/dist/modules/pipelines/index.js +0 -3
  83. package/dist/modules/pipelines/parser.js +0 -53
  84. package/dist/modules/pipelines/template.js +0 -14
  85. package/dist/modules/plugins/builtin/lint-on-write.js +0 -121
  86. package/dist/modules/plugins/builtin/notify.js +0 -8
  87. package/dist/modules/plugins/index.js +0 -1
  88. package/dist/modules/plugins/loader.js +0 -28
  89. package/dist/modules/plugins/manager.js +0 -161
  90. package/dist/modules/plugins/types.js +0 -1
  91. package/dist/modules/processes/detect.js +0 -34
  92. package/dist/modules/processes/index.js +0 -3
  93. package/dist/modules/processes/registry.js +0 -148
  94. package/dist/modules/processes/runner.js +0 -124
  95. package/dist/modules/registry.js +0 -45
  96. package/dist/modules/security/audit-log.js +0 -116
  97. package/dist/modules/security/audit-notifier.js +0 -292
  98. package/dist/modules/security/command-validator.js +0 -185
  99. package/dist/modules/security/content-scanner.js +0 -52
  100. package/dist/modules/security/data-sanitizer.js +0 -97
  101. package/dist/modules/security/encryption.js +0 -240
  102. package/dist/modules/security/index.js +0 -14
  103. package/dist/modules/security/network-validator.js +0 -79
  104. package/dist/modules/security/path-validator.js +0 -155
  105. package/dist/modules/security/rate-limiter.js +0 -119
  106. package/dist/modules/security/security-policies.js +0 -393
  107. package/dist/modules/security/session-encryption.js +0 -193
  108. package/dist/modules/security/session-isolation.js +0 -95
  109. package/dist/modules/session/index.js +0 -3
  110. package/dist/modules/session/manager.js +0 -167
  111. package/dist/modules/session/module.js +0 -24
  112. package/dist/modules/session/store.js +0 -174
  113. package/dist/modules/session/types.js +0 -1
  114. package/dist/modules/skills/index.js +0 -3
  115. package/dist/modules/skills/loader.js +0 -72
  116. package/dist/modules/skills/matcher.js +0 -27
  117. package/dist/modules/skills/module.js +0 -143
  118. package/dist/modules/types.js +0 -1
  119. package/dist/modules/updater/checker.js +0 -32
  120. package/dist/modules/updater/index.js +0 -1
  121. package/dist/modules/user-profile/compressor.js +0 -16
  122. package/dist/modules/user-profile/index.js +0 -1
  123. package/dist/modules/user-profile/profile.js +0 -68
  124. package/dist/skills/builtin/builtin/git.md +0 -36
  125. package/dist/skills/builtin/builtin/typescript.md +0 -35
  126. package/dist/tools/approve.js +0 -32
  127. package/dist/tools/attach-image.js +0 -89
  128. package/dist/tools/bash.js +0 -140
  129. package/dist/tools/browser.js +0 -97
  130. package/dist/tools/create-dir.js +0 -56
  131. package/dist/tools/delete-file.js +0 -63
  132. package/dist/tools/edit-file.js +0 -77
  133. package/dist/tools/executor.js +0 -95
  134. package/dist/tools/file-info.js +0 -45
  135. package/dist/tools/filter-tools.js +0 -10
  136. package/dist/tools/glob-tool.js +0 -26
  137. package/dist/tools/grep-tool.js +0 -64
  138. package/dist/tools/index.js +0 -52
  139. package/dist/tools/list-dir.js +0 -47
  140. package/dist/tools/load-skill.js +0 -48
  141. package/dist/tools/mcp-call.js +0 -68
  142. package/dist/tools/move-file.js +0 -84
  143. package/dist/tools/path-utils.js +0 -51
  144. package/dist/tools/pipeline-run.js +0 -144
  145. package/dist/tools/preview.js +0 -2
  146. package/dist/tools/process-kill.js +0 -29
  147. package/dist/tools/process-list.js +0 -38
  148. package/dist/tools/process-log.js +0 -41
  149. package/dist/tools/question.js +0 -142
  150. package/dist/tools/read-file.js +0 -73
  151. package/dist/tools/recall.js +0 -110
  152. package/dist/tools/registry.js +0 -36
  153. package/dist/tools/remember.js +0 -67
  154. package/dist/tools/scope-check.js +0 -30
  155. package/dist/tools/search-history.js +0 -64
  156. package/dist/tools/subagent.js +0 -142
  157. package/dist/tools/types.js +0 -1
  158. package/dist/tools/user-input.js +0 -123
  159. package/dist/tools/web-browse.js +0 -57
  160. package/dist/tools/web-fetch.js +0 -72
  161. package/dist/tools/web-search.js +0 -59
  162. package/dist/tools/write-file.js +0 -80
  163. package/dist/ui/box.js +0 -81
  164. package/dist/ui/colors.js +0 -4
  165. package/dist/ui/diff.js +0 -185
  166. package/dist/ui/index.js +0 -6
  167. package/dist/ui/md-formatter.js +0 -212
  168. package/dist/ui/output.js +0 -13
  169. package/dist/ui/renderer.js +0 -141
  170. package/dist/ui/spinner.js +0 -70
  171. package/dist/ui/table.js +0 -144
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "micro-models-agent",
3
- "version": "0.23.0",
3
+ "version": "0.24.1",
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": {
@@ -17,7 +17,7 @@
17
17
  "mma": "bun run src/cli/main.ts",
18
18
  "build": "bun run build:tsc && bun run build:copy-assets",
19
19
  "build:tsc": "tsc -p tsconfig.build.json",
20
- "build:copy-assets": "powershell -Command \"Copy-Item -Recurse -Force 'src/modules/skills/builtin' 'dist/skills/builtin'\"",
20
+ "build:copy-assets": "bun run scripts/copy-assets.ts",
21
21
  "build:prod": "bun run 'build:bundle' && bun run 'build:copy-assets'",
22
22
  "build:clean": "cmd /c \"if exist dist rmdir /s /q dist\"",
23
23
  "build:bundle": "bun build ./src/cli/main.ts --outfile ./dist/main.js --target node --format esm --external playwright",
@@ -33,7 +33,8 @@
33
33
  "jsonrepair": "^3.15.0",
34
34
  "picocolors": "^1.1.1",
35
35
  "playwright": "^1.62.0",
36
- "string-width": "^8.2.2"
36
+ "string-width": "^8.2.2",
37
+ "yaml": "^2.9.0"
37
38
  },
38
39
  "devDependencies": {
39
40
  "@types/bun": "^1.3.14",
@@ -1,220 +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 } from "path";
7
- import { homedir } from "os";
8
- import { createSecurityCommand } from "./security-commands";
9
- import { version } from "../../package.json";
10
- export function createProgram() {
11
- const program = new Command()
12
- .name("mma")
13
- .description(t("cli.description"))
14
- .version(version)
15
- .option("--no-agents-md", t("cli.no_agents_md"))
16
- .option("-d, --dir <path>", t("cli.dir"))
17
- .option("-e, --exit-on-complete", t("cli.exit_on_complete"))
18
- .option("-j, --json", t("cli.json"));
19
- program
20
- .command("init")
21
- .description(t("cli.init"))
22
- .action(async () => {
23
- const answers = await runSetup();
24
- const configPath = join(homedir(), ".mma", "config.json");
25
- const { config } = await bootstrap();
26
- config.provider.type = answers.provider;
27
- config.provider.baseUrl = answers.apiBase;
28
- config.provider.apiKey = answers.apiKey;
29
- config.model = answers.model;
30
- config.contextWindow = answers.contextWindow;
31
- config.maxToolIterations = answers.maxToolIterations;
32
- config.locale = answers.locale;
33
- saveConfig(config, configPath);
34
- console.log(t("cli.config_saved"));
35
- });
36
- const configCmd = program
37
- .command("config")
38
- .description(t("cli.manage_config"));
39
- configCmd
40
- .command("set")
41
- .argument("<key>", t("cli.config_key"))
42
- .argument("<value>", "Config value")
43
- .description(t("cli.set_value"))
44
- .action(async (key, value) => {
45
- const configPath = join(homedir(), ".mma", "config.json");
46
- const { config } = await bootstrap();
47
- const keys = key.split(".");
48
- let obj = config;
49
- for (let i = 0; i < keys.length - 1; i++) {
50
- if (!(keys[i] in obj))
51
- obj[keys[i]] = {};
52
- obj = obj[keys[i]];
53
- }
54
- const lastKey = keys[keys.length - 1];
55
- if (value === "true")
56
- obj[lastKey] = true;
57
- else if (value === "false")
58
- obj[lastKey] = false;
59
- else if (/^\d+$/.test(value))
60
- obj[lastKey] = parseInt(value, 10);
61
- else if (/^\d+\.\d+$/.test(value))
62
- obj[lastKey] = parseFloat(value);
63
- else
64
- obj[lastKey] = value;
65
- saveConfig(config, configPath);
66
- console.log(t("cli.set_done", { key, value }));
67
- });
68
- configCmd
69
- .command("show")
70
- .description(t("cli.show_config"))
71
- .action(async () => {
72
- const { config } = await bootstrap();
73
- console.log(JSON.stringify(config, null, 2));
74
- });
75
- const model = program.command("model").description(t("cli.manage_models"));
76
- model
77
- .command("list")
78
- .description(t("cli.list_models"))
79
- .action(async () => {
80
- const { config } = await bootstrap();
81
- console.log(t("cli.current_model"), config.model);
82
- // Fetch available models from provider
83
- const { OpenAICompatProvider } = await import("../llm/openai-compat");
84
- const provider = new OpenAICompatProvider({
85
- model: config.model,
86
- baseUrl: config.provider.baseUrl,
87
- apiKey: config.provider.apiKey,
88
- contextWindow: config.contextWindow,
89
- });
90
- const spinner = (await import("../ui/spinner")).Spinner;
91
- const s = new spinner();
92
- s.start(t("cli.fetching_models"));
93
- try {
94
- const models = await provider.listModels();
95
- s.stop();
96
- if (models.length > 0) {
97
- console.log(t("cli.available_models"));
98
- for (const m of models) {
99
- const marker = m === config.model ? "* " : " ";
100
- console.log(` ${marker}${m}`);
101
- }
102
- }
103
- else {
104
- console.log(t("cli.no_models_found"));
105
- }
106
- }
107
- catch (err) {
108
- s.stop();
109
- console.log(t("cli.model_fetch_failed", { error: String(err) }));
110
- }
111
- console.log(t("cli.model_hint"));
112
- });
113
- model
114
- .command("use")
115
- .argument("<name>", "Model name")
116
- .description(t("cli.set_model"))
117
- .action(async (name) => {
118
- const configPath = join(homedir(), ".mma", "config.json");
119
- const { config } = await bootstrap();
120
- config.model = name;
121
- saveConfig(config, configPath);
122
- console.log(t("cli.model_set", { name }));
123
- });
124
- // Context window command
125
- program
126
- .command("context")
127
- .description(t("cli.manage_context"))
128
- .argument("<size>", "Context window size in tokens")
129
- .action(async (size) => {
130
- const configPath = join(homedir(), ".mma", "config.json");
131
- const { config } = await bootstrap();
132
- const contextWindow = parseInt(size, 10);
133
- if (isNaN(contextWindow) || contextWindow < 1024) {
134
- console.log(t("cli.invalid_context_size"));
135
- return;
136
- }
137
- config.contextWindow = contextWindow;
138
- saveConfig(config, configPath);
139
- console.log(t("cli.context_set", { size: contextWindow }));
140
- });
141
- const provider = program
142
- .command("provider")
143
- .description(t("cli.manage_providers"));
144
- provider
145
- .command("list")
146
- .description(t("cli.list_providers"))
147
- .action(async () => {
148
- const { config } = await bootstrap();
149
- console.log(t("cli.current_provider"), config.provider.type);
150
- console.log(t("cli.base_url"), config.provider.baseUrl);
151
- });
152
- provider
153
- .command("use")
154
- .argument("<name>", "Provider name")
155
- .description(t("cli.set_provider"))
156
- .action(async (name) => {
157
- const configPath = join(homedir(), ".mma", "config.json");
158
- const { config } = await bootstrap();
159
- config.provider.type = name;
160
- saveConfig(config, configPath);
161
- console.log(t("cli.provider_set", { name }));
162
- });
163
- const session = program
164
- .command("session")
165
- .description(t("cli.manage_sessions"));
166
- session
167
- .command("list")
168
- .description(t("cli.list_sessions"))
169
- .action(async () => {
170
- const { sessionManager } = await bootstrap();
171
- const sessions = sessionManager.list();
172
- if (sessions.length === 0) {
173
- console.log(t("session.no_sessions"));
174
- return;
175
- }
176
- const active = sessionManager.getActive();
177
- for (const s of sessions) {
178
- const marker = s.id === active ? "*" : " ";
179
- console.log(` ${marker} ${s.id.slice(0, 12)} ${s.name} ${s.messageCount} msgs ${s.updatedAt.slice(0, 10)}`);
180
- }
181
- });
182
- session
183
- .command("show")
184
- .argument("<id>", "Session id")
185
- .description(t("cli.show_details"))
186
- .action(async (id) => {
187
- const { sessionManager } = await bootstrap();
188
- const meta = sessionManager.get(id);
189
- if (!meta) {
190
- console.log(t("session.not_found", { id }));
191
- return;
192
- }
193
- console.log(`ID: ${meta.id}`);
194
- console.log(`Name: ${meta.name}`);
195
- console.log(`Created: ${meta.createdAt}`);
196
- console.log(`Updated: ${meta.updatedAt}`);
197
- console.log(`Messages: ${meta.messageCount}`);
198
- console.log(`Model: ${meta.model}`);
199
- console.log(`Context: ${meta.contextWindow}`);
200
- console.log(`Project: ${meta.projectDir}`);
201
- });
202
- session
203
- .command("delete")
204
- .argument("<id>", "Session id")
205
- .description(t("cli.delete_session"))
206
- .action(async (id) => {
207
- const { sessionManager } = await bootstrap();
208
- sessionManager.delete(id);
209
- console.log(t("session.deleted", { id }));
210
- });
211
- // Add security commands
212
- createSecurityCommand(program);
213
- program
214
- .argument("[prompt...]", "Prompt to execute")
215
- .description("Run a single prompt")
216
- .action((prompt) => {
217
- /* Handled by main.ts after program.parse() */
218
- });
219
- return program;
220
- }
@@ -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';
package/dist/cli/main.js DELETED
@@ -1,113 +0,0 @@
1
- import { createProgram } from "./commands";
2
- import { bootstrap } from "../core/bootstrap";
3
- import { Repl } from "./repl";
4
- import { formatMarkdown } from "../ui/md-formatter";
5
- import { Renderer } from "../ui/renderer";
6
- import { runSetup } from "./setup";
7
- import { saveConfig } from "../config/config";
8
- import { t } from "../i18n/index";
9
- import { pc } from "../ui/colors";
10
- import { existsSync } from "fs";
11
- import { join } from "path";
12
- import { homedir } from "os";
13
- async function main() {
14
- const program = createProgram();
15
- program.parse(process.argv);
16
- const cmdNames = new Set(program.commands.map((c) => c.name()));
17
- const opts = program.opts();
18
- const noAgentsMd = opts.noAgentsMd === true;
19
- const projectDir = opts.dir;
20
- const exitOnComplete = opts.exitOnComplete === true;
21
- const jsonMode = opts.json === true;
22
- const isSubcommand = program.args.length > 0 && cmdNames.has(program.args[0]);
23
- if (isSubcommand) {
24
- return;
25
- }
26
- if (program.args.length > 0) {
27
- const prompt = program.args.join(" ");
28
- const { agent, config } = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
29
- if (jsonMode) {
30
- const result = await agent.run(prompt);
31
- agent.shutdown();
32
- process.stdout.write(JSON.stringify({
33
- success: result.success,
34
- text: result.text,
35
- error: result.error ?? null,
36
- iterationCount: result.iterationCount,
37
- contextUsed: result.contextUsed ?? null,
38
- contextLimit: result.contextLimit ?? null,
39
- promptTokens: result.promptTokens ?? null,
40
- completionTokens: result.completionTokens ?? null,
41
- totalTokens: result.totalTokens ?? null,
42
- }, null, 2));
43
- process.stdout.write("\n");
44
- process.exit(result.success ? 0 : 1);
45
- }
46
- const renderer = new Renderer({ spinner: config.ui?.spinner ?? true });
47
- const result = await agent.run(prompt, (chunk) => renderer.text(chunk), (meta) => renderer.meta(meta), (ev) => {
48
- if (ev.type === "start") {
49
- renderer.toolStart(ev.tool, ev.args);
50
- }
51
- else {
52
- renderer.toolEnd(ev.tool, ev.duration ?? 0, ev.error);
53
- }
54
- }, (phase) => {
55
- if (phase === "thinking") {
56
- renderer.thinkingStart();
57
- }
58
- else {
59
- renderer.thinkingEnd();
60
- }
61
- });
62
- renderer.flush();
63
- if (result.success) {
64
- if (!result.text) {
65
- console.log(pc.yellow(t("cli.no_output")));
66
- }
67
- }
68
- else {
69
- console.error(`${t("error.prefix")}${result.error}`);
70
- if (result.text) {
71
- console.log(formatMarkdown(result.text));
72
- }
73
- process.exit(1);
74
- }
75
- agent.shutdown();
76
- }
77
- else {
78
- const configPath = join(homedir(), ".mma", "config.json");
79
- if (!existsSync(configPath)) {
80
- console.log(pc.yellow("\n " + t("cli.first_run") + "\n"));
81
- const answers = await runSetup();
82
- const { config } = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
83
- config.provider.type = answers.provider;
84
- config.provider.baseUrl = answers.apiBase;
85
- config.provider.apiKey = answers.apiKey;
86
- config.model = answers.model;
87
- config.contextWindow = answers.contextWindow;
88
- config.maxToolIterations = answers.maxToolIterations;
89
- config.locale = answers.locale;
90
- if (config.security) {
91
- config.security.bash.blockDangerousFlags = answers.securityFlagsBlock;
92
- if (answers.securityBashBlock) {
93
- config.security.bash.blacklist = [
94
- ...new Set([
95
- ...config.security.bash.blacklist,
96
- "rm", "dd", "chmod", "wget", "curl", "scp", "ssh", "nc", "netcat",
97
- "sudo", "su", "kill", "pkill", "killall", "shutdown", "reboot",
98
- ]),
99
- ];
100
- }
101
- if (!answers.securityPathsDeny) {
102
- config.security.paths.denied = [];
103
- }
104
- }
105
- saveConfig(config, configPath);
106
- }
107
- const { agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, } = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
108
- const repl = new Repl(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd);
109
- repl.start();
110
- }
111
- }
112
- main();
113
- export { main };