@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.
- package/README.md +226 -9
- package/dist/app-authoring.d.ts +15 -0
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +144 -58
- 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-prebuild.d.ts +18 -0
- package/dist/app-prebuild.d.ts.map +1 -1
- package/dist/app-prebuild.js +46 -0
- package/dist/app-prebuild.js.map +1 -1
- package/dist/app-templates.d.ts +0 -1
- package/dist/app-templates.d.ts.map +1 -1
- package/dist/app-templates.js +8 -46
- 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.bundle-viewer.car +0 -0
- package/dist/builtins/template.check.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 +1 -23
- package/dist/builtins.js.map +1 -1
- package/dist/bundled-skills.d.ts +14 -0
- package/dist/bundled-skills.d.ts.map +1 -0
- package/dist/bundled-skills.js +34 -0
- package/dist/bundled-skills.js.map +1 -0
- package/dist/cli.d.ts +8 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1919 -256
- 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 +12 -0
- package/dist/config-secret.js.map +1 -0
- package/dist/config.d.ts +7 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +151 -8
- package/dist/config.js.map +1 -1
- package/dist/content-provider.d.ts +32 -0
- package/dist/content-provider.d.ts.map +1 -0
- package/dist/content-provider.js +222 -0
- package/dist/content-provider.js.map +1 -0
- package/dist/context-types.d.ts +12 -0
- package/dist/context-types.d.ts.map +1 -0
- package/dist/context-types.js +2 -0
- package/dist/context-types.js.map +1 -0
- package/dist/context.d.ts +26 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +54 -10
- package/dist/context.js.map +1 -1
- package/dist/daemon-ui.d.ts +93 -0
- package/dist/daemon-ui.d.ts.map +1 -0
- package/dist/daemon-ui.js +713 -0
- package/dist/daemon-ui.js.map +1 -0
- package/dist/daemon.d.ts +21 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +317 -0
- package/dist/daemon.js.map +1 -0
- package/dist/doctor.d.ts +32 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +684 -0
- package/dist/doctor.js.map +1 -0
- package/dist/errors.d.ts +1 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -20
- package/dist/errors.js.map +1 -1
- 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/history.d.ts.map +1 -1
- package/dist/history.js +6 -14
- package/dist/history.js.map +1 -1
- package/dist/host-error.d.ts +9 -0
- package/dist/host-error.d.ts.map +1 -0
- package/dist/host-error.js +21 -0
- package/dist/host-error.js.map +1 -0
- package/dist/identity.d.ts +16 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +119 -0
- package/dist/identity.js.map +1 -0
- package/dist/ipc.d.ts +5 -2
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +124 -12
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.d.ts +26 -0
- package/dist/kubo-install.d.ts.map +1 -0
- package/dist/kubo-install.js +724 -0
- package/dist/kubo-install.js.map +1 -0
- package/dist/kubo-peering.d.ts +11 -0
- package/dist/kubo-peering.d.ts.map +1 -0
- package/dist/kubo-peering.js +93 -0
- package/dist/kubo-peering.js.map +1 -0
- package/dist/kubo-peers.d.ts +12 -0
- package/dist/kubo-peers.d.ts.map +1 -0
- package/dist/kubo-peers.js +119 -0
- package/dist/kubo-peers.js.map +1 -0
- package/dist/kubo-release.d.ts +22 -0
- package/dist/kubo-release.d.ts.map +1 -0
- package/dist/kubo-release.js +176 -0
- package/dist/kubo-release.js.map +1 -0
- package/dist/kubo-topology.d.ts +19 -0
- package/dist/kubo-topology.d.ts.map +1 -0
- package/dist/kubo-topology.js +113 -0
- package/dist/kubo-topology.js.map +1 -0
- package/dist/kubo.d.ts +85 -0
- package/dist/kubo.d.ts.map +1 -0
- package/dist/kubo.js +755 -0
- package/dist/kubo.js.map +1 -0
- package/dist/pins.d.ts +16 -18
- package/dist/pins.d.ts.map +1 -1
- package/dist/pins.js +144 -106
- package/dist/pins.js.map +1 -1
- package/dist/pivot-rpc.d.ts +62 -0
- package/dist/pivot-rpc.d.ts.map +1 -0
- package/dist/pivot-rpc.js +407 -0
- package/dist/pivot-rpc.js.map +1 -0
- package/dist/pivot-service.d.ts +16 -0
- package/dist/pivot-service.d.ts.map +1 -0
- package/dist/pivot-service.js +50 -0
- package/dist/pivot-service.js.map +1 -0
- package/dist/publish-source.d.ts +3 -0
- package/dist/publish-source.d.ts.map +1 -0
- package/dist/publish-source.js +85 -0
- package/dist/publish-source.js.map +1 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +9 -4
- package/dist/runtime.js.map +1 -1
- package/dist/search-index.d.ts +64 -0
- package/dist/search-index.d.ts.map +1 -0
- package/dist/search-index.js +409 -0
- package/dist/search-index.js.map +1 -0
- package/dist/search-service.d.ts +23 -0
- package/dist/search-service.d.ts.map +1 -0
- package/dist/search-service.js +116 -0
- package/dist/search-service.js.map +1 -0
- package/dist/skill-definition.d.ts +6 -0
- package/dist/skill-definition.d.ts.map +1 -0
- package/dist/skill-definition.js +38 -0
- package/dist/skill-definition.js.map +1 -0
- package/dist/skill-source.d.ts +9 -0
- package/dist/skill-source.d.ts.map +1 -0
- package/dist/skill-source.js +24 -0
- package/dist/skill-source.js.map +1 -0
- package/dist/skills.d.ts +104 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +894 -0
- package/dist/skills.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-path.d.ts +3 -0
- package/dist/space-path.d.ts.map +1 -0
- package/dist/space-path.js +17 -0
- package/dist/space-path.js.map +1 -0
- package/dist/space.d.ts +16 -4
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +170 -24
- package/dist/space.js.map +1 -1
- package/dist/state-storage-windows.d.ts +2 -0
- package/dist/state-storage-windows.d.ts.map +1 -0
- package/dist/state-storage-windows.js +114 -0
- package/dist/state-storage-windows.js.map +1 -0
- package/dist/state-storage.d.ts +5 -0
- package/dist/state-storage.d.ts.map +1 -0
- package/dist/state-storage.js +333 -0
- package/dist/state-storage.js.map +1 -0
- package/dist/state.d.ts +115 -13
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +492 -91
- package/dist/state.js.map +1 -1
- package/dist/swarm-envelope.d.ts +57 -0
- package/dist/swarm-envelope.d.ts.map +1 -0
- package/dist/swarm-envelope.js +299 -0
- package/dist/swarm-envelope.js.map +1 -0
- package/dist/swarm-files.d.ts +6 -0
- package/dist/swarm-files.d.ts.map +1 -0
- package/dist/swarm-files.js +116 -0
- package/dist/swarm-files.js.map +1 -0
- package/dist/swarm-meta.d.ts +15 -0
- package/dist/swarm-meta.d.ts.map +1 -0
- package/dist/swarm-meta.js +68 -0
- package/dist/swarm-meta.js.map +1 -0
- package/dist/swarm-observations.d.ts +40 -0
- package/dist/swarm-observations.d.ts.map +1 -0
- package/dist/swarm-observations.js +271 -0
- package/dist/swarm-observations.js.map +1 -0
- package/dist/swarm.d.ts +469 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/swarm.js +4708 -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-paths.d.ts +7 -0
- package/dist/template-paths.d.ts.map +1 -0
- package/dist/template-paths.js +23 -0
- package/dist/template-paths.js.map +1 -0
- package/dist/template-presentation.d.ts +20 -0
- package/dist/template-presentation.d.ts.map +1 -0
- package/dist/template-presentation.js +133 -0
- package/dist/template-presentation.js.map +1 -0
- package/dist/template-source.d.ts +4 -1
- package/dist/template-source.d.ts.map +1 -1
- package/dist/template-source.js +11 -4
- package/dist/template-source.js.map +1 -1
- package/dist/templates.d.ts +11 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +53 -0
- package/dist/templates.js.map +1 -0
- package/dist/unixfs-tree.d.ts +67 -0
- package/dist/unixfs-tree.d.ts.map +1 -0
- package/dist/unixfs-tree.js +329 -0
- package/dist/unixfs-tree.js.map +1 -0
- package/package.json +14 -7
- package/src/app-authoring.ts +240 -76
- package/src/app-definition.ts +33 -39
- package/src/app-prebuild.ts +61 -0
- package/src/app-templates.ts +17 -73
- package/src/assembly.ts +185 -0
- package/src/authoring.ts +41 -17
- package/src/builtins.ts +2 -27
- package/src/bundled-skills.ts +60 -0
- package/src/cli.ts +2399 -320
- package/src/config-secret.ts +14 -0
- package/src/config.ts +196 -8
- package/src/content-provider.ts +299 -0
- package/src/context-types.ts +11 -0
- package/src/context.ts +98 -10
- package/src/daemon-ui.ts +812 -0
- package/src/daemon.ts +386 -0
- package/src/doctor.ts +1082 -0
- package/src/errors.ts +1 -25
- package/src/get.ts +90 -0
- package/src/history.ts +5 -15
- package/src/host-error.ts +26 -0
- package/src/identity.ts +175 -0
- package/src/ipc.ts +160 -11
- package/src/kubo-install.ts +936 -0
- package/src/kubo-peering.ts +126 -0
- package/src/kubo-peers.ts +144 -0
- package/src/kubo-release.ts +230 -0
- package/src/kubo-topology.ts +148 -0
- package/src/kubo.ts +1088 -0
- package/src/pins.ts +188 -126
- package/src/pivot-rpc.ts +601 -0
- package/src/pivot-service.ts +87 -0
- package/src/publish-source.ts +103 -0
- package/src/runtime.ts +16 -4
- package/src/search-index.ts +560 -0
- package/src/search-service.ts +152 -0
- package/src/skill-definition.ts +53 -0
- package/src/skill-source.ts +29 -0
- package/src/skills.ts +1236 -0
- package/src/source-bundle.ts +26 -13
- package/src/space-path.ts +30 -0
- package/src/space.ts +230 -42
- package/src/state-storage-windows.ts +134 -0
- package/src/state-storage.ts +378 -0
- package/src/state.ts +759 -107
- package/src/swarm-envelope.ts +461 -0
- package/src/swarm-files.ts +126 -0
- package/src/swarm-meta.ts +98 -0
- package/src/swarm-observations.ts +393 -0
- package/src/swarm.ts +7051 -0
- package/src/template-definition.ts +36 -41
- package/src/template-paths.ts +43 -0
- package/src/template-presentation.ts +151 -0
- package/src/template-source.ts +19 -5
- package/src/templates.ts +77 -0
- package/src/unixfs-tree.ts +401 -0
package/src/assembly.ts
ADDED
|
@@ -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
|
-
|
|
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,12 +1,6 @@
|
|
|
1
1
|
import { builtinAppSchema } from "./app-definition.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
+
}
|