@really-knows-ai/foundry 3.0.2 → 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 (34) hide show
  1. package/README.md +8 -7
  2. package/dist/.opencode/plugins/foundry-tools/helpers.js +10 -19
  3. package/dist/.opencode/plugins/foundry-tools/refresh-agents-tool.js +88 -0
  4. package/dist/.opencode/plugins/foundry.js +2 -0
  5. package/dist/CHANGELOG.md +113 -0
  6. package/dist/README.md +8 -7
  7. package/dist/agents/foundry.md +37 -0
  8. package/dist/docs/architecture.md +6 -3
  9. package/dist/docs/concepts.md +1 -1
  10. package/dist/docs/getting-started.md +57 -135
  11. package/dist/docs/tools.md +21 -1
  12. package/dist/scripts/sort.js +1 -1
  13. package/dist/skills/add-appraiser/SKILL.md +19 -34
  14. package/dist/skills/add-artefact-type/SKILL.md +19 -22
  15. package/dist/skills/add-cycle/SKILL.md +28 -37
  16. package/dist/skills/add-extractor/SKILL.md +21 -33
  17. package/dist/skills/add-flow/SKILL.md +43 -88
  18. package/dist/skills/add-law/SKILL.md +19 -24
  19. package/dist/skills/add-memory-edge-type/SKILL.md +11 -17
  20. package/dist/skills/add-memory-entity-type/SKILL.md +9 -16
  21. package/dist/skills/change-embedding-model/SKILL.md +6 -8
  22. package/dist/skills/drop-memory-edge-type/SKILL.md +6 -8
  23. package/dist/skills/drop-memory-entity-type/SKILL.md +6 -8
  24. package/dist/skills/dry-run/SKILL.md +11 -28
  25. package/dist/skills/flow/SKILL.md +1 -1
  26. package/dist/skills/init-foundry/SKILL.md +30 -25
  27. package/dist/skills/init-memory/SKILL.md +11 -22
  28. package/dist/skills/list-agents/SKILL.md +1 -1
  29. package/dist/skills/refresh-agents/SKILL.md +4 -26
  30. package/dist/skills/rename-memory-edge-type/SKILL.md +6 -8
  31. package/dist/skills/rename-memory-entity-type/SKILL.md +6 -8
  32. package/dist/skills/reset-memory/SKILL.md +10 -16
  33. package/dist/skills/upgrade-foundry/SKILL.md +1 -1
  34. package/package.json +2 -1
@@ -23,24 +23,17 @@ Before running this skill, verify all of the following:
23
23
  `git rev-parse --abbrev-ref HEAD` and confirm it matches
24
24
  `config/<description>`.
25
25
 
26
- 3. If the branch does not start with `config/`, instruct the user to
27
- create one before continuing:
28
-
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.
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/*`.
39
-
40
- 4. `foundry/memory/config.md` exists and has `enabled: true` (run
41
- `init-memory` first if not). Every entity type the extractor will
42
- populate must already be declared in `foundry/memory/entities/`
43
- (use `add-memory-entity-type` to create any that are missing).
26
+ 3. If the branch does not start with `config/`, move to a suitable
27
+ `config/*` branch internally when the current branch is safe. If
28
+ the current branch is `work/*` or `dry-run/*/*`, stop and explain
29
+ the active work must be finished first. When unrelated uncommitted
30
+ changes could be affected by branching or writing files, ask before
31
+ proceeding.
32
+
33
+ 4. `foundry/memory/config.md` exists and has `enabled: true` (initialise
34
+ memory internally first if not). Missing memory entity or edge type
35
+ dependencies are created or composed internally when they are part of
36
+ the user's stated goal.
44
37
 
45
38
  ## Steps
46
39
 
@@ -50,7 +43,7 @@ Ask the user for, in this order (one question at a time):
50
43
 
51
44
  1. **Extractor name.** Lowercase kebab-case (`java-symbols`, `python-classes`, `tree-sitter-rust`). This becomes the filename under `foundry/memory/extractors/<name>.md` and the identifier referenced from cycle frontmatter.
52
45
  2. **Command.** The path to the executable (relative to the repo root, e.g. `scripts/extract-java-symbols.sh`) or a short shell command. This is passed to `/bin/sh -c` at runtime.
53
- 3. **Entity types to populate (`memoryWrite`).** A list of entity type names already declared in this project's memory vocabulary. Validate against what exists; if the user names a type that doesn't exist, either offer to create it via `add-memory-entity-type` first or ask them to adjust.
46
+ 3. **Entity types to populate (`memoryWrite`).** A list of entity type names already declared in this project's memory vocabulary. Validate against what exists; if the user names a type that doesn't exist, compose or create it internally when it is part of the user's stated goal, or ask one focused question when schema design is ambiguous.
54
47
  4. **Timeout** (optional). Duration string like `30s`, `2m`, or a number of milliseconds. Defaults to 60 seconds if omitted.
55
48
  5. **Brief description.** 1–3 paragraphs of prose describing what this extractor extracts, what it requires on `PATH`, and any re-run triggers. This body is injected into the forge prompt of every cycle that uses this extractor, so clarity here translates to better downstream generation.
56
49
 
@@ -111,23 +104,18 @@ git add foundry/memory/extractors/<name>.md scripts/<command>
111
104
  git commit -m "feat(memory): add '<name>' extractor"
112
105
  ```
113
106
 
114
- ### 6. Guide the user on wiring it in
107
+ ### 6. Compose into a cycle when the user's goal requires it
115
108
 
116
- After creation, tell the user how to opt a cycle into this extractor:
109
+ When the user's stated goal is to add memory extraction to a flow or cycle, compose this extractor into the relevant cycle definition. See **Composing cycle definitions** below.
117
110
 
118
- > To use this extractor, add the following to the cycle's frontmatter:
119
- >
120
- > ```yaml
121
- > memory:
122
- > write: [<each type in memoryWrite>] # must include every type the extractor writes
123
- > assay:
124
- > extractors: [<this extractor's name>]
125
- > ```
126
- >
127
- > Then run the `flow` or `orchestrate` skill. On the first iteration of the cycle, the assay stage will execute this extractor before forge.
111
+ ## Dependency composition
112
+
113
+ Missing memory entity or edge type dependencies are **composed internally** when they are part of the user's stated goal. Compose into the appropriate memory vocabulary when schema design is ambiguous — ask one focused question rather than stalling.
128
114
 
129
115
  ## What this skill must not do
130
116
 
131
117
  - **Must not** run the extractor script itself to verify it works. That is the author's job.
132
- - **Must not** modify cycle definitions. Opting a cycle into the extractor is an explicit editorial step for the user to take.
133
- - **Must not** create entity or edge types that don't already exist. Compose into `add-memory-entity-type` / `add-memory-edge-type` for any missing vocabulary.
118
+
119
+ ## Composing cycle definitions
120
+
121
+ When the user's stated goal includes opting an existing cycle into this extractor, update the cycle definition internally to add the `extractors` and `memoryWrite` fields. Ask for confirmation or one focused question when cycle selection or wiring is ambiguous.
@@ -6,119 +6,74 @@ description: Creates a new foundry flow definition.
6
6
 
7
7
  # Add Flow
8
8
 
9
- You help the user create a new foundry flow. A foundry flow is a set of foundry cycles with declared starting points cycles own their own routing via targets and input contracts.
9
+ You help the user create a complete Foundry flow for their stated outcome. A flow may require artefact types, laws, validators, appraisers, and cycles before the flow file itself can validate. Work backwards from the requested outcome and create missing dependencies in validation order.
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.
39
32
 
40
- ## Protocol
41
-
42
- ### 1. Gather basics
43
-
44
- From the user's prompt, establish:
45
- - `id` — lowercase, hyphenated identifier
46
- - `name` — human-readable name
47
- - A prose description of what this foundry flow achieves end-to-end
48
-
49
- If any of these are missing, ask.
50
-
51
- ### 2. Check for id conflicts
52
-
53
- Read all existing flow definitions in `foundry/flows/*.md`.
54
-
55
- - Exact id match → hard conflict, must choose a different id
56
- - Semantically similar name or description → warn and ask if the new foundry flow is genuinely distinct
57
-
58
- ### 3. Determine foundry cycles and starting cycles
59
-
60
- Ask the user which foundry cycles this flow includes. List available cycles from `foundry/cycles/*.md` for reference.
33
+ Do not tell the user to call branch tools directly.
61
34
 
62
- Then ask: which of these are **starting cycles** — the cycles that can be entered first when the flow begins?
63
-
64
- - Starting cycles typically have no input dependencies
65
- - Multiple starting cycles are fine — the user (or context) determines which one to run first
66
-
67
- ### 4. Validate cycle graph
68
-
69
- For each non-starting cycle, verify it is reachable:
70
- - At least one other cycle in the flow has it as a target
71
- - Its input contract can be satisfied by cycles in the flow
72
-
73
- If a cycle is unreachable (no cycle targets it and it's not a starting cycle), warn:
74
-
75
- > Cycle `<id>` is not a starting cycle and no other cycle targets it. It will never be reached in this flow.
76
-
77
- ### 5. Draft the definition
35
+ ## Protocol
78
36
 
79
- Present the flow definition to the user:
37
+ ### 1. Understand the outcome
80
38
 
81
- ```markdown
82
- ---
83
- id: <id>
84
- name: <name>
85
- starting-cycles:
86
- - <cycle-id>
87
- ---
39
+ Extract or ask for the flow purpose, expected final artefact, output location, and any quality constraints. Prefer practical defaults for common requests.
88
40
 
89
- # <Name>
41
+ ### 2. Inventory existing configuration
90
42
 
91
- <description>
43
+ Read existing flows in `foundry/flows/*.md`, cycles in `foundry/cycles/*.md`, artefact types in `foundry/artefacts/*/definition.md`, laws in `foundry/laws/*.md`, and appraisers in `foundry/appraisers/*.md`. Identify reusable pieces and conflicts.
92
44
 
93
- ## Cycles
45
+ Reject duplicate flow IDs — if a flow with the same ID already exists, choose a different ID. Warn about semantic duplicates (different ID but near-identical purpose) and ask whether the new flow is genuinely distinct.
94
46
 
95
- - <cycle-id>
96
- - <cycle-id>
97
- ```
47
+ ### 3. Design the dependency set
98
48
 
99
- The `starting-cycles` field lists entry points. `## Cycles` lists all cycles in the flow (no ordering implied — routing is owned by individual cycle definitions via their `targets` field).
49
+ Create missing dependencies in validation order:
100
50
 
101
- Ask: does this capture the flow correctly?
51
+ 1. Artefact type and file patterns.
52
+ 2. Type-specific laws.
53
+ 3. Deterministic validators attached to laws.
54
+ 4. Appraisers or appraiser selection.
55
+ 5. Cycles that produce the artefact types.
56
+ 6. Flow tying starting cycles and cycle list together.
102
57
 
103
- ### 6. Validate the draft
58
+ For the haiku example, default to a `haiku` artefact type, `haikus/*.md` file pattern, laws for form, imagery, and mood, a deterministic syllable validator where project dependencies allow it, two or three distinct appraisers, one cycle, and one flow.
104
59
 
105
- Call `foundry_config_validate_flow({ name: "<id>", body: "<full markdown>" })`.
60
+ After designing cycles, validate the cycle graph: verify each non-starting cycle is reachable from a starting cycle through the `targets` graph, and verify each cycle's input contracts can be satisfied by other cycles in the flow. Warn about unreachable cycles or unsatisfiable contracts before proceeding.
106
61
 
107
- If the result is `{ ok: false, errors: [...] }`, address each error (adjust the body) and re-run until you get `{ ok: true }`. Common issues: missing required frontmatter keys, references to artefact types or flows that don't exist yet.
62
+ ### 4. Confirm ambiguous choices
108
63
 
109
- ### 7. Create the file
64
+ Ask only for choices that affect the user's goal or safety. Reuse compatible existing configuration when it clearly fits.
110
65
 
111
- Call `foundry_config_create_flow({ name: "<id>", body: "<full markdown>" })`. The tool:
66
+ ### 5. Validate and create each piece
112
67
 
113
- - re-validates the body (TOCTOU);
114
- - writes `foundry/flows/<id>.md`;
115
- - produces one git commit on the current `config/*` branch.
68
+ For each definition, use the `foundry_config_validate_*` tool family to validate it first. Resolve any validation errors, then use the corresponding `foundry_config_create_*` tool to create it. Summarise each created file and commit hash in Foundry terms.
116
69
 
117
- If the tool returns `{ ok: false, errors }` because the target file already exists, the user should edit the file by hand on this `config/*` branch — `foundry_config_create_flow` does not support updates.
70
+ ### 6. Final summary
118
71
 
119
- Show the user the resulting commit hash from the response.
72
+ Report the flow, starting cycles, artefact type, laws, validators, appraisers, and files created. Tell the user they can now ask the Foundry agent to run the flow.
120
73
 
121
- ## What you do NOT do
74
+ ## Safety Rules
122
75
 
123
- - You do not create foundry cycles that is a separate skill
124
- - You do not skip dependency validation
76
+ - Do not create overlapping artefact file patterns.
77
+ - Do not skip dependency validation.
78
+ - Do not expose internal tool-call syntax to the user.
79
+ - Do not continue when a branch or worktree state could overwrite user changes.
@@ -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
 
@@ -154,7 +149,7 @@ Show the user the resulting commit hash from the response.
154
149
 
155
150
  ### 7. Verify uniqueness
156
151
 
157
- 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.
158
153
 
159
154
  ### 7a. Validator contract
160
155
 
@@ -299,4 +294,4 @@ Validate the result. If the tool returns `{ ok: true }`, show the user the commi
299
294
 
300
295
  - You do not skip the conflict check
301
296
  - You do not silently overwrite existing laws
302
- - 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
 
@@ -50,42 +50,47 @@ Set up the `foundry/` directory structure in the current project.
50
50
  The plugin will idempotently append `.foundry/` itself on first
51
51
  boot, so you do not need to add that line.
52
52
 
53
- 4. **Generate foundry agent files**
53
+ 4. **Generate model-routing agent files**
54
54
 
55
- 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.
56
56
 
57
- 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**
58
68
 
59
69
  ```bash
60
- git add foundry/ .gitignore .opencode/agents/foundry-*.md
61
- 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"
62
72
  ```
63
73
 
64
- 6. **Guide next steps**
74
+ 7. **Guide next steps**
65
75
 
66
76
  Tell the user:
67
77
 
68
- > 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.
69
79
  >
70
- > The first time the plugin boots in this project, it will create the
71
- > `.foundry/` runtime directory (which holds the per-worktree HMAC key) and
72
- > idempotently append `.foundry/` to your `.gitignore` so the secret never
73
- > gets committed. The `.snapshots/` line was added by this skill to keep
74
- > 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.
75
81
  >
76
- > Here's how to set up your first pipeline:
82
+ > Then ask the Foundry agent for the outcome you want, for example:
77
83
  >
78
- > 1. **Define an artefact type** use the `add-artefact-type` skill
79
- > 2. **Add laws** — use the `add-law` skill to define quality criteria
80
- > 3. **Create appraiser personalities** — use the `add-appraiser` skill
81
- > 4. **Define a cycle** — use the `add-cycle` skill
82
- > 5. **Create a flow** — use the `add-flow` skill
84
+ > `set up a flow that writes haikus`
83
85
  >
84
- > 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.
85
91
  >
86
92
  > **Optional: Flow Memory**
87
93
  >
88
- > If your flows need persistent knowledge (entities, relationships, semantic
89
- > search), use the `init-memory` skill to scaffold flow memory. Memory is
90
- > useful for projects that need to track code structure, dependencies, or
91
- > 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.