@really-knows-ai/foundry 3.2.7 → 3.3.1

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.
@@ -48,28 +48,37 @@ If the user names a type-specific law for an artefact type that does not exist,
48
48
 
49
49
  ### 2. Draft the law
50
50
 
51
- Write the law following the standard format:
51
+ Write the law using these structured fields:
52
52
 
53
- ```markdown
54
- ## <law-id>
53
+ - `id` (string) — lowercase, hyphenated law identifier, unique across all laws
54
+ - `name` (string) — human-readable name
55
+ - `description` (string) — one or two sentences describing what this law checks
56
+ - `passing` (string) — description of what passing looks like
57
+ - `failing` (string) — description of what failing looks like
58
+ - `validators` (array, optional) — validator entries. Include only when a deterministic check can decide pass/fail. See **Validator contract** below for the exact shape a validator command must satisfy.
55
59
 
56
- <What this law checks one or two sentences.>
60
+ #### 2a. Identify deterministic vs subjective elements
57
61
 
58
- validators:
59
- - id: validator-id
60
- command: ./script.sh
61
- failure-means: (optional description)
62
- ```
62
+ For each law, explicitly split what it checks into two categories:
63
+
64
+ - **Deterministic** — can be checked by a script without human or LLM judgment. Examples: line count, syllable count, word minimum, forbidden patterns, file existence, formatting rules. These become `validators:` entries in the law.
65
+ - **Subjective** — requires judgment. Examples: imagery quality, emotional resonance, persuasiveness, aesthetic appeal, clarity of argument. The appraisers evaluate these during the appraise stage. No validator entry needed; the law's prose alone guides the appraiser.
66
+
67
+ Walk the user through this split for each law:
63
68
 
64
- The `law-id` (heading) should be:
69
+ > This law covers [summary]. Here's what's deterministic vs subjective:
70
+ > - Deterministic: [list elements that can be script-checked]
71
+ > - Subjective: [list elements requiring judgment — appraisers handle these]
72
+ >
73
+ > Shall I add validators for the deterministic elements?
74
+
75
+ For each deterministic element, write a standalone `.mjs` script next to the artefacts it validates (e.g. `foundry/artefacts/<type>/check-line-count.mjs`) and reference it in the command (e.g. `node foundry/artefacts/<type>/check-line-count.mjs {files}`). Place validators alongside the artefacts so they colocate with what they validate. Prefer Node.js built-ins and libraries already in the project; hand-rolled heuristics are fragile — use available packages instead of writing custom validation logic from scratch.
76
+
77
+ The `id` value should be:
65
78
  - Lowercase, hyphenated
66
79
  - Short but descriptive
67
80
  - Unique across all laws (global and type-specific)
68
81
 
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.
72
-
73
82
  ### 3. Check for conflicts
74
83
 
75
84
  Read all existing laws that would apply to the same artefact types:
@@ -111,7 +120,7 @@ Iterate until the user is happy.
111
120
 
112
121
  ### 5. Validate the draft
113
122
 
114
- Call `foundry_config_validate_law({ name: "<file-name-without-extension>", body: "<full markdown>" })`.
123
+ Call `foundry_config_validate_law({ name: "<id>", body: "<assembled markdown>" })`. Assemble the body from the fields using the `## <id>` heading format the tool produces internally.
115
124
 
116
125
  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 that don't exist yet.
117
126
 
@@ -126,8 +135,11 @@ Then call:
126
135
 
127
136
  ```
128
137
  foundry_config_add_law({
129
- name: "<file-name-without-extension>",
130
- body: "<full markdown>",
138
+ id: "<id>",
139
+ name: "<name>",
140
+ description: "<description>",
141
+ passing: "<passing>",
142
+ failing: "<failing>",
131
143
  target: { kind: "global", file: "<file-name>.md" } // OR
132
144
  { kind: "type-specific", typeId: "<artefact-type>" }
133
145
  })
@@ -140,9 +152,9 @@ The tool:
140
152
  - produces one git commit on the current `config/*` branch.
141
153
 
142
154
  The tool appends to an existing `laws.md` automatically when the
143
- new `## <law-id>` heading is not already present. It only errors when
155
+ new law id is not already present. It only errors when
144
156
  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>" })`
157
+ `foundry_config_edit_law({ id: "<law-id>", description: "<updated>", passing: "<updated>", failing: "<updated>" })`
146
158
  to modify the existing law in place.
147
159
 
148
160
  Show the user the resulting commit hash from the response.
@@ -286,7 +298,7 @@ Then proceed with the update.
286
298
 
287
299
  #### 8e. Apply the update
288
300
 
289
- Call `foundry_config_edit_law({ id: "<law-id>", body: "<updated-markdown>" })` with the full updated body (prose and validators combined).
301
+ Call `foundry_config_edit_law({ id: "<law-id>", description: "<updated>", passing: "<updated>", failing: "<updated>", validators: [...] })` with the full updated fields.
290
302
 
291
303
  Validate the result. If the tool returns `{ ok: true }`, show the user the commit hash. If it returns `{ ok: false, errors }`, address each error and retry.
292
304
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@really-knows-ai/foundry",
3
- "version": "3.2.7",
3
+ "version": "3.3.1",
4
4
  "description": "A skill-driven framework for governed artefact generation with AI coding tools. Define your own artefact types, laws, and flows — Foundry handles the forge → quench → appraise pipeline with deterministic routing, quality gates, and iterative refinement.",
5
5
  "type": "module",
6
6
  "main": "dist/.opencode/plugins/foundry.js",