@ipab/cli 0.1.0-rc.1 → 0.1.0-rc.10

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 (285) hide show
  1. package/README.md +226 -9
  2. package/dist/app-authoring.d.ts +15 -0
  3. package/dist/app-authoring.d.ts.map +1 -1
  4. package/dist/app-authoring.js +144 -58
  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-prebuild.d.ts +18 -0
  11. package/dist/app-prebuild.d.ts.map +1 -1
  12. package/dist/app-prebuild.js +46 -0
  13. package/dist/app-prebuild.js.map +1 -1
  14. package/dist/app-templates.d.ts +0 -1
  15. package/dist/app-templates.d.ts.map +1 -1
  16. package/dist/app-templates.js +8 -46
  17. package/dist/app-templates.js.map +1 -1
  18. package/dist/assembly.d.ts +7 -0
  19. package/dist/assembly.d.ts.map +1 -0
  20. package/dist/assembly.js +130 -0
  21. package/dist/assembly.js.map +1 -0
  22. package/dist/authoring.d.ts +4 -8
  23. package/dist/authoring.d.ts.map +1 -1
  24. package/dist/authoring.js +25 -15
  25. package/dist/authoring.js.map +1 -1
  26. package/dist/builtins/skill.ipab.car +0 -0
  27. package/dist/builtins/template.bundle-viewer.car +0 -0
  28. package/dist/builtins/template.check.car +0 -0
  29. package/dist/builtins/template.node.car +0 -0
  30. package/dist/builtins/template.web-app.car +0 -0
  31. package/dist/builtins.d.ts.map +1 -1
  32. package/dist/builtins.js +1 -23
  33. package/dist/builtins.js.map +1 -1
  34. package/dist/bundled-skills.d.ts +14 -0
  35. package/dist/bundled-skills.d.ts.map +1 -0
  36. package/dist/bundled-skills.js +34 -0
  37. package/dist/bundled-skills.js.map +1 -0
  38. package/dist/cli.d.ts +8 -2
  39. package/dist/cli.d.ts.map +1 -1
  40. package/dist/cli.js +1919 -256
  41. package/dist/cli.js.map +1 -1
  42. package/dist/config-secret.d.ts +3 -0
  43. package/dist/config-secret.d.ts.map +1 -0
  44. package/dist/config-secret.js +12 -0
  45. package/dist/config-secret.js.map +1 -0
  46. package/dist/config.d.ts +7 -2
  47. package/dist/config.d.ts.map +1 -1
  48. package/dist/config.js +151 -8
  49. package/dist/config.js.map +1 -1
  50. package/dist/content-provider.d.ts +32 -0
  51. package/dist/content-provider.d.ts.map +1 -0
  52. package/dist/content-provider.js +222 -0
  53. package/dist/content-provider.js.map +1 -0
  54. package/dist/context-types.d.ts +12 -0
  55. package/dist/context-types.d.ts.map +1 -0
  56. package/dist/context-types.js +2 -0
  57. package/dist/context-types.js.map +1 -0
  58. package/dist/context.d.ts +26 -1
  59. package/dist/context.d.ts.map +1 -1
  60. package/dist/context.js +54 -10
  61. package/dist/context.js.map +1 -1
  62. package/dist/daemon-ui.d.ts +93 -0
  63. package/dist/daemon-ui.d.ts.map +1 -0
  64. package/dist/daemon-ui.js +713 -0
  65. package/dist/daemon-ui.js.map +1 -0
  66. package/dist/daemon.d.ts +21 -0
  67. package/dist/daemon.d.ts.map +1 -0
  68. package/dist/daemon.js +317 -0
  69. package/dist/daemon.js.map +1 -0
  70. package/dist/doctor.d.ts +32 -0
  71. package/dist/doctor.d.ts.map +1 -0
  72. package/dist/doctor.js +684 -0
  73. package/dist/doctor.js.map +1 -0
  74. package/dist/errors.d.ts +1 -8
  75. package/dist/errors.d.ts.map +1 -1
  76. package/dist/errors.js +1 -20
  77. package/dist/errors.js.map +1 -1
  78. package/dist/get.d.ts +3 -0
  79. package/dist/get.d.ts.map +1 -0
  80. package/dist/get.js +80 -0
  81. package/dist/get.js.map +1 -0
  82. package/dist/history.d.ts.map +1 -1
  83. package/dist/history.js +6 -14
  84. package/dist/history.js.map +1 -1
  85. package/dist/host-error.d.ts +9 -0
  86. package/dist/host-error.d.ts.map +1 -0
  87. package/dist/host-error.js +21 -0
  88. package/dist/host-error.js.map +1 -0
  89. package/dist/identity.d.ts +16 -0
  90. package/dist/identity.d.ts.map +1 -0
  91. package/dist/identity.js +119 -0
  92. package/dist/identity.js.map +1 -0
  93. package/dist/ipc.d.ts +5 -2
  94. package/dist/ipc.d.ts.map +1 -1
  95. package/dist/ipc.js +124 -12
  96. package/dist/ipc.js.map +1 -1
  97. package/dist/kubo-install.d.ts +26 -0
  98. package/dist/kubo-install.d.ts.map +1 -0
  99. package/dist/kubo-install.js +724 -0
  100. package/dist/kubo-install.js.map +1 -0
  101. package/dist/kubo-peering.d.ts +11 -0
  102. package/dist/kubo-peering.d.ts.map +1 -0
  103. package/dist/kubo-peering.js +93 -0
  104. package/dist/kubo-peering.js.map +1 -0
  105. package/dist/kubo-peers.d.ts +12 -0
  106. package/dist/kubo-peers.d.ts.map +1 -0
  107. package/dist/kubo-peers.js +119 -0
  108. package/dist/kubo-peers.js.map +1 -0
  109. package/dist/kubo-release.d.ts +22 -0
  110. package/dist/kubo-release.d.ts.map +1 -0
  111. package/dist/kubo-release.js +176 -0
  112. package/dist/kubo-release.js.map +1 -0
  113. package/dist/kubo-topology.d.ts +19 -0
  114. package/dist/kubo-topology.d.ts.map +1 -0
  115. package/dist/kubo-topology.js +113 -0
  116. package/dist/kubo-topology.js.map +1 -0
  117. package/dist/kubo.d.ts +85 -0
  118. package/dist/kubo.d.ts.map +1 -0
  119. package/dist/kubo.js +755 -0
  120. package/dist/kubo.js.map +1 -0
  121. package/dist/pins.d.ts +16 -18
  122. package/dist/pins.d.ts.map +1 -1
  123. package/dist/pins.js +144 -106
  124. package/dist/pins.js.map +1 -1
  125. package/dist/pivot-rpc.d.ts +62 -0
  126. package/dist/pivot-rpc.d.ts.map +1 -0
  127. package/dist/pivot-rpc.js +407 -0
  128. package/dist/pivot-rpc.js.map +1 -0
  129. package/dist/pivot-service.d.ts +16 -0
  130. package/dist/pivot-service.d.ts.map +1 -0
  131. package/dist/pivot-service.js +50 -0
  132. package/dist/pivot-service.js.map +1 -0
  133. package/dist/publish-source.d.ts +3 -0
  134. package/dist/publish-source.d.ts.map +1 -0
  135. package/dist/publish-source.js +85 -0
  136. package/dist/publish-source.js.map +1 -0
  137. package/dist/runtime.d.ts +2 -0
  138. package/dist/runtime.d.ts.map +1 -1
  139. package/dist/runtime.js +9 -4
  140. package/dist/runtime.js.map +1 -1
  141. package/dist/search-index.d.ts +64 -0
  142. package/dist/search-index.d.ts.map +1 -0
  143. package/dist/search-index.js +409 -0
  144. package/dist/search-index.js.map +1 -0
  145. package/dist/search-service.d.ts +23 -0
  146. package/dist/search-service.d.ts.map +1 -0
  147. package/dist/search-service.js +116 -0
  148. package/dist/search-service.js.map +1 -0
  149. package/dist/skill-definition.d.ts +6 -0
  150. package/dist/skill-definition.d.ts.map +1 -0
  151. package/dist/skill-definition.js +38 -0
  152. package/dist/skill-definition.js.map +1 -0
  153. package/dist/skill-source.d.ts +9 -0
  154. package/dist/skill-source.d.ts.map +1 -0
  155. package/dist/skill-source.js +24 -0
  156. package/dist/skill-source.js.map +1 -0
  157. package/dist/skills.d.ts +104 -0
  158. package/dist/skills.d.ts.map +1 -0
  159. package/dist/skills.js +894 -0
  160. package/dist/skills.js.map +1 -0
  161. package/dist/source-bundle.d.ts +3 -8
  162. package/dist/source-bundle.d.ts.map +1 -1
  163. package/dist/source-bundle.js +17 -12
  164. package/dist/source-bundle.js.map +1 -1
  165. package/dist/space-path.d.ts +3 -0
  166. package/dist/space-path.d.ts.map +1 -0
  167. package/dist/space-path.js +17 -0
  168. package/dist/space-path.js.map +1 -0
  169. package/dist/space.d.ts +16 -4
  170. package/dist/space.d.ts.map +1 -1
  171. package/dist/space.js +170 -24
  172. package/dist/space.js.map +1 -1
  173. package/dist/state-storage-windows.d.ts +2 -0
  174. package/dist/state-storage-windows.d.ts.map +1 -0
  175. package/dist/state-storage-windows.js +114 -0
  176. package/dist/state-storage-windows.js.map +1 -0
  177. package/dist/state-storage.d.ts +5 -0
  178. package/dist/state-storage.d.ts.map +1 -0
  179. package/dist/state-storage.js +333 -0
  180. package/dist/state-storage.js.map +1 -0
  181. package/dist/state.d.ts +115 -13
  182. package/dist/state.d.ts.map +1 -1
  183. package/dist/state.js +492 -91
  184. package/dist/state.js.map +1 -1
  185. package/dist/swarm-envelope.d.ts +57 -0
  186. package/dist/swarm-envelope.d.ts.map +1 -0
  187. package/dist/swarm-envelope.js +299 -0
  188. package/dist/swarm-envelope.js.map +1 -0
  189. package/dist/swarm-files.d.ts +6 -0
  190. package/dist/swarm-files.d.ts.map +1 -0
  191. package/dist/swarm-files.js +116 -0
  192. package/dist/swarm-files.js.map +1 -0
  193. package/dist/swarm-meta.d.ts +15 -0
  194. package/dist/swarm-meta.d.ts.map +1 -0
  195. package/dist/swarm-meta.js +68 -0
  196. package/dist/swarm-meta.js.map +1 -0
  197. package/dist/swarm-observations.d.ts +40 -0
  198. package/dist/swarm-observations.d.ts.map +1 -0
  199. package/dist/swarm-observations.js +271 -0
  200. package/dist/swarm-observations.js.map +1 -0
  201. package/dist/swarm.d.ts +469 -0
  202. package/dist/swarm.d.ts.map +1 -0
  203. package/dist/swarm.js +4708 -0
  204. package/dist/swarm.js.map +1 -0
  205. package/dist/template-definition.d.ts +47 -52
  206. package/dist/template-definition.d.ts.map +1 -1
  207. package/dist/template-definition.js +36 -41
  208. package/dist/template-definition.js.map +1 -1
  209. package/dist/template-paths.d.ts +7 -0
  210. package/dist/template-paths.d.ts.map +1 -0
  211. package/dist/template-paths.js +23 -0
  212. package/dist/template-paths.js.map +1 -0
  213. package/dist/template-presentation.d.ts +20 -0
  214. package/dist/template-presentation.d.ts.map +1 -0
  215. package/dist/template-presentation.js +133 -0
  216. package/dist/template-presentation.js.map +1 -0
  217. package/dist/template-source.d.ts +4 -1
  218. package/dist/template-source.d.ts.map +1 -1
  219. package/dist/template-source.js +11 -4
  220. package/dist/template-source.js.map +1 -1
  221. package/dist/templates.d.ts +11 -0
  222. package/dist/templates.d.ts.map +1 -0
  223. package/dist/templates.js +53 -0
  224. package/dist/templates.js.map +1 -0
  225. package/dist/unixfs-tree.d.ts +67 -0
  226. package/dist/unixfs-tree.d.ts.map +1 -0
  227. package/dist/unixfs-tree.js +329 -0
  228. package/dist/unixfs-tree.js.map +1 -0
  229. package/package.json +14 -7
  230. package/src/app-authoring.ts +240 -76
  231. package/src/app-definition.ts +33 -39
  232. package/src/app-prebuild.ts +61 -0
  233. package/src/app-templates.ts +17 -73
  234. package/src/assembly.ts +185 -0
  235. package/src/authoring.ts +41 -17
  236. package/src/builtins.ts +2 -27
  237. package/src/bundled-skills.ts +60 -0
  238. package/src/cli.ts +2399 -320
  239. package/src/config-secret.ts +14 -0
  240. package/src/config.ts +196 -8
  241. package/src/content-provider.ts +299 -0
  242. package/src/context-types.ts +11 -0
  243. package/src/context.ts +98 -10
  244. package/src/daemon-ui.ts +812 -0
  245. package/src/daemon.ts +386 -0
  246. package/src/doctor.ts +1082 -0
  247. package/src/errors.ts +1 -25
  248. package/src/get.ts +90 -0
  249. package/src/history.ts +5 -15
  250. package/src/host-error.ts +26 -0
  251. package/src/identity.ts +175 -0
  252. package/src/ipc.ts +160 -11
  253. package/src/kubo-install.ts +936 -0
  254. package/src/kubo-peering.ts +126 -0
  255. package/src/kubo-peers.ts +144 -0
  256. package/src/kubo-release.ts +230 -0
  257. package/src/kubo-topology.ts +148 -0
  258. package/src/kubo.ts +1088 -0
  259. package/src/pins.ts +188 -126
  260. package/src/pivot-rpc.ts +601 -0
  261. package/src/pivot-service.ts +87 -0
  262. package/src/publish-source.ts +103 -0
  263. package/src/runtime.ts +16 -4
  264. package/src/search-index.ts +560 -0
  265. package/src/search-service.ts +152 -0
  266. package/src/skill-definition.ts +53 -0
  267. package/src/skill-source.ts +29 -0
  268. package/src/skills.ts +1236 -0
  269. package/src/source-bundle.ts +26 -13
  270. package/src/space-path.ts +30 -0
  271. package/src/space.ts +230 -42
  272. package/src/state-storage-windows.ts +134 -0
  273. package/src/state-storage.ts +378 -0
  274. package/src/state.ts +759 -107
  275. package/src/swarm-envelope.ts +461 -0
  276. package/src/swarm-files.ts +126 -0
  277. package/src/swarm-meta.ts +98 -0
  278. package/src/swarm-observations.ts +393 -0
  279. package/src/swarm.ts +7051 -0
  280. package/src/template-definition.ts +36 -41
  281. package/src/template-paths.ts +43 -0
  282. package/src/template-presentation.ts +151 -0
  283. package/src/template-source.ts +19 -5
  284. package/src/templates.ts +77 -0
  285. package/src/unixfs-tree.ts +401 -0
@@ -0,0 +1,185 @@
1
+ import { lstat } from "node:fs/promises";
2
+ import { basename, dirname, join, resolve } from "node:path";
3
+ import { CID } from "multiformats/cid";
4
+ import { parseData, parseBundleManifest } from "@ipab/bundle";
5
+ import {
6
+ encodeBundleCar,
7
+ fileTree,
8
+ readBytes,
9
+ type FileReader,
10
+ } from "@ipab/bundle-builder";
11
+ import { filesystemTree } from "@ipab/bundle-builder/node";
12
+ import { HostError, object } from "./errors.js";
13
+ import { relativePath } from "./space.js";
14
+ import {
15
+ nodeError,
16
+ outputAvailable,
17
+ readCar,
18
+ writeCar,
19
+ type AuthoringOptions,
20
+ type BuildResult,
21
+ } from "./authoring.js";
22
+
23
+ function keys(value: Record<string, unknown>, allowed: string[]): void {
24
+ if (Object.keys(value).some((key) => !allowed.includes(key)))
25
+ throw new HostError(
26
+ "Unknown assembly recipe field. Legacy App ipab.yaml/ipab.json is not a generic assembly recipe; run project preparation separately.",
27
+ );
28
+ }
29
+
30
+ export async function assembleBundle(
31
+ source = ".",
32
+ options: AuthoringOptions & {
33
+ output?: string;
34
+ outputDir?: string;
35
+ replace?: boolean;
36
+ } = {},
37
+ ): Promise<BuildResult> {
38
+ const input = resolve(source);
39
+ const stat = await lstat(input);
40
+ if (stat.isSymbolicLink())
41
+ throw new HostError("Assembly input must not be a symlink.");
42
+ const recipePath = stat.isDirectory()
43
+ ? join(input, "ipab.build.yaml")
44
+ : input;
45
+ const root = dirname(recipePath);
46
+ const tree = await filesystemTree(root);
47
+ let recipeBytes: Uint8Array;
48
+ try {
49
+ recipeBytes = await readBytes(
50
+ tree,
51
+ basename(recipePath),
52
+ 64 * 1024,
53
+ options,
54
+ );
55
+ } catch (cause) {
56
+ if (stat.isDirectory()) {
57
+ for (const legacy of ["ipab.yaml", "ipab.json"]) {
58
+ try {
59
+ await lstat(join(root, legacy));
60
+ throw new HostError(
61
+ "Legacy App build configuration is unsupported by generic build. Run the project preparation script, then supply ipab.build.yaml.",
62
+ );
63
+ } catch (error) {
64
+ if (!nodeError(error, "ENOENT")) throw error;
65
+ }
66
+ }
67
+ }
68
+ throw cause;
69
+ }
70
+ const recipe = object(
71
+ parseData(recipeBytes, "application/yaml"),
72
+ "assembly recipe",
73
+ );
74
+ keys(recipe, ["version", "files", "imports"]);
75
+ if (
76
+ recipe.version !== 1 ||
77
+ !Array.isArray(recipe.files) ||
78
+ !Array.isArray(recipe.imports ?? [])
79
+ )
80
+ throw new HostError(
81
+ "Assembly recipe requires version: 1, files: [{source,target}], and optional imports: [{cid,target}].",
82
+ );
83
+ const files = new Map<string, FileReader>();
84
+ const paths: string[] = [];
85
+ const claim = (target: string) => {
86
+ relativePath(target);
87
+ const key = target.toLowerCase();
88
+ if (
89
+ paths.some(
90
+ (previous) =>
91
+ previous === key ||
92
+ previous.startsWith(`${key}/`) ||
93
+ key.startsWith(`${previous}/`),
94
+ )
95
+ )
96
+ throw new HostError(`Assembly target collision: ${target}.`);
97
+ paths.push(key);
98
+ };
99
+ files.set(".bundle.yaml", () => tree.read(".bundle.yaml", options));
100
+ claim(".bundle.yaml");
101
+ const definition = parseBundleManifest(
102
+ await readBytes(tree, ".bundle.yaml", 1024 * 1024, options),
103
+ );
104
+ const inputs = new Set<string>([resolve(root, ".bundle.yaml"), recipePath]);
105
+ for (const item of recipe.files) {
106
+ const mapping = object(item, "file mapping");
107
+ keys(mapping, ["source", "target"]);
108
+ if (
109
+ typeof mapping.source !== "string" ||
110
+ typeof mapping.target !== "string"
111
+ )
112
+ throw new HostError(
113
+ "Recipe file mappings require source and target strings.",
114
+ );
115
+ relativePath(mapping.source);
116
+ claim(mapping.target);
117
+ inputs.add(resolve(root, ...mapping.source.split("/")));
118
+ const sourcePath = mapping.source;
119
+ files.set(mapping.target, () => tree.read(sourcePath, options));
120
+ }
121
+ // CID grafts are processed sequentially; keep at most one local CAR in memory.
122
+ let localCar:
123
+ { path: string; data: Awaited<ReturnType<typeof readCar>> } | undefined;
124
+ const imports = ((recipe.imports as unknown[] | undefined) ?? []).map(
125
+ (item) => {
126
+ const mapping = object(item, "CID import");
127
+ keys(mapping, ["cid", "target", "car"]);
128
+ if (typeof mapping.cid !== "string" || typeof mapping.target !== "string")
129
+ throw new HostError("CID imports require cid and target strings.");
130
+ const cid = CID.parse(mapping.cid);
131
+ claim(mapping.target);
132
+ if (mapping.car !== undefined) {
133
+ if (typeof mapping.car !== "string")
134
+ throw new HostError("CID import car must be a relative file path.");
135
+ const path = resolve(root, relativePath(mapping.car));
136
+ inputs.add(path);
137
+ return {
138
+ path: mapping.target,
139
+ cid,
140
+ resolveCid: async (block: CID) => {
141
+ if (localCar?.path !== path)
142
+ localCar = { path, data: await readCar(path, options, root) };
143
+ if (!localCar.data.root.equals(cid))
144
+ throw new HostError(
145
+ "CID import does not match the local CAR root.",
146
+ );
147
+ return localCar.data.resolveCid(block);
148
+ },
149
+ };
150
+ }
151
+ if (!options.resolveCid)
152
+ throw new HostError("CID imports require a Store.");
153
+ return { path: mapping.target, cid, resolveCid: options.resolveCid };
154
+ },
155
+ );
156
+ if (
157
+ [definition.entry, definition.type].some(
158
+ (path) => !files.has(path) && !imports.some((item) => item.path === path),
159
+ )
160
+ )
161
+ throw new HostError(
162
+ "Recipe must explicitly select the Bundle entry and type files.",
163
+ );
164
+ const output = options.output
165
+ ? resolve(options.output)
166
+ : join(root, options.outputDir ?? "dist", "bundle.car");
167
+ if ([...inputs].some((input) => input.toLowerCase() === output.toLowerCase()))
168
+ throw new HostError("CAR output cannot replace recipe or source inputs.");
169
+ await outputAvailable(output, Boolean(options.replace));
170
+ const encoded = await encodeBundleCar(fileTree(files), {
171
+ ...options,
172
+ imports,
173
+ });
174
+ const result = {
175
+ kind: "content-bundle" as const,
176
+ cid: encoded.cid.toString(),
177
+ schemaCid: encoded.schema.cid.toString(),
178
+ output,
179
+ validation: encoded.validation,
180
+ };
181
+ return {
182
+ ...result,
183
+ bytes: await writeCar(encoded, output, Boolean(options.replace), options),
184
+ };
185
+ }
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,12 +1,6 @@
1
1
  import { builtinAppSchema } from "./app-definition.js";
2
- import {
3
- builtinTemplateSchema,
4
- templateSchema,
5
- templateSchemaCid,
6
- } from "./template-definition.js";
7
- import { builtinTemplateNames } from "./app-templates.js";
8
- import { builtinTemplateSource } from "./template-source.js";
9
- import type { NamedPin, PinMetadata } from "./state.js";
2
+ import { builtinTemplateSchema } from "./template-definition.js";
3
+ import type { NamedPin } from "./state.js";
10
4
 
11
5
  async function loadBuiltins(): Promise<{
12
6
  pins: readonly NamedPin[];
@@ -14,16 +8,6 @@ async function loadBuiltins(): Promise<{
14
8
  }> {
15
9
  const pins: NamedPin[] = [];
16
10
  const blocks = new Map<string, Uint8Array>();
17
- const add = (name: string, cid: string, metadata: PinMetadata) => {
18
- pins.push({
19
- name,
20
- cid,
21
- owner: name,
22
- status: "ready",
23
- metadata,
24
- builtin: true,
25
- });
26
- };
27
11
  for (const schema of [
28
12
  await builtinAppSchema(),
29
13
  await builtinTemplateSchema(),
@@ -31,15 +15,6 @@ async function loadBuiltins(): Promise<{
31
15
  const cid = schema.cid.toString();
32
16
  blocks.set(cid, schema.bytes);
33
17
  }
34
- for (const [name, selector] of builtinTemplateNames) {
35
- const template = await builtinTemplateSource(selector);
36
- for (const [cid, bytes] of template.blocks) blocks.set(cid, bytes);
37
- add(name, template.cid, {
38
- kind: "bundle",
39
- typeName: templateSchema.name,
40
- schemaCid: templateSchemaCid.toString(),
41
- });
42
- }
43
18
  return { pins, blocks };
44
19
  }
45
20
 
@@ -0,0 +1,60 @@
1
+ import { join } from "node:path";
2
+ import { bundledSkillSource } from "./skill-source.js";
3
+ import {
4
+ inspectBundledSkill,
5
+ manageSkills,
6
+ officialSkillsPort,
7
+ bundledSkillOrigin,
8
+ type SkillsPort,
9
+ } from "./skills.js";
10
+ import { HostError } from "./errors.js";
11
+
12
+ export async function inspectBundledSkills(
13
+ port: SkillsPort = officialSkillsPort,
14
+ ) {
15
+ return inspectBundledSkill(await bundledSkillSource(), port);
16
+ }
17
+
18
+ export async function installBundledSkills(
19
+ env: NodeJS.ProcessEnv,
20
+ preview: (text: string) => void,
21
+ port: SkillsPort = officialSkillsPort,
22
+ ) {
23
+ const catalog = await port.catalog();
24
+ const agents = catalog.detected
25
+ .filter((agent) =>
26
+ catalog.supported.some(
27
+ (entry) => entry.id === agent.id && entry.globalSkillsDir !== null,
28
+ ),
29
+ )
30
+ .map((agent) => agent.id);
31
+ if (!agents.length)
32
+ throw new HostError(
33
+ "No globally supported agents detected. Install an Agent, then retry ipab doctor --fix.",
34
+ );
35
+ const result = await manageSkills(
36
+ { env, bundledSkill: await bundledSkillSource() },
37
+ bundledSkillOrigin,
38
+ {
39
+ sync: true,
40
+ names: [],
41
+ agents,
42
+ overrideExisting: false,
43
+ dryRun: false,
44
+ yes: true,
45
+ tty: false,
46
+ confirm: () => Promise.resolve(false),
47
+ preview,
48
+ },
49
+ port,
50
+ );
51
+ if (!result.ok)
52
+ throw new HostError(
53
+ [
54
+ "Bundled IPAB Skill installation failed; existing custom content was preserved.",
55
+ ...result.items.flatMap((item) => item.problems),
56
+ ...result.results.flatMap((item) => (item.error ? [item.error] : [])),
57
+ `Inspect ${join(port.home, ".ipab", "skills", "installations.json")} and retry ipab doctor --fix.`,
58
+ ].join("\n"),
59
+ );
60
+ }