sil-openclaw 0.3.3 → 0.3.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 +26 -0
- package/README.md +1 -1
- package/dist/index.js +38 -6
- package/dist/lib/credentials.js +31 -8
- package/dist/lib/openclaw-allowlist.js +156 -0
- package/dist/lib/profile-store.js +10 -4
- package/dist/tools/profile.js +1 -1
- package/openclaw.plugin.json +3 -3
- package/package.json +8 -3
- package/scripts/allowlist-openclaw.mjs +226 -0
- package/scripts/changelog.mjs +0 -0
- package/scripts/release.mjs +228 -0
- package/scripts/sync-version.mjs +52 -0
- package/{skill → sil-shopping}/SKILL.md +3 -3
- /package/{skill → sil-shopping}/examples/road_cycling_expert_walkthrough.md +0 -0
- /package/{skill → sil-shopping}/references/agent_creation_engine.md +0 -0
- /package/{skill → sil-shopping}/references/brainstorm_interview.md +0 -0
- /package/{skill → sil-shopping}/references/catalog_tools_reference.md +0 -0
- /package/{skill → sil-shopping}/references/expert_shopping.md +0 -0
- /package/{skill → sil-shopping}/references/manage_experts.md +0 -0
- /package/{skill → sil-shopping}/references/refine_expert.md +0 -0
- /package/{skill → sil-shopping}/references/search_param_mapping.md +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,32 @@ release (`clawhub package publish --changelog`). See [README](./README.md#releas
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [0.3.5] - 2026-06-27
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- **Catalog description rewritten to "Turn your OpenClaw into an expert shopping
|
|
18
|
+
agent."** — the same line now in both `package.json#description` and
|
|
19
|
+
`openclaw.plugin.json#description`. ClawHub crops the catalog card at 10 words, and
|
|
20
|
+
the old opener ("OpenClaw plugin for sil — …") spent those words on what the listing
|
|
21
|
+
already shows (the package is `@4gpts/sil`). The new line is benefit-led and names the
|
|
22
|
+
shopping-expert headline feature within the visible crop.
|
|
23
|
+
|
|
24
|
+
## [0.3.4] - 2026-06-25
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Bundled skill now publishes under the unique basename `sil-shopping/`** (was the
|
|
29
|
+
generic `skill/`). The OpenClaw host derives a skill's published name from its
|
|
30
|
+
directory basename, so the old `skill/` collided with klodi's identically-named
|
|
31
|
+
`skill/` when both plugins were co-installed — the host logged a
|
|
32
|
+
`"skill" resolves to both` collision warning and silently dropped sil's skill
|
|
33
|
+
(only the first basename wins), leaving the model with no skill to drive the
|
|
34
|
+
`sil_*` tools. Renaming the directory to `sil-shopping/` makes the published name
|
|
35
|
+
sil-unique and collision-free. The skill's frontmatter `name` is realigned to
|
|
36
|
+
`sil-shopping` and its `description` sharpened so the model reliably routes every
|
|
37
|
+
shopping / identity / shopping-expert intent to it.
|
|
38
|
+
|
|
13
39
|
## [0.3.3] - 2026-06-25
|
|
14
40
|
|
|
15
41
|
### Fixed
|
package/README.md
CHANGED
|
@@ -183,7 +183,7 @@ Namespaced `sil_*` so they never collide with other plugins. Your agent calls th
|
|
|
183
183
|
|
|
184
184
|
## Skills
|
|
185
185
|
|
|
186
|
-
The plugin ships one bundled skill — **`sil`** 🛒 — that your agent loads automatically the first time you express a shopping intent. You don't invoke it; it's the playbook that makes the tools work well together:
|
|
186
|
+
The plugin ships one bundled skill — **`sil-shopping`** 🛒 — that your agent loads automatically the first time you express a shopping intent. You don't invoke it; it's the playbook that makes the tools work well together:
|
|
187
187
|
|
|
188
188
|
- **Routes intent to the right tool.** *"find me a keyboard"* → `sil_search`, *"look these up"* → `sil_product_get`, *"who am I?"* → `sil_whoami`, *"sign me up"* → `sil_register`, *"make me an expert for X"* → the create flow, *"list / show / remove my experts"* → the `sil_profile_*` tools.
|
|
189
189
|
- **Interviews lightly, then researches deeply.** Asked for a shopping expert, it runs a light interview (≤10 questions) to shape the niche and persona *with* you, then researches the niche itself and derives how to decompose every request — and creates nothing until you explicitly endorse the assembled draft.
|
package/dist/index.js
CHANGED
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
* time — `register()` is strictly synchronous and opens nothing.
|
|
9
9
|
*
|
|
10
10
|
* `register()` MUST stay synchronous and side-effect-free beyond
|
|
11
|
-
* registering tools and logging. The reference
|
|
12
|
-
* (`klodi-plugin/adapters/openclaw`) carries a smoke gate
|
|
13
|
-
* because an eager connection opened in `register()` once held
|
|
14
|
-
* install subprocess event loop open and blocked gateway
|
|
15
|
-
* that way: all I/O lives inside a tool's `execute()` —
|
|
16
|
-
* sockets, no unawaited promises here.
|
|
11
|
+
* registering tools, ensuring the data dir, and logging. The reference
|
|
12
|
+
* adapter (`klodi-plugin/adapters/openclaw`) carries a smoke gate
|
|
13
|
+
* precisely because an eager connection opened in `register()` once held
|
|
14
|
+
* the host's install subprocess event loop open and blocked gateway
|
|
15
|
+
* startup. Keep it that way: all I/O lives inside a tool's `execute()` —
|
|
16
|
+
* no timers, no sockets, no unawaited promises here. The one synchronous
|
|
17
|
+
* `mkdirSync` (via `ensureDataDir()`) is exempt: it returns immediately
|
|
18
|
+
* and holds no resource open.
|
|
17
19
|
*
|
|
18
20
|
* To add a tool, see `src/tools/identity.ts` (the reference group — it
|
|
19
21
|
* sets the `jsonResult` success shape and structured-error envelope every
|
|
@@ -21,6 +23,7 @@
|
|
|
21
23
|
*/
|
|
22
24
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
23
25
|
import { applyPluginConfigOverrides, getWebUrl, getWebUrlSource, getApiUrl, getApiUrlSource, } from "./lib/config.js";
|
|
26
|
+
import { ensureDataDir, getDataDir } from "./lib/credentials.js";
|
|
24
27
|
import { registerCatalogTools } from "./tools/catalog.js";
|
|
25
28
|
import { registerIdentityTools } from "./tools/identity.js";
|
|
26
29
|
import { registerProfileTools } from "./tools/profile.js";
|
|
@@ -31,11 +34,40 @@ export default definePluginEntry({
|
|
|
31
34
|
+ " and search and look up products in the sil catalog.",
|
|
32
35
|
register(api) {
|
|
33
36
|
applyPluginConfigOverrides(api.pluginConfig);
|
|
37
|
+
// Guarantee the data home exists from the instant register() returns — not
|
|
38
|
+
// lazily on first write — so tokens, config, and SDS profile artefacts have
|
|
39
|
+
// one consistent home from load. One-shot synchronous mkdir (recursive,
|
|
40
|
+
// 0700): it returns immediately and holds no resource open, so the
|
|
41
|
+
// register()-stays-synchronous / opens-nothing invariant is preserved.
|
|
42
|
+
//
|
|
43
|
+
// Fail-closed: an uncreatable home (parent unwritable, path occupied by a
|
|
44
|
+
// file → ENOTDIR, no space) is logged LOUDLY and DISTINCTLY (the path + OS
|
|
45
|
+
// cause, no token/PII) then RETHROWN — the host rejects a plugin whose
|
|
46
|
+
// register() throws, which is the correct outcome for an unusable data home.
|
|
47
|
+
// A guaranteed home that silently isn't there is the exact failure this
|
|
48
|
+
// guard exists to kill; we do NOT swallow it or fall back to another dir.
|
|
49
|
+
let dataDir;
|
|
50
|
+
try {
|
|
51
|
+
dataDir = ensureDataDir();
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
const cause = err instanceof Error ? err.message : String(err);
|
|
55
|
+
api.logger.error("sil_plugin_data_dir_failed", {
|
|
56
|
+
message: "sil could NOT create its data directory at registration, so tokens,"
|
|
57
|
+
+ " config, and profiles have no home. Fix the data directory (it must"
|
|
58
|
+
+ " be writable — check permissions / free space / that $SIL_DATA_DIR"
|
|
59
|
+
+ " is a directory), then reload the plugin.",
|
|
60
|
+
data_dir: getDataDir(),
|
|
61
|
+
cause,
|
|
62
|
+
});
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
34
65
|
registerIdentityTools(api);
|
|
35
66
|
registerCatalogTools(api);
|
|
36
67
|
registerProfileTools(api);
|
|
37
68
|
api.logger.info("sil_plugin_loaded", {
|
|
38
69
|
message: "sil plugin registered.",
|
|
70
|
+
data_dir: dataDir,
|
|
39
71
|
api_url: getWebUrl(),
|
|
40
72
|
api_url_source: getWebUrlSource(),
|
|
41
73
|
sil_api_url: getApiUrl(),
|
package/dist/lib/credentials.js
CHANGED
|
@@ -26,12 +26,15 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
28
28
|
import { homedir } from "node:os";
|
|
29
|
-
import {
|
|
29
|
+
import { join } from "node:path";
|
|
30
30
|
import { randomBytes } from "node:crypto";
|
|
31
31
|
/** Owner read/write only. The bearer pair must never be group/world-readable. */
|
|
32
32
|
const FILE_MODE = 0o600;
|
|
33
|
-
/** Owner read/write/execute only on the data dir itself.
|
|
34
|
-
|
|
33
|
+
/** Owner read/write/execute only on the data dir itself. Exported so the one
|
|
34
|
+
* other writer of a `$SIL_DATA_DIR` sub-tree (`profile-store.ts`, the SDS
|
|
35
|
+
* artefact store) shares this single source of truth for the data-home mode
|
|
36
|
+
* rather than duplicating the literal. */
|
|
37
|
+
export const DIR_MODE = 0o700;
|
|
35
38
|
const TOKENS_FILE = "tokens.json";
|
|
36
39
|
const CONFIG_FILE = "config.json";
|
|
37
40
|
/**
|
|
@@ -48,6 +51,23 @@ export function getDataDir() {
|
|
|
48
51
|
return join(xdg, "sil");
|
|
49
52
|
return join(homedir(), ".local", "share", "sil");
|
|
50
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Create the resolved data dir (`0700`) if absent and return its path. The SOLE
|
|
56
|
+
* creator of the data dir — `register()` calls it at load (so the home exists
|
|
57
|
+
* from the moment the plugin registers, not lazily on first write), and the
|
|
58
|
+
* write paths call it before every write, which doubles as the guard against the
|
|
59
|
+
* dir being deleted out from under a running session.
|
|
60
|
+
*
|
|
61
|
+
* Idempotent: `mkdirSync(..., { recursive: true })` is a clean no-op when the dir
|
|
62
|
+
* already exists, never re-permissioning or disturbing existing contents. Throws
|
|
63
|
+
* the raw fs error (ENOTDIR/EACCES/ENOSPC…) on a genuinely uncreatable path —
|
|
64
|
+
* callers surface it (fail-closed), never swallow it.
|
|
65
|
+
*/
|
|
66
|
+
export function ensureDataDir() {
|
|
67
|
+
const dir = getDataDir();
|
|
68
|
+
mkdirSync(dir, { recursive: true, mode: DIR_MODE });
|
|
69
|
+
return dir;
|
|
70
|
+
}
|
|
51
71
|
export function getTokensPath() {
|
|
52
72
|
return join(getDataDir(), TOKENS_FILE);
|
|
53
73
|
}
|
|
@@ -114,13 +134,16 @@ export function clearTokens() {
|
|
|
114
134
|
* The temp file is created `0600` and the final file is re-`chmod`'d to `0600`
|
|
115
135
|
* in case the rename inherited a different mode on some filesystems.
|
|
116
136
|
*
|
|
117
|
-
*
|
|
118
|
-
* a non-error
|
|
119
|
-
*
|
|
137
|
+
* Ensuring the data dir first (recursive, `0700`, via `ensureDataDir()`) makes
|
|
138
|
+
* first-run on a clean machine a non-error AND re-heals the home if it was
|
|
139
|
+
* deleted out from under a running session before this write. The token/config
|
|
140
|
+
* paths are always direct children of `getDataDir()`, so the dir ensured here is
|
|
141
|
+
* exactly the one the write lands in. The temp name carries random bytes so two
|
|
142
|
+
* concurrent writers (a pathological double-register sharing a data dir) don't
|
|
143
|
+
* collide on the temp.
|
|
120
144
|
*/
|
|
121
145
|
function writeJsonAtomic(path, data) {
|
|
122
|
-
|
|
123
|
-
mkdirSync(dir, { recursive: true, mode: DIR_MODE });
|
|
146
|
+
ensureDataDir();
|
|
124
147
|
const tmp = `${path}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
|
|
125
148
|
writeFileSync(tmp, JSON.stringify(data, null, 2), {
|
|
126
149
|
encoding: "utf-8",
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, typed merge core for trusting `sil` in a host OpenClaw config.
|
|
3
|
+
*
|
|
4
|
+
* On install OpenClaw discovers `sil` as a non-bundled plugin, but with an
|
|
5
|
+
* empty `plugins.allow` it warns that discovered plugins may auto-load
|
|
6
|
+
* unrestricted. This module computes the additive, idempotent edit that
|
|
7
|
+
* closes that warning by trusting `sil` at the THREE real allow surfaces of
|
|
8
|
+
* the `alpine/openclaw:2026.6.9` config schema:
|
|
9
|
+
*
|
|
10
|
+
* - `plugins.allow` string[] of plugin IDs — emptiness fires the warning
|
|
11
|
+
* - `tools.alsoAllow` string[] of plugin IDs — admits a plugin's tools by
|
|
12
|
+
* ID (NO per-tool-name key
|
|
13
|
+
* exists; this is how all of
|
|
14
|
+
* sil's tools become un-filtered)
|
|
15
|
+
* - `plugins.entries.sil` { enabled, config } — makes sil loadable/exposing
|
|
16
|
+
*
|
|
17
|
+
* There is no global skill allow-list — a skill attaches per-agent via
|
|
18
|
+
* `agents.list[i].skills`, which is the host-wiring path's job, NOT this
|
|
19
|
+
* helper's. `sil.tools` / `sil.skill` are carried in the facts type only for
|
|
20
|
+
* the operator log fields; the merge never enumerates tool names into config,
|
|
21
|
+
* because on 2026.6.9 the mechanism is plugin-ID admission.
|
|
22
|
+
*
|
|
23
|
+
* This module is pure (no I/O). The config arrives as `unknown` because the
|
|
24
|
+
* file is operator-editable and may be any shape; every read narrows with
|
|
25
|
+
* `typeof` / `Array.isArray` before use. A present-but-wrong-typed allow array
|
|
26
|
+
* is a hard error (we never coerce — that risks clobbering operator state).
|
|
27
|
+
*
|
|
28
|
+
* Invariants (the two the suite exists to defend):
|
|
29
|
+
* - ADDITIVE: a pre-existing entry is never removed, reordered, or
|
|
30
|
+
* overwritten — sil's IDs are only ever appended; an existing
|
|
31
|
+
* `plugins.entries.sil` is left untouched.
|
|
32
|
+
* - IDEMPOTENT: `changed` is computed from set membership, so a second run
|
|
33
|
+
* finds nothing missing and reports `changed: false` (the I/O shell then
|
|
34
|
+
* writes nothing).
|
|
35
|
+
*
|
|
36
|
+
* OQ3 — enabling the restriction must never silently un-trust a plugin the
|
|
37
|
+
* permissive empty-list default was auto-loading. So when `plugins.allow` is
|
|
38
|
+
* empty/absent, we seed it with every ID already recorded under
|
|
39
|
+
* `plugins.entries` (the host's own record of installed plugins) before
|
|
40
|
+
* appending `sil`. The seed IDs are read from the live config, never hardcoded.
|
|
41
|
+
*/
|
|
42
|
+
/** Thrown when the operator-editable config has a shape we refuse to coerce
|
|
43
|
+
* (a non-object root, or a present-but-non-array allow surface). The I/O shell
|
|
44
|
+
* maps this to the `sil_allowlist_merge_failed` outcome — fail closed, never
|
|
45
|
+
* silently overwrite operator state. */
|
|
46
|
+
export class AllowlistShapeError extends Error {
|
|
47
|
+
name = "AllowlistShapeError";
|
|
48
|
+
}
|
|
49
|
+
function isPlainObject(value) {
|
|
50
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
51
|
+
}
|
|
52
|
+
/** Append `id` to `arr` if absent. Returns true iff a mutation occurred —
|
|
53
|
+
* append-only, so order is preserved and pre-existing entries are byte-stable. */
|
|
54
|
+
function appendIfAbsent(arr, id) {
|
|
55
|
+
if (arr.includes(id))
|
|
56
|
+
return false;
|
|
57
|
+
arr.push(id);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Compute the additive, idempotent merge that trusts `sil` in the given config.
|
|
62
|
+
*
|
|
63
|
+
* Mutates a copy is NOT what we do — we mutate the passed object in place (the
|
|
64
|
+
* I/O shell parses fresh per run, so there is no aliasing hazard) and return it
|
|
65
|
+
* for ergonomics. All three merges happen in-memory before the shell does its
|
|
66
|
+
* single atomic write, so a crash mid-merge can never half-write the file.
|
|
67
|
+
*
|
|
68
|
+
* @throws AllowlistShapeError if `config` is not an object, or if any of
|
|
69
|
+
* `plugins.allow`, `tools.alsoAllow`, `plugins.entries` is present but the
|
|
70
|
+
* wrong type (non-array / non-object) — we refuse to coerce.
|
|
71
|
+
*/
|
|
72
|
+
export function mergeSilAllowlist(config, sil) {
|
|
73
|
+
if (!isPlainObject(config)) {
|
|
74
|
+
throw new AllowlistShapeError("OpenClaw config root must be a JSON object, got: "
|
|
75
|
+
+ (config === null ? "null" : Array.isArray(config) ? "array" : typeof config));
|
|
76
|
+
}
|
|
77
|
+
// --- Narrow / create the `plugins` container -------------------------------
|
|
78
|
+
if (config["plugins"] !== undefined && !isPlainObject(config["plugins"])) {
|
|
79
|
+
throw new AllowlistShapeError("config.plugins must be an object when present, got: " + typeof config["plugins"]);
|
|
80
|
+
}
|
|
81
|
+
if (config["plugins"] === undefined)
|
|
82
|
+
config["plugins"] = {};
|
|
83
|
+
const plugins = config["plugins"];
|
|
84
|
+
// --- Narrow / create the `tools` container ---------------------------------
|
|
85
|
+
if (config["tools"] !== undefined && !isPlainObject(config["tools"])) {
|
|
86
|
+
throw new AllowlistShapeError("config.tools must be an object when present, got: " + typeof config["tools"]);
|
|
87
|
+
}
|
|
88
|
+
if (config["tools"] === undefined)
|
|
89
|
+
config["tools"] = {};
|
|
90
|
+
const tools = config["tools"];
|
|
91
|
+
// --- Narrow `plugins.entries` (read-only for the OQ3 seed) -----------------
|
|
92
|
+
if (plugins["entries"] !== undefined && !isPlainObject(plugins["entries"])) {
|
|
93
|
+
throw new AllowlistShapeError("config.plugins.entries must be an object when present, got: "
|
|
94
|
+
+ typeof plugins["entries"]);
|
|
95
|
+
}
|
|
96
|
+
const entries = isPlainObject(plugins["entries"])
|
|
97
|
+
? plugins["entries"]
|
|
98
|
+
: undefined;
|
|
99
|
+
// --- 1. plugins.allow ------------------------------------------------------
|
|
100
|
+
// A present-but-non-array allow is a hard error: coercing it would silently
|
|
101
|
+
// discard whatever the operator put there.
|
|
102
|
+
if (plugins["allow"] !== undefined && !Array.isArray(plugins["allow"])) {
|
|
103
|
+
throw new AllowlistShapeError("config.plugins.allow must be an array when present, got: " + typeof plugins["allow"]);
|
|
104
|
+
}
|
|
105
|
+
// Every element must be a string — a mixed array is operator corruption we
|
|
106
|
+
// refuse to silently propagate.
|
|
107
|
+
const existingAllow = plugins["allow"];
|
|
108
|
+
if (existingAllow && existingAllow.some((x) => typeof x !== "string")) {
|
|
109
|
+
throw new AllowlistShapeError("config.plugins.allow must contain only strings");
|
|
110
|
+
}
|
|
111
|
+
let allowChanged = false;
|
|
112
|
+
if (!existingAllow || existingAllow.length === 0) {
|
|
113
|
+
// Empty/absent → flipping from permissive (auto-loads everything) to
|
|
114
|
+
// explicit (allow-list enforced) would un-trust every other installed
|
|
115
|
+
// plugin. Seed with sil + every ID the host already records under
|
|
116
|
+
// `plugins.entries`, so enabling the restriction never silently excludes a
|
|
117
|
+
// previously auto-loading plugin (OQ3). Seed IDs come from the live config.
|
|
118
|
+
const seed = [sil.id, ...(entries ? Object.keys(entries) : [])];
|
|
119
|
+
const deduped = [];
|
|
120
|
+
for (const id of seed)
|
|
121
|
+
appendIfAbsent(deduped, id);
|
|
122
|
+
plugins["allow"] = deduped;
|
|
123
|
+
allowChanged = true;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Non-empty → append sil only; the other trusted IDs stay, in order (AC5).
|
|
127
|
+
allowChanged = appendIfAbsent(existingAllow, sil.id);
|
|
128
|
+
}
|
|
129
|
+
// --- 2. tools.alsoAllow ----------------------------------------------------
|
|
130
|
+
if (tools["alsoAllow"] !== undefined && !Array.isArray(tools["alsoAllow"])) {
|
|
131
|
+
throw new AllowlistShapeError("config.tools.alsoAllow must be an array when present, got: "
|
|
132
|
+
+ typeof tools["alsoAllow"]);
|
|
133
|
+
}
|
|
134
|
+
const existingAlsoAllow = tools["alsoAllow"];
|
|
135
|
+
if (existingAlsoAllow && existingAlsoAllow.some((x) => typeof x !== "string")) {
|
|
136
|
+
throw new AllowlistShapeError("config.tools.alsoAllow must contain only strings");
|
|
137
|
+
}
|
|
138
|
+
if (existingAlsoAllow === undefined)
|
|
139
|
+
tools["alsoAllow"] = [];
|
|
140
|
+
const alsoAllowChanged = appendIfAbsent(tools["alsoAllow"], sil.id);
|
|
141
|
+
// --- 3. plugins.entries.<id> -----------------------------------------------
|
|
142
|
+
// Set the enable entry ONLY when absent — never overwrite an operator's
|
|
143
|
+
// existing `enabled`/`config` (AC4). Create the entries container if needed.
|
|
144
|
+
if (plugins["entries"] === undefined)
|
|
145
|
+
plugins["entries"] = {};
|
|
146
|
+
const entriesObj = plugins["entries"];
|
|
147
|
+
let entryChanged = false;
|
|
148
|
+
if (!(sil.id in entriesObj)) {
|
|
149
|
+
entriesObj[sil.id] = { enabled: true, config: {} };
|
|
150
|
+
entryChanged = true;
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
config: config,
|
|
154
|
+
changed: allowChanged || alsoAllowChanged || entryChanged,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* sil shopping-expert behaviour-artefact store.
|
|
3
3
|
*
|
|
4
|
-
* The agent-creation engine (the bundled `
|
|
4
|
+
* The agent-creation engine (the bundled `sil-shopping/SKILL.md` procedure driving
|
|
5
5
|
* the OpenClaw host CLI) registers the *wiring* of a new sil-wired agent into
|
|
6
6
|
* the host's own config — the `agents.list[]` entry, the enabled `sil` plugin,
|
|
7
7
|
* the attached `sil` skill. That host-config write is the host agent driving
|
|
@@ -67,10 +67,11 @@
|
|
|
67
67
|
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync, } from "node:fs";
|
|
68
68
|
import { dirname, join } from "node:path";
|
|
69
69
|
import { randomBytes } from "node:crypto";
|
|
70
|
-
import { getDataDir } from "./credentials.js";
|
|
71
|
-
/** Owner-only file
|
|
70
|
+
import { DIR_MODE, ensureDataDir, getDataDir } from "./credentials.js";
|
|
71
|
+
/** Owner-only file mode — the artefacts are user-scoped, like tokens. The dir
|
|
72
|
+
* mode (`DIR_MODE`, `0o700`) is owned by `credentials.ts` (the data-dir owner)
|
|
73
|
+
* and imported, so the data-home permission lives in exactly one place. */
|
|
72
74
|
const FILE_MODE = 0o600;
|
|
73
|
-
const DIR_MODE = 0o700;
|
|
74
75
|
/** The sub-tree under `$SIL_DATA_DIR` that holds per-agent behaviour artefacts. */
|
|
75
76
|
const AGENTS_SUBDIR = "agents";
|
|
76
77
|
/** Artefact filenames (stable — the sil skill resolves them from profile.json,
|
|
@@ -167,6 +168,11 @@ export function materializeProfile(spec) {
|
|
|
167
168
|
// destroying anything pre-existing).
|
|
168
169
|
const dirPreexisted = existsSync(dir);
|
|
169
170
|
try {
|
|
171
|
+
// Ensure the data home (`$SIL_DATA_DIR`, 0700) exists first — its creation
|
|
172
|
+
// and mode are owned by credentials.ts (the data-dir owner), and this also
|
|
173
|
+
// re-heals it if it was deleted mid-session. Then create the per-agent leaf
|
|
174
|
+
// (`agents/<id>`), which is profile-store's own concern.
|
|
175
|
+
ensureDataDir();
|
|
170
176
|
mkdirSync(dir, { recursive: true, mode: DIR_MODE });
|
|
171
177
|
atomicWrite(domainSpecPath, spec.domainSpec);
|
|
172
178
|
atomicWrite(intentSpecPath, spec.intentSpec);
|
package/dist/tools/profile.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* identity/voice is the host workspace `SOUL.md`, written directly via the host
|
|
11
11
|
* CLI. The *wiring* half — the host `agents.list[]` entry, the enabled `sil`
|
|
12
12
|
* plugin, the attached `sil` skill, the `SOUL.md` — is the host agent driving
|
|
13
|
-
* its own `openclaw …` CLI under the bundled `
|
|
13
|
+
* its own `openclaw …` CLI under the bundled `sil-shopping/SKILL.md` procedure; the
|
|
14
14
|
* plugin never writes `~/.openclaw` (`security.noChildProcess: true`, host
|
|
15
15
|
* config is outside `filesystemScope`).
|
|
16
16
|
*
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "sil",
|
|
3
3
|
"name": "sil",
|
|
4
|
-
"description": "
|
|
5
|
-
"version": "0.3.
|
|
6
|
-
"skills": ["./
|
|
4
|
+
"description": "Turn your OpenClaw into an expert shopping agent.",
|
|
5
|
+
"version": "0.3.5",
|
|
6
|
+
"skills": ["./sil-shopping"],
|
|
7
7
|
"activation": {
|
|
8
8
|
"onCapabilities": ["tool"]
|
|
9
9
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sil-openclaw",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.5",
|
|
4
|
+
"description": "Turn your OpenClaw into an expert shopping agent.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -26,9 +26,13 @@
|
|
|
26
26
|
"node": ">=22"
|
|
27
27
|
},
|
|
28
28
|
"main": "./dist/index.js",
|
|
29
|
+
"bin": {
|
|
30
|
+
"sil-openclaw-allowlist": "./scripts/allowlist-openclaw.mjs"
|
|
31
|
+
},
|
|
29
32
|
"files": [
|
|
30
33
|
"dist",
|
|
31
|
-
"
|
|
34
|
+
"scripts",
|
|
35
|
+
"sil-shopping",
|
|
32
36
|
"openclaw.plugin.json",
|
|
33
37
|
"README.md",
|
|
34
38
|
"CHANGELOG.md",
|
|
@@ -79,6 +83,7 @@
|
|
|
79
83
|
"test": "vitest run --passWithNoTests",
|
|
80
84
|
"test:watch": "vitest",
|
|
81
85
|
"sync-version": "node scripts/sync-version.mjs",
|
|
86
|
+
"openclaw:allowlist": "node scripts/allowlist-openclaw.mjs",
|
|
82
87
|
"preversion": "pnpm typecheck && pnpm test",
|
|
83
88
|
"version": "pnpm sync-version && node scripts/changelog.mjs cut && git add openclaw.plugin.json CHANGELOG.md",
|
|
84
89
|
"postversion": "git push --follow-tags",
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Install-time helper: trust `sil` in the host OpenClaw config.
|
|
4
|
+
*
|
|
5
|
+
* Operator-invoked (NEVER an npm lifecycle hook — `openclaw.plugin.json#
|
|
6
|
+
* security.noInstallScripts: true` is a shipped guarantee that the package
|
|
7
|
+
* runs nothing automatically; an operator explicitly running this is the
|
|
8
|
+
* opposite of an install hook and honours it). This is a standalone script in
|
|
9
|
+
* the same class as `scripts/release.mjs` — it is NOT the plugin process, so
|
|
10
|
+
* the plugin's `~/.openclaw`-write boundary does not apply to it.
|
|
11
|
+
*
|
|
12
|
+
* What it does: resolve the host `openclaw.json`, read sil's facts from the
|
|
13
|
+
* shipped manifest (single source of truth), call the pure `mergeSilAllowlist`
|
|
14
|
+
* core, and — only when something changed — write a `.bak` then atomically
|
|
15
|
+
* (tmp → rename) write the merged config back, preserving the file's existing
|
|
16
|
+
* mode (host config is operator-readable, NOT a 0600 credential). When the
|
|
17
|
+
* `openclaw` binary is on PATH it runs `openclaw config validate --json` as a
|
|
18
|
+
* best-effort post-write guard and reverts from `.bak` if the merged config is
|
|
19
|
+
* rejected — so a bad result fails closed and never leaves the host half-merged.
|
|
20
|
+
*
|
|
21
|
+
* Config-path precedence (first existing wins):
|
|
22
|
+
* 1. $OPENCLAW_CONFIG_PATH
|
|
23
|
+
* 2. $OPENCLAW_STATE_DIR/openclaw.json
|
|
24
|
+
* 3. ~/.openclaw/openclaw.json
|
|
25
|
+
* None resolves → fail closed (structured error + non-zero exit), create no
|
|
26
|
+
* parent dir (that would mask a misconfiguration; the operator must start the
|
|
27
|
+
* gateway once so it writes its own base config).
|
|
28
|
+
*
|
|
29
|
+
* Three distinct structured outcomes, in sil's `snake_case_marker` log style
|
|
30
|
+
* (here as plain NDJSON on stdout/stderr — the script runs outside the
|
|
31
|
+
* gateway, so there is no `api.logger`). No PII, no secrets:
|
|
32
|
+
* - sil_allowlist_merged (info, stdout) — a fresh merge was written
|
|
33
|
+
* - sil_allowlist_unchanged (info, stdout) — idempotent no-op, nothing written
|
|
34
|
+
* - sil_allowlist_merge_failed (error, stderr) — fail-closed, nothing left half-done
|
|
35
|
+
*
|
|
36
|
+
* All real merge logic lives in the typed lib (`src/lib/openclaw-allowlist.ts`,
|
|
37
|
+
* compiled to `dist/lib/openclaw-allowlist.js`). This shell is thin I/O only.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import { execFileSync } from "node:child_process";
|
|
41
|
+
import {
|
|
42
|
+
copyFileSync,
|
|
43
|
+
existsSync,
|
|
44
|
+
readFileSync,
|
|
45
|
+
renameSync,
|
|
46
|
+
statSync,
|
|
47
|
+
writeFileSync,
|
|
48
|
+
} from "node:fs";
|
|
49
|
+
import { homedir } from "node:os";
|
|
50
|
+
import { dirname, join, resolve } from "node:path";
|
|
51
|
+
import { randomBytes } from "node:crypto";
|
|
52
|
+
import { fileURLToPath } from "node:url";
|
|
53
|
+
|
|
54
|
+
import { mergeSilAllowlist, AllowlistShapeError } from "../dist/lib/openclaw-allowlist.js";
|
|
55
|
+
|
|
56
|
+
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
57
|
+
const MANIFEST_PATH = resolve(ROOT, "openclaw.plugin.json");
|
|
58
|
+
|
|
59
|
+
/** Emit one structured NDJSON line in sil's marker style: `{event, level, ...}`. */
|
|
60
|
+
function logMarker(stream, level, event, fields) {
|
|
61
|
+
const line = JSON.stringify({ event, level, ...fields });
|
|
62
|
+
stream.write(line + "\n");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const logInfo = (event, fields) => logMarker(process.stdout, "info", event, fields ?? {});
|
|
66
|
+
const logError = (event, fields) => logMarker(process.stderr, "error", event, fields ?? {});
|
|
67
|
+
|
|
68
|
+
/** Resolve the host config path by precedence; first existing file wins.
|
|
69
|
+
* Returns the resolved path, or null if none exists (caller fails closed). */
|
|
70
|
+
function resolveConfigPath() {
|
|
71
|
+
const candidates = [];
|
|
72
|
+
if (process.env["OPENCLAW_CONFIG_PATH"]) {
|
|
73
|
+
candidates.push(process.env["OPENCLAW_CONFIG_PATH"]);
|
|
74
|
+
}
|
|
75
|
+
if (process.env["OPENCLAW_STATE_DIR"]) {
|
|
76
|
+
candidates.push(join(process.env["OPENCLAW_STATE_DIR"], "openclaw.json"));
|
|
77
|
+
}
|
|
78
|
+
candidates.push(join(homedir(), ".openclaw", "openclaw.json"));
|
|
79
|
+
|
|
80
|
+
for (const candidate of candidates) {
|
|
81
|
+
if (existsSync(candidate)) return candidate;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Read sil's facts from the shipped manifest — the single source of truth.
|
|
87
|
+
* id / tools / skill are never re-hardcoded in this script. */
|
|
88
|
+
function readSilFacts() {
|
|
89
|
+
const manifest = JSON.parse(readFileSync(MANIFEST_PATH, "utf8"));
|
|
90
|
+
const id = manifest.id;
|
|
91
|
+
const tools = Array.isArray(manifest.contracts?.tools) ? manifest.contracts.tools : [];
|
|
92
|
+
const skill = Array.isArray(manifest.skills) ? (manifest.skills[0] ?? "") : "";
|
|
93
|
+
if (typeof id !== "string" || id.length === 0) {
|
|
94
|
+
throw new Error(`manifest ${MANIFEST_PATH} has no usable "id"`);
|
|
95
|
+
}
|
|
96
|
+
return { id, tools, skill };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Atomic single-file write: tmp sibling → write → rename over target,
|
|
100
|
+
* PRESERVING the source file's existing mode (host config is operator-readable,
|
|
101
|
+
* NOT a 0600 credential — mirrors `src/lib/profile-store.ts:321-327` minus the
|
|
102
|
+
* hardcoded mode). A reader sees either the old file or the new one, never a
|
|
103
|
+
* half-written one; a crash before rename leaves the original untouched. */
|
|
104
|
+
function atomicWrite(path, contents, mode) {
|
|
105
|
+
const tmp = path + "." + randomBytes(6).toString("hex") + ".tmp";
|
|
106
|
+
writeFileSync(tmp, contents, { mode });
|
|
107
|
+
renameSync(tmp, path);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Best-effort `openclaw config validate --json` guard. Returns:
|
|
111
|
+
* { ran: false } — binary absent / not invokable (skip, keep write)
|
|
112
|
+
* { ran: true, valid: boolean, cause?: string }
|
|
113
|
+
* Never throws across the boundary — a non-zero exit from the binary is read
|
|
114
|
+
* from its stdout `.valid`, and an un-parseable response is treated as invalid. */
|
|
115
|
+
function validateConfig(path) {
|
|
116
|
+
let raw;
|
|
117
|
+
try {
|
|
118
|
+
raw = execFileSync("openclaw", ["config", "validate", "--json"], {
|
|
119
|
+
env: { ...process.env, OPENCLAW_CONFIG_PATH: path },
|
|
120
|
+
encoding: "utf8",
|
|
121
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
122
|
+
});
|
|
123
|
+
} catch (err) {
|
|
124
|
+
// ENOENT → binary not on PATH: skip validation (the script must run
|
|
125
|
+
// pre-gateway-boot). Any other spawn failure also means we can't validate;
|
|
126
|
+
// the atomic write + .bak revert remains the real safety net, so we treat a
|
|
127
|
+
// failed *spawn* as "not run" (keep the write) rather than "invalid".
|
|
128
|
+
if (err && err.code === "ENOENT") return { ran: false };
|
|
129
|
+
// The binary ran but exited non-zero — capture its stdout if any so we can
|
|
130
|
+
// read a structured verdict; otherwise treat as invalid (fail closed).
|
|
131
|
+
const stdout = typeof err?.stdout === "string" ? err.stdout : "";
|
|
132
|
+
if (stdout) {
|
|
133
|
+
raw = stdout;
|
|
134
|
+
} else {
|
|
135
|
+
return { ran: true, valid: false, cause: "openclaw config validate exited non-zero" };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
const parsed = JSON.parse(raw);
|
|
140
|
+
if (parsed && parsed.valid === true) return { ran: true, valid: true };
|
|
141
|
+
const cause =
|
|
142
|
+
(parsed && (parsed.error || parsed.message))
|
|
143
|
+
|| "openclaw config validate reported valid !== true";
|
|
144
|
+
return { ran: true, valid: false, cause: String(cause) };
|
|
145
|
+
} catch {
|
|
146
|
+
return { ran: true, valid: false, cause: "openclaw config validate returned non-JSON" };
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function main() {
|
|
151
|
+
const configPath = resolveConfigPath();
|
|
152
|
+
if (configPath === null) {
|
|
153
|
+
logError("sil_allowlist_merge_failed", {
|
|
154
|
+
path: null,
|
|
155
|
+
cause:
|
|
156
|
+
"no OpenClaw config found at OPENCLAW_CONFIG_PATH, "
|
|
157
|
+
+ "$OPENCLAW_STATE_DIR/openclaw.json, or ~/.openclaw/openclaw.json — "
|
|
158
|
+
+ "start the OpenClaw gateway once so it writes its base config, then re-run",
|
|
159
|
+
});
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const sil = readSilFacts();
|
|
164
|
+
|
|
165
|
+
let parsed;
|
|
166
|
+
try {
|
|
167
|
+
parsed = JSON.parse(readFileSync(configPath, "utf8"));
|
|
168
|
+
} catch (err) {
|
|
169
|
+
logError("sil_allowlist_merge_failed", {
|
|
170
|
+
path: configPath,
|
|
171
|
+
cause: "config is not valid JSON: " + (err?.message ?? String(err)),
|
|
172
|
+
});
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
let result;
|
|
177
|
+
try {
|
|
178
|
+
result = mergeSilAllowlist(parsed, sil);
|
|
179
|
+
} catch (err) {
|
|
180
|
+
const cause =
|
|
181
|
+
err instanceof AllowlistShapeError
|
|
182
|
+
? err.message
|
|
183
|
+
: "merge failed: " + (err?.message ?? String(err));
|
|
184
|
+
logError("sil_allowlist_merge_failed", { path: configPath, cause });
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (!result.changed) {
|
|
189
|
+
logInfo("sil_allowlist_unchanged", { plugin: sil.id });
|
|
190
|
+
process.exit(0);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Something changed → back up, atomically write, then best-effort validate.
|
|
194
|
+
const mode = statSync(configPath).mode & 0o777;
|
|
195
|
+
const bakPath = configPath + ".bak";
|
|
196
|
+
copyFileSync(configPath, bakPath);
|
|
197
|
+
|
|
198
|
+
const serialized = JSON.stringify(result.config, null, 2) + "\n";
|
|
199
|
+
atomicWrite(configPath, serialized, mode);
|
|
200
|
+
|
|
201
|
+
const validation = validateConfig(configPath);
|
|
202
|
+
if (validation.ran && !validation.valid) {
|
|
203
|
+
// Revert to the exact pre-run bytes; leave the host in its pre-run state.
|
|
204
|
+
copyFileSync(bakPath, configPath);
|
|
205
|
+
logError("sil_allowlist_merge_failed", {
|
|
206
|
+
path: configPath,
|
|
207
|
+
cause: validation.cause ?? "openclaw config validate rejected the merged config",
|
|
208
|
+
});
|
|
209
|
+
process.exit(1);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const allowSize = Array.isArray(result.config.plugins?.allow)
|
|
213
|
+
? result.config.plugins.allow.length
|
|
214
|
+
: 0;
|
|
215
|
+
logInfo("sil_allowlist_merged", {
|
|
216
|
+
plugin: sil.id,
|
|
217
|
+
tools_added: sil.tools.length,
|
|
218
|
+
skill_added: sil.skill.length > 0,
|
|
219
|
+
plugins_allow_size: allowSize,
|
|
220
|
+
validated: validation.ran,
|
|
221
|
+
path: configPath,
|
|
222
|
+
});
|
|
223
|
+
process.exit(0);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
main();
|
|
Binary file
|
|
@@ -0,0 +1,228 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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}`);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: sil
|
|
3
|
-
description: This skill should be used
|
|
2
|
+
name: sil-shopping
|
|
3
|
+
description: This skill should be used whenever the user wants to shop on sil or run a sil shopping expert: register or sign in to sil, check who they are, search the sil catalog for purchasable products, or look up specific products by id — and for the full shopping-expert lifecycle: "make me a shopping expert" / "set up an agent that shops for me" (interview, then create), list the experts they have created, view or remove one, refine an existing expert, or — inside a created expert — run a profile-driven Spec-Driven Shopping query on its niche. Route here for any shopping, identity, or shopping-expert intent on sil. Drives sil_register, sil_whoami, sil_search, sil_product_get, sil_profile_materialize, sil_profile_list, sil_profile_get, and sil_profile_remove.
|
|
4
4
|
metadata:
|
|
5
5
|
openclaw:
|
|
6
6
|
emoji: "\U0001F6D2"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
# sil
|
|
9
|
+
# sil-shopping
|
|
10
10
|
|
|
11
11
|
Drive the sil plugin's tools on the user's behalf: register them on sil, read their identity, help them find purchasable products in the sil catalog — and, when asked, create a dedicated sil-wired shopping expert, then list, view, or remove the experts they have created. Read user intent, route to the matching tool (loading its reference on demand), call it, and report what came back.
|
|
12
12
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|