claude-code-workflow 6.0.4 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/.claude/agents/action-planning-agent.md +1 -1
  2. package/.claude/agents/cli-execution-agent.md +269 -269
  3. package/.claude/agents/cli-explore-agent.md +182 -182
  4. package/.claude/agents/context-search-agent.md +582 -582
  5. package/.claude/agents/memory-bridge.md +93 -93
  6. package/.claude/commands/cli/cli-init.md +1 -1
  7. package/.claude/commands/memory/docs-full-cli.md +471 -471
  8. package/.claude/commands/memory/docs-related-cli.md +386 -386
  9. package/.claude/commands/memory/docs.md +615 -615
  10. package/.claude/commands/memory/load.md +1 -1
  11. package/.claude/commands/memory/update-full.md +332 -332
  12. package/.claude/commands/memory/update-related.md +5 -5
  13. package/.claude/commands/workflow/init.md +1 -1
  14. package/.claude/commands/workflow/lite-fix.md +621 -621
  15. package/.claude/commands/workflow/lite-plan.md +592 -592
  16. package/.claude/commands/workflow/tools/context-gather.md +434 -434
  17. package/.claude/commands/workflow/ui-design/generate.md +504 -504
  18. package/.claude/commands/workflow/ui-design/import-from-code.md +537 -537
  19. package/.claude/scripts/classify-folders.sh +4 -0
  20. package/.claude/scripts/convert_tokens_to_css.sh +4 -0
  21. package/.claude/scripts/detect_changed_modules.sh +5 -1
  22. package/.claude/scripts/discover-design-files.sh +87 -83
  23. package/.claude/scripts/generate_module_docs.sh +717 -713
  24. package/.claude/scripts/get_modules_by_depth.sh +5 -1
  25. package/.claude/scripts/ui-generate-preview.sh +4 -0
  26. package/.claude/scripts/ui-instantiate-prototypes.sh +4 -0
  27. package/.claude/scripts/update_module_claude.sh +4 -0
  28. package/.claude/skills/command-guide/index/all-commands.json +1 -12
  29. package/.claude/skills/command-guide/index/by-category.json +1 -12
  30. package/.claude/skills/command-guide/index/by-use-case.json +1 -12
  31. package/.claude/skills/command-guide/index/essential-commands.json +1 -12
  32. package/.claude/skills/command-guide/reference/agents/action-planning-agent.md +127 -71
  33. package/.claude/skills/command-guide/reference/agents/cli-execution-agent.md +269 -269
  34. package/.claude/skills/command-guide/reference/agents/cli-explore-agent.md +182 -182
  35. package/.claude/skills/command-guide/reference/agents/conceptual-planning-agent.md +18 -38
  36. package/.claude/skills/command-guide/reference/agents/context-search-agent.md +582 -577
  37. package/.claude/skills/command-guide/reference/agents/memory-bridge.md +93 -93
  38. package/.claude/skills/command-guide/reference/commands/cli/cli-init.md +1 -1
  39. package/.claude/skills/command-guide/reference/commands/memory/docs-full-cli.md +471 -471
  40. package/.claude/skills/command-guide/reference/commands/memory/docs-related-cli.md +386 -386
  41. package/.claude/skills/command-guide/reference/commands/memory/docs.md +615 -610
  42. package/.claude/skills/command-guide/reference/commands/memory/load.md +1 -1
  43. package/.claude/skills/command-guide/reference/commands/memory/update-full.md +332 -332
  44. package/.claude/skills/command-guide/reference/commands/memory/update-related.md +5 -5
  45. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/artifacts.md +299 -451
  46. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/auto-parallel.md +14 -37
  47. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/synthesis.md +252 -350
  48. package/.claude/skills/command-guide/reference/commands/workflow/init.md +2 -2
  49. package/.claude/skills/command-guide/reference/commands/workflow/lite-execute.md +52 -0
  50. package/.claude/skills/command-guide/reference/commands/workflow/lite-fix.md +621 -602
  51. package/.claude/skills/command-guide/reference/commands/workflow/lite-plan.md +46 -36
  52. package/.claude/skills/command-guide/reference/commands/workflow/review-fix.md +18 -58
  53. package/.claude/skills/command-guide/reference/commands/workflow/review-module-cycle.md +22 -52
  54. package/.claude/skills/command-guide/reference/commands/workflow/review-session-cycle.md +19 -48
  55. package/.claude/skills/command-guide/reference/commands/workflow/session/start.md +25 -5
  56. package/.claude/skills/command-guide/reference/commands/workflow/tdd-plan.md +1 -1
  57. package/.claude/skills/command-guide/reference/commands/workflow/test-fix-gen.md +7 -7
  58. package/.claude/skills/command-guide/reference/commands/workflow/tools/context-gather.md +434 -434
  59. package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-agent.md +151 -11
  60. package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-tdd.md +4 -4
  61. package/.claude/skills/command-guide/reference/commands/workflow/tools/test-task-generate.md +1 -1
  62. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/generate.md +504 -504
  63. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/import-from-code.md +537 -537
  64. package/.claude/workflows/context-search-strategy.md +77 -77
  65. package/.claude/workflows/tool-strategy.md +90 -71
  66. package/.claude/workflows/workflow-architecture.md +1 -1
  67. package/ccw/package.json +6 -6
  68. package/ccw/src/cli.js +16 -0
  69. package/ccw/src/commands/stop.js +101 -0
  70. package/ccw/src/commands/tool.js +181 -0
  71. package/ccw/src/core/dashboard-generator.js +18 -3
  72. package/ccw/src/core/lite-scanner.js +35 -11
  73. package/ccw/src/core/server.js +583 -17
  74. package/ccw/src/templates/dashboard-css/01-base.css +161 -0
  75. package/ccw/src/templates/dashboard-css/02-session.css +726 -0
  76. package/ccw/src/templates/dashboard-css/03-tasks.css +512 -0
  77. package/ccw/src/templates/dashboard-css/04-lite-tasks.css +843 -0
  78. package/ccw/src/templates/dashboard-css/05-context.css +2206 -0
  79. package/ccw/src/templates/dashboard-css/06-cards.css +1570 -0
  80. package/ccw/src/templates/dashboard-css/07-managers.css +936 -0
  81. package/ccw/src/templates/dashboard-css/08-review.css +1266 -0
  82. package/ccw/src/templates/dashboard-css/09-explorer.css +1397 -0
  83. package/ccw/src/templates/dashboard-js/components/global-notifications.js +219 -0
  84. package/ccw/src/templates/dashboard-js/components/hook-manager.js +10 -0
  85. package/ccw/src/templates/dashboard-js/components/mcp-manager.js +24 -2
  86. package/ccw/src/templates/dashboard-js/components/navigation.js +11 -5
  87. package/ccw/src/templates/dashboard-js/components/tabs-context.js +20 -20
  88. package/ccw/src/templates/dashboard-js/components/tabs-other.js +11 -11
  89. package/ccw/src/templates/dashboard-js/components/theme.js +29 -1
  90. package/ccw/src/templates/dashboard-js/main.js +4 -0
  91. package/ccw/src/templates/dashboard-js/state.js +5 -0
  92. package/ccw/src/templates/dashboard-js/views/explorer.js +852 -0
  93. package/ccw/src/templates/dashboard-js/views/home.js +13 -9
  94. package/ccw/src/templates/dashboard-js/views/hook-manager.js +8 -5
  95. package/ccw/src/templates/dashboard-js/views/lite-tasks.js +21 -16
  96. package/ccw/src/templates/dashboard-js/views/mcp-manager.js +148 -8
  97. package/ccw/src/templates/dashboard-js/views/project-overview.js +15 -11
  98. package/ccw/src/templates/dashboard-js/views/review-session.js +3 -3
  99. package/ccw/src/templates/dashboard-js/views/session-detail.js +38 -28
  100. package/ccw/src/templates/dashboard.html +129 -28
  101. package/ccw/src/tools/classify-folders.js +204 -0
  102. package/ccw/src/tools/convert-tokens-to-css.js +250 -0
  103. package/ccw/src/tools/detect-changed-modules.js +288 -0
  104. package/ccw/src/tools/discover-design-files.js +134 -0
  105. package/ccw/src/tools/edit-file.js +266 -0
  106. package/ccw/src/tools/generate-module-docs.js +416 -0
  107. package/ccw/src/tools/get-modules-by-depth.js +308 -0
  108. package/ccw/src/tools/index.js +176 -0
  109. package/ccw/src/tools/ui-generate-preview.js +327 -0
  110. package/ccw/src/tools/ui-instantiate-prototypes.js +301 -0
  111. package/ccw/src/tools/update-module-claude.js +380 -0
  112. package/ccw/src/utils/browser-launcher.js +15 -4
  113. package/package.json +1 -1
  114. package/.claude/skills/command-guide/reference/commands/workflow/status.md +0 -352
  115. package/ccw/src/core/server.js.bak +0 -385
  116. package/ccw/src/core/server_original.bak +0 -385
  117. package/ccw/src/templates/dashboard.css +0 -8114
  118. package/ccw/src/templates/dashboard_tailwind.html +0 -42
  119. package/ccw/src/templates/dashboard_test.html +0 -37
  120. package/ccw/src/templates/tailwind-base.css +0 -212
@@ -1,77 +1,77 @@
1
- ---
2
- name: context-search-strategy
3
- description: Strategic guidelines for context search commands
4
- type: search-guideline
5
- ---
6
-
7
- # Context Search Strategy
8
-
9
- ## ⚡ Execution Environment
10
-
11
- **CRITICAL**: All commands execute in **Bash environment** (Git Bash on Windows)
12
-
13
- **❌ Forbidden**: Windows commands (`findstr`, `dir`, `where`) - Use Bash (`grep`, `find`, `cat`)
14
-
15
- ## ⚡ Core Search Tools
16
-
17
- **Skill()**: FASTEST way to get context - use FIRST if SKILL exists. Three types: (1) `workflow-progress` for WFS sessions (2) tech SKILLs for stack docs (3) `{project-name}` for project docs
18
- **codebase-retrieval**: Semantic file discovery via Gemini CLI with all files analysis
19
- **rg (ripgrep)**: Fast content search with regex support
20
- **find**: File/directory location by name patterns
21
- **grep**: Built-in pattern matching (fallback when rg unavailable)
22
- **get_modules_by_depth.sh**: Program architecture analysis (MANDATORY before planning)
23
-
24
- ## 📋 Tool Selection Matrix
25
-
26
- | Need | Tool | Use Case |
27
- |------|------|----------|
28
- | **Workflow history** | Skill(workflow-progress) | WFS sessions lessons/conflicts - `/memory:workflow-skill-memory` |
29
- | **Tech stack docs** | Skill({tech-name}) | Stack APIs/guides - `/memory:tech-research` |
30
- | **Project docs** | Skill({project-name}) | Project modules/architecture - `/memory:skill-memory` |
31
- | **Semantic discovery** | codebase-retrieval | Find files relevant to task/feature context |
32
- | **Pattern matching** | rg | Search code content with regex |
33
- | **File name lookup** | find | Locate files by name patterns |
34
- | **Architecture** | get_modules_by_depth.sh | Understand program structure |
35
-
36
- ## 🔧 Quick Command Reference
37
-
38
- ```bash
39
- # SKILL Packages (FIRST PRIORITY - fastest context loading)
40
- Skill(command: "workflow-progress") # Workflow: WFS sessions history, lessons, conflicts
41
- Skill(command: "react-dev") # Tech: React APIs, patterns, best practices
42
- Skill(command: "claude_dms3") # Project: Project modules, architecture, examples
43
-
44
- # Semantic File Discovery (codebase-retrieval)
45
- cd [directory] && gemini -p "
46
- PURPOSE: Discover files relevant to task/feature
47
- TASK: List all files related to [task/feature description]
48
- MODE: analysis
49
- CONTEXT: @**/*
50
- EXPECTED: Relevant file paths with relevance explanation
51
- RULES: Focus on direct relevance to task requirements
52
- "
53
-
54
- # Program Architecture (MANDATORY before planning)
55
- ~/.claude/scripts/get_modules_by_depth.sh
56
-
57
- # Content Search (rg preferred)
58
- rg "pattern" --type js -n # Search JS files with line numbers
59
- rg -i "case-insensitive" # Ignore case
60
- rg -C 3 "context" # Show 3 lines before/after
61
-
62
- # File Search
63
- find . -name "*.ts" -type f # Find TypeScript files
64
- find . -path "*/node_modules" -prune -o -name "*.js" -print
65
-
66
- # Workflow Examples
67
- rg "IMPL-\d+" .workflow/ --type json # Find task IDs
68
- find .workflow/ -name "*.json" -path "*/.task/*" # Locate task files
69
- rg "status.*pending" .workflow/.task/ # Find pending tasks
70
- ```
71
-
72
- ## ⚡ Performance Tips
73
-
74
- - **rg > grep** for content search
75
- - **Use --type filters** to limit file types
76
- - **Exclude dirs**: `--glob '!node_modules'`
77
- - **Use -F** for literal strings (no regex)
1
+ ---
2
+ name: context-search-strategy
3
+ description: Strategic guidelines for context search commands
4
+ type: search-guideline
5
+ ---
6
+
7
+ # Context Search Strategy
8
+
9
+ ## ⚡ Execution Environment
10
+
11
+ **CRITICAL**: All commands execute in **Bash environment** (Git Bash on Windows)
12
+
13
+ **❌ Forbidden**: Windows commands (`findstr`, `dir`, `where`) - Use Bash (`grep`, `find`, `cat`)
14
+
15
+ ## ⚡ Core Search Tools
16
+
17
+ **Skill()**: FASTEST way to get context - use FIRST if SKILL exists. Three types: (1) `workflow-progress` for WFS sessions (2) tech SKILLs for stack docs (3) `{project-name}` for project docs
18
+ **codebase-retrieval**: Semantic file discovery via Gemini CLI with all files analysis
19
+ **rg (ripgrep)**: Fast content search with regex support
20
+ **find**: File/directory location by name patterns
21
+ **grep**: Built-in pattern matching (fallback when rg unavailable)
22
+ **get_modules_by_depth.sh**: Program architecture analysis (MANDATORY before planning)
23
+
24
+ ## 📋 Tool Selection Matrix
25
+
26
+ | Need | Tool | Use Case |
27
+ |------|------|----------|
28
+ | **Workflow history** | Skill(workflow-progress) | WFS sessions lessons/conflicts - `/memory:workflow-skill-memory` |
29
+ | **Tech stack docs** | Skill({tech-name}) | Stack APIs/guides - `/memory:tech-research` |
30
+ | **Project docs** | Skill({project-name}) | Project modules/architecture - `/memory:skill-memory` |
31
+ | **Semantic discovery** | codebase-retrieval | Find files relevant to task/feature context |
32
+ | **Pattern matching** | rg | Search code content with regex |
33
+ | **File name lookup** | find | Locate files by name patterns |
34
+ | **Architecture** | get_modules_by_depth.sh | Understand program structure |
35
+
36
+ ## 🔧 Quick Command Reference
37
+
38
+ ```bash
39
+ # SKILL Packages (FIRST PRIORITY - fastest context loading)
40
+ Skill(command: "workflow-progress") # Workflow: WFS sessions history, lessons, conflicts
41
+ Skill(command: "react-dev") # Tech: React APIs, patterns, best practices
42
+ Skill(command: "claude_dms3") # Project: Project modules, architecture, examples
43
+
44
+ # Semantic File Discovery (codebase-retrieval)
45
+ cd [directory] && gemini -p "
46
+ PURPOSE: Discover files relevant to task/feature
47
+ TASK: List all files related to [task/feature description]
48
+ MODE: analysis
49
+ CONTEXT: @**/*
50
+ EXPECTED: Relevant file paths with relevance explanation
51
+ RULES: Focus on direct relevance to task requirements
52
+ "
53
+
54
+ # Program Architecture (MANDATORY before planning)
55
+ ccw tool exec get_modules_by_depth '{}'
56
+
57
+ # Content Search (rg preferred)
58
+ rg "pattern" --type js -n # Search JS files with line numbers
59
+ rg -i "case-insensitive" # Ignore case
60
+ rg -C 3 "context" # Show 3 lines before/after
61
+
62
+ # File Search
63
+ find . -name "*.ts" -type f # Find TypeScript files
64
+ find . -path "*/node_modules" -prune -o -name "*.js" -print
65
+
66
+ # Workflow Examples
67
+ rg "IMPL-\d+" .workflow/ --type json # Find task IDs
68
+ find .workflow/ -name "*.json" -path "*/.task/*" # Locate task files
69
+ rg "status.*pending" .workflow/.task/ # Find pending tasks
70
+ ```
71
+
72
+ ## ⚡ Performance Tips
73
+
74
+ - **rg > grep** for content search
75
+ - **Use --type filters** to limit file types
76
+ - **Exclude dirs**: `--glob '!node_modules'`
77
+ - **Use -F** for literal strings (no regex)
@@ -1,71 +1,90 @@
1
- # Tool Strategy
2
-
3
- ## ⚡ Exa Triggering Mechanisms
4
-
5
- **Auto-Trigger**:
6
- - User mentions "exa-code" or code-related queries → `mcp__exa__get_code_context_exa`
7
- - Need current web information → `mcp__exa__web_search_exa`
8
-
9
- **Manual Trigger**:
10
- - Complex API research → Exa Code Context
11
- - Real-time information needs → Exa Web Search
12
-
13
- ## ⚡ Bash Text Processing (sed/awk)
14
-
15
- **When to Use**: Edit tool fails 2+ times on same file
16
-
17
- ### sed Quick Reference
18
-
19
- ```bash
20
- # Replace first occurrence per line
21
- sed 's/old/new/' file.txt
22
-
23
- # Replace all occurrences (global)
24
- sed 's/old/new/g' file.txt
25
-
26
- # In-place edit (modify file directly)
27
- sed -i 's/old/new/g' file.txt
28
-
29
- # Delete lines matching pattern
30
- sed '/pattern/d' file.txt
31
-
32
- # Insert line before match
33
- sed '/pattern/i\new line' file.txt
34
-
35
- # Insert line after match
36
- sed '/pattern/a\new line' file.txt
37
-
38
- # Replace on specific line number
39
- sed '5s/old/new/' file.txt
40
-
41
- # Multi-line replacement (escape newlines)
42
- sed ':a;N;$!ba;s/old\npattern/new\ntext/g' file.txt
43
- ```
44
-
45
- ### awk Quick Reference
46
-
47
- ```bash
48
- # Print specific column
49
- awk '{print $1}' file.txt
50
-
51
- # Print lines matching pattern
52
- awk '/pattern/' file.txt
53
-
54
- # Replace field value
55
- awk '{$2="new"; print}' file.txt
56
-
57
- # Conditional replacement
58
- awk '/pattern/{gsub(/old/,"new")}1' file.txt
59
-
60
- # Insert line after match
61
- awk '/pattern/{print; print "new line"; next}1' file.txt
62
-
63
- # Multi-field operations
64
- awk -F',' '{print $1, $3}' file.csv
65
- ```
66
-
67
- ### Fallback Strategy
68
-
69
- 1. **Edit fails 2+ times** Try sed for simple replacements
70
- 2. **sed fails** Try awk for complex patterns
71
- 3. **awk fails** Use Write to recreate file
1
+ # Tool Strategy
2
+
3
+ ## ⚡ Exa Triggering Mechanisms
4
+
5
+ **Auto-Trigger**:
6
+ - User mentions "exa-code" or code-related queries → `mcp__exa__get_code_context_exa`
7
+ - Need current web information → `mcp__exa__web_search_exa`
8
+
9
+ **Manual Trigger**:
10
+ - Complex API research → Exa Code Context
11
+ - Real-time information needs → Exa Web Search
12
+
13
+ ## ⚡ CCW edit_file Tool (AI-Powered Editing)
14
+
15
+ **When to Use**: Edit tool fails 2+ times on same file
16
+
17
+ ### update Mode (Default)
18
+
19
+ **Best for**: Code block replacements, function rewrites, multi-line changes
20
+
21
+ ```bash
22
+ ccw tool exec edit_file '{
23
+ "path": "file.py",
24
+ "oldText": "def old():\n pass",
25
+ "newText": "def new():\n return True"
26
+ }'
27
+ ```
28
+
29
+ **Features**:
30
+ - Exact text matching (precise and predictable)
31
+ - ✅ Auto line ending adaptation (CRLF/LF)
32
+ - Simple `oldText` → `newText` replacement
33
+ - No special markers needed
34
+
35
+ ### line Mode (Precise Line Operations)
36
+
37
+ **Best for**: Config files, line insertions/deletions, precise line number control
38
+
39
+ ```bash
40
+ # Insert after specific line
41
+ ccw tool exec edit_file '{
42
+ "path": "config.txt",
43
+ "mode": "line",
44
+ "operation": "insert_after",
45
+ "line": 10,
46
+ "text": "new config line"
47
+ }'
48
+
49
+ # Delete line range
50
+ ccw tool exec edit_file '{
51
+ "path": "log.txt",
52
+ "mode": "line",
53
+ "operation": "delete",
54
+ "line": 5,
55
+ "end_line": 8
56
+ }'
57
+
58
+ # Replace specific line
59
+ ccw tool exec edit_file '{
60
+ "path": "script.sh",
61
+ "mode": "line",
62
+ "operation": "replace",
63
+ "line": 3,
64
+ "text": "#!/bin/bash"
65
+ }'
66
+ ```
67
+
68
+ **Operations**:
69
+ - `insert_before`: Insert text before specified line
70
+ - `insert_after`: Insert text after specified line
71
+ - `replace`: Replace line or line range
72
+ - `delete`: Delete line or line range
73
+
74
+ ### Mode Selection Guide
75
+
76
+ | Scenario | Mode | Reason |
77
+ |----------|------|--------|
78
+ | Code refactoring | update | Content-driven replacement |
79
+ | Function rewrite | update | Simple oldText/newText |
80
+ | Config line change | line | Precise line number control |
81
+ | Insert at specific position | line | Exact line number needed |
82
+ | Delete line range | line | Line-based operation |
83
+
84
+ ### Fallback Strategy
85
+
86
+ 1. **Edit fails 1+ times** → Use `ccw tool exec edit_file` (update mode)
87
+ 2. **update mode fails** → Try line mode with precise line numbers
88
+ 3. **All fails** → Use Write to recreate file
89
+
90
+ **Default mode**: update (exact matching with line ending adaptation)
@@ -433,7 +433,7 @@ The `[FLOW_CONTROL]` marker indicates that a task or prompt contains flow contro
433
433
  "step": "load_context",
434
434
  "action": "Load project context and patterns",
435
435
  "commands": [
436
- "bash(~/.claude/scripts/get_modules_by_depth.sh)",
436
+ "bash(ccw tool exec get_modules_by_depth '{}')",
437
437
  "Read(CLAUDE.md)"
438
438
  ],
439
439
  "output_to": "project_structure",
package/ccw/package.json CHANGED
@@ -24,15 +24,15 @@
24
24
  "node": ">=16.0.0"
25
25
  },
26
26
  "dependencies": {
27
- "commander": "^11.0.0",
28
- "open": "^9.1.0",
27
+ "boxen": "^7.1.0",
29
28
  "chalk": "^5.3.0",
29
+ "commander": "^11.0.0",
30
+ "figlet": "^1.7.0",
30
31
  "glob": "^10.3.0",
32
+ "gradient-string": "^2.0.2",
31
33
  "inquirer": "^9.2.0",
32
- "ora": "^7.0.0",
33
- "figlet": "^1.7.0",
34
- "boxen": "^7.1.0",
35
- "gradient-string": "^2.0.2"
34
+ "open": "^9.1.0",
35
+ "ora": "^7.0.0"
36
36
  },
37
37
  "files": [
38
38
  "bin/",
package/ccw/src/cli.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { Command } from 'commander';
2
2
  import { viewCommand } from './commands/view.js';
3
3
  import { serveCommand } from './commands/serve.js';
4
+ import { stopCommand } from './commands/stop.js';
4
5
  import { installCommand } from './commands/install.js';
5
6
  import { uninstallCommand } from './commands/uninstall.js';
6
7
  import { upgradeCommand } from './commands/upgrade.js';
7
8
  import { listCommand } from './commands/list.js';
9
+ import { toolCommand } from './commands/tool.js';
8
10
  import { readFileSync, existsSync } from 'fs';
9
11
  import { fileURLToPath } from 'url';
10
12
  import { dirname, join } from 'path';
@@ -68,6 +70,14 @@ export function run(argv) {
68
70
  .option('--no-browser', 'Start server without opening browser')
69
71
  .action(serveCommand);
70
72
 
73
+ // Stop command
74
+ program
75
+ .command('stop')
76
+ .description('Stop the running CCW dashboard server')
77
+ .option('--port <port>', 'Server port', '3456')
78
+ .option('-f, --force', 'Force kill process on the port')
79
+ .action(stopCommand);
80
+
71
81
  // Install command
72
82
  program
73
83
  .command('install')
@@ -96,5 +106,11 @@ export function run(argv) {
96
106
  .description('List all installed Claude Code Workflow instances')
97
107
  .action(listCommand);
98
108
 
109
+ // Tool command
110
+ program
111
+ .command('tool [subcommand] [args] [json]')
112
+ .description('Execute CCW tools')
113
+ .action((subcommand, args, json) => toolCommand(subcommand, args, { json }));
114
+
99
115
  program.parse(argv);
100
116
  }
@@ -0,0 +1,101 @@
1
+ import chalk from 'chalk';
2
+ import { exec } from 'child_process';
3
+ import { promisify } from 'util';
4
+
5
+ const execAsync = promisify(exec);
6
+
7
+ /**
8
+ * Find process using a specific port (Windows)
9
+ * @param {number} port - Port number
10
+ * @returns {Promise<string|null>} PID or null
11
+ */
12
+ async function findProcessOnPort(port) {
13
+ try {
14
+ const { stdout } = await execAsync(`netstat -ano | findstr :${port} | findstr LISTENING`);
15
+ const lines = stdout.trim().split('\n');
16
+ if (lines.length > 0) {
17
+ const parts = lines[0].trim().split(/\s+/);
18
+ return parts[parts.length - 1]; // PID is the last column
19
+ }
20
+ } catch {
21
+ // No process found
22
+ }
23
+ return null;
24
+ }
25
+
26
+ /**
27
+ * Kill process by PID (Windows)
28
+ * @param {string} pid - Process ID
29
+ * @returns {Promise<boolean>} Success status
30
+ */
31
+ async function killProcess(pid) {
32
+ try {
33
+ await execAsync(`taskkill /PID ${pid} /F`);
34
+ return true;
35
+ } catch {
36
+ return false;
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Stop command handler - stops the running CCW dashboard server
42
+ * @param {Object} options - Command options
43
+ */
44
+ export async function stopCommand(options) {
45
+ const port = options.port || 3456;
46
+ const force = options.force || false;
47
+
48
+ console.log(chalk.blue.bold('\n CCW Dashboard\n'));
49
+ console.log(chalk.gray(` Checking server on port ${port}...`));
50
+
51
+ try {
52
+ // Try graceful shutdown via API first
53
+ const healthCheck = await fetch(`http://localhost:${port}/api/health`, {
54
+ signal: AbortSignal.timeout(2000)
55
+ }).catch(() => null);
56
+
57
+ if (healthCheck && healthCheck.ok) {
58
+ // CCW server is running - send shutdown signal
59
+ console.log(chalk.cyan(' CCW server found, sending shutdown signal...'));
60
+
61
+ await fetch(`http://localhost:${port}/api/shutdown`, {
62
+ method: 'POST',
63
+ signal: AbortSignal.timeout(5000)
64
+ }).catch(() => null);
65
+
66
+ // Wait a moment for shutdown
67
+ await new Promise(resolve => setTimeout(resolve, 500));
68
+
69
+ console.log(chalk.green.bold('\n Server stopped successfully!\n'));
70
+ return;
71
+ }
72
+
73
+ // No CCW server responding, check if port is in use
74
+ const pid = await findProcessOnPort(port);
75
+
76
+ if (!pid) {
77
+ console.log(chalk.yellow(` No server running on port ${port}\n`));
78
+ return;
79
+ }
80
+
81
+ // Port is in use by another process
82
+ console.log(chalk.yellow(` Port ${port} is in use by process PID: ${pid}`));
83
+
84
+ if (force) {
85
+ console.log(chalk.cyan(' Force killing process...'));
86
+ const killed = await killProcess(pid);
87
+
88
+ if (killed) {
89
+ console.log(chalk.green.bold('\n Process killed successfully!\n'));
90
+ } else {
91
+ console.log(chalk.red('\n Failed to kill process. Try running as administrator.\n'));
92
+ }
93
+ } else {
94
+ console.log(chalk.gray(`\n This is not a CCW server. Use --force to kill it:`));
95
+ console.log(chalk.white(` ccw stop --force\n`));
96
+ }
97
+
98
+ } catch (err) {
99
+ console.error(chalk.red(`\n Error: ${err.message}\n`));
100
+ }
101
+ }
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Tool Command - Execute and manage CCW tools
3
+ */
4
+
5
+ import chalk from 'chalk';
6
+ import { listTools, executeTool, getTool, getAllToolSchemas } from '../tools/index.js';
7
+
8
+ /**
9
+ * List all available tools
10
+ */
11
+ async function listAction() {
12
+ const tools = listTools();
13
+
14
+ if (tools.length === 0) {
15
+ console.log(chalk.yellow('No tools registered'));
16
+ return;
17
+ }
18
+
19
+ console.log(chalk.bold.cyan('\nAvailable Tools:\n'));
20
+
21
+ for (const tool of tools) {
22
+ console.log(chalk.bold.white(` ${tool.name}`));
23
+ console.log(chalk.gray(` ${tool.description}`));
24
+
25
+ if (tool.parameters?.properties) {
26
+ const props = tool.parameters.properties;
27
+ const required = tool.parameters.required || [];
28
+
29
+ console.log(chalk.gray(' Parameters:'));
30
+ for (const [name, schema] of Object.entries(props)) {
31
+ const req = required.includes(name) ? chalk.red('*') : '';
32
+ const defaultVal = schema.default !== undefined ? chalk.gray(` (default: ${schema.default})`) : '';
33
+ console.log(chalk.gray(` - ${name}${req}: ${schema.description}${defaultVal}`));
34
+ }
35
+ }
36
+ console.log();
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Show tool schema in MCP-compatible JSON format
42
+ */
43
+ async function schemaAction(options) {
44
+ const { name } = options;
45
+
46
+ if (name) {
47
+ const tool = getTool(name);
48
+ if (!tool) {
49
+ console.error(chalk.red(`Tool not found: ${name}`));
50
+ process.exit(1);
51
+ }
52
+
53
+ const schema = {
54
+ name: tool.name,
55
+ description: tool.description,
56
+ inputSchema: {
57
+ type: 'object',
58
+ properties: tool.parameters?.properties || {},
59
+ required: tool.parameters?.required || []
60
+ }
61
+ };
62
+ console.log(JSON.stringify(schema, null, 2));
63
+ } else {
64
+ const schemas = getAllToolSchemas();
65
+ console.log(JSON.stringify({ tools: schemas }, null, 2));
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Read from stdin if available
71
+ */
72
+ async function readStdin() {
73
+ // Check if stdin is a TTY (interactive terminal)
74
+ if (process.stdin.isTTY) {
75
+ return null;
76
+ }
77
+
78
+ return new Promise((resolve, reject) => {
79
+ let data = '';
80
+
81
+ process.stdin.setEncoding('utf8');
82
+
83
+ process.stdin.on('readable', () => {
84
+ let chunk;
85
+ while ((chunk = process.stdin.read()) !== null) {
86
+ data += chunk;
87
+ }
88
+ });
89
+
90
+ process.stdin.on('end', () => {
91
+ resolve(data.trim() || null);
92
+ });
93
+
94
+ process.stdin.on('error', (err) => {
95
+ reject(err);
96
+ });
97
+ });
98
+ }
99
+
100
+ /**
101
+ * Execute a tool with given parameters
102
+ */
103
+ async function execAction(toolName, jsonInput, options) {
104
+ if (!toolName) {
105
+ console.error(chalk.red('Tool name is required'));
106
+ console.error(chalk.gray('Usage: ccw tool exec <tool-name> \'{"param": "value"}\''));
107
+ process.exit(1);
108
+ }
109
+
110
+ const tool = getTool(toolName);
111
+ if (!tool) {
112
+ console.error(chalk.red(`Tool not found: ${toolName}`));
113
+ console.error(chalk.gray('Use "ccw tool list" to see available tools'));
114
+ process.exit(1);
115
+ }
116
+
117
+ // Parse JSON input (default format)
118
+ let params = {};
119
+
120
+ if (jsonInput) {
121
+ try {
122
+ params = JSON.parse(jsonInput);
123
+ } catch (error) {
124
+ console.error(chalk.red(`Invalid JSON: ${error.message}`));
125
+ process.exit(1);
126
+ }
127
+ }
128
+
129
+ // Check for stdin input (for piped commands)
130
+ const stdinData = await readStdin();
131
+ if (stdinData) {
132
+ // If tool has an 'input' parameter, use it
133
+ // Otherwise, try to parse stdin as JSON and merge with params
134
+ if (tool.parameters?.properties?.input) {
135
+ params.input = stdinData;
136
+ } else {
137
+ try {
138
+ const stdinJson = JSON.parse(stdinData);
139
+ params = { ...stdinJson, ...params };
140
+ } catch {
141
+ // If not JSON, store as 'input' anyway
142
+ params.input = stdinData;
143
+ }
144
+ }
145
+ }
146
+
147
+ // Execute tool
148
+ const result = await executeTool(toolName, params);
149
+
150
+ // Always output JSON
151
+ console.log(JSON.stringify(result, null, 2));
152
+ }
153
+
154
+ /**
155
+ * Tool command entry point
156
+ */
157
+ export async function toolCommand(subcommand, args, options) {
158
+ // Handle subcommands
159
+ switch (subcommand) {
160
+ case 'list':
161
+ await listAction();
162
+ break;
163
+ case 'schema':
164
+ await schemaAction({ name: args });
165
+ break;
166
+ case 'exec':
167
+ await execAction(args, options.json, options);
168
+ break;
169
+ default:
170
+ console.log(chalk.bold.cyan('\nCCW Tool System\n'));
171
+ console.log('Subcommands:');
172
+ console.log(chalk.gray(' list List all available tools'));
173
+ console.log(chalk.gray(' schema [name] Show tool schema (JSON)'));
174
+ console.log(chalk.gray(' exec <name> Execute a tool'));
175
+ console.log();
176
+ console.log('Examples:');
177
+ console.log(chalk.gray(' ccw tool list'));
178
+ console.log(chalk.gray(' ccw tool schema edit_file'));
179
+ console.log(chalk.gray(' ccw tool exec edit_file \'{"path":"file.txt","oldText":"old","newText":"new"}\''));
180
+ }
181
+ }