sil-openclaw 0.4.2 → 0.4.3

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,48 @@ release (`clawhub package publish --changelog`). See [README](./README.md#releas
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.4.3] - 2026-07-17
14
+
15
+ ### Added
16
+
17
+ - **`sil_doctor` — a report-first diagnostic over `$SIL_DATA_DIR`.** It reads the
18
+ data dir, file modes, `tokens.json` / `config.json` metadata, and artefact
19
+ frontmatter, and returns a machine-readable findings array. Token health is
20
+ metadata only (present / mode / parses / expired — expiry decoded from the
21
+ access token's own JWT `exp` claim strictly locally, no signature check, no
22
+ network, never a token byte emitted). Its only writes are two safe idempotent
23
+ fixes: tightening a too-open mode (narrows only, never widens) and creating the
24
+ missing data dir; anything that would mutate an existing artefact is reported
25
+ as `needs_confirmation`, never run. It also folds in a version advisory via one
26
+ bounded, unauthenticated, fail-soft-to-silence ClawHub `GET` — the only reason
27
+ `https://clawhub.ai` is now a declared endpoint.
28
+ - **Host-wiring drift + gateway-compat advisories (detect-only).** Every sil tool
29
+ result and `sil_doctor` now surface `advisory` findings when the plugin's
30
+ effective host wiring drifts from the manifest, or when the running OpenClaw is
31
+ below the gateway version the plugin needs. 100% local and detect-only: nothing
32
+ writes host config, spawns a process, reloads the gateway, or ships an installer.
33
+
34
+ ### Changed
35
+
36
+ - **The shopper's `agentId` is now derived from its display name** rather than
37
+ supplied separately, so the two can't drift.
38
+
39
+ ### Fixed
40
+
41
+ - **Shopper creation reached its last step on ClawHub installs.** The flow
42
+ documented a bare bin (`sil-openclaw-create-shopper`) that only reaches `PATH`
43
+ via a global npm-style install's bin linking; `openclaw plugins install` merely
44
+ extracts the tarball, so on that channel creation died silently at the end.
45
+ `sil_doctor` now reports `creationEntrypoint` (resolved from `import.meta.url`,
46
+ so the reported path and the probed path can't drift) and the skill runs it as
47
+ `node "<it>"` — no bare bin, no `<plugin-root>` placeholder.
48
+ - **Manifest `security.packagingNote` no longer declares `sil_learn`'s deleted
49
+ ops.** `0.4.2`'s document-first rewrite replaced `append` / `amend` / `retract`
50
+ with `create` / `write` / `attach-asset`, but the declared security surface
51
+ still described the old in-place section-edit model. Restated to the real
52
+ semantics: `create` mints (fail-closed if one exists), `write` replaces a whole
53
+ body (fail-closed if absent), no in-place section edit.
54
+
13
55
  ## [0.4.2] - 2026-07-14
14
56
 
15
57
  ### Changed
package/dist/index.js CHANGED
@@ -24,7 +24,9 @@
24
24
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
25
25
  import { applyPluginConfigOverrides, getWebUrl, getWebUrlSource, getApiUrl, getApiUrlSource, } from "./lib/config.js";
26
26
  import { ensureDataDir, getDataDir } from "./lib/credentials.js";
27
+ import { detectWiringDrift, readSilWiringFacts } from "./lib/host-wiring.js";
27
28
  import { registerCatalogTools } from "./tools/catalog.js";
29
+ import { registerDoctorTools } from "./tools/doctor.js";
28
30
  import { registerIdentityTools } from "./tools/identity.js";
29
31
  import { registerProfileTools } from "./tools/profile.js";
30
32
  export default definePluginEntry({
@@ -65,6 +67,30 @@ export default definePluginEntry({
65
67
  registerIdentityTools(api);
66
68
  registerCatalogTools(api);
67
69
  registerProfileTools(api);
70
+ registerDoctorTools(api);
71
+ // Host-wiring drift, at the ONE surface that survives it.
72
+ //
73
+ // `tools.alsoAllow` is GLOBAL, so the state where sil's tools are filtered
74
+ // filters `sil_doctor` too — it is a sil tool. A detector living inside the
75
+ // plugin can only speak where its own surface is callable, and here the
76
+ // gateway log is all that is left; its audience (an operator wondering why
77
+ // their sil tools do nothing) is exactly the right one.
78
+ //
79
+ // Invariant-safe: a config read already in memory plus a synchronous log.
80
+ // The rule is "opens nothing" — no timer, no socket, no unawaited promise —
81
+ // and this opens nothing. `readSilWiringFacts()` also warms its cache here,
82
+ // so a broken build fails loud at load (as `ensureDataDir` does) instead of
83
+ // throwing inside a tool result later.
84
+ const drift = detectWiringDrift(api.config, readSilWiringFacts());
85
+ if (drift.length > 0) {
86
+ api.logger.warn("sil_plugin_wiring_drift", {
87
+ message: "sil is installed but MIS-WIRED in this OpenClaw host, so part of it is"
88
+ + " not doing anything. Each finding names the exact one-line fix. sil"
89
+ + " only reports this — it never edits host config or reloads the"
90
+ + " gateway.",
91
+ findings: drift,
92
+ });
93
+ }
68
94
  api.logger.info("sil_plugin_loaded", {
69
95
  message: "sil plugin registered.",
70
96
  data_dir: dataDir,
@@ -0,0 +1,111 @@
1
+ /**
2
+ * The runnable paths of the plugin's shipped operator scripts — resolved from
3
+ * this module's own location, because the agent cannot derive them.
4
+ *
5
+ * WHY THIS EXISTS: a bare bin name (`sil-openclaw-create-shopper`) is on PATH
6
+ * only when a global npm-style install links it. `openclaw plugins install` just
7
+ * extracts the tarball and links nothing, so on that channel the documented
8
+ * creation command did not exist and the flow died at its last step.
9
+ *
10
+ * WHY NOT "resolve it from the skill file's location": the host publishes plugin
11
+ * skills as SYMLINKS into its config tree and hands the agent the symlink path
12
+ * deliberately. Node's `path.resolve()` normalizes `..` LEXICALLY, before
13
+ * touching the filesystem, so a `<skilldir>/../scripts/x` hop is erased and the
14
+ * loader looks beside the symlink, not beside the real file. `cat` and `ls`
15
+ * succeed on the exact string `node` rejects with MODULE_NOT_FOUND — a trap that
16
+ * hand-testing certifies as working. The plugin process's own `import.meta.url`
17
+ * is the ONLY sound root, so the plugin reports the path and the agent runs it.
18
+ *
19
+ * The root derivation mirrors `version-advisory.ts` — two levels up reaches the
20
+ * plugin root from both `src/lib/` and `dist/lib/`. Never cwd (production cwd is
21
+ * the agent's workspace, and cwd passes every test run from the repo root), never
22
+ * PATH, never the user's home, never a hardcoded install path.
23
+ *
24
+ * This module spawns nothing: reachability is a filesystem read. Naming a path is
25
+ * not running it, which is what keeps `security.noChildProcess` true.
26
+ */
27
+ import { statSync } from "node:fs";
28
+ import { dirname, join } from "node:path";
29
+ import { fileURLToPath } from "node:url";
30
+ /**
31
+ * THE literal. `sil_doctor` reports this path and probes this path, the skill
32
+ * prose documents it, and `package.json#bin` maps it — one constant, so the
33
+ * reported path and the probed path cannot drift. A doctor that certifies a path
34
+ * it never probed is the same class of lie this module exists to kill.
35
+ */
36
+ export const CREATION_ENTRYPOINT_RELATIVE = "scripts/create-shopper.mjs";
37
+ /** The creation entrypoint's sibling. It lives here for the same reason and by
38
+ * the same root: `wiring.tools_not_admitted` used to hand ClawHub operators a
39
+ * bare bin name too — doctor's own advice, unrunnable on the channel it
40
+ * diagnoses. One root derivation, one place. */
41
+ export const ALLOWLIST_SCRIPT_RELATIVE = "scripts/allowlist-openclaw.mjs";
42
+ const PLUGIN_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
43
+ export function resolveCreationEntrypoint() {
44
+ return join(PLUGIN_ROOT, CREATION_ENTRYPOINT_RELATIVE);
45
+ }
46
+ export function resolveAllowlistScript() {
47
+ return join(PLUGIN_ROOT, ALLOWLIST_SCRIPT_RELATIVE);
48
+ }
49
+ /**
50
+ * Probe the entrypoint — a local `stat`, so it stays determinate with the
51
+ * network down.
52
+ *
53
+ * `unresolvable` is not padding: ENOENT means the tarball shipped incomplete,
54
+ * while an unreadable parent or a non-file at the path means something else is
55
+ * wrong with the tree. They are the same severity but not the same sentence, and
56
+ * the operator's next move depends on which one it is.
57
+ */
58
+ export function probeCreationEntrypoint(entrypoint = resolveCreationEntrypoint()) {
59
+ try {
60
+ return statSync(entrypoint).isFile() ? "present" : "unresolvable";
61
+ }
62
+ catch (err) {
63
+ return err.code === "ENOENT"
64
+ ? "missing"
65
+ : "unresolvable";
66
+ }
67
+ }
68
+ /**
69
+ * A singleton subsystem check, so it reports EVERY run and says `ok` when
70
+ * healthy — `fixed → re-run → ok` needs the id to still be there after the fix.
71
+ * Hence a `Finding`, never `Finding | null`: an advisory-only builder could not
72
+ * tell "reachable" from "never checked".
73
+ *
74
+ * Pure — the caller does the I/O and hands in the verdict. That is what makes the
75
+ * no-bare-bin guarantee cheap to assert totally, over every verdict.
76
+ *
77
+ * `warn`, not `critical`: by the doctor's ladder critical means the core path is
78
+ * broken, and a plugin that broken could not run a tool to say so. The plugin
79
+ * runs fine here — one flow cannot. `warn` is also the load-bearing half: it is
80
+ * what makes `healthy` false.
81
+ */
82
+ export function buildCreationEntrypointFinding(entrypoint, verdict) {
83
+ const id = "creation.entrypoint_present";
84
+ if (verdict === "present") {
85
+ return {
86
+ id,
87
+ severity: "info",
88
+ status: "ok",
89
+ detected: `The shopper-creation entrypoint ${entrypoint} is present and runnable.`,
90
+ suggestedAction: null,
91
+ appliedAction: null,
92
+ };
93
+ }
94
+ return {
95
+ id,
96
+ severity: "warn",
97
+ status: "advisory",
98
+ detected: verdict === "missing"
99
+ ? `The shopper-creation entrypoint ${entrypoint} is missing, so creating`
100
+ + " a shopper would fail at its last step."
101
+ : `The shopper-creation entrypoint ${entrypoint} could not be read as a`
102
+ + " file, so creating a shopper would fail at its last step.",
103
+ // Never a bare bin name and never a PATH edit: this diagnoses an incomplete
104
+ // plugin tree, and the recovery must be runnable on the channel it is being
105
+ // read on. `openclaw` itself is always on PATH — that is the whole premise.
106
+ suggestedAction: "Reinstall the sil plugin through OpenClaw's own plugin install path (for"
107
+ + " example `openclaw plugins install @4gpts/sil`), then reload — the"
108
+ + " plugin tree is incomplete. sil never reinstalls itself.",
109
+ appliedAction: null,
110
+ };
111
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Derive a shopper's host `agentId` from its ONE friendly display `name`.
3
+ *
4
+ * Onboarding used to make the user invent TWO names for one shopper — a lower-kebab
5
+ * `agentId` AND a friendly display `name`. The id is pure host plumbing (a workspace
6
+ * path segment, the `/agent <id>` switch handle, the channel-bind target) the user
7
+ * should never author. `create-shopper` now takes only the `name`; the bin derives the
8
+ * id here, so the id never surfaces as a second thing the user has to get right.
9
+ *
10
+ * The slug: NFKD-normalize + strip combining marks (so `Café`/`Málaga` keep their base
11
+ * letters — `cafe`, `malaga` — instead of splitting mid-word on the accent) → lowercase
12
+ * → collapse each run of non-`[a-z0-9]` to a single hyphen → trim edge hyphens. An empty
13
+ * slug (emoji-only / punctuation-only name) OR the host-reserved `main` both fold to the
14
+ * `sil-shopper` fallback — the display `name` the user chose stays intact; only the
15
+ * plumbing id falls back, silently.
16
+ *
17
+ * Pure and total: no I/O, no host, no throw. For ANY string the result satisfies the
18
+ * postcondition `AGENT_ID_RE` (`^[a-z0-9][a-z0-9-]*$`) and is never `main` — so the bin
19
+ * needs no runtime re-validation of the derived id.
20
+ */
21
+ /** The lower-kebab shopper-id shape — never `main` (host-reserved). The postcondition
22
+ * every `deriveAgentId` result satisfies; also the bin's documented DERIVED shape. */
23
+ export const AGENT_ID_RE = /^[a-z0-9][a-z0-9-]*$/;
24
+ /** Fallback id when the slug is empty or lands on the host-reserved `main`. */
25
+ const FALLBACK_AGENT_ID = "sil-shopper";
26
+ /** The one host-reserved id a derived slug must never become. */
27
+ const RESERVED_AGENT_ID = "main";
28
+ export function deriveAgentId(name) {
29
+ const slug = name
30
+ .normalize("NFKD")
31
+ .replace(/\p{M}/gu, "")
32
+ .toLowerCase()
33
+ .replace(/[^a-z0-9]+/g, "-")
34
+ .replace(/^-+|-+$/g, "");
35
+ return slug === "" || slug === RESERVED_AGENT_ID ? FALLBACK_AGENT_ID : slug;
36
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The shared health-finding vocabulary — one addressable observation about one
3
+ * artefact or subsystem.
4
+ *
5
+ * This lives in `lib/`, not with `sil_doctor`, because a second consumer cannot
6
+ * reach a tool group without a cycle: the self-upgrade card folds a `wiring.*`
7
+ * advisory into EVERY `sil_*` result, and `tools/* → tools/doctor.ts` is an
8
+ * import cycle. `lib → tools` is the only acyclic direction.
9
+ *
10
+ * The six fields are flat and domain-agnostic on purpose: one shape serves the
11
+ * sil-shopping skill, the self-upgrade advisory, and a future dashboard. A
12
+ * version advisory and a host-wiring advisory are ordinary findings whose
13
+ * specifics ride the strings — there is no structured `advisory` sub-object.
14
+ *
15
+ * NOTHING here may ever carry a secret or PII: `detected` / `suggestedAction` /
16
+ * `appliedAction` name paths and conditions, never contents.
17
+ */
18
+ const SEVERITY_RANK = {
19
+ critical: 0,
20
+ warn: 1,
21
+ info: 2,
22
+ };
23
+ /**
24
+ * Order by (severity desc, `id` asc) — total, stable, and idempotent, so a
25
+ * dashboard renders stably and a run-to-run diff means something.
26
+ *
27
+ * Returns a new array; the input is never mutated.
28
+ */
29
+ export function sortFindings(findings) {
30
+ return [...findings].sort((a, b) => {
31
+ const bySeverity = SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity];
32
+ if (bySeverity !== 0)
33
+ return bySeverity;
34
+ if (a.id < b.id)
35
+ return -1;
36
+ if (a.id > b.id)
37
+ return 1;
38
+ return 0;
39
+ });
40
+ }
@@ -0,0 +1,238 @@
1
+ /**
2
+ * Host-wiring drift — is sil wired the way it thinks it is?
3
+ *
4
+ * A skill attaches per-agent at `agents.list[i].skills` by its PUBLISHED NAME
5
+ * (`sil-shopping` = the skill-dir basename); tools admit by PLUGIN ID (`sil`).
6
+ * Two different host keys, and conflating them seeded incident #1 — silently,
7
+ * because the host fails a bad skill ref with a warning, not an error.
8
+ *
9
+ * That silence is why this detector exists, and why the wiring advisory rides
10
+ * every `sil_*` result: a mis-wired skill isn't running its own flow, so it
11
+ * cannot carry its own warning. The tools are the only surviving messenger.
12
+ *
13
+ * DETECT ONLY. Everything here reads; nothing writes. In particular this module
14
+ * does NOT import `openclaw-allowlist.ts`: that is a mutation planner which
15
+ * edits its argument IN PLACE (`:100-104`, `:174`, `:193`, `:202`), and the
16
+ * config we are handed is the host's LIVE in-memory tree. Sharing it for a read
17
+ * would silently corrupt host state from a detect-only path. The two share
18
+ * surface knowledge, not an operation.
19
+ *
20
+ * Wiring is read from `api.config` — the tree in force in the RUNNING process —
21
+ * never from `~/.openclaw` on disk. That keeps `filesystemScope` unchanged and,
22
+ * more importantly, reports what is actually running: a fixed-on-disk config
23
+ * that has not been reloaded is STILL mis-wired, so the advisory persisting is
24
+ * truthful, not stale. Hence every fix string names edit + RELOAD.
25
+ */
26
+ import { readFileSync } from "node:fs";
27
+ import { basename, dirname, join } from "node:path";
28
+ import { fileURLToPath } from "node:url";
29
+ import { resolveAllowlistScript } from "./creation-entrypoint.js";
30
+ /** The shipped manifest, resolved relative to this module — two levels up from
31
+ * both `src/lib/` and `dist/lib/`. It ships via `package.json#files`. */
32
+ const MANIFEST_PATH = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "openclaw.plugin.json");
33
+ let cachedFacts;
34
+ /**
35
+ * Read sil's wiring facts from the shipped manifest (module-cached).
36
+ *
37
+ * The one I/O in this module; `detectWiringDrift` itself stays pure. Throws when
38
+ * the manifest is missing or shapeless: that is a broken build, not a runtime
39
+ * state to model — the same call `readInstalledVersion()` makes.
40
+ */
41
+ export function readSilWiringFacts() {
42
+ if (cachedFacts !== undefined)
43
+ return cachedFacts;
44
+ const parsed = JSON.parse(readFileSync(MANIFEST_PATH, "utf8"));
45
+ const id = parsed.id;
46
+ if (typeof id !== "string" || id.length === 0) {
47
+ throw new Error(`${MANIFEST_PATH}: manifest carries no plugin id`);
48
+ }
49
+ const skills = parsed.skills;
50
+ const ref = Array.isArray(skills) ? skills[0] : undefined;
51
+ if (typeof ref !== "string" || ref.length === 0) {
52
+ throw new Error(`${MANIFEST_PATH}: manifest declares no skill to attach`);
53
+ }
54
+ cachedFacts = { id, skill: basename(ref) };
55
+ return cachedFacts;
56
+ }
57
+ function isRecord(value) {
58
+ return typeof value === "object" && value !== null && !Array.isArray(value);
59
+ }
60
+ /** The string members of `value`, or null when it isn't an array at all. A
61
+ * mixed array yields only its strings — the config is operator-editable, and a
62
+ * detector that throws on junk turns an advisory into an outage. */
63
+ function stringsOf(value) {
64
+ if (!Array.isArray(value))
65
+ return null;
66
+ return value.filter((x) => typeof x === "string");
67
+ }
68
+ /**
69
+ * The running host's version, or `null` when nothing readable is present.
70
+ *
71
+ * `api.runtime.version` is the ONLY source, proven by probe against a live
72
+ * `alpine/openclaw:2026.6.9`. There is deliberately no fallback:
73
+ * `config.gateway` does not exist, and `config.meta.lastTouchedVersion` is the
74
+ * version that last WROTE the config file — reading that as the running host
75
+ * would fabricate a compat verdict for anyone who ran a newer OpenClaw once and
76
+ * downgraded. `null` ⇒ INCONCLUSIVE ⇒ no compat finding, ever.
77
+ */
78
+ export function readHostVersion(api) {
79
+ const version = api.runtime?.version;
80
+ if (typeof version !== "string")
81
+ return null;
82
+ const trimmed = version.trim();
83
+ return trimmed.length === 0 ? null : trimmed;
84
+ }
85
+ /**
86
+ * Detect host-wiring drift. Pure: no I/O, no network, no mutation.
87
+ *
88
+ * `config` is `unknown` because it is the operator-editable OpenClawConfig tree;
89
+ * every read narrows, and nothing here throws. Returns 0..2 findings, each
90
+ * `warn` / `advisory` / `appliedAction: null` — we name a fix, we never apply
91
+ * one.
92
+ *
93
+ * `plugins.allow` is deliberately NOT read. Empty/absent is the permissive
94
+ * default that auto-loads everything (so sil IS allowed — flagging it would fire
95
+ * a false advisory on a correctly-working default install), and a NON-EMPTY
96
+ * allow that omits sil is unreportable by construction: the plugin never loads,
97
+ * so this code never runs. Reporting neither state means reading neither key.
98
+ */
99
+ export function detectWiringDrift(config, facts) {
100
+ if (!isRecord(config))
101
+ return [];
102
+ const findings = [];
103
+ const misattached = findMisattachedAgents(config, facts);
104
+ if (misattached.length > 0) {
105
+ findings.push(buildSkillMisattachedFinding(misattached, facts));
106
+ }
107
+ const reasons = findUnadmittedReasons(config, facts);
108
+ if (reasons.length > 0) {
109
+ findings.push(buildToolsNotAdmittedFinding(reasons, facts));
110
+ }
111
+ return findings;
112
+ }
113
+ /**
114
+ * Agents that reached for sil and used the WRONG token: `skills` carries the
115
+ * plugin id but NOT the published name.
116
+ *
117
+ * Both halves are load-bearing. "Lacks the published name" alone is not drift —
118
+ * a host runs many agents and only one is the shopper, so that would fire on
119
+ * every unrelated agent. And an agent carrying BOTH tokens is not drift either:
120
+ * the published name attaches, the skill runs, nothing is degraded.
121
+ */
122
+ function findMisattachedAgents(config, facts) {
123
+ const agents = isRecord(config["agents"]) ? config["agents"] : undefined;
124
+ const list = Array.isArray(agents?.["list"]) ? agents["list"] : [];
125
+ const labels = [];
126
+ for (let i = 0; i < list.length; i += 1) {
127
+ const entry = list[i];
128
+ if (!isRecord(entry))
129
+ continue;
130
+ const skills = stringsOf(entry["skills"]);
131
+ if (skills === null)
132
+ continue;
133
+ if (!skills.includes(facts.id) || skills.includes(facts.skill))
134
+ continue;
135
+ // The fix string points at this agent, so it must be legible. An entry with
136
+ // no usable id is operator corruption — the drift is still real, so report
137
+ // it positionally rather than printing `undefined` at the operator.
138
+ const id = entry["id"];
139
+ labels.push(typeof id === "string" && id.length > 0 ? id : `agents.list[${i}]`);
140
+ }
141
+ return labels;
142
+ }
143
+ /**
144
+ * Why sil's tools are filtered, if they are. Two independent causes, folded into
145
+ * ONE finding — AC3/AC11 pin a bare `wiring.tools_not_admitted` id that the
146
+ * doctor and the tool fold must both carry, so it cannot be per-cause suffixed.
147
+ *
148
+ * ENABLE ≠ ADMIT is the false negative this exists for: `enabled: true` means
149
+ * the plugin LOADS, not that its tools are admitted. That is the half-trust
150
+ * state (the agent-creation-engine bug) where the register-time log is the only
151
+ * surface still alive.
152
+ */
153
+ function findUnadmittedReasons(config, facts) {
154
+ const reasons = [];
155
+ // Only a NON-EMPTY allowlist that omits the id counts: an empty/absent one
156
+ // admits by default, and flagging it would fire on a default install.
157
+ const tools = isRecord(config["tools"]) ? config["tools"] : undefined;
158
+ const alsoAllow = stringsOf(tools?.["alsoAllow"]);
159
+ if (alsoAllow !== null && alsoAllow.length > 0 && !alsoAllow.includes(facts.id)) {
160
+ reasons.push(`the plugin id "${facts.id}" is absent from a non-empty \`tools.alsoAllow\``);
161
+ }
162
+ const plugins = isRecord(config["plugins"]) ? config["plugins"] : undefined;
163
+ const entries = isRecord(plugins?.["entries"]) ? plugins["entries"] : undefined;
164
+ const entry = entries?.[facts.id];
165
+ // An ABSENT entry is not drift (the host loads discovered plugins by default);
166
+ // only an explicit `false` is.
167
+ if (isRecord(entry) && entry["enabled"] === false) {
168
+ reasons.push(`\`plugins.entries.${facts.id}.enabled\` is false`);
169
+ }
170
+ return reasons;
171
+ }
172
+ /**
173
+ * The advisory block to spread onto a `sil_*` SUCCESS payload.
174
+ *
175
+ * PRESENT-ONLY-ON-DRIFT: healthy wiring yields `{}`, so the happy-path payload
176
+ * stays byte-identical to today. Absence of a problem is not a finding, and an
177
+ * always-present key is one consumers start depending on.
178
+ *
179
+ * Additive, never a wrapper: a `sil_search` result carrying an advisory is still
180
+ * the same search result, with the same products in the same order.
181
+ *
182
+ * It recurs on every result while the drift persists — that is the feature, not
183
+ * noise: the misconfiguration it reports is silent by construction, which is
184
+ * exactly how it rotted into incident #1. It self-clears when the fix is IN
185
+ * EFFECT (after the reload), not when the file is merely edited.
186
+ *
187
+ * No I/O on this hot path: `readSilWiringFacts()` is module-cached and warmed at
188
+ * register(), where a broken build correctly fails loud instead of taking down
189
+ * the tool result it was folded into.
190
+ */
191
+ export function wiringAdvisories(api) {
192
+ const drift = detectWiringDrift(api.config, readSilWiringFacts());
193
+ return drift.length === 0 ? {} : { advisories: drift };
194
+ }
195
+ function buildSkillMisattachedFinding(agentLabels, facts) {
196
+ const agents = agentLabels.join(", ");
197
+ const plural = agentLabels.length > 1;
198
+ return {
199
+ id: "wiring.skill_misattached",
200
+ severity: "warn",
201
+ status: "advisory",
202
+ detected: `${plural ? "Agents" : "Agent"} ${agents} attach${plural ? "" : "es"} sil by`
203
+ + ` plugin id "${facts.id}" instead of its published skill name`
204
+ + ` "${facts.skill}". A skill attaches by published name, so the sil skill`
205
+ + ` is NOT running for ${plural ? "these agents" : "that agent"} — its`
206
+ + ` tools still work, which is why this rides the tool result.`,
207
+ suggestedAction: `In each listed agent's \`skills\` (${agents}), replace "${facts.id}" with`
208
+ + ` "${facts.skill}", then reload OpenClaw — the edit takes effect on the`
209
+ + ` next reload, and sil never reloads the gateway itself.`,
210
+ appliedAction: null,
211
+ };
212
+ }
213
+ function buildToolsNotAdmittedFinding(reasons, facts) {
214
+ return {
215
+ id: "wiring.tools_not_admitted",
216
+ severity: "warn",
217
+ status: "advisory",
218
+ detected: `sil's tools are not admitted by the running OpenClaw: ${reasons.join("; ")}.`
219
+ + ` The plugin loads, but every sil_* tool stays filtered.`,
220
+ // NEVER an inline `openclaw config set tools.alsoAllow …`: that key is
221
+ // overwrite-only on 2026.6.9, so following such a "fix" would silently
222
+ // un-admit every other plugin already in the array. A fix that breaks klodi
223
+ // to fix sil is not a fix — and the user would discover it later, in a
224
+ // different plugin, with no trail back to us. The shipped script is additive
225
+ // and idempotent across all three trust surfaces.
226
+ //
227
+ // By absolute path via `node`, NEVER the bare `sil-openclaw-allowlist` name:
228
+ // that name reaches PATH only through a global npm-style install's bin
229
+ // linking, which the plugin-install channel does not do. An operator who is
230
+ // already broken, follows this advice, and gets "command not found" learns
231
+ // that the doctor cannot be trusted.
232
+ suggestedAction: `Run \`node "${resolveAllowlistScript()}"\` — it admits "${facts.id}"`
233
+ + ` additively, preserving every other trusted plugin — then reload`
234
+ + ` OpenClaw. The edit takes effect on the next reload, and sil never`
235
+ + ` writes host config or reloads the gateway itself.`,
236
+ appliedAction: null,
237
+ };
238
+ }