@ipab/cli 0.1.0-rc.2 → 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.
Files changed (102) hide show
  1. package/README.md +35 -14
  2. package/dist/app-authoring.d.ts.map +1 -1
  3. package/dist/app-authoring.js +11 -2
  4. package/dist/app-authoring.js.map +1 -1
  5. package/dist/app-definition.d.ts +52 -57
  6. package/dist/app-definition.d.ts.map +1 -1
  7. package/dist/app-definition.js +33 -38
  8. package/dist/app-definition.js.map +1 -1
  9. package/dist/app-templates.d.ts.map +1 -1
  10. package/dist/app-templates.js +2 -1
  11. package/dist/app-templates.js.map +1 -1
  12. package/dist/assembly.d.ts.map +1 -1
  13. package/dist/assembly.js +3 -4
  14. package/dist/assembly.js.map +1 -1
  15. package/dist/authoring.d.ts +3 -7
  16. package/dist/authoring.d.ts.map +1 -1
  17. package/dist/authoring.js +22 -12
  18. package/dist/authoring.js.map +1 -1
  19. package/dist/builtins/skill.ipab.car +0 -0
  20. package/dist/builtins/template.node.car +0 -0
  21. package/dist/builtins/template.web-app.car +0 -0
  22. package/dist/builtins.d.ts.map +1 -1
  23. package/dist/builtins.js +18 -2
  24. package/dist/builtins.js.map +1 -1
  25. package/dist/cli.d.ts.map +1 -1
  26. package/dist/cli.js +306 -116
  27. package/dist/cli.js.map +1 -1
  28. package/dist/config.d.ts +2 -1
  29. package/dist/config.d.ts.map +1 -1
  30. package/dist/config.js +19 -15
  31. package/dist/config.js.map +1 -1
  32. package/dist/content-provider.d.ts +1 -1
  33. package/dist/content-provider.d.ts.map +1 -1
  34. package/dist/content-provider.js +5 -2
  35. package/dist/content-provider.js.map +1 -1
  36. package/dist/get.d.ts.map +1 -1
  37. package/dist/get.js +34 -15
  38. package/dist/get.js.map +1 -1
  39. package/dist/kubo.d.ts +38 -0
  40. package/dist/kubo.d.ts.map +1 -0
  41. package/dist/kubo.js +528 -0
  42. package/dist/kubo.js.map +1 -0
  43. package/dist/pins.d.ts +3 -3
  44. package/dist/pins.js +1 -1
  45. package/dist/pins.js.map +1 -1
  46. package/dist/setup.d.ts +7 -0
  47. package/dist/setup.d.ts.map +1 -0
  48. package/dist/setup.js +22 -0
  49. package/dist/setup.js.map +1 -0
  50. package/dist/source-bundle.d.ts +3 -8
  51. package/dist/source-bundle.d.ts.map +1 -1
  52. package/dist/source-bundle.js +16 -11
  53. package/dist/source-bundle.js.map +1 -1
  54. package/dist/space.d.ts.map +1 -1
  55. package/dist/space.js +2 -2
  56. package/dist/space.js.map +1 -1
  57. package/dist/state.d.ts +4 -4
  58. package/dist/state.d.ts.map +1 -1
  59. package/dist/state.js +11 -12
  60. package/dist/state.js.map +1 -1
  61. package/dist/swarm-envelope.d.ts +36 -0
  62. package/dist/swarm-envelope.d.ts.map +1 -0
  63. package/dist/swarm-envelope.js +145 -0
  64. package/dist/swarm-envelope.js.map +1 -0
  65. package/dist/swarm-files.d.ts +5 -0
  66. package/dist/swarm-files.d.ts.map +1 -0
  67. package/dist/swarm-files.js +94 -0
  68. package/dist/swarm-files.js.map +1 -0
  69. package/dist/swarm.d.ts +117 -57
  70. package/dist/swarm.d.ts.map +1 -1
  71. package/dist/swarm.js +1033 -548
  72. package/dist/swarm.js.map +1 -1
  73. package/dist/template-definition.d.ts +47 -52
  74. package/dist/template-definition.d.ts.map +1 -1
  75. package/dist/template-definition.js +36 -41
  76. package/dist/template-definition.js.map +1 -1
  77. package/dist/template-source.d.ts +2 -0
  78. package/dist/template-source.d.ts.map +1 -1
  79. package/dist/template-source.js +4 -3
  80. package/dist/template-source.js.map +1 -1
  81. package/package.json +3 -3
  82. package/src/app-authoring.ts +22 -5
  83. package/src/app-definition.ts +33 -39
  84. package/src/app-templates.ts +9 -1
  85. package/src/assembly.ts +7 -4
  86. package/src/authoring.ts +31 -14
  87. package/src/builtins.ts +23 -2
  88. package/src/cli.ts +362 -139
  89. package/src/config.ts +22 -18
  90. package/src/content-provider.ts +5 -4
  91. package/src/get.ts +37 -15
  92. package/src/kubo.ts +691 -0
  93. package/src/pins.ts +1 -1
  94. package/src/setup.ts +21 -0
  95. package/src/source-bundle.ts +25 -12
  96. package/src/space.ts +2 -5
  97. package/src/state.ts +14 -13
  98. package/src/swarm-envelope.ts +255 -0
  99. package/src/swarm-files.ts +100 -0
  100. package/src/swarm.ts +1676 -837
  101. package/src/template-definition.ts +36 -41
  102. package/src/template-source.ts +10 -3
@@ -8,46 +8,40 @@ import {
8
8
 
9
9
  export const appBuiltinAlias = "builtin:node-app.v1";
10
10
  export const appSchema = {
11
- name: "IPAB Node App",
12
- description:
13
- "Self-contained Node CommonJS application and declarative metadata.",
14
- entry: {
15
- path: "app.json",
16
- contentType: "application/json",
17
- schema: {
18
- $id: "urn:ipab:node-app.v1",
19
- type: "object",
20
- additionalProperties: false,
21
- required: ["name", "version", "entry"],
22
- properties: {
23
- name: { type: "string" },
24
- version: { type: "string" },
25
- description: { type: "string" },
26
- entry: { type: "string" },
27
- source: {
28
- type: "object",
29
- additionalProperties: false,
30
- required: ["cid"],
31
- properties: { cid: { type: "string" } },
32
- },
33
- supportedSchemas: { type: "string" },
34
- author: {
11
+ contentType: "application/json",
12
+ schema: {
13
+ $id: "urn:ipab:node-app.v1",
14
+ type: "object",
15
+ additionalProperties: false,
16
+ required: ["name", "version", "entry"],
17
+ properties: {
18
+ name: { type: "string" },
19
+ version: { type: "string" },
20
+ description: { type: "string" },
21
+ entry: { type: "string" },
22
+ source: {
23
+ type: "object",
24
+ additionalProperties: false,
25
+ required: ["cid"],
26
+ properties: { cid: { type: "string" } },
27
+ },
28
+ supportedSchemas: { type: "string" },
29
+ author: {
30
+ type: "object",
31
+ additionalProperties: false,
32
+ required: ["name"],
33
+ properties: { name: { type: "string" }, email: { type: "string" } },
34
+ },
35
+ license: { type: "string" },
36
+ icon: { type: "string" },
37
+ i18n: {
38
+ type: "object",
39
+ additionalProperties: {
35
40
  type: "object",
36
41
  additionalProperties: false,
37
- required: ["name"],
38
- properties: { name: { type: "string" }, email: { type: "string" } },
39
- },
40
- license: { type: "string" },
41
- icon: { type: "string" },
42
- i18n: {
43
- type: "object",
44
- additionalProperties: {
45
- type: "object",
46
- additionalProperties: false,
47
- properties: {
48
- name: { type: "string" },
49
- description: { type: "string" },
50
- },
42
+ properties: {
43
+ name: { type: "string" },
44
+ description: { type: "string" },
51
45
  },
52
46
  },
53
47
  },
@@ -57,7 +51,7 @@ export const appSchema = {
57
51
 
58
52
  // This is the canonical full definition, not a separate identity for the alias.
59
53
  export const appSchemaCid = CID.parse(
60
- "bafyreid3qonq3i2rjekgz7mtarpu4zbfmgg4uhtcjtpijdgrrhdke5opzq",
54
+ "bafyreifualoac4ddlzl63jlfstz4xsq75cai5t6ywu3j3khhyukoccmybm",
61
55
  );
62
56
  export const builtinTypes: ReadonlyMap<string, string> = new Map([
63
57
  [appBuiltinAlias, appSchemaCid.toString()],
@@ -2,6 +2,7 @@ import { fileURLToPath } from "node:url";
2
2
  import { resolve } from "node:path";
3
3
  import { lstat, readFile } from "node:fs/promises";
4
4
  import { Liquid, type Template } from "liquidjs";
5
+ import { parseBundleManifest } from "@ipab/bundle";
5
6
  import {
6
7
  listTree,
7
8
  readBytes,
@@ -248,7 +249,14 @@ export async function renderTemplate(
248
249
  options: AuthoringOptions & { parameters?: readonly string[] },
249
250
  ) {
250
251
  const definition = templateDefinition(
251
- await readBytes(tree, "template.yaml", 64 * 1024, options),
252
+ await readBytes(
253
+ tree,
254
+ parseBundleManifest(
255
+ await readBytes(tree, ".bundle.yaml", 1024 * 1024, options),
256
+ ).entry,
257
+ 64 * 1024,
258
+ options,
259
+ ),
252
260
  );
253
261
  const values = templateParameters(definition, name, options.parameters);
254
262
  const files = new Map<string, string | Uint8Array>();
package/src/assembly.ts CHANGED
@@ -154,14 +154,17 @@ export async function assembleBundle(
154
154
  },
155
155
  );
156
156
  if (
157
- !files.has(definition.entry.path) &&
158
- !imports.some((item) => item.path === definition.entry.path)
157
+ [definition.entry, definition.type].some(
158
+ (path) => !files.has(path) && !imports.some((item) => item.path === path),
159
+ )
159
160
  )
160
- throw new HostError("Recipe must explicitly select the Bundle entry.");
161
+ throw new HostError(
162
+ "Recipe must explicitly select the Bundle entry and type files.",
163
+ );
161
164
  const output = options.output
162
165
  ? resolve(options.output)
163
166
  : join(root, options.outputDir ?? "dist", "bundle.car");
164
- if (inputs.has(output))
167
+ if ([...inputs].some((input) => input.toLowerCase() === output.toLowerCase()))
165
168
  throw new HostError("CAR output cannot replace recipe or source inputs.");
166
169
  await outputAvailable(output, Boolean(options.replace));
167
170
  const encoded = await encodeBundleCar(fileTree(files), {
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
- name: string;
73
- description: string;
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 parseBundleManifest(
114
+ return parseBundleType(
114
115
  await localFile(path, bundleLimits.parsingBytes, options),
115
116
  );
116
117
  }
@@ -160,7 +161,7 @@ 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.path])
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.`,
@@ -307,19 +308,18 @@ async function fromRoot(
307
308
  });
308
309
  return {
309
310
  schema: bundle.schema,
311
+ manifest: bundle.manifest,
310
312
  validation: bundle.validation,
311
313
  kind: "content-bundle" as const,
312
314
  sourceKind,
313
315
  cid: root.toString(),
314
316
  };
315
317
  }
316
- function summary(schema: SchemaBlock) {
317
- const { name, description, entry } = schema.manifest;
318
+ function summary(schema: SchemaBlock, manifest?: BundleManifest) {
318
319
  return {
319
320
  schemaCid: schema.cid.toString(),
320
- name,
321
- description,
322
- entry: { path: entry.path, contentType: entry.contentType },
321
+ type: schema.type,
322
+ ...(manifest ? { manifest } : {}),
323
323
  };
324
324
  }
325
325
  export async function inspectBundle(
@@ -342,7 +342,7 @@ export async function inspectBundle(
342
342
  kind: "content-bundle",
343
343
  sourceKind: "directory",
344
344
  cid: null,
345
- ...summary(encoded.schema),
345
+ ...summary(encoded.schema, encoded.manifest ?? undefined),
346
346
  validation: {
347
347
  definition: "valid",
348
348
  storage: "verified",
@@ -358,7 +358,10 @@ export async function inspectBundle(
358
358
  kind: loaded.kind,
359
359
  sourceKind: loaded.sourceKind,
360
360
  cid: loaded.cid,
361
- ...summary(loaded.schema),
361
+ ...summary(
362
+ loaded.schema,
363
+ "manifest" in loaded ? loaded.manifest : undefined,
364
+ ),
362
365
  validation: {
363
366
  definition: "valid",
364
367
  storage: loaded.kind === "content-bundle" ? "verified" : "not-applicable",
@@ -473,14 +476,28 @@ export async function buildBundle(
473
476
  const output = options.output
474
477
  ? resolve(options.output)
475
478
  : join(outputDirectory, options.schemaOnly ? "schema.car" : "bundle.car");
476
- const definitionPath = stat.isDirectory() ? join(root, ".bundle.yaml") : path;
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;
477
489
  const definition = await definitionAt(definitionPath, options);
478
490
  if (
479
491
  [
480
492
  definitionPath,
481
493
  join(root, ".bundle.yaml"),
482
494
  join(root, ".bundle-ignore"),
483
- resolve(root, ...definition.entry.path.split("/")),
495
+ ...(manifest
496
+ ? [
497
+ resolve(root, ...manifest.entry.split("/")),
498
+ resolve(root, ...manifest.type.split("/")),
499
+ ]
500
+ : []),
484
501
  ].some((input) => pathKey(output) === pathKey(input))
485
502
  )
486
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
- typeName: templateSchema.name,
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