akm-cli 0.10.261124 → 0.10.261125-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 +21 -0
- package/dist/cli.js +10 -0
- package/dist/commands/feedback-cli.js +12 -3
- package/dist/commands/health/semantic-search-check.js +12 -2
- package/dist/commands/health.js +8 -15
- package/dist/commands/lint/index.js +6 -6
- package/dist/commands/read/knowledge.js +8 -8
- package/dist/commands/read/related.js +3 -9
- package/dist/commands/read/show.js +17 -9
- package/dist/commands/sources/bundle-cli.js +1 -0
- package/dist/commands/sources/installed-stashes.js +36 -27
- package/dist/core/asset/resolve-ref.js +8 -0
- package/dist/core/common.js +21 -0
- package/dist/core/endpoint-url.js +4 -4
- package/dist/core/events.js +8 -2
- package/dist/core/file-lock.js +52 -1
- package/dist/core/state-db.js +47 -15
- package/dist/core/stdio-reader-gone.js +19 -0
- package/dist/core/write-source.js +2 -2
- package/dist/indexer/index-build.js +6 -3
- package/dist/indexer/index-readiness.js +30 -4
- package/dist/indexer/indexer.js +56 -8
- package/dist/indexer/search/db-search.js +7 -1
- package/dist/indexer/search/search-source.js +23 -25
- package/dist/indexer/usage/usage-events.js +13 -4
- package/dist/registry/origin-resolve.js +2 -3
- package/dist/scripts/akm-migrate-node.js +118 -72
- package/dist/scripts/akm-migrate.js +118 -72
- package/dist/setup/endpoint.js +1 -1
- package/dist/storage/repositories/index-connection.js +44 -41
- package/dist/storage/repositories/index-entries-repository.js +14 -7
- package/dist/storage/repositories/index-entry-schema.js +7 -5
- package/dist/storage/repositories/index-schema.js +23 -0
- package/dist/workspace/assets.js +24 -44
- package/dist/workspace/bundle-files.js +2 -2
- package/dist/workspace/documents.js +7 -12
- package/dist/workspace/graph-topics.js +249 -0
- package/dist/workspace/graph.js +68 -4
- package/docs/reference/workspace.md +21 -4
- package/package.json +1 -1
|
@@ -28761,8 +28761,27 @@ function tryAcquireLockSync(lockPath, payload) {
|
|
|
28761
28761
|
}
|
|
28762
28762
|
if (snapshot.rawContent !== payload)
|
|
28763
28763
|
return;
|
|
28764
|
+
acquiredByThisProcess.set(lockPath, payload);
|
|
28764
28765
|
return { lockPath, ...snapshot };
|
|
28765
28766
|
}
|
|
28767
|
+
function processIdentity(pid) {
|
|
28768
|
+
try {
|
|
28769
|
+
const bootId = fs4.readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
28770
|
+
const stat = fs4.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
28771
|
+
const startTime = stat.slice(stat.lastIndexOf(")") + 2).split(" ")[19];
|
|
28772
|
+
return bootId && startTime ? { bootId, startTime } : undefined;
|
|
28773
|
+
} catch {
|
|
28774
|
+
return;
|
|
28775
|
+
}
|
|
28776
|
+
}
|
|
28777
|
+
function holderPidReused(holderPid, recorded) {
|
|
28778
|
+
if (typeof recorded.bootId !== "string" || typeof recorded.startTime !== "string")
|
|
28779
|
+
return false;
|
|
28780
|
+
const current = processIdentity(holderPid);
|
|
28781
|
+
if (!current)
|
|
28782
|
+
return false;
|
|
28783
|
+
return current.bootId !== recorded.bootId || current.startTime !== recorded.startTime;
|
|
28784
|
+
}
|
|
28766
28785
|
function launcherPidFromEnv() {
|
|
28767
28786
|
const raw = process.env.AKM_LAUNCHER_PID;
|
|
28768
28787
|
if (!raw)
|
|
@@ -28775,6 +28794,7 @@ function createLockPayload(metadata = {}) {
|
|
|
28775
28794
|
return JSON.stringify({
|
|
28776
28795
|
...metadata,
|
|
28777
28796
|
pid: process.pid,
|
|
28797
|
+
...processIdentity(process.pid),
|
|
28778
28798
|
...launcherPid !== undefined ? { launcherPid } : {},
|
|
28779
28799
|
lockId: randomUUID()
|
|
28780
28800
|
});
|
|
@@ -28800,6 +28820,10 @@ function probeLock(lockPath) {
|
|
|
28800
28820
|
if (!isProcessAlive(holderPid)) {
|
|
28801
28821
|
return { state: "stale", reason: "pid_dead", holderPid, launcherPid, ageMs, rawContent, identity: identity3 };
|
|
28802
28822
|
}
|
|
28823
|
+
const ownLeftover = holderPid === process.pid && acquiredByThisProcess.get(lockPath) !== rawContent;
|
|
28824
|
+
if (ownLeftover || holderPidReused(holderPid, parseLockJson(rawContent))) {
|
|
28825
|
+
return { state: "stale", reason: "pid_reused", holderPid, launcherPid, ageMs, rawContent, identity: identity3 };
|
|
28826
|
+
}
|
|
28803
28827
|
return { state: "held", holderPid, launcherPid, ageMs, rawContent, identity: identity3 };
|
|
28804
28828
|
}
|
|
28805
28829
|
function reclaimStaleLock(lockPath, probe, options) {
|
|
@@ -28857,6 +28881,8 @@ function reclaimStaleLock(lockPath, probe, options) {
|
|
|
28857
28881
|
}
|
|
28858
28882
|
function releaseLock(ownership) {
|
|
28859
28883
|
const { lockPath } = ownership;
|
|
28884
|
+
if (acquiredByThisProcess.get(lockPath) === ownership.rawContent)
|
|
28885
|
+
acquiredByThisProcess.delete(lockPath);
|
|
28860
28886
|
let current;
|
|
28861
28887
|
try {
|
|
28862
28888
|
current = readLockSnapshot(lockPath);
|
|
@@ -28867,6 +28893,14 @@ function releaseLock(ownership) {
|
|
|
28867
28893
|
releaseLockRaw(lockPath);
|
|
28868
28894
|
}
|
|
28869
28895
|
}
|
|
28896
|
+
function parseLockJson(content) {
|
|
28897
|
+
try {
|
|
28898
|
+
const parsed = JSON.parse(content);
|
|
28899
|
+
return typeof parsed === "object" && parsed !== null ? parsed : {};
|
|
28900
|
+
} catch {
|
|
28901
|
+
return {};
|
|
28902
|
+
}
|
|
28903
|
+
}
|
|
28870
28904
|
function extractLockIdentity(content) {
|
|
28871
28905
|
const trimmed = content.trim();
|
|
28872
28906
|
if (!trimmed)
|
|
@@ -28887,9 +28921,10 @@ function extractLockIdentity(content) {
|
|
|
28887
28921
|
const pid = Number.parseInt(trimmed, 10);
|
|
28888
28922
|
return { holderPid: Number.isInteger(pid) && pid > 0 ? pid : undefined };
|
|
28889
28923
|
}
|
|
28890
|
-
var UNINITIALISED_LOCK_GRACE_MS = 2000;
|
|
28924
|
+
var acquiredByThisProcess, UNINITIALISED_LOCK_GRACE_MS = 2000;
|
|
28891
28925
|
var init_file_lock = __esm(() => {
|
|
28892
28926
|
init_common();
|
|
28927
|
+
acquiredByThisProcess = new Map;
|
|
28893
28928
|
});
|
|
28894
28929
|
|
|
28895
28930
|
// src/core/config/config-io.ts
|
|
@@ -32722,7 +32757,7 @@ function sameEndpoint(a, b) {
|
|
|
32722
32757
|
}
|
|
32723
32758
|
var OPERATION_SUFFIX;
|
|
32724
32759
|
var init_endpoint_url = __esm(() => {
|
|
32725
|
-
OPERATION_SUFFIX = /\/(?:chat\/completions|embeddings)
|
|
32760
|
+
OPERATION_SUFFIX = /\/(?:chat\/completions|completions|embeddings|models)$/i;
|
|
32726
32761
|
});
|
|
32727
32762
|
|
|
32728
32763
|
// src/core/config/credentials.ts
|
|
@@ -35190,16 +35225,34 @@ function migrateStateDatabase(db, dbPath) {
|
|
|
35190
35225
|
db.exec("VACUUM");
|
|
35191
35226
|
return backupPath ? { applied, backupPath } : { applied };
|
|
35192
35227
|
}
|
|
35228
|
+
function isStateDbCorruption(error62) {
|
|
35229
|
+
const code = error62?.code;
|
|
35230
|
+
if (code === "SQLITE_NOTADB" || code === "SQLITE_CORRUPT" || code === "SQLITE_IOERR_SHORT_READ")
|
|
35231
|
+
return true;
|
|
35232
|
+
return /not a database|disk image is malformed|SQLITE_CORRUPT/i.test(error62 instanceof Error ? error62.message : String(error62));
|
|
35233
|
+
}
|
|
35234
|
+
function classifyStateDbError(error62, dbPath) {
|
|
35235
|
+
if (error62 instanceof ConfigError || !isStateDbCorruption(error62))
|
|
35236
|
+
return error62;
|
|
35237
|
+
return damagedStateDbError(dbPath, error62 instanceof Error ? error62.message : String(error62));
|
|
35238
|
+
}
|
|
35239
|
+
function damagedStateDbError(dbPath, detail) {
|
|
35240
|
+
return new ConfigError(`state.db at ${dbPath} is damaged (${detail}).`, "INVALID_CONFIG_FILE", "state.db holds non-regenerable state. Back it up, then recover it with " + '`sqlite3 -readonly state.db ".recover" | sqlite3 state.new.db`, or restore a copy; if nothing can be recovered, move it aside and the next akm command creates a new one.');
|
|
35241
|
+
}
|
|
35193
35242
|
function openAndMigrate(dbPath) {
|
|
35194
35243
|
let report = { applied: [] };
|
|
35195
|
-
|
|
35196
|
-
|
|
35197
|
-
|
|
35198
|
-
|
|
35199
|
-
|
|
35200
|
-
|
|
35201
|
-
|
|
35202
|
-
|
|
35244
|
+
try {
|
|
35245
|
+
const db = openManagedDatabase({
|
|
35246
|
+
path: dbPath,
|
|
35247
|
+
pragmas: { dataDir: path23.dirname(dbPath) },
|
|
35248
|
+
init: (handle) => {
|
|
35249
|
+
report = migrateStateDatabase(handle, dbPath);
|
|
35250
|
+
}
|
|
35251
|
+
});
|
|
35252
|
+
return { db, ...report };
|
|
35253
|
+
} catch (error62) {
|
|
35254
|
+
throw classifyStateDbError(error62, dbPath);
|
|
35255
|
+
}
|
|
35203
35256
|
}
|
|
35204
35257
|
function listPendingStateMigrations(dbPath = getStateDbPath()) {
|
|
35205
35258
|
if (!fs20.existsSync(dbPath))
|
|
@@ -35227,6 +35280,7 @@ var init_state_db = __esm(() => {
|
|
|
35227
35280
|
init_sqlite_migrations();
|
|
35228
35281
|
init_sqlite_pragmas();
|
|
35229
35282
|
init_version2();
|
|
35283
|
+
init_errors();
|
|
35230
35284
|
init_paths();
|
|
35231
35285
|
init_migrations();
|
|
35232
35286
|
init_warn();
|
|
@@ -69436,7 +69490,6 @@ var init_website_ingest = __esm(() => {
|
|
|
69436
69490
|
});
|
|
69437
69491
|
|
|
69438
69492
|
// src/indexer/search/search-source.ts
|
|
69439
|
-
import fs47 from "node:fs";
|
|
69440
69493
|
import path54 from "node:path";
|
|
69441
69494
|
function implicitStashDir(config2, overrideStashDir) {
|
|
69442
69495
|
if (overrideStashDir !== undefined)
|
|
@@ -69453,21 +69506,13 @@ function resolveSourceEntries(overrideStashDir, existingConfig) {
|
|
|
69453
69506
|
if (implicitConfiguredBundle && !isBundleEnabled(config2, implicitConfiguredBundle)) {
|
|
69454
69507
|
throw new ConfigError(`The requested working source is disabled as bundle ${JSON.stringify(implicitConfiguredBundle)}.`, "INVALID_CONFIG_FILE");
|
|
69455
69508
|
}
|
|
69456
|
-
const sources = implicitStash ? [{ path: implicitStash, writable: true, isDefault: true, type: "filesystem" }] : [];
|
|
69457
|
-
const
|
|
69458
|
-
const resolved = path54.resolve(dir);
|
|
69459
|
-
try {
|
|
69460
|
-
return fs47.realpathSync.native(resolved);
|
|
69461
|
-
} catch {
|
|
69462
|
-
return resolved;
|
|
69463
|
-
}
|
|
69464
|
-
};
|
|
69465
|
-
const seen = new Set(implicitStash ? [sourceIdentity(implicitStash)] : []);
|
|
69509
|
+
const sources = implicitStash ? [{ path: safeRealpath(implicitStash), writable: true, isDefault: true, type: "filesystem" }] : [];
|
|
69510
|
+
const seen = new Set(implicitStash ? [safeRealpath(implicitStash)] : []);
|
|
69466
69511
|
const addSource = (dir, registryId, writable, type, adapterId, unresolved = false, isDefault = false) => {
|
|
69467
69512
|
const resolved = path54.resolve(dir);
|
|
69468
|
-
const identity3 =
|
|
69513
|
+
const identity3 = safeRealpath(resolved);
|
|
69469
69514
|
if (seen.has(identity3)) {
|
|
69470
|
-
const existing = sources.find((source) =>
|
|
69515
|
+
const existing = sources.find((source) => safeRealpath(source.path) === identity3);
|
|
69471
69516
|
if (existing && existing.registryId === undefined) {
|
|
69472
69517
|
if (registryId)
|
|
69473
69518
|
existing.registryId = registryId;
|
|
@@ -69486,7 +69531,7 @@ function resolveSourceEntries(overrideStashDir, existingConfig) {
|
|
|
69486
69531
|
warn(`Warning: stash root "${dir}" appears to be a system directory. This may be unintentional.`);
|
|
69487
69532
|
}
|
|
69488
69533
|
sources.push({
|
|
69489
|
-
path:
|
|
69534
|
+
path: identity3,
|
|
69490
69535
|
...registryId ? { registryId } : {},
|
|
69491
69536
|
...isDefault ? { isDefault: true } : {},
|
|
69492
69537
|
writable,
|
|
@@ -69571,6 +69616,7 @@ var init_search_source = __esm(() => {
|
|
|
69571
69616
|
// src/registry/origin-resolve.ts
|
|
69572
69617
|
var init_origin_resolve = __esm(() => {
|
|
69573
69618
|
init_asset_ref();
|
|
69619
|
+
init_common();
|
|
69574
69620
|
init_installations();
|
|
69575
69621
|
init_resolve();
|
|
69576
69622
|
});
|
|
@@ -69642,9 +69688,9 @@ var init_env_secret_ref = __esm(() => {
|
|
|
69642
69688
|
});
|
|
69643
69689
|
|
|
69644
69690
|
// src/core/secret-value.ts
|
|
69645
|
-
import
|
|
69691
|
+
import fs47 from "node:fs";
|
|
69646
69692
|
function readValue(secretPath) {
|
|
69647
|
-
return
|
|
69693
|
+
return fs47.readFileSync(secretPath, "utf8").trim();
|
|
69648
69694
|
}
|
|
69649
69695
|
var init_secret_value = () => {};
|
|
69650
69696
|
|
|
@@ -72858,7 +72904,7 @@ init_secret_seam();
|
|
|
72858
72904
|
|
|
72859
72905
|
// scripts/akm-migrate/migrate/dead-residue.ts
|
|
72860
72906
|
init_paths();
|
|
72861
|
-
import
|
|
72907
|
+
import fs48 from "node:fs";
|
|
72862
72908
|
import path55 from "node:path";
|
|
72863
72909
|
var DEAD_RESIDUE_PATHS = [
|
|
72864
72910
|
{ name: "proposals", reason: "superseded by the `proposals` table in $DATA/state.db (0.9.0)" },
|
|
@@ -72876,7 +72922,7 @@ function dirSizeBytes(target) {
|
|
|
72876
72922
|
let total = 0;
|
|
72877
72923
|
let entries;
|
|
72878
72924
|
try {
|
|
72879
|
-
entries =
|
|
72925
|
+
entries = fs48.readdirSync(target, { withFileTypes: true });
|
|
72880
72926
|
} catch {
|
|
72881
72927
|
return 0;
|
|
72882
72928
|
}
|
|
@@ -72886,14 +72932,14 @@ function dirSizeBytes(target) {
|
|
|
72886
72932
|
total += dirSizeBytes(entryPath);
|
|
72887
72933
|
} else if (entry.isFile()) {
|
|
72888
72934
|
try {
|
|
72889
|
-
total +=
|
|
72935
|
+
total += fs48.statSync(entryPath).size;
|
|
72890
72936
|
} catch {}
|
|
72891
72937
|
}
|
|
72892
72938
|
}
|
|
72893
72939
|
return total;
|
|
72894
72940
|
}
|
|
72895
72941
|
function sizeOf(target) {
|
|
72896
|
-
const st2 =
|
|
72942
|
+
const st2 = fs48.statSync(target);
|
|
72897
72943
|
return st2.isDirectory() ? dirSizeBytes(target) : st2.size;
|
|
72898
72944
|
}
|
|
72899
72945
|
function hostResidue() {
|
|
@@ -72912,7 +72958,7 @@ function hostResidue() {
|
|
|
72912
72958
|
const found = [];
|
|
72913
72959
|
const claimed = new Set;
|
|
72914
72960
|
for (const entry of named) {
|
|
72915
|
-
if (claimed.has(entry.absolutePath) || !
|
|
72961
|
+
if (claimed.has(entry.absolutePath) || !fs48.existsSync(entry.absolutePath))
|
|
72916
72962
|
continue;
|
|
72917
72963
|
try {
|
|
72918
72964
|
found.push({ ...entry, relativePath: entry.absolutePath, sizeBytes: sizeOf(entry.absolutePath) });
|
|
@@ -72936,7 +72982,7 @@ function hostResidue() {
|
|
|
72936
72982
|
function findSidecars(root, depth, skip) {
|
|
72937
72983
|
let entries;
|
|
72938
72984
|
try {
|
|
72939
|
-
entries =
|
|
72985
|
+
entries = fs48.readdirSync(root, { withFileTypes: true });
|
|
72940
72986
|
} catch {
|
|
72941
72987
|
return [];
|
|
72942
72988
|
}
|
|
@@ -72958,7 +73004,7 @@ function findDeadResidueEntries(stashDir) {
|
|
|
72958
73004
|
const akmDir = path55.join(stashDir, ".akm");
|
|
72959
73005
|
let names;
|
|
72960
73006
|
try {
|
|
72961
|
-
names =
|
|
73007
|
+
names = fs48.readdirSync(akmDir);
|
|
72962
73008
|
} catch {
|
|
72963
73009
|
return host;
|
|
72964
73010
|
}
|
|
@@ -72984,7 +73030,7 @@ function removeDeadResidue(stashDir) {
|
|
|
72984
73030
|
const entries = findDeadResidueEntries(stashDir);
|
|
72985
73031
|
return entries.map((entry) => {
|
|
72986
73032
|
try {
|
|
72987
|
-
|
|
73033
|
+
fs48.rmSync(entry.absolutePath, { recursive: true, force: true });
|
|
72988
73034
|
return { relativePath: entry.relativePath, sizeBytes: entry.sizeBytes, removed: true };
|
|
72989
73035
|
} catch (error62) {
|
|
72990
73036
|
return {
|
|
@@ -73014,7 +73060,7 @@ init_errors();
|
|
|
73014
73060
|
init_write_source();
|
|
73015
73061
|
init_search_source();
|
|
73016
73062
|
init_lockfile();
|
|
73017
|
-
import
|
|
73063
|
+
import fs49 from "node:fs";
|
|
73018
73064
|
import os10 from "node:os";
|
|
73019
73065
|
import path56 from "node:path";
|
|
73020
73066
|
function expandTilde(value) {
|
|
@@ -73026,7 +73072,7 @@ function expandTilde(value) {
|
|
|
73026
73072
|
}
|
|
73027
73073
|
function existingDirectory(target) {
|
|
73028
73074
|
try {
|
|
73029
|
-
return
|
|
73075
|
+
return fs49.statSync(target).isDirectory();
|
|
73030
73076
|
} catch (cause) {
|
|
73031
73077
|
if (cause.code === "ENOENT")
|
|
73032
73078
|
return false;
|
|
@@ -73277,14 +73323,14 @@ function planEngineKeys(inputs, resolve) {
|
|
|
73277
73323
|
|
|
73278
73324
|
// scripts/akm-migrate/migrate/engine-key-files.ts
|
|
73279
73325
|
init_walker();
|
|
73280
|
-
import
|
|
73326
|
+
import fs51 from "node:fs";
|
|
73281
73327
|
import path59 from "node:path";
|
|
73282
73328
|
|
|
73283
73329
|
// scripts/akm-migrate/migrate/task-files.ts
|
|
73284
73330
|
init_errors();
|
|
73285
73331
|
init_task_source_v4();
|
|
73286
73332
|
import crypto5 from "node:crypto";
|
|
73287
|
-
import
|
|
73333
|
+
import fs50 from "node:fs";
|
|
73288
73334
|
import path58 from "node:path";
|
|
73289
73335
|
|
|
73290
73336
|
// scripts/akm-migrate/migrate/task-to-v4.ts
|
|
@@ -74342,14 +74388,14 @@ function contained(root, candidate) {
|
|
|
74342
74388
|
return relative === "" || !relative.startsWith("..") && !path58.isAbsolute(relative);
|
|
74343
74389
|
}
|
|
74344
74390
|
function realDirectory(filePath) {
|
|
74345
|
-
const stat =
|
|
74391
|
+
const stat = fs50.lstatSync(filePath);
|
|
74346
74392
|
if (stat.isSymbolicLink() || !stat.isDirectory())
|
|
74347
74393
|
throw migrationError(`${filePath} must be a real directory.`);
|
|
74348
|
-
return
|
|
74394
|
+
return fs50.realpathSync(filePath);
|
|
74349
74395
|
}
|
|
74350
74396
|
function isWritable(filePath) {
|
|
74351
74397
|
try {
|
|
74352
|
-
|
|
74398
|
+
fs50.accessSync(filePath, fs50.constants.W_OK);
|
|
74353
74399
|
return true;
|
|
74354
74400
|
} catch {
|
|
74355
74401
|
return false;
|
|
@@ -74362,11 +74408,11 @@ function walkRootFiles(root, directory, extension, onLink, visit3) {
|
|
|
74362
74408
|
throw migrationError(`${root.root} resolves outside bundle ${root.bundleId}.`);
|
|
74363
74409
|
}
|
|
74364
74410
|
const walk = (current) => {
|
|
74365
|
-
const physicalDirectory =
|
|
74411
|
+
const physicalDirectory = fs50.realpathSync(current);
|
|
74366
74412
|
if (!contained(physicalRoot, physicalDirectory)) {
|
|
74367
74413
|
throw migrationError(`${current} resolves outside bundle ${root.bundleId}.`);
|
|
74368
74414
|
}
|
|
74369
|
-
for (const entry of
|
|
74415
|
+
for (const entry of fs50.readdirSync(current, { withFileTypes: true }).sort((a3, b) => a3.name.localeCompare(b.name))) {
|
|
74370
74416
|
const candidate = path58.join(current, entry.name);
|
|
74371
74417
|
if (entry.isSymbolicLink()) {
|
|
74372
74418
|
onLink(candidate);
|
|
@@ -74386,11 +74432,11 @@ function walkTasks(root, tasksDir, out) {
|
|
|
74386
74432
|
walkRootFiles(root, tasksDir, ".yml", (link) => {
|
|
74387
74433
|
throw migrationError(`task migration does not follow symbolic link ${link}.`);
|
|
74388
74434
|
}, (candidate, directory) => {
|
|
74389
|
-
const stat =
|
|
74435
|
+
const stat = fs50.lstatSync(candidate);
|
|
74390
74436
|
const mode = stat.mode & 511;
|
|
74391
74437
|
out.push({
|
|
74392
74438
|
filePath: candidate,
|
|
74393
|
-
bytes:
|
|
74439
|
+
bytes: fs50.readFileSync(candidate),
|
|
74394
74440
|
mode,
|
|
74395
74441
|
writable: root.writable,
|
|
74396
74442
|
onDiskWritable: isWritable(candidate) && isWritable(directory) && (mode & 146) !== 0
|
|
@@ -74402,7 +74448,7 @@ function inspectTaskFiles(roots) {
|
|
|
74402
74448
|
for (const root of [...roots].sort((a3, b) => a3.bundleId.localeCompare(b.bundleId))) {
|
|
74403
74449
|
const tasksDir = root.layout === "akm-task" ? root.root : path58.join(root.root, "tasks");
|
|
74404
74450
|
try {
|
|
74405
|
-
const stat =
|
|
74451
|
+
const stat = fs50.lstatSync(tasksDir);
|
|
74406
74452
|
if (stat.isSymbolicLink())
|
|
74407
74453
|
throw migrationError(`task migration does not follow symbolic link ${tasksDir}.`);
|
|
74408
74454
|
if (!stat.isDirectory())
|
|
@@ -74427,11 +74473,11 @@ function fsyncDirectory(directory) {
|
|
|
74427
74473
|
if (process.platform === "win32")
|
|
74428
74474
|
return;
|
|
74429
74475
|
try {
|
|
74430
|
-
const fd =
|
|
74476
|
+
const fd = fs50.openSync(directory, "r");
|
|
74431
74477
|
try {
|
|
74432
|
-
|
|
74478
|
+
fs50.fsyncSync(fd);
|
|
74433
74479
|
} finally {
|
|
74434
|
-
|
|
74480
|
+
fs50.closeSync(fd);
|
|
74435
74481
|
}
|
|
74436
74482
|
} catch (cause) {
|
|
74437
74483
|
const code = cause.code;
|
|
@@ -74440,30 +74486,30 @@ function fsyncDirectory(directory) {
|
|
|
74440
74486
|
}
|
|
74441
74487
|
}
|
|
74442
74488
|
function writeDurable(filePath, bytes, mode, exclusive = false) {
|
|
74443
|
-
|
|
74444
|
-
const fd =
|
|
74489
|
+
fs50.mkdirSync(path58.dirname(filePath), { recursive: true });
|
|
74490
|
+
const fd = fs50.openSync(filePath, exclusive ? "wx" : "w", mode);
|
|
74445
74491
|
try {
|
|
74446
|
-
|
|
74447
|
-
|
|
74492
|
+
fs50.writeFileSync(fd, bytes);
|
|
74493
|
+
fs50.fsyncSync(fd);
|
|
74448
74494
|
} finally {
|
|
74449
|
-
|
|
74495
|
+
fs50.closeSync(fd);
|
|
74450
74496
|
}
|
|
74451
|
-
|
|
74497
|
+
fs50.chmodSync(filePath, mode);
|
|
74452
74498
|
fsyncDirectory(path58.dirname(filePath));
|
|
74453
74499
|
}
|
|
74454
74500
|
function replaceAtomically(filePath, bytes, mode) {
|
|
74455
74501
|
const temporary = path58.join(path58.dirname(filePath), `.${path58.basename(filePath)}.migrate-${crypto5.randomUUID()}`);
|
|
74456
74502
|
try {
|
|
74457
74503
|
writeDurable(temporary, bytes, mode, true);
|
|
74458
|
-
|
|
74504
|
+
fs50.renameSync(temporary, filePath);
|
|
74459
74505
|
fsyncDirectory(path58.dirname(filePath));
|
|
74460
74506
|
} finally {
|
|
74461
|
-
|
|
74507
|
+
fs50.rmSync(temporary, { force: true });
|
|
74462
74508
|
}
|
|
74463
74509
|
}
|
|
74464
74510
|
function holds(filePath, bytes) {
|
|
74465
74511
|
try {
|
|
74466
|
-
return
|
|
74512
|
+
return fs50.readFileSync(filePath).equals(bytes);
|
|
74467
74513
|
} catch {
|
|
74468
74514
|
return false;
|
|
74469
74515
|
}
|
|
@@ -74483,7 +74529,7 @@ function replaceFilesWithBackups(changes, backupRoot) {
|
|
|
74483
74529
|
try {
|
|
74484
74530
|
for (const change of backedUp) {
|
|
74485
74531
|
if (!holds(change.filePath, change.before)) {
|
|
74486
|
-
|
|
74532
|
+
fs50.rmSync(taskFileBackupPath(backupRoot, change.filePath), { force: true });
|
|
74487
74533
|
conflicts.push(change.filePath);
|
|
74488
74534
|
continue;
|
|
74489
74535
|
}
|
|
@@ -74494,7 +74540,7 @@ function replaceFilesWithBackups(changes, backupRoot) {
|
|
|
74494
74540
|
const unrestored = [];
|
|
74495
74541
|
for (const change of [...replaced].reverse()) {
|
|
74496
74542
|
if (holds(change.filePath, change.after)) {
|
|
74497
|
-
replaceAtomically(change.filePath,
|
|
74543
|
+
replaceAtomically(change.filePath, fs50.readFileSync(taskFileBackupPath(backupRoot, change.filePath)), change.mode);
|
|
74498
74544
|
} else {
|
|
74499
74545
|
unrestored.push(change.filePath);
|
|
74500
74546
|
}
|
|
@@ -74540,7 +74586,7 @@ var LAYOUTS = new Map([
|
|
|
74540
74586
|
function collect(root, directory, role, extension, out) {
|
|
74541
74587
|
let top;
|
|
74542
74588
|
try {
|
|
74543
|
-
top =
|
|
74589
|
+
top = fs51.lstatSync(directory);
|
|
74544
74590
|
} catch (cause) {
|
|
74545
74591
|
if (cause.code === "ENOENT")
|
|
74546
74592
|
return;
|
|
@@ -74553,8 +74599,8 @@ function collect(root, directory, role, extension, out) {
|
|
|
74553
74599
|
return;
|
|
74554
74600
|
out.set(link, {
|
|
74555
74601
|
filePath: link,
|
|
74556
|
-
bytes:
|
|
74557
|
-
mode:
|
|
74602
|
+
bytes: fs51.readFileSync(link),
|
|
74603
|
+
mode: fs51.statSync(link).mode & 511,
|
|
74558
74604
|
role,
|
|
74559
74605
|
writable: root.writable,
|
|
74560
74606
|
link: true
|
|
@@ -74564,8 +74610,8 @@ function collect(root, directory, role, extension, out) {
|
|
|
74564
74610
|
return;
|
|
74565
74611
|
out.set(candidate, {
|
|
74566
74612
|
filePath: candidate,
|
|
74567
|
-
bytes:
|
|
74568
|
-
mode:
|
|
74613
|
+
bytes: fs51.readFileSync(candidate),
|
|
74614
|
+
mode: fs51.lstatSync(candidate).mode & 511,
|
|
74569
74615
|
role,
|
|
74570
74616
|
writable: root.writable
|
|
74571
74617
|
});
|
|
@@ -74698,7 +74744,7 @@ init_paths();
|
|
|
74698
74744
|
init_walker();
|
|
74699
74745
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
74700
74746
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
74701
|
-
import
|
|
74747
|
+
import fs52 from "node:fs";
|
|
74702
74748
|
import path61 from "node:path";
|
|
74703
74749
|
|
|
74704
74750
|
// scripts/akm-migrate/migrate/content-ref-planner.ts
|
|
@@ -74762,7 +74808,7 @@ function contentRefRewriter(bundles) {
|
|
|
74762
74808
|
// scripts/akm-migrate/content-ref-migrate.ts
|
|
74763
74809
|
var TEXT_EXTENSIONS = new Set([".md", ".yml", ".yaml", ".sh", ".ts", ".js", ".json", ".txt", ".py", ".mjs", ".jsonc", ".toml", ""]);
|
|
74764
74810
|
function textFiles(root) {
|
|
74765
|
-
return walkStashFlat(root).filter((file2) => TEXT_EXTENSIONS.has(file2.ext) &&
|
|
74811
|
+
return walkStashFlat(root).filter((file2) => TEXT_EXTENSIONS.has(file2.ext) && fs52.lstatSync(file2.absPath).isFile()).map((file2) => file2.absPath);
|
|
74766
74812
|
}
|
|
74767
74813
|
function bundleDocuments(roots) {
|
|
74768
74814
|
const bundles = new Map;
|
|
@@ -74798,7 +74844,7 @@ function gitReconcile(filePaths, backupPath) {
|
|
|
74798
74844
|
const topOf = new Map;
|
|
74799
74845
|
const byRoot = new Map;
|
|
74800
74846
|
for (const filePath of filePaths) {
|
|
74801
|
-
const real =
|
|
74847
|
+
const real = fs52.realpathSync(filePath);
|
|
74802
74848
|
const dir = path61.dirname(real);
|
|
74803
74849
|
if (!topOf.has(dir)) {
|
|
74804
74850
|
const top = spawnSync6("git", ["-C", dir, "rev-parse", "--show-toplevel"], { encoding: "utf8", env });
|
|
@@ -74827,7 +74873,7 @@ function plan2() {
|
|
|
74827
74873
|
if (seen.has(filePath) || !(documents.files.has(filePath) || isStructuralFile(root.root, adapterId, filePath, assetDirs)))
|
|
74828
74874
|
continue;
|
|
74829
74875
|
seen.add(filePath);
|
|
74830
|
-
const before =
|
|
74876
|
+
const before = fs52.readFileSync(filePath);
|
|
74831
74877
|
const text2 = before.toString("utf8");
|
|
74832
74878
|
if (!Buffer.from(text2, "utf8").equals(before))
|
|
74833
74879
|
continue;
|
|
@@ -74835,7 +74881,7 @@ function plan2() {
|
|
|
74835
74881
|
if (count === 0)
|
|
74836
74882
|
continue;
|
|
74837
74883
|
files.push({
|
|
74838
|
-
replacement: { filePath, before, after: Buffer.from(rewritten, "utf8"), mode:
|
|
74884
|
+
replacement: { filePath, before, after: Buffer.from(rewritten, "utf8"), mode: fs52.statSync(filePath).mode & 511 },
|
|
74839
74885
|
refs: count
|
|
74840
74886
|
});
|
|
74841
74887
|
}
|
|
@@ -74891,7 +74937,7 @@ init_config_io();
|
|
|
74891
74937
|
init_errors();
|
|
74892
74938
|
init_paths();
|
|
74893
74939
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
74894
|
-
import
|
|
74940
|
+
import fs53 from "node:fs";
|
|
74895
74941
|
import path62 from "node:path";
|
|
74896
74942
|
function taskRoots(config2) {
|
|
74897
74943
|
return bundleRoots(config2).flatMap((root) => {
|
|
@@ -74903,7 +74949,7 @@ function taskRoot(candidate) {
|
|
|
74903
74949
|
const { bundleId, bundleRoot, root, writable } = candidate;
|
|
74904
74950
|
const adapter = candidate.adapter ?? detectAdapterId(root, "");
|
|
74905
74951
|
if (!candidate.adapter && adapter === "") {
|
|
74906
|
-
const flatTasks =
|
|
74952
|
+
const flatTasks = fs53.readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".yml")).map((entry) => entry.name).sort();
|
|
74907
74953
|
if (flatTasks.length > 0) {
|
|
74908
74954
|
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");
|
|
74909
74955
|
}
|