oh-my-codex 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +269 -0
- package/bin/omx.js +25 -0
- package/dist/agents/definitions.d.ts +22 -0
- package/dist/agents/definitions.d.ts.map +1 -0
- package/dist/agents/definitions.js +235 -0
- package/dist/agents/definitions.js.map +1 -0
- package/dist/cli/doctor.d.ts +11 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +157 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +266 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/setup.d.ts +12 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +175 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/version.d.ts +2 -0
- package/dist/cli/version.d.ts.map +1 -0
- package/dist/cli/version.js +17 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/config/generator.d.ts +14 -0
- package/dist/config/generator.d.ts.map +1 -0
- package/dist/config/generator.js +106 -0
- package/dist/config/generator.js.map +1 -0
- package/dist/hooks/__tests__/agents-overlay.test.d.ts +8 -0
- package/dist/hooks/__tests__/agents-overlay.test.d.ts.map +1 -0
- package/dist/hooks/__tests__/agents-overlay.test.js +148 -0
- package/dist/hooks/__tests__/agents-overlay.test.js.map +1 -0
- package/dist/hooks/agents-overlay.d.ts +34 -0
- package/dist/hooks/agents-overlay.d.ts.map +1 -0
- package/dist/hooks/agents-overlay.js +265 -0
- package/dist/hooks/agents-overlay.js.map +1 -0
- package/dist/hooks/emulator.d.ts +44 -0
- package/dist/hooks/emulator.d.ts.map +1 -0
- package/dist/hooks/emulator.js +108 -0
- package/dist/hooks/emulator.js.map +1 -0
- package/dist/hooks/keyword-detector.d.ts +27 -0
- package/dist/hooks/keyword-detector.d.ts.map +1 -0
- package/dist/hooks/keyword-detector.js +63 -0
- package/dist/hooks/keyword-detector.js.map +1 -0
- package/dist/hooks/session.d.ts +38 -0
- package/dist/hooks/session.d.ts.map +1 -0
- package/dist/hooks/session.js +135 -0
- package/dist/hooks/session.js.map +1 -0
- package/dist/hud/colors.d.ts +26 -0
- package/dist/hud/colors.d.ts.map +1 -0
- package/dist/hud/colors.js +71 -0
- package/dist/hud/colors.js.map +1 -0
- package/dist/hud/index.d.ts +12 -0
- package/dist/hud/index.d.ts.map +1 -0
- package/dist/hud/index.js +107 -0
- package/dist/hud/index.js.map +1 -0
- package/dist/hud/render.d.ts +9 -0
- package/dist/hud/render.d.ts.map +1 -0
- package/dist/hud/render.js +192 -0
- package/dist/hud/render.js.map +1 -0
- package/dist/hud/state.d.ts +21 -0
- package/dist/hud/state.d.ts.map +1 -0
- package/dist/hud/state.js +101 -0
- package/dist/hud/state.js.map +1 -0
- package/dist/hud/types.d.ts +87 -0
- package/dist/hud/types.d.ts.map +1 -0
- package/dist/hud/types.js +8 -0
- package/dist/hud/types.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/code-intel-server.d.ts +7 -0
- package/dist/mcp/code-intel-server.d.ts.map +1 -0
- package/dist/mcp/code-intel-server.js +567 -0
- package/dist/mcp/code-intel-server.js.map +1 -0
- package/dist/mcp/memory-server.d.ts +7 -0
- package/dist/mcp/memory-server.d.ts.map +1 -0
- package/dist/mcp/memory-server.js +359 -0
- package/dist/mcp/memory-server.js.map +1 -0
- package/dist/mcp/state-server.d.ts +7 -0
- package/dist/mcp/state-server.d.ts.map +1 -0
- package/dist/mcp/state-server.js +181 -0
- package/dist/mcp/state-server.js.map +1 -0
- package/dist/mcp/trace-server.d.ts +7 -0
- package/dist/mcp/trace-server.d.ts.map +1 -0
- package/dist/mcp/trace-server.js +205 -0
- package/dist/mcp/trace-server.js.map +1 -0
- package/dist/modes/base.d.ts +50 -0
- package/dist/modes/base.d.ts.map +1 -0
- package/dist/modes/base.js +140 -0
- package/dist/modes/base.js.map +1 -0
- package/dist/notifications/notifier.d.ts +30 -0
- package/dist/notifications/notifier.d.ts.map +1 -0
- package/dist/notifications/notifier.js +124 -0
- package/dist/notifications/notifier.js.map +1 -0
- package/dist/team/orchestrator.d.ts +54 -0
- package/dist/team/orchestrator.d.ts.map +1 -0
- package/dist/team/orchestrator.js +106 -0
- package/dist/team/orchestrator.js.map +1 -0
- package/dist/utils/package.d.ts +9 -0
- package/dist/utils/package.d.ts.map +1 -0
- package/dist/utils/package.js +31 -0
- package/dist/utils/package.js.map +1 -0
- package/dist/utils/paths.d.ts +27 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +60 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/verification/verifier.d.ts +32 -0
- package/dist/verification/verifier.d.ts.map +1 -0
- package/dist/verification/verifier.js +81 -0
- package/dist/verification/verifier.js.map +1 -0
- package/package.json +54 -0
- package/prompts/analyst.md +110 -0
- package/prompts/api-reviewer.md +98 -0
- package/prompts/architect.md +109 -0
- package/prompts/build-fixer.md +89 -0
- package/prompts/code-reviewer.md +105 -0
- package/prompts/critic.md +87 -0
- package/prompts/debugger.md +93 -0
- package/prompts/deep-executor.md +112 -0
- package/prompts/dependency-expert.md +99 -0
- package/prompts/designer.md +103 -0
- package/prompts/executor.md +99 -0
- package/prompts/explore.md +112 -0
- package/prompts/git-master.md +92 -0
- package/prompts/information-architect.md +267 -0
- package/prompts/performance-reviewer.md +94 -0
- package/prompts/planner.md +116 -0
- package/prompts/product-analyst.md +299 -0
- package/prompts/product-manager.md +255 -0
- package/prompts/qa-tester.md +98 -0
- package/prompts/quality-reviewer.md +105 -0
- package/prompts/quality-strategist.md +227 -0
- package/prompts/researcher.md +96 -0
- package/prompts/scientist.md +92 -0
- package/prompts/security-reviewer.md +125 -0
- package/prompts/style-reviewer.md +87 -0
- package/prompts/test-engineer.md +103 -0
- package/prompts/ux-researcher.md +282 -0
- package/prompts/verifier.md +95 -0
- package/prompts/vision.md +75 -0
- package/prompts/writer.md +86 -0
- package/scripts/notify-hook.js +237 -0
- package/skills/analyze/SKILL.md +93 -0
- package/skills/autopilot/SKILL.md +175 -0
- package/skills/build-fix/SKILL.md +123 -0
- package/skills/cancel/SKILL.md +387 -0
- package/skills/code-review/SKILL.md +208 -0
- package/skills/configure-discord/SKILL.md +256 -0
- package/skills/configure-telegram/SKILL.md +232 -0
- package/skills/deepinit/SKILL.md +320 -0
- package/skills/deepsearch/SKILL.md +38 -0
- package/skills/doctor/SKILL.md +193 -0
- package/skills/ecomode/SKILL.md +114 -0
- package/skills/frontend-ui-ux/SKILL.md +34 -0
- package/skills/git-master/SKILL.md +29 -0
- package/skills/help/SKILL.md +192 -0
- package/skills/hud/SKILL.md +97 -0
- package/skills/learn-about-omx/SKILL.md +37 -0
- package/skills/learner/SKILL.md +135 -0
- package/skills/note/SKILL.md +62 -0
- package/skills/omx-setup/SKILL.md +1147 -0
- package/skills/pipeline/SKILL.md +407 -0
- package/skills/plan/SKILL.md +223 -0
- package/skills/project-session-manager/SKILL.md +560 -0
- package/skills/psm/SKILL.md +20 -0
- package/skills/ralph/SKILL.md +197 -0
- package/skills/ralph-init/SKILL.md +38 -0
- package/skills/ralplan/SKILL.md +34 -0
- package/skills/release/SKILL.md +83 -0
- package/skills/research/SKILL.md +510 -0
- package/skills/review/SKILL.md +30 -0
- package/skills/security-review/SKILL.md +284 -0
- package/skills/skill/SKILL.md +837 -0
- package/skills/swarm/SKILL.md +25 -0
- package/skills/tdd/SKILL.md +106 -0
- package/skills/team/SKILL.md +860 -0
- package/skills/trace/SKILL.md +33 -0
- package/skills/ultrapilot/SKILL.md +632 -0
- package/skills/ultraqa/SKILL.md +130 -0
- package/skills/ultrawork/SKILL.md +143 -0
- package/skills/writer-memory/SKILL.md +443 -0
- package/templates/AGENTS.md +326 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Technical documentation writer for README, API docs, and comments (Haiku)"
|
|
3
|
+
argument-hint: "task description"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<Agent_Prompt>
|
|
7
|
+
<Role>
|
|
8
|
+
You are Writer. Your mission is to create clear, accurate technical documentation that developers want to read.
|
|
9
|
+
You are responsible for README files, API documentation, architecture docs, user guides, and code comments.
|
|
10
|
+
You are not responsible for implementing features, reviewing code quality, or making architectural decisions.
|
|
11
|
+
</Role>
|
|
12
|
+
|
|
13
|
+
<Why_This_Matters>
|
|
14
|
+
Inaccurate documentation is worse than no documentation -- it actively misleads. These rules exist because documentation with untested code examples causes frustration, and documentation that doesn't match reality wastes developer time. Every example must work, every command must be verified.
|
|
15
|
+
</Why_This_Matters>
|
|
16
|
+
|
|
17
|
+
<Success_Criteria>
|
|
18
|
+
- All code examples tested and verified to work
|
|
19
|
+
- All commands tested and verified to run
|
|
20
|
+
- Documentation matches existing style and structure
|
|
21
|
+
- Content is scannable: headers, code blocks, tables, bullet points
|
|
22
|
+
- A new developer can follow the documentation without getting stuck
|
|
23
|
+
</Success_Criteria>
|
|
24
|
+
|
|
25
|
+
<Constraints>
|
|
26
|
+
- Document precisely what is requested, nothing more, nothing less.
|
|
27
|
+
- Verify every code example and command before including it.
|
|
28
|
+
- Match existing documentation style and conventions.
|
|
29
|
+
- Use active voice, direct language, no filler words.
|
|
30
|
+
- If examples cannot be tested, explicitly state this limitation.
|
|
31
|
+
</Constraints>
|
|
32
|
+
|
|
33
|
+
<Investigation_Protocol>
|
|
34
|
+
1) Parse the request to identify the exact documentation task.
|
|
35
|
+
2) Explore the codebase to understand what to document (use Glob, Grep, Read in parallel).
|
|
36
|
+
3) Study existing documentation for style, structure, and conventions.
|
|
37
|
+
4) Write documentation with verified code examples.
|
|
38
|
+
5) Test all commands and examples.
|
|
39
|
+
6) Report what was documented and verification results.
|
|
40
|
+
</Investigation_Protocol>
|
|
41
|
+
|
|
42
|
+
<Tool_Usage>
|
|
43
|
+
- Use Read/Glob/Grep to explore codebase and existing docs (parallel calls).
|
|
44
|
+
- Use Write to create documentation files.
|
|
45
|
+
- Use Edit to update existing documentation.
|
|
46
|
+
- Use Bash to test commands and verify examples work.
|
|
47
|
+
</Tool_Usage>
|
|
48
|
+
|
|
49
|
+
<Execution_Policy>
|
|
50
|
+
- Default effort: low (concise, accurate documentation).
|
|
51
|
+
- Stop when documentation is complete, accurate, and verified.
|
|
52
|
+
</Execution_Policy>
|
|
53
|
+
|
|
54
|
+
<Output_Format>
|
|
55
|
+
COMPLETED TASK: [exact task description]
|
|
56
|
+
STATUS: SUCCESS / FAILED / BLOCKED
|
|
57
|
+
|
|
58
|
+
FILES CHANGED:
|
|
59
|
+
- Created: [list]
|
|
60
|
+
- Modified: [list]
|
|
61
|
+
|
|
62
|
+
VERIFICATION:
|
|
63
|
+
- Code examples tested: X/Y working
|
|
64
|
+
- Commands verified: X/Y valid
|
|
65
|
+
</Output_Format>
|
|
66
|
+
|
|
67
|
+
<Failure_Modes_To_Avoid>
|
|
68
|
+
- Untested examples: Including code snippets that don't actually compile or run. Test everything.
|
|
69
|
+
- Stale documentation: Documenting what the code used to do rather than what it currently does. Read the actual code first.
|
|
70
|
+
- Scope creep: Documenting adjacent features when asked to document one specific thing. Stay focused.
|
|
71
|
+
- Wall of text: Dense paragraphs without structure. Use headers, bullets, code blocks, and tables.
|
|
72
|
+
</Failure_Modes_To_Avoid>
|
|
73
|
+
|
|
74
|
+
<Examples>
|
|
75
|
+
<Good>Task: "Document the auth API." Writer reads the actual auth code, writes API docs with tested curl examples that return real responses, includes error codes from actual error handling, and verifies the installation command works.</Good>
|
|
76
|
+
<Bad>Task: "Document the auth API." Writer guesses at endpoint paths, invents response formats, includes untested curl examples, and copies parameter names from memory instead of reading the code.</Bad>
|
|
77
|
+
</Examples>
|
|
78
|
+
|
|
79
|
+
<Final_Checklist>
|
|
80
|
+
- Are all code examples tested and working?
|
|
81
|
+
- Are all commands verified?
|
|
82
|
+
- Does the documentation match existing style?
|
|
83
|
+
- Is the content scannable (headers, code blocks, tables)?
|
|
84
|
+
- Did I stay within the requested scope?
|
|
85
|
+
</Final_Checklist>
|
|
86
|
+
</Agent_Prompt>
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* oh-my-codex Notification Hook
|
|
5
|
+
* Codex CLI fires this after each agent turn via the `notify` config.
|
|
6
|
+
* Receives JSON payload as the last argv argument.
|
|
7
|
+
*
|
|
8
|
+
* This hook:
|
|
9
|
+
* 1. Logs agent turn completions to .omx/logs/
|
|
10
|
+
* 2. Updates state for active workflow modes
|
|
11
|
+
* 3. Tracks subagent activity
|
|
12
|
+
* 4. Triggers desktop notifications if configured
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { writeFile, appendFile, mkdir, readFile } from 'fs/promises';
|
|
16
|
+
import { join } from 'path';
|
|
17
|
+
import { existsSync } from 'fs';
|
|
18
|
+
|
|
19
|
+
function asNumber(value) {
|
|
20
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
21
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
22
|
+
const parsed = Number(value);
|
|
23
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getSessionTokenUsage(payload) {
|
|
29
|
+
const usage = payload.usage || payload['usage'] || payload.token_usage || payload['token-usage'] || {};
|
|
30
|
+
|
|
31
|
+
const input = asNumber(
|
|
32
|
+
usage.session_input_tokens
|
|
33
|
+
?? usage.input_tokens
|
|
34
|
+
?? usage.total_input_tokens
|
|
35
|
+
?? payload.session_input_tokens
|
|
36
|
+
?? payload.input_tokens
|
|
37
|
+
?? payload.total_input_tokens
|
|
38
|
+
);
|
|
39
|
+
const output = asNumber(
|
|
40
|
+
usage.session_output_tokens
|
|
41
|
+
?? usage.output_tokens
|
|
42
|
+
?? usage.total_output_tokens
|
|
43
|
+
?? payload.session_output_tokens
|
|
44
|
+
?? payload.output_tokens
|
|
45
|
+
?? payload.total_output_tokens
|
|
46
|
+
);
|
|
47
|
+
const total = asNumber(
|
|
48
|
+
usage.session_total_tokens
|
|
49
|
+
?? usage.total_tokens
|
|
50
|
+
?? payload.session_total_tokens
|
|
51
|
+
?? payload.total_tokens
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (input === null && output === null && total === null) return null;
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
input,
|
|
58
|
+
output,
|
|
59
|
+
total: total ?? ((input ?? 0) + (output ?? 0)),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function clampPct(value) {
|
|
64
|
+
if (!Number.isFinite(value)) return null;
|
|
65
|
+
if (value < 0) return 0;
|
|
66
|
+
if (value <= 1) return Math.round(value * 100);
|
|
67
|
+
if (value > 100) return 100;
|
|
68
|
+
return Math.round(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function extractLimitPct(limit) {
|
|
72
|
+
if (limit == null) return null;
|
|
73
|
+
if (typeof limit === 'number' || typeof limit === 'string') return clampPct(asNumber(limit));
|
|
74
|
+
if (typeof limit !== 'object') return null;
|
|
75
|
+
|
|
76
|
+
const directPct = clampPct(asNumber(limit.percent ?? limit.pct ?? limit.usage_percent ?? limit.usagePct));
|
|
77
|
+
if (directPct !== null) return directPct;
|
|
78
|
+
|
|
79
|
+
const used = asNumber(limit.used ?? limit.usage ?? limit.current);
|
|
80
|
+
const max = asNumber(limit.limit ?? limit.max ?? limit.total);
|
|
81
|
+
if (used !== null && max !== null && max > 0) {
|
|
82
|
+
return clampPct((used / max) * 100);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const remaining = asNumber(limit.remaining ?? limit.left);
|
|
86
|
+
if (remaining !== null && max !== null && max > 0) {
|
|
87
|
+
return clampPct(((max - remaining) / max) * 100);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function getQuotaUsage(payload) {
|
|
94
|
+
const usage = payload.usage || payload['usage'] || payload.token_usage || payload['token-usage'] || {};
|
|
95
|
+
|
|
96
|
+
const fiveHourRaw =
|
|
97
|
+
usage.five_hour_limit
|
|
98
|
+
?? usage.fiveHourLimit
|
|
99
|
+
?? usage['5h_limit']
|
|
100
|
+
?? payload.five_hour_limit
|
|
101
|
+
?? payload.fiveHourLimit
|
|
102
|
+
?? payload['5h_limit'];
|
|
103
|
+
const weeklyRaw =
|
|
104
|
+
usage.weekly_limit
|
|
105
|
+
?? usage.weeklyLimit
|
|
106
|
+
?? payload.weekly_limit
|
|
107
|
+
?? payload.weeklyLimit;
|
|
108
|
+
|
|
109
|
+
const fiveHourLimitPct = extractLimitPct(fiveHourRaw);
|
|
110
|
+
const weeklyLimitPct = extractLimitPct(weeklyRaw);
|
|
111
|
+
|
|
112
|
+
if (fiveHourLimitPct === null && weeklyLimitPct === null) return null;
|
|
113
|
+
return { fiveHourLimitPct, weeklyLimitPct };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function main() {
|
|
117
|
+
const rawPayload = process.argv[process.argv.length - 1];
|
|
118
|
+
if (!rawPayload || rawPayload.startsWith('-')) {
|
|
119
|
+
process.exit(0);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
let payload;
|
|
123
|
+
try {
|
|
124
|
+
payload = JSON.parse(rawPayload);
|
|
125
|
+
} catch {
|
|
126
|
+
process.exit(0);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const cwd = payload.cwd || payload['cwd'] || process.cwd();
|
|
130
|
+
const omxDir = join(cwd, '.omx');
|
|
131
|
+
const logsDir = join(omxDir, 'logs');
|
|
132
|
+
const stateDir = join(omxDir, 'state');
|
|
133
|
+
|
|
134
|
+
// Ensure directories exist
|
|
135
|
+
await mkdir(logsDir, { recursive: true }).catch(() => {});
|
|
136
|
+
await mkdir(stateDir, { recursive: true }).catch(() => {});
|
|
137
|
+
|
|
138
|
+
// 1. Log the turn
|
|
139
|
+
const logEntry = {
|
|
140
|
+
timestamp: new Date().toISOString(),
|
|
141
|
+
type: payload.type || 'agent-turn-complete',
|
|
142
|
+
thread_id: payload['thread-id'] || payload.thread_id,
|
|
143
|
+
turn_id: payload['turn-id'] || payload.turn_id,
|
|
144
|
+
input_preview: (payload['input-messages'] || payload.input_messages || [])
|
|
145
|
+
.map(m => m.slice(0, 100))
|
|
146
|
+
.join('; '),
|
|
147
|
+
output_preview: (payload['last-assistant-message'] || payload.last_assistant_message || '')
|
|
148
|
+
.slice(0, 200),
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const logFile = join(logsDir, `turns-${new Date().toISOString().split('T')[0]}.jsonl`);
|
|
152
|
+
await appendFile(logFile, JSON.stringify(logEntry) + '\n').catch(() => {});
|
|
153
|
+
|
|
154
|
+
// 2. Update active mode state (increment iteration)
|
|
155
|
+
try {
|
|
156
|
+
const stateFiles = await readdir(stateDir);
|
|
157
|
+
for (const f of stateFiles) {
|
|
158
|
+
if (!f.endsWith('-state.json')) continue;
|
|
159
|
+
const statePath = join(stateDir, f);
|
|
160
|
+
const state = JSON.parse(await readFile(statePath, 'utf-8'));
|
|
161
|
+
if (state.active) {
|
|
162
|
+
state.iteration = (state.iteration || 0) + 1;
|
|
163
|
+
state.last_turn_at = new Date().toISOString();
|
|
164
|
+
await writeFile(statePath, JSON.stringify(state, null, 2));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} catch {
|
|
168
|
+
// Non-critical
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// 3. Track subagent metrics
|
|
172
|
+
const metricsPath = join(omxDir, 'metrics.json');
|
|
173
|
+
try {
|
|
174
|
+
let metrics = {
|
|
175
|
+
total_turns: 0,
|
|
176
|
+
session_turns: 0,
|
|
177
|
+
last_activity: '',
|
|
178
|
+
session_input_tokens: 0,
|
|
179
|
+
session_output_tokens: 0,
|
|
180
|
+
session_total_tokens: 0,
|
|
181
|
+
};
|
|
182
|
+
if (existsSync(metricsPath)) {
|
|
183
|
+
metrics = { ...metrics, ...JSON.parse(await readFile(metricsPath, 'utf-8')) };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const tokenUsage = getSessionTokenUsage(payload);
|
|
187
|
+
const quotaUsage = getQuotaUsage(payload);
|
|
188
|
+
|
|
189
|
+
metrics.total_turns++;
|
|
190
|
+
metrics.session_turns++;
|
|
191
|
+
metrics.last_activity = new Date().toISOString();
|
|
192
|
+
|
|
193
|
+
if (tokenUsage) {
|
|
194
|
+
if (tokenUsage.input !== null) metrics.session_input_tokens = tokenUsage.input;
|
|
195
|
+
if (tokenUsage.output !== null) metrics.session_output_tokens = tokenUsage.output;
|
|
196
|
+
if (tokenUsage.total !== null) {
|
|
197
|
+
metrics.session_total_tokens = tokenUsage.total;
|
|
198
|
+
} else {
|
|
199
|
+
metrics.session_total_tokens = (metrics.session_input_tokens || 0) + (metrics.session_output_tokens || 0);
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
metrics.session_total_tokens = (metrics.session_input_tokens || 0) + (metrics.session_output_tokens || 0);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (quotaUsage) {
|
|
206
|
+
if (quotaUsage.fiveHourLimitPct !== null) metrics.five_hour_limit_pct = quotaUsage.fiveHourLimitPct;
|
|
207
|
+
if (quotaUsage.weeklyLimitPct !== null) metrics.weekly_limit_pct = quotaUsage.weeklyLimitPct;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
await writeFile(metricsPath, JSON.stringify(metrics, null, 2));
|
|
211
|
+
} catch {
|
|
212
|
+
// Non-critical
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// 4. Write HUD state summary for `omx hud`
|
|
216
|
+
const hudStatePath = join(stateDir, 'hud-state.json');
|
|
217
|
+
try {
|
|
218
|
+
let hudState = { last_turn_at: '', turn_count: 0 };
|
|
219
|
+
if (existsSync(hudStatePath)) {
|
|
220
|
+
hudState = JSON.parse(await readFile(hudStatePath, 'utf-8'));
|
|
221
|
+
}
|
|
222
|
+
hudState.last_turn_at = new Date().toISOString();
|
|
223
|
+
hudState.turn_count = (hudState.turn_count || 0) + 1;
|
|
224
|
+
hudState.last_agent_output = (payload['last-assistant-message'] || payload.last_assistant_message || '')
|
|
225
|
+
.slice(0, 100);
|
|
226
|
+
await writeFile(hudStatePath, JSON.stringify(hudState, null, 2));
|
|
227
|
+
} catch {
|
|
228
|
+
// Non-critical
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
async function readdir(dir) {
|
|
233
|
+
const { readdir: rd } = await import('fs/promises');
|
|
234
|
+
return rd(dir);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
main().catch(() => process.exit(0));
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: analyze
|
|
3
|
+
description: Deep analysis and investigation
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<Purpose>
|
|
7
|
+
Analyze performs deep investigation of architecture, bugs, performance issues, and dependencies. It routes to the architect agent or Codex MCP for thorough analysis and returns structured findings with evidence.
|
|
8
|
+
</Purpose>
|
|
9
|
+
|
|
10
|
+
<Use_When>
|
|
11
|
+
- User says "analyze", "investigate", "debug", "why does", or "what's causing"
|
|
12
|
+
- User needs to understand a system's architecture or behavior before making changes
|
|
13
|
+
- User wants root cause analysis of a bug or performance issue
|
|
14
|
+
- User needs dependency analysis or impact assessment for a proposed change
|
|
15
|
+
- A complex question requires reading multiple files and reasoning across them
|
|
16
|
+
</Use_When>
|
|
17
|
+
|
|
18
|
+
<Do_Not_Use_When>
|
|
19
|
+
- User wants code changes made -- use executor agents or `ralph` instead
|
|
20
|
+
- User wants a full plan with acceptance criteria -- use `plan` skill instead
|
|
21
|
+
- User wants a quick file lookup or symbol search -- use `explore` agent instead
|
|
22
|
+
- User asks a simple factual question that can be answered from one file -- just read and answer directly
|
|
23
|
+
</Do_Not_Use_When>
|
|
24
|
+
|
|
25
|
+
<Why_This_Exists>
|
|
26
|
+
Deep investigation requires a different approach than quick lookups or code changes. Analysis tasks need broad context gathering, cross-file reasoning, and structured findings. Routing these to the architect agent or Codex ensures the right level of depth without the overhead of a full planning or execution workflow.
|
|
27
|
+
</Why_This_Exists>
|
|
28
|
+
|
|
29
|
+
<Execution_Policy>
|
|
30
|
+
- Prefer Codex MCP for analysis when available (faster, lower cost)
|
|
31
|
+
- Fall back to architect Claude agent when Codex is unavailable
|
|
32
|
+
- Always provide context files to the analysis tool for grounded reasoning
|
|
33
|
+
- Return structured findings, not just raw observations
|
|
34
|
+
</Execution_Policy>
|
|
35
|
+
|
|
36
|
+
<Steps>
|
|
37
|
+
1. **Identify the analysis type**: Architecture, bug investigation, performance, or dependency analysis
|
|
38
|
+
2. **Gather relevant context**: Read or identify the key files involved
|
|
39
|
+
3. **Route to analyzer**:
|
|
40
|
+
- Preferred: `ask_codex` with `agent_role: "architect"` and relevant `context_files`
|
|
41
|
+
- Fallback: `spawn_sub_agent(subagent_type="oh-my-codex:architect", model="opus", prompt="Analyze: ...")`
|
|
42
|
+
4. **Return structured findings**: Present the analysis with evidence, file references, and actionable recommendations
|
|
43
|
+
</Steps>
|
|
44
|
+
|
|
45
|
+
<Tool_Usage>
|
|
46
|
+
- Before first MCP tool use, call `ToolSearch("mcp")` to discover deferred MCP tools
|
|
47
|
+
- Use `ask_codex` with `agent_role: "architect"` as the preferred analysis route
|
|
48
|
+
- Pass `context_files` with all relevant source files for grounded analysis
|
|
49
|
+
- Use `spawn_sub_agent(subagent_type="oh-my-codex:architect", model="opus", ...)` as fallback when ToolSearch finds no MCP tools or Codex is unavailable
|
|
50
|
+
- For broad analysis, use `explore` agent first to identify relevant files before routing to architect
|
|
51
|
+
</Tool_Usage>
|
|
52
|
+
|
|
53
|
+
<Examples>
|
|
54
|
+
<Good>
|
|
55
|
+
User: "analyze why the WebSocket connections drop after 30 seconds"
|
|
56
|
+
Action: Gather WebSocket-related files, route to architect with context, return root cause analysis with specific file:line references and a recommended fix.
|
|
57
|
+
Why good: Clear investigation target, structured output with evidence.
|
|
58
|
+
</Good>
|
|
59
|
+
|
|
60
|
+
<Good>
|
|
61
|
+
User: "investigate the dependency chain from src/api/routes.ts"
|
|
62
|
+
Action: Use explore agent to map the import graph, then route to architect for impact analysis.
|
|
63
|
+
Why good: Uses explore for fact-gathering, architect for reasoning.
|
|
64
|
+
</Good>
|
|
65
|
+
|
|
66
|
+
<Bad>
|
|
67
|
+
User: "analyze the auth module"
|
|
68
|
+
Action: Returning "The auth module handles authentication."
|
|
69
|
+
Why bad: Shallow summary without investigation. Should examine the module's structure, patterns, potential issues, and provide specific findings with file references.
|
|
70
|
+
</Bad>
|
|
71
|
+
|
|
72
|
+
<Bad>
|
|
73
|
+
User: "fix the bug in the parser"
|
|
74
|
+
Action: Running analysis skill.
|
|
75
|
+
Why bad: This is a fix request, not an analysis request. Route to executor or ralph instead.
|
|
76
|
+
</Bad>
|
|
77
|
+
</Examples>
|
|
78
|
+
|
|
79
|
+
<Escalation_And_Stop_Conditions>
|
|
80
|
+
- If analysis reveals the issue requires code changes, report findings and recommend using `ralph` or executor for the fix
|
|
81
|
+
- If the analysis scope is too broad ("analyze everything"), ask the user to narrow the focus
|
|
82
|
+
- If Codex is unavailable and the architect agent also fails, report what context was gathered and suggest manual investigation paths
|
|
83
|
+
</Escalation_And_Stop_Conditions>
|
|
84
|
+
|
|
85
|
+
<Final_Checklist>
|
|
86
|
+
- [ ] Analysis addresses the specific question or investigation target
|
|
87
|
+
- [ ] Findings reference specific files and line numbers where applicable
|
|
88
|
+
- [ ] Root causes are identified (not just symptoms) for bug investigations
|
|
89
|
+
- [ ] Actionable recommendations are provided
|
|
90
|
+
- [ ] Analysis distinguishes between confirmed facts and hypotheses
|
|
91
|
+
</Final_Checklist>
|
|
92
|
+
|
|
93
|
+
Task: {{ARGUMENTS}}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: autopilot
|
|
3
|
+
description: Full autonomous execution from idea to working code
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<Purpose>
|
|
7
|
+
Autopilot takes a brief product idea and autonomously handles the full lifecycle: requirements analysis, technical design, planning, parallel implementation, QA cycling, and multi-perspective validation. It produces working, verified code from a 2-3 line description.
|
|
8
|
+
</Purpose>
|
|
9
|
+
|
|
10
|
+
<Use_When>
|
|
11
|
+
- User wants end-to-end autonomous execution from an idea to working code
|
|
12
|
+
- User says "autopilot", "auto pilot", "autonomous", "build me", "create me", "make me", "full auto", "handle it all", or "I want a/an..."
|
|
13
|
+
- Task requires multiple phases: planning, coding, testing, and validation
|
|
14
|
+
- User wants hands-off execution and is willing to let the system run to completion
|
|
15
|
+
</Use_When>
|
|
16
|
+
|
|
17
|
+
<Do_Not_Use_When>
|
|
18
|
+
- User wants to explore options or brainstorm -- use `plan` skill instead
|
|
19
|
+
- User says "just explain", "draft only", or "what would you suggest" -- respond conversationally
|
|
20
|
+
- User wants a single focused code change -- use `ralph` or delegate to an executor agent
|
|
21
|
+
- User wants to review or critique an existing plan -- use `plan --review`
|
|
22
|
+
- Task is a quick fix or small bug -- use direct executor delegation
|
|
23
|
+
</Do_Not_Use_When>
|
|
24
|
+
|
|
25
|
+
<Why_This_Exists>
|
|
26
|
+
Most non-trivial software tasks require coordinated phases: understanding requirements, designing a solution, implementing in parallel, testing, and validating quality. Autopilot orchestrates all of these phases automatically so the user can describe what they want and receive working code without managing each step.
|
|
27
|
+
</Why_This_Exists>
|
|
28
|
+
|
|
29
|
+
<Execution_Policy>
|
|
30
|
+
- Each phase must complete before the next begins
|
|
31
|
+
- Parallel execution is used within phases where possible (Phase 2 and Phase 4)
|
|
32
|
+
- QA cycles repeat up to 5 times; if the same error persists 3 times, stop and report the fundamental issue
|
|
33
|
+
- Validation requires approval from all reviewers; rejected items get fixed and re-validated
|
|
34
|
+
- Cancel with `/cancel` at any time; progress is preserved for resume
|
|
35
|
+
</Execution_Policy>
|
|
36
|
+
|
|
37
|
+
<Steps>
|
|
38
|
+
1. **Phase 0 - Expansion**: Turn the user's idea into a detailed spec
|
|
39
|
+
- Analyst (Opus): Extract requirements
|
|
40
|
+
- Architect (Opus): Create technical specification
|
|
41
|
+
- Output: `.omx/plans/autopilot-spec.md`
|
|
42
|
+
|
|
43
|
+
2. **Phase 1 - Planning**: Create an implementation plan from the spec
|
|
44
|
+
- Architect (Opus): Create plan (direct mode, no interview)
|
|
45
|
+
- Critic (Opus): Validate plan
|
|
46
|
+
- Output: `.omx/plans/autopilot-impl.md`
|
|
47
|
+
|
|
48
|
+
3. **Phase 2 - Execution**: Implement the plan using Ralph + Ultrawork
|
|
49
|
+
- Executor-low (Haiku): Simple tasks
|
|
50
|
+
- Executor (Sonnet): Standard tasks
|
|
51
|
+
- Executor-high (Opus): Complex tasks
|
|
52
|
+
- Run independent tasks in parallel
|
|
53
|
+
|
|
54
|
+
4. **Phase 3 - QA**: Cycle until all tests pass (UltraQA mode)
|
|
55
|
+
- Build, lint, test, fix failures
|
|
56
|
+
- Repeat up to 5 cycles
|
|
57
|
+
- Stop early if the same error repeats 3 times (indicates a fundamental issue)
|
|
58
|
+
|
|
59
|
+
5. **Phase 4 - Validation**: Multi-perspective review in parallel
|
|
60
|
+
- Architect: Functional completeness
|
|
61
|
+
- Security-reviewer: Vulnerability check
|
|
62
|
+
- Code-reviewer: Quality review
|
|
63
|
+
- All must approve; fix and re-validate on rejection
|
|
64
|
+
|
|
65
|
+
6. **Phase 5 - Cleanup**: Clear all mode state via OMX MCP tools on successful completion
|
|
66
|
+
- `state_clear({mode: "autopilot"})`
|
|
67
|
+
- `state_clear({mode: "ralph"})`
|
|
68
|
+
- `state_clear({mode: "ultrawork"})`
|
|
69
|
+
- `state_clear({mode: "ultraqa"})`
|
|
70
|
+
- Or run `/cancel` for clean exit
|
|
71
|
+
</Steps>
|
|
72
|
+
|
|
73
|
+
<Tool_Usage>
|
|
74
|
+
- Before first MCP tool use, call `ToolSearch("mcp")` to discover deferred MCP tools
|
|
75
|
+
- Use `ask_codex` with `agent_role: "architect"` for Phase 4 architecture validation
|
|
76
|
+
- Use `ask_codex` with `agent_role: "security-reviewer"` for Phase 4 security review
|
|
77
|
+
- Use `ask_codex` with `agent_role: "code-reviewer"` for Phase 4 quality review
|
|
78
|
+
- Agents form their own analysis first, then consult Codex for cross-validation
|
|
79
|
+
- If ToolSearch finds no MCP tools or Codex is unavailable, proceed without it -- never block on external tools
|
|
80
|
+
</Tool_Usage>
|
|
81
|
+
|
|
82
|
+
## State Management
|
|
83
|
+
|
|
84
|
+
Use `omx_state` MCP tools for autopilot lifecycle state.
|
|
85
|
+
|
|
86
|
+
- **On start**:
|
|
87
|
+
`state_write({mode: "autopilot", active: true, current_phase: "expansion", started_at: "<now>"})`
|
|
88
|
+
- **On phase transitions**:
|
|
89
|
+
`state_write({mode: "autopilot", current_phase: "planning"})`
|
|
90
|
+
`state_write({mode: "autopilot", current_phase: "execution"})`
|
|
91
|
+
`state_write({mode: "autopilot", current_phase: "qa"})`
|
|
92
|
+
`state_write({mode: "autopilot", current_phase: "validation"})`
|
|
93
|
+
- **On completion**:
|
|
94
|
+
`state_write({mode: "autopilot", active: false, current_phase: "complete", completed_at: "<now>"})`
|
|
95
|
+
- **On cancellation/cleanup**:
|
|
96
|
+
run `$cancel` (which should call `state_clear(mode="autopilot")`)
|
|
97
|
+
|
|
98
|
+
<Examples>
|
|
99
|
+
<Good>
|
|
100
|
+
User: "autopilot A REST API for a bookstore inventory with CRUD operations using TypeScript"
|
|
101
|
+
Why good: Specific domain (bookstore), clear features (CRUD), technology constraint (TypeScript). Autopilot has enough context to expand into a full spec.
|
|
102
|
+
</Good>
|
|
103
|
+
|
|
104
|
+
<Good>
|
|
105
|
+
User: "build me a CLI tool that tracks daily habits with streak counting"
|
|
106
|
+
Why good: Clear product concept with a specific feature. The "build me" trigger activates autopilot.
|
|
107
|
+
</Good>
|
|
108
|
+
|
|
109
|
+
<Bad>
|
|
110
|
+
User: "fix the bug in the login page"
|
|
111
|
+
Why bad: This is a single focused fix, not a multi-phase project. Use direct executor delegation or ralph instead.
|
|
112
|
+
</Bad>
|
|
113
|
+
|
|
114
|
+
<Bad>
|
|
115
|
+
User: "what are some good approaches for adding caching?"
|
|
116
|
+
Why bad: This is an exploration/brainstorming request. Respond conversationally or use the plan skill.
|
|
117
|
+
</Bad>
|
|
118
|
+
</Examples>
|
|
119
|
+
|
|
120
|
+
<Escalation_And_Stop_Conditions>
|
|
121
|
+
- Stop and report when the same QA error persists across 3 cycles (fundamental issue requiring human input)
|
|
122
|
+
- Stop and report when validation keeps failing after 3 re-validation rounds
|
|
123
|
+
- Stop when the user says "stop", "cancel", or "abort"
|
|
124
|
+
- If requirements were too vague and expansion produces an unclear spec, pause and ask the user for clarification before proceeding
|
|
125
|
+
</Escalation_And_Stop_Conditions>
|
|
126
|
+
|
|
127
|
+
<Final_Checklist>
|
|
128
|
+
- [ ] All 5 phases completed (Expansion, Planning, Execution, QA, Validation)
|
|
129
|
+
- [ ] All validators approved in Phase 4
|
|
130
|
+
- [ ] Tests pass (verified with fresh test run output)
|
|
131
|
+
- [ ] Build succeeds (verified with fresh build output)
|
|
132
|
+
- [ ] State files cleaned up
|
|
133
|
+
- [ ] User informed of completion with summary of what was built
|
|
134
|
+
</Final_Checklist>
|
|
135
|
+
|
|
136
|
+
<Advanced>
|
|
137
|
+
## Configuration
|
|
138
|
+
|
|
139
|
+
Optional settings in `.claude/settings.json`:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"omc": {
|
|
144
|
+
"autopilot": {
|
|
145
|
+
"maxIterations": 10,
|
|
146
|
+
"maxQaCycles": 5,
|
|
147
|
+
"maxValidationRounds": 3,
|
|
148
|
+
"pauseAfterExpansion": false,
|
|
149
|
+
"pauseAfterPlanning": false,
|
|
150
|
+
"skipQa": false,
|
|
151
|
+
"skipValidation": false
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Resume
|
|
158
|
+
|
|
159
|
+
If autopilot was cancelled or failed, run `/autopilot` again to resume from where it stopped.
|
|
160
|
+
|
|
161
|
+
## Best Practices for Input
|
|
162
|
+
|
|
163
|
+
1. Be specific about the domain -- "bookstore" not "store"
|
|
164
|
+
2. Mention key features -- "with CRUD", "with authentication"
|
|
165
|
+
3. Specify constraints -- "using TypeScript", "with PostgreSQL"
|
|
166
|
+
4. Let it run -- avoid interrupting unless truly needed
|
|
167
|
+
|
|
168
|
+
## Troubleshooting
|
|
169
|
+
|
|
170
|
+
**Stuck in a phase?** Check TODO list for blocked tasks, run `state_read({mode: "autopilot"})`, or cancel and resume.
|
|
171
|
+
|
|
172
|
+
**QA cycles exhausted?** The same error 3 times indicates a fundamental issue. Review the error pattern; manual intervention may be needed.
|
|
173
|
+
|
|
174
|
+
**Validation keeps failing?** Review the specific issues. Requirements may have been too vague -- cancel and provide more detail.
|
|
175
|
+
</Advanced>
|