@really-knows-ai/foundry 2.3.2 → 3.0.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 (170) hide show
  1. package/README.md +180 -369
  2. package/dist/.opencode/plugins/foundry-tools/appraiser-tools.js +28 -0
  3. package/dist/.opencode/plugins/foundry-tools/artefact-tools.js +58 -0
  4. package/dist/.opencode/plugins/foundry-tools/assay-tools.js +92 -0
  5. package/dist/.opencode/plugins/foundry-tools/attestation-tools.js +191 -0
  6. package/dist/.opencode/plugins/foundry-tools/config-create-tools.js +128 -0
  7. package/dist/.opencode/plugins/foundry-tools/config-law-tools.js +380 -0
  8. package/dist/.opencode/plugins/foundry-tools/config-tools.js +43 -0
  9. package/dist/.opencode/plugins/foundry-tools/feedback-tools.js +234 -0
  10. package/dist/.opencode/plugins/foundry-tools/git-helpers.js +354 -0
  11. package/dist/.opencode/plugins/foundry-tools/git-tools.js +181 -0
  12. package/dist/.opencode/plugins/foundry-tools/helpers.js +340 -0
  13. package/dist/.opencode/plugins/foundry-tools/history-tools.js +20 -0
  14. package/dist/.opencode/plugins/foundry-tools/memory-admin-tools.js +296 -0
  15. package/dist/.opencode/plugins/foundry-tools/memory-helpers.js +104 -0
  16. package/dist/.opencode/plugins/foundry-tools/memory-tools.js +286 -0
  17. package/dist/.opencode/plugins/foundry-tools/orchestrate-tool.js +159 -0
  18. package/dist/.opencode/plugins/foundry-tools/snapshot-tools.js +104 -0
  19. package/dist/.opencode/plugins/foundry-tools/stage-tools.js +186 -0
  20. package/dist/.opencode/plugins/foundry-tools/validate-tools.js +263 -0
  21. package/dist/.opencode/plugins/foundry-tools/workfile-tools.js +102 -0
  22. package/dist/.opencode/plugins/foundry.js +105 -0
  23. package/dist/CHANGELOG.md +490 -0
  24. package/dist/LICENSE +21 -0
  25. package/dist/README.md +278 -0
  26. package/dist/docs/README.md +59 -0
  27. package/dist/docs/architecture.md +434 -0
  28. package/dist/docs/concepts.md +396 -0
  29. package/dist/docs/getting-started.md +345 -0
  30. package/dist/docs/memory-maintenance.md +176 -0
  31. package/dist/docs/tools.md +1411 -0
  32. package/dist/docs/work-spec.md +283 -0
  33. package/dist/scripts/lib/artefacts.js +151 -0
  34. package/dist/scripts/lib/assay/loader.js +151 -0
  35. package/dist/scripts/lib/assay/parse-jsonl.js +102 -0
  36. package/dist/scripts/lib/assay/permissions.js +52 -0
  37. package/dist/scripts/lib/assay/run.js +219 -0
  38. package/dist/scripts/lib/assay/spawn-with-timeout.js +138 -0
  39. package/dist/scripts/lib/attestation/attest.js +111 -0
  40. package/dist/scripts/lib/attestation/canonical-json.js +109 -0
  41. package/dist/scripts/lib/attestation/hash.js +17 -0
  42. package/dist/scripts/lib/attestation/parse.js +14 -0
  43. package/dist/scripts/lib/attestation/payload.js +106 -0
  44. package/dist/scripts/lib/attestation/render.js +16 -0
  45. package/dist/scripts/lib/attestation/verify.js +15 -0
  46. package/dist/scripts/lib/branch-guard.js +72 -0
  47. package/dist/scripts/lib/config-creators/appraiser.js +9 -0
  48. package/dist/scripts/lib/config-creators/artefact-type.js +9 -0
  49. package/dist/scripts/lib/config-creators/cycle.js +11 -0
  50. package/dist/scripts/lib/config-creators/factory.js +49 -0
  51. package/dist/scripts/lib/config-creators/flow.js +11 -0
  52. package/dist/scripts/lib/config-validators/appraiser.js +49 -0
  53. package/dist/scripts/lib/config-validators/artefact-type.js +38 -0
  54. package/dist/scripts/lib/config-validators/cycle.js +131 -0
  55. package/dist/scripts/lib/config-validators/flow.js +57 -0
  56. package/dist/scripts/lib/config-validators/helpers.js +96 -0
  57. package/dist/scripts/lib/config-validators/law.js +96 -0
  58. package/dist/scripts/lib/config.js +393 -0
  59. package/dist/scripts/lib/failed-flow.js +131 -0
  60. package/dist/scripts/lib/feedback-store.js +249 -0
  61. package/dist/scripts/lib/feedback-transitions.js +105 -0
  62. package/dist/scripts/lib/finalize.js +70 -0
  63. package/dist/scripts/lib/foundational-guards.js +13 -0
  64. package/dist/scripts/lib/git-bridge.js +77 -0
  65. package/dist/scripts/lib/git-finish/work-finish.js +233 -0
  66. package/dist/scripts/lib/git-policy.js +101 -0
  67. package/dist/scripts/lib/guards.js +125 -0
  68. package/dist/scripts/lib/history.js +132 -0
  69. package/dist/scripts/lib/memory/admin/create-edge-type.js +91 -0
  70. package/dist/scripts/lib/memory/admin/create-entity-type.js +43 -0
  71. package/dist/scripts/lib/memory/admin/create-extractor.js +67 -0
  72. package/dist/scripts/lib/memory/admin/drop-edge-type.js +40 -0
  73. package/dist/scripts/lib/memory/admin/drop-entity-type.js +172 -0
  74. package/dist/scripts/lib/memory/admin/dump.js +47 -0
  75. package/dist/scripts/lib/memory/admin/helpers.js +31 -0
  76. package/dist/scripts/lib/memory/admin/init.js +170 -0
  77. package/dist/scripts/lib/memory/admin/live-store.js +76 -0
  78. package/dist/scripts/lib/memory/admin/reembed.js +285 -0
  79. package/dist/scripts/lib/memory/admin/rename-edge-type.js +54 -0
  80. package/dist/scripts/lib/memory/admin/rename-entity-type.js +151 -0
  81. package/dist/scripts/lib/memory/admin/reset.js +24 -0
  82. package/dist/scripts/lib/memory/admin/vacuum.js +9 -0
  83. package/dist/scripts/lib/memory/admin/validate.js +19 -0
  84. package/dist/scripts/lib/memory/config.js +149 -0
  85. package/dist/scripts/lib/memory/cozo.js +136 -0
  86. package/dist/scripts/lib/memory/drift.js +71 -0
  87. package/dist/scripts/lib/memory/embeddings.js +128 -0
  88. package/dist/scripts/lib/memory/frontmatter.js +75 -0
  89. package/dist/scripts/lib/memory/ndjson.js +84 -0
  90. package/dist/scripts/lib/memory/paths.js +25 -0
  91. package/dist/scripts/lib/memory/permissions.js +41 -0
  92. package/dist/scripts/lib/memory/prompt.js +109 -0
  93. package/dist/scripts/lib/memory/query.js +56 -0
  94. package/dist/scripts/lib/memory/reads.js +109 -0
  95. package/dist/scripts/lib/memory/schema.js +64 -0
  96. package/dist/scripts/lib/memory/search.js +73 -0
  97. package/dist/scripts/lib/memory/singleton.js +49 -0
  98. package/dist/scripts/lib/memory/store.js +162 -0
  99. package/dist/scripts/lib/memory/types.js +93 -0
  100. package/dist/scripts/lib/memory/validate.js +58 -0
  101. package/dist/scripts/lib/memory/writes.js +40 -0
  102. package/{scripts → dist/scripts}/lib/pending.js +7 -2
  103. package/dist/scripts/lib/secret.js +59 -0
  104. package/{scripts → dist/scripts}/lib/slug.js +3 -2
  105. package/dist/scripts/lib/snapshot/finish.js +103 -0
  106. package/dist/scripts/lib/snapshot/inspect.js +253 -0
  107. package/dist/scripts/lib/snapshot/render.js +55 -0
  108. package/dist/scripts/lib/sort-fs-check.js +121 -0
  109. package/dist/scripts/lib/sort-routing.js +101 -0
  110. package/{scripts → dist/scripts}/lib/stage-guard.js +12 -6
  111. package/{scripts → dist/scripts}/lib/state.js +4 -0
  112. package/dist/scripts/lib/token.js +57 -0
  113. package/dist/scripts/lib/tracing.js +59 -0
  114. package/dist/scripts/lib/ulid.js +100 -0
  115. package/dist/scripts/lib/validator-jsonl.js +162 -0
  116. package/{scripts → dist/scripts}/lib/workfile.js +38 -20
  117. package/dist/scripts/orchestrate-cycle.js +215 -0
  118. package/dist/scripts/orchestrate-phases.js +314 -0
  119. package/dist/scripts/orchestrate.js +163 -0
  120. package/dist/scripts/sort.js +278 -0
  121. package/{skills → dist/skills}/add-appraiser/SKILL.md +39 -9
  122. package/{skills → dist/skills}/add-artefact-type/SKILL.md +46 -24
  123. package/{skills → dist/skills}/add-cycle/SKILL.md +57 -17
  124. package/dist/skills/add-extractor/SKILL.md +133 -0
  125. package/{skills → dist/skills}/add-flow/SKILL.md +36 -10
  126. package/dist/skills/add-law/SKILL.md +191 -0
  127. package/dist/skills/add-memory-edge-type/SKILL.md +52 -0
  128. package/dist/skills/add-memory-entity-type/SKILL.md +74 -0
  129. package/{skills → dist/skills}/appraise/SKILL.md +62 -13
  130. package/dist/skills/assay/SKILL.md +72 -0
  131. package/dist/skills/change-embedding-model/SKILL.md +58 -0
  132. package/dist/skills/drop-memory-edge-type/SKILL.md +54 -0
  133. package/dist/skills/drop-memory-entity-type/SKILL.md +57 -0
  134. package/dist/skills/dry-run/SKILL.md +116 -0
  135. package/{skills → dist/skills}/flow/SKILL.md +15 -2
  136. package/dist/skills/forge/SKILL.md +121 -0
  137. package/dist/skills/human-appraise/SKILL.md +153 -0
  138. package/{skills → dist/skills}/init-foundry/SKILL.md +23 -4
  139. package/dist/skills/init-memory/SKILL.md +92 -0
  140. package/{skills → dist/skills}/orchestrate/SKILL.md +30 -4
  141. package/dist/skills/quench/SKILL.md +99 -0
  142. package/{skills → dist/skills}/refresh-agents/SKILL.md +1 -1
  143. package/dist/skills/rename-memory-edge-type/SKILL.md +50 -0
  144. package/dist/skills/rename-memory-entity-type/SKILL.md +51 -0
  145. package/dist/skills/reset-memory/SKILL.md +54 -0
  146. package/dist/skills/upgrade-foundry/SKILL.md +192 -0
  147. package/package.json +34 -17
  148. package/.opencode/plugins/foundry.js +0 -761
  149. package/CHANGELOG.md +0 -100
  150. package/docs/concepts.md +0 -122
  151. package/docs/getting-started.md +0 -187
  152. package/docs/work-spec.md +0 -207
  153. package/scripts/lib/artefacts.js +0 -124
  154. package/scripts/lib/config.js +0 -175
  155. package/scripts/lib/feedback-transitions.js +0 -25
  156. package/scripts/lib/feedback.js +0 -440
  157. package/scripts/lib/finalize.js +0 -41
  158. package/scripts/lib/history.js +0 -59
  159. package/scripts/lib/secret.js +0 -23
  160. package/scripts/lib/tags.js +0 -108
  161. package/scripts/lib/token.js +0 -26
  162. package/scripts/orchestrate.js +0 -418
  163. package/scripts/sort.js +0 -370
  164. package/scripts/validate-tags.js +0 -54
  165. package/skills/add-law/SKILL.md +0 -111
  166. package/skills/forge/SKILL.md +0 -88
  167. package/skills/human-appraise/SKILL.md +0 -82
  168. package/skills/quench/SKILL.md +0 -62
  169. package/skills/upgrade-foundry/SKILL.md +0 -216
  170. /package/{skills → dist/skills}/list-agents/SKILL.md +0 -0
@@ -1,82 +0,0 @@
1
- ---
2
- name: human-appraise
3
- type: atomic
4
- description: Human quality gate. Presents the artefact to the human for review and collects feedback tagged #human.
5
- ---
6
-
7
- # Human Appraise
8
-
9
- You are a human quality gate. Sort has routed to you either because the LLM appraisers have finished (normal flow) or because a deadlock was detected between forge and appraisers.
10
-
11
- ## Prerequisites
12
-
13
- Before running this skill, verify that the `foundry/` directory exists in the project root. If it does not exist, stop and tell the user:
14
-
15
- > Foundry is not initialized in this project. Run the `init-foundry` skill first to create the foundry/ directory structure.
16
-
17
- ## Stage lifecycle (mandatory)
18
-
19
- Human-appraise runs inside an enforced stage. Your **first** and **last** tool calls are fixed:
20
-
21
- 1. **First:** `foundry_stage_begin({stage, cycle, token})` — copy the token verbatim from the dispatch prompt.
22
- 2. **Last:** `foundry_stage_end({summary})`.
23
-
24
- Human-appraise makes **no disk writes**. All output flows through `foundry_feedback_add` / `foundry_feedback_resolve` / `foundry_artefacts_set_status`. `foundry_stage_finalize` flags unexpected writes as a violation.
25
-
26
- ## Input
27
-
28
- When invoked from orchestrate, you receive `{cycle, token, context}`:
29
- - `cycle` — the current cycle id
30
- - `token` — single-use token for `foundry_stage_begin`
31
- - `context.artefact_file` — the target artefact
32
- - `context.recent_feedback` — recent deadlocked feedback items to present to the user
33
-
34
- Your FIRST tool call must be `foundry_stage_begin({stage: 'human-appraise:<cycle>', cycle, token})`.
35
-
36
- Your LAST tool call must be `foundry_stage_end({summary: '<one-sentence description of the user verdict>'})` — orchestrate reads this summary for the commit message.
37
-
38
- ## Protocol
39
-
40
- 1. `foundry_stage_begin(...)`.
41
- 2. Gather context by calling:
42
- - `foundry_workfile_get` — current state, goal, cycle
43
- - `foundry_artefacts_list({cycle: <current-cycle>})` — this cycle's artefact files and status (always pass the `cycle` filter; omitting it returns stale rows from prior sessions)
44
- - `foundry_feedback_list` — all existing feedback
45
- - `foundry_history_list` — what has happened so far
46
-
47
- 3. Read the artefact file(s) for this cycle.
48
-
49
- 4. Present to the human:
50
- - The current artefact content (full file content or multi-file diff)
51
- - A summary of this iteration's feedback (resolved and open)
52
- - If this is a deadlock escalation, clearly explain the deadlock:
53
- - Which feedback item(s) are stuck
54
- - The appraiser's reasoning
55
- - Forge's wont-fix or revision justification
56
- - Ask the human to resolve the disagreement
57
-
58
- 5. Wait for the human's response.
59
-
60
- 6. Act on the response (tag MUST be `human` on any added feedback — the tool rejects other tags during human-appraise):
61
- - **Approve** — "looks good" / "continue" — no feedback added, sort will advance.
62
- - **Provide feedback** — `foundry_feedback_add(file, text, tag: 'human')`. Sort will route back to forge.
63
- - **Dismiss deadlocked feedback** — `foundry_feedback_resolve(file, index, resolution: 'approved')`. Human-appraise may resolve items in state `actioned` or `wont-fix`. This overrides the appraiser.
64
- - **Abort** — `foundry_artefacts_set_status(file, 'blocked')`, cycle ends.
65
-
66
- 7. `foundry_stage_end({summary})` — describe what the human decided so sort can log it.
67
-
68
- ## #human feedback rules
69
-
70
- - Feedback tagged `human` takes priority over all LLM appraiser feedback
71
- - Forge MUST address `#human` feedback — it cannot wont-fix it
72
- - When `#human` feedback contradicts LLM appraiser feedback, forge follows the human's direction
73
-
74
- ## What you do NOT do
75
-
76
- - You do not write files — all output goes through foundry tools.
77
- - You do not make decisions for the human — present the state and wait.
78
- - You do not modify the artefact.
79
- - You do not skip the pause — the human must respond before continuing.
80
- - You do not filter or summarise away important details — show the full picture.
81
- - You do not call `foundry_history_append` or `foundry_git_commit` — sort owns those.
82
- - You do not register artefacts — handled by `foundry_stage_finalize`.
@@ -1,62 +0,0 @@
1
- ---
2
- name: quench
3
- type: atomic
4
- description: Deterministic validation of an artefact by running CLI commands. Writes feedback via foundry tools.
5
- ---
6
-
7
- # Quench
8
-
9
- You run deterministic checks on an artefact by executing the CLI commands defined in the artefact type's validation config. No judgment — commands pass or fail.
10
-
11
- ## Prerequisites
12
-
13
- Before running this skill, verify that the `foundry/` directory exists in the project root. If it does not exist, stop and tell the user:
14
-
15
- > Foundry is not initialized in this project. Run the `init-foundry` skill first to create the foundry/ directory structure.
16
-
17
- ## Stage lifecycle (mandatory)
18
-
19
- Quench runs inside an enforced stage. Your **first** and **last** tool calls are fixed:
20
-
21
- 1. **First:** `foundry_stage_begin({stage, cycle, token})` — copy the token verbatim from the dispatch prompt. Any other tool call before this will be blocked.
22
- 2. **Last:** `foundry_stage_end({summary})`.
23
-
24
- Quench makes **no disk writes**. You produce feedback via `foundry_feedback_add`, never by creating or modifying files. `foundry_stage_finalize` (run by the orchestrator after you return) will flag any unexpected writes as a violation.
25
-
26
- ## Protocol
27
-
28
- 1. `foundry_stage_begin(...)`.
29
- 2. `foundry_workfile_get` — read the `cycle` from frontmatter.
30
- 3. `foundry_artefacts_list({cycle: <current-cycle>})` — enumerate the artefacts produced by **this** cycle. Always pass the `cycle` filter; omitting it returns rows from prior sessions and validates stale files. Skip rows whose status is `done` or `blocked`.
31
- 4. For each remaining row:
32
- a. `foundry_config_validation` with the row's type. If it returns null, skip this row.
33
- b. `foundry_validate_run` with the type ID and the row's file path — executes all validation commands and returns results.
34
- c. For each failure: `foundry_feedback_add(file, text, tag: 'validation')`. Tag MUST be `validation` — the tool rejects other tags during quench.
35
- 5. If every command passes for every row, add no new feedback.
36
- 6. If the artefact table has no rows for this cycle, `foundry_stage_end({summary: 'SKIP: no artefacts registered for this cycle'})` and stop.
37
- 7. `foundry_stage_end({summary})`.
38
-
39
- ## Reviewing actioned feedback
40
-
41
- On subsequent passes, review previously actioned items:
42
-
43
- 1. `foundry_feedback_list` — find `actioned` items tagged `validation` for artefacts in this cycle (use the file list from step 3 above).
44
- 2. Re-run the relevant command via `foundry_validate_run`.
45
- 3. If the check now passes: `foundry_feedback_resolve(file, index, resolution: 'approved')`.
46
- 4. If it still fails: `foundry_feedback_resolve(file, index, resolution: 'rejected', reason)`.
47
-
48
- There is no wont-fix for validation feedback — deterministic rules are not negotiable. Quench may only resolve items in state `actioned`; the feedback tool enforces this.
49
-
50
- ## History
51
-
52
- Do NOT call `foundry_history_append` or `foundry_git_commit` — the sort skill handles those. Return a clear summary via `foundry_stage_end` (e.g., "2 validation issues found" or "Validation passed").
53
-
54
- ## What you do NOT do
55
-
56
- - You do not write files — all output goes through `foundry_feedback_add`.
57
- - You do not make subjective judgments.
58
- - You do not revise the artefact (forge's job).
59
- - You do not evaluate laws — that is the appraise skill's job.
60
- - You do not invent validation rules — you only run commands from the validation config.
61
- - You do not duplicate feedback that already exists (the tool de-duplicates by text-hash, but don't rely on it).
62
- - You do not register artefacts — that happens automatically.
@@ -1,216 +0,0 @@
1
- ---
2
- name: upgrade-foundry
3
- type: atomic
4
- description: Analyses and migrates foundry configuration to the current version format.
5
- ---
6
-
7
- # Upgrade Foundry
8
-
9
- You analyse the entire `foundry/` directory and migrate configuration files to the current format, asking the user for clarification where needed.
10
-
11
- ## Prerequisites
12
-
13
- Before running this skill, verify that the `foundry/` directory exists in the project root. If it does not exist, stop and tell the user:
14
-
15
- > Foundry is not initialized in this project. Run the `init-foundry` skill first to create the foundry/ directory structure.
16
-
17
- ## Protocol
18
-
19
- ### 1. Scan entire foundry directory
20
-
21
- Read all configuration files:
22
- - `foundry/flows/*.md` — flow definitions
23
- - `foundry/cycles/*.md` — cycle definitions
24
- - `foundry/artefacts/*/definition.md` — artefact type definitions
25
- - `foundry/artefacts/*/laws.md` — type-specific laws
26
- - `foundry/artefacts/*/validation.md` — validation commands
27
- - `foundry/laws/*.md` — global laws
28
- - `foundry/appraisers/*.md` — appraiser definitions
29
-
30
- Also scan `.opencode/agents/foundry-*.md` for agent-filename migration (see §2).
31
-
32
- For each file, parse the frontmatter and body content.
33
-
34
- ### 2. Detect what needs migration
35
-
36
- Check each file against the current expected format:
37
-
38
- **Agent files (v2.1 migration):**
39
- - Any `.opencode/agents/foundry-*.md` filename containing a `.` character? → needs renaming to all-dashes format. The v2.1 naming convention replaces both `/` and `.` in the model ID with `-`. For example, `foundry-github-copilot-claude-sonnet-4.6.md` must become `foundry-github-copilot-claude-sonnet-4-6.md`. The inner `model:` frontmatter field is **not** changed — only the filename.
40
-
41
- **Flows:**
42
- - Has `starting-cycles` field? If not → needs DAG migration
43
- - Has ordered numbered list under `## Cycles`? → needs conversion to unordered list
44
-
45
- **Cycles:**
46
- - Has `targets` field? If not → needs target routing
47
- - Has `inputs.type` (`any-of`/`all-of`)? If `inputs` is a plain list → needs contract type
48
- - Has `hitl` in stages or frontmatter? → needs human-appraise migration
49
- - Has nested `human-appraise: {enabled, deadlock-threshold}`? → v2.2.1 flat-keys migration (see §4b)
50
- - Has `models` map? Check format
51
-
52
- **Artefact types:**
53
- - Has required frontmatter fields (`id`, `name`, `file-patterns`)?
54
- - Has `appraisers` config if applicable?
55
-
56
- **Appraisers:**
57
- - Has `id` and personality content?
58
- - Has optional `model` field?
59
- - References any deprecated stage types?
60
-
61
- **Laws:**
62
- - Uses `## heading` per law?
63
- - Any structural issues?
64
-
65
- **Validation:**
66
- - Uses `Command:` / `Failure means:` format?
67
- - Commands have backticks that could cause issues? (Suggest removing — the parser strips them but clean is better)
68
-
69
- ### 3. Present findings
70
-
71
- Present a grouped summary of all issues found:
72
-
73
- > **Migration Report**
74
- >
75
- > **Flows (N issues):**
76
- > - `creative-flow.md` — missing `starting-cycles`, has ordered cycle list
77
- >
78
- > **Cycles (N issues):**
79
- > - `create-haiku.md` — missing `targets` field
80
- > - `create-short-story.md` — inputs is plain list, needs `any-of`/`all-of` contract
81
- >
82
- > **Artefact types (N issues):**
83
- > - (none found)
84
- >
85
- > **Appraisers (N issues):**
86
- > - (none found)
87
- >
88
- > **Everything else clean**
89
-
90
- If nothing needs migration, say so and stop.
91
-
92
- ### 4. Migrate agent files (v2.1)
93
-
94
- For each `.opencode/agents/foundry-*.md` file with a `.` in its filename:
95
- - Compute the new filename by replacing all `.` with `-` (keep the `.md` extension)
96
- - `git mv <old> <new>` to preserve history
97
- - Do **not** modify the file contents — the `model:` field inside retains its original dots
98
-
99
- After renaming, remind the user: **Restart OpenCode** for the new agent filenames to register.
100
-
101
- ### 4a. v2.2.0 lifecycle upgrade
102
-
103
- Foundry v2.2.0 introduces a tool-enforced stage lifecycle (`stage_begin` / `stage_end` / `stage_finalize`) backed by a per-project state directory and HMAC-signed dispatch tokens. The upgrade is non-destructive — no WORK.md or artefact migration is required — but the project needs three small changes:
104
-
105
- 1. **Create `.foundry/`** (if absent):
106
- - `mkdir -p .foundry`
107
- - The plugin auto-creates `.foundry/.secret` on first boot via `readOrCreateSecret`. You do not need to generate it by hand; just ensure the directory exists and is writable.
108
- 2. **Gitignore `.foundry/`**:
109
- - Ensure `.gitignore` contains a line `.foundry/` (append if missing; do not duplicate). The directory holds a per-worktree HMAC secret and transient active-stage state — neither should be committed.
110
- 3. **Pre-existing state:** v2.2.0 is a fresh state system. There is no `active-stage.json` to migrate. If one happens to exist from a manually-aborted prior run, leave it alone — the new plugin treats its absence as "no active stage" and its presence as a legitimate in-flight stage.
111
-
112
- The `foundry_artefacts_add` tool has been removed in v2.2.0 — artefact registration now happens automatically via `foundry_stage_finalize`. No existing config references this tool, so there is nothing to migrate in `foundry/`.
113
-
114
- ### 4b. v2.2.1 cycle-definition flat human-appraise keys
115
-
116
- v2.2.1 replaces the nested `human-appraise: {enabled, deadlock-threshold}` block in cycle definitions with three flat keys:
117
-
118
- ```yaml
119
- human-appraise: <true|false> # default: false — run human-appraise every iteration
120
- deadlock-appraise: <true|false> # default: true — pull in human-appraise when LLM appraisers deadlock
121
- deadlock-iterations: <number> # default: 5 — deadlock detection threshold
122
- ```
123
-
124
- For each `foundry/cycles/*.md` whose frontmatter has the old nested form, migrate:
125
-
126
- - `human-appraise.enabled: true` → `human-appraise: true`
127
- - `human-appraise.enabled: false` (or missing) → `human-appraise: false`
128
- - `human-appraise.deadlock-threshold: N` → `deadlock-iterations: N`
129
- - Always add `deadlock-appraise: true` unless the user explicitly wants the stricter "no human ever" behavior (`deadlock-appraise: false` → deadlock marks the cycle `blocked`).
130
-
131
- The old nested form is no longer read. After migration, verify by asking: "cycle `<id>`: human-appraise every iteration? deadlock-appraise on? deadlock-iterations = N?".
132
-
133
- ### 4c. v2.2.x → v2.3.0
134
-
135
- v2.3.0 replaces the LLM-driven sort orchestrator with the `foundry_orchestrate` plugin tool. The `cycle` and `sort` skills are removed. Six tools are deregistered: `foundry_sort`, `foundry_history_append`, `foundry_stage_finalize`, `foundry_git_commit`, `foundry_workfile_configure_from_cycle`, `foundry_workfile_set`.
136
-
137
- #### Pre-flight checks
138
-
139
- Before upgrading, verify a clean base state. Abort the upgrade if any of these fail:
140
-
141
- 1. **Branch**: must be on `main` (or the user's configured default base branch).
142
- - Check: `git rev-parse --abbrev-ref HEAD` — must match expected default.
143
- - If on `work/*`: abort with "You're on a work branch. Switch to main and complete or discard any in-flight flow before upgrading."
144
-
145
- 2. **Working tree**: must be clean.
146
- - Check: `git status --porcelain` — must be empty.
147
- - If dirty: abort with "Uncommitted changes. Commit or stash before upgrading."
148
-
149
- 3. **In-flight workfile**: `WORK.md` must not exist.
150
- - Check: is `WORK.md` present in the repo root?
151
- - If yes: abort with "In-flight workfile detected. Delete it (`foundry_workfile_delete`) or complete the cycle before upgrading."
152
-
153
- Only when all three pass, proceed with the plugin swap.
154
-
155
- #### Upgrade steps
156
-
157
- 1. Install the new plugin package version: `npm install @really-knows-ai/foundry@2.3.0 --save-dev`.
158
- 2. Swap `.opencode/plugins/foundry.js` with the new version from `node_modules/@really-knows-ai/foundry/.opencode/plugins/foundry.js`.
159
- 3. Remove `skills/cycle/` and `skills/sort/` directories from the project if they exist locally (they shouldn't — skills live in the package).
160
- 4. Commit the upgrade: `chore: upgrade foundry to 2.3.0`.
161
-
162
- No state migration is performed. In-flight cycles from v2.2.x must be completed or discarded before upgrading.
163
-
164
- ### 5. Migrate flows
165
-
166
- For each flow needing migration:
167
- - Show the current ordered cycle list
168
- - Ask: which cycles are starting cycles?
169
- - Infer targets from adjacency (cycle N → cycle N+1)
170
- - Present the proposed `starting-cycles` and confirm
171
- - Convert numbered `## Cycles` list to unordered
172
-
173
- ### 6. Migrate cycles
174
-
175
- For each cycle needing migration:
176
-
177
- **Targets:** Infer from the flow's old ordering. Present and confirm:
178
- > Cycle `create-haiku` was followed by `create-short-story` in the flow. Set `targets: [create-short-story]`?
179
-
180
- **Input contracts:** If inputs exist as a plain list, ask:
181
- > Cycle `create-short-story` has inputs `[haiku, limerick]`. Should it require:
182
- > 1. `any-of` — at least one must exist
183
- > 2. `all-of` — all must exist
184
-
185
- **HITL migration:** If `hitl` is found in stages:
186
- > Cycle `create-haiku` has an `hitl` stage. This has been replaced by `human-appraise`.
187
- > - Enable human-appraise? (yes/no)
188
- > - Deadlock threshold? (default: 3)
189
-
190
- Remove `hitl` from stages and add `human-appraise` config if enabled.
191
-
192
- ### 7. Migrate other config
193
-
194
- For artefact types, appraisers, laws, and validation with issues:
195
- - Present each issue with a suggested fix
196
- - Ask the user to confirm or adjust
197
-
198
- ### 8. Present migration plan
199
-
200
- Before writing anything, show the complete list of changes:
201
- - Group by category
202
- - Show each file and the specific changes
203
- - Ask for confirmation
204
-
205
- ### 9. Apply changes
206
-
207
- - Update all affected files
208
- - Commit with message: `[foundry] upgrade: migrate to current format`
209
-
210
- ## What you do NOT do
211
-
212
- - You do not create new cycles, artefact types, or appraisers
213
- - You do not delete existing files without confirmation
214
- - You do not modify artefact content (produced artefacts, not config)
215
- - You do not run automatically — the user invokes it explicitly
216
- - You do not guess when uncertain — ask the user
File without changes