@ipab/cli 0.1.0-rc.11 → 0.1.0-rc.12

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