prjct-cli 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -932,6 +932,60 @@ var init_author_detector = __esm({
932
932
  }
933
933
  });
934
934
 
935
+ // core/storage/safe-reader.ts
936
+ import fs4 from "node:fs/promises";
937
+ async function safeRead(filePath, schema) {
938
+ let content;
939
+ try {
940
+ content = await fs4.readFile(filePath, "utf-8");
941
+ } catch (error) {
942
+ if (isNotFoundError(error)) {
943
+ return null;
944
+ }
945
+ throw error;
946
+ }
947
+ let raw;
948
+ try {
949
+ raw = JSON.parse(content);
950
+ } catch {
951
+ await createBackup(filePath, content);
952
+ logCorruption(filePath, "Malformed JSON");
953
+ return null;
954
+ }
955
+ const result = schema.safeParse(raw);
956
+ if (result.success) {
957
+ return raw;
958
+ }
959
+ await createBackup(filePath, content);
960
+ logCorruption(filePath, formatZodError(result.error));
961
+ return null;
962
+ }
963
+ async function createBackup(filePath, content) {
964
+ const backupPath = `${filePath}.backup`;
965
+ try {
966
+ await fs4.writeFile(backupPath, content, "utf-8");
967
+ } catch {
968
+ }
969
+ }
970
+ function logCorruption(filePath, reason2) {
971
+ console.error(`[prjct] Warning: Corrupted storage file: ${filePath}`);
972
+ console.error(`[prjct] Reason: ${reason2}`);
973
+ console.error(`[prjct] A .backup file has been created. Returning defaults.`);
974
+ }
975
+ function formatZodError(error) {
976
+ return error.issues.slice(0, 3).map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ");
977
+ }
978
+ var init_safe_reader = __esm({
979
+ "core/storage/safe-reader.ts"() {
980
+ "use strict";
981
+ init_fs();
982
+ __name(safeRead, "safeRead");
983
+ __name(createBackup, "createBackup");
984
+ __name(logCorruption, "logCorruption");
985
+ __name(formatZodError, "formatZodError");
986
+ }
987
+ });
988
+
935
989
  // core/utils/file-helper.ts
936
990
  var file_helper_exports = {};
937
991
  __export(file_helper_exports, {
@@ -958,11 +1012,15 @@ __export(file_helper_exports, {
958
1012
  writeJson: () => writeJson,
959
1013
  writeLines: () => writeLines
960
1014
  });
961
- import fs4 from "node:fs/promises";
1015
+ import fs5 from "node:fs/promises";
962
1016
  import path4 from "node:path";
963
- async function readJson(filePath, defaultValue = null) {
1017
+ async function readJson(filePath, defaultValue = null, schema) {
1018
+ if (schema) {
1019
+ const data = await safeRead(filePath, schema);
1020
+ return data ?? defaultValue;
1021
+ }
964
1022
  try {
965
- const content = await fs4.readFile(filePath, "utf-8");
1023
+ const content = await fs5.readFile(filePath, "utf-8");
966
1024
  return JSON.parse(content);
967
1025
  } catch (error) {
968
1026
  if (isNotFoundError(error)) {
@@ -973,11 +1031,11 @@ async function readJson(filePath, defaultValue = null) {
973
1031
  }
974
1032
  async function writeJson(filePath, data, indent = 2) {
975
1033
  const content = JSON.stringify(data, null, indent);
976
- await fs4.writeFile(filePath, content, "utf-8");
1034
+ await fs5.writeFile(filePath, content, "utf-8");
977
1035
  }
978
1036
  async function readFile(filePath, defaultValue = "") {
979
1037
  try {
980
- return await fs4.readFile(filePath, "utf-8");
1038
+ return await fs5.readFile(filePath, "utf-8");
981
1039
  } catch (error) {
982
1040
  if (isNotFoundError(error)) {
983
1041
  return defaultValue;
@@ -987,32 +1045,32 @@ async function readFile(filePath, defaultValue = "") {
987
1045
  }
988
1046
  async function writeFile(filePath, content) {
989
1047
  const dir = path4.dirname(filePath);
990
- await fs4.mkdir(dir, { recursive: true });
991
- await fs4.writeFile(filePath, content, "utf-8");
1048
+ await fs5.mkdir(dir, { recursive: true });
1049
+ await fs5.writeFile(filePath, content, "utf-8");
992
1050
  }
993
1051
  async function atomicWrite(filePath, content) {
994
1052
  const dir = path4.dirname(filePath);
995
- await fs4.mkdir(dir, { recursive: true });
1053
+ await fs5.mkdir(dir, { recursive: true });
996
1054
  const tempPath = `${filePath}.${Date.now()}.tmp`;
997
- await fs4.writeFile(tempPath, content, "utf-8");
998
- await fs4.rename(tempPath, filePath);
1055
+ await fs5.writeFile(tempPath, content, "utf-8");
1056
+ await fs5.rename(tempPath, filePath);
999
1057
  }
1000
1058
  async function appendToFile(filePath, content) {
1001
- await fs4.appendFile(filePath, content, "utf-8");
1059
+ await fs5.appendFile(filePath, content, "utf-8");
1002
1060
  }
1003
1061
  async function appendLine(filePath, line) {
1004
1062
  const dir = path4.dirname(filePath);
1005
- await fs4.mkdir(dir, { recursive: true });
1006
- await fs4.appendFile(filePath, `${line}
1063
+ await fs5.mkdir(dir, { recursive: true });
1064
+ await fs5.appendFile(filePath, `${line}
1007
1065
  `, "utf-8");
1008
1066
  }
1009
1067
  async function prependToFile(filePath, content) {
1010
1068
  try {
1011
- const existing = await fs4.readFile(filePath, "utf-8");
1012
- await fs4.writeFile(filePath, content + existing, "utf-8");
1069
+ const existing = await fs5.readFile(filePath, "utf-8");
1070
+ await fs5.writeFile(filePath, content + existing, "utf-8");
1013
1071
  } catch (error) {
1014
1072
  if (isNotFoundError(error)) {
1015
- await fs4.writeFile(filePath, content, "utf-8");
1073
+ await fs5.writeFile(filePath, content, "utf-8");
1016
1074
  } else {
1017
1075
  throw error;
1018
1076
  }
@@ -1020,7 +1078,7 @@ async function prependToFile(filePath, content) {
1020
1078
  }
1021
1079
  async function fileExists2(filePath) {
1022
1080
  try {
1023
- await fs4.access(filePath);
1081
+ await fs5.access(filePath);
1024
1082
  return true;
1025
1083
  } catch (error) {
1026
1084
  if (isNotFoundError(error)) {
@@ -1031,7 +1089,7 @@ async function fileExists2(filePath) {
1031
1089
  }
1032
1090
  async function dirExists(dirPath) {
1033
1091
  try {
1034
- const stats = await fs4.stat(dirPath);
1092
+ const stats = await fs5.stat(dirPath);
1035
1093
  return stats.isDirectory();
1036
1094
  } catch (error) {
1037
1095
  if (isNotFoundError(error)) {
@@ -1041,11 +1099,11 @@ async function dirExists(dirPath) {
1041
1099
  }
1042
1100
  }
1043
1101
  async function ensureDir(dirPath) {
1044
- await fs4.mkdir(dirPath, { recursive: true });
1102
+ await fs5.mkdir(dirPath, { recursive: true });
1045
1103
  }
1046
1104
  async function deleteFile(filePath) {
1047
1105
  try {
1048
- await fs4.unlink(filePath);
1106
+ await fs5.unlink(filePath);
1049
1107
  return true;
1050
1108
  } catch (error) {
1051
1109
  if (isNotFoundError(error)) {
@@ -1056,7 +1114,7 @@ async function deleteFile(filePath) {
1056
1114
  }
1057
1115
  async function deleteDir(dirPath) {
1058
1116
  try {
1059
- await fs4.rm(dirPath, { recursive: true, force: true });
1117
+ await fs5.rm(dirPath, { recursive: true, force: true });
1060
1118
  return true;
1061
1119
  } catch (error) {
1062
1120
  if (isNotFoundError(error)) {
@@ -1067,7 +1125,7 @@ async function deleteDir(dirPath) {
1067
1125
  }
1068
1126
  async function listFiles(dirPath, options = {}) {
1069
1127
  try {
1070
- const entries = await fs4.readdir(dirPath, { withFileTypes: true });
1128
+ const entries = await fs5.readdir(dirPath, { withFileTypes: true });
1071
1129
  let files = entries;
1072
1130
  if (options.filesOnly) {
1073
1131
  files = files.filter((entry) => entry.isFile());
@@ -1087,18 +1145,18 @@ async function listFiles(dirPath, options = {}) {
1087
1145
  }
1088
1146
  }
1089
1147
  async function getFileSize(filePath) {
1090
- const stats = await fs4.stat(filePath);
1148
+ const stats = await fs5.stat(filePath);
1091
1149
  return stats.size;
1092
1150
  }
1093
1151
  async function getFileModifiedTime(filePath) {
1094
- const stats = await fs4.stat(filePath);
1152
+ const stats = await fs5.stat(filePath);
1095
1153
  return stats.mtime;
1096
1154
  }
1097
1155
  async function copyFile(sourcePath, destPath) {
1098
- await fs4.copyFile(sourcePath, destPath);
1156
+ await fs5.copyFile(sourcePath, destPath);
1099
1157
  }
1100
1158
  async function moveFile(oldPath, newPath) {
1101
- await fs4.rename(oldPath, newPath);
1159
+ await fs5.rename(oldPath, newPath);
1102
1160
  }
1103
1161
  async function readLines(filePath) {
1104
1162
  const content = await readFile(filePath, "");
@@ -1117,6 +1175,7 @@ function getFileNameWithoutExtension(filePath) {
1117
1175
  var init_file_helper = __esm({
1118
1176
  "core/utils/file-helper.ts"() {
1119
1177
  "use strict";
1178
+ init_safe_reader();
1120
1179
  init_fs();
1121
1180
  __name(readJson, "readJson");
1122
1181
  __name(writeJson, "writeJson");
@@ -1145,7 +1204,7 @@ var init_file_helper = __esm({
1145
1204
 
1146
1205
  // core/infrastructure/path-manager.ts
1147
1206
  import crypto2 from "node:crypto";
1148
- import fs5 from "node:fs/promises";
1207
+ import fs6 from "node:fs/promises";
1149
1208
  import os3 from "node:os";
1150
1209
  import path5 from "node:path";
1151
1210
  import { globSync } from "glob";
@@ -1285,17 +1344,17 @@ var init_path_manager = __esm({
1285
1344
  const sessionsDir = path5.join(this.getGlobalProjectPath(projectId), "sessions");
1286
1345
  const sessions = [];
1287
1346
  try {
1288
- const years = await fs5.readdir(sessionsDir, { withFileTypes: true });
1347
+ const years = await fs6.readdir(sessionsDir, { withFileTypes: true });
1289
1348
  for (const yearEntry of years) {
1290
1349
  if (!yearEntry.isDirectory()) continue;
1291
1350
  if (year && yearEntry.name !== year.toString()) continue;
1292
1351
  const yearPath = path5.join(sessionsDir, yearEntry.name);
1293
- const months = await fs5.readdir(yearPath, { withFileTypes: true });
1352
+ const months = await fs6.readdir(yearPath, { withFileTypes: true });
1294
1353
  for (const monthEntry of months) {
1295
1354
  if (!monthEntry.isDirectory()) continue;
1296
1355
  if (month && monthEntry.name !== month.toString().padStart(2, "0")) continue;
1297
1356
  const monthPath = path5.join(yearPath, monthEntry.name);
1298
- const days = await fs5.readdir(monthPath, { withFileTypes: true });
1357
+ const days = await fs6.readdir(monthPath, { withFileTypes: true });
1299
1358
  for (const dayEntry of days) {
1300
1359
  if (!dayEntry.isDirectory()) continue;
1301
1360
  sessions.push({
@@ -1333,7 +1392,7 @@ var init_path_manager = __esm({
1333
1392
  async listProjects() {
1334
1393
  try {
1335
1394
  await this.ensureGlobalStructure();
1336
- const entries = await fs5.readdir(this.globalProjectsDir, { withFileTypes: true });
1395
+ const entries = await fs6.readdir(this.globalProjectsDir, { withFileTypes: true });
1337
1396
  return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
1338
1397
  } catch (_error) {
1339
1398
  return [];
@@ -1473,7 +1532,7 @@ var init_path_manager = __esm({
1473
1532
  const packageJsonPath = path5.join(projectPath, "package.json");
1474
1533
  if (await fileExists2(packageJsonPath)) {
1475
1534
  try {
1476
- const content = await fs5.readFile(packageJsonPath, "utf-8");
1535
+ const content = await fs6.readFile(packageJsonPath, "utf-8");
1477
1536
  const pkg = JSON.parse(content);
1478
1537
  if (pkg.workspaces) {
1479
1538
  result.isMonorepo = true;
@@ -1496,14 +1555,14 @@ var init_path_manager = __esm({
1496
1555
  let patterns = [];
1497
1556
  try {
1498
1557
  if (type === "pnpm") {
1499
- const yaml = await fs5.readFile(path5.join(rootPath, "pnpm-workspace.yaml"), "utf-8");
1558
+ const yaml = await fs6.readFile(path5.join(rootPath, "pnpm-workspace.yaml"), "utf-8");
1500
1559
  const match = yaml.match(/packages:\s*\n((?:\s*-\s*.+\n?)+)/);
1501
1560
  if (match) {
1502
1561
  patterns = match[1].split("\n").map((line) => line.replace(/^\s*-\s*['"]?|['"]?\s*$/g, "")).filter(Boolean);
1503
1562
  }
1504
1563
  } else if (type === "npm" || type === "lerna") {
1505
1564
  const packageJsonPath = path5.join(rootPath, "package.json");
1506
- const content = await fs5.readFile(packageJsonPath, "utf-8");
1565
+ const content = await fs6.readFile(packageJsonPath, "utf-8");
1507
1566
  const pkg = JSON.parse(content);
1508
1567
  if (Array.isArray(pkg.workspaces)) {
1509
1568
  patterns = pkg.workspaces;
@@ -1513,7 +1572,7 @@ var init_path_manager = __esm({
1513
1572
  if (type === "lerna") {
1514
1573
  const lernaPath = path5.join(rootPath, "lerna.json");
1515
1574
  if (await fileExists2(lernaPath)) {
1516
- const lernaContent = await fs5.readFile(lernaPath, "utf-8");
1575
+ const lernaContent = await fs6.readFile(lernaPath, "utf-8");
1517
1576
  const lerna = JSON.parse(lernaContent);
1518
1577
  if (lerna.packages) {
1519
1578
  patterns = lerna.packages;
@@ -1524,7 +1583,7 @@ var init_path_manager = __esm({
1524
1583
  patterns = ["apps/*", "libs/*", "packages/*"];
1525
1584
  } else if (type === "turborepo") {
1526
1585
  const packageJsonPath = path5.join(rootPath, "package.json");
1527
- const content = await fs5.readFile(packageJsonPath, "utf-8");
1586
+ const content = await fs6.readFile(packageJsonPath, "utf-8");
1528
1587
  const pkg = JSON.parse(content);
1529
1588
  if (Array.isArray(pkg.workspaces)) {
1530
1589
  patterns = pkg.workspaces;
@@ -1544,7 +1603,7 @@ var init_path_manager = __esm({
1544
1603
  const packageJsonPath = path5.join(packagePath, "package.json");
1545
1604
  if (await fileExists2(packageJsonPath)) {
1546
1605
  try {
1547
- const content = await fs5.readFile(packageJsonPath, "utf-8");
1606
+ const content = await fs6.readFile(packageJsonPath, "utf-8");
1548
1607
  const pkg = JSON.parse(content);
1549
1608
  const prjctMdPath = path5.join(packagePath, "PRJCT.md");
1550
1609
  packages.push({
@@ -1600,7 +1659,7 @@ var init_path_manager = __esm({
1600
1659
  });
1601
1660
 
1602
1661
  // core/infrastructure/config-manager.ts
1603
- import fs6 from "node:fs/promises";
1662
+ import fs7 from "node:fs/promises";
1604
1663
  import path6 from "node:path";
1605
1664
  import * as jsonc from "jsonc-parser";
1606
1665
  function parseJsonc(content) {
@@ -1639,7 +1698,7 @@ var init_config_manager = __esm({
1639
1698
  async readConfig(projectPath) {
1640
1699
  try {
1641
1700
  const configPath = path_manager_default.getLocalConfigPath(projectPath);
1642
- const content = await fs6.readFile(configPath, "utf-8");
1701
+ const content = await fs7.readFile(configPath, "utf-8");
1643
1702
  return parseJsonc(content);
1644
1703
  } catch (error) {
1645
1704
  if (isNotFoundError(error)) {
@@ -1655,9 +1714,9 @@ var init_config_manager = __esm({
1655
1714
  async writeConfig(projectPath, config) {
1656
1715
  const configPath = path_manager_default.getLocalConfigPath(projectPath);
1657
1716
  const configDir = path_manager_default.getLegacyPrjctPath(projectPath);
1658
- await fs6.mkdir(configDir, { recursive: true });
1717
+ await fs7.mkdir(configDir, { recursive: true });
1659
1718
  const content = JSON.stringify(config, null, 2);
1660
- await fs6.writeFile(configPath, `${content}
1719
+ await fs7.writeFile(configPath, `${content}
1661
1720
  `, "utf-8");
1662
1721
  }
1663
1722
  /**
@@ -1668,7 +1727,7 @@ var init_config_manager = __esm({
1668
1727
  async readGlobalConfig(projectId) {
1669
1728
  try {
1670
1729
  const configPath = path_manager_default.getGlobalProjectConfigPath(projectId);
1671
- const content = await fs6.readFile(configPath, "utf-8");
1730
+ const content = await fs7.readFile(configPath, "utf-8");
1672
1731
  return parseJsonc(content);
1673
1732
  } catch (error) {
1674
1733
  if (isNotFoundError(error)) {
@@ -1686,9 +1745,9 @@ var init_config_manager = __esm({
1686
1745
  async writeGlobalConfig(projectId, config) {
1687
1746
  const configPath = path_manager_default.getGlobalProjectConfigPath(projectId);
1688
1747
  const configDir = path_manager_default.getGlobalProjectPath(projectId);
1689
- await fs6.mkdir(configDir, { recursive: true });
1748
+ await fs7.mkdir(configDir, { recursive: true });
1690
1749
  const content = JSON.stringify(config, null, 2);
1691
- await fs6.writeFile(configPath, `${content}
1750
+ await fs7.writeFile(configPath, `${content}
1692
1751
  `, "utf-8");
1693
1752
  }
1694
1753
  /**
@@ -1778,7 +1837,7 @@ var init_config_manager = __esm({
1778
1837
  if (!config || !config.projectId) return true;
1779
1838
  const globalPath = path_manager_default.getGlobalProjectPath(config.projectId);
1780
1839
  try {
1781
- const coreFiles = await fs6.readdir(path6.join(globalPath, "core"));
1840
+ const coreFiles = await fs7.readdir(path6.join(globalPath, "core"));
1782
1841
  return coreFiles.length === 0;
1783
1842
  } catch (error) {
1784
1843
  if (isNotFoundError(error)) {
@@ -1901,7 +1960,7 @@ var init_config_manager = __esm({
1901
1960
  });
1902
1961
 
1903
1962
  // core/infrastructure/editors-config.ts
1904
- import fs7 from "node:fs/promises";
1963
+ import fs8 from "node:fs/promises";
1905
1964
  import os4 from "node:os";
1906
1965
  import path7 from "node:path";
1907
1966
  var EditorsConfig, editorsConfig, editors_config_default;
@@ -1926,7 +1985,7 @@ var init_editors_config = __esm({
1926
1985
  */
1927
1986
  async ensureConfigDir() {
1928
1987
  try {
1929
- await fs7.mkdir(this.configDir, { recursive: true });
1988
+ await fs8.mkdir(this.configDir, { recursive: true });
1930
1989
  } catch (error) {
1931
1990
  console.error("[editors-config] Error creating config directory:", getErrorMessage2(error));
1932
1991
  }
@@ -1936,7 +1995,7 @@ var init_editors_config = __esm({
1936
1995
  */
1937
1996
  async loadConfig() {
1938
1997
  try {
1939
- const content = await fs7.readFile(this.configFile, "utf-8");
1998
+ const content = await fs8.readFile(this.configFile, "utf-8");
1940
1999
  return JSON.parse(content);
1941
2000
  } catch (error) {
1942
2001
  if (error.code === "ENOENT") {
@@ -1960,7 +2019,7 @@ var init_editors_config = __esm({
1960
2019
  lastInstall: (/* @__PURE__ */ new Date()).toISOString(),
1961
2020
  path: installPath
1962
2021
  };
1963
- await fs7.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
2022
+ await fs8.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
1964
2023
  return true;
1965
2024
  } catch (error) {
1966
2025
  console.error("[editors-config] Error saving config:", getErrorMessage2(error));
@@ -2000,7 +2059,7 @@ var init_editors_config = __esm({
2000
2059
  }
2001
2060
  config.version = version;
2002
2061
  config.lastInstall = (/* @__PURE__ */ new Date()).toISOString();
2003
- await fs7.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
2062
+ await fs8.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
2004
2063
  return true;
2005
2064
  } catch (error) {
2006
2065
  console.error("[editors-config] Error updating version:", getErrorMessage2(error));
@@ -2012,7 +2071,7 @@ var init_editors_config = __esm({
2012
2071
  */
2013
2072
  async configExists() {
2014
2073
  try {
2015
- await fs7.access(this.configFile);
2074
+ await fs8.access(this.configFile);
2016
2075
  return true;
2017
2076
  } catch (_error) {
2018
2077
  return false;
@@ -2026,7 +2085,7 @@ var init_editors_config = __esm({
2026
2085
  try {
2027
2086
  const exists = await this.configExists();
2028
2087
  if (exists) {
2029
- await fs7.unlink(this.configFile);
2088
+ await fs8.unlink(this.configFile);
2030
2089
  }
2031
2090
  return true;
2032
2091
  } catch (error) {
@@ -2709,7 +2768,7 @@ __export(session_tracker_exports, {
2709
2768
  default: () => session_tracker_default,
2710
2769
  sessionTracker: () => sessionTracker
2711
2770
  });
2712
- import fs10 from "node:fs/promises";
2771
+ import fs11 from "node:fs/promises";
2713
2772
  import path10 from "node:path";
2714
2773
  var SESSION_FILENAME, DEFAULT_IDLE_TIMEOUT_MS, MAX_COMMAND_HISTORY, MAX_FILE_HISTORY, SessionTracker, sessionTracker, session_tracker_default;
2715
2774
  var init_session_tracker = __esm({
@@ -2735,7 +2794,7 @@ var init_session_tracker = __esm({
2735
2794
  async read(projectId) {
2736
2795
  const filePath = this.getPath(projectId);
2737
2796
  try {
2738
- const content = await fs10.readFile(filePath, "utf-8");
2797
+ const content = await fs11.readFile(filePath, "utf-8");
2739
2798
  return JSON.parse(content);
2740
2799
  } catch (error) {
2741
2800
  if (isNotFoundError(error) || error instanceof SyntaxError) {
@@ -2749,8 +2808,8 @@ var init_session_tracker = __esm({
2749
2808
  */
2750
2809
  async write(projectId, data) {
2751
2810
  const filePath = this.getPath(projectId);
2752
- await fs10.mkdir(path10.dirname(filePath), { recursive: true });
2753
- await fs10.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
2811
+ await fs11.mkdir(path10.dirname(filePath), { recursive: true });
2812
+ await fs11.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
2754
2813
  }
2755
2814
  getDefault() {
2756
2815
  return {
@@ -2912,7 +2971,7 @@ var start_exports = {};
2912
2971
  __export(start_exports, {
2913
2972
  runStart: () => runStart
2914
2973
  });
2915
- import fs11 from "node:fs/promises";
2974
+ import fs12 from "node:fs/promises";
2916
2975
  import os5 from "node:os";
2917
2976
  import path11 from "node:path";
2918
2977
  import chalk3 from "chalk";
@@ -3018,14 +3077,14 @@ async function installRouter(provider) {
3018
3077
  }
3019
3078
  try {
3020
3079
  const commandsDir = path11.join(config.configDir, "commands");
3021
- await fs11.mkdir(commandsDir, { recursive: true });
3080
+ await fs12.mkdir(commandsDir, { recursive: true });
3022
3081
  const { getPackageRoot: getPackageRoot2 } = await Promise.resolve().then(() => (init_version(), version_exports));
3023
3082
  const packageRoot = getPackageRoot2();
3024
3083
  const routerFile = provider === "claude" ? "p.md" : "p.toml";
3025
3084
  const src = path11.join(packageRoot, "templates", "commands", routerFile);
3026
3085
  const dest = path11.join(commandsDir, routerFile);
3027
3086
  if (await fileExists(src)) {
3028
- await fs11.copyFile(src, dest);
3087
+ await fs12.copyFile(src, dest);
3029
3088
  return true;
3030
3089
  }
3031
3090
  return false;
@@ -3042,16 +3101,16 @@ async function installGlobalConfig(provider) {
3042
3101
  return false;
3043
3102
  }
3044
3103
  try {
3045
- await fs11.mkdir(config.configDir, { recursive: true });
3104
+ await fs12.mkdir(config.configDir, { recursive: true });
3046
3105
  const { getPackageRoot: getPackageRoot2 } = await Promise.resolve().then(() => (init_version(), version_exports));
3047
3106
  const packageRoot = getPackageRoot2();
3048
3107
  const configFile = provider === "claude" ? "CLAUDE.md" : "GEMINI.md";
3049
3108
  const src = path11.join(packageRoot, "templates", "global", configFile);
3050
3109
  const dest = path11.join(config.configDir, configFile);
3051
3110
  if (await fileExists(src)) {
3052
- const content = await fs11.readFile(src, "utf-8");
3111
+ const content = await fs12.readFile(src, "utf-8");
3053
3112
  if (await fileExists(dest)) {
3054
- const existing = await fs11.readFile(dest, "utf-8");
3113
+ const existing = await fs12.readFile(dest, "utf-8");
3055
3114
  const startMarker = "<!-- prjct:start - DO NOT REMOVE THIS MARKER -->";
3056
3115
  const endMarker = "<!-- prjct:end - DO NOT REMOVE THIS MARKER -->";
3057
3116
  if (existing.includes(startMarker) && existing.includes(endMarker)) {
@@ -3061,14 +3120,14 @@ async function installGlobalConfig(provider) {
3061
3120
  content.indexOf(startMarker),
3062
3121
  content.indexOf(endMarker) + endMarker.length
3063
3122
  );
3064
- await fs11.writeFile(dest, before + prjctSection + after);
3123
+ await fs12.writeFile(dest, before + prjctSection + after);
3065
3124
  } else {
3066
- await fs11.writeFile(dest, `${existing}
3125
+ await fs12.writeFile(dest, `${existing}
3067
3126
 
3068
3127
  ${content}`);
3069
3128
  }
3070
3129
  } else {
3071
- await fs11.writeFile(dest, content);
3130
+ await fs12.writeFile(dest, content);
3072
3131
  }
3073
3132
  return true;
3074
3133
  }
@@ -3082,7 +3141,7 @@ ${content}`);
3082
3141
  }
3083
3142
  async function saveSetupConfig(providers) {
3084
3143
  const configDir = path11.join(os5.homedir(), ".prjct-cli", "config");
3085
- await fs11.mkdir(configDir, { recursive: true });
3144
+ await fs12.mkdir(configDir, { recursive: true });
3086
3145
  const configPath = path11.join(configDir, "installed-editors.json");
3087
3146
  const config = {
3088
3147
  version: VERSION,
@@ -3093,7 +3152,7 @@ async function saveSetupConfig(providers) {
3093
3152
  lastInstall: (/* @__PURE__ */ new Date()).toISOString(),
3094
3153
  path: path11.join(os5.homedir(), `.${providers[0]}`, "commands")
3095
3154
  };
3096
- await fs11.writeFile(configPath, JSON.stringify(config, null, 2));
3155
+ await fs12.writeFile(configPath, JSON.stringify(config, null, 2));
3097
3156
  }
3098
3157
  function showCompletion(providers) {
3099
3158
  console.log(`
@@ -3123,7 +3182,7 @@ async function runStart() {
3123
3182
  showBanner();
3124
3183
  const configPath = path11.join(os5.homedir(), ".prjct-cli", "config", "installed-editors.json");
3125
3184
  if (await fileExists(configPath)) {
3126
- const existing = JSON.parse(await fs11.readFile(configPath, "utf-8"));
3185
+ const existing = JSON.parse(await fs12.readFile(configPath, "utf-8"));
3127
3186
  if (existing.version === VERSION) {
3128
3187
  console.log(` ${chalk3.yellow("\u2139")} Already configured for v${VERSION}`);
3129
3188
  console.log(` ${chalk3.dim("Run with --force to reconfigure")}
@@ -3477,7 +3536,7 @@ var init_cache = __esm({
3477
3536
  });
3478
3537
 
3479
3538
  // core/storage/storage-manager.ts
3480
- import fs12 from "node:fs/promises";
3539
+ import fs13 from "node:fs/promises";
3481
3540
  import path12 from "node:path";
3482
3541
  var StorageManager;
3483
3542
  var init_storage_manager = __esm({
@@ -3488,15 +3547,18 @@ var init_storage_manager = __esm({
3488
3547
  init_fs();
3489
3548
  init_cache();
3490
3549
  init_date_helper();
3550
+ init_safe_reader();
3491
3551
  StorageManager = class {
3492
3552
  static {
3493
3553
  __name(this, "StorageManager");
3494
3554
  }
3495
3555
  filename;
3496
3556
  cache;
3497
- constructor(filename) {
3557
+ schema;
3558
+ constructor(filename, schema) {
3498
3559
  this.filename = filename;
3499
3560
  this.cache = new TTLCache({ ttl: 5e3, maxSize: 50 });
3561
+ this.schema = schema ?? null;
3500
3562
  }
3501
3563
  /**
3502
3564
  * Get file path for storage JSON
@@ -3513,7 +3575,9 @@ var init_storage_manager = __esm({
3513
3575
  return path_manager_default.getFilePath(projectId, layer, mdFilename);
3514
3576
  }
3515
3577
  /**
3516
- * Read data from storage
3578
+ * Read data from storage with optional Zod validation.
3579
+ * When a schema is provided (via constructor), validates after JSON.parse.
3580
+ * On corruption: creates .backup file, logs warning, returns default.
3517
3581
  */
3518
3582
  async read(projectId) {
3519
3583
  const cached = this.cache.get(projectId);
@@ -3521,8 +3585,16 @@ var init_storage_manager = __esm({
3521
3585
  return cached;
3522
3586
  }
3523
3587
  const filePath = this.getStoragePath(projectId);
3588
+ if (this.schema) {
3589
+ const data = await safeRead(filePath, this.schema);
3590
+ if (data !== null) {
3591
+ this.cache.set(projectId, data);
3592
+ return data;
3593
+ }
3594
+ return this.getDefault();
3595
+ }
3524
3596
  try {
3525
- const content = await fs12.readFile(filePath, "utf-8");
3597
+ const content = await fs13.readFile(filePath, "utf-8");
3526
3598
  const data = JSON.parse(content);
3527
3599
  this.cache.set(projectId, data);
3528
3600
  return data;
@@ -3539,13 +3611,13 @@ var init_storage_manager = __esm({
3539
3611
  async write(projectId, data) {
3540
3612
  const storagePath = this.getStoragePath(projectId);
3541
3613
  const contextPath = this.getContextPath(projectId, this.getMdFilename());
3542
- await fs12.mkdir(path12.dirname(storagePath), { recursive: true });
3543
- await fs12.mkdir(path12.dirname(contextPath), { recursive: true });
3614
+ await fs13.mkdir(path12.dirname(storagePath), { recursive: true });
3615
+ await fs13.mkdir(path12.dirname(contextPath), { recursive: true });
3544
3616
  const tempPath = `${storagePath}.${Date.now()}.tmp`;
3545
- await fs12.writeFile(tempPath, JSON.stringify(data, null, 2), "utf-8");
3546
- await fs12.rename(tempPath, storagePath);
3617
+ await fs13.writeFile(tempPath, JSON.stringify(data, null, 2), "utf-8");
3618
+ await fs13.rename(tempPath, storagePath);
3547
3619
  const md2 = this.toMarkdown(data);
3548
- await fs12.writeFile(contextPath, md2, "utf-8");
3620
+ await fs13.writeFile(contextPath, md2, "utf-8");
3549
3621
  this.cache.set(projectId, data);
3550
3622
  }
3551
3623
  /**
@@ -3593,7 +3665,7 @@ var init_storage_manager = __esm({
3593
3665
  async exists(projectId) {
3594
3666
  const filePath = this.getStoragePath(projectId);
3595
3667
  try {
3596
- await fs12.access(filePath);
3668
+ await fs13.access(filePath);
3597
3669
  return true;
3598
3670
  } catch (error) {
3599
3671
  if (isNotFoundError(error)) {
@@ -3635,7 +3707,7 @@ var init_metrics_storage = __esm({
3635
3707
  __name(this, "MetricsStorage");
3636
3708
  }
3637
3709
  constructor() {
3638
- super("metrics.json");
3710
+ super("metrics.json", MetricsJsonSchema);
3639
3711
  }
3640
3712
  getDefault() {
3641
3713
  return { ...DEFAULT_METRICS };
@@ -3855,7 +3927,7 @@ var init_metrics_storage = __esm({
3855
3927
 
3856
3928
  // core/context-tools/files-tool.ts
3857
3929
  import { exec as execCallback2 } from "node:child_process";
3858
- import fs13 from "node:fs/promises";
3930
+ import fs14 from "node:fs/promises";
3859
3931
  import path13 from "node:path";
3860
3932
  import { promisify as promisify3 } from "node:util";
3861
3933
  async function findRelevantFiles(taskDescription, projectPath, options = {}) {
@@ -3985,7 +4057,7 @@ async function getAllCodeFiles(projectPath) {
3985
4057
  const files = [];
3986
4058
  async function walk(dir, relativePath = "") {
3987
4059
  try {
3988
- const entries = await fs13.readdir(dir, { withFileTypes: true });
4060
+ const entries = await fs14.readdir(dir, { withFileTypes: true });
3989
4061
  for (const entry of entries) {
3990
4062
  const fullPath = path13.join(dir, entry.name);
3991
4063
  const relPath = path13.join(relativePath, entry.name);
@@ -4289,14 +4361,14 @@ var init_files_tool = __esm({
4289
4361
 
4290
4362
  // core/context-tools/imports-tool.ts
4291
4363
  import { exec as execCallback3 } from "node:child_process";
4292
- import fs14 from "node:fs/promises";
4364
+ import fs15 from "node:fs/promises";
4293
4365
  import path14 from "node:path";
4294
4366
  import { promisify as promisify4 } from "node:util";
4295
4367
  async function analyzeImports(filePath, projectPath = process.cwd(), options = {}) {
4296
4368
  const absolutePath = path14.isAbsolute(filePath) ? filePath : path14.join(projectPath, filePath);
4297
4369
  let content;
4298
4370
  try {
4299
- content = await fs14.readFile(absolutePath, "utf-8");
4371
+ content = await fs15.readFile(absolutePath, "utf-8");
4300
4372
  } catch (error) {
4301
4373
  if (isNotFoundError(error)) {
4302
4374
  return {
@@ -4388,7 +4460,7 @@ async function tryResolve(basePath, projectPath) {
4388
4460
  for (const ext of extensions) {
4389
4461
  const fullPath = basePath + ext;
4390
4462
  try {
4391
- const stat = await fs14.stat(fullPath);
4463
+ const stat = await fs15.stat(fullPath);
4392
4464
  if (stat.isFile()) {
4393
4465
  return path14.relative(projectPath, fullPath);
4394
4466
  }
@@ -4917,13 +4989,13 @@ var init_token_counter = __esm({
4917
4989
  });
4918
4990
 
4919
4991
  // core/context-tools/signatures-tool.ts
4920
- import fs15 from "node:fs/promises";
4992
+ import fs16 from "node:fs/promises";
4921
4993
  import path15 from "node:path";
4922
4994
  async function extractSignatures(filePath, projectPath = process.cwd()) {
4923
4995
  const absolutePath = path15.isAbsolute(filePath) ? filePath : path15.join(projectPath, filePath);
4924
4996
  let content;
4925
4997
  try {
4926
- content = await fs15.readFile(absolutePath, "utf-8");
4998
+ content = await fs16.readFile(absolutePath, "utf-8");
4927
4999
  } catch (error) {
4928
5000
  if (isNotFoundError(error)) {
4929
5001
  return {
@@ -4967,7 +5039,7 @@ async function extractDirectorySignatures(dirPath, projectPath = process.cwd(),
4967
5039
  const absolutePath = path15.isAbsolute(dirPath) ? dirPath : path15.join(projectPath, dirPath);
4968
5040
  const results = [];
4969
5041
  async function processDir(dir) {
4970
- const entries = await fs15.readdir(dir, { withFileTypes: true });
5042
+ const entries = await fs16.readdir(dir, { withFileTypes: true });
4971
5043
  for (const entry of entries) {
4972
5044
  const fullPath = path15.join(dir, entry.name);
4973
5045
  const relativePath = path15.relative(projectPath, fullPath);
@@ -5269,13 +5341,13 @@ var init_signatures_tool = __esm({
5269
5341
  });
5270
5342
 
5271
5343
  // core/context-tools/summary-tool.ts
5272
- import fs16 from "node:fs/promises";
5344
+ import fs17 from "node:fs/promises";
5273
5345
  import path16 from "node:path";
5274
5346
  async function summarizeFile(filePath, projectPath = process.cwd()) {
5275
5347
  const absolutePath = path16.isAbsolute(filePath) ? filePath : path16.join(projectPath, filePath);
5276
5348
  let content;
5277
5349
  try {
5278
- content = await fs16.readFile(absolutePath, "utf-8");
5350
+ content = await fs17.readFile(absolutePath, "utf-8");
5279
5351
  } catch (error) {
5280
5352
  if (isNotFoundError(error)) {
5281
5353
  return {
@@ -5313,7 +5385,7 @@ async function summarizeDirectory(dirPath, projectPath = process.cwd(), options
5313
5385
  const absolutePath = path16.isAbsolute(dirPath) ? dirPath : path16.join(projectPath, dirPath);
5314
5386
  const results = [];
5315
5387
  async function processDir(dir) {
5316
- const entries = await fs16.readdir(dir, { withFileTypes: true });
5388
+ const entries = await fs17.readdir(dir, { withFileTypes: true });
5317
5389
  for (const entry of entries) {
5318
5390
  const fullPath = path16.join(dir, entry.name);
5319
5391
  const relativePath = path16.relative(projectPath, fullPath);
@@ -5575,11 +5647,11 @@ async function runSignaturesTool(args2, projectPath) {
5575
5647
  }
5576
5648
  };
5577
5649
  }
5578
- const fs52 = await import("node:fs/promises");
5650
+ const fs53 = await import("node:fs/promises");
5579
5651
  const path65 = await import("node:path");
5580
5652
  const fullPath = path65.isAbsolute(filePath) ? filePath : path65.join(projectPath, filePath);
5581
5653
  try {
5582
- const stat = await fs52.stat(fullPath);
5654
+ const stat = await fs53.stat(fullPath);
5583
5655
  if (stat.isDirectory()) {
5584
5656
  const results = await extractDirectorySignatures(filePath, projectPath, {
5585
5657
  recursive: args2.includes("--recursive") || args2.includes("-r")
@@ -5646,11 +5718,11 @@ async function runSummaryTool(args2, projectPath) {
5646
5718
  }
5647
5719
  };
5648
5720
  }
5649
- const fs52 = await import("node:fs/promises");
5721
+ const fs53 = await import("node:fs/promises");
5650
5722
  const path65 = await import("node:path");
5651
5723
  const fullPath = path65.isAbsolute(targetPath) ? targetPath : path65.join(projectPath, targetPath);
5652
5724
  try {
5653
- const stat = await fs52.stat(fullPath);
5725
+ const stat = await fs53.stat(fullPath);
5654
5726
  if (stat.isDirectory()) {
5655
5727
  const results = await summarizeDirectory(targetPath, projectPath, {
5656
5728
  recursive: args2.includes("--recursive") || args2.includes("-r")
@@ -5810,7 +5882,7 @@ var hooks_service_exports = {};
5810
5882
  __export(hooks_service_exports, {
5811
5883
  hooksService: () => hooksService
5812
5884
  });
5813
- import fs17 from "node:fs/promises";
5885
+ import fs18 from "node:fs/promises";
5814
5886
  import path17 from "node:path";
5815
5887
  import chalk4 from "chalk";
5816
5888
  function getPostCommitScript() {
@@ -5893,7 +5965,7 @@ function selectStrategy(detected) {
5893
5965
  async function installLefthook(projectPath, hooks) {
5894
5966
  const configFile = await fileExists(path17.join(projectPath, "lefthook.yml")) ? "lefthook.yml" : "lefthook.yaml";
5895
5967
  const configPath = path17.join(projectPath, configFile);
5896
- let content = await fs17.readFile(configPath, "utf-8");
5968
+ let content = await fs18.readFile(configPath, "utf-8");
5897
5969
  for (const hook of hooks) {
5898
5970
  const sectionName = hook;
5899
5971
  const commandName = `prjct-sync-${hook}`;
@@ -5922,7 +5994,7 @@ ${sectionName}:
5922
5994
  ${hookBlock}`;
5923
5995
  }
5924
5996
  }
5925
- await fs17.writeFile(configPath, content, "utf-8");
5997
+ await fs18.writeFile(configPath, content, "utf-8");
5926
5998
  return true;
5927
5999
  }
5928
6000
  async function installHusky(projectPath, hooks) {
@@ -5931,13 +6003,13 @@ async function installHusky(projectPath, hooks) {
5931
6003
  const hookPath = path17.join(huskyDir, hook);
5932
6004
  const script = hook === "post-commit" ? getPostCommitScript() : getPostCheckoutScript();
5933
6005
  if (await fileExists(hookPath)) {
5934
- const existing = await fs17.readFile(hookPath, "utf-8");
6006
+ const existing = await fs18.readFile(hookPath, "utf-8");
5935
6007
  if (existing.includes("prjct sync")) {
5936
6008
  continue;
5937
6009
  }
5938
- await fs17.appendFile(hookPath, "\n# prjct auto-sync\nprjct sync --quiet --yes &\n");
6010
+ await fs18.appendFile(hookPath, "\n# prjct auto-sync\nprjct sync --quiet --yes &\n");
5939
6011
  } else {
5940
- await fs17.writeFile(hookPath, script, { mode: 493 });
6012
+ await fs18.writeFile(hookPath, script, { mode: 493 });
5941
6013
  }
5942
6014
  }
5943
6015
  return true;
@@ -5945,24 +6017,24 @@ async function installHusky(projectPath, hooks) {
5945
6017
  async function installDirect(projectPath, hooks) {
5946
6018
  const hooksDir = path17.join(projectPath, ".git", "hooks");
5947
6019
  if (!await fileExists(hooksDir)) {
5948
- await fs17.mkdir(hooksDir, { recursive: true });
6020
+ await fs18.mkdir(hooksDir, { recursive: true });
5949
6021
  }
5950
6022
  for (const hook of hooks) {
5951
6023
  const hookPath = path17.join(hooksDir, hook);
5952
6024
  const script = hook === "post-commit" ? getPostCommitScript() : getPostCheckoutScript();
5953
6025
  if (await fileExists(hookPath)) {
5954
- const existing = await fs17.readFile(hookPath, "utf-8");
6026
+ const existing = await fs18.readFile(hookPath, "utf-8");
5955
6027
  if (existing.includes("prjct sync")) {
5956
6028
  continue;
5957
6029
  }
5958
- await fs17.appendFile(
6030
+ await fs18.appendFile(
5959
6031
  hookPath,
5960
6032
  `
5961
6033
  # prjct auto-sync
5962
6034
  ${script.split("\n").slice(1).join("\n")}`
5963
6035
  );
5964
6036
  } else {
5965
- await fs17.writeFile(hookPath, script, { mode: 493 });
6037
+ await fs18.writeFile(hookPath, script, { mode: 493 });
5966
6038
  }
5967
6039
  }
5968
6040
  return true;
@@ -5971,10 +6043,10 @@ async function uninstallLefthook(projectPath) {
5971
6043
  const configFile = await fileExists(path17.join(projectPath, "lefthook.yml")) ? "lefthook.yml" : "lefthook.yaml";
5972
6044
  const configPath = path17.join(projectPath, configFile);
5973
6045
  if (!await fileExists(configPath)) return false;
5974
- let content = await fs17.readFile(configPath, "utf-8");
6046
+ let content = await fs18.readFile(configPath, "utf-8");
5975
6047
  content = content.replace(/\s*prjct-sync-[\w-]+:[\s\S]*?(?=\n\S|\n*$)/g, "");
5976
6048
  content = content.replace(/^(post-commit|post-checkout):\s*commands:\s*$/gm, "");
5977
- await fs17.writeFile(configPath, `${content.trimEnd()}
6049
+ await fs18.writeFile(configPath, `${content.trimEnd()}
5978
6050
  `, "utf-8");
5979
6051
  return true;
5980
6052
  }
@@ -5983,13 +6055,13 @@ async function uninstallHusky(projectPath) {
5983
6055
  for (const hook of ["post-commit", "post-checkout"]) {
5984
6056
  const hookPath = path17.join(huskyDir, hook);
5985
6057
  if (!await fileExists(hookPath)) continue;
5986
- const content = await fs17.readFile(hookPath, "utf-8");
6058
+ const content = await fs18.readFile(hookPath, "utf-8");
5987
6059
  if (!content.includes("prjct sync")) continue;
5988
6060
  const cleaned = content.split("\n").filter((line) => !line.includes("prjct sync") && !line.includes("prjct auto-sync")).join("\n");
5989
6061
  if (cleaned.trim() === "#!/bin/sh" || cleaned.trim() === "#!/usr/bin/env sh") {
5990
- await fs17.unlink(hookPath);
6062
+ await fs18.unlink(hookPath);
5991
6063
  } else {
5992
- await fs17.writeFile(hookPath, cleaned, { mode: 493 });
6064
+ await fs18.writeFile(hookPath, cleaned, { mode: 493 });
5993
6065
  }
5994
6066
  }
5995
6067
  return true;
@@ -5999,13 +6071,13 @@ async function uninstallDirect(projectPath) {
5999
6071
  for (const hook of ["post-commit", "post-checkout"]) {
6000
6072
  const hookPath = path17.join(hooksDir, hook);
6001
6073
  if (!await fileExists(hookPath)) continue;
6002
- const content = await fs17.readFile(hookPath, "utf-8");
6074
+ const content = await fs18.readFile(hookPath, "utf-8");
6003
6075
  if (!content.includes("prjct sync")) continue;
6004
6076
  if (content.includes("Installed by: prjct hooks install")) {
6005
- await fs17.unlink(hookPath);
6077
+ await fs18.unlink(hookPath);
6006
6078
  } else {
6007
6079
  const cleaned = content.split("\n").filter((line) => !line.includes("prjct sync") && !line.includes("prjct auto-sync")).join("\n");
6008
- await fs17.writeFile(hookPath, cleaned, { mode: 493 });
6080
+ await fs18.writeFile(hookPath, cleaned, { mode: 493 });
6009
6081
  }
6010
6082
  }
6011
6083
  return true;
@@ -6231,17 +6303,17 @@ var init_hooks_service = __esm({
6231
6303
  const configFile = await fileExists(path17.join(projectPath, "lefthook.yml")) ? "lefthook.yml" : "lefthook.yaml";
6232
6304
  const configPath = path17.join(projectPath, configFile);
6233
6305
  if (!await fileExists(configPath)) return false;
6234
- const content = await fs17.readFile(configPath, "utf-8");
6306
+ const content = await fs18.readFile(configPath, "utf-8");
6235
6307
  return content.includes(`prjct-sync-${hook}`);
6236
6308
  }
6237
6309
  if (strategy === "husky") {
6238
6310
  const hookPath2 = path17.join(projectPath, ".husky", hook);
6239
6311
  if (!await fileExists(hookPath2)) return false;
6240
- return (await fs17.readFile(hookPath2, "utf-8")).includes("prjct sync");
6312
+ return (await fs18.readFile(hookPath2, "utf-8")).includes("prjct sync");
6241
6313
  }
6242
6314
  const hookPath = path17.join(projectPath, ".git", "hooks", hook);
6243
6315
  if (!await fileExists(hookPath)) return false;
6244
- return (await fs17.readFile(hookPath, "utf-8")).includes("prjct sync");
6316
+ return (await fs18.readFile(hookPath, "utf-8")).includes("prjct sync");
6245
6317
  }
6246
6318
  async getHookPath(projectPath, hook, strategy) {
6247
6319
  if (strategy === "lefthook") {
@@ -6264,7 +6336,7 @@ var init_hooks_service = __esm({
6264
6336
  "project.json"
6265
6337
  );
6266
6338
  if (!await fileExists(projectJsonPath)) return null;
6267
- const project = JSON.parse(await fs17.readFile(projectJsonPath, "utf-8"));
6339
+ const project = JSON.parse(await fs18.readFile(projectJsonPath, "utf-8"));
6268
6340
  return project.hooks || null;
6269
6341
  } catch {
6270
6342
  return null;
@@ -6282,9 +6354,9 @@ var init_hooks_service = __esm({
6282
6354
  "project.json"
6283
6355
  );
6284
6356
  if (!await fileExists(projectJsonPath)) return;
6285
- const project = JSON.parse(await fs17.readFile(projectJsonPath, "utf-8"));
6357
+ const project = JSON.parse(await fs18.readFile(projectJsonPath, "utf-8"));
6286
6358
  project.hooks = config;
6287
- await fs17.writeFile(projectJsonPath, JSON.stringify(project, null, 2));
6359
+ await fs18.writeFile(projectJsonPath, JSON.stringify(project, null, 2));
6288
6360
  } catch {
6289
6361
  }
6290
6362
  }
@@ -6300,7 +6372,7 @@ __export(doctor_service_exports, {
6300
6372
  doctorService: () => doctorService
6301
6373
  });
6302
6374
  import { execSync } from "node:child_process";
6303
- import fs18 from "node:fs/promises";
6375
+ import fs19 from "node:fs/promises";
6304
6376
  import path18 from "node:path";
6305
6377
  import chalk5 from "chalk";
6306
6378
  var DoctorService, doctorService;
@@ -6416,7 +6488,7 @@ var init_doctor_service = __esm({
6416
6488
  async checkPrjctConfig() {
6417
6489
  const configPath = path18.join(this.projectPath, ".prjct", "prjct.config.json");
6418
6490
  try {
6419
- await fs18.access(configPath);
6491
+ await fs19.access(configPath);
6420
6492
  return {
6421
6493
  name: "prjct config",
6422
6494
  status: "ok",
@@ -6440,7 +6512,7 @@ var init_doctor_service = __esm({
6440
6512
  }
6441
6513
  const claudePath = path18.join(this.globalPath, "context", "CLAUDE.md");
6442
6514
  try {
6443
- const stat = await fs18.stat(claudePath);
6515
+ const stat = await fs19.stat(claudePath);
6444
6516
  const ageMs = Date.now() - stat.mtimeMs;
6445
6517
  const ageHours = Math.floor(ageMs / (1e3 * 60 * 60));
6446
6518
  const ageDays = Math.floor(ageHours / 24);
@@ -6514,7 +6586,7 @@ var init_doctor_service = __esm({
6514
6586
  }
6515
6587
  const statePath = path18.join(this.globalPath, "storage", "state.json");
6516
6588
  try {
6517
- const content = await fs18.readFile(statePath, "utf-8");
6589
+ const content = await fs19.readFile(statePath, "utf-8");
6518
6590
  const state = JSON.parse(content);
6519
6591
  if (state.currentTask) {
6520
6592
  return {
@@ -6611,13 +6683,13 @@ var init_doctor_service = __esm({
6611
6683
  });
6612
6684
 
6613
6685
  // core/infrastructure/command-installer.ts
6614
- import fs19 from "node:fs/promises";
6686
+ import fs20 from "node:fs/promises";
6615
6687
  import os6 from "node:os";
6616
6688
  import path19 from "node:path";
6617
6689
  async function loadModuleConfig() {
6618
6690
  try {
6619
6691
  const configPath = path19.join(PACKAGE_ROOT, "templates/global/modules/module-config.json");
6620
- const content = await fs19.readFile(configPath, "utf-8");
6692
+ const content = await fs20.readFile(configPath, "utf-8");
6621
6693
  return JSON.parse(content);
6622
6694
  } catch {
6623
6695
  return null;
@@ -6628,7 +6700,7 @@ async function composeGlobalTemplate(profile) {
6628
6700
  const modulesDir = path19.join(PACKAGE_ROOT, "templates/global/modules");
6629
6701
  if (!config) {
6630
6702
  const legacyPath = path19.join(PACKAGE_ROOT, "templates/global/CLAUDE.md");
6631
- return fs19.readFile(legacyPath, "utf-8");
6703
+ return fs20.readFile(legacyPath, "utf-8");
6632
6704
  }
6633
6705
  const profileName = profile || config.default;
6634
6706
  const selectedProfile = config.profiles[profileName];
@@ -6636,7 +6708,7 @@ async function composeGlobalTemplate(profile) {
6636
6708
  const defaultProfile = config.profiles[config.default];
6637
6709
  if (!defaultProfile) {
6638
6710
  const legacyPath = path19.join(PACKAGE_ROOT, "templates/global/CLAUDE.md");
6639
- return fs19.readFile(legacyPath, "utf-8");
6711
+ return fs20.readFile(legacyPath, "utf-8");
6640
6712
  }
6641
6713
  }
6642
6714
  const modules = (selectedProfile || config.profiles[config.default]).modules;
@@ -6645,7 +6717,7 @@ async function composeGlobalTemplate(profile) {
6645
6717
  for (const moduleName of modules) {
6646
6718
  try {
6647
6719
  const modulePath = path19.join(modulesDir, moduleName);
6648
- const content = await fs19.readFile(modulePath, "utf-8");
6720
+ const content = await fs20.readFile(modulePath, "utf-8");
6649
6721
  parts.push("");
6650
6722
  parts.push(content);
6651
6723
  } catch {
@@ -6661,14 +6733,14 @@ async function installDocs() {
6661
6733
  try {
6662
6734
  const docsDir = path19.join(os6.homedir(), ".prjct-cli", "docs");
6663
6735
  const templateDocsDir = path19.join(PACKAGE_ROOT, "templates/global/docs");
6664
- await fs19.mkdir(docsDir, { recursive: true });
6665
- const docFiles = await fs19.readdir(templateDocsDir);
6736
+ await fs20.mkdir(docsDir, { recursive: true });
6737
+ const docFiles = await fs20.readdir(templateDocsDir);
6666
6738
  for (const file of docFiles) {
6667
6739
  if (file.endsWith(".md")) {
6668
6740
  const srcPath = path19.join(templateDocsDir, file);
6669
6741
  const destPath = path19.join(docsDir, file);
6670
- const content = await fs19.readFile(srcPath, "utf-8");
6671
- await fs19.writeFile(destPath, content, "utf-8");
6742
+ const content = await fs20.readFile(srcPath, "utf-8");
6743
+ await fs20.writeFile(destPath, content, "utf-8");
6672
6744
  }
6673
6745
  }
6674
6746
  return { success: true };
@@ -6689,23 +6761,23 @@ async function installGlobalConfig2() {
6689
6761
  };
6690
6762
  }
6691
6763
  try {
6692
- await fs19.mkdir(activeProvider.configDir, { recursive: true });
6764
+ await fs20.mkdir(activeProvider.configDir, { recursive: true });
6693
6765
  const globalConfigPath = path19.join(activeProvider.configDir, activeProvider.contextFile);
6694
6766
  const templatePath = path19.join(PACKAGE_ROOT, "templates", "global", activeProvider.contextFile);
6695
6767
  let templateContent = "";
6696
6768
  try {
6697
- templateContent = await fs19.readFile(templatePath, "utf-8");
6769
+ templateContent = await fs20.readFile(templatePath, "utf-8");
6698
6770
  } catch (_error) {
6699
6771
  if (providerName === "claude") {
6700
6772
  try {
6701
6773
  templateContent = await composeGlobalTemplate("standard");
6702
6774
  } catch {
6703
6775
  const fallbackTemplatePath = path19.join(PACKAGE_ROOT, "templates/global/CLAUDE.md");
6704
- templateContent = await fs19.readFile(fallbackTemplatePath, "utf-8");
6776
+ templateContent = await fs20.readFile(fallbackTemplatePath, "utf-8");
6705
6777
  }
6706
6778
  } else {
6707
6779
  const fallbackTemplatePath = path19.join(PACKAGE_ROOT, "templates/global/CLAUDE.md");
6708
- templateContent = await fs19.readFile(fallbackTemplatePath, "utf-8");
6780
+ templateContent = await fs20.readFile(fallbackTemplatePath, "utf-8");
6709
6781
  if (providerName === "gemini") {
6710
6782
  templateContent = templateContent.replace(/Claude/g, "Gemini");
6711
6783
  }
@@ -6714,7 +6786,7 @@ async function installGlobalConfig2() {
6714
6786
  let existingContent = "";
6715
6787
  let fileExists3 = false;
6716
6788
  try {
6717
- existingContent = await fs19.readFile(globalConfigPath, "utf-8");
6789
+ existingContent = await fs20.readFile(globalConfigPath, "utf-8");
6718
6790
  fileExists3 = true;
6719
6791
  } catch (error) {
6720
6792
  if (isNotFoundError(error)) {
@@ -6724,7 +6796,7 @@ async function installGlobalConfig2() {
6724
6796
  }
6725
6797
  }
6726
6798
  if (!fileExists3) {
6727
- await fs19.writeFile(globalConfigPath, templateContent, "utf-8");
6799
+ await fs20.writeFile(globalConfigPath, templateContent, "utf-8");
6728
6800
  return {
6729
6801
  success: true,
6730
6802
  action: "created",
@@ -6738,7 +6810,7 @@ async function installGlobalConfig2() {
6738
6810
  const updatedContent = `${existingContent}
6739
6811
 
6740
6812
  ${templateContent}`;
6741
- await fs19.writeFile(globalConfigPath, updatedContent, "utf-8");
6813
+ await fs20.writeFile(globalConfigPath, updatedContent, "utf-8");
6742
6814
  return {
6743
6815
  success: true,
6744
6816
  action: "appended",
@@ -6754,7 +6826,7 @@ ${templateContent}`;
6754
6826
  templateContent.indexOf(endMarker) + endMarker.length
6755
6827
  );
6756
6828
  const updatedContent = beforeMarker + prjctSection + afterMarker;
6757
- await fs19.writeFile(globalConfigPath, updatedContent, "utf-8");
6829
+ await fs20.writeFile(globalConfigPath, updatedContent, "utf-8");
6758
6830
  return {
6759
6831
  success: true,
6760
6832
  action: "updated",
@@ -6826,7 +6898,7 @@ var init_command_installer = __esm({
6826
6898
  async detectActiveProvider() {
6827
6899
  await this.ensureInit();
6828
6900
  try {
6829
- await fs19.access(this.claudeConfigPath);
6901
+ await fs20.access(this.claudeConfigPath);
6830
6902
  return true;
6831
6903
  } catch (error) {
6832
6904
  if (isNotFoundError(error)) {
@@ -6846,7 +6918,7 @@ var init_command_installer = __esm({
6846
6918
  */
6847
6919
  async getCommandFiles() {
6848
6920
  try {
6849
- const files = await fs19.readdir(this.templatesDir);
6921
+ const files = await fs20.readdir(this.templatesDir);
6850
6922
  return files.filter((f) => f.endsWith(".md"));
6851
6923
  } catch (_error) {
6852
6924
  return [
@@ -6887,7 +6959,7 @@ var init_command_installer = __esm({
6887
6959
  }
6888
6960
  try {
6889
6961
  await this.installRouter();
6890
- await fs19.mkdir(this.claudeCommandsPath, { recursive: true });
6962
+ await fs20.mkdir(this.claudeCommandsPath, { recursive: true });
6891
6963
  const commandFiles = await this.getCommandFiles();
6892
6964
  const installed = [];
6893
6965
  const errors = [];
@@ -6895,8 +6967,8 @@ var init_command_installer = __esm({
6895
6967
  try {
6896
6968
  const sourcePath = path19.join(this.templatesDir, file);
6897
6969
  const destPath = path19.join(this.claudeCommandsPath, file);
6898
- const content = await fs19.readFile(sourcePath, "utf-8");
6899
- await fs19.writeFile(destPath, content, "utf-8");
6970
+ const content = await fs20.readFile(sourcePath, "utf-8");
6971
+ await fs20.writeFile(destPath, content, "utf-8");
6900
6972
  installed.push(file.replace(".md", ""));
6901
6973
  } catch (error) {
6902
6974
  errors.push({ file, error: getErrorMessage2(error) });
@@ -6926,7 +6998,7 @@ var init_command_installer = __esm({
6926
6998
  for (const file of commandFiles) {
6927
6999
  try {
6928
7000
  const filePath = path19.join(this.claudeCommandsPath, file);
6929
- await fs19.unlink(filePath);
7001
+ await fs20.unlink(filePath);
6930
7002
  uninstalled.push(file.replace(".md", ""));
6931
7003
  } catch (error) {
6932
7004
  if (error.code !== "ENOENT") {
@@ -6935,7 +7007,7 @@ var init_command_installer = __esm({
6935
7007
  }
6936
7008
  }
6937
7009
  try {
6938
- await fs19.rmdir(this.claudeCommandsPath);
7010
+ await fs20.rmdir(this.claudeCommandsPath);
6939
7011
  } catch (_error) {
6940
7012
  }
6941
7013
  return {
@@ -6962,8 +7034,8 @@ var init_command_installer = __esm({
6962
7034
  };
6963
7035
  }
6964
7036
  try {
6965
- await fs19.access(this.claudeCommandsPath);
6966
- const files = await fs19.readdir(this.claudeCommandsPath);
7037
+ await fs20.access(this.claudeCommandsPath);
7038
+ const files = await fs20.readdir(this.claudeCommandsPath);
6967
7039
  const installedCommands = files.filter((f) => f.endsWith(".md")).map((f) => f.replace(".md", ""));
6968
7040
  return {
6969
7041
  installed: installedCommands.length > 0,
@@ -7012,7 +7084,7 @@ var init_command_installer = __esm({
7012
7084
  async verifyTemplate(commandName) {
7013
7085
  try {
7014
7086
  const templatePath = path19.join(this.templatesDir, `${commandName}.md`);
7015
- await fs19.access(templatePath);
7087
+ await fs20.access(templatePath);
7016
7088
  return true;
7017
7089
  } catch (error) {
7018
7090
  if (isNotFoundError(error)) {
@@ -7032,9 +7104,9 @@ var init_command_installer = __esm({
7032
7104
  try {
7033
7105
  const routerSource = path19.join(this.templatesDir, routerFile);
7034
7106
  const routerDest = path19.join(activeProvider.configDir, "commands", routerFile);
7035
- await fs19.mkdir(path19.dirname(routerDest), { recursive: true });
7036
- const content = await fs19.readFile(routerSource, "utf-8");
7037
- await fs19.writeFile(routerDest, content, "utf-8");
7107
+ await fs20.mkdir(path19.dirname(routerDest), { recursive: true });
7108
+ const content = await fs20.readFile(routerSource, "utf-8");
7109
+ await fs20.writeFile(routerDest, content, "utf-8");
7038
7110
  return true;
7039
7111
  } catch (error) {
7040
7112
  if (isNotFoundError(error)) {
@@ -7053,11 +7125,11 @@ var init_command_installer = __esm({
7053
7125
  const commandsRoot = path19.join(activeProvider.configDir, "commands");
7054
7126
  let removed = 0;
7055
7127
  try {
7056
- const files = await fs19.readdir(commandsRoot);
7128
+ const files = await fs20.readdir(commandsRoot);
7057
7129
  const legacyFiles = files.filter((f) => f.startsWith("p.") && f.endsWith(".md"));
7058
7130
  for (const file of legacyFiles) {
7059
7131
  try {
7060
- await fs19.unlink(path19.join(commandsRoot, file));
7132
+ await fs20.unlink(path19.join(commandsRoot, file));
7061
7133
  removed++;
7062
7134
  } catch {
7063
7135
  }
@@ -7082,11 +7154,11 @@ var init_command_installer = __esm({
7082
7154
  }
7083
7155
  try {
7084
7156
  await this.installRouter();
7085
- await fs19.mkdir(this.claudeCommandsPath, { recursive: true });
7157
+ await fs20.mkdir(this.claudeCommandsPath, { recursive: true });
7086
7158
  const templateFiles = await this.getCommandFiles();
7087
7159
  let installedFiles = [];
7088
7160
  try {
7089
- installedFiles = await fs19.readdir(this.claudeCommandsPath);
7161
+ installedFiles = await fs20.readdir(this.claudeCommandsPath);
7090
7162
  installedFiles = installedFiles.filter((f) => f.endsWith(".md"));
7091
7163
  } catch (error) {
7092
7164
  if (isNotFoundError(error)) {
@@ -7107,8 +7179,8 @@ var init_command_installer = __esm({
7107
7179
  const sourcePath = path19.join(this.templatesDir, file);
7108
7180
  const destPath = path19.join(this.claudeCommandsPath, file);
7109
7181
  const exists = installedFiles.includes(file);
7110
- const content = await fs19.readFile(sourcePath, "utf-8");
7111
- await fs19.writeFile(destPath, content, "utf-8");
7182
+ const content = await fs20.readFile(sourcePath, "utf-8");
7183
+ await fs20.writeFile(destPath, content, "utf-8");
7112
7184
  if (!exists) {
7113
7185
  results.added++;
7114
7186
  } else {
@@ -7492,7 +7564,7 @@ var init_chain_of_thought = __esm({
7492
7564
  });
7493
7565
 
7494
7566
  // core/agentic/context-builder.ts
7495
- import fs20 from "node:fs/promises";
7567
+ import fs21 from "node:fs/promises";
7496
7568
  var ContextBuilder, contextBuilder, context_builder_default;
7497
7569
  var init_context_builder = __esm({
7498
7570
  "core/agentic/context-builder.ts"() {
@@ -7571,7 +7643,7 @@ var init_context_builder = __esm({
7571
7643
  for (const [, filePath] of filteredEntries) {
7572
7644
  if (this._cache.has(filePath)) {
7573
7645
  try {
7574
- const stat = await fs20.stat(filePath);
7646
+ const stat = await fs21.stat(filePath);
7575
7647
  const cachedMtime = this._mtimes.get(filePath);
7576
7648
  if (!cachedMtime || stat.mtimeMs > cachedMtime) {
7577
7649
  this._cache.delete(filePath);
@@ -7599,8 +7671,8 @@ var init_context_builder = __esm({
7599
7671
  const readPromises = uncachedEntries.map(async ([key, filePath]) => {
7600
7672
  try {
7601
7673
  const [content, stat] = await Promise.all([
7602
- fs20.readFile(filePath, "utf-8"),
7603
- fs20.stat(filePath)
7674
+ fs21.readFile(filePath, "utf-8"),
7675
+ fs21.stat(filePath)
7604
7676
  ]);
7605
7677
  return { key, filePath, content, mtime: stat.mtimeMs };
7606
7678
  } catch (error) {
@@ -7674,7 +7746,7 @@ var init_context_builder = __esm({
7674
7746
  if (uncachedPaths.length > 0) {
7675
7747
  const readPromises = uncachedPaths.map(async (filePath) => {
7676
7748
  try {
7677
- const content = await fs20.readFile(filePath, "utf-8");
7749
+ const content = await fs21.readFile(filePath, "utf-8");
7678
7750
  return { filePath, content };
7679
7751
  } catch (error) {
7680
7752
  if (isNotFoundError(error)) {
@@ -7708,7 +7780,7 @@ var init_context_builder = __esm({
7708
7780
  */
7709
7781
  async fileExists(filePath) {
7710
7782
  try {
7711
- await fs20.access(filePath);
7783
+ await fs21.access(filePath);
7712
7784
  return true;
7713
7785
  } catch (error) {
7714
7786
  if (isNotFoundError(error)) {
@@ -7735,7 +7807,7 @@ var init_context_builder = __esm({
7735
7807
 
7736
7808
  // core/agentic/ground-truth.ts
7737
7809
  import { exec as exec6 } from "node:child_process";
7738
- import fs21 from "node:fs/promises";
7810
+ import fs22 from "node:fs/promises";
7739
7811
  import os7 from "node:os";
7740
7812
  import path20 from "node:path";
7741
7813
  import { promisify as promisify6 } from "node:util";
@@ -7774,7 +7846,7 @@ async function verifyDone(context2) {
7774
7846
  const actual = {};
7775
7847
  const nowPath = context2.paths.now;
7776
7848
  try {
7777
- const nowContent = await fs21.readFile(nowPath, "utf-8");
7849
+ const nowContent = await fs22.readFile(nowPath, "utf-8");
7778
7850
  actual.nowExists = true;
7779
7851
  actual.nowContent = nowContent.trim();
7780
7852
  actual.nowLength = nowContent.length;
@@ -7802,7 +7874,7 @@ async function verifyDone(context2) {
7802
7874
  }
7803
7875
  const nextPath = context2.paths.next;
7804
7876
  try {
7805
- const nextContent = await fs21.readFile(nextPath, "utf-8");
7877
+ const nextContent = await fs22.readFile(nextPath, "utf-8");
7806
7878
  actual.nextExists = true;
7807
7879
  const tasks = nextContent.match(/- \[ \]/g) || [];
7808
7880
  actual.pendingTasks = tasks.length;
@@ -7816,7 +7888,7 @@ async function verifyDone(context2) {
7816
7888
  }
7817
7889
  const metricsPath = context2.paths.metrics;
7818
7890
  try {
7819
- await fs21.access(path20.dirname(metricsPath), fs21.constants.W_OK);
7891
+ await fs22.access(path20.dirname(metricsPath), fs22.constants.W_OK);
7820
7892
  actual.metricsWritable = true;
7821
7893
  } catch (error) {
7822
7894
  if (isNotFoundError(error)) {
@@ -7852,7 +7924,7 @@ async function verifyShip(context2) {
7852
7924
  }
7853
7925
  const pkgPath = path20.join(context2.projectPath, "package.json");
7854
7926
  try {
7855
- const pkgContent = await fs21.readFile(pkgPath, "utf-8");
7927
+ const pkgContent = await fs22.readFile(pkgPath, "utf-8");
7856
7928
  const pkg = JSON.parse(pkgContent);
7857
7929
  actual.currentVersion = pkg.version;
7858
7930
  actual.hasPackageJson = true;
@@ -7868,7 +7940,7 @@ async function verifyShip(context2) {
7868
7940
  }
7869
7941
  const shippedPath = context2.paths.shipped;
7870
7942
  try {
7871
- const shippedContent = await fs21.readFile(shippedPath, "utf-8");
7943
+ const shippedContent = await fs22.readFile(shippedPath, "utf-8");
7872
7944
  actual.shippedExists = true;
7873
7945
  const featureName = context2.params.feature || context2.params.description;
7874
7946
  if (featureName) {
@@ -7888,7 +7960,7 @@ async function verifyShip(context2) {
7888
7960
  }
7889
7961
  if (actual.hasPackageJson) {
7890
7962
  try {
7891
- const pkgContent = await fs21.readFile(pkgPath, "utf-8");
7963
+ const pkgContent = await fs22.readFile(pkgPath, "utf-8");
7892
7964
  const pkg = JSON.parse(pkgContent);
7893
7965
  actual.hasTestScript = !!pkg.scripts?.test;
7894
7966
  } catch (error) {
@@ -7912,7 +7984,7 @@ async function verifyFeature(context2) {
7912
7984
  const actual = {};
7913
7985
  const nextPath = context2.paths.next;
7914
7986
  try {
7915
- const nextContent = await fs21.readFile(nextPath, "utf-8");
7987
+ const nextContent = await fs22.readFile(nextPath, "utf-8");
7916
7988
  actual.nextExists = true;
7917
7989
  const tasks = nextContent.match(/- \[[ x]\]/g) || [];
7918
7990
  actual.taskCount = tasks.length;
@@ -7931,7 +8003,7 @@ async function verifyFeature(context2) {
7931
8003
  }
7932
8004
  const roadmapPath = context2.paths.roadmap;
7933
8005
  try {
7934
- const roadmapContent = await fs21.readFile(roadmapPath, "utf-8");
8006
+ const roadmapContent = await fs22.readFile(roadmapPath, "utf-8");
7935
8007
  actual.roadmapExists = true;
7936
8008
  const featureName = context2.params.description || context2.params.feature;
7937
8009
  if (featureName) {
@@ -7950,7 +8022,7 @@ async function verifyFeature(context2) {
7950
8022
  }
7951
8023
  const nowPath = context2.paths.now;
7952
8024
  try {
7953
- const nowContent = await fs21.readFile(nowPath, "utf-8");
8025
+ const nowContent = await fs22.readFile(nowPath, "utf-8");
7954
8026
  actual.hasActiveTask = nowContent.trim().length > 0 && !nowContent.includes("No current task");
7955
8027
  if (actual.hasActiveTask) {
7956
8028
  recommendations.push("Consider completing current task first with /p:done");
@@ -7975,7 +8047,7 @@ async function verifyNow(context2) {
7975
8047
  const actual = {};
7976
8048
  const nowPath = context2.paths.now;
7977
8049
  try {
7978
- const nowContent = await fs21.readFile(nowPath, "utf-8");
8050
+ const nowContent = await fs22.readFile(nowPath, "utf-8");
7979
8051
  actual.nowExists = true;
7980
8052
  actual.nowContent = nowContent.trim();
7981
8053
  const hasRealTask = nowContent.trim().length > 0 && !nowContent.includes("No current task") && !nowContent.match(/^#\s*NOW\s*$/m);
@@ -7995,7 +8067,7 @@ async function verifyNow(context2) {
7995
8067
  }
7996
8068
  const nextPath = context2.paths.next;
7997
8069
  try {
7998
- const nextContent = await fs21.readFile(nextPath, "utf-8");
8070
+ const nextContent = await fs22.readFile(nextPath, "utf-8");
7999
8071
  const pendingTasks = (nextContent.match(/- \[ \]/g) || []).length;
8000
8072
  actual.pendingTasks = pendingTasks;
8001
8073
  if (!context2.params.task && pendingTasks > 0) {
@@ -8021,7 +8093,7 @@ async function verifyInit(context2) {
8021
8093
  const actual = {};
8022
8094
  const configPath = path20.join(context2.projectPath, ".prjct/prjct.config.json");
8023
8095
  try {
8024
- const configContent = await fs21.readFile(configPath, "utf-8");
8096
+ const configContent = await fs22.readFile(configPath, "utf-8");
8025
8097
  actual.alreadyInitialized = true;
8026
8098
  actual.existingConfig = JSON.parse(configContent);
8027
8099
  warnings.push("Project already initialized");
@@ -8038,12 +8110,12 @@ async function verifyInit(context2) {
8038
8110
  }
8039
8111
  const globalPath = path20.join(os7.homedir(), ".prjct-cli");
8040
8112
  try {
8041
- await fs21.access(globalPath, fs21.constants.W_OK);
8113
+ await fs22.access(globalPath, fs22.constants.W_OK);
8042
8114
  actual.globalPathWritable = true;
8043
8115
  } catch (error) {
8044
8116
  if (isNotFoundError(error)) {
8045
8117
  try {
8046
- await fs21.mkdir(globalPath, { recursive: true });
8118
+ await fs22.mkdir(globalPath, { recursive: true });
8047
8119
  actual.globalPathWritable = true;
8048
8120
  actual.globalPathCreated = true;
8049
8121
  } catch (_mkdirError) {
@@ -8070,7 +8142,7 @@ async function verifySync(context2) {
8070
8142
  const actual = {};
8071
8143
  const configPath = path20.join(context2.projectPath, ".prjct/prjct.config.json");
8072
8144
  try {
8073
- const configContent = await fs21.readFile(configPath, "utf-8");
8145
+ const configContent = await fs22.readFile(configPath, "utf-8");
8074
8146
  actual.hasConfig = true;
8075
8147
  actual.config = JSON.parse(configContent);
8076
8148
  } catch (error) {
@@ -8091,7 +8163,7 @@ async function verifySync(context2) {
8091
8163
  const projectId = actual.config?.projectId;
8092
8164
  const globalProjectPath = path20.join(os7.homedir(), ".prjct-cli/projects", projectId || "");
8093
8165
  try {
8094
- await fs21.access(globalProjectPath);
8166
+ await fs22.access(globalProjectPath);
8095
8167
  actual.globalStorageExists = true;
8096
8168
  } catch (error) {
8097
8169
  if (isNotFoundError(error)) {
@@ -8117,7 +8189,7 @@ async function verifyAnalyze(context2) {
8117
8189
  actual.detectedFiles = [];
8118
8190
  for (const file of files) {
8119
8191
  try {
8120
- await fs21.access(path20.join(context2.projectPath, file));
8192
+ await fs22.access(path20.join(context2.projectPath, file));
8121
8193
  actual.detectedFiles.push(file);
8122
8194
  } catch (error) {
8123
8195
  if (!isNotFoundError(error)) {
@@ -8133,7 +8205,7 @@ async function verifyAnalyze(context2) {
8133
8205
  actual.detectedSrcDirs = [];
8134
8206
  for (const dir of srcDirs) {
8135
8207
  try {
8136
- const stat = await fs21.stat(path20.join(context2.projectPath, dir));
8208
+ const stat = await fs22.stat(path20.join(context2.projectPath, dir));
8137
8209
  if (stat.isDirectory()) {
8138
8210
  ;
8139
8211
  actual.detectedSrcDirs.push(dir);
@@ -8158,9 +8230,9 @@ async function verifySpec(context2) {
8158
8230
  const actual = {};
8159
8231
  const specsPath = context2.paths.specs;
8160
8232
  try {
8161
- await fs21.access(specsPath);
8233
+ await fs22.access(specsPath);
8162
8234
  actual.specsExists = true;
8163
- const files = await fs21.readdir(specsPath);
8235
+ const files = await fs22.readdir(specsPath);
8164
8236
  actual.existingSpecs = files.filter((f) => f.endsWith(".md"));
8165
8237
  actual.specCount = actual.existingSpecs.length;
8166
8238
  } catch (error) {
@@ -9385,7 +9457,7 @@ var init_shipped = __esm({
9385
9457
  agent: z9.string().optional(),
9386
9458
  // "fe+be", "be", "fe"
9387
9459
  description: z9.string().optional(),
9388
- changes: z9.array(ShipChangeSchema),
9460
+ changes: z9.array(ShipChangeSchema).optional(),
9389
9461
  codeSnippets: z9.array(z9.string()).optional(),
9390
9462
  commit: CommitInfoSchema.optional(),
9391
9463
  codeMetrics: CodeMetricsSchema.optional(),
@@ -9398,7 +9470,7 @@ var init_shipped = __esm({
9398
9470
  featureId: z9.string().optional()
9399
9471
  });
9400
9472
  ShippedJsonSchema = z9.object({
9401
- items: z9.array(ShippedItemSchema),
9473
+ shipped: z9.array(ShippedItemSchema),
9402
9474
  lastUpdated: z9.string()
9403
9475
  });
9404
9476
  }
@@ -9592,7 +9664,7 @@ __export(jsonl_helper_exports, {
9592
9664
  writeJsonLines: () => writeJsonLines
9593
9665
  });
9594
9666
  import fsSync from "node:fs";
9595
- import fs22 from "node:fs/promises";
9667
+ import fs23 from "node:fs/promises";
9596
9668
  import path21 from "node:path";
9597
9669
  import readline from "node:readline";
9598
9670
  function parseJsonLines(content) {
@@ -9612,7 +9684,7 @@ function stringifyJsonLines(objects) {
9612
9684
  }
9613
9685
  async function readJsonLines(filePath) {
9614
9686
  try {
9615
- const content = await fs22.readFile(filePath, "utf-8");
9687
+ const content = await fs23.readFile(filePath, "utf-8");
9616
9688
  return parseJsonLines(content);
9617
9689
  } catch (error) {
9618
9690
  if (isNotFoundError(error)) {
@@ -9623,16 +9695,16 @@ async function readJsonLines(filePath) {
9623
9695
  }
9624
9696
  async function writeJsonLines(filePath, objects) {
9625
9697
  const content = stringifyJsonLines(objects);
9626
- await fs22.writeFile(filePath, content, "utf-8");
9698
+ await fs23.writeFile(filePath, content, "utf-8");
9627
9699
  }
9628
9700
  async function appendJsonLine(filePath, object) {
9629
9701
  const line = `${JSON.stringify(object)}
9630
9702
  `;
9631
- await fs22.appendFile(filePath, line, "utf-8");
9703
+ await fs23.appendFile(filePath, line, "utf-8");
9632
9704
  }
9633
9705
  async function appendJsonLines(filePath, objects) {
9634
9706
  const content = stringifyJsonLines(objects);
9635
- await fs22.appendFile(filePath, content, "utf-8");
9707
+ await fs23.appendFile(filePath, content, "utf-8");
9636
9708
  }
9637
9709
  async function filterJsonLines(filePath, predicate) {
9638
9710
  const entries = await readJsonLines(filePath);
@@ -9640,7 +9712,7 @@ async function filterJsonLines(filePath, predicate) {
9640
9712
  }
9641
9713
  async function countJsonLines(filePath) {
9642
9714
  try {
9643
- const content = await fs22.readFile(filePath, "utf-8");
9715
+ const content = await fs23.readFile(filePath, "utf-8");
9644
9716
  const lines = content.split("\n").filter((line) => line.trim());
9645
9717
  return lines.length;
9646
9718
  } catch (error) {
@@ -9699,7 +9771,7 @@ async function readJsonLinesStreaming(filePath, maxLines = STORAGE_LIMITS.JSONL_
9699
9771
  }
9700
9772
  async function getFileSizeMB(filePath) {
9701
9773
  try {
9702
- const stats = await fs22.stat(filePath);
9774
+ const stats = await fs23.stat(filePath);
9703
9775
  return stats.size / (1024 * 1024);
9704
9776
  } catch (error) {
9705
9777
  if (isNotFoundError(error)) {
@@ -9718,7 +9790,7 @@ async function rotateJsonLinesIfNeeded(filePath, maxSizeMB = STORAGE_LIMITS.ROTA
9718
9790
  const ext = path21.extname(filePath);
9719
9791
  const base = path21.basename(filePath, ext);
9720
9792
  const archivePath = path21.join(dir, `${base}-${timestamp}${ext}`);
9721
- await fs22.rename(filePath, archivePath);
9793
+ await fs23.rename(filePath, archivePath);
9722
9794
  console.log(
9723
9795
  `\u{1F4E6} Rotated ${path21.basename(filePath)} (${sizeMB.toFixed(1)}MB) \u2192 ${path21.basename(archivePath)}`
9724
9796
  );
@@ -9798,7 +9870,7 @@ var init_memory = __esm({
9798
9870
  });
9799
9871
 
9800
9872
  // core/agentic/memory-system.ts
9801
- import fs23 from "node:fs/promises";
9873
+ import fs24 from "node:fs/promises";
9802
9874
  import path22 from "node:path";
9803
9875
  var CachedStore, SessionStore, HistoryStore, PatternStore, SemanticMemories, MemorySystem, memorySystem, memory_system_default;
9804
9876
  var init_memory_system = __esm({
@@ -9865,7 +9937,7 @@ var init_memory_system = __esm({
9865
9937
  }
9866
9938
  const filePath = this.getPath(projectId);
9867
9939
  try {
9868
- const content = await fs23.readFile(filePath, "utf-8");
9940
+ const content = await fs24.readFile(filePath, "utf-8");
9869
9941
  this._data = JSON.parse(content);
9870
9942
  this.afterLoad(this._data);
9871
9943
  } catch (error) {
@@ -9901,8 +9973,8 @@ var init_memory_system = __esm({
9901
9973
  async save(projectId) {
9902
9974
  if (!this._data) return;
9903
9975
  const filePath = this.getPath(projectId);
9904
- await fs23.mkdir(path22.dirname(filePath), { recursive: true });
9905
- await fs23.writeFile(filePath, JSON.stringify(this._data, null, 2), "utf-8");
9976
+ await fs24.mkdir(path22.dirname(filePath), { recursive: true });
9977
+ await fs24.writeFile(filePath, JSON.stringify(this._data, null, 2), "utf-8");
9906
9978
  }
9907
9979
  /**
9908
9980
  * Access the cached data without triggering a disk read.
@@ -10691,6 +10763,7 @@ var init_ideas_storage = __esm({
10691
10763
  "core/storage/ideas-storage.ts"() {
10692
10764
  "use strict";
10693
10765
  init_schemas2();
10766
+ init_ideas();
10694
10767
  init_date_helper();
10695
10768
  init_storage_manager();
10696
10769
  IdeasStorage = class extends StorageManager {
@@ -10698,7 +10771,7 @@ var init_ideas_storage = __esm({
10698
10771
  __name(this, "IdeasStorage");
10699
10772
  }
10700
10773
  constructor() {
10701
- super("ideas.json");
10774
+ super("ideas.json", IdeasJsonSchema);
10702
10775
  }
10703
10776
  getDefault() {
10704
10777
  return {
@@ -10891,7 +10964,7 @@ var init_ideas_storage = __esm({
10891
10964
 
10892
10965
  // core/storage/index-storage.ts
10893
10966
  import crypto4 from "node:crypto";
10894
- import fs24 from "node:fs/promises";
10967
+ import fs25 from "node:fs/promises";
10895
10968
  import path23 from "node:path";
10896
10969
  function getDefaultChecksums() {
10897
10970
  return {
@@ -10924,7 +10997,7 @@ var init_index_storage = __esm({
10924
10997
  */
10925
10998
  async ensureIndexDir(projectId) {
10926
10999
  const indexPath = this.getIndexPath(projectId);
10927
- await fs24.mkdir(indexPath, { recursive: true });
11000
+ await fs25.mkdir(indexPath, { recursive: true });
10928
11001
  return indexPath;
10929
11002
  }
10930
11003
  // ==========================================================================
@@ -10936,7 +11009,7 @@ var init_index_storage = __esm({
10936
11009
  async readIndex(projectId) {
10937
11010
  const filePath = path23.join(this.getIndexPath(projectId), "project-index.json");
10938
11011
  try {
10939
- const content = await fs24.readFile(filePath, "utf-8");
11012
+ const content = await fs25.readFile(filePath, "utf-8");
10940
11013
  const index = JSON.parse(content);
10941
11014
  if (index.version !== INDEX_VERSION) {
10942
11015
  return null;
@@ -10955,7 +11028,7 @@ var init_index_storage = __esm({
10955
11028
  async writeIndex(projectId, index) {
10956
11029
  await this.ensureIndexDir(projectId);
10957
11030
  const filePath = path23.join(this.getIndexPath(projectId), "project-index.json");
10958
- await fs24.writeFile(filePath, JSON.stringify(index, null, 2), "utf-8");
11031
+ await fs25.writeFile(filePath, JSON.stringify(index, null, 2), "utf-8");
10959
11032
  }
10960
11033
  /**
10961
11034
  * Check if index exists and is valid
@@ -10973,7 +11046,7 @@ var init_index_storage = __esm({
10973
11046
  async readChecksums(projectId) {
10974
11047
  const filePath = path23.join(this.getIndexPath(projectId), "checksums.json");
10975
11048
  try {
10976
- const content = await fs24.readFile(filePath, "utf-8");
11049
+ const content = await fs25.readFile(filePath, "utf-8");
10977
11050
  return JSON.parse(content);
10978
11051
  } catch (error) {
10979
11052
  if (isNotFoundError(error)) {
@@ -10988,14 +11061,14 @@ var init_index_storage = __esm({
10988
11061
  async writeChecksums(projectId, checksums) {
10989
11062
  await this.ensureIndexDir(projectId);
10990
11063
  const filePath = path23.join(this.getIndexPath(projectId), "checksums.json");
10991
- await fs24.writeFile(filePath, JSON.stringify(checksums, null, 2), "utf-8");
11064
+ await fs25.writeFile(filePath, JSON.stringify(checksums, null, 2), "utf-8");
10992
11065
  }
10993
11066
  /**
10994
11067
  * Calculate checksum for a file
10995
11068
  */
10996
11069
  async calculateChecksum(filePath) {
10997
11070
  try {
10998
- const content = await fs24.readFile(filePath);
11071
+ const content = await fs25.readFile(filePath);
10999
11072
  return crypto4.createHash("md5").update(content).digest("hex");
11000
11073
  } catch {
11001
11074
  return "";
@@ -11033,7 +11106,7 @@ var init_index_storage = __esm({
11033
11106
  async readScores(projectId) {
11034
11107
  const filePath = path23.join(this.getIndexPath(projectId), "file-scores.json");
11035
11108
  try {
11036
- const content = await fs24.readFile(filePath, "utf-8");
11109
+ const content = await fs25.readFile(filePath, "utf-8");
11037
11110
  const data = JSON.parse(content);
11038
11111
  return data.scores || [];
11039
11112
  } catch (error) {
@@ -11054,7 +11127,7 @@ var init_index_storage = __esm({
11054
11127
  lastUpdated: getTimestamp(),
11055
11128
  scores
11056
11129
  };
11057
- await fs24.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
11130
+ await fs25.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
11058
11131
  }
11059
11132
  // ==========================================================================
11060
11133
  // UTILITY METHODS
@@ -11065,8 +11138,8 @@ var init_index_storage = __esm({
11065
11138
  async clearIndex(projectId) {
11066
11139
  const indexPath = this.getIndexPath(projectId);
11067
11140
  try {
11068
- const files = await fs24.readdir(indexPath);
11069
- await Promise.all(files.map((file) => fs24.unlink(path23.join(indexPath, file))));
11141
+ const files = await fs25.readdir(indexPath);
11142
+ await Promise.all(files.map((file) => fs25.unlink(path23.join(indexPath, file))));
11070
11143
  } catch (error) {
11071
11144
  if (!isNotFoundError(error)) {
11072
11145
  throw error;
@@ -11094,7 +11167,7 @@ var init_index_storage = __esm({
11094
11167
  async readDomains(projectId) {
11095
11168
  const filePath = path23.join(this.getIndexPath(projectId), "domains.json");
11096
11169
  try {
11097
- const content = await fs24.readFile(filePath, "utf-8");
11170
+ const content = await fs25.readFile(filePath, "utf-8");
11098
11171
  const domains = JSON.parse(content);
11099
11172
  if (domains.version !== INDEX_VERSION) {
11100
11173
  return null;
@@ -11113,7 +11186,7 @@ var init_index_storage = __esm({
11113
11186
  async writeDomains(projectId, domains) {
11114
11187
  await this.ensureIndexDir(projectId);
11115
11188
  const filePath = path23.join(this.getIndexPath(projectId), "domains.json");
11116
- await fs24.writeFile(filePath, JSON.stringify(domains, null, 2), "utf-8");
11189
+ await fs25.writeFile(filePath, JSON.stringify(domains, null, 2), "utf-8");
11117
11190
  }
11118
11191
  // ==========================================================================
11119
11192
  // CATEGORIES CACHE
@@ -11124,7 +11197,7 @@ var init_index_storage = __esm({
11124
11197
  async readCategories(projectId) {
11125
11198
  const filePath = path23.join(this.getIndexPath(projectId), "categories-cache.json");
11126
11199
  try {
11127
- const content = await fs24.readFile(filePath, "utf-8");
11200
+ const content = await fs25.readFile(filePath, "utf-8");
11128
11201
  const cache2 = JSON.parse(content);
11129
11202
  if (cache2.version !== INDEX_VERSION) {
11130
11203
  return null;
@@ -11143,7 +11216,7 @@ var init_index_storage = __esm({
11143
11216
  async writeCategories(projectId, cache2) {
11144
11217
  await this.ensureIndexDir(projectId);
11145
11218
  const filePath = path23.join(this.getIndexPath(projectId), "categories-cache.json");
11146
- await fs24.writeFile(filePath, JSON.stringify(cache2, null, 2), "utf-8");
11219
+ await fs25.writeFile(filePath, JSON.stringify(cache2, null, 2), "utf-8");
11147
11220
  }
11148
11221
  /**
11149
11222
  * Get file categories for specific paths
@@ -11183,6 +11256,7 @@ var init_queue_storage = __esm({
11183
11256
  "core/storage/queue-storage.ts"() {
11184
11257
  "use strict";
11185
11258
  init_schemas2();
11259
+ init_state();
11186
11260
  init_date_helper();
11187
11261
  init_storage_manager();
11188
11262
  QueueStorage = class extends StorageManager {
@@ -11190,7 +11264,7 @@ var init_queue_storage = __esm({
11190
11264
  __name(this, "QueueStorage");
11191
11265
  }
11192
11266
  constructor() {
11193
- super("queue.json");
11267
+ super("queue.json", QueueJsonSchema);
11194
11268
  }
11195
11269
  getDefault() {
11196
11270
  return {
@@ -11423,6 +11497,7 @@ var init_shipped_storage = __esm({
11423
11497
  "core/storage/shipped-storage.ts"() {
11424
11498
  "use strict";
11425
11499
  init_schemas2();
11500
+ init_shipped();
11426
11501
  init_date_helper();
11427
11502
  init_storage_manager();
11428
11503
  ShippedStorage = class extends StorageManager {
@@ -11430,7 +11505,7 @@ var init_shipped_storage = __esm({
11430
11505
  __name(this, "ShippedStorage");
11431
11506
  }
11432
11507
  constructor() {
11433
- super("shipped.json");
11508
+ super("shipped.json", ShippedJsonSchema);
11434
11509
  }
11435
11510
  getDefault() {
11436
11511
  return {
@@ -11823,6 +11898,7 @@ var init_state_storage = __esm({
11823
11898
  "core/storage/state-storage.ts"() {
11824
11899
  "use strict";
11825
11900
  init_schemas2();
11901
+ init_state();
11826
11902
  init_date_helper();
11827
11903
  init_markdown_builder();
11828
11904
  init_storage_manager();
@@ -11831,7 +11907,7 @@ var init_state_storage = __esm({
11831
11907
  __name(this, "StateStorage");
11832
11908
  }
11833
11909
  constructor() {
11834
- super("state.json");
11910
+ super("state.json", StateJsonSchema);
11835
11911
  }
11836
11912
  getDefault() {
11837
11913
  return {
@@ -12200,7 +12276,7 @@ var init_state_storage = __esm({
12200
12276
  });
12201
12277
 
12202
12278
  // core/storage/storage.ts
12203
- import fs25 from "node:fs/promises";
12279
+ import fs26 from "node:fs/promises";
12204
12280
  import os8 from "node:os";
12205
12281
  import path24 from "node:path";
12206
12282
  function getStorage(projectId) {
@@ -12238,8 +12314,8 @@ var init_storage = __esm({
12238
12314
  }
12239
12315
  async write(pathArray, data) {
12240
12316
  const filePath = this.pathToFile(pathArray);
12241
- await fs25.mkdir(path24.dirname(filePath), { recursive: true });
12242
- await fs25.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
12317
+ await fs26.mkdir(path24.dirname(filePath), { recursive: true });
12318
+ await fs26.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
12243
12319
  eventBus.publish({
12244
12320
  type: inferEventType(pathArray, "write"),
12245
12321
  path: pathArray,
@@ -12254,7 +12330,7 @@ var init_storage = __esm({
12254
12330
  async read(pathArray) {
12255
12331
  const filePath = this.pathToFile(pathArray);
12256
12332
  try {
12257
- const content = await fs25.readFile(filePath, "utf-8");
12333
+ const content = await fs26.readFile(filePath, "utf-8");
12258
12334
  return JSON.parse(content);
12259
12335
  } catch (error) {
12260
12336
  if (isNotFoundError(error) || error instanceof SyntaxError) {
@@ -12266,7 +12342,7 @@ var init_storage = __esm({
12266
12342
  async list(prefix) {
12267
12343
  const dir = path24.join(this.basePath, `${prefix[0]}s`);
12268
12344
  try {
12269
- const files = await fs25.readdir(dir);
12345
+ const files = await fs26.readdir(dir);
12270
12346
  return files.filter((f) => f.endsWith(".json") && f !== "index.json").map((f) => [...prefix, f.replace(".json", "")]);
12271
12347
  } catch (error) {
12272
12348
  if (isNotFoundError(error)) {
@@ -12278,7 +12354,7 @@ var init_storage = __esm({
12278
12354
  async delete(pathArray) {
12279
12355
  const filePath = this.pathToFile(pathArray);
12280
12356
  try {
12281
- await fs25.unlink(filePath);
12357
+ await fs26.unlink(filePath);
12282
12358
  eventBus.publish({
12283
12359
  type: inferEventType(pathArray, "delete"),
12284
12360
  path: pathArray,
@@ -12298,7 +12374,7 @@ var init_storage = __esm({
12298
12374
  async exists(pathArray) {
12299
12375
  const filePath = this.pathToFile(pathArray);
12300
12376
  try {
12301
- await fs25.access(filePath);
12377
+ await fs26.access(filePath);
12302
12378
  return true;
12303
12379
  } catch (error) {
12304
12380
  if (isNotFoundError(error)) {
@@ -12314,7 +12390,7 @@ var init_storage = __esm({
12314
12390
  const indexPath = path24.join(this.basePath, `${collection}s`, "index.json");
12315
12391
  let index = { ids: [], updatedAt: "" };
12316
12392
  try {
12317
- const content = await fs25.readFile(indexPath, "utf-8");
12393
+ const content = await fs26.readFile(indexPath, "utf-8");
12318
12394
  index = JSON.parse(content);
12319
12395
  } catch (error) {
12320
12396
  if (!isNotFoundError(error) && !(error instanceof SyntaxError)) {
@@ -12327,8 +12403,8 @@ var init_storage = __esm({
12327
12403
  index.ids = index.ids.filter((i) => i !== id);
12328
12404
  }
12329
12405
  index.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
12330
- await fs25.mkdir(path24.dirname(indexPath), { recursive: true });
12331
- await fs25.writeFile(indexPath, JSON.stringify(index, null, 2), "utf-8");
12406
+ await fs26.mkdir(path24.dirname(indexPath), { recursive: true });
12407
+ await fs26.writeFile(indexPath, JSON.stringify(index, null, 2), "utf-8");
12332
12408
  }
12333
12409
  };
12334
12410
  __name(getStorage, "getStorage");
@@ -12351,7 +12427,7 @@ var init_storage2 = __esm({
12351
12427
  });
12352
12428
 
12353
12429
  // core/agentic/template-loader.ts
12354
- import fs26 from "node:fs/promises";
12430
+ import fs27 from "node:fs/promises";
12355
12431
  import path25 from "node:path";
12356
12432
  function updateLruOrder(key) {
12357
12433
  const index = cacheOrder.indexOf(key);
@@ -12392,7 +12468,7 @@ async function load(commandName) {
12392
12468
  }
12393
12469
  const templatePath = path25.join(TEMPLATES_DIR, `${commandName}.md`);
12394
12470
  try {
12395
- const rawContent = await fs26.readFile(templatePath, "utf-8");
12471
+ const rawContent = await fs27.readFile(templatePath, "utf-8");
12396
12472
  const parsed = parseFrontmatter(rawContent);
12397
12473
  evictLru();
12398
12474
  cache.set(commandName, parsed);
@@ -12432,7 +12508,7 @@ var init_template_loader = __esm({
12432
12508
 
12433
12509
  // core/agentic/orchestrator-executor.ts
12434
12510
  import { exec as execCallback5 } from "node:child_process";
12435
- import fs27 from "node:fs/promises";
12511
+ import fs28 from "node:fs/promises";
12436
12512
  import os9 from "node:os";
12437
12513
  import path26 from "node:path";
12438
12514
  import { promisify as promisify7 } from "node:util";
@@ -12703,7 +12779,7 @@ var init_orchestrator_executor = __esm({
12703
12779
  async loadRepoAnalysis(globalPath) {
12704
12780
  try {
12705
12781
  const analysisPath = path26.join(globalPath, "analysis", "repo-analysis.json");
12706
- const content = await fs27.readFile(analysisPath, "utf-8");
12782
+ const content = await fs28.readFile(analysisPath, "utf-8");
12707
12783
  return JSON.parse(content);
12708
12784
  } catch (error) {
12709
12785
  if (isNotFoundError(error)) return null;
@@ -12768,7 +12844,7 @@ var init_orchestrator_executor = __esm({
12768
12844
  async getAvailableAgentNames(globalPath) {
12769
12845
  try {
12770
12846
  const agentsDir = path26.join(globalPath, "agents");
12771
- const files = await fs27.readdir(agentsDir);
12847
+ const files = await fs28.readdir(agentsDir);
12772
12848
  return files.filter((f) => f.endsWith(".md")).map((f) => f.replace(".md", ""));
12773
12849
  } catch {
12774
12850
  return [];
@@ -12790,7 +12866,7 @@ var init_orchestrator_executor = __esm({
12790
12866
  for (const fileName of possibleNames) {
12791
12867
  const filePath = path26.join(agentsDir, fileName);
12792
12868
  try {
12793
- const content = await fs27.readFile(filePath, "utf-8");
12869
+ const content = await fs28.readFile(filePath, "utf-8");
12794
12870
  const { frontmatter, body } = this.parseAgentFile(content);
12795
12871
  return {
12796
12872
  name: fileName.replace(".md", ""),
@@ -12845,11 +12921,11 @@ var init_orchestrator_executor = __esm({
12845
12921
  const flatPath = path26.join(skillsDir, `${skillName}.md`);
12846
12922
  const subdirPath = path26.join(skillsDir, skillName, "SKILL.md");
12847
12923
  try {
12848
- const content = await fs27.readFile(subdirPath, "utf-8");
12924
+ const content = await fs28.readFile(subdirPath, "utf-8");
12849
12925
  return { name: skillName, content, filePath: subdirPath };
12850
12926
  } catch {
12851
12927
  try {
12852
- const content = await fs27.readFile(flatPath, "utf-8");
12928
+ const content = await fs28.readFile(flatPath, "utf-8");
12853
12929
  return { name: skillName, content, filePath: flatPath };
12854
12930
  } catch {
12855
12931
  const agentNames = skillToAgents.get(skillName) || [];
@@ -13772,7 +13848,7 @@ var init_outcomes2 = __esm({
13772
13848
  });
13773
13849
 
13774
13850
  // core/agentic/prompt-builder.ts
13775
- import fs28 from "node:fs/promises";
13851
+ import fs29 from "node:fs/promises";
13776
13852
  import path28 from "node:path";
13777
13853
  var PromptBuilder, promptBuilder, prompt_builder_default;
13778
13854
  var init_prompt_builder = __esm({
@@ -13811,7 +13887,7 @@ var init_prompt_builder = __esm({
13811
13887
  }
13812
13888
  try {
13813
13889
  if (await fileExists(templatePath)) {
13814
- const content = await fs28.readFile(templatePath, "utf-8");
13890
+ const content = await fs29.readFile(templatePath, "utf-8");
13815
13891
  this._templateCache.set(templatePath, { content, loadedAt: now });
13816
13892
  return content;
13817
13893
  }
@@ -13882,7 +13958,7 @@ var init_prompt_builder = __esm({
13882
13958
  const checklists = {};
13883
13959
  try {
13884
13960
  if (await fileExists(checklistsDir)) {
13885
- const files = (await fs28.readdir(checklistsDir)).filter((f) => f.endsWith(".md"));
13961
+ const files = (await fs29.readdir(checklistsDir)).filter((f) => f.endsWith(".md"));
13886
13962
  for (const file of files) {
13887
13963
  const name = file.replace(".md", "");
13888
13964
  const templatePath = path28.join(checklistsDir, file);
@@ -14442,7 +14518,7 @@ Context: ${fileCount} files available. Read what you need.
14442
14518
  });
14443
14519
 
14444
14520
  // core/agentic/template-executor.ts
14445
- import fs29 from "node:fs/promises";
14521
+ import fs30 from "node:fs/promises";
14446
14522
  import path29 from "node:path";
14447
14523
  var ORCHESTRATED_COMMANDS, SIMPLE_COMMANDS, TemplateExecutor, templateExecutor, template_executor_default;
14448
14524
  var init_template_executor = __esm({
@@ -14521,7 +14597,7 @@ var init_template_executor = __esm({
14521
14597
  try {
14522
14598
  const projectId = await this.getProjectId(projectPath);
14523
14599
  const agentsDir = path29.join(path_manager_default.getGlobalProjectPath(projectId), "agents");
14524
- const files = await fs29.readdir(agentsDir);
14600
+ const files = await fs30.readdir(agentsDir);
14525
14601
  return files.some((f) => f.endsWith(".md"));
14526
14602
  } catch (error) {
14527
14603
  if (isNotFoundError(error)) return false;
@@ -14535,7 +14611,7 @@ var init_template_executor = __esm({
14535
14611
  try {
14536
14612
  const projectId = await this.getProjectId(projectPath);
14537
14613
  const agentsDir = path29.join(path_manager_default.getGlobalProjectPath(projectId), "agents");
14538
- const files = await fs29.readdir(agentsDir);
14614
+ const files = await fs30.readdir(agentsDir);
14539
14615
  return files.filter((f) => f.endsWith(".md")).map((f) => f.replace(".md", ""));
14540
14616
  } catch {
14541
14617
  return [];
@@ -14644,7 +14720,7 @@ When fragmenting tasks:
14644
14720
 
14645
14721
  // core/agentic/tool-registry.ts
14646
14722
  import { exec as exec7 } from "node:child_process";
14647
- import fs30 from "node:fs/promises";
14723
+ import fs31 from "node:fs/promises";
14648
14724
  import { promisify as promisify8 } from "node:util";
14649
14725
  var execAsync4, toolRegistry, tool_registry_default;
14650
14726
  var init_tool_registry = __esm({
@@ -14688,14 +14764,14 @@ var init_tool_registry = __esm({
14688
14764
  };
14689
14765
  toolRegistry.register("Read", async (filePath) => {
14690
14766
  try {
14691
- return await fs30.readFile(filePath, "utf-8");
14767
+ return await fs31.readFile(filePath, "utf-8");
14692
14768
  } catch (_error) {
14693
14769
  return null;
14694
14770
  }
14695
14771
  });
14696
14772
  toolRegistry.register("Write", async (filePath, content) => {
14697
14773
  try {
14698
- await fs30.writeFile(filePath, content, "utf-8");
14774
+ await fs31.writeFile(filePath, content, "utf-8");
14699
14775
  return true;
14700
14776
  } catch (_error) {
14701
14777
  return false;
@@ -14730,23 +14806,23 @@ var init_tool_registry = __esm({
14730
14806
  });
14731
14807
 
14732
14808
  // core/agentic/command-executor.ts
14733
- import fs31 from "node:fs/promises";
14809
+ import fs32 from "node:fs/promises";
14734
14810
  import os10 from "node:os";
14735
14811
  import path30 from "node:path";
14736
14812
  async function signalStart(commandName) {
14737
14813
  try {
14738
14814
  const dir = path30.dirname(RUNNING_FILE);
14739
14815
  if (!await fileExists(dir)) {
14740
- await fs31.mkdir(dir, { recursive: true });
14816
+ await fs32.mkdir(dir, { recursive: true });
14741
14817
  }
14742
- await fs31.writeFile(RUNNING_FILE, `/p:${commandName}`);
14818
+ await fs32.writeFile(RUNNING_FILE, `/p:${commandName}`);
14743
14819
  } catch (_error) {
14744
14820
  }
14745
14821
  }
14746
14822
  async function signalEnd() {
14747
14823
  try {
14748
14824
  if (await fileExists(RUNNING_FILE)) {
14749
- await fs31.unlink(RUNNING_FILE);
14825
+ await fs32.unlink(RUNNING_FILE);
14750
14826
  }
14751
14827
  } catch (_error) {
14752
14828
  }
@@ -15079,7 +15155,7 @@ var init_command_executor = __esm({
15079
15155
  });
15080
15156
 
15081
15157
  // core/infrastructure/update-checker.ts
15082
- import fs32 from "node:fs/promises";
15158
+ import fs33 from "node:fs/promises";
15083
15159
  import https from "node:https";
15084
15160
  import os11 from "node:os";
15085
15161
  import path31 from "node:path";
@@ -15110,7 +15186,7 @@ var init_update_checker = __esm({
15110
15186
  async getCurrentVersion() {
15111
15187
  try {
15112
15188
  const packageJsonPath = path31.join(__dirname, "..", "..", "package.json");
15113
- const packageJson = JSON.parse(await fs32.readFile(packageJsonPath, "utf8"));
15189
+ const packageJson = JSON.parse(await fs33.readFile(packageJsonPath, "utf8"));
15114
15190
  return packageJson.version;
15115
15191
  } catch (error) {
15116
15192
  console.error("Error reading package version:", getErrorMessage2(error));
@@ -15180,7 +15256,7 @@ var init_update_checker = __esm({
15180
15256
  async readCache() {
15181
15257
  try {
15182
15258
  if (await fileExists(this.cacheFile)) {
15183
- const cache2 = JSON.parse(await fs32.readFile(this.cacheFile, "utf8"));
15259
+ const cache2 = JSON.parse(await fs33.readFile(this.cacheFile, "utf8"));
15184
15260
  return cache2;
15185
15261
  }
15186
15262
  } catch (_error) {
@@ -15193,9 +15269,9 @@ var init_update_checker = __esm({
15193
15269
  async writeCache(data) {
15194
15270
  try {
15195
15271
  if (!await fileExists(this.cacheDir)) {
15196
- await fs32.mkdir(this.cacheDir, { recursive: true });
15272
+ await fs33.mkdir(this.cacheDir, { recursive: true });
15197
15273
  }
15198
- await fs32.writeFile(this.cacheFile, JSON.stringify(data, null, 2), "utf8");
15274
+ await fs33.writeFile(this.cacheFile, JSON.stringify(data, null, 2), "utf8");
15199
15275
  } catch (_error) {
15200
15276
  }
15201
15277
  }
@@ -15353,7 +15429,7 @@ var init_agent_generator = __esm({
15353
15429
  });
15354
15430
 
15355
15431
  // core/agentic/agent-router.ts
15356
- import fs33 from "node:fs/promises";
15432
+ import fs34 from "node:fs/promises";
15357
15433
  import path32 from "node:path";
15358
15434
  var AgentRouter, agent_router_default;
15359
15435
  var init_agent_router = __esm({
@@ -15383,12 +15459,12 @@ var init_agent_router = __esm({
15383
15459
  async loadAvailableAgents() {
15384
15460
  if (!this.agentsPath) return [];
15385
15461
  try {
15386
- const files = await fs33.readdir(this.agentsPath);
15462
+ const files = await fs34.readdir(this.agentsPath);
15387
15463
  const agents = [];
15388
15464
  for (const file of files) {
15389
15465
  if (file.endsWith(".md")) {
15390
15466
  const name = file.replace(".md", "");
15391
- const content = await fs33.readFile(path32.join(this.agentsPath, file), "utf-8");
15467
+ const content = await fs34.readFile(path32.join(this.agentsPath, file), "utf-8");
15392
15468
  agents.push({ name, content });
15393
15469
  }
15394
15470
  }
@@ -15414,7 +15490,7 @@ var init_agent_router = __esm({
15414
15490
  if (!this.agentsPath) return null;
15415
15491
  try {
15416
15492
  const filePath = path32.join(this.agentsPath, `${name}.md`);
15417
- const content = await fs33.readFile(filePath, "utf-8");
15493
+ const content = await fs34.readFile(filePath, "utf-8");
15418
15494
  return { name, content };
15419
15495
  } catch (error) {
15420
15496
  if (!isNotFoundError(error)) {
@@ -15456,7 +15532,7 @@ var init_agent_router = __esm({
15456
15532
  projectId: this.projectId
15457
15533
  })}
15458
15534
  `;
15459
- await fs33.appendFile(logPath, entry);
15535
+ await fs34.appendFile(logPath, entry);
15460
15536
  } catch (error) {
15461
15537
  if (!isNotFoundError(error)) {
15462
15538
  console.error(`Agent usage log error: ${getErrorMessage2(error)}`);
@@ -16935,7 +17011,7 @@ var init_memory_service = __esm({
16935
17011
  });
16936
17012
 
16937
17013
  // core/services/nested-context-resolver.ts
16938
- import fs34 from "node:fs/promises";
17014
+ import fs35 from "node:fs/promises";
16939
17015
  import path36 from "node:path";
16940
17016
  var NestedContextResolver;
16941
17017
  var init_nested_context_resolver = __esm({
@@ -16989,7 +17065,7 @@ var init_nested_context_resolver = __esm({
16989
17065
  * Load a single PRJCT.md file into a NestedContext
16990
17066
  */
16991
17067
  async loadContext(filePath, parent, pkg = null) {
16992
- const content = await fs34.readFile(filePath, "utf-8");
17068
+ const content = await fs35.readFile(filePath, "utf-8");
16993
17069
  const relativePath = path36.relative(this.rootPath, filePath);
16994
17070
  const depth = relativePath.split(path36.sep).length - 1;
16995
17071
  return {
@@ -17045,7 +17121,7 @@ var init_nested_context_resolver = __esm({
17045
17121
  const scan = /* @__PURE__ */ __name(async (currentDir, depth) => {
17046
17122
  if (depth > 5) return;
17047
17123
  try {
17048
- const entries = await fs34.readdir(currentDir, { withFileTypes: true });
17124
+ const entries = await fs35.readdir(currentDir, { withFileTypes: true });
17049
17125
  for (const entry of entries) {
17050
17126
  if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "coverage") {
17051
17127
  continue;
@@ -17212,7 +17288,7 @@ ${content}`);
17212
17288
  * Load a single AGENTS.md file into a NestedAgents structure
17213
17289
  */
17214
17290
  async loadAgents(filePath, parent, pkg = null) {
17215
- const content = await fs34.readFile(filePath, "utf-8");
17291
+ const content = await fs35.readFile(filePath, "utf-8");
17216
17292
  const relativePath = path36.relative(this.rootPath, filePath);
17217
17293
  const depth = relativePath.split(path36.sep).length - 1;
17218
17294
  return {
@@ -17347,7 +17423,7 @@ ${content}`);
17347
17423
  const scan = /* @__PURE__ */ __name(async (currentDir, depth) => {
17348
17424
  if (depth > 5) return;
17349
17425
  try {
17350
- const entries = await fs34.readdir(currentDir, { withFileTypes: true });
17426
+ const entries = await fs35.readdir(currentDir, { withFileTypes: true });
17351
17427
  for (const entry of entries) {
17352
17428
  if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "coverage") {
17353
17429
  continue;
@@ -17980,16 +18056,16 @@ var init_onboarding = __esm({
17980
18056
  * Detect project type from file system
17981
18057
  */
17982
18058
  async detectProjectType() {
17983
- const fs52 = await import("node:fs/promises");
18059
+ const fs53 = await import("node:fs/promises");
17984
18060
  const path65 = await import("node:path");
17985
18061
  try {
17986
- const files = await fs52.readdir(this.projectPath);
18062
+ const files = await fs53.readdir(this.projectPath);
17987
18063
  if (files.includes("turbo.json") || files.includes("lerna.json") || files.includes("nx.json")) {
17988
18064
  return "monorepo";
17989
18065
  }
17990
18066
  if (files.includes("package.json")) {
17991
18067
  const pkgPath = path65.join(this.projectPath, "package.json");
17992
- const pkgContent = await fs52.readFile(pkgPath, "utf-8");
18068
+ const pkgContent = await fs53.readFile(pkgPath, "utf-8");
17993
18069
  const pkg = JSON.parse(pkgContent);
17994
18070
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
17995
18071
  if (pkg.bin) return "cli-tool";
@@ -18025,32 +18101,32 @@ var init_onboarding = __esm({
18025
18101
  * Detect installed AI agents from config files
18026
18102
  */
18027
18103
  async detectInstalledAgents() {
18028
- const fs52 = await import("node:fs/promises");
18104
+ const fs53 = await import("node:fs/promises");
18029
18105
  const path65 = await import("node:path");
18030
18106
  const os21 = await import("node:os");
18031
18107
  const agents = [];
18032
18108
  try {
18033
- await fs52.access(path65.join(os21.homedir(), ".claude"));
18109
+ await fs53.access(path65.join(os21.homedir(), ".claude"));
18034
18110
  agents.push("claude");
18035
18111
  } catch {
18036
18112
  }
18037
18113
  try {
18038
- await fs52.access(path65.join(this.projectPath, ".cursorrules"));
18114
+ await fs53.access(path65.join(this.projectPath, ".cursorrules"));
18039
18115
  agents.push("cursor");
18040
18116
  } catch {
18041
18117
  }
18042
18118
  try {
18043
- await fs52.access(path65.join(this.projectPath, ".windsurfrules"));
18119
+ await fs53.access(path65.join(this.projectPath, ".windsurfrules"));
18044
18120
  agents.push("windsurf");
18045
18121
  } catch {
18046
18122
  }
18047
18123
  try {
18048
- await fs52.access(path65.join(this.projectPath, ".github", "copilot-instructions.md"));
18124
+ await fs53.access(path65.join(this.projectPath, ".github", "copilot-instructions.md"));
18049
18125
  agents.push("copilot");
18050
18126
  } catch {
18051
18127
  }
18052
18128
  try {
18053
- await fs52.access(path65.join(os21.homedir(), ".gemini"));
18129
+ await fs53.access(path65.join(os21.homedir(), ".gemini"));
18054
18130
  agents.push("gemini");
18055
18131
  } catch {
18056
18132
  }
@@ -18060,17 +18136,17 @@ var init_onboarding = __esm({
18060
18136
  * Detect tech stack from project files
18061
18137
  */
18062
18138
  async detectStack() {
18063
- const fs52 = await import("node:fs/promises");
18139
+ const fs53 = await import("node:fs/promises");
18064
18140
  const path65 = await import("node:path");
18065
18141
  const stack = {
18066
18142
  language: "Unknown",
18067
18143
  technologies: []
18068
18144
  };
18069
18145
  try {
18070
- const files = await fs52.readdir(this.projectPath);
18146
+ const files = await fs53.readdir(this.projectPath);
18071
18147
  if (files.includes("package.json")) {
18072
18148
  const pkgPath = path65.join(this.projectPath, "package.json");
18073
- const pkgContent = await fs52.readFile(pkgPath, "utf-8");
18149
+ const pkgContent = await fs53.readFile(pkgPath, "utf-8");
18074
18150
  const pkg = JSON.parse(pkgContent);
18075
18151
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
18076
18152
  stack.language = deps.typescript ? "TypeScript" : "JavaScript";
@@ -18177,14 +18253,14 @@ var init_wizard = __esm({
18177
18253
 
18178
18254
  // core/context/generator.ts
18179
18255
  import { exec as exec10 } from "node:child_process";
18180
- import fs35 from "node:fs/promises";
18256
+ import fs36 from "node:fs/promises";
18181
18257
  import path37 from "node:path";
18182
18258
  import { promisify as promisify11 } from "node:util";
18183
18259
  async function generateContext(projectId, repoPath) {
18184
18260
  const _globalPath = path_manager_default.getGlobalProjectPath(projectId);
18185
18261
  const contextPath = path_manager_default.getContextPath(projectId);
18186
18262
  const storage = getStorage(projectId);
18187
- await fs35.mkdir(contextPath, { recursive: true });
18263
+ await fs36.mkdir(contextPath, { recursive: true });
18188
18264
  const project = await storage.read(["project"]) || {};
18189
18265
  const taskPaths = await storage.list(["task"]);
18190
18266
  const featurePaths = await storage.list(["feature"]);
@@ -18267,7 +18343,7 @@ async function getPackageData(repoPath) {
18267
18343
  };
18268
18344
  try {
18269
18345
  const pkgPath = path37.join(repoPath, "package.json");
18270
- const pkg = JSON.parse(await fs35.readFile(pkgPath, "utf-8"));
18346
+ const pkg = JSON.parse(await fs36.readFile(pkgPath, "utf-8"));
18271
18347
  data.dependencies = pkg.dependencies || {};
18272
18348
  data.devDependencies = pkg.devDependencies || {};
18273
18349
  data.scripts = pkg.scripts || {};
@@ -18351,7 +18427,7 @@ ${agents.length > 0 ? agents.map((a) => `- **${a.name}**: ${a.role || "Specialis
18351
18427
  \u2514\u2500\u2500 pending.json
18352
18428
  \`\`\`
18353
18429
  `;
18354
- await fs35.writeFile(path37.join(contextPath, "CLAUDE.md"), content, "utf-8");
18430
+ await fs36.writeFile(path37.join(contextPath, "CLAUDE.md"), content, "utf-8");
18355
18431
  }
18356
18432
  async function generateNowMd(contextPath, tasks) {
18357
18433
  const currentTask = tasks.find((t) => t.status === "in_progress");
@@ -18366,7 +18442,7 @@ async function generateNowMd(contextPath, tasks) {
18366
18442
 
18367
18443
  _No active task. Use /p:now to start._
18368
18444
  `;
18369
- await fs35.writeFile(path37.join(contextPath, "now.md"), content, "utf-8");
18445
+ await fs36.writeFile(path37.join(contextPath, "now.md"), content, "utf-8");
18370
18446
  }
18371
18447
  async function generateQueueMd(contextPath, tasks) {
18372
18448
  const pendingTasks = tasks.filter((t) => t.status === "pending");
@@ -18374,7 +18450,7 @@ async function generateQueueMd(contextPath, tasks) {
18374
18450
 
18375
18451
  ${pendingTasks.length > 0 ? pendingTasks.map((t, i) => `${i + 1}. ${t.description}${t.priority ? ` [${t.priority}]` : ""}`).join("\n") : "_Empty queue. Use /p:next to add tasks._"}
18376
18452
  `;
18377
- await fs35.writeFile(path37.join(contextPath, "queue.md"), content, "utf-8");
18453
+ await fs36.writeFile(path37.join(contextPath, "queue.md"), content, "utf-8");
18378
18454
  }
18379
18455
  async function generateSummaryMd(contextPath, project, gitData, pkgData) {
18380
18456
  const content = `# PROJECT SUMMARY
@@ -18394,7 +18470,7 @@ async function generateSummaryMd(contextPath, project, gitData, pkgData) {
18394
18470
  - Production: ${Object.keys(pkgData.dependencies).length}
18395
18471
  - Dev: ${Object.keys(pkgData.devDependencies).length}
18396
18472
  `;
18397
- await fs35.writeFile(path37.join(contextPath, "summary.md"), content, "utf-8");
18473
+ await fs36.writeFile(path37.join(contextPath, "summary.md"), content, "utf-8");
18398
18474
  }
18399
18475
  var execAsync7;
18400
18476
  var init_generator = __esm({
@@ -18415,7 +18491,7 @@ var init_generator = __esm({
18415
18491
 
18416
18492
  // core/domain/analyzer.ts
18417
18493
  import { exec as execCallback6 } from "node:child_process";
18418
- import fs36 from "node:fs/promises";
18494
+ import fs37 from "node:fs/promises";
18419
18495
  import path38 from "node:path";
18420
18496
  import { promisify as promisify12 } from "node:util";
18421
18497
  var exec11, CodebaseAnalyzer, analyzer, analyzer_default2;
@@ -18441,7 +18517,7 @@ var init_analyzer2 = __esm({
18441
18517
  async readPackageJson() {
18442
18518
  try {
18443
18519
  const packagePath = path38.join(this.projectPath, "package.json");
18444
- const content = await fs36.readFile(packagePath, "utf-8");
18520
+ const content = await fs37.readFile(packagePath, "utf-8");
18445
18521
  return JSON.parse(content);
18446
18522
  } catch (error) {
18447
18523
  if (isNotFoundError(error) || error instanceof SyntaxError) {
@@ -18456,7 +18532,7 @@ var init_analyzer2 = __esm({
18456
18532
  async readCargoToml() {
18457
18533
  try {
18458
18534
  const cargoPath = path38.join(this.projectPath, "Cargo.toml");
18459
- return await fs36.readFile(cargoPath, "utf-8");
18535
+ return await fs37.readFile(cargoPath, "utf-8");
18460
18536
  } catch (error) {
18461
18537
  if (isNotFoundError(error)) {
18462
18538
  return null;
@@ -18470,7 +18546,7 @@ var init_analyzer2 = __esm({
18470
18546
  async readRequirements() {
18471
18547
  try {
18472
18548
  const reqPath = path38.join(this.projectPath, "requirements.txt");
18473
- return await fs36.readFile(reqPath, "utf-8");
18549
+ return await fs37.readFile(reqPath, "utf-8");
18474
18550
  } catch (error) {
18475
18551
  if (isNotFoundError(error)) {
18476
18552
  return null;
@@ -18484,7 +18560,7 @@ var init_analyzer2 = __esm({
18484
18560
  async readGoMod() {
18485
18561
  try {
18486
18562
  const goModPath = path38.join(this.projectPath, "go.mod");
18487
- return await fs36.readFile(goModPath, "utf-8");
18563
+ return await fs37.readFile(goModPath, "utf-8");
18488
18564
  } catch (error) {
18489
18565
  if (isNotFoundError(error)) {
18490
18566
  return null;
@@ -18498,7 +18574,7 @@ var init_analyzer2 = __esm({
18498
18574
  async readGemfile() {
18499
18575
  try {
18500
18576
  const gemfilePath = path38.join(this.projectPath, "Gemfile");
18501
- return await fs36.readFile(gemfilePath, "utf-8");
18577
+ return await fs37.readFile(gemfilePath, "utf-8");
18502
18578
  } catch (error) {
18503
18579
  if (isNotFoundError(error)) {
18504
18580
  return null;
@@ -18512,7 +18588,7 @@ var init_analyzer2 = __esm({
18512
18588
  async readMixExs() {
18513
18589
  try {
18514
18590
  const mixPath = path38.join(this.projectPath, "mix.exs");
18515
- return await fs36.readFile(mixPath, "utf-8");
18591
+ return await fs37.readFile(mixPath, "utf-8");
18516
18592
  } catch (error) {
18517
18593
  if (isNotFoundError(error)) {
18518
18594
  return null;
@@ -18526,7 +18602,7 @@ var init_analyzer2 = __esm({
18526
18602
  async readPomXml() {
18527
18603
  try {
18528
18604
  const pomPath = path38.join(this.projectPath, "pom.xml");
18529
- return await fs36.readFile(pomPath, "utf-8");
18605
+ return await fs37.readFile(pomPath, "utf-8");
18530
18606
  } catch (error) {
18531
18607
  if (isNotFoundError(error)) {
18532
18608
  return null;
@@ -18540,7 +18616,7 @@ var init_analyzer2 = __esm({
18540
18616
  async readComposerJson() {
18541
18617
  try {
18542
18618
  const composerPath = path38.join(this.projectPath, "composer.json");
18543
- const content = await fs36.readFile(composerPath, "utf-8");
18619
+ const content = await fs37.readFile(composerPath, "utf-8");
18544
18620
  return JSON.parse(content);
18545
18621
  } catch (error) {
18546
18622
  if (isNotFoundError(error) || error instanceof SyntaxError) {
@@ -18555,7 +18631,7 @@ var init_analyzer2 = __esm({
18555
18631
  async readPyprojectToml() {
18556
18632
  try {
18557
18633
  const pyprojectPath = path38.join(this.projectPath, "pyproject.toml");
18558
- return await fs36.readFile(pyprojectPath, "utf-8");
18634
+ return await fs37.readFile(pyprojectPath, "utf-8");
18559
18635
  } catch (error) {
18560
18636
  if (isNotFoundError(error)) {
18561
18637
  return null;
@@ -18591,7 +18667,7 @@ var init_analyzer2 = __esm({
18591
18667
  */
18592
18668
  async listConfigFiles() {
18593
18669
  try {
18594
- const entries = await fs36.readdir(this.projectPath);
18670
+ const entries = await fs37.readdir(this.projectPath);
18595
18671
  const configPatterns = [
18596
18672
  /^package\.json$/,
18597
18673
  /^Cargo\.toml$/,
@@ -18621,7 +18697,7 @@ var init_analyzer2 = __esm({
18621
18697
  */
18622
18698
  async listDirectories() {
18623
18699
  try {
18624
- const entries = await fs36.readdir(this.projectPath, { withFileTypes: true });
18700
+ const entries = await fs37.readdir(this.projectPath, { withFileTypes: true });
18625
18701
  return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) => !name.startsWith(".") && name !== "node_modules");
18626
18702
  } catch (error) {
18627
18703
  if (isNotFoundError(error)) {
@@ -18692,7 +18768,7 @@ var init_analyzer2 = __esm({
18692
18768
  */
18693
18769
  async fileExists(filename) {
18694
18770
  try {
18695
- await fs36.access(path38.join(this.projectPath, filename));
18771
+ await fs37.access(path38.join(this.projectPath, filename));
18696
18772
  return true;
18697
18773
  } catch (error) {
18698
18774
  if (isNotFoundError(error)) {
@@ -18707,7 +18783,7 @@ var init_analyzer2 = __esm({
18707
18783
  async readFile(relativePath) {
18708
18784
  try {
18709
18785
  const fullPath = path38.join(this.projectPath, relativePath);
18710
- return await fs36.readFile(fullPath, "utf-8");
18786
+ return await fs37.readFile(fullPath, "utf-8");
18711
18787
  } catch (error) {
18712
18788
  if (isNotFoundError(error)) {
18713
18789
  return null;
@@ -18955,7 +19031,7 @@ var analysis_exports = {};
18955
19031
  __export(analysis_exports, {
18956
19032
  AnalysisCommands: () => AnalysisCommands
18957
19033
  });
18958
- import fs37 from "node:fs/promises";
19034
+ import fs38 from "node:fs/promises";
18959
19035
  import path39 from "node:path";
18960
19036
  import prompts2 from "prompts";
18961
19037
  var AnalysisCommands;
@@ -19187,7 +19263,7 @@ var init_analysis2 = __esm({
19187
19263
  const claudeMdPath = path39.join(globalPath, "context", "CLAUDE.md");
19188
19264
  let existingContent = null;
19189
19265
  try {
19190
- existingContent = await fs37.readFile(claudeMdPath, "utf-8");
19266
+ existingContent = await fs38.readFile(claudeMdPath, "utf-8");
19191
19267
  } catch {
19192
19268
  }
19193
19269
  const isNonInteractive = !process.stdin.isTTY || options.json;
@@ -19206,7 +19282,7 @@ var init_analysis2 = __esm({
19206
19282
  }
19207
19283
  let newContent;
19208
19284
  try {
19209
- newContent = await fs37.readFile(claudeMdPath, "utf-8");
19285
+ newContent = await fs38.readFile(claudeMdPath, "utf-8");
19210
19286
  } catch {
19211
19287
  newContent = "";
19212
19288
  }
@@ -19230,7 +19306,7 @@ var init_analysis2 = __esm({
19230
19306
  }
19231
19307
  const restoreOriginal = /* @__PURE__ */ __name(async () => {
19232
19308
  if (existingContent != null) {
19233
- await fs37.writeFile(claudeMdPath, existingContent, "utf-8");
19309
+ await fs38.writeFile(claudeMdPath, existingContent, "utf-8");
19234
19310
  }
19235
19311
  }, "restoreOriginal");
19236
19312
  if (isNonInteractive) {
@@ -19449,7 +19525,7 @@ ${formatFullDiff(diff)}`);
19449
19525
  let projectName = "Unknown";
19450
19526
  try {
19451
19527
  const projectJson = JSON.parse(
19452
- await fs37.readFile(path39.join(globalPath, "project.json"), "utf-8")
19528
+ await fs38.readFile(path39.join(globalPath, "project.json"), "utf-8")
19453
19529
  );
19454
19530
  projectName = projectJson.name || "Unknown";
19455
19531
  } catch {
@@ -20204,8 +20280,8 @@ Generated: ${(/* @__PURE__ */ new Date()).toLocaleString()}
20204
20280
  const globalPath2 = path_manager_default.getGlobalProjectPath(projectId);
20205
20281
  const specsPath2 = path40.join(globalPath2, "planning", "specs");
20206
20282
  try {
20207
- const fs52 = await import("node:fs/promises");
20208
- const files = await fs52.readdir(specsPath2);
20283
+ const fs53 = await import("node:fs/promises");
20284
+ const files = await fs53.readdir(specsPath2);
20209
20285
  const specs = files.filter((f) => f.endsWith(".md") && f !== ".gitkeep");
20210
20286
  if (specs.length === 0) {
20211
20287
  output_default.warn("no specs yet");
@@ -20419,7 +20495,7 @@ var init_project_service = __esm({
20419
20495
 
20420
20496
  // core/services/staleness-checker.ts
20421
20497
  import { exec as exec12 } from "node:child_process";
20422
- import fs38 from "node:fs/promises";
20498
+ import fs39 from "node:fs/promises";
20423
20499
  import path41 from "node:path";
20424
20500
  import { promisify as promisify13 } from "node:util";
20425
20501
  var execAsync8, DEFAULT_CONFIG, StalenessChecker, createStalenessChecker;
@@ -20473,7 +20549,7 @@ var init_staleness_checker = __esm({
20473
20549
  const projectJsonPath = path41.join(path_manager_default.getGlobalProjectPath(projectId), "project.json");
20474
20550
  let projectJson = {};
20475
20551
  try {
20476
- projectJson = JSON.parse(await fs38.readFile(projectJsonPath, "utf-8"));
20552
+ projectJson = JSON.parse(await fs39.readFile(projectJsonPath, "utf-8"));
20477
20553
  } catch {
20478
20554
  status.isStale = true;
20479
20555
  status.reason = "No sync history found. Run `prjct sync` to initialize.";
@@ -21040,7 +21116,7 @@ var init_registry = __esm({
21040
21116
  });
21041
21117
 
21042
21118
  // core/ai-tools/generator.ts
21043
- import fs39 from "node:fs/promises";
21119
+ import fs40 from "node:fs/promises";
21044
21120
  import path43 from "node:path";
21045
21121
  async function generateAIToolContexts(context2, globalPath, repoPath, toolIds = DEFAULT_AI_TOOLS) {
21046
21122
  const results = [];
@@ -21080,9 +21156,9 @@ async function generateForTool(context2, config, globalPath, repoPath) {
21080
21156
  } else {
21081
21157
  outputPath = path43.join(globalPath, "context", config.outputFile);
21082
21158
  }
21083
- await fs39.mkdir(path43.dirname(outputPath), { recursive: true });
21159
+ await fs40.mkdir(path43.dirname(outputPath), { recursive: true });
21084
21160
  try {
21085
- const existingContent = await fs39.readFile(outputPath, "utf-8");
21161
+ const existingContent = await fs40.readFile(outputPath, "utf-8");
21086
21162
  const validation = validatePreserveBlocks(existingContent);
21087
21163
  if (!validation.valid) {
21088
21164
  console.warn(`\u26A0\uFE0F ${config.outputFile} has invalid preserve blocks:`);
@@ -21093,7 +21169,7 @@ async function generateForTool(context2, config, globalPath, repoPath) {
21093
21169
  content = mergePreservedSections(content, existingContent);
21094
21170
  } catch {
21095
21171
  }
21096
- await fs39.writeFile(outputPath, content, "utf-8");
21172
+ await fs40.writeFile(outputPath, content, "utf-8");
21097
21173
  return {
21098
21174
  toolId: config.id,
21099
21175
  outputFile: config.outputFile,
@@ -21133,7 +21209,7 @@ var init_ai_tools = __esm({
21133
21209
  });
21134
21210
 
21135
21211
  // core/services/context-generator.ts
21136
- import fs40 from "node:fs/promises";
21212
+ import fs41 from "node:fs/promises";
21137
21213
  import path44 from "node:path";
21138
21214
  var ContextFileGenerator;
21139
21215
  var init_context_generator = __esm({
@@ -21159,7 +21235,7 @@ var init_context_generator = __esm({
21159
21235
  async writeWithPreservation(filePath, content) {
21160
21236
  let finalContent = content;
21161
21237
  try {
21162
- const existingContent = await fs40.readFile(filePath, "utf-8");
21238
+ const existingContent = await fs41.readFile(filePath, "utf-8");
21163
21239
  const validation = validatePreserveBlocks(existingContent);
21164
21240
  if (!validation.valid) {
21165
21241
  const filename = path44.basename(filePath);
@@ -21171,7 +21247,7 @@ var init_context_generator = __esm({
21171
21247
  finalContent = mergePreservedSections(content, existingContent);
21172
21248
  } catch {
21173
21249
  }
21174
- await fs40.writeFile(filePath, finalContent, "utf-8");
21250
+ await fs41.writeFile(filePath, finalContent, "utf-8");
21175
21251
  }
21176
21252
  /**
21177
21253
  * Generate all context files in parallel
@@ -21287,7 +21363,7 @@ Load from \`~/.prjct-cli/projects/${this.config.projectId}/agents/\`:
21287
21363
  let currentTask = null;
21288
21364
  try {
21289
21365
  const statePath = path44.join(this.config.globalPath, "storage", "state.json");
21290
- const state = JSON.parse(await fs40.readFile(statePath, "utf-8"));
21366
+ const state = JSON.parse(await fs41.readFile(statePath, "utf-8"));
21291
21367
  currentTask = state.currentTask;
21292
21368
  } catch {
21293
21369
  }
@@ -21312,7 +21388,7 @@ Use \`p. task "description"\` to start working.
21312
21388
  let queue = { tasks: [] };
21313
21389
  try {
21314
21390
  const queuePath = path44.join(this.config.globalPath, "storage", "queue.json");
21315
- queue = JSON.parse(await fs40.readFile(queuePath, "utf-8"));
21391
+ queue = JSON.parse(await fs41.readFile(queuePath, "utf-8"));
21316
21392
  } catch {
21317
21393
  }
21318
21394
  const content = `# NEXT
@@ -21328,7 +21404,7 @@ ${queue.tasks.length > 0 ? queue.tasks.map((t, i) => `${i + 1}. ${t.description}
21328
21404
  let ideas = { ideas: [] };
21329
21405
  try {
21330
21406
  const ideasPath = path44.join(this.config.globalPath, "storage", "ideas.json");
21331
- ideas = JSON.parse(await fs40.readFile(ideasPath, "utf-8"));
21407
+ ideas = JSON.parse(await fs41.readFile(ideasPath, "utf-8"));
21332
21408
  } catch {
21333
21409
  }
21334
21410
  const content = `# IDEAS
@@ -21346,7 +21422,7 @@ ${ideas.ideas.length > 0 ? ideas.ideas.map((i) => `- ${i.text}${i.priority ? ` [
21346
21422
  };
21347
21423
  try {
21348
21424
  const shippedPath = path44.join(this.config.globalPath, "storage", "shipped.json");
21349
- shipped = JSON.parse(await fs40.readFile(shippedPath, "utf-8"));
21425
+ shipped = JSON.parse(await fs41.readFile(shippedPath, "utf-8"));
21350
21426
  } catch {
21351
21427
  }
21352
21428
  const content = `# SHIPPED \u{1F680}
@@ -21400,7 +21476,7 @@ ${shipped.shipped.length > 0 ? shipped.shipped.slice(-10).map((s) => `- **${s.na
21400
21476
  let pkgName = pkg.name;
21401
21477
  try {
21402
21478
  const pkgJsonPath = path44.join(pkg.path, "package.json");
21403
- const pkgJson = JSON.parse(await fs40.readFile(pkgJsonPath, "utf-8"));
21479
+ const pkgJson = JSON.parse(await fs41.readFile(pkgJsonPath, "utf-8"));
21404
21480
  pkgVersion = pkgJson.version || stats.version;
21405
21481
  pkgName = pkgJson.name || pkg.name;
21406
21482
  } catch {
@@ -21465,7 +21541,7 @@ Load from \`~/.prjct-cli/projects/${this.config.projectId}/agents/\`:
21465
21541
  });
21466
21542
 
21467
21543
  // core/services/local-state-generator.ts
21468
- import fs41 from "node:fs/promises";
21544
+ import fs42 from "node:fs/promises";
21469
21545
  import path45 from "node:path";
21470
21546
  var LOCAL_STATE_FILENAME, LocalStateGenerator, localStateGenerator;
21471
21547
  var init_local_state_generator = __esm({
@@ -21483,7 +21559,7 @@ var init_local_state_generator = __esm({
21483
21559
  async generate(projectPath, state) {
21484
21560
  const filePath = path45.join(projectPath, LOCAL_STATE_FILENAME);
21485
21561
  const content = this.toMarkdown(state);
21486
- await fs41.writeFile(filePath, content, "utf-8");
21562
+ await fs42.writeFile(filePath, content, "utf-8");
21487
21563
  }
21488
21564
  /**
21489
21565
  * Remove local state file
@@ -21491,7 +21567,7 @@ var init_local_state_generator = __esm({
21491
21567
  async remove(projectPath) {
21492
21568
  const filePath = path45.join(projectPath, LOCAL_STATE_FILENAME);
21493
21569
  try {
21494
- await fs41.unlink(filePath);
21570
+ await fs42.unlink(filePath);
21495
21571
  } catch (error) {
21496
21572
  if (!isNotFoundError(error)) throw error;
21497
21573
  }
@@ -21502,7 +21578,7 @@ var init_local_state_generator = __esm({
21502
21578
  async exists(projectPath) {
21503
21579
  const filePath = path45.join(projectPath, LOCAL_STATE_FILENAME);
21504
21580
  try {
21505
- await fs41.access(filePath);
21581
+ await fs42.access(filePath);
21506
21582
  return true;
21507
21583
  } catch {
21508
21584
  return false;
@@ -21581,7 +21657,7 @@ var init_local_state_generator = __esm({
21581
21657
  });
21582
21658
 
21583
21659
  // core/services/skill-lock.ts
21584
- import fs42 from "node:fs/promises";
21660
+ import fs43 from "node:fs/promises";
21585
21661
  import os13 from "node:os";
21586
21662
  import path46 from "node:path";
21587
21663
  function getLockFilePath() {
@@ -21596,7 +21672,7 @@ function createEmptyLockFile() {
21596
21672
  }
21597
21673
  async function read() {
21598
21674
  try {
21599
- const content = await fs42.readFile(getLockFilePath(), "utf-8");
21675
+ const content = await fs43.readFile(getLockFilePath(), "utf-8");
21600
21676
  return JSON.parse(content);
21601
21677
  } catch {
21602
21678
  return createEmptyLockFile();
@@ -21604,9 +21680,9 @@ async function read() {
21604
21680
  }
21605
21681
  async function write(lockFile) {
21606
21682
  const lockPath = getLockFilePath();
21607
- await fs42.mkdir(path46.dirname(lockPath), { recursive: true });
21683
+ await fs43.mkdir(path46.dirname(lockPath), { recursive: true });
21608
21684
  lockFile.generatedAt = (/* @__PURE__ */ new Date()).toISOString();
21609
- await fs42.writeFile(lockPath, JSON.stringify(lockFile, null, 2), "utf-8");
21685
+ await fs43.writeFile(lockPath, JSON.stringify(lockFile, null, 2), "utf-8");
21610
21686
  }
21611
21687
  async function addEntry(entry) {
21612
21688
  const lockFile = await read();
@@ -21659,7 +21735,7 @@ var init_skill_lock = __esm({
21659
21735
 
21660
21736
  // core/services/skill-installer.ts
21661
21737
  import { exec as execCallback7 } from "node:child_process";
21662
- import fs43 from "node:fs/promises";
21738
+ import fs44 from "node:fs/promises";
21663
21739
  import os14 from "node:os";
21664
21740
  import path47 from "node:path";
21665
21741
  import { promisify as promisify15 } from "node:util";
@@ -21705,7 +21781,7 @@ async function discoverSkills(dir) {
21705
21781
  const skills = [];
21706
21782
  try {
21707
21783
  const rootSkill = path47.join(dir, "SKILL.md");
21708
- await fs43.access(rootSkill);
21784
+ await fs44.access(rootSkill);
21709
21785
  const dirName = path47.basename(dir);
21710
21786
  skills.push({ name: dirName, filePath: rootSkill });
21711
21787
  } catch {
@@ -21761,10 +21837,10 @@ async function installSkillFile(sourcePath, name, source, sha) {
21761
21837
  const installDir = getInstallDir();
21762
21838
  const targetDir = path47.join(installDir, name);
21763
21839
  const targetPath = path47.join(targetDir, "SKILL.md");
21764
- const content = await fs43.readFile(sourcePath, "utf-8");
21840
+ const content = await fs44.readFile(sourcePath, "utf-8");
21765
21841
  const enrichedContent = injectSourceMetadata(content, source, sha);
21766
- await fs43.mkdir(targetDir, { recursive: true });
21767
- await fs43.writeFile(targetPath, enrichedContent, "utf-8");
21842
+ await fs44.mkdir(targetDir, { recursive: true });
21843
+ await fs44.writeFile(targetPath, enrichedContent, "utf-8");
21768
21844
  return {
21769
21845
  name,
21770
21846
  filePath: targetPath,
@@ -21825,7 +21901,7 @@ async function installFromGitHub(source) {
21825
21901
  }
21826
21902
  } finally {
21827
21903
  try {
21828
- await fs43.rm(tmpDir, { recursive: true, force: true });
21904
+ await fs44.rm(tmpDir, { recursive: true, force: true });
21829
21905
  } catch {
21830
21906
  }
21831
21907
  }
@@ -21835,12 +21911,12 @@ async function installFromLocal(source) {
21835
21911
  const result = { installed: [], skipped: [], errors: [] };
21836
21912
  const localPath = source.localPath;
21837
21913
  try {
21838
- await fs43.access(localPath);
21914
+ await fs44.access(localPath);
21839
21915
  } catch {
21840
21916
  result.errors.push(`Local path not found: ${localPath}`);
21841
21917
  return result;
21842
21918
  }
21843
- const stat = await fs43.stat(localPath);
21919
+ const stat = await fs44.stat(localPath);
21844
21920
  if (stat.isFile()) {
21845
21921
  const name = path47.basename(path47.dirname(localPath));
21846
21922
  try {
@@ -21884,12 +21960,12 @@ async function remove(name) {
21884
21960
  const installDir = getInstallDir();
21885
21961
  const subdirPath = path47.join(installDir, name);
21886
21962
  try {
21887
- await fs43.rm(subdirPath, { recursive: true, force: true });
21963
+ await fs44.rm(subdirPath, { recursive: true, force: true });
21888
21964
  } catch {
21889
21965
  }
21890
21966
  const flatPath = path47.join(installDir, `${name}.md`);
21891
21967
  try {
21892
- await fs43.rm(flatPath, { force: true });
21968
+ await fs44.rm(flatPath, { force: true });
21893
21969
  } catch {
21894
21970
  }
21895
21971
  return skillLock.removeEntry(name);
@@ -21937,7 +22013,7 @@ var init_skill_installer = __esm({
21937
22013
  });
21938
22014
 
21939
22015
  // core/services/stack-detector.ts
21940
- import fs44 from "node:fs/promises";
22016
+ import fs45 from "node:fs/promises";
21941
22017
  import path48 from "node:path";
21942
22018
  var StackDetector;
21943
22019
  var init_stack_detector = __esm({
@@ -22098,7 +22174,7 @@ var init_stack_detector = __esm({
22098
22174
  async readPackageJson() {
22099
22175
  try {
22100
22176
  const pkgPath = path48.join(this.projectPath, "package.json");
22101
- const content = await fs44.readFile(pkgPath, "utf-8");
22177
+ const content = await fs45.readFile(pkgPath, "utf-8");
22102
22178
  return JSON.parse(content);
22103
22179
  } catch {
22104
22180
  return null;
@@ -22109,7 +22185,7 @@ var init_stack_detector = __esm({
22109
22185
  */
22110
22186
  async fileExists(filename) {
22111
22187
  try {
22112
- await fs44.access(path48.join(this.projectPath, filename));
22188
+ await fs45.access(path48.join(this.projectPath, filename));
22113
22189
  return true;
22114
22190
  } catch {
22115
22191
  return false;
@@ -22121,7 +22197,7 @@ var init_stack_detector = __esm({
22121
22197
 
22122
22198
  // core/services/sync-verifier.ts
22123
22199
  import { exec as exec15 } from "node:child_process";
22124
- import fs45 from "node:fs/promises";
22200
+ import fs46 from "node:fs/promises";
22125
22201
  import path49 from "node:path";
22126
22202
  import { promisify as promisify16 } from "node:util";
22127
22203
  var execAsync10, BUILTIN_CHECKS, SyncVerifier, syncVerifier;
@@ -22141,7 +22217,7 @@ var init_sync_verifier = __esm({
22141
22217
  for (const file of expected) {
22142
22218
  const filePath = path49.join(globalPath, file);
22143
22219
  try {
22144
- await fs45.access(filePath);
22220
+ await fs46.access(filePath);
22145
22221
  } catch {
22146
22222
  missing.push(file);
22147
22223
  }
@@ -22164,7 +22240,7 @@ var init_sync_verifier = __esm({
22164
22240
  for (const file of jsonFiles) {
22165
22241
  const filePath = path49.join(globalPath, file);
22166
22242
  try {
22167
- const content = await fs45.readFile(filePath, "utf-8");
22243
+ const content = await fs46.readFile(filePath, "utf-8");
22168
22244
  JSON.parse(content);
22169
22245
  } catch (error) {
22170
22246
  if (!isNotFoundError(error)) {
@@ -22193,10 +22269,10 @@ var init_sync_verifier = __esm({
22193
22269
  ];
22194
22270
  const violations = [];
22195
22271
  try {
22196
- const files = await fs45.readdir(contextDir);
22272
+ const files = await fs46.readdir(contextDir);
22197
22273
  for (const file of files) {
22198
22274
  if (!file.endsWith(".md")) continue;
22199
- const content = await fs45.readFile(path49.join(contextDir, file), "utf-8");
22275
+ const content = await fs46.readFile(path49.join(contextDir, file), "utf-8");
22200
22276
  for (const pattern of patterns) {
22201
22277
  if (pattern.test(content)) {
22202
22278
  violations.push(`${file}: potential sensitive data detected`);
@@ -22317,7 +22393,7 @@ var init_sync_verifier = __esm({
22317
22393
 
22318
22394
  // core/services/sync-service.ts
22319
22395
  import { exec as exec16 } from "node:child_process";
22320
- import fs46 from "node:fs/promises";
22396
+ import fs47 from "node:fs/promises";
22321
22397
  import os15 from "node:os";
22322
22398
  import path50 from "node:path";
22323
22399
  import { promisify as promisify17 } from "node:util";
@@ -22495,7 +22571,7 @@ var init_sync_service = __esm({
22495
22571
  async ensureDirectories() {
22496
22572
  const dirs = ["storage", "context", "agents", "memory", "analysis", "config", "sync"];
22497
22573
  await Promise.all(
22498
- dirs.map((dir) => fs46.mkdir(path50.join(this.globalPath, dir), { recursive: true }))
22574
+ dirs.map((dir) => fs47.mkdir(path50.join(this.globalPath, dir), { recursive: true }))
22499
22575
  );
22500
22576
  }
22501
22577
  // ==========================================================================
@@ -22584,7 +22660,7 @@ var init_sync_service = __esm({
22584
22660
  }
22585
22661
  try {
22586
22662
  const pkgPath = path50.join(this.projectPath, "package.json");
22587
- const pkg = JSON.parse(await fs46.readFile(pkgPath, "utf-8"));
22663
+ const pkg = JSON.parse(await fs47.readFile(pkgPath, "utf-8"));
22588
22664
  stats.version = pkg.version || "0.0.0";
22589
22665
  stats.name = pkg.name || stats.name;
22590
22666
  stats.ecosystem = "JavaScript";
@@ -22731,10 +22807,10 @@ var init_sync_service = __esm({
22731
22807
  const agents = [];
22732
22808
  const agentsPath = path50.join(this.globalPath, "agents");
22733
22809
  try {
22734
- const files = await fs46.readdir(agentsPath);
22810
+ const files = await fs47.readdir(agentsPath);
22735
22811
  for (const file of files) {
22736
22812
  if (file.endsWith(".md")) {
22737
- await fs46.unlink(path50.join(agentsPath, file));
22813
+ await fs47.unlink(path50.join(agentsPath, file));
22738
22814
  }
22739
22815
  }
22740
22816
  } catch (error) {
@@ -22792,7 +22868,7 @@ var init_sync_service = __esm({
22792
22868
  `${partialName}.md`
22793
22869
  );
22794
22870
  try {
22795
- const partialContent = await fs46.readFile(partialPath, "utf-8");
22871
+ const partialContent = await fs47.readFile(partialPath, "utf-8");
22796
22872
  resolved = resolved.replace(match[0], partialContent.trim());
22797
22873
  } catch {
22798
22874
  resolved = resolved.replace(match[0], `<!-- partial "${partialName}" not found -->`);
@@ -22812,7 +22888,7 @@ var init_sync_service = __esm({
22812
22888
  "workflow",
22813
22889
  `${name}.md`
22814
22890
  );
22815
- content = await fs46.readFile(templatePath, "utf-8");
22891
+ content = await fs47.readFile(templatePath, "utf-8");
22816
22892
  content = await this.resolveTemplateIncludes(content);
22817
22893
  } catch (error) {
22818
22894
  logger_default.debug("Workflow agent template not found, generating minimal", {
@@ -22821,7 +22897,7 @@ var init_sync_service = __esm({
22821
22897
  });
22822
22898
  content = this.generateMinimalWorkflowAgent(name);
22823
22899
  }
22824
- await fs46.writeFile(path50.join(agentsPath, `${name}.md`), content, "utf-8");
22900
+ await fs47.writeFile(path50.join(agentsPath, `${name}.md`), content, "utf-8");
22825
22901
  }
22826
22902
  async generateDomainAgent(name, agentsPath, stats, stack) {
22827
22903
  let content = "";
@@ -22835,7 +22911,7 @@ var init_sync_service = __esm({
22835
22911
  "domain",
22836
22912
  `${name}.md`
22837
22913
  );
22838
- content = await fs46.readFile(templatePath, "utf-8");
22914
+ content = await fs47.readFile(templatePath, "utf-8");
22839
22915
  content = await this.resolveTemplateIncludes(content);
22840
22916
  content = content.replace("{projectName}", stats.name);
22841
22917
  content = content.replace("{frameworks}", stack.frameworks.join(", ") || "None detected");
@@ -22847,7 +22923,7 @@ var init_sync_service = __esm({
22847
22923
  });
22848
22924
  content = this.generateMinimalDomainAgent(name, stats, stack);
22849
22925
  }
22850
- await fs46.writeFile(path50.join(agentsPath, `${name}.md`), content, "utf-8");
22926
+ await fs47.writeFile(path50.join(agentsPath, `${name}.md`), content, "utf-8");
22851
22927
  }
22852
22928
  generateMinimalWorkflowAgent(name) {
22853
22929
  const descriptions = {
@@ -22915,7 +22991,7 @@ You are the ${name} expert for this project. Apply best practices for the detect
22915
22991
  })),
22916
22992
  agentSkillMap: Object.fromEntries(skills.map((s) => [s.agent, s.skill]))
22917
22993
  };
22918
- fs46.writeFile(
22994
+ fs47.writeFile(
22919
22995
  path50.join(this.globalPath, "config", "skills.json"),
22920
22996
  JSON.stringify(skillsConfig, null, 2),
22921
22997
  "utf-8"
@@ -22942,7 +23018,7 @@ You are the ${name} expert for this project. Apply best practices for the detect
22942
23018
  "config",
22943
23019
  "skill-mappings.json"
22944
23020
  );
22945
- const mappingsContent = await fs46.readFile(mappingsPath, "utf-8");
23021
+ const mappingsContent = await fs47.readFile(mappingsPath, "utf-8");
22946
23022
  const mappings = JSON.parse(mappingsContent);
22947
23023
  const agentToSkillMap = mappings.agentToSkillMap || {};
22948
23024
  const packagesToInstall = [];
@@ -22962,11 +23038,11 @@ You are the ${name} expert for this project. Apply best practices for the detect
22962
23038
  const flatPath = path50.join(skillsDir, `${skillName}.md`);
22963
23039
  let alreadyInstalled = false;
22964
23040
  try {
22965
- await fs46.access(subdirPath);
23041
+ await fs47.access(subdirPath);
22966
23042
  alreadyInstalled = true;
22967
23043
  } catch {
22968
23044
  try {
22969
- await fs46.access(flatPath);
23045
+ await fs47.access(flatPath);
22970
23046
  alreadyInstalled = true;
22971
23047
  } catch {
22972
23048
  }
@@ -23021,7 +23097,7 @@ You are the ${name} expert for this project. Apply best practices for the detect
23021
23097
  const projectJsonPath = path50.join(this.globalPath, "project.json");
23022
23098
  let existing = {};
23023
23099
  try {
23024
- existing = JSON.parse(await fs46.readFile(projectJsonPath, "utf-8"));
23100
+ existing = JSON.parse(await fs47.readFile(projectJsonPath, "utf-8"));
23025
23101
  } catch (error) {
23026
23102
  logger_default.debug("No existing project.json", {
23027
23103
  path: projectJsonPath,
@@ -23047,7 +23123,7 @@ You are the ${name} expert for this project. Apply best practices for the detect
23047
23123
  lastSyncCommit: git.recentCommits[0]?.hash || null,
23048
23124
  lastSyncBranch: git.branch
23049
23125
  };
23050
- await fs46.writeFile(projectJsonPath, JSON.stringify(updated, null, 2), "utf-8");
23126
+ await fs47.writeFile(projectJsonPath, JSON.stringify(updated, null, 2), "utf-8");
23051
23127
  }
23052
23128
  // ==========================================================================
23053
23129
  // STATE.JSON UPDATE
@@ -23056,7 +23132,7 @@ You are the ${name} expert for this project. Apply best practices for the detect
23056
23132
  const statePath = path50.join(this.globalPath, "storage", "state.json");
23057
23133
  let state = {};
23058
23134
  try {
23059
- state = JSON.parse(await fs46.readFile(statePath, "utf-8"));
23135
+ state = JSON.parse(await fs47.readFile(statePath, "utf-8"));
23060
23136
  } catch (error) {
23061
23137
  logger_default.debug("No existing state.json", { path: statePath, error: getErrorMessage(error) });
23062
23138
  }
@@ -23084,7 +23160,7 @@ You are the ${name} expert for this project. Apply best practices for the detect
23084
23160
  lastAction: "Synced project",
23085
23161
  nextAction: 'Run `p. task "description"` to start working'
23086
23162
  };
23087
- await fs46.writeFile(statePath, JSON.stringify(state, null, 2), "utf-8");
23163
+ await fs47.writeFile(statePath, JSON.stringify(state, null, 2), "utf-8");
23088
23164
  try {
23089
23165
  await localStateGenerator.generate(
23090
23166
  this.projectPath,
@@ -23107,7 +23183,7 @@ You are the ${name} expert for this project. Apply best practices for the detect
23107
23183
  fileCount: stats.fileCount,
23108
23184
  commitCount: git.commits
23109
23185
  };
23110
- await fs46.appendFile(memoryPath, `${JSON.stringify(event)}
23186
+ await fs47.appendFile(memoryPath, `${JSON.stringify(event)}
23111
23187
  `, "utf-8");
23112
23188
  }
23113
23189
  // ==========================================================================
@@ -23128,7 +23204,7 @@ You are the ${name} expert for this project. Apply best practices for the detect
23128
23204
  for (const file of contextFiles) {
23129
23205
  try {
23130
23206
  const filePath = path50.join(this.globalPath, file);
23131
- const content = await fs46.readFile(filePath, "utf-8");
23207
+ const content = await fs47.readFile(filePath, "utf-8");
23132
23208
  filteredChars += content.length;
23133
23209
  } catch (error) {
23134
23210
  logger_default.debug("Context file not found for metrics", { file, error: getErrorMessage(error) });
@@ -23137,7 +23213,7 @@ You are the ${name} expert for this project. Apply best practices for the detect
23137
23213
  for (const agent of agents) {
23138
23214
  try {
23139
23215
  const agentPath = path50.join(this.globalPath, "agents", `${agent.name}.md`);
23140
- const content = await fs46.readFile(agentPath, "utf-8");
23216
+ const content = await fs47.readFile(agentPath, "utf-8");
23141
23217
  filteredChars += content.length;
23142
23218
  } catch (error) {
23143
23219
  logger_default.debug("Agent file not found for metrics", {
@@ -23173,7 +23249,7 @@ You are the ${name} expert for this project. Apply best practices for the detect
23173
23249
  // ==========================================================================
23174
23250
  async fileExists(filename) {
23175
23251
  try {
23176
- await fs46.access(path50.join(this.projectPath, filename));
23252
+ await fs47.access(path50.join(this.projectPath, filename));
23177
23253
  return true;
23178
23254
  } catch (error) {
23179
23255
  logger_default.debug("File not found", { filename, error: getErrorMessage(error) });
@@ -23183,7 +23259,7 @@ You are the ${name} expert for this project. Apply best practices for the detect
23183
23259
  async getCliVersion() {
23184
23260
  try {
23185
23261
  const pkgPath = path50.join(__dirname, "..", "..", "package.json");
23186
- const pkg = JSON.parse(await fs46.readFile(pkgPath, "utf-8"));
23262
+ const pkg = JSON.parse(await fs47.readFile(pkgPath, "utf-8"));
23187
23263
  return pkg.version || "0.0.0";
23188
23264
  } catch (error) {
23189
23265
  logger_default.debug("Failed to read CLI version", { error: getErrorMessage(error) });
@@ -23344,7 +23420,7 @@ __export(uninstall_exports, {
23344
23420
  uninstall: () => uninstall
23345
23421
  });
23346
23422
  import { execSync as execSync3 } from "node:child_process";
23347
- import fs47 from "node:fs/promises";
23423
+ import fs48 from "node:fs/promises";
23348
23424
  import os16 from "node:os";
23349
23425
  import path51 from "node:path";
23350
23426
  import readline2 from "node:readline";
@@ -23352,14 +23428,14 @@ import chalk12 from "chalk";
23352
23428
  async function getDirectorySize(dirPath) {
23353
23429
  let totalSize = 0;
23354
23430
  try {
23355
- const entries = await fs47.readdir(dirPath, { withFileTypes: true });
23431
+ const entries = await fs48.readdir(dirPath, { withFileTypes: true });
23356
23432
  for (const entry of entries) {
23357
23433
  const entryPath = path51.join(dirPath, entry.name);
23358
23434
  if (entry.isDirectory()) {
23359
23435
  totalSize += await getDirectorySize(entryPath);
23360
23436
  } else {
23361
23437
  try {
23362
- const stats = await fs47.stat(entryPath);
23438
+ const stats = await fs48.stat(entryPath);
23363
23439
  totalSize += stats.size;
23364
23440
  } catch {
23365
23441
  }
@@ -23378,7 +23454,7 @@ function formatSize(bytes) {
23378
23454
  }
23379
23455
  async function countDirectoryItems(dirPath) {
23380
23456
  try {
23381
- const entries = await fs47.readdir(dirPath, { withFileTypes: true });
23457
+ const entries = await fs48.readdir(dirPath, { withFileTypes: true });
23382
23458
  return entries.filter((e) => e.isDirectory()).length;
23383
23459
  } catch {
23384
23460
  return 0;
@@ -23426,7 +23502,7 @@ async function gatherUninstallItems() {
23426
23502
  let hasPrjctSection = false;
23427
23503
  if (claudeMdExists) {
23428
23504
  try {
23429
- const content = await fs47.readFile(claudeMdPath, "utf-8");
23505
+ const content = await fs48.readFile(claudeMdPath, "utf-8");
23430
23506
  hasPrjctSection = content.includes(PRJCT_START_MARKER) && content.includes(PRJCT_END_MARKER);
23431
23507
  } catch {
23432
23508
  }
@@ -23476,7 +23552,7 @@ async function gatherUninstallItems() {
23476
23552
  let hasGeminiPrjctSection = false;
23477
23553
  if (geminiMdExists) {
23478
23554
  try {
23479
- const content = await fs47.readFile(geminiMdPath, "utf-8");
23555
+ const content = await fs48.readFile(geminiMdPath, "utf-8");
23480
23556
  hasGeminiPrjctSection = content.includes(PRJCT_START_MARKER) && content.includes(PRJCT_END_MARKER);
23481
23557
  } catch {
23482
23558
  }
@@ -23493,7 +23569,7 @@ async function gatherUninstallItems() {
23493
23569
  }
23494
23570
  async function removePrjctSection(filePath) {
23495
23571
  try {
23496
- const content = await fs47.readFile(filePath, "utf-8");
23572
+ const content = await fs48.readFile(filePath, "utf-8");
23497
23573
  if (!content.includes(PRJCT_START_MARKER) || !content.includes(PRJCT_END_MARKER)) {
23498
23574
  return false;
23499
23575
  }
@@ -23502,9 +23578,9 @@ async function removePrjctSection(filePath) {
23502
23578
  let newContent = content.substring(0, startIndex) + content.substring(endIndex);
23503
23579
  newContent = newContent.replace(/\n{3,}/g, "\n\n").trim();
23504
23580
  if (!newContent || newContent.trim().length === 0) {
23505
- await fs47.unlink(filePath);
23581
+ await fs48.unlink(filePath);
23506
23582
  } else {
23507
- await fs47.writeFile(filePath, `${newContent}
23583
+ await fs48.writeFile(filePath, `${newContent}
23508
23584
  `, "utf-8");
23509
23585
  }
23510
23586
  return true;
@@ -23512,12 +23588,12 @@ async function removePrjctSection(filePath) {
23512
23588
  return false;
23513
23589
  }
23514
23590
  }
23515
- async function createBackup() {
23591
+ async function createBackup2() {
23516
23592
  const homeDir = os16.homedir();
23517
23593
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").substring(0, 19);
23518
23594
  const backupDir = path51.join(homeDir, `.prjct-backup-${timestamp}`);
23519
23595
  try {
23520
- await fs47.mkdir(backupDir, { recursive: true });
23596
+ await fs48.mkdir(backupDir, { recursive: true });
23521
23597
  const prjctCliPath = path_manager_default.getGlobalBasePath();
23522
23598
  if (await fileExists(prjctCliPath)) {
23523
23599
  await copyDirectory(prjctCliPath, path51.join(backupDir, ".prjct-cli"));
@@ -23528,15 +23604,15 @@ async function createBackup() {
23528
23604
  }
23529
23605
  }
23530
23606
  async function copyDirectory(src, dest) {
23531
- await fs47.mkdir(dest, { recursive: true });
23532
- const entries = await fs47.readdir(src, { withFileTypes: true });
23607
+ await fs48.mkdir(dest, { recursive: true });
23608
+ const entries = await fs48.readdir(src, { withFileTypes: true });
23533
23609
  for (const entry of entries) {
23534
23610
  const srcPath = path51.join(src, entry.name);
23535
23611
  const destPath = path51.join(dest, entry.name);
23536
23612
  if (entry.isDirectory()) {
23537
23613
  await copyDirectory(srcPath, destPath);
23538
23614
  } else {
23539
- await fs47.copyFile(srcPath, destPath);
23615
+ await fs48.copyFile(srcPath, destPath);
23540
23616
  }
23541
23617
  }
23542
23618
  }
@@ -23552,10 +23628,10 @@ async function performUninstall(items, installation, options) {
23552
23628
  deleted.push(item.path);
23553
23629
  }
23554
23630
  } else if (item.type === "directory") {
23555
- await fs47.rm(item.path, { recursive: true, force: true });
23631
+ await fs48.rm(item.path, { recursive: true, force: true });
23556
23632
  deleted.push(item.path);
23557
23633
  } else if (item.type === "file") {
23558
- await fs47.unlink(item.path);
23634
+ await fs48.unlink(item.path);
23559
23635
  deleted.push(item.path);
23560
23636
  }
23561
23637
  } catch (error) {
@@ -23649,7 +23725,7 @@ async function uninstall(options = {}, _projectPath = process.cwd()) {
23649
23725
  }
23650
23726
  if (options.backup) {
23651
23727
  console.log(chalk12.blue("Creating backup..."));
23652
- const backupPath = await createBackup();
23728
+ const backupPath = await createBackup2();
23653
23729
  if (backupPath) {
23654
23730
  console.log(chalk12.green(`Backup created: ${path_manager_default.getDisplayPath(backupPath)}`));
23655
23731
  console.log("");
@@ -23710,7 +23786,7 @@ var init_uninstall = __esm({
23710
23786
  __name(detectInstallation, "detectInstallation");
23711
23787
  __name(gatherUninstallItems, "gatherUninstallItems");
23712
23788
  __name(removePrjctSection, "removePrjctSection");
23713
- __name(createBackup, "createBackup");
23789
+ __name(createBackup2, "createBackup");
23714
23790
  __name(copyDirectory, "copyDirectory");
23715
23791
  __name(performUninstall, "performUninstall");
23716
23792
  __name(promptConfirmation, "promptConfirmation");
@@ -24621,7 +24697,7 @@ __export(setup_exports, {
24621
24697
  run: () => run
24622
24698
  });
24623
24699
  import { execSync as execSync4 } from "node:child_process";
24624
- import fs48 from "node:fs/promises";
24700
+ import fs49 from "node:fs/promises";
24625
24701
  import os17 from "node:os";
24626
24702
  import path53 from "node:path";
24627
24703
  import chalk15 from "chalk";
@@ -24765,9 +24841,9 @@ async function installGeminiRouter() {
24765
24841
  const geminiCommandsDir = path53.join(os17.homedir(), ".gemini", "commands");
24766
24842
  const routerSource = path53.join(PACKAGE_ROOT, "templates", "commands", "p.toml");
24767
24843
  const routerDest = path53.join(geminiCommandsDir, "p.toml");
24768
- await fs48.mkdir(geminiCommandsDir, { recursive: true });
24844
+ await fs49.mkdir(geminiCommandsDir, { recursive: true });
24769
24845
  if (await fileExists(routerSource)) {
24770
- await fs48.copyFile(routerSource, routerDest);
24846
+ await fs49.copyFile(routerSource, routerDest);
24771
24847
  return true;
24772
24848
  }
24773
24849
  return false;
@@ -24781,12 +24857,12 @@ async function installGeminiGlobalConfig() {
24781
24857
  const geminiDir = path53.join(os17.homedir(), ".gemini");
24782
24858
  const globalConfigPath = path53.join(geminiDir, "GEMINI.md");
24783
24859
  const templatePath = path53.join(PACKAGE_ROOT, "templates", "global", "GEMINI.md");
24784
- await fs48.mkdir(geminiDir, { recursive: true });
24785
- const templateContent = await fs48.readFile(templatePath, "utf-8");
24860
+ await fs49.mkdir(geminiDir, { recursive: true });
24861
+ const templateContent = await fs49.readFile(templatePath, "utf-8");
24786
24862
  let existingContent = "";
24787
24863
  let configExists = false;
24788
24864
  try {
24789
- existingContent = await fs48.readFile(globalConfigPath, "utf-8");
24865
+ existingContent = await fs49.readFile(globalConfigPath, "utf-8");
24790
24866
  configExists = true;
24791
24867
  } catch (error) {
24792
24868
  if (isNotFoundError(error)) {
@@ -24796,7 +24872,7 @@ async function installGeminiGlobalConfig() {
24796
24872
  }
24797
24873
  }
24798
24874
  if (!configExists) {
24799
- await fs48.writeFile(globalConfigPath, templateContent, "utf-8");
24875
+ await fs49.writeFile(globalConfigPath, templateContent, "utf-8");
24800
24876
  return { success: true, action: "created" };
24801
24877
  }
24802
24878
  const startMarker = "<!-- prjct:start - DO NOT REMOVE THIS MARKER -->";
@@ -24806,7 +24882,7 @@ async function installGeminiGlobalConfig() {
24806
24882
  const updatedContent2 = `${existingContent}
24807
24883
 
24808
24884
  ${templateContent}`;
24809
- await fs48.writeFile(globalConfigPath, updatedContent2, "utf-8");
24885
+ await fs49.writeFile(globalConfigPath, updatedContent2, "utf-8");
24810
24886
  return { success: true, action: "appended" };
24811
24887
  }
24812
24888
  const beforeMarker = existingContent.substring(0, existingContent.indexOf(startMarker));
@@ -24818,7 +24894,7 @@ ${templateContent}`;
24818
24894
  templateContent.indexOf(endMarker) + endMarker.length
24819
24895
  );
24820
24896
  const updatedContent = beforeMarker + prjctSection + afterMarker;
24821
- await fs48.writeFile(globalConfigPath, updatedContent, "utf-8");
24897
+ await fs49.writeFile(globalConfigPath, updatedContent, "utf-8");
24822
24898
  return { success: true, action: "updated" };
24823
24899
  } catch (error) {
24824
24900
  logger_default.warn(`Gemini config warning: ${getErrorMessage2(error)}`);
@@ -24831,14 +24907,14 @@ async function installAntigravitySkill() {
24831
24907
  const prjctSkillDir = path53.join(antigravitySkillsDir, "prjct");
24832
24908
  const skillMdPath = path53.join(prjctSkillDir, "SKILL.md");
24833
24909
  const templatePath = path53.join(PACKAGE_ROOT, "templates", "antigravity", "SKILL.md");
24834
- await fs48.mkdir(prjctSkillDir, { recursive: true });
24910
+ await fs49.mkdir(prjctSkillDir, { recursive: true });
24835
24911
  const skillExists = await fileExists(skillMdPath);
24836
24912
  if (!await fileExists(templatePath)) {
24837
24913
  logger_default.warn("Antigravity SKILL.md template not found");
24838
24914
  return { success: false, action: null };
24839
24915
  }
24840
- const templateContent = await fs48.readFile(templatePath, "utf-8");
24841
- await fs48.writeFile(skillMdPath, templateContent, "utf-8");
24916
+ const templateContent = await fs49.readFile(templatePath, "utf-8");
24917
+ await fs49.writeFile(skillMdPath, templateContent, "utf-8");
24842
24918
  return { success: true, action: skillExists ? "updated" : "created" };
24843
24919
  } catch (error) {
24844
24920
  logger_default.warn(`Antigravity skill warning: ${getErrorMessage2(error)}`);
@@ -24863,18 +24939,18 @@ async function installCursorProject(projectRoot) {
24863
24939
  const routerMdcDest = path53.join(rulesDir, "prjct.mdc");
24864
24940
  const routerMdcSource = path53.join(PACKAGE_ROOT, "templates", "cursor", "router.mdc");
24865
24941
  const cursorCommandsSource = path53.join(PACKAGE_ROOT, "templates", "cursor", "commands");
24866
- await fs48.mkdir(rulesDir, { recursive: true });
24867
- await fs48.mkdir(commandsDir, { recursive: true });
24942
+ await fs49.mkdir(rulesDir, { recursive: true });
24943
+ await fs49.mkdir(commandsDir, { recursive: true });
24868
24944
  if (await fileExists(routerMdcSource)) {
24869
- await fs48.copyFile(routerMdcSource, routerMdcDest);
24945
+ await fs49.copyFile(routerMdcSource, routerMdcDest);
24870
24946
  result.rulesCreated = true;
24871
24947
  }
24872
24948
  if (await fileExists(cursorCommandsSource)) {
24873
- const commandFiles = (await fs48.readdir(cursorCommandsSource)).filter((f) => f.endsWith(".md"));
24949
+ const commandFiles = (await fs49.readdir(cursorCommandsSource)).filter((f) => f.endsWith(".md"));
24874
24950
  for (const file of commandFiles) {
24875
24951
  const src = path53.join(cursorCommandsSource, file);
24876
24952
  const dest = path53.join(commandsDir, file);
24877
- await fs48.copyFile(src, dest);
24953
+ await fs49.copyFile(src, dest);
24878
24954
  }
24879
24955
  result.commandsCreated = commandFiles.length > 0;
24880
24956
  }
@@ -24903,7 +24979,7 @@ async function addCursorToGitignore(projectRoot) {
24903
24979
  let content = "";
24904
24980
  let configExists = false;
24905
24981
  try {
24906
- content = await fs48.readFile(gitignorePath, "utf-8");
24982
+ content = await fs49.readFile(gitignorePath, "utf-8");
24907
24983
  configExists = true;
24908
24984
  } catch (error) {
24909
24985
  if (!isNotFoundError(error)) {
@@ -24918,7 +24994,7 @@ async function addCursorToGitignore(projectRoot) {
24918
24994
  ${entriesToAdd.join("\n")}
24919
24995
  ` : `${entriesToAdd.join("\n")}
24920
24996
  `;
24921
- await fs48.writeFile(gitignorePath, newContent, "utf-8");
24997
+ await fs49.writeFile(gitignorePath, newContent, "utf-8");
24922
24998
  return true;
24923
24999
  } catch (error) {
24924
25000
  logger_default.warn(`Gitignore update warning: ${getErrorMessage2(error)}`);
@@ -24947,20 +25023,20 @@ async function installWindsurfProject(projectRoot) {
24947
25023
  const routerDest = path53.join(rulesDir, "prjct.md");
24948
25024
  const routerSource = path53.join(PACKAGE_ROOT, "templates", "windsurf", "router.md");
24949
25025
  const windsurfWorkflowsSource = path53.join(PACKAGE_ROOT, "templates", "windsurf", "workflows");
24950
- await fs48.mkdir(rulesDir, { recursive: true });
24951
- await fs48.mkdir(workflowsDir, { recursive: true });
25026
+ await fs49.mkdir(rulesDir, { recursive: true });
25027
+ await fs49.mkdir(workflowsDir, { recursive: true });
24952
25028
  if (await fileExists(routerSource)) {
24953
- await fs48.copyFile(routerSource, routerDest);
25029
+ await fs49.copyFile(routerSource, routerDest);
24954
25030
  result.rulesCreated = true;
24955
25031
  }
24956
25032
  if (await fileExists(windsurfWorkflowsSource)) {
24957
- const workflowFiles = (await fs48.readdir(windsurfWorkflowsSource)).filter(
25033
+ const workflowFiles = (await fs49.readdir(windsurfWorkflowsSource)).filter(
24958
25034
  (f) => f.endsWith(".md")
24959
25035
  );
24960
25036
  for (const file of workflowFiles) {
24961
25037
  const src = path53.join(windsurfWorkflowsSource, file);
24962
25038
  const dest = path53.join(workflowsDir, file);
24963
- await fs48.copyFile(src, dest);
25039
+ await fs49.copyFile(src, dest);
24964
25040
  }
24965
25041
  result.workflowsCreated = workflowFiles.length > 0;
24966
25042
  }
@@ -24989,7 +25065,7 @@ async function addWindsurfToGitignore(projectRoot) {
24989
25065
  let content = "";
24990
25066
  let configExists = false;
24991
25067
  try {
24992
- content = await fs48.readFile(gitignorePath, "utf-8");
25068
+ content = await fs49.readFile(gitignorePath, "utf-8");
24993
25069
  configExists = true;
24994
25070
  } catch (error) {
24995
25071
  if (!isNotFoundError(error)) {
@@ -25004,7 +25080,7 @@ async function addWindsurfToGitignore(projectRoot) {
25004
25080
  ${entriesToAdd.join("\n")}
25005
25081
  ` : `${entriesToAdd.join("\n")}
25006
25082
  `;
25007
- await fs48.writeFile(gitignorePath, newContent, "utf-8");
25083
+ await fs49.writeFile(gitignorePath, newContent, "utf-8");
25008
25084
  return true;
25009
25085
  } catch (error) {
25010
25086
  logger_default.warn(`Gitignore update warning: ${getErrorMessage2(error)}`);
@@ -25025,7 +25101,7 @@ async function migrateProjectsCliVersion() {
25025
25101
  if (!await fileExists(projectsDir)) {
25026
25102
  return;
25027
25103
  }
25028
- const projectDirs = (await fs48.readdir(projectsDir, { withFileTypes: true })).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
25104
+ const projectDirs = (await fs49.readdir(projectsDir, { withFileTypes: true })).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
25029
25105
  let migrated = 0;
25030
25106
  for (const projectId of projectDirs) {
25031
25107
  const projectJsonPath = path53.join(projectsDir, projectId, "project.json");
@@ -25033,11 +25109,11 @@ async function migrateProjectsCliVersion() {
25033
25109
  continue;
25034
25110
  }
25035
25111
  try {
25036
- const content = await fs48.readFile(projectJsonPath, "utf8");
25112
+ const content = await fs49.readFile(projectJsonPath, "utf8");
25037
25113
  const project = JSON.parse(content);
25038
25114
  if (project.cliVersion !== VERSION) {
25039
25115
  project.cliVersion = VERSION;
25040
- await fs48.writeFile(projectJsonPath, JSON.stringify(project, null, 2));
25116
+ await fs49.writeFile(projectJsonPath, JSON.stringify(project, null, 2));
25041
25117
  migrated++;
25042
25118
  }
25043
25119
  } catch (error) {
@@ -25059,7 +25135,7 @@ async function ensureStatusLineSettings(settingsPath, statusLinePath) {
25059
25135
  let settings = {};
25060
25136
  if (await fileExists(settingsPath)) {
25061
25137
  try {
25062
- settings = JSON.parse(await fs48.readFile(settingsPath, "utf8"));
25138
+ settings = JSON.parse(await fs49.readFile(settingsPath, "utf8"));
25063
25139
  } catch (error) {
25064
25140
  if (!(error instanceof SyntaxError)) {
25065
25141
  throw error;
@@ -25067,7 +25143,7 @@ async function ensureStatusLineSettings(settingsPath, statusLinePath) {
25067
25143
  }
25068
25144
  }
25069
25145
  settings.statusLine = { type: "command", command: statusLinePath };
25070
- await fs48.writeFile(settingsPath, JSON.stringify(settings, null, 2));
25146
+ await fs49.writeFile(settingsPath, JSON.stringify(settings, null, 2));
25071
25147
  }
25072
25148
  async function installStatusLine() {
25073
25149
  try {
@@ -25087,22 +25163,22 @@ async function installStatusLine() {
25087
25163
  const sourceComponentsDir = path53.join(assetsDir, "components");
25088
25164
  const sourceConfigPath = path53.join(assetsDir, "default-config.json");
25089
25165
  if (!await fileExists(claudeDir)) {
25090
- await fs48.mkdir(claudeDir, { recursive: true });
25166
+ await fs49.mkdir(claudeDir, { recursive: true });
25091
25167
  }
25092
25168
  if (!await fileExists(prjctStatusLineDir)) {
25093
- await fs48.mkdir(prjctStatusLineDir, { recursive: true });
25169
+ await fs49.mkdir(prjctStatusLineDir, { recursive: true });
25094
25170
  }
25095
25171
  if (!await fileExists(prjctThemesDir)) {
25096
- await fs48.mkdir(prjctThemesDir, { recursive: true });
25172
+ await fs49.mkdir(prjctThemesDir, { recursive: true });
25097
25173
  }
25098
25174
  if (!await fileExists(prjctLibDir)) {
25099
- await fs48.mkdir(prjctLibDir, { recursive: true });
25175
+ await fs49.mkdir(prjctLibDir, { recursive: true });
25100
25176
  }
25101
25177
  if (!await fileExists(prjctComponentsDir)) {
25102
- await fs48.mkdir(prjctComponentsDir, { recursive: true });
25178
+ await fs49.mkdir(prjctComponentsDir, { recursive: true });
25103
25179
  }
25104
25180
  if (await fileExists(prjctStatusLinePath)) {
25105
- const existingContent = await fs48.readFile(prjctStatusLinePath, "utf8");
25181
+ const existingContent = await fs49.readFile(prjctStatusLinePath, "utf8");
25106
25182
  if (existingContent.includes("CLI_VERSION=")) {
25107
25183
  const versionMatch = existingContent.match(/CLI_VERSION="([^"]*)"/);
25108
25184
  if (versionMatch && versionMatch[1] !== VERSION) {
@@ -25110,7 +25186,7 @@ async function installStatusLine() {
25110
25186
  /CLI_VERSION="[^"]*"/,
25111
25187
  `CLI_VERSION="${VERSION}"`
25112
25188
  );
25113
- await fs48.writeFile(prjctStatusLinePath, updatedContent, { mode: 493 });
25189
+ await fs49.writeFile(prjctStatusLinePath, updatedContent, { mode: 493 });
25114
25190
  }
25115
25191
  await installStatusLineModules(sourceLibDir, prjctLibDir);
25116
25192
  await installStatusLineModules(sourceComponentsDir, prjctComponentsDir);
@@ -25120,21 +25196,21 @@ async function installStatusLine() {
25120
25196
  }
25121
25197
  }
25122
25198
  if (await fileExists(sourceScript)) {
25123
- let scriptContent = await fs48.readFile(sourceScript, "utf8");
25199
+ let scriptContent = await fs49.readFile(sourceScript, "utf8");
25124
25200
  scriptContent = scriptContent.replace(/CLI_VERSION="[^"]*"/, `CLI_VERSION="${VERSION}"`);
25125
- await fs48.writeFile(prjctStatusLinePath, scriptContent, { mode: 493 });
25201
+ await fs49.writeFile(prjctStatusLinePath, scriptContent, { mode: 493 });
25126
25202
  await installStatusLineModules(sourceLibDir, prjctLibDir);
25127
25203
  await installStatusLineModules(sourceComponentsDir, prjctComponentsDir);
25128
25204
  if (await fileExists(sourceThemeDir)) {
25129
- const themes = await fs48.readdir(sourceThemeDir);
25205
+ const themes = await fs49.readdir(sourceThemeDir);
25130
25206
  for (const theme of themes) {
25131
25207
  const src = path53.join(sourceThemeDir, theme);
25132
25208
  const dest = path53.join(prjctThemesDir, theme);
25133
- await fs48.copyFile(src, dest);
25209
+ await fs49.copyFile(src, dest);
25134
25210
  }
25135
25211
  }
25136
25212
  if (!await fileExists(prjctConfigPath) && await fileExists(sourceConfigPath)) {
25137
- await fs48.copyFile(sourceConfigPath, prjctConfigPath);
25213
+ await fs49.copyFile(sourceConfigPath, prjctConfigPath);
25138
25214
  }
25139
25215
  } else {
25140
25216
  const scriptContent = `#!/bin/bash
@@ -25169,7 +25245,7 @@ if [ -f "$CONFIG" ]; then
25169
25245
  fi
25170
25246
  echo "prjct"
25171
25247
  `;
25172
- await fs48.writeFile(prjctStatusLinePath, scriptContent, { mode: 493 });
25248
+ await fs49.writeFile(prjctStatusLinePath, scriptContent, { mode: 493 });
25173
25249
  }
25174
25250
  await ensureStatusLineSymlink(claudeStatusLinePath, prjctStatusLinePath);
25175
25251
  await ensureStatusLineSettings(settingsPath, claudeStatusLinePath);
@@ -25184,7 +25260,7 @@ async function installContext7MCP() {
25184
25260
  const claudeDir = path53.join(os17.homedir(), ".claude");
25185
25261
  const mcpConfigPath = path53.join(claudeDir, "mcp.json");
25186
25262
  if (!await fileExists(claudeDir)) {
25187
- await fs48.mkdir(claudeDir, { recursive: true });
25263
+ await fs49.mkdir(claudeDir, { recursive: true });
25188
25264
  }
25189
25265
  const context7Config = {
25190
25266
  mcpServers: {
@@ -25195,16 +25271,16 @@ async function installContext7MCP() {
25195
25271
  }
25196
25272
  };
25197
25273
  if (await fileExists(mcpConfigPath)) {
25198
- const existingContent = await fs48.readFile(mcpConfigPath, "utf-8");
25274
+ const existingContent = await fs49.readFile(mcpConfigPath, "utf-8");
25199
25275
  const existingConfig = JSON.parse(existingContent);
25200
25276
  if (existingConfig.mcpServers?.context7) {
25201
25277
  return;
25202
25278
  }
25203
25279
  existingConfig.mcpServers = existingConfig.mcpServers || {};
25204
25280
  existingConfig.mcpServers.context7 = context7Config.mcpServers.context7;
25205
- await fs48.writeFile(mcpConfigPath, JSON.stringify(existingConfig, null, 2), "utf-8");
25281
+ await fs49.writeFile(mcpConfigPath, JSON.stringify(existingConfig, null, 2), "utf-8");
25206
25282
  } else {
25207
- await fs48.writeFile(mcpConfigPath, JSON.stringify(context7Config, null, 2), "utf-8");
25283
+ await fs49.writeFile(mcpConfigPath, JSON.stringify(context7Config, null, 2), "utf-8");
25208
25284
  }
25209
25285
  } catch (error) {
25210
25286
  logger_default.warn(`Context7 MCP setup warning: ${getErrorMessage2(error)}`);
@@ -25214,34 +25290,34 @@ async function installStatusLineModules(sourceDir, destDir) {
25214
25290
  if (!await fileExists(sourceDir)) {
25215
25291
  return;
25216
25292
  }
25217
- const files = await fs48.readdir(sourceDir);
25293
+ const files = await fs49.readdir(sourceDir);
25218
25294
  for (const file of files) {
25219
25295
  if (file.endsWith(".sh")) {
25220
25296
  const src = path53.join(sourceDir, file);
25221
25297
  const dest = path53.join(destDir, file);
25222
- await fs48.copyFile(src, dest);
25223
- await fs48.chmod(dest, 493);
25298
+ await fs49.copyFile(src, dest);
25299
+ await fs49.chmod(dest, 493);
25224
25300
  }
25225
25301
  }
25226
25302
  }
25227
25303
  async function ensureStatusLineSymlink(linkPath, targetPath) {
25228
25304
  try {
25229
25305
  if (await fileExists(linkPath)) {
25230
- const stats = await fs48.lstat(linkPath);
25306
+ const stats = await fs49.lstat(linkPath);
25231
25307
  if (stats.isSymbolicLink()) {
25232
- const existingTarget = await fs48.readlink(linkPath);
25308
+ const existingTarget = await fs49.readlink(linkPath);
25233
25309
  if (existingTarget === targetPath) {
25234
25310
  return;
25235
25311
  }
25236
25312
  }
25237
- await fs48.unlink(linkPath);
25313
+ await fs49.unlink(linkPath);
25238
25314
  }
25239
- await fs48.symlink(targetPath, linkPath);
25315
+ await fs49.symlink(targetPath, linkPath);
25240
25316
  } catch (_error) {
25241
25317
  try {
25242
25318
  if (await fileExists(targetPath)) {
25243
- await fs48.copyFile(targetPath, linkPath);
25244
- await fs48.chmod(linkPath, 493);
25319
+ await fs49.copyFile(targetPath, linkPath);
25320
+ await fs49.chmod(linkPath, 493);
25245
25321
  }
25246
25322
  } catch (copyError) {
25247
25323
  if (!isNotFoundError(copyError)) {
@@ -25935,7 +26011,7 @@ ${"\u2550".repeat(50)}
25935
26011
  });
25936
26012
 
25937
26013
  // core/commands/context.ts
25938
- import fs49 from "node:fs/promises";
26014
+ import fs50 from "node:fs/promises";
25939
26015
  import path55 from "node:path";
25940
26016
  var ContextCommands, contextCommands;
25941
26017
  var init_context = __esm({
@@ -26063,7 +26139,7 @@ var init_context = __esm({
26063
26139
  async loadRepoAnalysis(globalPath) {
26064
26140
  try {
26065
26141
  const analysisPath = path55.join(globalPath, "analysis", "repo-analysis.json");
26066
- const content = await fs49.readFile(analysisPath, "utf-8");
26142
+ const content = await fs50.readFile(analysisPath, "utf-8");
26067
26143
  const data = JSON.parse(content);
26068
26144
  return {
26069
26145
  ecosystem: data.ecosystem || "unknown",
@@ -26560,7 +26636,7 @@ var init_maintenance = __esm({
26560
26636
  });
26561
26637
 
26562
26638
  // core/commands/setup.ts
26563
- import fs50 from "node:fs/promises";
26639
+ import fs51 from "node:fs/promises";
26564
26640
  import path59 from "node:path";
26565
26641
  import chalk16 from "chalk";
26566
26642
  var SetupCommands;
@@ -26748,11 +26824,11 @@ fi
26748
26824
  # Default: show prjct branding
26749
26825
  echo "\u26A1 prjct"
26750
26826
  `;
26751
- await fs50.writeFile(statusLinePath, scriptContent, { mode: 493 });
26827
+ await fs51.writeFile(statusLinePath, scriptContent, { mode: 493 });
26752
26828
  let settings = {};
26753
26829
  if (await fileExists(settingsPath)) {
26754
26830
  try {
26755
- settings = JSON.parse(await fs50.readFile(settingsPath, "utf8"));
26831
+ settings = JSON.parse(await fs51.readFile(settingsPath, "utf8"));
26756
26832
  } catch (_error) {
26757
26833
  }
26758
26834
  }
@@ -26760,7 +26836,7 @@ echo "\u26A1 prjct"
26760
26836
  type: "command",
26761
26837
  command: statusLinePath
26762
26838
  };
26763
- await fs50.writeFile(settingsPath, JSON.stringify(settings, null, 2));
26839
+ await fs51.writeFile(settingsPath, JSON.stringify(settings, null, 2));
26764
26840
  return { success: true };
26765
26841
  } catch (error) {
26766
26842
  return { success: false, error: getErrorMessage2(error) };
@@ -28118,7 +28194,7 @@ var init_linear = __esm({
28118
28194
  });
28119
28195
 
28120
28196
  // core/utils/project-credentials.ts
28121
- import fs51 from "node:fs/promises";
28197
+ import fs52 from "node:fs/promises";
28122
28198
  import os18 from "node:os";
28123
28199
  import path62 from "node:path";
28124
28200
  function getCredentialsPath(projectId) {
@@ -28130,7 +28206,7 @@ async function getProjectCredentials(projectId) {
28130
28206
  return {};
28131
28207
  }
28132
28208
  try {
28133
- return JSON.parse(await fs51.readFile(credPath, "utf-8"));
28209
+ return JSON.parse(await fs52.readFile(credPath, "utf-8"));
28134
28210
  } catch (error) {
28135
28211
  console.error("[project-credentials] Failed to read credentials:", getErrorMessage2(error));
28136
28212
  return {};
@@ -28710,7 +28786,7 @@ var require_package = __commonJS({
28710
28786
  "package.json"(exports, module) {
28711
28787
  module.exports = {
28712
28788
  name: "prjct-cli",
28713
- version: "1.7.0",
28789
+ version: "1.7.1",
28714
28790
  description: "Context layer for AI agents. Project context for Claude Code, Gemini CLI, and more.",
28715
28791
  main: "core/index.ts",
28716
28792
  bin: {
@@ -29185,7 +29261,7 @@ __name(isBun, "isBun");
29185
29261
  init_path_manager();
29186
29262
  init_fs();
29187
29263
  init_logger();
29188
- import fs8 from "node:fs/promises";
29264
+ import fs9 from "node:fs/promises";
29189
29265
  import path8 from "node:path";
29190
29266
  import { Hono } from "hono";
29191
29267
  import * as jsonc2 from "jsonc-parser";
@@ -29198,7 +29274,7 @@ var STORAGE_PATHS = {
29198
29274
  };
29199
29275
  async function readJsonFile(filePath) {
29200
29276
  try {
29201
- const content = await fs8.readFile(filePath, "utf-8");
29277
+ const content = await fs9.readFile(filePath, "utf-8");
29202
29278
  const errors = [];
29203
29279
  const result = jsonc2.parse(content, errors);
29204
29280
  return errors.length > 0 ? null : result;
@@ -29212,8 +29288,8 @@ async function readJsonFile(filePath) {
29212
29288
  __name(readJsonFile, "readJsonFile");
29213
29289
  async function writeJsonFile(filePath, data) {
29214
29290
  try {
29215
- await fs8.mkdir(path8.dirname(filePath), { recursive: true });
29216
- await fs8.writeFile(filePath, `${JSON.stringify(data, null, 2)}
29291
+ await fs9.mkdir(path8.dirname(filePath), { recursive: true });
29292
+ await fs9.writeFile(filePath, `${JSON.stringify(data, null, 2)}
29217
29293
  `, "utf-8");
29218
29294
  return true;
29219
29295
  } catch (error) {
@@ -29303,7 +29379,7 @@ function createRoutes(projectId, _projectPath) {
29303
29379
  }
29304
29380
  try {
29305
29381
  const filePath = path8.join(dataPath, "context", `${name}.md`);
29306
- const content = await fs8.readFile(filePath, "utf-8");
29382
+ const content = await fs9.readFile(filePath, "utf-8");
29307
29383
  return c.text(content, 200, { "Content-Type": "text/markdown" });
29308
29384
  } catch (error) {
29309
29385
  if (!isNotFoundError(error)) {
@@ -29319,7 +29395,7 @@ __name(createRoutes, "createRoutes");
29319
29395
  // core/server/routes-extended.ts
29320
29396
  init_path_manager();
29321
29397
  init_fs();
29322
- import fs9 from "node:fs/promises";
29398
+ import fs10 from "node:fs/promises";
29323
29399
  import path9 from "node:path";
29324
29400
  import { Hono as Hono2 } from "hono";
29325
29401
  import * as jsonc3 from "jsonc-parser";
@@ -29327,7 +29403,7 @@ var GLOBAL_BASE = path_manager_default.getGlobalBasePath();
29327
29403
  var PROJECTS_DIR = path9.join(GLOBAL_BASE, "projects");
29328
29404
  async function readJsonFile2(filePath) {
29329
29405
  try {
29330
- const content = await fs9.readFile(filePath, "utf-8");
29406
+ const content = await fs10.readFile(filePath, "utf-8");
29331
29407
  const errors = [];
29332
29408
  const result = jsonc3.parse(content, errors);
29333
29409
  return errors.length > 0 ? null : result;
@@ -29341,8 +29417,8 @@ async function readJsonFile2(filePath) {
29341
29417
  __name(readJsonFile2, "readJsonFile");
29342
29418
  async function writeJsonFile2(filePath, data) {
29343
29419
  try {
29344
- await fs9.mkdir(path9.dirname(filePath), { recursive: true });
29345
- await fs9.writeFile(filePath, `${JSON.stringify(data, null, 2)}
29420
+ await fs10.mkdir(path9.dirname(filePath), { recursive: true });
29421
+ await fs10.writeFile(filePath, `${JSON.stringify(data, null, 2)}
29346
29422
  `, "utf-8");
29347
29423
  return true;
29348
29424
  } catch (error) {
@@ -29379,8 +29455,8 @@ function createExtendedRoutes() {
29379
29455
  const api = new Hono2();
29380
29456
  api.get("/projects", async (c) => {
29381
29457
  try {
29382
- await fs9.mkdir(PROJECTS_DIR, { recursive: true });
29383
- const entries = await fs9.readdir(PROJECTS_DIR, { withFileTypes: true });
29458
+ await fs10.mkdir(PROJECTS_DIR, { recursive: true });
29459
+ const entries = await fs10.readdir(PROJECTS_DIR, { withFileTypes: true });
29384
29460
  const projectIds = entries.filter((e) => e.isDirectory()).map((e) => e.name);
29385
29461
  const projects = await Promise.all(
29386
29462
  projectIds.map(async (id) => {
@@ -29639,8 +29715,8 @@ function createExtendedRoutes() {
29639
29715
  });
29640
29716
  api.get("/stats/global", async (c) => {
29641
29717
  try {
29642
- await fs9.mkdir(PROJECTS_DIR, { recursive: true });
29643
- const entries = await fs9.readdir(PROJECTS_DIR, { withFileTypes: true });
29718
+ await fs10.mkdir(PROJECTS_DIR, { recursive: true });
29719
+ const entries = await fs10.readdir(PROJECTS_DIR, { withFileTypes: true });
29644
29720
  const projectIds = entries.filter((e) => e.isDirectory()).map((e) => e.name);
29645
29721
  let totalTasks = 0;
29646
29722
  let totalIdeas = 0;
@@ -29674,8 +29750,8 @@ function createExtendedRoutes() {
29674
29750
  api.get("/status-bar/compact", async (c) => {
29675
29751
  try {
29676
29752
  const cwd = c.req.query("cwd");
29677
- await fs9.mkdir(PROJECTS_DIR, { recursive: true });
29678
- const entries = await fs9.readdir(PROJECTS_DIR, { withFileTypes: true });
29753
+ await fs10.mkdir(PROJECTS_DIR, { recursive: true });
29754
+ const entries = await fs10.readdir(PROJECTS_DIR, { withFileTypes: true });
29679
29755
  const projectIds = entries.filter((e) => e.isDirectory()).map((e) => e.name);
29680
29756
  let targetProjectId = null;
29681
29757
  if (cwd) {