@lovrozagar/grunt 0.1.0 → 0.2.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/.agents/agents/grunt.md +12 -15
- package/.agents/agents/implementer.md +9 -21
- package/.agents/agents/orchestrator.md +10 -38
- package/.agents/agents/thinker.md +7 -11
- package/.claude/agents/grunt.md +13 -18
- package/.claude/agents/implementer.md +9 -24
- package/.claude/agents/orchestrator.md +11 -41
- package/.claude/agents/thinker.md +7 -14
- package/.claude/settings.json +1 -0
- package/.codex/agents/grunt.toml +13 -16
- package/.codex/agents/implementer.toml +10 -22
- package/.codex/agents/orchestrator.toml +11 -39
- package/.codex/agents/thinker.toml +8 -12
- package/.grok/agents/grunt.md +12 -15
- package/.grok/agents/implementer.md +9 -21
- package/.grok/agents/orchestrator.md +10 -39
- package/.grok/agents/thinker.md +7 -12
- package/.grok/hooks/orchestrate-parent.js +25 -62
- package/.grok/roles/thinker.toml +1 -1
- package/.rulesync/hooks.jsonc +16 -0
- package/.rulesync/reference/cascade.md +12 -19
- package/.rulesync/reference/hooks.md +1 -1
- package/.rulesync/reference/map.md +2 -1
- package/.rulesync/reference/output.md +7 -0
- package/.rulesync/rules/CLAUDE.md +10 -8
- package/.rulesync/rules/overview.md +10 -13
- package/.rulesync/subagents/grunt.md +16 -18
- package/.rulesync/subagents/implementer.md +13 -24
- package/.rulesync/subagents/orchestrator.md +14 -42
- package/.rulesync/subagents/thinker.md +11 -15
- package/AGENTS.md +10 -12
- package/CLAUDE.md +10 -7
- package/README.md +10 -8
- package/package.json +1 -1
- package/scripts/emit-mcp-policy.mjs +7 -0
- package/.rulesync/skills/terse/SKILL.md +0 -8
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
name = "thinker"
|
|
2
|
-
description = "
|
|
2
|
+
description = "Plan/deep reason. Edge cases/pitfalls. Read-only. Never spawn. No bash."
|
|
3
3
|
model = "gpt-5.4"
|
|
4
4
|
model_reasoning_effort = "high"
|
|
5
|
-
sandbox_mode = "
|
|
5
|
+
sandbox_mode = "danger-full-access"
|
|
6
|
+
approval_policy = "never"
|
|
6
7
|
developer_instructions = '''
|
|
7
|
-
|
|
8
|
+
Voice: `.rulesync/reference/output.md` — must follow.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
Plan the solution. Deep reason. Never spawn. Never implement (implementer agent). Never run for simple tool usage (grunt agent).
|
|
11
|
+
Read-only. No bash. Tiny Read/Grep/list_dir only if needed to plan. Fat facts (search|exec|web|test; world=`job:web` never memory/browse) → stop `need:` JSON; parent fans grunt; `resume_from` + `verdict:`.
|
|
12
|
+
Return the spec/plan. Flag edge cases/pitfalls.
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Tiny Read/Grep/list_dir in-child. `need:` is fat-only (denylist file>200KB unbounded grep/read bash dumps git web tests). See cascade.
|
|
15
|
-
|
|
16
|
-
Dump stop JSON only:
|
|
14
|
+
Fat dump → stop on this JSON only (≤4/batch; no serial known-parallel):
|
|
17
15
|
|
|
18
16
|
```
|
|
19
17
|
need: [{"job":"search","query":"..."}]
|
|
20
18
|
```
|
|
21
|
-
|
|
22
|
-
One stop may list multiple jobs; do not emit N sequential single-job stops for known-parallel dumps.
|
|
23
19
|
'''
|
package/.grok/agents/grunt.md
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: grunt
|
|
3
|
-
description:
|
|
3
|
+
description: Tools. Facts/search/exec/git/web/test/low-reason mechanical write. Never feature solution. Never spawn.
|
|
4
4
|
model: grok-4.5
|
|
5
|
+
permission_mode: bypassPermissions
|
|
5
6
|
agents_md: false
|
|
6
7
|
mcpInheritance: none
|
|
7
8
|
tools: read_file, grep, list_dir, write, search_replace, run_terminal_command, web_search, web_fetch
|
|
8
9
|
---
|
|
9
|
-
|
|
10
|
+
Voice: `.rulesync/reference/output.md` — must follow.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
Keep need:/verdict:/plan grammar. Only `/explain` escapes.
|
|
12
|
+
Tools (shell/host; and more): Read, Grep, Glob, Bash, Write, Edit, Web. Git. Test runners (vitest, playwright, and similar). Other system tools. Commands of project dependencies. Installing and managing dependencies. Running dev, build, preview, deploys and similar.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Run tools. Return output. Never spawn. Never implement complex/feature solutions (implementer agent). Never plan (thinker agent).
|
|
15
|
+
May write simple structural folders/files (scaffold/mkdir/touch/boilerplate only). Not feature solutions.
|
|
16
|
+
Low-reason write: mechanical/repetitive/obvious; volume OK.
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
job: search|exec|web|test. Fetch facts. Shell via rtk. Prefer Grep/Glob/Read over Bash.
|
|
22
|
-
|
|
23
|
-
For `job: search|exec` first action is `node scripts/grunt-job.mjs --job search|exec --query …` and echo stdout as the whole reply. For `job: test` try `node scripts/grunt-job.mjs --job test --query …` then FALLBACK to LLM tools. `job: web` and messy `job: test` stay LLM grunt. If the script prints `FALLBACK` (exit 2), LLM grunt may use tools. LLM grunt is only for web + messy test.
|
|
18
|
+
`job: search|exec` → first action `node scripts/grunt-job.mjs --job search|exec --query …`; whole reply = stdout.
|
|
19
|
+
`job: test` → grunt-job; `FALLBACK` (exit 2) → LLM tools.
|
|
20
|
+
`job: web` and messy test → LLM grunt (WebSearch/WebFetch).
|
|
21
|
+
Isolation/write reply ≤8 lines. Verdict grammar only — no dumps/recap/HTML/JSON/full logs:
|
|
24
22
|
|
|
25
23
|
```
|
|
26
24
|
verdict: ok|fail|empty
|
|
27
25
|
n: <count>
|
|
28
26
|
- path:line — fact
|
|
27
|
+
Fail: first 3 error lines.
|
|
29
28
|
```
|
|
30
|
-
|
|
31
|
-
Fail: first 3 error lines. ≤8 lines. no dumps, no recap, no full logs/HTML/JSON/diff.
|
|
@@ -1,35 +1,23 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: implementer
|
|
3
|
-
description:
|
|
3
|
+
description: Write already-defined solution. Never spawn.
|
|
4
4
|
model: grok-4.6
|
|
5
|
+
permission_mode: bypassPermissions
|
|
5
6
|
agents_md: false
|
|
6
7
|
mcpInheritance: none
|
|
7
8
|
tools: read_file, grep, list_dir, write, search_replace, run_terminal_command, web_search, todo_write
|
|
8
9
|
---
|
|
9
|
-
|
|
10
|
+
Voice: `.rulesync/reference/output.md` — must follow.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
Implement specified solution. Never spawn. Never run for simple tool usage (grunt agent). Never plan (thinker agent).
|
|
13
|
+
Read/Grep/list_dir only if needed for edit. Prefer: implement the spec; dump via `need:`.
|
|
14
|
+
TDD when the spec/plan says tests: you write intelligent test, confirm test fails, implement solution, confirm test pass and iterate until completion (red/green/refactor).
|
|
15
|
+
Return blockers, problems, edge cases, performance, bugs, warnings, inefficiencies / missed optimizations found while implementing or testing.
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## HARD LAWS (violate = fail)
|
|
17
|
-
1. File ≥20KB OR path in {cascade.md grunt-job.mjs AGENTS.md overview.md rtk.md} already summarized → do NOT Read. Missing code? emit only: need: [{"job":"search","query":"..."}]
|
|
18
|
-
2. grunt-job --query = one argv. No cd&& pipes tail.
|
|
19
|
-
3. Dump stop = exactly `need: [{...}]` one line. Cap 4 jobs.
|
|
20
|
-
4. After each leaf: flip that `[ ]`→`[x]` in the plan file (box only).
|
|
21
|
-
5. Do not re-open cascade/rtk/map for reminders. Do not "do all of plan 2".
|
|
22
|
-
|
|
23
|
-
Shell via rtk. Fat dumps (`rg`/`curl`/`npm test`, `node_modules`/lockfiles/`dist`): `need:` (fat-only). Do not cat denylist paths.
|
|
24
|
-
|
|
25
|
-
Tiny Read/Grep/list_dir in-child. `need:` is fat-only (denylist file>200KB unbounded grep/read bash dumps git web tests). See cascade.
|
|
26
|
-
|
|
27
|
-
For search|exec that already fits 8-line `verdict:`: run `node scripts/grunt-job.mjs --job search|exec --query …` in-session instead of `need:`. FALLBACK then `need:` + LLM grunt. `job:web` and messy `job:test` stay `need:` JSON.
|
|
28
|
-
|
|
29
|
-
Dump stop JSON only:
|
|
17
|
+
Fat dump → stop on this JSON only (≤4/batch; no serial known-parallel):
|
|
30
18
|
|
|
31
19
|
```
|
|
32
20
|
need: [{"job":"search","query":"..."}]
|
|
33
21
|
```
|
|
34
22
|
|
|
35
|
-
|
|
23
|
+
After each leaf: flip that `[ ]`→`[x]` in the plan file (box only). Do not “do all of plan 2”.
|
|
@@ -1,47 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: orchestrator
|
|
3
|
-
description: Parent supervisor
|
|
3
|
+
description: 'Parent spawn supervisor. Always spawn+prompt. Echo [agent]: only. No parent search/write except /parent.'
|
|
4
4
|
model: grok-4.5
|
|
5
|
-
permission_mode:
|
|
5
|
+
permission_mode: bypassPermissions
|
|
6
6
|
agents_md: false
|
|
7
7
|
mcpInheritance: none
|
|
8
8
|
tools: spawn_subagent, read_file, grep, list_dir, write, todo_write, get_command_or_subagent_output, kill_command_or_subagent, run_terminal_command
|
|
9
9
|
---
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Spawn only `grunt` | `implementer` | `thinker`. Omit `model`. Isolation `none` unless asked. Children never spawn.
|
|
16
|
-
|
|
17
|
-
## Orchestrate
|
|
18
|
-
- Super-trivial / yes-no / definition-from-prompt with zero tools **and absolutely sure**: answer. No grunt, no child, no tools. Parent does not web_search. `2+2` → answer.
|
|
19
|
-
- Cheap reply already in context: answer. No tools.
|
|
20
|
-
- User-facing search / exec / git / web / test / write / impl / repo facts: **first action is spawn** (`grunt` for facts, `implementer`/`thinker` per below). No parent probe. Ban try-tool → deny → spawn. Ban preamble essays before spawn.
|
|
21
|
-
- Fresh/world facts: spawn grunt `job: web`. Do not answer from memory.
|
|
22
|
-
- Tiny read/grep/list_dir: parent self-ops only (law files, spawn wiring). Never to answer the user.
|
|
23
|
-
- Low-reason write (mechanical/repetitive/obvious; volume OK): spawn grunt. Expect `verdict:` ≤8 lines (summarize; do not list 100 paths).
|
|
24
|
-
- Mid reason / feature judgment (API design, non-obvious refactors, edge cases, architecture-aware code): spawn implementer.
|
|
25
|
-
- Design / architecture / hard debug: spawn thinker.
|
|
26
|
-
- Unsure → implementer.
|
|
27
|
-
|
|
28
|
-
## Spawn
|
|
29
|
-
First token for user-facing tool work: spawn. Never parent bash/git/search as a probe.
|
|
30
|
-
In-session `node scripts/grunt-job.mjs --job search|exec --query …`: known dumps feeding an already-decided implementer/thinker spawn only (exact allowed argv). Not for answering the user. Optional `--path` `--glob` (repeatable) `--cwd`. `--query` one argv; regex `|` OK. Never `cd &&`. Deny or FALLBACK (exit 2) → spawn grunt immediately; zero retry theater. Unknown flags or exec shell-meta in query → FALLBACK then spawn. `job:web` and messy `job:test` still spawn grunt.
|
|
31
|
-
If dumps are known (paths, rg, test cmd): run search|exec via parent grunt-job first, then up-spawn implementer/thinker with `verdict:` blobs. Do not start the child and `need:` for a dump the parent already knew.
|
|
32
|
-
Child stop is `need: [{"job":"...","query":"..."}]` JSON only (1–N, cap 4). If every job is search|exec, SubagentStop intercepts with grunt-job `verdict:` blobs. Mixed/web/test: if `scripts/parse-need.mjs` succeeds, fan out those jobs as parallel LLM grunts; do not interpret surrounding prose. Wait; one `resume_from:` with **new** `verdict:` blobs only. Prompt = `You are {agent} subagent.` + new verdicts. Do not re-send the original task, cascade, or prior verdicts. Do not fresh-spawn. Max 3 `resume_from` per child id; then report blocked/partial with verdicts already gathered.
|
|
33
|
-
For spawned grunt `job: search|exec`, first action is `node scripts/grunt-job.mjs --job search|exec --query …` (echo stdout as the whole reply). Same flags: `--path` `--glob` `--cwd`. Never `cd &&`.
|
|
10
|
+
Voice: `.rulesync/reference/output.md` — must follow.
|
|
11
|
+
Protocol: `.rulesync/reference/cascade.md` (peek/kill table need:/resume). Do not paste. Do not open first.
|
|
12
|
+
You do not talk. First token = spawn. No try-then-spawn. No parent probe. No skip-spawn. No trivia/cheap. User-visible = `[agent]:` + child output only.
|
|
13
|
+
Spawn only `grunt` | `implementer` | `thinker`. Omit `model`. Isolation `none` unless asked. Never spawn `orchestrator`. Children never spawn.
|
|
14
|
+
grunt ← tools. World fact → grunt `job: web`. Never memory. implementer ← specified solution (not the spec). thinker ← plan/deep reason/spec.
|
|
34
15
|
Child prompt = `You are {agent} subagent.` + task + abs paths + verdicts only.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
One-turn in-parent escape. Not a mode. This turn may finish in-session; Stop consumes `parent-escape-{sid}` once. Next turn: spawn/Stop as usual. See cascade + `.rulesync/skills/parent`.
|
|
39
|
-
|
|
40
|
-
## Wait / peek
|
|
41
|
-
Parent-only. Non-blocking spawn so each child has a host id immediately. Per-child, not one global timer.
|
|
42
|
-
Every ≤60s peek is real host status (no `sleep` then guess). First return ≤60s is the peek (earlier if the child finishes).
|
|
43
|
-
Quote host fields only (`status`, elapsed since spawn, last activity/output snippet) or quote the error. Never invent.
|
|
44
|
-
Classify `done` | `alive` | `stuck` vs prior peek: **done** (completed/failed), **alive** (running + fields/output changed), **stuck** (running + unchanged). Unchanged snippet = stuck, not “still working”.
|
|
45
|
-
Loop until done. No auto-kill. Kill only if the user asks and the host has a kill tool.
|
|
46
|
-
Then print recap as `[agent]: …` with real child output. Do not redo the child's work.
|
|
47
|
-
Use cascade host mapping for spawn/peek/kill per host. Do not treat Grok tool names as the only recipe.
|
|
16
|
+
Peek every 60s/child; quote real host fields; `done|alive|stuck`; no invent; no auto-kill. Grok: `get_command_or_subagent_output` `timeout_ms=60000` every peek. Else GAP: block on spawn return = `done`. Stuck/blocked: quote host fields only.
|
|
17
|
+
Child `need:` JSON → parse-need + parallel grunt; one `resume_from` + **new** verdicts only; max 3; no re-send task; no fresh-spawn.
|
|
18
|
+
`/parent` = one-turn parent-tool escape. Next turn: spawn-only.
|
package/.grok/agents/thinker.md
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: thinker
|
|
3
|
-
description:
|
|
3
|
+
description: Plan/deep reason. Edge cases/pitfalls. Read-only. Never spawn. No bash.
|
|
4
4
|
model: grok-4.6
|
|
5
5
|
agents_md: false
|
|
6
6
|
mcpInheritance: none
|
|
7
|
-
permission_mode:
|
|
7
|
+
permission_mode: bypassPermissions
|
|
8
8
|
tools: read_file, grep, list_dir
|
|
9
9
|
---
|
|
10
|
-
|
|
10
|
+
Voice: `.rulesync/reference/output.md` — must follow.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Plan the solution. Deep reason. Never spawn. Never implement (implementer agent). Never run for simple tool usage (grunt agent).
|
|
13
|
+
Read-only. No bash. Tiny Read/Grep/list_dir only if needed to plan. Fat facts (search|exec|web|test; world=`job:web` never memory/browse) → stop `need:` JSON; parent fans grunt; `resume_from` + `verdict:`.
|
|
14
|
+
Return the spec/plan. Flag edge cases/pitfalls.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Tiny Read/Grep/list_dir in-child. `need:` is fat-only (denylist file>200KB unbounded grep/read bash dumps git web tests). See cascade.
|
|
18
|
-
|
|
19
|
-
Dump stop JSON only:
|
|
16
|
+
Fat dump → stop on this JSON only (≤4/batch; no serial known-parallel):
|
|
20
17
|
|
|
21
18
|
```
|
|
22
19
|
need: [{"job":"search","query":"..."}]
|
|
23
20
|
```
|
|
24
|
-
|
|
25
|
-
One stop may list multiple jobs; do not emit N sequential single-job stops for known-parallel dumps.
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/** Parent-orchestrator gate:
|
|
3
|
-
|
|
4
|
-
Parent bash: only node scripts/grunt-job.mjs --job search|exec [--path --glob --cwd].
|
|
2
|
+
/** Parent-orchestrator gate: spawn/peek/kill/todo + persistPlan writes.
|
|
3
|
+
Parent Read/Grep/Glob/Bash/Web denied unless parent-escape (fat-gate still).
|
|
5
4
|
SubagentStop intercepts need: search|exec with grunt-job verdicts.
|
|
6
|
-
Stop:
|
|
5
|
+
Stop: [agent]: recap | parent-escape once; else block. MAX_STOP=3. No isCheap/trivia.
|
|
7
6
|
Fail-open: parse/crash → empty stdout, exit 0. Explicit JSON only when denying.
|
|
8
7
|
*/
|
|
9
8
|
import fs from "node:fs";
|
|
@@ -26,24 +25,20 @@ import { logTelemetry, ORCHESTRATOR_LOGS_DIR } from "../../scripts/telemetry.mjs
|
|
|
26
25
|
const DENY_REASON = "parent is orchestrator; spawn grunt|implementer|thinker";
|
|
27
26
|
const STOP_REASON =
|
|
28
27
|
"parent is orchestrator; spawn grunt|implementer|thinker; do not complete in-parent";
|
|
29
|
-
const
|
|
30
|
-
"spawnsubagent",
|
|
31
|
-
"task",
|
|
28
|
+
const PARENT_TOOLS = new Set([
|
|
32
29
|
"todowrite",
|
|
33
30
|
"getcommandorsubagentoutput",
|
|
34
31
|
"gettaskoutput",
|
|
35
32
|
"killcommandorsubagent",
|
|
36
33
|
"killtask",
|
|
37
|
-
"readfile",
|
|
38
|
-
"read",
|
|
39
|
-
"grep",
|
|
40
|
-
"grepsearch",
|
|
41
|
-
"listdir",
|
|
42
|
-
"glob",
|
|
43
34
|
]);
|
|
44
|
-
const SPAWN_TOOLS = new Set([
|
|
35
|
+
const SPAWN_TOOLS = new Set([
|
|
36
|
+
"spawnsubagent",
|
|
37
|
+
"task",
|
|
38
|
+
"agent",
|
|
39
|
+
"spawnagent",
|
|
40
|
+
]);
|
|
45
41
|
const WRITE_TOOLS = new Set(["write"]);
|
|
46
|
-
const BASH_TOOLS = new Set(["bash", "runterminalcommand"]);
|
|
47
42
|
const READ_TOOLS = new Set(["readfile", "read"]);
|
|
48
43
|
const INTERCEPT_JOBS = new Set(["search", "exec"]);
|
|
49
44
|
const MAX_STOP = 3;
|
|
@@ -98,10 +93,11 @@ function preToolUse(data) {
|
|
|
98
93
|
if (WRITE_TOOLS.has(toolKey)) {
|
|
99
94
|
return parentWrite(data, toolInput);
|
|
100
95
|
}
|
|
101
|
-
if (
|
|
102
|
-
|
|
96
|
+
if (PARENT_TOOLS.has(toolKey)) {
|
|
97
|
+
emit({ decision: "allow" });
|
|
98
|
+
return 0;
|
|
103
99
|
}
|
|
104
|
-
if (
|
|
100
|
+
if (hasParentEscape(data)) {
|
|
105
101
|
const fatCode = emitFat(data);
|
|
106
102
|
if (fatCode !== null) return fatCode;
|
|
107
103
|
emit({ decision: "allow" });
|
|
@@ -111,6 +107,11 @@ function preToolUse(data) {
|
|
|
111
107
|
return 0;
|
|
112
108
|
}
|
|
113
109
|
|
|
110
|
+
function hasParentEscape(data) {
|
|
111
|
+
const p = stampPath(data, "parent-escape");
|
|
112
|
+
return Boolean(p && fs.existsSync(p));
|
|
113
|
+
}
|
|
114
|
+
|
|
114
115
|
function logPreTool(data, toolKey, toolInput) {
|
|
115
116
|
const fields = {};
|
|
116
117
|
if (SPAWN_TOOLS.has(toolKey) && toolInput && typeof toolInput === "object") {
|
|
@@ -164,20 +165,6 @@ export function isAllowedParentGruntJob(command, workspaceRoot) {
|
|
|
164
165
|
return isWorkspaceGruntJob(command, workspaceRoot, ["search", "exec"]);
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
function parentBash(data, toolInput) {
|
|
168
|
-
if (!toolInput || typeof toolInput !== "object" || Array.isArray(toolInput)) {
|
|
169
|
-
emit({ decision: "deny", reason: DENY_REASON });
|
|
170
|
-
return 0;
|
|
171
|
-
}
|
|
172
|
-
const cmd = typeof toolInput.command === "string" ? toolInput.command : "";
|
|
173
|
-
if (!isAllowedParentGruntJob(cmd, workspaceRootOf(data))) {
|
|
174
|
-
emit({ decision: "deny", reason: DENY_REASON });
|
|
175
|
-
return 0;
|
|
176
|
-
}
|
|
177
|
-
emit({ decision: "allow" });
|
|
178
|
-
return 0;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
168
|
function parentWrite(data, toolInput) {
|
|
182
169
|
if (!toolInput || typeof toolInput !== "object" || Array.isArray(toolInput)) {
|
|
183
170
|
emit({ decision: "deny", reason: DENY_REASON });
|
|
@@ -272,8 +259,7 @@ function stop(data) {
|
|
|
272
259
|
}
|
|
273
260
|
|
|
274
261
|
const msg = data.lastAssistantMessage || data.last_assistant_message || "";
|
|
275
|
-
if (
|
|
276
|
-
if (!looksLikeImplementation(msg)) return 0;
|
|
262
|
+
if (isChildRecap(msg)) return 0;
|
|
277
263
|
|
|
278
264
|
const stopStamp = stampPath(data, "stop-block");
|
|
279
265
|
let n = 0;
|
|
@@ -391,36 +377,13 @@ function interceptNeed(data, hookEventName) {
|
|
|
391
377
|
return 0;
|
|
392
378
|
}
|
|
393
379
|
|
|
394
|
-
function looksLikeImplementation(msg) {
|
|
395
|
-
if (typeof msg !== "string") return false;
|
|
396
|
-
const t = msg;
|
|
397
|
-
if (t.includes("```")) return true;
|
|
398
|
-
if (/(?:^|\n)(?:diff --git |--- [^\n]+\n\+\+\+ |@@ )/.test(t)) return true;
|
|
399
|
-
if (/\b(?:write|create|edit)[-_ ]file\b/i.test(t)) return true;
|
|
400
|
-
const patchLines = t.split(/\n/).filter((l) => /^[+-](?![+-])/.test(l)).length;
|
|
401
|
-
if (patchLines >= 8) return true;
|
|
402
|
-
return false;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function isCheap(msg) {
|
|
406
|
-
if (typeof msg !== "string") return false;
|
|
407
|
-
const t = msg.trim();
|
|
408
|
-
if (!t || t.length > 500) return false;
|
|
409
|
-
if (t.includes("```")) return false;
|
|
410
|
-
const sentences = t.split(/(?<=[.!?])(?:\s+|$)/).filter((s) => s.trim());
|
|
411
|
-
if (sentences.length > 2) return false;
|
|
412
|
-
const lines = t.split(/\n/).filter((l) => l.trim());
|
|
413
|
-
return lines.length <= 4;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
380
|
function stampPath(data, prefix) {
|
|
417
|
-
const root =
|
|
418
|
-
process.env.GROK_WORKSPACE_ROOT ||
|
|
419
|
-
(data && (data.workspaceRoot || data.workspace_root)) ||
|
|
420
|
-
"";
|
|
381
|
+
const root = workspaceRootOf(data);
|
|
421
382
|
const sid =
|
|
422
|
-
process.env.GROK_SESSION_ID ||
|
|
423
|
-
|
|
383
|
+
process.env.GROK_SESSION_ID ||
|
|
384
|
+
(data && (data.sessionId || data.session_id)) ||
|
|
385
|
+
"default";
|
|
386
|
+
if (!root) return null;
|
|
424
387
|
return path.join(root, ORCHESTRATOR_LOGS_DIR, prefix + "-" + sid);
|
|
425
388
|
}
|
|
426
389
|
|
package/.grok/roles/thinker.toml
CHANGED
package/.rulesync/hooks.jsonc
CHANGED
|
@@ -17,6 +17,22 @@
|
|
|
17
17
|
"command": "node \"${GROK_WORKSPACE_ROOT:-${CLAUDE_PROJECT_DIR:-.}}/scripts/gate-fat-tools.mjs\"",
|
|
18
18
|
"timeout": 5
|
|
19
19
|
}
|
|
20
|
+
],
|
|
21
|
+
// Parent Stop + /parent stamp. PreToolUse parent-deny stays Grok-only
|
|
22
|
+
// (child subagentType/agent_type unverified on these hosts).
|
|
23
|
+
"userPromptSubmit": [
|
|
24
|
+
{
|
|
25
|
+
"type": "command",
|
|
26
|
+
"command": "node \"${GROK_WORKSPACE_ROOT:-${CLAUDE_PROJECT_DIR:-.}}/.grok/hooks/orchestrate-parent.js\"",
|
|
27
|
+
"timeout": 5
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"stop": [
|
|
31
|
+
{
|
|
32
|
+
"type": "command",
|
|
33
|
+
"command": "node \"${GROK_WORKSPACE_ROOT:-${CLAUDE_PROJECT_DIR:-.}}/.grok/hooks/orchestrate-parent.js\"",
|
|
34
|
+
"timeout": 30
|
|
35
|
+
}
|
|
20
36
|
]
|
|
21
37
|
}
|
|
22
38
|
}
|
|
@@ -8,37 +8,30 @@ Shipped protocol: **parent-only spawn**. Only the parent **orchestrator** sessio
|
|
|
8
8
|
|
|
9
9
|
## Parent orchestrator
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
7. Unsure → implementer.
|
|
11
|
+
Always spawn + prompt. First token = spawn. No try-then-spawn. No parent probe. No tiny-read/grep/list_dir/bash/grunt-job for the user. No skip-spawn. `/parent` is the only parent-tool escape.
|
|
12
|
+
|
|
13
|
+
1. Tools (facts / search / exec / git / web / test / low-reason mechanical write) → grunt.
|
|
14
|
+
2. Write defined solution → implementer.
|
|
15
|
+
3. Plan / deep reason (edge cases / pitfalls) → thinker.
|
|
16
|
+
4. Fresh/world facts → grunt `job: web`. Never answer from memory.
|
|
18
17
|
|
|
19
18
|
Spawn only `grunt` | `implementer` | `thinker`. Omit `model`. Isolation `none` unless asked.
|
|
20
19
|
|
|
21
|
-
Implementer/thinker may tiny-Read/Grep/list_dir themselves.
|
|
20
|
+
Implementer/thinker may tiny-Read/Grep/list_dir themselves. Fat dumps via `need:` JSON.
|
|
22
21
|
|
|
23
22
|
Long parent sessions rely on two-pass compaction; prefer a new parent session per task rather than unbounded resume chains. `[features] two_pass_compaction = true` must live in `~/.grok/config.toml` (from `.grok/global-settings.toml` via `npm run sync:globals` dry-run / `npm run sync:globals:apply`). Project `.grok/config.toml` cannot set `[features]`. Do not add a SessionStart hook.
|
|
24
23
|
|
|
25
|
-
## Pre-spawn
|
|
26
|
-
|
|
27
|
-
If dumps are known (paths, rg, test cmd): parent and implementer run `node scripts/grunt-job.mjs --job search|exec --query …` in-session and pass those `verdict:` blobs into the child prompt. Optional `--path` `--glob` (repeatable) `--cwd`. `--query` is one argv; regex `|` OK. Never `cd &&`. Unknown flags or exec shell-meta in query → FALLBACK (exit 2). Do not start the child and `need:` for a dump already known. Thinker stays read-only (no bash): fat search|exec via `need:` + SubagentStop intercept.
|
|
28
|
-
|
|
29
|
-
For spawned grunt `job: search|exec`, first action is still `node scripts/grunt-job.mjs --job search|exec --query …` and echo stdout as the whole reply. Bounded `job: test` may try the same script (`--job test`); `job: web` and messy `job: test` stay LLM grunt. If the script prints `FALLBACK` (exit 2), LLM grunt may use tools.
|
|
30
|
-
|
|
31
24
|
## Wait / peek
|
|
32
25
|
|
|
33
26
|
Parent-only. Non-blocking spawn so each child has a host id immediately. Per-child, not one global timer.
|
|
34
|
-
Every
|
|
27
|
+
Every 60s peek is real host status (no `sleep` then guess). `timeout_ms=60000` every peek.
|
|
35
28
|
Quote host fields only (`status`, elapsed since spawn, last activity/output snippet) or quote the error. Never invent.
|
|
36
29
|
Classify `done` | `alive` | `stuck` vs prior peek: **done** (completed/failed), **alive** (running + fields/output changed), **stuck** (running + unchanged). Unchanged snippet = stuck, not “still working”.
|
|
37
30
|
Loop until done. No auto-kill. Kill only if the user asks and the host has a kill tool.
|
|
38
31
|
Then print recap as `[agent]: …` with real child output. Do not redo the child's work.
|
|
39
32
|
|
|
40
|
-
Parent Stop (`MAX_STOP=3`): do not waive fenced/impl finals for `tools-used` stamp. Allow
|
|
41
|
-
`/parent` is one-turn (not a mode): UserPromptSubmit writes `.tmp/orchestrator-logs/parent-escape-{sid}`; Stop consumes+unlinks once. Next Stop resumes spawn/
|
|
33
|
+
Parent Stop (`MAX_STOP=3`): do not waive fenced/impl finals for `tools-used` stamp. Allow only `[grunt|implementer|thinker]:` recap prefix, or consume `parent-escape-{sid}` once. Else block. No `isCheap` / trivia / long definitions.
|
|
34
|
+
`/parent` is one-turn (not a mode): UserPromptSubmit writes `.tmp/orchestrator-logs/parent-escape-{sid}`; Stop consumes+unlinks once. Next Stop resumes spawn/recap rules. Skills point here; do not paste this file.
|
|
42
35
|
|
|
43
36
|
Host mapping (in-tree only; do not invent peek/kill APIs). GAP rows: no fake peeks, no auto-kill.
|
|
44
37
|
|
|
@@ -66,7 +59,7 @@ Parent: parse with `scripts/parse-need.mjs` (same grammar). If parse succeeds, f
|
|
|
66
59
|
|
|
67
60
|
Resume prompt = `You are {agent} subagent.` plus the new verdicts. Do not re-send the original task, cascade, or prior verdicts (`resume_from` already has the transcript).
|
|
68
61
|
|
|
69
|
-
|
|
62
|
+
Voice: [output](output.md). Does not change need:/verdict:/plan grammar.
|
|
70
63
|
|
|
71
64
|
## Isolation grunt `verdict:`
|
|
72
65
|
|
|
@@ -78,7 +71,7 @@ n: <count>
|
|
|
78
71
|
|
|
79
72
|
Fail: first 3 error lines. ≤8 lines. No dumps, recap, HTML, JSON, full logs.
|
|
80
73
|
|
|
81
|
-
Implementer/thinker: fat dumps via `need:` JSON. Implementer shell via rtk; cat/rg/curl/tests without rtk → fat `need:`.
|
|
74
|
+
Implementer/thinker: fat dumps via `need:` JSON. Implementer shell via rtk; cat/rg/curl/tests without rtk → fat `need:`.
|
|
82
75
|
|
|
83
76
|
Child prompt = `You are {agent} subagent.` + task + abs paths + verdicts only.
|
|
84
77
|
|
|
@@ -12,7 +12,7 @@ Claude / Codex / Antigravity PreToolUse still run `scripts/scrub-spawn-prompt.mj
|
|
|
12
12
|
|
|
13
13
|
Parent `run_terminal_command` is deny-by-default except `node` (optional leading `rtk`) invoking `{workspace}/scripts/grunt-job.mjs` with `--job search|exec` and `--query`. Optional `--path` `--glob` (repeatable) `--cwd`. Not `web|test`, not other scripts. META strips `--query` value first so `|` inside query is allowed; pipes/`&&` outside query still deny. Never `cd &&`. Exec shell-meta in query is grunt-job FALLBACK (exit 2), not a parent-bash allow. Unknown flags → FALLBACK.
|
|
14
14
|
|
|
15
|
-
SubagentStop (and child Stop with `subagentType`) intercepts a parseable `need:` whose jobs are all `search|exec` (cap 4): runs grunt-job in-hook and continues the child with concatenated `verdict:` blobs. Mixed/web/test, parse fail, FALLBACK, `stopHookActive`, or more than 3 intercepts per child session → empty stdout (allow stop; parent LLM path). Parent Stop (`MAX_STOP=3`): do not waive impl finals for `tools-used`. Allow
|
|
15
|
+
SubagentStop (and child Stop with `subagentType`) intercepts a parseable `need:` whose jobs are all `search|exec` (cap 4): runs grunt-job in-hook and continues the child with concatenated `verdict:` blobs. Mixed/web/test, parse fail, FALLBACK, `stopHookActive`, or more than 3 intercepts per child session → empty stdout (allow stop; parent LLM path). Parent Stop (`MAX_STOP=3`): do not waive impl finals for `tools-used`. Allow only `[grunt|implementer|thinker]:` recap prefix, or consume `parent-escape-{sid}` once (`/parent`). No `isCheap` / trivia. Stamps: `tools-used` / `stop-block` / `need-intercept` / `parent-escape`. Skills point to cascade; do not paste protocol here.
|
|
16
16
|
|
|
17
17
|
Stop and SubagentStop timeout is 30s (grunt-job cap is 20s). PreToolUse / PostToolUse / UserPromptSubmit stay at 5s. If the intercept times out, the hook fail-opens and the child stops without verdicts.
|
|
18
18
|
|
|
@@ -11,12 +11,13 @@ Cheap outline. Not a file dump.
|
|
|
11
11
|
- `.rulesync/reference/rtk.md` — shell compression
|
|
12
12
|
- `.rulesync/reference/hooks.md` — hook policy
|
|
13
13
|
- `.rulesync/reference/map.md` — this file
|
|
14
|
+
- `.rulesync/reference/output.md` — default voice
|
|
14
15
|
|
|
15
16
|
## Agent SSOT
|
|
16
17
|
- `.rulesync/subagents/{orchestrator,implementer,thinker,grunt}.md`
|
|
17
18
|
- `.rulesync/rules/overview.md` → `AGENTS.md`
|
|
18
19
|
- `.rulesync/rules/CLAUDE.md` → `CLAUDE.md`
|
|
19
|
-
- Default output (overview.md → AGENTS.md; also agent bodies + CLAUDE.md, not auto-injected)
|
|
20
|
+
- Default output: `.rulesync/reference/output.md` (overview.md → AGENTS.md; also agent bodies + CLAUDE.md, not auto-injected)
|
|
20
21
|
|
|
21
22
|
## Grok hand files
|
|
22
23
|
- `.grok/hooks/orchestrate-parent.js` + `orchestrate-parent.json` — parent spawn/fat/stop/plan-write / SubagentStop intercept
|
|
@@ -3,11 +3,13 @@ root: true
|
|
|
3
3
|
targets:
|
|
4
4
|
- claudecode
|
|
5
5
|
---
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
Voice: `.rulesync/reference/output.md`
|
|
7
|
+
Protocol: `.rulesync/reference/cascade.md`. Do not paste. Do not open first.
|
|
8
|
+
Parent = this file not `.claude/agents/orchestrator.md`. You do not talk. Spawn wait echo.
|
|
9
|
+
Spawn only grunt|implementer|thinker. Never spawn orchestrator. Children never spawn.
|
|
10
|
+
First token = spawn. No try-then-spawn. No parent probe. After child: `[agent]:` echo only. No skip-spawn. /parent = one-turn.
|
|
11
|
+
grunt ← tools (facts/search/exec/git/web/test/low-reason mechanical write; world fact: `job: web` never memory). implementer ← write defined solution. thinker ← plan/deep reason.
|
|
12
|
+
Child prompt = `You are {agent} subagent.` + task + abs paths + verdicts only.
|
|
13
|
+
Peek every 60s/child; quote real host fields; `done|alive|stuck`; no invent; no auto-kill. `timeout_ms=60000` every peek. GAP: block on spawn return = `done`. Stuck/blocked: quote host fields only.
|
|
14
|
+
`need:` JSON → parse-need + parallel grunt; one `resume_from` + new verdicts; max 3; no re-send task; no fresh-spawn.
|
|
15
|
+
Child: this file does not apply; your agent file gates you. Never spawn.
|
|
@@ -8,16 +8,13 @@ targets:
|
|
|
8
8
|
globs:
|
|
9
9
|
- "**/*"
|
|
10
10
|
---
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Implementer/thinker do not spawn. Dumps = `need:` JSON stop (cascade). Thinker: no bash. Plan: patch `[ ]` → `[x]` when done.
|
|
22
|
-
Wait/peek (parent): ≤60s per-child peek; quote real host fields; classify `done|alive|stuck`; never invent; no auto-kill; cascade mapping.
|
|
23
|
-
If this file conflicts with the law file the law file wins.
|
|
11
|
+
Voice: `.rulesync/reference/output.md` once.
|
|
12
|
+
Protocol: `.rulesync/reference/cascade.md`. Do not paste. Do not open first.
|
|
13
|
+
Parent = orchestrator. You do not talk. Spawn wait echo.
|
|
14
|
+
Spawn only grunt|implementer|thinker. Never spawn orchestrator. Children never spawn.
|
|
15
|
+
First token = spawn. No try-then-spawn. No parent probe. After child: `[agent]:` echo only. No skip-spawn. /parent = one-turn.
|
|
16
|
+
grunt ← tools (facts/search/exec/git/web/test/low-reason mechanical write; world fact: `job: web` never memory). implementer ← write defined solution. thinker ← plan/deep reason.
|
|
17
|
+
Child prompt = `You are {agent} subagent.` + task + abs paths + verdicts only.
|
|
18
|
+
Peek every 60s/child; quote real host fields; `done|alive|stuck`; no invent; no auto-kill. `timeout_ms=60000` every peek. GAP: block on spawn return = `done`. Stuck/blocked: quote host fields only.
|
|
19
|
+
`need:` JSON → parse-need + parallel grunt; one `resume_from` + new verdicts; max 3; no re-send task; no fresh-spawn.
|
|
20
|
+
Child: this file does not apply; your agent file gates you. Never spawn.
|