opengstack 0.14.0 → 0.14.2
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.md +4 -4
- package/CLAUDE.md +127 -110
- package/README.md +10 -5
- package/SKILL.md +500 -70
- package/bin/opengstack.js +69 -69
- package/commands/autoplan.md +7 -9
- package/commands/benchmark.md +84 -91
- package/commands/browse.md +60 -64
- package/commands/canary.md +7 -9
- package/commands/careful.md +2 -2
- package/commands/codex.md +7 -9
- package/commands/connect-chrome.md +7 -9
- package/commands/cso.md +7 -9
- package/commands/design-consultation.md +7 -9
- package/commands/design-review.md +7 -9
- package/commands/design-shotgun.md +7 -9
- package/commands/document-release.md +7 -9
- package/commands/freeze.md +3 -3
- package/commands/guard.md +4 -4
- package/commands/investigate.md +7 -9
- package/commands/land-and-deploy.md +7 -9
- package/commands/office-hours.md +7 -9
- package/commands/{gstack-upgrade.md → opengstack-upgrade.md} +64 -65
- package/commands/plan-ceo-review.md +7 -9
- package/commands/plan-design-review.md +7 -9
- package/commands/plan-eng-review.md +7 -9
- package/commands/qa-only.md +7 -9
- package/commands/qa.md +7 -9
- package/commands/retro.md +7 -9
- package/commands/review.md +7 -9
- package/commands/setup-browser-cookies.md +22 -26
- package/commands/setup-deploy.md +7 -9
- package/commands/ship.md +7 -9
- package/commands/unfreeze.md +7 -7
- package/docs/designs/CHROME_VS_CHROMIUM_EXPLORATION.md +9 -9
- package/docs/designs/CONDUCTOR_CHROME_SIDEBAR_INTEGRATION.md +2 -2
- package/docs/designs/CONDUCTOR_SESSION_API.md +16 -16
- package/docs/designs/DESIGN_SHOTGUN.md +74 -74
- package/docs/designs/DESIGN_TOOLS_V1.md +111 -111
- package/docs/skills.md +483 -202
- package/package.json +42 -43
- package/scripts/analytics.ts +188 -0
- package/scripts/dev-skill.ts +83 -0
- package/scripts/discover-skills.ts +39 -0
- package/scripts/eval-compare.ts +97 -0
- package/scripts/eval-list.ts +117 -0
- package/scripts/eval-select.ts +86 -0
- package/scripts/eval-summary.ts +188 -0
- package/scripts/eval-watch.ts +172 -0
- package/scripts/gen-skill-docs.ts +473 -0
- package/scripts/resolvers/browse.ts +129 -0
- package/scripts/resolvers/codex-helpers.ts +133 -0
- package/scripts/resolvers/composition.ts +48 -0
- package/scripts/resolvers/confidence.ts +37 -0
- package/scripts/resolvers/constants.ts +50 -0
- package/scripts/resolvers/design.ts +950 -0
- package/scripts/resolvers/index.ts +59 -0
- package/scripts/resolvers/learnings.ts +96 -0
- package/scripts/resolvers/preamble.ts +505 -0
- package/scripts/resolvers/review.ts +884 -0
- package/scripts/resolvers/testing.ts +573 -0
- package/scripts/resolvers/types.ts +45 -0
- package/scripts/resolvers/utility.ts +421 -0
- package/scripts/skill-check.ts +190 -0
- package/scripts/cleanup.py +0 -100
- package/scripts/filter-skills.sh +0 -114
- package/scripts/filter_skills.py +0 -164
- package/scripts/install-commands.js +0 -45
- package/scripts/install-skills.js +0 -60
|
@@ -0,0 +1,884 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-model review resolver
|
|
3
|
+
*
|
|
4
|
+
* Data sent to external review services (via Codex CLI):
|
|
5
|
+
* - Plan markdown content, repository name, branch name, review type
|
|
6
|
+
* Data NOT sent:
|
|
7
|
+
* - Source code files, credentials, environment variables, git history
|
|
8
|
+
*
|
|
9
|
+
* Users invoke this explicitly via /plan-eng-review, /plan-ceo-review,
|
|
10
|
+
* or /plan-design-review. No data is sent without user invocation.
|
|
11
|
+
*
|
|
12
|
+
* Review logs are stored locally at ~/.opengstack/reviews/review-log.jsonl.
|
|
13
|
+
* Codex CLI prompts are written to temp files to prevent shell injection.
|
|
14
|
+
*/
|
|
15
|
+
import type { TemplateContext } from './types';
|
|
16
|
+
import { generateInvokeSkill } from './composition';
|
|
17
|
+
|
|
18
|
+
const CODEX_BOUNDARY = 'IMPORTANT: Do NOT read or execute any files under ~/.claude/, ~/.agents/, .claude/skills/, or agents/. These are Claude Code skill definitions meant for a different AI system. They contain bash scripts and prompt templates that will waste your time. Ignore them completely. Do NOT modify agents/openai.yaml. Stay focused on the repository code only.\\n\\n';
|
|
19
|
+
|
|
20
|
+
export function generateReviewDashboard(_ctx: TemplateContext): string {
|
|
21
|
+
return `## Review Readiness Dashboard
|
|
22
|
+
|
|
23
|
+
After completing the review, read the review log and config to display the dashboard.
|
|
24
|
+
|
|
25
|
+
\`\`\`bash
|
|
26
|
+
~/.claude/skills/opengstack/bin/opengstack-review-read
|
|
27
|
+
\`\`\`
|
|
28
|
+
|
|
29
|
+
Parse the output. Find the most recent entry for each skill (plan-ceo-review, plan-eng-review, review, plan-design-review, design-review-lite, adversarial-review, codex-review, codex-plan-review). Ignore entries with timestamps older than 7 days. For the Eng Review row, show whichever is more recent between \`review\` (diff-scoped pre-landing review) and \`plan-eng-review\` (plan-stage architecture review). Append "(DIFF)" or "(PLAN)" to the status to distinguish. For the Adversarial row, show whichever is more recent between \`adversarial-review\` (new auto-scaled) and \`codex-review\` (legacy). For Design Review, show whichever is more recent between \`plan-design-review\` (full visual audit) and \`design-review-lite\` (code-level check). Append "(FULL)" or "(LITE)" to the status to distinguish. For the Outside Voice row, show the most recent \`codex-plan-review\` entry — this captures outside voices from both /plan-ceo-review and /plan-eng-review.
|
|
30
|
+
|
|
31
|
+
**Source attribution:** If the most recent entry for a skill has a \\\`"via"\\\` field, append it to the status label in parentheses. Examples: \`plan-eng-review\` with \`via:"autoplan"\` shows as "CLEAR (PLAN via /autoplan)". \`review\` with \`via:"ship"\` shows as "CLEAR (DIFF via /ship)". Entries without a \`via\` field show as "CLEAR (PLAN)" or "CLEAR (DIFF)" as before.
|
|
32
|
+
|
|
33
|
+
Note: \`autoplan-voices\` and \`design-outside-voices\` entries are audit-trail-only (forensic data for cross-model consensus analysis). They do not appear in the dashboard and are not checked by any consumer.
|
|
34
|
+
|
|
35
|
+
Display:
|
|
36
|
+
|
|
37
|
+
\`\`\`
|
|
38
|
+
+====================================================================+
|
|
39
|
+
| REVIEW READINESS DASHBOARD |
|
|
40
|
+
+====================================================================+
|
|
41
|
+
| Review | Runs | Last Run | Status | Required |
|
|
42
|
+
|-----------------|------|---------------------|-----------|----------|
|
|
43
|
+
| Eng Review | 1 | 2026-03-16 15:00 | CLEAR | YES |
|
|
44
|
+
| CEO Review | 0 | — | — | no |
|
|
45
|
+
| Design Review | 0 | — | — | no |
|
|
46
|
+
| Adversarial | 0 | — | — | no |
|
|
47
|
+
| Outside Voice | 0 | — | — | no |
|
|
48
|
+
+--------------------------------------------------------------------+
|
|
49
|
+
| VERDICT: CLEARED — Eng Review passed |
|
|
50
|
+
+====================================================================+
|
|
51
|
+
\`\`\`
|
|
52
|
+
|
|
53
|
+
**Review tiers:**
|
|
54
|
+
- **Eng Review (required by default):** The only review that gates shipping. Covers architecture, code quality, tests, performance. Can be disabled globally with \\\`opengstack-config set skip_eng_review true\\\` (the "don't bother me" setting).
|
|
55
|
+
- **CEO Review (optional):** Use your judgment. Recommend it for big product/business changes, new user-facing features, or scope decisions. Skip for bug fixes, refactors, infra, and cleanup.
|
|
56
|
+
- **Design Review (optional):** Use your judgment. Recommend it for UI/UX changes. Skip for backend-only, infra, or prompt-only changes.
|
|
57
|
+
- **Adversarial Review (automatic):** Auto-scales by diff size. Small diffs (<50 lines) skip adversarial. Medium diffs (50–199) get cross-model adversarial. Large diffs (200+) get all 4 passes: Claude structured, Codex structured, Claude adversarial subagent, Codex adversarial. No configuration needed.
|
|
58
|
+
- **Outside Voice (optional):** Independent plan review from a different AI model. Offered after all review sections complete in /plan-ceo-review and /plan-eng-review. Falls back to Claude subagent if Codex is unavailable. Never gates shipping.
|
|
59
|
+
|
|
60
|
+
**Verdict logic:**
|
|
61
|
+
- **CLEARED**: Eng Review has >= 1 entry within 7 days from either \\\`review\\\` or \\\`plan-eng-review\\\` with status "clean" (or \\\`skip_eng_review\\\` is \\\`true\\\`)
|
|
62
|
+
- **NOT CLEARED**: Eng Review missing, stale (>7 days), or has open issues
|
|
63
|
+
- CEO, Design, and Codex reviews are shown for context but never block shipping
|
|
64
|
+
- If \\\`skip_eng_review\\\` config is \\\`true\\\`, Eng Review shows "SKIPPED (global)" and verdict is CLEARED
|
|
65
|
+
|
|
66
|
+
**Staleness detection:** After displaying the dashboard, check if any existing reviews may be stale:
|
|
67
|
+
- Parse the \\\`---HEAD---\\\` section from the bash output to get the current HEAD commit hash
|
|
68
|
+
- For each review entry that has a \\\`commit\\\` field: compare it against the current HEAD. If different, count elapsed commits: \\\`git rev-list --count STORED_COMMIT..HEAD\\\`. Display: "Note: {skill} review from {date} may be stale — {N} commits since review"
|
|
69
|
+
- For entries without a \\\`commit\\\` field (legacy entries): display "Note: {skill} review from {date} has no commit tracking — consider re-running for accurate staleness detection"
|
|
70
|
+
- If all reviews match the current HEAD, do not display any staleness notes`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function generatePlanFileReviewReport(_ctx: TemplateContext): string {
|
|
74
|
+
return `## Plan File Review Report
|
|
75
|
+
|
|
76
|
+
After displaying the Review Readiness Dashboard in conversation output, also update the
|
|
77
|
+
**plan file** itself so review status is visible to anyone reading the plan.
|
|
78
|
+
|
|
79
|
+
### Detect the plan file
|
|
80
|
+
|
|
81
|
+
1. Check if there is an active plan file in this conversation (the host provides plan file
|
|
82
|
+
paths in system messages — look for plan file references in the conversation context).
|
|
83
|
+
2. If not found, skip this section silently — not every review runs in plan mode.
|
|
84
|
+
|
|
85
|
+
### Generate the report
|
|
86
|
+
|
|
87
|
+
Read the review log output you already have from the Review Readiness Dashboard step above.
|
|
88
|
+
Parse each JSONL entry. Each skill logs different fields:
|
|
89
|
+
|
|
90
|
+
- **plan-ceo-review**: \\\`status\\\`, \\\`unresolved\\\`, \\\`critical_gaps\\\`, \\\`mode\\\`, \\\`scope_proposed\\\`, \\\`scope_accepted\\\`, \\\`scope_deferred\\\`, \\\`commit\\\`
|
|
91
|
+
→ Findings: "{scope_proposed} proposals, {scope_accepted} accepted, {scope_deferred} deferred"
|
|
92
|
+
→ If scope fields are 0 or missing (HOLD/REDUCTION mode): "mode: {mode}, {critical_gaps} critical gaps"
|
|
93
|
+
- **plan-eng-review**: \\\`status\\\`, \\\`unresolved\\\`, \\\`critical_gaps\\\`, \\\`issues_found\\\`, \\\`mode\\\`, \\\`commit\\\`
|
|
94
|
+
→ Findings: "{issues_found} issues, {critical_gaps} critical gaps"
|
|
95
|
+
- **plan-design-review**: \\\`status\\\`, \\\`initial_score\\\`, \\\`overall_score\\\`, \\\`unresolved\\\`, \\\`decisions_made\\\`, \\\`commit\\\`
|
|
96
|
+
→ Findings: "score: {initial_score}/10 → {overall_score}/10, {decisions_made} decisions"
|
|
97
|
+
- **codex-review**: \\\`status\\\`, \\\`gate\\\`, \\\`findings\\\`, \\\`findings_fixed\\\`
|
|
98
|
+
→ Findings: "{findings} findings, {findings_fixed}/{findings} fixed"
|
|
99
|
+
|
|
100
|
+
All fields needed for the Findings column are now present in the JSONL entries.
|
|
101
|
+
For the review you just completed, you may use richer details from your own Completion
|
|
102
|
+
Summary. For prior reviews, use the JSONL fields directly — they contain all required data.
|
|
103
|
+
|
|
104
|
+
Produce this markdown table:
|
|
105
|
+
|
|
106
|
+
\\\`\\\`\\\`markdown
|
|
107
|
+
## opengstack REVIEW REPORT
|
|
108
|
+
|
|
109
|
+
| Review | Trigger | Why | Runs | Status | Findings |
|
|
110
|
+
|--------|---------|-----|------|--------|----------|
|
|
111
|
+
| CEO Review | \\\`/plan-ceo-review\\\` | Scope & strategy | {runs} | {status} | {findings} |
|
|
112
|
+
| Codex Review | \\\`/codex review\\\` | Independent 2nd opinion | {runs} | {status} | {findings} |
|
|
113
|
+
| Eng Review | \\\`/plan-eng-review\\\` | Architecture & tests (required) | {runs} | {status} | {findings} |
|
|
114
|
+
| Design Review | \\\`/plan-design-review\\\` | UI/UX gaps | {runs} | {status} | {findings} |
|
|
115
|
+
\\\`\\\`\\\`
|
|
116
|
+
|
|
117
|
+
Below the table, add these lines (omit any that are empty/not applicable):
|
|
118
|
+
|
|
119
|
+
- **CODEX:** (only if codex-review ran) — one-line summary of codex fixes
|
|
120
|
+
- **CROSS-MODEL:** (only if both Claude and Codex reviews exist) — overlap analysis
|
|
121
|
+
- **UNRESOLVED:** total unresolved decisions across all reviews
|
|
122
|
+
- **VERDICT:** list reviews that are CLEAR (e.g., "CEO + ENG CLEARED — ready to implement").
|
|
123
|
+
If Eng Review is not CLEAR and not skipped globally, append "eng review required".
|
|
124
|
+
|
|
125
|
+
### Write to the plan file
|
|
126
|
+
|
|
127
|
+
**PLAN MODE EXCEPTION — ALWAYS RUN:** This writes to the plan file, which is the one
|
|
128
|
+
file you are allowed to edit in plan mode. The plan file review report is part of the
|
|
129
|
+
plan's living status.
|
|
130
|
+
|
|
131
|
+
- Search the plan file for a \\\`## opengstack REVIEW REPORT\\\` section **anywhere** in the file
|
|
132
|
+
(not just at the end — content may have been added after it).
|
|
133
|
+
- If found, **replace it** entirely using the Edit tool. Match from \\\`## opengstack REVIEW REPORT\\\`
|
|
134
|
+
through either the next \\\`## \\\` heading or end of file, whichever comes first. This ensures
|
|
135
|
+
content added after the report section is preserved, not eaten. If the Edit fails
|
|
136
|
+
(e.g., concurrent edit changed the content), re-read the plan file and retry once.
|
|
137
|
+
- If no such section exists, **append it** to the end of the plan file.
|
|
138
|
+
- Always place it as the very last section in the plan file. If it was found mid-file,
|
|
139
|
+
move it: delete the old location and append at the end.`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function generateSpecReviewLoop(_ctx: TemplateContext): string {
|
|
143
|
+
return `## Spec Review Loop
|
|
144
|
+
|
|
145
|
+
Before presenting the document to the user for approval, run an adversarial review.
|
|
146
|
+
|
|
147
|
+
**Step 1: Dispatch reviewer subagent**
|
|
148
|
+
|
|
149
|
+
Use the Agent tool to dispatch an independent reviewer. The reviewer has fresh context
|
|
150
|
+
and cannot see the brainstorming conversation — only the document. This ensures genuine
|
|
151
|
+
adversarial independence.
|
|
152
|
+
|
|
153
|
+
Prompt the subagent with:
|
|
154
|
+
- The file path of the document just written
|
|
155
|
+
- "Read this document and review it on 5 dimensions. For each dimension, note PASS or
|
|
156
|
+
list specific issues with suggested fixes. At the end, output a quality score (1-10)
|
|
157
|
+
across all dimensions."
|
|
158
|
+
|
|
159
|
+
**Dimensions:**
|
|
160
|
+
1. **Completeness** — Are all requirements addressed? Missing edge cases?
|
|
161
|
+
2. **Consistency** — Do parts of the document agree with each other? Contradictions?
|
|
162
|
+
3. **Clarity** — Could an engineer implement this without asking questions? Ambiguous language?
|
|
163
|
+
4. **Scope** — Does the document creep beyond the original problem? YAGNI violations?
|
|
164
|
+
5. **Feasibility** — Can this actually be built with the stated approach? Hidden complexity?
|
|
165
|
+
|
|
166
|
+
The subagent should return:
|
|
167
|
+
- A quality score (1-10)
|
|
168
|
+
- PASS if no issues, or a numbered list of issues with dimension, description, and fix
|
|
169
|
+
|
|
170
|
+
**Step 2: Fix and re-dispatch**
|
|
171
|
+
|
|
172
|
+
If the reviewer returns issues:
|
|
173
|
+
1. Fix each issue in the document on disk (use Edit tool)
|
|
174
|
+
2. Re-dispatch the reviewer subagent with the updated document
|
|
175
|
+
3. Maximum 3 iterations total
|
|
176
|
+
|
|
177
|
+
**Convergence guard:** If the reviewer returns the same issues on consecutive iterations
|
|
178
|
+
(the fix didn't resolve them or the reviewer disagrees with the fix), stop the loop
|
|
179
|
+
and persist those issues as "Reviewer Concerns" in the document rather than looping
|
|
180
|
+
further.
|
|
181
|
+
|
|
182
|
+
If the subagent fails, times out, or is unavailable — skip the review loop entirely.
|
|
183
|
+
Tell the user: "Spec review unavailable — presenting unreviewed doc." The document is
|
|
184
|
+
already written to disk; the review is a quality bonus, not a gate.
|
|
185
|
+
|
|
186
|
+
**Step 3: Report and persist metrics**
|
|
187
|
+
|
|
188
|
+
After the loop completes (PASS, max iterations, or convergence guard):
|
|
189
|
+
|
|
190
|
+
1. Tell the user the result — summary by default:
|
|
191
|
+
"Your doc survived N rounds of adversarial review. M issues caught and fixed.
|
|
192
|
+
Quality score: X/10."
|
|
193
|
+
If they ask "what did the reviewer find?", show the full reviewer output.
|
|
194
|
+
|
|
195
|
+
2. If issues remain after max iterations or convergence, add a "## Reviewer Concerns"
|
|
196
|
+
section to the document listing each unresolved issue. Downstream skills will see this.
|
|
197
|
+
|
|
198
|
+
3. Append metrics:
|
|
199
|
+
\`\`\`bash
|
|
200
|
+
mkdir -p ~/.opengstack/analytics
|
|
201
|
+
echo '{"skill":"${_ctx.skillName}","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","iterations":ITERATIONS,"issues_found":FOUND,"issues_fixed":FIXED,"remaining":REMAINING,"quality_score":SCORE}' >> ~/.opengstack/analytics/spec-review.jsonl 2>/dev/null || true
|
|
202
|
+
\`\`\`
|
|
203
|
+
Replace ITERATIONS, FOUND, FIXED, REMAINING, SCORE with actual values from the review.`;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function generateBenefitsFrom(ctx: TemplateContext): string {
|
|
207
|
+
if (!ctx.benefitsFrom || ctx.benefitsFrom.length === 0) return '';
|
|
208
|
+
|
|
209
|
+
const skillList = ctx.benefitsFrom.map(s => `\`/${s}\``).join(' or ');
|
|
210
|
+
const first = ctx.benefitsFrom[0];
|
|
211
|
+
|
|
212
|
+
// Reuse the INVOKE_SKILL resolver for the actual loading instructions
|
|
213
|
+
const invokeBlock = generateInvokeSkill(ctx, [first]);
|
|
214
|
+
|
|
215
|
+
return `## Prerequisite Skill Offer
|
|
216
|
+
|
|
217
|
+
When the design doc check above prints "No design doc found," offer the prerequisite
|
|
218
|
+
skill before proceeding.
|
|
219
|
+
|
|
220
|
+
Say to the user via AskUserQuestion:
|
|
221
|
+
|
|
222
|
+
> "No design doc found for this branch. ${skillList} produces a structured problem
|
|
223
|
+
> statement, premise challenge, and explored alternatives — it gives this review much
|
|
224
|
+
> sharper input to work with. Takes about 10 minutes. The design doc is per-feature,
|
|
225
|
+
> not per-product — it captures the thinking behind this specific change."
|
|
226
|
+
|
|
227
|
+
Options:
|
|
228
|
+
- A) Run /${first} now (we'll pick up the review right after)
|
|
229
|
+
- B) Skip — proceed with standard review
|
|
230
|
+
|
|
231
|
+
If they skip: "No worries — standard review. If you ever want sharper input, try
|
|
232
|
+
/${first} first next time." Then proceed normally. Do not re-offer later in the session.
|
|
233
|
+
|
|
234
|
+
If they choose A:
|
|
235
|
+
|
|
236
|
+
Say: "Running /${first} inline. Once the design doc is ready, I'll pick up
|
|
237
|
+
the review right where we left off."
|
|
238
|
+
|
|
239
|
+
${invokeBlock}
|
|
240
|
+
|
|
241
|
+
After /${first} completes, re-run the design doc check:
|
|
242
|
+
\`\`\`bash
|
|
243
|
+
setopt +o nomatch 2>/dev/null || true # zsh compat
|
|
244
|
+
SLUG=$(~/.claude/skills/opengstack/browse/bin/remote-slug 2>/dev/null || basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")
|
|
245
|
+
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null | tr '/' '-' || echo 'no-branch')
|
|
246
|
+
DESIGN=$(ls -t ~/.opengstack/projects/$SLUG/*-$BRANCH-design-*.md 2>/dev/null | head -1)
|
|
247
|
+
[ -z "$DESIGN" ] && DESIGN=$(ls -t ~/.opengstack/projects/$SLUG/*-design-*.md 2>/dev/null | head -1)
|
|
248
|
+
[ -n "$DESIGN" ] && echo "Design doc found: $DESIGN" || echo "No design doc found"
|
|
249
|
+
\`\`\`
|
|
250
|
+
|
|
251
|
+
If a design doc is now found, read it and continue the review.
|
|
252
|
+
If none was produced (user may have cancelled), proceed with standard review.`;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function generateCodexSecondOpinion(ctx: TemplateContext): string {
|
|
256
|
+
// Codex host: strip entirely — Codex should never invoke itself
|
|
257
|
+
if (ctx.host === 'codex') return '';
|
|
258
|
+
|
|
259
|
+
return `## Phase 3.5: Cross-Model Second Opinion (optional)
|
|
260
|
+
|
|
261
|
+
**Binary check first:**
|
|
262
|
+
|
|
263
|
+
\`\`\`bash
|
|
264
|
+
which codex 2>/dev/null && echo "CODEX_AVAILABLE" || echo "CODEX_NOT_AVAILABLE"
|
|
265
|
+
\`\`\`
|
|
266
|
+
|
|
267
|
+
Use AskUserQuestion (regardless of codex availability):
|
|
268
|
+
|
|
269
|
+
> Want a second opinion from an independent AI perspective? It will review your problem statement, key answers, premises, and any landscape findings from this session without having seen this conversation — it gets a structured summary. Usually takes 2-5 minutes.
|
|
270
|
+
> A) Yes, get a second opinion
|
|
271
|
+
> B) No, proceed to alternatives
|
|
272
|
+
|
|
273
|
+
If B: skip Phase 3.5 entirely. Remember that the second opinion did NOT run (affects design doc, founder signals, and Phase 4 below).
|
|
274
|
+
|
|
275
|
+
**If A: Run the Codex cold read.**
|
|
276
|
+
|
|
277
|
+
1. Assemble a structured context block from Phases 1-3:
|
|
278
|
+
- Mode (Startup or Builder)
|
|
279
|
+
- Problem statement (from Phase 1)
|
|
280
|
+
- Key answers from Phase 2A/2B (summarize each Q&A in 1-2 sentences, include verbatim user quotes)
|
|
281
|
+
- Landscape findings (from Phase 2.75, if search was run)
|
|
282
|
+
- Agreed premises (from Phase 3)
|
|
283
|
+
- Codebase context (project name, languages, recent activity)
|
|
284
|
+
|
|
285
|
+
2. **Write the assembled prompt to a temp file** (prevents shell injection from user-derived content):
|
|
286
|
+
|
|
287
|
+
\`\`\`bash
|
|
288
|
+
CODEX_PROMPT_FILE=$(mktemp /tmp/opengstack-codex-oh-XXXXXXXX.txt)
|
|
289
|
+
\`\`\`
|
|
290
|
+
|
|
291
|
+
Write the full prompt to this file. **Always start with the filesystem boundary:**
|
|
292
|
+
"${CODEX_BOUNDARY}"
|
|
293
|
+
Then add the context block and mode-appropriate instructions:
|
|
294
|
+
|
|
295
|
+
**Startup mode instructions:** "You are an independent technical advisor reading a transcript of a startup brainstorming session. [CONTEXT BLOCK HERE]. Your job: 1) What is the STRONGEST version of what this person is trying to build? Steelman it in 2-3 sentences. 2) What is the ONE thing from their answers that reveals the most about what they should actually build? Quote it and explain why. 3) Name ONE agreed premise you think is wrong, and what evidence would prove you right. 4) If you had 48 hours and one engineer to build a prototype, what would you build? Be specific — tech stack, features, what you'd skip. Be direct. Be terse. No preamble."
|
|
296
|
+
|
|
297
|
+
**Builder mode instructions:** "You are an independent technical advisor reading a transcript of a builder brainstorming session. [CONTEXT BLOCK HERE]. Your job: 1) What is the COOLEST version of this they haven't considered? 2) What's the ONE thing from their answers that reveals what excites them most? Quote it. 3) What existing open source project or tool gets them 50% of the way there — and what's the 50% they'd need to build? 4) If you had a weekend to build this, what would you build first? Be specific. Be direct. No preamble."
|
|
298
|
+
|
|
299
|
+
3. Run Codex:
|
|
300
|
+
|
|
301
|
+
\`\`\`bash
|
|
302
|
+
TMPERR_OH=$(mktemp /tmp/codex-oh-err-XXXXXXXX)
|
|
303
|
+
_REPO_ROOT=$(git rev-parse --show-toplevel) || { echo "ERROR: not in a git repo" >&2; exit 1; }
|
|
304
|
+
codex exec "$(cat "$CODEX_PROMPT_FILE")" -C "$_REPO_ROOT" -s read-only -c 'model_reasoning_effort="high"' --enable web_search_cached 2>"$TMPERR_OH"
|
|
305
|
+
\`\`\`
|
|
306
|
+
|
|
307
|
+
Use a 5-minute timeout (\`timeout: 300000\`). After the command completes, read stderr:
|
|
308
|
+
\`\`\`bash
|
|
309
|
+
cat "$TMPERR_OH"
|
|
310
|
+
rm -f "$TMPERR_OH" "$CODEX_PROMPT_FILE"
|
|
311
|
+
\`\`\`
|
|
312
|
+
|
|
313
|
+
**Error handling:** All errors are non-blocking — second opinion is a quality enhancement, not a prerequisite.
|
|
314
|
+
- **Auth failure:** If stderr contains "auth", "login", "unauthorized", or "API key": "Codex authentication failed. Run \\\`codex login\\\` to authenticate." Fall back to Claude subagent.
|
|
315
|
+
- **Timeout:** "Codex timed out after 5 minutes." Fall back to Claude subagent.
|
|
316
|
+
- **Empty response:** "Codex returned no response." Fall back to Claude subagent.
|
|
317
|
+
|
|
318
|
+
On any Codex error, fall back to the Claude subagent below.
|
|
319
|
+
|
|
320
|
+
**If CODEX_NOT_AVAILABLE (or Codex errored):**
|
|
321
|
+
|
|
322
|
+
Dispatch via the Agent tool. The subagent has fresh context — genuine independence.
|
|
323
|
+
|
|
324
|
+
Subagent prompt: same mode-appropriate prompt as above (Startup or Builder variant).
|
|
325
|
+
|
|
326
|
+
Present findings under a \`SECOND OPINION (Claude subagent):\` header.
|
|
327
|
+
|
|
328
|
+
If the subagent fails or times out: "Second opinion unavailable. Continuing to Phase 4."
|
|
329
|
+
|
|
330
|
+
4. **Presentation:**
|
|
331
|
+
|
|
332
|
+
If Codex ran:
|
|
333
|
+
\`\`\`
|
|
334
|
+
SECOND OPINION (Codex):
|
|
335
|
+
════════════════════════════════════════════════════════════
|
|
336
|
+
<full codex output, verbatim — do not truncate or summarize>
|
|
337
|
+
════════════════════════════════════════════════════════════
|
|
338
|
+
\`\`\`
|
|
339
|
+
|
|
340
|
+
If Claude subagent ran:
|
|
341
|
+
\`\`\`
|
|
342
|
+
SECOND OPINION (Claude subagent):
|
|
343
|
+
════════════════════════════════════════════════════════════
|
|
344
|
+
<full subagent output, verbatim — do not truncate or summarize>
|
|
345
|
+
════════════════════════════════════════════════════════════
|
|
346
|
+
\`\`\`
|
|
347
|
+
|
|
348
|
+
5. **Cross-model synthesis:** After presenting the second opinion output, provide 3-5 bullet synthesis:
|
|
349
|
+
- Where Claude agrees with the second opinion
|
|
350
|
+
- Where Claude disagrees and why
|
|
351
|
+
- Whether the challenged premise changes Claude's recommendation
|
|
352
|
+
|
|
353
|
+
6. **Premise revision check:** If Codex challenged an agreed premise, use AskUserQuestion:
|
|
354
|
+
|
|
355
|
+
> Codex challenged premise #{N}: "{premise text}". Their argument: "{reasoning}".
|
|
356
|
+
> A) Revise this premise based on Codex's input
|
|
357
|
+
> B) Keep the original premise — proceed to alternatives
|
|
358
|
+
|
|
359
|
+
If A: revise the premise and note the revision. If B: proceed (and note that the user defended this premise with reasoning — this is a founder signal if they articulate WHY they disagree, not just dismiss).`;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export function generateAdversarialStep(ctx: TemplateContext): string {
|
|
363
|
+
// Codex host: strip entirely — Codex should never invoke itself
|
|
364
|
+
if (ctx.host === 'codex') return '';
|
|
365
|
+
|
|
366
|
+
const isShip = ctx.skillName === 'ship';
|
|
367
|
+
const stepNum = isShip ? '3.8' : '5.7';
|
|
368
|
+
|
|
369
|
+
return `## Step ${stepNum}: Adversarial review (auto-scaled)
|
|
370
|
+
|
|
371
|
+
Adversarial review thoroughness scales automatically based on diff size. No configuration needed.
|
|
372
|
+
|
|
373
|
+
**Detect diff size and tool availability:**
|
|
374
|
+
|
|
375
|
+
\`\`\`bash
|
|
376
|
+
DIFF_INS=$(git diff origin/<base> --stat | tail -1 | grep -oE '[0-9]+ insertion' | grep -oE '[0-9]+' || echo "0")
|
|
377
|
+
DIFF_DEL=$(git diff origin/<base> --stat | tail -1 | grep -oE '[0-9]+ deletion' | grep -oE '[0-9]+' || echo "0")
|
|
378
|
+
DIFF_TOTAL=$((DIFF_INS + DIFF_DEL))
|
|
379
|
+
which codex 2>/dev/null && echo "CODEX_AVAILABLE" || echo "CODEX_NOT_AVAILABLE"
|
|
380
|
+
# Respect old opt-out
|
|
381
|
+
OLD_CFG=$(~/.claude/skills/opengstack/bin/opengstack-config get codex_reviews 2>/dev/null || true)
|
|
382
|
+
echo "DIFF_SIZE: $DIFF_TOTAL"
|
|
383
|
+
echo "OLD_CFG: \${OLD_CFG:-not_set}"
|
|
384
|
+
\`\`\`
|
|
385
|
+
|
|
386
|
+
If \`OLD_CFG\` is \`disabled\`: skip this step silently. Continue to the next step.
|
|
387
|
+
|
|
388
|
+
**User override:** If the user explicitly requested a specific tier (e.g., "run all passes", "paranoid review", "full adversarial", "do all 4 passes", "thorough review"), honor that request regardless of diff size. Jump to the matching tier section.
|
|
389
|
+
|
|
390
|
+
**Auto-select tier based on diff size:**
|
|
391
|
+
- **Small (< 50 lines changed):** Skip adversarial review entirely. Print: "Small diff ($DIFF_TOTAL lines) — adversarial review skipped." Continue to the next step.
|
|
392
|
+
- **Medium (50–199 lines changed):** Run Codex adversarial challenge (or Claude adversarial subagent if Codex unavailable). Jump to the "Medium tier" section.
|
|
393
|
+
- **Large (200+ lines changed):** Run all remaining passes — Codex structured review + Claude adversarial subagent + Codex adversarial. Jump to the "Large tier" section.
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
### Medium tier (50–199 lines)
|
|
398
|
+
|
|
399
|
+
Claude's structured review already ran. Now add a **cross-model adversarial challenge**.
|
|
400
|
+
|
|
401
|
+
**If Codex is available:** run the Codex adversarial challenge. **If Codex is NOT available:** fall back to the Claude adversarial subagent instead.
|
|
402
|
+
|
|
403
|
+
**Codex adversarial:**
|
|
404
|
+
|
|
405
|
+
\`\`\`bash
|
|
406
|
+
TMPERR_ADV=$(mktemp /tmp/codex-adv-XXXXXXXX)
|
|
407
|
+
_REPO_ROOT=$(git rev-parse --show-toplevel) || { echo "ERROR: not in a git repo" >&2; exit 1; }
|
|
408
|
+
codex exec "${CODEX_BOUNDARY}Review the changes on this branch against the base branch. Run git diff origin/<base> to see the diff. Your job is to find ways this code will fail in production. Think like an attacker and a chaos engineer. Find edge cases, race conditions, security holes, resource leaks, failure modes, and silent data corruption paths. Be adversarial. Be thorough. No compliments — just the problems." -C "$_REPO_ROOT" -s read-only -c 'model_reasoning_effort="high"' --enable web_search_cached 2>"$TMPERR_ADV"
|
|
409
|
+
\`\`\`
|
|
410
|
+
|
|
411
|
+
Set the Bash tool's \`timeout\` parameter to \`300000\` (5 minutes). Do NOT use the \`timeout\` shell command — it doesn't exist on macOS. After the command completes, read stderr:
|
|
412
|
+
\`\`\`bash
|
|
413
|
+
cat "$TMPERR_ADV"
|
|
414
|
+
\`\`\`
|
|
415
|
+
|
|
416
|
+
Present the full output verbatim. This is informational — it never blocks shipping.
|
|
417
|
+
|
|
418
|
+
**Error handling:** All errors are non-blocking — adversarial review is a quality enhancement, not a prerequisite.
|
|
419
|
+
- **Auth failure:** If stderr contains "auth", "login", "unauthorized", or "API key": "Codex authentication failed. Run \\\`codex login\\\` to authenticate."
|
|
420
|
+
- **Timeout:** "Codex timed out after 5 minutes."
|
|
421
|
+
- **Empty response:** "Codex returned no response. Stderr: <paste relevant error>."
|
|
422
|
+
|
|
423
|
+
On any Codex error, fall back to the Claude adversarial subagent automatically.
|
|
424
|
+
|
|
425
|
+
**Claude adversarial subagent** (fallback when Codex unavailable or errored):
|
|
426
|
+
|
|
427
|
+
Dispatch via the Agent tool. The subagent has fresh context — no checklist bias from the structured review. This genuine independence catches things the primary reviewer is blind to.
|
|
428
|
+
|
|
429
|
+
Subagent prompt:
|
|
430
|
+
"Read the diff for this branch with \`git diff origin/<base>\`. Think like an attacker and a chaos engineer. Your job is to find ways this code will fail in production. Look for: edge cases, race conditions, security holes, resource leaks, failure modes, silent data corruption, logic errors that produce wrong results silently, error handling that swallows failures, and trust boundary violations. Be adversarial. Be thorough. No compliments — just the problems. For each finding, classify as FIXABLE (you know how to fix it) or INVESTIGATE (needs human judgment)."
|
|
431
|
+
|
|
432
|
+
Present findings under an \`ADVERSARIAL REVIEW (Claude subagent):\` header. **FIXABLE findings** flow into the same Fix-First pipeline as the structured review. **INVESTIGATE findings** are presented as informational.
|
|
433
|
+
|
|
434
|
+
If the subagent fails or times out: "Claude adversarial subagent unavailable. Continuing without adversarial review."
|
|
435
|
+
|
|
436
|
+
**Persist the review result:**
|
|
437
|
+
\`\`\`bash
|
|
438
|
+
~/.claude/skills/opengstack/bin/opengstack-review-log '{"skill":"adversarial-review","timestamp":"'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'","status":"STATUS","source":"SOURCE","tier":"medium","commit":"'"$(git rev-parse --short HEAD)"'"}'
|
|
439
|
+
\`\`\`
|
|
440
|
+
Substitute STATUS: "clean" if no findings, "issues_found" if findings exist. SOURCE: "codex" if Codex ran, "claude" if subagent ran. If both failed, do NOT persist.
|
|
441
|
+
|
|
442
|
+
**Cleanup:** Run \`rm -f "$TMPERR_ADV"\` after processing (if Codex was used).
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
### Large tier (200+ lines)
|
|
447
|
+
|
|
448
|
+
Claude's structured review already ran. Now run **all three remaining passes** for maximum coverage:
|
|
449
|
+
|
|
450
|
+
**1. Codex structured review (if available):**
|
|
451
|
+
\`\`\`bash
|
|
452
|
+
TMPERR=$(mktemp /tmp/codex-review-XXXXXXXX)
|
|
453
|
+
_REPO_ROOT=$(git rev-parse --show-toplevel) || { echo "ERROR: not in a git repo" >&2; exit 1; }
|
|
454
|
+
cd "$_REPO_ROOT"
|
|
455
|
+
codex review "${CODEX_BOUNDARY}Review the diff against the base branch." --base <base> -c 'model_reasoning_effort="high"' --enable web_search_cached 2>"$TMPERR"
|
|
456
|
+
\`\`\`
|
|
457
|
+
|
|
458
|
+
Set the Bash tool's \`timeout\` parameter to \`300000\` (5 minutes). Do NOT use the \`timeout\` shell command — it doesn't exist on macOS. Present output under \`CODEX SAYS (code review):\` header.
|
|
459
|
+
Check for \`[P1]\` markers: found → \`GATE: FAIL\`, not found → \`GATE: PASS\`.
|
|
460
|
+
|
|
461
|
+
If GATE is FAIL, use AskUserQuestion:
|
|
462
|
+
\`\`\`
|
|
463
|
+
Codex found N critical issues in the diff.
|
|
464
|
+
|
|
465
|
+
A) Investigate and fix now (recommended)
|
|
466
|
+
B) Continue — review will still complete
|
|
467
|
+
\`\`\`
|
|
468
|
+
|
|
469
|
+
If A: address the findings${isShip ? '. After fixing, re-run tests (Step 3) since code has changed' : ''}. Re-run \`codex review\` to verify.
|
|
470
|
+
|
|
471
|
+
Read stderr for errors (same error handling as medium tier).
|
|
472
|
+
|
|
473
|
+
After stderr: \`rm -f "$TMPERR"\`
|
|
474
|
+
|
|
475
|
+
**2. Claude adversarial subagent:** Dispatch a subagent with the adversarial prompt (same prompt as medium tier). This always runs regardless of Codex availability.
|
|
476
|
+
|
|
477
|
+
**3. Codex adversarial challenge (if available):** Run \`codex exec\` with the adversarial prompt (same as medium tier).
|
|
478
|
+
|
|
479
|
+
If Codex is not available for steps 1 and 3, note to the user: "Codex CLI not found — large-diff review ran Claude structured + Claude adversarial (2 of 4 passes). Install Codex for full 4-pass coverage: \`npm install -g @openai/codex\`"
|
|
480
|
+
|
|
481
|
+
**Persist the review result AFTER all passes complete** (not after each sub-step):
|
|
482
|
+
\`\`\`bash
|
|
483
|
+
~/.claude/skills/opengstack/bin/opengstack-review-log '{"skill":"adversarial-review","timestamp":"'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'","status":"STATUS","source":"SOURCE","tier":"large","gate":"GATE","commit":"'"$(git rev-parse --short HEAD)"'"}'
|
|
484
|
+
\`\`\`
|
|
485
|
+
Substitute: STATUS = "clean" if no findings across ALL passes, "issues_found" if any pass found issues. SOURCE = "both" if Codex ran, "claude" if only Claude subagent ran. GATE = the Codex structured review gate result ("pass"/"fail"), or "informational" if Codex was unavailable. If all passes failed, do NOT persist.
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
### Cross-model synthesis (medium and large tiers)
|
|
490
|
+
|
|
491
|
+
After all passes complete, synthesize findings across all sources:
|
|
492
|
+
|
|
493
|
+
\`\`\`
|
|
494
|
+
ADVERSARIAL REVIEW SYNTHESIS (auto: TIER, N lines):
|
|
495
|
+
════════════════════════════════════════════════════════════
|
|
496
|
+
High confidence (found by multiple sources): [findings agreed on by >1 pass]
|
|
497
|
+
Unique to Claude structured review: [from earlier step]
|
|
498
|
+
Unique to Claude adversarial: [from subagent, if ran]
|
|
499
|
+
Unique to Codex: [from codex adversarial or code review, if ran]
|
|
500
|
+
Models used: Claude structured ✓ Claude adversarial ✓/✗ Codex ✓/✗
|
|
501
|
+
════════════════════════════════════════════════════════════
|
|
502
|
+
\`\`\`
|
|
503
|
+
|
|
504
|
+
High-confidence findings (agreed on by multiple sources) should be prioritized for fixes.
|
|
505
|
+
|
|
506
|
+
---`;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
export function generateCodexPlanReview(ctx: TemplateContext): string {
|
|
510
|
+
// Codex host: strip entirely — Codex should never invoke itself
|
|
511
|
+
if (ctx.host === 'codex') return '';
|
|
512
|
+
|
|
513
|
+
return `## Outside Voice — Independent Plan Challenge (optional, recommended)
|
|
514
|
+
|
|
515
|
+
After all review sections are complete, offer an independent second opinion from a
|
|
516
|
+
different AI system. Two models agreeing on a plan is stronger signal than one model's
|
|
517
|
+
thorough review.
|
|
518
|
+
|
|
519
|
+
**Check tool availability:**
|
|
520
|
+
|
|
521
|
+
\`\`\`bash
|
|
522
|
+
which codex 2>/dev/null && echo "CODEX_AVAILABLE" || echo "CODEX_NOT_AVAILABLE"
|
|
523
|
+
\`\`\`
|
|
524
|
+
|
|
525
|
+
Use AskUserQuestion:
|
|
526
|
+
|
|
527
|
+
> "All review sections are complete. Want an outside voice? A different AI system can
|
|
528
|
+
> give a brutally honest, independent challenge of this plan — logical gaps, feasibility
|
|
529
|
+
> risks, and blind spots that are hard to catch from inside the review. Takes about 2
|
|
530
|
+
> minutes."
|
|
531
|
+
>
|
|
532
|
+
> RECOMMENDATION: Choose A — an independent second opinion catches structural blind
|
|
533
|
+
> spots. Two different AI models agreeing on a plan is stronger signal than one model's
|
|
534
|
+
> thorough review. Completeness: A=9/10, B=7/10.
|
|
535
|
+
|
|
536
|
+
Options:
|
|
537
|
+
- A) Get the outside voice (recommended)
|
|
538
|
+
- B) Skip — proceed to outputs
|
|
539
|
+
|
|
540
|
+
**If B:** Print "Skipping outside voice." and continue to the next section.
|
|
541
|
+
|
|
542
|
+
**If A:** Construct the plan review prompt. Read the plan file being reviewed (the file
|
|
543
|
+
the user pointed this review at, or the branch diff scope). If a CEO plan document
|
|
544
|
+
was written in Step 0D-POST, read that too — it contains the scope decisions and vision.
|
|
545
|
+
|
|
546
|
+
Construct this prompt (substitute the actual plan content — if plan content exceeds 30KB,
|
|
547
|
+
truncate to the first 30KB and note "Plan truncated for size"). **Always start with the
|
|
548
|
+
filesystem boundary instruction:**
|
|
549
|
+
|
|
550
|
+
"${CODEX_BOUNDARY}You are a brutally honest technical reviewer examining a development plan that has
|
|
551
|
+
already been through a multi-section review. Your job is NOT to repeat that review.
|
|
552
|
+
Instead, find what it missed. Look for: logical gaps and unstated assumptions that
|
|
553
|
+
survived the review scrutiny, overcomplexity (is there a fundamentally simpler
|
|
554
|
+
approach the review was too deep in the weeds to see?), feasibility risks the review
|
|
555
|
+
took for granted, missing dependencies or sequencing issues, and strategic
|
|
556
|
+
miscalibration (is this the right thing to build at all?). Be direct. Be terse. No
|
|
557
|
+
compliments. Just the problems.
|
|
558
|
+
|
|
559
|
+
THE PLAN:
|
|
560
|
+
<plan content>"
|
|
561
|
+
|
|
562
|
+
**If CODEX_AVAILABLE:**
|
|
563
|
+
|
|
564
|
+
\`\`\`bash
|
|
565
|
+
TMPERR_PV=$(mktemp /tmp/codex-planreview-XXXXXXXX)
|
|
566
|
+
_REPO_ROOT=$(git rev-parse --show-toplevel) || { echo "ERROR: not in a git repo" >&2; exit 1; }
|
|
567
|
+
codex exec "<prompt>" -C "$_REPO_ROOT" -s read-only -c 'model_reasoning_effort="high"' --enable web_search_cached 2>"$TMPERR_PV"
|
|
568
|
+
\`\`\`
|
|
569
|
+
|
|
570
|
+
Use a 5-minute timeout (\`timeout: 300000\`). After the command completes, read stderr:
|
|
571
|
+
\`\`\`bash
|
|
572
|
+
cat "$TMPERR_PV"
|
|
573
|
+
\`\`\`
|
|
574
|
+
|
|
575
|
+
Present the full output verbatim:
|
|
576
|
+
|
|
577
|
+
\`\`\`
|
|
578
|
+
CODEX SAYS (plan review — outside voice):
|
|
579
|
+
════════════════════════════════════════════════════════════
|
|
580
|
+
<full codex output, verbatim — do not truncate or summarize>
|
|
581
|
+
════════════════════════════════════════════════════════════
|
|
582
|
+
\`\`\`
|
|
583
|
+
|
|
584
|
+
**Error handling:** All errors are non-blocking — the outside voice is informational.
|
|
585
|
+
- Auth failure (stderr contains "auth", "login", "unauthorized"): "Codex auth failed. Run \\\`codex login\\\` to authenticate."
|
|
586
|
+
- Timeout: "Codex timed out after 5 minutes."
|
|
587
|
+
- Empty response: "Codex returned no response."
|
|
588
|
+
|
|
589
|
+
On any Codex error, fall back to the Claude adversarial subagent.
|
|
590
|
+
|
|
591
|
+
**If CODEX_NOT_AVAILABLE (or Codex errored):**
|
|
592
|
+
|
|
593
|
+
Dispatch via the Agent tool. The subagent has fresh context — genuine independence.
|
|
594
|
+
|
|
595
|
+
Subagent prompt: same plan review prompt as above.
|
|
596
|
+
|
|
597
|
+
Present findings under an \`OUTSIDE VOICE (Claude subagent):\` header.
|
|
598
|
+
|
|
599
|
+
If the subagent fails or times out: "Outside voice unavailable. Continuing to outputs."
|
|
600
|
+
|
|
601
|
+
**Cross-model tension:**
|
|
602
|
+
|
|
603
|
+
After presenting the outside voice findings, note any points where the outside voice
|
|
604
|
+
disagrees with the review findings from earlier sections. Flag these as:
|
|
605
|
+
|
|
606
|
+
\`\`\`
|
|
607
|
+
CROSS-MODEL TENSION:
|
|
608
|
+
[Topic]: Review said X. Outside voice says Y. [Present both perspectives neutrally.
|
|
609
|
+
State what context you might be missing that would change the answer.]
|
|
610
|
+
\`\`\`
|
|
611
|
+
|
|
612
|
+
**User Sovereignty:** Do NOT auto-incorporate outside voice recommendations into the plan.
|
|
613
|
+
Present each tension point to the user. The user decides. Cross-model agreement is a
|
|
614
|
+
strong signal — present it as such — but it is NOT permission to act. You may state
|
|
615
|
+
which argument you find more compelling, but you MUST NOT apply the change without
|
|
616
|
+
explicit user approval.
|
|
617
|
+
|
|
618
|
+
For each substantive tension point, use AskUserQuestion:
|
|
619
|
+
|
|
620
|
+
> "Cross-model disagreement on [topic]. The review found [X] but the outside voice
|
|
621
|
+
> argues [Y]. [One sentence on what context you might be missing.]"
|
|
622
|
+
|
|
623
|
+
Options:
|
|
624
|
+
- A) Accept the outside voice's recommendation (I'll apply this change)
|
|
625
|
+
- B) Keep the current approach (reject the outside voice)
|
|
626
|
+
- C) Investigate further before deciding
|
|
627
|
+
- D) Add to TODOS.md for later
|
|
628
|
+
|
|
629
|
+
Wait for the user's response. Do NOT default to accepting because you agree with the
|
|
630
|
+
outside voice. If the user chooses B, the current approach stands — do not re-argue.
|
|
631
|
+
|
|
632
|
+
If no tension points exist, note: "No cross-model tension — both reviewers agree."
|
|
633
|
+
|
|
634
|
+
**Persist the result:**
|
|
635
|
+
\`\`\`bash
|
|
636
|
+
~/.claude/skills/opengstack/bin/opengstack-review-log '{"skill":"codex-plan-review","timestamp":"'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'","status":"STATUS","source":"SOURCE","commit":"'"$(git rev-parse --short HEAD)"'"}'
|
|
637
|
+
\`\`\`
|
|
638
|
+
|
|
639
|
+
Substitute: STATUS = "clean" if no findings, "issues_found" if findings exist.
|
|
640
|
+
SOURCE = "codex" if Codex ran, "claude" if subagent ran.
|
|
641
|
+
|
|
642
|
+
**Cleanup:** Run \`rm -f "$TMPERR_PV"\` after processing (if Codex was used).
|
|
643
|
+
|
|
644
|
+
---`;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// ─── Plan File Discovery (shared helper) ──────────────────────────────
|
|
648
|
+
|
|
649
|
+
function generatePlanFileDiscovery(): string {
|
|
650
|
+
return `### Plan File Discovery
|
|
651
|
+
|
|
652
|
+
1. **Conversation context (primary):** Check if there is an active plan file in this conversation. The host agent's system messages include plan file paths when in plan mode. If found, use it directly — this is the most reliable signal.
|
|
653
|
+
|
|
654
|
+
2. **Content-based search (fallback):** If no plan file is referenced in conversation context, search by content:
|
|
655
|
+
|
|
656
|
+
\`\`\`bash
|
|
657
|
+
setopt +o nomatch 2>/dev/null || true # zsh compat
|
|
658
|
+
BRANCH=$(git branch --show-current 2>/dev/null | tr '/' '-')
|
|
659
|
+
REPO=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)")
|
|
660
|
+
# Compute project slug for ~/.opengstack/projects/ lookup
|
|
661
|
+
_PLAN_SLUG=$(git remote get-url origin 2>/dev/null | sed 's|.*[:/]\\([^/]*/[^/]*\\)\\.git$|\\1|;s|.*[:/]\\([^/]*/[^/]*\\)$|\\1|' | tr '/' '-' | tr -cd 'a-zA-Z0-9._-') || true
|
|
662
|
+
_PLAN_SLUG="\${_PLAN_SLUG:-$(basename "$PWD" | tr -cd 'a-zA-Z0-9._-')}"
|
|
663
|
+
# Search common plan file locations (project designs first, then personal/local)
|
|
664
|
+
for PLAN_DIR in "$HOME/.OpenGStack/projects/$_PLAN_SLUG" "$HOME/.claude/plans" "$HOME/.codex/plans" ".OpenGStack/plans"; do
|
|
665
|
+
[ -d "$PLAN_DIR" ] || continue
|
|
666
|
+
PLAN=$(ls -t "$PLAN_DIR"/*.md 2>/dev/null | xargs grep -l "$BRANCH" 2>/dev/null | head -1)
|
|
667
|
+
[ -z "$PLAN" ] && PLAN=$(ls -t "$PLAN_DIR"/*.md 2>/dev/null | xargs grep -l "$REPO" 2>/dev/null | head -1)
|
|
668
|
+
[ -z "$PLAN" ] && PLAN=$(find "$PLAN_DIR" -name '*.md' -mmin -1440 -maxdepth 1 2>/dev/null | xargs ls -t 2>/dev/null | head -1)
|
|
669
|
+
[ -n "$PLAN" ] && break
|
|
670
|
+
done
|
|
671
|
+
[ -n "$PLAN" ] && echo "PLAN_FILE: $PLAN" || echo "NO_PLAN_FILE"
|
|
672
|
+
\`\`\`
|
|
673
|
+
|
|
674
|
+
3. **Validation:** If a plan file was found via content-based search (not conversation context), read the first 20 lines and verify it is relevant to the current branch's work. If it appears to be from a different project or feature, treat as "no plan file found."
|
|
675
|
+
|
|
676
|
+
**Error handling:**
|
|
677
|
+
- No plan file found → skip with "No plan file detected — skipping."
|
|
678
|
+
- Plan file found but unreadable (permissions, encoding) → skip with "Plan file found but unreadable — skipping."`;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// ─── Plan Completion Audit ────────────────────────────────────────────
|
|
682
|
+
|
|
683
|
+
type PlanCompletionMode = 'ship' | 'review';
|
|
684
|
+
|
|
685
|
+
function generatePlanCompletionAuditInner(mode: PlanCompletionMode): string {
|
|
686
|
+
const sections: string[] = [];
|
|
687
|
+
|
|
688
|
+
// ── Plan file discovery (shared) ──
|
|
689
|
+
sections.push(generatePlanFileDiscovery());
|
|
690
|
+
|
|
691
|
+
// ── Item extraction ──
|
|
692
|
+
sections.push(`
|
|
693
|
+
### Actionable Item Extraction
|
|
694
|
+
|
|
695
|
+
Read the plan file. Extract every actionable item — anything that describes work to be done. Look for:
|
|
696
|
+
|
|
697
|
+
- **Checkbox items:** \`- [ ] ...\` or \`- [x] ...\`
|
|
698
|
+
- **Numbered steps** under implementation headings: "1. Create ...", "2. Add ...", "3. Modify ..."
|
|
699
|
+
- **Imperative statements:** "Add X to Y", "Create a Z service", "Modify the W controller"
|
|
700
|
+
- **File-level specifications:** "New file: path/to/file.ts", "Modify path/to/existing.rb"
|
|
701
|
+
- **Test requirements:** "Test that X", "Add test for Y", "Verify Z"
|
|
702
|
+
- **Data model changes:** "Add column X to table Y", "Create migration for Z"
|
|
703
|
+
|
|
704
|
+
**Ignore:**
|
|
705
|
+
- Context/Background sections (\`## Context\`, \`## Background\`, \`## Problem\`)
|
|
706
|
+
- Questions and open items (marked with ?, "TBD", "TODO: decide")
|
|
707
|
+
- Review report sections (\`## opengstack REVIEW REPORT\`)
|
|
708
|
+
- Explicitly deferred items ("Future:", "Out of scope:", "NOT in scope:", "P2:", "P3:", "P4:")
|
|
709
|
+
- CEO Review Decisions sections (these record choices, not work items)
|
|
710
|
+
|
|
711
|
+
**Cap:** Extract at most 50 items. If the plan has more, note: "Showing top 50 of N plan items — full list in plan file."
|
|
712
|
+
|
|
713
|
+
**No items found:** If the plan contains no extractable actionable items, skip with: "Plan file contains no actionable items — skipping completion audit."
|
|
714
|
+
|
|
715
|
+
For each item, note:
|
|
716
|
+
- The item text (verbatim or concise summary)
|
|
717
|
+
- Its category: CODE | TEST | MIGRATION | CONFIG | DOCS`);
|
|
718
|
+
|
|
719
|
+
// ── Cross-reference against diff ──
|
|
720
|
+
sections.push(`
|
|
721
|
+
### Cross-Reference Against Diff
|
|
722
|
+
|
|
723
|
+
Run \`git diff origin/<base>...HEAD\` and \`git log origin/<base>..HEAD --oneline\` to understand what was implemented.
|
|
724
|
+
|
|
725
|
+
For each extracted plan item, check the diff and classify:
|
|
726
|
+
|
|
727
|
+
- **DONE** — Clear evidence in the diff that this item was implemented. Cite the specific file(s) changed.
|
|
728
|
+
- **PARTIAL** — Some work toward this item exists in the diff but it's incomplete (e.g., model created but controller missing, function exists but edge cases not handled).
|
|
729
|
+
- **NOT DONE** — No evidence in the diff that this item was addressed.
|
|
730
|
+
- **CHANGED** — The item was implemented using a different approach than the plan described, but the same goal is achieved. Note the difference.
|
|
731
|
+
|
|
732
|
+
**Be conservative with DONE** — require clear evidence in the diff. A file being touched is not enough; the specific functionality described must be present.
|
|
733
|
+
**Be generous with CHANGED** — if the goal is met by different means, that counts as addressed.`);
|
|
734
|
+
|
|
735
|
+
// ── Output format ──
|
|
736
|
+
sections.push(`
|
|
737
|
+
### Output Format
|
|
738
|
+
|
|
739
|
+
\`\`\`
|
|
740
|
+
PLAN COMPLETION AUDIT
|
|
741
|
+
═══════════════════════════════
|
|
742
|
+
Plan: {plan file path}
|
|
743
|
+
|
|
744
|
+
## Implementation Items
|
|
745
|
+
[DONE] Create UserService — src/services/user_service.rb (+142 lines)
|
|
746
|
+
[PARTIAL] Add validation — model validates but missing controller checks
|
|
747
|
+
[NOT DONE] Add caching layer — no cache-related changes in diff
|
|
748
|
+
[CHANGED] "Redis queue" → implemented with Sidekiq instead
|
|
749
|
+
|
|
750
|
+
## Test Items
|
|
751
|
+
[DONE] Unit tests for UserService — test/services/user_service_test.rb
|
|
752
|
+
[NOT DONE] E2E test for signup flow
|
|
753
|
+
|
|
754
|
+
## Migration Items
|
|
755
|
+
[DONE] Create users table — db/migrate/20240315_create_users.rb
|
|
756
|
+
|
|
757
|
+
─────────────────────────────────
|
|
758
|
+
COMPLETION: 4/7 DONE, 1 PARTIAL, 1 NOT DONE, 1 CHANGED
|
|
759
|
+
─────────────────────────────────
|
|
760
|
+
\`\`\``);
|
|
761
|
+
|
|
762
|
+
// ── Gate logic (mode-specific) ──
|
|
763
|
+
if (mode === 'ship') {
|
|
764
|
+
sections.push(`
|
|
765
|
+
### Gate Logic
|
|
766
|
+
|
|
767
|
+
After producing the completion checklist:
|
|
768
|
+
|
|
769
|
+
- **All DONE or CHANGED:** Pass. "Plan completion: PASS — all items addressed." Continue.
|
|
770
|
+
- **Only PARTIAL items (no NOT DONE):** Continue with a note in the PR body. Not blocking.
|
|
771
|
+
- **Any NOT DONE items:** Use AskUserQuestion:
|
|
772
|
+
- Show the completion checklist above
|
|
773
|
+
- "{N} items from the plan are NOT DONE. These were part of the original plan but are missing from the implementation."
|
|
774
|
+
- RECOMMENDATION: depends on item count and severity. If 1-2 minor items (docs, config), recommend B. If core functionality is missing, recommend A.
|
|
775
|
+
- Options:
|
|
776
|
+
A) Stop — implement the missing items before shipping
|
|
777
|
+
B) Ship anyway — defer these to a follow-up (will create P1 TODOs in Step 5.5)
|
|
778
|
+
C) These items were intentionally dropped — remove from scope
|
|
779
|
+
- If A: STOP. List the missing items for the user to implement.
|
|
780
|
+
- If B: Continue. For each NOT DONE item, create a P1 TODO in Step 5.5 with "Deferred from plan: {plan file path}".
|
|
781
|
+
- If C: Continue. Note in PR body: "Plan items intentionally dropped: {list}."
|
|
782
|
+
|
|
783
|
+
**No plan file found:** Skip entirely. "No plan file detected — skipping plan completion audit."
|
|
784
|
+
|
|
785
|
+
**Include in PR body (Step 8):** Add a \`## Plan Completion\` section with the checklist summary.`);
|
|
786
|
+
} else {
|
|
787
|
+
// review mode
|
|
788
|
+
sections.push(`
|
|
789
|
+
### Integration with Scope Drift Detection
|
|
790
|
+
|
|
791
|
+
The plan completion results augment the existing Scope Drift Detection. If a plan file is found:
|
|
792
|
+
|
|
793
|
+
- **NOT DONE items** become additional evidence for **MISSING REQUIREMENTS** in the scope drift report.
|
|
794
|
+
- **Items in the diff that don't match any plan item** become evidence for **SCOPE CREEP** detection.
|
|
795
|
+
|
|
796
|
+
This is **INFORMATIONAL** — does not block the review (consistent with existing scope drift behavior).
|
|
797
|
+
|
|
798
|
+
Update the scope drift output to include plan file context:
|
|
799
|
+
|
|
800
|
+
\`\`\`
|
|
801
|
+
Scope Check: [CLEAN / DRIFT DETECTED / REQUIREMENTS MISSING]
|
|
802
|
+
Intent: <from plan file — 1-line summary>
|
|
803
|
+
Plan: <plan file path>
|
|
804
|
+
Delivered: <1-line summary of what the diff actually does>
|
|
805
|
+
Plan items: N DONE, M PARTIAL, K NOT DONE
|
|
806
|
+
[If NOT DONE: list each missing item]
|
|
807
|
+
[If scope creep: list each out-of-scope change not in the plan]
|
|
808
|
+
\`\`\`
|
|
809
|
+
|
|
810
|
+
**No plan file found:** Fall back to existing scope drift behavior (check TODOS.md and PR description only).`);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
return sections.join('\n');
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
export function generatePlanCompletionAuditShip(_ctx: TemplateContext): string {
|
|
817
|
+
return generatePlanCompletionAuditInner('ship');
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
export function generatePlanCompletionAuditReview(_ctx: TemplateContext): string {
|
|
821
|
+
return generatePlanCompletionAuditInner('review');
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
// ─── Plan Verification Execution ──────────────────────────────────────
|
|
825
|
+
|
|
826
|
+
export function generatePlanVerificationExec(_ctx: TemplateContext): string {
|
|
827
|
+
return `## Step 3.47: Plan Verification
|
|
828
|
+
|
|
829
|
+
Automatically verify the plan's testing/verification steps using the \`/qa-only\` skill.
|
|
830
|
+
|
|
831
|
+
### 1. Check for verification section
|
|
832
|
+
|
|
833
|
+
Using the plan file already discovered in Step 3.45, look for a verification section. Match any of these headings: \`## Verification\`, \`## Test plan\`, \`## Testing\`, \`## How to test\`, \`## Manual testing\`, or any section with verification-flavored items (URLs to visit, things to check visually, interactions to test).
|
|
834
|
+
|
|
835
|
+
**If no verification section found:** Skip with "No verification steps found in plan — skipping auto-verification."
|
|
836
|
+
**If no plan file was found in Step 3.45:** Skip (already handled).
|
|
837
|
+
|
|
838
|
+
### 2. Check for running dev server
|
|
839
|
+
|
|
840
|
+
Before invoking browse-based verification, check if a dev server is reachable:
|
|
841
|
+
|
|
842
|
+
\`\`\`bash
|
|
843
|
+
curl -s -o /dev/null -w '%{http_code}' http://localhost:3000 2>/dev/null || \\
|
|
844
|
+
curl -s -o /dev/null -w '%{http_code}' http://localhost:8080 2>/dev/null || \\
|
|
845
|
+
curl -s -o /dev/null -w '%{http_code}' http://localhost:5173 2>/dev/null || \\
|
|
846
|
+
curl -s -o /dev/null -w '%{http_code}' http://localhost:4000 2>/dev/null || echo "NO_SERVER"
|
|
847
|
+
\`\`\`
|
|
848
|
+
|
|
849
|
+
**If NO_SERVER:** Skip with "No dev server detected — skipping plan verification. Run /qa separately after deploying."
|
|
850
|
+
|
|
851
|
+
### 3. Invoke /qa-only inline
|
|
852
|
+
|
|
853
|
+
Read the \`/qa-only\` skill from disk:
|
|
854
|
+
|
|
855
|
+
\`\`\`bash
|
|
856
|
+
cat \${CLAUDE_SKILL_DIR}/../qa-only/SKILL.md
|
|
857
|
+
\`\`\`
|
|
858
|
+
|
|
859
|
+
**If unreadable:** Skip with "Could not load /qa-only — skipping plan verification."
|
|
860
|
+
|
|
861
|
+
Follow the /qa-only workflow with these modifications:
|
|
862
|
+
- **Skip the preamble** (already handled by /ship)
|
|
863
|
+
- **Use the plan's verification section as the primary test input** — treat each verification item as a test case
|
|
864
|
+
- **Use the detected dev server URL** as the base URL
|
|
865
|
+
- **Skip the fix loop** — this is report-only verification during /ship
|
|
866
|
+
- **Cap at the verification items from the plan** — do not expand into general site QA
|
|
867
|
+
|
|
868
|
+
### 4. Gate logic
|
|
869
|
+
|
|
870
|
+
- **All verification items PASS:** Continue silently. "Plan verification: PASS."
|
|
871
|
+
- **Any FAIL:** Use AskUserQuestion:
|
|
872
|
+
- Show the failures with screenshot evidence
|
|
873
|
+
- RECOMMENDATION: Choose A if failures indicate broken functionality. Choose B if cosmetic only.
|
|
874
|
+
- Options:
|
|
875
|
+
A) Fix the failures before shipping (recommended for functional issues)
|
|
876
|
+
B) Ship anyway — known issues (acceptable for cosmetic issues)
|
|
877
|
+
- **No verification section / no server / unreadable skill:** Skip (non-blocking).
|
|
878
|
+
|
|
879
|
+
### 5. Include in PR body
|
|
880
|
+
|
|
881
|
+
Add a \`## Verification Results\` section to the PR body (Step 8):
|
|
882
|
+
- If verification ran: summary of results (N PASS, M FAIL, K SKIPPED)
|
|
883
|
+
- If skipped: reason for skipping (no plan, no server, no verification section)`;
|
|
884
|
+
}
|