@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/src/authoring.ts
CHANGED
|
@@ -28,12 +28,14 @@ import {
|
|
|
28
28
|
openBundle,
|
|
29
29
|
openSchema,
|
|
30
30
|
parseBundleManifest,
|
|
31
|
+
parseBundleType,
|
|
31
32
|
ContentBundleError,
|
|
32
33
|
} from "@ipab/bundle";
|
|
33
34
|
import type {
|
|
34
35
|
EntryValidation,
|
|
35
36
|
OpenBundleOptions,
|
|
36
37
|
SchemaBlock,
|
|
38
|
+
BundleManifest,
|
|
37
39
|
} from "@ipab/bundle";
|
|
38
40
|
import {
|
|
39
41
|
encodeBundleCar,
|
|
@@ -69,9 +71,8 @@ export interface InspectResult {
|
|
|
69
71
|
sourceKind: "directory" | "definition" | "car" | "cid";
|
|
70
72
|
cid: string | null;
|
|
71
73
|
schemaCid: string;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
entry: { path: string; contentType: string };
|
|
74
|
+
manifest?: BundleManifest;
|
|
75
|
+
type: SchemaBlock["type"];
|
|
75
76
|
validation: {
|
|
76
77
|
definition: "valid";
|
|
77
78
|
storage: "verified" | "not-applicable";
|
|
@@ -110,7 +111,7 @@ async function localFile(
|
|
|
110
111
|
return readBytes(tree, basename(path), maximum, options);
|
|
111
112
|
}
|
|
112
113
|
async function definitionAt(path: string, options: AuthoringOptions) {
|
|
113
|
-
return
|
|
114
|
+
return parseBundleType(
|
|
114
115
|
await localFile(path, bundleLimits.parsingBytes, options),
|
|
115
116
|
);
|
|
116
117
|
}
|
|
@@ -160,16 +161,23 @@ export async function selectedTree(
|
|
|
160
161
|
pathKey(path).startsWith(`${pathKey(outputDir)}/`)),
|
|
161
162
|
) ||
|
|
162
163
|
matcher.ignores(directory ? `${path}/` : path);
|
|
163
|
-
for (const required of [".bundle.yaml", definition.entry.
|
|
164
|
+
for (const required of [".bundle.yaml", definition.entry, definition.type])
|
|
164
165
|
if (excluded(required, false))
|
|
165
166
|
throw new HostError(
|
|
166
167
|
`Required bundle file is excluded: ${required}. Fix .bundle-ignore or choose an output outside the entry tree.`,
|
|
167
168
|
);
|
|
168
169
|
return filesystemTree(root, { exclude: excluded });
|
|
169
170
|
}
|
|
170
|
-
export async function readCar(
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
export async function readCar(
|
|
172
|
+
path: string,
|
|
173
|
+
options: AuthoringOptions,
|
|
174
|
+
directory = dirname(path),
|
|
175
|
+
) {
|
|
176
|
+
const tree = await filesystemTree(directory);
|
|
177
|
+
const input = await tree.read(
|
|
178
|
+
relative(directory, path).split(sep).join("/"),
|
|
179
|
+
options,
|
|
180
|
+
);
|
|
173
181
|
const chunks = streamChunks(input, options);
|
|
174
182
|
let bytes = 0;
|
|
175
183
|
try {
|
|
@@ -300,19 +308,18 @@ async function fromRoot(
|
|
|
300
308
|
});
|
|
301
309
|
return {
|
|
302
310
|
schema: bundle.schema,
|
|
311
|
+
manifest: bundle.manifest,
|
|
303
312
|
validation: bundle.validation,
|
|
304
313
|
kind: "content-bundle" as const,
|
|
305
314
|
sourceKind,
|
|
306
315
|
cid: root.toString(),
|
|
307
316
|
};
|
|
308
317
|
}
|
|
309
|
-
function summary(schema: SchemaBlock) {
|
|
310
|
-
const { name, description, entry } = schema.manifest;
|
|
318
|
+
function summary(schema: SchemaBlock, manifest?: BundleManifest) {
|
|
311
319
|
return {
|
|
312
320
|
schemaCid: schema.cid.toString(),
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
entry: { path: entry.path, contentType: entry.contentType },
|
|
321
|
+
type: schema.type,
|
|
322
|
+
...(manifest ? { manifest } : {}),
|
|
316
323
|
};
|
|
317
324
|
}
|
|
318
325
|
export async function inspectBundle(
|
|
@@ -335,7 +342,7 @@ export async function inspectBundle(
|
|
|
335
342
|
kind: "content-bundle",
|
|
336
343
|
sourceKind: "directory",
|
|
337
344
|
cid: null,
|
|
338
|
-
...summary(encoded.schema),
|
|
345
|
+
...summary(encoded.schema, encoded.manifest ?? undefined),
|
|
339
346
|
validation: {
|
|
340
347
|
definition: "valid",
|
|
341
348
|
storage: "verified",
|
|
@@ -351,7 +358,10 @@ export async function inspectBundle(
|
|
|
351
358
|
kind: loaded.kind,
|
|
352
359
|
sourceKind: loaded.sourceKind,
|
|
353
360
|
cid: loaded.cid,
|
|
354
|
-
...summary(
|
|
361
|
+
...summary(
|
|
362
|
+
loaded.schema,
|
|
363
|
+
"manifest" in loaded ? loaded.manifest : undefined,
|
|
364
|
+
),
|
|
355
365
|
validation: {
|
|
356
366
|
definition: "valid",
|
|
357
367
|
storage: loaded.kind === "content-bundle" ? "verified" : "not-applicable",
|
|
@@ -466,14 +476,28 @@ export async function buildBundle(
|
|
|
466
476
|
const output = options.output
|
|
467
477
|
? resolve(options.output)
|
|
468
478
|
: join(outputDirectory, options.schemaOnly ? "schema.car" : "bundle.car");
|
|
469
|
-
const
|
|
479
|
+
const manifestPath = join(root, ".bundle.yaml");
|
|
480
|
+
const manifest =
|
|
481
|
+
!options.schemaOnly || (await existing(manifestPath))
|
|
482
|
+
? parseBundleManifest(
|
|
483
|
+
await localFile(manifestPath, bundleLimits.manifestBytes, options),
|
|
484
|
+
)
|
|
485
|
+
: undefined;
|
|
486
|
+
const definitionPath = stat.isDirectory()
|
|
487
|
+
? join(root, manifest?.type ?? ".bundle-type.yaml")
|
|
488
|
+
: path;
|
|
470
489
|
const definition = await definitionAt(definitionPath, options);
|
|
471
490
|
if (
|
|
472
491
|
[
|
|
473
492
|
definitionPath,
|
|
474
493
|
join(root, ".bundle.yaml"),
|
|
475
494
|
join(root, ".bundle-ignore"),
|
|
476
|
-
|
|
495
|
+
...(manifest
|
|
496
|
+
? [
|
|
497
|
+
resolve(root, ...manifest.entry.split("/")),
|
|
498
|
+
resolve(root, ...manifest.type.split("/")),
|
|
499
|
+
]
|
|
500
|
+
: []),
|
|
477
501
|
].some((input) => pathKey(output) === pathKey(input))
|
|
478
502
|
)
|
|
479
503
|
throw new HostError(
|
package/src/builtins.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { builtinAppSchema } from "./app-definition.js";
|
|
2
2
|
import {
|
|
3
3
|
builtinTemplateSchema,
|
|
4
|
-
templateSchema,
|
|
5
4
|
templateSchemaCid,
|
|
6
5
|
} from "./template-definition.js";
|
|
7
6
|
import { builtinTemplateNames } from "./app-templates.js";
|
|
8
7
|
import { builtinTemplateSource } from "./template-source.js";
|
|
8
|
+
import { openBundle } from "@ipab/bundle";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { readCar } from "./authoring.js";
|
|
9
11
|
import type { NamedPin, PinMetadata } from "./state.js";
|
|
10
12
|
|
|
11
13
|
async function loadBuiltins(): Promise<{
|
|
@@ -36,10 +38,29 @@ async function loadBuiltins(): Promise<{
|
|
|
36
38
|
for (const [cid, bytes] of template.blocks) blocks.set(cid, bytes);
|
|
37
39
|
add(name, template.cid, {
|
|
38
40
|
kind: "bundle",
|
|
39
|
-
|
|
41
|
+
title: template.manifest.title,
|
|
40
42
|
schemaCid: templateSchemaCid.toString(),
|
|
41
43
|
});
|
|
42
44
|
}
|
|
45
|
+
const skill = await readCar(
|
|
46
|
+
fileURLToPath(new URL("../dist/builtins/skill.ipab.car", import.meta.url)),
|
|
47
|
+
{},
|
|
48
|
+
);
|
|
49
|
+
const bundle = await openBundle(skill.root, { resolveCid: skill.resolveCid });
|
|
50
|
+
if (
|
|
51
|
+
bundle.manifest.entry !== "SKILL.md" ||
|
|
52
|
+
bundle.schema.type.contentType !== "text/markdown" ||
|
|
53
|
+
bundle.validation.status !== "validated"
|
|
54
|
+
)
|
|
55
|
+
throw new Error(
|
|
56
|
+
"Built-in IPAB Skill must be a validated Markdown Skill Bundle.",
|
|
57
|
+
);
|
|
58
|
+
for (const [cid, bytes] of skill.blocks) blocks.set(cid, bytes);
|
|
59
|
+
add("builtin:skill.ipab", skill.root.toString(), {
|
|
60
|
+
kind: "bundle",
|
|
61
|
+
title: bundle.manifest.title,
|
|
62
|
+
schemaCid: bundle.schemaKey,
|
|
63
|
+
});
|
|
43
64
|
return { pins, blocks };
|
|
44
65
|
}
|
|
45
66
|
|