@lsctech/polaris 0.1.0 → 0.1.3
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-assets.js +187 -0
- package/dist/cli/adopt-cognition.js +1 -2
- package/dist/cli/adopt-genesis.js +84 -0
- package/dist/cli/adopt-instructions.js +1 -2
- package/dist/cli/adopt-report.js +67 -0
- package/dist/cli/adopt-workspace.js +114 -0
- package/dist/cli/adoption-plan.js +11 -0
- package/dist/cli/init.js +79 -7
- package/dist/workspace/.polaris/roles/analyst.md +38 -0
- package/dist/workspace/.polaris/roles/closeout-librarian.md +122 -0
- package/dist/workspace/.polaris/roles/cognition-librarian.md +37 -0
- package/dist/workspace/.polaris/roles/finalizer.md +45 -0
- package/dist/workspace/.polaris/roles/foreman.md +165 -0
- package/dist/workspace/.polaris/roles/librarian.md +74 -0
- package/dist/workspace/.polaris/roles/worker.md +119 -0
- package/dist/workspace/.polaris/session-type +1 -0
- package/dist/workspace/.polaris/skills/ROUTING.md +109 -0
- package/dist/workspace/.polaris/skills/caveman/SKILL.md +74 -0
- package/dist/workspace/.polaris/skills/caveman-compress/scripts/compress.py +272 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/POLARIS.md +46 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/SKILL.md +59 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/chain.md +116 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/steps/01-load-cluster-context.md +78 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/steps/02-drift-reconciliation.md +157 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/steps/03-reconcile-polaris-md.md +93 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/steps/04-reconcile-summary-md.md +106 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/steps/05-doc-ingestion.md +114 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/steps/06-link-validation.md +128 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/steps/07-yaml-linking.md +95 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/steps/08-librarian-commit.md +119 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/steps/09-sealed-result.md +118 -0
- package/dist/workspace/.polaris/skills/docs-ingest/SKILL.md +68 -0
- package/dist/workspace/.polaris/skills/docs-ingest/chain.json +23 -0
- package/dist/workspace/.polaris/skills/docs-ingest/chain.md +149 -0
- package/dist/workspace/.polaris/skills/docs-ingest/steps/01-orient-ingest.md +85 -0
- package/dist/workspace/.polaris/skills/docs-ingest/steps/02-classify-batch.md +87 -0
- package/dist/workspace/.polaris/skills/docs-ingest/steps/03-conflict-check.md +66 -0
- package/dist/workspace/.polaris/skills/docs-ingest/steps/04-place-and-link.md +77 -0
- package/dist/workspace/.polaris/skills/docs-ingest/steps/05-finalize-ingest.md +49 -0
- package/dist/workspace/.polaris/skills/docs-promote/SKILL.md +79 -0
- package/dist/workspace/.polaris/skills/docs-promote/chain.json +25 -0
- package/dist/workspace/.polaris/skills/docs-promote/chain.md +80 -0
- package/dist/workspace/.polaris/skills/docs-promote/steps/01-orient-promote.md +53 -0
- package/dist/workspace/.polaris/skills/docs-promote/steps/02-review-candidates.md +51 -0
- package/dist/workspace/.polaris/skills/docs-promote/steps/03-read-linked-code.md +50 -0
- package/dist/workspace/.polaris/skills/docs-promote/steps/04-conflict-surface.md +65 -0
- package/dist/workspace/.polaris/skills/docs-promote/steps/05-await-approval.md +61 -0
- package/dist/workspace/.polaris/skills/docs-promote/steps/06-execute-promote-deprecate.md +65 -0
- package/dist/workspace/.polaris/skills/docs-promote/steps/07-finalize-promote.md +44 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/SKILL.md +94 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/chain.json +20 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/chain.md +105 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/issue-reconciliation.md +149 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/issue-template.md +133 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/linked-skills/repo-analysis.md +55 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/steps/01-fetch-and-orient.md +79 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/steps/02-map-affected-code.md +58 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/steps/03-assess-issue.md +58 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/steps/04-blocker-check.md +60 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/steps/05-create-cluster-plan.md +197 -0
- package/dist/workspace/.polaris/skills/polaris-analyze/steps/06-final-report.md +60 -0
- package/dist/workspace/.polaris/skills/polaris-catalog/SKILL.md +91 -0
- package/dist/workspace/.polaris/skills/polaris-catalog/chain.json +22 -0
- package/dist/workspace/.polaris/skills/polaris-catalog/chain.md +85 -0
- package/dist/workspace/.polaris/skills/polaris-catalog/steps/01-orient-catalog.md +92 -0
- package/dist/workspace/.polaris/skills/polaris-catalog/steps/02-reconcile-polaris-md.md +33 -0
- package/dist/workspace/.polaris/skills/polaris-catalog/steps/03-reconcile-summary-md.md +70 -0
- package/dist/workspace/.polaris/skills/polaris-catalog/steps/04-classify-and-place.md +117 -0
- package/dist/workspace/.polaris/skills/polaris-catalog/steps/05-catalog-commit.md +94 -0
- package/dist/workspace/.polaris/skills/polaris-medic/SKILL.md +52 -0
- package/dist/workspace/.polaris/skills/polaris-medic/chain.md +111 -0
- package/dist/workspace/.polaris/skills/polaris-medic/steps/01-orient-medic.md +75 -0
- package/dist/workspace/.polaris/skills/polaris-medic/steps/02-diagnose.md +79 -0
- package/dist/workspace/.polaris/skills/polaris-medic/steps/03-repair.md +64 -0
- package/dist/workspace/.polaris/skills/polaris-medic/steps/04-validate.md +66 -0
- package/dist/workspace/.polaris/skills/polaris-medic/steps/05-create-chart.md +85 -0
- package/dist/workspace/.polaris/skills/polaris-medic/steps/06-closeout.md +86 -0
- package/dist/workspace/.polaris/skills/polaris-reconcile/SKILL.md +75 -0
- package/dist/workspace/.polaris/skills/polaris-reconcile/chain.json +20 -0
- package/dist/workspace/.polaris/skills/polaris-reconcile/chain.md +67 -0
- package/dist/workspace/.polaris/skills/polaris-reconcile/steps/01-orient-reconcile.md +82 -0
- package/dist/workspace/.polaris/skills/polaris-reconcile/steps/02-reconcile-polaris-md.md +95 -0
- package/dist/workspace/.polaris/skills/polaris-reconcile/steps/03-reconcile-summary-md.md +108 -0
- package/dist/workspace/.polaris/skills/polaris-reconcile/steps/04-reconcile-commit.md +88 -0
- package/dist/workspace/.polaris/skills/polaris-run/SKILL.md +135 -0
- package/dist/workspace/.polaris/skills/polaris-run/chain.json +19 -0
- package/dist/workspace/.polaris/skills/polaris-run/chain.md +298 -0
- package/dist/workspace/.polaris/skills/polaris-run/execution-adapter.md +34 -0
- package/dist/workspace/.polaris/skills/polaris-run/linked-skills/repo-analysis.md +58 -0
- package/dist/workspace/.polaris/skills/polaris-run/steps/01-orient-cluster.md +96 -0
- package/dist/workspace/.polaris/skills/polaris-run/steps/02-prepare-branch.md +53 -0
- package/dist/workspace/.polaris/skills/polaris-run/steps/03-select-child.md +63 -0
- package/dist/workspace/.polaris/skills/polaris-run/steps/04-execute-child.md +75 -0
- package/dist/workspace/.polaris/skills/polaris-run/steps/05-validate-child.md +57 -0
- package/dist/workspace/.polaris/skills/polaris-run/steps/06-commit-and-update-linear.md +74 -0
- package/dist/workspace/.polaris/skills/polaris-run/steps/07-decide-continuation.md +89 -0
- package/dist/workspace/.polaris/skills/polaris-run/steps/08-closeout-librarian.md +146 -0
- package/dist/workspace/.polaris/skills/polaris-run/steps/08-final-delivery.md +91 -0
- package/dist/workspace/.polaris/skills/polaris-run/steps/09-final-delivery.md +104 -0
- package/dist/workspace/.polaris/skills/polaris-tools/README.md +63 -0
- package/dist/workspace/.polaris/skills/polaris-tools/SKILL.md +94 -0
- package/dist/workspace/.polaris/skills/polaris-tools/tools.js +191 -0
- package/dist/workspace/smartdocs/architecture/.gitkeep +0 -0
- package/dist/workspace/smartdocs/audits/.gitkeep +0 -0
- package/dist/workspace/smartdocs/decisions/.gitkeep +0 -0
- package/dist/workspace/smartdocs/doctrine/active/.gitkeep +0 -0
- package/dist/workspace/smartdocs/runtime/.gitkeep +0 -0
- package/dist/workspace/smartdocs/specs/active/.gitkeep +0 -0
- package/dist/workspace/smartdocs/specs/archive/.gitkeep +0 -0
- package/dist/workspace/workspace/.polaris/roles/analyst.md +38 -0
- package/dist/workspace/workspace/.polaris/roles/closeout-librarian.md +122 -0
- package/dist/workspace/workspace/.polaris/roles/cognition-librarian.md +37 -0
- package/dist/workspace/workspace/.polaris/roles/finalizer.md +45 -0
- package/dist/workspace/workspace/.polaris/roles/foreman.md +165 -0
- package/dist/workspace/workspace/.polaris/roles/librarian.md +74 -0
- package/dist/workspace/workspace/.polaris/roles/worker.md +119 -0
- package/dist/workspace/workspace/.polaris/session-type +1 -0
- package/dist/workspace/workspace/.polaris/skills/ROUTING.md +109 -0
- package/dist/workspace/workspace/.polaris/skills/caveman/SKILL.md +74 -0
- package/dist/workspace/workspace/.polaris/skills/caveman-compress/scripts/compress.py +272 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/POLARIS.md +46 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/SKILL.md +59 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/chain.md +116 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/01-load-cluster-context.md +78 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/02-drift-reconciliation.md +157 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/03-reconcile-polaris-md.md +93 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/04-reconcile-summary-md.md +106 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/05-doc-ingestion.md +114 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/06-link-validation.md +128 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/07-yaml-linking.md +95 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/08-librarian-commit.md +119 -0
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/09-sealed-result.md +118 -0
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/SKILL.md +68 -0
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/chain.json +23 -0
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/chain.md +149 -0
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/steps/01-orient-ingest.md +85 -0
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/steps/02-classify-batch.md +87 -0
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/steps/03-conflict-check.md +66 -0
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/steps/04-place-and-link.md +77 -0
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/steps/05-finalize-ingest.md +49 -0
- package/dist/workspace/workspace/.polaris/skills/docs-promote/SKILL.md +79 -0
- package/dist/workspace/workspace/.polaris/skills/docs-promote/chain.json +25 -0
- package/dist/workspace/workspace/.polaris/skills/docs-promote/chain.md +80 -0
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/01-orient-promote.md +53 -0
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/02-review-candidates.md +51 -0
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/03-read-linked-code.md +50 -0
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/04-conflict-surface.md +65 -0
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/05-await-approval.md +61 -0
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/06-execute-promote-deprecate.md +65 -0
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/07-finalize-promote.md +44 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/SKILL.md +94 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/chain.json +20 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/chain.md +105 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/issue-reconciliation.md +149 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/issue-template.md +133 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/linked-skills/repo-analysis.md +55 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/01-fetch-and-orient.md +79 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/02-map-affected-code.md +58 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/03-assess-issue.md +58 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/04-blocker-check.md +60 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/05-create-cluster-plan.md +197 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/06-final-report.md +60 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/SKILL.md +91 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/chain.json +22 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/chain.md +85 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/steps/01-orient-catalog.md +92 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/steps/02-reconcile-polaris-md.md +33 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/steps/03-reconcile-summary-md.md +70 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/steps/04-classify-and-place.md +117 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/steps/05-catalog-commit.md +94 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/SKILL.md +52 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/chain.md +111 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/01-orient-medic.md +75 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/02-diagnose.md +79 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/03-repair.md +64 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/04-validate.md +66 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/05-create-chart.md +85 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/06-closeout.md +86 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/SKILL.md +75 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/chain.json +20 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/chain.md +67 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/steps/01-orient-reconcile.md +82 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/steps/02-reconcile-polaris-md.md +95 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/steps/03-reconcile-summary-md.md +108 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/steps/04-reconcile-commit.md +88 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/SKILL.md +135 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/chain.json +19 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/chain.md +298 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/execution-adapter.md +34 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/linked-skills/repo-analysis.md +58 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/01-orient-cluster.md +96 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/02-prepare-branch.md +53 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/03-select-child.md +63 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/04-execute-child.md +75 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/05-validate-child.md +57 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/06-commit-and-update-linear.md +74 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/07-decide-continuation.md +89 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/08-closeout-librarian.md +146 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/08-final-delivery.md +91 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/09-final-delivery.md +104 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-tools/README.md +63 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-tools/SKILL.md +94 -0
- package/dist/workspace/workspace/.polaris/skills/polaris-tools/tools.js +191 -0
- package/dist/workspace/workspace/smartdocs/architecture/.gitkeep +0 -0
- package/dist/workspace/workspace/smartdocs/audits/.gitkeep +0 -0
- package/dist/workspace/workspace/smartdocs/decisions/.gitkeep +0 -0
- package/dist/workspace/workspace/smartdocs/doctrine/active/.gitkeep +0 -0
- package/dist/workspace/workspace/smartdocs/runtime/.gitkeep +0 -0
- package/dist/workspace/workspace/smartdocs/specs/active/.gitkeep +0 -0
- package/dist/workspace/workspace/smartdocs/specs/archive/.gitkeep +0 -0
- package/package.json +4 -4
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isThinPointer = isThinPointer;
|
|
4
|
+
exports.installWorkspaceAssets = installWorkspaceAssets;
|
|
5
|
+
exports.runGraphBuild = runGraphBuild;
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
function isAncestorSymlink(repoRoot, relPath) {
|
|
10
|
+
const parts = relPath.split("/").filter(Boolean);
|
|
11
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
12
|
+
const ancestor = (0, node_path_1.resolve)(repoRoot, ...parts.slice(0, i + 1));
|
|
13
|
+
try {
|
|
14
|
+
const stat = (0, node_fs_1.lstatSync)(ancestor);
|
|
15
|
+
if (stat.isSymbolicLink())
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
if (err.code === "ENOENT")
|
|
20
|
+
return false;
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Recursively walk srcDir and install directories + .gitkeep files into dstDir.
|
|
28
|
+
* parentWasPreExisting: true if dstDir already existed before Polaris touched it this run.
|
|
29
|
+
* Skip .gitkeep if parentWasPreExisting (user already has content in that dir).
|
|
30
|
+
*/
|
|
31
|
+
function installSmartdocsDir(srcDir, dstDir, relPrefix, installed, alreadyPresent, parentWasPreExisting) {
|
|
32
|
+
for (const entry of (0, node_fs_1.readdirSync)(srcDir, { withFileTypes: true })) {
|
|
33
|
+
const srcChild = (0, node_path_1.join)(srcDir, entry.name);
|
|
34
|
+
const dstChild = (0, node_path_1.join)(dstDir, entry.name);
|
|
35
|
+
const relChild = `${relPrefix}/${entry.name}`;
|
|
36
|
+
if (entry.isDirectory()) {
|
|
37
|
+
const childPreExisted = (0, node_fs_1.existsSync)(dstChild);
|
|
38
|
+
if (!childPreExisted) {
|
|
39
|
+
(0, node_fs_1.mkdirSync)(dstChild, { recursive: true });
|
|
40
|
+
installed.push(relChild);
|
|
41
|
+
}
|
|
42
|
+
installSmartdocsDir(srcChild, dstChild, relChild, installed, alreadyPresent, childPreExisted);
|
|
43
|
+
}
|
|
44
|
+
else if (entry.name === ".gitkeep") {
|
|
45
|
+
if (parentWasPreExisting) {
|
|
46
|
+
alreadyPresent.push(relChild);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (!(0, node_fs_1.existsSync)(dstDir)) {
|
|
50
|
+
(0, node_fs_1.mkdirSync)(dstDir, { recursive: true });
|
|
51
|
+
}
|
|
52
|
+
installed.push(relChild);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function isThinPointer(content) {
|
|
58
|
+
// Split into lines
|
|
59
|
+
const lines = content.split("\n");
|
|
60
|
+
// Filter to meaningful lines (non-empty, non-whitespace, non-HTML-comment)
|
|
61
|
+
const meaningfulLines = lines.filter((line) => {
|
|
62
|
+
const trimmed = line.trim();
|
|
63
|
+
// Empty or whitespace-only
|
|
64
|
+
if (!trimmed)
|
|
65
|
+
return false;
|
|
66
|
+
// HTML comment line (entire line is a comment)
|
|
67
|
+
if (/^<!--.*-->$/.test(trimmed))
|
|
68
|
+
return false;
|
|
69
|
+
return true;
|
|
70
|
+
});
|
|
71
|
+
// Rule 1: meaningful lines must be <= 3
|
|
72
|
+
if (meaningfulLines.length > 3)
|
|
73
|
+
return false;
|
|
74
|
+
// Rule 2: at least one line must contain "POLARIS.md"
|
|
75
|
+
const hasPolarisRef = meaningfulLines.some((line) => line.includes("POLARIS.md"));
|
|
76
|
+
if (!hasPolarisRef)
|
|
77
|
+
return false;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
function installWorkspaceAssets(repoRoot, workspaceDir) {
|
|
81
|
+
const installed = [];
|
|
82
|
+
const alreadyPresent = [];
|
|
83
|
+
const skipped = [];
|
|
84
|
+
const conflicted = [];
|
|
85
|
+
// 1. Skills
|
|
86
|
+
const srcSkillsDir = (0, node_path_1.join)(workspaceDir, ".polaris", "skills");
|
|
87
|
+
const dstSkillsDir = (0, node_path_1.join)(repoRoot, ".polaris", "skills");
|
|
88
|
+
if ((0, node_fs_1.existsSync)(srcSkillsDir)) {
|
|
89
|
+
for (const entry of (0, node_fs_1.readdirSync)(srcSkillsDir, { withFileTypes: true })) {
|
|
90
|
+
if (!entry.isDirectory())
|
|
91
|
+
continue;
|
|
92
|
+
const relSkillDir = `.polaris/skills/${entry.name}`;
|
|
93
|
+
if (isAncestorSymlink(repoRoot, relSkillDir)) {
|
|
94
|
+
skipped.push(relSkillDir);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const dstSkill = (0, node_path_1.join)(dstSkillsDir, entry.name);
|
|
98
|
+
if ((0, node_fs_1.existsSync)(dstSkill)) {
|
|
99
|
+
alreadyPresent.push(relSkillDir);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const srcSkill = (0, node_path_1.join)(srcSkillsDir, entry.name);
|
|
103
|
+
(0, node_fs_1.mkdirSync)(dstSkill, { recursive: true });
|
|
104
|
+
for (const file of (0, node_fs_1.readdirSync)(srcSkill, { withFileTypes: true })) {
|
|
105
|
+
if (!file.isFile())
|
|
106
|
+
continue;
|
|
107
|
+
(0, node_fs_1.copyFileSync)((0, node_path_1.join)(srcSkill, file.name), (0, node_path_1.join)(dstSkill, file.name));
|
|
108
|
+
}
|
|
109
|
+
installed.push(relSkillDir);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// 2. ROUTING.md
|
|
113
|
+
const routingRel = ".polaris/skills/ROUTING.md";
|
|
114
|
+
const srcRouting = (0, node_path_1.join)(workspaceDir, routingRel);
|
|
115
|
+
const dstRouting = (0, node_path_1.join)(repoRoot, routingRel);
|
|
116
|
+
if ((0, node_fs_1.existsSync)(srcRouting)) {
|
|
117
|
+
if (isAncestorSymlink(repoRoot, routingRel)) {
|
|
118
|
+
skipped.push(routingRel);
|
|
119
|
+
}
|
|
120
|
+
else if ((0, node_fs_1.existsSync)(dstRouting)) {
|
|
121
|
+
alreadyPresent.push(routingRel);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(repoRoot, ".polaris", "skills"), { recursive: true });
|
|
125
|
+
(0, node_fs_1.copyFileSync)(srcRouting, dstRouting);
|
|
126
|
+
installed.push(routingRel);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// 3. Roles
|
|
130
|
+
const srcRolesDir = (0, node_path_1.join)(workspaceDir, ".polaris", "roles");
|
|
131
|
+
const dstRolesDir = (0, node_path_1.join)(repoRoot, ".polaris", "roles");
|
|
132
|
+
if ((0, node_fs_1.existsSync)(srcRolesDir)) {
|
|
133
|
+
for (const entry of (0, node_fs_1.readdirSync)(srcRolesDir, { withFileTypes: true })) {
|
|
134
|
+
if (!entry.isFile())
|
|
135
|
+
continue;
|
|
136
|
+
const relFile = `.polaris/roles/${entry.name}`;
|
|
137
|
+
if (isAncestorSymlink(repoRoot, relFile)) {
|
|
138
|
+
skipped.push(relFile);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const dstFile = (0, node_path_1.join)(dstRolesDir, entry.name);
|
|
142
|
+
if ((0, node_fs_1.existsSync)(dstFile)) {
|
|
143
|
+
alreadyPresent.push(relFile);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
(0, node_fs_1.mkdirSync)(dstRolesDir, { recursive: true });
|
|
147
|
+
(0, node_fs_1.copyFileSync)((0, node_path_1.join)(srcRolesDir, entry.name), dstFile);
|
|
148
|
+
installed.push(relFile);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// 4. Smartdocs scaffold
|
|
152
|
+
const srcSmartdocs = (0, node_path_1.join)(workspaceDir, "smartdocs");
|
|
153
|
+
const dstSmartdocs = (0, node_path_1.join)(repoRoot, "smartdocs");
|
|
154
|
+
if ((0, node_fs_1.existsSync)(srcSmartdocs)) {
|
|
155
|
+
const smartdocsPreExisted = (0, node_fs_1.existsSync)(dstSmartdocs);
|
|
156
|
+
installSmartdocsDir(srcSmartdocs, dstSmartdocs, "smartdocs", installed, alreadyPresent, smartdocsPreExisted);
|
|
157
|
+
}
|
|
158
|
+
return { installed, alreadyPresent, skipped, conflicted };
|
|
159
|
+
}
|
|
160
|
+
function runGraphBuild(repoRoot) {
|
|
161
|
+
try {
|
|
162
|
+
const proc = (0, node_child_process_1.spawnSync)(process.execPath, [process.argv[1], "graph", "build"], {
|
|
163
|
+
cwd: repoRoot,
|
|
164
|
+
encoding: "buffer",
|
|
165
|
+
timeout: 5 * 60 * 1000,
|
|
166
|
+
});
|
|
167
|
+
if (proc.status === 0) {
|
|
168
|
+
return {
|
|
169
|
+
status: "graph-success",
|
|
170
|
+
stdout: proc.stdout ? proc.stdout.toString("utf-8") : undefined,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
status: "graph-failed",
|
|
175
|
+
reason: proc.stderr ? proc.stderr.toString("utf-8") : "Unknown error",
|
|
176
|
+
followUpCommand: "polaris-cli graph build",
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
181
|
+
return {
|
|
182
|
+
status: "graph-failed",
|
|
183
|
+
reason: errorMsg,
|
|
184
|
+
followUpCommand: "polaris-cli graph build",
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -157,11 +157,10 @@ function buildSummaryDraft(folder) {
|
|
|
157
157
|
"",
|
|
158
158
|
].join("\n");
|
|
159
159
|
}
|
|
160
|
-
function generateFolderCognition(plan, inventory) {
|
|
160
|
+
function generateFolderCognition(plan, inventory, repoRoot) {
|
|
161
161
|
if (plan.dry_run) {
|
|
162
162
|
return Promise.resolve();
|
|
163
163
|
}
|
|
164
|
-
const repoRoot = (0, node_path_1.resolve)(process.cwd());
|
|
165
164
|
const folders = Array.from(new Set(inventory.likely_canonical_folders.map(normalizeFolder)));
|
|
166
165
|
for (const folder of folders) {
|
|
167
166
|
if (!isFolderEligible(folder, inventory)) {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reconcileAgentFiles = reconcileAgentFiles;
|
|
4
|
+
const promises_1 = require("node:readline/promises");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const adopt_assets_js_1 = require("./adopt-assets.js");
|
|
8
|
+
const AGENT_FILES = ["CLAUDE.md", "AGENTS.md", ".github/copilot-instructions.md"];
|
|
9
|
+
function formatDate(d) {
|
|
10
|
+
return d.toISOString().slice(0, 10);
|
|
11
|
+
}
|
|
12
|
+
async function reconcileAgentFiles(repoRoot, options) {
|
|
13
|
+
const results = [];
|
|
14
|
+
for (const file of AGENT_FILES) {
|
|
15
|
+
const filePath = (0, node_path_1.join)(repoRoot, file);
|
|
16
|
+
if (!(0, node_fs_1.existsSync)(filePath)) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const content = (0, node_fs_1.readFileSync)(filePath, "utf8");
|
|
20
|
+
if ((0, adopt_assets_js_1.isThinPointer)(content)) {
|
|
21
|
+
results.push({ file, outcome: "already-present" });
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const rl = (0, promises_1.createInterface)({ input: process.stdin, output: process.stdout });
|
|
25
|
+
let answer;
|
|
26
|
+
try {
|
|
27
|
+
answer = await rl.question(`\n${file} has existing content. Compress and archive as genesis doctrine? (Requires ANTHROPIC_API_KEY) [Y/n]: `);
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
rl.close();
|
|
31
|
+
}
|
|
32
|
+
const trimmed = answer.trim().toLowerCase();
|
|
33
|
+
if (trimmed === "n" || trimmed === "no") {
|
|
34
|
+
const pointer = `<!-- See [POLARIS.md](POLARIS.md) for repo instructions -->\n`;
|
|
35
|
+
(0, node_fs_1.writeFileSync)(filePath, pointer + content, "utf8");
|
|
36
|
+
results.push({ file, outcome: "refused" });
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
// Accepted — attempt compression
|
|
40
|
+
const apiKey = options?.anthropicKey ?? process.env["ANTHROPIC_API_KEY"];
|
|
41
|
+
if (!apiKey) {
|
|
42
|
+
process.stderr.write(`Warning: ANTHROPIC_API_KEY not found. Skipping compression of ${file}.\n`);
|
|
43
|
+
results.push({ file, outcome: "skipped" });
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
let Anthropic;
|
|
47
|
+
try {
|
|
48
|
+
// @ts-ignore: @anthropic-ai/sdk may not be installed as a dependency
|
|
49
|
+
const mod = await import("@anthropic-ai/sdk");
|
|
50
|
+
Anthropic = mod.default;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
process.stderr.write(`Warning: @anthropic-ai/sdk not installed. Skipping compression of ${file}.\n`);
|
|
54
|
+
results.push({ file, outcome: "skipped" });
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const client = new Anthropic({ apiKey });
|
|
58
|
+
const response = await client.messages.create({
|
|
59
|
+
model: "claude-opus-4-5",
|
|
60
|
+
max_tokens: 1024,
|
|
61
|
+
messages: [
|
|
62
|
+
{
|
|
63
|
+
role: "user",
|
|
64
|
+
content: `Distill the following agent instructions into concise bullet-point rules that preserve all essential guidance:\n\n${content}`,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
const distilled = response.content
|
|
69
|
+
.filter((b) => b.type === "text")
|
|
70
|
+
.map((b) => b.text)
|
|
71
|
+
.join("\n");
|
|
72
|
+
const now = options?.now ?? new Date();
|
|
73
|
+
const dateStr = formatDate(now);
|
|
74
|
+
const genesisPath = `smartdocs/doctrine/active/${dateStr}-genesis-agent-doctrine.md`;
|
|
75
|
+
const genesisFullPath = (0, node_path_1.join)(repoRoot, genesisPath);
|
|
76
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(repoRoot, "smartdocs/doctrine/active"), { recursive: true });
|
|
77
|
+
(0, node_fs_1.writeFileSync)(genesisFullPath, distilled, "utf8");
|
|
78
|
+
const thinPointer = `# Agent Instructions\n\nRead [POLARIS.md](POLARIS.md) before beginning any work.\n\n` +
|
|
79
|
+
`<!-- genesis doctrine archived: ${genesisPath} -->\n`;
|
|
80
|
+
(0, node_fs_1.writeFileSync)(filePath, thinPointer, "utf8");
|
|
81
|
+
results.push({ file, outcome: "compressed", genesisPath });
|
|
82
|
+
}
|
|
83
|
+
return results;
|
|
84
|
+
}
|
|
@@ -100,11 +100,10 @@ function appendInstructionProvenance(repoRoot, records) {
|
|
|
100
100
|
};
|
|
101
101
|
(0, node_fs_1.writeFileSync)(provenancePath, `${JSON.stringify(updated, null, 2)}\n`, "utf-8");
|
|
102
102
|
}
|
|
103
|
-
function handleInstructionFiles(plan, inventory) {
|
|
103
|
+
function handleInstructionFiles(plan, inventory, repoRoot) {
|
|
104
104
|
if (plan.dry_run) {
|
|
105
105
|
return Promise.resolve();
|
|
106
106
|
}
|
|
107
|
-
const repoRoot = (0, node_path_1.resolve)(process.cwd());
|
|
108
107
|
const doctrineExists = hasDoctrine(repoRoot);
|
|
109
108
|
const now = new Date().toISOString();
|
|
110
109
|
const candidates = Array.from(new Set(inventory.agent_instruction_files
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildAdoptionReport = buildAdoptionReport;
|
|
4
|
+
exports.writeAdoptionReport = writeAdoptionReport;
|
|
5
|
+
exports.printAdoptionReport = printAdoptionReport;
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
function buildAdoptionReport(options) {
|
|
9
|
+
const { install, graph, agents, now } = options;
|
|
10
|
+
const timestamp = (now ?? new Date()).toISOString();
|
|
11
|
+
return {
|
|
12
|
+
timestamp,
|
|
13
|
+
installed: install.installed,
|
|
14
|
+
alreadyPresent: install.alreadyPresent,
|
|
15
|
+
skipped: install.skipped,
|
|
16
|
+
conflicted: install.conflicted,
|
|
17
|
+
graphStatus: graph.status,
|
|
18
|
+
graphDetail: graph.stdout ?? graph.reason,
|
|
19
|
+
graphFollowUp: graph.followUpCommand,
|
|
20
|
+
agents,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function writeAdoptionReport(repoRoot, report) {
|
|
24
|
+
// Safe timestamp: replace ":" with "-" and "." with "-"
|
|
25
|
+
// e.g. "2026-06-09T12:00:00.000Z" → "adoption-report-2026-06-09T12-00-00-000Z.json"
|
|
26
|
+
const safeTimestamp = report.timestamp.replace(/:/g, "-").replace(/\./g, "-");
|
|
27
|
+
const fileName = `adoption-report-${safeTimestamp}.json`;
|
|
28
|
+
const runsDir = (0, node_path_1.join)(repoRoot, ".polaris", "runs");
|
|
29
|
+
if (!(0, node_fs_1.existsSync)(runsDir)) {
|
|
30
|
+
(0, node_fs_1.mkdirSync)(runsDir, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
const reportPath = (0, node_path_1.join)(runsDir, fileName);
|
|
33
|
+
(0, node_fs_1.writeFileSync)(reportPath, JSON.stringify(report, null, 2), "utf-8");
|
|
34
|
+
}
|
|
35
|
+
function printAdoptionReport(report) {
|
|
36
|
+
// Print structured summary to stdout
|
|
37
|
+
console.log("Adoption Report:");
|
|
38
|
+
console.log(` Timestamp: ${report.timestamp}`);
|
|
39
|
+
console.log("");
|
|
40
|
+
console.log("Asset Installation:");
|
|
41
|
+
console.log(` Installed: ${report.installed.length}`);
|
|
42
|
+
console.log(` Already Present: ${report.alreadyPresent.length}`);
|
|
43
|
+
console.log(` Skipped: ${report.skipped.length}`);
|
|
44
|
+
console.log(` Conflicted: ${report.conflicted.length}`);
|
|
45
|
+
console.log("");
|
|
46
|
+
console.log("Agent Files:");
|
|
47
|
+
if (report.agents.length === 0) {
|
|
48
|
+
console.log(" (none)");
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
for (const agent of report.agents) {
|
|
52
|
+
console.log(` ${agent.file}: ${agent.outcome}`);
|
|
53
|
+
if (agent.genesisPath) {
|
|
54
|
+
console.log(` -> archived to ${agent.genesisPath}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
console.log("");
|
|
59
|
+
console.log("Graph Build:");
|
|
60
|
+
console.log(` Status: ${report.graphStatus}`);
|
|
61
|
+
if (report.graphDetail) {
|
|
62
|
+
console.log(` Detail: ${report.graphDetail}`);
|
|
63
|
+
}
|
|
64
|
+
if (report.graphFollowUp) {
|
|
65
|
+
console.log(` Follow-up: ${report.graphFollowUp}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scaffoldRootSurfaces = scaffoldRootSurfaces;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
function isAncestorSymlink(repoRoot, relPath) {
|
|
7
|
+
const parts = relPath.split("/").filter(Boolean);
|
|
8
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
9
|
+
const ancestor = (0, node_path_1.resolve)(repoRoot, ...parts.slice(0, i + 1));
|
|
10
|
+
try {
|
|
11
|
+
const stat = (0, node_fs_1.lstatSync)(ancestor);
|
|
12
|
+
if (stat.isSymbolicLink())
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
if (err.code === "ENOENT")
|
|
17
|
+
return false;
|
|
18
|
+
throw err;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
function buildRootPolarisDraft() {
|
|
24
|
+
return [
|
|
25
|
+
"<!-- polaris:draft -->",
|
|
26
|
+
"# Repository",
|
|
27
|
+
"",
|
|
28
|
+
"> Polaris draft — review and remove the `<!-- polaris:draft -->` marker to promote.",
|
|
29
|
+
"",
|
|
30
|
+
"## Purpose",
|
|
31
|
+
"",
|
|
32
|
+
"<!-- One paragraph describing what this repository does. -->",
|
|
33
|
+
"",
|
|
34
|
+
"**Domain:** unknown",
|
|
35
|
+
"**Route:** /",
|
|
36
|
+
"**Taskchain:** unknown",
|
|
37
|
+
"",
|
|
38
|
+
"## What belongs here",
|
|
39
|
+
"",
|
|
40
|
+
"<!-- Describe the top-level assets and responsibilities. -->",
|
|
41
|
+
"",
|
|
42
|
+
"## What does not belong here",
|
|
43
|
+
"",
|
|
44
|
+
"<!-- Describe content that should be routed elsewhere. -->",
|
|
45
|
+
"",
|
|
46
|
+
"## Polaris Rules",
|
|
47
|
+
"",
|
|
48
|
+
"See [POLARIS_RULES.md](POLARIS_RULES.md) for canonical Polaris navigation and routing rules.",
|
|
49
|
+
"",
|
|
50
|
+
].join("\n");
|
|
51
|
+
}
|
|
52
|
+
function buildRootSummaryDraft() {
|
|
53
|
+
return [
|
|
54
|
+
"<!-- polaris:draft -->",
|
|
55
|
+
"# Summary — Repository Root",
|
|
56
|
+
"",
|
|
57
|
+
"> Polaris draft — review and remove the `<!-- polaris:draft -->` marker to promote.",
|
|
58
|
+
"",
|
|
59
|
+
"- Route: `/`",
|
|
60
|
+
"- Canon status: draft",
|
|
61
|
+
"- Linked doctrine: `POLARIS.md`",
|
|
62
|
+
"",
|
|
63
|
+
"## Notes",
|
|
64
|
+
"",
|
|
65
|
+
"<!-- Add concise context, references, and ownership details. -->",
|
|
66
|
+
"",
|
|
67
|
+
].join("\n");
|
|
68
|
+
}
|
|
69
|
+
function buildAgentPointer() {
|
|
70
|
+
return [
|
|
71
|
+
"# Agent Instructions",
|
|
72
|
+
"",
|
|
73
|
+
"This repository is managed by Polaris.",
|
|
74
|
+
"Read [POLARIS.md](POLARIS.md) before beginning any work.",
|
|
75
|
+
"",
|
|
76
|
+
].join("\n");
|
|
77
|
+
}
|
|
78
|
+
function buildCopilotPointer() {
|
|
79
|
+
return [
|
|
80
|
+
"# Copilot Instructions",
|
|
81
|
+
"",
|
|
82
|
+
"This repository is managed by Polaris.",
|
|
83
|
+
"Read [POLARIS.md](../../POLARIS.md) before beginning any work.",
|
|
84
|
+
"",
|
|
85
|
+
].join("\n");
|
|
86
|
+
}
|
|
87
|
+
function scaffoldRootSurfaces(repoRoot) {
|
|
88
|
+
const surfaces = [
|
|
89
|
+
{ relPath: "POLARIS.md", content: buildRootPolarisDraft() },
|
|
90
|
+
{ relPath: "SUMMARY.md", content: buildRootSummaryDraft() },
|
|
91
|
+
{ relPath: "CLAUDE.md", content: buildAgentPointer() },
|
|
92
|
+
{ relPath: "AGENTS.md", content: buildAgentPointer() },
|
|
93
|
+
{ relPath: ".github/copilot-instructions.md", content: buildCopilotPointer() },
|
|
94
|
+
];
|
|
95
|
+
const created = [];
|
|
96
|
+
const skipped = [];
|
|
97
|
+
for (const { relPath, content } of surfaces) {
|
|
98
|
+
if (isAncestorSymlink(repoRoot, relPath)) {
|
|
99
|
+
process.stderr.write(`Skipping root surface inside symlinked path: ${relPath}\n`);
|
|
100
|
+
skipped.push(relPath);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const absPath = (0, node_path_1.join)(repoRoot, relPath);
|
|
104
|
+
if ((0, node_fs_1.existsSync)(absPath)) {
|
|
105
|
+
skipped.push(relPath);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const dir = (0, node_path_1.dirname)(absPath);
|
|
109
|
+
(0, node_fs_1.mkdirSync)(dir, { recursive: true });
|
|
110
|
+
(0, node_fs_1.writeFileSync)(absPath, content, "utf-8");
|
|
111
|
+
created.push(relPath);
|
|
112
|
+
}
|
|
113
|
+
return { created, skipped };
|
|
114
|
+
}
|
|
@@ -43,6 +43,17 @@ function buildSteps(inventory) {
|
|
|
43
43
|
requires_approval: false,
|
|
44
44
|
estimated_risk: "low",
|
|
45
45
|
}));
|
|
46
|
+
steps.push(createStep(order++, {
|
|
47
|
+
step_id: "workspace-root-surfaces",
|
|
48
|
+
phase: "A",
|
|
49
|
+
category: "scaffold",
|
|
50
|
+
action: "create",
|
|
51
|
+
dest_path: "CLAUDE.md, AGENTS.md, .github/copilot-instructions.md",
|
|
52
|
+
description: "Create root POLARIS.md, SUMMARY.md, and thin-pointer agent instruction files if missing.",
|
|
53
|
+
destructive: false,
|
|
54
|
+
requires_approval: false,
|
|
55
|
+
estimated_risk: "low",
|
|
56
|
+
}));
|
|
46
57
|
for (const candidate of inventory.smartdocs_candidates) {
|
|
47
58
|
steps.push(createStep(order++, {
|
|
48
59
|
step_id: `smartdocs-migrate-${order.toString().padStart(3, "0")}`,
|
package/dist/cli/init.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.detectRepoState = void 0;
|
|
4
4
|
exports.runAdoptionAtlas = runAdoptionAtlas;
|
|
5
|
+
exports.isBeyondSymlink = isBeyondSymlink;
|
|
5
6
|
exports.finalizeAdoption = finalizeAdoption;
|
|
6
7
|
exports.runInit = runInit;
|
|
7
8
|
exports.createInitCommand = createInitCommand;
|
|
@@ -18,6 +19,10 @@ const adopt_cognition_js_1 = require("./adopt-cognition.js");
|
|
|
18
19
|
const adopt_smartdocs_js_1 = require("./adopt-smartdocs.js");
|
|
19
20
|
const index_js_1 = require("../map/index.js");
|
|
20
21
|
const adopt_instructions_js_1 = require("./adopt-instructions.js");
|
|
22
|
+
const adopt_workspace_js_1 = require("./adopt-workspace.js");
|
|
23
|
+
const adopt_assets_js_1 = require("./adopt-assets.js");
|
|
24
|
+
const adopt_genesis_js_1 = require("./adopt-genesis.js");
|
|
25
|
+
const adopt_report_js_1 = require("./adopt-report.js");
|
|
21
26
|
const artifact_policy_js_1 = require("../finalize/artifact-policy.js");
|
|
22
27
|
var init_detect_js_2 = require("./init-detect.js");
|
|
23
28
|
Object.defineProperty(exports, "detectRepoState", { enumerable: true, get: function () { return init_detect_js_2.detectRepoState; } });
|
|
@@ -243,6 +248,26 @@ function updatePlanForFinalization(repoRoot, plan, now) {
|
|
|
243
248
|
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(repoRoot, ".polaris", "adoption-plan.json"), `${JSON.stringify(updatedPlan, null, 2)}\n`, "utf-8");
|
|
244
249
|
return updatedPlan;
|
|
245
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Returns true if any ancestor of relPath (from repoRoot) is a symlink.
|
|
253
|
+
* Prevents git from rejecting pathspecs that are "beyond a symbolic link".
|
|
254
|
+
*/
|
|
255
|
+
function isBeyondSymlink(repoRoot, relPath) {
|
|
256
|
+
const parts = relPath.split("/").filter(Boolean);
|
|
257
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
258
|
+
const ancestor = (0, node_path_1.resolve)(repoRoot, ...parts.slice(0, i + 1));
|
|
259
|
+
try {
|
|
260
|
+
if ((0, node_fs_1.lstatSync)(ancestor).isSymbolicLink()) {
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
// ancestor doesn't exist — can't be a symlink
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
246
271
|
function stageAdoptionOutputs(repoRoot, plan) {
|
|
247
272
|
const stagePaths = new Set([
|
|
248
273
|
".polaris/adoption-plan.json",
|
|
@@ -252,6 +277,9 @@ function stageAdoptionOutputs(repoRoot, plan) {
|
|
|
252
277
|
".polaris/map",
|
|
253
278
|
"POLARIS.md",
|
|
254
279
|
"SUMMARY.md",
|
|
280
|
+
"CLAUDE.md",
|
|
281
|
+
"AGENTS.md",
|
|
282
|
+
".github/copilot-instructions.md",
|
|
255
283
|
".gitignore",
|
|
256
284
|
]);
|
|
257
285
|
for (const step of plan.steps) {
|
|
@@ -262,9 +290,19 @@ function stageAdoptionOutputs(repoRoot, plan) {
|
|
|
262
290
|
stagePaths.add(step.dest_path);
|
|
263
291
|
}
|
|
264
292
|
}
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
(0,
|
|
293
|
+
const validPaths = [];
|
|
294
|
+
for (const p of stagePaths) {
|
|
295
|
+
if (!(0, node_fs_1.existsSync)((0, node_path_1.resolve)(repoRoot, p))) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (isBeyondSymlink(repoRoot, p)) {
|
|
299
|
+
process.stderr.write(`Skipping adoption output inside symlinked path: ${p}\n`);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
validPaths.push(p);
|
|
303
|
+
}
|
|
304
|
+
if (validPaths.length > 0) {
|
|
305
|
+
(0, node_child_process_1.execFileSync)("git", ["add", "-A", "--", ...validPaths], { cwd: repoRoot, stdio: "pipe" });
|
|
268
306
|
}
|
|
269
307
|
}
|
|
270
308
|
function unstageRuntimeArtifacts(repoRoot) {
|
|
@@ -360,6 +398,13 @@ async function runInit(options = {}) {
|
|
|
360
398
|
if (options.adopt) {
|
|
361
399
|
if (!options.dryRun) {
|
|
362
400
|
writeAdoptionConfigLock(repoRoot, configPath, existing, detected, detectedRepoAnalysis);
|
|
401
|
+
// Phase A: scaffold root surfaces before inventory scan so doctrineExists check in
|
|
402
|
+
// instruction reconciliation sees POLARIS.md at runtime.
|
|
403
|
+
const scaffoldFn = options.scaffoldRootSurfaces ?? adopt_workspace_js_1.scaffoldRootSurfaces;
|
|
404
|
+
const scaffoldResult = scaffoldFn(repoRoot);
|
|
405
|
+
if (scaffoldResult.created.length > 0) {
|
|
406
|
+
process.stdout.write(`Root surfaces created: ${scaffoldResult.created.join(", ")}\n`);
|
|
407
|
+
}
|
|
363
408
|
}
|
|
364
409
|
}
|
|
365
410
|
else {
|
|
@@ -451,19 +496,46 @@ async function runInit(options = {}) {
|
|
|
451
496
|
const migrationResult = (options.applySmartDocsMigration ?? applySmartDocsMigration)(repoRoot, inventory);
|
|
452
497
|
process.stdout.write(`SmartDocs migration step completed: moved ${migrationResult.moved}, skipped ${migrationResult.skipped}.\n`);
|
|
453
498
|
}
|
|
454
|
-
void (options.generateFolderCognition ?? adopt_cognition_js_1.generateFolderCognition)(adoptionArtifacts.plan, inventory);
|
|
499
|
+
void (options.generateFolderCognition ?? adopt_cognition_js_1.generateFolderCognition)(adoptionArtifacts.plan, inventory, repoRoot);
|
|
455
500
|
process.stdout.write("Folder cognition generation step completed.\n");
|
|
456
|
-
(0, adopt_instructions_js_1.handleInstructionFiles)(adoptionArtifacts.plan, inventory);
|
|
501
|
+
(0, adopt_instructions_js_1.handleInstructionFiles)(adoptionArtifacts.plan, inventory, repoRoot);
|
|
457
502
|
process.stdout.write("Instruction file handling step completed.\n");
|
|
503
|
+
// Phase B — install bundled workspace assets
|
|
504
|
+
const installFn = options.installWorkspaceAssets ?? adopt_assets_js_1.installWorkspaceAssets;
|
|
505
|
+
const workspaceDir = (0, node_path_1.resolve)(__dirname, "../workspace");
|
|
506
|
+
const installResult = installFn(repoRoot, workspaceDir);
|
|
507
|
+
process.stdout.write(`Workspace assets installed: ${installResult.installed.length} installed, ${installResult.alreadyPresent.length} already present.\n`);
|
|
508
|
+
const finalizeAdoptionFn = options.finalizeAdoption ?? finalizeAdoption;
|
|
458
509
|
if (adoptionArtifacts.plan.steps.some((step) => step.category === "stage")) {
|
|
459
|
-
|
|
510
|
+
await finalizeAdoptionFn(adoptionArtifacts.plan, {
|
|
460
511
|
repoRoot,
|
|
461
512
|
commit: options.commit,
|
|
462
513
|
now,
|
|
463
514
|
});
|
|
464
515
|
return;
|
|
465
516
|
}
|
|
466
|
-
|
|
517
|
+
// Phase C2 — graph build (automatic, non-blocking)
|
|
518
|
+
const graphBuildFn = options.runGraphBuild ?? adopt_assets_js_1.runGraphBuild;
|
|
519
|
+
const graphResult = graphBuildFn(repoRoot);
|
|
520
|
+
// Phase D — agent file reconciliation
|
|
521
|
+
const reconcileFn = options.reconcileAgentFiles ?? adopt_genesis_js_1.reconcileAgentFiles;
|
|
522
|
+
const agentResults = await reconcileFn(repoRoot);
|
|
523
|
+
// Phase E — adoption report
|
|
524
|
+
const adoptReport = (0, adopt_report_js_1.buildAdoptionReport)({ install: installResult, graph: graphResult, agents: agentResults });
|
|
525
|
+
(0, adopt_report_js_1.printAdoptionReport)(adoptReport);
|
|
526
|
+
(0, adopt_report_js_1.writeAdoptionReport)(repoRoot, adoptReport);
|
|
527
|
+
// Phase F — safe stage + optional commit
|
|
528
|
+
stageAdoptionOutputs(repoRoot, adoptionArtifacts.plan);
|
|
529
|
+
unstageRuntimeArtifacts(repoRoot);
|
|
530
|
+
printAdoptionSummary(repoRoot, adoptionArtifacts.plan);
|
|
531
|
+
if (options.commit) {
|
|
532
|
+
const message = createAdoptionCommitMessage(adoptionArtifacts.plan);
|
|
533
|
+
(0, node_child_process_1.execFileSync)("git", ["commit", "-m", message], { cwd: repoRoot, stdio: "pipe" });
|
|
534
|
+
process.stdout.write(`Adoption commit created: ${message}\n`);
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
process.stdout.write("Adoption changes staged. Review with `git diff --cached` and commit when ready.\n");
|
|
538
|
+
}
|
|
467
539
|
}
|
|
468
540
|
/**
|
|
469
541
|
* Registers the `init` subcommand on a Commander program.
|