@ipab/cli 0.1.0-rc.0 → 0.1.0-rc.2

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 (101) hide show
  1. package/README.md +26 -4
  2. package/dist/app-authoring.d.ts +11 -2
  3. package/dist/app-authoring.d.ts.map +1 -1
  4. package/dist/app-authoring.js +135 -20
  5. package/dist/app-authoring.js.map +1 -1
  6. package/dist/app-definition.d.ts +0 -6
  7. package/dist/app-definition.d.ts.map +1 -1
  8. package/dist/app-definition.js +1 -7
  9. package/dist/app-definition.js.map +1 -1
  10. package/dist/app-templates.d.ts.map +1 -1
  11. package/dist/app-templates.js +8 -0
  12. package/dist/app-templates.js.map +1 -1
  13. package/dist/assembly.d.ts +7 -0
  14. package/dist/assembly.d.ts.map +1 -0
  15. package/dist/assembly.js +131 -0
  16. package/dist/assembly.js.map +1 -0
  17. package/dist/authoring.d.ts +6 -15
  18. package/dist/authoring.d.ts.map +1 -1
  19. package/dist/authoring.js +13 -42
  20. package/dist/authoring.js.map +1 -1
  21. package/dist/builtins/template.node.car +0 -0
  22. package/dist/builtins/template.web-app.car +0 -0
  23. package/dist/builtins.d.ts.map +1 -1
  24. package/dist/builtins.js +5 -10
  25. package/dist/builtins.js.map +1 -1
  26. package/dist/cli.d.ts +1 -0
  27. package/dist/cli.d.ts.map +1 -1
  28. package/dist/cli.js +639 -147
  29. package/dist/cli.js.map +1 -1
  30. package/dist/config-secret.d.ts +3 -0
  31. package/dist/config-secret.d.ts.map +1 -0
  32. package/dist/config-secret.js +83 -0
  33. package/dist/config-secret.js.map +1 -0
  34. package/dist/config.d.ts +7 -4
  35. package/dist/config.d.ts.map +1 -1
  36. package/dist/config.js +118 -22
  37. package/dist/config.js.map +1 -1
  38. package/dist/content-provider.d.ts +9 -0
  39. package/dist/content-provider.d.ts.map +1 -0
  40. package/dist/content-provider.js +90 -0
  41. package/dist/content-provider.js.map +1 -0
  42. package/dist/context.d.ts +1 -0
  43. package/dist/context.d.ts.map +1 -1
  44. package/dist/context.js +10 -0
  45. package/dist/context.js.map +1 -1
  46. package/dist/get.d.ts +3 -0
  47. package/dist/get.d.ts.map +1 -0
  48. package/dist/get.js +61 -0
  49. package/dist/get.js.map +1 -0
  50. package/dist/identity.d.ts +9 -0
  51. package/dist/identity.d.ts.map +1 -0
  52. package/dist/identity.js +89 -0
  53. package/dist/identity.js.map +1 -0
  54. package/dist/ipc.d.ts +2 -1
  55. package/dist/ipc.d.ts.map +1 -1
  56. package/dist/ipc.js +10 -1
  57. package/dist/ipc.js.map +1 -1
  58. package/dist/pins.d.ts +9 -9
  59. package/dist/pins.d.ts.map +1 -1
  60. package/dist/pins.js +10 -28
  61. package/dist/pins.js.map +1 -1
  62. package/dist/runtime.d.ts.map +1 -1
  63. package/dist/runtime.js +1 -1
  64. package/dist/runtime.js.map +1 -1
  65. package/dist/source-bundle.d.ts +0 -1
  66. package/dist/source-bundle.d.ts.map +1 -1
  67. package/dist/source-bundle.js +1 -2
  68. package/dist/source-bundle.js.map +1 -1
  69. package/dist/state.d.ts +35 -10
  70. package/dist/state.d.ts.map +1 -1
  71. package/dist/state.js +124 -14
  72. package/dist/state.js.map +1 -1
  73. package/dist/swarm.d.ts +113 -0
  74. package/dist/swarm.d.ts.map +1 -0
  75. package/dist/swarm.js +760 -0
  76. package/dist/swarm.js.map +1 -0
  77. package/dist/template-definition.d.ts +0 -17
  78. package/dist/template-definition.d.ts.map +1 -1
  79. package/dist/template-definition.js +1 -10
  80. package/dist/template-definition.js.map +1 -1
  81. package/package.json +15 -10
  82. package/src/app-authoring.ts +203 -29
  83. package/src/app-definition.ts +1 -7
  84. package/src/app-templates.ts +13 -0
  85. package/src/assembly.ts +182 -0
  86. package/src/authoring.ts +32 -58
  87. package/src/builtins.ts +5 -11
  88. package/src/cli.ts +785 -167
  89. package/src/config-secret.ts +96 -0
  90. package/src/config.ts +161 -25
  91. package/src/content-provider.ts +123 -0
  92. package/src/context.ts +10 -0
  93. package/src/get.ts +68 -0
  94. package/src/identity.ts +133 -0
  95. package/src/ipc.ts +8 -0
  96. package/src/pins.ts +14 -28
  97. package/src/runtime.ts +1 -0
  98. package/src/source-bundle.ts +1 -2
  99. package/src/state.ts +149 -24
  100. package/src/swarm.ts +1186 -0
  101. package/src/template-definition.ts +1 -10
package/dist/cli.js CHANGED
@@ -3,18 +3,22 @@ import { readFile } from "node:fs/promises";
3
3
  import { IpfsStore } from "@ipab/ipfs-store";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import stringWidth from "string-width";
6
- import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, } from "./config.js";
6
+ import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, visibleConfig, } from "./config.js";
7
7
  import { HostError, message, object, syntax } from "./errors.js";
8
8
  import { filters, listHistory, selectedIds, Ownership, recoverInactive, removeHistory, } from "./history.js";
9
9
  import { execute } from "./runtime.js";
10
10
  import { validatedBundle } from "./space.js";
11
11
  import { exactCid, pinName, State } from "./state.js";
12
- import { buildBundle, initBundle, inspectBundle, importBundle, } from "./authoring.js";
13
- import { buildApp, initApp } from "./app-authoring.js";
12
+ import { buildBundle, inspectBundle, importBundle } from "./authoring.js";
13
+ import { initApp } from "./app-authoring.js";
14
+ import { assembleBundle } from "./assembly.js";
15
+ import { getBundle } from "./get.js";
16
+ import { createSwarm, requestMembership, approveMembership, joinSwarm, descriptor, swarmHeader, addSwarm, updateSwarm, searchNames, resolveReference, publish, } from "./swarm.js";
14
17
  import { schemaAlias } from "./app-definition.js";
15
18
  import { addPin, deletePin, pinDetails, renamePin } from "./pins.js";
16
19
  import { logFiles } from "./logs.js";
17
20
  import { builtinContent } from "./builtins.js";
21
+ import { readSecretStream } from "./config-secret.js";
18
22
  export const processIO = {
19
23
  out(text) {
20
24
  process.stdout.write(`${text}\n`);
@@ -26,6 +30,12 @@ export const processIO = {
26
30
  columns() {
27
31
  return process.stdout.columns;
28
32
  },
33
+ async readSecret() {
34
+ if (process.stdin.isTTY)
35
+ syntax("Pipe the API key through stdin; interactive echo is not permitted.");
36
+ process.stdin.setEncoding("utf8");
37
+ return readSecretStream(process.stdin);
38
+ },
29
39
  async confirm(text) {
30
40
  const reader = createInterface({
31
41
  input: process.stdin,
@@ -40,39 +50,221 @@ export const processIO = {
40
50
  },
41
51
  };
42
52
  const commands = {
53
+ "swarm create": "swarm create [--service URL] [--resume OPERATION]",
54
+ "swarm request": "swarm request SWARM_CID",
55
+ "swarm approve": "swarm approve REQUEST_CID [--expires-in SECONDS] --yes",
56
+ "swarm join": "swarm join RESPONSE_CID",
57
+ "swarm status": "swarm status [SWARM_CID]",
58
+ "swarm list": "swarm list",
59
+ "swarm add": "swarm add SWARM_CID [--alias ALIAS]",
60
+ "swarm use": "swarm use CID_OR_ALIAS",
61
+ "swarm remove": "swarm remove CID_OR_ALIAS",
62
+ "swarm update": "swarm update [CID_OR_ALIAS] [--name TEXT] [--description TEXT]",
63
+ publish: "publish CID_OR_CAR [--name NAME [--expect OLD_NODE_CID | --snapshot]]",
64
+ get: "get REF [--raw] [--force | --no-force] [-o DIRECTORY]",
65
+ search: "search QUERY [--current] [--force | --no-force]",
43
66
  init: "init NAME [DIR] [OPTIONS]",
44
- build: "build [DIR] [OPTIONS]",
45
- "bundle init": "bundle init TYPE DIR",
67
+ build: "build [SOURCE] [OPTIONS]",
46
68
  "bundle build": "bundle build SOURCE [OPTIONS]",
47
69
  "bundle inspect": "bundle inspect SOURCE",
48
70
  "bundle import": "bundle import FILE.car",
49
- exec: "exec [--log] APP [APP_ARGS...]",
50
- open: "open [--log] CONTENT",
71
+ exec: "exec [--log] [--force | --no-force] APP [APP_ARGS...]",
72
+ open: "open [--log] [--raw] [--force | --no-force] CONTENT",
51
73
  "pin add": "pin add NAME CID",
52
74
  "pin delete": "pin delete NAME",
53
- "pin list": "pin list [--kind bundle|schema] [--type TYPE]",
75
+ "pin list": "pin list [--type TYPE]",
54
76
  "pin show": "pin show NAME",
55
77
  "pin rename": "pin rename OLD_NAME NEW_NAME",
56
78
  "register list": "register list",
57
79
  "register set": "register set SCHEMA APP [--replace] [-- TEMPLATE...]",
58
80
  "register remove": "register remove SCHEMA",
59
81
  "config get": "config get [KEY]",
60
- "config set": "config set KEY VALUE",
82
+ "config set": "config set KEY VALUE\n ipab config set pointers.apiKey - < protected-key-file",
61
83
  "config reset": "config reset KEY",
84
+ "store usage": "store usage",
85
+ "store gc": "store gc",
62
86
  "history list": "history list [OPTIONS]",
63
87
  "history show": "history show RUN_ID",
64
88
  "history remove": "history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
65
89
  };
66
90
  const groups = {
91
+ swarm: "Create, authorize, select and manage personal swarms",
67
92
  bundle: "Create, inspect and import content bundles",
68
93
  pin: "Retain content and manage short names",
69
94
  register: "Associate content types with Apps",
70
95
  config: "Manage local configuration",
96
+ store: "Query local storage and collect unreferenced blocks",
71
97
  history: "View and remove execution history",
72
98
  };
73
99
  const commandHelp = {
100
+ "swarm create": {
101
+ summary: "Create a swarm using the account HOME identity",
102
+ options: [
103
+ "--service URL Must match the protected pointers.service origin.",
104
+ "--resume OPERATION Recover the same saved create/idempotency result.",
105
+ "--name TEXT Initial mutable swarm name.",
106
+ "--description TEXT Initial mutable description.",
107
+ "--alias ALIAS Optional local registry alias (not the shared name).",
108
+ ],
109
+ examples: [
110
+ "ipab config set pointers.service https://service.example",
111
+ "ipab config set pointers.apiKey -",
112
+ "ipab swarm create",
113
+ ],
114
+ notes: [
115
+ "Creation uses the protected, origin-bound API key and owner possession proof.",
116
+ "Uses the prepared private Kubo provider; never deploys infrastructure.",
117
+ "Returns one descriptor CID; owner needs no member certificate.",
118
+ ],
119
+ },
120
+ "swarm request": {
121
+ summary: "Publish a signed account membership request",
122
+ examples: ["ipab swarm request SWARM_CID"],
123
+ notes: [
124
+ "Returns one request CID. Private IPFS access is a prerequisite, not membership.",
125
+ ],
126
+ },
127
+ "swarm approve": {
128
+ summary: "Owner signs a certificate for an exact request",
129
+ options: [
130
+ "--yes Explicit approval; required outside a TTY.",
131
+ "--expires-in SECONDS 60..2592000; default 604800.",
132
+ ],
133
+ examples: ["ipab swarm approve REQUEST_CID --yes"],
134
+ notes: ["Returns one response CID. Never exports the owner private key."],
135
+ },
136
+ "swarm join": {
137
+ summary: "Verify a response and authenticate HEAD",
138
+ examples: ["ipab swarm join RESPONSE_CID"],
139
+ options: ["--alias ALIAS Register this swarm with a local alias."],
140
+ notes: [
141
+ "Requires this account's exact pending request and bound member certificate.",
142
+ ],
143
+ },
144
+ "swarm status": {
145
+ summary: "Authenticate the current swarm HEAD",
146
+ examples: ["ipab swarm status", "ipab swarm status work"],
147
+ notes: [
148
+ "Always authenticate and refresh HEAD; update the local header cache.",
149
+ ],
150
+ },
151
+ "swarm list": {
152
+ summary: "List local swarm registrations and the effective selection",
153
+ examples: ["ipab swarm list", "ipab --json swarm list"],
154
+ notes: ["Local only; does not verify remote membership or refresh HEAD."],
155
+ },
156
+ "swarm add": {
157
+ summary: "Authenticate and register a swarm you already have access to",
158
+ options: [
159
+ "--alias ALIAS Unique local alias; does not rename the shared swarm.",
160
+ ],
161
+ examples: ["ipab swarm add SWARM_CID --alias work"],
162
+ notes: [
163
+ "Not a membership grant. The first registration becomes the saved default only if none exists.",
164
+ ],
165
+ },
166
+ "swarm use": {
167
+ summary: "Save a registered swarm as the current default",
168
+ examples: ["ipab swarm use work"],
169
+ notes: ["Local only. --swarm still overrides the saved default."],
170
+ },
171
+ "swarm remove": {
172
+ summary: "Forget a local registration without revoking membership",
173
+ examples: ["ipab swarm remove work"],
174
+ notes: [
175
+ "Preserves credentials, content and remote membership. Clears a matching saved default without selecting a replacement.",
176
+ ],
177
+ },
178
+ "swarm update": {
179
+ summary: "Update shared swarm information as an owner or member",
180
+ arguments: ["CID_OR_ALIAS Defaults to the effective current swarm."],
181
+ options: [
182
+ "--name TEXT Replace the shared display name; empty text clears it.",
183
+ "--description TEXT Replace the shared description; empty text clears it.",
184
+ ],
185
+ examples: [
186
+ 'ipab swarm update work --name "Team" --description "Shared workspace"',
187
+ 'ipab swarm update --description ""',
188
+ ],
189
+ notes: [
190
+ "Requires at least one field. Any authorized member can update both fields.",
191
+ "Last successful write wins for the specified fields; no expected-value/version input.",
192
+ "Automatically retries HEAD contention while preserving current Names and unspecified properties.",
193
+ "Shared name changes do not rename local registry aliases.",
194
+ ],
195
+ },
196
+ search: {
197
+ summary: "Search formal Names across registered swarms",
198
+ arguments: [
199
+ "QUERY Case-insensitive literal name substring, 1..256 characters.",
200
+ ],
201
+ options: [
202
+ "--current Search only the effective current swarm; conflicts with --swarm.",
203
+ "--force Refresh HEAD for every swarm in the search scope.",
204
+ "--no-force Override swarm.forceRefresh and use valid cached headers.",
205
+ ],
206
+ examples: ["ipab search hello", "ipab --swarm work search hello --force"],
207
+ notes: [
208
+ "Searches all registered swarms unless --current or --swarm selects one.",
209
+ "Valid caches use local Names only; absent/expired caches refresh. No payload downloads.",
210
+ "No matches is success, not a reason to refresh valid caches. Any failed swarm fails the whole search.",
211
+ ],
212
+ },
213
+ publish: {
214
+ summary: "Provide built content and explicitly publish a Name",
215
+ options: [
216
+ "--name NAME New formal Name; occupied Names fail.",
217
+ "--expect CID Exact old Artifact node, required for iteration.",
218
+ "--snapshot Name ordinary content without an Artifact; initial only.",
219
+ ],
220
+ examples: [
221
+ "ipab publish app.car --name apps/hello",
222
+ "ipab publish APP_CID --name apps/hello --expect OLD_NODE_CID",
223
+ "ipab publish CONTENT_CID",
224
+ ],
225
+ notes: [
226
+ "No build, edit, install or execution. CID-only stdout.",
227
+ "Different-name CAS contention is rebased; same-name edits conflict (exit 3).",
228
+ "Kubo pin confirmation precedes HEAD; it does not prove a remote device is online.",
229
+ ],
230
+ },
231
+ get: {
232
+ summary: "Verify and unpack Bundle content without executing it",
233
+ options: [
234
+ "--raw Select the Artifact node instead of its value.",
235
+ "--force Refresh the shared Name's swarm HEAD.",
236
+ "--no-force Override swarm.forceRefresh and use valid cached headers.",
237
+ "-o, --output DIRECTORY New or empty directory; defaults to resolved CID.",
238
+ ],
239
+ examples: [
240
+ "ipab --json get ipab:///apps/hello -o hello-app",
241
+ "ipab get ipab://work/apps/hello -o hello-app",
242
+ "ipab get --raw RELEASE_CID",
243
+ ],
244
+ notes: [
245
+ "Returns the selected content CID and original target CID (editing baseline).",
246
+ "ipab://SWARM_CID_OR_ALIAS/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
247
+ "Does not install, build, edit, or automatically retrieve associated source.",
248
+ ],
249
+ },
250
+ "store usage": {
251
+ summary: "Query cached and recursively pinned block bytes",
252
+ examples: ["ipab store usage", "ipab --json store usage"],
253
+ notes: [
254
+ "Local Store only; excludes metadata, temporary files and disk allocation overhead.",
255
+ "Pinned DAGs include all descendants, with shared blocks counted once.",
256
+ ],
257
+ },
258
+ "store gc": {
259
+ summary: "Delete unprotected blocks from the entire selected local Store",
260
+ examples: ["ipab store gc", "ipab --json store gc"],
261
+ notes: [
262
+ "Preserves pins, all participating owners, pending operations and staged imports.",
263
+ "Does not unpin, clear history, delete unknown files or request Kubo daemon GC.",
264
+ ],
265
+ },
74
266
  init: {
75
- summary: "Create a private TypeScript App project",
267
+ summary: "Create files from a Template Bundle (default: Node App project)",
76
268
  arguments: ["NAME Project name; DIR defaults to NAME (new/empty only)."],
77
269
  options: [
78
270
  "--template TEMPLATE node (default), web-app, directory, CAR, CID or pin.",
@@ -87,33 +279,27 @@ const commandHelp = {
87
279
  notes: ["Does not install dependencies or execute template code."],
88
280
  },
89
281
  build: {
90
- summary: "Build an App CAR from a project",
91
- arguments: ["DIR Project directory (default: current directory)."],
282
+ summary: "Assemble any Bundle using ipab.build.yaml (no compilation)",
283
+ arguments: [
284
+ "SOURCE Recipe file or Bundle directory (default: current directory).",
285
+ ],
92
286
  options: [
93
- "-o, --output FILE Destination (default: dist/app.car).",
287
+ "-o, --output FILE Destination (default: dist/bundle.car).",
94
288
  "--replace Allow replacing existing regular artifacts.",
95
- "--no-import Write CAR files without importing the App into Store.",
96
- "--with-source Include a separate source CAR (default: enabled).",
97
- "--without-source Omit source CAR; conflicts with --with-source.",
289
+ "--no-import Write the CAR without importing the Bundle into Store.",
290
+ ],
291
+ examples: [
292
+ "ipab build prepared-app",
293
+ "ipab build ipab.build.yaml --replace",
98
294
  ],
99
- examples: ["ipab build", "ipab build hello --replace --without-source"],
100
295
  notes: [
101
- "Uses local tsc and bundles Node CommonJS; ipab.yaml configures the build.",
102
- "Explicit ipab-prebuild strategy executes trusted project code.",
103
- "Source follows project .gitignore rules; review private files before sharing.",
104
- "Imports only the App, without pinning; source needs separate import/retention.",
296
+ "Recipe explicitly maps source files and exact CID imports to target paths.",
297
+ "Type and entry come from .bundle.yaml; imported DAG identities are preserved.",
298
+ "Legacy App ipab.yaml is rejected; use project preparation tools separately.",
299
+ "Select explicit files; review private files before providing Bundles.",
105
300
  "Store failures preserve the CAR; retry with ipab bundle import FILE.car.",
106
301
  ],
107
302
  },
108
- "bundle init": {
109
- summary: "Create content from a Bundle type",
110
- arguments: [
111
- "TYPE Definition file, type CAR, exact type CID or Schema pin.",
112
- "DIR New or empty destination directory.",
113
- ],
114
- examples: ["ipab bundle init types\\dist\\schema.car note"],
115
- notes: ["Writes .bundle.yaml, .bundle-ignore and the default entry."],
116
- },
117
303
  "bundle build": {
118
304
  summary: "Build a content or type CAR without compiling code",
119
305
  arguments: ["SOURCE Bundle directory or definition file."],
@@ -148,20 +334,23 @@ const commandHelp = {
148
334
  ],
149
335
  },
150
336
  exec: {
151
- summary: "Run an App by CID or named pin",
337
+ summary: "Run an App by CID, named pin or IPAB URI",
152
338
  arguments: [
153
339
  "APP_ARGS Everything after APP is passed verbatim, including --help.",
154
340
  ],
155
341
  options: [
156
342
  "--log Record stdout/stderr; must precede APP. Requires history enabled.",
343
+ "--force Refresh the shared Name's swarm HEAD; must precede APP.",
344
+ "--no-force Override swarm.forceRefresh; must precede APP.",
157
345
  ],
158
346
  examples: [
159
347
  "ipab exec reader",
160
- "ipab exec reader --help",
161
348
  "ipab exec --log reader",
349
+ "ipab exec ipab://work/apps/hello --help",
162
350
  ],
163
351
  notes: [
164
352
  "Apps are NOT sandboxed; run only Apps you trust.",
353
+ "ipab://SWARM_CID_OR_ALIAS/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
165
354
  "History stores argv by default; do not put secrets in arguments.",
166
355
  "Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
167
356
  "--json is not supported; App stdio is passed through.",
@@ -169,25 +358,35 @@ const commandHelp = {
169
358
  },
170
359
  open: {
171
360
  summary: "Open content with its registered App",
172
- arguments: ["CONTENT Bundle CID or named pin."],
173
- options: ["--log Record stdout/stderr; requires history enabled."],
174
- examples: ["ipab open CONTENT_CID", "ipab open --log my-note"],
361
+ arguments: ["CONTENT Bundle CID, named pin or IPAB URI."],
362
+ options: [
363
+ "--log Record stdout/stderr; requires history enabled.",
364
+ "--raw Open the Artifact node rather than its value.",
365
+ "--force Refresh the shared Name's swarm HEAD.",
366
+ "--no-force Override swarm.forceRefresh and use valid cached headers.",
367
+ ],
368
+ examples: [
369
+ "ipab open CONTENT_CID",
370
+ "ipab open --log my-note",
371
+ "ipab open ipab:///documents/readme",
372
+ ],
175
373
  notes: [
176
374
  "Requires a saved registration and App support for the exact content type.",
375
+ "ipab://SWARM_CID_OR_ALIAS/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
177
376
  "Apps are NOT sandboxed; run only Apps you trust.",
178
377
  "Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
179
378
  "--json is not supported; App stdio is passed through.",
180
379
  ],
181
380
  },
182
381
  "pin add": {
183
- summary: "Verify, retain and name content",
382
+ summary: "Verify, retain and name a Bundle",
184
383
  arguments: [
185
384
  "NAME Unused short name.",
186
- "CID Exact content CID, not another pin name.",
385
+ "CID Exact Bundle CID, not another pin name or a standalone type block.",
187
386
  ],
188
387
  examples: ["ipab pin add reader APP_CID"],
189
388
  notes: [
190
- "Verifies the full DAG and retains it in the configured Store.",
389
+ "Validates a complete Bundle and retains its full DAG in the configured Store.",
191
390
  "Does not execute or trust Apps, install dependencies or start a daemon.",
192
391
  "The builtin namespace is read-only.",
193
392
  ],
@@ -203,15 +402,12 @@ const commandHelp = {
203
402
  "pin list": {
204
403
  summary: "List user and built-in pins",
205
404
  options: [
206
- "--kind bundle|schema Filter by kind; omit to include ordinary content.",
207
- "--type TYPE Exact schema CID, Schema pin or builtin shortcut.",
208
- ],
209
- examples: [
210
- "ipab pin list",
211
- "ipab pin list --kind bundle --type builtin:node-app.v1",
405
+ "--type TYPE Exact type CID or the name of a Bundle pin of that type.",
212
406
  ],
407
+ examples: ["ipab pin list", "ipab pin list --type reader"],
213
408
  notes: [
214
- "Filters combine with AND. Unfinished user operations are reported separately.",
409
+ "Unfinished operations and legacy non-Bundle pins are reported separately.",
410
+ "Legacy retention is preserved; use pin delete to explicitly release it.",
215
411
  "Reads local registrations and packaged built-ins, not live node status.",
216
412
  ],
217
413
  },
@@ -260,21 +456,25 @@ const commandHelp = {
260
456
  "config get": {
261
457
  summary: "Show effective configuration",
262
458
  arguments: ["KEY Optional configuration key; omit to show all values."],
263
- examples: ["ipab config get", "ipab config get store.rpc"],
459
+ examples: ["ipab config get", "ipab config get store.gateway"],
264
460
  },
265
461
  "config set": {
266
462
  summary: "Save a local configuration value",
267
463
  examples: [
268
- "ipab config set store.rpc http://127.0.0.1:5001",
464
+ "ipab config set pointers.apiKey -",
465
+ "ipab config set store.gateway http://127.0.0.1:8080",
269
466
  "ipab config set history.enabled false",
270
467
  ],
271
468
  notes: [
272
- "store.rpc is a Kubo RPC API URL, not a gateway; no daemon is started.",
469
+ "store.gateway is a read-only HTTP gateway; blocks, pins and GC remain local.",
470
+ "pointers.service is a canonical HTTPS origin (HTTP loopback allowed).",
471
+ "pointers.apiKey is accepted only through stdin using VALUE '-'; queries and confirmations redact it.",
472
+ "Saving pointers.apiKey protects state SQLite files with account-only Unix modes or Windows ACLs.",
273
473
  ],
274
474
  },
275
475
  "config reset": {
276
476
  summary: "Remove a saved configuration override",
277
- examples: ["ipab config reset store.rpc"],
477
+ examples: ["ipab config reset store.gateway"],
278
478
  },
279
479
  "history list": {
280
480
  summary: "List execution history",
@@ -321,8 +521,9 @@ const commandHelp = {
321
521
  };
322
522
  export function help(path = "") {
323
523
  const globalOptions = `Global options (before COMMAND):
524
+ --swarm CID|ALIAS Select shared swarm (otherwise swarm.default; URI swarm takes precedence)
324
525
  --state-dir PATH Set the local state directory
325
- --store-rpc URL Use a Kubo RPC endpoint
526
+ --store-gateway URL Use a read-only upstream HTTP gateway
326
527
  --json Output management/development metadata, not App stdio`;
327
528
  const footer = "Full reference: https://github.com/silvermoon-work/ipab/blob/main/docs/reference.md";
328
529
  if (!path)
@@ -340,9 +541,14 @@ Create:
340
541
  bundle ${groups.bundle}
341
542
 
342
543
  Manage:
544
+ swarm ${groups.swarm}
545
+ search Search formal Names across registered swarms
546
+ publish ${commandHelp.publish.summary}
547
+ get ${commandHelp.get.summary}
343
548
  pin ${groups.pin}
344
549
  register ${groups.register}
345
550
  config ${groups.config}
551
+ store ${groups.store}
346
552
  history ${groups.history}
347
553
 
348
554
  ${globalOptions}
@@ -412,6 +618,19 @@ function runDuration(record) {
412
618
  throw new HostError("Execution record has an invalid duration.");
413
619
  return `${Math.floor(duration / 1000)}s`;
414
620
  }
621
+ function storageBytes(bytes) {
622
+ const units = ["B", "KB", "MB", "GB", "TB", "PB"];
623
+ let scaled = bytes;
624
+ let unit = 0;
625
+ while (scaled >= 1000 && unit < units.length - 1) {
626
+ scaled /= 1000;
627
+ unit++;
628
+ }
629
+ const exact = bytes.toLocaleString("en-US");
630
+ return unit === 0
631
+ ? `${exact} bytes`
632
+ : `${scaled.toLocaleString("en-US", { maximumFractionDigits: 2 })} ${units[unit]} (${exact} bytes)`;
633
+ }
415
634
  function table(headers, rows, empty) {
416
635
  if (!rows.length)
417
636
  return empty;
@@ -490,14 +709,20 @@ export function parse(argv) {
490
709
  }
491
710
  if (flag === "--json")
492
711
  flags.json = true;
493
- else if (flag === "--state-dir" || flag === "--store-rpc") {
712
+ else if (flag === "--store-rpc")
713
+ syntax("Store RPC is no longer supported. Use --store-gateway with an HTTP gateway URL; existing Kubo pins are not migrated.");
714
+ else if (flag === "--state-dir" ||
715
+ flag === "--store-gateway" ||
716
+ flag === "--swarm") {
494
717
  const value = tokens.shift();
495
718
  if (!value || value.startsWith("-"))
496
719
  syntax(`${flag} needs a value.`);
497
720
  if (flag === "--state-dir")
498
721
  flags.stateDir = value;
722
+ else if (flag === "--swarm")
723
+ flags.swarm = value;
499
724
  else {
500
- flags.storeRpc = publicUrl(value);
725
+ flags.storeGateway = publicUrl(value);
501
726
  }
502
727
  }
503
728
  else
@@ -517,10 +742,14 @@ export function parse(argv) {
517
742
  if (group === "exec") {
518
743
  if (flags.json)
519
744
  syntax("--json is not supported for exec/open.");
520
- if (tokens[0] === "--log") {
521
- result.options.log = true;
522
- tokens.shift();
745
+ while (["--log", "--force", "--no-force"].includes(tokens[0] ?? "")) {
746
+ const option = tokens.shift().slice(2);
747
+ if (Object.hasOwn(result.options, option))
748
+ syntax(`Duplicate option --${option}.`);
749
+ result.options[option] = true;
523
750
  }
751
+ if (result.options.force && result.options["no-force"])
752
+ syntax("--force and --no-force are mutually exclusive.");
524
753
  if (tokens[0] === "-h" || tokens[0] === "--help") {
525
754
  result.help = true;
526
755
  return result;
@@ -530,8 +759,16 @@ export function parse(argv) {
530
759
  result.positional = tokens;
531
760
  return result;
532
761
  }
533
- if (!["open", "init", "build"].includes(group)) {
534
- if (!["bundle", "pin", "register", "config", "history"].includes(group))
762
+ if (!["open", "init", "build", "publish", "get", "search"].includes(group)) {
763
+ if (![
764
+ "bundle",
765
+ "pin",
766
+ "register",
767
+ "config",
768
+ "history",
769
+ "store",
770
+ "swarm",
771
+ ].includes(group))
535
772
  syntax(`Unknown command "${group}".`);
536
773
  if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
537
774
  result.help = true;
@@ -552,28 +789,52 @@ export function parse(argv) {
552
789
  result.help = true;
553
790
  return result;
554
791
  }
792
+ if (result.path === "config set" &&
793
+ tokens.includes("pointers.apiKey") &&
794
+ !(tokens.length === 2 && tokens[1] === "-"))
795
+ syntax("API key must be provided through '-' and piped stdin; never pass it in command arguments.");
555
796
  const booleans = result.path === "bundle build"
556
797
  ? ["replace", "schema-only", "no-import"]
557
798
  : result.path === "build"
558
- ? ["replace", "no-import", "with-source", "without-source"]
559
- : result.path === "register set"
560
- ? ["replace"]
561
- : result.path === "history remove"
562
- ? ["yes"]
563
- : result.path === "open"
564
- ? ["log"]
565
- : [];
566
- const values = result.path === "init"
567
- ? ["template"]
568
- : result.path === "bundle build" || result.path === "build"
569
- ? ["output"]
570
- : result.path === "history list"
571
- ? ["app", "status", "since", "until", "limit", "before"]
572
- : result.path === "history remove"
573
- ? ["app", "status", "since", "until"]
574
- : result.path === "pin list"
575
- ? ["kind", "type"]
576
- : [];
799
+ ? ["replace", "no-import"]
800
+ : result.path === "publish"
801
+ ? ["snapshot"]
802
+ : result.path === "get"
803
+ ? ["raw", "force", "no-force"]
804
+ : result.path === "search"
805
+ ? ["current", "force", "no-force"]
806
+ : result.path === "swarm approve"
807
+ ? ["yes"]
808
+ : result.path === "register set"
809
+ ? ["replace"]
810
+ : result.path === "history remove"
811
+ ? ["yes"]
812
+ : result.path === "open"
813
+ ? ["log", "raw", "force", "no-force"]
814
+ : [];
815
+ const values = result.path === "swarm create"
816
+ ? ["service", "resume", "name", "description", "alias"]
817
+ : result.path === "swarm add" || result.path === "swarm join"
818
+ ? ["alias"]
819
+ : result.path === "swarm update"
820
+ ? ["name", "description"]
821
+ : result.path === "swarm approve"
822
+ ? ["expires-in"]
823
+ : result.path === "publish"
824
+ ? ["name", "expect"]
825
+ : result.path === "get"
826
+ ? ["output"]
827
+ : result.path === "init"
828
+ ? ["template"]
829
+ : result.path === "bundle build" || result.path === "build"
830
+ ? ["output"]
831
+ : result.path === "history list"
832
+ ? ["app", "status", "since", "until", "limit", "before"]
833
+ : result.path === "history remove"
834
+ ? ["app", "status", "since", "until"]
835
+ : result.path === "pin list"
836
+ ? ["type"]
837
+ : [];
577
838
  while (tokens.length) {
578
839
  const value = tokens.shift();
579
840
  if (value.startsWith("--") || value === "-o") {
@@ -591,7 +852,9 @@ export function parse(argv) {
591
852
  result.options[option] = true;
592
853
  else if (values.includes(option)) {
593
854
  const input = tokens.shift();
594
- if (!input || input.startsWith("--"))
855
+ if (input === undefined ||
856
+ input.startsWith("--") ||
857
+ (input === "" && result.path !== "swarm update"))
595
858
  syntax(`${value} needs a value.`);
596
859
  result.options[option] = input;
597
860
  }
@@ -601,10 +864,28 @@ export function parse(argv) {
601
864
  else
602
865
  result.positional.push(value);
603
866
  }
867
+ if (result.options.force && result.options["no-force"])
868
+ syntax("--force and --no-force are mutually exclusive.");
869
+ if (result.path === "search" &&
870
+ result.options.current &&
871
+ flags.swarm !== undefined)
872
+ syntax("--current and --swarm are mutually exclusive.");
604
873
  const counts = {
874
+ "swarm create": [0, 0],
875
+ "swarm request": [1, 1],
876
+ "swarm approve": [1, 1],
877
+ "swarm join": [1, 1],
878
+ "swarm status": [0, 1],
879
+ "swarm list": [0, 0],
880
+ "swarm add": [1, 1],
881
+ "swarm use": [1, 1],
882
+ "swarm remove": [1, 1],
883
+ "swarm update": [0, 1],
884
+ publish: [1, 1],
885
+ get: [1, 1],
886
+ search: [1, 1],
605
887
  init: [1, 2],
606
888
  build: [0, 1],
607
- "bundle init": [2, 2],
608
889
  "bundle build": [1, 1],
609
890
  "bundle inspect": [1, 1],
610
891
  "bundle import": [1, 1],
@@ -620,6 +901,8 @@ export function parse(argv) {
620
901
  "config get": [0, 1],
621
902
  "config set": [2, 2],
622
903
  "config reset": [1, 1],
904
+ "store usage": [0, 0],
905
+ "store gc": [0, 0],
623
906
  "history list": [0, 0],
624
907
  "history show": [1, 1],
625
908
  "history remove": [0, Number.MAX_SAFE_INTEGER],
@@ -646,14 +929,18 @@ export function parse(argv) {
646
929
  if (result.path === "pin rename")
647
930
  pinName(result.positional[1]);
648
931
  }
649
- if (result.options.kind !== undefined &&
650
- !["bundle", "schema"].includes(String(result.options.kind)))
651
- syntax("--kind must be bundle or schema.");
652
932
  if (result.path.startsWith("config ") && result.positional[0]) {
653
- if (!(result.path === "config get" && result.positional[0] === "state-dir"))
933
+ if (!(result.path === "config get" && result.positional[0] === "state-dir") &&
934
+ !(result.path === "config reset" && result.positional[0] === "store.rpc"))
654
935
  configKey(result.positional[0]);
655
- if (result.path === "config set")
656
- parseValue(configKey(result.positional[0]), result.positional[1], true);
936
+ if (result.path === "config set") {
937
+ if (result.positional[0] === "pointers.apiKey") {
938
+ if (result.positional[1] !== "-")
939
+ syntax("Set pointers.apiKey using '-' and piped stdin; never put the key in command-line arguments.");
940
+ }
941
+ else
942
+ parseValue(configKey(result.positional[0]), result.positional[1], true);
943
+ }
657
944
  }
658
945
  if (typeof result.options.limit === "string")
659
946
  parseValue("history.limit", result.options.limit, true);
@@ -682,19 +969,231 @@ async function performCli(argv, io, env) {
682
969
  syntax("Non-interactive history remove requires --yes.");
683
970
  const builtins = await builtinContent();
684
971
  state = new State(stateLocation(parsed.flags, env).path, builtins.pins);
685
- const items = effectiveConfig(state.config(), parsed.flags, env);
972
+ if (parsed.path === "config reset" &&
973
+ parsed.positional[0] === "store.rpc") {
974
+ state.resetConfig("store.rpc");
975
+ io.out(parsed.flags.json
976
+ ? JSON.stringify({ reset: ["store.rpc"] })
977
+ : "Removed legacy store.rpc configuration. Existing Kubo pins and content are unchanged.");
978
+ return 0;
979
+ }
980
+ const items = effectiveConfig(state.config(), parsed.flags, env, (reference) => state.resolveSwarm(reference));
686
981
  const value = (key) => items.find((item) => item.key === key).value;
687
982
  const emit = (result, human) => {
688
983
  io.out(parsed.flags.json ? JSON.stringify(result) : human);
689
984
  };
690
985
  const [first, second] = parsed.positional;
986
+ const selectedSwarm = value("swarm.default") === null
987
+ ? undefined
988
+ : String(value("swarm.default"));
989
+ const swarmContext = () => ({
990
+ store: store,
991
+ state: state,
992
+ env,
993
+ stateDir: stateLocation(parsed.flags, env).path,
994
+ provider: String(value("swarm.provider") ?? "http://127.0.0.1:5001"),
995
+ cacheTtl: Number(value("swarm.cacheTtl")),
996
+ forceRefresh: parsed.options.force
997
+ ? true
998
+ : parsed.options["no-force"]
999
+ ? false
1000
+ : Boolean(value("swarm.forceRefresh")),
1001
+ diagnostic: (text) => {
1002
+ io.err(text);
1003
+ },
1004
+ ...(typeof value("pointers.service") === "string"
1005
+ ? { pointerService: String(value("pointers.service")) }
1006
+ : {}),
1007
+ ...(typeof value("pointers.apiKey") === "string"
1008
+ ? { pointerApiKey: String(value("pointers.apiKey")) }
1009
+ : {}),
1010
+ });
691
1011
  const filter = parsed.path.startsWith("history ")
692
1012
  ? filters(state, parsed.options)
693
1013
  : {};
1014
+ const selection = () => {
1015
+ const current = effectiveConfig(state.config(), parsed.flags, env, (reference) => state.resolveSwarm(reference)).find((item) => item.key === "swarm.default");
1016
+ return {
1017
+ savedCurrent: state.config()["swarm.default"] ?? null,
1018
+ effectiveCurrent: current.value,
1019
+ source: current.source,
1020
+ };
1021
+ };
694
1022
  switch (parsed.path) {
1023
+ case "swarm list": {
1024
+ const result = { swarms: state.swarms(), ...selection() };
1025
+ emit(result, [
1026
+ ...result.swarms.map((entry) => `${entry.cid === result.savedCurrent ? "*" : " "} ${printable(entry.alias ?? entry.cid)} ${entry.cid}`),
1027
+ `Saved current: ${result.savedCurrent ?? "(none)"}`,
1028
+ `Effective current: ${result.effectiveCurrent ?? "(none)"} (${result.source})`,
1029
+ ].join("\n"));
1030
+ break;
1031
+ }
1032
+ case "swarm use": {
1033
+ state.useSwarm(first);
1034
+ const result = selection();
1035
+ emit(result, `Saved current swarm: ${result.savedCurrent}`);
1036
+ if (result.source === "flag" || result.source === "env")
1037
+ io.err(`The saved default is overridden by ${result.source}: ${result.effectiveCurrent}.`);
1038
+ break;
1039
+ }
1040
+ case "swarm remove": {
1041
+ const removed = state.removeSwarm(first);
1042
+ emit({ removed, savedCurrent: state.config()["swarm.default"] ?? null }, `Removed registration ${removed}. Credentials, content and remote membership are unchanged.`);
1043
+ break;
1044
+ }
1045
+ case "swarm add":
1046
+ case "swarm update":
1047
+ case "search":
1048
+ case "swarm create":
1049
+ case "swarm request":
1050
+ case "swarm approve":
1051
+ case "swarm join":
1052
+ case "swarm status":
1053
+ case "publish":
1054
+ case "get": {
1055
+ store = new IpfsStore(await storeConfiguration(value("store.gateway")));
1056
+ const context = swarmContext();
1057
+ if (parsed.path === "swarm update") {
1058
+ const cid = first ? state.resolveSwarm(first) : selectedSwarm;
1059
+ if (!cid)
1060
+ syntax("swarm update requires a registered alias, Swarm CID or current swarm.");
1061
+ const result = await updateSwarm(context, cid, {
1062
+ ...(typeof parsed.options.name === "string"
1063
+ ? { name: parsed.options.name }
1064
+ : {}),
1065
+ ...(typeof parsed.options.description === "string"
1066
+ ? { description: parsed.options.description }
1067
+ : {}),
1068
+ });
1069
+ emit(result, `Swarm: ${result.cid}\nName: ${printable(result.properties.name)}\nDescription: ${printable(result.properties.description)}\nHEAD: ${result.root}\nRevision: ${result.revision}`);
1070
+ break;
1071
+ }
1072
+ if (parsed.path === "swarm add") {
1073
+ const cid = exactCid(first);
1074
+ await addSwarm(context, cid, typeof parsed.options.alias === "string"
1075
+ ? parsed.options.alias
1076
+ : undefined);
1077
+ const entry = state.registeredSwarm(cid);
1078
+ emit({ ...entry, savedCurrent: state.config()["swarm.default"] ?? null }, `Registered swarm ${entry.alias ?? cid} (${cid}).`);
1079
+ break;
1080
+ }
1081
+ if (parsed.path === "search") {
1082
+ const source = items.find((item) => item.key === "swarm.default").source;
1083
+ const limited = parsed.options.current || source === "flag";
1084
+ if (limited && !selectedSwarm)
1085
+ syntax("Search of the current swarm requires --swarm or swarm.default.");
1086
+ const registrations = state.swarms();
1087
+ const scope = limited
1088
+ ? [
1089
+ {
1090
+ cid: selectedSwarm,
1091
+ alias: registrations.find((entry) => entry.cid === selectedSwarm)
1092
+ ?.alias ?? null,
1093
+ },
1094
+ ]
1095
+ : registrations;
1096
+ const result = await searchNames(context, first, scope);
1097
+ emit(result, result.matches.length
1098
+ ? result.matches
1099
+ .map((match) => `${printable(match.alias ?? match.swarm)} ${printable(match.name)} ${match.targetCid}\n ipab get ${printable(match.reference)}`)
1100
+ .join("\n")
1101
+ : "No matching Names.");
1102
+ break;
1103
+ }
1104
+ if (parsed.path === "swarm status") {
1105
+ const cid = first ? state.resolveSwarm(first) : selectedSwarm;
1106
+ if (!cid)
1107
+ syntax("swarm status requires a Swarm CID or swarm.default.");
1108
+ const data = await descriptor(store, cid);
1109
+ const { head, snapshot } = await swarmHeader(context, cid, true);
1110
+ emit({
1111
+ cid,
1112
+ ...data,
1113
+ root: head.root,
1114
+ revision: head.revision,
1115
+ properties: snapshot.properties,
1116
+ }, `Swarm: ${cid}\nName: ${printable(snapshot.properties.name)}\nDescription: ${printable(snapshot.properties.description)}\nHEAD: ${head.root}\nRevision: ${head.revision}`);
1117
+ break;
1118
+ }
1119
+ if (parsed.path === "get") {
1120
+ const selected = await resolveReference(context, first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw));
1121
+ const directory = await getBundle(store, selected.cid, typeof parsed.options.output === "string"
1122
+ ? parsed.options.output
1123
+ : undefined);
1124
+ emit({ ...selected, directory }, `CID: ${selected.cid}\nTarget CID: ${selected.targetCid}\nDirectory: ${directory}`);
1125
+ break;
1126
+ }
1127
+ let cid;
1128
+ if (parsed.path === "swarm create") {
1129
+ cid = await createSwarm(context, {
1130
+ ...(typeof parsed.options.service === "string"
1131
+ ? { service: parsed.options.service }
1132
+ : {}),
1133
+ ...(typeof parsed.options.resume === "string"
1134
+ ? { resume: parsed.options.resume }
1135
+ : {}),
1136
+ properties: {
1137
+ name: String(parsed.options.name ?? ""),
1138
+ description: String(parsed.options.description ?? ""),
1139
+ },
1140
+ ...(typeof parsed.options.alias === "string"
1141
+ ? { alias: parsed.options.alias }
1142
+ : {}),
1143
+ });
1144
+ }
1145
+ else if (parsed.path === "swarm request")
1146
+ cid = await requestMembership(context, exactCid(first));
1147
+ else if (parsed.path === "swarm approve") {
1148
+ if (!parsed.options.yes &&
1149
+ (!io.tty ||
1150
+ !(await io.confirm(`Approve membership request ${first}? This grants swarm HEAD read/write access.`))))
1151
+ throw new HostError("Approval requires explicit --yes or interactive confirmation.");
1152
+ cid = await approveMembership(context, exactCid(first), parsed.options["expires-in"] === undefined
1153
+ ? undefined
1154
+ : Number(parsed.options["expires-in"]));
1155
+ }
1156
+ else if (parsed.path === "swarm join")
1157
+ cid = await joinSwarm(context, exactCid(first), typeof parsed.options.alias === "string"
1158
+ ? parsed.options.alias
1159
+ : undefined);
1160
+ else {
1161
+ let content;
1162
+ if (first.toLowerCase().endsWith(".car"))
1163
+ content = (await importBundle(first, () => Promise.resolve(store))).cid;
1164
+ else
1165
+ content = exactCid(first);
1166
+ cid = await publish(context, content, {
1167
+ ...(selectedSwarm ? { swarm: selectedSwarm } : {}),
1168
+ ...(typeof parsed.options.name === "string"
1169
+ ? { name: parsed.options.name }
1170
+ : {}),
1171
+ ...(typeof parsed.options.expect === "string"
1172
+ ? { expect: parsed.options.expect }
1173
+ : {}),
1174
+ snapshot: Boolean(parsed.options.snapshot),
1175
+ });
1176
+ }
1177
+ if (parsed.path === "swarm create" || parsed.path === "swarm join")
1178
+ io.err(`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config()["swarm.default"] ?? "(none)"}.`);
1179
+ emit({ cid }, cid);
1180
+ break;
1181
+ }
1182
+ case "store usage":
1183
+ case "store gc": {
1184
+ store = new IpfsStore(await storeConfiguration(value("store.gateway")));
1185
+ if (parsed.path === "store usage") {
1186
+ const result = await store.usage();
1187
+ emit(result, `Cached blocks: ${storageBytes(result.cachedBytes)}\nPinned blocks (deduplicated): ${storageBytes(result.pinnedBytes)}`);
1188
+ }
1189
+ else {
1190
+ const result = await store.gc();
1191
+ emit(result, `Removed ${result.removedBlocks} blocks; reclaimed ${storageBytes(result.reclaimedBytes)}.`);
1192
+ }
1193
+ break;
1194
+ }
695
1195
  case "init":
696
1196
  case "build":
697
- case "bundle init":
698
1197
  case "bundle build":
699
1198
  case "bundle inspect":
700
1199
  case "bundle import": {
@@ -713,7 +1212,7 @@ async function performCli(argv, io, env) {
713
1212
  try {
714
1213
  let pendingStore;
715
1214
  const getStore = () => {
716
- pendingStore ??= storeConfiguration(value("store.rpc")).then((configuration) => {
1215
+ pendingStore ??= storeConfiguration(value("store.gateway")).then((configuration) => {
717
1216
  store = new IpfsStore(configuration);
718
1217
  return store;
719
1218
  });
@@ -738,7 +1237,7 @@ async function performCli(argv, io, env) {
738
1237
  : first;
739
1238
  if (parsed.path === "bundle build" || parsed.path === "build")
740
1239
  io.err(parsed.path === "build"
741
- ? "Typechecking, bundling and building App..."
1240
+ ? "Assembling and validating Bundle (no compilation)..."
742
1241
  : "Validating and building bundle...");
743
1242
  if (parsed.path === "bundle import")
744
1243
  io.err("Validating and importing CAR into Store...");
@@ -759,34 +1258,27 @@ async function performCli(argv, io, env) {
759
1258
  : {}),
760
1259
  })
761
1260
  : parsed.path === "build"
762
- ? await buildApp(first, {
1261
+ ? await assembleBundle(first, {
763
1262
  ...request,
764
1263
  replace: Boolean(parsed.options.replace),
765
- ...(parsed.options["with-source"]
766
- ? { includeSource: true }
767
- : parsed.options["without-source"]
768
- ? { includeSource: false }
769
- : {}),
770
1264
  ...(typeof parsed.options.output === "string"
771
1265
  ? { output: parsed.options.output }
772
1266
  : {}),
773
1267
  outputDir: String(value("bundle.outputDir")),
774
1268
  })
775
- : parsed.path === "bundle init"
776
- ? await initBundle(source, second, request)
777
- : parsed.path === "bundle build"
778
- ? await buildBundle(source, {
779
- ...request,
780
- schemaOnly: Boolean(parsed.options["schema-only"]),
781
- replace: Boolean(parsed.options.replace),
782
- ...(typeof parsed.options.output === "string"
783
- ? { output: parsed.options.output }
784
- : {}),
785
- outputDir: String(value("bundle.outputDir")),
786
- })
787
- : parsed.path === "bundle import"
788
- ? await importBundle(first, getStore, request)
789
- : await inspectBundle(source, request);
1269
+ : parsed.path === "bundle build"
1270
+ ? await buildBundle(source, {
1271
+ ...request,
1272
+ schemaOnly: Boolean(parsed.options["schema-only"]),
1273
+ replace: Boolean(parsed.options.replace),
1274
+ ...(typeof parsed.options.output === "string"
1275
+ ? { output: parsed.options.output }
1276
+ : {}),
1277
+ outputDir: String(value("bundle.outputDir")),
1278
+ })
1279
+ : parsed.path === "bundle import"
1280
+ ? await importBundle(first, getStore, request)
1281
+ : await inspectBundle(source, request);
790
1282
  const importing = "output" in result && !parsed.options["no-import"];
791
1283
  if (importing) {
792
1284
  io.err("Importing build result into Store (without pinning)...");
@@ -804,19 +1296,20 @@ async function performCli(argv, io, env) {
804
1296
  state = undefined;
805
1297
  controller.signal.throwIfAborted();
806
1298
  if ("output" in result)
807
- emit({ ...result, imported: importing }, `CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${"source" in result ? `\nSource CID: ${result.source.cid}\nSource CAR: ${result.source.output} (not imported or pinned)` : ""}\nStore: ${importing ? "imported (not pinned)" : "not imported (--no-import)"}`);
1299
+ emit({ ...result, imported: importing }, `CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${result.validation !== undefined ? `\nEntry validation: ${result.validation?.status ?? "not-applicable"}` : ""}\nStore: ${importing ? "imported (not pinned)" : "not imported (--no-import)"}`);
808
1300
  else if (result.kind === "bundle-import")
809
- emit(result, `Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}`);
810
- else if (result.kind === "app-init") {
811
- emit(result, `Created App project: ${result.directory}\nSchema CID: ${result.schemaCid}`);
812
- io.err(`Next: install declared dependencies in ${JSON.stringify(result.directory)}; then ipab build ${JSON.stringify(result.directory)} (requires locally linked ipab).`);
813
- }
814
- else if ("directory" in result) {
815
- emit(result, `Created: ${result.directory}\nSchema CID: ${result.schemaCid}\nEntry: ${result.entry.path} (${result.entry.contentType})`);
816
- io.err(`Next: ipab bundle build ${JSON.stringify(result.directory)}`);
1301
+ emit(result, `Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}\nEntry validation: ${result.validation?.status ?? "not-applicable"}`);
1302
+ else if (result.kind === "project-init") {
1303
+ emit(result, `Created project: ${result.directory}${result.templateCid ? `\nTemplate CID: ${result.templateCid}` : ""}`);
1304
+ if (result.files.includes("package.json") &&
1305
+ (result.files.includes("ipab.yaml") ||
1306
+ result.files.includes("ipab.json")))
1307
+ io.err(`Next: install declared dependencies and explicitly link the candidate @ipab/cli as a project dependency in ${JSON.stringify(result.directory)}; run pnpm build to prepare and package the App. Root ipab build does not compile.`);
1308
+ else if (result.files.includes(".bundle.yaml"))
1309
+ io.err(`Next: ipab bundle build ${JSON.stringify(result.directory)}`);
817
1310
  }
818
1311
  else
819
- emit(result, `Kind: ${result.kind}\nName: ${printable(result.name)}\nSchema CID: ${result.schemaCid}\nEntry: ${result.entry.path} (${result.entry.contentType})\nValidation: passed`);
1312
+ emit(result, `Kind: ${result.kind}\nName: ${printable(result.name)}\nSchema CID: ${result.schemaCid}\nEntry: ${result.entry.path} (${result.entry.contentType})\nDefinition validation: passed\nStorage verification: ${result.validation.storage}\nEntry validation: ${result.validation.entry?.status ?? "not-applicable"}`);
820
1313
  }
821
1314
  catch (cause) {
822
1315
  if (cancelled)
@@ -830,44 +1323,42 @@ async function performCli(argv, io, env) {
830
1323
  break;
831
1324
  }
832
1325
  case "pin list": {
833
- if (typeof parsed.options.type === "string") {
834
- const named = state.pin(parsed.options.type);
835
- if (named && pinDetails(named).kind !== "schema")
836
- throw new HostError("--type short names must identify a Schema pin.");
837
- }
838
1326
  const type = typeof parsed.options.type === "string"
839
- ? state.resolve(schemaAlias(parsed.options.type), true)
1327
+ ? state.resolve(parsed.options.type, true)
840
1328
  : undefined;
841
1329
  const pins = state.pins();
842
1330
  const listed = pins
843
- .filter((pin) => pin.status === "ready")
1331
+ .filter((pin) => pin.status === "ready" && pin.metadata?.kind === "bundle")
844
1332
  .map(pinDetails)
845
- .filter((pin) => (!parsed.options.kind || pin.kind === parsed.options.kind) &&
846
- (type === undefined || pin.schemaCid === type));
1333
+ .filter((pin) => type === undefined || pin.schemaCid === type);
1334
+ const invalid = pins
1335
+ .filter((pin) => pin.status === "ready" && pin.metadata?.kind !== "bundle")
1336
+ .map(({ name, cid, metadata }) => ({
1337
+ name,
1338
+ cid,
1339
+ kind: metadata?.kind,
1340
+ reason: "Not a Bundle pin; retention is preserved. Use pin delete to release it.",
1341
+ }));
847
1342
  const pending = pins
848
1343
  .filter((pin) => pin.status !== "ready")
849
1344
  .map(({ name, cid, status }) => ({ name, cid, status }));
850
- const legacyAliases = state.aliases();
851
1345
  if (pending.length)
852
1346
  io.err(`Unfinished pin operations (not usable pins): ${JSON.stringify(pending)}. Retry pin add/delete.`);
853
- if (legacyAliases.length)
854
- io.err("Legacy Alias metadata is preserved but is not pinned. Use the listed exact CIDs with pin add to migrate.");
855
- emit({ items: listed, pending, legacyAliases }, table(["NAME", "CID", "KIND", "BUNDLE TYPE", "SOURCE"], listed.map((pin) => [
1347
+ if (invalid.length)
1348
+ io.err(`Legacy non-Bundle pins (not usable pins): ${JSON.stringify(invalid)}. Retention is unchanged; delete explicitly and wrap content in a Bundle before pinning again.`);
1349
+ emit({ items: listed, pending, invalid }, table(["NAME", "CID", "KIND", "BUNDLE TYPE", "SOURCE"], listed.map((pin) => [
856
1350
  pin.name,
857
1351
  pin.cid,
858
1352
  pin.kind,
859
- pin.typeName ?? "(no Bundle type metadata)",
1353
+ pin.typeName,
860
1354
  pin.builtin ? "built-in (read-only)" : "user",
861
- ]), "No named pins.") +
862
- (legacyAliases.length
863
- ? `\nLegacy Aliases (not pinned):\n${table(["NAME", "CID"], legacyAliases.map((alias) => [alias.name, alias.cid]), "")}`
864
- : ""));
1355
+ ]), "No named pins."));
865
1356
  break;
866
1357
  }
867
1358
  case "pin add": {
868
1359
  io.err("Fetching, verifying and retaining content in Store...");
869
- const result = await addPin(state, first, second, await storeConfiguration(value("store.rpc")));
870
- emit(result, `${result.name} → ${result.cid}\nKind: ${result.kind}\nBundle type: ${printable(result.typeName ?? "(no Bundle type metadata)")}`);
1360
+ const result = await addPin(state, first, second, await storeConfiguration(value("store.gateway")));
1361
+ emit(result, `${result.name} → ${result.cid}\nBundle type: ${printable(result.typeName)}`);
871
1362
  break;
872
1363
  }
873
1364
  case "pin delete": {
@@ -880,7 +1371,7 @@ async function performCli(argv, io, env) {
880
1371
  if (!pin)
881
1372
  throw new HostError(`Pin "${first}" does not exist. Run ipab pin list.`);
882
1373
  const result = pinDetails(pin);
883
- emit(result, `Name: ${printable(result.name)}\nCID: ${result.cid}\nKind: ${result.kind}\nBundle type: ${printable(result.typeName ?? "(no Bundle type metadata)")}${result.schemaCid ? `\nSchema CID: ${result.schemaCid}` : ""}\nSource: ${result.builtin ? "built-in (read-only; content bundled with IPAB)" : "local registration (not live node verification)"}`);
1374
+ emit(result, `Name: ${printable(result.name)}\nCID: ${result.cid}\nBundle type: ${printable(result.typeName)}\nSchema CID: ${result.schemaCid}\nSource: ${result.builtin ? "built-in (read-only; content bundled with IPAB)" : "local registration (not live node verification)"}`);
884
1375
  break;
885
1376
  }
886
1377
  case "pin rename": {
@@ -908,20 +1399,21 @@ async function performCli(argv, io, env) {
908
1399
  break;
909
1400
  }
910
1401
  case "config get": {
911
- const selected = first
912
- ? items.filter((item) => item.key === first)
913
- : items;
1402
+ const selected = (first ? items.filter((item) => item.key === first) : items).map(visibleConfig);
914
1403
  emit({ items: selected }, table(["KEY", "VALUE", "SOURCE"], selected.map((item) => [item.key, String(item.value), item.source]), "No configuration values."));
915
1404
  break;
916
1405
  }
917
1406
  case "config set": {
918
1407
  const key = configKey(first);
919
- const saved = parseValue(key, second, true);
1408
+ const saved = parseValue(key, key === "pointers.apiKey"
1409
+ ? await (io.readSecret ?? processIO.readSecret)()
1410
+ : second, true);
920
1411
  state.setConfig(key, saved);
921
1412
  const source = items.find((item) => item.key === key).source;
922
1413
  if (source === "env" || source === "flag")
923
1414
  io.err(`Warning: saved user value is masked by ${source}.`);
924
- emit({ key, value: saved, source: "user" }, `Saved ${key} = ${printable(String(saved))} (user).`);
1415
+ const display = visibleConfig({ key, value: saved, source: "user" });
1416
+ emit(display, `Saved ${key} = ${printable(String(display.value))} (user).`);
925
1417
  break;
926
1418
  }
927
1419
  case "config reset":
@@ -995,9 +1487,9 @@ async function performCli(argv, io, env) {
995
1487
  case "open": {
996
1488
  if (parsed.options.log && !value("history.enabled"))
997
1489
  throw new HostError("Execution logging requires history.enabled=true.");
998
- const target = state.resolve(first);
999
1490
  await recoverInactive(state);
1000
- store = new IpfsStore(await storeConfiguration(value("store.rpc")));
1491
+ store = new IpfsStore(await storeConfiguration(value("store.gateway")));
1492
+ const target = (await resolveReference(swarmContext(), first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw))).cid;
1001
1493
  let appCid;
1002
1494
  let appArgv;
1003
1495
  if (parsed.path === "open") {