@lsctech/polaris 0.3.28 → 0.3.29
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/index.js +14 -0
- package/dist/loop/dispatch.js +8 -2
- package/dist/loop/simplicity.js +34 -0
- package/dist/loop/worker-packet.js +1 -0
- package/dist/loop/worker-prompt.js +28 -0
- package/package.json +1 -1
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 simplicity_js_1 = require("../loop/simplicity.js");
|
|
30
31
|
function resolveStateFile(repoRoot, explicit) {
|
|
31
32
|
if (explicit)
|
|
32
33
|
return (0, node_path_1.resolve)(explicit);
|
|
@@ -108,6 +109,19 @@ function createPolarisCommand(options = {}) {
|
|
|
108
109
|
repoRoot,
|
|
109
110
|
}));
|
|
110
111
|
program.addCommand((0, adopt_command_js_1.createAdoptCommand)({ repoRoot }));
|
|
112
|
+
program
|
|
113
|
+
.command("simplicity")
|
|
114
|
+
.description("View or override the simplicity discipline mode for the active run")
|
|
115
|
+
.option("--bypass", "Omit the discipline ladder from worker prompts for this run")
|
|
116
|
+
.option("--restore", "Re-enable the discipline ladder (clear bypass)")
|
|
117
|
+
.option("--state-file <path>", "Override path to current-state.json")
|
|
118
|
+
.action((cmdOptions) => {
|
|
119
|
+
(0, simplicity_js_1.runSimplicityCommand)({
|
|
120
|
+
bypass: !!cmdOptions.bypass,
|
|
121
|
+
restore: !!cmdOptions.restore,
|
|
122
|
+
stateFile: resolveStateFile(repoRoot, cmdOptions.stateFile),
|
|
123
|
+
});
|
|
124
|
+
});
|
|
111
125
|
const agentCmd = new commander_1.Command("agent").description("Manage Polaris agent provider configuration");
|
|
112
126
|
agentCmd.addCommand(new commander_1.Command("setup")
|
|
113
127
|
.description("Configure agent providers per role (librarian, foreman, worker, analyst)")
|
package/dist/loop/dispatch.js
CHANGED
|
@@ -15,6 +15,11 @@ const body_parser_js_1 = require("./body-parser.js");
|
|
|
15
15
|
const loader_js_1 = require("../config/loader.js");
|
|
16
16
|
const store_js_1 = require("../cluster-state/store.js");
|
|
17
17
|
const worker_prompt_js_1 = require("./worker-prompt.js");
|
|
18
|
+
function resolveSimplicityMode(state, config) {
|
|
19
|
+
if (state.simplicity_bypass)
|
|
20
|
+
return "off";
|
|
21
|
+
return config?.simplicity?.mode ?? "full";
|
|
22
|
+
}
|
|
18
23
|
const dispatch_boundary_js_1 = require("./dispatch-boundary.js");
|
|
19
24
|
const run_bootstrap_js_1 = require("./run-bootstrap.js");
|
|
20
25
|
const ledger_js_1 = require("./ledger.js");
|
|
@@ -659,7 +664,7 @@ function selectChild(state, requestedChild) {
|
|
|
659
664
|
* @param resultFile - Optional path for the expected result file; non-absolute paths are resolved against `repoRoot`
|
|
660
665
|
* @returns The constructed WorkerPacket ready for dispatch
|
|
661
666
|
*/
|
|
662
|
-
function buildPacket(state, childId, stateFile, telemetryFile, repoRoot, resultFile) {
|
|
667
|
+
function buildPacket(state, childId, stateFile, telemetryFile, repoRoot, resultFile, config) {
|
|
663
668
|
const childMeta = state.open_children_meta?.[childId];
|
|
664
669
|
// Hydrate body from cluster snapshot when runtime state lacks it.
|
|
665
670
|
const cachedBody = childMeta?.body;
|
|
@@ -694,6 +699,7 @@ function buildPacket(state, childId, stateFile, telemetryFile, repoRoot, resultF
|
|
|
694
699
|
allowedScope: resolvedScope.length > 0 ? resolvedScope : undefined,
|
|
695
700
|
maxConcurrentWorkers: 1,
|
|
696
701
|
promptMode: (0, worker_prompt_js_1.selectPromptMode)(childId, state),
|
|
702
|
+
simplicityMode: resolveSimplicityMode(state, config),
|
|
697
703
|
resultFile: canonicalPath(absoluteResultFile(repoRoot, resultFile)),
|
|
698
704
|
});
|
|
699
705
|
}
|
|
@@ -912,7 +918,7 @@ function runLoopDispatch(options) {
|
|
|
912
918
|
step_cursor: "dispatch",
|
|
913
919
|
dispatch_boundary: (0, dispatch_boundary_js_1.advanceDispatchEpoch)(state.dispatch_boundary, childId),
|
|
914
920
|
};
|
|
915
|
-
const packet = buildPacket(preliminaryState, childId, options.stateFile, telemetryFile, options.repoRoot, canonicalResultFile);
|
|
921
|
+
const packet = buildPacket(preliminaryState, childId, options.stateFile, telemetryFile, options.repoRoot, canonicalResultFile, loadedConfig);
|
|
916
922
|
const packetFailure = detectPacketGenerationFailure(packet);
|
|
917
923
|
if (packetFailure) {
|
|
918
924
|
appendTelemetry(telemetryFile, {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runSimplicityCommand = runSimplicityCommand;
|
|
4
|
+
const checkpoint_js_1 = require("./checkpoint.js");
|
|
5
|
+
/**
|
|
6
|
+
* Handles `polaris simplicity [--bypass | --restore]`.
|
|
7
|
+
*
|
|
8
|
+
* --bypass: sets simplicity_bypass: true for the active run (omits discipline ladder from worker prompts).
|
|
9
|
+
* --restore: clears simplicity_bypass (re-enables the ladder).
|
|
10
|
+
* bare: prints current bypass status without mutating state.
|
|
11
|
+
*/
|
|
12
|
+
function runSimplicityCommand(opts) {
|
|
13
|
+
if (!opts.bypass && !opts.restore) {
|
|
14
|
+
const state = (0, checkpoint_js_1.readState)(opts.stateFile);
|
|
15
|
+
if (state.simplicity_bypass) {
|
|
16
|
+
console.log("Simplicity bypass: on — discipline ladder omitted for this run.");
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
console.log("Simplicity bypass: off — discipline mode comes from project config/default.");
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const state = (0, checkpoint_js_1.readState)(opts.stateFile);
|
|
24
|
+
if (opts.bypass) {
|
|
25
|
+
state.simplicity_bypass = true;
|
|
26
|
+
(0, checkpoint_js_1.writeStateAtomic)(opts.stateFile, state);
|
|
27
|
+
console.log("Simplicity bypass enabled — discipline ladder will be omitted from worker prompts for this run.");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// restore
|
|
31
|
+
state.simplicity_bypass = false;
|
|
32
|
+
(0, checkpoint_js_1.writeStateAtomic)(opts.stateFile, state);
|
|
33
|
+
console.log("Simplicity bypass cleared — discipline ladder will be injected into worker prompts.");
|
|
34
|
+
}
|
|
@@ -57,6 +57,29 @@ function selectPromptMode(childId, state, override) {
|
|
|
57
57
|
return override;
|
|
58
58
|
return isNarrowChild(childId, state) ? 'compact' : 'full';
|
|
59
59
|
}
|
|
60
|
+
// ── Discipline section ────────────────────────────────────────────────────────
|
|
61
|
+
function buildDisciplineSection(mode) {
|
|
62
|
+
if (mode === "off")
|
|
63
|
+
return [];
|
|
64
|
+
const lines = [
|
|
65
|
+
"## Implementation Discipline",
|
|
66
|
+
"Before writing code, stop at the first rung that holds:",
|
|
67
|
+
"",
|
|
68
|
+
"1. Does this need to exist? → no: skip it (YAGNI)",
|
|
69
|
+
"2. Stdlib does it? → use it",
|
|
70
|
+
"3. Native platform feature? → use it",
|
|
71
|
+
"4. Installed dependency? → use it",
|
|
72
|
+
"5. One line? → one line",
|
|
73
|
+
"6. Only then: the minimum that works",
|
|
74
|
+
"",
|
|
75
|
+
"Lazy, not negligent: validation, error handling, security, and accessibility are never on the chopping block.",
|
|
76
|
+
];
|
|
77
|
+
if (mode === "full") {
|
|
78
|
+
lines.push("", "When you defer a simplification for later, mark it inline:", " // ponytail: <what you deferred and why>");
|
|
79
|
+
}
|
|
80
|
+
lines.push("");
|
|
81
|
+
return lines;
|
|
82
|
+
}
|
|
60
83
|
// ── Builder ───────────────────────────────────────────────────────────────────
|
|
61
84
|
/**
|
|
62
85
|
* Build a compact or full worker dispatch prompt.
|
|
@@ -80,6 +103,10 @@ function buildWorkerPrompt(input) {
|
|
|
80
103
|
lines.push('## Goal');
|
|
81
104
|
lines.push(input.goal.trim());
|
|
82
105
|
lines.push('');
|
|
106
|
+
// ── Implementation Discipline ─────────────────────────────────────────────
|
|
107
|
+
for (const line of buildDisciplineSection(input.simplicityMode ?? 'full')) {
|
|
108
|
+
lines.push(line);
|
|
109
|
+
}
|
|
83
110
|
// ── Scope ─────────────────────────────────────────────────────────────────
|
|
84
111
|
lines.push('## Scope');
|
|
85
112
|
if (input.scopeTouch.length > 0) {
|
|
@@ -256,5 +283,6 @@ function buildPromptFromPacketInput(input) {
|
|
|
256
283
|
telemetryFile: input.telemetryFile,
|
|
257
284
|
issueContext: input.issueContext,
|
|
258
285
|
mode: input.mode,
|
|
286
|
+
simplicityMode: input.simplicityMode,
|
|
259
287
|
});
|
|
260
288
|
}
|