@ipab/cli 0.1.0-rc.6 → 0.1.0-rc.8
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 +96 -34
- package/dist/app-authoring.d.ts +5 -0
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +6 -45
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-prebuild.d.ts +18 -0
- package/dist/app-prebuild.d.ts.map +1 -1
- package/dist/app-prebuild.js +46 -0
- package/dist/app-prebuild.js.map +1 -1
- package/dist/app-templates.d.ts +0 -1
- package/dist/app-templates.d.ts.map +1 -1
- package/dist/app-templates.js +6 -45
- package/dist/app-templates.js.map +1 -1
- package/dist/builtins/skill.ipab.car +0 -0
- package/dist/builtins/template.bundle-viewer.car +0 -0
- package/dist/builtins/template.check.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 +1 -39
- 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 +668 -221
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -4
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +20 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +31 -2
- package/dist/context.js.map +1 -1
- package/dist/errors.d.ts +1 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -20
- package/dist/errors.js.map +1 -1
- package/dist/host-error.d.ts +9 -0
- package/dist/host-error.d.ts.map +1 -0
- package/dist/host-error.js +21 -0
- package/dist/host-error.js.map +1 -0
- package/dist/ipc.d.ts +2 -1
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +61 -3
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.js +1 -1
- package/dist/kubo-install.js.map +1 -1
- package/dist/kubo-peers.d.ts.map +1 -1
- package/dist/kubo-peers.js +2 -1
- package/dist/kubo-peers.js.map +1 -1
- package/dist/kubo-topology.d.ts +19 -0
- package/dist/kubo-topology.d.ts.map +1 -0
- package/dist/kubo-topology.js +105 -0
- package/dist/kubo-topology.js.map +1 -0
- package/dist/kubo.d.ts +10 -0
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +96 -15
- package/dist/kubo.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +6 -3
- package/dist/runtime.js.map +1 -1
- package/dist/skill-definition.d.ts +6 -0
- package/dist/skill-definition.d.ts.map +1 -0
- package/dist/skill-definition.js +38 -0
- package/dist/skill-definition.js.map +1 -0
- package/dist/skill-source.d.ts +5 -0
- package/dist/skill-source.d.ts.map +1 -0
- package/dist/skill-source.js +12 -0
- package/dist/skill-source.js.map +1 -0
- package/dist/skills.d.ts +84 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +736 -0
- package/dist/skills.js.map +1 -0
- package/dist/space-path.d.ts +3 -0
- package/dist/space-path.d.ts.map +1 -0
- package/dist/space-path.js +17 -0
- package/dist/space-path.js.map +1 -0
- package/dist/space.d.ts +16 -4
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +155 -18
- package/dist/space.js.map +1 -1
- package/dist/state-storage.js +1 -1
- package/dist/state-storage.js.map +1 -1
- package/dist/state.d.ts +2 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +32 -13
- package/dist/state.js.map +1 -1
- package/dist/swarm-files.d.ts +2 -2
- package/dist/swarm-files.d.ts.map +1 -1
- package/dist/swarm-files.js +4 -4
- package/dist/swarm-files.js.map +1 -1
- package/dist/swarm-meta.d.ts +14 -0
- package/dist/swarm-meta.d.ts.map +1 -0
- package/dist/swarm-meta.js +65 -0
- package/dist/swarm-meta.js.map +1 -0
- package/dist/swarm-observations.d.ts +40 -0
- package/dist/swarm-observations.d.ts.map +1 -0
- package/dist/swarm-observations.js +262 -0
- package/dist/swarm-observations.js.map +1 -0
- package/dist/swarm.d.ts +172 -6
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +1106 -132
- package/dist/swarm.js.map +1 -1
- package/dist/template-paths.d.ts +7 -0
- package/dist/template-paths.d.ts.map +1 -0
- package/dist/template-paths.js +23 -0
- package/dist/template-paths.js.map +1 -0
- package/dist/template-presentation.d.ts +20 -0
- package/dist/template-presentation.d.ts.map +1 -0
- package/dist/template-presentation.js +133 -0
- package/dist/template-presentation.js.map +1 -0
- package/dist/template-source.d.ts +2 -1
- package/dist/template-source.d.ts.map +1 -1
- package/dist/template-source.js +7 -1
- package/dist/template-source.js.map +1 -1
- package/dist/templates.d.ts +11 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +53 -0
- package/dist/templates.js.map +1 -0
- package/package.json +7 -6
- package/src/app-authoring.ts +30 -55
- package/src/app-prebuild.ts +61 -0
- package/src/app-templates.ts +8 -72
- package/src/builtins.ts +2 -48
- package/src/cli.ts +830 -247
- package/src/config.ts +12 -4
- package/src/context.ts +60 -2
- package/src/errors.ts +1 -25
- package/src/host-error.ts +26 -0
- package/src/ipc.ts +82 -2
- package/src/kubo-install.ts +1 -1
- package/src/kubo-peers.ts +2 -3
- package/src/kubo-topology.ts +135 -0
- package/src/kubo.ts +134 -25
- package/src/runtime.ts +6 -2
- package/src/skill-definition.ts +53 -0
- package/src/skill-source.ts +15 -0
- package/src/skills.ts +1005 -0
- package/src/space-path.ts +30 -0
- package/src/space.ts +216 -33
- package/src/state-storage.ts +1 -1
- package/src/state.ts +38 -13
- package/src/swarm-files.ts +4 -2
- package/src/swarm-meta.ts +90 -0
- package/src/swarm-observations.ts +374 -0
- package/src/swarm.ts +1637 -193
- package/src/template-paths.ts +43 -0
- package/src/template-presentation.ts +151 -0
- package/src/template-source.ts +9 -2
- package/src/templates.ts +77 -0
package/dist/cli.js
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import { createInterface } from "node:readline/promises";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { lstat, readFile } from "node:fs/promises";
|
|
3
3
|
import { ContentError, IpfsStore } from "@ipab/ipfs-store";
|
|
4
4
|
import { ContentBundleError } from "@ipab/bundle";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
import { CID } from "multiformats/cid";
|
|
7
7
|
import stringWidth from "string-width";
|
|
8
|
-
import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, visibleConfig, } from "./config.js";
|
|
8
|
+
import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, swarmUrl, visibleConfig, } from "./config.js";
|
|
9
9
|
import { HostError, message, object, syntax } from "./errors.js";
|
|
10
10
|
import { filters, listHistory, selectedIds, Ownership, recoverInactive, removeHistory, } from "./history.js";
|
|
11
11
|
import { execute } from "./runtime.js";
|
|
12
12
|
import { validatedBundle } from "./space.js";
|
|
13
|
-
import { createAssociation, exactCid, State, } from "./state.js";
|
|
14
|
-
import { buildBundle, inspectBundle, importBundle } from "./authoring.js";
|
|
13
|
+
import { createAssociation, exactCid, swarmAlias, State, } from "./state.js";
|
|
14
|
+
import { buildBundle, inspectBundle, importBundle, nodeError, } from "./authoring.js";
|
|
15
15
|
import { initApp } from "./app-authoring.js";
|
|
16
16
|
import { assembleBundle } from "./assembly.js";
|
|
17
17
|
import { getBundle } from "./get.js";
|
|
18
18
|
import { doctorDevice, doctorText } from "./doctor.js";
|
|
19
19
|
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
20
|
-
import { createSwarm, requestMembership, approveMembership, exportRequest, removeMember, resumeRemoval, updateProfile, accountProfile, updateAccountProfile, swarmMembers, verifiedRequest, verifiedRequestStream, membershipRequestSummary,
|
|
20
|
+
import { createSwarm, swarmDaemon, requestMembership, approveMembership, exportRequest, removeMember, resumeRemoval, updateProfile, accountProfile, updateAccountProfile, swarmMembers, inspectSwarmStatus, verifiedRequest, verifiedRequestStream, membershipRequestSummary, updateSwarm, searchNames, formatNameReference, resolveReference, parseNameReference, formalName, publish, pinNameSubscription, pinReference, swarmRegistrations, swarmAssociation, setSwarmAssociation, removeSwarmAssociation, resolveTemplateSelector, templateName, swarmTemplates, setSwarmTemplate, removeSwarmTemplate, } from "./swarm.js";
|
|
21
21
|
import { schemaAlias } from "./app-definition.js";
|
|
22
22
|
import { unpin, pinDetails } from "./pins.js";
|
|
23
23
|
import { publicationSource } from "./publish-source.js";
|
|
24
|
+
import { templateRenderExample, templateOutputTree, templateParameterRows, } from "./template-presentation.js";
|
|
24
25
|
import { logFiles } from "./logs.js";
|
|
25
26
|
import { builtinContent } from "./builtins.js";
|
|
26
27
|
import { readSecretStream } from "./config-secret.js";
|
|
28
|
+
import { manageSkills } from "./skills.js";
|
|
27
29
|
let progressLine = false;
|
|
28
30
|
export const processIO = {
|
|
29
31
|
out(text) {
|
|
@@ -69,39 +71,46 @@ export const processIO = {
|
|
|
69
71
|
},
|
|
70
72
|
};
|
|
71
73
|
const commands = {
|
|
74
|
+
daemon: "daemon [--swarm URL_OR_ALIAS]",
|
|
75
|
+
"skills list": "skills list [--refresh | --no-refresh]",
|
|
76
|
+
"skills sync": "skills sync [NAMES...] [--agent AGENT]... [--dry-run] [--yes] [--refresh | --no-refresh]",
|
|
72
77
|
doctor: "doctor [--fix [--yes]]",
|
|
73
78
|
profile: "profile [--name NAME] [--description TEXT]",
|
|
74
79
|
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
75
|
-
"swarm request": "swarm request
|
|
80
|
+
"swarm request": "swarm request URL_OR_ALIAS [--output FILE]",
|
|
76
81
|
"swarm export": "swarm export --output FILE",
|
|
77
82
|
"swarm approve": "swarm approve REQUEST_FILE [--again] --yes",
|
|
78
83
|
"swarm exclude": "swarm exclude MEMBER_PUBLIC_KEY --yes",
|
|
79
84
|
"swarm resume": "swarm resume",
|
|
80
85
|
"swarm profile": "swarm profile --address MULTIADDR",
|
|
81
|
-
"swarm status": "swarm status [--
|
|
82
|
-
"swarm members": "swarm members",
|
|
86
|
+
"swarm status": "swarm status [--refresh | --no-refresh]",
|
|
87
|
+
"swarm members": "swarm members [--refresh | --no-refresh]",
|
|
83
88
|
"swarm list": "swarm list",
|
|
84
|
-
"swarm
|
|
89
|
+
"swarm set": "swarm set ALIAS CONFIG_URL [--yes]",
|
|
85
90
|
"swarm use": "swarm use URL_OR_ALIAS",
|
|
86
91
|
"swarm remove": "swarm remove URL_OR_ALIAS",
|
|
87
92
|
"swarm update": "swarm update [--name TEXT] [--description TEXT]",
|
|
88
|
-
publish: "publish NAME SOURCE [--expect
|
|
89
|
-
get: "get REF [--raw] [--
|
|
90
|
-
search: "search QUERY [--all | --current] [--
|
|
91
|
-
|
|
93
|
+
publish: "publish NAME SOURCE [--expect OLD_CID | --snapshot]",
|
|
94
|
+
get: "get REF [--raw] [--refresh | --no-refresh] [-o DIRECTORY]",
|
|
95
|
+
search: "search QUERY [--all | --current] [--refresh | --no-refresh]",
|
|
96
|
+
"templates render": "templates render TEMPLATE NAME [DIR] [OPTIONS]",
|
|
92
97
|
build: "build [SOURCE] [OPTIONS]",
|
|
93
98
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
94
99
|
"bundle inspect": "bundle inspect SOURCE",
|
|
95
100
|
"bundle import": "bundle import FILE.car",
|
|
96
|
-
exec: "exec [--log] [--
|
|
97
|
-
open: "open [--log] [--raw] [--
|
|
98
|
-
pin: "pin REF",
|
|
101
|
+
exec: "exec [--log] [--refresh | --no-refresh] APP [APP_ARGS...]",
|
|
102
|
+
open: "open [--log] [--raw] [--refresh | --no-refresh] CONTENT",
|
|
103
|
+
pin: "pin REF [--refresh | --no-refresh]",
|
|
99
104
|
unpin: "unpin REF",
|
|
100
105
|
"pin list": "pin list",
|
|
101
106
|
"pin show": "pin show REF",
|
|
102
|
-
"register list": "register list [--swarm URL_OR_ALIAS]
|
|
103
|
-
"register set": "register set SCHEMA APP [--swarm URL_OR_ALIAS]... [--replace]
|
|
107
|
+
"register list": "register list [--swarm URL_OR_ALIAS]",
|
|
108
|
+
"register set": "register set SCHEMA APP [--swarm URL_OR_ALIAS]... [--replace]",
|
|
104
109
|
"register remove": "register remove SCHEMA [--swarm URL_OR_ALIAS]...",
|
|
110
|
+
"templates list": "templates list [--refresh | --no-refresh]",
|
|
111
|
+
"templates show": "templates show NAME [--refresh | --no-refresh]",
|
|
112
|
+
"templates set": "templates set NAME SOURCE [--expect OLD_TARGET_CID]",
|
|
113
|
+
"templates remove": "templates remove NAME --expect OLD_TARGET_CID",
|
|
105
114
|
"config get": "config get [KEY]",
|
|
106
115
|
"config set": "config set KEY VALUE\n ipab config set pointers.apiKey - < protected-key-file",
|
|
107
116
|
"config reset": "config reset KEY",
|
|
@@ -112,15 +121,115 @@ const commands = {
|
|
|
112
121
|
"history remove": "history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
|
|
113
122
|
};
|
|
114
123
|
const groups = {
|
|
124
|
+
skills: "Discover and explicitly synchronize selected Swarm Skills globally",
|
|
115
125
|
swarm: "Create, authorize, select and manage personal swarms",
|
|
116
126
|
bundle: "Create, inspect and import content bundles",
|
|
117
127
|
pin: "Retain an exact CID or follow a shared Swarm Name",
|
|
118
128
|
register: "Associate content types with Apps",
|
|
129
|
+
templates: "Inspect, render and manage Template Bundles",
|
|
119
130
|
config: "Manage local configuration",
|
|
120
131
|
store: "Query local storage and collect unreferenced blocks",
|
|
121
132
|
history: "View and remove execution history",
|
|
122
133
|
};
|
|
123
134
|
const commandHelp = {
|
|
135
|
+
daemon: {
|
|
136
|
+
summary: "Manage existing private Swarm nodes in the foreground",
|
|
137
|
+
examples: ["ipab daemon", "ipab daemon --swarm work"],
|
|
138
|
+
notes: [
|
|
139
|
+
"Manages all registered Swarms independently, or only the explicitly selected --swarm; ignores the saved default.",
|
|
140
|
+
"Probes pivot candidates, refreshes approved profiles and retries with cooldown. Diagnostics go to stderr.",
|
|
141
|
+
"Ctrl-C / TERM drains operations and releases the device/state-dir lock; Kubo stays running. Run under your own supervisor if desired.",
|
|
142
|
+
"Role and relay candidate changes restart only the verified managed Kubo node.",
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
"templates list": {
|
|
146
|
+
summary: "List templates under the selected Swarm Meta templatePath",
|
|
147
|
+
options: [
|
|
148
|
+
"--refresh / --no-refresh Refresh HEAD now / allow a valid cached snapshot.",
|
|
149
|
+
],
|
|
150
|
+
examples: [
|
|
151
|
+
"ipab --swarm work templates list",
|
|
152
|
+
"ipab --json templates list",
|
|
153
|
+
],
|
|
154
|
+
notes: [
|
|
155
|
+
"Uses only global --swarm (once, before the command), otherwise the saved default. No builtin or other Swarm fallback.",
|
|
156
|
+
],
|
|
157
|
+
},
|
|
158
|
+
"templates show": {
|
|
159
|
+
summary: "Show one template, its exact targets and declared parameters",
|
|
160
|
+
arguments: [
|
|
161
|
+
"NAME Safe relative template Name; nested names are supported.",
|
|
162
|
+
],
|
|
163
|
+
options: [
|
|
164
|
+
"--refresh / --no-refresh Refresh HEAD now / allow a valid cached snapshot.",
|
|
165
|
+
],
|
|
166
|
+
examples: ["ipab --swarm work templates show node"],
|
|
167
|
+
},
|
|
168
|
+
"templates set": {
|
|
169
|
+
summary: "Publish one validated Template Bundle with exact Name conflict checks",
|
|
170
|
+
arguments: [
|
|
171
|
+
"NAME Safe relative template Name.",
|
|
172
|
+
"SOURCE Exact Template CID, self-contained CAR or explicit manifest directory; no URI, build or hooks.",
|
|
173
|
+
],
|
|
174
|
+
options: [
|
|
175
|
+
"--expect OLD_TARGET_CID Required to replace an occupied Name; use its exact target CID, including an Artifact wrapper.",
|
|
176
|
+
],
|
|
177
|
+
examples: [
|
|
178
|
+
"ipab --swarm work templates set team/node ./template.car",
|
|
179
|
+
"ipab templates set node TEMPLATE_CID --expect OLD_TARGET_CID",
|
|
180
|
+
],
|
|
181
|
+
notes: [
|
|
182
|
+
"Publishes an ordinary Artifact and preserves publication history and content retention.",
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
"templates remove": {
|
|
186
|
+
summary: "Remove only one template Name, without deleting content",
|
|
187
|
+
arguments: ["NAME Safe relative template Name."],
|
|
188
|
+
options: [
|
|
189
|
+
"--expect OLD_TARGET_CID Required exact current Name target CID.",
|
|
190
|
+
],
|
|
191
|
+
examples: [
|
|
192
|
+
"ipab --swarm work templates remove team/node --expect OLD_TARGET_CID",
|
|
193
|
+
],
|
|
194
|
+
notes: [
|
|
195
|
+
"Missing Names are errors. Does not unpin, GC or delete content or history.",
|
|
196
|
+
],
|
|
197
|
+
},
|
|
198
|
+
"skills list": {
|
|
199
|
+
summary: "List typed Skills and local installation status from one Swarm",
|
|
200
|
+
options: [
|
|
201
|
+
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
202
|
+
"Global --json Emit machine-readable names, exact payload CIDs and status.",
|
|
203
|
+
],
|
|
204
|
+
examples: ["ipab --swarm work skills list", "ipab --json skills list"],
|
|
205
|
+
notes: [
|
|
206
|
+
"Select one Swarm with global --swarm or swarm use; there is no --all.",
|
|
207
|
+
"Requires skillPath in the exact root State Bundle or legacy Meta type. Older v5 roots require a new seeded Swarm; only legacy v2/v3/v4 Meta can be explicitly replaced with --expect. No silent upgrades.",
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
"skills sync": {
|
|
211
|
+
summary: "Install reviewed Swarm Skills using the pinned official npx installer",
|
|
212
|
+
arguments: [
|
|
213
|
+
"NAMES Install identities, e.g. ipab code-review, or full shared Names such as ipab/skills/ipab. Resolved from one verified snapshot; omit for all Skills.",
|
|
214
|
+
],
|
|
215
|
+
options: [
|
|
216
|
+
"--agent AGENT Repeatable globally supported agent ID; default is detected agents.",
|
|
217
|
+
"--dry-run Preview without invoking npx or changing installed Skills.",
|
|
218
|
+
"--yes Skip IPAB consent only; conflicts and local edits remain protected.",
|
|
219
|
+
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
220
|
+
],
|
|
221
|
+
examples: [
|
|
222
|
+
"ipab --swarm work skills sync --dry-run",
|
|
223
|
+
"ipab skills sync ipab code-review --agent github-copilot --yes",
|
|
224
|
+
],
|
|
225
|
+
notes: [
|
|
226
|
+
"Global installs only, through official skills@1.9.1 with --copy. Requires Node >=22.20.0.",
|
|
227
|
+
"Non-interactive execution requires --yes. Installer version, source, paths and agents are shown first.",
|
|
228
|
+
"No Skill hooks/scripts run. The trusted installer is not sandboxed. Telemetry and remote audits are disabled.",
|
|
229
|
+
"Non-IPAB installs, local edits, cross-Swarm collisions and symlink/junction aliases are never overwritten. Removed sources are reported, not deleted.",
|
|
230
|
+
"Partial failures report individual results, preserve pending attribution and exit nonzero; retry the same sync.",
|
|
231
|
+
],
|
|
232
|
+
},
|
|
124
233
|
profile: {
|
|
125
234
|
summary: "Read or update your account-wide public name and description",
|
|
126
235
|
examples: [
|
|
@@ -182,11 +291,10 @@ const commandHelp = {
|
|
|
182
291
|
"swarm request": {
|
|
183
292
|
summary: "Save and export a signed self-contained membership Request",
|
|
184
293
|
examples: [
|
|
185
|
-
"ipab swarm request
|
|
186
|
-
"ipab swarm request CONFIG_URL --output request.json
|
|
294
|
+
"ipab swarm request work",
|
|
295
|
+
"ipab swarm request CONFIG_URL --output request.json",
|
|
187
296
|
],
|
|
188
297
|
options: [
|
|
189
|
-
"--alias ALIAS Pre-register the target for lazy onboarding.",
|
|
190
298
|
"--output FILE Export to a new file instead of stdout; never overwrites.",
|
|
191
299
|
],
|
|
192
300
|
notes: [
|
|
@@ -196,7 +304,7 @@ const commandHelp = {
|
|
|
196
304
|
"Retries export the exact saved Request without expiry or a new PeerID.",
|
|
197
305
|
"No Invite, Response file, password or Join. Next normal use fetches and decrypts the approved package.",
|
|
198
306
|
"Set your account-wide personal name with ipab profile --name NAME before requesting membership.",
|
|
199
|
-
"
|
|
307
|
+
"Accepts a local alias or a configuration URL. Never changes local registrations, aliases or the saved default; use ipab swarm set ALIAS CONFIG_URL separately.",
|
|
200
308
|
],
|
|
201
309
|
},
|
|
202
310
|
"swarm approve": {
|
|
@@ -240,24 +348,35 @@ const commandHelp = {
|
|
|
240
348
|
},
|
|
241
349
|
"swarm members": {
|
|
242
350
|
summary: "List every public member, including the Owner",
|
|
243
|
-
|
|
351
|
+
options: [
|
|
352
|
+
"--refresh / --no-refresh Fetch public Variables now / reuse the saved inspection, fetching if missing.",
|
|
353
|
+
"--local Deprecated no-op; local daemon observations are always included.",
|
|
354
|
+
],
|
|
355
|
+
examples: [
|
|
356
|
+
"ipab --swarm work swarm members",
|
|
357
|
+
"ipab --json swarm members --refresh",
|
|
358
|
+
],
|
|
244
359
|
notes: [
|
|
245
|
-
"
|
|
360
|
+
"Default: reuse the inspection cache, fetching public Variables if missing. Includes Pivot declarations and existing daemon observations; no HOME identity access, node activation or probes.",
|
|
361
|
+
"PIVOT: - for ordinary members; selected, cooldown, unknown, self or candidate for declared Pivots. Selected means applied configuration, not connectivity.",
|
|
246
362
|
],
|
|
247
363
|
},
|
|
248
364
|
"swarm status": {
|
|
249
|
-
summary: "
|
|
365
|
+
summary: "Inspect cached Swarm directory, HEAD and local networking",
|
|
250
366
|
options: [
|
|
251
|
-
"--
|
|
367
|
+
"--refresh / --no-refresh Fetch public Variables now / reuse the saved inspection, fetching if missing.",
|
|
368
|
+
"--local Deprecated no-op; never activates a node.",
|
|
252
369
|
],
|
|
253
370
|
examples: [
|
|
254
371
|
"ipab swarm status",
|
|
255
372
|
"ipab --swarm work swarm status",
|
|
256
|
-
"ipab --swarm work swarm status --
|
|
373
|
+
"ipab --swarm work swarm status --refresh",
|
|
257
374
|
],
|
|
258
375
|
notes: [
|
|
259
|
-
"
|
|
260
|
-
"
|
|
376
|
+
"Default: reuse the inspection cache, fetching public Variables if missing. Refresh verifies Config, Scope, members, Profiles and HEAD, not connectivity or State content.",
|
|
377
|
+
"Always shows daemon freshness, Pivot selection, probes/cooldown and separately timestamped daemon connection snapshots. Never contacts Kubo, initializes HOME identity, changes remote profiles or activates a node.",
|
|
378
|
+
"State content is explicitly unavailable in inspection; use get ipab:/// to obtain the State Bundle.",
|
|
379
|
+
"Local connectivity is not global availability; a relay connection does not guarantee content transfer.",
|
|
261
380
|
],
|
|
262
381
|
},
|
|
263
382
|
"swarm list": {
|
|
@@ -265,13 +384,19 @@ const commandHelp = {
|
|
|
265
384
|
examples: ["ipab swarm list", "ipab --json swarm list"],
|
|
266
385
|
notes: ["Local only; does not verify remote membership or refresh HEAD."],
|
|
267
386
|
},
|
|
268
|
-
"swarm
|
|
269
|
-
summary: "
|
|
387
|
+
"swarm set": {
|
|
388
|
+
summary: "Set a local alias for a swarm configuration URL",
|
|
270
389
|
options: [
|
|
271
|
-
"--
|
|
390
|
+
"--yes Authorize retargeting an existing alias without prompting.",
|
|
391
|
+
],
|
|
392
|
+
examples: [
|
|
393
|
+
"ipab swarm set work CONFIG_URL",
|
|
394
|
+
"ipab swarm set work OTHER_CONFIG_URL --yes",
|
|
272
395
|
],
|
|
273
|
-
examples: ["ipab swarm add CONFIG_URL --alias work"],
|
|
274
396
|
notes: [
|
|
397
|
+
"Local only; no network, account identity or approved membership required.",
|
|
398
|
+
"Setting the same mapping is idempotent. One alias per URL; a new alias for that URL replaces its old alias.",
|
|
399
|
+
"Retargeting an alias requires confirmation or --yes. Keeps the old URL registered without that alias; credentials, caches and the saved default URL are unchanged.",
|
|
275
400
|
"Not a membership grant. The first registration becomes the saved default only if none exists.",
|
|
276
401
|
],
|
|
277
402
|
},
|
|
@@ -311,13 +436,13 @@ const commandHelp = {
|
|
|
311
436
|
options: [
|
|
312
437
|
"--all Search all registered swarms; conflicts with --current and --swarm.",
|
|
313
438
|
"--current Explicitly select the default search scope; conflicts with --swarm.",
|
|
314
|
-
"--
|
|
315
|
-
"--no-
|
|
439
|
+
"--refresh Refresh HEAD for every swarm in the search scope.",
|
|
440
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
316
441
|
],
|
|
317
442
|
examples: [
|
|
318
443
|
"ipab search hello",
|
|
319
444
|
"ipab search hello --all",
|
|
320
|
-
"ipab --swarm work search hello --
|
|
445
|
+
"ipab --swarm work search hello --refresh",
|
|
321
446
|
],
|
|
322
447
|
notes: [
|
|
323
448
|
"Searches only --swarm or the saved current swarm by default. Use --all to search every registration.",
|
|
@@ -330,18 +455,18 @@ const commandHelp = {
|
|
|
330
455
|
publish: {
|
|
331
456
|
summary: "Protect content locally and publish a shared Swarm Name",
|
|
332
457
|
options: [
|
|
333
|
-
"--expect CID Exact old
|
|
458
|
+
"--expect CID Exact old Name target CID, required for iteration.",
|
|
334
459
|
"--snapshot Name ordinary content without an Artifact; initial only.",
|
|
335
460
|
],
|
|
336
461
|
examples: [
|
|
337
462
|
"ipab --swarm work publish apps/hello app.car",
|
|
338
|
-
"ipab publish apps/hello APP_CID --expect
|
|
463
|
+
"ipab publish apps/hello APP_CID --expect OLD_APP_CID",
|
|
339
464
|
"ipab publish notes/readme ./README.md",
|
|
340
465
|
],
|
|
341
466
|
notes: [
|
|
342
467
|
"SOURCE is an exact Bundle CID, CAR, regular file or directory. No compiler, hooks, install or App execution.",
|
|
343
468
|
"Directories require .bundle.yaml/type, or a package.json source snapshot. Standalone .json/.yaml/.yml/.md/.txt entries get a standard Bundle; other file types require explicit metadata.",
|
|
344
|
-
"Occupied Names require --expect
|
|
469
|
+
"App and Meta Bundles publish direct CID links; other content uses Artifact records. Occupied Names require --expect EXACT_OLD_CID (the old Artifact CID when applicable). Published payloads are local CID pins; unpin CID releases that protection, not history holders.",
|
|
345
470
|
"Different-name CAS contention is rebased; same-name edits conflict (exit 3).",
|
|
346
471
|
"Kubo pin confirmation precedes HEAD; it does not prove a remote device is online.",
|
|
347
472
|
],
|
|
@@ -350,8 +475,8 @@ const commandHelp = {
|
|
|
350
475
|
summary: "Verify and unpack Bundle content without executing it",
|
|
351
476
|
options: [
|
|
352
477
|
"--raw Select the Artifact node instead of its value.",
|
|
353
|
-
"--
|
|
354
|
-
"--no-
|
|
478
|
+
"--refresh Refresh the shared Name's swarm HEAD.",
|
|
479
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
355
480
|
"-o, --output DIRECTORY New or empty directory; defaults to a unique temporary directory.",
|
|
356
481
|
],
|
|
357
482
|
examples: [
|
|
@@ -384,20 +509,28 @@ const commandHelp = {
|
|
|
384
509
|
"Does not unpin, clear history, delete unknown files or request Kubo daemon GC.",
|
|
385
510
|
],
|
|
386
511
|
},
|
|
387
|
-
|
|
388
|
-
summary: "
|
|
389
|
-
arguments: [
|
|
512
|
+
"templates render": {
|
|
513
|
+
summary: "Render a template's project files into a new or empty folder",
|
|
514
|
+
arguments: [
|
|
515
|
+
"TEMPLATE Explicit Swarm selector, directory, CAR, exact CID or IPAB URI.",
|
|
516
|
+
"NAME Project name parameter; DIR defaults to NAME (new/empty only).",
|
|
517
|
+
],
|
|
390
518
|
options: [
|
|
391
|
-
"--
|
|
519
|
+
"--description TEXT Set the declared description parameter.",
|
|
520
|
+
"--refresh / --no-refresh Refresh Swarm HEAD now / allow its valid cached snapshot.",
|
|
392
521
|
"--param KEY=VALUE Template parameter; repeatable. Strings are literal;",
|
|
393
522
|
" other parameter types use JSON.",
|
|
394
523
|
],
|
|
395
524
|
examples: [
|
|
396
|
-
"ipab
|
|
397
|
-
"ipab
|
|
398
|
-
"ipab
|
|
525
|
+
"ipab templates render node hello",
|
|
526
|
+
"ipab templates render web-app dashboard --param webAppDependency=0.1.0-rc.2",
|
|
527
|
+
"ipab templates render ./template.car hello --description Demo",
|
|
528
|
+
],
|
|
529
|
+
notes: [
|
|
530
|
+
"Short selectors resolve through the selected Swarm's typed root configuration (legacy v2/v3/v4 use Meta Name ipab); no builtin fallback.",
|
|
531
|
+
"Explicit directory, CAR and available exact CID work offline without a Swarm.",
|
|
532
|
+
"Does not install dependencies or execute template code.",
|
|
399
533
|
],
|
|
400
|
-
notes: ["Does not install dependencies or execute template code."],
|
|
401
534
|
},
|
|
402
535
|
build: {
|
|
403
536
|
summary: "Assemble any Bundle using ipab.build.yaml (no compilation)",
|
|
@@ -463,8 +596,8 @@ const commandHelp = {
|
|
|
463
596
|
],
|
|
464
597
|
options: [
|
|
465
598
|
"--log Record stdout/stderr; must precede APP. Requires history enabled.",
|
|
466
|
-
"--
|
|
467
|
-
"--no-
|
|
599
|
+
"--refresh Refresh the shared Name's swarm HEAD; must precede APP.",
|
|
600
|
+
"--no-refresh Override swarm.forceRefresh; must precede APP.",
|
|
468
601
|
],
|
|
469
602
|
examples: [
|
|
470
603
|
"ipab exec reader",
|
|
@@ -487,16 +620,17 @@ const commandHelp = {
|
|
|
487
620
|
options: [
|
|
488
621
|
"--log Record stdout/stderr; requires history enabled.",
|
|
489
622
|
"--raw Open the Artifact node rather than its value.",
|
|
490
|
-
"--
|
|
491
|
-
"--no-
|
|
623
|
+
"--refresh Refresh the shared Name's swarm HEAD.",
|
|
624
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
492
625
|
],
|
|
493
626
|
examples: [
|
|
494
627
|
"ipab open CONTENT_CID",
|
|
495
|
-
"ipab open --log
|
|
496
|
-
"ipab open ipab:///
|
|
628
|
+
"ipab open --log --refresh ipab:///documents/readme",
|
|
629
|
+
"ipab open ipab:///",
|
|
497
630
|
],
|
|
498
631
|
notes: [
|
|
499
632
|
"Requires a saved registration and App support for the exact content type.",
|
|
633
|
+
"An empty URI Name (ipab:/// or ipab://ALIAS/) resolves to that Swarm's verified root State CID, not its publication CID. The root binding cannot be overwritten.",
|
|
500
634
|
"Uses only the content URI's Swarm, otherwise --swarm, otherwise swarm.default. A selected Swarm is required.",
|
|
501
635
|
"A registered App's retrieval, compatibility or execution failure never triggers fallback.",
|
|
502
636
|
"Legacy User registrations are inactive and preserved in the state database's legacy_user_registrations table; review them before explicit Swarm registration.",
|
|
@@ -511,6 +645,9 @@ const commandHelp = {
|
|
|
511
645
|
arguments: [
|
|
512
646
|
"REF Exact Bundle CID or ipab://SWARM/NAME; no local content aliases.",
|
|
513
647
|
],
|
|
648
|
+
options: [
|
|
649
|
+
"--refresh / --no-refresh Refresh shared HEAD now / allow its valid cached snapshot.",
|
|
650
|
+
],
|
|
514
651
|
examples: [
|
|
515
652
|
"ipab pin APP_CID",
|
|
516
653
|
"ipab pin ipab://work/apps/reader",
|
|
@@ -545,15 +682,15 @@ const commandHelp = {
|
|
|
545
682
|
},
|
|
546
683
|
"pin show": {
|
|
547
684
|
summary: "Show saved retention and following status",
|
|
548
|
-
examples: ["ipab pin show APP_CID"
|
|
685
|
+
examples: ["ipab pin show APP_CID"],
|
|
549
686
|
notes: [
|
|
550
687
|
"Reads local metadata; built-in pins do not claim user Store retention.",
|
|
551
688
|
],
|
|
552
689
|
},
|
|
553
690
|
"register list": {
|
|
554
|
-
summary: "List
|
|
691
|
+
summary: "List content-type associations in the current or selected Swarm",
|
|
555
692
|
options: [
|
|
556
|
-
"--swarm URL_OR_ALIAS Read this Swarm registry;
|
|
693
|
+
"--swarm URL_OR_ALIAS Read only this Swarm registry; specify at most once.",
|
|
557
694
|
],
|
|
558
695
|
examples: ["ipab register list", "ipab register list --swarm work"],
|
|
559
696
|
notes: [
|
|
@@ -566,19 +703,18 @@ const commandHelp = {
|
|
|
566
703
|
arguments: [
|
|
567
704
|
"SCHEMA Exact type CID or builtin:node-app.v1.",
|
|
568
705
|
"APP App CID or Swarm IPAB URI; the exact CID is saved.",
|
|
569
|
-
"TEMPLATE App argv after --; must contain a whole argument % (default: %).",
|
|
570
706
|
],
|
|
571
707
|
options: [
|
|
572
708
|
"--replace Allow changing an existing association.",
|
|
573
709
|
"--swarm URL_OR_ALIAS Write this Swarm registry; repeat for multiple Swarms.",
|
|
574
710
|
],
|
|
575
711
|
examples: [
|
|
576
|
-
"ipab register set SCHEMA_CID
|
|
577
|
-
"ipab register set SCHEMA_CID reader '--' '--cid' '%'",
|
|
712
|
+
"ipab register set SCHEMA_CID APP_CID",
|
|
578
713
|
"ipab register set SCHEMA_CID ipab:///apps/reader --swarm work --swarm team",
|
|
579
714
|
],
|
|
580
715
|
notes: [
|
|
581
|
-
"
|
|
716
|
+
"Writes the Name META.registryPath/TYPE_CID directly to the App CID. Open passes only the content CID.",
|
|
717
|
+
"Custom per-association argv is unsupported; adapt the App or use ipab exec APP_CID ARGS.",
|
|
582
718
|
"Does not verify App type support; open checks it before execution.",
|
|
583
719
|
"Without explicit --swarm, writes the saved default Swarm. Swarm writes require HEAD write access.",
|
|
584
720
|
"Multiple Swarms commit sequentially, not atomically; failures report completed targets.",
|
|
@@ -682,7 +818,7 @@ Run Apps:
|
|
|
682
818
|
open ${commandHelp.open.summary}
|
|
683
819
|
|
|
684
820
|
Create:
|
|
685
|
-
|
|
821
|
+
templates ${groups.templates}
|
|
686
822
|
build ${commandHelp.build.summary}
|
|
687
823
|
bundle ${groups.bundle}
|
|
688
824
|
|
|
@@ -690,6 +826,7 @@ Manage:
|
|
|
690
826
|
doctor ${commandHelp.doctor.summary}
|
|
691
827
|
profile ${commandHelp.profile.summary}
|
|
692
828
|
swarm ${groups.swarm}
|
|
829
|
+
skills ${groups.skills}
|
|
693
830
|
search Search formal Names in the current swarm
|
|
694
831
|
publish ${commandHelp.publish.summary}
|
|
695
832
|
get ${commandHelp.get.summary}
|
|
@@ -714,7 +851,13 @@ ${footer}`;
|
|
|
714
851
|
return [
|
|
715
852
|
`${topic.summary}.\n\nUsage: ipab [GLOBAL_OPTIONS] ${usage}`,
|
|
716
853
|
...(topic.arguments ? [section("Arguments", topic.arguments)] : []),
|
|
717
|
-
...(topic.options
|
|
854
|
+
...(topic.options
|
|
855
|
+
? [
|
|
856
|
+
section("Options", topic.options.map((line) => line.startsWith("--refresh")
|
|
857
|
+
? `${line} Legacy aliases: --force/--no-force.`
|
|
858
|
+
: line)),
|
|
859
|
+
]
|
|
860
|
+
: []),
|
|
718
861
|
section("Examples", topic.examples),
|
|
719
862
|
...([
|
|
720
863
|
"swarm status",
|
|
@@ -761,8 +904,15 @@ function printable(text) {
|
|
|
761
904
|
}
|
|
762
905
|
export function formatSearchResults(matches) {
|
|
763
906
|
return matches.length
|
|
764
|
-
? matches
|
|
765
|
-
|
|
907
|
+
? alignedRows(matches.map((match) => [
|
|
908
|
+
match.alias ?? match.swarm,
|
|
909
|
+
match.name,
|
|
910
|
+
match.targetCid,
|
|
911
|
+
]))
|
|
912
|
+
.map((row, index) => {
|
|
913
|
+
const match = matches[index];
|
|
914
|
+
return `${row}\n ipab get ${formatNameReference(match.alias ?? match.swarm, match.name)}`;
|
|
915
|
+
})
|
|
766
916
|
.join("\n")
|
|
767
917
|
: "No matching Names.";
|
|
768
918
|
}
|
|
@@ -805,18 +955,17 @@ function storageBytes(bytes) {
|
|
|
805
955
|
? `${exact} bytes`
|
|
806
956
|
: `${scaled.toLocaleString("en-US", { maximumFractionDigits: 2 })} ${units[unit]} (${exact} bytes)`;
|
|
807
957
|
}
|
|
808
|
-
function
|
|
809
|
-
if (!rows.length)
|
|
810
|
-
return empty;
|
|
958
|
+
function alignedRows(rows) {
|
|
811
959
|
const cells = rows.map((row) => row.map(printable));
|
|
812
|
-
const widths =
|
|
813
|
-
return
|
|
814
|
-
.map((
|
|
815
|
-
.map((cell, column) => column === headers.length - 1
|
|
960
|
+
const widths = (cells[0] ?? []).map((_, column) => cells.reduce((width, row) => Math.max(width, stringWidth(row[column])), 0));
|
|
961
|
+
return cells.map((row) => row
|
|
962
|
+
.map((cell, column) => column === widths.length - 1
|
|
816
963
|
? cell
|
|
817
964
|
: cell.padEnd(cell.length + widths[column] - stringWidth(cell)))
|
|
818
|
-
.join(" "))
|
|
819
|
-
|
|
965
|
+
.join(" "));
|
|
966
|
+
}
|
|
967
|
+
function table(headers, rows, empty) {
|
|
968
|
+
return rows.length ? alignedRows([headers, ...rows]).join("\n") : empty;
|
|
820
969
|
}
|
|
821
970
|
function runDetails(record) {
|
|
822
971
|
const fields = [
|
|
@@ -847,6 +996,12 @@ function runDetails(record) {
|
|
|
847
996
|
fields.push(["Retention owner", record.retention.owner]);
|
|
848
997
|
return fields.map(([key, value]) => `${key}: ${printable(value)}`).join("\n");
|
|
849
998
|
}
|
|
999
|
+
function validateRefreshOptions(options) {
|
|
1000
|
+
const positive = ["refresh", "force"].find((key) => options[key]);
|
|
1001
|
+
const negative = ["no-refresh", "no-force"].find((key) => options[key]);
|
|
1002
|
+
if (positive && negative)
|
|
1003
|
+
syntax(`--${positive} and --${negative} are mutually exclusive.`);
|
|
1004
|
+
}
|
|
850
1005
|
async function closeStore(store, appExitCode) {
|
|
851
1006
|
try {
|
|
852
1007
|
await store?.close();
|
|
@@ -906,6 +1061,10 @@ export function parse(argv) {
|
|
|
906
1061
|
syntax(`Unknown global option "${flag}".`);
|
|
907
1062
|
}
|
|
908
1063
|
const group = tokens.shift() ?? "";
|
|
1064
|
+
if (group === "init")
|
|
1065
|
+
syntax("Root init was removed. Use ipab templates render TEMPLATE NAME [DIR]; TEMPLATE is the first positional argument, not --template.");
|
|
1066
|
+
if (group === "templates" && swarms.length > 1)
|
|
1067
|
+
syntax("Templates accepts only one global --swarm, before the command.");
|
|
909
1068
|
const result = {
|
|
910
1069
|
flags,
|
|
911
1070
|
path: group,
|
|
@@ -920,14 +1079,13 @@ export function parse(argv) {
|
|
|
920
1079
|
if (group === "exec") {
|
|
921
1080
|
if (flags.json)
|
|
922
1081
|
syntax("--json is not supported for exec/open.");
|
|
923
|
-
while (["--log", "--force", "--no-force"].includes(tokens[0] ?? "")) {
|
|
1082
|
+
while (["--log", "--force", "--no-force", "--refresh", "--no-refresh"].includes(tokens[0] ?? "")) {
|
|
924
1083
|
const option = tokens.shift().slice(2);
|
|
925
1084
|
if (Object.hasOwn(result.options, option))
|
|
926
1085
|
syntax(`Duplicate option --${option}.`);
|
|
927
1086
|
result.options[option] = true;
|
|
928
1087
|
}
|
|
929
|
-
|
|
930
|
-
syntax("--force and --no-force are mutually exclusive.");
|
|
1088
|
+
validateRefreshOptions(result.options);
|
|
931
1089
|
if (tokens[0] === "-h" || tokens[0] === "--help") {
|
|
932
1090
|
result.help = true;
|
|
933
1091
|
return result;
|
|
@@ -939,12 +1097,12 @@ export function parse(argv) {
|
|
|
939
1097
|
}
|
|
940
1098
|
if (![
|
|
941
1099
|
"open",
|
|
942
|
-
"init",
|
|
943
1100
|
"build",
|
|
944
1101
|
"publish",
|
|
945
1102
|
"get",
|
|
946
1103
|
"search",
|
|
947
1104
|
"doctor",
|
|
1105
|
+
"daemon",
|
|
948
1106
|
"profile",
|
|
949
1107
|
"unpin",
|
|
950
1108
|
].includes(group)) {
|
|
@@ -952,10 +1110,12 @@ export function parse(argv) {
|
|
|
952
1110
|
"bundle",
|
|
953
1111
|
"pin",
|
|
954
1112
|
"register",
|
|
1113
|
+
"templates",
|
|
955
1114
|
"config",
|
|
956
1115
|
"history",
|
|
957
1116
|
"store",
|
|
958
1117
|
"swarm",
|
|
1118
|
+
"skills",
|
|
959
1119
|
].includes(group))
|
|
960
1120
|
syntax(`Unknown command "${group}".${group === "setup" ? " Run ipab doctor to inspect, or ipab doctor --fix to prepare this device." : " Run ipab --help."}`);
|
|
961
1121
|
if (group === "pin" && !["list", "show"].includes(tokens[0] ?? "")) {
|
|
@@ -973,8 +1133,12 @@ export function parse(argv) {
|
|
|
973
1133
|
}
|
|
974
1134
|
else if (group === "open" && flags.json)
|
|
975
1135
|
syntax("--json is not supported for exec/open.");
|
|
1136
|
+
if (result.path === "swarm add")
|
|
1137
|
+
syntax("swarm add was removed. Use ipab swarm set ALIAS CONFIG_URL for local naming, then ipab swarm request ALIAS to request membership.");
|
|
976
1138
|
if (!commands[result.path])
|
|
977
1139
|
syntax(`Unknown command "${result.path}".`);
|
|
1140
|
+
if (group === "skills" && swarms.length > 1)
|
|
1141
|
+
syntax("Skills operations select exactly one Swarm; repeated --swarm is not supported.");
|
|
978
1142
|
const separator = result.path === "register set" ? tokens.indexOf("--") : -1;
|
|
979
1143
|
if (separator >= 0)
|
|
980
1144
|
result.template = tokens.splice(separator + 1);
|
|
@@ -988,66 +1152,81 @@ export function parse(argv) {
|
|
|
988
1152
|
tokens.includes("pointers.apiKey") &&
|
|
989
1153
|
!(tokens.length === 2 && tokens[1] === "-"))
|
|
990
1154
|
syntax("API key must be provided through '-' and piped stdin; never pass it in command arguments.");
|
|
991
|
-
const booleans = result.path
|
|
992
|
-
?
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1155
|
+
const booleans = result.path.startsWith("skills ")
|
|
1156
|
+
? result.path === "skills sync"
|
|
1157
|
+
? ["dry-run", "yes", "force", "no-force"]
|
|
1158
|
+
: ["force", "no-force"]
|
|
1159
|
+
: result.path === "doctor"
|
|
1160
|
+
? ["fix", "yes"]
|
|
1161
|
+
: result.path === "bundle build"
|
|
1162
|
+
? ["replace", "schema-only", "no-import"]
|
|
1163
|
+
: result.path === "build"
|
|
1164
|
+
? ["replace", "no-import"]
|
|
1165
|
+
: result.path === "publish"
|
|
1166
|
+
? ["snapshot"]
|
|
1167
|
+
: [
|
|
1168
|
+
"get",
|
|
1169
|
+
"templates render",
|
|
1170
|
+
"templates list",
|
|
1171
|
+
"templates show",
|
|
1172
|
+
].includes(result.path)
|
|
1173
|
+
? result.path === "templates render"
|
|
1174
|
+
? ["force", "no-force"]
|
|
1175
|
+
: result.path === "get"
|
|
1176
|
+
? ["raw", "force", "no-force"]
|
|
1177
|
+
: ["force", "no-force"]
|
|
1178
|
+
: result.path === "search"
|
|
1179
|
+
? ["all", "current", "force", "no-force"]
|
|
1180
|
+
: result.path === "swarm approve"
|
|
1181
|
+
? ["yes", "again"]
|
|
1182
|
+
: ["swarm status", "swarm members"].includes(result.path)
|
|
1183
|
+
? ["local", "force", "no-force"]
|
|
1184
|
+
: ["swarm exclude", "swarm set"].includes(result.path)
|
|
1185
|
+
? ["yes"]
|
|
1186
|
+
: result.path === "register set"
|
|
1187
|
+
? ["replace"]
|
|
1188
|
+
: result.path === "history remove"
|
|
1189
|
+
? ["yes"]
|
|
1190
|
+
: result.path === "open"
|
|
1191
|
+
? ["log", "raw", "force", "no-force"]
|
|
1192
|
+
: result.path === "pin"
|
|
1193
|
+
? ["force", "no-force"]
|
|
1194
|
+
: [];
|
|
1195
|
+
if (booleans.includes("force"))
|
|
1196
|
+
booleans.push("refresh", "no-refresh");
|
|
1016
1197
|
const values = result.path === "swarm create"
|
|
1017
1198
|
? ["service", "resume", "name", "description", "alias"]
|
|
1018
|
-
: result.path === "swarm
|
|
1019
|
-
? ["
|
|
1020
|
-
: result.path === "swarm
|
|
1021
|
-
? ["
|
|
1022
|
-
: result.path === "swarm
|
|
1023
|
-
? ["
|
|
1024
|
-
: result.path === "swarm profile"
|
|
1025
|
-
? ["
|
|
1026
|
-
: result.path === "swarm
|
|
1027
|
-
? [
|
|
1028
|
-
:
|
|
1029
|
-
? []
|
|
1030
|
-
: result.path === "
|
|
1031
|
-
? ["
|
|
1032
|
-
: result.path === "
|
|
1033
|
-
? ["
|
|
1034
|
-
: result.path === "
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
? [
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
]
|
|
1048
|
-
:
|
|
1049
|
-
? ["app", "status", "since", "until"]
|
|
1050
|
-
: [];
|
|
1199
|
+
: result.path === "swarm request"
|
|
1200
|
+
? ["output"]
|
|
1201
|
+
: result.path === "swarm export"
|
|
1202
|
+
? ["output"]
|
|
1203
|
+
: result.path === "swarm profile"
|
|
1204
|
+
? ["address"]
|
|
1205
|
+
: result.path === "swarm update" || result.path === "profile"
|
|
1206
|
+
? ["name", "description"]
|
|
1207
|
+
: result.path === "swarm approve"
|
|
1208
|
+
? []
|
|
1209
|
+
: ["publish", "templates set", "templates remove"].includes(result.path)
|
|
1210
|
+
? ["expect"]
|
|
1211
|
+
: result.path === "get"
|
|
1212
|
+
? ["output"]
|
|
1213
|
+
: result.path === "templates render"
|
|
1214
|
+
? ["description"]
|
|
1215
|
+
: result.path === "bundle build" ||
|
|
1216
|
+
result.path === "build"
|
|
1217
|
+
? ["output"]
|
|
1218
|
+
: result.path === "history list"
|
|
1219
|
+
? [
|
|
1220
|
+
"app",
|
|
1221
|
+
"status",
|
|
1222
|
+
"since",
|
|
1223
|
+
"until",
|
|
1224
|
+
"limit",
|
|
1225
|
+
"before",
|
|
1226
|
+
]
|
|
1227
|
+
: result.path === "history remove"
|
|
1228
|
+
? ["app", "status", "since", "until"]
|
|
1229
|
+
: [];
|
|
1051
1230
|
while (tokens.length) {
|
|
1052
1231
|
const value = tokens.shift();
|
|
1053
1232
|
if (result.path === "swarm exclude" &&
|
|
@@ -1056,6 +1235,22 @@ export function parse(argv) {
|
|
|
1056
1235
|
}
|
|
1057
1236
|
else if (value.startsWith("--") || value === "-o") {
|
|
1058
1237
|
const option = value === "-o" ? "output" : value.slice(2);
|
|
1238
|
+
if (result.path === "daemon" && option === "swarm") {
|
|
1239
|
+
const input = tokens.shift();
|
|
1240
|
+
if (!input || input.startsWith("-"))
|
|
1241
|
+
syntax("--swarm needs a value.");
|
|
1242
|
+
if (flags.swarm !== undefined)
|
|
1243
|
+
syntax("daemon accepts --swarm at most once.");
|
|
1244
|
+
flags.swarm = input;
|
|
1245
|
+
continue;
|
|
1246
|
+
}
|
|
1247
|
+
if (result.path === "skills sync" && option === "agent") {
|
|
1248
|
+
const input = tokens.shift();
|
|
1249
|
+
if (!input || input.startsWith("-"))
|
|
1250
|
+
syntax("--agent needs a value.");
|
|
1251
|
+
(result.agents ??= []).push(input);
|
|
1252
|
+
continue;
|
|
1253
|
+
}
|
|
1059
1254
|
if (result.path.startsWith("register ") && option === "swarm") {
|
|
1060
1255
|
const input = tokens.shift();
|
|
1061
1256
|
if (!input || input.startsWith("-"))
|
|
@@ -1064,13 +1259,17 @@ export function parse(argv) {
|
|
|
1064
1259
|
flags.swarm = input;
|
|
1065
1260
|
continue;
|
|
1066
1261
|
}
|
|
1067
|
-
if (result.path === "
|
|
1262
|
+
if (result.path === "templates render" && option === "template")
|
|
1263
|
+
syntax("--template was removed. Use ipab templates render TEMPLATE NAME [DIR], with TEMPLATE first.");
|
|
1264
|
+
if (result.path === "templates render" && option === "param") {
|
|
1068
1265
|
const input = tokens.shift();
|
|
1069
1266
|
if (!input || input.startsWith("--") || input.indexOf("=") < 1)
|
|
1070
1267
|
syntax("--param requires KEY=VALUE.");
|
|
1071
1268
|
(result.parameters ??= []).push(input);
|
|
1072
1269
|
continue;
|
|
1073
1270
|
}
|
|
1271
|
+
if (result.path === "swarm request" && option === "alias")
|
|
1272
|
+
syntax("swarm request --alias was removed. First run ipab swarm set ALIAS CONFIG_URL, then ipab swarm request ALIAS.");
|
|
1074
1273
|
if (Object.hasOwn(result.options, option))
|
|
1075
1274
|
syntax(`Duplicate option ${value}.`);
|
|
1076
1275
|
if (booleans.includes(option))
|
|
@@ -1080,7 +1279,8 @@ export function parse(argv) {
|
|
|
1080
1279
|
if (input === undefined ||
|
|
1081
1280
|
(input.startsWith("--") &&
|
|
1082
1281
|
!(option === "resume" && /^[A-Za-z0-9_-]{43}$/.test(input))) ||
|
|
1083
|
-
(input === "" &&
|
|
1282
|
+
(input === "" &&
|
|
1283
|
+
!["swarm update", "profile", "templates render"].includes(result.path)))
|
|
1084
1284
|
syntax(`${value} needs a value.`);
|
|
1085
1285
|
result.options[option] = input;
|
|
1086
1286
|
}
|
|
@@ -1093,8 +1293,7 @@ export function parse(argv) {
|
|
|
1093
1293
|
else
|
|
1094
1294
|
result.positional.push(value);
|
|
1095
1295
|
}
|
|
1096
|
-
|
|
1097
|
-
syntax("--force and --no-force are mutually exclusive.");
|
|
1296
|
+
validateRefreshOptions(result.options);
|
|
1098
1297
|
if (result.path === "search" &&
|
|
1099
1298
|
result.options.current &&
|
|
1100
1299
|
flags.swarm !== undefined)
|
|
@@ -1103,8 +1302,14 @@ export function parse(argv) {
|
|
|
1103
1302
|
result.options.all &&
|
|
1104
1303
|
(result.options.current || flags.swarm !== undefined))
|
|
1105
1304
|
syntax("--all is mutually exclusive with --current and --swarm.");
|
|
1305
|
+
if (result.path === "register list" &&
|
|
1306
|
+
(result.registrySwarms?.length ?? 0) > 1)
|
|
1307
|
+
syntax("register list accepts --swarm at most once. Select one Swarm or omit it to use the current Swarm.");
|
|
1106
1308
|
const counts = {
|
|
1309
|
+
daemon: [0, 0],
|
|
1107
1310
|
doctor: [0, 0],
|
|
1311
|
+
"skills list": [0, 0],
|
|
1312
|
+
"skills sync": [0, Number.MAX_SAFE_INTEGER],
|
|
1108
1313
|
profile: [0, 0],
|
|
1109
1314
|
"swarm create": [0, 0],
|
|
1110
1315
|
"swarm request": [1, 1],
|
|
@@ -1116,14 +1321,14 @@ export function parse(argv) {
|
|
|
1116
1321
|
"swarm status": [0, 0],
|
|
1117
1322
|
"swarm members": [0, 0],
|
|
1118
1323
|
"swarm list": [0, 0],
|
|
1119
|
-
"swarm
|
|
1324
|
+
"swarm set": [2, 2],
|
|
1120
1325
|
"swarm use": [1, 1],
|
|
1121
1326
|
"swarm remove": [1, 1],
|
|
1122
1327
|
"swarm update": [0, 0],
|
|
1123
1328
|
publish: [2, 2],
|
|
1124
1329
|
get: [1, 1],
|
|
1125
1330
|
search: [1, 1],
|
|
1126
|
-
|
|
1331
|
+
"templates render": [2, 3],
|
|
1127
1332
|
build: [0, 1],
|
|
1128
1333
|
"bundle build": [1, 1],
|
|
1129
1334
|
"bundle inspect": [1, 1],
|
|
@@ -1136,6 +1341,10 @@ export function parse(argv) {
|
|
|
1136
1341
|
"register list": [0, 0],
|
|
1137
1342
|
"register set": [2, 2],
|
|
1138
1343
|
"register remove": [1, 1],
|
|
1344
|
+
"templates list": [0, 0],
|
|
1345
|
+
"templates show": [1, 1],
|
|
1346
|
+
"templates set": [2, 2],
|
|
1347
|
+
"templates remove": [1, 1],
|
|
1139
1348
|
"config get": [0, 1],
|
|
1140
1349
|
"config set": [2, 2],
|
|
1141
1350
|
"config reset": [1, 1],
|
|
@@ -1162,9 +1371,8 @@ export function parse(argv) {
|
|
|
1162
1371
|
syntax(`Swarm target positionals are no longer supported. Use ipab --swarm URL_OR_ALIAS ${result.path} instead.`);
|
|
1163
1372
|
if (result.positional.length < minimum || result.positional.length > maximum)
|
|
1164
1373
|
syntax(`Invalid arguments.\n${help(result.path)}`);
|
|
1165
|
-
if (result.template
|
|
1166
|
-
(
|
|
1167
|
-
syntax('Argument template must contain a whole "%" token.');
|
|
1374
|
+
if (result.template)
|
|
1375
|
+
syntax('Custom per-association argv is unsupported. Remove "-- TEMPLATE..."; open passes only the content CID. Adapt the App or use ipab exec APP_CID ARGS.');
|
|
1168
1376
|
if (result.path === "history remove") {
|
|
1169
1377
|
const selected = values.some((value) => Object.hasOwn(result.options, value));
|
|
1170
1378
|
if ((!selected && !result.positional.length) ||
|
|
@@ -1187,6 +1395,15 @@ export function parse(argv) {
|
|
|
1187
1395
|
if (result.options.expect && result.options.snapshot)
|
|
1188
1396
|
syntax("--snapshot is initial-only and cannot be combined with --expect.");
|
|
1189
1397
|
}
|
|
1398
|
+
if (result.path.startsWith("templates ") &&
|
|
1399
|
+
result.path !== "templates render") {
|
|
1400
|
+
if (result.positional[0] !== undefined)
|
|
1401
|
+
templateName(result.positional[0]);
|
|
1402
|
+
if (typeof result.options.expect === "string")
|
|
1403
|
+
exactCid(result.options.expect);
|
|
1404
|
+
if (result.path === "templates remove" && !result.options.expect)
|
|
1405
|
+
syntax("templates remove requires --expect OLD_TARGET_CID.");
|
|
1406
|
+
}
|
|
1190
1407
|
if (result.path.startsWith("config ") && result.positional[0]) {
|
|
1191
1408
|
if (!(result.path === "config get" && result.positional[0] === "state-dir") &&
|
|
1192
1409
|
!(result.path === "config reset" && result.positional[0] === "store.rpc"))
|
|
@@ -1268,8 +1485,12 @@ async function performCli(argv, io, env) {
|
|
|
1268
1485
|
return 0;
|
|
1269
1486
|
}
|
|
1270
1487
|
const items = effectiveConfig(state.config({
|
|
1271
|
-
includeSecrets: ![
|
|
1272
|
-
|
|
1488
|
+
includeSecrets: ![
|
|
1489
|
+
"swarm members",
|
|
1490
|
+
"profile",
|
|
1491
|
+
"swarm status",
|
|
1492
|
+
"swarm set",
|
|
1493
|
+
].includes(parsed.path),
|
|
1273
1494
|
}), parsed.flags, env, (reference) => state.resolveSwarm(reference));
|
|
1274
1495
|
const value = (key) => items.find((item) => item.key === key).value;
|
|
1275
1496
|
const emit = (result, human) => {
|
|
@@ -1296,9 +1517,10 @@ async function performCli(argv, io, env) {
|
|
|
1296
1517
|
stateDir: stateLocation(parsed.flags, env).path,
|
|
1297
1518
|
cacheTtl: Number(value("swarm.cacheTtl")),
|
|
1298
1519
|
listen: value("swarm.listen") === "loopback" ? "loopback" : "lan",
|
|
1299
|
-
|
|
1520
|
+
pivot: Boolean(value("swarm.pivot")),
|
|
1521
|
+
forceRefresh: parsed.options.refresh || parsed.options.force
|
|
1300
1522
|
? true
|
|
1301
|
-
: parsed.options["no-force"]
|
|
1523
|
+
: parsed.options["no-refresh"] || parsed.options["no-force"]
|
|
1302
1524
|
? false
|
|
1303
1525
|
: Boolean(value("swarm.forceRefresh")),
|
|
1304
1526
|
diagnostic: (text) => {
|
|
@@ -1325,10 +1547,93 @@ async function performCli(argv, io, env) {
|
|
|
1325
1547
|
};
|
|
1326
1548
|
if (parsed.path === "open" || parsed.path.startsWith("register ")) {
|
|
1327
1549
|
if (state.legacyRegistrationCount)
|
|
1328
|
-
io.err(`Legacy User registrations are inactive. ${state.legacyRegistrationCount} entries are preserved in legacy_user_registrations in the state database under ${state.directory}; nothing was uploaded or deleted. Review the archived values and explicitly run ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS
|
|
1550
|
+
io.err(`Legacy User registrations are inactive. ${state.legacyRegistrationCount} entries are preserved in legacy_user_registrations in the state database under ${state.directory}; nothing was uploaded or deleted. Custom per-association argv is unsupported. Review the archived values and explicitly run ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS to publish only intended associations.`);
|
|
1329
1551
|
}
|
|
1330
1552
|
if (state.legacyPinCount)
|
|
1331
1553
|
io.err(`Legacy local pin names are inactive: ${state.legacyPinCount} records are preserved in legacy_named_pins under ${state.directory}. Retention and original Store owners are unchanged; inspect ipab pin list and release intended archived holders with ipab unpin EXACT_CID.`);
|
|
1554
|
+
if (parsed.path.startsWith("templates ") &&
|
|
1555
|
+
parsed.path !== "templates render") {
|
|
1556
|
+
const configUrl = requireSwarm();
|
|
1557
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1558
|
+
const context = swarmContext();
|
|
1559
|
+
const expected = typeof parsed.options.expect === "string"
|
|
1560
|
+
? parsed.options.expect
|
|
1561
|
+
: undefined;
|
|
1562
|
+
try {
|
|
1563
|
+
if (parsed.path === "templates list") {
|
|
1564
|
+
const items = await swarmTemplates(context, configUrl);
|
|
1565
|
+
const alias = state
|
|
1566
|
+
.swarms()
|
|
1567
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1568
|
+
emit({ items }, `Swarm: ${alias ? printable(alias) : "(no local alias)"}\nConfig URL: ${configUrl}\nTemplates: ${items.length}\n\n${table(["NAME", "TITLE", "TARGET CID", "TEMPLATE CID"], items.map((item) => [
|
|
1569
|
+
item.selector,
|
|
1570
|
+
item.title,
|
|
1571
|
+
item.targetCid,
|
|
1572
|
+
item.templateCid,
|
|
1573
|
+
]), "No templates registered in this Swarm.\nAdd a template: ipab templates set NAME SOURCE")}`);
|
|
1574
|
+
}
|
|
1575
|
+
else if (parsed.path === "templates show") {
|
|
1576
|
+
const item = (await swarmTemplates(context, configUrl, first))[0];
|
|
1577
|
+
if (parsed.flags.json)
|
|
1578
|
+
io.out(JSON.stringify(item));
|
|
1579
|
+
else {
|
|
1580
|
+
const alias = state
|
|
1581
|
+
.swarms()
|
|
1582
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1583
|
+
const swarm = alias ?? configUrl;
|
|
1584
|
+
const reference = formatNameReference(swarm, item.name);
|
|
1585
|
+
const tree = await templateOutputTree(context.store, item.templateCid);
|
|
1586
|
+
const shell = process.platform === "win32" ? "powershell" : "posix";
|
|
1587
|
+
io.out([
|
|
1588
|
+
`${printable(item.selector)} — ${printable(item.title)}`,
|
|
1589
|
+
printable(item.description) || "(No description.)",
|
|
1590
|
+
"",
|
|
1591
|
+
"Location",
|
|
1592
|
+
` Swarm: ${printable(swarm)}`,
|
|
1593
|
+
` Name: ${printable(item.name)}`,
|
|
1594
|
+
"",
|
|
1595
|
+
`Create a project (${shell === "powershell" ? "PowerShell" : "POSIX shell"})`,
|
|
1596
|
+
` ${templateRenderExample(reference, swarm, item.definition, shell)}`,
|
|
1597
|
+
" Replace example parameter values as needed. No code is run by show.",
|
|
1598
|
+
"",
|
|
1599
|
+
"Parameters",
|
|
1600
|
+
table(["NAME", "TYPE", "REQUIRED", "DEFAULT", "INPUT"], templateParameterRows(item.definition), "No parameters declared."),
|
|
1601
|
+
"Required means an input is needed when no default is declared.",
|
|
1602
|
+
"",
|
|
1603
|
+
"Output files (from project/)",
|
|
1604
|
+
" my-project/",
|
|
1605
|
+
...tree.entries.map((entry) => `${" ".repeat(entry.path.split("/").length + 1)}${printable(entry.path.split("/").at(-1))}${entry.kind === "directory" ? "/" : ""}`),
|
|
1606
|
+
...(tree.truncated
|
|
1607
|
+
? [
|
|
1608
|
+
` ... truncated: ${tree.truncated}; more files may exist.`,
|
|
1609
|
+
]
|
|
1610
|
+
: tree.entries.length
|
|
1611
|
+
? []
|
|
1612
|
+
: [" (no output files)"]),
|
|
1613
|
+
"",
|
|
1614
|
+
"Versions",
|
|
1615
|
+
` Template CID: ${item.templateCid}`,
|
|
1616
|
+
` Reference: ${reference}`,
|
|
1617
|
+
...(item.targetCid !== item.templateCid
|
|
1618
|
+
? [` Target CID (--expect): ${item.targetCid}`]
|
|
1619
|
+
: []),
|
|
1620
|
+
].join("\n"));
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
else if (parsed.path === "templates set") {
|
|
1624
|
+
const item = await setSwarmTemplate(context, configUrl, first, second, expected);
|
|
1625
|
+
emit(item, `${item.reference} → ${item.targetCid} (Template ${item.templateCid})`);
|
|
1626
|
+
}
|
|
1627
|
+
else {
|
|
1628
|
+
const item = await removeSwarmTemplate(context, configUrl, first, expected);
|
|
1629
|
+
emit({ removed: item }, `Removed ${item.reference}; content and history are retained.`);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
finally {
|
|
1633
|
+
await context.finishRead?.();
|
|
1634
|
+
}
|
|
1635
|
+
return 0;
|
|
1636
|
+
}
|
|
1332
1637
|
if (parsed.path.startsWith("register ")) {
|
|
1333
1638
|
const references = parsed.registrySwarms?.length
|
|
1334
1639
|
? parsed.registrySwarms
|
|
@@ -1336,7 +1641,7 @@ async function performCli(argv, io, env) {
|
|
|
1336
1641
|
? [selectedSwarm]
|
|
1337
1642
|
: [];
|
|
1338
1643
|
if (!references.length)
|
|
1339
|
-
throw new HostError("Register requires a selected Swarm. Pass --swarm URL_OR_ALIAS
|
|
1644
|
+
throw new HostError("Register requires a selected Swarm. Pass --swarm URL_OR_ALIAS, or save a default with ipab swarm use URL_OR_ALIAS.");
|
|
1340
1645
|
const targets = [
|
|
1341
1646
|
...new Set(references.map((reference) => state.resolveSwarm(reference))),
|
|
1342
1647
|
];
|
|
@@ -1352,12 +1657,11 @@ async function performCli(argv, io, env) {
|
|
|
1352
1657
|
try {
|
|
1353
1658
|
if (parsed.path === "register list") {
|
|
1354
1659
|
const items = await swarmRegistrations(context, configUrl);
|
|
1660
|
+
const alias = state
|
|
1661
|
+
.swarms()
|
|
1662
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1355
1663
|
results.push({ items });
|
|
1356
|
-
human.push(
|
|
1357
|
-
item.schemaCid,
|
|
1358
|
-
item.appCid,
|
|
1359
|
-
JSON.stringify(item.argv),
|
|
1360
|
-
]), "No associations.")}`);
|
|
1664
|
+
human.push(`Swarm: ${alias ? printable(alias) : "(no local alias)"}\nConfig URL: ${configUrl}\nAssociations: ${items.length}\n\n${table(["TYPE CID", "APP CID"], items.map((item) => [item.schemaCid, item.appCid]), "No associations registered in this Swarm.\nRegister an App: ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS")}`);
|
|
1361
1665
|
}
|
|
1362
1666
|
else if (parsed.path === "register set") {
|
|
1363
1667
|
const appCid = parseNameReference(second)
|
|
@@ -1375,7 +1679,9 @@ async function performCli(argv, io, env) {
|
|
|
1375
1679
|
completed.push(configUrl);
|
|
1376
1680
|
}
|
|
1377
1681
|
catch (cause) {
|
|
1378
|
-
throw new HostError(
|
|
1682
|
+
throw new HostError(parsed.path === "register list"
|
|
1683
|
+
? `Cannot list associations for Swarm ${configUrl}: ${message(cause)}`
|
|
1684
|
+
: `Registry operation failed for ${configUrl}: ${message(cause)}. Completed Swarms: ${completed.length ? completed.join(", ") : "(none)"}. Multiple Swarm edits are not atomic.`, cause instanceof HostError ? cause.exitCode : 1, cause instanceof HostError ? cause.code : "REGISTRY_FAILED", "publication");
|
|
1379
1685
|
}
|
|
1380
1686
|
finally {
|
|
1381
1687
|
await context.finishRead?.();
|
|
@@ -1429,7 +1735,10 @@ async function performCli(argv, io, env) {
|
|
|
1429
1735
|
alias: entry.alias,
|
|
1430
1736
|
})),
|
|
1431
1737
|
}, [
|
|
1432
|
-
...result.swarms.map((entry) =>
|
|
1738
|
+
...alignedRows(result.swarms.map((entry) => [
|
|
1739
|
+
`${entry.cid === result.effectiveCurrent ? "*" : " "} ${entry.alias ?? entry.cid}`,
|
|
1740
|
+
entry.cid,
|
|
1741
|
+
])),
|
|
1433
1742
|
...(result.swarms.length ? [] : ["No registered Swarms."]),
|
|
1434
1743
|
...(result.effectiveCurrent === null
|
|
1435
1744
|
? ["Use ipab swarm use <alias> to select a default Swarm."]
|
|
@@ -1458,9 +1767,52 @@ async function performCli(argv, io, env) {
|
|
|
1458
1767
|
}, `Removed registration ${removed}. Credentials, content and remote membership are unchanged.`);
|
|
1459
1768
|
break;
|
|
1460
1769
|
}
|
|
1461
|
-
case "swarm
|
|
1770
|
+
case "swarm set": {
|
|
1771
|
+
swarmAlias(first);
|
|
1772
|
+
const cid = swarmUrl(second);
|
|
1773
|
+
const previous = state.swarms().find((entry) => entry.alias === first);
|
|
1774
|
+
if (previous && previous.cid !== cid) {
|
|
1775
|
+
io.err(`Swarm alias ${first}: ${previous.cid} -> ${cid}`);
|
|
1776
|
+
if (!parsed.options.yes &&
|
|
1777
|
+
(!io.tty ||
|
|
1778
|
+
!(await io.confirm(`Retarget local Swarm alias "${first}" from ${previous.cid} to ${cid}?`))))
|
|
1779
|
+
throw new HostError("Alias unchanged. Retargeting requires --yes or interactive confirmation.");
|
|
1780
|
+
}
|
|
1781
|
+
const entry = state.setSwarm(first, cid, previous?.cid ?? null);
|
|
1782
|
+
emit({
|
|
1783
|
+
configUrl: entry.cid,
|
|
1784
|
+
alias: entry.alias,
|
|
1785
|
+
savedCurrent: state.config({ includeSecrets: false })["swarm.default"] ?? null,
|
|
1786
|
+
}, `Set local swarm alias ${entry.alias} (${cid}).`);
|
|
1787
|
+
break;
|
|
1788
|
+
}
|
|
1789
|
+
case "daemon": {
|
|
1790
|
+
if (parsed.flags.json)
|
|
1791
|
+
syntax("--json is not supported for daemon; diagnostics are written to stderr.");
|
|
1792
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1793
|
+
const controller = new AbortController();
|
|
1794
|
+
const interrupt = () => {
|
|
1795
|
+
controller.abort();
|
|
1796
|
+
};
|
|
1797
|
+
process.once("SIGINT", interrupt);
|
|
1798
|
+
process.once("SIGTERM", interrupt);
|
|
1799
|
+
try {
|
|
1800
|
+
await swarmDaemon(swarmContext(), parsed.flags.swarm === undefined ? undefined : requireSwarm(), controller.signal);
|
|
1801
|
+
}
|
|
1802
|
+
catch (cause) {
|
|
1803
|
+
if (!controller.signal.aborted)
|
|
1804
|
+
throw cause;
|
|
1805
|
+
}
|
|
1806
|
+
finally {
|
|
1807
|
+
process.removeListener("SIGINT", interrupt);
|
|
1808
|
+
process.removeListener("SIGTERM", interrupt);
|
|
1809
|
+
}
|
|
1810
|
+
break;
|
|
1811
|
+
}
|
|
1462
1812
|
case "swarm update":
|
|
1463
1813
|
case "search":
|
|
1814
|
+
case "skills list":
|
|
1815
|
+
case "skills sync":
|
|
1464
1816
|
case "swarm create":
|
|
1465
1817
|
case "swarm request":
|
|
1466
1818
|
case "swarm approve":
|
|
@@ -1476,6 +1828,35 @@ async function performCli(argv, io, env) {
|
|
|
1476
1828
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1477
1829
|
const context = swarmContext();
|
|
1478
1830
|
readContext = context;
|
|
1831
|
+
if (parsed.path.startsWith("skills ")) {
|
|
1832
|
+
const result = await manageSkills(context, requireSwarm(), {
|
|
1833
|
+
sync: parsed.path === "skills sync",
|
|
1834
|
+
names: parsed.positional,
|
|
1835
|
+
agents: parsed.agents ?? [],
|
|
1836
|
+
dryRun: Boolean(parsed.options["dry-run"]),
|
|
1837
|
+
yes: Boolean(parsed.options.yes),
|
|
1838
|
+
tty: io.tty,
|
|
1839
|
+
confirm: (text) => io.confirm(text),
|
|
1840
|
+
preview: (text) => {
|
|
1841
|
+
io.err(text);
|
|
1842
|
+
},
|
|
1843
|
+
});
|
|
1844
|
+
store = context.store;
|
|
1845
|
+
emit(result, [
|
|
1846
|
+
table(["NAME", "PAYLOAD CID", "INSTALL NAME", "STATUS"], result.items.map((skill) => [
|
|
1847
|
+
skill.name,
|
|
1848
|
+
skill.cid,
|
|
1849
|
+
skill.identity,
|
|
1850
|
+
skill.status,
|
|
1851
|
+
]), "No Skills."),
|
|
1852
|
+
...result.items.flatMap((skill) => skill.problems),
|
|
1853
|
+
...result.orphaned.map((skill) => `Source removed: ${skill.name} ${skill.cid} (${skill.path}); installation retained.`),
|
|
1854
|
+
...result.results.map((entry) => `${entry.name} / ${entry.agent}: ${entry.status}${entry.error ? `: ${entry.error}` : ""}`),
|
|
1855
|
+
].join("\n"));
|
|
1856
|
+
if (!result.ok)
|
|
1857
|
+
return 1;
|
|
1858
|
+
break;
|
|
1859
|
+
}
|
|
1479
1860
|
if (parsed.path === "pin") {
|
|
1480
1861
|
io.err("Fetching, verifying and retaining content...");
|
|
1481
1862
|
const result = await pinNameSubscription(context, first, selectedSwarm);
|
|
@@ -1484,13 +1865,20 @@ async function performCli(argv, io, env) {
|
|
|
1484
1865
|
break;
|
|
1485
1866
|
}
|
|
1486
1867
|
if (parsed.path === "swarm members") {
|
|
1487
|
-
const result = await swarmMembers(context, requireSwarm());
|
|
1488
|
-
emit(result,
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
member
|
|
1492
|
-
|
|
1493
|
-
|
|
1868
|
+
const result = await swarmMembers(context, requireSwarm(), Boolean(parsed.options.refresh || parsed.options.force));
|
|
1869
|
+
emit(result, [
|
|
1870
|
+
`Directory: ${result.cache.source} (${result.cache.freshness}), observed ${result.cache.updatedAt}`,
|
|
1871
|
+
`Daemon: ${result.local.status}, observed ${result.local.updatedAt ?? "unknown"}; control-plane verified ${result.local.verifiedAt ?? "unknown"}`,
|
|
1872
|
+
table(["NAME", "DESCRIPTION", "ROLE", "PIVOT", "PUBLIC KEY"], result.members.map((member) => [
|
|
1873
|
+
member.name,
|
|
1874
|
+
member.description,
|
|
1875
|
+
member.role,
|
|
1876
|
+
member.pivot ? (member.localStatus ?? "candidate") : "-",
|
|
1877
|
+
member.publicKey,
|
|
1878
|
+
]), "No members."),
|
|
1879
|
+
].join("\n"));
|
|
1880
|
+
if (result.local.error)
|
|
1881
|
+
io.err(`Local Pivot observations (${result.local.status}): ${printable(result.local.error)}`);
|
|
1494
1882
|
break;
|
|
1495
1883
|
}
|
|
1496
1884
|
if (parsed.path === "swarm export") {
|
|
@@ -1534,20 +1922,6 @@ async function performCli(argv, io, env) {
|
|
|
1534
1922
|
emit(result, `Swarm: ${result.configUrl}\nName: ${printable(result.properties.name)}\nDescription: ${printable(result.properties.description)}\nHEAD ID: ${result.headId}\nConfig content CID: ${result.valueCid}`);
|
|
1535
1923
|
break;
|
|
1536
1924
|
}
|
|
1537
|
-
if (parsed.path === "swarm add") {
|
|
1538
|
-
const cid = state.resolveSwarm(first);
|
|
1539
|
-
await addSwarm(context, cid, typeof parsed.options.alias === "string"
|
|
1540
|
-
? parsed.options.alias
|
|
1541
|
-
: undefined);
|
|
1542
|
-
const entry = state.registeredSwarm(cid);
|
|
1543
|
-
emit({
|
|
1544
|
-
configUrl: entry.cid,
|
|
1545
|
-
alias: entry.alias,
|
|
1546
|
-
savedCurrent: state.config({ includeSecrets: false })["swarm.default"] ??
|
|
1547
|
-
null,
|
|
1548
|
-
}, `Registered swarm ${entry.alias ?? cid} (${cid}).`);
|
|
1549
|
-
break;
|
|
1550
|
-
}
|
|
1551
1925
|
if (parsed.path === "search") {
|
|
1552
1926
|
const registrations = state.swarms();
|
|
1553
1927
|
const scope = parsed.options.all
|
|
@@ -1565,10 +1939,7 @@ async function performCli(argv, io, env) {
|
|
|
1565
1939
|
}
|
|
1566
1940
|
if (parsed.path === "swarm status") {
|
|
1567
1941
|
const cid = requireSwarm();
|
|
1568
|
-
const
|
|
1569
|
-
const { head, config } = local
|
|
1570
|
-
? await swarmHeader(context, cid, true)
|
|
1571
|
-
: await sharedSwarmStatus(context, cid);
|
|
1942
|
+
const { head, config, networking, cache, state: contentState, } = await inspectSwarmStatus(context, cid, Boolean(parsed.options.refresh || parsed.options.force));
|
|
1572
1943
|
const fingerprint = await keyId(config.owner);
|
|
1573
1944
|
store = context.store;
|
|
1574
1945
|
emit({
|
|
@@ -1576,12 +1947,11 @@ async function performCli(argv, io, env) {
|
|
|
1576
1947
|
owner: config.owner,
|
|
1577
1948
|
ownerFingerprint: fingerprint,
|
|
1578
1949
|
epoch: config.epoch,
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
: {}),
|
|
1950
|
+
scopeId: config.scopeId,
|
|
1951
|
+
headId: config.headId,
|
|
1952
|
+
cache,
|
|
1953
|
+
state: contentState,
|
|
1954
|
+
networking,
|
|
1585
1955
|
root: head.root,
|
|
1586
1956
|
valueCid: head.cid,
|
|
1587
1957
|
properties: {
|
|
@@ -1590,6 +1960,7 @@ async function performCli(argv, io, env) {
|
|
|
1590
1960
|
},
|
|
1591
1961
|
}, [
|
|
1592
1962
|
"Swarm",
|
|
1963
|
+
` Directory: ${cache.source} (${cache.freshness}), observed ${cache.updatedAt}`,
|
|
1593
1964
|
` Name: ${printable(config.name)}`,
|
|
1594
1965
|
` Description: ${config.description ? printable(config.description) : "(none)"}`,
|
|
1595
1966
|
" Config URL:",
|
|
@@ -1598,21 +1969,59 @@ async function performCli(argv, io, env) {
|
|
|
1598
1969
|
"Identity",
|
|
1599
1970
|
" Owner fingerprint:",
|
|
1600
1971
|
` ${fingerprint}`,
|
|
1601
|
-
...(local
|
|
1602
|
-
? [
|
|
1603
|
-
" PeerID:",
|
|
1604
|
-
` ${context.node.peerId}`,
|
|
1605
|
-
"",
|
|
1606
|
-
"Local addresses",
|
|
1607
|
-
...context.node.addresses.map((address) => ` ${printable(address)}`),
|
|
1608
|
-
]
|
|
1609
|
-
: []),
|
|
1610
1972
|
"",
|
|
1611
1973
|
"Content",
|
|
1612
1974
|
" HEAD (publication root):",
|
|
1613
1975
|
` ${head.root}`,
|
|
1614
1976
|
" Content CID (HEAD value):",
|
|
1615
1977
|
` ${head.cid}`,
|
|
1978
|
+
` State: ${contentState.status}. ${contentState.error}`,
|
|
1979
|
+
"",
|
|
1980
|
+
"Local networking",
|
|
1981
|
+
` Daemon observations: ${networking.daemon.status}`,
|
|
1982
|
+
` Updated: ${networking.daemon.updatedAt ?? "unknown"}`,
|
|
1983
|
+
` Control-plane verified: ${networking.daemon.verifiedAt ?? "unknown"}`,
|
|
1984
|
+
...(networking.daemon.error
|
|
1985
|
+
? [` Observation error: ${printable(networking.daemon.error)}`]
|
|
1986
|
+
: []),
|
|
1987
|
+
` Connections observed: ${networking.connections.observedAt ?? "unknown"} (${networking.connections.freshness})`,
|
|
1988
|
+
...(networking.connections.error
|
|
1989
|
+
? [
|
|
1990
|
+
` Connection error: ${printable(networking.connections.error)}`,
|
|
1991
|
+
]
|
|
1992
|
+
: []),
|
|
1993
|
+
table([
|
|
1994
|
+
"PIVOT PEER ID",
|
|
1995
|
+
"LOCAL",
|
|
1996
|
+
"PROBE",
|
|
1997
|
+
"PROBED AT",
|
|
1998
|
+
"FAILURES",
|
|
1999
|
+
"RETRY AT",
|
|
2000
|
+
"CONNECTION",
|
|
2001
|
+
], networking.pivots.map((pivot) => [
|
|
2002
|
+
pivot.peerId,
|
|
2003
|
+
pivot.localStatus ?? "unknown",
|
|
2004
|
+
`${pivot.probe.result} (${pivot.probe.freshness})`,
|
|
2005
|
+
pivot.probe.at ?? "-",
|
|
2006
|
+
pivot.failures === null ? "-" : String(pivot.failures),
|
|
2007
|
+
pivot.retryAt ?? "-",
|
|
2008
|
+
pivot.connection.status,
|
|
2009
|
+
]), "No declared Pivots."),
|
|
2010
|
+
...networking.pivots.flatMap((pivot) => pivot.probe.error
|
|
2011
|
+
? [
|
|
2012
|
+
` ${pivot.peerId} probe error: ${printable(pivot.probe.error)}`,
|
|
2013
|
+
]
|
|
2014
|
+
: []),
|
|
2015
|
+
...(networking.connections.error
|
|
2016
|
+
? []
|
|
2017
|
+
: [
|
|
2018
|
+
table(["CONNECTED PEER ID", "TRANSPORT", "ADDRESS"], networking.connections.peers.map((peer) => [
|
|
2019
|
+
peer.peerId,
|
|
2020
|
+
peer.transport,
|
|
2021
|
+
peer.address,
|
|
2022
|
+
]), "No observed peer connections."),
|
|
2023
|
+
]),
|
|
2024
|
+
" Selected is configuration, not connection success. Relay connectivity does not guarantee content availability.",
|
|
1616
2025
|
].join("\n"));
|
|
1617
2026
|
break;
|
|
1618
2027
|
}
|
|
@@ -1679,10 +2088,7 @@ async function performCli(argv, io, env) {
|
|
|
1679
2088
|
});
|
|
1680
2089
|
}
|
|
1681
2090
|
else if (parsed.path === "swarm request") {
|
|
1682
|
-
const result = await requestMembership(context, first, {
|
|
1683
|
-
...(typeof parsed.options.alias === "string"
|
|
1684
|
-
? { alias: parsed.options.alias }
|
|
1685
|
-
: {}),
|
|
2091
|
+
const result = await requestMembership(context, state.resolveSwarm(first), {
|
|
1686
2092
|
...(typeof parsed.options.output === "string"
|
|
1687
2093
|
? { output: parsed.options.output }
|
|
1688
2094
|
: {}),
|
|
@@ -1755,7 +2161,7 @@ async function performCli(argv, io, env) {
|
|
|
1755
2161
|
}
|
|
1756
2162
|
break;
|
|
1757
2163
|
}
|
|
1758
|
-
case "
|
|
2164
|
+
case "templates render":
|
|
1759
2165
|
case "build":
|
|
1760
2166
|
case "bundle build":
|
|
1761
2167
|
case "bundle inspect":
|
|
@@ -1791,34 +2197,73 @@ async function performCli(argv, io, env) {
|
|
|
1791
2197
|
const builtin = builtins.blocks.get(cid.toV1().toString());
|
|
1792
2198
|
if (builtin)
|
|
1793
2199
|
return builtin.slice();
|
|
1794
|
-
return (await getStore()).block.get(cid.toString(), options);
|
|
2200
|
+
return (store ?? (await getStore())).block.get(cid.toString(), options);
|
|
1795
2201
|
},
|
|
1796
2202
|
};
|
|
1797
2203
|
const builtinSource = first ? state.pin(first) : undefined;
|
|
1798
2204
|
const source = builtinSource?.builtin && builtinSource.metadata?.kind === "bundle"
|
|
1799
2205
|
? builtinSource.cid
|
|
1800
2206
|
: first;
|
|
2207
|
+
let selectedTemplate;
|
|
2208
|
+
if (parsed.path === "templates render") {
|
|
2209
|
+
const selector = first;
|
|
2210
|
+
selectedTemplate = selector;
|
|
2211
|
+
if (parseNameReference(selector)) {
|
|
2212
|
+
await getStore();
|
|
2213
|
+
const context = swarmContext();
|
|
2214
|
+
readContext = context;
|
|
2215
|
+
selectedTemplate = (await resolveReference(context, selector, selectedSwarm, (reference) => state.resolve(reference), false, "local-first")).cid;
|
|
2216
|
+
store = context.store;
|
|
2217
|
+
}
|
|
2218
|
+
else {
|
|
2219
|
+
let explicit = false;
|
|
2220
|
+
try {
|
|
2221
|
+
CID.parse(selector);
|
|
2222
|
+
explicit = true;
|
|
2223
|
+
}
|
|
2224
|
+
catch {
|
|
2225
|
+
/* Not a CID. */
|
|
2226
|
+
}
|
|
2227
|
+
explicit ||= selector.toLowerCase().endsWith(".car");
|
|
2228
|
+
if (!explicit) {
|
|
2229
|
+
try {
|
|
2230
|
+
await lstat(selector);
|
|
2231
|
+
explicit = true;
|
|
2232
|
+
}
|
|
2233
|
+
catch (cause) {
|
|
2234
|
+
if (!nodeError(cause, "ENOENT") &&
|
|
2235
|
+
!nodeError(cause, "ENOTDIR"))
|
|
2236
|
+
throw cause;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
if (!explicit) {
|
|
2240
|
+
templateName(selector);
|
|
2241
|
+
if (!selectedSwarm)
|
|
2242
|
+
throw new HostError("Template selectors require a selected Swarm. Use --swarm or swarm use, or supply an explicit Bundle directory, CAR, exact CID or IPAB URI.");
|
|
2243
|
+
await getStore();
|
|
2244
|
+
const context = swarmContext();
|
|
2245
|
+
readContext = context;
|
|
2246
|
+
selectedTemplate = await resolveTemplateSelector(context, selector, selectedSwarm);
|
|
2247
|
+
store = context.store;
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
1801
2251
|
if (parsed.path === "bundle build" || parsed.path === "build")
|
|
1802
2252
|
io.err(parsed.path === "build"
|
|
1803
2253
|
? "Assembling and validating Bundle (no compilation)..."
|
|
1804
2254
|
: "Validating and building bundle...");
|
|
1805
2255
|
if (parsed.path === "bundle import")
|
|
1806
2256
|
io.err("Validating and importing CAR into Store...");
|
|
1807
|
-
const result = parsed.path === "
|
|
1808
|
-
? await initApp(
|
|
2257
|
+
const result = parsed.path === "templates render"
|
|
2258
|
+
? await initApp(second, parsed.positional[2], {
|
|
1809
2259
|
...request,
|
|
1810
|
-
...(
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
}
|
|
1818
|
-
: {}),
|
|
1819
|
-
...(parsed.parameters
|
|
1820
|
-
? { parameters: parsed.parameters }
|
|
1821
|
-
: {}),
|
|
2260
|
+
...(selectedTemplate ? { template: selectedTemplate } : {}),
|
|
2261
|
+
parameters: [
|
|
2262
|
+
...(parsed.parameters ?? []),
|
|
2263
|
+
...(typeof parsed.options.description === "string"
|
|
2264
|
+
? [`description=${parsed.options.description}`]
|
|
2265
|
+
: []),
|
|
2266
|
+
],
|
|
1822
2267
|
})
|
|
1823
2268
|
: parsed.path === "build"
|
|
1824
2269
|
? await assembleBundle(first, {
|
|
@@ -2116,7 +2561,9 @@ async function performCli(argv, io, env) {
|
|
|
2116
2561
|
if (!association)
|
|
2117
2562
|
throw new HostError(`No App registered for Schema ${schema} in Swarm ${registrySwarm}. Use ipab register set ${schema} APP_CID --swarm ${registrySwarm} or ipab exec.`);
|
|
2118
2563
|
appCid = association.appCid;
|
|
2119
|
-
|
|
2564
|
+
if (association.argv.length !== 1 || association.argv[0] !== "%")
|
|
2565
|
+
throw new HostError("Custom per-association argv is unsupported; adapt the App to accept only the content CID or use ipab exec APP_CID ARGS.");
|
|
2566
|
+
appArgv = [root];
|
|
2120
2567
|
// execute owns the App/input context before this validation owner's eventual release.
|
|
2121
2568
|
const result = await execute(state, store, { origin: "open", appCid, argv: appArgv }, {
|
|
2122
2569
|
inputSchema: schema,
|