Skip to content

Commit 53db2b7

Browse files
jwaldripclaude
andcommitted
fix: move iteration.json initialization from elaboration to construction
Elaboration should only write spec artifacts and intent-slug, not construction state. /construct now initializes iteration.json from intent.md frontmatter on first run if it doesn't exist. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 57f9128 commit 53db2b7

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

plugin/skills/construct/SKILL.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,40 @@ STATE=$(han keep load iteration.json --quiet)
196196
INTENT_SLUG=$(han keep load intent-slug --quiet)
197197
```
198198

199-
If no state exists:
199+
If `INTENT_SLUG` is empty (no intent exists at all):
200200
```
201201
No AI-DLC state found.
202202
203203
If you have existing intent artifacts in .ai-dlc/, run /resume to continue.
204204
Otherwise, run /elaborate to start a new task.
205205
```
206206

207+
If `INTENT_SLUG` exists but `STATE` is empty (first construction run — elaboration wrote artifacts but no iteration state):
208+
209+
Initialize `iteration.json` from the intent artifacts:
210+
211+
```bash
212+
INTENT_DIR=".ai-dlc/${INTENT_SLUG}"
213+
INTENT_FILE="$INTENT_DIR/intent.md"
214+
215+
# Read workflow and mode from intent.md frontmatter
216+
WORKFLOW_NAME=$(han parse yaml workflow -r --default "default" < "$INTENT_FILE" 2>/dev/null || echo "default")
217+
MODE=$(han parse yaml mode -r --default "OHOTL" < "$INTENT_FILE" 2>/dev/null || echo "OHOTL")
218+
219+
# Resolve workflow to hat sequence
220+
if [ -f ".ai-dlc/workflows.yml" ]; then
221+
WORKFLOW_HATS=$(han parse yaml "${WORKFLOW_NAME}" < ".ai-dlc/workflows.yml" 2>/dev/null || echo "")
222+
fi
223+
if [ -z "$WORKFLOW_HATS" ] && [ -f "${CLAUDE_PLUGIN_ROOT}/workflows.yml" ]; then
224+
WORKFLOW_HATS=$(han parse yaml "${WORKFLOW_NAME}" < "${CLAUDE_PLUGIN_ROOT}/workflows.yml" 2>/dev/null || echo "")
225+
fi
226+
FIRST_HAT=$(echo "$WORKFLOW_HATS" | jq -r '.[0]')
227+
228+
# Initialize iteration state
229+
STATE='{"iteration":1,"hat":"'"${FIRST_HAT}"'","workflowName":"'"${WORKFLOW_NAME}"'","mode":"'"${MODE}"'","workflow":'"${WORKFLOW_HATS}"',"status":"active"}'
230+
han keep save iteration.json "$STATE"
231+
```
232+
207233
If status is "complete":
208234
```
209235
Task already complete! Run /reset to start a new task.

plugin/skills/elaborate/SKILL.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -774,18 +774,15 @@ misinterpret what to build.}
774774
- `documentation``do-technical-documentation` agents
775775
- `devops` → infrastructure/deployment agents
776776

777-
### 4. Save iteration state to han keep:
778-
779-
Intent-level state is saved to the current branch (which is now the intent branch):
777+
### 4. Save intent slug to han keep:
780778

781779
```bash
782-
# Intent-level state -> current branch (intent branch)
780+
# Intent-level identifier -> current branch (intent branch)
783781
han keep save intent-slug "{intent-slug}"
784-
785-
# Intent-level state -> current branch (intent branch)
786-
han keep save iteration.json '{"iteration":1,"hat":"{first-hat}","workflowName":"{workflow}","mode":"{HITL|OHOTL|AHOTL}","workflow":["{hat1}","{hat2}"],"status":"active"}'
787782
```
788783

784+
**Note:** Do NOT save `iteration.json` here. Construction state (hat, iteration count, workflow, status) is initialized by `/construct` when the build loop starts. Elaboration only writes the spec artifacts and the intent slug.
785+
789786
### 5. Commit all artifacts on intent branch:
790787

791788
```bash

0 commit comments

Comments
 (0)