sil-openclaw 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,111 @@ release (`clawhub package publish --changelog`). See [README](./README.md#releas
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.4.2] - 2026-07-14
14
+
15
+ ### Changed
16
+
17
+ - **The shopper no longer sets a per-agent `tools.deny`.** `create-shopper.mjs` used to
18
+ deny `["exec","write","edit","apply_patch"]`; removed. On the codex runtime the shell is
19
+ codex-native (surfaced as `bash`) — a tool the deny never named, so it read skill files
20
+ and could write host files regardless, while the denied OpenClaw `exec` tool was one
21
+ codex never used. Denying fs-mutators while a shell stays open buys nothing (an open
22
+ shell writes anyway — documented OpenClaw behaviour). The shopper now inherits the host
23
+ default toolset; the shell is open by design (trusted single-operator posture) and is how
24
+ codex reads its progressively-disclosed skill references. Persistence is steered to the
25
+ sil tools by the skill, not by tool policy.
26
+ - **`SKILL.md`'s always-on contract now pins two behaviours that lived only in read-once
27
+ references:** the shopper's memory is the sil store (`sil_learn` / `sil_profile_*`),
28
+ never a workspace `MEMORY.md`; and Beat 4 is bounded to **≤ 4 spec-filtered `sil_search`
29
+ calls** per request (core first, then widenings — never brand-by-brand). Both went stale
30
+ in attention when they lived two lazy reference-hops deep.
31
+ - **`sil_learn`'s write model is now document-first: `create` / `write` / `attach-asset`.**
32
+ The surgical bullet ops (`append` / `amend` / `retract`) are removed. `create` mints a
33
+ NEW method/PRD (errors if one exists); `write` replaces an existing doc's whole body with
34
+ a reconciled version the model authors (read it first, carry every buyer line forward). A
35
+ correction now rewrites the line it changes instead of stacking a contradicting bullet —
36
+ the self-contradicting PRD (a "prefer transparency" requirement beside a "transparency not
37
+ valued" correction) becomes structurally impossible. The method now holds only the general
38
+ buying guide + coined spec **vocabulary** (never this-buyer values); the PRD carries a
39
+ **`## Search specs`** block — the resolved `{ns,key,op,value,hard?}` predicate set projected
40
+ verbatim into `sil_search`, so structured filters no longer decay to keyword-only
41
+ mid-session. Beat 1 pins the domain to the broad, reusable product category (never folding
42
+ the use-context into the slug), and a "prefer X, Y/Z acceptable" requirement becomes one
43
+ `op:in` set with the favourite applied as ranking, not an over-hard `eq`.
44
+
45
+ ### Fixed
46
+
47
+ - **Artefacts no longer serialize two stacked frontmatter blocks.** A model-authored
48
+ `sil_learn create` body (or `sil_profile_materialize` userSpec) that began with its own
49
+ `--- … ---` block got the store's canonical frontmatter wrapped around it.
50
+ `serializeArtefact` now strips a leading frontmatter fence from the body first, so every
51
+ artefact carries exactly one (the store's — frontmatter-as-truth); existing
52
+ double-frontmatter files self-heal on their next write.
53
+
54
+ ## [0.4.1] - 2026-07-14
55
+
56
+ ### Fixed
57
+
58
+ - **First shop now reliably mints its domain.** A buy-intent in an unlearned niche
59
+ used to stall silently — the model classified the miss, found nothing to reuse,
60
+ and, with no next move in hand, answered off the open web instead of minting the
61
+ domain and shopping the sil catalog. The mint trigger is now **structural**:
62
+ `sil_profile_search` returns `next_step: "mint_domain"` (plus `guidance`) whenever
63
+ no learned domain matches (an empty store OR a filtered miss on a populated one),
64
+ so the MISS itself points at the mint — the same way the catalog tools carry
65
+ `recovery`. The always-on `SKILL.md` contract now states the rule up front
66
+ (mint-first-on-buy-intent; the picks are always sil catalog products, never
67
+ open-web results — the web only researches the method), instead of burying it two
68
+ lazy reference-hops deep.
69
+ - **Onboarding read the wrong tool for shopper state.** `setup_onboarding.md` steered
70
+ the model to a no-arg `sil_profile_get` overview, but `sil_profile_get` *requires* a
71
+ `domainSlug` — the coordinates-only overview tool is `sil_profile_search`. All stage
72
+ reads now use `sil_whoami` + `sil_profile_search`.
73
+
74
+ ### Changed
75
+
76
+ - **The shopper's soul carries the sil creed.** Every new shopper's `SOUL.md` gets a
77
+ "The sil way" block appended after its persona — a creed, not a rulebook: the mantra
78
+ (*explore first*), the loop in three lines (learn the domain → know the person → find
79
+ the thing), and the one distinction that matters — **the sil catalog is where you buy;
80
+ the open web is where you learn**. The method lives in the skill; the philosophy lives
81
+ in the soul, where the model weights identity.
82
+ - **The skill bundle is leaner.** The whole `sil-shopping/` bundle (router + references +
83
+ example) was cut to its load-bearing contract — narration, hedging, and cross-section
84
+ restatement removed. The 1341-line `skill-content.test.ts`, which pinned prose clauses
85
+ as spec (and stayed green while the mint bug was live), is deleted and replaced by a
86
+ lean behavioral guard that pins the contract: frontmatter + name-agreement, the
87
+ registered tool set appearing in the bundle, cross-link integrity, no dead tokens, and
88
+ the mint-first / catalog-of-record rule.
89
+ - **The shopper is denied the shell + file-write escape hatches.** `create-shopper.mjs`
90
+ now sets `agents.list[<idx>].tools.deny = ["exec","write","edit","apply_patch"]` (a
91
+ per-agent deny, never a global host change) so a new shopper can no longer run a shell
92
+ (`exec` — which it wasted re-reading its own skill files) or mutate host files
93
+ (`write`/`edit`/`apply_patch` — which it used to persist shopping memory into the host
94
+ workspace instead of the sil store). `deny` is used deliberately over a `tools.profile`
95
+ override: per OpenClaw's tool-precedence model a deny only *further-restricts* and
96
+ cannot strip the sil grant, whereas a profile swap replaces the agent's base tool set
97
+ and would risk removing the sil tools entirely. The sil tools and web (for domain
98
+ research) are kept.
99
+ - **Minting is where the shopper explores; the catalog is where it buys.**
100
+ `method_and_prds.md`'s MINT step now encourages web research **freely and often** to
101
+ learn how a niche is really bought (its load-bearing attributes, failure modes, what
102
+ separates a good buy from a bad one) — that exploration is the point of a first shop.
103
+ The one boundary: the shopper researches the **domain** on the web, never the
104
+ **products** — recommended products always come from `sil_search`, and if the catalog's
105
+ results aren't satisfactory that is the answer, not an open-web fallback.
106
+ - **Consolidated the reference set.** Deleted `references/catalog_tools_reference.md` and
107
+ `references/search_param_mapping.md` — the per-tool behaviour, status taxonomy, and
108
+ search params they restated already live in the tool definitions. Merged
109
+ `references/brainstorm_interview.md` into `references/agent_creation_engine.md` so the
110
+ onboarding interview and the creation engine are one endorsement-gated "create the
111
+ shopper" doc.
112
+ - **Leaner tool descriptions.** The five `sil_profile_*` / `sil_learn` verbs and
113
+ `sil_specs` had their descriptions cut to their load-bearing core (the store rules
114
+ they restated are already enforced by the code and named by the per-field schema),
115
+ reducing the per-turn token cost. `sil_profile_search` now advertises its
116
+ `next_step: mint_domain` cue.
117
+
13
118
  ## [0.4.0] - 2026-07-13
14
119
 
15
120
  ### Changed
@@ -45,9 +45,6 @@ const METHOD_FILE = "method.md";
45
45
  /** A domain slug / PRD key must be lower-kebab and never `main` (host-reserved). Both
46
46
  * are joined as filesystem path segments, so they carry this guard before any join. */
47
47
  const SEGMENT_RE = /^[a-z0-9][a-z0-9-]*$/;
48
- /** The stable marker the shop loop's reject-at-pick rule greps for an inviolable
49
- * constraint (e.g. `- [hard] never leather`). */
50
- const HARD_MARKER = "[hard]";
51
48
  /** attach-asset limits: ~8 MB decoded, image MIME allowlist → file extension. */
52
49
  const MAX_ASSET_BYTES = 8 * 1024 * 1024;
53
50
  const MIME_EXT = {
@@ -126,7 +123,10 @@ function serializeArtefact(fields, body) {
126
123
  const fm = Object.entries(fields)
127
124
  .map(([k, v]) => k + ": " + scalar(v))
128
125
  .join("\n");
129
- const b = body.endsWith("\n") ? body : body + "\n";
126
+ // The store owns frontmatter — strip any block a model prepended to the body so the
127
+ // artefact never stacks two (self-heals a previously double-wrapped file on re-write).
128
+ const clean = stripLeadingFrontmatter(body);
129
+ const b = clean.endsWith("\n") ? clean : clean + "\n";
130
130
  return "---\n" + fm + "\n---\n" + b;
131
131
  }
132
132
  /** Parse `--- key: value … ---` frontmatter + body. Returns null (⇒ `unreadable`) on
@@ -150,6 +150,15 @@ function parseArtefact(raw) {
150
150
  return null;
151
151
  return { fields, body };
152
152
  }
153
+ /** Strip a leading `--- … ---` frontmatter block a model may have prepended to a body,
154
+ * reusing `parseArtefact` so ONLY a fence whose content is real frontmatter (≥1
155
+ * `key: value`) is removed — a body opening with a bare `---` thematic break parses to
156
+ * null and is returned untouched. The store owns frontmatter (frontmatter-as-truth), so a
157
+ * model-authored block must never survive into the serialized body and stack a second. */
158
+ function stripLeadingFrontmatter(body) {
159
+ const parsed = parseArtefact(body);
160
+ return parsed === null ? body : parsed.body;
161
+ }
153
162
  /** Read + parse one artefact file, or null if absent/unreadable/malformed. */
154
163
  function readArtefactFile(path) {
155
164
  if (!existsSync(path))
@@ -251,36 +260,25 @@ function resolveTarget(spec) {
251
260
  };
252
261
  }
253
262
  export function learnArtefact(spec) {
254
- // `hard` is valid ONLY on append to user_spec / prd. Every other combination —
255
- // all four non-append kinds on any target, and append to method — is rejected
256
- // LOUDLY, never silently dropped: a buyer who passes `hard:true` expecting to
257
- // promote a constraint must learn at once when the promotion does not land.
258
- // Hoisted ABOVE the kind switch so a hard misuse wins error-precedence over the
259
- // per-kind field checks (this subsumes the old method-only append guard).
260
- if (spec.hard === true && !(spec.kind === "append" && spec.target !== "method")) {
261
- return invalid("hard", "hard is valid only on append to user_spec or prd — a method carries no hard"
262
- + " constraints, and create/amend/retract/attach-asset take no hard flag.");
263
- }
264
263
  switch (spec.kind) {
265
264
  case "create":
266
265
  return learnCreate(spec);
267
- case "append":
268
- return learnAppend(spec);
269
- case "amend":
270
- case "retract":
271
- return learnAmendRetract(spec);
266
+ case "write":
267
+ return learnWrite(spec);
272
268
  case "attach-asset":
273
269
  return learnAttachAsset(spec);
274
270
  default:
275
- return invalid("kind", "kind must be one of create|append|amend|retract|attach-asset.");
271
+ return invalid("kind", "kind must be one of create|write|attach-asset.");
276
272
  }
277
273
  }
278
- /** `create` mints a whole method or PRD body atomically — the file IS the
279
- * registration (no manifest). NOT valid for user_spec (that is materialize). */
274
+ /** `create` mints a NEW method or PRD body atomically — the file IS the registration
275
+ * (no manifest). Refuses if one already exists at these coordinates (→ use `write` to
276
+ * replace it), so a mint never silently clobbers. NOT valid for user_spec (that is
277
+ * materialize; refine it with `write`). */
280
278
  function learnCreate(spec) {
281
279
  if (spec.target === "user_spec") {
282
280
  return invalid("target", "create is not valid for user_spec — the shopper's shared spec is written by"
283
- + " sil_profile_materialize (setup), then refined with append/amend/retract.");
281
+ + " sil_profile_materialize (setup), then refined with kind:write.");
284
282
  }
285
283
  if (!nonBlank(spec.body))
286
284
  return invalid("body", "body is required and must be non-empty.");
@@ -293,6 +291,10 @@ function learnCreate(spec) {
293
291
  if (!nonBlank(spec.name))
294
292
  return invalid("name", "name is required for a method.");
295
293
  const path = join(getDomainArtefactDir(slug), METHOD_FILE);
294
+ if (existsSync(path)) {
295
+ return invalid("kind", 'a method already exists for domain "' + slug + '" — use kind:write to replace its'
296
+ + " body (create only mints a new one, it never overwrites).");
297
+ }
296
298
  const fields = { domain: slug, name: spec.name, updated_at: now };
297
299
  try {
298
300
  atomicWrite(path, serializeArtefact(fields, spec.body));
@@ -312,16 +314,17 @@ function learnCreate(spec) {
312
314
  return invalid(f, f + " is required for a prd.");
313
315
  }
314
316
  const path = join(getDomainArtefactDir(slug), PRDS_SUBDIR, prd + ".md");
315
- // Preserve created_at on a re-mint; advance updated_at.
316
- const prior = readArtefactFile(path);
317
- const createdAt = prior?.fields["created_at"] ?? now;
317
+ if (existsSync(path)) {
318
+ return invalid("kind", 'a PRD "' + prd + '" already exists in domain "' + slug + '" — use kind:write to'
319
+ + " replace its body (create only mints a new one, it never overwrites).");
320
+ }
318
321
  const fields = {
319
322
  key: prd,
320
323
  product: spec.product,
321
324
  intent: spec.intent,
322
325
  title: spec.title,
323
326
  domain: slug,
324
- created_at: createdAt,
327
+ created_at: now,
325
328
  updated_at: now,
326
329
  };
327
330
  try {
@@ -332,81 +335,26 @@ function learnCreate(spec) {
332
335
  }
333
336
  return { ok: true, kind: "create", target: "prd", domain: slug, prd, path };
334
337
  }
335
- /** append — add `- <text>` (or `- [hard] <text>`) under `## <section>` when given
336
- * (fail-closed if that heading is absent), else at EOF. The target must already
337
- * exist → not_found (never resurrects a seed-less doc). `hard` is guarded up-front
338
- * in `learnArtefact` (append to method / any non-append kind is rejected there). */
339
- function learnAppend(spec) {
340
- if (!nonBlank(spec.text))
341
- return invalid("text", "text is required and must be non-empty.");
338
+ /** `write` replaces the WHOLE body of an EXISTING method / PRD / user_spec with a
339
+ * reconciled version — the model reads current (`sil_profile_get`), reconciles in
340
+ * context, and writes the whole doc back. Frontmatter coordinates + `created_at` are
341
+ * preserved and `updated_at` bumps (user_spec carries no timestamp). Fail-closed on a
342
+ * missing doc (`not_found` — write never mints, that is create) and on a present-but-
343
+ * corrupt one (`unreadable` — inspect / repair, never clobber a recoverable artefact). */
344
+ function learnWrite(spec) {
345
+ if (!nonBlank(spec.body))
346
+ return invalid("body", "body is required and must be non-empty.");
342
347
  const target = resolveTarget(spec);
343
348
  if ("ok" in target)
344
349
  return target;
345
350
  const existing = readArtefactFile(target.path);
346
351
  if (existing === null) {
347
- return notFound("The target " + target.label + " does not exist — create it first (append never"
348
- + " resurrects a seed-less doc).");
349
- }
350
- const mark = spec.hard === true ? HARD_MARKER + " " : "";
351
- const bullet = "- " + mark + spec.text.trim();
352
- let body;
353
- if (nonBlank(spec.section)) {
354
- const inserted = insertUnderSection(existing.body, spec.section, bullet);
355
- if (inserted === null) {
356
- const sections = listSections(existing.body);
357
- return invalid("section", 'no "## ' + spec.section + '" heading in the ' + target.label + "; existing sections: "
358
- + (sections.length > 0 ? sections.join(", ") : "(none)"));
359
- }
360
- body = inserted;
352
+ if (existsSync(target.path))
353
+ return unreadable(target.path);
354
+ return notFound("The target " + target.label + " does not exist — mint it with kind:create first"
355
+ + " (write replaces an existing doc, it never mints).");
361
356
  }
362
- else {
363
- body = existing.body.replace(/\n*$/, "\n") + bullet + "\n";
364
- }
365
- return writeArtefactBody(target, existing.fields, body, "append");
366
- }
367
- /** amend/retract — exact single-occurrence bullet match on `from`; 0 → not_found,
368
- * 2+ → invalid_request(ambiguous_match). A `[hard]` marker is preserved on amend. */
369
- function learnAmendRetract(spec) {
370
- if (!nonBlank(spec.from))
371
- return invalid("from", "from is required and must be non-empty.");
372
- if (spec.kind === "amend" && !nonBlank(spec.to)) {
373
- return invalid("to", "to is required for amend.");
374
- }
375
- const target = resolveTarget(spec);
376
- if ("ok" in target)
377
- return target;
378
- const existing = readArtefactFile(target.path);
379
- if (existing === null) {
380
- return notFound("The target " + target.label + " does not exist — nothing to change.");
381
- }
382
- const from = spec.from.trim();
383
- const lines = existing.body.split("\n");
384
- const matches = [];
385
- const scoped = nonBlank(spec.section)
386
- ? sectionLineRange(lines, spec.section)
387
- : { start: 0, end: lines.length };
388
- for (let i = scoped.start; i < scoped.end; i++) {
389
- const parsed = parseBullet(lines[i]);
390
- if (parsed && parsed.text.trim() === from)
391
- matches.push(i);
392
- }
393
- if (matches.length === 0) {
394
- return notFound('No bullet matching "' + from + '" in the ' + target.label + ".");
395
- }
396
- if (matches.length > 1) {
397
- return invalid("ambiguous_match", "the text matches " + matches.length + " bullets — refine `from` (or scope with"
398
- + " `section`) so it matches exactly one; refusing an ambiguous multi-write.");
399
- }
400
- const idx = matches[0];
401
- if (spec.kind === "retract") {
402
- lines.splice(idx, 1);
403
- }
404
- else {
405
- const parsed = parseBullet(lines[idx]);
406
- const mark = parsed.hard ? HARD_MARKER + " " : "";
407
- lines[idx] = parsed.indent + "- " + mark + spec.to.trim();
408
- }
409
- return writeArtefactBody(target, existing.fields, lines.join("\n"), spec.kind);
357
+ return writeArtefactBody(target, existing.fields, spec.body, "write");
410
358
  }
411
359
  /** attach-asset — persist image bytes into `domains/<slug>/assets/<hash>.<ext>`
412
360
  * (owner-only, content-hash = free dedup), then link them into the target by a
@@ -493,57 +441,6 @@ function writeArtefactBody(target, fields, body, kind) {
493
441
  path: target.path,
494
442
  };
495
443
  }
496
- /** Parse a markdown bullet line (`- text` / `- [hard] text`), or null. */
497
- function parseBullet(line) {
498
- const m = /^(\s*)-\s+(\[hard\]\s+)?(.*)$/.exec(line);
499
- if (!m)
500
- return null;
501
- return { indent: m[1], hard: m[2] !== undefined, text: m[3] };
502
- }
503
- /** All `## <section>` heading texts present in a body (for a fail-closed message). */
504
- function listSections(body) {
505
- return body
506
- .split("\n")
507
- .map((l) => /^##\s+(.*)$/.exec(l))
508
- .filter((m) => m !== null)
509
- .map((m) => m[1].trim());
510
- }
511
- /** The [start,end) line range of a `## <section>` body (heading exclusive, up to the
512
- * next `## ` heading or EOF). `start === -1` when the heading is absent. */
513
- function sectionLineRange(lines, section) {
514
- const target = section.trim();
515
- let start = -1;
516
- for (let i = 0; i < lines.length; i++) {
517
- const m = /^##\s+(.*)$/.exec(lines[i]);
518
- if (m && m[1].trim() === target) {
519
- start = i + 1;
520
- break;
521
- }
522
- }
523
- if (start === -1)
524
- return { start: 0, end: 0 };
525
- let end = lines.length;
526
- for (let i = start; i < lines.length; i++) {
527
- if (/^##\s+/.test(lines[i])) {
528
- end = i;
529
- break;
530
- }
531
- }
532
- return { start, end };
533
- }
534
- /** Insert `bullet` at the end of `## <section>` (before the next heading, after the
535
- * section's last non-blank line), or null when the heading is absent. */
536
- function insertUnderSection(body, section, bullet) {
537
- if (!listSections(body).includes(section.trim()))
538
- return null;
539
- const lines = body.split("\n");
540
- const range = sectionLineRange(lines, section);
541
- let at = range.end;
542
- while (at > range.start && lines[at - 1].trim() === "")
543
- at--;
544
- lines.splice(at, 0, bullet);
545
- return lines.join("\n");
546
- }
547
444
  export function searchProfileFrontmatter(query = {}) {
548
445
  const domainsRoot = join(getShopperArtefactDir(), DOMAINS_SUBDIR);
549
446
  const domains = [];
@@ -602,25 +602,15 @@ function registerSpecs(api) {
602
602
  api.registerTool({
603
603
  name: "sil_specs",
604
604
  label: "Canonicalize coined spec definitions",
605
- description: "Canonicalize the coined spec DEFINITIONS a shopping method invents for a"
606
- + " niche — the dedupe-or-create registry call at method mint/refresh (Beat 2)."
607
- + " Pass the motivating `query` (what the shopper is buying — governance /"
608
- + " dedupe context) and `specs`, a list of coined definitions ({ namespace,"
609
- + " key, display_name, data_type, description?, unit?, allowed_values? }). Each"
610
- + " submitted spec resolves 1:1: a `matched` result means an equivalent"
611
- + " canonical spec already exists — ADOPT its `canonical` { namespace, key }"
612
- + " and DROP your coined synonym (this convergence is what makes filters.specs"
613
- + " actually filter across methods); a `created` result means yours is novel and"
614
- + " registered as canonical (`canonical` === `submitted`, keep it). Rewrite the"
615
- + " method's `## Search vocabulary` and any PRD `specs` predicates to the"
616
- + " returned canonical names BEFORE persisting — the method is born canonical,"
617
- + " never write-then-amend. On REFRESH submit ONLY the specs that do not yet"
618
- + " carry a canonical name; already-canonical names are stable, do not resubmit"
619
- + " them. This is INTERNAL plumbing: never surface `ns.key` names or"
620
- + " \"converged your specs\" to the buyer. If the call is not `ok` (retryable /"
621
- + " forbidden / must_reregister), do NOT block the mint — persist the method"
622
- + " with the raw coined names and shop on; convergence retries on the next"
623
- + " mint/refresh. Requires registration (run sil_register first).",
605
+ description: "Canonicalize the coined spec DEFINITIONS a method invents for a niche — the"
606
+ + " dedupe-or-create registry call at method mint/refresh. Pass the motivating"
607
+ + " `query` and `specs` (coined { namespace, key, display_name, data_type,"
608
+ + " description?, unit?, allowed_values? }). Each resolves 1:1: `matched` → adopt"
609
+ + " the returned canonical { namespace, key } and drop your synonym; `created` →"
610
+ + " yours is novel, keep it. Rewrite the method's search vocabulary + any PRD"
611
+ + " predicates to the canonical names before persisting. Internal plumbing — never"
612
+ + " surface ns.key to the buyer. If not `ok`, do NOT block the mint: persist raw and"
613
+ + " converge on the next mint/refresh. Requires registration.",
624
614
  parameters: Type.Object({
625
615
  query: Type.String({
626
616
  description: "The motivating shopping query — what the shopper is buying. Governance /"