akm-cli 0.9.1-beta.1 → 0.9.1-beta.2

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/dist/cli/parse-args.js +7 -1
  3. package/dist/commands/env/child-env.js +14 -0
  4. package/dist/commands/improve/eval-cases.js +2 -0
  5. package/dist/commands/improve/memory/memory-improve.js +1 -0
  6. package/dist/commands/lint/index.js +5 -1
  7. package/dist/commands/sources/add-cli.js +8 -2
  8. package/dist/commands/sources/migration-help.js +12 -3
  9. package/dist/commands/sources/self-update.js +9 -1
  10. package/dist/core/adapter/adapters/agent-skills-adapter.js +32 -16
  11. package/dist/core/adapter/adapters/akm-lint.js +6 -2
  12. package/dist/core/adapter/adapters/akm-task-adapter.js +4 -2
  13. package/dist/core/adapter/adapters/dotenv-adapter.js +21 -0
  14. package/dist/core/asset/frontmatter.js +6 -1
  15. package/dist/core/common.js +81 -3
  16. package/dist/core/config/config-io.js +5 -45
  17. package/dist/core/config/schema/engines.js +14 -3
  18. package/dist/core/extra-params.js +11 -0
  19. package/dist/core/fs-txn.js +15 -2
  20. package/dist/core/json-schema.js +19 -2
  21. package/dist/core/paths.js +16 -2
  22. package/dist/core/redaction.js +22 -1
  23. package/dist/core/state-db.js +1 -0
  24. package/dist/core/write-source.js +26 -2
  25. package/dist/indexer/indexer.js +31 -6
  26. package/dist/indexer/search/db-search.js +17 -2
  27. package/dist/indexer/walk/walker.js +6 -1
  28. package/dist/integrations/agent/detect.js +13 -1
  29. package/dist/integrations/harnesses/opencode-sdk/sdk-runner.js +21 -0
  30. package/dist/integrations/lockfile.js +10 -0
  31. package/dist/llm/client.js +14 -19
  32. package/dist/llm/embedder.js +23 -3
  33. package/dist/llm/embedders/remote.js +27 -2
  34. package/dist/output/html-render.js +40 -1
  35. package/dist/runtime.js +23 -1
  36. package/dist/scripts/akm-migrate-node.js +303 -107
  37. package/dist/scripts/akm-migrate.js +303 -107
  38. package/dist/setup/setup.js +22 -7
  39. package/dist/sources/providers/git-install.js +25 -2
  40. package/dist/sources/snapshot-fetchers/content-extract.js +63 -1
  41. package/dist/storage/database.js +71 -12
  42. package/dist/storage/engines/sqlite-migrations.js +61 -2
  43. package/dist/storage/repositories/index-connection.js +11 -1
  44. package/dist/storage/repositories/index-meta-repository.js +11 -0
  45. package/dist/storage/repositories/index-schema.js +17 -2
  46. package/dist/storage/repositories/index-vec-repository.js +43 -5
  47. package/dist/storage/sqlite-pragmas.js +12 -1
  48. package/dist/tasks/runner.js +84 -7
  49. package/dist/tasks/scheduler-invocation.js +19 -0
  50. package/dist/tasks/schema.js +21 -1
  51. package/dist/text-import-hook.mjs +1 -1
  52. package/dist/workflows/exec/native-executor.js +8 -0
  53. package/dist/workflows/exec/step-work.js +10 -2
  54. package/dist/workflows/parser.js +26 -1
  55. package/package.json +1 -1
  56. package/schemas/akm-config.json +10 -5
  57. package/schemas/akm-workflow.json +7 -3
@@ -7075,6 +7075,7 @@ var init_platform = __esm(() => {
7075
7075
  });
7076
7076
 
7077
7077
  // src/core/paths.ts
7078
+ import os from "os";
7078
7079
  import path from "path";
7079
7080
  function isUnderBunTest(env) {
7080
7081
  return env.BUN_TEST === "1" || env.NODE_ENV === "test";
@@ -7153,9 +7154,13 @@ function getCacheDir(env = process.env) {
7153
7154
  }
7154
7155
  const home = env.HOME?.trim();
7155
7156
  if (!home)
7156
- return path.join("/tmp", "akm-cache");
7157
+ return homelessFallbackDir("akm-cache");
7157
7158
  return path.join(home, ".cache", "akm");
7158
7159
  }
7160
+ function homelessFallbackDir(kind) {
7161
+ const uid = typeof process.getuid === "function" ? process.getuid() : undefined;
7162
+ return path.join(os.tmpdir(), uid === undefined ? kind : `${kind}-${uid}`);
7163
+ }
7159
7164
  function getDataDir(env = process.env, platform = process.platform) {
7160
7165
  const override = env.AKM_DATA_DIR?.trim();
7161
7166
  if (override)
@@ -7181,7 +7186,7 @@ function getDataDir(env = process.env, platform = process.platform) {
7181
7186
  return path.join(xdgDataHome, "akm");
7182
7187
  const home = env.HOME?.trim();
7183
7188
  if (!home)
7184
- return path.join("/tmp", "akm-data");
7189
+ return homelessFallbackDir("akm-data");
7185
7190
  return path.join(home, ".local", "share", "akm");
7186
7191
  }
7187
7192
  function getDbPath(env = process.env) {
@@ -7261,6 +7266,59 @@ function readTextFileWithLimit(filePath, maxBytes, label = "File") {
7261
7266
  fs.closeSync(fd);
7262
7267
  }
7263
7268
  }
7269
+ function stripJsonComments(text) {
7270
+ let result = "";
7271
+ let i = 0;
7272
+ let inString = false;
7273
+ while (i < text.length) {
7274
+ if (inString) {
7275
+ if (text[i] === "\\") {
7276
+ result += text[i] + (text[i + 1] ?? "");
7277
+ i += 2;
7278
+ continue;
7279
+ }
7280
+ if (text[i] === '"') {
7281
+ inString = false;
7282
+ }
7283
+ result += text[i];
7284
+ i++;
7285
+ continue;
7286
+ }
7287
+ if (text[i] === '"') {
7288
+ inString = true;
7289
+ result += text[i];
7290
+ i++;
7291
+ continue;
7292
+ }
7293
+ if (text[i] === "/" && text[i + 1] === "/") {
7294
+ while (i < text.length && text[i] !== `
7295
+ `)
7296
+ i++;
7297
+ continue;
7298
+ }
7299
+ if (text[i] === "/" && text[i + 1] === "*") {
7300
+ i += 2;
7301
+ while (i < text.length && !(text[i] === "*" && text[i + 1] === "/"))
7302
+ i++;
7303
+ i += 2;
7304
+ continue;
7305
+ }
7306
+ result += text[i];
7307
+ i++;
7308
+ }
7309
+ return result;
7310
+ }
7311
+ function existingFileMode(filePath) {
7312
+ try {
7313
+ return fs.statSync(filePath).mode & 511;
7314
+ } catch {
7315
+ try {
7316
+ return 438 & ~process.umask();
7317
+ } catch {
7318
+ return 420;
7319
+ }
7320
+ }
7321
+ }
7264
7322
  function writeFileAtomic(target, content, mode) {
7265
7323
  const tmp = `${target}.tmp.${process.pid}.${crypto.randomBytes(8).toString("hex")}`;
7266
7324
  const data = typeof content === "string" ? Buffer.from(content) : content;
@@ -7373,7 +7431,7 @@ function readStashDirFromConfig() {
7373
7431
  try {
7374
7432
  const configPath = getConfigPath();
7375
7433
  const text = readTextFileWithLimit(configPath, MAX_CONFIG_FILE_BYTES, "Config file");
7376
- const raw = JSON.parse(text);
7434
+ const raw = JSON.parse(stripJsonComments(text));
7377
7435
  if (typeof raw !== "object" || raw === null)
7378
7436
  return;
7379
7437
  const bundles = raw.bundles;
@@ -7662,8 +7720,8 @@ function isProcessAlive(pid) {
7662
7720
  try {
7663
7721
  process.kill(pid, 0);
7664
7722
  return true;
7665
- } catch {
7666
- return false;
7723
+ } catch (err) {
7724
+ return err?.code === "EPERM";
7667
7725
  }
7668
7726
  }
7669
7727
  var MAX_CONFIG_FILE_BYTES, MAX_LOCAL_METADATA_BYTES, MAX_LOCK_METADATA_BYTES, DEFAULT_RESPONSE_BYTE_CAP, ResponseTooLargeError, BodyReadTimeoutError;
@@ -7828,7 +7886,7 @@ var init_runtime = __esm(() => {
7828
7886
  var require_main = __commonJS((exports, module) => {
7829
7887
  var fs3 = __require("fs");
7830
7888
  var path7 = __require("path");
7831
- var os = __require("os");
7889
+ var os2 = __require("os");
7832
7890
  var crypto2 = __require("crypto");
7833
7891
  var TIPS = [
7834
7892
  "\u25C8 encrypted .env [www.dotenvx.com]",
@@ -7976,7 +8034,7 @@ var require_main = __commonJS((exports, module) => {
7976
8034
  return null;
7977
8035
  }
7978
8036
  function _resolveHome(envPath) {
7979
- return envPath[0] === "~" ? path7.join(os.homedir(), envPath.slice(1)) : envPath;
8037
+ return envPath[0] === "~" ? path7.join(os2.homedir(), envPath.slice(1)) : envPath;
7980
8038
  }
7981
8039
  function _configVault(options) {
7982
8040
  const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
@@ -8288,21 +8346,32 @@ function loadBunSqlite() {
8288
8346
  }
8289
8347
  return bunSqliteModule;
8290
8348
  }
8349
+ function abiMismatchRemedy(message) {
8350
+ const ABI_MISMATCH_SHAPES = [
8351
+ "did not self-register",
8352
+ "NODE_MODULE_VERSION",
8353
+ "was compiled against a different",
8354
+ "invalid ELF header"
8355
+ ];
8356
+ if (!ABI_MISMATCH_SHAPES.some((shape) => message.includes(shape)))
8357
+ return;
8358
+ return `akm could not load 'better-sqlite3': its native binding was built for a different
8359
+ ` + `Node.js version than the one now running (this Node is ABI ${process.versions.modules}).
8360
+ ` + `This is what happens when Node is upgraded after akm is installed. It is NOT a
8361
+ ` + `broken install, and reinstalling akm is not required.
8362
+ ` + ` Fix: npm rebuild better-sqlite3 # in akm's install directory
8363
+ ` + ` Or: npm install -g akm-cli # reinstall, rebuilding against this Node
8364
+ ` + " Or: run akm under Bun, whose built-in SQLite driver needs no native binding.";
8365
+ }
8291
8366
  function loadBetterSqlite3() {
8292
8367
  if (!betterSqlite3Ctor) {
8293
8368
  let mod;
8294
8369
  try {
8295
8370
  mod = nodeRequire2("better-sqlite3");
8296
8371
  } catch (err) {
8297
- throw new Error(`akm could not load 'better-sqlite3', the SQLite driver it needs on Node.js.
8298
- ` + ` \u2022 If the error below says the module was compiled against a DIFFERENT Node.js
8299
- ` + ` version, you upgraded Node after installing akm. Reinstall akm (or run
8300
- ` + " `npm rebuild better-sqlite3` in its install directory) so the binding is\n" + ` rebuilt for the Node you are now running. This is the common case after a
8301
- ` + ` Node major upgrade, and it is NOT a broken install.
8302
- ` + ` \u2022 Otherwise, reinstall akm with a working C/C++ build toolchain so its optional
8303
- ` + " 'better-sqlite3' native binding rebuilds (a global `npm i -g better-sqlite3`\n" + ` will NOT be resolved \u2014 Node loads it from akm's own node_modules).
8304
- ` + ` \u2022 Or run akm under Bun, which has a built-in SQLite driver and needs no native build.
8305
- ` + ` Underlying load error: ${err instanceof Error ? err.message : String(err)}`);
8372
+ const raw = err instanceof Error ? err.message : String(err);
8373
+ throw new Error(`${abiMismatchRemedy(raw) ?? MISSING_BINDING_REMEDY}
8374
+ Underlying load error: ${raw}`);
8306
8375
  }
8307
8376
  betterSqlite3Ctor = mod.default ?? mod;
8308
8377
  }
@@ -8315,11 +8384,22 @@ function openNodeDatabase(path10, opts) {
8315
8384
  options.readonly = opts.readonly;
8316
8385
  if (opts?.create === false)
8317
8386
  options.fileMustExist = true;
8318
- const db = opts ? new BetterSqlite3(path10, options) : new BetterSqlite3(path10);
8387
+ let db;
8388
+ try {
8389
+ db = opts ? new BetterSqlite3(path10, options) : new BetterSqlite3(path10);
8390
+ } catch (err) {
8391
+ const raw = err instanceof Error ? err.message : String(err);
8392
+ const remedy = abiMismatchRemedy(raw);
8393
+ if (!remedy)
8394
+ throw err;
8395
+ throw new Error(`${remedy}
8396
+ Underlying error: ${raw}`);
8397
+ }
8319
8398
  return {
8320
8399
  prepare: db.prepare.bind(db),
8321
8400
  exec: db.exec.bind(db),
8322
8401
  run: (sql, ...params) => db.prepare(sql).run(...params),
8402
+ loadExtension: db.loadExtension.bind(db),
8323
8403
  transaction: db.transaction.bind(db),
8324
8404
  get inTransaction() {
8325
8405
  return db.inTransaction;
@@ -8327,7 +8407,7 @@ function openNodeDatabase(path10, opts) {
8327
8407
  close: db.close.bind(db)
8328
8408
  };
8329
8409
  }
8330
- var isBun2, nodeRequire2, bunSqliteProvider, nodeSqliteProvider, PROVIDERS, bunSqliteModule, betterSqlite3Ctor;
8410
+ var isBun2, nodeRequire2, bunSqliteProvider, nodeSqliteProvider, PROVIDERS, bunSqliteModule, betterSqlite3Ctor, MISSING_BINDING_REMEDY;
8331
8411
  var init_database = __esm(() => {
8332
8412
  isBun2 = !!process.versions?.bun;
8333
8413
  nodeRequire2 = createRequire2(import.meta.url);
@@ -8342,6 +8422,10 @@ var init_database = __esm(() => {
8342
8422
  open: openNodeDatabase
8343
8423
  };
8344
8424
  PROVIDERS = [bunSqliteProvider, nodeSqliteProvider];
8425
+ MISSING_BINDING_REMEDY = `akm could not load 'better-sqlite3', the SQLite driver it needs on Node.js.
8426
+ ` + ` \u2022 Reinstall akm with a working C/C++ build toolchain so its optional
8427
+ ` + " 'better-sqlite3' native binding builds (a global `npm i -g better-sqlite3`\n" + ` will NOT be resolved \u2014 Node loads it from akm's own node_modules).
8428
+ ` + " \u2022 Or run akm under Bun, which has a built-in SQLite driver and needs no native build.";
8345
8429
  });
8346
8430
 
8347
8431
  // src/core/file-lock.ts
@@ -8760,12 +8844,43 @@ function runMigrations(db, migrations, opts) {
8760
8844
  if (applied.has(migration.id))
8761
8845
  continue;
8762
8846
  opts?.beforeMigration?.(migration);
8763
- db.transaction(() => {
8847
+ withImmediateWriteLock(db, () => {
8848
+ const already = db.prepare("SELECT 1 FROM schema_migrations WHERE id = ?").get(migration.id);
8849
+ if (already)
8850
+ return;
8764
8851
  db.exec(migration.up);
8765
8852
  db.prepare("INSERT INTO schema_migrations (id) VALUES (?)").run(migration.id);
8766
- })();
8853
+ });
8854
+ applied.add(migration.id);
8855
+ }
8856
+ }
8857
+ function withImmediateWriteLock(db, fn) {
8858
+ if (db.inTransaction) {
8859
+ fn();
8860
+ return;
8861
+ }
8862
+ let lastBeginErr;
8863
+ for (let attempt = 1;attempt <= IMMEDIATE_LOCK_MAX_ATTEMPTS; attempt++) {
8864
+ try {
8865
+ db.exec("BEGIN IMMEDIATE");
8866
+ } catch (err) {
8867
+ lastBeginErr = err;
8868
+ continue;
8869
+ }
8870
+ try {
8871
+ fn();
8872
+ db.exec("COMMIT");
8873
+ return;
8874
+ } catch (err) {
8875
+ try {
8876
+ db.exec("ROLLBACK");
8877
+ } catch {}
8878
+ throw err;
8879
+ }
8767
8880
  }
8881
+ throw lastBeginErr instanceof Error ? lastBeginErr : new Error(`could not acquire the migration write lock after ${IMMEDIATE_LOCK_MAX_ATTEMPTS} attempts`);
8768
8882
  }
8883
+ var IMMEDIATE_LOCK_MAX_ATTEMPTS = 5;
8769
8884
 
8770
8885
  // src/core/state/migrations.ts
8771
8886
  function runMigrations2(db, options) {
@@ -27019,7 +27134,7 @@ function applyStandardPragmas(db, opts = {}) {
27019
27134
  warnNetworkFallbackOnce(opts.dataDir);
27020
27135
  }
27021
27136
  }
27022
- db.exec("PRAGMA busy_timeout = 30000");
27137
+ db.exec(`PRAGMA busy_timeout = ${SQLITE_BUSY_TIMEOUT_MS}`);
27023
27138
  db.exec(`PRAGMA journal_mode = ${mode}`);
27024
27139
  if (opts.foreignKeys !== false) {
27025
27140
  db.exec("PRAGMA foreign_keys = ON");
@@ -27035,7 +27150,7 @@ function warnNetworkFallbackOnce(dataDir) {
27035
27150
  warnedNetworkFallback = true;
27036
27151
  warn(`[akm] network filesystem detected at ${dataDir} \u2014 WAL unsupported, using DELETE journal mode`);
27037
27152
  }
27038
- var VALID_MODES, warnedInvalid = false, warnedNetworkFallback = false, FS_MAGIC_NFS = 26985, FS_MAGIC_SMB = 20859, FS_MAGIC_CIFS = 4283649346, FS_MAGIC_SMB2 = 4266872130, FS_MAGIC_FUSE = 1702057286, NETWORK_FS_MAGICS;
27153
+ var VALID_MODES, warnedInvalid = false, warnedNetworkFallback = false, FS_MAGIC_NFS = 26985, FS_MAGIC_SMB = 20859, FS_MAGIC_CIFS = 4283649346, FS_MAGIC_SMB2 = 4266872130, FS_MAGIC_FUSE = 1702057286, NETWORK_FS_MAGICS, SQLITE_BUSY_TIMEOUT_MS = 30000;
27039
27154
  var init_sqlite_pragmas = __esm(() => {
27040
27155
  init_warn();
27041
27156
  init_runtime();
@@ -27128,6 +27243,7 @@ function openStateDatabase(dbPath) {
27128
27243
  exec: db.exec.bind(db),
27129
27244
  run: db.run.bind(db),
27130
27245
  transaction: db.transaction.bind(db),
27246
+ loadExtension: db.loadExtension.bind(db),
27131
27247
  get inTransaction() {
27132
27248
  return db.inTransaction;
27133
27249
  },
@@ -27600,13 +27716,14 @@ function purgeEmbeddings(db, opts) {
27600
27716
  }
27601
27717
  setMeta(db, "hasEmbeddings", "0");
27602
27718
  }
27603
- var vecStatus, VEC_DOCS_URL = "https://github.com/itlackey/akm/blob/main/docs/reference/configuration.md#sqlite-vec-extension", VEC_FALLBACK_THRESHOLD = 1e4, vecInitWarnedDbs;
27719
+ var vecStatus, vecTablePresent, VEC_DOCS_URL = "https://github.com/itlackey/akm/blob/main/docs/reference/configuration.md#sqlite-vec-extension", VEC_FALLBACK_THRESHOLD = 1e4, vecInitWarnedDbs;
27604
27720
  var init_index_vec_repository = __esm(() => {
27605
27721
  init_best_effort();
27606
27722
  init_warn();
27607
27723
  init_types();
27608
27724
  init_index_meta_repository();
27609
27725
  vecStatus = new WeakMap;
27726
+ vecTablePresent = new WeakMap;
27610
27727
  vecInitWarnedDbs = new WeakSet;
27611
27728
  });
27612
27729
 
@@ -27897,8 +28014,13 @@ function ensureBundleRefColumns(db) {
27897
28014
  }, "entries table may not exist on a brand-new DB before CREATE \u2014 caller is responsible");
27898
28015
  }
27899
28016
  function ensureUniqueItemRefIndex(db) {
27900
- db.exec("DROP INDEX IF EXISTS idx_entries_item_ref");
27901
- db.exec("CREATE UNIQUE INDEX idx_entries_item_ref ON entries(item_ref)");
28017
+ const existing = db.prepare("SELECT sql FROM sqlite_master WHERE type = 'index' AND name = 'idx_entries_item_ref'").get();
28018
+ if (existing?.sql && /\bUNIQUE\b/i.test(existing.sql))
28019
+ return;
28020
+ db.transaction(() => {
28021
+ db.exec("DROP INDEX IF EXISTS idx_entries_item_ref");
28022
+ db.exec("CREATE UNIQUE INDEX IF NOT EXISTS idx_entries_item_ref ON entries(item_ref)");
28023
+ })();
27902
28024
  }
27903
28025
  function tableExists2(db, name) {
27904
28026
  const row = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=? LIMIT 1").get(name);
@@ -28033,7 +28155,9 @@ function openReadonlyExistingDatabase(dbPath) {
28033
28155
  assertIndexPathReadable(resolvedPath);
28034
28156
  if (classifyPathAccess(resolvedPath).access === "absent")
28035
28157
  return;
28036
- return openDatabase(resolvedPath, { readonly: true, create: false });
28158
+ const db = openDatabase(resolvedPath, { readonly: true, create: false });
28159
+ db.exec(`PRAGMA busy_timeout = ${SQLITE_BUSY_TIMEOUT_MS}`);
28160
+ return db;
28037
28161
  }
28038
28162
  function closeDatabase(db) {
28039
28163
  db.close();
@@ -28044,6 +28168,7 @@ var init_index_connection = __esm(() => {
28044
28168
  init_paths();
28045
28169
  init_database();
28046
28170
  init_managed_db();
28171
+ init_sqlite_pragmas();
28047
28172
  init_index_schema();
28048
28173
  init_index_vec_repository();
28049
28174
  });
@@ -28405,7 +28530,7 @@ __export(exports_migrate_storage, {
28405
28530
  MIGRATIONS: () => MIGRATIONS
28406
28531
  });
28407
28532
  import fs46 from "fs";
28408
- import os7 from "os";
28533
+ import os8 from "os";
28409
28534
  import path52 from "path";
28410
28535
  import readline from "readline";
28411
28536
  function parseFromArg(args) {
@@ -29230,8 +29355,8 @@ async function main(args = process.argv.slice(2)) {
29230
29355
  var MIGRATED_MARKER = ".migrated", dataDir, stateDir, cacheDir, configDir, stateDbPath, indexDbPath, PATHS, versionReports, v07To08Migration, v08To09Migration, MIGRATIONS;
29231
29356
  var init_migrate_storage = __esm(() => {
29232
29357
  init_paths();
29233
- dataDir = process.env.AKM_DATA_DIR?.trim() ?? (process.env.XDG_DATA_HOME?.trim() ? path52.join(process.env.XDG_DATA_HOME.trim(), "akm") : path52.join(os7.homedir(), ".local", "share", "akm"));
29234
- stateDir = process.env.AKM_STATE_DIR?.trim() ?? (process.env.XDG_STATE_HOME?.trim() ? path52.join(process.env.XDG_STATE_HOME.trim(), "akm") : path52.join(os7.homedir(), ".local", "state", "akm"));
29358
+ dataDir = process.env.AKM_DATA_DIR?.trim() ?? (process.env.XDG_DATA_HOME?.trim() ? path52.join(process.env.XDG_DATA_HOME.trim(), "akm") : path52.join(os8.homedir(), ".local", "share", "akm"));
29359
+ stateDir = process.env.AKM_STATE_DIR?.trim() ?? (process.env.XDG_STATE_HOME?.trim() ? path52.join(process.env.XDG_STATE_HOME.trim(), "akm") : path52.join(os8.homedir(), ".local", "state", "akm"));
29235
29360
  cacheDir = getCacheDir();
29236
29361
  configDir = getConfigDir();
29237
29362
  stateDbPath = path52.join(dataDir, "state.db");
@@ -29377,8 +29502,8 @@ function flattenForText(value, path, lines) {
29377
29502
  }
29378
29503
 
29379
29504
  // src/output/html-render.ts
29380
- init_runtime();
29381
29505
  import path4 from "path";
29506
+ init_runtime();
29382
29507
  var TEMPLATES_DIR = path4.join(getDirname(import.meta.url), "../assets/templates/html");
29383
29508
 
29384
29509
  // src/output/command-registry.ts
@@ -31854,7 +31979,7 @@ init_errors();
31854
31979
  // scripts/akm-migrate/config-migrate.ts
31855
31980
  import { randomUUID as randomUUID5 } from "crypto";
31856
31981
  import fs43 from "fs";
31857
- import os6 from "os";
31982
+ import os7 from "os";
31858
31983
  import path49 from "path";
31859
31984
 
31860
31985
  // src/core/adapter/adapters/akm-lint.ts
@@ -31993,6 +32118,15 @@ var TASK_EXTENSION = ".yml";
31993
32118
  var TASK_NEAR_MISS_EXTENSION = ".yaml";
31994
32119
  var TASK_MAX_TIMEOUT_MS = WORKFLOW_MAX_TIMEOUT_MS;
31995
32120
  var TASK_MAX_REDACT_NAMES = WORKFLOW_MAX_EXEC_PASS_ENV;
32121
+ function isPresentTarget(value) {
32122
+ if (value === undefined || value === null)
32123
+ return false;
32124
+ if (typeof value === "string")
32125
+ return value.trim() !== "";
32126
+ if (Array.isArray(value))
32127
+ return value.length > 0;
32128
+ return true;
32129
+ }
31996
32130
  function taskFieldProblems(data) {
31997
32131
  const problems = [];
31998
32132
  if (data.version !== TASK_SCHEMA_VERSION)
@@ -32341,6 +32475,7 @@ function collectWorkflowWarnings(document) {
32341
32475
 
32342
32476
  // src/core/asset/frontmatter.ts
32343
32477
  import fs4 from "fs";
32478
+ init_common();
32344
32479
 
32345
32480
  // src/core/write-provenance.ts
32346
32481
  import path7 from "path";
@@ -32459,7 +32594,7 @@ function mutateFrontmatter(filePath, mutator) {
32459
32594
  ${serializeFrontmatter(nextFrontmatter)}
32460
32595
  ---
32461
32596
  ${parsed.content}` : assembleAsset(nextFrontmatter, parsed.content);
32462
- fs4.writeFileSync(filePath, next, "utf8");
32597
+ writeFileAtomic(filePath, next, existingFileMode(filePath));
32463
32598
  recordWrittenPath(filePath);
32464
32599
  return true;
32465
32600
  }
@@ -32547,8 +32682,12 @@ function validateExtraParams(value) {
32547
32682
  return [{ path: [], message: "must be an object" }];
32548
32683
  }
32549
32684
  const issues = [];
32685
+ const seen = new WeakSet;
32550
32686
  const visit2 = (entry, path8) => {
32551
32687
  if (Array.isArray(entry)) {
32688
+ if (seen.has(entry))
32689
+ return;
32690
+ seen.add(entry);
32552
32691
  entry.forEach((child, index) => {
32553
32692
  visit2(child, [...path8, index]);
32554
32693
  });
@@ -32556,6 +32695,9 @@ function validateExtraParams(value) {
32556
32695
  }
32557
32696
  if (!entry || typeof entry !== "object")
32558
32697
  return;
32698
+ if (seen.has(entry))
32699
+ return;
32700
+ seen.add(entry);
32559
32701
  for (const [key, child] of Object.entries(entry)) {
32560
32702
  const normalized = normalizeExtraParamKey(key);
32561
32703
  if (path8.length === 0 && PROTECTED_TOP_LEVEL_KEYS.has(normalized)) {
@@ -32650,6 +32792,9 @@ function pushIssue(issues, path8, keyword, kind, message) {
32650
32792
  function isPlainObject(value) {
32651
32793
  return typeof value === "object" && value !== null && !Array.isArray(value);
32652
32794
  }
32795
+ function isSupportedEnumValue(value) {
32796
+ return value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
32797
+ }
32653
32798
  function checkDefinitionNode(schema, path8, issues, depth) {
32654
32799
  if (depth > MAX_DEFINITION_DEPTH) {
32655
32800
  pushIssue(issues, path8, "(depth)", "malformed", `schema nesting exceeds the depth limit of ${MAX_DEFINITION_DEPTH}`);
@@ -32676,8 +32821,16 @@ function checkDefinitionNode(schema, path8, issues, depth) {
32676
32821
  }
32677
32822
  }
32678
32823
  }
32679
- if (schema.enum !== undefined && (!Array.isArray(schema.enum) || schema.enum.length === 0)) {
32680
- pushIssue(issues, [...path8, "enum"], "enum", "malformed", `"enum" must be a non-empty array of allowed values`);
32824
+ if (schema.enum !== undefined) {
32825
+ if (!Array.isArray(schema.enum) || schema.enum.length === 0) {
32826
+ pushIssue(issues, [...path8, "enum"], "enum", "malformed", `"enum" must be a non-empty array of allowed values`);
32827
+ } else {
32828
+ schema.enum.forEach((value, index) => {
32829
+ if (isSupportedEnumValue(value))
32830
+ return;
32831
+ pushIssue(issues, [...path8, "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`);
32832
+ });
32833
+ }
32681
32834
  }
32682
32835
  for (const keyword of ["allOf", "anyOf", "oneOf"]) {
32683
32836
  const branches = schema[keyword];
@@ -33358,7 +33511,13 @@ function parseUnit(ctx, raw, path8, stepLabel) {
33358
33511
  unit.output = output;
33359
33512
  if (raw.env !== undefined) {
33360
33513
  if (Array.isArray(raw.env) && raw.env.every((entry) => typeof entry === "string" && entry.trim() !== "")) {
33361
- unit.env = raw.env.map((entry) => entry.trim());
33514
+ const envRefs = raw.env.map((entry) => entry.trim());
33515
+ const duplicate = envRefs.find((ref, i) => envRefs.indexOf(ref) !== i);
33516
+ if (duplicate !== undefined) {
33517
+ ctx.err([...path8, "env"], `${stepLabel} "env" contains a duplicate entry: "${duplicate}".`);
33518
+ } else {
33519
+ unit.env = envRefs;
33520
+ }
33362
33521
  } else {
33363
33522
  ctx.err([...path8, "env"], `${stepLabel} "env" must be a list of non-empty env asset refs.`);
33364
33523
  }
@@ -33526,6 +33685,10 @@ function parseRoute(ctx, raw, path8, stepLabel, stepIndex, routeChecks) {
33526
33685
  return;
33527
33686
  }
33528
33687
  const match = String(branch.match);
33688
+ if (match === "") {
33689
+ ctx.errAtLine(matchLine, `${stepLabel} "when[${i}].match" must not be empty.`);
33690
+ return;
33691
+ }
33529
33692
  if (typeof branch.step !== "string" || branch.step.trim() === "") {
33530
33693
  ctx.err([...branchPath, "step"], `${stepLabel} "when[${i}].step" must be a step id string.`);
33531
33694
  return;
@@ -33567,12 +33730,18 @@ function parseInputs(ctx, raw, path8, stepLabel) {
33567
33730
  ctx.err(path8, `${stepLabel} "inputs" must contain at most ${WORKFLOW_MAX_INPUTS} entries.`);
33568
33731
  }
33569
33732
  const out = [];
33733
+ const seen = new Set;
33570
33734
  raw.forEach((entry, i) => {
33571
33735
  if (typeof entry !== "string" || entry.trim() === "") {
33572
33736
  ctx.err([...path8, i], `${stepLabel} "inputs[${i}]" must be a non-empty reference string.`);
33573
33737
  return;
33574
33738
  }
33575
33739
  const value = entry.trim();
33740
+ if (seen.has(value)) {
33741
+ ctx.err([...path8, i], `${stepLabel} "inputs[${i}]" duplicates an earlier entry: "${value}".`);
33742
+ return;
33743
+ }
33744
+ seen.add(value);
33576
33745
  checkReferenceSyntax(ctx, value, [...path8, i], `${stepLabel} "inputs[${i}]"`);
33577
33746
  out.push(value);
33578
33747
  });
@@ -33960,7 +34129,7 @@ function taskDiagnostics(relPath, data) {
33960
34129
  if (data === null || Object.keys(data).length === 0)
33961
34130
  return [];
33962
34131
  const missing = taskFieldProblems(data);
33963
- const hasTarget = "prompt" in data || "workflow" in data || "command" in data;
34132
+ const hasTarget = ["prompt", "workflow", "command"].some((key) => isPresentTarget(data[key]));
33964
34133
  if (!hasTarget)
33965
34134
  missing.push("prompt, workflow, or command");
33966
34135
  if (missing.length > 0) {
@@ -34078,6 +34247,7 @@ init_common();
34078
34247
  init_errors();
34079
34248
  init_file_lock();
34080
34249
  init_paths();
34250
+ init_common();
34081
34251
  import fs7 from "fs";
34082
34252
  import path11 from "path";
34083
34253
  function readConfigText(configPath) {
@@ -34157,48 +34327,6 @@ function withConfigLock(fn) {
34157
34327
  release();
34158
34328
  }
34159
34329
  }
34160
- function stripJsonComments(text) {
34161
- let result = "";
34162
- let i = 0;
34163
- let inString = false;
34164
- while (i < text.length) {
34165
- if (inString) {
34166
- if (text[i] === "\\") {
34167
- result += text[i] + (text[i + 1] ?? "");
34168
- i += 2;
34169
- continue;
34170
- }
34171
- if (text[i] === '"') {
34172
- inString = false;
34173
- }
34174
- result += text[i];
34175
- i++;
34176
- continue;
34177
- }
34178
- if (text[i] === '"') {
34179
- inString = true;
34180
- result += text[i];
34181
- i++;
34182
- continue;
34183
- }
34184
- if (text[i] === "/" && text[i + 1] === "/") {
34185
- while (i < text.length && text[i] !== `
34186
- `)
34187
- i++;
34188
- continue;
34189
- }
34190
- if (text[i] === "/" && text[i + 1] === "*") {
34191
- i += 2;
34192
- while (i < text.length && !(text[i] === "*" && text[i + 1] === "/"))
34193
- i++;
34194
- i += 2;
34195
- continue;
34196
- }
34197
- result += text[i];
34198
- i++;
34199
- }
34200
- return result;
34201
- }
34202
34330
 
34203
34331
  // node_modules/zod/v3/external.js
34204
34332
  var exports_external = {};
@@ -38301,6 +38429,7 @@ var VALID_HARNESS_IDS = Object.freeze(HARNESS_ID_TABLE.map((h) => h.id));
38301
38429
  var HARNESS_AGENT_DISPATCH_IDS = new Set(HARNESS_ID_TABLE.filter((h) => h.agentDispatch).map((h) => h.id));
38302
38430
 
38303
38431
  // src/core/config/schema/engines.ts
38432
+ var timeoutMsField = exports_external.union([positiveInt.max(WORKFLOW_MAX_TIMEOUT_MS), exports_external.null()]).optional();
38304
38433
  var LlmConnectionConfigSchema = exports_external.object({
38305
38434
  provider: exports_external.string().optional(),
38306
38435
  endpoint: exports_external.string(),
@@ -38308,7 +38437,7 @@ var LlmConnectionConfigSchema = exports_external.object({
38308
38437
  apiKey: exports_external.string().optional(),
38309
38438
  temperature: exports_external.number().finite().optional(),
38310
38439
  maxTokens: positiveInt.optional(),
38311
- timeoutMs: exports_external.union([positiveInt, exports_external.null()]).optional(),
38440
+ timeoutMs: timeoutMsField,
38312
38441
  concurrency: positiveInt.optional(),
38313
38442
  capabilities: LlmCapabilitiesSchema.optional(),
38314
38443
  extraParams: ExtraParamsSchema.optional(),
@@ -38327,7 +38456,7 @@ var LlmEngineSchema = exports_external.object({
38327
38456
  apiKey: exports_external.string().regex(ENV_REFERENCE_PATTERN, `apiKey must be $VAR or \${VAR}`).optional(),
38328
38457
  temperature: exports_external.number().finite().optional(),
38329
38458
  maxTokens: positiveInt.optional(),
38330
- timeoutMs: exports_external.union([positiveInt, exports_external.null()]).optional(),
38459
+ timeoutMs: timeoutMsField,
38331
38460
  concurrency: positiveInt.optional(),
38332
38461
  supportsJsonSchema: exports_external.boolean().optional(),
38333
38462
  extraParams: ExtraParamsSchema.optional(),
@@ -38348,7 +38477,7 @@ var AgentEngineSchema = exports_external.object({
38348
38477
  args: exports_external.array(exports_external.string()).optional(),
38349
38478
  workspace: nonEmptyString.optional(),
38350
38479
  model: nonEmptyString.optional(),
38351
- timeoutMs: exports_external.union([positiveInt, exports_external.null()]).optional(),
38480
+ timeoutMs: timeoutMsField,
38352
38481
  modelAliases: ModelAliasMapSchema.optional(),
38353
38482
  llmEngine: engineName.optional()
38354
38483
  }).passthrough().superRefine((value, ctx) => {
@@ -39451,7 +39580,7 @@ function inferLegacyBundleIds(sources) {
39451
39580
 
39452
39581
  // scripts/akm-migrate/migrate/legacy/config-source-migration.ts
39453
39582
  import fs24 from "fs";
39454
- import os from "os";
39583
+ import os2 from "os";
39455
39584
  import path28 from "path";
39456
39585
 
39457
39586
  // src/core/adapter/adapters/agent-skills-adapter.ts
@@ -39700,20 +39829,32 @@ function skillFieldDiagnostics(relPath, dirName, data) {
39700
39829
  return diagnostics;
39701
39830
  }
39702
39831
  var MAX_PACKAGE_PROBE_DEPTH = 3;
39703
- async function subtreeHasManifest(dir, entries, ctx, depth) {
39832
+ function missingManifestDiagnostic(dir) {
39833
+ return { file: dir, issue: "missing-skill-md", detail: `no SKILL.md in ${dir}/`, fixed: false };
39834
+ }
39835
+ async function scanPackageCandidate(dir, entries, ctx, depth) {
39704
39836
  if (entries.includes(SKILL_MANIFEST))
39705
- return true;
39706
- if (depth >= MAX_PACKAGE_PROBE_DEPTH)
39707
- return false;
39837
+ return { containsManifest: true, diagnostics: [] };
39838
+ if (depth >= MAX_PACKAGE_PROBE_DEPTH) {
39839
+ return { containsManifest: false, diagnostics: [missingManifestDiagnostic(dir)] };
39840
+ }
39841
+ const children = [];
39708
39842
  for (const entry of entries) {
39843
+ if (entry.startsWith("."))
39844
+ continue;
39709
39845
  const child = `${dir}/${entry}`;
39710
39846
  const childEntries = await ctx.list(child);
39711
39847
  if (childEntries.length === 0)
39712
39848
  continue;
39713
- if (await subtreeHasManifest(child, childEntries, ctx, depth + 1))
39714
- return true;
39849
+ children.push(await scanPackageCandidate(child, childEntries, ctx, depth + 1));
39715
39850
  }
39716
- return false;
39851
+ if (children.some((child) => child.containsManifest)) {
39852
+ return {
39853
+ containsManifest: true,
39854
+ diagnostics: children.flatMap((child) => child.diagnostics)
39855
+ };
39856
+ }
39857
+ return { containsManifest: false, diagnostics: [missingManifestDiagnostic(dir)] };
39717
39858
  }
39718
39859
  async function missingManifestDiagnostics(ctx) {
39719
39860
  const diagnostics = [];
@@ -39723,9 +39864,7 @@ async function missingManifestDiagnostics(ctx) {
39723
39864
  const entries = await ctx.list(name);
39724
39865
  if (entries.length === 0)
39725
39866
  continue;
39726
- if (await subtreeHasManifest(name, entries, ctx, 1))
39727
- continue;
39728
- diagnostics.push({ file: name, issue: "missing-skill-md", detail: `no SKILL.md in ${name}/`, fixed: false });
39867
+ diagnostics.push(...(await scanPackageCandidate(name, entries, ctx, 1)).diagnostics);
39729
39868
  }
39730
39869
  return diagnostics;
39731
39870
  }
@@ -41466,7 +41605,7 @@ function taskDiagnostics2(relPath, data) {
41466
41605
  if (Object.keys(data).length === 0)
41467
41606
  return [];
41468
41607
  const problems = taskFieldProblems(data);
41469
- const targets = TARGET_KEYS.filter((k) => (k in data) && data[k] !== undefined && data[k] !== null);
41608
+ const targets = TARGET_KEYS.filter((k) => isPresentTarget(data[k]));
41470
41609
  if (targets.length === 0)
41471
41610
  problems.push("exactly one target (prompt, workflow, or command)");
41472
41611
  else if (targets.length > 1)
@@ -41870,6 +42009,10 @@ function classify2(relPath) {
41870
42009
  }
41871
42010
  return null;
41872
42011
  }
42012
+ function hasSensitiveMarker(absPath, type) {
42013
+ const marker = type === "env" ? absPath.replace(/\.env$/i, ".sensitive") : `${absPath}.sensitive`;
42014
+ return marker !== absPath && fs19.existsSync(marker);
42015
+ }
41873
42016
  function scanKeyNames(raw) {
41874
42017
  const keys = [];
41875
42018
  const seen = new Set;
@@ -41889,6 +42032,8 @@ function recognize5(c, file) {
41889
42032
  const type = classify2(file.relPath);
41890
42033
  if (type === null)
41891
42034
  return null;
42035
+ if (hasSensitiveMarker(file.absPath, type))
42036
+ return null;
41892
42037
  const posix = toPosix6(file.relPath);
41893
42038
  const raw = file.content();
41894
42039
  if (type === "env") {
@@ -42803,9 +42948,9 @@ function hasOldSourceShape(raw) {
42803
42948
  }
42804
42949
  function expandTilde(p) {
42805
42950
  if (p === "~")
42806
- return os.homedir();
42951
+ return os2.homedir();
42807
42952
  if (p.startsWith("~/") || p.startsWith("~\\"))
42808
- return path28.join(os.homedir(), p.slice(2));
42953
+ return path28.join(os2.homedir(), p.slice(2));
42809
42954
  return p;
42810
42955
  }
42811
42956
  function readString(value) {
@@ -43036,14 +43181,14 @@ function generateTargetConfig(raw, currentConfigVersion) {
43036
43181
  // scripts/akm-migrate/migrate/legacy/content-migration.ts
43037
43182
  import { randomBytes } from "crypto";
43038
43183
  import fs27 from "fs";
43039
- import os3 from "os";
43184
+ import os4 from "os";
43040
43185
  import path31 from "path";
43041
43186
  init_common();
43042
43187
  init_warn();
43043
43188
 
43044
43189
  // scripts/akm-migrate/migrate/legacy/legacy-layout.ts
43045
43190
  import fs25 from "fs";
43046
- import os2 from "os";
43191
+ import os3 from "os";
43047
43192
  import path29 from "path";
43048
43193
  import { fileURLToPath as fileURLToPath2 } from "url";
43049
43194
 
@@ -43479,7 +43624,7 @@ function fileUriToPath(ref) {
43479
43624
  return after;
43480
43625
  }
43481
43626
  function toReadableLocalId(absolutePath) {
43482
- const home = os2.homedir();
43627
+ const home = os3.homedir();
43483
43628
  if (absolutePath === home)
43484
43629
  return "~";
43485
43630
  if (absolutePath.startsWith(home + path29.sep)) {
@@ -43634,7 +43779,7 @@ function runContentMigration(stashRoots, options = {}) {
43634
43779
  rewriteSourceBackrefsInDir(dir, report);
43635
43780
  }
43636
43781
  const operationId = options.operationId ?? `direct-${process.pid}-${randomBytes(8).toString("hex")}`;
43637
- const batchPath = options.renameBatchPath ?? path31.join(os3.tmpdir(), `akm-reserved-renames-${operationId}-${randomBytes(8).toString("hex")}.json`);
43782
+ const batchPath = options.renameBatchPath ?? path31.join(os4.tmpdir(), `akm-reserved-renames-${operationId}-${randomBytes(8).toString("hex")}.json`);
43638
43783
  let batch;
43639
43784
  try {
43640
43785
  batch = loadReservedRenameBatch(batchPath, operationId);
@@ -43916,7 +44061,7 @@ init_common();
43916
44061
  init_errors();
43917
44062
  import { spawnSync as spawnSync3 } from "child_process";
43918
44063
  import fs28 from "fs";
43919
- import os4 from "os";
44064
+ import os5 from "os";
43920
44065
  import path33 from "path";
43921
44066
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
43922
44067
 
@@ -44436,7 +44581,7 @@ function fileUriToPath2(ref) {
44436
44581
  return after;
44437
44582
  }
44438
44583
  function toReadableLocalId2(absolutePath) {
44439
- const home = os4.homedir();
44584
+ const home = os5.homedir();
44440
44585
  if (absolutePath === home)
44441
44586
  return "~";
44442
44587
  if (absolutePath.startsWith(home + path33.sep)) {
@@ -44841,7 +44986,7 @@ function errMsg2(error2) {
44841
44986
  // scripts/akm-migrate/migrate/legacy/task-target-ref-migration.ts
44842
44987
  import crypto4 from "crypto";
44843
44988
  import fs40 from "fs";
44844
- import os5 from "os";
44989
+ import os6 from "os";
44845
44990
  import path46 from "path";
44846
44991
  init_errors();
44847
44992
 
@@ -45445,6 +45590,14 @@ function resolveWritable(entry) {
45445
45590
  return entry.writable;
45446
45591
  return entry.type === "filesystem";
45447
45592
  }
45593
+ var WINDOWS_RESERVED_DEVICE_NAMES = new Set([
45594
+ "con",
45595
+ "prn",
45596
+ "aux",
45597
+ "nul",
45598
+ ...Array.from({ length: 9 }, (_, i) => `com${i + 1}`),
45599
+ ...Array.from({ length: 9 }, (_, i) => `lpt${i + 1}`)
45600
+ ]);
45448
45601
  function resolveGitContentRoot(repoPath) {
45449
45602
  const contentPath = path40.join(repoPath, "content");
45450
45603
  return fs35.existsSync(contentPath) && fs35.statSync(contentPath).isDirectory() ? contentPath : repoPath;
@@ -50690,6 +50843,22 @@ function markdownDestination(url) {
50690
50843
  return url.replaceAll("(", "%28").replaceAll(")", "%29");
50691
50844
  }
50692
50845
  var MAX_NESTING_DEPTH = 2000;
50846
+ var VOID_ELEMENTS = new Set([
50847
+ "area",
50848
+ "base",
50849
+ "br",
50850
+ "col",
50851
+ "embed",
50852
+ "hr",
50853
+ "img",
50854
+ "input",
50855
+ "link",
50856
+ "meta",
50857
+ "param",
50858
+ "source",
50859
+ "track",
50860
+ "wbr"
50861
+ ]);
50693
50862
  function exceedsNestingBudget(html) {
50694
50863
  let depth = 0;
50695
50864
  let max = 0;
@@ -50699,6 +50868,8 @@ function exceedsNestingBudget(html) {
50699
50868
  const selfClosing = match[3] === "/";
50700
50869
  if (selfClosing)
50701
50870
  continue;
50871
+ if (VOID_ELEMENTS.has(match[2].toLowerCase()))
50872
+ continue;
50702
50873
  if (closing)
50703
50874
  depth = Math.max(0, depth - 1);
50704
50875
  else {
@@ -50900,8 +51071,33 @@ ${content.trim().replace(/\n\s*\n/g, `
50900
51071
  function escapeResidualMarkup(markdown) {
50901
51072
  return markdown.replace(/<(?=[a-zA-Z/!?])/g, "&lt;");
50902
51073
  }
51074
+ function escapeOutsideCodeFences(markdown) {
51075
+ const lines = markdown.split(`
51076
+ `);
51077
+ let inFence = false;
51078
+ let fenceMarker = "";
51079
+ for (let i = 0;i < lines.length; i++) {
51080
+ const line = lines[i];
51081
+ const fence = /^\s*(`{3,}|~{3,})/.exec(line);
51082
+ if (fence) {
51083
+ const marker = fence[1];
51084
+ if (!inFence) {
51085
+ inFence = true;
51086
+ fenceMarker = marker[0];
51087
+ } else if (marker[0] === fenceMarker) {
51088
+ inFence = false;
51089
+ fenceMarker = "";
51090
+ }
51091
+ continue;
51092
+ }
51093
+ if (!inFence)
51094
+ lines[i] = escapeResidualMarkup(line);
51095
+ }
51096
+ return lines.join(`
51097
+ `);
51098
+ }
50903
51099
  function finalizeMarkdown(markdown) {
50904
- return escapeResidualMarkup(markdown).replace(/\r/g, "").replace(/[ \t]+\n/g, `
51100
+ return escapeOutsideCodeFences(markdown).replace(/\r/g, "").replace(/[ \t]+\n/g, `
50905
51101
  `).replace(/\n{3,}/g, `
50906
51102
 
50907
51103
  `).trim();
@@ -57779,9 +57975,9 @@ function migrationError(filePath, detail) {
57779
57975
  }
57780
57976
  function expandTilde2(value) {
57781
57977
  if (value === "~")
57782
- return os5.homedir();
57978
+ return os6.homedir();
57783
57979
  if (value.startsWith("~/") || value.startsWith("~\\"))
57784
- return path46.join(os5.homedir(), value.slice(2));
57980
+ return path46.join(os6.homedir(), value.slice(2));
57785
57981
  return value;
57786
57982
  }
57787
57983
  function bundlesFromConfig(config, pathResolutionBase, migrationLockEntries) {
@@ -59752,9 +59948,9 @@ async function runMigrationStatus(options = {}) {
59752
59948
  }
59753
59949
  function expandTilde4(value) {
59754
59950
  if (value === "~")
59755
- return os6.homedir();
59951
+ return os7.homedir();
59756
59952
  if (value.startsWith("~/") || value.startsWith("~\\"))
59757
- return path49.join(os6.homedir(), value.slice(2));
59953
+ return path49.join(os7.homedir(), value.slice(2));
59758
59954
  return value;
59759
59955
  }
59760
59956
  function migrationLockMatchesBundle(lock, bundle) {