Skip to content

Commit 1579947

Browse files
Yeachan-HeoCodex Review
andauthored
fix: align persistent stop hook and tighten agent output contracts (#2653)
Co-authored-by: Codex Review <codex-review@example.com>
1 parent 4851e81 commit 1579947

File tree

10 files changed

+61
-1
lines changed

10 files changed

+61
-1
lines changed

hooks/hooks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
},
181181
{
182182
"type": "command",
183-
"command": "node \"$CLAUDE_PLUGIN_ROOT\"/scripts/run.cjs \"$CLAUDE_PLUGIN_ROOT\"/scripts/persistent-mode.cjs",
183+
"command": "node \"$CLAUDE_PLUGIN_ROOT\"/scripts/run.cjs \"$CLAUDE_PLUGIN_ROOT\"/scripts/persistent-mode.mjs",
184184
"timeout": 10
185185
},
186186
{
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { readFileSync } from 'fs';
3+
import { join } from 'path';
4+
import { ULTRAWORK_MESSAGE } from '../installer/hooks.js';
5+
6+
describe('issue #2652 runtime wiring and output contract', () => {
7+
it('ships the Stop hook through persistent-mode.mjs', () => {
8+
const hooksJsonPath = join(process.cwd(), 'hooks', 'hooks.json');
9+
const hooks = JSON.parse(readFileSync(hooksJsonPath, 'utf-8')) as {
10+
hooks?: Record<string, Array<{ hooks?: Array<{ command?: string }> }>>;
11+
};
12+
13+
const stopCommands = (hooks.hooks?.Stop ?? [])
14+
.flatMap((entry) => entry.hooks ?? [])
15+
.map((hook) => hook.command ?? '');
16+
17+
expect(stopCommands.some((command) => command.includes('/scripts/persistent-mode.mjs'))).toBe(true);
18+
expect(stopCommands.some((command) => command.includes('/scripts/persistent-mode.cjs'))).toBe(false);
19+
});
20+
21+
it('ultrawork mode instructs spawned agents to keep outputs concise', () => {
22+
expect(ULTRAWORK_MESSAGE).toContain('CONCISE OUTPUTS');
23+
expect(ULTRAWORK_MESSAGE).toContain('under 100 words');
24+
expect(ULTRAWORK_MESSAGE).toContain('files touched');
25+
expect(ULTRAWORK_MESSAGE).toContain('verification status');
26+
});
27+
});

src/__tests__/ralph-prd-mandatory.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ describe('Ralph PRD-Mandatory', () => {
320320
expect(prompt).toContain('Are ALL requirements from the original task met?');
321321
expect(prompt).toContain('Is the implementation complete, not partial?');
322322
expect(prompt).not.toContain('Verify EACH acceptance criterion');
323+
expect(prompt).toContain('concise review summary under 100 words');
323324
});
324325

325326
it('should fall back to generic prompt when story is undefined', () => {

src/hooks/autopilot/__tests__/pipeline.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ describe('Stage Adapters', () => {
133133
expect(prompt).toContain('Team Mode');
134134
expect(prompt).toContain('TeamCreate');
135135
expect(prompt).toContain(EXECUTION_COMPLETION_SIGNAL);
136+
expect(prompt).toContain('short execution summary under 100 words');
136137
});
137138

138139
it('should generate solo prompt for solo mode', () => {
@@ -143,6 +144,7 @@ describe('Stage Adapters', () => {
143144
});
144145
expect(prompt).toContain('Solo Mode');
145146
expect(prompt).toContain(EXECUTION_COMPLETION_SIGNAL);
147+
expect(prompt).toContain('short execution summary under 100 words');
146148
});
147149
});
148150

@@ -166,6 +168,7 @@ describe('Stage Adapters', () => {
166168
});
167169
expect(prompt).toContain('50');
168170
expect(prompt).toContain(RALPH_COMPLETION_SIGNAL);
171+
expect(prompt).toContain('concise review summary under 100 words');
169172
});
170173
});
171174

src/hooks/autopilot/__tests__/prompts.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ describe("Prompt Generation", () => {
7373
expect(prompt).toContain("Ralph");
7474
expect(prompt).toContain("Ultrawork");
7575
});
76+
77+
it("should require concise executor summaries", () => {
78+
const prompt = getExecutionPrompt("plan.md");
79+
expect(prompt).toContain("concise execution summary under 100 words");
80+
expect(prompt).toContain("files touched");
81+
expect(prompt).toContain("verification status");
82+
});
7683
});
7784

7885
describe("getQAPrompt", () => {
@@ -96,6 +103,13 @@ describe("Prompt Generation", () => {
96103
expect(prompt).toContain("Security");
97104
expect(prompt).toContain("Quality");
98105
});
106+
107+
it("should require concise reviewer summaries", () => {
108+
const prompt = getValidationPrompt("spec.md");
109+
expect(prompt).toContain("concise review summary under 100 words");
110+
expect(prompt).toContain("evidence highlights");
111+
expect(prompt).toContain("files checked");
112+
});
99113
});
100114

101115
describe("getPhasePrompt", () => {

src/hooks/autopilot/adapters/execution-adapter.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Use the Team orchestrator to execute tasks in parallel:
4949
4. **Monitor progress** as teammates complete tasks
5050
5. **Coordinate** dependencies between tasks
5151
52+
### Output Contract
53+
54+
Every teammate response must stay concise: return ONLY a short execution summary under 100 words covering what changed, files touched, verification status, and blockers. Store bulky logs/details in files or artifacts and reference them briefly.
55+
5256
### Agent Selection
5357
5458
Match agent types to task complexity:
@@ -92,6 +96,10 @@ Execute tasks sequentially (or with limited parallelism via background agents):
9296
3. Use executor agents for independent tasks that can run in parallel
9397
4. Track progress in the TODO list
9498
99+
### Output Contract
100+
101+
Every spawned executor response must return ONLY a short execution summary under 100 words covering what changed, files touched, verification status, and blockers. Store bulky logs/details in files or artifacts and reference them briefly.
102+
95103
### Agent Spawning
96104
97105
\`\`\`

src/hooks/autopilot/adapters/ralph-adapter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Verify the implementation against the specification using the Ralph verification
3939
4040
Spawn parallel verification reviewers:
4141
42+
Each reviewer must return ONLY a concise review summary under 100 words covering verdict, evidence highlights, files checked, and blockers. Avoid dumping long logs or transcripts into the main session.
43+
4244
\`\`\`
4345
// Functional Completeness Review
4446
Task(

src/hooks/autopilot/prompts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ Ralph and Ultrawork are now active. Execute tasks in parallel where possible.
214214
- Spawn multiple executor agents for parallel work
215215
- Track progress in the TODO list
216216
- Use appropriate agent tiers based on task complexity
217+
- Every spawned agent must return ONLY a concise execution summary under 100 words covering: what changed, files touched, verification status, and blockers. Do not paste long logs inline; write bulky output to files/artifacts and reference them briefly.
217218
218219
### Agent Spawning Pattern
219220
@@ -316,6 +317,8 @@ Spawn parallel validation architects for comprehensive review.
316317
317318
Spawn all three architects in parallel:
318319
320+
Each reviewer must return ONLY a concise review summary under 100 words with verdict, evidence highlights, files checked, and blockers. Do not paste long transcripts or logs into the main session.
321+
319322
\`\`\`
320323
// Functional Completeness Review
321324
Task(

src/hooks/ralph/verifier.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ ${getVerificationAgentStep(state.critic_mode)}
272272
- Are there any obvious bugs or issues?
273273
- Does the code compile/run without errors?
274274
- Are tests passing (if applicable)?
275+
- Return ONLY a concise review summary under 100 words with verdict, evidence highlights, files checked, and blockers. Do not paste long logs inline.
275276
276277
3. **Based on ${criticLabel}'s response:**
277278
- If APPROVED: Output the exact correlated approval tag \`${approvalTag}\`, then run \`/oh-my-claudecode:cancel\` to cleanly exit

src/installer/hooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ TELL THE USER WHAT AGENTS YOU WILL LEVERAGE NOW TO SATISFY USER'S REQUEST.
135135
- **TODO**: Track EVERY step. Mark complete IMMEDIATELY after each.
136136
- **PARALLEL**: Fire independent agent calls simultaneously via Task(run_in_background=true) - NEVER wait sequentially.
137137
- **BACKGROUND FIRST**: Use Task tool for exploration/document-specialist agents (10+ concurrent if needed).
138+
- **CONCISE OUTPUTS**: Every Task/Agent result must return ONLY a short execution summary (target: under 100 words) covering what changed, files touched, verification status, and blockers. Do not paste long logs into the main session; put bulky details in files/artifacts and reference them briefly.
138139
- **VERIFY**: Re-read request after completion. Check ALL requirements met before reporting done.
139140
- **DELEGATE**: Don't do everything yourself - orchestrate specialized agents for their strengths.
140141

0 commit comments

Comments
 (0)