@ipab/cli 0.1.0-rc.6 → 0.1.0-rc.7
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 +72 -33
- package/dist/app-authoring.d.ts +5 -0
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +4 -1
- package/dist/app-authoring.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 +395 -86
- package/dist/cli.js.map +1 -1
- package/dist/context.d.ts +16 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +20 -0
- package/dist/context.js.map +1 -1
- package/dist/ipc.d.ts +2 -1
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +44 -3
- package/dist/ipc.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.d.ts +15 -2
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +153 -3
- package/dist/space.js.map +1 -1
- package/dist/state.js +1 -1
- package/dist/swarm-files.d.ts +1 -1
- package/dist/swarm-files.d.ts.map +1 -1
- package/dist/swarm-files.js +2 -2
- package/dist/swarm-files.js.map +1 -1
- package/dist/swarm-meta.d.ts +17 -0
- package/dist/swarm-meta.d.ts.map +1 -0
- package/dist/swarm-meta.js +96 -0
- package/dist/swarm-meta.js.map +1 -0
- package/dist/swarm.d.ts +53 -0
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +465 -73
- 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 +18 -2
- package/src/app-templates.ts +8 -72
- package/src/builtins.ts +2 -48
- package/src/cli.ts +474 -71
- package/src/context.ts +45 -0
- package/src/ipc.ts +63 -2
- 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.ts +214 -5
- package/src/state.ts +1 -1
- package/src/swarm-files.ts +2 -1
- package/src/swarm-meta.ts +109 -0
- package/src/swarm.ts +721 -128
- 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";
|
|
@@ -33,7 +33,12 @@ import {
|
|
|
33
33
|
type Association,
|
|
34
34
|
type RunRecord,
|
|
35
35
|
} from "./state.js";
|
|
36
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
buildBundle,
|
|
38
|
+
inspectBundle,
|
|
39
|
+
importBundle,
|
|
40
|
+
nodeError,
|
|
41
|
+
} from "./authoring.js";
|
|
37
42
|
import { initApp } from "./app-authoring.js";
|
|
38
43
|
import { assembleBundle } from "./assembly.js";
|
|
39
44
|
import { getBundle } from "./get.js";
|
|
@@ -69,14 +74,25 @@ import {
|
|
|
69
74
|
swarmAssociation,
|
|
70
75
|
setSwarmAssociation,
|
|
71
76
|
removeSwarmAssociation,
|
|
77
|
+
resolveTemplateSelector,
|
|
78
|
+
templateName,
|
|
79
|
+
swarmTemplates,
|
|
80
|
+
setSwarmTemplate,
|
|
81
|
+
removeSwarmTemplate,
|
|
72
82
|
type SwarmContext,
|
|
73
83
|
} from "./swarm.js";
|
|
74
84
|
import { schemaAlias } from "./app-definition.js";
|
|
75
85
|
import { unpin, pinDetails } from "./pins.js";
|
|
76
86
|
import { publicationSource } from "./publish-source.js";
|
|
87
|
+
import {
|
|
88
|
+
templateRenderExample,
|
|
89
|
+
templateOutputTree,
|
|
90
|
+
templateParameterRows,
|
|
91
|
+
} from "./template-presentation.js";
|
|
77
92
|
import { logFiles } from "./logs.js";
|
|
78
93
|
import { builtinContent } from "./builtins.js";
|
|
79
94
|
import { readSecretStream } from "./config-secret.js";
|
|
95
|
+
import { manageSkills } from "./skills.js";
|
|
80
96
|
|
|
81
97
|
export interface IO {
|
|
82
98
|
out(text: string): void;
|
|
@@ -139,6 +155,9 @@ export const processIO: IO = {
|
|
|
139
155
|
},
|
|
140
156
|
};
|
|
141
157
|
const commands: Record<string, string> = {
|
|
158
|
+
"skills list": "skills list [--force | --no-force]",
|
|
159
|
+
"skills sync":
|
|
160
|
+
"skills sync [NAMES...] [--agent AGENT]... [--dry-run] [--yes] [--force | --no-force]",
|
|
142
161
|
doctor: "doctor [--fix [--yes]]",
|
|
143
162
|
profile: "profile [--name NAME] [--description TEXT]",
|
|
144
163
|
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
@@ -155,10 +174,10 @@ const commands: Record<string, string> = {
|
|
|
155
174
|
"swarm use": "swarm use URL_OR_ALIAS",
|
|
156
175
|
"swarm remove": "swarm remove URL_OR_ALIAS",
|
|
157
176
|
"swarm update": "swarm update [--name TEXT] [--description TEXT]",
|
|
158
|
-
publish: "publish NAME SOURCE [--expect
|
|
177
|
+
publish: "publish NAME SOURCE [--expect OLD_CID | --snapshot]",
|
|
159
178
|
get: "get REF [--raw] [--force | --no-force] [-o DIRECTORY]",
|
|
160
179
|
search: "search QUERY [--all | --current] [--force | --no-force]",
|
|
161
|
-
|
|
180
|
+
"templates render": "templates render TEMPLATE NAME [DIR] [OPTIONS]",
|
|
162
181
|
build: "build [SOURCE] [OPTIONS]",
|
|
163
182
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
164
183
|
"bundle inspect": "bundle inspect SOURCE",
|
|
@@ -169,10 +188,14 @@ const commands: Record<string, string> = {
|
|
|
169
188
|
unpin: "unpin REF",
|
|
170
189
|
"pin list": "pin list",
|
|
171
190
|
"pin show": "pin show REF",
|
|
172
|
-
"register list": "register list [--swarm URL_OR_ALIAS]
|
|
191
|
+
"register list": "register list [--swarm URL_OR_ALIAS]",
|
|
173
192
|
"register set":
|
|
174
|
-
"register set SCHEMA APP [--swarm URL_OR_ALIAS]... [--replace]
|
|
193
|
+
"register set SCHEMA APP [--swarm URL_OR_ALIAS]... [--replace]",
|
|
175
194
|
"register remove": "register remove SCHEMA [--swarm URL_OR_ALIAS]...",
|
|
195
|
+
"templates list": "templates list [--force | --no-force]",
|
|
196
|
+
"templates show": "templates show NAME [--force | --no-force]",
|
|
197
|
+
"templates set": "templates set NAME SOURCE [--expect OLD_TARGET_CID]",
|
|
198
|
+
"templates remove": "templates remove NAME --expect OLD_TARGET_CID",
|
|
176
199
|
"config get": "config get [KEY]",
|
|
177
200
|
"config set":
|
|
178
201
|
"config set KEY VALUE\n ipab config set pointers.apiKey - < protected-key-file",
|
|
@@ -185,10 +208,12 @@ const commands: Record<string, string> = {
|
|
|
185
208
|
"history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
|
|
186
209
|
};
|
|
187
210
|
const groups: Record<string, string> = {
|
|
211
|
+
skills: "Discover and explicitly synchronize selected Swarm Skills globally",
|
|
188
212
|
swarm: "Create, authorize, select and manage personal swarms",
|
|
189
213
|
bundle: "Create, inspect and import content bundles",
|
|
190
214
|
pin: "Retain an exact CID or follow a shared Swarm Name",
|
|
191
215
|
register: "Associate content types with Apps",
|
|
216
|
+
templates: "Inspect, render and manage Template Bundles",
|
|
192
217
|
config: "Manage local configuration",
|
|
193
218
|
store: "Query local storage and collect unreferenced blocks",
|
|
194
219
|
history: "View and remove execution history",
|
|
@@ -203,6 +228,96 @@ const commandHelp: Record<
|
|
|
203
228
|
notes?: string[];
|
|
204
229
|
}
|
|
205
230
|
> = {
|
|
231
|
+
"templates list": {
|
|
232
|
+
summary: "List templates under the selected Swarm Meta templatePath",
|
|
233
|
+
options: [
|
|
234
|
+
"--force / --no-force Refresh HEAD now / allow a valid cached snapshot.",
|
|
235
|
+
],
|
|
236
|
+
examples: [
|
|
237
|
+
"ipab --swarm work templates list",
|
|
238
|
+
"ipab --json templates list",
|
|
239
|
+
],
|
|
240
|
+
notes: [
|
|
241
|
+
"Uses only global --swarm (once, before the command), otherwise the saved default. No builtin or other Swarm fallback.",
|
|
242
|
+
],
|
|
243
|
+
},
|
|
244
|
+
"templates show": {
|
|
245
|
+
summary: "Show one template, its exact targets and declared parameters",
|
|
246
|
+
arguments: [
|
|
247
|
+
"NAME Safe relative template Name; nested names are supported.",
|
|
248
|
+
],
|
|
249
|
+
options: [
|
|
250
|
+
"--force / --no-force Refresh HEAD now / allow a valid cached snapshot.",
|
|
251
|
+
],
|
|
252
|
+
examples: ["ipab --swarm work templates show node"],
|
|
253
|
+
},
|
|
254
|
+
"templates set": {
|
|
255
|
+
summary:
|
|
256
|
+
"Publish one validated Template Bundle with exact Name conflict checks",
|
|
257
|
+
arguments: [
|
|
258
|
+
"NAME Safe relative template Name.",
|
|
259
|
+
"SOURCE Exact Template CID, self-contained CAR or explicit manifest directory; no URI, build or hooks.",
|
|
260
|
+
],
|
|
261
|
+
options: [
|
|
262
|
+
"--expect OLD_TARGET_CID Required to replace an occupied Name; use its exact target CID, including an Artifact wrapper.",
|
|
263
|
+
],
|
|
264
|
+
examples: [
|
|
265
|
+
"ipab --swarm work templates set team/node ./template.car",
|
|
266
|
+
"ipab templates set node TEMPLATE_CID --expect OLD_TARGET_CID",
|
|
267
|
+
],
|
|
268
|
+
notes: [
|
|
269
|
+
"Publishes an ordinary Artifact and preserves publication history and content retention.",
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
"templates remove": {
|
|
273
|
+
summary: "Remove only one template Name, without deleting content",
|
|
274
|
+
arguments: ["NAME Safe relative template Name."],
|
|
275
|
+
options: [
|
|
276
|
+
"--expect OLD_TARGET_CID Required exact current Name target CID.",
|
|
277
|
+
],
|
|
278
|
+
examples: [
|
|
279
|
+
"ipab --swarm work templates remove team/node --expect OLD_TARGET_CID",
|
|
280
|
+
],
|
|
281
|
+
notes: [
|
|
282
|
+
"Missing Names are errors. Does not unpin, GC or delete content or history.",
|
|
283
|
+
],
|
|
284
|
+
},
|
|
285
|
+
"skills list": {
|
|
286
|
+
summary: "List typed Skills and local installation status from one Swarm",
|
|
287
|
+
options: [
|
|
288
|
+
"--force / --no-force Refresh HEAD now / reuse a valid verified snapshot.",
|
|
289
|
+
"Global --json Emit machine-readable names, exact payload CIDs and status.",
|
|
290
|
+
],
|
|
291
|
+
examples: ["ipab --swarm work skills list", "ipab --json skills list"],
|
|
292
|
+
notes: [
|
|
293
|
+
"Select one Swarm with global --swarm or swarm use; there is no --all.",
|
|
294
|
+
"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.",
|
|
295
|
+
],
|
|
296
|
+
},
|
|
297
|
+
"skills sync": {
|
|
298
|
+
summary:
|
|
299
|
+
"Install reviewed Swarm Skills using the pinned official npx installer",
|
|
300
|
+
arguments: [
|
|
301
|
+
"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.",
|
|
302
|
+
],
|
|
303
|
+
options: [
|
|
304
|
+
"--agent AGENT Repeatable globally supported agent ID; default is detected agents.",
|
|
305
|
+
"--dry-run Preview without invoking npx or changing installed Skills.",
|
|
306
|
+
"--yes Skip IPAB consent only; conflicts and local edits remain protected.",
|
|
307
|
+
"--force / --no-force Refresh HEAD now / reuse a valid verified snapshot.",
|
|
308
|
+
],
|
|
309
|
+
examples: [
|
|
310
|
+
"ipab --swarm work skills sync --dry-run",
|
|
311
|
+
"ipab skills sync ipab code-review --agent github-copilot --yes",
|
|
312
|
+
],
|
|
313
|
+
notes: [
|
|
314
|
+
"Global installs only, through official skills@1.9.1 with --copy. Requires Node >=22.20.0.",
|
|
315
|
+
"Non-interactive execution requires --yes. Installer version, source, paths and agents are shown first.",
|
|
316
|
+
"No Skill hooks/scripts run. The trusted installer is not sandboxed. Telemetry and remote audits are disabled.",
|
|
317
|
+
"Non-IPAB installs, local edits, cross-Swarm collisions and symlink/junction aliases are never overwritten. Removed sources are reported, not deleted.",
|
|
318
|
+
"Partial failures report individual results, preserve pending attribution and exit nonzero; retry the same sync.",
|
|
319
|
+
],
|
|
320
|
+
},
|
|
206
321
|
profile: {
|
|
207
322
|
summary: "Read or update your account-wide public name and description",
|
|
208
323
|
examples: [
|
|
@@ -413,18 +528,18 @@ const commandHelp: Record<
|
|
|
413
528
|
publish: {
|
|
414
529
|
summary: "Protect content locally and publish a shared Swarm Name",
|
|
415
530
|
options: [
|
|
416
|
-
"--expect CID Exact old
|
|
531
|
+
"--expect CID Exact old Name target CID, required for iteration.",
|
|
417
532
|
"--snapshot Name ordinary content without an Artifact; initial only.",
|
|
418
533
|
],
|
|
419
534
|
examples: [
|
|
420
535
|
"ipab --swarm work publish apps/hello app.car",
|
|
421
|
-
"ipab publish apps/hello APP_CID --expect
|
|
536
|
+
"ipab publish apps/hello APP_CID --expect OLD_APP_CID",
|
|
422
537
|
"ipab publish notes/readme ./README.md",
|
|
423
538
|
],
|
|
424
539
|
notes: [
|
|
425
540
|
"SOURCE is an exact Bundle CID, CAR, regular file or directory. No compiler, hooks, install or App execution.",
|
|
426
541
|
"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
|
|
542
|
+
"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
543
|
"Different-name CAS contention is rebased; same-name edits conflict (exit 3).",
|
|
429
544
|
"Kubo pin confirmation precedes HEAD; it does not prove a remote device is online.",
|
|
430
545
|
],
|
|
@@ -467,20 +582,28 @@ const commandHelp: Record<
|
|
|
467
582
|
"Does not unpin, clear history, delete unknown files or request Kubo daemon GC.",
|
|
468
583
|
],
|
|
469
584
|
},
|
|
470
|
-
|
|
471
|
-
summary: "
|
|
472
|
-
arguments: [
|
|
585
|
+
"templates render": {
|
|
586
|
+
summary: "Render a template's project files into a new or empty folder",
|
|
587
|
+
arguments: [
|
|
588
|
+
"TEMPLATE Explicit Swarm selector, directory, CAR, exact CID or IPAB URI.",
|
|
589
|
+
"NAME Project name parameter; DIR defaults to NAME (new/empty only).",
|
|
590
|
+
],
|
|
473
591
|
options: [
|
|
474
|
-
"--
|
|
592
|
+
"--description TEXT Set the declared description parameter.",
|
|
593
|
+
"--force / --no-force Refresh Swarm HEAD now / allow its valid cached snapshot.",
|
|
475
594
|
"--param KEY=VALUE Template parameter; repeatable. Strings are literal;",
|
|
476
595
|
" other parameter types use JSON.",
|
|
477
596
|
],
|
|
478
597
|
examples: [
|
|
479
|
-
"ipab
|
|
480
|
-
"ipab
|
|
481
|
-
"ipab
|
|
598
|
+
"ipab templates render node hello",
|
|
599
|
+
"ipab templates render web-app dashboard --param webAppDependency=0.1.0-rc.2",
|
|
600
|
+
"ipab templates render ./template.car hello --description Demo",
|
|
601
|
+
],
|
|
602
|
+
notes: [
|
|
603
|
+
"Short selectors resolve through the selected Swarm's typed root configuration (legacy v2/v3/v4 use Meta Name ipab); no builtin fallback.",
|
|
604
|
+
"Explicit directory, CAR and available exact CID work offline without a Swarm.",
|
|
605
|
+
"Does not install dependencies or execute template code.",
|
|
482
606
|
],
|
|
483
|
-
notes: ["Does not install dependencies or execute template code."],
|
|
484
607
|
},
|
|
485
608
|
build: {
|
|
486
609
|
summary: "Assemble any Bundle using ipab.build.yaml (no compilation)",
|
|
@@ -628,15 +751,15 @@ const commandHelp: Record<
|
|
|
628
751
|
},
|
|
629
752
|
"pin show": {
|
|
630
753
|
summary: "Show saved retention and following status",
|
|
631
|
-
examples: ["ipab pin show APP_CID"
|
|
754
|
+
examples: ["ipab pin show APP_CID"],
|
|
632
755
|
notes: [
|
|
633
756
|
"Reads local metadata; built-in pins do not claim user Store retention.",
|
|
634
757
|
],
|
|
635
758
|
},
|
|
636
759
|
"register list": {
|
|
637
|
-
summary: "List
|
|
760
|
+
summary: "List content-type associations in the current or selected Swarm",
|
|
638
761
|
options: [
|
|
639
|
-
"--swarm URL_OR_ALIAS Read this Swarm registry;
|
|
762
|
+
"--swarm URL_OR_ALIAS Read only this Swarm registry; specify at most once.",
|
|
640
763
|
],
|
|
641
764
|
examples: ["ipab register list", "ipab register list --swarm work"],
|
|
642
765
|
notes: [
|
|
@@ -649,19 +772,18 @@ const commandHelp: Record<
|
|
|
649
772
|
arguments: [
|
|
650
773
|
"SCHEMA Exact type CID or builtin:node-app.v1.",
|
|
651
774
|
"APP App CID or Swarm IPAB URI; the exact CID is saved.",
|
|
652
|
-
"TEMPLATE App argv after --; must contain a whole argument % (default: %).",
|
|
653
775
|
],
|
|
654
776
|
options: [
|
|
655
777
|
"--replace Allow changing an existing association.",
|
|
656
778
|
"--swarm URL_OR_ALIAS Write this Swarm registry; repeat for multiple Swarms.",
|
|
657
779
|
],
|
|
658
780
|
examples: [
|
|
659
|
-
"ipab register set SCHEMA_CID
|
|
660
|
-
"ipab register set SCHEMA_CID reader '--' '--cid' '%'",
|
|
781
|
+
"ipab register set SCHEMA_CID APP_CID",
|
|
661
782
|
"ipab register set SCHEMA_CID ipab:///apps/reader --swarm work --swarm team",
|
|
662
783
|
],
|
|
663
784
|
notes: [
|
|
664
|
-
"
|
|
785
|
+
"Writes the Name META.registryPath/TYPE_CID directly to the App CID. Open passes only the content CID.",
|
|
786
|
+
"Custom per-association argv is unsupported; adapt the App or use ipab exec APP_CID ARGS.",
|
|
665
787
|
"Does not verify App type support; open checks it before execution.",
|
|
666
788
|
"Without explicit --swarm, writes the saved default Swarm. Swarm writes require HEAD write access.",
|
|
667
789
|
"Multiple Swarms commit sequentially, not atomically; failures report completed targets.",
|
|
@@ -767,7 +889,7 @@ Run Apps:
|
|
|
767
889
|
open ${commandHelp.open!.summary}
|
|
768
890
|
|
|
769
891
|
Create:
|
|
770
|
-
|
|
892
|
+
templates ${groups.templates}
|
|
771
893
|
build ${commandHelp.build!.summary}
|
|
772
894
|
bundle ${groups.bundle}
|
|
773
895
|
|
|
@@ -775,6 +897,7 @@ Manage:
|
|
|
775
897
|
doctor ${commandHelp.doctor!.summary}
|
|
776
898
|
profile ${commandHelp.profile!.summary}
|
|
777
899
|
swarm ${groups.swarm}
|
|
900
|
+
skills ${groups.skills}
|
|
778
901
|
search Search formal Names in the current swarm
|
|
779
902
|
publish ${commandHelp.publish!.summary}
|
|
780
903
|
get ${commandHelp.get!.summary}
|
|
@@ -964,6 +1087,7 @@ interface Parsed {
|
|
|
964
1087
|
template?: string[];
|
|
965
1088
|
parameters?: string[];
|
|
966
1089
|
registrySwarms?: string[];
|
|
1090
|
+
agents?: string[];
|
|
967
1091
|
help: boolean;
|
|
968
1092
|
version: boolean;
|
|
969
1093
|
}
|
|
@@ -1032,6 +1156,12 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1032
1156
|
} else syntax(`Unknown global option "${flag}".`);
|
|
1033
1157
|
}
|
|
1034
1158
|
const group = tokens.shift() ?? "";
|
|
1159
|
+
if (group === "init")
|
|
1160
|
+
syntax(
|
|
1161
|
+
"Root init was removed. Use ipab templates render TEMPLATE NAME [DIR]; TEMPLATE is the first positional argument, not --template.",
|
|
1162
|
+
);
|
|
1163
|
+
if (group === "templates" && swarms.length > 1)
|
|
1164
|
+
syntax("Templates accepts only one global --swarm, before the command.");
|
|
1035
1165
|
const result: Parsed = {
|
|
1036
1166
|
flags,
|
|
1037
1167
|
path: group,
|
|
@@ -1064,7 +1194,6 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1064
1194
|
if (
|
|
1065
1195
|
![
|
|
1066
1196
|
"open",
|
|
1067
|
-
"init",
|
|
1068
1197
|
"build",
|
|
1069
1198
|
"publish",
|
|
1070
1199
|
"get",
|
|
@@ -1079,10 +1208,12 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1079
1208
|
"bundle",
|
|
1080
1209
|
"pin",
|
|
1081
1210
|
"register",
|
|
1211
|
+
"templates",
|
|
1082
1212
|
"config",
|
|
1083
1213
|
"history",
|
|
1084
1214
|
"store",
|
|
1085
1215
|
"swarm",
|
|
1216
|
+
"skills",
|
|
1086
1217
|
].includes(group)
|
|
1087
1218
|
)
|
|
1088
1219
|
syntax(
|
|
@@ -1100,6 +1231,10 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1100
1231
|
} else if (group === "open" && flags.json)
|
|
1101
1232
|
syntax("--json is not supported for exec/open.");
|
|
1102
1233
|
if (!commands[result.path]) syntax(`Unknown command "${result.path}".`);
|
|
1234
|
+
if (group === "skills" && swarms.length > 1)
|
|
1235
|
+
syntax(
|
|
1236
|
+
"Skills operations select exactly one Swarm; repeated --swarm is not supported.",
|
|
1237
|
+
);
|
|
1103
1238
|
const separator = result.path === "register set" ? tokens.indexOf("--") : -1;
|
|
1104
1239
|
if (separator >= 0) result.template = tokens.splice(separator + 1);
|
|
1105
1240
|
if (separator >= 0) tokens.splice(separator);
|
|
@@ -1115,8 +1250,11 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1115
1250
|
syntax(
|
|
1116
1251
|
"API key must be provided through '-' and piped stdin; never pass it in command arguments.",
|
|
1117
1252
|
);
|
|
1118
|
-
const booleans =
|
|
1119
|
-
result.path === "
|
|
1253
|
+
const booleans = result.path.startsWith("skills ")
|
|
1254
|
+
? result.path === "skills sync"
|
|
1255
|
+
? ["dry-run", "yes", "force", "no-force"]
|
|
1256
|
+
: ["force", "no-force"]
|
|
1257
|
+
: result.path === "doctor"
|
|
1120
1258
|
? ["fix", "yes"]
|
|
1121
1259
|
: result.path === "bundle build"
|
|
1122
1260
|
? ["replace", "schema-only", "no-import"]
|
|
@@ -1124,8 +1262,17 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1124
1262
|
? ["replace", "no-import"]
|
|
1125
1263
|
: result.path === "publish"
|
|
1126
1264
|
? ["snapshot"]
|
|
1127
|
-
:
|
|
1128
|
-
|
|
1265
|
+
: [
|
|
1266
|
+
"get",
|
|
1267
|
+
"templates render",
|
|
1268
|
+
"templates list",
|
|
1269
|
+
"templates show",
|
|
1270
|
+
].includes(result.path)
|
|
1271
|
+
? result.path === "templates render"
|
|
1272
|
+
? ["force", "no-force"]
|
|
1273
|
+
: result.path === "get"
|
|
1274
|
+
? ["raw", "force", "no-force"]
|
|
1275
|
+
: ["force", "no-force"]
|
|
1129
1276
|
: result.path === "search"
|
|
1130
1277
|
? ["all", "current", "force", "no-force"]
|
|
1131
1278
|
: result.path === "swarm approve"
|
|
@@ -1156,12 +1303,14 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1156
1303
|
? ["name", "description"]
|
|
1157
1304
|
: result.path === "swarm approve"
|
|
1158
1305
|
? []
|
|
1159
|
-
:
|
|
1306
|
+
: ["publish", "templates set", "templates remove"].includes(
|
|
1307
|
+
result.path,
|
|
1308
|
+
)
|
|
1160
1309
|
? ["expect"]
|
|
1161
1310
|
: result.path === "get"
|
|
1162
1311
|
? ["output"]
|
|
1163
|
-
: result.path === "
|
|
1164
|
-
? ["
|
|
1312
|
+
: result.path === "templates render"
|
|
1313
|
+
? ["description"]
|
|
1165
1314
|
: result.path === "bundle build" ||
|
|
1166
1315
|
result.path === "build"
|
|
1167
1316
|
? ["output"]
|
|
@@ -1186,6 +1335,12 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1186
1335
|
result.positional.push(value);
|
|
1187
1336
|
} else if (value.startsWith("--") || value === "-o") {
|
|
1188
1337
|
const option = value === "-o" ? "output" : value.slice(2);
|
|
1338
|
+
if (result.path === "skills sync" && option === "agent") {
|
|
1339
|
+
const input = tokens.shift();
|
|
1340
|
+
if (!input || input.startsWith("-")) syntax("--agent needs a value.");
|
|
1341
|
+
(result.agents ??= []).push(input);
|
|
1342
|
+
continue;
|
|
1343
|
+
}
|
|
1189
1344
|
if (result.path.startsWith("register ") && option === "swarm") {
|
|
1190
1345
|
const input = tokens.shift();
|
|
1191
1346
|
if (!input || input.startsWith("-")) syntax("--swarm needs a value.");
|
|
@@ -1193,7 +1348,11 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1193
1348
|
flags.swarm = input;
|
|
1194
1349
|
continue;
|
|
1195
1350
|
}
|
|
1196
|
-
if (result.path === "
|
|
1351
|
+
if (result.path === "templates render" && option === "template")
|
|
1352
|
+
syntax(
|
|
1353
|
+
"--template was removed. Use ipab templates render TEMPLATE NAME [DIR], with TEMPLATE first.",
|
|
1354
|
+
);
|
|
1355
|
+
if (result.path === "templates render" && option === "param") {
|
|
1197
1356
|
const input = tokens.shift();
|
|
1198
1357
|
if (!input || input.startsWith("--") || input.indexOf("=") < 1)
|
|
1199
1358
|
syntax("--param requires KEY=VALUE.");
|
|
@@ -1209,7 +1368,10 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1209
1368
|
input === undefined ||
|
|
1210
1369
|
(input.startsWith("--") &&
|
|
1211
1370
|
!(option === "resume" && /^[A-Za-z0-9_-]{43}$/.test(input))) ||
|
|
1212
|
-
(input === "" &&
|
|
1371
|
+
(input === "" &&
|
|
1372
|
+
!["swarm update", "profile", "templates render"].includes(
|
|
1373
|
+
result.path,
|
|
1374
|
+
))
|
|
1213
1375
|
)
|
|
1214
1376
|
syntax(`${value} needs a value.`);
|
|
1215
1377
|
result.options[option] = input;
|
|
@@ -1237,8 +1399,17 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1237
1399
|
(result.options.current || flags.swarm !== undefined)
|
|
1238
1400
|
)
|
|
1239
1401
|
syntax("--all is mutually exclusive with --current and --swarm.");
|
|
1402
|
+
if (
|
|
1403
|
+
result.path === "register list" &&
|
|
1404
|
+
(result.registrySwarms?.length ?? 0) > 1
|
|
1405
|
+
)
|
|
1406
|
+
syntax(
|
|
1407
|
+
"register list accepts --swarm at most once. Select one Swarm or omit it to use the current Swarm.",
|
|
1408
|
+
);
|
|
1240
1409
|
const counts: Record<string, [number, number]> = {
|
|
1241
1410
|
doctor: [0, 0],
|
|
1411
|
+
"skills list": [0, 0],
|
|
1412
|
+
"skills sync": [0, Number.MAX_SAFE_INTEGER],
|
|
1242
1413
|
profile: [0, 0],
|
|
1243
1414
|
"swarm create": [0, 0],
|
|
1244
1415
|
"swarm request": [1, 1],
|
|
@@ -1257,7 +1428,7 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1257
1428
|
publish: [2, 2],
|
|
1258
1429
|
get: [1, 1],
|
|
1259
1430
|
search: [1, 1],
|
|
1260
|
-
|
|
1431
|
+
"templates render": [2, 3],
|
|
1261
1432
|
build: [0, 1],
|
|
1262
1433
|
"bundle build": [1, 1],
|
|
1263
1434
|
"bundle inspect": [1, 1],
|
|
@@ -1270,6 +1441,10 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1270
1441
|
"register list": [0, 0],
|
|
1271
1442
|
"register set": [2, 2],
|
|
1272
1443
|
"register remove": [1, 1],
|
|
1444
|
+
"templates list": [0, 0],
|
|
1445
|
+
"templates show": [1, 1],
|
|
1446
|
+
"templates set": [2, 2],
|
|
1447
|
+
"templates remove": [1, 1],
|
|
1273
1448
|
"config get": [0, 1],
|
|
1274
1449
|
"config set": [2, 2],
|
|
1275
1450
|
"config reset": [1, 1],
|
|
@@ -1300,11 +1475,10 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1300
1475
|
);
|
|
1301
1476
|
if (result.positional.length < minimum || result.positional.length > maximum)
|
|
1302
1477
|
syntax(`Invalid arguments.\n${help(result.path)}`);
|
|
1303
|
-
if (
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
syntax('Argument template must contain a whole "%" token.');
|
|
1478
|
+
if (result.template)
|
|
1479
|
+
syntax(
|
|
1480
|
+
'Custom per-association argv is unsupported. Remove "-- TEMPLATE..."; open passes only the content CID. Adapt the App or use ipab exec APP_CID ARGS.',
|
|
1481
|
+
);
|
|
1308
1482
|
if (result.path === "history remove") {
|
|
1309
1483
|
const selected = values.some((value) =>
|
|
1310
1484
|
Object.hasOwn(result.options, value),
|
|
@@ -1337,6 +1511,16 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1337
1511
|
"--snapshot is initial-only and cannot be combined with --expect.",
|
|
1338
1512
|
);
|
|
1339
1513
|
}
|
|
1514
|
+
if (
|
|
1515
|
+
result.path.startsWith("templates ") &&
|
|
1516
|
+
result.path !== "templates render"
|
|
1517
|
+
) {
|
|
1518
|
+
if (result.positional[0] !== undefined) templateName(result.positional[0]);
|
|
1519
|
+
if (typeof result.options.expect === "string")
|
|
1520
|
+
exactCid(result.options.expect);
|
|
1521
|
+
if (result.path === "templates remove" && !result.options.expect)
|
|
1522
|
+
syntax("templates remove requires --expect OLD_TARGET_CID.");
|
|
1523
|
+
}
|
|
1340
1524
|
if (result.path.startsWith("config ") && result.positional[0]) {
|
|
1341
1525
|
if (
|
|
1342
1526
|
!(result.path === "config get" && result.positional[0] === "state-dir") &&
|
|
@@ -1512,13 +1696,130 @@ async function performCli(
|
|
|
1512
1696
|
if (parsed.path === "open" || parsed.path.startsWith("register ")) {
|
|
1513
1697
|
if (state.legacyRegistrationCount)
|
|
1514
1698
|
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
|
|
1699
|
+
`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
1700
|
);
|
|
1517
1701
|
}
|
|
1518
1702
|
if (state.legacyPinCount)
|
|
1519
1703
|
io.err(
|
|
1520
1704
|
`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
1705
|
);
|
|
1706
|
+
if (
|
|
1707
|
+
parsed.path.startsWith("templates ") &&
|
|
1708
|
+
parsed.path !== "templates render"
|
|
1709
|
+
) {
|
|
1710
|
+
const configUrl = requireSwarm();
|
|
1711
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1712
|
+
const context = swarmContext();
|
|
1713
|
+
const expected =
|
|
1714
|
+
typeof parsed.options.expect === "string"
|
|
1715
|
+
? parsed.options.expect
|
|
1716
|
+
: undefined;
|
|
1717
|
+
try {
|
|
1718
|
+
if (parsed.path === "templates list") {
|
|
1719
|
+
const items = await swarmTemplates(context, configUrl);
|
|
1720
|
+
const alias = state
|
|
1721
|
+
.swarms()
|
|
1722
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1723
|
+
emit(
|
|
1724
|
+
{ items },
|
|
1725
|
+
`Swarm: ${alias ? printable(alias) : "(no local alias)"}\nConfig URL: ${configUrl}\nTemplates: ${items.length}\n\n${table(
|
|
1726
|
+
["NAME", "TITLE", "TARGET CID", "TEMPLATE CID"],
|
|
1727
|
+
items.map((item) => [
|
|
1728
|
+
item.selector,
|
|
1729
|
+
item.title,
|
|
1730
|
+
item.targetCid,
|
|
1731
|
+
item.templateCid,
|
|
1732
|
+
]),
|
|
1733
|
+
"No templates registered in this Swarm.\nAdd a template: ipab templates set NAME SOURCE",
|
|
1734
|
+
)}`,
|
|
1735
|
+
);
|
|
1736
|
+
} else if (parsed.path === "templates show") {
|
|
1737
|
+
const item = (await swarmTemplates(context, configUrl, first))[0]!;
|
|
1738
|
+
if (parsed.flags.json) io.out(JSON.stringify(item));
|
|
1739
|
+
else {
|
|
1740
|
+
const alias = state
|
|
1741
|
+
.swarms()
|
|
1742
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1743
|
+
const swarm = alias ?? configUrl;
|
|
1744
|
+
const reference = formatNameReference(swarm, item.name);
|
|
1745
|
+
const tree = await templateOutputTree(
|
|
1746
|
+
context.store,
|
|
1747
|
+
item.templateCid,
|
|
1748
|
+
);
|
|
1749
|
+
const shell = process.platform === "win32" ? "powershell" : "posix";
|
|
1750
|
+
io.out(
|
|
1751
|
+
[
|
|
1752
|
+
`${printable(item.selector)} — ${printable(item.title)}`,
|
|
1753
|
+
printable(item.description) || "(No description.)",
|
|
1754
|
+
"",
|
|
1755
|
+
"Location",
|
|
1756
|
+
` Swarm: ${printable(swarm)}`,
|
|
1757
|
+
` Name: ${printable(item.name)}`,
|
|
1758
|
+
"",
|
|
1759
|
+
`Create a project (${shell === "powershell" ? "PowerShell" : "POSIX shell"})`,
|
|
1760
|
+
` ${templateRenderExample(reference, swarm, item.definition, shell)}`,
|
|
1761
|
+
" Replace example parameter values as needed. No code is run by show.",
|
|
1762
|
+
"",
|
|
1763
|
+
"Parameters",
|
|
1764
|
+
table(
|
|
1765
|
+
["NAME", "TYPE", "REQUIRED", "DEFAULT", "INPUT"],
|
|
1766
|
+
templateParameterRows(item.definition),
|
|
1767
|
+
"No parameters declared.",
|
|
1768
|
+
),
|
|
1769
|
+
"Required means an input is needed when no default is declared.",
|
|
1770
|
+
"",
|
|
1771
|
+
"Output files (from project/)",
|
|
1772
|
+
" my-project/",
|
|
1773
|
+
...tree.entries.map(
|
|
1774
|
+
(entry) =>
|
|
1775
|
+
`${" ".repeat(entry.path.split("/").length + 1)}${printable(entry.path.split("/").at(-1)!)}${entry.kind === "directory" ? "/" : ""}`,
|
|
1776
|
+
),
|
|
1777
|
+
...(tree.truncated
|
|
1778
|
+
? [
|
|
1779
|
+
` ... truncated: ${tree.truncated}; more files may exist.`,
|
|
1780
|
+
]
|
|
1781
|
+
: tree.entries.length
|
|
1782
|
+
? []
|
|
1783
|
+
: [" (no output files)"]),
|
|
1784
|
+
"",
|
|
1785
|
+
"Versions",
|
|
1786
|
+
` Template CID: ${item.templateCid}`,
|
|
1787
|
+
` Reference: ${reference}`,
|
|
1788
|
+
...(item.targetCid !== item.templateCid
|
|
1789
|
+
? [` Target CID (--expect): ${item.targetCid}`]
|
|
1790
|
+
: []),
|
|
1791
|
+
].join("\n"),
|
|
1792
|
+
);
|
|
1793
|
+
}
|
|
1794
|
+
} else if (parsed.path === "templates set") {
|
|
1795
|
+
const item = await setSwarmTemplate(
|
|
1796
|
+
context,
|
|
1797
|
+
configUrl,
|
|
1798
|
+
first!,
|
|
1799
|
+
second!,
|
|
1800
|
+
expected,
|
|
1801
|
+
);
|
|
1802
|
+
emit(
|
|
1803
|
+
item,
|
|
1804
|
+
`${item.reference} → ${item.targetCid} (Template ${item.templateCid})`,
|
|
1805
|
+
);
|
|
1806
|
+
} else {
|
|
1807
|
+
const item = await removeSwarmTemplate(
|
|
1808
|
+
context,
|
|
1809
|
+
configUrl,
|
|
1810
|
+
first!,
|
|
1811
|
+
expected!,
|
|
1812
|
+
);
|
|
1813
|
+
emit(
|
|
1814
|
+
{ removed: item },
|
|
1815
|
+
`Removed ${item.reference}; content and history are retained.`,
|
|
1816
|
+
);
|
|
1817
|
+
}
|
|
1818
|
+
} finally {
|
|
1819
|
+
await context.finishRead?.();
|
|
1820
|
+
}
|
|
1821
|
+
return 0;
|
|
1822
|
+
}
|
|
1522
1823
|
if (parsed.path.startsWith("register ")) {
|
|
1523
1824
|
const references = parsed.registrySwarms?.length
|
|
1524
1825
|
? parsed.registrySwarms
|
|
@@ -1527,7 +1828,7 @@ async function performCli(
|
|
|
1527
1828
|
: [];
|
|
1528
1829
|
if (!references.length)
|
|
1529
1830
|
throw new HostError(
|
|
1530
|
-
"Register requires a selected Swarm. Pass --swarm URL_OR_ALIAS
|
|
1831
|
+
"Register requires a selected Swarm. Pass --swarm URL_OR_ALIAS, or save a default with ipab swarm use URL_OR_ALIAS.",
|
|
1531
1832
|
);
|
|
1532
1833
|
const targets = [
|
|
1533
1834
|
...new Set(
|
|
@@ -1556,16 +1857,15 @@ async function performCli(
|
|
|
1556
1857
|
try {
|
|
1557
1858
|
if (parsed.path === "register list") {
|
|
1558
1859
|
const items = await swarmRegistrations(context, configUrl);
|
|
1860
|
+
const alias = state
|
|
1861
|
+
.swarms()
|
|
1862
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1559
1863
|
results.push({ items });
|
|
1560
1864
|
human.push(
|
|
1561
|
-
|
|
1562
|
-
["
|
|
1563
|
-
items.map((item) => [
|
|
1564
|
-
|
|
1565
|
-
item.appCid,
|
|
1566
|
-
JSON.stringify(item.argv),
|
|
1567
|
-
]),
|
|
1568
|
-
"No associations.",
|
|
1865
|
+
`Swarm: ${alias ? printable(alias) : "(no local alias)"}\nConfig URL: ${configUrl}\nAssociations: ${items.length}\n\n${table(
|
|
1866
|
+
["TYPE CID", "APP CID"],
|
|
1867
|
+
items.map((item) => [item.schemaCid, item.appCid]),
|
|
1868
|
+
"No associations registered in this Swarm.\nRegister an App: ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS",
|
|
1569
1869
|
)}`,
|
|
1570
1870
|
);
|
|
1571
1871
|
} else if (parsed.path === "register set") {
|
|
@@ -1601,7 +1901,9 @@ async function performCli(
|
|
|
1601
1901
|
completed.push(configUrl);
|
|
1602
1902
|
} catch (cause) {
|
|
1603
1903
|
throw new HostError(
|
|
1604
|
-
|
|
1904
|
+
parsed.path === "register list"
|
|
1905
|
+
? `Cannot list associations for Swarm ${configUrl}: ${message(cause)}`
|
|
1906
|
+
: `Registry operation failed for ${configUrl}: ${message(cause)}. Completed Swarms: ${completed.length ? completed.join(", ") : "(none)"}. Multiple Swarm edits are not atomic.`,
|
|
1605
1907
|
cause instanceof HostError ? cause.exitCode : 1,
|
|
1606
1908
|
cause instanceof HostError ? cause.code : "REGISTRY_FAILED",
|
|
1607
1909
|
"publication",
|
|
@@ -1715,6 +2017,8 @@ async function performCli(
|
|
|
1715
2017
|
case "swarm add":
|
|
1716
2018
|
case "swarm update":
|
|
1717
2019
|
case "search":
|
|
2020
|
+
case "skills list":
|
|
2021
|
+
case "skills sync":
|
|
1718
2022
|
case "swarm create":
|
|
1719
2023
|
case "swarm request":
|
|
1720
2024
|
case "swarm approve":
|
|
@@ -1730,6 +2034,47 @@ async function performCli(
|
|
|
1730
2034
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1731
2035
|
const context = swarmContext();
|
|
1732
2036
|
readContext = context;
|
|
2037
|
+
if (parsed.path.startsWith("skills ")) {
|
|
2038
|
+
const result = await manageSkills(context, requireSwarm(), {
|
|
2039
|
+
sync: parsed.path === "skills sync",
|
|
2040
|
+
names: parsed.positional,
|
|
2041
|
+
agents: parsed.agents ?? [],
|
|
2042
|
+
dryRun: Boolean(parsed.options["dry-run"]),
|
|
2043
|
+
yes: Boolean(parsed.options.yes),
|
|
2044
|
+
tty: io.tty,
|
|
2045
|
+
confirm: (text) => io.confirm(text),
|
|
2046
|
+
preview: (text) => {
|
|
2047
|
+
io.err(text);
|
|
2048
|
+
},
|
|
2049
|
+
});
|
|
2050
|
+
store = context.store;
|
|
2051
|
+
emit(
|
|
2052
|
+
result,
|
|
2053
|
+
[
|
|
2054
|
+
table(
|
|
2055
|
+
["NAME", "PAYLOAD CID", "INSTALL NAME", "STATUS"],
|
|
2056
|
+
result.items.map((skill) => [
|
|
2057
|
+
skill.name,
|
|
2058
|
+
skill.cid,
|
|
2059
|
+
skill.identity,
|
|
2060
|
+
skill.status,
|
|
2061
|
+
]),
|
|
2062
|
+
"No Skills.",
|
|
2063
|
+
),
|
|
2064
|
+
...result.items.flatMap((skill) => skill.problems),
|
|
2065
|
+
...result.orphaned.map(
|
|
2066
|
+
(skill) =>
|
|
2067
|
+
`Source removed: ${skill.name} ${skill.cid} (${skill.path}); installation retained.`,
|
|
2068
|
+
),
|
|
2069
|
+
...result.results.map(
|
|
2070
|
+
(entry) =>
|
|
2071
|
+
`${entry.name} / ${entry.agent}: ${entry.status}${entry.error ? `: ${entry.error}` : ""}`,
|
|
2072
|
+
),
|
|
2073
|
+
].join("\n"),
|
|
2074
|
+
);
|
|
2075
|
+
if (!result.ok) return 1;
|
|
2076
|
+
break;
|
|
2077
|
+
}
|
|
1733
2078
|
if (parsed.path === "pin") {
|
|
1734
2079
|
io.err("Fetching, verifying and retaining content...");
|
|
1735
2080
|
const result = await pinNameSubscription(
|
|
@@ -2091,7 +2436,7 @@ async function performCli(
|
|
|
2091
2436
|
}
|
|
2092
2437
|
break;
|
|
2093
2438
|
}
|
|
2094
|
-
case "
|
|
2439
|
+
case "templates render":
|
|
2095
2440
|
case "build":
|
|
2096
2441
|
case "bundle build":
|
|
2097
2442
|
case "bundle inspect":
|
|
@@ -2128,7 +2473,10 @@ async function performCli(
|
|
|
2128
2473
|
options.signal?.throwIfAborted();
|
|
2129
2474
|
const builtin = builtins.blocks.get(cid.toV1().toString());
|
|
2130
2475
|
if (builtin) return builtin.slice();
|
|
2131
|
-
return (await getStore()).block.get(
|
|
2476
|
+
return (store ?? (await getStore())).block.get(
|
|
2477
|
+
cid.toString(),
|
|
2478
|
+
options,
|
|
2479
|
+
);
|
|
2132
2480
|
},
|
|
2133
2481
|
};
|
|
2134
2482
|
const builtinSource = first ? state.pin(first) : undefined;
|
|
@@ -2136,6 +2484,64 @@ async function performCli(
|
|
|
2136
2484
|
builtinSource?.builtin && builtinSource.metadata?.kind === "bundle"
|
|
2137
2485
|
? builtinSource.cid
|
|
2138
2486
|
: first;
|
|
2487
|
+
let selectedTemplate: string | undefined;
|
|
2488
|
+
if (parsed.path === "templates render") {
|
|
2489
|
+
const selector = first!;
|
|
2490
|
+
selectedTemplate = selector;
|
|
2491
|
+
if (parseNameReference(selector)) {
|
|
2492
|
+
await getStore();
|
|
2493
|
+
const context = swarmContext();
|
|
2494
|
+
readContext = context;
|
|
2495
|
+
selectedTemplate = (
|
|
2496
|
+
await resolveReference(
|
|
2497
|
+
context,
|
|
2498
|
+
selector,
|
|
2499
|
+
selectedSwarm,
|
|
2500
|
+
(reference) => state!.resolve(reference),
|
|
2501
|
+
false,
|
|
2502
|
+
"local-first",
|
|
2503
|
+
)
|
|
2504
|
+
).cid;
|
|
2505
|
+
store = context.store;
|
|
2506
|
+
} else {
|
|
2507
|
+
let explicit = false;
|
|
2508
|
+
try {
|
|
2509
|
+
CID.parse(selector);
|
|
2510
|
+
explicit = true;
|
|
2511
|
+
} catch {
|
|
2512
|
+
/* Not a CID. */
|
|
2513
|
+
}
|
|
2514
|
+
explicit ||= selector.toLowerCase().endsWith(".car");
|
|
2515
|
+
if (!explicit) {
|
|
2516
|
+
try {
|
|
2517
|
+
await lstat(selector);
|
|
2518
|
+
explicit = true;
|
|
2519
|
+
} catch (cause) {
|
|
2520
|
+
if (
|
|
2521
|
+
!nodeError(cause, "ENOENT") &&
|
|
2522
|
+
!nodeError(cause, "ENOTDIR")
|
|
2523
|
+
)
|
|
2524
|
+
throw cause;
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
if (!explicit) {
|
|
2528
|
+
templateName(selector);
|
|
2529
|
+
if (!selectedSwarm)
|
|
2530
|
+
throw new HostError(
|
|
2531
|
+
"Template selectors require a selected Swarm. Use --swarm or swarm use, or supply an explicit Bundle directory, CAR, exact CID or IPAB URI.",
|
|
2532
|
+
);
|
|
2533
|
+
await getStore();
|
|
2534
|
+
const context = swarmContext();
|
|
2535
|
+
readContext = context;
|
|
2536
|
+
selectedTemplate = await resolveTemplateSelector(
|
|
2537
|
+
context,
|
|
2538
|
+
selector,
|
|
2539
|
+
selectedSwarm,
|
|
2540
|
+
);
|
|
2541
|
+
store = context.store;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2139
2545
|
if (parsed.path === "bundle build" || parsed.path === "build")
|
|
2140
2546
|
io.err(
|
|
2141
2547
|
parsed.path === "build"
|
|
@@ -2145,21 +2551,16 @@ async function performCli(
|
|
|
2145
2551
|
if (parsed.path === "bundle import")
|
|
2146
2552
|
io.err("Validating and importing CAR into Store...");
|
|
2147
2553
|
const result =
|
|
2148
|
-
parsed.path === "
|
|
2149
|
-
? await initApp(
|
|
2554
|
+
parsed.path === "templates render"
|
|
2555
|
+
? await initApp(second!, parsed.positional[2], {
|
|
2150
2556
|
...request,
|
|
2151
|
-
...(
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
}
|
|
2159
|
-
: {}),
|
|
2160
|
-
...(parsed.parameters
|
|
2161
|
-
? { parameters: parsed.parameters }
|
|
2162
|
-
: {}),
|
|
2557
|
+
...(selectedTemplate ? { template: selectedTemplate } : {}),
|
|
2558
|
+
parameters: [
|
|
2559
|
+
...(parsed.parameters ?? []),
|
|
2560
|
+
...(typeof parsed.options.description === "string"
|
|
2561
|
+
? [`description=${parsed.options.description}`]
|
|
2562
|
+
: []),
|
|
2563
|
+
],
|
|
2163
2564
|
})
|
|
2164
2565
|
: parsed.path === "build"
|
|
2165
2566
|
? await assembleBundle(first, {
|
|
@@ -2574,9 +2975,11 @@ async function performCli(
|
|
|
2574
2975
|
`No App registered for Schema ${schema} in Swarm ${registrySwarm}. Use ipab register set ${schema} APP_CID --swarm ${registrySwarm} or ipab exec.`,
|
|
2575
2976
|
);
|
|
2576
2977
|
appCid = association.appCid;
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2978
|
+
if (association.argv.length !== 1 || association.argv[0] !== "%")
|
|
2979
|
+
throw new HostError(
|
|
2980
|
+
"Custom per-association argv is unsupported; adapt the App to accept only the content CID or use ipab exec APP_CID ARGS.",
|
|
2981
|
+
);
|
|
2982
|
+
appArgv = [root];
|
|
2580
2983
|
// execute owns the App/input context before this validation owner's eventual release.
|
|
2581
2984
|
const result = await execute(
|
|
2582
2985
|
state,
|