harnery 0.31.6 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +2 -0
- package/dist/commands/agents.d.ts +0 -9
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +70 -95
- package/dist/commands/browse-session.d.ts +21 -0
- package/dist/commands/browse-session.d.ts.map +1 -0
- package/dist/commands/browse-session.js +157 -0
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +205 -37
- package/dist/commands/checkpoint.js +1 -1
- package/dist/commands/deinit.d.ts.map +1 -1
- package/dist/commands/deinit.js +4 -0
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +40 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +100 -17
- package/dist/commands/init.d.ts +1 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +16 -5
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +2 -3
- package/dist/core/agents/canonical-emit.d.ts +1 -2
- package/dist/core/agents/canonical-emit.d.ts.map +1 -1
- package/dist/core/agents/canonical-emit.js +1 -2
- package/dist/core/agents/cli.js +123 -88
- package/dist/core/agents/coord-client.d.ts +7 -3
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +5 -4
- package/dist/core/agents/finalization.d.ts +68 -0
- package/dist/core/agents/finalization.d.ts.map +1 -0
- package/dist/core/agents/finalization.js +443 -0
- package/dist/core/agents/git-hook.d.ts +51 -0
- package/dist/core/agents/git-hook.d.ts.map +1 -0
- package/dist/core/agents/git-hook.js +118 -0
- package/dist/core/agents/render/prompt-context.d.ts +6 -5
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +26 -13
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +15 -2
- package/dist/core/agents/rules/claim-conflict.js +3 -3
- package/dist/core/agents/rules/commit-conflict.d.ts +15 -6
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/commit-conflict.js +21 -5
- package/dist/core/agents/rules/stop-hook.d.ts +3 -0
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +59 -23
- package/dist/core/agents/session-events.d.ts +8 -16
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +12 -26
- package/dist/core/agents/state/heartbeat-projector.d.ts +3 -0
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-projector.js +44 -1
- package/dist/core/agents/state/heartbeat-writer.d.ts +32 -5
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +54 -17
- package/dist/core/agents/state/names.d.ts +22 -1
- package/dist/core/agents/state/names.d.ts.map +1 -1
- package/dist/core/agents/state/names.js +40 -2
- package/dist/core/config.d.ts +30 -2
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +74 -11
- package/dist/core/governor/planning.d.ts.map +1 -1
- package/dist/core/governor/planning.js +12 -13
- package/dist/core/hooks/adapter/detect.d.ts +2 -4
- package/dist/core/hooks/adapter/detect.d.ts.map +1 -1
- package/dist/core/hooks/adapter/detect.js +4 -14
- package/dist/core/hooks/adapter/output.d.ts +1 -1
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.js +5 -4
- package/dist/core/hooks/adapter/wiring.d.ts +23 -0
- package/dist/core/hooks/adapter/wiring.d.ts.map +1 -1
- package/dist/core/hooks/adapter/wiring.js +32 -0
- package/dist/core/hooks/cli.d.ts +1 -2
- package/dist/core/hooks/cli.d.ts.map +1 -1
- package/dist/core/hooks/cli.js +169 -27
- package/dist/core/hooks/codex-wsl-bridge.d.ts +46 -0
- package/dist/core/hooks/codex-wsl-bridge.d.ts.map +1 -0
- package/dist/core/hooks/codex-wsl-bridge.js +137 -0
- package/dist/core/hooks/effects/index.d.ts +1 -1
- package/dist/core/hooks/effects/index.js +3 -3
- package/dist/core/hooks/events/schema.d.ts +27 -0
- package/dist/core/hooks/events/schema.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.d.ts +7 -1
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +15 -0
- package/dist/core/hooks/resolve/transcript.d.ts +44 -0
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +176 -1
- package/dist/core/hooks/session-name-presence.d.ts +30 -0
- package/dist/core/hooks/session-name-presence.d.ts.map +1 -0
- package/dist/core/hooks/session-name-presence.js +43 -0
- package/dist/core/hooks/unsafe-cross-shell.d.ts +13 -0
- package/dist/core/hooks/unsafe-cross-shell.d.ts.map +1 -0
- package/dist/core/hooks/unsafe-cross-shell.js +151 -0
- package/dist/core/work/state.d.ts +4 -5
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +5 -8
- package/dist/core/workflow/index.d.ts +1 -1
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/proof.d.ts +2 -2
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +2 -2
- package/dist/core/workflow/run-state.d.ts +2 -2
- package/dist/core/workflow/run-state.d.ts.map +1 -1
- package/dist/core/workflow/run-state.js +2 -2
- package/dist/core/workflow/types.d.ts +3 -3
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/execution.d.ts +2 -2
- package/dist/core/workflow/workspaces/execution.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/execution.js +5 -0
- package/dist/core/workflow/workspaces/index.d.ts +1 -1
- package/dist/core/workflow/workspaces/index.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/local-git.js +1 -2
- package/dist/core/workflow/workspaces/paths.d.ts +2 -2
- package/dist/core/workflow/workspaces/types.d.ts +0 -6
- package/dist/core/workflow/workspaces/types.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/validate.d.ts +0 -2
- package/dist/core/workflow/workspaces/validate.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/validate.js +0 -2
- package/dist/lib/browser/client.d.ts +118 -1
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +435 -6
- package/dist/lib/browser/geometry.d.ts.map +1 -1
- package/dist/lib/browser/geometry.js +180 -37
- package/dist/lib/browser/index.d.ts +5 -1
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +5 -1
- package/dist/lib/browser/netscape-cookies.d.ts +6 -0
- package/dist/lib/browser/netscape-cookies.d.ts.map +1 -0
- package/dist/lib/browser/netscape-cookies.js +31 -0
- package/dist/lib/browser/proxy.d.ts +24 -0
- package/dist/lib/browser/proxy.d.ts.map +1 -0
- package/dist/lib/browser/proxy.js +84 -0
- package/dist/lib/browser/runts.d.ts +6 -0
- package/dist/lib/browser/runts.d.ts.map +1 -1
- package/dist/lib/browser/runts.js +21 -4
- package/dist/lib/browser/session-control.d.ts +112 -0
- package/dist/lib/browser/session-control.d.ts.map +1 -0
- package/dist/lib/browser/session-control.js +670 -0
- package/dist/lib/docs-links.d.ts +108 -0
- package/dist/lib/docs-links.d.ts.map +1 -0
- package/dist/lib/docs-links.js +555 -0
- package/dist/lib/exec.d.ts +1 -1
- package/dist/lib/exec.js +1 -1
- package/dist/lib/identities/assume.d.ts +4 -2
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +15 -2
- package/dist/lib/instructions/git-hooks.d.ts +75 -0
- package/dist/lib/instructions/git-hooks.d.ts.map +1 -0
- package/dist/lib/instructions/git-hooks.js +238 -0
- package/dist/lib/instructions/splice.d.ts +10 -4
- package/dist/lib/instructions/splice.d.ts.map +1 -1
- package/dist/lib/instructions/splice.js +19 -11
- package/package.json +1 -1
- package/schemas/config.schema.json +32 -0
- package/src/commander.ts +2 -0
- package/src/commands/agents.ts +96 -115
- package/src/commands/browse-session.ts +245 -0
- package/src/commands/browse.ts +287 -44
- package/src/commands/checkpoint.ts +1 -1
- package/src/commands/deinit.ts +7 -1
- package/src/commands/docs.ts +56 -0
- package/src/commands/doctor.ts +100 -18
- package/src/commands/init.ts +17 -9
- package/src/commands/tunnel.ts +2 -5
- package/src/core/agents/canonical-emit.ts +1 -2
- package/src/core/agents/cli.ts +137 -88
- package/src/core/agents/coord-client.ts +10 -5
- package/src/core/agents/finalization.ts +595 -0
- package/src/core/agents/git-hook.ts +126 -0
- package/src/core/agents/render/prompt-context.ts +28 -13
- package/src/core/agents/render/session-context.ts +15 -2
- package/src/core/agents/rules/claim-conflict.ts +3 -3
- package/src/core/agents/rules/commit-conflict.ts +35 -8
- package/src/core/agents/rules/stop-hook.ts +71 -23
- package/src/core/agents/session-events.ts +14 -41
- package/src/core/agents/state/heartbeat-projector.ts +45 -1
- package/src/core/agents/state/heartbeat-writer.ts +78 -16
- package/src/core/agents/state/names.ts +54 -2
- package/src/core/config.ts +92 -12
- package/src/core/governor/planning.ts +17 -12
- package/src/core/hooks/adapter/detect.ts +4 -13
- package/src/core/hooks/adapter/output.ts +9 -4
- package/src/core/hooks/adapter/wiring.ts +43 -0
- package/src/core/hooks/cli.ts +201 -23
- package/src/core/hooks/codex-wsl-bridge.ts +188 -0
- package/src/core/hooks/effects/index.ts +5 -5
- package/src/core/hooks/events/schema.ts +27 -0
- package/src/core/hooks/resolve/owner.ts +22 -1
- package/src/core/hooks/resolve/transcript.ts +164 -1
- package/src/core/hooks/session-name-presence.ts +52 -0
- package/src/core/hooks/unsafe-cross-shell.ts +160 -0
- package/src/core/work/state.ts +8 -12
- package/src/core/workflow/engine.ts +2 -2
- package/src/core/workflow/index.ts +0 -1
- package/src/core/workflow/proof.ts +4 -4
- package/src/core/workflow/run-state.ts +5 -5
- package/src/core/workflow/types.ts +3 -3
- package/src/core/workflow/workspaces/execution.ts +11 -4
- package/src/core/workflow/workspaces/index.ts +0 -3
- package/src/core/workflow/workspaces/local-git.ts +1 -2
- package/src/core/workflow/workspaces/paths.ts +2 -2
- package/src/core/workflow/workspaces/types.ts +0 -9
- package/src/core/workflow/workspaces/validate.ts +1 -5
- package/src/lib/browser/client.ts +528 -6
- package/src/lib/browser/geometry.ts +197 -37
- package/src/lib/browser/index.ts +39 -0
- package/src/lib/browser/netscape-cookies.ts +39 -0
- package/src/lib/browser/proxy.ts +105 -0
- package/src/lib/browser/runts.ts +27 -3
- package/src/lib/browser/session-control.ts +892 -0
- package/src/lib/docs-links.ts +674 -0
- package/src/lib/exec.ts +1 -1
- package/src/lib/identities/assume.ts +22 -1
- package/src/lib/instructions/git-hooks.ts +259 -0
- package/src/lib/instructions/splice.ts +41 -11
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git-plumbing collection for `agent-coord git-hook <event>` — the in-process
|
|
3
|
+
* replacement for the bash that host pre-commit / post-commit / post-checkout
|
|
4
|
+
* hooks used to carry.
|
|
5
|
+
*
|
|
6
|
+
* Everything here is a port of hook logic that lived in host repos as shell:
|
|
7
|
+
* staged-path collection with rename handling, submodule canonicalization,
|
|
8
|
+
* the gitlink probe, and the clean-in-worktree checks that gate claim pruning.
|
|
9
|
+
* Owning it here means a harnery upgrade upgrades the behavior; the host hook
|
|
10
|
+
* file keeps only a stable managed region that invokes `git-hook <event>`.
|
|
11
|
+
*
|
|
12
|
+
* All functions take an explicit cwd and return data — no printing, no
|
|
13
|
+
* process.exit — so they unit-test against a temp repo.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { spawnSync } from "node:child_process";
|
|
17
|
+
|
|
18
|
+
export type GitHookEvent = "pre-commit" | "post-commit" | "post-checkout";
|
|
19
|
+
|
|
20
|
+
function git(args: string[], cwd: string): string {
|
|
21
|
+
const r = spawnSync("git", args, { cwd, encoding: "utf8", timeout: 5000 });
|
|
22
|
+
return r.status === 0 ? (r.stdout ?? "") : "";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The coordination root for a hook firing in `cwd`: the superproject when the
|
|
27
|
+
* repo is a submodule, else the repo's own toplevel. Pinning to the
|
|
28
|
+
* superproject matters because some submodules carry a config-only `.harnery/`
|
|
29
|
+
* that a cwd walk would land on, running the check against an empty claims dir.
|
|
30
|
+
*/
|
|
31
|
+
export function discoverCoordRoot(cwd: string): string | null {
|
|
32
|
+
const superproject = git(["rev-parse", "--show-superproject-working-tree"], cwd).trim();
|
|
33
|
+
if (superproject) return superproject;
|
|
34
|
+
const toplevel = git(["rev-parse", "--show-toplevel"], cwd).trim();
|
|
35
|
+
return toplevel || null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Monorepo-relative prefix when `cwd` is inside a submodule ("" in the parent). */
|
|
39
|
+
export function submodulePrefix(cwd: string): string {
|
|
40
|
+
const superproject = git(["rev-parse", "--show-superproject-working-tree"], cwd).trim();
|
|
41
|
+
if (!superproject) return "";
|
|
42
|
+
const toplevel = git(["rev-parse", "--show-toplevel"], cwd).trim();
|
|
43
|
+
if (!toplevel.startsWith(`${superproject}/`)) return "";
|
|
44
|
+
return toplevel.slice(superproject.length + 1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Parse `--name-status -M` output into repo-local paths. Renames/copies emit
|
|
49
|
+
* BOTH sides so the source's claim releases too; plain statuses emit one.
|
|
50
|
+
*/
|
|
51
|
+
export function parseNameStatus(output: string): string[] {
|
|
52
|
+
const paths: string[] = [];
|
|
53
|
+
for (const line of output.split("\n")) {
|
|
54
|
+
if (!line.trim()) continue;
|
|
55
|
+
const parts = line.split("\t");
|
|
56
|
+
const status = parts[0] ?? "";
|
|
57
|
+
if (/^[RC]/.test(status)) {
|
|
58
|
+
if (parts[1]) paths.push(parts[1]);
|
|
59
|
+
if (parts[2]) paths.push(parts[2]);
|
|
60
|
+
} else if (parts[1]) {
|
|
61
|
+
paths.push(parts[1]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return paths;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function canonicalize(paths: string[], prefix: string): string[] {
|
|
68
|
+
return prefix ? paths.map((p) => `${prefix}/${p}`) : [...paths];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Is this repo-local path a submodule gitlink (mode 160000) in the index? */
|
|
72
|
+
function isGitlink(path: string, cwd: string): boolean {
|
|
73
|
+
return git(["ls-files", "--stage", "--", path], cwd).startsWith("160000 ");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Is this repo-local path clean in the worktree (no unstaged residue)? */
|
|
77
|
+
function isCleanInWorktree(path: string, cwd: string): boolean {
|
|
78
|
+
return git(["status", "--porcelain", "--", path], cwd).trim() === "";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* pre-commit: staged paths (canonical, monorepo-relative) plus which of them
|
|
83
|
+
* are submodule gitlinks — a parent-repo pointer bump is not a claim on the
|
|
84
|
+
* submodule's contents, and the conflict rule's prefix matcher needs to know.
|
|
85
|
+
*/
|
|
86
|
+
export function collectStaged(cwd: string): { staged: string[]; gitlinks: string[] } {
|
|
87
|
+
const out = git(["diff", "--cached", "--name-status", "-M"], cwd);
|
|
88
|
+
const local = parseNameStatus(out);
|
|
89
|
+
const prefix = submodulePrefix(cwd);
|
|
90
|
+
const staged = canonicalize(local, prefix);
|
|
91
|
+
const gitlinks: string[] = [];
|
|
92
|
+
for (let i = 0; i < local.length; i++) {
|
|
93
|
+
const l = local[i]!;
|
|
94
|
+
if (isGitlink(l, cwd)) gitlinks.push(staged[i]!);
|
|
95
|
+
}
|
|
96
|
+
return { staged, gitlinks };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* post-commit: paths the just-landed HEAD commit touched that are now clean in
|
|
101
|
+
* the worktree. A path with unstaged residue keeps its claim — the agent is
|
|
102
|
+
* still mid-work on it.
|
|
103
|
+
*/
|
|
104
|
+
export function collectCommitted(cwd: string): string[] {
|
|
105
|
+
// --root: a repo's first commit has no parent; without it diff-tree emits
|
|
106
|
+
// nothing and the root commit's claims never prune (a bash-era blind spot).
|
|
107
|
+
const out = git(
|
|
108
|
+
["diff-tree", "--no-commit-id", "--name-status", "-M", "-r", "--root", "HEAD"],
|
|
109
|
+
cwd,
|
|
110
|
+
);
|
|
111
|
+
const local = parseNameStatus(out).filter((p) => isCleanInWorktree(p, cwd));
|
|
112
|
+
return canonicalize(local, submodulePrefix(cwd));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* post-checkout: paths the ref move rewrote that are now clean — a checkout
|
|
117
|
+
* that discarded an agent's edits should release its claims so a peer's later
|
|
118
|
+
* Edit isn't falsely blocked. `oldRef`/`newRef` are the hook's $1/$2.
|
|
119
|
+
*/
|
|
120
|
+
export function collectCheckoutRemoved(cwd: string, oldRef: string, newRef: string): string[] {
|
|
121
|
+
const from = oldRef || "0000000000000000000000000000000000000000";
|
|
122
|
+
const to = newRef || "HEAD";
|
|
123
|
+
const out = git(["diff", "--name-status", "-M", from, to], cwd);
|
|
124
|
+
const local = parseNameStatus(out).filter((p) => isCleanInWorktree(p, cwd));
|
|
125
|
+
return canonicalize(local, submodulePrefix(cwd));
|
|
126
|
+
}
|
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
* + sorted(files_touched) + platform, sorted by instance_id).
|
|
13
13
|
* 2. Council pending: pending open-council IDs hashed; re-emits when the
|
|
14
14
|
* ID set changes.
|
|
15
|
-
* 3. Focus nudge.
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* 3. Focus nudge. Until the session has produced its suggested name (first
|
|
16
|
+
* non-empty set-task), tells every adapter — on every prompt, undeduped —
|
|
17
|
+
* to reproduce set-task's suggested session name in a fenced code block.
|
|
18
|
+
* Cursor/Codex additionally get the existing unset/stale-task reminder
|
|
19
|
+
* because their Stop hooks do not enforce task declarations as reliably
|
|
20
|
+
* as Claude Code's.
|
|
20
21
|
* 4. Codex status footer: a non-deduplicated reminder to put the live status
|
|
21
22
|
* box after the substantive answer. Stop stays observe-only, so missing the
|
|
22
23
|
* footer can never trigger a replacement response.
|
|
@@ -42,7 +43,7 @@ import {
|
|
|
42
43
|
import { join } from "node:path";
|
|
43
44
|
|
|
44
45
|
import { coordEnv } from "../../../lib/env.ts";
|
|
45
|
-
import { resolveBinName } from "../../config.ts";
|
|
46
|
+
import { endOfTurnStatusCommand, resolveBinName } from "../../config.ts";
|
|
46
47
|
import { type RemoteMachine, readRemoteMachines } from "../../presence/index.ts";
|
|
47
48
|
import { formatPendingCouncils } from "./session-context.ts";
|
|
48
49
|
|
|
@@ -59,6 +60,7 @@ interface HeartbeatRow {
|
|
|
59
60
|
platform?: string;
|
|
60
61
|
task?: string;
|
|
61
62
|
task_updated_at?: string;
|
|
63
|
+
suggested_session_name?: string;
|
|
62
64
|
turn_summary?: string;
|
|
63
65
|
workflow_run_id?: string;
|
|
64
66
|
}
|
|
@@ -135,10 +137,11 @@ function renderStatusFooterReminder(coordRoot: string, selfInstanceId: string):
|
|
|
135
137
|
const hb = readHeartbeat(join(coordRoot, ".harnery", "active", `${selfInstanceId}.json`));
|
|
136
138
|
if (!hb || hb.kind === "subagent" || hb.kind === "transient" || hb.workflow_run_id) return "";
|
|
137
139
|
|
|
138
|
-
const
|
|
140
|
+
const statusCommand = endOfTurnStatusCommand(coordRoot);
|
|
139
141
|
return (
|
|
140
142
|
"Codex status footer: complete the user's request first. " +
|
|
141
|
-
`Then run \`${
|
|
143
|
+
`Then run \`${statusCommand}\` as your final shell call and append its stdout verbatim in a fenced code block at the bottom of the same substantive reply. ` +
|
|
144
|
+
"If it fails, finish the owned Git work and rerun it before replying. " +
|
|
142
145
|
"Keep the answer intact. If the footer is missed, do not retry or replace the reply; the Stop hook is observe-only."
|
|
143
146
|
);
|
|
144
147
|
}
|
|
@@ -176,13 +179,15 @@ function computeFocusNudgeIfChanged(
|
|
|
176
179
|
let message = "";
|
|
177
180
|
let nudgeKind = "";
|
|
178
181
|
|
|
179
|
-
if (opts.sessionNameNudge && !hb.
|
|
182
|
+
if (opts.sessionNameNudge && !hb.suggested_session_name) {
|
|
183
|
+
// Keyed on "a name was ever produced", not task_updated_at: a bare clear
|
|
184
|
+
// as the first declaration must not end the naming window.
|
|
180
185
|
needsNudge = true;
|
|
181
186
|
nudgeKind = "session-name";
|
|
182
187
|
message =
|
|
183
|
-
`
|
|
188
|
+
`This session has no name yet: run \`${bin} agents set-task "<2-5 word session topic>"\` as your first tool call. ` +
|
|
184
189
|
"When it returns `first_of_session: true`, reproduce its `suggested_session_name` value by itself inside a fenced code block at the very top of your reply so the operator can one-click-copy it as the session/tab title. " +
|
|
185
|
-
"Then continue with the task; that
|
|
190
|
+
"Then continue with the task; that `set-task` also satisfies this turn's focus declaration.";
|
|
186
191
|
} else if (opts.taskNudge && !taskValue) {
|
|
187
192
|
needsNudge = true;
|
|
188
193
|
nudgeKind = "task-unset";
|
|
@@ -207,8 +212,18 @@ function computeFocusNudgeIfChanged(
|
|
|
207
212
|
return "";
|
|
208
213
|
}
|
|
209
214
|
|
|
210
|
-
//
|
|
211
|
-
//
|
|
215
|
+
// The session-name reminder is deliberately NOT deduped: it re-emits on
|
|
216
|
+
// every prompt until a name is produced, because the "still unnamed" state
|
|
217
|
+
// is the failure state — deduping it erases the only reminder after one
|
|
218
|
+
// ignored prompt (the miss mode operators reported). Bounded in practice:
|
|
219
|
+
// Stop rule 3/3 forces a set-task on the first tool-using turn.
|
|
220
|
+
if (nudgeKind === "session-name") {
|
|
221
|
+
clearHashFile(hashFile);
|
|
222
|
+
return message;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Dedup the task-unset/stale reminders on kind + task state so a repeat
|
|
226
|
+
// prompt in the same state stays quiet.
|
|
212
227
|
const state = `${nudgeKind}|task=${taskValue}|updated=${hb.task_updated_at ?? ""}|threshold=${threshold}`;
|
|
213
228
|
const newHash = sha256Hex16(state);
|
|
214
229
|
const oldHash = safeRead(hashFile);
|
|
@@ -13,6 +13,7 @@ import { join } from "node:path";
|
|
|
13
13
|
import { resolveBinName, resolveHooksSetupHint } from "../../config.ts";
|
|
14
14
|
import { harneryVersion, loadAdapterWiring } from "../../hooks/adapter/wiring.ts";
|
|
15
15
|
import { readRemoteMachines } from "../../presence/index.ts";
|
|
16
|
+
import { readForkParent } from "../state/names.ts";
|
|
16
17
|
|
|
17
18
|
interface HeartbeatRow {
|
|
18
19
|
instance_id?: string;
|
|
@@ -54,7 +55,19 @@ export function renderSessionContext(opts: RenderOpts): string {
|
|
|
54
55
|
const peerTable = [localTable, formatRemoteMachines(coordRoot)].filter(Boolean).join("\n\n");
|
|
55
56
|
if (agentName) {
|
|
56
57
|
const suffix = platformLabel ? ` (${platformLabel})` : "";
|
|
57
|
-
|
|
58
|
+
// The authority clause guards forked/branched chats. An adapter that forks a
|
|
59
|
+
// conversation copies the parent's transcript, so the fork's context still
|
|
60
|
+
// asserts the parent's name, claims, and task. When recorded fork lineage
|
|
61
|
+
// (.name-history forked_from) names the parent, say so specifically — the
|
|
62
|
+
// fork is about to read a transcript full of that exact name. Otherwise
|
|
63
|
+
// fall back to the generic clause, which needs no fork detection.
|
|
64
|
+
const forkParent = readForkParent(coordRoot, instanceId);
|
|
65
|
+
const authority = forkParent?.name
|
|
66
|
+
? `This conversation was branched from agent-${forkParent.name}'s session: earlier context showing agent-${forkParent.name}'s name, task, or file claims belongs to the pre-fork session, not to you.`
|
|
67
|
+
: forkParent
|
|
68
|
+
? `This conversation was branched from another session (${forkParent.instance_id}); any agent name in earlier context belongs to that session, not to you.`
|
|
69
|
+
: "Any different agent name in earlier context was inherited from another session; this one is authoritative.";
|
|
70
|
+
const selfLine = `You are agent-${agentName}${suffix}. ${authority}`;
|
|
58
71
|
messages.push(peerTable ? `${selfLine}\n\n${peerTable}` : selfLine);
|
|
59
72
|
} else if (peerTable) {
|
|
60
73
|
messages.push(peerTable);
|
|
@@ -79,7 +92,7 @@ export function renderSessionContext(opts: RenderOpts): string {
|
|
|
79
92
|
const hint = resolveHooksSetupHint(coordRoot);
|
|
80
93
|
const fix = hint
|
|
81
94
|
? `Run \`${hint}\` to install them.`
|
|
82
|
-
:
|
|
95
|
+
: `Run \`${resolveBinName(coordRoot)} init\` to install the harnery-managed git-hook regions (commit guard + claim pruning).`;
|
|
83
96
|
const wiringSummary = `Coordination hooks are NOT wired: the E-guard will not block conflicting commits, and post-commit claim pruning will not run. ${fix} Detected:\n${wiringIssues.map((i) => ` - ${i}`).join("\n")}`;
|
|
84
97
|
messages.push(wiringSummary);
|
|
85
98
|
}
|
|
@@ -271,8 +271,8 @@ function isFresh(lastHeartbeat: string): boolean {
|
|
|
271
271
|
* - diff shows non-empty output (genuinely dirty)
|
|
272
272
|
*/
|
|
273
273
|
function isFileCommittedClean(coordRoot: string, relPath: string): boolean {
|
|
274
|
-
//
|
|
275
|
-
//
|
|
274
|
+
// Tool payloads can provide either absolute-under-coordRoot or canonical
|
|
275
|
+
// monorepo-relative paths.
|
|
276
276
|
const rel = relPath.startsWith(`${coordRoot}/`) ? relPath.slice(coordRoot.length + 1) : relPath;
|
|
277
277
|
const abs = join(coordRoot, rel);
|
|
278
278
|
if (!existsSync(abs)) return false;
|
|
@@ -305,7 +305,7 @@ function pruneClaimFromPeer(coordRoot: string, instanceId: string, relPath: stri
|
|
|
305
305
|
const body = JSON.parse(readFileSync(path, "utf8")) as Record<string, unknown>;
|
|
306
306
|
const files = (body.files_touched as string[] | undefined) ?? [];
|
|
307
307
|
// Normalize both sides: files_touched can hold absolute-under-coordRoot
|
|
308
|
-
// entries
|
|
308
|
+
// entries as well as canonical relative ones — an
|
|
309
309
|
// exact-string filter silently no-ops on the mixed-form case and the
|
|
310
310
|
// stale claim never heals.
|
|
311
311
|
const norm = (p: string): string =>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pre-commit E-guard verdict. The caller (typically a bash pre-commit hook)
|
|
3
|
-
* sends a JSON request with the staged paths
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* sends a JSON request with the staged paths and prints the verdict
|
|
4
|
+
* messages + exits with verdict.exit_code. Committer identity is resolved
|
|
5
|
+
* HERE via `resolveOwner()` unless the request explicitly carries one.
|
|
6
6
|
*
|
|
7
7
|
* Three outcomes:
|
|
8
8
|
* 1. allow (no conflicts): exit 0.
|
|
@@ -24,6 +24,7 @@ import { spawnSync } from "node:child_process";
|
|
|
24
24
|
import { appendFileSync, existsSync, readdirSync, readFileSync } from "node:fs";
|
|
25
25
|
import { basename, dirname, join } from "node:path";
|
|
26
26
|
import { coordFreshnessSeconds } from "../../config.ts";
|
|
27
|
+
import { resolveOwner } from "../../hooks/resolve/owner.ts";
|
|
27
28
|
import { instanceHasLivePid } from "../state/pidmap.ts";
|
|
28
29
|
|
|
29
30
|
interface PeerHeartbeat {
|
|
@@ -46,9 +47,16 @@ interface Conflict {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
export interface CommitVerdictRequest {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Committer identity. Optional: when absent (or the legacy
|
|
52
|
+
* `__unattributed__` sentinel), the verdict resolves it via
|
|
53
|
+
* `resolveOwner()` — env → pid-map walk → validated Codex thread id —
|
|
54
|
+
* from its own process context. Callers should stop hand-rolling
|
|
55
|
+
* identity resolution and omit this.
|
|
56
|
+
*/
|
|
57
|
+
instance_id?: string;
|
|
58
|
+
/** Group key. Subagents inherit parent's session_id. Same optionality. */
|
|
59
|
+
session_id?: string;
|
|
52
60
|
/** Canonical monorepo-relative paths. */
|
|
53
61
|
staged_paths: string[];
|
|
54
62
|
/** Paths in `staged_paths` that resolve to submodule gitlinks (mode 160000)
|
|
@@ -62,6 +70,8 @@ export interface CommitVerdictResult {
|
|
|
62
70
|
allow: boolean;
|
|
63
71
|
exit_code: number;
|
|
64
72
|
rule: string;
|
|
73
|
+
/** The committer identity the verdict actually used (resolved or passed). */
|
|
74
|
+
instance_id: string;
|
|
65
75
|
/** Conflict details (for the caller to print). */
|
|
66
76
|
conflicts: Conflict[];
|
|
67
77
|
/** Path-specific gates that fired (for `coord_log` lines). */
|
|
@@ -73,11 +83,24 @@ export interface CommitVerdictResult {
|
|
|
73
83
|
}
|
|
74
84
|
|
|
75
85
|
export function evaluateCommit(coordRoot: string, req: CommitVerdictRequest): CommitVerdictResult {
|
|
86
|
+
// Resolve the committer here, not in the calling hook. The bash shims used
|
|
87
|
+
// to carry their own pid-map walk (a pre-extraction fossil of resolveOwner);
|
|
88
|
+
// a hand-rolled copy can only fall behind as tiers are added, so the rule
|
|
89
|
+
// resolves identity from its own process context and callers just omit it.
|
|
90
|
+
const passed = req.instance_id?.trim();
|
|
91
|
+
const me =
|
|
92
|
+
passed && passed !== "__unattributed__"
|
|
93
|
+
? passed
|
|
94
|
+
: (resolveOwner({ payload: null, coordRoot })?.instance_id ?? "__unattributed__");
|
|
95
|
+
const passedSession = req.session_id?.trim();
|
|
96
|
+
const mySession = passed && passedSession ? passedSession : me;
|
|
97
|
+
|
|
76
98
|
if (req.staged_paths.length === 0) {
|
|
77
99
|
return {
|
|
78
100
|
allow: true,
|
|
79
101
|
exit_code: 0,
|
|
80
102
|
rule: "commit.pass",
|
|
103
|
+
instance_id: me,
|
|
81
104
|
conflicts: [],
|
|
82
105
|
log_lines: [],
|
|
83
106
|
message: "",
|
|
@@ -91,9 +114,9 @@ export function evaluateCommit(coordRoot: string, req: CommitVerdictRequest): Co
|
|
|
91
114
|
|
|
92
115
|
const conflicts: Conflict[] = [];
|
|
93
116
|
for (const peer of peers) {
|
|
94
|
-
if (peer.instance_id ===
|
|
117
|
+
if (peer.instance_id === me) continue;
|
|
95
118
|
const peerSession = peer.session_id ?? peer.instance_id;
|
|
96
|
-
if (
|
|
119
|
+
if (mySession !== "__unattributed__" && peerSession === mySession) continue; // same group
|
|
97
120
|
const ts = peer.last_heartbeat ? Date.parse(peer.last_heartbeat) : 0;
|
|
98
121
|
if (!Number.isFinite(ts) || ts < cutoffMs) continue; // stale
|
|
99
122
|
const files = peer.files_touched ?? [];
|
|
@@ -118,6 +141,7 @@ export function evaluateCommit(coordRoot: string, req: CommitVerdictRequest): Co
|
|
|
118
141
|
allow: true,
|
|
119
142
|
exit_code: 0,
|
|
120
143
|
rule: "commit.pass",
|
|
144
|
+
instance_id: me,
|
|
121
145
|
conflicts: [],
|
|
122
146
|
log_lines: [],
|
|
123
147
|
message: "",
|
|
@@ -129,6 +153,7 @@ export function evaluateCommit(coordRoot: string, req: CommitVerdictRequest): Co
|
|
|
129
153
|
allow: true,
|
|
130
154
|
exit_code: 0,
|
|
131
155
|
rule: "commit.bypass",
|
|
156
|
+
instance_id: me,
|
|
132
157
|
conflicts,
|
|
133
158
|
log_lines: conflicts.map(
|
|
134
159
|
(c) => `COMMIT_BYPASSED path=${c.staged_path} owner=${c.short_name}`,
|
|
@@ -149,6 +174,7 @@ export function evaluateCommit(coordRoot: string, req: CommitVerdictRequest): Co
|
|
|
149
174
|
allow: true,
|
|
150
175
|
exit_code: 0,
|
|
151
176
|
rule: "commit.suppressed",
|
|
177
|
+
instance_id: me,
|
|
152
178
|
conflicts,
|
|
153
179
|
log_lines: conflicts.map(
|
|
154
180
|
(c) =>
|
|
@@ -167,6 +193,7 @@ export function evaluateCommit(coordRoot: string, req: CommitVerdictRequest): Co
|
|
|
167
193
|
allow: false,
|
|
168
194
|
exit_code: 1,
|
|
169
195
|
rule: "commit.conflict",
|
|
196
|
+
instance_id: me,
|
|
170
197
|
conflicts,
|
|
171
198
|
log_lines: conflicts.map((c) => `COMMIT_BLOCKED path=${c.staged_path} owner=${c.short_name}`),
|
|
172
199
|
message:
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* stop currently firing carries that field via the in-flight event
|
|
12
12
|
* agent-hook emits before the stop hook runs).
|
|
13
13
|
* Rule 3/3: `state.task_set` event with matching turn boundary exists.
|
|
14
|
+
* Session-naming rule (at most once per session, CC semantics only): the turn
|
|
15
|
+
* whose set-task produced `suggested_session_name` must carry an
|
|
16
|
+
* in-window `turn.stop` with `session_name_present: true`.
|
|
14
17
|
*
|
|
15
18
|
* Pure-prose-turn exemption: when zero `tool.pre_use` events fire in
|
|
16
19
|
* the current turn, rules 1/3 and 3/3 do not apply. Rule 2/3 still applies
|
|
@@ -25,7 +28,11 @@
|
|
|
25
28
|
|
|
26
29
|
import { existsSync, readFileSync } from "node:fs";
|
|
27
30
|
import { join } from "node:path";
|
|
28
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
agentsRequireGitFinalization,
|
|
33
|
+
endOfTurnStatusCommand,
|
|
34
|
+
resolveBinName,
|
|
35
|
+
} from "../../config.ts";
|
|
29
36
|
|
|
30
37
|
export type { VerdictResult } from "./verdict.ts";
|
|
31
38
|
|
|
@@ -106,18 +113,6 @@ const RECENT_EVENT_WINDOW_LINES = 5_000;
|
|
|
106
113
|
*/
|
|
107
114
|
export const STOP_REMEDIATION_MARKER = "[harnery:stop-remediation";
|
|
108
115
|
|
|
109
|
-
/**
|
|
110
|
-
* The pre-marker message shape, still recognized on purpose.
|
|
111
|
-
*
|
|
112
|
-
* A followup already sitting in the stream was written by whichever build was
|
|
113
|
-
* running when it fired. An agent whose session spans an upgrade would otherwise
|
|
114
|
-
* keep alternating until the first new-format followup appeared, which is the
|
|
115
|
-
* exact failure this change removes. Recognizing the older trailing form closes
|
|
116
|
-
* that rollout window at no cost: it only ever appears in a `prompt_text`
|
|
117
|
-
* because Harnery put it there.
|
|
118
|
-
*/
|
|
119
|
-
const STOP_REMEDIATION_LEGACY_MARKER = "[agent-hook stop]: rule=";
|
|
120
|
-
|
|
121
116
|
/** How far back the remediation walk may travel. Adapters cap their own
|
|
122
117
|
* followup chains (Cursor's `loop_limit`), and each prompt can appear once per
|
|
123
118
|
* observing adapter, so this only guards a pathological stream. */
|
|
@@ -126,7 +121,7 @@ const MAX_REMEDIATION_WALK_BACK = 16;
|
|
|
126
121
|
function isStopRemediationPrompt(event: CanonicalEvent): boolean {
|
|
127
122
|
const text = event.data.prompt_text;
|
|
128
123
|
if (typeof text !== "string") return false;
|
|
129
|
-
return text.includes(STOP_REMEDIATION_MARKER)
|
|
124
|
+
return text.includes(STOP_REMEDIATION_MARKER);
|
|
130
125
|
}
|
|
131
126
|
|
|
132
127
|
/**
|
|
@@ -233,7 +228,7 @@ export function evaluateStopHook(coordRoot: string, req: StopHookRequest): Verdi
|
|
|
233
228
|
allow: true,
|
|
234
229
|
exit_code: 0,
|
|
235
230
|
rule: "stop-hook.no_history",
|
|
236
|
-
reason: "no canonical events for this owner;
|
|
231
|
+
reason: "no canonical events for this owner; nothing to evaluate",
|
|
237
232
|
};
|
|
238
233
|
}
|
|
239
234
|
|
|
@@ -255,7 +250,11 @@ export function evaluateStopHook(coordRoot: string, req: StopHookRequest): Verdi
|
|
|
255
250
|
});
|
|
256
251
|
|
|
257
252
|
const toolPreUseInTurn = inTurn.some((e) => e.event_type === "tool.pre_use");
|
|
258
|
-
const
|
|
253
|
+
const statusEvents = inTurn.filter((e) => e.event_type === "state.status_checked");
|
|
254
|
+
const statusChecked = statusEvents.length > 0;
|
|
255
|
+
const requiredStatusChecked = agentsRequireGitFinalization(coordRoot)
|
|
256
|
+
? statusEvents.some((e) => e.data.git_finalization_checked === true)
|
|
257
|
+
: statusChecked;
|
|
259
258
|
const taskSet = inTurn.some((e) => e.event_type === "state.task_set");
|
|
260
259
|
|
|
261
260
|
// Rule 2/3: status_box_present on the most recent turn.stop for this owner.
|
|
@@ -270,8 +269,14 @@ export function evaluateStopHook(coordRoot: string, req: StopHookRequest): Verdi
|
|
|
270
269
|
// on Claude Code / Codex it's the transcript-scanned `status_box_present`.
|
|
271
270
|
// The matching block helper carries the right "how to fix" message.
|
|
272
271
|
const ackSignal = ackSignalFor(req.adapter);
|
|
273
|
-
const ackPresent =
|
|
274
|
-
|
|
272
|
+
const ackPresent =
|
|
273
|
+
ackSignal === "status_checked"
|
|
274
|
+
? toolPreUseInTurn
|
|
275
|
+
? requiredStatusChecked
|
|
276
|
+
: statusChecked
|
|
277
|
+
: boxPresent;
|
|
278
|
+
const ackBlock =
|
|
279
|
+
ackSignal === "status_checked" ? () => rule13Block(coordRoot) : () => rule23Block(coordRoot);
|
|
275
280
|
|
|
276
281
|
// Pure-prose-turn exemption: only the ack signal applies. Parity
|
|
277
282
|
// across adapters: CC requires the box; Cursor requires status_checked.
|
|
@@ -287,12 +292,43 @@ export function evaluateStopHook(coordRoot: string, req: StopHookRequest): Verdi
|
|
|
287
292
|
};
|
|
288
293
|
}
|
|
289
294
|
|
|
290
|
-
if (!
|
|
295
|
+
if (!requiredStatusChecked) return rule13Block(coordRoot);
|
|
291
296
|
// On Cursor `ackPresent === statusChecked` (already true here), so this is a
|
|
292
297
|
// no-op and rule 2/3 is not enforced; on CC/Codex it's the box-paste check.
|
|
293
298
|
if (!ackPresent) return ackBlock();
|
|
294
299
|
if (!taskSet) return rule33Block();
|
|
295
300
|
|
|
301
|
+
// Session-naming rule (at most once per session, evaluated last so
|
|
302
|
+
// remediation stays monotonic in the established order): the turn whose
|
|
303
|
+
// set-task produced the suggested session name must show that name in the
|
|
304
|
+
// reply. Claude Code semantics only — Cursor's Stop payload carries neither
|
|
305
|
+
// a transcript nor the assistant message, so the fence is undetectable there
|
|
306
|
+
// (the same reason rule 2/3 collapses into 1/3 on Cursor), and Codex
|
|
307
|
+
// returned observe-only above. Detection rides `turn.stop`'s
|
|
308
|
+
// `session_name_present` (assistant-text-only transcript scan), mirroring
|
|
309
|
+
// how rule 2/3 rides `status_box_present`.
|
|
310
|
+
if (ackSignal === "status_box_present") {
|
|
311
|
+
const namingTaskSet = inTurn.find(
|
|
312
|
+
(e) =>
|
|
313
|
+
e.event_type === "state.task_set" &&
|
|
314
|
+
e.data.first_of_session === true &&
|
|
315
|
+
typeof e.data.suggested_session_name === "string" &&
|
|
316
|
+
e.data.suggested_session_name.length > 0,
|
|
317
|
+
);
|
|
318
|
+
if (namingTaskSet) {
|
|
319
|
+
// ANY in-window turn.stop with the flag satisfies the rule, not just the
|
|
320
|
+
// latest: once seen, `session_name_seen_at` is stamped and later
|
|
321
|
+
// turn.stops OMIT the field, so a later block on a different rule (whose
|
|
322
|
+
// repair fires a fresh turn.stop) must not un-satisfy this one.
|
|
323
|
+
const namePresent = inTurn.some(
|
|
324
|
+
(e) => e.event_type === "turn.stop" && e.data.session_name_present === true,
|
|
325
|
+
);
|
|
326
|
+
if (!namePresent) {
|
|
327
|
+
return sessionNameBlock(String(namingTaskSet.data.suggested_session_name));
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
296
332
|
return {
|
|
297
333
|
allow: true,
|
|
298
334
|
exit_code: 0,
|
|
@@ -300,21 +336,33 @@ export function evaluateStopHook(coordRoot: string, req: StopHookRequest): Verdi
|
|
|
300
336
|
};
|
|
301
337
|
}
|
|
302
338
|
|
|
303
|
-
function rule13Block(): VerdictResult {
|
|
339
|
+
function rule13Block(coordRoot?: string): VerdictResult {
|
|
340
|
+
const missingEvidence = agentsRequireGitFinalization(coordRoot)
|
|
341
|
+
? "no Git-finalized state.status_checked event found in this turn"
|
|
342
|
+
: "no state.status_checked event found in this turn";
|
|
304
343
|
return {
|
|
305
344
|
allow: false,
|
|
306
345
|
exit_code: 2,
|
|
307
346
|
rule: "stop-hook.rule_1_3",
|
|
308
|
-
reason: `End-of-turn rule (1/3):
|
|
347
|
+
reason: `End-of-turn rule (1/3): ${missingEvidence}; run \`${endOfTurnStatusCommand(coordRoot)}\` as your last tool call.`,
|
|
309
348
|
};
|
|
310
349
|
}
|
|
311
350
|
|
|
312
|
-
function rule23Block(): VerdictResult {
|
|
351
|
+
function rule23Block(coordRoot?: string): VerdictResult {
|
|
313
352
|
return {
|
|
314
353
|
allow: false,
|
|
315
354
|
exit_code: 2,
|
|
316
355
|
rule: "stop-hook.rule_2_3",
|
|
317
|
-
reason: `End-of-turn rule (2/3): turn.stop did not see the agent-status box in your reply text. Paste the \`${
|
|
356
|
+
reason: `End-of-turn rule (2/3): turn.stop did not see the agent-status box in your reply text. Paste the \`${endOfTurnStatusCommand(coordRoot)}\` output verbatim as a fenced code block (the \`┌─ agent-\` prefix is the detection signal).`,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function sessionNameBlock(name: string): VerdictResult {
|
|
361
|
+
return {
|
|
362
|
+
allow: false,
|
|
363
|
+
exit_code: 2,
|
|
364
|
+
rule: "stop-hook.session_name",
|
|
365
|
+
reason: `Session-naming rule: this turn's set-task produced the session name, but your reply doesn't show it. Reproduce it by itself in a fenced code block so the operator can one-click-copy it as the session/tab title: ${name}`,
|
|
318
366
|
};
|
|
319
367
|
}
|
|
320
368
|
|