@lsctech/polaris 0.4.1 → 0.4.2
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-rules.js +28 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/upgrade-command.js +26 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/steps/08-librarian-commit.md +2 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/steps/09-sealed-result.md +1 -1
- package/package.json +1 -1
package/dist/cli/adopt-rules.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractRepoOverview = extractRepoOverview;
|
|
4
|
+
exports.refreshPolarisRules = refreshPolarisRules;
|
|
3
5
|
exports.generatePolarisRules = generatePolarisRules;
|
|
4
6
|
const node_fs_1 = require("node:fs");
|
|
5
7
|
const node_path_1 = require("node:path");
|
|
@@ -186,6 +188,32 @@ function buildContentInline(overview) {
|
|
|
186
188
|
"",
|
|
187
189
|
].join("\n");
|
|
188
190
|
}
|
|
191
|
+
function extractRepoOverview(content) {
|
|
192
|
+
const match = content.match(/(?:^|\n)## Repository Overview\r?\n([\s\S]*?)(?:\r?\n## |$)/);
|
|
193
|
+
if (!match)
|
|
194
|
+
return "Repository managed by Polaris.";
|
|
195
|
+
const overview = match[1].trim().replace(/(^|\n)---\s*$/, "").trim();
|
|
196
|
+
return overview || "Repository managed by Polaris.";
|
|
197
|
+
}
|
|
198
|
+
function refreshPolarisRules(repoRoot, currentVersion) {
|
|
199
|
+
const outputPath = (0, node_path_1.join)(repoRoot, "POLARIS_RULES.md");
|
|
200
|
+
let content = "";
|
|
201
|
+
if ((0, node_fs_1.existsSync)(outputPath)) {
|
|
202
|
+
content = (0, node_fs_1.readFileSync)(outputPath, "utf-8");
|
|
203
|
+
}
|
|
204
|
+
const firstLine = content.split(/\r?\n/)[0] ?? "";
|
|
205
|
+
const versionMatch = firstLine.match(/^<!-- polaris-version: ([\d.]+-?[\w.]*) -->$/);
|
|
206
|
+
const existingVersion = versionMatch?.[1];
|
|
207
|
+
if (existingVersion === currentVersion) {
|
|
208
|
+
return { status: "skipped", path: outputPath };
|
|
209
|
+
}
|
|
210
|
+
const overview = extractRepoOverview(content);
|
|
211
|
+
const newContent = `<!-- polaris-version: ${currentVersion} -->\n${buildContentInline(overview)}`;
|
|
212
|
+
const dir = (0, node_path_1.dirname)(outputPath);
|
|
213
|
+
(0, node_fs_1.mkdirSync)(dir, { recursive: true });
|
|
214
|
+
(0, node_fs_1.writeFileSync)(outputPath, newContent, "utf-8");
|
|
215
|
+
return { status: "updated", path: outputPath };
|
|
216
|
+
}
|
|
189
217
|
async function generatePolarisRules(repoRoot, inventory, options = {}) {
|
|
190
218
|
const { overwrite = false, workspaceDir } = options;
|
|
191
219
|
const outputPath = (0, node_path_1.join)(repoRoot, "POLARIS_RULES.md");
|
package/dist/cli/index.js
CHANGED
|
@@ -27,6 +27,7 @@ const librarian_js_1 = require("./librarian.js");
|
|
|
27
27
|
const medic_js_1 = require("./medic.js");
|
|
28
28
|
const welfare_js_1 = require("../map/welfare.js");
|
|
29
29
|
const adopt_command_js_1 = require("./adopt-command.js");
|
|
30
|
+
const upgrade_command_js_1 = require("./upgrade-command.js");
|
|
30
31
|
const simplicity_js_1 = require("../loop/simplicity.js");
|
|
31
32
|
const autoresearch_js_1 = require("./autoresearch.js");
|
|
32
33
|
function resolveStateFile(repoRoot, explicit) {
|
|
@@ -110,6 +111,7 @@ function createPolarisCommand(options = {}) {
|
|
|
110
111
|
repoRoot,
|
|
111
112
|
}));
|
|
112
113
|
program.addCommand((0, adopt_command_js_1.createAdoptCommand)({ repoRoot }));
|
|
114
|
+
program.addCommand((0, upgrade_command_js_1.createUpgradeCommand)({ repoRoot }));
|
|
113
115
|
program.addCommand((0, autoresearch_js_1.createAutoresearchCommand)({ repoRoot }));
|
|
114
116
|
program
|
|
115
117
|
.command("simplicity")
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createUpgradeCommand = createUpgradeCommand;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const version_js_1 = require("./version.js");
|
|
6
|
+
const adopt_rules_js_1 = require("./adopt-rules.js");
|
|
7
|
+
function createUpgradeCommand(options = {}) {
|
|
8
|
+
const repoRoot = options.repoRoot ?? process.cwd();
|
|
9
|
+
const doRefresh = options.refresh ?? adopt_rules_js_1.refreshPolarisRules;
|
|
10
|
+
const getCurrentVersion = options.getVersion ?? version_js_1.getVersion;
|
|
11
|
+
const cmd = new commander_1.Command("upgrade")
|
|
12
|
+
.description("Refresh POLARIS_RULES.md to the current Polaris CLI version")
|
|
13
|
+
.option("-r, --repo-root <path>", "Repository root", repoRoot)
|
|
14
|
+
.action(async (cmdOptions) => {
|
|
15
|
+
const targetRoot = cmdOptions.repoRoot ?? repoRoot;
|
|
16
|
+
const version = getCurrentVersion();
|
|
17
|
+
const result = doRefresh(targetRoot, version);
|
|
18
|
+
if (result.status === "updated") {
|
|
19
|
+
process.stdout.write(`POLARIS_RULES.md updated to version ${version}\n`);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
process.stdout.write(`Already up to date (${version})\n`);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return cmd;
|
|
26
|
+
}
|
|
@@ -101,6 +101,8 @@ Capture the resulting commit SHA.
|
|
|
101
101
|
|
|
102
102
|
Record the commit SHA and list of committed files for step 09.
|
|
103
103
|
|
|
104
|
+
Use `git diff --cached --name-only` output as the source for `files_committed` — git outputs repo-relative paths (e.g., "src/cli/POLARIS.md"), which is the required format for the result JSON.
|
|
105
|
+
|
|
104
106
|
## Failure Handling
|
|
105
107
|
|
|
106
108
|
If `git commit` fails:
|
|
@@ -24,7 +24,7 @@ interface CloseoutLibrarianResult {
|
|
|
24
24
|
status: "success" | "partial" | "blocked" | "failure";
|
|
25
25
|
commit_sha: string | null;
|
|
26
26
|
commit_message: string;
|
|
27
|
-
files_committed: string[];
|
|
27
|
+
files_committed: string[]; // repo-relative paths (e.g., "src/cli/POLARIS.md")
|
|
28
28
|
drift_reconciliation: DriftReconciliationResult;
|
|
29
29
|
polaris_md_updates: FileUpdate[];
|
|
30
30
|
summary_md_updates: FileUpdate[];
|