@lsctech/polaris 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/adopt-canon.js +30 -0
- package/package.json +1 -1
package/dist/cli/adopt-canon.js
CHANGED
|
@@ -7,6 +7,32 @@ const node_child_process_1 = require("node:child_process");
|
|
|
7
7
|
const loader_js_1 = require("../config/loader.js");
|
|
8
8
|
const librarian_dispatch_js_1 = require("../smartdocs-engine/librarian-dispatch.js");
|
|
9
9
|
const SKIP_DIRS = new Set(["node_modules", ".git", "dist", "build", ".polaris", "smartdocs"]);
|
|
10
|
+
function loadInventoryCanonicalFolders(repoRoot) {
|
|
11
|
+
const inventoryPath = (0, node_path_1.join)(repoRoot, ".polaris", "adoption-inventory.json");
|
|
12
|
+
if (!(0, node_fs_1.existsSync)(inventoryPath))
|
|
13
|
+
return [];
|
|
14
|
+
try {
|
|
15
|
+
const raw = JSON.parse((0, node_fs_1.readFileSync)(inventoryPath, "utf-8"));
|
|
16
|
+
const folders = raw["likely_canonical_folders"];
|
|
17
|
+
return Array.isArray(folders) ? folders : [];
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function scaffoldDraftSummaryFiles(repoRoot, canonicalFolders) {
|
|
24
|
+
for (const folder of canonicalFolders) {
|
|
25
|
+
const dir = (0, node_path_1.join)(repoRoot, folder);
|
|
26
|
+
if (!(0, node_fs_1.existsSync)(dir))
|
|
27
|
+
continue;
|
|
28
|
+
const summaryPath = (0, node_path_1.join)(dir, "SUMMARY.md");
|
|
29
|
+
if ((0, node_fs_1.existsSync)(summaryPath))
|
|
30
|
+
continue;
|
|
31
|
+
(0, node_fs_1.mkdirSync)(dir, { recursive: true });
|
|
32
|
+
(0, node_fs_1.writeFileSync)(summaryPath, `# ${folder}\n\n<!-- polaris:draft -->\n`, "utf-8");
|
|
33
|
+
console.log(` Scaffolded draft SUMMARY.md: ${folder}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
10
36
|
function walkForSummaryDirs(dir, repoRoot, results) {
|
|
11
37
|
let entries;
|
|
12
38
|
try {
|
|
@@ -144,6 +170,10 @@ async function enrichCanonFiles(repoRoot) {
|
|
|
144
170
|
"Run `polaris agent setup` to configure an available agent.");
|
|
145
171
|
}
|
|
146
172
|
const doctrineDocs = listActiveDoctrineDocs(repoRoot);
|
|
173
|
+
const canonicalFolders = loadInventoryCanonicalFolders(repoRoot);
|
|
174
|
+
if (canonicalFolders.length > 0) {
|
|
175
|
+
scaffoldDraftSummaryFiles(repoRoot, canonicalFolders);
|
|
176
|
+
}
|
|
147
177
|
const summaryDirs = [];
|
|
148
178
|
walkForSummaryDirs(repoRoot, repoRoot, summaryDirs);
|
|
149
179
|
let enrichedCount = 0;
|