@really-knows-ai/foundry 3.8.5 → 3.9.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.
@@ -21,9 +21,9 @@ Before running this skill, verify that the `foundry/` directory exists in the pr
21
21
  Appraise runs inside an enforced stage. Your **first** and **last** tool calls are fixed:
22
22
 
23
23
  1. **First:** `foundry_stage_begin({stage, cycle, token})` — copy the token verbatim from the dispatch prompt. No other tool call is permitted before this one.
24
- 2. **Last:** `foundry_stage_end({summary})`.
24
+ 2. **Last:** `foundry_stage_end()`.
25
25
 
26
- Appraise makes **no disk writes**. Feedback output flows through JSONL returned in your response text. The orchestrator's internal consolidate step parses the JSONL, posts feedback, and resolves prior items.
26
+ Appraise makes **no disk writes**. Feedback output flows through `foundry_stage_output` calls. The orchestrator's internal consolidate step reads the outputs, posts feedback, and resolves prior items.
27
27
 
28
28
  ## Protocol
29
29
 
@@ -35,43 +35,25 @@ Appraise makes **no disk writes**. Feedback output flows through JSONL returned
35
35
  6. Evaluate each file against each law. For each law, either:
36
36
  - Note no issues (pass)
37
37
  - Describe the violation, quoting evidence from the artefact
38
- 7. Output JSONL. Each line is one JSON object:
39
-
40
- ```json
41
- {"file": "<path>", "law": "<law-slug>", "text": "<issue description>", "evidence": "<quote from artefact>"}
42
- ```
43
-
38
+ 7. For each violation, call `foundry_stage_output({ file, law, text, evidence })`.
44
39
  `file` and `text` are required. `law` and `evidence` are recommended — `law` tells the orchestrator which law tag to use, `evidence` quotes the offending passage. Optional extra fields (`severity`, `location`) are passed through unchanged.
45
40
 
46
- If there are no issues, output nothing (empty response).
47
-
48
- Your response text is ONLY JSONL — one JSON object per line. No markdown headings, no code blocks, no commentary, no YAML.
49
-
50
- 8. `foundry_stage_end({summary})`. The summary describes how many issues were found (e.g. "3 issues found" or "No issues found").
51
-
52
- ## Output examples
53
-
54
- Good (issues found):
55
-
56
- ```
57
- {"file": "haikus/mountain.md", "law": "syllable-count", "text": "Line 2 has 8 syllables, expected 7", "evidence": "A frog jumps into the pond", "location": "2:1"}
58
- {"file": "haikus/mountain.md", "law": "nature-imagery", "text": "Contains industrial imagery violating nature-only requirement", "evidence": "The rusty old machine"}
59
- ```
41
+ If no issues, call `foundry_stage_end()` directly — no `stage_output` calls needed.
60
42
 
61
- Good (no issues found empty response, then stage_end):
43
+ Do NOT write JSONL as text. Call the tool.
62
44
 
63
- (no output text)
45
+ 8. `foundry_stage_end()`.
64
46
 
65
47
  ## Feedback handling
66
48
 
67
- You do NOT call `foundry_feedback_add` or `foundry_feedback_resolve`. The orchestrator's consolidate step reads your JSONL output, de-duplicates across all appraisers, posts feedback items with tag `law:<slug>`, and resolves prior appraise-sourced feedback.
49
+ You do NOT call `foundry_feedback_add` or `foundry_feedback_resolve`. The orchestrator's consolidate step reads your stage outputs, de-duplicates across all appraisers, posts feedback items with tag `law:<slug>`, and resolves prior appraise-sourced feedback.
68
50
 
69
51
  ## What you do NOT do
70
52
 
71
- - You do not write files — feedback output goes through JSONL, not `foundry_feedback_add`.
53
+ - You do not write files — feedback output goes through `foundry_stage_output`, not `foundry_feedback_add`.
72
54
  - You do not revise the artefact — that is the forge skill's job.
73
55
  - You do not run deterministic validators — that is the quench skill's job.
74
56
  - You do not call `foundry_feedback_add`, `foundry_feedback_action`, `foundry_feedback_wontfix`, or `foundry_feedback_resolve`.
75
57
  - You do not call `foundry_history_append` or `foundry_git_commit` — `foundry_orchestrate` handles those.
76
58
  - You do not register artefacts — that happens automatically.
77
- - You do not output YAML, markdown, or prose — only JSONL.
59
+ - You do not output YAML, markdown, or prose — use `foundry_stage_output` for structured data.
@@ -8,7 +8,7 @@ description: Deterministic population of flow memory by running project-authored
8
8
 
9
9
  Runs the `assay` stage of a cycle. An assay stage executes every extractor listed in the cycle's `assay.extractors` frontmatter, in order. Each extractor is a project-authored CLI script at the path given in its definition file — see the `foundry/memory/extractors/<name>.md` files for what each one does.
10
10
 
11
- The assay stage is **deterministic**. This skill does **not** interpret extractor output. It only calls `foundry_assay_run`, which handles spawning, parsing, validation, and memory upserts. On any failure (extractor non-zero exit, parse error, permission violation, timeout, or post-run memory sync failure), `foundry_assay_run` marks the workfile failed (`status: failed`) with a reason describing the failure, and returns `{error, flow_failed: true, ...}`. The cycle is over — extractor scripts live outside any artefact's `file-patterns`, so forge cannot fix them. The user must fix the extractor and start a new cycle. Your job is to wrap the lifecycle cleanly: end the stage with a descriptive summary even on failure, then stop.
11
+ The assay stage is **deterministic**. This skill does **not** interpret extractor output. It only calls `foundry_assay_run`, which handles spawning, parsing, validation, and memory upserts. On any failure (extractor non-zero exit, parse error, permission violation, timeout, or post-run memory sync failure), `foundry_assay_run` marks the workfile failed (`status: failed`) with a reason describing the failure, and returns `{error, flow_failed: true, ...}`. The cycle is over — extractor scripts live outside any artefact's `file-patterns`, so forge cannot fix them. The user must fix the extractor and start a new cycle. Your job is to wrap the lifecycle cleanly: end the stage and stop.
12
12
 
13
13
  ## Protocol
14
14
 
@@ -22,7 +22,7 @@ Call `foundry_stage_begin({ stage, cycle, token })` with the values from the dis
22
22
 
23
23
  ### 2. Read WORK.md to find the extractor list
24
24
 
25
- Call `foundry_workfile_get()`. Read `frontmatter.assay.extractors`. This is an ordered array of extractor names. If it is missing or empty, this is a routing bug — end the stage (step 5) with an error summary describing the missing extractor list.
25
+ Call `foundry_workfile_get()`. Read `frontmatter.assay.extractors`. This is an ordered array of extractor names. If it is missing or empty, this is a routing bug — end the stage (step 4) with an error describing the missing extractor list.
26
26
 
27
27
  ### Check for failed flow state
28
28
 
@@ -45,21 +45,14 @@ Call `foundry_assay_run({ cycle, extractors })` passing exactly those values. Do
45
45
  - `{ok: true, perExtractor: [{name, rowsUpserted, durationMs}, ...]}` — all extractors succeeded.
46
46
  - `{error, flow_failed: true, aborted: true, failedExtractor, reason, stderr, perExtractor: [...]}` — the run aborted on an extractor failure. The workfile is already marked failed; no further work is permitted until the user abandons the cycle.
47
47
  - `{error, flow_failed: true}` — post-run memory sync failed. Same recovery path: workfile is failed, user must abandon.
48
- - `{error: "..."}` (without `flow_failed`) — a precondition failed (not an active assay stage, etc.). This should not happen if step 1 succeeded; treat as an error and end the stage (step 5) with the error text as the summary.
48
+ - `{error: "..."}` (without `flow_failed`) — a precondition failed (not an active assay stage, etc.). This should not happen if step 1 succeeded; treat as an error and end the stage (step 4).
49
49
 
50
- ### 4. Prepare the summary
50
+ ### 4. End the stage
51
51
 
52
- Build a short summary string for `foundry_stage_end`. Examples:
53
-
54
- - On success: `"ran 2 extractors, upserted 47 rows in 1420ms"`.
55
- - On abort: `"aborted on extractor 'java-symbols': extractor exited with exit code 2"`.
52
+ Call `foundry_stage_end()`. Always end the stage, whether the run succeeded or aborted. The stage lifecycle must close cleanly so the orchestrator can commit.
56
53
 
57
54
  Do not add feedback items, do not call `foundry_feedback_add`. Assay stages cannot file feedback — extractor failure is recorded directly on the workfile (`status: failed`).
58
55
 
59
- ### 5. End the stage
60
-
61
- Call `foundry_stage_end({ summary })` with the summary from step 4. Always end the stage, whether the run succeeded or aborted. The stage lifecycle must close cleanly so the orchestrator can commit.
62
-
63
56
  ## What this skill must not do
64
57
 
65
58
  - **Must not** read or parse extractor output files itself.
@@ -69,4 +62,4 @@ Call `foundry_stage_end({ summary })` with the summary from step 4. Always end t
69
62
 
70
63
  ## If something unexpected happens
71
64
 
72
- If `foundry_assay_run` throws an unrelated error (e.g. `error: memory not enabled`), that is a programming error in the cycle configuration — not an expected extractor failure. Do not retry. End the stage with a summary quoting the error and stop.
65
+ If `foundry_assay_run` throws an unrelated error (e.g. `error: memory not enabled`), that is a programming error in the cycle configuration — not an expected extractor failure. Do not retry. End the stage and stop.
@@ -21,7 +21,7 @@ Before running this skill, verify that the `foundry/` directory exists in the pr
21
21
  Forge runs inside an enforced stage. Your **first** and **last** tool calls are fixed:
22
22
 
23
23
  1. **First:** `foundry_stage_begin({stage, cycle, token})` — the orchestrator hands you `stage`, `cycle`, and an opaque `token` string in the dispatch prompt. Copy the token verbatim; never invent, edit, or re-sign it. No other tool call is permitted before this one. Any writes before `stage_begin` will be blocked by preconditions.
24
- 2. **Last:** `foundry_stage_end({summary})` — return control to the orchestrator. After `stage_end`, the orchestrator's internal finalise step scans the disk and registers your output artefact. **You do not register artefacts yourself.**
24
+ 2. **Last:** `foundry_stage_end()` — return control to the orchestrator. After `stage_end`, the orchestrator's internal finalise step scans the disk and registers your output artefact. **You do not register artefacts yourself.**
25
25
 
26
26
  ## Protocol
27
27
 
@@ -51,7 +51,7 @@ Forge runs inside an enforced stage. Your **first** and **last** tool calls are
51
51
  - Read the selected files for context.
52
52
  7. Produce the artefact, respecting all applicable laws from the start.
53
53
  8. Write the artefact file to a location that matches the artefact type's `file-patterns`.
54
- 9. `foundry_stage_end({summary: "DONE"})`.
54
+ 9. `foundry_stage_output({ status: "done" })` then `foundry_stage_end()`.
55
55
 
56
56
  ### Revision (feedback exists)
57
57
 
@@ -60,26 +60,25 @@ Forge runs inside an enforced stage. Your **first** and **last** tool calls are
60
60
  3. If the cycle declares `inputs`, discover them via filesystem scan against each input type's `file-patterns` (same protocol as first-generation step 6). Re-read the relevant files — they may have changed on disk since the previous iteration (nothing in this cycle wrote to them, but the user may have modified them between iterations).
61
61
  4. Address the single feedback item from the dispatch prompt following the feedback handling rules below.
62
62
  5. Update the artefact file (if fixing), or skip (if WONT-FIX).
63
- 6. `foundry_stage_end({summary})`. The summary must be EXACTLY one of:
64
- - `"ACTIONED"` — file was changed to address the feedback
65
- - `"WONT-FIX: <justification>"` — item already resolved or does not apply
66
- Write NOTHING else in the summary.
63
+ 6. `foundry_stage_output({ status: "actioned" })` then `foundry_stage_end()` file was changed to address the feedback.
64
+ Or: `foundry_stage_output({ status: "wont-fix", reason: "<justification>" })` then `foundry_stage_end()` item already resolved or does not apply.
65
+ Call `foundry_stage_output` with the correct status object. Write nothing else format is validated by the tool.
67
66
 
68
67
  ## Feedback handling
69
68
 
70
69
  The dispatch prompt contains one feedback item to address.
71
70
 
72
71
  **To fix the issue** — change the artefact file and call
73
- `foundry_stage_end({summary: "ACTIONED"})`.
72
+ `foundry_stage_output({ status: "actioned" })` then `foundry_stage_end()`.
74
73
 
75
74
  **If the issue is already resolved** — call
76
- `foundry_stage_end({summary: "WONT-FIX: <justification>"})`.
75
+ `foundry_stage_output({ status: "wont-fix", reason: "<justification>" })` then `foundry_stage_end()`.
77
76
  Do NOT change the file.
78
77
 
79
78
  **If the issue does not apply** (appraise judgement you disagree with) — same
80
- `WONT-FIX:` flow.
79
+ `wont-fix` flow.
81
80
 
82
- The summary is ONLY one of these keywords. No descriptions, no explanations.
81
+ The status is validated by the tool. No descriptions, no explanations.
83
82
 
84
83
  Do NOT call `foundry_feedback_action`, `foundry_feedback_wontfix`, or
85
84
  `foundry_feedback_resolve`. The orchestrator handles transitions automatically.
@@ -109,5 +108,5 @@ items in the list output.
109
108
  - You do not register artefacts — the orchestrator's internal finalise step handles that automatically.
110
109
  - You do not call `foundry_history_append` or `foundry_git_commit` — `foundry_orchestrate` does (those tools are not registered publicly).
111
110
  - You do not evaluate or score the artefact.
112
- - You do not mark feedback as actioned or wont-fix via tool calls — the orchestrator handles feedback transitions based on your artefact changes and `stage_end` summary.
111
+ - You do not mark feedback as actioned or wont-fix via tool calls — the orchestrator handles feedback transitions based on your artefact changes and stage output.
113
112
  - You do not write to any file outside the output artefact type's `file-patterns` (plus `WORK.md` / `WORK.feedback.yaml` / `WORK.history.yaml`). Input files are read-only unless the output type's patterns happen to cover them.
@@ -19,7 +19,7 @@ Before running this skill, verify that the `foundry/` directory exists in the pr
19
19
  Human-appraise runs inside an enforced stage. Your **first** and **last** tool calls are fixed:
20
20
 
21
21
  1. **First:** `foundry_stage_begin({stage, cycle, token})` — copy the token verbatim from the dispatch prompt.
22
- 2. **Last:** `foundry_stage_end({summary})`.
22
+ 2. **Last:** `foundry_stage_end()`.
23
23
 
24
24
  Human-appraise makes **no disk writes**. All output flows through `foundry_feedback_add` and `foundry_feedback_resolve`. `foundry_stage_end` flags unexpected writes as a violation.
25
25
 
@@ -35,7 +35,7 @@ When invoked from orchestrate, you receive `{cycle, token, context}`:
35
35
 
36
36
  Your FIRST tool call must be `foundry_stage_begin({stage: 'human-appraise:<cycle>', cycle, token})`.
37
37
 
38
- 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.
38
+ Your last tool calls must be `foundry_stage_output({ verdict: "approved" })` then `foundry_stage_end()`. The verdict is communicated through `foundry_stage_output` before the stage is closed.
39
39
 
40
40
  ## Protocol
41
41
 
@@ -54,7 +54,7 @@ Your LAST tool call must be `foundry_stage_end({summary: '<one-sentence descript
54
54
  > 2. Back out to main (`git checkout main`) and delete the work branch.
55
55
  > 3. Investigate and fix the root cause of the failure before restarting.
56
56
 
57
- Then call `foundry_stage_end({summary: 'Flow is failed; no human appraisal performed'})`, return control to the user, and stop.
57
+ Then call `foundry_stage_end()`, return control to the user, and stop.
58
58
 
59
59
  3. `foundry_artefacts_list({})` — this cycle's branch artefact changes as `[{ file, state }]` entries.
60
60
  4. `foundry_feedback_list` — all existing feedback items.
@@ -118,8 +118,8 @@ options:
118
118
 
119
119
  ### A.3 Act on response
120
120
 
121
- - **Approve**: No feedback added. Call `foundry_stage_end({summary: 'Human approved no issues'})`. Sort will route to `done`.
122
- - **Provide feedback**: Ask the user what needs changing (the user types their feedback). Then call `foundry_feedback_add({ file: '<artefact-file>', text: '<user feedback>', tag: 'human' })`. Call `foundry_stage_end({summary: 'Human requested changes'})`. Sort will route to forge.
121
+ - **Approve**: No feedback added. Call `foundry_stage_output({ verdict: "approved" })` then `foundry_stage_end()`. Sort will route to `done`.
122
+ - **Provide feedback**: Ask the user what needs changing (the user types their feedback). Then call `foundry_feedback_add({ file: '<artefact-file>', text: '<user feedback>', tag: 'human' })`. Call `foundry_stage_end()`. Sort will route to forge.
123
123
 
124
124
  ---
125
125
 
@@ -178,8 +178,8 @@ options:
178
178
  description: "Provide additional notes for forge"
179
179
  ```
180
180
 
181
- - **None — continue**: Call `foundry_stage_end({summary: 'Human reviewed <count> item(s) agreed, <count> overridden'})`.
182
- - **Add more feedback**: Ask the user what they want to add, then call `foundry_feedback_add({ file: '<file>', text: '<text>', tag: 'human' })`. Then call `foundry_stage_end({summary: 'Human reviewed with additional feedback'})`.
181
+ - **None — continue**: Call `foundry_stage_output({ verdict: "approved" })` then `foundry_stage_end()`.
182
+ - **Add more feedback**: Ask the user what they want to add, then call `foundry_feedback_add({ file: '<file>', text: '<text>', tag: 'human' })`. Then call `foundry_stage_end()`.
183
183
 
184
184
  ---
185
185
 
@@ -207,5 +207,5 @@ What human-appraise CAN do:
207
207
  - You do not modify the artefact.
208
208
  - You do not skip the pause — the human must respond before continuing.
209
209
  - You do not call `foundry_history_append` or `foundry_git_commit` — `foundry_orchestrate` owns those (the tools are not registered publicly).
210
- - You do not register artefacts — handled by `foundry_stage_end({summary})`.
210
+ - You do not register artefacts — handled by `foundry_stage_end()`.
211
211
  - You do not present the full artefact file content — the human can inspect files themselves if curious. Show summaries only.
@@ -82,7 +82,7 @@ module handles lifecycle internally.
82
82
 
83
83
  Payload: `{stage, token, context}`.
84
84
 
85
- Invoke the `human-appraise` skill inline, passing `{cycle, token, context}`. The skill will prompt the user, collect feedback, and call `foundry_stage_end({summary})`.
85
+ Invoke the `human-appraise` skill inline, passing `{cycle, token, context}`. The skill will prompt the user, collect feedback, and call `foundry_stage_output({ verdict: "approved" })` then `foundry_stage_end()`.
86
86
 
87
87
  When it returns, call `foundry_orchestrate({lastResult: {ok: true}})`.
88
88
 
@@ -117,7 +117,7 @@ Report to the user: "Cycle halted (violation): `<details>`. Affected files: `<af
117
117
 
118
118
  The orchestrator manages forge feedback transitions directly. After each
119
119
  forge subagent completes, `enforceForgeStage` inspects the outcome — a
120
- version change or a WONT-FIX in the stage-end summary — and transitions the
120
+ version change or a wont-fix status in the stage output — and transitions the
121
121
  feedback item to `actioned` or `wont-fix`. Forge subagents do not call
122
122
  `foundry_feedback_action` or `foundry_feedback_wontfix`; those are the
123
123
  orchestrator's responsibility. If you want to inspect feedback state for
@@ -19,7 +19,7 @@ Before running this skill, verify that the `foundry/` directory exists in the pr
19
19
  Quench runs inside an enforced stage. Your **first** and **last** tool calls are fixed:
20
20
 
21
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})`.
22
+ 2. **Last:** `foundry_stage_end()`.
23
23
 
24
24
  Quench makes **no disk writes**. You produce feedback via `foundry_feedback_add`, never by creating or modifying files. The orchestrator's internal finalize step (run after `stage_end`) will flag any unexpected writes as a violation.
25
25
 
@@ -43,11 +43,11 @@ Quench makes **no disk writes**. You produce feedback via `foundry_feedback_add`
43
43
  4. For each artefact change:
44
44
  a. `foundry_validate_run({ typeId: '<type-id>' })` — executes all law-based validators for the artefact type. The tool returns `{ ok, validatorsRun, items, errors }`. `items` is the array of parsed feedback items; each entry carries `lawId`, `validatorId`, `file`, and `text` (plus optional `location` and `severity`). `errors` carries validator-level failures with `lawId`, `validatorId`, `type` (`parse` or `pattern-mismatch`), and `message`.
45
45
  b. For each entry in `items`: call `foundry_feedback_add` with `{ file: item.file, text: item.text, tag: 'law:' + item.lawId + ':' + item.validatorId }`. The tag uses the law ID and validator ID returned by the tool so operators reading `WORK.feedback.yaml` can identify exactly which validator produced each item.
46
- c. If `errors` is non-empty, the validators themselves misbehaved (malformed JSONL or files outside the artefact type's `file-patterns`). Report these to the user via `foundry_stage_end` summary; do not convert them to law-tagged feedback.
46
+ c. If `errors` is non-empty, the validators themselves misbehaved (malformed JSONL or files outside the artefact type's `file-patterns`). Report these to the user; do not convert them to law-tagged feedback.
47
47
  5. Call `foundry_feedback_list`. For items whose `source` matches your stage id and whose state is `actioned` or `wont-fix`, use the validation results from step 4 to resolve them by id: approve when the relevant validation now passes or the deterministic issue is gone; reject with a reason when it still fails.
48
48
  6. If every command passes for every artefact change, add no new feedback.
49
- 7. If the artefact list is empty, `foundry_stage_end({summary: 'SKIP: no files'})` and stop.
50
- 8. `foundry_stage_end({summary})`.
49
+ 7. If the artefact list is empty, `foundry_stage_end()` and stop.
50
+ 8. `foundry_stage_end()`.
51
51
 
52
52
  ## Feedback handling
53
53
 
@@ -86,7 +86,7 @@ deadlocked items (only human-appraise can override those).
86
86
 
87
87
  ## History
88
88
 
89
- Do NOT call `foundry_history_append` or `foundry_git_commit` — `foundry_orchestrate` handles those (the tools are not registered publicly). Return a clear summary via `foundry_stage_end` (e.g., "2 validation issues found" or "Validation passed").
89
+ Do NOT call `foundry_history_append` or `foundry_git_commit` — `foundry_orchestrate` handles those (the tools are not registered publicly).
90
90
 
91
91
  ## What you do NOT do
92
92
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@really-knows-ai/foundry",
3
- "version": "3.8.5",
3
+ "version": "3.9.0",
4
4
  "description": "A skill-driven framework for governed artefact generation with AI coding tools. Define your own artefact types, laws, and flows — Foundry handles the forge → quench → appraise pipeline with deterministic routing, quality gates, and iterative refinement.",
5
5
  "type": "module",
6
6
  "main": "dist/.opencode/plugins/foundry.js",