opencode-homebrew-agent 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +175 -0
  3. package/agents/brew.md +146 -0
  4. package/package.json +22 -0
  5. package/src/AGENTS.md +172 -0
  6. package/src/scripts/brew-analyze.sh +373 -0
  7. package/src/scripts/brew-deps.sh +140 -0
  8. package/src/scripts/brew-env.sh +288 -0
  9. package/src/scripts/brew-search.sh +150 -0
  10. package/src/scripts/brew-template.sh +263 -0
  11. package/src/scripts/package.json +21 -0
  12. package/src/skills/homebrew-agent/SKILL.md +203 -0
  13. package/src/skills/homebrew-tap/SKILL.md +97 -0
  14. package/src/templates/taps/01-full-ci/AGENTS.md +71 -0
  15. package/src/templates/taps/01-full-ci/tap-structure/.github/workflows/autobump.yml +24 -0
  16. package/src/templates/taps/01-full-ci/tap-structure/.github/workflows/publish.yml +33 -0
  17. package/src/templates/taps/01-full-ci/tap-structure/.github/workflows/tests.yml +33 -0
  18. package/src/templates/taps/01-full-ci/tap-structure/Formula/_formula.rb +31 -0
  19. package/src/templates/taps/01-full-ci/tap-structure/README.md +27 -0
  20. package/src/templates/taps/01-full-ci/tap-structure/cmd/.gitkeep +0 -0
  21. package/src/templates/taps/01-full-ci/tap-structure/formula_renames.json +1 -0
  22. package/src/templates/taps/01-full-ci/tap-structure/lib/.gitkeep +0 -0
  23. package/src/templates/taps/01-full-ci/tap-structure/require/.gitkeep +0 -0
  24. package/src/templates/taps/01-full-ci/tap-structure/tap_migrations.json +1 -0
  25. package/src/templates/taps/01-full-ci/template.md +45 -0
  26. package/src/templates/taps/02-root-level/AGENTS.md +72 -0
  27. package/src/templates/taps/02-root-level/tap-structure/README.md +27 -0
  28. package/src/templates/taps/02-root-level/tap-structure/_formula.rb +29 -0
  29. package/src/templates/taps/02-root-level/template.md +35 -0
  30. package/src/templates/taps/03-simple-script/AGENTS.md +71 -0
  31. package/src/templates/taps/03-simple-script/tap-structure/Formula/_formula.rb +27 -0
  32. package/src/templates/taps/03-simple-script/tap-structure/README.md +27 -0
  33. package/src/templates/taps/03-simple-script/tap-structure/scripts/release.rb +46 -0
  34. package/src/templates/taps/03-simple-script/template.md +41 -0
  35. package/src/templates/taps/04-python-venv/AGENTS.md +83 -0
  36. package/src/templates/taps/04-python-venv/tap-structure/Formula/_formula.rb +57 -0
  37. package/src/templates/taps/04-python-venv/tap-structure/README.md +27 -0
  38. package/src/templates/taps/04-python-venv/tap-structure/scripts/release.rb +44 -0
  39. package/src/templates/taps/04-python-venv/template.md +58 -0
  40. package/src/templates/taps/05-node-npm/AGENTS.md +90 -0
  41. package/src/templates/taps/05-node-npm/tap-structure/Formula/_formula.rb +46 -0
  42. package/src/templates/taps/05-node-npm/tap-structure/README.md +27 -0
  43. package/src/templates/taps/05-node-npm/tap-structure/scripts/release.rb +40 -0
  44. package/src/templates/taps/05-node-npm/template.md +74 -0
  45. package/src/templates/taps/06-keg-only/AGENTS.md +82 -0
  46. package/src/templates/taps/06-keg-only/tap-structure/Formula/_formula.rb +45 -0
  47. package/src/templates/taps/06-keg-only/tap-structure/README.md +27 -0
  48. package/src/templates/taps/06-keg-only/template.md +60 -0
  49. package/src/templates/taps/07-cask-only/AGENTS.md +97 -0
  50. package/src/templates/taps/07-cask-only/tap-structure/Casks/_app.rb +26 -0
  51. package/src/templates/taps/07-cask-only/tap-structure/README.md +27 -0
  52. package/src/templates/taps/07-cask-only/template.md +58 -0
  53. package/src/templates/taps/08-go-binary/AGENTS.md +86 -0
  54. package/src/templates/taps/08-go-binary/tap-structure/Formula/_formula.rb +40 -0
  55. package/src/templates/taps/08-go-binary/tap-structure/README.md +27 -0
  56. package/src/templates/taps/08-go-binary/tap-structure/scripts/release.rb +38 -0
  57. package/src/templates/taps/08-go-binary/template.md +60 -0
  58. package/src/workflows/analyze-source.sh +124 -0
  59. package/src/workflows/convert-npm-to-bun.sh +112 -0
  60. package/src/workflows/create-tap.sh +196 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bendz Gerona
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # homebrew-tap
2
+
3
+ A reference collection of Homebrew tap patterns, templates, and opencode agent for creating Homebrew formulae on Apple Silicon (aarch64-apple-darwin).
4
+
5
+ ---
6
+
7
+ ## Reference: How Homebrew Taps Work
8
+
9
+ A **tap** is a GitHub repo named `homebrew-<tapname>` under any user/org.
10
+ Users install it with `brew tap <user>/<tapname>`.
11
+
12
+ ```
13
+ GitHub repo -> brew tap -> local path
14
+ ─────────────────────────────────────────────────────────────
15
+ oven-sh/homebrew-bun -> brew tap oven-sh/bun -> /opt/homebrew/Library/Taps/oven-sh/homebrew-bun
16
+ bendzgerona/homebrew-litellm -> brew tap bendzgerona/litellm -> /opt/homebrew/Library/Taps/bendzgerona/homebrew-litellm
17
+ ```
18
+
19
+ ### Tap Structure Variants
20
+
21
+ | Pattern | Repo Name | `.github/workflows/` | `Formula/` dir | `scripts/` | Tap Template |
22
+ |---|---|---|---|---|---|
23
+ | Full CI suite | `homebrew-*` | ✅ tests+publish+autobump | ✅ subdir | optional | [01](./src/templates/taps/01-full-ci/) |
24
+ | Root-level `.rb` | `homebrew-*` | ❌ | ❌ `.rb` at root | ❌ | [02](./src/templates/taps/02-root-level/) |
25
+ | Simple + script | `homebrew-*` | ❌ | ✅ subdir | ✅ release.rb | [03](./src/templates/taps/03-simple-script/) |
26
+ | Python virtualenv | `homebrew-*` | optional | ✅ subdir | ✅ update-formula.rb | [04](./src/templates/taps/04-python-venv/) |
27
+ | JS Runtime (npm/bun) | `homebrew-*` | optional | ✅ subdir | optional | [05](./src/templates/taps/05-node-npm/) |
28
+ | Keg-only system tool | `homebrew-*` | optional | ✅ subdir | ❌ | [06](./src/templates/taps/06-keg-only/) |
29
+ | Cask-only | `homebrew-*` | optional | Casks/ subdir | ❌ | [07](./src/templates/taps/07-cask-only/) |
30
+ | Go binary | `homebrew-*` | optional | ✅ subdir | optional | [08](./src/templates/taps/08-go-binary/) |
31
+
32
+ ### Formula Location Rules
33
+
34
+ Homebrew finds formulae by scanning:
35
+ 1. `Formula/<formula>.rb` (subdirectory) — preferred for multi-formula taps
36
+ 2. `<formula>.rb` (root level) — acceptable for 1-2 formula taps
37
+ 3. `formula.rb`, `Formula/<formula>.rb`, or `HomebrewFormula/<formula>.rb` — all valid
38
+
39
+ ### Key Files in a Tap
40
+
41
+ | File | Purpose |
42
+ |---|---|
43
+ | `Formula/<name>.rb` | The formula definition (Ruby DSL) |
44
+ | `.github/workflows/tests.yml` | `brew test-bot` — CI for PRs/pushes |
45
+ | `.github/workflows/publish.yml` | `brew pr-pull` — publishes bottles from labeled PRs |
46
+ | `.github/workflows/autobump.yml` | Auto-update formula via `livecheck` |
47
+ | `scripts/release.rb` | Manual version bump script (bun pattern) |
48
+ | `LICENSE` | MIT (or other open-source license) |
49
+ | `README.md` | Install/upgrade/uninstall docs |
50
+ | `formula_renames.json` | Track renamed formulae for seamless upgrades |
51
+ | `tap_migrations.json` | Track formulae moved to other taps |
52
+
53
+ ---
54
+
55
+ ## Templates
56
+
57
+ Eight ready-to-use tap templates live under [`src/templates/taps/`](./src/templates/taps/).
58
+ Each includes a `template.md` reference, a `tap-structure/` skeleton with
59
+ copy-paste-ready file stubs (`.rb`, `.yml`, `.sh`), and an `AGENTS.md` agent
60
+ definition installable to `~/.config/opencode/agents/`.
61
+
62
+ To bootstrap a new tap: `cp -r src/templates/taps/<pattern>/tap-structure /path/to/homebrew-<name>/`
63
+ Or start with `brew tap-new <user>/homebrew-<tapname>` and overlay the template stubs on top.
64
+
65
+ | # | Template | Pattern | Best For |
66
+ |---|---|---|---|
67
+ | [01](./src/templates/taps/01-full-ci/) | Full CI suite | `gromgit/homebrew-fuse` | Multi-formula taps needing test-bot + bottle publishing |
68
+ | [02](./src/templates/taps/02-root-level/) | Root-level `.rb` | `yakitrak/homebrew-yakitrak` | 1-2 formula taps, minimal structure |
69
+ | [03](./src/templates/taps/03-simple-script/) | Simple + script | `oven-sh/homebrew-bun` | Single-formula taps with script-driven releases |
70
+ | [04](./src/templates/taps/04-python-venv/) | Python virtualenv | `bendzgerona/homebrew-litellm` | Python CLI tools with pip dependencies |
71
+ | [05](./src/templates/taps/05-node-npm/) | JS Runtime (npm/bun) | Personal npm- or bun-driven CLI taps | JS/TS CLI tools distributed via npm or bun |
72
+ | [06](./src/templates/taps/06-keg-only/) | Keg-only system tool | `homebrew-core` (gnuwhich) | System tool replacements shadowing macOS binaries |
73
+ | [07](./src/templates/taps/07-cask-only/) | Cask-only | Personal cask taps | macOS GUI apps (.app, .dmg, .pkg) |
74
+ | [08](./src/templates/taps/08-go-binary/) | Go binary | Modern CLI tools in Go | Go CLI tools built from source |
75
+
76
+ ---
77
+
78
+ ## Platform Requirements
79
+
80
+ This project is designed exclusively for **aarch64-apple-darwin** (Apple Silicon Macs).
81
+ All dependencies must be installed via **Homebrew**.
82
+
83
+ Required dependencies:
84
+ - `brew` — Homebrew (macOS package manager)
85
+ - `ruby-lsp` — Ruby LSP for formula DSL autocomplete
86
+ - `fish-lsp` — Fish shell LSP for shell scripts
87
+ - `bash-language-server` — Shell language server
88
+ - `shfmt` — Shell formatter
89
+ - `typos-lsp` — Typo checking
90
+
91
+ Install with:
92
+ ```sh
93
+ brew install ruby-lsp fish-lsp bash-language-server shfmt typos-lsp
94
+ ```
95
+
96
+ ---
97
+
98
+ ## brew sh Development Shell
99
+
100
+ All formula development should be done inside `brew sh` shells:
101
+
102
+ ```sh
103
+ brew sh --ruby # For writing/validating .rb files (brew's Ruby 4.0.5 + RuboCop)
104
+ brew sh # For testing formula installation (build environment)
105
+ ```
106
+
107
+ See the template `AGENTS.md` files for agent-level guidance on each pattern.
108
+
109
+ ---
110
+
111
+ ## Skills
112
+
113
+ Skills in each template's `AGENTS.md` teach AI agents how to work with
114
+ that tap pattern. They are designed to be copied to `~/.config/opencode/agents/`.
115
+
116
+ A root-level skill lives at [`src/skills/homebrew-tap/SKILL.md`](./src/skills/homebrew-tap/SKILL.md)
117
+ that teaches agents how to navigate the full template collection.
118
+ Each template also has its own `AGENTS.md` for pattern-specific agent guidance.
119
+
120
+ For the litellm tap specifically, see the [`lite-llm` skill](https://github.com/bendzgerona/homebrew-litellm).
121
+
122
+ ---
123
+
124
+ ## License
125
+
126
+ MIT
127
+
128
+ ---
129
+
130
+ ## Homebrew Agent Ecosystem
131
+
132
+ This project includes a complete AI-assisted Homebrew packaging ecosystem.
133
+
134
+ ### Quick Start
135
+
136
+ ```bash
137
+ # Analyze a project
138
+ bash src/workflows/analyze-source.sh --dir /path/to/project
139
+
140
+ # Create a tap
141
+ bash src/workflows/create-tap.sh \
142
+ --source /path/to/project \
143
+ --name MyCli \
144
+ --tap myuser/homebrew-mycli \
145
+ --output ./mytap \
146
+ --non-interactive
147
+
148
+ # Convert npm formula to bun
149
+ bash src/workflows/convert-npm-to-bun.sh --formula Formula/my-cli.rb --dry-run
150
+ ```
151
+
152
+ ### Agent Commands
153
+
154
+ | Command | Purpose |
155
+ |---------|---------|
156
+ | `homebrew:env` | Inspect brew environment |
157
+ | `homebrew:deps <formula>` | Show dependencies |
158
+ | `homebrew:search <query>` | Search packages |
159
+ | `homebrew:create <source>` | Create tap from source |
160
+ | `homebrew:analyze <source>` | Analyze project type |
161
+
162
+ To install the agent, link the assets in `src/` to `~/.config/opencode/`:
163
+ ```sh
164
+ ln -sf "$(pwd)/src/agents" ~/.config/opencode/agents/homebrew-tap
165
+ ln -sf "$(pwd)/src/commands" ~/.config/opencode/commands/homebrew-tap
166
+ ln -sf "$(pwd)/src/skills" ~/.config/opencode/skills/homebrew-tap
167
+ ```
168
+
169
+ ### Tool Scripts
170
+
171
+ All scripts in `src/scripts/` and `src/workflows/`:
172
+ - Environment inspection, dependency analysis, package search
173
+ - Source type detection (Go, Python, Node, Rust, etc.)
174
+ - Template scaffolding and formula generation
175
+ - npm to bun conversion
package/agents/brew.md ADDED
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: brew
3
+ description: >-
4
+ Homebrew packaging expert: inspect brew environments, analyze source code, recommend tap templates,
5
+ scaffold formula files, convert npm to bun, validate formulae. Installed taps via rust-mcp-filesystem and
6
+ Homebrew MCP server. Searches GitHub for upstream releases.
7
+ mode: primary
8
+ mcp:
9
+ - name: brew-mcp
10
+ type: local
11
+ command:
12
+ - /opt/homebrew/bin/brew
13
+ - mcp-server
14
+ enabled: true
15
+ - name: rust-mcp-filesystem
16
+ type: local
17
+ command:
18
+ - /Users/bendz/.local/share/cargo/bin/rust-mcp-filesystem
19
+ - -w
20
+ - -t
21
+ - /Users/bendz
22
+ - /opt/homebrew/Library/Taps
23
+ enabled: true
24
+ - name: github-mcp
25
+ type: local
26
+ command:
27
+ - /opt/homebrew/bin/github-mcp-server
28
+ - stdio
29
+ env:
30
+ GITHUB_PERSONAL_ACCESS_TOKEN: gho_5EgTmtq4Kh2Y5sq7rWJAXrJ9RBi5S0zsDqa
31
+ enabled: true
32
+ permission:
33
+ edit: allow
34
+ bash: allow
35
+ read: allow
36
+ glob: allow
37
+ grep: allow
38
+ list: allow
39
+ task: allow
40
+ lsp: allow
41
+ webfetch: allow
42
+ websearch: allow
43
+ external_directory:
44
+ /opt/homebrew/Library/Taps/**/*: allow
45
+ /opt/homebrew/**: allow
46
+ /Users/bendz/.config/opencode/**/*: allow
47
+ /Users/bendz/.local/share/opencode: allow
48
+ /Users/bendz/Projects/Opencode/homebrew-tap/**/*: allow
49
+ todowrite: allow
50
+ question: allow
51
+ ---
52
+
53
+ # Brew Agent
54
+
55
+ You are a Homebrew packaging expert. You help users inspect their brew environment, analyze source code, create tap structures, and validate formulae.
56
+
57
+ ## PROACTIVE BEHAVIOR
58
+
59
+ **DO NOT ask the user if they want to run a tool. Just run it.**
60
+
61
+ When the user says:
62
+ - "create a tap for [X]" → IMMEDIATELY run `bash src/workflows/create-tap.sh`
63
+ - "analyze [X]" → IMMEDIATELY run `bash src/workflows/analyze-source.sh`
64
+ - "what are the dependencies of [X]" → IMMEDIATELY run `bash src/scripts/brew-deps.sh`
65
+ - "search brew for [X]" → IMMEDIATELY run `bash src/scripts/brew-search.sh`
66
+ - "show my brew env" → IMMEDIATELY run `bash src/scripts/brew-env.sh`
67
+
68
+ ## MCP Servers Available
69
+
70
+ This agent has three MCP servers for enhanced functionality:
71
+
72
+ ### 1. rust-mcp-filesystem
73
+ - **Path**: `/Users/bendz/.local/share/cargo/bin/rust-mcp-filesystem`
74
+ - **Purpose**: Read/write access to Homebrew tap files. Use for:
75
+ - Reading existing formulae in local taps
76
+ - Writing new formula files to tap directories
77
+ - Browsing tap directory structures
78
+ - Modifying formula files
79
+
80
+ ### 2. brew mcp-server
81
+ - **Path**: `/opt/homebrew/bin/brew mcp-server`
82
+ - **Purpose**: Interact with Homebrew directly. Use for:
83
+ - Installing/uninstalling packages
84
+ - Running `brew info`, `brew deps`, `brew search`
85
+ - Running `brew style` and `brew audit` on formulae
86
+ - Managing taps, services, and packages
87
+
88
+ ### 3. github-mcp-server
89
+ - **Path**: `/opt/homebrew/bin/github-mcp-server stdio`
90
+ - **Env**: `GITHUB_PERSONAL_ACCESS_TOKEN` set via `gh auth token`
91
+ - **Purpose**: Search and read GitHub repositories. Use for:
92
+ - Finding latest releases of projects
93
+ - Reading repository metadata
94
+ - Searching GitHub for projects
95
+ - Getting release tags and artifacts
96
+
97
+ ## Tool Scripts
98
+
99
+ All tools are in the `src/scripts/` directory of this plugin package.
100
+ Run them via `bash src/scripts/<tool>.sh` from the package root.
101
+
102
+ | Command | Script | Purpose |
103
+ |---------|--------|---------|
104
+ | `bun run analyze -- --dir <path>` | `brew-analyze.sh` | Detect source type and recommend template |
105
+ | `bun run env` | `brew-env.sh` | Inspect brew environment |
106
+ | `bun run deps -- <formula>` | `brew-deps.sh` | Show formula dependencies |
107
+ | `bun run search -- <query>` | `brew-search.sh` | Search Homebrew packages |
108
+ | `bun run template <type>` | `brew-template.sh` | Scaffold tap template |
109
+ | `bun run build` | package.json | Build test to `dist/tests/` |
110
+
111
+ ## Default Behaviors
112
+
113
+ **Tap Creation:**
114
+ - If user doesn't specify `--output`, default to `./homebrew-<projectname>`
115
+ - Auto-generate formula name from project folder (kebab-case → CamelCase)
116
+ - Use `--non-interactive` mode to avoid prompts
117
+ - Always run `ruby -c` on the generated formula
118
+ - Validate with `brew style` and `brew audit`
119
+
120
+ **Source Analysis:**
121
+ - Accept local paths or GitHub URLs
122
+ - If unclear, assume it's a local path first, then GitHub URL
123
+
124
+ ## Workflow Patterns
125
+
126
+ 1. **Environment Inspection**: Run `bash src/scripts/brew-env.sh` with appropriate flags.
127
+ 2. **Dependency Analysis**: Run `bash src/scripts/brew-deps.sh` with the formula name.
128
+ 3. **Search**: Run `bash src/scripts/brew-search.sh` to find packages.
129
+ 4. **Source Analysis**: Run `bash src/workflows/analyze-source.sh` to determine project type.
130
+ 5. **Tap Creation**: Run `bash src/workflows/create-tap.sh` with appropriate args.
131
+ 6. **Formula Validation**: Validate with `ruby -c`, `brew style`, `brew audit`.
132
+ 7. **GitHub Release Lookup**: Use the github-mcp-server to find latest releases and download URLs.
133
+ 8. **Tap File Management**: Use rust-mcp-filesystem to create/modify formula files in `/opt/homebrew/Library/Taps/`.
134
+
135
+ ## Response Format
136
+
137
+ - Start with a brief summary of what was done
138
+ - Show key results in a clear format
139
+ - Provide next steps when relevant
140
+ - Use code blocks for commands and file paths
141
+
142
+ ## Error Handling
143
+
144
+ - If a command fails, show the error message and suggest fixes
145
+ - If a formula fails validation, show the specific error and how to fix it
146
+ - If a source cannot be analyzed, ask for clarification
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "opencode-homebrew-agent",
3
+ "version": "1.0.0",
4
+ "description": "Homebrew agent for OpenCode — analyze projects, scaffold formulae, validate packages on Apple Silicon",
5
+ "type": "module",
6
+ "private": false,
7
+ "license": "MIT",
8
+ "keywords": ["opencode", "opencode-plugin", "homebrew", "tap", "formula"],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/bendzgerona/opencode-homebrew-agent.git"
12
+ },
13
+ "files": [
14
+ "agents/",
15
+ "src/AGENTS.md",
16
+ "src/scripts/*.sh",
17
+ "src/scripts/package.json",
18
+ "src/workflows/",
19
+ "src/templates/",
20
+ "src/skills/"
21
+ ]
22
+ }
package/src/AGENTS.md ADDED
@@ -0,0 +1,172 @@
1
+ ---
2
+ description: >-
3
+ Homebrew tap pattern reference and template collection. Use when creating,
4
+ editing, or validating Homebrew formula (.rb), cask, and workflow (.yml)
5
+ files. Designed for the homebrew-tap project at bendzgerona/homebrew-tap.
6
+ mode: primary
7
+ permission:
8
+ edit: allow
9
+ bash: allow
10
+ read: allow
11
+ glob: allow
12
+ grep: allow
13
+ list: allow
14
+ task: allow
15
+ lsp: allow
16
+ webfetch: allow
17
+ websearch: allow
18
+ external_directory:
19
+ /opt/homebrew/Library/Taps/**/*: allow
20
+ /opt/homebrew/**/*: allow
21
+ /Users/bendz/.config/opencode/**/*: allow
22
+ todowrite: allow
23
+ question: allow
24
+ ---
25
+
26
+ # homebrew-tap Project Agent
27
+
28
+ You are working on the **homebrew-tap** template collection at
29
+ `/Users/bendz/Projects/Opencode/homebrew-tap/`.
30
+
31
+ ## Platform Constraint
32
+
33
+ This agent is designed exclusively for **aarch64-apple-darwin** (Apple Silicon Macs).
34
+ Do NOT run on Intel Macs (x86_64) or Linux. If `uname -m` is not `arm64`, abort.
35
+
36
+ All tool dependencies must be installed via **Homebrew**:
37
+ - `ruby-lsp` for Ruby DSL autocomplete (RBI stubs provided)
38
+ - `fish-lsp` for Fish shell scripts
39
+ - `bash-language-server` for Shell scripts
40
+ - `shfmt` for shell formatting
41
+ - `typos-lsp` for typo checking
42
+
43
+ ## Project Structure
44
+
45
+ ```
46
+ homebrew-tap/
47
+ ├── src/ # All project source code
48
+ │ ├── AGENTS.md # This file — agent instructions
49
+ │ ├── scripts/ # Tool scripts (brew-env, brew-deps, etc.)
50
+ │ ├── workflows/ # Workflow scripts (create-tap, analyze-source, etc.)
51
+ │ ├── templates/taps/ # 8 tap template patterns (01-full-ci through 08-go-binary)
52
+ │ ├── skills/ # OpenCode skills
53
+ │ │ ├── homebrew-tap/ # Root-level skill for the project
54
+ │ │ └── homebrew-agent/ # Homebrew agent skill
55
+ │ ├── agents/ # Agent definitions (homebrew-agent, homebrew-subagent)
56
+ │ └── commands/ # OpenCode commands (homebrew-env, homebrew-deps, etc.)
57
+ ├── README.md
58
+ ├── LICENSE
59
+ └── .gitignore
60
+ ```
61
+
62
+ ## LSP Setup
63
+
64
+ This project uses Ruby LSP for Homebrew formula DSL autocomplete:
65
+ - **ruby-lsp** — Shopify's Ruby LSP (RBI stubs in `.opencode/sorbet/rbi/`)
66
+ - **fish-lsp** — Fish shell LSP for shell scripts
67
+ - **bash-language-server** — Shell language server
68
+ - **typos-lsp** — Typo checking across all files
69
+
70
+ Before editing any `.rb` file, ensure LSP diagnostics are available:
71
+ ```sh
72
+ ruby-lsp --version # Verify Ruby LSP is installed
73
+ ```
74
+
75
+ After writing a formula, always run validation:
76
+ ```sh
77
+ ruby -c Formula/<formula>.rb
78
+ brew style --tap <user>/<tapname> Formula/<formula>.rb
79
+ brew audit --new-formula Formula/<formula>.rb
80
+ ```
81
+
82
+ ## Tool Use Rules
83
+
84
+ | Tool | Permission | Notes |
85
+ |---|---|---|
86
+ | `edit` | allow | Edit any file in the project |
87
+ | `bash` | allow | Run shell commands for validation |
88
+ | `read` | allow | Read any file |
89
+ | `glob`/`grep`/`list` | allow | Search and navigate |
90
+ | `task` | allow | Delegate work to subagents |
91
+ | `lsp` | allow | Use LSP diagnostics on formula files |
92
+ | `external_directory` | allow for /opt/homebrew and ~/.config/opencode | Access Homebrew core and opencode config |
93
+ | `webfetch`/`websearch` | allow | Research Homebrew docs and patterns |
94
+ | `todowrite` | allow | Track session progress |
95
+
96
+ ## Formula Validation Checklist
97
+
98
+ Before marking any formula work as done:
99
+ 1. [ ] `ruby-lsp` available (or editor LSP integration active)
100
+ 2. [ ] `ruby -c Formula/<formula>.rb` passes syntax check
101
+ 3. [ ] `brew style --tap <user>/<tapname> Formula/<formula>.rb` passes linting
102
+ 4. [ ] `brew audit --new-formula Formula/<formula>.rb` passes audit
103
+ 5. [ ] Class name matches filename in CamelCase
104
+ 6. [ ] `depends_on` ordering: build deps before runtime deps
105
+ 7. [ ] `version` and `sha256` fields present and correct
106
+ 8. [ ] `livecheck` block present for updateable formulae
107
+ 9. [ ] `test` block exercises at least the CLI entry point
108
+
109
+ ## Editor LSP Configuration
110
+
111
+ ### VSCode
112
+ Install the **Ruby LSP** extension (Shopify). Configure in `.vscode/settings.json`:
113
+ ```json
114
+ {
115
+ "rubyLsp.bundleGemfile": "Gemfile",
116
+ "rubyLsp.formatter": "rubocop",
117
+ "rubyLsp.linters": ["rubocop"],
118
+ "LSP": {
119
+ "ruby-lsp": { "enabled": true },
120
+ "fish-lsp": { "enabled": true }
121
+ }
122
+ }
123
+ ```
124
+
125
+ ### Zed
126
+ ```json
127
+ {
128
+ "lsp": {
129
+ "ruby-lsp": {
130
+ "initialization_options": {
131
+ "enabledFeatures": { "diagnostics": true, "formatting": true }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Homebrew Agent Ecosystem
141
+
142
+ This project includes a complete Homebrew agent ecosystem for AI-assisted tap development.
143
+
144
+ ### Agent: `@homebrew-agent`
145
+
146
+ The primary agent for Homebrew packaging tasks. Invoke with `@homebrew-agent` or via commands.
147
+
148
+ ### Commands
149
+
150
+ | Command | Purpose | Example |
151
+ |---------|---------|---------|
152
+ | `homebrew:env` | Inspect brew environment | `homebrew:env --json` |
153
+ | `homebrew:deps` | Show formula dependencies | `homebrew:deps git` |
154
+ | `homebrew:search` | Search formulae/casks | `homebrew:search python` |
155
+ | `homebrew:create` | Create tap from source | `homebrew:create --source /path/to/project` |
156
+ | `homebrew:analyze` | Analyze source type | `homebrew:analyze --dir /path/to/project` |
157
+
158
+ ### Tool Scripts
159
+
160
+ Located in `src/scripts/`:
161
+ - `brew-env.sh` — Environment inspection
162
+ - `brew-deps.sh` — Dependency analysis
163
+ - `brew-search.sh` — Package search
164
+ - `brew-analyze.sh` — Source type detection
165
+ - `brew-template.sh` — Template application
166
+
167
+ ### Workflow Scripts
168
+
169
+ Located in `src/workflows/`:
170
+ - `create-tap.sh` — End-to-end tap creation
171
+ - `analyze-source.sh` — Rich analysis report
172
+ - `convert-npm-to-bun.sh` — npm to bun conversion