@sofatutor/agent-bridge 0.13.1
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.
- package/README.md +231 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +1648 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Agent Bridge
|
|
2
|
+
|
|
3
|
+
A CLI tool that syncs AI agent configurations (skills, agents, prompts, ...etc.) from shared sources into your project's tool directories (`.github/`, `.cursor/`, `.claude/`, ..etc.).
|
|
4
|
+
|
|
5
|
+
### Why Agent Bridge?
|
|
6
|
+
|
|
7
|
+
As teams adopt AI coding tools, agent instructions quickly scatter across projects with no shared structure. Agent Bridge solves this by letting you **centralize and distribute** AI agent features across any number of projects, teams, and repositories — using **conventions over configuration**, with no manifests or mapping files required.
|
|
8
|
+
|
|
9
|
+
- **Convention over configuration** — features are discovered from the filesystem automatically. No manifests, no mapping files — just organize by domain and feature type.
|
|
10
|
+
- **Tool-agnostic, tool-aware** — syncs to all configured tools by default, while the `<tool>--` prefix convention lets you target features to specific tools (VS Code, Cursor, Claude Code, or custom tools) when needed.
|
|
11
|
+
- **Extensible** — not limited to skills, agents, prompts, or instructions. Any new feature type that tools introduce is automatically supported — just add a folder to your source.
|
|
12
|
+
- **Multiple sources** — pull from any combination of Git repositories (HTTPS/SSH) and local paths. Mix company-wide standards with team-specific or project-specific sources.
|
|
13
|
+
- **Multi-domain organization** — structure features by domain (`backend`, `frontend`, `shared`, or your own) so each project pulls only what it needs.
|
|
14
|
+
- **Non-destructive** — previously defined skills, agents, prompts, and other tool files are **never** touched, modified, or deleted.
|
|
15
|
+
|
|
16
|
+
## Prerequisites
|
|
17
|
+
|
|
18
|
+
- Git (optional — needed only for remote sources)
|
|
19
|
+
- Node.js ≥ 18
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g @sofatutor/agent-bridge
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or install locally as a dev dependency:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install --save-dev @sofatutor/agent-bridge
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Or run directly with `npx`:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx @sofatutor/agent-bridge init
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
### 1. Initialize
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
agent-bridge init
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The interactive init flow will:
|
|
48
|
+
1. Ask which domains to use (e.g. `backend`, `frontend`, `shared`).
|
|
49
|
+
2. Ask which tools to configure — choose from well-known presets (VS Code, Cursor, Claude) or add custom tools.
|
|
50
|
+
3. Ask for sources — Git repos (HTTPS/SSH) or local paths, with optional branch.
|
|
51
|
+
4. Generate `.agent-bridge/config.yml`.
|
|
52
|
+
5. Clone any remote sources.
|
|
53
|
+
6. Create `.agent-bridge/.gitignore` (ignores cloned repos, keeps config).
|
|
54
|
+
7. Optionally install git hooks to auto-sync on checkout/merge.
|
|
55
|
+
|
|
56
|
+
#### Non-Interactive Mode
|
|
57
|
+
|
|
58
|
+
Pass `--tools` and `--source` to skip all prompts:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
agent-bridge init \
|
|
62
|
+
--tools cursor,vscode,claude \
|
|
63
|
+
--source https://github.com/org/repo.git#main
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Multiple sources and custom tools are supported:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
agent-bridge init \
|
|
70
|
+
--domains shared,backend \
|
|
71
|
+
--tools cursor,windsurf:.windsurf \
|
|
72
|
+
--source https://github.com/org/repo.git#main \
|
|
73
|
+
--source /local/path \
|
|
74
|
+
--hooks
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
| Option | Description |
|
|
78
|
+
| ------------------- | ---------------------------------------------------------------------------------------- |
|
|
79
|
+
| `--tools <list>` | Comma-separated tool names (`cursor`, `vscode`, `claude`) or `name:folder` pairs |
|
|
80
|
+
| `-s, --source <url>`| Source URL or path (repeatable). Append `#branch` for a specific branch |
|
|
81
|
+
| `--domains <list>` | Comma-separated domain list (default: `backend,frontend,shared`) |
|
|
82
|
+
| `--hooks` | Auto-install git hooks without prompting |
|
|
83
|
+
|
|
84
|
+
After init, commit `.agent-bridge/config.yml` to your repo.
|
|
85
|
+
|
|
86
|
+
### 2. Sync
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
agent-bridge sync
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Fetches remote sources, discovers features, and copies them into your tool folders.
|
|
93
|
+
|
|
94
|
+
Run this whenever:
|
|
95
|
+
- A source repository has new or changed features.
|
|
96
|
+
- You add, rename, or remove sources in `config.yml`.
|
|
97
|
+
- You change tool or domain configuration.
|
|
98
|
+
|
|
99
|
+
### 3. Update
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
agent-bridge update
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Pulls the latest changes from all remote sources. Local sources require no update.
|
|
106
|
+
|
|
107
|
+
After updating, run `agent-bridge sync` to reconcile features.
|
|
108
|
+
|
|
109
|
+
### 4. Opt Out
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
agent-bridge opt-out
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`opt-out` is non-interactive and removes Agent Bridge from the current repository by:
|
|
116
|
+
- Removing synced feature and tool-root entries tracked in `.agentbridge` manifests
|
|
117
|
+
- Removing Agent Bridge-managed git hooks (`post-checkout`, `post-merge`)
|
|
118
|
+
- Removing `config.yml` and cloned sources from `.agent-bridge/`
|
|
119
|
+
- Leaving a `.agent-bridge/optout` tombstone behind so a `postinstall` guard won't silently reinstall
|
|
120
|
+
|
|
121
|
+
Notes:
|
|
122
|
+
- Root files like `AGENTS.md`, `CLAUDE.md`, and `SYSTEM.md` are not removed by `opt-out`.
|
|
123
|
+
- Existing non-Agent-Bridge hooks are preserved.
|
|
124
|
+
- The tombstone lives at `.agent-bridge/optout` and is **gitignored by default**, so opt-out is local to your machine. Force-add it (`git add -f .agent-bridge/optout`) to commit a repo-wide opt-out.
|
|
125
|
+
- While the tombstone exists, `agent-bridge init` and `agent-bridge sync` are no-ops.
|
|
126
|
+
- To re-enable, run `agent-bridge init --force` (which clears the tombstone) or delete `.agent-bridge/optout`.
|
|
127
|
+
|
|
128
|
+
#### Opting out with a `postinstall` hook
|
|
129
|
+
|
|
130
|
+
If a project auto-installs Agent Bridge via `postinstall`, guard it on `.agent-bridge`:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
"postinstall": "test -d .agent-bridge || (npx agent-bridge init --domains … --tools … --source … --hooks && npx agent-bridge sync) || true"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Because `opt-out` keeps the `.agent-bridge/` directory (holding only the tombstone), `test -d .agent-bridge` stays true after opting out and the guard short-circuits — nothing is reinstalled. If your guard invokes `init`/`sync` directly instead, they still no-op on the tombstone.
|
|
137
|
+
|
|
138
|
+
## Git Hooks (Auto-Sync)
|
|
139
|
+
|
|
140
|
+
When running `agent-bridge init` inside a Git repository, you'll be prompted to install git hooks that automatically keep your AI agent configurations up to date. If enabled, Agent Bridge installs:
|
|
141
|
+
|
|
142
|
+
- **post-checkout** — runs after `git checkout` (switching branches)
|
|
143
|
+
- **post-merge** — runs after `git merge` or `git pull`
|
|
144
|
+
|
|
145
|
+
These hooks run `agent-bridge update && agent-bridge sync` in the background, so your workflow isn't blocked.
|
|
146
|
+
|
|
147
|
+
### How It Works
|
|
148
|
+
|
|
149
|
+
The hooks execute asynchronously with a short delay to let Git complete its operations. They:
|
|
150
|
+
1. Check if `agent-bridge` is available globally
|
|
151
|
+
2. Fall back to `npx @sofatutor/agent-bridge` if not
|
|
152
|
+
3. Run update and sync silently in the background
|
|
153
|
+
|
|
154
|
+
### Skipping Existing Hooks
|
|
155
|
+
|
|
156
|
+
If you already have custom `post-checkout` or `post-merge` hooks, Agent Bridge will skip them to avoid conflicts. You can manually integrate Agent Bridge into your existing hooks by adding:
|
|
157
|
+
|
|
158
|
+
```sh
|
|
159
|
+
# At the end of your existing hook
|
|
160
|
+
(
|
|
161
|
+
sleep 1
|
|
162
|
+
agent-bridge update && agent-bridge sync
|
|
163
|
+
) >/dev/null 2>&1 &
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Removing Hooks
|
|
167
|
+
|
|
168
|
+
Agent Bridge marks its hooks with a special comment.
|
|
169
|
+
|
|
170
|
+
Recommended: run `agent-bridge opt-out` to remove Agent Bridge-managed hooks and state.
|
|
171
|
+
|
|
172
|
+
Manual alternative: delete the hook files:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
rm .git/hooks/post-checkout .git/hooks/post-merge
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Or re-run `agent-bridge init` — Agent Bridge hooks are automatically updated on re-init.
|
|
179
|
+
|
|
180
|
+
## CLI Commands
|
|
181
|
+
|
|
182
|
+
| Command | Description |
|
|
183
|
+
| --------------------- | ------------------------------------------------------ |
|
|
184
|
+
| `agent-bridge init` | Interactive setup — creates `.agent-bridge/config.yml` (supports [non-interactive mode](#non-interactive-mode)) |
|
|
185
|
+
| `agent-bridge sync` | Fetch sources, discover features, reconcile files |
|
|
186
|
+
| `agent-bridge update` | Fetch latest changes for all remote sources |
|
|
187
|
+
| `agent-bridge opt-out`| Non-interactive cleanup of Agent Bridge-managed state |
|
|
188
|
+
|
|
189
|
+
### Global Options
|
|
190
|
+
|
|
191
|
+
| Option | Description |
|
|
192
|
+
| -------------- | ---------------------------------------------------------------------------------------- |
|
|
193
|
+
| `--cwd <path>` | Override the working directory. Defaults to the Git root, or `cwd` if not in a Git repo. |
|
|
194
|
+
|
|
195
|
+
Examples:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Run sync for a specific project in a monorepo
|
|
199
|
+
agent-bridge sync --cwd ./packages/api
|
|
200
|
+
|
|
201
|
+
# Point at a project outside the current directory
|
|
202
|
+
agent-bridge sync --cwd /path/to/my-project
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Documentation
|
|
206
|
+
|
|
207
|
+
- [Configuration](docs/configuration.md) — config file reference, fields, source types
|
|
208
|
+
- [Conventions](docs/conventions.md) — source directory structure, tool-prefix routing, authoring features
|
|
209
|
+
- [Sync Strategy](docs/sync-strategy.md) — marker files, project structure after sync, cleanup behavior
|
|
210
|
+
|
|
211
|
+
## Troubleshooting
|
|
212
|
+
|
|
213
|
+
| Symptom | Fix |
|
|
214
|
+
| ---------------------------- | -------------------------------------------------------------------- |
|
|
215
|
+
| `config.yml not found` | Run `agent-bridge init` from the repo root |
|
|
216
|
+
| Source clone failed | Check the Git URL and your SSH/HTTPS credentials |
|
|
217
|
+
| Duplicate feature name error | Rename one of the conflicting features across sources |
|
|
218
|
+
| Local source path not found | Verify the path in `config.yml` is correct relative to the repo root |
|
|
219
|
+
| Path conflict error | A non-managed folder exists at the destination — rename or remove it |
|
|
220
|
+
| Git hooks not installed | Run `agent-bridge init` from inside a Git repository |
|
|
221
|
+
| Hooks skipped (existing) | Existing non-Agent-Bridge hooks are preserved; integrate manually |
|
|
222
|
+
| Remove Agent Bridge from repo| Run `agent-bridge opt-out` |
|
|
223
|
+
|
|
224
|
+
## Development
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
npm install
|
|
228
|
+
npm run build # Package the CLI with Vite+
|
|
229
|
+
npm test # Run all tests
|
|
230
|
+
npm run test:watch # Watch mode
|
|
231
|
+
```
|
package/dist/index.d.mts
ADDED