akm-cli 0.10.261128 → 0.10.261129-beta.1
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 +20 -0
- package/dist/cli.js +2 -0
- package/dist/commands/agent/contribute-cli.js +7 -1
- package/dist/commands/backups-cli.js +103 -0
- package/dist/commands/health.js +1 -34
- package/dist/commands/improve/reflect-noise.js +0 -1
- package/dist/commands/lint/base-linter.js +24 -48
- package/dist/commands/lint/bundle-skip.js +27 -0
- package/dist/commands/lint/index.js +83 -45
- package/dist/commands/lint/tracked-secrets.js +43 -0
- package/dist/commands/lint/types.js +58 -0
- package/dist/commands/proposal/repository.js +5 -1
- package/dist/commands/sources/stash-skeleton.js +7 -26
- package/dist/core/adapter/adapters/akm-adapter.js +2 -2
- package/dist/core/adapter/adapters/akm-workflow-adapter.js +6 -1
- package/dist/core/adapter/adapters/shared.js +13 -25
- package/dist/core/asset/lint-text.js +14 -13
- package/dist/core/asset/stale-path.js +63 -0
- package/dist/core/config/schema/sources-bundles.js +3 -0
- package/dist/output/shapes/passthrough.js +1 -0
- package/dist/output/text/lint-format.js +90 -1
- package/dist/output/text/migrate.js +5 -0
- package/dist/scripts/akm-migrate-node.js +1149 -791
- package/dist/scripts/akm-migrate.js +1149 -791
- package/dist/sources/include.js +1 -1
- package/dist/sources/snapshot-fetchers/website-ingest.js +0 -2
- package/dist/workspace/backups.js +21 -0
- package/dist/workspace/cli-child.js +5 -1
- package/dist/workspace-node.mjs +2 -0
- package/dist/workspace.d.ts +4 -0
- package/dist/workspace.js +1 -0
- package/docs/architecture/internals/health-advisories.md +1 -2
- package/docs/guides/bundles.md +5 -4
- package/docs/integration/bundling-akm.md +9 -1
- package/docs/reference/asset-types.md +1 -2
- package/docs/reference/cli.md +83 -3
- package/docs/reference/configuration.md +8 -2
- package/docs/reference/data-and-telemetry.md +1 -0
- package/docs/reference/env-and-secrets.md +9 -4
- package/docs/reference/website-sources.md +2 -2
- package/docs/reference/workspace.md +1 -0
- package/package.json +1 -1
- package/schemas/akm-config.json +34 -0
- package/dist/commands/health/stash-exposure.js +0 -64
|
@@ -8106,6 +8106,9 @@ var init_common = __esm(() => {
|
|
|
8106
8106
|
});
|
|
8107
8107
|
|
|
8108
8108
|
// src/core/registry-url.ts
|
|
8109
|
+
function hasRegistryUrlCredentials(raw) {
|
|
8110
|
+
return inspectStrictRegistryUrl(raw).unsafe;
|
|
8111
|
+
}
|
|
8109
8112
|
function formatRegistryUrl(raw) {
|
|
8110
8113
|
const parsed = parseWholeHttpUrl(raw);
|
|
8111
8114
|
const inspection = inspectStrictRegistryUrl(raw);
|
|
@@ -8127,6 +8130,10 @@ function formatRegistryUrl(raw) {
|
|
|
8127
8130
|
}
|
|
8128
8131
|
return INVALID_REGISTRY_URL_LABEL;
|
|
8129
8132
|
}
|
|
8133
|
+
function formatRegistryLabel(entry) {
|
|
8134
|
+
const url = formatRegistryUrl(entry.url);
|
|
8135
|
+
return entry.name ? `${entry.name} (${url})` : url;
|
|
8136
|
+
}
|
|
8130
8137
|
function inspectStrictRegistryUrl(raw) {
|
|
8131
8138
|
const state = { candidates: 0, decodedBytes: 0 };
|
|
8132
8139
|
const parsed = parseWholeHttpUrl(raw);
|
|
@@ -9279,14 +9286,14 @@ function codePointLength(str) {
|
|
|
9279
9286
|
const units = str.length;
|
|
9280
9287
|
if (!highSurrogate.test(str))
|
|
9281
9288
|
return units;
|
|
9282
|
-
let
|
|
9289
|
+
let count2 = units;
|
|
9283
9290
|
for (let i = 0;i < units - 1; i++) {
|
|
9284
9291
|
if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
9285
|
-
|
|
9292
|
+
count2--;
|
|
9286
9293
|
i++;
|
|
9287
9294
|
}
|
|
9288
9295
|
}
|
|
9289
|
-
return
|
|
9296
|
+
return count2;
|
|
9290
9297
|
}
|
|
9291
9298
|
function getLengthableOrigin(input) {
|
|
9292
9299
|
if (Array.isArray(input))
|
|
@@ -13680,8 +13687,8 @@ var init_az = __esm(() => {
|
|
|
13680
13687
|
});
|
|
13681
13688
|
|
|
13682
13689
|
// node_modules/zod/v4/locales/be.js
|
|
13683
|
-
function getBelarusianPlural(
|
|
13684
|
-
const absCount = Math.abs(
|
|
13690
|
+
function getBelarusianPlural(count2, one, few, many) {
|
|
13691
|
+
const absCount = Math.abs(count2);
|
|
13685
13692
|
const lastDigit = absCount % 10;
|
|
13686
13693
|
const lastTwoDigits = absCount % 100;
|
|
13687
13694
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -16387,8 +16394,8 @@ var init_hu = __esm(() => {
|
|
|
16387
16394
|
});
|
|
16388
16395
|
|
|
16389
16396
|
// node_modules/zod/v4/locales/hy.js
|
|
16390
|
-
function getArmenianPlural(
|
|
16391
|
-
return Math.abs(
|
|
16397
|
+
function getArmenianPlural(count2, one, many) {
|
|
16398
|
+
return Math.abs(count2) === 1 ? one : many;
|
|
16392
16399
|
}
|
|
16393
16400
|
function withDefiniteArticle(word) {
|
|
16394
16401
|
if (!word)
|
|
@@ -19190,8 +19197,8 @@ var init_ro = __esm(() => {
|
|
|
19190
19197
|
});
|
|
19191
19198
|
|
|
19192
19199
|
// node_modules/zod/v4/locales/ru.js
|
|
19193
|
-
function getRussianPlural(
|
|
19194
|
-
const absCount = Math.abs(
|
|
19200
|
+
function getRussianPlural(count2, one, few, many) {
|
|
19201
|
+
const absCount = Math.abs(count2);
|
|
19195
19202
|
const lastDigit = absCount % 10;
|
|
19196
19203
|
const lastTwoDigits = absCount % 100;
|
|
19197
19204
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -31618,7 +31625,8 @@ var init_sources_bundles = __esm(() => {
|
|
|
31618
31625
|
writable: exports_external.boolean().optional(),
|
|
31619
31626
|
enabled: exports_external.boolean().optional(),
|
|
31620
31627
|
registryId: exports_external.string().min(1).optional(),
|
|
31621
|
-
components: exports_external.record(exports_external.string().min(1), BundleComponentConfigSchema).optional()
|
|
31628
|
+
components: exports_external.record(exports_external.string().min(1), BundleComponentConfigSchema).optional(),
|
|
31629
|
+
lint: exports_external.object({ skip: exports_external.record(exports_external.string(), exports_external.array(exports_external.string())).optional() }).optional()
|
|
31622
31630
|
}).passthrough().superRefine((entry, ctx) => {
|
|
31623
31631
|
const options = entry.options;
|
|
31624
31632
|
if (options && typeof options === "object" && "pushOnCommit" in options) {
|
|
@@ -33674,6 +33682,15 @@ function assertConfigExtendsPhysicalContainment(root, candidate, ref) {
|
|
|
33674
33682
|
throw new ConfigError(`extends ${JSON.stringify(ref)} resolves through a symbolic link outside its bundle content root.`, "INVALID_CONFIG_FILE");
|
|
33675
33683
|
}
|
|
33676
33684
|
}
|
|
33685
|
+
function hasRawPath(raw, segments) {
|
|
33686
|
+
let cursor = raw;
|
|
33687
|
+
for (const segment of segments) {
|
|
33688
|
+
if (!isRecord(cursor) || !(segment in cursor))
|
|
33689
|
+
return false;
|
|
33690
|
+
cursor = cursor[segment];
|
|
33691
|
+
}
|
|
33692
|
+
return true;
|
|
33693
|
+
}
|
|
33677
33694
|
function loadConfig() {
|
|
33678
33695
|
return loadUserConfig();
|
|
33679
33696
|
}
|
|
@@ -33708,6 +33725,73 @@ function pruneUnchangedInheritedFields(before, after, localRaw) {
|
|
|
33708
33725
|
}
|
|
33709
33726
|
return result;
|
|
33710
33727
|
}
|
|
33728
|
+
function applyEdit(target, before, after, unremoved = [], at = []) {
|
|
33729
|
+
for (const key of Object.keys(before)) {
|
|
33730
|
+
if (Object.hasOwn(after, key))
|
|
33731
|
+
continue;
|
|
33732
|
+
if (Object.hasOwn(target, key))
|
|
33733
|
+
delete target[key];
|
|
33734
|
+
else
|
|
33735
|
+
unremoved.push([...at, key]);
|
|
33736
|
+
}
|
|
33737
|
+
for (const [key, value] of Object.entries(after)) {
|
|
33738
|
+
const was = before[key];
|
|
33739
|
+
if (isDeepStrictEqual3(value, was))
|
|
33740
|
+
continue;
|
|
33741
|
+
if (at.length === 1 && at[0] === "projects") {
|
|
33742
|
+
target[key] = value;
|
|
33743
|
+
continue;
|
|
33744
|
+
}
|
|
33745
|
+
const existing = target[key];
|
|
33746
|
+
const merges = was === undefined ? isPlainObject2(existing) : isPlainObject2(was);
|
|
33747
|
+
if (!isPlainObject2(value) || !merges || existing !== undefined && !isPlainObject2(existing)) {
|
|
33748
|
+
target[key] = value;
|
|
33749
|
+
continue;
|
|
33750
|
+
}
|
|
33751
|
+
const part = existing ?? {};
|
|
33752
|
+
applyEdit(part, isPlainObject2(was) ? was : {}, value, unremoved, [...at, key]);
|
|
33753
|
+
followKeyOrder(part, value);
|
|
33754
|
+
if (existing !== undefined || Object.keys(part).length > 0)
|
|
33755
|
+
target[key] = part;
|
|
33756
|
+
}
|
|
33757
|
+
}
|
|
33758
|
+
function followKeyOrder(target, order) {
|
|
33759
|
+
const keys = [
|
|
33760
|
+
...Object.keys(order).filter((key) => Object.hasOwn(target, key)),
|
|
33761
|
+
...Object.keys(target).filter((key) => !Object.hasOwn(order, key))
|
|
33762
|
+
];
|
|
33763
|
+
const entries = keys.map((key) => [key, target[key]]);
|
|
33764
|
+
for (const key of Object.keys(target))
|
|
33765
|
+
delete target[key];
|
|
33766
|
+
for (const [key, value] of entries)
|
|
33767
|
+
target[key] = value;
|
|
33768
|
+
}
|
|
33769
|
+
function editedConfigFile(document, current, next, persistTopLevelKeys = [], unremoved = [], writeProjects = []) {
|
|
33770
|
+
if (document === undefined)
|
|
33771
|
+
return next;
|
|
33772
|
+
const body = structuredClone(document);
|
|
33773
|
+
applyEdit(body, current, next, unremoved);
|
|
33774
|
+
for (const name of writeProjects) {
|
|
33775
|
+
const entry = next.projects?.[name];
|
|
33776
|
+
if (!entry)
|
|
33777
|
+
continue;
|
|
33778
|
+
if (!isPlainObject2(body.projects))
|
|
33779
|
+
body.projects = {};
|
|
33780
|
+
body.projects[name] = entry;
|
|
33781
|
+
}
|
|
33782
|
+
for (const key of persistTopLevelKeys) {
|
|
33783
|
+
if (Object.hasOwn(next, key))
|
|
33784
|
+
body[key] = next[key];
|
|
33785
|
+
}
|
|
33786
|
+
body.configVersion = CURRENT_CONFIG_VERSION;
|
|
33787
|
+
return body;
|
|
33788
|
+
}
|
|
33789
|
+
function refuseRemovalFromRetiredForm(unremoved, document, converted) {
|
|
33790
|
+
const fromRetiredForm = unremoved.filter((keyPath) => hasRawPath(converted, [...keyPath]) && !hasRawPath(document, [...keyPath]));
|
|
33791
|
+
if (fromRetiredForm.length === 0)
|
|
33792
|
+
return;
|
|
33793
|
+
throw new UsageError(`Cannot remove ${fromRetiredForm.map((keyPath) => keyPath.join(".")).join(", ")}: it comes from the retired engines form or models.json, which this config.json still reads. ` + "Run `akm migrate apply` to convert the file, then repeat the change.");
|
|
33794
|
+
}
|
|
33711
33795
|
function configWriteBody(localRaw, current, next, persistTopLevelKeys = []) {
|
|
33712
33796
|
if (localRaw === undefined)
|
|
33713
33797
|
return next;
|
|
@@ -33804,6 +33888,53 @@ function normalizeConfigFile(configPath, options) {
|
|
|
33804
33888
|
};
|
|
33805
33889
|
return options.apply ? withConfigLock(normalize) : normalize();
|
|
33806
33890
|
}
|
|
33891
|
+
function mutateConfig(mutate, options) {
|
|
33892
|
+
cachedConfig = undefined;
|
|
33893
|
+
const configPath = getConfigPath();
|
|
33894
|
+
return withConfigLock(() => {
|
|
33895
|
+
const text2 = readConfigText(configPath);
|
|
33896
|
+
if (text2 === undefined && options?.absentNoop) {
|
|
33897
|
+
return { config: { ...DEFAULT_CONFIG }, written: false };
|
|
33898
|
+
}
|
|
33899
|
+
const document = text2 === undefined ? undefined : readConfigFile(text2, configPath);
|
|
33900
|
+
const localRaw = document === undefined ? undefined : readRetiredEngines(document, configPath);
|
|
33901
|
+
const current = localRaw === undefined ? { ...DEFAULT_CONFIG } : buildEffectiveConfig(localRaw, configPath);
|
|
33902
|
+
const mutated = mutate(current);
|
|
33903
|
+
if (mutated === current)
|
|
33904
|
+
return { config: current, written: false };
|
|
33905
|
+
const next = validateCompleteConfig({ ...mutated, configVersion: CURRENT_CONFIG_VERSION });
|
|
33906
|
+
const unremoved = [];
|
|
33907
|
+
const body = editedConfigFile(document, current, next, [], unremoved, options?.writeProjects);
|
|
33908
|
+
refuseRemovalFromRetiredForm(unremoved, document, localRaw);
|
|
33909
|
+
if (text2 !== undefined)
|
|
33910
|
+
backupExistingConfig(configPath);
|
|
33911
|
+
fs17.mkdirSync(path20.dirname(configPath), { recursive: true });
|
|
33912
|
+
writeConfigAtomic(configPath, sanitizeConfigForWrite(body));
|
|
33913
|
+
return { config: next, written: true };
|
|
33914
|
+
});
|
|
33915
|
+
}
|
|
33916
|
+
function sanitizeConfigForWrite(config2, options) {
|
|
33917
|
+
const sanitized = { ...config2 };
|
|
33918
|
+
if (config2.registries) {
|
|
33919
|
+
const droppedRegistries = [];
|
|
33920
|
+
const registries2 = config2.registries.filter((entry) => {
|
|
33921
|
+
if (!hasRegistryUrlCredentials(entry.url))
|
|
33922
|
+
return true;
|
|
33923
|
+
droppedRegistries.push(formatRegistryLabel(entry));
|
|
33924
|
+
return false;
|
|
33925
|
+
});
|
|
33926
|
+
if (droppedRegistries.length > 0) {
|
|
33927
|
+
sanitized.registries = registries2;
|
|
33928
|
+
if (!options?.quiet)
|
|
33929
|
+
warn(`Config sanitizer dropped registry entr${droppedRegistries.length === 1 ? "y" : "ies"} with URL credentials before writing to disk:
|
|
33930
|
+
- ${droppedRegistries.join(`
|
|
33931
|
+
- `)}
|
|
33932
|
+
|
|
33933
|
+
Registry URLs must be credential-free; configure a credential-free HTTPS endpoint.`);
|
|
33934
|
+
}
|
|
33935
|
+
}
|
|
33936
|
+
return sanitized;
|
|
33937
|
+
}
|
|
33807
33938
|
function resolveSecret(value, resolveFromStore) {
|
|
33808
33939
|
if (value === undefined)
|
|
33809
33940
|
return;
|
|
@@ -35428,33 +35559,84 @@ var init_frontmatter_lint = __esm(() => {
|
|
|
35428
35559
|
function stripTrailingSentencePunctuation(token) {
|
|
35429
35560
|
return token.replace(/[.;:!?]+$/, "");
|
|
35430
35561
|
}
|
|
35431
|
-
function
|
|
35432
|
-
return
|
|
35562
|
+
function isSkillPath(relPath) {
|
|
35563
|
+
return relPath.split(/[\\/]/)[0] === "skills";
|
|
35433
35564
|
}
|
|
35434
|
-
function findCurrentPathReferences(text2) {
|
|
35435
|
-
const pathRe = /(
|
|
35565
|
+
function findCurrentPathReferences(text2, firstLine = 1) {
|
|
35566
|
+
const pathRe = /(?<=^|[\s"'`([=])\/[^\s"'`)\]>,:\[\n]+/g;
|
|
35436
35567
|
const out = [];
|
|
35437
35568
|
let inNonCurrentSection = false;
|
|
35438
|
-
|
|
35569
|
+
text2.split(/\r?\n/).forEach((line, index) => {
|
|
35439
35570
|
if (/^#{1,6}\s/.test(line))
|
|
35440
35571
|
inNonCurrentSection = NON_CURRENT_HEADING_PATTERN.test(line);
|
|
35441
35572
|
if (inNonCurrentSection || NON_CURRENT_LINE_PATTERN.test(line))
|
|
35442
|
-
|
|
35573
|
+
return;
|
|
35443
35574
|
for (const match of line.matchAll(pathRe)) {
|
|
35444
35575
|
const candidate = stripTrailingSentencePunctuation(match[0]);
|
|
35445
|
-
if (!PATH_PLACEHOLDER_PATTERN.test(candidate))
|
|
35446
|
-
out.push(candidate);
|
|
35576
|
+
if (candidate.length > 1 && !PATH_PLACEHOLDER_PATTERN.test(candidate)) {
|
|
35577
|
+
out.push({ path: candidate, line: firstLine + index, lineText: line.trim() });
|
|
35578
|
+
}
|
|
35447
35579
|
}
|
|
35448
|
-
}
|
|
35580
|
+
});
|
|
35449
35581
|
return out;
|
|
35450
35582
|
}
|
|
35451
35583
|
var PATH_PLACEHOLDER_PATTERN, NON_CURRENT_LINE_PATTERN, NON_CURRENT_HEADING_PATTERN;
|
|
35452
35584
|
var init_lint_text = __esm(() => {
|
|
35453
|
-
PATH_PLACEHOLDER_PATTERN = /[<{]|[*?]|[YMDHS]{4,}
|
|
35585
|
+
PATH_PLACEHOLDER_PATTERN = /[<{]|[*?]|[YMDHS]{4,}|\.\.\./;
|
|
35454
35586
|
NON_CURRENT_LINE_PATTERN = /\b(?:historical(?:ly)?|previously|formerly|for example|for instance)\b|\be\.g\./i;
|
|
35455
35587
|
NON_CURRENT_HEADING_PATTERN = /^#{1,6}\s.*\b(?:history|changelog|archive|examples?)\b/i;
|
|
35456
35588
|
});
|
|
35457
35589
|
|
|
35590
|
+
// src/core/asset/stale-path.ts
|
|
35591
|
+
import fs21 from "node:fs";
|
|
35592
|
+
import os9 from "node:os";
|
|
35593
|
+
import path24 from "node:path";
|
|
35594
|
+
function stalePathRoots(config2, ...extraRoots) {
|
|
35595
|
+
const projectPaths = Object.values(config2.projects ?? {}).flatMap((project) => project.paths ?? []);
|
|
35596
|
+
return [
|
|
35597
|
+
os9.homedir(),
|
|
35598
|
+
...bundleContentRoots(config2).map((bundle) => bundle.contentRoot),
|
|
35599
|
+
...projectPaths.map(expandProjectPath),
|
|
35600
|
+
...extraRoots
|
|
35601
|
+
];
|
|
35602
|
+
}
|
|
35603
|
+
function isUnder(candidate, root) {
|
|
35604
|
+
return candidate === root || candidate.startsWith(root.endsWith("/") ? root : `${root}/`);
|
|
35605
|
+
}
|
|
35606
|
+
function nearestExistingDirectory(candidate) {
|
|
35607
|
+
let dir = path24.dirname(candidate);
|
|
35608
|
+
while (dir !== path24.dirname(dir) && !fs21.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) {
|
|
35609
|
+
dir = path24.dirname(dir);
|
|
35610
|
+
}
|
|
35611
|
+
return dir;
|
|
35612
|
+
}
|
|
35613
|
+
function findStalePaths(text2, firstLine, roots, bundleRoot) {
|
|
35614
|
+
const findings = [];
|
|
35615
|
+
for (const { path: candidate, line, lineText } of findCurrentPathReferences(text2, firstLine)) {
|
|
35616
|
+
const managed = roots.some((root) => isUnder(candidate, root));
|
|
35617
|
+
const ephemeral = !managed && candidate.startsWith("/tmp/");
|
|
35618
|
+
if (!managed && !ephemeral)
|
|
35619
|
+
continue;
|
|
35620
|
+
if (fs21.existsSync(candidate))
|
|
35621
|
+
continue;
|
|
35622
|
+
const portable = isUnder(candidate, bundleRoot) ? ` (portable form: $AKM_BUNDLE_DIR${candidate.slice(bundleRoot.length)})` : "";
|
|
35623
|
+
findings.push({
|
|
35624
|
+
path: candidate,
|
|
35625
|
+
line,
|
|
35626
|
+
lineText,
|
|
35627
|
+
nearestExisting: nearestExistingDirectory(candidate),
|
|
35628
|
+
reason: ephemeral ? "ephemeral" : "missing",
|
|
35629
|
+
detail: `${ephemeral ? "ephemeral" : "nonexistent"} path: ${candidate}${portable}`
|
|
35630
|
+
});
|
|
35631
|
+
}
|
|
35632
|
+
return findings;
|
|
35633
|
+
}
|
|
35634
|
+
var init_stale_path = __esm(() => {
|
|
35635
|
+
init_config_sources();
|
|
35636
|
+
init_projects();
|
|
35637
|
+
init_lint_text();
|
|
35638
|
+
});
|
|
35639
|
+
|
|
35458
35640
|
// src/core/adapter/adapters/shared.ts
|
|
35459
35641
|
import { createHash } from "node:crypto";
|
|
35460
35642
|
function hashContent(content) {
|
|
@@ -35472,8 +35654,8 @@ function readTags(value) {
|
|
|
35472
35654
|
const tags = value.filter((tag) => typeof tag === "string" && tag.trim().length > 0);
|
|
35473
35655
|
return tags.length > 0 ? tags : undefined;
|
|
35474
35656
|
}
|
|
35475
|
-
function checkMissingUpdated(data, frontmatterText) {
|
|
35476
|
-
return frontmatterText !== null && !("updated" in data);
|
|
35657
|
+
function checkMissingUpdated(relPath, data, frontmatterText) {
|
|
35658
|
+
return frontmatterText !== null && !("updated" in data) && !isSkillPath(relPath);
|
|
35477
35659
|
}
|
|
35478
35660
|
function stripFencedBlocksSimple(body) {
|
|
35479
35661
|
const lines = body.split(/\r?\n/);
|
|
@@ -35534,12 +35716,12 @@ function readRefStringOrArray(value) {
|
|
|
35534
35716
|
}
|
|
35535
35717
|
async function runBaseValidateChecks(relPath, parsed, componentRoot, ctx) {
|
|
35536
35718
|
const diagnostics = [];
|
|
35537
|
-
const { data, content: body, frontmatter } = parsed;
|
|
35719
|
+
const { data, content: body, frontmatter, bodyStartLine } = parsed;
|
|
35538
35720
|
const unquotedColonDetail = checkUnquotedDescriptionColon(frontmatter);
|
|
35539
35721
|
if (unquotedColonDetail) {
|
|
35540
35722
|
diagnostics.push({ file: relPath, issue: "unquoted-colon", detail: unquotedColonDetail, fixed: false });
|
|
35541
35723
|
}
|
|
35542
|
-
if (checkMissingUpdated(data, frontmatter)) {
|
|
35724
|
+
if (checkMissingUpdated(relPath, data, frontmatter)) {
|
|
35543
35725
|
diagnostics.push({
|
|
35544
35726
|
file: relPath,
|
|
35545
35727
|
issue: "missing-updated",
|
|
@@ -35547,25 +35729,13 @@ async function runBaseValidateChecks(relPath, parsed, componentRoot, ctx) {
|
|
|
35547
35729
|
fixed: false
|
|
35548
35730
|
});
|
|
35549
35731
|
}
|
|
35550
|
-
const
|
|
35551
|
-
|
|
35552
|
-
...frontmatter ?
|
|
35732
|
+
const roots = stalePathRoots(loadConfig(), componentRoot);
|
|
35733
|
+
const stale = [
|
|
35734
|
+
...frontmatter ? findStalePaths(frontmatter, 2, roots, componentRoot) : [],
|
|
35735
|
+
...findStalePaths(body, bodyStartLine, roots, componentRoot)
|
|
35553
35736
|
];
|
|
35554
|
-
for (const
|
|
35555
|
-
|
|
35556
|
-
if (home !== undefined && (await ctx.list(home)).length === 0)
|
|
35557
|
-
continue;
|
|
35558
|
-
const found = await ctx.readFile(candidate);
|
|
35559
|
-
if (found !== null)
|
|
35560
|
-
continue;
|
|
35561
|
-
const portableHint = candidate.startsWith(componentRoot) ? ` (portable form: $AKM_BUNDLE_DIR${candidate.slice(componentRoot.length)})` : "";
|
|
35562
|
-
diagnostics.push({
|
|
35563
|
-
file: relPath,
|
|
35564
|
-
issue: "stale-path",
|
|
35565
|
-
detail: `nonexistent path: ${candidate}${portableHint}`,
|
|
35566
|
-
fixed: false
|
|
35567
|
-
});
|
|
35568
|
-
}
|
|
35737
|
+
for (const finding of stale)
|
|
35738
|
+
diagnostics.push({ file: relPath, issue: "stale-path", fixed: false, ...finding });
|
|
35569
35739
|
for (const ref of extractProseRefTokens(body)) {
|
|
35570
35740
|
const { exists } = await ctx.resolveRef(ref);
|
|
35571
35741
|
if (!exists)
|
|
@@ -35613,14 +35783,16 @@ var init_shared = __esm(() => {
|
|
|
35613
35783
|
init_frontmatter();
|
|
35614
35784
|
init_frontmatter_lint();
|
|
35615
35785
|
init_lint_text();
|
|
35786
|
+
init_stale_path();
|
|
35616
35787
|
init_common();
|
|
35788
|
+
init_config();
|
|
35617
35789
|
RESERVED_FILES = new Set(["index.md", "log.md"]);
|
|
35618
35790
|
XREF_FRONTMATTER_KEYS = ["xrefs", "supersededBy", "contradictedBy"];
|
|
35619
35791
|
});
|
|
35620
35792
|
|
|
35621
35793
|
// src/core/adapter/adapters/agent-skills-adapter.ts
|
|
35622
|
-
import
|
|
35623
|
-
import
|
|
35794
|
+
import fs22 from "node:fs";
|
|
35795
|
+
import path25 from "node:path";
|
|
35624
35796
|
function skillPackage(relPath) {
|
|
35625
35797
|
const posix = toPosix(relPath);
|
|
35626
35798
|
const segs = posix.split("/").filter((s) => s.length > 0);
|
|
@@ -35758,12 +35930,12 @@ var init_agent_skills_adapter = __esm(() => {
|
|
|
35758
35930
|
recognize,
|
|
35759
35931
|
validate: validate2,
|
|
35760
35932
|
readCandidates(c, conceptId) {
|
|
35761
|
-
return [{ path:
|
|
35933
|
+
return [{ path: path25.join(c.root, conceptId, SKILL_MANIFEST), conceptId }];
|
|
35762
35934
|
},
|
|
35763
35935
|
looksLikeRoot(root) {
|
|
35764
35936
|
let entries;
|
|
35765
35937
|
try {
|
|
35766
|
-
entries =
|
|
35938
|
+
entries = fs22.readdirSync(root, { withFileTypes: true });
|
|
35767
35939
|
} catch {
|
|
35768
35940
|
return false;
|
|
35769
35941
|
}
|
|
@@ -35771,7 +35943,7 @@ var init_agent_skills_adapter = __esm(() => {
|
|
|
35771
35943
|
if (!entry.isDirectory() || isScratchPath(entry.name))
|
|
35772
35944
|
return false;
|
|
35773
35945
|
try {
|
|
35774
|
-
return
|
|
35946
|
+
return fs22.existsSync(path25.join(root, entry.name, SKILL_MANIFEST));
|
|
35775
35947
|
} catch {
|
|
35776
35948
|
return false;
|
|
35777
35949
|
}
|
|
@@ -35781,8 +35953,8 @@ var init_agent_skills_adapter = __esm(() => {
|
|
|
35781
35953
|
});
|
|
35782
35954
|
|
|
35783
35955
|
// src/indexer/passes/metadata.ts
|
|
35784
|
-
import
|
|
35785
|
-
import
|
|
35956
|
+
import fs23 from "node:fs";
|
|
35957
|
+
import path26 from "node:path";
|
|
35786
35958
|
function normalizeQuality(raw) {
|
|
35787
35959
|
if (KNOWN_QUALITY_VALUES.has(raw))
|
|
35788
35960
|
return raw;
|
|
@@ -36067,7 +36239,7 @@ function applyProvenanceFrontmatter(entry, fmData) {
|
|
|
36067
36239
|
function extractScriptParameters(filePath, content) {
|
|
36068
36240
|
if (content === undefined) {
|
|
36069
36241
|
try {
|
|
36070
|
-
content =
|
|
36242
|
+
content = fs23.readFileSync(filePath, "utf8");
|
|
36071
36243
|
} catch {
|
|
36072
36244
|
return;
|
|
36073
36245
|
}
|
|
@@ -36158,7 +36330,7 @@ function parseIntentCommentLine(cleaned, metadata) {
|
|
|
36158
36330
|
function extractCommentMetadata(filePath, content) {
|
|
36159
36331
|
if (content === undefined) {
|
|
36160
36332
|
try {
|
|
36161
|
-
content =
|
|
36333
|
+
content = fs23.readFileSync(filePath, "utf8");
|
|
36162
36334
|
} catch {
|
|
36163
36335
|
return;
|
|
36164
36336
|
}
|
|
@@ -36563,7 +36735,7 @@ function projectMarkdownFragmentContent(raw) {
|
|
|
36563
36735
|
return text2.trim() ? text2 : undefined;
|
|
36564
36736
|
}
|
|
36565
36737
|
function applyPreContributorFields(entry, file2, ctx, pkgMeta) {
|
|
36566
|
-
const ext =
|
|
36738
|
+
const ext = path26.extname(file2).toLowerCase();
|
|
36567
36739
|
if (pkgMeta) {
|
|
36568
36740
|
if (pkgMeta.description && !entry.description) {
|
|
36569
36741
|
entry.description = pkgMeta.description;
|
|
@@ -36611,8 +36783,8 @@ function applyPreContributorFields(entry, file2, ctx, pkgMeta) {
|
|
|
36611
36783
|
}
|
|
36612
36784
|
}
|
|
36613
36785
|
function applyPostContributorFields(entry, file2, canonicalName, dirPath) {
|
|
36614
|
-
const ext =
|
|
36615
|
-
const baseName =
|
|
36786
|
+
const ext = path26.extname(file2).toLowerCase();
|
|
36787
|
+
const baseName = path26.basename(file2, ext);
|
|
36616
36788
|
if (!entry.description) {
|
|
36617
36789
|
entry.description = fileNameToDescription(baseName);
|
|
36618
36790
|
entry.source = "filename";
|
|
@@ -36624,7 +36796,7 @@ function applyPostContributorFields(entry, file2, canonicalName, dirPath) {
|
|
|
36624
36796
|
entry.tags = [...entry.tags ?? [], ...extractDirTagsFromName(canonicalName)];
|
|
36625
36797
|
entry.tags = normalizeTerms(entry.tags ?? []);
|
|
36626
36798
|
entry.aliases = mergeAliases(entry.aliases, buildAliases(canonicalName, entry.tags));
|
|
36627
|
-
entry.filename =
|
|
36799
|
+
entry.filename = path26.basename(file2);
|
|
36628
36800
|
}
|
|
36629
36801
|
function normalizeTerms(values) {
|
|
36630
36802
|
const normalized = new Set;
|
|
@@ -36646,11 +36818,11 @@ function buildAliases(name, tags) {
|
|
|
36646
36818
|
return Array.from(aliases);
|
|
36647
36819
|
}
|
|
36648
36820
|
function extractPackageMetadata(dirPath) {
|
|
36649
|
-
const pkgPath =
|
|
36650
|
-
if (!
|
|
36821
|
+
const pkgPath = path26.join(dirPath, "package.json");
|
|
36822
|
+
if (!fs23.existsSync(pkgPath))
|
|
36651
36823
|
return null;
|
|
36652
36824
|
try {
|
|
36653
|
-
const pkg = JSON.parse(
|
|
36825
|
+
const pkg = JSON.parse(fs23.readFileSync(pkgPath, "utf8"));
|
|
36654
36826
|
const result = {};
|
|
36655
36827
|
if (typeof pkg.name === "string")
|
|
36656
36828
|
result.name = pkg.name;
|
|
@@ -36668,11 +36840,11 @@ function fileNameToDescription(fileName) {
|
|
|
36668
36840
|
return fileName.replace(/[-_]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase().trim();
|
|
36669
36841
|
}
|
|
36670
36842
|
function extractTagsFromPath(filePath, rootDir) {
|
|
36671
|
-
const rel =
|
|
36672
|
-
const parts = rel.split(
|
|
36843
|
+
const rel = path26.relative(rootDir, filePath);
|
|
36844
|
+
const parts = rel.split(path26.sep);
|
|
36673
36845
|
const tags = new Set;
|
|
36674
36846
|
for (const part of parts) {
|
|
36675
|
-
const name = part.replace(
|
|
36847
|
+
const name = part.replace(path26.extname(part), "");
|
|
36676
36848
|
for (const token of name.split(/[-_./\\]+/)) {
|
|
36677
36849
|
const clean = token.toLowerCase().trim();
|
|
36678
36850
|
if (clean && clean.length > 1)
|
|
@@ -36727,15 +36899,15 @@ var init_metadata = __esm(() => {
|
|
|
36727
36899
|
});
|
|
36728
36900
|
|
|
36729
36901
|
// src/indexer/walk/file-context.ts
|
|
36730
|
-
import
|
|
36731
|
-
import
|
|
36902
|
+
import fs24 from "node:fs";
|
|
36903
|
+
import path27 from "node:path";
|
|
36732
36904
|
function buildFileContext(stashRoot, absPath) {
|
|
36733
|
-
const relPath = toPosix(
|
|
36734
|
-
const ext =
|
|
36735
|
-
const fileName =
|
|
36736
|
-
const parentDirAbs =
|
|
36737
|
-
const parentDir =
|
|
36738
|
-
const relDir = toPosix(
|
|
36905
|
+
const relPath = toPosix(path27.relative(stashRoot, absPath));
|
|
36906
|
+
const ext = path27.extname(absPath).toLowerCase();
|
|
36907
|
+
const fileName = path27.basename(absPath);
|
|
36908
|
+
const parentDirAbs = path27.dirname(absPath);
|
|
36909
|
+
const parentDir = path27.basename(parentDirAbs);
|
|
36910
|
+
const relDir = toPosix(path27.dirname(relPath));
|
|
36739
36911
|
const ancestorDirs = relDir === "." ? [] : relDir.split("/").filter((seg) => seg.length > 0);
|
|
36740
36912
|
let cachedContent;
|
|
36741
36913
|
let cachedFrontmatter;
|
|
@@ -36752,7 +36924,7 @@ function buildFileContext(stashRoot, absPath) {
|
|
|
36752
36924
|
stashRoot,
|
|
36753
36925
|
content() {
|
|
36754
36926
|
if (cachedContent === undefined) {
|
|
36755
|
-
cachedContent =
|
|
36927
|
+
cachedContent = fs24.readFileSync(absPath, "utf8");
|
|
36756
36928
|
}
|
|
36757
36929
|
return cachedContent;
|
|
36758
36930
|
},
|
|
@@ -36767,7 +36939,7 @@ function buildFileContext(stashRoot, absPath) {
|
|
|
36767
36939
|
},
|
|
36768
36940
|
stat() {
|
|
36769
36941
|
if (cachedStat === undefined) {
|
|
36770
|
-
cachedStat =
|
|
36942
|
+
cachedStat = fs24.statSync(absPath);
|
|
36771
36943
|
}
|
|
36772
36944
|
return cachedStat;
|
|
36773
36945
|
}
|
|
@@ -37165,25 +37337,25 @@ function parseExecutionMarkdown(raw, filePath) {
|
|
|
37165
37337
|
function own2(data, key) {
|
|
37166
37338
|
return Object.hasOwn(data, key);
|
|
37167
37339
|
}
|
|
37168
|
-
function requireMetadataMapping(value,
|
|
37340
|
+
function requireMetadataMapping(value, path28) {
|
|
37169
37341
|
try {
|
|
37170
|
-
return snapshotStrictRecord(value,
|
|
37342
|
+
return snapshotStrictRecord(value, path28);
|
|
37171
37343
|
} catch (cause) {
|
|
37172
|
-
throw new TypeError(`${
|
|
37344
|
+
throw new TypeError(`${path28} must be a mapping with enumerable data fields`, { cause });
|
|
37173
37345
|
}
|
|
37174
37346
|
}
|
|
37175
|
-
function nullableString(value,
|
|
37347
|
+
function nullableString(value, path28) {
|
|
37176
37348
|
if (value !== null && typeof value !== "string")
|
|
37177
|
-
throw new TypeError(`${
|
|
37349
|
+
throw new TypeError(`${path28} must be a string or null`);
|
|
37178
37350
|
return value;
|
|
37179
37351
|
}
|
|
37180
|
-
function nullableObject(value,
|
|
37181
|
-
return value === null ? null : cloneExecutionJsonObject(value,
|
|
37352
|
+
function nullableObject(value, path28) {
|
|
37353
|
+
return value === null ? null : cloneExecutionJsonObject(value, path28);
|
|
37182
37354
|
}
|
|
37183
|
-
function nullableTimeout(value,
|
|
37184
|
-
const timeout = cloneExecutionJson(value,
|
|
37355
|
+
function nullableTimeout(value, path28) {
|
|
37356
|
+
const timeout = cloneExecutionJson(value, path28);
|
|
37185
37357
|
if (timeout !== null && typeof timeout !== "string" && typeof timeout !== "number") {
|
|
37186
|
-
throw new TypeError(`${
|
|
37358
|
+
throw new TypeError(`${path28} must be a string, number, or null`);
|
|
37187
37359
|
}
|
|
37188
37360
|
return timeout;
|
|
37189
37361
|
}
|
|
@@ -37351,9 +37523,9 @@ var init_recognize_match = __esm(() => {
|
|
|
37351
37523
|
|
|
37352
37524
|
// node_modules/dotenv/lib/main.js
|
|
37353
37525
|
var require_main = __commonJS((exports, module) => {
|
|
37354
|
-
var
|
|
37355
|
-
var
|
|
37356
|
-
var
|
|
37526
|
+
var fs25 = __require("fs");
|
|
37527
|
+
var path28 = __require("path");
|
|
37528
|
+
var os10 = __require("os");
|
|
37357
37529
|
var crypto3 = __require("crypto");
|
|
37358
37530
|
var TIPS = [
|
|
37359
37531
|
"◈ encrypted .env [www.dotenvx.com]",
|
|
@@ -37485,7 +37657,7 @@ var require_main = __commonJS((exports, module) => {
|
|
|
37485
37657
|
if (options && options.path && options.path.length > 0) {
|
|
37486
37658
|
if (Array.isArray(options.path)) {
|
|
37487
37659
|
for (const filepath of options.path) {
|
|
37488
|
-
if (
|
|
37660
|
+
if (fs25.existsSync(filepath)) {
|
|
37489
37661
|
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
37490
37662
|
}
|
|
37491
37663
|
}
|
|
@@ -37493,15 +37665,15 @@ var require_main = __commonJS((exports, module) => {
|
|
|
37493
37665
|
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
37494
37666
|
}
|
|
37495
37667
|
} else {
|
|
37496
|
-
possibleVaultPath =
|
|
37668
|
+
possibleVaultPath = path28.resolve(process.cwd(), ".env.vault");
|
|
37497
37669
|
}
|
|
37498
|
-
if (
|
|
37670
|
+
if (fs25.existsSync(possibleVaultPath)) {
|
|
37499
37671
|
return possibleVaultPath;
|
|
37500
37672
|
}
|
|
37501
37673
|
return null;
|
|
37502
37674
|
}
|
|
37503
37675
|
function _resolveHome(envPath) {
|
|
37504
|
-
return envPath[0] === "~" ?
|
|
37676
|
+
return envPath[0] === "~" ? path28.join(os10.homedir(), envPath.slice(1)) : envPath;
|
|
37505
37677
|
}
|
|
37506
37678
|
function _configVault(options) {
|
|
37507
37679
|
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
@@ -37518,7 +37690,7 @@ var require_main = __commonJS((exports, module) => {
|
|
|
37518
37690
|
return { parsed };
|
|
37519
37691
|
}
|
|
37520
37692
|
function configDotenv(options) {
|
|
37521
|
-
const dotenvPath =
|
|
37693
|
+
const dotenvPath = path28.resolve(process.cwd(), ".env");
|
|
37522
37694
|
let encoding = "utf8";
|
|
37523
37695
|
let processEnv = process.env;
|
|
37524
37696
|
if (options && options.processEnv != null) {
|
|
@@ -37546,13 +37718,13 @@ var require_main = __commonJS((exports, module) => {
|
|
|
37546
37718
|
}
|
|
37547
37719
|
let lastError;
|
|
37548
37720
|
const parsedAll = {};
|
|
37549
|
-
for (const
|
|
37721
|
+
for (const path29 of optionPaths) {
|
|
37550
37722
|
try {
|
|
37551
|
-
const parsed = DotenvModule.parse(
|
|
37723
|
+
const parsed = DotenvModule.parse(fs25.readFileSync(path29, { encoding }));
|
|
37552
37724
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
37553
37725
|
} catch (e) {
|
|
37554
37726
|
if (debug) {
|
|
37555
|
-
_debug(`failed to load ${
|
|
37727
|
+
_debug(`failed to load ${path29} ${e.message}`);
|
|
37556
37728
|
}
|
|
37557
37729
|
lastError = e;
|
|
37558
37730
|
}
|
|
@@ -37565,7 +37737,7 @@ var require_main = __commonJS((exports, module) => {
|
|
|
37565
37737
|
const shortPaths = [];
|
|
37566
37738
|
for (const filePath of optionPaths) {
|
|
37567
37739
|
try {
|
|
37568
|
-
const relative =
|
|
37740
|
+
const relative = path28.relative(process.cwd(), filePath);
|
|
37569
37741
|
shortPaths.push(relative);
|
|
37570
37742
|
} catch (e) {
|
|
37571
37743
|
if (debug) {
|
|
@@ -38057,34 +38229,34 @@ function checkJsonSchemaDefinition(schema) {
|
|
|
38057
38229
|
checkDefinitionNode(schema, [], issues, 0);
|
|
38058
38230
|
return issues;
|
|
38059
38231
|
}
|
|
38060
|
-
function pointerFor(
|
|
38061
|
-
return
|
|
38232
|
+
function pointerFor(path28) {
|
|
38233
|
+
return path28.length === 0 ? "$" : `$.${path28.map(String).join(".")}`;
|
|
38062
38234
|
}
|
|
38063
|
-
function pushIssue2(issues,
|
|
38064
|
-
issues.push({ path: [...
|
|
38235
|
+
function pushIssue2(issues, path28, keyword, kind, message) {
|
|
38236
|
+
issues.push({ path: [...path28], pointer: pointerFor(path28), keyword, kind, message });
|
|
38065
38237
|
}
|
|
38066
38238
|
function isSupportedEnumValue(value) {
|
|
38067
38239
|
return value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
|
|
38068
38240
|
}
|
|
38069
|
-
function checkDefinitionNode(schema,
|
|
38241
|
+
function checkDefinitionNode(schema, path28, issues, depth) {
|
|
38070
38242
|
if (depth > MAX_DEFINITION_DEPTH) {
|
|
38071
|
-
pushIssue2(issues,
|
|
38243
|
+
pushIssue2(issues, path28, "(depth)", "malformed", `schema nesting exceeds the depth limit of ${MAX_DEFINITION_DEPTH}`);
|
|
38072
38244
|
return;
|
|
38073
38245
|
}
|
|
38074
38246
|
for (const keyword of Object.keys(schema)) {
|
|
38075
38247
|
if (UNSUPPORTED_KEYWORDS.has(keyword)) {
|
|
38076
38248
|
const hint = UNSUPPORTED_KEYWORD_HINTS.get(keyword);
|
|
38077
|
-
pushIssue2(issues, [...
|
|
38249
|
+
pushIssue2(issues, [...path28, keyword], keyword, "unsupported", `keyword "${keyword}" is not enforced by the workflow schema subset — the schema would silently not ` + `constrain what it looks like it constrains${hint ? `; ${hint}` : ""}`);
|
|
38078
38250
|
}
|
|
38079
38251
|
}
|
|
38080
38252
|
const declared = schema.type;
|
|
38081
38253
|
if (declared !== undefined) {
|
|
38082
38254
|
const names = Array.isArray(declared) ? declared : [declared];
|
|
38083
38255
|
if (names.length === 0) {
|
|
38084
|
-
pushIssue2(issues, [...
|
|
38256
|
+
pushIssue2(issues, [...path28, "type"], "type", "malformed", `"type" must name at least one type`);
|
|
38085
38257
|
}
|
|
38086
38258
|
for (const [index, name] of names.entries()) {
|
|
38087
|
-
const namePath = Array.isArray(declared) ? [...
|
|
38259
|
+
const namePath = Array.isArray(declared) ? [...path28, "type", index] : [...path28, "type"];
|
|
38088
38260
|
if (typeof name !== "string") {
|
|
38089
38261
|
pushIssue2(issues, namePath, "type", "malformed", `"type" must be a string or an array of strings`);
|
|
38090
38262
|
} else if (!KNOWN_TYPE_NAMES.has(name)) {
|
|
@@ -38094,12 +38266,12 @@ function checkDefinitionNode(schema, path27, issues, depth) {
|
|
|
38094
38266
|
}
|
|
38095
38267
|
if (schema.enum !== undefined) {
|
|
38096
38268
|
if (!Array.isArray(schema.enum) || schema.enum.length === 0) {
|
|
38097
|
-
pushIssue2(issues, [...
|
|
38269
|
+
pushIssue2(issues, [...path28, "enum"], "enum", "malformed", `"enum" must be a non-empty array of allowed values`);
|
|
38098
38270
|
} else {
|
|
38099
38271
|
schema.enum.forEach((value, index) => {
|
|
38100
38272
|
if (isSupportedEnumValue(value))
|
|
38101
38273
|
return;
|
|
38102
|
-
pushIssue2(issues, [...
|
|
38274
|
+
pushIssue2(issues, [...path28, "enum", index], "enum", "unsupported", `"enum" values must be JSON primitives (string, finite number, boolean, or null) in the workflow ` + `schema subset — object and array enum members cannot be matched by the runtime subset`);
|
|
38103
38275
|
});
|
|
38104
38276
|
}
|
|
38105
38277
|
}
|
|
@@ -38108,68 +38280,68 @@ function checkDefinitionNode(schema, path27, issues, depth) {
|
|
|
38108
38280
|
if (branches === undefined)
|
|
38109
38281
|
continue;
|
|
38110
38282
|
if (!Array.isArray(branches) || branches.length === 0) {
|
|
38111
|
-
pushIssue2(issues, [...
|
|
38283
|
+
pushIssue2(issues, [...path28, keyword], keyword, "malformed", `"${keyword}" must be a non-empty array of schema objects`);
|
|
38112
38284
|
continue;
|
|
38113
38285
|
}
|
|
38114
38286
|
branches.forEach((branch, index) => {
|
|
38115
38287
|
if (isRecord(branch)) {
|
|
38116
|
-
checkDefinitionNode(branch, [...
|
|
38288
|
+
checkDefinitionNode(branch, [...path28, keyword, index], issues, depth + 1);
|
|
38117
38289
|
} else {
|
|
38118
|
-
pushIssue2(issues, [...
|
|
38290
|
+
pushIssue2(issues, [...path28, keyword, index], keyword, "malformed", `"${keyword}[${index}]" must be a schema object`);
|
|
38119
38291
|
}
|
|
38120
38292
|
});
|
|
38121
38293
|
}
|
|
38122
38294
|
if (schema.not !== undefined) {
|
|
38123
38295
|
if (isRecord(schema.not)) {
|
|
38124
|
-
checkDefinitionNode(schema.not, [...
|
|
38296
|
+
checkDefinitionNode(schema.not, [...path28, "not"], issues, depth + 1);
|
|
38125
38297
|
} else {
|
|
38126
|
-
pushIssue2(issues, [...
|
|
38298
|
+
pushIssue2(issues, [...path28, "not"], "not", "malformed", `"not" must be a schema object`);
|
|
38127
38299
|
}
|
|
38128
38300
|
}
|
|
38129
38301
|
if (schema.required !== undefined) {
|
|
38130
38302
|
if (!Array.isArray(schema.required) || !schema.required.every((key) => typeof key === "string")) {
|
|
38131
|
-
pushIssue2(issues, [...
|
|
38303
|
+
pushIssue2(issues, [...path28, "required"], "required", "malformed", `"required" must be an array of property-name strings`);
|
|
38132
38304
|
}
|
|
38133
38305
|
}
|
|
38134
38306
|
if (schema.properties !== undefined) {
|
|
38135
38307
|
if (!isRecord(schema.properties)) {
|
|
38136
|
-
pushIssue2(issues, [...
|
|
38308
|
+
pushIssue2(issues, [...path28, "properties"], "properties", "malformed", `"properties" must be an object mapping property names to schemas`);
|
|
38137
38309
|
} else {
|
|
38138
38310
|
for (const [key, propSchema] of Object.entries(schema.properties)) {
|
|
38139
38311
|
if (isRecord(propSchema)) {
|
|
38140
|
-
checkDefinitionNode(propSchema, [...
|
|
38312
|
+
checkDefinitionNode(propSchema, [...path28, "properties", key], issues, depth + 1);
|
|
38141
38313
|
} else {
|
|
38142
|
-
pushIssue2(issues, [...
|
|
38314
|
+
pushIssue2(issues, [...path28, "properties", key], "properties", "malformed", `property ${JSON.stringify(key)} must be a schema object`);
|
|
38143
38315
|
}
|
|
38144
38316
|
}
|
|
38145
38317
|
}
|
|
38146
38318
|
}
|
|
38147
38319
|
if (schema.items !== undefined) {
|
|
38148
38320
|
if (isRecord(schema.items)) {
|
|
38149
|
-
checkDefinitionNode(schema.items, [...
|
|
38321
|
+
checkDefinitionNode(schema.items, [...path28, "items"], issues, depth + 1);
|
|
38150
38322
|
} else if (Array.isArray(schema.items)) {
|
|
38151
|
-
pushIssue2(issues, [...
|
|
38323
|
+
pushIssue2(issues, [...path28, "items"], "items", "unsupported", `tuple-form "items" (an array of schemas) is not enforced by the workflow schema subset — use a single schema object`);
|
|
38152
38324
|
} else {
|
|
38153
|
-
pushIssue2(issues, [...
|
|
38325
|
+
pushIssue2(issues, [...path28, "items"], "items", "malformed", `"items" must be a schema object`);
|
|
38154
38326
|
}
|
|
38155
38327
|
}
|
|
38156
38328
|
if (schema.additionalProperties !== undefined && typeof schema.additionalProperties !== "boolean") {
|
|
38157
38329
|
if (isRecord(schema.additionalProperties)) {
|
|
38158
|
-
pushIssue2(issues, [...
|
|
38330
|
+
pushIssue2(issues, [...path28, "additionalProperties"], "additionalProperties", "unsupported", `schema-form "additionalProperties" is not enforced by the workflow schema subset — only "additionalProperties: false" is`);
|
|
38159
38331
|
} else {
|
|
38160
|
-
pushIssue2(issues, [...
|
|
38332
|
+
pushIssue2(issues, [...path28, "additionalProperties"], "additionalProperties", "malformed", `"additionalProperties" must be a boolean (only "false" is enforced)`);
|
|
38161
38333
|
}
|
|
38162
38334
|
}
|
|
38163
38335
|
for (const keyword of ["minItems", "maxItems", "minLength", "maxLength"]) {
|
|
38164
38336
|
const value = schema[keyword];
|
|
38165
38337
|
if (value !== undefined && (typeof value !== "number" || !Number.isInteger(value) || value < 0)) {
|
|
38166
|
-
pushIssue2(issues, [...
|
|
38338
|
+
pushIssue2(issues, [...path28, keyword], keyword, "malformed", `"${keyword}" must be a non-negative integer`);
|
|
38167
38339
|
}
|
|
38168
38340
|
}
|
|
38169
38341
|
for (const keyword of ["minimum", "maximum"]) {
|
|
38170
38342
|
const value = schema[keyword];
|
|
38171
38343
|
if (value !== undefined && (typeof value !== "number" || !Number.isFinite(value))) {
|
|
38172
|
-
pushIssue2(issues, [...
|
|
38344
|
+
pushIssue2(issues, [...path28, keyword], keyword, "malformed", `"${keyword}" must be a finite number`);
|
|
38173
38345
|
}
|
|
38174
38346
|
}
|
|
38175
38347
|
}
|
|
@@ -38194,9 +38366,9 @@ function matchesType(actual, expected) {
|
|
|
38194
38366
|
return true;
|
|
38195
38367
|
return expected === "number" && actual === "integer";
|
|
38196
38368
|
}
|
|
38197
|
-
function branchErrors(value, schema,
|
|
38369
|
+
function branchErrors(value, schema, path28, ctx) {
|
|
38198
38370
|
const errors4 = [];
|
|
38199
|
-
validateNode(value, schema,
|
|
38371
|
+
validateNode(value, schema, path28, { ...ctx, errors: errors4, depth: ctx.depth + 1 });
|
|
38200
38372
|
return errors4;
|
|
38201
38373
|
}
|
|
38202
38374
|
function combinatorBranches(schema, keyword) {
|
|
@@ -38211,9 +38383,9 @@ function summarizeBranchFailures(failures) {
|
|
|
38211
38383
|
shown.push(`…${failures.length - shown.length} more`);
|
|
38212
38384
|
return shown.join("; ");
|
|
38213
38385
|
}
|
|
38214
|
-
function validateCombinators(value, schema,
|
|
38386
|
+
function validateCombinators(value, schema, path28, ctx) {
|
|
38215
38387
|
for (const branch of combinatorBranches(schema, "allOf")) {
|
|
38216
|
-
ctx.errors.push(...branchErrors(value, branch,
|
|
38388
|
+
ctx.errors.push(...branchErrors(value, branch, path28, ctx));
|
|
38217
38389
|
}
|
|
38218
38390
|
for (const keyword of ["anyOf", "oneOf"]) {
|
|
38219
38391
|
const branches = combinatorBranches(schema, keyword);
|
|
@@ -38222,27 +38394,27 @@ function validateCombinators(value, schema, path27, ctx) {
|
|
|
38222
38394
|
const failures = [];
|
|
38223
38395
|
const matched = [];
|
|
38224
38396
|
branches.forEach((branch, index) => {
|
|
38225
|
-
const errors4 = branchErrors(value, branch,
|
|
38397
|
+
const errors4 = branchErrors(value, branch, path28, ctx);
|
|
38226
38398
|
if (errors4.length === 0)
|
|
38227
38399
|
matched.push(index + 1);
|
|
38228
38400
|
else
|
|
38229
38401
|
failures.push({ index, errors: errors4 });
|
|
38230
38402
|
});
|
|
38231
38403
|
if (matched.length === 0) {
|
|
38232
|
-
ctx.errors.push(`${
|
|
38404
|
+
ctx.errors.push(`${path28}: value matches none of the ${branches.length} "${keyword}" schemas (${summarizeBranchFailures(failures)})`);
|
|
38233
38405
|
} else if (keyword === "oneOf" && matched.length > 1) {
|
|
38234
|
-
ctx.errors.push(`${
|
|
38406
|
+
ctx.errors.push(`${path28}: value matches ${matched.length} "oneOf" schemas (branches ${matched.join(", ")}); exactly one must match`);
|
|
38235
38407
|
}
|
|
38236
38408
|
}
|
|
38237
38409
|
const not = schema.not;
|
|
38238
|
-
if (isRecord(not) && branchErrors(value, not,
|
|
38239
|
-
ctx.errors.push(`${
|
|
38410
|
+
if (isRecord(not) && branchErrors(value, not, path28, ctx).length === 0) {
|
|
38411
|
+
ctx.errors.push(`${path28}: value must not match the "not" schema`);
|
|
38240
38412
|
}
|
|
38241
38413
|
}
|
|
38242
|
-
function validateNode(value, schema,
|
|
38414
|
+
function validateNode(value, schema, path28, ctx) {
|
|
38243
38415
|
const errors4 = ctx.errors;
|
|
38244
38416
|
if (ctx.depth > MAX_DEFINITION_DEPTH) {
|
|
38245
|
-
errors4.push(`${
|
|
38417
|
+
errors4.push(`${path28}: schema nesting exceeds the depth limit of ${MAX_DEFINITION_DEPTH}`);
|
|
38246
38418
|
return;
|
|
38247
38419
|
}
|
|
38248
38420
|
const actual = typeOf(value);
|
|
@@ -38250,47 +38422,47 @@ function validateNode(value, schema, path27, ctx) {
|
|
|
38250
38422
|
if (typeof declared === "string" || Array.isArray(declared)) {
|
|
38251
38423
|
const expected = (Array.isArray(declared) ? declared : [declared]).filter((t) => typeof t === "string");
|
|
38252
38424
|
if (expected.length > 0 && !expected.some((t) => matchesType(actual, t))) {
|
|
38253
|
-
errors4.push(`${
|
|
38425
|
+
errors4.push(`${path28}: expected type ${expected.join(" | ")}, got ${actual}`);
|
|
38254
38426
|
return;
|
|
38255
38427
|
}
|
|
38256
38428
|
}
|
|
38257
38429
|
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
38258
38430
|
const allowed = schema.enum;
|
|
38259
38431
|
if (!allowed.some((candidate) => candidate === value)) {
|
|
38260
|
-
errors4.push(ctx.redactValues ? `${
|
|
38432
|
+
errors4.push(ctx.redactValues ? `${path28}: value is not one of ${JSON.stringify(allowed)}` : `${path28}: value ${JSON.stringify(value)} is not one of ${JSON.stringify(allowed)}`);
|
|
38261
38433
|
return;
|
|
38262
38434
|
}
|
|
38263
38435
|
}
|
|
38264
|
-
validateCombinators(value, schema,
|
|
38436
|
+
validateCombinators(value, schema, path28, ctx);
|
|
38265
38437
|
if (actual === "string" && typeof value === "string") {
|
|
38266
38438
|
if (typeof schema.minLength === "number" && value.length < schema.minLength) {
|
|
38267
|
-
errors4.push(`${
|
|
38439
|
+
errors4.push(`${path28}: string shorter than minLength ${schema.minLength}`);
|
|
38268
38440
|
}
|
|
38269
38441
|
if (typeof schema.maxLength === "number" && value.length > schema.maxLength) {
|
|
38270
|
-
errors4.push(`${
|
|
38442
|
+
errors4.push(`${path28}: string longer than maxLength ${schema.maxLength}`);
|
|
38271
38443
|
}
|
|
38272
38444
|
return;
|
|
38273
38445
|
}
|
|
38274
38446
|
if ((actual === "number" || actual === "integer") && typeof value === "number") {
|
|
38275
38447
|
if (typeof schema.minimum === "number" && value < schema.minimum) {
|
|
38276
|
-
errors4.push(ctx.redactValues ? `${
|
|
38448
|
+
errors4.push(ctx.redactValues ? `${path28}: value is below minimum ${schema.minimum}` : `${path28}: ${value} is below minimum ${schema.minimum}`);
|
|
38277
38449
|
}
|
|
38278
38450
|
if (typeof schema.maximum === "number" && value > schema.maximum) {
|
|
38279
|
-
errors4.push(ctx.redactValues ? `${
|
|
38451
|
+
errors4.push(ctx.redactValues ? `${path28}: value is above maximum ${schema.maximum}` : `${path28}: ${value} is above maximum ${schema.maximum}`);
|
|
38280
38452
|
}
|
|
38281
38453
|
return;
|
|
38282
38454
|
}
|
|
38283
38455
|
if (actual === "array" && Array.isArray(value)) {
|
|
38284
38456
|
if (typeof schema.minItems === "number" && value.length < schema.minItems) {
|
|
38285
|
-
errors4.push(`${
|
|
38457
|
+
errors4.push(`${path28}: array has fewer than minItems ${schema.minItems}`);
|
|
38286
38458
|
}
|
|
38287
38459
|
if (typeof schema.maxItems === "number" && value.length > schema.maxItems) {
|
|
38288
|
-
errors4.push(`${
|
|
38460
|
+
errors4.push(`${path28}: array has more than maxItems ${schema.maxItems}`);
|
|
38289
38461
|
}
|
|
38290
38462
|
const items = schema.items;
|
|
38291
38463
|
if (items && typeof items === "object" && !Array.isArray(items)) {
|
|
38292
38464
|
value.forEach((element, index) => {
|
|
38293
|
-
validateNode(element, items, `${
|
|
38465
|
+
validateNode(element, items, `${path28}[${index}]`, {
|
|
38294
38466
|
...ctx,
|
|
38295
38467
|
depth: ctx.depth + 1
|
|
38296
38468
|
});
|
|
@@ -38304,7 +38476,7 @@ function validateNode(value, schema, path27, ctx) {
|
|
|
38304
38476
|
if (Array.isArray(schema.required)) {
|
|
38305
38477
|
for (const key of schema.required) {
|
|
38306
38478
|
if (typeof key === "string" && !Object.hasOwn(record2, key)) {
|
|
38307
|
-
errors4.push(`${
|
|
38479
|
+
errors4.push(`${path28}: missing required property "${key}"`);
|
|
38308
38480
|
}
|
|
38309
38481
|
}
|
|
38310
38482
|
}
|
|
@@ -38313,7 +38485,7 @@ function validateNode(value, schema, path27, ctx) {
|
|
|
38313
38485
|
if (!Object.hasOwn(record2, key))
|
|
38314
38486
|
continue;
|
|
38315
38487
|
if (propSchema && typeof propSchema === "object" && !Array.isArray(propSchema)) {
|
|
38316
|
-
validateNode(record2[key], propSchema, `${
|
|
38488
|
+
validateNode(record2[key], propSchema, `${path28}.${key}`, {
|
|
38317
38489
|
...ctx,
|
|
38318
38490
|
depth: ctx.depth + 1
|
|
38319
38491
|
});
|
|
@@ -38323,7 +38495,7 @@ function validateNode(value, schema, path27, ctx) {
|
|
|
38323
38495
|
if (schema.additionalProperties === false) {
|
|
38324
38496
|
for (const key of Object.keys(record2)) {
|
|
38325
38497
|
if (!properties || !Object.hasOwn(properties, key)) {
|
|
38326
|
-
errors4.push(`${
|
|
38498
|
+
errors4.push(`${path28}: unexpected property "${key}" (additionalProperties: false)`);
|
|
38327
38499
|
}
|
|
38328
38500
|
}
|
|
38329
38501
|
}
|
|
@@ -38679,13 +38851,13 @@ function noGithubExpression(value, ctx, fieldPath) {
|
|
|
38679
38851
|
if (value.includes("${{"))
|
|
38680
38852
|
sourceError(ctx, fieldPath, "contains an unsupported GitHub expression.");
|
|
38681
38853
|
}
|
|
38682
|
-
function parseEnvironment(value, ctx,
|
|
38683
|
-
const environment = asRecord2(value, ctx,
|
|
38854
|
+
function parseEnvironment(value, ctx, path28 = ["env"]) {
|
|
38855
|
+
const environment = asRecord2(value, ctx, path28);
|
|
38684
38856
|
for (const [key, child] of Object.entries(environment)) {
|
|
38685
38857
|
if (!WORKFLOW_ENV_VAR_NAME_PATTERN.test(key))
|
|
38686
|
-
sourceError(ctx, [...
|
|
38858
|
+
sourceError(ctx, [...path28, key], "has an invalid environment variable name.");
|
|
38687
38859
|
if (typeof child !== "string" && typeof child !== "number" && typeof child !== "boolean") {
|
|
38688
|
-
sourceError(ctx, [...
|
|
38860
|
+
sourceError(ctx, [...path28, key], "must be a string, finite number, or boolean.");
|
|
38689
38861
|
}
|
|
38690
38862
|
}
|
|
38691
38863
|
return environment;
|
|
@@ -38939,31 +39111,31 @@ function valueLooksSecret(value) {
|
|
|
38939
39111
|
function detectSecretShapedParams(params) {
|
|
38940
39112
|
const warnings = [];
|
|
38941
39113
|
const seen = new Set;
|
|
38942
|
-
walkSecretShaped(params, (
|
|
38943
|
-
if (seen.has(
|
|
39114
|
+
walkSecretShaped(params, (path28, why) => {
|
|
39115
|
+
if (seen.has(path28))
|
|
38944
39116
|
return;
|
|
38945
|
-
seen.add(
|
|
38946
|
-
warnings.push(`Run param "${
|
|
39117
|
+
seen.add(path28);
|
|
39118
|
+
warnings.push(`Run param "${path28}" ${why}. ${MOVE_TO_ENV} (Heuristic warning; params are declared non-secret.)`);
|
|
38947
39119
|
});
|
|
38948
39120
|
return warnings;
|
|
38949
39121
|
}
|
|
38950
39122
|
function walkSecretShaped(params, hit) {
|
|
38951
|
-
const walk = (value,
|
|
39123
|
+
const walk = (value, path28, key) => {
|
|
38952
39124
|
if (key !== null && keyLooksSecret(key))
|
|
38953
|
-
hit(
|
|
39125
|
+
hit(path28, "has a secret-suggesting name", value);
|
|
38954
39126
|
if (typeof value === "string") {
|
|
38955
39127
|
if (valueLooksSecret(value))
|
|
38956
|
-
hit(
|
|
39128
|
+
hit(path28, "has a secret-shaped value (long, high-entropy string)", value);
|
|
38957
39129
|
return;
|
|
38958
39130
|
}
|
|
38959
39131
|
if (Array.isArray(value)) {
|
|
38960
39132
|
for (let i = 0;i < value.length; i++)
|
|
38961
|
-
walk(value[i], `${
|
|
39133
|
+
walk(value[i], `${path28}[${i}]`, null);
|
|
38962
39134
|
return;
|
|
38963
39135
|
}
|
|
38964
39136
|
if (value && typeof value === "object") {
|
|
38965
39137
|
for (const [k, v] of Object.entries(value)) {
|
|
38966
|
-
walk(v,
|
|
39138
|
+
walk(v, path28 ? `${path28}.${k}` : k, k);
|
|
38967
39139
|
}
|
|
38968
39140
|
}
|
|
38969
39141
|
};
|
|
@@ -39075,21 +39247,21 @@ function classifyTaskSourceV4Uses(value) {
|
|
|
39075
39247
|
}
|
|
39076
39248
|
return Object.freeze({ kind: classified.kind, ref: classified.ref });
|
|
39077
39249
|
}
|
|
39078
|
-
function nullableSelectorTopLevel(value, ctx, key,
|
|
39079
|
-
const selector = stringField(value, ctx,
|
|
39250
|
+
function nullableSelectorTopLevel(value, ctx, key, path28 = [key]) {
|
|
39251
|
+
const selector = stringField(value, ctx, path28, { nullable: true });
|
|
39080
39252
|
if (selector !== null && selector.trim().length === 0)
|
|
39081
|
-
sourceError(ctx,
|
|
39253
|
+
sourceError(ctx, path28, "must be null or a non-empty string.");
|
|
39082
39254
|
return selector;
|
|
39083
39255
|
}
|
|
39084
|
-
function parseTimeoutTopLevel(value, ctx,
|
|
39256
|
+
function parseTimeoutTopLevel(value, ctx, path28 = ["timeout"]) {
|
|
39085
39257
|
if (value === null)
|
|
39086
39258
|
return null;
|
|
39087
39259
|
if (typeof value === "string" && value.trim() !== value) {
|
|
39088
|
-
sourceError(ctx,
|
|
39260
|
+
sourceError(ctx, path28, "must not contain surrounding whitespace.");
|
|
39089
39261
|
}
|
|
39090
39262
|
const milliseconds = typeof value === "string" ? parseDuration(value, DURATION_UNITS) : value;
|
|
39091
39263
|
if (milliseconds === null || typeof milliseconds !== "number" || !Number.isSafeInteger(milliseconds) || milliseconds < 0 || milliseconds > EXECUTION_MAX_TIMEOUT_MS) {
|
|
39092
|
-
sourceError(ctx,
|
|
39264
|
+
sourceError(ctx, path28, `must be null, 0 through ${EXECUTION_MAX_TIMEOUT_MS} milliseconds, or a common duration such as 20m.`);
|
|
39093
39265
|
}
|
|
39094
39266
|
return value;
|
|
39095
39267
|
}
|
|
@@ -39110,8 +39282,8 @@ function parseShellAndDirectory(input2, ctx) {
|
|
|
39110
39282
|
}
|
|
39111
39283
|
return { ...shell ? { shell } : {}, ...workingDirectory ? { workingDirectory } : {} };
|
|
39112
39284
|
}
|
|
39113
|
-
function parseStepPrompt(value, ctx,
|
|
39114
|
-
const text2 = stringField(value, ctx,
|
|
39285
|
+
function parseStepPrompt(value, ctx, path28) {
|
|
39286
|
+
const text2 = stringField(value, ctx, path28, { nonempty: true });
|
|
39115
39287
|
if (!/\s/.test(text2)) {
|
|
39116
39288
|
let classified;
|
|
39117
39289
|
try {
|
|
@@ -39122,48 +39294,48 @@ function parseStepPrompt(value, ctx, path27) {
|
|
|
39122
39294
|
if (classified?.kind === "command")
|
|
39123
39295
|
return Object.freeze({ kind: "ref", ref: classified.ref });
|
|
39124
39296
|
if (classified)
|
|
39125
|
-
sourceError(ctx,
|
|
39297
|
+
sourceError(ctx, path28, "names a non-command asset; use a commands/ ref or inline prompt text.");
|
|
39126
39298
|
}
|
|
39127
39299
|
return Object.freeze({ kind: "inline", content: text2 });
|
|
39128
39300
|
}
|
|
39129
39301
|
function parseStep(raw, index, ctx) {
|
|
39130
|
-
const
|
|
39131
|
-
const step = asRecord2(raw, ctx,
|
|
39132
|
-
checkKeys(step, TASK_SOURCE_V4_STEP_KEYS, ctx,
|
|
39302
|
+
const path28 = ["steps", index];
|
|
39303
|
+
const step = asRecord2(raw, ctx, path28);
|
|
39304
|
+
checkKeys(step, TASK_SOURCE_V4_STEP_KEYS, ctx, path28);
|
|
39133
39305
|
if (!own3(step, "name"))
|
|
39134
|
-
sourceError(ctx, [...
|
|
39135
|
-
const name = stringField(step.name, ctx, [...
|
|
39306
|
+
sourceError(ctx, [...path28, "name"], "is required.");
|
|
39307
|
+
const name = stringField(step.name, ctx, [...path28, "name"]);
|
|
39136
39308
|
if (!STEP_NAME_PATTERN.test(name)) {
|
|
39137
|
-
sourceError(ctx, [...
|
|
39309
|
+
sourceError(ctx, [...path28, "name"], "must be 1-64 letters, digits, '_' or '-', starting with a letter or digit.");
|
|
39138
39310
|
}
|
|
39139
39311
|
const selectors = ["run", "prompt", "task"].filter((key) => own3(step, key));
|
|
39140
39312
|
if (selectors.length !== 1)
|
|
39141
|
-
sourceError(ctx,
|
|
39313
|
+
sourceError(ctx, path28, "requires exactly one of run, prompt or task.");
|
|
39142
39314
|
const kind = selectors[0];
|
|
39143
39315
|
if (kind !== "prompt") {
|
|
39144
39316
|
const stray = PROMPT_ONLY_STEP_KEYS.find((key) => own3(step, key));
|
|
39145
39317
|
if (stray)
|
|
39146
|
-
sourceError(ctx, [...
|
|
39318
|
+
sourceError(ctx, [...path28, stray], "is legal only on a prompt step.");
|
|
39147
39319
|
}
|
|
39148
39320
|
let env;
|
|
39149
39321
|
if (own3(step, "env")) {
|
|
39150
|
-
env = parseEnvironment(presentJsonValue(step.env, ctx, [...
|
|
39322
|
+
env = parseEnvironment(presentJsonValue(step.env, ctx, [...path28, "env"]), ctx, [...path28, "env"]);
|
|
39151
39323
|
}
|
|
39152
|
-
const timeout = own3(step, "timeout") ? parseTimeoutTopLevel(step.timeout, ctx, [...
|
|
39324
|
+
const timeout = own3(step, "timeout") ? parseTimeoutTopLevel(step.timeout, ctx, [...path28, "timeout"]) : undefined;
|
|
39153
39325
|
let retries = 0;
|
|
39154
39326
|
if (own3(step, "retries")) {
|
|
39155
39327
|
if (!Number.isSafeInteger(step.retries) || step.retries < 0 || step.retries > TASK_SOURCE_V4_MAX_STEP_RETRIES) {
|
|
39156
|
-
sourceError(ctx, [...
|
|
39328
|
+
sourceError(ctx, [...path28, "retries"], `must be an integer from 0 to ${TASK_SOURCE_V4_MAX_STEP_RETRIES}.`);
|
|
39157
39329
|
}
|
|
39158
39330
|
retries = step.retries;
|
|
39159
39331
|
}
|
|
39160
39332
|
const common = { name, ...env ? { env } : {}, ...timeout !== undefined ? { timeout } : {}, retries };
|
|
39161
39333
|
if (kind === "run") {
|
|
39162
|
-
const run = stringField(step.run, ctx, [...
|
|
39334
|
+
const run = stringField(step.run, ctx, [...path28, "run"], { nonempty: true });
|
|
39163
39335
|
return Object.freeze({ ...common, kind, run });
|
|
39164
39336
|
}
|
|
39165
39337
|
if (kind === "task") {
|
|
39166
|
-
const text2 = stringField(step.task, ctx, [...
|
|
39338
|
+
const text2 = stringField(step.task, ctx, [...path28, "task"], { nonempty: true });
|
|
39167
39339
|
let ref;
|
|
39168
39340
|
try {
|
|
39169
39341
|
const classified = classifyTargetRef(text2);
|
|
@@ -39171,21 +39343,21 @@ function parseStep(raw, index, ctx) {
|
|
|
39171
39343
|
throw new UsageError("not a task ref");
|
|
39172
39344
|
ref = classified.ref;
|
|
39173
39345
|
} catch {
|
|
39174
|
-
sourceError(ctx, [...
|
|
39346
|
+
sourceError(ctx, [...path28, "task"], "must be a canonical tasks/ ref (optionally <bundle>//tasks/<name>).");
|
|
39175
39347
|
}
|
|
39176
39348
|
return Object.freeze({ ...common, kind, ref });
|
|
39177
39349
|
}
|
|
39178
|
-
const prompt = parseStepPrompt(step.prompt, ctx, [...
|
|
39350
|
+
const prompt = parseStepPrompt(step.prompt, ctx, [...path28, "prompt"]);
|
|
39179
39351
|
const selectors2 = {};
|
|
39180
39352
|
for (const key of ["harness", "connection", "model"]) {
|
|
39181
39353
|
if (own3(step, key))
|
|
39182
|
-
selectors2[key] = nullableSelectorTopLevel(step[key], ctx, key, [...
|
|
39354
|
+
selectors2[key] = nullableSelectorTopLevel(step[key], ctx, key, [...path28, key]);
|
|
39183
39355
|
}
|
|
39184
39356
|
let expect;
|
|
39185
39357
|
if (own3(step, "expect")) {
|
|
39186
|
-
expect = parseStringArray(step.expect, ctx, [...
|
|
39358
|
+
expect = parseStringArray(step.expect, ctx, [...path28, "expect"], { max: 32 });
|
|
39187
39359
|
if (expect.length === 0 || new Set(expect).size !== expect.length) {
|
|
39188
|
-
sourceError(ctx, [...
|
|
39360
|
+
sourceError(ctx, [...path28, "expect"], "must be a non-empty list of distinct field names.");
|
|
39189
39361
|
}
|
|
39190
39362
|
}
|
|
39191
39363
|
return Object.freeze({ ...common, kind, prompt, ...selectors2, ...expect ? { expect } : {} });
|
|
@@ -39669,10 +39841,10 @@ function parseReference(source) {
|
|
|
39669
39841
|
if (!output2 || output2.name !== "output") {
|
|
39670
39842
|
return { ok: false, message: `Expected ".output" after "steps.${stepId.name}" in "${text2}".` };
|
|
39671
39843
|
}
|
|
39672
|
-
const
|
|
39673
|
-
if (!
|
|
39674
|
-
return { ok: false, message:
|
|
39675
|
-
return { ok: true, expr: { kind: "stepOutput", stepId: stepId.name, path:
|
|
39844
|
+
const path28 = parsePath(text2, output2.end);
|
|
39845
|
+
if (!path28.ok)
|
|
39846
|
+
return { ok: false, message: path28.message };
|
|
39847
|
+
return { ok: true, expr: { kind: "stepOutput", stepId: stepId.name, path: path28.path } };
|
|
39676
39848
|
}
|
|
39677
39849
|
default:
|
|
39678
39850
|
return { ok: false, message: `Unknown root "${root.name}" in "${text2}"; ${GRAMMAR_HINT}.` };
|
|
@@ -39687,7 +39859,7 @@ function readIdent(text2, start) {
|
|
|
39687
39859
|
return { name: text2.slice(start, end), end };
|
|
39688
39860
|
}
|
|
39689
39861
|
function parsePath(text2, start) {
|
|
39690
|
-
const
|
|
39862
|
+
const path28 = [];
|
|
39691
39863
|
let i = start;
|
|
39692
39864
|
while (i < text2.length) {
|
|
39693
39865
|
const char = text2[i];
|
|
@@ -39696,7 +39868,7 @@ function parsePath(text2, start) {
|
|
|
39696
39868
|
if (!ident) {
|
|
39697
39869
|
return { ok: false, message: `Invalid path segment after "." at position ${i} in "${text2}".` };
|
|
39698
39870
|
}
|
|
39699
|
-
|
|
39871
|
+
path28.push(ident.name);
|
|
39700
39872
|
i = ident.end;
|
|
39701
39873
|
} else if (char === "[") {
|
|
39702
39874
|
let j = i + 1;
|
|
@@ -39708,13 +39880,13 @@ function parsePath(text2, start) {
|
|
|
39708
39880
|
message: `Invalid indexer at position ${i} in "${text2}" — expected [<non-negative integer>].`
|
|
39709
39881
|
};
|
|
39710
39882
|
}
|
|
39711
|
-
|
|
39883
|
+
path28.push(Number.parseInt(text2.slice(i + 1, j), 10));
|
|
39712
39884
|
i = j + 1;
|
|
39713
39885
|
} else {
|
|
39714
39886
|
return { ok: false, message: `Unexpected character "${char}" at position ${i} in "${text2}".` };
|
|
39715
39887
|
}
|
|
39716
39888
|
}
|
|
39717
|
-
return { ok: true, path:
|
|
39889
|
+
return { ok: true, path: path28 };
|
|
39718
39890
|
}
|
|
39719
39891
|
function formatReference(expr) {
|
|
39720
39892
|
switch (expr.kind) {
|
|
@@ -39740,7 +39912,7 @@ function parseWorkflow(markdown, source) {
|
|
|
39740
39912
|
};
|
|
39741
39913
|
}
|
|
39742
39914
|
const errors4 = [];
|
|
39743
|
-
const
|
|
39915
|
+
const path28 = source.path;
|
|
39744
39916
|
const lines = markdown.split(/\r?\n/);
|
|
39745
39917
|
const totalLines = lines.length;
|
|
39746
39918
|
const fmBlock = parseFrontmatterBlock(markdown);
|
|
@@ -39792,7 +39964,7 @@ function parseWorkflow(markdown, source) {
|
|
|
39792
39964
|
return 2;
|
|
39793
39965
|
};
|
|
39794
39966
|
const ctx = {
|
|
39795
|
-
filePath:
|
|
39967
|
+
filePath: path28,
|
|
39796
39968
|
errors: errors4,
|
|
39797
39969
|
lineAt,
|
|
39798
39970
|
lineAtOffset: (offset) => Math.max(1, lineCounter2.linePos(offset).line + lineOffset),
|
|
@@ -39804,10 +39976,10 @@ function parseWorkflow(markdown, source) {
|
|
|
39804
39976
|
if (range) {
|
|
39805
39977
|
const start = Math.max(1, lineCounter2.linePos(range[0]).line + lineOffset);
|
|
39806
39978
|
const end = Math.max(start, lineCounter2.linePos(Math.max(range[0], range[1] - 1)).line + lineOffset);
|
|
39807
|
-
return { path:
|
|
39979
|
+
return { path: path28, start, end };
|
|
39808
39980
|
}
|
|
39809
39981
|
}
|
|
39810
|
-
return { path:
|
|
39982
|
+
return { path: path28, start: frontmatterEndLine, end: frontmatterEndLine };
|
|
39811
39983
|
},
|
|
39812
39984
|
err: (p, message) => errors4.push({ line: lineAt(p), message }),
|
|
39813
39985
|
errAtLine: (line, message) => errors4.push({ line, message })
|
|
@@ -39830,7 +40002,7 @@ function parseWorkflow(markdown, source) {
|
|
|
39830
40002
|
const parsedSteps = parseSteps(ctx, root.steps);
|
|
39831
40003
|
const toc = parseMarkdownToc(markdown);
|
|
39832
40004
|
const declaredIds = new Set(parsedSteps.map((s) => s.id));
|
|
39833
|
-
const { sections, preamble } = bindStepSections(toc.headings, lines, fmBlock.bodyStartLine, totalLines,
|
|
40005
|
+
const { sections, preamble } = bindStepSections(toc.headings, lines, fmBlock.bodyStartLine, totalLines, path28, declaredIds, errors4);
|
|
39834
40006
|
const steps = parsedSteps.map((step, index) => {
|
|
39835
40007
|
const section2 = sections.get(step.id);
|
|
39836
40008
|
if (!section2) {
|
|
@@ -39875,7 +40047,7 @@ function parseWorkflow(markdown, source) {
|
|
|
39875
40047
|
const paramNames = params ? Object.keys(params) : [];
|
|
39876
40048
|
const plan = {
|
|
39877
40049
|
irVersion: WORKFLOW_PLAN_VERSION,
|
|
39878
|
-
title: source.title ??
|
|
40050
|
+
title: source.title ?? path28.replace(/^.*[\\/]/, "").replace(/\.[^.]*$/, ""),
|
|
39879
40051
|
...params && paramNames.length > 0 ? { params: paramNames, paramSchemas: params } : {},
|
|
39880
40052
|
...budget ? { budget } : {},
|
|
39881
40053
|
...defaults ? { defaults } : {},
|
|
@@ -39925,7 +40097,7 @@ function checkCanonicalXrefs(value, line, errors4) {
|
|
|
39925
40097
|
}
|
|
39926
40098
|
}
|
|
39927
40099
|
}
|
|
39928
|
-
function bindStepSections(headings, lines, bodyStartLine, totalLines,
|
|
40100
|
+
function bindStepSections(headings, lines, bodyStartLine, totalLines, path28, declaredIds, errors4) {
|
|
39929
40101
|
const sections = new Map;
|
|
39930
40102
|
const h2s = headings.filter((h) => h.level === 2);
|
|
39931
40103
|
const firstH2Line = h2s[0]?.line;
|
|
@@ -39949,24 +40121,24 @@ function bindStepSections(headings, lines, bodyStartLine, totalLines, path27, de
|
|
|
39949
40121
|
continue;
|
|
39950
40122
|
}
|
|
39951
40123
|
const sectionEnd = findNextHeadingAtOrAboveLevel(headings, i, 2, totalLines);
|
|
39952
|
-
const gate = findGateSubsection(headings, i, sectionEnd,
|
|
40124
|
+
const gate = findGateSubsection(headings, i, sectionEnd, path28, h.text, errors4);
|
|
39953
40125
|
const instructionsEnd = gate ? gate.headingLine - 1 : sectionEnd;
|
|
39954
40126
|
const instructionsText = sliceProseLines(lines, h.line + 1, instructionsEnd);
|
|
39955
40127
|
const section2 = { headingLine: h.line };
|
|
39956
40128
|
if (instructionsText) {
|
|
39957
|
-
section2.instructions = { text: instructionsText, source: { path:
|
|
40129
|
+
section2.instructions = { text: instructionsText, source: { path: path28, start: h.line + 1, end: instructionsEnd } };
|
|
39958
40130
|
}
|
|
39959
40131
|
if (gate) {
|
|
39960
40132
|
const gateText = sliceProseLines(lines, gate.bodyStart, gate.bodyEnd);
|
|
39961
40133
|
if (gateText) {
|
|
39962
|
-
section2.gateRubric = { text: gateText, source: { path:
|
|
40134
|
+
section2.gateRubric = { text: gateText, source: { path: path28, start: gate.bodyStart, end: gate.bodyEnd } };
|
|
39963
40135
|
}
|
|
39964
40136
|
}
|
|
39965
40137
|
sections.set(h.text, section2);
|
|
39966
40138
|
}
|
|
39967
40139
|
return { sections, preamble: preambleRaw || undefined };
|
|
39968
40140
|
}
|
|
39969
|
-
function findGateSubsection(headings, stepHeadingIndex, sectionEnd,
|
|
40141
|
+
function findGateSubsection(headings, stepHeadingIndex, sectionEnd, path28, stepId, errors4) {
|
|
39970
40142
|
let found;
|
|
39971
40143
|
for (let j = stepHeadingIndex + 1;j < headings.length; j++) {
|
|
39972
40144
|
const h = headings[j];
|
|
@@ -40048,19 +40220,19 @@ function checkEnvelopeFields(ctx, root, fmEndLine) {
|
|
|
40048
40220
|
ctx.err(["stale_after"], `Workflow frontmatter "stale_after" must be a string.`);
|
|
40049
40221
|
}
|
|
40050
40222
|
}
|
|
40051
|
-
function checkActorStamp(ctx, value,
|
|
40223
|
+
function checkActorStamp(ctx, value, path28, label) {
|
|
40052
40224
|
if (value === undefined)
|
|
40053
40225
|
return;
|
|
40054
40226
|
if (!isRecord(value)) {
|
|
40055
|
-
ctx.err(
|
|
40227
|
+
ctx.err(path28, `Workflow frontmatter ${label} must be a mapping with a non-empty "by".`);
|
|
40056
40228
|
return;
|
|
40057
40229
|
}
|
|
40058
|
-
checkUnknownKeys(ctx, value,
|
|
40230
|
+
checkUnknownKeys(ctx, value, path28, ACTOR_STAMP_KEYS, `${label} actor stamp`);
|
|
40059
40231
|
if (typeof value.by !== "string" || value.by.length === 0) {
|
|
40060
|
-
ctx.err([...
|
|
40232
|
+
ctx.err([...path28, "by"], `Workflow frontmatter ${label} must be a mapping with a non-empty "by".`);
|
|
40061
40233
|
}
|
|
40062
40234
|
if (value.at !== undefined && typeof value.at !== "string") {
|
|
40063
|
-
ctx.err([...
|
|
40235
|
+
ctx.err([...path28, "at"], `Workflow frontmatter ${label} actor stamp "at" must be a string.`);
|
|
40064
40236
|
}
|
|
40065
40237
|
}
|
|
40066
40238
|
function readTags2(ctx, value, fmEndLine) {
|
|
@@ -40107,17 +40279,17 @@ function parseParams(ctx, raw) {
|
|
|
40107
40279
|
function parseDefaults(ctx, raw) {
|
|
40108
40280
|
if (raw === undefined)
|
|
40109
40281
|
return;
|
|
40110
|
-
const
|
|
40282
|
+
const path28 = ["defaults"];
|
|
40111
40283
|
if (!isRecord(raw)) {
|
|
40112
|
-
ctx.err(
|
|
40284
|
+
ctx.err(path28, `"defaults" must be a mapping with any of: ${DEFAULTS_KEYS.join(", ")}.`);
|
|
40113
40285
|
return;
|
|
40114
40286
|
}
|
|
40115
|
-
checkUnknownKeys(ctx, raw,
|
|
40287
|
+
checkUnknownKeys(ctx, raw, path28, DEFAULTS_KEYS, `"defaults"`);
|
|
40116
40288
|
const defaults = {};
|
|
40117
40289
|
for (const key of ["connection", "harness", "engine"]) {
|
|
40118
40290
|
if (raw[key] === undefined)
|
|
40119
40291
|
continue;
|
|
40120
|
-
const name = parseEngineName(ctx, raw[key], [...
|
|
40292
|
+
const name = parseEngineName(ctx, raw[key], [...path28, key], `"defaults.${key}"`);
|
|
40121
40293
|
if (name !== undefined)
|
|
40122
40294
|
defaults[key] = name;
|
|
40123
40295
|
if (key === "engine")
|
|
@@ -40127,15 +40299,15 @@ function parseDefaults(ctx, raw) {
|
|
|
40127
40299
|
if (typeof raw.model === "string" && raw.model.trim() !== "")
|
|
40128
40300
|
defaults.model = raw.model.trim();
|
|
40129
40301
|
else
|
|
40130
|
-
ctx.err([...
|
|
40302
|
+
ctx.err([...path28, "model"], `"defaults.model" must be a non-empty string (a model alias or exact id).`);
|
|
40131
40303
|
}
|
|
40132
|
-
const timeoutMs = parseTimeoutField(ctx, raw.timeout, [...
|
|
40304
|
+
const timeoutMs = parseTimeoutField(ctx, raw.timeout, [...path28, "timeout"], `"defaults.timeout"`);
|
|
40133
40305
|
if (timeoutMs !== undefined)
|
|
40134
40306
|
defaults.timeoutMs = timeoutMs;
|
|
40135
|
-
const onError = parseEnumField(ctx, raw.on_error, [...
|
|
40307
|
+
const onError = parseEnumField(ctx, raw.on_error, [...path28, "on_error"], `"defaults.on_error"`, PROGRAM_ON_ERROR);
|
|
40136
40308
|
if (onError !== undefined)
|
|
40137
40309
|
defaults.onError = onError;
|
|
40138
|
-
const llm = parseLlmOverrides(ctx, raw.llm, [...
|
|
40310
|
+
const llm = parseLlmOverrides(ctx, raw.llm, [...path28, "llm"], `"defaults.llm"`);
|
|
40139
40311
|
if (llm !== undefined)
|
|
40140
40312
|
defaults.llm = llm;
|
|
40141
40313
|
return Object.keys(defaults).length > 0 ? defaults : undefined;
|
|
@@ -40143,25 +40315,25 @@ function parseDefaults(ctx, raw) {
|
|
|
40143
40315
|
function parseBudget(ctx, raw) {
|
|
40144
40316
|
if (raw === undefined)
|
|
40145
40317
|
return;
|
|
40146
|
-
const
|
|
40318
|
+
const path28 = ["budget"];
|
|
40147
40319
|
if (!isRecord(raw)) {
|
|
40148
|
-
ctx.err(
|
|
40320
|
+
ctx.err(path28, `"budget" must be a mapping with any of: ${BUDGET_KEYS.join(", ")}.`);
|
|
40149
40321
|
return;
|
|
40150
40322
|
}
|
|
40151
|
-
checkUnknownKeys(ctx, raw,
|
|
40323
|
+
checkUnknownKeys(ctx, raw, path28, BUDGET_KEYS, `"budget"`);
|
|
40152
40324
|
const budget = {};
|
|
40153
40325
|
if (raw.max_tokens !== undefined) {
|
|
40154
40326
|
if (typeof raw.max_tokens === "number" && Number.isInteger(raw.max_tokens) && raw.max_tokens >= 1) {
|
|
40155
40327
|
budget.maxTokens = raw.max_tokens;
|
|
40156
40328
|
} else {
|
|
40157
|
-
ctx.err([...
|
|
40329
|
+
ctx.err([...path28, "max_tokens"], `"budget.max_tokens" must be an integer >= 1.`);
|
|
40158
40330
|
}
|
|
40159
40331
|
}
|
|
40160
40332
|
if (raw.max_units !== undefined) {
|
|
40161
40333
|
if (typeof raw.max_units === "number" && Number.isInteger(raw.max_units) && raw.max_units >= 1) {
|
|
40162
40334
|
budget.maxUnits = raw.max_units;
|
|
40163
40335
|
} else {
|
|
40164
|
-
ctx.err([...
|
|
40336
|
+
ctx.err([...path28, "max_units"], `"budget.max_units" must be an integer >= 1.`);
|
|
40165
40337
|
}
|
|
40166
40338
|
}
|
|
40167
40339
|
return Object.keys(budget).length > 0 ? budget : undefined;
|
|
@@ -40174,38 +40346,38 @@ function parseSteps(ctx, raw) {
|
|
|
40174
40346
|
const steps = [];
|
|
40175
40347
|
const seenIds = new Map;
|
|
40176
40348
|
raw.forEach((rawStep, index) => {
|
|
40177
|
-
const
|
|
40349
|
+
const path28 = ["steps", index];
|
|
40178
40350
|
if (!isRecord(rawStep)) {
|
|
40179
|
-
ctx.err(
|
|
40351
|
+
ctx.err(path28, `Step ${index + 1} must be a mapping with an "id".`);
|
|
40180
40352
|
return;
|
|
40181
40353
|
}
|
|
40182
40354
|
const label = typeof rawStep.id === "string" && rawStep.id !== "" ? `Step "${rawStep.id}"` : `Step ${index + 1}`;
|
|
40183
40355
|
const isMapStep = rawStep.map !== undefined;
|
|
40184
40356
|
const unitKeyHome = isMapStep ? "map.unit:" : "unit:";
|
|
40185
|
-
checkUnknownKeys(ctx, rawStep,
|
|
40357
|
+
checkUnknownKeys(ctx, rawStep, path28, STEP_KEYS, label, (key) => UNIT_KEYS.includes(key) ? ` (this belongs under "${unitKeyHome}")` : "");
|
|
40186
40358
|
let id = "";
|
|
40187
40359
|
if (typeof rawStep.id !== "string" || rawStep.id === "") {
|
|
40188
|
-
ctx.err([...
|
|
40360
|
+
ctx.err([...path28, "id"], `${label} requires a non-empty string "id".`);
|
|
40189
40361
|
} else if (!PROGRAM_STEP_ID_PATTERN.test(rawStep.id)) {
|
|
40190
|
-
ctx.err([...
|
|
40362
|
+
ctx.err([...path28, "id"], `${label} has an invalid id "${rawStep.id}". A step id cannot be referenced from steps.${rawStep.id}.output ` + `unless it matches [A-Za-z_][A-Za-z0-9_-]* (a letter or underscore first, then letters, digits, ` + `underscores, or dashes; no dots, no leading digit).`);
|
|
40191
40363
|
} else {
|
|
40192
40364
|
id = rawStep.id;
|
|
40193
40365
|
const firstIndex = seenIds.get(id);
|
|
40194
40366
|
if (firstIndex !== undefined) {
|
|
40195
|
-
ctx.err([...
|
|
40367
|
+
ctx.err([...path28, "id"], `Duplicate step id "${id}" (first used by step ${firstIndex + 1}). Step ids must be unique.`);
|
|
40196
40368
|
} else {
|
|
40197
40369
|
seenIds.set(id, index);
|
|
40198
40370
|
}
|
|
40199
40371
|
}
|
|
40200
40372
|
if (isMapStep && rawStep.unit !== undefined) {
|
|
40201
|
-
ctx.err(
|
|
40202
|
-
}
|
|
40203
|
-
const unit = rawStep.unit !== undefined && !isMapStep ? parseUnit(ctx, rawStep.unit, [...
|
|
40204
|
-
const map2 = isMapStep ? parseMap(ctx, rawStep.map, [...
|
|
40205
|
-
const inputs = parseInputs(ctx, rawStep.inputs, [...
|
|
40206
|
-
const output2 = parseSchemaObject(ctx, rawStep.output, [...
|
|
40207
|
-
const gate = rawStep.gate !== undefined ? parseGate(ctx, rawStep.gate, [...
|
|
40208
|
-
const step = { id, source: ctx.refAt(
|
|
40373
|
+
ctx.err(path28, `${label} is a map step; the per-item dispatch-override bag belongs at "map.unit", not top-level "unit".`);
|
|
40374
|
+
}
|
|
40375
|
+
const unit = rawStep.unit !== undefined && !isMapStep ? parseUnit(ctx, rawStep.unit, [...path28, "unit"], label) : undefined;
|
|
40376
|
+
const map2 = isMapStep ? parseMap(ctx, rawStep.map, [...path28, "map"], label) : undefined;
|
|
40377
|
+
const inputs = parseInputs(ctx, rawStep.inputs, [...path28, "inputs"], label);
|
|
40378
|
+
const output2 = parseSchemaObject(ctx, rawStep.output, [...path28, "output"], `${label} "output"`);
|
|
40379
|
+
const gate = rawStep.gate !== undefined ? parseGate(ctx, rawStep.gate, [...path28, "gate"], label) : undefined;
|
|
40380
|
+
const step = { id, source: ctx.refAt(path28) };
|
|
40209
40381
|
if (unit)
|
|
40210
40382
|
step.unit = unit;
|
|
40211
40383
|
if (output2 !== undefined && !isMapStep && unit?.output === undefined && unit?.workflow === undefined) {
|
|
@@ -40223,41 +40395,41 @@ function parseSteps(ctx, raw) {
|
|
|
40223
40395
|
});
|
|
40224
40396
|
return steps;
|
|
40225
40397
|
}
|
|
40226
|
-
function parseUnit(ctx, raw,
|
|
40398
|
+
function parseUnit(ctx, raw, path28, stepLabel, allowWorkflow = true) {
|
|
40227
40399
|
if (!isRecord(raw)) {
|
|
40228
|
-
ctx.err(
|
|
40400
|
+
ctx.err(path28, `${stepLabel} "unit" must be a mapping (a dispatch-override bag).`);
|
|
40229
40401
|
return;
|
|
40230
40402
|
}
|
|
40231
|
-
checkUnknownKeys(ctx, raw,
|
|
40232
|
-
const unit = { source: ctx.refAt(
|
|
40403
|
+
checkUnknownKeys(ctx, raw, path28, UNIT_KEYS, `${stepLabel} "unit"`);
|
|
40404
|
+
const unit = { source: ctx.refAt(path28) };
|
|
40233
40405
|
if (raw.exec !== undefined) {
|
|
40234
|
-
const exec = parseExec(ctx, raw.exec, [...
|
|
40406
|
+
const exec = parseExec(ctx, raw.exec, [...path28, "exec"], stepLabel);
|
|
40235
40407
|
if (exec !== undefined)
|
|
40236
40408
|
unit.exec = exec;
|
|
40237
40409
|
for (const key of UNIT_ENGINE_KEYS) {
|
|
40238
40410
|
if (raw[key] === undefined)
|
|
40239
40411
|
continue;
|
|
40240
|
-
ctx.err([...
|
|
40412
|
+
ctx.err([...path28, key], `${stepLabel} "unit" declares both "exec" and "${key}". An exec unit runs a shell command and never ` + `reaches an engine, so "${key}" would have no effect — remove one of the two.`);
|
|
40241
40413
|
}
|
|
40242
40414
|
}
|
|
40243
40415
|
if (raw.workflow !== undefined) {
|
|
40244
|
-
const workflow = parseChildWorkflowRef(ctx, raw.workflow, [...
|
|
40416
|
+
const workflow = parseChildWorkflowRef(ctx, raw.workflow, [...path28, "workflow"], stepLabel, allowWorkflow);
|
|
40245
40417
|
if (workflow !== undefined)
|
|
40246
40418
|
unit.workflow = workflow;
|
|
40247
40419
|
if (raw.exec !== undefined) {
|
|
40248
|
-
ctx.err([...
|
|
40420
|
+
ctx.err([...path28, "workflow"], `${stepLabel} "unit" declares both "exec" and "workflow" — a unit runs one or the other.`);
|
|
40249
40421
|
}
|
|
40250
40422
|
for (const key of [...UNIT_ENGINE_KEYS, "env"]) {
|
|
40251
40423
|
if (raw[key] === undefined)
|
|
40252
40424
|
continue;
|
|
40253
|
-
ctx.err([...
|
|
40425
|
+
ctx.err([...path28, key], `${stepLabel} "unit" declares both "workflow" and "${key}". A workflow unit starts a child run and never ` + `reaches an engine or an environment of its own, so "${key}" would have no effect — set it in the child workflow.`);
|
|
40254
40426
|
}
|
|
40255
40427
|
}
|
|
40256
40428
|
if (raw.with !== undefined) {
|
|
40257
40429
|
if (raw.workflow === undefined) {
|
|
40258
|
-
ctx.err([...
|
|
40430
|
+
ctx.err([...path28, "with"], `${stepLabel} "unit" declares "with" without "workflow" — it binds a child workflow's params.`);
|
|
40259
40431
|
} else if (!isRecord(raw.with)) {
|
|
40260
|
-
ctx.err([...
|
|
40432
|
+
ctx.err([...path28, "with"], `${stepLabel} "with" must be a mapping of the child's param name to a literal value or { from: <reference> }.`);
|
|
40261
40433
|
} else {
|
|
40262
40434
|
unit.with = raw.with;
|
|
40263
40435
|
}
|
|
@@ -40265,7 +40437,7 @@ function parseUnit(ctx, raw, path27, stepLabel, allowWorkflow = true) {
|
|
|
40265
40437
|
for (const key of ["connection", "harness", "engine"]) {
|
|
40266
40438
|
if (raw[key] === undefined)
|
|
40267
40439
|
continue;
|
|
40268
|
-
const name = parseEngineName(ctx, raw[key], [...
|
|
40440
|
+
const name = parseEngineName(ctx, raw[key], [...path28, key], `${stepLabel} "${key}"`);
|
|
40269
40441
|
if (name !== undefined)
|
|
40270
40442
|
unit[key] = name;
|
|
40271
40443
|
if (key === "engine")
|
|
@@ -40275,21 +40447,21 @@ function parseUnit(ctx, raw, path27, stepLabel, allowWorkflow = true) {
|
|
|
40275
40447
|
if (typeof raw.model === "string" && raw.model.trim() !== "")
|
|
40276
40448
|
unit.model = raw.model.trim();
|
|
40277
40449
|
else
|
|
40278
|
-
ctx.err([...
|
|
40450
|
+
ctx.err([...path28, "model"], `${stepLabel} "model" must be a non-empty string (a model alias or exact id).`);
|
|
40279
40451
|
}
|
|
40280
|
-
const llm = parseLlmOverrides(ctx, raw.llm, [...
|
|
40452
|
+
const llm = parseLlmOverrides(ctx, raw.llm, [...path28, "llm"], `${stepLabel} "llm"`);
|
|
40281
40453
|
if (llm !== undefined)
|
|
40282
40454
|
unit.llm = llm;
|
|
40283
|
-
const timeoutMs = parseTimeoutField(ctx, raw.timeout, [...
|
|
40455
|
+
const timeoutMs = parseTimeoutField(ctx, raw.timeout, [...path28, "timeout"], `${stepLabel} "timeout"`);
|
|
40284
40456
|
if (timeoutMs !== undefined)
|
|
40285
40457
|
unit.timeoutMs = timeoutMs;
|
|
40286
|
-
const retry = parseRetry(ctx, raw.retry, [...
|
|
40458
|
+
const retry = parseRetry(ctx, raw.retry, [...path28, "retry"], stepLabel);
|
|
40287
40459
|
if (retry !== undefined)
|
|
40288
40460
|
unit.retry = retry;
|
|
40289
|
-
const onError = parseEnumField(ctx, raw.on_error, [...
|
|
40461
|
+
const onError = parseEnumField(ctx, raw.on_error, [...path28, "on_error"], `${stepLabel} "on_error"`, PROGRAM_ON_ERROR);
|
|
40290
40462
|
if (onError !== undefined)
|
|
40291
40463
|
unit.onError = onError;
|
|
40292
|
-
const output2 = parseSchemaObject(ctx, raw.output, [...
|
|
40464
|
+
const output2 = parseSchemaObject(ctx, raw.output, [...path28, "output"], `${stepLabel} unit "output"`);
|
|
40293
40465
|
if (output2 !== undefined)
|
|
40294
40466
|
unit.output = output2;
|
|
40295
40467
|
if (raw.env !== undefined) {
|
|
@@ -40297,118 +40469,118 @@ function parseUnit(ctx, raw, path27, stepLabel, allowWorkflow = true) {
|
|
|
40297
40469
|
const envRefs = raw.env.map((entry) => entry.trim());
|
|
40298
40470
|
const duplicate = envRefs.find((ref, i) => envRefs.indexOf(ref) !== i);
|
|
40299
40471
|
if (duplicate !== undefined) {
|
|
40300
|
-
ctx.err([...
|
|
40472
|
+
ctx.err([...path28, "env"], `${stepLabel} "env" contains a duplicate entry: "${duplicate}".`);
|
|
40301
40473
|
} else {
|
|
40302
40474
|
unit.env = envRefs;
|
|
40303
40475
|
}
|
|
40304
40476
|
} else {
|
|
40305
|
-
ctx.err([...
|
|
40477
|
+
ctx.err([...path28, "env"], `${stepLabel} "env" must be a list of non-empty env asset refs.`);
|
|
40306
40478
|
}
|
|
40307
40479
|
}
|
|
40308
40480
|
return unit;
|
|
40309
40481
|
}
|
|
40310
|
-
function parseChildWorkflowRef(ctx, raw,
|
|
40482
|
+
function parseChildWorkflowRef(ctx, raw, path28, stepLabel, allowed) {
|
|
40311
40483
|
if (!allowed) {
|
|
40312
|
-
ctx.err(
|
|
40484
|
+
ctx.err(path28, `${stepLabel} "workflow" is not supported inside "map.unit": a child workflow runs once per step.`);
|
|
40313
40485
|
return;
|
|
40314
40486
|
}
|
|
40315
40487
|
try {
|
|
40316
40488
|
if (typeof raw === "string" && classifyTargetRef(raw).kind === "workflow")
|
|
40317
40489
|
return raw;
|
|
40318
40490
|
} catch {}
|
|
40319
|
-
ctx.err(
|
|
40491
|
+
ctx.err(path28, `${stepLabel} "workflow" must be a canonical workflow ref such as "workflows/<name>".`);
|
|
40320
40492
|
return;
|
|
40321
40493
|
}
|
|
40322
|
-
function parseExec(ctx, raw,
|
|
40494
|
+
function parseExec(ctx, raw, path28, stepLabel) {
|
|
40323
40495
|
if (!isRecord(raw)) {
|
|
40324
|
-
ctx.err(
|
|
40496
|
+
ctx.err(path28, `${stepLabel} "exec" must be a mapping with a "command" argv list.`);
|
|
40325
40497
|
return;
|
|
40326
40498
|
}
|
|
40327
|
-
checkUnknownKeys(ctx, raw,
|
|
40328
|
-
const command = parseExecCommand(ctx, raw.command, [...
|
|
40499
|
+
checkUnknownKeys(ctx, raw, path28, EXEC_KEYS, `${stepLabel} "exec"`);
|
|
40500
|
+
const command = parseExecCommand(ctx, raw.command, [...path28, "command"], stepLabel);
|
|
40329
40501
|
if (command === undefined)
|
|
40330
40502
|
return;
|
|
40331
40503
|
const exec = { command };
|
|
40332
|
-
const cwd = parseExecCwd(ctx, raw.cwd, [...
|
|
40504
|
+
const cwd = parseExecCwd(ctx, raw.cwd, [...path28, "cwd"], stepLabel);
|
|
40333
40505
|
if (cwd !== undefined)
|
|
40334
40506
|
exec.cwd = cwd;
|
|
40335
|
-
const passEnv = parseExecPassEnv(ctx, raw.pass_env, [...
|
|
40507
|
+
const passEnv = parseExecPassEnv(ctx, raw.pass_env, [...path28, "pass_env"], stepLabel);
|
|
40336
40508
|
if (passEnv !== undefined)
|
|
40337
40509
|
exec.passEnv = passEnv;
|
|
40338
40510
|
return exec;
|
|
40339
40511
|
}
|
|
40340
|
-
function parseExecPassEnv(ctx, raw,
|
|
40512
|
+
function parseExecPassEnv(ctx, raw, path28, stepLabel) {
|
|
40341
40513
|
if (raw === undefined)
|
|
40342
40514
|
return;
|
|
40343
40515
|
if (!Array.isArray(raw) || raw.length === 0) {
|
|
40344
|
-
ctx.err(
|
|
40516
|
+
ctx.err(path28, `${stepLabel} "exec.pass_env" must be a non-empty list of environment variable NAMES, e.g. ` + `pass_env: [CARGO_HOME]. It has no effect: the command inherits akm's environment. Values never appear ` + `here — use "env:" bindings for those.`);
|
|
40345
40517
|
return;
|
|
40346
40518
|
}
|
|
40347
40519
|
const names = [];
|
|
40348
40520
|
for (const [index, entry] of raw.entries()) {
|
|
40349
40521
|
if (typeof entry !== "string" || !WORKFLOW_ENV_VAR_NAME_PATTERN.test(entry)) {
|
|
40350
|
-
ctx.err(
|
|
40522
|
+
ctx.err(path28, `${stepLabel} "exec.pass_env[${index}]" must be an environment variable name matching ` + `${WORKFLOW_ENV_VAR_NAME_PATTERN.source}.`);
|
|
40351
40523
|
return;
|
|
40352
40524
|
}
|
|
40353
40525
|
if (names.includes(entry)) {
|
|
40354
|
-
ctx.err(
|
|
40526
|
+
ctx.err(path28, `${stepLabel} "exec.pass_env" lists "${entry}" more than once.`);
|
|
40355
40527
|
return;
|
|
40356
40528
|
}
|
|
40357
40529
|
names.push(entry);
|
|
40358
40530
|
}
|
|
40359
40531
|
return names;
|
|
40360
40532
|
}
|
|
40361
|
-
function parseExecCommand(ctx, raw,
|
|
40533
|
+
function parseExecCommand(ctx, raw, path28, stepLabel) {
|
|
40362
40534
|
if (!Array.isArray(raw) || raw.length === 0) {
|
|
40363
|
-
ctx.err(
|
|
40535
|
+
ctx.err(path28, `${stepLabel} "exec" requires "command": a non-empty argv list, e.g. command: ["bun", "run", "test:unit"]. ` + `A single shell string is not accepted — the command is spawned directly, never through a shell.`);
|
|
40364
40536
|
return;
|
|
40365
40537
|
}
|
|
40366
40538
|
const argv = [];
|
|
40367
40539
|
for (const [index, entry] of raw.entries()) {
|
|
40368
40540
|
if (typeof entry !== "string" || entry === "") {
|
|
40369
|
-
ctx.err(
|
|
40541
|
+
ctx.err(path28, `${stepLabel} "exec.command[${index}]" must be a non-empty string.`);
|
|
40370
40542
|
return;
|
|
40371
40543
|
}
|
|
40372
40544
|
if (entry.includes("\x00")) {
|
|
40373
|
-
ctx.err([...
|
|
40545
|
+
ctx.err([...path28, index], `${stepLabel} "exec.command[${index}]" may not contain NUL bytes.`);
|
|
40374
40546
|
return;
|
|
40375
40547
|
}
|
|
40376
40548
|
argv.push(entry);
|
|
40377
40549
|
}
|
|
40378
40550
|
return argv;
|
|
40379
40551
|
}
|
|
40380
|
-
function parseExecCwd(ctx, raw,
|
|
40552
|
+
function parseExecCwd(ctx, raw, path28, stepLabel) {
|
|
40381
40553
|
if (raw === undefined)
|
|
40382
40554
|
return;
|
|
40383
40555
|
if (typeof raw !== "string" || raw.trim() === "") {
|
|
40384
|
-
ctx.err(
|
|
40556
|
+
ctx.err(path28, `${stepLabel} "exec.cwd" must be a non-empty string.`);
|
|
40385
40557
|
return;
|
|
40386
40558
|
}
|
|
40387
40559
|
return raw.trim();
|
|
40388
40560
|
}
|
|
40389
|
-
function parseMap(ctx, raw,
|
|
40561
|
+
function parseMap(ctx, raw, path28, stepLabel) {
|
|
40390
40562
|
if (!isRecord(raw)) {
|
|
40391
|
-
ctx.err(
|
|
40563
|
+
ctx.err(path28, `${stepLabel} "map" must be a mapping with an "over" key.`);
|
|
40392
40564
|
return;
|
|
40393
40565
|
}
|
|
40394
|
-
checkUnknownKeys(ctx, raw,
|
|
40566
|
+
checkUnknownKeys(ctx, raw, path28, MAP_KEYS, `${stepLabel} "map"`);
|
|
40395
40567
|
let over = "";
|
|
40396
40568
|
if (typeof raw.over === "string" && raw.over.trim() !== "") {
|
|
40397
40569
|
over = raw.over.trim();
|
|
40398
|
-
checkReferenceSyntax(ctx, over, [...
|
|
40570
|
+
checkReferenceSyntax(ctx, over, [...path28, "over"], `${stepLabel} "over"`);
|
|
40399
40571
|
} else {
|
|
40400
|
-
ctx.err([...
|
|
40572
|
+
ctx.err([...path28, "over"], `${stepLabel} "map" requires "over": a reference naming the item list (e.g. steps.discover.output.files).`);
|
|
40401
40573
|
}
|
|
40402
40574
|
let concurrency;
|
|
40403
40575
|
if (raw.concurrency !== undefined) {
|
|
40404
40576
|
if (typeof raw.concurrency === "number" && Number.isInteger(raw.concurrency) && raw.concurrency > 0) {
|
|
40405
40577
|
concurrency = Math.min(raw.concurrency, WORKFLOW_MAX_CONCURRENCY);
|
|
40406
40578
|
} else {
|
|
40407
|
-
ctx.err([...
|
|
40579
|
+
ctx.err([...path28, "concurrency"], `${stepLabel} "concurrency" must be a positive integer.`);
|
|
40408
40580
|
}
|
|
40409
40581
|
}
|
|
40410
|
-
const reducer = parseEnumField(ctx, raw.reducer, [...
|
|
40411
|
-
const unit = raw.unit !== undefined ? parseUnit(ctx, raw.unit, [...
|
|
40582
|
+
const reducer = parseEnumField(ctx, raw.reducer, [...path28, "reducer"], `${stepLabel} "reducer"`, PROGRAM_REDUCERS);
|
|
40583
|
+
const unit = raw.unit !== undefined ? parseUnit(ctx, raw.unit, [...path28, "unit"], stepLabel, false) : undefined;
|
|
40412
40584
|
const map2 = { over };
|
|
40413
40585
|
if (concurrency !== undefined)
|
|
40414
40586
|
map2.concurrency = concurrency;
|
|
@@ -40418,70 +40590,70 @@ function parseMap(ctx, raw, path27, stepLabel) {
|
|
|
40418
40590
|
map2.unit = unit;
|
|
40419
40591
|
return map2;
|
|
40420
40592
|
}
|
|
40421
|
-
function parseInputs(ctx, raw,
|
|
40593
|
+
function parseInputs(ctx, raw, path28, stepLabel) {
|
|
40422
40594
|
if (raw === undefined)
|
|
40423
40595
|
return;
|
|
40424
40596
|
if (!Array.isArray(raw) || raw.length === 0) {
|
|
40425
|
-
ctx.err(
|
|
40597
|
+
ctx.err(path28, `${stepLabel} "inputs" must be a non-empty list of reference strings.`);
|
|
40426
40598
|
return;
|
|
40427
40599
|
}
|
|
40428
40600
|
const out = [];
|
|
40429
40601
|
const seen = new Set;
|
|
40430
40602
|
raw.forEach((entry, i) => {
|
|
40431
40603
|
if (typeof entry !== "string" || entry.trim() === "") {
|
|
40432
|
-
ctx.err([...
|
|
40604
|
+
ctx.err([...path28, i], `${stepLabel} "inputs[${i}]" must be a non-empty reference string.`);
|
|
40433
40605
|
return;
|
|
40434
40606
|
}
|
|
40435
40607
|
const value = entry.trim();
|
|
40436
40608
|
if (seen.has(value)) {
|
|
40437
|
-
ctx.err([...
|
|
40609
|
+
ctx.err([...path28, i], `${stepLabel} "inputs[${i}]" duplicates an earlier entry: "${value}".`);
|
|
40438
40610
|
return;
|
|
40439
40611
|
}
|
|
40440
40612
|
seen.add(value);
|
|
40441
|
-
checkReferenceSyntax(ctx, value, [...
|
|
40613
|
+
checkReferenceSyntax(ctx, value, [...path28, i], `${stepLabel} "inputs[${i}]"`);
|
|
40442
40614
|
out.push(value);
|
|
40443
40615
|
});
|
|
40444
40616
|
return out.length > 0 ? out : undefined;
|
|
40445
40617
|
}
|
|
40446
|
-
function parseGate(ctx, raw,
|
|
40618
|
+
function parseGate(ctx, raw, path28, stepLabel) {
|
|
40447
40619
|
if (!isRecord(raw)) {
|
|
40448
|
-
ctx.err(
|
|
40620
|
+
ctx.err(path28, `${stepLabel} "gate" must be a mapping with any of: ${GATE_KEYS.join(", ")}.`);
|
|
40449
40621
|
return;
|
|
40450
40622
|
}
|
|
40451
|
-
checkUnknownKeys(ctx, raw,
|
|
40623
|
+
checkUnknownKeys(ctx, raw, path28, GATE_KEYS, `${stepLabel} "gate"`);
|
|
40452
40624
|
const gate = {};
|
|
40453
40625
|
if (raw.max_loops !== undefined) {
|
|
40454
40626
|
if (typeof raw.max_loops === "number" && Number.isInteger(raw.max_loops) && raw.max_loops >= 1) {
|
|
40455
40627
|
gate.maxLoops = raw.max_loops;
|
|
40456
40628
|
} else {
|
|
40457
|
-
ctx.err([...
|
|
40629
|
+
ctx.err([...path28, "max_loops"], `${stepLabel} "gate.max_loops" must be an integer of at least 1.`);
|
|
40458
40630
|
}
|
|
40459
40631
|
}
|
|
40460
40632
|
return gate;
|
|
40461
40633
|
}
|
|
40462
|
-
function parseEngineName(ctx, raw,
|
|
40634
|
+
function parseEngineName(ctx, raw, path28, label) {
|
|
40463
40635
|
if (typeof raw !== "string" || raw.trim() === "") {
|
|
40464
|
-
ctx.err(
|
|
40636
|
+
ctx.err(path28, `${label} must be a non-empty name.`);
|
|
40465
40637
|
return;
|
|
40466
40638
|
}
|
|
40467
40639
|
const name = raw.trim();
|
|
40468
40640
|
if (!WORKFLOW_ENGINE_NAME_PATTERN.test(name) || name.length > WORKFLOW_MAX_ENGINE_NAME_LENGTH) {
|
|
40469
|
-
ctx.err(
|
|
40641
|
+
ctx.err(path28, `${label} has an invalid name ${JSON.stringify(name)}. Names are lowercase words of letters ` + `and digits separated by single dashes, starting with a letter (e.g. "code-review-llm"), at most ` + `${WORKFLOW_MAX_ENGINE_NAME_LENGTH} characters.`);
|
|
40470
40642
|
return;
|
|
40471
40643
|
}
|
|
40472
40644
|
return name;
|
|
40473
40645
|
}
|
|
40474
|
-
function parseRetry(ctx, raw,
|
|
40646
|
+
function parseRetry(ctx, raw, path28, stepLabel) {
|
|
40475
40647
|
if (raw === undefined)
|
|
40476
40648
|
return;
|
|
40477
40649
|
if (!isRecord(raw)) {
|
|
40478
|
-
ctx.err(
|
|
40650
|
+
ctx.err(path28, `${stepLabel} "retry" must be a mapping: { max: <n>, on: [<failure_reason>, …] }.`);
|
|
40479
40651
|
return;
|
|
40480
40652
|
}
|
|
40481
|
-
checkUnknownKeys(ctx, raw,
|
|
40653
|
+
checkUnknownKeys(ctx, raw, path28, RETRY_KEYS, `${stepLabel} "retry"`);
|
|
40482
40654
|
let ok = true;
|
|
40483
40655
|
if (!(typeof raw.max === "number" && Number.isInteger(raw.max) && raw.max >= 0)) {
|
|
40484
|
-
ctx.err([...
|
|
40656
|
+
ctx.err([...path28, "max"], `${stepLabel} "retry.max" is required and must be a non-negative integer.`);
|
|
40485
40657
|
ok = false;
|
|
40486
40658
|
}
|
|
40487
40659
|
const on = [];
|
|
@@ -40490,27 +40662,27 @@ function parseRetry(ctx, raw, path27, stepLabel) {
|
|
|
40490
40662
|
if (typeof reason === "string" && PROGRAM_RETRY_REASONS.includes(reason)) {
|
|
40491
40663
|
on.push(reason);
|
|
40492
40664
|
} else {
|
|
40493
|
-
ctx.err([...
|
|
40665
|
+
ctx.err([...path28, "on", i], `${stepLabel} "retry.on" has unknown failure reason ${JSON.stringify(reason)}. Valid reasons: ${PROGRAM_RETRY_REASONS.join(", ")}.`);
|
|
40494
40666
|
ok = false;
|
|
40495
40667
|
}
|
|
40496
40668
|
});
|
|
40497
40669
|
} else {
|
|
40498
|
-
ctx.err([...
|
|
40670
|
+
ctx.err([...path28, "on"], `${stepLabel} "retry.on" is required and must be a non-empty list of failure reasons (${PROGRAM_RETRY_REASONS.join(", ")}).`);
|
|
40499
40671
|
ok = false;
|
|
40500
40672
|
}
|
|
40501
40673
|
return ok ? { max: raw.max, on } : undefined;
|
|
40502
40674
|
}
|
|
40503
|
-
function parseTimeoutField(ctx, raw,
|
|
40675
|
+
function parseTimeoutField(ctx, raw, path28, label) {
|
|
40504
40676
|
if (raw === undefined)
|
|
40505
40677
|
return;
|
|
40506
40678
|
if (typeof raw === "number") {
|
|
40507
40679
|
if (Number.isInteger(raw) && raw > 0)
|
|
40508
|
-
return checkTimeoutCeiling(ctx, raw,
|
|
40509
|
-
ctx.err(
|
|
40680
|
+
return checkTimeoutCeiling(ctx, raw, path28, label, String(raw));
|
|
40681
|
+
ctx.err(path28, `${label} has a non-positive timeout ${JSON.stringify(raw)}. ${TIMEOUT_HINT}.`);
|
|
40510
40682
|
return;
|
|
40511
40683
|
}
|
|
40512
40684
|
if (typeof raw !== "string") {
|
|
40513
|
-
ctx.err(
|
|
40685
|
+
ctx.err(path28, `${label} must be a duration string. ${TIMEOUT_HINT}.`);
|
|
40514
40686
|
return;
|
|
40515
40687
|
}
|
|
40516
40688
|
const value = raw.trim().toLowerCase();
|
|
@@ -40518,37 +40690,37 @@ function parseTimeoutField(ctx, raw, path27, label) {
|
|
|
40518
40690
|
return null;
|
|
40519
40691
|
const match = value.match(TIMEOUT_VALUE);
|
|
40520
40692
|
if (!match) {
|
|
40521
|
-
ctx.err(
|
|
40693
|
+
ctx.err(path28, `${label} has an invalid timeout "${raw}". ${TIMEOUT_HINT}.`);
|
|
40522
40694
|
return;
|
|
40523
40695
|
}
|
|
40524
40696
|
const n = Number.parseInt(match[1], 10);
|
|
40525
40697
|
const unit = match[2] ?? "ms";
|
|
40526
40698
|
const timeoutMs = unit === "m" ? n * 60000 : unit === "s" ? n * 1000 : n;
|
|
40527
40699
|
if (timeoutMs <= 0) {
|
|
40528
|
-
ctx.err(
|
|
40700
|
+
ctx.err(path28, `${label} has a non-positive timeout "${raw}". Use a positive duration or "none".`);
|
|
40529
40701
|
return;
|
|
40530
40702
|
}
|
|
40531
|
-
return checkTimeoutCeiling(ctx, timeoutMs,
|
|
40703
|
+
return checkTimeoutCeiling(ctx, timeoutMs, path28, label, raw);
|
|
40532
40704
|
}
|
|
40533
|
-
function checkTimeoutCeiling(ctx, timeoutMs,
|
|
40705
|
+
function checkTimeoutCeiling(ctx, timeoutMs, path28, label, raw) {
|
|
40534
40706
|
if (timeoutMs <= WORKFLOW_MAX_TIMEOUT_MS)
|
|
40535
40707
|
return timeoutMs;
|
|
40536
|
-
ctx.err(
|
|
40708
|
+
ctx.err(path28, `${label} has a timeout "${raw}" above the maximum of ${WORKFLOW_MAX_TIMEOUT_MS} ms (about 24.8 days). ` + `Use a shorter duration or "none" for no timeout.`);
|
|
40537
40709
|
return;
|
|
40538
40710
|
}
|
|
40539
|
-
function parseEnumField(ctx, raw,
|
|
40711
|
+
function parseEnumField(ctx, raw, path28, label, allowed) {
|
|
40540
40712
|
if (raw === undefined)
|
|
40541
40713
|
return;
|
|
40542
40714
|
if (typeof raw === "string" && allowed.includes(raw))
|
|
40543
40715
|
return raw;
|
|
40544
|
-
ctx.err(
|
|
40716
|
+
ctx.err(path28, `${label} must be one of: ${allowed.join(" | ")} (got ${JSON.stringify(raw)}).`);
|
|
40545
40717
|
return;
|
|
40546
40718
|
}
|
|
40547
|
-
function parseLlmOverrides(ctx, raw,
|
|
40719
|
+
function parseLlmOverrides(ctx, raw, path28, label) {
|
|
40548
40720
|
if (raw === undefined)
|
|
40549
40721
|
return;
|
|
40550
40722
|
if (!isRecord(raw)) {
|
|
40551
|
-
ctx.err(
|
|
40723
|
+
ctx.err(path28, `${label} must be a mapping of LLM invocation overrides.`);
|
|
40552
40724
|
return;
|
|
40553
40725
|
}
|
|
40554
40726
|
const keys = [
|
|
@@ -40560,19 +40732,19 @@ function parseLlmOverrides(ctx, raw, path27, label) {
|
|
|
40560
40732
|
"enable_thinking",
|
|
40561
40733
|
"reasoning_effort"
|
|
40562
40734
|
];
|
|
40563
|
-
checkUnknownKeys(ctx, raw,
|
|
40735
|
+
checkUnknownKeys(ctx, raw, path28, keys, label);
|
|
40564
40736
|
const result = {};
|
|
40565
40737
|
if (raw.temperature !== undefined) {
|
|
40566
40738
|
if (typeof raw.temperature === "number" && Number.isFinite(raw.temperature))
|
|
40567
40739
|
result.temperature = raw.temperature;
|
|
40568
40740
|
else
|
|
40569
|
-
ctx.err([...
|
|
40741
|
+
ctx.err([...path28, "temperature"], `${label}.temperature must be a finite number.`);
|
|
40570
40742
|
}
|
|
40571
40743
|
if (raw.max_tokens !== undefined) {
|
|
40572
40744
|
if (typeof raw.max_tokens === "number" && Number.isInteger(raw.max_tokens) && raw.max_tokens > 0) {
|
|
40573
40745
|
result.maxTokens = raw.max_tokens;
|
|
40574
40746
|
} else
|
|
40575
|
-
ctx.err([...
|
|
40747
|
+
ctx.err([...path28, "max_tokens"], `${label}.max_tokens must be a positive integer.`);
|
|
40576
40748
|
}
|
|
40577
40749
|
for (const [key, why] of Object.entries(RETIRED_LLM_KEYS)) {
|
|
40578
40750
|
if (raw[key] !== undefined)
|
|
@@ -40580,14 +40752,14 @@ function parseLlmOverrides(ctx, raw, path27, label) {
|
|
|
40580
40752
|
}
|
|
40581
40753
|
if (raw.extra_params !== undefined) {
|
|
40582
40754
|
if (!isRecord(raw.extra_params)) {
|
|
40583
|
-
ctx.err([...
|
|
40755
|
+
ctx.err([...path28, "extra_params"], `${label}.extra_params must be a JSON object.`);
|
|
40584
40756
|
} else {
|
|
40585
40757
|
const issues = validateExtraParams(raw.extra_params);
|
|
40586
40758
|
for (const issue2 of issues) {
|
|
40587
|
-
ctx.err([...
|
|
40759
|
+
ctx.err([...path28, "extra_params", ...issue2.path], `${formatExtraParamsIssue(`${label}.extra_params`, issue2)}.`);
|
|
40588
40760
|
}
|
|
40589
40761
|
if (jsonBytes(raw.extra_params) > WORKFLOW_MAX_EXTRA_PARAMS_BYTES) {
|
|
40590
|
-
ctx.err([...
|
|
40762
|
+
ctx.err([...path28, "extra_params"], `${label}.extra_params exceeds the 64 KiB resource limit.`);
|
|
40591
40763
|
}
|
|
40592
40764
|
if (issues.length === 0 && jsonBytes(raw.extra_params) <= WORKFLOW_MAX_EXTRA_PARAMS_BYTES) {
|
|
40593
40765
|
result.extraParams = raw.extra_params;
|
|
@@ -40598,32 +40770,32 @@ function parseLlmOverrides(ctx, raw, path27, label) {
|
|
|
40598
40770
|
if (typeof raw.enable_thinking === "boolean")
|
|
40599
40771
|
result.enableThinking = raw.enable_thinking;
|
|
40600
40772
|
else
|
|
40601
|
-
ctx.err([...
|
|
40773
|
+
ctx.err([...path28, "enable_thinking"], `${label}.enable_thinking must be a boolean.`);
|
|
40602
40774
|
}
|
|
40603
40775
|
if (raw.reasoning_effort !== undefined) {
|
|
40604
40776
|
if (typeof raw.reasoning_effort === "string" && raw.reasoning_effort.trim().length > 0) {
|
|
40605
40777
|
result.reasoningEffort = raw.reasoning_effort;
|
|
40606
40778
|
} else
|
|
40607
|
-
ctx.err([...
|
|
40779
|
+
ctx.err([...path28, "reasoning_effort"], `${label}.reasoning_effort must be a non-empty string.`);
|
|
40608
40780
|
}
|
|
40609
40781
|
return Object.keys(result).length > 0 ? result : undefined;
|
|
40610
40782
|
}
|
|
40611
|
-
function parseSchemaObject(ctx, raw,
|
|
40783
|
+
function parseSchemaObject(ctx, raw, path28, label) {
|
|
40612
40784
|
if (raw === undefined)
|
|
40613
40785
|
return;
|
|
40614
40786
|
if (!isRecord(raw)) {
|
|
40615
|
-
ctx.err(
|
|
40787
|
+
ctx.err(path28, `${label} must be a JSON Schema object (e.g. { type: object, properties: { … } }).`);
|
|
40616
40788
|
return;
|
|
40617
40789
|
}
|
|
40618
40790
|
if (jsonBytes(raw) > WORKFLOW_MAX_SCHEMA_BYTES) {
|
|
40619
|
-
ctx.err(
|
|
40791
|
+
ctx.err(path28, `${label} exceeds the 256 KiB resource limit.`);
|
|
40620
40792
|
}
|
|
40621
|
-
checkSchemaDefinition(ctx, raw,
|
|
40793
|
+
checkSchemaDefinition(ctx, raw, path28, label);
|
|
40622
40794
|
return raw;
|
|
40623
40795
|
}
|
|
40624
|
-
function checkSchemaDefinition(ctx, schema,
|
|
40796
|
+
function checkSchemaDefinition(ctx, schema, path28, label) {
|
|
40625
40797
|
for (const issue2 of checkJsonSchemaDefinition(schema)) {
|
|
40626
|
-
const issuePath = [...
|
|
40798
|
+
const issuePath = [...path28, ...issue2.path];
|
|
40627
40799
|
if (issue2.kind === "unsupported") {
|
|
40628
40800
|
ctx.err(issuePath, `${label} (at ${issue2.pointer}): ${issue2.message}. Supported JSON Schema keywords: ` + `${JSON_SCHEMA_SUBSET_SUPPORTED_KEYWORDS}.`);
|
|
40629
40801
|
} else {
|
|
@@ -40631,15 +40803,15 @@ function checkSchemaDefinition(ctx, schema, path27, label) {
|
|
|
40631
40803
|
}
|
|
40632
40804
|
}
|
|
40633
40805
|
}
|
|
40634
|
-
function checkReferenceSyntax(ctx, text2,
|
|
40806
|
+
function checkReferenceSyntax(ctx, text2, path28, label) {
|
|
40635
40807
|
const result = parseReference(text2);
|
|
40636
40808
|
if (!result.ok)
|
|
40637
|
-
ctx.err(
|
|
40809
|
+
ctx.err(path28, `${label}: ${result.message}`);
|
|
40638
40810
|
}
|
|
40639
|
-
function checkUnknownKeys(ctx, obj,
|
|
40811
|
+
function checkUnknownKeys(ctx, obj, path28, allowed, label, hint = () => "") {
|
|
40640
40812
|
for (const key of Object.keys(obj)) {
|
|
40641
40813
|
if (!allowed.includes(key)) {
|
|
40642
|
-
ctx.err([...
|
|
40814
|
+
ctx.err([...path28, key], `Unknown ${label} key "${key}"${hint(key)}. Allowed keys: ${allowed.join(", ")}.`);
|
|
40643
40815
|
}
|
|
40644
40816
|
}
|
|
40645
40817
|
}
|
|
@@ -40737,10 +40909,10 @@ var init_parser = __esm(() => {
|
|
|
40737
40909
|
});
|
|
40738
40910
|
|
|
40739
40911
|
// src/workflows/compile.ts
|
|
40740
|
-
import
|
|
40912
|
+
import path28 from "node:path";
|
|
40741
40913
|
function compileWorkflowSource(source, options) {
|
|
40742
|
-
const extension =
|
|
40743
|
-
const title = options.title ??
|
|
40914
|
+
const extension = path28.extname(options.path).toLowerCase();
|
|
40915
|
+
const title = options.title ?? path28.basename(options.path, path28.extname(options.path));
|
|
40744
40916
|
if (extension !== ".md") {
|
|
40745
40917
|
return {
|
|
40746
40918
|
ok: false,
|
|
@@ -40847,7 +41019,7 @@ var init_compile2 = __esm(() => {
|
|
|
40847
41019
|
});
|
|
40848
41020
|
|
|
40849
41021
|
// src/core/adapter/adapters/akm-lint.ts
|
|
40850
|
-
import
|
|
41022
|
+
import path29 from "node:path";
|
|
40851
41023
|
function checkMissingNameOrType(data, frontmatter) {
|
|
40852
41024
|
if (!frontmatter)
|
|
40853
41025
|
return null;
|
|
@@ -40869,7 +41041,7 @@ function checkInvalidTypeValue(data, allowedTypes) {
|
|
|
40869
41041
|
return `type field has invalid value '${value}'; expected one of: ${allowedTypes.join(", ")}`;
|
|
40870
41042
|
}
|
|
40871
41043
|
function suggestSlug(filePath) {
|
|
40872
|
-
return
|
|
41044
|
+
return path29.basename(filePath, ".md").toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
40873
41045
|
}
|
|
40874
41046
|
function nameOrTypeDiagnostics(relPath, data, frontmatter, allowedTypes) {
|
|
40875
41047
|
const missingFieldDetail = checkMissingNameOrType(data, frontmatter);
|
|
@@ -40909,7 +41081,7 @@ function collectSuppressedKeys(raw) {
|
|
|
40909
41081
|
function dangerousEnvKeyDiagnostics(type, relPath, raw) {
|
|
40910
41082
|
if (type !== "env" && type !== "secret")
|
|
40911
41083
|
return [];
|
|
40912
|
-
const baseNameWithExt =
|
|
41084
|
+
const baseNameWithExt = path29.basename(relPath);
|
|
40913
41085
|
if (!baseNameWithExt.endsWith(".env"))
|
|
40914
41086
|
return [];
|
|
40915
41087
|
const ref = conceptIdForStashFile(type, ".", relPath);
|
|
@@ -42875,8 +43047,8 @@ var init_markdown_link_targets = __esm(() => {
|
|
|
42875
43047
|
});
|
|
42876
43048
|
|
|
42877
43049
|
// src/core/adapter/adapters/llm-wiki-adapter.ts
|
|
42878
|
-
import
|
|
42879
|
-
import
|
|
43050
|
+
import fs25 from "node:fs";
|
|
43051
|
+
import path30 from "node:path";
|
|
42880
43052
|
function conceptIdOf(relPath) {
|
|
42881
43053
|
return toPosix(relPath).replace(/\.md$/i, "");
|
|
42882
43054
|
}
|
|
@@ -42928,7 +43100,7 @@ function resolveXref(xref, bundleId) {
|
|
|
42928
43100
|
return target.length > 0 ? target : null;
|
|
42929
43101
|
}
|
|
42930
43102
|
function resolveBodyLinks(body, fileRelPath) {
|
|
42931
|
-
const dir =
|
|
43103
|
+
const dir = path30.posix.dirname(toPosix(fileRelPath));
|
|
42932
43104
|
const out = [];
|
|
42933
43105
|
const seen = new Set;
|
|
42934
43106
|
for (const link of markdownLinkTargets(body, false)) {
|
|
@@ -42952,10 +43124,10 @@ function resolveBodyLinks(body, fileRelPath) {
|
|
|
42952
43124
|
continue;
|
|
42953
43125
|
let resolved;
|
|
42954
43126
|
if (target.startsWith("/")) {
|
|
42955
|
-
resolved =
|
|
43127
|
+
resolved = path30.posix.normalize(target.slice(1));
|
|
42956
43128
|
} else {
|
|
42957
43129
|
const base = dir === "." ? "" : dir;
|
|
42958
|
-
resolved =
|
|
43130
|
+
resolved = path30.posix.normalize(path30.posix.join(base, target));
|
|
42959
43131
|
}
|
|
42960
43132
|
if (resolved.startsWith("../") || resolved === ".." || resolved.startsWith("/"))
|
|
42961
43133
|
continue;
|
|
@@ -43145,16 +43317,16 @@ var init_llm_wiki_adapter = __esm(() => {
|
|
|
43145
43317
|
validate: validate3,
|
|
43146
43318
|
readCandidates(c, conceptId) {
|
|
43147
43319
|
const canonical = toPosix(conceptId).replace(/\.md$/i, "");
|
|
43148
|
-
return [{ path:
|
|
43320
|
+
return [{ path: path30.join(c.root, `${canonical}.md`), conceptId: canonical }];
|
|
43149
43321
|
},
|
|
43150
43322
|
directoryList(_c) {
|
|
43151
43323
|
return ["."];
|
|
43152
43324
|
},
|
|
43153
43325
|
looksLikeRoot(root) {
|
|
43154
43326
|
try {
|
|
43155
|
-
if (!
|
|
43327
|
+
if (!fs25.existsSync(path30.join(root, "schema.md")))
|
|
43156
43328
|
return false;
|
|
43157
|
-
return
|
|
43329
|
+
return fs25.statSync(path30.join(root, PAGES_SUBDIR)).isDirectory();
|
|
43158
43330
|
} catch {
|
|
43159
43331
|
return false;
|
|
43160
43332
|
}
|
|
@@ -43163,14 +43335,14 @@ var init_llm_wiki_adapter = __esm(() => {
|
|
|
43163
43335
|
});
|
|
43164
43336
|
|
|
43165
43337
|
// src/core/adapter/adapters/akm-adapter.ts
|
|
43166
|
-
import
|
|
43167
|
-
import
|
|
43338
|
+
import fs26 from "node:fs";
|
|
43339
|
+
import path31 from "node:path";
|
|
43168
43340
|
function isReservedFileName(name) {
|
|
43169
43341
|
return RESERVED_FILES.has(name.toLowerCase());
|
|
43170
43342
|
}
|
|
43171
43343
|
function akmStashAbstains(root, absPath) {
|
|
43172
|
-
const relPath =
|
|
43173
|
-
if (!relPath || relPath.startsWith("..") ||
|
|
43344
|
+
const relPath = path31.relative(root, absPath);
|
|
43345
|
+
if (!relPath || relPath.startsWith("..") || path31.isAbsolute(relPath))
|
|
43174
43346
|
return false;
|
|
43175
43347
|
const segments = relPath.split(/[\\/]+/).filter(Boolean);
|
|
43176
43348
|
if (segments.length === 0)
|
|
@@ -43178,14 +43350,14 @@ function akmStashAbstains(root, absPath) {
|
|
|
43178
43350
|
if (segments.length === 1 && segments[0]?.toLowerCase() === "readme.md")
|
|
43179
43351
|
return true;
|
|
43180
43352
|
const ancestorDirs = segments.slice(0, -1);
|
|
43181
|
-
if (ancestorDirs.includes("env") && (absPath.endsWith(".env") ||
|
|
43182
|
-
if (
|
|
43353
|
+
if (ancestorDirs.includes("env") && (absPath.endsWith(".env") || path31.basename(absPath) === ".env")) {
|
|
43354
|
+
if (fs26.existsSync(sensitiveMarkerPath(absPath, "env")))
|
|
43183
43355
|
return true;
|
|
43184
43356
|
}
|
|
43185
43357
|
if (ancestorDirs.includes("secrets")) {
|
|
43186
43358
|
if (absPath.endsWith(".sensitive") || absPath.endsWith(".lock"))
|
|
43187
43359
|
return true;
|
|
43188
|
-
if (
|
|
43360
|
+
if (fs26.existsSync(sensitiveMarkerPath(absPath, "secret")))
|
|
43189
43361
|
return true;
|
|
43190
43362
|
}
|
|
43191
43363
|
const wikisIdx = segments.indexOf("wikis");
|
|
@@ -43251,7 +43423,7 @@ function isWikiRaw(c, file2) {
|
|
|
43251
43423
|
return false;
|
|
43252
43424
|
const dirs = file2.ancestorDirs;
|
|
43253
43425
|
for (let i = 0;i < dirs.length; i++) {
|
|
43254
|
-
if (dirs[i] === "raw" && llmWikiAdapter.looksLikeRoot?.(
|
|
43426
|
+
if (dirs[i] === "raw" && llmWikiAdapter.looksLikeRoot?.(path31.join(c.root, ...dirs.slice(0, i))) === true) {
|
|
43255
43427
|
return true;
|
|
43256
43428
|
}
|
|
43257
43429
|
}
|
|
@@ -43269,7 +43441,7 @@ function recognize3(c, file2) {
|
|
|
43269
43441
|
const canonicalName = deriveCanonicalAssetNameFromStashRoot(match.type, c.root, file2.absPath);
|
|
43270
43442
|
if (conceptId === undefined || canonicalName === undefined)
|
|
43271
43443
|
return null;
|
|
43272
|
-
const dirPath =
|
|
43444
|
+
const dirPath = path31.dirname(file2.absPath);
|
|
43273
43445
|
const entry = {
|
|
43274
43446
|
name: canonicalName,
|
|
43275
43447
|
type: match.type,
|
|
@@ -43314,13 +43486,13 @@ function renderExecutionSource(c, file2) {
|
|
|
43314
43486
|
});
|
|
43315
43487
|
}
|
|
43316
43488
|
function buildOverlayContext(root, relPathInput, raw) {
|
|
43317
|
-
const absPath =
|
|
43318
|
-
const relPath =
|
|
43319
|
-
const ext =
|
|
43320
|
-
const fileName =
|
|
43321
|
-
const parentDirAbs =
|
|
43322
|
-
const parentDir =
|
|
43323
|
-
const relDir =
|
|
43489
|
+
const absPath = path31.join(root, relPathInput);
|
|
43490
|
+
const relPath = path31.relative(root, absPath).replace(/\\/g, "/");
|
|
43491
|
+
const ext = path31.extname(absPath).toLowerCase();
|
|
43492
|
+
const fileName = path31.basename(absPath);
|
|
43493
|
+
const parentDirAbs = path31.dirname(absPath);
|
|
43494
|
+
const parentDir = path31.basename(parentDirAbs);
|
|
43495
|
+
const relDir = path31.dirname(relPath).replace(/\\/g, "/");
|
|
43324
43496
|
const ancestorDirs = relDir === "." ? [] : relDir.split("/").filter((seg) => seg.length > 0);
|
|
43325
43497
|
let cachedFrontmatter;
|
|
43326
43498
|
let frontmatterComputed = false;
|
|
@@ -43361,10 +43533,10 @@ async function validate4(c, changes, ctx) {
|
|
|
43361
43533
|
const type = match?.type;
|
|
43362
43534
|
let parsed;
|
|
43363
43535
|
if (type === "task") {
|
|
43364
|
-
parsed = { data: {}, content: raw, frontmatter: null };
|
|
43536
|
+
parsed = { data: {}, content: raw, frontmatter: null, bodyStartLine: 1 };
|
|
43365
43537
|
} else {
|
|
43366
43538
|
const p = parseFrontmatter(raw);
|
|
43367
|
-
parsed = { data: p.data, content: p.content, frontmatter: p.frontmatter };
|
|
43539
|
+
parsed = { data: p.data, content: p.content, frontmatter: p.frontmatter, bodyStartLine: p.bodyStartLine };
|
|
43368
43540
|
}
|
|
43369
43541
|
diagnostics.push(...await runBaseValidateChecks(change.path, parsed, c.root, ctx));
|
|
43370
43542
|
diagnostics.push(...await perTypeValidateChecks({
|
|
@@ -43452,7 +43624,7 @@ var init_akm_adapter = __esm(() => {
|
|
|
43452
43624
|
const posix = conceptId.replace(/\\/g, "/");
|
|
43453
43625
|
const paths = placementTypes().flatMap((type) => assetPathCandidatesForName(type, c.root, posix).filter((candidate) => {
|
|
43454
43626
|
const declared = declaredTypeForPath(buildFileContext(c.root, candidate));
|
|
43455
|
-
return declared === undefined || declared === type || type === "skill" &&
|
|
43627
|
+
return declared === undefined || declared === type || type === "skill" && path31.basename(candidate) === "SKILL.md";
|
|
43456
43628
|
}));
|
|
43457
43629
|
return [...new Set(paths)].map((candidatePath) => ({ path: candidatePath, conceptId: posix }));
|
|
43458
43630
|
},
|
|
@@ -43461,13 +43633,13 @@ var init_akm_adapter = __esm(() => {
|
|
|
43461
43633
|
},
|
|
43462
43634
|
looksLikeRoot(root) {
|
|
43463
43635
|
try {
|
|
43464
|
-
if (
|
|
43636
|
+
if (fs26.statSync(path31.join(root, ".stash")).isDirectory())
|
|
43465
43637
|
return true;
|
|
43466
43638
|
} catch {}
|
|
43467
43639
|
const ownedDirNames = new Set(stashDirNames());
|
|
43468
43640
|
let entries;
|
|
43469
43641
|
try {
|
|
43470
|
-
entries =
|
|
43642
|
+
entries = fs26.readdirSync(root, { withFileTypes: true });
|
|
43471
43643
|
} catch {
|
|
43472
43644
|
return false;
|
|
43473
43645
|
}
|
|
@@ -43479,10 +43651,10 @@ var init_akm_adapter = __esm(() => {
|
|
|
43479
43651
|
return false;
|
|
43480
43652
|
const expectedType = typeForStashDir(only.name);
|
|
43481
43653
|
try {
|
|
43482
|
-
const markdown2 =
|
|
43654
|
+
const markdown2 = fs26.readdirSync(path31.join(root, only.name), { withFileTypes: true }).find((entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".md"));
|
|
43483
43655
|
if (!markdown2)
|
|
43484
43656
|
return true;
|
|
43485
|
-
const data = parseFrontmatter(
|
|
43657
|
+
const data = parseFrontmatter(fs26.readFileSync(path31.join(root, only.name, markdown2.name), "utf8")).data;
|
|
43486
43658
|
const declaredType = typeof data.type === "string" ? data.type.trim() : "";
|
|
43487
43659
|
return !declaredType || declaredType === expectedType;
|
|
43488
43660
|
} catch {
|
|
@@ -43493,8 +43665,8 @@ var init_akm_adapter = __esm(() => {
|
|
|
43493
43665
|
});
|
|
43494
43666
|
|
|
43495
43667
|
// src/core/adapter/adapters/akm-task-adapter.ts
|
|
43496
|
-
import
|
|
43497
|
-
import
|
|
43668
|
+
import fs27 from "node:fs";
|
|
43669
|
+
import path32 from "node:path";
|
|
43498
43670
|
function recognize4(c, file2) {
|
|
43499
43671
|
if (file2.ext !== TASK_EXT)
|
|
43500
43672
|
return null;
|
|
@@ -43522,7 +43694,7 @@ async function validate5(_c, changes, ctx) {
|
|
|
43522
43694
|
const raw = change.after ?? await ctx.readFile(change.path);
|
|
43523
43695
|
if (typeof raw !== "string")
|
|
43524
43696
|
continue;
|
|
43525
|
-
const ext =
|
|
43697
|
+
const ext = path32.extname(change.path).toLowerCase();
|
|
43526
43698
|
if (ext !== TASK_EXT && ext !== TASK_NEAR_MISS_EXTENSION)
|
|
43527
43699
|
continue;
|
|
43528
43700
|
const relPath = toPosix(change.path);
|
|
@@ -43575,8 +43747,8 @@ var init_akm_task_adapter = __esm(() => {
|
|
|
43575
43747
|
readCandidates(c, conceptId) {
|
|
43576
43748
|
const posix = toPosix(conceptId).replace(/\.ya?ml$/i, "");
|
|
43577
43749
|
return [
|
|
43578
|
-
{ path:
|
|
43579
|
-
{ path:
|
|
43750
|
+
{ path: path32.join(c.root, `${posix}.yml`), conceptId: posix },
|
|
43751
|
+
{ path: path32.join(c.root, `${posix}.yaml`), conceptId: posix }
|
|
43580
43752
|
];
|
|
43581
43753
|
},
|
|
43582
43754
|
directoryList() {
|
|
@@ -43585,16 +43757,16 @@ var init_akm_task_adapter = __esm(() => {
|
|
|
43585
43757
|
looksLikeRoot(root) {
|
|
43586
43758
|
let entries;
|
|
43587
43759
|
try {
|
|
43588
|
-
entries =
|
|
43760
|
+
entries = fs27.readdirSync(root, { withFileTypes: true });
|
|
43589
43761
|
} catch {
|
|
43590
43762
|
return false;
|
|
43591
43763
|
}
|
|
43592
43764
|
for (const entry of entries) {
|
|
43593
|
-
if (!entry.isFile() ||
|
|
43765
|
+
if (!entry.isFile() || path32.extname(entry.name).toLowerCase() !== TASK_EXT)
|
|
43594
43766
|
continue;
|
|
43595
43767
|
let raw;
|
|
43596
43768
|
try {
|
|
43597
|
-
raw =
|
|
43769
|
+
raw = fs27.readFileSync(path32.join(root, entry.name), "utf8");
|
|
43598
43770
|
} catch {
|
|
43599
43771
|
continue;
|
|
43600
43772
|
}
|
|
@@ -43616,8 +43788,8 @@ var init_akm_task_adapter = __esm(() => {
|
|
|
43616
43788
|
});
|
|
43617
43789
|
|
|
43618
43790
|
// src/core/adapter/adapters/akm-workflow-adapter.ts
|
|
43619
|
-
import
|
|
43620
|
-
import
|
|
43791
|
+
import fs28 from "node:fs";
|
|
43792
|
+
import path33 from "node:path";
|
|
43621
43793
|
function conceptIdOf2(relPath) {
|
|
43622
43794
|
return toPosix(relPath).replace(/\.(?:md|yml)$/i, "");
|
|
43623
43795
|
}
|
|
@@ -43669,14 +43841,19 @@ async function validate6(c, changes, ctx) {
|
|
|
43669
43841
|
const raw = change.after ?? await ctx.readFile(change.path);
|
|
43670
43842
|
if (typeof raw !== "string")
|
|
43671
43843
|
continue;
|
|
43672
|
-
const ext =
|
|
43673
|
-
if (!WORKFLOW_EXTS.has(ext) || isReservedDocFile(
|
|
43844
|
+
const ext = path33.extname(change.path).toLowerCase();
|
|
43845
|
+
if (!WORKFLOW_EXTS.has(ext) || isReservedDocFile(path33.basename(change.path)))
|
|
43674
43846
|
continue;
|
|
43675
43847
|
const relPath = toPosix(change.path);
|
|
43676
43848
|
if (!isWorkflowFile(raw))
|
|
43677
43849
|
continue;
|
|
43678
43850
|
const p = parseFrontmatter(raw);
|
|
43679
|
-
const parsed = {
|
|
43851
|
+
const parsed = {
|
|
43852
|
+
data: p.data,
|
|
43853
|
+
content: p.content,
|
|
43854
|
+
frontmatter: p.frontmatter,
|
|
43855
|
+
bodyStartLine: p.bodyStartLine
|
|
43856
|
+
};
|
|
43680
43857
|
diagnostics.push(...await runBaseValidateChecks(relPath, parsed, c.root, ctx));
|
|
43681
43858
|
diagnostics.push(...await perTypeValidateChecks({
|
|
43682
43859
|
type: "workflow",
|
|
@@ -43695,12 +43872,12 @@ function hasTopLevelWorkflowFile(root, entries) {
|
|
|
43695
43872
|
for (const entry of entries) {
|
|
43696
43873
|
if (!entry.isFile())
|
|
43697
43874
|
continue;
|
|
43698
|
-
const ext =
|
|
43875
|
+
const ext = path33.extname(entry.name).toLowerCase();
|
|
43699
43876
|
if (!WORKFLOW_EXTS.has(ext) || isReservedDocFile(entry.name))
|
|
43700
43877
|
continue;
|
|
43701
43878
|
let raw;
|
|
43702
43879
|
try {
|
|
43703
|
-
raw =
|
|
43880
|
+
raw = fs28.readFileSync(path33.join(root, entry.name), "utf8");
|
|
43704
43881
|
} catch {
|
|
43705
43882
|
continue;
|
|
43706
43883
|
}
|
|
@@ -43725,7 +43902,7 @@ var init_akm_workflow_adapter = __esm(() => {
|
|
|
43725
43902
|
readCandidates(c, conceptId) {
|
|
43726
43903
|
const posix = toPosix(conceptId);
|
|
43727
43904
|
const canonical = posix.replace(/\.md$/i, "");
|
|
43728
|
-
return /\.md$/i.test(posix) ? [{ path:
|
|
43905
|
+
return /\.md$/i.test(posix) ? [{ path: path33.join(c.root, posix), conceptId: canonical }] : [{ path: path33.join(c.root, `${posix}.md`), conceptId: canonical }];
|
|
43729
43906
|
},
|
|
43730
43907
|
directoryList() {
|
|
43731
43908
|
return ["."];
|
|
@@ -43733,7 +43910,7 @@ var init_akm_workflow_adapter = __esm(() => {
|
|
|
43733
43910
|
looksLikeRoot(root) {
|
|
43734
43911
|
let entries;
|
|
43735
43912
|
try {
|
|
43736
|
-
entries =
|
|
43913
|
+
entries = fs28.readdirSync(root, { withFileTypes: true });
|
|
43737
43914
|
} catch {
|
|
43738
43915
|
return false;
|
|
43739
43916
|
}
|
|
@@ -43743,7 +43920,7 @@ var init_akm_workflow_adapter = __esm(() => {
|
|
|
43743
43920
|
});
|
|
43744
43921
|
|
|
43745
43922
|
// src/core/adapter/adapters/tool-dir-shared.ts
|
|
43746
|
-
import
|
|
43923
|
+
import path34 from "node:path";
|
|
43747
43924
|
function isReserved(base) {
|
|
43748
43925
|
return RESERVED_FILES.has(base.toLowerCase());
|
|
43749
43926
|
}
|
|
@@ -43759,7 +43936,7 @@ function classify(relPath, layout) {
|
|
|
43759
43936
|
return { type: "instruction", conceptId: layout.instructionConceptId, name: layout.instructionConceptId };
|
|
43760
43937
|
}
|
|
43761
43938
|
const head = segs[0];
|
|
43762
|
-
const ext =
|
|
43939
|
+
const ext = path34.extname(base).toLowerCase();
|
|
43763
43940
|
if (layout.skillDirs.has(head)) {
|
|
43764
43941
|
if (segs.length === 3 && base === SKILL_MANIFEST2) {
|
|
43765
43942
|
return { type: "skill", conceptId: `${segs[0]}/${segs[1]}`, name: segs[1] };
|
|
@@ -43808,7 +43985,7 @@ function recognizeToolDir(layout, c, file2) {
|
|
|
43808
43985
|
function readCandidatesToolDir(layout, c, conceptId) {
|
|
43809
43986
|
const posix = toPosix(conceptId);
|
|
43810
43987
|
if (posix === layout.instructionConceptId) {
|
|
43811
|
-
return [{ path:
|
|
43988
|
+
return [{ path: path34.join(c.root, layout.instructionFile), conceptId: posix }];
|
|
43812
43989
|
}
|
|
43813
43990
|
const segs = posix.split("/").filter((segment) => segment.length > 0);
|
|
43814
43991
|
const head = segs[0];
|
|
@@ -43816,10 +43993,10 @@ function readCandidatesToolDir(layout, c, conceptId) {
|
|
|
43816
43993
|
if (!head || !rest)
|
|
43817
43994
|
return [];
|
|
43818
43995
|
if (layout.skillDirs.has(head)) {
|
|
43819
|
-
return segs.length === 2 ? [{ path:
|
|
43996
|
+
return segs.length === 2 ? [{ path: path34.join(c.root, head, rest, SKILL_MANIFEST2), conceptId: posix }] : [];
|
|
43820
43997
|
}
|
|
43821
43998
|
if (layout.commandDirs.has(head) || layout.agentDirs.has(head)) {
|
|
43822
|
-
return [{ path:
|
|
43999
|
+
return [{ path: path34.join(c.root, head, `${rest}.md`), conceptId: posix }];
|
|
43823
44000
|
}
|
|
43824
44001
|
return [];
|
|
43825
44002
|
}
|
|
@@ -43903,23 +44080,23 @@ var init_tool_dir_shared = __esm(() => {
|
|
|
43903
44080
|
});
|
|
43904
44081
|
|
|
43905
44082
|
// src/core/adapter/adapters/claude-adapter.ts
|
|
43906
|
-
import
|
|
43907
|
-
import
|
|
44083
|
+
import fs29 from "node:fs";
|
|
44084
|
+
import path35 from "node:path";
|
|
43908
44085
|
function dirExists(p) {
|
|
43909
44086
|
try {
|
|
43910
|
-
return
|
|
44087
|
+
return fs29.statSync(p).isDirectory();
|
|
43911
44088
|
} catch {
|
|
43912
44089
|
return false;
|
|
43913
44090
|
}
|
|
43914
44091
|
}
|
|
43915
44092
|
function claudeLooksLikeRoot(root) {
|
|
43916
44093
|
try {
|
|
43917
|
-
if (!
|
|
44094
|
+
if (!fs29.existsSync(path35.join(root, "CLAUDE.md")))
|
|
43918
44095
|
return false;
|
|
43919
44096
|
} catch {
|
|
43920
44097
|
return false;
|
|
43921
44098
|
}
|
|
43922
|
-
return ["commands", "agents", "skills"].some((d) => dirExists(
|
|
44099
|
+
return ["commands", "agents", "skills"].some((d) => dirExists(path35.join(root, d)));
|
|
43923
44100
|
}
|
|
43924
44101
|
var LAYOUT, claudeAdapter;
|
|
43925
44102
|
var init_claude_adapter = __esm(() => {
|
|
@@ -43937,7 +44114,7 @@ var init_claude_adapter = __esm(() => {
|
|
|
43937
44114
|
});
|
|
43938
44115
|
|
|
43939
44116
|
// src/core/adapter/adapters/code-project-adapter.ts
|
|
43940
|
-
import
|
|
44117
|
+
import path36 from "node:path";
|
|
43941
44118
|
function classify2(base, ext) {
|
|
43942
44119
|
if (CONFIG_FILENAMES.has(base) || TSCONFIG.test(base))
|
|
43943
44120
|
return "config";
|
|
@@ -43955,10 +44132,10 @@ function eligibleType(relPath) {
|
|
|
43955
44132
|
}
|
|
43956
44133
|
if (EXCLUDED_FILENAMES.has(base) || EXCLUDED_NAME_PATTERN.test(base))
|
|
43957
44134
|
return;
|
|
43958
|
-
return classify2(base,
|
|
44135
|
+
return classify2(base, path36.extname(base));
|
|
43959
44136
|
}
|
|
43960
44137
|
function languageOf(relPath) {
|
|
43961
|
-
return LANGUAGE_BY_EXTENSION[
|
|
44138
|
+
return LANGUAGE_BY_EXTENSION[path36.extname(relPath).toLowerCase()];
|
|
43962
44139
|
}
|
|
43963
44140
|
function recognize6(c, file2) {
|
|
43964
44141
|
const conceptId = toPosix(file2.relPath);
|
|
@@ -44100,13 +44277,13 @@ var init_code_project_adapter = __esm(() => {
|
|
|
44100
44277
|
extensions: [...MARKDOWN_EXTENSIONS],
|
|
44101
44278
|
walkMode: "all-directories",
|
|
44102
44279
|
recognize: recognize6,
|
|
44103
|
-
validate: (c, changes, ctx) => validateChangesWithBaseChecks(c, changes.filter((change) => MARKDOWN_EXTENSIONS.has(
|
|
44104
|
-
readCandidates: (c, conceptId) => [{ path:
|
|
44280
|
+
validate: (c, changes, ctx) => validateChangesWithBaseChecks(c, changes.filter((change) => MARKDOWN_EXTENSIONS.has(path36.extname(change.path).toLowerCase())), ctx),
|
|
44281
|
+
readCandidates: (c, conceptId) => [{ path: path36.join(c.root, conceptId), conceptId }]
|
|
44105
44282
|
};
|
|
44106
44283
|
});
|
|
44107
44284
|
|
|
44108
44285
|
// src/core/adapter/adapters/dotenv-adapter.ts
|
|
44109
|
-
import
|
|
44286
|
+
import fs30 from "node:fs";
|
|
44110
44287
|
function classify3(relPath) {
|
|
44111
44288
|
const posix = toPosix(relPath);
|
|
44112
44289
|
const segs = posix.split("/").filter((s) => s.length > 0);
|
|
@@ -44124,7 +44301,7 @@ function classify3(relPath) {
|
|
|
44124
44301
|
}
|
|
44125
44302
|
function hasSensitiveMarker(absPath, type) {
|
|
44126
44303
|
const marker = sensitiveMarkerPath(absPath, type === "env" ? "env" : "secret");
|
|
44127
|
-
return marker !== absPath &&
|
|
44304
|
+
return marker !== absPath && fs30.existsSync(marker);
|
|
44128
44305
|
}
|
|
44129
44306
|
function conceptIdForPath(type, relativePath) {
|
|
44130
44307
|
const posix = toPosix(relativePath);
|
|
@@ -44213,7 +44390,7 @@ var init_dotenv_adapter = __esm(() => {
|
|
|
44213
44390
|
looksLikeRoot(root) {
|
|
44214
44391
|
let entries;
|
|
44215
44392
|
try {
|
|
44216
|
-
entries =
|
|
44393
|
+
entries = fs30.readdirSync(root, { withFileTypes: true });
|
|
44217
44394
|
} catch {
|
|
44218
44395
|
return false;
|
|
44219
44396
|
}
|
|
@@ -44228,7 +44405,7 @@ var init_dotenv_adapter = __esm(() => {
|
|
|
44228
44405
|
});
|
|
44229
44406
|
|
|
44230
44407
|
// src/core/adapter/adapters/generic-files-adapter.ts
|
|
44231
|
-
import
|
|
44408
|
+
import path37 from "node:path";
|
|
44232
44409
|
function isReserved2(base) {
|
|
44233
44410
|
return RESERVED_FILES.has(base.toLowerCase());
|
|
44234
44411
|
}
|
|
@@ -44287,12 +44464,12 @@ var init_generic_files_adapter = __esm(() => {
|
|
|
44287
44464
|
validate: validateChangesWithBaseChecks,
|
|
44288
44465
|
readCandidates(c, conceptId) {
|
|
44289
44466
|
const posix = toPosix(conceptId);
|
|
44290
|
-
const extension =
|
|
44467
|
+
const extension = path37.extname(posix).toLowerCase();
|
|
44291
44468
|
const documentCandidates2 = [...DOCUMENT_EXTENSIONS].map((candidateExtension) => ({
|
|
44292
|
-
path:
|
|
44469
|
+
path: path37.join(c.root, `${posix}${candidateExtension}`),
|
|
44293
44470
|
conceptId: posix
|
|
44294
44471
|
}));
|
|
44295
|
-
return DOCUMENT_EXTENSIONS.has(extension) ? documentCandidates2 : [{ path:
|
|
44472
|
+
return DOCUMENT_EXTENSIONS.has(extension) ? documentCandidates2 : [{ path: path37.join(c.root, posix), conceptId: posix }, ...documentCandidates2];
|
|
44296
44473
|
},
|
|
44297
44474
|
looksLikeRoot() {
|
|
44298
44475
|
return false;
|
|
@@ -44301,8 +44478,8 @@ var init_generic_files_adapter = __esm(() => {
|
|
|
44301
44478
|
});
|
|
44302
44479
|
|
|
44303
44480
|
// src/core/adapter/adapters/okf-adapter.ts
|
|
44304
|
-
import
|
|
44305
|
-
import
|
|
44481
|
+
import fs31 from "node:fs";
|
|
44482
|
+
import path38 from "node:path";
|
|
44306
44483
|
function parseActorMapping(value) {
|
|
44307
44484
|
if (!isRecord(value))
|
|
44308
44485
|
return;
|
|
@@ -44361,7 +44538,7 @@ function isReservedFileName2(name) {
|
|
|
44361
44538
|
return RESERVED_FILES.has(name.toLowerCase());
|
|
44362
44539
|
}
|
|
44363
44540
|
function resolveOkfLinks(body, fileRelPath) {
|
|
44364
|
-
const dir =
|
|
44541
|
+
const dir = path38.posix.dirname(toPosix(fileRelPath));
|
|
44365
44542
|
const out = [];
|
|
44366
44543
|
const seen = new Set;
|
|
44367
44544
|
for (const link of markdownLinkTargets(body, true)) {
|
|
@@ -44385,10 +44562,10 @@ function resolveOkfLinks(body, fileRelPath) {
|
|
|
44385
44562
|
continue;
|
|
44386
44563
|
let resolved;
|
|
44387
44564
|
if (target.startsWith("/")) {
|
|
44388
|
-
resolved =
|
|
44565
|
+
resolved = path38.posix.normalize(target.slice(1));
|
|
44389
44566
|
} else {
|
|
44390
44567
|
const base = dir === "." ? "" : dir;
|
|
44391
|
-
resolved =
|
|
44568
|
+
resolved = path38.posix.normalize(path38.posix.join(base, target));
|
|
44392
44569
|
}
|
|
44393
44570
|
if (resolved.startsWith("../") || resolved === ".." || resolved.startsWith("/"))
|
|
44394
44571
|
continue;
|
|
@@ -44537,13 +44714,13 @@ var init_okf_adapter = __esm(() => {
|
|
|
44537
44714
|
validate: validate8,
|
|
44538
44715
|
readCandidates(c, conceptId) {
|
|
44539
44716
|
const canonical = conceptId.replace(/\\/g, "/").replace(/\.md$/i, "");
|
|
44540
|
-
return [{ path:
|
|
44717
|
+
return [{ path: path38.join(c.root, `${canonical}.md`), conceptId: canonical }];
|
|
44541
44718
|
},
|
|
44542
44719
|
directoryList(_c) {
|
|
44543
44720
|
return ["."];
|
|
44544
44721
|
},
|
|
44545
44722
|
looksLikeRoot(root) {
|
|
44546
|
-
if (
|
|
44723
|
+
if (fs31.existsSync(path38.join(root, "index.md")))
|
|
44547
44724
|
return true;
|
|
44548
44725
|
const stack = [root];
|
|
44549
44726
|
while (stack.length > 0) {
|
|
@@ -44552,15 +44729,15 @@ var init_okf_adapter = __esm(() => {
|
|
|
44552
44729
|
continue;
|
|
44553
44730
|
let entries;
|
|
44554
44731
|
try {
|
|
44555
|
-
entries =
|
|
44732
|
+
entries = fs31.readdirSync(current, { withFileTypes: true });
|
|
44556
44733
|
} catch {
|
|
44557
44734
|
continue;
|
|
44558
44735
|
}
|
|
44559
44736
|
for (const entry of entries) {
|
|
44560
44737
|
if (entry.isSymbolicLink() || entry.name === ".git")
|
|
44561
44738
|
continue;
|
|
44562
|
-
const absolute =
|
|
44563
|
-
if (isScratchPath(
|
|
44739
|
+
const absolute = path38.join(current, entry.name);
|
|
44740
|
+
if (isScratchPath(path38.relative(root, absolute)))
|
|
44564
44741
|
continue;
|
|
44565
44742
|
if (entry.isDirectory()) {
|
|
44566
44743
|
stack.push(absolute);
|
|
@@ -44568,7 +44745,7 @@ var init_okf_adapter = __esm(() => {
|
|
|
44568
44745
|
}
|
|
44569
44746
|
if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".md") || isReservedFileName2(entry.name))
|
|
44570
44747
|
continue;
|
|
44571
|
-
const type = nonEmptyString2(parseFrontmatter(
|
|
44748
|
+
const type = nonEmptyString2(parseFrontmatter(fs31.readFileSync(absolute, "utf8")).data.type);
|
|
44572
44749
|
if (type)
|
|
44573
44750
|
return true;
|
|
44574
44751
|
}
|
|
@@ -44579,28 +44756,28 @@ var init_okf_adapter = __esm(() => {
|
|
|
44579
44756
|
});
|
|
44580
44757
|
|
|
44581
44758
|
// src/core/adapter/adapters/opencode-adapter.ts
|
|
44582
|
-
import
|
|
44583
|
-
import
|
|
44759
|
+
import fs32 from "node:fs";
|
|
44760
|
+
import path39 from "node:path";
|
|
44584
44761
|
function fileExists(p) {
|
|
44585
44762
|
try {
|
|
44586
|
-
return
|
|
44763
|
+
return fs32.existsSync(p);
|
|
44587
44764
|
} catch {
|
|
44588
44765
|
return false;
|
|
44589
44766
|
}
|
|
44590
44767
|
}
|
|
44591
44768
|
function dirExists2(p) {
|
|
44592
44769
|
try {
|
|
44593
|
-
return
|
|
44770
|
+
return fs32.statSync(p).isDirectory();
|
|
44594
44771
|
} catch {
|
|
44595
44772
|
return false;
|
|
44596
44773
|
}
|
|
44597
44774
|
}
|
|
44598
44775
|
function opencodeLooksLikeRoot(root) {
|
|
44599
|
-
if (CONFIG_FILES.some((f2) => fileExists(
|
|
44776
|
+
if (CONFIG_FILES.some((f2) => fileExists(path39.join(root, f2))))
|
|
44600
44777
|
return true;
|
|
44601
|
-
if (!fileExists(
|
|
44778
|
+
if (!fileExists(path39.join(root, "AGENTS.md")))
|
|
44602
44779
|
return false;
|
|
44603
|
-
return TOOL_DIRS.some((d) => dirExists2(
|
|
44780
|
+
return TOOL_DIRS.some((d) => dirExists2(path39.join(root, d)));
|
|
44604
44781
|
}
|
|
44605
44782
|
var LAYOUT2, CONFIG_FILES, TOOL_DIRS, opencodeAdapter;
|
|
44606
44783
|
var init_opencode_adapter = __esm(() => {
|
|
@@ -44620,8 +44797,8 @@ var init_opencode_adapter = __esm(() => {
|
|
|
44620
44797
|
});
|
|
44621
44798
|
|
|
44622
44799
|
// src/core/adapter/adapters/website-snapshot-adapter.ts
|
|
44623
|
-
import
|
|
44624
|
-
import
|
|
44800
|
+
import fs33 from "node:fs";
|
|
44801
|
+
import path40 from "node:path";
|
|
44625
44802
|
function parseSnapshotFrontmatter(raw) {
|
|
44626
44803
|
const out = { tags: [] };
|
|
44627
44804
|
const block = parseFrontmatterBlock(raw);
|
|
@@ -44711,12 +44888,12 @@ var init_website_snapshot_adapter = __esm(() => {
|
|
|
44711
44888
|
validate: validate9,
|
|
44712
44889
|
readCandidates(c, conceptId) {
|
|
44713
44890
|
const canonical = toPosix(conceptId).replace(/\.md$/i, "");
|
|
44714
|
-
return [{ path:
|
|
44891
|
+
return [{ path: path40.join(c.root, PAGES_PREFIX, `${canonical}.md`), conceptId: canonical }];
|
|
44715
44892
|
},
|
|
44716
44893
|
looksLikeRoot(root) {
|
|
44717
44894
|
let raw;
|
|
44718
44895
|
try {
|
|
44719
|
-
raw =
|
|
44896
|
+
raw = fs33.readFileSync(path40.join(root, MANIFEST_FILE), "utf8");
|
|
44720
44897
|
} catch {
|
|
44721
44898
|
return false;
|
|
44722
44899
|
}
|
|
@@ -44796,8 +44973,8 @@ var init_registry = __esm(() => {
|
|
|
44796
44973
|
});
|
|
44797
44974
|
|
|
44798
44975
|
// src/core/adapter/detect-adapter.ts
|
|
44799
|
-
import
|
|
44800
|
-
import
|
|
44976
|
+
import fs34 from "node:fs";
|
|
44977
|
+
import path41 from "node:path";
|
|
44801
44978
|
function hasExtraAkmContent(root, winnerId) {
|
|
44802
44979
|
const akm = adapterForId("akm");
|
|
44803
44980
|
if (akm?.looksLikeRoot?.(root) !== true)
|
|
@@ -44807,7 +44984,7 @@ function hasExtraAkmContent(root, winnerId) {
|
|
|
44807
44984
|
const ownedDirs = new Set(winner?.directoryList?.(stubComponent) ?? []);
|
|
44808
44985
|
let entries;
|
|
44809
44986
|
try {
|
|
44810
|
-
entries =
|
|
44987
|
+
entries = fs34.readdirSync(root, { withFileTypes: true });
|
|
44811
44988
|
} catch {
|
|
44812
44989
|
return false;
|
|
44813
44990
|
}
|
|
@@ -44818,13 +44995,13 @@ function hasExtraAkmContent(root, winnerId) {
|
|
|
44818
44995
|
continue;
|
|
44819
44996
|
if (winnerId === "agent-skills") {
|
|
44820
44997
|
try {
|
|
44821
|
-
if (
|
|
44998
|
+
if (fs34.statSync(path41.join(root, entry.name, "SKILL.md")).isFile())
|
|
44822
44999
|
continue;
|
|
44823
45000
|
} catch {}
|
|
44824
45001
|
}
|
|
44825
45002
|
let children;
|
|
44826
45003
|
try {
|
|
44827
|
-
children =
|
|
45004
|
+
children = fs34.readdirSync(path41.join(root, entry.name), { withFileTypes: true });
|
|
44828
45005
|
} catch {
|
|
44829
45006
|
continue;
|
|
44830
45007
|
}
|
|
@@ -44951,8 +45128,8 @@ var init_index_entries_repository = __esm(() => {
|
|
|
44951
45128
|
});
|
|
44952
45129
|
|
|
44953
45130
|
// src/workflows/source-files.ts
|
|
44954
|
-
import
|
|
44955
|
-
import
|
|
45131
|
+
import fs35 from "node:fs";
|
|
45132
|
+
import path42 from "node:path";
|
|
44956
45133
|
function ownsWorkflowFile(sourceRoot, adapterId, absPath) {
|
|
44957
45134
|
if (adapterId === "akm-workflow")
|
|
44958
45135
|
return true;
|
|
@@ -44966,39 +45143,39 @@ function listWorkflowSourceFiles(sourceRoot, adapterId, name) {
|
|
|
44966
45143
|
throw new UsageError("Workflow ref resolves outside the bundle root.", "PATH_ESCAPE_VIOLATION");
|
|
44967
45144
|
}
|
|
44968
45145
|
let realRoot;
|
|
44969
|
-
const authoredRoot =
|
|
45146
|
+
const authoredRoot = path42.resolve(sourceRoot);
|
|
44970
45147
|
try {
|
|
44971
|
-
realRoot =
|
|
45148
|
+
realRoot = fs35.realpathSync(authoredRoot);
|
|
44972
45149
|
} catch {
|
|
44973
45150
|
return [];
|
|
44974
45151
|
}
|
|
44975
|
-
const parent =
|
|
45152
|
+
const parent = path42.join(authoredRoot, path42.dirname(canonicalName));
|
|
44976
45153
|
if (!isWithinResolved(parent, authoredRoot)) {
|
|
44977
45154
|
throw new UsageError("Workflow ref resolves outside the bundle root.", "PATH_ESCAPE_VIOLATION");
|
|
44978
45155
|
}
|
|
44979
45156
|
let entries;
|
|
44980
45157
|
try {
|
|
44981
|
-
entries =
|
|
45158
|
+
entries = fs35.readdirSync(parent, { withFileTypes: true });
|
|
44982
45159
|
} catch {
|
|
44983
45160
|
return [];
|
|
44984
45161
|
}
|
|
44985
|
-
const basename =
|
|
45162
|
+
const basename = path42.basename(canonicalName);
|
|
44986
45163
|
const candidates = [];
|
|
44987
45164
|
for (const entry of entries) {
|
|
44988
45165
|
if (!entry.isFile() && !entry.isSymbolicLink())
|
|
44989
45166
|
continue;
|
|
44990
|
-
const extension =
|
|
45167
|
+
const extension = path42.extname(entry.name);
|
|
44991
45168
|
const lowerExtension = extension.toLowerCase();
|
|
44992
45169
|
if (!WORKFLOW_EXTENSIONS.includes(lowerExtension))
|
|
44993
45170
|
continue;
|
|
44994
45171
|
if (entry.name.slice(0, -extension.length) !== basename)
|
|
44995
45172
|
continue;
|
|
44996
|
-
const candidatePath =
|
|
45173
|
+
const candidatePath = path42.join(parent, entry.name);
|
|
44997
45174
|
if (!ownsWorkflowFile(authoredRoot, adapterId, candidatePath))
|
|
44998
45175
|
continue;
|
|
44999
45176
|
candidates.push({
|
|
45000
45177
|
path: candidatePath,
|
|
45001
|
-
relativePath: toPosix(
|
|
45178
|
+
relativePath: toPosix(path42.relative(authoredRoot, candidatePath)),
|
|
45002
45179
|
lowerExtension,
|
|
45003
45180
|
extensionlessStem: entry.name.slice(0, -extension.length)
|
|
45004
45181
|
});
|
|
@@ -45032,7 +45209,7 @@ function inspectWorkflowSourceCandidate(candidate, canonicalName, realRoot) {
|
|
|
45032
45209
|
const issues = [];
|
|
45033
45210
|
let authoredStat;
|
|
45034
45211
|
try {
|
|
45035
|
-
authoredStat =
|
|
45212
|
+
authoredStat = fs35.lstatSync(candidate.path);
|
|
45036
45213
|
} catch {
|
|
45037
45214
|
issues.push(new WorkflowSourceLinkResolutionError(candidate.relativePath));
|
|
45038
45215
|
return { issues };
|
|
@@ -45044,17 +45221,17 @@ function inspectWorkflowSourceCandidate(candidate, canonicalName, realRoot) {
|
|
|
45044
45221
|
}
|
|
45045
45222
|
let realPath;
|
|
45046
45223
|
try {
|
|
45047
|
-
realPath =
|
|
45224
|
+
realPath = fs35.realpathSync(candidate.path);
|
|
45048
45225
|
} catch {
|
|
45049
45226
|
issues.push(new WorkflowSourceLinkResolutionError(candidate.relativePath));
|
|
45050
45227
|
return { issues };
|
|
45051
45228
|
}
|
|
45052
|
-
const targetPath = toPosix(
|
|
45053
|
-
if (isLink &&
|
|
45229
|
+
const targetPath = toPosix(path42.relative(realRoot, realPath));
|
|
45230
|
+
if (isLink && path42.extname(realPath).toLowerCase() !== candidate.lowerExtension) {
|
|
45054
45231
|
issues.push(new WorkflowSourceLinkIdentityError(candidate.relativePath, targetPath));
|
|
45055
45232
|
}
|
|
45056
45233
|
try {
|
|
45057
|
-
if (!
|
|
45234
|
+
if (!fs35.statSync(realPath).isFile())
|
|
45058
45235
|
issues.push(new WorkflowSourceLinkResolutionError(candidate.relativePath));
|
|
45059
45236
|
} catch {
|
|
45060
45237
|
issues.push(new WorkflowSourceLinkResolutionError(candidate.relativePath));
|
|
@@ -45080,11 +45257,11 @@ function normalizeName2(name) {
|
|
|
45080
45257
|
return name.replaceAll("\\", "/");
|
|
45081
45258
|
}
|
|
45082
45259
|
function isSafeRelativeName(name) {
|
|
45083
|
-
return name.length > 0 && !
|
|
45260
|
+
return name.length > 0 && !path42.posix.isAbsolute(name) && name !== ".." && !name.startsWith("../") && path42.posix.normalize(name) === name;
|
|
45084
45261
|
}
|
|
45085
45262
|
function isWithinResolved(candidate, root) {
|
|
45086
|
-
const relative =
|
|
45087
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
45263
|
+
const relative = path42.relative(root, path42.resolve(candidate));
|
|
45264
|
+
return relative === "" || !relative.startsWith("..") && !path42.isAbsolute(relative);
|
|
45088
45265
|
}
|
|
45089
45266
|
var WorkflowSourceRejectionError, WorkflowSourceLinkIdentityError, WorkflowSourceLinkResolutionError;
|
|
45090
45267
|
var init_source_files = __esm(() => {
|
|
@@ -45134,11 +45311,11 @@ var init_index_writer_lock = __esm(() => {
|
|
|
45134
45311
|
});
|
|
45135
45312
|
|
|
45136
45313
|
// src/integrations/lockfile.ts
|
|
45137
|
-
import
|
|
45314
|
+
import fs36 from "node:fs";
|
|
45138
45315
|
function readLockfile() {
|
|
45139
45316
|
const lockfilePath = getLockfilePath();
|
|
45140
45317
|
try {
|
|
45141
|
-
const raw = JSON.parse(
|
|
45318
|
+
const raw = JSON.parse(fs36.readFileSync(lockfilePath, "utf8"));
|
|
45142
45319
|
if (!Array.isArray(raw))
|
|
45143
45320
|
return [];
|
|
45144
45321
|
return raw.filter(isValidLockfileEntry);
|
|
@@ -47115,9 +47292,9 @@ var init_semver = __esm(() => {
|
|
|
47115
47292
|
|
|
47116
47293
|
// src/registry/resolve.ts
|
|
47117
47294
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
47118
|
-
import
|
|
47119
|
-
import
|
|
47120
|
-
import
|
|
47295
|
+
import fs37 from "node:fs";
|
|
47296
|
+
import os10 from "node:os";
|
|
47297
|
+
import path43 from "node:path";
|
|
47121
47298
|
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
|
|
47122
47299
|
function gitCredentialEnvironment(credential) {
|
|
47123
47300
|
if (!credential)
|
|
@@ -47303,10 +47480,10 @@ function parseGitUrl(input2, originalRef) {
|
|
|
47303
47480
|
};
|
|
47304
47481
|
}
|
|
47305
47482
|
function tryParseLocalRef(rawRef, explicitPath) {
|
|
47306
|
-
const resolvedPath =
|
|
47483
|
+
const resolvedPath = path43.resolve(rawRef);
|
|
47307
47484
|
let stat;
|
|
47308
47485
|
try {
|
|
47309
|
-
stat =
|
|
47486
|
+
stat = fs37.statSync(resolvedPath);
|
|
47310
47487
|
} catch {
|
|
47311
47488
|
if (explicitPath) {
|
|
47312
47489
|
throw new NotFoundError(`Local path not found: ${resolvedPath}`, "FILE_NOT_FOUND", "Check the path exists and is readable.");
|
|
@@ -47333,7 +47510,7 @@ function isPathLikeRef(ref) {
|
|
|
47333
47510
|
return false;
|
|
47334
47511
|
if (ref === "." || ref === "..")
|
|
47335
47512
|
return true;
|
|
47336
|
-
if (
|
|
47513
|
+
if (path43.isAbsolute(ref))
|
|
47337
47514
|
return true;
|
|
47338
47515
|
if (ref.startsWith("./") || ref.startsWith("../") || ref.startsWith(".\\") || ref.startsWith("..\\")) {
|
|
47339
47516
|
return true;
|
|
@@ -47563,21 +47740,21 @@ function fileUriToPath(ref) {
|
|
|
47563
47740
|
return after;
|
|
47564
47741
|
}
|
|
47565
47742
|
function toReadableLocalId(absolutePath) {
|
|
47566
|
-
const home =
|
|
47743
|
+
const home = os10.homedir();
|
|
47567
47744
|
if (absolutePath === home)
|
|
47568
47745
|
return "~";
|
|
47569
|
-
if (absolutePath.startsWith(home +
|
|
47746
|
+
if (absolutePath.startsWith(home + path43.sep)) {
|
|
47570
47747
|
return `~/${absolutePath.slice(home.length + 1)}`;
|
|
47571
47748
|
}
|
|
47572
47749
|
return absolutePath;
|
|
47573
47750
|
}
|
|
47574
47751
|
function findGitRepoRoot(startDir) {
|
|
47575
|
-
let current =
|
|
47752
|
+
let current = path43.resolve(startDir);
|
|
47576
47753
|
while (true) {
|
|
47577
|
-
if (
|
|
47754
|
+
if (fs37.existsSync(path43.join(current, ".git"))) {
|
|
47578
47755
|
return current;
|
|
47579
47756
|
}
|
|
47580
|
-
const parent =
|
|
47757
|
+
const parent = path43.dirname(current);
|
|
47581
47758
|
if (parent === current)
|
|
47582
47759
|
return;
|
|
47583
47760
|
current = parent;
|
|
@@ -47613,11 +47790,11 @@ var init_resolve = __esm(() => {
|
|
|
47613
47790
|
});
|
|
47614
47791
|
|
|
47615
47792
|
// src/sources/include.ts
|
|
47616
|
-
import
|
|
47617
|
-
import
|
|
47793
|
+
import fs38 from "node:fs";
|
|
47794
|
+
import path44 from "node:path";
|
|
47618
47795
|
function readPackageJsonAt(dirPath) {
|
|
47619
47796
|
try {
|
|
47620
|
-
const raw =
|
|
47797
|
+
const raw = fs38.readFileSync(path44.join(dirPath, "package.json"), "utf8");
|
|
47621
47798
|
const parsed = JSON.parse(raw);
|
|
47622
47799
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
47623
47800
|
return parsed;
|
|
@@ -47644,8 +47821,8 @@ function extractIncludeList(pkg) {
|
|
|
47644
47821
|
return;
|
|
47645
47822
|
}
|
|
47646
47823
|
function findNearestIncludeConfig(startDir, boundary) {
|
|
47647
|
-
let current =
|
|
47648
|
-
const resolvedBoundary =
|
|
47824
|
+
let current = path44.resolve(startDir);
|
|
47825
|
+
const resolvedBoundary = path44.resolve(boundary);
|
|
47649
47826
|
while (isWithin(current, resolvedBoundary)) {
|
|
47650
47827
|
const pkg = readPackageJsonAt(current);
|
|
47651
47828
|
const include = extractIncludeList(pkg);
|
|
@@ -47654,7 +47831,7 @@ function findNearestIncludeConfig(startDir, boundary) {
|
|
|
47654
47831
|
}
|
|
47655
47832
|
if (current === resolvedBoundary)
|
|
47656
47833
|
break;
|
|
47657
|
-
const parent =
|
|
47834
|
+
const parent = path44.dirname(current);
|
|
47658
47835
|
if (parent === current)
|
|
47659
47836
|
break;
|
|
47660
47837
|
current = parent;
|
|
@@ -47665,7 +47842,7 @@ function isIncludeEntryPattern(entry) {
|
|
|
47665
47842
|
return /[*?]/.test(entry);
|
|
47666
47843
|
}
|
|
47667
47844
|
function includeEntryToRegExp(entry) {
|
|
47668
|
-
const normalized = entry.split(
|
|
47845
|
+
const normalized = entry.split(path44.sep).join("/");
|
|
47669
47846
|
let pattern = "";
|
|
47670
47847
|
for (let i = 0;i < normalized.length; ) {
|
|
47671
47848
|
if (normalized.startsWith("**", i)) {
|
|
@@ -47687,7 +47864,7 @@ function includeEntryToRegExp(entry) {
|
|
|
47687
47864
|
}
|
|
47688
47865
|
function isBrokenSymlink(candidate) {
|
|
47689
47866
|
try {
|
|
47690
|
-
return
|
|
47867
|
+
return fs38.lstatSync(candidate).isSymbolicLink();
|
|
47691
47868
|
} catch {
|
|
47692
47869
|
return false;
|
|
47693
47870
|
}
|
|
@@ -47696,15 +47873,15 @@ function listAllRelativePaths(dir, base) {
|
|
|
47696
47873
|
const out = [];
|
|
47697
47874
|
let entries;
|
|
47698
47875
|
try {
|
|
47699
|
-
entries =
|
|
47876
|
+
entries = fs38.readdirSync(dir, { withFileTypes: true });
|
|
47700
47877
|
} catch {
|
|
47701
47878
|
return out;
|
|
47702
47879
|
}
|
|
47703
47880
|
for (const entry of entries) {
|
|
47704
47881
|
if (entry.name === ".git")
|
|
47705
47882
|
continue;
|
|
47706
|
-
const absolute =
|
|
47707
|
-
out.push(
|
|
47883
|
+
const absolute = path44.join(dir, entry.name);
|
|
47884
|
+
out.push(path44.relative(base, absolute).split(path44.sep).join("/"));
|
|
47708
47885
|
if (entry.isDirectory())
|
|
47709
47886
|
out.push(...listAllRelativePaths(absolute, base));
|
|
47710
47887
|
}
|
|
@@ -47712,9 +47889,9 @@ function listAllRelativePaths(dir, base) {
|
|
|
47712
47889
|
}
|
|
47713
47890
|
function resolveIncludeEntry(entry, sourceDir) {
|
|
47714
47891
|
if (!isIncludeEntryPattern(entry))
|
|
47715
|
-
return [
|
|
47892
|
+
return [path44.resolve(sourceDir, entry)];
|
|
47716
47893
|
const pattern = includeEntryToRegExp(entry);
|
|
47717
|
-
return listAllRelativePaths(sourceDir, sourceDir).filter((relative) => pattern.test(relative)).map((relative) =>
|
|
47894
|
+
return listAllRelativePaths(sourceDir, sourceDir).filter((relative) => pattern.test(relative)).map((relative) => path44.join(sourceDir, relative));
|
|
47718
47895
|
}
|
|
47719
47896
|
function copyIncludedPaths(includeGlobs, sourceDir, destDir) {
|
|
47720
47897
|
for (const entry of includeGlobs) {
|
|
@@ -47727,59 +47904,59 @@ function copyIncludedPaths(includeGlobs, sourceDir, destDir) {
|
|
|
47727
47904
|
if (!isWithin(resolvedSource, sourceDir)) {
|
|
47728
47905
|
throw new Error(`Path in akm.include escapes the package root: ${entry}`);
|
|
47729
47906
|
}
|
|
47730
|
-
if (!
|
|
47907
|
+
if (!fs38.existsSync(resolvedSource) && !isBrokenSymlink(resolvedSource)) {
|
|
47731
47908
|
warnOnce(`akm-include-missing:${sourceDir}:${entry}`, `[akm] Skipping "${entry}" in akm.include: no matching file or directory.`);
|
|
47732
47909
|
continue;
|
|
47733
47910
|
}
|
|
47734
|
-
if (
|
|
47911
|
+
if (path44.basename(resolvedSource) === ".git")
|
|
47735
47912
|
continue;
|
|
47736
|
-
const relativePath =
|
|
47913
|
+
const relativePath = path44.relative(sourceDir, resolvedSource);
|
|
47737
47914
|
if (!relativePath || relativePath === ".") {
|
|
47738
47915
|
copyDirectoryContents(sourceDir, destDir, sourceDir);
|
|
47739
47916
|
continue;
|
|
47740
47917
|
}
|
|
47741
|
-
copyPath(resolvedSource,
|
|
47918
|
+
copyPath(resolvedSource, path44.join(destDir, relativePath), sourceDir);
|
|
47742
47919
|
}
|
|
47743
47920
|
}
|
|
47744
47921
|
}
|
|
47745
47922
|
function copyDirectoryContents(sourceDir, destinationDir, containmentRoot) {
|
|
47746
|
-
for (const entry of
|
|
47923
|
+
for (const entry of fs38.readdirSync(sourceDir, { withFileTypes: true })) {
|
|
47747
47924
|
if (entry.name === ".git")
|
|
47748
47925
|
continue;
|
|
47749
|
-
copyPath(
|
|
47926
|
+
copyPath(path44.join(sourceDir, entry.name), path44.join(destinationDir, entry.name), containmentRoot);
|
|
47750
47927
|
}
|
|
47751
47928
|
}
|
|
47752
47929
|
function copyPath(sourcePath, destinationPath, containmentRoot) {
|
|
47753
|
-
const stat =
|
|
47930
|
+
const stat = fs38.lstatSync(sourcePath);
|
|
47754
47931
|
if (stat.isSymbolicLink()) {
|
|
47755
47932
|
let resolved;
|
|
47756
47933
|
try {
|
|
47757
|
-
resolved =
|
|
47934
|
+
resolved = fs38.realpathSync(sourcePath);
|
|
47758
47935
|
} catch {
|
|
47759
|
-
warnOnce(`akm-include-broken-symlink:${sourcePath}`, `[akm] Skipping broken symlink in akm.include: ${
|
|
47936
|
+
warnOnce(`akm-include-broken-symlink:${sourcePath}`, `[akm] Skipping broken symlink in akm.include: ${path44.relative(containmentRoot, sourcePath)}`);
|
|
47760
47937
|
return;
|
|
47761
47938
|
}
|
|
47762
47939
|
if (!isWithin(resolved, containmentRoot)) {
|
|
47763
|
-
warnOnce(`akm-include-symlink-escape:${sourcePath}`, `[akm] Skipping symlink in akm.include that points outside the package: ${
|
|
47940
|
+
warnOnce(`akm-include-symlink-escape:${sourcePath}`, `[akm] Skipping symlink in akm.include that points outside the package: ${path44.relative(containmentRoot, sourcePath)}`);
|
|
47764
47941
|
return;
|
|
47765
47942
|
}
|
|
47766
|
-
const resolvedStat =
|
|
47767
|
-
|
|
47943
|
+
const resolvedStat = fs38.statSync(resolved);
|
|
47944
|
+
fs38.mkdirSync(path44.dirname(destinationPath), { recursive: true });
|
|
47768
47945
|
if (resolvedStat.isDirectory()) {
|
|
47769
|
-
|
|
47946
|
+
fs38.mkdirSync(destinationPath, { recursive: true });
|
|
47770
47947
|
copyDirectoryContents(resolved, destinationPath, containmentRoot);
|
|
47771
47948
|
return;
|
|
47772
47949
|
}
|
|
47773
|
-
|
|
47950
|
+
fs38.copyFileSync(resolved, destinationPath);
|
|
47774
47951
|
return;
|
|
47775
47952
|
}
|
|
47776
|
-
|
|
47953
|
+
fs38.mkdirSync(path44.dirname(destinationPath), { recursive: true });
|
|
47777
47954
|
if (stat.isDirectory()) {
|
|
47778
|
-
|
|
47955
|
+
fs38.mkdirSync(destinationPath, { recursive: true });
|
|
47779
47956
|
copyDirectoryContents(sourcePath, destinationPath, containmentRoot);
|
|
47780
47957
|
return;
|
|
47781
47958
|
}
|
|
47782
|
-
|
|
47959
|
+
fs38.copyFileSync(sourcePath, destinationPath);
|
|
47783
47960
|
}
|
|
47784
47961
|
var INCLUDE_CONFIG_KEYS;
|
|
47785
47962
|
var init_include2 = __esm(() => {
|
|
@@ -47790,8 +47967,8 @@ var init_include2 = __esm(() => {
|
|
|
47790
47967
|
|
|
47791
47968
|
// src/sources/providers/provider-utils.ts
|
|
47792
47969
|
import { createHash as createHash3, randomUUID as randomUUID2 } from "node:crypto";
|
|
47793
|
-
import
|
|
47794
|
-
import
|
|
47970
|
+
import fs39 from "node:fs";
|
|
47971
|
+
import path45 from "node:path";
|
|
47795
47972
|
function sanitizeString(value, maxLength = 255) {
|
|
47796
47973
|
if (typeof value !== "string")
|
|
47797
47974
|
return "";
|
|
@@ -47807,7 +47984,7 @@ function looksLikeAnyBundleRoot(root) {
|
|
|
47807
47984
|
return false;
|
|
47808
47985
|
}
|
|
47809
47986
|
function detectStashRoot(extractedDir) {
|
|
47810
|
-
const root =
|
|
47987
|
+
const root = path45.resolve(extractedDir);
|
|
47811
47988
|
if (looksLikeAnyBundleRoot(root)) {
|
|
47812
47989
|
return root;
|
|
47813
47990
|
}
|
|
@@ -47824,15 +48001,15 @@ function buildInstallCacheDir(cacheRootDir, source, id, version2) {
|
|
|
47824
48001
|
const identitySuffix = version2 === "writable" ? `-${createHash3("sha256").update(`${source}:${id}`).digest("hex").slice(0, 12)}` : "";
|
|
47825
48002
|
const slug = `${source}-${safeId}${identitySuffix}`;
|
|
47826
48003
|
const versionSlug = source === "local" ? uniqueSlug() : version2?.replace(/[^a-zA-Z0-9_.-]+/g, "-") ?? uniqueSlug();
|
|
47827
|
-
return
|
|
48004
|
+
return path45.join(cacheRootDir, slug || source, versionSlug);
|
|
47828
48005
|
}
|
|
47829
48006
|
function applyAkmIncludeConfig(sourceRoot, cacheDir, searchRoot = sourceRoot) {
|
|
47830
48007
|
const includeConfig = findNearestIncludeConfig(sourceRoot, searchRoot);
|
|
47831
48008
|
if (!includeConfig)
|
|
47832
48009
|
return;
|
|
47833
|
-
const selectedDir =
|
|
47834
|
-
|
|
47835
|
-
|
|
48010
|
+
const selectedDir = path45.join(cacheDir, "selected");
|
|
48011
|
+
fs39.rmSync(selectedDir, { recursive: true, force: true });
|
|
48012
|
+
fs39.mkdirSync(selectedDir, { recursive: true });
|
|
47836
48013
|
copyIncludedPaths(includeConfig.include, includeConfig.baseDir, selectedDir);
|
|
47837
48014
|
return selectedDir;
|
|
47838
48015
|
}
|
|
@@ -47841,13 +48018,13 @@ async function downloadArchive(url2, destination) {
|
|
|
47841
48018
|
await writeResponseToFileCapped(destination, response);
|
|
47842
48019
|
}
|
|
47843
48020
|
async function computeFileHash(filePath) {
|
|
47844
|
-
const data =
|
|
48021
|
+
const data = fs39.readFileSync(filePath);
|
|
47845
48022
|
const hash2 = createHash3("sha256").update(data).digest("hex");
|
|
47846
48023
|
return `sha256:${hash2}`;
|
|
47847
48024
|
}
|
|
47848
48025
|
function isDirectory(target) {
|
|
47849
48026
|
try {
|
|
47850
|
-
return
|
|
48027
|
+
return fs39.statSync(target).isDirectory();
|
|
47851
48028
|
} catch {
|
|
47852
48029
|
return false;
|
|
47853
48030
|
}
|
|
@@ -47855,7 +48032,7 @@ function isDirectory(target) {
|
|
|
47855
48032
|
function countStashDirs(dirPath) {
|
|
47856
48033
|
if (!isDirectory(dirPath))
|
|
47857
48034
|
return 0;
|
|
47858
|
-
const entries =
|
|
48035
|
+
const entries = fs39.readdirSync(dirPath, { withFileTypes: true });
|
|
47859
48036
|
return entries.filter((entry) => entry.isDirectory() && REGISTRY_STASH_DIR_NAMES.has(entry.name)).length;
|
|
47860
48037
|
}
|
|
47861
48038
|
function findShallowestStashRoot(root) {
|
|
@@ -47867,7 +48044,7 @@ function findShallowestStashRoot(root) {
|
|
|
47867
48044
|
}
|
|
47868
48045
|
const { dir: current, depth } = item;
|
|
47869
48046
|
if (current !== root) {
|
|
47870
|
-
if (isDirectory(
|
|
48047
|
+
if (isDirectory(path45.join(current, ".stash"))) {
|
|
47871
48048
|
return current;
|
|
47872
48049
|
}
|
|
47873
48050
|
if (countStashDirs(current) >= 2) {
|
|
@@ -47878,7 +48055,7 @@ function findShallowestStashRoot(root) {
|
|
|
47878
48055
|
continue;
|
|
47879
48056
|
let children;
|
|
47880
48057
|
try {
|
|
47881
|
-
children =
|
|
48058
|
+
children = fs39.readdirSync(current, { withFileTypes: true });
|
|
47882
48059
|
} catch {
|
|
47883
48060
|
continue;
|
|
47884
48061
|
}
|
|
@@ -47887,8 +48064,8 @@ function findShallowestStashRoot(root) {
|
|
|
47887
48064
|
continue;
|
|
47888
48065
|
if (child.name === ".git" || child.name === "node_modules")
|
|
47889
48066
|
continue;
|
|
47890
|
-
const dir =
|
|
47891
|
-
if (isScratchPath(
|
|
48067
|
+
const dir = path45.join(current, child.name);
|
|
48068
|
+
if (isScratchPath(path45.relative(root, dir)))
|
|
47892
48069
|
continue;
|
|
47893
48070
|
queue.push({ dir, depth: depth + 1 });
|
|
47894
48071
|
}
|
|
@@ -47909,8 +48086,8 @@ var init_provider_utils = __esm(() => {
|
|
|
47909
48086
|
// src/sources/providers/git-install.ts
|
|
47910
48087
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
47911
48088
|
import { randomBytes } from "node:crypto";
|
|
47912
|
-
import
|
|
47913
|
-
import
|
|
48089
|
+
import fs40 from "node:fs";
|
|
48090
|
+
import path46 from "node:path";
|
|
47914
48091
|
function assertCleanWorktree(repoDir, subject, refusal) {
|
|
47915
48092
|
const status = runGit(["-C", repoDir, "-c", "core.quotePath=false", "status", "--porcelain"]);
|
|
47916
48093
|
if (status.error || status.status !== 0) {
|
|
@@ -47972,25 +48149,25 @@ function assertNoIgnoredPathOverwrite(repoDir, targetRevision) {
|
|
|
47972
48149
|
const changedPaths = changed.stdout.split("\x00").filter(Boolean);
|
|
47973
48150
|
const conflict = ignoredPaths.find((ignoredPath) => changedPaths.some((changedPath) => changedPath === ignoredPath || changedPath.startsWith(`${ignoredPath}/`) || ignoredPath.startsWith(`${changedPath}/`)));
|
|
47974
48151
|
if (conflict) {
|
|
47975
|
-
throw new UsageError(`Git update would overwrite ignored local path ${
|
|
48152
|
+
throw new UsageError(`Git update would overwrite ignored local path ${path46.join(repoDir, conflict)}; move or remove it before update.`, "INVALID_FLAG_VALUE", UPDATE_REFUSAL_HINT);
|
|
47976
48153
|
}
|
|
47977
48154
|
}
|
|
47978
48155
|
function replaceDirectory(stagedDir, destination) {
|
|
47979
48156
|
const backup = `${destination}.backup-${randomBytes(4).toString("hex")}`;
|
|
47980
|
-
|
|
47981
|
-
const hadDestination =
|
|
48157
|
+
fs40.mkdirSync(path46.dirname(destination), { recursive: true });
|
|
48158
|
+
const hadDestination = fs40.existsSync(destination);
|
|
47982
48159
|
if (hadDestination)
|
|
47983
|
-
|
|
48160
|
+
fs40.renameSync(destination, backup);
|
|
47984
48161
|
try {
|
|
47985
|
-
|
|
48162
|
+
fs40.renameSync(stagedDir, destination);
|
|
47986
48163
|
} catch (error62) {
|
|
47987
|
-
if (hadDestination &&
|
|
47988
|
-
|
|
48164
|
+
if (hadDestination && fs40.existsSync(backup))
|
|
48165
|
+
fs40.renameSync(backup, destination);
|
|
47989
48166
|
throw error62;
|
|
47990
48167
|
}
|
|
47991
48168
|
if (hadDestination) {
|
|
47992
48169
|
try {
|
|
47993
|
-
|
|
48170
|
+
fs40.rmSync(backup, { recursive: true, force: true });
|
|
47994
48171
|
} catch {}
|
|
47995
48172
|
}
|
|
47996
48173
|
}
|
|
@@ -48004,18 +48181,18 @@ function cloneRepo(cloneUrl, ref, destDir, writable = false, credential) {
|
|
|
48004
48181
|
args.push(cloneUrl, tmpDir);
|
|
48005
48182
|
const result = runGit(args, { timeout: 120000, env: gitCredentialEnvironment(credential) });
|
|
48006
48183
|
if (result.status !== 0) {
|
|
48007
|
-
|
|
48184
|
+
fs40.rmSync(tmpDir, { recursive: true, force: true });
|
|
48008
48185
|
throw new Error(classifyCloneFailure(cloneUrl, result.stderr, result.error));
|
|
48009
48186
|
}
|
|
48010
48187
|
try {
|
|
48011
48188
|
if (!writable) {
|
|
48012
|
-
const gitDir =
|
|
48013
|
-
if (
|
|
48014
|
-
|
|
48189
|
+
const gitDir = path46.join(tmpDir, ".git");
|
|
48190
|
+
if (fs40.existsSync(gitDir))
|
|
48191
|
+
fs40.rmSync(gitDir, { recursive: true, force: true });
|
|
48015
48192
|
}
|
|
48016
48193
|
replaceDirectory(tmpDir, destDir);
|
|
48017
48194
|
} catch (err) {
|
|
48018
|
-
|
|
48195
|
+
fs40.rmSync(tmpDir, { recursive: true, force: true });
|
|
48019
48196
|
throw err;
|
|
48020
48197
|
}
|
|
48021
48198
|
}
|
|
@@ -48054,12 +48231,12 @@ var init_git_install = __esm(() => {
|
|
|
48054
48231
|
});
|
|
48055
48232
|
|
|
48056
48233
|
// src/sources/freshness.ts
|
|
48057
|
-
import
|
|
48234
|
+
import fs41 from "node:fs";
|
|
48058
48235
|
async function withFreshnessCache(options) {
|
|
48059
48236
|
const usable = options.isUsable ?? (() => true);
|
|
48060
48237
|
let materialized = false;
|
|
48061
48238
|
try {
|
|
48062
|
-
|
|
48239
|
+
fs41.statSync(options.markerPath);
|
|
48063
48240
|
materialized = true;
|
|
48064
48241
|
} catch {}
|
|
48065
48242
|
if (!options.force && materialized && usable()) {
|
|
@@ -48071,8 +48248,8 @@ var init_freshness = () => {};
|
|
|
48071
48248
|
|
|
48072
48249
|
// src/sources/providers/git-provider.ts
|
|
48073
48250
|
import { createHash as createHash4 } from "node:crypto";
|
|
48074
|
-
import
|
|
48075
|
-
import
|
|
48251
|
+
import fs42 from "node:fs";
|
|
48252
|
+
import path47 from "node:path";
|
|
48076
48253
|
|
|
48077
48254
|
class GitSourceProvider {
|
|
48078
48255
|
kind = "git";
|
|
@@ -48108,11 +48285,11 @@ function resolveGitContentDir(config2) {
|
|
|
48108
48285
|
function getCachePaths(repoUrl, cacheRootOverride) {
|
|
48109
48286
|
const key = createHash4("sha256").update(repoUrl).digest("hex").slice(0, 16);
|
|
48110
48287
|
const cacheRoot = cacheRootOverride ?? getRegistryIndexCacheDir();
|
|
48111
|
-
const rootDir =
|
|
48288
|
+
const rootDir = path47.join(cacheRoot, `git-${key}`);
|
|
48112
48289
|
return {
|
|
48113
48290
|
rootDir,
|
|
48114
|
-
repoDir:
|
|
48115
|
-
indexPath:
|
|
48291
|
+
repoDir: path47.join(rootDir, "repo"),
|
|
48292
|
+
indexPath: path47.join(rootDir, "index.json")
|
|
48116
48293
|
};
|
|
48117
48294
|
}
|
|
48118
48295
|
async function ensureGitMirror(repo, cachePaths, options) {
|
|
@@ -48123,13 +48300,13 @@ async function ensureGitMirror(repo, cachePaths, options) {
|
|
|
48123
48300
|
force: options?.force === true,
|
|
48124
48301
|
isUsable: () => !requireRepoDir || hasExtractedRepo(cachePaths.repoDir),
|
|
48125
48302
|
refresh: async () => {
|
|
48126
|
-
|
|
48127
|
-
if (writable &&
|
|
48303
|
+
fs42.mkdirSync(cachePaths.rootDir, { recursive: true });
|
|
48304
|
+
if (writable && fs42.existsSync(path47.join(cachePaths.repoDir, ".git"))) {
|
|
48128
48305
|
pullRepo(cachePaths.repoDir, options?.credential);
|
|
48129
48306
|
} else {
|
|
48130
48307
|
cloneRepo(repo.cloneUrl, repo.ref, cachePaths.repoDir, writable, options?.credential);
|
|
48131
48308
|
}
|
|
48132
|
-
|
|
48309
|
+
fs42.writeFileSync(cachePaths.indexPath, "[]", { encoding: "utf8", mode: 384 });
|
|
48133
48310
|
}
|
|
48134
48311
|
});
|
|
48135
48312
|
}
|
|
@@ -48178,16 +48355,16 @@ function pullRepo(repoDir, credential) {
|
|
|
48178
48355
|
}
|
|
48179
48356
|
function hasExtractedRepo(repoDir) {
|
|
48180
48357
|
try {
|
|
48181
|
-
if (!
|
|
48358
|
+
if (!fs42.statSync(repoDir).isDirectory())
|
|
48182
48359
|
return false;
|
|
48183
|
-
if (
|
|
48360
|
+
if (fs42.statSync(path47.join(repoDir, "content")).isDirectory())
|
|
48184
48361
|
return true;
|
|
48185
48362
|
} catch {}
|
|
48186
48363
|
try {
|
|
48187
|
-
if (!
|
|
48364
|
+
if (!fs42.statSync(repoDir).isDirectory())
|
|
48188
48365
|
return false;
|
|
48189
48366
|
const ownedDirs = akmAdapter.directoryList?.({ id: "akm", adapter: "akm", root: repoDir, writable: false }) ?? stashDirNames();
|
|
48190
|
-
return ownedDirs.some((dirName) =>
|
|
48367
|
+
return ownedDirs.some((dirName) => fs42.existsSync(path47.join(repoDir, dirName)));
|
|
48191
48368
|
} catch {
|
|
48192
48369
|
return false;
|
|
48193
48370
|
}
|
|
@@ -48284,8 +48461,8 @@ var init_akm_markdown = __esm(() => {
|
|
|
48284
48461
|
});
|
|
48285
48462
|
|
|
48286
48463
|
// src/core/write-source.ts
|
|
48287
|
-
import
|
|
48288
|
-
import
|
|
48464
|
+
import fs43 from "node:fs";
|
|
48465
|
+
import path48 from "node:path";
|
|
48289
48466
|
function resolveWritable(entry) {
|
|
48290
48467
|
if (typeof entry.writable === "boolean")
|
|
48291
48468
|
return entry.writable;
|
|
@@ -48295,8 +48472,8 @@ function isSourceWriteActivated(source) {
|
|
|
48295
48472
|
return source.writable === true;
|
|
48296
48473
|
}
|
|
48297
48474
|
function resolveGitContentRoot(repoPath) {
|
|
48298
|
-
const contentPath =
|
|
48299
|
-
return
|
|
48475
|
+
const contentPath = path48.join(repoPath, "content");
|
|
48476
|
+
return fs43.existsSync(contentPath) && fs43.statSync(contentPath).isDirectory() ? contentPath : repoPath;
|
|
48300
48477
|
}
|
|
48301
48478
|
var WINDOWS_RESERVED_DEVICE_NAMES, pendingGitPaths;
|
|
48302
48479
|
var init_write_source = __esm(() => {
|
|
@@ -48357,8 +48534,8 @@ var init_installations = __esm(() => {
|
|
|
48357
48534
|
});
|
|
48358
48535
|
|
|
48359
48536
|
// src/indexer/walk/walker.ts
|
|
48360
|
-
import
|
|
48361
|
-
import
|
|
48537
|
+
import fs44 from "node:fs";
|
|
48538
|
+
import path49 from "node:path";
|
|
48362
48539
|
function isSkippedDir(name, options) {
|
|
48363
48540
|
return ALWAYS_SKIP_DIRS.has(name) || !options.includeAllDirectories && (AKM_SKIP_DIRS.has(name) || name.startsWith("."));
|
|
48364
48541
|
}
|
|
@@ -48373,7 +48550,7 @@ function walkStashFlat(stashRoot, options = {}) {
|
|
|
48373
48550
|
return walkStashFlatWithStatus(stashRoot, options).files;
|
|
48374
48551
|
}
|
|
48375
48552
|
function walkStashFlatWithStatus(stashRoot, options = {}) {
|
|
48376
|
-
if (!
|
|
48553
|
+
if (!fs44.existsSync(stashRoot))
|
|
48377
48554
|
return { files: [], complete: false };
|
|
48378
48555
|
const gitResult = walkStashGit(stashRoot, options);
|
|
48379
48556
|
if (gitResult)
|
|
@@ -48401,13 +48578,13 @@ function walkStashGit(stashRoot, options) {
|
|
|
48401
48578
|
ignoredStdout = Buffer.isBuffer(ignoredResult.stdout) ? ignoredResult.stdout.toString("utf8") : String(ignoredResult.stdout ?? "");
|
|
48402
48579
|
}
|
|
48403
48580
|
const stdout = Buffer.isBuffer(result.stdout) ? result.stdout.toString("utf8") : String(result.stdout ?? "");
|
|
48404
|
-
const files = [...stdout.split("\x00"), ...ignoredStdout.split("\x00")].filter((f2) => f2.length > 0).filter((f2) => !deletedFiles.has(f2)).filter((f2) => !f2.startsWith("..") && !
|
|
48581
|
+
const files = [...stdout.split("\x00"), ...ignoredStdout.split("\x00")].filter((f2) => f2.length > 0).filter((f2) => !deletedFiles.has(f2)).filter((f2) => !f2.startsWith("..") && !path49.isAbsolute(f2)).filter((f2) => !isExcludedPath(f2, options));
|
|
48405
48582
|
const results = [];
|
|
48406
48583
|
let complete = true;
|
|
48407
48584
|
for (const relFile of files) {
|
|
48408
|
-
const absPath =
|
|
48585
|
+
const absPath = path49.join(stashRoot, relFile);
|
|
48409
48586
|
try {
|
|
48410
|
-
const stat =
|
|
48587
|
+
const stat = fs44.lstatSync(absPath);
|
|
48411
48588
|
if (stat.isFile() || stat.isSymbolicLink() && isFileOrFileSymlink(absPath)) {
|
|
48412
48589
|
results.push(buildFileContext(stashRoot, absPath));
|
|
48413
48590
|
}
|
|
@@ -48418,16 +48595,16 @@ function walkStashGit(stashRoot, options) {
|
|
|
48418
48595
|
return { files: results, complete };
|
|
48419
48596
|
}
|
|
48420
48597
|
function isInsideGitRepo(dir) {
|
|
48421
|
-
let current =
|
|
48422
|
-
const root =
|
|
48598
|
+
let current = path49.resolve(dir);
|
|
48599
|
+
const root = path49.parse(current).root;
|
|
48423
48600
|
while (current !== root) {
|
|
48424
48601
|
try {
|
|
48425
|
-
const gitDir =
|
|
48426
|
-
const stat =
|
|
48602
|
+
const gitDir = path49.join(current, ".git");
|
|
48603
|
+
const stat = fs44.statSync(gitDir);
|
|
48427
48604
|
if (stat.isDirectory() || stat.isFile())
|
|
48428
48605
|
return true;
|
|
48429
48606
|
} catch {}
|
|
48430
|
-
const parent =
|
|
48607
|
+
const parent = path49.dirname(current);
|
|
48431
48608
|
if (parent === current)
|
|
48432
48609
|
break;
|
|
48433
48610
|
current = parent;
|
|
@@ -48444,14 +48621,14 @@ function walkStashManual(stashRoot, options) {
|
|
|
48444
48621
|
continue;
|
|
48445
48622
|
let entries;
|
|
48446
48623
|
try {
|
|
48447
|
-
entries =
|
|
48624
|
+
entries = fs44.readdirSync(current, { withFileTypes: true });
|
|
48448
48625
|
} catch {
|
|
48449
48626
|
complete = false;
|
|
48450
48627
|
continue;
|
|
48451
48628
|
}
|
|
48452
48629
|
for (const entry of entries) {
|
|
48453
|
-
const fullPath =
|
|
48454
|
-
if (isExcludedPath(
|
|
48630
|
+
const fullPath = path49.join(current, entry.name);
|
|
48631
|
+
if (isExcludedPath(path49.relative(stashRoot, fullPath), options))
|
|
48455
48632
|
continue;
|
|
48456
48633
|
if (entry.isSymbolicLink()) {
|
|
48457
48634
|
if (isFileOrFileSymlink(fullPath))
|
|
@@ -48471,7 +48648,7 @@ function walkStashManual(stashRoot, options) {
|
|
|
48471
48648
|
}
|
|
48472
48649
|
function isFileOrFileSymlink(filePath) {
|
|
48473
48650
|
try {
|
|
48474
|
-
return
|
|
48651
|
+
return fs44.statSync(filePath).isFile();
|
|
48475
48652
|
} catch {
|
|
48476
48653
|
return false;
|
|
48477
48654
|
}
|
|
@@ -48488,11 +48665,11 @@ var init_walker = __esm(() => {
|
|
|
48488
48665
|
});
|
|
48489
48666
|
|
|
48490
48667
|
// src/indexer/lookup/adapter-concept-owner.ts
|
|
48491
|
-
import
|
|
48492
|
-
import
|
|
48668
|
+
import fs45 from "node:fs";
|
|
48669
|
+
import path50 from "node:path";
|
|
48493
48670
|
function normalizedConceptId(conceptId) {
|
|
48494
48671
|
const normalized = conceptId.replaceAll("\\", "/");
|
|
48495
|
-
if (!normalized ||
|
|
48672
|
+
if (!normalized || path50.posix.isAbsolute(normalized) || normalized === ".." || normalized.startsWith("../") || path50.posix.normalize(normalized) !== normalized) {
|
|
48496
48673
|
return;
|
|
48497
48674
|
}
|
|
48498
48675
|
return normalized;
|
|
@@ -48501,36 +48678,36 @@ function componentFor(sourcePath, adapterId) {
|
|
|
48501
48678
|
return { id: adapterId, adapter: adapterId, root: sourcePath, writable: false };
|
|
48502
48679
|
}
|
|
48503
48680
|
function lexicallyWithin(candidate, root) {
|
|
48504
|
-
const relative =
|
|
48505
|
-
return relative === "" || !relative.startsWith(`..${
|
|
48681
|
+
const relative = path50.relative(path50.resolve(root), path50.resolve(candidate));
|
|
48682
|
+
return relative === "" || !relative.startsWith(`..${path50.sep}`) && relative !== ".." && !path50.isAbsolute(relative);
|
|
48506
48683
|
}
|
|
48507
48684
|
function candidateSpellings(candidate, sourcePath) {
|
|
48508
|
-
const authored =
|
|
48685
|
+
const authored = path50.resolve(candidate.path);
|
|
48509
48686
|
if (!lexicallyWithin(authored, sourcePath))
|
|
48510
48687
|
return [{ ...candidate, path: authored }];
|
|
48511
|
-
const parent =
|
|
48688
|
+
const parent = path50.dirname(authored);
|
|
48512
48689
|
let entries;
|
|
48513
48690
|
try {
|
|
48514
|
-
entries =
|
|
48691
|
+
entries = fs45.readdirSync(parent, { withFileTypes: true });
|
|
48515
48692
|
} catch {
|
|
48516
48693
|
return [{ ...candidate, path: authored }];
|
|
48517
48694
|
}
|
|
48518
|
-
const extension =
|
|
48695
|
+
const extension = path50.extname(authored);
|
|
48519
48696
|
if (!extension)
|
|
48520
48697
|
return [{ ...candidate, path: authored }];
|
|
48521
|
-
const stem =
|
|
48698
|
+
const stem = path50.basename(authored, extension);
|
|
48522
48699
|
return entries.filter((entry) => {
|
|
48523
|
-
const entryExtension =
|
|
48524
|
-
return
|
|
48525
|
-
}).map((entry) => ({ ...candidate, path:
|
|
48700
|
+
const entryExtension = path50.extname(entry.name);
|
|
48701
|
+
return path50.basename(entry.name, entryExtension) === stem && entryExtension.toLowerCase() === extension.toLowerCase();
|
|
48702
|
+
}).map((entry) => ({ ...candidate, path: path50.join(parent, entry.name) }));
|
|
48526
48703
|
}
|
|
48527
48704
|
function inspectCandidate(sourcePath, adapterId, candidate) {
|
|
48528
|
-
const authoredPath =
|
|
48705
|
+
const authoredPath = path50.resolve(candidate.path);
|
|
48529
48706
|
if (!lexicallyWithin(authoredPath, sourcePath))
|
|
48530
48707
|
return;
|
|
48531
48708
|
let authoredStat;
|
|
48532
48709
|
try {
|
|
48533
|
-
authoredStat =
|
|
48710
|
+
authoredStat = fs45.lstatSync(authoredPath);
|
|
48534
48711
|
} catch {
|
|
48535
48712
|
return;
|
|
48536
48713
|
}
|
|
@@ -48538,12 +48715,12 @@ function inspectCandidate(sourcePath, adapterId, candidate) {
|
|
|
48538
48715
|
return;
|
|
48539
48716
|
let realPath;
|
|
48540
48717
|
try {
|
|
48541
|
-
realPath =
|
|
48718
|
+
realPath = fs45.realpathSync(authoredPath);
|
|
48542
48719
|
} catch {
|
|
48543
48720
|
return;
|
|
48544
48721
|
}
|
|
48545
48722
|
try {
|
|
48546
|
-
if (!
|
|
48723
|
+
if (!fs45.statSync(realPath).isFile())
|
|
48547
48724
|
return;
|
|
48548
48725
|
} catch {
|
|
48549
48726
|
return;
|
|
@@ -48574,7 +48751,7 @@ function isMarkedSensitive(sourcePath, owner) {
|
|
|
48574
48751
|
if (type !== "env" && type !== "secret")
|
|
48575
48752
|
return false;
|
|
48576
48753
|
const marker = sensitiveMarkerPath(owner.path, type);
|
|
48577
|
-
return marker !== owner.path &&
|
|
48754
|
+
return marker !== owner.path && fs45.existsSync(marker);
|
|
48578
48755
|
}
|
|
48579
48756
|
function resolveAdapterConceptOwner(sourcePath, adapterId, conceptId, options) {
|
|
48580
48757
|
const adapter = adapterForId(adapterId);
|
|
@@ -48582,7 +48759,7 @@ function resolveAdapterConceptOwner(sourcePath, adapterId, conceptId, options) {
|
|
|
48582
48759
|
if (!adapter || !normalized)
|
|
48583
48760
|
return;
|
|
48584
48761
|
try {
|
|
48585
|
-
|
|
48762
|
+
fs45.realpathSync(sourcePath);
|
|
48586
48763
|
} catch (error62) {
|
|
48587
48764
|
if (hasErrnoCode(error62, "ENOENT"))
|
|
48588
48765
|
return;
|
|
@@ -48600,11 +48777,11 @@ function resolveAdapterConceptOwner(sourcePath, adapterId, conceptId, options) {
|
|
|
48600
48777
|
adapterId,
|
|
48601
48778
|
workflowSource
|
|
48602
48779
|
};
|
|
48603
|
-
ownersByIdentity.set(`${
|
|
48780
|
+
ownersByIdentity.set(`${path50.resolve(workflowOwner.path)}\x00${resolutionConceptId}`, workflowOwner);
|
|
48604
48781
|
}
|
|
48605
48782
|
const spellings = (adapter.readCandidates?.(component, resolutionConceptId) ?? []).flatMap((candidate) => candidateSpellings(candidate, sourcePath));
|
|
48606
48783
|
const inspected = [
|
|
48607
|
-
...new Map(spellings.map((candidate) => [`${
|
|
48784
|
+
...new Map(spellings.map((candidate) => [`${path50.resolve(candidate.path)}\x00${candidate.conceptId}`, candidate])).values()
|
|
48608
48785
|
].sort((left, right) => compareCodePoints(left.path, right.path)).flatMap((candidate) => {
|
|
48609
48786
|
const owner = inspectCandidate(sourcePath, adapterId, candidate);
|
|
48610
48787
|
return owner ? [owner] : [];
|
|
@@ -48612,7 +48789,7 @@ function resolveAdapterConceptOwner(sourcePath, adapterId, conceptId, options) {
|
|
|
48612
48789
|
for (const candidate of inspected) {
|
|
48613
48790
|
if (candidate.conceptId !== resolutionConceptId)
|
|
48614
48791
|
continue;
|
|
48615
|
-
const identity3 = `${
|
|
48792
|
+
const identity3 = `${path50.resolve(candidate.path)}\x00${candidate.conceptId}`;
|
|
48616
48793
|
if (ownersByIdentity.has(identity3))
|
|
48617
48794
|
continue;
|
|
48618
48795
|
if (claimsWithoutContent(adapter, component, candidate) || options?.includeSensitive && isMarkedSensitive(sourcePath, candidate)) {
|
|
@@ -48622,10 +48799,10 @@ function resolveAdapterConceptOwner(sourcePath, adapterId, conceptId, options) {
|
|
|
48622
48799
|
const owners = [...ownersByIdentity.values()].filter((owner) => owner.conceptId === resolutionConceptId).sort((left, right) => compareCodePoints(left.path, right.path));
|
|
48623
48800
|
if (owners.length > 1) {
|
|
48624
48801
|
if (options?.mode !== "read") {
|
|
48625
|
-
throw new AdapterConceptCollisionError(adapterId, resolutionConceptId, owners.map((owner) =>
|
|
48802
|
+
throw new AdapterConceptCollisionError(adapterId, resolutionConceptId, owners.map((owner) => path50.relative(sourcePath, owner.path).replaceAll("\\", "/")));
|
|
48626
48803
|
}
|
|
48627
48804
|
const [winner, ...losers] = owners;
|
|
48628
|
-
warnOnce(`adapter-concept-collision:${adapterId}:${resolutionConceptId}`, `Adapter "${adapterId}" has multiple physical owners for "${resolutionConceptId}": ` + `${owners.map((owner) =>
|
|
48805
|
+
warnOnce(`adapter-concept-collision:${adapterId}:${resolutionConceptId}`, `Adapter "${adapterId}" has multiple physical owners for "${resolutionConceptId}": ` + `${owners.map((owner) => path50.relative(sourcePath, owner.path).replaceAll("\\", "/")).join(", ")}. ` + `Reading "${path50.relative(sourcePath, winner.path).replaceAll("\\", "/")}" and ignoring ` + `${losers.map((owner) => path50.relative(sourcePath, owner.path).replaceAll("\\", "/")).join(", ")}.`);
|
|
48629
48806
|
return winner;
|
|
48630
48807
|
}
|
|
48631
48808
|
return owners[0];
|
|
@@ -48716,21 +48893,21 @@ var init_filesystem = __esm(() => {
|
|
|
48716
48893
|
|
|
48717
48894
|
// src/sources/providers/tar-utils.ts
|
|
48718
48895
|
import { createHash as createHash5 } from "node:crypto";
|
|
48719
|
-
import
|
|
48720
|
-
import
|
|
48896
|
+
import fs46 from "node:fs";
|
|
48897
|
+
import path51 from "node:path";
|
|
48721
48898
|
function verifyArchiveIntegrity(archivePath, expected, source) {
|
|
48722
48899
|
if (!expected)
|
|
48723
48900
|
return;
|
|
48724
48901
|
if (source === "github" || source === "git")
|
|
48725
48902
|
return;
|
|
48726
|
-
const fileBuffer =
|
|
48903
|
+
const fileBuffer = fs46.readFileSync(archivePath);
|
|
48727
48904
|
if (expected.startsWith("sha256-") || expected.startsWith("sha512-")) {
|
|
48728
48905
|
const dashIndex = expected.indexOf("-");
|
|
48729
48906
|
const algorithm = expected.slice(0, dashIndex);
|
|
48730
48907
|
const expectedBase64 = expected.slice(dashIndex + 1);
|
|
48731
48908
|
const actualBase64 = createHash5(algorithm).update(fileBuffer).digest("base64");
|
|
48732
48909
|
if (actualBase64 !== expectedBase64) {
|
|
48733
|
-
|
|
48910
|
+
fs46.unlinkSync(archivePath);
|
|
48734
48911
|
throw new Error(`Integrity check failed for ${archivePath}: expected ${algorithm} digest ${expectedBase64}, got ${actualBase64}`);
|
|
48735
48912
|
}
|
|
48736
48913
|
return;
|
|
@@ -48738,7 +48915,7 @@ function verifyArchiveIntegrity(archivePath, expected, source) {
|
|
|
48738
48915
|
if (/^[0-9a-f]{40}$/i.test(expected)) {
|
|
48739
48916
|
const actualHex = createHash5("sha1").update(fileBuffer).digest("hex");
|
|
48740
48917
|
if (actualHex.toLowerCase() !== expected.toLowerCase()) {
|
|
48741
|
-
|
|
48918
|
+
fs46.unlinkSync(archivePath);
|
|
48742
48919
|
throw new Error(`Integrity check failed for ${archivePath}: expected sha1 ${expected}, got ${actualHex}`);
|
|
48743
48920
|
}
|
|
48744
48921
|
return;
|
|
@@ -48752,8 +48929,8 @@ function extractTarGzSecure(archivePath, destinationDir) {
|
|
|
48752
48929
|
throw new Error(`Failed to inspect archive ${archivePath}: ${err}`);
|
|
48753
48930
|
}
|
|
48754
48931
|
validateTarEntries(listResult.stdout.toString());
|
|
48755
|
-
|
|
48756
|
-
|
|
48932
|
+
fs46.rmSync(destinationDir, { recursive: true, force: true });
|
|
48933
|
+
fs46.mkdirSync(destinationDir, { recursive: true });
|
|
48757
48934
|
const extractResult = spawnSync([
|
|
48758
48935
|
"tar",
|
|
48759
48936
|
"xzf",
|
|
@@ -48770,20 +48947,20 @@ function extractTarGzSecure(archivePath, destinationDir) {
|
|
|
48770
48947
|
scanExtractedFiles(destinationDir, destinationDir);
|
|
48771
48948
|
}
|
|
48772
48949
|
function scanExtractedFiles(dir, root) {
|
|
48773
|
-
const entries =
|
|
48950
|
+
const entries = fs46.readdirSync(dir, { withFileTypes: true });
|
|
48774
48951
|
for (const entry of entries) {
|
|
48775
|
-
const fullPath =
|
|
48952
|
+
const fullPath = path51.join(dir, entry.name);
|
|
48776
48953
|
if (entry.name === ".." || entry.name === ".") {
|
|
48777
48954
|
throw new Error(`Post-extraction scan: suspicious entry name: ${fullPath}`);
|
|
48778
48955
|
}
|
|
48779
48956
|
if (entry.isSymbolicLink()) {
|
|
48780
|
-
const target =
|
|
48957
|
+
const target = fs46.realpathSync(fullPath);
|
|
48781
48958
|
if (!isWithin(target, root)) {
|
|
48782
48959
|
throw new Error(`Post-extraction scan: symlink escapes destination directory: ${fullPath} -> ${target}`);
|
|
48783
48960
|
}
|
|
48784
48961
|
}
|
|
48785
48962
|
if (!entry.isSymbolicLink()) {
|
|
48786
|
-
const resolved =
|
|
48963
|
+
const resolved = path51.resolve(fullPath);
|
|
48787
48964
|
if (!isWithin(resolved, root)) {
|
|
48788
48965
|
throw new Error(`Post-extraction scan: entry escapes destination directory: ${fullPath}`);
|
|
48789
48966
|
}
|
|
@@ -48803,7 +48980,7 @@ function validateTarEntries(listOutput) {
|
|
|
48803
48980
|
if (entry.startsWith("/")) {
|
|
48804
48981
|
throw new Error(`Archive contains an absolute path entry: ${entry}`);
|
|
48805
48982
|
}
|
|
48806
|
-
const normalized =
|
|
48983
|
+
const normalized = path51.posix.normalize(entry);
|
|
48807
48984
|
if (normalized === ".." || normalized.startsWith("../")) {
|
|
48808
48985
|
throw new Error(`Archive contains a path traversal entry: ${entry}`);
|
|
48809
48986
|
}
|
|
@@ -48811,8 +48988,8 @@ function validateTarEntries(listOutput) {
|
|
|
48811
48988
|
const stripped = parts.slice(1).join("/");
|
|
48812
48989
|
if (!stripped)
|
|
48813
48990
|
continue;
|
|
48814
|
-
const normalizedStripped =
|
|
48815
|
-
if (normalizedStripped === ".." || normalizedStripped.startsWith("../") ||
|
|
48991
|
+
const normalizedStripped = path51.posix.normalize(stripped);
|
|
48992
|
+
if (normalizedStripped === ".." || normalizedStripped.startsWith("../") || path51.posix.isAbsolute(normalizedStripped)) {
|
|
48816
48993
|
throw new Error(`Archive contains an unsafe entry after strip-components: ${entry}`);
|
|
48817
48994
|
}
|
|
48818
48995
|
}
|
|
@@ -48824,8 +49001,8 @@ var init_tar_utils = __esm(() => {
|
|
|
48824
49001
|
});
|
|
48825
49002
|
|
|
48826
49003
|
// src/sources/providers/npm.ts
|
|
48827
|
-
import
|
|
48828
|
-
import
|
|
49004
|
+
import fs47 from "node:fs";
|
|
49005
|
+
import path52 from "node:path";
|
|
48829
49006
|
|
|
48830
49007
|
class NpmSourceProvider {
|
|
48831
49008
|
kind = "npm";
|
|
@@ -48864,13 +49041,13 @@ async function doSyncNpm(parsed, options) {
|
|
|
48864
49041
|
const syncedAt = (options?.now ?? new Date).toISOString();
|
|
48865
49042
|
const cacheRootDir = options?.cacheRootDir ?? getRegistryCacheDir();
|
|
48866
49043
|
const cacheDir = buildInstallCacheDir(cacheRootDir, resolved.source, resolved.id, resolved.resolvedVersion ?? resolved.resolvedRevision);
|
|
48867
|
-
const archivePath =
|
|
48868
|
-
const extractedDir =
|
|
49044
|
+
const archivePath = path52.join(cacheDir, "artifact.tar.gz");
|
|
49045
|
+
const extractedDir = path52.join(cacheDir, "extracted");
|
|
48869
49046
|
if (!options?.force && isDirectory(extractedDir)) {
|
|
48870
49047
|
try {
|
|
48871
49048
|
const cachedStashRoot = detectStashRoot(extractedDir);
|
|
48872
49049
|
if (cachedStashRoot) {
|
|
48873
|
-
const integrity2 =
|
|
49050
|
+
const integrity2 = fs47.existsSync(archivePath) ? await computeFileHash(archivePath) : undefined;
|
|
48874
49051
|
return {
|
|
48875
49052
|
id: resolved.id,
|
|
48876
49053
|
source: resolved.source,
|
|
@@ -48888,7 +49065,7 @@ async function doSyncNpm(parsed, options) {
|
|
|
48888
49065
|
}
|
|
48889
49066
|
} catch {}
|
|
48890
49067
|
}
|
|
48891
|
-
|
|
49068
|
+
fs47.mkdirSync(cacheDir, { recursive: true });
|
|
48892
49069
|
let integrity;
|
|
48893
49070
|
let provisionalBundleRoot;
|
|
48894
49071
|
let installRoot;
|
|
@@ -48911,7 +49088,7 @@ async function doSyncNpm(parsed, options) {
|
|
|
48911
49088
|
stashRoot = detectedStashRoot;
|
|
48912
49089
|
} catch (err) {
|
|
48913
49090
|
try {
|
|
48914
|
-
|
|
49091
|
+
fs47.rmSync(cacheDir, { recursive: true, force: true });
|
|
48915
49092
|
} catch {}
|
|
48916
49093
|
throw err;
|
|
48917
49094
|
}
|
|
@@ -49099,7 +49276,7 @@ var init_host_guard = __esm(() => {
|
|
|
49099
49276
|
|
|
49100
49277
|
// src/sources/website-url.ts
|
|
49101
49278
|
import { createHash as createHash6 } from "node:crypto";
|
|
49102
|
-
import
|
|
49279
|
+
import path53 from "node:path";
|
|
49103
49280
|
function shouldAllowPrivateWebsiteHostsForTests() {
|
|
49104
49281
|
return process.env.BUN_TEST === "1" || false;
|
|
49105
49282
|
}
|
|
@@ -49119,11 +49296,11 @@ function shouldAllowPrivateWebsiteUrlForTests(rawUrl) {
|
|
|
49119
49296
|
}
|
|
49120
49297
|
function getWebsiteCachePaths(siteUrl) {
|
|
49121
49298
|
const key = createHash6("sha256").update(normalizeSiteUrl(siteUrl)).digest("hex").slice(0, 16);
|
|
49122
|
-
const rootDir =
|
|
49299
|
+
const rootDir = path53.join(getRegistryIndexCacheDir(), `website-${key}`);
|
|
49123
49300
|
return {
|
|
49124
49301
|
rootDir,
|
|
49125
|
-
stashDir:
|
|
49126
|
-
manifestPath:
|
|
49302
|
+
stashDir: path53.join(rootDir, "stash"),
|
|
49303
|
+
manifestPath: path53.join(rootDir, "manifest.json")
|
|
49127
49304
|
};
|
|
49128
49305
|
}
|
|
49129
49306
|
function validateWebsiteUrl(rawUrl, options) {
|
|
@@ -52933,16 +53110,16 @@ var require_CharacterData = __commonJS((exports, module) => {
|
|
|
52933
53110
|
Leaf.call(this);
|
|
52934
53111
|
}
|
|
52935
53112
|
CharacterData.prototype = Object.create(Leaf.prototype, {
|
|
52936
|
-
substringData: { value: function substringData(offset,
|
|
53113
|
+
substringData: { value: function substringData(offset, count2) {
|
|
52937
53114
|
if (arguments.length < 2) {
|
|
52938
53115
|
throw new TypeError("Not enough arguments");
|
|
52939
53116
|
}
|
|
52940
53117
|
offset = offset >>> 0;
|
|
52941
|
-
|
|
52942
|
-
if (offset > this.data.length || offset < 0 ||
|
|
53118
|
+
count2 = count2 >>> 0;
|
|
53119
|
+
if (offset > this.data.length || offset < 0 || count2 < 0) {
|
|
52943
53120
|
utils.IndexSizeError();
|
|
52944
53121
|
}
|
|
52945
|
-
return this.data.substring(offset, offset +
|
|
53122
|
+
return this.data.substring(offset, offset + count2);
|
|
52946
53123
|
} },
|
|
52947
53124
|
appendData: { value: function appendData(data) {
|
|
52948
53125
|
if (arguments.length < 1) {
|
|
@@ -52953,19 +53130,19 @@ var require_CharacterData = __commonJS((exports, module) => {
|
|
|
52953
53130
|
insertData: { value: function insertData(offset, data) {
|
|
52954
53131
|
return this.replaceData(offset, 0, data);
|
|
52955
53132
|
} },
|
|
52956
|
-
deleteData: { value: function deleteData(offset,
|
|
52957
|
-
return this.replaceData(offset,
|
|
53133
|
+
deleteData: { value: function deleteData(offset, count2) {
|
|
53134
|
+
return this.replaceData(offset, count2, "");
|
|
52958
53135
|
} },
|
|
52959
|
-
replaceData: { value: function replaceData(offset,
|
|
53136
|
+
replaceData: { value: function replaceData(offset, count2, data) {
|
|
52960
53137
|
var curtext = this.data, len = curtext.length;
|
|
52961
53138
|
offset = offset >>> 0;
|
|
52962
|
-
|
|
53139
|
+
count2 = count2 >>> 0;
|
|
52963
53140
|
data = String(data);
|
|
52964
53141
|
if (offset > len || offset < 0)
|
|
52965
53142
|
utils.IndexSizeError();
|
|
52966
|
-
if (offset +
|
|
52967
|
-
|
|
52968
|
-
var prefix = curtext.substring(0, offset), suffix = curtext.substring(offset +
|
|
53143
|
+
if (offset + count2 > len)
|
|
53144
|
+
count2 = len - offset;
|
|
53145
|
+
var prefix = curtext.substring(0, offset), suffix = curtext.substring(offset + count2);
|
|
52969
53146
|
this.data = prefix + data + suffix;
|
|
52970
53147
|
} },
|
|
52971
53148
|
isEqual: { value: function isEqual(n) {
|
|
@@ -53794,33 +53971,33 @@ var require_URL = __commonJS((exports, module) => {
|
|
|
53794
53971
|
else
|
|
53795
53972
|
return basepath.substring(0, lastslash + 1) + refpath;
|
|
53796
53973
|
}
|
|
53797
|
-
function remove_dot_segments(
|
|
53798
|
-
if (!
|
|
53799
|
-
return
|
|
53974
|
+
function remove_dot_segments(path54) {
|
|
53975
|
+
if (!path54)
|
|
53976
|
+
return path54;
|
|
53800
53977
|
var output2 = "";
|
|
53801
|
-
while (
|
|
53802
|
-
if (
|
|
53803
|
-
|
|
53978
|
+
while (path54.length > 0) {
|
|
53979
|
+
if (path54 === "." || path54 === "..") {
|
|
53980
|
+
path54 = "";
|
|
53804
53981
|
break;
|
|
53805
53982
|
}
|
|
53806
|
-
var twochars =
|
|
53807
|
-
var threechars =
|
|
53808
|
-
var fourchars =
|
|
53983
|
+
var twochars = path54.substring(0, 2);
|
|
53984
|
+
var threechars = path54.substring(0, 3);
|
|
53985
|
+
var fourchars = path54.substring(0, 4);
|
|
53809
53986
|
if (threechars === "../") {
|
|
53810
|
-
|
|
53987
|
+
path54 = path54.substring(3);
|
|
53811
53988
|
} else if (twochars === "./") {
|
|
53812
|
-
|
|
53989
|
+
path54 = path54.substring(2);
|
|
53813
53990
|
} else if (threechars === "/./") {
|
|
53814
|
-
|
|
53815
|
-
} else if (twochars === "/." &&
|
|
53816
|
-
|
|
53817
|
-
} else if (fourchars === "/../" || threechars === "/.." &&
|
|
53818
|
-
|
|
53991
|
+
path54 = "/" + path54.substring(3);
|
|
53992
|
+
} else if (twochars === "/." && path54.length === 2) {
|
|
53993
|
+
path54 = "/";
|
|
53994
|
+
} else if (fourchars === "/../" || threechars === "/.." && path54.length === 3) {
|
|
53995
|
+
path54 = "/" + path54.substring(4);
|
|
53819
53996
|
output2 = output2.replace(/\/?[^\/]*$/, "");
|
|
53820
53997
|
} else {
|
|
53821
|
-
var segment =
|
|
53998
|
+
var segment = path54.match(/(\/?([^\/]*))/)[0];
|
|
53822
53999
|
output2 += segment;
|
|
53823
|
-
|
|
54000
|
+
path54 = path54.substring(segment.length);
|
|
53824
54001
|
}
|
|
53825
54002
|
}
|
|
53826
54003
|
return output2;
|
|
@@ -59632,13 +59809,13 @@ var require_HTMLParser = __commonJS((exports, module) => {
|
|
|
59632
59809
|
this.attrs.push(this.MARKER);
|
|
59633
59810
|
};
|
|
59634
59811
|
HTMLParser.ActiveFormattingElements.prototype.push = function(elt, attrs) {
|
|
59635
|
-
var
|
|
59812
|
+
var count2 = 0;
|
|
59636
59813
|
for (var i = this.list.length - 1;i >= 0; i--) {
|
|
59637
59814
|
if (this.list[i] === this.MARKER)
|
|
59638
59815
|
break;
|
|
59639
59816
|
if (equal(elt, this.list[i], this.attrs[i])) {
|
|
59640
|
-
|
|
59641
|
-
if (
|
|
59817
|
+
count2++;
|
|
59818
|
+
if (count2 === 3) {
|
|
59642
59819
|
this.list.splice(i, 1);
|
|
59643
59820
|
this.attrs.splice(i, 1);
|
|
59644
59821
|
break;
|
|
@@ -65074,8 +65251,8 @@ var require_turndown_cjs = __commonJS((exports, module) => {
|
|
|
65074
65251
|
}
|
|
65075
65252
|
return destination;
|
|
65076
65253
|
}
|
|
65077
|
-
function repeat(character,
|
|
65078
|
-
return Array(
|
|
65254
|
+
function repeat(character, count2) {
|
|
65255
|
+
return Array(count2 + 1).join(character);
|
|
65079
65256
|
}
|
|
65080
65257
|
function trimLeadingNewlines(string4) {
|
|
65081
65258
|
return string4.replace(/^\n*/, "");
|
|
@@ -66105,9 +66282,9 @@ function validateAmpersand(xmlData, i) {
|
|
|
66105
66282
|
i++;
|
|
66106
66283
|
return validateNumberAmpersand(xmlData, i);
|
|
66107
66284
|
}
|
|
66108
|
-
let
|
|
66109
|
-
for (;i < xmlData.length; i++,
|
|
66110
|
-
if (xmlData[i].match(/\w/) &&
|
|
66285
|
+
let count2 = 0;
|
|
66286
|
+
for (;i < xmlData.length; i++, count2++) {
|
|
66287
|
+
if (xmlData[i].match(/\w/) && count2 < 20)
|
|
66111
66288
|
continue;
|
|
66112
66289
|
if (xmlData[i] === ";")
|
|
66113
66290
|
break;
|
|
@@ -67546,24 +67723,24 @@ class MatcherView {
|
|
|
67546
67723
|
return this._matcher.separator;
|
|
67547
67724
|
}
|
|
67548
67725
|
getCurrentTag() {
|
|
67549
|
-
const
|
|
67550
|
-
return
|
|
67726
|
+
const path54 = this._matcher.path;
|
|
67727
|
+
return path54.length > 0 ? path54[path54.length - 1].tag : undefined;
|
|
67551
67728
|
}
|
|
67552
67729
|
getCurrentNamespace() {
|
|
67553
|
-
const
|
|
67554
|
-
return
|
|
67730
|
+
const path54 = this._matcher.path;
|
|
67731
|
+
return path54.length > 0 ? path54[path54.length - 1].namespace : undefined;
|
|
67555
67732
|
}
|
|
67556
67733
|
getAttrValue(attrName) {
|
|
67557
|
-
const
|
|
67558
|
-
if (
|
|
67734
|
+
const path54 = this._matcher.path;
|
|
67735
|
+
if (path54.length === 0)
|
|
67559
67736
|
return;
|
|
67560
|
-
return
|
|
67737
|
+
return path54[path54.length - 1].values?.[attrName];
|
|
67561
67738
|
}
|
|
67562
67739
|
hasAttr(attrName) {
|
|
67563
|
-
const
|
|
67564
|
-
if (
|
|
67740
|
+
const path54 = this._matcher.path;
|
|
67741
|
+
if (path54.length === 0)
|
|
67565
67742
|
return false;
|
|
67566
|
-
const current =
|
|
67743
|
+
const current = path54[path54.length - 1];
|
|
67567
67744
|
return current.values !== undefined && attrName in current.values;
|
|
67568
67745
|
}
|
|
67569
67746
|
getAnyParentAttr(attrName) {
|
|
@@ -67573,16 +67750,16 @@ class MatcherView {
|
|
|
67573
67750
|
return this._matcher.hasAnyParentAttr(attrName);
|
|
67574
67751
|
}
|
|
67575
67752
|
getPosition() {
|
|
67576
|
-
const
|
|
67577
|
-
if (
|
|
67753
|
+
const path54 = this._matcher.path;
|
|
67754
|
+
if (path54.length === 0)
|
|
67578
67755
|
return -1;
|
|
67579
|
-
return
|
|
67756
|
+
return path54[path54.length - 1].position ?? 0;
|
|
67580
67757
|
}
|
|
67581
67758
|
getCounter() {
|
|
67582
|
-
const
|
|
67583
|
-
if (
|
|
67759
|
+
const path54 = this._matcher.path;
|
|
67760
|
+
if (path54.length === 0)
|
|
67584
67761
|
return -1;
|
|
67585
|
-
return
|
|
67762
|
+
return path54[path54.length - 1].counter ?? 0;
|
|
67586
67763
|
}
|
|
67587
67764
|
getIndex() {
|
|
67588
67765
|
return this.getPosition();
|
|
@@ -69487,7 +69664,7 @@ var init_youtube = __esm(() => {
|
|
|
69487
69664
|
});
|
|
69488
69665
|
|
|
69489
69666
|
// src/sources/snapshot-fetchers/registry.ts
|
|
69490
|
-
import
|
|
69667
|
+
import path54 from "node:path";
|
|
69491
69668
|
var FETCHER_DIR;
|
|
69492
69669
|
var init_registry2 = __esm(() => {
|
|
69493
69670
|
init_warn();
|
|
@@ -69496,7 +69673,7 @@ var init_registry2 = __esm(() => {
|
|
|
69496
69673
|
init_rss();
|
|
69497
69674
|
init_x();
|
|
69498
69675
|
init_youtube();
|
|
69499
|
-
FETCHER_DIR =
|
|
69676
|
+
FETCHER_DIR = path54.join("scripts", "wiki-fetchers");
|
|
69500
69677
|
});
|
|
69501
69678
|
|
|
69502
69679
|
// src/sources/snapshot-fetchers/robots.ts
|
|
@@ -69540,10 +69717,10 @@ var init_website_ingest = __esm(() => {
|
|
|
69540
69717
|
});
|
|
69541
69718
|
|
|
69542
69719
|
// src/indexer/search/search-source.ts
|
|
69543
|
-
import
|
|
69720
|
+
import path55 from "node:path";
|
|
69544
69721
|
function implicitStashDir(config2, overrideStashDir) {
|
|
69545
69722
|
if (overrideStashDir !== undefined)
|
|
69546
|
-
return
|
|
69723
|
+
return path55.resolve(overrideStashDir);
|
|
69547
69724
|
if (process.env.AKM_BUNDLE_DIR?.trim())
|
|
69548
69725
|
return resolveStashDir();
|
|
69549
69726
|
return config2.defaultBundle ? undefined : resolveStashDir();
|
|
@@ -69559,7 +69736,7 @@ function resolveSourceEntries(overrideStashDir, existingConfig) {
|
|
|
69559
69736
|
const sources = implicitStash ? [{ path: safeRealpath(implicitStash), writable: true, isDefault: true, type: "filesystem" }] : [];
|
|
69560
69737
|
const seen = new Set(implicitStash ? [safeRealpath(implicitStash)] : []);
|
|
69561
69738
|
const addSource = (dir, registryId, writable, type, adapterId, unresolved = false, isDefault = false) => {
|
|
69562
|
-
const resolved =
|
|
69739
|
+
const resolved = path55.resolve(dir);
|
|
69563
69740
|
const identity3 = safeRealpath(resolved);
|
|
69564
69741
|
if (seen.has(identity3)) {
|
|
69565
69742
|
const existing = sources.find((source) => safeRealpath(source.path) === identity3);
|
|
@@ -69596,14 +69773,14 @@ function resolveSourceEntries(overrideStashDir, existingConfig) {
|
|
|
69596
69773
|
const component = bundleComponentConfig(config2.bundles?.[entry.name ?? ""]);
|
|
69597
69774
|
const contentRoot = resolveEntryContentDir(entry);
|
|
69598
69775
|
if (contentRoot == null) {
|
|
69599
|
-
const unresolvedPath =
|
|
69776
|
+
const unresolvedPath = path55.join(getUnresolvedSourcesDir(implicitStash ?? process.cwd()), entry.name ?? entry.type);
|
|
69600
69777
|
addSource(unresolvedPath, entry.name, component?.writable ?? resolveWritable(entry), entry.type, component?.adapter, true, entry.name === config2.defaultBundle);
|
|
69601
69778
|
continue;
|
|
69602
69779
|
}
|
|
69603
|
-
const dir =
|
|
69780
|
+
const dir = path55.resolve(contentRoot, component?.root ?? ".");
|
|
69604
69781
|
if (!isWithin(dir, contentRoot)) {
|
|
69605
69782
|
warn(`Warning: component root "${component?.root}" escapes bundle "${entry.name}"; skipping source.`);
|
|
69606
|
-
const unresolvedPath =
|
|
69783
|
+
const unresolvedPath = path55.join(getUnresolvedSourcesDir(contentRoot), entry.name ?? entry.type);
|
|
69607
69784
|
addSource(unresolvedPath, entry.name, component?.writable ?? resolveWritable(entry), entry.type, component?.adapter, true, entry.name === config2.defaultBundle);
|
|
69608
69785
|
continue;
|
|
69609
69786
|
}
|
|
@@ -69638,13 +69815,13 @@ function resolveEntryContentDir(entry) {
|
|
|
69638
69815
|
return dir;
|
|
69639
69816
|
}
|
|
69640
69817
|
function isSuspiciousStashRoot(dir) {
|
|
69641
|
-
const resolved =
|
|
69818
|
+
const resolved = path55.resolve(dir);
|
|
69642
69819
|
const normalized = process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
69643
69820
|
if (SUSPICIOUS_ROOTS.has(normalized))
|
|
69644
69821
|
return true;
|
|
69645
69822
|
if (process.platform === "win32") {
|
|
69646
69823
|
const winDir = (process.env.SystemRoot || "C:\\Windows").toLowerCase();
|
|
69647
|
-
if (normalized === winDir || normalized.startsWith(winDir +
|
|
69824
|
+
if (normalized === winDir || normalized.startsWith(winDir + path55.sep))
|
|
69648
69825
|
return true;
|
|
69649
69826
|
}
|
|
69650
69827
|
return false;
|
|
@@ -69738,9 +69915,9 @@ var init_env_secret_ref = __esm(() => {
|
|
|
69738
69915
|
});
|
|
69739
69916
|
|
|
69740
69917
|
// src/core/secret-value.ts
|
|
69741
|
-
import
|
|
69918
|
+
import fs48 from "node:fs";
|
|
69742
69919
|
function readValue(secretPath) {
|
|
69743
|
-
return
|
|
69920
|
+
return fs48.readFileSync(secretPath, "utf8").trim();
|
|
69744
69921
|
}
|
|
69745
69922
|
var init_secret_value = () => {};
|
|
69746
69923
|
|
|
@@ -70337,6 +70514,7 @@ function makeStampHandler(command) {
|
|
|
70337
70514
|
var PASSTHROUGH_COMMANDS = [
|
|
70338
70515
|
"add",
|
|
70339
70516
|
"agent-result",
|
|
70517
|
+
"backups-prune",
|
|
70340
70518
|
"bundle-create",
|
|
70341
70519
|
"bundle-rename",
|
|
70342
70520
|
"bundle-show",
|
|
@@ -71355,6 +71533,82 @@ function renderIssueSection(title, issues) {
|
|
|
71355
71533
|
return [`${title}: (none)`];
|
|
71356
71534
|
return [`${title} (${issues.length})`, ...renderStatusEntries(issues.map(issueEntry))];
|
|
71357
71535
|
}
|
|
71536
|
+
var RULE_HELP = {
|
|
71537
|
+
"unquoted-colon": { fix: true, how: "quote the description value" },
|
|
71538
|
+
"missing-updated": { fix: true, how: "add `updated: YYYY-MM-DD` to the frontmatter" },
|
|
71539
|
+
"orphaned-stub": { fix: true, how: "write the stub's derived file or delete the stub" },
|
|
71540
|
+
"placeholder-stub": { fix: true, how: "replace the placeholder text or delete the file" },
|
|
71541
|
+
"missing-name-or-type": { fix: false, how: "add the missing `name` or `type` to the frontmatter" },
|
|
71542
|
+
"missing-type": { fix: false, how: "add `type` to the frontmatter" },
|
|
71543
|
+
"stale-path": {
|
|
71544
|
+
fix: false,
|
|
71545
|
+
how: 'correct the path; if the line records the past or an example, say so on the line ("formerly", "for example") or put it under a History/Examples heading'
|
|
71546
|
+
},
|
|
71547
|
+
"missing-skill-md": { fix: false, how: "add a SKILL.md to the skill directory" },
|
|
71548
|
+
"invalid-task-yaml": { fix: false, how: "use the .yml extension and valid task YAML" },
|
|
71549
|
+
"missing-ref": { fix: false, how: "correct the ref or create the asset it names" },
|
|
71550
|
+
"redacted-content": { fix: false, how: "restore the original text from version history" },
|
|
71551
|
+
"dangerous-env-key": { fix: false, how: "remove the key from the env file" },
|
|
71552
|
+
"tracked-secrets": {
|
|
71553
|
+
fix: false,
|
|
71554
|
+
how: "`git rm --cached` the file, or list its path under `lint.skip.tracked-secrets`"
|
|
71555
|
+
},
|
|
71556
|
+
"missing-category": { fix: false, how: "add the fact's `category`" },
|
|
71557
|
+
"invalid-workflow-structure": { fix: false, how: "correct the workflow as the detail says" }
|
|
71558
|
+
};
|
|
71559
|
+
function topFolders(files) {
|
|
71560
|
+
const counts = new Map;
|
|
71561
|
+
for (const file of files) {
|
|
71562
|
+
const folder = file.split(/[\\/]/).slice(0, -1).slice(0, 2).join("/") || ".";
|
|
71563
|
+
counts.set(folder, (counts.get(folder) ?? 0) + 1);
|
|
71564
|
+
}
|
|
71565
|
+
return [...counts].sort((a, b) => b[1] - a[1]).slice(0, 3).map(([folder, count]) => `${folder} (${count})`).join(", ");
|
|
71566
|
+
}
|
|
71567
|
+
var count = (n, noun) => `${n} ${noun}${n === 1 ? "" : "s"}`;
|
|
71568
|
+
function renderRuleSummary(flagged, byRule) {
|
|
71569
|
+
if (flagged.length === 0)
|
|
71570
|
+
return ["flagged: (none)"];
|
|
71571
|
+
const rules = Object.entries(byRule).sort((a, b) => b[1].findings - a[1].findings);
|
|
71572
|
+
return [
|
|
71573
|
+
`flagged (${flagged.length}); list one rule with \`akm lint --rule <rule>\``,
|
|
71574
|
+
...rules.map(([rule, { findings, assets }]) => {
|
|
71575
|
+
const help = RULE_HELP[rule];
|
|
71576
|
+
const folders = topFolders(flagged.filter((issue) => issue.issue === rule).map((issue) => issue.file));
|
|
71577
|
+
return ` ${rule}: ${count(findings, "finding")} in ${count(assets, "asset")}; ${folders}; ` + `--fix ${help?.fix ? "fixes it" : "does not fix it"}; ${help?.how ?? "see the detail with --rule"}`;
|
|
71578
|
+
})
|
|
71579
|
+
];
|
|
71580
|
+
}
|
|
71581
|
+
function excerpt(lineText, path5) {
|
|
71582
|
+
if (lineText.length <= 200)
|
|
71583
|
+
return lineText;
|
|
71584
|
+
const start = Math.max(0, lineText.indexOf(path5) - 80);
|
|
71585
|
+
return `${start > 0 ? "..." : ""}${lineText.slice(start, start + 200)}...`;
|
|
71586
|
+
}
|
|
71587
|
+
function renderRuleListing(rule, flagged) {
|
|
71588
|
+
if (flagged.length === 0)
|
|
71589
|
+
return [`${rule}: no findings`];
|
|
71590
|
+
const byFile = new Map;
|
|
71591
|
+
for (const issue of flagged)
|
|
71592
|
+
byFile.set(issue.file, [...byFile.get(issue.file) ?? [], issue]);
|
|
71593
|
+
const help = RULE_HELP[rule];
|
|
71594
|
+
const lines = [`${rule}: ${count(flagged.length, "finding")} in ${count(byFile.size, "asset")}`];
|
|
71595
|
+
if (help)
|
|
71596
|
+
lines.push(`how to fix: ${help.how}`);
|
|
71597
|
+
for (const [file, issues] of byFile) {
|
|
71598
|
+
const ref = issues[0]?.ref;
|
|
71599
|
+
lines.push("", ref ? `${ref} (${file})` : file);
|
|
71600
|
+
for (const issue of issues) {
|
|
71601
|
+
const at = typeof issue.line === "number" ? `line ${issue.line} ` : "";
|
|
71602
|
+
if (issue.path === undefined) {
|
|
71603
|
+
lines.push(` ${at}${issue.detail}`);
|
|
71604
|
+
continue;
|
|
71605
|
+
}
|
|
71606
|
+
lines.push(` ${at}${issue.path} ${issue.reason}; nearest existing: ${issue.nearestExisting}`);
|
|
71607
|
+
lines.push(` ${excerpt(issue.lineText ?? "", issue.path)}`);
|
|
71608
|
+
}
|
|
71609
|
+
}
|
|
71610
|
+
return lines;
|
|
71611
|
+
}
|
|
71358
71612
|
function formatLintPlain(r) {
|
|
71359
71613
|
if (r === null || typeof r !== "object")
|
|
71360
71614
|
return null;
|
|
@@ -71366,7 +71620,8 @@ function formatLintPlain(r) {
|
|
|
71366
71620
|
if (typeof r.ok === "boolean")
|
|
71367
71621
|
lines.push(`ok: ${r.ok}`);
|
|
71368
71622
|
lines.push(`summary: fixed=${summary?.fixed ?? fixed.length} flagged=${summary?.flagged ?? flagged.length}` + ` warnings=${summary?.warnings ?? warnings.length}`);
|
|
71369
|
-
|
|
71623
|
+
const rule = typeof r.rule === "string" ? r.rule : undefined;
|
|
71624
|
+
lines.push("", ...rule ? renderRuleListing(rule, flagged) : renderRuleSummary(flagged, r.byRule ?? {}));
|
|
71370
71625
|
lines.push("", ...renderIssueSection("warnings", warnings));
|
|
71371
71626
|
lines.push("", ...renderIssueSection("fixed", fixed));
|
|
71372
71627
|
return lines.join(`
|
|
@@ -72296,9 +72551,9 @@ class ByteReader {
|
|
|
72296
72551
|
this.#pending = this.#pending.subarray(taken.length);
|
|
72297
72552
|
return taken;
|
|
72298
72553
|
}
|
|
72299
|
-
async exact(
|
|
72554
|
+
async exact(count2) {
|
|
72300
72555
|
const parts = [];
|
|
72301
|
-
for (let left =
|
|
72556
|
+
for (let left = count2;left > 0; ) {
|
|
72302
72557
|
const part = await this.read(left);
|
|
72303
72558
|
if (!part)
|
|
72304
72559
|
throw new Error("the archive ends inside an entry");
|
|
@@ -72307,8 +72562,8 @@ class ByteReader {
|
|
|
72307
72562
|
}
|
|
72308
72563
|
return Buffer.concat(parts);
|
|
72309
72564
|
}
|
|
72310
|
-
async skip(
|
|
72311
|
-
for (let left =
|
|
72565
|
+
async skip(count2) {
|
|
72566
|
+
for (let left = count2;left > 0; ) {
|
|
72312
72567
|
const part = await this.read(left);
|
|
72313
72568
|
if (!part)
|
|
72314
72569
|
throw new Error("the archive ends inside an entry");
|
|
@@ -72733,6 +72988,8 @@ function formatMigratePlain(result) {
|
|
|
72733
72988
|
const refs = plan.assetContentRefs;
|
|
72734
72989
|
lines.push(` asset content refs: ${refs.refs} in ${refs.changed} file(s) change, ${refs.skipped} skipped, ${refs.shadowed?.length ?? 0} shadowed`);
|
|
72735
72990
|
}
|
|
72991
|
+
if (plan.bundlePolicy)
|
|
72992
|
+
lines.push(` bundle policy: ${plan.bundlePolicy.changed} change(s)`);
|
|
72736
72993
|
if (plan.blockers?.length) {
|
|
72737
72994
|
lines.push("", "blockers:", ...plan.blockers.map((blocker) => ` - ${blocker}`));
|
|
72738
72995
|
}
|
|
@@ -72742,6 +72999,9 @@ function formatMigratePlain(result) {
|
|
|
72742
72999
|
if (plan.assetEngineKeys?.notes?.length) {
|
|
72743
73000
|
lines.push("", "engine name notes:", ...plan.assetEngineKeys.notes.map((note) => ` - ${note}`));
|
|
72744
73001
|
}
|
|
73002
|
+
if (plan.bundlePolicy?.notes?.length) {
|
|
73003
|
+
lines.push("", "bundle policy notes:", ...plan.bundlePolicy.notes.map((note) => ` - ${note}`));
|
|
73004
|
+
}
|
|
72745
73005
|
if (plan.assetContentRefs?.shadowed?.length) {
|
|
72746
73006
|
lines.push("", "shadowed refs (another file holds the old spelling as its ref; not rewritten, resolve them by hand):", ...plan.assetContentRefs.shadowed.map((ref) => ` - ${ref.bundleId}: ${ref.from} (now ${ref.to})`));
|
|
72747
73007
|
}
|
|
@@ -72943,7 +73203,7 @@ var EXIT_CODES2 = {
|
|
|
72943
73203
|
init_errors();
|
|
72944
73204
|
|
|
72945
73205
|
// scripts/akm-migrate/help.txt
|
|
72946
|
-
var help_default = "Usage: akm-migrate <command> [options]\n\nThe one migration tool for an akm installation. The CLI proper reads every\nshape akm has ever written (in memory, with a warning); `apply` makes the\ncurrent shape durable on disk. `status` and `apply` run every step, in\norder, and print one combined JSON plan (exit 1 when any step is blocked):\n\n 1. config.json rewritten in its current shape (unknown keys dropped, the\n `engines`/`defaults` form converted to `connections`/`harnesses` with\n `defaults.improveStrategy` as `improve.strategy`, `configVersion` set\n to the current value) -- backed up first. A config in the pre-0.9.15\n source layout is refused, not converted: run this under akm 0.9.x. Keys akm no longer reads from config (an engine's\n `apiKeyFile`, a literal or `${secrets/...}` `apiKey`, and the same on a\n connection or `embedding`) move to\n credentials.json, one note per key (never its value); a key that cannot\n be moved stays on the connection as `apiKey`, with a note. The retired\n models.json is folded into the models of the connections and harnesses\n it names (the entries it cannot place are listed in the notes), then\n moved to the config backups. A connection or harness akm cannot use stays in the\n file as written, with a note on what to fix\n 2. pending state.db migrations, historical-destructive ones included,\n with a verified sibling safety copy (the only path that admits them)\n 3. task files at version 2 or 3, and version 4 files still carrying the\n retired `schedule[].enabled` key, rewritten as task source v4 under\n one backup directory per run\n 4. the retired `engine:` key on commands, agents, workflows and task\n sources rewritten to `connection:` or `harness:` by what the name is\n now, under one backup directory per run\n 5. refs in the text files akm indexes in writable bundles that still use\n the spelling from before refs became bundle paths (`knowledge/WORK/x`,\n now `WORK/x`), in frontmatter and body: `[bundle//]<folder>/<path>`,\n `<type>:<path>` and `wiki:<path>`, rewritten under one backup directory\n per run. An old spelling that is now another file's ref is not\n rewritten, only listed\n 6. superseded residue removed: pre-0.9.0 `.akm` leftovers in the stash,\n and the transaction-journal, maintenance-barrier, lock-mutex and\n version-stamp files older releases kept under $DATA, $STATE and $CONFIG\n\n`akm migrate status|apply` wraps this executable; `akm upgrade` runs\n`apply` after its install step, so an image that ships akm can put either\nin its entrypoint (a current installation is a no-op).\n\nCommands:\n status Inspect every pending migration without changing anything.\n apply [--dry-run] Back up and apply every pending migration.\n";
|
|
73206
|
+
var help_default = "Usage: akm-migrate <command> [options]\n\nThe one migration tool for an akm installation. The CLI proper reads every\nshape akm has ever written (in memory, with a warning); `apply` makes the\ncurrent shape durable on disk. `status` and `apply` run every step, in\norder, and print one combined JSON plan (exit 1 when any step is blocked):\n\n 1. config.json rewritten in its current shape (unknown keys dropped, the\n `engines`/`defaults` form converted to `connections`/`harnesses` with\n `defaults.improveStrategy` as `improve.strategy`, `configVersion` set\n to the current value) -- backed up first. A config in the pre-0.9.15\n source layout is refused, not converted: run this under akm 0.9.x. Keys akm no longer reads from config (an engine's\n `apiKeyFile`, a literal or `${secrets/...}` `apiKey`, and the same on a\n connection or `embedding`) move to\n credentials.json, one note per key (never its value); a key that cannot\n be moved stays on the connection as `apiKey`, with a note. The retired\n models.json is folded into the models of the connections and harnesses\n it names (the entries it cannot place are listed in the notes), then\n moved to the config backups. A connection or harness akm cannot use stays in the\n file as written, with a note on what to fix\n 2. pending state.db migrations, historical-destructive ones included,\n with a verified sibling safety copy (the only path that admits them)\n 3. task files at version 2 or 3, and version 4 files still carrying the\n retired `schedule[].enabled` key, rewritten as task source v4 under\n one backup directory per run\n 4. the retired `engine:` key on commands, agents, workflows and task\n sources rewritten to `connection:` or `harness:` by what the name is\n now, under one backup directory per run\n 5. refs in the text files akm indexes in writable bundles that still use\n the spelling from before refs became bundle paths (`knowledge/WORK/x`,\n now `WORK/x`), in frontmatter and body: `[bundle//]<folder>/<path>`,\n `<type>:<path>` and `wiki:<path>`, rewritten under one backup directory\n per run. An old spelling that is now another file's ref is not\n rewritten, only listed\n 6. bundle policy in writable bundles: an asset's `lint_skip:` frontmatter\n is stripped (lint skips live in the bundle's `lint.skip` config); a\n `.gitignore` with the old marker for tracking env and secrets adds\n `\"tracked-secrets\": [\"**\"]` to that bundle's `lint.skip`. `.gitignore` is\n never modified. The config is written first, the files under one backup\n directory per run\n 7. superseded residue removed: pre-0.9.0 `.akm` leftovers in the stash,\n and the transaction-journal, maintenance-barrier, lock-mutex and\n version-stamp files older releases kept under $DATA, $STATE and $CONFIG\n\n`akm migrate status|apply` wraps this executable; `akm upgrade` runs\n`apply` after its install step, so an image that ships akm can put either\nin its entrypoint (a current installation is a no-op).\n\nCommands:\n status Inspect every pending migration without changing anything.\n apply [--dry-run] Back up and apply every pending migration.\n";
|
|
72947
73207
|
|
|
72948
73208
|
// scripts/akm-migrate/run-migrate.ts
|
|
72949
73209
|
init_common();
|
|
@@ -72955,8 +73215,8 @@ init_secret_seam();
|
|
|
72955
73215
|
|
|
72956
73216
|
// scripts/akm-migrate/migrate/dead-residue.ts
|
|
72957
73217
|
init_paths();
|
|
72958
|
-
import
|
|
72959
|
-
import
|
|
73218
|
+
import fs49 from "node:fs";
|
|
73219
|
+
import path56 from "node:path";
|
|
72960
73220
|
var DEAD_RESIDUE_PATHS = [
|
|
72961
73221
|
{ name: "proposals", reason: "superseded by the `proposals` table in $DATA/state.db (0.9.0)" },
|
|
72962
73222
|
{ prefix: "runs.archived-", reason: "orphaned archive of a directory that no longer exists" },
|
|
@@ -72973,43 +73233,43 @@ function dirSizeBytes(target) {
|
|
|
72973
73233
|
let total = 0;
|
|
72974
73234
|
let entries;
|
|
72975
73235
|
try {
|
|
72976
|
-
entries =
|
|
73236
|
+
entries = fs49.readdirSync(target, { withFileTypes: true });
|
|
72977
73237
|
} catch {
|
|
72978
73238
|
return 0;
|
|
72979
73239
|
}
|
|
72980
73240
|
for (const entry of entries) {
|
|
72981
|
-
const entryPath =
|
|
73241
|
+
const entryPath = path56.join(target, entry.name);
|
|
72982
73242
|
if (entry.isDirectory()) {
|
|
72983
73243
|
total += dirSizeBytes(entryPath);
|
|
72984
73244
|
} else if (entry.isFile()) {
|
|
72985
73245
|
try {
|
|
72986
|
-
total +=
|
|
73246
|
+
total += fs49.statSync(entryPath).size;
|
|
72987
73247
|
} catch {}
|
|
72988
73248
|
}
|
|
72989
73249
|
}
|
|
72990
73250
|
return total;
|
|
72991
73251
|
}
|
|
72992
73252
|
function sizeOf(target) {
|
|
72993
|
-
const st2 =
|
|
73253
|
+
const st2 = fs49.statSync(target);
|
|
72994
73254
|
return st2.isDirectory() ? dirSizeBytes(target) : st2.size;
|
|
72995
73255
|
}
|
|
72996
73256
|
function hostResidue() {
|
|
72997
73257
|
const data = getDataDir();
|
|
72998
73258
|
const state = getStateDir();
|
|
72999
|
-
const configDir =
|
|
73259
|
+
const configDir = path56.dirname(getConfigPath());
|
|
73000
73260
|
const named = [
|
|
73001
|
-
{ absolutePath:
|
|
73002
|
-
{ absolutePath:
|
|
73003
|
-
{ absolutePath:
|
|
73004
|
-
{ absolutePath:
|
|
73005
|
-
{ absolutePath:
|
|
73006
|
-
{ absolutePath:
|
|
73007
|
-
{ absolutePath:
|
|
73261
|
+
{ absolutePath: path56.join(data, "txn"), reason: "filesystem transaction journals (removed in 0.9.17)" },
|
|
73262
|
+
{ absolutePath: path56.join(data, "txn-quarantine"), reason: "quarantined transaction journals (removed in 0.9.17)" },
|
|
73263
|
+
{ absolutePath: path56.join(data, "maintenance.barrier.lock"), reason: "maintenance barrier (removed in 0.9.17)" },
|
|
73264
|
+
{ absolutePath: path56.join(data, "maintenance-activities"), reason: "per-process activity registry (removed in 0.9.17)" },
|
|
73265
|
+
{ absolutePath: path56.join(state, "maintenance-activities"), reason: "per-process activity registry (removed in 0.9.17)" },
|
|
73266
|
+
{ absolutePath: path56.join(state, "version-reconcile.json"), reason: "startup reconcile stamp (removed in 0.9.17)" },
|
|
73267
|
+
{ absolutePath: path56.join(state, "locks", "version-reconcile.lock"), reason: "startup reconcile lock (removed in 0.9.17)" }
|
|
73008
73268
|
];
|
|
73009
73269
|
const found = [];
|
|
73010
73270
|
const claimed = new Set;
|
|
73011
73271
|
for (const entry of named) {
|
|
73012
|
-
if (claimed.has(entry.absolutePath) || !
|
|
73272
|
+
if (claimed.has(entry.absolutePath) || !fs49.existsSync(entry.absolutePath))
|
|
73013
73273
|
continue;
|
|
73014
73274
|
try {
|
|
73015
73275
|
found.push({ ...entry, relativePath: entry.absolutePath, sizeBytes: sizeOf(entry.absolutePath) });
|
|
@@ -73033,13 +73293,13 @@ function hostResidue() {
|
|
|
73033
73293
|
function findSidecars(root, depth, skip) {
|
|
73034
73294
|
let entries;
|
|
73035
73295
|
try {
|
|
73036
|
-
entries =
|
|
73296
|
+
entries = fs49.readdirSync(root, { withFileTypes: true });
|
|
73037
73297
|
} catch {
|
|
73038
73298
|
return [];
|
|
73039
73299
|
}
|
|
73040
73300
|
const found = [];
|
|
73041
73301
|
for (const entry of entries) {
|
|
73042
|
-
const entryPath =
|
|
73302
|
+
const entryPath = path56.join(root, entry.name);
|
|
73043
73303
|
if (entry.isFile() && entry.name.endsWith(".operations.sensitive"))
|
|
73044
73304
|
found.push(entryPath);
|
|
73045
73305
|
else if (entry.isDirectory() && depth > 0 && !skip.has(entryPath)) {
|
|
@@ -73052,10 +73312,10 @@ function findDeadResidueEntries(stashDir) {
|
|
|
73052
73312
|
const host = hostResidue();
|
|
73053
73313
|
if (stashDir === undefined)
|
|
73054
73314
|
return host;
|
|
73055
|
-
const akmDir =
|
|
73315
|
+
const akmDir = path56.join(stashDir, ".akm");
|
|
73056
73316
|
let names;
|
|
73057
73317
|
try {
|
|
73058
|
-
names =
|
|
73318
|
+
names = fs49.readdirSync(akmDir);
|
|
73059
73319
|
} catch {
|
|
73060
73320
|
return host;
|
|
73061
73321
|
}
|
|
@@ -73065,14 +73325,14 @@ function findDeadResidueEntries(stashDir) {
|
|
|
73065
73325
|
for (const name of matches) {
|
|
73066
73326
|
if (!names.includes(name))
|
|
73067
73327
|
continue;
|
|
73068
|
-
const absolutePath =
|
|
73328
|
+
const absolutePath = path56.join(akmDir, name);
|
|
73069
73329
|
let sizeBytes;
|
|
73070
73330
|
try {
|
|
73071
73331
|
sizeBytes = sizeOf(absolutePath);
|
|
73072
73332
|
} catch {
|
|
73073
73333
|
continue;
|
|
73074
73334
|
}
|
|
73075
|
-
found.push({ relativePath:
|
|
73335
|
+
found.push({ relativePath: path56.join(".akm", name), absolutePath, sizeBytes, reason: spec.reason });
|
|
73076
73336
|
}
|
|
73077
73337
|
}
|
|
73078
73338
|
return found;
|
|
@@ -73081,7 +73341,7 @@ function removeDeadResidue(stashDir) {
|
|
|
73081
73341
|
const entries = findDeadResidueEntries(stashDir);
|
|
73082
73342
|
return entries.map((entry) => {
|
|
73083
73343
|
try {
|
|
73084
|
-
|
|
73344
|
+
fs49.rmSync(entry.absolutePath, { recursive: true, force: true });
|
|
73085
73345
|
return { relativePath: entry.relativePath, sizeBytes: entry.sizeBytes, removed: true };
|
|
73086
73346
|
} catch (error62) {
|
|
73087
73347
|
return {
|
|
@@ -73101,7 +73361,7 @@ init_config_io();
|
|
|
73101
73361
|
init_retired_engines();
|
|
73102
73362
|
init_paths();
|
|
73103
73363
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
73104
|
-
import
|
|
73364
|
+
import path61 from "node:path";
|
|
73105
73365
|
|
|
73106
73366
|
// scripts/akm-migrate/bundle-roots.ts
|
|
73107
73367
|
init_detect_adapter();
|
|
@@ -73111,19 +73371,19 @@ init_errors();
|
|
|
73111
73371
|
init_write_source();
|
|
73112
73372
|
init_search_source();
|
|
73113
73373
|
init_lockfile();
|
|
73114
|
-
import
|
|
73115
|
-
import
|
|
73116
|
-
import
|
|
73374
|
+
import fs50 from "node:fs";
|
|
73375
|
+
import os11 from "node:os";
|
|
73376
|
+
import path57 from "node:path";
|
|
73117
73377
|
function expandTilde(value) {
|
|
73118
73378
|
if (value === "~")
|
|
73119
|
-
return
|
|
73379
|
+
return os11.homedir();
|
|
73120
73380
|
if (value.startsWith("~/") || value.startsWith("~\\"))
|
|
73121
|
-
return
|
|
73381
|
+
return path57.join(os11.homedir(), value.slice(2));
|
|
73122
73382
|
return value;
|
|
73123
73383
|
}
|
|
73124
73384
|
function existingDirectory(target) {
|
|
73125
73385
|
try {
|
|
73126
|
-
return
|
|
73386
|
+
return fs50.statSync(target).isDirectory();
|
|
73127
73387
|
} catch (cause) {
|
|
73128
73388
|
if (cause.code === "ENOENT")
|
|
73129
73389
|
return false;
|
|
@@ -73154,14 +73414,14 @@ function bundleRoots(config2) {
|
|
|
73154
73414
|
const source = sources.get(bundleId);
|
|
73155
73415
|
if (!source)
|
|
73156
73416
|
continue;
|
|
73157
|
-
const configuredRoot = source.type === "filesystem" && source.path ?
|
|
73417
|
+
const configuredRoot = source.type === "filesystem" && source.path ? path57.resolve(expandTilde(source.path)) : lockContentRootFor(bundleId, source.type);
|
|
73158
73418
|
if (!configuredRoot || !existingDirectory(configuredRoot))
|
|
73159
73419
|
continue;
|
|
73160
|
-
const bundleRoot =
|
|
73420
|
+
const bundleRoot = path57.resolve(configuredRoot);
|
|
73161
73421
|
const component = bundleComponentConfig(bundle);
|
|
73162
|
-
const componentRoot =
|
|
73163
|
-
const relative =
|
|
73164
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
73422
|
+
const componentRoot = path57.resolve(bundleRoot, component?.root ?? ".");
|
|
73423
|
+
const relative = path57.relative(bundleRoot, componentRoot);
|
|
73424
|
+
if (relative === ".." || relative.startsWith(`..${path57.sep}`) || path57.isAbsolute(relative)) {
|
|
73165
73425
|
throw new ConfigError(`Migration component root ${componentRoot} escapes bundle ${bundleId} at ${bundleRoot}.`, "INVALID_CONFIG_FILE");
|
|
73166
73426
|
}
|
|
73167
73427
|
if (!existingDirectory(componentRoot))
|
|
@@ -73374,15 +73634,15 @@ function planEngineKeys(inputs, resolve) {
|
|
|
73374
73634
|
|
|
73375
73635
|
// scripts/akm-migrate/migrate/engine-key-files.ts
|
|
73376
73636
|
init_walker();
|
|
73377
|
-
import
|
|
73378
|
-
import
|
|
73637
|
+
import fs52 from "node:fs";
|
|
73638
|
+
import path60 from "node:path";
|
|
73379
73639
|
|
|
73380
73640
|
// scripts/akm-migrate/migrate/task-files.ts
|
|
73381
73641
|
init_errors();
|
|
73382
73642
|
init_task_source_v4();
|
|
73383
73643
|
import crypto5 from "node:crypto";
|
|
73384
|
-
import
|
|
73385
|
-
import
|
|
73644
|
+
import fs51 from "node:fs";
|
|
73645
|
+
import path59 from "node:path";
|
|
73386
73646
|
|
|
73387
73647
|
// scripts/akm-migrate/migrate/task-to-v4.ts
|
|
73388
73648
|
init_dist();
|
|
@@ -73392,7 +73652,7 @@ init_resource_limits();
|
|
|
73392
73652
|
init_task_id();
|
|
73393
73653
|
init_bounded_document();
|
|
73394
73654
|
import crypto4 from "node:crypto";
|
|
73395
|
-
import
|
|
73655
|
+
import path58 from "node:path";
|
|
73396
73656
|
|
|
73397
73657
|
// scripts/akm-migrate/migrate/task-source-v3-frozen.ts
|
|
73398
73658
|
init_builtin_action();
|
|
@@ -74181,7 +74441,7 @@ function addSharedNonPromptOverrides(data, akm) {
|
|
|
74181
74441
|
}
|
|
74182
74442
|
function promptSourceKind(raw) {
|
|
74183
74443
|
const trimmed = raw.trim();
|
|
74184
|
-
if (trimmed.startsWith("./") || trimmed.startsWith("../") ||
|
|
74444
|
+
if (trimmed.startsWith("./") || trimmed.startsWith("../") || path58.isAbsolute(trimmed) || /^[A-Za-z]:[\\/]/.test(trimmed)) {
|
|
74185
74445
|
return "file";
|
|
74186
74446
|
}
|
|
74187
74447
|
try {
|
|
@@ -74285,7 +74545,7 @@ function planV2DataToV4(input2, data) {
|
|
|
74285
74545
|
return blocked(input2, "read-only-source", !input2.writable ? "the owning source is not writable" : "the source file or publication directory is read-only");
|
|
74286
74546
|
}
|
|
74287
74547
|
try {
|
|
74288
|
-
validateTaskId(
|
|
74548
|
+
validateTaskId(path58.basename(input2.filePath, ".yml"));
|
|
74289
74549
|
} catch (cause) {
|
|
74290
74550
|
return blocked(input2, "invalid-v2-task", causeMessage(cause));
|
|
74291
74551
|
}
|
|
@@ -74423,7 +74683,7 @@ function taskToV4PlanFromOutcomes(outcomes) {
|
|
|
74423
74683
|
for (let index = 1;index < files.length; index += 1) {
|
|
74424
74684
|
const previous = files[index - 1];
|
|
74425
74685
|
const current = files[index];
|
|
74426
|
-
if (previous && current &&
|
|
74686
|
+
if (previous && current && path58.resolve(previous.filePath) === path58.resolve(current.filePath)) {
|
|
74427
74687
|
throw new Error(`duplicate task migration file path: ${current.filePath}`);
|
|
74428
74688
|
}
|
|
74429
74689
|
}
|
|
@@ -74435,18 +74695,18 @@ function migrationError(detail) {
|
|
|
74435
74695
|
return new ConfigError(`Task migration failed: ${detail}`, "INVALID_CONFIG_FILE");
|
|
74436
74696
|
}
|
|
74437
74697
|
function contained(root, candidate) {
|
|
74438
|
-
const relative =
|
|
74439
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
74698
|
+
const relative = path59.relative(root, candidate);
|
|
74699
|
+
return relative === "" || !relative.startsWith("..") && !path59.isAbsolute(relative);
|
|
74440
74700
|
}
|
|
74441
74701
|
function realDirectory(filePath) {
|
|
74442
|
-
const stat =
|
|
74702
|
+
const stat = fs51.lstatSync(filePath);
|
|
74443
74703
|
if (stat.isSymbolicLink() || !stat.isDirectory())
|
|
74444
74704
|
throw migrationError(`${filePath} must be a real directory.`);
|
|
74445
|
-
return
|
|
74705
|
+
return fs51.realpathSync(filePath);
|
|
74446
74706
|
}
|
|
74447
74707
|
function isWritable(filePath) {
|
|
74448
74708
|
try {
|
|
74449
|
-
|
|
74709
|
+
fs51.accessSync(filePath, fs51.constants.W_OK);
|
|
74450
74710
|
return true;
|
|
74451
74711
|
} catch {
|
|
74452
74712
|
return false;
|
|
@@ -74459,12 +74719,12 @@ function walkRootFiles(root, directory, extension, onLink, visit3) {
|
|
|
74459
74719
|
throw migrationError(`${root.root} resolves outside bundle ${root.bundleId}.`);
|
|
74460
74720
|
}
|
|
74461
74721
|
const walk = (current) => {
|
|
74462
|
-
const physicalDirectory =
|
|
74722
|
+
const physicalDirectory = fs51.realpathSync(current);
|
|
74463
74723
|
if (!contained(physicalRoot, physicalDirectory)) {
|
|
74464
74724
|
throw migrationError(`${current} resolves outside bundle ${root.bundleId}.`);
|
|
74465
74725
|
}
|
|
74466
|
-
for (const entry of
|
|
74467
|
-
const candidate =
|
|
74726
|
+
for (const entry of fs51.readdirSync(current, { withFileTypes: true }).sort((a3, b) => a3.name.localeCompare(b.name))) {
|
|
74727
|
+
const candidate = path59.join(current, entry.name);
|
|
74468
74728
|
if (entry.isSymbolicLink()) {
|
|
74469
74729
|
onLink(candidate);
|
|
74470
74730
|
continue;
|
|
@@ -74483,11 +74743,11 @@ function walkTasks(root, tasksDir, out) {
|
|
|
74483
74743
|
walkRootFiles(root, tasksDir, ".yml", (link) => {
|
|
74484
74744
|
throw migrationError(`task migration does not follow symbolic link ${link}.`);
|
|
74485
74745
|
}, (candidate, directory) => {
|
|
74486
|
-
const stat =
|
|
74746
|
+
const stat = fs51.lstatSync(candidate);
|
|
74487
74747
|
const mode = stat.mode & 511;
|
|
74488
74748
|
out.push({
|
|
74489
74749
|
filePath: candidate,
|
|
74490
|
-
bytes:
|
|
74750
|
+
bytes: fs51.readFileSync(candidate),
|
|
74491
74751
|
mode,
|
|
74492
74752
|
writable: root.writable,
|
|
74493
74753
|
onDiskWritable: isWritable(candidate) && isWritable(directory) && (mode & 146) !== 0
|
|
@@ -74497,9 +74757,9 @@ function walkTasks(root, tasksDir, out) {
|
|
|
74497
74757
|
function inspectTaskFiles(roots) {
|
|
74498
74758
|
const files = [];
|
|
74499
74759
|
for (const root of [...roots].sort((a3, b) => a3.bundleId.localeCompare(b.bundleId))) {
|
|
74500
|
-
const tasksDir = root.layout === "akm-task" ? root.root :
|
|
74760
|
+
const tasksDir = root.layout === "akm-task" ? root.root : path59.join(root.root, "tasks");
|
|
74501
74761
|
try {
|
|
74502
|
-
const stat =
|
|
74762
|
+
const stat = fs51.lstatSync(tasksDir);
|
|
74503
74763
|
if (stat.isSymbolicLink())
|
|
74504
74764
|
throw migrationError(`task migration does not follow symbolic link ${tasksDir}.`);
|
|
74505
74765
|
if (!stat.isDirectory())
|
|
@@ -74517,18 +74777,18 @@ function planTaskFilesMigration(inputs) {
|
|
|
74517
74777
|
return taskToV4PlanFromOutcomes(inputs.map(planTaskToV4File));
|
|
74518
74778
|
}
|
|
74519
74779
|
function taskFileBackupPath(backupRoot, filePath) {
|
|
74520
|
-
const digest = crypto5.createHash("sha256").update(
|
|
74521
|
-
return
|
|
74780
|
+
const digest = crypto5.createHash("sha256").update(path59.resolve(filePath)).digest("hex").slice(0, 16);
|
|
74781
|
+
return path59.join(backupRoot, "files", `${digest}-${path59.basename(filePath)}`);
|
|
74522
74782
|
}
|
|
74523
74783
|
function fsyncDirectory(directory) {
|
|
74524
74784
|
if (process.platform === "win32")
|
|
74525
74785
|
return;
|
|
74526
74786
|
try {
|
|
74527
|
-
const fd =
|
|
74787
|
+
const fd = fs51.openSync(directory, "r");
|
|
74528
74788
|
try {
|
|
74529
|
-
|
|
74789
|
+
fs51.fsyncSync(fd);
|
|
74530
74790
|
} finally {
|
|
74531
|
-
|
|
74791
|
+
fs51.closeSync(fd);
|
|
74532
74792
|
}
|
|
74533
74793
|
} catch (cause) {
|
|
74534
74794
|
const code = cause.code;
|
|
@@ -74537,30 +74797,30 @@ function fsyncDirectory(directory) {
|
|
|
74537
74797
|
}
|
|
74538
74798
|
}
|
|
74539
74799
|
function writeDurable(filePath, bytes, mode, exclusive = false) {
|
|
74540
|
-
|
|
74541
|
-
const fd =
|
|
74800
|
+
fs51.mkdirSync(path59.dirname(filePath), { recursive: true });
|
|
74801
|
+
const fd = fs51.openSync(filePath, exclusive ? "wx" : "w", mode);
|
|
74542
74802
|
try {
|
|
74543
|
-
|
|
74544
|
-
|
|
74803
|
+
fs51.writeFileSync(fd, bytes);
|
|
74804
|
+
fs51.fsyncSync(fd);
|
|
74545
74805
|
} finally {
|
|
74546
|
-
|
|
74806
|
+
fs51.closeSync(fd);
|
|
74547
74807
|
}
|
|
74548
|
-
|
|
74549
|
-
fsyncDirectory(
|
|
74808
|
+
fs51.chmodSync(filePath, mode);
|
|
74809
|
+
fsyncDirectory(path59.dirname(filePath));
|
|
74550
74810
|
}
|
|
74551
74811
|
function replaceAtomically(filePath, bytes, mode) {
|
|
74552
|
-
const temporary =
|
|
74812
|
+
const temporary = path59.join(path59.dirname(filePath), `.${path59.basename(filePath)}.migrate-${crypto5.randomUUID()}`);
|
|
74553
74813
|
try {
|
|
74554
74814
|
writeDurable(temporary, bytes, mode, true);
|
|
74555
|
-
|
|
74556
|
-
fsyncDirectory(
|
|
74815
|
+
fs51.renameSync(temporary, filePath);
|
|
74816
|
+
fsyncDirectory(path59.dirname(filePath));
|
|
74557
74817
|
} finally {
|
|
74558
|
-
|
|
74818
|
+
fs51.rmSync(temporary, { force: true });
|
|
74559
74819
|
}
|
|
74560
74820
|
}
|
|
74561
74821
|
function holds(filePath, bytes) {
|
|
74562
74822
|
try {
|
|
74563
|
-
return
|
|
74823
|
+
return fs51.readFileSync(filePath).equals(bytes);
|
|
74564
74824
|
} catch {
|
|
74565
74825
|
return false;
|
|
74566
74826
|
}
|
|
@@ -74580,7 +74840,7 @@ function replaceFilesWithBackups(changes, backupRoot) {
|
|
|
74580
74840
|
try {
|
|
74581
74841
|
for (const change of backedUp) {
|
|
74582
74842
|
if (!holds(change.filePath, change.before)) {
|
|
74583
|
-
|
|
74843
|
+
fs51.rmSync(taskFileBackupPath(backupRoot, change.filePath), { force: true });
|
|
74584
74844
|
conflicts.push(change.filePath);
|
|
74585
74845
|
continue;
|
|
74586
74846
|
}
|
|
@@ -74591,7 +74851,7 @@ function replaceFilesWithBackups(changes, backupRoot) {
|
|
|
74591
74851
|
const unrestored = [];
|
|
74592
74852
|
for (const change of [...replaced].reverse()) {
|
|
74593
74853
|
if (holds(change.filePath, change.after)) {
|
|
74594
|
-
replaceAtomically(change.filePath,
|
|
74854
|
+
replaceAtomically(change.filePath, fs51.readFileSync(taskFileBackupPath(backupRoot, change.filePath)), change.mode);
|
|
74595
74855
|
} else {
|
|
74596
74856
|
unrestored.push(change.filePath);
|
|
74597
74857
|
}
|
|
@@ -74637,7 +74897,7 @@ var LAYOUTS = new Map([
|
|
|
74637
74897
|
function collect(root, directory, role, extension, out) {
|
|
74638
74898
|
let top;
|
|
74639
74899
|
try {
|
|
74640
|
-
top =
|
|
74900
|
+
top = fs52.lstatSync(directory);
|
|
74641
74901
|
} catch (cause) {
|
|
74642
74902
|
if (cause.code === "ENOENT")
|
|
74643
74903
|
return;
|
|
@@ -74650,8 +74910,8 @@ function collect(root, directory, role, extension, out) {
|
|
|
74650
74910
|
return;
|
|
74651
74911
|
out.set(link, {
|
|
74652
74912
|
filePath: link,
|
|
74653
|
-
bytes:
|
|
74654
|
-
mode:
|
|
74913
|
+
bytes: fs52.readFileSync(link),
|
|
74914
|
+
mode: fs52.statSync(link).mode & 511,
|
|
74655
74915
|
role,
|
|
74656
74916
|
writable: root.writable,
|
|
74657
74917
|
link: true
|
|
@@ -74661,8 +74921,8 @@ function collect(root, directory, role, extension, out) {
|
|
|
74661
74921
|
return;
|
|
74662
74922
|
out.set(candidate, {
|
|
74663
74923
|
filePath: candidate,
|
|
74664
|
-
bytes:
|
|
74665
|
-
mode:
|
|
74924
|
+
bytes: fs52.readFileSync(candidate),
|
|
74925
|
+
mode: fs52.lstatSync(candidate).mode & 511,
|
|
74666
74926
|
role,
|
|
74667
74927
|
writable: root.writable
|
|
74668
74928
|
});
|
|
@@ -74672,7 +74932,7 @@ function inspectEngineKeyFiles(roots) {
|
|
|
74672
74932
|
const files = new Map;
|
|
74673
74933
|
for (const root of [...roots].sort((a3, b) => a3.bundleId.localeCompare(b.bundleId))) {
|
|
74674
74934
|
for (const { dir, role, extension } of LAYOUTS.get(root.adapter) ?? []) {
|
|
74675
|
-
collect(root,
|
|
74935
|
+
collect(root, path60.join(root.root, dir), role, extension, files);
|
|
74676
74936
|
}
|
|
74677
74937
|
}
|
|
74678
74938
|
return [...files.values()].sort((a3, b) => a3.filePath.localeCompare(b.filePath));
|
|
@@ -74760,7 +75020,7 @@ function applyEngineKeysMigration(targets) {
|
|
|
74760
75020
|
const notes3 = pendingEngineKeys(before) === 0 ? forgetOldNames(knownTargets(targets)) : [];
|
|
74761
75021
|
return statusOf(notes3.length > 0 ? { ...summary, notes: notes3 } : summary);
|
|
74762
75022
|
}
|
|
74763
|
-
const backupPath =
|
|
75023
|
+
const backupPath = path61.join(getDataDir(), "backups", "asset-engine-keys", `${Date.now()}-${randomUUID3()}`);
|
|
74764
75024
|
const { rewritten, conflicts } = applyEngineKeysPlan(before, { backupRoot: backupPath });
|
|
74765
75025
|
const files = summary.files.map((file2) => conflicts.includes(file2.filePath) ? {
|
|
74766
75026
|
filePath: file2.filePath,
|
|
@@ -74795,8 +75055,8 @@ init_paths();
|
|
|
74795
75055
|
init_walker();
|
|
74796
75056
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
74797
75057
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
74798
|
-
import
|
|
74799
|
-
import
|
|
75058
|
+
import fs53 from "node:fs";
|
|
75059
|
+
import path62 from "node:path";
|
|
74800
75060
|
|
|
74801
75061
|
// scripts/akm-migrate/migrate/content-ref-planner.ts
|
|
74802
75062
|
init_asset_placement();
|
|
@@ -74835,23 +75095,23 @@ function contentRefRewriter(bundles) {
|
|
|
74835
75095
|
return {
|
|
74836
75096
|
shadowed,
|
|
74837
75097
|
rewrite(text2) {
|
|
74838
|
-
let
|
|
75098
|
+
let count2 = 0;
|
|
74839
75099
|
const replaced = text2.replace(pathToken, (token, bundleId, run) => {
|
|
74840
75100
|
const { stem, tail, md } = splitRun(run);
|
|
74841
75101
|
const to = newRef(bundleId, stem);
|
|
74842
75102
|
if (to === undefined)
|
|
74843
75103
|
return token;
|
|
74844
|
-
|
|
75104
|
+
count2++;
|
|
74845
75105
|
return `${bundleId === undefined ? "" : `${bundleId}//`}${to}${md ? ".md" : ""}${tail}`;
|
|
74846
75106
|
}).replace(typedToken, (token, type, run) => {
|
|
74847
75107
|
const { stem, tail, md } = splitRun(run);
|
|
74848
75108
|
const to = newRef(undefined, `${folderOf(type)}/${stem}`);
|
|
74849
75109
|
if (to === undefined)
|
|
74850
75110
|
return token;
|
|
74851
|
-
|
|
75111
|
+
count2++;
|
|
74852
75112
|
return `${to}${md ? ".md" : ""}${tail}`;
|
|
74853
75113
|
});
|
|
74854
|
-
return { text: replaced, count };
|
|
75114
|
+
return { text: replaced, count: count2 };
|
|
74855
75115
|
}
|
|
74856
75116
|
};
|
|
74857
75117
|
}
|
|
@@ -74860,7 +75120,7 @@ function contentRefRewriter(bundles) {
|
|
|
74860
75120
|
var TEXT_EXTENSIONS = new Set([".md", ".yml", ".yaml"]);
|
|
74861
75121
|
var UNOWNED_ADAPTERS = new Set(["generic-files", "code-project", "website-snapshot"]);
|
|
74862
75122
|
function textFiles(root) {
|
|
74863
|
-
return walkStashFlat(root).filter((file2) => TEXT_EXTENSIONS.has(file2.ext) &&
|
|
75123
|
+
return walkStashFlat(root).filter((file2) => TEXT_EXTENSIONS.has(file2.ext) && fs53.lstatSync(file2.absPath).isFile()).map((file2) => file2.absPath);
|
|
74864
75124
|
}
|
|
74865
75125
|
function bundleDocuments(roots) {
|
|
74866
75126
|
const bundles = new Map;
|
|
@@ -74882,29 +75142,29 @@ function bundleDocuments(roots) {
|
|
|
74882
75142
|
return { bundles, files };
|
|
74883
75143
|
}
|
|
74884
75144
|
function isStructuralFile(root, adapterId, filePath, assetDirs) {
|
|
74885
|
-
const segments =
|
|
75145
|
+
const segments = path62.relative(root, filePath).split(path62.sep);
|
|
74886
75146
|
if (segments.slice(0, -1).includes("raw"))
|
|
74887
75147
|
return false;
|
|
74888
75148
|
const name = segments[segments.length - 1].toLowerCase();
|
|
74889
75149
|
const atWikiRoot = segments.length >= 3 && segments[segments.length - 3] === "wikis";
|
|
74890
75150
|
if (name === "schema.md")
|
|
74891
75151
|
return atWikiRoot || adapterId === "llm-wiki" && segments.length === 1;
|
|
74892
|
-
return name === "index.md" && (atWikiRoot || assetDirs.has(
|
|
75152
|
+
return name === "index.md" && (atWikiRoot || assetDirs.has(path62.dirname(filePath)));
|
|
74893
75153
|
}
|
|
74894
75154
|
function gitReconcile(filePaths, backupPath) {
|
|
74895
75155
|
const { GIT_DIR: _dir, GIT_WORK_TREE: _tree, ...env } = process.env;
|
|
74896
75156
|
const topOf = new Map;
|
|
74897
75157
|
const byRoot = new Map;
|
|
74898
75158
|
for (const filePath of filePaths) {
|
|
74899
|
-
const real =
|
|
74900
|
-
const dir =
|
|
75159
|
+
const real = fs53.realpathSync(filePath);
|
|
75160
|
+
const dir = path62.dirname(real);
|
|
74901
75161
|
if (!topOf.has(dir)) {
|
|
74902
75162
|
const top = spawnSync6("git", ["-C", dir, "rev-parse", "--show-toplevel"], { encoding: "utf8", env });
|
|
74903
75163
|
topOf.set(dir, top.status === 0 ? top.stdout.trim() : undefined);
|
|
74904
75164
|
}
|
|
74905
75165
|
const gitRoot = topOf.get(dir);
|
|
74906
75166
|
if (gitRoot !== undefined)
|
|
74907
|
-
byRoot.set(gitRoot, [...byRoot.get(gitRoot) ?? [],
|
|
75167
|
+
byRoot.set(gitRoot, [...byRoot.get(gitRoot) ?? [], path62.relative(gitRoot, real)]);
|
|
74908
75168
|
}
|
|
74909
75169
|
return [...byRoot].map(([gitRoot, paths]) => {
|
|
74910
75170
|
const quoted = paths.map((file2) => JSON.stringify(file2)).join(" ");
|
|
@@ -74918,7 +75178,7 @@ function plan2() {
|
|
|
74918
75178
|
const rewriter = contentRefRewriter(documents.bundles);
|
|
74919
75179
|
const files = [];
|
|
74920
75180
|
const seen = new Set;
|
|
74921
|
-
const assetDirs = new Set([...documents.files].map((file2) =>
|
|
75181
|
+
const assetDirs = new Set([...documents.files].map((file2) => path62.dirname(file2)));
|
|
74922
75182
|
for (const root of roots.filter((candidate) => candidate.writable)) {
|
|
74923
75183
|
const adapterId = root.adapter ?? detectAdapterId(root.root);
|
|
74924
75184
|
if (UNOWNED_ADAPTERS.has(adapterId))
|
|
@@ -74927,16 +75187,16 @@ function plan2() {
|
|
|
74927
75187
|
if (seen.has(filePath) || !(documents.files.has(filePath) || isStructuralFile(root.root, adapterId, filePath, assetDirs)))
|
|
74928
75188
|
continue;
|
|
74929
75189
|
seen.add(filePath);
|
|
74930
|
-
const before =
|
|
75190
|
+
const before = fs53.readFileSync(filePath);
|
|
74931
75191
|
const text2 = before.toString("utf8");
|
|
74932
75192
|
if (!Buffer.from(text2, "utf8").equals(before))
|
|
74933
75193
|
continue;
|
|
74934
|
-
const { text: rewritten, count } = rewriter.rewrite(text2);
|
|
74935
|
-
if (
|
|
75194
|
+
const { text: rewritten, count: count2 } = rewriter.rewrite(text2);
|
|
75195
|
+
if (count2 === 0)
|
|
74936
75196
|
continue;
|
|
74937
75197
|
files.push({
|
|
74938
|
-
replacement: { filePath, before, after: Buffer.from(rewritten, "utf8"), mode:
|
|
74939
|
-
refs:
|
|
75198
|
+
replacement: { filePath, before, after: Buffer.from(rewritten, "utf8"), mode: fs53.statSync(filePath).mode & 511 },
|
|
75199
|
+
refs: count2
|
|
74940
75200
|
});
|
|
74941
75201
|
}
|
|
74942
75202
|
}
|
|
@@ -74964,7 +75224,7 @@ function applyContentRefsMigration() {
|
|
|
74964
75224
|
const summary = summarize2(planned);
|
|
74965
75225
|
if (summary.changed === 0)
|
|
74966
75226
|
return statusOf2(summary);
|
|
74967
|
-
const backupPath =
|
|
75227
|
+
const backupPath = path62.join(getDataDir(), "backups", "asset-content-refs", `${Date.now()}-${randomUUID4()}`);
|
|
74968
75228
|
const { replaced, conflicts } = replaceFilesWithBackups(planned.files.map((file2) => file2.replacement), backupPath);
|
|
74969
75229
|
const files = summary.files.map((file2) => conflicts.includes(file2.filePath) ? { ...file2, status: "skipped", reason: "it changed after it was planned, so it was left as it is; run again to plan it afresh" } : file2);
|
|
74970
75230
|
const reconcile = gitReconcile(replaced, backupPath);
|
|
@@ -74984,15 +75244,110 @@ function applyContentRefsMigration() {
|
|
|
74984
75244
|
});
|
|
74985
75245
|
}
|
|
74986
75246
|
|
|
75247
|
+
// scripts/akm-migrate/bundle-policy-migrate.ts
|
|
75248
|
+
init_config();
|
|
75249
|
+
init_paths();
|
|
75250
|
+
init_walker();
|
|
75251
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
75252
|
+
import fs54 from "node:fs";
|
|
75253
|
+
import path63 from "node:path";
|
|
75254
|
+
var ASSET_DIRS = new Set(["agents", "commands", "memories", "skills", "workflows", "lessons", "tasks", "knowledge", "facts"]);
|
|
75255
|
+
var TRACK_SECRETS_MARKER = "# akm: intentionally track env and secrets";
|
|
75256
|
+
function withoutLintSkip(raw) {
|
|
75257
|
+
const parts = raw.split(/(\r?\n)/);
|
|
75258
|
+
if (parts[0]?.trim() !== "---")
|
|
75259
|
+
return null;
|
|
75260
|
+
const closeAt = parts.findIndex((part, i) => i > 0 && part.trim() === "---");
|
|
75261
|
+
const at2 = parts.findIndex((part, i) => i > 0 && i < closeAt && /^lint_skip:(?:[ \t]|$)/.test(part));
|
|
75262
|
+
if (closeAt === -1 || at2 === -1)
|
|
75263
|
+
return null;
|
|
75264
|
+
let end = at2;
|
|
75265
|
+
while (end + 2 < closeAt && /^(?:[ \t]|-[ \t]|\]|$)/.test(parts[end + 2]))
|
|
75266
|
+
end += 2;
|
|
75267
|
+
parts.splice(at2, end - at2 + 2);
|
|
75268
|
+
return parts.join("");
|
|
75269
|
+
}
|
|
75270
|
+
function plan3() {
|
|
75271
|
+
resetConfigCache();
|
|
75272
|
+
const config2 = loadConfig();
|
|
75273
|
+
const files = [];
|
|
75274
|
+
const bundles = [];
|
|
75275
|
+
const notes2 = [];
|
|
75276
|
+
for (const root of bundleRoots(config2).filter((candidate) => candidate.writable)) {
|
|
75277
|
+
const edits = [];
|
|
75278
|
+
if ((root.adapter ?? "akm") === "akm") {
|
|
75279
|
+
for (const file2 of walkStashFlat(root.root)) {
|
|
75280
|
+
const rel = path63.relative(root.root, file2.absPath).split(path63.sep).join("/");
|
|
75281
|
+
if (file2.ext !== ".md" || !ASSET_DIRS.has(rel.split("/")[0]) || !fs54.lstatSync(file2.absPath).isFile())
|
|
75282
|
+
continue;
|
|
75283
|
+
const after = withoutLintSkip(fs54.readFileSync(file2.absPath, "utf8"));
|
|
75284
|
+
if (after !== null)
|
|
75285
|
+
edits.push({ filePath: file2.absPath, after });
|
|
75286
|
+
}
|
|
75287
|
+
}
|
|
75288
|
+
const gitignorePath = path63.join(root.root, ".gitignore");
|
|
75289
|
+
const marked = fs54.existsSync(gitignorePath) && fs54.lstatSync(gitignorePath).isFile() && fs54.readFileSync(gitignorePath, "utf8").split(/\r?\n/).includes(TRACK_SECRETS_MARKER);
|
|
75290
|
+
const entry = config2.bundles?.[root.bundleId];
|
|
75291
|
+
const skipTrackedSecrets = marked && entry !== undefined && !entry.lint?.skip?.["tracked-secrets"]?.includes("**");
|
|
75292
|
+
if (marked && entry === undefined) {
|
|
75293
|
+
notes2.push(`Bundle ${root.bundleId} at ${root.root} tracks env and secrets on purpose and has no config entry for a lint skip.`);
|
|
75294
|
+
}
|
|
75295
|
+
if (edits.length === 0 && !skipTrackedSecrets)
|
|
75296
|
+
continue;
|
|
75297
|
+
bundles.push({ bundleId: root.bundleId, stripped: edits.length, skipTrackedSecrets });
|
|
75298
|
+
for (const edit of edits) {
|
|
75299
|
+
const before = fs54.readFileSync(edit.filePath);
|
|
75300
|
+
files.push({ filePath: edit.filePath, before, after: Buffer.from(edit.after, "utf8"), mode: fs54.statSync(edit.filePath).mode & 511 });
|
|
75301
|
+
}
|
|
75302
|
+
}
|
|
75303
|
+
return { files, bundles, notes: notes2 };
|
|
75304
|
+
}
|
|
75305
|
+
function summarize3(planned) {
|
|
75306
|
+
const skips = planned.bundles.filter((bundle) => bundle.skipTrackedSecrets).length;
|
|
75307
|
+
return { schemaVersion: 1, changed: planned.files.length + skips, bundles: planned.bundles, notes: planned.notes };
|
|
75308
|
+
}
|
|
75309
|
+
function statusOf3(summary) {
|
|
75310
|
+
return { schemaVersion: 1, status: summary.changed > 0 ? "ready" : "current", bundlePolicy: summary };
|
|
75311
|
+
}
|
|
75312
|
+
function inspectBundlePolicyMigration() {
|
|
75313
|
+
return statusOf3(summarize3(plan3()));
|
|
75314
|
+
}
|
|
75315
|
+
function applyBundlePolicyMigration() {
|
|
75316
|
+
const planned = plan3();
|
|
75317
|
+
const summary = summarize3(planned);
|
|
75318
|
+
if (summary.changed === 0)
|
|
75319
|
+
return statusOf3(summary);
|
|
75320
|
+
const skipping = planned.bundles.filter((bundle) => bundle.skipTrackedSecrets);
|
|
75321
|
+
if (skipping.length > 0) {
|
|
75322
|
+
mutateConfig((current) => {
|
|
75323
|
+
const bundles = { ...current.bundles };
|
|
75324
|
+
for (const { bundleId } of skipping) {
|
|
75325
|
+
const entry = bundles[bundleId];
|
|
75326
|
+
const skip = { ...entry.lint?.skip };
|
|
75327
|
+
skip["tracked-secrets"] = [...new Set([...skip["tracked-secrets"] ?? [], "**"])];
|
|
75328
|
+
bundles[bundleId] = { ...entry, lint: { ...entry.lint, skip } };
|
|
75329
|
+
}
|
|
75330
|
+
return { ...current, bundles };
|
|
75331
|
+
});
|
|
75332
|
+
}
|
|
75333
|
+
const backupPath = planned.files.length > 0 ? path63.join(getDataDir(), "backups", "bundle-policy", `${Date.now()}-${randomUUID5()}`) : undefined;
|
|
75334
|
+
const { replaced, conflicts } = backupPath ? replaceFilesWithBackups(planned.files, backupPath) : { replaced: [], conflicts: [] };
|
|
75335
|
+
return {
|
|
75336
|
+
schemaVersion: 1,
|
|
75337
|
+
status: conflicts.length > 0 ? "ready" : "current",
|
|
75338
|
+
bundlePolicy: { ...summary, applied: replaced.length + skipping.length, ...backupPath ? { backupPath } : {} }
|
|
75339
|
+
};
|
|
75340
|
+
}
|
|
75341
|
+
|
|
74987
75342
|
// scripts/akm-migrate/task-migrate.ts
|
|
74988
75343
|
init_detect_adapter();
|
|
74989
75344
|
init_config();
|
|
74990
75345
|
init_config_io();
|
|
74991
75346
|
init_errors();
|
|
74992
75347
|
init_paths();
|
|
74993
|
-
import { randomUUID as
|
|
74994
|
-
import
|
|
74995
|
-
import
|
|
75348
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
75349
|
+
import fs55 from "node:fs";
|
|
75350
|
+
import path64 from "node:path";
|
|
74996
75351
|
function taskRoots(config2) {
|
|
74997
75352
|
return bundleRoots(config2).flatMap((root) => {
|
|
74998
75353
|
const tasks = taskRoot(root);
|
|
@@ -75003,7 +75358,7 @@ function taskRoot(candidate) {
|
|
|
75003
75358
|
const { bundleId, bundleRoot, root, writable } = candidate;
|
|
75004
75359
|
const adapter = candidate.adapter ?? detectAdapterId(root, "");
|
|
75005
75360
|
if (!candidate.adapter && adapter === "") {
|
|
75006
|
-
const flatTasks =
|
|
75361
|
+
const flatTasks = fs55.readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".yml")).map((entry) => entry.name).sort();
|
|
75007
75362
|
if (flatTasks.length > 0) {
|
|
75008
75363
|
throw new ConfigError(`Task migration cannot classify top-level task file(s) ${flatTasks.join(", ")} in bundle ${bundleId}; configure adapter "akm-task" or move them under tasks/.`, "INVALID_CONFIG_FILE");
|
|
75009
75364
|
}
|
|
@@ -75012,8 +75367,8 @@ function taskRoot(candidate) {
|
|
|
75012
75367
|
return;
|
|
75013
75368
|
return { bundleId, root, bundleRoot, writable, layout: adapter === "akm-task" ? "akm-task" : "akm-stash" };
|
|
75014
75369
|
}
|
|
75015
|
-
function
|
|
75016
|
-
const files =
|
|
75370
|
+
function summarize4(plan4) {
|
|
75371
|
+
const files = plan4.files.map((file2) => ({
|
|
75017
75372
|
filePath: file2.filePath,
|
|
75018
75373
|
status: file2.status,
|
|
75019
75374
|
reason: file2.reason,
|
|
@@ -75032,11 +75387,11 @@ function summarize3(plan3) {
|
|
|
75032
75387
|
}
|
|
75033
75388
|
function inspectCurrent() {
|
|
75034
75389
|
resetConfigCache();
|
|
75035
|
-
const
|
|
75036
|
-
const blockers =
|
|
75037
|
-
const summary =
|
|
75390
|
+
const plan4 = planTaskFilesMigration(inspectTaskFiles(taskRoots(loadConfig())));
|
|
75391
|
+
const blockers = plan4.files.flatMap((file2) => file2.status === "blocked" ? [`${file2.filePath}: ${file2.reason}${file2.detail ? ` (${file2.detail})` : ""}`] : []);
|
|
75392
|
+
const summary = summarize4(plan4);
|
|
75038
75393
|
return {
|
|
75039
|
-
plan:
|
|
75394
|
+
plan: plan4,
|
|
75040
75395
|
result: {
|
|
75041
75396
|
schemaVersion: 1,
|
|
75042
75397
|
status: blockers.length > 0 ? "blocked" : summary.changed > 0 ? "ready" : "current",
|
|
@@ -75053,7 +75408,7 @@ function applyTaskFilesMigration() {
|
|
|
75053
75408
|
const before = inspectCurrent();
|
|
75054
75409
|
if (before.result.taskFiles.changed === 0)
|
|
75055
75410
|
return before.result;
|
|
75056
|
-
const backupPath =
|
|
75411
|
+
const backupPath = path64.join(getDataDir(), "backups", "tasks", `${Date.now()}-${randomUUID6()}`);
|
|
75057
75412
|
const applied = applyTaskFilesPlan(before.plan, { backupRoot: backupPath });
|
|
75058
75413
|
return {
|
|
75059
75414
|
...inspectCurrent().result,
|
|
@@ -75121,15 +75476,17 @@ async function runMigration(options) {
|
|
|
75121
75476
|
const engineTargets = configFile?.engineTargets;
|
|
75122
75477
|
const assetEngineKeys = configFailed ? undefined : await migrationStep(failedSteps, "assetEngineKeys", () => apply ? applyEngineKeysMigration(engineTargets) : inspectEngineKeysMigration(engineTargets), apply ? () => inspectEngineKeysMigration(engineTargets) : undefined);
|
|
75123
75478
|
const assetContentRefs = await migrationStep(failedSteps, "assetContentRefs", () => apply ? applyContentRefsMigration() : inspectContentRefsMigration(), apply ? () => inspectContentRefsMigration() : undefined);
|
|
75479
|
+
const bundlePolicy = await migrationStep(failedSteps, "bundlePolicy", () => apply ? applyBundlePolicyMigration() : inspectBundlePolicyMigration(), apply ? () => inspectBundlePolicyMigration() : undefined);
|
|
75124
75480
|
const stashDir = await migrationStep(failedSteps, "stashDir", () => stashDirIfConfigured());
|
|
75125
75481
|
const deadResidue = await migrationStep(failedSteps, "deadResidue", () => apply ? { removed: removeDeadResidue(stashDir) } : { pending: findDeadResidueEntries(stashDir) }, apply ? () => ({ pending: findDeadResidueEntries(stashDir) }) : undefined);
|
|
75126
75482
|
const stateStatus = stateMigrations && "pending" in stateMigrations && stateMigrations.pending.length > 0 ? "ready" : "current";
|
|
75127
75483
|
const configFileStatus = configFile?.changed && !configFile.applied ? "ready" : "current";
|
|
75128
75484
|
const engineKeysStatus = assetEngineKeys?.status ?? "current";
|
|
75129
75485
|
const contentRefsStatus = assetContentRefs?.status ?? "current";
|
|
75486
|
+
const bundlePolicyStatus = bundlePolicy?.status ?? "current";
|
|
75130
75487
|
return {
|
|
75131
75488
|
schemaVersion: 1,
|
|
75132
|
-
status: statusWithFailedSteps([stateStatus, configFileStatus, engineKeysStatus, contentRefsStatus].reduce(worstStatus, taskFiles?.status ?? "blocked"), failedSteps),
|
|
75489
|
+
status: statusWithFailedSteps([stateStatus, configFileStatus, engineKeysStatus, contentRefsStatus, bundlePolicyStatus].reduce(worstStatus, taskFiles?.status ?? "blocked"), failedSteps),
|
|
75133
75490
|
blockers: [...taskFiles?.blockers ?? [], ...failedStepBlockers(failedSteps)],
|
|
75134
75491
|
...failedSteps.length > 0 ? { failedSteps } : {},
|
|
75135
75492
|
...configFile !== undefined ? { configFile } : {},
|
|
@@ -75139,6 +75496,7 @@ async function runMigration(options) {
|
|
|
75139
75496
|
...taskFiles?.applied !== undefined ? { applied: taskFiles.applied } : {},
|
|
75140
75497
|
...assetEngineKeys !== undefined ? { assetEngineKeys: assetEngineKeys.assetEngineKeys } : {},
|
|
75141
75498
|
...assetContentRefs !== undefined ? { assetContentRefs: assetContentRefs.assetContentRefs } : {},
|
|
75499
|
+
...bundlePolicy !== undefined ? { bundlePolicy: bundlePolicy.bundlePolicy } : {},
|
|
75142
75500
|
...deadResidue !== undefined ? { deadResidue } : {}
|
|
75143
75501
|
};
|
|
75144
75502
|
}
|
|
@@ -75148,9 +75506,9 @@ function applyStateMigrations() {
|
|
|
75148
75506
|
}
|
|
75149
75507
|
|
|
75150
75508
|
// scripts/akm-migrate/main.ts
|
|
75151
|
-
function printPlan(
|
|
75152
|
-
console.log(JSON.stringify(
|
|
75153
|
-
if (
|
|
75509
|
+
function printPlan(plan4) {
|
|
75510
|
+
console.log(JSON.stringify(plan4));
|
|
75511
|
+
if (plan4.status === "blocked")
|
|
75154
75512
|
process.exitCode = EXIT_CODES2.GENERAL;
|
|
75155
75513
|
}
|
|
75156
75514
|
async function main(args = process.argv.slice(2)) {
|