Skip to content

Commit 7771344

Browse files
dhaneshclaude
andcommitted
feat(parallel): integrate auto-suggester hook with m4-generate
- Add parallel execution integration section to m4-generate.md - Add parallelization check as step 5 in execution instructions - Add user approval prompt template for parallel generation - Add validation function to install.sh with --validate flag - Validation checks: skill file, 9 commands, 11 lib files, 2 hooks - Auto-validation runs after installation completes - Document iteration 9 in parallel-agents manifold Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e4e492b commit 7771344

3 files changed

Lines changed: 223 additions & 6 deletions

File tree

.manifold/parallel-agents.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,23 @@ iterations:
414414
file_count: 13
415415
result: "distributable"
416416

417+
- number: 9
418+
phase: "hook-integration"
419+
timestamp: "2026-01-16T12:00:00Z"
420+
issue: "Parallel execution hooks not being invoked during /m4-generate"
421+
changes:
422+
- "Added 'Parallel Execution Integration' section to m4-generate.md"
423+
- "Added parallelization check as step 5 in execution instructions"
424+
- "Added user approval prompt template for parallel generation"
425+
- "Added validation function to install.sh (--validate flag)"
426+
- "Validation checks: skill file, 9 commands, 11 library files, 2 hooks"
427+
validation_added:
428+
- "validate_installation() function for per-agent validation"
429+
- "run_validation() function for all-agents validation"
430+
- "install.sh --validate flag for standalone validation"
431+
- "Auto-validation after installation completes"
432+
result: "integrated"
433+
417434
generation:
418435
option: "D"
419436
timestamp: "2026-01-16T10:15:00Z"

install/commands/m4-generate.md

Lines changed: 98 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,110 @@ After generation, verify:
165165
- [ ] Install script includes new command files
166166
- [ ] Hooks are in `install/hooks/` if they need distribution
167167

168+
## Parallel Execution Integration
169+
170+
**IMPORTANT**: Before generating artifacts, check for parallelization opportunities.
171+
172+
### Parallelization Check
173+
174+
When the generation plan includes **3+ independent artifact groups**, invoke the parallel execution system:
175+
176+
1. **Analyze Artifact Groups**
177+
- Code files (can be generated in parallel across modules)
178+
- Test files (depend on code, but tests for different modules can parallelize)
179+
- Documentation (independent, can parallelize)
180+
- Operational artifacts (runbooks, dashboards, alerts - independent)
181+
182+
2. **Invoke Auto-Suggester**
183+
```typescript
184+
// The auto-suggester at ~/.claude/hooks/auto-suggester.ts analyzes tasks
185+
// Import and use when parallelization is beneficial:
186+
import { AutoSuggester } from '~/.claude/lib/parallel/index';
187+
188+
const suggester = new AutoSuggester(process.cwd());
189+
const tasks = [
190+
"Generate PaymentRetryClient.ts with error classification",
191+
"Generate PaymentRetryQueue.ts with durable queue logic",
192+
"Generate IdempotencyService.ts with duplicate prevention",
193+
"Generate all test files for retry module",
194+
"Generate documentation for payment-retry feature"
195+
];
196+
197+
const suggestion = await suggester.suggest(tasks);
198+
if (suggestion.shouldParallelize) {
199+
// Display suggestion to user
200+
console.log(suggester.formatSuggestion(suggestion));
201+
}
202+
```
203+
204+
3. **User Approval Prompt**
205+
When parallelization is suggested, display:
206+
```
207+
PARALLEL EXECUTION OPPORTUNITY DETECTED
208+
209+
The following artifact groups can be generated in parallel:
210+
211+
Group 1: Code Implementation
212+
- PaymentRetryClient.ts
213+
- PaymentRetryQueue.ts
214+
- IdempotencyService.ts
215+
- CircuitBreaker.ts
216+
217+
Group 2: Test Files
218+
- PaymentRetryClient.test.ts
219+
- IdempotencyService.test.ts
220+
- integration.test.ts
221+
222+
Group 3: Documentation & Ops
223+
- README.md, API.md, DECISIONS.md
224+
- Runbooks, Dashboards, Alerts
225+
226+
Estimated speedup: 2.5x
227+
Confidence: 85%
228+
229+
Would you like to generate artifacts in parallel using git worktrees?
230+
[Y]es / [N]o / [D]etails
231+
```
232+
233+
4. **If Approved**: Use `/parallel` command to execute generation in isolated worktrees
234+
5. **If Declined**: Proceed with sequential generation
235+
236+
### Parallel Generation Flow
237+
238+
```
239+
User runs: /m4-generate payment-retry --option=C
240+
241+
1. Parse manifold and anchoring
242+
2. Build artifact generation plan
243+
3. Analyze for parallelization (≥3 independent groups?)
244+
└── YES: Invoke auto-suggester
245+
└── Suggestion positive?
246+
└── YES: Prompt user for approval
247+
└── Approved: Use /parallel for generation
248+
└── Declined: Sequential generation
249+
└── NO: Sequential generation
250+
└── NO: Sequential generation
251+
4. Generate artifacts (parallel or sequential)
252+
5. Merge results and update manifold
253+
```
254+
168255
## Execution Instructions
169256
170257
1. Read manifold from `.manifold/<feature>.yaml`
171258
2. Read anchoring from `.manifold/<feature>.anchor.yaml`
172259
3. Select solution option (from `--option` or prompt user)
173260
4. **CHECK PROJECT PATTERNS** - Examine existing structure before placing files
174-
5. For each artifact type:
261+
5. **PARALLELIZATION CHECK** - Analyze artifacts for parallel generation opportunity
262+
- If ≥3 independent artifact groups detected
263+
- Run auto-suggester analysis
264+
- Prompt user: "Parallel generation detected (Xfiles, Yx speedup). Enable? [Y/N]"
265+
- If approved, use `/parallel` command with artifact tasks
266+
6. For each artifact type:
175267
- Generate artifact with constraint traceability
176268
- Add comments linking to constraint IDs: `// Satisfies: B1, T2`
177269
- **Place in correct directory per Artifact Placement Rules**
178-
6. Create all files in appropriate directories
179-
7. **Update install script** if adding new distributable commands
180-
8. **Update manifold YAML** with generation tracking (artifacts, coverage)
181-
9. Set phase to GENERATED
182-
10. Display summary with constraint coverage
270+
7. Create all files in appropriate directories
271+
8. **Update install script** if adding new distributable commands
272+
9. **Update manifold YAML** with generation tracking (artifacts, coverage)
273+
10. Set phase to GENERATED
274+
11. Display summary with constraint coverage

install/install.sh

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,118 @@ main() {
343343
echo ""
344344
}
345345

346+
# Validate installation
347+
validate_installation() {
348+
local base_dir="$1"
349+
local agent_name="$2"
350+
local errors=0
351+
352+
echo ""
353+
print_step "Validating $agent_name installation..."
354+
355+
# Check skill file
356+
if [[ ! -f "$base_dir/skills/manifold/SKILL.md" ]]; then
357+
print_error "Missing: skills/manifold/SKILL.md"
358+
((errors++))
359+
else
360+
print_success "Found: skills/manifold/SKILL.md"
361+
fi
362+
363+
# Check command files
364+
for cmd_file in "${COMMAND_FILES[@]}"; do
365+
if [[ ! -f "$base_dir/commands/$cmd_file" ]]; then
366+
print_error "Missing: commands/$cmd_file"
367+
((errors++))
368+
else
369+
print_success "Found: commands/$cmd_file"
370+
fi
371+
done
372+
373+
# Check parallel library files
374+
for lib_file in "${PARALLEL_LIB_FILES[@]}"; do
375+
if [[ ! -f "$base_dir/lib/parallel/$lib_file" ]]; then
376+
print_error "Missing: lib/parallel/$lib_file"
377+
((errors++))
378+
else
379+
print_success "Found: lib/parallel/$lib_file"
380+
fi
381+
done
382+
383+
# Check hooks
384+
local hooks=("manifold-context.ts" "auto-suggester.ts")
385+
for hook_file in "${hooks[@]}"; do
386+
if [[ ! -f "$base_dir/hooks/$hook_file" ]]; then
387+
print_error "Missing: hooks/$hook_file"
388+
((errors++))
389+
else
390+
print_success "Found: hooks/$hook_file"
391+
fi
392+
done
393+
394+
# Summary
395+
echo ""
396+
if [[ $errors -eq 0 ]]; then
397+
print_success "$agent_name installation validated: All files present"
398+
return 0
399+
else
400+
print_error "$agent_name installation has $errors missing file(s)"
401+
return 1
402+
fi
403+
}
404+
405+
# Run validation for all detected agents
406+
run_validation() {
407+
local validated=0
408+
local failed=0
409+
410+
echo ""
411+
echo -e "${CYAN}╔════════════════════════════════════════════════════════╗${NC}"
412+
echo -e "${CYAN}${NC} ${BOLD}Manifold Installation Validation${NC} ${CYAN}${NC}"
413+
echo -e "${CYAN}╚════════════════════════════════════════════════════════╝${NC}"
414+
echo ""
415+
416+
# Validate Claude Code
417+
if [[ -d "$HOME/.claude" ]]; then
418+
if validate_installation "$HOME/.claude" "Claude Code"; then
419+
((validated++))
420+
else
421+
((failed++))
422+
fi
423+
fi
424+
425+
# Validate AMP
426+
if [[ -d "$HOME/.amp" ]]; then
427+
if validate_installation "$HOME/.amp" "AMP"; then
428+
((validated++))
429+
else
430+
((failed++))
431+
fi
432+
fi
433+
434+
echo ""
435+
echo -e "${GREEN}════════════════════════════════════════════════════════${NC}"
436+
if [[ $failed -eq 0 ]]; then
437+
echo -e "${GREEN} Validation complete: $validated agent(s) verified${NC}"
438+
else
439+
echo -e "${YELLOW} Validation complete: $validated passed, $failed failed${NC}"
440+
fi
441+
echo -e "${GREEN}════════════════════════════════════════════════════════${NC}"
442+
echo ""
443+
}
444+
346445
# Handle local install mode
347446
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
348447
if [[ -f "$SCRIPT_DIR/manifold/SKILL.md" && -d "$SCRIPT_DIR/commands" ]]; then
349448
LOCAL_INSTALL=1
350449
fi
351450

451+
# Check for validation flag
452+
if [[ "$1" == "--validate" || "$1" == "-v" ]]; then
453+
run_validation
454+
exit 0
455+
fi
456+
352457
main "$@"
458+
459+
# Run validation after installation
460+
run_validation

0 commit comments

Comments
 (0)