feat: add codex-iterm skill
This commit is contained in:
@@ -0,0 +1,60 @@
|
|||||||
|
---
|
||||||
|
name: codex-iterm
|
||||||
|
description: Run Codex CLI tasks inside iTerm so the user can watch progress. Use when Adolfo wants coding work done by Codex with a visible terminal session (e.g., "fire up Codex in iTerm", "let me see Codex work").
|
||||||
|
---
|
||||||
|
|
||||||
|
# Codex iTerm Runner
|
||||||
|
|
||||||
|
Use this skill whenever Adolfo wants Codex to handle coding tasks while he watches the live session in iTerm. The helper script pipes a Codex command into the foreground iTerm window so the GUI stays visible on his Mac.
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd $WORKSPACE
|
||||||
|
python3 skills/codex-iterm/scripts/run_codex_iterm.py \
|
||||||
|
--workdir /Users/adolforeyna/Project/basic1 \
|
||||||
|
--flags "--full-auto" \
|
||||||
|
"Run git pull --ff-only, then summarize last 3 commits."
|
||||||
|
```
|
||||||
|
|
||||||
|
What the helper does:
|
||||||
|
1. Builds a safe shell command: `cd <workdir> && codex <flags> '<prompt>'`
|
||||||
|
2. Calls `osascript` with `run_codex_iterm.applescript`
|
||||||
|
3. AppleScript activates iTerm (creates a window if needed) and types the command into the current session so Codex runs visibly.
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
1. **Prep the prompt**
|
||||||
|
- Keep prompts explicit about the repo, steps, and deliverables, e.g.:
|
||||||
|
- `"Sync with origin (git pull --ff-only) then describe any skill that can generate games from images."
|
||||||
|
2. **Run the helper**
|
||||||
|
- `python3 skills/codex-iterm/scripts/run_codex_iterm.py --workdir <repo> --flags "--full-auto" "<prompt>"`
|
||||||
|
- Flags can be swapped (`--yolo`, `--model gpt-5.3-codex`, etc.) by editing the `--flags` string.
|
||||||
|
3. **Monitor progress**
|
||||||
|
- Adolfo watches the iTerm window; stay available in chat in case Codex asks for input.
|
||||||
|
4. **Capture results**
|
||||||
|
- Once Codex finishes, summarize what happened (commands run, key outputs, follow-ups) in chat.
|
||||||
|
5. **Close the terminal**
|
||||||
|
- When the run is complete and results are copied, close the active iTerm tab/window (⌘W or `osascript -e 'tell application "iTerm" to tell current session of current window to close'`) so Codex isn’t left running.
|
||||||
|
|
||||||
|
## Tips & Troubleshooting
|
||||||
|
|
||||||
|
- **Permission errors (`.git/FETCH_HEAD`)**: Report them to Adolfo before attempting fixes; he may prefer to adjust permissions locally.
|
||||||
|
- **Multiple commands**: Encode the entire plan in one prompt or run the helper multiple times.
|
||||||
|
- **Non-default repos**: Override `--workdir`. The default is `~/Project/basic1`.
|
||||||
|
- **Script locations**:
|
||||||
|
- AppleScript: `skills/codex-iterm/scripts/run_codex_iterm.applescript`
|
||||||
|
- Python helper: `skills/codex-iterm/scripts/run_codex_iterm.py`
|
||||||
|
- **Manual fallback**: If the helper ever fails, replicate it manually:
|
||||||
|
```bash
|
||||||
|
/usr/bin/osascript <<'OSA'
|
||||||
|
set cmd to "cd /path/to/repo && /Applications/Codex.app/Contents/Resources/codex --full-auto 'your prompt'"
|
||||||
|
tell application "iTerm"
|
||||||
|
activate
|
||||||
|
if (count of windows) = 0 then create window with default profile
|
||||||
|
tell current session of current window to write text cmd
|
||||||
|
end tell
|
||||||
|
OSA
|
||||||
|
```
|
||||||
|
|
||||||
|
Stay in sync with Adolfo after each run: confirm the command launched and summarize Codex’s output once it completes.
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
on run argv
|
||||||
|
if (count of argv) is 0 then
|
||||||
|
error "Expected shell command argument"
|
||||||
|
end if
|
||||||
|
set shellCommand to item 1 of argv
|
||||||
|
tell application "iTerm"
|
||||||
|
activate
|
||||||
|
if (count of windows) = 0 then
|
||||||
|
create window with default profile
|
||||||
|
end if
|
||||||
|
tell current session of current window
|
||||||
|
write text shellCommand
|
||||||
|
end tell
|
||||||
|
end tell
|
||||||
|
end run
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Helper to run Codex commands inside iTerm so the user can watch output."""
|
||||||
|
import argparse
|
||||||
|
import shlex
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
DEFAULT_CODEX = "/Applications/Codex.app/Contents/Resources/codex"
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("prompt", help="Codex prompt/instruction string")
|
||||||
|
parser.add_argument("--workdir", default=str(Path.home() / "Project/basic1"),
|
||||||
|
help="Working directory for the Codex session")
|
||||||
|
parser.add_argument("--flags", default="--full-auto",
|
||||||
|
help="Additional flags to pass to Codex (e.g. '--yolo')")
|
||||||
|
parser.add_argument("--codex-path", default=DEFAULT_CODEX,
|
||||||
|
help="Path to the Codex CLI binary")
|
||||||
|
parser.add_argument("--applescript", default=str(Path(__file__).with_name("run_codex_iterm.applescript")),
|
||||||
|
help="Path to the AppleScript wrapper")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
workdir = Path(args.workdir).expanduser()
|
||||||
|
codex_bin = Path(args.codex_path).expanduser()
|
||||||
|
applescript = Path(args.applescript).expanduser()
|
||||||
|
|
||||||
|
if not codex_bin.exists():
|
||||||
|
raise SystemExit(f"Codex binary not found at {codex_bin}")
|
||||||
|
if not applescript.exists():
|
||||||
|
raise SystemExit(f"AppleScript helper not found at {applescript}")
|
||||||
|
|
||||||
|
cmd = f"cd {shlex.quote(str(workdir))} && {shlex.quote(str(codex_bin))} {args.flags} {shlex.quote(args.prompt)}"
|
||||||
|
|
||||||
|
subprocess.run([
|
||||||
|
"osascript",
|
||||||
|
str(applescript),
|
||||||
|
cmd,
|
||||||
|
], check=True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user