@lsctech/polaris 0.1.0
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/README.md +87 -0
- package/dist/__mocks__/tool-server-linear.js +34 -0
- package/dist/cli/adopt-approve.js +60 -0
- package/dist/cli/adopt-cognition.js +199 -0
- package/dist/cli/adopt-instructions.js +143 -0
- package/dist/cli/adopt-rules.js +169 -0
- package/dist/cli/adopt-scan.js +25 -0
- package/dist/cli/adopt-smartdocs.js +192 -0
- package/dist/cli/adoption-inventory.js +350 -0
- package/dist/cli/adoption-plan.js +222 -0
- package/dist/cli/args.js +28 -0
- package/dist/cli/args.test.js +30 -0
- package/dist/cli/branding.js +41 -0
- package/dist/cli/graph.js +358 -0
- package/dist/cli/index.js +127 -0
- package/dist/cli/index.test.js +162 -0
- package/dist/cli/init-detect.js +61 -0
- package/dist/cli/init.js +492 -0
- package/dist/cli/init.test.js +259 -0
- package/dist/cli/librarian.js +32 -0
- package/dist/cli/medic.js +96 -0
- package/dist/cli/startup.test.js +23 -0
- package/dist/cli/tracker.js +130 -0
- package/dist/cli/tracker.test.js +126 -0
- package/dist/cli/version.js +10 -0
- package/dist/cli/version.test.js +11 -0
- package/dist/cli/worker.js +287 -0
- package/dist/cluster-state/fixtures/test-clusters.json +19 -0
- package/dist/cluster-state/store.js +302 -0
- package/dist/cluster-state/store.test.js +145 -0
- package/dist/cluster-state/types.js +2 -0
- package/dist/cognition/archive.js +158 -0
- package/dist/cognition/closeout-librarian-types.js +161 -0
- package/dist/cognition/cognition.test.js +623 -0
- package/dist/cognition/index.js +41 -0
- package/dist/cognition/librarian-dispatch.js +391 -0
- package/dist/cognition/librarian-dispatch.test.js +247 -0
- package/dist/cognition/librarian-packet.js +313 -0
- package/dist/cognition/librarian-types.js +57 -0
- package/dist/cognition/route-cognition-delta.js +350 -0
- package/dist/cognition/summary-delta.js +279 -0
- package/dist/cognition/validate.js +162 -0
- package/dist/config/defaults.js +98 -0
- package/dist/config/doctor.js +273 -0
- package/dist/config/index.js +14 -0
- package/dist/config/loader.js +58 -0
- package/dist/config/provider-detect.js +60 -0
- package/dist/config/provider-detect.test.js +119 -0
- package/dist/config/schema.js +2 -0
- package/dist/config/show.js +44 -0
- package/dist/config/show.test.js +42 -0
- package/dist/config/validator.js +675 -0
- package/dist/config/validator.test.js +77 -0
- package/dist/docs/canon-check.js +334 -0
- package/dist/docs/canon-check.test.js +207 -0
- package/dist/docs/doctrine.js +133 -0
- package/dist/docs/doctrine.test.js +139 -0
- package/dist/docs/index.js +168 -0
- package/dist/docs/index.test.js +83 -0
- package/dist/docs/ingest.js +295 -0
- package/dist/docs/ingest.test.js +71 -0
- package/dist/docs/migrate.js +165 -0
- package/dist/docs/migrate.test.js +136 -0
- package/dist/docs/seed-instructions.js +147 -0
- package/dist/docs/seed-instructions.test.js +137 -0
- package/dist/docs/validate-instructions.js +267 -0
- package/dist/docs/validate-instructions.test.js +238 -0
- package/dist/finalize/artifact-policy.js +214 -0
- package/dist/finalize/artifact-policy.test.js +84 -0
- package/dist/finalize/delivery-integrity.js +141 -0
- package/dist/finalize/finalize.test.js +210 -0
- package/dist/finalize/github.js +41 -0
- package/dist/finalize/index.js +474 -0
- package/dist/finalize/linear.js +213 -0
- package/dist/finalize/run-report.js +47 -0
- package/dist/finalize/steps/01-map-update.js +11 -0
- package/dist/finalize/steps/02-map-validate.js +11 -0
- package/dist/finalize/steps/03-schema-validate.js +11 -0
- package/dist/finalize/steps/04-run-checks.js +118 -0
- package/dist/finalize/steps/05-generate-report.js +14 -0
- package/dist/finalize/steps/06-commit.js +39 -0
- package/dist/finalize/steps/07-push.js +10 -0
- package/dist/finalize/steps/08-create-pr.js +9 -0
- package/dist/finalize/steps/09-update-state.js +9 -0
- package/dist/finalize/steps/10-append-jsonl.js +23 -0
- package/dist/finalize/steps/11-update-linear.js +22 -0
- package/dist/finalize/steps/12-archive.js +21 -0
- package/dist/graph/adapter/c/adapter.js +45 -0
- package/dist/graph/adapter/c/extract.js +135 -0
- package/dist/graph/adapter/c/index.js +10 -0
- package/dist/graph/adapter/c/runtime.js +67 -0
- package/dist/graph/adapter/cpp/adapter.js +45 -0
- package/dist/graph/adapter/cpp/extract.js +159 -0
- package/dist/graph/adapter/cpp/index.js +10 -0
- package/dist/graph/adapter/cpp/runtime.js +61 -0
- package/dist/graph/adapter/csharp/adapter.js +45 -0
- package/dist/graph/adapter/csharp/extract.js +127 -0
- package/dist/graph/adapter/csharp/index.js +10 -0
- package/dist/graph/adapter/csharp/runtime.js +61 -0
- package/dist/graph/adapter/dart/adapter.js +56 -0
- package/dist/graph/adapter/dart/extract.js +130 -0
- package/dist/graph/adapter/dart/index.js +10 -0
- package/dist/graph/adapter/dart/runtime.js +61 -0
- package/dist/graph/adapter/go/adapter.js +45 -0
- package/dist/graph/adapter/go/extract.js +112 -0
- package/dist/graph/adapter/go/index.js +10 -0
- package/dist/graph/adapter/go/runtime.js +58 -0
- package/dist/graph/adapter/kotlin-java/extract-common.js +83 -0
- package/dist/graph/adapter/kotlin-java/index.js +15 -0
- package/dist/graph/adapter/kotlin-java/java-adapter.js +45 -0
- package/dist/graph/adapter/kotlin-java/java-extract.js +42 -0
- package/dist/graph/adapter/kotlin-java/kotlin-adapter.js +48 -0
- package/dist/graph/adapter/kotlin-java/kotlin-extract.js +58 -0
- package/dist/graph/adapter/kotlin-java/runtime.js +75 -0
- package/dist/graph/adapter/python/adapter.js +45 -0
- package/dist/graph/adapter/python/extract.js +121 -0
- package/dist/graph/adapter/python/index.js +10 -0
- package/dist/graph/adapter/python/runtime.js +70 -0
- package/dist/graph/adapter/registry.js +82 -0
- package/dist/graph/adapter/rust/adapter.js +45 -0
- package/dist/graph/adapter/rust/extract.js +110 -0
- package/dist/graph/adapter/rust/index.js +10 -0
- package/dist/graph/adapter/rust/runtime.js +74 -0
- package/dist/graph/adapter/shell/adapter.js +34 -0
- package/dist/graph/adapter/shell/extract.js +98 -0
- package/dist/graph/adapter/shell/index.js +8 -0
- package/dist/graph/adapter/svelte/adapter.js +91 -0
- package/dist/graph/adapter/svelte/extract.js +41 -0
- package/dist/graph/adapter/svelte/index.js +8 -0
- package/dist/graph/adapter/swift/adapter.js +45 -0
- package/dist/graph/adapter/swift/extract.js +120 -0
- package/dist/graph/adapter/swift/index.js +10 -0
- package/dist/graph/adapter/swift/runtime.js +70 -0
- package/dist/graph/adapter/types.js +2 -0
- package/dist/graph/adapter/typescript-javascript/adapter.js +72 -0
- package/dist/graph/adapter/typescript-javascript/extract.js +115 -0
- package/dist/graph/adapter/typescript-javascript/index.js +10 -0
- package/dist/graph/adapter/typescript-javascript/runtime.js +97 -0
- package/dist/graph/capability/index.js +105 -0
- package/dist/graph/governance.js +104 -0
- package/dist/graph/parser/extract.js +5 -0
- package/dist/graph/parser/loader.js +2 -0
- package/dist/graph/parser/pipeline.js +194 -0
- package/dist/graph/query/index.js +277 -0
- package/dist/graph/query/types.js +5 -0
- package/dist/graph/resolver/build-edges.js +211 -0
- package/dist/graph/resolver/index.js +23 -0
- package/dist/graph/resolver/resolve-imports.js +168 -0
- package/dist/graph/store/adapter.js +132 -0
- package/dist/graph/store/queries.js +124 -0
- package/dist/graph/store/types.js +4 -0
- package/dist/ignore/defaults.js +41 -0
- package/dist/ignore/parser.js +39 -0
- package/dist/lint/map-reference-validator.js +72 -0
- package/dist/loop/abort.js +188 -0
- package/dist/loop/abort.test.js +151 -0
- package/dist/loop/adapters/__tests__/terminal-cli.test.js +92 -0
- package/dist/loop/adapters/agent-subtask.js +137 -0
- package/dist/loop/adapters/agent-subtask.test.js +151 -0
- package/dist/loop/adapters/cli-subtask-bridge.js +108 -0
- package/dist/loop/adapters/index.js +9 -0
- package/dist/loop/adapters/registry.js +17 -0
- package/dist/loop/adapters/terminal-cli.js +403 -0
- package/dist/loop/adapters/types.js +2 -0
- package/dist/loop/adapters/worker-instructions.js +85 -0
- package/dist/loop/body-parser.js +226 -0
- package/dist/loop/bootstrap-packet.js +97 -0
- package/dist/loop/bootstrap-packet.test.js +171 -0
- package/dist/loop/branch-governance.js +54 -0
- package/dist/loop/budget.js +63 -0
- package/dist/loop/budget.test.js +163 -0
- package/dist/loop/checkpoint.js +325 -0
- package/dist/loop/compact-return.js +59 -0
- package/dist/loop/continue.js +645 -0
- package/dist/loop/continue.test.js +337 -0
- package/dist/loop/dispatch-boundary.js +335 -0
- package/dist/loop/dispatch-state.js +223 -0
- package/dist/loop/dispatch-state.test.js +186 -0
- package/dist/loop/dispatch.js +1236 -0
- package/dist/loop/dispatch.test.js +499 -0
- package/dist/loop/ephemeral-smoke.test.js +160 -0
- package/dist/loop/evidence-backfill.js +216 -0
- package/dist/loop/execution-adapter.js +141 -0
- package/dist/loop/execution-adapter.test.js +66 -0
- package/dist/loop/finalize-evidence.js +169 -0
- package/dist/loop/git-custody.js +250 -0
- package/dist/loop/impl-packet-input.js +38 -0
- package/dist/loop/index.js +270 -0
- package/dist/loop/ledger.js +49 -0
- package/dist/loop/ledger.test.js +127 -0
- package/dist/loop/lifecycle-dispatch.js +348 -0
- package/dist/loop/lifecycle-dispatch.test.js +318 -0
- package/dist/loop/lifecycle.js +93 -0
- package/dist/loop/lifecycle.test.js +150 -0
- package/dist/loop/orphan-recovery.js +276 -0
- package/dist/loop/orphan-recovery.test.js +236 -0
- package/dist/loop/parent.js +1566 -0
- package/dist/loop/parent.test.js +738 -0
- package/dist/loop/provider-sealed-packet.test.js +164 -0
- package/dist/loop/resume.js +295 -0
- package/dist/loop/resume.test.js +172 -0
- package/dist/loop/run-bootstrap.js +234 -0
- package/dist/loop/run-preflight.js +203 -0
- package/dist/loop/status.js +665 -0
- package/dist/loop/status.test.js +235 -0
- package/dist/loop/wait.js +86 -0
- package/dist/loop/worker-packet.js +406 -0
- package/dist/loop/worker-packet.test.js +243 -0
- package/dist/loop/worker-prompt.js +260 -0
- package/dist/loop/worker-prompt.test.js +247 -0
- package/dist/loop/worker.js +498 -0
- package/dist/loop/worker.test.js +372 -0
- package/dist/map/atlas.js +77 -0
- package/dist/map/backfill.js +171 -0
- package/dist/map/backfill.test.js +120 -0
- package/dist/map/index.js +255 -0
- package/dist/map/inference.js +73 -0
- package/dist/map/inference.test.js +35 -0
- package/dist/map/query.js +157 -0
- package/dist/map/query.test.js +174 -0
- package/dist/map/update.js +355 -0
- package/dist/map/update.test.js +67 -0
- package/dist/map/validate.js +153 -0
- package/dist/map/validate.test.js +90 -0
- package/dist/map/welfare.js +86 -0
- package/dist/mcp/lib/invoke.js +35 -0
- package/dist/mcp/lib/redact.js +24 -0
- package/dist/mcp/lib/redact.test.js +112 -0
- package/dist/mcp/lib/root.js +41 -0
- package/dist/mcp/lib/root.test.js +114 -0
- package/dist/mcp/server.js +15 -0
- package/dist/mcp/tools/claim-child.js +119 -0
- package/dist/mcp/tools/claim-child.test.js +69 -0
- package/dist/mcp/tools/current-state.js +73 -0
- package/dist/mcp/tools/current-state.test.js +114 -0
- package/dist/mcp/tools/dispatch-result.js +186 -0
- package/dist/mcp/tools/dispatch-result.test.js +109 -0
- package/dist/mcp/tools/index.js +222 -0
- package/dist/mcp/tools/index.test.js +172 -0
- package/dist/mcp/tools/linear.js +74 -0
- package/dist/mcp/tools/loop-continue.js +159 -0
- package/dist/mcp/tools/loop-continue.test.js +186 -0
- package/dist/mcp/tools/loop-dry-run.js +15 -0
- package/dist/mcp/tools/status.js +65 -0
- package/dist/medic/chart-id.js +75 -0
- package/dist/medic/chart-schema.js +139 -0
- package/dist/runs/index.js +119 -0
- package/dist/runs/index.test.js +184 -0
- package/dist/runs/ledger-tail.js +15 -0
- package/dist/runs/list.js +29 -0
- package/dist/runs/reconcile.js +74 -0
- package/dist/runs/show.js +10 -0
- package/dist/runtime/audit/logger.js +15 -0
- package/dist/runtime/audit/reader.js +42 -0
- package/dist/runtime/checkpoint.js +89 -0
- package/dist/runtime/continuation/confirmed.js +225 -0
- package/dist/runtime/continuation/confirmed.test.js +421 -0
- package/dist/runtime/continuation/dry-run.js +74 -0
- package/dist/runtime/execution-window.js +106 -0
- package/dist/runtime/scheduling/child-selector.js +16 -0
- package/dist/runtime/state.js +43 -0
- package/dist/runtime/status.js +46 -0
- package/dist/runtime/verification/envelope.js +80 -0
- package/dist/runtime/verification/fingerprint.js +26 -0
- package/dist/skill-packet/cli.test.js +105 -0
- package/dist/skill-packet/generator.js +225 -0
- package/dist/skill-packet/generator.test.js +159 -0
- package/dist/skill-packet/index.js +49 -0
- package/dist/skill-packet/types.js +2 -0
- package/dist/smartdocs-engine/audit.js +194 -0
- package/dist/smartdocs-engine/audit.test.js +122 -0
- package/dist/smartdocs-engine/canon-check.js +340 -0
- package/dist/smartdocs-engine/canon-check.test.js +234 -0
- package/dist/smartdocs-engine/doctrine.js +633 -0
- package/dist/smartdocs-engine/doctrine.test.js +374 -0
- package/dist/smartdocs-engine/index.js +456 -0
- package/dist/smartdocs-engine/index.test.js +82 -0
- package/dist/smartdocs-engine/ingest.js +495 -0
- package/dist/smartdocs-engine/ingest.test.js +163 -0
- package/dist/smartdocs-engine/migrate.js +217 -0
- package/dist/smartdocs-engine/migrate.test.js +200 -0
- package/dist/smartdocs-engine/seed-instructions.js +335 -0
- package/dist/smartdocs-engine/seed-instructions.test.js +275 -0
- package/dist/smartdocs-engine/smartdoc-ignore.js +258 -0
- package/dist/smartdocs-engine/smartdoc-ignore.test.js +146 -0
- package/dist/smartdocs-engine/validate-instructions.js +366 -0
- package/dist/smartdocs-engine/validate-instructions.test.js +283 -0
- package/dist/tracker/adapters/github/index.js +305 -0
- package/dist/tracker/adapters/jira/index.js +293 -0
- package/dist/tracker/adapters/linear/http-errors.test.js +51 -0
- package/dist/tracker/adapters/linear/index.js +621 -0
- package/dist/tracker/adapters/linear/index.test.js +238 -0
- package/dist/tracker/adapters/linear.js +50 -0
- package/dist/tracker/adapters/local/index.js +10 -0
- package/dist/tracker/adapters/local-file/index.js +159 -0
- package/dist/tracker/adapters/mcp-bridge.js +158 -0
- package/dist/tracker/adapters/mcp-bridge.test.js +12 -0
- package/dist/tracker/adapters/spec/index.js +146 -0
- package/dist/tracker/capabilities.js +2 -0
- package/dist/tracker/index.js +49 -0
- package/dist/tracker/lifecycle-policy.js +139 -0
- package/dist/tracker/lifecycle-transition.js +164 -0
- package/dist/tracker/local-graph.js +98 -0
- package/dist/tracker/migration.js +56 -0
- package/dist/tracker/schema.js +86 -0
- package/dist/tracker/sync/index.js +404 -0
- package/dist/tracker/sync/queue-store.js +95 -0
- package/dist/tracker/sync/queue-store.test.js +104 -0
- package/dist/tracker/types.js +11 -0
- package/dist/types/linear.js +3 -0
- package/dist/types/result-packet.js +12 -0
- package/dist/types/runtime-state.js +2 -0
- package/dist/types/work-contract.js +2 -0
- package/dist/utils/monotonic-timestamp.js +13 -0
- package/dist/utils/monotonic-timestamp.test.js +19 -0
- package/package.json +64 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePolarisRules = generatePolarisRules;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
function buildRepoOverview(inventory) {
|
|
7
|
+
const notes = inventory.architecture_notes.filter(Boolean);
|
|
8
|
+
const roots = inventory.source_roots.filter(Boolean);
|
|
9
|
+
const lines = [];
|
|
10
|
+
if (notes.length > 0) {
|
|
11
|
+
lines.push(notes.slice(0, 3).join(" "));
|
|
12
|
+
}
|
|
13
|
+
else if (roots.length > 0) {
|
|
14
|
+
lines.push(`Source roots: ${roots.slice(0, 4).join(", ")}.`);
|
|
15
|
+
}
|
|
16
|
+
return lines.join(" ").trim() || "Repository managed by Polaris.";
|
|
17
|
+
}
|
|
18
|
+
async function generatePolarisRules(repoRoot, inventory, options = {}) {
|
|
19
|
+
const { overwrite = true } = options;
|
|
20
|
+
const outputPath = (0, node_path_1.join)(repoRoot, "POLARIS_RULES.md");
|
|
21
|
+
if ((0, node_fs_1.existsSync)(outputPath) && !overwrite) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const overview = buildRepoOverview(inventory);
|
|
25
|
+
const content = [
|
|
26
|
+
"# Polaris Rules",
|
|
27
|
+
"",
|
|
28
|
+
"> This file is the single shared governance source for this Polaris-managed repository.",
|
|
29
|
+
"> Agent files (AGENTS.md, CLAUDE.md, etc.) are pointers to this file.",
|
|
30
|
+
"> This file is SmartDocs-ignored — it is bootstrap governance, not doctrine.",
|
|
31
|
+
"",
|
|
32
|
+
"## Repository Overview",
|
|
33
|
+
"",
|
|
34
|
+
overview,
|
|
35
|
+
"",
|
|
36
|
+
"---",
|
|
37
|
+
"",
|
|
38
|
+
"## Temporary Worker Doctrine",
|
|
39
|
+
"",
|
|
40
|
+
"Every model instance is a temporary occupant of a durable role. Roles persist; model",
|
|
41
|
+
"instances are disposable.",
|
|
42
|
+
"",
|
|
43
|
+
"A worker should arrive at a task knowing only:",
|
|
44
|
+
"- what job it is doing",
|
|
45
|
+
"- what files it may touch",
|
|
46
|
+
"- what route governs the work",
|
|
47
|
+
"- what validation proves completion",
|
|
48
|
+
"",
|
|
49
|
+
"If a worker requires broad repository context, the cognition structure has failed — not",
|
|
50
|
+
"the worker.",
|
|
51
|
+
"",
|
|
52
|
+
"---",
|
|
53
|
+
"",
|
|
54
|
+
"## Repository Memory Doctrine",
|
|
55
|
+
"",
|
|
56
|
+
"Polaris stores institutional memory in repository artifacts rather than model memory.",
|
|
57
|
+
"Knowledge should be discoverable through navigation, route cognition, SmartDocs,",
|
|
58
|
+
"summaries, commits, telemetry, and runtime artifacts.",
|
|
59
|
+
"",
|
|
60
|
+
"Workers should not rely on persistent model memory to perform assigned work.",
|
|
61
|
+
"",
|
|
62
|
+
"---",
|
|
63
|
+
"",
|
|
64
|
+
"## Navigation Before Retrieval",
|
|
65
|
+
"",
|
|
66
|
+
"Links are retrieval paths, not reading assignments.",
|
|
67
|
+
"",
|
|
68
|
+
"Workers should not read doctrine, charts, or supporting documents merely because they",
|
|
69
|
+
"exist.",
|
|
70
|
+
"",
|
|
71
|
+
"Expected behavior:",
|
|
72
|
+
"1. Attempt work",
|
|
73
|
+
"2. Encounter problem",
|
|
74
|
+
"3. Check local guidance",
|
|
75
|
+
"4. Match symptom",
|
|
76
|
+
"5. Retrieve relevant artifact",
|
|
77
|
+
"6. Continue",
|
|
78
|
+
"",
|
|
79
|
+
"Never preload all linked documents.",
|
|
80
|
+
"Never load all doctrine.",
|
|
81
|
+
"Never load all charts.",
|
|
82
|
+
"",
|
|
83
|
+
"Navigation precedes retrieval.",
|
|
84
|
+
"Retrieval precedes loading.",
|
|
85
|
+
"",
|
|
86
|
+
"---",
|
|
87
|
+
"",
|
|
88
|
+
"## Skill Command Routing",
|
|
89
|
+
"",
|
|
90
|
+
"When a Polaris skill command is received, load the skill packet before any other action.",
|
|
91
|
+
"Full routing table: `.polaris/skills/ROUTING.md`",
|
|
92
|
+
"",
|
|
93
|
+
"Recognized command forms use `<CLUSTER-ID>` as the work identifier:",
|
|
94
|
+
"",
|
|
95
|
+
"- `polaris-analyze <CLUSTER-ID>` / `run polaris-analyze on [issue] <CLUSTER-ID>`",
|
|
96
|
+
"- `polaris-run <CLUSTER-ID>` / `run polaris-run on [issue] <CLUSTER-ID>`",
|
|
97
|
+
"- `polaris-finalize` / `run polaris-finalize`",
|
|
98
|
+
"- `polaris-status` / `run polaris-status`",
|
|
99
|
+
"- `docs-ingest` / `run docs-ingest`",
|
|
100
|
+
"- `polaris-reconcile <CLUSTER-ID>` / `run polaris-reconcile on [issue] <CLUSTER-ID>`",
|
|
101
|
+
"- `polaris-catalog <CLUSTER-ID>` / `run polaris-catalog on [issue] <CLUSTER-ID>`",
|
|
102
|
+
"",
|
|
103
|
+
"When a recognized command is received:",
|
|
104
|
+
"1. Look up the target skill in `.polaris/skills/ROUTING.md`",
|
|
105
|
+
"2. Read `.polaris/skills/<target-skill>/SKILL.md` first — before any repo inspection",
|
|
106
|
+
"3. Run the bootloader command to obtain the runtime packet",
|
|
107
|
+
"4. Execute the skill's `chain.md` in strict step order",
|
|
108
|
+
"",
|
|
109
|
+
"---",
|
|
110
|
+
"",
|
|
111
|
+
"## Map-Query Rule",
|
|
112
|
+
"",
|
|
113
|
+
"The map is runtime infrastructure. Query results are model context.",
|
|
114
|
+
"",
|
|
115
|
+
"**Agents may query the map. Agents may not consume map artifacts.**",
|
|
116
|
+
"",
|
|
117
|
+
"Use:",
|
|
118
|
+
"```",
|
|
119
|
+
"polaris map query <path>",
|
|
120
|
+
"```",
|
|
121
|
+
"",
|
|
122
|
+
"Never read these files directly:",
|
|
123
|
+
"- `.polaris/map/file-routes.json`",
|
|
124
|
+
"- `.polaris/map/index.json`",
|
|
125
|
+
"- `.polaris/map/needs-review.json`",
|
|
126
|
+
"",
|
|
127
|
+
"These paths appear only in prohibition lists.",
|
|
128
|
+
"",
|
|
129
|
+
"---",
|
|
130
|
+
"",
|
|
131
|
+
"## Tracker-Agnostic Work Intake",
|
|
132
|
+
"",
|
|
133
|
+
"Work identifiers are opaque to the model. Polaris is tracker-agnostic.",
|
|
134
|
+
"",
|
|
135
|
+
"Work may originate from Linear, GitHub, a SmartDocs spec, a local work contract,",
|
|
136
|
+
"a manual prompt, or a future provider. The runtime resolves identifiers.",
|
|
137
|
+
"The model does not interpret or construct cluster identifiers.",
|
|
138
|
+
"",
|
|
139
|
+
"---",
|
|
140
|
+
"",
|
|
141
|
+
"## Runtime Boundaries",
|
|
142
|
+
"",
|
|
143
|
+
"- Resolve execution state before beginning work",
|
|
144
|
+
"- Follow the active cluster and child ordering",
|
|
145
|
+
"- Execute only the currently assigned child",
|
|
146
|
+
"- Do not expand scope outside the assigned child",
|
|
147
|
+
"- If blocked, stop and report the unblock condition",
|
|
148
|
+
"- Foreman orchestrates; Worker implements; Librarian reconciles",
|
|
149
|
+
"- A provider may occupy multiple roles, but role authority does not merge",
|
|
150
|
+
"",
|
|
151
|
+
"---",
|
|
152
|
+
"",
|
|
153
|
+
"## Canon Discovery",
|
|
154
|
+
"",
|
|
155
|
+
"Project canon is route-local.",
|
|
156
|
+
"",
|
|
157
|
+
"Use:",
|
|
158
|
+
"- `POLARIS.md` in the relevant route folder for operational guidance",
|
|
159
|
+
"- `SUMMARY.md` in the relevant route folder for informational context",
|
|
160
|
+
"- `polaris map query <path>` for route and ownership resolution",
|
|
161
|
+
"- Runtime state artifacts for execution state and resume handling",
|
|
162
|
+
"",
|
|
163
|
+
"Do not assume global repository context unless explicitly provided by the runtime.",
|
|
164
|
+
"",
|
|
165
|
+
].join("\n");
|
|
166
|
+
const dir = (0, node_path_1.dirname)(outputPath);
|
|
167
|
+
(0, node_fs_1.mkdirSync)(dir, { recursive: true });
|
|
168
|
+
(0, node_fs_1.writeFileSync)(outputPath, content, "utf-8");
|
|
169
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scanRepo = scanRepo;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const adoption_inventory_js_1 = require("./adoption-inventory.js");
|
|
7
|
+
function readExistingInventory(repoRoot) {
|
|
8
|
+
const inventoryPath = (0, node_path_1.join)(repoRoot, ".polaris", "adoption-inventory.json");
|
|
9
|
+
if (!(0, node_fs_1.existsSync)(inventoryPath)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse((0, node_fs_1.readFileSync)(inventoryPath, "utf-8"));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function scanRepo(repoRoot, options = {}) {
|
|
20
|
+
const existingInventory = options.rescan ? null : readExistingInventory(repoRoot);
|
|
21
|
+
if (existingInventory) {
|
|
22
|
+
return existingInventory;
|
|
23
|
+
}
|
|
24
|
+
return (0, adoption_inventory_js_1.scanAdoptionInventory)(repoRoot, { now: options.now, writeArtifact: true });
|
|
25
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateSmartDocs = migrateSmartDocs;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const COMPLETE_STATUSES = new Set(["completed", "skipped"]);
|
|
8
|
+
function isExcludedSourcePath(sourcePath) {
|
|
9
|
+
const normalized = sourcePath.replaceAll("\\", "/");
|
|
10
|
+
const basenameOnly = (0, node_path_1.basename)(normalized);
|
|
11
|
+
if (["README.md", "CHANGELOG.md", "LICENSE", "CONTRIBUTING.md"].includes(basenameOnly)) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (normalized === "smartdocs" ||
|
|
15
|
+
normalized.startsWith("smartdocs/") ||
|
|
16
|
+
normalized.startsWith("test/") ||
|
|
17
|
+
normalized.includes("/test/") ||
|
|
18
|
+
normalized.startsWith("fixtures/") ||
|
|
19
|
+
normalized.includes("/fixtures/") ||
|
|
20
|
+
normalized.startsWith("__mocks__/") ||
|
|
21
|
+
normalized.includes("/__mocks__/") ||
|
|
22
|
+
normalized.startsWith("generated/") ||
|
|
23
|
+
normalized.includes("/generated/") ||
|
|
24
|
+
normalized.startsWith("dist/") ||
|
|
25
|
+
normalized.includes("/dist/") ||
|
|
26
|
+
normalized.startsWith("build/") ||
|
|
27
|
+
normalized.includes("/build/") ||
|
|
28
|
+
normalized.startsWith("coverage/") ||
|
|
29
|
+
normalized.includes("/coverage/")) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
function loadPlan(repoRoot, fallback) {
|
|
35
|
+
const planPath = (0, node_path_1.join)(repoRoot, ".polaris", "adoption-plan.json");
|
|
36
|
+
if (!(0, node_fs_1.existsSync)(planPath)) {
|
|
37
|
+
return fallback;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse((0, node_fs_1.readFileSync)(planPath, "utf-8"));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return fallback;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function savePlan(repoRoot, plan) {
|
|
47
|
+
const planPath = (0, node_path_1.join)(repoRoot, ".polaris", "adoption-plan.json");
|
|
48
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(planPath), { recursive: true });
|
|
49
|
+
(0, node_fs_1.writeFileSync)(planPath, `${JSON.stringify(plan, null, 2)}\n`, "utf-8");
|
|
50
|
+
}
|
|
51
|
+
function loadExistingProvenance(repoRoot) {
|
|
52
|
+
const provenancePath = (0, node_path_1.join)(repoRoot, ".polaris", "adoption-provenance.json");
|
|
53
|
+
if (!(0, node_fs_1.existsSync)(provenancePath)) {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(provenancePath, "utf-8"));
|
|
58
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
59
|
+
return parsed;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// Fall through and rewrite a clean provenance file.
|
|
64
|
+
}
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
function saveProvenance(repoRoot, records) {
|
|
68
|
+
if (records.length === 0) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const provenancePath = (0, node_path_1.join)(repoRoot, ".polaris", "adoption-provenance.json");
|
|
72
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(provenancePath), { recursive: true });
|
|
73
|
+
const existing = loadExistingProvenance(repoRoot);
|
|
74
|
+
const prior = Array.isArray(existing.smartdocs_migrations) ? existing.smartdocs_migrations : [];
|
|
75
|
+
const updated = {
|
|
76
|
+
...existing,
|
|
77
|
+
updated_at: new Date().toISOString(),
|
|
78
|
+
smartdocs_migrations: [...prior, ...records],
|
|
79
|
+
};
|
|
80
|
+
(0, node_fs_1.writeFileSync)(provenancePath, `${JSON.stringify(updated, null, 2)}\n`, "utf-8");
|
|
81
|
+
}
|
|
82
|
+
function recordKey(record) {
|
|
83
|
+
return `${record.step_id}:${record.source_path}:${record.dest_path}`;
|
|
84
|
+
}
|
|
85
|
+
function existingRecordKeys(repoRoot) {
|
|
86
|
+
const provenance = loadExistingProvenance(repoRoot);
|
|
87
|
+
const records = Array.isArray(provenance.smartdocs_migrations) ? provenance.smartdocs_migrations : [];
|
|
88
|
+
const keys = new Set();
|
|
89
|
+
for (const record of records) {
|
|
90
|
+
if (typeof record === "object" &&
|
|
91
|
+
record !== null &&
|
|
92
|
+
!Array.isArray(record) &&
|
|
93
|
+
typeof record.step_id === "string" &&
|
|
94
|
+
typeof record.source_path === "string" &&
|
|
95
|
+
typeof record.dest_path === "string") {
|
|
96
|
+
keys.add(recordKey({
|
|
97
|
+
step_id: record.step_id,
|
|
98
|
+
source_path: record.source_path,
|
|
99
|
+
dest_path: record.dest_path,
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return keys;
|
|
104
|
+
}
|
|
105
|
+
function normalizeStatus(step, status, completedAt) {
|
|
106
|
+
return {
|
|
107
|
+
...step,
|
|
108
|
+
status,
|
|
109
|
+
completed_at: completedAt ?? step.completed_at,
|
|
110
|
+
error: status === "completed" || status === "skipped" ? undefined : step.error,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function migrateSmartDocs(plan, repoRoot = (0, node_path_1.resolve)(process.cwd())) {
|
|
114
|
+
const effectivePlan = loadPlan(repoRoot, plan);
|
|
115
|
+
const provenanceRecords = [];
|
|
116
|
+
const seenRecords = existingRecordKeys(repoRoot);
|
|
117
|
+
const now = new Date().toISOString();
|
|
118
|
+
for (let index = 0; index < effectivePlan.steps.length; index += 1) {
|
|
119
|
+
const step = effectivePlan.steps[index];
|
|
120
|
+
if (step.category !== "smartdocs-migrate" || COMPLETE_STATUSES.has(step.status)) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const sourcePath = step.source_path ?? "";
|
|
124
|
+
const destPath = step.dest_path ?? `smartdocs/raw/${(0, node_path_1.basename)(sourcePath || `step-${step.order}.md`)}`;
|
|
125
|
+
if (!sourcePath) {
|
|
126
|
+
effectivePlan.steps[index] = normalizeStatus(step, "skipped", now);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (isExcludedSourcePath(sourcePath)) {
|
|
130
|
+
effectivePlan.steps[index] = normalizeStatus(step, "skipped", now);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const sourceAbs = (0, node_path_1.join)(repoRoot, sourcePath);
|
|
134
|
+
const destAbs = (0, node_path_1.join)(repoRoot, destPath);
|
|
135
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(destAbs), { recursive: true });
|
|
136
|
+
if (!(0, node_fs_1.existsSync)(sourceAbs)) {
|
|
137
|
+
if ((0, node_fs_1.existsSync)(destAbs)) {
|
|
138
|
+
effectivePlan.steps[index] = normalizeStatus(step, "completed", step.completed_at ?? now);
|
|
139
|
+
const record = {
|
|
140
|
+
step_id: step.step_id,
|
|
141
|
+
source_path: sourcePath,
|
|
142
|
+
dest_path: destPath,
|
|
143
|
+
migrated_at: step.completed_at ?? now,
|
|
144
|
+
migration_run_id: effectivePlan.plan_id,
|
|
145
|
+
transport: "reconciled",
|
|
146
|
+
};
|
|
147
|
+
if (!seenRecords.has(recordKey(record))) {
|
|
148
|
+
provenanceRecords.push(record);
|
|
149
|
+
seenRecords.add(recordKey(record));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
effectivePlan.steps[index] = {
|
|
154
|
+
...step,
|
|
155
|
+
status: "skipped",
|
|
156
|
+
completed_at: now,
|
|
157
|
+
error: `source missing: ${sourcePath}`,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
let transport = "git mv";
|
|
163
|
+
try {
|
|
164
|
+
(0, node_child_process_1.execFileSync)("git", ["mv", "--", sourcePath, destPath], {
|
|
165
|
+
cwd: repoRoot,
|
|
166
|
+
stdio: "pipe",
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
process.stdout.write(`SmartDocs git mv failed for ${sourcePath}; falling back to fs.rename().\n`);
|
|
171
|
+
(0, node_fs_1.renameSync)(sourceAbs, destAbs);
|
|
172
|
+
transport = "fs.rename";
|
|
173
|
+
}
|
|
174
|
+
const record = {
|
|
175
|
+
step_id: step.step_id,
|
|
176
|
+
source_path: sourcePath,
|
|
177
|
+
dest_path: destPath,
|
|
178
|
+
migrated_at: now,
|
|
179
|
+
migration_run_id: effectivePlan.plan_id,
|
|
180
|
+
transport,
|
|
181
|
+
};
|
|
182
|
+
effectivePlan.steps[index] = normalizeStatus(step, "completed", now);
|
|
183
|
+
if (!seenRecords.has(recordKey(record))) {
|
|
184
|
+
provenanceRecords.push(record);
|
|
185
|
+
seenRecords.add(recordKey(record));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
savePlan(repoRoot, effectivePlan);
|
|
189
|
+
saveProvenance(repoRoot, provenanceRecords);
|
|
190
|
+
Object.assign(plan, effectivePlan);
|
|
191
|
+
return Promise.resolve();
|
|
192
|
+
}
|