@imenam/mcp-documentor 1.0.99 → 1.0.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +9 -1
  2. package/dist/src/core/comment-store.d.ts +13 -2
  3. package/dist/src/core/comment-store.js +44 -6
  4. package/dist/src/core/embedding-store.js +12 -12
  5. package/dist/src/core/history-store.js +14 -14
  6. package/dist/src/gui-worker.js +17 -8
  7. package/dist/src/index.js +17 -4
  8. package/dist/src/tools/comments.d.ts +1 -1
  9. package/dist/src/tools/comments.js +51 -8
  10. package/gui/README.md +75 -0
  11. package/gui/dist/assets/{DocContent-ByGAvCaA.js → DocContent-D5CLsUKq.js} +51 -51
  12. package/gui/dist/assets/{abnfDiagram-WEYOIA3C-C9H-rU6M.js → abnfDiagram-WEYOIA3C-BqeAt-Gs.js} +1 -1
  13. package/gui/dist/assets/{arc-vCYNE25X.js → arc-Btzq4ujL.js} +1 -1
  14. package/gui/dist/assets/{architectureDiagram-ZHVYKT53-BKQrc7ec.js → architectureDiagram-ZHVYKT53-64qym6UB.js} +1 -1
  15. package/gui/dist/assets/{blockDiagram-RJAE7QA3-D_dicGXX.js → blockDiagram-RJAE7QA3-WAx3357U.js} +1 -1
  16. package/gui/dist/assets/{c4Diagram-XDPPPE54-CZFnurNd.js → c4Diagram-XDPPPE54-JfnC4lFj.js} +1 -1
  17. package/gui/dist/assets/channel-CAKB_FDX.js +1 -0
  18. package/gui/dist/assets/{chunk-2E7WHVMD-B-MISuU2.js → chunk-2E7WHVMD-ChRTmoE5.js} +1 -1
  19. package/gui/dist/assets/{chunk-2Q5K7J3B-2a52SE3x.js → chunk-2Q5K7J3B-BLmYMU05.js} +1 -1
  20. package/gui/dist/assets/{chunk-4EMNKR2T-DPfeHeMi.js → chunk-4EMNKR2T-ByrvV5eh.js} +1 -1
  21. package/gui/dist/assets/{chunk-55XCU76K-CuJqVzJg.js → chunk-55XCU76K-CR5a5uPD.js} +1 -1
  22. package/gui/dist/assets/{chunk-5VM5RSS4-CjT3LcWh.js → chunk-5VM5RSS4-Pitn_Zvk.js} +1 -1
  23. package/gui/dist/assets/{chunk-JWPE2WC7-pBWIoivI.js → chunk-JWPE2WC7-DGhyzwFs.js} +1 -1
  24. package/gui/dist/assets/{chunk-VQ5W62QI-B2vesLrV.js → chunk-VQ5W62QI-DgcZxhBM.js} +1 -1
  25. package/gui/dist/assets/{chunk-XXDRQBXY-COcLsneb.js → chunk-XXDRQBXY-CZUV9J1S.js} +1 -1
  26. package/gui/dist/assets/{chunk-ZCHMQSOR-Dmi8Z1BU.js → chunk-ZCHMQSOR-CNNcMwIE.js} +2 -2
  27. package/gui/dist/assets/{classDiagram-v2-4MYWR3UA-D2osY65Q.js → classDiagram-v2-4MYWR3UA-CqjmyUA_.js} +1 -1
  28. package/gui/dist/assets/{cose-bilkent-JH36ORCC-D-LBPHYI.js → cose-bilkent-JH36ORCC-CEo1fweo.js} +1 -1
  29. package/gui/dist/assets/{cynefin-EF2NZ3EQ-u1hU8acG.js → cynefin-EF2NZ3EQ-DJXHpx7E.js} +1 -1
  30. package/gui/dist/assets/{cynefinDiagram-WF24UDRP-BkfQkkkP.js → cynefinDiagram-WF24UDRP-DV_NDSud.js} +1 -1
  31. package/gui/dist/assets/{dagre-NK4GIZVX-C-EzM8in.js → dagre-NK4GIZVX-DQqk6wyz.js} +1 -1
  32. package/gui/dist/assets/{diagram-CBK3MWTC-BOKTtHCl.js → diagram-CBK3MWTC-jqLTDlwa.js} +1 -1
  33. package/gui/dist/assets/{diagram-I5XIIV2D-ngRhV4vV.js → diagram-I5XIIV2D-DX8lfXfI.js} +1 -1
  34. package/gui/dist/assets/{diagram-ODIL2UCW-DwTFpM7V.js → diagram-ODIL2UCW-DeXMUnn8.js} +1 -1
  35. package/gui/dist/assets/{diagram-PFBEJUXE-CNhBo08V.js → diagram-PFBEJUXE-BmNTodoc.js} +1 -1
  36. package/gui/dist/assets/{diagram-RJA3I4VV-qNCeztWZ.js → diagram-RJA3I4VV-Cy6P24cC.js} +1 -1
  37. package/gui/dist/assets/{diagram-TYUNFSNR-DLMiUXhU.js → diagram-TYUNFSNR-DHzYjDGy.js} +1 -1
  38. package/gui/dist/assets/{ebnfDiagram-V4P3TTPT-2EvohYBp.js → ebnfDiagram-V4P3TTPT-B4zOXNTZ.js} +1 -1
  39. package/gui/dist/assets/{elk-QONTBCTQ-DWMzZmm4.js → elk-QONTBCTQ-C4QICnsH.js} +1 -1
  40. package/gui/dist/assets/{erDiagram-KYQIGQAA-BgT-YhVQ.js → erDiagram-KYQIGQAA-p2xJfOWB.js} +1 -1
  41. package/gui/dist/assets/{flowDiagram-IUGLLWBU-CtGI0l2V.js → flowDiagram-IUGLLWBU-DFghgvui.js} +1 -1
  42. package/gui/dist/assets/{ganttDiagram-R7GPNTJY-DEQo6jBk.js → ganttDiagram-R7GPNTJY-HV4LZlu4.js} +1 -1
  43. package/gui/dist/assets/{gitGraphDiagram-PDYL7XHY-idf8MV3F.js → gitGraphDiagram-PDYL7XHY-DXtnta89.js} +1 -1
  44. package/gui/dist/assets/{infoDiagram-MVDRKAX5-m0KC07GR.js → infoDiagram-MVDRKAX5-D0VueLNb.js} +1 -1
  45. package/gui/dist/assets/{ishikawaDiagram-HPEHV2GE-CQzdMlUE.js → ishikawaDiagram-HPEHV2GE-D7K9eBsu.js} +1 -1
  46. package/gui/dist/assets/{journeyDiagram-BOSHW7O7-Bn-ydjkw.js → journeyDiagram-BOSHW7O7-B4bvZn8i.js} +1 -1
  47. package/gui/dist/assets/{kanban-definition-FNSA4HC5-CIPHomZ_.js → kanban-definition-FNSA4HC5-DFUTIwXB.js} +1 -1
  48. package/gui/dist/assets/{linear-BtDtYBvG.js → linear-DNC-wMVK.js} +1 -1
  49. package/gui/dist/assets/main-BTLYod5c.js +10 -0
  50. package/gui/dist/assets/{mindmap-definition-6OY57UG3-Dq-MAgfA.js → mindmap-definition-6OY57UG3-DoOaHbpM.js} +1 -1
  51. package/gui/dist/assets/{pegDiagram-ECIUJNBX-DkN63ahL.js → pegDiagram-ECIUJNBX-ryLSl0Ah.js} +1 -1
  52. package/gui/dist/assets/{pieDiagram-GNMPY74T-DMxFYL7W.js → pieDiagram-GNMPY74T-Bq8sW6iW.js} +1 -1
  53. package/gui/dist/assets/{public-BWV0VJ0G.js → public-3iVzlO1l.js} +1 -1
  54. package/gui/dist/assets/{quadrantDiagram-D57K4MC3-DvCAV95z.js → quadrantDiagram-D57K4MC3-DgbEH3GR.js} +1 -1
  55. package/gui/dist/assets/{railroadDiagram-Y72NRBL7-DIqa4oYb.js → railroadDiagram-Y72NRBL7-CPohPlF3.js} +1 -1
  56. package/gui/dist/assets/{requirementDiagram-EQYSW5RA-CiiuKxrT.js → requirementDiagram-EQYSW5RA-DWFB0c6H.js} +1 -1
  57. package/gui/dist/assets/{sankeyDiagram-SY24JHO5-D7Pqsvht.js → sankeyDiagram-SY24JHO5-Dy_Tjcb0.js} +1 -1
  58. package/gui/dist/assets/{sequenceDiagram-BLEHNHQU-CNOJD6dZ.js → sequenceDiagram-BLEHNHQU-CrojUX5d.js} +1 -1
  59. package/gui/dist/assets/{sizeCapture-INFHLROL-CZUHdjoX.js → sizeCapture-INFHLROL-CgsMV-GT.js} +1 -1
  60. package/gui/dist/assets/{stateDiagram-v2-A6IESKWZ-DwJxREKr.js → stateDiagram-v2-A6IESKWZ-CrIqIMW1.js} +1 -1
  61. package/gui/dist/assets/{swimlanes-B3ENRKFQ-CmwpC4o5.js → swimlanes-B3ENRKFQ-B4GJZt_W.js} +1 -1
  62. package/gui/dist/assets/swimlanesDiagram-AYQRV4AK-Da3hBJCE.js +8 -0
  63. package/gui/dist/assets/{timeline-definition-JXYKGLGB-BYqVvD1n.js → timeline-definition-JXYKGLGB-CEGP9Rfk.js} +1 -1
  64. package/gui/dist/assets/{usecaseDiagram-WPOLBNNX-w3DqfbYF.js → usecaseDiagram-WPOLBNNX-DVDVukRl.js} +1 -1
  65. package/gui/dist/assets/{vennDiagram-Q3Y3IDCW-apvvK_7Z.js → vennDiagram-Q3Y3IDCW-CEr2cVXx.js} +1 -1
  66. package/gui/dist/assets/{wardleyDiagram-IVAIDKWA-DJCHxKD3.js → wardleyDiagram-IVAIDKWA-C1f76sDQ.js} +1 -1
  67. package/gui/dist/assets/{xychartDiagram-4URNHDU4-CBbKJ4ms.js → xychartDiagram-4URNHDU4-DdnVSssZ.js} +1 -1
  68. package/gui/dist/index.html +2 -2
  69. package/gui/dist/public.html +2 -2
  70. package/package.json +72 -69
  71. package/scripts/migrate-links.js +258 -258
  72. package/scripts/migrate-paths-to-relative.js +196 -196
  73. package/gui/dist/assets/channel-CXrvaRTy.js +0 -1
  74. package/gui/dist/assets/main-Cs4w8XB_.js +0 -10
  75. package/gui/dist/assets/swimlanesDiagram-AYQRV4AK-DDXQdzqq.js +0 -8
@@ -1,196 +1,196 @@
1
- #!/usr/bin/env node
2
- /**
3
- * migrate-paths-to-relative.js
4
- *
5
- * One-shot migration that rewrites the absolute paths stored in each doc's
6
- * `tracked_files[].path` into the portable, code-root-relative form introduced
7
- * alongside GitHub documentation sync. Portable paths let an agent running on a
8
- * different machine (where the codebase lives at a different absolute location)
9
- * resolve tracked files correctly.
10
- *
11
- * Resolution reuses the compiled path-resolver (dist/) so it behaves exactly
12
- * like the running server — RUN `npm run build` FIRST.
13
- *
14
- * The conversion uses the code roots of this machine, as the server does: the
15
- * default root and the per-project roots stored in <data dir>/local-state.json,
16
- * set from the GUI (project settings) or with the set_code_root tool.
17
- *
18
- * A tracked file whose absolute path is NOT under the project's code root is
19
- * left absolute and reported, so nothing is silently broken.
20
- *
21
- * The data dir is resolved like the server: --data-dir flag, else MCP_DATA_DIR,
22
- * else <package>/data. The MCP_DATA_DIR fallback is what makes npx usable.
23
- *
24
- * Usage (from a clone):
25
- * node scripts/migrate-paths-to-relative.js [--dry-run] [--data-dir <dir>]
26
- *
27
- * Usage (npx install — no clone):
28
- * MCP_DATA_DIR="<your data dir>" \
29
- * npx -p @imenam/mcp-documentor mcp-documentor-migrate-paths --dry-run
30
- *
31
- * This migration is a ONE-TIME operation: run it once on the machine where the
32
- * stored absolute paths are valid, publish the result (sync_docs / push_docs),
33
- * and every other machine just pulls and sets its own code roots.
34
- */
35
-
36
- import fs from "fs";
37
- import path from "path";
38
- import { fileURLToPath, pathToFileURL } from "url";
39
- import matter from "gray-matter";
40
-
41
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
42
- const rootDir = path.join(__dirname, "..");
43
-
44
- const args = process.argv.slice(2);
45
- const dryRun = args.includes("--dry-run");
46
-
47
- // Data dir resolution mirrors the server (StorageEngine.getDataDir):
48
- // --data-dir flag > MCP_DATA_DIR env > <package>/data fallback.
49
- // The env fallback is what makes `npx` work: the data lives in the user's
50
- // MCP_DATA_DIR, not inside the npx package cache.
51
- const dataDirArgIdx = args.indexOf("--data-dir");
52
- const dataDir =
53
- dataDirArgIdx !== -1 && args[dataDirArgIdx + 1]
54
- ? args[dataDirArgIdx + 1]
55
- : process.env.MCP_DATA_DIR && process.env.MCP_DATA_DIR.trim() !== ""
56
- ? process.env.MCP_DATA_DIR.trim()
57
- : path.join(rootDir, "data");
58
-
59
- // ---------------------------------------------------------------------------
60
- // Reuse the compiled resolver so migration matches runtime behaviour exactly.
61
- // ---------------------------------------------------------------------------
62
-
63
- const resolverPath = path.join(rootDir, "dist", "src", "core", "path-resolver.js");
64
- const localStatePath = path.join(rootDir, "dist", "src", "core", "local-state.js");
65
- if (!fs.existsSync(resolverPath) || !fs.existsSync(localStatePath)) {
66
- console.error(`[ERROR] Compiled resolver not found at: ${resolverPath}`);
67
- console.error(" Run `npm run build` before this migration.");
68
- process.exit(1);
69
- }
70
- const { getCodeRoot, toStoredPath, setCodeRootProvider } = await import(pathToFileURL(resolverPath).href);
71
- const { LocalState } = await import(pathToFileURL(localStatePath).href);
72
- const localState = new LocalState(dataDir);
73
- setCodeRootProvider((project) => localState.getCodeRoot(project));
74
-
75
- // ---------------------------------------------------------------------------
76
- // Helpers
77
- // ---------------------------------------------------------------------------
78
-
79
- function walkMdFiles(dir) {
80
- if (!fs.existsSync(dir)) return [];
81
- const results = [];
82
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
83
- const fullPath = path.join(dir, entry.name);
84
- if (entry.isDirectory()) {
85
- results.push(...walkMdFiles(fullPath));
86
- } else if (entry.isFile() && entry.name.endsWith(".md")) {
87
- results.push(fullPath);
88
- }
89
- }
90
- return results;
91
- }
92
-
93
- function filePathToDocId(filePath, projectDir) {
94
- return path.relative(projectDir, filePath).replace(/\.md$/, "").split(path.sep).join("/");
95
- }
96
-
97
- // ---------------------------------------------------------------------------
98
- // Load config
99
- // ---------------------------------------------------------------------------
100
-
101
- const configPath = path.join(dataDir, "config.json");
102
- if (!fs.existsSync(configPath)) {
103
- console.error(`[ERROR] config.json not found at: ${configPath}`);
104
- console.error(" Make sure --data-dir points to the right directory.");
105
- process.exit(1);
106
- }
107
-
108
- const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
109
- const projects = config.projects ?? ["default"];
110
-
111
- console.log(`${dryRun ? "[DRY RUN] " : ""}migrate-paths-to-relative`);
112
- console.log(`Data dir : ${dataDir}`);
113
- console.log(`Projects : ${projects.length}`);
114
- console.log("");
115
-
116
- // ---------------------------------------------------------------------------
117
- // Migrate
118
- // ---------------------------------------------------------------------------
119
-
120
- let totalDocsChanged = 0;
121
- let totalConverted = 0;
122
- let totalLeftAbsolute = 0;
123
- const projectsWithoutRoot = [];
124
-
125
- for (const project of projects) {
126
- const root = getCodeRoot(project);
127
- if (!root) {
128
- projectsWithoutRoot.push(project);
129
- continue;
130
- }
131
-
132
- const projectDir = path.join(dataDir, "projects", project);
133
- const files = walkMdFiles(projectDir);
134
- if (files.length === 0) continue;
135
-
136
- const docChanges = [];
137
-
138
- for (const filePath of files) {
139
- const fullId = filePathToDocId(filePath, projectDir);
140
- const parsed = matter(fs.readFileSync(filePath, "utf-8"));
141
- const tracked = parsed.data.tracked_files;
142
- if (!Array.isArray(tracked) || tracked.length === 0) continue;
143
-
144
- let docChanged = false;
145
- for (const tf of tracked) {
146
- if (!tf || typeof tf.path !== "string") continue;
147
- if (!path.isAbsolute(tf.path)) continue; // already relative
148
-
149
- const stored = toStoredPath(tf.path, project);
150
- if (path.isAbsolute(stored)) {
151
- // Outside the root (or different drive) — resolver kept it absolute.
152
- totalLeftAbsolute++;
153
- docChanges.push(` [${fullId}] KEPT ABSOLUTE (outside root): ${tf.path}`);
154
- continue;
155
- }
156
-
157
- docChanges.push(` [${fullId}] "${tf.path}" → "${stored}"`);
158
- tf.path = stored;
159
- docChanged = true;
160
- totalConverted++;
161
- }
162
-
163
- if (docChanged) {
164
- totalDocsChanged++;
165
- if (!dryRun) {
166
- fs.writeFileSync(filePath, matter.stringify(parsed.content, parsed.data), "utf-8");
167
- }
168
- }
169
- }
170
-
171
- if (docChanges.length > 0) {
172
- console.log(`### Project: ${project} (root: ${root})`);
173
- docChanges.forEach((c) => console.log(c));
174
- console.log("");
175
- }
176
- }
177
-
178
- // ---------------------------------------------------------------------------
179
- // Summary
180
- // ---------------------------------------------------------------------------
181
-
182
- console.log("─".repeat(60));
183
- console.log(`Paths converted to relative : ${totalConverted}`);
184
- console.log(`Paths kept absolute : ${totalLeftAbsolute} ← outside the code root`);
185
- console.log(`Docs modified : ${totalDocsChanged}`);
186
- if (projectsWithoutRoot.length > 0) {
187
- console.log("");
188
- console.log(`Projects skipped (no code root configured): ${projectsWithoutRoot.length}`);
189
- console.log(` ${projectsWithoutRoot.join(", ")}`);
190
- console.log(" → set their code root (project settings in the GUI, or set_code_root) to migrate them.");
191
- }
192
-
193
- if (dryRun) {
194
- console.log("");
195
- console.log("[DRY RUN] No files were modified. Run without --dry-run to apply.");
196
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * migrate-paths-to-relative.js
4
+ *
5
+ * One-shot migration that rewrites the absolute paths stored in each doc's
6
+ * `tracked_files[].path` into the portable, code-root-relative form introduced
7
+ * alongside GitHub documentation sync. Portable paths let an agent running on a
8
+ * different machine (where the codebase lives at a different absolute location)
9
+ * resolve tracked files correctly.
10
+ *
11
+ * Resolution reuses the compiled path-resolver (dist/) so it behaves exactly
12
+ * like the running server — RUN `npm run build` FIRST.
13
+ *
14
+ * The conversion uses the code roots of this machine, as the server does: the
15
+ * default root and the per-project roots stored in <data dir>/local-state.json,
16
+ * set from the GUI (project settings) or with the set_code_root tool.
17
+ *
18
+ * A tracked file whose absolute path is NOT under the project's code root is
19
+ * left absolute and reported, so nothing is silently broken.
20
+ *
21
+ * The data dir is resolved like the server: --data-dir flag, else MCP_DATA_DIR,
22
+ * else <package>/data. The MCP_DATA_DIR fallback is what makes npx usable.
23
+ *
24
+ * Usage (from a clone):
25
+ * node scripts/migrate-paths-to-relative.js [--dry-run] [--data-dir <dir>]
26
+ *
27
+ * Usage (npx install — no clone):
28
+ * MCP_DATA_DIR="<your data dir>" \
29
+ * npx -p @imenam/mcp-documentor mcp-documentor-migrate-paths --dry-run
30
+ *
31
+ * This migration is a ONE-TIME operation: run it once on the machine where the
32
+ * stored absolute paths are valid, publish the result (sync_docs / push_docs),
33
+ * and every other machine just pulls and sets its own code roots.
34
+ */
35
+
36
+ import fs from "fs";
37
+ import path from "path";
38
+ import { fileURLToPath, pathToFileURL } from "url";
39
+ import matter from "gray-matter";
40
+
41
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
42
+ const rootDir = path.join(__dirname, "..");
43
+
44
+ const args = process.argv.slice(2);
45
+ const dryRun = args.includes("--dry-run");
46
+
47
+ // Data dir resolution mirrors the server (StorageEngine.getDataDir):
48
+ // --data-dir flag > MCP_DATA_DIR env > <package>/data fallback.
49
+ // The env fallback is what makes `npx` work: the data lives in the user's
50
+ // MCP_DATA_DIR, not inside the npx package cache.
51
+ const dataDirArgIdx = args.indexOf("--data-dir");
52
+ const dataDir =
53
+ dataDirArgIdx !== -1 && args[dataDirArgIdx + 1]
54
+ ? args[dataDirArgIdx + 1]
55
+ : process.env.MCP_DATA_DIR && process.env.MCP_DATA_DIR.trim() !== ""
56
+ ? process.env.MCP_DATA_DIR.trim()
57
+ : path.join(rootDir, "data");
58
+
59
+ // ---------------------------------------------------------------------------
60
+ // Reuse the compiled resolver so migration matches runtime behaviour exactly.
61
+ // ---------------------------------------------------------------------------
62
+
63
+ const resolverPath = path.join(rootDir, "dist", "src", "core", "path-resolver.js");
64
+ const localStatePath = path.join(rootDir, "dist", "src", "core", "local-state.js");
65
+ if (!fs.existsSync(resolverPath) || !fs.existsSync(localStatePath)) {
66
+ console.error(`[ERROR] Compiled resolver not found at: ${resolverPath}`);
67
+ console.error(" Run `npm run build` before this migration.");
68
+ process.exit(1);
69
+ }
70
+ const { getCodeRoot, toStoredPath, setCodeRootProvider } = await import(pathToFileURL(resolverPath).href);
71
+ const { LocalState } = await import(pathToFileURL(localStatePath).href);
72
+ const localState = new LocalState(dataDir);
73
+ setCodeRootProvider((project) => localState.getCodeRoot(project));
74
+
75
+ // ---------------------------------------------------------------------------
76
+ // Helpers
77
+ // ---------------------------------------------------------------------------
78
+
79
+ function walkMdFiles(dir) {
80
+ if (!fs.existsSync(dir)) return [];
81
+ const results = [];
82
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
83
+ const fullPath = path.join(dir, entry.name);
84
+ if (entry.isDirectory()) {
85
+ results.push(...walkMdFiles(fullPath));
86
+ } else if (entry.isFile() && entry.name.endsWith(".md")) {
87
+ results.push(fullPath);
88
+ }
89
+ }
90
+ return results;
91
+ }
92
+
93
+ function filePathToDocId(filePath, projectDir) {
94
+ return path.relative(projectDir, filePath).replace(/\.md$/, "").split(path.sep).join("/");
95
+ }
96
+
97
+ // ---------------------------------------------------------------------------
98
+ // Load config
99
+ // ---------------------------------------------------------------------------
100
+
101
+ const configPath = path.join(dataDir, "config.json");
102
+ if (!fs.existsSync(configPath)) {
103
+ console.error(`[ERROR] config.json not found at: ${configPath}`);
104
+ console.error(" Make sure --data-dir points to the right directory.");
105
+ process.exit(1);
106
+ }
107
+
108
+ const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
109
+ const projects = config.projects ?? ["default"];
110
+
111
+ console.log(`${dryRun ? "[DRY RUN] " : ""}migrate-paths-to-relative`);
112
+ console.log(`Data dir : ${dataDir}`);
113
+ console.log(`Projects : ${projects.length}`);
114
+ console.log("");
115
+
116
+ // ---------------------------------------------------------------------------
117
+ // Migrate
118
+ // ---------------------------------------------------------------------------
119
+
120
+ let totalDocsChanged = 0;
121
+ let totalConverted = 0;
122
+ let totalLeftAbsolute = 0;
123
+ const projectsWithoutRoot = [];
124
+
125
+ for (const project of projects) {
126
+ const root = getCodeRoot(project);
127
+ if (!root) {
128
+ projectsWithoutRoot.push(project);
129
+ continue;
130
+ }
131
+
132
+ const projectDir = path.join(dataDir, "projects", project);
133
+ const files = walkMdFiles(projectDir);
134
+ if (files.length === 0) continue;
135
+
136
+ const docChanges = [];
137
+
138
+ for (const filePath of files) {
139
+ const fullId = filePathToDocId(filePath, projectDir);
140
+ const parsed = matter(fs.readFileSync(filePath, "utf-8"));
141
+ const tracked = parsed.data.tracked_files;
142
+ if (!Array.isArray(tracked) || tracked.length === 0) continue;
143
+
144
+ let docChanged = false;
145
+ for (const tf of tracked) {
146
+ if (!tf || typeof tf.path !== "string") continue;
147
+ if (!path.isAbsolute(tf.path)) continue; // already relative
148
+
149
+ const stored = toStoredPath(tf.path, project);
150
+ if (path.isAbsolute(stored)) {
151
+ // Outside the root (or different drive) — resolver kept it absolute.
152
+ totalLeftAbsolute++;
153
+ docChanges.push(` [${fullId}] KEPT ABSOLUTE (outside root): ${tf.path}`);
154
+ continue;
155
+ }
156
+
157
+ docChanges.push(` [${fullId}] "${tf.path}" → "${stored}"`);
158
+ tf.path = stored;
159
+ docChanged = true;
160
+ totalConverted++;
161
+ }
162
+
163
+ if (docChanged) {
164
+ totalDocsChanged++;
165
+ if (!dryRun) {
166
+ fs.writeFileSync(filePath, matter.stringify(parsed.content, parsed.data), "utf-8");
167
+ }
168
+ }
169
+ }
170
+
171
+ if (docChanges.length > 0) {
172
+ console.log(`### Project: ${project} (root: ${root})`);
173
+ docChanges.forEach((c) => console.log(c));
174
+ console.log("");
175
+ }
176
+ }
177
+
178
+ // ---------------------------------------------------------------------------
179
+ // Summary
180
+ // ---------------------------------------------------------------------------
181
+
182
+ console.log("─".repeat(60));
183
+ console.log(`Paths converted to relative : ${totalConverted}`);
184
+ console.log(`Paths kept absolute : ${totalLeftAbsolute} ← outside the code root`);
185
+ console.log(`Docs modified : ${totalDocsChanged}`);
186
+ if (projectsWithoutRoot.length > 0) {
187
+ console.log("");
188
+ console.log(`Projects skipped (no code root configured): ${projectsWithoutRoot.length}`);
189
+ console.log(` ${projectsWithoutRoot.join(", ")}`);
190
+ console.log(" → set their code root (project settings in the GUI, or set_code_root) to migrate them.");
191
+ }
192
+
193
+ if (dryRun) {
194
+ console.log("");
195
+ console.log("[DRY RUN] No files were modified. Run without --dry-run to apply.");
196
+ }
@@ -1 +0,0 @@
1
- import{ao as r,ap as n}from"./DocContent-ByGAvCaA.js";const t=(a,o)=>r.lang.round(n.parse(a)[o]);export{t as c};