@dotobokuri/fleet-console 1.22.1 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/AGENTS.md +4 -2
  2. package/dist/cli.mjs +128 -62
  3. package/dist/client/assets/{_baseUniq-cap0P4FK.js → _baseUniq-BjOe5yYF.js} +1 -1
  4. package/dist/client/assets/{arc-yBqa09aK.js → arc-bFUuO3jf.js} +1 -1
  5. package/dist/client/assets/{architectureDiagram-Q4EWVU46-Bug4qdr-.js → architectureDiagram-Q4EWVU46-Ba7nimQq.js} +1 -1
  6. package/dist/client/assets/{blockDiagram-DXYQGD6D-BkiIL2xt.js → blockDiagram-DXYQGD6D-CQGf47hl.js} +1 -1
  7. package/dist/client/assets/{c4Diagram-AHTNJAMY-DYY200Al.js → c4Diagram-AHTNJAMY-DZF_cAK4.js} +1 -1
  8. package/dist/client/assets/channel-D2BahVp1.js +1 -0
  9. package/dist/client/assets/{chunk-4BX2VUAB-DQKmhVxn.js → chunk-4BX2VUAB-DjUUHSQ5.js} +1 -1
  10. package/dist/client/assets/{chunk-4TB4RGXK-DHpmA3Zl.js → chunk-4TB4RGXK-Dvqti8bd.js} +1 -1
  11. package/dist/client/assets/{chunk-55IACEB6-DeRDuQXE.js → chunk-55IACEB6-2BxiBvkp.js} +1 -1
  12. package/dist/client/assets/{chunk-EDXVE4YY-CNpnhSJm.js → chunk-EDXVE4YY-CqCjol5O.js} +1 -1
  13. package/dist/client/assets/{chunk-FMBD7UC4-BXGVABL-.js → chunk-FMBD7UC4-eoCfIbly.js} +1 -1
  14. package/dist/client/assets/{chunk-OYMX7WX6-WbJs4VwZ.js → chunk-OYMX7WX6-CoC86V_1.js} +1 -1
  15. package/dist/client/assets/{chunk-QZHKN3VN-u3BLl6Sl.js → chunk-QZHKN3VN-CJQA5mlQ.js} +1 -1
  16. package/dist/client/assets/{chunk-YZCP3GAM-BFESuhuJ.js → chunk-YZCP3GAM-C5C4kbLu.js} +1 -1
  17. package/dist/client/assets/classDiagram-6PBFFD2Q-DsDAVLhS.js +1 -0
  18. package/dist/client/assets/classDiagram-v2-HSJHXN6E-DsDAVLhS.js +1 -0
  19. package/dist/client/assets/clone-CdZy2Xzf.js +1 -0
  20. package/dist/client/assets/{cose-bilkent-S5V4N54A-rouOsZjT.js → cose-bilkent-S5V4N54A-CahuunpL.js} +1 -1
  21. package/dist/client/assets/{dagre-KV5264BT-QCUeCVpM.js → dagre-KV5264BT-Cbv5kSi5.js} +1 -1
  22. package/dist/client/assets/{diagram-5BDNPKRD-DqerlFb_.js → diagram-5BDNPKRD-CNm40ZGB.js} +1 -1
  23. package/dist/client/assets/{diagram-G4DWMVQ6-BS3a1YGN.js → diagram-G4DWMVQ6-DrlGNT3i.js} +1 -1
  24. package/dist/client/assets/{diagram-MMDJMWI5-BeauTcSV.js → diagram-MMDJMWI5-r8Y2oqmw.js} +1 -1
  25. package/dist/client/assets/{diagram-TYMM5635-Ci2wLUUE.js → diagram-TYMM5635-CMzEhXup.js} +1 -1
  26. package/dist/client/assets/{erDiagram-SMLLAGMA-9MnmiKch.js → erDiagram-SMLLAGMA-UFjUUMPz.js} +1 -1
  27. package/dist/client/assets/{flowDiagram-DWJPFMVM-CiV9p5EU.js → flowDiagram-DWJPFMVM-Dd1STmYc.js} +1 -1
  28. package/dist/client/assets/{ganttDiagram-T4ZO3ILL-D6oNoENl.js → ganttDiagram-T4ZO3ILL-CHHU0hVd.js} +1 -1
  29. package/dist/client/assets/{gitGraphDiagram-UUTBAWPF-DESO385F.js → gitGraphDiagram-UUTBAWPF-vj2HukAF.js} +1 -1
  30. package/dist/client/assets/{graph-BZdl-RHy.js → graph-DhjfEbEb.js} +1 -1
  31. package/dist/client/assets/index-Dq9EKm2G.css +1 -0
  32. package/dist/client/assets/{index-BKpCMFrm.js → index-DtzbOdd7.js} +75 -75
  33. package/dist/client/assets/{infoDiagram-42DDH7IO-lc8vZnyi.js → infoDiagram-42DDH7IO-CC7AEgDm.js} +1 -1
  34. package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-BfzvQXhn.js → ishikawaDiagram-UXIWVN3A-DlRw2B9G.js} +1 -1
  35. package/dist/client/assets/{journeyDiagram-VCZTEJTY-BS_Dr0EV.js → journeyDiagram-VCZTEJTY-BbRXANKQ.js} +1 -1
  36. package/dist/client/assets/{kanban-definition-6JOO6SKY-Cw7oTQJN.js → kanban-definition-6JOO6SKY-DtvdCxGN.js} +1 -1
  37. package/dist/client/assets/{layout-ChwcDQm8.js → layout-Dg5cvw5v.js} +1 -1
  38. package/dist/client/assets/{linear-C7GLbmND.js → linear-BvVlQLqF.js} +1 -1
  39. package/dist/client/assets/{mermaid.core-D9phfpQo.js → mermaid.core-DzrV8sC-.js} +4 -4
  40. package/dist/client/assets/{min-p7Whc_Wi.js → min-DNGQ1Ciz.js} +1 -1
  41. package/dist/client/assets/{mindmap-definition-QFDTVHPH-fl_SJKrw.js → mindmap-definition-QFDTVHPH-DxJCNZbg.js} +1 -1
  42. package/dist/client/assets/{pieDiagram-DEJITSTG-Btw7ckA5.js → pieDiagram-DEJITSTG-B75XHG-s.js} +1 -1
  43. package/dist/client/assets/{quadrantDiagram-34T5L4WZ-DB4iJlTI.js → quadrantDiagram-34T5L4WZ-CL4yoF0m.js} +1 -1
  44. package/dist/client/assets/{requirementDiagram-MS252O5E-hXwV5Nhy.js → requirementDiagram-MS252O5E-kGV4vcr1.js} +1 -1
  45. package/dist/client/assets/{sankeyDiagram-XADWPNL6-DC-fizCk.js → sankeyDiagram-XADWPNL6-DoA4u7wI.js} +1 -1
  46. package/dist/client/assets/{sequenceDiagram-FGHM5R23-RrfrroR5.js → sequenceDiagram-FGHM5R23-ZpNDf1bS.js} +1 -1
  47. package/dist/client/assets/{stateDiagram-FHFEXIEX-q8FUPV_e.js → stateDiagram-FHFEXIEX-BzgKcVAG.js} +1 -1
  48. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-yRK5hzZ4.js +1 -0
  49. package/dist/client/assets/{timeline-definition-GMOUNBTQ-tegMd8Od.js → timeline-definition-GMOUNBTQ-B_DkUDsD.js} +1 -1
  50. package/dist/client/assets/{vennDiagram-DHZGUBPP-CXx5oN2X.js → vennDiagram-DHZGUBPP-MCUnnsKb.js} +1 -1
  51. package/dist/client/assets/{wardley-RL74JXVD-CxSJ3P_7.js → wardley-RL74JXVD-D_JAMSxj.js} +1 -1
  52. package/dist/client/assets/{wardleyDiagram-NUSXRM2D-DN1P180Z.js → wardleyDiagram-NUSXRM2D-BHCwZGLq.js} +1 -1
  53. package/dist/client/assets/{xychartDiagram-5P7HB3ND-Dcn9ukv5.js → xychartDiagram-5P7HB3ND-FbGwbD3V.js} +1 -1
  54. package/dist/client/index.html +2 -2
  55. package/dist/fleet-plugins/skills/routes.mjs +0 -3
  56. package/dist/fleet-plugins/terminal/routes.mjs +388 -365
  57. package/package.json +1 -1
  58. package/dist/client/assets/channel-B3EqY8ya.js +0 -1
  59. package/dist/client/assets/classDiagram-6PBFFD2Q-BekEZLVJ.js +0 -1
  60. package/dist/client/assets/classDiagram-v2-HSJHXN6E-BekEZLVJ.js +0 -1
  61. package/dist/client/assets/clone-CsVi9-Ni.js +0 -1
  62. package/dist/client/assets/index-cg8Uxys9.css +0 -1
  63. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-BErzXGq7.js +0 -1
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import * as fs2 from 'fs';
3
3
  import fs2__default, { existsSync, accessSync, constants, mkdtempSync, writeFileSync, mkdirSync, rmSync, chmodSync, renameSync, readdirSync, readFileSync, openSync, closeSync, realpathSync, fstatSync, lstatSync, unlinkSync, statSync } from 'fs';
4
- import * as path27 from 'path';
5
- import path27__default, { dirname } from 'path';
4
+ import * as path28 from 'path';
5
+ import path28__default, { dirname } from 'path';
6
6
  import * as os3 from 'os';
7
7
  import os3__default, { homedir } from 'os';
8
8
  import crypto4, { createHash, randomUUID } from 'crypto';
@@ -25,22 +25,22 @@ var __export = (target, all) => {
25
25
  function definePlugin(definition) {
26
26
  return definition;
27
27
  }
28
- function registerRouter(ctx, path42, handler) {
29
- ctx.registerRouter(normalizePath(path42), handler);
28
+ function registerRouter(ctx, path43, handler) {
29
+ ctx.registerRouter(normalizePath(path43), handler);
30
30
  }
31
- function registerWsHandler(ctx, path42, handler) {
32
- ctx.registerWsHandler(normalizePath(path42), handler);
31
+ function registerWsHandler(ctx, path43, handler) {
32
+ ctx.registerWsHandler(normalizePath(path43), handler);
33
33
  }
34
34
  function registerLaunchCatalog(ctx, provider) {
35
35
  return ctx.host.operations.registerLaunchCatalog(ctx.pluginId, provider);
36
36
  }
37
- function normalizePath(path42) {
38
- if (path42.length === 0 || path42 === "/") return "/";
39
- return path42;
37
+ function normalizePath(path43) {
38
+ if (path43.length === 0 || path43 === "/") return "/";
39
+ return path43;
40
40
  }
41
41
  var FLEET_DATA_DIR_NAME = ".fleet";
42
42
  function getFleetDataDir() {
43
- return path27.join(os3.homedir(), FLEET_DATA_DIR_NAME);
43
+ return path28.join(os3.homedir(), FLEET_DATA_DIR_NAME);
44
44
  }
45
45
  var SECURE_DIR_MODE = 448;
46
46
  var SECURE_FILE_MODE = 384;
@@ -128,7 +128,7 @@ function cleanupTempFiles(dir, prefix, minAgeMs, now) {
128
128
  if (!entry.startsWith(prefix)) {
129
129
  continue;
130
130
  }
131
- const tempPath = path27.join(dir, entry);
131
+ const tempPath = path28.join(dir, entry);
132
132
  try {
133
133
  const stat3 = fs2.lstatSync(tempPath);
134
134
  if (stat3?.isFile() && !stat3.isSymbolicLink() && now - stat3.mtimeMs >= minAgeMs) {
@@ -234,7 +234,7 @@ function writeLockOwner(lockDir, ownerFileName, startedAt) {
234
234
  hostname: os3.hostname(),
235
235
  startedAt
236
236
  };
237
- const ownerPath = path27.join(lockDir, ownerFileName);
237
+ const ownerPath = path28.join(lockDir, ownerFileName);
238
238
  try {
239
239
  fs2.writeFileSync(ownerPath, JSON.stringify(owner), { encoding: "utf-8", mode: 384 });
240
240
  } catch (error51) {
@@ -243,7 +243,7 @@ function writeLockOwner(lockDir, ownerFileName, startedAt) {
243
243
  }
244
244
  }
245
245
  function readLockOwner(lockDir, ownerFileName) {
246
- const ownerPath = path27.join(lockDir, ownerFileName);
246
+ const ownerPath = path28.join(lockDir, ownerFileName);
247
247
  try {
248
248
  return sanitizeLockOwner(JSON.parse(fs2.readFileSync(ownerPath, "utf-8")));
249
249
  } catch (error51) {
@@ -320,7 +320,7 @@ function readAuthStoreFile(filePath) {
320
320
  }
321
321
 
322
322
  // ../../packages/core-infra/src/auth/auth-storage.ts
323
- var DEFAULT_AUTH_PATH = path27.join(getFleetDataDir(), "auth.json");
323
+ var DEFAULT_AUTH_PATH = path28.join(getFleetDataDir(), "auth.json");
324
324
  var AUTH_LOCK_OWNER_FILE_NAME = "owner.json";
325
325
  var AUTH_LOCK_TIMEOUT_MS = 5e3;
326
326
  function createAuthService(deps = {}) {
@@ -376,7 +376,7 @@ function createAuthService(deps = {}) {
376
376
  }
377
377
  },
378
378
  async setApiKey(providerId, key) {
379
- const dir = path27.dirname(authPath);
379
+ const dir = path28.dirname(authPath);
380
380
  ensureSafeDirectory(dir);
381
381
  withAuthLock(authPath, lockDir, () => {
382
382
  const data = fs2.existsSync(authPath) ? readAuthStoreFile(authPath) : {};
@@ -411,7 +411,7 @@ function createDurableJsonStore(deps) {
411
411
  const now = deps.now ?? (() => Date.now());
412
412
  const mode = SECURE_FILE_MODE ;
413
413
  const minAgeMs = deps.tempCleanupMinAgeMs ?? DEFAULT_TEMP_FILE_MIN_AGE_MS;
414
- const dir = path27.dirname(deps.filePath);
414
+ const dir = path28.dirname(deps.filePath);
415
415
  return {
416
416
  path: deps.filePath,
417
417
  load() {
@@ -495,8 +495,8 @@ var LOCK_OWNER_FILE_NAME = "owner";
495
495
  var TEMP_FILE_PREFIX = `.tmp-${GLOBAL_OPTIONS_FILE_NAME}-`;
496
496
  function createGlobalOptionsStore(deps = {}) {
497
497
  const dataDir = deps.dataDir ?? getFleetDataDir();
498
- const optionsPath = path27.join(dataDir, GLOBAL_OPTIONS_FILE_NAME);
499
- const lockDir = path27.join(dataDir, LOCK_DIR_NAME);
498
+ const optionsPath = path28.join(dataDir, GLOBAL_OPTIONS_FILE_NAME);
499
+ const lockDir = path28.join(dataDir, LOCK_DIR_NAME);
500
500
  const store2 = createDurableJsonStore({
501
501
  filePath: optionsPath,
502
502
  lockDir,
@@ -1398,10 +1398,10 @@ function mergeDefs(...defs) {
1398
1398
  function cloneDef(schema) {
1399
1399
  return mergeDefs(schema._zod.def);
1400
1400
  }
1401
- function getElementAtPath(obj, path42) {
1402
- if (!path42)
1401
+ function getElementAtPath(obj, path43) {
1402
+ if (!path43)
1403
1403
  return obj;
1404
- return path42.reduce((acc, key) => acc?.[key], obj);
1404
+ return path43.reduce((acc, key) => acc?.[key], obj);
1405
1405
  }
1406
1406
  function promiseAllObject(promisesObj) {
1407
1407
  const keys = Object.keys(promisesObj);
@@ -1810,11 +1810,11 @@ function explicitlyAborted(x, startIndex = 0) {
1810
1810
  }
1811
1811
  return false;
1812
1812
  }
1813
- function prefixIssues(path42, issues) {
1813
+ function prefixIssues(path43, issues) {
1814
1814
  return issues.map((iss) => {
1815
1815
  var _a3;
1816
1816
  (_a3 = iss).path ?? (_a3.path = []);
1817
- iss.path.unshift(path42);
1817
+ iss.path.unshift(path43);
1818
1818
  return iss;
1819
1819
  });
1820
1820
  }
@@ -1961,16 +1961,16 @@ function flattenError(error51, mapper = (issue3) => issue3.message) {
1961
1961
  }
1962
1962
  function formatError(error51, mapper = (issue3) => issue3.message) {
1963
1963
  const fieldErrors = { _errors: [] };
1964
- const processError = (error52, path42 = []) => {
1964
+ const processError = (error52, path43 = []) => {
1965
1965
  for (const issue3 of error52.issues) {
1966
1966
  if (issue3.code === "invalid_union" && issue3.errors.length) {
1967
- issue3.errors.map((issues) => processError({ issues }, [...path42, ...issue3.path]));
1967
+ issue3.errors.map((issues) => processError({ issues }, [...path43, ...issue3.path]));
1968
1968
  } else if (issue3.code === "invalid_key") {
1969
- processError({ issues: issue3.issues }, [...path42, ...issue3.path]);
1969
+ processError({ issues: issue3.issues }, [...path43, ...issue3.path]);
1970
1970
  } else if (issue3.code === "invalid_element") {
1971
- processError({ issues: issue3.issues }, [...path42, ...issue3.path]);
1971
+ processError({ issues: issue3.issues }, [...path43, ...issue3.path]);
1972
1972
  } else {
1973
- const fullpath = [...path42, ...issue3.path];
1973
+ const fullpath = [...path43, ...issue3.path];
1974
1974
  if (fullpath.length === 0) {
1975
1975
  fieldErrors._errors.push(mapper(issue3));
1976
1976
  } else {
@@ -1997,17 +1997,17 @@ function formatError(error51, mapper = (issue3) => issue3.message) {
1997
1997
  }
1998
1998
  function treeifyError(error51, mapper = (issue3) => issue3.message) {
1999
1999
  const result = { errors: [] };
2000
- const processError = (error52, path42 = []) => {
2000
+ const processError = (error52, path43 = []) => {
2001
2001
  var _a3, _b;
2002
2002
  for (const issue3 of error52.issues) {
2003
2003
  if (issue3.code === "invalid_union" && issue3.errors.length) {
2004
- issue3.errors.map((issues) => processError({ issues }, [...path42, ...issue3.path]));
2004
+ issue3.errors.map((issues) => processError({ issues }, [...path43, ...issue3.path]));
2005
2005
  } else if (issue3.code === "invalid_key") {
2006
- processError({ issues: issue3.issues }, [...path42, ...issue3.path]);
2006
+ processError({ issues: issue3.issues }, [...path43, ...issue3.path]);
2007
2007
  } else if (issue3.code === "invalid_element") {
2008
- processError({ issues: issue3.issues }, [...path42, ...issue3.path]);
2008
+ processError({ issues: issue3.issues }, [...path43, ...issue3.path]);
2009
2009
  } else {
2010
- const fullpath = [...path42, ...issue3.path];
2010
+ const fullpath = [...path43, ...issue3.path];
2011
2011
  if (fullpath.length === 0) {
2012
2012
  result.errors.push(mapper(issue3));
2013
2013
  continue;
@@ -2039,8 +2039,8 @@ function treeifyError(error51, mapper = (issue3) => issue3.message) {
2039
2039
  }
2040
2040
  function toDotPath(_path) {
2041
2041
  const segs = [];
2042
- const path42 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2043
- for (const seg of path42) {
2042
+ const path43 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2043
+ for (const seg of path43) {
2044
2044
  if (typeof seg === "number")
2045
2045
  segs.push(`[${seg}]`);
2046
2046
  else if (typeof seg === "symbol")
@@ -14704,13 +14704,13 @@ function resolveRef(ref, ctx) {
14704
14704
  if (!ref.startsWith("#")) {
14705
14705
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14706
14706
  }
14707
- const path42 = ref.slice(1).split("/").filter(Boolean);
14708
- if (path42.length === 0) {
14707
+ const path43 = ref.slice(1).split("/").filter(Boolean);
14708
+ if (path43.length === 0) {
14709
14709
  return ctx.rootSchema;
14710
14710
  }
14711
14711
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14712
- if (path42[0] === defsKey) {
14713
- const key = path42[1];
14712
+ if (path43[0] === defsKey) {
14713
+ const key = path43[1];
14714
14714
  if (!key || !ctx.defs[key]) {
14715
14715
  throw new Error(`Reference not found: ${ref}`);
14716
14716
  }
@@ -18883,7 +18883,7 @@ function createChildEnv(env, overlay) {
18883
18883
  return child;
18884
18884
  }
18885
18885
  function wrapWindowsShim(resolved, env, platform) {
18886
- if (platform !== "win32" || !WINDOWS_SHIM_EXTENSIONS.has(path27__default.extname(resolved).toLowerCase())) {
18886
+ if (platform !== "win32" || !WINDOWS_SHIM_EXTENSIONS.has(path28__default.extname(resolved).toLowerCase())) {
18887
18887
  return { bin: resolved, prefixArgs: [] };
18888
18888
  }
18889
18889
  rejectCmdExpansionSensitiveShim(resolved);
@@ -18901,13 +18901,13 @@ function forceWindowsArgQuoting(value) {
18901
18901
  return `${value} `;
18902
18902
  }
18903
18903
  function findOnPath(bin, pathValue, pathExts, platform) {
18904
- const pathSeparator = platform === "win32" ? WINDOWS_PATH_SEPARATOR : path27__default.delimiter;
18905
- if (hasPathSeparator(bin, platform) || path27__default.isAbsolute(bin)) {
18904
+ const pathSeparator = platform === "win32" ? WINDOWS_PATH_SEPARATOR : path28__default.delimiter;
18905
+ if (hasPathSeparator(bin, platform) || path28__default.isAbsolute(bin)) {
18906
18906
  return resolveWithExtensions(bin, pathExts, platform);
18907
18907
  }
18908
18908
  for (const entry of pathValue.split(pathSeparator)) {
18909
18909
  const searchDir = entry.length === 0 ? "." : entry;
18910
- const candidate = resolveWithExtensions(path27__default.join(searchDir, bin), pathExts, platform);
18910
+ const candidate = resolveWithExtensions(path28__default.join(searchDir, bin), pathExts, platform);
18911
18911
  if (candidate) {
18912
18912
  return candidate;
18913
18913
  }
@@ -18915,7 +18915,7 @@ function findOnPath(bin, pathValue, pathExts, platform) {
18915
18915
  return void 0;
18916
18916
  }
18917
18917
  function resolveWithExtensions(candidate, pathExts, platform) {
18918
- if (platform !== "win32" || path27__default.extname(candidate).length > 0) {
18918
+ if (platform !== "win32" || path28__default.extname(candidate).length > 0) {
18919
18919
  return isAccessibleExecutable(candidate, platform) ? candidate : void 0;
18920
18920
  }
18921
18921
  for (const ext of pathExts) {
@@ -20329,11 +20329,24 @@ function getYoloModeId(cli) {
20329
20329
  return "yolo";
20330
20330
  }
20331
20331
  }
20332
- function buildCodexDeveloperInstructionConfig(systemPrompt) {
20333
- if (!systemPrompt) {
20334
- return [];
20332
+ function buildCodexConfigEnv(systemPrompt, configOverrides, baseConfigJson) {
20333
+ const map2 = parseBaseConfigMap(baseConfigJson);
20334
+ for (const override of configOverrides ?? []) {
20335
+ const eqIndex = override.indexOf("=");
20336
+ if (eqIndex < 0) {
20337
+ continue;
20338
+ }
20339
+ const key = override.slice(0, eqIndex);
20340
+ const rawValue = override.slice(eqIndex + 1);
20341
+ assignNestedKey(map2, key, parseOverrideValue(rawValue));
20342
+ }
20343
+ if (systemPrompt) {
20344
+ map2.developer_instructions = systemPrompt;
20345
+ }
20346
+ if (Object.keys(map2).length === 0) {
20347
+ return void 0;
20335
20348
  }
20336
- return [`developer_instructions="${escapeTomlBasicString(systemPrompt)}"`];
20349
+ return JSON.stringify(map2);
20337
20350
  }
20338
20351
  function buildConfigOverrideArgs(overrides) {
20339
20352
  return overrides.flatMap((override) => ["-c", override]);
@@ -20361,27 +20374,44 @@ function mcpServerConfigsToAcp(servers) {
20361
20374
  headers: server.headers ?? []
20362
20375
  }));
20363
20376
  }
20364
- function escapeTomlBasicString(value) {
20365
- return value.replace(/[\u0000-\u001f"\\\u007f]/g, (char) => {
20366
- switch (char) {
20367
- case "\b":
20368
- return "\\b";
20369
- case " ":
20370
- return "\\t";
20371
- case "\n":
20372
- return "\\n";
20373
- case "\f":
20374
- return "\\f";
20375
- case "\r":
20376
- return "\\r";
20377
- case '"':
20378
- return '\\"';
20379
- case "\\":
20380
- return "\\\\";
20381
- default:
20382
- return `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
20377
+ function parseBaseConfigMap(baseConfigJson) {
20378
+ if (!baseConfigJson) {
20379
+ return {};
20380
+ }
20381
+ try {
20382
+ const parsed = JSON.parse(baseConfigJson);
20383
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
20384
+ return parsed;
20383
20385
  }
20384
- });
20386
+ } catch {
20387
+ }
20388
+ return {};
20389
+ }
20390
+ function parseOverrideValue(raw) {
20391
+ try {
20392
+ return JSON.parse(raw);
20393
+ } catch {
20394
+ if (raw.length >= 2 && raw.startsWith('"') && raw.endsWith('"')) {
20395
+ return raw.slice(1, -1);
20396
+ }
20397
+ return raw;
20398
+ }
20399
+ }
20400
+ function assignNestedKey(target, dottedKey, value) {
20401
+ const segments = dottedKey.split(".");
20402
+ let cursor = target;
20403
+ for (let i = 0; i < segments.length - 1; i += 1) {
20404
+ const segment = segments[i];
20405
+ const existing = cursor[segment];
20406
+ if (typeof existing === "object" && existing !== null && !Array.isArray(existing)) {
20407
+ cursor = existing;
20408
+ } else {
20409
+ const nested = {};
20410
+ cursor[segment] = nested;
20411
+ cursor = nested;
20412
+ }
20413
+ }
20414
+ cursor[segments[segments.length - 1]] = value;
20385
20415
  }
20386
20416
 
20387
20417
  // ../../packages/core-unified-agent/src/detector/CliDetector.ts
@@ -21642,12 +21672,12 @@ var CodexAppServerConnection = class extends BaseConnection {
21642
21672
  );
21643
21673
  }
21644
21674
  findRolloutPathForThreadId(threadId) {
21645
- const codexHome = this.codexHome ?? this.env.CODEX_HOME ?? path27.join(this.env.HOME ?? "", ".codex");
21675
+ const codexHome = this.codexHome ?? this.env.CODEX_HOME ?? path28.join(this.env.HOME ?? "", ".codex");
21646
21676
  if (!codexHome) {
21647
21677
  return null;
21648
21678
  }
21649
21679
  for (const rootName of ["sessions", "archived_sessions"]) {
21650
- const found = findRolloutPath(path27.join(codexHome, rootName), threadId);
21680
+ const found = findRolloutPath(path28.join(codexHome, rootName), threadId);
21651
21681
  if (found) {
21652
21682
  return found;
21653
21683
  }
@@ -21758,7 +21788,7 @@ function findRolloutPath(root, threadId) {
21758
21788
  return null;
21759
21789
  }
21760
21790
  for (const entry of fs2.readdirSync(root, { withFileTypes: true })) {
21761
- const entryPath = path27.join(root, entry.name);
21791
+ const entryPath = path28.join(root, entry.name);
21762
21792
  if (entry.isDirectory()) {
21763
21793
  const found = findRolloutPath(entryPath, threadId);
21764
21794
  if (found) {
@@ -21776,13 +21806,11 @@ function findRolloutPath(root, threadId) {
21776
21806
  // ../../packages/core-unified-agent/src/client/UnifiedCodexAgentClient.ts
21777
21807
  var CODEX_TURN_LEVEL_CONFIG_KEYS = /* @__PURE__ */ new Set(["effort", "model"]);
21778
21808
  var CODEX_THREAD_POLICY_CONFIG_KEYS = /* @__PURE__ */ new Set(["approvalPolicy", "sandbox"]);
21779
- var CODEX_ACP_PROMPT_FALLBACK = process.platform === "win32";
21780
21809
  var UnifiedCodexAgentClient = class extends EventEmitter {
21781
21810
  connection = null;
21782
21811
  sessionId = null;
21783
21812
  sessionCwd = null;
21784
21813
  currentSystemPrompt = null;
21785
- firstPromptPending = null;
21786
21814
  pendingOverrides = null;
21787
21815
  detector = new CliDetector();
21788
21816
  on(event, listener) {
@@ -21874,22 +21902,17 @@ var UnifiedCodexAgentClient = class extends EventEmitter {
21874
21902
  async connectAcp(options) {
21875
21903
  const cleanEnv = cleanEnvironment(process.env, options.env);
21876
21904
  const spawnConfig = createSpawnConfig("codex", options);
21877
- const developerInstructions = CODEX_ACP_PROMPT_FALLBACK ? void 0 : options.systemPrompt ?? void 0;
21878
- const args = [
21879
- ...spawnConfig.args,
21880
- ...this.buildStartupConfigArgs(
21881
- options.configOverrides,
21882
- void 0,
21883
- void 0,
21884
- developerInstructions
21885
- )
21886
- ];
21905
+ const codexConfigEnv = buildCodexConfigEnv(
21906
+ options.systemPrompt,
21907
+ options.configOverrides,
21908
+ cleanEnv.CODEX_CONFIG
21909
+ );
21887
21910
  const connection = new AcpConnection({
21888
21911
  command: spawnConfig.command,
21889
- args,
21912
+ args: spawnConfig.args,
21890
21913
  cliType: "codex",
21891
21914
  cwd: options.cwd,
21892
- env: { ...cleanEnv },
21915
+ env: { ...cleanEnv, ...codexConfigEnv ? { CODEX_CONFIG: codexConfigEnv } : {} },
21893
21916
  requestTimeout: options.timeout ?? 6e5,
21894
21917
  initTimeout: options.timeout ?? 6e4,
21895
21918
  promptIdleTimeout: options.promptIdleTimeout ?? 6e5,
@@ -21986,17 +22009,7 @@ var UnifiedCodexAgentClient = class extends EventEmitter {
21986
22009
  if (!this.sessionId) {
21987
22010
  throw new Error("\uC5F0\uACB0\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21988
22011
  }
21989
- const systemPrompt = this.firstPromptPending;
21990
- if (!systemPrompt) {
21991
- return this.connection.sendPrompt(this.sessionId, content);
21992
- }
21993
- const userBlocks = typeof content === "string" ? [{ type: "text", text: content }] : content;
21994
- const response = await this.connection.sendPrompt(this.sessionId, [
21995
- { type: "text", text: systemPrompt },
21996
- ...userBlocks
21997
- ]);
21998
- this.firstPromptPending = null;
21999
- return response;
22012
+ return this.connection.sendPrompt(this.sessionId, content);
22000
22013
  }
22001
22014
  this.applyPendingOverrides();
22002
22015
  const input = typeof content === "string" ? [{ type: "text", text: content, text_elements: [] }] : content.map((block) => "text" in block ? { type: "text", text: block.text, text_elements: [] } : { type: "text", text: JSON.stringify(block), text_elements: [] });
@@ -22078,8 +22091,6 @@ var UnifiedCodexAgentClient = class extends EventEmitter {
22078
22091
  mcpServers: this.resolveAcpMcpServers(mcpServers)
22079
22092
  });
22080
22093
  this.sessionId = sessionId;
22081
- this.currentSystemPrompt = null;
22082
- this.firstPromptPending = null;
22083
22094
  return;
22084
22095
  }
22085
22096
  if (mcpServers?.length) {
@@ -22116,7 +22127,6 @@ var UnifiedCodexAgentClient = class extends EventEmitter {
22116
22127
  const session = await this.connection.reconnectSession(targetCwd);
22117
22128
  this.sessionId = session.sessionId;
22118
22129
  this.sessionCwd = targetCwd;
22119
- this.firstPromptPending = this.currentSystemPrompt;
22120
22130
  return {
22121
22131
  cli: "codex",
22122
22132
  protocol: "acp",
@@ -22144,7 +22154,6 @@ var UnifiedCodexAgentClient = class extends EventEmitter {
22144
22154
  this.sessionId = session.sessionId;
22145
22155
  this.sessionCwd = options.cwd;
22146
22156
  this.currentSystemPrompt = options.systemPrompt ?? null;
22147
- this.firstPromptPending = CODEX_ACP_PROMPT_FALLBACK && !options.sessionId ? options.systemPrompt ?? null : null;
22148
22157
  this.pendingOverrides = {
22149
22158
  turnConfig: {},
22150
22159
  threadConfig: {}
@@ -22162,7 +22171,6 @@ var UnifiedCodexAgentClient = class extends EventEmitter {
22162
22171
  this.sessionId = null;
22163
22172
  this.sessionCwd = null;
22164
22173
  this.currentSystemPrompt = null;
22165
- this.firstPromptPending = null;
22166
22174
  this.pendingOverrides = null;
22167
22175
  }
22168
22176
  validateModelEffort(modelId, effort) {
@@ -22373,9 +22381,8 @@ var UnifiedCodexAgentClient = class extends EventEmitter {
22373
22381
  return "read-only";
22374
22382
  }
22375
22383
  }
22376
- buildStartupConfigArgs(overrides, servers, modeMapping, developerInstructions) {
22384
+ buildStartupConfigArgs(overrides, servers, modeMapping) {
22377
22385
  const configArgs = [
22378
- ...buildCodexDeveloperInstructionConfig(developerInstructions),
22379
22386
  ...modeMapping ? [
22380
22387
  `approval_policy="${modeMapping.approvalPolicy}"`,
22381
22388
  `sandbox_mode="${modeMapping.sandbox}"`
@@ -25085,7 +25092,7 @@ function readRawCarriersOrDefaultStore() {
25085
25092
  return readCarriers();
25086
25093
  }
25087
25094
  function getCarriersFilePath() {
25088
- return path27.join(resolveStoreDir(), FILENAME);
25095
+ return path28.join(resolveStoreDir(), FILENAME);
25089
25096
  }
25090
25097
  function updateCarriers(mutator) {
25091
25098
  withStoreLock(() => {
@@ -25099,7 +25106,7 @@ function updateCarriers(mutator) {
25099
25106
  function withStoreLock(operation) {
25100
25107
  const dir = resolveStoreDir();
25101
25108
  ensureSafeDirectory(dir);
25102
- const lockDir = path27.join(dir, LOCK_DIRNAME);
25109
+ const lockDir = path28.join(dir, LOCK_DIRNAME);
25103
25110
  return withDirectoryLock(
25104
25111
  { lockDir, ownerFileName: LOCK_OWNER_FILENAME },
25105
25112
  operation
@@ -25112,7 +25119,7 @@ function readCarriers() {
25112
25119
  return readCarriersFromDir(resolveStoreDir());
25113
25120
  }
25114
25121
  function readCarriersFromDir(dir) {
25115
- const filePath = path27.join(dir, FILENAME);
25122
+ const filePath = path28.join(dir, FILENAME);
25116
25123
  let fd;
25117
25124
  try {
25118
25125
  const stat3 = fs2.lstatSync(filePath);
@@ -25141,7 +25148,7 @@ function recordLastLocalWriteFingerprint(filePath, generation) {
25141
25148
  }
25142
25149
  function writeCarriers(s) {
25143
25150
  const dir = resolveStoreDir();
25144
- const filePath = path27.join(dir, FILENAME);
25151
+ const filePath = path28.join(dir, FILENAME);
25145
25152
  const next = serializeFleetCarriers(s);
25146
25153
  writeAtomicSync(filePath, `${JSON.stringify(next, null, 2)}
25147
25154
  `, { fsync: false, mode: 420 });
@@ -25166,7 +25173,7 @@ function sanitizeFleetCarriers(value) {
25166
25173
  }
25167
25174
  function unlinkStaleSubagentModeFile(dir) {
25168
25175
  try {
25169
- fs2.unlinkSync(path27.join(dir, STALE_SUBAGENT_MODE_FILENAME));
25176
+ fs2.unlinkSync(path28.join(dir, STALE_SUBAGENT_MODE_FILENAME));
25170
25177
  } catch {
25171
25178
  }
25172
25179
  }
@@ -32710,7 +32717,7 @@ function resolveDispatchCwd(rawCwd, fallbackCwd) {
32710
32717
  if (rawCwd === void 0) return { ok: true, cwd: fallbackCwd };
32711
32718
  const trimmed = rawCwd.trim();
32712
32719
  if (trimmed.length === 0) return { ok: true, cwd: fallbackCwd };
32713
- if (!path27__default.isAbsolute(trimmed)) {
32720
+ if (!path28__default.isAbsolute(trimmed)) {
32714
32721
  return {
32715
32722
  ok: false,
32716
32723
  error: `Invalid cwd "${rawCwd}": must be an absolute path. Provide an absolute directory or omit cwd to use the host session cwd.`
@@ -33420,7 +33427,7 @@ function requireSystemPromptFile(context) {
33420
33427
  var TOML_BASIC_STRING_ESCAPE_PATTERN = /[\u0000-\u001f"\\\u007f]/g;
33421
33428
  var TOML_MULTILINE_CONTROL_PATTERN = new RegExp("[\\u0000-\\u0008\\u000b-\\u001f\\u007f]", "g");
33422
33429
  var TOML_MULTILINE_QUOTE_RUN_PATTERN = /"+/g;
33423
- function escapeTomlBasicString2(value) {
33430
+ function escapeTomlBasicString(value) {
33424
33431
  return value.replace(TOML_BASIC_STRING_ESCAPE_PATTERN, (char) => {
33425
33432
  switch (char) {
33426
33433
  case "\b":
@@ -33493,9 +33500,9 @@ function buildCodexNativeArgs(context) {
33493
33500
  const bearerHeader = `Bearer ${server.bearerToken}`;
33494
33501
  args.push(
33495
33502
  "-c",
33496
- `${prefix}.url="${escapeTomlBasicString2(server.endpointUrl)}"`,
33503
+ `${prefix}.url="${escapeTomlBasicString(server.endpointUrl)}"`,
33497
33504
  "-c",
33498
- `${prefix}.http_headers={"Authorization" = "${escapeTomlBasicString2(bearerHeader)}"}`,
33505
+ `${prefix}.http_headers={"Authorization" = "${escapeTomlBasicString(bearerHeader)}"}`,
33499
33506
  "-c",
33500
33507
  `${prefix}.tool_timeout_sec=${CODEX_TOOL_TIMEOUT_SEC}`
33501
33508
  );
@@ -33606,7 +33613,7 @@ function writePrivateJson(filePath, value, rootBase) {
33606
33613
  function writePrivateFile(filePath, content, rootBase) {
33607
33614
  const resolvedBase = ensureRootBase(rootBase);
33608
33615
  ensurePathWithinRoot(resolvedBase, filePath);
33609
- ensureDirectorySegments(resolvedBase, path27__default.dirname(filePath));
33616
+ ensureDirectorySegments(resolvedBase, path28__default.dirname(filePath));
33610
33617
  writeFileNoFollow(filePath, content);
33611
33618
  chmodBestEffort(filePath, FILE_MODE);
33612
33619
  }
@@ -33653,20 +33660,20 @@ function writeFileNoFollow(filePath, content) {
33653
33660
  }
33654
33661
  }
33655
33662
  function ensureRootBase(rootBase) {
33656
- const resolvedBase = path27__default.resolve(rootBase);
33657
- const anchor = findExistingDirectoryAnchor(path27__default.dirname(resolvedBase));
33663
+ const resolvedBase = path28__default.resolve(rootBase);
33664
+ const anchor = findExistingDirectoryAnchor(path28__default.dirname(resolvedBase));
33658
33665
  ensureDirectorySegments(anchor, resolvedBase);
33659
33666
  assertDirectorySafe(resolvedBase, "Plugin root base");
33660
33667
  return resolvedBase;
33661
33668
  }
33662
33669
  function assertRootBaseSafe(rootBase) {
33663
- const resolvedBase = path27__default.resolve(rootBase);
33664
- assertExistingSegmentsSafe(findExistingDirectoryAnchor(path27__default.dirname(resolvedBase)), resolvedBase);
33670
+ const resolvedBase = path28__default.resolve(rootBase);
33671
+ assertExistingSegmentsSafe(findExistingDirectoryAnchor(path28__default.dirname(resolvedBase)), resolvedBase);
33665
33672
  assertDirectorySafe(resolvedBase, "Plugin root base");
33666
33673
  return resolvedBase;
33667
33674
  }
33668
33675
  function findExistingDirectoryAnchor(targetPath) {
33669
- const resolvedTarget = path27__default.resolve(targetPath);
33676
+ const resolvedTarget = path28__default.resolve(targetPath);
33670
33677
  let current = resolvedTarget;
33671
33678
  while (true) {
33672
33679
  try {
@@ -33674,7 +33681,7 @@ function findExistingDirectoryAnchor(targetPath) {
33674
33681
  return current;
33675
33682
  } catch (error51) {
33676
33683
  if (error51 instanceof Error && "code" in error51 && error51.code === "ENOENT") {
33677
- const parent = path27__default.dirname(current);
33684
+ const parent = path28__default.dirname(current);
33678
33685
  if (parent === current) throw error51;
33679
33686
  current = parent;
33680
33687
  continue;
@@ -33693,17 +33700,17 @@ function assertDirectorySafe(dirPath, label) {
33693
33700
  }
33694
33701
  }
33695
33702
  function ensurePathWithinRoot(resolvedBase, candidatePath) {
33696
- const resolvedCandidate = path27__default.resolve(candidatePath);
33697
- const relative = path27__default.relative(resolvedBase, resolvedCandidate);
33698
- if (relative === "" || !relative.startsWith("..") && !path27__default.isAbsolute(relative)) return;
33703
+ const resolvedCandidate = path28__default.resolve(candidatePath);
33704
+ const relative = path28__default.relative(resolvedBase, resolvedCandidate);
33705
+ if (relative === "" || !relative.startsWith("..") && !path28__default.isAbsolute(relative)) return;
33699
33706
  throw new Error(`Plugin path escapes root base: ${candidatePath}`);
33700
33707
  }
33701
33708
  function ensureDirectorySegments(resolvedBase, dirPath) {
33702
- const target = path27__default.resolve(dirPath);
33703
- const relative = path27__default.relative(resolvedBase, target);
33709
+ const target = path28__default.resolve(dirPath);
33710
+ const relative = path28__default.relative(resolvedBase, target);
33704
33711
  let current = resolvedBase;
33705
- for (const segment of relative.split(path27__default.sep).filter(Boolean)) {
33706
- current = path27__default.join(current, segment);
33712
+ for (const segment of relative.split(path28__default.sep).filter(Boolean)) {
33713
+ current = path28__default.join(current, segment);
33707
33714
  try {
33708
33715
  const stat3 = lstatSync(current);
33709
33716
  if (stat3.isSymbolicLink()) {
@@ -33724,11 +33731,11 @@ function ensureDirectorySegments(resolvedBase, dirPath) {
33724
33731
  }
33725
33732
  }
33726
33733
  function assertExistingSegmentsSafe(resolvedBase, targetPath) {
33727
- const target = path27__default.resolve(targetPath);
33728
- const relative = path27__default.relative(resolvedBase, target);
33734
+ const target = path28__default.resolve(targetPath);
33735
+ const relative = path28__default.relative(resolvedBase, target);
33729
33736
  let current = resolvedBase;
33730
- for (const segment of relative.split(path27__default.sep).filter(Boolean)) {
33731
- current = path27__default.join(current, segment);
33737
+ for (const segment of relative.split(path28__default.sep).filter(Boolean)) {
33738
+ current = path28__default.join(current, segment);
33732
33739
  const stat3 = lstatSync(current);
33733
33740
  if (stat3.isSymbolicLink()) {
33734
33741
  throw new Error(`Plugin path segment is a symlink: ${current}`);
@@ -33740,27 +33747,22 @@ function assertExistingSegmentsSafe(resolvedBase, targetPath) {
33740
33747
  }
33741
33748
  }
33742
33749
  function assertExistingParentSegmentsSafe(resolvedBase, targetPath) {
33743
- assertExistingSegmentsSafe(resolvedBase, path27__default.dirname(targetPath));
33750
+ assertExistingSegmentsSafe(resolvedBase, path28__default.dirname(targetPath));
33744
33751
  }
33745
33752
  function assertSegmentRealpathWithinRoot(resolvedBase, segmentPath) {
33746
33753
  const baseRealpath = realpathSync(resolvedBase);
33747
33754
  const segmentRealpath = realpathSync(segmentPath);
33748
- const relative = path27__default.relative(baseRealpath, segmentRealpath);
33749
- if (relative === "" || !relative.startsWith("..") && !path27__default.isAbsolute(relative)) return;
33755
+ const relative = path28__default.relative(baseRealpath, segmentRealpath);
33756
+ if (relative === "" || !relative.startsWith("..") && !path28__default.isAbsolute(relative)) return;
33750
33757
  throw new Error(`Plugin path segment escapes root base: ${segmentPath}`);
33751
33758
  }
33752
33759
 
33753
- // ../../packages/fleet-admiral/src/agent-cli/plugin/fleet.ts
33754
- var CURSOR_DOCTRINE_RULE_FILE = "fleet-doctrine.mdc";
33755
- var CURSOR_DOCTRINE_RULE_FRONTMATTER = `---
33756
- description: Fleet Admiral operating doctrine. Always apply in Fleet-launched Cursor Agent sessions.
33757
- globs:
33758
- alwaysApply: true
33759
- ---
33760
- `;
33761
- var CURSOR_DOCTRINE_RULE_PREAMBLE = `# Fleet Runtime Doctrine for Cursor Agent
33760
+ // ../../packages/fleet-admiral/src/agent-cli/doctrine-hook.ts
33761
+ var DOCTRINE_FILE_NAME = "doctrine.md";
33762
+ var DOCTRINE_HOOK_SCRIPT_NAME = "inject-doctrine.mjs";
33763
+ var CURSOR_DOCTRINE_PREAMBLE = `# Fleet Runtime Doctrine for Cursor Agent
33762
33764
 
33763
- You are running as Cursor Agent inside Fleet. Cursor provides this file as a persistent rule, not as a native system prompt. For this Fleet-launched session, treat the embedded Fleet system prompt below as your active Fleet runtime doctrine.
33765
+ You are running as Cursor Agent inside Fleet. This context was injected through a Fleet sessionStart hook. Treat the embedded Fleet system prompt below as your active Fleet runtime doctrine.
33764
33766
 
33765
33767
  Priority and interpretation:
33766
33768
 
@@ -33774,13 +33776,39 @@ Priority and interpretation:
33774
33776
 
33775
33777
  ## Embedded Fleet System Prompt
33776
33778
 
33777
- The following block is the Fleet system prompt content adapted for Cursor's rules mechanism. It is intentionally embedded verbatim after this wrapper.
33779
+ The following block is the Fleet system prompt content adapted for Cursor hook injection. It is intentionally embedded verbatim after this wrapper.
33778
33780
 
33779
33781
  <fleet-system-prompt>
33780
33782
  `;
33781
- var CURSOR_DOCTRINE_RULE_FOOTER = `
33783
+ var CURSOR_DOCTRINE_FOOTER = `
33782
33784
  </fleet-system-prompt>
33783
33785
  `;
33786
+ var INJECT_DOCTRINE_HOOK_SCRIPT = `import fs from "node:fs";
33787
+ import path from "node:path";
33788
+ import { fileURLToPath } from "node:url";
33789
+
33790
+ const pluginRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
33791
+ const doctrine = fs.readFileSync(path.join(pluginRoot, "${DOCTRINE_FILE_NAME}"), "utf8");
33792
+ process.stdout.write(JSON.stringify({ additional_context: doctrine }));
33793
+ `;
33794
+ function formatCursorDoctrine(doctrine) {
33795
+ return `${CURSOR_DOCTRINE_PREAMBLE}${doctrine}${CURSOR_DOCTRINE_FOOTER}`;
33796
+ }
33797
+ function renderCursorDoctrineHookAssets(pluginRoot, doctrine, hookCommandRoot = pluginRoot) {
33798
+ writePrivateFile(
33799
+ path28__default.join(pluginRoot, DOCTRINE_FILE_NAME),
33800
+ formatCursorDoctrine(doctrine),
33801
+ pluginRoot
33802
+ );
33803
+ const scriptPath = path28__default.join(hookCommandRoot, "hooks", DOCTRINE_HOOK_SCRIPT_NAME);
33804
+ writePrivateFile(path28__default.join(pluginRoot, "hooks", DOCTRINE_HOOK_SCRIPT_NAME), INJECT_DOCTRINE_HOOK_SCRIPT, pluginRoot);
33805
+ return {
33806
+ command: process.execPath,
33807
+ args: [scriptPath]
33808
+ };
33809
+ }
33810
+
33811
+ // ../../packages/fleet-admiral/src/agent-cli/plugin/fleet.ts
33784
33812
  var assetBundle = {
33785
33813
  description: "Fleet carrier delegation and wiki evidence plugin",
33786
33814
  directoryName: "fleet",
@@ -33791,11 +33819,16 @@ var assetBundle = {
33791
33819
  };
33792
33820
  function renderAssetPluginRoot(pluginRoot, bundle, options) {
33793
33821
  renderEmbeddedSkillAssets(pluginRoot);
33822
+ const doctrineHookExec = options.cliId === "cursor" && options.doctrine !== void 0 ? renderCursorDoctrineHookAssets(
33823
+ pluginRoot,
33824
+ options.doctrine,
33825
+ options.installedPluginRoot ?? pluginRoot
33826
+ ) : void 0;
33794
33827
  if (options.cliId === "claude") {
33795
- writePrivateJson(path27__default.join(pluginRoot, "hooks", "hooks.json"), claudeHooks(options), pluginRoot);
33828
+ writePrivateJson(path28__default.join(pluginRoot, "hooks", "hooks.json"), claudeHooks(options), pluginRoot);
33796
33829
  }
33797
33830
  if (options.cliId === "cursor") {
33798
- renderCursorPluginRoot(pluginRoot, options);
33831
+ renderCursorPluginRoot(pluginRoot, options, doctrineHookExec);
33799
33832
  }
33800
33833
  }
33801
33834
  function claudeHooks(options) {
@@ -33836,25 +33869,15 @@ function claudeCommandHook(hookExec) {
33836
33869
  type: "command"
33837
33870
  };
33838
33871
  }
33839
- function renderCursorPluginRoot(pluginRoot, options) {
33840
- if (options.doctrine !== void 0) {
33841
- renderCursorDoctrineRule(pluginRoot, options.doctrine);
33842
- }
33872
+ function renderCursorPluginRoot(pluginRoot, options, doctrineHookExec) {
33843
33873
  if ((options.mcpServers ?? []).length > 0) {
33844
- writePrivateJson(path27__default.join(pluginRoot, "mcp.json"), cursorMcpConfig(options.mcpServers ?? []), pluginRoot);
33874
+ writePrivateJson(path28__default.join(pluginRoot, "mcp.json"), cursorMcpConfig(options.mcpServers ?? []), pluginRoot);
33845
33875
  }
33846
- const hooks = cursorHooks(options);
33876
+ const hooks = cursorHooks(options, doctrineHookExec);
33847
33877
  if (hooks !== void 0) {
33848
- writePrivateJson(path27__default.join(pluginRoot, "hooks", "hooks.json"), hooks, pluginRoot);
33878
+ writePrivateJson(path28__default.join(pluginRoot, "hooks", "hooks.json"), hooks, pluginRoot);
33849
33879
  }
33850
33880
  }
33851
- function renderCursorDoctrineRule(pluginRoot, doctrine) {
33852
- writePrivateFile(
33853
- path27__default.join(pluginRoot, "rules", CURSOR_DOCTRINE_RULE_FILE),
33854
- `${CURSOR_DOCTRINE_RULE_FRONTMATTER}${CURSOR_DOCTRINE_RULE_PREAMBLE}${doctrine}${CURSOR_DOCTRINE_RULE_FOOTER}`,
33855
- pluginRoot
33856
- );
33857
- }
33858
33881
  function cursorMcpConfig(servers) {
33859
33882
  return {
33860
33883
  mcpServers: Object.fromEntries(
@@ -33868,8 +33891,8 @@ function cursorMcpConfig(servers) {
33868
33891
  )
33869
33892
  };
33870
33893
  }
33871
- function cursorHooks(options) {
33872
- const sessionStartExecs = [options.captureSessionHookExec].filter((exec) => exec !== void 0);
33894
+ function cursorHooks(options, doctrineHookExec) {
33895
+ const sessionStartExecs = [doctrineHookExec, options.captureSessionHookExec].filter((exec) => exec !== void 0);
33873
33896
  const beforeSubmitPromptExecs = [options.turnStartHookExec, options.autoNameHookExec].filter((exec) => exec !== void 0);
33874
33897
  const stopExecs = [options.turnEndHookExec].filter((exec) => exec !== void 0);
33875
33898
  if (sessionStartExecs.length === 0 && beforeSubmitPromptExecs.length === 0 && stopExecs.length === 0) return void 0;
@@ -33892,7 +33915,7 @@ function cursorCommandHook(hookExec, extraArgs = []) {
33892
33915
  }
33893
33916
  function renderEmbeddedSkillAssets(pluginRoot) {
33894
33917
  for (const asset of EMBEDDED_AGENT_CLI_SKILL_ASSETS) {
33895
- writePrivateFile(path27__default.join(pluginRoot, "skills", asset.relativePath), asset.content, pluginRoot);
33918
+ writePrivateFile(path28__default.join(pluginRoot, "skills", asset.relativePath), asset.content, pluginRoot);
33896
33919
  }
33897
33920
  }
33898
33921
  var CONFIG_FILE_NAME = "config.toml";
@@ -33907,7 +33930,7 @@ function neutralizeCodexFleetPluginConfig(options) {
33907
33930
  mutateCodexConfigWithRetry(options, 0);
33908
33931
  }
33909
33932
  function mutateCodexConfigWithRetry(options, attempt) {
33910
- const configPath = path27__default.join(options.codexHome, CONFIG_FILE_NAME);
33933
+ const configPath = path28__default.join(options.codexHome, CONFIG_FILE_NAME);
33911
33934
  const targetPath = resolveRealConfigPath(configPath);
33912
33935
  const snapshot = readConfigSnapshot(targetPath);
33913
33936
  const nextContent = patchCodexConfig(snapshot.content, options);
@@ -33928,7 +33951,7 @@ function resolveRealConfigPath(configPath) {
33928
33951
  } catch (error51) {
33929
33952
  if (!isNodeError(error51, "ENOENT")) throw error51;
33930
33953
  try {
33931
- return path27__default.join(realpathSync(path27__default.dirname(configPath)), path27__default.basename(configPath));
33954
+ return path28__default.join(realpathSync(path28__default.dirname(configPath)), path28__default.basename(configPath));
33932
33955
  } catch (dirError) {
33933
33956
  if (isNodeError(dirError, "ENOENT")) return configPath;
33934
33957
  throw dirError;
@@ -33965,9 +33988,9 @@ function readConfigSnapshot(configPath) {
33965
33988
  }
33966
33989
  }
33967
33990
  function writeConfigIfUnchanged(configPath, snapshot, content) {
33968
- mkdirSync(path27__default.dirname(configPath), { recursive: true, mode: 448 });
33991
+ mkdirSync(path28__default.dirname(configPath), { recursive: true, mode: 448 });
33969
33992
  assertConfigUnchanged(configPath, snapshot);
33970
- const tempPath = path27__default.join(path27__default.dirname(configPath), `.${path27__default.basename(configPath)}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`);
33993
+ const tempPath = path28__default.join(path28__default.dirname(configPath), `.${path28__default.basename(configPath)}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`);
33971
33994
  let fd;
33972
33995
  try {
33973
33996
  fd = openSync(tempPath, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, CONFIG_FILE_MODE);
@@ -34215,7 +34238,7 @@ function ensureCodexPluginRegisteredOrThrow(registration, command, runCommand) {
34215
34238
  pluginKey
34216
34239
  });
34217
34240
  writePrivateFile(registration.hashPath, `${registration.contentHash}
34218
- `, path27__default.dirname(registration.hashPath));
34241
+ `, path28__default.dirname(registration.hashPath));
34219
34242
  }
34220
34243
  function assertCommandSucceeded(label, result) {
34221
34244
  if (result.status === 0) return;
@@ -34223,7 +34246,7 @@ function assertCommandSucceeded(label, result) {
34223
34246
  throw new Error(`${label} failed${detail.length > 0 ? `: ${detail}` : ""}`);
34224
34247
  }
34225
34248
  function resolveCodexHome(env) {
34226
- return env.CODEX_HOME ?? path27__default.join(env.HOME ?? os3__default.homedir(), ".codex");
34249
+ return env.CODEX_HOME ?? path28__default.join(env.HOME ?? os3__default.homedir(), ".codex");
34227
34250
  }
34228
34251
  function findMarketplaceEntries(result, marketplaceName) {
34229
34252
  return parseMarketplaceEntries(result).filter((entry) => entry.name === marketplaceName);
@@ -34239,7 +34262,7 @@ function parseMarketplaceEntries(result) {
34239
34262
  return entries;
34240
34263
  }
34241
34264
  function normalizeMarketplaceRoot(rootPath, cwd) {
34242
- const resolved = path27__default.resolve(cwd, rootPath);
34265
+ const resolved = path28__default.resolve(cwd, rootPath);
34243
34266
  try {
34244
34267
  return realpathSync(resolved);
34245
34268
  } catch (error51) {
@@ -34263,7 +34286,7 @@ function readHash(hashPath) {
34263
34286
  }
34264
34287
  function removeFlatMarketplaceResidue(projectMarketplaceRoot) {
34265
34288
  for (const entry of FLAT_MARKETPLACE_FS_RESIDUE_ENTRIES) {
34266
- removePrivatePath(path27__default.join(projectMarketplaceRoot, entry), projectMarketplaceRoot);
34289
+ removePrivatePath(path28__default.join(projectMarketplaceRoot, entry), projectMarketplaceRoot);
34267
34290
  }
34268
34291
  }
34269
34292
 
@@ -34323,7 +34346,7 @@ async function createAgentCliPlugin(options) {
34323
34346
  cleanup,
34324
34347
  codexRegistrations: options.cliId === "codex" ? renderableBundles.map(({ bundle, target }, index) => ({
34325
34348
  contentHash: contentHashes.get(target.root),
34326
- hashPath: path27__default.join(target.root, bundle.hashFileName),
34349
+ hashPath: path28__default.join(target.root, bundle.hashFileName),
34327
34350
  marketplaceDir: target.root,
34328
34351
  marketplaceName: target.name,
34329
34352
  pluginName: bundle.name,
@@ -34340,7 +34363,7 @@ function resolveRenderablePluginBundles(fleetRoot) {
34340
34363
  function homeMarketplaceTarget(fleetRoot) {
34341
34364
  return {
34342
34365
  name: FLEET_MARKETPLACE_NAME,
34343
- root: path27__default.join(fleetRoot, MARKETPLACE_DIR_NAME)
34366
+ root: path28__default.join(fleetRoot, MARKETPLACE_DIR_NAME)
34344
34367
  };
34345
34368
  }
34346
34369
  function groupRenderableBundlesByMarketplace(bundles) {
@@ -34356,24 +34379,24 @@ function groupRenderableBundlesByMarketplace(bundles) {
34356
34379
  return groups;
34357
34380
  }
34358
34381
  function renderPluginRoot(pluginRoot, bundle, options) {
34359
- const parentRoot = path27__default.dirname(pluginRoot);
34382
+ const parentRoot = path28__default.dirname(pluginRoot);
34360
34383
  ensurePrivateDir(parentRoot, parentRoot);
34361
34384
  const stageParent = createStagingDir(parentRoot);
34362
- const stagedPluginRoot = path27__default.join(stageParent, path27__default.basename(pluginRoot));
34385
+ const stagedPluginRoot = path28__default.join(stageParent, path28__default.basename(pluginRoot));
34363
34386
  try {
34364
34387
  ensurePrivateDir(stagedPluginRoot, stagedPluginRoot);
34365
- writePrivateJson(path27__default.join(stagedPluginRoot, ".claude-plugin", "plugin.json"), claudeManifest(bundle), stagedPluginRoot);
34388
+ writePrivateJson(path28__default.join(stagedPluginRoot, ".claude-plugin", "plugin.json"), claudeManifest(bundle), stagedPluginRoot);
34366
34389
  switch (bundle.source) {
34367
34390
  case "asset":
34368
34391
  if (options.cliId === "claude") {
34369
- ensurePrivateDir(path27__default.join(stagedPluginRoot, "agents"), stagedPluginRoot);
34392
+ ensurePrivateDir(path28__default.join(stagedPluginRoot, "agents"), stagedPluginRoot);
34370
34393
  }
34371
- ensurePrivateDir(path27__default.join(stagedPluginRoot, "skills"), stagedPluginRoot);
34372
- renderAssetPluginRoot(stagedPluginRoot, bundle, options);
34394
+ ensurePrivateDir(path28__default.join(stagedPluginRoot, "skills"), stagedPluginRoot);
34395
+ renderAssetPluginRoot(stagedPluginRoot, bundle, { ...options, installedPluginRoot: pluginRoot });
34373
34396
  break;
34374
34397
  }
34375
- writePrivateJson(path27__default.join(stagedPluginRoot, ".codex-plugin", "plugin.json"), codexManifest(bundle, stagedPluginRoot), stagedPluginRoot);
34376
- writePrivateJson(path27__default.join(stagedPluginRoot, ".cursor-plugin", "plugin.json"), cursorManifest(bundle, stagedPluginRoot), stagedPluginRoot);
34398
+ writePrivateJson(path28__default.join(stagedPluginRoot, ".codex-plugin", "plugin.json"), codexManifest(bundle, stagedPluginRoot), stagedPluginRoot);
34399
+ writePrivateJson(path28__default.join(stagedPluginRoot, ".cursor-plugin", "plugin.json"), cursorManifest(bundle, stagedPluginRoot), stagedPluginRoot);
34377
34400
  removePrivatePath(pluginRoot, parentRoot);
34378
34401
  renameSync(stagedPluginRoot, pluginRoot);
34379
34402
  } finally {
@@ -34385,13 +34408,13 @@ function renderMarketplaceRoot(target, bundles) {
34385
34408
  ensurePrivateDir(marketplaceRoot, marketplaceRoot);
34386
34409
  const stagedRoot = createStagingDir(marketplaceRoot);
34387
34410
  try {
34388
- writePrivateJson(path27__default.join(stagedRoot, ".agents", "plugins", "marketplace.json"), codexMarketplace(target, bundles), stagedRoot);
34389
- writePrivateJson(path27__default.join(stagedRoot, ".claude-plugin", "marketplace.json"), claudeMarketplace(target, bundles), stagedRoot);
34390
- writePrivateJson(path27__default.join(stagedRoot, ".cursor-plugin", "marketplace.json"), cursorMarketplace(target, bundles), stagedRoot);
34411
+ writePrivateJson(path28__default.join(stagedRoot, ".agents", "plugins", "marketplace.json"), codexMarketplace(target, bundles), stagedRoot);
34412
+ writePrivateJson(path28__default.join(stagedRoot, ".claude-plugin", "marketplace.json"), claudeMarketplace(target, bundles), stagedRoot);
34413
+ writePrivateJson(path28__default.join(stagedRoot, ".cursor-plugin", "marketplace.json"), cursorMarketplace(target, bundles), stagedRoot);
34391
34414
  pruneMarketplaceRoot(target);
34392
34415
  pruneStalePluginDirs(target, bundles);
34393
34416
  for (const entry of readdirSync(stagedRoot)) {
34394
- renameSync(path27__default.join(stagedRoot, entry), path27__default.join(marketplaceRoot, entry));
34417
+ renameSync(path28__default.join(stagedRoot, entry), path28__default.join(marketplaceRoot, entry));
34395
34418
  }
34396
34419
  } finally {
34397
34420
  cleanupPrivateRoot(stagedRoot, marketplaceRoot);
@@ -34399,22 +34422,22 @@ function renderMarketplaceRoot(target, bundles) {
34399
34422
  }
34400
34423
  function pruneMarketplaceRoot(target) {
34401
34424
  for (const entry of MARKETPLACE_PRUNE_ENTRIES) {
34402
- removePrivatePath(path27__default.join(target.root, entry), target.root);
34425
+ removePrivatePath(path28__default.join(target.root, entry), target.root);
34403
34426
  }
34404
34427
  }
34405
34428
  function pruneStalePluginDirs(target, bundles) {
34406
- const pluginsDir = path27__default.join(target.root, PLUGIN_BUNDLES_DIR_NAME);
34429
+ const pluginsDir = path28__default.join(target.root, PLUGIN_BUNDLES_DIR_NAME);
34407
34430
  if (!existsSync(pluginsDir)) return;
34408
34431
  const activeDirectoryNames = new Set(bundles.map((bundle) => bundle.directoryName));
34409
34432
  for (const entry of readdirSync(pluginsDir)) {
34410
34433
  if (activeDirectoryNames.has(entry)) continue;
34411
- removePrivatePath(path27__default.join(pluginsDir, entry), target.root);
34434
+ removePrivatePath(path28__default.join(pluginsDir, entry), target.root);
34412
34435
  }
34413
34436
  }
34414
34437
  function buildContentHash(target) {
34415
34438
  const hash2 = crypto4.createHash("sha256");
34416
34439
  for (const filePath of listRenderableFiles(target)) {
34417
- const relativePath = path27__default.relative(target.root, filePath);
34440
+ const relativePath = path28__default.relative(target.root, filePath);
34418
34441
  hash2.update(relativePath);
34419
34442
  hash2.update("\0");
34420
34443
  hash2.update(readFileSync(filePath));
@@ -34423,14 +34446,14 @@ function buildContentHash(target) {
34423
34446
  return hash2.digest("hex");
34424
34447
  }
34425
34448
  function createStagingDir(rootPath) {
34426
- const stageRoot = mkdtempSync(path27__default.join(rootPath, `.fleet-stage-${process.pid}-${Date.now()}-`));
34449
+ const stageRoot = mkdtempSync(path28__default.join(rootPath, `.fleet-stage-${process.pid}-${Date.now()}-`));
34427
34450
  return stageRoot;
34428
34451
  }
34429
34452
  function listRenderableFiles(target) {
34430
34453
  const files = [];
34431
34454
  const ancestorRealDirs = /* @__PURE__ */ new Set();
34432
34455
  for (const entry of MARKETPLACE_MANAGED_ENTRIES) {
34433
- const entryPath = path27__default.join(target.root, entry);
34456
+ const entryPath = path28__default.join(target.root, entry);
34434
34457
  if (!existsSync(entryPath)) continue;
34435
34458
  collectRenderableFiles(target.root, entryPath, files, ancestorRealDirs);
34436
34459
  }
@@ -34441,8 +34464,8 @@ function collectRenderableFiles(rootPath, currentPath, files, ancestorRealDirs)
34441
34464
  if (ancestorRealDirs.has(realDir)) return;
34442
34465
  ancestorRealDirs.add(realDir);
34443
34466
  for (const entry of readdirSync(currentPath)) {
34444
- const entryPath = path27__default.join(currentPath, entry);
34445
- const relativePath = path27__default.relative(rootPath, entryPath);
34467
+ const entryPath = path28__default.join(currentPath, entry);
34468
+ const relativePath = path28__default.relative(rootPath, entryPath);
34446
34469
  if (HASH_IGNORED_RELATIVE_PATHS.has(relativePath)) continue;
34447
34470
  const stat3 = lstatSync(entryPath);
34448
34471
  if (stat3.isSymbolicLink()) {
@@ -34519,7 +34542,7 @@ function cursorMarketplace(target, bundles) {
34519
34542
  };
34520
34543
  }
34521
34544
  function pluginRootForTarget(target, bundle) {
34522
- return path27__default.join(target.root, PLUGIN_BUNDLES_DIR_NAME, bundle.directoryName);
34545
+ return path28__default.join(target.root, PLUGIN_BUNDLES_DIR_NAME, bundle.directoryName);
34523
34546
  }
34524
34547
  function marketplacePluginPath(target, bundle) {
34525
34548
  return `./${PLUGIN_BUNDLES_DIR_NAME}/${bundle.directoryName}`;
@@ -34546,7 +34569,7 @@ function cursorManifestVersion(bundle, pluginRoot) {
34546
34569
  hash2.update(bundle.description);
34547
34570
  hash2.update("\0");
34548
34571
  for (const filePath of listCursorEffectivePluginFiles(pluginRoot)) {
34549
- const relativePath = path27__default.relative(pluginRoot, filePath);
34572
+ const relativePath = path28__default.relative(pluginRoot, filePath);
34550
34573
  hash2.update(relativePath);
34551
34574
  hash2.update("\0");
34552
34575
  hash2.update(readFileSync(filePath));
@@ -34561,7 +34584,7 @@ function codexManifestVersion(bundle, pluginRoot) {
34561
34584
  hash2.update(bundle.description);
34562
34585
  hash2.update("\0");
34563
34586
  for (const filePath of listCodexEffectivePluginFiles(pluginRoot)) {
34564
- const relativePath = path27__default.relative(pluginRoot, filePath);
34587
+ const relativePath = path28__default.relative(pluginRoot, filePath);
34565
34588
  hash2.update(relativePath);
34566
34589
  hash2.update("\0");
34567
34590
  hash2.update(readFileSync(filePath));
@@ -34570,7 +34593,7 @@ function codexManifestVersion(bundle, pluginRoot) {
34570
34593
  return `0.0.0+${hash2.digest("hex").slice(0, 12)}`;
34571
34594
  }
34572
34595
  function listCodexEffectivePluginFiles(pluginRoot) {
34573
- const skillsPath = path27__default.join(pluginRoot, "skills");
34596
+ const skillsPath = path28__default.join(pluginRoot, "skills");
34574
34597
  if (!existsSync(skillsPath)) return [];
34575
34598
  const files = [];
34576
34599
  collectRenderableFiles(pluginRoot, skillsPath, files, /* @__PURE__ */ new Set());
@@ -34578,8 +34601,8 @@ function listCodexEffectivePluginFiles(pluginRoot) {
34578
34601
  }
34579
34602
  function listCursorEffectivePluginFiles(pluginRoot) {
34580
34603
  const files = [];
34581
- for (const entry of ["skills", "rules", "hooks", "mcp.json"]) {
34582
- const entryPath = path27__default.join(pluginRoot, entry);
34604
+ for (const entry of ["skills", "hooks", "doctrine.md", "mcp.json"]) {
34605
+ const entryPath = path28__default.join(pluginRoot, entry);
34583
34606
  if (!existsSync(entryPath)) continue;
34584
34607
  const stat3 = lstatSync(entryPath);
34585
34608
  if (stat3.isFile()) {
@@ -34652,8 +34675,8 @@ async function injectAgentCliProfile(profile, options) {
34652
34675
  env: { ...profile.env }
34653
34676
  }, requireCodexCommandRunner(options.codexCommandRunner), options.withMarketplaceLock, {
34654
34677
  homeMarketplaceName: FLEET_MARKETPLACE_NAME,
34655
- homeMarketplaceRoot: path27__default.join(options.pluginRootDir ?? options.dataDir ?? getFleetDataDir(), "marketplace"),
34656
- projectMarketplaceRoot: path27__default.join(profile.cwd, ".fleet")
34678
+ homeMarketplaceRoot: path28__default.join(options.pluginRootDir ?? options.dataDir ?? getFleetDataDir(), "marketplace"),
34679
+ projectMarketplaceRoot: path28__default.join(profile.cwd, ".fleet")
34657
34680
  });
34658
34681
  if (cleanupWarning !== void 0) {
34659
34682
  launchWarnings.push(`Deprecated Codex plugin cleanup failed: ${cleanupWarning}`);
@@ -34716,19 +34739,19 @@ function buildAgentCliMcpServerConfigs(endpoints, tokens) {
34716
34739
  });
34717
34740
  }
34718
34741
  function writeSystemPromptFile(cliId, systemPrompt, onCleanup) {
34719
- const tempDir = mkdtempSync(path27__default.join(os3__default.tmpdir(), `fleet-${cliId}-`));
34742
+ const tempDir = mkdtempSync(path28__default.join(os3__default.tmpdir(), `fleet-${cliId}-`));
34720
34743
  onCleanup(() => rmBestEffort(tempDir));
34721
- const filePath = path27__default.join(tempDir, "system-prompt.md");
34744
+ const filePath = path28__default.join(tempDir, "system-prompt.md");
34722
34745
  writeFileSync(filePath, systemPrompt, { encoding: "utf8", flag: "wx", mode: SYSTEM_PROMPT_FILE_MODE });
34723
34746
  chmodBestEffort2(filePath, SYSTEM_PROMPT_FILE_MODE);
34724
34747
  return filePath;
34725
34748
  }
34726
34749
  function writeCodexFleetProfile(env, doctrine, pluginKeys, hookExecs) {
34727
- const codexHome = env.CODEX_HOME ?? path27__default.join(env.HOME ?? os3__default.homedir(), ".codex");
34750
+ const codexHome = env.CODEX_HOME ?? path28__default.join(env.HOME ?? os3__default.homedir(), ".codex");
34728
34751
  mkdirSync(codexHome, { recursive: true });
34729
34752
  pruneLegacyCodexFleetProfiles(codexHome);
34730
34753
  const profileName = CODEX_FLEET_PROFILE_NAME;
34731
- const profilePath = path27__default.join(codexHome, CODEX_FLEET_PROFILE_FILE_NAME);
34754
+ const profilePath = path28__default.join(codexHome, CODEX_FLEET_PROFILE_FILE_NAME);
34732
34755
  const hookTrustState = readCodexFleetHookTrustState(profilePath);
34733
34756
  writeFileNoFollow2(profilePath, [
34734
34757
  CODEX_FLEET_PROFILE_MARKER,
@@ -34742,7 +34765,7 @@ function writeCodexFleetProfile(env, doctrine, pluginKeys, hookExecs) {
34742
34765
  "hooks = true",
34743
34766
  "",
34744
34767
  ...pluginKeys.flatMap((pluginKey) => [
34745
- `[plugins."${escapeTomlBasicString2(pluginKey)}"]`,
34768
+ `[plugins."${escapeTomlBasicString(pluginKey)}"]`,
34746
34769
  "enabled = true",
34747
34770
  ""
34748
34771
  ]),
@@ -34769,7 +34792,7 @@ function codexHooksConfig(hookExecs) {
34769
34792
  function codexHookHandlersInline(execs) {
34770
34793
  const handlers = execs.map((exec) => {
34771
34794
  const command = buildPosixShellCommand([exec.command, ...exec.args]);
34772
- return `{ type = "command", command = "${escapeTomlBasicString2(command)}" }`;
34795
+ return `{ type = "command", command = "${escapeTomlBasicString(command)}" }`;
34773
34796
  }).join(", ");
34774
34797
  return `[{ hooks = [${handlers}] }]`;
34775
34798
  }
@@ -34832,7 +34855,7 @@ function pruneLegacyCodexFleetProfiles(codexHome) {
34832
34855
  }
34833
34856
  for (const entry of entries) {
34834
34857
  if (!CODEX_LEGACY_FLEET_PROFILE_FILE_NAME_PATTERN.test(entry)) continue;
34835
- const filePath = path27__default.join(codexHome, entry);
34858
+ const filePath = path28__default.join(codexHome, entry);
34836
34859
  if (!isLegacyFleetCodexProfile(filePath)) continue;
34837
34860
  unlinkBestEffort2(filePath);
34838
34861
  }
@@ -35285,7 +35308,7 @@ function extractLegacyMarkdownWikiLinks(body, wikiDir, basePath) {
35285
35308
  }
35286
35309
  function resolveLegacyWikiTarget(target, wikiDir, basePath) {
35287
35310
  if (!target || target.startsWith("#")) return null;
35288
- if (path27__default.isAbsolute(target)) return null;
35311
+ if (path28__default.isAbsolute(target)) return null;
35289
35312
  if (/^[a-z][a-z0-9+.-]*:/i.test(target)) return null;
35290
35313
  const withoutFragment = target.split("#", 1)[0]?.split("?", 1)[0] ?? "";
35291
35314
  if (!withoutFragment.endsWith(".md")) return null;
@@ -35295,12 +35318,12 @@ function resolveLegacyWikiTarget(target, wikiDir, basePath) {
35295
35318
  } catch {
35296
35319
  return null;
35297
35320
  }
35298
- const resolved = path27__default.resolve(path27__default.dirname(basePath), decodedTarget);
35299
- const relative = path27__default.relative(wikiDir, resolved);
35300
- if (!relative || relative.startsWith("..") || path27__default.isAbsolute(relative)) return null;
35321
+ const resolved = path28__default.resolve(path28__default.dirname(basePath), decodedTarget);
35322
+ const relative = path28__default.relative(wikiDir, resolved);
35323
+ if (!relative || relative.startsWith("..") || path28__default.isAbsolute(relative)) return null;
35301
35324
  return {
35302
35325
  target,
35303
- entryId: path27__default.basename(relative, ".md")
35326
+ entryId: path28__default.basename(relative, ".md")
35304
35327
  };
35305
35328
  }
35306
35329
 
@@ -35560,18 +35583,18 @@ Always read \`schema/wiki-schema.md\` directly before composing or revising entr
35560
35583
  `;
35561
35584
  async function ensureWorkspaceSchema(paths) {
35562
35585
  await mkdir(paths.schemaDir, { recursive: true });
35563
- await writeDefaultFileIfMissing(path27__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME), DEFAULT_WORKSPACE_SCHEMA_AGENTS);
35564
- await writeDefaultFileIfMissing(path27__default.join(paths.schemaDir, WORKSPACE_SCHEMA_FILENAME), DEFAULT_WORKSPACE_WIKI_SCHEMA);
35586
+ await writeDefaultFileIfMissing(path28__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME), DEFAULT_WORKSPACE_SCHEMA_AGENTS);
35587
+ await writeDefaultFileIfMissing(path28__default.join(paths.schemaDir, WORKSPACE_SCHEMA_FILENAME), DEFAULT_WORKSPACE_WIKI_SCHEMA);
35565
35588
  await writeDefaultFileIfMissing(buildTemplatePath(paths, "prd"), DEFAULT_TEMPLATE_PRD);
35566
35589
  return readWorkspaceSchemaSummary(paths);
35567
35590
  }
35568
35591
  async function ensureWorkspaceDoctrine(paths) {
35569
35592
  await mkdir(paths.root, { recursive: true });
35570
- await writeDefaultFileIfMissing(path27__default.join(paths.root, WORKSPACE_KNOWLEDGE_AGENTS_FILENAME), DEFAULT_WORKSPACE_KNOWLEDGE_AGENTS);
35593
+ await writeDefaultFileIfMissing(path28__default.join(paths.root, WORKSPACE_KNOWLEDGE_AGENTS_FILENAME), DEFAULT_WORKSPACE_KNOWLEDGE_AGENTS);
35571
35594
  }
35572
35595
  async function readWorkspaceSchemaSummary(paths) {
35573
- const agentsPath = path27__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME);
35574
- const wikiSchemaPath = path27__default.join(paths.schemaDir, WORKSPACE_SCHEMA_FILENAME);
35596
+ const agentsPath = path28__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME);
35597
+ const wikiSchemaPath = path28__default.join(paths.schemaDir, WORKSPACE_SCHEMA_FILENAME);
35575
35598
  const wikiSchemaContent = await tryReadFile(wikiSchemaPath);
35576
35599
  const templates = await scanTemplates(paths);
35577
35600
  if (wikiSchemaContent === null) {
@@ -35610,7 +35633,7 @@ async function scanTemplates(paths) {
35610
35633
  if (!entry.name.startsWith(WORKSPACE_TEMPLATE_PREFIX) || !entry.name.endsWith(WORKSPACE_TEMPLATE_SUFFIX)) continue;
35611
35634
  const id = entry.name.slice(WORKSPACE_TEMPLATE_PREFIX.length, -WORKSPACE_TEMPLATE_SUFFIX.length);
35612
35635
  if (!id) continue;
35613
- const filePath = path27__default.join(paths.schemaDir, entry.name);
35636
+ const filePath = path28__default.join(paths.schemaDir, entry.name);
35614
35637
  try {
35615
35638
  const parsed = parseTemplateMarkdown(await readFile(filePath, "utf8"));
35616
35639
  templates.push({
@@ -35644,7 +35667,7 @@ async function validateTemplateCompliance(paths, templateId, body) {
35644
35667
  }
35645
35668
  }
35646
35669
  function inferTemplateIdFromTarget(target, knownTemplateIds) {
35647
- const basename = path27__default.basename(target, ".md");
35670
+ const basename = path28__default.basename(target, ".md");
35648
35671
  const ids = knownTemplateIds ?? DEFAULT_TEMPLATE_IDS;
35649
35672
  const sorted = [...ids].sort((a, b) => b.length - a.length);
35650
35673
  for (const id of sorted) {
@@ -35673,7 +35696,7 @@ function extractSchemaSummary(content) {
35673
35696
  return lines.find((line) => line.length > 0 && !line.startsWith("#")) ?? "Workspace schema is present.";
35674
35697
  }
35675
35698
  function buildTemplatePath(paths, id) {
35676
- return path27__default.join(paths.schemaDir, `${WORKSPACE_TEMPLATE_PREFIX}${id}${WORKSPACE_TEMPLATE_SUFFIX}`);
35699
+ return path28__default.join(paths.schemaDir, `${WORKSPACE_TEMPLATE_PREFIX}${id}${WORKSPACE_TEMPLATE_SUFFIX}`);
35677
35700
  }
35678
35701
  function parseTemplateMarkdown(content) {
35679
35702
  const normalized = content.replace(/\r\n/g, "\n");
@@ -35700,16 +35723,16 @@ function isAlreadyExistsError(error51) {
35700
35723
 
35701
35724
  // ../../packages/fleet-wiki/src/paths.ts
35702
35725
  function resolveMemoryPaths(cwd) {
35703
- const root = path27__default.join(cwd, KNOWLEDGE_ROOT_DIRNAME);
35726
+ const root = path28__default.join(cwd, KNOWLEDGE_ROOT_DIRNAME);
35704
35727
  return {
35705
35728
  root,
35706
- rawDir: path27__default.join(root, RAW_DIRNAME),
35707
- wikiDir: path27__default.join(root, WIKI_DIRNAME),
35708
- schemaDir: path27__default.join(root, SCHEMA_DIRNAME),
35709
- queueDir: path27__default.join(root, QUEUE_DIRNAME),
35710
- archiveDir: path27__default.join(root, ARCHIVE_DIRNAME),
35711
- conflictsDir: path27__default.join(root, CONFLICTS_DIRNAME),
35712
- indexFile: path27__default.join(root, INDEX_FILENAME)
35729
+ rawDir: path28__default.join(root, RAW_DIRNAME),
35730
+ wikiDir: path28__default.join(root, WIKI_DIRNAME),
35731
+ schemaDir: path28__default.join(root, SCHEMA_DIRNAME),
35732
+ queueDir: path28__default.join(root, QUEUE_DIRNAME),
35733
+ archiveDir: path28__default.join(root, ARCHIVE_DIRNAME),
35734
+ conflictsDir: path28__default.join(root, CONFLICTS_DIRNAME),
35735
+ indexFile: path28__default.join(root, INDEX_FILENAME)
35713
35736
  };
35714
35737
  }
35715
35738
  async function ensureMemoryRoot(paths) {
@@ -35724,10 +35747,10 @@ async function ensureMemoryRoot(paths) {
35724
35747
  await ensureWorkspaceDoctrine(paths);
35725
35748
  }
35726
35749
  function getIndexMarkdownFile(paths) {
35727
- return path27__default.join(paths.wikiDir, INDEX_MD_FILENAME);
35750
+ return path28__default.join(paths.wikiDir, INDEX_MD_FILENAME);
35728
35751
  }
35729
35752
  function getLogFile(paths) {
35730
- return path27__default.join(paths.root, LOG_MD_FILENAME);
35753
+ return path28__default.join(paths.root, LOG_MD_FILENAME);
35731
35754
  }
35732
35755
 
35733
35756
  // ../../packages/fleet-wiki/src/log.ts
@@ -35891,12 +35914,12 @@ async function readWikiEntry(id, paths) {
35891
35914
  const index = await loadIndex(paths);
35892
35915
  const indexed = index[id];
35893
35916
  if (indexed) {
35894
- const resolved = path27__default.resolve(paths.root, indexed.path);
35895
- const rel = path27__default.relative(paths.wikiDir, resolved);
35896
- if (!rel || rel.startsWith("..") || path27__default.isAbsolute(rel)) return null;
35917
+ const resolved = path28__default.resolve(paths.root, indexed.path);
35918
+ const rel = path28__default.relative(paths.wikiDir, resolved);
35919
+ if (!rel || rel.startsWith("..") || path28__default.isAbsolute(rel)) return null;
35897
35920
  return readMarkdownFile(resolved);
35898
35921
  }
35899
- const fallbackPath = path27__default.join(paths.wikiDir, `${id}.md`);
35922
+ const fallbackPath = path28__default.join(paths.wikiDir, `${id}.md`);
35900
35923
  if (await pathExists(fallbackPath)) {
35901
35924
  return readMarkdownFile(fallbackPath);
35902
35925
  }
@@ -35907,20 +35930,20 @@ async function readWikiEntry(id, paths) {
35907
35930
  async function writeWikiEntryAtTarget(entry, target, paths) {
35908
35931
  await ensureMemoryRoot(paths);
35909
35932
  assertSafeEntryId(entry.id);
35910
- const absoluteTarget = path27__default.resolve(paths.root, target);
35911
- const relativeTarget = path27__default.relative(paths.wikiDir, absoluteTarget);
35912
- if (!relativeTarget || relativeTarget.startsWith("..") || path27__default.isAbsolute(relativeTarget)) {
35933
+ const absoluteTarget = path28__default.resolve(paths.root, target);
35934
+ const relativeTarget = path28__default.relative(paths.wikiDir, absoluteTarget);
35935
+ if (!relativeTarget || relativeTarget.startsWith("..") || path28__default.isAbsolute(relativeTarget)) {
35913
35936
  throw new Error(`[fleet-wiki] wiki target escapes wiki/: ${target}`);
35914
35937
  }
35915
35938
  if (!absoluteTarget.endsWith(".md")) {
35916
35939
  throw new Error(`[fleet-wiki] wiki target must end with .md: ${target}`);
35917
35940
  }
35918
- if (path27__default.basename(absoluteTarget, ".md") !== entry.id) {
35941
+ if (path28__default.basename(absoluteTarget, ".md") !== entry.id) {
35919
35942
  throw new Error("wiki patch body id must match target filename");
35920
35943
  }
35921
- await mkdir(path27__default.dirname(absoluteTarget), { recursive: true });
35944
+ await mkdir(path28__default.dirname(absoluteTarget), { recursive: true });
35922
35945
  await writeMarkdownAtomic(absoluteTarget, serializeWikiEntry(entry), paths);
35923
- return path27__default.join("wiki", relativeTarget).replaceAll(path27__default.sep, "/");
35946
+ return path28__default.join("wiki", relativeTarget).replaceAll(path28__default.sep, "/");
35924
35947
  }
35925
35948
  async function writeRawSourceEntry(entry, paths) {
35926
35949
  await ensureMemoryRoot(paths);
@@ -35939,11 +35962,11 @@ async function writeRawSourceEntry(entry, paths) {
35939
35962
  },
35940
35963
  entry.content
35941
35964
  );
35942
- await writeMarkdownAtomic(path27__default.join(paths.root, relativePath), content, paths);
35965
+ await writeMarkdownAtomic(path28__default.join(paths.root, relativePath), content, paths);
35943
35966
  return relativePath;
35944
35967
  }
35945
35968
  async function readRawSourceEntry(rawSourceRef, paths) {
35946
- const absolutePath = path27__default.resolve(paths.root, rawSourceRef);
35969
+ const absolutePath = path28__default.resolve(paths.root, rawSourceRef);
35947
35970
  assertWithinRawDir(absolutePath, paths);
35948
35971
  const parsed = parseMarkdown(await readFile(absolutePath, "utf8"));
35949
35972
  return {
@@ -36134,8 +36157,8 @@ function computeContentHash(content) {
36134
36157
  return crypto4.createHash("sha256").update(content, "utf8").digest("hex").slice(0, 8);
36135
36158
  }
36136
36159
  function assertWithinRawDir(absolutePath, paths) {
36137
- const relative = path27__default.relative(paths.rawDir, absolutePath);
36138
- if (!relative || relative.startsWith("..") || path27__default.isAbsolute(relative)) {
36160
+ const relative = path28__default.relative(paths.rawDir, absolutePath);
36161
+ if (!relative || relative.startsWith("..") || path28__default.isAbsolute(relative)) {
36139
36162
  throw new Error(`[fleet-wiki] raw source ref escapes raw/: ${absolutePath}`);
36140
36163
  }
36141
36164
  }
@@ -36191,7 +36214,7 @@ function parseWikiEntry(content) {
36191
36214
  async function listWikiRecords(paths) {
36192
36215
  return listMarkdownEntriesRecursive(paths.wikiDir, paths, (content, filePath) => ({
36193
36216
  entry: parseWikiEntry(content),
36194
- path: path27__default.relative(paths.root, filePath).replaceAll(path27__default.sep, "/")
36217
+ path: path28__default.relative(paths.root, filePath).replaceAll(path28__default.sep, "/")
36195
36218
  }));
36196
36219
  }
36197
36220
  async function listMarkdownEntriesRecursive(dirPath, paths, parser) {
@@ -36204,7 +36227,7 @@ async function listMarkdownEntriesRecursive(dirPath, paths, parser) {
36204
36227
  }
36205
36228
  const sortedEntries = entries.sort((left, right) => left.name.localeCompare(right.name));
36206
36229
  for (const entry of sortedEntries) {
36207
- const filePath = path27__default.join(dirPath, entry.name);
36230
+ const filePath = path28__default.join(dirPath, entry.name);
36208
36231
  if (entry.isDirectory()) {
36209
36232
  items.push(...await listMarkdownEntriesRecursive(filePath, paths, parser));
36210
36233
  continue;
@@ -36342,8 +36365,8 @@ async function writeJsonAtomic(filePath, value, paths) {
36342
36365
  }
36343
36366
  async function writeAtomic(filePath, content, paths) {
36344
36367
  await ensureMemoryRoot(paths);
36345
- const tempPath = path27__default.join(
36346
- path27__default.dirname(filePath),
36368
+ const tempPath = path28__default.join(
36369
+ path28__default.dirname(filePath),
36347
36370
  `.tmp-${process.pid}-${Date.now()}-${crypto4.randomUUID()}-${os3__default.hostname()}`
36348
36371
  );
36349
36372
  await writeFile(tempPath, content, "utf8");
@@ -36390,7 +36413,7 @@ async function enhancedSearch(paths, options) {
36390
36413
  for (const entry of entries) {
36391
36414
  if (!index[entry.id]) {
36392
36415
  index[entry.id] = {
36393
- path: path27__default.join("wiki", `${entry.id}.md`),
36416
+ path: path28__default.join("wiki", `${entry.id}.md`),
36394
36417
  title: entry.title,
36395
36418
  tags: entry.tags,
36396
36419
  updated: entry.updated
@@ -36526,7 +36549,7 @@ function toEnhancedHit(entry, signals) {
36526
36549
  score: enhancedScore,
36527
36550
  reason: signals.legacyReason ?? "body",
36528
36551
  excerpt,
36529
- path: path27__default.join("wiki", `${entry.id}.md`),
36552
+ path: path28__default.join("wiki", `${entry.id}.md`),
36530
36553
  tags: entry.tags,
36531
36554
  updated: entry.updated,
36532
36555
  version: entry.version,
@@ -36722,7 +36745,7 @@ function toRankedHit(entry, reason, detail, graphBoost, backlinksById) {
36722
36745
  score: basePriority * 100 + statusPriority * 10 + graphScore + (detail.tagBoost ?? 0),
36723
36746
  reason,
36724
36747
  excerpt,
36725
- path: path27__default.join("wiki", `${entry.id}.md`),
36748
+ path: path28__default.join("wiki", `${entry.id}.md`),
36726
36749
  tags: entry.tags,
36727
36750
  updated: entry.updated,
36728
36751
  version: entry.version,
@@ -37150,15 +37173,15 @@ var PATCH_SET_DIRNAME = "_sets";
37150
37173
  var PATCH_SET_META_FILENAME = PATCH_META_FILENAME;
37151
37174
  function getPatchSetDir(paths, patchSetId) {
37152
37175
  assertSafePatchSetId(patchSetId);
37153
- const patchSetDir = path27__default.join(paths.queueDir, PATCH_SET_DIRNAME, patchSetId);
37154
- const relative = path27__default.relative(path27__default.join(paths.queueDir, PATCH_SET_DIRNAME), patchSetDir);
37155
- if (!relative || relative.startsWith("..") || path27__default.isAbsolute(relative)) {
37176
+ const patchSetDir = path28__default.join(paths.queueDir, PATCH_SET_DIRNAME, patchSetId);
37177
+ const relative = path28__default.relative(path28__default.join(paths.queueDir, PATCH_SET_DIRNAME), patchSetDir);
37178
+ if (!relative || relative.startsWith("..") || path28__default.isAbsolute(relative)) {
37156
37179
  throw new Error(`[fleet-wiki] patch set id escapes queue/_sets: ${patchSetId}`);
37157
37180
  }
37158
37181
  return patchSetDir;
37159
37182
  }
37160
37183
  function getPatchSetMetaFile(paths, patchSetId) {
37161
- return path27__default.join(getPatchSetDir(paths, patchSetId), PATCH_SET_META_FILENAME);
37184
+ return path28__default.join(getPatchSetDir(paths, patchSetId), PATCH_SET_META_FILENAME);
37162
37185
  }
37163
37186
  function buildPatchSetId(createdAt, sourceRef) {
37164
37187
  const compact = createdAt.replace(/[:.]/g, "-");
@@ -37191,7 +37214,7 @@ async function createConflict(input, paths) {
37191
37214
  await ensureMemoryRoot(paths);
37192
37215
  const now = input.now ?? /* @__PURE__ */ new Date();
37193
37216
  const conflictId = buildConflictId(now, input.wikiId, input.reason, input.proposed);
37194
- const conflictDir = path27__default.join(paths.conflictsDir, conflictId);
37217
+ const conflictDir = path28__default.join(paths.conflictsDir, conflictId);
37195
37218
  await mkdir(conflictDir, { recursive: true });
37196
37219
  const meta3 = {
37197
37220
  id: conflictId,
@@ -37211,13 +37234,13 @@ async function createConflict(input, paths) {
37211
37234
  currentHash: input.currentHash,
37212
37235
  warnings: input.warnings
37213
37236
  };
37214
- await writeJsonFile(path27__default.join(conflictDir, CONFLICT_META_FILENAME), meta3, paths);
37215
- await writePatchFile(path27__default.join(conflictDir, CONFLICT_PROPOSED_FILENAME), input.proposed, paths);
37237
+ await writeJsonFile(path28__default.join(conflictDir, CONFLICT_META_FILENAME), meta3, paths);
37238
+ await writePatchFile(path28__default.join(conflictDir, CONFLICT_PROPOSED_FILENAME), input.proposed, paths);
37216
37239
  if (input.current !== void 0) {
37217
- await writePatchFile(path27__default.join(conflictDir, CONFLICT_CURRENT_FILENAME), input.current, paths);
37240
+ await writePatchFile(path28__default.join(conflictDir, CONFLICT_CURRENT_FILENAME), input.current, paths);
37218
37241
  }
37219
37242
  if (input.rawSource !== void 0) {
37220
- await writePatchFile(path27__default.join(conflictDir, CONFLICT_RAW_SOURCE_FILENAME), input.rawSource, paths);
37243
+ await writePatchFile(path28__default.join(conflictDir, CONFLICT_RAW_SOURCE_FILENAME), input.rawSource, paths);
37221
37244
  }
37222
37245
  return {
37223
37246
  meta: meta3,
@@ -37231,7 +37254,7 @@ async function listConflicts(paths) {
37231
37254
  const metas = [];
37232
37255
  for (const id of ids) {
37233
37256
  try {
37234
- metas.push(await readJsonFile2(path27__default.join(paths.conflictsDir, id, CONFLICT_META_FILENAME)));
37257
+ metas.push(await readJsonFile2(path28__default.join(paths.conflictsDir, id, CONFLICT_META_FILENAME)));
37235
37258
  } catch {
37236
37259
  continue;
37237
37260
  }
@@ -37240,13 +37263,13 @@ async function listConflicts(paths) {
37240
37263
  }
37241
37264
  async function readConflict(conflictId, paths) {
37242
37265
  const conflictDir = resolveConflictDir(conflictId, paths);
37243
- const meta3 = await readJsonFile2(path27__default.join(conflictDir, CONFLICT_META_FILENAME));
37244
- const currentPath = path27__default.join(conflictDir, CONFLICT_CURRENT_FILENAME);
37245
- const rawSourcePath = path27__default.join(conflictDir, CONFLICT_RAW_SOURCE_FILENAME);
37266
+ const meta3 = await readJsonFile2(path28__default.join(conflictDir, CONFLICT_META_FILENAME));
37267
+ const currentPath = path28__default.join(conflictDir, CONFLICT_CURRENT_FILENAME);
37268
+ const rawSourcePath = path28__default.join(conflictDir, CONFLICT_RAW_SOURCE_FILENAME);
37246
37269
  return {
37247
37270
  meta: meta3,
37248
37271
  current: await pathExists(currentPath) ? await readPatchFile(currentPath) : void 0,
37249
- proposed: await readPatchFile(path27__default.join(conflictDir, CONFLICT_PROPOSED_FILENAME)),
37272
+ proposed: await readPatchFile(path28__default.join(conflictDir, CONFLICT_PROPOSED_FILENAME)),
37250
37273
  rawSource: await pathExists(rawSourcePath) ? await readPatchFile(rawSourcePath) : void 0
37251
37274
  };
37252
37275
  }
@@ -37265,9 +37288,9 @@ function sanitizeConflictToken(value) {
37265
37288
  return value.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "unknown";
37266
37289
  }
37267
37290
  function resolveConflictDir(conflictId, paths) {
37268
- const conflictDir = path27__default.resolve(paths.conflictsDir, conflictId);
37269
- const relative = path27__default.relative(paths.conflictsDir, conflictDir);
37270
- if (!relative || relative.startsWith("..") || path27__default.isAbsolute(relative)) {
37291
+ const conflictDir = path28__default.resolve(paths.conflictsDir, conflictId);
37292
+ const relative = path28__default.relative(paths.conflictsDir, conflictDir);
37293
+ if (!relative || relative.startsWith("..") || path28__default.isAbsolute(relative)) {
37271
37294
  throw new Error(`[fleet-wiki] conflict id escapes conflicts/: ${conflictId}`);
37272
37295
  }
37273
37296
  return conflictDir;
@@ -37305,11 +37328,11 @@ async function validatePatch(patch, paths) {
37305
37328
  if (!target || !summary || !proposer || !created) throw new Error("patch frontmatter is incomplete");
37306
37329
  if (summary.length > 120) throw new Error("patch summary exceeds 120 chars");
37307
37330
  assertCanonicalPatchTarget(target);
37308
- const absoluteTarget = path27__default.resolve(paths.root, target);
37309
- if (!absoluteTarget.startsWith(`${paths.root}${path27__default.sep}`) && absoluteTarget !== paths.root) {
37331
+ const absoluteTarget = path28__default.resolve(paths.root, target);
37332
+ if (!absoluteTarget.startsWith(`${paths.root}${path28__default.sep}`) && absoluteTarget !== paths.root) {
37310
37333
  throw new Error("patch target escapes wiki root");
37311
37334
  }
37312
- if (!absoluteTarget.startsWith(`${paths.wikiDir}${path27__default.sep}`)) throw new Error("wiki patch must target wiki/");
37335
+ if (!absoluteTarget.startsWith(`${paths.wikiDir}${path28__default.sep}`)) throw new Error("wiki patch must target wiki/");
37313
37336
  assertNoSymlinkPathComponents(target, paths);
37314
37337
  if (op === "create_wiki" && await pathExists(absoluteTarget)) {
37315
37338
  throw new Error(
@@ -37330,19 +37353,19 @@ async function applyPatch(patch, paths) {
37330
37353
  async function enqueuePatch(patch, paths, metaOverrides) {
37331
37354
  await ensureMemoryRoot(paths);
37332
37355
  const patchId = buildPatchId(patch.frontmatter.created, patch.frontmatter.summary, patch.frontmatter.target, patch.body);
37333
- const queueDir = path27__default.join(paths.queueDir, patchId);
37356
+ const queueDir = path28__default.join(paths.queueDir, patchId);
37334
37357
  if (await pathExists(queueDir)) {
37335
37358
  throw new Error(`[fleet-wiki] patch id collision: ${patchId} - this should never happen with target+body hashing`);
37336
37359
  }
37337
37360
  await mkdir(queueDir, { recursive: true });
37338
- await writePatchFile(path27__default.join(queueDir, PATCH_FILENAME), serializePatch(patch), paths);
37361
+ await writePatchFile(path28__default.join(queueDir, PATCH_FILENAME), serializePatch(patch), paths);
37339
37362
  const meta3 = {
37340
37363
  id: patchId,
37341
37364
  status: "pending",
37342
37365
  createdAt: patch.frontmatter.created,
37343
37366
  ...metaOverrides
37344
37367
  };
37345
- await writeJsonFile(path27__default.join(queueDir, PATCH_META_FILENAME), meta3, paths);
37368
+ await writeJsonFile(path28__default.join(queueDir, PATCH_META_FILENAME), meta3, paths);
37346
37369
  await appendLog(paths, "patch enqueued", {
37347
37370
  patch_id: patchId,
37348
37371
  patch_set_id: meta3.patch_set_id ?? null,
@@ -37360,7 +37383,7 @@ async function listQueue(paths) {
37360
37383
  for (const id of ids) {
37361
37384
  if (id === "_sets") continue;
37362
37385
  try {
37363
- const meta3 = await readJsonFile2(path27__default.join(paths.queueDir, id, PATCH_META_FILENAME));
37386
+ const meta3 = await readJsonFile2(path28__default.join(paths.queueDir, id, PATCH_META_FILENAME));
37364
37387
  results.push({ id, meta: meta3 });
37365
37388
  } catch {
37366
37389
  continue;
@@ -37385,17 +37408,17 @@ async function resolveQueueSelection(id, paths) {
37385
37408
  }
37386
37409
  async function showQueue(id, paths) {
37387
37410
  const selection = await resolveQueueSelection(id, paths);
37388
- const queueDir = path27__default.join(paths.queueDir, selection.id);
37389
- const patch = await parsePatch(await readPatchFile(path27__default.join(queueDir, PATCH_FILENAME)));
37390
- const meta3 = await readJsonFile2(path27__default.join(queueDir, PATCH_META_FILENAME));
37411
+ const queueDir = path28__default.join(paths.queueDir, selection.id);
37412
+ const patch = await parsePatch(await readPatchFile(path28__default.join(queueDir, PATCH_FILENAME)));
37413
+ const meta3 = await readJsonFile2(path28__default.join(queueDir, PATCH_META_FILENAME));
37391
37414
  return { patch, meta: meta3 };
37392
37415
  }
37393
37416
  async function rewriteQueuedPatch(id, paths, patch, meta3, expectedPatchHash) {
37394
37417
  assertSafeQueueId(id);
37395
37418
  return withPatchEditLock(paths, id, async () => {
37396
- const queueDir = path27__default.join(paths.queueDir, id);
37419
+ const queueDir = path28__default.join(paths.queueDir, id);
37397
37420
  if (expectedPatchHash !== void 0) {
37398
- const currentMarkdown = await readPatchFile(path27__default.join(queueDir, PATCH_FILENAME));
37421
+ const currentMarkdown = await readPatchFile(path28__default.join(queueDir, PATCH_FILENAME));
37399
37422
  const currentHash = computeContentHash(currentMarkdown);
37400
37423
  if (currentHash !== expectedPatchHash) {
37401
37424
  throw new Error(`[fleet-wiki] wiki_patch_edit stale base_patch_hash: expected ${currentHash}, got ${expectedPatchHash}`);
@@ -37404,8 +37427,8 @@ async function rewriteQueuedPatch(id, paths, patch, meta3, expectedPatchHash) {
37404
37427
  const patchMarkdown = serializePatch(patch);
37405
37428
  const patchHash = computeContentHash(patchMarkdown);
37406
37429
  const nextMeta = { ...meta3, lastEditHash: patchHash };
37407
- await writePatchFile(path27__default.join(queueDir, PATCH_FILENAME), patchMarkdown, paths);
37408
- await writeJsonFile(path27__default.join(queueDir, PATCH_META_FILENAME), nextMeta, paths);
37430
+ await writePatchFile(path28__default.join(queueDir, PATCH_FILENAME), patchMarkdown, paths);
37431
+ await writeJsonFile(path28__default.join(queueDir, PATCH_META_FILENAME), nextMeta, paths);
37409
37432
  return patchHash;
37410
37433
  });
37411
37434
  }
@@ -37429,8 +37452,8 @@ async function approvePatch(id, paths) {
37429
37452
  rawSourceRef: meta3.rawSourceRef,
37430
37453
  warnings: meta3.warnings
37431
37454
  });
37432
- const queueDir = path27__default.join(paths.queueDir, id);
37433
- await writeJsonFile(path27__default.join(queueDir, PATCH_META_FILENAME), {
37455
+ const queueDir = path28__default.join(paths.queueDir, id);
37456
+ await writeJsonFile(path28__default.join(queueDir, PATCH_META_FILENAME), {
37434
37457
  ...meta3,
37435
37458
  conflictId
37436
37459
  }, paths);
@@ -37466,7 +37489,7 @@ async function approvePatchSet(patchSetId, paths) {
37466
37489
  const failed = [];
37467
37490
  const missing = [];
37468
37491
  for (const patchId of patchSet.patchIds) {
37469
- const queueDir = path27__default.join(paths.queueDir, patchId);
37492
+ const queueDir = path28__default.join(paths.queueDir, patchId);
37470
37493
  if (!await pathExists(queueDir)) {
37471
37494
  missing.push(patchId);
37472
37495
  continue;
@@ -37532,7 +37555,7 @@ ${patch.body}`;
37532
37555
  }
37533
37556
  async function normalizeWikiEntryPatch(entry, target, paths) {
37534
37557
  assertSafeEntryId(entry.id);
37535
- if (entry.id !== path27__default.basename(target, ".md")) {
37558
+ if (entry.id !== path28__default.basename(target, ".md")) {
37536
37559
  throw new Error("wiki patch body id must match target filename");
37537
37560
  }
37538
37561
  const inlineRawSourceRef = extractInlineRawSourceRef(entry.body);
@@ -37575,9 +37598,9 @@ function buildPatchId(createdAt, summary, target, body) {
37575
37598
  }
37576
37599
  async function validatePatchBase(patch, meta3, paths) {
37577
37600
  if (patch.frontmatter.op !== "update_wiki" || !meta3?.baseVersion && !meta3?.baseHash) return;
37578
- const wikiId = path27__default.basename(patch.frontmatter.target, ".md");
37601
+ const wikiId = path28__default.basename(patch.frontmatter.target, ".md");
37579
37602
  const currentEntry = await readWikiEntry(wikiId, paths);
37580
- const currentPath = path27__default.join(paths.root, patch.frontmatter.target);
37603
+ const currentPath = path28__default.join(paths.root, patch.frontmatter.target);
37581
37604
  const currentMarkdown = await pathExists(currentPath) ? await readPatchFile(currentPath) : void 0;
37582
37605
  if (meta3.baseVersion !== void 0 && currentEntry?.version !== meta3.baseVersion) {
37583
37606
  throw new Error(
@@ -37636,17 +37659,17 @@ function assertCanonicalPatchTarget(target) {
37636
37659
  if (target.endsWith("/")) {
37637
37660
  throw new Error("patch target must not end with a slash");
37638
37661
  }
37639
- if (target.startsWith("/") || path27__default.posix.isAbsolute(target) || path27__default.win32.isAbsolute(target)) {
37662
+ if (target.startsWith("/") || path28__default.posix.isAbsolute(target) || path28__default.win32.isAbsolute(target)) {
37640
37663
  throw new Error("patch target must be relative");
37641
37664
  }
37642
- if (path27__default.posix.normalize(target) !== target) {
37665
+ if (path28__default.posix.normalize(target) !== target) {
37643
37666
  throw new Error("patch target must not contain dot segments or redundant separators");
37644
37667
  }
37645
37668
  }
37646
37669
  function canonicalApprovalLockKey(paths, target) {
37647
37670
  const wikiRoot = realpathSync(paths.wikiDir);
37648
- const relativeTarget = path27__default.posix.relative("wiki", target);
37649
- const targetPath = path27__default.join(wikiRoot, ...relativeTarget.split("/"));
37671
+ const relativeTarget = path28__default.posix.relative("wiki", target);
37672
+ const targetPath = path28__default.join(wikiRoot, ...relativeTarget.split("/"));
37650
37673
  return `${wikiRoot}\0${targetPath}`.toLowerCase();
37651
37674
  }
37652
37675
  function canonicalPatchEditLockKey(paths, patchId) {
@@ -37662,7 +37685,7 @@ function assertNoSymlinkPathComponents(target, paths) {
37662
37685
  throw error51;
37663
37686
  }
37664
37687
  for (const part of parts) {
37665
- current = path27__default.join(current, part);
37688
+ current = path28__default.join(current, part);
37666
37689
  try {
37667
37690
  if (lstatSync(current).isSymbolicLink()) {
37668
37691
  throw new Error("patch target must not include symlink path components");
@@ -37677,8 +37700,8 @@ function assertSafeRawSourceRef(rawSourceRef, paths) {
37677
37700
  if (!rawSourceRef.startsWith("raw/")) {
37678
37701
  throw new Error("raw source provenance must point into raw/");
37679
37702
  }
37680
- const absoluteRef = path27__default.resolve(paths.root, rawSourceRef);
37681
- if (!absoluteRef.startsWith(`${paths.rawDir}${path27__default.sep}`)) {
37703
+ const absoluteRef = path28__default.resolve(paths.root, rawSourceRef);
37704
+ if (!absoluteRef.startsWith(`${paths.rawDir}${path28__default.sep}`)) {
37682
37705
  throw new Error("raw source provenance must point into raw/");
37683
37706
  }
37684
37707
  }
@@ -37694,14 +37717,14 @@ function classifyPatchConflict(error51) {
37694
37717
  }
37695
37718
  async function recordPatchConflict(patch, paths, reason, options) {
37696
37719
  const now = /* @__PURE__ */ new Date();
37697
- const targetPath = path27__default.join(paths.root, patch.frontmatter.target);
37720
+ const targetPath = path28__default.join(paths.root, patch.frontmatter.target);
37698
37721
  const current = await pathExists(targetPath) ? await readPatchFile(targetPath) : void 0;
37699
37722
  const currentEntry = current ? parseStoredWikiEntry(current) : void 0;
37700
37723
  const proposedEntry = parsePatchBodyEntry(patch.body);
37701
37724
  const record2 = await createConflict({
37702
37725
  reason,
37703
37726
  target: patch.frontmatter.target,
37704
- wikiId: proposedEntry?.id ?? path27__default.basename(patch.frontmatter.target, ".md"),
37727
+ wikiId: proposedEntry?.id ?? path28__default.basename(patch.frontmatter.target, ".md"),
37705
37728
  title: proposedEntry?.title,
37706
37729
  proposer: patch.frontmatter.proposer,
37707
37730
  rawSourceRef: options?.rawSourceRef,
@@ -37797,11 +37820,11 @@ function parseInlineArray(value) {
37797
37820
  return inner.split(",").map((item) => item.trim().replace(/^"(.*)"$/, "$1"));
37798
37821
  }
37799
37822
  async function archiveQueueEntry(id, paths, meta3) {
37800
- const fromDir = path27__default.join(paths.queueDir, id);
37801
- const toDir = path27__default.join(paths.archiveDir, id);
37823
+ const fromDir = path28__default.join(paths.queueDir, id);
37824
+ const toDir = path28__default.join(paths.archiveDir, id);
37802
37825
  await removePath(toDir);
37803
37826
  await movePath(fromDir, toDir);
37804
- await writeJsonFile(path27__default.join(toDir, PATCH_META_FILENAME), meta3, paths);
37827
+ await writeJsonFile(path28__default.join(toDir, PATCH_META_FILENAME), meta3, paths);
37805
37828
  }
37806
37829
  function buildQueueIdHelp(prefix, availableIds) {
37807
37830
  if (availableIds.length === 0) {
@@ -38013,7 +38036,7 @@ async function resolveCompileSource(input, paths, now) {
38013
38036
  }
38014
38037
  async function buildCompileProposals(input, paths, now, resolvedSource) {
38015
38038
  const sourceTarget = `wiki/sources/${resolvedSource.sourcePageId}.md`;
38016
- const sourceExists = await pathExists(path27__default.join(paths.root, sourceTarget));
38039
+ const sourceExists = await pathExists(path28__default.join(paths.root, sourceTarget));
38017
38040
  const existingEntries = await listWiki(paths);
38018
38041
  const sourcePageTitle = resolvedSource.sourceTitle?.trim() || `Source ${resolvedSource.sourcePageId}`;
38019
38042
  const existingSourceEntry = existingEntries.find((entry) => entry.id === resolvedSource.sourcePageId);
@@ -38035,7 +38058,7 @@ async function buildCompileProposals(input, paths, now, resolvedSource) {
38035
38058
  target: sourceTarget,
38036
38059
  summary: truncateSummary(`Compile source page ${sourcePageTitle}`),
38037
38060
  entry: sourceEntry,
38038
- baseHash: sourceExists ? computeContentHash(await readPatchFile(path27__default.join(paths.root, sourceTarget))) : void 0,
38061
+ baseHash: sourceExists ? computeContentHash(await readPatchFile(path28__default.join(paths.root, sourceTarget))) : void 0,
38039
38062
  baseVersion: existingSourceEntry?.version
38040
38063
  }];
38041
38064
  const relatedCandidates = await discoverRelatedEntryCandidates(paths, resolvedSource.sourceContent, resolvedSource.sourceTitle);
@@ -38055,7 +38078,7 @@ async function buildCompileProposals(input, paths, now, resolvedSource) {
38055
38078
  rawSourceRefs: mergeRawSourceRefs(existing.rawSourceRefs, existing.rawSourceRef, { ref: resolvedSource.rawSourceRef }),
38056
38079
  body: appendSourceCompileNote(existing.body, resolvedSource.sourcePageId, resolvedSource.rawSourceRef)
38057
38080
  },
38058
- baseHash: computeContentHash(await readPatchFile(path27__default.join(paths.wikiDir, `${existing.id}.md`))),
38081
+ baseHash: computeContentHash(await readPatchFile(path28__default.join(paths.wikiDir, `${existing.id}.md`))),
38059
38082
  baseVersion: existing.version
38060
38083
  });
38061
38084
  }
@@ -38190,13 +38213,13 @@ async function readClaims(entryId, paths) {
38190
38213
  }
38191
38214
  }
38192
38215
  function getClaimsDir(paths) {
38193
- return path27__default.join(paths.wikiDir, CLAIMS_DIRNAME);
38216
+ return path28__default.join(paths.wikiDir, CLAIMS_DIRNAME);
38194
38217
  }
38195
38218
  function getClaimsFile(paths, entryId) {
38196
38219
  assertSafeEntryId(entryId);
38197
- const claimsFile = path27__default.join(getClaimsDir(paths), `${entryId}.json`);
38198
- const relative = path27__default.relative(getClaimsDir(paths), claimsFile);
38199
- if (!relative || relative.startsWith("..") || path27__default.isAbsolute(relative)) {
38220
+ const claimsFile = path28__default.join(getClaimsDir(paths), `${entryId}.json`);
38221
+ const relative = path28__default.relative(getClaimsDir(paths), claimsFile);
38222
+ if (!relative || relative.startsWith("..") || path28__default.isAbsolute(relative)) {
38200
38223
  throw new Error(`[fleet-wiki] claims sidecar escapes wiki/.claims: ${entryId}`);
38201
38224
  }
38202
38225
  return claimsFile;
@@ -38287,7 +38310,7 @@ function assertSafeClaimRawRef(ref) {
38287
38310
  if (!ref.startsWith("raw/")) {
38288
38311
  throw new Error(`claim sourceRef must point into raw/: ${ref}`);
38289
38312
  }
38290
- if (ref.includes("..") || path27__default.isAbsolute(ref)) {
38313
+ if (ref.includes("..") || path28__default.isAbsolute(ref)) {
38291
38314
  throw new Error(`claim sourceRef escapes raw/: ${ref}`);
38292
38315
  }
38293
38316
  }
@@ -38365,22 +38388,22 @@ async function runDryDock(paths, options = {}) {
38365
38388
  }
38366
38389
  for (const fileName of await listFileNames(paths.rawDir)) {
38367
38390
  if (!fileName.endsWith(".md")) continue;
38368
- const filePath = path27__default.join(paths.rawDir, fileName);
38391
+ const filePath = path28__default.join(paths.rawDir, fileName);
38369
38392
  issues.push(...safetyIssues(await readPatchFile(filePath), filePath));
38370
38393
  }
38371
38394
  for (const queueId of await listDirectoryNames(paths.queueDir)) {
38372
38395
  if (queueId === PATCH_SET_DIRNAME) continue;
38373
- const queueDir = path27__default.join(paths.queueDir, queueId);
38396
+ const queueDir = path28__default.join(paths.queueDir, queueId);
38374
38397
  try {
38375
- const patchContent = await readPatchFile(path27__default.join(queueDir, PATCH_FILENAME));
38376
- issues.push(...safetyIssues(patchContent, path27__default.join(queueDir, PATCH_FILENAME)));
38377
- await readJsonFile2(path27__default.join(queueDir, PATCH_META_FILENAME));
38398
+ const patchContent = await readPatchFile(path28__default.join(queueDir, PATCH_FILENAME));
38399
+ issues.push(...safetyIssues(patchContent, path28__default.join(queueDir, PATCH_FILENAME)));
38400
+ await readJsonFile2(path28__default.join(queueDir, PATCH_META_FILENAME));
38378
38401
  } catch {
38379
38402
  issues.push(issue2("malformed_queue", "error", "\uC190\uC0C1\uB41C queue \uC5D4\uD2B8\uB9AC", queueDir));
38380
38403
  }
38381
38404
  }
38382
- for (const patchSetId of await listDirectoryNames(path27__default.join(paths.queueDir, PATCH_SET_DIRNAME))) {
38383
- const patchSetMetaFile = path27__default.join(paths.queueDir, PATCH_SET_DIRNAME, patchSetId, PATCH_META_FILENAME);
38405
+ for (const patchSetId of await listDirectoryNames(path28__default.join(paths.queueDir, PATCH_SET_DIRNAME))) {
38406
+ const patchSetMetaFile = path28__default.join(paths.queueDir, PATCH_SET_DIRNAME, patchSetId, PATCH_META_FILENAME);
38384
38407
  let patchSet;
38385
38408
  try {
38386
38409
  patchSet = await readPatchSet(paths, patchSetId);
@@ -38389,8 +38412,8 @@ async function runDryDock(paths, options = {}) {
38389
38412
  continue;
38390
38413
  }
38391
38414
  for (const patchId of patchSet.patchIds) {
38392
- const queueMetaFile = path27__default.join(paths.queueDir, patchId, PATCH_META_FILENAME);
38393
- const archiveMetaFile = path27__default.join(paths.archiveDir, patchId, PATCH_META_FILENAME);
38415
+ const queueMetaFile = path28__default.join(paths.queueDir, patchId, PATCH_META_FILENAME);
38416
+ const archiveMetaFile = path28__default.join(paths.archiveDir, patchId, PATCH_META_FILENAME);
38394
38417
  if (!await pathExists(queueMetaFile) && !await pathExists(archiveMetaFile)) {
38395
38418
  issues.push(
38396
38419
  issue2(
@@ -38427,7 +38450,7 @@ async function runDryDock(paths, options = {}) {
38427
38450
  "conflict_unresolved",
38428
38451
  "warning",
38429
38452
  `\uBBF8\uD574\uACB0 conflict: ${conflict.reason} (${conflict.target})`,
38430
- path27__default.join(paths.conflictsDir, conflict.id, "meta.json")
38453
+ path28__default.join(paths.conflictsDir, conflict.id, "meta.json")
38431
38454
  )
38432
38455
  );
38433
38456
  }
@@ -38440,7 +38463,7 @@ async function runDryDock(paths, options = {}) {
38440
38463
  "unresolved_conflict",
38441
38464
  "warning",
38442
38465
  "\uC190\uC0C1\uB41C conflict \uC5D4\uD2B8\uB9AC",
38443
- path27__default.join(paths.conflictsDir, conflictId, "meta.json")
38466
+ path28__default.join(paths.conflictsDir, conflictId, "meta.json")
38444
38467
  )
38445
38468
  );
38446
38469
  }
@@ -38497,8 +38520,8 @@ async function claimIssues(paths, wikiIds) {
38497
38520
  const claimsDir = getClaimsDir(paths);
38498
38521
  for (const fileName of await listFileNames(claimsDir)) {
38499
38522
  if (!fileName.endsWith(".json")) continue;
38500
- const filePath = path27__default.join(claimsDir, fileName);
38501
- const entryIdFromFile = path27__default.basename(fileName, ".json");
38523
+ const filePath = path28__default.join(claimsDir, fileName);
38524
+ const entryIdFromFile = path28__default.basename(fileName, ".json");
38502
38525
  let raw;
38503
38526
  try {
38504
38527
  raw = await readJsonFile2(filePath);
@@ -38577,7 +38600,7 @@ function toSemanticEntry(filePath, frontmatter, body) {
38577
38600
  async function schemaIssues(paths) {
38578
38601
  const issues = [];
38579
38602
  const schema = await readWorkspaceSchemaSummary(paths);
38580
- const agentsPath = path27__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME);
38603
+ const agentsPath = path28__default.join(paths.schemaDir, WORKSPACE_SCHEMA_AGENTS_FILENAME);
38581
38604
  if (!await pathExists(schema.wikiSchemaPath)) {
38582
38605
  issues.push(issue2("schema_missing", "warning", `Workspace schema file is missing: schema/${WORKSPACE_SCHEMA_FILENAME}`, schema.wikiSchemaPath));
38583
38606
  } else {
@@ -38964,7 +38987,7 @@ async function listWikiMarkdownFiles(dirPath) {
38964
38987
  const files = [];
38965
38988
  const sortedEntries = entries.sort((left, right) => left.name.localeCompare(right.name));
38966
38989
  for (const entry of sortedEntries) {
38967
- const filePath = path27__default.join(dirPath, entry.name);
38990
+ const filePath = path28__default.join(dirPath, entry.name);
38968
38991
  if (entry.isDirectory()) {
38969
38992
  files.push(...await listWikiMarkdownFiles(filePath));
38970
38993
  continue;
@@ -39048,7 +39071,7 @@ async function planIngest(input, paths, now) {
39048
39071
  const target = `wiki/${input.id}.md`;
39049
39072
  const proposer = input.proposer ?? "tool:wiki_ingest";
39050
39073
  const currentEntry = await readWikiEntry(input.id, paths);
39051
- const currentMarkdown = currentEntry ? await readPatchFile(path27__default.join(paths.wikiDir, `${input.id}.md`)) : void 0;
39074
+ const currentMarkdown = currentEntry ? await readPatchFile(path28__default.join(paths.wikiDir, `${input.id}.md`)) : void 0;
39052
39075
  const currentHash = currentMarkdown ? computeContentHash(currentMarkdown) : void 0;
39053
39076
  const rawSource = buildRawSourceEntry(input, now);
39054
39077
  await ensureWorkspaceSchema(paths);
@@ -39727,11 +39750,11 @@ async function editQueuedPatch(input, paths) {
39727
39750
  };
39728
39751
  }
39729
39752
  async function readQueuedPatchSnapshot(paths, patchId) {
39730
- const queueDir = path27__default.join(paths.queueDir, patchId);
39731
- const markdown = await readPatchFile(path27__default.join(queueDir, PATCH_FILENAME));
39753
+ const queueDir = path28__default.join(paths.queueDir, patchId);
39754
+ const markdown = await readPatchFile(path28__default.join(queueDir, PATCH_FILENAME));
39732
39755
  return {
39733
39756
  patch: await parsePatch(markdown),
39734
- meta: await readJsonFile2(path27__default.join(queueDir, PATCH_META_FILENAME)),
39757
+ meta: await readJsonFile2(path28__default.join(queueDir, PATCH_META_FILENAME)),
39735
39758
  patchHash: computeContentHash(markdown)
39736
39759
  };
39737
39760
  }
@@ -40493,7 +40516,7 @@ ${input.answer ?? ""}`)}`;
40493
40516
  assertSafeEntryId(targetId);
40494
40517
  const subdir = input.targetType === "synthesis" ? "synthesis" : "queries";
40495
40518
  const target = `wiki/${subdir}/${targetId}.md`;
40496
- const absoluteTarget = path27__default.join(paths.root, target);
40519
+ const absoluteTarget = path28__default.join(paths.root, target);
40497
40520
  const exists = await pathExists(absoluteTarget);
40498
40521
  const existingEntry = exists ? await readWikiEntry(targetId, paths) : null;
40499
40522
  if (exists && !existingEntry) {
@@ -40575,7 +40598,7 @@ function assertSafeRawRef(rawRef) {
40575
40598
  if (!rawRef.startsWith("raw/")) {
40576
40599
  throw new Error(`[fleet-wiki] wiki_query raw source ref must point into raw/: ${rawRef}`);
40577
40600
  }
40578
- if (rawRef.includes("..") || path27__default.isAbsolute(rawRef)) {
40601
+ if (rawRef.includes("..") || path28__default.isAbsolute(rawRef)) {
40579
40602
  throw new Error(`[fleet-wiki] wiki_query raw source ref escapes raw/: ${rawRef}`);
40580
40603
  }
40581
40604
  }
@@ -40694,7 +40717,7 @@ async function buildReadEntryResult(entry, paths, graph, input) {
40694
40717
  rawSourceRef: entry.rawSourceRef,
40695
40718
  rawSourceRefs,
40696
40719
  source: {
40697
- path: path27__default.join("wiki", `${entry.id}.md`),
40720
+ path: path28__default.join("wiki", `${entry.id}.md`),
40698
40721
  rawSourceRef: entry.rawSourceRef,
40699
40722
  rawSourceRefs
40700
40723
  },
@@ -40820,7 +40843,7 @@ function buildRelatedEntries(entry, graph) {
40820
40843
  deduped.set(candidate.id, {
40821
40844
  id: relatedEntry.id,
40822
40845
  title: relatedEntry.title,
40823
- path: path27__default.join("wiki", `${relatedEntry.id}.md`),
40846
+ path: path28__default.join("wiki", `${relatedEntry.id}.md`),
40824
40847
  reason: candidate.reason
40825
40848
  });
40826
40849
  }
@@ -41162,15 +41185,15 @@ function loadNodePtyRequire(currentFile) {
41162
41185
  return consolePackageRequire ?? require2;
41163
41186
  }
41164
41187
  function findConsolePackageRequire(currentFile) {
41165
- let dir = path27__default.dirname(currentFile);
41188
+ let dir = path28__default.dirname(currentFile);
41166
41189
  while (true) {
41167
- const packageJson = path27__default.join(dir, "package.json");
41190
+ const packageJson = path28__default.join(dir, "package.json");
41168
41191
  if (isFleetConsolePackage(packageJson)) return createRequire(packageJson);
41169
- const nestedConsolePackage = path27__default.join(dir, "runtime", "fleet-console", "package.json");
41192
+ const nestedConsolePackage = path28__default.join(dir, "runtime", "fleet-console", "package.json");
41170
41193
  if (isFleetConsolePackage(nestedConsolePackage)) return createRequire(nestedConsolePackage);
41171
- const siblingConsolePackage = path27__default.join(dir, "..", "..", "fleet-console", "package.json");
41194
+ const siblingConsolePackage = path28__default.join(dir, "..", "..", "fleet-console", "package.json");
41172
41195
  if (isFleetConsolePackage(siblingConsolePackage)) return createRequire(siblingConsolePackage);
41173
- const parent = path27__default.dirname(dir);
41196
+ const parent = path28__default.dirname(dir);
41174
41197
  if (parent === dir) return null;
41175
41198
  dir = parent;
41176
41199
  }
@@ -41955,7 +41978,7 @@ function captureSession(options) {
41955
41978
  function readProviderSessionCapture(fleetSessionId, deps = {}) {
41956
41979
  if (!isSafeCaptureId(fleetSessionId)) return null;
41957
41980
  const capturesDir = deps.capturesDir ?? defaultCapturePaths().capturesDir;
41958
- const filePath = path27__default.join(capturesDir, `${fleetSessionId}.json`);
41981
+ const filePath = path28__default.join(capturesDir, `${fleetSessionId}.json`);
41959
41982
  try {
41960
41983
  const parsed = JSON.parse(fs2__default.readFileSync(filePath, "utf8"));
41961
41984
  return sanitizeProviderSession(parsed);
@@ -41967,7 +41990,7 @@ function unlinkProviderSessionCapture(fleetSessionId, deps = {}) {
41967
41990
  if (!isSafeCaptureId(fleetSessionId)) return false;
41968
41991
  const capturesDir = deps.capturesDir ?? defaultCapturePaths().capturesDir;
41969
41992
  try {
41970
- fs2__default.unlinkSync(path27__default.join(capturesDir, `${fleetSessionId}.json`));
41993
+ fs2__default.unlinkSync(path28__default.join(capturesDir, `${fleetSessionId}.json`));
41971
41994
  return true;
41972
41995
  } catch {
41973
41996
  return false;
@@ -41979,8 +42002,8 @@ function captureSessionStrict(options) {
41979
42002
  const input = parseHookInput(options.input ?? "");
41980
42003
  const providerSession = toProviderSession(provider, input, options.now ?? (() => /* @__PURE__ */ new Date()));
41981
42004
  const capturesDir = (options.paths ?? defaultCapturePaths()).capturesDir;
41982
- const finalPath = path27__default.join(capturesDir, `${fleetSessionId}.json`);
41983
- const tempPath = path27__default.join(capturesDir, `${CAPTURE_TEMP_PREFIX}${fleetSessionId}.${process5.pid}.${Date.now()}.tmp`);
42005
+ const finalPath = path28__default.join(capturesDir, `${fleetSessionId}.json`);
42006
+ const tempPath = path28__default.join(capturesDir, `${CAPTURE_TEMP_PREFIX}${fleetSessionId}.${process5.pid}.${Date.now()}.tmp`);
41984
42007
  fs2__default.mkdirSync(capturesDir, { recursive: true, mode: 448 });
41985
42008
  fs2__default.writeFileSync(tempPath, `${JSON.stringify(providerSession, null, 2)}
41986
42009
  `, { mode: 384 });
@@ -41994,7 +42017,7 @@ function parseProvider(value) {
41994
42017
  function readFleetSessionId(env) {
41995
42018
  const value = env.FLEET_CONSOLE_SESSION_ID;
41996
42019
  if (!value) throw new Error("missing_fleet_session_id");
41997
- if (path27__default.basename(value) !== value || value.includes(path27__default.sep) || value.includes(path27__default.posix.sep)) {
42020
+ if (path28__default.basename(value) !== value || value.includes(path28__default.sep) || value.includes(path28__default.posix.sep)) {
41998
42021
  throw new Error("invalid_fleet_session_id");
41999
42022
  }
42000
42023
  return value;
@@ -42039,10 +42062,10 @@ function isProvider(value) {
42039
42062
  return value === "claude" || value === "codex" || value === "cursor";
42040
42063
  }
42041
42064
  function isSafeCaptureId(value) {
42042
- return value.length > 0 && path27__default.basename(value) === value && !value.includes(path27__default.sep) && !value.includes(path27__default.posix.sep);
42065
+ return value.length > 0 && path28__default.basename(value) === value && !value.includes(path28__default.sep) && !value.includes(path28__default.posix.sep);
42043
42066
  }
42044
42067
  function defaultCapturePaths() {
42045
- return { capturesDir: path27__default.join(getFleetDataDir(), CONSOLE_DATA_DIR_NAME, CONSOLE_CAPTURES_DIR_NAME) };
42068
+ return { capturesDir: path28__default.join(getFleetDataDir(), CONSOLE_DATA_DIR_NAME, CONSOLE_CAPTURES_DIR_NAME) };
42046
42069
  }
42047
42070
  var JAVASCRIPT_ENTRY_EXTENSIONS = /* @__PURE__ */ new Set([".cjs", ".js", ".mjs"]);
42048
42071
  var TYPESCRIPT_ENTRY_EXTENSIONS = /* @__PURE__ */ new Set([".cts", ".mts", ".ts", ".tsx"]);
@@ -42057,7 +42080,7 @@ function buildConsoleAutoNameHookCommand(entry) {
42057
42080
  return buildConsoleCliHookExec(entry, ["hook", "auto-name"]);
42058
42081
  }
42059
42082
  function buildConsoleCaptureHookCommand(entry, cliId) {
42060
- const extension = path27__default.extname(entry.entryPath);
42083
+ const extension = path28__default.extname(entry.entryPath);
42061
42084
  if (JAVASCRIPT_ENTRY_EXTENSIONS.has(extension)) {
42062
42085
  return createSessionCaptureHookExec({
42063
42086
  entryPath: entry.entryPath,
@@ -42093,11 +42116,11 @@ function runCodexCommand(command) {
42093
42116
  }
42094
42117
  function withConsoleMarketplaceLock(target, fn) {
42095
42118
  const lockDir = `${target}${MARKETPLACE_LOCK_DIR_SUFFIX}`;
42096
- mkdirSync(path27__default.dirname(lockDir), { recursive: true });
42119
+ mkdirSync(path28__default.dirname(lockDir), { recursive: true });
42097
42120
  return withDirectoryLock({ lockDir }, fn);
42098
42121
  }
42099
42122
  function buildConsoleCliHookExec(entry, trailingArgs) {
42100
- const extension = path27__default.extname(entry.entryPath);
42123
+ const extension = path28__default.extname(entry.entryPath);
42101
42124
  if (JAVASCRIPT_ENTRY_EXTENSIONS.has(extension)) {
42102
42125
  return {
42103
42126
  command: entry.execPath,
@@ -42181,7 +42204,7 @@ function resolveHookEntryPath(candidate) {
42181
42204
  return CONSOLE_ENTRY_PATH;
42182
42205
  }
42183
42206
  function hasHookEntryExtension(entryPath) {
42184
- return HOOK_ENTRY_EXTENSIONS.has(path27__default.extname(entryPath));
42207
+ return HOOK_ENTRY_EXTENSIONS.has(path28__default.extname(entryPath));
42185
42208
  }
42186
42209
  async function createAgentCliLaunchSpec(options) {
42187
42210
  const cleanupStack = [];
@@ -42403,7 +42426,7 @@ function createConsoleObservabilityStore(deps = {}) {
42403
42426
  return terminalSessionsById.get(sessionId)?.cwd ?? workspacesByCliRunId.get(sessionId)?.session.cwd ?? null;
42404
42427
  }
42405
42428
  function createPendingTerminalSession(input) {
42406
- if (!path27__default.isAbsolute(input.cwd)) throw new Error("Terminal session cwd must be absolute");
42429
+ if (!path28__default.isAbsolute(input.cwd)) throw new Error("Terminal session cwd must be absolute");
42407
42430
  const createdAt = input.createdAt ?? now();
42408
42431
  const canonicalCwd = canonicalizeTheaterPath(input.cwd);
42409
42432
  const theaterId = workspaceHash(canonicalCwd);
@@ -42411,7 +42434,7 @@ function createConsoleObservabilityStore(deps = {}) {
42411
42434
  sessionId: input.sessionId,
42412
42435
  cwd: input.cwd,
42413
42436
  canonicalCwd,
42414
- cwdLabel: path27__default.basename(input.cwd) || input.cwd,
42437
+ cwdLabel: path28__default.basename(input.cwd) || input.cwd,
42415
42438
  cliId: input.cliId,
42416
42439
  createdAt,
42417
42440
  theaterId,
@@ -42426,7 +42449,7 @@ function createConsoleObservabilityStore(deps = {}) {
42426
42449
  sessionId: operation.sessionId,
42427
42450
  cwd: operation.cwd,
42428
42451
  canonicalCwd: canonicalizeTheaterPath(operation.cwd),
42429
- cwdLabel: path27__default.basename(operation.cwd) || operation.cwd,
42452
+ cwdLabel: path28__default.basename(operation.cwd) || operation.cwd,
42430
42453
  label: operation.label,
42431
42454
  labelSource: operation.labelSource,
42432
42455
  cliId: operation.cliId,
@@ -42653,7 +42676,7 @@ function defaultWorkspaceHash(canonicalCwd) {
42653
42676
  return crypto4.createHash("sha256").update(canonicalCwd).digest("hex").slice(0, 12);
42654
42677
  }
42655
42678
  function defaultCanonicalizeTheaterPath(cwd) {
42656
- const resolved = path27__default.resolve(cwd);
42679
+ const resolved = path28__default.resolve(cwd);
42657
42680
  try {
42658
42681
  return fs2__default.realpathSync.native(resolved);
42659
42682
  } catch {
@@ -42947,23 +42970,23 @@ function createAgentApi(ctx, terminalRuntime, deps) {
42947
42970
  backfillAgentOperationLaunchKinds();
42948
42971
  rehydrateDormantAgentOperations();
42949
42972
  async function handle({ req, res, pathname }) {
42950
- const path42 = pathname.slice(`${ctx.basePath}/agent`.length) || "/";
42951
- if (path42 === "/state") {
42973
+ const path43 = pathname.slice(`${ctx.basePath}/agent`.length) || "/";
42974
+ if (path43 === "/state") {
42952
42975
  if (req.method !== "GET") return methodNotAllowed(res);
42953
42976
  ctx.host.http.writeJson(res, 200, { agentClis: await buildAgentCliLaunchMetadata() });
42954
42977
  return true;
42955
42978
  }
42956
- if (path42 === "/agent-cli/state") {
42979
+ if (path43 === "/agent-cli/state") {
42957
42980
  if (req.method !== "GET") return methodNotAllowed(res);
42958
42981
  ctx.host.http.writeJson(res, 200, { clis: await detector.detect() });
42959
42982
  return true;
42960
42983
  }
42961
- if (path42 === "/tenants") {
42984
+ if (path43 === "/tenants") {
42962
42985
  if (req.method !== "GET") return methodNotAllowed(res);
42963
42986
  ctx.host.http.writeJson(res, 200, { tenants: observability.listWorkspaces() });
42964
42987
  return true;
42965
42988
  }
42966
- if (path42 === "/jobs") {
42989
+ if (path43 === "/jobs") {
42967
42990
  if (req.method !== "GET") return methodNotAllowed(res);
42968
42991
  const requestedTenantId = new URL(req.url ?? "/", "http://127.0.0.1").searchParams.get("tenant");
42969
42992
  const visible = requestedTenantId ? observability.listWorkspaces().filter((workspace) => workspace.tenantId === requestedTenantId) : observability.listWorkspaces();
@@ -42974,7 +42997,7 @@ function createAgentApi(ctx, terminalRuntime, deps) {
42974
42997
  ctx.host.http.writeJson(res, 200, { tenants: visible.map((workspace) => ({ tenantId: workspace.tenantId, tenantLabel: workspace.tenantLabel, jobs: observability.listJobs(workspace.tenantId), truncation: observability.getTruncation(workspace.tenantId) })) });
42975
42998
  return true;
42976
42999
  }
42977
- if (path42 === "/events") {
43000
+ if (path43 === "/events") {
42978
43001
  if (req.method !== "GET") return methodNotAllowed(res);
42979
43002
  const requestedTenantId = new URL(req.url ?? "/", "http://127.0.0.1").searchParams.get("tenant");
42980
43003
  const visible = requestedTenantId ? observability.listWorkspaces().filter((workspace) => workspace.tenantId === requestedTenantId) : observability.listWorkspaces();
@@ -42985,11 +43008,11 @@ function createAgentApi(ctx, terminalRuntime, deps) {
42985
43008
  writeAggregateObserverEvents(req, res, visible, observability, (tenantId) => observability.getWorkspace(tenantId), { subscribeAll: true });
42986
43009
  return true;
42987
43010
  }
42988
- if (path42 === "/sessions") return handleSessions(req, res);
42989
- if (path42 === "/capture") return handleCapture(req, res, "");
42990
- const sessionMatch = path42.match(/^\/sessions\/([^/]+)(?:\/([^/]+))?$/);
43011
+ if (path43 === "/sessions") return handleSessions(req, res);
43012
+ if (path43 === "/capture") return handleCapture(req, res, "");
43013
+ const sessionMatch = path43.match(/^\/sessions\/([^/]+)(?:\/([^/]+))?$/);
42991
43014
  if (sessionMatch) return handleSessionItem(req, res, decodeURIComponent(sessionMatch[1] ?? ""), sessionMatch[2] ?? "");
42992
- if (path42 === "/ticket") {
43015
+ if (path43 === "/ticket") {
42993
43016
  if (req.method !== "POST") return methodNotAllowed(res);
42994
43017
  if (!ctx.host.security.isTerminalAuthorized(req)) {
42995
43018
  ctx.host.http.writeJson(res, 401, { error: "Unauthorized" });
@@ -43083,7 +43106,7 @@ function createAgentApi(ctx, terminalRuntime, deps) {
43083
43106
  theaterId,
43084
43107
  type: AGENT_OPERATION_TYPE,
43085
43108
  pluginId: ctx.pluginId,
43086
- title: session.label ?? path27__default.basename(cwd),
43109
+ title: session.label ?? path28__default.basename(cwd),
43087
43110
  payload: toOperationPayload(cwd, session),
43088
43111
  createdAt: session.createdAt
43089
43112
  });
@@ -43194,7 +43217,7 @@ function createAgentApi(ctx, terminalRuntime, deps) {
43194
43217
  if (result?.renamed) {
43195
43218
  observability.notifySessionUpdated(result.session);
43196
43219
  const autoNameCwd = readPayloadString(ctx.host.operations.get(sessionId)?.payload ?? {}, "cwd") ?? result.session.cwdLabel;
43197
- ctx.host.operations.patch(sessionId, { title: result.session.label ?? path27__default.basename(autoNameCwd) });
43220
+ ctx.host.operations.patch(sessionId, { title: result.session.label ?? path28__default.basename(autoNameCwd) });
43198
43221
  }
43199
43222
  ctx.host.http.writeJson(res, 200, { ok: true, renamed: result?.renamed === true });
43200
43223
  return true;