Skip to content

Commit c4d3ff0

Browse files
committed
fix: move mode into spec level
1 parent bf0a940 commit c4d3ff0

18 files changed

Lines changed: 685 additions & 69 deletions

.implementation-notes.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Per-Spec Mode Implementation Notes
2+
3+
## Status: Phase 2 In Progress
4+
5+
### Completed (Phase 1):
6+
- ✅ Created detect-workflow-config.sh and .ps1
7+
- ✅ Exported to common.sh/ps1
8+
- ✅ All tests passing
9+
10+
### Completed (Phase 2 Partial):
11+
- ✅ Updated /specify template with parameters
12+
- ✅ Updated spec-template.md and spec-template-build.md with metadata
13+
- ✅ Added parameter parsing to create-new-feature.sh
14+
15+
### In Progress:
16+
- 🔄 Complete create-new-feature.sh (lines 331-380 need mode variable substitution)
17+
- 🔄 Update /architect to accept --mode parameters
18+
- 🔄 Update /plan, /tasks, /implement to auto-detect from spec.md
19+
20+
### Remaining:
21+
- Update create-new-feature.ps1
22+
- Remove /mode command
23+
- Update config.json schema
24+
- Documentation updates
25+
- End-to-end testing
26+
27+
## Key Design Decision:
28+
- `/specify` and `/architect` → Accept mode parameters (CREATE documents)
29+
- `/plan`, `/tasks`, `/implement` → Auto-detect from spec.md (READ mode)
30+
- No redundant mode parameters in downstream commands

roadmap.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,106 @@ Consolidates: Command-level model selection + context budgeting + two-model revi
503503

504504
## 🚀 **NEXT PHASE** (Deferred - Complete After Current Phase)
505505

506+
### **Worktrunk-Integrated Parallel Execution with Dependency-Aware Orchestration** *(0% Complete)* - **HIGH PRIORITY** - Incident.io workflow pattern enabling 5+ agents in parallel with git worktree isolation
507+
508+
**Purpose**: Enable safe parallel execution of SYNC/ASYNC tasks with explicit dependency tracking and phase-respecting orchestration. Validates the incident.io pattern (multiple agents, branch isolation, clean merge workflow) using Worktrunk as optional infrastructure for parallel development.
509+
510+
**Design Foundation** (locked design from validated patterns):
511+
512+
| Aspect | Decision | Validation |
513+
|--------|----------|-----------|
514+
| Branch Structure | Hierarchical: `feature/spec-name/task-NNN-description-[sync\|async]` | Nests task branches under spec branch from `/specify`; prevents collision |
515+
| Dependencies | Explicit in tasks.md: `depends: [T001, T002]` | Human-writable during `/plan`; pre-merge hooks validate; enables sophisticated scheduling |
516+
| Phase Ordering | Enforce phase boundaries; parallelize `[P]` within phase | Setup → Foundational → Stories; respects internal dependencies |
517+
| Unmet Dependencies | Skip task with warning; don't block phase | Graceful degradation; visibility into blocking tasks |
518+
| Worktree Isolation | Optional (Worktrunk); sequential fallback | Enables incident.io pattern; functional without worktrees |
519+
| Worktree Paths | Full hierarchical: `repo.feature.spec-name.task-NNN-desc` | Fully qualified; prevents collision across features |
520+
521+
**Implementation Roadmap** (5 Phases, 10 Weeks):
522+
523+
##### Phase 1: Dependency Model & Parsing (Weeks 1-2)
524+
- [ ] Update `templates/tasks-template.md` with `depends: [T001, T002]` syntax + examples
525+
- [ ] Create `scripts/bash/parse-dependencies.sh` with DAG validation (cycles, cross-phase violations, missing refs)
526+
- [ ] Create PowerShell equivalent: `scripts/powershell/Parse-Dependencies.ps1`
527+
- [ ] Update `/tasks` template to emit dependency syntax
528+
- [ ] Update `docs/triage-framework.md` with dependency declaration guidance
529+
530+
**Testing**: Sample tasks.md with 10+ tasks across 3 phases; verify DAG validation
531+
532+
##### Phase 2: Phase-Aware Orchestration (Weeks 3-4)
533+
- [ ] Create `scripts/bash/orchestrate-tasks.sh` with phase-sequential + [P] parallelization logic
534+
- [ ] Create PowerShell equivalent: `scripts/powershell/Orchestrate-Tasks.ps1`
535+
- [ ] Extend `/implement` template to call orchestration logic
536+
- [ ] Add phase-aware progress reporting ("Phase 1/3: 2/3 tasks complete")
537+
538+
**Testing**: Full workflow on test project with 10+ tasks; verify sequential Setup, parallel Foundational
539+
540+
##### Phase 3: Worktrunk Integration (Optional) (Weeks 5-6)
541+
- [ ] Create `scripts/bash/spawn-task-worktree.sh` with worktree creation + branch hierarchy
542+
- [ ] Create PowerShell equivalent: `scripts/powershell/Spawn-TaskWorktree.ps1`
543+
- [ ] Generate `.config/wt.toml` template with pre-merge dependency validation hooks
544+
- [ ] Extend `/implement` to detect Worktrunk + choose execution path
545+
- [ ] Add `--enable-worktrunk`, `--prefer-worktrunk` (default), `--no-worktrunk` flags
546+
547+
**Testing**: Run with Worktrunk available and without; verify isolation and fallback
548+
549+
##### Phase 4: Remote Async Agent Integration (Weeks 7-8) *(Tier 1.3 + 1.4 enablement)*
550+
- [ ] Extend `dispatch_async_task()` to include worktree branch SHA + path (if available)
551+
- [ ] Create `scripts/bash/package-task-context.sh` bundling spec, plan, research, task spec
552+
- [ ] Update delegation template with task dependency metadata
553+
- [ ] Extend `tasks-meta-utils.sh` to track async task status from remote agents
554+
555+
**Testing**: Delegate ASYNC task with full worktree context; verify agent receives branch info
556+
557+
##### Phase 5: Monitoring & Documentation (Weeks 9-10)
558+
- [ ] Create monitoring dashboard script: `scripts/bash/monitor-parallel-tasks.sh`
559+
- [ ] Update `/implement` output to show phase progress, pending dependencies, agent status
560+
- [ ] Create comprehensive guide: `docs/parallel-execution-guide.md`
561+
- [ ] Create end-to-end integration test: `test-parallel-execution.sh`
562+
563+
**Testing**: Complete workflow with 3 phases, mixed SYNC/ASYNC, dependencies; verify monitoring
564+
565+
**Integration with Existing Framework**:
566+
567+
- **Enhances [P] Markers** (line 56-61): Existing `[P]` parallelization now coordinated via Worktrunk worktrees (incident.io pattern)
568+
- **Orchestrates SYNC/ASYNC** (line 72-80): Dependency-aware scheduling enables safe parallel execution of mixed SYNC/ASYNC tasks
569+
- **Prerequisite for Tier 1.3** (line 323-328): Worktree branch context becomes artifact delivery mechanism for remote async agents
570+
- **Realizes Tier 2.5** (line 407-413): This IS the implementation of "Parallel Sub-Agent Coordination" with explicit dependencies
571+
572+
**Key Benefits**:
573+
574+
- Enables incident.io's 5+ agents in parallel without context clash (each in isolated branch + worktree)
575+
- Pre-merge hooks enforce dependency constraints before merging
576+
- Phase-respecting orchestration maintains logical workflow structure
577+
- Graceful fallback without Worktrunk (sequential in-directory execution)
578+
- Clear visibility into which tasks are blocked (waiting for dependencies)
579+
580+
**Success Metrics**:
581+
582+
- All 3 phases complete in correct order
583+
- Multiple [P] tasks execute simultaneously (with Worktrunk)
584+
- Pre-merge hooks prevent merging with unmet dependencies
585+
- Dashboard shows real-time parallel task progress
586+
- ASYNC tasks receive full worktree branch context (ready for Tier 1)
587+
588+
**Risks & Mitigation**:
589+
590+
| Risk | Mitigation |
591+
|------|-----------|
592+
| Dependency cycles in tasks.md | DAG validation in Phase 1 prevents cycles during parsing |
593+
| Pre-merge hooks too strict | Customizable per project in `.config/wt.toml` |
594+
| Worktrunk not installed | Graceful fallback to sequential in-directory execution |
595+
| Tasks blocked on dependencies | Clear warning messages indicate which deps are waiting |
596+
| Tier 1 integration complexity | Phase 4 provides scoped worktree context + packaging |
597+
598+
**References**:
599+
600+
- incident.io: "Shipping faster with Claude Code and Git Worktrees" (Jun 2025) - validates multi-agent + worktree pattern
601+
- Worktrunk: https://github.com/max-sixty/worktrunk - git worktree management for parallel AI workflows
602+
- Existing SYNC/ASYNC triage (line 72-87) + [P] markers (line 56-61) provide foundation
603+
604+
---
605+
506606
### **Command Prefix Migration** *(0% Complete)* - **MEDIUM PRIORITY** - Fork differentiation and user experience
507607

508608
-**Prefix Change Implementation**: Migrate from `/speckit.*` to `/agenticsdlc.*` commands for clear fork identification
@@ -519,6 +619,113 @@ Consolidates: Command-level model selection + context budgeting + two-model revi
519619

520620
### **Future Enhancement Categories**
521621

622+
### **Beads-Backed Task Execution Tracker** *(0% Complete)* - **MEDIUM PRIORITY** - Agent-native persistent work tracking
623+
624+
**Problem Statement**:
625+
The `/tasks` command generates dependency-ordered tasks.md files, but agents lack persistent cross-session visibility into task state, dependencies, and execution progress. This leads to:
626+
- Agents losing context about task generation decisions across sessions (inter-session amnesia)
627+
- Inability to query ready-to-execute tasks without parsing markdown
628+
- Lost work discovery when agents encounter issues during implementation but lack structured recording mechanism
629+
- Suboptimal agent behavior near context limits (workarounds instead of updating task status)
630+
631+
Per Steve Yegge's Beads manifesto, agents naturally work better with issue trackers than markdown plans because structured dependency queries and persistent memory solve these problems.
632+
633+
**Solution**:
634+
Integrate Beads (native issue tracker) with `/tasks` command as dual-output system:
635+
- `/tasks` continues generating tasks.md (no breaking changes to current workflow)
636+
- **NEW**: `/tasks` also populates beads issues with explicit dependencies, SYNC/ASYNC classification, and phase structure
637+
- Agents can query beads during `/implement` for ready work: `bd ready --json --assignee me`
638+
- Discovered work automatically recorded to beads by agents without context pressure
639+
- Task status updates via `bd update` provide persistent progress tracking across sessions
640+
641+
**Scope** (Conservative Approach - Option A):
642+
-`/tasks` generates beads issues in parallel with tasks.md (coexistence, not replacement)
643+
- ✅ Each task becomes a beads issue with:
644+
- Title: Task name from tasks.md
645+
- Description: Task description + rationale for SYNC/ASYNC classification
646+
- Labels: `[SYNC]`, `[ASYNC]`, `[P]` (parallelizable), phase name (Setup, Foundational, US1, etc.)
647+
- Dependencies: Links between phases and dependent tasks via beads parent/child relationships
648+
- Status: `open` (not started), `in_progress`, `done`
649+
- ✅ Beads database lives alongside tasks.md in `specs/[feature-name]/` directory
650+
- ✅ Beads is native install (users install `bd` CLI separately)
651+
- ✅ Graceful fallback: If beads unavailable, tasks.md workflow still works
652+
- ❌ NOT replacing tasks.md as execution format (yet)
653+
- ❌ NOT for multi-feature pattern learning
654+
- ❌ NOT for cross-project agent coordination
655+
656+
**Integration Points**:
657+
658+
| Component | Current | Change | Impact |
659+
|-----------|---------|--------|--------|
660+
| `/tasks` command | Generates tasks.md only | Also calls `bd create` for each task | Dual output, no breaking changes |
661+
| `tasks-meta-utils.sh` | Tracks task metadata in tasks_meta.json | Sync SYNC/ASYNC classification to beads issue labels | Beads becomes single source of execution mode truth |
662+
| `/implement` command | Parses tasks.md for task list | Optional: Query `bd ready --json` for better structure (Phase 2) | Phase 1 uses tasks.md, Phase 2 uses beads |
663+
| Task storage | `specs/[feature]/tasks.md` | Add `specs/[feature]/.beads/` directory | Beads provides query-able execution tracker |
664+
| Agent context | Session-based (limited memory) | Can query beads for discovered issues, previous decisions | Persistent cross-session memory |
665+
666+
**Implementation Roadmap**:
667+
668+
**Phase 1: Beads Issue Generation from `/tasks`** (Weeks 1-3)
669+
- ❌ Modify `/tasks` template to call `scripts/bash/tasks-to-beads.sh` after tasks.md generation
670+
- ❌ Create `scripts/bash/tasks-to-beads.sh` (+ PowerShell equivalent):
671+
- Parse generated tasks.md
672+
- Extract: task ID, title, description, phase, SYNC/ASYNC classification, dependencies
673+
- Call `bd create` with formatted issue + labels
674+
- Link parent/child tasks via beads dependency relationships
675+
- Handle duplicate runs (update existing issues vs. create new)
676+
- ❌ Add beads initialization to `/tasks` workflow: `bd init` if `.beads/` doesn't exist
677+
- ❌ Document beads setup in `/tasks` help text: "Beads database available at .beads/issues.jsonl"
678+
- ❌ Test with single feature: Generate tasks.md + beads issues, verify structure
679+
680+
**Phase 2: Agent Work Discovery & Status Tracking** (Weeks 4-6, deferred)
681+
- ❌ Guide agents to use `bd create` when discovering issues during implementation
682+
- ❌ Inject prompt guidance into `/implement` delegation template about recording work
683+
- ❌ Enable agents to update task status: `bd update --status in_progress` as they work
684+
- ❌ Test: Run `/implement` with beads tracking, verify discovered issues recorded
685+
686+
**Phase 3: Query-Based Task Fetching** (Weeks 7-9, deferred - Option B migration)
687+
- ❌ Modify `/implement` to use `bd ready --json` instead of parsing tasks.md
688+
- ❌ Implement task batching: agents fetch tasks in phases (Setup → Foundational → Stories)
689+
- ❌ Enable dynamic task re-ordering based on discovered blockers (via beads dependency updates)
690+
- ❌ This phase represents migration from Option A (coexistence) to Option B (full beads execution)
691+
692+
**Relationship to Async Work** (Tier 1.4 - Tier 1.6):
693+
- Beads issues can be tagged `async-ready` during `/tasks` generation (integrates with Tier 1.5)
694+
- Remote async agents query `bd ready --json --label async-ready` for delegatable work
695+
- Webhook callbacks from remote agents update beads issue status (Tier 1.4)
696+
- Full artifact context packaging (Tier 1.6) includes beads issue descriptions for agent briefing
697+
698+
**Success Metrics**:
699+
- Phase 1 Complete: 100% of tasks.md tasks also exist as beads issues with correct dependencies
700+
- Phase 1 Quality: Agents report improved context retention across `/tasks` regenerations
701+
- Phase 2 Complete: Discovered issues automatically recorded to beads (no manual prompting)
702+
- Phase 3 Complete: Agents prefer `bd ready --json` queries over tasks.md parsing
703+
704+
**Risks & Mitigation**:
705+
- Risk: Agents delete/corrupt beads database (like markdown plans in Yegge's experience)
706+
- Mitigation: Beads backed by git, easy recovery; document git workflow in guide
707+
- Risk: Tasks.md and beads get out of sync during development
708+
- Mitigation: Phase 1 only generates beads at `/tasks` time; `/implement` still uses tasks.md (Phase 3 solves this)
709+
- Risk: Beads adoption overhead for users
710+
- Mitigation: Optional feature (graceful fallback); native beads install keeps dependencies simple
711+
712+
**Related Commands**:
713+
- Complements `/trace` command (which captures session decisions) by making them queryable
714+
- Enables future `/levelup` enhancements (extract patterns from beads issue history)
715+
- Works with existing `/implement` (Phase 1) and enhances it (Phase 2-3)
716+
717+
**References**:
718+
- Beads Article: https://steve-yegge.medium.com/introducing-beads-a-coding-agent-memory-system-637d7d92514a
719+
- Beads GitHub: https://github.com/steveyegge/beads
720+
721+
**Notes**:
722+
- Conservative scope (Option A) chosen to minimize risk: coexists with tasks.md, no breaking changes
723+
- Full vision (Option B) available for future consideration: agents work directly from beads queries
724+
- Implementation depends on users having `bd` CLI installed (documentation will cover setup)
725+
- Aligns with Beads manifesto insight: agents work better with persistent, queryable issue trackers than stateless markdown
726+
727+
---
728+
522729
### **Executable Specifications** *(0% Complete)* - **NICE-TO-HAVE** - No implementation planned
523730

524731
**Status**: Deferred to focus on core workflow stability and high-priority items.

scripts/bash/common.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,25 @@ try:
409409
410410
print(json.dumps(views, ensure_ascii=False))
411411
except Exception as e:
412-
print('{}')
412+
print('[]')
413413
PY
414414
}
415415

416+
# Detect workflow mode and framework options from spec.md
417+
# Usage: detect_workflow_config [path/to/spec.md]
418+
# Returns JSON: {"mode":"build|spec","tdd":true|false,"contracts":true|false,"data_models":true|false,"risk_tests":true|false}
419+
detect_workflow_config() {
420+
local spec_file="${1:-spec.md}"
421+
422+
# Source the standalone script
423+
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
424+
source "$script_dir/detect-workflow-config.sh"
425+
426+
# Call the function
427+
detect_workflow_config "$spec_file"
428+
}
429+
430+
416431
# Extract diagram blocks from architecture.md
417432
# Returns JSON array of diagrams with type and format
418433
extract_architecture_diagrams() {

0 commit comments

Comments
 (0)