|
1 | 1 | --- |
2 | 2 | name: agent-tools |
3 | | -description: Use Windows-native agent helper commands for bounded UTF-8 file reads with glob expansion and batch boundaries, noise-excluded ripgrep searches, direct apply_patch delivery, Git checks, kill-on-close child processes, and profile-free PowerShell 7 execution. Use for routine repository work on Windows when quoting, encoding, oversized files or lines, profile noise, shell metacharacters, or orphaned child processes make raw PowerShell commands fragile. |
| 3 | +description: Maintain, install, or troubleshoot the Windows-native agent helper commands and their global AGENTS.md integration. Use when Codex needs to change this tool package, reinstall it, diagnose behavior not covered by the installed global reference, or when the user explicitly invokes $agent-tools. Routine command usage is documented in global AGENTS.md and should not implicitly trigger this skill. |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | # Agent Tools |
7 | 7 |
|
8 | | -Invoke the installed `agent-*` executable names directly. The installer places `%AGENT_TOOLS_HOME%` on `PATH`; use a computed path only with PowerShell's `&` call operator. |
| 8 | +The installer writes the complete routine command reference from `assets/global-agents.md` into the global `AGENTS.md`. Do not load this skill merely to look up normal `agent-*` syntax; use the already-loaded global reference. |
9 | 9 |
|
10 | | -## Read Files |
| 10 | +## Maintenance Workflow |
11 | 11 |
|
12 | | -Use `agent-read` for bounded UTF-8 reads: |
13 | | - |
14 | | -```powershell |
15 | | -agent-read <path-or-pattern>... |
16 | | -agent-read <paths...> --lines START:END |
17 | | -agent-read <paths...> --from N --count N |
18 | | -agent-read <paths...> --head N |
19 | | -agent-read <paths...> --tail N |
20 | | -agent-read <paths...> --number |
21 | | -agent-read <paths...> --all |
22 | | -agent-read <paths...> --max-lines N |
23 | | -``` |
24 | | - |
25 | | -Pass multiple concrete paths or patterns using `*`, `?`, `[]`, or recursive `**`. Results are sorted and deduplicated. Prefix a path beginning with `-` by `--`. |
26 | | - |
27 | | -The default output is the first 2,000 lines. Follow the stderr continuation hint when more content exists. Explicit ranges and `--tail` are complete unless `--max-lines` is supplied. |
28 | | - |
29 | | -For multiple files, recognize these boundaries and use the JSON metadata to associate content with its source: |
30 | | - |
31 | | -```text |
32 | | -<<<AGENT_READ_FILE_START {"index":1,"total":2,"path":"C:\\code\\a.txt"}>>> |
33 | | -... |
34 | | -<<<AGENT_READ_FILE_END {"index":1,"total":2,"path":"C:\\code\\a.txt","status":"ok"}>>> |
35 | | -``` |
36 | | - |
37 | | -Treat invalid UTF-8 and safety-limit errors as failed reads. Limits are 1,000 matched files, 512 MiB per file, 8 MiB per line, 128 MiB retained tail content, and 1,000,000 tail lines. `~`, `~/...`, and `~\...` expand to the current user profile. |
38 | | - |
39 | | -## Search Repositories |
40 | | - |
41 | | -Use `agent-rg <pattern> [roots...]`. It invokes Windows `rg.exe` with line numbers, smart case, safe pattern separation, and exclusions for `node_modules`, `dist`, `logs`, `.git`, `.idea`, `tmp`, `.cache`, and `coverage`. |
42 | | - |
43 | | -## Apply Patches |
44 | | - |
45 | | -Use `agent-ap <patch-file>`. Supply a valid UTF-8 patch beginning with `*** Begin Patch` at byte zero. The helper passes it directly to `codex.exe --codex-run-as-apply-patch` without an intermediate shell. |
46 | | - |
47 | | -Codex CLI discovery order is `CODEX_EXE`, `%LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe`, then `codex.exe` in `PATH`. |
48 | | - |
49 | | -## Check Git State |
50 | | - |
51 | | -Use `agent-status [repo]` for `git -C <repo> status --short`. |
52 | | - |
53 | | -Use `agent-diff [repo] [paths...]`. With no paths it prints `git diff --stat`; with paths it adds an argument-array `--` separator. |
54 | | - |
55 | | -## Run PowerShell |
56 | | - |
57 | | -Pipe Agent-authored scripts as literal here-strings to keep source out of command-line parsing: |
58 | | - |
59 | | -```powershell |
60 | | -@' |
61 | | -param([string]$Text) |
62 | | -$payload = '{"enabled":true}' |
63 | | -Write-Output "$Text $payload" |
64 | | -'@ | agent-ps -- -Text 'a|b & 中文 "quote"' |
65 | | -``` |
66 | | - |
67 | | -Use `agent-ps --file <script.ps1> [-- args...]` for existing files. Use direct `agent-ps '<script>'` only for trivial one-line scripts already represented by one caller argument. |
68 | | - |
69 | | -`agent-ps` requires `pwsh.exe` and always supplies `-NoProfile -ExecutionPolicy Bypass`. It validates piped UTF-8, uses a temporary `.ps1`, and removes matching temporary files older than one hour. It does not fall back to Windows PowerShell 5.1. |
70 | | - |
71 | | -## Safety And Dependencies |
72 | | - |
73 | | -- External processes receive argument arrays rather than `.cmd` forwarding. |
74 | | -- External processes join a `KILL_ON_JOB_CLOSE` Windows Job Object when available. |
75 | | -- Missing dependencies return 127; usage errors return 2; file and parse failures normally return 1. |
76 | | -- `agent-read` is self-contained. `agent-rg` requires `rg.exe`; Git commands require Git; `agent-ps` requires PowerShell 7; `agent-ap` requires Codex CLI. |
| 12 | +1. Edit `assets/global-agents.md` when changing the Agent-facing routine usage contract. |
| 13 | +2. Edit `scripts/agent-tools.go` and its tests when changing executable behavior. |
| 14 | +3. Keep `scripts/install.ps1` responsible for validating and installing the template, binaries, and skill files. |
| 15 | +4. Run the Go tests and the installation integration test. |
| 16 | +5. Reinstall from the repository root to deploy the updated binaries, skill metadata, and global reference. |
77 | 17 |
|
78 | 18 | ## Install |
79 | 19 |
|
80 | | -Run `pwsh -NoProfile -File scripts/install.ps1` from the repository root. The installer builds seven executable names, sets `AGENT_TOOLS_HOME`, installs the Skill under `%CODEX_HOME%\skills\agent-tools`, and updates the global `AGENTS.md` marker block. |
| 20 | +Run `pwsh -NoProfile -File scripts/install.ps1` from the repository root. The installer builds seven executable names, sets `AGENT_TOOLS_HOME`, installs the skill under `%CODEX_HOME%\skills\agent-tools`, and replaces the global `AGENTS.md` marker block from the validated template. |
81 | 21 |
|
82 | | -Standard layout: |
| 22 | +The installed skill contains: |
83 | 23 |
|
84 | 24 | ```text |
85 | | -%USERPROFILE%\.codex\bin\ |
86 | | - agent-tools.exe |
87 | | - agent-read.exe |
88 | | - agent-rg.exe |
89 | | - agent-ap.exe |
90 | | - agent-status.exe |
91 | | - agent-diff.exe |
92 | | - agent-ps.exe |
93 | | -
|
94 | 25 | %USERPROFILE%\.codex\skills\agent-tools\ |
95 | 26 | SKILL.md |
96 | 27 | agents\openai.yaml |
| 28 | + assets\global-agents.md |
97 | 29 | scripts\agent-tools.go |
98 | 30 | scripts\agent-tools_test.go |
99 | 31 | ``` |
| 32 | + |
| 33 | +Routine command syntax, read limits, output boundaries, PowerShell transport, and dependency behavior belong in the global reference, not duplicated here. |
0 commit comments