@miller-tech/uap 1.3.5 → 1.4.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 (41) hide show
  1. package/dist/bin/cli.js +285 -120
  2. package/dist/bin/cli.js.map +1 -1
  3. package/dist/cli/init.d.ts.map +1 -1
  4. package/dist/cli/init.js +3 -3
  5. package/dist/cli/init.js.map +1 -1
  6. package/dist/cli/task.js +9 -3
  7. package/dist/cli/task.js.map +1 -1
  8. package/dist/coordination/service.d.ts.map +1 -1
  9. package/dist/coordination/service.js +4 -1
  10. package/dist/coordination/service.js.map +1 -1
  11. package/dist/mcp-router/executor/client.d.ts.map +1 -1
  12. package/dist/mcp-router/executor/client.js +10 -3
  13. package/dist/mcp-router/executor/client.js.map +1 -1
  14. package/dist/mcp-router/output-compressor.d.ts.map +1 -1
  15. package/dist/mcp-router/output-compressor.js +146 -26
  16. package/dist/mcp-router/output-compressor.js.map +1 -1
  17. package/dist/mcp-router/search/fuzzy.d.ts +1 -0
  18. package/dist/mcp-router/search/fuzzy.d.ts.map +1 -1
  19. package/dist/mcp-router/search/fuzzy.js +16 -6
  20. package/dist/mcp-router/search/fuzzy.js.map +1 -1
  21. package/dist/mcp-router/server.d.ts +5 -2
  22. package/dist/mcp-router/server.d.ts.map +1 -1
  23. package/dist/mcp-router/server.js +125 -29
  24. package/dist/mcp-router/server.js.map +1 -1
  25. package/dist/memory/knowledge-graph.d.ts +2 -1
  26. package/dist/memory/knowledge-graph.d.ts.map +1 -1
  27. package/dist/memory/knowledge-graph.js +56 -33
  28. package/dist/memory/knowledge-graph.js.map +1 -1
  29. package/dist/policies/policy-gate.d.ts +14 -1
  30. package/dist/policies/policy-gate.d.ts.map +1 -1
  31. package/dist/policies/policy-gate.js +129 -12
  32. package/dist/policies/policy-gate.js.map +1 -1
  33. package/dist/policies/schemas/policy.d.ts +2 -2
  34. package/dist/tasks/service.d.ts +7 -2
  35. package/dist/tasks/service.d.ts.map +1 -1
  36. package/dist/tasks/service.js +90 -18
  37. package/dist/tasks/service.js.map +1 -1
  38. package/dist/tasks/types.d.ts +8 -0
  39. package/dist/tasks/types.d.ts.map +1 -1
  40. package/dist/tasks/types.js.map +1 -1
  41. package/package.json +1 -1
package/dist/bin/cli.js CHANGED
@@ -4,28 +4,32 @@ import { existsSync, readFileSync } from 'fs';
4
4
  import { execSync } from 'child_process';
5
5
  import { fileURLToPath } from 'url';
6
6
  import { dirname, join } from 'path';
7
- import { initCommand } from '../cli/init.js';
8
- import { analyzeCommand } from '../cli/analyze.js';
9
- import { generateCommand } from '../cli/generate.js';
10
- import { memoryCommand } from '../cli/memory.js';
11
- import { worktreeCommand } from '../cli/worktree.js';
12
- import { syncCommand } from '../cli/sync.js';
13
- import { droidsCommand } from '../cli/droids.js';
14
- import { coordCommand } from '../cli/coord.js';
15
- import { agentCommand } from '../cli/agent.js';
16
- import { deployCommand } from '../cli/deploy.js';
17
- import { taskCommand } from '../cli/task.js';
18
- import { registerModelCommands } from '../cli/model.js';
19
- import { mcpRouterCommand } from '../cli/mcp-router.js';
20
- import { dashboardCommand } from '../cli/dashboard.js';
21
- import { hooksCommand } from '../cli/hooks.js';
22
- import { patternsCommand } from '../cli/patterns.js';
23
- import { setupCommand } from '../cli/setup.js';
24
- import { setupMcpRouter } from '../cli/setup-mcp-router.js';
25
- import { complianceCommand } from '../cli/compliance.js';
26
- import { registerSchemaDiffCommand } from '../cli/schema-diff.js';
27
- import { installRTK, checkRTKStatus, showRTKHelp } from '../cli/rtk.js';
28
- import { toolCallsCommand } from '../cli/tool-calls.js';
7
+ // Lazy import helpers - commands are loaded on-demand to reduce startup time (~10x faster --help)
8
+ // Each command module is only imported when its action handler is invoked.
9
+ const lazy = {
10
+ init: () => import('../cli/init.js').then((m) => m.initCommand),
11
+ analyze: () => import('../cli/analyze.js').then((m) => m.analyzeCommand),
12
+ generate: () => import('../cli/generate.js').then((m) => m.generateCommand),
13
+ memory: () => import('../cli/memory.js').then((m) => m.memoryCommand),
14
+ worktree: () => import('../cli/worktree.js').then((m) => m.worktreeCommand),
15
+ sync: () => import('../cli/sync.js').then((m) => m.syncCommand),
16
+ droids: () => import('../cli/droids.js').then((m) => m.droidsCommand),
17
+ coord: () => import('../cli/coord.js').then((m) => m.coordCommand),
18
+ agent: () => import('../cli/agent.js').then((m) => m.agentCommand),
19
+ deploy: () => import('../cli/deploy.js').then((m) => m.deployCommand),
20
+ task: () => import('../cli/task.js').then((m) => m.taskCommand),
21
+ model: () => import('../cli/model.js').then((m) => m.registerModelCommands),
22
+ mcpRouter: () => import('../cli/mcp-router.js').then((m) => m.mcpRouterCommand),
23
+ dashboard: () => import('../cli/dashboard.js').then((m) => m.dashboardCommand),
24
+ hooks: () => import('../cli/hooks.js'),
25
+ patterns: () => import('../cli/patterns.js').then((m) => m.patternsCommand),
26
+ setup: () => import('../cli/setup.js').then((m) => m.setupCommand),
27
+ setupMcpRouter: () => import('../cli/setup-mcp-router.js').then((m) => m.setupMcpRouter),
28
+ compliance: () => import('../cli/compliance.js').then((m) => m.complianceCommand),
29
+ schemaDiff: () => import('../cli/schema-diff.js').then((m) => m.registerSchemaDiffCommand),
30
+ rtk: () => import('../cli/rtk.js'),
31
+ toolCalls: () => import('../cli/tool-calls.js').then((m) => m.toolCallsCommand),
32
+ };
29
33
  // Read version from package.json
30
34
  const __filename = fileURLToPath(import.meta.url);
31
35
  const __dirname = dirname(__filename);
@@ -46,7 +50,10 @@ program
46
50
  .option('--no-patterns', 'Skip pattern RAG setup')
47
51
  .option('--pipeline-only', 'Enforce pipeline-only infrastructure changes (no direct kubectl/terraform)')
48
52
  .option('-f, --force', 'Overwrite existing configuration')
49
- .action(initCommand);
53
+ .action(async (options) => {
54
+ const cmd = await lazy.init();
55
+ await cmd(options);
56
+ });
50
57
  program
51
58
  .command('setup')
52
59
  .description('Full one-command setup: init + start Qdrant + install Python deps + index patterns')
@@ -55,13 +62,17 @@ program
55
62
  .option('--no-memory', 'Skip memory system setup')
56
63
  .option('-d, --project-dir <path>', 'Target project directory (defaults to current working directory)')
57
64
  .option('-i, --interactive', 'Run interactive setup wizard with feature toggles')
58
- .action(setupCommand);
65
+ .action(async (options) => {
66
+ (await lazy.setup())(options);
67
+ });
59
68
  program
60
69
  .command('analyze')
61
70
  .description('Analyze project structure and generate metadata')
62
71
  .option('-o, --output <format>', 'Output format (json, yaml, md)', 'json')
63
72
  .option('--save', 'Save analysis to .uap.analysis.json')
64
- .action(analyzeCommand);
73
+ .action(async (options) => {
74
+ (await lazy.analyze())(options);
75
+ });
65
76
  program
66
77
  .command('generate')
67
78
  .description('Generate or update CLAUDE.md and related files')
@@ -70,29 +81,39 @@ program
70
81
  .option('-p, --platform <platform>', 'Generate for specific platform only')
71
82
  .option('--web', 'Generate AGENT.md for web platforms (claude.ai, factory.ai)')
72
83
  .option('--pipeline-only', 'Enforce pipeline-only infrastructure changes (no direct kubectl/terraform)')
73
- .action(generateCommand);
84
+ .action(async (options) => {
85
+ (await lazy.generate())(options);
86
+ });
74
87
  program
75
88
  .command('memory')
76
89
  .description('Manage agent memory system')
77
- .addCommand(new Command('status')
78
- .description('Show memory system status')
79
- .action(() => memoryCommand('status')))
90
+ .addCommand(new Command('status').description('Show memory system status').action(async () => {
91
+ (await lazy.memory())('status');
92
+ }))
80
93
  .addCommand(new Command('start')
81
94
  .description('Start memory services (Qdrant container)')
82
- .action(() => memoryCommand('start')))
83
- .addCommand(new Command('stop').description('Stop memory services').action(() => memoryCommand('stop')))
95
+ .action(async () => {
96
+ (await lazy.memory())('start');
97
+ }))
98
+ .addCommand(new Command('stop').description('Stop memory services').action(async () => {
99
+ (await lazy.memory())('stop');
100
+ }))
84
101
  .addCommand(new Command('query')
85
102
  .description('Query long-term memory')
86
103
  .argument('<search>', 'Search term')
87
104
  .option('-n, --limit <number>', 'Max results', '10')
88
- .action((search, options) => memoryCommand('query', { search, ...options })))
105
+ .action(async (search, options) => {
106
+ (await lazy.memory())('query', { search, ...options });
107
+ }))
89
108
  .addCommand(new Command('store')
90
109
  .description('Store a memory (applies write gate unless --force)')
91
110
  .argument('<content>', 'Memory content')
92
111
  .option('-t, --tags <tags>', 'Comma-separated tags')
93
112
  .option('-i, --importance <number>', 'Importance score (1-10)', '5')
94
113
  .option('-f, --force', 'Bypass write gate (store without quality check)')
95
- .action((content, options) => memoryCommand('store', { content, ...options })))
114
+ .action(async (content, options) => {
115
+ (await lazy.memory())('store', { content, ...options });
116
+ }))
96
117
  .addCommand(new Command('prepopulate')
97
118
  .description('Prepopulate memory from documentation and git history')
98
119
  .option('--docs', 'Import from documentation only')
@@ -100,79 +121,111 @@ program
100
121
  .option('-n, --limit <number>', 'Limit git commits to analyze', '500')
101
122
  .option('--since <date>', 'Only analyze commits since date (e.g., "2024-01-01")')
102
123
  .option('-v, --verbose', 'Show detailed output')
103
- .action((options) => memoryCommand('prepopulate', options)))
124
+ .action(async (options) => {
125
+ (await lazy.memory())('prepopulate', options);
126
+ }))
104
127
  .addCommand(new Command('promote')
105
128
  .description('Review and promote daily log entries to working/semantic memory')
106
- .action((options) => memoryCommand('promote', options)))
129
+ .action(async (options) => {
130
+ (await lazy.memory())('promote', options);
131
+ }))
107
132
  .addCommand(new Command('correct')
108
133
  .description('Correct a memory (propagates across all tiers, marks old as superseded)')
109
134
  .argument('<search>', 'Search term to find the memory to correct')
110
135
  .option('-c, --correction <text>', 'The corrected content')
111
136
  .option('-r, --reason <reason>', 'Reason for correction')
112
- .action((search, options) => memoryCommand('correct', { search, ...options })))
137
+ .action(async (search, options) => {
138
+ (await lazy.memory())('correct', { search, ...options });
139
+ }))
113
140
  .addCommand(new Command('maintain')
114
141
  .description('Run maintenance: decay, prune stale, archive old, remove duplicates')
115
142
  .option('-v, --verbose', 'Show detailed output')
116
- .action((options) => memoryCommand('maintain', options)));
143
+ .action(async (options) => {
144
+ (await lazy.memory())('maintain', options);
145
+ }));
117
146
  // Pattern RAG Commands
118
147
  program
119
148
  .command('patterns')
120
149
  .description('Manage pattern RAG (on-demand pattern retrieval via Qdrant)')
121
150
  .addCommand(new Command('status')
122
151
  .description('Show pattern RAG status and collection info')
123
- .action(() => patternsCommand('status')))
152
+ .action(async () => {
153
+ (await lazy.patterns())('status');
154
+ }))
124
155
  .addCommand(new Command('index')
125
156
  .description('Index patterns from CLAUDE.md into Qdrant')
126
157
  .option('-v, --verbose', 'Show detailed output')
127
- .action((options) => patternsCommand('index', options)))
158
+ .action(async (options) => {
159
+ (await lazy.patterns())('index', options);
160
+ }))
128
161
  .addCommand(new Command('query')
129
162
  .description('Query patterns by task description')
130
163
  .argument('<search>', 'Task description to match')
131
164
  .option('-n, --top <number>', 'Number of results', '2')
132
165
  .option('--min-score <number>', 'Minimum similarity score', '0.35')
133
166
  .option('--format <format>', 'Output format (text, json, context)', 'text')
134
- .action((search, options) => patternsCommand('query', { search, ...options })))
167
+ .action(async (search, options) => {
168
+ (await lazy.patterns())('query', { search, ...options });
169
+ }))
135
170
  .addCommand(new Command('generate')
136
171
  .description('Generate Python index/query scripts from config')
137
172
  .option('-f, --force', 'Overwrite existing scripts')
138
- .action((options) => patternsCommand('generate', options)));
173
+ .action(async (options) => {
174
+ (await lazy.patterns())('generate', options);
175
+ }));
139
176
  program
140
177
  .command('worktree')
141
178
  .description('Manage git worktrees')
142
179
  .addCommand(new Command('create')
143
180
  .description('Create a new worktree for a feature')
144
181
  .argument('<slug>', 'Feature slug (e.g., add-user-auth)')
145
- .action((slug) => worktreeCommand('create', { slug })))
146
- .addCommand(new Command('list').description('List all worktrees').action(() => worktreeCommand('list')))
182
+ .action(async (slug) => {
183
+ (await lazy.worktree())('create', { slug });
184
+ }))
185
+ .addCommand(new Command('list').description('List all worktrees').action(async () => {
186
+ (await lazy.worktree())('list');
187
+ }))
147
188
  .addCommand(new Command('pr')
148
189
  .description('Create PR from worktree')
149
190
  .argument('<id>', 'Worktree ID')
150
191
  .option('--draft', 'Create as draft PR')
151
- .action((id, options) => worktreeCommand('pr', { id, ...options })))
192
+ .action(async (id, options) => {
193
+ (await lazy.worktree())('pr', { id, ...options });
194
+ }))
152
195
  .addCommand(new Command('cleanup')
153
196
  .description('Remove worktree and delete branch')
154
197
  .argument('<id>', 'Worktree ID')
155
- .action((id) => worktreeCommand('cleanup', { id })));
198
+ .action(async (id) => {
199
+ (await lazy.worktree())('cleanup', { id });
200
+ }));
156
201
  program
157
202
  .command('sync')
158
203
  .description('Sync configuration between platforms')
159
204
  .option('--from <platform>', 'Source platform (claude, factory, vscode, opencode)')
160
205
  .option('--to <platform>', 'Target platform(s)')
161
206
  .option('--dry-run', 'Preview changes without writing files')
162
- .action(syncCommand);
207
+ .action(async (options) => {
208
+ (await lazy.sync())(options);
209
+ });
163
210
  program
164
211
  .command('droids')
165
212
  .description('Manage custom droids/agents')
166
- .addCommand(new Command('list').description('List all droids').action(() => droidsCommand('list')))
213
+ .addCommand(new Command('list').description('List all droids').action(async () => {
214
+ (await lazy.droids())('list');
215
+ }))
167
216
  .addCommand(new Command('add')
168
217
  .description('Add a new droid')
169
218
  .argument('<name>', 'Droid name')
170
219
  .option('-t, --template <template>', 'Use built-in template')
171
- .action((name, options) => droidsCommand('add', { name, ...options })))
220
+ .action(async (name, options) => {
221
+ (await lazy.droids())('add', { name, ...options });
222
+ }))
172
223
  .addCommand(new Command('import')
173
224
  .description('Import droids from another platform')
174
225
  .argument('<path>', 'Path to import from')
175
- .action((path) => droidsCommand('import', { path })));
226
+ .action(async (path) => {
227
+ (await lazy.droids())('import', { path });
228
+ }));
176
229
  // Agent Coordination Commands
177
230
  program
178
231
  .command('coord')
@@ -180,13 +233,19 @@ program
180
233
  .addCommand(new Command('status')
181
234
  .description('Show coordination status (agents, claims, deploys)')
182
235
  .option('-v, --verbose', 'Show detailed information')
183
- .action((options) => coordCommand('status', options)))
236
+ .action(async (options) => {
237
+ (await lazy.coord())('status', options);
238
+ }))
184
239
  .addCommand(new Command('flush')
185
240
  .description('Force execute all pending deploys')
186
- .action((options) => coordCommand('flush', options)))
241
+ .action(async (options) => {
242
+ (await lazy.coord())('flush', options);
243
+ }))
187
244
  .addCommand(new Command('cleanup')
188
245
  .description('Clean up stale agents and expired data')
189
- .action((options) => coordCommand('cleanup', options)));
246
+ .action(async (options) => {
247
+ (await lazy.coord())('cleanup', options);
248
+ }));
190
249
  program
191
250
  .command('agent')
192
251
  .description('Agent lifecycle, work coordination, and communication')
@@ -195,15 +254,21 @@ program
195
254
  .option('-n, --name <name>', 'Agent name (required)')
196
255
  .option('-c, --capabilities <caps>', 'Comma-separated capabilities')
197
256
  .option('-w, --worktree <branch>', 'Git worktree branch this agent is using')
198
- .action((options) => agentCommand('register', options)))
257
+ .action(async (options) => {
258
+ (await lazy.agent())('register', options);
259
+ }))
199
260
  .addCommand(new Command('heartbeat')
200
261
  .description('Send heartbeat for an agent')
201
262
  .option('-i, --id <id>', 'Agent ID (required)')
202
- .action((options) => agentCommand('heartbeat', options)))
263
+ .action(async (options) => {
264
+ (await lazy.agent())('heartbeat', options);
265
+ }))
203
266
  .addCommand(new Command('status')
204
267
  .description('Show agent status')
205
268
  .option('-i, --id <id>', 'Agent ID (optional, shows all if omitted)')
206
- .action((options) => agentCommand('status', options)))
269
+ .action(async (options) => {
270
+ (await lazy.agent())('status', options);
271
+ }))
207
272
  .addCommand(new Command('announce')
208
273
  .description('Announce intent to work on a resource (informational, enables overlap detection)')
209
274
  .option('-i, --id <id>', 'Agent ID (required)')
@@ -212,40 +277,54 @@ program
212
277
  .option('-d, --description <desc>', 'Description of planned changes')
213
278
  .option('-f, --files <files>', 'Comma-separated list of files that will be affected')
214
279
  .option('--minutes <minutes>', 'Estimated time to complete (in minutes)')
215
- .action((options) => agentCommand('announce', options)))
280
+ .action(async (options) => {
281
+ (await lazy.agent())('announce', options);
282
+ }))
216
283
  .addCommand(new Command('complete')
217
284
  .description('Mark work as complete on a resource (notifies other agents)')
218
285
  .option('-i, --id <id>', 'Agent ID (required)')
219
286
  .option('-r, --resource <resource>', 'Resource that work is complete on')
220
- .action((options) => agentCommand('complete', options)))
287
+ .action(async (options) => {
288
+ (await lazy.agent())('complete', options);
289
+ }))
221
290
  .addCommand(new Command('overlaps')
222
291
  .description('Check for overlapping work (merge conflict risk assessment)')
223
292
  .option('-r, --resource <resource>', 'Resource to check (omit to show all active work)')
224
- .action((options) => agentCommand('overlaps', options)))
293
+ .action(async (options) => {
294
+ (await lazy.agent())('overlaps', options);
295
+ }))
225
296
  .addCommand(new Command('broadcast')
226
297
  .description('Broadcast a message to all agents')
227
298
  .option('-i, --id <id>', 'Agent ID (required)')
228
299
  .option('-c, --channel <channel>', 'Channel: broadcast, deploy, review, coordination')
229
300
  .option('-m, --message <message>', 'Message payload (JSON or string)')
230
301
  .option('-p, --priority <priority>', 'Priority 1-10', '5')
231
- .action((options) => agentCommand('broadcast', options)))
302
+ .action(async (options) => {
303
+ (await lazy.agent())('broadcast', options);
304
+ }))
232
305
  .addCommand(new Command('send')
233
306
  .description('Send a direct message to another agent')
234
307
  .option('-i, --id <id>', 'Sender agent ID (required)')
235
308
  .option('-t, --to <to>', 'Recipient agent ID (required)')
236
309
  .option('-m, --message <message>', 'Message payload (JSON or string)')
237
310
  .option('-p, --priority <priority>', 'Priority 1-10', '5')
238
- .action((options) => agentCommand('send', options)))
311
+ .action(async (options) => {
312
+ (await lazy.agent())('send', options);
313
+ }))
239
314
  .addCommand(new Command('receive')
240
315
  .description('Receive pending messages')
241
316
  .option('-i, --id <id>', 'Agent ID (required)')
242
317
  .option('-c, --channel <channel>', 'Filter by channel')
243
318
  .option('--no-mark-read', 'Do not mark messages as read')
244
- .action((options) => agentCommand('receive', options)))
319
+ .action(async (options) => {
320
+ (await lazy.agent())('receive', options);
321
+ }))
245
322
  .addCommand(new Command('deregister')
246
323
  .description('Deregister an agent')
247
324
  .option('-i, --id <id>', 'Agent ID (required)')
248
- .action((options) => agentCommand('deregister', options)));
325
+ .action(async (options) => {
326
+ (await lazy.agent())('deregister', options);
327
+ }));
249
328
  program
250
329
  .command('deploy')
251
330
  .description('Deployment batching and execution')
@@ -261,37 +340,53 @@ program
261
340
  .option('--ref <ref>', 'Git ref (for workflow action)')
262
341
  .option('--inputs <inputs>', 'Workflow inputs as JSON (for workflow action)')
263
342
  .option('-p, --priority <priority>', 'Priority 1-10', '5')
264
- .action((options) => deployCommand('queue', options)))
343
+ .action(async (options) => {
344
+ (await lazy.deploy())('queue', options);
345
+ }))
265
346
  .addCommand(new Command('batch')
266
347
  .description('Create a batch from pending deploy actions')
267
348
  .option('-v, --verbose', 'Show detailed batch info')
268
- .action((options) => deployCommand('batch', options)))
349
+ .action(async (options) => {
350
+ (await lazy.deploy())('batch', options);
351
+ }))
269
352
  .addCommand(new Command('execute')
270
353
  .description('Execute a deploy batch')
271
354
  .option('-b, --batch-id <id>', 'Batch ID (required)')
272
355
  .option('--dry-run', 'Show what would be executed without running')
273
- .action((options) => deployCommand('execute', options)))
356
+ .action(async (options) => {
357
+ (await lazy.deploy())('execute', options);
358
+ }))
274
359
  .addCommand(new Command('status')
275
360
  .description('Show deploy queue status')
276
361
  .option('-v, --verbose', 'Show detailed status')
277
- .action((options) => deployCommand('status', options)))
362
+ .action(async (options) => {
363
+ (await lazy.deploy())('status', options);
364
+ }))
278
365
  .addCommand(new Command('flush')
279
366
  .description('Flush all pending deploys (batch and execute)')
280
367
  .option('-v, --verbose', 'Show detailed results')
281
368
  .option('--dry-run', 'Show what would be executed without running')
282
- .action((options) => deployCommand('flush', options)))
369
+ .action(async (options) => {
370
+ (await lazy.deploy())('flush', options);
371
+ }))
283
372
  .addCommand(new Command('config')
284
373
  .description('Show deploy batch configuration (window settings)')
285
- .action((options) => deployCommand('config', options)))
374
+ .action(async (options) => {
375
+ (await lazy.deploy())('config', options);
376
+ }))
286
377
  .addCommand(new Command('set-config')
287
378
  .description('Set deploy batch configuration (window settings)')
288
379
  .option('--message <json>', 'JSON object with window settings, e.g. {"commit":60000,"push":3000}')
289
- .action((options) => deployCommand('set-config', options)))
380
+ .action(async (options) => {
381
+ (await lazy.deploy())('set-config', options);
382
+ }))
290
383
  .addCommand(new Command('urgent')
291
384
  .description('Enable or disable urgent mode (fast batch windows)')
292
385
  .option('--on', 'Enable urgent mode')
293
386
  .option('--off', 'Disable urgent mode (default)')
294
- .action((options) => deployCommand('urgent', { force: options.on, remote: options.off })));
387
+ .action(async (options) => {
388
+ (await lazy.deploy())('urgent', { force: options.on, remote: options.off });
389
+ }));
295
390
  // Task Management
296
391
  program
297
392
  .command('task')
@@ -306,7 +401,9 @@ program
306
401
  .option('--parent <parent>', 'Parent task ID (for hierarchy)')
307
402
  .option('-n, --notes <notes>', 'Markdown notes')
308
403
  .option('--json', 'Output as JSON')
309
- .action((options) => taskCommand('create', options)))
404
+ .action(async (options) => {
405
+ (await lazy.task())('create', options);
406
+ }))
310
407
  .addCommand(new Command('list')
311
408
  .description('List tasks')
312
409
  .option('-s, --filter-status <status>', 'Filter by status (comma-separated)')
@@ -319,13 +416,17 @@ program
319
416
  .option('--show-ready', 'Show only ready tasks')
320
417
  .option('-v, --verbose', 'Show more details')
321
418
  .option('--json', 'Output as JSON')
322
- .action((options) => taskCommand('list', options)))
419
+ .action(async (options) => {
420
+ (await lazy.task())('list', options);
421
+ }))
323
422
  .addCommand(new Command('show')
324
423
  .description('Show task details')
325
424
  .argument('<id>', 'Task ID')
326
425
  .option('-v, --verbose', 'Show history')
327
426
  .option('--json', 'Output as JSON')
328
- .action((id, options) => taskCommand('show', { id, ...options })))
427
+ .action(async (id, options) => {
428
+ (await lazy.task())('show', { id, ...options });
429
+ }))
329
430
  .addCommand(new Command('update')
330
431
  .description('Update a task')
331
432
  .argument('<id>', 'Task ID')
@@ -338,56 +439,80 @@ program
338
439
  .option('-w, --worktree <worktree>', 'Set worktree branch')
339
440
  .option('-l, --labels <labels>', 'New labels (comma-separated)')
340
441
  .option('-n, --notes <notes>', 'New notes')
341
- .action((id, options) => taskCommand('update', { id, ...options })))
442
+ .action(async (id, options) => {
443
+ (await lazy.task())('update', { id, ...options });
444
+ }))
342
445
  .addCommand(new Command('close')
343
446
  .description('Close a task (mark as done)')
344
447
  .argument('<id>', 'Task ID')
345
448
  .option('-r, --reason <reason>', 'Closure reason')
346
- .action((id, options) => taskCommand('close', { id, ...options })))
449
+ .action(async (id, options) => {
450
+ (await lazy.task())('close', { id, ...options });
451
+ }))
347
452
  .addCommand(new Command('delete')
348
453
  .description('Delete a task')
349
454
  .argument('<id>', 'Task ID')
350
- .action((id) => taskCommand('delete', { id })))
455
+ .action(async (id) => {
456
+ (await lazy.task())('delete', { id });
457
+ }))
351
458
  .addCommand(new Command('ready')
352
459
  .description('List tasks ready to work on (no blockers)')
353
460
  .option('--json', 'Output as JSON')
354
- .action((options) => taskCommand('ready', options)))
461
+ .action(async (options) => {
462
+ (await lazy.task())('ready', options);
463
+ }))
355
464
  .addCommand(new Command('blocked')
356
465
  .description('List blocked tasks')
357
466
  .option('--json', 'Output as JSON')
358
- .action((options) => taskCommand('blocked', options)))
467
+ .action(async (options) => {
468
+ (await lazy.task())('blocked', options);
469
+ }))
359
470
  .addCommand(new Command('dep')
360
471
  .description('Add a dependency between tasks')
361
472
  .option('-f, --from <from>', 'Dependent task (the task that is blocked)')
362
473
  .option('-t, --to <to>', 'Blocking task (the task that must complete first)')
363
474
  .option('--dep-type <type>', 'Dependency type: blocks, related, discovered_from', 'blocks')
364
- .action((options) => taskCommand('dep', options)))
475
+ .action(async (options) => {
476
+ (await lazy.task())('dep', options);
477
+ }))
365
478
  .addCommand(new Command('undep')
366
479
  .description('Remove a dependency between tasks')
367
480
  .option('-f, --from <from>', 'Dependent task')
368
481
  .option('-t, --to <to>', 'Blocking task')
369
- .action((options) => taskCommand('undep', options)))
482
+ .action(async (options) => {
483
+ (await lazy.task())('undep', options);
484
+ }))
370
485
  .addCommand(new Command('claim')
371
486
  .description('Claim a task (assign + announce work + create worktree)')
372
487
  .argument('<id>', 'Task ID')
373
488
  .option('-b, --branch <branch>', 'Worktree branch name')
374
- .action((id, options) => taskCommand('claim', { id, ...options })))
489
+ .action(async (id, options) => {
490
+ (await lazy.task())('claim', { id, ...options });
491
+ }))
375
492
  .addCommand(new Command('release')
376
493
  .description('Release a task (mark complete + announce)')
377
494
  .argument('<id>', 'Task ID')
378
495
  .option('-r, --reason <reason>', 'Completion reason')
379
- .action((id, options) => taskCommand('release', { id, ...options })))
496
+ .action(async (id, options) => {
497
+ (await lazy.task())('release', { id, ...options });
498
+ }))
380
499
  .addCommand(new Command('stats')
381
500
  .description('Show task statistics')
382
501
  .option('--json', 'Output as JSON')
383
- .action((options) => taskCommand('stats', options)))
502
+ .action(async (options) => {
503
+ (await lazy.task())('stats', options);
504
+ }))
384
505
  .addCommand(new Command('sync')
385
506
  .description('Sync tasks with JSONL file (for git versioning)')
386
- .action((options) => taskCommand('sync', options)))
507
+ .action(async (options) => {
508
+ (await lazy.task())('sync', options);
509
+ }))
387
510
  .addCommand(new Command('compact')
388
511
  .description('Compact old closed tasks into summaries')
389
512
  .option('--days <days>', 'Compact tasks older than N days', '90')
390
- .action((options) => taskCommand('compact', options)));
513
+ .action(async (options) => {
514
+ (await lazy.task())('compact', options);
515
+ }));
391
516
  // Compliance - protocol verification and auto-fix
392
517
  program
393
518
  .command('compliance')
@@ -395,15 +520,21 @@ program
395
520
  .addCommand(new Command('check')
396
521
  .description('Run compliance check (schema, memory, Qdrant, worktrees, secrets)')
397
522
  .option('-v, --verbose', 'Show detailed information')
398
- .action((options) => complianceCommand('check', options)))
523
+ .action(async (options) => {
524
+ (await lazy.compliance())('check', options);
525
+ }))
399
526
  .addCommand(new Command('audit')
400
527
  .description('Deep compliance audit with verbose output')
401
528
  .option('-v, --verbose', 'Show detailed information')
402
- .action((options) => complianceCommand('audit', options)))
529
+ .action(async (options) => {
530
+ (await lazy.compliance())('audit', options);
531
+ }))
403
532
  .addCommand(new Command('fix')
404
533
  .description('Auto-fix compliance issues (schema migrations, Qdrant collections, worktree cleanup)')
405
534
  .option('-v, --verbose', 'Show detailed information')
406
- .action((options) => complianceCommand('fix', options)));
535
+ .action(async (options) => {
536
+ (await lazy.compliance())('fix', options);
537
+ }));
407
538
  program
408
539
  .command('update')
409
540
  .description('Update CLAUDE.md, memory system, and all related components')
@@ -425,35 +556,50 @@ program
425
556
  .description('Full system overview with charts and progress bars')
426
557
  .option('-v, --verbose', 'Show detailed information')
427
558
  .option('--compact', 'Compact output for narrow terminals')
428
- .action((options) => dashboardCommand('overview', options)))
559
+ .action(async (options) => {
560
+ (await lazy.dashboard())('overview', options);
561
+ }))
429
562
  .addCommand(new Command('tasks')
430
563
  .description('Task breakdown with charts, progress bars, and hierarchy trees')
431
564
  .option('-v, --verbose', 'Show detailed information')
432
565
  .option('--compact', 'Compact output')
433
- .action((options) => dashboardCommand('tasks', options)))
566
+ .action(async (options) => {
567
+ (await lazy.dashboard())('tasks', options);
568
+ }))
434
569
  .addCommand(new Command('agents')
435
570
  .description('Agent activity, resource claims, and coordination status')
436
571
  .option('-v, --verbose', 'Show detailed information')
437
- .action((options) => dashboardCommand('agents', options)))
572
+ .action(async (options) => {
573
+ (await lazy.dashboard())('agents', options);
574
+ }))
438
575
  .addCommand(new Command('memory')
439
576
  .description('Memory system health, capacity, and layer architecture')
440
577
  .option('-v, --verbose', 'Show detailed information')
441
- .action((options) => dashboardCommand('memory', options)))
578
+ .action(async (options) => {
579
+ (await lazy.dashboard())('memory', options);
580
+ }))
442
581
  .addCommand(new Command('progress')
443
582
  .description('Completion tracking with per-priority and per-type progress')
444
583
  .option('-v, --verbose', 'Show detailed information')
445
- .action((options) => dashboardCommand('progress', options)))
584
+ .action(async (options) => {
585
+ (await lazy.dashboard())('progress', options);
586
+ }))
446
587
  .addCommand(new Command('stats')
447
588
  .description('Session context consumption stats with per-tool breakdown')
448
589
  .option('-v, --verbose', 'Show detailed information')
449
- .action((options) => dashboardCommand('stats', options)))
590
+ .action(async (options) => {
591
+ (await lazy.dashboard())('stats', options);
592
+ }))
450
593
  .addCommand(new Command('session')
451
594
  .description('Live UAP session state: infrastructure, patterns, skills, git, policies')
452
595
  .option('-v, --verbose', 'Show detailed information')
453
596
  .option('--compact', 'Compact summary box (for post-task / pre-compact)')
454
- .action((options) => dashboardCommand('session', options)));
455
- // Multi-Model Architecture commands
456
- registerModelCommands(program);
597
+ .action(async (options) => {
598
+ (await lazy.dashboard())('session', options);
599
+ }));
600
+ // Multi-Model Architecture commands - registered lazily via top-level await
601
+ const registerModelFn = await lazy.model();
602
+ registerModelFn(program);
457
603
  // MCP Router - Lightweight hierarchical router for 98%+ token reduction
458
604
  program
459
605
  .command('mcp-router')
@@ -462,13 +608,17 @@ program
462
608
  .description('Start the MCP router as a stdio server')
463
609
  .option('-c, --config <path>', 'Path to mcp.json config file')
464
610
  .option('-v, --verbose', 'Enable verbose logging')
465
- .action((options) => mcpRouterCommand('start', options)))
611
+ .action(async (options) => {
612
+ (await lazy.mcpRouter())('start', options);
613
+ }))
466
614
  .addCommand(new Command('stats')
467
615
  .description('Show router statistics (servers, tools, token savings)')
468
616
  .option('-c, --config <path>', 'Path to mcp.json config file')
469
617
  .option('-v, --verbose', 'Enable verbose logging')
470
618
  .option('--json', 'Output as JSON')
471
- .action((options) => mcpRouterCommand('stats', options)))
619
+ .action(async (options) => {
620
+ (await lazy.mcpRouter())('stats', options);
621
+ }))
472
622
  .addCommand(new Command('discover')
473
623
  .description('Discover tools matching a query')
474
624
  .option('-q, --query <query>', 'Search query (required)')
@@ -477,12 +627,16 @@ program
477
627
  .option('-c, --config <path>', 'Path to mcp.json config file')
478
628
  .option('-v, --verbose', 'Enable verbose logging')
479
629
  .option('--json', 'Output as JSON')
480
- .action((options) => mcpRouterCommand('discover', options)))
630
+ .action(async (options) => {
631
+ (await lazy.mcpRouter())('discover', options);
632
+ }))
481
633
  .addCommand(new Command('list')
482
634
  .description('List configured MCP servers')
483
635
  .option('-c, --config <path>', 'Path to mcp.json config file')
484
636
  .option('--json', 'Output as JSON')
485
- .action((options) => mcpRouterCommand('list', options)));
637
+ .action(async (options) => {
638
+ (await lazy.mcpRouter())('list', options);
639
+ }));
486
640
  // Session Hooks - automatic memory injection and pre-compaction flush
487
641
  program
488
642
  .command('hooks')
@@ -490,27 +644,33 @@ program
490
644
  .addCommand(new Command('install')
491
645
  .description('Install UAP session hooks')
492
646
  .option('-t, --target <target>', 'Target platform: claude, factory, cursor, vscode, opencode, omp (default: all)')
493
- .action((options) => hooksCommand('install', { target: options.target })))
647
+ .action((options) => lazy
648
+ .hooks()
649
+ .then((m) => m.hooksCommand('install', { target: options.target }))))
494
650
  .addCommand(new Command('status')
495
651
  .description('Show hooks installation status')
496
652
  .option('-t, --target <target>', 'Target platform: claude, factory, cursor, vscode, opencode, omp (default: all)')
497
- .action((options) => hooksCommand('status', { target: options.target })));
653
+ .action((options) => lazy
654
+ .hooks()
655
+ .then((m) => m.hooksCommand('status', { target: options.target }))));
498
656
  // Qwen3.5 Tool Call Fixes - performance optimizations for tool calling
499
657
  const toolCallsCmd = new Command('tool-calls');
500
658
  toolCallsCmd.description('Manage Qwen3.5 tool call fixes and chat templates');
501
- toolCallsCmd.addCommand(new Command('setup')
502
- .description('Install chat templates and Python scripts')
503
- .action(() => toolCallsCommand('setup')));
659
+ toolCallsCmd.addCommand(new Command('setup').description('Install chat templates and Python scripts').action(async () => {
660
+ (await lazy.toolCalls())('setup');
661
+ }));
504
662
  toolCallsCmd.addCommand(new Command('test')
505
663
  .description('Run reliability test suite')
506
664
  .addOption(new Option('--verbose', 'Verbose output'))
507
- .action(() => toolCallsCommand('test')));
508
- toolCallsCmd.addCommand(new Command('status')
509
- .description('Check current configuration')
510
- .action(() => toolCallsCommand('status')));
511
- toolCallsCmd.addCommand(new Command('fix')
512
- .description('Apply template fixes to existing templates')
513
- .action(() => toolCallsCommand('fix')));
665
+ .action(async () => {
666
+ (await lazy.toolCalls())('test');
667
+ }));
668
+ toolCallsCmd.addCommand(new Command('status').description('Check current configuration').action(async () => {
669
+ (await lazy.toolCalls())('status');
670
+ }));
671
+ toolCallsCmd.addCommand(new Command('fix').description('Apply template fixes to existing templates').action(async () => {
672
+ (await lazy.toolCalls())('fix');
673
+ }));
514
674
  program.addCommand(toolCallsCmd);
515
675
  // RTK (Rust Token Killer) - CLI proxy for 60-90% token savings
516
676
  const rtkCmd = new Command('rtk');
@@ -520,16 +680,19 @@ rtkCmd.addCommand(new Command('install')
520
680
  .option('--force', 'Force reinstall')
521
681
  .option('--method <method>', 'Installation method (npm, cargo, binary)')
522
682
  .action(async (options) => {
523
- await installRTK({
683
+ const rtk = await lazy.rtk();
684
+ await rtk.installRTK({
524
685
  force: !!options.force,
525
686
  method: options.method,
526
687
  });
527
688
  }));
528
689
  rtkCmd.addCommand(new Command('status').description('Check RTK installation and token savings').action(async () => {
529
- await checkRTKStatus();
690
+ const rtk = await lazy.rtk();
691
+ await rtk.checkRTKStatus();
530
692
  }));
531
- rtkCmd.addCommand(new Command('help').description('Show RTK usage information').action(() => {
532
- showRTKHelp();
693
+ rtkCmd.addCommand(new Command('help').description('Show RTK usage information').action(async () => {
694
+ const rtk = await lazy.rtk();
695
+ rtk.showRTKHelp();
533
696
  }));
534
697
  program.addCommand(rtkCmd);
535
698
  // MCP Setup - Configure MCP Router for all platforms
@@ -539,10 +702,12 @@ program
539
702
  .option('--force', 'Force replace existing MCP configurations')
540
703
  .option('--verbose', 'Enable verbose output')
541
704
  .action(async (options) => {
542
- await setupMcpRouter({ force: !!options.force, verbose: !!options.verbose });
705
+ const fn = await lazy.setupMcpRouter();
706
+ await fn({ force: !!options.force, verbose: !!options.verbose });
543
707
  });
544
- // Register schema-diff command
545
- registerSchemaDiffCommand(program);
708
+ // Register schema-diff command lazily
709
+ const registerSchemaDiffFn = await lazy.schemaDiff();
710
+ registerSchemaDiffFn(program);
546
711
  // UAP for Oh-My-Pi - dashboard and controls for omp users
547
712
  const uapOmpCmd = new Command('uap-omp');
548
713
  uapOmpCmd.description('UAP integration commands for oh-my-pi (omp) users');