@ipab/cli 0.1.0-rc.6 → 0.1.0-rc.7

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 (97) hide show
  1. package/README.md +72 -33
  2. package/dist/app-authoring.d.ts +5 -0
  3. package/dist/app-authoring.d.ts.map +1 -1
  4. package/dist/app-authoring.js +4 -1
  5. package/dist/app-authoring.js.map +1 -1
  6. package/dist/app-templates.d.ts +0 -1
  7. package/dist/app-templates.d.ts.map +1 -1
  8. package/dist/app-templates.js +6 -45
  9. package/dist/app-templates.js.map +1 -1
  10. package/dist/builtins/skill.ipab.car +0 -0
  11. package/dist/builtins/template.bundle-viewer.car +0 -0
  12. package/dist/builtins/template.check.car +0 -0
  13. package/dist/builtins/template.node.car +0 -0
  14. package/dist/builtins/template.web-app.car +0 -0
  15. package/dist/builtins.d.ts.map +1 -1
  16. package/dist/builtins.js +1 -39
  17. package/dist/builtins.js.map +1 -1
  18. package/dist/cli.d.ts +1 -0
  19. package/dist/cli.d.ts.map +1 -1
  20. package/dist/cli.js +395 -86
  21. package/dist/cli.js.map +1 -1
  22. package/dist/context.d.ts +16 -0
  23. package/dist/context.d.ts.map +1 -1
  24. package/dist/context.js +20 -0
  25. package/dist/context.js.map +1 -1
  26. package/dist/ipc.d.ts +2 -1
  27. package/dist/ipc.d.ts.map +1 -1
  28. package/dist/ipc.js +44 -3
  29. package/dist/ipc.js.map +1 -1
  30. package/dist/runtime.d.ts.map +1 -1
  31. package/dist/runtime.js +6 -3
  32. package/dist/runtime.js.map +1 -1
  33. package/dist/skill-definition.d.ts +6 -0
  34. package/dist/skill-definition.d.ts.map +1 -0
  35. package/dist/skill-definition.js +38 -0
  36. package/dist/skill-definition.js.map +1 -0
  37. package/dist/skill-source.d.ts +5 -0
  38. package/dist/skill-source.d.ts.map +1 -0
  39. package/dist/skill-source.js +12 -0
  40. package/dist/skill-source.js.map +1 -0
  41. package/dist/skills.d.ts +84 -0
  42. package/dist/skills.d.ts.map +1 -0
  43. package/dist/skills.js +736 -0
  44. package/dist/skills.js.map +1 -0
  45. package/dist/space.d.ts +15 -2
  46. package/dist/space.d.ts.map +1 -1
  47. package/dist/space.js +153 -3
  48. package/dist/space.js.map +1 -1
  49. package/dist/state.js +1 -1
  50. package/dist/swarm-files.d.ts +1 -1
  51. package/dist/swarm-files.d.ts.map +1 -1
  52. package/dist/swarm-files.js +2 -2
  53. package/dist/swarm-files.js.map +1 -1
  54. package/dist/swarm-meta.d.ts +17 -0
  55. package/dist/swarm-meta.d.ts.map +1 -0
  56. package/dist/swarm-meta.js +96 -0
  57. package/dist/swarm-meta.js.map +1 -0
  58. package/dist/swarm.d.ts +53 -0
  59. package/dist/swarm.d.ts.map +1 -1
  60. package/dist/swarm.js +465 -73
  61. package/dist/swarm.js.map +1 -1
  62. package/dist/template-paths.d.ts +7 -0
  63. package/dist/template-paths.d.ts.map +1 -0
  64. package/dist/template-paths.js +23 -0
  65. package/dist/template-paths.js.map +1 -0
  66. package/dist/template-presentation.d.ts +20 -0
  67. package/dist/template-presentation.d.ts.map +1 -0
  68. package/dist/template-presentation.js +133 -0
  69. package/dist/template-presentation.js.map +1 -0
  70. package/dist/template-source.d.ts +2 -1
  71. package/dist/template-source.d.ts.map +1 -1
  72. package/dist/template-source.js +7 -1
  73. package/dist/template-source.js.map +1 -1
  74. package/dist/templates.d.ts +11 -0
  75. package/dist/templates.d.ts.map +1 -0
  76. package/dist/templates.js +53 -0
  77. package/dist/templates.js.map +1 -0
  78. package/package.json +7 -6
  79. package/src/app-authoring.ts +18 -2
  80. package/src/app-templates.ts +8 -72
  81. package/src/builtins.ts +2 -48
  82. package/src/cli.ts +474 -71
  83. package/src/context.ts +45 -0
  84. package/src/ipc.ts +63 -2
  85. package/src/runtime.ts +6 -2
  86. package/src/skill-definition.ts +53 -0
  87. package/src/skill-source.ts +15 -0
  88. package/src/skills.ts +1005 -0
  89. package/src/space.ts +214 -5
  90. package/src/state.ts +1 -1
  91. package/src/swarm-files.ts +2 -1
  92. package/src/swarm-meta.ts +109 -0
  93. package/src/swarm.ts +721 -128
  94. package/src/template-paths.ts +43 -0
  95. package/src/template-presentation.ts +151 -0
  96. package/src/template-source.ts +9 -2
  97. package/src/templates.ts +77 -0
@@ -0,0 +1,133 @@
1
+ import { listTree, } from "@ipab/bundle-builder";
2
+ import { bundleLimits, ContentBundleError } from "@ipab/bundle";
3
+ import { addTemplateOutputPath, templateOutputPath } from "./template-paths.js";
4
+ import { templateSource } from "./template-source.js";
5
+ class PreviewLimit extends Error {
6
+ }
7
+ function previewLimit(cause) {
8
+ for (let depth = 0; depth < 16 && cause instanceof Error; depth++) {
9
+ if (cause instanceof PreviewLimit)
10
+ return cause;
11
+ cause = cause.cause;
12
+ }
13
+ return undefined;
14
+ }
15
+ export async function projectOutputTree(tree) {
16
+ const entries = [];
17
+ const paths = new Map();
18
+ let pathBytes = 0;
19
+ const collect = async (directory, depth) => {
20
+ if (depth >= 8)
21
+ throw new PreviewLimit("depth limit (8)");
22
+ for (const entry of await listTree(tree, directory)) {
23
+ if (entries.length >= 64)
24
+ throw new PreviewLimit("entry limit (64)");
25
+ const source = `${directory}/${entry.name}`;
26
+ const { target } = templateOutputPath(source, entry.kind);
27
+ pathBytes += Buffer.byteLength(target);
28
+ if (pathBytes > 16 * 1024)
29
+ throw new PreviewLimit("path byte limit (16 KiB)");
30
+ addTemplateOutputPath(paths, target, entry.kind);
31
+ entries.push({ path: target, kind: entry.kind });
32
+ if (entry.kind === "directory")
33
+ await collect(source, depth + 1);
34
+ }
35
+ };
36
+ let truncated;
37
+ try {
38
+ await collect("project", 0);
39
+ }
40
+ catch (cause) {
41
+ const limit = previewLimit(cause);
42
+ if (!limit)
43
+ throw cause;
44
+ truncated = limit.message;
45
+ }
46
+ return { entries, truncated };
47
+ }
48
+ export async function templateOutputTree(store, cid) {
49
+ let reads = 0, bytes = 0;
50
+ try {
51
+ const source = await templateSource(cid, {
52
+ async resolveCid(key, options) {
53
+ if (++reads > 512)
54
+ throw new PreviewLimit("content read limit (512)");
55
+ const block = await store.block.get(key.toString(), options);
56
+ if (block.byteLength > bundleLimits.blockBytes)
57
+ throw new ContentBundleError("LIMIT_EXCEEDED", "Template source exceeds the Bundle block byte limit.");
58
+ bytes += block.byteLength;
59
+ if (bytes > 2 * 1024 * 1024)
60
+ throw new PreviewLimit("content byte limit (2 MiB)");
61
+ return block;
62
+ },
63
+ });
64
+ return await projectOutputTree(source.tree);
65
+ }
66
+ catch (cause) {
67
+ const limit = previewLimit(cause);
68
+ if (!limit)
69
+ throw cause;
70
+ return { entries: [], truncated: limit.message };
71
+ }
72
+ }
73
+ function hasDefault(parameter) {
74
+ return Object.hasOwn(parameter, "default");
75
+ }
76
+ export function templateParameterRows(definition) {
77
+ const names = Object.keys(definition.parameters).sort();
78
+ const ordered = [
79
+ "name",
80
+ "description",
81
+ ...names.filter((name) => name !== "name" && name !== "description"),
82
+ ];
83
+ return ordered
84
+ .filter((name) => Object.hasOwn(definition.parameters, name))
85
+ .map((name) => {
86
+ const parameter = definition.parameters[name];
87
+ return [
88
+ name,
89
+ parameter.type,
90
+ parameter.required && !hasDefault(parameter) ? "yes" : "no",
91
+ hasDefault(parameter) ? JSON.stringify(parameter.default) : "-",
92
+ name === "name"
93
+ ? "NAME positional"
94
+ : name === "description"
95
+ ? "--description TEXT"
96
+ : `--param ${name}=VALUE`,
97
+ ];
98
+ });
99
+ }
100
+ export function templateRenderExample(selector, swarm, definition, shell) {
101
+ const quote = (value) => {
102
+ // Shell controls cannot safely be embedded in a copyable, single-line example.
103
+ const safe = [...value].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127);
104
+ if (safe)
105
+ throw new Error("Cannot produce a render example containing control characters.");
106
+ return shell === "powershell"
107
+ ? `'${value.replaceAll("'", "''")}'`
108
+ : `'${value.replaceAll("'", "'\\''")}'`;
109
+ };
110
+ const args = [
111
+ "ipab",
112
+ "--swarm",
113
+ quote(swarm),
114
+ "templates",
115
+ "render",
116
+ quote(selector),
117
+ quote("my-project"),
118
+ ];
119
+ for (const name of Object.keys(definition.parameters).sort()) {
120
+ const parameter = definition.parameters[name];
121
+ if (name === "name" || !parameter.required || hasDefault(parameter))
122
+ continue;
123
+ const example = {
124
+ string: "VALUE",
125
+ number: "0",
126
+ boolean: "true",
127
+ json: "null",
128
+ }[parameter.type];
129
+ args.push("--param", quote(`${name}=${example}`));
130
+ }
131
+ return args.join(" ");
132
+ }
133
+ //# sourceMappingURL=template-presentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-presentation.js","sourceRoot":"","sources":["../src/template-presentation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,GAGT,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAKhE,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,YAAa,SAAQ,KAAK;CAAG;AAEnC,SAAS,YAAY,CAAC,KAAc;IAClC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,IAAI,KAAK,YAAY,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QAClE,IAAI,KAAK,YAAY,YAAY;YAAE,OAAO,KAAK,CAAC;QAChD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAsB;IAC5D,MAAM,OAAO,GAAgD,EAAE,CAAC;IAChE,MAAM,KAAK,GAAG,IAAI,GAAG,EAA6B,CAAC;IACnD,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,MAAM,OAAO,GAAG,KAAK,EAAE,SAAiB,EAAE,KAAa,EAAiB,EAAE;QACxE,IAAI,KAAK,IAAI,CAAC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le-builder";
2
2
  import { type AuthoringOptions } from "./authoring.js";
3
- export declare function builtinTemplateSource(selector: "node" | "web-app", options?: AuthoringOptions): Promise<{
3
+ export declare const seedTemplateNames: readonly ["node", "web-app", "check", "bundle-viewer"];
4
+ export declare function seedTemplateSource(selector: (typeof seedTemplateNames)[number], options?: AuthoringOptions): Promise<{
4
5
  blocks: Map<string, Uint8Array<ArrayBufferLike>>;
5
6
  tree: ReadonlyFileTree;
6
7
  cid: string;
@@ -1 +1 @@
1
- {"version":3,"file":"template-source.d.ts","sourceRoot":"","sources":["../src/template-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAI9E,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,GAAE,gBAAqB;;;;;GAa/B;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB;;;;GAoG1B"}
1
+ {"version":3,"file":"template-source.d.ts","sourceRoot":"","sources":["../src/template-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAI9E,eAAO,MAAM,iBAAiB,wDAKpB,CAAC;AAEX,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,EAC5C,OAAO,GAAE,gBAAqB;;;;;GAa/B;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB;;;;GAoG1B"}
@@ -8,7 +8,13 @@ import { openContent } from "@ipab/ipfs-store";
8
8
  import { readCar, selectedTree } from "./authoring.js";
9
9
  import { HostError } from "./errors.js";
10
10
  import { builtinTemplateSchema } from "./template-definition.js";
11
- export async function builtinTemplateSource(selector, options = {}) {
11
+ export const seedTemplateNames = [
12
+ "node",
13
+ "web-app",
14
+ "check",
15
+ "bundle-viewer",
16
+ ];
17
+ export async function seedTemplateSource(selector, options = {}) {
12
18
  const car = await readCar(fileURLToPath(new URL(`../dist/builtins/template.${selector}.car`, import.meta.url)), options);
13
19
  const source = await templateSource(car.root.toString(), {
14
20
  ...options,
@@ -1 +1 @@
1
- {"version":3,"file":"template-source.js","sourceRoot":"","sources":["../src/template-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EACL,eAAe,EACf,SAAS,GAEV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAyB,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,QAA4B,EAC5B,UAA4B,EAAE;IAE9B,MAAM,GAAG,GAAG,MAAM,OAAO,CACvB,aAAa,CACX,IAAI,GAAG,CAAC,6BAA6B,QAAQ,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CACtE,EACD,OAAO,CACR,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE;QACvD,GA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11 @@
1
+ import type { IpfsStore } from "@ipab/ipfs-store";
2
+ export declare function inspectTemplate(store: IpfsStore, cid: string): Promise<{
3
+ templateCid: string;
4
+ typeCid: string;
5
+ title: string;
6
+ description: string;
7
+ definition: import("./template-definition.js").TemplateDefinition;
8
+ parameters: Record<string, import("./template-definition.js").TemplateParameter>;
9
+ }>;
10
+ export declare function templatePublicationSource(input: string, store: IpfsStore): Promise<string>;
11
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AASlD,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM;;;;;;;GAsBlE;AAED,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,mBAqCjB"}
@@ -0,0 +1,53 @@
1
+ import { lstat } from "node:fs/promises";
2
+ import { resolve } from "node:path";
3
+ import { CID } from "multiformats/cid";
4
+ import { bundleLimits, openBundle } from "@ipab/bundle";
5
+ import { HostError } from "./errors.js";
6
+ import { publicationSource } from "./publish-source.js";
7
+ import { bytes } from "./space.js";
8
+ import { templateDefinition, templateSchemaCid, } from "./template-definition.js";
9
+ export async function inspectTemplate(store, cid) {
10
+ const bundle = await openBundle(CID.parse(cid), {
11
+ resolveCid: (key) => store.block.get(key.toString()),
12
+ });
13
+ if (bundle.schemaKey !== templateSchemaCid.toString())
14
+ throw new HostError("Template Bundle must use the exact project-template type CID.");
15
+ const definition = templateDefinition(await bytes(await bundle.readFile(bundle.manifest.entry), bundleLimits.parsingBytes));
16
+ return {
17
+ templateCid: bundle.cid.toString(),
18
+ typeCid: bundle.schemaKey,
19
+ title: bundle.manifest.title,
20
+ description: bundle.manifest.description,
21
+ definition,
22
+ parameters: definition.parameters,
23
+ };
24
+ }
25
+ export async function templatePublicationSource(input, store) {
26
+ let cid;
27
+ try {
28
+ cid = CID.parse(input);
29
+ }
30
+ catch {
31
+ // Only explicit local Template Bundles are accepted besides exact CIDs.
32
+ }
33
+ if (!cid) {
34
+ if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(input) &&
35
+ !/^[A-Za-z]:[\\/]/.test(input))
36
+ throw new HostError("Template SOURCE does not accept URIs; use an exact CID, self-contained CAR or explicit Template Bundle directory.");
37
+ const path = resolve(input);
38
+ const stat = await lstat(path);
39
+ if (stat.isSymbolicLink() ||
40
+ (!stat.isDirectory() &&
41
+ !(stat.isFile() && path.toLowerCase().endsWith(".car"))))
42
+ throw new HostError("Template SOURCE must be an exact CID, self-contained CAR or explicit Template Bundle directory.");
43
+ if (stat.isDirectory()) {
44
+ const manifest = await lstat(resolve(path, ".bundle.yaml"));
45
+ if (!manifest.isFile() || manifest.isSymbolicLink())
46
+ throw new HostError("Template directory requires an explicit regular .bundle.yaml.");
47
+ }
48
+ }
49
+ const content = await publicationSource(input, store);
50
+ await inspectTemplate(store, content);
51
+ return content;
52
+ }
53
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,eA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OAAO,CAAC,KAAK,CAAC,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,IACE,IAAI,CAAC,cAAc,EAAE;YACrB,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE;gBAClB,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAE1D,MAAM,IAAI,SAAS,CACjB,iGAAiG,CAClG,CAAC;QACJ,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;YAC5D,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,QAAQ,CAAC,cAAc,EAAE;gBACjD,MAAM,IAAI,SAAS,CACjB,+DAA+D,CAChE,CAAC;QACN,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACtD,MAAM,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtC,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ipab/cli",
3
- "version": "0.1.0-rc.6",
3
+ "version": "0.1.0-rc.7",
4
4
  "private": false,
5
5
  "description": "Node subprocess IPAB host.",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "access": "public"
20
20
  },
21
21
  "engines": {
22
- "node": ">=22.15.0"
22
+ "node": ">=22.20.0"
23
23
  },
24
24
  "bin": {
25
25
  "ipab": "dist/main.js"
@@ -42,18 +42,19 @@
42
42
  "dependencies": {
43
43
  "@ipld/dag-cbor": "10.0.2",
44
44
  "liquidjs": "10.30.1",
45
- "@ipab/web-app": "0.1.0-rc.3",
45
+ "@ipab/web-app": "0.1.0-rc.4",
46
46
  "esbuild": "0.28.2",
47
- "@ipab/bundle-builder": "0.1.0-rc.6",
47
+ "@ipab/bundle-builder": "0.1.0-rc.7",
48
48
  "@ipld/car": "5.4.6",
49
49
  "@ipld/dag-pb": "4.2.0",
50
- "@ipab/bundle": "0.1.0-rc.6",
51
- "@ipab/ipfs-store": "0.1.0-rc.2",
50
+ "@ipab/bundle": "0.1.0-rc.7",
51
+ "@ipab/ipfs-store": "0.1.0-rc.3",
52
52
  "ipfs-unixfs": "13.1.2",
53
53
  "ipfs-unixfs-importer": "17.1.1",
54
54
  "multiformats": "14.0.5",
55
55
  "string-width": "8.2.1",
56
56
  "ignore": "7.0.16",
57
+ "skills": "1.9.1",
57
58
  "yaml": "2.9.1"
58
59
  },
59
60
  "devDependencies": {
@@ -13,7 +13,7 @@ import {
13
13
  import { StringDecoder } from "node:string_decoder";
14
14
  import { compileFunction } from "node:vm";
15
15
  import { stringify } from "yaml";
16
- import { parseData } from "@ipab/bundle";
16
+ import { parseData, type BundleType } from "@ipab/bundle";
17
17
  import { filesystemTree } from "@ipab/bundle-builder/node";
18
18
  import { encodeBundleCar, memoryTree, readBytes } from "@ipab/bundle-builder";
19
19
  import {
@@ -199,6 +199,8 @@ export async function buildApp(
199
199
  outputDir?: string;
200
200
  replace?: boolean;
201
201
  includeSource?: boolean;
202
+ /** Exact types from an author's Open App definition; exclusive with config paths. */
203
+ supportedTypes?: readonly BundleType[];
202
204
  preparedDirectory?: string;
203
205
  } = {},
204
206
  ): Promise<
@@ -340,7 +342,19 @@ export async function buildApp(
340
342
  throw new HostError(
341
343
  "App metadata cannot override the generated source declaration.",
342
344
  );
343
- const supportedSchemas = await buildSupportedSchemas(tree, schemas, options);
345
+ if (options.supportedTypes && schemas.size)
346
+ throw new HostError(
347
+ "Use either supportedTypes or supportedSchemas paths, not both.",
348
+ );
349
+ const declared = options.supportedTypes?.map(
350
+ (type, index) =>
351
+ [`schemas/${index}.json`, new TextEncoder().encode(json(type))] as const,
352
+ );
353
+ const supportedSchemas = await buildSupportedSchemas(
354
+ declared ? memoryTree(new Map(declared)) : tree,
355
+ declared ? new Set(declared.map(([path]) => path)) : schemas,
356
+ options,
357
+ );
344
358
  const description = appDescription({
345
359
  ...defaults,
346
360
  ...overrides,
@@ -727,6 +741,8 @@ export async function prepareApp(
727
741
  options: AuthoringOptions & {
728
742
  replace?: boolean;
729
743
  includeSource?: boolean;
744
+ /** Exact types from an author's Open App definition; exclusive with config paths. */
745
+ supportedTypes?: readonly BundleType[];
730
746
  } = {},
731
747
  ) {
732
748
  const root = resolve(directory);
@@ -1,12 +1,12 @@
1
- import { fileURLToPath } from "node:url";
2
1
  import { resolve } from "node:path";
3
- import { lstat, readFile } from "node:fs/promises";
2
+ import { lstat } from "node:fs/promises";
4
3
  import { Liquid, type Template } from "liquidjs";
5
4
  import { parseBundleManifest } from "@ipab/bundle";
6
5
  import {
7
6
  listTree,
8
7
  readBytes,
9
8
  type ReadonlyFileTree,
9
+ type TreeEntry,
10
10
  } from "@ipab/bundle-builder";
11
11
  import { filesystemTree } from "@ipab/bundle-builder/node";
12
12
  import { HostError, object } from "./errors.js";
@@ -16,14 +16,10 @@ import {
16
16
  templateDefinition,
17
17
  templateParameters,
18
18
  } from "./template-definition.js";
19
- import { builtinTemplateSource, templateSource } from "./template-source.js";
19
+ import { templateSource } from "./template-source.js";
20
+ import { addTemplateOutputPath, templateOutputPath } from "./template-paths.js";
20
21
  import { nodeError } from "./authoring.js";
21
22
 
22
- export const builtinTemplateNames = new Map([
23
- ["builtin:template.node", "node"],
24
- ["builtin:template.web-app", "web-app"],
25
- ] as const);
26
-
27
23
  function appName(name: string) {
28
24
  if (
29
25
  !/^[a-z0-9][a-z0-9._-]*$/.test(name) ||
@@ -260,7 +256,7 @@ export async function renderTemplate(
260
256
  );
261
257
  const values = templateParameters(definition, name, options.parameters);
262
258
  const files = new Map<string, string | Uint8Array>();
263
- const paths = new Map<string, string>();
259
+ const paths = new Map<string, TreeEntry["kind"]>();
264
260
  let count = 0,
265
261
  total = 0;
266
262
  const collect = async (directory: string, depth: number): Promise<void> => {
@@ -270,35 +266,8 @@ export async function renderTemplate(
270
266
  if (++count > 256)
271
267
  throw new HostError("Template exceeds 256 project paths.");
272
268
  const source = `${directory}/${entry.name}`;
273
- relativePath(source);
274
- const original = source.slice("project/".length);
275
- const rendered = entry.kind === "file" && original.endsWith(".liquid");
276
- const target = relativePath(
277
- rendered ? original.slice(0, -".liquid".length) : original,
278
- );
279
- if (
280
- target
281
- .split("/")
282
- .some(
283
- (part) =>
284
- ["node_modules", ".git", "dist"].includes(part.toLowerCase()) ||
285
- /^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/i.test(part),
286
- )
287
- )
288
- throw new HostError(`Unsafe template output path: ${target}.`);
289
- const key = target.toLowerCase();
290
- if (
291
- paths.has(key) ||
292
- [...paths].some(
293
- ([existing, kind]) =>
294
- (kind === "file" && key.startsWith(`${existing}/`)) ||
295
- (entry.kind === "file" && existing.startsWith(`${key}/`)),
296
- )
297
- )
298
- throw new HostError(
299
- `Duplicate or overlapping template output path: ${target}.`,
300
- );
301
- paths.set(key, entry.kind);
269
+ const { target, rendered } = templateOutputPath(source, entry.kind);
270
+ addTemplateOutputPath(paths, target, entry.kind);
302
271
  if (entry.kind === "directory") {
303
272
  await collect(source, depth + 1);
304
273
  continue;
@@ -333,39 +302,6 @@ export async function appTemplate(
333
302
  options: AuthoringOptions & { parameters?: readonly string[] },
334
303
  ): Promise<{ files: Map<string, string | Uint8Array>; cid: string | null }> {
335
304
  options.signal?.throwIfAborted();
336
- for (const [alias, name] of builtinTemplateNames)
337
- if (selector === alias) selector = name;
338
- if (selector === "node" || selector === "web-app") {
339
- appName(name);
340
- const loaded = await builtinTemplateSource(selector, options);
341
- const parameters = [...(options.parameters ?? [])];
342
- if (
343
- selector === "web-app" &&
344
- !parameters.some((value) => value.startsWith("webAppDependency="))
345
- ) {
346
- const framework = object(
347
- JSON.parse(
348
- await readFile(
349
- fileURLToPath(import.meta.resolve("@ipab/web-app/package.json")),
350
- "utf8",
351
- ),
352
- ) as unknown,
353
- "Web App framework package",
354
- );
355
- if (typeof framework.version !== "string" || !framework.version.trim())
356
- throw new HostError(
357
- "Web App framework package is missing its version.",
358
- );
359
- parameters.push(`webAppDependency=${framework.version}`);
360
- }
361
- return {
362
- files: await renderTemplate(loaded.tree, name, {
363
- ...options,
364
- parameters,
365
- }),
366
- cid: loaded.cid,
367
- };
368
- }
369
305
  let legacy = false;
370
306
  try {
371
307
  await lstat(resolve(selector, ".bundle.yaml"));
@@ -396,7 +332,7 @@ export async function appTemplate(
396
332
  } catch (error) {
397
333
  if (nodeError(error, "ENOENT"))
398
334
  throw new HostError(
399
- `Unknown template "${selector}". Use node, web-app, a valid Bundle directory, single-root CAR, exact CID or packaged builtin reference. Local content aliases are unsupported.`,
335
+ `Unknown template "${selector}". Use a Swarm template selector, valid Bundle directory, single-root CAR, exact CID or IPAB URI. Builtin templates and local aliases are unsupported.`,
400
336
  );
401
337
  throw error;
402
338
  }
package/src/builtins.ts CHANGED
@@ -1,14 +1,6 @@
1
1
  import { builtinAppSchema } from "./app-definition.js";
2
- import {
3
- builtinTemplateSchema,
4
- templateSchemaCid,
5
- } from "./template-definition.js";
6
- import { builtinTemplateNames } from "./app-templates.js";
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";
11
- import type { NamedPin, PinMetadata } from "./state.js";
2
+ import { builtinTemplateSchema } from "./template-definition.js";
3
+ import type { NamedPin } from "./state.js";
12
4
 
13
5
  async function loadBuiltins(): Promise<{
14
6
  pins: readonly NamedPin[];
@@ -16,16 +8,6 @@ async function loadBuiltins(): Promise<{
16
8
  }> {
17
9
  const pins: NamedPin[] = [];
18
10
  const blocks = new Map<string, Uint8Array>();
19
- const add = (name: string, cid: string, metadata: PinMetadata) => {
20
- pins.push({
21
- name,
22
- cid,
23
- owner: name,
24
- status: "ready",
25
- metadata,
26
- builtin: true,
27
- });
28
- };
29
11
  for (const schema of [
30
12
  await builtinAppSchema(),
31
13
  await builtinTemplateSchema(),
@@ -33,34 +15,6 @@ async function loadBuiltins(): Promise<{
33
15
  const cid = schema.cid.toString();
34
16
  blocks.set(cid, schema.bytes);
35
17
  }
36
- for (const [name, selector] of builtinTemplateNames) {
37
- const template = await builtinTemplateSource(selector);
38
- for (const [cid, bytes] of template.blocks) blocks.set(cid, bytes);
39
- add(name, template.cid, {
40
- kind: "bundle",
41
- title: template.manifest.title,
42
- schemaCid: templateSchemaCid.toString(),
43
- });
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
- });
64
18
  return { pins, blocks };
65
19
  }
66
20