@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.
Files changed (116) hide show
  1. package/README.md +43 -6
  2. package/dist/app-authoring.d.ts +10 -0
  3. package/dist/app-authoring.d.ts.map +1 -1
  4. package/dist/app-authoring.js +138 -13
  5. package/dist/app-authoring.js.map +1 -1
  6. package/dist/app-definition.d.ts +52 -57
  7. package/dist/app-definition.d.ts.map +1 -1
  8. package/dist/app-definition.js +33 -38
  9. package/dist/app-definition.js.map +1 -1
  10. package/dist/app-templates.d.ts.map +1 -1
  11. package/dist/app-templates.js +2 -1
  12. package/dist/app-templates.js.map +1 -1
  13. package/dist/assembly.d.ts +7 -0
  14. package/dist/assembly.d.ts.map +1 -0
  15. package/dist/assembly.js +130 -0
  16. package/dist/assembly.js.map +1 -0
  17. package/dist/authoring.d.ts +4 -8
  18. package/dist/authoring.d.ts.map +1 -1
  19. package/dist/authoring.js +25 -15
  20. package/dist/authoring.js.map +1 -1
  21. package/dist/builtins/skill.ipab.car +0 -0
  22. package/dist/builtins/template.node.car +0 -0
  23. package/dist/builtins/template.web-app.car +0 -0
  24. package/dist/builtins.d.ts.map +1 -1
  25. package/dist/builtins.js +18 -2
  26. package/dist/builtins.js.map +1 -1
  27. package/dist/cli.d.ts +1 -0
  28. package/dist/cli.d.ts.map +1 -1
  29. package/dist/cli.js +720 -76
  30. package/dist/cli.js.map +1 -1
  31. package/dist/config-secret.d.ts +3 -0
  32. package/dist/config-secret.d.ts.map +1 -0
  33. package/dist/config-secret.js +83 -0
  34. package/dist/config-secret.js.map +1 -0
  35. package/dist/config.d.ts +6 -2
  36. package/dist/config.d.ts.map +1 -1
  37. package/dist/config.js +109 -7
  38. package/dist/config.js.map +1 -1
  39. package/dist/content-provider.d.ts +9 -0
  40. package/dist/content-provider.d.ts.map +1 -0
  41. package/dist/content-provider.js +93 -0
  42. package/dist/content-provider.js.map +1 -0
  43. package/dist/get.d.ts +3 -0
  44. package/dist/get.d.ts.map +1 -0
  45. package/dist/get.js +80 -0
  46. package/dist/get.js.map +1 -0
  47. package/dist/identity.d.ts +9 -0
  48. package/dist/identity.d.ts.map +1 -0
  49. package/dist/identity.js +89 -0
  50. package/dist/identity.js.map +1 -0
  51. package/dist/kubo.d.ts +38 -0
  52. package/dist/kubo.d.ts.map +1 -0
  53. package/dist/kubo.js +528 -0
  54. package/dist/kubo.js.map +1 -0
  55. package/dist/pins.d.ts +3 -3
  56. package/dist/pins.js +1 -1
  57. package/dist/pins.js.map +1 -1
  58. package/dist/setup.d.ts +7 -0
  59. package/dist/setup.d.ts.map +1 -0
  60. package/dist/setup.js +22 -0
  61. package/dist/setup.js.map +1 -0
  62. package/dist/source-bundle.d.ts +3 -8
  63. package/dist/source-bundle.d.ts.map +1 -1
  64. package/dist/source-bundle.js +17 -12
  65. package/dist/source-bundle.js.map +1 -1
  66. package/dist/space.d.ts.map +1 -1
  67. package/dist/space.js +2 -2
  68. package/dist/space.js.map +1 -1
  69. package/dist/state.d.ts +19 -4
  70. package/dist/state.d.ts.map +1 -1
  71. package/dist/state.js +105 -7
  72. package/dist/state.js.map +1 -1
  73. package/dist/swarm-envelope.d.ts +36 -0
  74. package/dist/swarm-envelope.d.ts.map +1 -0
  75. package/dist/swarm-envelope.js +145 -0
  76. package/dist/swarm-envelope.js.map +1 -0
  77. package/dist/swarm-files.d.ts +5 -0
  78. package/dist/swarm-files.d.ts.map +1 -0
  79. package/dist/swarm-files.js +94 -0
  80. package/dist/swarm-files.js.map +1 -0
  81. package/dist/swarm.d.ts +173 -0
  82. package/dist/swarm.d.ts.map +1 -0
  83. package/dist/swarm.js +1245 -0
  84. package/dist/swarm.js.map +1 -0
  85. package/dist/template-definition.d.ts +47 -52
  86. package/dist/template-definition.d.ts.map +1 -1
  87. package/dist/template-definition.js +36 -41
  88. package/dist/template-definition.js.map +1 -1
  89. package/dist/template-source.d.ts +2 -0
  90. package/dist/template-source.d.ts.map +1 -1
  91. package/dist/template-source.js +4 -3
  92. package/dist/template-source.js.map +1 -1
  93. package/package.json +10 -5
  94. package/src/app-authoring.ts +210 -21
  95. package/src/app-definition.ts +33 -39
  96. package/src/app-templates.ts +9 -1
  97. package/src/assembly.ts +185 -0
  98. package/src/authoring.ts +41 -17
  99. package/src/builtins.ts +23 -2
  100. package/src/cli.ts +875 -79
  101. package/src/config-secret.ts +96 -0
  102. package/src/config.ts +146 -7
  103. package/src/content-provider.ts +124 -0
  104. package/src/get.ts +90 -0
  105. package/src/identity.ts +133 -0
  106. package/src/kubo.ts +691 -0
  107. package/src/pins.ts +1 -1
  108. package/src/setup.ts +21 -0
  109. package/src/source-bundle.ts +26 -13
  110. package/src/space.ts +2 -5
  111. package/src/state.ts +121 -9
  112. package/src/swarm-envelope.ts +255 -0
  113. package/src/swarm-files.ts +100 -0
  114. package/src/swarm.ts +2025 -0
  115. package/src/template-definition.ts +36 -41
  116. 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
- 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,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.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.`,
167
168
  );
168
169
  return filesystemTree(root, { exclude: excluded });
169
170
  }
170
- export async function readCar(path: string, options: AuthoringOptions) {
171
- const tree = await filesystemTree(dirname(path));
172
- const input = await tree.read(basename(path), options);
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
- name,
314
- description,
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(loaded.schema),
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 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;
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
- resolve(root, ...definition.entry.path.split("/")),
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
- 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