@ipab/cli 0.1.0-rc.5 → 0.1.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -15
- package/dist/app-templates.js +1 -1
- package/dist/app-templates.js.map +1 -1
- package/dist/builtins/skill.ipab.car +0 -0
- package/dist/builtins/template.node.car +0 -0
- package/dist/builtins/template.web-app.car +0 -0
- package/dist/cli.d.ts +3 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +561 -272
- package/dist/cli.js.map +1 -1
- package/dist/content-provider.d.ts +1 -1
- package/dist/content-provider.d.ts.map +1 -1
- package/dist/content-provider.js +4 -3
- package/dist/content-provider.js.map +1 -1
- package/dist/context.d.ts +0 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +0 -10
- package/dist/context.js.map +1 -1
- package/dist/doctor.d.ts +29 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +576 -0
- package/dist/doctor.js.map +1 -0
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +9 -9
- package/dist/identity.js.map +1 -1
- package/dist/ipc.d.ts +1 -2
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +1 -10
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.d.ts +18 -1
- package/dist/kubo-install.d.ts.map +1 -1
- package/dist/kubo-install.js +424 -61
- package/dist/kubo-install.js.map +1 -1
- package/dist/kubo-release.d.ts +19 -0
- package/dist/kubo-release.d.ts.map +1 -1
- package/dist/kubo-release.js +164 -0
- package/dist/kubo-release.js.map +1 -1
- package/dist/kubo.d.ts +1 -0
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +102 -96
- package/dist/kubo.js.map +1 -1
- package/dist/pins.d.ts +15 -17
- package/dist/pins.d.ts.map +1 -1
- package/dist/pins.js +144 -106
- package/dist/pins.js.map +1 -1
- package/dist/publish-source.d.ts +3 -0
- package/dist/publish-source.d.ts.map +1 -0
- package/dist/publish-source.js +85 -0
- package/dist/publish-source.js.map +1 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -3
- package/dist/runtime.js.map +1 -1
- package/dist/state-storage-windows.js +1 -1
- package/dist/state-storage.d.ts +3 -1
- package/dist/state-storage.d.ts.map +1 -1
- package/dist/state-storage.js +38 -7
- package/dist/state-storage.js.map +1 -1
- package/dist/state.d.ts +40 -6
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +208 -82
- package/dist/state.js.map +1 -1
- package/dist/swarm-envelope.d.ts +1 -0
- package/dist/swarm-envelope.d.ts.map +1 -1
- package/dist/swarm-envelope.js +12 -0
- package/dist/swarm-envelope.js.map +1 -1
- package/dist/swarm.d.ts +64 -8
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +858 -106
- package/dist/swarm.js.map +1 -1
- package/package.json +4 -4
- package/src/app-templates.ts +1 -1
- package/src/cli.ts +702 -338
- package/src/content-provider.ts +4 -2
- package/src/context.ts +0 -10
- package/src/doctor.ts +902 -0
- package/src/identity.ts +10 -10
- package/src/ipc.ts +0 -8
- package/src/kubo-install.ts +562 -78
- package/src/kubo-release.ts +213 -0
- package/src/kubo.ts +134 -106
- package/src/pins.ts +188 -126
- package/src/publish-source.ts +103 -0
- package/src/runtime.ts +0 -3
- package/src/state-storage-windows.ts +1 -1
- package/src/state-storage.ts +53 -7
- package/src/state.ts +357 -98
- package/src/swarm-envelope.ts +14 -0
- package/src/swarm.ts +1234 -125
- package/dist/setup.d.ts +0 -8
- package/dist/setup.d.ts.map +0 -1
- package/dist/setup.js +0 -27
- package/dist/setup.js.map +0 -1
- package/src/setup.ts +0 -34
package/dist/cli.js
CHANGED
|
@@ -10,16 +10,17 @@ import { HostError, message, object, syntax } from "./errors.js";
|
|
|
10
10
|
import { filters, listHistory, selectedIds, Ownership, recoverInactive, removeHistory, } from "./history.js";
|
|
11
11
|
import { execute } from "./runtime.js";
|
|
12
12
|
import { validatedBundle } from "./space.js";
|
|
13
|
-
import {
|
|
13
|
+
import { createAssociation, exactCid, State, } from "./state.js";
|
|
14
14
|
import { buildBundle, inspectBundle, importBundle } from "./authoring.js";
|
|
15
15
|
import { initApp } from "./app-authoring.js";
|
|
16
16
|
import { assembleBundle } from "./assembly.js";
|
|
17
17
|
import { getBundle } from "./get.js";
|
|
18
|
-
import {
|
|
18
|
+
import { doctorDevice, doctorText } from "./doctor.js";
|
|
19
19
|
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
20
|
-
import { createSwarm, requestMembership, approveMembership, exportRequest, removeMember, resumeRemoval, updateProfile, verifiedRequest, membershipRequestSummary, swarmHeader, sharedSwarmStatus, addSwarm, updateSwarm, searchNames, formatNameReference, resolveReference, parseNameReference, publish, } from "./swarm.js";
|
|
20
|
+
import { createSwarm, requestMembership, approveMembership, exportRequest, removeMember, resumeRemoval, updateProfile, accountProfile, updateAccountProfile, swarmMembers, verifiedRequest, verifiedRequestStream, membershipRequestSummary, swarmHeader, sharedSwarmStatus, addSwarm, updateSwarm, searchNames, formatNameReference, resolveReference, parseNameReference, formalName, publish, pinNameSubscription, pinReference, swarmRegistrations, swarmAssociation, setSwarmAssociation, removeSwarmAssociation, } from "./swarm.js";
|
|
21
21
|
import { schemaAlias } from "./app-definition.js";
|
|
22
|
-
import {
|
|
22
|
+
import { unpin, pinDetails } from "./pins.js";
|
|
23
|
+
import { publicationSource } from "./publish-source.js";
|
|
23
24
|
import { logFiles } from "./logs.js";
|
|
24
25
|
import { builtinContent } from "./builtins.js";
|
|
25
26
|
import { readSecretStream } from "./config-secret.js";
|
|
@@ -43,19 +44,24 @@ export const processIO = {
|
|
|
43
44
|
columns() {
|
|
44
45
|
return process.stdout.columns;
|
|
45
46
|
},
|
|
47
|
+
requestInput() {
|
|
48
|
+
if (process.stdin.isTTY)
|
|
49
|
+
syntax("Pipe Request JSON into swarm approve - --yes, or pass a Request file.");
|
|
50
|
+
return process.stdin;
|
|
51
|
+
},
|
|
46
52
|
async readSecret() {
|
|
47
53
|
if (process.stdin.isTTY)
|
|
48
54
|
syntax("Pipe the API key through stdin; interactive echo is not permitted.");
|
|
49
55
|
process.stdin.setEncoding("utf8");
|
|
50
56
|
return readSecretStream(process.stdin);
|
|
51
57
|
},
|
|
52
|
-
async confirm(text) {
|
|
58
|
+
async confirm(text, signal) {
|
|
53
59
|
const reader = createInterface({
|
|
54
60
|
input: process.stdin,
|
|
55
61
|
output: process.stderr,
|
|
56
62
|
});
|
|
57
63
|
try {
|
|
58
|
-
return /^(y|yes)$/i.test((await reader.question(`${text} [y/N]
|
|
64
|
+
return /^(y|yes)$/i.test((await reader.question(`${text} [y/N] `, signal ? { signal } : {})).trim());
|
|
59
65
|
}
|
|
60
66
|
finally {
|
|
61
67
|
reader.close();
|
|
@@ -63,23 +69,25 @@ export const processIO = {
|
|
|
63
69
|
},
|
|
64
70
|
};
|
|
65
71
|
const commands = {
|
|
66
|
-
|
|
72
|
+
doctor: "doctor [--fix [--yes]]",
|
|
73
|
+
profile: "profile [--name NAME] [--description TEXT]",
|
|
67
74
|
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
68
|
-
"swarm request": "swarm request CONFIG_URL
|
|
69
|
-
"swarm export": "swarm export
|
|
75
|
+
"swarm request": "swarm request CONFIG_URL [--output FILE] [--alias ALIAS]",
|
|
76
|
+
"swarm export": "swarm export --output FILE",
|
|
70
77
|
"swarm approve": "swarm approve REQUEST_FILE [--again] --yes",
|
|
71
|
-
"swarm exclude": "swarm exclude MEMBER_PUBLIC_KEY
|
|
72
|
-
"swarm resume": "swarm resume
|
|
73
|
-
"swarm profile": "swarm profile
|
|
74
|
-
"swarm status": "swarm status [
|
|
78
|
+
"swarm exclude": "swarm exclude MEMBER_PUBLIC_KEY --yes",
|
|
79
|
+
"swarm resume": "swarm resume",
|
|
80
|
+
"swarm profile": "swarm profile --address MULTIADDR",
|
|
81
|
+
"swarm status": "swarm status [--local]",
|
|
82
|
+
"swarm members": "swarm members",
|
|
75
83
|
"swarm list": "swarm list",
|
|
76
84
|
"swarm add": "swarm add CONFIG_URL [--alias ALIAS]",
|
|
77
85
|
"swarm use": "swarm use URL_OR_ALIAS",
|
|
78
86
|
"swarm remove": "swarm remove URL_OR_ALIAS",
|
|
79
|
-
"swarm update": "swarm update [
|
|
80
|
-
publish: "publish
|
|
87
|
+
"swarm update": "swarm update [--name TEXT] [--description TEXT]",
|
|
88
|
+
publish: "publish NAME SOURCE [--expect OLD_ARTIFACT_CID | --snapshot]",
|
|
81
89
|
get: "get REF [--raw] [--force | --no-force] [-o DIRECTORY]",
|
|
82
|
-
search: "search QUERY [--current] [--force | --no-force]",
|
|
90
|
+
search: "search QUERY [--all | --current] [--force | --no-force]",
|
|
83
91
|
init: "init NAME [DIR] [OPTIONS]",
|
|
84
92
|
build: "build [SOURCE] [OPTIONS]",
|
|
85
93
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
@@ -87,14 +95,13 @@ const commands = {
|
|
|
87
95
|
"bundle import": "bundle import FILE.car",
|
|
88
96
|
exec: "exec [--log] [--force | --no-force] APP [APP_ARGS...]",
|
|
89
97
|
open: "open [--log] [--raw] [--force | --no-force] CONTENT",
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"pin list": "pin list
|
|
93
|
-
"pin show": "pin show
|
|
94
|
-
"
|
|
95
|
-
"register
|
|
96
|
-
"register
|
|
97
|
-
"register remove": "register remove SCHEMA",
|
|
98
|
+
pin: "pin REF",
|
|
99
|
+
unpin: "unpin REF",
|
|
100
|
+
"pin list": "pin list",
|
|
101
|
+
"pin show": "pin show REF",
|
|
102
|
+
"register list": "register list [--swarm URL_OR_ALIAS]...",
|
|
103
|
+
"register set": "register set SCHEMA APP [--swarm URL_OR_ALIAS]... [--replace] [-- TEMPLATE...]",
|
|
104
|
+
"register remove": "register remove SCHEMA [--swarm URL_OR_ALIAS]...",
|
|
98
105
|
"config get": "config get [KEY]",
|
|
99
106
|
"config set": "config set KEY VALUE\n ipab config set pointers.apiKey - < protected-key-file",
|
|
100
107
|
"config reset": "config reset KEY",
|
|
@@ -107,22 +114,48 @@ const commands = {
|
|
|
107
114
|
const groups = {
|
|
108
115
|
swarm: "Create, authorize, select and manage personal swarms",
|
|
109
116
|
bundle: "Create, inspect and import content bundles",
|
|
110
|
-
pin: "Retain
|
|
117
|
+
pin: "Retain an exact CID or follow a shared Swarm Name",
|
|
111
118
|
register: "Associate content types with Apps",
|
|
112
119
|
config: "Manage local configuration",
|
|
113
120
|
store: "Query local storage and collect unreferenced blocks",
|
|
114
121
|
history: "View and remove execution history",
|
|
115
122
|
};
|
|
116
123
|
const commandHelp = {
|
|
117
|
-
|
|
118
|
-
summary: "
|
|
119
|
-
examples: [
|
|
124
|
+
profile: {
|
|
125
|
+
summary: "Read or update your account-wide public name and description",
|
|
126
|
+
examples: [
|
|
127
|
+
"ipab profile",
|
|
128
|
+
'ipab profile --name Wei --description "Developer"',
|
|
129
|
+
'ipab profile --description ""',
|
|
130
|
+
],
|
|
120
131
|
options: [
|
|
121
|
-
"--
|
|
122
|
-
"--
|
|
132
|
+
"--name NAME Replace only your personal name.",
|
|
133
|
+
"--description TEXT Replace only your description; empty text clears it.",
|
|
123
134
|
],
|
|
124
135
|
notes: [
|
|
125
|
-
"
|
|
136
|
+
"Independent of Swarm selection. Reading never creates an identity, persists a profile or activates a node.",
|
|
137
|
+
"An explicit update prepares a missing account identity without starting Kubo.",
|
|
138
|
+
"Updates persist locally first, then synchronize all registered memberships without changing network addresses. Partial failure exits nonzero and reports every result.",
|
|
139
|
+
"Retry the same profile update, or normally activate a failed membership to synchronize the saved profile.",
|
|
140
|
+
"First use preserves unanimous legacy values; conflicting fields require an explicit choice. New memberships adopt this same profile.",
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
doctor: {
|
|
144
|
+
summary: "Inspect device readiness without writes; explicitly authorize safe repairs",
|
|
145
|
+
examples: [
|
|
146
|
+
"ipab doctor",
|
|
147
|
+
"ipab doctor --fix",
|
|
148
|
+
"ipab --json doctor --fix --yes",
|
|
149
|
+
],
|
|
150
|
+
options: [
|
|
151
|
+
"--fix Repair missing components, cache official archives to verify existing Kubo without reinstall, and authorize healthy compatible upgrades within ^0.43.2.",
|
|
152
|
+
"--yes Authorize planned repairs without prompting; requires --fix.",
|
|
153
|
+
],
|
|
154
|
+
notes: [
|
|
155
|
+
"Always checks local state/configuration, managed Kubo, HOME identity, local Swarm registry and compatible updates.",
|
|
156
|
+
"Inspection never creates state, locks, credentials or caches. Official release metadata may be queried; unavailable updates are not claimed current.",
|
|
157
|
+
"Healthy current components are reused without download or confirmation. Fixed protected archive cache is automatic.",
|
|
158
|
+
"Unverified existing Kubo: --fix may download/cache its exact-version official archive for byte comparison only; never execute it to authenticate itself or overwrite a mismatch.",
|
|
126
159
|
"Does not create Swarm repos, start or contact any daemon, deploy services or install login startup.",
|
|
127
160
|
],
|
|
128
161
|
},
|
|
@@ -149,16 +182,20 @@ const commandHelp = {
|
|
|
149
182
|
"swarm request": {
|
|
150
183
|
summary: "Save and export a signed self-contained membership Request",
|
|
151
184
|
examples: [
|
|
152
|
-
"ipab swarm request CONFIG_URL --
|
|
185
|
+
"ipab swarm request CONFIG_URL --alias work",
|
|
186
|
+
"ipab swarm request CONFIG_URL --output request.json --alias work",
|
|
153
187
|
],
|
|
154
188
|
options: [
|
|
155
|
-
"--owner-fingerprint VALUE Verify Owner through a trusted independent channel.",
|
|
156
|
-
"--name NAME Initial public display name.",
|
|
157
189
|
"--alias ALIAS Pre-register the target for lazy onboarding.",
|
|
158
|
-
"--output FILE Export
|
|
190
|
+
"--output FILE Export to a new file instead of stdout; never overwrites.",
|
|
159
191
|
],
|
|
160
192
|
notes: [
|
|
193
|
+
"Verify the printed Owner fingerprint through an independent trusted channel before manually sending the Request file to the Owner.",
|
|
194
|
+
"Without --output, stdout is the signed Request JSON, including in --json mode.",
|
|
195
|
+
"With --output, reports the file on stderr; --json returns file, requestId and ownerFingerprint.",
|
|
196
|
+
"Retries export the exact saved Request without expiry or a new PeerID.",
|
|
161
197
|
"No Invite, Response file, password or Join. Next normal use fetches and decrypts the approved package.",
|
|
198
|
+
"Set your account-wide personal name with ipab profile --name NAME before requesting membership.",
|
|
162
199
|
"If the alias is taken, choose another to keep both Swarms. If you mean to replace only the local registration, run ipab swarm remove ALIAS and retry.",
|
|
163
200
|
],
|
|
164
201
|
},
|
|
@@ -168,14 +205,18 @@ const commandHelp = {
|
|
|
168
205
|
"--yes Explicit approval; required outside a TTY.",
|
|
169
206
|
"--again Explicit fresh approval of an old Request; history is advisory.",
|
|
170
207
|
],
|
|
171
|
-
examples: [
|
|
208
|
+
examples: [
|
|
209
|
+
"ipab swarm approve request.json --yes",
|
|
210
|
+
"ipab swarm approve - --yes < request.json",
|
|
211
|
+
],
|
|
172
212
|
notes: [
|
|
213
|
+
"Use '-' to read Request JSON from stdin (maximum 16 KiB); --yes is required and no confirmation prompt reads stdin.",
|
|
173
214
|
"Creates a public profile and publishes an Owner-signed X25519/AES-GCM package. Exact-ID certificates have no expiry.",
|
|
174
215
|
],
|
|
175
216
|
},
|
|
176
217
|
"swarm export": {
|
|
177
218
|
summary: "Re-export the same persisted Request",
|
|
178
|
-
examples: ["ipab swarm export
|
|
219
|
+
examples: ["ipab --swarm work swarm export --output request.json"],
|
|
179
220
|
},
|
|
180
221
|
"swarm exclude": {
|
|
181
222
|
summary: "Owner removes a member with irreversible HEAD/key rotation",
|
|
@@ -186,13 +227,22 @@ const commandHelp = {
|
|
|
186
227
|
},
|
|
187
228
|
"swarm resume": {
|
|
188
229
|
summary: "Owner resumes an interrupted organization switch",
|
|
189
|
-
examples: ["ipab swarm resume
|
|
230
|
+
examples: ["ipab --swarm work swarm resume"],
|
|
190
231
|
},
|
|
191
232
|
"swarm profile": {
|
|
192
|
-
summary: "
|
|
233
|
+
summary: "Configure only your selected Swarm's LAN/VPN IPv4 TCP address",
|
|
193
234
|
examples: [
|
|
194
|
-
"ipab swarm profile
|
|
195
|
-
|
|
235
|
+
"ipab --swarm work swarm profile --address /ip4/192.168.1.12/tcp/4001/p2p/PEER_ID",
|
|
236
|
+
],
|
|
237
|
+
notes: [
|
|
238
|
+
"Personal name/description are managed only by ipab profile, not this network configuration command.",
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
"swarm members": {
|
|
242
|
+
summary: "List every public member, including the Owner",
|
|
243
|
+
examples: ["ipab --swarm work swarm members", "ipab --json swarm members"],
|
|
244
|
+
notes: [
|
|
245
|
+
"Public HTTP reads only; no local membership, identity creation or node activation. Failed reads fail the command, never omit members.",
|
|
196
246
|
],
|
|
197
247
|
},
|
|
198
248
|
"swarm status": {
|
|
@@ -202,8 +252,8 @@ const commandHelp = {
|
|
|
202
252
|
],
|
|
203
253
|
examples: [
|
|
204
254
|
"ipab swarm status",
|
|
205
|
-
"ipab swarm status
|
|
206
|
-
"ipab swarm status
|
|
255
|
+
"ipab --swarm work swarm status",
|
|
256
|
+
"ipab --swarm work swarm status --local",
|
|
207
257
|
],
|
|
208
258
|
notes: [
|
|
209
259
|
"Always read public configuration, Scope and HEAD, and verify the State. Local content needs no HOME identity or node activation.",
|
|
@@ -239,13 +289,12 @@ const commandHelp = {
|
|
|
239
289
|
},
|
|
240
290
|
"swarm update": {
|
|
241
291
|
summary: "Owner updates public organization information",
|
|
242
|
-
arguments: ["URL_OR_ALIAS Defaults to the effective current swarm."],
|
|
243
292
|
options: [
|
|
244
293
|
"--name TEXT Replace the shared display name; empty text clears it.",
|
|
245
294
|
"--description TEXT Replace the shared description; empty text clears it.",
|
|
246
295
|
],
|
|
247
296
|
examples: [
|
|
248
|
-
'ipab swarm update
|
|
297
|
+
'ipab --swarm work swarm update --name "Team" --description "Shared workspace"',
|
|
249
298
|
'ipab swarm update --description ""',
|
|
250
299
|
],
|
|
251
300
|
notes: [
|
|
@@ -255,37 +304,44 @@ const commandHelp = {
|
|
|
255
304
|
],
|
|
256
305
|
},
|
|
257
306
|
search: {
|
|
258
|
-
summary: "Search formal Names
|
|
307
|
+
summary: "Search formal Names in the current swarm",
|
|
259
308
|
arguments: [
|
|
260
309
|
"QUERY Case-insensitive literal name substring, 1..256 characters.",
|
|
261
310
|
],
|
|
262
311
|
options: [
|
|
263
|
-
"--
|
|
312
|
+
"--all Search all registered swarms; conflicts with --current and --swarm.",
|
|
313
|
+
"--current Explicitly select the default search scope; conflicts with --swarm.",
|
|
264
314
|
"--force Refresh HEAD for every swarm in the search scope.",
|
|
265
315
|
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
266
316
|
],
|
|
267
|
-
examples: [
|
|
317
|
+
examples: [
|
|
318
|
+
"ipab search hello",
|
|
319
|
+
"ipab search hello --all",
|
|
320
|
+
"ipab --swarm work search hello --force",
|
|
321
|
+
],
|
|
268
322
|
notes: [
|
|
269
|
-
"Searches
|
|
270
|
-
"Valid caches use local Names
|
|
323
|
+
"Searches only --swarm or the saved current swarm by default. Use --all to search every registration.",
|
|
324
|
+
"Valid caches use local Names; absent/expired caches refresh. Active Name pins may synchronize content.",
|
|
325
|
+
"Refresh reads public configuration and HEAD; private networking is activated only for missing content.",
|
|
271
326
|
"No matches is success, not a reason to refresh valid caches. Any failed swarm fails the whole search.",
|
|
272
327
|
"Text uses local alias URIs when available; JSON references use full configuration URLs for cross-device sharing.",
|
|
273
328
|
],
|
|
274
329
|
},
|
|
275
330
|
publish: {
|
|
276
|
-
summary: "
|
|
331
|
+
summary: "Protect content locally and publish a shared Swarm Name",
|
|
277
332
|
options: [
|
|
278
|
-
"--name NAME New formal Name; occupied Names fail.",
|
|
279
333
|
"--expect CID Exact old Artifact node, required for iteration.",
|
|
280
334
|
"--snapshot Name ordinary content without an Artifact; initial only.",
|
|
281
335
|
],
|
|
282
336
|
examples: [
|
|
283
|
-
"ipab
|
|
284
|
-
"ipab publish
|
|
285
|
-
"ipab publish
|
|
337
|
+
"ipab --swarm work publish apps/hello app.car",
|
|
338
|
+
"ipab publish apps/hello APP_CID --expect OLD_ARTIFACT_CID",
|
|
339
|
+
"ipab publish notes/readme ./README.md",
|
|
286
340
|
],
|
|
287
341
|
notes: [
|
|
288
|
-
"No
|
|
342
|
+
"SOURCE is an exact Bundle CID, CAR, regular file or directory. No compiler, hooks, install or App execution.",
|
|
343
|
+
"Directories require .bundle.yaml/type, or a package.json source snapshot. Standalone .json/.yaml/.yml/.md/.txt entries get a standard Bundle; other file types require explicit metadata.",
|
|
344
|
+
"Occupied Names require --expect EXACT_OLD_ARTIFACT_CID. Published payloads are local CID pins; unpin CID releases that current protection, not legitimate history holders.",
|
|
289
345
|
"Different-name CAS contention is rebased; same-name edits conflict (exit 3).",
|
|
290
346
|
"Kubo pin confirmation precedes HEAD; it does not prove a remote device is online.",
|
|
291
347
|
],
|
|
@@ -385,7 +441,9 @@ const commandHelp = {
|
|
|
385
441
|
},
|
|
386
442
|
"bundle inspect": {
|
|
387
443
|
summary: "Inspect a Bundle or type definition",
|
|
388
|
-
arguments: [
|
|
444
|
+
arguments: [
|
|
445
|
+
"SOURCE Directory, definition file, CAR, CID or packaged builtin reference.",
|
|
446
|
+
],
|
|
389
447
|
examples: ["ipab bundle inspect note\\dist\\bundle.car"],
|
|
390
448
|
notes: ["Does not execute Apps, import content or create pins."],
|
|
391
449
|
},
|
|
@@ -395,11 +453,11 @@ const commandHelp = {
|
|
|
395
453
|
examples: ["ipab bundle import hello\\dist\\app.car"],
|
|
396
454
|
notes: [
|
|
397
455
|
"Repeated imports are safe; no App execution or daemon startup.",
|
|
398
|
-
"Does not pin or retain content. Use pin
|
|
456
|
+
"Does not pin or retain content. Use pin CID for persistent retention.",
|
|
399
457
|
],
|
|
400
458
|
},
|
|
401
459
|
exec: {
|
|
402
|
-
summary: "Run an App by CID
|
|
460
|
+
summary: "Run an App by exact CID or Swarm IPAB URI",
|
|
403
461
|
arguments: [
|
|
404
462
|
"APP_ARGS Everything after APP is passed verbatim, including --help.",
|
|
405
463
|
],
|
|
@@ -423,7 +481,9 @@ const commandHelp = {
|
|
|
423
481
|
},
|
|
424
482
|
open: {
|
|
425
483
|
summary: "Open content with its registered App",
|
|
426
|
-
arguments: [
|
|
484
|
+
arguments: [
|
|
485
|
+
"CONTENT Bundle CID, packaged builtin reference or Swarm IPAB URI.",
|
|
486
|
+
],
|
|
427
487
|
options: [
|
|
428
488
|
"--log Record stdout/stderr; requires history enabled.",
|
|
429
489
|
"--raw Open the Artifact node rather than its value.",
|
|
@@ -437,86 +497,107 @@ const commandHelp = {
|
|
|
437
497
|
],
|
|
438
498
|
notes: [
|
|
439
499
|
"Requires a saved registration and App support for the exact content type.",
|
|
500
|
+
"Uses only the content URI's Swarm, otherwise --swarm, otherwise swarm.default. A selected Swarm is required.",
|
|
501
|
+
"A registered App's retrieval, compatibility or execution failure never triggers fallback.",
|
|
502
|
+
"Legacy User registrations are inactive and preserved in the state database's legacy_user_registrations table; review them before explicit Swarm registration.",
|
|
440
503
|
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
441
504
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
442
505
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
443
506
|
"--json is not supported; App stdio is passed through.",
|
|
444
507
|
],
|
|
445
508
|
},
|
|
446
|
-
|
|
447
|
-
summary: "
|
|
509
|
+
pin: {
|
|
510
|
+
summary: "Retain an immutable CID or follow a shared Swarm Name",
|
|
448
511
|
arguments: [
|
|
449
|
-
"
|
|
450
|
-
|
|
512
|
+
"REF Exact Bundle CID or ipab://SWARM/NAME; no local content aliases.",
|
|
513
|
+
],
|
|
514
|
+
examples: [
|
|
515
|
+
"ipab pin APP_CID",
|
|
516
|
+
"ipab pin ipab://work/apps/reader",
|
|
517
|
+
"ipab pin list",
|
|
451
518
|
],
|
|
452
|
-
examples: ["ipab pin add reader APP_CID"],
|
|
453
519
|
notes: [
|
|
454
520
|
"Validates a complete Bundle and retains its full DAG in the configured Store.",
|
|
455
|
-
"
|
|
521
|
+
"A CID stays fixed. A shared Name saves its canonical configuration URL and exact Name, refreshing on related Swarm HEAD reads/sync, not continuously.",
|
|
522
|
+
"New content is verified and retained before the previous subscription version is released. Failures keep the last good version marked stale; deleted Names keep it marked missing.",
|
|
523
|
+
"Does not execute Apps or install dependencies. Shared Names connect to their Swarm content source only as needed.",
|
|
456
524
|
"The builtin namespace is read-only.",
|
|
457
525
|
],
|
|
458
526
|
},
|
|
459
|
-
|
|
460
|
-
summary: "
|
|
461
|
-
examples: ["ipab
|
|
527
|
+
unpin: {
|
|
528
|
+
summary: "Release a CID pin or stop following a shared Name",
|
|
529
|
+
examples: ["ipab unpin APP_CID", "ipab unpin ipab://work/apps/reader"],
|
|
462
530
|
notes: [
|
|
463
531
|
"Releases only this pin's ownership on its original backend; no block deletion or GC.",
|
|
464
|
-
"
|
|
532
|
+
"Never re-resolves a shared Name to release content. Uses only saved actual roots. Missing pins are success.",
|
|
533
|
+
"Exact CID also releases archived legacy named-pin holders for that CID. Does not change shared Names, registrations or history. Built-ins are read-only.",
|
|
534
|
+
"Publication/history owners are independent; --snapshot payloads remain recursively retained by publication history after ordinary unpin.",
|
|
465
535
|
],
|
|
466
536
|
},
|
|
467
537
|
"pin list": {
|
|
468
|
-
summary: "List
|
|
469
|
-
|
|
470
|
-
"--type TYPE Exact type CID or the name of a Bundle pin of that type.",
|
|
471
|
-
],
|
|
472
|
-
examples: ["ipab pin list", "ipab pin list --type reader"],
|
|
538
|
+
summary: "List local retention, following Names and packaged built-ins",
|
|
539
|
+
examples: ["ipab pin list"],
|
|
473
540
|
notes: [
|
|
474
|
-
"
|
|
475
|
-
"Legacy retention is preserved; use
|
|
541
|
+
"Includes pending/stale/missing records and inactive archived local pin names.",
|
|
542
|
+
"Legacy retention is preserved; use unpin EXACT_CID to explicitly release its archived holders.",
|
|
476
543
|
"Reads local registrations and packaged built-ins, not live node status.",
|
|
477
544
|
],
|
|
478
545
|
},
|
|
479
546
|
"pin show": {
|
|
480
|
-
summary: "Show
|
|
481
|
-
examples: ["ipab pin show
|
|
547
|
+
summary: "Show saved retention and following status",
|
|
548
|
+
examples: ["ipab pin show APP_CID", "ipab pin show builtin:template.node"],
|
|
482
549
|
notes: [
|
|
483
550
|
"Reads local metadata; built-in pins do not claim user Store retention.",
|
|
484
551
|
],
|
|
485
552
|
},
|
|
486
|
-
"pin rename": {
|
|
487
|
-
summary: "Rename a user pin without changing its content",
|
|
488
|
-
examples: ["ipab pin rename reader my-reader"],
|
|
489
|
-
notes: [
|
|
490
|
-
"NEW_NAME must be unused. Built-in pins are read-only.",
|
|
491
|
-
"CID, ownership, registrations and history are unchanged.",
|
|
492
|
-
],
|
|
493
|
-
},
|
|
494
553
|
"register list": {
|
|
495
554
|
summary: "List saved content-type associations",
|
|
496
|
-
|
|
555
|
+
options: [
|
|
556
|
+
"--swarm URL_OR_ALIAS Read this Swarm registry; repeat for multiple Swarms.",
|
|
557
|
+
],
|
|
558
|
+
examples: ["ipab register list", "ipab register list --swarm work"],
|
|
559
|
+
notes: [
|
|
560
|
+
"Without explicit --swarm, reads the saved default Swarm. Select one with --swarm or ipab swarm use.",
|
|
561
|
+
"Legacy User registrations are inactive and preserved in legacy_user_registrations; no automatic upload or deletion.",
|
|
562
|
+
],
|
|
497
563
|
},
|
|
498
564
|
"register set": {
|
|
499
565
|
summary: "Associate a content type with an App",
|
|
500
566
|
arguments: [
|
|
501
567
|
"SCHEMA Exact type CID or builtin:node-app.v1.",
|
|
502
|
-
"APP App CID or
|
|
568
|
+
"APP App CID or Swarm IPAB URI; the exact CID is saved.",
|
|
503
569
|
"TEMPLATE App argv after --; must contain a whole argument % (default: %).",
|
|
504
570
|
],
|
|
505
|
-
options: [
|
|
571
|
+
options: [
|
|
572
|
+
"--replace Allow changing an existing association.",
|
|
573
|
+
"--swarm URL_OR_ALIAS Write this Swarm registry; repeat for multiple Swarms.",
|
|
574
|
+
],
|
|
506
575
|
examples: [
|
|
507
576
|
"ipab register set SCHEMA_CID reader",
|
|
508
577
|
"ipab register set SCHEMA_CID reader '--' '--cid' '%'",
|
|
578
|
+
"ipab register set SCHEMA_CID ipab:///apps/reader --swarm work --swarm team",
|
|
509
579
|
],
|
|
510
580
|
notes: [
|
|
511
581
|
"Replaces only the whole % argument with the content CID; no shell expansion.",
|
|
512
582
|
"Does not verify App type support; open checks it before execution.",
|
|
583
|
+
"Without explicit --swarm, writes the saved default Swarm. Swarm writes require HEAD write access.",
|
|
584
|
+
"Multiple Swarms commit sequentially, not atomically; failures report completed targets.",
|
|
513
585
|
],
|
|
514
586
|
},
|
|
515
587
|
"register remove": {
|
|
516
588
|
summary: "Remove a saved content-type association",
|
|
517
589
|
arguments: ["SCHEMA Exact type CID or builtin:node-app.v1."],
|
|
518
|
-
|
|
519
|
-
|
|
590
|
+
options: [
|
|
591
|
+
"--swarm URL_OR_ALIAS Remove from this Swarm registry; repeat for multiple Swarms.",
|
|
592
|
+
],
|
|
593
|
+
examples: [
|
|
594
|
+
"ipab register remove SCHEMA_CID",
|
|
595
|
+
"ipab register remove SCHEMA_CID --swarm work",
|
|
596
|
+
],
|
|
597
|
+
notes: [
|
|
598
|
+
"Without explicit --swarm, removes from the saved default Swarm. Multiple Swarm edits are not atomic.",
|
|
599
|
+
"Does not remove Apps, pins or content.",
|
|
600
|
+
],
|
|
520
601
|
},
|
|
521
602
|
"config get": {
|
|
522
603
|
summary: "Show effective configuration",
|
|
@@ -544,7 +625,7 @@ const commandHelp = {
|
|
|
544
625
|
"history list": {
|
|
545
626
|
summary: "List execution history",
|
|
546
627
|
options: [
|
|
547
|
-
"--app APP Filter by App CID
|
|
628
|
+
"--app APP Filter by exact App CID.",
|
|
548
629
|
"--status STATUS succeeded, failed or cancelled.",
|
|
549
630
|
"--since TIME Include runs ended at or after TIME.",
|
|
550
631
|
"--until TIME Include runs ended before TIME.",
|
|
@@ -567,7 +648,7 @@ const commandHelp = {
|
|
|
567
648
|
"history remove": {
|
|
568
649
|
summary: "Remove execution records and their logs",
|
|
569
650
|
options: [
|
|
570
|
-
"--app APP Filter by App CID
|
|
651
|
+
"--app APP Filter by exact App CID.",
|
|
571
652
|
"--status STATUS succeeded, failed or cancelled.",
|
|
572
653
|
"--since TIME Include runs ended at or after TIME.",
|
|
573
654
|
"--until TIME Include runs ended before TIME.",
|
|
@@ -606,12 +687,14 @@ Create:
|
|
|
606
687
|
bundle ${groups.bundle}
|
|
607
688
|
|
|
608
689
|
Manage:
|
|
609
|
-
|
|
690
|
+
doctor ${commandHelp.doctor.summary}
|
|
691
|
+
profile ${commandHelp.profile.summary}
|
|
610
692
|
swarm ${groups.swarm}
|
|
611
|
-
search Search formal Names
|
|
693
|
+
search Search formal Names in the current swarm
|
|
612
694
|
publish ${commandHelp.publish.summary}
|
|
613
695
|
get ${commandHelp.get.summary}
|
|
614
696
|
pin ${groups.pin}
|
|
697
|
+
unpin ${commandHelp.unpin.summary}
|
|
615
698
|
register ${groups.register}
|
|
616
699
|
config ${groups.config}
|
|
617
700
|
store ${groups.store}
|
|
@@ -633,7 +716,25 @@ ${footer}`;
|
|
|
633
716
|
...(topic.arguments ? [section("Arguments", topic.arguments)] : []),
|
|
634
717
|
...(topic.options ? [section("Options", topic.options)] : []),
|
|
635
718
|
section("Examples", topic.examples),
|
|
636
|
-
...(
|
|
719
|
+
...([
|
|
720
|
+
"swarm status",
|
|
721
|
+
"swarm members",
|
|
722
|
+
"swarm update",
|
|
723
|
+
"swarm resume",
|
|
724
|
+
"swarm profile",
|
|
725
|
+
"swarm export",
|
|
726
|
+
"swarm approve",
|
|
727
|
+
"swarm exclude",
|
|
728
|
+
].includes(path)
|
|
729
|
+
? [
|
|
730
|
+
section("Notes", [
|
|
731
|
+
...(topic.notes ?? []),
|
|
732
|
+
"Select only with global --swarm URL_OR_ALIAS (before the command), or the saved swarm.default. Neither means an error.",
|
|
733
|
+
]),
|
|
734
|
+
]
|
|
735
|
+
: topic.notes
|
|
736
|
+
? [section("Notes", topic.notes)]
|
|
737
|
+
: []),
|
|
637
738
|
`\n\n-h, --help shows this help. Global options: see 'ipab --help'.\n${footer}`,
|
|
638
739
|
].join("");
|
|
639
740
|
}
|
|
@@ -757,6 +858,7 @@ async function closeStore(store, appExitCode) {
|
|
|
757
858
|
export function parse(argv) {
|
|
758
859
|
const tokens = [...argv];
|
|
759
860
|
const flags = { json: false };
|
|
861
|
+
const swarms = [];
|
|
760
862
|
while (tokens[0]?.startsWith("-")) {
|
|
761
863
|
const flag = tokens.shift();
|
|
762
864
|
if (flag === "-h" || flag === "--help")
|
|
@@ -792,8 +894,10 @@ export function parse(argv) {
|
|
|
792
894
|
syntax(`${flag} needs a value.`);
|
|
793
895
|
if (flag === "--state-dir")
|
|
794
896
|
flags.stateDir = value;
|
|
795
|
-
else if (flag === "--swarm")
|
|
897
|
+
else if (flag === "--swarm") {
|
|
796
898
|
flags.swarm = value;
|
|
899
|
+
swarms.push(value);
|
|
900
|
+
}
|
|
797
901
|
else {
|
|
798
902
|
flags.storeGateway = publicUrl(value);
|
|
799
903
|
}
|
|
@@ -809,6 +913,7 @@ export function parse(argv) {
|
|
|
809
913
|
options: {},
|
|
810
914
|
help: !group,
|
|
811
915
|
version: false,
|
|
916
|
+
...(group === "register" ? { registrySwarms: swarms } : {}),
|
|
812
917
|
};
|
|
813
918
|
if (!group)
|
|
814
919
|
return result;
|
|
@@ -832,7 +937,17 @@ export function parse(argv) {
|
|
|
832
937
|
result.positional = tokens;
|
|
833
938
|
return result;
|
|
834
939
|
}
|
|
835
|
-
if (![
|
|
940
|
+
if (![
|
|
941
|
+
"open",
|
|
942
|
+
"init",
|
|
943
|
+
"build",
|
|
944
|
+
"publish",
|
|
945
|
+
"get",
|
|
946
|
+
"search",
|
|
947
|
+
"doctor",
|
|
948
|
+
"profile",
|
|
949
|
+
"unpin",
|
|
950
|
+
].includes(group)) {
|
|
836
951
|
if (![
|
|
837
952
|
"bundle",
|
|
838
953
|
"pin",
|
|
@@ -842,12 +957,19 @@ export function parse(argv) {
|
|
|
842
957
|
"store",
|
|
843
958
|
"swarm",
|
|
844
959
|
].includes(group))
|
|
845
|
-
syntax(`Unknown command "${group}"
|
|
846
|
-
if (
|
|
960
|
+
syntax(`Unknown command "${group}".${group === "setup" ? " Run ipab doctor to inspect, or ipab doctor --fix to prepare this device." : " Run ipab --help."}`);
|
|
961
|
+
if (group === "pin" && !["list", "show"].includes(tokens[0] ?? "")) {
|
|
962
|
+
if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
|
|
963
|
+
result.help = true;
|
|
964
|
+
return result;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
else if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
|
|
847
968
|
result.help = true;
|
|
848
969
|
return result;
|
|
849
970
|
}
|
|
850
|
-
|
|
971
|
+
else
|
|
972
|
+
result.path = `${group} ${tokens.shift()}`;
|
|
851
973
|
}
|
|
852
974
|
else if (group === "open" && flags.json)
|
|
853
975
|
syntax("--json is not supported for exec/open.");
|
|
@@ -866,8 +988,8 @@ export function parse(argv) {
|
|
|
866
988
|
tokens.includes("pointers.apiKey") &&
|
|
867
989
|
!(tokens.length === 2 && tokens[1] === "-"))
|
|
868
990
|
syntax("API key must be provided through '-' and piped stdin; never pass it in command arguments.");
|
|
869
|
-
const booleans = result.path === "
|
|
870
|
-
? ["yes"]
|
|
991
|
+
const booleans = result.path === "doctor"
|
|
992
|
+
? ["fix", "yes"]
|
|
871
993
|
: result.path === "bundle build"
|
|
872
994
|
? ["replace", "schema-only", "no-import"]
|
|
873
995
|
: result.path === "build"
|
|
@@ -877,7 +999,7 @@ export function parse(argv) {
|
|
|
877
999
|
: result.path === "get"
|
|
878
1000
|
? ["raw", "force", "no-force"]
|
|
879
1001
|
: result.path === "search"
|
|
880
|
-
? ["current", "force", "no-force"]
|
|
1002
|
+
? ["all", "current", "force", "no-force"]
|
|
881
1003
|
: result.path === "swarm approve"
|
|
882
1004
|
? ["yes", "again"]
|
|
883
1005
|
: result.path === "swarm status"
|
|
@@ -896,17 +1018,17 @@ export function parse(argv) {
|
|
|
896
1018
|
: result.path === "swarm add"
|
|
897
1019
|
? ["alias"]
|
|
898
1020
|
: result.path === "swarm request"
|
|
899
|
-
? ["
|
|
1021
|
+
? ["alias", "output"]
|
|
900
1022
|
: result.path === "swarm export"
|
|
901
1023
|
? ["output"]
|
|
902
1024
|
: result.path === "swarm profile"
|
|
903
|
-
? ["
|
|
904
|
-
: result.path === "swarm update"
|
|
1025
|
+
? ["address"]
|
|
1026
|
+
: result.path === "swarm update" || result.path === "profile"
|
|
905
1027
|
? ["name", "description"]
|
|
906
1028
|
: result.path === "swarm approve"
|
|
907
1029
|
? []
|
|
908
1030
|
: result.path === "publish"
|
|
909
|
-
? ["
|
|
1031
|
+
? ["expect"]
|
|
910
1032
|
: result.path === "get"
|
|
911
1033
|
? ["output"]
|
|
912
1034
|
: result.path === "init"
|
|
@@ -925,11 +1047,7 @@ export function parse(argv) {
|
|
|
925
1047
|
]
|
|
926
1048
|
: result.path === "history remove"
|
|
927
1049
|
? ["app", "status", "since", "until"]
|
|
928
|
-
:
|
|
929
|
-
? ["type"]
|
|
930
|
-
: [];
|
|
931
|
-
if (result.path === "setup")
|
|
932
|
-
values.push("kubo-archive");
|
|
1050
|
+
: [];
|
|
933
1051
|
while (tokens.length) {
|
|
934
1052
|
const value = tokens.shift();
|
|
935
1053
|
if (result.path === "swarm exclude" &&
|
|
@@ -938,6 +1056,14 @@ export function parse(argv) {
|
|
|
938
1056
|
}
|
|
939
1057
|
else if (value.startsWith("--") || value === "-o") {
|
|
940
1058
|
const option = value === "-o" ? "output" : value.slice(2);
|
|
1059
|
+
if (result.path.startsWith("register ") && option === "swarm") {
|
|
1060
|
+
const input = tokens.shift();
|
|
1061
|
+
if (!input || input.startsWith("-"))
|
|
1062
|
+
syntax("--swarm needs a value.");
|
|
1063
|
+
result.registrySwarms.push(input);
|
|
1064
|
+
flags.swarm = input;
|
|
1065
|
+
continue;
|
|
1066
|
+
}
|
|
941
1067
|
if (result.path === "init" && option === "param") {
|
|
942
1068
|
const input = tokens.shift();
|
|
943
1069
|
if (!input || input.startsWith("--") || input.indexOf("=") < 1)
|
|
@@ -953,12 +1079,14 @@ export function parse(argv) {
|
|
|
953
1079
|
const input = tokens.shift();
|
|
954
1080
|
if (input === undefined ||
|
|
955
1081
|
(input.startsWith("--") &&
|
|
956
|
-
!(
|
|
957
|
-
|
|
958
|
-
(input === "" && result.path !== "swarm update"))
|
|
1082
|
+
!(option === "resume" && /^[A-Za-z0-9_-]{43}$/.test(input))) ||
|
|
1083
|
+
(input === "" && !["swarm update", "profile"].includes(result.path)))
|
|
959
1084
|
syntax(`${value} needs a value.`);
|
|
960
1085
|
result.options[option] = input;
|
|
961
1086
|
}
|
|
1087
|
+
else if (option === "name" &&
|
|
1088
|
+
["swarm profile", "swarm request"].includes(result.path))
|
|
1089
|
+
syntax(`Personal names are account-wide. Use ipab profile --name NAME instead.${result.path === "swarm profile" ? " For network configuration, use ipab --swarm URL_OR_ALIAS swarm profile --address MULTIADDR." : ""}`);
|
|
962
1090
|
else
|
|
963
1091
|
syntax(`Unknown option "${value}".`);
|
|
964
1092
|
}
|
|
@@ -971,22 +1099,28 @@ export function parse(argv) {
|
|
|
971
1099
|
result.options.current &&
|
|
972
1100
|
flags.swarm !== undefined)
|
|
973
1101
|
syntax("--current and --swarm are mutually exclusive.");
|
|
1102
|
+
if (result.path === "search" &&
|
|
1103
|
+
result.options.all &&
|
|
1104
|
+
(result.options.current || flags.swarm !== undefined))
|
|
1105
|
+
syntax("--all is mutually exclusive with --current and --swarm.");
|
|
974
1106
|
const counts = {
|
|
975
|
-
|
|
1107
|
+
doctor: [0, 0],
|
|
1108
|
+
profile: [0, 0],
|
|
976
1109
|
"swarm create": [0, 0],
|
|
977
1110
|
"swarm request": [1, 1],
|
|
978
1111
|
"swarm approve": [1, 1],
|
|
979
|
-
"swarm export": [
|
|
1112
|
+
"swarm export": [0, 0],
|
|
980
1113
|
"swarm exclude": [1, 1],
|
|
981
|
-
"swarm resume": [0,
|
|
982
|
-
"swarm profile": [0,
|
|
983
|
-
"swarm status": [0,
|
|
1114
|
+
"swarm resume": [0, 0],
|
|
1115
|
+
"swarm profile": [0, 0],
|
|
1116
|
+
"swarm status": [0, 0],
|
|
1117
|
+
"swarm members": [0, 0],
|
|
984
1118
|
"swarm list": [0, 0],
|
|
985
1119
|
"swarm add": [1, 1],
|
|
986
1120
|
"swarm use": [1, 1],
|
|
987
1121
|
"swarm remove": [1, 1],
|
|
988
|
-
"swarm update": [0,
|
|
989
|
-
publish: [
|
|
1122
|
+
"swarm update": [0, 0],
|
|
1123
|
+
publish: [2, 2],
|
|
990
1124
|
get: [1, 1],
|
|
991
1125
|
search: [1, 1],
|
|
992
1126
|
init: [1, 2],
|
|
@@ -995,11 +1129,10 @@ export function parse(argv) {
|
|
|
995
1129
|
"bundle inspect": [1, 1],
|
|
996
1130
|
"bundle import": [1, 1],
|
|
997
1131
|
open: [1, 1],
|
|
998
|
-
|
|
999
|
-
|
|
1132
|
+
pin: [1, 1],
|
|
1133
|
+
unpin: [1, 1],
|
|
1000
1134
|
"pin list": [0, 0],
|
|
1001
1135
|
"pin show": [1, 1],
|
|
1002
|
-
"pin rename": [2, 2],
|
|
1003
1136
|
"register list": [0, 0],
|
|
1004
1137
|
"register set": [2, 2],
|
|
1005
1138
|
"register remove": [1, 1],
|
|
@@ -1015,6 +1148,18 @@ export function parse(argv) {
|
|
|
1015
1148
|
if (result.options["with-source"] && result.options["without-source"])
|
|
1016
1149
|
syntax("--with-source and --without-source are mutually exclusive.");
|
|
1017
1150
|
const [minimum, maximum] = counts[result.path];
|
|
1151
|
+
if (result.path === "profile" && flags.swarm !== undefined)
|
|
1152
|
+
syntax("Personal profile is account-wide; do not pass --swarm.");
|
|
1153
|
+
if (result.positional.length &&
|
|
1154
|
+
[
|
|
1155
|
+
"swarm status",
|
|
1156
|
+
"swarm update",
|
|
1157
|
+
"swarm resume",
|
|
1158
|
+
"swarm profile",
|
|
1159
|
+
"swarm export",
|
|
1160
|
+
"swarm members",
|
|
1161
|
+
].includes(result.path))
|
|
1162
|
+
syntax(`Swarm target positionals are no longer supported. Use ipab --swarm URL_OR_ALIAS ${result.path} instead.`);
|
|
1018
1163
|
if (result.positional.length < minimum || result.positional.length > maximum)
|
|
1019
1164
|
syntax(`Invalid arguments.\n${help(result.path)}`);
|
|
1020
1165
|
if (result.template &&
|
|
@@ -1027,12 +1172,20 @@ export function parse(argv) {
|
|
|
1027
1172
|
syntax("history remove requires explicit IDs OR filters, not both.");
|
|
1028
1173
|
}
|
|
1029
1174
|
// Validate syntactic values before state access, let alone a backend connection.
|
|
1030
|
-
if (
|
|
1031
|
-
|
|
1032
|
-
if (result.path
|
|
1033
|
-
|
|
1034
|
-
if (result.path === "pin
|
|
1035
|
-
|
|
1175
|
+
if (["pin", "unpin", "pin show"].includes(result.path)) {
|
|
1176
|
+
const reference = result.positional[0];
|
|
1177
|
+
if (reference.startsWith("builtin:") && result.path !== "pin show")
|
|
1178
|
+
syntax("Packaged builtin references are read-only; they cannot be pinned or unpinned.");
|
|
1179
|
+
if (!(result.path === "pin show" && reference.startsWith("builtin:")) &&
|
|
1180
|
+
!parseNameReference(reference))
|
|
1181
|
+
exactCid(reference);
|
|
1182
|
+
}
|
|
1183
|
+
if (result.path === "publish") {
|
|
1184
|
+
formalName(result.positional[0]);
|
|
1185
|
+
if (typeof result.options.expect === "string")
|
|
1186
|
+
exactCid(result.options.expect);
|
|
1187
|
+
if (result.options.expect && result.options.snapshot)
|
|
1188
|
+
syntax("--snapshot is initial-only and cannot be combined with --expect.");
|
|
1036
1189
|
}
|
|
1037
1190
|
if (result.path.startsWith("config ") && result.positional[0]) {
|
|
1038
1191
|
if (!(result.path === "config get" && result.positional[0] === "state-dir") &&
|
|
@@ -1051,6 +1204,8 @@ export function parse(argv) {
|
|
|
1051
1204
|
parseValue("history.limit", result.options.limit, true);
|
|
1052
1205
|
if (result.options.output === "-")
|
|
1053
1206
|
syntax("CAR output requires a file path; binary stdout is not supported.");
|
|
1207
|
+
if (result.path === "doctor" && result.options.yes && !result.options.fix)
|
|
1208
|
+
syntax("doctor --yes requires --fix.");
|
|
1054
1209
|
return result;
|
|
1055
1210
|
}
|
|
1056
1211
|
async function performCli(argv, io, env) {
|
|
@@ -1073,34 +1228,29 @@ async function performCli(argv, io, env) {
|
|
|
1073
1228
|
}
|
|
1074
1229
|
if (parsed.path === "history remove" && !parsed.options.yes && !io.tty)
|
|
1075
1230
|
syntax("Non-interactive history remove requires --yes.");
|
|
1076
|
-
if (parsed.path === "
|
|
1077
|
-
if (!parsed.options.yes &&
|
|
1078
|
-
(!io.tty ||
|
|
1079
|
-
!(await io.confirm("Install checksum-verified Kubo and initialize/reuse the protected HOME identity? No daemon will be contacted or started."))))
|
|
1080
|
-
throw new HostError("Setup requires explicit --yes or interactive confirmation.");
|
|
1231
|
+
if (parsed.path === "doctor") {
|
|
1081
1232
|
const controller = new AbortController();
|
|
1082
1233
|
const interrupt = () => {
|
|
1083
|
-
controller.abort(new HostError("
|
|
1234
|
+
controller.abort(new HostError("Doctor interrupted.", 130, "ABORTED"));
|
|
1084
1235
|
};
|
|
1085
1236
|
const terminate = () => {
|
|
1086
|
-
controller.abort(new HostError("
|
|
1237
|
+
controller.abort(new HostError("Doctor terminated.", 143, "ABORTED"));
|
|
1087
1238
|
};
|
|
1088
1239
|
process.once("SIGINT", interrupt);
|
|
1089
1240
|
process.once("SIGTERM", terminate);
|
|
1090
1241
|
try {
|
|
1091
|
-
const result = await
|
|
1242
|
+
const result = await doctorDevice(stateLocation(parsed.flags, env).path, env, {
|
|
1092
1243
|
diagnostic: (text, progress) => {
|
|
1093
1244
|
io.err(text, progress);
|
|
1094
1245
|
},
|
|
1095
1246
|
signal: controller.signal,
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1247
|
+
fix: Boolean(parsed.options.fix),
|
|
1248
|
+
yes: Boolean(parsed.options.yes),
|
|
1249
|
+
tty: io.tty,
|
|
1250
|
+
confirm: (text, signal) => io.confirm(text, signal),
|
|
1099
1251
|
});
|
|
1100
|
-
io.out(parsed.flags.json
|
|
1101
|
-
|
|
1102
|
-
: `Kubo ${result.kuboVersion}: ${result.binary}\nAccount fingerprint: ${result.fingerprint}\nReady. Nodes start only when a Swarm is used.`);
|
|
1103
|
-
return 0;
|
|
1252
|
+
io.out(parsed.flags.json ? JSON.stringify(result) : doctorText(result));
|
|
1253
|
+
return result.ready ? 0 : 1;
|
|
1104
1254
|
}
|
|
1105
1255
|
finally {
|
|
1106
1256
|
process.removeListener("SIGINT", interrupt);
|
|
@@ -1118,7 +1268,8 @@ async function performCli(argv, io, env) {
|
|
|
1118
1268
|
return 0;
|
|
1119
1269
|
}
|
|
1120
1270
|
const items = effectiveConfig(state.config({
|
|
1121
|
-
includeSecrets:
|
|
1271
|
+
includeSecrets: !["swarm members", "profile", "swarm status"].includes(parsed.path) ||
|
|
1272
|
+
Boolean(parsed.options.local),
|
|
1122
1273
|
}), parsed.flags, env, (reference) => state.resolveSwarm(reference));
|
|
1123
1274
|
const value = (key) => items.find((item) => item.key === key).value;
|
|
1124
1275
|
const emit = (result, human) => {
|
|
@@ -1128,6 +1279,11 @@ async function performCli(argv, io, env) {
|
|
|
1128
1279
|
const selectedSwarm = value("swarm.default") === null
|
|
1129
1280
|
? undefined
|
|
1130
1281
|
: String(value("swarm.default"));
|
|
1282
|
+
const requireSwarm = () => {
|
|
1283
|
+
if (!selectedSwarm)
|
|
1284
|
+
syntax("Select a Swarm with ipab --swarm URL_OR_ALIAS, or save a default with ipab swarm use URL_OR_ALIAS.");
|
|
1285
|
+
return selectedSwarm;
|
|
1286
|
+
};
|
|
1131
1287
|
const swarmContext = () => ({
|
|
1132
1288
|
get store() {
|
|
1133
1289
|
return store;
|
|
@@ -1167,7 +1323,103 @@ async function performCli(argv, io, env) {
|
|
|
1167
1323
|
source: current.source,
|
|
1168
1324
|
};
|
|
1169
1325
|
};
|
|
1326
|
+
if (parsed.path === "open" || parsed.path.startsWith("register ")) {
|
|
1327
|
+
if (state.legacyRegistrationCount)
|
|
1328
|
+
io.err(`Legacy User registrations are inactive. ${state.legacyRegistrationCount} entries are preserved in legacy_user_registrations in the state database under ${state.directory}; nothing was uploaded or deleted. Review the archived values and explicitly run ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS [-- TEMPLATE...] to publish only intended associations.`);
|
|
1329
|
+
}
|
|
1330
|
+
if (state.legacyPinCount)
|
|
1331
|
+
io.err(`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.`);
|
|
1332
|
+
if (parsed.path.startsWith("register ")) {
|
|
1333
|
+
const references = parsed.registrySwarms?.length
|
|
1334
|
+
? parsed.registrySwarms
|
|
1335
|
+
: selectedSwarm
|
|
1336
|
+
? [selectedSwarm]
|
|
1337
|
+
: [];
|
|
1338
|
+
if (!references.length)
|
|
1339
|
+
throw new HostError("Register requires a selected Swarm. Pass --swarm URL_OR_ALIAS (repeat for multiple Swarms), or save a default with ipab swarm use URL_OR_ALIAS.");
|
|
1340
|
+
const targets = [
|
|
1341
|
+
...new Set(references.map((reference) => state.resolveSwarm(reference))),
|
|
1342
|
+
];
|
|
1343
|
+
const schema = first
|
|
1344
|
+
? state.resolve(schemaAlias(first), true)
|
|
1345
|
+
: undefined;
|
|
1346
|
+
const results = [];
|
|
1347
|
+
const completed = [];
|
|
1348
|
+
const human = [];
|
|
1349
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1350
|
+
for (const configUrl of targets) {
|
|
1351
|
+
const context = swarmContext();
|
|
1352
|
+
try {
|
|
1353
|
+
if (parsed.path === "register list") {
|
|
1354
|
+
const items = await swarmRegistrations(context, configUrl);
|
|
1355
|
+
results.push({ items });
|
|
1356
|
+
human.push(`${configUrl}\n${table(["SCHEMA CID", "APP CID", "ARGV"], items.map((item) => [
|
|
1357
|
+
item.schemaCid,
|
|
1358
|
+
item.appCid,
|
|
1359
|
+
JSON.stringify(item.argv),
|
|
1360
|
+
]), "No associations.")}`);
|
|
1361
|
+
}
|
|
1362
|
+
else if (parsed.path === "register set") {
|
|
1363
|
+
const appCid = parseNameReference(second)
|
|
1364
|
+
? (await resolveReference(context, second, configUrl, (reference) => state.resolve(reference))).cid
|
|
1365
|
+
: state.resolve(second);
|
|
1366
|
+
const association = await setSwarmAssociation(context, configUrl, createAssociation(schema, appCid, parsed.template ?? ["%"]), Boolean(parsed.options.replace));
|
|
1367
|
+
results.push({ association });
|
|
1368
|
+
human.push(`${configUrl}: ${association.schemaCid} → ${association.appCid} ${JSON.stringify(association.argv)}`);
|
|
1369
|
+
}
|
|
1370
|
+
else {
|
|
1371
|
+
const removed = await removeSwarmAssociation(context, configUrl, schema);
|
|
1372
|
+
results.push({ removed: [removed] });
|
|
1373
|
+
human.push(`${configUrl}: removed association for ${removed}.`);
|
|
1374
|
+
}
|
|
1375
|
+
completed.push(configUrl);
|
|
1376
|
+
}
|
|
1377
|
+
catch (cause) {
|
|
1378
|
+
throw new HostError(`Registry operation failed for ${configUrl}: ${message(cause)}. Completed Swarms: ${completed.length ? completed.join(", ") : "(none)"}. Multiple Swarm edits are not atomic.`, cause instanceof HostError ? cause.exitCode : 1, cause instanceof HostError ? cause.code : "REGISTRY_FAILED", "publication");
|
|
1379
|
+
}
|
|
1380
|
+
finally {
|
|
1381
|
+
await context.finishRead?.();
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
emit({
|
|
1385
|
+
swarms: results.map((result, index) => ({
|
|
1386
|
+
configUrl: targets[index],
|
|
1387
|
+
...result,
|
|
1388
|
+
})),
|
|
1389
|
+
}, human.join("\n\n"));
|
|
1390
|
+
return 0;
|
|
1391
|
+
}
|
|
1170
1392
|
switch (parsed.path) {
|
|
1393
|
+
case "profile": {
|
|
1394
|
+
const context = swarmContext();
|
|
1395
|
+
readContext = context;
|
|
1396
|
+
const changes = {
|
|
1397
|
+
...(typeof parsed.options.name === "string"
|
|
1398
|
+
? { name: parsed.options.name }
|
|
1399
|
+
: {}),
|
|
1400
|
+
...(typeof parsed.options.description === "string"
|
|
1401
|
+
? { description: parsed.options.description }
|
|
1402
|
+
: {}),
|
|
1403
|
+
};
|
|
1404
|
+
if (!Object.keys(changes).length) {
|
|
1405
|
+
const profile = await accountProfile(context);
|
|
1406
|
+
emit({ profile, localPersisted: profile.updatedAt !== null }, `Name: ${printable(profile.name)}\nDescription: ${printable(profile.description)}\nPublic key: ${profile.publicKey}`);
|
|
1407
|
+
}
|
|
1408
|
+
else {
|
|
1409
|
+
const result = await updateAccountProfile(context, changes);
|
|
1410
|
+
emit(result, [
|
|
1411
|
+
`Name: ${printable(result.profile.name)}`,
|
|
1412
|
+
`Description: ${printable(result.profile.description)}`,
|
|
1413
|
+
"Personal profile saved locally.",
|
|
1414
|
+
...result.swarms.map((entry) => `${entry.configUrl}: ${entry.synchronized ? "synchronized" : `FAILED: ${entry.error}`}`),
|
|
1415
|
+
].join("\n"));
|
|
1416
|
+
if (result.swarms.some((entry) => !entry.synchronized)) {
|
|
1417
|
+
io.err("Profile saved locally, but some Swarms failed. Retry the profile update or normally activate each failed membership to synchronize it.");
|
|
1418
|
+
return 1;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
break;
|
|
1422
|
+
}
|
|
1171
1423
|
case "swarm list": {
|
|
1172
1424
|
const result = { swarms: state.swarms(), ...selection() };
|
|
1173
1425
|
emit({
|
|
@@ -1216,24 +1468,38 @@ async function performCli(argv, io, env) {
|
|
|
1216
1468
|
case "swarm exclude":
|
|
1217
1469
|
case "swarm resume":
|
|
1218
1470
|
case "swarm profile":
|
|
1471
|
+
case "swarm members":
|
|
1219
1472
|
case "swarm status":
|
|
1220
1473
|
case "publish":
|
|
1474
|
+
case "pin":
|
|
1221
1475
|
case "get": {
|
|
1222
1476
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1223
1477
|
const context = swarmContext();
|
|
1478
|
+
readContext = context;
|
|
1479
|
+
if (parsed.path === "pin") {
|
|
1480
|
+
io.err("Fetching, verifying and retaining content...");
|
|
1481
|
+
const result = await pinNameSubscription(context, first, selectedSwarm);
|
|
1482
|
+
store = context.store;
|
|
1483
|
+
emit(result, `${result.reference} → ${result.cid}\nStatus: ${result.freshness}`);
|
|
1484
|
+
break;
|
|
1485
|
+
}
|
|
1486
|
+
if (parsed.path === "swarm members") {
|
|
1487
|
+
const result = await swarmMembers(context, requireSwarm());
|
|
1488
|
+
emit(result, table(["NAME", "DESCRIPTION", "ROLE", "PUBLIC KEY"], result.members.map((member) => [
|
|
1489
|
+
member.name,
|
|
1490
|
+
member.description,
|
|
1491
|
+
member.role,
|
|
1492
|
+
member.publicKey,
|
|
1493
|
+
]), "No members."));
|
|
1494
|
+
break;
|
|
1495
|
+
}
|
|
1224
1496
|
if (parsed.path === "swarm export") {
|
|
1225
|
-
const id = await exportRequest(context,
|
|
1497
|
+
const id = await exportRequest(context, requireSwarm(), String(parsed.options.output ?? ""));
|
|
1226
1498
|
emit({ id }, id);
|
|
1227
1499
|
break;
|
|
1228
1500
|
}
|
|
1229
1501
|
if (["swarm exclude", "swarm resume", "swarm profile"].includes(parsed.path)) {
|
|
1230
|
-
const url =
|
|
1231
|
-
? selectedSwarm
|
|
1232
|
-
: first
|
|
1233
|
-
? state.resolveSwarm(first)
|
|
1234
|
-
: selectedSwarm;
|
|
1235
|
-
if (!url)
|
|
1236
|
-
syntax("Select a Swarm configuration URL or alias.");
|
|
1502
|
+
const url = requireSwarm();
|
|
1237
1503
|
if (parsed.path === "swarm exclude") {
|
|
1238
1504
|
if (!parsed.options.yes)
|
|
1239
1505
|
syntax("Member removal is irreversible; --yes required.");
|
|
@@ -1243,9 +1509,6 @@ async function performCli(argv, io, env) {
|
|
|
1243
1509
|
await resumeRemoval(context, url);
|
|
1244
1510
|
else {
|
|
1245
1511
|
const profile = await updateProfile(context, url, {
|
|
1246
|
-
...(typeof parsed.options.name === "string"
|
|
1247
|
-
? { name: parsed.options.name }
|
|
1248
|
-
: {}),
|
|
1249
1512
|
...(typeof parsed.options.address === "string"
|
|
1250
1513
|
? { addresses: [parsed.options.address] }
|
|
1251
1514
|
: {}),
|
|
@@ -1259,9 +1522,7 @@ async function performCli(argv, io, env) {
|
|
|
1259
1522
|
break;
|
|
1260
1523
|
}
|
|
1261
1524
|
if (parsed.path === "swarm update") {
|
|
1262
|
-
const cid =
|
|
1263
|
-
if (!cid)
|
|
1264
|
-
syntax("swarm update requires a registered alias, configuration URL or current swarm.");
|
|
1525
|
+
const cid = requireSwarm();
|
|
1265
1526
|
const result = await updateSwarm(context, cid, {
|
|
1266
1527
|
...(typeof parsed.options.name === "string"
|
|
1267
1528
|
? { name: parsed.options.name }
|
|
@@ -1288,28 +1549,22 @@ async function performCli(argv, io, env) {
|
|
|
1288
1549
|
break;
|
|
1289
1550
|
}
|
|
1290
1551
|
if (parsed.path === "search") {
|
|
1291
|
-
const source = items.find((item) => item.key === "swarm.default").source;
|
|
1292
|
-
const limited = parsed.options.current || source === "flag";
|
|
1293
|
-
if (limited && !selectedSwarm)
|
|
1294
|
-
syntax("Search of the current swarm requires --swarm or swarm.default.");
|
|
1295
1552
|
const registrations = state.swarms();
|
|
1296
|
-
const scope =
|
|
1297
|
-
?
|
|
1553
|
+
const scope = parsed.options.all
|
|
1554
|
+
? registrations
|
|
1555
|
+
: [
|
|
1298
1556
|
{
|
|
1299
|
-
cid:
|
|
1557
|
+
cid: requireSwarm(),
|
|
1300
1558
|
alias: registrations.find((entry) => entry.cid === selectedSwarm)
|
|
1301
1559
|
?.alias ?? null,
|
|
1302
1560
|
},
|
|
1303
|
-
]
|
|
1304
|
-
: registrations;
|
|
1561
|
+
];
|
|
1305
1562
|
const result = await searchNames(context, first, scope);
|
|
1306
1563
|
emit(result, formatSearchResults(result.matches));
|
|
1307
1564
|
break;
|
|
1308
1565
|
}
|
|
1309
1566
|
if (parsed.path === "swarm status") {
|
|
1310
|
-
const cid =
|
|
1311
|
-
if (!cid)
|
|
1312
|
-
syntax("swarm status requires a configuration URL or swarm.default.");
|
|
1567
|
+
const cid = requireSwarm();
|
|
1313
1568
|
const local = Boolean(parsed.options.local);
|
|
1314
1569
|
const { head, config } = local
|
|
1315
1570
|
? await swarmHeader(context, cid, true)
|
|
@@ -1362,7 +1617,6 @@ async function performCli(argv, io, env) {
|
|
|
1362
1617
|
break;
|
|
1363
1618
|
}
|
|
1364
1619
|
if (parsed.path === "get") {
|
|
1365
|
-
readContext = context;
|
|
1366
1620
|
const localCid = /^(ipab|name):/i.test(first)
|
|
1367
1621
|
? undefined
|
|
1368
1622
|
: state.resolve(first);
|
|
@@ -1391,6 +1645,12 @@ async function performCli(argv, io, env) {
|
|
|
1391
1645
|
finally {
|
|
1392
1646
|
await source.close();
|
|
1393
1647
|
}
|
|
1648
|
+
try {
|
|
1649
|
+
await context.finishRead?.();
|
|
1650
|
+
}
|
|
1651
|
+
finally {
|
|
1652
|
+
readContext = undefined;
|
|
1653
|
+
}
|
|
1394
1654
|
const closing = store;
|
|
1395
1655
|
store = undefined;
|
|
1396
1656
|
await closeStore(closing, undefined);
|
|
@@ -1400,6 +1660,7 @@ async function performCli(argv, io, env) {
|
|
|
1400
1660
|
break;
|
|
1401
1661
|
}
|
|
1402
1662
|
let cid;
|
|
1663
|
+
let contentCid;
|
|
1403
1664
|
if (parsed.path === "swarm create") {
|
|
1404
1665
|
cid = await createSwarm(context, {
|
|
1405
1666
|
...(typeof parsed.options.service === "string"
|
|
@@ -1417,12 +1678,8 @@ async function performCli(argv, io, env) {
|
|
|
1417
1678
|
: {}),
|
|
1418
1679
|
});
|
|
1419
1680
|
}
|
|
1420
|
-
else if (parsed.path === "swarm request")
|
|
1421
|
-
|
|
1422
|
-
ownerFingerprint: String(parsed.options["owner-fingerprint"] ?? ""),
|
|
1423
|
-
...(typeof parsed.options.name === "string"
|
|
1424
|
-
? { name: parsed.options.name }
|
|
1425
|
-
: {}),
|
|
1681
|
+
else if (parsed.path === "swarm request") {
|
|
1682
|
+
const result = await requestMembership(context, first, {
|
|
1426
1683
|
...(typeof parsed.options.alias === "string"
|
|
1427
1684
|
? { alias: parsed.options.alias }
|
|
1428
1685
|
: {}),
|
|
@@ -1430,8 +1687,30 @@ async function performCli(argv, io, env) {
|
|
|
1430
1687
|
? { output: parsed.options.output }
|
|
1431
1688
|
: {}),
|
|
1432
1689
|
});
|
|
1690
|
+
store = context.store;
|
|
1691
|
+
io.err(`Owner fingerprint: ${result.ownerFingerprint}\nVerify this fingerprint through an independent trusted channel before manually sending the Request file to the Owner.`);
|
|
1692
|
+
if (result.file === undefined)
|
|
1693
|
+
io.out(JSON.stringify(result.request, null, 2));
|
|
1694
|
+
else {
|
|
1695
|
+
io.err(`Request saved to: ${result.file}`);
|
|
1696
|
+
if (parsed.flags.json)
|
|
1697
|
+
emit({
|
|
1698
|
+
file: result.file,
|
|
1699
|
+
requestId: result.requestId,
|
|
1700
|
+
ownerFingerprint: result.ownerFingerprint,
|
|
1701
|
+
}, "");
|
|
1702
|
+
}
|
|
1703
|
+
break;
|
|
1704
|
+
}
|
|
1433
1705
|
else if (parsed.path === "swarm approve") {
|
|
1434
|
-
const
|
|
1706
|
+
const selected = requireSwarm();
|
|
1707
|
+
if (first === "-" && !parsed.options.yes)
|
|
1708
|
+
syntax("Reading a Request from stdin requires explicit --yes; no interactive confirmation is available.");
|
|
1709
|
+
const request = first === "-"
|
|
1710
|
+
? await verifiedRequestStream((io.requestInput ?? processIO.requestInput)())
|
|
1711
|
+
: await verifiedRequest(first);
|
|
1712
|
+
if (request.configUrl !== selected)
|
|
1713
|
+
syntax(`Request belongs to ${request.configUrl}, not the selected Swarm. Use ipab --swarm ${request.configUrl} swarm approve REQUEST_FILE --yes.`);
|
|
1435
1714
|
io.err(await membershipRequestSummary(request));
|
|
1436
1715
|
if (!parsed.options.yes &&
|
|
1437
1716
|
(!io.tty ||
|
|
@@ -1442,16 +1721,11 @@ async function performCli(argv, io, env) {
|
|
|
1442
1721
|
});
|
|
1443
1722
|
}
|
|
1444
1723
|
else {
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
content = (await importBundle(first, () => Promise.resolve(store))).cid;
|
|
1448
|
-
else
|
|
1449
|
-
content = exactCid(first);
|
|
1724
|
+
const content = await publicationSource(second, store);
|
|
1725
|
+
contentCid = content;
|
|
1450
1726
|
cid = await publish(context, content, {
|
|
1451
1727
|
...(selectedSwarm ? { swarm: selectedSwarm } : {}),
|
|
1452
|
-
|
|
1453
|
-
? { name: parsed.options.name }
|
|
1454
|
-
: {}),
|
|
1728
|
+
name: first,
|
|
1455
1729
|
...(typeof parsed.options.expect === "string"
|
|
1456
1730
|
? { expect: parsed.options.expect }
|
|
1457
1731
|
: {}),
|
|
@@ -1461,11 +1735,11 @@ async function performCli(argv, io, env) {
|
|
|
1461
1735
|
store = context.store;
|
|
1462
1736
|
if (parsed.path === "swarm create")
|
|
1463
1737
|
io.err(`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config({ includeSecrets: false })["swarm.default"] ?? "(none)"}.`);
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1738
|
+
if (contentCid)
|
|
1739
|
+
io.err(`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.`);
|
|
1740
|
+
emit(parsed.path === "swarm create" || parsed.path === "swarm approve"
|
|
1741
|
+
? { configUrl: cid }
|
|
1742
|
+
: { cid, ...(contentCid ? { contentCid } : {}) }, cid);
|
|
1469
1743
|
break;
|
|
1470
1744
|
}
|
|
1471
1745
|
case "store usage":
|
|
@@ -1593,7 +1867,7 @@ async function performCli(argv, io, env) {
|
|
|
1593
1867
|
if (result.files.includes("package.json") &&
|
|
1594
1868
|
(result.files.includes("ipab.yaml") ||
|
|
1595
1869
|
result.files.includes("ipab.json")))
|
|
1596
|
-
io.err(`Next: install declared dependencies
|
|
1870
|
+
io.err(`Next: install declared dependencies in ${JSON.stringify(result.directory)}; if your template does not declare @ipab/cli, add or link it as a development dependency. Run pnpm build to prepare and package the App. Root ipab build does not compile.`);
|
|
1597
1871
|
else if (result.files.includes(".bundle.yaml"))
|
|
1598
1872
|
io.err(`Next: ipab bundle build ${JSON.stringify(result.directory)}`);
|
|
1599
1873
|
}
|
|
@@ -1612,80 +1886,62 @@ async function performCli(argv, io, env) {
|
|
|
1612
1886
|
break;
|
|
1613
1887
|
}
|
|
1614
1888
|
case "pin list": {
|
|
1615
|
-
const
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
.map((
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
emit({ items: listed, pending, invalid }, table(["NAME", "CID", "KIND", "TITLE", "TYPE CID", "SOURCE"], listed.map((pin) => [
|
|
1639
|
-
pin.name,
|
|
1640
|
-
pin.cid,
|
|
1641
|
-
pin.kind,
|
|
1642
|
-
pin.title,
|
|
1643
|
-
pin.schemaCid,
|
|
1644
|
-
pin.builtin ? "built-in (read-only)" : "user",
|
|
1645
|
-
]), "No named pins."));
|
|
1889
|
+
const listed = state.contentPins();
|
|
1890
|
+
const archived = state.archivedPins();
|
|
1891
|
+
const builtins = state.pins().map(pinDetails);
|
|
1892
|
+
emit({ items: listed, builtins, archived }, table(["REFERENCE", "CID", "STATUS", "SOURCE"], [
|
|
1893
|
+
...listed.map((pin) => [
|
|
1894
|
+
pin.reference,
|
|
1895
|
+
pin.cid ?? "(none)",
|
|
1896
|
+
`${pin.status}/${pin.freshness}${pin.error ? `: ${pin.error}` : ""}`,
|
|
1897
|
+
pin.swarm ? "following shared Name" : "fixed CID",
|
|
1898
|
+
]),
|
|
1899
|
+
...builtins.map((pin) => [
|
|
1900
|
+
pin.name,
|
|
1901
|
+
pin.cid,
|
|
1902
|
+
"read-only",
|
|
1903
|
+
"built-in",
|
|
1904
|
+
]),
|
|
1905
|
+
...archived.map((pin) => [
|
|
1906
|
+
pin.cid,
|
|
1907
|
+
pin.cid,
|
|
1908
|
+
pin.status,
|
|
1909
|
+
`inactive archive (${pin.name}); unpin exact CID`,
|
|
1910
|
+
]),
|
|
1911
|
+
], "No pins."));
|
|
1646
1912
|
break;
|
|
1647
1913
|
}
|
|
1648
|
-
case "
|
|
1649
|
-
|
|
1650
|
-
const result = await
|
|
1651
|
-
emit(result,
|
|
1652
|
-
break;
|
|
1653
|
-
}
|
|
1654
|
-
case "pin delete": {
|
|
1655
|
-
const result = await deletePin(state, first);
|
|
1656
|
-
emit(result, `Deleted ${first}; released only its retention responsibility. No blocks deleted or GC requested.`);
|
|
1914
|
+
case "unpin": {
|
|
1915
|
+
const canonical = pinReference(state, first, selectedSwarm);
|
|
1916
|
+
const result = await unpin(state, canonical.reference);
|
|
1917
|
+
emit(result, `Unpinned ${canonical.reference}; released only its saved retention responsibility. No blocks deleted or GC requested.`);
|
|
1657
1918
|
break;
|
|
1658
1919
|
}
|
|
1659
1920
|
case "pin show": {
|
|
1660
|
-
const
|
|
1661
|
-
|
|
1921
|
+
const builtin = first.startsWith("builtin:")
|
|
1922
|
+
? state.pin(first)
|
|
1923
|
+
: undefined;
|
|
1924
|
+
const canonical = builtin
|
|
1925
|
+
? undefined
|
|
1926
|
+
: pinReference(state, first, selectedSwarm);
|
|
1927
|
+
const pin = canonical
|
|
1928
|
+
? state.contentPin(canonical.reference)
|
|
1929
|
+
: undefined;
|
|
1930
|
+
const archived = canonical
|
|
1931
|
+
? state
|
|
1932
|
+
.archivedPins()
|
|
1933
|
+
.filter((pin) => pin.cid === canonical.reference)
|
|
1934
|
+
: [];
|
|
1935
|
+
if (!pin && !builtin && !archived.length)
|
|
1662
1936
|
throw new HostError(`Pin "${first}" does not exist. Run ipab pin list.`);
|
|
1663
|
-
const result =
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
}
|
|
1672
|
-
case "register list": {
|
|
1673
|
-
const associations = state.registrations();
|
|
1674
|
-
emit({ items: associations }, table(["SCHEMA CID", "APP CID", "ARGV"], associations.map((association) => [
|
|
1675
|
-
association.schemaCid,
|
|
1676
|
-
association.appCid,
|
|
1677
|
-
JSON.stringify(association.argv),
|
|
1678
|
-
]), "No associations."));
|
|
1679
|
-
break;
|
|
1680
|
-
}
|
|
1681
|
-
case "register set": {
|
|
1682
|
-
const association = state.setAssociation(schemaAlias(first), second, parsed.template ?? ["%"], Boolean(parsed.options.replace));
|
|
1683
|
-
emit(association, `${association.schemaCid} → ${association.appCid} ${JSON.stringify(association.argv)}`);
|
|
1684
|
-
break;
|
|
1685
|
-
}
|
|
1686
|
-
case "register remove": {
|
|
1687
|
-
const removed = state.removeAssociation(schemaAlias(first));
|
|
1688
|
-
emit({ removed: [removed] }, `Removed association for ${removed}.`);
|
|
1937
|
+
const result = builtin
|
|
1938
|
+
? pinDetails(builtin)
|
|
1939
|
+
: {
|
|
1940
|
+
pin: pin ?? null,
|
|
1941
|
+
roots: pin ? state.hold(pin.owner)?.roots : [],
|
|
1942
|
+
archived,
|
|
1943
|
+
};
|
|
1944
|
+
emit(result, JSON.stringify(result, null, 2));
|
|
1689
1945
|
break;
|
|
1690
1946
|
}
|
|
1691
1947
|
case "config get": {
|
|
@@ -1775,12 +2031,19 @@ async function performCli(argv, io, env) {
|
|
|
1775
2031
|
}
|
|
1776
2032
|
case "exec":
|
|
1777
2033
|
case "open": {
|
|
2034
|
+
const named = parsed.path === "open" ? parseNameReference(first) : undefined;
|
|
2035
|
+
const registrySwarm = named?.swarm
|
|
2036
|
+
? state.resolveSwarm(named.swarm)
|
|
2037
|
+
: selectedSwarm;
|
|
2038
|
+
if (parsed.path === "open" && !registrySwarm)
|
|
2039
|
+
throw new HostError("Open requires a selected Swarm. Use ipab://URL_OR_ALIAS/PATH, pass --swarm URL_OR_ALIAS, or save a default with ipab swarm use URL_OR_ALIAS. To select an App directly, use ipab exec.");
|
|
1778
2040
|
if (parsed.options.log && !value("history.enabled"))
|
|
1779
2041
|
throw new HostError("Execution logging requires history.enabled=true.");
|
|
1780
2042
|
await recoverInactive(state);
|
|
1781
2043
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1782
2044
|
const context = swarmContext();
|
|
1783
|
-
|
|
2045
|
+
readContext = context;
|
|
2046
|
+
const target = (await resolveReference(context, first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw), "local-first")).cid;
|
|
1784
2047
|
store = context.store;
|
|
1785
2048
|
const resolveBundleReference = async (reference, signal, preferredSwarm) => {
|
|
1786
2049
|
signal.throwIfAborted();
|
|
@@ -1795,7 +2058,7 @@ async function performCli(argv, io, env) {
|
|
|
1795
2058
|
: preferredSwarm
|
|
1796
2059
|
? state.resolveSwarm(preferredSwarm)
|
|
1797
2060
|
: selectedSwarm;
|
|
1798
|
-
const resolve = (source) => resolveReference(lookup, reference, source, (input) => state.resolve(input));
|
|
2061
|
+
const resolve = (source) => resolveReference(lookup, reference, source, (input) => state.resolve(input), false, "local-first");
|
|
1799
2062
|
let resolved;
|
|
1800
2063
|
try {
|
|
1801
2064
|
resolved = await resolve(named ? swarm : undefined);
|
|
@@ -1816,7 +2079,12 @@ async function performCli(argv, io, env) {
|
|
|
1816
2079
|
return { ...resolved, ...(swarm ? { swarm } : {}) };
|
|
1817
2080
|
}
|
|
1818
2081
|
finally {
|
|
1819
|
-
|
|
2082
|
+
try {
|
|
2083
|
+
await lookup.finishRead?.();
|
|
2084
|
+
}
|
|
2085
|
+
finally {
|
|
2086
|
+
await lookup.store.close();
|
|
2087
|
+
}
|
|
1820
2088
|
}
|
|
1821
2089
|
};
|
|
1822
2090
|
let appCid;
|
|
@@ -1827,9 +2095,26 @@ async function performCli(argv, io, env) {
|
|
|
1827
2095
|
try {
|
|
1828
2096
|
const content = await validatedBundle(root, store, owner);
|
|
1829
2097
|
const schema = content.schemaKey;
|
|
1830
|
-
|
|
2098
|
+
let association;
|
|
2099
|
+
if (registrySwarm) {
|
|
2100
|
+
const lookup = {
|
|
2101
|
+
...swarmContext(),
|
|
2102
|
+
store: new IpfsStore(await storeConfiguration(value("store.gateway"))),
|
|
2103
|
+
};
|
|
2104
|
+
try {
|
|
2105
|
+
association = await swarmAssociation(lookup, registrySwarm, schema, "local-first");
|
|
2106
|
+
}
|
|
2107
|
+
finally {
|
|
2108
|
+
try {
|
|
2109
|
+
await lookup.finishRead?.();
|
|
2110
|
+
}
|
|
2111
|
+
finally {
|
|
2112
|
+
await lookup.store.close();
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
1831
2116
|
if (!association)
|
|
1832
|
-
throw new HostError(`No App registered for Schema ${schema}. Use ipab register set or ipab exec.`);
|
|
2117
|
+
throw new HostError(`No App registered for Schema ${schema} in Swarm ${registrySwarm}. Use ipab register set ${schema} APP_CID --swarm ${registrySwarm} or ipab exec.`);
|
|
1833
2118
|
appCid = association.appCid;
|
|
1834
2119
|
appArgv = association.argv.map((argument) => argument === "%" ? root : argument);
|
|
1835
2120
|
// execute owns the App/input context before this validation owner's eventual release.
|
|
@@ -1876,8 +2161,12 @@ async function performCli(argv, io, env) {
|
|
|
1876
2161
|
}
|
|
1877
2162
|
finally {
|
|
1878
2163
|
try {
|
|
1879
|
-
|
|
1880
|
-
|
|
2164
|
+
try {
|
|
2165
|
+
await readContext?.finishRead?.();
|
|
2166
|
+
}
|
|
2167
|
+
finally {
|
|
2168
|
+
await closeStore(store, appExitCode);
|
|
2169
|
+
}
|
|
1881
2170
|
}
|
|
1882
2171
|
finally {
|
|
1883
2172
|
state?.close();
|