@really-knows-ai/foundry 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +8 -7
  2. package/dist/.opencode/plugins/foundry-tools/config-law-tools.js +53 -69
  3. package/dist/.opencode/plugins/foundry-tools/helpers.js +10 -19
  4. package/dist/.opencode/plugins/foundry-tools/refresh-agents-tool.js +88 -0
  5. package/dist/.opencode/plugins/foundry-tools/validate-tools.js +37 -29
  6. package/dist/.opencode/plugins/foundry.js +2 -0
  7. package/dist/CHANGELOG.md +182 -0
  8. package/dist/README.md +8 -7
  9. package/dist/agents/foundry.md +37 -0
  10. package/dist/docs/architecture.md +6 -3
  11. package/dist/docs/concepts.md +1 -1
  12. package/dist/docs/getting-started.md +57 -135
  13. package/dist/docs/tools.md +21 -1
  14. package/dist/scripts/sort.js +1 -1
  15. package/dist/skills/add-appraiser/SKILL.md +19 -34
  16. package/dist/skills/add-artefact-type/SKILL.md +47 -43
  17. package/dist/skills/add-cycle/SKILL.md +28 -37
  18. package/dist/skills/add-extractor/SKILL.md +21 -33
  19. package/dist/skills/add-flow/SKILL.md +43 -88
  20. package/dist/skills/add-law/SKILL.md +132 -26
  21. package/dist/skills/add-memory-edge-type/SKILL.md +11 -17
  22. package/dist/skills/add-memory-entity-type/SKILL.md +9 -16
  23. package/dist/skills/change-embedding-model/SKILL.md +6 -8
  24. package/dist/skills/drop-memory-edge-type/SKILL.md +6 -8
  25. package/dist/skills/drop-memory-entity-type/SKILL.md +6 -8
  26. package/dist/skills/dry-run/SKILL.md +11 -28
  27. package/dist/skills/flow/SKILL.md +1 -1
  28. package/dist/skills/init-foundry/SKILL.md +47 -27
  29. package/dist/skills/init-memory/SKILL.md +11 -22
  30. package/dist/skills/list-agents/SKILL.md +1 -1
  31. package/dist/skills/refresh-agents/SKILL.md +4 -26
  32. package/dist/skills/rename-memory-edge-type/SKILL.md +6 -8
  33. package/dist/skills/rename-memory-entity-type/SKILL.md +6 -8
  34. package/dist/skills/reset-memory/SKILL.md +10 -16
  35. package/dist/skills/upgrade-foundry/SKILL.md +1 -1
  36. package/package.json +2 -1
@@ -8,34 +8,29 @@ description: Creates a new law, checking for conflicts with existing laws.
8
8
 
9
9
  You help the user create a new law. You ensure it's well-scoped, doesn't conflict with existing laws, and ends up in the right file.
10
10
 
11
- ## Prerequisites
11
+ ## Foundry Agent Preflight
12
12
 
13
- Before running this skill, verify all three of the following:
13
+ If you are clearly operating as the Foundry agent, continue.
14
14
 
15
- 1. The `foundry/` directory exists in the project root. If it does not
16
- exist, stop and tell the user:
15
+ If you are not clearly operating as the Foundry agent, pause and tell the user:
17
16
 
18
- > Foundry is not initialized in this project. Run the
19
- > `init-foundry` skill first to create the foundry/ directory
20
- > structure.
17
+ > This work is best handled by the Foundry agent. Restart OpenCode if you have just initialised Foundry, switch to the **Foundry** agent, and continue this request there.
21
18
 
22
- 2. The current git branch is a `config/*` branch. Run
23
- `git rev-parse --abbrev-ref HEAD` and confirm it matches
24
- `config/<description>`.
19
+ This is an advisory guard. Continue only when the active instructions make it clear you are the Foundry agent or the user explicitly asks to proceed here.
25
20
 
26
- 3. If the branch does not start with `config/`, instruct the user to
27
- create one before continuing:
21
+ ## Config Branch Handling
28
22
 
29
- > Foundry configuration changes must be made on a config/* branch.
30
- > From a clean main branch, call:
31
- >
32
- > `foundry_git_branch({ kind: "config", description: "<short-name>" })`
33
- >
34
- > Then re-run this skill.
23
+ Before writing Foundry configuration:
35
24
 
36
- If the user is on a `dry-run/*/*` branch, they must finish
37
- that dry-run first (`foundry_git_finish({ message, confirm: true })`)
38
- before re-running this skill on the parent `config/*`.
25
+ - Confirm `foundry/` exists. If it is missing, initialise Foundry first when that serves the user's goal.
26
+ - Check the current branch.
27
+ - On `main` or another clean non-work branch, create a `config/<short-description>` branch internally.
28
+ - On `config/*`, continue on the current branch.
29
+ - On `work/*`, stop and explain that active flow work must be finished before configuration changes.
30
+ - On `dry-run/*/*`, stop and explain that the dry run must be finished before configuration changes.
31
+ - If unrelated uncommitted changes could be affected by branching or writing files, ask before proceeding.
32
+
33
+ Do not tell the user to call branch tools directly.
39
34
 
40
35
  ## Protocol
41
36
 
@@ -49,7 +44,7 @@ If the user doesn't specify, ask:
49
44
 
50
45
  > Should this law apply globally to all artefact types, or to a specific type?
51
46
 
52
- If they name a type, verify it exists in `foundry/artefacts/`. If it doesn't, tell them and ask if they want to create the artefact type first.
47
+ If the user names a type-specific law for an artefact type that does not exist, create the artefact type first when that supports the user's stated goal. Use the `add-artefact-type` workflow internally, and ask for the file pattern only when it cannot be inferred safely.
53
48
 
54
49
  ### 2. Draft the law
55
50
 
@@ -71,7 +66,9 @@ The `law-id` (heading) should be:
71
66
  - Short but descriptive
72
67
  - Unique across all laws (global and type-specific)
73
68
 
74
- The `validators:` block is optional. Include it only if you want to add validation commands for this law.
69
+ The `validators:` block is optional. Include it only when a
70
+ deterministic check can decide pass/fail. See **Validator contract**
71
+ below for the exact shape a validator command must satisfy.
75
72
 
76
73
  ### 3. Check for conflicts
77
74
 
@@ -142,13 +139,122 @@ The tool:
142
139
  - writes the law file at the path determined by `target`;
143
140
  - produces one git commit on the current `config/*` branch.
144
141
 
145
- If the tool returns `{ ok: false, errors }` because the target file already exists, use `foundry_config_edit_law({ id: "<law-id>", body: "<updated-body>" })` to modify the law.
142
+ The tool appends to an existing `laws.md` automatically when the
143
+ new `## <law-id>` heading is not already present. It only errors when
144
+ a law with the same id is already in the file — in that case use
145
+ `foundry_config_edit_law({ id: "<law-id>", body: "<updated-body>" })`
146
+ to modify the existing law in place.
146
147
 
147
148
  Show the user the resulting commit hash from the response.
148
149
 
149
150
  ### 7. Verify uniqueness
150
151
 
151
- After the file is created, confirm the law id is unique across all law files. If a collision exists, ask the user to rename and edit by hand on this branch.
152
+ After the file is created, confirm the law id is unique across all law files. If a collision exists, read the colliding law, present the conflict to the user, propose a rename or merge, ask one focused question about the user's preference, then write and commit the resolution.
153
+
154
+ ### 7a. Validator contract
155
+
156
+ A law's `validators:` entries declare CLI commands that `quench` runs
157
+ during a cycle. The plugin parses each command's stdout as **JSONL**
158
+ (one JSON object per line). Authors must follow this contract exactly;
159
+ nothing in plugin source needs to be read.
160
+
161
+ #### Output format (stdout, parsed as JSONL)
162
+
163
+ One JSON object per line. Empty lines are ignored. Required fields:
164
+
165
+ - `file` *(string)* — path of the offending file, relative to the
166
+ worktree root. Must match at least one of the artefact type's
167
+ `file-patterns:`; otherwise the line becomes a validator-level
168
+ error, not feedback.
169
+ - `text` *(string)* — the feedback message.
170
+
171
+ Optional fields:
172
+
173
+ - `location` *(string, e.g. `"3:1"`)* — line:column reference,
174
+ prepended to `text` as `file:location — text`.
175
+ - `severity` *(string, e.g. `"error"` or `"warning"`)* — prepended to
176
+ `text` as `[severity] file:location — text` (or `[severity] file —
177
+ text` when no `location`).
178
+
179
+ Anything else on the line is preserved verbatim on the parsed item.
180
+ The validator's exit code is **ignored** — the parser reads stdout
181
+ either way, and falls back to stderr when stdout is empty (so tools
182
+ like `rg` that exit non-zero on hits still work).
183
+
184
+ #### Command placeholders
185
+
186
+ Inside `command:`, two placeholders may appear, alone, together, or
187
+ not at all. They are recognised only as standalone tokens (bounded by
188
+ whitespace or string start/end). Authors may wrap a placeholder in
189
+ single or double quotes for readability — surrounding quotes are
190
+ stripped before substitution.
191
+
192
+ - `{pattern}` → the artefact type's `file-patterns:` rendered as
193
+ space-separated, shell-quoted globs (e.g.
194
+ `'haikus/*.md' 'drafts/*.md'`). Use this when the validator does
195
+ its own globbing or accepts globs directly (e.g. `rg --glob`).
196
+ - `{files}` → the matching files in the worktree, rendered as
197
+ space-separated, shell-quoted paths (e.g.
198
+ `'haikus/one.md' 'haikus/two.md'`). Use this when the validator
199
+ takes an explicit list of file paths.
200
+
201
+ A command with neither placeholder runs verbatim — useful for
202
+ self-resolving validators such as `npm test`, `tsc --noEmit`, or
203
+ `pnpm run lint`.
204
+
205
+ #### Skip rule
206
+
207
+ A validator is skipped iff its command contains `{files}` and there
208
+ are no matching files in the worktree. Commands using `{pattern}` only,
209
+ or no placeholders at all, always run.
210
+
211
+ #### Working directory
212
+
213
+ Validators run with `cwd` set to the worktree root, so root-level
214
+ `node_modules/`, `package.json`, and project tooling all resolve
215
+ normally. Do not assume the validator runs from inside the artefact
216
+ type's directory.
217
+
218
+ #### Worked example
219
+
220
+ A validator that checks each `.md` file in `haikus/` has exactly three
221
+ non-empty lines, attached to a haiku artefact type
222
+ (`file-patterns: ["haikus/*.md"]`):
223
+
224
+ `foundry/artefacts/haiku/check-line-count.mjs`:
225
+
226
+ ~~~js
227
+ #!/usr/bin/env node
228
+ import { readFile } from 'node:fs/promises';
229
+
230
+ for (const file of process.argv.slice(2)) {
231
+ const content = await readFile(file, 'utf8');
232
+ const lines = content
233
+ .split('\n')
234
+ .map((l) => l.trim())
235
+ .filter((l) => l.length > 0);
236
+ if (lines.length !== 3) {
237
+ process.stdout.write(JSON.stringify({
238
+ file,
239
+ text: `Expected 3 non-empty lines, got ${lines.length}.`,
240
+ severity: 'error',
241
+ }) + '\n');
242
+ }
243
+ }
244
+ ~~~
245
+
246
+ Declared in the law:
247
+
248
+ ~~~markdown
249
+ ## three-lines
250
+
251
+ A haiku must consist of exactly three non-empty lines.
252
+
253
+ validators:
254
+ - id: line-count
255
+ command: node foundry/artefacts/haiku/check-line-count.mjs {files}
256
+ failure-means: The artefact file does not contain exactly three non-empty lines.
257
+ ~~~
152
258
 
153
259
  ### 8. Editing existing laws (prose or validators)
154
260
 
@@ -188,4 +294,4 @@ Validate the result. If the tool returns `{ ok: true }`, show the user the commi
188
294
 
189
295
  - You do not skip the conflict check
190
296
  - You do not silently overwrite existing laws
191
- - You do not create artefact types that is a separate skill
297
+ - You do not create artefact types unless the user's stated goal clearly requires it; ask one focused question when multiple designs are plausible
@@ -21,23 +21,17 @@ Before running this skill, verify all of the following:
21
21
  `git rev-parse --abbrev-ref HEAD` and confirm it matches
22
22
  `config/<description>`.
23
23
 
24
- 3. If the branch does not start with `config/`, instruct the user to
25
- create one before continuing:
26
-
27
- > Foundry configuration changes must be made on a config/* branch.
28
- > From a clean main branch, call:
29
- >
30
- > `foundry_git_branch({ kind: "config", description: "<short-name>" })`
31
- >
32
- > Then re-run this skill.
33
-
34
- If the user is on a `dry-run/*/*` branch, they must finish
35
- that dry-run first (`foundry_git_finish({ message, confirm: true })`)
36
- before re-running this skill on the parent `config/*`.
37
-
38
- 4. Memory is initialised (`foundry/memory/` exists; run `init-memory`
39
- if not). Entity types referenced in `sources` and `targets` must
40
- already exist (or be added first).
24
+ 3. If the branch does not start with `config/`, move to a suitable
25
+ `config/*` branch internally when the current branch is safe. If
26
+ the current branch is `work/*` or `dry-run/*/*`, stop and explain
27
+ the active work must be finished first. When unrelated uncommitted
28
+ changes could be affected by branching or writing files, ask before
29
+ proceeding.
30
+
31
+ 4. Memory is initialised (`foundry/memory/` exists; initialise memory
32
+ internally first if not). Entity types referenced in `sources` and
33
+ `targets` must already exist (or be created or composed internally
34
+ when they are part of the user's stated goal).
41
35
 
42
36
  ## Steps
43
37
 
@@ -24,22 +24,15 @@ Before running this skill, verify all of the following:
24
24
  `git rev-parse --abbrev-ref HEAD` and confirm it matches
25
25
  `config/<description>`.
26
26
 
27
- 3. If the branch does not start with `config/`, instruct the user to
28
- create one before continuing:
27
+ 3. If the branch does not start with `config/`, move to a suitable
28
+ `config/*` branch internally when the current branch is safe. If
29
+ the current branch is `work/*` or `dry-run/*/*`, stop and explain
30
+ the active work must be finished first. When unrelated uncommitted
31
+ changes could be affected by branching or writing files, ask before
32
+ proceeding.
29
33
 
30
- > Foundry configuration changes must be made on a config/* branch.
31
- > From a clean main branch, call:
32
- >
33
- > `foundry_git_branch({ kind: "config", description: "<short-name>" })`
34
- >
35
- > Then re-run this skill.
36
-
37
- If the user is on a `dry-run/*/*` branch, they must finish
38
- that dry-run first (`foundry_git_finish({ message, confirm: true })`)
39
- before re-running this skill on the parent `config/*`.
40
-
41
- 4. Memory is initialised (`foundry/memory/` exists; run `init-memory`
42
- if not).
34
+ 4. Memory is initialised (`foundry/memory/` exists; initialise memory
35
+ internally first if not).
43
36
 
44
37
  ## Steps
45
38
 
@@ -71,4 +64,4 @@ Before running this skill, verify all of the following:
71
64
  git commit -m "feat(memory): add entity type <name>"
72
65
  ```
73
66
 
74
- 6. **Guidance to the user**: suggest they also add relevant edge types using `add-memory-edge-type`.
67
+ 6. **Dependency composition**: if related edge types would serve the user's stated goal, compose them internally with one focused question for ambiguity.
@@ -28,15 +28,13 @@ Before running this skill, verify all of the following:
28
28
  create one before continuing:
29
29
 
30
30
  > Foundry configuration changes must be made on a config/* branch.
31
- > From a clean main branch, call:
31
+ > If configuration changes are needed, move to a suitable `config/*`
32
+ > branch internally when the current branch is safe. If the current
33
+ > branch is `work/*` or `dry-run/*/*`, stop and explain the active
34
+ > work must be finished first.
32
35
  >
33
- > `foundry_git_branch({ kind: "config", description: "<short-name>" })`
34
- >
35
- > Then re-run this skill.
36
-
37
- If the user is on a `dry-run/*/*` branch, they must finish
38
- that dry-run first (`foundry_git_finish({ message, confirm: true })`)
39
- before re-running this skill on the parent `config/*`.
36
+ > After the prerequisite is handled, continue the user's original
37
+ > request from the current context.
40
38
 
41
39
  4. Memory is initialised and enabled. The new provider is reachable
42
40
  from this machine. Allow enough time and bandwidth to re-embed
@@ -27,15 +27,13 @@ Before running this skill, verify all of the following:
27
27
  create one before continuing:
28
28
 
29
29
  > Foundry configuration changes must be made on a config/* branch.
30
- > From a clean main branch, call:
30
+ > If configuration changes are needed, move to a suitable `config/*`
31
+ > branch internally when the current branch is safe. If the current
32
+ > branch is `work/*` or `dry-run/*/*`, stop and explain the active
33
+ > work must be finished first.
31
34
  >
32
- > `foundry_git_branch({ kind: "config", description: "<short-name>" })`
33
- >
34
- > Then re-run this skill.
35
-
36
- If the user is on a `dry-run/*/*` branch, they must finish
37
- that dry-run first (`foundry_git_finish({ message, confirm: true })`)
38
- before re-running this skill on the parent `config/*`.
35
+ > After the prerequisite is handled, continue the user's original
36
+ > request from the current context.
39
37
 
40
38
  4. Memory is initialised (`foundry/memory/` exists; run `init-memory`
41
39
  if not).
@@ -28,15 +28,13 @@ Before running this skill, verify all of the following:
28
28
  create one before continuing:
29
29
 
30
30
  > Foundry configuration changes must be made on a config/* branch.
31
- > From a clean main branch, call:
31
+ > If configuration changes are needed, move to a suitable `config/*`
32
+ > branch internally when the current branch is safe. If the current
33
+ > branch is `work/*` or `dry-run/*/*`, stop and explain the active
34
+ > work must be finished first.
32
35
  >
33
- > `foundry_git_branch({ kind: "config", description: "<short-name>" })`
34
- >
35
- > Then re-run this skill.
36
-
37
- If the user is on a `dry-run/*/*` branch, they must finish
38
- that dry-run first (`foundry_git_finish({ message, confirm: true })`)
39
- before re-running this skill on the parent `config/*`.
36
+ > After the prerequisite is handled, continue the user's original
37
+ > request from the current context.
40
38
 
41
39
  4. Memory is initialised (`foundry/memory/` exists; run `init-memory`
42
40
  if not).
@@ -22,24 +22,18 @@ files or memory rows behind on `config/<x>`.
22
22
  2. Working tree is clean.
23
23
  3. The flow id and a one-line description of the goal are known.
24
24
 
25
- If on `main`, edit on a `config/<x>` branch first:
26
- `foundry_git_branch({ kind: "config", description: "<short-name>" })`.
25
+ If on `main`, edit on a `config/<x>` branch first. If configuration
26
+ changes are needed, move to a suitable `config/*` branch internally
27
+ when the current branch is safe. If the current branch is `work/*` or
28
+ `dry-run/*/*`, stop and explain the active work must be finished first.
27
29
 
28
30
  ## Protocol
29
31
 
30
32
  ### 1. Branch into dry-run mode
31
33
 
32
- ```text
33
- foundry_git_branch({
34
- kind: "dry-run",
35
- flowId: "<flow-id>",
36
- description: "<dry-run-purpose-slug>"
37
- })
38
- ```
39
-
40
- This creates `dry-run/<x>/<flow>-<purpose>` and truncates the trace
41
- file. From here every `foundry_*` tool call is logged to
42
- `.foundry/trace/<branch-slug>.jsonl`.
34
+ The assistant creates a `dry-run/<x>/<flow>-<purpose>` branch and
35
+ truncates the trace file. From here every internal tool call is logged
36
+ to `.foundry/trace/<branch-slug>.jsonl`.
43
37
 
44
38
  ### 2. Run the flow
45
39
 
@@ -57,12 +51,8 @@ they appear in the trace.
57
51
 
58
52
  ### 4. Finish: snapshot + discard
59
53
 
60
- ```text
61
- foundry_git_finish({
62
- message: "<one-paragraph findings>",
63
- confirm: true
64
- })
65
- ```
54
+ Finish the dry-run with a one-paragraph findings message and explicit
55
+ confirmation.
66
56
 
67
57
  The tool:
68
58
 
@@ -92,15 +82,8 @@ dry-run mode for another run. Snapshots accumulate; prune them with
92
82
 
93
83
  ### 6. Finish the config
94
84
 
95
- When ready, finish `config/<x>` to `main`:
96
-
97
- ```text
98
- foundry_git_finish({
99
- message: "<config description>",
100
- baseBranch: "main",
101
- confirm: true
102
- })
103
- ```
85
+ When ready, finish `config/<x>` to `main` with a config description and
86
+ explicit confirmation.
104
87
 
105
88
  Snapshots are gitignored and stay in the local working tree; they do
106
89
  not merge with the config.
@@ -20,7 +20,7 @@ Before running this skill, verify that the `foundry/` directory exists in the pr
20
20
  ## Starting a flow
21
21
 
22
22
  1. Call `foundry_config_flow` with the flow ID — get the flow definition
23
- 2. Call `foundry_git_branch` with `kind: "work"`, the flow ID, and a short description — create the work branch (e.g. `foundry_git_branch({ kind: "work", flowId, description })`)
23
+ 2. Create a work branch for the flow using the flow ID and a short description
24
24
  3. Determine the starting cycle:
25
25
  - Any cycle listed in the flow can be the starting cycle. The flow's `starting-cycles` list is a hint for when the user's request is ambiguous.
26
26
  - Map the user's goal to a cycle by matching the requested output (e.g. "write a short story from the tennis haiku" → `create-short-story`; "write a haiku" → `create-haiku`).
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  name: init-foundry
3
3
  type: atomic
4
- description: Initialize a Foundry project by creating the foundry/ directory structure
4
+ description: Initialise a Foundry project by creating the foundry/ directory structure
5
5
  ---
6
6
 
7
- # Initialize Foundry
7
+ # Initialise Foundry
8
8
 
9
9
  Set up the `foundry/` directory structure in the current project.
10
10
 
@@ -31,46 +31,66 @@ Set up the `foundry/` directory structure in the current project.
31
31
 
32
32
  3. **Update `.gitignore`**
33
33
 
34
- Append `.snapshots/` to the project's `.gitignore` (creating the file if absent). This directory is where dry-run snapshots are written and must never be committed.
34
+ Append the following lines to the project's `.gitignore` (creating
35
+ the file if absent), skipping any that are already present:
35
36
 
36
- The plugin will idempotently append `.foundry/` itself on first boot, so you do not need to add that line.
37
+ ```
38
+ .snapshots/
39
+ node_modules/
40
+ .DS_Store
41
+ ```
42
+
43
+ - `.snapshots/` keeps dry-run snapshots out of git.
44
+ - `node_modules/` keeps any npm dependencies (e.g. validator
45
+ packages) out of git. Without it, foundry's `config/*` tools
46
+ reject calls with `unexpected_files` as soon as the user runs
47
+ `npm install`.
48
+ - `.DS_Store` keeps macOS metadata out of git.
49
+
50
+ The plugin will idempotently append `.foundry/` itself on first
51
+ boot, so you do not need to add that line.
37
52
 
38
- 4. **Generate foundry agent files**
53
+ 4. **Generate model-routing agent files**
39
54
 
40
- Run the `refresh-agents` skill to generate `.opencode/agents/foundry-*.md` files for multi-model routing.
55
+ Call `foundry_refresh_agents()` to generate model-routing `.opencode/agents/foundry-*.md` files.
41
56
 
42
- 5. **Commit the structure**
57
+ 5. **Install the Foundry guide agent**
58
+
59
+ Create `.opencode/agents/foundry.md` from the packaged Foundry guide
60
+ agent template. Copy whichever template path exists: prefer
61
+ `dist/agents/foundry.md` when running from the built package, then
62
+ fall back to `src/agents/foundry.md` when running from a source
63
+ checkout. This user-facing agent is installed during `init-foundry`;
64
+ `foundry_refresh_agents()` manages only generated `foundry-*` stage
65
+ agents.
66
+
67
+ 6. **Commit the structure**
43
68
 
44
69
  ```bash
45
- git add foundry/ .gitignore .opencode/agents/foundry-*.md
46
- git commit -m "feat: initialize Foundry project structure"
70
+ git add foundry/ .gitignore .opencode/agents/foundry.md .opencode/agents/foundry-*.md
71
+ git commit -m "feat: initialise Foundry project structure"
47
72
  ```
48
73
 
49
- 6. **Guide next steps**
74
+ 7. **Guide next steps**
50
75
 
51
76
  Tell the user:
52
77
 
53
- > Foundry is initialized. **Restart OpenCode** for the new foundry agents to take effect.
78
+ > Foundry is initialised. **Restart OpenCode** so the new Foundry agents register.
54
79
  >
55
- > The first time the plugin boots in this project, it will create the
56
- > `.foundry/` runtime directory (which holds the per-worktree HMAC key) and
57
- > idempotently append `.foundry/` to your `.gitignore` so the secret never
58
- > gets committed. The `.snapshots/` line was added by this skill to keep
59
- > dry-run snapshots out of git.
80
+ > After the restart, switch to the **Foundry** agent. The Foundry agent is the user-facing guide for setting up artefact types, laws, validators, appraisers, cycles, and flows.
60
81
  >
61
- > Here's how to set up your first pipeline:
82
+ > Then ask the Foundry agent for the outcome you want, for example:
62
83
  >
63
- > 1. **Define an artefact type** use the `add-artefact-type` skill
64
- > 2. **Add laws** — use the `add-law` skill to define quality criteria
65
- > 3. **Create appraiser personalities** — use the `add-appraiser` skill
66
- > 4. **Define a cycle** — use the `add-cycle` skill
67
- > 5. **Create a flow** — use the `add-flow` skill
84
+ > `set up a flow that writes haikus`
68
85
  >
69
- > Then run your flow with the `flow` skill.
86
+ > The first time the plugin boots in this project, it will create the
87
+ > `.foundry/` runtime directory and idempotently append `.foundry/` to
88
+ > `.gitignore` so the per-worktree HMAC key stays out of git. The
89
+ > `.snapshots/` line was added by this skill to keep dry-run snapshots
90
+ > out of git.
70
91
  >
71
92
  > **Optional: Flow Memory**
72
93
  >
73
- > If your flows need persistent knowledge (entities, relationships, semantic
74
- > search), use the `init-memory` skill to scaffold flow memory. Memory is
75
- > useful for projects that need to track code structure, dependencies, or
76
- > domain knowledge across flow runs.
94
+ > If your flows need persistent knowledge, ask the Foundry agent to add
95
+ > flow memory. Memory is useful for projects that need to track code
96
+ > structure, dependencies, or domain knowledge across flow runs.
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  name: init-memory
3
3
  type: atomic
4
- description: Initialize flow memory by creating the foundry/memory/ and foundry-memory/ directory structures
4
+ description: Initialise flow memory by creating the foundry/memory/ and foundry-memory/ directory structures
5
5
  ---
6
6
 
7
- # Initialize Flow Memory
7
+ # Initialise Flow Memory
8
8
 
9
9
  Scaffold `foundry/memory/` (config) and `foundry-memory/relations/` (row data)
10
10
  in the current project. `foundry/memory/` holds entity-type and edge-type
@@ -27,19 +27,12 @@ Before running this skill, verify all of the following:
27
27
  `git rev-parse --abbrev-ref HEAD` and confirm it matches
28
28
  `config/<description>`.
29
29
 
30
- 3. If the branch does not start with `config/`, instruct the user to
31
- create one before continuing:
32
-
33
- > Foundry configuration changes must be made on a config/* branch.
34
- > From a clean main branch, call:
35
- >
36
- > `foundry_git_branch({ kind: "config", description: "<short-name>" })`
37
- >
38
- > Then re-run this skill.
39
-
40
- If the user is on a `dry-run/*/*` branch, they must finish
41
- that dry-run first (`foundry_git_finish({ message, confirm: true })`)
42
- before re-running this skill on the parent `config/*`.
30
+ 3. If the branch does not start with `config/`, move to a suitable
31
+ `config/*` branch internally when the current branch is safe. If
32
+ the current branch is `work/*` or `dry-run/*/*`, stop and explain
33
+ the active work must be finished first. When unrelated uncommitted
34
+ changes could be affected by branching or writing files, ask before
35
+ proceeding.
43
36
 
44
37
  Neither `foundry/memory/` nor `foundry-memory/` may already exist.
45
38
 
@@ -82,11 +75,7 @@ Neither `foundry/memory/` nor `foundry-memory/` may already exist.
82
75
  git commit -m "feat: initialise flow memory"
83
76
  ```
84
77
 
85
- 5. **Tell the user what is next**:
78
+ 5. **Continue the user's original request**:
86
79
 
87
- > Flow memory is scaffolded. Next steps:
88
- >
89
- > - Use `add-memory-entity-type` to declare entity types (e.g. `class`,
90
- > `method`, `table`).
91
- > - Use `add-memory-edge-type` to declare edge types (e.g. `calls`,
92
- > `writes`, `references`).
80
+ > Flow memory is scaffolded. The Foundry agent will continue to define
81
+ > memory entity and edge types as needed to support your goal.
@@ -21,4 +21,4 @@ foundry-<provider>-<model> → <provider>/<model>
21
21
 
22
22
  If no `foundry-*.md` files are found, output:
23
23
 
24
- > No foundry agent files found. Run the `refresh-agents` skill to generate them.
24
+ > No foundry agent files found. Call `foundry_refresh_agents()` to generate them.
@@ -9,35 +9,13 @@ Regenerate `.opencode/agents/foundry-*.md` files from the currently available mo
9
9
 
10
10
  ## Protocol
11
11
 
12
- 1. Run `opencode models` to get all available `provider/model` IDs
13
- 2. Create `.opencode/agents/` directory if it does not exist
14
- 3. Delete all existing `.opencode/agents/foundry-*.md` files (stale agents from removed providers)
15
- 4. For each model line in the output, generate a markdown agent file
12
+ Call the `foundry_refresh_agents` tool. It runs `opencode models`, deletes stale agent files, and generates fresh ones.
16
13
 
17
- ### Agent file format
14
+ ## Output
18
15
 
19
- Filename: `.opencode/agents/foundry-<slug>.md`
16
+ The tool returns `{ ok: true, count: <n> }` on success.
20
17
 
21
- Where `<slug>` is the model ID with **both** `/` and `.` replaced by `-`. This keeps filenames shell-safe and unambiguous.
22
-
23
- Examples:
24
- - `opencode/claude-sonnet-4` → `.opencode/agents/foundry-opencode-claude-sonnet-4.md`
25
- - `github-copilot/claude-sonnet-4.6` → `.opencode/agents/foundry-github-copilot-claude-sonnet-4-6.md`
26
- - `github-copilot/gpt-5.4` → `.opencode/agents/foundry-github-copilot-gpt-5-4.md`
27
-
28
- Content:
29
-
30
- ```markdown
31
- ---
32
- description: "Foundry stage agent using <provider>/<model-key>"
33
- mode: subagent
34
- model: "<provider>/<model-key>"
35
- hidden: true
36
- ---
37
- You are a Foundry stage agent. Follow the skill instructions provided in your task prompt exactly.
38
- ```
39
-
40
- 5. After writing all files, output:
18
+ After the tool completes, tell the user:
41
19
 
42
20
  > Generated `<count>` foundry agent files in `.opencode/agents/`.
43
21
  > **Restart OpenCode** for the new agents to take effect.
@@ -25,15 +25,13 @@ Before running this skill, verify all of the following:
25
25
  create one before continuing:
26
26
 
27
27
  > Foundry configuration changes must be made on a config/* branch.
28
- > From a clean main branch, call:
28
+ > If configuration changes are needed, move to a suitable `config/*`
29
+ > branch internally when the current branch is safe. If the current
30
+ > branch is `work/*` or `dry-run/*/*`, stop and explain the active
31
+ > work must be finished first.
29
32
  >
30
- > `foundry_git_branch({ kind: "config", description: "<short-name>" })`
31
- >
32
- > Then re-run this skill.
33
-
34
- If the user is on a `dry-run/*/*` branch, they must finish
35
- that dry-run first (`foundry_git_finish({ message, confirm: true })`)
36
- before re-running this skill on the parent `config/*`.
33
+ > After the prerequisite is handled, continue the user's original
34
+ > request from the current context.
37
35
 
38
36
  4. Memory is initialised. The `from` edge type must exist; the `to`
39
37
  name must be free.