|
1 | 1 | # /setup-fast-tools |
2 | 2 |
|
3 | | -Append the project’s fast-tools prompt to `AGENTS.md` without attempting to install any system packages. This avoids requiring `sudo`. |
4 | | - |
5 | | -What this does: |
6 | | - |
7 | | -- Detects `AGENTS.md` and `cdx/agents/fast-tools.md` (or `agents/fast-tools.md`) in the current repo. |
8 | | -- Checks for the `FAST-TOOLS PROMPT v1` watermark to avoid duplicates. |
9 | | -- Appends the prompt if not already present. |
10 | | - |
11 | | -It does not install `ripgrep`, `fd`/`fdfind`, or `jq`. If you need those tools, install them separately using your OS package manager (see brief guidance inside `cdx/agents/fast-tools.md`). |
12 | | - |
13 | | -Run this minimal, no-sudo snippet: |
| 3 | +Append the fast-tools prompt from `./cdx/agents/fast-tools.md` into `./AGENTS.md` for the current working directory whenever it is missing. |
14 | 4 |
|
15 | 5 | ```bash |
16 | 6 | set -euo pipefail |
17 | 7 |
|
18 | | -# Find repo root (or stay in CWD if not a git repo) |
19 | | -repo_root=$(git rev-parse --show-toplevel 2>/dev/null || pwd) |
20 | | -agents="$repo_root/AGENTS.md" |
21 | | -if [ -f "$repo_root/cdx/agents/fast-tools.md" ]; then |
22 | | - prompt_src="$repo_root/cdx/agents/fast-tools.md" |
23 | | -elif [ -f "$repo_root/agents/fast-tools.md" ]; then |
24 | | - prompt_src="$repo_root/agents/fast-tools.md" |
25 | | -else |
26 | | - echo "Prompt file missing under cdx/agents or agents in $repo_root" >&2 |
27 | | - exit 1 |
28 | | -fi |
| 8 | +cwd=$(pwd) |
| 9 | +prompt_src="$cwd/cdx/agents/fast-tools.md" |
| 10 | +agents="$cwd/AGENTS.md" |
29 | 11 |
|
30 | | -if [ ! -f "$agents" ]; then |
31 | | - echo "AGENTS.md not found under $repo_root" >&2 |
32 | | - exit 1 |
33 | | -fi |
34 | 12 | if [ ! -f "$prompt_src" ]; then |
35 | | - echo "Prompt file missing: $prompt_src" >&2 |
| 13 | + echo "Missing $prompt_src" >&2 |
36 | 14 | exit 1 |
37 | 15 | fi |
38 | 16 |
|
39 | | -# Avoid duplicates using rg if available, otherwise grep |
40 | | -if command -v rg >/dev/null 2>&1; then |
41 | | - if rg -q "FAST-TOOLS PROMPT v1" "$agents"; then |
42 | | - echo "FAST-TOOLS prompt already present — nothing to do." |
| 17 | +if [ -f "$agents" ]; then |
| 18 | + if command -v rg >/dev/null 2>&1; then |
| 19 | + if rg -q "FAST-TOOLS PROMPT v1" "$agents"; then |
| 20 | + echo "FAST-TOOLS prompt already present." |
| 21 | + exit 0 |
| 22 | + fi |
| 23 | + elif grep -q "FAST-TOOLS PROMPT v1" "$agents"; then |
| 24 | + echo "FAST-TOOLS prompt already present." |
43 | 25 | exit 0 |
44 | 26 | fi |
45 | 27 | else |
46 | | - if grep -q "FAST-TOOLS PROMPT v1" "$agents"; then |
47 | | - echo "FAST-TOOLS prompt already present — nothing to do." |
48 | | - exit 0 |
49 | | - fi |
| 28 | + touch "$agents" |
50 | 29 | fi |
51 | 30 |
|
52 | | -printf "\n\n" >> "$agents" |
53 | | -cat "$prompt_src" >> "$agents" |
54 | | -echo "Appended fast-tools prompt to AGENTS.md" |
55 | | -``` |
56 | | - |
57 | | -## Quick Setup Script |
58 | | - |
59 | | -Tell the user to that they need to install dependencies / third party tools after the prompt is appended to AGENTS.md, which they can utilise the following prompts for. |
60 | | - |
61 | | -```bash |
62 | | -# Append prompt (idempotent) |
63 | | -bash cdx/scripts/setup-fast-tools.sh |
| 31 | +if [ -s "$agents" ]; then |
| 32 | + printf "\n\n" >> "$agents" |
| 33 | +fi |
64 | 34 |
|
65 | | -# Append and install ripgrep/fd/jq (best effort) |
66 | | -bash cdx/scripts/setup-fast-tools.sh --install-deps |
| 35 | +cat "$prompt_src" >> "$agents" |
| 36 | +echo "Appended fast-tools prompt to $agents" |
67 | 37 | ``` |
68 | | - |
69 | | -Notes: |
70 | | - |
71 | | -- Non-interactive envs can add `--non-interactive` or `--dry-run` to print commands. |
72 | | -- Debian/Ubuntu may provide `fdfind` instead of `fd` (use `alias fd=fdfind`). |
0 commit comments