@ipab/cli 0.1.0-rc.10 → 0.1.0-rc.12
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/README.md +24 -11
- package/dist/authoring.d.ts +7 -0
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +85 -5
- package/dist/authoring.js.map +1 -1
- package/dist/builtins/skill.ipab.car +0 -0
- package/dist/builtins/template.bundle-viewer.car +0 -0
- package/dist/builtins/template.check.car +0 -0
- package/dist/builtins/template.node.car +0 -0
- package/dist/builtins/template.web-app.car +0 -0
- package/dist/bundled-skills.d.ts +1 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +904 -183
- package/dist/cli.js.map +1 -1
- package/dist/config-secret.js +1 -1
- package/dist/config-secret.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +17 -2
- package/dist/config.js.map +1 -1
- package/dist/daemon-ui.d.ts +1 -0
- package/dist/daemon-ui.d.ts.map +1 -1
- package/dist/daemon-ui.js +2 -0
- package/dist/daemon-ui.js.map +1 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +7 -3
- package/dist/doctor.js.map +1 -1
- package/dist/get.d.ts.map +1 -1
- package/dist/get.js +1 -1
- package/dist/get.js.map +1 -1
- package/dist/history.d.ts +3 -1
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +16 -1
- package/dist/history.js.map +1 -1
- package/dist/kubo-topology.d.ts +2 -0
- package/dist/kubo-topology.d.ts.map +1 -1
- package/dist/kubo-topology.js +17 -20
- package/dist/kubo-topology.js.map +1 -1
- package/dist/kubo.d.ts +5 -3
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +83 -13
- package/dist/kubo.js.map +1 -1
- package/dist/name-reference.d.ts +8 -0
- package/dist/name-reference.d.ts.map +1 -0
- package/dist/name-reference.js +63 -0
- package/dist/name-reference.js.map +1 -0
- package/dist/pivot-rpc.d.ts +37 -2
- package/dist/pivot-rpc.d.ts.map +1 -1
- package/dist/pivot-rpc.js +188 -8
- package/dist/pivot-rpc.js.map +1 -1
- package/dist/search-index.d.ts.map +1 -1
- package/dist/search-index.js +1 -0
- package/dist/search-index.js.map +1 -1
- package/dist/skill-definition.d.ts +9 -0
- package/dist/skill-definition.d.ts.map +1 -1
- package/dist/skill-definition.js +26 -2
- package/dist/skill-definition.js.map +1 -1
- package/dist/skill-source.d.ts +1 -0
- package/dist/skill-source.d.ts.map +1 -1
- package/dist/skill-source.js +10 -4
- package/dist/skill-source.js.map +1 -1
- package/dist/skills.d.ts +9 -3
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +31 -2
- package/dist/skills.js.map +1 -1
- package/dist/state.d.ts +20 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +87 -3
- package/dist/state.js.map +1 -1
- package/dist/swarm-fs-core.d.ts +217 -0
- package/dist/swarm-fs-core.d.ts.map +1 -0
- package/dist/swarm-fs-core.js +885 -0
- package/dist/swarm-fs-core.js.map +1 -0
- package/dist/swarm-fs-path.d.ts +17 -0
- package/dist/swarm-fs-path.d.ts.map +1 -0
- package/dist/swarm-fs-path.js +46 -0
- package/dist/swarm-fs-path.js.map +1 -0
- package/dist/swarm-fs.d.ts +9 -0
- package/dist/swarm-fs.d.ts.map +1 -0
- package/dist/swarm-fs.js +21 -0
- package/dist/swarm-fs.js.map +1 -0
- package/dist/swarm-observations.d.ts +6 -0
- package/dist/swarm-observations.d.ts.map +1 -1
- package/dist/swarm-observations.js +28 -8
- package/dist/swarm-observations.js.map +1 -1
- package/dist/swarm.d.ts +192 -17
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +1360 -442
- package/dist/swarm.js.map +1 -1
- package/dist/unixfs-tree.d.ts +55 -0
- package/dist/unixfs-tree.d.ts.map +1 -1
- package/dist/unixfs-tree.js +361 -2
- package/dist/unixfs-tree.js.map +1 -1
- package/package.json +5 -5
- package/src/authoring.ts +125 -8
- package/src/cli.ts +1215 -281
- package/src/config-secret.ts +1 -1
- package/src/config.ts +20 -2
- package/src/daemon-ui.ts +3 -0
- package/src/doctor.ts +12 -2
- package/src/get.ts +2 -1
- package/src/history.ts +26 -1
- package/src/kubo-topology.ts +25 -22
- package/src/kubo.ts +127 -9
- package/src/name-reference.ts +91 -0
- package/src/pivot-rpc.ts +272 -14
- package/src/search-index.ts +1 -0
- package/src/skill-definition.ts +45 -3
- package/src/skill-source.ts +10 -4
- package/src/skills.ts +43 -2
- package/src/state.ts +117 -2
- package/src/swarm-fs-core.ts +1461 -0
- package/src/swarm-fs-path.ts +68 -0
- package/src/swarm-fs.ts +104 -0
- package/src/swarm-observations.ts +40 -14
- package/src/swarm.ts +1950 -727
- package/src/unixfs-tree.ts +447 -2
package/src/cli.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { createInterface } from "node:readline/promises";
|
|
2
2
|
import { lstat, readFile } from "node:fs/promises";
|
|
3
|
-
import {
|
|
4
|
-
import { ContentBundleError } from "@ipab/bundle";
|
|
3
|
+
import type { IpfsStore } from "@ipab/ipfs-store";
|
|
5
4
|
import { randomUUID } from "node:crypto";
|
|
6
5
|
import { CID } from "multiformats/cid";
|
|
7
6
|
import stringWidth from "string-width";
|
|
8
7
|
import {
|
|
8
|
+
LOCAL_SWARM_ALIAS,
|
|
9
9
|
configKey,
|
|
10
10
|
effectiveConfig,
|
|
11
|
+
isLocalSwarm,
|
|
11
12
|
parseValue,
|
|
12
13
|
publicUrl,
|
|
13
14
|
stateLocation,
|
|
@@ -16,17 +17,8 @@ import {
|
|
|
16
17
|
visibleConfig,
|
|
17
18
|
type GlobalOptions,
|
|
18
19
|
} from "./config.js";
|
|
19
|
-
import { HostError,
|
|
20
|
-
import {
|
|
21
|
-
filters,
|
|
22
|
-
listHistory,
|
|
23
|
-
selectedIds,
|
|
24
|
-
Ownership,
|
|
25
|
-
recoverInactive,
|
|
26
|
-
removeHistory,
|
|
27
|
-
} from "./history.js";
|
|
28
|
-
import { execute } from "./runtime.js";
|
|
29
|
-
import { validatedBundle } from "./space.js";
|
|
20
|
+
import { HostError, object, syntax } from "./host-error.js";
|
|
21
|
+
import type { Ownership as HistoryOwnership } from "./history.js";
|
|
30
22
|
import {
|
|
31
23
|
createAssociation,
|
|
32
24
|
exactCid,
|
|
@@ -35,72 +27,15 @@ import {
|
|
|
35
27
|
type Association,
|
|
36
28
|
type RunRecord,
|
|
37
29
|
} from "./state.js";
|
|
30
|
+
import type { searchNames, SwarmContext } from "./swarm.js";
|
|
38
31
|
import {
|
|
39
|
-
buildBundle,
|
|
40
|
-
inspectBundle,
|
|
41
|
-
importBundle,
|
|
42
|
-
nodeError,
|
|
43
|
-
} from "./authoring.js";
|
|
44
|
-
import { initApp } from "./app-authoring.js";
|
|
45
|
-
import { assembleBundle } from "./assembly.js";
|
|
46
|
-
import { getBundle } from "./get.js";
|
|
47
|
-
import { doctorDevice, doctorText } from "./doctor.js";
|
|
48
|
-
import {
|
|
49
|
-
daemonEndpoint,
|
|
50
|
-
ensureDaemon,
|
|
51
|
-
openLoopbackUrl,
|
|
52
|
-
serveDaemon,
|
|
53
|
-
} from "./daemon.js";
|
|
54
|
-
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
55
|
-
import {
|
|
56
|
-
createSwarm,
|
|
57
|
-
swarmDaemon,
|
|
58
|
-
requestMembership,
|
|
59
|
-
approveMembership,
|
|
60
|
-
grantPivotAuthority,
|
|
61
|
-
exportRequest,
|
|
62
|
-
removeMember,
|
|
63
|
-
resumeRemoval,
|
|
64
|
-
updateProfile,
|
|
65
|
-
accountProfile,
|
|
66
|
-
updateAccountProfile,
|
|
67
|
-
swarmMembers,
|
|
68
|
-
inspectSwarmStatus,
|
|
69
|
-
verifiedRequest,
|
|
70
|
-
verifiedRequestStream,
|
|
71
|
-
membershipRequestSummary,
|
|
72
|
-
updateSwarm,
|
|
73
|
-
searchNames,
|
|
74
32
|
formatNameReference,
|
|
75
|
-
resolveReference,
|
|
76
33
|
parseNameReference,
|
|
77
34
|
formalName,
|
|
78
|
-
publish,
|
|
79
|
-
pinNameSubscription,
|
|
80
|
-
pinReference,
|
|
81
|
-
swarmRegistrations,
|
|
82
|
-
swarmAssociation,
|
|
83
|
-
setSwarmAssociation,
|
|
84
|
-
removeSwarmAssociation,
|
|
85
|
-
resolveTemplateSelector,
|
|
86
35
|
templateName,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
removeSwarmTemplate,
|
|
90
|
-
type SwarmContext,
|
|
91
|
-
} from "./swarm.js";
|
|
92
|
-
import { schemaAlias } from "./app-definition.js";
|
|
93
|
-
import { unpin, pinDetails } from "./pins.js";
|
|
94
|
-
import { publicationSource } from "./publish-source.js";
|
|
95
|
-
import {
|
|
96
|
-
templateRenderExample,
|
|
97
|
-
templateOutputTree,
|
|
98
|
-
templateParameterRows,
|
|
99
|
-
} from "./template-presentation.js";
|
|
100
|
-
import { logFiles } from "./logs.js";
|
|
101
|
-
import { builtinContent } from "./builtins.js";
|
|
36
|
+
} from "./name-reference.js";
|
|
37
|
+
import { normalizeSwarmFsPath } from "./swarm-fs-path.js";
|
|
102
38
|
import { readSecretStream } from "./config-secret.js";
|
|
103
|
-
import { manageSkills, syncDaemonSwarm } from "./skills.js";
|
|
104
39
|
|
|
105
40
|
export interface IO {
|
|
106
41
|
out(text: string): void;
|
|
@@ -166,6 +101,9 @@ const commands: Record<string, string> = {
|
|
|
166
101
|
daemon: "daemon",
|
|
167
102
|
"daemon ui": "daemon ui [--open]",
|
|
168
103
|
"skills list": "skills list [--refresh | --no-refresh]",
|
|
104
|
+
"skills show": "skills show SCHEMA_OR_CONTENT [--refresh | --no-refresh]",
|
|
105
|
+
"skills set": "skills set SKILL [--global] [--type SCHEMA]... [--replace]",
|
|
106
|
+
"skills remove": "skills remove [--global NAME] [--type SCHEMA]...",
|
|
169
107
|
"skills sync":
|
|
170
108
|
"skills sync [NAMES...] [--agent AGENT]... [--override-existing] [--dry-run] [--yes] [--refresh | --no-refresh]",
|
|
171
109
|
doctor: "doctor [--fix [--yes]]",
|
|
@@ -179,6 +117,7 @@ const commands: Record<string, string> = {
|
|
|
179
117
|
"swarm resume": "swarm resume",
|
|
180
118
|
"swarm profile": "swarm profile [--address MULTIADDR] [--pivot true|false]",
|
|
181
119
|
"swarm status": "swarm status [--refresh | --no-refresh]",
|
|
120
|
+
"swarm replicate": "swarm replicate [--pivot MEMBER]",
|
|
182
121
|
"swarm members": "swarm members [--refresh | --no-refresh]",
|
|
183
122
|
"swarm list": "swarm list",
|
|
184
123
|
"swarm set": "swarm set ALIAS CONFIG_URL [--yes]",
|
|
@@ -193,7 +132,7 @@ const commands: Record<string, string> = {
|
|
|
193
132
|
build: "build [SOURCE] [OPTIONS]",
|
|
194
133
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
195
134
|
"bundle inspect": "bundle inspect SOURCE",
|
|
196
|
-
"bundle import": "bundle import
|
|
135
|
+
"bundle import": "bundle import SOURCE",
|
|
197
136
|
exec: "exec [--log] [--refresh | --no-refresh] APP [APP_ARGS...]",
|
|
198
137
|
open: "open [--log] [--raw] [--refresh | --no-refresh] CONTENT",
|
|
199
138
|
pin: "pin REF [--refresh | --no-refresh]",
|
|
@@ -214,18 +153,23 @@ const commands: Record<string, string> = {
|
|
|
214
153
|
"config reset": "config reset KEY",
|
|
215
154
|
"store usage": "store usage",
|
|
216
155
|
"store gc": "store gc",
|
|
156
|
+
"fs ls": "fs ls [PATH] [--all] [--recursive] [--refresh | --no-refresh]",
|
|
157
|
+
"fs stat": "fs stat PATH [--refresh | --no-refresh]",
|
|
158
|
+
"fs set": "fs set PATH CID [--expect OLD_CID | --replace]",
|
|
159
|
+
"fs rm": "fs rm PATH [--expect OLD_CID]",
|
|
217
160
|
"history list": "history list [OPTIONS]",
|
|
218
161
|
"history show": "history show RUN_ID",
|
|
219
162
|
"history remove":
|
|
220
163
|
"history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
|
|
221
164
|
};
|
|
222
165
|
const groups: Record<string, string> = {
|
|
223
|
-
skills: "Discover and
|
|
166
|
+
skills: "Discover, associate, and synchronize Swarm Skills",
|
|
224
167
|
swarm: "Create, authorize, select and manage personal swarms",
|
|
225
168
|
bundle: "Create, inspect and import content bundles",
|
|
226
169
|
pin: "Retain an exact CID or follow a shared Swarm Name",
|
|
227
170
|
register: "Associate content types with Apps",
|
|
228
171
|
templates: "Inspect, render and manage Template Bundles",
|
|
172
|
+
fs: "Inspect and modify paths in a Swarm UnixFS tree",
|
|
229
173
|
config: "Manage local configuration",
|
|
230
174
|
store: "Query local storage and collect unreferenced blocks",
|
|
231
175
|
history: "View and remove execution history",
|
|
@@ -324,22 +268,81 @@ const commandHelp: Record<
|
|
|
324
268
|
],
|
|
325
269
|
},
|
|
326
270
|
"skills list": {
|
|
327
|
-
summary:
|
|
271
|
+
summary:
|
|
272
|
+
"List Global Skills (with local status) and Type Skills from one Swarm",
|
|
328
273
|
options: [
|
|
329
274
|
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
330
|
-
"Global --json Emit machine-readable
|
|
275
|
+
"Global --json Emit machine-readable global items, typeSkills, CIDs and status.",
|
|
331
276
|
],
|
|
332
277
|
examples: ["ipab --swarm work skills list", "ipab --json skills list"],
|
|
333
278
|
notes: [
|
|
334
279
|
"Select one Swarm with global --swarm or swarm use; there is no --all.",
|
|
335
|
-
"
|
|
280
|
+
"Reads <skillPath>/global/* and <skillPath>/types/*; missing subdirectories are treated as empty.",
|
|
281
|
+
"Requires skillPath in the exact root State Bundle or legacy Meta type. No silent upgrades.",
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
"skills show": {
|
|
285
|
+
summary: "Show the Skill associated with a Bundle type or content Bundle",
|
|
286
|
+
arguments: [
|
|
287
|
+
"SCHEMA_OR_CONTENT Canonical schema CID, builtin: alias, content Bundle CID, Swarm URI, or local .car/Bundle directory.",
|
|
288
|
+
],
|
|
289
|
+
options: [
|
|
290
|
+
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
291
|
+
"Global --json Emit machine-readable Skill association details.",
|
|
292
|
+
],
|
|
293
|
+
examples: [
|
|
294
|
+
"ipab skills show SCHEMA_CID",
|
|
295
|
+
"ipab skills show ipab://work/docs/spec",
|
|
296
|
+
"ipab --json skills show ./document.car",
|
|
297
|
+
],
|
|
298
|
+
notes: [
|
|
299
|
+
"Swarm URIs use the URI's Swarm ahead of --swarm and the default Swarm.",
|
|
300
|
+
"Content Bundle references automatically unwrap Artifacts and resolve their schema CID.",
|
|
301
|
+
"Exits with code 1 (SKILL_NOT_FOUND) when no Skill is associated with the schema.",
|
|
302
|
+
],
|
|
303
|
+
},
|
|
304
|
+
"skills set": {
|
|
305
|
+
summary: "Associate a Skill Bundle globally and/or with Bundle types",
|
|
306
|
+
arguments: [
|
|
307
|
+
"SKILL Skill Bundle CID, Swarm URI, local .car file, or assembled Skill Bundle directory containing .bundle.yaml.",
|
|
308
|
+
],
|
|
309
|
+
options: [
|
|
310
|
+
"--global Publish to <skillPath>/global/<skill-name> for global synchronization.",
|
|
311
|
+
"--type SCHEMA Repeatable target Bundle schema CID (writes <skillPath>/types/<schemaCid>).",
|
|
312
|
+
"--replace Overwrite existing targets that point to a different Skill CID.",
|
|
313
|
+
],
|
|
314
|
+
examples: [
|
|
315
|
+
"ipab skills set SKILL_CID --global",
|
|
316
|
+
"ipab skills set ./skill.car --type SCHEMA_CID",
|
|
317
|
+
"ipab skills set SKILL_CID --global --type SCHEMA_CID --replace",
|
|
318
|
+
],
|
|
319
|
+
notes: [
|
|
320
|
+
"Requires --global and/or at least one --type SCHEMA. All targets commit atomically in one HEAD CAS.",
|
|
321
|
+
"Writes direct Skill Bundle CIDs. Occupied targets with a different CID fail with exit code 3 unless --replace is set.",
|
|
322
|
+
],
|
|
323
|
+
},
|
|
324
|
+
"skills remove": {
|
|
325
|
+
summary: "Remove global and/or type Skill associations atomically",
|
|
326
|
+
options: [
|
|
327
|
+
"--global NAME Remove <skillPath>/global/NAME (at most once).",
|
|
328
|
+
"--type SCHEMA Repeatable target Bundle schema CID to remove from <skillPath>/types/.",
|
|
329
|
+
],
|
|
330
|
+
examples: [
|
|
331
|
+
"ipab skills remove --global my-skill",
|
|
332
|
+
"ipab skills remove --type SCHEMA_CID",
|
|
333
|
+
"ipab skills remove --global my-skill --type SCHEMA_CID",
|
|
334
|
+
],
|
|
335
|
+
notes: [
|
|
336
|
+
"Requires --global NAME and/or at least one --type SCHEMA. All removals commit atomically in one HEAD CAS.",
|
|
337
|
+
"If any target is missing, the entire batch fails with exit code 1 and nothing is modified.",
|
|
338
|
+
"Does not delete underlying content blocks or locally installed Agent Skill files.",
|
|
336
339
|
],
|
|
337
340
|
},
|
|
338
341
|
"skills sync": {
|
|
339
342
|
summary:
|
|
340
|
-
"Install reviewed Swarm Skills using the pinned official npx installer",
|
|
343
|
+
"Install reviewed Global Swarm Skills using the pinned official npx installer",
|
|
341
344
|
arguments: [
|
|
342
|
-
"NAMES Install identities, e.g. ipab code-review, or full shared Names such as ipab/skills/ipab. Resolved from one verified snapshot; omit for all Skills.",
|
|
345
|
+
"NAMES Install identities, e.g. ipab code-review, or full shared Names such as ipab/skills/global/ipab. Resolved from one verified snapshot; omit for all Global Skills.",
|
|
343
346
|
],
|
|
344
347
|
options: [
|
|
345
348
|
"--agent AGENT Repeatable globally supported agent ID; default is universal (~/.agents/skills).",
|
|
@@ -353,6 +356,7 @@ const commandHelp: Record<
|
|
|
353
356
|
"ipab skills sync ipab code-review --agent github-copilot --yes",
|
|
354
357
|
],
|
|
355
358
|
notes: [
|
|
359
|
+
"Scans <skillPath>/global/* only; Type Skills under <skillPath>/types/* are never installed globally.",
|
|
356
360
|
"Global installs only, through official skills@1.9.1 with --copy. Requires Node >=22.20.0.",
|
|
357
361
|
"Non-interactive execution requires --yes. Installer version, source, paths and agents are shown first.",
|
|
358
362
|
"No Skill hooks/scripts run. The trusted installer is not sandboxed. Telemetry and remote audits are disabled.",
|
|
@@ -494,6 +498,21 @@ const commandHelp: Record<
|
|
|
494
498
|
"Pivot provides backbone connectivity and durable published-content Pin service through daemon. Keep it online with sufficient storage.",
|
|
495
499
|
],
|
|
496
500
|
},
|
|
501
|
+
"swarm replicate": {
|
|
502
|
+
summary: "Replicate the complete local current HEAD to a remote Pivot",
|
|
503
|
+
options: [
|
|
504
|
+
"--pivot MEMBER Target one declared Pivot by exact member name, public key or PeerID.",
|
|
505
|
+
],
|
|
506
|
+
examples: [
|
|
507
|
+
"ipab --swarm work swarm replicate --pivot scott-office-ubuntu",
|
|
508
|
+
"ipab --json --swarm work swarm replicate",
|
|
509
|
+
],
|
|
510
|
+
notes: [
|
|
511
|
+
"Requires approved membership and the complete current HEAD locally. Works behind NAT; no source address publication is required.",
|
|
512
|
+
"Checks Pivot readiness and idempotently copies to an unready Pivot. Stops after the first ready replica; --pivot restricts all work to that member. Never changes HEAD or bypasses a write receipt.",
|
|
513
|
+
"Progress goes to stderr; --json returns the HEAD and per-Pivot results. At least one Pivot must confirm readiness for success.",
|
|
514
|
+
],
|
|
515
|
+
},
|
|
497
516
|
"swarm members": {
|
|
498
517
|
summary: "List every public member, including the Owner",
|
|
499
518
|
options: [
|
|
@@ -734,17 +753,25 @@ const commandHelp: Record<
|
|
|
734
753
|
notes: ["Does not execute Apps, import content or create pins."],
|
|
735
754
|
},
|
|
736
755
|
"bundle import": {
|
|
737
|
-
summary:
|
|
738
|
-
|
|
739
|
-
|
|
756
|
+
summary:
|
|
757
|
+
"Validate and import a CAR or Bundle directory into the configured Store",
|
|
758
|
+
arguments: [
|
|
759
|
+
"SOURCE Self-contained single-root CAR or local Content Bundle directory.",
|
|
760
|
+
],
|
|
761
|
+
examples: [
|
|
762
|
+
"ipab bundle import hello\\dist\\app.car",
|
|
763
|
+
"ipab bundle import .",
|
|
764
|
+
],
|
|
740
765
|
notes: [
|
|
766
|
+
"Directories must contain valid Bundle metadata; .bundle-ignore is honored without writing CAR files.",
|
|
741
767
|
"Repeated imports are safe; no App execution or daemon startup.",
|
|
742
768
|
"Does not pin or retain content. Use pin CID for persistent retention.",
|
|
743
769
|
],
|
|
744
770
|
},
|
|
745
771
|
exec: {
|
|
746
|
-
summary: "Run an App by
|
|
772
|
+
summary: "Run an App by CID, Swarm IPAB URI, local CAR or Bundle directory",
|
|
747
773
|
arguments: [
|
|
774
|
+
"APP App CID, Swarm IPAB URI, local App .car file or assembled App Bundle directory.",
|
|
748
775
|
"APP_ARGS Everything after APP is passed verbatim, including --help.",
|
|
749
776
|
],
|
|
750
777
|
options: [
|
|
@@ -753,12 +780,13 @@ const commandHelp: Record<
|
|
|
753
780
|
"--no-refresh Override swarm.forceRefresh; must precede APP.",
|
|
754
781
|
],
|
|
755
782
|
examples: [
|
|
756
|
-
"ipab exec
|
|
757
|
-
"ipab exec --
|
|
783
|
+
"ipab exec APP_CID",
|
|
784
|
+
"ipab exec .\\dist\\app.car --help",
|
|
758
785
|
"ipab exec ipab://work/apps/hello --help",
|
|
759
786
|
],
|
|
760
787
|
notes: [
|
|
761
788
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
789
|
+
"Local App directories must already contain valid assembled Bundle metadata; exec does not compile source, pin or modify the directory.",
|
|
762
790
|
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
763
791
|
"History stores argv by default; do not put secrets in arguments.",
|
|
764
792
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
@@ -768,7 +796,7 @@ const commandHelp: Record<
|
|
|
768
796
|
open: {
|
|
769
797
|
summary: "Open content with its registered App",
|
|
770
798
|
arguments: [
|
|
771
|
-
"CONTENT Bundle CID, packaged builtin reference or Swarm IPAB URI.",
|
|
799
|
+
"CONTENT Local Bundle directory or .car file, Bundle CID, packaged builtin reference or Swarm IPAB URI.",
|
|
772
800
|
],
|
|
773
801
|
options: [
|
|
774
802
|
"--log Record stdout/stderr; requires history enabled.",
|
|
@@ -777,12 +805,13 @@ const commandHelp: Record<
|
|
|
777
805
|
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
778
806
|
],
|
|
779
807
|
examples: [
|
|
780
|
-
"ipab open
|
|
808
|
+
"ipab open .",
|
|
809
|
+
"ipab open .\\dist\\bundle.car",
|
|
781
810
|
"ipab open --log --refresh ipab:///documents/readme",
|
|
782
|
-
"ipab open ipab:///",
|
|
783
811
|
],
|
|
784
812
|
notes: [
|
|
785
813
|
"Requires a saved registration and App support for the exact content type.",
|
|
814
|
+
"Local directories and .car files must contain a valid Content Bundle; quote paths with spaces. Directory snapshots honor .bundle-ignore without compiling, publishing, pinning, writing CAR files or updating the source.",
|
|
786
815
|
"An empty URI Name (ipab:/// or ipab://ALIAS/) resolves to that Swarm's verified root State CID, not its publication CID. The root binding cannot be overwritten.",
|
|
787
816
|
"Uses only the content URI's Swarm, otherwise --swarm, otherwise swarm.default. A selected Swarm is required.",
|
|
788
817
|
"A registered App's retrieval, compatibility or execution failure never triggers fallback.",
|
|
@@ -855,7 +884,7 @@ const commandHelp: Record<
|
|
|
855
884
|
summary: "Associate a content type with an App",
|
|
856
885
|
arguments: [
|
|
857
886
|
"SCHEMA Exact type CID or builtin:node-app.v1.",
|
|
858
|
-
"APP App CID
|
|
887
|
+
"APP App CID, Swarm IPAB URI, local App .car file or assembled App Bundle directory.",
|
|
859
888
|
],
|
|
860
889
|
options: [
|
|
861
890
|
"--replace Allow changing an existing association.",
|
|
@@ -863,10 +892,12 @@ const commandHelp: Record<
|
|
|
863
892
|
],
|
|
864
893
|
examples: [
|
|
865
894
|
"ipab register set SCHEMA_CID APP_CID",
|
|
895
|
+
"ipab register set SCHEMA_CID .\\dist\\app.car --swarm work",
|
|
866
896
|
"ipab register set SCHEMA_CID ipab:///apps/reader --swarm work --swarm team",
|
|
867
897
|
],
|
|
868
898
|
notes: [
|
|
869
899
|
"Writes the Name META.registryPath/TYPE_CID directly to the App CID. Open passes only the content CID.",
|
|
900
|
+
"Local App .car files or assembled App Bundle directories are snapshotted into the local Store once and published into each selected Swarm registry without compiling or pinning.",
|
|
870
901
|
"Custom per-association argv is unsupported; adapt the App or use ipab exec APP_CID ARGS.",
|
|
871
902
|
"Does not verify App type support; open checks it before execution.",
|
|
872
903
|
"Without explicit --swarm, writes the saved default Swarm. Swarm writes require HEAD write access.",
|
|
@@ -888,6 +919,80 @@ const commandHelp: Record<
|
|
|
888
919
|
"Does not remove Apps, pins or content.",
|
|
889
920
|
],
|
|
890
921
|
},
|
|
922
|
+
"fs ls": {
|
|
923
|
+
summary: "List entries under a path in the selected Swarm UnixFS tree",
|
|
924
|
+
arguments: [
|
|
925
|
+
"PATH Optional directory path inside the Swarm root (defaults to /).",
|
|
926
|
+
],
|
|
927
|
+
options: [
|
|
928
|
+
"--all Include protected v7 root metadata files when listing /.",
|
|
929
|
+
"--recursive Traverse subdirectories recursively (bounded depth/nodes).",
|
|
930
|
+
"--refresh Fetch the latest Swarm HEAD before listing.",
|
|
931
|
+
"--no-refresh Use only the cached Swarm HEAD without contacting network.",
|
|
932
|
+
],
|
|
933
|
+
examples: [
|
|
934
|
+
"ipab fs ls",
|
|
935
|
+
"ipab fs ls ipab/skills --recursive",
|
|
936
|
+
"ipab --json fs ls --all",
|
|
937
|
+
],
|
|
938
|
+
notes: [
|
|
939
|
+
"On legacy (v2-v6) Swarms, lists a read-only virtual view projected from snapshot names.",
|
|
940
|
+
],
|
|
941
|
+
},
|
|
942
|
+
"fs stat": {
|
|
943
|
+
summary: "Inspect metadata for a path in the selected Swarm UnixFS tree",
|
|
944
|
+
arguments: ["PATH Path inside the Swarm root (use / or . for root)."],
|
|
945
|
+
options: [
|
|
946
|
+
"--refresh Fetch the latest Swarm HEAD before inspecting.",
|
|
947
|
+
"--no-refresh Use only the cached Swarm HEAD without contacting network.",
|
|
948
|
+
],
|
|
949
|
+
examples: [
|
|
950
|
+
"ipab fs stat /",
|
|
951
|
+
"ipab fs stat ipab/skills",
|
|
952
|
+
"ipab --json fs stat docs/guide",
|
|
953
|
+
],
|
|
954
|
+
notes: [
|
|
955
|
+
"On legacy (v2-v6) Swarms, reports a read-only virtual view projected from snapshot names.",
|
|
956
|
+
],
|
|
957
|
+
},
|
|
958
|
+
"fs set": {
|
|
959
|
+
summary:
|
|
960
|
+
"Mount an existing CID at a path in the selected Swarm UnixFS tree",
|
|
961
|
+
arguments: [
|
|
962
|
+
"PATH Relative path inside the Swarm root (root / and protected metadata are rejected).",
|
|
963
|
+
"CID Canonical CID already present in the local IPFS store.",
|
|
964
|
+
],
|
|
965
|
+
options: [
|
|
966
|
+
"--expect OLD_CID Require the current path CID to match OLD_CID before replacing.",
|
|
967
|
+
"--replace Allow replacing an existing different CID at PATH.",
|
|
968
|
+
],
|
|
969
|
+
examples: [
|
|
970
|
+
"ipab fs set docs/guide bafy...",
|
|
971
|
+
"ipab fs set docs/guide bafyNEW --expect bafyOLD",
|
|
972
|
+
"ipab --json fs set docs/guide bafyNEW --replace",
|
|
973
|
+
],
|
|
974
|
+
notes: [
|
|
975
|
+
"Requires a State v7 UnixFS Swarm root; legacy (v2-v6) Swarms are not implicitly migrated.",
|
|
976
|
+
"Protected v7 root metadata files (.bundle.yaml, typeFile, entryFile) cannot be overwritten.",
|
|
977
|
+
],
|
|
978
|
+
},
|
|
979
|
+
"fs rm": {
|
|
980
|
+
summary: "Remove a path from the selected Swarm UnixFS tree",
|
|
981
|
+
arguments: [
|
|
982
|
+
"PATH Relative path to remove (automatically prunes empty parent directories up to /).",
|
|
983
|
+
],
|
|
984
|
+
options: [
|
|
985
|
+
"--expect OLD_CID Require the current path CID to match OLD_CID before removing.",
|
|
986
|
+
],
|
|
987
|
+
examples: [
|
|
988
|
+
"ipab fs rm docs/guide",
|
|
989
|
+
"ipab fs rm docs/guide --expect bafyOLD",
|
|
990
|
+
"ipab --json fs rm docs/guide",
|
|
991
|
+
],
|
|
992
|
+
notes: [
|
|
993
|
+
"Requires a State v7 UnixFS Swarm root; protected root metadata files cannot be removed.",
|
|
994
|
+
],
|
|
995
|
+
},
|
|
891
996
|
"config get": {
|
|
892
997
|
summary: "Show effective configuration",
|
|
893
998
|
arguments: ["KEY Optional configuration key; omit to show all values."],
|
|
@@ -957,7 +1062,7 @@ const commandHelp: Record<
|
|
|
957
1062
|
|
|
958
1063
|
export function help(path = ""): string {
|
|
959
1064
|
const globalOptions = `Global options (before COMMAND):
|
|
960
|
-
--swarm URL|ALIAS Select
|
|
1065
|
+
--swarm URL|ALIAS Select Swarm (defaults to built-in local Swarm or saved swarm.default; URI swarm takes precedence)
|
|
961
1066
|
--state-dir PATH Set a dedicated, account-private local state directory
|
|
962
1067
|
--store-gateway URL Use a read-only upstream HTTP gateway
|
|
963
1068
|
--json Output management/development metadata, not App stdio`;
|
|
@@ -981,6 +1086,7 @@ Manage:
|
|
|
981
1086
|
doctor ${commandHelp.doctor!.summary}
|
|
982
1087
|
profile ${commandHelp.profile!.summary}
|
|
983
1088
|
swarm ${groups.swarm}
|
|
1089
|
+
fs ${groups.fs}
|
|
984
1090
|
skills ${groups.skills}
|
|
985
1091
|
search Search formal Names in the current swarm
|
|
986
1092
|
publish ${commandHelp.publish!.summary}
|
|
@@ -1023,6 +1129,7 @@ ${footer}`;
|
|
|
1023
1129
|
...([
|
|
1024
1130
|
"swarm status",
|
|
1025
1131
|
"swarm members",
|
|
1132
|
+
"swarm replicate",
|
|
1026
1133
|
"swarm update",
|
|
1027
1134
|
"swarm resume",
|
|
1028
1135
|
"swarm profile",
|
|
@@ -1188,6 +1295,7 @@ interface Parsed {
|
|
|
1188
1295
|
parameters?: string[];
|
|
1189
1296
|
registrySwarms?: string[];
|
|
1190
1297
|
agents?: string[];
|
|
1298
|
+
types?: string[];
|
|
1191
1299
|
help: boolean;
|
|
1192
1300
|
version: boolean;
|
|
1193
1301
|
}
|
|
@@ -1205,6 +1313,7 @@ async function closeStore(
|
|
|
1205
1313
|
try {
|
|
1206
1314
|
await store?.close();
|
|
1207
1315
|
} catch (error) {
|
|
1316
|
+
const { message } = await import("./errors.js");
|
|
1208
1317
|
throw new HostError(
|
|
1209
1318
|
`Store cleanup failed: ${message(error)}`,
|
|
1210
1319
|
appExitCode || 1,
|
|
@@ -1326,6 +1435,7 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1326
1435
|
"store",
|
|
1327
1436
|
"swarm",
|
|
1328
1437
|
"skills",
|
|
1438
|
+
"fs",
|
|
1329
1439
|
].includes(group)
|
|
1330
1440
|
)
|
|
1331
1441
|
syntax(
|
|
@@ -1362,6 +1472,10 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1362
1472
|
syntax(
|
|
1363
1473
|
"Skills operations select exactly one Swarm; repeated --swarm is not supported.",
|
|
1364
1474
|
);
|
|
1475
|
+
if (group === "fs" && swarms.length > 1)
|
|
1476
|
+
syntax(
|
|
1477
|
+
"fs operations select at most one Swarm; repeated --swarm is not supported.",
|
|
1478
|
+
);
|
|
1365
1479
|
const separator = result.path === "register set" ? tokens.indexOf("--") : -1;
|
|
1366
1480
|
if (separator >= 0) result.template = tokens.splice(separator + 1);
|
|
1367
1481
|
if (separator >= 0) tokens.splice(separator);
|
|
@@ -1380,51 +1494,63 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1380
1494
|
const booleans = result.path.startsWith("skills ")
|
|
1381
1495
|
? result.path === "skills sync"
|
|
1382
1496
|
? ["dry-run", "yes", "override-existing", "force", "no-force"]
|
|
1383
|
-
:
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
? ["
|
|
1400
|
-
: result.path === "
|
|
1401
|
-
? ["
|
|
1402
|
-
: [
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
?
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
? ["
|
|
1417
|
-
: result.path === "
|
|
1418
|
-
? ["
|
|
1419
|
-
:
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1497
|
+
: result.path === "skills set"
|
|
1498
|
+
? ["global", "replace"]
|
|
1499
|
+
: result.path === "skills remove"
|
|
1500
|
+
? []
|
|
1501
|
+
: ["force", "no-force"]
|
|
1502
|
+
: result.path === "fs ls"
|
|
1503
|
+
? ["all", "recursive", "force", "no-force"]
|
|
1504
|
+
: result.path === "fs stat"
|
|
1505
|
+
? ["force", "no-force"]
|
|
1506
|
+
: result.path === "fs set"
|
|
1507
|
+
? ["replace"]
|
|
1508
|
+
: result.path === "doctor"
|
|
1509
|
+
? ["fix", "yes"]
|
|
1510
|
+
: result.path === "bundle build"
|
|
1511
|
+
? ["replace", "schema-only", "no-import"]
|
|
1512
|
+
: result.path === "build"
|
|
1513
|
+
? ["replace", "no-import"]
|
|
1514
|
+
: result.path === "publish"
|
|
1515
|
+
? ["snapshot"]
|
|
1516
|
+
: [
|
|
1517
|
+
"get",
|
|
1518
|
+
"templates render",
|
|
1519
|
+
"templates list",
|
|
1520
|
+
"templates show",
|
|
1521
|
+
].includes(result.path)
|
|
1522
|
+
? result.path === "templates render"
|
|
1523
|
+
? ["force", "no-force"]
|
|
1524
|
+
: result.path === "get"
|
|
1525
|
+
? ["raw", "force", "no-force"]
|
|
1526
|
+
: ["force", "no-force"]
|
|
1527
|
+
: result.path === "search"
|
|
1528
|
+
? ["all", "current", "force", "no-force"]
|
|
1529
|
+
: result.path === "swarm request"
|
|
1530
|
+
? ["pivot"]
|
|
1531
|
+
: result.path === "swarm approve"
|
|
1532
|
+
? ["yes", "again", "pivot"]
|
|
1533
|
+
: ["swarm status", "swarm members"].includes(
|
|
1534
|
+
result.path,
|
|
1535
|
+
)
|
|
1536
|
+
? ["local", "force", "no-force"]
|
|
1537
|
+
: [
|
|
1538
|
+
"swarm exclude",
|
|
1539
|
+
"swarm set",
|
|
1540
|
+
"swarm pivot grant",
|
|
1541
|
+
].includes(result.path)
|
|
1542
|
+
? ["yes"]
|
|
1543
|
+
: result.path === "register set"
|
|
1544
|
+
? ["replace"]
|
|
1545
|
+
: result.path === "history remove"
|
|
1546
|
+
? ["yes"]
|
|
1547
|
+
: result.path === "open"
|
|
1548
|
+
? ["log", "raw", "force", "no-force"]
|
|
1549
|
+
: result.path === "pin"
|
|
1550
|
+
? ["force", "no-force"]
|
|
1551
|
+
: result.path === "daemon ui"
|
|
1552
|
+
? ["open"]
|
|
1553
|
+
: [];
|
|
1428
1554
|
if (booleans.includes("force")) booleans.push("refresh", "no-refresh");
|
|
1429
1555
|
const values =
|
|
1430
1556
|
result.path === "swarm create"
|
|
@@ -1435,35 +1561,43 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1435
1561
|
? ["output"]
|
|
1436
1562
|
: result.path === "swarm profile"
|
|
1437
1563
|
? ["address", "pivot"]
|
|
1438
|
-
: result.path === "swarm
|
|
1439
|
-
? ["
|
|
1440
|
-
: result.path === "swarm
|
|
1441
|
-
? []
|
|
1442
|
-
:
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1564
|
+
: result.path === "swarm replicate"
|
|
1565
|
+
? ["pivot"]
|
|
1566
|
+
: result.path === "swarm update" || result.path === "profile"
|
|
1567
|
+
? ["name", "description"]
|
|
1568
|
+
: result.path === "swarm approve"
|
|
1569
|
+
? []
|
|
1570
|
+
: [
|
|
1571
|
+
"publish",
|
|
1572
|
+
"templates set",
|
|
1573
|
+
"templates remove",
|
|
1574
|
+
"fs set",
|
|
1575
|
+
"fs rm",
|
|
1576
|
+
].includes(result.path)
|
|
1577
|
+
? ["expect"]
|
|
1578
|
+
: result.path === "get"
|
|
1579
|
+
? ["output"]
|
|
1580
|
+
: result.path === "search"
|
|
1581
|
+
? ["prefix", "kind", "schema", "limit", "offset"]
|
|
1582
|
+
: result.path === "templates render"
|
|
1583
|
+
? ["description"]
|
|
1584
|
+
: result.path === "bundle build" ||
|
|
1585
|
+
result.path === "build"
|
|
1586
|
+
? ["output"]
|
|
1587
|
+
: result.path === "history list"
|
|
1588
|
+
? [
|
|
1589
|
+
"app",
|
|
1590
|
+
"status",
|
|
1591
|
+
"since",
|
|
1592
|
+
"until",
|
|
1593
|
+
"limit",
|
|
1594
|
+
"before",
|
|
1595
|
+
]
|
|
1596
|
+
: result.path === "history remove"
|
|
1597
|
+
? ["app", "status", "since", "until"]
|
|
1598
|
+
: result.path === "skills remove"
|
|
1599
|
+
? ["global"]
|
|
1600
|
+
: [];
|
|
1467
1601
|
while (tokens.length) {
|
|
1468
1602
|
const value = tokens.shift()!;
|
|
1469
1603
|
if (
|
|
@@ -1483,6 +1617,21 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1483
1617
|
(result.agents ??= []).push(input);
|
|
1484
1618
|
continue;
|
|
1485
1619
|
}
|
|
1620
|
+
if (
|
|
1621
|
+
(result.path === "skills set" || result.path === "skills remove") &&
|
|
1622
|
+
option === "type"
|
|
1623
|
+
) {
|
|
1624
|
+
const input = tokens.shift();
|
|
1625
|
+
if (!input || input.startsWith("-")) syntax("--type needs a value.");
|
|
1626
|
+
(result.types ??= []).push(input);
|
|
1627
|
+
continue;
|
|
1628
|
+
}
|
|
1629
|
+
if (
|
|
1630
|
+
result.path === "skills remove" &&
|
|
1631
|
+
option === "global" &&
|
|
1632
|
+
Object.hasOwn(result.options, "global")
|
|
1633
|
+
)
|
|
1634
|
+
syntax("--global may be specified at most once.");
|
|
1486
1635
|
if (result.path.startsWith("register ") && option === "swarm") {
|
|
1487
1636
|
const input = tokens.shift();
|
|
1488
1637
|
if (!input || input.startsWith("-")) syntax("--swarm needs a value.");
|
|
@@ -1551,11 +1700,39 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1551
1700
|
syntax(
|
|
1552
1701
|
"register list accepts --swarm at most once. Select one Swarm or omit it to use the current Swarm.",
|
|
1553
1702
|
);
|
|
1703
|
+
if (result.path === "skills set") {
|
|
1704
|
+
if (!result.options.global && !(result.types?.length ?? 0))
|
|
1705
|
+
syntax("skills set requires --global and/or at least one --type SCHEMA.");
|
|
1706
|
+
for (const schema of result.types ?? [])
|
|
1707
|
+
if (!schema.startsWith("builtin:")) exactCid(schema, true);
|
|
1708
|
+
}
|
|
1709
|
+
if (result.path === "skills remove") {
|
|
1710
|
+
if (
|
|
1711
|
+
typeof result.options.global !== "string" &&
|
|
1712
|
+
!(result.types?.length ?? 0)
|
|
1713
|
+
)
|
|
1714
|
+
syntax(
|
|
1715
|
+
"skills remove requires --global NAME and/or at least one --type SCHEMA.",
|
|
1716
|
+
);
|
|
1717
|
+
if (
|
|
1718
|
+
typeof result.options.global === "string" &&
|
|
1719
|
+
(!/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(result.options.global) ||
|
|
1720
|
+
result.options.global.length > 64)
|
|
1721
|
+
)
|
|
1722
|
+
syntax(
|
|
1723
|
+
`Invalid global Skill name "${result.options.global}". Expected lowercase kebab-case (1..64 characters).`,
|
|
1724
|
+
);
|
|
1725
|
+
for (const schema of result.types ?? [])
|
|
1726
|
+
if (!schema.startsWith("builtin:")) exactCid(schema, true);
|
|
1727
|
+
}
|
|
1554
1728
|
const counts: Record<string, [number, number]> = {
|
|
1555
1729
|
daemon: [0, 0],
|
|
1556
1730
|
"daemon ui": [0, 0],
|
|
1557
1731
|
doctor: [0, 0],
|
|
1558
1732
|
"skills list": [0, 0],
|
|
1733
|
+
"skills show": [1, 1],
|
|
1734
|
+
"skills set": [1, 1],
|
|
1735
|
+
"skills remove": [0, 0],
|
|
1559
1736
|
"skills sync": [0, Number.MAX_SAFE_INTEGER],
|
|
1560
1737
|
profile: [0, 0],
|
|
1561
1738
|
"swarm create": [0, 0],
|
|
@@ -1567,6 +1744,7 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1567
1744
|
"swarm resume": [0, 0],
|
|
1568
1745
|
"swarm profile": [0, 0],
|
|
1569
1746
|
"swarm status": [0, 0],
|
|
1747
|
+
"swarm replicate": [0, 0],
|
|
1570
1748
|
"swarm members": [0, 0],
|
|
1571
1749
|
"swarm list": [0, 0],
|
|
1572
1750
|
"swarm set": [2, 2],
|
|
@@ -1593,6 +1771,10 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1593
1771
|
"templates show": [1, 1],
|
|
1594
1772
|
"templates set": [2, 2],
|
|
1595
1773
|
"templates remove": [1, 1],
|
|
1774
|
+
"fs ls": [0, 1],
|
|
1775
|
+
"fs stat": [1, 1],
|
|
1776
|
+
"fs set": [2, 2],
|
|
1777
|
+
"fs rm": [1, 1],
|
|
1596
1778
|
"config get": [0, 1],
|
|
1597
1779
|
"config set": [2, 2],
|
|
1598
1780
|
"config reset": [1, 1],
|
|
@@ -1669,6 +1851,37 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1669
1851
|
if (result.path === "templates remove" && !result.options.expect)
|
|
1670
1852
|
syntax("templates remove requires --expect OLD_TARGET_CID.");
|
|
1671
1853
|
}
|
|
1854
|
+
if (result.path === "fs ls" && result.positional[0] !== undefined) {
|
|
1855
|
+
normalizeSwarmFsPath(result.positional[0], {
|
|
1856
|
+
allowRoot: true,
|
|
1857
|
+
allowTrailingSlash: true,
|
|
1858
|
+
});
|
|
1859
|
+
}
|
|
1860
|
+
if (result.path === "fs stat") {
|
|
1861
|
+
normalizeSwarmFsPath(result.positional[0], {
|
|
1862
|
+
allowRoot: true,
|
|
1863
|
+
allowTrailingSlash: true,
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
if (result.path === "fs set") {
|
|
1867
|
+
normalizeSwarmFsPath(result.positional[0], {
|
|
1868
|
+
allowRoot: false,
|
|
1869
|
+
allowTrailingSlash: false,
|
|
1870
|
+
});
|
|
1871
|
+
exactCid(result.positional[1]!);
|
|
1872
|
+
if (typeof result.options.expect === "string")
|
|
1873
|
+
exactCid(result.options.expect);
|
|
1874
|
+
if (result.options.expect !== undefined && result.options.replace)
|
|
1875
|
+
syntax("--expect and --replace are mutually exclusive.");
|
|
1876
|
+
}
|
|
1877
|
+
if (result.path === "fs rm") {
|
|
1878
|
+
normalizeSwarmFsPath(result.positional[0], {
|
|
1879
|
+
allowRoot: false,
|
|
1880
|
+
allowTrailingSlash: false,
|
|
1881
|
+
});
|
|
1882
|
+
if (typeof result.options.expect === "string")
|
|
1883
|
+
exactCid(result.options.expect);
|
|
1884
|
+
}
|
|
1672
1885
|
if (result.path.startsWith("config ") && result.positional[0]) {
|
|
1673
1886
|
if (
|
|
1674
1887
|
!(result.path === "config get" && result.positional[0] === "state-dir") &&
|
|
@@ -1724,6 +1937,7 @@ async function performCli(
|
|
|
1724
1937
|
if (parsed.path === "history remove" && !parsed.options.yes && !io.tty)
|
|
1725
1938
|
syntax("Non-interactive history remove requires --yes.");
|
|
1726
1939
|
if (parsed.path === "doctor") {
|
|
1940
|
+
const { doctorDevice, doctorText } = await import("./doctor.js");
|
|
1727
1941
|
const controller = new AbortController();
|
|
1728
1942
|
const interrupt = () => {
|
|
1729
1943
|
controller.abort(new HostError("Doctor interrupted.", 130, "ABORTED"));
|
|
@@ -1756,6 +1970,7 @@ async function performCli(
|
|
|
1756
1970
|
}
|
|
1757
1971
|
}
|
|
1758
1972
|
if (parsed.path === "daemon ui") {
|
|
1973
|
+
const { daemonEndpoint, openLoopbackUrl } = await import("./daemon.js");
|
|
1759
1974
|
const stateDir = stateLocation(parsed.flags, env).path;
|
|
1760
1975
|
const endpoint = await daemonEndpoint(stateDir);
|
|
1761
1976
|
if (!endpoint)
|
|
@@ -1773,7 +1988,10 @@ async function performCli(
|
|
|
1773
1988
|
);
|
|
1774
1989
|
return 0;
|
|
1775
1990
|
}
|
|
1776
|
-
const builtins =
|
|
1991
|
+
const builtins =
|
|
1992
|
+
parsed.path === "swarm list"
|
|
1993
|
+
? { pins: [], blocks: new Map<string, Uint8Array>() }
|
|
1994
|
+
: await (await import("./builtins.js")).builtinContent();
|
|
1777
1995
|
state = new State(
|
|
1778
1996
|
stateLocation(parsed.flags, env).path,
|
|
1779
1997
|
builtins.pins,
|
|
@@ -1872,9 +2090,6 @@ async function performCli(
|
|
|
1872
2090
|
? { pointerApiKey: String(value("pointers.apiKey")) }
|
|
1873
2091
|
: {}),
|
|
1874
2092
|
});
|
|
1875
|
-
const filter = parsed.path.startsWith("history ")
|
|
1876
|
-
? filters(state, parsed.options)
|
|
1877
|
-
: {};
|
|
1878
2093
|
const selection = () => {
|
|
1879
2094
|
const saved = state!.config({ includeSecrets: false });
|
|
1880
2095
|
const current = effectiveConfig(saved, parsed.flags, env, (reference) =>
|
|
@@ -1896,6 +2111,128 @@ async function performCli(
|
|
|
1896
2111
|
io.err(
|
|
1897
2112
|
`Legacy local pin names are inactive: ${state.legacyPinCount} records are preserved in legacy_named_pins under ${state.directory}. Retention and original Store owners are unchanged; inspect ipab pin list and release intended archived holders with ipab unpin EXACT_CID.`,
|
|
1898
2113
|
);
|
|
2114
|
+
if (parsed.path === "swarm list") {
|
|
2115
|
+
const result = { swarms: state.allSwarms(), ...selection() };
|
|
2116
|
+
emit(
|
|
2117
|
+
{
|
|
2118
|
+
...result,
|
|
2119
|
+
swarms: result.swarms.map((entry) => ({
|
|
2120
|
+
configUrl: entry.cid,
|
|
2121
|
+
alias: entry.alias,
|
|
2122
|
+
local: Boolean(entry.local),
|
|
2123
|
+
})),
|
|
2124
|
+
},
|
|
2125
|
+
[
|
|
2126
|
+
...alignedRows(
|
|
2127
|
+
result.swarms.map((entry) => [
|
|
2128
|
+
`${entry.cid === result.effectiveCurrent ? "*" : " "} ${entry.alias ?? entry.cid}${entry.local ? " [local]" : ""}`,
|
|
2129
|
+
entry.cid,
|
|
2130
|
+
]),
|
|
2131
|
+
),
|
|
2132
|
+
...(result.source === "flag" &&
|
|
2133
|
+
result.effectiveCurrent !== result.savedCurrent
|
|
2134
|
+
? [
|
|
2135
|
+
`Selected via --swarm: ${printable(String(result.swarms.find((entry) => entry.cid === result.effectiveCurrent)?.alias ?? result.effectiveCurrent ?? "(none)"))}; saved default: ${printable(String(result.swarms.find((entry) => entry.cid === result.savedCurrent)?.alias ?? result.savedCurrent ?? "(none)"))}.`,
|
|
2136
|
+
]
|
|
2137
|
+
: []),
|
|
2138
|
+
].join("\n"),
|
|
2139
|
+
);
|
|
2140
|
+
return 0;
|
|
2141
|
+
}
|
|
2142
|
+
const [
|
|
2143
|
+
{ ContentError, IpfsStore },
|
|
2144
|
+
{ ContentBundleError, openBundle },
|
|
2145
|
+
{ message },
|
|
2146
|
+
{
|
|
2147
|
+
filters,
|
|
2148
|
+
listHistory,
|
|
2149
|
+
selectedIds,
|
|
2150
|
+
Ownership,
|
|
2151
|
+
recoverInactive,
|
|
2152
|
+
removeHistory,
|
|
2153
|
+
},
|
|
2154
|
+
{ execute },
|
|
2155
|
+
{ validatedBundle },
|
|
2156
|
+
{
|
|
2157
|
+
buildBundle,
|
|
2158
|
+
inspectBundle,
|
|
2159
|
+
importBundle,
|
|
2160
|
+
nodeError,
|
|
2161
|
+
resolveLocalBundleInput,
|
|
2162
|
+
snapshotLocalBundle,
|
|
2163
|
+
},
|
|
2164
|
+
{ initApp },
|
|
2165
|
+
{ assembleBundle },
|
|
2166
|
+
{ getBundle },
|
|
2167
|
+
{ ensureDaemon, serveDaemon },
|
|
2168
|
+
{ keyId },
|
|
2169
|
+
{
|
|
2170
|
+
createSwarm,
|
|
2171
|
+
swarmDaemon,
|
|
2172
|
+
requestMembership,
|
|
2173
|
+
approveMembership,
|
|
2174
|
+
grantPivotAuthority,
|
|
2175
|
+
exportRequest,
|
|
2176
|
+
removeMember,
|
|
2177
|
+
resumeRemoval,
|
|
2178
|
+
updateProfile,
|
|
2179
|
+
accountProfile,
|
|
2180
|
+
updateAccountProfile,
|
|
2181
|
+
swarmMembers,
|
|
2182
|
+
inspectSwarmStatus,
|
|
2183
|
+
verifiedRequest,
|
|
2184
|
+
verifiedRequestStream,
|
|
2185
|
+
membershipRequestSummary,
|
|
2186
|
+
updateSwarm,
|
|
2187
|
+
searchNames,
|
|
2188
|
+
resolveReference,
|
|
2189
|
+
publish,
|
|
2190
|
+
pinNameSubscription,
|
|
2191
|
+
pinReference,
|
|
2192
|
+
swarmRegistrations,
|
|
2193
|
+
swarmAssociation,
|
|
2194
|
+
setSwarmAssociation,
|
|
2195
|
+
removeSwarmAssociation,
|
|
2196
|
+
resolveTemplateSelector,
|
|
2197
|
+
swarmTemplates,
|
|
2198
|
+
setSwarmTemplate,
|
|
2199
|
+
removeSwarmTemplate,
|
|
2200
|
+
artifactValue,
|
|
2201
|
+
swarmTypeSkills,
|
|
2202
|
+
swarmTypeSkill,
|
|
2203
|
+
setSwarmSkill,
|
|
2204
|
+
removeSwarmSkill,
|
|
2205
|
+
},
|
|
2206
|
+
{ schemaAlias },
|
|
2207
|
+
{ unpin, pinDetails },
|
|
2208
|
+
{ publicationSource },
|
|
2209
|
+
{ templateRenderExample, templateOutputTree, templateParameterRows },
|
|
2210
|
+
{ logFiles },
|
|
2211
|
+
{ manageSkills, syncDaemonSwarm },
|
|
2212
|
+
] = await Promise.all([
|
|
2213
|
+
import("@ipab/ipfs-store"),
|
|
2214
|
+
import("@ipab/bundle"),
|
|
2215
|
+
import("./errors.js"),
|
|
2216
|
+
import("./history.js"),
|
|
2217
|
+
import("./runtime.js"),
|
|
2218
|
+
import("./space.js"),
|
|
2219
|
+
import("./authoring.js"),
|
|
2220
|
+
import("./app-authoring.js"),
|
|
2221
|
+
import("./assembly.js"),
|
|
2222
|
+
import("./get.js"),
|
|
2223
|
+
import("./daemon.js"),
|
|
2224
|
+
import("@ipab/bundle/pointer/crypto"),
|
|
2225
|
+
import("./swarm.js"),
|
|
2226
|
+
import("./app-definition.js"),
|
|
2227
|
+
import("./pins.js"),
|
|
2228
|
+
import("./publish-source.js"),
|
|
2229
|
+
import("./template-presentation.js"),
|
|
2230
|
+
import("./logs.js"),
|
|
2231
|
+
import("./skills.js"),
|
|
2232
|
+
]);
|
|
2233
|
+
const filter = parsed.path.startsWith("history ")
|
|
2234
|
+
? filters(state, parsed.options)
|
|
2235
|
+
: {};
|
|
1899
2236
|
if (
|
|
1900
2237
|
parsed.path.startsWith("templates ") &&
|
|
1901
2238
|
parsed.path !== "templates render"
|
|
@@ -1911,7 +2248,7 @@ async function performCli(
|
|
|
1911
2248
|
if (parsed.path === "templates list") {
|
|
1912
2249
|
const items = await swarmTemplates(context, configUrl);
|
|
1913
2250
|
const alias = state
|
|
1914
|
-
.
|
|
2251
|
+
.allSwarms()
|
|
1915
2252
|
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1916
2253
|
emit(
|
|
1917
2254
|
{ items },
|
|
@@ -1931,7 +2268,7 @@ async function performCli(
|
|
|
1931
2268
|
if (parsed.flags.json) io.out(JSON.stringify(item));
|
|
1932
2269
|
else {
|
|
1933
2270
|
const alias = state
|
|
1934
|
-
.
|
|
2271
|
+
.allSwarms()
|
|
1935
2272
|
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1936
2273
|
const swarm = alias ?? configUrl;
|
|
1937
2274
|
const reference = formatNameReference(swarm, item.name);
|
|
@@ -2045,65 +2382,96 @@ async function performCli(
|
|
|
2045
2382
|
const completed: string[] = [];
|
|
2046
2383
|
const human: string[] = [];
|
|
2047
2384
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2385
|
+
const localApp =
|
|
2386
|
+
parsed.path === "register set" && !parseNameReference(second!)
|
|
2387
|
+
? await resolveLocalBundleInput(second!)
|
|
2388
|
+
: undefined;
|
|
2389
|
+
let registerOwner: HistoryOwnership | undefined;
|
|
2390
|
+
let localAppCid: string | undefined;
|
|
2391
|
+
try {
|
|
2392
|
+
if (localApp) {
|
|
2393
|
+
const session = `register:${randomUUID()}`;
|
|
2394
|
+
registerOwner = await Ownership.create(
|
|
2395
|
+
state,
|
|
2396
|
+
store,
|
|
2397
|
+
`register:${randomUUID()}`,
|
|
2398
|
+
session,
|
|
2399
|
+
);
|
|
2400
|
+
localAppCid = await snapshotLocalBundle(
|
|
2401
|
+
localApp,
|
|
2402
|
+
registerOwner,
|
|
2403
|
+
session,
|
|
2404
|
+
{
|
|
2405
|
+
diagnostic: (text) => {
|
|
2406
|
+
io.err(text);
|
|
2407
|
+
},
|
|
2408
|
+
},
|
|
2409
|
+
);
|
|
2410
|
+
}
|
|
2411
|
+
for (const configUrl of targets) {
|
|
2412
|
+
const context = swarmContext();
|
|
2413
|
+
try {
|
|
2414
|
+
if (parsed.path === "register list") {
|
|
2415
|
+
const items = await swarmRegistrations(context, configUrl);
|
|
2416
|
+
const alias = state
|
|
2417
|
+
.allSwarms()
|
|
2418
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
2419
|
+
results.push({ items });
|
|
2420
|
+
human.push(
|
|
2421
|
+
`Swarm: ${alias ? printable(alias) : "(no local alias)"}\nConfig URL: ${configUrl}\nAssociations: ${items.length}\n\n${table(
|
|
2422
|
+
["TYPE CID", "APP CID"],
|
|
2423
|
+
items.map((item) => [item.schemaCid, item.appCid]),
|
|
2424
|
+
"No associations registered in this Swarm.\nRegister an App: ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS",
|
|
2425
|
+
)}`,
|
|
2426
|
+
);
|
|
2427
|
+
} else if (parsed.path === "register set") {
|
|
2428
|
+
const appCid =
|
|
2429
|
+
localAppCid ??
|
|
2430
|
+
(parseNameReference(second!)
|
|
2431
|
+
? (
|
|
2432
|
+
await resolveReference(
|
|
2433
|
+
context,
|
|
2434
|
+
second!,
|
|
2435
|
+
configUrl,
|
|
2436
|
+
(reference) => state!.resolve(reference),
|
|
2437
|
+
)
|
|
2438
|
+
).cid
|
|
2439
|
+
: state.resolve(second!));
|
|
2440
|
+
const association = await setSwarmAssociation(
|
|
2441
|
+
context,
|
|
2442
|
+
configUrl,
|
|
2443
|
+
createAssociation(schema!, appCid, parsed.template ?? ["%"]),
|
|
2444
|
+
Boolean(parsed.options.replace),
|
|
2445
|
+
);
|
|
2446
|
+
results.push({ association });
|
|
2447
|
+
human.push(
|
|
2448
|
+
`${configUrl}: ${association.schemaCid} → ${association.appCid} ${JSON.stringify(association.argv)}`,
|
|
2449
|
+
);
|
|
2450
|
+
} else {
|
|
2451
|
+
const removed = await removeSwarmAssociation(
|
|
2452
|
+
context,
|
|
2453
|
+
configUrl,
|
|
2454
|
+
schema!,
|
|
2455
|
+
);
|
|
2456
|
+
results.push({ removed: [removed] });
|
|
2457
|
+
human.push(`${configUrl}: removed association for ${removed}.`);
|
|
2458
|
+
}
|
|
2459
|
+
completed.push(configUrl);
|
|
2460
|
+
} catch (cause) {
|
|
2461
|
+
throw new HostError(
|
|
2462
|
+
parsed.path === "register list"
|
|
2463
|
+
? `Cannot list associations for Swarm ${configUrl}: ${message(cause)}`
|
|
2464
|
+
: `Registry operation failed for ${configUrl}: ${message(cause)}. Completed Swarms: ${completed.length ? completed.join(", ") : "(none)"}. Multiple Swarm edits are not atomic.`,
|
|
2465
|
+
cause instanceof HostError ? cause.exitCode : 1,
|
|
2466
|
+
cause instanceof HostError ? cause.code : "REGISTRY_FAILED",
|
|
2467
|
+
"publication",
|
|
2090
2468
|
);
|
|
2091
|
-
|
|
2092
|
-
|
|
2469
|
+
} finally {
|
|
2470
|
+
await context.finishRead?.();
|
|
2093
2471
|
}
|
|
2094
|
-
completed.push(configUrl);
|
|
2095
|
-
} catch (cause) {
|
|
2096
|
-
throw new HostError(
|
|
2097
|
-
parsed.path === "register list"
|
|
2098
|
-
? `Cannot list associations for Swarm ${configUrl}: ${message(cause)}`
|
|
2099
|
-
: `Registry operation failed for ${configUrl}: ${message(cause)}. Completed Swarms: ${completed.length ? completed.join(", ") : "(none)"}. Multiple Swarm edits are not atomic.`,
|
|
2100
|
-
cause instanceof HostError ? cause.exitCode : 1,
|
|
2101
|
-
cause instanceof HostError ? cause.code : "REGISTRY_FAILED",
|
|
2102
|
-
"publication",
|
|
2103
|
-
);
|
|
2104
|
-
} finally {
|
|
2105
|
-
await context.finishRead?.();
|
|
2106
2472
|
}
|
|
2473
|
+
} finally {
|
|
2474
|
+
await registerOwner?.release();
|
|
2107
2475
|
}
|
|
2108
2476
|
emit(
|
|
2109
2477
|
{
|
|
@@ -2157,36 +2525,6 @@ async function performCli(
|
|
|
2157
2525
|
}
|
|
2158
2526
|
break;
|
|
2159
2527
|
}
|
|
2160
|
-
case "swarm list": {
|
|
2161
|
-
const result = { swarms: state.swarms(), ...selection() };
|
|
2162
|
-
emit(
|
|
2163
|
-
{
|
|
2164
|
-
...result,
|
|
2165
|
-
swarms: result.swarms.map((entry) => ({
|
|
2166
|
-
configUrl: entry.cid,
|
|
2167
|
-
alias: entry.alias,
|
|
2168
|
-
})),
|
|
2169
|
-
},
|
|
2170
|
-
[
|
|
2171
|
-
...alignedRows(
|
|
2172
|
-
result.swarms.map((entry) => [
|
|
2173
|
-
`${entry.cid === result.effectiveCurrent ? "*" : " "} ${entry.alias ?? entry.cid}`,
|
|
2174
|
-
entry.cid,
|
|
2175
|
-
]),
|
|
2176
|
-
),
|
|
2177
|
-
...(result.swarms.length ? [] : ["No registered Swarms."]),
|
|
2178
|
-
...(result.effectiveCurrent === null
|
|
2179
|
-
? ["Use ipab swarm use <alias> to select a default Swarm."]
|
|
2180
|
-
: []),
|
|
2181
|
-
...(result.effectiveCurrent !== result.savedCurrent
|
|
2182
|
-
? [
|
|
2183
|
-
`Selected via --swarm: ${printable(String(result.swarms.find((entry) => entry.cid === result.effectiveCurrent)?.alias ?? result.effectiveCurrent ?? "(none)"))}; saved default: ${printable(String(result.swarms.find((entry) => entry.cid === result.savedCurrent)?.alias ?? result.savedCurrent ?? "(none)"))}.`,
|
|
2184
|
-
]
|
|
2185
|
-
: []),
|
|
2186
|
-
].join("\n"),
|
|
2187
|
-
);
|
|
2188
|
-
break;
|
|
2189
|
-
}
|
|
2190
2528
|
case "swarm use": {
|
|
2191
2529
|
state.useSwarm(first!);
|
|
2192
2530
|
const result = selection();
|
|
@@ -2267,6 +2605,9 @@ async function performCli(
|
|
|
2267
2605
|
case "swarm update":
|
|
2268
2606
|
case "search":
|
|
2269
2607
|
case "skills list":
|
|
2608
|
+
case "skills show":
|
|
2609
|
+
case "skills set":
|
|
2610
|
+
case "skills remove":
|
|
2270
2611
|
case "skills sync":
|
|
2271
2612
|
case "swarm create":
|
|
2272
2613
|
case "swarm request":
|
|
@@ -2278,15 +2619,502 @@ async function performCli(
|
|
|
2278
2619
|
case "swarm profile":
|
|
2279
2620
|
case "swarm members":
|
|
2280
2621
|
case "swarm status":
|
|
2622
|
+
case "swarm replicate":
|
|
2623
|
+
case "fs ls":
|
|
2624
|
+
case "fs stat":
|
|
2625
|
+
case "fs set":
|
|
2626
|
+
case "fs rm":
|
|
2281
2627
|
case "publish":
|
|
2282
2628
|
case "pin":
|
|
2283
2629
|
case "get": {
|
|
2284
2630
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
2285
2631
|
const context = swarmContext();
|
|
2286
2632
|
readContext = context;
|
|
2633
|
+
if (parsed.path.startsWith("fs ")) {
|
|
2634
|
+
const {
|
|
2635
|
+
listSwarmFsPath,
|
|
2636
|
+
removeSwarmFsPath,
|
|
2637
|
+
setSwarmFsPath,
|
|
2638
|
+
statSwarmFsPath,
|
|
2639
|
+
} = await import("./swarm-fs.js");
|
|
2640
|
+
const swarmUrlSelected = requireSwarm();
|
|
2641
|
+
const explicitRefresh: boolean | undefined =
|
|
2642
|
+
parsed.options.refresh || parsed.options.force
|
|
2643
|
+
? true
|
|
2644
|
+
: parsed.options["no-refresh"] || parsed.options["no-force"]
|
|
2645
|
+
? false
|
|
2646
|
+
: value("swarm.forceRefresh")
|
|
2647
|
+
? true
|
|
2648
|
+
: undefined;
|
|
2649
|
+
|
|
2650
|
+
if (parsed.path === "fs ls") {
|
|
2651
|
+
const result = await listSwarmFsPath(
|
|
2652
|
+
context,
|
|
2653
|
+
swarmUrlSelected,
|
|
2654
|
+
first,
|
|
2655
|
+
{
|
|
2656
|
+
all: Boolean(parsed.options.all),
|
|
2657
|
+
recursive: Boolean(parsed.options.recursive),
|
|
2658
|
+
mode: "local-first",
|
|
2659
|
+
...(explicitRefresh !== undefined
|
|
2660
|
+
? { forceRefresh: explicitRefresh }
|
|
2661
|
+
: {}),
|
|
2662
|
+
},
|
|
2663
|
+
);
|
|
2664
|
+
store = context.store;
|
|
2665
|
+
const text = result.entries.length
|
|
2666
|
+
? result.entries
|
|
2667
|
+
.map(
|
|
2668
|
+
(entry) =>
|
|
2669
|
+
`${result.recursive ? entry.path : entry.name}\t${entry.cid ?? "<dir>"}\t${entry.size !== null ? String(entry.size) : entry.kind}`,
|
|
2670
|
+
)
|
|
2671
|
+
.join("\n")
|
|
2672
|
+
: "No entries.";
|
|
2673
|
+
emit(result, text);
|
|
2674
|
+
if (result.truncated || result.skippedSubtrees > 0) {
|
|
2675
|
+
io.err(
|
|
2676
|
+
`Listing incomplete: truncated=${String(result.truncated)}, skippedSubtrees=${String(result.skippedSubtrees)}.`,
|
|
2677
|
+
);
|
|
2678
|
+
}
|
|
2679
|
+
break;
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
if (parsed.path === "fs stat") {
|
|
2683
|
+
const result = await statSwarmFsPath(
|
|
2684
|
+
context,
|
|
2685
|
+
swarmUrlSelected,
|
|
2686
|
+
first!,
|
|
2687
|
+
{
|
|
2688
|
+
mode: "local-first",
|
|
2689
|
+
...(explicitRefresh !== undefined
|
|
2690
|
+
? { forceRefresh: explicitRefresh }
|
|
2691
|
+
: {}),
|
|
2692
|
+
},
|
|
2693
|
+
);
|
|
2694
|
+
store = context.store;
|
|
2695
|
+
const lines = [
|
|
2696
|
+
`Path: ${result.path || "/"}`,
|
|
2697
|
+
`CID: ${result.cid ?? "(virtual)"}`,
|
|
2698
|
+
`Kind: ${result.kind}`,
|
|
2699
|
+
`Size: ${result.size !== null ? String(result.size) : "unavailable"}`,
|
|
2700
|
+
...(result.kind === "directory" && result.isBundle !== undefined
|
|
2701
|
+
? [`Bundle: ${result.isBundle ? "yes" : "no"}`]
|
|
2702
|
+
: []),
|
|
2703
|
+
...(result.kind === "directory" && result.entryCount !== undefined
|
|
2704
|
+
? [`Entries: ${result.entryCount}`]
|
|
2705
|
+
: []),
|
|
2706
|
+
`Swarm: ${result.swarm}`,
|
|
2707
|
+
`Snapshot: ${result.snapshotVersion === "legacy" ? "legacy (read-only virtual)" : "v7"}`,
|
|
2708
|
+
];
|
|
2709
|
+
emit(result, lines.join("\n"));
|
|
2710
|
+
break;
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
if (parsed.path === "fs set") {
|
|
2714
|
+
const result = await setSwarmFsPath(
|
|
2715
|
+
context,
|
|
2716
|
+
swarmUrlSelected,
|
|
2717
|
+
first!,
|
|
2718
|
+
second!,
|
|
2719
|
+
{
|
|
2720
|
+
...(typeof parsed.options.expect === "string"
|
|
2721
|
+
? { expect: parsed.options.expect }
|
|
2722
|
+
: {}),
|
|
2723
|
+
...(parsed.options.replace ? { replace: true } : {}),
|
|
2724
|
+
},
|
|
2725
|
+
);
|
|
2726
|
+
store = context.store;
|
|
2727
|
+
emit(
|
|
2728
|
+
result,
|
|
2729
|
+
result.changed
|
|
2730
|
+
? `Set ${result.path} -> ${result.cid} (HEAD ${result.headCid})`
|
|
2731
|
+
: `Unchanged ${result.path} -> ${result.cid} (HEAD ${result.headCid})`,
|
|
2732
|
+
);
|
|
2733
|
+
break;
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
const result = await removeSwarmFsPath(
|
|
2737
|
+
context,
|
|
2738
|
+
swarmUrlSelected,
|
|
2739
|
+
first!,
|
|
2740
|
+
{
|
|
2741
|
+
...(typeof parsed.options.expect === "string"
|
|
2742
|
+
? { expect: parsed.options.expect }
|
|
2743
|
+
: {}),
|
|
2744
|
+
},
|
|
2745
|
+
);
|
|
2746
|
+
store = context.store;
|
|
2747
|
+
emit(
|
|
2748
|
+
result,
|
|
2749
|
+
`Removed ${result.path} (was ${result.removedCid}, HEAD ${result.headCid})`,
|
|
2750
|
+
);
|
|
2751
|
+
break;
|
|
2752
|
+
}
|
|
2753
|
+
if (parsed.path === "swarm replicate") {
|
|
2754
|
+
const { replicateSwarm } = await import("./swarm.js");
|
|
2755
|
+
context.diagnostic = (text) => {
|
|
2756
|
+
io.err(text);
|
|
2757
|
+
};
|
|
2758
|
+
const result = await replicateSwarm(
|
|
2759
|
+
context,
|
|
2760
|
+
requireSwarm(),
|
|
2761
|
+
undefined,
|
|
2762
|
+
{
|
|
2763
|
+
...(typeof parsed.options.pivot === "string"
|
|
2764
|
+
? { pivot: parsed.options.pivot }
|
|
2765
|
+
: {}),
|
|
2766
|
+
},
|
|
2767
|
+
);
|
|
2768
|
+
store = context.store;
|
|
2769
|
+
emit(
|
|
2770
|
+
result,
|
|
2771
|
+
[
|
|
2772
|
+
`HEAD: ${result.headCid}`,
|
|
2773
|
+
...result.results.map(
|
|
2774
|
+
(entry) =>
|
|
2775
|
+
`${entry.peerId}: ${entry.status}${entry.error ? ` (${entry.error})` : ""}`,
|
|
2776
|
+
),
|
|
2777
|
+
].join("\n"),
|
|
2778
|
+
);
|
|
2779
|
+
break;
|
|
2780
|
+
}
|
|
2287
2781
|
if (parsed.path.startsWith("skills ")) {
|
|
2782
|
+
const explicitRefresh: boolean | undefined =
|
|
2783
|
+
parsed.options.refresh || parsed.options.force
|
|
2784
|
+
? true
|
|
2785
|
+
: parsed.options["no-refresh"] || parsed.options["no-force"]
|
|
2786
|
+
? false
|
|
2787
|
+
: value("swarm.forceRefresh")
|
|
2788
|
+
? true
|
|
2789
|
+
: undefined;
|
|
2790
|
+
const refreshOption =
|
|
2791
|
+
explicitRefresh !== undefined
|
|
2792
|
+
? { forceRefresh: explicitRefresh }
|
|
2793
|
+
: {};
|
|
2794
|
+
|
|
2795
|
+
if (parsed.path === "skills show") {
|
|
2796
|
+
const named = parseNameReference(first!);
|
|
2797
|
+
let targetSwarm: string;
|
|
2798
|
+
let schemaCid: string;
|
|
2799
|
+
let resolvedFrom: "uri" | "local" | "schema" | "content";
|
|
2800
|
+
let contentCid: string | undefined;
|
|
2801
|
+
let reference: string | undefined;
|
|
2802
|
+
let association:
|
|
2803
|
+
Awaited<ReturnType<typeof swarmTypeSkill>> | undefined;
|
|
2804
|
+
|
|
2805
|
+
if (named) {
|
|
2806
|
+
targetSwarm = named.swarm
|
|
2807
|
+
? state.resolveSwarm(named.swarm)
|
|
2808
|
+
: requireSwarm();
|
|
2809
|
+
const resolved = await resolveReference(
|
|
2810
|
+
context,
|
|
2811
|
+
first!,
|
|
2812
|
+
targetSwarm,
|
|
2813
|
+
(ref) => state!.resolve(ref),
|
|
2814
|
+
false,
|
|
2815
|
+
"local-first",
|
|
2816
|
+
);
|
|
2817
|
+
store = context.store;
|
|
2818
|
+
contentCid = resolved.cid;
|
|
2819
|
+
reference = first!;
|
|
2820
|
+
const bundle = await openBundle(CID.parse(contentCid), {
|
|
2821
|
+
resolveCid: (key) => context.store.block.get(key.toString()),
|
|
2822
|
+
});
|
|
2823
|
+
schemaCid = bundle.schemaKey;
|
|
2824
|
+
resolvedFrom = "uri";
|
|
2825
|
+
association = await swarmTypeSkill(
|
|
2826
|
+
context,
|
|
2827
|
+
targetSwarm,
|
|
2828
|
+
schemaCid,
|
|
2829
|
+
{
|
|
2830
|
+
mode: "local-first",
|
|
2831
|
+
...refreshOption,
|
|
2832
|
+
},
|
|
2833
|
+
);
|
|
2834
|
+
} else {
|
|
2835
|
+
targetSwarm = requireSwarm();
|
|
2836
|
+
const localInput = await resolveLocalBundleInput(first!);
|
|
2837
|
+
if (localInput) {
|
|
2838
|
+
const session = `skills-show:${randomUUID()}`;
|
|
2839
|
+
const owner = await Ownership.create(
|
|
2840
|
+
state,
|
|
2841
|
+
store,
|
|
2842
|
+
`skills-show:${randomUUID()}`,
|
|
2843
|
+
session,
|
|
2844
|
+
);
|
|
2845
|
+
try {
|
|
2846
|
+
const root = await snapshotLocalBundle(
|
|
2847
|
+
localInput,
|
|
2848
|
+
owner,
|
|
2849
|
+
session,
|
|
2850
|
+
{
|
|
2851
|
+
diagnostic: (text) => {
|
|
2852
|
+
io.err(text);
|
|
2853
|
+
},
|
|
2854
|
+
},
|
|
2855
|
+
);
|
|
2856
|
+
contentCid = await artifactValue(store, root);
|
|
2857
|
+
const bundle = await openBundle(CID.parse(contentCid), {
|
|
2858
|
+
resolveCid: (key) => store!.block.get(key.toString()),
|
|
2859
|
+
});
|
|
2860
|
+
schemaCid = bundle.schemaKey;
|
|
2861
|
+
resolvedFrom = "local";
|
|
2862
|
+
association = await swarmTypeSkill(
|
|
2863
|
+
context,
|
|
2864
|
+
targetSwarm,
|
|
2865
|
+
schemaCid,
|
|
2866
|
+
{
|
|
2867
|
+
mode: "local-first",
|
|
2868
|
+
...refreshOption,
|
|
2869
|
+
},
|
|
2870
|
+
);
|
|
2871
|
+
} finally {
|
|
2872
|
+
await owner.release();
|
|
2873
|
+
}
|
|
2874
|
+
} else {
|
|
2875
|
+
const resolved = state.resolve(schemaAlias(first!));
|
|
2876
|
+
const parsedCid = CID.parse(resolved);
|
|
2877
|
+
const isSchemaCid =
|
|
2878
|
+
parsedCid.code === 0x71 && parsedCid.multihash.code === 0x12;
|
|
2879
|
+
schemaCid = resolved;
|
|
2880
|
+
resolvedFrom = "schema";
|
|
2881
|
+
if (isSchemaCid) {
|
|
2882
|
+
association = await swarmTypeSkill(
|
|
2883
|
+
context,
|
|
2884
|
+
targetSwarm,
|
|
2885
|
+
resolved,
|
|
2886
|
+
{
|
|
2887
|
+
mode: "local-first",
|
|
2888
|
+
...refreshOption,
|
|
2889
|
+
},
|
|
2890
|
+
);
|
|
2891
|
+
} else {
|
|
2892
|
+
const refResolved = await resolveReference(
|
|
2893
|
+
context,
|
|
2894
|
+
resolved,
|
|
2895
|
+
targetSwarm,
|
|
2896
|
+
(ref) => state!.resolve(ref),
|
|
2897
|
+
false,
|
|
2898
|
+
"local-first",
|
|
2899
|
+
);
|
|
2900
|
+
store = context.store;
|
|
2901
|
+
const bundle = await openBundle(CID.parse(refResolved.cid), {
|
|
2902
|
+
resolveCid: (key) =>
|
|
2903
|
+
context.store.block.get(key.toString()),
|
|
2904
|
+
});
|
|
2905
|
+
schemaCid = bundle.schemaKey;
|
|
2906
|
+
contentCid = refResolved.cid;
|
|
2907
|
+
resolvedFrom = "content";
|
|
2908
|
+
association = await swarmTypeSkill(
|
|
2909
|
+
context,
|
|
2910
|
+
targetSwarm,
|
|
2911
|
+
schemaCid,
|
|
2912
|
+
{
|
|
2913
|
+
mode: "local-first",
|
|
2914
|
+
...refreshOption,
|
|
2915
|
+
},
|
|
2916
|
+
);
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
store = context.store;
|
|
2921
|
+
if (!association)
|
|
2922
|
+
throw new HostError(
|
|
2923
|
+
`No Skill associated with Schema ${schemaCid} in Swarm ${targetSwarm}. Associate one with: ipab skills set SKILL --type ${schemaCid}`,
|
|
2924
|
+
1,
|
|
2925
|
+
"SKILL_NOT_FOUND",
|
|
2926
|
+
"state",
|
|
2927
|
+
);
|
|
2928
|
+
const payload = {
|
|
2929
|
+
swarm: targetSwarm,
|
|
2930
|
+
schemaCid,
|
|
2931
|
+
resolvedFrom,
|
|
2932
|
+
...(contentCid ? { contentCid } : {}),
|
|
2933
|
+
...(reference ? { reference } : {}),
|
|
2934
|
+
name: association.name,
|
|
2935
|
+
cid: association.cid,
|
|
2936
|
+
identity: association.identity,
|
|
2937
|
+
description: association.description,
|
|
2938
|
+
};
|
|
2939
|
+
const lines = [
|
|
2940
|
+
`Swarm: ${targetSwarm}`,
|
|
2941
|
+
`Schema: ${schemaCid}`,
|
|
2942
|
+
...(contentCid ? [`Content CID: ${contentCid}`] : []),
|
|
2943
|
+
`Skill: ${association.identity}`,
|
|
2944
|
+
`Skill CID: ${association.cid}`,
|
|
2945
|
+
`Path: ${association.name}`,
|
|
2946
|
+
`Description: ${association.description}`,
|
|
2947
|
+
];
|
|
2948
|
+
emit(payload, lines.join("\n"));
|
|
2949
|
+
break;
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
if (parsed.path === "skills set") {
|
|
2953
|
+
const targetSwarm = requireSwarm();
|
|
2954
|
+
const types = (parsed.types ?? []).map((schema) =>
|
|
2955
|
+
state!.resolve(schemaAlias(schema), true),
|
|
2956
|
+
);
|
|
2957
|
+
const localSkill = !parseNameReference(first!)
|
|
2958
|
+
? await resolveLocalBundleInput(first!)
|
|
2959
|
+
: undefined;
|
|
2960
|
+
let skillOwner: HistoryOwnership | undefined;
|
|
2961
|
+
try {
|
|
2962
|
+
let skillCid: string;
|
|
2963
|
+
if (localSkill) {
|
|
2964
|
+
const session = `skills-set:${randomUUID()}`;
|
|
2965
|
+
skillOwner = await Ownership.create(
|
|
2966
|
+
state,
|
|
2967
|
+
store,
|
|
2968
|
+
`skills-set:${randomUUID()}`,
|
|
2969
|
+
session,
|
|
2970
|
+
);
|
|
2971
|
+
skillCid = await snapshotLocalBundle(
|
|
2972
|
+
localSkill,
|
|
2973
|
+
skillOwner,
|
|
2974
|
+
session,
|
|
2975
|
+
{
|
|
2976
|
+
diagnostic: (text) => {
|
|
2977
|
+
io.err(text);
|
|
2978
|
+
},
|
|
2979
|
+
},
|
|
2980
|
+
);
|
|
2981
|
+
} else if (parseNameReference(first!)) {
|
|
2982
|
+
skillCid = (
|
|
2983
|
+
await resolveReference(
|
|
2984
|
+
context,
|
|
2985
|
+
first!,
|
|
2986
|
+
targetSwarm,
|
|
2987
|
+
(ref) => state!.resolve(ref),
|
|
2988
|
+
false,
|
|
2989
|
+
)
|
|
2990
|
+
).cid;
|
|
2991
|
+
store = context.store;
|
|
2992
|
+
} else {
|
|
2993
|
+
skillCid = state.resolve(first!);
|
|
2994
|
+
}
|
|
2995
|
+
const result = await setSwarmSkill(context, targetSwarm, {
|
|
2996
|
+
skillCid,
|
|
2997
|
+
global: Boolean(parsed.options.global),
|
|
2998
|
+
types,
|
|
2999
|
+
replace: Boolean(parsed.options.replace),
|
|
3000
|
+
});
|
|
3001
|
+
store = context.store;
|
|
3002
|
+
const text = result.changed
|
|
3003
|
+
? [
|
|
3004
|
+
`Skill: ${result.identity} (${result.cid})`,
|
|
3005
|
+
`HEAD: ${result.headCid}`,
|
|
3006
|
+
...result.targets.map((target) => {
|
|
3007
|
+
const status = !target.changed
|
|
3008
|
+
? "unchanged"
|
|
3009
|
+
: target.previousCid
|
|
3010
|
+
? "updated"
|
|
3011
|
+
: "created";
|
|
3012
|
+
return target.scope === "global"
|
|
3013
|
+
? ` global -> ${target.name} (${status})`
|
|
3014
|
+
: ` type ${target.schemaCid} -> ${target.name} (${status})`;
|
|
3015
|
+
}),
|
|
3016
|
+
].join("\n")
|
|
3017
|
+
: `Unchanged: ${result.identity} (${result.cid}) (HEAD ${result.headCid})`;
|
|
3018
|
+
emit(result, text);
|
|
3019
|
+
} finally {
|
|
3020
|
+
await skillOwner?.release();
|
|
3021
|
+
}
|
|
3022
|
+
break;
|
|
3023
|
+
}
|
|
3024
|
+
|
|
3025
|
+
if (parsed.path === "skills remove") {
|
|
3026
|
+
const targetSwarm = requireSwarm();
|
|
3027
|
+
const types = (parsed.types ?? []).map((schema) =>
|
|
3028
|
+
state!.resolve(schemaAlias(schema), true),
|
|
3029
|
+
);
|
|
3030
|
+
const globalName =
|
|
3031
|
+
typeof parsed.options.global === "string"
|
|
3032
|
+
? parsed.options.global
|
|
3033
|
+
: undefined;
|
|
3034
|
+
const result = await removeSwarmSkill(context, targetSwarm, {
|
|
3035
|
+
...(globalName !== undefined ? { globalName } : {}),
|
|
3036
|
+
types,
|
|
3037
|
+
});
|
|
3038
|
+
store = context.store;
|
|
3039
|
+
const lines = [
|
|
3040
|
+
`Removed ${result.removed.length} Skill association(s) (HEAD ${result.headCid}):`,
|
|
3041
|
+
...result.removed.map((entry) =>
|
|
3042
|
+
entry.scope === "global"
|
|
3043
|
+
? ` global ${entry.name} (was ${entry.removedCid})`
|
|
3044
|
+
: ` type ${entry.schemaCid} ${entry.name} (was ${entry.removedCid})`,
|
|
3045
|
+
),
|
|
3046
|
+
];
|
|
3047
|
+
emit(result, lines.join("\n"));
|
|
3048
|
+
break;
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
if (parsed.path === "skills list") {
|
|
3052
|
+
const targetSwarm = requireSwarm();
|
|
3053
|
+
const managed = await manageSkills(context, targetSwarm, {
|
|
3054
|
+
sync: false,
|
|
3055
|
+
names: parsed.positional,
|
|
3056
|
+
agents: parsed.agents ?? [],
|
|
3057
|
+
overrideExisting: false,
|
|
3058
|
+
dryRun: false,
|
|
3059
|
+
yes: false,
|
|
3060
|
+
tty: io.tty,
|
|
3061
|
+
confirm: (text) => io.confirm(text),
|
|
3062
|
+
preview: (text) => {
|
|
3063
|
+
io.err(text);
|
|
3064
|
+
},
|
|
3065
|
+
});
|
|
3066
|
+
const typeSkills = await swarmTypeSkills(context, targetSwarm, {
|
|
3067
|
+
mode: "local-first",
|
|
3068
|
+
...refreshOption,
|
|
3069
|
+
});
|
|
3070
|
+
const result = {
|
|
3071
|
+
swarm: managed.swarm,
|
|
3072
|
+
installer: managed.installer,
|
|
3073
|
+
agents: managed.agents,
|
|
3074
|
+
dryRun: managed.dryRun,
|
|
3075
|
+
items: managed.items,
|
|
3076
|
+
typeSkills,
|
|
3077
|
+
orphaned: managed.orphaned,
|
|
3078
|
+
results: managed.results,
|
|
3079
|
+
ok: managed.ok,
|
|
3080
|
+
};
|
|
3081
|
+
store = context.store;
|
|
3082
|
+
const globalLines = [
|
|
3083
|
+
table(
|
|
3084
|
+
["NAME", "PAYLOAD CID", "INSTALL NAME", "STATUS"],
|
|
3085
|
+
result.items.map((skill) => [
|
|
3086
|
+
skill.name,
|
|
3087
|
+
skill.cid,
|
|
3088
|
+
skill.identity,
|
|
3089
|
+
skill.status,
|
|
3090
|
+
]),
|
|
3091
|
+
"No Global Skills.",
|
|
3092
|
+
),
|
|
3093
|
+
...result.items.flatMap((skill) => skill.problems),
|
|
3094
|
+
...result.orphaned.map(
|
|
3095
|
+
(skill) =>
|
|
3096
|
+
`Source removed: ${skill.name} ${skill.cid} (${skill.path}); installation retained.`,
|
|
3097
|
+
),
|
|
3098
|
+
];
|
|
3099
|
+
const typeLines = [
|
|
3100
|
+
"Type Skills:",
|
|
3101
|
+
table(
|
|
3102
|
+
["TYPE CID", "SKILL NAME", "SKILL CID"],
|
|
3103
|
+
result.typeSkills.map((entry) => [
|
|
3104
|
+
entry.schemaCid,
|
|
3105
|
+
entry.identity,
|
|
3106
|
+
entry.cid,
|
|
3107
|
+
]),
|
|
3108
|
+
"No Type Skills.",
|
|
3109
|
+
),
|
|
3110
|
+
];
|
|
3111
|
+
emit(result, [...globalLines, "", ...typeLines].join("\n"));
|
|
3112
|
+
if (!result.ok) return 1;
|
|
3113
|
+
break;
|
|
3114
|
+
}
|
|
3115
|
+
|
|
2288
3116
|
const result = await manageSkills(context, requireSwarm(), {
|
|
2289
|
-
sync:
|
|
3117
|
+
sync: true,
|
|
2290
3118
|
names: parsed.positional,
|
|
2291
3119
|
agents: parsed.agents ?? [],
|
|
2292
3120
|
overrideExisting: Boolean(parsed.options["override-existing"]),
|
|
@@ -2346,6 +3174,17 @@ async function performCli(
|
|
|
2346
3174
|
requireSwarm(),
|
|
2347
3175
|
Boolean(parsed.options.refresh || parsed.options.force),
|
|
2348
3176
|
);
|
|
3177
|
+
if (result.mode === "local") {
|
|
3178
|
+
emit(
|
|
3179
|
+
result,
|
|
3180
|
+
[
|
|
3181
|
+
"Swarm: local (Built-in single-machine Swarm)",
|
|
3182
|
+
"Mode: local",
|
|
3183
|
+
"Members: local user only (single-machine; no remote collaborators or HOME identity required)",
|
|
3184
|
+
].join("\n"),
|
|
3185
|
+
);
|
|
3186
|
+
break;
|
|
3187
|
+
}
|
|
2349
3188
|
emit(
|
|
2350
3189
|
result,
|
|
2351
3190
|
[
|
|
@@ -2446,7 +3285,7 @@ async function performCli(
|
|
|
2446
3285
|
break;
|
|
2447
3286
|
}
|
|
2448
3287
|
if (parsed.path === "search") {
|
|
2449
|
-
const registrations = state.
|
|
3288
|
+
const registrations = state.allSwarms();
|
|
2450
3289
|
const scope = parsed.options.all
|
|
2451
3290
|
? registrations
|
|
2452
3291
|
: [
|
|
@@ -2483,6 +3322,43 @@ async function performCli(
|
|
|
2483
3322
|
}
|
|
2484
3323
|
if (parsed.path === "swarm status") {
|
|
2485
3324
|
const cid = requireSwarm();
|
|
3325
|
+
const status = await inspectSwarmStatus(
|
|
3326
|
+
context,
|
|
3327
|
+
cid,
|
|
3328
|
+
Boolean(parsed.options.refresh || parsed.options.force),
|
|
3329
|
+
);
|
|
3330
|
+
store = context.store;
|
|
3331
|
+
if (status.mode === "local") {
|
|
3332
|
+
emit(
|
|
3333
|
+
{
|
|
3334
|
+
mode: "local",
|
|
3335
|
+
configUrl: cid,
|
|
3336
|
+
root: status.head.root,
|
|
3337
|
+
valueCid: status.head.cid,
|
|
3338
|
+
properties: {
|
|
3339
|
+
name: status.config.name,
|
|
3340
|
+
description: status.config.description,
|
|
3341
|
+
},
|
|
3342
|
+
local: status.local,
|
|
3343
|
+
},
|
|
3344
|
+
[
|
|
3345
|
+
"Swarm",
|
|
3346
|
+
" Mode: local (built-in single-machine Swarm)",
|
|
3347
|
+
` Name: ${printable(status.config.name)}`,
|
|
3348
|
+
` Description: ${printable(status.config.description)}`,
|
|
3349
|
+
" Config URL:",
|
|
3350
|
+
` ${cid}`,
|
|
3351
|
+
"",
|
|
3352
|
+
"Content",
|
|
3353
|
+
" HEAD (publication root):",
|
|
3354
|
+
` ${status.head.root}`,
|
|
3355
|
+
" Content CID (HEAD value):",
|
|
3356
|
+
` ${status.head.cid}`,
|
|
3357
|
+
` Names: ${status.local.names} (Templates: ${status.local.templates}, Skills: ${status.local.skills} [global: ${status.local.globalSkills}, types: ${status.local.typeSkills}], Registrations: ${status.local.registrations})`,
|
|
3358
|
+
].join("\n"),
|
|
3359
|
+
);
|
|
3360
|
+
break;
|
|
3361
|
+
}
|
|
2486
3362
|
const {
|
|
2487
3363
|
head,
|
|
2488
3364
|
config,
|
|
@@ -2490,13 +3366,8 @@ async function performCli(
|
|
|
2490
3366
|
cache,
|
|
2491
3367
|
lastWriter,
|
|
2492
3368
|
state: contentState,
|
|
2493
|
-
} =
|
|
2494
|
-
context,
|
|
2495
|
-
cid,
|
|
2496
|
-
Boolean(parsed.options.refresh || parsed.options.force),
|
|
2497
|
-
);
|
|
3369
|
+
} = status;
|
|
2498
3370
|
const fingerprint = await keyId(config.owner);
|
|
2499
|
-
store = context.store;
|
|
2500
3371
|
emit(
|
|
2501
3372
|
{
|
|
2502
3373
|
configUrl: cid,
|
|
@@ -2568,6 +3439,7 @@ async function performCli(
|
|
|
2568
3439
|
"FAILURES",
|
|
2569
3440
|
"RETRY AT",
|
|
2570
3441
|
"CONNECTION",
|
|
3442
|
+
"READINESS",
|
|
2571
3443
|
],
|
|
2572
3444
|
networking.pivots.map((pivot) => [
|
|
2573
3445
|
pivot.peerId,
|
|
@@ -2577,6 +3449,7 @@ async function performCli(
|
|
|
2577
3449
|
pivot.failures === null ? "-" : String(pivot.failures),
|
|
2578
3450
|
pivot.retryAt ?? "-",
|
|
2579
3451
|
pivot.connection.status,
|
|
3452
|
+
pivot.readiness.status,
|
|
2580
3453
|
]),
|
|
2581
3454
|
"No declared Pivots.",
|
|
2582
3455
|
),
|
|
@@ -2712,6 +3585,10 @@ async function performCli(
|
|
|
2712
3585
|
break;
|
|
2713
3586
|
} else if (parsed.path === "swarm approve") {
|
|
2714
3587
|
const selected = requireSwarm();
|
|
3588
|
+
if (isLocalSwarm(selected))
|
|
3589
|
+
throw new HostError(
|
|
3590
|
+
`The built-in "${LOCAL_SWARM_ALIAS}" Swarm is a single-machine Swarm and does not support swarm approve.`,
|
|
3591
|
+
);
|
|
2715
3592
|
if (first === "-" && !parsed.options.yes)
|
|
2716
3593
|
syntax(
|
|
2717
3594
|
"Reading a Request from stdin requires explicit --yes; no interactive confirmation is available.",
|
|
@@ -2754,10 +3631,14 @@ async function performCli(
|
|
|
2754
3631
|
});
|
|
2755
3632
|
}
|
|
2756
3633
|
store = context.store;
|
|
2757
|
-
if (parsed.path === "swarm create")
|
|
3634
|
+
if (parsed.path === "swarm create") {
|
|
2758
3635
|
io.err(
|
|
2759
3636
|
`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config({ includeSecrets: false })["swarm.default"] ?? "(none)"}.`,
|
|
2760
3637
|
);
|
|
3638
|
+
io.err(
|
|
3639
|
+
"Pivot replication is not yet confirmed. Keep this member online until a Pivot is ready; daemon will replicate automatically. Manual retry: ipab swarm replicate. Inspect readiness with ipab swarm status.",
|
|
3640
|
+
);
|
|
3641
|
+
}
|
|
2761
3642
|
if (contentCid)
|
|
2762
3643
|
io.err(
|
|
2763
3644
|
`Locally protected payload: ${contentCid}. Use ipab unpin ${contentCid} to release this CID pin only; Name subscriptions and publication/history owners remain. --snapshot links payloads directly into retained publication history, so unpin cannot release that protection.`,
|
|
@@ -2901,7 +3782,11 @@ async function performCli(
|
|
|
2901
3782
|
: "Validating and building bundle...",
|
|
2902
3783
|
);
|
|
2903
3784
|
if (parsed.path === "bundle import")
|
|
2904
|
-
io.err(
|
|
3785
|
+
io.err(
|
|
3786
|
+
first!.toLowerCase().endsWith(".car")
|
|
3787
|
+
? "Validating and importing CAR into Store..."
|
|
3788
|
+
: "Validating and importing Bundle into Store...",
|
|
3789
|
+
);
|
|
2905
3790
|
const result =
|
|
2906
3791
|
parsed.path === "templates render"
|
|
2907
3792
|
? await initApp(second!, parsed.positional[2], {
|
|
@@ -2964,7 +3849,7 @@ async function performCli(
|
|
|
2964
3849
|
else if (result.kind === "bundle-import")
|
|
2965
3850
|
emit(
|
|
2966
3851
|
result,
|
|
2967
|
-
`Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\
|
|
3852
|
+
`Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\n${result.source.toLowerCase().endsWith(".car") ? "CAR" : "Source"}: ${result.source}\nEntry validation: ${result.validation?.status ?? "not-applicable"}`,
|
|
2968
3853
|
);
|
|
2969
3854
|
else if (result.kind === "project-init") {
|
|
2970
3855
|
emit(
|
|
@@ -3216,16 +4101,19 @@ async function performCli(
|
|
|
3216
4101
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
3217
4102
|
const context = swarmContext();
|
|
3218
4103
|
readContext = context;
|
|
3219
|
-
const
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
4104
|
+
const localInput = await resolveLocalBundleInput(first!);
|
|
4105
|
+
const target = localInput
|
|
4106
|
+
? undefined
|
|
4107
|
+
: (
|
|
4108
|
+
await resolveReference(
|
|
4109
|
+
context,
|
|
4110
|
+
first!,
|
|
4111
|
+
selectedSwarm,
|
|
4112
|
+
(reference) => state!.resolve(reference),
|
|
4113
|
+
Boolean(parsed.options.raw),
|
|
4114
|
+
"local-first",
|
|
4115
|
+
)
|
|
4116
|
+
).cid;
|
|
3229
4117
|
store = context.store;
|
|
3230
4118
|
const resolveBundleReference = async (
|
|
3231
4119
|
reference: string,
|
|
@@ -3289,14 +4177,21 @@ async function performCli(
|
|
|
3289
4177
|
let appCid: string;
|
|
3290
4178
|
let appArgv: string[];
|
|
3291
4179
|
if (parsed.path === "open") {
|
|
3292
|
-
const
|
|
4180
|
+
const session = localInput ? `open:${randomUUID()}` : null;
|
|
3293
4181
|
const owner = await Ownership.create(
|
|
3294
4182
|
state,
|
|
3295
4183
|
store,
|
|
3296
4184
|
`open:${randomUUID()}`,
|
|
3297
|
-
|
|
4185
|
+
session,
|
|
3298
4186
|
);
|
|
3299
4187
|
try {
|
|
4188
|
+
const root = localInput
|
|
4189
|
+
? await snapshotLocalBundle(localInput, owner, session!, {
|
|
4190
|
+
diagnostic: (text) => {
|
|
4191
|
+
io.err(text);
|
|
4192
|
+
},
|
|
4193
|
+
})
|
|
4194
|
+
: target!;
|
|
3300
4195
|
const content = await validatedBundle(root, store, owner);
|
|
3301
4196
|
const schema = content.schemaKey;
|
|
3302
4197
|
let association: Association | undefined;
|
|
@@ -3332,6 +4227,7 @@ async function performCli(
|
|
|
3332
4227
|
"Custom per-association argv is unsupported; adapt the App to accept only the content CID or use ipab exec APP_CID ARGS.",
|
|
3333
4228
|
);
|
|
3334
4229
|
appArgv = [root];
|
|
4230
|
+
io.err("Starting App...");
|
|
3335
4231
|
// execute owns the App/input context before this validation owner's eventual release.
|
|
3336
4232
|
const result = await execute(
|
|
3337
4233
|
state,
|
|
@@ -3353,8 +4249,44 @@ async function performCli(
|
|
|
3353
4249
|
} finally {
|
|
3354
4250
|
await owner.release();
|
|
3355
4251
|
}
|
|
4252
|
+
} else if (localInput) {
|
|
4253
|
+
const session = `exec:${randomUUID()}`;
|
|
4254
|
+
const owner = await Ownership.create(
|
|
4255
|
+
state,
|
|
4256
|
+
store,
|
|
4257
|
+
`exec:${randomUUID()}`,
|
|
4258
|
+
session,
|
|
4259
|
+
);
|
|
4260
|
+
try {
|
|
4261
|
+
appCid = await snapshotLocalBundle(localInput, owner, session, {
|
|
4262
|
+
diagnostic: (text) => {
|
|
4263
|
+
io.err(text);
|
|
4264
|
+
},
|
|
4265
|
+
});
|
|
4266
|
+
appArgv = parsed.positional.slice(1);
|
|
4267
|
+
io.err("Starting App...");
|
|
4268
|
+
appExitCode = (
|
|
4269
|
+
await execute(
|
|
4270
|
+
state,
|
|
4271
|
+
store,
|
|
4272
|
+
{ origin: "exec", appCid, argv: appArgv },
|
|
4273
|
+
{
|
|
4274
|
+
resolveBundleReference,
|
|
4275
|
+
history: Boolean(value("history.enabled")),
|
|
4276
|
+
retain: value("output.retention") === "history",
|
|
4277
|
+
log: Boolean(parsed.options.log),
|
|
4278
|
+
diagnostic: (text) => {
|
|
4279
|
+
io.err(text);
|
|
4280
|
+
},
|
|
4281
|
+
},
|
|
4282
|
+
)
|
|
4283
|
+
).exitCode;
|
|
4284
|
+
return appExitCode;
|
|
4285
|
+
} finally {
|
|
4286
|
+
await owner.release();
|
|
4287
|
+
}
|
|
3356
4288
|
} else {
|
|
3357
|
-
appCid = target
|
|
4289
|
+
appCid = target!;
|
|
3358
4290
|
appArgv = parsed.positional.slice(1);
|
|
3359
4291
|
}
|
|
3360
4292
|
appExitCode = (
|
|
@@ -3380,6 +4312,7 @@ async function performCli(
|
|
|
3380
4312
|
}
|
|
3381
4313
|
return 0;
|
|
3382
4314
|
} catch (error) {
|
|
4315
|
+
const { message } = await import("./errors.js");
|
|
3383
4316
|
io.err(`Error: ${message(error)}`);
|
|
3384
4317
|
return error instanceof HostError ? error.exitCode : 1;
|
|
3385
4318
|
} finally {
|
|
@@ -3403,6 +4336,7 @@ export async function runCli(
|
|
|
3403
4336
|
try {
|
|
3404
4337
|
return await performCli(argv, io, env);
|
|
3405
4338
|
} catch (error) {
|
|
4339
|
+
const { message } = await import("./errors.js");
|
|
3406
4340
|
io.err(`Error: ${message(error)}`);
|
|
3407
4341
|
return error instanceof HostError ? error.exitCode : 1;
|
|
3408
4342
|
}
|