claude-flow 2.5.0-alpha.138 → 2.5.0-alpha.141

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.
@@ -41,7 +41,7 @@
41
41
  "hooks": [
42
42
  {
43
43
  "type": "command",
44
- "command": "cat | jq -r '.tool_input.command // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks pre-command --command '{}' --validate-safety true --prepare-resources true"
44
+ "command": "cat | npx claude-flow@alpha hooks modify-bash"
45
45
  }
46
46
  ]
47
47
  },
@@ -50,7 +50,7 @@
50
50
  "hooks": [
51
51
  {
52
52
  "type": "command",
53
- "command": "cat | jq -r '.tool_input.file_path // .tool_input.path // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks pre-edit --file '{}' --auto-assign-agents true --load-context true"
53
+ "command": "cat | npx claude-flow@alpha hooks modify-file"
54
54
  }
55
55
  ]
56
56
  }
@@ -109,6 +109,7 @@
109
109
  "includeCoAuthoredBy": true,
110
110
  "enabledMcpjsonServers": ["claude-flow", "ruv-swarm"],
111
111
  "statusLine": {
112
+ "type": "command",
112
113
  "command": "~/.claude/statusline-command.sh"
113
114
  }
114
115
  }
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # 🌊 Claude-Flow v2.5.0 Alpha 130: AI Orchestration Platform
1
+ # 🌊 Claude-Flow v2.5.0 Alpha 140: AI Orchestration Platform
2
2
 
3
3
  <div align="center">
4
4
 
5
5
  [![🌟 Star on GitHub](https://img.shields.io/github/stars/ruvnet/claude-flow?style=for-the-badge&logo=github&color=gold)](https://github.com/ruvnet/claude-flow)
6
6
  [![📈 Downloads](https://img.shields.io/npm/dt/claude-flow?style=for-the-badge&logo=npm&color=blue&label=Downloads)](https://www.npmjs.com/package/claude-flow)
7
- [![📦 Latest Release](https://img.shields.io/npm/v/claude-flow?style=for-the-badge&logo=npm&color=green&label=v2.5.0-alpha.130)](https://www.npmjs.com/package/claude-flow)
7
+ [![📦 Latest Release](https://img.shields.io/npm/v/claude-flow?style=for-the-badge&logo=npm&color=green&label=v2.5.0-alpha.140)](https://www.npmjs.com/package/claude-flow)
8
8
  [![⚡ Claude Code](https://img.shields.io/badge/Claude%20Code-SDK%20Integrated-green?style=for-the-badge&logo=anthropic)](https://github.com/ruvnet/claude-flow)
9
9
  [![🏛️ Agentics Foundation](https://img.shields.io/badge/Agentics-Foundation-crimson?style=for-the-badge&logo=openai)](https://discord.com/invite/dfxmpwkG2D)
10
10
  [![🐝 Hive-Mind](https://img.shields.io/badge/Hive--Mind-AI%20Coordination-purple?style=for-the-badge&logo=swarm)](https://github.com/ruvnet/claude-flow)
@@ -13,57 +13,6 @@
13
13
 
14
14
  </div>
15
15
 
16
- ---
17
-
18
- ## 🎉 What's New in v2.5.0-alpha.130
19
-
20
- **🚀 Claude Code SDK Integration** - Major performance breakthrough with 100-600x potential speedup!
21
-
22
- ### ✨ New Features
23
-
24
- **Session Forking & Real-Time Control** 🔥
25
- - ⚡ **10-20x faster** parallel agent spawning using Claude Code SDK's session forking
26
- - 🎮 Real-time query control: pause, resume, terminate agents mid-execution
27
- - 🔄 Dynamic model and permission changes during runtime
28
- - 📊 26 new methods for advanced agent orchestration
29
-
30
- **Hook Matchers & 4-Level Permissions** 🎯
31
- - 🎨 **2-3x faster** hook execution with pattern-based selective triggering
32
- - 🔐 Hierarchical permission system: USER → PROJECT → LOCAL → SESSION
33
- - 🔍 Glob and regex pattern matching for file-based hooks
34
- - ⚡ Intelligent caching for near-instant permission resolution
35
-
36
- **In-Process MCP Server** 🚄
37
- - 🏎️ **50-100x faster** tool calls by eliminating IPC overhead
38
- - 📦 Direct in-process execution for all 50+ Claude-Flow tools
39
- - 💾 10MB memory savings per MCP server (no extra processes)
40
- - 🔌 Automatic routing: in-process for local tools, stdio/SSE for external
41
-
42
-
43
-
44
- ### 📊 Performance Impact
45
-
46
- | Feature | Speedup | Impact |
47
- |---------|---------|--------|
48
- | Session Forking | 10-20x | Parallel agent spawning |
49
- | Hook Matchers | 2-3x | Selective hook execution |
50
- | In-Process MCP | 50-100x | Tool call latency |
51
- | **Combined** | **100-600x** | Full workflow orchestration |
52
-
53
- **Real-World Example**: Spawning 10 agents now takes ~750ms instead of ~7,500ms! 🚀
54
-
55
- ### 🔧 SDK Integration Benefits
56
-
57
- - ✅ Native Claude Code SDK features instead of custom implementations
58
- - ✅ Automatic retry handling and error management
59
- - ✅ Optimized streaming and artifact durability
60
- - ✅ Context checkpoints and session management
61
- - ✅ Reduced codebase by 200+ lines of redundant retry logic
62
-
63
- **See Full Details**: [GitHub Issue #780](https://github.com/ruvnet/claude-flow/issues/780)
64
-
65
- ---
66
-
67
16
  ## 🌟 **Overview**
68
17
 
69
18
  **Claude-Flow v2 Alpha** is an enterprise-grade AI orchestration platform that reimagines how developers build with AI. By combining **hive-mind swarm intelligence**, **neural pattern recognition**, and **87 advanced MCP tools**, Claude-Flow enables unprecedented AI-powered development workflows.
@@ -78,9 +27,41 @@
78
27
  - **🪝 Advanced Hooks System**: Automated workflows with pre/post operation hooks
79
28
  - **📊 GitHub Integration**: 6 specialized modes for repository management
80
29
  - **🌐 Flow Nexus Cloud Platform**: E2B sandboxes, AI swarms, challenges, and marketplace integration
30
+ - **🎯 PreToolUse Modification Hooks**: NEW - Claude Code v2.0.10+ intelligent input modification (safety, organization, optimization)
81
31
 
82
32
  > 🔥 **Revolutionary AI Coordination**: Build faster, smarter, and more efficiently with AI-powered development orchestration
83
33
 
34
+ ## 🎯 **NEW: PreToolUse Modification Hooks Plugin** (v2.5.0-alpha.140)
35
+
36
+ **First Claude Code plugin with intelligent tool input modification** - automatically enhances commands and files before execution.
37
+
38
+ **Key Features:**
39
+ - 🛡️ **Safety**: Auto-adds `-i` to `rm` commands, detects sensitive keywords
40
+ - 📁 **Organization**: Auto-routes files (tests→`/tests/`, src→`/src/`)
41
+ - ⚡ **Productivity**: Alias expansion (`ll`→`ls -lah`), conventional commits
42
+
43
+ **Quick Start:**
44
+
45
+ **Option 1: Direct Plugin Installation** (Recommended)
46
+ ```bash
47
+ # In Claude Code, run:
48
+ /plugin ruvnet/claude-flow
49
+ ```
50
+
51
+ **Option 2: Via NPM**
52
+ ```bash
53
+ npx claude-flow@alpha init --force # Auto-configures .claude-plugin/hooks/hooks.json
54
+ ```
55
+
56
+ **Examples:**
57
+ ```bash
58
+ rm test.txt → rm -i test.txt # Safety
59
+ test.js → src/test.js # Organization
60
+ git commit -m "fix" → [fix] fix + co-author # Commits
61
+ ```
62
+
63
+ > 📚 **Docs**: [HOOKS-V2-MODIFICATION.md](./docs/HOOKS-V2-MODIFICATION.md) | **Plugin**: `.claude-plugin/` | **Composable** with `agent-booster`
64
+
84
65
  ## 🌐 **Flow Nexus Cloud Platform**
85
66
 
86
67
  **NEW**: Claude-Flow v2.0.0 now includes **Flow Nexus integration** - a cloud-powered AI development platform featuring:
@@ -116,11 +97,18 @@ claude --dangerously-skip-permissions
116
97
 
117
98
  ### 🎯 **Instant Alpha Testing**
118
99
 
100
+ **Method 1: Plugin Installation** (Easiest - includes PreToolUse hooks!)
101
+ ```bash
102
+ # In Claude Code:
103
+ /plugin ruvnet/claude-flow
104
+ ```
105
+
106
+ **Method 2: NPM Installation** (For MCP server + CLI)
119
107
  ```bash
120
108
  # 1. Initialize Claude Flow with enhanced MCP setup (auto-configures permissions!)
121
109
  npx claude-flow@alpha init --force
122
110
 
123
- # 2. Explore all revolutionary capabilities
111
+ # 2. Explore all revolutionary capabilities
124
112
  npx claude-flow@alpha --help
125
113
 
126
114
  # 3a. Quick AI coordination (recommended for most tasks)
@@ -347,6 +335,13 @@ For detailed information about all features, advanced usage, and comprehensive g
347
335
 
348
336
  ---
349
337
 
338
+ ### 📊 Targets (Month 12)
339
+ - 5K+ GitHub stars, 50K npm downloads/month
340
+ - $25K MRR, 15 enterprise customers
341
+ - 90%+ error prevention, 30+ min saved/dev/week
342
+
343
+ ---
344
+
350
345
  ## Star History
351
346
 
352
347
  <a href="https://www.star-history.com/#ruvnet/claude-flow&Date">
@@ -361,6 +356,6 @@ For detailed information about all features, advanced usage, and comprehensive g
361
356
 
362
357
  **Built with ❤️ by [rUv](https://github.com/ruvnet) | Powered by Revolutionary AI**
363
358
 
364
- *v2.0.0 Alpha - The Future of AI Orchestration*
359
+ *v2.5.0-alpha.140 - The Future of AI Orchestration with PreToolUse Modification Hooks*
365
360
 
366
361
  </div>
package/bin/claude-flow CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
  # Claude-Flow Smart Dispatcher - Detects and uses the best available runtime
3
3
 
4
- VERSION="2.5.0-alpha.138"
4
+ VERSION="2.5.0-alpha.141"
5
5
 
6
6
  # Determine the correct path based on how the script is invoked
7
7
  if [ -L "$0" ]; then
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from './commander-fix.js';
3
+ import chalk from 'chalk';
4
+ import { checkpointManager } from '../../sdk/checkpoint-manager.js';
5
+ import Table from 'cli-table3';
6
+ import inquirer from 'inquirer';
7
+ export const checkpointCommand = new Command().name('checkpoint').description('Manage session checkpoints (Git-like time travel for AI sessions)').action(()=>{
8
+ checkpointCommand.help();
9
+ });
10
+ checkpointCommand.command('create').description('Create a checkpoint for a session').argument('<session-id>', 'Session ID to checkpoint').argument("[description]", "Checkpoint description").action(async (sessionId, description)=>{
11
+ try {
12
+ console.log(chalk.cyan(`Creating checkpoint for session: ${sessionId}`));
13
+ const checkpointId = await checkpointManager.createCheckpoint(sessionId, description || `Manual checkpoint at ${new Date().toLocaleString()}`);
14
+ console.log(chalk.green('✓ Checkpoint created'));
15
+ console.log(`${chalk.white('ID:')} ${checkpointId}`);
16
+ console.log(`${chalk.white('Session:')} ${sessionId}`);
17
+ console.log(`${chalk.white("Description:")} ${description || '(auto-generated)'}`);
18
+ console.log(chalk.gray(` Use 'claude-flow checkpoint rollback ${checkpointId}' to restore`));
19
+ } catch (error) {
20
+ console.error(chalk.red('Failed to create checkpoint:'), error.message);
21
+ process.exit(1);
22
+ }
23
+ });
24
+ checkpointCommand.command('list').description('List checkpoints for a session').argument('<session-id>', 'Session ID').option('--format <format>', 'Output format (table, json)', 'table').action(async (sessionId, options)=>{
25
+ try {
26
+ const checkpoints = checkpointManager.listCheckpoints(sessionId);
27
+ if (checkpoints.length === 0) {
28
+ console.log(chalk.gray(`No checkpoints found for session: ${sessionId}`));
29
+ return;
30
+ }
31
+ if (options.format === 'json') {
32
+ console.log(JSON.stringify(checkpoints, null, 2));
33
+ return;
34
+ }
35
+ console.log(chalk.cyan.bold(`Checkpoints for ${sessionId} (${checkpoints.length})`));
36
+ console.log('─'.repeat(80));
37
+ const table = new Table({
38
+ head: [
39
+ 'ID',
40
+ "Description",
41
+ 'Messages',
42
+ 'Tokens',
43
+ 'Files',
44
+ 'Created'
45
+ ]
46
+ });
47
+ for (const cp of checkpoints){
48
+ table.push([
49
+ chalk.gray(cp.id.substring(0, 8) + '...'),
50
+ cp.description.substring(0, 30) + (cp.description.length > 30 ? '...' : ''),
51
+ cp.messageCount.toString(),
52
+ cp.totalTokens.toString(),
53
+ cp.filesModified.length.toString(),
54
+ new Date(cp.timestamp).toLocaleString()
55
+ ]);
56
+ }
57
+ console.log(table.toString());
58
+ } catch (error) {
59
+ console.error(chalk.red('Failed to list checkpoints:'), error.message);
60
+ process.exit(1);
61
+ }
62
+ });
63
+ checkpointCommand.command('info').description('Show detailed checkpoint information').argument('<checkpoint-id>', 'Checkpoint ID').action(async (checkpointId)=>{
64
+ try {
65
+ const checkpoint = checkpointManager.getCheckpoint(checkpointId);
66
+ if (!checkpoint) {
67
+ console.error(chalk.red(`Checkpoint '${checkpointId}' not found`));
68
+ process.exit(1);
69
+ }
70
+ console.log(chalk.cyan.bold('Checkpoint Information'));
71
+ console.log('─'.repeat(50));
72
+ console.log(`${chalk.white('ID:')} ${checkpoint.id}`);
73
+ console.log(`${chalk.white('Session:')} ${checkpoint.sessionId}`);
74
+ console.log(`${chalk.white("Description:")} ${checkpoint.description}`);
75
+ console.log(`${chalk.white('Created:')} ${new Date(checkpoint.timestamp).toLocaleString()}`);
76
+ console.log();
77
+ console.log(chalk.cyan.bold('Statistics'));
78
+ console.log('─'.repeat(50));
79
+ console.log(`${chalk.white('Messages:')} ${checkpoint.messageCount}`);
80
+ console.log(`${chalk.white('Total Tokens:')} ${checkpoint.totalTokens}`);
81
+ console.log(`${chalk.white('Files Modified:')} ${checkpoint.filesModified.length}`);
82
+ if (checkpoint.filesModified.length > 0) {
83
+ console.log();
84
+ console.log(chalk.cyan.bold('Modified Files'));
85
+ console.log('─'.repeat(50));
86
+ for (const file of checkpoint.filesModified){
87
+ console.log(` • ${file}`);
88
+ }
89
+ }
90
+ } catch (error) {
91
+ console.error(chalk.red('Failed to show checkpoint info:'), error.message);
92
+ process.exit(1);
93
+ }
94
+ });
95
+ checkpointCommand.command('rollback').description('Rollback session to a checkpoint (Git-like time travel)').argument('<checkpoint-id>', 'Checkpoint ID to restore').option('-p, --prompt <prompt>', 'Continue prompt after rollback').option('-f, --force', 'Skip confirmation').action(async (checkpointId, options)=>{
96
+ try {
97
+ const checkpoint = checkpointManager.getCheckpoint(checkpointId);
98
+ if (!checkpoint) {
99
+ console.error(chalk.red(`Checkpoint '${checkpointId}' not found`));
100
+ process.exit(1);
101
+ }
102
+ console.log(chalk.cyan.bold('Checkpoint to restore:'));
103
+ console.log(`${chalk.white("Description:")} ${checkpoint.description}`);
104
+ console.log(`${chalk.white('Created:')} ${new Date(checkpoint.timestamp).toLocaleString()}`);
105
+ console.log(`${chalk.white('Messages:')} ${checkpoint.messageCount}`);
106
+ console.log(`${chalk.white('Files:')} ${checkpoint.filesModified.length}`);
107
+ if (!options.force) {
108
+ const { confirmed } = await inquirer.prompt({
109
+ type: 'confirm',
110
+ name: 'confirmed',
111
+ message: 'Rollback to this checkpoint? (Current progress will be lost)',
112
+ default: false
113
+ });
114
+ if (!confirmed) {
115
+ console.log(chalk.gray('Rollback cancelled'));
116
+ return;
117
+ }
118
+ }
119
+ console.log(chalk.yellow('Rolling back...'));
120
+ console.log(chalk.blue(' • Using SDK resumeSessionAt to rewind'));
121
+ await checkpointManager.rollbackToCheckpoint(checkpointId, options.prompt || 'Continue from checkpoint');
122
+ console.log(chalk.green('✓ Rolled back to checkpoint successfully'));
123
+ console.log(chalk.gray(' Session rewound to exact point using SDK'));
124
+ } catch (error) {
125
+ console.error(chalk.red('Failed to rollback:'), error.message);
126
+ process.exit(1);
127
+ }
128
+ });
129
+ checkpointCommand.command('delete').description('Delete a checkpoint').argument('<checkpoint-id>', 'Checkpoint ID').option('-f, --force', 'Skip confirmation').action(async (checkpointId, options)=>{
130
+ try {
131
+ const checkpoint = checkpointManager.getCheckpoint(checkpointId);
132
+ if (!checkpoint) {
133
+ console.error(chalk.red(`Checkpoint '${checkpointId}' not found`));
134
+ process.exit(1);
135
+ }
136
+ if (!options.force) {
137
+ const { confirmed } = await inquirer.prompt({
138
+ type: 'confirm',
139
+ name: 'confirmed',
140
+ message: `Delete checkpoint '${checkpoint.description}'?`,
141
+ default: false
142
+ });
143
+ if (!confirmed) {
144
+ console.log(chalk.gray('Delete cancelled'));
145
+ return;
146
+ }
147
+ }
148
+ await checkpointManager.deleteCheckpoint(checkpointId);
149
+ console.log(chalk.green('✓ Checkpoint deleted'));
150
+ } catch (error) {
151
+ console.error(chalk.red('Failed to delete checkpoint:'), error.message);
152
+ process.exit(1);
153
+ }
154
+ });
155
+
156
+ //# sourceMappingURL=checkpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/cli/commands/checkpoint.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * Checkpoint Management Commands\n * Uses SDK checkpoint manager for Git-like checkpointing\n */\n\nimport { Command } from './commander-fix.js';\nimport chalk from 'chalk';\nimport { checkpointManager } from '../../sdk/checkpoint-manager.js';\nimport Table from 'cli-table3';\nimport inquirer from 'inquirer';\n\nexport const checkpointCommand = new Command()\n .name('checkpoint')\n .description('Manage session checkpoints (Git-like time travel for AI sessions)')\n .action(() => {\n checkpointCommand.help();\n });\n\n// Create checkpoint\ncheckpointCommand\n .command('create')\n .description('Create a checkpoint for a session')\n .argument('<session-id>', 'Session ID to checkpoint')\n .argument('[description]', 'Checkpoint description')\n .action(async (sessionId: string, description?: string) => {\n try {\n console.log(chalk.cyan(`Creating checkpoint for session: ${sessionId}`));\n\n const checkpointId = await checkpointManager.createCheckpoint(\n sessionId,\n description || `Manual checkpoint at ${new Date().toLocaleString()}`\n );\n\n console.log(chalk.green('✓ Checkpoint created'));\n console.log(`${chalk.white('ID:')} ${checkpointId}`);\n console.log(`${chalk.white('Session:')} ${sessionId}`);\n console.log(`${chalk.white('Description:')} ${description || '(auto-generated)'}`);\n console.log(chalk.gray(` Use 'claude-flow checkpoint rollback ${checkpointId}' to restore`));\n } catch (error) {\n console.error(chalk.red('Failed to create checkpoint:'), (error as Error).message);\n process.exit(1);\n }\n });\n\n// List checkpoints\ncheckpointCommand\n .command('list')\n .description('List checkpoints for a session')\n .argument('<session-id>', 'Session ID')\n .option('--format <format>', 'Output format (table, json)', 'table')\n .action(async (sessionId: string, options: any) => {\n try {\n const checkpoints = checkpointManager.listCheckpoints(sessionId);\n\n if (checkpoints.length === 0) {\n console.log(chalk.gray(`No checkpoints found for session: ${sessionId}`));\n return;\n }\n\n if (options.format === 'json') {\n console.log(JSON.stringify(checkpoints, null, 2));\n return;\n }\n\n console.log(chalk.cyan.bold(`Checkpoints for ${sessionId} (${checkpoints.length})`));\n console.log('─'.repeat(80));\n\n const table = new Table({\n head: ['ID', 'Description', 'Messages', 'Tokens', 'Files', 'Created'],\n });\n\n for (const cp of checkpoints) {\n table.push([\n chalk.gray(cp.id.substring(0, 8) + '...'),\n cp.description.substring(0, 30) + (cp.description.length > 30 ? '...' : ''),\n cp.messageCount.toString(),\n cp.totalTokens.toString(),\n cp.filesModified.length.toString(),\n new Date(cp.timestamp).toLocaleString(),\n ]);\n }\n\n console.log(table.toString());\n } catch (error) {\n console.error(chalk.red('Failed to list checkpoints:'), (error as Error).message);\n process.exit(1);\n }\n });\n\n// Get checkpoint info\ncheckpointCommand\n .command('info')\n .description('Show detailed checkpoint information')\n .argument('<checkpoint-id>', 'Checkpoint ID')\n .action(async (checkpointId: string) => {\n try {\n const checkpoint = checkpointManager.getCheckpoint(checkpointId);\n\n if (!checkpoint) {\n console.error(chalk.red(`Checkpoint '${checkpointId}' not found`));\n process.exit(1);\n }\n\n console.log(chalk.cyan.bold('Checkpoint Information'));\n console.log('─'.repeat(50));\n console.log(`${chalk.white('ID:')} ${checkpoint.id}`);\n console.log(`${chalk.white('Session:')} ${checkpoint.sessionId}`);\n console.log(`${chalk.white('Description:')} ${checkpoint.description}`);\n console.log(`${chalk.white('Created:')} ${new Date(checkpoint.timestamp).toLocaleString()}`);\n console.log();\n\n console.log(chalk.cyan.bold('Statistics'));\n console.log('─'.repeat(50));\n console.log(`${chalk.white('Messages:')} ${checkpoint.messageCount}`);\n console.log(`${chalk.white('Total Tokens:')} ${checkpoint.totalTokens}`);\n console.log(`${chalk.white('Files Modified:')} ${checkpoint.filesModified.length}`);\n\n if (checkpoint.filesModified.length > 0) {\n console.log();\n console.log(chalk.cyan.bold('Modified Files'));\n console.log('─'.repeat(50));\n for (const file of checkpoint.filesModified) {\n console.log(` • ${file}`);\n }\n }\n } catch (error) {\n console.error(chalk.red('Failed to show checkpoint info:'), (error as Error).message);\n process.exit(1);\n }\n });\n\n// Rollback to checkpoint\ncheckpointCommand\n .command('rollback')\n .description('Rollback session to a checkpoint (Git-like time travel)')\n .argument('<checkpoint-id>', 'Checkpoint ID to restore')\n .option('-p, --prompt <prompt>', 'Continue prompt after rollback')\n .option('-f, --force', 'Skip confirmation')\n .action(async (checkpointId: string, options: any) => {\n try {\n const checkpoint = checkpointManager.getCheckpoint(checkpointId);\n\n if (!checkpoint) {\n console.error(chalk.red(`Checkpoint '${checkpointId}' not found`));\n process.exit(1);\n }\n\n console.log(chalk.cyan.bold('Checkpoint to restore:'));\n console.log(`${chalk.white('Description:')} ${checkpoint.description}`);\n console.log(`${chalk.white('Created:')} ${new Date(checkpoint.timestamp).toLocaleString()}`);\n console.log(`${chalk.white('Messages:')} ${checkpoint.messageCount}`);\n console.log(`${chalk.white('Files:')} ${checkpoint.filesModified.length}`);\n\n if (!options.force) {\n const { confirmed } = await inquirer.prompt({\n type: 'confirm',\n name: 'confirmed',\n message: 'Rollback to this checkpoint? (Current progress will be lost)',\n default: false,\n });\n\n if (!confirmed) {\n console.log(chalk.gray('Rollback cancelled'));\n return;\n }\n }\n\n console.log(chalk.yellow('Rolling back...'));\n console.log(chalk.blue(' • Using SDK resumeSessionAt to rewind'));\n\n await checkpointManager.rollbackToCheckpoint(\n checkpointId,\n options.prompt || 'Continue from checkpoint'\n );\n\n console.log(chalk.green('✓ Rolled back to checkpoint successfully'));\n console.log(chalk.gray(' Session rewound to exact point using SDK'));\n } catch (error) {\n console.error(chalk.red('Failed to rollback:'), (error as Error).message);\n process.exit(1);\n }\n });\n\n// Delete checkpoint\ncheckpointCommand\n .command('delete')\n .description('Delete a checkpoint')\n .argument('<checkpoint-id>', 'Checkpoint ID')\n .option('-f, --force', 'Skip confirmation')\n .action(async (checkpointId: string, options: any) => {\n try {\n const checkpoint = checkpointManager.getCheckpoint(checkpointId);\n\n if (!checkpoint) {\n console.error(chalk.red(`Checkpoint '${checkpointId}' not found`));\n process.exit(1);\n }\n\n if (!options.force) {\n const { confirmed } = await inquirer.prompt({\n type: 'confirm',\n name: 'confirmed',\n message: `Delete checkpoint '${checkpoint.description}'?`,\n default: false,\n });\n\n if (!confirmed) {\n console.log(chalk.gray('Delete cancelled'));\n return;\n }\n }\n\n await checkpointManager.deleteCheckpoint(checkpointId);\n console.log(chalk.green('✓ Checkpoint deleted'));\n } catch (error) {\n console.error(chalk.red('Failed to delete checkpoint:'), (error as Error).message);\n process.exit(1);\n }\n });\n"],"names":["Command","chalk","checkpointManager","Table","inquirer","checkpointCommand","name","description","action","help","command","argument","sessionId","console","log","cyan","checkpointId","createCheckpoint","Date","toLocaleString","green","white","gray","error","red","message","process","exit","option","options","checkpoints","listCheckpoints","length","format","JSON","stringify","bold","repeat","table","head","cp","push","id","substring","messageCount","toString","totalTokens","filesModified","timestamp","checkpoint","getCheckpoint","file","force","confirmed","prompt","type","default","yellow","blue","rollbackToCheckpoint","deleteCheckpoint"],"mappings":";AAMA,SAASA,OAAO,QAAQ,qBAAqB;AAC7C,OAAOC,WAAW,QAAQ;AAC1B,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,OAAOC,WAAW,aAAa;AAC/B,OAAOC,cAAc,WAAW;AAEhC,OAAO,MAAMC,oBAAoB,IAAIL,UAClCM,IAAI,CAAC,cACLC,WAAW,CAAC,qEACZC,MAAM,CAAC;IACNH,kBAAkBI,IAAI;AACxB,GAAG;AAGLJ,kBACGK,OAAO,CAAC,UACRH,WAAW,CAAC,qCACZI,QAAQ,CAAC,gBAAgB,4BACzBA,QAAQ,CAAC,iBAAiB,0BAC1BH,MAAM,CAAC,OAAOI,WAAmBL;IAChC,IAAI;QACFM,QAAQC,GAAG,CAACb,MAAMc,IAAI,CAAC,CAAC,iCAAiC,EAAEH,WAAW;QAEtE,MAAMI,eAAe,MAAMd,kBAAkBe,gBAAgB,CAC3DL,WACAL,eAAe,CAAC,qBAAqB,EAAE,IAAIW,OAAOC,cAAc,IAAI;QAGtEN,QAAQC,GAAG,CAACb,MAAMmB,KAAK,CAAC;QACxBP,QAAQC,GAAG,CAAC,GAAGb,MAAMoB,KAAK,CAAC,OAAO,CAAC,EAAEL,cAAc;QACnDH,QAAQC,GAAG,CAAC,GAAGb,MAAMoB,KAAK,CAAC,YAAY,CAAC,EAAET,WAAW;QACrDC,QAAQC,GAAG,CAAC,GAAGb,MAAMoB,KAAK,CAAC,gBAAgB,CAAC,EAAEd,eAAe,oBAAoB;QACjFM,QAAQC,GAAG,CAACb,MAAMqB,IAAI,CAAC,CAAC,uCAAuC,EAAEN,aAAa,YAAY,CAAC;IAC7F,EAAE,OAAOO,OAAO;QACdV,QAA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AAY,EAAER,aAAa,WAAW,CAAC;YAChEU,QAAQC,IAAI,CAAC;QACf;QAEA,IAAI,CAACE,QAAQuB,KAAK,EAAE;YAClB,MAAM,EAAEC,SAAS,EAAE,GAAG,MAAMjD,SAASkD,MAAM,CAAC;gBAC1CC,MAAM;gBACNjD,MAAM;gBACNmB,SAAS,CAAC,mBAAmB,EAAEwB,WAAW1C,WAAW,CAAC,EAAE,CAAC;gBACzDiD,SAAS;YACX;YAEA,IAAI,CAACH,WAAW;gBACdxC,QAAQC,GAAG,CAACb,MAAMqB,IAAI,CAAC;gBACvB;YACF;QACF;QAEA,MAAMpB,kBAAkB0D,gBAAgB,CAAC5C;QACzCH,QAAQC,GAAG,CAACb,MAAMmB,KAAK,CAAC;IAC1B,EAAE,OAAOG,OAAO;QACdV,QAAQU,KAAK,CAACtB,MAAMuB,GAAG,CAAC,iCAAiC,AAACD,MAAgBE,OAAO;QACjFC,QAAQC,IAAI,CAAC;IACf;AACF"}
@@ -24,6 +24,9 @@ export class HelpFormatter {
24
24
  if (info.examples && info.examples.length > 0) {
25
25
  sections.push(this.formatSection('EXAMPLES', info.examples));
26
26
  }
27
+ if (info.details) {
28
+ sections.push('\n' + info.details);
29
+ }
27
30
  if (info.commands && info.commands.length > 0) {
28
31
  sections.push(`Run '${info.name} <command> --help' for more information on a command.`);
29
32
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/cli/help-formatter.ts"],"sourcesContent":["/**\n * Standardized CLI Help Formatter\n * Follows Unix/Linux conventions for help output\n */\n\nexport interface CommandInfo {\n name: string;\n description: string;\n usage?: string;\n commands?: CommandItem[];\n options?: OptionItem[];\n examples?: string[];\n globalOptions?: OptionItem[];\n}\n\nexport interface CommandItem {\n name: string;\n description: string;\n aliases?: string[];\n}\n\nexport interface OptionItem {\n flags: string;\n description: string;\n defaultValue?: string;\n validValues?: string[];\n}\n\nexport class HelpFormatter {\n private static readonly INDENT = ' ';\n private static readonly COLUMN_GAP = 2;\n private static readonly MIN_DESCRIPTION_COLUMN = 25;\n\n /**\n * Format main command help\n */\n static formatHelp(info: CommandInfo): string {\n const sections: string[] = [];\n\n // NAME section\n sections.push(this.formatSection('NAME', [`${info.name} - ${info.description}`]));\n\n // SYNOPSIS section\n if (info.usage) {\n sections.push(this.formatSection('SYNOPSIS', [info.usage]));\n }\n\n // COMMANDS section\n if (info.commands && info.commands.length > 0) {\n sections.push(this.formatSection('COMMANDS', this.formatCommands(info.commands)));\n }\n\n // OPTIONS section\n if (info.options && info.options.length > 0) {\n sections.push(this.formatSection('OPTIONS', this.formatOptions(info.options)));\n }\n\n // GLOBAL OPTIONS section\n if (info.globalOptions && info.globalOptions.length > 0) {\n sections.push(this.formatSection('GLOBAL OPTIONS', this.formatOptions(info.globalOptions)));\n }\n\n // EXAMPLES section\n if (info.examples && info.examples.length > 0) {\n sections.push(this.formatSection('EXAMPLES', info.examples));\n }\n\n // Footer\n if (info.commands && info.commands.length > 0) {\n sections.push(`Run '${info.name} <command> --help' for more information on a command.`);\n }\n\n return sections.join('\\n\\n');\n }\n\n /**\n * Format error message with usage hint\n */\n static formatError(error: string, command: string, usage?: string): string {\n const lines: string[] = [`Error: ${error}`, ''];\n\n if (usage) {\n lines.push(`Usage: ${usage}`);\n }\n\n lines.push(`Try '${command} --help' for more information.`);\n\n return lines.join('\\n');\n }\n\n /**\n * Format validation error with valid options\n */\n static formatValidationError(\n value: string,\n paramName: string,\n validOptions: string[],\n command: string,\n ): string {\n return this.formatError(\n `'${value}' is not a valid ${paramName}. Valid options are: ${validOptions.join(', ')}.`,\n command,\n );\n }\n\n private static formatSection(title: string, content: string[]): string {\n return `${title}\\n${content.map((line) => `${this.INDENT}${line}`).join('\\n')}`;\n }\n\n private static formatCommands(commands: CommandItem[]): string[] {\n const maxNameLength = Math.max(\n this.MIN_DESCRIPTION_COLUMN,\n ...commands.map((cmd) => {\n const nameLength = cmd.name.length;\n const aliasLength = cmd.aliases ? ` (${cmd.aliases.join(', ')})`.length : 0;\n return nameLength + aliasLength;\n }),\n );\n\n return commands.map((cmd) => {\n let name = cmd.name;\n if (cmd.aliases && cmd.aliases.length > 0) {\n name += ` (${cmd.aliases.join(', ')})`;\n }\n const padding = ' '.repeat(maxNameLength - name.length + this.COLUMN_GAP);\n return `${name}${padding}${cmd.description}`;\n });\n }\n\n private static formatOptions(options: OptionItem[]): string[] {\n const maxFlagsLength = Math.max(\n this.MIN_DESCRIPTION_COLUMN,\n ...options.map((opt) => opt.flags.length),\n );\n\n return options.map((opt) => {\n const padding = ' '.repeat(maxFlagsLength - opt.flags.length + this.COLUMN_GAP);\n let description = opt.description;\n\n // Add default value\n if (opt.defaultValue !== undefined) {\n description += ` [default: ${opt.defaultValue}]`;\n }\n\n // Add valid values on next line if present\n if (opt.validValues && opt.validValues.length > 0) {\n const validValuesLine =\n ' '.repeat(maxFlagsLength + this.COLUMN_GAP) + `Valid: ${opt.validValues.join(', ')}`;\n return `${opt.flags}${padding}${description}\\n${this.INDENT}${validValuesLine}`;\n }\n\n return `${opt.flags}${padding}${description}`;\n });\n }\n\n /**\n * Strip ANSI color codes and emojis from text\n */\n static stripFormatting(text: string): string {\n // Remove ANSI color codes\n text = text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\n // Remove common emojis used in the CLI\n const emojiPattern =\n /[\\u{1F300}-\\u{1F9FF}]|[\\u{2600}-\\u{27BF}]|[\\u{1F000}-\\u{1F6FF}]|[\\u{1F680}-\\u{1F6FF}]/gu;\n text = text.replace(emojiPattern, '').trim();\n\n // Remove multiple spaces\n text = text.replace(/\\s+/g, ' ');\n\n return text;\n }\n}\n"],"names":["HelpFormatter","INDENT","COLUMN_GAP","MIN_DESCRIPTION_COLUMN","formatHelp","info","sections","push","formatSection","name","description","usage","commands","length","formatCommands","options","formatOptions","globalOptions","examples","join","formatError","error","command","lines","formatValidationError","value","paramName","validOptions","title","content","map","line","maxNameLength","Math","max","cmd","nameLength","aliasLength","aliases","padding","repeat","maxFlagsLength","opt","flags","defaultValue","undefined","validVal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AAKC,OAAO,CAAC,mBAAmB;QAGvC,MAAMC,eACJ;QACFF,OAAOA,KAAKC,OAAO,CAACC,cAAc,IAAIC,IAAI;QAG1CH,OAAOA,KAAKC,OAAO,CAAC,QAAQ;QAE5B,OAAOD;IACT;AACF"}
1
+ {"version":3,"sources":["../../../src/cli/help-formatter.js"],"sourcesContent":["/**\n * Standardized CLI Help Formatter\n * Follows Unix/Linux conventions for help output\n */\n\nexport class HelpFormatter {\n static INDENT = ' ';\n static COLUMN_GAP = 2;\n static MIN_DESCRIPTION_COLUMN = 25;\n\n /**\n * Format main command help\n */\n static formatHelp(info) {\n const sections = [];\n\n // NAME section\n sections.push(this.formatSection('NAME', [`${info.name} - ${info.description}`]));\n\n // SYNOPSIS section\n if (info.usage) {\n sections.push(this.formatSection('SYNOPSIS', [info.usage]));\n }\n\n // COMMANDS section\n if (info.commands && info.commands.length > 0) {\n sections.push(this.formatSection('COMMANDS', this.formatCommands(info.commands)));\n }\n\n // OPTIONS section\n if (info.options && info.options.length > 0) {\n sections.push(this.formatSection('OPTIONS', this.formatOptions(info.options)));\n }\n\n // GLOBAL OPTIONS section\n if (info.globalOptions && info.globalOptions.length > 0) {\n sections.push(this.formatSection('GLOBAL OPTIONS', this.formatOptions(info.globalOptions)));\n }\n\n // EXAMPLES section\n if (info.examples && info.examples.length > 0) {\n sections.push(this.formatSection('EXAMPLES', info.examples));\n }\n\n // DETAILS section (additional information)\n if (info.details) {\n sections.push('\\n' + info.details);\n }\n\n // Footer\n if (info.commands && info.commands.length > 0) {\n sections.push(`Run '${info.name} <command> --help' for more information on a command.`);\n }\n\n return sections.join('\\n\\n');\n }\n\n /**\n * Format error message with usage hint\n */\n static formatError(error, command, usage) {\n const lines = [`Error: ${error}`, ''];\n\n if (usage) {\n lines.push(`Usage: ${usage}`);\n }\n\n lines.push(`Try '${command} --help' for more information.`);\n\n return lines.join('\\n');\n }\n\n /**\n * Format validation error with valid options\n */\n static formatValidationError(value, paramName, validOptions, command) {\n return this.formatError(\n `'${value}' is not a valid ${paramName}. Valid options are: ${validOptions.join(', ')}.`,\n command,\n );\n }\n\n static formatSection(title, content) {\n return `${title}\\n${content.map((line) => `${this.INDENT}${line}`).join('\\n')}`;\n }\n\n static formatCommands(commands) {\n const maxNameLength = Math.max(\n this.MIN_DESCRIPTION_COLUMN,\n ...commands.map((cmd) => {\n const nameLength = cmd.name.length;\n const aliasLength = cmd.aliases ? ` (${cmd.aliases.join(', ')})`.length : 0;\n return nameLength + aliasLength;\n }),\n );\n\n return commands.map((cmd) => {\n let name = cmd.name;\n if (cmd.aliases && cmd.aliases.length > 0) {\n name += ` (${cmd.aliases.join(', ')})`;\n }\n const padding = ' '.repeat(maxNameLength - name.length + this.COLUMN_GAP);\n return `${name}${padding}${cmd.description}`;\n });\n }\n\n static formatOptions(options) {\n const maxFlagsLength = Math.max(\n this.MIN_DESCRIPTION_COLUMN,\n ...options.map((opt) => opt.flags.length),\n );\n\n return options.map((opt) => {\n const padding = ' '.repeat(maxFlagsLength - opt.flags.length + this.COLUMN_GAP);\n let description = opt.description;\n\n // Add default value\n if (opt.defaultValue !== undefined) {\n description += ` [default: ${opt.defaultValue}]`;\n }\n\n // Add valid values on next line if present\n if (opt.validValues && opt.validValues.length > 0) {\n const validValuesLine =\n ' '.repeat(maxFlagsLength + this.COLUMN_GAP) + `Valid: ${opt.validValues.join(', ')}`;\n return `${opt.flags}${padding}${description}\\n${this.INDENT}${validValuesLine}`;\n }\n\n return `${opt.flags}${padding}${description}`;\n });\n }\n\n /**\n * Strip ANSI color codes and emojis from text\n */\n static stripFormatting(text) {\n // Remove ANSI color codes\n text = text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\n // Remove common emojis used in the CLI\n const emojiPattern =\n /[\\u{1F300}-\\u{1F9FF}]|[\\u{2600}-\\u{27BF}]|[\\u{1F000}-\\u{1F6FF}]|[\\u{1F680}-\\u{1F6FF}]/gu;\n text = text.replace(emojiPattern, '').trim();\n\n // Remove multiple spaces\n text = text.replace(/\\s+/g, ' ');\n\n return text;\n }\n}\n"],"names":["HelpFormatter","INDENT","COLUMN_GAP","MIN_DESCRIPTION_COLUMN","formatHelp","info","sections","push","formatSection","name","description","usage","commands","length","formatCommands","options","formatOptions","globalOptions","examples","details","join","formatError","error","command","lines","formatValidationError","value","paramName","validOptions","title","content","map","line","maxNameLength","Math","max","cmd","nameLength","aliasLength","aliases","padding","repeat","maxFlagsLength","opt","flags","defaultValue","undefined","validValues","validValuesLine","stripFormatting","text","replace","emojiPattern","trim"],"mappings":"AAKA,OAAO,MAAMA;IACX,OAAOC,SAAS,OAAO;IACvB,OAAOC,aAAa,EAAE;IACtB,OAAOC,yBAAyB,GAAG;IAKnC,OAAOC,WAAWC,IAAI,EAAE;QACtB,MAAMC,WAAW,EAAE;QAGnBA,SAASC,IAAI,CAAC,IAAI,CAACC,aAAa,CAAC,QAAQ;YAAC,GAAGH,KAAKI,IAAI,CAAC,GAAG,EAAEJ,KAAKK,WAAW,EAAE;SAAC;QAG/E,IAAIL,KAAKM,KAAK,EAAE;YACdL,SAASC,IAAI,CAAC,IAAI,CAACC,aAAa,CAAC,YAAY;gBAACH,KAAKM,KAAK;aAAC;QAC3D;QAGA,IAAIN,KAAKO,QAAQ,IAAIP,KAAKO,QAAQ,CAACC,MAAM,GAAG,GAAG;YAC7CP,SAASC,IAAI,CAAC,IAAI,CAACC,aAAa,CAAC,YAAY,IAAI,CAACM,cAAc,CAACT,KAAKO,QAAQ;QAChF;QAGA,IAAIP,KAAKU,OAAO,IAAIV,KAAKU,OAAO,CAACF,MAAM,GAAG,GAAG;YAC3CP,SAASC,IAAI,CAAC,IAAI,CAACC,aAAa,CAAC,WAAW,IAAI,CAACQ,aAAa,CAACX,KAAKU,OAAO;QAC7E;QAGA,IAAIV,KAAKY,aAAa,IAAIZ,KAAKY,aAAa,CAACJ,MAAM,GAAG,GAAG;YACvDP,SAASC,IAAI,CAAC,IAAI,CAACC,aAAa,CAAC,kBAAkB,IAAI,CAACQ,aAAa,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