@ipab/cli 0.1.0-rc.1 → 0.1.0-rc.3
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 +43 -6
- package/dist/app-authoring.d.ts +10 -0
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +138 -13
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-definition.d.ts +52 -57
- package/dist/app-definition.d.ts.map +1 -1
- package/dist/app-definition.js +33 -38
- package/dist/app-definition.js.map +1 -1
- package/dist/app-templates.d.ts.map +1 -1
- package/dist/app-templates.js +2 -1
- package/dist/app-templates.js.map +1 -1
- package/dist/assembly.d.ts +7 -0
- package/dist/assembly.d.ts.map +1 -0
- package/dist/assembly.js +130 -0
- package/dist/assembly.js.map +1 -0
- package/dist/authoring.d.ts +4 -8
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +25 -15
- package/dist/authoring.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/builtins.d.ts.map +1 -1
- package/dist/builtins.js +18 -2
- package/dist/builtins.js.map +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +720 -76
- package/dist/cli.js.map +1 -1
- package/dist/config-secret.d.ts +3 -0
- package/dist/config-secret.d.ts.map +1 -0
- package/dist/config-secret.js +83 -0
- package/dist/config-secret.js.map +1 -0
- package/dist/config.d.ts +6 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +109 -7
- package/dist/config.js.map +1 -1
- package/dist/content-provider.d.ts +9 -0
- package/dist/content-provider.d.ts.map +1 -0
- package/dist/content-provider.js +93 -0
- package/dist/content-provider.js.map +1 -0
- package/dist/get.d.ts +3 -0
- package/dist/get.d.ts.map +1 -0
- package/dist/get.js +80 -0
- package/dist/get.js.map +1 -0
- package/dist/identity.d.ts +9 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +89 -0
- package/dist/identity.js.map +1 -0
- package/dist/kubo.d.ts +38 -0
- package/dist/kubo.d.ts.map +1 -0
- package/dist/kubo.js +528 -0
- package/dist/kubo.js.map +1 -0
- package/dist/pins.d.ts +3 -3
- package/dist/pins.js +1 -1
- package/dist/pins.js.map +1 -1
- package/dist/setup.d.ts +7 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +22 -0
- package/dist/setup.js.map +1 -0
- package/dist/source-bundle.d.ts +3 -8
- package/dist/source-bundle.d.ts.map +1 -1
- package/dist/source-bundle.js +17 -12
- package/dist/source-bundle.js.map +1 -1
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +2 -2
- package/dist/space.js.map +1 -1
- package/dist/state.d.ts +19 -4
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +105 -7
- package/dist/state.js.map +1 -1
- package/dist/swarm-envelope.d.ts +36 -0
- package/dist/swarm-envelope.d.ts.map +1 -0
- package/dist/swarm-envelope.js +145 -0
- package/dist/swarm-envelope.js.map +1 -0
- package/dist/swarm-files.d.ts +5 -0
- package/dist/swarm-files.d.ts.map +1 -0
- package/dist/swarm-files.js +94 -0
- package/dist/swarm-files.js.map +1 -0
- package/dist/swarm.d.ts +173 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/swarm.js +1245 -0
- package/dist/swarm.js.map +1 -0
- package/dist/template-definition.d.ts +47 -52
- package/dist/template-definition.d.ts.map +1 -1
- package/dist/template-definition.js +36 -41
- package/dist/template-definition.js.map +1 -1
- package/dist/template-source.d.ts +2 -0
- package/dist/template-source.d.ts.map +1 -1
- package/dist/template-source.js +4 -3
- package/dist/template-source.js.map +1 -1
- package/package.json +10 -5
- package/src/app-authoring.ts +210 -21
- package/src/app-definition.ts +33 -39
- package/src/app-templates.ts +9 -1
- package/src/assembly.ts +185 -0
- package/src/authoring.ts +41 -17
- package/src/builtins.ts +23 -2
- package/src/cli.ts +875 -79
- package/src/config-secret.ts +96 -0
- package/src/config.ts +146 -7
- package/src/content-provider.ts +124 -0
- package/src/get.ts +90 -0
- package/src/identity.ts +133 -0
- package/src/kubo.ts +691 -0
- package/src/pins.ts +1 -1
- package/src/setup.ts +21 -0
- package/src/source-bundle.ts +26 -13
- package/src/space.ts +2 -5
- package/src/state.ts +121 -9
- package/src/swarm-envelope.ts +255 -0
- package/src/swarm-files.ts +100 -0
- package/src/swarm.ts +2025 -0
- package/src/template-definition.ts +36 -41
- package/src/template-source.ts +10 -3
package/dist/cli.js
CHANGED
|
@@ -2,19 +2,26 @@ import { createInterface } from "node:readline/promises";
|
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { IpfsStore } from "@ipab/ipfs-store";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { CID } from "multiformats/cid";
|
|
5
6
|
import stringWidth from "string-width";
|
|
6
|
-
import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, } from "./config.js";
|
|
7
|
+
import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, visibleConfig, } from "./config.js";
|
|
7
8
|
import { HostError, message, object, syntax } from "./errors.js";
|
|
8
9
|
import { filters, listHistory, selectedIds, Ownership, recoverInactive, removeHistory, } from "./history.js";
|
|
9
10
|
import { execute } from "./runtime.js";
|
|
10
11
|
import { validatedBundle } from "./space.js";
|
|
11
12
|
import { exactCid, pinName, State } from "./state.js";
|
|
12
13
|
import { buildBundle, inspectBundle, importBundle } from "./authoring.js";
|
|
13
|
-
import {
|
|
14
|
+
import { initApp } from "./app-authoring.js";
|
|
15
|
+
import { assembleBundle } from "./assembly.js";
|
|
16
|
+
import { getBundle } from "./get.js";
|
|
17
|
+
import { setupDevice } from "./setup.js";
|
|
18
|
+
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
19
|
+
import { createSwarm, requestMembership, approveMembership, exportRequest, removeMember, resumeRemoval, updateProfile, verifiedRequest, membershipRequestSummary, swarmHeader, addSwarm, updateSwarm, searchNames, resolveReference, publish, } from "./swarm.js";
|
|
14
20
|
import { schemaAlias } from "./app-definition.js";
|
|
15
21
|
import { addPin, deletePin, pinDetails, renamePin } from "./pins.js";
|
|
16
22
|
import { logFiles } from "./logs.js";
|
|
17
23
|
import { builtinContent } from "./builtins.js";
|
|
24
|
+
import { readSecretStream } from "./config-secret.js";
|
|
18
25
|
export const processIO = {
|
|
19
26
|
out(text) {
|
|
20
27
|
process.stdout.write(`${text}\n`);
|
|
@@ -26,6 +33,12 @@ export const processIO = {
|
|
|
26
33
|
columns() {
|
|
27
34
|
return process.stdout.columns;
|
|
28
35
|
},
|
|
36
|
+
async readSecret() {
|
|
37
|
+
if (process.stdin.isTTY)
|
|
38
|
+
syntax("Pipe the API key through stdin; interactive echo is not permitted.");
|
|
39
|
+
process.stdin.setEncoding("utf8");
|
|
40
|
+
return readSecretStream(process.stdin);
|
|
41
|
+
},
|
|
29
42
|
async confirm(text) {
|
|
30
43
|
const reader = createInterface({
|
|
31
44
|
input: process.stdin,
|
|
@@ -40,13 +53,30 @@ export const processIO = {
|
|
|
40
53
|
},
|
|
41
54
|
};
|
|
42
55
|
const commands = {
|
|
56
|
+
setup: "setup [--yes]",
|
|
57
|
+
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
58
|
+
"swarm request": "swarm request CONFIG_URL --owner-fingerprint FINGERPRINT [--output FILE] [--alias ALIAS]",
|
|
59
|
+
"swarm export": "swarm export URL_OR_ALIAS --output FILE",
|
|
60
|
+
"swarm approve": "swarm approve REQUEST_FILE [--again] --yes",
|
|
61
|
+
"swarm exclude": "swarm exclude MEMBER_PUBLIC_KEY [--swarm URL_OR_ALIAS] --yes",
|
|
62
|
+
"swarm resume": "swarm resume [URL_OR_ALIAS]",
|
|
63
|
+
"swarm profile": "swarm profile [URL_OR_ALIAS] [--name NAME] [--address MULTIADDR]",
|
|
64
|
+
"swarm status": "swarm status [URL_OR_ALIAS]",
|
|
65
|
+
"swarm list": "swarm list",
|
|
66
|
+
"swarm add": "swarm add CONFIG_URL [--alias ALIAS]",
|
|
67
|
+
"swarm use": "swarm use URL_OR_ALIAS",
|
|
68
|
+
"swarm remove": "swarm remove URL_OR_ALIAS",
|
|
69
|
+
"swarm update": "swarm update [URL_OR_ALIAS] [--name TEXT] [--description TEXT]",
|
|
70
|
+
publish: "publish CID_OR_CAR [--name NAME [--expect OLD_NODE_CID | --snapshot]]",
|
|
71
|
+
get: "get REF [--raw] [--force | --no-force] [-o DIRECTORY]",
|
|
72
|
+
search: "search QUERY [--current] [--force | --no-force]",
|
|
43
73
|
init: "init NAME [DIR] [OPTIONS]",
|
|
44
|
-
build: "build [
|
|
74
|
+
build: "build [SOURCE] [OPTIONS]",
|
|
45
75
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
46
76
|
"bundle inspect": "bundle inspect SOURCE",
|
|
47
77
|
"bundle import": "bundle import FILE.car",
|
|
48
|
-
exec: "exec [--log] APP [APP_ARGS...]",
|
|
49
|
-
open: "open [--log] CONTENT",
|
|
78
|
+
exec: "exec [--log] [--force | --no-force] APP [APP_ARGS...]",
|
|
79
|
+
open: "open [--log] [--raw] [--force | --no-force] CONTENT",
|
|
50
80
|
"pin add": "pin add NAME CID",
|
|
51
81
|
"pin delete": "pin delete NAME",
|
|
52
82
|
"pin list": "pin list [--type TYPE]",
|
|
@@ -56,7 +86,7 @@ const commands = {
|
|
|
56
86
|
"register set": "register set SCHEMA APP [--replace] [-- TEMPLATE...]",
|
|
57
87
|
"register remove": "register remove SCHEMA",
|
|
58
88
|
"config get": "config get [KEY]",
|
|
59
|
-
"config set": "config set KEY VALUE",
|
|
89
|
+
"config set": "config set KEY VALUE\n ipab config set pointers.apiKey - < protected-key-file",
|
|
60
90
|
"config reset": "config reset KEY",
|
|
61
91
|
"store usage": "store usage",
|
|
62
92
|
"store gc": "store gc",
|
|
@@ -65,6 +95,7 @@ const commands = {
|
|
|
65
95
|
"history remove": "history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
|
|
66
96
|
};
|
|
67
97
|
const groups = {
|
|
98
|
+
swarm: "Create, authorize, select and manage personal swarms",
|
|
68
99
|
bundle: "Create, inspect and import content bundles",
|
|
69
100
|
pin: "Retain content and manage short names",
|
|
70
101
|
register: "Associate content types with Apps",
|
|
@@ -73,6 +104,192 @@ const groups = {
|
|
|
73
104
|
history: "View and remove execution history",
|
|
74
105
|
};
|
|
75
106
|
const commandHelp = {
|
|
107
|
+
setup: {
|
|
108
|
+
summary: "Verify/install Kubo and prepare the protected HOME account identity",
|
|
109
|
+
examples: ["ipab setup --yes", "ipab setup"],
|
|
110
|
+
options: [
|
|
111
|
+
"--yes Confirm installation and identity initialization outside a TTY.",
|
|
112
|
+
],
|
|
113
|
+
notes: [
|
|
114
|
+
"Idempotent: reuse the same verified program and existing identity.",
|
|
115
|
+
"Does not create Swarm repos, start or contact any daemon, deploy services or install login startup.",
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
"swarm create": {
|
|
119
|
+
summary: "Create a swarm using the account HOME identity",
|
|
120
|
+
options: [
|
|
121
|
+
"--service URL Must match the protected pointers.service origin.",
|
|
122
|
+
"--resume OPERATION Recover the same saved create/idempotency result.",
|
|
123
|
+
"--name TEXT Initial mutable swarm name.",
|
|
124
|
+
"--description TEXT Initial mutable description.",
|
|
125
|
+
"--alias ALIAS Optional local registry alias (not the shared name).",
|
|
126
|
+
],
|
|
127
|
+
examples: [
|
|
128
|
+
"ipab config set pointers.service https://service.example",
|
|
129
|
+
"ipab config set pointers.apiKey -",
|
|
130
|
+
"ipab swarm create",
|
|
131
|
+
],
|
|
132
|
+
notes: [
|
|
133
|
+
"Creation uses the protected, origin-bound API key and owner possession proof.",
|
|
134
|
+
"Installs checksum-verified Kubo on demand; each Swarm has its own protected repo and ports.",
|
|
135
|
+
"Returns the public organization configuration URL; owner needs no certificate.",
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
"swarm request": {
|
|
139
|
+
summary: "Save and export a signed self-contained membership Request",
|
|
140
|
+
examples: [
|
|
141
|
+
"ipab swarm request CONFIG_URL --owner-fingerprint TRUSTED_FINGERPRINT --output request.json --alias work",
|
|
142
|
+
],
|
|
143
|
+
options: [
|
|
144
|
+
"--owner-fingerprint VALUE Verify Owner through a trusted independent channel.",
|
|
145
|
+
"--name NAME Initial public display name.",
|
|
146
|
+
"--alias ALIAS Pre-register the target for lazy onboarding.",
|
|
147
|
+
"--output FILE Export the saved exact Request; no expiry or new PeerID on retry.",
|
|
148
|
+
],
|
|
149
|
+
notes: [
|
|
150
|
+
"No Invite, Response file, password or Join. Next normal use fetches and decrypts the approved package.",
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
"swarm approve": {
|
|
154
|
+
summary: "Owner signs a certificate for an exact request",
|
|
155
|
+
options: [
|
|
156
|
+
"--yes Explicit approval; required outside a TTY.",
|
|
157
|
+
"--again Explicit fresh approval of an old Request; history is advisory.",
|
|
158
|
+
],
|
|
159
|
+
examples: ["ipab swarm approve request.json --yes"],
|
|
160
|
+
notes: [
|
|
161
|
+
"Creates a public profile and publishes an Owner-signed X25519/AES-GCM package. Exact-ID certificates have no expiry.",
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
"swarm export": {
|
|
165
|
+
summary: "Re-export the same persisted Request",
|
|
166
|
+
examples: ["ipab swarm export work --output request.json"],
|
|
167
|
+
},
|
|
168
|
+
"swarm exclude": {
|
|
169
|
+
summary: "Owner removes a member with irreversible HEAD/key rotation",
|
|
170
|
+
examples: ["ipab --swarm work swarm exclude MEMBER_PUBLIC_KEY --yes"],
|
|
171
|
+
notes: [
|
|
172
|
+
"Freezes the old HEAD atomically, preserves its final committed publication, rotates the key and remaining packages, deletes the leaving profile and retires the old HEAD.",
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
"swarm resume": {
|
|
176
|
+
summary: "Owner resumes an interrupted organization switch",
|
|
177
|
+
examples: ["ipab swarm resume work"],
|
|
178
|
+
},
|
|
179
|
+
"swarm profile": {
|
|
180
|
+
summary: "Update your public display name and LAN/VPN IPv4 TCP address",
|
|
181
|
+
examples: [
|
|
182
|
+
"ipab swarm profile work --name Wei",
|
|
183
|
+
"ipab swarm profile work --address /ip4/192.168.1.12/tcp/4001/p2p/PEER_ID",
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
"swarm status": {
|
|
187
|
+
summary: "Authenticate the current swarm HEAD",
|
|
188
|
+
examples: ["ipab swarm status", "ipab swarm status work"],
|
|
189
|
+
notes: [
|
|
190
|
+
"Always authenticate and refresh HEAD; update the local header cache.",
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
"swarm list": {
|
|
194
|
+
summary: "List local swarm registrations and the effective selection",
|
|
195
|
+
examples: ["ipab swarm list", "ipab --json swarm list"],
|
|
196
|
+
notes: ["Local only; does not verify remote membership or refresh HEAD."],
|
|
197
|
+
},
|
|
198
|
+
"swarm add": {
|
|
199
|
+
summary: "Authenticate and register a swarm you already have access to",
|
|
200
|
+
options: [
|
|
201
|
+
"--alias ALIAS Unique local alias; does not rename the shared swarm.",
|
|
202
|
+
],
|
|
203
|
+
examples: ["ipab swarm add CONFIG_URL --alias work"],
|
|
204
|
+
notes: [
|
|
205
|
+
"Not a membership grant. The first registration becomes the saved default only if none exists.",
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
"swarm use": {
|
|
209
|
+
summary: "Save a registered swarm as the current default",
|
|
210
|
+
examples: ["ipab swarm use work"],
|
|
211
|
+
notes: ["Local only. --swarm still overrides the saved default."],
|
|
212
|
+
},
|
|
213
|
+
"swarm remove": {
|
|
214
|
+
summary: "Forget a local registration without revoking membership",
|
|
215
|
+
examples: ["ipab swarm remove work"],
|
|
216
|
+
notes: [
|
|
217
|
+
"Preserves credentials, content and remote membership. Clears a matching saved default without selecting a replacement.",
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
"swarm update": {
|
|
221
|
+
summary: "Owner updates public organization information",
|
|
222
|
+
arguments: ["URL_OR_ALIAS Defaults to the effective current swarm."],
|
|
223
|
+
options: [
|
|
224
|
+
"--name TEXT Replace the shared display name; empty text clears it.",
|
|
225
|
+
"--description TEXT Replace the shared description; empty text clears it.",
|
|
226
|
+
],
|
|
227
|
+
examples: [
|
|
228
|
+
'ipab swarm update work --name "Team" --description "Shared workspace"',
|
|
229
|
+
'ipab swarm update --description ""',
|
|
230
|
+
],
|
|
231
|
+
notes: [
|
|
232
|
+
"Requires at least one field. Members can change only their own profile.",
|
|
233
|
+
"Content-CID CAS prevents overwriting concurrent organization changes.",
|
|
234
|
+
"Shared name changes do not rename local registry aliases.",
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
search: {
|
|
238
|
+
summary: "Search formal Names across registered swarms",
|
|
239
|
+
arguments: [
|
|
240
|
+
"QUERY Case-insensitive literal name substring, 1..256 characters.",
|
|
241
|
+
],
|
|
242
|
+
options: [
|
|
243
|
+
"--current Search only the effective current swarm; conflicts with --swarm.",
|
|
244
|
+
"--force Refresh HEAD for every swarm in the search scope.",
|
|
245
|
+
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
246
|
+
],
|
|
247
|
+
examples: ["ipab search hello", "ipab --swarm work search hello --force"],
|
|
248
|
+
notes: [
|
|
249
|
+
"Searches all registered swarms unless --current or --swarm selects one.",
|
|
250
|
+
"Valid caches use local Names only; absent/expired caches refresh. No payload downloads.",
|
|
251
|
+
"No matches is success, not a reason to refresh valid caches. Any failed swarm fails the whole search.",
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
publish: {
|
|
255
|
+
summary: "Provide built content and explicitly publish a Name",
|
|
256
|
+
options: [
|
|
257
|
+
"--name NAME New formal Name; occupied Names fail.",
|
|
258
|
+
"--expect CID Exact old Artifact node, required for iteration.",
|
|
259
|
+
"--snapshot Name ordinary content without an Artifact; initial only.",
|
|
260
|
+
],
|
|
261
|
+
examples: [
|
|
262
|
+
"ipab publish app.car --name apps/hello",
|
|
263
|
+
"ipab publish APP_CID --name apps/hello --expect OLD_NODE_CID",
|
|
264
|
+
"ipab publish CONTENT_CID",
|
|
265
|
+
],
|
|
266
|
+
notes: [
|
|
267
|
+
"No build, edit, install or execution. CID-only stdout.",
|
|
268
|
+
"Different-name CAS contention is rebased; same-name edits conflict (exit 3).",
|
|
269
|
+
"Kubo pin confirmation precedes HEAD; it does not prove a remote device is online.",
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
get: {
|
|
273
|
+
summary: "Verify and unpack Bundle content without executing it",
|
|
274
|
+
options: [
|
|
275
|
+
"--raw Select the Artifact node instead of its value.",
|
|
276
|
+
"--force Refresh the shared Name's swarm HEAD.",
|
|
277
|
+
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
278
|
+
"-o, --output DIRECTORY New or empty directory; defaults to a unique temporary directory.",
|
|
279
|
+
],
|
|
280
|
+
examples: [
|
|
281
|
+
"ipab --json get ipab:///apps/hello -o hello-app",
|
|
282
|
+
"ipab get ipab://work/apps/hello -o hello-app",
|
|
283
|
+
"ipab get CONTENT_CID",
|
|
284
|
+
"ipab get --raw RELEASE_CID",
|
|
285
|
+
],
|
|
286
|
+
notes: [
|
|
287
|
+
"Stdout contains only the absolute directory path; --json also returns content and original target CIDs.",
|
|
288
|
+
"Temporary exports remain after exit; copy before cleanup, not symlink. Use --output for a persistent destination.",
|
|
289
|
+
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
290
|
+
"Does not install, build, edit, or automatically retrieve associated source.",
|
|
291
|
+
],
|
|
292
|
+
},
|
|
76
293
|
"store usage": {
|
|
77
294
|
summary: "Query cached and recursively pinned block bytes",
|
|
78
295
|
examples: ["ipab store usage", "ipab --json store usage"],
|
|
@@ -105,21 +322,24 @@ const commandHelp = {
|
|
|
105
322
|
notes: ["Does not install dependencies or execute template code."],
|
|
106
323
|
},
|
|
107
324
|
build: {
|
|
108
|
-
summary: "
|
|
109
|
-
arguments: [
|
|
325
|
+
summary: "Assemble any Bundle using ipab.build.yaml (no compilation)",
|
|
326
|
+
arguments: [
|
|
327
|
+
"SOURCE Recipe file or Bundle directory (default: current directory).",
|
|
328
|
+
],
|
|
110
329
|
options: [
|
|
111
|
-
"-o, --output FILE Destination (default: dist/
|
|
330
|
+
"-o, --output FILE Destination (default: dist/bundle.car).",
|
|
112
331
|
"--replace Allow replacing existing regular artifacts.",
|
|
113
|
-
"--no-import Write CAR
|
|
114
|
-
|
|
115
|
-
|
|
332
|
+
"--no-import Write the CAR without importing the Bundle into Store.",
|
|
333
|
+
],
|
|
334
|
+
examples: [
|
|
335
|
+
"ipab build prepared-app",
|
|
336
|
+
"ipab build ipab.build.yaml --replace",
|
|
116
337
|
],
|
|
117
|
-
examples: ["ipab build", "ipab build hello --replace --without-source"],
|
|
118
338
|
notes: [
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
339
|
+
"Recipe explicitly maps source files and exact CID imports to target paths.",
|
|
340
|
+
"Instance paths come from .bundle.yaml; the referenced file defines the type. Imported DAG identities are preserved.",
|
|
341
|
+
"Legacy App ipab.yaml is rejected; use project preparation tools separately.",
|
|
342
|
+
"Select explicit files; review private files before providing Bundles.",
|
|
123
343
|
"Store failures preserve the CAR; retry with ipab bundle import FILE.car.",
|
|
124
344
|
],
|
|
125
345
|
},
|
|
@@ -134,7 +354,7 @@ const commandHelp = {
|
|
|
134
354
|
],
|
|
135
355
|
examples: [
|
|
136
356
|
"ipab bundle build note",
|
|
137
|
-
"ipab bundle build types\\.bundle.yaml --schema-only",
|
|
357
|
+
"ipab bundle build types\\.bundle-type.yaml --schema-only",
|
|
138
358
|
],
|
|
139
359
|
notes: [
|
|
140
360
|
"Imports into the configured Store without pinning or executing Apps.",
|
|
@@ -157,20 +377,23 @@ const commandHelp = {
|
|
|
157
377
|
],
|
|
158
378
|
},
|
|
159
379
|
exec: {
|
|
160
|
-
summary: "Run an App by CID or
|
|
380
|
+
summary: "Run an App by CID, named pin or IPAB URI",
|
|
161
381
|
arguments: [
|
|
162
382
|
"APP_ARGS Everything after APP is passed verbatim, including --help.",
|
|
163
383
|
],
|
|
164
384
|
options: [
|
|
165
385
|
"--log Record stdout/stderr; must precede APP. Requires history enabled.",
|
|
386
|
+
"--force Refresh the shared Name's swarm HEAD; must precede APP.",
|
|
387
|
+
"--no-force Override swarm.forceRefresh; must precede APP.",
|
|
166
388
|
],
|
|
167
389
|
examples: [
|
|
168
390
|
"ipab exec reader",
|
|
169
|
-
"ipab exec reader --help",
|
|
170
391
|
"ipab exec --log reader",
|
|
392
|
+
"ipab exec ipab://work/apps/hello --help",
|
|
171
393
|
],
|
|
172
394
|
notes: [
|
|
173
395
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
396
|
+
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
174
397
|
"History stores argv by default; do not put secrets in arguments.",
|
|
175
398
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
176
399
|
"--json is not supported; App stdio is passed through.",
|
|
@@ -178,11 +401,21 @@ const commandHelp = {
|
|
|
178
401
|
},
|
|
179
402
|
open: {
|
|
180
403
|
summary: "Open content with its registered App",
|
|
181
|
-
arguments: ["CONTENT Bundle CID or
|
|
182
|
-
options: [
|
|
183
|
-
|
|
404
|
+
arguments: ["CONTENT Bundle CID, named pin or IPAB URI."],
|
|
405
|
+
options: [
|
|
406
|
+
"--log Record stdout/stderr; requires history enabled.",
|
|
407
|
+
"--raw Open the Artifact node rather than its value.",
|
|
408
|
+
"--force Refresh the shared Name's swarm HEAD.",
|
|
409
|
+
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
410
|
+
],
|
|
411
|
+
examples: [
|
|
412
|
+
"ipab open CONTENT_CID",
|
|
413
|
+
"ipab open --log my-note",
|
|
414
|
+
"ipab open ipab:///documents/readme",
|
|
415
|
+
],
|
|
184
416
|
notes: [
|
|
185
417
|
"Requires a saved registration and App support for the exact content type.",
|
|
418
|
+
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
186
419
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
187
420
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
188
421
|
"--json is not supported; App stdio is passed through.",
|
|
@@ -271,11 +504,15 @@ const commandHelp = {
|
|
|
271
504
|
"config set": {
|
|
272
505
|
summary: "Save a local configuration value",
|
|
273
506
|
examples: [
|
|
507
|
+
"ipab config set pointers.apiKey -",
|
|
274
508
|
"ipab config set store.gateway http://127.0.0.1:8080",
|
|
275
509
|
"ipab config set history.enabled false",
|
|
276
510
|
],
|
|
277
511
|
notes: [
|
|
278
512
|
"store.gateway is a read-only HTTP gateway; blocks, pins and GC remain local.",
|
|
513
|
+
"pointers.service is a canonical HTTPS origin (HTTP loopback allowed).",
|
|
514
|
+
"pointers.apiKey is accepted only through stdin using VALUE '-'; queries and confirmations redact it.",
|
|
515
|
+
"Saving pointers.apiKey protects state SQLite files with account-only Unix modes or Windows ACLs.",
|
|
279
516
|
],
|
|
280
517
|
},
|
|
281
518
|
"config reset": {
|
|
@@ -327,6 +564,7 @@ const commandHelp = {
|
|
|
327
564
|
};
|
|
328
565
|
export function help(path = "") {
|
|
329
566
|
const globalOptions = `Global options (before COMMAND):
|
|
567
|
+
--swarm URL|ALIAS Select shared swarm (otherwise swarm.default; URI swarm takes precedence)
|
|
330
568
|
--state-dir PATH Set the local state directory
|
|
331
569
|
--store-gateway URL Use a read-only upstream HTTP gateway
|
|
332
570
|
--json Output management/development metadata, not App stdio`;
|
|
@@ -346,6 +584,11 @@ Create:
|
|
|
346
584
|
bundle ${groups.bundle}
|
|
347
585
|
|
|
348
586
|
Manage:
|
|
587
|
+
setup ${commandHelp.setup.summary}
|
|
588
|
+
swarm ${groups.swarm}
|
|
589
|
+
search Search formal Names across registered swarms
|
|
590
|
+
publish ${commandHelp.publish.summary}
|
|
591
|
+
get ${commandHelp.get.summary}
|
|
349
592
|
pin ${groups.pin}
|
|
350
593
|
register ${groups.register}
|
|
351
594
|
config ${groups.config}
|
|
@@ -512,12 +755,16 @@ export function parse(argv) {
|
|
|
512
755
|
flags.json = true;
|
|
513
756
|
else if (flag === "--store-rpc")
|
|
514
757
|
syntax("Store RPC is no longer supported. Use --store-gateway with an HTTP gateway URL; existing Kubo pins are not migrated.");
|
|
515
|
-
else if (flag === "--state-dir" ||
|
|
758
|
+
else if (flag === "--state-dir" ||
|
|
759
|
+
flag === "--store-gateway" ||
|
|
760
|
+
flag === "--swarm") {
|
|
516
761
|
const value = tokens.shift();
|
|
517
762
|
if (!value || value.startsWith("-"))
|
|
518
763
|
syntax(`${flag} needs a value.`);
|
|
519
764
|
if (flag === "--state-dir")
|
|
520
765
|
flags.stateDir = value;
|
|
766
|
+
else if (flag === "--swarm")
|
|
767
|
+
flags.swarm = value;
|
|
521
768
|
else {
|
|
522
769
|
flags.storeGateway = publicUrl(value);
|
|
523
770
|
}
|
|
@@ -539,10 +786,14 @@ export function parse(argv) {
|
|
|
539
786
|
if (group === "exec") {
|
|
540
787
|
if (flags.json)
|
|
541
788
|
syntax("--json is not supported for exec/open.");
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
789
|
+
while (["--log", "--force", "--no-force"].includes(tokens[0] ?? "")) {
|
|
790
|
+
const option = tokens.shift().slice(2);
|
|
791
|
+
if (Object.hasOwn(result.options, option))
|
|
792
|
+
syntax(`Duplicate option --${option}.`);
|
|
793
|
+
result.options[option] = true;
|
|
545
794
|
}
|
|
795
|
+
if (result.options.force && result.options["no-force"])
|
|
796
|
+
syntax("--force and --no-force are mutually exclusive.");
|
|
546
797
|
if (tokens[0] === "-h" || tokens[0] === "--help") {
|
|
547
798
|
result.help = true;
|
|
548
799
|
return result;
|
|
@@ -552,8 +803,16 @@ export function parse(argv) {
|
|
|
552
803
|
result.positional = tokens;
|
|
553
804
|
return result;
|
|
554
805
|
}
|
|
555
|
-
if (!["open", "init", "build"].includes(group)) {
|
|
556
|
-
if (![
|
|
806
|
+
if (!["open", "init", "build", "publish", "get", "search", "setup"].includes(group)) {
|
|
807
|
+
if (![
|
|
808
|
+
"bundle",
|
|
809
|
+
"pin",
|
|
810
|
+
"register",
|
|
811
|
+
"config",
|
|
812
|
+
"history",
|
|
813
|
+
"store",
|
|
814
|
+
"swarm",
|
|
815
|
+
].includes(group))
|
|
557
816
|
syntax(`Unknown command "${group}".`);
|
|
558
817
|
if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
|
|
559
818
|
result.help = true;
|
|
@@ -574,31 +833,77 @@ export function parse(argv) {
|
|
|
574
833
|
result.help = true;
|
|
575
834
|
return result;
|
|
576
835
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
836
|
+
if (result.path === "config set" &&
|
|
837
|
+
tokens.includes("pointers.apiKey") &&
|
|
838
|
+
!(tokens.length === 2 && tokens[1] === "-"))
|
|
839
|
+
syntax("API key must be provided through '-' and piped stdin; never pass it in command arguments.");
|
|
840
|
+
const booleans = result.path === "setup"
|
|
841
|
+
? ["yes"]
|
|
842
|
+
: result.path === "bundle build"
|
|
843
|
+
? ["replace", "schema-only", "no-import"]
|
|
844
|
+
: result.path === "build"
|
|
845
|
+
? ["replace", "no-import"]
|
|
846
|
+
: result.path === "publish"
|
|
847
|
+
? ["snapshot"]
|
|
848
|
+
: result.path === "get"
|
|
849
|
+
? ["raw", "force", "no-force"]
|
|
850
|
+
: result.path === "search"
|
|
851
|
+
? ["current", "force", "no-force"]
|
|
852
|
+
: result.path === "swarm approve"
|
|
853
|
+
? ["yes", "again"]
|
|
854
|
+
: result.path === "swarm exclude"
|
|
855
|
+
? ["yes"]
|
|
856
|
+
: result.path === "register set"
|
|
857
|
+
? ["replace"]
|
|
858
|
+
: result.path === "history remove"
|
|
859
|
+
? ["yes"]
|
|
860
|
+
: result.path === "open"
|
|
861
|
+
? ["log", "raw", "force", "no-force"]
|
|
862
|
+
: [];
|
|
863
|
+
const values = result.path === "swarm create"
|
|
864
|
+
? ["service", "resume", "name", "description", "alias"]
|
|
865
|
+
: result.path === "swarm add"
|
|
866
|
+
? ["alias"]
|
|
867
|
+
: result.path === "swarm request"
|
|
868
|
+
? ["owner-fingerprint", "name", "alias", "output"]
|
|
869
|
+
: result.path === "swarm export"
|
|
870
|
+
? ["output"]
|
|
871
|
+
: result.path === "swarm profile"
|
|
872
|
+
? ["name", "address"]
|
|
873
|
+
: result.path === "swarm update"
|
|
874
|
+
? ["name", "description"]
|
|
875
|
+
: result.path === "swarm approve"
|
|
876
|
+
? []
|
|
877
|
+
: result.path === "publish"
|
|
878
|
+
? ["name", "expect"]
|
|
879
|
+
: result.path === "get"
|
|
880
|
+
? ["output"]
|
|
881
|
+
: result.path === "init"
|
|
882
|
+
? ["template"]
|
|
883
|
+
: result.path === "bundle build" ||
|
|
884
|
+
result.path === "build"
|
|
885
|
+
? ["output"]
|
|
886
|
+
: result.path === "history list"
|
|
887
|
+
? [
|
|
888
|
+
"app",
|
|
889
|
+
"status",
|
|
890
|
+
"since",
|
|
891
|
+
"until",
|
|
892
|
+
"limit",
|
|
893
|
+
"before",
|
|
894
|
+
]
|
|
895
|
+
: result.path === "history remove"
|
|
896
|
+
? ["app", "status", "since", "until"]
|
|
897
|
+
: result.path === "pin list"
|
|
898
|
+
? ["type"]
|
|
899
|
+
: [];
|
|
599
900
|
while (tokens.length) {
|
|
600
901
|
const value = tokens.shift();
|
|
601
|
-
if (
|
|
902
|
+
if (result.path === "swarm exclude" &&
|
|
903
|
+
/^--[A-Za-z0-9_-]{41}$/.test(value)) {
|
|
904
|
+
result.positional.push(value);
|
|
905
|
+
}
|
|
906
|
+
else if (value.startsWith("--") || value === "-o") {
|
|
602
907
|
const option = value === "-o" ? "output" : value.slice(2);
|
|
603
908
|
if (result.path === "init" && option === "param") {
|
|
604
909
|
const input = tokens.shift();
|
|
@@ -613,7 +918,11 @@ export function parse(argv) {
|
|
|
613
918
|
result.options[option] = true;
|
|
614
919
|
else if (values.includes(option)) {
|
|
615
920
|
const input = tokens.shift();
|
|
616
|
-
if (
|
|
921
|
+
if (input === undefined ||
|
|
922
|
+
(input.startsWith("--") &&
|
|
923
|
+
!(["resume", "owner-fingerprint"].includes(option) &&
|
|
924
|
+
/^[A-Za-z0-9_-]{43}$/.test(input))) ||
|
|
925
|
+
(input === "" && result.path !== "swarm update"))
|
|
617
926
|
syntax(`${value} needs a value.`);
|
|
618
927
|
result.options[option] = input;
|
|
619
928
|
}
|
|
@@ -623,7 +932,30 @@ export function parse(argv) {
|
|
|
623
932
|
else
|
|
624
933
|
result.positional.push(value);
|
|
625
934
|
}
|
|
935
|
+
if (result.options.force && result.options["no-force"])
|
|
936
|
+
syntax("--force and --no-force are mutually exclusive.");
|
|
937
|
+
if (result.path === "search" &&
|
|
938
|
+
result.options.current &&
|
|
939
|
+
flags.swarm !== undefined)
|
|
940
|
+
syntax("--current and --swarm are mutually exclusive.");
|
|
626
941
|
const counts = {
|
|
942
|
+
setup: [0, 0],
|
|
943
|
+
"swarm create": [0, 0],
|
|
944
|
+
"swarm request": [1, 1],
|
|
945
|
+
"swarm approve": [1, 1],
|
|
946
|
+
"swarm export": [1, 1],
|
|
947
|
+
"swarm exclude": [1, 1],
|
|
948
|
+
"swarm resume": [0, 1],
|
|
949
|
+
"swarm profile": [0, 1],
|
|
950
|
+
"swarm status": [0, 1],
|
|
951
|
+
"swarm list": [0, 0],
|
|
952
|
+
"swarm add": [1, 1],
|
|
953
|
+
"swarm use": [1, 1],
|
|
954
|
+
"swarm remove": [1, 1],
|
|
955
|
+
"swarm update": [0, 1],
|
|
956
|
+
publish: [1, 1],
|
|
957
|
+
get: [1, 1],
|
|
958
|
+
search: [1, 1],
|
|
627
959
|
init: [1, 2],
|
|
628
960
|
build: [0, 1],
|
|
629
961
|
"bundle build": [1, 1],
|
|
@@ -673,8 +1005,14 @@ export function parse(argv) {
|
|
|
673
1005
|
if (!(result.path === "config get" && result.positional[0] === "state-dir") &&
|
|
674
1006
|
!(result.path === "config reset" && result.positional[0] === "store.rpc"))
|
|
675
1007
|
configKey(result.positional[0]);
|
|
676
|
-
if (result.path === "config set")
|
|
677
|
-
|
|
1008
|
+
if (result.path === "config set") {
|
|
1009
|
+
if (result.positional[0] === "pointers.apiKey") {
|
|
1010
|
+
if (result.positional[1] !== "-")
|
|
1011
|
+
syntax("Set pointers.apiKey using '-' and piped stdin; never put the key in command-line arguments.");
|
|
1012
|
+
}
|
|
1013
|
+
else
|
|
1014
|
+
parseValue(configKey(result.positional[0]), result.positional[1], true);
|
|
1015
|
+
}
|
|
678
1016
|
}
|
|
679
1017
|
if (typeof result.options.limit === "string")
|
|
680
1018
|
parseValue("history.limit", result.options.limit, true);
|
|
@@ -701,6 +1039,17 @@ async function performCli(argv, io, env) {
|
|
|
701
1039
|
}
|
|
702
1040
|
if (parsed.path === "history remove" && !parsed.options.yes && !io.tty)
|
|
703
1041
|
syntax("Non-interactive history remove requires --yes.");
|
|
1042
|
+
if (parsed.path === "setup") {
|
|
1043
|
+
if (!parsed.options.yes &&
|
|
1044
|
+
(!io.tty ||
|
|
1045
|
+
!(await io.confirm("Install checksum-verified Kubo and initialize/reuse the protected HOME identity? No daemon will be contacted or started."))))
|
|
1046
|
+
throw new HostError("Setup requires explicit --yes or interactive confirmation.");
|
|
1047
|
+
const result = await setupDevice(stateLocation(parsed.flags, env).path, env);
|
|
1048
|
+
io.out(parsed.flags.json
|
|
1049
|
+
? JSON.stringify(result)
|
|
1050
|
+
: `Kubo ${result.kuboVersion}: ${result.binary}\nAccount fingerprint: ${result.fingerprint}\nReady. Nodes start only when a Swarm is used.`);
|
|
1051
|
+
return 0;
|
|
1052
|
+
}
|
|
704
1053
|
const builtins = await builtinContent();
|
|
705
1054
|
state = new State(stateLocation(parsed.flags, env).path, builtins.pins);
|
|
706
1055
|
if (parsed.path === "config reset" &&
|
|
@@ -711,16 +1060,312 @@ async function performCli(argv, io, env) {
|
|
|
711
1060
|
: "Removed legacy store.rpc configuration. Existing Kubo pins and content are unchanged.");
|
|
712
1061
|
return 0;
|
|
713
1062
|
}
|
|
714
|
-
const items = effectiveConfig(state.config(), parsed.flags, env);
|
|
1063
|
+
const items = effectiveConfig(state.config(), parsed.flags, env, (reference) => state.resolveSwarm(reference));
|
|
715
1064
|
const value = (key) => items.find((item) => item.key === key).value;
|
|
716
1065
|
const emit = (result, human) => {
|
|
717
1066
|
io.out(parsed.flags.json ? JSON.stringify(result) : human);
|
|
718
1067
|
};
|
|
719
1068
|
const [first, second] = parsed.positional;
|
|
1069
|
+
const selectedSwarm = value("swarm.default") === null
|
|
1070
|
+
? undefined
|
|
1071
|
+
: String(value("swarm.default"));
|
|
1072
|
+
const swarmContext = () => ({
|
|
1073
|
+
get store() {
|
|
1074
|
+
return store;
|
|
1075
|
+
},
|
|
1076
|
+
set store(next) {
|
|
1077
|
+
store = next;
|
|
1078
|
+
},
|
|
1079
|
+
state: state,
|
|
1080
|
+
env,
|
|
1081
|
+
stateDir: stateLocation(parsed.flags, env).path,
|
|
1082
|
+
cacheTtl: Number(value("swarm.cacheTtl")),
|
|
1083
|
+
forceRefresh: parsed.options.force
|
|
1084
|
+
? true
|
|
1085
|
+
: parsed.options["no-force"]
|
|
1086
|
+
? false
|
|
1087
|
+
: Boolean(value("swarm.forceRefresh")),
|
|
1088
|
+
diagnostic: (text) => {
|
|
1089
|
+
io.err(text);
|
|
1090
|
+
},
|
|
1091
|
+
...(typeof value("pointers.service") === "string"
|
|
1092
|
+
? { pointerService: String(value("pointers.service")) }
|
|
1093
|
+
: {}),
|
|
1094
|
+
...(typeof value("pointers.apiKey") === "string"
|
|
1095
|
+
? { pointerApiKey: String(value("pointers.apiKey")) }
|
|
1096
|
+
: {}),
|
|
1097
|
+
});
|
|
720
1098
|
const filter = parsed.path.startsWith("history ")
|
|
721
1099
|
? filters(state, parsed.options)
|
|
722
1100
|
: {};
|
|
1101
|
+
const selection = () => {
|
|
1102
|
+
const current = effectiveConfig(state.config(), parsed.flags, env, (reference) => state.resolveSwarm(reference)).find((item) => item.key === "swarm.default");
|
|
1103
|
+
return {
|
|
1104
|
+
savedCurrent: state.config()["swarm.default"] ?? null,
|
|
1105
|
+
effectiveCurrent: current.value,
|
|
1106
|
+
source: current.source,
|
|
1107
|
+
};
|
|
1108
|
+
};
|
|
723
1109
|
switch (parsed.path) {
|
|
1110
|
+
case "swarm list": {
|
|
1111
|
+
const result = { swarms: state.swarms(), ...selection() };
|
|
1112
|
+
emit({
|
|
1113
|
+
...result,
|
|
1114
|
+
swarms: result.swarms.map((entry) => ({
|
|
1115
|
+
configUrl: entry.cid,
|
|
1116
|
+
alias: entry.alias,
|
|
1117
|
+
})),
|
|
1118
|
+
}, [
|
|
1119
|
+
...result.swarms.map((entry) => `${entry.cid === result.savedCurrent ? "*" : " "} ${printable(entry.alias ?? entry.cid)} ${entry.cid}`),
|
|
1120
|
+
`Saved current: ${result.savedCurrent ?? "(none)"}`,
|
|
1121
|
+
`Effective current: ${result.effectiveCurrent ?? "(none)"} (${result.source})`,
|
|
1122
|
+
].join("\n"));
|
|
1123
|
+
break;
|
|
1124
|
+
}
|
|
1125
|
+
case "swarm use": {
|
|
1126
|
+
state.useSwarm(first);
|
|
1127
|
+
const result = selection();
|
|
1128
|
+
emit(result, `Saved current swarm: ${result.savedCurrent}`);
|
|
1129
|
+
if (result.source === "flag" || result.source === "env")
|
|
1130
|
+
io.err(`The saved default is overridden by ${result.source}: ${result.effectiveCurrent}.`);
|
|
1131
|
+
break;
|
|
1132
|
+
}
|
|
1133
|
+
case "swarm remove": {
|
|
1134
|
+
const removed = state.removeSwarm(first);
|
|
1135
|
+
emit({ removed, savedCurrent: state.config()["swarm.default"] ?? null }, `Removed registration ${removed}. Credentials, content and remote membership are unchanged.`);
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
case "swarm add":
|
|
1139
|
+
case "swarm update":
|
|
1140
|
+
case "search":
|
|
1141
|
+
case "swarm create":
|
|
1142
|
+
case "swarm request":
|
|
1143
|
+
case "swarm approve":
|
|
1144
|
+
case "swarm export":
|
|
1145
|
+
case "swarm exclude":
|
|
1146
|
+
case "swarm resume":
|
|
1147
|
+
case "swarm profile":
|
|
1148
|
+
case "swarm status":
|
|
1149
|
+
case "publish":
|
|
1150
|
+
case "get": {
|
|
1151
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1152
|
+
const context = swarmContext();
|
|
1153
|
+
if (parsed.path === "swarm export") {
|
|
1154
|
+
const id = await exportRequest(context, state.resolveSwarm(first), String(parsed.options.output ?? ""));
|
|
1155
|
+
emit({ id }, id);
|
|
1156
|
+
break;
|
|
1157
|
+
}
|
|
1158
|
+
if (["swarm exclude", "swarm resume", "swarm profile"].includes(parsed.path)) {
|
|
1159
|
+
const url = parsed.path === "swarm exclude"
|
|
1160
|
+
? selectedSwarm
|
|
1161
|
+
: first
|
|
1162
|
+
? state.resolveSwarm(first)
|
|
1163
|
+
: selectedSwarm;
|
|
1164
|
+
if (!url)
|
|
1165
|
+
syntax("Select a Swarm configuration URL or alias.");
|
|
1166
|
+
if (parsed.path === "swarm exclude") {
|
|
1167
|
+
if (!parsed.options.yes)
|
|
1168
|
+
syntax("Member removal is irreversible; --yes required.");
|
|
1169
|
+
await removeMember(context, url, first);
|
|
1170
|
+
}
|
|
1171
|
+
else if (parsed.path === "swarm resume")
|
|
1172
|
+
await resumeRemoval(context, url);
|
|
1173
|
+
else {
|
|
1174
|
+
const profile = await updateProfile(context, url, {
|
|
1175
|
+
...(typeof parsed.options.name === "string"
|
|
1176
|
+
? { name: parsed.options.name }
|
|
1177
|
+
: {}),
|
|
1178
|
+
...(typeof parsed.options.address === "string"
|
|
1179
|
+
? { addresses: [parsed.options.address] }
|
|
1180
|
+
: {}),
|
|
1181
|
+
});
|
|
1182
|
+
emit(profile, JSON.stringify(profile));
|
|
1183
|
+
store = context.store;
|
|
1184
|
+
break;
|
|
1185
|
+
}
|
|
1186
|
+
store = context.store;
|
|
1187
|
+
emit({ url, completed: true }, `Organization switch complete: ${url}`);
|
|
1188
|
+
break;
|
|
1189
|
+
}
|
|
1190
|
+
if (parsed.path === "swarm update") {
|
|
1191
|
+
const cid = first ? state.resolveSwarm(first) : selectedSwarm;
|
|
1192
|
+
if (!cid)
|
|
1193
|
+
syntax("swarm update requires a registered alias, configuration URL or current swarm.");
|
|
1194
|
+
const result = await updateSwarm(context, cid, {
|
|
1195
|
+
...(typeof parsed.options.name === "string"
|
|
1196
|
+
? { name: parsed.options.name }
|
|
1197
|
+
: {}),
|
|
1198
|
+
...(typeof parsed.options.description === "string"
|
|
1199
|
+
? { description: parsed.options.description }
|
|
1200
|
+
: {}),
|
|
1201
|
+
});
|
|
1202
|
+
emit(result, `Swarm: ${result.configUrl}\nName: ${printable(result.properties.name)}\nDescription: ${printable(result.properties.description)}\nHEAD ID: ${result.headId}\nConfig content CID: ${result.valueCid}`);
|
|
1203
|
+
break;
|
|
1204
|
+
}
|
|
1205
|
+
if (parsed.path === "swarm add") {
|
|
1206
|
+
const cid = state.resolveSwarm(first);
|
|
1207
|
+
await addSwarm(context, cid, typeof parsed.options.alias === "string"
|
|
1208
|
+
? parsed.options.alias
|
|
1209
|
+
: undefined);
|
|
1210
|
+
const entry = state.registeredSwarm(cid);
|
|
1211
|
+
emit({
|
|
1212
|
+
configUrl: entry.cid,
|
|
1213
|
+
alias: entry.alias,
|
|
1214
|
+
savedCurrent: state.config()["swarm.default"] ?? null,
|
|
1215
|
+
}, `Registered swarm ${entry.alias ?? cid} (${cid}).`);
|
|
1216
|
+
break;
|
|
1217
|
+
}
|
|
1218
|
+
if (parsed.path === "search") {
|
|
1219
|
+
const source = items.find((item) => item.key === "swarm.default").source;
|
|
1220
|
+
const limited = parsed.options.current || source === "flag";
|
|
1221
|
+
if (limited && !selectedSwarm)
|
|
1222
|
+
syntax("Search of the current swarm requires --swarm or swarm.default.");
|
|
1223
|
+
const registrations = state.swarms();
|
|
1224
|
+
const scope = limited
|
|
1225
|
+
? [
|
|
1226
|
+
{
|
|
1227
|
+
cid: selectedSwarm,
|
|
1228
|
+
alias: registrations.find((entry) => entry.cid === selectedSwarm)
|
|
1229
|
+
?.alias ?? null,
|
|
1230
|
+
},
|
|
1231
|
+
]
|
|
1232
|
+
: registrations;
|
|
1233
|
+
const result = await searchNames(context, first, scope);
|
|
1234
|
+
emit(result, result.matches.length
|
|
1235
|
+
? result.matches
|
|
1236
|
+
.map((match) => `${printable(match.alias ?? match.swarm)} ${printable(match.name)} ${match.targetCid}\n ipab get ${printable(match.reference)}`)
|
|
1237
|
+
.join("\n")
|
|
1238
|
+
: "No matching Names.");
|
|
1239
|
+
break;
|
|
1240
|
+
}
|
|
1241
|
+
if (parsed.path === "swarm status") {
|
|
1242
|
+
const cid = first ? state.resolveSwarm(first) : selectedSwarm;
|
|
1243
|
+
if (!cid)
|
|
1244
|
+
syntax("swarm status requires a configuration URL or swarm.default.");
|
|
1245
|
+
const { head, config } = await swarmHeader(context, cid, true);
|
|
1246
|
+
store = context.store;
|
|
1247
|
+
emit({
|
|
1248
|
+
configUrl: cid,
|
|
1249
|
+
owner: config.owner,
|
|
1250
|
+
ownerFingerprint: await keyId(config.owner),
|
|
1251
|
+
epoch: config.epoch,
|
|
1252
|
+
peerId: context.node.peerId,
|
|
1253
|
+
addresses: context.node.addresses,
|
|
1254
|
+
root: head.root,
|
|
1255
|
+
valueCid: head.cid,
|
|
1256
|
+
properties: {
|
|
1257
|
+
name: config.name,
|
|
1258
|
+
description: config.description,
|
|
1259
|
+
},
|
|
1260
|
+
}, `Swarm: ${cid}\nOwner fingerprint: ${await keyId(config.owner)}\nPeerID: ${context.node.peerId}\nLocal address: ${context.node.addresses.join(", ")}\nName: ${printable(config.name)}\nDescription: ${printable(config.description)}\nHEAD: ${head.root}\nContent CID: ${head.cid}`);
|
|
1261
|
+
break;
|
|
1262
|
+
}
|
|
1263
|
+
if (parsed.path === "get") {
|
|
1264
|
+
const localCid = first.startsWith("ipab://")
|
|
1265
|
+
? undefined
|
|
1266
|
+
: state.resolve(first);
|
|
1267
|
+
const builtin = builtins.pins.find((pin) => pin.cid === localCid);
|
|
1268
|
+
const selected = builtin
|
|
1269
|
+
? { cid: builtin.cid, targetCid: builtin.cid }
|
|
1270
|
+
: await resolveReference(context, first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw));
|
|
1271
|
+
const contentStore = context.store;
|
|
1272
|
+
const source = IpfsStore.fromClient({
|
|
1273
|
+
block: {
|
|
1274
|
+
get: (key, options) => {
|
|
1275
|
+
options?.signal?.throwIfAborted();
|
|
1276
|
+
const builtin = builtins.blocks.get(CID.parse(key).toV1().toString());
|
|
1277
|
+
return builtin
|
|
1278
|
+
? Promise.resolve(builtin.slice())
|
|
1279
|
+
: contentStore.block.get(key, options);
|
|
1280
|
+
},
|
|
1281
|
+
},
|
|
1282
|
+
}, contentStore.limits);
|
|
1283
|
+
let directory;
|
|
1284
|
+
try {
|
|
1285
|
+
directory = await getBundle(source, selected.cid, typeof parsed.options.output === "string"
|
|
1286
|
+
? parsed.options.output
|
|
1287
|
+
: undefined);
|
|
1288
|
+
}
|
|
1289
|
+
finally {
|
|
1290
|
+
await source.close();
|
|
1291
|
+
}
|
|
1292
|
+
const closing = store;
|
|
1293
|
+
store = undefined;
|
|
1294
|
+
await closeStore(closing, undefined);
|
|
1295
|
+
state.close();
|
|
1296
|
+
state = undefined;
|
|
1297
|
+
emit({ ...selected, directory }, directory);
|
|
1298
|
+
break;
|
|
1299
|
+
}
|
|
1300
|
+
let cid;
|
|
1301
|
+
if (parsed.path === "swarm create") {
|
|
1302
|
+
cid = await createSwarm(context, {
|
|
1303
|
+
...(typeof parsed.options.service === "string"
|
|
1304
|
+
? { service: parsed.options.service }
|
|
1305
|
+
: {}),
|
|
1306
|
+
...(typeof parsed.options.resume === "string"
|
|
1307
|
+
? { resume: parsed.options.resume }
|
|
1308
|
+
: {}),
|
|
1309
|
+
properties: {
|
|
1310
|
+
name: String(parsed.options.name ?? ""),
|
|
1311
|
+
description: String(parsed.options.description ?? ""),
|
|
1312
|
+
},
|
|
1313
|
+
...(typeof parsed.options.alias === "string"
|
|
1314
|
+
? { alias: parsed.options.alias }
|
|
1315
|
+
: {}),
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
else if (parsed.path === "swarm request")
|
|
1319
|
+
cid = await requestMembership(context, first, {
|
|
1320
|
+
ownerFingerprint: String(parsed.options["owner-fingerprint"] ?? ""),
|
|
1321
|
+
...(typeof parsed.options.name === "string"
|
|
1322
|
+
? { name: parsed.options.name }
|
|
1323
|
+
: {}),
|
|
1324
|
+
...(typeof parsed.options.alias === "string"
|
|
1325
|
+
? { alias: parsed.options.alias }
|
|
1326
|
+
: {}),
|
|
1327
|
+
...(typeof parsed.options.output === "string"
|
|
1328
|
+
? { output: parsed.options.output }
|
|
1329
|
+
: {}),
|
|
1330
|
+
});
|
|
1331
|
+
else if (parsed.path === "swarm approve") {
|
|
1332
|
+
const request = await verifiedRequest(first);
|
|
1333
|
+
io.err(await membershipRequestSummary(request));
|
|
1334
|
+
if (!parsed.options.yes &&
|
|
1335
|
+
(!io.tty ||
|
|
1336
|
+
!(await io.confirm(`Approve the verified Request ${request.id} above? This grants current HEAD and the member's profile write access; all reads are public.`))))
|
|
1337
|
+
throw new HostError("Approval requires explicit --yes or interactive confirmation.");
|
|
1338
|
+
cid = await approveMembership(context, request, {
|
|
1339
|
+
again: Boolean(parsed.options.again),
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
else {
|
|
1343
|
+
let content;
|
|
1344
|
+
if (first.toLowerCase().endsWith(".car"))
|
|
1345
|
+
content = (await importBundle(first, () => Promise.resolve(store))).cid;
|
|
1346
|
+
else
|
|
1347
|
+
content = exactCid(first);
|
|
1348
|
+
cid = await publish(context, content, {
|
|
1349
|
+
...(selectedSwarm ? { swarm: selectedSwarm } : {}),
|
|
1350
|
+
...(typeof parsed.options.name === "string"
|
|
1351
|
+
? { name: parsed.options.name }
|
|
1352
|
+
: {}),
|
|
1353
|
+
...(typeof parsed.options.expect === "string"
|
|
1354
|
+
? { expect: parsed.options.expect }
|
|
1355
|
+
: {}),
|
|
1356
|
+
snapshot: Boolean(parsed.options.snapshot),
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
store = context.store;
|
|
1360
|
+
if (parsed.path === "swarm create")
|
|
1361
|
+
io.err(`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config()["swarm.default"] ?? "(none)"}.`);
|
|
1362
|
+
emit(parsed.path === "swarm request"
|
|
1363
|
+
? { requestId: cid }
|
|
1364
|
+
: parsed.path === "swarm create" || parsed.path === "swarm approve"
|
|
1365
|
+
? { configUrl: cid }
|
|
1366
|
+
: { cid }, cid);
|
|
1367
|
+
break;
|
|
1368
|
+
}
|
|
724
1369
|
case "store usage":
|
|
725
1370
|
case "store gc": {
|
|
726
1371
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
@@ -779,7 +1424,7 @@ async function performCli(argv, io, env) {
|
|
|
779
1424
|
: first;
|
|
780
1425
|
if (parsed.path === "bundle build" || parsed.path === "build")
|
|
781
1426
|
io.err(parsed.path === "build"
|
|
782
|
-
? "
|
|
1427
|
+
? "Assembling and validating Bundle (no compilation)..."
|
|
783
1428
|
: "Validating and building bundle...");
|
|
784
1429
|
if (parsed.path === "bundle import")
|
|
785
1430
|
io.err("Validating and importing CAR into Store...");
|
|
@@ -800,14 +1445,9 @@ async function performCli(argv, io, env) {
|
|
|
800
1445
|
: {}),
|
|
801
1446
|
})
|
|
802
1447
|
: parsed.path === "build"
|
|
803
|
-
? await
|
|
1448
|
+
? await assembleBundle(first, {
|
|
804
1449
|
...request,
|
|
805
1450
|
replace: Boolean(parsed.options.replace),
|
|
806
|
-
...(parsed.options["with-source"]
|
|
807
|
-
? { includeSource: true }
|
|
808
|
-
: parsed.options["without-source"]
|
|
809
|
-
? { includeSource: false }
|
|
810
|
-
: {}),
|
|
811
1451
|
...(typeof parsed.options.output === "string"
|
|
812
1452
|
? { output: parsed.options.output }
|
|
813
1453
|
: {}),
|
|
@@ -843,7 +1483,7 @@ async function performCli(argv, io, env) {
|
|
|
843
1483
|
state = undefined;
|
|
844
1484
|
controller.signal.throwIfAborted();
|
|
845
1485
|
if ("output" in result)
|
|
846
|
-
emit({ ...result, imported: importing }, `CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${result.validation !== undefined ? `\nEntry validation: ${result.validation?.status ?? "not-applicable"}` : ""}
|
|
1486
|
+
emit({ ...result, imported: importing }, `CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${result.validation !== undefined ? `\nEntry validation: ${result.validation?.status ?? "not-applicable"}` : ""}\nStore: ${importing ? "imported (not pinned)" : "not imported (--no-import)"}`);
|
|
847
1487
|
else if (result.kind === "bundle-import")
|
|
848
1488
|
emit(result, `Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}\nEntry validation: ${result.validation?.status ?? "not-applicable"}`);
|
|
849
1489
|
else if (result.kind === "project-init") {
|
|
@@ -851,12 +1491,12 @@ async function performCli(argv, io, env) {
|
|
|
851
1491
|
if (result.files.includes("package.json") &&
|
|
852
1492
|
(result.files.includes("ipab.yaml") ||
|
|
853
1493
|
result.files.includes("ipab.json")))
|
|
854
|
-
io.err(`Next: install declared dependencies in ${JSON.stringify(result.directory)};
|
|
1494
|
+
io.err(`Next: install declared dependencies and explicitly link the candidate @ipab/cli as a project dependency in ${JSON.stringify(result.directory)}; run pnpm build to prepare and package the App. Root ipab build does not compile.`);
|
|
855
1495
|
else if (result.files.includes(".bundle.yaml"))
|
|
856
1496
|
io.err(`Next: ipab bundle build ${JSON.stringify(result.directory)}`);
|
|
857
1497
|
}
|
|
858
1498
|
else
|
|
859
|
-
emit(result, `Kind: ${result.kind}\
|
|
1499
|
+
emit(result, `Kind: ${result.kind}\n${result.manifest ? `Title: ${printable(result.manifest.title)}\nEntry: ${result.manifest.entry}\nType file: ${result.manifest.type}\n` : ""}Type CID: ${result.schemaCid}\nContent type: ${result.type.contentType}\nDefinition validation: passed\nStorage verification: ${result.validation.storage}\nEntry validation: ${result.validation.entry?.status ?? "not-applicable"}`);
|
|
860
1500
|
}
|
|
861
1501
|
catch (cause) {
|
|
862
1502
|
if (cancelled)
|
|
@@ -893,11 +1533,12 @@ async function performCli(argv, io, env) {
|
|
|
893
1533
|
io.err(`Unfinished pin operations (not usable pins): ${JSON.stringify(pending)}. Retry pin add/delete.`);
|
|
894
1534
|
if (invalid.length)
|
|
895
1535
|
io.err(`Legacy non-Bundle pins (not usable pins): ${JSON.stringify(invalid)}. Retention is unchanged; delete explicitly and wrap content in a Bundle before pinning again.`);
|
|
896
|
-
emit({ items: listed, pending, invalid }, table(["NAME", "CID", "KIND", "
|
|
1536
|
+
emit({ items: listed, pending, invalid }, table(["NAME", "CID", "KIND", "TITLE", "TYPE CID", "SOURCE"], listed.map((pin) => [
|
|
897
1537
|
pin.name,
|
|
898
1538
|
pin.cid,
|
|
899
1539
|
pin.kind,
|
|
900
|
-
pin.
|
|
1540
|
+
pin.title,
|
|
1541
|
+
pin.schemaCid,
|
|
901
1542
|
pin.builtin ? "built-in (read-only)" : "user",
|
|
902
1543
|
]), "No named pins."));
|
|
903
1544
|
break;
|
|
@@ -905,7 +1546,7 @@ async function performCli(argv, io, env) {
|
|
|
905
1546
|
case "pin add": {
|
|
906
1547
|
io.err("Fetching, verifying and retaining content in Store...");
|
|
907
1548
|
const result = await addPin(state, first, second, await storeConfiguration(value("store.gateway")));
|
|
908
|
-
emit(result, `${result.name} → ${result.cid}\
|
|
1549
|
+
emit(result, `${result.name} → ${result.cid}\nTitle: ${printable(result.title)}\nType CID: ${result.schemaCid}`);
|
|
909
1550
|
break;
|
|
910
1551
|
}
|
|
911
1552
|
case "pin delete": {
|
|
@@ -918,7 +1559,7 @@ async function performCli(argv, io, env) {
|
|
|
918
1559
|
if (!pin)
|
|
919
1560
|
throw new HostError(`Pin "${first}" does not exist. Run ipab pin list.`);
|
|
920
1561
|
const result = pinDetails(pin);
|
|
921
|
-
emit(result, `Name: ${printable(result.name)}\nCID: ${result.cid}\
|
|
1562
|
+
emit(result, `Name: ${printable(result.name)}\nCID: ${result.cid}\nTitle: ${printable(result.title)}\nType CID: ${result.schemaCid}\nSource: ${result.builtin ? "built-in (read-only; content bundled with IPAB)" : "local registration (not live node verification)"}`);
|
|
922
1563
|
break;
|
|
923
1564
|
}
|
|
924
1565
|
case "pin rename": {
|
|
@@ -946,20 +1587,21 @@ async function performCli(argv, io, env) {
|
|
|
946
1587
|
break;
|
|
947
1588
|
}
|
|
948
1589
|
case "config get": {
|
|
949
|
-
const selected = first
|
|
950
|
-
? items.filter((item) => item.key === first)
|
|
951
|
-
: items;
|
|
1590
|
+
const selected = (first ? items.filter((item) => item.key === first) : items).map(visibleConfig);
|
|
952
1591
|
emit({ items: selected }, table(["KEY", "VALUE", "SOURCE"], selected.map((item) => [item.key, String(item.value), item.source]), "No configuration values."));
|
|
953
1592
|
break;
|
|
954
1593
|
}
|
|
955
1594
|
case "config set": {
|
|
956
1595
|
const key = configKey(first);
|
|
957
|
-
const saved = parseValue(key,
|
|
1596
|
+
const saved = parseValue(key, key === "pointers.apiKey"
|
|
1597
|
+
? await (io.readSecret ?? processIO.readSecret)()
|
|
1598
|
+
: second, true);
|
|
958
1599
|
state.setConfig(key, saved);
|
|
959
1600
|
const source = items.find((item) => item.key === key).source;
|
|
960
1601
|
if (source === "env" || source === "flag")
|
|
961
1602
|
io.err(`Warning: saved user value is masked by ${source}.`);
|
|
962
|
-
|
|
1603
|
+
const display = visibleConfig({ key, value: saved, source: "user" });
|
|
1604
|
+
emit(display, `Saved ${key} = ${printable(String(display.value))} (user).`);
|
|
963
1605
|
break;
|
|
964
1606
|
}
|
|
965
1607
|
case "config reset":
|
|
@@ -1033,9 +1675,11 @@ async function performCli(argv, io, env) {
|
|
|
1033
1675
|
case "open": {
|
|
1034
1676
|
if (parsed.options.log && !value("history.enabled"))
|
|
1035
1677
|
throw new HostError("Execution logging requires history.enabled=true.");
|
|
1036
|
-
const target = state.resolve(first);
|
|
1037
1678
|
await recoverInactive(state);
|
|
1038
1679
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1680
|
+
const context = swarmContext();
|
|
1681
|
+
const target = (await resolveReference(context, first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw))).cid;
|
|
1682
|
+
store = context.store;
|
|
1039
1683
|
let appCid;
|
|
1040
1684
|
let appArgv;
|
|
1041
1685
|
if (parsed.path === "open") {
|