@ipab/cli 0.1.0-rc.6 → 0.1.0-rc.8
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 +96 -34
- package/dist/app-authoring.d.ts +5 -0
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +6 -45
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-prebuild.d.ts +18 -0
- package/dist/app-prebuild.d.ts.map +1 -1
- package/dist/app-prebuild.js +46 -0
- package/dist/app-prebuild.js.map +1 -1
- package/dist/app-templates.d.ts +0 -1
- package/dist/app-templates.d.ts.map +1 -1
- package/dist/app-templates.js +6 -45
- package/dist/app-templates.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/builtins.d.ts.map +1 -1
- package/dist/builtins.js +1 -39
- package/dist/builtins.js.map +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +668 -221
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -4
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +20 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +31 -2
- package/dist/context.js.map +1 -1
- package/dist/errors.d.ts +1 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -20
- package/dist/errors.js.map +1 -1
- package/dist/host-error.d.ts +9 -0
- package/dist/host-error.d.ts.map +1 -0
- package/dist/host-error.js +21 -0
- package/dist/host-error.js.map +1 -0
- package/dist/ipc.d.ts +2 -1
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +61 -3
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.js +1 -1
- package/dist/kubo-install.js.map +1 -1
- package/dist/kubo-peers.d.ts.map +1 -1
- package/dist/kubo-peers.js +2 -1
- package/dist/kubo-peers.js.map +1 -1
- package/dist/kubo-topology.d.ts +19 -0
- package/dist/kubo-topology.d.ts.map +1 -0
- package/dist/kubo-topology.js +105 -0
- package/dist/kubo-topology.js.map +1 -0
- package/dist/kubo.d.ts +10 -0
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +96 -15
- package/dist/kubo.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +6 -3
- package/dist/runtime.js.map +1 -1
- package/dist/skill-definition.d.ts +6 -0
- package/dist/skill-definition.d.ts.map +1 -0
- package/dist/skill-definition.js +38 -0
- package/dist/skill-definition.js.map +1 -0
- package/dist/skill-source.d.ts +5 -0
- package/dist/skill-source.d.ts.map +1 -0
- package/dist/skill-source.js +12 -0
- package/dist/skill-source.js.map +1 -0
- package/dist/skills.d.ts +84 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +736 -0
- package/dist/skills.js.map +1 -0
- package/dist/space-path.d.ts +3 -0
- package/dist/space-path.d.ts.map +1 -0
- package/dist/space-path.js +17 -0
- package/dist/space-path.js.map +1 -0
- package/dist/space.d.ts +16 -4
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +155 -18
- package/dist/space.js.map +1 -1
- package/dist/state-storage.js +1 -1
- package/dist/state-storage.js.map +1 -1
- package/dist/state.d.ts +2 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +32 -13
- package/dist/state.js.map +1 -1
- package/dist/swarm-files.d.ts +2 -2
- package/dist/swarm-files.d.ts.map +1 -1
- package/dist/swarm-files.js +4 -4
- package/dist/swarm-files.js.map +1 -1
- package/dist/swarm-meta.d.ts +14 -0
- package/dist/swarm-meta.d.ts.map +1 -0
- package/dist/swarm-meta.js +65 -0
- package/dist/swarm-meta.js.map +1 -0
- package/dist/swarm-observations.d.ts +40 -0
- package/dist/swarm-observations.d.ts.map +1 -0
- package/dist/swarm-observations.js +262 -0
- package/dist/swarm-observations.js.map +1 -0
- package/dist/swarm.d.ts +172 -6
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +1106 -132
- package/dist/swarm.js.map +1 -1
- package/dist/template-paths.d.ts +7 -0
- package/dist/template-paths.d.ts.map +1 -0
- package/dist/template-paths.js +23 -0
- package/dist/template-paths.js.map +1 -0
- package/dist/template-presentation.d.ts +20 -0
- package/dist/template-presentation.d.ts.map +1 -0
- package/dist/template-presentation.js +133 -0
- package/dist/template-presentation.js.map +1 -0
- package/dist/template-source.d.ts +2 -1
- package/dist/template-source.d.ts.map +1 -1
- package/dist/template-source.js +7 -1
- package/dist/template-source.js.map +1 -1
- package/dist/templates.d.ts +11 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +53 -0
- package/dist/templates.js.map +1 -0
- package/package.json +7 -6
- package/src/app-authoring.ts +30 -55
- package/src/app-prebuild.ts +61 -0
- package/src/app-templates.ts +8 -72
- package/src/builtins.ts +2 -48
- package/src/cli.ts +830 -247
- package/src/config.ts +12 -4
- package/src/context.ts +60 -2
- package/src/errors.ts +1 -25
- package/src/host-error.ts +26 -0
- package/src/ipc.ts +82 -2
- package/src/kubo-install.ts +1 -1
- package/src/kubo-peers.ts +2 -3
- package/src/kubo-topology.ts +135 -0
- package/src/kubo.ts +134 -25
- package/src/runtime.ts +6 -2
- package/src/skill-definition.ts +53 -0
- package/src/skill-source.ts +15 -0
- package/src/skills.ts +1005 -0
- package/src/space-path.ts +30 -0
- package/src/space.ts +216 -33
- package/src/state-storage.ts +1 -1
- package/src/state.ts +38 -13
- package/src/swarm-files.ts +4 -2
- package/src/swarm-meta.ts +90 -0
- package/src/swarm-observations.ts +374 -0
- package/src/swarm.ts +1637 -193
- package/src/template-paths.ts +43 -0
- package/src/template-presentation.ts +151 -0
- package/src/template-source.ts +9 -2
- package/src/templates.ts +77 -0
package/src/cli.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createInterface } from "node:readline/promises";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { lstat, readFile } from "node:fs/promises";
|
|
3
3
|
import { ContentError, IpfsStore } from "@ipab/ipfs-store";
|
|
4
4
|
import { ContentBundleError } from "@ipab/bundle";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
publicUrl,
|
|
13
13
|
stateLocation,
|
|
14
14
|
storeConfiguration,
|
|
15
|
+
swarmUrl,
|
|
15
16
|
visibleConfig,
|
|
16
17
|
type GlobalOptions,
|
|
17
18
|
} from "./config.js";
|
|
@@ -29,11 +30,17 @@ import { validatedBundle } from "./space.js";
|
|
|
29
30
|
import {
|
|
30
31
|
createAssociation,
|
|
31
32
|
exactCid,
|
|
33
|
+
swarmAlias,
|
|
32
34
|
State,
|
|
33
35
|
type Association,
|
|
34
36
|
type RunRecord,
|
|
35
37
|
} from "./state.js";
|
|
36
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
buildBundle,
|
|
40
|
+
inspectBundle,
|
|
41
|
+
importBundle,
|
|
42
|
+
nodeError,
|
|
43
|
+
} from "./authoring.js";
|
|
37
44
|
import { initApp } from "./app-authoring.js";
|
|
38
45
|
import { assembleBundle } from "./assembly.js";
|
|
39
46
|
import { getBundle } from "./get.js";
|
|
@@ -41,6 +48,7 @@ import { doctorDevice, doctorText } from "./doctor.js";
|
|
|
41
48
|
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
42
49
|
import {
|
|
43
50
|
createSwarm,
|
|
51
|
+
swarmDaemon,
|
|
44
52
|
requestMembership,
|
|
45
53
|
approveMembership,
|
|
46
54
|
exportRequest,
|
|
@@ -50,12 +58,10 @@ import {
|
|
|
50
58
|
accountProfile,
|
|
51
59
|
updateAccountProfile,
|
|
52
60
|
swarmMembers,
|
|
61
|
+
inspectSwarmStatus,
|
|
53
62
|
verifiedRequest,
|
|
54
63
|
verifiedRequestStream,
|
|
55
64
|
membershipRequestSummary,
|
|
56
|
-
swarmHeader,
|
|
57
|
-
sharedSwarmStatus,
|
|
58
|
-
addSwarm,
|
|
59
65
|
updateSwarm,
|
|
60
66
|
searchNames,
|
|
61
67
|
formatNameReference,
|
|
@@ -69,14 +75,25 @@ import {
|
|
|
69
75
|
swarmAssociation,
|
|
70
76
|
setSwarmAssociation,
|
|
71
77
|
removeSwarmAssociation,
|
|
78
|
+
resolveTemplateSelector,
|
|
79
|
+
templateName,
|
|
80
|
+
swarmTemplates,
|
|
81
|
+
setSwarmTemplate,
|
|
82
|
+
removeSwarmTemplate,
|
|
72
83
|
type SwarmContext,
|
|
73
84
|
} from "./swarm.js";
|
|
74
85
|
import { schemaAlias } from "./app-definition.js";
|
|
75
86
|
import { unpin, pinDetails } from "./pins.js";
|
|
76
87
|
import { publicationSource } from "./publish-source.js";
|
|
88
|
+
import {
|
|
89
|
+
templateRenderExample,
|
|
90
|
+
templateOutputTree,
|
|
91
|
+
templateParameterRows,
|
|
92
|
+
} from "./template-presentation.js";
|
|
77
93
|
import { logFiles } from "./logs.js";
|
|
78
94
|
import { builtinContent } from "./builtins.js";
|
|
79
95
|
import { readSecretStream } from "./config-secret.js";
|
|
96
|
+
import { manageSkills } from "./skills.js";
|
|
80
97
|
|
|
81
98
|
export interface IO {
|
|
82
99
|
out(text: string): void;
|
|
@@ -139,40 +156,48 @@ export const processIO: IO = {
|
|
|
139
156
|
},
|
|
140
157
|
};
|
|
141
158
|
const commands: Record<string, string> = {
|
|
159
|
+
daemon: "daemon [--swarm URL_OR_ALIAS]",
|
|
160
|
+
"skills list": "skills list [--refresh | --no-refresh]",
|
|
161
|
+
"skills sync":
|
|
162
|
+
"skills sync [NAMES...] [--agent AGENT]... [--dry-run] [--yes] [--refresh | --no-refresh]",
|
|
142
163
|
doctor: "doctor [--fix [--yes]]",
|
|
143
164
|
profile: "profile [--name NAME] [--description TEXT]",
|
|
144
165
|
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
145
|
-
"swarm request": "swarm request
|
|
166
|
+
"swarm request": "swarm request URL_OR_ALIAS [--output FILE]",
|
|
146
167
|
"swarm export": "swarm export --output FILE",
|
|
147
168
|
"swarm approve": "swarm approve REQUEST_FILE [--again] --yes",
|
|
148
169
|
"swarm exclude": "swarm exclude MEMBER_PUBLIC_KEY --yes",
|
|
149
170
|
"swarm resume": "swarm resume",
|
|
150
171
|
"swarm profile": "swarm profile --address MULTIADDR",
|
|
151
|
-
"swarm status": "swarm status [--
|
|
152
|
-
"swarm members": "swarm members",
|
|
172
|
+
"swarm status": "swarm status [--refresh | --no-refresh]",
|
|
173
|
+
"swarm members": "swarm members [--refresh | --no-refresh]",
|
|
153
174
|
"swarm list": "swarm list",
|
|
154
|
-
"swarm
|
|
175
|
+
"swarm set": "swarm set ALIAS CONFIG_URL [--yes]",
|
|
155
176
|
"swarm use": "swarm use URL_OR_ALIAS",
|
|
156
177
|
"swarm remove": "swarm remove URL_OR_ALIAS",
|
|
157
178
|
"swarm update": "swarm update [--name TEXT] [--description TEXT]",
|
|
158
|
-
publish: "publish NAME SOURCE [--expect
|
|
159
|
-
get: "get REF [--raw] [--
|
|
160
|
-
search: "search QUERY [--all | --current] [--
|
|
161
|
-
|
|
179
|
+
publish: "publish NAME SOURCE [--expect OLD_CID | --snapshot]",
|
|
180
|
+
get: "get REF [--raw] [--refresh | --no-refresh] [-o DIRECTORY]",
|
|
181
|
+
search: "search QUERY [--all | --current] [--refresh | --no-refresh]",
|
|
182
|
+
"templates render": "templates render TEMPLATE NAME [DIR] [OPTIONS]",
|
|
162
183
|
build: "build [SOURCE] [OPTIONS]",
|
|
163
184
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
164
185
|
"bundle inspect": "bundle inspect SOURCE",
|
|
165
186
|
"bundle import": "bundle import FILE.car",
|
|
166
|
-
exec: "exec [--log] [--
|
|
167
|
-
open: "open [--log] [--raw] [--
|
|
168
|
-
pin: "pin REF",
|
|
187
|
+
exec: "exec [--log] [--refresh | --no-refresh] APP [APP_ARGS...]",
|
|
188
|
+
open: "open [--log] [--raw] [--refresh | --no-refresh] CONTENT",
|
|
189
|
+
pin: "pin REF [--refresh | --no-refresh]",
|
|
169
190
|
unpin: "unpin REF",
|
|
170
191
|
"pin list": "pin list",
|
|
171
192
|
"pin show": "pin show REF",
|
|
172
|
-
"register list": "register list [--swarm URL_OR_ALIAS]
|
|
193
|
+
"register list": "register list [--swarm URL_OR_ALIAS]",
|
|
173
194
|
"register set":
|
|
174
|
-
"register set SCHEMA APP [--swarm URL_OR_ALIAS]... [--replace]
|
|
195
|
+
"register set SCHEMA APP [--swarm URL_OR_ALIAS]... [--replace]",
|
|
175
196
|
"register remove": "register remove SCHEMA [--swarm URL_OR_ALIAS]...",
|
|
197
|
+
"templates list": "templates list [--refresh | --no-refresh]",
|
|
198
|
+
"templates show": "templates show NAME [--refresh | --no-refresh]",
|
|
199
|
+
"templates set": "templates set NAME SOURCE [--expect OLD_TARGET_CID]",
|
|
200
|
+
"templates remove": "templates remove NAME --expect OLD_TARGET_CID",
|
|
176
201
|
"config get": "config get [KEY]",
|
|
177
202
|
"config set":
|
|
178
203
|
"config set KEY VALUE\n ipab config set pointers.apiKey - < protected-key-file",
|
|
@@ -185,10 +210,12 @@ const commands: Record<string, string> = {
|
|
|
185
210
|
"history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
|
|
186
211
|
};
|
|
187
212
|
const groups: Record<string, string> = {
|
|
213
|
+
skills: "Discover and explicitly synchronize selected Swarm Skills globally",
|
|
188
214
|
swarm: "Create, authorize, select and manage personal swarms",
|
|
189
215
|
bundle: "Create, inspect and import content bundles",
|
|
190
216
|
pin: "Retain an exact CID or follow a shared Swarm Name",
|
|
191
217
|
register: "Associate content types with Apps",
|
|
218
|
+
templates: "Inspect, render and manage Template Bundles",
|
|
192
219
|
config: "Manage local configuration",
|
|
193
220
|
store: "Query local storage and collect unreferenced blocks",
|
|
194
221
|
history: "View and remove execution history",
|
|
@@ -203,6 +230,106 @@ const commandHelp: Record<
|
|
|
203
230
|
notes?: string[];
|
|
204
231
|
}
|
|
205
232
|
> = {
|
|
233
|
+
daemon: {
|
|
234
|
+
summary: "Manage existing private Swarm nodes in the foreground",
|
|
235
|
+
examples: ["ipab daemon", "ipab daemon --swarm work"],
|
|
236
|
+
notes: [
|
|
237
|
+
"Manages all registered Swarms independently, or only the explicitly selected --swarm; ignores the saved default.",
|
|
238
|
+
"Probes pivot candidates, refreshes approved profiles and retries with cooldown. Diagnostics go to stderr.",
|
|
239
|
+
"Ctrl-C / TERM drains operations and releases the device/state-dir lock; Kubo stays running. Run under your own supervisor if desired.",
|
|
240
|
+
"Role and relay candidate changes restart only the verified managed Kubo node.",
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
"templates list": {
|
|
244
|
+
summary: "List templates under the selected Swarm Meta templatePath",
|
|
245
|
+
options: [
|
|
246
|
+
"--refresh / --no-refresh Refresh HEAD now / allow a valid cached snapshot.",
|
|
247
|
+
],
|
|
248
|
+
examples: [
|
|
249
|
+
"ipab --swarm work templates list",
|
|
250
|
+
"ipab --json templates list",
|
|
251
|
+
],
|
|
252
|
+
notes: [
|
|
253
|
+
"Uses only global --swarm (once, before the command), otherwise the saved default. No builtin or other Swarm fallback.",
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
"templates show": {
|
|
257
|
+
summary: "Show one template, its exact targets and declared parameters",
|
|
258
|
+
arguments: [
|
|
259
|
+
"NAME Safe relative template Name; nested names are supported.",
|
|
260
|
+
],
|
|
261
|
+
options: [
|
|
262
|
+
"--refresh / --no-refresh Refresh HEAD now / allow a valid cached snapshot.",
|
|
263
|
+
],
|
|
264
|
+
examples: ["ipab --swarm work templates show node"],
|
|
265
|
+
},
|
|
266
|
+
"templates set": {
|
|
267
|
+
summary:
|
|
268
|
+
"Publish one validated Template Bundle with exact Name conflict checks",
|
|
269
|
+
arguments: [
|
|
270
|
+
"NAME Safe relative template Name.",
|
|
271
|
+
"SOURCE Exact Template CID, self-contained CAR or explicit manifest directory; no URI, build or hooks.",
|
|
272
|
+
],
|
|
273
|
+
options: [
|
|
274
|
+
"--expect OLD_TARGET_CID Required to replace an occupied Name; use its exact target CID, including an Artifact wrapper.",
|
|
275
|
+
],
|
|
276
|
+
examples: [
|
|
277
|
+
"ipab --swarm work templates set team/node ./template.car",
|
|
278
|
+
"ipab templates set node TEMPLATE_CID --expect OLD_TARGET_CID",
|
|
279
|
+
],
|
|
280
|
+
notes: [
|
|
281
|
+
"Publishes an ordinary Artifact and preserves publication history and content retention.",
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
"templates remove": {
|
|
285
|
+
summary: "Remove only one template Name, without deleting content",
|
|
286
|
+
arguments: ["NAME Safe relative template Name."],
|
|
287
|
+
options: [
|
|
288
|
+
"--expect OLD_TARGET_CID Required exact current Name target CID.",
|
|
289
|
+
],
|
|
290
|
+
examples: [
|
|
291
|
+
"ipab --swarm work templates remove team/node --expect OLD_TARGET_CID",
|
|
292
|
+
],
|
|
293
|
+
notes: [
|
|
294
|
+
"Missing Names are errors. Does not unpin, GC or delete content or history.",
|
|
295
|
+
],
|
|
296
|
+
},
|
|
297
|
+
"skills list": {
|
|
298
|
+
summary: "List typed Skills and local installation status from one Swarm",
|
|
299
|
+
options: [
|
|
300
|
+
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
301
|
+
"Global --json Emit machine-readable names, exact payload CIDs and status.",
|
|
302
|
+
],
|
|
303
|
+
examples: ["ipab --swarm work skills list", "ipab --json skills list"],
|
|
304
|
+
notes: [
|
|
305
|
+
"Select one Swarm with global --swarm or swarm use; there is no --all.",
|
|
306
|
+
"Requires skillPath in the exact root State Bundle or legacy Meta type. Older v5 roots require a new seeded Swarm; only legacy v2/v3/v4 Meta can be explicitly replaced with --expect. No silent upgrades.",
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
"skills sync": {
|
|
310
|
+
summary:
|
|
311
|
+
"Install reviewed Swarm Skills using the pinned official npx installer",
|
|
312
|
+
arguments: [
|
|
313
|
+
"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.",
|
|
314
|
+
],
|
|
315
|
+
options: [
|
|
316
|
+
"--agent AGENT Repeatable globally supported agent ID; default is detected agents.",
|
|
317
|
+
"--dry-run Preview without invoking npx or changing installed Skills.",
|
|
318
|
+
"--yes Skip IPAB consent only; conflicts and local edits remain protected.",
|
|
319
|
+
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
320
|
+
],
|
|
321
|
+
examples: [
|
|
322
|
+
"ipab --swarm work skills sync --dry-run",
|
|
323
|
+
"ipab skills sync ipab code-review --agent github-copilot --yes",
|
|
324
|
+
],
|
|
325
|
+
notes: [
|
|
326
|
+
"Global installs only, through official skills@1.9.1 with --copy. Requires Node >=22.20.0.",
|
|
327
|
+
"Non-interactive execution requires --yes. Installer version, source, paths and agents are shown first.",
|
|
328
|
+
"No Skill hooks/scripts run. The trusted installer is not sandboxed. Telemetry and remote audits are disabled.",
|
|
329
|
+
"Non-IPAB installs, local edits, cross-Swarm collisions and symlink/junction aliases are never overwritten. Removed sources are reported, not deleted.",
|
|
330
|
+
"Partial failures report individual results, preserve pending attribution and exit nonzero; retry the same sync.",
|
|
331
|
+
],
|
|
332
|
+
},
|
|
206
333
|
profile: {
|
|
207
334
|
summary: "Read or update your account-wide public name and description",
|
|
208
335
|
examples: [
|
|
@@ -265,11 +392,10 @@ const commandHelp: Record<
|
|
|
265
392
|
"swarm request": {
|
|
266
393
|
summary: "Save and export a signed self-contained membership Request",
|
|
267
394
|
examples: [
|
|
268
|
-
"ipab swarm request
|
|
269
|
-
"ipab swarm request CONFIG_URL --output request.json
|
|
395
|
+
"ipab swarm request work",
|
|
396
|
+
"ipab swarm request CONFIG_URL --output request.json",
|
|
270
397
|
],
|
|
271
398
|
options: [
|
|
272
|
-
"--alias ALIAS Pre-register the target for lazy onboarding.",
|
|
273
399
|
"--output FILE Export to a new file instead of stdout; never overwrites.",
|
|
274
400
|
],
|
|
275
401
|
notes: [
|
|
@@ -279,7 +405,7 @@ const commandHelp: Record<
|
|
|
279
405
|
"Retries export the exact saved Request without expiry or a new PeerID.",
|
|
280
406
|
"No Invite, Response file, password or Join. Next normal use fetches and decrypts the approved package.",
|
|
281
407
|
"Set your account-wide personal name with ipab profile --name NAME before requesting membership.",
|
|
282
|
-
"
|
|
408
|
+
"Accepts a local alias or a configuration URL. Never changes local registrations, aliases or the saved default; use ipab swarm set ALIAS CONFIG_URL separately.",
|
|
283
409
|
],
|
|
284
410
|
},
|
|
285
411
|
"swarm approve": {
|
|
@@ -323,24 +449,35 @@ const commandHelp: Record<
|
|
|
323
449
|
},
|
|
324
450
|
"swarm members": {
|
|
325
451
|
summary: "List every public member, including the Owner",
|
|
326
|
-
|
|
452
|
+
options: [
|
|
453
|
+
"--refresh / --no-refresh Fetch public Variables now / reuse the saved inspection, fetching if missing.",
|
|
454
|
+
"--local Deprecated no-op; local daemon observations are always included.",
|
|
455
|
+
],
|
|
456
|
+
examples: [
|
|
457
|
+
"ipab --swarm work swarm members",
|
|
458
|
+
"ipab --json swarm members --refresh",
|
|
459
|
+
],
|
|
327
460
|
notes: [
|
|
328
|
-
"
|
|
461
|
+
"Default: reuse the inspection cache, fetching public Variables if missing. Includes Pivot declarations and existing daemon observations; no HOME identity access, node activation or probes.",
|
|
462
|
+
"PIVOT: - for ordinary members; selected, cooldown, unknown, self or candidate for declared Pivots. Selected means applied configuration, not connectivity.",
|
|
329
463
|
],
|
|
330
464
|
},
|
|
331
465
|
"swarm status": {
|
|
332
|
-
summary: "
|
|
466
|
+
summary: "Inspect cached Swarm directory, HEAD and local networking",
|
|
333
467
|
options: [
|
|
334
|
-
"--
|
|
468
|
+
"--refresh / --no-refresh Fetch public Variables now / reuse the saved inspection, fetching if missing.",
|
|
469
|
+
"--local Deprecated no-op; never activates a node.",
|
|
335
470
|
],
|
|
336
471
|
examples: [
|
|
337
472
|
"ipab swarm status",
|
|
338
473
|
"ipab --swarm work swarm status",
|
|
339
|
-
"ipab --swarm work swarm status --
|
|
474
|
+
"ipab --swarm work swarm status --refresh",
|
|
340
475
|
],
|
|
341
476
|
notes: [
|
|
342
|
-
"
|
|
343
|
-
"
|
|
477
|
+
"Default: reuse the inspection cache, fetching public Variables if missing. Refresh verifies Config, Scope, members, Profiles and HEAD, not connectivity or State content.",
|
|
478
|
+
"Always shows daemon freshness, Pivot selection, probes/cooldown and separately timestamped daemon connection snapshots. Never contacts Kubo, initializes HOME identity, changes remote profiles or activates a node.",
|
|
479
|
+
"State content is explicitly unavailable in inspection; use get ipab:/// to obtain the State Bundle.",
|
|
480
|
+
"Local connectivity is not global availability; a relay connection does not guarantee content transfer.",
|
|
344
481
|
],
|
|
345
482
|
},
|
|
346
483
|
"swarm list": {
|
|
@@ -348,13 +485,19 @@ const commandHelp: Record<
|
|
|
348
485
|
examples: ["ipab swarm list", "ipab --json swarm list"],
|
|
349
486
|
notes: ["Local only; does not verify remote membership or refresh HEAD."],
|
|
350
487
|
},
|
|
351
|
-
"swarm
|
|
352
|
-
summary: "
|
|
488
|
+
"swarm set": {
|
|
489
|
+
summary: "Set a local alias for a swarm configuration URL",
|
|
353
490
|
options: [
|
|
354
|
-
"--
|
|
491
|
+
"--yes Authorize retargeting an existing alias without prompting.",
|
|
492
|
+
],
|
|
493
|
+
examples: [
|
|
494
|
+
"ipab swarm set work CONFIG_URL",
|
|
495
|
+
"ipab swarm set work OTHER_CONFIG_URL --yes",
|
|
355
496
|
],
|
|
356
|
-
examples: ["ipab swarm add CONFIG_URL --alias work"],
|
|
357
497
|
notes: [
|
|
498
|
+
"Local only; no network, account identity or approved membership required.",
|
|
499
|
+
"Setting the same mapping is idempotent. One alias per URL; a new alias for that URL replaces its old alias.",
|
|
500
|
+
"Retargeting an alias requires confirmation or --yes. Keeps the old URL registered without that alias; credentials, caches and the saved default URL are unchanged.",
|
|
358
501
|
"Not a membership grant. The first registration becomes the saved default only if none exists.",
|
|
359
502
|
],
|
|
360
503
|
},
|
|
@@ -394,13 +537,13 @@ const commandHelp: Record<
|
|
|
394
537
|
options: [
|
|
395
538
|
"--all Search all registered swarms; conflicts with --current and --swarm.",
|
|
396
539
|
"--current Explicitly select the default search scope; conflicts with --swarm.",
|
|
397
|
-
"--
|
|
398
|
-
"--no-
|
|
540
|
+
"--refresh Refresh HEAD for every swarm in the search scope.",
|
|
541
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
399
542
|
],
|
|
400
543
|
examples: [
|
|
401
544
|
"ipab search hello",
|
|
402
545
|
"ipab search hello --all",
|
|
403
|
-
"ipab --swarm work search hello --
|
|
546
|
+
"ipab --swarm work search hello --refresh",
|
|
404
547
|
],
|
|
405
548
|
notes: [
|
|
406
549
|
"Searches only --swarm or the saved current swarm by default. Use --all to search every registration.",
|
|
@@ -413,18 +556,18 @@ const commandHelp: Record<
|
|
|
413
556
|
publish: {
|
|
414
557
|
summary: "Protect content locally and publish a shared Swarm Name",
|
|
415
558
|
options: [
|
|
416
|
-
"--expect CID Exact old
|
|
559
|
+
"--expect CID Exact old Name target CID, required for iteration.",
|
|
417
560
|
"--snapshot Name ordinary content without an Artifact; initial only.",
|
|
418
561
|
],
|
|
419
562
|
examples: [
|
|
420
563
|
"ipab --swarm work publish apps/hello app.car",
|
|
421
|
-
"ipab publish apps/hello APP_CID --expect
|
|
564
|
+
"ipab publish apps/hello APP_CID --expect OLD_APP_CID",
|
|
422
565
|
"ipab publish notes/readme ./README.md",
|
|
423
566
|
],
|
|
424
567
|
notes: [
|
|
425
568
|
"SOURCE is an exact Bundle CID, CAR, regular file or directory. No compiler, hooks, install or App execution.",
|
|
426
569
|
"Directories require .bundle.yaml/type, or a package.json source snapshot. Standalone .json/.yaml/.yml/.md/.txt entries get a standard Bundle; other file types require explicit metadata.",
|
|
427
|
-
"Occupied Names require --expect
|
|
570
|
+
"App and Meta Bundles publish direct CID links; other content uses Artifact records. Occupied Names require --expect EXACT_OLD_CID (the old Artifact CID when applicable). Published payloads are local CID pins; unpin CID releases that protection, not history holders.",
|
|
428
571
|
"Different-name CAS contention is rebased; same-name edits conflict (exit 3).",
|
|
429
572
|
"Kubo pin confirmation precedes HEAD; it does not prove a remote device is online.",
|
|
430
573
|
],
|
|
@@ -433,8 +576,8 @@ const commandHelp: Record<
|
|
|
433
576
|
summary: "Verify and unpack Bundle content without executing it",
|
|
434
577
|
options: [
|
|
435
578
|
"--raw Select the Artifact node instead of its value.",
|
|
436
|
-
"--
|
|
437
|
-
"--no-
|
|
579
|
+
"--refresh Refresh the shared Name's swarm HEAD.",
|
|
580
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
438
581
|
"-o, --output DIRECTORY New or empty directory; defaults to a unique temporary directory.",
|
|
439
582
|
],
|
|
440
583
|
examples: [
|
|
@@ -467,20 +610,28 @@ const commandHelp: Record<
|
|
|
467
610
|
"Does not unpin, clear history, delete unknown files or request Kubo daemon GC.",
|
|
468
611
|
],
|
|
469
612
|
},
|
|
470
|
-
|
|
471
|
-
summary: "
|
|
472
|
-
arguments: [
|
|
613
|
+
"templates render": {
|
|
614
|
+
summary: "Render a template's project files into a new or empty folder",
|
|
615
|
+
arguments: [
|
|
616
|
+
"TEMPLATE Explicit Swarm selector, directory, CAR, exact CID or IPAB URI.",
|
|
617
|
+
"NAME Project name parameter; DIR defaults to NAME (new/empty only).",
|
|
618
|
+
],
|
|
473
619
|
options: [
|
|
474
|
-
"--
|
|
620
|
+
"--description TEXT Set the declared description parameter.",
|
|
621
|
+
"--refresh / --no-refresh Refresh Swarm HEAD now / allow its valid cached snapshot.",
|
|
475
622
|
"--param KEY=VALUE Template parameter; repeatable. Strings are literal;",
|
|
476
623
|
" other parameter types use JSON.",
|
|
477
624
|
],
|
|
478
625
|
examples: [
|
|
479
|
-
"ipab
|
|
480
|
-
"ipab
|
|
481
|
-
"ipab
|
|
626
|
+
"ipab templates render node hello",
|
|
627
|
+
"ipab templates render web-app dashboard --param webAppDependency=0.1.0-rc.2",
|
|
628
|
+
"ipab templates render ./template.car hello --description Demo",
|
|
629
|
+
],
|
|
630
|
+
notes: [
|
|
631
|
+
"Short selectors resolve through the selected Swarm's typed root configuration (legacy v2/v3/v4 use Meta Name ipab); no builtin fallback.",
|
|
632
|
+
"Explicit directory, CAR and available exact CID work offline without a Swarm.",
|
|
633
|
+
"Does not install dependencies or execute template code.",
|
|
482
634
|
],
|
|
483
|
-
notes: ["Does not install dependencies or execute template code."],
|
|
484
635
|
},
|
|
485
636
|
build: {
|
|
486
637
|
summary: "Assemble any Bundle using ipab.build.yaml (no compilation)",
|
|
@@ -546,8 +697,8 @@ const commandHelp: Record<
|
|
|
546
697
|
],
|
|
547
698
|
options: [
|
|
548
699
|
"--log Record stdout/stderr; must precede APP. Requires history enabled.",
|
|
549
|
-
"--
|
|
550
|
-
"--no-
|
|
700
|
+
"--refresh Refresh the shared Name's swarm HEAD; must precede APP.",
|
|
701
|
+
"--no-refresh Override swarm.forceRefresh; must precede APP.",
|
|
551
702
|
],
|
|
552
703
|
examples: [
|
|
553
704
|
"ipab exec reader",
|
|
@@ -570,16 +721,17 @@ const commandHelp: Record<
|
|
|
570
721
|
options: [
|
|
571
722
|
"--log Record stdout/stderr; requires history enabled.",
|
|
572
723
|
"--raw Open the Artifact node rather than its value.",
|
|
573
|
-
"--
|
|
574
|
-
"--no-
|
|
724
|
+
"--refresh Refresh the shared Name's swarm HEAD.",
|
|
725
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
575
726
|
],
|
|
576
727
|
examples: [
|
|
577
728
|
"ipab open CONTENT_CID",
|
|
578
|
-
"ipab open --log
|
|
579
|
-
"ipab open ipab:///
|
|
729
|
+
"ipab open --log --refresh ipab:///documents/readme",
|
|
730
|
+
"ipab open ipab:///",
|
|
580
731
|
],
|
|
581
732
|
notes: [
|
|
582
733
|
"Requires a saved registration and App support for the exact content type.",
|
|
734
|
+
"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.",
|
|
583
735
|
"Uses only the content URI's Swarm, otherwise --swarm, otherwise swarm.default. A selected Swarm is required.",
|
|
584
736
|
"A registered App's retrieval, compatibility or execution failure never triggers fallback.",
|
|
585
737
|
"Legacy User registrations are inactive and preserved in the state database's legacy_user_registrations table; review them before explicit Swarm registration.",
|
|
@@ -594,6 +746,9 @@ const commandHelp: Record<
|
|
|
594
746
|
arguments: [
|
|
595
747
|
"REF Exact Bundle CID or ipab://SWARM/NAME; no local content aliases.",
|
|
596
748
|
],
|
|
749
|
+
options: [
|
|
750
|
+
"--refresh / --no-refresh Refresh shared HEAD now / allow its valid cached snapshot.",
|
|
751
|
+
],
|
|
597
752
|
examples: [
|
|
598
753
|
"ipab pin APP_CID",
|
|
599
754
|
"ipab pin ipab://work/apps/reader",
|
|
@@ -628,15 +783,15 @@ const commandHelp: Record<
|
|
|
628
783
|
},
|
|
629
784
|
"pin show": {
|
|
630
785
|
summary: "Show saved retention and following status",
|
|
631
|
-
examples: ["ipab pin show APP_CID"
|
|
786
|
+
examples: ["ipab pin show APP_CID"],
|
|
632
787
|
notes: [
|
|
633
788
|
"Reads local metadata; built-in pins do not claim user Store retention.",
|
|
634
789
|
],
|
|
635
790
|
},
|
|
636
791
|
"register list": {
|
|
637
|
-
summary: "List
|
|
792
|
+
summary: "List content-type associations in the current or selected Swarm",
|
|
638
793
|
options: [
|
|
639
|
-
"--swarm URL_OR_ALIAS Read this Swarm registry;
|
|
794
|
+
"--swarm URL_OR_ALIAS Read only this Swarm registry; specify at most once.",
|
|
640
795
|
],
|
|
641
796
|
examples: ["ipab register list", "ipab register list --swarm work"],
|
|
642
797
|
notes: [
|
|
@@ -649,19 +804,18 @@ const commandHelp: Record<
|
|
|
649
804
|
arguments: [
|
|
650
805
|
"SCHEMA Exact type CID or builtin:node-app.v1.",
|
|
651
806
|
"APP App CID or Swarm IPAB URI; the exact CID is saved.",
|
|
652
|
-
"TEMPLATE App argv after --; must contain a whole argument % (default: %).",
|
|
653
807
|
],
|
|
654
808
|
options: [
|
|
655
809
|
"--replace Allow changing an existing association.",
|
|
656
810
|
"--swarm URL_OR_ALIAS Write this Swarm registry; repeat for multiple Swarms.",
|
|
657
811
|
],
|
|
658
812
|
examples: [
|
|
659
|
-
"ipab register set SCHEMA_CID
|
|
660
|
-
"ipab register set SCHEMA_CID reader '--' '--cid' '%'",
|
|
813
|
+
"ipab register set SCHEMA_CID APP_CID",
|
|
661
814
|
"ipab register set SCHEMA_CID ipab:///apps/reader --swarm work --swarm team",
|
|
662
815
|
],
|
|
663
816
|
notes: [
|
|
664
|
-
"
|
|
817
|
+
"Writes the Name META.registryPath/TYPE_CID directly to the App CID. Open passes only the content CID.",
|
|
818
|
+
"Custom per-association argv is unsupported; adapt the App or use ipab exec APP_CID ARGS.",
|
|
665
819
|
"Does not verify App type support; open checks it before execution.",
|
|
666
820
|
"Without explicit --swarm, writes the saved default Swarm. Swarm writes require HEAD write access.",
|
|
667
821
|
"Multiple Swarms commit sequentially, not atomically; failures report completed targets.",
|
|
@@ -767,7 +921,7 @@ Run Apps:
|
|
|
767
921
|
open ${commandHelp.open!.summary}
|
|
768
922
|
|
|
769
923
|
Create:
|
|
770
|
-
|
|
924
|
+
templates ${groups.templates}
|
|
771
925
|
build ${commandHelp.build!.summary}
|
|
772
926
|
bundle ${groups.bundle}
|
|
773
927
|
|
|
@@ -775,6 +929,7 @@ Manage:
|
|
|
775
929
|
doctor ${commandHelp.doctor!.summary}
|
|
776
930
|
profile ${commandHelp.profile!.summary}
|
|
777
931
|
swarm ${groups.swarm}
|
|
932
|
+
skills ${groups.skills}
|
|
778
933
|
search Search formal Names in the current swarm
|
|
779
934
|
publish ${commandHelp.publish!.summary}
|
|
780
935
|
get ${commandHelp.get!.summary}
|
|
@@ -800,7 +955,18 @@ ${footer}`;
|
|
|
800
955
|
return [
|
|
801
956
|
`${topic.summary}.\n\nUsage: ipab [GLOBAL_OPTIONS] ${usage}`,
|
|
802
957
|
...(topic.arguments ? [section("Arguments", topic.arguments)] : []),
|
|
803
|
-
...(topic.options
|
|
958
|
+
...(topic.options
|
|
959
|
+
? [
|
|
960
|
+
section(
|
|
961
|
+
"Options",
|
|
962
|
+
topic.options.map((line) =>
|
|
963
|
+
line.startsWith("--refresh")
|
|
964
|
+
? `${line} Legacy aliases: --force/--no-force.`
|
|
965
|
+
: line,
|
|
966
|
+
),
|
|
967
|
+
),
|
|
968
|
+
]
|
|
969
|
+
: []),
|
|
804
970
|
section("Examples", topic.examples),
|
|
805
971
|
...([
|
|
806
972
|
"swarm status",
|
|
@@ -853,11 +1019,17 @@ export function formatSearchResults(
|
|
|
853
1019
|
matches: Awaited<ReturnType<typeof searchNames>>["matches"],
|
|
854
1020
|
): string {
|
|
855
1021
|
return matches.length
|
|
856
|
-
?
|
|
857
|
-
.map(
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
1022
|
+
? alignedRows(
|
|
1023
|
+
matches.map((match) => [
|
|
1024
|
+
match.alias ?? match.swarm,
|
|
1025
|
+
match.name,
|
|
1026
|
+
match.targetCid,
|
|
1027
|
+
]),
|
|
1028
|
+
)
|
|
1029
|
+
.map((row, index) => {
|
|
1030
|
+
const match = matches[index]!;
|
|
1031
|
+
return `${row}\n ipab get ${formatNameReference(match.alias ?? match.swarm, match.name)}`;
|
|
1032
|
+
})
|
|
861
1033
|
.join("\n")
|
|
862
1034
|
: "No matching Names.";
|
|
863
1035
|
}
|
|
@@ -904,26 +1076,24 @@ function storageBytes(bytes: number): string {
|
|
|
904
1076
|
: `${scaled.toLocaleString("en-US", { maximumFractionDigits: 2 })} ${units[unit]} (${exact} bytes)`;
|
|
905
1077
|
}
|
|
906
1078
|
|
|
907
|
-
function
|
|
908
|
-
if (!rows.length) return empty;
|
|
1079
|
+
function alignedRows(rows: string[][]): string[] {
|
|
909
1080
|
const cells = rows.map((row) => row.map(printable));
|
|
910
|
-
const widths =
|
|
911
|
-
cells.reduce(
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
1081
|
+
const widths = (cells[0] ?? []).map((_, column) =>
|
|
1082
|
+
cells.reduce((width, row) => Math.max(width, stringWidth(row[column]!)), 0),
|
|
1083
|
+
);
|
|
1084
|
+
return cells.map((row) =>
|
|
1085
|
+
row
|
|
1086
|
+
.map((cell, column) =>
|
|
1087
|
+
column === widths.length - 1
|
|
1088
|
+
? cell
|
|
1089
|
+
: cell.padEnd(cell.length + widths[column]! - stringWidth(cell)),
|
|
1090
|
+
)
|
|
1091
|
+
.join(" "),
|
|
915
1092
|
);
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
column === headers.length - 1
|
|
921
|
-
? cell
|
|
922
|
-
: cell.padEnd(cell.length + widths[column]! - stringWidth(cell)),
|
|
923
|
-
)
|
|
924
|
-
.join(" "),
|
|
925
|
-
)
|
|
926
|
-
.join("\n");
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
function table(headers: string[], rows: string[][], empty: string): string {
|
|
1096
|
+
return rows.length ? alignedRows([headers, ...rows]).join("\n") : empty;
|
|
927
1097
|
}
|
|
928
1098
|
|
|
929
1099
|
function runDetails(record: RunRecord): string {
|
|
@@ -964,9 +1134,16 @@ interface Parsed {
|
|
|
964
1134
|
template?: string[];
|
|
965
1135
|
parameters?: string[];
|
|
966
1136
|
registrySwarms?: string[];
|
|
1137
|
+
agents?: string[];
|
|
967
1138
|
help: boolean;
|
|
968
1139
|
version: boolean;
|
|
969
1140
|
}
|
|
1141
|
+
function validateRefreshOptions(options: Parsed["options"]): void {
|
|
1142
|
+
const positive = ["refresh", "force"].find((key) => options[key]);
|
|
1143
|
+
const negative = ["no-refresh", "no-force"].find((key) => options[key]);
|
|
1144
|
+
if (positive && negative)
|
|
1145
|
+
syntax(`--${positive} and --${negative} are mutually exclusive.`);
|
|
1146
|
+
}
|
|
970
1147
|
|
|
971
1148
|
async function closeStore(
|
|
972
1149
|
store: IpfsStore | undefined,
|
|
@@ -1032,6 +1209,12 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1032
1209
|
} else syntax(`Unknown global option "${flag}".`);
|
|
1033
1210
|
}
|
|
1034
1211
|
const group = tokens.shift() ?? "";
|
|
1212
|
+
if (group === "init")
|
|
1213
|
+
syntax(
|
|
1214
|
+
"Root init was removed. Use ipab templates render TEMPLATE NAME [DIR]; TEMPLATE is the first positional argument, not --template.",
|
|
1215
|
+
);
|
|
1216
|
+
if (group === "templates" && swarms.length > 1)
|
|
1217
|
+
syntax("Templates accepts only one global --swarm, before the command.");
|
|
1035
1218
|
const result: Parsed = {
|
|
1036
1219
|
flags,
|
|
1037
1220
|
path: group,
|
|
@@ -1044,14 +1227,17 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1044
1227
|
if (!group) return result;
|
|
1045
1228
|
if (group === "exec") {
|
|
1046
1229
|
if (flags.json) syntax("--json is not supported for exec/open.");
|
|
1047
|
-
while (
|
|
1230
|
+
while (
|
|
1231
|
+
["--log", "--force", "--no-force", "--refresh", "--no-refresh"].includes(
|
|
1232
|
+
tokens[0] ?? "",
|
|
1233
|
+
)
|
|
1234
|
+
) {
|
|
1048
1235
|
const option = tokens.shift()!.slice(2);
|
|
1049
1236
|
if (Object.hasOwn(result.options, option))
|
|
1050
1237
|
syntax(`Duplicate option --${option}.`);
|
|
1051
1238
|
result.options[option] = true;
|
|
1052
1239
|
}
|
|
1053
|
-
|
|
1054
|
-
syntax("--force and --no-force are mutually exclusive.");
|
|
1240
|
+
validateRefreshOptions(result.options);
|
|
1055
1241
|
if (tokens[0] === "-h" || tokens[0] === "--help") {
|
|
1056
1242
|
result.help = true;
|
|
1057
1243
|
return result;
|
|
@@ -1064,12 +1250,12 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1064
1250
|
if (
|
|
1065
1251
|
![
|
|
1066
1252
|
"open",
|
|
1067
|
-
"init",
|
|
1068
1253
|
"build",
|
|
1069
1254
|
"publish",
|
|
1070
1255
|
"get",
|
|
1071
1256
|
"search",
|
|
1072
1257
|
"doctor",
|
|
1258
|
+
"daemon",
|
|
1073
1259
|
"profile",
|
|
1074
1260
|
"unpin",
|
|
1075
1261
|
].includes(group)
|
|
@@ -1079,10 +1265,12 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1079
1265
|
"bundle",
|
|
1080
1266
|
"pin",
|
|
1081
1267
|
"register",
|
|
1268
|
+
"templates",
|
|
1082
1269
|
"config",
|
|
1083
1270
|
"history",
|
|
1084
1271
|
"store",
|
|
1085
1272
|
"swarm",
|
|
1273
|
+
"skills",
|
|
1086
1274
|
].includes(group)
|
|
1087
1275
|
)
|
|
1088
1276
|
syntax(
|
|
@@ -1099,7 +1287,15 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1099
1287
|
} else result.path = `${group} ${tokens.shift()!}`;
|
|
1100
1288
|
} else if (group === "open" && flags.json)
|
|
1101
1289
|
syntax("--json is not supported for exec/open.");
|
|
1290
|
+
if (result.path === "swarm add")
|
|
1291
|
+
syntax(
|
|
1292
|
+
"swarm add was removed. Use ipab swarm set ALIAS CONFIG_URL for local naming, then ipab swarm request ALIAS to request membership.",
|
|
1293
|
+
);
|
|
1102
1294
|
if (!commands[result.path]) syntax(`Unknown command "${result.path}".`);
|
|
1295
|
+
if (group === "skills" && swarms.length > 1)
|
|
1296
|
+
syntax(
|
|
1297
|
+
"Skills operations select exactly one Swarm; repeated --swarm is not supported.",
|
|
1298
|
+
);
|
|
1103
1299
|
const separator = result.path === "register set" ? tokens.indexOf("--") : -1;
|
|
1104
1300
|
if (separator >= 0) result.template = tokens.splice(separator + 1);
|
|
1105
1301
|
if (separator >= 0) tokens.splice(separator);
|
|
@@ -1115,8 +1311,11 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1115
1311
|
syntax(
|
|
1116
1312
|
"API key must be provided through '-' and piped stdin; never pass it in command arguments.",
|
|
1117
1313
|
);
|
|
1118
|
-
const booleans =
|
|
1119
|
-
result.path === "
|
|
1314
|
+
const booleans = result.path.startsWith("skills ")
|
|
1315
|
+
? result.path === "skills sync"
|
|
1316
|
+
? ["dry-run", "yes", "force", "no-force"]
|
|
1317
|
+
: ["force", "no-force"]
|
|
1318
|
+
: result.path === "doctor"
|
|
1120
1319
|
? ["fix", "yes"]
|
|
1121
1320
|
: result.path === "bundle build"
|
|
1122
1321
|
? ["replace", "schema-only", "no-import"]
|
|
@@ -1124,15 +1323,24 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1124
1323
|
? ["replace", "no-import"]
|
|
1125
1324
|
: result.path === "publish"
|
|
1126
1325
|
? ["snapshot"]
|
|
1127
|
-
:
|
|
1128
|
-
|
|
1326
|
+
: [
|
|
1327
|
+
"get",
|
|
1328
|
+
"templates render",
|
|
1329
|
+
"templates list",
|
|
1330
|
+
"templates show",
|
|
1331
|
+
].includes(result.path)
|
|
1332
|
+
? result.path === "templates render"
|
|
1333
|
+
? ["force", "no-force"]
|
|
1334
|
+
: result.path === "get"
|
|
1335
|
+
? ["raw", "force", "no-force"]
|
|
1336
|
+
: ["force", "no-force"]
|
|
1129
1337
|
: result.path === "search"
|
|
1130
1338
|
? ["all", "current", "force", "no-force"]
|
|
1131
1339
|
: result.path === "swarm approve"
|
|
1132
1340
|
? ["yes", "again"]
|
|
1133
|
-
:
|
|
1134
|
-
? ["local"]
|
|
1135
|
-
:
|
|
1341
|
+
: ["swarm status", "swarm members"].includes(result.path)
|
|
1342
|
+
? ["local", "force", "no-force"]
|
|
1343
|
+
: ["swarm exclude", "swarm set"].includes(result.path)
|
|
1136
1344
|
? ["yes"]
|
|
1137
1345
|
: result.path === "register set"
|
|
1138
1346
|
? ["replace"]
|
|
@@ -1140,43 +1348,46 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1140
1348
|
? ["yes"]
|
|
1141
1349
|
: result.path === "open"
|
|
1142
1350
|
? ["log", "raw", "force", "no-force"]
|
|
1143
|
-
:
|
|
1351
|
+
: result.path === "pin"
|
|
1352
|
+
? ["force", "no-force"]
|
|
1353
|
+
: [];
|
|
1354
|
+
if (booleans.includes("force")) booleans.push("refresh", "no-refresh");
|
|
1144
1355
|
const values =
|
|
1145
1356
|
result.path === "swarm create"
|
|
1146
1357
|
? ["service", "resume", "name", "description", "alias"]
|
|
1147
|
-
: result.path === "swarm
|
|
1148
|
-
? ["
|
|
1149
|
-
: result.path === "swarm
|
|
1150
|
-
? ["
|
|
1151
|
-
: result.path === "swarm
|
|
1152
|
-
? ["
|
|
1153
|
-
: result.path === "swarm profile"
|
|
1154
|
-
? ["
|
|
1155
|
-
: result.path === "swarm
|
|
1156
|
-
? [
|
|
1157
|
-
:
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1358
|
+
: result.path === "swarm request"
|
|
1359
|
+
? ["output"]
|
|
1360
|
+
: result.path === "swarm export"
|
|
1361
|
+
? ["output"]
|
|
1362
|
+
: result.path === "swarm profile"
|
|
1363
|
+
? ["address"]
|
|
1364
|
+
: result.path === "swarm update" || result.path === "profile"
|
|
1365
|
+
? ["name", "description"]
|
|
1366
|
+
: result.path === "swarm approve"
|
|
1367
|
+
? []
|
|
1368
|
+
: ["publish", "templates set", "templates remove"].includes(
|
|
1369
|
+
result.path,
|
|
1370
|
+
)
|
|
1371
|
+
? ["expect"]
|
|
1372
|
+
: result.path === "get"
|
|
1373
|
+
? ["output"]
|
|
1374
|
+
: result.path === "templates render"
|
|
1375
|
+
? ["description"]
|
|
1376
|
+
: result.path === "bundle build" ||
|
|
1377
|
+
result.path === "build"
|
|
1378
|
+
? ["output"]
|
|
1379
|
+
: result.path === "history list"
|
|
1380
|
+
? [
|
|
1381
|
+
"app",
|
|
1382
|
+
"status",
|
|
1383
|
+
"since",
|
|
1384
|
+
"until",
|
|
1385
|
+
"limit",
|
|
1386
|
+
"before",
|
|
1387
|
+
]
|
|
1388
|
+
: result.path === "history remove"
|
|
1389
|
+
? ["app", "status", "since", "until"]
|
|
1390
|
+
: [];
|
|
1180
1391
|
while (tokens.length) {
|
|
1181
1392
|
const value = tokens.shift()!;
|
|
1182
1393
|
if (
|
|
@@ -1186,6 +1397,20 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1186
1397
|
result.positional.push(value);
|
|
1187
1398
|
} else if (value.startsWith("--") || value === "-o") {
|
|
1188
1399
|
const option = value === "-o" ? "output" : value.slice(2);
|
|
1400
|
+
if (result.path === "daemon" && option === "swarm") {
|
|
1401
|
+
const input = tokens.shift();
|
|
1402
|
+
if (!input || input.startsWith("-")) syntax("--swarm needs a value.");
|
|
1403
|
+
if (flags.swarm !== undefined)
|
|
1404
|
+
syntax("daemon accepts --swarm at most once.");
|
|
1405
|
+
flags.swarm = input;
|
|
1406
|
+
continue;
|
|
1407
|
+
}
|
|
1408
|
+
if (result.path === "skills sync" && option === "agent") {
|
|
1409
|
+
const input = tokens.shift();
|
|
1410
|
+
if (!input || input.startsWith("-")) syntax("--agent needs a value.");
|
|
1411
|
+
(result.agents ??= []).push(input);
|
|
1412
|
+
continue;
|
|
1413
|
+
}
|
|
1189
1414
|
if (result.path.startsWith("register ") && option === "swarm") {
|
|
1190
1415
|
const input = tokens.shift();
|
|
1191
1416
|
if (!input || input.startsWith("-")) syntax("--swarm needs a value.");
|
|
@@ -1193,13 +1418,21 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1193
1418
|
flags.swarm = input;
|
|
1194
1419
|
continue;
|
|
1195
1420
|
}
|
|
1196
|
-
if (result.path === "
|
|
1421
|
+
if (result.path === "templates render" && option === "template")
|
|
1422
|
+
syntax(
|
|
1423
|
+
"--template was removed. Use ipab templates render TEMPLATE NAME [DIR], with TEMPLATE first.",
|
|
1424
|
+
);
|
|
1425
|
+
if (result.path === "templates render" && option === "param") {
|
|
1197
1426
|
const input = tokens.shift();
|
|
1198
1427
|
if (!input || input.startsWith("--") || input.indexOf("=") < 1)
|
|
1199
1428
|
syntax("--param requires KEY=VALUE.");
|
|
1200
1429
|
(result.parameters ??= []).push(input);
|
|
1201
1430
|
continue;
|
|
1202
1431
|
}
|
|
1432
|
+
if (result.path === "swarm request" && option === "alias")
|
|
1433
|
+
syntax(
|
|
1434
|
+
"swarm request --alias was removed. First run ipab swarm set ALIAS CONFIG_URL, then ipab swarm request ALIAS.",
|
|
1435
|
+
);
|
|
1203
1436
|
if (Object.hasOwn(result.options, option))
|
|
1204
1437
|
syntax(`Duplicate option ${value}.`);
|
|
1205
1438
|
if (booleans.includes(option)) result.options[option] = true;
|
|
@@ -1209,7 +1442,10 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1209
1442
|
input === undefined ||
|
|
1210
1443
|
(input.startsWith("--") &&
|
|
1211
1444
|
!(option === "resume" && /^[A-Za-z0-9_-]{43}$/.test(input))) ||
|
|
1212
|
-
(input === "" &&
|
|
1445
|
+
(input === "" &&
|
|
1446
|
+
!["swarm update", "profile", "templates render"].includes(
|
|
1447
|
+
result.path,
|
|
1448
|
+
))
|
|
1213
1449
|
)
|
|
1214
1450
|
syntax(`${value} needs a value.`);
|
|
1215
1451
|
result.options[option] = input;
|
|
@@ -1223,8 +1459,7 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1223
1459
|
else syntax(`Unknown option "${value}".`);
|
|
1224
1460
|
} else result.positional.push(value);
|
|
1225
1461
|
}
|
|
1226
|
-
|
|
1227
|
-
syntax("--force and --no-force are mutually exclusive.");
|
|
1462
|
+
validateRefreshOptions(result.options);
|
|
1228
1463
|
if (
|
|
1229
1464
|
result.path === "search" &&
|
|
1230
1465
|
result.options.current &&
|
|
@@ -1237,8 +1472,18 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1237
1472
|
(result.options.current || flags.swarm !== undefined)
|
|
1238
1473
|
)
|
|
1239
1474
|
syntax("--all is mutually exclusive with --current and --swarm.");
|
|
1475
|
+
if (
|
|
1476
|
+
result.path === "register list" &&
|
|
1477
|
+
(result.registrySwarms?.length ?? 0) > 1
|
|
1478
|
+
)
|
|
1479
|
+
syntax(
|
|
1480
|
+
"register list accepts --swarm at most once. Select one Swarm or omit it to use the current Swarm.",
|
|
1481
|
+
);
|
|
1240
1482
|
const counts: Record<string, [number, number]> = {
|
|
1483
|
+
daemon: [0, 0],
|
|
1241
1484
|
doctor: [0, 0],
|
|
1485
|
+
"skills list": [0, 0],
|
|
1486
|
+
"skills sync": [0, Number.MAX_SAFE_INTEGER],
|
|
1242
1487
|
profile: [0, 0],
|
|
1243
1488
|
"swarm create": [0, 0],
|
|
1244
1489
|
"swarm request": [1, 1],
|
|
@@ -1250,14 +1495,14 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1250
1495
|
"swarm status": [0, 0],
|
|
1251
1496
|
"swarm members": [0, 0],
|
|
1252
1497
|
"swarm list": [0, 0],
|
|
1253
|
-
"swarm
|
|
1498
|
+
"swarm set": [2, 2],
|
|
1254
1499
|
"swarm use": [1, 1],
|
|
1255
1500
|
"swarm remove": [1, 1],
|
|
1256
1501
|
"swarm update": [0, 0],
|
|
1257
1502
|
publish: [2, 2],
|
|
1258
1503
|
get: [1, 1],
|
|
1259
1504
|
search: [1, 1],
|
|
1260
|
-
|
|
1505
|
+
"templates render": [2, 3],
|
|
1261
1506
|
build: [0, 1],
|
|
1262
1507
|
"bundle build": [1, 1],
|
|
1263
1508
|
"bundle inspect": [1, 1],
|
|
@@ -1270,6 +1515,10 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1270
1515
|
"register list": [0, 0],
|
|
1271
1516
|
"register set": [2, 2],
|
|
1272
1517
|
"register remove": [1, 1],
|
|
1518
|
+
"templates list": [0, 0],
|
|
1519
|
+
"templates show": [1, 1],
|
|
1520
|
+
"templates set": [2, 2],
|
|
1521
|
+
"templates remove": [1, 1],
|
|
1273
1522
|
"config get": [0, 1],
|
|
1274
1523
|
"config set": [2, 2],
|
|
1275
1524
|
"config reset": [1, 1],
|
|
@@ -1300,11 +1549,10 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1300
1549
|
);
|
|
1301
1550
|
if (result.positional.length < minimum || result.positional.length > maximum)
|
|
1302
1551
|
syntax(`Invalid arguments.\n${help(result.path)}`);
|
|
1303
|
-
if (
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
syntax('Argument template must contain a whole "%" token.');
|
|
1552
|
+
if (result.template)
|
|
1553
|
+
syntax(
|
|
1554
|
+
'Custom per-association argv is unsupported. Remove "-- TEMPLATE..."; open passes only the content CID. Adapt the App or use ipab exec APP_CID ARGS.',
|
|
1555
|
+
);
|
|
1308
1556
|
if (result.path === "history remove") {
|
|
1309
1557
|
const selected = values.some((value) =>
|
|
1310
1558
|
Object.hasOwn(result.options, value),
|
|
@@ -1337,6 +1585,16 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1337
1585
|
"--snapshot is initial-only and cannot be combined with --expect.",
|
|
1338
1586
|
);
|
|
1339
1587
|
}
|
|
1588
|
+
if (
|
|
1589
|
+
result.path.startsWith("templates ") &&
|
|
1590
|
+
result.path !== "templates render"
|
|
1591
|
+
) {
|
|
1592
|
+
if (result.positional[0] !== undefined) templateName(result.positional[0]);
|
|
1593
|
+
if (typeof result.options.expect === "string")
|
|
1594
|
+
exactCid(result.options.expect);
|
|
1595
|
+
if (result.path === "templates remove" && !result.options.expect)
|
|
1596
|
+
syntax("templates remove requires --expect OLD_TARGET_CID.");
|
|
1597
|
+
}
|
|
1340
1598
|
if (result.path.startsWith("config ") && result.positional[0]) {
|
|
1341
1599
|
if (
|
|
1342
1600
|
!(result.path === "config get" && result.positional[0] === "state-dir") &&
|
|
@@ -1443,9 +1701,12 @@ async function performCli(
|
|
|
1443
1701
|
}
|
|
1444
1702
|
const items = effectiveConfig(
|
|
1445
1703
|
state.config({
|
|
1446
|
-
includeSecrets:
|
|
1447
|
-
|
|
1448
|
-
|
|
1704
|
+
includeSecrets: ![
|
|
1705
|
+
"swarm members",
|
|
1706
|
+
"profile",
|
|
1707
|
+
"swarm status",
|
|
1708
|
+
"swarm set",
|
|
1709
|
+
].includes(parsed.path),
|
|
1449
1710
|
}),
|
|
1450
1711
|
parsed.flags,
|
|
1451
1712
|
env,
|
|
@@ -1480,11 +1741,13 @@ async function performCli(
|
|
|
1480
1741
|
stateDir: stateLocation(parsed.flags, env).path,
|
|
1481
1742
|
cacheTtl: Number(value("swarm.cacheTtl")),
|
|
1482
1743
|
listen: value("swarm.listen") === "loopback" ? "loopback" : "lan",
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
?
|
|
1487
|
-
:
|
|
1744
|
+
pivot: Boolean(value("swarm.pivot")),
|
|
1745
|
+
forceRefresh:
|
|
1746
|
+
parsed.options.refresh || parsed.options.force
|
|
1747
|
+
? true
|
|
1748
|
+
: parsed.options["no-refresh"] || parsed.options["no-force"]
|
|
1749
|
+
? false
|
|
1750
|
+
: Boolean(value("swarm.forceRefresh")),
|
|
1488
1751
|
diagnostic: (text) => {
|
|
1489
1752
|
io.err(text);
|
|
1490
1753
|
},
|
|
@@ -1512,13 +1775,130 @@ async function performCli(
|
|
|
1512
1775
|
if (parsed.path === "open" || parsed.path.startsWith("register ")) {
|
|
1513
1776
|
if (state.legacyRegistrationCount)
|
|
1514
1777
|
io.err(
|
|
1515
|
-
`Legacy User registrations are inactive. ${state.legacyRegistrationCount} entries are preserved in legacy_user_registrations in the state database under ${state.directory}; nothing was uploaded or deleted. Review the archived values and explicitly run ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS
|
|
1778
|
+
`Legacy User registrations are inactive. ${state.legacyRegistrationCount} entries are preserved in legacy_user_registrations in the state database under ${state.directory}; nothing was uploaded or deleted. Custom per-association argv is unsupported. Review the archived values and explicitly run ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS to publish only intended associations.`,
|
|
1516
1779
|
);
|
|
1517
1780
|
}
|
|
1518
1781
|
if (state.legacyPinCount)
|
|
1519
1782
|
io.err(
|
|
1520
1783
|
`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.`,
|
|
1521
1784
|
);
|
|
1785
|
+
if (
|
|
1786
|
+
parsed.path.startsWith("templates ") &&
|
|
1787
|
+
parsed.path !== "templates render"
|
|
1788
|
+
) {
|
|
1789
|
+
const configUrl = requireSwarm();
|
|
1790
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1791
|
+
const context = swarmContext();
|
|
1792
|
+
const expected =
|
|
1793
|
+
typeof parsed.options.expect === "string"
|
|
1794
|
+
? parsed.options.expect
|
|
1795
|
+
: undefined;
|
|
1796
|
+
try {
|
|
1797
|
+
if (parsed.path === "templates list") {
|
|
1798
|
+
const items = await swarmTemplates(context, configUrl);
|
|
1799
|
+
const alias = state
|
|
1800
|
+
.swarms()
|
|
1801
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1802
|
+
emit(
|
|
1803
|
+
{ items },
|
|
1804
|
+
`Swarm: ${alias ? printable(alias) : "(no local alias)"}\nConfig URL: ${configUrl}\nTemplates: ${items.length}\n\n${table(
|
|
1805
|
+
["NAME", "TITLE", "TARGET CID", "TEMPLATE CID"],
|
|
1806
|
+
items.map((item) => [
|
|
1807
|
+
item.selector,
|
|
1808
|
+
item.title,
|
|
1809
|
+
item.targetCid,
|
|
1810
|
+
item.templateCid,
|
|
1811
|
+
]),
|
|
1812
|
+
"No templates registered in this Swarm.\nAdd a template: ipab templates set NAME SOURCE",
|
|
1813
|
+
)}`,
|
|
1814
|
+
);
|
|
1815
|
+
} else if (parsed.path === "templates show") {
|
|
1816
|
+
const item = (await swarmTemplates(context, configUrl, first))[0]!;
|
|
1817
|
+
if (parsed.flags.json) io.out(JSON.stringify(item));
|
|
1818
|
+
else {
|
|
1819
|
+
const alias = state
|
|
1820
|
+
.swarms()
|
|
1821
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1822
|
+
const swarm = alias ?? configUrl;
|
|
1823
|
+
const reference = formatNameReference(swarm, item.name);
|
|
1824
|
+
const tree = await templateOutputTree(
|
|
1825
|
+
context.store,
|
|
1826
|
+
item.templateCid,
|
|
1827
|
+
);
|
|
1828
|
+
const shell = process.platform === "win32" ? "powershell" : "posix";
|
|
1829
|
+
io.out(
|
|
1830
|
+
[
|
|
1831
|
+
`${printable(item.selector)} — ${printable(item.title)}`,
|
|
1832
|
+
printable(item.description) || "(No description.)",
|
|
1833
|
+
"",
|
|
1834
|
+
"Location",
|
|
1835
|
+
` Swarm: ${printable(swarm)}`,
|
|
1836
|
+
` Name: ${printable(item.name)}`,
|
|
1837
|
+
"",
|
|
1838
|
+
`Create a project (${shell === "powershell" ? "PowerShell" : "POSIX shell"})`,
|
|
1839
|
+
` ${templateRenderExample(reference, swarm, item.definition, shell)}`,
|
|
1840
|
+
" Replace example parameter values as needed. No code is run by show.",
|
|
1841
|
+
"",
|
|
1842
|
+
"Parameters",
|
|
1843
|
+
table(
|
|
1844
|
+
["NAME", "TYPE", "REQUIRED", "DEFAULT", "INPUT"],
|
|
1845
|
+
templateParameterRows(item.definition),
|
|
1846
|
+
"No parameters declared.",
|
|
1847
|
+
),
|
|
1848
|
+
"Required means an input is needed when no default is declared.",
|
|
1849
|
+
"",
|
|
1850
|
+
"Output files (from project/)",
|
|
1851
|
+
" my-project/",
|
|
1852
|
+
...tree.entries.map(
|
|
1853
|
+
(entry) =>
|
|
1854
|
+
`${" ".repeat(entry.path.split("/").length + 1)}${printable(entry.path.split("/").at(-1)!)}${entry.kind === "directory" ? "/" : ""}`,
|
|
1855
|
+
),
|
|
1856
|
+
...(tree.truncated
|
|
1857
|
+
? [
|
|
1858
|
+
` ... truncated: ${tree.truncated}; more files may exist.`,
|
|
1859
|
+
]
|
|
1860
|
+
: tree.entries.length
|
|
1861
|
+
? []
|
|
1862
|
+
: [" (no output files)"]),
|
|
1863
|
+
"",
|
|
1864
|
+
"Versions",
|
|
1865
|
+
` Template CID: ${item.templateCid}`,
|
|
1866
|
+
` Reference: ${reference}`,
|
|
1867
|
+
...(item.targetCid !== item.templateCid
|
|
1868
|
+
? [` Target CID (--expect): ${item.targetCid}`]
|
|
1869
|
+
: []),
|
|
1870
|
+
].join("\n"),
|
|
1871
|
+
);
|
|
1872
|
+
}
|
|
1873
|
+
} else if (parsed.path === "templates set") {
|
|
1874
|
+
const item = await setSwarmTemplate(
|
|
1875
|
+
context,
|
|
1876
|
+
configUrl,
|
|
1877
|
+
first!,
|
|
1878
|
+
second!,
|
|
1879
|
+
expected,
|
|
1880
|
+
);
|
|
1881
|
+
emit(
|
|
1882
|
+
item,
|
|
1883
|
+
`${item.reference} → ${item.targetCid} (Template ${item.templateCid})`,
|
|
1884
|
+
);
|
|
1885
|
+
} else {
|
|
1886
|
+
const item = await removeSwarmTemplate(
|
|
1887
|
+
context,
|
|
1888
|
+
configUrl,
|
|
1889
|
+
first!,
|
|
1890
|
+
expected!,
|
|
1891
|
+
);
|
|
1892
|
+
emit(
|
|
1893
|
+
{ removed: item },
|
|
1894
|
+
`Removed ${item.reference}; content and history are retained.`,
|
|
1895
|
+
);
|
|
1896
|
+
}
|
|
1897
|
+
} finally {
|
|
1898
|
+
await context.finishRead?.();
|
|
1899
|
+
}
|
|
1900
|
+
return 0;
|
|
1901
|
+
}
|
|
1522
1902
|
if (parsed.path.startsWith("register ")) {
|
|
1523
1903
|
const references = parsed.registrySwarms?.length
|
|
1524
1904
|
? parsed.registrySwarms
|
|
@@ -1527,7 +1907,7 @@ async function performCli(
|
|
|
1527
1907
|
: [];
|
|
1528
1908
|
if (!references.length)
|
|
1529
1909
|
throw new HostError(
|
|
1530
|
-
"Register requires a selected Swarm. Pass --swarm URL_OR_ALIAS
|
|
1910
|
+
"Register requires a selected Swarm. Pass --swarm URL_OR_ALIAS, or save a default with ipab swarm use URL_OR_ALIAS.",
|
|
1531
1911
|
);
|
|
1532
1912
|
const targets = [
|
|
1533
1913
|
...new Set(
|
|
@@ -1556,16 +1936,15 @@ async function performCli(
|
|
|
1556
1936
|
try {
|
|
1557
1937
|
if (parsed.path === "register list") {
|
|
1558
1938
|
const items = await swarmRegistrations(context, configUrl);
|
|
1939
|
+
const alias = state
|
|
1940
|
+
.swarms()
|
|
1941
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1559
1942
|
results.push({ items });
|
|
1560
1943
|
human.push(
|
|
1561
|
-
|
|
1562
|
-
["
|
|
1563
|
-
items.map((item) => [
|
|
1564
|
-
|
|
1565
|
-
item.appCid,
|
|
1566
|
-
JSON.stringify(item.argv),
|
|
1567
|
-
]),
|
|
1568
|
-
"No associations.",
|
|
1944
|
+
`Swarm: ${alias ? printable(alias) : "(no local alias)"}\nConfig URL: ${configUrl}\nAssociations: ${items.length}\n\n${table(
|
|
1945
|
+
["TYPE CID", "APP CID"],
|
|
1946
|
+
items.map((item) => [item.schemaCid, item.appCid]),
|
|
1947
|
+
"No associations registered in this Swarm.\nRegister an App: ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS",
|
|
1569
1948
|
)}`,
|
|
1570
1949
|
);
|
|
1571
1950
|
} else if (parsed.path === "register set") {
|
|
@@ -1601,7 +1980,9 @@ async function performCli(
|
|
|
1601
1980
|
completed.push(configUrl);
|
|
1602
1981
|
} catch (cause) {
|
|
1603
1982
|
throw new HostError(
|
|
1604
|
-
|
|
1983
|
+
parsed.path === "register list"
|
|
1984
|
+
? `Cannot list associations for Swarm ${configUrl}: ${message(cause)}`
|
|
1985
|
+
: `Registry operation failed for ${configUrl}: ${message(cause)}. Completed Swarms: ${completed.length ? completed.join(", ") : "(none)"}. Multiple Swarm edits are not atomic.`,
|
|
1605
1986
|
cause instanceof HostError ? cause.exitCode : 1,
|
|
1606
1987
|
cause instanceof HostError ? cause.code : "REGISTRY_FAILED",
|
|
1607
1988
|
"publication",
|
|
@@ -1673,9 +2054,11 @@ async function performCli(
|
|
|
1673
2054
|
})),
|
|
1674
2055
|
},
|
|
1675
2056
|
[
|
|
1676
|
-
...
|
|
1677
|
-
(entry) =>
|
|
1678
|
-
`${entry.cid === result.effectiveCurrent ? "*" : " "} ${
|
|
2057
|
+
...alignedRows(
|
|
2058
|
+
result.swarms.map((entry) => [
|
|
2059
|
+
`${entry.cid === result.effectiveCurrent ? "*" : " "} ${entry.alias ?? entry.cid}`,
|
|
2060
|
+
entry.cid,
|
|
2061
|
+
]),
|
|
1679
2062
|
),
|
|
1680
2063
|
...(result.swarms.length ? [] : ["No registered Swarms."]),
|
|
1681
2064
|
...(result.effectiveCurrent === null
|
|
@@ -1712,9 +2095,65 @@ async function performCli(
|
|
|
1712
2095
|
);
|
|
1713
2096
|
break;
|
|
1714
2097
|
}
|
|
1715
|
-
case "swarm
|
|
2098
|
+
case "swarm set": {
|
|
2099
|
+
swarmAlias(first!);
|
|
2100
|
+
const cid = swarmUrl(second!);
|
|
2101
|
+
const previous = state.swarms().find((entry) => entry.alias === first);
|
|
2102
|
+
if (previous && previous.cid !== cid) {
|
|
2103
|
+
io.err(`Swarm alias ${first}: ${previous.cid} -> ${cid}`);
|
|
2104
|
+
if (
|
|
2105
|
+
!parsed.options.yes &&
|
|
2106
|
+
(!io.tty ||
|
|
2107
|
+
!(await io.confirm(
|
|
2108
|
+
`Retarget local Swarm alias "${first}" from ${previous.cid} to ${cid}?`,
|
|
2109
|
+
)))
|
|
2110
|
+
)
|
|
2111
|
+
throw new HostError(
|
|
2112
|
+
"Alias unchanged. Retargeting requires --yes or interactive confirmation.",
|
|
2113
|
+
);
|
|
2114
|
+
}
|
|
2115
|
+
const entry = state.setSwarm(first!, cid, previous?.cid ?? null);
|
|
2116
|
+
emit(
|
|
2117
|
+
{
|
|
2118
|
+
configUrl: entry.cid,
|
|
2119
|
+
alias: entry.alias,
|
|
2120
|
+
savedCurrent:
|
|
2121
|
+
state.config({ includeSecrets: false })["swarm.default"] ?? null,
|
|
2122
|
+
},
|
|
2123
|
+
`Set local swarm alias ${entry.alias} (${cid}).`,
|
|
2124
|
+
);
|
|
2125
|
+
break;
|
|
2126
|
+
}
|
|
2127
|
+
case "daemon": {
|
|
2128
|
+
if (parsed.flags.json)
|
|
2129
|
+
syntax(
|
|
2130
|
+
"--json is not supported for daemon; diagnostics are written to stderr.",
|
|
2131
|
+
);
|
|
2132
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
2133
|
+
const controller = new AbortController();
|
|
2134
|
+
const interrupt = () => {
|
|
2135
|
+
controller.abort();
|
|
2136
|
+
};
|
|
2137
|
+
process.once("SIGINT", interrupt);
|
|
2138
|
+
process.once("SIGTERM", interrupt);
|
|
2139
|
+
try {
|
|
2140
|
+
await swarmDaemon(
|
|
2141
|
+
swarmContext(),
|
|
2142
|
+
parsed.flags.swarm === undefined ? undefined : requireSwarm(),
|
|
2143
|
+
controller.signal,
|
|
2144
|
+
);
|
|
2145
|
+
} catch (cause) {
|
|
2146
|
+
if (!controller.signal.aborted) throw cause;
|
|
2147
|
+
} finally {
|
|
2148
|
+
process.removeListener("SIGINT", interrupt);
|
|
2149
|
+
process.removeListener("SIGTERM", interrupt);
|
|
2150
|
+
}
|
|
2151
|
+
break;
|
|
2152
|
+
}
|
|
1716
2153
|
case "swarm update":
|
|
1717
2154
|
case "search":
|
|
2155
|
+
case "skills list":
|
|
2156
|
+
case "skills sync":
|
|
1718
2157
|
case "swarm create":
|
|
1719
2158
|
case "swarm request":
|
|
1720
2159
|
case "swarm approve":
|
|
@@ -1730,6 +2169,47 @@ async function performCli(
|
|
|
1730
2169
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1731
2170
|
const context = swarmContext();
|
|
1732
2171
|
readContext = context;
|
|
2172
|
+
if (parsed.path.startsWith("skills ")) {
|
|
2173
|
+
const result = await manageSkills(context, requireSwarm(), {
|
|
2174
|
+
sync: parsed.path === "skills sync",
|
|
2175
|
+
names: parsed.positional,
|
|
2176
|
+
agents: parsed.agents ?? [],
|
|
2177
|
+
dryRun: Boolean(parsed.options["dry-run"]),
|
|
2178
|
+
yes: Boolean(parsed.options.yes),
|
|
2179
|
+
tty: io.tty,
|
|
2180
|
+
confirm: (text) => io.confirm(text),
|
|
2181
|
+
preview: (text) => {
|
|
2182
|
+
io.err(text);
|
|
2183
|
+
},
|
|
2184
|
+
});
|
|
2185
|
+
store = context.store;
|
|
2186
|
+
emit(
|
|
2187
|
+
result,
|
|
2188
|
+
[
|
|
2189
|
+
table(
|
|
2190
|
+
["NAME", "PAYLOAD CID", "INSTALL NAME", "STATUS"],
|
|
2191
|
+
result.items.map((skill) => [
|
|
2192
|
+
skill.name,
|
|
2193
|
+
skill.cid,
|
|
2194
|
+
skill.identity,
|
|
2195
|
+
skill.status,
|
|
2196
|
+
]),
|
|
2197
|
+
"No Skills.",
|
|
2198
|
+
),
|
|
2199
|
+
...result.items.flatMap((skill) => skill.problems),
|
|
2200
|
+
...result.orphaned.map(
|
|
2201
|
+
(skill) =>
|
|
2202
|
+
`Source removed: ${skill.name} ${skill.cid} (${skill.path}); installation retained.`,
|
|
2203
|
+
),
|
|
2204
|
+
...result.results.map(
|
|
2205
|
+
(entry) =>
|
|
2206
|
+
`${entry.name} / ${entry.agent}: ${entry.status}${entry.error ? `: ${entry.error}` : ""}`,
|
|
2207
|
+
),
|
|
2208
|
+
].join("\n"),
|
|
2209
|
+
);
|
|
2210
|
+
if (!result.ok) return 1;
|
|
2211
|
+
break;
|
|
2212
|
+
}
|
|
1733
2213
|
if (parsed.path === "pin") {
|
|
1734
2214
|
io.err("Fetching, verifying and retaining content...");
|
|
1735
2215
|
const result = await pinNameSubscription(
|
|
@@ -1745,20 +2225,33 @@ async function performCli(
|
|
|
1745
2225
|
break;
|
|
1746
2226
|
}
|
|
1747
2227
|
if (parsed.path === "swarm members") {
|
|
1748
|
-
const result = await swarmMembers(
|
|
2228
|
+
const result = await swarmMembers(
|
|
2229
|
+
context,
|
|
2230
|
+
requireSwarm(),
|
|
2231
|
+
Boolean(parsed.options.refresh || parsed.options.force),
|
|
2232
|
+
);
|
|
1749
2233
|
emit(
|
|
1750
2234
|
result,
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
result.
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
member
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
2235
|
+
[
|
|
2236
|
+
`Directory: ${result.cache.source} (${result.cache.freshness}), observed ${result.cache.updatedAt}`,
|
|
2237
|
+
`Daemon: ${result.local.status}, observed ${result.local.updatedAt ?? "unknown"}; control-plane verified ${result.local.verifiedAt ?? "unknown"}`,
|
|
2238
|
+
table(
|
|
2239
|
+
["NAME", "DESCRIPTION", "ROLE", "PIVOT", "PUBLIC KEY"],
|
|
2240
|
+
result.members.map((member) => [
|
|
2241
|
+
member.name,
|
|
2242
|
+
member.description,
|
|
2243
|
+
member.role,
|
|
2244
|
+
member.pivot ? (member.localStatus ?? "candidate") : "-",
|
|
2245
|
+
member.publicKey,
|
|
2246
|
+
]),
|
|
2247
|
+
"No members.",
|
|
2248
|
+
),
|
|
2249
|
+
].join("\n"),
|
|
1761
2250
|
);
|
|
2251
|
+
if (result.local.error)
|
|
2252
|
+
io.err(
|
|
2253
|
+
`Local Pivot observations (${result.local.status}): ${printable(result.local.error)}`,
|
|
2254
|
+
);
|
|
1762
2255
|
break;
|
|
1763
2256
|
}
|
|
1764
2257
|
if (parsed.path === "swarm export") {
|
|
@@ -1815,28 +2308,6 @@ async function performCli(
|
|
|
1815
2308
|
);
|
|
1816
2309
|
break;
|
|
1817
2310
|
}
|
|
1818
|
-
if (parsed.path === "swarm add") {
|
|
1819
|
-
const cid = state.resolveSwarm(first!);
|
|
1820
|
-
await addSwarm(
|
|
1821
|
-
context,
|
|
1822
|
-
cid,
|
|
1823
|
-
typeof parsed.options.alias === "string"
|
|
1824
|
-
? parsed.options.alias
|
|
1825
|
-
: undefined,
|
|
1826
|
-
);
|
|
1827
|
-
const entry = state.registeredSwarm(cid);
|
|
1828
|
-
emit(
|
|
1829
|
-
{
|
|
1830
|
-
configUrl: entry.cid,
|
|
1831
|
-
alias: entry.alias,
|
|
1832
|
-
savedCurrent:
|
|
1833
|
-
state.config({ includeSecrets: false })["swarm.default"] ??
|
|
1834
|
-
null,
|
|
1835
|
-
},
|
|
1836
|
-
`Registered swarm ${entry.alias ?? cid} (${cid}).`,
|
|
1837
|
-
);
|
|
1838
|
-
break;
|
|
1839
|
-
}
|
|
1840
2311
|
if (parsed.path === "search") {
|
|
1841
2312
|
const registrations = state.swarms();
|
|
1842
2313
|
const scope = parsed.options.all
|
|
@@ -1855,10 +2326,17 @@ async function performCli(
|
|
|
1855
2326
|
}
|
|
1856
2327
|
if (parsed.path === "swarm status") {
|
|
1857
2328
|
const cid = requireSwarm();
|
|
1858
|
-
const
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
2329
|
+
const {
|
|
2330
|
+
head,
|
|
2331
|
+
config,
|
|
2332
|
+
networking,
|
|
2333
|
+
cache,
|
|
2334
|
+
state: contentState,
|
|
2335
|
+
} = await inspectSwarmStatus(
|
|
2336
|
+
context,
|
|
2337
|
+
cid,
|
|
2338
|
+
Boolean(parsed.options.refresh || parsed.options.force),
|
|
2339
|
+
);
|
|
1862
2340
|
const fingerprint = await keyId(config.owner);
|
|
1863
2341
|
store = context.store;
|
|
1864
2342
|
emit(
|
|
@@ -1867,12 +2345,11 @@ async function performCli(
|
|
|
1867
2345
|
owner: config.owner,
|
|
1868
2346
|
ownerFingerprint: fingerprint,
|
|
1869
2347
|
epoch: config.epoch,
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
: {}),
|
|
2348
|
+
scopeId: config.scopeId,
|
|
2349
|
+
headId: config.headId,
|
|
2350
|
+
cache,
|
|
2351
|
+
state: contentState,
|
|
2352
|
+
networking,
|
|
1876
2353
|
root: head.root,
|
|
1877
2354
|
valueCid: head.cid,
|
|
1878
2355
|
properties: {
|
|
@@ -1882,6 +2359,7 @@ async function performCli(
|
|
|
1882
2359
|
},
|
|
1883
2360
|
[
|
|
1884
2361
|
"Swarm",
|
|
2362
|
+
` Directory: ${cache.source} (${cache.freshness}), observed ${cache.updatedAt}`,
|
|
1885
2363
|
` Name: ${printable(config.name)}`,
|
|
1886
2364
|
` Description: ${config.description ? printable(config.description) : "(none)"}`,
|
|
1887
2365
|
" Config URL:",
|
|
@@ -1890,23 +2368,69 @@ async function performCli(
|
|
|
1890
2368
|
"Identity",
|
|
1891
2369
|
" Owner fingerprint:",
|
|
1892
2370
|
` ${fingerprint}`,
|
|
1893
|
-
...(local
|
|
1894
|
-
? [
|
|
1895
|
-
" PeerID:",
|
|
1896
|
-
` ${context.node!.peerId}`,
|
|
1897
|
-
"",
|
|
1898
|
-
"Local addresses",
|
|
1899
|
-
...context.node!.addresses.map(
|
|
1900
|
-
(address) => ` ${printable(address)}`,
|
|
1901
|
-
),
|
|
1902
|
-
]
|
|
1903
|
-
: []),
|
|
1904
2371
|
"",
|
|
1905
2372
|
"Content",
|
|
1906
2373
|
" HEAD (publication root):",
|
|
1907
2374
|
` ${head.root}`,
|
|
1908
2375
|
" Content CID (HEAD value):",
|
|
1909
2376
|
` ${head.cid}`,
|
|
2377
|
+
` State: ${contentState.status}. ${contentState.error}`,
|
|
2378
|
+
"",
|
|
2379
|
+
"Local networking",
|
|
2380
|
+
` Daemon observations: ${networking.daemon.status}`,
|
|
2381
|
+
` Updated: ${networking.daemon.updatedAt ?? "unknown"}`,
|
|
2382
|
+
` Control-plane verified: ${networking.daemon.verifiedAt ?? "unknown"}`,
|
|
2383
|
+
...(networking.daemon.error
|
|
2384
|
+
? [` Observation error: ${printable(networking.daemon.error)}`]
|
|
2385
|
+
: []),
|
|
2386
|
+
` Connections observed: ${networking.connections.observedAt ?? "unknown"} (${networking.connections.freshness})`,
|
|
2387
|
+
...(networking.connections.error
|
|
2388
|
+
? [
|
|
2389
|
+
` Connection error: ${printable(networking.connections.error)}`,
|
|
2390
|
+
]
|
|
2391
|
+
: []),
|
|
2392
|
+
table(
|
|
2393
|
+
[
|
|
2394
|
+
"PIVOT PEER ID",
|
|
2395
|
+
"LOCAL",
|
|
2396
|
+
"PROBE",
|
|
2397
|
+
"PROBED AT",
|
|
2398
|
+
"FAILURES",
|
|
2399
|
+
"RETRY AT",
|
|
2400
|
+
"CONNECTION",
|
|
2401
|
+
],
|
|
2402
|
+
networking.pivots.map((pivot) => [
|
|
2403
|
+
pivot.peerId,
|
|
2404
|
+
pivot.localStatus ?? "unknown",
|
|
2405
|
+
`${pivot.probe.result} (${pivot.probe.freshness})`,
|
|
2406
|
+
pivot.probe.at ?? "-",
|
|
2407
|
+
pivot.failures === null ? "-" : String(pivot.failures),
|
|
2408
|
+
pivot.retryAt ?? "-",
|
|
2409
|
+
pivot.connection.status,
|
|
2410
|
+
]),
|
|
2411
|
+
"No declared Pivots.",
|
|
2412
|
+
),
|
|
2413
|
+
...networking.pivots.flatMap((pivot) =>
|
|
2414
|
+
pivot.probe.error
|
|
2415
|
+
? [
|
|
2416
|
+
` ${pivot.peerId} probe error: ${printable(pivot.probe.error)}`,
|
|
2417
|
+
]
|
|
2418
|
+
: [],
|
|
2419
|
+
),
|
|
2420
|
+
...(networking.connections.error
|
|
2421
|
+
? []
|
|
2422
|
+
: [
|
|
2423
|
+
table(
|
|
2424
|
+
["CONNECTED PEER ID", "TRANSPORT", "ADDRESS"],
|
|
2425
|
+
networking.connections.peers.map((peer) => [
|
|
2426
|
+
peer.peerId,
|
|
2427
|
+
peer.transport,
|
|
2428
|
+
peer.address,
|
|
2429
|
+
]),
|
|
2430
|
+
"No observed peer connections.",
|
|
2431
|
+
),
|
|
2432
|
+
]),
|
|
2433
|
+
" Selected is configuration, not connection success. Relay connectivity does not guarantee content availability.",
|
|
1910
2434
|
].join("\n"),
|
|
1911
2435
|
);
|
|
1912
2436
|
break;
|
|
@@ -1987,14 +2511,15 @@ async function performCli(
|
|
|
1987
2511
|
: {}),
|
|
1988
2512
|
});
|
|
1989
2513
|
} else if (parsed.path === "swarm request") {
|
|
1990
|
-
const result = await requestMembership(
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2514
|
+
const result = await requestMembership(
|
|
2515
|
+
context,
|
|
2516
|
+
state.resolveSwarm(first!),
|
|
2517
|
+
{
|
|
2518
|
+
...(typeof parsed.options.output === "string"
|
|
2519
|
+
? { output: parsed.options.output }
|
|
2520
|
+
: {}),
|
|
2521
|
+
},
|
|
2522
|
+
);
|
|
1998
2523
|
store = context.store;
|
|
1999
2524
|
io.err(
|
|
2000
2525
|
`Owner fingerprint: ${result.ownerFingerprint}\nVerify this fingerprint through an independent trusted channel before manually sending the Request file to the Owner.`,
|
|
@@ -2091,7 +2616,7 @@ async function performCli(
|
|
|
2091
2616
|
}
|
|
2092
2617
|
break;
|
|
2093
2618
|
}
|
|
2094
|
-
case "
|
|
2619
|
+
case "templates render":
|
|
2095
2620
|
case "build":
|
|
2096
2621
|
case "bundle build":
|
|
2097
2622
|
case "bundle inspect":
|
|
@@ -2128,7 +2653,10 @@ async function performCli(
|
|
|
2128
2653
|
options.signal?.throwIfAborted();
|
|
2129
2654
|
const builtin = builtins.blocks.get(cid.toV1().toString());
|
|
2130
2655
|
if (builtin) return builtin.slice();
|
|
2131
|
-
return (await getStore()).block.get(
|
|
2656
|
+
return (store ?? (await getStore())).block.get(
|
|
2657
|
+
cid.toString(),
|
|
2658
|
+
options,
|
|
2659
|
+
);
|
|
2132
2660
|
},
|
|
2133
2661
|
};
|
|
2134
2662
|
const builtinSource = first ? state.pin(first) : undefined;
|
|
@@ -2136,6 +2664,64 @@ async function performCli(
|
|
|
2136
2664
|
builtinSource?.builtin && builtinSource.metadata?.kind === "bundle"
|
|
2137
2665
|
? builtinSource.cid
|
|
2138
2666
|
: first;
|
|
2667
|
+
let selectedTemplate: string | undefined;
|
|
2668
|
+
if (parsed.path === "templates render") {
|
|
2669
|
+
const selector = first!;
|
|
2670
|
+
selectedTemplate = selector;
|
|
2671
|
+
if (parseNameReference(selector)) {
|
|
2672
|
+
await getStore();
|
|
2673
|
+
const context = swarmContext();
|
|
2674
|
+
readContext = context;
|
|
2675
|
+
selectedTemplate = (
|
|
2676
|
+
await resolveReference(
|
|
2677
|
+
context,
|
|
2678
|
+
selector,
|
|
2679
|
+
selectedSwarm,
|
|
2680
|
+
(reference) => state!.resolve(reference),
|
|
2681
|
+
false,
|
|
2682
|
+
"local-first",
|
|
2683
|
+
)
|
|
2684
|
+
).cid;
|
|
2685
|
+
store = context.store;
|
|
2686
|
+
} else {
|
|
2687
|
+
let explicit = false;
|
|
2688
|
+
try {
|
|
2689
|
+
CID.parse(selector);
|
|
2690
|
+
explicit = true;
|
|
2691
|
+
} catch {
|
|
2692
|
+
/* Not a CID. */
|
|
2693
|
+
}
|
|
2694
|
+
explicit ||= selector.toLowerCase().endsWith(".car");
|
|
2695
|
+
if (!explicit) {
|
|
2696
|
+
try {
|
|
2697
|
+
await lstat(selector);
|
|
2698
|
+
explicit = true;
|
|
2699
|
+
} catch (cause) {
|
|
2700
|
+
if (
|
|
2701
|
+
!nodeError(cause, "ENOENT") &&
|
|
2702
|
+
!nodeError(cause, "ENOTDIR")
|
|
2703
|
+
)
|
|
2704
|
+
throw cause;
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
if (!explicit) {
|
|
2708
|
+
templateName(selector);
|
|
2709
|
+
if (!selectedSwarm)
|
|
2710
|
+
throw new HostError(
|
|
2711
|
+
"Template selectors require a selected Swarm. Use --swarm or swarm use, or supply an explicit Bundle directory, CAR, exact CID or IPAB URI.",
|
|
2712
|
+
);
|
|
2713
|
+
await getStore();
|
|
2714
|
+
const context = swarmContext();
|
|
2715
|
+
readContext = context;
|
|
2716
|
+
selectedTemplate = await resolveTemplateSelector(
|
|
2717
|
+
context,
|
|
2718
|
+
selector,
|
|
2719
|
+
selectedSwarm,
|
|
2720
|
+
);
|
|
2721
|
+
store = context.store;
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2139
2725
|
if (parsed.path === "bundle build" || parsed.path === "build")
|
|
2140
2726
|
io.err(
|
|
2141
2727
|
parsed.path === "build"
|
|
@@ -2145,21 +2731,16 @@ async function performCli(
|
|
|
2145
2731
|
if (parsed.path === "bundle import")
|
|
2146
2732
|
io.err("Validating and importing CAR into Store...");
|
|
2147
2733
|
const result =
|
|
2148
|
-
parsed.path === "
|
|
2149
|
-
? await initApp(
|
|
2734
|
+
parsed.path === "templates render"
|
|
2735
|
+
? await initApp(second!, parsed.positional[2], {
|
|
2150
2736
|
...request,
|
|
2151
|
-
...(
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
}
|
|
2159
|
-
: {}),
|
|
2160
|
-
...(parsed.parameters
|
|
2161
|
-
? { parameters: parsed.parameters }
|
|
2162
|
-
: {}),
|
|
2737
|
+
...(selectedTemplate ? { template: selectedTemplate } : {}),
|
|
2738
|
+
parameters: [
|
|
2739
|
+
...(parsed.parameters ?? []),
|
|
2740
|
+
...(typeof parsed.options.description === "string"
|
|
2741
|
+
? [`description=${parsed.options.description}`]
|
|
2742
|
+
: []),
|
|
2743
|
+
],
|
|
2163
2744
|
})
|
|
2164
2745
|
: parsed.path === "build"
|
|
2165
2746
|
? await assembleBundle(first, {
|
|
@@ -2574,9 +3155,11 @@ async function performCli(
|
|
|
2574
3155
|
`No App registered for Schema ${schema} in Swarm ${registrySwarm}. Use ipab register set ${schema} APP_CID --swarm ${registrySwarm} or ipab exec.`,
|
|
2575
3156
|
);
|
|
2576
3157
|
appCid = association.appCid;
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
3158
|
+
if (association.argv.length !== 1 || association.argv[0] !== "%")
|
|
3159
|
+
throw new HostError(
|
|
3160
|
+
"Custom per-association argv is unsupported; adapt the App to accept only the content CID or use ipab exec APP_CID ARGS.",
|
|
3161
|
+
);
|
|
3162
|
+
appArgv = [root];
|
|
2580
3163
|
// execute owns the App/input context before this validation owner's eventual release.
|
|
2581
3164
|
const result = await execute(
|
|
2582
3165
|
state,
|