feed-the-machine 1.2.0 → 1.3.1
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.
- package/bin/install.mjs +272 -25
- package/ftm-audit/SKILL.md +383 -57
- package/ftm-brainstorm/SKILL.md +119 -51
- package/ftm-config/SKILL.md +1 -1
- package/ftm-council/SKILL.md +259 -31
- package/ftm-dashboard/SKILL.md +10 -10
- package/ftm-debug/SKILL.md +861 -54
- package/ftm-diagram/SKILL.md +1 -1
- package/ftm-executor/SKILL.md +6 -6
- package/ftm-git/SKILL.md +209 -22
- package/ftm-inbox/bin/start.sh +1 -1
- package/ftm-inbox/bin/status.sh +1 -1
- package/ftm-inbox/bin/stop.sh +1 -1
- package/ftm-intent/SKILL.md +0 -1
- package/ftm-mind/SKILL.md +861 -11
- package/ftm-mind/references/event-registry.md +30 -0
- package/ftm-pause/SKILL.md +256 -37
- package/ftm-resume/SKILL.md +380 -75
- package/ftm-retro/SKILL.md +164 -27
- package/ftm-upgrade/SKILL.md +4 -4
- package/hooks/ftm-blackboard-enforcer.sh +29 -27
- package/hooks/ftm-plan-gate.sh +21 -25
- package/install.sh +244 -112
- package/package.json +1 -1
package/ftm-retro/SKILL.md
CHANGED
|
@@ -51,19 +51,73 @@ Never ask the user to provide data you can find yourself. Read the files.
|
|
|
51
51
|
|
|
52
52
|
---
|
|
53
53
|
|
|
54
|
-
## Scoring
|
|
54
|
+
## Scoring Dimensions
|
|
55
55
|
|
|
56
|
-
Score
|
|
56
|
+
Score each dimension 0–10 with a citation to specific data. Do not estimate without evidence — if data is missing, note it and score conservatively.
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
### 1. Wave Parallelism Efficiency (0–10)
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
2. **Audit Pass Rate** — what percentage of tasks passed ftm-audit on the first attempt?
|
|
62
|
-
3. **Codex Gate Pass Rate** — what percentage of waves passed the ftm-codex-gate on the first attempt?
|
|
63
|
-
4. **Retry and Fix Count** — how many total review-fix cycles were needed? Lower is better.
|
|
64
|
-
5. **Execution Smoothness** — evidence-grounded assessment of blockers, ambiguities, and manual interventions.
|
|
60
|
+
Were independent tasks actually dispatched in parallel? Could more tasks have been parallelized?
|
|
65
61
|
|
|
66
|
-
Every
|
|
62
|
+
- **10**: Every task that could run in parallel did. No serial bottlenecks where parallelism was possible.
|
|
63
|
+
- **7–9**: Minor serial steps that could have been parallel (e.g., final post-processing tasks run sequentially).
|
|
64
|
+
- **4–6**: Significant parallelism opportunities missed. Tasks that had no dependencies ran serially.
|
|
65
|
+
- **1–3**: Nearly all tasks ran serially despite having no dependencies on each other.
|
|
66
|
+
- **0**: Everything was serial regardless of dependency structure.
|
|
67
|
+
|
|
68
|
+
Evidence to cite: wave structure from PROGRESS.md, task dependency graph, agent dispatch timestamps.
|
|
69
|
+
|
|
70
|
+
### 2. Audit Pass Rate (0–10)
|
|
71
|
+
|
|
72
|
+
What percentage of tasks passed ftm-audit on the first attempt?
|
|
73
|
+
|
|
74
|
+
- **10**: 100% first-pass. No task needed a fix cycle.
|
|
75
|
+
- **8**: 90%+ first-pass. One or two tasks needed minor fixes.
|
|
76
|
+
- **6**: 75–89% first-pass.
|
|
77
|
+
- **4**: 50–74% first-pass. Roughly half the tasks needed audit remediation.
|
|
78
|
+
- **2**: Below 50% first-pass.
|
|
79
|
+
- **0**: Every single task failed audit on the first attempt.
|
|
80
|
+
|
|
81
|
+
Evidence to cite: per-task audit results (pass/fail counts, auto-fix counts, manual-fix counts).
|
|
82
|
+
|
|
83
|
+
### 3. Codex Gate Pass Rate (0–10)
|
|
84
|
+
|
|
85
|
+
What percentage of waves passed the ftm-codex-gate on the first attempt?
|
|
86
|
+
|
|
87
|
+
- **10**: All waves passed on first gate run.
|
|
88
|
+
- **7–9**: One wave needed a fix-and-retry.
|
|
89
|
+
- **4–6**: Multiple waves needed retries.
|
|
90
|
+
- **1–3**: Most waves failed the gate at least once.
|
|
91
|
+
- **0**: Every wave failed the gate.
|
|
92
|
+
|
|
93
|
+
Evidence to cite: codex gate results per wave (pass/fail, failure types).
|
|
94
|
+
|
|
95
|
+
### 4. Retry and Fix Count (0–10)
|
|
96
|
+
|
|
97
|
+
How many total review-fix cycles were needed across all tasks and waves? Lower is better.
|
|
98
|
+
|
|
99
|
+
Formula: score = max(0, 10 - (total_retries / task_count) * 5)
|
|
100
|
+
|
|
101
|
+
- **10**: Zero retries.
|
|
102
|
+
- **8**: Fewer than 0.5 retries per task on average.
|
|
103
|
+
- **6**: 0.5–1.0 retries per task.
|
|
104
|
+
- **4**: 1–2 retries per task.
|
|
105
|
+
- **2**: 2–3 retries per task.
|
|
106
|
+
- **0**: More than 3 retries per task on average.
|
|
107
|
+
|
|
108
|
+
Evidence to cite: total retries, broken down by type (audit fix, codex gate retry, manual intervention).
|
|
109
|
+
|
|
110
|
+
### 5. Execution Smoothness (0–10)
|
|
111
|
+
|
|
112
|
+
Subjective but evidence-grounded assessment. Were there blockers, ambiguous plan steps, confusing errors, or required manual interventions?
|
|
113
|
+
|
|
114
|
+
- **10**: Fully autonomous from start to finish. No blockers, no ambiguity, no manual steps.
|
|
115
|
+
- **7–9**: Minor friction — one clarification needed, one unexpected error handled gracefully.
|
|
116
|
+
- **4–6**: Moderate friction — multiple ambiguities, one blocker that paused execution, one manual intervention.
|
|
117
|
+
- **1–3**: Significant friction — repeated blockers, unclear plan steps that caused wrong-direction work, multiple manual interventions.
|
|
118
|
+
- **0**: Execution could not proceed without constant human steering.
|
|
119
|
+
|
|
120
|
+
Evidence to cite: error log entries, any manual interventions recorded in PROGRESS.md, plan ambiguities encountered.
|
|
67
121
|
|
|
68
122
|
---
|
|
69
123
|
|
|
@@ -75,28 +129,122 @@ Every score requires a citation to specific data. If data for a dimension is una
|
|
|
75
129
|
mkdir -p ~/.claude/ftm-retros/
|
|
76
130
|
```
|
|
77
131
|
|
|
78
|
-
### Step 2:
|
|
132
|
+
### Step 2: Generate plan slug
|
|
79
133
|
|
|
80
|
-
|
|
134
|
+
Take the plan title, lowercase it, replace spaces with hyphens, strip all non-alphanumeric characters except hyphens.
|
|
81
135
|
|
|
82
|
-
|
|
136
|
+
Examples:
|
|
137
|
+
- "FTM Ecosystem Expansion" → `ftm-ecosystem-expansion`
|
|
138
|
+
- "Fix Auth Bug + Rate Limiting" → `fix-auth-bug-rate-limiting`
|
|
139
|
+
- "v2.0 API Refactor" → `v20-api-refactor`
|
|
140
|
+
|
|
141
|
+
### Step 3: Check for past retros
|
|
142
|
+
|
|
143
|
+
Before writing anything, check whether any `.md` files exist in `~/.claude/ftm-retros/`. If they do, read them all. You will use them for the Pattern Analysis section.
|
|
83
144
|
|
|
84
|
-
|
|
145
|
+
### Step 4: Write the report
|
|
85
146
|
|
|
86
147
|
Save to: `~/.claude/ftm-retros/{plan-slug}-{YYYY-MM-DD}.md`
|
|
87
148
|
|
|
149
|
+
Use this exact format:
|
|
150
|
+
|
|
151
|
+
```markdown
|
|
152
|
+
# Retro: {Plan Title}
|
|
153
|
+
|
|
154
|
+
**Date:** {YYYY-MM-DD}
|
|
155
|
+
**Plan:** {absolute path to plan file}
|
|
156
|
+
**Duration:** {total execution time, e.g. "47 minutes"}
|
|
157
|
+
|
|
158
|
+
## Scores
|
|
159
|
+
|
|
160
|
+
| Dimension | Score | Notes |
|
|
161
|
+
|-----------|-------|-------|
|
|
162
|
+
| Wave Parallelism | X/10 | {1-sentence justification with data} |
|
|
163
|
+
| Audit Pass Rate | X/10 | {N}/{total} tasks first-pass |
|
|
164
|
+
| Codex Gate Pass Rate | X/10 | {N}/{total} waves first-pass |
|
|
165
|
+
| Retry/Fix Count | X/10 | {total retries} across {N} tasks |
|
|
166
|
+
| Execution Smoothness | X/10 | {1-sentence justification} |
|
|
167
|
+
|
|
168
|
+
**Overall: {sum}/50**
|
|
169
|
+
|
|
170
|
+
## Raw Data
|
|
171
|
+
|
|
172
|
+
- Tasks: {N}
|
|
173
|
+
- Waves: {N}
|
|
174
|
+
- Agents spawned: {N}
|
|
175
|
+
- Audit findings: {N} total ({N} auto-fixed, {N} manual)
|
|
176
|
+
- Codex gate results: Wave 1: pass | Wave 2: fail → pass | Wave 3: pass
|
|
177
|
+
- Errors/blockers: {list any, or "none"}
|
|
178
|
+
|
|
179
|
+
## What Went Well
|
|
180
|
+
|
|
181
|
+
{2–4 specific observations, each grounded in a data point or task number.}
|
|
182
|
+
|
|
183
|
+
Example format:
|
|
184
|
+
- **Task 3 (auth middleware)** completed in a single commit with zero audit findings. The agent prompt had clear acceptance criteria and a scoped file list — the agent never wandered.
|
|
185
|
+
- **Wave 2 parallelism** was fully utilized: all 4 tasks dispatched simultaneously, cutting estimated serial time from ~32 minutes to ~9 minutes.
|
|
186
|
+
|
|
187
|
+
## What Was Slow
|
|
188
|
+
|
|
189
|
+
{2–4 specific bottlenecks with timing data or retry counts where available.}
|
|
190
|
+
|
|
191
|
+
Example format:
|
|
192
|
+
- **ftm-audit Phase 1 (knip)** repeated full project analysis for each task in wave 3, even though tasks only touched 2–3 files each. Added ~40s × 5 tasks = ~3.5 minutes of unnecessary scanning.
|
|
193
|
+
- **Task 7 needed 3 audit fix cycles** due to an import path that kept regenerating incorrectly. The agent prompt did not specify the alias configuration in tsconfig.paths.
|
|
194
|
+
|
|
195
|
+
## Proposed Improvements
|
|
196
|
+
|
|
197
|
+
{3–5 specific, actionable suggestions. Each must identify: which skill to change, what to change exactly, and why it would help.}
|
|
198
|
+
|
|
199
|
+
Format each as:
|
|
200
|
+
**N. {Short title}** — {Skill to change} — {Specific change} — {Expected impact}
|
|
201
|
+
|
|
202
|
+
Examples:
|
|
203
|
+
1. **Cache knip results within a wave** — ftm-audit — In Phase 1, check whether knip results are already cached for the current wave (via a temp file at `/tmp/ftm-knip-cache-{wave-id}.json`). Only re-run knip if the cache is missing or if the files changed by this task differ from cached scope. Expected: 3× speedup for ftm-audit on large projects with many tasks per wave.
|
|
204
|
+
2. **Dispatch Instrumentor and Researcher in parallel** — ftm-debug — These two agents have no shared state and currently run sequentially. Dispatch them simultaneously. Expected: ~40% reduction in ftm-debug total runtime.
|
|
205
|
+
3. **Add tsconfig.paths to agent context for TypeScript projects** — ftm-executor — When generating agent prompts for TypeScript tasks, include the relevant `paths` aliases from `tsconfig.json`. Expected: eliminates the import-alias regeneration loop that caused 3 retries on Task 7.
|
|
206
|
+
|
|
207
|
+
## Pattern Analysis
|
|
208
|
+
|
|
209
|
+
{Only include this section if past retros exist in ~/.claude/ftm-retros/}
|
|
210
|
+
|
|
211
|
+
### Recurring Issues
|
|
212
|
+
|
|
213
|
+
{List problems that appeared in 2 or more retros. Format: "Issue description — appeared in: retro-slug-1, retro-slug-2"}
|
|
214
|
+
|
|
215
|
+
### Score Trends
|
|
216
|
+
|
|
217
|
+
{Compare overall scores across retros. Are they improving, declining, or stable? Cite actual numbers.}
|
|
218
|
+
|
|
219
|
+
Example: Overall scores: 32/50 → 38/50 → 41/50 across the last 3 retros. Parallelism and smoothness improving; audit pass rate stuck at 6/10 for all three runs.
|
|
220
|
+
|
|
221
|
+
### Unaddressed Suggestions
|
|
222
|
+
|
|
223
|
+
{List proposed improvements from past retros that have not yet been implemented. These get escalated — flag them explicitly.}
|
|
224
|
+
|
|
225
|
+
Format: "**[ESCALATED]** {suggestion} — first proposed in {retro-slug-date}, appeared {N} times"
|
|
226
|
+
```
|
|
227
|
+
|
|
88
228
|
---
|
|
89
229
|
|
|
90
230
|
## Key Behaviors
|
|
91
231
|
|
|
232
|
+
### Evidence-first scoring
|
|
233
|
+
|
|
234
|
+
Every score needs a citation. "Tasks passed audit" is not a citation. "12/14 tasks passed audit on first attempt; Tasks 3 and 9 each needed one auto-fix cycle" is a citation. If the data to score a dimension is genuinely unavailable, note the gap explicitly and score conservatively (assume worst case for that dimension).
|
|
235
|
+
|
|
92
236
|
### Improvement specificity
|
|
93
237
|
|
|
94
|
-
"Improve parallelism" is not an improvement proposal. "Add a dependency pre-check step to ftm-executor Phase 2 that flags tasks with no declared dependencies as parallelizable, and warn when they are dispatched serially" is an improvement proposal. Every proposed improvement must be concrete enough that a future session could implement it from the description alone.
|
|
238
|
+
"Improve parallelism" is not an improvement proposal. "Add a dependency pre-check step to ftm-executor Phase 2 that flags tasks with no declared dependencies as parallelizable, and warn when they are dispatched serially" is an improvement proposal. Every proposed improvement must be concrete enough that a future session could implement it from the description alone without asking clarifying questions.
|
|
95
239
|
|
|
96
240
|
### Pattern escalation
|
|
97
241
|
|
|
98
242
|
Recurring issues that have appeared in 3+ retros without being addressed should be flagged with `[ESCALATED - 3+ occurrences]` and moved to the top of the Proposed Improvements list. These are systemic problems, not one-off noise.
|
|
99
243
|
|
|
244
|
+
### No vibes
|
|
245
|
+
|
|
246
|
+
Do not write "the execution felt smooth" or "agents seemed efficient." Write "0 manual interventions were required and all errors were caught and auto-resolved by ftm-audit Phase 2." The report is read by future executions that need to calibrate behavior, not by humans looking for encouragement.
|
|
247
|
+
|
|
100
248
|
---
|
|
101
249
|
|
|
102
250
|
## Output
|
|
@@ -111,7 +259,7 @@ Top issue: {single most impactful bottleneck in one sentence}
|
|
|
111
259
|
Top suggestion: {single highest-value proposed improvement in one sentence}
|
|
112
260
|
```
|
|
113
261
|
|
|
114
|
-
Do not print the full report to the terminal — it lives in the file.
|
|
262
|
+
Do not print the full report to the terminal — it lives in the file. The summary above is sufficient for the user to know the run completed and where to find details.
|
|
115
263
|
|
|
116
264
|
---
|
|
117
265
|
|
|
@@ -137,7 +285,7 @@ Confidence: [low/medium/high]"
|
|
|
137
285
|
|
|
138
286
|
### Experience Entry Creation
|
|
139
287
|
|
|
140
|
-
Write a structured experience entry to `~/.claude/ftm-state/blackboard/experiences/YYYY-MM-DD_task-slug.json
|
|
288
|
+
Write a structured experience entry to `~/.claude/ftm-state/blackboard/experiences/YYYY-MM-DD_task-slug.json` following the schema in blackboard-schema.md.
|
|
141
289
|
|
|
142
290
|
Key fields:
|
|
143
291
|
- `task_type`: derived from the task
|
|
@@ -177,17 +325,6 @@ During the first ~10 interactions (when `experiences/index.json` has `total_coun
|
|
|
177
325
|
- Set `confidence: "low"` on all entries
|
|
178
326
|
- Prioritize breadth of recording over depth of analysis
|
|
179
327
|
|
|
180
|
-
## Blackboard Write
|
|
181
|
-
|
|
182
|
-
After completing, update:
|
|
183
|
-
1. `~/.claude/ftm-state/blackboard/context.json`:
|
|
184
|
-
- Set current_task status to "complete"
|
|
185
|
-
- Append decision summary to recent_decisions (cap at 10)
|
|
186
|
-
- Update session_metadata.skills_invoked and last_updated
|
|
187
|
-
2. Write experience file to `~/.claude/ftm-state/blackboard/experiences/YYYY-MM-DD_task-slug.json`
|
|
188
|
-
3. Update `experiences/index.json` with the new entry
|
|
189
|
-
4. Emit `task_completed`
|
|
190
|
-
|
|
191
328
|
## Requirements
|
|
192
329
|
|
|
193
330
|
- reference: `PROGRESS.md` | optional | executor progress log for auto-triggered mode
|
package/ftm-upgrade/SKILL.md
CHANGED
|
@@ -13,7 +13,7 @@ description: Self-upgrade mechanism for ftm skills ecosystem. Checks GitHub Rele
|
|
|
13
13
|
|
|
14
14
|
# ftm-upgrade
|
|
15
15
|
|
|
16
|
-
Self-upgrade mechanism for the ftm skills ecosystem. Fetches the latest release from `kkudumu/ftm-
|
|
16
|
+
Self-upgrade mechanism for the ftm skills ecosystem. Fetches the latest release from `kkudumu/ftm-skills` on GitHub, compares it to the locally installed version, and copies updated skill files in place.
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
@@ -135,7 +135,7 @@ Map `CHECK_FAILED <reason>` codes to user-facing messages:
|
|
|
135
135
|
|---|---|
|
|
136
136
|
| `gh_not_installed` | GitHub CLI is not installed. Install it with: `brew install gh` (macOS) or see https://cli.github.com |
|
|
137
137
|
| `no_internet` | Cannot reach GitHub. Check your internet connection and try again. |
|
|
138
|
-
| `repo_not_found` | Repository `kkudumu/ftm-
|
|
138
|
+
| `repo_not_found` | Repository `kkudumu/ftm-skills` not found. Verify you have access to the repository. |
|
|
139
139
|
| `no_releases_found` | No releases found in the repository yet. Check back later. |
|
|
140
140
|
| any other reason | Version check failed: `<reason>`. Try running manually: `bash ~/.claude/skills/ftm-upgrade/scripts/check-version.sh` |
|
|
141
141
|
|
|
@@ -148,9 +148,9 @@ Map `CHECK_FAILED <reason>` codes to user-facing messages:
|
|
|
148
148
|
| `~/.claude/skills/ftm-upgrade/scripts/check-version.sh` | Query GitHub for latest release, cache result 60 min |
|
|
149
149
|
| `~/.claude/skills/ftm-upgrade/scripts/upgrade.sh` | Download and install latest release |
|
|
150
150
|
|
|
151
|
-
**Cache location**: `~/.cache/ftm-
|
|
151
|
+
**Cache location**: `~/.cache/ftm-skills/version-check`
|
|
152
152
|
**Version file**: `~/.claude/skills/ftm-version.txt`
|
|
153
|
-
**Repo**: `kkudumu/ftm-
|
|
153
|
+
**Repo**: `kkudumu/ftm-skills`
|
|
154
154
|
|
|
155
155
|
## Requirements
|
|
156
156
|
|
|
@@ -1,41 +1,39 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# ftm-blackboard-enforcer.sh
|
|
3
|
-
# Stop hook that
|
|
4
|
-
#
|
|
5
|
-
# to write the experience first.
|
|
3
|
+
# Stop hook that nudges Claude to record an experience if meaningful work
|
|
4
|
+
# was done but no blackboard entry was written.
|
|
6
5
|
#
|
|
7
|
-
#
|
|
6
|
+
# Uses additionalContext (not "decision: block") so Claude can still act on
|
|
7
|
+
# the reminder. A blocking stop creates a deadlock — Claude can't write files
|
|
8
|
+
# after the user ends the conversation.
|
|
9
|
+
#
|
|
10
|
+
# "Meaningful work" = 3+ edits tracked by the edit counter,
|
|
8
11
|
# or ftm skills were invoked (checked via context.json).
|
|
9
12
|
#
|
|
10
13
|
# Hook: Stop
|
|
11
14
|
|
|
12
15
|
set -euo pipefail
|
|
13
16
|
|
|
17
|
+
# shellcheck disable=SC2034
|
|
14
18
|
INPUT=$(cat)
|
|
15
19
|
|
|
16
|
-
# Prevent infinite loop — if this hook already fired, let Claude stop
|
|
17
|
-
STOP_HOOK_ACTIVE=$(echo "$INPUT" | jq -r '.stop_hook_active // false')
|
|
18
|
-
if [[ "$STOP_HOOK_ACTIVE" == "true" ]]; then
|
|
19
|
-
exit 0
|
|
20
|
-
fi
|
|
21
|
-
|
|
22
20
|
STATE_DIR="$HOME/.claude/ftm-state"
|
|
23
21
|
BB_DIR="$STATE_DIR/blackboard"
|
|
24
22
|
EDIT_COUNTER="$STATE_DIR/.edit-count"
|
|
25
23
|
CONTEXT_FILE="$BB_DIR/context.json"
|
|
26
24
|
EXPERIENCES_DIR="$BB_DIR/experiences"
|
|
27
|
-
EXPERIENCE_INDEX="$EXPERIENCES_DIR/index.json"
|
|
28
|
-
|
|
29
|
-
CURRENT_SESSION="${CLAUDE_SESSION_ID:-unknown}"
|
|
30
25
|
|
|
31
26
|
# Check 1: Were there meaningful edits this session?
|
|
27
|
+
# Edit counter contains just a number now (no session ID).
|
|
28
|
+
# If the counter file is recent (< 4 hours) and >= 3, count as meaningful.
|
|
32
29
|
HAD_EDITS=false
|
|
33
30
|
if [[ -f "$EDIT_COUNTER" ]]; then
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
COUNTER_AGE=$(( $(date +%s) - $(stat -c %Y "$EDIT_COUNTER" 2>/dev/null || stat -f %m "$EDIT_COUNTER" 2>/dev/null || echo "0") ))
|
|
32
|
+
if [[ "$COUNTER_AGE" -lt 14400 ]]; then
|
|
33
|
+
STORED_COUNT=$(cat "$EDIT_COUNTER" 2>/dev/null || echo "0")
|
|
34
|
+
if [[ "$STORED_COUNT" -ge 3 ]]; then
|
|
35
|
+
HAD_EDITS=true
|
|
36
|
+
fi
|
|
39
37
|
fi
|
|
40
38
|
fi
|
|
41
39
|
|
|
@@ -48,8 +46,10 @@ if [[ -f "$CONTEXT_FILE" ]]; then
|
|
|
48
46
|
fi
|
|
49
47
|
fi
|
|
50
48
|
|
|
51
|
-
# If no meaningful work detected, allow stop
|
|
49
|
+
# If no meaningful work detected, allow stop quietly
|
|
52
50
|
if [[ "$HAD_EDITS" == "false" && "$HAD_SKILLS" == "false" ]]; then
|
|
51
|
+
# Clean up session markers
|
|
52
|
+
rm -f "$EDIT_COUNTER" "$STATE_DIR/.plan-presented" 2>/dev/null
|
|
53
53
|
exit 0
|
|
54
54
|
fi
|
|
55
55
|
|
|
@@ -58,19 +58,17 @@ TODAY=$(date +%Y-%m-%d)
|
|
|
58
58
|
HAS_EXPERIENCE=false
|
|
59
59
|
|
|
60
60
|
if [[ -d "$EXPERIENCES_DIR" ]]; then
|
|
61
|
-
# Check for experience files created today
|
|
62
61
|
TODAY_EXPERIENCE=$(find "$EXPERIENCES_DIR" -name "${TODAY}*" -type f 2>/dev/null | head -1)
|
|
63
62
|
if [[ -n "$TODAY_EXPERIENCE" ]]; then
|
|
64
63
|
HAS_EXPERIENCE=true
|
|
65
64
|
fi
|
|
66
65
|
fi
|
|
67
66
|
|
|
68
|
-
# Also check if context.json was updated
|
|
67
|
+
# Also check if context.json was updated today (recent_decisions not empty)
|
|
69
68
|
if [[ -f "$CONTEXT_FILE" ]]; then
|
|
70
69
|
DECISIONS_COUNT=$(jq -r '.recent_decisions | length' "$CONTEXT_FILE" 2>/dev/null || echo "0")
|
|
71
70
|
LAST_UPDATED=$(jq -r '.session_metadata.last_updated // ""' "$CONTEXT_FILE" 2>/dev/null || echo "")
|
|
72
71
|
if [[ "$DECISIONS_COUNT" -gt 0 && -n "$LAST_UPDATED" ]]; then
|
|
73
|
-
# Check if last_updated is from today
|
|
74
72
|
if [[ "$LAST_UPDATED" == *"$TODAY"* ]]; then
|
|
75
73
|
HAS_EXPERIENCE=true
|
|
76
74
|
fi
|
|
@@ -78,17 +76,21 @@ if [[ -f "$CONTEXT_FILE" ]]; then
|
|
|
78
76
|
fi
|
|
79
77
|
|
|
80
78
|
if [[ "$HAS_EXPERIENCE" == "true" ]]; then
|
|
81
|
-
# Blackboard was written, allow stop
|
|
82
|
-
# Clean up session markers
|
|
79
|
+
# Blackboard was written, clean up and allow stop
|
|
83
80
|
rm -f "$EDIT_COUNTER" "$STATE_DIR/.plan-presented" 2>/dev/null
|
|
84
81
|
exit 0
|
|
85
82
|
fi
|
|
86
83
|
|
|
87
|
-
# Work was done but no blackboard write —
|
|
84
|
+
# Work was done but no blackboard write — nudge (don't block)
|
|
88
85
|
cat <<'JSON'
|
|
89
86
|
{
|
|
90
|
-
"
|
|
91
|
-
|
|
87
|
+
"hookSpecificOutput": {
|
|
88
|
+
"hookEventName": "Stop",
|
|
89
|
+
"additionalContext": "[ftm-blackboard-enforcer] You did meaningful work this session but did not record an experience to the blackboard. Before finishing, please: (1) Update ~/.claude/ftm-state/blackboard/context.json with current_task status and recent_decisions. (2) Write an experience file to ~/.claude/ftm-state/blackboard/experiences/ with task_type, tags, outcome, and lessons. (3) Update ~/.claude/ftm-state/blackboard/experiences/index.json with the new entry. This is how ftm learns — skipping it means the next session starts from zero."
|
|
90
|
+
}
|
|
92
91
|
}
|
|
93
92
|
JSON
|
|
93
|
+
|
|
94
|
+
# Clean up session markers regardless — don't let stale state carry over
|
|
95
|
+
rm -f "$EDIT_COUNTER" "$STATE_DIR/.plan-presented" 2>/dev/null
|
|
94
96
|
exit 0
|
package/hooks/ftm-plan-gate.sh
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
# ftm-plan-gate.sh
|
|
3
3
|
# PreToolUse hook for Edit/Write tools.
|
|
4
4
|
#
|
|
5
|
-
# Checks if a plan has been presented
|
|
6
|
-
#
|
|
7
|
-
# a medium+ task (detected by ftm-state), injects additionalContext
|
|
5
|
+
# Checks if a plan has been presented this session before allowing code edits.
|
|
6
|
+
# If no plan marker exists and the edit count is climbing, injects warnings
|
|
8
7
|
# telling Claude to stop and present a plan first.
|
|
9
8
|
#
|
|
10
|
-
# The marker file is created by Claude
|
|
11
|
-
#
|
|
12
|
-
#
|
|
9
|
+
# The marker file (~/.claude/ftm-state/.plan-presented) is created by Claude
|
|
10
|
+
# when it presents a plan. Any non-empty content counts as "plan presented".
|
|
11
|
+
# The file is cleaned up by the blackboard enforcer at session end.
|
|
13
12
|
#
|
|
14
13
|
# Hook: PreToolUse (matcher: Edit|Write)
|
|
15
14
|
|
|
@@ -25,9 +24,7 @@ fi
|
|
|
25
24
|
|
|
26
25
|
STATE_DIR="$HOME/.claude/ftm-state"
|
|
27
26
|
PLAN_MARKER="$STATE_DIR/.plan-presented"
|
|
28
|
-
SESSION_MARKER="$STATE_DIR/.session-id"
|
|
29
27
|
EDIT_COUNTER="$STATE_DIR/.edit-count"
|
|
30
|
-
SKILL_FILES_DIR="$HOME/.claude/skills"
|
|
31
28
|
|
|
32
29
|
# Get the file being edited
|
|
33
30
|
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // ""')
|
|
@@ -47,37 +44,36 @@ if [[ "$FILE_PATH" == *".claude/skills/"* ]] || \
|
|
|
47
44
|
exit 0
|
|
48
45
|
fi
|
|
49
46
|
|
|
50
|
-
# If plan marker exists
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
# If plan marker exists (any content), allow edits
|
|
48
|
+
if [[ -f "$PLAN_MARKER" ]] && [[ -s "$PLAN_MARKER" ]]; then
|
|
49
|
+
exit 0
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
# Reset edit counter if it's stale (older than 4 hours = likely a new session)
|
|
53
|
+
if [[ -f "$EDIT_COUNTER" ]]; then
|
|
54
|
+
COUNTER_AGE=$(( $(date +%s) - $(stat -c %Y "$EDIT_COUNTER" 2>/dev/null || echo "0") ))
|
|
55
|
+
if [[ "$COUNTER_AGE" -gt 14400 ]]; then
|
|
56
|
+
rm -f "$EDIT_COUNTER"
|
|
56
57
|
fi
|
|
57
58
|
fi
|
|
58
59
|
|
|
59
|
-
# Count edits
|
|
60
|
+
# Count edits without a plan marker
|
|
60
61
|
EDIT_COUNT=0
|
|
61
62
|
if [[ -f "$EDIT_COUNTER" ]]; then
|
|
62
|
-
|
|
63
|
-
STORED_SESSION=$(echo "$STORED" | cut -d: -f2)
|
|
64
|
-
if [[ "$STORED_SESSION" == "$CURRENT_SESSION" ]]; then
|
|
65
|
-
EDIT_COUNT=$(echo "$STORED" | cut -d: -f1)
|
|
66
|
-
fi
|
|
63
|
+
EDIT_COUNT=$(cat "$EDIT_COUNTER" 2>/dev/null || echo "0")
|
|
67
64
|
fi
|
|
68
65
|
|
|
69
66
|
EDIT_COUNT=$((EDIT_COUNT + 1))
|
|
70
|
-
echo "$
|
|
67
|
+
echo "$EDIT_COUNT" > "$EDIT_COUNTER"
|
|
71
68
|
|
|
72
|
-
# First 2 edits get a
|
|
69
|
+
# First 2 edits get a soft reminder (don't block — could be micro tasks)
|
|
73
70
|
# After 3+ edits without a plan marker, escalate the warning
|
|
74
71
|
if [[ $EDIT_COUNT -le 2 ]]; then
|
|
75
|
-
# Soft reminder — inject context but allow
|
|
76
72
|
cat <<'JSON'
|
|
77
73
|
{
|
|
78
74
|
"hookSpecificOutput": {
|
|
79
75
|
"hookEventName": "PreToolUse",
|
|
80
|
-
"additionalContext": "[ftm-plan-gate] You are editing files without having presented a plan this session. If this task is medium+ (touches 3+ files, involves external systems, or has stakeholder coordination), you MUST present a numbered plan and get user approval BEFORE editing code. If this is a micro/small task, you can proceed — but create the plan marker
|
|
76
|
+
"additionalContext": "[ftm-plan-gate] You are editing files without having presented a plan this session. If this task is medium+ (touches 3+ files, involves external systems, or has stakeholder coordination), you MUST present a numbered plan and get user approval BEFORE editing code. If this is a micro/small task, you can proceed — but create the plan marker: write any content to ~/.claude/ftm-state/.plan-presented to acknowledge you've considered it."
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
JSON
|
|
@@ -89,7 +85,7 @@ cat <<'JSON'
|
|
|
89
85
|
{
|
|
90
86
|
"hookSpecificOutput": {
|
|
91
87
|
"hookEventName": "PreToolUse",
|
|
92
|
-
"additionalContext": "[ftm-plan-gate WARNING] You have made 3+ file edits this session without presenting a plan. This is exactly the 'grinding without a plan' pattern that ftm-mind is supposed to prevent. STOP editing and do one of: (1) Present a numbered plan to the user and wait for approval, then write
|
|
88
|
+
"additionalContext": "[ftm-plan-gate WARNING] You have made 3+ file edits this session without presenting a plan. This is exactly the 'grinding without a plan' pattern that ftm-mind is supposed to prevent. STOP editing and do one of: (1) Present a numbered plan to the user and wait for approval, then write any content to ~/.claude/ftm-state/.plan-presented. (2) If the user explicitly said 'just do it' or this is genuinely a micro task, write the plan marker to acknowledge you've considered it. Do NOT continue editing without addressing this."
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
91
|
JSON
|