nubos-pilot 1.3.2 → 1.3.4
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/CHANGELOG.md +5 -2
- package/agents/np-critic-economy.md +103 -0
- package/agents/np-critic.md +11 -10
- package/agents/np-executor.md +14 -0
- package/agents/np-simplifier.md +83 -0
- package/agents/np-task-architect.md +95 -0
- package/agents/np-test-writer.md +89 -0
- package/bin/install.js +86 -0
- package/bin/np-tools/_commands.cjs +2 -0
- package/bin/np-tools/commit-task.cjs +80 -6
- package/bin/np-tools/commit-task.test.cjs +133 -0
- package/bin/np-tools/doctor.cjs +1 -0
- package/bin/np-tools/economy-mode.cjs +47 -0
- package/bin/np-tools/loop-commands.test.cjs +121 -2
- package/bin/np-tools/loop-run-round.cjs +122 -6
- package/bin/np-tools/resolve-model.cjs +1 -0
- package/bin/np-tools/simplify-debt.cjs +91 -0
- package/bin/np-tools/simplify-debt.test.cjs +99 -0
- package/lib/agents-registry.cjs +12 -1
- package/lib/agents.test.cjs +4 -0
- package/lib/config-defaults.cjs +22 -1
- package/lib/config-defaults.test.cjs +9 -0
- package/lib/config-schema.cjs +6 -0
- package/lib/economy-debt.cjs +235 -0
- package/lib/economy-debt.test.cjs +131 -0
- package/lib/economy-mode.cjs +66 -0
- package/lib/economy-mode.test.cjs +85 -0
- package/lib/git.cjs +6 -2
- package/lib/git.test.cjs +28 -0
- package/lib/nubosloop.cjs +4 -0
- package/lib/nubosloop.test.cjs +1 -0
- package/np-tools.cjs +2 -0
- package/package.json +1 -1
- package/templates/RULES.md +36 -1
- package/workflows/execute-phase.md +154 -1
- package/workflows/plan-phase.md +17 -2
- package/workflows/simplify-debt.md +93 -0
- package/workflows/simplify-review.md +103 -0
package/workflows/plan-phase.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
command: np:plan-phase
|
|
3
3
|
description: Plans a milestone (M<NNN>) — breaks it into slices (waves) and tasks. Spawns np-planner (opus) + np-plan-checker (opus), 2-iteration verification, then scaffolds every task file.
|
|
4
|
-
argument-hint: <milestone-number> [--research] [--repromote]
|
|
4
|
+
argument-hint: <milestone-number> [--research] [--architect] [--repromote]
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# np:plan-phase
|
|
@@ -41,17 +41,19 @@ Output layout:
|
|
|
41
41
|
```bash
|
|
42
42
|
PHASE=""
|
|
43
43
|
RESEARCH_FLAG=0
|
|
44
|
+
ARCHITECT_FLAG=0
|
|
44
45
|
REPROMOTE_FLAG=0
|
|
45
46
|
for arg in "$@"; do
|
|
46
47
|
case "$arg" in
|
|
47
48
|
--research) RESEARCH_FLAG=1 ;;
|
|
49
|
+
--architect) ARCHITECT_FLAG=1 ;;
|
|
48
50
|
--repromote) REPROMOTE_FLAG=1 ;;
|
|
49
51
|
--*) echo "Unknown flag: $arg" >&2; exit 2 ;;
|
|
50
52
|
*) [[ -z "$PHASE" ]] && PHASE="$arg" ;;
|
|
51
53
|
esac
|
|
52
54
|
done
|
|
53
55
|
if [[ -z "$PHASE" ]]; then
|
|
54
|
-
echo "Usage: /np:plan-phase <milestone-number> [--research] [--repromote]" >&2
|
|
56
|
+
echo "Usage: /np:plan-phase <milestone-number> [--research] [--architect] [--repromote]" >&2
|
|
55
57
|
exit 2
|
|
56
58
|
fi
|
|
57
59
|
```
|
|
@@ -154,6 +156,19 @@ fi
|
|
|
154
156
|
|
|
155
157
|
**Exit code 42 contract:** orchestrator sees exit 42 → runs `/np:research-phase $PHASE` → re-enters `/np:plan-phase $PHASE` without the `--research` flag.
|
|
156
158
|
|
|
159
|
+
### Gate 2b — Optional architecture pass (`--architect`)
|
|
160
|
+
|
|
161
|
+
The `--architect` flag auto-dispatches `/np:architect-phase` before planning, so a structural ADR pass (`M<NNN>-ARCHITECTURE.md`) is decided up front and the planner consumes it like an extension of CONTEXT.md. Dispatched AFTER research (the established flow is research → architect → plan): when both flags are set, the research re-entry strips `--research`, leaving `--architect` to dispatch on the next pass.
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
if [[ "$ARCHITECT_FLAG" == "1" ]]; then
|
|
165
|
+
echo "architect-auto: dispatching /np:architect-phase $PHASE before planning" >&2
|
|
166
|
+
exit 43
|
|
167
|
+
fi
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Exit code 43 contract:** orchestrator sees exit 43 → runs `/np:architect-phase $PHASE` → re-enters `/np:plan-phase $PHASE` without the `--architect` flag. The milestone `np-architect` stays intent-level (ADR-0019): its decisions inform the plan; they do not bake schema/filenames/code-style into `PLAN.md`.
|
|
171
|
+
|
|
157
172
|
**Researcher-Schwarm semantics (ADR-0011).** The dispatched `/np:research-phase` runs in Schwarm mode by default (`swarm.research.k=3`). The cache-bypass at Pre-flight short-circuits the swarm whenever the milestone goal + requirements match a stored learning at similarity ≥ `swarm.research.threshold` and `occurrence ≥ swarm.research.minOccurrence`. The merged consensus carries a `<consensus_meta>` block (`k`, `agreement_score`, `flagged_decisions`) which `np-plan-checker` reads to weight downstream verdicts. No additional flags needed at this site — the swarm runs automatically when `--research` is set.
|
|
158
173
|
|
|
159
174
|
### Gate 3 — Milestone already planned
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
command: np:simplify-debt
|
|
3
|
+
description: Economy-debt ledger — record, list, and resolve simplifications you deferred rather than fixed now, so "later" doesn't become "never". CRUD-only (no agent spawn unless you harvest from a review). Manual twin of the in-loop Economy critic (agents.economy full/ultra).
|
|
4
|
+
argument-hint: "[list [--status open|resolved|all]] | [add --file <f> --line <n> --category <c> --note <text>] | [resolve <id>] | [harvest [<git-range>]]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /np:simplify-debt
|
|
8
|
+
|
|
9
|
+
<objective>
|
|
10
|
+
Keep a durable ledger of over-engineering you chose NOT to fix this round. `/np:simplify-review` finds what could be deleted, reused, or condensed; whatever you defer goes here as a tracked entry, so the shortcut is harvested rather than lost. Each entry carries a `file`, optional `line`, one of the four Economy categories (`over-engineering` / `stdlib-reinvention` / `native-duplication` / `shrinkable`), and a one-line note. This command is CRUD over `.nubos-pilot/economy-debt/` — it does not edit source and does not commit code. It is the deferred-work counterpart of the in-loop Economy critic (`/np:execute-phase` with `agents.economy` set to `full` or `ultra`).
|
|
11
|
+
</objective>
|
|
12
|
+
|
|
13
|
+
## Initialize
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
LANG_DIRECTIVE=$(node .nubos-pilot/bin/np-tools.cjs lang-directive)
|
|
17
|
+
VERB="${1:-list}"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`$LANG_DIRECTIVE` governs the prose you wrap around the CLI output; the ledger lines (id, category, `file:line`, note) stay canonical. Supersedes CLAUDE.md.
|
|
21
|
+
|
|
22
|
+
## Route by verb
|
|
23
|
+
|
|
24
|
+
This is a pure-CRUD workflow — the ledger lives behind `node .nubos-pilot/bin/np-tools.cjs simplify-debt`; never read or write `.nubos-pilot/economy-debt/` directly.
|
|
25
|
+
|
|
26
|
+
### `list` (default)
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
node .nubos-pilot/bin/np-tools.cjs simplify-debt list --status "${2:-open}"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Prints the open ledger (oldest debt first — longest-deferred is most urgent). `--status resolved` or `--status all` widen the view; append `--json` for the machine shape. Print the output verbatim.
|
|
33
|
+
|
|
34
|
+
### `add`
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
node .nubos-pilot/bin/np-tools.cjs simplify-debt add \
|
|
38
|
+
--file "$FILE" --line "$LINE" --category "$CATEGORY" --note "$NOTE"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`--category` MUST be one of `over-engineering`, `stdlib-reinvention`, `native-duplication`, `shrinkable` (the CLI rejects anything else). `--line` is optional (omit for a file-level note). Adds are idempotent: re-adding an identical finding is a no-op (`was_new=false`), so re-harvesting the same review never duplicates.
|
|
42
|
+
|
|
43
|
+
### `resolve`
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
node .nubos-pilot/bin/np-tools.cjs simplify-debt resolve "$ID"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Moves the entry from `open/` to `resolved/` and stamps the resolution time. Use it once the simplification has actually landed (by hand or via a later `/np:execute-phase` round).
|
|
50
|
+
|
|
51
|
+
### `harvest [<git-range>]`
|
|
52
|
+
|
|
53
|
+
Spawn ONE read-only reviewer — `Agent(subagent_type="np-simplifier", prompt=<…>)` — over the diff (default: working tree + staged vs `HEAD`; or the passed git range). Its prompt MUST carry `agents/np-critic-economy.md` as the rubric (the canonical ladder + safety boundaries) and the captured `git diff --no-color`. For each finding the reviewer returns that you are NOT fixing now, record it with one `simplify-debt add` call (mapping the report tag to the matching `--category`). Findings you fix immediately are not harvested. Print the resulting open ledger when done.
|
|
54
|
+
|
|
55
|
+
## No Source Mutation
|
|
56
|
+
|
|
57
|
+
CRUD over the ledger only. This workflow NEVER edits source, NEVER stages, NEVER commits code. The ledger files under `.nubos-pilot/economy-debt/` are the only writes; commit them with your normal docs/artifact flow if `workflow.commit_docs` is set.
|
|
58
|
+
|
|
59
|
+
## Scope Guardrail
|
|
60
|
+
|
|
61
|
+
<scope_guardrail>
|
|
62
|
+
**Do:**
|
|
63
|
+
- Route every ledger read/write through `node .nubos-pilot/bin/np-tools.cjs simplify-debt <verb>` — never touch `.nubos-pilot/economy-debt/` directly.
|
|
64
|
+
- Use one of the four Economy categories on `add`; the CLI is the source of truth and rejects others.
|
|
65
|
+
- On `harvest`, pass `agents/np-critic-economy.md` to the reviewer so the ledger and the in-loop critic apply the identical bar.
|
|
66
|
+
|
|
67
|
+
**Don't:**
|
|
68
|
+
- Edit, stage, or commit source — this command only records deferred work. No `Write`/`Edit` of source, no `git add` of code.
|
|
69
|
+
- Log a test, input-validation, error-handling, security, or required-edge-case removal as debt — those are completeness, never economy (the rubric's safety boundaries; completeness wins).
|
|
70
|
+
- Record low-confidence "could be cleaner" noise — every entry needs a concrete file + replacement, same bar as `/np:simplify-review`.
|
|
71
|
+
</scope_guardrail>
|
|
72
|
+
|
|
73
|
+
## Output
|
|
74
|
+
|
|
75
|
+
- The ledger view (open / resolved / all) or the result of an `add` / `resolve`, printed verbatim.
|
|
76
|
+
- On `harvest`: one ledger entry per deferred finding, then the refreshed open ledger.
|
|
77
|
+
- No source changes, no code commits.
|
|
78
|
+
|
|
79
|
+
## Definition of Done
|
|
80
|
+
|
|
81
|
+
Ledger CRUD. Definition of Done, per [`templates/COMPLETENESS.md`](../templates/COMPLETENESS.md):
|
|
82
|
+
|
|
83
|
+
- Rule 3 (Do it with tests) — the ledger NEVER records deleting or weakening test code; coverage is completeness, not debt.
|
|
84
|
+
- Rule 8 (Never present a workaround when the real fix exists) — entries point at the root-cause-simple form, not an obscure golfed one-liner.
|
|
85
|
+
- Rule 11 (Ship the complete thing) — deferred simplifications are tracked, not silently dropped; "later" stays visible until `resolve`.
|
|
86
|
+
|
|
87
|
+
Any violation = the operation is incomplete; surface it and exit non-zero. The orchestrator does not relax these.
|
|
88
|
+
|
|
89
|
+
## Related Workflows
|
|
90
|
+
|
|
91
|
+
- **`/np:simplify-review <git-range>`** — read-only economy audit of a diff (the finder; this command is the ledger that outlives a single review).
|
|
92
|
+
- **`/np:execute-phase`** — runs the Economy critic in-loop when `agents.economy` is `full` or `ultra`, enforcing the same rubric during execution.
|
|
93
|
+
- **`/np:add-todo`** — general pending-todo capture (this command is the economy-specific deferred-work ledger).
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
command: np:simplify-review
|
|
3
|
+
description: Read-only economy audit of a git diff, the working tree, or the whole repo (--repo) — flags over-engineering, stdlib-reinvention, native-duplication, and shrinkable logic via the np-simplifier agent. Never edits or commits; emits a deletion-oriented report. Manual twin of the Economy critic axis (agents.economy full/ultra).
|
|
4
|
+
argument-hint: "[<git-range> | --repo] (default: working tree + staged vs HEAD)"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /np:simplify-review
|
|
8
|
+
|
|
9
|
+
<objective>
|
|
10
|
+
Catalogue what could be deleted, reused, or condensed in a change set — the "wrote-too-much" review. A read-only `np-simplifier` agent scans the diff against the Economy rubric (`agents/np-critic-economy.md`) and emits one finding per removable construct plus a `net: -<N> lines possible.` summary. This command NEVER edits source and NEVER commits; it hands a report to the user. It is the manual counterpart of the in-loop Economy critic (`/np:execute-phase` with `agents.economy` set to `full` or `ultra`), and both apply the identical rubric and safety boundaries.
|
|
11
|
+
</objective>
|
|
12
|
+
|
|
13
|
+
## Initialize
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
LANG_DIRECTIVE=$(node .nubos-pilot/bin/np-tools.cjs lang-directive)
|
|
17
|
+
RANGE="$*"
|
|
18
|
+
if [[ "$RANGE" == "--repo" || "$RANGE" == "--all" ]]; then
|
|
19
|
+
SCOPE_MODE="repo"
|
|
20
|
+
FILES=$(git ls-files)
|
|
21
|
+
SCOPE_DESC="whole repository (tracked files)"
|
|
22
|
+
if [[ -z "$FILES" ]]; then
|
|
23
|
+
echo "No tracked files in scope ($SCOPE_DESC). Nothing to review."
|
|
24
|
+
exit 0
|
|
25
|
+
fi
|
|
26
|
+
elif [[ -n "$RANGE" ]]; then
|
|
27
|
+
SCOPE_MODE="diff"
|
|
28
|
+
DIFF=$(git diff --no-color "$RANGE")
|
|
29
|
+
SCOPE_DESC="$RANGE"
|
|
30
|
+
else
|
|
31
|
+
SCOPE_MODE="diff"
|
|
32
|
+
DIFF=$(git diff --no-color HEAD)
|
|
33
|
+
SCOPE_DESC="working tree + staged vs HEAD"
|
|
34
|
+
fi
|
|
35
|
+
if [[ "$SCOPE_MODE" == "diff" && -z "$DIFF" ]]; then
|
|
36
|
+
echo "No changes in scope ($SCOPE_DESC). Nothing to review."
|
|
37
|
+
exit 0
|
|
38
|
+
fi
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Capture is read-only — neither `git diff` nor `git ls-files` stages, edits, or commits anything. There are two scope modes:
|
|
42
|
+
|
|
43
|
+
- **diff** (default) — a range (`HEAD~5..HEAD`, a branch name, `--staged`, …) is passed through verbatim; with no argument the scope is uncommitted + staged work against `HEAD`. This is the "review what just changed" mode.
|
|
44
|
+
- **repo** (`--repo` / `--all`) — audits the whole tracked tree, not just a diff. `git ls-files` hands the agent the file roster; the agent walks the existing source for standing over-engineering (single-use abstractions, hand-rolled stdlib, duplicated native features, condensable logic) that predates any one change. Slower and noisier than diff mode — use it for a periodic cleanup pass, not every review.
|
|
45
|
+
|
|
46
|
+
**Language (SSOT = `.nubos-pilot/config.json` → `response_language`).** `$LANG_DIRECTIVE` is authoritative for the report's prose and the final summary line. Finding lines (`<file>:L<line>: <tag> …`), file paths, and code snippets stay canonical. Supersedes CLAUDE.md.
|
|
47
|
+
|
|
48
|
+
## Review
|
|
49
|
+
|
|
50
|
+
Spawn ONE read-only reviewer — `Agent(subagent_type="np-simplifier", prompt=<…>)`, sonnet by default. The prompt MUST carry:
|
|
51
|
+
|
|
52
|
+
- `<files_to_read>` listing `agents/np-critic-economy.md` (the canonical rubric — ladder, categories, severity bar, safety boundaries), plus `.nubos-pilot/codebase/INDEX.md` and `.nubos-pilot/RULES.md` when present (stdlib / native-feature / existing-helper context).
|
|
53
|
+
- The review scope, by mode:
|
|
54
|
+
- **diff mode** — pass the captured `$DIFF` as the scope; the agent reviews only the changed hunks.
|
|
55
|
+
- **repo mode** — pass `$SCOPE_DESC` plus the `$FILES` roster from `git ls-files`, and instruct the agent to walk the tracked source itself (`Read`/`Grep`/`Glob`) under the same rubric. The agent should skip vendored, generated, and lock files and prioritise the largest hand-written modules. Because there is no diff, findings cite the source line as `<file>:L<line>` from the file it read.
|
|
56
|
+
- `$SCOPE_MODE` and `$SCOPE_DESC` so the agent knows whether it is auditing a change set or the standing codebase.
|
|
57
|
+
- `$LANG_DIRECTIVE` so the prose follows the project language.
|
|
58
|
+
|
|
59
|
+
The agent is READ-ONLY (`tools: Read, Bash, Grep, Glob` — no Write/Edit). It returns a plain-text report: one line per finding in the shape `<file>:L<line>: <tag> <what>. <replacement>.` (tags `delete:` / `stdlib:` / `native:` / `shrink:`), ending with `net: -<N> lines possible.` or `Lean already. Ship.`
|
|
60
|
+
|
|
61
|
+
## Report
|
|
62
|
+
|
|
63
|
+
Print the agent's report verbatim to the user. Do not edit files, do not stage, do not commit — this command only catalogues. Close with the next-step hint:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
Reductions are suggestions, not applied. To act on them: edit by hand, or run
|
|
67
|
+
/np:execute-phase with agents.economy set to full (or ultra) so the Economy critic
|
|
68
|
+
enforces the same bar inside the adversarial loop.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Scope Guardrail
|
|
72
|
+
|
|
73
|
+
<scope_guardrail>
|
|
74
|
+
**Do:**
|
|
75
|
+
- Capture the scope read-only — `git diff` in diff mode, `git ls-files` in `--repo` mode (no staging, no `-w` rewrites, no commit).
|
|
76
|
+
- Spawn exactly one `np-simplifier` agent; pass it `agents/np-critic-economy.md` as the rubric so the manual command and the in-loop critic never diverge.
|
|
77
|
+
- Print the report verbatim; respect `$LANG_DIRECTIVE` for prose only.
|
|
78
|
+
|
|
79
|
+
**Don't:**
|
|
80
|
+
- Edit, stage, or commit anything — this is a read-only audit. No `git add`, no `commit`, no `Write`/`Edit` of source.
|
|
81
|
+
- Flag tests, input validation, error handling, security/access-control, or required edge cases as removable (the rubric's safety boundaries; completeness wins over economy).
|
|
82
|
+
- Emit low-confidence "could be cleaner" noise — high-confidence, concrete replacements only.
|
|
83
|
+
</scope_guardrail>
|
|
84
|
+
|
|
85
|
+
## Output
|
|
86
|
+
|
|
87
|
+
- A plain-text economy report to the user (findings + `net: -<N> lines possible.` or `Lean already. Ship.`).
|
|
88
|
+
- No filesystem changes, no commits, no state mutation — read-only by contract.
|
|
89
|
+
|
|
90
|
+
## Definition of Done
|
|
91
|
+
|
|
92
|
+
This workflow audits a diff for economy and reports. The Definition of Done, per [`templates/COMPLETENESS.md`](../templates/COMPLETENESS.md):
|
|
93
|
+
|
|
94
|
+
- Rule 3 (Do it with tests) — the report NEVER proposes deleting or weakening test code; coverage is completeness, not bloat.
|
|
95
|
+
- Rule 5 (Aim to genuinely impress) — every finding cites file, line, the exact construct, and a concrete replacement; no vague "could be simpler" entries.
|
|
96
|
+
- Rule 8 (Never present a workaround when the real fix exists) — reductions favour the root-cause-simple form over obscure golfed one-liners.
|
|
97
|
+
|
|
98
|
+
Any violation = the review is incomplete; surface it and exit non-zero. The orchestrator does not relax these.
|
|
99
|
+
|
|
100
|
+
## Related Workflows
|
|
101
|
+
|
|
102
|
+
- **`/np:verify-work <N>`** — correctness/acceptance verification (the orthogonal axis; economy never judges correctness).
|
|
103
|
+
- **`/np:execute-phase`** — runs the Economy critic in-loop when `agents.economy` is `full` or `ultra`, enforcing this exact rubric during execution.
|