feed-the-machine 1.1.0 → 1.3.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 (92) hide show
  1. package/bin/generate-manifest.mjs +253 -0
  2. package/bin/install.mjs +372 -26
  3. package/docs/INBOX.md +233 -0
  4. package/ftm/SKILL.md +34 -0
  5. package/ftm-audit/SKILL.md +69 -0
  6. package/ftm-brainstorm/SKILL.md +51 -0
  7. package/ftm-browse/SKILL.md +39 -0
  8. package/ftm-capture/SKILL.md +370 -0
  9. package/ftm-capture.yml +4 -0
  10. package/ftm-codex-gate/SKILL.md +59 -0
  11. package/ftm-config/SKILL.md +35 -0
  12. package/ftm-council/SKILL.md +56 -0
  13. package/ftm-dashboard/SKILL.md +34 -0
  14. package/ftm-debug/SKILL.md +84 -0
  15. package/ftm-diagram/SKILL.md +44 -0
  16. package/ftm-executor/SKILL.md +97 -0
  17. package/ftm-git/SKILL.md +60 -0
  18. package/ftm-inbox/backend/__init__.py +0 -0
  19. package/ftm-inbox/backend/adapters/__init__.py +0 -0
  20. package/ftm-inbox/backend/adapters/_retry.py +64 -0
  21. package/ftm-inbox/backend/adapters/base.py +230 -0
  22. package/ftm-inbox/backend/adapters/freshservice.py +104 -0
  23. package/ftm-inbox/backend/adapters/gmail.py +125 -0
  24. package/ftm-inbox/backend/adapters/jira.py +136 -0
  25. package/ftm-inbox/backend/adapters/registry.py +192 -0
  26. package/ftm-inbox/backend/adapters/slack.py +110 -0
  27. package/ftm-inbox/backend/db/__init__.py +0 -0
  28. package/ftm-inbox/backend/db/connection.py +54 -0
  29. package/ftm-inbox/backend/db/schema.py +78 -0
  30. package/ftm-inbox/backend/executor/__init__.py +7 -0
  31. package/ftm-inbox/backend/executor/engine.py +149 -0
  32. package/ftm-inbox/backend/executor/step_runner.py +98 -0
  33. package/ftm-inbox/backend/main.py +103 -0
  34. package/ftm-inbox/backend/models/__init__.py +1 -0
  35. package/ftm-inbox/backend/models/unified_task.py +36 -0
  36. package/ftm-inbox/backend/planner/__init__.py +6 -0
  37. package/ftm-inbox/backend/planner/generator.py +127 -0
  38. package/ftm-inbox/backend/planner/schema.py +34 -0
  39. package/ftm-inbox/backend/requirements.txt +5 -0
  40. package/ftm-inbox/backend/routes/__init__.py +0 -0
  41. package/ftm-inbox/backend/routes/execute.py +186 -0
  42. package/ftm-inbox/backend/routes/health.py +52 -0
  43. package/ftm-inbox/backend/routes/inbox.py +68 -0
  44. package/ftm-inbox/backend/routes/plan.py +271 -0
  45. package/ftm-inbox/bin/launchagent.mjs +91 -0
  46. package/ftm-inbox/bin/setup.mjs +188 -0
  47. package/ftm-inbox/bin/start.sh +10 -0
  48. package/ftm-inbox/bin/status.sh +17 -0
  49. package/ftm-inbox/bin/stop.sh +8 -0
  50. package/ftm-inbox/config.example.yml +55 -0
  51. package/ftm-inbox/package-lock.json +2898 -0
  52. package/ftm-inbox/package.json +26 -0
  53. package/ftm-inbox/postcss.config.js +6 -0
  54. package/ftm-inbox/src/app.css +199 -0
  55. package/ftm-inbox/src/app.html +18 -0
  56. package/ftm-inbox/src/lib/api.ts +166 -0
  57. package/ftm-inbox/src/lib/components/ExecutionLog.svelte +81 -0
  58. package/ftm-inbox/src/lib/components/InboxFeed.svelte +143 -0
  59. package/ftm-inbox/src/lib/components/PlanStep.svelte +271 -0
  60. package/ftm-inbox/src/lib/components/PlanView.svelte +206 -0
  61. package/ftm-inbox/src/lib/components/StreamPanel.svelte +99 -0
  62. package/ftm-inbox/src/lib/components/TaskCard.svelte +190 -0
  63. package/ftm-inbox/src/lib/components/ui/EmptyState.svelte +63 -0
  64. package/ftm-inbox/src/lib/components/ui/KawaiiCard.svelte +86 -0
  65. package/ftm-inbox/src/lib/components/ui/PillButton.svelte +106 -0
  66. package/ftm-inbox/src/lib/components/ui/StatusBadge.svelte +67 -0
  67. package/ftm-inbox/src/lib/components/ui/StreamDrawer.svelte +149 -0
  68. package/ftm-inbox/src/lib/components/ui/ThemeToggle.svelte +80 -0
  69. package/ftm-inbox/src/lib/theme.ts +47 -0
  70. package/ftm-inbox/src/routes/+layout.svelte +76 -0
  71. package/ftm-inbox/src/routes/+page.svelte +401 -0
  72. package/ftm-inbox/static/favicon.png +0 -0
  73. package/ftm-inbox/svelte.config.js +12 -0
  74. package/ftm-inbox/tailwind.config.ts +63 -0
  75. package/ftm-inbox/tsconfig.json +13 -0
  76. package/ftm-inbox/vite.config.ts +6 -0
  77. package/ftm-intent/SKILL.md +44 -0
  78. package/ftm-manifest.json +3794 -0
  79. package/ftm-map/SKILL.md +50 -0
  80. package/ftm-mind/SKILL.md +173 -66
  81. package/ftm-pause/SKILL.md +43 -0
  82. package/ftm-researcher/SKILL.md +55 -0
  83. package/ftm-resume/SKILL.md +47 -0
  84. package/ftm-retro/SKILL.md +54 -0
  85. package/ftm-routine/SKILL.md +36 -0
  86. package/ftm-state/blackboard/capabilities.json +5 -0
  87. package/ftm-state/blackboard/capabilities.schema.json +27 -0
  88. package/ftm-upgrade/SKILL.md +41 -0
  89. package/hooks/ftm-blackboard-enforcer.sh +28 -27
  90. package/hooks/ftm-plan-gate.sh +21 -25
  91. package/install.sh +238 -111
  92. package/package.json +6 -2
package/ftm/SKILL.md CHANGED
@@ -33,6 +33,7 @@ If input starts with a recognized skill name, route directly to that skill:
33
33
  | `upgrade` | ftm-upgrade |
34
34
  | `retro` | ftm-retro |
35
35
  | `config` | ftm-config |
36
+ | `capture`, `codify`, `save as routine` | ftm-capture |
36
37
  | `mind` | ftm-mind |
37
38
 
38
39
  When routing to a specific skill:
@@ -77,6 +78,7 @@ FTM Skills:
77
78
  /ftm upgrade — Check for and install skill updates
78
79
  /ftm retro — Post-execution retrospective
79
80
  /ftm config — View and edit ftm configuration
81
+ /ftm capture [name] — Extract routine + playbook from current session
80
82
 
81
83
  Or just describe what you need and ftm-mind will handle it.
82
84
  ```
@@ -86,3 +88,35 @@ Or just describe what you need and ftm-mind will handle it.
86
88
  - Do not attempt to do the work yourself — route only.
87
89
  - Be fast — decisive routing, not conversation.
88
90
  - Case insensitive matching for all prefix detection.
91
+
92
+ ## Requirements
93
+
94
+ - config: `~/.claude/ftm-config.yml` | optional | legacy_router_fallback setting
95
+ - reference: `~/.claude/ftm-state/blackboard/context.json` | optional | session state for blackboard update on routing
96
+ - tool: none beyond skill invocation mechanism
97
+
98
+ ## Risk
99
+
100
+ - level: read_only
101
+ - scope: reads blackboard context.json and updates session_metadata.skills_invoked before routing; does not modify any project files
102
+ - rollback: no mutations to reverse; blackboard update is a metadata append
103
+
104
+ ## Approval Gates
105
+
106
+ - trigger: ftm-mind failure AND legacy_router_fallback enabled | action: fall back to keyword routing automatically (no user gate needed)
107
+ - complexity_routing: micro → auto | small → auto | medium → auto | large → auto | xl → auto
108
+
109
+ ## Fallbacks
110
+
111
+ - condition: ftm-mind fails or times out | action: check legacy_router_fallback in ftm-config.yml; if true, use keyword matching; if false, report failure
112
+ - condition: blackboard context.json missing | action: skip blackboard update, proceed with routing
113
+ - condition: skill tool unavailable for target skill | action: report routing failure to user with the target skill name
114
+
115
+ ## Capabilities
116
+
117
+ - env: none required
118
+
119
+ ## Event Payloads
120
+
121
+ ### (none)
122
+ ftm is a pure router and does not emit events directly. Events are emitted by the target skill after routing.
@@ -144,3 +144,72 @@ After completing:
144
144
  ## Report Format
145
145
 
146
146
  See `references/templates/REPORT-FORMAT.md` for the full report template (summary, changelog table, layer-by-layer finding format with examples).
147
+
148
+ ## Requirements
149
+
150
+ - tool: `knip` | optional | static dead-code and unused-export analysis (Layer 1)
151
+ - tool: `node` | required | runtime for knip via npx
152
+ - config: `knip.config.ts` | optional | custom knip configuration at project root
153
+ - reference: `references/protocols/PROJECT-PATTERNS.md` | required | framework detection table and dimension activation matrix
154
+ - reference: `references/strategies/AUTO-FIX-STRATEGIES.md` | required | fix actions by finding type
155
+ - reference: `references/protocols/WIRING-CONTRACTS.md` | optional | wiring contract schema for plan-driven audits
156
+ - reference: `references/protocols/RUNTIME-WIRING.md` | optional | runtime verification protocol
157
+ - reference: `references/templates/REPORT-FORMAT.md` | required | structured report template
158
+ - tool: `$HOME/.claude/skills/ftm-browse/bin/ftm-browse` | optional | runtime wiring verification via browser (Phase 3)
159
+
160
+ ## Risk
161
+
162
+ - level: medium_write
163
+ - scope: modifies source files to fix wiring issues (auto-fix layer); also adds/removes imports and route registrations; reads codebase broadly
164
+ - rollback: git checkout on auto-fixed files; all changes are tracked in the changelog report before being applied
165
+
166
+ ## Approval Gates
167
+
168
+ - trigger: auto-fix proposed for a finding | action: report proposed change before applying (show "Proposed: ..." format)
169
+ - trigger: finding flagged MANUAL_INTERVENTION_NEEDED | action: surface to user with suggested action, do not auto-fix
170
+ - trigger: re-verification still fails after 3 iterations | action: stop and report remaining issues to user
171
+ - complexity_routing: micro → auto | small → auto | medium → plan_first | large → plan_first | xl → always_ask
172
+
173
+ ## Fallbacks
174
+
175
+ - condition: knip not installed and npx unavailable | action: skip Layer 1, run Layer 2 adversarial audit only
176
+ - condition: no package.json found | action: skip knip entirely, run adversarial audit only
177
+ - condition: ftm-browse not installed | action: skip Phase 3 runtime wiring check, log reason and continue
178
+ - condition: dev server not running | action: skip Phase 3 runtime wiring check, log reason and continue
179
+ - condition: wiring contracts absent | action: run pure Layer 1 + Layer 2 analysis without contract checking
180
+ - condition: project has no identifiable entry point | action: skip knip, run adversarial audit only
181
+
182
+ ## Capabilities
183
+
184
+ - cli: `knip` | optional | dead code detection via npx knip
185
+ - cli: `node` | required | JavaScript runtime for npx
186
+ - cli: `$HOME/.claude/skills/ftm-browse/bin/ftm-browse` | optional | headless browser for runtime wiring
187
+ - mcp: `git` | optional | diff scope for Layer 2 adversarial audit
188
+
189
+ ## Event Payloads
190
+
191
+ ### audit_complete
192
+ - skill: string — "ftm-audit"
193
+ - findings_count: number — total issues found across all layers
194
+ - auto_fixed_count: number — issues auto-remediated by Layer 3
195
+ - manual_count: number — issues requiring manual intervention
196
+ - scope: string[] — file paths audited
197
+ - duration_ms: number — total audit duration
198
+ - layers_run: string[] — which layers executed (e.g., ["layer1", "layer2", "layer3"])
199
+
200
+ ### issue_found
201
+ - skill: string — "ftm-audit"
202
+ - layer: string — "layer1" | "layer2" | "layer3"
203
+ - dimension: string — D1 | D2 | D3 | D4 | D5 (for Layer 2 findings)
204
+ - finding_type: string — exports | types | duplicates | UNWIRED_COMPONENT | etc.
205
+ - file_path: string — affected file
206
+ - symbol: string — affected symbol name
207
+ - severity: string — CRITICAL | HIGH | MEDIUM | LOW
208
+ - auto_fixable: boolean — whether Layer 3 can fix this automatically
209
+
210
+ ### task_completed
211
+ - skill: string — "ftm-audit"
212
+ - result: string — "pass" | "pass_with_fixes" | "fail"
213
+ - findings_count: number — total findings
214
+ - auto_fixed_count: number — auto-remediated count
215
+ - manual_count: number — manual intervention needed
@@ -377,3 +377,54 @@ After completing, update:
377
377
  3. Update `experiences/index.json` with the new entry
378
378
  4. Emit `plan_generated` with `{ plan_path, plan_title, task_count, wave_count }` (if Phase 3 completed)
379
379
  5. Emit `task_completed` with `{ task_title, plan_path, duration_ms }`
380
+
381
+ ## Requirements
382
+
383
+ - config: `~/.claude/ftm-config.yml` | optional | model profile for planning agents
384
+ - reference: `references/agent-prompts.md` | required | research agent prompt templates
385
+ - reference: `references/plan-template.md` | required | plan document generation template
386
+ - reference: `~/.claude/ftm-state/blackboard/context.json` | optional | session state and active constraints
387
+ - reference: `~/.claude/ftm-state/blackboard/experiences/index.json` | optional | past brainstorm lessons
388
+ - reference: `~/.claude/ftm-state/blackboard/patterns.json` | optional | execution and user behavior patterns
389
+
390
+ ## Risk
391
+
392
+ - level: low_write
393
+ - scope: writes plan documents to ~/.claude/plans/; writes blackboard context and experience files; does not modify project source code
394
+ - rollback: delete generated plan file; blackboard writes can be reverted by editing JSON files
395
+
396
+ ## Approval Gates
397
+
398
+ - trigger: Phase 3 plan generation ready | action: present "Here's what I think we've landed on" summary and wait for explicit user approval before generating plan
399
+ - trigger: plan document generated | action: present plan incrementally (vision → tasks → agents/waves) and get approval at each step
400
+ - trigger: research returns thin results on all agents | action: note research gaps, present fewer suggestions, do not fabricate citations
401
+ - complexity_routing: micro → auto | small → auto | medium → plan_first | large → plan_first | xl → always_ask
402
+
403
+ ## Fallbacks
404
+
405
+ - condition: ftm-researcher not available | action: dispatch 3 direct parallel research agents (web/github/competitive) using built-in prompts from references/agent-prompts.md
406
+ - condition: no git repo detected in Phase 0 | action: skip repo scan, ask about tech stack during intake
407
+ - condition: blackboard missing or empty | action: proceed without experience-informed shortcuts, rely on direct analysis
408
+ - condition: ftm-config.yml missing | action: use session default model for all agents
409
+
410
+ ## Capabilities
411
+
412
+ - mcp: `WebSearch` | optional | web research agents use for blog posts and case studies
413
+ - mcp: `WebFetch` | optional | GitHub exploration and competitive analysis
414
+ - mcp: `sequential-thinking` | optional | complex trade-off analysis during synthesis
415
+ - env: none required
416
+
417
+ ## Event Payloads
418
+
419
+ ### plan_generated
420
+ - skill: string — "ftm-brainstorm"
421
+ - plan_path: string — absolute path to generated plan file
422
+ - plan_title: string — human-readable plan title
423
+ - task_count: number — total tasks in the plan
424
+ - wave_count: number — number of parallel execution waves
425
+
426
+ ### task_completed
427
+ - skill: string — "ftm-brainstorm"
428
+ - task_title: string — title of the brainstorm topic
429
+ - plan_path: string | null — path to generated plan if Phase 3 completed
430
+ - duration_ms: number — total session duration
@@ -413,3 +413,42 @@ When ftm-browse is used directly (not within a plan), supervised mode is OFF by
413
413
  - The daemon uses a 1280x800 headless Chromium viewport with a standard Mac Chrome user-agent, so most sites render predictably.
414
414
  - To stop the daemon explicitly: `$PB stop`. It will auto-restart on next use.
415
415
  - `$PB eval` is the escape hatch for anything the ARIA tree doesn't expose — hidden inputs, JS globals, localStorage, computed values.
416
+
417
+ ## Requirements
418
+
419
+ - tool: `$HOME/.claude/skills/ftm-browse/bin/ftm-browse` | required | headless browser CLI binary
420
+ - tool: `npx playwright install chromium` | required | Chromium browser engine (first-time setup)
421
+ - reference: none required
422
+
423
+ ## Risk
424
+
425
+ - level: low_write
426
+ - scope: navigates browser, takes screenshots saved to ~/.ftm-browse/screenshots/; does not modify project source files; form fills and clicks can have side effects on the target application
427
+ - rollback: no project file mutations; browser interactions on local dev servers are typically reversible by reloading
428
+
429
+ ## Approval Gates
430
+
431
+ - trigger: auth redirect detected during supervised execution | action: STOP immediately, present options (retry/skip/abort/manual), wait for user choice
432
+ - trigger: unexpected browser state during plan step | action: STOP, take screenshot, present situation to user, wait for explicit choice
433
+ - trigger: supervised mode enabled AND state mismatch detected | action: halt and report before proceeding
434
+ - complexity_routing: micro → auto | small → auto | medium → auto | large → auto | xl → auto
435
+
436
+ ## Fallbacks
437
+
438
+ - condition: daemon binary not found at expected path | action: report installation instructions and stop
439
+ - condition: Chromium not installed | action: instruct user to run "npx playwright install chromium" and stop
440
+ - condition: daemon fails to start within 10 seconds | action: check ~/.ftm-browse/ logs, report binary or Bun issue
441
+ - condition: dev server not running when navigating to localhost | action: report timeout error with the URL attempted
442
+ - condition: stale ref after navigation | action: re-run snapshot -i before retrying click/fill
443
+
444
+ ## Capabilities
445
+
446
+ - cli: `$HOME/.claude/skills/ftm-browse/bin/ftm-browse` | required | headless Chromium control CLI
447
+
448
+ ## Event Payloads
449
+
450
+ ### task_completed
451
+ - skill: string — "ftm-browse"
452
+ - workflow: string — description of the visual verification or interaction performed
453
+ - screenshots: string[] — absolute paths to screenshots taken
454
+ - duration_ms: number — total workflow duration
@@ -0,0 +1,370 @@
1
+ ---
2
+ name: ftm-capture
3
+ description: Extract reusable routines, playbooks, and reference docs from the current session's work. Reads session context (blackboard, daily log, tool history), asks clarifying questions about generalizability, then writes to all three ftm knowledge layers. Use when user says "capture this", "save this as a routine", "make a playbook from this", "ftm capture", "codify this", "turn this into a routine", "extract the pattern", "save what we did", "learn from this", "remember how to do this", "don't make me explain this again".
4
+ ---
5
+
6
+ ## Events
7
+
8
+ ### Emits
9
+ - `capture_complete` — when all three artifacts (routine, playbook, reference doc) are written
10
+ - `experience_recorded` — when the capture is logged to the blackboard experience layer
11
+ - `known_issue_recorded` — when API gotchas or failure workarounds are encoded
12
+
13
+ ### Listens To
14
+ - `task_completed` — can be auto-triggered after task completion to suggest capture
15
+ - `pattern_discovered` — if ftm-retro identifies a recurring workflow, suggest capture
16
+
17
+ # FTM Capture — Session-to-Knowledge Extractor
18
+
19
+ Turns what you just did into reusable automation. Reads the current session's work (blackboard context, daily log, tool calls, experiences), asks 2-4 clarifying questions about generalizability, then writes to all three ftm knowledge layers simultaneously.
20
+
21
+ ## Why This Exists
22
+
23
+ Every time you complete a repeatable workflow (SSO setup, service catalog creation, vendor onboarding, incident response), the knowledge lives only in the conversation. Next session starts from zero. ftm-capture closes this gap by extracting the pattern while context is fresh and writing it to durable storage that ftm-mind, ftm-routine, and eng-buddy can all access.
24
+
25
+ ## Output Artifacts
26
+
27
+ ftm-capture writes to **three locations** simultaneously:
28
+
29
+ | Artifact | Location | Format | Consumer |
30
+ |---|---|---|---|
31
+ | **Routine** | `~/.ftm/routines/{name}.yml` | YAML with phases/steps | `ftm-routine` (executable) |
32
+ | **Playbook** | `~/.claude/eng-buddy/playbooks/{name}.json` | JSON with exact tool params | eng-buddy playbook engine |
33
+ | **Reference Doc** | `~/Documents/Code/panda/docs/playbooks/{name}.md` | Markdown with gotchas | Future agents + humans |
34
+
35
+ All three are kept in sync. The routine is the executable version, the playbook has exact tool parameters, and the reference doc has the context and gotchas.
36
+
37
+ ## Operating Modes
38
+
39
+ ### Mode 1: Explicit Capture (`/ftm capture [name]`)
40
+
41
+ User invokes directly after completing work. This is the primary mode.
42
+
43
+ ### Mode 2: Auto-Suggest (via ftm-retro or ftm-mind)
44
+
45
+ After ftm-retro scores an execution, if it detects a repeatable pattern, it suggests: "This looks like a reusable workflow. Run `/ftm capture` to save it."
46
+
47
+ ftm-mind can also suggest capture when it detects the user doing something they've done before (matching experiences in the blackboard).
48
+
49
+ ### Mode 3: Inline Capture (mid-session)
50
+
51
+ User says "capture this" or "save what we just did" while still working. Capture the completed portion and note what's still in progress.
52
+
53
+ ## Execution Protocol
54
+
55
+ ### Step 1: Gather Session Context
56
+
57
+ Read these files in order:
58
+
59
+ 1. **Blackboard context**: `~/.claude/ftm-state/blackboard/context.json`
60
+ - Extract: `current_task`, `recent_decisions`, `active_constraints`
61
+ 2. **Today's daily log**: `~/.claude/eng-buddy/daily/{today}.md`
62
+ - Extract: completed items, tool calls, blockers encountered, lessons learned
63
+ 3. **Recent experiences**: `~/.claude/ftm-state/blackboard/experiences/index.json`
64
+ - Filter for entries from today's session
65
+ - Load matching experience files for their `lessons` and `decisions_made`
66
+ 4. **Existing routines**: `ls ~/.ftm/routines/` — check if a routine for this workflow already exists
67
+ 5. **Existing playbooks**: `ls ~/.claude/eng-buddy/playbooks/` — check for existing playbook
68
+ 6. **Existing reference docs**: `ls ~/Documents/Code/panda/docs/playbooks/` — check for existing doc
69
+
70
+ If an existing artifact covers this workflow, the capture becomes an **update** not a create. Load the existing version and merge new learnings.
71
+
72
+ ### Step 2: Identify the Pattern
73
+
74
+ From the gathered context, identify:
75
+
76
+ - **Workflow name**: kebab-case identifier (e.g., `sso-full-setup`, `vendor-onboarding`, `incident-response`)
77
+ - **Trigger**: What kicks off this workflow? (ticket type, user request, event)
78
+ - **Phases**: Major stages of the workflow (e.g., "Okta setup", "Freshservice config", "Vendor coordination")
79
+ - **Steps per phase**: Specific actions with tools, parameters, and verification
80
+ - **Decision points**: Where does the workflow branch based on input? (e.g., "SCIM supported?" → yes/no path)
81
+ - **Known issues**: API gotchas, workarounds, things that failed and were fixed
82
+ - **Environment assumptions**: What repo, what API access, what tools are available?
83
+
84
+ ### Step 3: Clarifying Questions (2-4 max)
85
+
86
+ Ask the user focused questions to determine generalizability. DO NOT ask more than 4 questions. Pick the most important from:
87
+
88
+ **Generalizability questions:**
89
+ - "Is this always [SAML/OIDC] or does it vary by vendor?"
90
+ - "Are the approvers always [names] or does that change per app?"
91
+ - "Should this routine always use the API, or sometimes browser?"
92
+ - "Are there apps where [specific step] wouldn't apply?"
93
+
94
+ **Scope questions:**
95
+ - "Should this cover [adjacent step] too, or is that separate?"
96
+ - "Does this workflow change if the app supports SCIM?"
97
+ - "Should I parameterize [specific value] or hardcode it?"
98
+
99
+ **Environment questions:**
100
+ - "Does this only work in the ragnarok repo, or should it be repo-agnostic?"
101
+ - "Are there API access requirements I should document?"
102
+
103
+ ### Step 4: Write the Routine (`~/.ftm/routines/{name}.yml`)
104
+
105
+ Follow the exact YAML format used by ftm-routine:
106
+
107
+ ```yaml
108
+ name: {kebab-case-name}
109
+ description: |
110
+ {What this routine does, when to use it, critical ordering rules}
111
+ trigger: manual
112
+ tags: [{relevant, tags}]
113
+
114
+ # Usage:
115
+ # /ftm-routine {name}
116
+ # or: "{natural language trigger}"
117
+ #
118
+ # Required context:
119
+ # - {param}: {description}
120
+
121
+ phases:
122
+ - name: "Phase N: {Phase Name}"
123
+ steps:
124
+ - name: {Step description}
125
+ action: {api|playwright_cli|python_browser|mcp|skill|routine|comms|manual|wait}
126
+ tool: {tool_name}
127
+ params: {exact parameters}
128
+ notes: |
129
+ {Gotchas, workarounds, known issues}
130
+ approval: {none|review|approve}
131
+
132
+ known_issues:
133
+ - issue: "{Issue name}"
134
+ description: "{What goes wrong}"
135
+ fix: "{How to fix it}"
136
+ ```
137
+
138
+ **Critical rules for routine writing:**
139
+ - Every step must specify the exact tool/action — no vague "do X"
140
+ - Include `notes` on steps that have known gotchas
141
+ - Use `approval: approve` for destructive or externally-visible actions
142
+ - Parameterize with `{curly_braces}` for values that change per invocation
143
+ - Include `known_issues` section with every API/tool gotcha discovered during the session
144
+ - Include environment assumptions (repo, API access, etc.) in the description
145
+
146
+ ### Step 5: Write the Playbook (`~/.claude/eng-buddy/playbooks/{name}.json`)
147
+
148
+ Follow the exact JSON format used by eng-buddy playbooks:
149
+
150
+ ```json
151
+ {
152
+ "id": "{kebab-case-name}",
153
+ "name": "{Human-readable name}",
154
+ "description": "{What and when}",
155
+ "trigger_keywords": ["{keywords}"],
156
+ "input_params": {
157
+ "{param}": {"type": "string", "description": "...", "required": true}
158
+ },
159
+ "steps": [
160
+ {
161
+ "number": 1,
162
+ "description": "{What this step does}",
163
+ "tool": "{exact_tool_name}",
164
+ "tool_params": {"exact": "params"},
165
+ "requires_human": false,
166
+ "notes": "{Gotchas}"
167
+ }
168
+ ],
169
+ "rollback": {
170
+ "description": "{How to undo}",
171
+ "steps": ["{exact}", "{reversal}", "{steps}"]
172
+ },
173
+ "known_issues": [
174
+ {"issue": "{Name}", "description": "...", "fix": "..."}
175
+ ],
176
+ "confidence": 1.0,
177
+ "version": 1,
178
+ "executions": 0,
179
+ "source": "captured",
180
+ "related_links": {}
181
+ }
182
+ ```
183
+
184
+ **Critical rules for playbook writing:**
185
+ - Every step must have exact `tool` and `tool_params` — eng-buddy executes these literally
186
+ - Include `rollback` section with exact reversal steps
187
+ - Set `requires_human: true` for steps needing auth, visual verification, or judgment
188
+ - `source: "captured"` distinguishes from `"manual"` or `"observed"`
189
+
190
+ ### Step 6: Write the Reference Doc (`~/Documents/Code/panda/docs/playbooks/{name}.md`)
191
+
192
+ This is the human-readable + agent-readable reference that captures context, gotchas, and decision rationale:
193
+
194
+ ```markdown
195
+ # {Workflow Name} — {Type} Playbook
196
+
197
+ ## Purpose
198
+ {What this workflow does and when to use it}
199
+
200
+ ## Execution Method
201
+ {Primary: API / Browser / Mixed — and why}
202
+
203
+ ## Prerequisites
204
+ {API access, repo, tools, credentials needed}
205
+
206
+ ## Phases
207
+ ### Phase 1: {Name}
208
+ {Steps with exact tool calls, selectors, API endpoints}
209
+
210
+ ### Phase 2: {Name}
211
+ ...
212
+
213
+ ## Known Issues & Gotchas
214
+ {Every API quirk, UI gotcha, and workaround discovered}
215
+
216
+ ## Decision Points
217
+ {Where the workflow branches and how to decide}
218
+
219
+ ## Information Needed from User
220
+ {What to collect before starting}
221
+ ```
222
+
223
+ ### Step 7: Record Experience
224
+
225
+ Write to `~/.claude/ftm-state/blackboard/experiences/{name}-capture.json`:
226
+
227
+ ```json
228
+ {
229
+ "id": "{name}-capture",
230
+ "timestamp": "{ISO timestamp}",
231
+ "task_type": "knowledge-capture",
232
+ "tags": ["{workflow-type}", "capture", "routine", "playbook"],
233
+ "outcome": "success",
234
+ "description": "Captured {workflow name} as routine + playbook + reference doc",
235
+ "lessons": ["{key learnings encoded}"],
236
+ "files_touched": [
237
+ "~/.ftm/routines/{name}.yml",
238
+ "~/.claude/eng-buddy/playbooks/{name}.json",
239
+ "~/Documents/Code/panda/docs/playbooks/{name}.md"
240
+ ],
241
+ "confidence": 1.0
242
+ }
243
+ ```
244
+
245
+ Update `experiences/index.json` with the new entry.
246
+
247
+ ### Step 8: Update Blackboard Context
248
+
249
+ Update `~/.claude/ftm-state/blackboard/context.json`:
250
+ - Set `current_task.status` to reflect capture completion
251
+ - Add to `recent_decisions`: what was captured and why
252
+
253
+ ### Step 9: Report to User
254
+
255
+ Show a summary:
256
+
257
+ ```
258
+ Captured: {workflow name}
259
+
260
+ Written to:
261
+ Routine: ~/.ftm/routines/{name}.yml
262
+ Playbook: ~/.claude/eng-buddy/playbooks/{name}.json
263
+ Reference: ~/Documents/Code/panda/docs/playbooks/{name}.md
264
+
265
+ Known issues encoded: {count}
266
+ Parameters: {list of parameterized values}
267
+ Phases: {count} phases, {count} steps
268
+
269
+ Next time, run: /ftm-routine {name}
270
+ ```
271
+
272
+ ## Updating Existing Artifacts
273
+
274
+ If Step 1 finds an existing routine/playbook/reference doc:
275
+
276
+ 1. Load the existing version
277
+ 2. Show the user what exists vs what's new
278
+ 3. Ask: "Update existing or create new version?"
279
+ 4. If updating:
280
+ - Merge new steps into existing phases
281
+ - Add new known_issues (don't duplicate)
282
+ - Increment `version` in playbook JSON
283
+ - Add "Updated: {date} — {what changed}" to reference doc
284
+ 5. If creating new:
285
+ - Use a different name (e.g., `sso-full-setup-v2`)
286
+
287
+ ## Integration Points
288
+
289
+ ### ftm-mind
290
+ ftm-mind knows about ftm-capture in its capability inventory. When ftm-mind detects:
291
+ - User completing a repeatable workflow
292
+ - Matching experiences in the blackboard (same task_type done 2+ times)
293
+ - User saying anything about "remembering" or "next time"
294
+
295
+ It should suggest: "This looks like a reusable pattern. Want me to `/ftm capture` it?"
296
+
297
+ ### ftm-retro
298
+ After ftm-retro scores an execution, if the workflow is repeatable, it should note: "Consider running `/ftm capture {name}` to save this as a routine."
299
+
300
+ ### ftm-routine
301
+ ftm-routine reads from `~/.ftm/routines/`. Anything ftm-capture writes there becomes immediately available via `/ftm-routine {name}`.
302
+
303
+ ### eng-buddy
304
+ eng-buddy's playbook engine reads from `~/.claude/eng-buddy/playbooks/`. Captured playbooks show up on the dashboard's Playbooks tab.
305
+
306
+ ### Environment Awareness
307
+
308
+ When capturing, always note the environment context:
309
+ - **If in `~/Documents/Code/ragnarok`**: Full API access to Okta, Freshservice, Slack, AWS (via shared_services). Prefer API over browser.
310
+ - **If in other repos**: May not have API access. Default to browser automation or MCP tools.
311
+ - **Always document**: Which APIs are used, what credentials are needed, what repo provides the client libraries.
312
+
313
+ This prevents future sessions from trying to use APIs they don't have access to.
314
+
315
+ ## Requirements
316
+
317
+ - reference: `~/.claude/ftm-state/blackboard/context.json` | required | current task and recent decisions for pattern extraction
318
+ - reference: `~/.claude/eng-buddy/daily/{today}.md` | optional | daily log for completed items and tool calls
319
+ - reference: `~/.claude/ftm-state/blackboard/experiences/index.json` | required | today's session experiences
320
+ - reference: `~/.ftm/routines/` | optional | check for existing routines before creating new one
321
+ - reference: `~/.claude/eng-buddy/playbooks/` | optional | check for existing playbooks before creating
322
+ - reference: `~/Documents/Code/panda/docs/playbooks/` | optional | check for existing reference docs before creating
323
+
324
+ ## Risk
325
+
326
+ - level: low_write
327
+ - scope: writes YAML routine to ~/.ftm/routines/, JSON playbook to ~/.claude/eng-buddy/playbooks/, and Markdown reference doc to ~/Documents/Code/panda/docs/playbooks/; writes experience to blackboard; does not modify project source code
328
+ - rollback: delete the three written artifact files; remove experience entry from blackboard experiences/
329
+
330
+ ## Approval Gates
331
+
332
+ - trigger: existing artifact found for this workflow name | action: show existing vs new content, ask user to confirm update or create new version
333
+ - trigger: Step 3 clarifying questions answered | action: proceed to write all three artifacts automatically (no additional gate)
334
+ - complexity_routing: micro → auto | small → auto | medium → auto | large → auto | xl → auto
335
+
336
+ ## Fallbacks
337
+
338
+ - condition: blackboard context.json missing | action: ask user directly about the workflow to capture instead of reading from blackboard
339
+ - condition: daily log missing or empty | action: skip daily log extraction, rely on conversation context and blackboard experiences
340
+ - condition: ~/.ftm/routines/ directory doesn't exist | action: create directory before writing routine
341
+ - condition: docs/playbooks/ directory doesn't exist | action: create directory before writing reference doc
342
+ - condition: existing artifact found but cannot be parsed | action: treat as missing, create fresh artifact
343
+
344
+ ## Capabilities
345
+
346
+ - mcp: none required directly (reads files and writes artifacts)
347
+ - env: none required
348
+
349
+ ## Event Payloads
350
+
351
+ ### capture_complete
352
+ - skill: string — "ftm-capture"
353
+ - workflow_name: string — kebab-case name of captured workflow
354
+ - routine_path: string — absolute path to written routine YAML
355
+ - playbook_path: string — absolute path to written playbook JSON
356
+ - reference_path: string — absolute path to written reference doc
357
+ - phases_count: number — number of workflow phases captured
358
+ - steps_count: number — total steps across all phases
359
+ - known_issues_count: number — API gotchas encoded
360
+
361
+ ### experience_recorded
362
+ - skill: string — "ftm-capture"
363
+ - experience_path: string — path to written experience file
364
+ - workflow_name: string — name of captured workflow
365
+
366
+ ### known_issue_recorded
367
+ - skill: string — "ftm-capture"
368
+ - workflow_name: string — workflow this issue belongs to
369
+ - issue: string — issue name
370
+ - fix: string — remediation approach encoded
@@ -0,0 +1,4 @@
1
+ ---
2
+ name: ftm-capture
3
+ description: Extract reusable routines, playbooks, and reference docs from the current session's work. Reads session context (blackboard, daily log, tool history), asks clarifying questions about generalizability, then writes to all three ftm knowledge layers (~/.ftm/routines/, ~/.claude/eng-buddy/playbooks/, ~/Documents/Code/panda/docs/playbooks/). Use when user says "capture this", "save this as a routine", "make a playbook from this", "ftm capture", "codify this", "turn this into a routine", "extract the pattern", "save what we did", or after completing a repeatable workflow that should be reusable. Also triggers on "learn from this", "remember how to do this", "don't make me explain this again".
4
+ ---
@@ -300,3 +300,62 @@ When returning an error before Codex runs:
300
300
  ### Remaining Issues
301
301
  - [error detail]
302
302
  ```
303
+
304
+ ## Requirements
305
+
306
+ - tool: `codex` | required | OpenAI Codex CLI for adversarial validation
307
+ - reference: `{project_root}/INTENT.md` | optional | root intent documentation for conflict detection
308
+ - reference: `{project_root}/STYLE.md` | optional | code style standards for quality enforcement
309
+ - reference: module-level `INTENT.md` files | optional | per-module intent for targeted conflict detection
310
+ - reference: `~/.claude/ftm-state/blackboard/context.json` | optional | session state
311
+ - reference: `~/.claude/ftm-state/blackboard/experiences/index.json` | optional | prior validation patterns
312
+
313
+ ## Risk
314
+
315
+ - level: medium_write
316
+ - scope: Codex modifies source files and commits fixes directly in the project working directory (--yolo mode); writes entries to DEBUG.md; writes structured output to /tmp/codex-result-*.md
317
+ - rollback: git revert codex fix commits; delete /tmp/codex-result-*.md cleanup is automatic
318
+
319
+ ## Approval Gates
320
+
321
+ - trigger: codex gate returns PASS_WITH_FIXES and INTENT.md conflict detected | action: auto-invoke ftm-council for arbitration before accepting or reverting the fix
322
+ - trigger: codex gate returns FAIL after 2 fix attempts | action: report remaining issues to ftm-executor caller, wait for direction
323
+ - trigger: codex CLI not found | action: return FAIL immediately with install instructions, do not proceed
324
+ - complexity_routing: micro → auto | small → auto | medium → auto | large → auto | xl → auto
325
+
326
+ ## Fallbacks
327
+
328
+ - condition: codex CLI not installed | action: return FAIL with "Codex CLI not found. Install with: npm install -g @openai/codex"
329
+ - condition: codex times out after 600s | action: read partial output if available, return PARTIAL results with note; if no output, return FAIL
330
+ - condition: output file empty or missing | action: return FAIL with "Codex output not found — may have crashed"
331
+ - condition: INTENT.md missing at project root | action: note in prompt to Codex and continue without INTENT validation
332
+ - condition: STYLE.md missing | action: note in prompt to Codex and continue without style enforcement
333
+
334
+ ## Capabilities
335
+
336
+ - cli: `codex` | required | OpenAI Codex CLI (npm install -g @openai/codex)
337
+ - env: `OPENAI_API_KEY` | required | authentication for Codex CLI execution
338
+
339
+ ## Event Payloads
340
+
341
+ ### review_complete
342
+ - skill: string — "ftm-codex-gate"
343
+ - mode: string — "wave" | "single-task"
344
+ - status: string — "PASS" | "PASS_WITH_FIXES" | "FAIL"
345
+ - tests_formed: number — adversarial test scenarios generated
346
+ - tests_passed: number — test scenarios that passed
347
+ - fixes_applied: number — fixes committed by Codex
348
+ - quality_issues: number — style/quality violations found
349
+ - intent_conflicts: number — INTENT.md conflicts detected
350
+
351
+ ### issue_found
352
+ - skill: string — "ftm-codex-gate"
353
+ - file_path: string — file where issue was found
354
+ - line: number | null — line number if available
355
+ - description: string — issue description
356
+ - type: string — "test_failure" | "quality_violation" | "intent_conflict"
357
+
358
+ ### task_completed
359
+ - skill: string — "ftm-codex-gate"
360
+ - status: string — "PASS" | "PASS_WITH_FIXES" | "FAIL"
361
+ - output_file: string — path to Codex result file