neurastream 0.2.28 → 0.2.30
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 +4 -3
- package/package.json +1 -1
- package/src/adapters/omp/index.ts +17 -4
- package/src/core/autonomy.ts +11 -5
- package/src/core/config.ts +5 -1
- package/src/core/guards.ts +149 -17
- package/src/core/owner-ui.ts +36 -8
- package/src/core/queue/lib.ts +39 -2
- package/templates/AGENTS.md +1 -1
- package/templates/config.yml +2 -1
package/README.md
CHANGED
|
@@ -95,7 +95,8 @@ Green is both exiting 0.
|
|
|
95
95
|
Owner rule: never write a plan when another agent is doing the research or reading for you. When Main writes a plan, Main reads the relevant code itself and lists those files in the plan.
|
|
96
96
|
|
|
97
97
|
- Logged: every non-`task` call Main makes adds the paths it touches to `main-reads.json` in the queue state dir (`paths.queue_state`), with the time. A `grep -n` result adds each file it names (`path:line:` at a line start), resolved against the call's directory.
|
|
98
|
-
- Window: `guards.plan_read_max_hours` (default 24, `docs/config.md`). Every file listed under `## Code read by Main` must exist and have a logged read within that many hours. A backticked path cited elsewhere in the plan, outside `docs/plans/`, must also be listed there.
|
|
98
|
+
- Window: `guards.plan_read_max_hours` (default 24, `docs/config.md`). Every file listed under `## Code read by Main` must exist and have a logged read within that many hours. A backticked path cited elsewhere in the plan, outside `docs/plans/`, must also be listed there. A logged read counts in any checkout: the file read at the plan's worktree path or at the same repo-relative path under the main checkout both pass.
|
|
99
|
+
- Auto-list: a cited file Main did read within the window but that is missing from the list is added to `## Code read by Main` when the edit is allowed (`plan-guard: added <n> file(s) to "## Code read by Main": …`) instead of refusing the edit; a file Main never read in any checkout is still refused. Reading a plan runs the same check early and appends `plan-guard: before you edit this plan, re-read: <paths>` to the read result when a listed entry would fail now, so Main re-reads before drafting instead of losing the edit at save time.
|
|
99
100
|
- Cutoff: plans whose filename stamp is `20261021_0100` or later must carry a non-empty `## Code read by Main` section. Older plans are grandfathered.
|
|
100
101
|
- Retention: entries older than 7 days are dropped on each write.
|
|
101
102
|
- Spawn briefs: a brief must name an unticked phase id of the plan (for example `P4`). A brief that asks for research for a plan to be written is refused, quoting the owner rule.
|
|
@@ -107,11 +108,11 @@ A plan parked for the owner has one line: `WAITING on owner: <what>`. That line
|
|
|
107
108
|
|
|
108
109
|
## Queue priority
|
|
109
110
|
|
|
110
|
-
`INDEX.md` order is priority: the top line is rank 1. The queue summary lists plans in that order (`N. <file> [flags] <goal>`). Before a spawn, the guard checks every plan above each plan the brief names. A higher plan that is idle — open, no `WAITING on owner:`, not awaiting merge, still has an unticked phase, and not itself waiting on another open indexed plan via a `Waits on: <plan>` line — and not staffed by a running job blocks the spawn unless the brief quotes the owner: `Priority skip: <plan> — owner: "<his words>"`, at least four words that appear in an owner message of the last 24 h (`<queue_state>/owner-messages.jsonl`, recorded from Main's prompts); any other skip line is refused. `Waits on:` lines are Main-only, like `WAITING on owner:`. Staffing is `<queue_state>/staffing.json` (each plan's newest spawn's task names) matched against omp's running job labels. The owner reorders the queue by dragging cards on the phone page.
|
|
111
|
+
`INDEX.md` order is priority: the top line is rank 1. The queue summary lists plans in that order (`N. <file> [flags] <goal>`). Before a spawn, the guard checks every plan above each plan the brief names. A higher plan that is idle — open, no `WAITING on owner:`, not awaiting merge, still has an unticked phase, and not itself waiting on another open indexed plan via a `Waits on: <plan>` line — and not staffed by a running job blocks the spawn unless the brief quotes the owner: `Priority skip: <plan> — owner: "<his words>"`, at least four words that appear in an owner message of the last 24 h (`<queue_state>/owner-messages.jsonl`, recorded from Main's prompts); any other skip line is refused. `Waits on:` lines are Main-only, like `WAITING on owner:`. Staffing is `<queue_state>/staffing.json` (each plan's newest spawn's task names) matched against omp's running job labels. The owner reorders the queue by dragging cards on the phone page — a drag held near the screen edge autoscrolls the page, so the end of a queue taller than the screen is reachable. The order must respect the dependencies: an open plan may not sit above the open plan its `Waits on:` line names — `queue-check` lists one problem per misranked plan and exits 1, the summary shows the target as a `waits on #N` flag on the plan, and a drag that would create such an order is refused with that reason (`blocked: #N <plan> waits on #M …`) before the index or the reorder inbox change. A `Waits on:` target that is complete or gone from the index imposes no order.
|
|
111
112
|
|
|
112
113
|
## Autonomy tiers
|
|
113
114
|
|
|
114
|
-
One setting decides how much Main does without asking: `autonomy.tier` in the config (default `opinionated`), moved any time by the owner's whole chat message `tier strict|opinionated|full` (when `guards.chat_unlock` is on) or the tier buttons on the phone page — the setting lives in `<queue_state>/autonomy-tier`, a guard-protected path no agent can write. `strict` caps Main's project-file changes at `autonomy.strict_edit_limit` per `guards.main_window_min` minutes and refuses `git push` / `glab mr merge` / `gh pr merge` until the owner types `go`
|
|
115
|
+
One setting decides how much Main does without asking: `autonomy.tier` in the config (default `opinionated`), moved any time by the owner's whole chat message `tier strict|opinionated|full` (when `guards.chat_unlock` is on) or the tier buttons on the phone page — the setting lives in `<queue_state>/autonomy-tier`, a guard-protected path no agent can write. `strict` caps Main's project-file changes at `autonomy.strict_edit_limit` per `guards.main_window_min` minutes and refuses `git push` / `glab mr merge` / `gh pr merge` until the owner types the approve phrase from `autonomy.go_phrase` (default `go push`; a bare `go` is an ordinary message — one landing, valid `autonomy.go_minutes` minutes); `opinionated` keeps today's limits (`guards.main_edit_limit`); `full` drops the cap and lets Main skip an idle higher plan with `Priority skip: <plan> — Main: "<reason>"` (reason ≥ 4 words). No tier loosens the owner-only moves: guard-file edits without the unlock, starting the phone page, reading notify secrets, local `npm publish` and the tier setting itself.
|
|
115
116
|
|
|
116
117
|
## Owner page (`neurastream ui`)
|
|
117
118
|
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ import { chatGo, chatTier, type Tier } from "../../core/autonomy.ts";
|
|
|
23
23
|
import { loadConfig, type Config } from "../../core/config.ts";
|
|
24
24
|
import { nowSec, strftime } from "../../core/clock.ts";
|
|
25
25
|
import { runDetectors, runDetectorsGated, type DetectorInput } from "../../core/incident-detectors.ts";
|
|
26
|
-
import { checkInject, checkPlanEdit, checkStop, checkTool, findingsValue, MAIN_PLAN_FILE, newProgressEntries, recordMainResult, revertMainEdit, rekeySpawnFile } from "../../core/guards.ts";
|
|
26
|
+
import { checkInject, checkPlanEdit, checkStop, checkTool, findingsValue, MAIN_PLAN_FILE, newProgressEntries, planReadNote, recordMainResult, revertMainEdit, rekeySpawnFile } from "../../core/guards.ts";
|
|
27
27
|
import { rateLimitWait } from "../../core/rate-limit.ts";
|
|
28
28
|
import { notifyProviders, postReply } from "../../core/notify.ts";
|
|
29
29
|
import { loadKnownSecrets, redactSecrets, redactSummary } from "../../core/secret-redact.ts";
|
|
@@ -794,6 +794,14 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
|
|
|
794
794
|
revertMainEdit(asString(e.toolName), asRecord(e.input), c.cwd ?? process.cwd(), cfg);
|
|
795
795
|
return { isError: true, content: [{ type: "text", text: d.reason }] };
|
|
796
796
|
}
|
|
797
|
+
// Plan-guard auto-listing (I-20261025-208): the allowed edit's file is amended to name
|
|
798
|
+
// the cited files Main did read; the note tells Main what moved into the list.
|
|
799
|
+
if (d.allow && d.rewrite) {
|
|
800
|
+
try {
|
|
801
|
+
writeFileSync(d.rewrite.path, d.rewrite.text);
|
|
802
|
+
} catch {}
|
|
803
|
+
if (d.note) notes.push(d.note);
|
|
804
|
+
}
|
|
797
805
|
if (d.allow && (!c.hasAgent || c.kind === "main") && q.doneCount(after) > q.doneCount(before) && q.planAt(file, q.activePlans())) {
|
|
798
806
|
const note = trimProgress(file);
|
|
799
807
|
if (note) notes.push(note);
|
|
@@ -808,6 +816,10 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
|
|
|
808
816
|
if ((!c.hasAgent || c.kind === "main") && !e.isError) {
|
|
809
817
|
const text = content.map(p => asString(asRecord(p).text)).join("\n");
|
|
810
818
|
recordMainResult(asString(e.toolName), asRecord(e.input), c.cwd ?? process.cwd(), text);
|
|
819
|
+
// After the reads are recorded: a fresh hit clears its own warning, a stale list warns
|
|
820
|
+
// before Main drafts an edit the plan-read guard would refuse (I-20261025-208 P3).
|
|
821
|
+
const readNote = planReadNote(asString(e.toolName), asRecord(e.input), c.cwd ?? process.cwd(), text, cfg);
|
|
822
|
+
if (readNote) notes.push(readNote);
|
|
811
823
|
}
|
|
812
824
|
if ((!c.hasAgent || c.kind === "main") && e.isError) {
|
|
813
825
|
revertMainEdit(asString(e.toolName), asRecord(e.input), c.cwd ?? process.cwd(), cfg);
|
|
@@ -1151,8 +1163,9 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
|
|
|
1151
1163
|
};
|
|
1152
1164
|
|
|
1153
1165
|
// Chat unlock + autonomy tiers (guards.chat_unlock): the owner's whole message "unlock"/
|
|
1154
|
-
// "unlock N"/"lock" moves the guard unlock file, "tier <name>" sets the autonomy tier and
|
|
1155
|
-
// "go" approves one strict landing
|
|
1166
|
+
// "unlock N"/"lock" moves the guard unlock file, "tier <name>" sets the autonomy tier and the
|
|
1167
|
+
// approve phrase (autonomy.go_phrase, default "go push") approves one strict landing
|
|
1168
|
+
// (src/core/queue/lib.ts chatUnlock, src/core/autonomy.ts
|
|
1156
1169
|
// chatTier/chatGo). Only prompts the owner really typed
|
|
1157
1170
|
// count: the local terminal (input event, source "interactive") and collab guest prompts from
|
|
1158
1171
|
// write peers. This handler is registered BEFORE the rollover input handler below, so the unlock
|
|
@@ -1176,7 +1189,7 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
|
|
|
1176
1189
|
const notifyGo = (ctx: unknown, r: { minutes?: number }): void => {
|
|
1177
1190
|
const c = asRolloverCtx(ctx);
|
|
1178
1191
|
if (!c || r.minutes === undefined) return;
|
|
1179
|
-
c.notify(
|
|
1192
|
+
c.notify(`${cfg.autonomy.go_phrase}: one push/merge approved for ${r.minutes} min`);
|
|
1180
1193
|
};
|
|
1181
1194
|
pi.on("input", (event, ctx) => {
|
|
1182
1195
|
if (!cfg.guards.chat_unlock || !isMain(ctx)) return undefined;
|
package/src/core/autonomy.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Autonomy tiers (I-20261025-177): one owner setting — strict / opinionated / full — that the
|
|
2
|
-
// guards follow. The tier and
|
|
2
|
+
// guards follow. The tier and the one-shot approve phrase (autonomy.go_phrase, default "go push")
|
|
3
|
+
// are written only by the owner's own words (the same
|
|
3
4
|
// paths as chatUnlock: the terminal input event and collab write-peer messages) or the
|
|
4
5
|
// authenticated phone page; never by a tool call (the state dir is protected) and never from
|
|
5
6
|
// model text. Every tier keeps the owner-only moves owner-only; no tier loosens them.
|
|
@@ -59,20 +60,25 @@ export function chatTier(text: string, cfg: Config, source: string, word: "chat"
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
export interface ChatGoResult {
|
|
62
|
-
/** True when the text was a whole-message
|
|
63
|
+
/** True when the text was a whole-message approve phrase that took effect. */
|
|
63
64
|
applied: boolean;
|
|
64
65
|
/** The minutes this `go` stays valid (autonomy.go_minutes), for the owner notice. */
|
|
65
66
|
minutes?: number;
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
/** The shape a phrase is matched in: trimmed, lowercased, inner whitespace collapsed. */
|
|
70
|
+
const goWords = (s: string): string => s.trim().toLowerCase().replace(/\s+/g, " ");
|
|
71
|
+
|
|
68
72
|
/**
|
|
69
73
|
* The strict tier's one-shot landing approval by chat (guards.chat_unlock): the whole trimmed
|
|
70
|
-
* message
|
|
71
|
-
*
|
|
74
|
+
* message matching `autonomy.go_phrase` (default "go push") — case-insensitive, inner spaces
|
|
75
|
+
* collapsed — touches `<state dir>/autonomy-go`; the next strict push/merge consumes it
|
|
76
|
+
* (takeGo). Same trust rules as chatTier. A bare "go" is an ordinary message (I-20261025-201):
|
|
77
|
+
* it approves nothing.
|
|
72
78
|
*/
|
|
73
79
|
export function chatGo(text: string, cfg: Config, source: string, word: "chat" | "ui" = "chat"): ChatGoResult {
|
|
74
80
|
if (!cfg.guards.chat_unlock) return { applied: false };
|
|
75
|
-
if (text
|
|
81
|
+
if (goWords(text) !== goWords(cfg.autonomy.go_phrase)) return { applied: false };
|
|
76
82
|
mkdirSync(stateDirPath(), { recursive: true });
|
|
77
83
|
writeFileSync(goFile(), "");
|
|
78
84
|
try {
|
package/src/core/config.ts
CHANGED
|
@@ -140,8 +140,10 @@ export interface Config {
|
|
|
140
140
|
tier: "strict" | "opinionated" | "full";
|
|
141
141
|
/** Main's project-file changes per guards.main_window_min window in tier strict. */
|
|
142
142
|
strict_edit_limit: number;
|
|
143
|
-
/** Minutes
|
|
143
|
+
/** Minutes the approve phrase approves exactly one push/merge in tier strict. */
|
|
144
144
|
go_minutes: number;
|
|
145
|
+
/** The whole chat message that approves one push/merge in tier strict (default "go push"; matched case-insensitively with inner spaces collapsed). */
|
|
146
|
+
go_phrase: string;
|
|
145
147
|
};
|
|
146
148
|
/** The owner's phone page (`neurastream ui`): binds the tailnet address only. */
|
|
147
149
|
ui: { enabled: boolean; port: number; owner_login: string };
|
|
@@ -426,6 +428,8 @@ function check(cfg: Config): void {
|
|
|
426
428
|
throw new ConfigError("autonomy.strict_edit_limit must be an integer >= 1");
|
|
427
429
|
if (!Number.isInteger(cfg.autonomy.go_minutes) || cfg.autonomy.go_minutes < 1)
|
|
428
430
|
throw new ConfigError("autonomy.go_minutes must be an integer >= 1");
|
|
431
|
+
if (typeof cfg.autonomy.go_phrase !== "string" || cfg.autonomy.go_phrase.trim() === "")
|
|
432
|
+
throw new ConfigError("autonomy.go_phrase must be a non-empty string");
|
|
429
433
|
if (!Array.isArray(cfg.guards.rate_limit.patterns) || cfg.guards.rate_limit.patterns.some(p => typeof p !== "string" || p === "")) {
|
|
430
434
|
throw new ConfigError("guards.rate_limit.patterns must be a list of non-empty strings");
|
|
431
435
|
}
|
package/src/core/guards.ts
CHANGED
|
@@ -35,6 +35,18 @@ import type { Plan } from "./queue/lib.ts";
|
|
|
35
35
|
import { nowSec } from "./clock.ts";
|
|
36
36
|
const ALLOW: Decision = { allow: true, reason: "" };
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The plan-edit decision: a Decision plus the allow-with-amendment fields of the plan-read guard
|
|
40
|
+
* (I-20261025-208). On allow, `rewrite` names the file the caller writes back (the auto-listed
|
|
41
|
+
* read section) and `note` is the receipt for the tool result; both travel through the guard
|
|
42
|
+
* CLI's JSON output. They live here, not on the shared Decision, so every other check keeps the
|
|
43
|
+
* plain shape.
|
|
44
|
+
*/
|
|
45
|
+
export interface PlanEditDecision extends Decision {
|
|
46
|
+
rewrite?: { path: string; text: string };
|
|
47
|
+
note?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
38
50
|
function deny(reason: string): Decision {
|
|
39
51
|
return { allow: false, reason };
|
|
40
52
|
}
|
|
@@ -700,12 +712,13 @@ function mainTool(e: ToolEvent, input: Record<string, unknown>, cfg: Config): De
|
|
|
700
712
|
return ALLOW;
|
|
701
713
|
}
|
|
702
714
|
if (cfg.guards.shell_tools.includes(e.tool)) {
|
|
703
|
-
// Strict landing gate (20261025_1940 P2): in tier strict every push/merge waits for the
|
|
704
|
-
// owner's
|
|
705
|
-
// Opinionated and full keep today's allowance. Owner-only rules above are
|
|
715
|
+
// Strict landing gate (20261025_1940 P2, P5): in tier strict every push/merge waits for the
|
|
716
|
+
// owner's approve phrase (autonomy.go_phrase, default "go push"); the landing that consumes
|
|
717
|
+
// it goes through. Opinionated and full keep today's allowance. Owner-only rules above are
|
|
718
|
+
// untouched.
|
|
706
719
|
if (landingCommand(input) && currentTier(cfg) === "strict" && !takeGo(cfg)) {
|
|
707
|
-
log(cfg.paths.guard_log, "BLOCK landing: tier strict, no
|
|
708
|
-
return deny(
|
|
720
|
+
log(cfg.paths.guard_log, "BLOCK landing: tier strict, no approve phrase");
|
|
721
|
+
return deny(`main-guard: tier strict — type "${cfg.autonomy.go_phrase}" to approve one push/merge`);
|
|
709
722
|
}
|
|
710
723
|
const command = String(input?.command ?? input?.code ?? "");
|
|
711
724
|
for (const entry of cfg.guards.bypass_spawn) {
|
|
@@ -859,6 +872,36 @@ export function recordMainResult(tool: string, input: Record<string, unknown>, c
|
|
|
859
872
|
recordMainReads([...text.matchAll(GREP_LINE)].map(m => path.resolve(dir, m[1] ?? "")));
|
|
860
873
|
}
|
|
861
874
|
|
|
875
|
+
/**
|
|
876
|
+
* The pre-draft warning (I-20261025-208): when Main reads a plan file (the read tool, or a result
|
|
877
|
+
* whose first `path:line:` hit is the plan), the tool result gains one note naming the plan's
|
|
878
|
+
* listed files that would fail the read check right now — before Main drafts an edit the guard
|
|
879
|
+
* would refuse and throw away. Silence when every listed file is fresh in some checkout.
|
|
880
|
+
*/
|
|
881
|
+
export function planReadNote(tool: string, input: Record<string, unknown>, cwd: string, text: string, cfg: Config): string | undefined {
|
|
882
|
+
let planPath = "";
|
|
883
|
+
if (tool === "read" && typeof input.path === "string") planPath = path.resolve(cwd, q.expandHome(input.path));
|
|
884
|
+
else {
|
|
885
|
+
const first = [...text.matchAll(GREP_LINE)][0];
|
|
886
|
+
if (first) {
|
|
887
|
+
const base = typeof input.cwd === "string" ? path.resolve(cwd, q.expandHome(input.cwd)) : cwd;
|
|
888
|
+
planPath = path.resolve(q.shellCwd(String(input.command ?? input.code ?? ""), base), first[1] ?? "");
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
if (!planPath || !MAIN_PLAN_FILE.test(planPath)) return undefined;
|
|
892
|
+
let plan: string;
|
|
893
|
+
try {
|
|
894
|
+
plan = readFileSync(planPath, "utf8");
|
|
895
|
+
} catch {
|
|
896
|
+
return undefined;
|
|
897
|
+
}
|
|
898
|
+
const stale = planReadProblems(plan, planPath, cfg)
|
|
899
|
+
.filter(p => p.includes(" was not read by Main within "))
|
|
900
|
+
.map(p => p.slice(0, p.indexOf(" was not read by Main within ")));
|
|
901
|
+
if (!stale.length) return undefined;
|
|
902
|
+
return `plan-guard: before you edit this plan, re-read: ${stale.join(", ")}`;
|
|
903
|
+
}
|
|
904
|
+
|
|
862
905
|
/**
|
|
863
906
|
* spawn: the allow-list, task-only and open-plan gates for one implementer launch. Covers both
|
|
864
907
|
* original paths (the extension spawn event and a `task` tool call); the brief names the plan.
|
|
@@ -937,7 +980,7 @@ export function checkInject(e: InjectEvent, cfg: Config): Decision {
|
|
|
937
980
|
const tier = currentTier(cfg);
|
|
938
981
|
const tierNote =
|
|
939
982
|
tier === "strict"
|
|
940
|
-
? `Main changes at most ${cfg.autonomy.strict_edit_limit} project files per ${cfg.guards.main_window_min} min, and every git push / glab mr merge / gh pr merge waits for your "
|
|
983
|
+
? `Main changes at most ${cfg.autonomy.strict_edit_limit} project files per ${cfg.guards.main_window_min} min, and every git push / glab mr merge / gh pr merge waits for your "${cfg.autonomy.go_phrase}" (one landing, valid ${cfg.autonomy.go_minutes} min).`
|
|
941
984
|
: tier === "full"
|
|
942
985
|
? `Main works unattended: no edit cap, its own "Priority skip: <plan> — Main: \\"<reason>\\"" skips pass, pushes and merges go through. Owner-only moves (guard files, the phone page, notify secrets, the unlock) stay locked.`
|
|
943
986
|
: `Main changes at most ${cfg.guards.main_edit_limit} project files per ${cfg.guards.main_window_min} min; pushes and merges go through.`;
|
|
@@ -964,7 +1007,7 @@ function mainOnlyLines(text: string): string {
|
|
|
964
1007
|
* `restore` hands back the untouched text for the caller to write (the original restored the
|
|
965
1008
|
* file itself before reporting).
|
|
966
1009
|
*/
|
|
967
|
-
export function checkPlanEdit(e: PlanEditEvent, cfg: Config):
|
|
1010
|
+
export function checkPlanEdit(e: PlanEditEvent, cfg: Config): PlanEditDecision {
|
|
968
1011
|
if (e.agent === "main") return checkMainPlan(e, cfg);
|
|
969
1012
|
if (q.outsideProgress(e.after) !== q.outsideProgress(e.before) || mainOnlyLines(e.after) !== mainOnlyLines(e.before)) {
|
|
970
1013
|
log(cfg.paths.plan_guard_log, `RESTORE ${e.path}`);
|
|
@@ -1042,13 +1085,27 @@ export function findingsValue(block: string): string | null {
|
|
|
1042
1085
|
|
|
1043
1086
|
// Main's plan text outside "## Progress" must rest on files Main read itself (planReadProblems).
|
|
1044
1087
|
// An empty `before` means the plan file did not exist yet; a refusal then deletes it.
|
|
1045
|
-
function checkMainPlan(e: PlanEditEvent, cfg: Config):
|
|
1088
|
+
function checkMainPlan(e: PlanEditEvent, cfg: Config): PlanEditDecision {
|
|
1046
1089
|
if (q.outsideProgress(e.after) === q.outsideProgress(e.before)) return ALLOW;
|
|
1090
|
+
// A cited file Main did read lands in the list instead of the refusal (I-20261025-208): fix the
|
|
1091
|
+
// text first, then judge the fixed text like any other edit.
|
|
1092
|
+
const fix = autoListReads(e.after, e.path, cfg);
|
|
1093
|
+
const fixed = fix ? fix.text : e.after;
|
|
1047
1094
|
// Refuse only what this edit adds: a problem the plan already had is not Main's doing now.
|
|
1048
1095
|
// The missing-section problem is always refused: a plan with no read list has no evidence behind its text.
|
|
1049
1096
|
const known = new Set(e.before ? planReadProblems(e.before, e.path, cfg) : []);
|
|
1050
|
-
const problems = planReadProblems(
|
|
1051
|
-
if (!problems.length)
|
|
1097
|
+
const problems = planReadProblems(fixed, e.path, cfg).filter(p => p === NO_SECTION || !known.has(p));
|
|
1098
|
+
if (!problems.length) {
|
|
1099
|
+
if (!fix) return ALLOW;
|
|
1100
|
+
const list = fix.paths.join(", ");
|
|
1101
|
+
log(cfg.paths.plan_guard_log, `AUTO-LIST ${e.path}: ${list}`);
|
|
1102
|
+
return {
|
|
1103
|
+
allow: true,
|
|
1104
|
+
reason: "",
|
|
1105
|
+
rewrite: { path: e.path, text: fix.text },
|
|
1106
|
+
note: `plan-guard: added ${fix.paths.length} file(s) to "## Code read by Main": ${list}`,
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1052
1109
|
log(cfg.paths.plan_guard_log, `REFUSE-READ ${e.path}: ${problems.join("; ")}`);
|
|
1053
1110
|
return {
|
|
1054
1111
|
allow: false,
|
|
@@ -1065,8 +1122,7 @@ const NO_SECTION = `no "## Code read by Main" section lists a file (list each fi
|
|
|
1065
1122
|
|
|
1066
1123
|
/** Read evidence behind a plan edit: section present, each listed path read within the window, no unlisted cited path. */
|
|
1067
1124
|
function planReadProblems(text: string, planPath: string, cfg: Config): string[] {
|
|
1068
|
-
const
|
|
1069
|
-
const listed = [...section.matchAll(LISTED_PATH)].map(m => (m[1] ?? "").replace(/:[\d,+\- ]+$/, ""));
|
|
1125
|
+
const listed = [...(READ_SECTION.exec(text)?.[1] ?? "").matchAll(LISTED_PATH)].map(m => (m[1] ?? "").replace(/:[\d,+\- ]+$/, ""));
|
|
1070
1126
|
if (!listed.length) return [NO_SECTION];
|
|
1071
1127
|
const reads = readMainReads();
|
|
1072
1128
|
const maxMs = cfg.guards.plan_read_max_hours * 3_600_000;
|
|
@@ -1076,11 +1132,11 @@ function planReadProblems(text: string, planPath: string, cfg: Config): string[]
|
|
|
1076
1132
|
const abs = planFile(p, planPath, text);
|
|
1077
1133
|
named.add(abs);
|
|
1078
1134
|
if (!isFile(abs)) problems.push(`${p} does not exist`);
|
|
1079
|
-
else if (!(
|
|
1135
|
+
else if (!readWithin(abs, planPath, text, reads, maxMs)) problems.push(`${p} was not read by Main within ${cfg.guards.plan_read_max_hours} h`);
|
|
1080
1136
|
}
|
|
1081
1137
|
for (const [, cited = ""] of q.outsideProgress(text).matchAll(CITED_PATH)) {
|
|
1082
1138
|
const abs = planFile(cited, planPath, text);
|
|
1083
|
-
if (abs.includes("/docs/plans/") || named
|
|
1139
|
+
if (abs.includes("/docs/plans/") || namedOrTwin(named, abs, planPath, text) || !isFile(abs)) continue;
|
|
1084
1140
|
problems.push(`${cited} is cited but not listed under "## Code read by Main"`);
|
|
1085
1141
|
}
|
|
1086
1142
|
return problems;
|
|
@@ -1090,11 +1146,87 @@ function planReadProblems(text: string, planPath: string, cfg: Config): string[]
|
|
|
1090
1146
|
function planFile(p: string, planPath: string, text: string): string {
|
|
1091
1147
|
const home = q.expandHome(p);
|
|
1092
1148
|
if (path.isAbsolute(home)) return home;
|
|
1149
|
+
const roots = planRoots(planPath, text);
|
|
1150
|
+
const root = roots.find(r => isFile(path.join(r, home))) ?? roots[roots.length - 1]!;
|
|
1151
|
+
return path.join(root, home);
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
/** The roots a plan-relative path resolves against: the plan's Worktree (when set), then its repo (dirname³ of the plan file). */
|
|
1155
|
+
function planRoots(planPath: string, text: string): string[] {
|
|
1093
1156
|
const wt = /^Worktree:\s*(\S+)/m.exec(text)?.[1];
|
|
1094
1157
|
const repo = path.dirname(path.dirname(path.dirname(planPath)));
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1158
|
+
return wt && wt !== "-" ? [wt, repo] : [repo];
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/** The same repo-relative file under the plan's other root (Worktree ↔ main checkout), or null when `abs` sits under neither. */
|
|
1162
|
+
function twinFile(abs: string, planPath: string, text: string): string | null {
|
|
1163
|
+
const roots = planRoots(planPath, text);
|
|
1164
|
+
for (const root of roots) {
|
|
1165
|
+
const prefixed = root.endsWith("/") ? root : `${root}/`;
|
|
1166
|
+
if (!abs.startsWith(prefixed)) continue;
|
|
1167
|
+
for (const other of roots) {
|
|
1168
|
+
if (other === root) continue;
|
|
1169
|
+
return `${other.endsWith("/") ? other : `${other}/`}${abs.slice(prefixed.length)}`;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return null;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/** Main read this file within the window — at the resolved path or at its twin under the plan's other root (I-20261025-208 evidence: the same file read in the main checkout must cover its Worktree copy). */
|
|
1176
|
+
function readWithin(abs: string, planPath: string, text: string, reads: Record<string, string>, maxMs: number): boolean {
|
|
1177
|
+
const cutoff = Date.now() - maxMs;
|
|
1178
|
+
const fresh = (f: string) => Date.parse(reads[f] ?? "") >= cutoff;
|
|
1179
|
+
if (fresh(abs)) return true;
|
|
1180
|
+
const twin = twinFile(abs, planPath, text);
|
|
1181
|
+
return twin !== null && fresh(twin);
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/** The resolved path, or its twin under the plan's other root, is already in the set (cited-vs-listed matches files, not spellings). */
|
|
1185
|
+
function namedOrTwin(named: Set<string>, abs: string, planPath: string, text: string): boolean {
|
|
1186
|
+
if (named.has(abs)) return true;
|
|
1187
|
+
const twin = twinFile(abs, planPath, text);
|
|
1188
|
+
return twin !== null && named.has(twin);
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
/**
|
|
1192
|
+
* Cited paths (outside Progress) Main read within the window but the list omits: returns the plan
|
|
1193
|
+
* text with one `- \`<path as cited>\`` line appended to "## Code read by Main" (the section is
|
|
1194
|
+
* created before "## Progress" when missing), or null when nothing qualifies. Never-read citations
|
|
1195
|
+
* stay out: they are refused like today.
|
|
1196
|
+
*/
|
|
1197
|
+
function autoListReads(text: string, planPath: string, cfg: Config): { text: string; paths: string[] } | null {
|
|
1198
|
+
const reads = readMainReads();
|
|
1199
|
+
const maxMs = cfg.guards.plan_read_max_hours * 3_600_000;
|
|
1200
|
+
const covered = new Set<string>();
|
|
1201
|
+
for (const p of [...(READ_SECTION.exec(text)?.[1] ?? "").matchAll(LISTED_PATH)].map(m => (m[1] ?? "").replace(/:[\d,+\- ]+$/, "")))
|
|
1202
|
+
covered.add(planFile(p, planPath, text));
|
|
1203
|
+
const added: string[] = [];
|
|
1204
|
+
const seen = new Set<string>();
|
|
1205
|
+
for (const [, cited = ""] of q.outsideProgress(text).matchAll(CITED_PATH)) {
|
|
1206
|
+
const abs = planFile(cited, planPath, text);
|
|
1207
|
+
if (abs.includes("/docs/plans/") || seen.has(cited) || !isFile(abs)) continue;
|
|
1208
|
+
if (namedOrTwin(covered, abs, planPath, text)) continue;
|
|
1209
|
+
if (!readWithin(abs, planPath, text, reads, maxMs)) continue;
|
|
1210
|
+
seen.add(cited);
|
|
1211
|
+
covered.add(abs);
|
|
1212
|
+
added.push(cited);
|
|
1213
|
+
}
|
|
1214
|
+
if (!added.length) return null;
|
|
1215
|
+
const lines = added.map(p => `- \`${p}\``);
|
|
1216
|
+
const m = READ_SECTION.exec(text);
|
|
1217
|
+
let out: string;
|
|
1218
|
+
if (m && m[1] !== undefined) {
|
|
1219
|
+
// Append after the section's last entry, ahead of the blank lines before the next heading.
|
|
1220
|
+
const bodyStart = m.index + m[0].length - m[1].length;
|
|
1221
|
+
const at = bodyStart + m[1].replace(/\s+$/, "").length;
|
|
1222
|
+
out = `${text.slice(0, at)}\n${lines.join("\n")}${text.slice(at)}`;
|
|
1223
|
+
} else {
|
|
1224
|
+
// No section yet: create it right before "## Progress" (or at the end when that is missing too).
|
|
1225
|
+
const at = text.search(/^## Progress\b/m);
|
|
1226
|
+
const block = `## Code read by Main\n${lines.join("\n")}\n\n`;
|
|
1227
|
+
out = at === -1 ? `${text}${block}` : `${text.slice(0, at)}${block}${text.slice(at)}`;
|
|
1228
|
+
}
|
|
1229
|
+
return { text: out, paths: added };
|
|
1098
1230
|
}
|
|
1099
1231
|
|
|
1100
1232
|
function isFile(file: string): boolean {
|
package/src/core/owner-ui.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { cpuCount } from "./host.ts";
|
|
|
19
19
|
import { openIncidents } from "./incidents.ts";
|
|
20
20
|
import { log } from "./guards.ts";
|
|
21
21
|
import { readMetricEvents } from "./metrics.ts";
|
|
22
|
-
import { activePlans, chatUnlock, expandHome, stateDirPath, unlockPath, type Plan } from "./queue/lib.ts";
|
|
22
|
+
import { activePlans, chatUnlock, dependencyOrderProblems, expandHome, stateDirPath, unlockPath, type Plan } from "./queue/lib.ts";
|
|
23
23
|
import type { Tailscale } from "./tailscale.ts";
|
|
24
24
|
|
|
25
25
|
const ANSWER_MAX = 2000;
|
|
@@ -711,8 +711,25 @@ export function dropSlot(mids: number[], mid: number): number {
|
|
|
711
711
|
return mids.length;
|
|
712
712
|
}
|
|
713
713
|
|
|
714
|
+
/**
|
|
715
|
+
* Autoscroll speed in px/frame while a drag is held near the screen edge (P5b): 0 outside a
|
|
716
|
+
* 72 px band, negative in the top band, positive in the bottom band, growing toward the edge,
|
|
717
|
+
* capped at 24 px/frame. Pure and exported so the page script — which inlines this exact
|
|
718
|
+
* source via toString() — and the test run the same code.
|
|
719
|
+
*/
|
|
720
|
+
export function edgeScrollStep(y: number, viewportH: number): number {
|
|
721
|
+
const BAND = 72;
|
|
722
|
+
const CAP = 24;
|
|
723
|
+
const fromTop = BAND - y;
|
|
724
|
+
const fromBottom = y - (viewportH - BAND);
|
|
725
|
+
if (fromTop > 0) return -Math.min(CAP, Math.ceil((CAP * fromTop) / BAND));
|
|
726
|
+
if (fromBottom > 0) return Math.min(CAP, Math.ceil((CAP * fromBottom) / BAND));
|
|
727
|
+
return 0;
|
|
728
|
+
}
|
|
729
|
+
|
|
714
730
|
const SCRIPT = `(function(){
|
|
715
731
|
var dropSlot=${dropSlot.toString()};
|
|
732
|
+
var edgeScrollStep=${edgeScrollStep.toString()};
|
|
716
733
|
// Keep only the tab in the address bar: receipts are one-time DOM, not a reloadable URL.
|
|
717
734
|
if(location.search){var keep=new URLSearchParams(location.search).get("tab");history.replaceState(null,"",location.pathname+(keep?"?tab="+keep:""));}
|
|
718
735
|
function store(d,v){var k="nsui:"+d.id;if(v===undefined)return sessionStorage.getItem(k);sessionStorage.setItem(k,v?"1":"0");}
|
|
@@ -746,10 +763,16 @@ function navigate(href){swapMain(href,true,true).catch(function(){showNetErr();}
|
|
|
746
763
|
function refreshNow(){if(swapping)return;swapping=true;swapMain(location.href,false,false).catch(function(){}).then(function(){swapping=false;});}
|
|
747
764
|
function showNetErr(){var d=showReceipt("Couldn't reach the page — tap to retry");if(d)d.setAttribute("data-js","neterr");}
|
|
748
765
|
var drag=null;
|
|
749
|
-
|
|
766
|
+
// One drag move: place the floating card at pointer Y and drop the placeholder between the
|
|
767
|
+
// cards around it. Also re-run after every autoscroll step, since scrolling moved the midpoints.
|
|
768
|
+
function dragMove(y){if(!drag)return;var card=drag.card,list=drag.list;card.style.transform="translateY("+(y-drag.y0)+"px)";var r=card.getBoundingClientRect();var mid=r.top+r.height/2;var mids=[];var els=[];var ch=list.children;for(var i=0;i<ch.length;i++){var el=ch[i];if(el===card||el===drag.ph)continue;var er=el.getBoundingClientRect();mids.push(er.top+er.height/2);els.push(el);}
|
|
750
769
|
var k=dropSlot(mids,mid);
|
|
751
|
-
if(k<mids.length){if(els[k].previousElementSibling!==drag.ph)list.insertBefore(drag.ph,els[k]);}else if(mids.length&&els[mids.length-1].nextElementSibling!==drag.ph){list.insertBefore(drag.ph,els[mids.length-1].nextSibling);}}
|
|
752
|
-
|
|
770
|
+
if(k<mids.length){if(els[k].previousElementSibling!==drag.ph)list.insertBefore(drag.ph,els[k]);}else if(mids.length&&els[mids.length-1].nextElementSibling!==drag.ph){list.insertBefore(drag.ph,els[mids.length-1].nextSibling);}}
|
|
771
|
+
window.addEventListener("pointermove",function(e){if(!drag||e.pointerId!==drag.id)return;drag.y=e.clientY;dragMove(drag.y);});
|
|
772
|
+
// P5b: a finger held still at the screen edge fires no pointermove, so a rAF loop keeps
|
|
773
|
+
// scrolling by edgeScrollStep and re-drops the placeholder while it scrolls; endDrag stops it.
|
|
774
|
+
function dragFrame(){if(!drag)return;var dy=edgeScrollStep(drag.y,window.innerHeight);if(dy){window.scrollBy(0,dy);dragMove(drag.y);}requestAnimationFrame(dragFrame);}
|
|
775
|
+
var endDrag=function(e,submitIt){if(!drag||(e&&e.pointerId!==undefined&&e.pointerId!==drag.id))return;var card=drag.card,ph=drag.ph,list=drag.list;if(drag.raf)cancelAnimationFrame(drag.raf);card.classList.remove("dragging");card.style.transform="";card.style.width="";card.style.left="";card.style.top="";list.insertBefore(card,ph);list.removeChild(ph);drag=null;if(submitIt)sendReorder(card.getAttribute("data-plan"),list);else dragging=false;};
|
|
753
776
|
window.addEventListener("pointerup",function(e){endDrag(e,true);});
|
|
754
777
|
window.addEventListener("pointercancel",function(e){endDrag(e,false);});
|
|
755
778
|
// Every POST form goes over fetch and swaps main in place (P11b); a no-JS browser still submits for real and gets the 303s.
|
|
@@ -782,7 +805,7 @@ var qlist=main.querySelector("#qlist");
|
|
|
782
805
|
if(qlist){
|
|
783
806
|
var moveCard=function(card,how){if(how==="top"){var f=qlist.querySelector(".qcard");if(f&&f!==card)qlist.insertBefore(card,f);}else if(how==="up"){var p=card.previousElementSibling;if(p&&p.classList.contains("qcard"))qlist.insertBefore(card,p);}else if(how==="down"){var n=card.nextElementSibling;if(n&&n.classList.contains("qcard"))qlist.insertBefore(card,n.nextSibling);}};
|
|
784
807
|
qlist.addEventListener("click",function(e){var t=e.target;if(!t||!t.closest)return;var b=t.closest(".qmove");if(!b)return;var card=t.closest(".qcard");if(!card)return;moveCard(card,b.getAttribute("data-move"));sendReorder(card.getAttribute("data-plan"),qlist);});
|
|
785
|
-
qlist.addEventListener("pointerdown",function(e){var t=e.target;if(!t||!t.closest)return;var h=t.closest(".qhandle");if(h&&!drag){var card=t.closest(".qcard");if(card){e.preventDefault();dragging=true;var r=card.getBoundingClientRect();var ph=document.createElement("li");ph.className="qph";ph.style.height=r.height+"px";qlist.insertBefore(ph,card);card.classList.add("dragging");card.style.width=r.width+"px";card.style.left=r.left+"px";card.style.top=r.top+"px";drag={card:card,ph:ph,y0:e.clientY,id:e.pointerId,list:qlist};try{h.setPointerCapture(e.pointerId);}catch(_){}}}});
|
|
808
|
+
qlist.addEventListener("pointerdown",function(e){var t=e.target;if(!t||!t.closest)return;var h=t.closest(".qhandle");if(h&&!drag){var card=t.closest(".qcard");if(card){e.preventDefault();dragging=true;var r=card.getBoundingClientRect();var ph=document.createElement("li");ph.className="qph";ph.style.height=r.height+"px";qlist.insertBefore(ph,card);card.classList.add("dragging");card.style.width=r.width+"px";card.style.left=r.left+"px";card.style.top=r.top+"px";drag={card:card,ph:ph,y0:e.clientY,y:e.clientY,id:e.pointerId,list:qlist,raf:0};try{h.setPointerCapture(e.pointerId);}catch(_){}requestAnimationFrame(dragFrame);}}}});
|
|
786
809
|
}
|
|
787
810
|
}
|
|
788
811
|
function busy(){if(dragging)return true;var els=document.querySelectorAll("input:not([type=hidden]), textarea");for(var k=0;k<els.length;k++){if(els[k]===document.activeElement||els[k].value)return true;}return false;}
|
|
@@ -1220,9 +1243,9 @@ function handleReorder(cfg: Config, fields: Record<string, string>, login: strin
|
|
|
1220
1243
|
const fail = (error: string, status: number): Response =>
|
|
1221
1244
|
wantsJson ? Response.json({ ok: false, error }, { status }) : textRes(error, status);
|
|
1222
1245
|
// One source of truth for the reorderable set: the open plans, the same list queueRows renders.
|
|
1223
|
-
const
|
|
1224
|
-
|
|
1225
|
-
|
|
1246
|
+
const openPlans = activePlans(index).filter(p => p.status === "open");
|
|
1247
|
+
const openPaths = openPlans.map(p => p.file);
|
|
1248
|
+
const openPlan: Record<string, Plan> = Object.fromEntries(openPlans.map(p => [p.file, p]));
|
|
1226
1249
|
if (!moved || !order.length) return fail("order and moved are required", 400);
|
|
1227
1250
|
// 400: the posted order must be exactly the open plans the page renders now — no adds, drops or duplicates.
|
|
1228
1251
|
if (new Set(order).size !== order.length) return fail("order lists a plan more than once", 400);
|
|
@@ -1233,6 +1256,11 @@ function handleReorder(cfg: Config, fields: Record<string, string>, login: strin
|
|
|
1233
1256
|
// 409: the order the page was rendered with must still be the open plans' current order.
|
|
1234
1257
|
const stale = before.length !== openPaths.length || before.some((p, i) => p !== openPaths[i]);
|
|
1235
1258
|
if (stale) return fail("the queue changed since the page loaded — reload and drag again", 409);
|
|
1259
|
+
// 409: the index is priority (I-20261025-208), so the posted order itself may not put a plan
|
|
1260
|
+
// above the open plan it waits on. Checked before any write: the index file and the reorder
|
|
1261
|
+
// inbox stay untouched, and the page's 409 branch shows the message and reloads the real order.
|
|
1262
|
+
const firstBlock = dependencyOrderProblems(order.map(o => openPlan[o]!))[0];
|
|
1263
|
+
if (firstBlock) return fail(`blocked: ${firstBlock}`, 409);
|
|
1236
1264
|
const from = openPaths.indexOf(moved);
|
|
1237
1265
|
const to = order.indexOf(moved);
|
|
1238
1266
|
if (from === -1 || to === -1) return fail("moved is not one of the page's plans", 400);
|
package/src/core/queue/lib.ts
CHANGED
|
@@ -807,6 +807,28 @@ export function awaitingMerge(p: Plan): boolean {
|
|
|
807
807
|
return p.status === "complete" && /^queue-close: AWAITING merge/.test(lastCloseResult(p.file) ?? "");
|
|
808
808
|
}
|
|
809
809
|
|
|
810
|
+
/**
|
|
811
|
+
* I-20261025-208: index order is priority, so an open plan must never sit above an open plan of
|
|
812
|
+
* this list it waits on. A "Waits on" target that is not an open plan of the list (complete,
|
|
813
|
+
* cancelled, gone from the index) imposes no order. Pure: queueProblems, queueSummary and the
|
|
814
|
+
* page's /reorder refusal all read it.
|
|
815
|
+
*/
|
|
816
|
+
export function dependencyOrderProblems(plans: Plan[]): string[] {
|
|
817
|
+
const rank = new Map(plans.map((p, i) => [p.file, i] as const));
|
|
818
|
+
const open = new Map(plans.filter(p => p.status === "open").map(p => [p.file, p] as const));
|
|
819
|
+
const problems: string[] = [];
|
|
820
|
+
plans.forEach((p, i) => {
|
|
821
|
+
if (p.status !== "open") return;
|
|
822
|
+
for (const f of p.waitsOn) {
|
|
823
|
+
const j = rank.get(f);
|
|
824
|
+
const target = open.get(f);
|
|
825
|
+
if (j === undefined || j <= i || !target) continue;
|
|
826
|
+
problems.push(`#${i + 1} ${p.title} waits on #${j + 1} ${target.title}; it cannot sit above it — move #${j + 1} up first or remove the "Waits on" line`);
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
return problems;
|
|
830
|
+
}
|
|
831
|
+
|
|
810
832
|
export interface QueueProblem {
|
|
811
833
|
where: string;
|
|
812
834
|
problem: string;
|
|
@@ -815,8 +837,9 @@ export interface QueueProblem {
|
|
|
815
837
|
export function queueProblems(index = INDEX, blockersDir = BLOCKERS_DIR): QueueProblem[] {
|
|
816
838
|
const probs: QueueProblem[] = [];
|
|
817
839
|
if (!existsSync(index)) probs.push({ where: index, problem: "main index missing: create it (empty = no open work)" });
|
|
840
|
+
const plans = readPlans(readIndex(index), blockersDir);
|
|
818
841
|
const byWorktree = new Map<string, Plan[]>();
|
|
819
|
-
for (const p of
|
|
842
|
+
for (const p of plans) {
|
|
820
843
|
for (const e of p.errors) probs.push({ where: p.file, problem: e });
|
|
821
844
|
if ((p.status === "complete" || p.status === "cancelled") && !awaitingMerge(p)) {
|
|
822
845
|
const last = lastCloseResult(p.file);
|
|
@@ -833,6 +856,11 @@ export function queueProblems(index = INDEX, blockersDir = BLOCKERS_DIR): QueueP
|
|
|
833
856
|
for (const [wt, ps] of byWorktree)
|
|
834
857
|
if (ps.length > 1)
|
|
835
858
|
probs.push({ where: wt, problem: `${ps.length} open plans name this worktree (${ps.map(p => p.file).join(", ")}); one plan = one worktree` });
|
|
859
|
+
// I-20261025-208: one problem per misranked plan, so queue-check exits 1 and the summary lists it.
|
|
860
|
+
for (const m of dependencyOrderProblems(plans)) {
|
|
861
|
+
const i = Number(/^#(\d+) /.exec(m)?.[1] ?? 0);
|
|
862
|
+
probs.push({ where: plans[i - 1]?.file ?? index, problem: m });
|
|
863
|
+
}
|
|
836
864
|
return probs;
|
|
837
865
|
}
|
|
838
866
|
|
|
@@ -840,12 +868,21 @@ export function queueSummary(index = INDEX): string {
|
|
|
840
868
|
// Index order IS priority (20261025_0215_index_priority): the list is flat and ranked,
|
|
841
869
|
// rank 1 = the index's top line; repos only surface through each plan's own path.
|
|
842
870
|
const plans = activePlans(index);
|
|
871
|
+
const rank = new Map(plans.map((p, i) => [p.file, i + 1] as const));
|
|
843
872
|
const repos = [...new Set(plans.map(p => p.repo))];
|
|
844
873
|
const lines = [`Queue (${index}): ${plans.length ? `${plans.length} plan(s) in ${repos.length} repo(s)` : "empty, no open work"}`];
|
|
845
874
|
plans.forEach((p, i) => {
|
|
846
875
|
const status = awaitingMerge(p) ? "complete, awaiting merge" : (p.status ?? "INVALID");
|
|
847
876
|
const hold = p.waiting ? `WAITING on owner: ${(p.waitingLine ?? "").slice(0, 80)}` : "";
|
|
848
|
-
|
|
877
|
+
// I-20261025-208: an open plan waiting on an open plan of the queue shows the target's rank.
|
|
878
|
+
const waits: string[] = [];
|
|
879
|
+
if (p.status === "open")
|
|
880
|
+
for (const f of p.waitsOn) {
|
|
881
|
+
const at = rank.get(f);
|
|
882
|
+
if (at === undefined || plans[at - 1]!.status !== "open") continue;
|
|
883
|
+
waits.push(`waits on #${at}`);
|
|
884
|
+
}
|
|
885
|
+
const flags = [status, hold, ...waits, p.priorityId ?? ""].filter(Boolean).join(", ");
|
|
849
886
|
const goal = items(sections(p.text).get("goal") ?? "")[0]?.slice(0, 100) ?? "";
|
|
850
887
|
lines.push(` ${i + 1}. ${p.file} [${flags}] ${goal}`);
|
|
851
888
|
});
|
package/templates/AGENTS.md
CHANGED
|
@@ -28,4 +28,4 @@ You are Main, the orchestrator. Main plans, delegates, reviews and lands; implem
|
|
|
28
28
|
|
|
29
29
|
Guard files are locked for every agent; the owner unlocks with `touch {{AGENT_DIR}}/.guard-unlock` (30 min), or — when `guards.chat_unlock` is on in the config — by typing `unlock 30` in chat (`lock` closes it again).
|
|
30
30
|
|
|
31
|
-
Autonomy tiers: the owner sets how much Main does unattended with one word — `tier strict` (edit cap `autonomy.strict_edit_limit`; every `git push`, `glab mr merge` or `gh pr merge` also waits until the owner types `go
|
|
31
|
+
Autonomy tiers: the owner sets how much Main does unattended with one word — `tier strict` (edit cap `autonomy.strict_edit_limit`; every `git push`, `glab mr merge` or `gh pr merge` also waits until the owner types the approve phrase from `autonomy.go_phrase` (default `go push`; a bare `go` is an ordinary message), which approves exactly one landing for `autonomy.go_minutes` minutes), `tier opinionated` (the limits above), or `tier full` (no edit cap, and a `Priority skip: <plan> — Main: "<reason>"` line with a reason of at least four words may skip an idle higher plan). Pushes stay owner-ruled in strict and opinionated as above; whatever the tier, guard files, the phone page, notify secrets and the unlock stay owner-only.
|
package/templates/config.yml
CHANGED
|
@@ -128,7 +128,8 @@ guards:
|
|
|
128
128
|
autonomy:
|
|
129
129
|
tier: opinionated # strict | opinionated | full: how much Main does without asking; the owner moves it with `tier <name>` in chat or a button on the phone page
|
|
130
130
|
strict_edit_limit: 2 # Main's project-file changes per main_window_min in tier strict
|
|
131
|
-
go_minutes: 10 # minutes
|
|
131
|
+
go_minutes: 10 # minutes the approve phrase approves exactly one push/merge in tier strict
|
|
132
|
+
go_phrase: "go push" # the whole chat message that approves one push/merge in tier strict (I-20261025-201); a bare `go` is an ordinary message
|
|
132
133
|
|
|
133
134
|
ui:
|
|
134
135
|
enabled: false # the owner's phone page (neurastream ui); binds the tailnet address only
|