@lumenflow/cli 2.6.0 → 2.8.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 (88) hide show
  1. package/README.md +120 -105
  2. package/dist/__tests__/agent-spawn-coordination.test.js +451 -0
  3. package/dist/__tests__/commands/integrate.test.js +165 -0
  4. package/dist/__tests__/gates-config.test.js +0 -1
  5. package/dist/__tests__/hooks/enforcement.test.js +279 -0
  6. package/dist/__tests__/init-greenfield.test.js +247 -0
  7. package/dist/__tests__/init-quick-ref.test.js +0 -1
  8. package/dist/__tests__/init-template-portability.test.js +0 -1
  9. package/dist/__tests__/init.test.js +27 -0
  10. package/dist/__tests__/initiative-e2e.test.js +442 -0
  11. package/dist/__tests__/initiative-plan-replacement.test.js +0 -1
  12. package/dist/__tests__/memory-integration.test.js +333 -0
  13. package/dist/__tests__/release.test.js +1 -1
  14. package/dist/__tests__/safe-git.test.js +0 -1
  15. package/dist/__tests__/state-doctor.test.js +54 -0
  16. package/dist/__tests__/sync-templates.test.js +255 -0
  17. package/dist/__tests__/wu-create-required-fields.test.js +121 -0
  18. package/dist/__tests__/wu-done-auto-cleanup.test.js +135 -0
  19. package/dist/__tests__/wu-lifecycle-integration.test.js +388 -0
  20. package/dist/__tests__/wu-proto.test.js +97 -0
  21. package/dist/backlog-prune.js +0 -1
  22. package/dist/cli-entry-point.js +0 -1
  23. package/dist/commands/integrate.js +229 -0
  24. package/dist/docs-sync.js +46 -0
  25. package/dist/doctor.js +0 -2
  26. package/dist/gates.js +0 -7
  27. package/dist/hooks/enforcement-checks.js +209 -0
  28. package/dist/hooks/enforcement-generator.js +365 -0
  29. package/dist/hooks/enforcement-sync.js +243 -0
  30. package/dist/hooks/index.js +7 -0
  31. package/dist/init.js +266 -11
  32. package/dist/initiative-add-wu.js +0 -2
  33. package/dist/initiative-create.js +0 -3
  34. package/dist/initiative-edit.js +0 -5
  35. package/dist/initiative-plan.js +0 -1
  36. package/dist/initiative-remove-wu.js +0 -2
  37. package/dist/lane-health.js +0 -2
  38. package/dist/lane-suggest.js +0 -1
  39. package/dist/mem-checkpoint.js +0 -2
  40. package/dist/mem-cleanup.js +0 -2
  41. package/dist/mem-context.js +0 -3
  42. package/dist/mem-create.js +0 -2
  43. package/dist/mem-delete.js +0 -3
  44. package/dist/mem-inbox.js +0 -2
  45. package/dist/mem-index.js +0 -1
  46. package/dist/mem-init.js +0 -2
  47. package/dist/mem-profile.js +0 -1
  48. package/dist/mem-promote.js +0 -1
  49. package/dist/mem-ready.js +0 -2
  50. package/dist/mem-signal.js +0 -2
  51. package/dist/mem-start.js +0 -2
  52. package/dist/mem-summarize.js +0 -2
  53. package/dist/metrics-cli.js +1 -1
  54. package/dist/metrics-snapshot.js +1 -1
  55. package/dist/onboarding-smoke-test.js +0 -5
  56. package/dist/orchestrate-init-status.js +0 -1
  57. package/dist/orchestrate-initiative.js +0 -1
  58. package/dist/orchestrate-monitor.js +0 -1
  59. package/dist/plan-create.js +0 -2
  60. package/dist/plan-edit.js +0 -2
  61. package/dist/plan-link.js +0 -2
  62. package/dist/plan-promote.js +0 -2
  63. package/dist/signal-cleanup.js +0 -4
  64. package/dist/state-bootstrap.js +0 -1
  65. package/dist/state-cleanup.js +0 -4
  66. package/dist/state-doctor-fix.js +5 -8
  67. package/dist/state-doctor.js +0 -11
  68. package/dist/sync-templates.js +188 -34
  69. package/dist/wu-block.js +100 -48
  70. package/dist/wu-claim.js +1 -22
  71. package/dist/wu-cleanup.js +0 -1
  72. package/dist/wu-create.js +0 -2
  73. package/dist/wu-done-auto-cleanup.js +139 -0
  74. package/dist/wu-done.js +11 -4
  75. package/dist/wu-edit.js +0 -12
  76. package/dist/wu-preflight.js +0 -1
  77. package/dist/wu-prep.js +0 -1
  78. package/dist/wu-proto.js +329 -0
  79. package/dist/wu-spawn.js +0 -3
  80. package/dist/wu-unblock.js +0 -2
  81. package/dist/wu-validate.js +0 -1
  82. package/package.json +9 -7
  83. package/templates/core/.husky/pre-commit.template +93 -0
  84. package/templates/core/ai/onboarding/quick-ref-commands.md.template +27 -0
  85. package/templates/core/ai/onboarding/rapid-prototyping.md +143 -0
  86. package/templates/core/ai/onboarding/starting-prompt.md.template +3 -3
  87. package/templates/vendors/claude/.claude/CLAUDE.md.template +25 -0
  88. package/templates/vendors/claude/.claude/hooks/enforce-worktree.sh +135 -0
@@ -0,0 +1,143 @@
1
+ # Rapid Prototyping with LumenFlow
2
+
3
+ **Last updated:** {{DATE}}
4
+
5
+ This guide explains how to move fast WITHIN the LumenFlow workflow, not by bypassing it.
6
+
7
+ ---
8
+
9
+ ## The Wrong Way: Skipping the Workflow
10
+
11
+ When asked to "prototype quickly" or "just get something working," agents often:
12
+
13
+ 1. Skip WU creation ("let's just commit directly")
14
+ 2. Work on main branch ("worktrees slow us down")
15
+ 3. Skip tests ("we'll add them later")
16
+ 4. Bypass gates ("pre-commit hooks are annoying")
17
+
18
+ **This creates technical debt, breaks workflow tracking, and causes merge conflicts.**
19
+
20
+ ---
21
+
22
+ ## The Right Way: Speed Through Parallelism
23
+
24
+ LumenFlow enables speed through **parallel WUs across lanes**, not by skipping steps.
25
+
26
+ ### Speed Strategy 1: Multiple Small WUs
27
+
28
+ Instead of one large WU, create multiple focused WUs:
29
+
30
+ ```bash
31
+ # SLOW: One massive WU
32
+ pnpm wu:create --lane "Framework: Core" --title "Build entire auth system"
33
+ # Takes 4 hours, blocks the lane
34
+
35
+ # FAST: Multiple parallel WUs
36
+ pnpm wu:create --lane "Framework: Core" --title "Add user model"
37
+ pnpm wu:create --lane "Framework: API" --title "Add auth endpoints"
38
+ pnpm wu:create --lane "Experience: UI" --title "Add login form"
39
+ # Each takes 1 hour, run in parallel across 3 lanes
40
+ ```
41
+
42
+ ### Speed Strategy 2: Spawn Sub-Agents
43
+
44
+ For complex work, spawn sub-agents to work in parallel:
45
+
46
+ ```bash
47
+ # Generate spawn prompt for parallel agent
48
+ pnpm wu:spawn --id WU-123 --client claude-code
49
+ ```
50
+
51
+ Sub-agents work on different aspects simultaneously:
52
+
53
+ - Agent 1: Core business logic
54
+ - Agent 2: API endpoints
55
+ - Agent 3: UI components
56
+ - Agent 4: Tests
57
+
58
+ ### Speed Strategy 3: Wave-Based Execution
59
+
60
+ Orchestrate initiatives in waves:
61
+
62
+ ```bash
63
+ # View what can run in parallel
64
+ pnpm orchestrate:init-status --id INIT-001
65
+
66
+ # Spawn wave of WUs
67
+ pnpm orchestrate:initiative --id INIT-001 --wave 1
68
+ ```
69
+
70
+ ### Speed Strategy 4: Docs-Only Fast Path
71
+
72
+ For documentation changes, use the fast path:
73
+
74
+ ```bash
75
+ # Skip lint/typecheck/tests for docs
76
+ pnpm gates --docs-only
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Time Comparison
82
+
83
+ | Approach | Perceived Speed | Actual Time | Technical Debt |
84
+ | --------------- | --------------- | ----------------------- | -------------- |
85
+ | Skip workflow | "Instant" | +2h later fixing issues | High |
86
+ | Single large WU | Slow | 4h blocked | Low |
87
+ | Parallel WUs | Fast | 1h each, parallel | None |
88
+
89
+ ---
90
+
91
+ ## Quick Reference: Fast But Safe
92
+
93
+ ```bash
94
+ # Fast: Create focused WU
95
+ pnpm wu:create --lane "Framework: Core" --title "Specific task"
96
+
97
+ # Fast: Claim and work
98
+ pnpm wu:claim --id WU-XXX --lane "Framework: Core"
99
+ cd worktrees/framework-core-wu-xxx
100
+
101
+ # Fast: Minimal viable implementation
102
+ # Write ONE test, implement, pass
103
+
104
+ # Fast: Complete
105
+ pnpm wu:prep --id WU-XXX
106
+ cd /path/to/main && pnpm wu:done --id WU-XXX
107
+ ```
108
+
109
+ ---
110
+
111
+ ## What to Say When Asked to "Skip the Workflow"
112
+
113
+ When a user says "just prototype this quickly":
114
+
115
+ 1. **Acknowledge the urgency**: "I understand you want this fast."
116
+ 2. **Explain the approach**: "I'll create focused WUs that can run in parallel."
117
+ 3. **Deliver value quickly**: "Here's the first deliverable in 30 minutes."
118
+
119
+ **Never say**: "Let me skip the workflow to save time."
120
+
121
+ ---
122
+
123
+ ## Anti-Patterns to Avoid
124
+
125
+ | Anti-Pattern | Why It's Slow | Better Alternative |
126
+ | ---------------------- | ----------------------------- | ----------------------- |
127
+ | Direct commits to main | Merge conflicts, broken gates | Use worktrees |
128
+ | One massive WU | Blocks lane for hours | Split into parallel WUs |
129
+ | Skip tests | Bugs found late, rework | TDD from start |
130
+ | "We'll document later" | Context lost, debt | Capture as you go |
131
+
132
+ ---
133
+
134
+ ## Summary
135
+
136
+ **Speed in LumenFlow comes from parallelism, not shortcuts.**
137
+
138
+ - Multiple small WUs across lanes
139
+ - Sub-agents for complex work
140
+ - Wave-based orchestration
141
+ - Docs-only fast path when applicable
142
+
143
+ The workflow exists to prevent the slowdowns that come from technical debt, merge conflicts, and broken builds.
@@ -10,7 +10,7 @@ This is the complete onboarding document for AI agents working with LumenFlow. R
10
10
 
11
11
  ```bash
12
12
  # 1. Check your assigned WU
13
- cat docs/04-operations/tasks/wu/WU-XXXX.yaml
13
+ cat {{DOCS_TASKS_PATH}}/wu/WU-XXXX.yaml
14
14
 
15
15
  # 2. Claim the WU (creates isolated worktree)
16
16
  pnpm wu:claim --id WU-XXXX --lane "Lane Name"
@@ -160,7 +160,7 @@ git add . && git commit -m "your message"
160
160
  **Fix:** Regenerate the backlog or manually add the missing WU:
161
161
 
162
162
  ```bash
163
- # In worktree, edit docs/04-operations/tasks/backlog.md
163
+ # In worktree, edit {{DOCS_TASKS_PATH}}/backlog.md
164
164
  # Add the missing WU reference in the appropriate section
165
165
  ```
166
166
 
@@ -266,7 +266,7 @@ pnpm wu:spawn --id WU-XXXX --client <client-type>
266
266
 
267
267
  ```
268
268
  /path/to/repo/
269
- ├── docs/04-operations/tasks/
269
+ ├── {{DOCS_TASKS_PATH}}/
270
270
  │ ├── backlog.md # All WUs listed here
271
271
  │ └── wu/WU-XXXX.yaml # Individual WU specs
272
272
  ├── worktrees/
@@ -36,6 +36,31 @@ See [LUMENFLOW.md](../LUMENFLOW.md) and [ai/onboarding/troubleshooting-wu-done.m
36
36
 
37
37
  ---
38
38
 
39
+ ## Orchestration & Memory Commands
40
+
41
+ Essential commands for multi-agent coordination and context management:
42
+
43
+ | Command | Description |
44
+ | ------------------------------------------ | --------------------------------- |
45
+ | `pnpm orchestrate:init-status -i INIT-XXX` | View initiative progress |
46
+ | `pnpm orchestrate:monitor` | Monitor spawn/agent activity |
47
+ | `pnpm mem:checkpoint --wu WU-XXX` | Save progress checkpoint |
48
+ | `pnpm mem:inbox --since 30m` | Check coordination signals |
49
+ | `pnpm mem:signal "msg" --wu WU-XXX` | Broadcast signal to other agents |
50
+ | `pnpm mem:create "msg" --wu WU-XXX` | Create memory node (bug capture) |
51
+ | `pnpm wu:spawn --id WU-XXX --client claude-code` | Spawn sub-agent prompt |
52
+
53
+ **When to checkpoint:**
54
+ - After each acceptance criterion completed
55
+ - Before running gates
56
+ - Every 30+ tool calls
57
+
58
+ **When to check inbox:**
59
+ - Before starting complex work (parallel agents may have signals)
60
+ - When blocked (other agents may have completed dependencies)
61
+
62
+ ---
63
+
39
64
  ## Claude-Specific Settings
40
65
 
41
66
  This directory contains Claude Code-specific configuration:
@@ -0,0 +1,135 @@
1
+ #!/bin/bash
2
+ #
3
+ # enforce-worktree.sh
4
+ #
5
+ # Claude PreToolUse hook that blocks Write/Edit operations on main branch.
6
+ #
7
+ # This hook enforces worktree discipline for Claude Code specifically,
8
+ # complementing the git pre-commit hook for stronger enforcement.
9
+ #
10
+ # Exit codes:
11
+ # 0 = Allow operation
12
+ # 2 = Block operation (stderr shown to Claude as guidance)
13
+ #
14
+ # Security: Fail-open design for this hook (branches can't always be detected)
15
+ # - If branch detection fails, allow operation (git hooks will catch it)
16
+ # - If JSON parse fails, allow operation (defensive, log warning)
17
+ #
18
+ # Blocking conditions:
19
+ # - Current branch is main or master
20
+ # - Tool is Write or Edit
21
+ # - Target file is in the main repo (not a worktree)
22
+ #
23
+
24
+ set -euo pipefail
25
+
26
+ # Derive repo paths from CLAUDE_PROJECT_DIR
27
+ if [[ -n "${CLAUDE_PROJECT_DIR:-}" ]]; then
28
+ MAIN_REPO_PATH="$CLAUDE_PROJECT_DIR"
29
+ else
30
+ MAIN_REPO_PATH=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
31
+ if [[ -z "$MAIN_REPO_PATH" ]]; then
32
+ # Not in a git repo - allow operation
33
+ exit 0
34
+ fi
35
+ fi
36
+
37
+ # Check if we're on main/master branch
38
+ CURRENT_BRANCH=$(git -C "$MAIN_REPO_PATH" rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
39
+
40
+ # If branch detection fails, fail-open (git hooks will catch issues)
41
+ if [[ -z "$CURRENT_BRANCH" ]]; then
42
+ exit 0
43
+ fi
44
+
45
+ # Allow operations on non-main branches
46
+ case "$CURRENT_BRANCH" in
47
+ main|master)
48
+ # Continue to check tool type
49
+ ;;
50
+ *)
51
+ # Not on main/master - allow
52
+ exit 0
53
+ ;;
54
+ esac
55
+
56
+ # Read JSON input from stdin
57
+ INPUT=$(cat)
58
+
59
+ # If no input, fail-open (defensive)
60
+ if [[ -z "$INPUT" ]]; then
61
+ exit 0
62
+ fi
63
+
64
+ # Parse JSON with Python to extract tool_name and file_path
65
+ PARSE_RESULT=$(python3 -c "
66
+ import json
67
+ import sys
68
+ try:
69
+ data = json.loads('''$INPUT''')
70
+ tool_name = data.get('tool_name', '')
71
+ tool_input = data.get('tool_input', {})
72
+ if not isinstance(tool_input, dict):
73
+ tool_input = {}
74
+ file_path = tool_input.get('file_path', '')
75
+ print('OK')
76
+ print(tool_name if tool_name else '')
77
+ print(file_path if file_path else '')
78
+ except Exception as e:
79
+ print('ERROR')
80
+ print(str(e))
81
+ print('')
82
+ " 2>&1)
83
+
84
+ # Parse the result
85
+ PARSE_STATUS=$(echo "$PARSE_RESULT" | head -1)
86
+ TOOL_NAME=$(echo "$PARSE_RESULT" | sed -n '2p')
87
+ FILE_PATH=$(echo "$PARSE_RESULT" | sed -n '3p')
88
+
89
+ # If parse failed, fail-open (defensive)
90
+ if [[ "$PARSE_STATUS" != "OK" ]]; then
91
+ exit 0
92
+ fi
93
+
94
+ # Only block Write and Edit tools
95
+ if [[ "$TOOL_NAME" != "Write" && "$TOOL_NAME" != "Edit" ]]; then
96
+ exit 0
97
+ fi
98
+
99
+ # Check if file path is in a worktree (allowed) or main repo (blocked)
100
+ WORKTREES_DIR="${MAIN_REPO_PATH}/worktrees"
101
+
102
+ if [[ -n "$FILE_PATH" ]]; then
103
+ RESOLVED_PATH=$(realpath -m "$FILE_PATH" 2>/dev/null || echo "$FILE_PATH")
104
+
105
+ # Allow if path is inside a worktree
106
+ if [[ "$RESOLVED_PATH" == "${WORKTREES_DIR}/"* ]]; then
107
+ exit 0
108
+ fi
109
+ fi
110
+
111
+ # Block: We're on main/master and trying to Write/Edit outside a worktree
112
+ echo "" >&2
113
+ echo "=== LumenFlow Worktree Enforcement ===" >&2
114
+ echo "" >&2
115
+ echo "BLOCKED: ${TOOL_NAME} operation on main branch" >&2
116
+ echo "" >&2
117
+ echo "You are on the '${CURRENT_BRANCH}' branch. Direct edits to main are not allowed." >&2
118
+ echo "" >&2
119
+ echo "WHAT TO DO:" >&2
120
+ echo " 1. Claim a WU to create a worktree:" >&2
121
+ echo " pnpm wu:claim --id WU-XXXX --lane \"<Lane>\"" >&2
122
+ echo "" >&2
123
+ echo " 2. Move to the worktree:" >&2
124
+ echo " cd worktrees/<lane>-wu-xxxx" >&2
125
+ echo "" >&2
126
+ echo " 3. Make your edits in the worktree" >&2
127
+ echo "" >&2
128
+ echo "WHY THIS MATTERS:" >&2
129
+ echo " - Worktrees isolate your changes from other work" >&2
130
+ echo " - All changes are tracked through the WU workflow" >&2
131
+ echo " - Parallel work across lanes stays independent" >&2
132
+ echo "" >&2
133
+ echo "See: LUMENFLOW.md for complete workflow documentation" >&2
134
+ echo "========================================" >&2
135
+ exit 2