@really-knows-ai/foundry 3.3.0 → 3.3.2

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.
@@ -142,7 +142,7 @@ function artefactTypeArgs(s) { return {
142
142
  function appraiserArgs(s) { return {
143
143
  id: s.string().describe('Slugged identifier matching the filename under foundry/appraisers/'),
144
144
  name: s.string().describe('Human-readable display name written to frontmatter.name'),
145
- description: s.string().describe('Prose personality description placed after frontmatter'),
145
+ description: s.string().describe('Personality or perspective (2-4 sentences: how they think, what they care about, how they evaluate). Appraisers read laws to learn what to check — laws define boundaries and constraints, this field defines the evaluator character and lens only. Do not enumerate criteria here; put those in laws.'),
146
146
  model: s.string().optional().describe('Optional model override for this appraiser (e.g. openai/gpt-4o)'),
147
147
  }; }
148
148
 
@@ -332,7 +332,7 @@ function makeAddLawTool(tool) {
332
332
  }).describe('Where to write the law'),
333
333
  validators: tool.schema.array(tool.schema.object({
334
334
  id: tool.schema.string().describe('Validator identifier'),
335
- command: tool.schema.string().describe('CLI command with optional {pattern} / {files} placeholders'),
335
+ command: tool.schema.string().describe('CLI command with optional {pattern} / {files} placeholders. Prefer JavaScript (.mjs) scripts as separate files (e.g. "node foundry/artefacts/<type>/check.mjs {files}"). Stdout must be NDJSON: one JSON object per line with required fields "file" (relative path) and "text" (message). Optional: "location" (line:col), "severity" (error|warning). Exit code is ignored.'),
336
336
  failureMeans: tool.schema.string().optional().describe('Description of what failure means'),
337
337
  })).optional().describe('Optional deterministic validators'),
338
338
  },
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.3.2] - 2026-05-14
4
+
5
+ ### Changed
6
+
7
+ - **All 15 creation and edit skills converted to an interactive wizard
8
+ protocol.** Every skill now follows Understand → Plan → Confirm → Build
9
+ instead of auto-creating configuration. The AI asks questions, presents a
10
+ plan, waits for confirmation, then builds — no file is created before the
11
+ user says yes.
12
+
13
+ Skills converted:
14
+
15
+ | Phase | Skills |
16
+ |-------|--------|
17
+ | Core config | `add-artefact-type`, `add-appraiser`, `add-law` |
18
+ | Cycle and flow | `add-cycle`, `add-flow` (composite — invokes sub-skills with context) |
19
+ | Memory creation | `add-extractor`, `add-memory-entity-type`, `add-memory-edge-type`, `init-memory` |
20
+ | Memory edit/destructive | `rename-memory-entity-type`, `rename-memory-edge-type`, `change-embedding-model`, `reset-memory`, `drop-memory-entity-type`, `drop-memory-edge-type` |
21
+
22
+ - **Sub-skill composition via context object contract.** Parent skills (e.g.
23
+ `add-flow`, `add-artefact-type`) pass pre-filled field objects to
24
+ sub-skills (e.g. `add-law`, `add-cycle`). Sub-skills skip questions for
25
+ provided fields and only ask for gaps. `add-flow` presents a single
26
+ combined plan covering all dependencies and confirms once before building.
27
+ - **Destructive skills require typed confirmation.** `reset-memory` requires
28
+ typing "reset"; `drop-*` skills show previews of affected rows and edges
29
+ before requiring explicit confirmation.
30
+
31
+ ## [3.3.1] - 2026-05-14
32
+
33
+ ### Fixed
34
+
35
+ - **Appraiser tool description** now explicitly states that appraisers are
36
+ personalities only — boundaries and constraints belong in laws. Prevents
37
+ the AI from embedding criteria in appraiser descriptions that should be
38
+ encoded as laws.
39
+ - **Validator command description** now mandates `.mjs` scripts and NDJSON
40
+ stdout format (`file`, `text`, optional `location`/`severity`, exit code
41
+ ignored). Prevents the AI from using inline bash/Python validators that
42
+ don't produce machine-parseable output.
43
+ - **add-law skill** gains §2a: a deterministic-vs-subjective split step
44
+ that walks the user through which law elements can be script-checked and
45
+ which are left to appraisers. Includes guidance to prefer existing
46
+ libraries over hand-rolled validation logic.
47
+ - **add-artefact-type skill** no longer carries validator guidance
48
+ (validators are exclusively law-related, not artefact-type-related).
49
+
3
50
  ## [3.3.0] - 2026-05-14
4
51
 
5
52
  ### Added
@@ -34,30 +34,23 @@ Do not tell the user to call branch tools directly.
34
34
 
35
35
  ## Protocol
36
36
 
37
- ### 1. Gather basics
37
+ ### Context object
38
38
 
39
- From the user's prompt, establish:
40
- - `id` — lowercase, hyphenated identifier
41
- - `name` — a short character name (e.g., "The Pedant", "The Pragmatist")
42
- - `model` — (optional) a specific model ID to use for this appraiser (e.g., `openai/gpt-4o`). Overrides the cycle-level model for the appraise stage. If omitted, the appraiser uses whatever model the cycle's appraise stage is configured with.
43
- - A prose description of the personality: how they think, what they prioritize, how they evaluate
39
+ When invoked with pre-filled fields matching the `foundry_config_create_appraiser` tool args, skip questions for provided fields. Missing fields trigger clarifying questions.
44
40
 
45
- If `id`, `name`, or the personality description are missing, ask. The `model` field is optional — only ask about it if the user mentions wanting a specific model for this appraiser.
41
+ Context fields: `{id, name, description, model?}`
46
42
 
47
- ### 2. Check for id conflicts
43
+ When invoked with a context:
44
+ - If all required fields are present, skip the Understand phase and proceed to Plan → Confirm → Build.
45
+ - If only some fields are present, ask only for the missing ones.
48
46
 
49
- Read all existing appraiser definitions in `foundry/appraisers/*.md`.
47
+ ### 1. Understand
50
48
 
51
- - Exact id match hard conflict, must choose a different id
49
+ Ask for `id`, `name`, and `description` one at a time. Ask about `model` (optional) — offer the default model as the recommended choice.
52
50
 
53
- ### 3. Check for semantic overlap
51
+ **Id conflict check**: Read all existing appraiser definitions in `foundry/appraisers/*.md`. Exact id match means a hard conflict — choose a different id.
54
52
 
55
- For each existing appraiser, compare the new personality against it:
56
- - What does this appraiser prioritize?
57
- - What lens do they evaluate through?
58
- - Would two artefacts get meaningfully different feedback from these appraisers?
59
-
60
- If significant overlap is found, present it to the user:
53
+ **Semantic overlap check**: For each existing appraiser, compare the new personality against it. If significant overlap is found, present it to the user:
61
54
 
62
55
  > The new appraiser `<new-id>` seems to overlap with existing appraiser `<existing-id>`:
63
56
  > - New: <name> — <personality summary>
@@ -74,45 +67,23 @@ If significant overlap is found, present it to the user:
74
67
 
75
68
  Do not proceed until the user has decided.
76
69
 
77
- ### 4. Draft the definition
78
-
79
- Present the definition to the user with these structured fields:
80
-
81
- - `id` (string) — lowercase, hyphenated identifier
82
- - `name` (string) — a short character name (e.g., "The Pedant", "The Pragmatist")
83
- - `description` (string) — 2-4 sentences describing how this appraiser thinks, what they care about, and how they approach evaluation
84
- - `model` (string, optional) — a specific model ID to use for this appraiser (e.g., `openai/gpt-4o`). Overrides the cycle-level model for the appraise stage. Omit this field to use the cycle's default model.
85
-
86
- Ask: does this capture the personality correctly?
87
-
88
- ### 5. Refine with the user
89
-
90
- Iterate until the user is happy with the personality description. Key things to check:
91
- - Is the personality distinct enough from existing appraisers?
92
- - Does the description give the LLM enough direction to adopt a consistent voice?
93
- - Is it clear what this appraiser would flag vs let pass?
94
-
95
- ### 6. Validate the draft
96
-
97
- Call `foundry_config_validate_appraiser({ name: "<id>", body: "<assembled markdown>" })`. Assemble the body from the fields using the frontmatter format the tool produces internally.
70
+ ### 2. Plan
98
71
 
99
- If the result is `{ ok: false, errors: [...] }`, address each error (adjust the body) and re-run until you get `{ ok: true }`. Common issues: missing required frontmatter keys, references to artefact types or flows that don't exist yet.
72
+ Present a quick inline summary: id, name, personality description. Include the model if one was specified. Ask: "Does this capture the personality correctly?" Iterate until the user is satisfied.
100
73
 
101
- ### 7. Create the file
74
+ ### 3. Confirm
102
75
 
103
- Call `foundry_config_create_appraiser({ id: "<id>", name: "<name>", description: "<description>" })`. The tool:
76
+ Ask: "Proceed with this plan?" wait for user answer before building. If the user rejects the plan, return to the Understand phase and adjust.
104
77
 
105
- - re-validates the body (TOCTOU);
106
- - writes `foundry/appraisers/<id>.md`;
107
- - produces one git commit on the current `config/*` branch.
78
+ ### 4. Build
108
79
 
109
- If the tool returns `{ ok: false, errors }` because the target file already exists, read the existing file, incorporate the user's requested changes into the current body, propose the merged result for review, then write and commit the updated file.
80
+ 1. **Validate**: Call `foundry_config_validate_appraiser({ name: "<id>", body: "<assembled markdown>" })`. Assemble the body from the fields using the frontmatter format the tool produces internally. If the result is `{ ok: false, errors: [...] }`, address each error and re-run until `{ ok: true }`. Common issues: missing required frontmatter keys, references to artefact types or flows that do not exist yet.
110
81
 
111
- Show the user the resulting commit hash from the response.
82
+ 2. **Create**: Call `foundry_config_create_appraiser({ id: "<id>", name: "<name>", description: "<description>" })`. The tool re-validates the body (TOCTOU), writes `foundry/appraisers/<id>.md`, and produces one git commit on the current `config/*` branch. Show the user the resulting commit hash.
112
83
 
113
- ### 8. Mention artefact type configuration
84
+ If the tool returns `{ ok: false, errors }` because the target file already exists, read the existing file, incorporate the user's requested changes into the current body, propose the merged result for review, then write and commit the updated file.
114
85
 
115
- After creating the appraiser, offer to connect it to relevant artefact-type configuration when doing so supports the user's stated goal. If the user confirms, update the artefact type's `appraisers.allowed` list on the same config branch.
86
+ 3. **Artefact type configuration**: After creating the appraiser, offer to connect it to relevant artefact-type configuration when doing so supports the user's stated goal. If the user confirms, update the artefact type's `appraisers.allowed` list on the same config branch.
116
87
 
117
88
  ## What you do NOT do
118
89
 
@@ -34,24 +34,21 @@ Do not tell the user to call branch tools directly.
34
34
 
35
35
  ## Protocol
36
36
 
37
- ### 1. Gather basics
37
+ ### Context object
38
38
 
39
- From the user's prompt, establish:
40
- - `id` — lowercase, hyphenated identifier (e.g. `haiku`). The
41
- frontmatter `name:` field must equal this id; any human-readable
42
- label goes in the `## Definition` prose, not in frontmatter.
43
- - `file-patterns` — glob patterns for files this type produces
44
- (forge's write scope is exactly these patterns).
45
- - A prose description of what this artefact type is.
39
+ When invoked with pre-filled fields matching the `foundry_config_create_artefact_type` tool args, skip questions for provided fields. Missing fields trigger clarifying questions.
46
40
 
47
- If any of these are missing, ask.
41
+ Context fields: `{id, name, filePatterns, description, appraisers?}`
48
42
 
49
- ### 2. Check for naming conflicts
43
+ When invoked with a context:
44
+ - If all required fields are present, skip the Understand phase and proceed to Plan → Confirm → Build.
45
+ - If only some fields are present, ask only for the missing ones.
50
46
 
51
- Read all existing artefact type definitions in `foundry/artefacts/*/definition.md`.
47
+ ### 1. Understand
52
48
 
53
- - Exact id match hard conflict, must choose a different id
54
- - Semantically similar name or description → warn the user. Ask:
49
+ Ask for each field one question at a time. Prefer multiple choice for `filePatterns`, deriving options from the artefact type name and common conventions (e.g. `haikus/*.md`, `haiku.md`, `output/haiku/*.md`). Ask about `appraisers` (optional) — either provide an existing appraiser ID or skip.
50
+
51
+ **Naming conflict check**: Read all existing artefact type definitions in `foundry/artefacts/*/definition.md`. Exact id match means a hard conflict — choose a different id. A semantically similar name or description triggers a warning:
55
52
 
56
53
  > An artefact type `<existing-id>` already exists that seems similar:
57
54
  > - Existing: <name> — <description summary>
@@ -59,16 +56,7 @@ Read all existing artefact type definitions in `foundry/artefacts/*/definition.m
59
56
  >
60
57
  > Is the new type genuinely distinct, or should you extend the existing one?
61
58
 
62
- ### 3. Check for glob intersection
63
-
64
- For each existing artefact type, check whether the new type's `file-patterns` could match the same files as any existing type's `file-patterns`.
65
-
66
- Examples of intersections:
67
- - `features/*.feature` vs `features/*.feature` — exact overlap
68
- - `features/**` vs `features/*.feature` — subset overlap
69
- - `output/*.md` vs `output/reports/*.md` — potential overlap if nested
70
-
71
- If any intersection is found, this is a hard block:
59
+ **File pattern overlap check**: For each existing artefact type, check whether the new type's `filePatterns` could match the same files as any existing type's patterns. Overlapping file patterns are a hard block:
72
60
 
73
61
  > The file pattern `<new-pattern>` intersects with artefact type `<existing-id>` which uses `<existing-pattern>`.
74
62
  >
@@ -78,100 +66,33 @@ If any intersection is found, this is a hard block:
78
66
 
79
67
  Do not proceed until the patterns are non-overlapping.
80
68
 
81
- ### 4. Draft the definition
69
+ ### 2. Plan
82
70
 
83
71
  Present the definition to the user with these structured fields:
84
72
 
85
- - `id` (string) — lowercase, hyphenated identifier (e.g. `haiku`). Must be unique across artefact types.
86
- - `name` (string) — human-readable label
87
- - `filePatterns` (string[]) — glob patterns for files this type produces (forge's write scope is exactly these patterns)
88
- - `description` (string) — prose description of what this artefact type is
89
- - `appraisers` ({ count?: number, allowed?: string[] }, optional) — appraiser configuration
90
-
91
- The `id` value must exactly match the artefact type's identifier
92
- (lowercase, hyphenated). If you want a human-readable label, put it
93
- in the `name` field.
94
-
95
- Ask: does this capture the artefact type correctly?
96
-
97
- When laws or validators are clearly part of the requested artefact type, draft them during artefact-type creation. Use the validator contract from `add-law` and prefer established packages installed with the project package manager.
98
-
99
- ### 5. Laws (optional)
100
-
101
- Ask:
102
-
103
- > Do you want to define any type-specific laws for this artefact type? (Global laws in `foundry/laws/` will apply automatically.)
104
-
105
- If yes, walk through each law using the same format as `add-law`:
106
- - Draft each law, adding validators where a deterministic check applies
107
- - Check for conflicts with global laws and any existing type-specific laws
108
- - Confirm with the user
109
-
110
- Each law may declare an optional `validators:` block; the YAML shape,
111
- JSONL output contract, `{pattern}` / `{files}` placeholders, skip
112
- rule, working directory, and a worked example are documented once in
113
- the `add-law` skill under **§7a. Validator contract**. Authors of
114
- type-specific laws must follow that contract — do not invent a
115
- different one here.
116
-
117
- **Use existing libraries:** Before writing custom validation logic,
118
- search npm for well-tested libraries that solve the problem (e.g.
119
- `syllable` for syllable counting, `natural` for NLP tasks).
120
- Hand-rolled heuristics are fragile — prefer battle-tested packages.
121
- Install them as project dependencies.
122
-
123
- Check the project's `package.json` for `"type": "module"`:
124
- - If ESM (`"type": "module"`): use `import` syntax, or name scripts with `.mjs` extension
125
- - If CommonJS (no `"type"` field or `"type": "commonjs"`): `require()` is fine, or use `.cjs` extension
126
- - When in doubt, use `.mjs` or `.cjs` extensions to be explicit regardless of project settings
127
-
128
- ### 6. Appraisers (optional)
129
-
130
- Ask:
131
-
132
- > How should appraisers be configured for this artefact type?
133
- > - How many appraisers per foundry cycle? (default: 3)
134
- > - Restrict to specific appraiser personalities? (default: all available)
135
-
136
- If the user specifies preferences, include these fields:
137
-
138
- - `appraisers.count` (number, optional, default: 3) — how many appraisers per foundry cycle
139
- - `appraisers.allowed` (string[], optional, default: all available) — whitelist of appraiser personality IDs
140
-
141
- If the user is happy with the defaults (3 appraisers, any personality), omit the appraisers configuration entirely.
142
-
143
- List the available appraisers from `foundry/appraisers/*.md` so the user can see their options.
144
-
145
- ### 7. Validate the draft
146
-
147
- Call `foundry_config_validate_artefact_type({ name: "<id>", body: "<assembled markdown>" })`. Assemble the body from the fields using the frontmatter format the tool produces internally.
148
-
149
- If the result is `{ ok: false, errors: [...] }`, address each error (adjust the body) and re-run until you get `{ ok: true }`. Common issues: missing required frontmatter keys, references to artefact types or flows that don't exist yet.
73
+ - `id` (string) — lowercase, hyphenated identifier. Must be unique across artefact types.
74
+ - `name` (string) — human-readable label.
75
+ - `filePatterns` (string[]) — glob patterns for files this type produces.
76
+ - `description` (string) — prose description of what this artefact type is.
77
+ - `appraisers` ({ count?: number, allowed?: string[] }, optional) — appraiser configuration.
150
78
 
151
- ### 8. Create the file
79
+ Ask: does this capture the artefact type correctly? Iterate until the user is satisfied.
152
80
 
153
- Call `foundry_config_create_artefact_type({ id: "<id>", name: "<name>", filePatterns: ["<pattern>"], description: "<description>" })`. The tool:
81
+ ### 3. Confirm
154
82
 
155
- - re-validates the body (TOCTOU);
156
- - writes `foundry/artefacts/<id>/definition.md`;
157
- - produces one git commit on the current `config/*` branch.
83
+ Ask: "Proceed with this plan?" — wait for user answer before building. If the user rejects the plan, return to the Understand phase and adjust.
158
84
 
159
- If the tool returns `{ ok: false, errors }` because the target file already exists, read the existing file, incorporate the user's requested changes into the current body, propose the merged result for review, then write and commit the updated file.
85
+ ### 4. Build
160
86
 
161
- Show the user the resulting commit hash from the response.
87
+ 1. **Validate**: Call `foundry_config_validate_artefact_type({ name: "<id>", body: "<assembled markdown>" })`. Assemble the body from the fields using the frontmatter format the tool produces internally. If the result is `{ ok: false, errors: [...] }`, address each error and re-run until `{ ok: true }`. Common issues: missing required frontmatter keys, references to artefact types or flows that do not exist yet.
162
88
 
163
- ### 9. Add laws file (if defined)
89
+ 2. **Create**: Call `foundry_config_create_artefact_type({ id: "<id>", name: "<name>", filePatterns: ["<pattern>"], description: "<description>" })`. The tool re-validates the body (TOCTOU), writes `foundry/artefacts/<id>/definition.md`, and produces one git commit on the current `config/*` branch. Show the user the resulting commit hash.
164
90
 
165
- If you drafted any type-specific laws in step 5, add them via
166
- `foundry_config_add_law` (one call per law) with
167
- `target: { kind: "type-specific", typeId: "<id>" }`. The first call
168
- creates `foundry/artefacts/<id>/laws.md`; subsequent calls append to
169
- that same file. Each call produces its own microcommit. See the
170
- `add-law` skill for the full protocol.
91
+ If the tool returns `{ ok: false, errors }` because the target file already exists, read the existing file, incorporate the user's requested changes into the current body, propose the merged result for review, then write and commit the updated file.
171
92
 
172
- ### 10. Confirm
93
+ 3. **Type-specific laws**: Ask "Define any type-specific laws for this artefact type?" If yes, invoke the `add-law` protocol with context: `{target: {kind: "type-specific", typeId: "<new-type-id>"}}`. The `add-law` skill asks for the missing law fields (id, name, description, passing, failing) and creates the law at `foundry/artefacts/<typeId>/laws.md`.
173
94
 
174
- Show the user the complete file listing and the commit hashes.
95
+ 4. **Appraisers**: Ask "How should appraisers be configured for this artefact type?" Offer the defaults (3 appraisers, any personality) or let the user specify preferences. List the available appraisers from `foundry/appraisers/*.md` so the user can see their options.
175
96
 
176
97
  ## What you do NOT do
177
98
 
@@ -34,151 +34,83 @@ Do not tell the user to call branch tools directly.
34
34
 
35
35
  ## Protocol
36
36
 
37
- ### 1. Identify the foundry flow
37
+ ### Context object
38
38
 
39
- From the user's prompt, identify which foundry flow this foundry cycle belongs to. If not specified, list available flows from `foundry/flows/` and ask.
39
+ When invoked with pre-filled fields matching the `foundry_config_create_cycle` tool args, skip questions for provided fields. Missing fields trigger clarifying questions.
40
40
 
41
- If the parent flow or required artefact type is missing and the user's goal clearly requires it, create that dependency first. If multiple designs are plausible, ask one focused question before creating it.
42
-
43
- ### 2. Gather basics
44
-
45
- From the user's prompt, establish:
46
- - `id` — lowercase, hyphenated identifier for the foundry cycle
47
- - `name` — human-readable name
48
- - `output-type` — the artefact type this foundry cycle produces (must exist in `foundry/artefacts/`)
49
- - `inputs` — artefact types this cycle reads, with a contract type:
50
- - `type`: `any-of` (at least one must exist) or `all-of` (all must exist)
51
- - `artefacts`: list of artefact type IDs
52
- - May be empty for starting cycles
53
- - `targets` — cycle(s) to route to after this cycle completes (may be empty for terminal cycles)
54
- - A prose description of what this foundry cycle does
41
+ Context fields: `{id, name, outputType, description, inputs?, targets?, humanAppraise?, deadlockAppraise?, deadlockIterations?, maxIterations?, assay?, memory?, models?}`
55
42
 
56
- If any of these are missing, ask.
43
+ When invoked with a context:
44
+ - If all required fields are present, skip the Understand phase and proceed to Plan → Confirm → Build.
45
+ - If only some fields are present, ask only for the missing ones.
57
46
 
58
- ### 3. Gather model configuration
47
+ ### 1. Understand
59
48
 
60
- For each stage in the cycle (forge, quench, appraise), ask the user if they want to specify a model:
49
+ **Identify the flow**: From the user's prompt, identify which foundry flow this cycle belongs to. If not specified, list available flows from `foundry/flows/` and ask.
61
50
 
62
- > Each stage can optionally run on a specific model for model diversity. Available session models are listed in your session configuration.
63
- >
64
- > For each stage, specify a model ID (e.g., `openai/gpt-4o`) or leave blank to use the session's default model:
65
- > - forge: ___
66
- > - quench: ___
67
- > - appraise: ___
68
-
69
- Only stages with an explicitly specified model are included in the `models` frontmatter map.
51
+ If the parent flow or required artefact type is missing and the user's goal clearly requires it, create that dependency first. If multiple designs are plausible, ask one focused question before creating it.
70
52
 
71
- If the user has no preference, omit the `models` map and use the session defaults.
53
+ **Required fields** Gather each required field one question at a time:
54
+ - `id` — lowercase, hyphenated identifier for the cycle
55
+ - `name` — human-readable name
56
+ - `outputType` — the artefact type this cycle produces. List existing artefact types from `foundry/artefacts/*/definition.md` as multiple-choice options.
57
+ - `description` — prose description of what this cycle does
72
58
 
73
- ### 4. Configure human appraise
59
+ **Id conflict check**: Read all existing cycle definitions in `foundry/cycles/*.md`. An exact id match is a hard conflict — choose a different id.
74
60
 
75
- Ask the user:
61
+ **Output-type conflict check**: Read the flow definition from `foundry/flows/<flow-id>.md`. Check that no cycle in the flow already outputs the same artefact type. Two cycles producing the same type in one flow is a conflict — the file modification enforcement cannot distinguish which cycle owns the files. If a conflict exists, present it:
76
62
 
77
- > Human-appraise has two independent knobs and one dependent setting:
78
- >
79
- > 1. `human-appraise` — should a human review the artefact every iteration? Default: no.
80
- > 2. `deadlock-appraise` — should a human be pulled in only when LLM appraisers deadlock? Default: yes.
81
- > 3. `deadlock-iterations` — the deadlock threshold (default: 5). Only applies when `deadlock-appraise` or `human-appraise` is enabled.
63
+ > A cycle `<existing-id>` already produces `<outputType>` in this flow. Two cycles producing the same artefact type creates a conflict.
82
64
  >
83
- > - human-appraise: yes/no (default no)
84
- > - deadlock-appraise: yes/no (default yes)
85
- > - deadlock-iterations: number (default 5)
86
-
87
- ### 5. Validate artefact types
88
-
89
- For `output-type` and each entry in `inputs`, verify the artefact type exists in `foundry/artefacts/<type>/definition.md`.
90
-
91
- If a required artefact type is missing and the user's goal clearly requires it, create that dependency first. If the file pattern or type design cannot be inferred safely, ask one focused question before creating it.
92
-
93
- ### 6. Validate against the foundry flow
94
-
95
- Read the flow definition from `foundry/flows/<flow-id>.md`. Check:
65
+ > Options:
66
+ > 1. Choose a different `outputType`
67
+ > 2. Choose a different flow
68
+ > 3. Proceed anyway if the types are intentionally distinct
96
69
 
97
- - No existing foundry cycle in the foundry flow already outputs the same artefact type. Two foundry cycles producing the same type in one foundry flow is a conflict the file modification enforcement can't distinguish which foundry cycle owns the files.
98
- - Each `input` artefact type is produced by some cycle that can run before this one according to the flow's `targets` graph (a reachable predecessor). If an input references an artefact type that no reachable predecessor outputs, warn:
70
+ **Input reachability check**: For each input artefact type, verify that a reachable predecessor in the flow's `targets` graph produces it. If an input references a type that no reachable predecessor outputs, warn:
99
71
 
100
- > Input `<type>` is not produced by any reachable predecessor of this foundry cycle in the flow's `targets` graph. The artefact won't exist when this foundry cycle runs.
72
+ > Input `<type>` is not produced by any reachable predecessor of this cycle in the flow's `targets` graph. The artefact will not exist when this cycle runs.
101
73
  >
102
74
  > Options:
103
- > 1. Add a foundry cycle that produces `<type>` and route to this cycle via `targets`
104
- > 2. Remove `<type>` from inputs (this foundry cycle won't have that context)
105
- > 3. Proceed anyway (the artefact may exist from a previous foundry flow run)
106
-
107
- ### 7. Check for id conflicts
108
-
109
- Read all existing cycle definitions in `foundry/cycles/*.md`.
110
-
111
- - Exact id match → hard conflict, must choose a different id
112
-
113
- ### 8. Check for semantic overlap
114
-
115
- For foundry cycles already in this foundry flow, check whether the new foundry cycle overlaps in purpose:
116
- - Does another foundry cycle already transform the same inputs into a similar output?
117
- - Would the new foundry cycle's description make sense as a revision of an existing foundry cycle rather than a new one?
118
-
119
- If overlap is found, present it and ask the user to confirm the distinction is real.
120
-
121
- ### 9. Draft the definition
122
-
123
- Present the foundry cycle definition to the user with these structured fields:
124
-
125
- - `id` (string) — lowercase, hyphenated identifier
126
- - `name` (string) — human-readable name
127
- - `outputType` (string) — the artefact type this cycle produces (must exist in `foundry/artefacts/`)
128
- - `description` (string) — prose description of what this cycle does
129
- - `inputs` (object, optional) — input contract. Shape: `{ type: "any-of" | "all-of", artefacts: string[] }`. May be omitted for starting cycles.
130
- - `targets` (string[], optional) — cycle IDs to route to after completion. May be omitted for terminal cycles.
131
- - `humanAppraise` (boolean, optional, default: false) — whether a human reviews the artefact every iteration
132
- - `deadlockAppraise` (boolean, optional, default: true) — whether a human is pulled in when LLM appraisers deadlock
133
- - `deadlockIterations` (number, optional, default: 5) — deadlock threshold
134
- - `maxIterations` (number, optional) — maximum iterations before forced progression
135
- - `assay` (object, optional) — assay configuration
136
- - `memory` (object, optional) — memory configuration
137
- - `models` (object, optional) — stage-specific model overrides, e.g. `{ appraise: "openai/gpt-4o" }`
138
-
139
- Ask: does this capture the foundry cycle correctly?
140
-
141
- ### 10. Validate target routing
142
-
143
- For each target cycle:
144
- - Verify the target cycle exists in `foundry/cycles/`
145
- - Verify this cycle's output type satisfies at least one of the target's input artefacts
146
- - If the target doesn't exist yet, note it as pending
75
+ > 1. Add a cycle that produces `<type>` and route to this cycle via `targets`
76
+ > 2. Remove `<type>` from inputs (this cycle will not have that context)
77
+ > 3. Proceed anyway (the artefact may exist from a previous flow run)
147
78
 
148
- For input validation:
149
- - Verify that at least one cycle in the flow has the input artefact type(s) as its output
150
- - If using `all-of`, verify all input types are producible
79
+ **Validate target routing**: For each target cycle, verify the target exists in `foundry/cycles/` and that this cycle's output type satisfies at least one of the target's input artefacts. If a target does not exist yet, note it as pending.
151
80
 
152
- ### 11. Validate the draft
81
+ **Optional clusters** After each cluster, ask whether the user wants to configure it; if not, skip:
153
82
 
154
- Call `foundry_config_validate_cycle({ name: "<id>", body: "<assembled markdown>" })`. Assemble the body from the fields using the frontmatter format the tool produces internally.
83
+ - **Routing**: `inputs` (input contract: `{type: "any-of"|"all-of", artefacts: string[]}`), `targets` (cycle IDs to route to after completion), `maxIterations` (maximum iterations before forced progression)
84
+ - **Human-appraise**: `humanAppraise` (boolean, default false) — human reviews every iteration; `deadlockAppraise` (boolean, default true) — human is pulled in when LLM appraisers deadlock; `deadlockIterations` (number, default 5) — deadlock threshold. Only applies when either appraise is enabled.
85
+ - **Memory and models**: `assay` (assay configuration), `memory` (memory configuration), `models` (stage-specific model overrides, e.g. `{forge: "openai/gpt-4o", appraise: "openai/gpt-4o"}`). For models, offer each stage (forge, quench, appraise) individually. If the user has no preference, omit the `models` map and use the session defaults.
155
86
 
156
- If the result is `{ ok: false, errors: [...] }`, address each error (adjust the body) and re-run until you get `{ ok: true }`. Common issues: missing required frontmatter keys, references to artefact types or flows that don't exist yet.
87
+ ### 2. Plan
157
88
 
158
- ### 12. Create the cycle file
89
+ Present a structured summary of the cycle definition: id, name, outputType, description, and any configured optional fields (inputs, targets, humanAppraise, deadlockAppraise, deadlockIterations, maxIterations, assay, memory, models). Include only fields that have values.
159
90
 
160
- Call `foundry_config_create_cycle({ id: "<id>", name: "<name>", outputType: "<type>", description: "<description>", inputs: ..., targets: ..., humanAppraise: ..., deadlockAppraise: ..., deadlockIterations: ..., maxIterations: ..., assay: ..., memory: ..., models: ... })`. The tool:
91
+ Ask: "Does this capture the cycle correctly?" Iterate until the user is satisfied.
161
92
 
162
- - re-validates the body (TOCTOU);
163
- - writes `foundry/cycles/<id>.md`;
164
- - produces one git commit on the current `config/*` branch.
93
+ ### 3. Confirm
165
94
 
166
- If the tool returns `{ ok: false, errors }` because the target file already exists, read the existing cycle file, apply any necessary updates, write it back, and commit on this `config/*` branch.
95
+ Ask: "Proceed with this plan?" wait for user answer before building. If the user rejects the plan, return to the Understand phase and adjust.
167
96
 
168
- Show the user the resulting commit hash from the response.
97
+ ### 4. Build
169
98
 
170
- ### 13. Add the cycle to the flow's cycle list
99
+ 1. **Validate**: Call `foundry_config_validate_cycle({ name: "<id>", body: "<assembled markdown>" })`. Assemble the body from the fields using the frontmatter format the tool produces internally. If the result is `{ ok: false, errors: [...] }`, address each error and re-run until `{ ok: true }`. Common issues: missing required frontmatter keys, references to artefact types or flows that do not exist yet.
171
100
 
172
- `foundry_config_create_cycle` writes the cycle file only. The cycle still needs to appear in the parent flow's `## Cycles` list.
101
+ 2. **Create**: Call `foundry_config_create_cycle({ id: "<id>", name: "<name>", outputType: "<type>", description: "<description>", inputs: ..., targets: ..., humanAppraise: ..., deadlockAppraise: ..., deadlockIterations: ..., maxIterations: ..., assay: ..., memory: ..., models: ... })`. The tool:
102
+ - re-validates the body (TOCTOU);
103
+ - writes `foundry/cycles/<id>.md`;
104
+ - produces one git commit on the current `config/*` branch.
173
105
 
174
- Read the existing flow file from `foundry/flows/<flow-id>.md`. Add the new cycle id under `## Cycles` if it is not already present. Write the updated file back and commit on this same `config/*` branch.
106
+ If the tool returns `{ ok: false, errors }` because the target file already exists, read the existing cycle file, apply any necessary updates, write it back, and commit on this `config/*` branch.
175
107
 
176
- ### 14. Confirm
108
+ 3. **Add to flow cycle list**: `foundry_config_create_cycle` writes the cycle file only. The cycle still needs to appear in the parent flow's `## Cycles` list. Read the existing flow file from `foundry/flows/<flow-id>.md`. Add the new cycle id under `## Cycles` if not already present. Write the updated file back and commit on this same `config/*` branch.
177
109
 
178
- Show the user the cycle file, the updated flow file, and both commit hashes.
110
+ 4. Show the user the cycle file, the updated flow file, and both commit hashes.
179
111
 
180
112
  ## What you do NOT do
181
113
 
182
- - You do not create foundry cycles that output an artefact type already produced by another foundry cycle in the same foundry flow
114
+ - You do not create cycles that output an artefact type already produced by another cycle in the same flow
183
115
  - You do not skip artefact type validation
184
116
  - You do not create dependencies (artefact types, flows) unless the user's stated goal clearly requires them; ask one focused question when multiple designs are plausible