@really-knows-ai/foundry 2.3.0 → 2.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.
- package/CHANGELOG.md +23 -0
- package/README.md +330 -139
- package/docs/concepts.md +89 -26
- package/docs/getting-started.md +149 -40
- package/docs/work-spec.md +38 -24
- package/package.json +1 -1
- package/skills/add-appraiser/SKILL.md +8 -2
- package/skills/add-artefact-type/SKILL.md +8 -2
- package/skills/add-cycle/SKILL.md +8 -2
- package/skills/add-flow/SKILL.md +8 -2
- package/skills/add-law/SKILL.md +8 -2
- package/skills/flow/SKILL.md +7 -5
- package/skills/forge/SKILL.md +15 -5
package/docs/concepts.md
CHANGED
|
@@ -1,59 +1,122 @@
|
|
|
1
1
|
# Concepts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is the glossary. Every term here has a single definition and links out to the spec document that elaborates it. Concepts are arranged roughly top-down: flows contain cycles, cycles contain stages, stages operate on artefacts, artefacts are governed by laws and evaluated by appraisers.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Flow
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The top-level unit of work. Defined in `foundry/flows/*.md`. A flow declares:
|
|
10
10
|
|
|
11
|
-
A
|
|
12
|
-
-
|
|
13
|
-
- Zero or more input artefact types (read-only, from previous foundry cycles)
|
|
11
|
+
- A `starting-cycles` list — hints about which cycles can be entered first when the flow begins.
|
|
12
|
+
- A set of cycles (listed under `## Cycles`). Order is not implied — routing between cycles is owned by cycles themselves via their `targets` field.
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
Running a flow creates a work branch and a `WORK.md`. The flow completes when no more reachable cycles remain to run, or when the user decides to stop.
|
|
15
|
+
|
|
16
|
+
## Cycle
|
|
17
|
+
|
|
18
|
+
An iterative loop that produces a single artefact type. Defined in `foundry/cycles/*.md`. A cycle declares:
|
|
19
|
+
|
|
20
|
+
- `output` — the artefact type it produces (read-write).
|
|
21
|
+
- `inputs` — a contract (`any-of` / `all-of`) over other artefact types. Inputs are discovered on disk; they are read-only unless the output type's patterns happen to cover them.
|
|
22
|
+
- `targets` — the cycle(s) that may run after this one. May be empty (terminal cycle).
|
|
23
|
+
- `human-appraise` — whether a human quality gate runs every iteration (default: `false`).
|
|
24
|
+
- `deadlock-appraise` — whether a human is pulled in when LLM appraisers deadlock (default: `true`).
|
|
25
|
+
- `deadlock-iterations` — deadlock threshold (default: `5`).
|
|
26
|
+
- `models` — optional per-stage model overrides.
|
|
27
|
+
|
|
28
|
+
A cycle runs **forge → quench → appraise** (and optionally **human-appraise**), looping until all feedback is resolved or `max-iterations` is hit.
|
|
16
29
|
|
|
17
30
|
## Stage
|
|
18
31
|
|
|
19
|
-
|
|
32
|
+
A single step within a cycle. Every stage is referenced as `base:alias` (e.g. `forge:write-haiku`, `quench:check-syllables`) — the base is the stage type; the alias makes the stage's role self-documenting in WORK.md.
|
|
20
33
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
34
|
+
Stage bases:
|
|
35
|
+
|
|
36
|
+
- **forge** — produce or revise the artefact.
|
|
37
|
+
- **quench** — run deterministic CLI checks (skipped if the artefact type has no `validation.md`).
|
|
38
|
+
- **appraise** — subjective evaluation by multiple appraiser sub-agents.
|
|
39
|
+
- **human-appraise** — human quality gate. Can run every iteration, only on deadlock, or both.
|
|
40
|
+
|
|
41
|
+
Every stage runs inside a token-gated lifecycle (`foundry_stage_begin` / `foundry_stage_end` / `foundry_stage_finalize`). Mutation tools are stage-locked: a forge stage can't add feedback, a quench stage can't register artefacts. See the enforcement section of the [README](../README.md#enforcement-model).
|
|
25
42
|
|
|
26
43
|
## Artefact type
|
|
27
44
|
|
|
28
|
-
A definition of what
|
|
29
|
-
|
|
30
|
-
- `
|
|
31
|
-
- `
|
|
45
|
+
A definition of what is being produced. Lives in `foundry/artefacts/<type>/`:
|
|
46
|
+
|
|
47
|
+
- `definition.md` — identity, file patterns, output directory, appraiser config, prose description.
|
|
48
|
+
- `laws.md` *(optional)* — type-specific subjective criteria.
|
|
49
|
+
- `validation.md` *(optional)* — CLI commands for deterministic quench checks.
|
|
50
|
+
|
|
51
|
+
File patterns must not overlap with any other artefact type's patterns — the write-invariant enforcer needs to know which type owns a given file.
|
|
32
52
|
|
|
33
53
|
## Law
|
|
34
54
|
|
|
35
|
-
A subjective pass/fail criterion.
|
|
55
|
+
A subjective pass/fail criterion. Two scopes:
|
|
56
|
+
|
|
57
|
+
- **Global** — `foundry/laws/*.md`, all files concatenated, applies to every artefact.
|
|
58
|
+
- **Type-specific** — `foundry/artefacts/<type>/laws.md`.
|
|
59
|
+
|
|
60
|
+
Each law is a `## heading` (its identifier, used in feedback tags as `#law:<id>`) with a description, passing criteria, and failing criteria.
|
|
36
61
|
|
|
37
62
|
## Appraiser
|
|
38
63
|
|
|
39
|
-
An independent evaluator with a defined personality. Lives in `foundry/appraisers
|
|
64
|
+
An independent evaluator with a defined personality. Lives in `foundry/appraisers/*.md`. Appraisers may specify a `model` field to override the cycle-level appraise model. Each artefact type picks which appraisers may evaluate it (`appraisers.allowed`) and how many run per iteration (`appraisers.count`). Selection distributes evenly across allowed personalities.
|
|
40
65
|
|
|
41
66
|
## WORK.md
|
|
42
67
|
|
|
43
|
-
The transient shared state for a
|
|
68
|
+
The transient shared state for a flow. Created on the work branch by the flow skill, it tracks:
|
|
69
|
+
|
|
70
|
+
- Current position (flow, cycle, stage list, iteration limits) in frontmatter.
|
|
71
|
+
- The goal (prose — written once).
|
|
72
|
+
- An artefact registry (file, type, cycle, status).
|
|
73
|
+
- All feedback with its full lifecycle.
|
|
74
|
+
|
|
75
|
+
See [work-spec.md](work-spec.md) for the full spec.
|
|
76
|
+
|
|
77
|
+
## WORK.history.yaml
|
|
78
|
+
|
|
79
|
+
Append-only log of every stage execution, sitting next to WORK.md. Used by sort to reconstruct what has happened in the current cycle. See [work-spec.md](work-spec.md).
|
|
44
80
|
|
|
45
81
|
## Feedback
|
|
46
82
|
|
|
47
|
-
The communication mechanism between stages. Written as markdown checklist items in WORK.md
|
|
83
|
+
The communication mechanism between stages. Written as markdown checklist items in WORK.md, grouped by artefact file, tagged by source:
|
|
84
|
+
|
|
85
|
+
- `#validation` — from a deterministic quench command. Cannot be wont-fixed.
|
|
86
|
+
- `#law:<law-id>` — from an appraiser, tied to a specific law. May be wont-fixed with justification.
|
|
87
|
+
- `#human` — from a human-appraise stage. Takes absolute priority; cannot be wont-fixed.
|
|
88
|
+
|
|
89
|
+
Lifecycle: `open` → `actioned` / `wont-fix` → `approved` / `rejected`. `approved` is terminal; `rejected` re-opens. Items are never deleted.
|
|
90
|
+
|
|
91
|
+
## HITL / human-appraise
|
|
92
|
+
|
|
93
|
+
Human-in-the-loop checkpoint. A stage where Foundry pauses and asks a human for input. Two triggers:
|
|
94
|
+
|
|
95
|
+
1. **Every-iteration** — the cycle declares `human-appraise: true`. The `human-appraise` stage runs after LLM appraise each iteration.
|
|
96
|
+
2. **Deadlock** — the cycle declares `deadlock-appraise: true` (default). If forge and appraisers ping-pong on the same items for `deadlock-iterations` (default 5) iterations, sort inserts a `human-appraise` stage to break the tie.
|
|
48
97
|
|
|
49
|
-
|
|
98
|
+
Human feedback is tagged `#human` and takes priority over LLM feedback on the same topic.
|
|
50
99
|
|
|
51
|
-
|
|
100
|
+
## Micro-commit
|
|
52
101
|
|
|
53
|
-
|
|
102
|
+
Every stage ends with a commit made by the orchestrator. This enables two things: file-modification enforcement (the write-invariant check compares the stage's diff to its allowed patterns) and recoverability (a crash mid-flow leaves a clean commit boundary to resume from). Orchestration refuses to proceed if uncommitted work is lingering in `WORK.md`, `WORK.history.yaml`, or `.foundry/`.
|
|
54
103
|
|
|
55
|
-
|
|
104
|
+
## Stage token
|
|
105
|
+
|
|
106
|
+
A single-use HMAC-signed string, minted by `foundry_orchestrate` when a stage is dispatched. The sub-agent must redeem the token via `foundry_stage_begin`; mutation tools then check the active stage matches their role. Keys live in `.foundry/.secret` (mode 0600, gitignored, one per worktree). This prevents out-of-band mutations, replayed stages, and sub-agents skipping the lifecycle.
|
|
107
|
+
|
|
108
|
+
## `.foundry/` state directory
|
|
109
|
+
|
|
110
|
+
A gitignored directory created on first plugin boot, holding runtime state:
|
|
111
|
+
|
|
112
|
+
- `.secret` — the HMAC key.
|
|
113
|
+
- `active-stage.json` — present only during an active stage.
|
|
114
|
+
- `last-stage.json` — used by `foundry_stage_finalize` after `stage_end`.
|
|
56
115
|
|
|
57
116
|
## Custom tools
|
|
58
117
|
|
|
59
|
-
All deterministic pipeline operations are exposed as custom tools
|
|
118
|
+
All deterministic pipeline operations are exposed as custom tools by the Foundry plugin. Skills call these tools instead of manipulating files directly. Tools are backed by shared library modules in `scripts/lib/` with injectable I/O so they can be unit-tested. This separation ensures state transitions and routing logic are tested code, not LLM interpretation. See the [README](../README.md#custom-tools) for the full catalogue.
|
|
119
|
+
|
|
120
|
+
## Skill
|
|
121
|
+
|
|
122
|
+
A self-contained workflow written as markdown with YAML frontmatter. Foundry ships pipeline skills (`flow`, `orchestrate`, `forge`, `quench`, `appraise`, `human-appraise`), authoring skills (`add-*`, `init-foundry`), and utility skills (`list-agents`, `refresh-agents`, `upgrade-foundry`). Skills are either **atomic** (do one thing) or **composite** (orchestrate other skills).
|
package/docs/getting-started.md
CHANGED
|
@@ -1,78 +1,187 @@
|
|
|
1
1
|
# Getting Started
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
End-to-end walkthrough for setting up Foundry and running your first flow.
|
|
4
|
+
|
|
5
|
+
---
|
|
4
6
|
|
|
5
7
|
## Prerequisites
|
|
6
8
|
|
|
7
|
-
-
|
|
8
|
-
- Node.js
|
|
9
|
-
-
|
|
9
|
+
- A git repository initialised with a clean working tree.
|
|
10
|
+
- Node.js ≥ 18.3.0 (for the plugin and validation scripts).
|
|
11
|
+
- [OpenCode](https://opencode.ai) (primary target — multi-model routing relies on OpenCode's agent files).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
Add Foundry to `opencode.json`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"packages": {
|
|
20
|
+
"@really-knows-ai/foundry": "latest"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Restart OpenCode (or reload plugins) so the plugin registers its tools and skills.
|
|
26
|
+
|
|
27
|
+
## Initialize
|
|
28
|
+
|
|
29
|
+
In your project, invoke the `init-foundry` skill. It:
|
|
30
|
+
|
|
31
|
+
1. Creates the `foundry/` directory structure:
|
|
32
|
+
```
|
|
33
|
+
foundry/
|
|
34
|
+
artefacts/.gitkeep
|
|
35
|
+
flows/.gitkeep
|
|
36
|
+
cycles/.gitkeep
|
|
37
|
+
laws/.gitkeep
|
|
38
|
+
appraisers/.gitkeep
|
|
39
|
+
```
|
|
40
|
+
2. Runs `refresh-agents` to generate `.opencode/agents/foundry-*.md` — one per available model — so cycles can dispatch to specific models later.
|
|
41
|
+
3. Commits the scaffolding.
|
|
42
|
+
|
|
43
|
+
The `.foundry/` runtime directory (holding `.secret` for stage tokens) is created automatically on first plugin boot and added to `.gitignore`.
|
|
10
44
|
|
|
11
|
-
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Author the configuration
|
|
48
|
+
|
|
49
|
+
Foundry's configuration is five things: artefact types, laws, appraisers, cycles, and flows. You can write the files by hand, but the authoring skills do conflict checking, scaffolding, and validation — use them.
|
|
12
50
|
|
|
13
51
|
### 1. Define an artefact type
|
|
14
52
|
|
|
15
|
-
|
|
53
|
+
Run `add-artefact-type`. It walks you through:
|
|
16
54
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
55
|
+
- `id` (lowercase, hyphenated), `name`, prose description.
|
|
56
|
+
- `file-patterns` — glob patterns describing which files this type owns. The skill refuses patterns that overlap with existing types.
|
|
57
|
+
- `output-dir` — where forge should write new files.
|
|
58
|
+
- Appraiser config — how many appraisers evaluate this type and which personalities are allowed.
|
|
59
|
+
- Optional `laws.md` — type-specific criteria.
|
|
60
|
+
- Optional `validation.md` — CLI commands for quench (non-zero exit = failure).
|
|
23
61
|
|
|
24
|
-
|
|
62
|
+
Produces `foundry/artefacts/<id>/definition.md` (+ optional `laws.md`, `validation.md`).
|
|
25
63
|
|
|
26
64
|
### 2. Write laws
|
|
27
65
|
|
|
28
|
-
|
|
66
|
+
Laws are subjective pass/fail criteria evaluated by appraisers. Two scopes:
|
|
67
|
+
|
|
68
|
+
- **Global** — `foundry/laws/*.md`. All files are concatenated and apply to every artefact.
|
|
69
|
+
- **Type-specific** — `foundry/artefacts/<type>/laws.md`.
|
|
29
70
|
|
|
30
|
-
Each law is a
|
|
71
|
+
Run `add-law` to create one with conflict detection. Each law is a `## heading` (its identifier, referenced as `#law:<id>` in feedback) with a description, passing criteria, and failing criteria.
|
|
31
72
|
|
|
32
|
-
### 3.
|
|
73
|
+
### 3. Create appraisers
|
|
33
74
|
|
|
34
|
-
|
|
75
|
+
Appraisers are independent evaluators with named personalities. Run `add-appraiser`. Each appraiser may override the cycle-level appraise model via a `model` field. Artefact types pick which appraisers may evaluate them (`appraisers.allowed`).
|
|
35
76
|
|
|
36
|
-
|
|
77
|
+
### 4. Define a cycle
|
|
78
|
+
|
|
79
|
+
Run `add-cycle`. A cycle produces one artefact type and declares:
|
|
80
|
+
|
|
81
|
+
- `output` — the artefact type (must already exist).
|
|
82
|
+
- `inputs` — a contract (`any-of` or `all-of`) over other types. Empty for starting cycles.
|
|
83
|
+
- `targets` — the cycle(s) that may run after this one. Empty for terminal cycles.
|
|
84
|
+
- `human-appraise` / `deadlock-appraise` / `deadlock-iterations` — human-gate config.
|
|
85
|
+
- `models` — optional per-stage model overrides.
|
|
86
|
+
|
|
87
|
+
Example:
|
|
88
|
+
|
|
89
|
+
```markdown
|
|
37
90
|
---
|
|
38
|
-
id:
|
|
39
|
-
name:
|
|
40
|
-
output:
|
|
41
|
-
inputs:
|
|
91
|
+
id: haiku-creation
|
|
92
|
+
name: Haiku Creation
|
|
93
|
+
output: haiku
|
|
94
|
+
inputs:
|
|
95
|
+
type: any-of
|
|
96
|
+
artefacts:
|
|
97
|
+
- petition
|
|
98
|
+
targets: []
|
|
99
|
+
human-appraise: false
|
|
100
|
+
deadlock-appraise: true
|
|
101
|
+
deadlock-iterations: 5
|
|
102
|
+
models:
|
|
103
|
+
appraise: openai/gpt-5
|
|
42
104
|
---
|
|
105
|
+
|
|
106
|
+
# Haiku Creation
|
|
107
|
+
|
|
108
|
+
Writes a haiku satisfying the petition produced by haiku-ideation.
|
|
43
109
|
```
|
|
44
110
|
|
|
45
|
-
|
|
111
|
+
The skill validates that every input type can be produced by some cycle in the flow and that targets are reachable.
|
|
46
112
|
|
|
47
|
-
###
|
|
113
|
+
### 5. Define a flow
|
|
48
114
|
|
|
49
|
-
|
|
115
|
+
Run `add-flow`. A flow groups cycles and declares starting points:
|
|
50
116
|
|
|
51
117
|
```markdown
|
|
52
118
|
---
|
|
53
|
-
id:
|
|
54
|
-
name:
|
|
119
|
+
id: make-haiku
|
|
120
|
+
name: Make a Haiku
|
|
121
|
+
starting-cycles:
|
|
122
|
+
- haiku-ideation
|
|
55
123
|
---
|
|
56
124
|
|
|
57
|
-
#
|
|
125
|
+
# Make a Haiku
|
|
58
126
|
|
|
59
|
-
|
|
127
|
+
End-to-end flow: petition → haiku, with a human quality gate.
|
|
60
128
|
|
|
61
129
|
## Cycles
|
|
62
130
|
|
|
63
|
-
|
|
131
|
+
- haiku-ideation
|
|
132
|
+
- haiku-creation
|
|
64
133
|
```
|
|
65
134
|
|
|
66
|
-
|
|
135
|
+
Routing between cycles is owned by individual cycles via their `targets`, not by the flow.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Run the flow
|
|
140
|
+
|
|
141
|
+
Tell OpenCode something like:
|
|
142
|
+
|
|
143
|
+
> Run the `make-haiku` flow to write a haiku about autumn rain.
|
|
144
|
+
|
|
145
|
+
The `flow` skill will:
|
|
146
|
+
|
|
147
|
+
1. Check prerequisites and pick a starting cycle — matching your prose to a cycle's output type. If the request is ambiguous, it prompts (defaulting to `starting-cycles`). If a cycle's input contract can't be satisfied from files on disk, it won't be chosen.
|
|
148
|
+
2. Create a work branch and scaffold `WORK.md` with the goal.
|
|
149
|
+
3. Hand off to `orchestrate`, which drives the cycle:
|
|
150
|
+
- **forge** writes the artefact.
|
|
151
|
+
- **quench** runs CLI validators (if configured).
|
|
152
|
+
- **appraise** dispatches parallel appraiser sub-agents and consolidates their `#law:<id>` feedback.
|
|
153
|
+
- **human-appraise** (if configured, or on deadlock) asks you for input.
|
|
154
|
+
- If any unresolved feedback remains, another forge iteration begins.
|
|
155
|
+
4. When the cycle completes, the flow skill checks the cycle's `targets`. If a target's input contract is satisfied, it asks whether to proceed.
|
|
156
|
+
5. When all desired cycles are done, the flow skill summarises the output and asks how to finish — squash-merge, PR, or leave the branch.
|
|
157
|
+
|
|
158
|
+
Every stage ends with a micro-commit. Violations of the write invariant (writing to disallowed files) hard-stop the cycle.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Inspecting progress
|
|
163
|
+
|
|
164
|
+
While a flow is running, the state of the world is in three places:
|
|
67
165
|
|
|
68
|
-
|
|
166
|
+
- `WORK.md` — current cycle, goal, artefact table, all feedback with full lifecycle.
|
|
167
|
+
- `WORK.history.yaml` — append-only log of every stage execution.
|
|
168
|
+
- `git log` — one commit per stage.
|
|
169
|
+
|
|
170
|
+
You can pause and resume: if the flow skill sees an existing `WORK.md` when you start, it asks whether to resume, discard, or abort. Resume is only offered if the existing flow and cycle match the current request.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Cleaning up
|
|
175
|
+
|
|
176
|
+
Before squash-merging the work branch back into main, **delete `WORK.md` and `WORK.history.yaml`** — they're ephemeral per-flow state, not artefacts. `.foundry/` is gitignored and doesn't need cleanup.
|
|
177
|
+
|
|
178
|
+
If you used `foundry_git_finish`, it handles this for you.
|
|
179
|
+
|
|
180
|
+
---
|
|
69
181
|
|
|
70
|
-
##
|
|
182
|
+
## Next steps
|
|
71
183
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
- Appraise dispatches sub-agent appraisers against the laws
|
|
77
|
-
- If feedback exists, forge revises and the foundry cycle repeats
|
|
78
|
-
3. When all foundry cycles complete, the human decides to merge, PR, or discard
|
|
184
|
+
- [docs/concepts.md](concepts.md) — concise glossary.
|
|
185
|
+
- [docs/work-spec.md](work-spec.md) — full WORK.md spec.
|
|
186
|
+
- [README.md](../README.md) — architecture, enforcement, design decisions.
|
|
187
|
+
- [CHANGELOG.md](../CHANGELOG.md) — version history.
|
package/docs/work-spec.md
CHANGED
|
@@ -10,23 +10,31 @@ flow: <flow-id>
|
|
|
10
10
|
cycle: <current-cycle-id>
|
|
11
11
|
stages: [forge:write-haiku, quench:check-syllables, appraise:evaluate-quality]
|
|
12
12
|
max-iterations: 3
|
|
13
|
+
human-appraise: false
|
|
14
|
+
deadlock-appraise: true
|
|
15
|
+
deadlock-iterations: 5
|
|
16
|
+
models:
|
|
17
|
+
forge: anthropic/claude-opus-4.7
|
|
18
|
+
appraise: openai/gpt-5
|
|
13
19
|
---
|
|
14
20
|
```
|
|
15
21
|
|
|
16
22
|
Fields:
|
|
17
|
-
- `flow` — the foundry flow being executed
|
|
18
|
-
- `cycle` — the current
|
|
19
|
-
- `stages` — the ordered route for this
|
|
20
|
-
- `max-iterations` — how many forge passes before the
|
|
23
|
+
- `flow` — the foundry flow being executed.
|
|
24
|
+
- `cycle` — the current cycle id.
|
|
25
|
+
- `stages` — the ordered route for this cycle. Each entry uses `base:alias` format where `base` is the stage type (`forge`, `quench`, `appraise`, or `human-appraise`) and `alias` is a human-readable name for what that stage does in this cycle. Derived from the cycle and artefact type: `forge` + `appraise` are always included, `quench` is included iff the artefact type has `validation.md`, `human-appraise` is included iff the cycle sets `human-appraise: true`.
|
|
26
|
+
- `max-iterations` — how many forge passes before the cycle is blocked (default: 3).
|
|
27
|
+
- `human-appraise` — run human-appraise every iteration (default: `false`).
|
|
28
|
+
- `deadlock-appraise` — route to human-appraise when LLM appraisers deadlock (default: `true`).
|
|
29
|
+
- `deadlock-iterations` — deadlock threshold (default: 5).
|
|
30
|
+
- `models` — optional per-stage model overrides; individual appraisers may further override via their own `model` field.
|
|
21
31
|
|
|
22
|
-
The `stages` list is the happy path. Sort follows it but loops back to `forge` when unresolved feedback demands it.
|
|
32
|
+
The `stages` list is the happy path. Sort follows it but loops back to `forge` when unresolved feedback demands it, and inserts a `human-appraise` stage on deadlock.
|
|
23
33
|
|
|
24
34
|
### Who sets what
|
|
25
35
|
|
|
26
|
-
- `flow` — set by the
|
|
27
|
-
- `
|
|
28
|
-
- `stages` — set by the orchestrate skill when starting each foundry cycle (reads artefact type to determine if quench is needed)
|
|
29
|
-
- `max-iterations` — set by the orchestrate skill (default 3, could be overridden in foundry cycle definition)
|
|
36
|
+
- `flow`, `cycle`, `goal` — set by the `flow` skill via `foundry_workfile_create` at flow/cycle boundaries.
|
|
37
|
+
- `stages`, `max-iterations`, `human-appraise`, `deadlock-appraise`, `deadlock-iterations`, `models` — set by `foundry_orchestrate` on the first call of each cycle (via internal `workfile_configure_from_cycle`, reading the cycle definition).
|
|
30
38
|
|
|
31
39
|
## Sections
|
|
32
40
|
|
|
@@ -70,7 +78,7 @@ Grouped by artefact file path. Each item is a checklist entry with a tag indicat
|
|
|
70
78
|
|
|
71
79
|
- `#validation` — from a deterministic quench command
|
|
72
80
|
- `#law:<law-id>` — from subjective appraise, tied to a specific law
|
|
73
|
-
- `#
|
|
81
|
+
- `#human` — from human-provided feedback at a human-appraise checkpoint
|
|
74
82
|
|
|
75
83
|
#### Lifecycle states
|
|
76
84
|
|
|
@@ -86,20 +94,23 @@ Grouped by artefact file path. Each item is a checklist entry with a tag indicat
|
|
|
86
94
|
|
|
87
95
|
#### Rules
|
|
88
96
|
|
|
89
|
-
- Validation feedback (`#validation`) cannot be wont-fixed
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
97
|
+
- Validation feedback (`#validation`) cannot be wont-fixed — deterministic rules are not negotiable.
|
|
98
|
+
- Human feedback (`#human`) cannot be wont-fixed — it takes absolute priority over LLM feedback.
|
|
99
|
+
- Feedback is never deleted — it stays as a record of the iteration history.
|
|
100
|
+
- New feedback is appended, not inserted.
|
|
101
|
+
- Items are grouped under the artefact they relate to.
|
|
93
102
|
|
|
94
103
|
## Who writes what
|
|
95
104
|
|
|
96
105
|
| Section | Written by | Updated by |
|
|
97
106
|
|---------|-----------|------------|
|
|
98
|
-
| Frontmatter (`flow`) | `foundry_workfile_create` (flow skill) |
|
|
99
|
-
| Frontmatter (`
|
|
107
|
+
| Frontmatter (`flow`, `cycle`, `goal`) | `foundry_workfile_create` (flow skill) | `foundry_workfile_delete` + re-create between cycles |
|
|
108
|
+
| Frontmatter (`stages`, `max-iterations`, `human-appraise`, `deadlock-appraise`, `deadlock-iterations`, `models`) | `foundry_orchestrate` (first call of each cycle, internally) | reset on each new cycle |
|
|
100
109
|
| Goal | `foundry_workfile_create` (flow skill) | nobody |
|
|
101
|
-
| Artefacts | `
|
|
102
|
-
| Feedback | `foundry_feedback_add` (quench/appraise/
|
|
110
|
+
| Artefacts | `foundry_stage_finalize` (orchestrator, after forge closes) | `foundry_artefacts_set_status` (orchestrator → `done`/`blocked`) |
|
|
111
|
+
| Feedback | `foundry_feedback_add` (quench / appraise / human-appraise) | `foundry_feedback_action` / `foundry_feedback_wontfix` (forge), `foundry_feedback_resolve` (quench / appraise / human-appraise) |
|
|
112
|
+
|
|
113
|
+
Note: `foundry_artefacts_add` no longer exists as a public tool — artefact registration is automatic via `stage_finalize`, which scans the git diff and registers files matching the output type's `file-patterns` as `draft`.
|
|
103
114
|
|
|
104
115
|
## WORK.history.yaml
|
|
105
116
|
|
|
@@ -141,20 +152,20 @@ A separate file (`WORK.history.yaml`) alongside WORK.md. Append-only log of ever
|
|
|
141
152
|
|
|
142
153
|
- `timestamp` — ISO 8601 UTC
|
|
143
154
|
- `cycle` — which foundry cycle this entry belongs to
|
|
144
|
-
- `stage` — which stage just completed, in `base:alias` format (e.g. `forge:draft-petition`, `quench:validate-petition`, `appraise:review-petition`, `
|
|
155
|
+
- `stage` — which stage just completed, in `base:alias` format (e.g. `forge:draft-petition`, `quench:validate-petition`, `appraise:review-petition`, `human-appraise:human-review`)
|
|
145
156
|
- `iteration` — the current iteration number (increments each time forge runs within a cycle)
|
|
146
157
|
- `comment` — brief description of what happened
|
|
147
158
|
|
|
148
159
|
### Rules
|
|
149
160
|
|
|
150
|
-
- Append-only — never edit or delete entries
|
|
151
|
-
- Every stage
|
|
152
|
-
-
|
|
153
|
-
- Iteration is derived from counting forge entries for the current
|
|
161
|
+
- Append-only — never edit or delete entries.
|
|
162
|
+
- Every stage produces an entry when it completes.
|
|
163
|
+
- Sort reads this to determine what has happened in the current cycle.
|
|
164
|
+
- Iteration is derived from counting forge entries for the current cycle.
|
|
154
165
|
|
|
155
166
|
### Who writes
|
|
156
167
|
|
|
157
|
-
|
|
168
|
+
History entries are written by `foundry_orchestrate` after each stage closes (via its internal `foundry_history_append` — the tool is not registered publicly). Sub-agents never append history directly.
|
|
158
169
|
|
|
159
170
|
## Example
|
|
160
171
|
|
|
@@ -166,6 +177,9 @@ flow: make-haiku
|
|
|
166
177
|
cycle: haiku-creation
|
|
167
178
|
stages: [forge:write-haiku, quench:check-syllables, appraise:evaluate-quality]
|
|
168
179
|
max-iterations: 3
|
|
180
|
+
human-appraise: false
|
|
181
|
+
deadlock-appraise: true
|
|
182
|
+
deadlock-iterations: 5
|
|
169
183
|
---
|
|
170
184
|
|
|
171
185
|
# Goal
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@really-knows-ai/foundry",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "A structured framework for AI-driven artefact creation with deterministic routing, quality gates, and iterative refinement cycles.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": ".opencode/plugins/foundry.js",
|
|
@@ -10,9 +10,15 @@ You help the user create a new appraiser personality. You ensure it's genuinely
|
|
|
10
10
|
|
|
11
11
|
## Prerequisites
|
|
12
12
|
|
|
13
|
-
Before running this skill, verify
|
|
13
|
+
Before running this skill, verify both of the following:
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
1. The `foundry/` directory exists in the project root. If it does not exist, stop and tell the user:
|
|
16
|
+
|
|
17
|
+
> Foundry is not initialized in this project. Run the `init-foundry` skill first to create the foundry/ directory structure.
|
|
18
|
+
|
|
19
|
+
2. The current git branch is not a work branch. Run `git rev-parse --abbrev-ref HEAD` — if it starts with `work/`, stop and tell the user:
|
|
20
|
+
|
|
21
|
+
> You're on a work branch (`<branch>`). Foundry configuration changes must be made on the base branch (usually `main`). Complete or discard the in-flight flow (`foundry_git_finish`, or switch branches and delete it), then re-run this skill from the base branch.
|
|
16
22
|
|
|
17
23
|
## Protocol
|
|
18
24
|
|
|
@@ -10,9 +10,15 @@ You help the user create a new artefact type. You ensure it doesn't conflict wit
|
|
|
10
10
|
|
|
11
11
|
## Prerequisites
|
|
12
12
|
|
|
13
|
-
Before running this skill, verify
|
|
13
|
+
Before running this skill, verify both of the following:
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
1. The `foundry/` directory exists in the project root. If it does not exist, stop and tell the user:
|
|
16
|
+
|
|
17
|
+
> Foundry is not initialized in this project. Run the `init-foundry` skill first to create the foundry/ directory structure.
|
|
18
|
+
|
|
19
|
+
2. The current git branch is not a work branch. Run `git rev-parse --abbrev-ref HEAD` — if it starts with `work/`, stop and tell the user:
|
|
20
|
+
|
|
21
|
+
> You're on a work branch (`<branch>`). Foundry configuration changes must be made on the base branch (usually `main`). Complete or discard the in-flight flow (`foundry_git_finish`, or switch branches and delete it), then re-run this skill from the base branch.
|
|
16
22
|
|
|
17
23
|
## Protocol
|
|
18
24
|
|
|
@@ -10,9 +10,15 @@ You help the user create a new foundry cycle and add it to an existing foundry f
|
|
|
10
10
|
|
|
11
11
|
## Prerequisites
|
|
12
12
|
|
|
13
|
-
Before running this skill, verify
|
|
13
|
+
Before running this skill, verify both of the following:
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
1. The `foundry/` directory exists in the project root. If it does not exist, stop and tell the user:
|
|
16
|
+
|
|
17
|
+
> Foundry is not initialized in this project. Run the `init-foundry` skill first to create the foundry/ directory structure.
|
|
18
|
+
|
|
19
|
+
2. The current git branch is not a work branch. Run `git rev-parse --abbrev-ref HEAD` — if it starts with `work/`, stop and tell the user:
|
|
20
|
+
|
|
21
|
+
> You're on a work branch (`<branch>`). Foundry configuration changes must be made on the base branch (usually `main`). Complete or discard the in-flight flow (`foundry_git_finish`, or switch branches and delete it), then re-run this skill from the base branch.
|
|
16
22
|
|
|
17
23
|
## Protocol
|
|
18
24
|
|
package/skills/add-flow/SKILL.md
CHANGED
|
@@ -10,9 +10,15 @@ You help the user create a new foundry flow. A foundry flow is a set of foundry
|
|
|
10
10
|
|
|
11
11
|
## Prerequisites
|
|
12
12
|
|
|
13
|
-
Before running this skill, verify
|
|
13
|
+
Before running this skill, verify both of the following:
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
1. The `foundry/` directory exists in the project root. If it does not exist, stop and tell the user:
|
|
16
|
+
|
|
17
|
+
> Foundry is not initialized in this project. Run the `init-foundry` skill first to create the foundry/ directory structure.
|
|
18
|
+
|
|
19
|
+
2. The current git branch is not a work branch. Run `git rev-parse --abbrev-ref HEAD` — if it starts with `work/`, stop and tell the user:
|
|
20
|
+
|
|
21
|
+
> You're on a work branch (`<branch>`). Foundry configuration changes must be made on the base branch (usually `main`). Complete or discard the in-flight flow (`foundry_git_finish`, or switch branches and delete it), then re-run this skill from the base branch.
|
|
16
22
|
|
|
17
23
|
## Protocol
|
|
18
24
|
|
package/skills/add-law/SKILL.md
CHANGED
|
@@ -10,9 +10,15 @@ You help the user create a new law. You ensure it's well-scoped, doesn't conflic
|
|
|
10
10
|
|
|
11
11
|
## Prerequisites
|
|
12
12
|
|
|
13
|
-
Before running this skill, verify
|
|
13
|
+
Before running this skill, verify both of the following:
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
1. The `foundry/` directory exists in the project root. If it does not exist, stop and tell the user:
|
|
16
|
+
|
|
17
|
+
> Foundry is not initialized in this project. Run the `init-foundry` skill first to create the foundry/ directory structure.
|
|
18
|
+
|
|
19
|
+
2. The current git branch is not a work branch. Run `git rev-parse --abbrev-ref HEAD` — if it starts with `work/`, stop and tell the user:
|
|
20
|
+
|
|
21
|
+
> You're on a work branch (`<branch>`). Foundry configuration changes must be made on the base branch (usually `main`). Complete or discard the in-flight flow (`foundry_git_finish`, or switch branches and delete it), then re-run this skill from the base branch.
|
|
16
22
|
|
|
17
23
|
## Protocol
|
|
18
24
|
|