@ipab/cli 0.1.0-rc.4 → 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 +88 -16
- 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 +6 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +656 -278
- package/dist/cli.js.map +1 -1
- package/dist/config-secret.d.ts +1 -1
- package/dist/config-secret.d.ts.map +1 -1
- package/dist/config-secret.js +2 -73
- package/dist/config-secret.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +12 -1
- package/dist/config.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-types.d.ts +12 -0
- package/dist/context-types.d.ts.map +1 -0
- package/dist/context-types.js +2 -0
- package/dist/context-types.js.map +1 -0
- package/dist/context.d.ts +6 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +24 -9
- 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 +3 -2
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +33 -9
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.d.ts +26 -0
- package/dist/kubo-install.d.ts.map +1 -0
- package/dist/kubo-install.js +724 -0
- package/dist/kubo-install.js.map +1 -0
- package/dist/kubo-peering.d.ts +11 -0
- package/dist/kubo-peering.d.ts.map +1 -0
- package/dist/kubo-peering.js +93 -0
- package/dist/kubo-peering.js.map +1 -0
- package/dist/kubo-peers.d.ts +12 -0
- package/dist/kubo-peers.d.ts.map +1 -0
- package/dist/kubo-peers.js +118 -0
- package/dist/kubo-peers.js.map +1 -0
- package/dist/kubo-release.d.ts +22 -0
- package/dist/kubo-release.d.ts.map +1 -0
- package/dist/kubo-release.js +176 -0
- package/dist/kubo-release.js.map +1 -0
- package/dist/kubo.d.ts +12 -4
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +218 -259
- 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 +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +4 -2
- package/dist/runtime.js.map +1 -1
- package/dist/state-storage-windows.d.ts +2 -0
- package/dist/state-storage-windows.d.ts.map +1 -0
- package/dist/state-storage-windows.js +114 -0
- package/dist/state-storage-windows.js.map +1 -0
- package/dist/state-storage.d.ts +5 -0
- package/dist/state-storage.d.ts.map +1 -0
- package/dist/state-storage.js +330 -0
- package/dist/state-storage.js.map +1 -0
- package/dist/state.d.ts +42 -8
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +254 -98
- 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-files.d.ts +1 -1
- package/dist/swarm-files.d.ts.map +1 -1
- package/dist/swarm-files.js +4 -1
- package/dist/swarm-files.js.map +1 -1
- package/dist/swarm.d.ts +70 -11
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +1033 -167
- package/dist/swarm.js.map +1 -1
- package/package.json +4 -4
- package/src/app-templates.ts +1 -1
- package/src/cli.ts +827 -356
- package/src/config-secret.ts +2 -84
- package/src/config.ts +14 -1
- package/src/content-provider.ts +4 -2
- package/src/context-types.ts +11 -0
- package/src/context.ts +39 -9
- package/src/doctor.ts +902 -0
- package/src/identity.ts +10 -10
- package/src/ipc.ts +49 -8
- package/src/kubo-install.ts +936 -0
- package/src/kubo-peering.ts +126 -0
- package/src/kubo-peers.ts +145 -0
- package/src/kubo-release.ts +230 -0
- package/src/kubo.ts +302 -336
- package/src/pins.ts +188 -126
- package/src/publish-source.ts +103 -0
- package/src/runtime.ts +10 -2
- package/src/state-storage-windows.ts +134 -0
- package/src/state-storage.ts +375 -0
- package/src/state.ts +410 -118
- package/src/swarm-envelope.ts +14 -0
- package/src/swarm-files.ts +4 -0
- package/src/swarm.ts +1482 -207
- package/dist/setup.d.ts +0 -7
- package/dist/setup.d.ts.map +0 -1
- package/dist/setup.js +0 -22
- package/dist/setup.js.map +0 -1
- package/src/setup.ts +0 -21
package/src/cli.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createInterface } from "node:readline/promises";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { IpfsStore } from "@ipab/ipfs-store";
|
|
3
|
+
import { ContentError, IpfsStore } from "@ipab/ipfs-store";
|
|
4
|
+
import { ContentBundleError } from "@ipab/bundle";
|
|
4
5
|
import { randomUUID } from "node:crypto";
|
|
5
6
|
import { CID } from "multiformats/cid";
|
|
6
7
|
import stringWidth from "string-width";
|
|
@@ -25,12 +26,18 @@ import {
|
|
|
25
26
|
} from "./history.js";
|
|
26
27
|
import { execute } from "./runtime.js";
|
|
27
28
|
import { validatedBundle } from "./space.js";
|
|
28
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
createAssociation,
|
|
31
|
+
exactCid,
|
|
32
|
+
State,
|
|
33
|
+
type Association,
|
|
34
|
+
type RunRecord,
|
|
35
|
+
} from "./state.js";
|
|
29
36
|
import { buildBundle, inspectBundle, importBundle } from "./authoring.js";
|
|
30
37
|
import { initApp } from "./app-authoring.js";
|
|
31
38
|
import { assembleBundle } from "./assembly.js";
|
|
32
39
|
import { getBundle } from "./get.js";
|
|
33
|
-
import {
|
|
40
|
+
import { doctorDevice, doctorText } from "./doctor.js";
|
|
34
41
|
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
35
42
|
import {
|
|
36
43
|
createSwarm,
|
|
@@ -40,42 +47,73 @@ import {
|
|
|
40
47
|
removeMember,
|
|
41
48
|
resumeRemoval,
|
|
42
49
|
updateProfile,
|
|
50
|
+
accountProfile,
|
|
51
|
+
updateAccountProfile,
|
|
52
|
+
swarmMembers,
|
|
43
53
|
verifiedRequest,
|
|
54
|
+
verifiedRequestStream,
|
|
44
55
|
membershipRequestSummary,
|
|
45
56
|
swarmHeader,
|
|
46
57
|
sharedSwarmStatus,
|
|
47
58
|
addSwarm,
|
|
48
59
|
updateSwarm,
|
|
49
60
|
searchNames,
|
|
61
|
+
formatNameReference,
|
|
50
62
|
resolveReference,
|
|
63
|
+
parseNameReference,
|
|
64
|
+
formalName,
|
|
51
65
|
publish,
|
|
66
|
+
pinNameSubscription,
|
|
67
|
+
pinReference,
|
|
68
|
+
swarmRegistrations,
|
|
69
|
+
swarmAssociation,
|
|
70
|
+
setSwarmAssociation,
|
|
71
|
+
removeSwarmAssociation,
|
|
52
72
|
type SwarmContext,
|
|
53
73
|
} from "./swarm.js";
|
|
54
74
|
import { schemaAlias } from "./app-definition.js";
|
|
55
|
-
import {
|
|
75
|
+
import { unpin, pinDetails } from "./pins.js";
|
|
76
|
+
import { publicationSource } from "./publish-source.js";
|
|
56
77
|
import { logFiles } from "./logs.js";
|
|
57
78
|
import { builtinContent } from "./builtins.js";
|
|
58
79
|
import { readSecretStream } from "./config-secret.js";
|
|
59
80
|
|
|
60
81
|
export interface IO {
|
|
61
82
|
out(text: string): void;
|
|
62
|
-
err(text: string): void;
|
|
83
|
+
err(text: string, progress?: boolean): void;
|
|
63
84
|
tty: boolean;
|
|
64
85
|
columns?(): number | undefined;
|
|
65
|
-
confirm(text: string): Promise<boolean>;
|
|
86
|
+
confirm(text: string, signal?: AbortSignal): Promise<boolean>;
|
|
66
87
|
readSecret?(): Promise<string>;
|
|
88
|
+
requestInput?(): AsyncIterable<string | Uint8Array>;
|
|
67
89
|
}
|
|
90
|
+
let progressLine = false;
|
|
68
91
|
export const processIO: IO = {
|
|
69
92
|
out(text) {
|
|
70
93
|
process.stdout.write(`${text}\n`);
|
|
71
94
|
},
|
|
72
|
-
err(text) {
|
|
73
|
-
process.stderr.
|
|
95
|
+
err(text, progress = false) {
|
|
96
|
+
if (progress && process.stderr.isTTY) {
|
|
97
|
+
const width =
|
|
98
|
+
(process.stderr.columns > 1 ? process.stderr.columns : 80) - 1;
|
|
99
|
+
process.stderr.write(`\r\x1b[2K${text.slice(0, width)}`);
|
|
100
|
+
progressLine = true;
|
|
101
|
+
} else {
|
|
102
|
+
process.stderr.write(`${progressLine ? "\n" : ""}${text}\n`);
|
|
103
|
+
progressLine = false;
|
|
104
|
+
}
|
|
74
105
|
},
|
|
75
106
|
tty: Boolean(process.stdin.isTTY && process.stderr.isTTY),
|
|
76
107
|
columns() {
|
|
77
108
|
return process.stdout.columns;
|
|
78
109
|
},
|
|
110
|
+
requestInput() {
|
|
111
|
+
if (process.stdin.isTTY)
|
|
112
|
+
syntax(
|
|
113
|
+
"Pipe Request JSON into swarm approve - --yes, or pass a Request file.",
|
|
114
|
+
);
|
|
115
|
+
return process.stdin;
|
|
116
|
+
},
|
|
79
117
|
async readSecret() {
|
|
80
118
|
if (process.stdin.isTTY)
|
|
81
119
|
syntax(
|
|
@@ -84,14 +122,16 @@ export const processIO: IO = {
|
|
|
84
122
|
process.stdin.setEncoding("utf8");
|
|
85
123
|
return readSecretStream(process.stdin as AsyncIterable<string>);
|
|
86
124
|
},
|
|
87
|
-
async confirm(text) {
|
|
125
|
+
async confirm(text, signal) {
|
|
88
126
|
const reader = createInterface({
|
|
89
127
|
input: process.stdin,
|
|
90
128
|
output: process.stderr,
|
|
91
129
|
});
|
|
92
130
|
try {
|
|
93
131
|
return /^(y|yes)$/i.test(
|
|
94
|
-
(
|
|
132
|
+
(
|
|
133
|
+
await reader.question(`${text} [y/N] `, signal ? { signal } : {})
|
|
134
|
+
).trim(),
|
|
95
135
|
);
|
|
96
136
|
} finally {
|
|
97
137
|
reader.close();
|
|
@@ -99,28 +139,25 @@ export const processIO: IO = {
|
|
|
99
139
|
},
|
|
100
140
|
};
|
|
101
141
|
const commands: Record<string, string> = {
|
|
102
|
-
|
|
142
|
+
doctor: "doctor [--fix [--yes]]",
|
|
143
|
+
profile: "profile [--name NAME] [--description TEXT]",
|
|
103
144
|
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
104
|
-
"swarm request":
|
|
105
|
-
|
|
106
|
-
"swarm export": "swarm export URL_OR_ALIAS --output FILE",
|
|
145
|
+
"swarm request": "swarm request CONFIG_URL [--output FILE] [--alias ALIAS]",
|
|
146
|
+
"swarm export": "swarm export --output FILE",
|
|
107
147
|
"swarm approve": "swarm approve REQUEST_FILE [--again] --yes",
|
|
108
|
-
"swarm exclude":
|
|
109
|
-
|
|
110
|
-
"swarm
|
|
111
|
-
"swarm
|
|
112
|
-
|
|
113
|
-
"swarm status": "swarm status [URL_OR_ALIAS]",
|
|
148
|
+
"swarm exclude": "swarm exclude MEMBER_PUBLIC_KEY --yes",
|
|
149
|
+
"swarm resume": "swarm resume",
|
|
150
|
+
"swarm profile": "swarm profile --address MULTIADDR",
|
|
151
|
+
"swarm status": "swarm status [--local]",
|
|
152
|
+
"swarm members": "swarm members",
|
|
114
153
|
"swarm list": "swarm list",
|
|
115
154
|
"swarm add": "swarm add CONFIG_URL [--alias ALIAS]",
|
|
116
155
|
"swarm use": "swarm use URL_OR_ALIAS",
|
|
117
156
|
"swarm remove": "swarm remove URL_OR_ALIAS",
|
|
118
|
-
"swarm update":
|
|
119
|
-
|
|
120
|
-
publish:
|
|
121
|
-
"publish CID_OR_CAR [--name NAME [--expect OLD_NODE_CID | --snapshot]]",
|
|
157
|
+
"swarm update": "swarm update [--name TEXT] [--description TEXT]",
|
|
158
|
+
publish: "publish NAME SOURCE [--expect OLD_ARTIFACT_CID | --snapshot]",
|
|
122
159
|
get: "get REF [--raw] [--force | --no-force] [-o DIRECTORY]",
|
|
123
|
-
search: "search QUERY [--current] [--force | --no-force]",
|
|
160
|
+
search: "search QUERY [--all | --current] [--force | --no-force]",
|
|
124
161
|
init: "init NAME [DIR] [OPTIONS]",
|
|
125
162
|
build: "build [SOURCE] [OPTIONS]",
|
|
126
163
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
@@ -128,14 +165,14 @@ const commands: Record<string, string> = {
|
|
|
128
165
|
"bundle import": "bundle import FILE.car",
|
|
129
166
|
exec: "exec [--log] [--force | --no-force] APP [APP_ARGS...]",
|
|
130
167
|
open: "open [--log] [--raw] [--force | --no-force] CONTENT",
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
"pin list": "pin list
|
|
134
|
-
"pin show": "pin show
|
|
135
|
-
"
|
|
136
|
-
"register
|
|
137
|
-
|
|
138
|
-
"register remove": "register remove SCHEMA",
|
|
168
|
+
pin: "pin REF",
|
|
169
|
+
unpin: "unpin REF",
|
|
170
|
+
"pin list": "pin list",
|
|
171
|
+
"pin show": "pin show REF",
|
|
172
|
+
"register list": "register list [--swarm URL_OR_ALIAS]...",
|
|
173
|
+
"register set":
|
|
174
|
+
"register set SCHEMA APP [--swarm URL_OR_ALIAS]... [--replace] [-- TEMPLATE...]",
|
|
175
|
+
"register remove": "register remove SCHEMA [--swarm URL_OR_ALIAS]...",
|
|
139
176
|
"config get": "config get [KEY]",
|
|
140
177
|
"config set":
|
|
141
178
|
"config set KEY VALUE\n ipab config set pointers.apiKey - < protected-key-file",
|
|
@@ -150,7 +187,7 @@ const commands: Record<string, string> = {
|
|
|
150
187
|
const groups: Record<string, string> = {
|
|
151
188
|
swarm: "Create, authorize, select and manage personal swarms",
|
|
152
189
|
bundle: "Create, inspect and import content bundles",
|
|
153
|
-
pin: "Retain
|
|
190
|
+
pin: "Retain an exact CID or follow a shared Swarm Name",
|
|
154
191
|
register: "Associate content types with Apps",
|
|
155
192
|
config: "Manage local configuration",
|
|
156
193
|
store: "Query local storage and collect unreferenced blocks",
|
|
@@ -166,15 +203,42 @@ const commandHelp: Record<
|
|
|
166
203
|
notes?: string[];
|
|
167
204
|
}
|
|
168
205
|
> = {
|
|
169
|
-
|
|
206
|
+
profile: {
|
|
207
|
+
summary: "Read or update your account-wide public name and description",
|
|
208
|
+
examples: [
|
|
209
|
+
"ipab profile",
|
|
210
|
+
'ipab profile --name Wei --description "Developer"',
|
|
211
|
+
'ipab profile --description ""',
|
|
212
|
+
],
|
|
213
|
+
options: [
|
|
214
|
+
"--name NAME Replace only your personal name.",
|
|
215
|
+
"--description TEXT Replace only your description; empty text clears it.",
|
|
216
|
+
],
|
|
217
|
+
notes: [
|
|
218
|
+
"Independent of Swarm selection. Reading never creates an identity, persists a profile or activates a node.",
|
|
219
|
+
"An explicit update prepares a missing account identity without starting Kubo.",
|
|
220
|
+
"Updates persist locally first, then synchronize all registered memberships without changing network addresses. Partial failure exits nonzero and reports every result.",
|
|
221
|
+
"Retry the same profile update, or normally activate a failed membership to synchronize the saved profile.",
|
|
222
|
+
"First use preserves unanimous legacy values; conflicting fields require an explicit choice. New memberships adopt this same profile.",
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
doctor: {
|
|
170
226
|
summary:
|
|
171
|
-
"
|
|
172
|
-
examples: [
|
|
227
|
+
"Inspect device readiness without writes; explicitly authorize safe repairs",
|
|
228
|
+
examples: [
|
|
229
|
+
"ipab doctor",
|
|
230
|
+
"ipab doctor --fix",
|
|
231
|
+
"ipab --json doctor --fix --yes",
|
|
232
|
+
],
|
|
173
233
|
options: [
|
|
174
|
-
"--
|
|
234
|
+
"--fix Repair missing components, cache official archives to verify existing Kubo without reinstall, and authorize healthy compatible upgrades within ^0.43.2.",
|
|
235
|
+
"--yes Authorize planned repairs without prompting; requires --fix.",
|
|
175
236
|
],
|
|
176
237
|
notes: [
|
|
177
|
-
"
|
|
238
|
+
"Always checks local state/configuration, managed Kubo, HOME identity, local Swarm registry and compatible updates.",
|
|
239
|
+
"Inspection never creates state, locks, credentials or caches. Official release metadata may be queried; unavailable updates are not claimed current.",
|
|
240
|
+
"Healthy current components are reused without download or confirmation. Fixed protected archive cache is automatic.",
|
|
241
|
+
"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.",
|
|
178
242
|
"Does not create Swarm repos, start or contact any daemon, deploy services or install login startup.",
|
|
179
243
|
],
|
|
180
244
|
},
|
|
@@ -201,16 +265,21 @@ const commandHelp: Record<
|
|
|
201
265
|
"swarm request": {
|
|
202
266
|
summary: "Save and export a signed self-contained membership Request",
|
|
203
267
|
examples: [
|
|
204
|
-
"ipab swarm request CONFIG_URL --
|
|
268
|
+
"ipab swarm request CONFIG_URL --alias work",
|
|
269
|
+
"ipab swarm request CONFIG_URL --output request.json --alias work",
|
|
205
270
|
],
|
|
206
271
|
options: [
|
|
207
|
-
"--owner-fingerprint VALUE Verify Owner through a trusted independent channel.",
|
|
208
|
-
"--name NAME Initial public display name.",
|
|
209
272
|
"--alias ALIAS Pre-register the target for lazy onboarding.",
|
|
210
|
-
"--output FILE Export
|
|
273
|
+
"--output FILE Export to a new file instead of stdout; never overwrites.",
|
|
211
274
|
],
|
|
212
275
|
notes: [
|
|
276
|
+
"Verify the printed Owner fingerprint through an independent trusted channel before manually sending the Request file to the Owner.",
|
|
277
|
+
"Without --output, stdout is the signed Request JSON, including in --json mode.",
|
|
278
|
+
"With --output, reports the file on stderr; --json returns file, requestId and ownerFingerprint.",
|
|
279
|
+
"Retries export the exact saved Request without expiry or a new PeerID.",
|
|
213
280
|
"No Invite, Response file, password or Join. Next normal use fetches and decrypts the approved package.",
|
|
281
|
+
"Set your account-wide personal name with ipab profile --name NAME before requesting membership.",
|
|
282
|
+
"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.",
|
|
214
283
|
],
|
|
215
284
|
},
|
|
216
285
|
"swarm approve": {
|
|
@@ -219,14 +288,18 @@ const commandHelp: Record<
|
|
|
219
288
|
"--yes Explicit approval; required outside a TTY.",
|
|
220
289
|
"--again Explicit fresh approval of an old Request; history is advisory.",
|
|
221
290
|
],
|
|
222
|
-
examples: [
|
|
291
|
+
examples: [
|
|
292
|
+
"ipab swarm approve request.json --yes",
|
|
293
|
+
"ipab swarm approve - --yes < request.json",
|
|
294
|
+
],
|
|
223
295
|
notes: [
|
|
296
|
+
"Use '-' to read Request JSON from stdin (maximum 16 KiB); --yes is required and no confirmation prompt reads stdin.",
|
|
224
297
|
"Creates a public profile and publishes an Owner-signed X25519/AES-GCM package. Exact-ID certificates have no expiry.",
|
|
225
298
|
],
|
|
226
299
|
},
|
|
227
300
|
"swarm export": {
|
|
228
301
|
summary: "Re-export the same persisted Request",
|
|
229
|
-
examples: ["ipab swarm export
|
|
302
|
+
examples: ["ipab --swarm work swarm export --output request.json"],
|
|
230
303
|
},
|
|
231
304
|
"swarm exclude": {
|
|
232
305
|
summary: "Owner removes a member with irreversible HEAD/key rotation",
|
|
@@ -237,13 +310,22 @@ const commandHelp: Record<
|
|
|
237
310
|
},
|
|
238
311
|
"swarm resume": {
|
|
239
312
|
summary: "Owner resumes an interrupted organization switch",
|
|
240
|
-
examples: ["ipab swarm resume
|
|
313
|
+
examples: ["ipab --swarm work swarm resume"],
|
|
241
314
|
},
|
|
242
315
|
"swarm profile": {
|
|
243
|
-
summary: "
|
|
316
|
+
summary: "Configure only your selected Swarm's LAN/VPN IPv4 TCP address",
|
|
244
317
|
examples: [
|
|
245
|
-
"ipab swarm profile
|
|
246
|
-
|
|
318
|
+
"ipab --swarm work swarm profile --address /ip4/192.168.1.12/tcp/4001/p2p/PEER_ID",
|
|
319
|
+
],
|
|
320
|
+
notes: [
|
|
321
|
+
"Personal name/description are managed only by ipab profile, not this network configuration command.",
|
|
322
|
+
],
|
|
323
|
+
},
|
|
324
|
+
"swarm members": {
|
|
325
|
+
summary: "List every public member, including the Owner",
|
|
326
|
+
examples: ["ipab --swarm work swarm members", "ipab --json swarm members"],
|
|
327
|
+
notes: [
|
|
328
|
+
"Public HTTP reads only; no local membership, identity creation or node activation. Failed reads fail the command, never omit members.",
|
|
247
329
|
],
|
|
248
330
|
},
|
|
249
331
|
"swarm status": {
|
|
@@ -253,8 +335,8 @@ const commandHelp: Record<
|
|
|
253
335
|
],
|
|
254
336
|
examples: [
|
|
255
337
|
"ipab swarm status",
|
|
256
|
-
"ipab swarm status
|
|
257
|
-
"ipab swarm status
|
|
338
|
+
"ipab --swarm work swarm status",
|
|
339
|
+
"ipab --swarm work swarm status --local",
|
|
258
340
|
],
|
|
259
341
|
notes: [
|
|
260
342
|
"Always read public configuration, Scope and HEAD, and verify the State. Local content needs no HOME identity or node activation.",
|
|
@@ -290,13 +372,12 @@ const commandHelp: Record<
|
|
|
290
372
|
},
|
|
291
373
|
"swarm update": {
|
|
292
374
|
summary: "Owner updates public organization information",
|
|
293
|
-
arguments: ["URL_OR_ALIAS Defaults to the effective current swarm."],
|
|
294
375
|
options: [
|
|
295
376
|
"--name TEXT Replace the shared display name; empty text clears it.",
|
|
296
377
|
"--description TEXT Replace the shared description; empty text clears it.",
|
|
297
378
|
],
|
|
298
379
|
examples: [
|
|
299
|
-
'ipab swarm update
|
|
380
|
+
'ipab --swarm work swarm update --name "Team" --description "Shared workspace"',
|
|
300
381
|
'ipab swarm update --description ""',
|
|
301
382
|
],
|
|
302
383
|
notes: [
|
|
@@ -306,36 +387,44 @@ const commandHelp: Record<
|
|
|
306
387
|
],
|
|
307
388
|
},
|
|
308
389
|
search: {
|
|
309
|
-
summary: "Search formal Names
|
|
390
|
+
summary: "Search formal Names in the current swarm",
|
|
310
391
|
arguments: [
|
|
311
392
|
"QUERY Case-insensitive literal name substring, 1..256 characters.",
|
|
312
393
|
],
|
|
313
394
|
options: [
|
|
314
|
-
"--
|
|
395
|
+
"--all Search all registered swarms; conflicts with --current and --swarm.",
|
|
396
|
+
"--current Explicitly select the default search scope; conflicts with --swarm.",
|
|
315
397
|
"--force Refresh HEAD for every swarm in the search scope.",
|
|
316
398
|
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
317
399
|
],
|
|
318
|
-
examples: [
|
|
400
|
+
examples: [
|
|
401
|
+
"ipab search hello",
|
|
402
|
+
"ipab search hello --all",
|
|
403
|
+
"ipab --swarm work search hello --force",
|
|
404
|
+
],
|
|
319
405
|
notes: [
|
|
320
|
-
"Searches
|
|
321
|
-
"Valid caches use local Names
|
|
406
|
+
"Searches only --swarm or the saved current swarm by default. Use --all to search every registration.",
|
|
407
|
+
"Valid caches use local Names; absent/expired caches refresh. Active Name pins may synchronize content.",
|
|
408
|
+
"Refresh reads public configuration and HEAD; private networking is activated only for missing content.",
|
|
322
409
|
"No matches is success, not a reason to refresh valid caches. Any failed swarm fails the whole search.",
|
|
410
|
+
"Text uses local alias URIs when available; JSON references use full configuration URLs for cross-device sharing.",
|
|
323
411
|
],
|
|
324
412
|
},
|
|
325
413
|
publish: {
|
|
326
|
-
summary: "
|
|
414
|
+
summary: "Protect content locally and publish a shared Swarm Name",
|
|
327
415
|
options: [
|
|
328
|
-
"--name NAME New formal Name; occupied Names fail.",
|
|
329
416
|
"--expect CID Exact old Artifact node, required for iteration.",
|
|
330
417
|
"--snapshot Name ordinary content without an Artifact; initial only.",
|
|
331
418
|
],
|
|
332
419
|
examples: [
|
|
333
|
-
"ipab
|
|
334
|
-
"ipab publish
|
|
335
|
-
"ipab publish
|
|
420
|
+
"ipab --swarm work publish apps/hello app.car",
|
|
421
|
+
"ipab publish apps/hello APP_CID --expect OLD_ARTIFACT_CID",
|
|
422
|
+
"ipab publish notes/readme ./README.md",
|
|
336
423
|
],
|
|
337
424
|
notes: [
|
|
338
|
-
"No
|
|
425
|
+
"SOURCE is an exact Bundle CID, CAR, regular file or directory. No compiler, hooks, install or App execution.",
|
|
426
|
+
"Directories require .bundle.yaml/type, or a package.json source snapshot. Standalone .json/.yaml/.yml/.md/.txt entries get a standard Bundle; other file types require explicit metadata.",
|
|
427
|
+
"Occupied Names require --expect EXACT_OLD_ARTIFACT_CID. Published payloads are local CID pins; unpin CID releases that current protection, not legitimate history holders.",
|
|
339
428
|
"Different-name CAS contention is rebased; same-name edits conflict (exit 3).",
|
|
340
429
|
"Kubo pin confirmation precedes HEAD; it does not prove a remote device is online.",
|
|
341
430
|
],
|
|
@@ -358,6 +447,7 @@ const commandHelp: Record<
|
|
|
358
447
|
"Stdout contains only the absolute directory path; --json also returns content and original target CIDs.",
|
|
359
448
|
"Temporary exports remain after exit; copy before cleanup, not symlink. Use --output for a persistent destination.",
|
|
360
449
|
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
450
|
+
"Copy the reference from ipab search, or percent-encode the entire configuration URL and each Name path segment separately.",
|
|
361
451
|
"Does not install, build, edit, or automatically retrieve associated source.",
|
|
362
452
|
],
|
|
363
453
|
},
|
|
@@ -434,7 +524,9 @@ const commandHelp: Record<
|
|
|
434
524
|
},
|
|
435
525
|
"bundle inspect": {
|
|
436
526
|
summary: "Inspect a Bundle or type definition",
|
|
437
|
-
arguments: [
|
|
527
|
+
arguments: [
|
|
528
|
+
"SOURCE Directory, definition file, CAR, CID or packaged builtin reference.",
|
|
529
|
+
],
|
|
438
530
|
examples: ["ipab bundle inspect note\\dist\\bundle.car"],
|
|
439
531
|
notes: ["Does not execute Apps, import content or create pins."],
|
|
440
532
|
},
|
|
@@ -444,11 +536,11 @@ const commandHelp: Record<
|
|
|
444
536
|
examples: ["ipab bundle import hello\\dist\\app.car"],
|
|
445
537
|
notes: [
|
|
446
538
|
"Repeated imports are safe; no App execution or daemon startup.",
|
|
447
|
-
"Does not pin or retain content. Use pin
|
|
539
|
+
"Does not pin or retain content. Use pin CID for persistent retention.",
|
|
448
540
|
],
|
|
449
541
|
},
|
|
450
542
|
exec: {
|
|
451
|
-
summary: "Run an App by CID
|
|
543
|
+
summary: "Run an App by exact CID or Swarm IPAB URI",
|
|
452
544
|
arguments: [
|
|
453
545
|
"APP_ARGS Everything after APP is passed verbatim, including --help.",
|
|
454
546
|
],
|
|
@@ -472,7 +564,9 @@ const commandHelp: Record<
|
|
|
472
564
|
},
|
|
473
565
|
open: {
|
|
474
566
|
summary: "Open content with its registered App",
|
|
475
|
-
arguments: [
|
|
567
|
+
arguments: [
|
|
568
|
+
"CONTENT Bundle CID, packaged builtin reference or Swarm IPAB URI.",
|
|
569
|
+
],
|
|
476
570
|
options: [
|
|
477
571
|
"--log Record stdout/stderr; requires history enabled.",
|
|
478
572
|
"--raw Open the Artifact node rather than its value.",
|
|
@@ -486,86 +580,107 @@ const commandHelp: Record<
|
|
|
486
580
|
],
|
|
487
581
|
notes: [
|
|
488
582
|
"Requires a saved registration and App support for the exact content type.",
|
|
583
|
+
"Uses only the content URI's Swarm, otherwise --swarm, otherwise swarm.default. A selected Swarm is required.",
|
|
584
|
+
"A registered App's retrieval, compatibility or execution failure never triggers fallback.",
|
|
585
|
+
"Legacy User registrations are inactive and preserved in the state database's legacy_user_registrations table; review them before explicit Swarm registration.",
|
|
489
586
|
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
490
587
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
491
588
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
492
589
|
"--json is not supported; App stdio is passed through.",
|
|
493
590
|
],
|
|
494
591
|
},
|
|
495
|
-
|
|
496
|
-
summary: "
|
|
592
|
+
pin: {
|
|
593
|
+
summary: "Retain an immutable CID or follow a shared Swarm Name",
|
|
497
594
|
arguments: [
|
|
498
|
-
"
|
|
499
|
-
|
|
595
|
+
"REF Exact Bundle CID or ipab://SWARM/NAME; no local content aliases.",
|
|
596
|
+
],
|
|
597
|
+
examples: [
|
|
598
|
+
"ipab pin APP_CID",
|
|
599
|
+
"ipab pin ipab://work/apps/reader",
|
|
600
|
+
"ipab pin list",
|
|
500
601
|
],
|
|
501
|
-
examples: ["ipab pin add reader APP_CID"],
|
|
502
602
|
notes: [
|
|
503
603
|
"Validates a complete Bundle and retains its full DAG in the configured Store.",
|
|
504
|
-
"
|
|
604
|
+
"A CID stays fixed. A shared Name saves its canonical configuration URL and exact Name, refreshing on related Swarm HEAD reads/sync, not continuously.",
|
|
605
|
+
"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.",
|
|
606
|
+
"Does not execute Apps or install dependencies. Shared Names connect to their Swarm content source only as needed.",
|
|
505
607
|
"The builtin namespace is read-only.",
|
|
506
608
|
],
|
|
507
609
|
},
|
|
508
|
-
|
|
509
|
-
summary: "
|
|
510
|
-
examples: ["ipab
|
|
610
|
+
unpin: {
|
|
611
|
+
summary: "Release a CID pin or stop following a shared Name",
|
|
612
|
+
examples: ["ipab unpin APP_CID", "ipab unpin ipab://work/apps/reader"],
|
|
511
613
|
notes: [
|
|
512
614
|
"Releases only this pin's ownership on its original backend; no block deletion or GC.",
|
|
513
|
-
"
|
|
615
|
+
"Never re-resolves a shared Name to release content. Uses only saved actual roots. Missing pins are success.",
|
|
616
|
+
"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.",
|
|
617
|
+
"Publication/history owners are independent; --snapshot payloads remain recursively retained by publication history after ordinary unpin.",
|
|
514
618
|
],
|
|
515
619
|
},
|
|
516
620
|
"pin list": {
|
|
517
|
-
summary: "List
|
|
518
|
-
|
|
519
|
-
"--type TYPE Exact type CID or the name of a Bundle pin of that type.",
|
|
520
|
-
],
|
|
521
|
-
examples: ["ipab pin list", "ipab pin list --type reader"],
|
|
621
|
+
summary: "List local retention, following Names and packaged built-ins",
|
|
622
|
+
examples: ["ipab pin list"],
|
|
522
623
|
notes: [
|
|
523
|
-
"
|
|
524
|
-
"Legacy retention is preserved; use
|
|
624
|
+
"Includes pending/stale/missing records and inactive archived local pin names.",
|
|
625
|
+
"Legacy retention is preserved; use unpin EXACT_CID to explicitly release its archived holders.",
|
|
525
626
|
"Reads local registrations and packaged built-ins, not live node status.",
|
|
526
627
|
],
|
|
527
628
|
},
|
|
528
629
|
"pin show": {
|
|
529
|
-
summary: "Show
|
|
530
|
-
examples: ["ipab pin show
|
|
630
|
+
summary: "Show saved retention and following status",
|
|
631
|
+
examples: ["ipab pin show APP_CID", "ipab pin show builtin:template.node"],
|
|
531
632
|
notes: [
|
|
532
633
|
"Reads local metadata; built-in pins do not claim user Store retention.",
|
|
533
634
|
],
|
|
534
635
|
},
|
|
535
|
-
"pin rename": {
|
|
536
|
-
summary: "Rename a user pin without changing its content",
|
|
537
|
-
examples: ["ipab pin rename reader my-reader"],
|
|
538
|
-
notes: [
|
|
539
|
-
"NEW_NAME must be unused. Built-in pins are read-only.",
|
|
540
|
-
"CID, ownership, registrations and history are unchanged.",
|
|
541
|
-
],
|
|
542
|
-
},
|
|
543
636
|
"register list": {
|
|
544
637
|
summary: "List saved content-type associations",
|
|
545
|
-
|
|
638
|
+
options: [
|
|
639
|
+
"--swarm URL_OR_ALIAS Read this Swarm registry; repeat for multiple Swarms.",
|
|
640
|
+
],
|
|
641
|
+
examples: ["ipab register list", "ipab register list --swarm work"],
|
|
642
|
+
notes: [
|
|
643
|
+
"Without explicit --swarm, reads the saved default Swarm. Select one with --swarm or ipab swarm use.",
|
|
644
|
+
"Legacy User registrations are inactive and preserved in legacy_user_registrations; no automatic upload or deletion.",
|
|
645
|
+
],
|
|
546
646
|
},
|
|
547
647
|
"register set": {
|
|
548
648
|
summary: "Associate a content type with an App",
|
|
549
649
|
arguments: [
|
|
550
650
|
"SCHEMA Exact type CID or builtin:node-app.v1.",
|
|
551
|
-
"APP App CID or
|
|
651
|
+
"APP App CID or Swarm IPAB URI; the exact CID is saved.",
|
|
552
652
|
"TEMPLATE App argv after --; must contain a whole argument % (default: %).",
|
|
553
653
|
],
|
|
554
|
-
options: [
|
|
654
|
+
options: [
|
|
655
|
+
"--replace Allow changing an existing association.",
|
|
656
|
+
"--swarm URL_OR_ALIAS Write this Swarm registry; repeat for multiple Swarms.",
|
|
657
|
+
],
|
|
555
658
|
examples: [
|
|
556
659
|
"ipab register set SCHEMA_CID reader",
|
|
557
660
|
"ipab register set SCHEMA_CID reader '--' '--cid' '%'",
|
|
661
|
+
"ipab register set SCHEMA_CID ipab:///apps/reader --swarm work --swarm team",
|
|
558
662
|
],
|
|
559
663
|
notes: [
|
|
560
664
|
"Replaces only the whole % argument with the content CID; no shell expansion.",
|
|
561
665
|
"Does not verify App type support; open checks it before execution.",
|
|
666
|
+
"Without explicit --swarm, writes the saved default Swarm. Swarm writes require HEAD write access.",
|
|
667
|
+
"Multiple Swarms commit sequentially, not atomically; failures report completed targets.",
|
|
562
668
|
],
|
|
563
669
|
},
|
|
564
670
|
"register remove": {
|
|
565
671
|
summary: "Remove a saved content-type association",
|
|
566
672
|
arguments: ["SCHEMA Exact type CID or builtin:node-app.v1."],
|
|
567
|
-
|
|
568
|
-
|
|
673
|
+
options: [
|
|
674
|
+
"--swarm URL_OR_ALIAS Remove from this Swarm registry; repeat for multiple Swarms.",
|
|
675
|
+
],
|
|
676
|
+
examples: [
|
|
677
|
+
"ipab register remove SCHEMA_CID",
|
|
678
|
+
"ipab register remove SCHEMA_CID --swarm work",
|
|
679
|
+
],
|
|
680
|
+
notes: [
|
|
681
|
+
"Without explicit --swarm, removes from the saved default Swarm. Multiple Swarm edits are not atomic.",
|
|
682
|
+
"Does not remove Apps, pins or content.",
|
|
683
|
+
],
|
|
569
684
|
},
|
|
570
685
|
"config get": {
|
|
571
686
|
summary: "Show effective configuration",
|
|
@@ -583,7 +698,7 @@ const commandHelp: Record<
|
|
|
583
698
|
"store.gateway is a read-only HTTP gateway; blocks, pins and GC remain local.",
|
|
584
699
|
"pointers.service is a canonical HTTPS origin (HTTP loopback allowed).",
|
|
585
700
|
"pointers.apiKey is accepted only through stdin using VALUE '-'; queries and confirmations redact it.",
|
|
586
|
-
"
|
|
701
|
+
"SQLite state is account-only even without a key. Reading or saving a nonempty key rechecks Unix modes or Windows ACLs.",
|
|
587
702
|
],
|
|
588
703
|
},
|
|
589
704
|
"config reset": {
|
|
@@ -593,7 +708,7 @@ const commandHelp: Record<
|
|
|
593
708
|
"history list": {
|
|
594
709
|
summary: "List execution history",
|
|
595
710
|
options: [
|
|
596
|
-
"--app APP Filter by App CID
|
|
711
|
+
"--app APP Filter by exact App CID.",
|
|
597
712
|
"--status STATUS succeeded, failed or cancelled.",
|
|
598
713
|
"--since TIME Include runs ended at or after TIME.",
|
|
599
714
|
"--until TIME Include runs ended before TIME.",
|
|
@@ -616,7 +731,7 @@ const commandHelp: Record<
|
|
|
616
731
|
"history remove": {
|
|
617
732
|
summary: "Remove execution records and their logs",
|
|
618
733
|
options: [
|
|
619
|
-
"--app APP Filter by App CID
|
|
734
|
+
"--app APP Filter by exact App CID.",
|
|
620
735
|
"--status STATUS succeeded, failed or cancelled.",
|
|
621
736
|
"--since TIME Include runs ended at or after TIME.",
|
|
622
737
|
"--until TIME Include runs ended before TIME.",
|
|
@@ -637,7 +752,7 @@ const commandHelp: Record<
|
|
|
637
752
|
export function help(path = ""): string {
|
|
638
753
|
const globalOptions = `Global options (before COMMAND):
|
|
639
754
|
--swarm URL|ALIAS Select shared swarm (otherwise swarm.default; URI swarm takes precedence)
|
|
640
|
-
--state-dir PATH Set
|
|
755
|
+
--state-dir PATH Set a dedicated, account-private local state directory
|
|
641
756
|
--store-gateway URL Use a read-only upstream HTTP gateway
|
|
642
757
|
--json Output management/development metadata, not App stdio`;
|
|
643
758
|
const footer =
|
|
@@ -657,12 +772,14 @@ Create:
|
|
|
657
772
|
bundle ${groups.bundle}
|
|
658
773
|
|
|
659
774
|
Manage:
|
|
660
|
-
|
|
775
|
+
doctor ${commandHelp.doctor!.summary}
|
|
776
|
+
profile ${commandHelp.profile!.summary}
|
|
661
777
|
swarm ${groups.swarm}
|
|
662
|
-
search Search formal Names
|
|
778
|
+
search Search formal Names in the current swarm
|
|
663
779
|
publish ${commandHelp.publish!.summary}
|
|
664
780
|
get ${commandHelp.get!.summary}
|
|
665
781
|
pin ${groups.pin}
|
|
782
|
+
unpin ${commandHelp.unpin!.summary}
|
|
666
783
|
register ${groups.register}
|
|
667
784
|
config ${groups.config}
|
|
668
785
|
store ${groups.store}
|
|
@@ -685,7 +802,25 @@ ${footer}`;
|
|
|
685
802
|
...(topic.arguments ? [section("Arguments", topic.arguments)] : []),
|
|
686
803
|
...(topic.options ? [section("Options", topic.options)] : []),
|
|
687
804
|
section("Examples", topic.examples),
|
|
688
|
-
...(
|
|
805
|
+
...([
|
|
806
|
+
"swarm status",
|
|
807
|
+
"swarm members",
|
|
808
|
+
"swarm update",
|
|
809
|
+
"swarm resume",
|
|
810
|
+
"swarm profile",
|
|
811
|
+
"swarm export",
|
|
812
|
+
"swarm approve",
|
|
813
|
+
"swarm exclude",
|
|
814
|
+
].includes(path)
|
|
815
|
+
? [
|
|
816
|
+
section("Notes", [
|
|
817
|
+
...(topic.notes ?? []),
|
|
818
|
+
"Select only with global --swarm URL_OR_ALIAS (before the command), or the saved swarm.default. Neither means an error.",
|
|
819
|
+
]),
|
|
820
|
+
]
|
|
821
|
+
: topic.notes
|
|
822
|
+
? [section("Notes", topic.notes)]
|
|
823
|
+
: []),
|
|
689
824
|
`\n\n-h, --help shows this help. Global options: see 'ipab --help'.\n${footer}`,
|
|
690
825
|
].join("");
|
|
691
826
|
}
|
|
@@ -714,6 +849,19 @@ function printable(text: string): string {
|
|
|
714
849
|
.join("");
|
|
715
850
|
}
|
|
716
851
|
|
|
852
|
+
export function formatSearchResults(
|
|
853
|
+
matches: Awaited<ReturnType<typeof searchNames>>["matches"],
|
|
854
|
+
): string {
|
|
855
|
+
return matches.length
|
|
856
|
+
? matches
|
|
857
|
+
.map(
|
|
858
|
+
(match) =>
|
|
859
|
+
`${printable(match.alias ?? match.swarm)} ${printable(match.name)} ${match.targetCid}\n ipab get ${formatNameReference(match.alias ?? match.swarm, match.name)}`,
|
|
860
|
+
)
|
|
861
|
+
.join("\n")
|
|
862
|
+
: "No matching Names.";
|
|
863
|
+
}
|
|
864
|
+
|
|
717
865
|
function runTime(value: string, field: "start" | "end"): string {
|
|
718
866
|
const date = new Date(value);
|
|
719
867
|
if (!Number.isFinite(date.getTime()))
|
|
@@ -815,6 +963,7 @@ interface Parsed {
|
|
|
815
963
|
options: Record<string, string | boolean>;
|
|
816
964
|
template?: string[];
|
|
817
965
|
parameters?: string[];
|
|
966
|
+
registrySwarms?: string[];
|
|
818
967
|
help: boolean;
|
|
819
968
|
version: boolean;
|
|
820
969
|
}
|
|
@@ -838,6 +987,7 @@ async function closeStore(
|
|
|
838
987
|
export function parse(argv: readonly string[]): Parsed {
|
|
839
988
|
const tokens = [...argv];
|
|
840
989
|
const flags: GlobalOptions = { json: false };
|
|
990
|
+
const swarms: string[] = [];
|
|
841
991
|
while (tokens[0]?.startsWith("-")) {
|
|
842
992
|
const flag = tokens.shift()!;
|
|
843
993
|
if (flag === "-h" || flag === "--help")
|
|
@@ -873,8 +1023,10 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
873
1023
|
const value = tokens.shift();
|
|
874
1024
|
if (!value || value.startsWith("-")) syntax(`${flag} needs a value.`);
|
|
875
1025
|
if (flag === "--state-dir") flags.stateDir = value;
|
|
876
|
-
else if (flag === "--swarm")
|
|
877
|
-
|
|
1026
|
+
else if (flag === "--swarm") {
|
|
1027
|
+
flags.swarm = value;
|
|
1028
|
+
swarms.push(value);
|
|
1029
|
+
} else {
|
|
878
1030
|
flags.storeGateway = publicUrl(value);
|
|
879
1031
|
}
|
|
880
1032
|
} else syntax(`Unknown global option "${flag}".`);
|
|
@@ -887,6 +1039,7 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
887
1039
|
options: {},
|
|
888
1040
|
help: !group,
|
|
889
1041
|
version: false,
|
|
1042
|
+
...(group === "register" ? { registrySwarms: swarms } : {}),
|
|
890
1043
|
};
|
|
891
1044
|
if (!group) return result;
|
|
892
1045
|
if (group === "exec") {
|
|
@@ -909,9 +1062,17 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
909
1062
|
return result;
|
|
910
1063
|
}
|
|
911
1064
|
if (
|
|
912
|
-
![
|
|
913
|
-
|
|
914
|
-
|
|
1065
|
+
![
|
|
1066
|
+
"open",
|
|
1067
|
+
"init",
|
|
1068
|
+
"build",
|
|
1069
|
+
"publish",
|
|
1070
|
+
"get",
|
|
1071
|
+
"search",
|
|
1072
|
+
"doctor",
|
|
1073
|
+
"profile",
|
|
1074
|
+
"unpin",
|
|
1075
|
+
].includes(group)
|
|
915
1076
|
) {
|
|
916
1077
|
if (
|
|
917
1078
|
![
|
|
@@ -924,12 +1085,18 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
924
1085
|
"swarm",
|
|
925
1086
|
].includes(group)
|
|
926
1087
|
)
|
|
927
|
-
syntax(
|
|
928
|
-
|
|
1088
|
+
syntax(
|
|
1089
|
+
`Unknown command "${group}".${group === "setup" ? " Run ipab doctor to inspect, or ipab doctor --fix to prepare this device." : " Run ipab --help."}`,
|
|
1090
|
+
);
|
|
1091
|
+
if (group === "pin" && !["list", "show"].includes(tokens[0] ?? "")) {
|
|
1092
|
+
if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
|
|
1093
|
+
result.help = true;
|
|
1094
|
+
return result;
|
|
1095
|
+
}
|
|
1096
|
+
} else if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
|
|
929
1097
|
result.help = true;
|
|
930
1098
|
return result;
|
|
931
|
-
}
|
|
932
|
-
result.path = `${group} ${tokens.shift()!}`;
|
|
1099
|
+
} else result.path = `${group} ${tokens.shift()!}`;
|
|
933
1100
|
} else if (group === "open" && flags.json)
|
|
934
1101
|
syntax("--json is not supported for exec/open.");
|
|
935
1102
|
if (!commands[result.path]) syntax(`Unknown command "${result.path}".`);
|
|
@@ -949,8 +1116,8 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
949
1116
|
"API key must be provided through '-' and piped stdin; never pass it in command arguments.",
|
|
950
1117
|
);
|
|
951
1118
|
const booleans =
|
|
952
|
-
result.path === "
|
|
953
|
-
? ["yes"]
|
|
1119
|
+
result.path === "doctor"
|
|
1120
|
+
? ["fix", "yes"]
|
|
954
1121
|
: result.path === "bundle build"
|
|
955
1122
|
? ["replace", "schema-only", "no-import"]
|
|
956
1123
|
: result.path === "build"
|
|
@@ -960,7 +1127,7 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
960
1127
|
: result.path === "get"
|
|
961
1128
|
? ["raw", "force", "no-force"]
|
|
962
1129
|
: result.path === "search"
|
|
963
|
-
? ["current", "force", "no-force"]
|
|
1130
|
+
? ["all", "current", "force", "no-force"]
|
|
964
1131
|
: result.path === "swarm approve"
|
|
965
1132
|
? ["yes", "again"]
|
|
966
1133
|
: result.path === "swarm status"
|
|
@@ -980,17 +1147,17 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
980
1147
|
: result.path === "swarm add"
|
|
981
1148
|
? ["alias"]
|
|
982
1149
|
: result.path === "swarm request"
|
|
983
|
-
? ["
|
|
1150
|
+
? ["alias", "output"]
|
|
984
1151
|
: result.path === "swarm export"
|
|
985
1152
|
? ["output"]
|
|
986
1153
|
: result.path === "swarm profile"
|
|
987
|
-
? ["
|
|
988
|
-
: result.path === "swarm update"
|
|
1154
|
+
? ["address"]
|
|
1155
|
+
: result.path === "swarm update" || result.path === "profile"
|
|
989
1156
|
? ["name", "description"]
|
|
990
1157
|
: result.path === "swarm approve"
|
|
991
1158
|
? []
|
|
992
1159
|
: result.path === "publish"
|
|
993
|
-
? ["
|
|
1160
|
+
? ["expect"]
|
|
994
1161
|
: result.path === "get"
|
|
995
1162
|
? ["output"]
|
|
996
1163
|
: result.path === "init"
|
|
@@ -1009,9 +1176,7 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1009
1176
|
]
|
|
1010
1177
|
: result.path === "history remove"
|
|
1011
1178
|
? ["app", "status", "since", "until"]
|
|
1012
|
-
:
|
|
1013
|
-
? ["type"]
|
|
1014
|
-
: [];
|
|
1179
|
+
: [];
|
|
1015
1180
|
while (tokens.length) {
|
|
1016
1181
|
const value = tokens.shift()!;
|
|
1017
1182
|
if (
|
|
@@ -1021,6 +1186,13 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1021
1186
|
result.positional.push(value);
|
|
1022
1187
|
} else if (value.startsWith("--") || value === "-o") {
|
|
1023
1188
|
const option = value === "-o" ? "output" : value.slice(2);
|
|
1189
|
+
if (result.path.startsWith("register ") && option === "swarm") {
|
|
1190
|
+
const input = tokens.shift();
|
|
1191
|
+
if (!input || input.startsWith("-")) syntax("--swarm needs a value.");
|
|
1192
|
+
result.registrySwarms!.push(input);
|
|
1193
|
+
flags.swarm = input;
|
|
1194
|
+
continue;
|
|
1195
|
+
}
|
|
1024
1196
|
if (result.path === "init" && option === "param") {
|
|
1025
1197
|
const input = tokens.shift();
|
|
1026
1198
|
if (!input || input.startsWith("--") || input.indexOf("=") < 1)
|
|
@@ -1036,15 +1208,19 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1036
1208
|
if (
|
|
1037
1209
|
input === undefined ||
|
|
1038
1210
|
(input.startsWith("--") &&
|
|
1039
|
-
!(
|
|
1040
|
-
|
|
1041
|
-
/^[A-Za-z0-9_-]{43}$/.test(input)
|
|
1042
|
-
)) ||
|
|
1043
|
-
(input === "" && result.path !== "swarm update")
|
|
1211
|
+
!(option === "resume" && /^[A-Za-z0-9_-]{43}$/.test(input))) ||
|
|
1212
|
+
(input === "" && !["swarm update", "profile"].includes(result.path))
|
|
1044
1213
|
)
|
|
1045
1214
|
syntax(`${value} needs a value.`);
|
|
1046
1215
|
result.options[option] = input;
|
|
1047
|
-
} else
|
|
1216
|
+
} else if (
|
|
1217
|
+
option === "name" &&
|
|
1218
|
+
["swarm profile", "swarm request"].includes(result.path)
|
|
1219
|
+
)
|
|
1220
|
+
syntax(
|
|
1221
|
+
`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." : ""}`,
|
|
1222
|
+
);
|
|
1223
|
+
else syntax(`Unknown option "${value}".`);
|
|
1048
1224
|
} else result.positional.push(value);
|
|
1049
1225
|
}
|
|
1050
1226
|
if (result.options.force && result.options["no-force"])
|
|
@@ -1055,22 +1231,30 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1055
1231
|
flags.swarm !== undefined
|
|
1056
1232
|
)
|
|
1057
1233
|
syntax("--current and --swarm are mutually exclusive.");
|
|
1234
|
+
if (
|
|
1235
|
+
result.path === "search" &&
|
|
1236
|
+
result.options.all &&
|
|
1237
|
+
(result.options.current || flags.swarm !== undefined)
|
|
1238
|
+
)
|
|
1239
|
+
syntax("--all is mutually exclusive with --current and --swarm.");
|
|
1058
1240
|
const counts: Record<string, [number, number]> = {
|
|
1059
|
-
|
|
1241
|
+
doctor: [0, 0],
|
|
1242
|
+
profile: [0, 0],
|
|
1060
1243
|
"swarm create": [0, 0],
|
|
1061
1244
|
"swarm request": [1, 1],
|
|
1062
1245
|
"swarm approve": [1, 1],
|
|
1063
|
-
"swarm export": [
|
|
1246
|
+
"swarm export": [0, 0],
|
|
1064
1247
|
"swarm exclude": [1, 1],
|
|
1065
|
-
"swarm resume": [0,
|
|
1066
|
-
"swarm profile": [0,
|
|
1067
|
-
"swarm status": [0,
|
|
1248
|
+
"swarm resume": [0, 0],
|
|
1249
|
+
"swarm profile": [0, 0],
|
|
1250
|
+
"swarm status": [0, 0],
|
|
1251
|
+
"swarm members": [0, 0],
|
|
1068
1252
|
"swarm list": [0, 0],
|
|
1069
1253
|
"swarm add": [1, 1],
|
|
1070
1254
|
"swarm use": [1, 1],
|
|
1071
1255
|
"swarm remove": [1, 1],
|
|
1072
|
-
"swarm update": [0,
|
|
1073
|
-
publish: [
|
|
1256
|
+
"swarm update": [0, 0],
|
|
1257
|
+
publish: [2, 2],
|
|
1074
1258
|
get: [1, 1],
|
|
1075
1259
|
search: [1, 1],
|
|
1076
1260
|
init: [1, 2],
|
|
@@ -1079,11 +1263,10 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1079
1263
|
"bundle inspect": [1, 1],
|
|
1080
1264
|
"bundle import": [1, 1],
|
|
1081
1265
|
open: [1, 1],
|
|
1082
|
-
|
|
1083
|
-
|
|
1266
|
+
pin: [1, 1],
|
|
1267
|
+
unpin: [1, 1],
|
|
1084
1268
|
"pin list": [0, 0],
|
|
1085
1269
|
"pin show": [1, 1],
|
|
1086
|
-
"pin rename": [2, 2],
|
|
1087
1270
|
"register list": [0, 0],
|
|
1088
1271
|
"register set": [2, 2],
|
|
1089
1272
|
"register remove": [1, 1],
|
|
@@ -1099,6 +1282,22 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1099
1282
|
if (result.options["with-source"] && result.options["without-source"])
|
|
1100
1283
|
syntax("--with-source and --without-source are mutually exclusive.");
|
|
1101
1284
|
const [minimum, maximum] = counts[result.path]!;
|
|
1285
|
+
if (result.path === "profile" && flags.swarm !== undefined)
|
|
1286
|
+
syntax("Personal profile is account-wide; do not pass --swarm.");
|
|
1287
|
+
if (
|
|
1288
|
+
result.positional.length &&
|
|
1289
|
+
[
|
|
1290
|
+
"swarm status",
|
|
1291
|
+
"swarm update",
|
|
1292
|
+
"swarm resume",
|
|
1293
|
+
"swarm profile",
|
|
1294
|
+
"swarm export",
|
|
1295
|
+
"swarm members",
|
|
1296
|
+
].includes(result.path)
|
|
1297
|
+
)
|
|
1298
|
+
syntax(
|
|
1299
|
+
`Swarm target positionals are no longer supported. Use ipab --swarm URL_OR_ALIAS ${result.path} instead.`,
|
|
1300
|
+
);
|
|
1102
1301
|
if (result.positional.length < minimum || result.positional.length > maximum)
|
|
1103
1302
|
syntax(`Invalid arguments.\n${help(result.path)}`);
|
|
1104
1303
|
if (
|
|
@@ -1117,10 +1316,26 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1117
1316
|
syntax("history remove requires explicit IDs OR filters, not both.");
|
|
1118
1317
|
}
|
|
1119
1318
|
// Validate syntactic values before state access, let alone a backend connection.
|
|
1120
|
-
if (
|
|
1121
|
-
|
|
1122
|
-
if (result.path
|
|
1123
|
-
|
|
1319
|
+
if (["pin", "unpin", "pin show"].includes(result.path)) {
|
|
1320
|
+
const reference = result.positional[0]!;
|
|
1321
|
+
if (reference.startsWith("builtin:") && result.path !== "pin show")
|
|
1322
|
+
syntax(
|
|
1323
|
+
"Packaged builtin references are read-only; they cannot be pinned or unpinned.",
|
|
1324
|
+
);
|
|
1325
|
+
if (
|
|
1326
|
+
!(result.path === "pin show" && reference.startsWith("builtin:")) &&
|
|
1327
|
+
!parseNameReference(reference)
|
|
1328
|
+
)
|
|
1329
|
+
exactCid(reference);
|
|
1330
|
+
}
|
|
1331
|
+
if (result.path === "publish") {
|
|
1332
|
+
formalName(result.positional[0]!);
|
|
1333
|
+
if (typeof result.options.expect === "string")
|
|
1334
|
+
exactCid(result.options.expect);
|
|
1335
|
+
if (result.options.expect && result.options.snapshot)
|
|
1336
|
+
syntax(
|
|
1337
|
+
"--snapshot is initial-only and cannot be combined with --expect.",
|
|
1338
|
+
);
|
|
1124
1339
|
}
|
|
1125
1340
|
if (result.path.startsWith("config ") && result.positional[0]) {
|
|
1126
1341
|
if (
|
|
@@ -1142,6 +1357,8 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1142
1357
|
parseValue("history.limit", result.options.limit, true);
|
|
1143
1358
|
if (result.options.output === "-")
|
|
1144
1359
|
syntax("CAR output requires a file path; binary stdout is not supported.");
|
|
1360
|
+
if (result.path === "doctor" && result.options.yes && !result.options.fix)
|
|
1361
|
+
syntax("doctor --yes requires --fix.");
|
|
1145
1362
|
return result;
|
|
1146
1363
|
}
|
|
1147
1364
|
|
|
@@ -1153,6 +1370,7 @@ async function performCli(
|
|
|
1153
1370
|
let state: State | undefined;
|
|
1154
1371
|
let store: IpfsStore | undefined;
|
|
1155
1372
|
let appExitCode: number | undefined;
|
|
1373
|
+
let readContext: SwarmContext | undefined;
|
|
1156
1374
|
try {
|
|
1157
1375
|
const parsed = parse(argv);
|
|
1158
1376
|
if (parsed.help) {
|
|
@@ -1173,30 +1391,44 @@ async function performCli(
|
|
|
1173
1391
|
}
|
|
1174
1392
|
if (parsed.path === "history remove" && !parsed.options.yes && !io.tty)
|
|
1175
1393
|
syntax("Non-interactive history remove requires --yes.");
|
|
1176
|
-
if (parsed.path === "
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
(
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1394
|
+
if (parsed.path === "doctor") {
|
|
1395
|
+
const controller = new AbortController();
|
|
1396
|
+
const interrupt = () => {
|
|
1397
|
+
controller.abort(new HostError("Doctor interrupted.", 130, "ABORTED"));
|
|
1398
|
+
};
|
|
1399
|
+
const terminate = () => {
|
|
1400
|
+
controller.abort(new HostError("Doctor terminated.", 143, "ABORTED"));
|
|
1401
|
+
};
|
|
1402
|
+
process.once("SIGINT", interrupt);
|
|
1403
|
+
process.once("SIGTERM", terminate);
|
|
1404
|
+
try {
|
|
1405
|
+
const result = await doctorDevice(
|
|
1406
|
+
stateLocation(parsed.flags, env).path,
|
|
1407
|
+
env,
|
|
1408
|
+
{
|
|
1409
|
+
diagnostic: (text, progress) => {
|
|
1410
|
+
io.err(text, progress);
|
|
1411
|
+
},
|
|
1412
|
+
signal: controller.signal,
|
|
1413
|
+
fix: Boolean(parsed.options.fix),
|
|
1414
|
+
yes: Boolean(parsed.options.yes),
|
|
1415
|
+
tty: io.tty,
|
|
1416
|
+
confirm: (text, signal) => io.confirm(text, signal),
|
|
1417
|
+
},
|
|
1186
1418
|
);
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
? JSON.stringify(result)
|
|
1194
|
-
: `Kubo ${result.kuboVersion}: ${result.binary}\nAccount fingerprint: ${result.fingerprint}\nReady. Nodes start only when a Swarm is used.`,
|
|
1195
|
-
);
|
|
1196
|
-
return 0;
|
|
1419
|
+
io.out(parsed.flags.json ? JSON.stringify(result) : doctorText(result));
|
|
1420
|
+
return result.ready ? 0 : 1;
|
|
1421
|
+
} finally {
|
|
1422
|
+
process.removeListener("SIGINT", interrupt);
|
|
1423
|
+
process.removeListener("SIGTERM", terminate);
|
|
1424
|
+
}
|
|
1197
1425
|
}
|
|
1198
1426
|
const builtins = await builtinContent();
|
|
1199
|
-
state = new State(
|
|
1427
|
+
state = new State(
|
|
1428
|
+
stateLocation(parsed.flags, env).path,
|
|
1429
|
+
builtins.pins,
|
|
1430
|
+
env,
|
|
1431
|
+
);
|
|
1200
1432
|
if (
|
|
1201
1433
|
parsed.path === "config reset" &&
|
|
1202
1434
|
parsed.positional[0] === "store.rpc"
|
|
@@ -1212,7 +1444,8 @@ async function performCli(
|
|
|
1212
1444
|
const items = effectiveConfig(
|
|
1213
1445
|
state.config({
|
|
1214
1446
|
includeSecrets:
|
|
1215
|
-
|
|
1447
|
+
!["swarm members", "profile", "swarm status"].includes(parsed.path) ||
|
|
1448
|
+
Boolean(parsed.options.local),
|
|
1216
1449
|
}),
|
|
1217
1450
|
parsed.flags,
|
|
1218
1451
|
env,
|
|
@@ -1228,6 +1461,13 @@ async function performCli(
|
|
|
1228
1461
|
value("swarm.default") === null
|
|
1229
1462
|
? undefined
|
|
1230
1463
|
: String(value("swarm.default"));
|
|
1464
|
+
const requireSwarm = () => {
|
|
1465
|
+
if (!selectedSwarm)
|
|
1466
|
+
syntax(
|
|
1467
|
+
"Select a Swarm with ipab --swarm URL_OR_ALIAS, or save a default with ipab swarm use URL_OR_ALIAS.",
|
|
1468
|
+
);
|
|
1469
|
+
return selectedSwarm;
|
|
1470
|
+
};
|
|
1231
1471
|
const swarmContext = (): SwarmContext => ({
|
|
1232
1472
|
get store() {
|
|
1233
1473
|
return store!;
|
|
@@ -1259,19 +1499,169 @@ async function performCli(
|
|
|
1259
1499
|
? filters(state, parsed.options)
|
|
1260
1500
|
: {};
|
|
1261
1501
|
const selection = () => {
|
|
1262
|
-
const
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
env,
|
|
1266
|
-
(reference) => state!.resolveSwarm(reference),
|
|
1502
|
+
const saved = state!.config({ includeSecrets: false });
|
|
1503
|
+
const current = effectiveConfig(saved, parsed.flags, env, (reference) =>
|
|
1504
|
+
state!.resolveSwarm(reference),
|
|
1267
1505
|
).find((item) => item.key === "swarm.default")!;
|
|
1268
1506
|
return {
|
|
1269
|
-
savedCurrent:
|
|
1507
|
+
savedCurrent: saved["swarm.default"] ?? null,
|
|
1270
1508
|
effectiveCurrent: current.value,
|
|
1271
1509
|
source: current.source,
|
|
1272
1510
|
};
|
|
1273
1511
|
};
|
|
1512
|
+
if (parsed.path === "open" || parsed.path.startsWith("register ")) {
|
|
1513
|
+
if (state.legacyRegistrationCount)
|
|
1514
|
+
io.err(
|
|
1515
|
+
`Legacy User registrations are inactive. ${state.legacyRegistrationCount} entries are preserved in legacy_user_registrations in the state database under ${state.directory}; nothing was uploaded or deleted. Review the archived values and explicitly run ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS [-- TEMPLATE...] to publish only intended associations.`,
|
|
1516
|
+
);
|
|
1517
|
+
}
|
|
1518
|
+
if (state.legacyPinCount)
|
|
1519
|
+
io.err(
|
|
1520
|
+
`Legacy local pin names are inactive: ${state.legacyPinCount} records are preserved in legacy_named_pins under ${state.directory}. Retention and original Store owners are unchanged; inspect ipab pin list and release intended archived holders with ipab unpin EXACT_CID.`,
|
|
1521
|
+
);
|
|
1522
|
+
if (parsed.path.startsWith("register ")) {
|
|
1523
|
+
const references = parsed.registrySwarms?.length
|
|
1524
|
+
? parsed.registrySwarms
|
|
1525
|
+
: selectedSwarm
|
|
1526
|
+
? [selectedSwarm]
|
|
1527
|
+
: [];
|
|
1528
|
+
if (!references.length)
|
|
1529
|
+
throw new HostError(
|
|
1530
|
+
"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.",
|
|
1531
|
+
);
|
|
1532
|
+
const targets = [
|
|
1533
|
+
...new Set(
|
|
1534
|
+
references.map((reference) => state!.resolveSwarm(reference)),
|
|
1535
|
+
),
|
|
1536
|
+
];
|
|
1537
|
+
const schema = first
|
|
1538
|
+
? state.resolve(schemaAlias(first), true)
|
|
1539
|
+
: undefined;
|
|
1540
|
+
const results: (
|
|
1541
|
+
| {
|
|
1542
|
+
items: Association[];
|
|
1543
|
+
}
|
|
1544
|
+
| {
|
|
1545
|
+
association: Association;
|
|
1546
|
+
}
|
|
1547
|
+
| {
|
|
1548
|
+
removed: string[];
|
|
1549
|
+
}
|
|
1550
|
+
)[] = [];
|
|
1551
|
+
const completed: string[] = [];
|
|
1552
|
+
const human: string[] = [];
|
|
1553
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1554
|
+
for (const configUrl of targets) {
|
|
1555
|
+
const context = swarmContext();
|
|
1556
|
+
try {
|
|
1557
|
+
if (parsed.path === "register list") {
|
|
1558
|
+
const items = await swarmRegistrations(context, configUrl);
|
|
1559
|
+
results.push({ items });
|
|
1560
|
+
human.push(
|
|
1561
|
+
`${configUrl}\n${table(
|
|
1562
|
+
["SCHEMA CID", "APP CID", "ARGV"],
|
|
1563
|
+
items.map((item) => [
|
|
1564
|
+
item.schemaCid,
|
|
1565
|
+
item.appCid,
|
|
1566
|
+
JSON.stringify(item.argv),
|
|
1567
|
+
]),
|
|
1568
|
+
"No associations.",
|
|
1569
|
+
)}`,
|
|
1570
|
+
);
|
|
1571
|
+
} else if (parsed.path === "register set") {
|
|
1572
|
+
const appCid = parseNameReference(second!)
|
|
1573
|
+
? (
|
|
1574
|
+
await resolveReference(
|
|
1575
|
+
context,
|
|
1576
|
+
second!,
|
|
1577
|
+
configUrl,
|
|
1578
|
+
(reference) => state!.resolve(reference),
|
|
1579
|
+
)
|
|
1580
|
+
).cid
|
|
1581
|
+
: state.resolve(second!);
|
|
1582
|
+
const association = await setSwarmAssociation(
|
|
1583
|
+
context,
|
|
1584
|
+
configUrl,
|
|
1585
|
+
createAssociation(schema!, appCid, parsed.template ?? ["%"]),
|
|
1586
|
+
Boolean(parsed.options.replace),
|
|
1587
|
+
);
|
|
1588
|
+
results.push({ association });
|
|
1589
|
+
human.push(
|
|
1590
|
+
`${configUrl}: ${association.schemaCid} → ${association.appCid} ${JSON.stringify(association.argv)}`,
|
|
1591
|
+
);
|
|
1592
|
+
} else {
|
|
1593
|
+
const removed = await removeSwarmAssociation(
|
|
1594
|
+
context,
|
|
1595
|
+
configUrl,
|
|
1596
|
+
schema!,
|
|
1597
|
+
);
|
|
1598
|
+
results.push({ removed: [removed] });
|
|
1599
|
+
human.push(`${configUrl}: removed association for ${removed}.`);
|
|
1600
|
+
}
|
|
1601
|
+
completed.push(configUrl);
|
|
1602
|
+
} catch (cause) {
|
|
1603
|
+
throw new HostError(
|
|
1604
|
+
`Registry operation failed for ${configUrl}: ${message(cause)}. Completed Swarms: ${completed.length ? completed.join(", ") : "(none)"}. Multiple Swarm edits are not atomic.`,
|
|
1605
|
+
cause instanceof HostError ? cause.exitCode : 1,
|
|
1606
|
+
cause instanceof HostError ? cause.code : "REGISTRY_FAILED",
|
|
1607
|
+
"publication",
|
|
1608
|
+
);
|
|
1609
|
+
} finally {
|
|
1610
|
+
await context.finishRead?.();
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
emit(
|
|
1614
|
+
{
|
|
1615
|
+
swarms: results.map((result, index) => ({
|
|
1616
|
+
configUrl: targets[index],
|
|
1617
|
+
...result,
|
|
1618
|
+
})),
|
|
1619
|
+
},
|
|
1620
|
+
human.join("\n\n"),
|
|
1621
|
+
);
|
|
1622
|
+
return 0;
|
|
1623
|
+
}
|
|
1274
1624
|
switch (parsed.path) {
|
|
1625
|
+
case "profile": {
|
|
1626
|
+
const context = swarmContext();
|
|
1627
|
+
readContext = context;
|
|
1628
|
+
const changes = {
|
|
1629
|
+
...(typeof parsed.options.name === "string"
|
|
1630
|
+
? { name: parsed.options.name }
|
|
1631
|
+
: {}),
|
|
1632
|
+
...(typeof parsed.options.description === "string"
|
|
1633
|
+
? { description: parsed.options.description }
|
|
1634
|
+
: {}),
|
|
1635
|
+
};
|
|
1636
|
+
if (!Object.keys(changes).length) {
|
|
1637
|
+
const profile = await accountProfile(context);
|
|
1638
|
+
emit(
|
|
1639
|
+
{ profile, localPersisted: profile.updatedAt !== null },
|
|
1640
|
+
`Name: ${printable(profile.name)}\nDescription: ${printable(profile.description)}\nPublic key: ${profile.publicKey}`,
|
|
1641
|
+
);
|
|
1642
|
+
} else {
|
|
1643
|
+
const result = await updateAccountProfile(context, changes);
|
|
1644
|
+
emit(
|
|
1645
|
+
result,
|
|
1646
|
+
[
|
|
1647
|
+
`Name: ${printable(result.profile.name)}`,
|
|
1648
|
+
`Description: ${printable(result.profile.description)}`,
|
|
1649
|
+
"Personal profile saved locally.",
|
|
1650
|
+
...result.swarms.map(
|
|
1651
|
+
(entry) =>
|
|
1652
|
+
`${entry.configUrl}: ${entry.synchronized ? "synchronized" : `FAILED: ${entry.error}`}`,
|
|
1653
|
+
),
|
|
1654
|
+
].join("\n"),
|
|
1655
|
+
);
|
|
1656
|
+
if (result.swarms.some((entry) => !entry.synchronized)) {
|
|
1657
|
+
io.err(
|
|
1658
|
+
"Profile saved locally, but some Swarms failed. Retry the profile update or normally activate each failed membership to synchronize it.",
|
|
1659
|
+
);
|
|
1660
|
+
return 1;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
break;
|
|
1664
|
+
}
|
|
1275
1665
|
case "swarm list": {
|
|
1276
1666
|
const result = { swarms: state.swarms(), ...selection() };
|
|
1277
1667
|
emit(
|
|
@@ -1313,7 +1703,11 @@ async function performCli(
|
|
|
1313
1703
|
case "swarm remove": {
|
|
1314
1704
|
const removed = state.removeSwarm(first!);
|
|
1315
1705
|
emit(
|
|
1316
|
-
{
|
|
1706
|
+
{
|
|
1707
|
+
removed,
|
|
1708
|
+
savedCurrent:
|
|
1709
|
+
state.config({ includeSecrets: false })["swarm.default"] ?? null,
|
|
1710
|
+
},
|
|
1317
1711
|
`Removed registration ${removed}. Credentials, content and remote membership are unchanged.`,
|
|
1318
1712
|
);
|
|
1319
1713
|
break;
|
|
@@ -1328,15 +1722,49 @@ async function performCli(
|
|
|
1328
1722
|
case "swarm exclude":
|
|
1329
1723
|
case "swarm resume":
|
|
1330
1724
|
case "swarm profile":
|
|
1725
|
+
case "swarm members":
|
|
1331
1726
|
case "swarm status":
|
|
1332
1727
|
case "publish":
|
|
1728
|
+
case "pin":
|
|
1333
1729
|
case "get": {
|
|
1334
1730
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1335
1731
|
const context = swarmContext();
|
|
1732
|
+
readContext = context;
|
|
1733
|
+
if (parsed.path === "pin") {
|
|
1734
|
+
io.err("Fetching, verifying and retaining content...");
|
|
1735
|
+
const result = await pinNameSubscription(
|
|
1736
|
+
context,
|
|
1737
|
+
first!,
|
|
1738
|
+
selectedSwarm,
|
|
1739
|
+
);
|
|
1740
|
+
store = context.store;
|
|
1741
|
+
emit(
|
|
1742
|
+
result,
|
|
1743
|
+
`${result.reference} → ${result.cid}\nStatus: ${result.freshness}`,
|
|
1744
|
+
);
|
|
1745
|
+
break;
|
|
1746
|
+
}
|
|
1747
|
+
if (parsed.path === "swarm members") {
|
|
1748
|
+
const result = await swarmMembers(context, requireSwarm());
|
|
1749
|
+
emit(
|
|
1750
|
+
result,
|
|
1751
|
+
table(
|
|
1752
|
+
["NAME", "DESCRIPTION", "ROLE", "PUBLIC KEY"],
|
|
1753
|
+
result.members.map((member) => [
|
|
1754
|
+
member.name,
|
|
1755
|
+
member.description,
|
|
1756
|
+
member.role,
|
|
1757
|
+
member.publicKey,
|
|
1758
|
+
]),
|
|
1759
|
+
"No members.",
|
|
1760
|
+
),
|
|
1761
|
+
);
|
|
1762
|
+
break;
|
|
1763
|
+
}
|
|
1336
1764
|
if (parsed.path === "swarm export") {
|
|
1337
1765
|
const id = await exportRequest(
|
|
1338
1766
|
context,
|
|
1339
|
-
|
|
1767
|
+
requireSwarm(),
|
|
1340
1768
|
String(parsed.options.output ?? ""),
|
|
1341
1769
|
);
|
|
1342
1770
|
emit({ id }, id);
|
|
@@ -1347,13 +1775,7 @@ async function performCli(
|
|
|
1347
1775
|
parsed.path,
|
|
1348
1776
|
)
|
|
1349
1777
|
) {
|
|
1350
|
-
const url =
|
|
1351
|
-
parsed.path === "swarm exclude"
|
|
1352
|
-
? selectedSwarm
|
|
1353
|
-
: first
|
|
1354
|
-
? state.resolveSwarm(first)
|
|
1355
|
-
: selectedSwarm;
|
|
1356
|
-
if (!url) syntax("Select a Swarm configuration URL or alias.");
|
|
1778
|
+
const url = requireSwarm();
|
|
1357
1779
|
if (parsed.path === "swarm exclude") {
|
|
1358
1780
|
if (!parsed.options.yes)
|
|
1359
1781
|
syntax("Member removal is irreversible; --yes required.");
|
|
@@ -1362,9 +1784,6 @@ async function performCli(
|
|
|
1362
1784
|
await resumeRemoval(context, url);
|
|
1363
1785
|
else {
|
|
1364
1786
|
const profile = await updateProfile(context, url, {
|
|
1365
|
-
...(typeof parsed.options.name === "string"
|
|
1366
|
-
? { name: parsed.options.name }
|
|
1367
|
-
: {}),
|
|
1368
1787
|
...(typeof parsed.options.address === "string"
|
|
1369
1788
|
? { addresses: [parsed.options.address] }
|
|
1370
1789
|
: {}),
|
|
@@ -1381,11 +1800,7 @@ async function performCli(
|
|
|
1381
1800
|
break;
|
|
1382
1801
|
}
|
|
1383
1802
|
if (parsed.path === "swarm update") {
|
|
1384
|
-
const cid =
|
|
1385
|
-
if (!cid)
|
|
1386
|
-
syntax(
|
|
1387
|
-
"swarm update requires a registered alias, configuration URL or current swarm.",
|
|
1388
|
-
);
|
|
1803
|
+
const cid = requireSwarm();
|
|
1389
1804
|
const result = await updateSwarm(context, cid, {
|
|
1390
1805
|
...(typeof parsed.options.name === "string"
|
|
1391
1806
|
? { name: parsed.options.name }
|
|
@@ -1414,52 +1829,32 @@ async function performCli(
|
|
|
1414
1829
|
{
|
|
1415
1830
|
configUrl: entry.cid,
|
|
1416
1831
|
alias: entry.alias,
|
|
1417
|
-
savedCurrent:
|
|
1832
|
+
savedCurrent:
|
|
1833
|
+
state.config({ includeSecrets: false })["swarm.default"] ??
|
|
1834
|
+
null,
|
|
1418
1835
|
},
|
|
1419
1836
|
`Registered swarm ${entry.alias ?? cid} (${cid}).`,
|
|
1420
1837
|
);
|
|
1421
1838
|
break;
|
|
1422
1839
|
}
|
|
1423
1840
|
if (parsed.path === "search") {
|
|
1424
|
-
const source = items.find(
|
|
1425
|
-
(item) => item.key === "swarm.default",
|
|
1426
|
-
)!.source;
|
|
1427
|
-
const limited = parsed.options.current || source === "flag";
|
|
1428
|
-
if (limited && !selectedSwarm)
|
|
1429
|
-
syntax(
|
|
1430
|
-
"Search of the current swarm requires --swarm or swarm.default.",
|
|
1431
|
-
);
|
|
1432
1841
|
const registrations = state.swarms();
|
|
1433
|
-
const scope =
|
|
1434
|
-
?
|
|
1842
|
+
const scope = parsed.options.all
|
|
1843
|
+
? registrations
|
|
1844
|
+
: [
|
|
1435
1845
|
{
|
|
1436
|
-
cid:
|
|
1846
|
+
cid: requireSwarm(),
|
|
1437
1847
|
alias:
|
|
1438
1848
|
registrations.find((entry) => entry.cid === selectedSwarm)
|
|
1439
1849
|
?.alias ?? null,
|
|
1440
1850
|
},
|
|
1441
|
-
]
|
|
1442
|
-
: registrations;
|
|
1851
|
+
];
|
|
1443
1852
|
const result = await searchNames(context, first!, scope);
|
|
1444
|
-
emit(
|
|
1445
|
-
result,
|
|
1446
|
-
result.matches.length
|
|
1447
|
-
? result.matches
|
|
1448
|
-
.map(
|
|
1449
|
-
(match) =>
|
|
1450
|
-
`${printable(match.alias ?? match.swarm)} ${printable(match.name)} ${match.targetCid}\n ipab get ${printable(match.reference)}`,
|
|
1451
|
-
)
|
|
1452
|
-
.join("\n")
|
|
1453
|
-
: "No matching Names.",
|
|
1454
|
-
);
|
|
1853
|
+
emit(result, formatSearchResults(result.matches));
|
|
1455
1854
|
break;
|
|
1456
1855
|
}
|
|
1457
1856
|
if (parsed.path === "swarm status") {
|
|
1458
|
-
const cid =
|
|
1459
|
-
if (!cid)
|
|
1460
|
-
syntax(
|
|
1461
|
-
"swarm status requires a configuration URL or swarm.default.",
|
|
1462
|
-
);
|
|
1857
|
+
const cid = requireSwarm();
|
|
1463
1858
|
const local = Boolean(parsed.options.local);
|
|
1464
1859
|
const { head, config } = local
|
|
1465
1860
|
? await swarmHeader(context, cid, true)
|
|
@@ -1517,7 +1912,7 @@ async function performCli(
|
|
|
1517
1912
|
break;
|
|
1518
1913
|
}
|
|
1519
1914
|
if (parsed.path === "get") {
|
|
1520
|
-
const localCid =
|
|
1915
|
+
const localCid = /^(ipab|name):/i.test(first!)
|
|
1521
1916
|
? undefined
|
|
1522
1917
|
: state.resolve(first!);
|
|
1523
1918
|
const builtin = builtins.pins.find((pin) => pin.cid === localCid);
|
|
@@ -1529,6 +1924,7 @@ async function performCli(
|
|
|
1529
1924
|
selectedSwarm,
|
|
1530
1925
|
(reference) => state!.resolve(reference),
|
|
1531
1926
|
Boolean(parsed.options.raw),
|
|
1927
|
+
"local-first",
|
|
1532
1928
|
);
|
|
1533
1929
|
const contentStore = context.store;
|
|
1534
1930
|
const source = IpfsStore.fromClient(
|
|
@@ -1559,6 +1955,11 @@ async function performCli(
|
|
|
1559
1955
|
} finally {
|
|
1560
1956
|
await source.close();
|
|
1561
1957
|
}
|
|
1958
|
+
try {
|
|
1959
|
+
await context.finishRead?.();
|
|
1960
|
+
} finally {
|
|
1961
|
+
readContext = undefined;
|
|
1962
|
+
}
|
|
1562
1963
|
const closing = store;
|
|
1563
1964
|
store = undefined;
|
|
1564
1965
|
await closeStore(closing, undefined);
|
|
@@ -1568,6 +1969,7 @@ async function performCli(
|
|
|
1568
1969
|
break;
|
|
1569
1970
|
}
|
|
1570
1971
|
let cid: string;
|
|
1972
|
+
let contentCid: string | undefined;
|
|
1571
1973
|
if (parsed.path === "swarm create") {
|
|
1572
1974
|
cid = await createSwarm(context, {
|
|
1573
1975
|
...(typeof parsed.options.service === "string"
|
|
@@ -1584,12 +1986,8 @@ async function performCli(
|
|
|
1584
1986
|
? { alias: parsed.options.alias }
|
|
1585
1987
|
: {}),
|
|
1586
1988
|
});
|
|
1587
|
-
} else if (parsed.path === "swarm request")
|
|
1588
|
-
|
|
1589
|
-
ownerFingerprint: String(parsed.options["owner-fingerprint"] ?? ""),
|
|
1590
|
-
...(typeof parsed.options.name === "string"
|
|
1591
|
-
? { name: parsed.options.name }
|
|
1592
|
-
: {}),
|
|
1989
|
+
} else if (parsed.path === "swarm request") {
|
|
1990
|
+
const result = await requestMembership(context, first!, {
|
|
1593
1991
|
...(typeof parsed.options.alias === "string"
|
|
1594
1992
|
? { alias: parsed.options.alias }
|
|
1595
1993
|
: {}),
|
|
@@ -1597,8 +1995,41 @@ async function performCli(
|
|
|
1597
1995
|
? { output: parsed.options.output }
|
|
1598
1996
|
: {}),
|
|
1599
1997
|
});
|
|
1600
|
-
|
|
1601
|
-
|
|
1998
|
+
store = context.store;
|
|
1999
|
+
io.err(
|
|
2000
|
+
`Owner fingerprint: ${result.ownerFingerprint}\nVerify this fingerprint through an independent trusted channel before manually sending the Request file to the Owner.`,
|
|
2001
|
+
);
|
|
2002
|
+
if (result.file === undefined)
|
|
2003
|
+
io.out(JSON.stringify(result.request, null, 2));
|
|
2004
|
+
else {
|
|
2005
|
+
io.err(`Request saved to: ${result.file}`);
|
|
2006
|
+
if (parsed.flags.json)
|
|
2007
|
+
emit(
|
|
2008
|
+
{
|
|
2009
|
+
file: result.file,
|
|
2010
|
+
requestId: result.requestId,
|
|
2011
|
+
ownerFingerprint: result.ownerFingerprint,
|
|
2012
|
+
},
|
|
2013
|
+
"",
|
|
2014
|
+
);
|
|
2015
|
+
}
|
|
2016
|
+
break;
|
|
2017
|
+
} else if (parsed.path === "swarm approve") {
|
|
2018
|
+
const selected = requireSwarm();
|
|
2019
|
+
if (first === "-" && !parsed.options.yes)
|
|
2020
|
+
syntax(
|
|
2021
|
+
"Reading a Request from stdin requires explicit --yes; no interactive confirmation is available.",
|
|
2022
|
+
);
|
|
2023
|
+
const request =
|
|
2024
|
+
first === "-"
|
|
2025
|
+
? await verifiedRequestStream(
|
|
2026
|
+
(io.requestInput ?? processIO.requestInput!)(),
|
|
2027
|
+
)
|
|
2028
|
+
: await verifiedRequest(first!);
|
|
2029
|
+
if (request.configUrl !== selected)
|
|
2030
|
+
syntax(
|
|
2031
|
+
`Request belongs to ${request.configUrl}, not the selected Swarm. Use ipab --swarm ${request.configUrl} swarm approve REQUEST_FILE --yes.`,
|
|
2032
|
+
);
|
|
1602
2033
|
io.err(await membershipRequestSummary(request));
|
|
1603
2034
|
if (
|
|
1604
2035
|
!parsed.options.yes &&
|
|
@@ -1614,17 +2045,11 @@ async function performCli(
|
|
|
1614
2045
|
again: Boolean(parsed.options.again),
|
|
1615
2046
|
});
|
|
1616
2047
|
} else {
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
content = (
|
|
1620
|
-
await importBundle(first!, () => Promise.resolve(store!))
|
|
1621
|
-
).cid;
|
|
1622
|
-
else content = exactCid(first!);
|
|
2048
|
+
const content = await publicationSource(second!, store);
|
|
2049
|
+
contentCid = content;
|
|
1623
2050
|
cid = await publish(context, content, {
|
|
1624
2051
|
...(selectedSwarm ? { swarm: selectedSwarm } : {}),
|
|
1625
|
-
|
|
1626
|
-
? { name: parsed.options.name }
|
|
1627
|
-
: {}),
|
|
2052
|
+
name: first!,
|
|
1628
2053
|
...(typeof parsed.options.expect === "string"
|
|
1629
2054
|
? { expect: parsed.options.expect }
|
|
1630
2055
|
: {}),
|
|
@@ -1634,14 +2059,16 @@ async function performCli(
|
|
|
1634
2059
|
store = context.store;
|
|
1635
2060
|
if (parsed.path === "swarm create")
|
|
1636
2061
|
io.err(
|
|
1637
|
-
`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config()["swarm.default"] ?? "(none)"}.`,
|
|
2062
|
+
`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config({ includeSecrets: false })["swarm.default"] ?? "(none)"}.`,
|
|
2063
|
+
);
|
|
2064
|
+
if (contentCid)
|
|
2065
|
+
io.err(
|
|
2066
|
+
`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.`,
|
|
1638
2067
|
);
|
|
1639
2068
|
emit(
|
|
1640
|
-
parsed.path === "swarm
|
|
1641
|
-
? {
|
|
1642
|
-
:
|
|
1643
|
-
? { configUrl: cid }
|
|
1644
|
-
: { cid },
|
|
2069
|
+
parsed.path === "swarm create" || parsed.path === "swarm approve"
|
|
2070
|
+
? { configUrl: cid }
|
|
2071
|
+
: { cid, ...(contentCid ? { contentCid } : {}) },
|
|
1645
2072
|
cid,
|
|
1646
2073
|
);
|
|
1647
2074
|
break;
|
|
@@ -1797,7 +2224,7 @@ async function performCli(
|
|
|
1797
2224
|
result.files.includes("ipab.json"))
|
|
1798
2225
|
)
|
|
1799
2226
|
io.err(
|
|
1800
|
-
`Next: install declared dependencies
|
|
2227
|
+
`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.`,
|
|
1801
2228
|
);
|
|
1802
2229
|
else if (result.files.includes(".bundle.yaml"))
|
|
1803
2230
|
io.err(
|
|
@@ -1824,128 +2251,74 @@ async function performCli(
|
|
|
1824
2251
|
break;
|
|
1825
2252
|
}
|
|
1826
2253
|
case "pin list": {
|
|
1827
|
-
const
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
: undefined;
|
|
1831
|
-
const pins = state.pins();
|
|
1832
|
-
const listed = pins
|
|
1833
|
-
.filter(
|
|
1834
|
-
(pin) => pin.status === "ready" && pin.metadata?.kind === "bundle",
|
|
1835
|
-
)
|
|
1836
|
-
.map(pinDetails)
|
|
1837
|
-
.filter((pin) => type === undefined || pin.schemaCid === type);
|
|
1838
|
-
const invalid = pins
|
|
1839
|
-
.filter(
|
|
1840
|
-
(pin) => pin.status === "ready" && pin.metadata?.kind !== "bundle",
|
|
1841
|
-
)
|
|
1842
|
-
.map(({ name, cid, metadata }) => ({
|
|
1843
|
-
name,
|
|
1844
|
-
cid,
|
|
1845
|
-
kind: metadata?.kind,
|
|
1846
|
-
reason:
|
|
1847
|
-
"Not a Bundle pin; retention is preserved. Use pin delete to release it.",
|
|
1848
|
-
}));
|
|
1849
|
-
const pending = pins
|
|
1850
|
-
.filter((pin) => pin.status !== "ready")
|
|
1851
|
-
.map(({ name, cid, status }) => ({ name, cid, status }));
|
|
1852
|
-
if (pending.length)
|
|
1853
|
-
io.err(
|
|
1854
|
-
`Unfinished pin operations (not usable pins): ${JSON.stringify(pending)}. Retry pin add/delete.`,
|
|
1855
|
-
);
|
|
1856
|
-
if (invalid.length)
|
|
1857
|
-
io.err(
|
|
1858
|
-
`Legacy non-Bundle pins (not usable pins): ${JSON.stringify(invalid)}. Retention is unchanged; delete explicitly and wrap content in a Bundle before pinning again.`,
|
|
1859
|
-
);
|
|
2254
|
+
const listed = state.contentPins();
|
|
2255
|
+
const archived = state.archivedPins();
|
|
2256
|
+
const builtins = state.pins().map(pinDetails);
|
|
1860
2257
|
emit(
|
|
1861
|
-
{ items: listed,
|
|
2258
|
+
{ items: listed, builtins, archived },
|
|
1862
2259
|
table(
|
|
1863
|
-
["
|
|
1864
|
-
|
|
1865
|
-
pin
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
2260
|
+
["REFERENCE", "CID", "STATUS", "SOURCE"],
|
|
2261
|
+
[
|
|
2262
|
+
...listed.map((pin) => [
|
|
2263
|
+
pin.reference,
|
|
2264
|
+
pin.cid ?? "(none)",
|
|
2265
|
+
`${pin.status}/${pin.freshness}${pin.error ? `: ${pin.error}` : ""}`,
|
|
2266
|
+
pin.swarm ? "following shared Name" : "fixed CID",
|
|
2267
|
+
]),
|
|
2268
|
+
...builtins.map((pin) => [
|
|
2269
|
+
pin.name,
|
|
2270
|
+
pin.cid,
|
|
2271
|
+
"read-only",
|
|
2272
|
+
"built-in",
|
|
2273
|
+
]),
|
|
2274
|
+
...archived.map((pin) => [
|
|
2275
|
+
pin.cid,
|
|
2276
|
+
pin.cid,
|
|
2277
|
+
pin.status,
|
|
2278
|
+
`inactive archive (${pin.name}); unpin exact CID`,
|
|
2279
|
+
]),
|
|
2280
|
+
],
|
|
2281
|
+
"No pins.",
|
|
1873
2282
|
),
|
|
1874
2283
|
);
|
|
1875
2284
|
break;
|
|
1876
2285
|
}
|
|
1877
|
-
case "
|
|
1878
|
-
|
|
1879
|
-
const result = await
|
|
1880
|
-
state,
|
|
1881
|
-
first!,
|
|
1882
|
-
second!,
|
|
1883
|
-
await storeConfiguration(value("store.gateway")),
|
|
1884
|
-
);
|
|
2286
|
+
case "unpin": {
|
|
2287
|
+
const canonical = pinReference(state, first!, selectedSwarm);
|
|
2288
|
+
const result = await unpin(state, canonical.reference);
|
|
1885
2289
|
emit(
|
|
1886
2290
|
result,
|
|
1887
|
-
|
|
1888
|
-
);
|
|
1889
|
-
break;
|
|
1890
|
-
}
|
|
1891
|
-
case "pin delete": {
|
|
1892
|
-
const result = await deletePin(state, first!);
|
|
1893
|
-
emit(
|
|
1894
|
-
result,
|
|
1895
|
-
`Deleted ${first}; released only its retention responsibility. No blocks deleted or GC requested.`,
|
|
2291
|
+
`Unpinned ${canonical.reference}; released only its saved retention responsibility. No blocks deleted or GC requested.`,
|
|
1896
2292
|
);
|
|
1897
2293
|
break;
|
|
1898
2294
|
}
|
|
1899
2295
|
case "pin show": {
|
|
1900
|
-
const
|
|
1901
|
-
|
|
2296
|
+
const builtin = first!.startsWith("builtin:")
|
|
2297
|
+
? state.pin(first!)
|
|
2298
|
+
: undefined;
|
|
2299
|
+
const canonical = builtin
|
|
2300
|
+
? undefined
|
|
2301
|
+
: pinReference(state, first!, selectedSwarm);
|
|
2302
|
+
const pin = canonical
|
|
2303
|
+
? state.contentPin(canonical.reference)
|
|
2304
|
+
: undefined;
|
|
2305
|
+
const archived = canonical
|
|
2306
|
+
? state
|
|
2307
|
+
.archivedPins()
|
|
2308
|
+
.filter((pin) => pin.cid === canonical.reference)
|
|
2309
|
+
: [];
|
|
2310
|
+
if (!pin && !builtin && !archived.length)
|
|
1902
2311
|
throw new HostError(
|
|
1903
2312
|
`Pin "${first}" does not exist. Run ipab pin list.`,
|
|
1904
2313
|
);
|
|
1905
|
-
const result =
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
const result = renamePin(state, first!, second!);
|
|
1914
|
-
emit(result, `${first} → ${result.name} (${result.cid})`);
|
|
1915
|
-
break;
|
|
1916
|
-
}
|
|
1917
|
-
case "register list": {
|
|
1918
|
-
const associations = state.registrations();
|
|
1919
|
-
emit(
|
|
1920
|
-
{ items: associations },
|
|
1921
|
-
table(
|
|
1922
|
-
["SCHEMA CID", "APP CID", "ARGV"],
|
|
1923
|
-
associations.map((association) => [
|
|
1924
|
-
association.schemaCid,
|
|
1925
|
-
association.appCid,
|
|
1926
|
-
JSON.stringify(association.argv),
|
|
1927
|
-
]),
|
|
1928
|
-
"No associations.",
|
|
1929
|
-
),
|
|
1930
|
-
);
|
|
1931
|
-
break;
|
|
1932
|
-
}
|
|
1933
|
-
case "register set": {
|
|
1934
|
-
const association = state.setAssociation(
|
|
1935
|
-
schemaAlias(first!),
|
|
1936
|
-
second!,
|
|
1937
|
-
parsed.template ?? ["%"],
|
|
1938
|
-
Boolean(parsed.options.replace),
|
|
1939
|
-
);
|
|
1940
|
-
emit(
|
|
1941
|
-
association,
|
|
1942
|
-
`${association.schemaCid} → ${association.appCid} ${JSON.stringify(association.argv)}`,
|
|
1943
|
-
);
|
|
1944
|
-
break;
|
|
1945
|
-
}
|
|
1946
|
-
case "register remove": {
|
|
1947
|
-
const removed = state.removeAssociation(schemaAlias(first!));
|
|
1948
|
-
emit({ removed: [removed] }, `Removed association for ${removed}.`);
|
|
2314
|
+
const result = builtin
|
|
2315
|
+
? pinDetails(builtin)
|
|
2316
|
+
: {
|
|
2317
|
+
pin: pin ?? null,
|
|
2318
|
+
roots: pin ? state.hold(pin.owner)?.roots : [],
|
|
2319
|
+
archived,
|
|
2320
|
+
};
|
|
2321
|
+
emit(result, JSON.stringify(result, null, 2));
|
|
1949
2322
|
break;
|
|
1950
2323
|
}
|
|
1951
2324
|
case "config get": {
|
|
@@ -2073,6 +2446,15 @@ async function performCli(
|
|
|
2073
2446
|
}
|
|
2074
2447
|
case "exec":
|
|
2075
2448
|
case "open": {
|
|
2449
|
+
const named =
|
|
2450
|
+
parsed.path === "open" ? parseNameReference(first!) : undefined;
|
|
2451
|
+
const registrySwarm = named?.swarm
|
|
2452
|
+
? state.resolveSwarm(named.swarm)
|
|
2453
|
+
: selectedSwarm;
|
|
2454
|
+
if (parsed.path === "open" && !registrySwarm)
|
|
2455
|
+
throw new HostError(
|
|
2456
|
+
"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.",
|
|
2457
|
+
);
|
|
2076
2458
|
if (parsed.options.log && !value("history.enabled"))
|
|
2077
2459
|
throw new HostError(
|
|
2078
2460
|
"Execution logging requires history.enabled=true.",
|
|
@@ -2080,6 +2462,7 @@ async function performCli(
|
|
|
2080
2462
|
await recoverInactive(state);
|
|
2081
2463
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
2082
2464
|
const context = swarmContext();
|
|
2465
|
+
readContext = context;
|
|
2083
2466
|
const target = (
|
|
2084
2467
|
await resolveReference(
|
|
2085
2468
|
context,
|
|
@@ -2087,9 +2470,69 @@ async function performCli(
|
|
|
2087
2470
|
selectedSwarm,
|
|
2088
2471
|
(reference) => state!.resolve(reference),
|
|
2089
2472
|
Boolean(parsed.options.raw),
|
|
2473
|
+
"local-first",
|
|
2090
2474
|
)
|
|
2091
2475
|
).cid;
|
|
2092
2476
|
store = context.store;
|
|
2477
|
+
const resolveBundleReference = async (
|
|
2478
|
+
reference: string,
|
|
2479
|
+
signal: AbortSignal,
|
|
2480
|
+
preferredSwarm?: string,
|
|
2481
|
+
) => {
|
|
2482
|
+
signal.throwIfAborted();
|
|
2483
|
+
const lookup: SwarmContext = {
|
|
2484
|
+
...swarmContext(),
|
|
2485
|
+
store: new IpfsStore(
|
|
2486
|
+
await storeConfiguration(value("store.gateway")),
|
|
2487
|
+
),
|
|
2488
|
+
};
|
|
2489
|
+
try {
|
|
2490
|
+
const named = parseNameReference(reference);
|
|
2491
|
+
const swarm = named?.swarm
|
|
2492
|
+
? state!.resolveSwarm(named.swarm)
|
|
2493
|
+
: preferredSwarm
|
|
2494
|
+
? state!.resolveSwarm(preferredSwarm)
|
|
2495
|
+
: selectedSwarm;
|
|
2496
|
+
const resolve = (source: string | undefined) =>
|
|
2497
|
+
resolveReference(
|
|
2498
|
+
lookup,
|
|
2499
|
+
reference,
|
|
2500
|
+
source,
|
|
2501
|
+
(input) => state!.resolve(input),
|
|
2502
|
+
false,
|
|
2503
|
+
"local-first",
|
|
2504
|
+
);
|
|
2505
|
+
let resolved;
|
|
2506
|
+
try {
|
|
2507
|
+
resolved = await resolve(named ? swarm : undefined);
|
|
2508
|
+
} catch (cause) {
|
|
2509
|
+
let failure: unknown = cause;
|
|
2510
|
+
for (
|
|
2511
|
+
let depth = 0;
|
|
2512
|
+
depth < 8 && failure instanceof ContentBundleError;
|
|
2513
|
+
depth++
|
|
2514
|
+
)
|
|
2515
|
+
failure = failure.cause;
|
|
2516
|
+
if (
|
|
2517
|
+
named ||
|
|
2518
|
+
!swarm ||
|
|
2519
|
+
!(failure instanceof ContentError) ||
|
|
2520
|
+
failure.code !== "missing_block"
|
|
2521
|
+
)
|
|
2522
|
+
throw cause;
|
|
2523
|
+
signal.throwIfAborted();
|
|
2524
|
+
resolved = await resolve(swarm);
|
|
2525
|
+
}
|
|
2526
|
+
signal.throwIfAborted();
|
|
2527
|
+
return { ...resolved, ...(swarm ? { swarm } : {}) };
|
|
2528
|
+
} finally {
|
|
2529
|
+
try {
|
|
2530
|
+
await lookup.finishRead?.();
|
|
2531
|
+
} finally {
|
|
2532
|
+
await lookup.store.close();
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
};
|
|
2093
2536
|
let appCid: string;
|
|
2094
2537
|
let appArgv: string[];
|
|
2095
2538
|
if (parsed.path === "open") {
|
|
@@ -2103,10 +2546,32 @@ async function performCli(
|
|
|
2103
2546
|
try {
|
|
2104
2547
|
const content = await validatedBundle(root, store, owner);
|
|
2105
2548
|
const schema = content.schemaKey;
|
|
2106
|
-
|
|
2549
|
+
let association: Association | undefined;
|
|
2550
|
+
if (registrySwarm) {
|
|
2551
|
+
const lookup: SwarmContext = {
|
|
2552
|
+
...swarmContext(),
|
|
2553
|
+
store: new IpfsStore(
|
|
2554
|
+
await storeConfiguration(value("store.gateway")),
|
|
2555
|
+
),
|
|
2556
|
+
};
|
|
2557
|
+
try {
|
|
2558
|
+
association = await swarmAssociation(
|
|
2559
|
+
lookup,
|
|
2560
|
+
registrySwarm,
|
|
2561
|
+
schema,
|
|
2562
|
+
"local-first",
|
|
2563
|
+
);
|
|
2564
|
+
} finally {
|
|
2565
|
+
try {
|
|
2566
|
+
await lookup.finishRead?.();
|
|
2567
|
+
} finally {
|
|
2568
|
+
await lookup.store.close();
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2107
2572
|
if (!association)
|
|
2108
2573
|
throw new HostError(
|
|
2109
|
-
`No App registered for Schema ${schema}. Use ipab register set or ipab exec.`,
|
|
2574
|
+
`No App registered for Schema ${schema} in Swarm ${registrySwarm}. Use ipab register set ${schema} APP_CID --swarm ${registrySwarm} or ipab exec.`,
|
|
2110
2575
|
);
|
|
2111
2576
|
appCid = association.appCid;
|
|
2112
2577
|
appArgv = association.argv.map((argument) =>
|
|
@@ -2119,6 +2584,7 @@ async function performCli(
|
|
|
2119
2584
|
{ origin: "open", appCid, argv: appArgv },
|
|
2120
2585
|
{
|
|
2121
2586
|
inputSchema: schema,
|
|
2587
|
+
resolveBundleReference,
|
|
2122
2588
|
history: Boolean(value("history.enabled")),
|
|
2123
2589
|
retain: value("output.retention") === "history",
|
|
2124
2590
|
log: Boolean(parsed.options.log),
|
|
@@ -2142,6 +2608,7 @@ async function performCli(
|
|
|
2142
2608
|
store,
|
|
2143
2609
|
{ origin: "exec", appCid, argv: appArgv },
|
|
2144
2610
|
{
|
|
2611
|
+
resolveBundleReference,
|
|
2145
2612
|
history: Boolean(value("history.enabled")),
|
|
2146
2613
|
retain: value("output.retention") === "history",
|
|
2147
2614
|
log: Boolean(parsed.options.log),
|
|
@@ -2162,7 +2629,11 @@ async function performCli(
|
|
|
2162
2629
|
return error instanceof HostError ? error.exitCode : 1;
|
|
2163
2630
|
} finally {
|
|
2164
2631
|
try {
|
|
2165
|
-
|
|
2632
|
+
try {
|
|
2633
|
+
await readContext?.finishRead?.();
|
|
2634
|
+
} finally {
|
|
2635
|
+
await closeStore(store, appExitCode);
|
|
2636
|
+
}
|
|
2166
2637
|
} finally {
|
|
2167
2638
|
state?.close();
|
|
2168
2639
|
}
|