Skip to content

Commit 4f0e195

Browse files
committed
feat: separate orchestrator directive from agent tasks
- IMPLEMENTATION_PLAN.md now contains single meta-directive: "Check .context/TASKS.md" - Tasks live in agent's mind (.context/TASKS.md), not orchestrator - ctx init creates IMPLEMENTATION_PLAN.md in project root - PROMPT.md updated to check .context/TASKS.md for task selection - Removed unused root templates/ directory (internal/templates/ is source of truth) - Added decision record and learnings for orchestrator/agent separation - Marked "Claude hooks" task complete in TASKS.md Signed-off-by: Jose Alekhinne <alekhinejose@gmail.com>
1 parent 87dcfa1 commit 4f0e195

16 files changed

Lines changed: 180 additions & 194 deletions

.context/DECISIONS.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,30 @@ ctx init # Creates BOTH .context/ AND .claude/hooks/
171171
- Only works with Claude Code (other tools need different approach)
172172
- Requires jq for JSON parsing in hook script
173173
- Session files are .jsonl format (need tooling to read)
174+
175+
---
176+
177+
## [2025-01-21] Separate Orchestrator Directive from Agent Tasks
178+
179+
**Status**: Accepted
180+
181+
**Context**: Two task systems existed: `IMPLEMENTATION_PLAN.md` (Ralph Loop orchestrator) and `.context/TASKS.md` (ctx's own context). Ralph would find IMPLEMENTATION_PLAN.md complete and exit, ignoring .context/TASKS.md.
182+
183+
**Decision**: Clean separation of concerns:
184+
- **`.context/TASKS.md`** = Agent's mind. Tasks the agent decided need doing.
185+
- **`IMPLEMENTATION_PLAN.md`** = Orchestrator's directive. A single meta-task: "Check your tasks."
186+
187+
The orchestrator doesn't maintain a parallel ledger — it just tells the agent to check its own mind.
188+
189+
**Rationale**:
190+
- Agent autonomy: the agent owns its task list
191+
- Single source of truth for tasks
192+
- Orchestrator is minimal, not a micromanager
193+
- Fresh `ctx init` deployments can have one directive: "Check .context/TASKS.md"
194+
- Prevents task list drift between two files
195+
196+
**Consequences**:
197+
- `PROMPT.md` now references `.context/TASKS.md` for task selection
198+
- `IMPLEMENTATION_PLAN.md` becomes a thin directive layer
199+
- Historical milestones are archived, not active tasks
200+
- North Star goals live in IMPLEMENTATION_PLAN.md (meta-level, not tasks)

.context/LEARNINGS.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,35 @@ The `.context/` directory is an ctx convention. Claude won't know about it unles
129129
CGO_ENABLED=0 go build -o ctx ./cmd/ctx
130130
CGO_ENABLED=0 go test ./...
131131
```
132+
133+
---
134+
135+
## Project Structure
136+
137+
### One Templates Directory, Not Two
138+
**Discovered**: 2025-01-21
139+
140+
**Context**: Confusion arose about `templates/` (root) vs `internal/templates/` (embedded).
141+
142+
**Lesson**: Only `internal/templates/` matters — it's where Go embeds files into the binary. A root `templates/` directory is spec baggage that serves no purpose.
143+
144+
**The actual flow:**
145+
```
146+
internal/templates/ ──[ctx init]──> .context/
147+
(baked into binary) (agent's working copy)
148+
```
149+
150+
**Application**: Don't create duplicate template directories. One source of truth.
151+
152+
### Orchestrator vs Agent Tasks
153+
**Discovered**: 2025-01-21
154+
155+
**Context**: Ralph Loop checked `IMPLEMENTATION_PLAN.md`, found all tasks done, exited — ignoring `.context/TASKS.md`.
156+
157+
**Lesson**: Separate concerns:
158+
- **`IMPLEMENTATION_PLAN.md`** = Orchestrator directive ("check your tasks")
159+
- **`.context/TASKS.md`** = Agent's mind (actual task list)
160+
161+
The orchestrator shouldn't maintain a parallel ledger. It just says "check your mind."
162+
163+
**Application**: For new projects, `IMPLEMENTATION_PLAN.md` has ONE task: "Check `.context/TASKS.md`"

.context/TASKS.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44

55
## Next Up
66

7-
### Enhance `ctx init` to Create Claude Hooks `#priority:high` `#area:cli`
8-
- [ ] Embed hook scripts in binary (like templates)
9-
- [ ] Create `.claude/hooks/auto-save-session.sh` during init
10-
- [ ] Create `.claude/settings.local.json` with PreToolUse and SessionEnd hooks
11-
- [ ] Detect platform to set correct binary path in hooks
12-
- [ ] Update `ctx init` output to mention Claude Code integration
13-
147
### Handle CLAUDE.md Creation/Merge `#priority:high` `#area:cli`
158
- [ ] Create CLAUDE.md if it doesn't exist
169
- [ ] If CLAUDE.md exists, backup to CLAUDE.md.<unix_timestamp>.bak before any modification
@@ -37,6 +30,7 @@
3730

3831
## Completed (Recent)
3932

33+
- [x] Enhance `ctx init` to create Claude hooks (embedded scripts, settings.local.json, platform detection) — 2025-01-21
4034
- [x] Set up PreToolUse hook for auto-load — 2025-01-20
4135
- [x] Set up SessionEnd hook for auto-save — 2025-01-20
4236
- [x] Create `.context/sessions/` directory structure — 2025-01-20

IMPLEMENTATION_PLAN.md

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,34 @@
11
# Implementation Plan
22

3-
This file tracks the implementation progress for Active Memory CLI.
4-
5-
## Milestone 1: Project Scaffolding
6-
- [x] Initialize Go module and directory structure
7-
- [x] Create Cobra CLI skeleton in `cmd/ctx/main.go`
8-
- [x] Create embedded templates in `internal/templates/`
9-
- [x] Add all template files to `templates/` directory
10-
11-
## Milestone 2: Core Commands (MVP)
12-
- [x] Implement `ctx init` — Create `.context/` with template files
13-
- [x] Implement `ctx status` — Show context summary with token estimate
14-
- [x] Implement `ctx load` — Output assembled context markdown
15-
16-
## Milestone 3: Context Operations
17-
- [x] Implement `ctx add` — Add decision/task/learning/convention
18-
- [x] Implement `ctx complete` — Mark task as done
19-
- [x] Implement `ctx agent` — Print AI-ready context packet
20-
21-
## Milestone 4: Maintenance Commands
22-
- [x] Implement `ctx drift` — Detect stale paths, broken refs (text output)
23-
- [x] Implement `ctx drift --json` — JSON output for automation
24-
- [x] Implement `ctx sync` — Reconcile context with codebase
25-
- [x] Implement `ctx compact` — Archive completed tasks
26-
- [x] Implement `ctx watch` — Watch for context-update commands
27-
28-
## Milestone 5: Integration
29-
- [x] Implement `ctx hook` — Generate AI tool integration configs
30-
- [x] Add `--help` text for all commands
31-
- [x] Add `--version` flag with build-time version
32-
33-
## Milestone 6: Testing & Release
34-
- [x] Write unit tests for `internal/context/` (loader, parser)
35-
- [x] Write unit tests for `internal/drift/` (detector)
36-
- [x] Write integration tests for CLI commands
37-
- [x] Create `scripts/build-all.sh` for cross-platform builds
38-
- [x] Create `.github/workflows/release.yml` for GitHub Actions
39-
- [x] Create `examples/demo/` with sample `.context/` directory
40-
- [x] Update README.md with installation and usage instructions
41-
42-
## Notes
43-
44-
- Build command: `CGO_ENABLED=0 go build -o ctx ./cmd/ctx`
45-
- CGO is disabled due to gcc cross-compilation issues on ARM64 Linux
3+
This file is the orchestrator's directive. The agent's actual tasks live in `.context/TASKS.md`.
4+
5+
## Current Directive
6+
7+
- [ ] Check `.context/TASKS.md` and work on the first unchecked item
8+
9+
## Completion Criteria
10+
11+
When `.context/TASKS.md` has no unchecked items in "Next Up", the directive is complete.
12+
13+
## North Star (Endgame)
14+
15+
Before declaring DONE, remind the user about these goals:
16+
17+
1. **Dogfood ctx on itself** — nuke repo, `ctx init` fresh, Ralph-loop build
18+
2. **Sample project** — bootstrap a RESTful app from scratch using ctx
19+
3. **Real-world validation** — apply to `github.com/spiffe/spike` and `spike-sdk-go`
20+
21+
---
22+
23+
## Archive (Historical)
24+
25+
The following milestones were completed during initial development:
26+
27+
### Milestone 1: Project Scaffolding ✅
28+
### Milestone 2: Core Commands (MVP) ✅
29+
### Milestone 3: Context Operations ✅
30+
### Milestone 4: Maintenance Commands ✅
31+
### Milestone 5: Integration ✅
32+
### Milestone 6: Testing & Release ✅
33+
34+
Build command: `CGO_ENABLED=0 go build -o ctx ./cmd/ctx`

PROMPT.md

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -56,49 +56,16 @@ Check if `go.mod` exists.
5656

5757
## PHASE 2: SELECT TASK
5858

59-
Read `IMPLEMENTATION_PLAN.md` and pick the **first unchecked item**.
60-
61-
**IF NO UNCHECKED ITEMS:** Output `<promise>DONE</promise>` and exit.
62-
63-
**NOTE:** Task tracking is done in `IMPLEMENTATION_PLAN.md`, not here.
64-
The milestones below are for reference only when creating a new plan.
65-
66-
### Milestone 1: Project Scaffolding
67-
- Initialize Go module and directory structure
68-
- Create Cobra CLI skeleton in `cmd/ctx/main.go`
69-
- Create embedded templates in `internal/templates/`
70-
- Add all template files to `templates/` directory
71-
72-
### Milestone 2: Core Commands (MVP)
73-
- Implement `ctx init` — Create `.context/` with template files
74-
- Implement `ctx status` — Show context summary with token estimate
75-
- Implement `ctx load` — Output assembled context markdown
76-
77-
### Milestone 3: Context Operations
78-
- Implement `ctx add` — Add decision/task/learning/convention
79-
- Implement `ctx complete` — Mark task as done
80-
- Implement `ctx agent` — Print AI-ready context packet
81-
82-
### Milestone 4: Maintenance Commands
83-
- Implement `ctx drift` — Detect stale paths, broken refs (text output)
84-
- Implement `ctx drift --json` — JSON output for automation
85-
- Implement `ctx sync` — Reconcile context with codebase
86-
- Implement `ctx compact` — Archive completed tasks
87-
- Implement `ctx watch` — Watch for context-update commands
88-
89-
### Milestone 5: Integration
90-
- Implement `ctx hook` — Generate AI tool integration configs
91-
- Add `--help` text for all commands
92-
- Add `--version` flag with build-time version
93-
94-
### Milestone 6: Testing & Release
95-
- Write unit tests for `internal/context/` (loader, parser)
96-
- Write unit tests for `internal/drift/` (detector)
97-
- Write integration tests for CLI commands
98-
- Create `scripts/build-all.sh` for cross-platform builds
99-
- Create `.github/workflows/release.yml` for GitHub Actions
100-
- Create `examples/demo/` with sample `.context/` directory
101-
- Update README.md with installation and usage instructions
59+
1. Read `IMPLEMENTATION_PLAN.md` for the current directive
60+
2. Follow the directive — typically: "Check `.context/TASKS.md`"
61+
3. Read `.context/TASKS.md` and pick the **first unchecked item** in "Next Up"
62+
63+
**IF NO UNCHECKED ITEMS in `.context/TASKS.md`:**
64+
1. Check `IMPLEMENTATION_PLAN.md` for North Star goals
65+
2. Remind user about Endgame goals before exiting
66+
3. Output `<promise>DONE</promise>`
67+
68+
**Philosophy:** Tasks live in the agent's mind (`.context/TASKS.md`). The orchestrator (`IMPLEMENTATION_PLAN.md`) provides the meta-directive, not the task list
10269

10370
---
10471

@@ -134,10 +101,11 @@ go vet ./... # No vet errors
134101

135102
## PHASE 5: UPDATE CONTEXT
136103

137-
1. Mark completed task `[x]` in `IMPLEMENTATION_PLAN.md`
138-
2. If you made an architectural decision → document in `specs/` or `.context/DECISIONS.md`
139-
3. If you learned a gotcha → add to `.context/LEARNINGS.md`
140-
4. If build commands changed → update `AGENTS.md`
104+
1. Mark completed task `[x]` in `.context/TASKS.md`
105+
2. Move task to "Completed (Recent)" section with date
106+
3. If you made an architectural decision → document in `.context/DECISIONS.md`
107+
4. If you learned a gotcha → add to `.context/LEARNINGS.md`
108+
5. If build commands changed → update `AGENTS.md`
141109

142110
---
143111

@@ -160,9 +128,9 @@ Complete ONE task, then stop. The loop handles continuation.
160128

161129
### NO CHAT
162130
Never ask questions. If blocked:
163-
1. Add `Blocked: [reason]` to `IMPLEMENTATION_PLAN.md`
164-
2. Move to next task
165-
3. If ALL blocked: `<promise>SYSTEM_BLOCKED</promise>`
131+
1. Move task to "Blocked" section in `.context/TASKS.md` with reason
132+
2. Move to next task in "Next Up"
133+
3. If ALL tasks blocked: `<promise>SYSTEM_BLOCKED</promise>`
166134

167135
### MEMORY IS THE FILESYSTEM
168136
You will not remember this conversation. Write everything important to files.
@@ -309,12 +277,10 @@ Never assume. If you don't see it in files, you don't know it.
309277

310278
Output `<promise>DONE</promise>` ONLY when ALL of these are true:
311279

312-
1. All commands in `specs/cli.md` are implemented
280+
1. `.context/TASKS.md` has no unchecked items in "Next Up"
313281
2. `go build ./...` passes
314282
3. `go test ./...` passes
315-
4. `ctx init && ctx status && ctx drift` works end-to-end
316-
5. `scripts/build-all.sh` produces binaries for linux/darwin/windows
317-
6. README.md has installation instructions
283+
4. You have reminded the user about the North Star goals in `IMPLEMENTATION_PLAN.md`
318284

319285
---
320286

internal/cli/init.go

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,16 @@ func runInit(cmd *cobra.Command, args []string) error {
9595
if initMinimal {
9696
templatesToCreate = minimalTemplates
9797
} else {
98-
var err error
99-
templatesToCreate, err = templates.ListTemplates()
98+
allTemplates, err := templates.ListTemplates()
10099
if err != nil {
101100
return fmt.Errorf("failed to list templates: %w", err)
102101
}
102+
// Filter out IMPLEMENTATION_PLAN.md - it goes in project root, not .context/
103+
for _, t := range allTemplates {
104+
if t != "IMPLEMENTATION_PLAN.md" {
105+
templatesToCreate = append(templatesToCreate, t)
106+
}
107+
}
103108
}
104109

105110
// Create template files
@@ -127,6 +132,12 @@ func runInit(cmd *cobra.Command, args []string) error {
127132

128133
fmt.Printf("\n%s initialized in %s/\n", green("Active Memory"), contextDir)
129134

135+
// Create IMPLEMENTATION_PLAN.md in project root (orchestrator directive)
136+
if err := createImplementationPlan(initForce); err != nil {
137+
// Non-fatal: warn but continue
138+
fmt.Printf(" %s IMPLEMENTATION_PLAN.md: %v\n", color.YellowString("⚠"), err)
139+
}
140+
130141
// Create Claude Code hooks
131142
fmt.Println("\nSetting up Claude Code integration...")
132143
if err := createClaudeHooks(initForce); err != nil {
@@ -249,3 +260,31 @@ func mergeSettingsHooks(projectDir string, force bool) error {
249260

250261
return nil
251262
}
263+
264+
// createImplementationPlan creates IMPLEMENTATION_PLAN.md in project root
265+
// This is the orchestrator directive that points to .context/TASKS.md
266+
func createImplementationPlan(force bool) error {
267+
green := color.New(color.FgGreen).SprintFunc()
268+
yellow := color.New(color.FgYellow).SprintFunc()
269+
270+
const planFileName = "IMPLEMENTATION_PLAN.md"
271+
272+
// Check if file exists
273+
if _, err := os.Stat(planFileName); err == nil && !force {
274+
fmt.Printf(" %s %s (exists, skipped)\n", yellow("○"), planFileName)
275+
return nil
276+
}
277+
278+
// Get template content
279+
content, err := templates.GetTemplate(planFileName)
280+
if err != nil {
281+
return fmt.Errorf("failed to read template: %w", err)
282+
}
283+
284+
if err := os.WriteFile(planFileName, content, 0644); err != nil {
285+
return fmt.Errorf("failed to write file: %w", err)
286+
}
287+
288+
fmt.Printf(" %s %s (orchestrator directive)\n", green("✓"), planFileName)
289+
return nil
290+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Implementation Plan
2+
3+
This file is the orchestrator's directive. The agent's actual tasks live in `.context/TASKS.md`.
4+
5+
## Current Directive
6+
7+
- [ ] Check `.context/TASKS.md` and work on the first unchecked item
8+
9+
## Completion Criteria
10+
11+
When `.context/TASKS.md` has no unchecked items in "Next Up", the directive is complete.
12+
13+
## North Star (Endgame)
14+
15+
Before declaring DONE, consider these goals:
16+
17+
1. **Define your north star** — What does "done" look like for this project?
18+
2. **Validate end-to-end** — Does the system work as intended?
19+
3. **Document for others** — Can someone else pick this up?
20+
21+
---
22+
23+
## Notes
24+
25+
- Tasks belong in `.context/TASKS.md` (the agent's mind)
26+
- This file provides meta-direction, not task details
27+
- Update North Star goals as the project evolves

templates/AGENT_PLAYBOOK.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

templates/ARCHITECTURE.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)