refactor(omo-codex): port ultrawork hook to typescript

This commit is contained in:
YeonGyu-Kim
2026-05-28 15:07:51 +09:00
parent 0f0c6d0850
commit 091550b94d
21 changed files with 515 additions and 255 deletions
@@ -5,13 +5,17 @@ Conventions for human contributors and AI agents working on this repository.
## Style
- Terse technical prose. No emojis in commits, issues, PR comments, or code.
- Python: PEP 484 type hints. Hook script stays in standard-library only — no pip dependencies.
- Tabs for indentation in JSON and Markdown tables. Spaces (4) for Python.
- TypeScript strict mode. No `any`, no `@ts-ignore`, no `@ts-expect-error`, no enums, no non-null assertions.
- ESM modules with `.js` suffix in runtime import paths.
- Runtime is Node only because Codex launches plugin hooks with Node.
- Tabs for indentation in JSON, TypeScript, and Markdown tables.
- Double quotes for JSON strings.
## Layout
- `hooks/ultrawork-detector.py` — pure stdlib `UserPromptSubmit` hook. Reads JSON on stdin, writes the directive to stdout when the keyword matches, exits 0 otherwise.
- `src/cli.ts` `UserPromptSubmit` hook CLI. Reads JSON on stdin, writes the directive to stdout when the keyword matches, exits 0 otherwise.
- `src/codex-hook.ts` — pure detector/hook behavior.
- `directive.md` — bundled ultrawork directive text.
- `agents/*.toml` — bundled Codex agent role files. Installed into `CODEX_HOME/agents/` by `src/cli/install-codex/link-cached-plugin-agents.ts` at install time (symlink on Unix, copy on Windows). No runtime `SessionStart` hook is involved.
- `hooks/hooks.json` — registers the prompt-detector hook only.
- `.codex-plugin/plugin.json` — Codex plugin manifest. Marketplace metadata lives here, not in `package.json`.
@@ -20,17 +24,18 @@ Conventions for human contributors and AI agents working on this repository.
- Never let the hook block a turn — exit code is always 0.
- Never make a network call from the hook.
- Keep the directive in `ULTRAWORK_DIRECTIVE` self-contained inside the Python file. The prompt hook is a single artifact a reviewer can read top-to-bottom.
- Keep the directive in `directive.md`. Do not inline it into TypeScript files.
- Keep bundled agent role prompts concise and model-specific; measure prompt length when changing them.
- When editing `ULTRAWORK_DIRECTIVE`, apply the `prompt-engineering` skill's entropy gate: every edit must reduce uncertainty per token. Re-measure character count before committing.
- When editing `directive.md`, apply the `prompt-engineering` skill's entropy gate: every edit must reduce uncertainty per token. Re-measure character count before committing.
## Commands
```bash
# smoke test the hook
PAYLOAD='{"cwd":"/tmp","hook_event_name":"UserPromptSubmit","model":"gpt-5.5","permission_mode":"default","session_id":"x","transcript_path":"","turn_id":"y","prompt":"please ultrawork"}'
echo "$PAYLOAD" | python3 hooks/ultrawork-detector.py | head -3
npm run build
echo "$PAYLOAD" | node dist/cli.js hook user-prompt-submit | head -3
# pattern boundary check (must be empty)
echo '{"hook_event_name":"UserPromptSubmit","prompt":"refactor ulw_helper.ts"}' | python3 hooks/ultrawork-detector.py | wc -c
echo '{"hook_event_name":"UserPromptSubmit","prompt":"refactor ulw_helper.ts"}' | node dist/cli.js hook user-prompt-submit | wc -c
```