@skaile/workspaces 0.49.0 → 0.52.0
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/CHANGELOG.md +248 -0
- package/dist/asset-feeds-OEGJ6NOF.js +205 -0
- package/dist/asset-feeds-OEGJ6NOF.js.map +1 -0
- package/dist/asset-manager/index.js +8 -8
- package/dist/asset-manager/installer.js +7 -7
- package/dist/asset-manager/src/index.d.ts +94 -6
- package/dist/asset-manager/src/index.d.ts.map +1 -1
- package/dist/asset-manager/src/installer.d.ts +19 -8
- package/dist/asset-manager/src/installer.d.ts.map +1 -1
- package/dist/{chunk-P4BDTJMI.js → chunk-2D5YE3FL.js} +4 -4
- package/dist/{chunk-P4BDTJMI.js.map → chunk-2D5YE3FL.js.map} +1 -1
- package/dist/{chunk-4IGNQG6E.js → chunk-2ZK7M2SG.js} +3 -3
- package/dist/{chunk-4IGNQG6E.js.map → chunk-2ZK7M2SG.js.map} +1 -1
- package/dist/{chunk-SXT6BAQJ.js → chunk-3IHBGDCG.js} +2 -2
- package/dist/{chunk-SXT6BAQJ.js.map → chunk-3IHBGDCG.js.map} +1 -1
- package/dist/{chunk-SDAKQCOB.js → chunk-3KPNDTMR.js} +3 -3
- package/dist/{chunk-SDAKQCOB.js.map → chunk-3KPNDTMR.js.map} +1 -1
- package/dist/{chunk-H74X4TSR.js → chunk-6K4RVXAM.js} +6 -6
- package/dist/{chunk-H74X4TSR.js.map → chunk-6K4RVXAM.js.map} +1 -1
- package/dist/{chunk-XVDXGQ55.js → chunk-7X53KHQ4.js} +4 -2
- package/dist/{chunk-XVDXGQ55.js.map → chunk-7X53KHQ4.js.map} +1 -1
- package/dist/{chunk-LTUTK2Q3.js → chunk-7ZWLZ5H3.js} +35 -22
- package/dist/chunk-7ZWLZ5H3.js.map +1 -0
- package/dist/{chunk-6IDBWPK2.js → chunk-BQCGFPHW.js} +4 -3
- package/dist/chunk-BQCGFPHW.js.map +1 -0
- package/dist/chunk-BXC5547R.js +377 -0
- package/dist/chunk-BXC5547R.js.map +1 -0
- package/dist/{chunk-3A3OACI2.js → chunk-EOINYN5T.js} +2 -2
- package/dist/{chunk-3A3OACI2.js.map → chunk-EOINYN5T.js.map} +1 -1
- package/dist/{chunk-XGCXFX7X.js → chunk-F3HNW354.js} +3 -3
- package/dist/{chunk-XGCXFX7X.js.map → chunk-F3HNW354.js.map} +1 -1
- package/dist/{chunk-33WB7VFV.js → chunk-LKOMH3QC.js} +3 -3
- package/dist/{chunk-33WB7VFV.js.map → chunk-LKOMH3QC.js.map} +1 -1
- package/dist/{chunk-O4JH3KUE.js → chunk-MENCWIHW.js} +11 -3
- package/dist/chunk-MENCWIHW.js.map +1 -0
- package/dist/{chunk-LV73DB4G.js → chunk-MGB657EG.js} +16 -21
- package/dist/chunk-MGB657EG.js.map +1 -0
- package/dist/{chunk-PBO6SCT2.js → chunk-NXC6IEL4.js} +37 -14
- package/dist/chunk-NXC6IEL4.js.map +1 -0
- package/dist/{chunk-EBSIZYM6.js → chunk-QLLFCQU5.js} +12 -12
- package/dist/chunk-QLLFCQU5.js.map +1 -0
- package/dist/{chunk-X46FY45B.js → chunk-SKADPHAM.js} +12 -8
- package/dist/chunk-SKADPHAM.js.map +1 -0
- package/dist/{chunk-BWCGSGAC.js → chunk-TCNYSHPM.js} +165 -28
- package/dist/chunk-TCNYSHPM.js.map +1 -0
- package/dist/{chunk-JXHULIOA.js → chunk-UTHEIPEY.js} +387 -42
- package/dist/chunk-UTHEIPEY.js.map +1 -0
- package/dist/{chunk-ZJ3VRPOI.js → chunk-VE2UIJ7Y.js} +11 -15
- package/dist/chunk-VE2UIJ7Y.js.map +1 -0
- package/dist/{chunk-WBF7JLTY.js → chunk-W53D5Q52.js} +4 -4
- package/dist/{chunk-WBF7JLTY.js.map → chunk-W53D5Q52.js.map} +1 -1
- package/dist/{chunk-HNORRENR.js → chunk-WD2NRI3T.js} +5 -5
- package/dist/{chunk-HNORRENR.js.map → chunk-WD2NRI3T.js.map} +1 -1
- package/dist/cli/index.js +688 -480
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/src/asset-feeds.d.ts +17 -3
- package/dist/cli/src/asset-feeds.d.ts.map +1 -1
- package/dist/cli/src/commands/catalog.d.ts +3 -2
- package/dist/cli/src/commands/catalog.d.ts.map +1 -1
- package/dist/cli/src/commands/manage.d.ts +47 -8
- package/dist/cli/src/commands/manage.d.ts.map +1 -1
- package/dist/cli/src/commands/project.d.ts.map +1 -1
- package/dist/cli/src/commands/source.d.ts +32 -0
- package/dist/cli/src/commands/source.d.ts.map +1 -1
- package/dist/cli/src/commands/update.d.ts +7 -0
- package/dist/cli/src/commands/update.d.ts.map +1 -1
- package/dist/connectors/config.js +7 -7
- package/dist/connectors/index.js +9 -9
- package/dist/connectors/src/config.d.ts +5 -13
- package/dist/connectors/src/config.d.ts.map +1 -1
- package/dist/connectors/src/index.d.ts +1 -1
- package/dist/connectors/src/index.d.ts.map +1 -1
- package/dist/core/driver-targets.js +1 -1
- package/dist/core/index.js +6 -6
- package/dist/core/manifest.js +1 -1
- package/dist/core/runtime-assets.js +4 -3
- package/dist/core/src/cache-paths.d.ts +6 -0
- package/dist/core/src/cache-paths.d.ts.map +1 -1
- package/dist/core/src/driver-targets.d.ts +12 -7
- package/dist/core/src/driver-targets.d.ts.map +1 -1
- package/dist/core/src/index.d.ts +3 -3
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/manifest.d.ts +6 -6
- package/dist/core/src/manifest.d.ts.map +1 -1
- package/dist/core/src/workspace-config.d.ts +36 -0
- package/dist/core/src/workspace-config.d.ts.map +1 -1
- package/dist/core/store.js +2 -2
- package/dist/core/workspace-config.js +3 -2
- package/dist/deploy/index.js +6 -6
- package/dist/discovery/index.js +2 -2
- package/dist/discovery/src/atomization-conventions.d.ts +30 -0
- package/dist/discovery/src/atomization-conventions.d.ts.map +1 -0
- package/dist/discovery/src/builtin-providers.d.ts.map +1 -1
- package/dist/discovery/src/discover-manifest.d.ts.map +1 -1
- package/dist/discovery/src/discover.d.ts +38 -0
- package/dist/discovery/src/discover.d.ts.map +1 -1
- package/dist/discovery/src/index.d.ts +5 -2
- package/dist/discovery/src/index.d.ts.map +1 -1
- package/dist/discovery/src/reference-lint.d.ts +112 -0
- package/dist/discovery/src/reference-lint.d.ts.map +1 -0
- package/dist/discovery/src/requires-graph.d.ts +1 -1
- package/dist/discovery/src/tree-entries.d.ts +9 -1
- package/dist/discovery/src/tree-entries.d.ts.map +1 -1
- package/dist/{ensure-sources-EE7Z2HKS.js → ensure-sources-GJOXWVWO.js} +8 -8
- package/dist/{ensure-sources-EE7Z2HKS.js.map → ensure-sources-GJOXWVWO.js.map} +1 -1
- package/dist/factory-assets/connectors/deploy.js +9 -9
- package/dist/factory-assets/connectors/devserver.js +9 -9
- package/dist/factory-assets/connectors/flow/adapter.js +9 -9
- package/dist/factory-assets/connectors/flow/engine/flow-kind-provider.d.ts +1 -1
- package/dist/factory-assets/connectors/flow/engine/flow-kind-provider.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/engine.js +7 -7
- package/dist/factory-assets/connectors/flow/run-flow.js +10 -10
- package/dist/factory-assets/connectors/flow.js +9 -9
- package/dist/factory-assets/connectors/git.js +9 -9
- package/dist/factory-assets/connectors/gmail/adapter.d.ts.map +1 -1
- package/dist/factory-assets/connectors/gmail.js +9 -9
- package/dist/factory-assets/connectors/googledrive.js +9 -9
- package/dist/factory-assets/connectors/local.js +9 -9
- package/dist/factory-assets/connectors/mattermost/adapter.d.ts.map +1 -1
- package/dist/factory-assets/connectors/mattermost.js +9 -9
- package/dist/factory-assets/connectors/memory.js +9 -9
- package/dist/factory-assets/connectors/minio/adapter.d.ts.map +1 -1
- package/dist/factory-assets/connectors/minio.js +9 -9
- package/dist/factory-assets/connectors/postgres/adapter.d.ts.map +1 -1
- package/dist/factory-assets/connectors/postgres.js +9 -9
- package/dist/factory-assets/connectors/s3/driver.d.ts.map +1 -1
- package/dist/factory-assets/connectors/s3.js +9 -9
- package/dist/factory-assets/connectors/sharepoint.js +9 -9
- package/dist/factory-assets/connectors/sqlite/adapter.d.ts.map +1 -1
- package/dist/factory-assets/connectors/sqlite.js +9 -9
- package/dist/factory-assets/connectors/static-server.js +9 -9
- package/dist/factory-assets/connectors/tunnel.js +9 -9
- package/dist/factory-assets/connectors/webdav.js +9 -9
- package/dist/factory-assets/connectors/xstate-store.js +9 -9
- package/dist/factory-assets/connectors/xstate.js +9 -9
- package/dist/{flows-AAHXXXCH.js → flows-AGPIE6JM.js} +3 -3
- package/dist/{flows-AAHXXXCH.js.map → flows-AGPIE6JM.js.map} +1 -1
- package/dist/library/index.js +8 -8
- package/dist/library/install.js +6 -6
- package/dist/open-library-ERKRGH4B.js +23 -0
- package/dist/{open-library-TXJMFG34.js.map → open-library-ERKRGH4B.js.map} +1 -1
- package/dist/paths-D6RUQ522.js +15 -0
- package/dist/{paths-OMVC4UWY.js.map → paths-D6RUQ522.js.map} +1 -1
- package/dist/{plugin-store-JWJHIPUT.js → plugin-store-SGNJTBYS.js} +8 -8
- package/dist/{plugin-store-JWJHIPUT.js.map → plugin-store-SGNJTBYS.js.map} +1 -1
- package/dist/runner/index.js +11 -11
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +8 -8
- package/dist/sdk/core.js +6 -6
- package/dist/sdk/flow.js +7 -7
- package/dist/sdk/index.js +17 -11
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/runner.js +11 -11
- package/dist/sdk/src/transport.d.ts +2 -0
- package/dist/sdk/src/transport.d.ts.map +1 -1
- package/dist/sdk/store.js +1 -1
- package/dist/{setup-ETNBVZQA.js → setup-IV2JFW3T.js} +8 -8
- package/dist/{setup-ETNBVZQA.js.map → setup-IV2JFW3T.js.map} +1 -1
- package/dist/source-FGOMQMZT.js +24 -0
- package/dist/source-FGOMQMZT.js.map +1 -0
- package/dist/store/index.js +1 -1
- package/dist/store/src/store.d.ts.map +1 -1
- package/dist/store-client-GJT2XQ5Z.js +15 -0
- package/dist/{store-client-SLFAAKSV.js.map → store-client-GJT2XQ5Z.js.map} +1 -1
- package/dist/tui/index.js +11 -11
- package/dist/types/src/transport.d.ts +12 -0
- package/dist/types/src/transport.d.ts.map +1 -1
- package/dist/workspace-plugin/adapters/mcp.js +1 -1
- package/dist/workspace-plugin/adapters/omp.js +3 -3
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +1 -1
- package/dist/asset-feeds-O6R6J4RI.js +0 -128
- package/dist/asset-feeds-O6R6J4RI.js.map +0 -1
- package/dist/chunk-6IDBWPK2.js.map +0 -1
- package/dist/chunk-BWCGSGAC.js.map +0 -1
- package/dist/chunk-EBSIZYM6.js.map +0 -1
- package/dist/chunk-JXHULIOA.js.map +0 -1
- package/dist/chunk-LTUTK2Q3.js.map +0 -1
- package/dist/chunk-LV73DB4G.js.map +0 -1
- package/dist/chunk-O4JH3KUE.js.map +0 -1
- package/dist/chunk-PBO6SCT2.js.map +0 -1
- package/dist/chunk-X46FY45B.js.map +0 -1
- package/dist/chunk-ZJ3VRPOI.js.map +0 -1
- package/dist/open-library-TXJMFG34.js +0 -23
- package/dist/paths-OMVC4UWY.js +0 -15
- package/dist/store-client-SLFAAKSV.js +0 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetKindRegistryFrozenError, AssetKindConflictError, AssetKindPatternConflictError, AssetKindPathAmbiguityError } from './chunk-JXT46QFC.js';
|
|
2
2
|
import { decodeSkaileManifest, SKAILE_MANIFEST_FILENAME } from './chunk-DZCK7GRW.js';
|
|
3
|
-
import { parseFrontmatter } from './chunk-
|
|
3
|
+
import { parseFrontmatter } from './chunk-BQCGFPHW.js';
|
|
4
4
|
import { isValidAssetName } from './chunk-GEEW6SY2.js';
|
|
5
5
|
import { validatePersona, validateRuleset, validateSkill, validateAgent, validateConnector, validateMcpServer, validateContract, validatePrompt, validatePreset } from './chunk-CU5Z7GH3.js';
|
|
6
6
|
import * as fs from 'fs';
|
|
@@ -113,6 +113,20 @@ var AssetKindRegistry = class {
|
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
+
// discovery/src/atomization-conventions.ts
|
|
117
|
+
var SKILL_COMPANION_DIRS = [
|
|
118
|
+
"references",
|
|
119
|
+
"scripts",
|
|
120
|
+
"assets",
|
|
121
|
+
"templates",
|
|
122
|
+
"modes",
|
|
123
|
+
"bin",
|
|
124
|
+
"data",
|
|
125
|
+
"examples",
|
|
126
|
+
"hooks"
|
|
127
|
+
];
|
|
128
|
+
var AGENT_COMPANION_DIRS = ["knowledge", "prompts", "examples"];
|
|
129
|
+
|
|
116
130
|
// discovery/src/requires-graph.ts
|
|
117
131
|
function extractRequires(assetRef, kind, manifest) {
|
|
118
132
|
const edges = [];
|
|
@@ -190,12 +204,16 @@ function extractAgentRequires(ref, m, edges) {
|
|
|
190
204
|
function extractFlowRequires(ref, m, edges) {
|
|
191
205
|
if (!Array.isArray(m.nodes)) return;
|
|
192
206
|
for (const node of m.nodes) {
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
});
|
|
207
|
+
if (typeof node !== "object" || node === null) continue;
|
|
208
|
+
const n = node;
|
|
209
|
+
const data = typeof n.data === "object" && n.data !== null ? n.data : {};
|
|
210
|
+
const skill = typeof data.skill === "string" ? data.skill : n.skill;
|
|
211
|
+
if (typeof skill === "string") {
|
|
212
|
+
edges.push({ from: ref, to: skill, field: "nodes[].data.skill" });
|
|
213
|
+
}
|
|
214
|
+
const subFlow = typeof data.flow === "string" ? data.flow : n.flow;
|
|
215
|
+
if (typeof subFlow === "string") {
|
|
216
|
+
edges.push({ from: ref, to: subFlow, field: "nodes[].data.flow" });
|
|
199
217
|
}
|
|
200
218
|
}
|
|
201
219
|
}
|
|
@@ -237,31 +255,31 @@ function extractSkillRequires(ref, m, edges) {
|
|
|
237
255
|
function findCyclePath(nodes, adj) {
|
|
238
256
|
const visited = /* @__PURE__ */ new Set();
|
|
239
257
|
const stack = /* @__PURE__ */ new Set();
|
|
240
|
-
const
|
|
258
|
+
const path8 = [];
|
|
241
259
|
for (const start of nodes) {
|
|
242
260
|
if (visited.has(start)) continue;
|
|
243
|
-
const cycle = dfs(start, adj, visited, stack,
|
|
261
|
+
const cycle = dfs(start, adj, visited, stack, path8, nodes);
|
|
244
262
|
if (cycle) return cycle;
|
|
245
263
|
}
|
|
246
264
|
return [...nodes];
|
|
247
265
|
}
|
|
248
|
-
function dfs(node, adj, visited, stack,
|
|
266
|
+
function dfs(node, adj, visited, stack, path8, scope) {
|
|
249
267
|
visited.add(node);
|
|
250
268
|
stack.add(node);
|
|
251
|
-
|
|
269
|
+
path8.push(node);
|
|
252
270
|
for (const neighbor of adj.get(node) ?? []) {
|
|
253
271
|
if (!scope.has(neighbor)) continue;
|
|
254
272
|
if (stack.has(neighbor)) {
|
|
255
|
-
const cycleStart =
|
|
256
|
-
return [...
|
|
273
|
+
const cycleStart = path8.indexOf(neighbor);
|
|
274
|
+
return [...path8.slice(cycleStart), neighbor];
|
|
257
275
|
}
|
|
258
276
|
if (!visited.has(neighbor)) {
|
|
259
|
-
const result = dfs(neighbor, adj, visited, stack,
|
|
277
|
+
const result = dfs(neighbor, adj, visited, stack, path8, scope);
|
|
260
278
|
if (result) return result;
|
|
261
279
|
}
|
|
262
280
|
}
|
|
263
281
|
stack.delete(node);
|
|
264
|
-
|
|
282
|
+
path8.pop();
|
|
265
283
|
return null;
|
|
266
284
|
}
|
|
267
285
|
function isObjectWithStringField(val, field) {
|
|
@@ -303,10 +321,13 @@ function skillFilter(manifestPath) {
|
|
|
303
321
|
for (const leaf of ["validator.py", "CLI.md"]) {
|
|
304
322
|
if (fs.existsSync(path.join(dir, leaf))) files.push(leaf);
|
|
305
323
|
}
|
|
306
|
-
|
|
324
|
+
const companions = new Set(SKILL_COMPANION_DIRS);
|
|
325
|
+
for (const sub of SKILL_COMPANION_DIRS) {
|
|
326
|
+
files.push(...collectDirRecursive(dir, sub));
|
|
327
|
+
}
|
|
307
328
|
try {
|
|
308
329
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
309
|
-
if (entry.isDirectory() && entry.name
|
|
330
|
+
if (entry.isDirectory() && !companions.has(entry.name)) {
|
|
310
331
|
if (fs.existsSync(path.join(dir, entry.name, "SKILL.md"))) {
|
|
311
332
|
files.push(...collectDirRecursive(dir, entry.name));
|
|
312
333
|
}
|
|
@@ -324,7 +345,9 @@ function agentFilter(manifestPath) {
|
|
|
324
345
|
for (const companion of ["SOUL.md", "RULES.md"]) {
|
|
325
346
|
if (fs.existsSync(path.join(dir, companion))) files.push(companion);
|
|
326
347
|
}
|
|
327
|
-
|
|
348
|
+
for (const sub of AGENT_COMPANION_DIRS) {
|
|
349
|
+
files.push(...collectDirRecursive(dir, sub));
|
|
350
|
+
}
|
|
328
351
|
files.sort();
|
|
329
352
|
return { assetRoot: dir, files };
|
|
330
353
|
}
|
|
@@ -814,7 +837,7 @@ function discoverFromManifest(rootPath, sourceConfig, registry, includeDev = fal
|
|
|
814
837
|
}
|
|
815
838
|
}
|
|
816
839
|
const graph = buildRequiresGraph(allEdges);
|
|
817
|
-
return { assets, graph, errors };
|
|
840
|
+
return { assets, graph, errors, warnings: [] };
|
|
818
841
|
}
|
|
819
842
|
function processEntry(rootPath, entry, registry) {
|
|
820
843
|
const errors = [];
|
|
@@ -1169,8 +1192,159 @@ function applyDomains(assets, domains) {
|
|
|
1169
1192
|
);
|
|
1170
1193
|
return { domains: ordered, errors };
|
|
1171
1194
|
}
|
|
1195
|
+
var SCANNABLE_EXT = /* @__PURE__ */ new Set([".md", ".mdx", ".markdown", ".txt"]);
|
|
1196
|
+
function isNonLocal(token) {
|
|
1197
|
+
return token.length === 0 || token.startsWith("#") || token.startsWith("//") || /^[a-z][a-z0-9+.-]*:/i.test(token);
|
|
1198
|
+
}
|
|
1199
|
+
function extractPathCandidates(text) {
|
|
1200
|
+
const out = /* @__PURE__ */ new Set();
|
|
1201
|
+
for (const m of text.matchAll(/!?\[[^\]]*\]\(\s*<?([^)>\s]+)>?(?:\s+"[^"]*")?\s*\)/g)) {
|
|
1202
|
+
if (m[1]) out.add(m[1]);
|
|
1203
|
+
}
|
|
1204
|
+
for (const m of text.matchAll(/`([^`\n]+)`/g)) {
|
|
1205
|
+
const tok = m[1]?.trim();
|
|
1206
|
+
if (tok) out.add(tok);
|
|
1207
|
+
}
|
|
1208
|
+
for (const m of text.matchAll(/(?:\.{0,2}\/)?(?:[\w.@-]+\/)+[\w.@-]*/g)) {
|
|
1209
|
+
if (m[0]) out.add(m[0]);
|
|
1210
|
+
}
|
|
1211
|
+
return [...out];
|
|
1212
|
+
}
|
|
1213
|
+
function looksLikePath(token) {
|
|
1214
|
+
if (isNonLocal(token)) return false;
|
|
1215
|
+
const clean = token.split(/[#?]/, 1)[0] ?? token;
|
|
1216
|
+
if (clean.length === 0) return false;
|
|
1217
|
+
if (clean.includes("/")) return true;
|
|
1218
|
+
return /\.[a-z0-9]{1,6}$/i.test(clean);
|
|
1219
|
+
}
|
|
1220
|
+
function cleanToken(token) {
|
|
1221
|
+
const clean = (token.split(/[#?]/, 1)[0] ?? token).trim();
|
|
1222
|
+
return clean.endsWith("/") ? clean.slice(0, -1) : clean;
|
|
1223
|
+
}
|
|
1224
|
+
function createNodeAssetFs(assetRoot) {
|
|
1225
|
+
const listFilesUnder = (rel) => {
|
|
1226
|
+
const full = path.join(assetRoot, rel);
|
|
1227
|
+
let stat;
|
|
1228
|
+
try {
|
|
1229
|
+
stat = fs.statSync(full);
|
|
1230
|
+
} catch {
|
|
1231
|
+
return [];
|
|
1232
|
+
}
|
|
1233
|
+
if (!stat.isDirectory()) return [rel];
|
|
1234
|
+
const out = [];
|
|
1235
|
+
for (const entry of fs.readdirSync(full, { withFileTypes: true })) {
|
|
1236
|
+
const childRel = path.posix.join(rel, entry.name);
|
|
1237
|
+
if (entry.isDirectory()) out.push(...listFilesUnder(childRel));
|
|
1238
|
+
else if (entry.isFile()) out.push(childRel);
|
|
1239
|
+
}
|
|
1240
|
+
return out;
|
|
1241
|
+
};
|
|
1242
|
+
return {
|
|
1243
|
+
readText(rel) {
|
|
1244
|
+
try {
|
|
1245
|
+
return fs.readFileSync(path.join(assetRoot, rel), "utf-8");
|
|
1246
|
+
} catch {
|
|
1247
|
+
return null;
|
|
1248
|
+
}
|
|
1249
|
+
},
|
|
1250
|
+
statKind(rel) {
|
|
1251
|
+
try {
|
|
1252
|
+
return fs.statSync(path.join(assetRoot, rel)).isDirectory() ? "dir" : "file";
|
|
1253
|
+
} catch {
|
|
1254
|
+
return "absent";
|
|
1255
|
+
}
|
|
1256
|
+
},
|
|
1257
|
+
listFilesUnder
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
function toFs(assetRootOrFs) {
|
|
1261
|
+
return typeof assetRootOrFs === "string" ? createNodeAssetFs(assetRootOrFs) : assetRootOrFs;
|
|
1262
|
+
}
|
|
1263
|
+
function scanAssetReferences(assetRootOrFs, includedFiles) {
|
|
1264
|
+
const afs = toFs(assetRootOrFs);
|
|
1265
|
+
const included = new Set(includedFiles);
|
|
1266
|
+
const isCoveredDir = (rel) => includedFiles.some((f) => f.startsWith(`${rel}/`));
|
|
1267
|
+
const results = [];
|
|
1268
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1269
|
+
for (const fromFile of includedFiles) {
|
|
1270
|
+
if (!SCANNABLE_EXT.has(path.posix.extname(fromFile).toLowerCase())) continue;
|
|
1271
|
+
const text = afs.readText(fromFile);
|
|
1272
|
+
if (text === null) continue;
|
|
1273
|
+
const fromDir = path.posix.dirname(fromFile);
|
|
1274
|
+
for (const raw of extractPathCandidates(text)) {
|
|
1275
|
+
if (!looksLikePath(raw)) continue;
|
|
1276
|
+
const clean = cleanToken(raw);
|
|
1277
|
+
if (clean.length === 0) continue;
|
|
1278
|
+
const joined = path.posix.normalize(
|
|
1279
|
+
fromDir === "." ? clean : path.posix.join(fromDir, clean)
|
|
1280
|
+
);
|
|
1281
|
+
const dedup = `${fromFile}\0${joined}`;
|
|
1282
|
+
if (seen.has(dedup)) continue;
|
|
1283
|
+
seen.add(dedup);
|
|
1284
|
+
if (joined === ".." || joined.startsWith("../")) {
|
|
1285
|
+
results.push({ fromFile, raw, resolved: joined, isDir: false, classification: "external" });
|
|
1286
|
+
continue;
|
|
1287
|
+
}
|
|
1288
|
+
const kind = afs.statKind(joined);
|
|
1289
|
+
if (kind === "absent") {
|
|
1290
|
+
results.push({
|
|
1291
|
+
fromFile,
|
|
1292
|
+
raw,
|
|
1293
|
+
resolved: joined,
|
|
1294
|
+
isDir: false,
|
|
1295
|
+
classification: "unresolved"
|
|
1296
|
+
});
|
|
1297
|
+
continue;
|
|
1298
|
+
}
|
|
1299
|
+
const isDir = kind === "dir";
|
|
1300
|
+
const covered = isDir ? isCoveredDir(joined) : included.has(joined);
|
|
1301
|
+
results.push({
|
|
1302
|
+
fromFile,
|
|
1303
|
+
raw,
|
|
1304
|
+
resolved: joined,
|
|
1305
|
+
isDir,
|
|
1306
|
+
classification: covered ? "covered" : "uncovered-in-dir"
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
return results;
|
|
1311
|
+
}
|
|
1312
|
+
function closeOverReferences(assetRootOrFs, seedFiles) {
|
|
1313
|
+
const afs = toFs(assetRootOrFs);
|
|
1314
|
+
const included = new Set(seedFiles);
|
|
1315
|
+
const added = /* @__PURE__ */ new Set();
|
|
1316
|
+
for (; ; ) {
|
|
1317
|
+
let grew = false;
|
|
1318
|
+
for (const r of scanAssetReferences(afs, [...included])) {
|
|
1319
|
+
if (r.classification !== "uncovered-in-dir") continue;
|
|
1320
|
+
for (const f of afs.listFilesUnder(r.resolved)) {
|
|
1321
|
+
if (!included.has(f)) {
|
|
1322
|
+
included.add(f);
|
|
1323
|
+
added.add(f);
|
|
1324
|
+
grew = true;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
if (!grew) break;
|
|
1329
|
+
}
|
|
1330
|
+
return { files: [...included].sort(), added: [...added].sort() };
|
|
1331
|
+
}
|
|
1332
|
+
function lintUncoveredReferences(manifestRelPath, assetRootOrFs, includedFiles) {
|
|
1333
|
+
const refs = scanAssetReferences(assetRootOrFs, includedFiles);
|
|
1334
|
+
const targets = /* @__PURE__ */ new Map();
|
|
1335
|
+
for (const r of refs) {
|
|
1336
|
+
if (r.classification === "uncovered-in-dir" && !targets.has(r.resolved)) {
|
|
1337
|
+
targets.set(r.resolved, r.raw);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
return [...targets.entries()].map(([resolved, raw]) => ({
|
|
1341
|
+
path: manifestRelPath,
|
|
1342
|
+
warning: `references "${raw}" \u2192 ${resolved}, which exists in the asset directory but is not captured by the file filter`
|
|
1343
|
+
}));
|
|
1344
|
+
}
|
|
1172
1345
|
|
|
1173
1346
|
// discovery/src/discover.ts
|
|
1347
|
+
var DEFAULT_ATOMIZATION_POLICY = "strict";
|
|
1174
1348
|
function createDefaultRegistry() {
|
|
1175
1349
|
const registry = new AssetKindRegistry();
|
|
1176
1350
|
for (const provider of BUILTIN_PROVIDERS) {
|
|
@@ -1179,10 +1353,7 @@ function createDefaultRegistry() {
|
|
|
1179
1353
|
return registry;
|
|
1180
1354
|
}
|
|
1181
1355
|
function discoverAssetsInTree(rootPath, optionsOrSourceConfig) {
|
|
1182
|
-
const { sourceConfig, registry, includeDev, sidecarPath, domainFiles } = normalizeDiscoveryArgs(
|
|
1183
|
-
rootPath,
|
|
1184
|
-
optionsOrSourceConfig
|
|
1185
|
-
);
|
|
1356
|
+
const { sourceConfig, registry, includeDev, sidecarPath, domainFiles, atomization } = normalizeDiscoveryArgs(rootPath, optionsOrSourceConfig);
|
|
1186
1357
|
const domainMds = domainFiles ? domainFiles.map((f) => parseDomainMd(f.path, parseDomainFrontmatter(f.content))) : collectDomainMds(sidecarPath ?? rootPath);
|
|
1187
1358
|
if (sourceConfig && isManifestMode(sourceConfig)) {
|
|
1188
1359
|
return finalizeDomains(
|
|
@@ -1192,6 +1363,7 @@ function discoverAssetsInTree(rootPath, optionsOrSourceConfig) {
|
|
|
1192
1363
|
}
|
|
1193
1364
|
const assets = [];
|
|
1194
1365
|
const errors = [];
|
|
1366
|
+
const warnings = [];
|
|
1195
1367
|
const allEdges = [];
|
|
1196
1368
|
const devPaths = sourceConfig?.dev_paths ?? [];
|
|
1197
1369
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -1214,12 +1386,13 @@ function discoverAssetsInTree(rootPath, optionsOrSourceConfig) {
|
|
|
1214
1386
|
seen.add(dedupKey);
|
|
1215
1387
|
processDiscoveredEntry(
|
|
1216
1388
|
{ absPath, relativePath, kind },
|
|
1217
|
-
{ registry, sourceConfig },
|
|
1218
|
-
{ assets, errors, allEdges }
|
|
1389
|
+
{ registry, sourceConfig, atomization },
|
|
1390
|
+
{ assets, errors, warnings, allEdges }
|
|
1219
1391
|
);
|
|
1220
1392
|
}
|
|
1393
|
+
allEdges.push(...extractBodyLinkEdges(assets));
|
|
1221
1394
|
const graph = buildRequiresGraph(allEdges);
|
|
1222
|
-
return finalizeDomains({ assets, graph, errors }, domainMds);
|
|
1395
|
+
return finalizeDomains({ assets, graph, errors, warnings }, domainMds);
|
|
1223
1396
|
}
|
|
1224
1397
|
function parseDomainFrontmatter(content) {
|
|
1225
1398
|
const { data } = parseFrontmatter(content);
|
|
@@ -1251,12 +1424,14 @@ function normalizeDiscoveryArgs(rootPath, optionsOrSourceConfig) {
|
|
|
1251
1424
|
let sidecarPath;
|
|
1252
1425
|
let includeDev = false;
|
|
1253
1426
|
let domainFiles;
|
|
1254
|
-
|
|
1427
|
+
let atomization = DEFAULT_ATOMIZATION_POLICY;
|
|
1428
|
+
if (optionsOrSourceConfig && ("registry" in optionsOrSourceConfig || "sourceConfig" in optionsOrSourceConfig || "sidecarPath" in optionsOrSourceConfig || "domainFiles" in optionsOrSourceConfig || "atomization" in optionsOrSourceConfig || "includeDev" in optionsOrSourceConfig)) {
|
|
1255
1429
|
sourceConfig = optionsOrSourceConfig.sourceConfig;
|
|
1256
1430
|
registry = optionsOrSourceConfig.registry;
|
|
1257
1431
|
sidecarPath = optionsOrSourceConfig.sidecarPath;
|
|
1258
1432
|
includeDev = optionsOrSourceConfig.includeDev ?? false;
|
|
1259
1433
|
domainFiles = optionsOrSourceConfig.domainFiles;
|
|
1434
|
+
atomization = optionsOrSourceConfig.atomization ?? DEFAULT_ATOMIZATION_POLICY;
|
|
1260
1435
|
} else {
|
|
1261
1436
|
sourceConfig = optionsOrSourceConfig;
|
|
1262
1437
|
}
|
|
@@ -1269,11 +1444,11 @@ function normalizeDiscoveryArgs(rootPath, optionsOrSourceConfig) {
|
|
|
1269
1444
|
sourceConfig = merged.config;
|
|
1270
1445
|
}
|
|
1271
1446
|
}
|
|
1272
|
-
return { sourceConfig, registry, includeDev, sidecarPath, domainFiles };
|
|
1447
|
+
return { sourceConfig, registry, includeDev, sidecarPath, domainFiles, atomization };
|
|
1273
1448
|
}
|
|
1274
1449
|
function processDiscoveredEntry(entry, ctx, acc) {
|
|
1275
1450
|
const { absPath, relativePath, kind } = entry;
|
|
1276
|
-
const { registry, sourceConfig } = ctx;
|
|
1451
|
+
const { registry, sourceConfig, atomization } = ctx;
|
|
1277
1452
|
try {
|
|
1278
1453
|
const manifest = parseManifest2(absPath);
|
|
1279
1454
|
if (!manifest) {
|
|
@@ -1288,6 +1463,7 @@ function processDiscoveredEntry(entry, ctx, acc) {
|
|
|
1288
1463
|
assetRoot: path.dirname(absPath),
|
|
1289
1464
|
files: [path.basename(absPath)]
|
|
1290
1465
|
};
|
|
1466
|
+
applyAtomizationPolicy(atomization, relativePath, fileFilter, registry, acc.warnings);
|
|
1291
1467
|
const sha256 = computeDeterministicHash(fileFilter.assetRoot, fileFilter.files);
|
|
1292
1468
|
const requires = registry.extractRequires(kind, ref, manifest);
|
|
1293
1469
|
acc.allEdges.push(...requires);
|
|
@@ -1311,6 +1487,61 @@ function processDiscoveredEntry(entry, ctx, acc) {
|
|
|
1311
1487
|
});
|
|
1312
1488
|
}
|
|
1313
1489
|
}
|
|
1490
|
+
function applyAtomizationPolicy(policy, relativePath, fileFilter, registry, warnings) {
|
|
1491
|
+
if (policy === "strict") {
|
|
1492
|
+
warnings.push(...lintUncoveredReferences(relativePath, fileFilter.assetRoot, fileFilter.files));
|
|
1493
|
+
return;
|
|
1494
|
+
}
|
|
1495
|
+
const structural = new Set(fileFilter.files);
|
|
1496
|
+
const expanded = policy === "full-dir" ? collectFullDirFiles(fileFilter.assetRoot, registry) : closeOverReferences(fileFilter.assetRoot, fileFilter.files).files;
|
|
1497
|
+
fileFilter.files = expanded;
|
|
1498
|
+
const reason = policy === "full-dir" ? "full-dir capture" : "reference closure (referenced but uncaptured)";
|
|
1499
|
+
for (const f of expanded) {
|
|
1500
|
+
if (!structural.has(f)) {
|
|
1501
|
+
warnings.push({ path: relativePath, warning: `captured "${f}" via ${reason}` });
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
function collectFullDirFiles(assetRoot, registry) {
|
|
1506
|
+
const all = [];
|
|
1507
|
+
const nestedDirs = [];
|
|
1508
|
+
for (const { relativePath } of walkTree(assetRoot)) {
|
|
1509
|
+
all.push(relativePath);
|
|
1510
|
+
const dir = path.posix.dirname(relativePath);
|
|
1511
|
+
if (dir === ".") continue;
|
|
1512
|
+
let kind;
|
|
1513
|
+
try {
|
|
1514
|
+
kind = registry.resolveKind(relativePath);
|
|
1515
|
+
} catch {
|
|
1516
|
+
kind = void 0;
|
|
1517
|
+
}
|
|
1518
|
+
if (kind) nestedDirs.push(dir);
|
|
1519
|
+
}
|
|
1520
|
+
const carved = [...new Set(nestedDirs)];
|
|
1521
|
+
const inCarvedSubtree = (file) => carved.some((d) => file.startsWith(`${d}/`));
|
|
1522
|
+
return all.filter((f) => !inCarvedSubtree(f)).sort();
|
|
1523
|
+
}
|
|
1524
|
+
function extractBodyLinkEdges(assets) {
|
|
1525
|
+
const roots = assets.map((a) => ({ root: a.fileFilter.assetRoot, ref: a.ref })).sort((x, y) => y.root.length - x.root.length);
|
|
1526
|
+
const edges = [];
|
|
1527
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1528
|
+
for (const asset of assets) {
|
|
1529
|
+
const root = asset.fileFilter.assetRoot;
|
|
1530
|
+
for (const r of scanAssetReferences(root, asset.fileFilter.files)) {
|
|
1531
|
+
if (r.classification !== "external") continue;
|
|
1532
|
+
const target = path.resolve(root, r.resolved);
|
|
1533
|
+
const hit = roots.find(
|
|
1534
|
+
(cand) => cand.ref !== asset.ref && (target === cand.root || target.startsWith(`${cand.root}${path.sep}`))
|
|
1535
|
+
);
|
|
1536
|
+
if (!hit) continue;
|
|
1537
|
+
const key = `${asset.ref}\0${hit.ref}`;
|
|
1538
|
+
if (seen.has(key)) continue;
|
|
1539
|
+
seen.add(key);
|
|
1540
|
+
edges.push({ from: asset.ref, to: hit.ref, field: "body-link" });
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
return edges;
|
|
1544
|
+
}
|
|
1314
1545
|
function* walkTree(rootDir) {
|
|
1315
1546
|
function* walk(dir, relDir) {
|
|
1316
1547
|
let entries;
|
|
@@ -1409,6 +1640,7 @@ function deriveName(relativePath, kind, manifest) {
|
|
|
1409
1640
|
async function discoverAssetsInTreeEntries(entries, options) {
|
|
1410
1641
|
const registry = options.registry ?? createDefaultRegistry();
|
|
1411
1642
|
const includeDev = options.includeDev ?? false;
|
|
1643
|
+
const atomization = options.atomization ?? DEFAULT_ATOMIZATION_POLICY;
|
|
1412
1644
|
const blobByPath = /* @__PURE__ */ new Map();
|
|
1413
1645
|
for (const entry of entries) {
|
|
1414
1646
|
if (entry.type === "blob") {
|
|
@@ -1438,6 +1670,7 @@ async function discoverAssetsInTreeEntries(entries, options) {
|
|
|
1438
1670
|
const sortedBlobPaths = [...blobByPath.keys()].sort();
|
|
1439
1671
|
const assets = [];
|
|
1440
1672
|
const errors = [];
|
|
1673
|
+
const warnings = [];
|
|
1441
1674
|
const allEdges = [];
|
|
1442
1675
|
const seen = /* @__PURE__ */ new Set();
|
|
1443
1676
|
for (const relativePath of sortedBlobPaths) {
|
|
@@ -1455,14 +1688,17 @@ async function discoverAssetsInTreeEntries(entries, options) {
|
|
|
1455
1688
|
options.fetchBlob,
|
|
1456
1689
|
resolvedSourceConfig,
|
|
1457
1690
|
registry,
|
|
1458
|
-
|
|
1691
|
+
atomization,
|
|
1692
|
+
errors,
|
|
1693
|
+
warnings
|
|
1459
1694
|
);
|
|
1460
1695
|
if (!result) continue;
|
|
1461
1696
|
allEdges.push(...result.requires);
|
|
1462
1697
|
assets.push(result);
|
|
1463
1698
|
}
|
|
1699
|
+
allEdges.push(...await extractBodyLinkEdgesTree(assets, blobByPath, options.fetchBlob));
|
|
1464
1700
|
const graph = buildRequiresGraph(allEdges);
|
|
1465
|
-
return finalizeDomains2({ assets, graph, errors }, domainMds);
|
|
1701
|
+
return finalizeDomains2({ assets, graph, errors, warnings }, domainMds);
|
|
1466
1702
|
}
|
|
1467
1703
|
function parseDomainFrontmatter2(content) {
|
|
1468
1704
|
const { data } = parseFrontmatter(content);
|
|
@@ -1507,7 +1743,7 @@ function resolveKindForPath(relativePath, registry, errors) {
|
|
|
1507
1743
|
return void 0;
|
|
1508
1744
|
}
|
|
1509
1745
|
}
|
|
1510
|
-
async function buildAssetFromBlob(relativePath, kind, blobByPath, fetchBlob, resolvedSourceConfig, registry, errors) {
|
|
1746
|
+
async function buildAssetFromBlob(relativePath, kind, blobByPath, fetchBlob, resolvedSourceConfig, registry, atomization, errors, warnings) {
|
|
1511
1747
|
const manifestEntry = blobByPath.get(relativePath);
|
|
1512
1748
|
if (!manifestEntry) {
|
|
1513
1749
|
errors.push({ path: relativePath, error: "Manifest blob disappeared from tree index" });
|
|
@@ -1538,6 +1774,16 @@ async function buildAssetFromBlob(relativePath, kind, blobByPath, fetchBlob, res
|
|
|
1538
1774
|
const version = coerceVersion2(manifest);
|
|
1539
1775
|
const ref = `${publisher}/${name}@${version}`;
|
|
1540
1776
|
const fileFilter = computeFileFilter(kind, relativePath, blobByPath);
|
|
1777
|
+
warnings.push(
|
|
1778
|
+
...await applyAtomizationPolicyTree(
|
|
1779
|
+
atomization,
|
|
1780
|
+
relativePath,
|
|
1781
|
+
fileFilter,
|
|
1782
|
+
blobByPath,
|
|
1783
|
+
fetchBlob,
|
|
1784
|
+
registry
|
|
1785
|
+
)
|
|
1786
|
+
);
|
|
1541
1787
|
let sha256;
|
|
1542
1788
|
try {
|
|
1543
1789
|
sha256 = await computeDeterministicHashFromTree(fileFilter, blobByPath, fetchBlob);
|
|
@@ -1667,14 +1913,14 @@ function skillFilterVirtual(dir, manifestName, blobByPath) {
|
|
|
1667
1913
|
const remainder = blobPath.slice(dir === "" ? 0 : dir.length + 1);
|
|
1668
1914
|
const slash = remainder.indexOf("/");
|
|
1669
1915
|
if (slash === -1) continue;
|
|
1670
|
-
|
|
1671
|
-
directChildDirs.add(childDir);
|
|
1916
|
+
directChildDirs.add(remainder.slice(0, slash));
|
|
1672
1917
|
}
|
|
1673
|
-
|
|
1674
|
-
|
|
1918
|
+
const companions = new Set(SKILL_COMPANION_DIRS);
|
|
1919
|
+
for (const sub of SKILL_COMPANION_DIRS) {
|
|
1920
|
+
if (directChildDirs.has(sub)) addAllUnder(files, dir, sub, blobByPath);
|
|
1675
1921
|
}
|
|
1676
1922
|
for (const childDir of directChildDirs) {
|
|
1677
|
-
if (childDir
|
|
1923
|
+
if (companions.has(childDir)) continue;
|
|
1678
1924
|
if (blobByPath.has(joinPosix(dir, childDir, "SKILL.md"))) {
|
|
1679
1925
|
addAllUnder(files, dir, childDir, blobByPath);
|
|
1680
1926
|
}
|
|
@@ -1686,7 +1932,9 @@ function agentFilterVirtual(dir, manifestName, blobByPath) {
|
|
|
1686
1932
|
for (const companion of ["SOUL.md", "RULES.md"]) {
|
|
1687
1933
|
if (blobByPath.has(joinPosix(dir, companion))) files.add(companion);
|
|
1688
1934
|
}
|
|
1689
|
-
|
|
1935
|
+
for (const sub of AGENT_COMPANION_DIRS) {
|
|
1936
|
+
addAllUnder(files, dir, sub, blobByPath);
|
|
1937
|
+
}
|
|
1690
1938
|
return { assetRoot: dir, files: [...files].sort() };
|
|
1691
1939
|
}
|
|
1692
1940
|
function contractFilterVirtual(dir, manifestName, blobByPath) {
|
|
@@ -1724,6 +1972,103 @@ async function computeDeterministicHashFromTree(fileFilter, blobByPath, fetchBlo
|
|
|
1724
1972
|
}
|
|
1725
1973
|
return hash.digest("hex");
|
|
1726
1974
|
}
|
|
1975
|
+
var TREE_SCANNABLE_EXT = /* @__PURE__ */ new Set([".md", ".mdx", ".markdown", ".txt"]);
|
|
1976
|
+
async function prefetchAssetText(assetRoot, blobByPath, fetchBlob) {
|
|
1977
|
+
const prefix = assetRoot === "" ? "" : `${assetRoot}/`;
|
|
1978
|
+
const out = /* @__PURE__ */ new Map();
|
|
1979
|
+
for (const [full, entry] of blobByPath) {
|
|
1980
|
+
if (assetRoot !== "" && !full.startsWith(prefix)) continue;
|
|
1981
|
+
if (!TREE_SCANNABLE_EXT.has(path.posix.extname(full).toLowerCase())) continue;
|
|
1982
|
+
let bytes;
|
|
1983
|
+
try {
|
|
1984
|
+
bytes = await fetchAsBuffer(fetchBlob, entry.sha);
|
|
1985
|
+
} catch {
|
|
1986
|
+
bytes = null;
|
|
1987
|
+
}
|
|
1988
|
+
if (bytes) out.set(full, bytes.toString("utf-8"));
|
|
1989
|
+
}
|
|
1990
|
+
return out;
|
|
1991
|
+
}
|
|
1992
|
+
function createTreeAssetFs(assetRoot, blobByPath, textByPath) {
|
|
1993
|
+
const full = (rel) => joinPosix(assetRoot, rel);
|
|
1994
|
+
return {
|
|
1995
|
+
readText(rel) {
|
|
1996
|
+
return textByPath.get(full(rel)) ?? null;
|
|
1997
|
+
},
|
|
1998
|
+
statKind(rel) {
|
|
1999
|
+
const f = full(rel);
|
|
2000
|
+
if (blobByPath.has(f)) return "file";
|
|
2001
|
+
const dirPrefix = `${f}/`;
|
|
2002
|
+
for (const k of blobByPath.keys()) if (k.startsWith(dirPrefix)) return "dir";
|
|
2003
|
+
return "absent";
|
|
2004
|
+
},
|
|
2005
|
+
listFilesUnder(rel) {
|
|
2006
|
+
const f = full(rel);
|
|
2007
|
+
if (blobByPath.has(f)) return [rel];
|
|
2008
|
+
const dirPrefix = `${f}/`;
|
|
2009
|
+
const out = [];
|
|
2010
|
+
for (const k of blobByPath.keys()) {
|
|
2011
|
+
if (k.startsWith(dirPrefix)) out.push(assetRoot === "" ? k : k.slice(assetRoot.length + 1));
|
|
2012
|
+
}
|
|
2013
|
+
return out;
|
|
2014
|
+
}
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
function collectFullDirFilesTree(assetRoot, blobByPath, registry) {
|
|
2018
|
+
const prefix = assetRoot === "" ? "" : `${assetRoot}/`;
|
|
2019
|
+
const all = [];
|
|
2020
|
+
const nestedDirs = [];
|
|
2021
|
+
for (const full of blobByPath.keys()) {
|
|
2022
|
+
if (assetRoot !== "" && !full.startsWith(prefix)) continue;
|
|
2023
|
+
const rel = assetRoot === "" ? full : full.slice(assetRoot.length + 1);
|
|
2024
|
+
all.push(rel);
|
|
2025
|
+
if (rel.includes("/")) {
|
|
2026
|
+
let kind;
|
|
2027
|
+
try {
|
|
2028
|
+
kind = registry.resolveKind(rel);
|
|
2029
|
+
} catch {
|
|
2030
|
+
kind = void 0;
|
|
2031
|
+
}
|
|
2032
|
+
if (kind) nestedDirs.push(posixDirname2(rel));
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
const carved = [...new Set(nestedDirs)];
|
|
2036
|
+
return all.filter((rel) => !carved.some((d) => rel.startsWith(`${d}/`))).sort();
|
|
2037
|
+
}
|
|
2038
|
+
async function applyAtomizationPolicyTree(policy, relativePath, fileFilter, blobByPath, fetchBlob, registry) {
|
|
2039
|
+
const textByPath = await prefetchAssetText(fileFilter.assetRoot, blobByPath, fetchBlob);
|
|
2040
|
+
const afs = createTreeAssetFs(fileFilter.assetRoot, blobByPath, textByPath);
|
|
2041
|
+
if (policy === "strict") {
|
|
2042
|
+
return lintUncoveredReferences(relativePath, afs, fileFilter.files);
|
|
2043
|
+
}
|
|
2044
|
+
const structural = new Set(fileFilter.files);
|
|
2045
|
+
fileFilter.files = policy === "full-dir" ? collectFullDirFilesTree(fileFilter.assetRoot, blobByPath, registry) : closeOverReferences(afs, fileFilter.files).files;
|
|
2046
|
+
const reason = policy === "full-dir" ? "full-dir capture" : "reference closure (referenced but uncaptured)";
|
|
2047
|
+
return fileFilter.files.filter((f) => !structural.has(f)).map((f) => ({ path: relativePath, warning: `captured "${f}" via ${reason}` }));
|
|
2048
|
+
}
|
|
2049
|
+
async function extractBodyLinkEdgesTree(assets, blobByPath, fetchBlob) {
|
|
2050
|
+
const roots = assets.map((a) => ({ root: a.fileFilter.assetRoot, ref: a.ref })).sort((x, y) => y.root.length - x.root.length);
|
|
2051
|
+
const edges = [];
|
|
2052
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2053
|
+
for (const asset of assets) {
|
|
2054
|
+
const root = asset.fileFilter.assetRoot;
|
|
2055
|
+
const textByPath = await prefetchAssetText(root, blobByPath, fetchBlob);
|
|
2056
|
+
const afs = createTreeAssetFs(root, blobByPath, textByPath);
|
|
2057
|
+
for (const r of scanAssetReferences(afs, asset.fileFilter.files)) {
|
|
2058
|
+
if (r.classification !== "external") continue;
|
|
2059
|
+
const target = path.posix.normalize(joinPosix(root, r.resolved));
|
|
2060
|
+
const hit = roots.find(
|
|
2061
|
+
(cand) => cand.ref !== asset.ref && (target === cand.root || target.startsWith(`${cand.root}/`))
|
|
2062
|
+
);
|
|
2063
|
+
if (!hit) continue;
|
|
2064
|
+
const key = `${asset.ref} ${hit.ref}`;
|
|
2065
|
+
if (seen.has(key)) continue;
|
|
2066
|
+
seen.add(key);
|
|
2067
|
+
edges.push({ from: asset.ref, to: hit.ref, field: "body-link" });
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
return edges;
|
|
2071
|
+
}
|
|
1727
2072
|
function posixDirname2(p) {
|
|
1728
2073
|
const i = p.lastIndexOf("/");
|
|
1729
2074
|
return i === -1 ? "" : p.slice(0, i);
|
|
@@ -1785,7 +2130,7 @@ async function discoverFromManifestTree(sourceConfig, blobByPath, fetchBlob, reg
|
|
|
1785
2130
|
}
|
|
1786
2131
|
}
|
|
1787
2132
|
const graph = buildRequiresGraph(allEdges);
|
|
1788
|
-
return { assets, graph, errors };
|
|
2133
|
+
return { assets, graph, errors, warnings: [] };
|
|
1789
2134
|
}
|
|
1790
2135
|
async function processManifestEntryTree(entry, blobByPath, fetchBlob, registry) {
|
|
1791
2136
|
const errors = [];
|
|
@@ -1998,6 +2343,6 @@ function validateRequiresSyntax2(requires) {
|
|
|
1998
2343
|
// discovery/src/index.ts
|
|
1999
2344
|
var VERSION = "0.0.0";
|
|
2000
2345
|
|
|
2001
|
-
export { AssetKindRegistry, BUILTIN_PROVIDERS, DOMAIN_MD_FILENAME, SEMVER_RE, SourceConfigSchema, VERSION, agentProvider, assignDomain, buildDomainIndex, buildRequiresGraph, computeDeterministicHash, computeDeterministicHashDetailed, connectorProvider, contractProvider, createDefaultRegistry, decodeManifestSourceConfig, detectCycles, discoverAssetsInTree, discoverAssetsInTreeEntries, discoverFromManifest, extractRequires, isDomainMdPath, isExcludedDevPath, isManifestMode, loadMergedSourceConfig, loadSourceConfig, manifestToSourceConfig, mcpServerProvider, mergeSourceConfigs, parseDomainMd, parseSourceConfig, personaProvider, presetProvider, promptProvider, readManifestSourceConfig, rulesetProvider, skillProvider, validateDomains, validateSourceConfig };
|
|
2002
|
-
//# sourceMappingURL=chunk-
|
|
2003
|
-
//# sourceMappingURL=chunk-
|
|
2346
|
+
export { AGENT_COMPANION_DIRS, AssetKindRegistry, BUILTIN_PROVIDERS, DEFAULT_ATOMIZATION_POLICY, DOMAIN_MD_FILENAME, SEMVER_RE, SKILL_COMPANION_DIRS, SourceConfigSchema, VERSION, agentProvider, assignDomain, buildDomainIndex, buildRequiresGraph, closeOverReferences, computeDeterministicHash, computeDeterministicHashDetailed, connectorProvider, contractProvider, createDefaultRegistry, createNodeAssetFs, decodeManifestSourceConfig, detectCycles, discoverAssetsInTree, discoverAssetsInTreeEntries, discoverFromManifest, extractPathCandidates, extractRequires, isDomainMdPath, isExcludedDevPath, isManifestMode, lintUncoveredReferences, loadMergedSourceConfig, loadSourceConfig, manifestToSourceConfig, mcpServerProvider, mergeSourceConfigs, parseDomainMd, parseSourceConfig, personaProvider, presetProvider, promptProvider, readManifestSourceConfig, rulesetProvider, scanAssetReferences, skillProvider, validateDomains, validateSourceConfig };
|
|
2347
|
+
//# sourceMappingURL=chunk-UTHEIPEY.js.map
|
|
2348
|
+
//# sourceMappingURL=chunk-UTHEIPEY.js.map
|