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