@claude-flow/cli 3.1.0-alpha.4 → 3.1.0-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/helpers/auto-memory-hook.mjs +350 -0
- package/.claude/helpers/hook-handler.cjs +232 -0
- package/.claude/helpers/intelligence.cjs +916 -0
- package/.claude/helpers/session.js +8 -0
- package/.claude/helpers/statusline.cjs +96 -28
- package/.claude/settings.json +86 -141
- package/README.md +830 -353
- package/bin/cli.js +6 -2
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +224 -32
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +191 -4
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +12 -2
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/init/executor.d.ts +8 -2
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +310 -41
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts +18 -0
- package/dist/src/init/helpers-generator.d.ts.map +1 -1
- package/dist/src/init/helpers-generator.js +498 -0
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +134 -91
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.d.ts.map +1 -1
- package/dist/src/init/statusline-generator.js +104 -34
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +12 -0
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +12 -0
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +4 -1
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +1 -0
- package/dist/src/memory/memory-initializer.d.ts.map +1 -1
- package/dist/src/memory/memory-initializer.js +14 -9
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -2
package/bin/cli.js
CHANGED
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
import { randomUUID } from 'crypto';
|
|
12
12
|
|
|
13
13
|
// Check if we should run in MCP server mode
|
|
14
|
-
// Conditions:
|
|
15
|
-
|
|
14
|
+
// Conditions:
|
|
15
|
+
// 1. stdin is being piped AND no CLI arguments provided (auto-detect)
|
|
16
|
+
// 2. stdin is being piped AND args are "mcp start" (explicit, e.g. npx claude-flow@alpha mcp start)
|
|
17
|
+
const cliArgs = process.argv.slice(2);
|
|
18
|
+
const isExplicitMCP = cliArgs.length >= 1 && cliArgs[0] === 'mcp' && (cliArgs.length === 1 || cliArgs[1] === 'start');
|
|
19
|
+
const isMCPMode = !process.stdin.isTTY && (process.argv.length === 2 || isExplicitMCP);
|
|
16
20
|
|
|
17
21
|
if (isMCPMode) {
|
|
18
22
|
// Run MCP server mode
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,aAAa,CAAC;AAizI1E,eAAO,MAAM,YAAY,EAAE,OAyG1B,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -32,7 +32,7 @@ const preEditCommand = {
|
|
|
32
32
|
short: 'f',
|
|
33
33
|
description: 'File path to edit',
|
|
34
34
|
type: 'string',
|
|
35
|
-
required:
|
|
35
|
+
required: false
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
name: 'operation',
|
|
@@ -53,12 +53,9 @@ const preEditCommand = {
|
|
|
53
53
|
{ command: 'claude-flow hooks pre-edit -f src/api.ts -o refactor', description: 'Pre-edit with operation type' }
|
|
54
54
|
],
|
|
55
55
|
action: async (ctx) => {
|
|
56
|
-
|
|
56
|
+
// Default file to 'unknown' for backward compatibility (env var may be empty)
|
|
57
|
+
const filePath = ctx.args[0] || ctx.flags.file || 'unknown';
|
|
57
58
|
const operation = ctx.flags.operation || 'update';
|
|
58
|
-
if (!filePath) {
|
|
59
|
-
output.printError('File path is required. Use --file or -f flag.');
|
|
60
|
-
return { success: false, exitCode: 1 };
|
|
61
|
-
}
|
|
62
59
|
output.printInfo(`Analyzing context for: ${output.highlight(filePath)}`);
|
|
63
60
|
try {
|
|
64
61
|
// Call MCP tool for pre-edit hook
|
|
@@ -134,14 +131,14 @@ const postEditCommand = {
|
|
|
134
131
|
short: 'f',
|
|
135
132
|
description: 'File path that was edited',
|
|
136
133
|
type: 'string',
|
|
137
|
-
required:
|
|
134
|
+
required: false
|
|
138
135
|
},
|
|
139
136
|
{
|
|
140
137
|
name: 'success',
|
|
141
138
|
short: 's',
|
|
142
139
|
description: 'Whether the edit was successful',
|
|
143
140
|
type: 'boolean',
|
|
144
|
-
required:
|
|
141
|
+
required: false
|
|
145
142
|
},
|
|
146
143
|
{
|
|
147
144
|
name: 'outcome',
|
|
@@ -161,16 +158,10 @@ const postEditCommand = {
|
|
|
161
158
|
{ command: 'claude-flow hooks post-edit -f src/api.ts --success false -o "Type error"', description: 'Record failed edit' }
|
|
162
159
|
],
|
|
163
160
|
action: async (ctx) => {
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return { success: false, exitCode: 1 };
|
|
169
|
-
}
|
|
170
|
-
if (success === undefined) {
|
|
171
|
-
output.printError('Success flag is required. Use --success true/false.');
|
|
172
|
-
return { success: false, exitCode: 1 };
|
|
173
|
-
}
|
|
161
|
+
// Default file to 'unknown' for backward compatibility (env var may be empty)
|
|
162
|
+
const filePath = ctx.args[0] || ctx.flags.file || 'unknown';
|
|
163
|
+
// Default success to true for backward compatibility (PostToolUse = success, PostToolUseFailure = failure)
|
|
164
|
+
const success = ctx.flags.success !== undefined ? ctx.flags.success : true;
|
|
174
165
|
output.printInfo(`Recording outcome for: ${output.highlight(filePath)}`);
|
|
175
166
|
try {
|
|
176
167
|
// Parse metrics if provided
|
|
@@ -339,7 +330,7 @@ const postCommandCommand = {
|
|
|
339
330
|
short: 's',
|
|
340
331
|
description: 'Whether the command succeeded',
|
|
341
332
|
type: 'boolean',
|
|
342
|
-
required:
|
|
333
|
+
required: false
|
|
343
334
|
},
|
|
344
335
|
{
|
|
345
336
|
name: 'exit-code',
|
|
@@ -361,15 +352,12 @@ const postCommandCommand = {
|
|
|
361
352
|
],
|
|
362
353
|
action: async (ctx) => {
|
|
363
354
|
const command = ctx.args[0] || ctx.flags.command;
|
|
364
|
-
|
|
355
|
+
// Default success to true for backward compatibility
|
|
356
|
+
const success = ctx.flags.success !== undefined ? ctx.flags.success : true;
|
|
365
357
|
if (!command) {
|
|
366
358
|
output.printError('Command is required. Use --command or -c flag.');
|
|
367
359
|
return { success: false, exitCode: 1 };
|
|
368
360
|
}
|
|
369
|
-
if (success === undefined) {
|
|
370
|
-
output.printError('Success flag is required. Use --success true/false.');
|
|
371
|
-
return { success: false, exitCode: 1 };
|
|
372
|
-
}
|
|
373
361
|
output.printInfo(`Recording command outcome: ${output.highlight(command)}`);
|
|
374
362
|
try {
|
|
375
363
|
// Call MCP tool for post-command hook
|
|
@@ -1305,7 +1293,7 @@ const postTaskCommand = {
|
|
|
1305
1293
|
short: 's',
|
|
1306
1294
|
description: 'Whether the task succeeded',
|
|
1307
1295
|
type: 'boolean',
|
|
1308
|
-
required:
|
|
1296
|
+
required: false
|
|
1309
1297
|
},
|
|
1310
1298
|
{
|
|
1311
1299
|
name: 'quality',
|
|
@@ -1327,11 +1315,8 @@ const postTaskCommand = {
|
|
|
1327
1315
|
action: async (ctx) => {
|
|
1328
1316
|
// Auto-generate task ID if not provided
|
|
1329
1317
|
const taskId = ctx.flags.taskId || `task_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
output.printError('Success flag is required. Use --success true/false.');
|
|
1333
|
-
return { success: false, exitCode: 1 };
|
|
1334
|
-
}
|
|
1318
|
+
// Default success to true for backward compatibility
|
|
1319
|
+
const success = ctx.flags.success !== undefined ? ctx.flags.success : true;
|
|
1335
1320
|
output.printInfo(`Recording outcome for task: ${output.highlight(taskId)}`);
|
|
1336
1321
|
try {
|
|
1337
1322
|
const result = await callMCPTool('hooks_post-task', {
|
|
@@ -3447,6 +3432,205 @@ const modelStatsCommand = {
|
|
|
3447
3432
|
}
|
|
3448
3433
|
}
|
|
3449
3434
|
};
|
|
3435
|
+
// Teammate Idle command - Agent Teams integration
|
|
3436
|
+
const teammateIdleCommand = {
|
|
3437
|
+
name: 'teammate-idle',
|
|
3438
|
+
description: 'Handle idle teammate in Agent Teams - auto-assign tasks or notify lead',
|
|
3439
|
+
options: [
|
|
3440
|
+
{
|
|
3441
|
+
name: 'auto-assign',
|
|
3442
|
+
short: 'a',
|
|
3443
|
+
description: 'Automatically assign pending tasks to idle teammate',
|
|
3444
|
+
type: 'boolean',
|
|
3445
|
+
default: true
|
|
3446
|
+
},
|
|
3447
|
+
{
|
|
3448
|
+
name: 'check-task-list',
|
|
3449
|
+
short: 'c',
|
|
3450
|
+
description: 'Check shared task list for available work',
|
|
3451
|
+
type: 'boolean',
|
|
3452
|
+
default: true
|
|
3453
|
+
},
|
|
3454
|
+
{
|
|
3455
|
+
name: 'teammate-id',
|
|
3456
|
+
short: 't',
|
|
3457
|
+
description: 'ID of the idle teammate',
|
|
3458
|
+
type: 'string'
|
|
3459
|
+
},
|
|
3460
|
+
{
|
|
3461
|
+
name: 'team-name',
|
|
3462
|
+
description: 'Team name for context',
|
|
3463
|
+
type: 'string'
|
|
3464
|
+
}
|
|
3465
|
+
],
|
|
3466
|
+
examples: [
|
|
3467
|
+
{ command: 'claude-flow hooks teammate-idle --auto-assign true', description: 'Auto-assign tasks to idle teammate' },
|
|
3468
|
+
{ command: 'claude-flow hooks teammate-idle -t worker-1 --check-task-list', description: 'Check tasks for specific teammate' }
|
|
3469
|
+
],
|
|
3470
|
+
action: async (ctx) => {
|
|
3471
|
+
const autoAssign = ctx.flags.autoAssign !== false;
|
|
3472
|
+
const checkTaskList = ctx.flags.checkTaskList !== false;
|
|
3473
|
+
const teammateId = ctx.flags.teammateId;
|
|
3474
|
+
const teamName = ctx.flags.teamName;
|
|
3475
|
+
if (ctx.flags.format !== 'json') {
|
|
3476
|
+
output.printInfo(`Teammate idle hook triggered${teammateId ? ` for: ${output.highlight(teammateId)}` : ''}`);
|
|
3477
|
+
}
|
|
3478
|
+
try {
|
|
3479
|
+
const result = await callMCPTool('hooks_teammate-idle', {
|
|
3480
|
+
autoAssign,
|
|
3481
|
+
checkTaskList,
|
|
3482
|
+
teammateId,
|
|
3483
|
+
teamName,
|
|
3484
|
+
timestamp: Date.now(),
|
|
3485
|
+
});
|
|
3486
|
+
if (ctx.flags.format === 'json') {
|
|
3487
|
+
output.printJson(result);
|
|
3488
|
+
return { success: true, data: result };
|
|
3489
|
+
}
|
|
3490
|
+
output.writeln();
|
|
3491
|
+
if (result.action === 'assigned' && result.taskAssigned) {
|
|
3492
|
+
output.printSuccess(`Task assigned: ${result.taskAssigned.subject}`);
|
|
3493
|
+
output.printList([
|
|
3494
|
+
`Task ID: ${result.taskAssigned.taskId}`,
|
|
3495
|
+
`Priority: ${result.taskAssigned.priority}`,
|
|
3496
|
+
`Pending tasks remaining: ${result.pendingTasks}`
|
|
3497
|
+
]);
|
|
3498
|
+
}
|
|
3499
|
+
else if (result.action === 'waiting') {
|
|
3500
|
+
output.printInfo('No pending tasks available - teammate waiting for work');
|
|
3501
|
+
}
|
|
3502
|
+
else {
|
|
3503
|
+
output.printInfo(`Team lead notified: ${result.message}`);
|
|
3504
|
+
}
|
|
3505
|
+
return { success: true, data: result };
|
|
3506
|
+
}
|
|
3507
|
+
catch (error) {
|
|
3508
|
+
// Graceful fallback - don't fail hard, just report
|
|
3509
|
+
if (ctx.flags.format === 'json') {
|
|
3510
|
+
output.printJson({ success: true, action: 'waiting', message: 'Teammate idle - no MCP server' });
|
|
3511
|
+
}
|
|
3512
|
+
else {
|
|
3513
|
+
output.printInfo('Teammate idle - awaiting task assignment');
|
|
3514
|
+
}
|
|
3515
|
+
return { success: true };
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
};
|
|
3519
|
+
// Task Completed command - Agent Teams integration
|
|
3520
|
+
const taskCompletedCommand = {
|
|
3521
|
+
name: 'task-completed',
|
|
3522
|
+
description: 'Handle task completion in Agent Teams - train patterns and notify lead',
|
|
3523
|
+
options: [
|
|
3524
|
+
{
|
|
3525
|
+
name: 'task-id',
|
|
3526
|
+
short: 'i',
|
|
3527
|
+
description: 'ID of the completed task',
|
|
3528
|
+
type: 'string',
|
|
3529
|
+
required: true
|
|
3530
|
+
},
|
|
3531
|
+
{
|
|
3532
|
+
name: 'train-patterns',
|
|
3533
|
+
short: 'p',
|
|
3534
|
+
description: 'Train neural patterns from successful task',
|
|
3535
|
+
type: 'boolean',
|
|
3536
|
+
default: true
|
|
3537
|
+
},
|
|
3538
|
+
{
|
|
3539
|
+
name: 'notify-lead',
|
|
3540
|
+
short: 'n',
|
|
3541
|
+
description: 'Notify team lead of task completion',
|
|
3542
|
+
type: 'boolean',
|
|
3543
|
+
default: true
|
|
3544
|
+
},
|
|
3545
|
+
{
|
|
3546
|
+
name: 'success',
|
|
3547
|
+
short: 's',
|
|
3548
|
+
description: 'Whether the task succeeded',
|
|
3549
|
+
type: 'boolean',
|
|
3550
|
+
default: true
|
|
3551
|
+
},
|
|
3552
|
+
{
|
|
3553
|
+
name: 'quality',
|
|
3554
|
+
short: 'q',
|
|
3555
|
+
description: 'Quality score (0-1)',
|
|
3556
|
+
type: 'number'
|
|
3557
|
+
},
|
|
3558
|
+
{
|
|
3559
|
+
name: 'teammate-id',
|
|
3560
|
+
short: 't',
|
|
3561
|
+
description: 'ID of the teammate that completed the task',
|
|
3562
|
+
type: 'string'
|
|
3563
|
+
}
|
|
3564
|
+
],
|
|
3565
|
+
examples: [
|
|
3566
|
+
{ command: 'claude-flow hooks task-completed -i task-123 --train-patterns', description: 'Complete task and train patterns' },
|
|
3567
|
+
{ command: 'claude-flow hooks task-completed -i task-456 --notify-lead --quality 0.95', description: 'Complete with quality score' }
|
|
3568
|
+
],
|
|
3569
|
+
action: async (ctx) => {
|
|
3570
|
+
const taskId = ctx.args[0] || ctx.flags.taskId;
|
|
3571
|
+
const trainPatterns = ctx.flags.trainPatterns !== false;
|
|
3572
|
+
const notifyLead = ctx.flags.notifyLead !== false;
|
|
3573
|
+
const success = ctx.flags.success !== false;
|
|
3574
|
+
const quality = ctx.flags.quality;
|
|
3575
|
+
const teammateId = ctx.flags.teammateId;
|
|
3576
|
+
if (!taskId) {
|
|
3577
|
+
output.printError('Task ID is required. Use --task-id or -i flag.');
|
|
3578
|
+
return { success: false, exitCode: 1 };
|
|
3579
|
+
}
|
|
3580
|
+
if (ctx.flags.format !== 'json') {
|
|
3581
|
+
output.printInfo(`Task completed: ${output.highlight(taskId)}`);
|
|
3582
|
+
}
|
|
3583
|
+
try {
|
|
3584
|
+
const result = await callMCPTool('hooks_task-completed', {
|
|
3585
|
+
taskId,
|
|
3586
|
+
trainPatterns,
|
|
3587
|
+
notifyLead,
|
|
3588
|
+
success,
|
|
3589
|
+
quality,
|
|
3590
|
+
teammateId,
|
|
3591
|
+
timestamp: Date.now(),
|
|
3592
|
+
});
|
|
3593
|
+
if (ctx.flags.format === 'json') {
|
|
3594
|
+
output.printJson(result);
|
|
3595
|
+
return { success: true, data: result };
|
|
3596
|
+
}
|
|
3597
|
+
output.writeln();
|
|
3598
|
+
output.printSuccess(`Task ${taskId} marked complete`);
|
|
3599
|
+
output.writeln();
|
|
3600
|
+
output.writeln(output.bold('Completion Metrics'));
|
|
3601
|
+
output.printTable({
|
|
3602
|
+
columns: [
|
|
3603
|
+
{ key: 'metric', header: 'Metric', width: 25 },
|
|
3604
|
+
{ key: 'value', header: 'Value', width: 20, align: 'right' }
|
|
3605
|
+
],
|
|
3606
|
+
data: [
|
|
3607
|
+
{ metric: 'Patterns Learned', value: result.patternsLearned },
|
|
3608
|
+
{ metric: 'Quality Score', value: quality ? `${(quality * 100).toFixed(0)}%` : 'N/A' },
|
|
3609
|
+
{ metric: 'Lead Notified', value: result.leadNotified ? 'Yes' : 'No' },
|
|
3610
|
+
{ metric: 'Learning Updates', value: result.metrics?.learningUpdates || 0 }
|
|
3611
|
+
]
|
|
3612
|
+
});
|
|
3613
|
+
if (result.nextTask) {
|
|
3614
|
+
output.writeln();
|
|
3615
|
+
output.printInfo(`Next available task: ${result.nextTask.subject}`);
|
|
3616
|
+
}
|
|
3617
|
+
return { success: true, data: result };
|
|
3618
|
+
}
|
|
3619
|
+
catch (error) {
|
|
3620
|
+
// Graceful fallback
|
|
3621
|
+
if (ctx.flags.format === 'json') {
|
|
3622
|
+
output.printJson({ success: true, taskId, message: 'Task completed - patterns pending' });
|
|
3623
|
+
}
|
|
3624
|
+
else {
|
|
3625
|
+
output.printSuccess(`Task ${taskId} completed`);
|
|
3626
|
+
if (trainPatterns) {
|
|
3627
|
+
output.printInfo('Pattern training queued for next sync');
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
return { success: true };
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
};
|
|
3450
3634
|
// Main hooks command
|
|
3451
3635
|
export const hooksCommand = {
|
|
3452
3636
|
name: 'hooks',
|
|
@@ -3486,6 +3670,9 @@ export const hooksCommand = {
|
|
|
3486
3670
|
sessionStartCommand,
|
|
3487
3671
|
preBashCommand,
|
|
3488
3672
|
postBashCommand,
|
|
3673
|
+
// Agent Teams integration
|
|
3674
|
+
teammateIdleCommand,
|
|
3675
|
+
taskCompletedCommand,
|
|
3489
3676
|
],
|
|
3490
3677
|
options: [],
|
|
3491
3678
|
examples: [
|
|
@@ -3528,7 +3715,11 @@ export const hooksCommand = {
|
|
|
3528
3715
|
`${output.highlight('token-optimize')} - Token optimization (30-50% savings)`,
|
|
3529
3716
|
`${output.highlight('model-route')} - Route to optimal model (haiku/sonnet/opus)`,
|
|
3530
3717
|
`${output.highlight('model-outcome')} - Record model routing outcome`,
|
|
3531
|
-
`${output.highlight('model-stats')} - View model routing statistics
|
|
3718
|
+
`${output.highlight('model-stats')} - View model routing statistics`,
|
|
3719
|
+
'',
|
|
3720
|
+
output.bold('Agent Teams:'),
|
|
3721
|
+
`${output.highlight('teammate-idle')} - Handle idle teammate (auto-assign tasks)`,
|
|
3722
|
+
`${output.highlight('task-completed')} - Handle task completion (train patterns)`
|
|
3532
3723
|
]);
|
|
3533
3724
|
output.writeln();
|
|
3534
3725
|
output.writeln('Run "claude-flow hooks <subcommand> --help" for subcommand help');
|
|
@@ -3540,7 +3731,8 @@ export const hooksCommand = {
|
|
|
3540
3731
|
'🔍 AgentDB integration (150x faster search)',
|
|
3541
3732
|
'📊 84.8% SWE-Bench solve rate',
|
|
3542
3733
|
'🎯 32.3% token reduction',
|
|
3543
|
-
'🚀 2.8-4.4x speed improvement'
|
|
3734
|
+
'🚀 2.8-4.4x speed improvement',
|
|
3735
|
+
'👥 Agent Teams integration (auto task assignment)'
|
|
3544
3736
|
]);
|
|
3545
3737
|
return { success: true };
|
|
3546
3738
|
}
|