@lsctech/polaris 0.3.22 → 0.3.23
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 +13 -0
- package/dist/cli/adopt-genesis.js +85 -4
- package/dist/cli/adopt-instructions.js +3 -3
- package/dist/cli/adopt-report.js +15 -1
- package/dist/cli/adopt-rules.js +44 -8
- package/dist/cli/adopt-workspace.js +2 -2
- package/dist/cli/adoption-inventory.js +5 -2
- package/dist/cli/init.js +5 -4
- package/dist/config/provider-detect.js +19 -2
- package/dist/workspace/.polaris/skills/ROUTING.md +4 -0
- package/dist/workspace/.polaris/skills/closeout-librarian/POLARIS.md +9 -8
- package/dist/workspace/.polaris/skills/docs-ingest/SKILL.md +2 -2
- package/dist/workspace/.polaris/skills/docs-ingest/chain.md +1 -1
- package/dist/workspace/.polaris/skills/docs-ingest/steps/04-place-and-link.md +5 -5
- package/dist/workspace/.polaris/skills/docs-ingest/steps/05-finalize-ingest.md +1 -1
- package/dist/workspace/.polaris/skills/docs-promote/SKILL.md +6 -6
- package/dist/workspace/.polaris/skills/docs-promote/chain.md +5 -5
- package/dist/workspace/.polaris/skills/docs-promote/steps/04-conflict-surface.md +1 -1
- package/dist/workspace/.polaris/skills/docs-promote/steps/06-execute-promote-deprecate.md +3 -3
- package/dist/workspace/{workspace/.polaris → .polaris}/skills/docs-review/SKILL.md +1 -1
- package/dist/workspace/{workspace/.polaris → .polaris}/skills/docs-triage/SKILL.md +1 -1
- package/dist/workspace/{workspace/.polaris → .polaris}/skills/docs-triage/chain.md +1 -1
- package/dist/workspace/.polaris/skills/polaris-analyze/SKILL.md +1 -1
- package/dist/workspace/.polaris/skills/polaris-analyze/chain.md +2 -2
- package/dist/workspace/.polaris/skills/polaris-analyze/issue-reconciliation.md +1 -1
- package/dist/workspace/.polaris/skills/polaris-analyze/linked-skills/repo-analysis.md +3 -4
- package/dist/workspace/.polaris/skills/polaris-analyze/steps/02-map-affected-code.md +2 -2
- package/dist/workspace/.polaris/skills/polaris-catalog/SKILL.md +5 -5
- package/dist/workspace/.polaris/skills/polaris-catalog/chain.md +3 -3
- package/dist/workspace/.polaris/skills/polaris-catalog/steps/04-classify-and-place.md +3 -3
- package/dist/workspace/.polaris/skills/polaris-reconcile/SKILL.md +2 -2
- package/dist/workspace/.polaris/skills/polaris-run/SKILL.md +1 -1
- package/dist/workspace/.polaris/skills/polaris-run/chain.md +17 -17
- package/dist/workspace/.polaris/skills/polaris-run/linked-skills/repo-analysis.md +3 -4
- package/dist/workspace/.polaris/skills/polaris-run/steps/01-orient-cluster.md +3 -3
- package/dist/workspace/.polaris/skills/polaris-run/steps/03-select-child.md +1 -1
- package/dist/workspace/.polaris/skills/polaris-run/steps/06-commit-and-update-linear.md +2 -2
- package/dist/workspace/.polaris/skills/polaris-run/steps/07-decide-continuation.md +3 -3
- package/dist/workspace/.polaris/skills/polaris-run/steps/08-closeout-librarian.md +1 -1
- package/dist/workspace/.polaris/skills/polaris-run/steps/08-final-delivery.md +2 -2
- package/dist/workspace/.polaris/skills/polaris-run/steps/09-final-delivery.md +1 -1
- package/dist/workspace/.polaris/skills/polaris-tools/README.md +1 -1
- package/dist/workspace/POLARIS_RULES.md +169 -0
- package/package.json +3 -2
- package/dist/workspace/workspace/.polaris/roles/analyst.md +0 -38
- package/dist/workspace/workspace/.polaris/roles/closeout-librarian.md +0 -122
- package/dist/workspace/workspace/.polaris/roles/cognition-librarian.md +0 -37
- package/dist/workspace/workspace/.polaris/roles/finalizer.md +0 -45
- package/dist/workspace/workspace/.polaris/roles/foreman.md +0 -165
- package/dist/workspace/workspace/.polaris/roles/librarian.md +0 -74
- package/dist/workspace/workspace/.polaris/roles/worker.md +0 -119
- package/dist/workspace/workspace/.polaris/session-type +0 -1
- package/dist/workspace/workspace/.polaris/skills/ROUTING.md +0 -113
- package/dist/workspace/workspace/.polaris/skills/caveman/SKILL.md +0 -74
- package/dist/workspace/workspace/.polaris/skills/caveman-compress/scripts/compress.py +0 -272
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/POLARIS.md +0 -46
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/SKILL.md +0 -59
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/chain.md +0 -116
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/01-load-cluster-context.md +0 -78
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/02-drift-reconciliation.md +0 -157
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/03-reconcile-polaris-md.md +0 -93
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/04-reconcile-summary-md.md +0 -106
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/05-doc-ingestion.md +0 -114
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/06-link-validation.md +0 -128
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/07-yaml-linking.md +0 -95
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/08-librarian-commit.md +0 -119
- package/dist/workspace/workspace/.polaris/skills/closeout-librarian/steps/09-sealed-result.md +0 -118
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/SKILL.md +0 -68
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/chain.json +0 -23
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/chain.md +0 -149
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/steps/01-orient-ingest.md +0 -85
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/steps/02-classify-batch.md +0 -87
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/steps/03-conflict-check.md +0 -66
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/steps/04-place-and-link.md +0 -77
- package/dist/workspace/workspace/.polaris/skills/docs-ingest/steps/05-finalize-ingest.md +0 -49
- package/dist/workspace/workspace/.polaris/skills/docs-promote/SKILL.md +0 -79
- package/dist/workspace/workspace/.polaris/skills/docs-promote/chain.json +0 -25
- package/dist/workspace/workspace/.polaris/skills/docs-promote/chain.md +0 -80
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/01-orient-promote.md +0 -53
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/02-review-candidates.md +0 -51
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/03-read-linked-code.md +0 -50
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/04-conflict-surface.md +0 -65
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/05-await-approval.md +0 -61
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/06-execute-promote-deprecate.md +0 -65
- package/dist/workspace/workspace/.polaris/skills/docs-promote/steps/07-finalize-promote.md +0 -44
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/SKILL.md +0 -94
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/chain.json +0 -20
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/chain.md +0 -105
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/issue-reconciliation.md +0 -149
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/issue-template.md +0 -133
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/linked-skills/repo-analysis.md +0 -55
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/01-fetch-and-orient.md +0 -79
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/02-map-affected-code.md +0 -58
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/03-assess-issue.md +0 -58
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/04-blocker-check.md +0 -60
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/05-create-cluster-plan.md +0 -197
- package/dist/workspace/workspace/.polaris/skills/polaris-analyze/steps/06-final-report.md +0 -60
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/SKILL.md +0 -91
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/chain.json +0 -22
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/chain.md +0 -85
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/steps/01-orient-catalog.md +0 -92
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/steps/02-reconcile-polaris-md.md +0 -33
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/steps/03-reconcile-summary-md.md +0 -70
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/steps/04-classify-and-place.md +0 -117
- package/dist/workspace/workspace/.polaris/skills/polaris-catalog/steps/05-catalog-commit.md +0 -94
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/SKILL.md +0 -52
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/chain.md +0 -111
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/01-orient-medic.md +0 -75
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/02-diagnose.md +0 -79
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/03-repair.md +0 -64
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/04-validate.md +0 -66
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/05-create-chart.md +0 -85
- package/dist/workspace/workspace/.polaris/skills/polaris-medic/steps/06-closeout.md +0 -86
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/SKILL.md +0 -75
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/chain.json +0 -20
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/chain.md +0 -67
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/steps/01-orient-reconcile.md +0 -82
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/steps/02-reconcile-polaris-md.md +0 -95
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/steps/03-reconcile-summary-md.md +0 -108
- package/dist/workspace/workspace/.polaris/skills/polaris-reconcile/steps/04-reconcile-commit.md +0 -88
- package/dist/workspace/workspace/.polaris/skills/polaris-run/SKILL.md +0 -135
- package/dist/workspace/workspace/.polaris/skills/polaris-run/chain.json +0 -19
- package/dist/workspace/workspace/.polaris/skills/polaris-run/chain.md +0 -298
- package/dist/workspace/workspace/.polaris/skills/polaris-run/execution-adapter.md +0 -34
- package/dist/workspace/workspace/.polaris/skills/polaris-run/linked-skills/repo-analysis.md +0 -58
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/01-orient-cluster.md +0 -96
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/02-prepare-branch.md +0 -53
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/03-select-child.md +0 -63
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/04-execute-child.md +0 -75
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/05-validate-child.md +0 -57
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/06-commit-and-update-linear.md +0 -74
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/07-decide-continuation.md +0 -89
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/08-closeout-librarian.md +0 -146
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/08-final-delivery.md +0 -91
- package/dist/workspace/workspace/.polaris/skills/polaris-run/steps/09-final-delivery.md +0 -104
- package/dist/workspace/workspace/.polaris/skills/polaris-tools/README.md +0 -63
- package/dist/workspace/workspace/.polaris/skills/polaris-tools/SKILL.md +0 -94
- package/dist/workspace/workspace/.polaris/skills/polaris-tools/tools.js +0 -191
- 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/dist/workspace/{workspace/.polaris → .polaris}/skills/docs-review/chain.md +0 -0
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# polaris-tools skill
|
|
2
|
-
|
|
3
|
-
Codex skill that exposes compact, read-only Polaris status helpers without dumping large state into chat context.
|
|
4
|
-
|
|
5
|
-
## Installation prerequisite
|
|
6
|
-
|
|
7
|
-
The Polaris CLI must be installed and resolvable before this skill will work.
|
|
8
|
-
|
|
9
|
-
### Option A — link from the repo (development)
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
# From the Polaris repo root:
|
|
13
|
-
npm run build
|
|
14
|
-
npm link
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
After `npm link`, `polaris` is available globally on your `PATH`.
|
|
18
|
-
|
|
19
|
-
### Option B — install globally
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install -g polaris
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### Verify
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npm run polaris -- --version
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
If the binary is not found, the skill will attempt `npx --no-install polaris` as a fallback. If that also fails, the tool returns a clear error with install instructions.
|
|
32
|
-
|
|
33
|
-
## Available tools
|
|
34
|
-
|
|
35
|
-
| Tool | CLI equivalent | Description |
|
|
36
|
-
|------|---------------|-------------|
|
|
37
|
-
| `polaris_status` | `polaris status --json` | Compact current run summary (no full state dump) |
|
|
38
|
-
| `polaris_loop_status` | `polaris loop status --json` | Compact loop subsystem summary (no full state dump) |
|
|
39
|
-
|
|
40
|
-
`polaris_run` and `polaris_loop_continue` are recognized only as operator-only legacy names and return an error without invoking the CLI. The public CLI does not expose `polaris run`, and `polaris loop continue` is mutating: it checkpoints state and writes a bootstrap packet.
|
|
41
|
-
|
|
42
|
-
The MCP safety model exposes `polaris_loop_continue_dry_run` and `polaris_loop_continue_confirmed` as a separate approval-envelope flow. This helper does not wrap continuation unless a true non-mutating CLI dry-run is added.
|
|
43
|
-
|
|
44
|
-
`polaris finalize` remains manual/operator-only. Do not expose finalize as a normal tool until a confirmed finalize approval flow exists.
|
|
45
|
-
|
|
46
|
-
## Usage from Codex
|
|
47
|
-
|
|
48
|
-
Invoke the helper script from the repo root:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
node .polaris/skills/polaris-tools/tools.js polaris_status
|
|
52
|
-
node .polaris/skills/polaris-tools/tools.js polaris_loop_status
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
All tools return compact JSON on stdout. On error, exit code is non-zero and the JSON contains an `error` field.
|
|
56
|
-
|
|
57
|
-
## Output contract
|
|
58
|
-
|
|
59
|
-
Tools return only a compact JSON summary. They never dump the full `current-state.json` or worker transcript into chat. Text summaries are truncated to 600 characters.
|
|
60
|
-
|
|
61
|
-
## Security note
|
|
62
|
-
|
|
63
|
-
All CLI arguments are passed as explicit argument arrays via `spawnSync` — no shell string interpolation is used.
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: polaris-tools
|
|
3
|
-
description: Exposes compact read-only Polaris status helpers. Direct run, ungated loop continuation, and finalize remain operator-only.
|
|
4
|
-
role: foreman
|
|
5
|
-
role_file: .polaris/roles/foreman.md
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Command entrypoints
|
|
9
|
-
|
|
10
|
-
This skill is the target for the following user commands:
|
|
11
|
-
|
|
12
|
-
- `polaris-status`
|
|
13
|
-
- `run polaris-status`
|
|
14
|
-
|
|
15
|
-
When any of these commands are issued, load this skill packet **first** before any other action.
|
|
16
|
-
See `.polaris/skills/ROUTING.md` for the full routing protocol.
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
# polaris-tools
|
|
21
|
-
|
|
22
|
-
Use this skill when the user wants to inspect Polaris run state without dumping large artifacts:
|
|
23
|
-
- `polaris status --json` / compact current-state summary → `polaris_status`
|
|
24
|
-
- `polaris loop status --json` / compact current-state summary → `polaris_loop_status`
|
|
25
|
-
|
|
26
|
-
Do not use this skill as a casual mutation surface. `polaris_run` and `polaris_loop_continue` are operator-only legacy names in the helper and return an error without invoking the CLI. Finalize is manual/operator-only until a confirmed finalize approval flow exists.
|
|
27
|
-
|
|
28
|
-
## Prerequisites
|
|
29
|
-
|
|
30
|
-
The Polaris CLI must be installed before using this skill. See `README.md` for installation steps.
|
|
31
|
-
|
|
32
|
-
## Tool behaviours
|
|
33
|
-
|
|
34
|
-
### polaris_status()
|
|
35
|
-
|
|
36
|
-
Attempts `polaris status --json`. If the CLI is not available, reads and summarises
|
|
37
|
-
`.taskchain_artifacts/polaris-run/current-state.json` compactly. Returns:
|
|
38
|
-
```json
|
|
39
|
-
{
|
|
40
|
-
"tool": "polaris_status",
|
|
41
|
-
"run_id": "...",
|
|
42
|
-
"cluster_id": "...",
|
|
43
|
-
"status": "...",
|
|
44
|
-
"active_child": null,
|
|
45
|
-
"next_open_child": "...",
|
|
46
|
-
"completed_children": [...],
|
|
47
|
-
"open_children": [...],
|
|
48
|
-
"updated_at": "..."
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### polaris_loop_status()
|
|
53
|
-
|
|
54
|
-
Attempts `polaris loop status --json`. If the CLI is not available, reads and summarises
|
|
55
|
-
`.taskchain_artifacts/polaris-run/current-state.json` compactly. Returns the same compact shape with `"tool": "polaris_loop_status"`.
|
|
56
|
-
|
|
57
|
-
### Operator-only names
|
|
58
|
-
|
|
59
|
-
`polaris_run(issue_id)` and `polaris_loop_continue(provider?)` are not exposed as casual helpers. They return:
|
|
60
|
-
```json
|
|
61
|
-
{"tool":"polaris_loop_continue","error":"operator_only","message":"..."}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
The MCP safety model has a separate `polaris_loop_continue_dry_run` / `polaris_loop_continue_confirmed` approval-envelope flow. This helper does not wrap continuation unless a true non-mutating CLI dry-run is added.
|
|
65
|
-
|
|
66
|
-
Never dump the full state file into chat.
|
|
67
|
-
|
|
68
|
-
## How to invoke
|
|
69
|
-
|
|
70
|
-
Run the helper script from the repo root:
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
node .polaris/skills/polaris-tools/tools.js <tool> [args...]
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Examples:
|
|
77
|
-
```
|
|
78
|
-
node .polaris/skills/polaris-tools/tools.js polaris_status
|
|
79
|
-
node .polaris/skills/polaris-tools/tools.js polaris_loop_status
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
The script prints compact JSON to stdout and exits 0 on success, non-zero on error.
|
|
83
|
-
|
|
84
|
-
## Discovery order for the Polaris binary
|
|
85
|
-
|
|
86
|
-
1. `polaris` on `PATH` (installed via `npm link` or `npm install -g`)
|
|
87
|
-
2. `npx --no-install polaris` (project-local install)
|
|
88
|
-
3. Error emitted clearly if neither resolves
|
|
89
|
-
|
|
90
|
-
## Error format
|
|
91
|
-
|
|
92
|
-
```json
|
|
93
|
-
{"error":"polaris binary not found. Install via: npm link (from repo root) or npm install -g polaris","tool":"<tool>"}
|
|
94
|
-
```
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* polaris-tools — Codex plugin skill helper
|
|
4
|
-
*
|
|
5
|
-
* Exposes compact read-only helpers backed by local Polaris CLI invocation.
|
|
6
|
-
* Prints compact JSON to stdout. Never dumps full state files.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* node tools.js polaris_status
|
|
10
|
-
* node tools.js polaris_loop_status
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
'use strict';
|
|
14
|
-
|
|
15
|
-
const { spawnSync } = require('child_process');
|
|
16
|
-
const fs = require('fs');
|
|
17
|
-
const path = require('path');
|
|
18
|
-
|
|
19
|
-
// ── binary resolution ──────────────────────────────────────────────────────
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Returns { cmd, args } for the polaris binary, or null if not found.
|
|
23
|
-
* Uses spawnSync with argument arrays — no shell interpolation.
|
|
24
|
-
*/
|
|
25
|
-
function findPolaris() {
|
|
26
|
-
// 1. polaris on PATH
|
|
27
|
-
const probe = spawnSync('polaris', ['--version'], { stdio: 'pipe', timeout: 5_000 });
|
|
28
|
-
if (probe.status === 0 && !probe.error) return { cmd: 'polaris', args: [] };
|
|
29
|
-
|
|
30
|
-
// 2. npx polaris (project-local, no network fetch)
|
|
31
|
-
const npxProbe = spawnSync('npx', ['--no-install', 'polaris', '--version'], {
|
|
32
|
-
stdio: 'pipe',
|
|
33
|
-
timeout: 10_000,
|
|
34
|
-
});
|
|
35
|
-
if (npxProbe.status === 0) return { cmd: 'npx', args: ['--no-install', 'polaris'] };
|
|
36
|
-
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function binaryError(tool) {
|
|
41
|
-
return {
|
|
42
|
-
error:
|
|
43
|
-
'polaris binary not found. Install via: npm link (from repo root) or npm install -g polaris',
|
|
44
|
-
tool,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// ── compact runner ─────────────────────────────────────────────────────────
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Runs a command safely using spawnSync with an explicit args array.
|
|
52
|
-
* @param {string} cmd
|
|
53
|
-
* @param {string[]} args
|
|
54
|
-
*/
|
|
55
|
-
function runSafe(cmd, args) {
|
|
56
|
-
const result = spawnSync(cmd, args, {
|
|
57
|
-
stdio: 'pipe',
|
|
58
|
-
timeout: 120_000,
|
|
59
|
-
encoding: 'utf8',
|
|
60
|
-
});
|
|
61
|
-
return {
|
|
62
|
-
exit_code: result.status ?? 1,
|
|
63
|
-
stdout: (result.stdout || '').trim(),
|
|
64
|
-
stderr: (result.stderr || '').trim(),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function truncate(str, max = 300) {
|
|
69
|
-
if (!str || str.length <= max) return str;
|
|
70
|
-
return str.slice(0, max) + ' ...(truncated)';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// ── tools ──────────────────────────────────────────────────────────────────
|
|
74
|
-
|
|
75
|
-
function printJson(value, exitCode = 0) {
|
|
76
|
-
console.log(JSON.stringify(value));
|
|
77
|
-
process.exit(exitCode);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function operatorOnly(tool, cliEquivalent) {
|
|
81
|
-
printJson(
|
|
82
|
-
{
|
|
83
|
-
tool,
|
|
84
|
-
error: 'operator_only',
|
|
85
|
-
message:
|
|
86
|
-
`${cliEquivalent} is mutating or deferred and is not exposed as a casual Codex plugin helper. Use the governed operator workflow with an explicit approval boundary.`,
|
|
87
|
-
},
|
|
88
|
-
1
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function compactState(tool, state) {
|
|
93
|
-
return {
|
|
94
|
-
tool,
|
|
95
|
-
run_id: state.run_id,
|
|
96
|
-
cluster_id: state.cluster_id,
|
|
97
|
-
status: state.status,
|
|
98
|
-
active_child: state.active_child || null,
|
|
99
|
-
next_open_child: state.next_open_child ?? null,
|
|
100
|
-
completed_children: Array.isArray(state.completed_children) ? state.completed_children : [],
|
|
101
|
-
open_children: Array.isArray(state.open_children) ? state.open_children : [],
|
|
102
|
-
updated_at: state.updated_at,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function compactCliStatus(tool, exit_code, stdout, stderr) {
|
|
107
|
-
if (exit_code !== 0) {
|
|
108
|
-
return {
|
|
109
|
-
tool,
|
|
110
|
-
exit_code,
|
|
111
|
-
error: 'polaris status command failed',
|
|
112
|
-
summary: truncate(stderr || stdout, 600),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
return {
|
|
118
|
-
...compactState(tool, JSON.parse(stdout)),
|
|
119
|
-
exit_code,
|
|
120
|
-
};
|
|
121
|
-
} catch {
|
|
122
|
-
return { tool, exit_code, summary: truncate(stdout || stderr, 600) };
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function statusFromStateFile(tool) {
|
|
127
|
-
const stateFile = path.join(
|
|
128
|
-
process.cwd(),
|
|
129
|
-
'.taskchain_artifacts',
|
|
130
|
-
'polaris-run',
|
|
131
|
-
'current-state.json'
|
|
132
|
-
);
|
|
133
|
-
if (!fs.existsSync(stateFile)) return null;
|
|
134
|
-
|
|
135
|
-
try {
|
|
136
|
-
const state = JSON.parse(fs.readFileSync(stateFile, 'utf8'));
|
|
137
|
-
return compactState(tool, state);
|
|
138
|
-
} catch (e) {
|
|
139
|
-
return {
|
|
140
|
-
tool,
|
|
141
|
-
error: `Failed to parse current-state.json: ${e.message}`,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function polarisStatus(tool, cliArgs) {
|
|
147
|
-
const bin = findPolaris();
|
|
148
|
-
|
|
149
|
-
if (bin) {
|
|
150
|
-
const { exit_code, stdout, stderr } = runSafe(bin.cmd, [...bin.args, ...cliArgs]);
|
|
151
|
-
const result = compactCliStatus(tool, exit_code, stdout, stderr);
|
|
152
|
-
printJson(result, exit_code === 0 ? 0 : 1);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const fallback = statusFromStateFile(tool);
|
|
156
|
-
if (fallback) {
|
|
157
|
-
printJson(fallback, fallback.error ? 1 : 0);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
printJson(binaryError(tool), 1);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function unknownTool(tool) {
|
|
164
|
-
console.log(
|
|
165
|
-
JSON.stringify({
|
|
166
|
-
error: `Unknown tool: "${tool}". Valid tools: polaris_status, polaris_loop_status. Operator-only legacy names: polaris_run, polaris_loop_continue`,
|
|
167
|
-
})
|
|
168
|
-
);
|
|
169
|
-
process.exit(1);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// ── dispatch ───────────────────────────────────────────────────────────────
|
|
173
|
-
|
|
174
|
-
const [, , tool, ...rest] = process.argv;
|
|
175
|
-
|
|
176
|
-
switch (tool) {
|
|
177
|
-
case 'polaris_run':
|
|
178
|
-
operatorOnly('polaris_run', 'polaris run <issue_id>');
|
|
179
|
-
break;
|
|
180
|
-
case 'polaris_loop_continue':
|
|
181
|
-
operatorOnly('polaris_loop_continue', 'polaris loop continue');
|
|
182
|
-
break;
|
|
183
|
-
case 'polaris_status':
|
|
184
|
-
polarisStatus('polaris_status', ['status', '--json']);
|
|
185
|
-
break;
|
|
186
|
-
case 'polaris_loop_status':
|
|
187
|
-
polarisStatus('polaris_loop_status', ['loop', 'status', '--json']);
|
|
188
|
-
break;
|
|
189
|
-
default:
|
|
190
|
-
unknownTool(tool);
|
|
191
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|