@really-knows-ai/foundry 3.5.8 → 3.6.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.
- package/README.md +16 -10
- package/dist/.opencode/plugins/foundry-tools/config-create-tools.js +2 -3
- package/dist/.opencode/plugins/foundry-tools/feedback-tools.js +9 -5
- package/dist/.opencode/plugins/foundry-tools/orchestrate-tool.js +3 -1
- package/dist/CHANGELOG.md +38 -0
- package/dist/README.md +16 -10
- package/dist/docs/README.md +6 -6
- package/dist/docs/architecture.md +59 -19
- package/dist/docs/concepts.md +55 -19
- package/dist/docs/getting-started.md +37 -15
- package/dist/docs/memory-maintenance.md +3 -3
- package/dist/docs/tools.md +131 -70
- package/dist/docs/work-spec.md +38 -52
- package/dist/scripts/appraise-module.js +69 -7
- package/dist/scripts/lib/artefacts.js +43 -1
- package/dist/scripts/lib/config-creators/cycle.js +6 -10
- package/dist/scripts/lib/config-validators/cycle.js +1 -9
- package/dist/scripts/lib/feedback-store.js +26 -51
- package/dist/scripts/lib/finalize.js +10 -2
- package/dist/scripts/lib/forge-contract.js +93 -0
- package/dist/scripts/lib/history.js +2 -1
- package/dist/scripts/lib/sort-reason.js +11 -8
- package/dist/scripts/lib/sort-routing.js +185 -63
- package/dist/scripts/lib/workfile.js +28 -0
- package/dist/scripts/orchestrate-cycle.js +3 -13
- package/dist/scripts/orchestrate-phases.js +51 -45
- package/dist/scripts/orchestrate-terminals.js +37 -2
- package/dist/scripts/orchestrate.js +62 -5
- package/dist/scripts/quench-module.js +54 -12
- package/dist/scripts/sort.js +42 -62
- package/dist/skills/add-cycle/SKILL.md +4 -4
- package/dist/skills/add-flow/SKILL.md +1 -1
- package/dist/skills/human-appraise/SKILL.md +12 -40
- package/package.json +1 -1
package/dist/docs/concepts.md
CHANGED
|
@@ -20,9 +20,9 @@ An iterative unit that produces one artefact type and routes to later cycles thr
|
|
|
20
20
|
- `output-type` — the artefact type it produces (read-write).
|
|
21
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
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
|
|
25
|
-
- `
|
|
23
|
+
- `always-human-appraise` — whether a human quality gate runs every iteration (default: `false`).
|
|
24
|
+
- `deadlock-human-appraise` — whether a human is pulled in when the deadlock threshold is reached (default: `true`).
|
|
25
|
+
- `max-iterations` — maximum forge iterations (default: `3`).
|
|
26
26
|
- `models` — optional per-stage model overrides.
|
|
27
27
|
|
|
28
28
|
A cycle runs **assay** first when configured, then **forge → quench → appraise** (and optionally **human-appraise**), looping until all feedback is resolved or `max-iterations` is hit.
|
|
@@ -35,9 +35,9 @@ The stage names come from the foundry metaphor because the system treats AI outp
|
|
|
35
35
|
|
|
36
36
|
- **assay** — opt-in pre-forge stage that populates flow memory by running project-authored extractor scripts (iteration 0 only). No artefact, no feedback, no output beyond memory writes. See the [Assay](#assay) and [Extractor](#extractor) entries below.
|
|
37
37
|
- **forge** — produce or revise the artefact.
|
|
38
|
-
- **quench** — run
|
|
39
|
-
- **appraise** —
|
|
40
|
-
- **human-appraise** — human quality gate.
|
|
38
|
+
- **quench** — deterministic validation run inside the orchestrator against laws that contain validators.
|
|
39
|
+
- **appraise** — orchestrator-managed `dispatch_multi` fan-out to appraiser sub-agents, with internal consolidation.
|
|
40
|
+
- **human-appraise** — human quality gate. Runs every iteration when `always-human-appraise` is true, or on deadlock when `deadlock-human-appraise` is true.
|
|
41
41
|
|
|
42
42
|
Feedback is always *about an artefact* and flows backward to forge. Assay sits outside the artefact-feedback loop because it precedes the artefact and its only failure mode (a broken extractor under `foundry/memory/extractors/`) lives outside forge's `file-patterns`.
|
|
43
43
|
|
|
@@ -63,31 +63,35 @@ See also: [Extractor](#extractor).
|
|
|
63
63
|
A definition of what is being produced. Lives in `foundry/artefacts/<type>/`:
|
|
64
64
|
|
|
65
65
|
- `definition.md` — identity, file patterns, output directory, appraiser config, prose description.
|
|
66
|
-
- `laws.md` *(optional)* — type-specific
|
|
66
|
+
- `laws.md` *(optional)* — type-specific criteria, with optional validators for deterministic checks.
|
|
67
67
|
|
|
68
68
|
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.
|
|
69
69
|
|
|
70
70
|
## Law
|
|
71
71
|
|
|
72
|
-
A
|
|
72
|
+
A rule or criterion that defines expectations for artefacts. Two scopes:
|
|
73
73
|
|
|
74
74
|
- **Global** — `foundry/laws/*.md`, all files concatenated, applies to every artefact.
|
|
75
75
|
- **Type-specific** — `foundry/artefacts/<type>/laws.md`.
|
|
76
76
|
|
|
77
|
-
Each law is a `## heading` (its identifier, used in feedback tags as `law:<id>`) with a description, passing criteria, and failing criteria.
|
|
77
|
+
Each law is a `## heading` (its identifier, used in feedback tags as `law:<id>`) with a description, passing criteria, and failing criteria. Laws may declare optional validators, which are deterministic scripts that verify the artefact programmatically.
|
|
78
|
+
|
|
79
|
+
## Validator
|
|
80
|
+
|
|
81
|
+
An optional deterministic script attached to a law. Declared in a law's `validators` field and run during the quench stage. Each validator produces feedback tagged `law:<law-id>:<validator-id>` when its check fails. Validators are the mechanism for automated, deterministic enforcement of law requirements.
|
|
78
82
|
|
|
79
83
|
## Appraiser
|
|
80
84
|
|
|
81
|
-
An
|
|
85
|
+
An evaluator that judges artefacts against laws through its personality or perspective. 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. Appraisers receive the artefact content and applicable laws; they do not receive validator metadata.
|
|
82
86
|
|
|
83
87
|
## WORK.md
|
|
84
88
|
|
|
85
|
-
The transient shared state for a flow. Created on the work branch
|
|
89
|
+
The transient shared state for a flow. Created on the work branch, it tracks:
|
|
86
90
|
|
|
87
91
|
- Current position (flow, cycle, stage list, iteration limits) in frontmatter.
|
|
88
92
|
- The goal (prose — written once).
|
|
89
|
-
|
|
90
|
-
- Feedback state lives alongside
|
|
93
|
+
|
|
94
|
+
Artefacts are discovered from branch changes against the current cycle's output-type file patterns, not stored as an artefact table in `WORK.md`. Feedback state lives alongside `WORK.md` in `WORK.feedback.yaml`.
|
|
91
95
|
|
|
92
96
|
See [work-spec.md](work-spec.md) for the full spec.
|
|
93
97
|
|
|
@@ -100,12 +104,12 @@ Append-only log of every stage execution, sitting next to WORK.md. Used by sort
|
|
|
100
104
|
Feedback items live in `WORK.feedback.yaml` — a yaml file at the worktree
|
|
101
105
|
root, alongside `WORK.md`. Every item has a ULID, a source stage, and a
|
|
102
106
|
full history of state transitions (open → actioned → resolved, or variants
|
|
103
|
-
including wont-fix / rejected
|
|
107
|
+
including wont-fix / rejected).
|
|
104
108
|
|
|
105
109
|
Plugins read and write feedback through the `foundry_feedback_*` tools;
|
|
106
|
-
skills never edit the yaml directly. Sort
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
skills never edit the yaml directly. Sort routing uses the iteration count
|
|
111
|
+
and `max-iterations` / `deadlock-human-appraise` settings to detect
|
|
112
|
+
deadlock, not per-item deadlock history.
|
|
109
113
|
|
|
110
114
|
See `docs/work-spec.md` for the full schema and state machine.
|
|
111
115
|
|
|
@@ -113,8 +117,8 @@ See `docs/work-spec.md` for the full schema and state machine.
|
|
|
113
117
|
|
|
114
118
|
Human-in-the-loop checkpoint. A stage where Foundry pauses and asks a human for input. Two triggers:
|
|
115
119
|
|
|
116
|
-
1. **Every-iteration** — the cycle declares `human-appraise: true`. The `human-appraise` stage runs after LLM appraise each iteration.
|
|
117
|
-
2. **Deadlock** — the cycle declares `deadlock-appraise: true` (default). If
|
|
120
|
+
1. **Every-iteration** — the cycle declares `always-human-appraise: true`. The `human-appraise` stage runs after LLM appraise each iteration.
|
|
121
|
+
2. **Deadlock** — the cycle declares `deadlock-human-appraise: true` (default). If the iteration count reaches `max-iterations`, sort inserts a `human-appraise` stage to break the tie.
|
|
118
122
|
|
|
119
123
|
Human feedback is tagged `human` and takes priority over LLM feedback on the same topic.
|
|
120
124
|
|
|
@@ -194,6 +198,28 @@ The signed squash commit on the base branch references the archive
|
|
|
194
198
|
branch tip SHA in its attestation block. Archive branches accumulate
|
|
195
199
|
indefinitely — periodic manual pruning is outside the tool's scope.
|
|
196
200
|
|
|
201
|
+
## Attestation
|
|
202
|
+
|
|
203
|
+
A cryptographic claim that a work branch completed all required stages
|
|
204
|
+
and all feedback was resolved. Created by `foundry_attest({ confirm: true })`,
|
|
205
|
+
which writes and commits `ATTEST.md` at `HEAD` containing the cycle
|
|
206
|
+
goal, a diff SHA-256 of the branch changes, and a canonical JSON payload
|
|
207
|
+
with the flow contract, governance hashes, output artefact list, process
|
|
208
|
+
log, and archive branch reference. Work-branch `foundry_git_finish`
|
|
209
|
+
verifies the attestation before allowing the squash merge. Config and
|
|
210
|
+
dry-run branches do not require attestation.
|
|
211
|
+
|
|
212
|
+
## ATTEST.md
|
|
213
|
+
|
|
214
|
+
The attestation document written by `foundry_attest` as the work-branch
|
|
215
|
+
`HEAD` commit. Contains the goal prose, `diff-sha256` of the branch
|
|
216
|
+
diff, and a signed attestation block between `-----BEGIN FOUNDRY
|
|
217
|
+
ATTESTATION-----` and `-----END FOUNDRY ATTESTATION-----` delimiters.
|
|
218
|
+
`foundry_git_finish` verifies `ATTEST.md` exists at `HEAD`, checks the
|
|
219
|
+
`diff-sha256` matches the recomputed branch diff, uses the attestation
|
|
220
|
+
payload in the signed final commit message, and preserves the archive
|
|
221
|
+
branch reference.
|
|
222
|
+
|
|
197
223
|
## Stage token
|
|
198
224
|
|
|
199
225
|
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.
|
|
@@ -267,6 +293,16 @@ All deterministic pipeline operations are exposed as custom tools by the Foundry
|
|
|
267
293
|
|
|
268
294
|
A self-contained workflow written as markdown with YAML frontmatter. Foundry ships a user-facing `Foundry` guide agent plus skills for pipeline execution, authoring, maintenance, and memory administration. The guide agent is the normal interface for users; skills and tools provide the internal workflows it uses to initialise projects, create artefact types, define laws, configure appraisers, build cycles and flows, and run governed artefact generation. Skills are either **atomic** (do one thing) or **composite** (orchestrate other skills).
|
|
269
295
|
|
|
296
|
+
## Foundry agent wizard
|
|
297
|
+
|
|
298
|
+
The interactive configuration process that runs when the user first
|
|
299
|
+
interacts with the Foundry agent. The wizard walks through four phases
|
|
300
|
+
— Understand, Plan, Confirm, Build — asking one question at a time.
|
|
301
|
+
Configuration files are created only after the user confirms the plan.
|
|
302
|
+
The wizard eliminates hand-authoring of normal setup by using the
|
|
303
|
+
structured config creation tools (`foundry_config_create_*`) on a
|
|
304
|
+
`config/*` branch.
|
|
305
|
+
|
|
270
306
|
---
|
|
271
307
|
|
|
272
308
|
## Extractor
|
|
@@ -26,7 +26,7 @@ directory structure, generates stage agents, and installs the Foundry guide
|
|
|
26
26
|
agent automatically.
|
|
27
27
|
|
|
28
28
|
After restart, type **hello foundry**. The assistant will tell you whether a
|
|
29
|
-
further restart is needed and when to switch to the Foundry agent.
|
|
29
|
+
further restart is needed and when to switch to the **Foundry** agent.
|
|
30
30
|
|
|
31
31
|
Optionally, if you want the package available to your project's local node_modules (for editor tooling or scripts), run:
|
|
32
32
|
|
|
@@ -44,7 +44,7 @@ assistant will read the Foundry bootstrap context and respond with guidance:
|
|
|
44
44
|
- If Foundry is already set up: it will tell you to switch to the Foundry agent
|
|
45
45
|
directly.
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
Switch to the **Foundry** agent before authoring flows. The Foundry agent
|
|
48
48
|
understands Foundry's authoring workflow and handles dependent setup such as
|
|
49
49
|
artefact types, laws, validators, appraisers, cycles, and config branches.
|
|
50
50
|
|
|
@@ -59,6 +59,12 @@ Foundry's configuration is five things: artefact types, laws, appraisers, cycles
|
|
|
59
59
|
|
|
60
60
|
### Author through the Foundry agent
|
|
61
61
|
|
|
62
|
+
The Foundry agent walks through a four-phase wizard protocol — **Understand,
|
|
63
|
+
Plan, Confirm, Build** — asking one question at a time. Configuration files are
|
|
64
|
+
created only after you confirm the plan. This wizard eliminates hand-authoring
|
|
65
|
+
of normal setup by using the structured config creation tools on a `config/*`
|
|
66
|
+
branch.
|
|
67
|
+
|
|
62
68
|
Ask the Foundry agent to author or modify any part of the configuration. For example:
|
|
63
69
|
|
|
64
70
|
> Add a `haiku` artefact type with a `poetic-form` appraiser.
|
|
@@ -77,11 +83,27 @@ These are the five pieces of a Foundry configuration, in dependency order:
|
|
|
77
83
|
|
|
78
84
|
1. **Artefact types** — define the output of each cycle. Each type has an `id`, `name`, prose description, `file-patterns` (forge's write scope), appraiser config, and optional type-specific `laws.md`. Produces `foundry/artefacts/<id>/definition.md`.
|
|
79
85
|
|
|
80
|
-
2. **Laws** —
|
|
86
|
+
2. **Laws** — rules or criteria evaluated by appraisers. Two scopes: global (`foundry/laws/*.md`, concatenated for every artefact) and type-specific (`foundry/artefacts/<type>/laws.md`). Each law is a `## heading` (its identifier, referenced as `law:<id>` in feedback) with a description, passing criteria, and failing criteria.
|
|
81
87
|
|
|
82
88
|
3. **Appraisers** — independent evaluators with named personalities. Each may override the cycle-level appraise model via a `model` field. Artefact types pick which appraisers may evaluate them (`appraisers.allowed`).
|
|
83
89
|
|
|
84
|
-
4. **Cycles** — produce one artefact type
|
|
90
|
+
4. **Cycles** — produce one artefact type from a definition with these fields:
|
|
91
|
+
|
|
92
|
+
| Field | Purpose |
|
|
93
|
+
|-------|---------|
|
|
94
|
+
| `id` | Unique identifier |
|
|
95
|
+
| `name` | Human-readable label |
|
|
96
|
+
| `output-type` | The artefact type this cycle produces |
|
|
97
|
+
| `inputs` | Contract over upstream types (e.g. `any-of`, `all-of`) |
|
|
98
|
+
| `targets` | Reachable downstream cycles for flow routing |
|
|
99
|
+
| `always-human-appraise` | Bypass LLM appraisers on every iteration |
|
|
100
|
+
| `deadlock-human-appraise` | Escalate to human appraiser at iteration limit |
|
|
101
|
+
| `max-iterations` | Maximum forge iterations before deadlock |
|
|
102
|
+
| `assay` | Optional extractor config for pre-forge measurement |
|
|
103
|
+
| `memory` | Optional entity read/write permissions |
|
|
104
|
+
| `models` | Per-stage model overrides (e.g. `appraise`, `forge`) |
|
|
105
|
+
|
|
106
|
+
Example:
|
|
85
107
|
|
|
86
108
|
```markdown
|
|
87
109
|
---
|
|
@@ -93,9 +115,9 @@ These are the five pieces of a Foundry configuration, in dependency order:
|
|
|
93
115
|
artefacts:
|
|
94
116
|
- petition
|
|
95
117
|
targets: []
|
|
96
|
-
human-appraise: false
|
|
97
|
-
deadlock-appraise: true
|
|
98
|
-
|
|
118
|
+
always-human-appraise: false
|
|
119
|
+
deadlock-human-appraise: true
|
|
120
|
+
max-iterations: 5
|
|
99
121
|
models:
|
|
100
122
|
appraise: openai/gpt-5
|
|
101
123
|
---
|
|
@@ -114,15 +136,15 @@ Users who prefer to write configuration files by hand open a config branch first
|
|
|
114
136
|
To run a flow, ask the Foundry agent with your goal as the input (e.g. "Run the make-haiku flow to write a haiku about autumn rain"). The Foundry agent dispatches the `flow` skill, which:
|
|
115
137
|
|
|
116
138
|
1. Checks prerequisites and picks 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.
|
|
117
|
-
2. Creates a work branch and scaffolds `WORK.md` with the
|
|
118
|
-
3. Hands off to `orchestrate`, which drives the cycle:
|
|
139
|
+
2. Creates a work branch and scaffolds `WORK.md` with frontmatter (`flow`, `cycle`) and the `# Goal` section. No artefact table is stored in the workfile; artefacts are discovered from branch diffs.
|
|
140
|
+
3. Hands off to `orchestrate`, which drives the cycle. Orchestrate setup fills the remaining frontmatter (`stages`, `max-iterations`, model overrides, `assay` config) from the cycle definition, then runs the loop:
|
|
119
141
|
- **forge** writes the artefact.
|
|
120
|
-
- **quench** runs
|
|
121
|
-
- **appraise**
|
|
122
|
-
- **human-appraise** (if configured, or
|
|
142
|
+
- **quench** runs deterministic validation inside the orchestrator, executing any validators attached to laws.
|
|
143
|
+
- **appraise** fans out parallel appraiser sub-agents via `dispatch_multi` and internally consolidates their `law:<id>` feedback.
|
|
144
|
+
- **human-appraise** (if configured, or at the iteration limit) asks you for input.
|
|
123
145
|
- If any unresolved feedback remains, another forge iteration begins.
|
|
124
146
|
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.
|
|
125
|
-
5. When all desired cycles are
|
|
147
|
+
5. When all desired cycles are complete, the flow skill asks you to attest the work via `foundry_attest`, which verifies cycle completion, writes and commits `ATTEST.md`. After attestation succeeds, `foundry_git_finish` squash-merges to the base branch with a signed attestation block, preserves the work branch as an archive, and creates the final signed commit. See [`docs/tools.md`](./tools.md#foundry_attest) for the attestation contract.
|
|
126
148
|
|
|
127
149
|
Every stage ends with a micro-commit. Violations of the write invariant (writing to disallowed files) hard-stop the cycle.
|
|
128
150
|
|
|
@@ -154,7 +176,7 @@ never committed by foundry. See the `dry-run` skill for the full loop.
|
|
|
154
176
|
|
|
155
177
|
While a flow is running, the state of the world is in four places:
|
|
156
178
|
|
|
157
|
-
- `WORK.md` — current cycle, goal, and
|
|
179
|
+
- `WORK.md` — current cycle, goal, and frontmatter state. Artefacts are discovered from branch diffs against the current cycle output type; see `foundry_artefacts_list`.
|
|
158
180
|
- `WORK.feedback.yaml` — feedback items and their lifecycle history.
|
|
159
181
|
- `WORK.history.yaml` — append-only stage execution log.
|
|
160
182
|
- `git log` — one commit per stage.
|
|
@@ -185,7 +207,7 @@ Use `foundry_stage_retry()` when the underlying problem is fixed and you want to
|
|
|
185
207
|
|
|
186
208
|
## Cleaning up
|
|
187
209
|
|
|
188
|
-
When a flow completes, `foundry_git_finish` handles integration with audit guarantees
|
|
210
|
+
When a flow completes, the flow skill asks you to attest the work via `foundry_attest`, which verifies cycle completion, writes `ATTEST.md` at `HEAD`, and commits it. After attestation succeeds, `foundry_git_finish` handles integration with audit guarantees: it commits `WORK.*` cleanup, preserves the branch as `archive/work/<flow>-<desc>-<hash>` for immutable forensic history, squash-merges to the base branch, and creates a signed commit whose message embeds the canonical Foundry attestation block. See [`docs/tools.md`](./tools.md#foundry_attest) and [`docs/tools.md`](./tools.md#foundry_git_finish) for the full contracts.
|
|
189
211
|
|
|
190
212
|
---
|
|
191
213
|
|
|
@@ -4,7 +4,7 @@ Contributor-facing notes. This file records the derived details from the
|
|
|
4
4
|
Cozo docs / plugin surface that cost us time to establish. Add entries when a
|
|
5
5
|
fix required non-trivial spelunking, so the next maintainer can reuse the result.
|
|
6
6
|
|
|
7
|
-
## Backend status
|
|
7
|
+
## Backend status
|
|
8
8
|
|
|
9
9
|
The memory subsystem persists to `cozo-node@0.7.6`, which wraps the Rust
|
|
10
10
|
`cozodb` engine. Both are effectively unmaintained:
|
|
@@ -23,7 +23,7 @@ property-graph with HNSW, Cypher dialect), **SurrealDB embedded**,
|
|
|
23
23
|
**DuckDB + vss + PGQ**, and **SQLite + `sqlite-vec`** with hand-rolled
|
|
24
24
|
graph traversal. The migration is structured so the public memory tool
|
|
25
25
|
surface (`foundry_memory_*`) and the on-disk durable artefacts
|
|
26
|
-
(`foundry
|
|
26
|
+
(`foundry/memory/entities/*.md`, `foundry/memory/edges/*.md`,
|
|
27
27
|
`foundry-memory/relations/*.ndjson`) remain stable; only the live
|
|
28
28
|
in-process store changes.
|
|
29
29
|
|
|
@@ -126,7 +126,7 @@ Extractors are defined at `foundry/memory/extractors/<name>.md` with a `command`
|
|
|
126
126
|
|
|
127
127
|
## Memory layout: two trees
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
Memory is split across two top-level trees:
|
|
130
130
|
|
|
131
131
|
- `foundry/memory/` — *config*. Holds `config.md`, `schema.json`,
|
|
132
132
|
`entities/<name>.md`, `edges/<name>.md`, `extractors/<name>.md`,
|
package/dist/docs/tools.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Foundry Public Tool Reference
|
|
2
2
|
|
|
3
|
-
Generated from the
|
|
3
|
+
Generated from the current public plugin API for Foundry 3.5.8. The authoritative tool set is
|
|
4
4
|
enforced by `tests/plugin/tool-registration.test.js` — if that snapshot
|
|
5
|
-
drifts, this doc must be updated. Total: **
|
|
5
|
+
drifts, this doc must be updated. Total: **65 tools**.
|
|
6
6
|
|
|
7
7
|
All tools accept arguments as a JSON object and return JSON-stringified
|
|
8
8
|
results. Errors are returned as a stringified `{error: "..."}` object (not
|
|
@@ -39,13 +39,15 @@ state machine, see [`docs/concepts.md`](./concepts.md) and
|
|
|
39
39
|
|
|
40
40
|
| Namespace | Applies to | Notes |
|
|
41
41
|
|-----------|------------|-------|
|
|
42
|
-
| `config/<description>` | `
|
|
42
|
+
| `config/<description>` | `foundry_config_create_artefact_type`, `foundry_config_create_appraiser`, `foundry_config_create_flow`, `foundry_config_create_cycle`, `foundry_config_add_law`, `foundry_config_edit_law`, `foundry_memory_create_entity_type`, `foundry_memory_create_edge_type`, `foundry_memory_rename_*`, `foundry_memory_drop_*`, `foundry_memory_reset`, `foundry_memory_init`, `foundry_memory_change_embedding_model`, `foundry_extractor_create` | Config and schema mutation only. |
|
|
43
43
|
| `work/<flow>-<desc>` or `dry-run/<x>/<y>` | `foundry_orchestrate`, `foundry_stage_begin`, `foundry_stage_end`, `foundry_stage_retry`, `foundry_workfile_*`, `foundry_artefacts_*`, `foundry_feedback_*`, `foundry_assay_run`, `foundry_validate_run`, `foundry_memory_put`, `foundry_memory_relate`, `foundry_memory_unrelate` | Flow-data mutation only. |
|
|
44
44
|
| Any branch | `foundry_workfile_get`, `foundry_artefacts_list`, `foundry_feedback_list`, `foundry_history_list`, `foundry_config_*` read tools, `foundry_config_validate_*`, `foundry_appraisers_select`, `foundry_memory_get`, `foundry_memory_list`, `foundry_memory_neighbours`, `foundry_memory_query`, `foundry_memory_search`, `foundry_memory_dump`, `foundry_memory_validate`, `foundry_snapshot_*` | No branch guard and no failed-flow guard. |
|
|
45
45
|
| Self-classifying | `foundry_git_branch`, `foundry_git_finish` | Each tool checks its own branch rules. Leaving the failed branch is the recovery path. |
|
|
46
46
|
|
|
47
47
|
Off-namespace calls return a structured refusal envelope naming the required namespace and the current branch.
|
|
48
48
|
|
|
49
|
+
> **Memory admin callability:** Schema-mutation and destructive memory admin tools (`foundry_memory_init`, `foundry_memory_create_entity_type`, `foundry_memory_create_edge_type`, `foundry_memory_rename_entity_type`, `foundry_memory_rename_edge_type`, `foundry_memory_drop_entity_type`, `foundry_memory_drop_edge_type`, `foundry_memory_reset`, `foundry_memory_change_embedding_model`) require `config/*` branches and non-failed flow. Read-only diagnostics (`foundry_memory_get`, `foundry_memory_list`, `foundry_memory_neighbours`, `foundry_memory_query`, `foundry_memory_search`, `foundry_memory_dump`, `foundry_memory_validate`) are broadly callable. `foundry_memory_vacuum` uses only the failed-flow guard and is not config-branch guarded.
|
|
50
|
+
|
|
49
51
|
## Tool index
|
|
50
52
|
|
|
51
53
|
**Lifecycle**
|
|
@@ -238,12 +240,17 @@ frontmatter.
|
|
|
238
240
|
**Args:**
|
|
239
241
|
- `lastResult` (object, optional): `{ ok: boolean, error?: string }` — output of the
|
|
240
242
|
prior action.
|
|
243
|
+
- `lastResults` (array, optional): Output of prior `dispatch_multi` actions.
|
|
241
244
|
- `cycleDef` (string, optional): Test-mode override path to a cycle file.
|
|
245
|
+
- `baseBranch` (string, optional, default `main`): Base branch for diff and merge.
|
|
246
|
+
- `defaultModel` (string, optional): Model override for all dispatch prompts.
|
|
242
247
|
|
|
243
248
|
**Returns:** one of:
|
|
244
249
|
- `{ action: "dispatch", stage, cycle, prompt, token, ... }` — caller
|
|
245
250
|
should dispatch a subagent. The `prompt` field is augmented with cycle
|
|
246
251
|
memory context (entity types, edge types, extractor briefs) when configured.
|
|
252
|
+
- `{ action: "dispatch_multi", tasks: [...], ... }` — caller should
|
|
253
|
+
dispatch multiple subagents in parallel (used for parallel appraiser dispatch).
|
|
247
254
|
- `{ action: "human_appraise", ... }` — surface to the user.
|
|
248
255
|
- `{ action: "done", ... }` — cycle complete.
|
|
249
256
|
- `{ action: "blocked", ... }` — cycle stalled.
|
|
@@ -261,6 +268,8 @@ failed flow.
|
|
|
261
268
|
**Side effects:** mints/persists dispatch tokens (in-memory pending
|
|
262
269
|
store); commits via `commitWithPolicy` when finalising stages (refuses
|
|
263
270
|
on unexpected files); appends WORK.md artefact rows when finalising.
|
|
271
|
+
Runs quench synchronously when laws contain validators; runs appraise
|
|
272
|
+
via `gatherAppraiseContext` + `consolidateAppraise`.
|
|
264
273
|
|
|
265
274
|
### `foundry_workfile_create`
|
|
266
275
|
|
|
@@ -325,7 +334,7 @@ flow** (escape hatch).
|
|
|
325
334
|
|
|
326
335
|
### `foundry_artefacts_list`
|
|
327
336
|
|
|
328
|
-
> List artefact changes on the current work branch for the current cycle.
|
|
337
|
+
> List artefact changes on the current work branch for the current cycle. Artefacts are discovered from branch diff status (git diff against base branch), filtered by the current cycle's output-type file patterns.
|
|
329
338
|
|
|
330
339
|
**Args:**
|
|
331
340
|
- none.
|
|
@@ -359,7 +368,7 @@ existing equivalent item was returned). `{ error: ... }` otherwise.
|
|
|
359
368
|
**Stage requirements:** requires active stage. Tag is gated by stage
|
|
360
369
|
base:
|
|
361
370
|
- `forge` → forbidden (forge stages do not add feedback).
|
|
362
|
-
- `quench` → tag must
|
|
371
|
+
- `quench` → tag must start with `law:`.
|
|
363
372
|
- `appraise` → tag must start with `law:`.
|
|
364
373
|
- `human-appraise` → tag must be exactly `human`.
|
|
365
374
|
- `assay` → forbidden. Extractor failures mark the workfile failed and end
|
|
@@ -542,7 +551,8 @@ that id is registered.
|
|
|
542
551
|
`file-patterns`.
|
|
543
552
|
|
|
544
553
|
**Stage requirements:** none (callable outside any stage; intended to be
|
|
545
|
-
invoked by quench, but not enforced).
|
|
554
|
+
invoked by quench, but not enforced). Requires a `work/*` or `dry-run/*`
|
|
555
|
+
branch (flow-data mutation namespace). Refused on a failed flow.
|
|
546
556
|
|
|
547
557
|
**Side effects:** spawns subprocesses via `execSync` in the worktree —
|
|
548
558
|
external commands may have arbitrary side effects, which is why the tool
|
|
@@ -654,11 +664,13 @@ can branch away to recover.
|
|
|
654
664
|
| current branch | mode | what happens |
|
|
655
665
|
| -------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
656
666
|
| `work/<x>` | work | commits `WORK.*` cleanup on the work branch, preserves the branch as `archive/work/<x>-<hash>`, squash-merges to `baseBranch`, creates a signed commit whose message embeds the canonical Foundry attestation block. |
|
|
657
|
-
| `config/<x>` | config | squash-merges to `baseBranch`, force-deletes the config branch. No WORK cleanup.
|
|
667
|
+
| `config/<x>` | config | squash-merges to `baseBranch`, force-deletes the config branch. No WORK cleanup. |
|
|
658
668
|
| `dry-run/<x>/<y>` | dry-run | writes `.snapshots/<run-id>/{README.md, work/WORK*, diff.patch, trace.jsonl}` on the parent `config/<x>` working tree; force-deletes the dry-run branch. No merge, no commit. |
|
|
659
669
|
| base branch (`main` by default) | noop | `{ ok: true, noop: true, ... }`. |
|
|
660
670
|
| anything else | refused | `{ ok: false, error: "... nothing to finish ..." }`. |
|
|
661
671
|
|
|
672
|
+
**Work-branch precondition (work mode):** `ATTEST.md` must exist at HEAD, created by a prior `foundry_attest({ confirm: true })` call. Without it, the work mode refuses.
|
|
673
|
+
|
|
662
674
|
**Returns:**
|
|
663
675
|
- Plan (when `confirm` is not true):
|
|
664
676
|
- Work mode: `{ ok: false, error: "... requires {confirm: true}...",
|
|
@@ -789,8 +801,7 @@ schema checks without writing. Laws use a different shape: `add_law`
|
|
|
789
801
|
creates a new entry, `edit_law` updates an existing one, and
|
|
790
802
|
`foundry_config_validate_law` covers schema validation for either.
|
|
791
803
|
|
|
792
|
-
Common
|
|
793
|
-
(string, markdown). Common returns across the whole family:
|
|
804
|
+
Common returns across the whole family:
|
|
794
805
|
`{ ok: true, path, sha }` on success; `{ ok: false, errors: [...] }`
|
|
795
806
|
on validation failure; `{ error, affected_files: [...] }` on
|
|
796
807
|
commit-policy refusal (the worktree was dirty with files outside
|
|
@@ -805,9 +816,11 @@ to update an existing law in place.
|
|
|
805
816
|
> `foundry/artefacts/<typeId>/`.
|
|
806
817
|
|
|
807
818
|
**Args:**
|
|
808
|
-
- `
|
|
809
|
-
- `
|
|
810
|
-
|
|
819
|
+
- `id` (string, required): Artefact type id (kebab-case slug).
|
|
820
|
+
- `name` (string, required): Human-readable name.
|
|
821
|
+
- `filePatterns` (string[], required): Glob patterns for matching artefacts.
|
|
822
|
+
- `description` (string, required): Prose description of the artefact type.
|
|
823
|
+
- `appraisers` (object, optional): `{ allowed: string[], count: number }` — appraiser pool and selection count.
|
|
811
824
|
|
|
812
825
|
**Returns:** `{ ok: true, path, sha }` on success;
|
|
813
826
|
`{ ok: false, errors: [...] }` on schema failure;
|
|
@@ -832,49 +845,53 @@ current `config/*` branch.
|
|
|
832
845
|
|
|
833
846
|
### `foundry_config_add_law`
|
|
834
847
|
|
|
835
|
-
> Add a new law
|
|
848
|
+
> Add a new law entry.
|
|
836
849
|
|
|
837
850
|
**Args:**
|
|
838
|
-
- `
|
|
839
|
-
|
|
840
|
-
- `
|
|
841
|
-
|
|
842
|
-
- `
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
-
|
|
856
|
-
|
|
857
|
-
-
|
|
858
|
-
|
|
859
|
-
-
|
|
860
|
-
`{
|
|
861
|
-
|
|
851
|
+
- `id` (string, required): Law id (kebab-case slug).
|
|
852
|
+
- `name` (string, required): Human-readable name.
|
|
853
|
+
- `description` (string, required): Prose description of the law.
|
|
854
|
+
- `passing` (string, required): Feedback text when the law passes.
|
|
855
|
+
- `failing` (string, required): Feedback text when the law fails.
|
|
856
|
+
- `target` (object, required): `{ kind: "global"|"type-specific", file?: string, typeId?: string }` — locator for the law target.
|
|
857
|
+
- `validators` (array, optional): Array of `{ name: string, command: string }` objects defining validator commands.
|
|
858
|
+
|
|
859
|
+
**Returns:** `{ ok: true, path, sha }` on success;
|
|
860
|
+
`{ ok: false, errors: [...] }` on validation failure;
|
|
861
|
+
`{ error, affected_files }` on commit-policy refusal.
|
|
862
|
+
|
|
863
|
+
**Stage requirements:** none (no active stage); requires a
|
|
864
|
+
`config/*` branch.
|
|
865
|
+
|
|
866
|
+
**Failure modes:**
|
|
867
|
+
- Off `config/*` branch → branch-guard refusal envelope.
|
|
868
|
+
- Failed flow → tool-name-prefixed error.
|
|
869
|
+
- Schema validation failure → `{ ok: false, errors: [...] }`.
|
|
870
|
+
- Target file already exists → `{ ok: false, errors: ["… already
|
|
871
|
+
exists; use foundry_config_edit_law to update an existing law in place"] }`.
|
|
872
|
+
- Worktree has changes outside `foundry/**` →
|
|
873
|
+
`{ error, affected_files }`.
|
|
874
|
+
|
|
875
|
+
**Side effects:** writes the law file and commits it on the current
|
|
876
|
+
`config/*` branch.
|
|
862
877
|
|
|
863
878
|
### `foundry_config_edit_law`
|
|
864
879
|
|
|
865
|
-
>
|
|
866
|
-
> laws
|
|
867
|
-
> and per-type `laws.md` files.
|
|
880
|
+
> Update an existing law's fields in place. Locates the law by id across
|
|
881
|
+
> both global laws and per-type `laws.md` files.
|
|
868
882
|
|
|
869
883
|
**Args:**
|
|
870
|
-
- `id` (string, required):
|
|
871
|
-
- `
|
|
872
|
-
|
|
884
|
+
- `id` (string, required): Law id to edit.
|
|
885
|
+
- `name` (string, optional): New human-readable name.
|
|
886
|
+
- `description` (string, optional): New prose description.
|
|
887
|
+
- `passing` (string, optional): New passing feedback text.
|
|
888
|
+
- `failing` (string, optional): New failing feedback text.
|
|
889
|
+
- `validators` (array, optional): New validator list replacing the current one.
|
|
873
890
|
|
|
874
891
|
**Returns:** `{ ok: true, id, path, source }` on success, where
|
|
875
892
|
`source` is `"global"` or `"type:<typeId>"`. Returns
|
|
876
893
|
`{ ok: false, errors: ["Law \"<id>\" not found"] }` when no law of
|
|
877
|
-
that id exists, or `{ ok: false, errors: [...] }` when the
|
|
894
|
+
that id exists, or `{ ok: false, errors: [...] }` when the update
|
|
878
895
|
fails law schema validation.
|
|
879
896
|
|
|
880
897
|
**Stage requirements:** none (no active stage); requires a `config/*`
|
|
@@ -888,48 +905,92 @@ the current `config/*` branch with message `config: edit law <id>`.
|
|
|
888
905
|
> Create a new appraiser personality at `foundry/appraisers/<id>.md`.
|
|
889
906
|
|
|
890
907
|
**Args:**
|
|
891
|
-
- `
|
|
892
|
-
- `
|
|
893
|
-
|
|
908
|
+
- `id` (string, required): Appraiser id (kebab-case slug).
|
|
909
|
+
- `name` (string, required): Human-readable name.
|
|
910
|
+
- `description` (string, required): Prose description of the appraiser's role.
|
|
911
|
+
- `model` (string, optional): Model override for this appraiser.
|
|
912
|
+
|
|
913
|
+
**Returns:** `{ ok: true, path, sha }` on success;
|
|
914
|
+
`{ ok: false, errors: [...] }` on schema failure;
|
|
915
|
+
`{ error, affected_files }` on commit-policy refusal.
|
|
894
916
|
|
|
895
|
-
**
|
|
896
|
-
`
|
|
917
|
+
**Stage requirements:** none (no active stage); requires a
|
|
918
|
+
`config/*` branch.
|
|
919
|
+
|
|
920
|
+
**Failure modes:**
|
|
921
|
+
- Off `config/*` branch → branch-guard refusal envelope.
|
|
922
|
+
- Failed flow → tool-name-prefixed error.
|
|
923
|
+
- Schema validation failure (missing description, semantic overlap
|
|
924
|
+
with an existing appraiser, …) → `{ ok: false, errors: [...] }`.
|
|
925
|
+
- Worktree has changes outside `foundry/**` →
|
|
926
|
+
`{ error, affected_files }`.
|
|
897
927
|
|
|
898
|
-
**
|
|
899
|
-
|
|
900
|
-
with an existing appraiser, …).
|
|
928
|
+
**Side effects:** writes the appraiser file and commits it on the
|
|
929
|
+
current `config/*` branch.
|
|
901
930
|
|
|
902
931
|
### `foundry_config_create_flow`
|
|
903
932
|
|
|
904
933
|
> Create a new flow definition under `foundry/flows/<flowId>/`.
|
|
905
934
|
|
|
906
935
|
**Args:**
|
|
907
|
-
- `
|
|
908
|
-
- `
|
|
909
|
-
|
|
936
|
+
- `id` (string, required): Flow id (kebab-case slug).
|
|
937
|
+
- `name` (string, required): Human-readable name.
|
|
938
|
+
- `startingCycles` (string[], required): Ordered list of cycle ids for this flow.
|
|
939
|
+
- `description` (string, required): Prose description of the flow.
|
|
940
|
+
|
|
941
|
+
**Returns:** `{ ok: true, path, sha }` on success;
|
|
942
|
+
`{ ok: false, errors: [...] }` on schema failure;
|
|
943
|
+
`{ error, affected_files }` on commit-policy refusal.
|
|
944
|
+
|
|
945
|
+
**Stage requirements:** none (no active stage); requires a
|
|
946
|
+
`config/*` branch.
|
|
910
947
|
|
|
911
|
-
**
|
|
912
|
-
`
|
|
948
|
+
**Failure modes:**
|
|
949
|
+
- Off `config/*` branch → branch-guard refusal envelope.
|
|
950
|
+
- Failed flow → tool-name-prefixed error.
|
|
951
|
+
- Schema validation failure → `{ ok: false, errors: [...] }`.
|
|
952
|
+
- Worktree has changes outside `foundry/**` →
|
|
953
|
+
`{ error, affected_files }`.
|
|
913
954
|
|
|
914
|
-
**
|
|
915
|
-
|
|
955
|
+
**Side effects:** writes the flow file and commits it on the
|
|
956
|
+
current `config/*` branch.
|
|
916
957
|
|
|
917
958
|
### `foundry_config_create_cycle`
|
|
918
959
|
|
|
919
960
|
> Create a new cycle markdown file under `foundry/cycles/<cycleId>.md`.
|
|
920
961
|
|
|
921
962
|
**Args:**
|
|
922
|
-
- `
|
|
923
|
-
- `
|
|
924
|
-
|
|
963
|
+
- `id` (string, required): Cycle id (kebab-case slug).
|
|
964
|
+
- `name` (string, required): Human-readable name.
|
|
965
|
+
- `outputType` (string, required): Artefact type id for this cycle's output.
|
|
966
|
+
- `inputs` (object, optional): `{ type: "any-of"|"all-of", artefacts: string[] }` — input filtering rules.
|
|
967
|
+
- `targets` (string[], optional): Target artefact file paths.
|
|
968
|
+
- `alwaysHumanAppraise` (boolean, optional): Force human appraisal on every run.
|
|
969
|
+
- `deadlockHumanAppraise` (boolean, optional): Fall back to human appraisal on deadlock.
|
|
970
|
+
- `maxIterations` (number, optional): Maximum forge-quench-appraise iterations.
|
|
971
|
+
- `assay` (object, optional): `{ extractors: string[] }` — extractors to run in the assay stage.
|
|
972
|
+
- `memory` (object, optional): `{ read: string[], write: string[] }` — memory permissions.
|
|
973
|
+
- `models` (object, optional): Per-stage model overrides.
|
|
974
|
+
- `description` (string, optional): Prose description of the cycle.
|
|
975
|
+
|
|
976
|
+
**Returns:** `{ ok: true, path, sha }` on success;
|
|
977
|
+
`{ ok: false, errors: [...] }` on schema failure;
|
|
978
|
+
`{ error, affected_files }` on commit-policy refusal.
|
|
979
|
+
|
|
980
|
+
**Stage requirements:** none (no active stage); requires a
|
|
981
|
+
`config/*` branch.
|
|
925
982
|
|
|
926
|
-
**
|
|
927
|
-
`
|
|
983
|
+
**Failure modes:**
|
|
984
|
+
- Off `config/*` branch → branch-guard refusal envelope.
|
|
985
|
+
- Failed flow → tool-name-prefixed error.
|
|
986
|
+
- Schema validation failure (unknown `outputType`, unknown
|
|
987
|
+
`memory.read` / `memory.write` types, unknown referenced appraisers,
|
|
988
|
+
…) → `{ ok: false, errors: [...] }`.
|
|
989
|
+
- Worktree has changes outside `foundry/**` →
|
|
990
|
+
`{ error, affected_files }`.
|
|
928
991
|
|
|
929
|
-
**
|
|
930
|
-
|
|
931
|
-
`memory.read` / `memory.write` types, unknown referenced appraisers,
|
|
932
|
-
…).
|
|
992
|
+
**Side effects:** writes the cycle file and commits it on the
|
|
993
|
+
current `config/*` branch.
|
|
933
994
|
|
|
934
995
|
---
|
|
935
996
|
|
|
@@ -1181,7 +1242,7 @@ read-disallowed.
|
|
|
1181
1242
|
|
|
1182
1243
|
**Args:**
|
|
1183
1244
|
- `type`, `name` (string, required).
|
|
1184
|
-
- `depth` (number, optional, default 1).
|
|
1245
|
+
- `depth` (number, optional, default 1, maximum 5).
|
|
1185
1246
|
- `edge_types` (string[], optional): Restrict traversal to named edges;
|
|
1186
1247
|
defaults to all known edges.
|
|
1187
1248
|
|
|
@@ -1211,7 +1272,7 @@ cycle cannot read; query contains a forbidden keyword.
|
|
|
1211
1272
|
|
|
1212
1273
|
**Args:**
|
|
1213
1274
|
- `query_text` (string, required).
|
|
1214
|
-
- `k` (number, optional, default 5).
|
|
1275
|
+
- `k` (number, optional, default 5, maximum 100).
|
|
1215
1276
|
- `type_filter` (string[], optional): default = all readable entity
|
|
1216
1277
|
types.
|
|
1217
1278
|
|