sil-openclaw 0.4.3 → 0.4.5
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 +42 -0
- package/dist/gateway/search-results.js +95 -0
- package/dist/index.js +8 -0
- package/dist/lib/search-results-store.js +113 -0
- package/dist/tools/catalog.js +17 -2
- package/openclaw.plugin.json +3 -3
- package/package.json +8 -7
- package/scripts/create-shopper.mjs +2 -3
- package/sil-shopping/SKILL.md +1 -1
- package/sil-shopping/references/agent_creation_engine.md +3 -6
- package/sil-shopping/references/fill_and_feedback.md +1 -1
- package/sil-shopping/references/setup_onboarding.md +1 -1
- package/scripts/changelog.mjs +0 -0
- package/scripts/release.mjs +0 -228
- package/scripts/sync-version.mjs +0 -52
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.5] - 2026-07-23
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **`sil.search_results` — pull a `sil_search` page over the paired gateway WS.**
|
|
18
|
+
A plugin-owned gateway method (scope `operator.read`, enforced by the host
|
|
19
|
+
before the handler runs) that answers `{ callId }` with the exact page that
|
|
20
|
+
call produced. The `callId` is the host's own — the same string a client
|
|
21
|
+
already reads off the tool frames — so the two sides join with no translation
|
|
22
|
+
table. It never reaches the model, starts no run, and re-queries nothing.
|
|
23
|
+
Unknown, expired, and foreign references all get one identical `not_found`
|
|
24
|
+
body; the cause is an operator-log marker only.
|
|
25
|
+
- **A bounded in-memory buffer behind it** (32 pages, 15-minute retention, lazy
|
|
26
|
+
eviction on write, no timer, never on disk) that `sil_search` writes its `ok`
|
|
27
|
+
page into as a pure side effect.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- **`sil_search`'s result is untouched** — no new key, no reference, no flag.
|
|
32
|
+
Every channel gets byte-identically what it got before.
|
|
33
|
+
- **Host floor raised to `>=2026.7.1`** (`compat.pluginApi`,
|
|
34
|
+
`compat.minGatewayVersion`, `install.minHostVersion`): the version
|
|
35
|
+
`registerGatewayMethod` is proven on. An older host is refused outright rather
|
|
36
|
+
than limped along on a compat shim.
|
|
37
|
+
|
|
38
|
+
## [0.4.4] - 2026-07-17
|
|
39
|
+
|
|
40
|
+
### Security
|
|
41
|
+
|
|
42
|
+
- **Ship only the two runtime operator bins, not the whole `scripts/` dir.**
|
|
43
|
+
`package.json#files` was dragging maintainer tooling (`release.mjs`,
|
|
44
|
+
`changelog.mjs`, `sync-version.mjs`) into the tarball. `security.noChildProcess`
|
|
45
|
+
is now `false` — the runtime spawns nothing, but the two shipped bins drive the
|
|
46
|
+
host `openclaw` CLI via `execFileSync`.
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- **Creation-engine doc: dropped a false claim and its defensive prose.** The
|
|
51
|
+
shopper's memory is the sil store; removed the "never to host files" absolute
|
|
52
|
+
that contradicted the one-time `SOUL.md` write, and the open-shell justification.
|
|
53
|
+
- **Narrowed the skill bundle's activation `description:` to explicit sil intent.**
|
|
54
|
+
|
|
13
55
|
## [0.4.3] - 2026-07-17
|
|
14
56
|
|
|
15
57
|
### Added
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `sil.search_results` — the plugin-owned gateway method a paired client calls
|
|
3
|
+
* to pull a `sil_search` page by the `callId` it already saw on the tool
|
|
4
|
+
* identity frames.
|
|
5
|
+
*
|
|
6
|
+
* NOT a tool, which is why it lives outside `src/tools/`: it never reaches the
|
|
7
|
+
* model, starts no run, and has no agent-facing surface. It is also not
|
|
8
|
+
* manifest-declarable — the host's `contracts` vocabulary is a closed set with
|
|
9
|
+
* no gateway-method key, so REGISTRATION IS THE DECLARATION.
|
|
10
|
+
*
|
|
11
|
+
* Two layers of authorization, each owned where it belongs. The HOST enforces
|
|
12
|
+
* role + `operator.read` before this handler runs (from the `{scope}` opt), so
|
|
13
|
+
* the plugin implements no scope logic and offers no bypass. The PLUGIN
|
|
14
|
+
* enforces the one thing the host cannot know: that the page belongs to the sil
|
|
15
|
+
* ACCOUNT that produced it, not to the machine or the socket. That is the only
|
|
16
|
+
* gate that matters here — the key is the host's `callId`, visible to anyone who
|
|
17
|
+
* can see the frames, so knowing one is never evidence of entitlement.
|
|
18
|
+
*
|
|
19
|
+
* Every outcome rides `respond(true, <structured body>)`; `ok:false` is used for
|
|
20
|
+
* nothing. A client reads a method-level ERROR as a transport fault worth
|
|
21
|
+
* retrying, and an unknown, expired, or foreign reference is not retryable —
|
|
22
|
+
* retrying it forever would leave the shopper's item spinning. So the failure is
|
|
23
|
+
* a successful response carrying a structured non-`ok` body, exactly as every
|
|
24
|
+
* sil tool already carries `status:"not_registered"` inside a successful result.
|
|
25
|
+
*
|
|
26
|
+
* The four failure causes are ONE body on the wire. A caller must not be able to
|
|
27
|
+
* tell "never existed" from "expired" from "not yours" — the distinction is a
|
|
28
|
+
* log marker, and nothing on the wire has a field, shape, or timing tell.
|
|
29
|
+
*/
|
|
30
|
+
import { hasTokens, readConfig } from "../lib/credentials.js";
|
|
31
|
+
import { getSearchResult, searchResultMiss } from "../lib/search-results-store.js";
|
|
32
|
+
export const SEARCH_RESULTS_METHOD = "sil.search_results";
|
|
33
|
+
/** The ONE failure body: unknown ≡ expired ≡ wrong-principal ≡ no live session.
|
|
34
|
+
* A client must be able to tell this apart from a genuine empty match (which is
|
|
35
|
+
* `{status:"ok", products:[]}`), or it renders a silent empty grid for what is
|
|
36
|
+
* actually a delivery failure. */
|
|
37
|
+
const NOT_FOUND = {
|
|
38
|
+
status: "not_found",
|
|
39
|
+
error: "result_unavailable",
|
|
40
|
+
message: "No search results are available for this call. They may never have been"
|
|
41
|
+
+ " stored, or the retention window has elapsed — run the search again.",
|
|
42
|
+
};
|
|
43
|
+
const INVALID_REQUEST = {
|
|
44
|
+
status: "invalid_request",
|
|
45
|
+
error: "invalid_call_id",
|
|
46
|
+
message: "sil.search_results requires a non-empty string `callId`.",
|
|
47
|
+
};
|
|
48
|
+
export function registerSearchResultsMethod(api) {
|
|
49
|
+
api.registerGatewayMethod(SEARCH_RESULTS_METHOD, ({ params, respond }) => {
|
|
50
|
+
// A throw out of here is an opaque gateway error the client reads as a
|
|
51
|
+
// retryable transport fault, so it would leave a shopper's item spinning
|
|
52
|
+
// forever on a permanent condition. Fail closed to the uniform body.
|
|
53
|
+
try {
|
|
54
|
+
resolve(api, params, respond);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
api.logger.error("sil_search_results_failed", {
|
|
58
|
+
cause: err instanceof Error ? err.message : String(err),
|
|
59
|
+
});
|
|
60
|
+
respond(true, NOT_FOUND);
|
|
61
|
+
}
|
|
62
|
+
}, { scope: "operator.read" });
|
|
63
|
+
}
|
|
64
|
+
function resolve(api, params, respond) {
|
|
65
|
+
const callId = params["callId"];
|
|
66
|
+
if (typeof callId !== "string" || callId.length === 0) {
|
|
67
|
+
api.logger.info("sil_search_results_invalid", { reason: "invalid_call_id" });
|
|
68
|
+
respond(true, INVALID_REQUEST);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// The principal is the sil account holding a LIVE session. `clearTokens()`
|
|
72
|
+
// unlinks tokens.json and leaves config.json intact, so the token check is
|
|
73
|
+
// what makes a logged-out plugin resolve nothing — a page belongs to the
|
|
74
|
+
// identity that produced it, never to the machine.
|
|
75
|
+
const principal = hasTokens() ? readConfig()?.user?.id : undefined;
|
|
76
|
+
if (principal === undefined) {
|
|
77
|
+
api.logger.info("sil_search_results_miss", { found: false, reason: "no_principal" });
|
|
78
|
+
respond(true, NOT_FOUND);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const page = getSearchResult(callId, principal);
|
|
82
|
+
if (page === null) {
|
|
83
|
+
api.logger.info("sil_search_results_miss", {
|
|
84
|
+
found: false,
|
|
85
|
+
reason: searchResultMiss(callId, principal),
|
|
86
|
+
});
|
|
87
|
+
respond(true, NOT_FOUND);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
api.logger.info("sil_search_results_hit", { found: true, count: page.products.length });
|
|
91
|
+
// Handed over BY REFERENCE, aliasing the array the agent envelope already
|
|
92
|
+
// serialized. Deliberate: both paths JSON-serialize immediately and neither
|
|
93
|
+
// mutates, so a defensive clone would copy ~50 KB per resolve for nothing.
|
|
94
|
+
respond(true, page);
|
|
95
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
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 { registerSearchResultsMethod } from "./gateway/search-results.js";
|
|
27
28
|
import { detectWiringDrift, readSilWiringFacts } from "./lib/host-wiring.js";
|
|
28
29
|
import { registerCatalogTools } from "./tools/catalog.js";
|
|
29
30
|
import { registerDoctorTools } from "./tools/doctor.js";
|
|
@@ -68,6 +69,13 @@ export default definePluginEntry({
|
|
|
68
69
|
registerCatalogTools(api);
|
|
69
70
|
registerProfileTools(api);
|
|
70
71
|
registerDoctorTools(api);
|
|
72
|
+
// The pull surface a paired client resolves a search page from. Registering
|
|
73
|
+
// a closure opens nothing — no socket, no timer — so the invariant above
|
|
74
|
+
// holds; the store behind it is touched only inside the handler and inside
|
|
75
|
+
// sil_search's execute(). NOT a tool and NOT a `registerXTools` group: it
|
|
76
|
+
// never reaches the model, and the manifest's `contracts` vocabulary has no
|
|
77
|
+
// gateway-method key, so this call IS the declaration.
|
|
78
|
+
registerSearchResultsMethod(api);
|
|
71
79
|
// Host-wiring drift, at the ONE surface that survives it.
|
|
72
80
|
//
|
|
73
81
|
// `tools.alsoAllow` is GLOBAL, so the state where sil's tools are filtered
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The search-results delivery buffer.
|
|
3
|
+
*
|
|
4
|
+
* `sil_search` returns its full page to the agent exactly as it always has —
|
|
5
|
+
* this store is a pure SIDE EFFECT on the `ok` path, invisible to every
|
|
6
|
+
* channel. It exists because the host's projection of a tool result is not a
|
|
7
|
+
* dependable transport for structured data: under codex `data.result` is absent
|
|
8
|
+
* from every frame, and the transcript that would otherwise carry it is both
|
|
9
|
+
* provider-capped and rewritten under context pressure as a run grows. A client
|
|
10
|
+
* that wants to render an intermediate search therefore needs its own way to
|
|
11
|
+
* fetch it — `sil.search_results` (see `../gateway/search-results.ts`) reads
|
|
12
|
+
* this map and answers over the paired `deviceToken` WS.
|
|
13
|
+
*
|
|
14
|
+
* The key is the HOST's `callId`, verbatim — never prefixed, hashed, or
|
|
15
|
+
* re-minted. It is the one identifier that is reliably streamed (the client
|
|
16
|
+
* already reads it off the tool identity frames as `data.itemId`), and
|
|
17
|
+
* `execute()` receives it BEFORE any I/O, so a page can never be orphaned by a
|
|
18
|
+
* failing search. Because that id is visible to anyone who can see the frames,
|
|
19
|
+
* knowledge of a `callId` is NOT evidence of entitlement: the principal check
|
|
20
|
+
* below is the only gate that matters.
|
|
21
|
+
*
|
|
22
|
+
* In-memory, by choice. Process death is the strongest retention ceiling
|
|
23
|
+
* available and costs nothing; an on-disk buffer would put prices, seller
|
|
24
|
+
* identity, and `checkout_url` at rest, widen the plugin's declared filesystem
|
|
25
|
+
* scope, and — with no timers allowed — leave the last pages there forever once
|
|
26
|
+
* the user stops searching.
|
|
27
|
+
*
|
|
28
|
+
* TIMER-FREE, and that is load-bearing: `register()` must stay synchronous and
|
|
29
|
+
* open nothing, so eviction is lazy on write. Reads are pure — they never
|
|
30
|
+
* evict, never reorder, and never consume, because a client remount or reload
|
|
31
|
+
* re-resolves the same page and a one-shot read would blank the shopper's
|
|
32
|
+
* screen on the first refresh.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* Fifteen minutes. A search result is point-in-time — price, availability, and
|
|
36
|
+
* `checkout_url` are exactly the fields a shopper must re-fetch before buying —
|
|
37
|
+
* so this is long enough for the settle edge, a client reload, a reconnect, and
|
|
38
|
+
* a short step-away, and short enough that nothing renders as stale truth. It
|
|
39
|
+
* is a delivery buffer, not scrollback and not history.
|
|
40
|
+
*/
|
|
41
|
+
export const RETENTION_MS = 15 * 60_000;
|
|
42
|
+
/**
|
|
43
|
+
* Sized against a whole RUN, not a single request: a real run issues 5–10 tool
|
|
44
|
+
* calls and a client must be able to render EVERY intermediate search in it,
|
|
45
|
+
* not just the last — so a "latest result" slot (or anything near the ≤4-call
|
|
46
|
+
* fan-out one shopper request makes) would evict an early search before the run
|
|
47
|
+
* ends. 32 leaves several runs' worth of headroom at a worst case of roughly
|
|
48
|
+
* 32 × ~51 KB ≈ 1.6 MB, which is nothing against the gateway's own 25 MB frame
|
|
49
|
+
* ceiling. Retention is a CEILING, not a guarantee: past it the product answer
|
|
50
|
+
* is always the same — run a fresh search.
|
|
51
|
+
*/
|
|
52
|
+
export const MAX_ENTRIES = 32;
|
|
53
|
+
const entries = new Map();
|
|
54
|
+
/** Store one `ok` page under the host's `callId`, bound to the sil account that
|
|
55
|
+
* produced it. An empty principal is refused: a page has an owner or it is
|
|
56
|
+
* unreachable, and an ownerless entry would only burn capacity. */
|
|
57
|
+
export function putSearchResult(callId, page, principal) {
|
|
58
|
+
if (principal.length === 0)
|
|
59
|
+
return;
|
|
60
|
+
evict();
|
|
61
|
+
entries.set(callId, { principal, page, expiresAtMs: Date.now() + RETENTION_MS });
|
|
62
|
+
}
|
|
63
|
+
/** The stored page, or `null` for every miss — unknown, expired, and foreign are
|
|
64
|
+
* ONE outcome to the caller. Pure: no eviction, no reordering, no consumption,
|
|
65
|
+
* so a client remount re-resolves the same page and a foreign probe cannot deny
|
|
66
|
+
* the owner theirs. */
|
|
67
|
+
export function getSearchResult(callId, principal) {
|
|
68
|
+
return lookup(callId, principal).page;
|
|
69
|
+
}
|
|
70
|
+
/** The miss cause, for the OPERATOR LOG only (criterion C3) — never the wire.
|
|
71
|
+
* A separate query rather than a richer return, because the wire path must not
|
|
72
|
+
* be able to reach the cause by accident: reading it is a deliberate call. */
|
|
73
|
+
export function searchResultMiss(callId, principal) {
|
|
74
|
+
return lookup(callId, principal).miss;
|
|
75
|
+
}
|
|
76
|
+
/** Reset for tests. Production never calls this — the process IS the lifetime. */
|
|
77
|
+
export function __resetSearchResultsStore() {
|
|
78
|
+
entries.clear();
|
|
79
|
+
}
|
|
80
|
+
function lookup(callId, principal) {
|
|
81
|
+
const entry = entries.get(callId);
|
|
82
|
+
if (entry === undefined)
|
|
83
|
+
return { page: null, miss: "unknown" };
|
|
84
|
+
if (entry.expiresAtMs <= Date.now())
|
|
85
|
+
return { page: null, miss: "expired" };
|
|
86
|
+
// An empty principal is the anonymous bucket, and there is no legitimate
|
|
87
|
+
// anonymous owner — it must not match, not even an entry stored under one.
|
|
88
|
+
if (principal.length === 0 || entry.principal !== principal) {
|
|
89
|
+
return { page: null, miss: "principal_mismatch" };
|
|
90
|
+
}
|
|
91
|
+
return { page: entry.page, miss: null };
|
|
92
|
+
}
|
|
93
|
+
/** Lazy eviction, run on every write: drop what has expired, then trim to
|
|
94
|
+
* capacity oldest-first. `Map` preserves insertion order and reads never touch
|
|
95
|
+
* it, so "oldest" is insertion order — deliberately not LRU-on-read, which
|
|
96
|
+
* would make a read mutate the store. */
|
|
97
|
+
function evict() {
|
|
98
|
+
const now = Date.now();
|
|
99
|
+
for (const [callId, entry] of entries) {
|
|
100
|
+
if (entry.expiresAtMs <= now)
|
|
101
|
+
entries.delete(callId);
|
|
102
|
+
}
|
|
103
|
+
// `>=` because this runs BEFORE the `set`, so the store never exceeds the
|
|
104
|
+
// ceiling. Re-writing an existing `callId` can trim one entry it did not need
|
|
105
|
+
// to; a `callId` is unique per tool call, so that branch is unreachable in
|
|
106
|
+
// practice and guarding it would cost more than it saves.
|
|
107
|
+
while (entries.size >= MAX_ENTRIES) {
|
|
108
|
+
const oldest = entries.keys().next();
|
|
109
|
+
if (oldest.done === true)
|
|
110
|
+
return;
|
|
111
|
+
entries.delete(oldest.value);
|
|
112
|
+
}
|
|
113
|
+
}
|
package/dist/tools/catalog.js
CHANGED
|
@@ -58,8 +58,9 @@
|
|
|
58
58
|
*/
|
|
59
59
|
import { Type } from "typebox";
|
|
60
60
|
import { getApiUrl } from "../lib/config.js";
|
|
61
|
-
import { clearTokens, readTokens } from "../lib/credentials.js";
|
|
61
|
+
import { clearTokens, readConfig, readTokens } from "../lib/credentials.js";
|
|
62
62
|
import { wiringAdvisories } from "../lib/host-wiring.js";
|
|
63
|
+
import { putSearchResult } from "../lib/search-results-store.js";
|
|
63
64
|
import { lookupCatalog, refreshAndRetryOnce, searchCatalog, specsCatalog, } from "../lib/sil-client.js";
|
|
64
65
|
import { jsonResult } from "../lib/tool-result.js";
|
|
65
66
|
/**
|
|
@@ -311,7 +312,7 @@ function registerSearch(api) {
|
|
|
311
312
|
+ " both. Omit when there are no structured requirements.",
|
|
312
313
|
})),
|
|
313
314
|
}),
|
|
314
|
-
async execute(
|
|
315
|
+
async execute(callId, params) {
|
|
315
316
|
// 1 — not registered: terminal, zero network calls.
|
|
316
317
|
const stored = readTokens();
|
|
317
318
|
if (stored === null) {
|
|
@@ -352,6 +353,20 @@ function registerSearch(api) {
|
|
|
352
353
|
// logs-only, no token material, NOT a payload field (the agent never sees it).
|
|
353
354
|
if (recovered.refreshed)
|
|
354
355
|
api.logger.info("sil_search_refreshed", {});
|
|
356
|
+
// Buffer the page for a paired client to pull by this exact `callId`
|
|
357
|
+
// (`sil.search_results`). A PURE SIDE EFFECT: the envelope returned
|
|
358
|
+
// below is byte-identical to what every channel got before this
|
|
359
|
+
// existed — no reference, no flag, no listener check. Only `ok` is
|
|
360
|
+
// stored; the other outcomes steer the agent's recovery and carry no
|
|
361
|
+
// product data to deliver. `advisories` stay OFF the stored page —
|
|
362
|
+
// they are operator/agent copy, not products.
|
|
363
|
+
if (recovered.outcome.kind === "ok") {
|
|
364
|
+
const { kind: _kind, ...page } = recovered.outcome;
|
|
365
|
+
const principal = readConfig()?.user?.id;
|
|
366
|
+
if (principal !== undefined) {
|
|
367
|
+
putSearchResult(callId, { status: "ok", ...page }, principal);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
355
370
|
return mapSearchOutcome(api, recovered.outcome);
|
|
356
371
|
case "must_reregister":
|
|
357
372
|
// A dead refresh token (invalid_grant) is cleared so the agent's
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "sil",
|
|
3
3
|
"name": "sil",
|
|
4
4
|
"description": "Turn your OpenClaw into an expert shopping agent.",
|
|
5
|
-
"version": "0.4.
|
|
5
|
+
"version": "0.4.5",
|
|
6
6
|
"skills": ["./sil-shopping"],
|
|
7
7
|
"activation": {
|
|
8
8
|
"onCapabilities": ["tool"]
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"security": {
|
|
56
56
|
"shipsRuntimeCode": true,
|
|
57
|
-
"packagingNote": "Compiled JavaScript ships under ./dist. register() stays synchronous and opens nothing — it only registers tools. ALL I/O happens inside a tool's execute(): sil_register calls sil-web over the network, writes tokens.json + config.json to the plugin data directory (owner-only, 0600), and arms a bounded background poll timer that stops on the first terminal claim outcome or after the session deadline. sil_whoami reads the stored session token and calls sil-api for the user's identity, refreshing transparently via sil-web on a 401 (at most one refresh + one retry per call, no timer); a confirmed-dead session clears tokens.json. sil_search and sil_product_get read the stored session token and call sil-api's catalog endpoints (search / lookup) with it — read-only on catalog data, no timer, but with the SAME bounded 401 recovery as sil_whoami: on a 401 they refresh ONCE via sil-web (rotating tokens.json) and retry the read ONCE; a second 401 or a dead (invalid_grant) refresh token clears tokens.json and is reported as a terminal re-register hint. A non-401 error writes no token. The five profile verbs make NO network call and read no token; they write the one sil shopper's SINGLETON behaviour artefacts under a fixed $SIL_DATA_DIR/shopper/ (owner-only, files 0600, dirs 0700) as frontmatter-as-truth markdown — there is NO profile.json manifest; each file's own frontmatter IS the source of truth, discovered by a filesystem scan. sil_profile_materialize is SETUP-ONLY: it writes shopper/user_spec.md (the shared person spec; its frontmatter carries the shopper name), minting no domain. sil_learn is the single target+change verb over shopper/domains/<slug>/{method.md, prds/<product>-<intent>.md, assets/}: create mints a whole method or PRD, fail-closed if one already exists; write replaces an existing doc's whole body with a caller-authored reconciled version, fail-closed if the target is absent — there is no in-place section edit, so every change rewrites the whole document; attach-asset persists image bytes (size-capped, image MIME allowlist) into the domain's assets/ owner-only and links them by RELATIVE path, never inline bytes. sil_profile_search scans artefact FRONTMATTER and returns coordinates only (no bodies) — a domain/PRD with malformed frontmatter is skipped and surfaced as unreadable, never silently dropped or half-read. sil_profile_get reads ONE whole body (method or PRD); sil_profile_remove deletes a whole validated domain subtree, or one PRD file, fail-closed on a malformed/traversal/\"main\" or missing slug (never the whole shopper). sil_doctor is a report-first diagnostic over the SAME $SIL_DATA_DIR state: it reads the data dir, file modes, tokens.json/config.json metadata, and artefact frontmatter, and returns a machine-readable findings array. It reads no token contents out and rotates no token: token health is metadata only (present / mode / parses / expired), where expiry is decoded from the access token's own JWT exp claim strictly LOCALLY (decode-only, no signature verification, no network, no claim other than exp extracted, never a token byte emitted or logged). Its only writes are two safe idempotent fixes under $SIL_DATA_DIR — tightening a too-open mode and creating the missing data dir; a tighten only ever NARROWS (it detects bits set outside the expected mask and chmods to mode & expected, which can only clear bits, never grant them). Enumerated entries under the data dir are lstat'd, and a symlink found among them is REPORTED, never chmod'd-through — that is what keeps a tighten inside the store. The data directory ROOT itself is stat'd rather than lstat'd, because chmod follows a symlink regardless (Linux exposes no lchmod), so lstat there would prevent nothing and merely re-report the same fix forever; a symlinked $SIL_DATA_DIR is an operator-declared indirection, so the tighten lands on the directory the plugin already stores everything in. anything that would mutate the bytes of an existing artefact (clearing a corrupt tokens.json, deleting an orphaned tmp file, repairing an artefact) is REPORTED as needs_confirmation and never run. It makes exactly ONE outbound request, and it is the only reason https://clawhub.ai is declared: an unauthenticated read-only GET of the published version of @4gpts/sil, bounded by an explicit timeout + abort, carrying no token, no PII, no store contents, and no Authorization header, pinned to that one host (redirects are refused). It fails soft to silence — an unreachable, slow, non-200, or unparseable response yields no finding at all and never fails the run. sil_doctor never acts on the version it reports: it installs nothing, spawns no process, writes no host config, and prompts nobody. The only caller-supplied path segments are the domain slug and the PRD key, both validated (lower-kebab, not \"main\") before any join; the shopper segment is a compile-time constant. Every write is atomic (tmp file → rename over target → chmod), so a reader sees a whole file or none. The persona is the shopper's host workspace SOUL.md, written by the host CLI (not this plugin, not a sil artefact), and the shopper's host-config wiring is driven separately by the host CLI. The PKCE verifier is held only in memory and is never written to disk. Artefact bodies, tokens, and identity PII are never logged.",
|
|
57
|
+
"packagingNote": "Compiled JavaScript ships under ./dist. register() stays synchronous and opens nothing — it only registers tools. ALL I/O happens inside a tool's execute(): sil_register calls sil-web over the network, writes tokens.json + config.json to the plugin data directory (owner-only, 0600), and arms a bounded background poll timer that stops on the first terminal claim outcome or after the session deadline. sil_whoami reads the stored session token and calls sil-api for the user's identity, refreshing transparently via sil-web on a 401 (at most one refresh + one retry per call, no timer); a confirmed-dead session clears tokens.json. sil_search and sil_product_get read the stored session token and call sil-api's catalog endpoints (search / lookup) with it — read-only on catalog data, no timer, but with the SAME bounded 401 recovery as sil_whoami: on a 401 they refresh ONCE via sil-web (rotating tokens.json) and retry the read ONCE; a second 401 or a dead (invalid_grant) refresh token clears tokens.json and is reported as a terminal re-register hint. A non-401 error writes no token. The five profile verbs make NO network call and read no token; they write the one sil shopper's SINGLETON behaviour artefacts under a fixed $SIL_DATA_DIR/shopper/ (owner-only, files 0600, dirs 0700) as frontmatter-as-truth markdown — there is NO profile.json manifest; each file's own frontmatter IS the source of truth, discovered by a filesystem scan. sil_profile_materialize is SETUP-ONLY: it writes shopper/user_spec.md (the shared person spec; its frontmatter carries the shopper name), minting no domain. sil_learn is the single target+change verb over shopper/domains/<slug>/{method.md, prds/<product>-<intent>.md, assets/}: create mints a whole method or PRD, fail-closed if one already exists; write replaces an existing doc's whole body with a caller-authored reconciled version, fail-closed if the target is absent — there is no in-place section edit, so every change rewrites the whole document; attach-asset persists image bytes (size-capped, image MIME allowlist) into the domain's assets/ owner-only and links them by RELATIVE path, never inline bytes. sil_profile_search scans artefact FRONTMATTER and returns coordinates only (no bodies) — a domain/PRD with malformed frontmatter is skipped and surfaced as unreadable, never silently dropped or half-read. sil_profile_get reads ONE whole body (method or PRD); sil_profile_remove deletes a whole validated domain subtree, or one PRD file, fail-closed on a malformed/traversal/\"main\" or missing slug (never the whole shopper). sil_doctor is a report-first diagnostic over the SAME $SIL_DATA_DIR state: it reads the data dir, file modes, tokens.json/config.json metadata, and artefact frontmatter, and returns a machine-readable findings array. It reads no token contents out and rotates no token: token health is metadata only (present / mode / parses / expired), where expiry is decoded from the access token's own JWT exp claim strictly LOCALLY (decode-only, no signature verification, no network, no claim other than exp extracted, never a token byte emitted or logged). Its only writes are two safe idempotent fixes under $SIL_DATA_DIR — tightening a too-open mode and creating the missing data dir; a tighten only ever NARROWS (it detects bits set outside the expected mask and chmods to mode & expected, which can only clear bits, never grant them). Enumerated entries under the data dir are lstat'd, and a symlink found among them is REPORTED, never chmod'd-through — that is what keeps a tighten inside the store. The data directory ROOT itself is stat'd rather than lstat'd, because chmod follows a symlink regardless (Linux exposes no lchmod), so lstat there would prevent nothing and merely re-report the same fix forever; a symlinked $SIL_DATA_DIR is an operator-declared indirection, so the tighten lands on the directory the plugin already stores everything in. anything that would mutate the bytes of an existing artefact (clearing a corrupt tokens.json, deleting an orphaned tmp file, repairing an artefact) is REPORTED as needs_confirmation and never run. It makes exactly ONE outbound request, and it is the only reason https://clawhub.ai is declared: an unauthenticated read-only GET of the published version of @4gpts/sil, bounded by an explicit timeout + abort, carrying no token, no PII, no store contents, and no Authorization header, pinned to that one host (redirects are refused). It fails soft to silence — an unreachable, slow, non-200, or unparseable response yields no finding at all and never fails the run. sil_doctor never acts on the version it reports: it installs nothing, spawns no process, writes no host config, and prompts nobody. The only caller-supplied path segments are the domain slug and the PRD key, both validated (lower-kebab, not \"main\") before any join; the shopper segment is a compile-time constant. Every write is atomic (tmp file → rename over target → chmod), so a reader sees a whole file or none. The persona is the shopper's host workspace SOUL.md, written by the host CLI (not this plugin, not a sil artefact), and the shopper's host-config wiring is driven separately by the host CLI. The PKCE verifier is held only in memory and is never written to disk. The plugin registers ONE gateway RPC method, sil.search_results (scope operator.read, which the host authorizes before the handler runs): a paired client calls it over the already-authenticated deviceToken WS to read back a sil_search page whose callId it already saw on the tool frames. It opens no socket, no port, and no route — registering it hands the host a closure, and the host owns the transport. The pages it serves live in a bounded IN-MEMORY buffer that is never written to disk: sil_search stores its own successful result there under the callId the host passed it (at most 32 pages, dropped 15 minutes after the search, evicted lazily on the next write with no timer, and gone entirely when the process exits). The method makes no network call, starts no agent run, and returns a page only to the sil account that produced it — every unknown, expired, or foreign reference gets one identical not-found body. Artefact bodies, tokens, and identity PII are never logged; the method logs only whether a page was found and how many products it held.",
|
|
58
58
|
"registersLongLivedService": false,
|
|
59
59
|
"serviceIds": [],
|
|
60
60
|
"runsTimers": true,
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"config.json (user identity)"
|
|
73
73
|
],
|
|
74
74
|
"noNativeModules": true,
|
|
75
|
-
"noChildProcess":
|
|
75
|
+
"noChildProcess": false,
|
|
76
76
|
"noInstallScripts": true,
|
|
77
77
|
"reportVulnerabilitiesTo": "https://x.com/4gpts"
|
|
78
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sil-openclaw",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Turn your OpenClaw into an expert shopping agent.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
34
|
"dist",
|
|
35
|
-
"scripts",
|
|
35
|
+
"scripts/create-shopper.mjs",
|
|
36
|
+
"scripts/allowlist-openclaw.mjs",
|
|
36
37
|
"sil-shopping",
|
|
37
38
|
"openclaw.plugin.json",
|
|
38
39
|
"README.md",
|
|
@@ -49,12 +50,12 @@
|
|
|
49
50
|
"./dist/index.js"
|
|
50
51
|
],
|
|
51
52
|
"compat": {
|
|
52
|
-
"pluginApi": ">=2026.
|
|
53
|
-
"minGatewayVersion": ">=2026.
|
|
53
|
+
"pluginApi": ">=2026.7.1",
|
|
54
|
+
"minGatewayVersion": ">=2026.7.1"
|
|
54
55
|
},
|
|
55
56
|
"build": {
|
|
56
|
-
"openclawVersion": "2026.
|
|
57
|
-
"pluginSdkVersion": "2026.
|
|
57
|
+
"openclawVersion": "2026.7.1",
|
|
58
|
+
"pluginSdkVersion": "2026.7.1"
|
|
58
59
|
},
|
|
59
60
|
"hostTargets": [
|
|
60
61
|
"darwin-arm64",
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
"npmSpec": "sil-openclaw",
|
|
74
75
|
"localPath": "./",
|
|
75
76
|
"defaultChoice": "npm",
|
|
76
|
-
"minHostVersion": ">=2026.
|
|
77
|
+
"minHostVersion": ">=2026.7.1"
|
|
77
78
|
}
|
|
78
79
|
},
|
|
79
80
|
"scripts": {
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* This is Change 3 of the onboarding-ux plan — it collapses the nine-step,
|
|
6
6
|
* agent-driven host-CLI choreography (`agent_creation_engine.md`) into ONE shipped
|
|
7
7
|
* package `bin`, a sibling of `scripts/allowlist-openclaw.mjs`. Like that bin it is
|
|
8
|
-
* a standalone operator script — NOT the plugin process —
|
|
9
|
-
*
|
|
10
|
-
* legitimately drives `openclaw …` via `execFileSync`.
|
|
8
|
+
* a standalone operator script — NOT the plugin process — that drives the host
|
|
9
|
+
* `openclaw` CLI via `execFileSync`.
|
|
11
10
|
*
|
|
12
11
|
* It runs POST-endorsement: the interview (`agent_creation_engine.md` Part 1) owns the
|
|
13
12
|
* consent gate; this bin executes an already-assembled, already-endorsed spec
|
package/sil-shopping/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sil-shopping
|
|
3
|
-
description: 'Use
|
|
3
|
+
description: 'Use when the user explicitly asks to shop with sil or manage their sil shopper: register or check their sil account, search the sil catalog or re-check products by id, set up their one shopper (a two-touchpoint, endorsement-gated onboarding), view or forget what it has learned (domains/PRDs), or — running as that shopper — execute the six-beat Spec-Driven Shopping loop and record a fact or taste it surfaced. Drives sil_register, sil_whoami, sil_search, sil_product_get, sil_specs, sil_profile_materialize, sil_profile_search, sil_profile_get, sil_profile_remove, sil_learn, sil_doctor.'
|
|
4
4
|
metadata:
|
|
5
5
|
openclaw:
|
|
6
6
|
emoji: "\U0001F6D2"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agent-creation-engine
|
|
3
|
-
description: Create the single sil-wired shopper end to end — the two-touchpoint onboarding interview (persona + shared user-spec seed, endorsement-gated) then the one-command engine that persists it. Load when the user asks to set up
|
|
3
|
+
description: Create the single sil-wired shopper end to end — the two-touchpoint onboarding interview (persona + shared user-spec seed, endorsement-gated) then the one-command engine that persists it. Load when the user asks to create or set up their sil shopper.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Create the shopper
|
|
@@ -172,10 +172,6 @@ to mint/refresh domains; if defaults grant none, the bin reports `created` with
|
|
|
172
172
|
mode the pinned `alpine/openclaw:2026.6.9` accepts):
|
|
173
173
|
`agents.list[<idx>].skills` ← `["sil-shopping"]`; `plugins.entries.sil.enabled` ←
|
|
174
174
|
`true`. **No per-agent `tools.deny`** — the shopper inherits the host default toolset.
|
|
175
|
-
An fs-mutator deny is inert while codex's own shell (surfaced as `bash`) stays open by
|
|
176
|
-
design: it reads the shopper's skill files and can write regardless. The shell stays
|
|
177
|
-
open (trusted single-operator posture); persistence is steered through the sil tools by
|
|
178
|
-
the skill, not enforced by tool policy.
|
|
179
175
|
8. **Admit sil (plugin trust)** — the shipped **`scripts/allowlist-openclaw.mjs`** helper
|
|
180
176
|
(which the script runs itself, by absolute path via `node` — never the bare name)
|
|
181
177
|
additively merges the three trust surfaces (`plugins.allow` + `tools.alsoAllow` +
|
|
@@ -203,7 +199,8 @@ carrying the **explore-first** mantra, the loop in three lines, and the one dist
|
|
|
203
199
|
that matters: the shopper **mints an unlearned niche first** (a `sil_profile_search`
|
|
204
200
|
MISS → `sil_learn create`, then search); **the sil catalog is where you buy, the open
|
|
205
201
|
web is where you learn** (web only researches a niche's buying guide, never sources a
|
|
206
|
-
pick); **
|
|
202
|
+
pick); and its **shopping memory is the sil store** — it records what it learns through
|
|
203
|
+
`sil_learn` / `sil_profile_*`.
|
|
207
204
|
|
|
208
205
|
### Status taxonomy
|
|
209
206
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: fill-and-feedback
|
|
3
|
-
description: Beat 3
|
|
3
|
+
description: Beats 3 and 6 of the sil shopping loop. Beat 3 fills the PRD by precedence (multi-turn, authors the Search specs block, hard-constraint dual-enforce, the persistence split); Beat 6 is the reaction half (capture-gate, confirm-before-write, route-by-scope). Covers sil_learn, the one target+change write verb (create | write | attach-asset). Load within an active sil shopping loop.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Beat 3 (Fill) and Beat 6 (Feedback) — via `sil_learn`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: setup-onboarding
|
|
3
|
-
description: The one-time setup script the router defers to — the five-stage onboarding progression, the after-register shopper offer, and the per-search pitch.
|
|
3
|
+
description: The one-time setup script the router defers to when state shows sil setup is incomplete (no shopper, or a shopper with no domains) — the five-stage onboarding progression, the after-register shopper offer, and the per-search pitch. Sheds once setup is complete.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Setting up the shopper — the staged onboarding
|
package/scripts/changelog.mjs
DELETED
|
Binary file
|
package/scripts/release.mjs
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Build, pack, and publish to npm and ClawHub.
|
|
4
|
-
*
|
|
5
|
-
* The two registries publish under DIFFERENT names, by hard constraint:
|
|
6
|
-
* - npm: `sil-openclaw` (unscoped — the bare `sil` is taken upstream)
|
|
7
|
-
* - ClawHub: `@4gpts/sil` (the plugin id `sil` cannot be claimed on its own;
|
|
8
|
-
* it is already owned by the @4gpts/sil package, so ClawHub publishes
|
|
9
|
-
* under the scoped @<owner>/<plugin-id> name. The runtime plugin id
|
|
10
|
-
* stays `sil`, but install uses the scoped name `openclaw plugins install clawhub:@4gpts/sil`.)
|
|
11
|
-
*
|
|
12
|
-
* One clean build, then the SAME file content to both registries: npm gets the
|
|
13
|
-
* packed `sil-openclaw` tarball as-is; ClawHub gets those identical files
|
|
14
|
-
* re-packed with only package.json#name rewritten to `@4gpts/sil` (ClawHub
|
|
15
|
-
* requires --name to equal the tarball's package.json#name). Same content, the
|
|
16
|
-
* name field is the only difference — no drift in what the two registries serve.
|
|
17
|
-
*
|
|
18
|
-
* Usage:
|
|
19
|
-
* pnpm release publish for real (npm + ClawHub)
|
|
20
|
-
* pnpm release:dry dry-run both: build + pack + preview, upload NOTHING
|
|
21
|
-
*
|
|
22
|
-
* Real-publish preflight (skipped under --dry-run, which is a pure preview):
|
|
23
|
-
* - clean git working tree
|
|
24
|
-
* - HEAD carries the v<version> tag (run `pnpm version <bump>` first)
|
|
25
|
-
* - `npm whoami` succeeds (run `npm login`)
|
|
26
|
-
* - `clawhub` CLI on PATH (npm i -g clawhub && clawhub login)
|
|
27
|
-
*
|
|
28
|
-
* ClawHub attribution: --family code-plugin, --owner (env CLAWHUB_OWNER,
|
|
29
|
-
* default below), --source-repo (derived from package.json#repository),
|
|
30
|
-
* --source-commit HEAD, and --tags latest on a real publish.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
import { execFileSync } from "node:child_process";
|
|
34
|
-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
35
|
-
import { tmpdir } from "node:os";
|
|
36
|
-
import { resolve, dirname, basename } from "node:path";
|
|
37
|
-
import { fileURLToPath } from "node:url";
|
|
38
|
-
|
|
39
|
-
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
40
|
-
const DRY_RUN = process.argv.includes("--dry-run");
|
|
41
|
-
// The 4gpts ClawHub org we publish under (mirrors the @4gpts npm scope). You
|
|
42
|
-
// authenticate as an org member via `clawhub login`; override with CLAWHUB_OWNER.
|
|
43
|
-
const DEFAULT_CLAWHUB_OWNER = "4gpts";
|
|
44
|
-
const CLAWHUB_OWNER = process.env.CLAWHUB_OWNER || DEFAULT_CLAWHUB_OWNER;
|
|
45
|
-
const CLAWHUB_FAMILY = "code-plugin";
|
|
46
|
-
|
|
47
|
-
const pkg = JSON.parse(readFileSync(resolve(ROOT, "package.json"), "utf8"));
|
|
48
|
-
const version = pkg.version;
|
|
49
|
-
const tag = `v${version}`;
|
|
50
|
-
|
|
51
|
-
// ClawHub package name: the SCOPED @<owner>/<plugin-id> identity (e.g. @4gpts/sil).
|
|
52
|
-
// The bare plugin id (`sil`, openclaw.plugin.json#id) cannot be a package name on
|
|
53
|
-
// its own — it is already claimed by the @4gpts/sil package — so the scoped name is
|
|
54
|
-
// the ClawHub identity, while the runtime plugin id stays `sil`. Derived from owner
|
|
55
|
-
// + id so it never drifts from the manifest.
|
|
56
|
-
const CLAWHUB_PLUGIN_ID = JSON.parse(
|
|
57
|
-
readFileSync(resolve(ROOT, "openclaw.plugin.json"), "utf8"),
|
|
58
|
-
).id;
|
|
59
|
-
const CLAWHUB_NAME = `@${CLAWHUB_OWNER}/${CLAWHUB_PLUGIN_ID}`;
|
|
60
|
-
|
|
61
|
-
const log = (msg) => console.log(`[release] ${msg}`);
|
|
62
|
-
function fail(msg) {
|
|
63
|
-
console.error(`[release] ${msg}`);
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Run a command, inheriting stdio (output streams to the terminal). */
|
|
68
|
-
function runInherit(cmd, args) {
|
|
69
|
-
execFileSync(cmd, args, { cwd: ROOT, stdio: "inherit" });
|
|
70
|
-
}
|
|
71
|
-
/** Run a command and capture trimmed stdout. */
|
|
72
|
-
function capture(cmd, args) {
|
|
73
|
-
return execFileSync(cmd, args, { cwd: ROOT, encoding: "utf8" }).trim();
|
|
74
|
-
}
|
|
75
|
-
/** Capture stdout, or null on any non-zero exit / spawn failure. */
|
|
76
|
-
function tryCapture(cmd, args) {
|
|
77
|
-
try {
|
|
78
|
-
return capture(cmd, args);
|
|
79
|
-
} catch {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/** True if `cmd` is resolvable on PATH (a non-zero exit still means present). */
|
|
84
|
-
function commandExists(cmd) {
|
|
85
|
-
try {
|
|
86
|
-
execFileSync(cmd, ["--version"], { stdio: "ignore" });
|
|
87
|
-
return true;
|
|
88
|
-
} catch (err) {
|
|
89
|
-
return err.code !== "ENOENT";
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** Derive "Owner/Repo" for ClawHub --source-repo from package.json#repository.url. */
|
|
94
|
-
function sourceRepo() {
|
|
95
|
-
const url = pkg.repository?.url ?? "";
|
|
96
|
-
const m = url.match(/github\.com[/:]([^/]+\/[^/]+?)(?:\.git)?$/);
|
|
97
|
-
if (!m) fail(`cannot derive --source-repo from package.json#repository.url: "${url}"`);
|
|
98
|
-
return m[1];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function preflight() {
|
|
102
|
-
if (!pkg.name) fail("package.json#name is missing — cannot publish.");
|
|
103
|
-
if (DRY_RUN) {
|
|
104
|
-
log("dry-run: skipping clean-tree / tag / auth preflight (pure preview).");
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const dirty = capture("git", ["status", "--porcelain"]);
|
|
108
|
-
if (dirty) fail(`working tree is dirty — commit or stash first:\n${dirty}`);
|
|
109
|
-
|
|
110
|
-
const headTags = (tryCapture("git", ["tag", "--points-at", "HEAD"]) ?? "").split("\n");
|
|
111
|
-
if (!headTags.includes(tag)) {
|
|
112
|
-
fail(`HEAD is not tagged ${tag}. Run \`pnpm version <patch|minor|major>\` first.`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const npmUser = tryCapture("npm", ["whoami"]);
|
|
116
|
-
if (!npmUser) fail("not authenticated with npm. Run `npm login`.");
|
|
117
|
-
log(`npm user: ${npmUser}`);
|
|
118
|
-
|
|
119
|
-
if (!commandExists("clawhub")) {
|
|
120
|
-
fail("clawhub CLI not found on PATH. Run `npm i -g clawhub && clawhub login`.");
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/** Clean-build dist, then pack a single tarball. Returns its absolute path. */
|
|
125
|
-
function buildAndPack() {
|
|
126
|
-
log("building (clean dist → tsc)…");
|
|
127
|
-
runInherit("pnpm", ["build"]);
|
|
128
|
-
log("packing tarball…");
|
|
129
|
-
// --ignore-scripts: dist is already fresh from the explicit build above, so
|
|
130
|
-
// skip prepack here and keep `npm pack --json` stdout pure JSON.
|
|
131
|
-
const out = capture("npm", ["pack", "--json", "--ignore-scripts"]);
|
|
132
|
-
const filename = JSON.parse(out)?.[0]?.filename;
|
|
133
|
-
if (!filename) fail("`npm pack --json` did not report a tarball filename.");
|
|
134
|
-
return resolve(ROOT, filename);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function publishNpm(tarball) {
|
|
138
|
-
const args = ["publish", tarball];
|
|
139
|
-
if (DRY_RUN) args.push("--dry-run");
|
|
140
|
-
log(`npm publish${DRY_RUN ? " --dry-run" : ""} ${basename(tarball)}`);
|
|
141
|
-
runInherit("npm", args);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Re-pack the just-built npm tarball under the ClawHub name. ClawHub requires
|
|
146
|
-
* --name to EQUAL the tarball's package.json#name, and the npm tarball carries
|
|
147
|
-
* `sil-openclaw` — so extract it, rewrite ONLY package.json#name to CLAWHUB_NAME
|
|
148
|
-
* (@4gpts/sil), and `npm pack` the renamed package. The content is identical to
|
|
149
|
-
* npm's (same extracted files); only the name field changes. Returns the staged
|
|
150
|
-
* tarball path — its parent temp dir is the caller's to remove.
|
|
151
|
-
*/
|
|
152
|
-
function packClawhubTarball(npmTarball) {
|
|
153
|
-
const stage = mkdtempSync(resolve(tmpdir(), "sil-clawhub-"));
|
|
154
|
-
// Extract the already-built npm tarball (→ <stage>/package/...) so the ClawHub
|
|
155
|
-
// artifact ships the exact same files, not a separate build.
|
|
156
|
-
runInherit("tar", ["-xzf", npmTarball, "-C", stage]);
|
|
157
|
-
const pkgPath = resolve(stage, "package", "package.json");
|
|
158
|
-
const staged = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
159
|
-
staged.name = CLAWHUB_NAME;
|
|
160
|
-
writeFileSync(pkgPath, `${JSON.stringify(staged, null, 2)}\n`, "utf8");
|
|
161
|
-
// Re-pack the renamed package dir into the same temp dir. --ignore-scripts: no
|
|
162
|
-
// prepack rebuild (the dist is already inside the extracted package).
|
|
163
|
-
const out = capture("npm", [
|
|
164
|
-
"pack",
|
|
165
|
-
resolve(stage, "package"),
|
|
166
|
-
"--json",
|
|
167
|
-
"--ignore-scripts",
|
|
168
|
-
"--pack-destination",
|
|
169
|
-
stage,
|
|
170
|
-
]);
|
|
171
|
-
const filename = JSON.parse(out)?.[0]?.filename;
|
|
172
|
-
if (!filename) fail("clawhub stage: `npm pack --json` did not report a tarball filename.");
|
|
173
|
-
return resolve(stage, filename);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function publishClawhub(npmTarball) {
|
|
177
|
-
const sha = capture("git", ["rev-parse", "HEAD"]);
|
|
178
|
-
// The release notes for this version, straight from CHANGELOG.md (empty if the
|
|
179
|
-
// version has no section yet — then we just omit --changelog).
|
|
180
|
-
const changelog = (tryCapture("node", ["scripts/changelog.mjs", "show", version]) ?? "").trim();
|
|
181
|
-
// Stage the @4gpts/sil-named tarball (ClawHub requires --name == package name).
|
|
182
|
-
const tarball = packClawhubTarball(npmTarball);
|
|
183
|
-
try {
|
|
184
|
-
const args = [
|
|
185
|
-
"package",
|
|
186
|
-
"publish",
|
|
187
|
-
tarball,
|
|
188
|
-
"--family",
|
|
189
|
-
CLAWHUB_FAMILY,
|
|
190
|
-
"--name",
|
|
191
|
-
CLAWHUB_NAME,
|
|
192
|
-
"--owner",
|
|
193
|
-
CLAWHUB_OWNER,
|
|
194
|
-
"--source-repo",
|
|
195
|
-
sourceRepo(),
|
|
196
|
-
"--source-commit",
|
|
197
|
-
sha,
|
|
198
|
-
];
|
|
199
|
-
if (changelog) args.push("--changelog", changelog);
|
|
200
|
-
if (DRY_RUN) args.push("--dry-run");
|
|
201
|
-
else args.push("--tags", "latest");
|
|
202
|
-
log(
|
|
203
|
-
`clawhub package publish${DRY_RUN ? " --dry-run" : ""} (name=${CLAWHUB_NAME}, owner=${CLAWHUB_OWNER}, ` +
|
|
204
|
-
`repo=${sourceRepo()}, changelog=${changelog ? "yes" : "none"})`,
|
|
205
|
-
);
|
|
206
|
-
runInherit("clawhub", args);
|
|
207
|
-
} finally {
|
|
208
|
-
rmSync(dirname(tarball), { recursive: true, force: true });
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
log(`${DRY_RUN ? "DRY-RUN " : ""}release ${pkg.name}@${version} (npm) + ${CLAWHUB_NAME}@${version} (ClawHub)`);
|
|
213
|
-
preflight();
|
|
214
|
-
const tarball = buildAndPack();
|
|
215
|
-
try {
|
|
216
|
-
publishNpm(tarball);
|
|
217
|
-
publishClawhub(tarball);
|
|
218
|
-
} finally {
|
|
219
|
-
rmSync(tarball, { force: true });
|
|
220
|
-
}
|
|
221
|
-
log(
|
|
222
|
-
DRY_RUN
|
|
223
|
-
? "dry-run complete — nothing was uploaded."
|
|
224
|
-
: `published ${pkg.name}@${version} (npm) + ${CLAWHUB_NAME}@${version} (ClawHub).`,
|
|
225
|
-
);
|
|
226
|
-
if (!DRY_RUN) {
|
|
227
|
-
log(`next: \`clawhub package readiness ${CLAWHUB_NAME}\` to check ClawHub readiness blockers.`);
|
|
228
|
-
}
|
package/scripts/sync-version.mjs
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Mirror the single source-of-truth version (package.json#version) into
|
|
4
|
-
* openclaw.plugin.json#version so the two never drift.
|
|
5
|
-
*
|
|
6
|
-
* package.json#version is authoritative — `pnpm version <bump>` bumps it,
|
|
7
|
-
* and this script copies it into the OpenClaw manifest. Wired into the
|
|
8
|
-
* `version` lifecycle (runs inside `pnpm version`, staged into the version
|
|
9
|
-
* commit) and re-runnable standalone (`pnpm sync-version`).
|
|
10
|
-
*
|
|
11
|
-
* Edits only the manifest's `version` string in place — all other bytes
|
|
12
|
-
* and formatting are preserved, so the diff is one line. Idempotent (a
|
|
13
|
-
* no-op when already in sync) and fail-fast on a non-semver version. The
|
|
14
|
-
* version-parity integration test is the guard that keeps this honest.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
18
|
-
import { resolve, dirname } from "node:path";
|
|
19
|
-
import { fileURLToPath } from "node:url";
|
|
20
|
-
|
|
21
|
-
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
22
|
-
const PKG_PATH = resolve(ROOT, "package.json");
|
|
23
|
-
const MANIFEST_PATH = resolve(ROOT, "openclaw.plugin.json");
|
|
24
|
-
|
|
25
|
-
const SEMVER = /^\d+\.\d+\.\d+(?:-[\w.]+)?$/;
|
|
26
|
-
|
|
27
|
-
const version = JSON.parse(readFileSync(PKG_PATH, "utf8")).version;
|
|
28
|
-
if (typeof version !== "string" || !SEMVER.test(version)) {
|
|
29
|
-
console.error(`[sync-version] refusing to sync non-semver version: ${version}`);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const before = readFileSync(MANIFEST_PATH, "utf8");
|
|
34
|
-
if (JSON.parse(before).version === version) {
|
|
35
|
-
console.log(`[sync-version] openclaw.plugin.json already at ${version}; no change.`);
|
|
36
|
-
process.exit(0);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Replace only the first `"version": "..."` — the top-level manifest field
|
|
40
|
-
// (it precedes every nested object in the file). The re-parse below proves
|
|
41
|
-
// the edit landed on the right key.
|
|
42
|
-
const after = before.replace(/("version"\s*:\s*)"[^"]*"/, `$1"${version}"`);
|
|
43
|
-
const reparsed = JSON.parse(after);
|
|
44
|
-
if (reparsed.version !== version) {
|
|
45
|
-
console.error(
|
|
46
|
-
`[sync-version] post-edit manifest version is ${reparsed.version}, expected ${version} — aborting.`,
|
|
47
|
-
);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
writeFileSync(MANIFEST_PATH, after, "utf8");
|
|
52
|
-
console.log(`[sync-version] openclaw.plugin.json → ${version}`);
|