Skip to content

Commit bc50495

Browse files
committed
feat: Initial commit of Codex CLI Extensions (cdx) with comprehensive project structure, installation scripts, and plugin management
- Added entrypoint script `cdx/cdx.sh` for command routing and plugin execution. - Implemented installation script `cdx/install.sh` for setting up the CLI in user environments. - Created plugin scripts for profiles, prompts, updates, and resume functionalities. - Introduced fast-tools prompt management in `cdx/agents/fast-tools.md`. - Established smoke test script `cdx/smoke-test.sh` for validating installation and functionality. - Documented repository guidelines and usage instructions in `AGENTS.md` and `README.md`. - Added support for managing custom prompts and dependencies installation.
0 parents  commit bc50495

12 files changed

Lines changed: 1011 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
- `cdx/cdx.sh` — entrypoint; sources a `cdx` shell function and `cx` alias.
5+
- `cdx/plugins/` — subcommands invoked as `cdx <name>` (e.g., `profiles.sh`, `prompts.sh`, `update.sh`).
6+
- `cdx/prompts/` — optional prompt files (Markdown). See `cdx/plugins/prompts.sh`.
7+
- `cdx/agents/fast-tools.md` — reusable prompt to append to this file.
8+
- `cdx/scripts/` — utility scripts (e.g., `setup-fast-tools.sh`).
9+
- `cdx/install.sh`, `cdx/smoke-test.sh` — installer and health check.
10+
Note: When embedding in another repo, `tools/cdx/**` is the recommended path. Set `REPO_PROMPTS_DIR` to override prompt source if layouts differ.
11+
12+
## Build, Test, and Development Commands
13+
- Load locally: `source cdx/cdx.sh && cdx help` (defines `cdx` in your shell).
14+
- Smoke test: `bash cdx/smoke-test.sh` (verifies sourcing, plugins, prompts, update check).
15+
- Install to shell: `bash cdx/install.sh [--with-prompts]`.
16+
- Update Codex CLI: `cdx update --check-only` or `cdx update [--sudo]`.
17+
- Prompts: `cdx prompts list``cdx prompts install``cdx prompts path`.
18+
- Profiles: `cdx profiles` or `cdx profiles --quiet`.
19+
20+
## Coding Style & Naming Conventions
21+
- Bash with `set -euo pipefail`; 2‑space indent; quote variables; prefer arrays.
22+
- Functions/locals: `snake_case`; env: `SCREAMING_SNAKE_CASE` (e.g., `CODEX_BIN`).
23+
- Prefer `printf` over `echo -e` and explicit `return`/exit codes.
24+
- Plugins live in `cdx/plugins/<name>.sh` and are invoked as `cdx <name>`.
25+
26+
## Testing Guidelines
27+
- Lint: `shellcheck cdx/**/*.sh` (aim for zero warnings).
28+
- Format: `shfmt -i 2 -sr -w cdx`.
29+
- Syntax check: `bash -n cdx/**/*.sh`.
30+
- Keep `cdx/smoke-test.sh` green; add focused tests near changed scripts when practical.
31+
32+
## Commit & Pull Request Guidelines
33+
- No history exists yet; use Conventional Commits (e.g., `feat:`, `fix:`, `docs:`).
34+
- PRs should describe behavior, list key commands/output, and link issues.
35+
- Update `README.md`/`--help` text when CLI surfaces change; include before/after examples.
36+
37+
## Agent-Specific Instructions
38+
- For repo-wide search, use `rg` (ripgrep) and `fd/fdfind`; avoid `grep/find`.
39+
- Cap file reads at ~250 lines; prefer `rg -n -A3 -B3` for context.
40+
- Use `jq` for JSON parsing.
41+
- Append the fast-tools prompt (idempotent): `bash cdx/scripts/setup-fast-tools.sh [--install-deps]`.
42+

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Codex CLI Extensions (cdx)
2+
3+
![Bash](https://img.shields.io/badge/Bash-4%2B-1f425f?logo=gnu-bash&logoColor=white)
4+
![OS](https://img.shields.io/badge/OS-macOS%20%7C%20Linux-lightgrey)
5+
![Type](https://img.shields.io/badge/Type-CLI%20Helpers-blue)
6+
7+
Lightweight, POSIX‑friendly helpers that enhance the Codex CLI with a single entrypoint, plugin routing, prompt management, and a quick smoke test. Use directly or vendor under `tools/cdx/` in your own repo.
8+
9+
## Why cdx
10+
- Fast: source one file and get a tidy `cdx` wrapper + `cx` alias.
11+
- Extensible: drop scripts in `cdx/plugins/` and call `cdx <name>`.
12+
- Practical: ship prompts and install them to `~/.codex/prompts`.
13+
- Safe: smoke test validates sourcing, plugins, and update checks.
14+
15+
## Quick Start
16+
- From this repo (local install):
17+
```bash
18+
# Add cdx to your shell
19+
bash cdx/install.sh --with-prompts # optional: copies prompts
20+
# Or for a temporary session
21+
source cdx/cdx.sh && cdx help
22+
```
23+
- One‑liner (template for vendored copies):
24+
```bash
25+
# Replace OWNER/REPO/BRANCH with your values
26+
bash <(curl -fsSL https://raw.githubusercontent.com/OWNER/REPO/BRANCH/tools/cdx/install.sh) --with-prompts
27+
```
28+
29+
## Usage
30+
```bash
31+
cdx help # usage and discovered plugins
32+
cdx plugins # list subcommands from cdx/plugins/
33+
cdx prompts list # show repo and installed prompts
34+
cdx prompts install # install prompts to ~/.codex/prompts
35+
cdx profiles # list profiles from ~/.codex/config.toml
36+
cdx update --check-only # check Codex CLI updates (uses npm)
37+
cdx -- --profile NAME # pass through to codex with defaults
38+
cdx raw <args> # run codex without defaults
39+
```
40+
41+
## Repo at a Glance
42+
```text
43+
cdx/
44+
cdx.sh # entrypoint defines `cdx` and alias `cx`
45+
plugins/ # profiles.sh, prompts.sh, update.sh, resume.sh
46+
prompts/ # optional Markdown prompts
47+
agents/ # reusable prompts (e.g., fast-tools.md)
48+
scripts/ # setup-fast-tools.sh and utilities
49+
smoke-test.sh # non-destructive health check
50+
```
51+
52+
## Repository Layout
53+
- `cdx/cdx.sh` — entrypoint defining the `cdx` function and `cx` alias.
54+
- `cdx/plugins/` — subcommands (`profiles.sh`, `prompts.sh`, `update.sh`, `resume.sh`).
55+
- `cdx/prompts/` — optional Markdown prompts for Codex.
56+
- `cdx/agents/fast-tools.md` — reusable prompt you can append to `AGENTS.md`.
57+
- `cdx/scripts/` — utilities (e.g., `setup-fast-tools.sh`).
58+
- `cdx/smoke-test.sh` — non‑destructive health check.
59+
60+
## Embed In Your Repo
61+
Vendor as `tools/cdx/**` and call the installer from your repo root:
62+
```bash
63+
bash tools/cdx/install.sh --with-prompts
64+
```
65+
If your prompts live elsewhere, set `REPO_PROMPTS_DIR=/path/to/prompts` before running `cdx prompts`.
66+
67+
> Tip: Append the fast‑tools prompt to `AGENTS.md` with `bash cdx/scripts/setup-fast-tools.sh` (idempotent; add `--install-deps` to install rg/fd/jq).
68+
69+
## Requirements & Troubleshooting
70+
- Bash 4+, macOS/Linux; Windows via WSL or Git Bash.
71+
- `npm` optional (only for `cdx update`). If `codex` is not on PATH after update, check `npm prefix -g` and your shell rc file.
72+
73+
## Contributing
74+
See `AGENTS.md` for style, testing, and PR conventions. Please keep the smoke test green: `bash cdx/smoke-test.sh`.
75+
76+
77+
Quick links: `AGENTS.md` · `cdx/README.md`

cdx/agents/fast-tools.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!-- FAST-TOOLS PROMPT v1 | codex-mastery | watermark:do-not-alter -->
2+
3+
## CRITICAL: Use ripgrep, not grep
4+
5+
NEVER use grep for project-wide searches (slow, ignores .gitignore). ALWAYS use rg.
6+
7+
- `rg "pattern"` — search content
8+
- `rg --files | rg "name"` — find files
9+
- `rg -t python "def"` — language filters
10+
11+
## File finding
12+
13+
- Prefer `fd` (or `fdfind` on Debian/Ubuntu). Respects .gitignore.
14+
15+
## JSON
16+
17+
- Use `jq` for parsing and transformations.
18+
19+
## Install Guidance
20+
21+
- macOS: `brew install ripgrep fd jq`
22+
- Debian/Ubuntu: `sudo apt update && sudo apt install -y ripgrep fd-find jq` (alias `fd=fdfind`)
23+
24+
## Agent Instructions
25+
26+
- Replace commands: grep→rg, find→rg --files/fd, ls -R→rg --files, cat|grep→rg pattern file
27+
- Cap reads at 250 lines; prefer `rg -n -A 3 -B 3` for context
28+
- Use `jq` for JSON instead of regex
29+
30+
<!-- END FAST-TOOLS PROMPT v1 | codex-mastery -->

0 commit comments

Comments
 (0)