@googlarz/agents-sync 1.4.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 (186) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +507 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +267 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/config/loader.d.ts +9 -0
  8. package/dist/config/loader.d.ts.map +1 -0
  9. package/dist/config/loader.js +55 -0
  10. package/dist/config/loader.js.map +1 -0
  11. package/dist/config/schema.d.ts +69 -0
  12. package/dist/config/schema.d.ts.map +1 -0
  13. package/dist/config/schema.js +33 -0
  14. package/dist/config/schema.js.map +1 -0
  15. package/dist/derivers/aider.d.ts +19 -0
  16. package/dist/derivers/aider.d.ts.map +1 -0
  17. package/dist/derivers/aider.js +117 -0
  18. package/dist/derivers/aider.js.map +1 -0
  19. package/dist/derivers/claude.d.ts +19 -0
  20. package/dist/derivers/claude.d.ts.map +1 -0
  21. package/dist/derivers/claude.js +93 -0
  22. package/dist/derivers/claude.js.map +1 -0
  23. package/dist/derivers/cline.d.ts +17 -0
  24. package/dist/derivers/cline.d.ts.map +1 -0
  25. package/dist/derivers/cline.js +92 -0
  26. package/dist/derivers/cline.js.map +1 -0
  27. package/dist/derivers/copilot.d.ts +16 -0
  28. package/dist/derivers/copilot.d.ts.map +1 -0
  29. package/dist/derivers/copilot.js +162 -0
  30. package/dist/derivers/copilot.js.map +1 -0
  31. package/dist/derivers/cursor.d.ts +16 -0
  32. package/dist/derivers/cursor.d.ts.map +1 -0
  33. package/dist/derivers/cursor.js +121 -0
  34. package/dist/derivers/cursor.js.map +1 -0
  35. package/dist/derivers/gemini.d.ts +19 -0
  36. package/dist/derivers/gemini.d.ts.map +1 -0
  37. package/dist/derivers/gemini.js +33 -0
  38. package/dist/derivers/gemini.js.map +1 -0
  39. package/dist/derivers/index.d.ts +33 -0
  40. package/dist/derivers/index.d.ts.map +1 -0
  41. package/dist/derivers/index.js +134 -0
  42. package/dist/derivers/index.js.map +1 -0
  43. package/dist/derivers/merger.d.ts +36 -0
  44. package/dist/derivers/merger.d.ts.map +1 -0
  45. package/dist/derivers/merger.js +83 -0
  46. package/dist/derivers/merger.js.map +1 -0
  47. package/dist/derivers/roo.d.ts +18 -0
  48. package/dist/derivers/roo.d.ts.map +1 -0
  49. package/dist/derivers/roo.js +92 -0
  50. package/dist/derivers/roo.js.map +1 -0
  51. package/dist/derivers/windsurf.d.ts +16 -0
  52. package/dist/derivers/windsurf.d.ts.map +1 -0
  53. package/dist/derivers/windsurf.js +91 -0
  54. package/dist/derivers/windsurf.js.map +1 -0
  55. package/dist/extractor/extractor.d.ts +4 -0
  56. package/dist/extractor/extractor.d.ts.map +1 -0
  57. package/dist/extractor/extractor.js +125 -0
  58. package/dist/extractor/extractor.js.map +1 -0
  59. package/dist/extractor/schema.d.ts +187 -0
  60. package/dist/extractor/schema.d.ts.map +1 -0
  61. package/dist/extractor/schema.js +44 -0
  62. package/dist/extractor/schema.js.map +1 -0
  63. package/dist/generator/agents-md.d.ts +6 -0
  64. package/dist/generator/agents-md.d.ts.map +1 -0
  65. package/dist/generator/agents-md.js +135 -0
  66. package/dist/generator/agents-md.js.map +1 -0
  67. package/dist/generator/validator.d.ts +7 -0
  68. package/dist/generator/validator.d.ts.map +1 -0
  69. package/dist/generator/validator.js +67 -0
  70. package/dist/generator/validator.js.map +1 -0
  71. package/dist/lib/claude-client.d.ts +11 -0
  72. package/dist/lib/claude-client.d.ts.map +1 -0
  73. package/dist/lib/claude-client.js +74 -0
  74. package/dist/lib/claude-client.js.map +1 -0
  75. package/dist/lib/errors.d.ts +10 -0
  76. package/dist/lib/errors.d.ts.map +1 -0
  77. package/dist/lib/errors.js +27 -0
  78. package/dist/lib/errors.js.map +1 -0
  79. package/dist/lib/file-utils.d.ts +7 -0
  80. package/dist/lib/file-utils.d.ts.map +1 -0
  81. package/dist/lib/file-utils.js +56 -0
  82. package/dist/lib/file-utils.js.map +1 -0
  83. package/dist/lib/token-estimate.d.ts +7 -0
  84. package/dist/lib/token-estimate.d.ts.map +1 -0
  85. package/dist/lib/token-estimate.js +15 -0
  86. package/dist/lib/token-estimate.js.map +1 -0
  87. package/dist/scanner/codegraph.d.ts +13 -0
  88. package/dist/scanner/codegraph.d.ts.map +1 -0
  89. package/dist/scanner/codegraph.js +65 -0
  90. package/dist/scanner/codegraph.js.map +1 -0
  91. package/dist/scanner/docs.d.ts +13 -0
  92. package/dist/scanner/docs.d.ts.map +1 -0
  93. package/dist/scanner/docs.js +63 -0
  94. package/dist/scanner/docs.js.map +1 -0
  95. package/dist/scanner/gotchas.d.ts +8 -0
  96. package/dist/scanner/gotchas.d.ts.map +1 -0
  97. package/dist/scanner/gotchas.js +107 -0
  98. package/dist/scanner/gotchas.js.map +1 -0
  99. package/dist/scanner/index.d.ts +26 -0
  100. package/dist/scanner/index.d.ts.map +1 -0
  101. package/dist/scanner/index.js +95 -0
  102. package/dist/scanner/index.js.map +1 -0
  103. package/dist/scanner/manifest.d.ts +13 -0
  104. package/dist/scanner/manifest.d.ts.map +1 -0
  105. package/dist/scanner/manifest.js +285 -0
  106. package/dist/scanner/manifest.js.map +1 -0
  107. package/dist/scanner/mcp.d.ts +12 -0
  108. package/dist/scanner/mcp.d.ts.map +1 -0
  109. package/dist/scanner/mcp.js +96 -0
  110. package/dist/scanner/mcp.js.map +1 -0
  111. package/dist/scanner/repomix.d.ts +11 -0
  112. package/dist/scanner/repomix.d.ts.map +1 -0
  113. package/dist/scanner/repomix.js +87 -0
  114. package/dist/scanner/repomix.js.map +1 -0
  115. package/dist/scanner/skills.d.ts +18 -0
  116. package/dist/scanner/skills.d.ts.map +1 -0
  117. package/dist/scanner/skills.js +100 -0
  118. package/dist/scanner/skills.js.map +1 -0
  119. package/dist/scanner/source.d.ts +13 -0
  120. package/dist/scanner/source.d.ts.map +1 -0
  121. package/dist/scanner/source.js +157 -0
  122. package/dist/scanner/source.js.map +1 -0
  123. package/dist/scanner/structure.d.ts +10 -0
  124. package/dist/scanner/structure.d.ts.map +1 -0
  125. package/dist/scanner/structure.js +168 -0
  126. package/dist/scanner/structure.js.map +1 -0
  127. package/dist/server.d.ts +2 -0
  128. package/dist/server.d.ts.map +1 -0
  129. package/dist/server.js +245 -0
  130. package/dist/server.js.map +1 -0
  131. package/dist/snapshot/drift.d.ts +28 -0
  132. package/dist/snapshot/drift.d.ts.map +1 -0
  133. package/dist/snapshot/drift.js +205 -0
  134. package/dist/snapshot/drift.js.map +1 -0
  135. package/dist/snapshot/schema.d.ts +94 -0
  136. package/dist/snapshot/schema.d.ts.map +1 -0
  137. package/dist/snapshot/schema.js +24 -0
  138. package/dist/snapshot/schema.js.map +1 -0
  139. package/dist/snapshot/writer.d.ts +17 -0
  140. package/dist/snapshot/writer.d.ts.map +1 -0
  141. package/dist/snapshot/writer.js +44 -0
  142. package/dist/snapshot/writer.js.map +1 -0
  143. package/dist/tools/drift.d.ts +15 -0
  144. package/dist/tools/drift.d.ts.map +1 -0
  145. package/dist/tools/drift.js +51 -0
  146. package/dist/tools/drift.js.map +1 -0
  147. package/dist/tools/export.d.ts +14 -0
  148. package/dist/tools/export.d.ts.map +1 -0
  149. package/dist/tools/export.js +53 -0
  150. package/dist/tools/export.js.map +1 -0
  151. package/dist/tools/init.d.ts +28 -0
  152. package/dist/tools/init.d.ts.map +1 -0
  153. package/dist/tools/init.js +103 -0
  154. package/dist/tools/init.js.map +1 -0
  155. package/dist/tools/lint.d.ts +24 -0
  156. package/dist/tools/lint.d.ts.map +1 -0
  157. package/dist/tools/lint.js +213 -0
  158. package/dist/tools/lint.js.map +1 -0
  159. package/dist/tools/scan-report.d.ts +14 -0
  160. package/dist/tools/scan-report.d.ts.map +1 -0
  161. package/dist/tools/scan-report.js +136 -0
  162. package/dist/tools/scan-report.js.map +1 -0
  163. package/dist/tools/status.d.ts +18 -0
  164. package/dist/tools/status.d.ts.map +1 -0
  165. package/dist/tools/status.js +38 -0
  166. package/dist/tools/status.js.map +1 -0
  167. package/dist/tools/sync.d.ts +22 -0
  168. package/dist/tools/sync.d.ts.map +1 -0
  169. package/dist/tools/sync.js +123 -0
  170. package/dist/tools/sync.js.map +1 -0
  171. package/dist/tools/validate.d.ts +22 -0
  172. package/dist/tools/validate.d.ts.map +1 -0
  173. package/dist/tools/validate.js +97 -0
  174. package/dist/tools/validate.js.map +1 -0
  175. package/docs/agents-md-spec.md +233 -0
  176. package/docs/examples/.clinerules +29 -0
  177. package/docs/examples/.cursorrules +19 -0
  178. package/docs/examples/.windsurfrules +14 -0
  179. package/docs/examples/AGENTS.md +97 -0
  180. package/docs/examples/CLAUDE.md +88 -0
  181. package/docs/examples/GEMINI.md +61 -0
  182. package/docs/examples/copilot-instructions.md +24 -0
  183. package/docs/github-action.yml +89 -0
  184. package/package.json +63 -0
  185. package/scripts/demo.sh +138 -0
  186. package/skill/SKILL.md +158 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 googlarz
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,507 @@
1
+ <div align="center">
2
+
3
+ # agents-sync
4
+
5
+ **Write your AI context once. Every tool stays in sync — automatically.**
6
+
7
+ **9 AI tools · drifts detected in milliseconds · 100% local · ~$0.05–0.10 per sync**
8
+
9
+ [![npm](https://img.shields.io/npm/v/@googlarz/agents-sync?style=flat-square&label=npm)](https://www.npmjs.com/package/@googlarz/agents-sync)
10
+ [![License](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)](LICENSE)
11
+ [![Node.js](https://img.shields.io/badge/Node.js-18%2B-green?style=flat-square)](https://nodejs.org)
12
+
13
+ ![Windows](https://img.shields.io/badge/Windows-supported-0078D6?style=flat-square)
14
+ ![macOS](https://img.shields.io/badge/macOS-supported-555555?style=flat-square)
15
+ ![Linux](https://img.shields.io/badge/Linux-supported-1793D1?style=flat-square)
16
+
17
+ [![Claude Code](https://img.shields.io/badge/Claude_Code-supported-E8670A?style=flat-square)](https://claude.ai/code)
18
+ [![Cursor](https://img.shields.io/badge/Cursor-supported-4B6EF5?style=flat-square)](https://cursor.com)
19
+ [![Codex CLI](https://img.shields.io/badge/Codex_CLI-supported-412991?style=flat-square)](https://github.com/openai/codex)
20
+ [![opencode](https://img.shields.io/badge/opencode-supported-7C3AED?style=flat-square)](https://opencode.ai)
21
+
22
+ </div>
23
+
24
+ ---
25
+
26
+ ## The Problem
27
+
28
+ You migrated from Prisma to Drizzle three weeks ago. You updated `CLAUDE.md`. Last Thursday, your colleague opened the project in Cursor — `.cursorrules` still said "use Prisma ORM". They wrote a new migration using Prisma. The PR landed on Friday. You found it Monday morning.
29
+
30
+ That's the problem. Every AI coding tool expects its own context file:
31
+
32
+ | Tool | File |
33
+ |---|---|
34
+ | Claude Code | `CLAUDE.md` |
35
+ | Cursor | `.cursorrules` |
36
+ | GitHub Copilot | `.github/copilot-instructions.md` |
37
+ | Codex / opencode / Amp | `AGENTS.md` |
38
+ | Gemini CLI | `GEMINI.md` |
39
+ | Windsurf | `.windsurfrules` |
40
+ | Cline | `.clinerules` |
41
+ | Roo Code | `.roomodes` |
42
+ | Aider | `CONVENTIONS.md` |
43
+
44
+ Maintain them manually and they drift. `agents-sync` generates all of them from a single canonical `AGENTS.md` — derived from your actual codebase, updated whenever your stack changes.
45
+
46
+ This is [GitHub issue #6235](https://github.com/anthropics/claude-code/issues/6235) — **AGENTS.md portability**, **3,914 upvotes**, the most demanded feature in the Claude Code repo.
47
+
48
+ ---
49
+
50
+ ## Quick Start
51
+
52
+ **Step 1 — scan your project (no API key, no cost):**
53
+
54
+ ```bash
55
+ npx @googlarz/agents-sync scan .
56
+ ```
57
+
58
+ ```
59
+ agents-sync scan — my-app
60
+
61
+ ▸ Project
62
+ Language: typescript
63
+ Framework: next.js
64
+ Runtime: node
65
+ Pkg manager: npm
66
+
67
+ ▸ Dependencies
68
+ 31 production, 22 dev
69
+ Notable: next, react, drizzle-orm, @auth/core, zod, tailwindcss +25 more
70
+
71
+ ▸ Structure
72
+ Top-level dirs: src, public, drizzle
73
+ Total files: ~412
74
+ Entry points: src/app/page.tsx
75
+ Test dirs: src
76
+
77
+ ▸ MCP Servers (.claude/settings.json)
78
+ ✓ postgres — PostgreSQL database access
79
+ ✓ github — GitHub API integration
80
+
81
+ ▸ Local Skills & Commands
82
+ ✓ /deploy — Production deployment checklist
83
+ ✓ /db-migrate — Database migration workflow
84
+
85
+ ▸ Gotchas found in source
86
+ FIXME src/lib/auth.ts:42 — token refresh race condition, needs mutex
87
+ HACK src/db/client.ts:17 — direct pool access bypasses connection limit
88
+ TODO src/api/webhooks.ts:91 — validate Stripe signature before processing
89
+
90
+ Scanned in 287ms · ~21,400 tokens of context
91
+
92
+ → Ready to init. Run:
93
+ ANTHROPIC_API_KEY=<key> npx @googlarz/agents-sync init .
94
+ Get a key: https://console.anthropic.com/
95
+ ```
96
+
97
+ **Step 2 — generate all context files (~$0.05–0.10, runs once):**
98
+
99
+ ```bash
100
+ ANTHROPIC_API_KEY=sk-ant-... npx @googlarz/agents-sync init .
101
+ ```
102
+
103
+ ```
104
+ ✓ AGENTS.md → /your/project/AGENTS.md
105
+ ✓ claude → /your/project/CLAUDE.md
106
+ ✓ cursor → /your/project/.cursorrules
107
+ ✓ copilot → /your/project/.github/copilot-instructions.md
108
+ ✓ gemini → /your/project/GEMINI.md
109
+ ✓ windsurf → /your/project/.windsurfrules
110
+ ✓ cline → /your/project/.clinerules
111
+ ✓ roo → /your/project/.roomodes
112
+ ✓ aider → /your/project/CONVENTIONS.md
113
+
114
+ ✓ Snapshot saved to .agents-sync/
115
+ ```
116
+
117
+ Add `AGENTS.md` to git. Add `.agents-sync/` to `.gitignore`.
118
+
119
+ ---
120
+
121
+ ## What Gets Generated
122
+
123
+ <details>
124
+ <summary><strong>Sample AGENTS.md</strong></summary>
125
+
126
+ ```markdown
127
+ # AGENTS.md
128
+
129
+ <!-- Generated by agents-sync v1.4.0 on 2026-05-20 -->
130
+
131
+ ## Project Overview
132
+ my-app is a SaaS dashboard built with Next.js 15 App Router, PostgreSQL
133
+ via Drizzle ORM, and Auth.js v5 for authentication.
134
+
135
+ ## Tech Stack
136
+ - TypeScript / Next.js 15 (App Router)
137
+ - PostgreSQL via Drizzle ORM
138
+ - Authentication: Auth.js v5
139
+ - Testing: Vitest (co-located)
140
+ - Deploy: Vercel
141
+
142
+ ## Architecture
143
+ - `src/app/` — Next.js pages and layouts (App Router)
144
+ - `src/features/` — feature modules (billing, users, dashboard)
145
+ - `src/lib/` — shared utilities: db singleton, auth config, api client
146
+ - `src/components/` — shared UI components (shadcn/ui)
147
+
148
+ ## Conventions
149
+ 1. kebab-case filenames throughout
150
+ 2. Named exports only — no default exports except Next.js page/layout components
151
+ 3. All external input validated with Zod before use
152
+ 4. Co-locate tests: `Button.test.tsx` next to `Button.tsx`
153
+ 5. Server components by default; `"use client"` only when required
154
+
155
+ ## Gotchas
156
+ 1. Never import the db client directly — use `lib/db.ts` singleton.
157
+ Direct imports cause connection pool exhaustion in serverless.
158
+ 2. All API routes require auth middleware — check `middleware.ts` first.
159
+ 3. `src/lib/auth.ts:42` has a known token refresh race condition.
160
+ Workaround in place; do not remove the mutex.
161
+
162
+ ## Boundaries
163
+
164
+ ### Never
165
+ - Commit `.env` or `.env.local`
166
+ - Import `db` outside of `lib/db.ts`
167
+ - Use `any` type — use `unknown` and narrow
168
+ - Bypass auth middleware on new API routes
169
+
170
+ ## MCP Servers
171
+ - **postgres** — PostgreSQL database access (read/write)
172
+ - **github** — GitHub API: issues, PRs, code search
173
+ ```
174
+
175
+ </details>
176
+
177
+ <details>
178
+ <summary><strong>What CLAUDE.md adds on top of AGENTS.md</strong></summary>
179
+
180
+ - **MCP server documentation** — each detected server with its purpose and key operations
181
+ - **Skill recommendations** — stack-aware suggestions (e.g. `test-driven-development` for Vitest projects, `debugging-and-error-recovery` for Express APIs)
182
+ - **Local commands** — your project's `.claude/commands/` and `.claude/skills/` documented for Claude
183
+
184
+ </details>
185
+
186
+ ---
187
+
188
+ ## Custom Sections
189
+
190
+ Manual additions you make to any managed file survive every resync:
191
+
192
+ ```markdown
193
+ <!-- AGENTS-SYNC:CUSTOM:START -->
194
+ ## Team Notes
195
+ - Payments work: check with @alice before shipping anything in src/billing/
196
+ - Use staging Stripe keys (in .env.staging) for all local testing
197
+ - The `/api/webhooks/stripe` endpoint must stay idempotent — see ADR-007
198
+ <!-- AGENTS-SYNC:CUSTOM:END -->
199
+ ```
200
+
201
+ Run `/agents-sync sync` next week after adding three new dependencies. Your team notes are untouched. The stack section is updated.
202
+
203
+ ---
204
+
205
+ ## Setup
206
+
207
+ ### Claude Code
208
+
209
+ Add to `~/.claude/claude_desktop_config.json` or your project's `.claude/settings.json`:
210
+
211
+ ```json
212
+ {
213
+ "mcpServers": {
214
+ "agents-sync": {
215
+ "command": "npx",
216
+ "args": ["@googlarz/agents-sync"],
217
+ "env": { "ANTHROPIC_API_KEY": "sk-ant-..." }
218
+ }
219
+ }
220
+ }
221
+ ```
222
+
223
+ Restart Claude Code. Then: `/agents-sync init` in any project.
224
+
225
+ ### Cursor
226
+
227
+ Add to `.cursor/mcp.json` in your project:
228
+
229
+ ```json
230
+ {
231
+ "mcpServers": {
232
+ "agents-sync": {
233
+ "command": "npx",
234
+ "args": ["@googlarz/agents-sync"],
235
+ "env": { "ANTHROPIC_API_KEY": "sk-ant-..." }
236
+ }
237
+ }
238
+ }
239
+ ```
240
+
241
+ ### Codex CLI
242
+
243
+ Add to `~/.codex/config.toml`:
244
+
245
+ ```toml
246
+ [mcp_servers.agents-sync]
247
+ command = "npx"
248
+ args = ["@googlarz/agents-sync"]
249
+ env = { ANTHROPIC_API_KEY = "sk-ant-..." }
250
+ ```
251
+
252
+ ### opencode
253
+
254
+ Add to `~/.config/opencode/config.json`:
255
+
256
+ ```json
257
+ {
258
+ "mcpServers": {
259
+ "agents-sync": {
260
+ "type": "local",
261
+ "command": ["npx", "@googlarz/agents-sync"],
262
+ "environment": { "ANTHROPIC_API_KEY": "sk-ant-..." }
263
+ }
264
+ }
265
+ }
266
+ ```
267
+
268
+ > **Codex / opencode users:** agents-sync uses the Anthropic API only for `init` and `sync`. All read commands (`scan`, `drift`, `lint`, `validate`, `status`, `export`) make zero API calls. The free tier at [console.anthropic.com](https://console.anthropic.com/) covers occasional syncs.
269
+
270
+ ---
271
+
272
+ ## Usage
273
+
274
+ ### Keep context fresh — check for drift
275
+
276
+ After any significant change (new dependency, new directory, architecture shift):
277
+
278
+ ```bash
279
+ npx @googlarz/agents-sync drift .
280
+ ```
281
+
282
+ ```
283
+ agents-sync drift report (2026-05-20)
284
+ Last sync: 12 days ago
285
+
286
+ HIGH New dependency detected: drizzle-orm
287
+ (package.json changed — possible architecture shift)
288
+ HIGH New top-level directory: src/workers/
289
+
290
+ MED 3 new files with new naming pattern
291
+
292
+ → Re-sync recommended. Run: agents-sync sync .
293
+ ```
294
+
295
+ ### Re-sync
296
+
297
+ ```bash
298
+ ANTHROPIC_API_KEY=sk-ant-... npx @googlarz/agents-sync sync .
299
+ ```
300
+
301
+ ```
302
+ ✓ claude → /your/project/CLAUDE.md
303
+ ✓ cursor → /your/project/.cursorrules
304
+ ✓ copilot → /your/project/.github/copilot-instructions.md
305
+
306
+ 2 custom section(s) preserved
307
+ ```
308
+
309
+ ### Lint — enforce your own rules
310
+
311
+ `agents-sync lint` checks your codebase against every mechanically-verifiable `Never` rule in `AGENTS.md`. Zero setup — the rules come from what Claude extracted about your project.
312
+
313
+ ```bash
314
+ npx @googlarz/agents-sync lint .
315
+ ```
316
+
317
+ ```
318
+ ⚠ 2 violation(s) found
319
+
320
+ any-type src/api/webhook.ts:34 parameter typed as 'any' — use 'unknown'
321
+ direct-db src/jobs/cleanup.ts:12 direct db import outside lib/db.ts
322
+ ```
323
+
324
+ Use `--ci` to exit 1 in CI pipelines.
325
+
326
+ ### Validate — check files are in sync
327
+
328
+ ```bash
329
+ npx @googlarz/agents-sync validate .
330
+ ```
331
+
332
+ ```
333
+ AGENTS.md (canonical) ✓
334
+
335
+ ✓ claude in sync CLAUDE.md
336
+ ⚠ cursor DRIFTED .cursorrules (modified after last sync)
337
+ ✓ copilot in sync .github/copilot-instructions.md
338
+
339
+ → Run agents-sync sync to fix.
340
+ ```
341
+
342
+ <details>
343
+ <summary><strong>Full CLI reference</strong></summary>
344
+
345
+ ```bash
346
+ npx @googlarz/agents-sync scan . # No API key — see what scanner detects
347
+ npx @googlarz/agents-sync init . # Generate all context files
348
+ npx @googlarz/agents-sync sync . # Re-sync after codebase changes
349
+ npx @googlarz/agents-sync drift . # Check what changed
350
+ npx @googlarz/agents-sync lint . # Verify codebase against Never rules
351
+ npx @googlarz/agents-sync validate . # Check files match AGENTS.md
352
+ npx @googlarz/agents-sync export cursor . # Re-derive one file (no API call)
353
+ npx @googlarz/agents-sync status . # Show sync status
354
+
355
+ npx @googlarz/agents-sync drift . --ci # Exit 1 on HIGH drift (CI)
356
+ npx @googlarz/agents-sync lint . --ci # Exit 1 on any violation (CI)
357
+ npx @googlarz/agents-sync init . --dry-run # Preview without writing
358
+ npx @googlarz/agents-sync init . --tools claude,cursor,roo # Specific tools only
359
+ npx @googlarz/agents-sync sync . --fast # Skip API call if drift is minor
360
+ ```
361
+
362
+ </details>
363
+
364
+ ---
365
+
366
+ ## GitHub Action
367
+
368
+ Automatically open a PR when drift goes HIGH. Copy [`docs/github-action.yml`](docs/github-action.yml) to `.github/workflows/agents-sync.yml`, add `ANTHROPIC_API_KEY` to repository secrets.
369
+
370
+ The workflow triggers on `package.json` / `pyproject.toml` / `Cargo.toml` / `go.mod` changes and runs weekly. When drift is HIGH it re-syncs and opens a PR for review.
371
+
372
+ ---
373
+
374
+ ## How It Works
375
+
376
+ <details>
377
+ <summary><strong>Pipeline details</strong></summary>
378
+
379
+ ```
380
+ Your codebase
381
+
382
+
383
+ [scan] package manifests · directory tree · source samples
384
+ README · FIXME/HACK/TODO comments · MCP servers · local skills
385
+
386
+
387
+ [extract] Claude API (claude-sonnet-4-6) → structured project metadata
388
+ stack · conventions · gotchas · architecture · boundaries
389
+
390
+
391
+ [generate] canonical AGENTS.md ←── one source of truth
392
+
393
+ ├──▶ AGENTS.md (read directly by Codex CLI and opencode)
394
+ ├──▶ CLAUDE.md (superset + MCP docs + skill recommendations)
395
+ ├──▶ .cursorrules (directive-style, < 400 words)
396
+ ├──▶ .github/copilot-instructions.md (code-level focus, < 300 words)
397
+ ├──▶ GEMINI.md (full AGENTS.md + Gemini CLI section)
398
+ ├──▶ .windsurfrules (directive-style, < 400 words)
399
+ ├──▶ .clinerules (Always/Never sections, < 400 words)
400
+ ├──▶ .roomodes (Roo Code custom modes)
401
+ └──▶ CONVENTIONS.md (Aider conventions file)
402
+ ```
403
+
404
+ The scanner runs entirely locally. Only the extract step calls the API. Drift detection, validation, lint, and export are all local.
405
+
406
+ </details>
407
+
408
+ ---
409
+
410
+ ## Troubleshooting
411
+
412
+ **"ANTHROPIC_API_KEY not set"**
413
+ Only `init` and `sync` need the key. Run `scan` first — it shows what was detected and prints the exact command to run once you have a key.
414
+
415
+ **"My AGENTS.md looks wrong / missed something important"**
416
+ Run `agents-sync sync .` to regenerate from the current codebase state. If the scanner missed something structural, check that your project has a recognizable manifest file (`package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`).
417
+
418
+ **"I edited CLAUDE.md manually and sync overwrites my changes"**
419
+ Wrap your additions in a custom section:
420
+ ```markdown
421
+ <!-- AGENTS-SYNC:CUSTOM:START -->
422
+ your content here
423
+ <!-- AGENTS-SYNC:CUSTOM:END -->
424
+ ```
425
+ Everything inside those markers survives every sync.
426
+
427
+ **"Drift says HIGH but I only changed one file"**
428
+ Drift scores are based on structural signals (new dependencies, new directories, naming pattern changes). A single `package.json` change that adds a major dependency triggers HIGH. That's intentional — architecture assumptions may need updating.
429
+
430
+ **"How much does each sync cost?"**
431
+ Typically $0.05–0.10 using `claude-sonnet-4-6`. Syncs on previously-indexed projects are cheaper due to prompt caching. Use `--fast` to skip the API call entirely when drift is minor.
432
+
433
+ ---
434
+
435
+ ## Environment Variables
436
+
437
+ | Variable | Required | Description |
438
+ |---|---|---|
439
+ | `ANTHROPIC_API_KEY` | For `init` and `sync` only | Your Anthropic API key |
440
+ | `AGENTS_SYNC_DEBUG=1` | No | Verbose debug output to stderr |
441
+ | `NO_COLOR=1` | No | Disable ANSI color |
442
+
443
+ `scan`, `drift`, `validate`, `status`, `export`, and `lint` never call the API.
444
+
445
+ ---
446
+
447
+ <details>
448
+ <summary><strong>MCP Tools Reference</strong></summary>
449
+
450
+ | Tool | Description |
451
+ |---|---|
452
+ | `agents_sync_scan` | Show what scanner detected — no API key needed |
453
+ | `agents_sync_init` | Full init: scan, extract, generate, derive, snapshot |
454
+ | `agents_sync_sync` | Re-sync from current codebase state |
455
+ | `agents_sync_drift` | Check what changed since last sync (read-only) |
456
+ | `agents_sync_export` | Re-derive a single tool file (no API call) |
457
+ | `agents_sync_validate` | Check if all tool files match AGENTS.md |
458
+ | `agents_sync_status` | Show sync status and managed files |
459
+ | `agents_sync_lint` | Verify codebase against Never rules in AGENTS.md |
460
+
461
+ </details>
462
+
463
+ ---
464
+
465
+ ## Supported Stacks
466
+
467
+ - **TypeScript/JavaScript**: Next.js, Express, Fastify, Remix, SvelteKit, Vite
468
+ - **Python**: Django, FastAPI, Flask
469
+ - **Rust**: Cargo workspaces, Axum, Actix
470
+ - **Go**: standard modules, Gin, Echo
471
+ - **PHP**: Composer projects, Laravel
472
+
473
+ Language-agnostic — works on any codebase with a manifest file.
474
+
475
+ ---
476
+
477
+ ## Contributing
478
+
479
+ ```bash
480
+ git clone https://github.com/googlarz/agents-sync
481
+ cd agents-sync
482
+ npm install
483
+ npm run dev # watch mode
484
+ npm test # 116 unit tests, no API key needed
485
+ ```
486
+
487
+ Integration tests (require `ANTHROPIC_API_KEY`, run against real fixtures):
488
+
489
+ ```bash
490
+ npm run test:integration
491
+ ```
492
+
493
+ ---
494
+
495
+ ## License
496
+
497
+ MIT
498
+
499
+ ---
500
+
501
+ <div align="center">
502
+
503
+ **Built for the vibe coding era — when your AI tools should know your codebase as well as you do.**
504
+
505
+ [Report a bug](https://github.com/googlarz/agents-sync/issues) · [Request a feature](https://github.com/googlarz/agents-sync/issues) · [Roadmap](ROADMAP.md)
506
+
507
+ </div>
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}