md-gossip 0.0.0-stage → 0.1.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.
package/README.md CHANGED
@@ -1,3 +1,277 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="assets/logo.png" width="128" height="128" alt="md-gossip logo: a purple hash symbol wrapped by a sync arc">
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ <h1 align="center">md-gossip</h1>
6
+
7
+ <p align="center">
8
+ <b>The place where your AI agents gossip.</b><br>
9
+ One <code>AGENTS.md</code> every agent reads, writes, and contributes to.<br>
10
+ Install once. They share what they learn. No scripts, no server, no telemetry.<br>
11
+ Claude Code · Codex · OpenCode · Devin · Antigravity · Cursor · Copilot · Windsurf · Gemini · Cline · Continue · Zed · Aider
12
+ </p>
13
+
14
+ <p align="center">
15
+ <img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-7C3AED?style=flat-square">
16
+ <img alt="Written in TypeScript" src="https://img.shields.io/badge/written%20in-TypeScript-7C3AED?style=flat-square">
17
+ <img alt="Zero runtime dependencies" src="https://img.shields.io/badge/runtime%20deps-0-7C3AED?style=flat-square">
18
+ <img alt="No telemetry" src="https://img.shields.io/badge/no%20account-no%20telemetry-0A0A0A?style=flat-square">
19
+ </p>
20
+
21
+ <p align="center">
22
+ <a href="#install">Install</a> ·
23
+ <a href="#how-it-works">How it works</a> ·
24
+ <a href="#supported-agents">Agents</a> ·
25
+ <a href="#the-protocol">Protocol</a> ·
26
+ <a href="#commands">Commands</a> ·
27
+ <a href="#deploy-on-github">GitHub</a> ·
28
+ <a href="#design-rules">Design</a> ·
29
+ <a href="#contributing">Contribute</a>
30
+ </p>
31
+
32
+ ---
33
+
34
+ ## Highlights
35
+
36
+ <table>
37
+ <tr>
38
+ <td width="33%" valign="top">
39
+
40
+ ### Universal
41
+ 13 agents out of the box: Claude Code, Codex CLI, OpenCode, Devin (cloud + CLI), Google Antigravity, Cursor, GitHub Copilot, Windsurf, Gemini CLI, Cline, Continue.dev, Zed, Aider. Adding a new agent is one row in a registry.
42
+
43
+ </td>
44
+ <td width="33%" valign="top">
45
+
46
+ ### Search-first
47
+ `AGENTS.md` stays tiny (~300 tokens) — a router with pinned facts and a tag index. All content lives in `AGENTS.d/*.md`. Agents grep on demand. Prompt caches stay warm, token cost stays flat regardless of project size.
48
+
49
+ </td>
50
+ <td width="33%" valign="top">
51
+
52
+ ### Yours
53
+ No daemon, no sync server, no API, no telemetry, no account. Git is the sync layer. The CLI runs once per repo (or once globally) — after that, every agent reads and writes on its own.
54
+
55
+ </td>
56
+ </tr>
57
+ </table>
58
+
59
+ ---
60
+
61
+ ## Install
62
+
63
+ ```sh
64
+ cd your-project
65
+ npx md-gossip install
66
+ git add AGENTS.md AGENTS.d/ .gitignore
67
+ git commit -m "add shared agent context"
68
+ git push
69
+ ```
70
+
71
+ That's it. Every supported agent now reads `AGENTS.md` on session start and appends durable facts to `AGENTS.d/` as it learns them. Teammates clone the repo and their agents pick it up too — no install required on their side.
72
+
73
+ **Global install** (write once per machine, every project inherits):
74
+
75
+ ```sh
76
+ npx md-gossip install --global
77
+ ```
78
+
79
+ ---
80
+
81
+ ## How it works
82
+
83
+ ```
84
+ your-repo/
85
+ ├── AGENTS.md ← tiny router. Pinned facts + tag index + protocol.
86
+ ├── AGENTS.d/ ← one file per tag. Agents grep on demand.
87
+ │ ├── stack.md
88
+ │ ├── style.md
89
+ │ ├── bugs.md
90
+ │ ├── api.md
91
+ │ ├── deploy.md
92
+ │ └── prefs.md
93
+ ├── CLAUDE.md ← symlink → AGENTS.md (gitignored)
94
+ ├── GEMINI.md ← symlink → AGENTS.md (gitignored)
95
+ ├── .cursor/rules/md-gossip.mdc ← wrapper with alwaysApply (gitignored)
96
+ ├── .continue/rules/md-gossip.md ← wrapper with alwaysApply (gitignored)
97
+ ├── .github/copilot-instructions.md ← symlink (gitignored)
98
+ ├── .windsurf/rules/context.md ← wrapper (gitignored)
99
+ └── ...
100
+ ```
101
+
102
+ Only `AGENTS.md` + `AGENTS.d/` are committed. Everything else is wired locally by each user running `install` once. Your repo stays clean on GitHub.
103
+
104
+ ### The sync story
105
+
106
+ **Reads** happen natively. Every agent loads its own expected filename at session start — `install` pointed that filename at `AGENTS.md`. No command runs; the agent does it.
107
+
108
+ **Writes** happen when the agent edits files. The router header inside `AGENTS.md` tells it: *grep `AGENTS.d/`, append durable facts, dedup first.* Agents follow in-file instructions. They use their own edit tools.
109
+
110
+ **Sync across machines** is git. Agents append → commit → push → other agents `git pull` → next session sees the new facts. No daemon, no realtime layer.
111
+
112
+ ---
113
+
114
+ ## Supported agents
115
+
116
+ | Agent | Auto-read | Auto-write | Setup after install |
117
+ |---|:-:|:-:|---|
118
+ | Claude Code | ✓ | ✓ | none |
119
+ | OpenAI Codex CLI | ✓ | ✓ | none |
120
+ | OpenCode | ✓ | ✓ | none |
121
+ | Devin (cloud + CLI) | ✓ | ✓ | none — reads `AGENTS.md` from repo |
122
+ | Google Antigravity | ✓ | ✓ | none |
123
+ | Cursor | ✓ | ✓ (agent mode) | none |
124
+ | GitHub Copilot | ✓ | ✓ (agent mode) | none |
125
+ | Windsurf | ✓ | ✓ | none |
126
+ | Gemini CLI | ✓ | ✓ | none |
127
+ | Cline | ✓ | ✓ | none |
128
+ | Continue.dev | ✓ | ✓ (agent mode) | none |
129
+ | Zed | ✓ | ✓ | none |
130
+ | Aider | ✓ | ✓ | none — `install` edits `.aider.conf.yml` |
131
+
132
+ Adding a new agent = one row in [`src/adapters/registry.ts`](src/adapters/registry.ts). PRs welcome.
133
+
134
+ ---
135
+
136
+ ## The protocol
137
+
138
+ Every `AGENTS.md` ships with this header. Agents read it, follow it.
139
+
140
+ ```
141
+ READ
142
+ 1. Pinned facts (top of file) always apply.
143
+ 2. Need more? Run: rg "<keyword>" AGENTS.d/
144
+ 3. Or read one chunk: AGENTS.d/<tag>.md
145
+ 4. Never read all of AGENTS.d/ at once — defeats the point.
146
+
147
+ WRITE (when you learn a durable fact)
148
+ 1. Pick the right tag (or create a new chunk).
149
+ 2. Grep first — skip if the fact already exists.
150
+ 3. Append ONE line: `#tag short fact under 120 chars`.
151
+ 4. Never delete lines you didn't write this session. Append-only.
152
+
153
+ LOCAL OVERRIDES
154
+ AGENTS.local.md and AGENTS.d/local/ are personal, gitignored.
155
+ Read shared first, then local. Later overrides earlier.
156
+ ```
157
+
158
+ A durable fact looks like:
159
+
160
+ ```
161
+ #stack next.js 15, bun, postgres, drizzle
162
+ #bugs win: `bun build` fails on CRLF — run `git config core.autocrlf input`
163
+ #prefs terse answers, no trailing summaries
164
+ #api /auth uses lucia, sessions in cookies not JWT
165
+ ```
166
+
167
+ Grep-friendly. Human-readable. Diff-friendly in git. No embeddings, no RAG, no JSON blobs.
168
+
169
+ ---
170
+
171
+ ## Commands
172
+
173
+ ```sh
174
+ md-gossip install # default — wires all adapters
175
+ md-gossip install --global # also write to ~/.claude, ~/.codex, etc.
176
+ md-gossip install --only claude-code,opencode,devin
177
+ md-gossip install --force # overwrite existing wrappers
178
+ md-gossip install --skip-agents-md # wire adapters without touching AGENTS.md
179
+
180
+ md-gossip status # show what's wired
181
+ md-gossip clean # remove generated links/skills
182
+ md-gossip clean --global # also clean user-level files
183
+ ```
184
+
185
+ Aliased as `gossip`.
186
+
187
+ ---
188
+
189
+ ## Deploy on GitHub
190
+
191
+ The install is designed for clean repos.
192
+
193
+ - **Committed:** `AGENTS.md`, `AGENTS.d/*.md`, `.gitignore` entries.
194
+ - **Gitignored:** every per-agent symlink, wrapper, and skill file.
195
+ - **Gitignored automatically:** `AGENTS.local.md` and `AGENTS.d/local/` for personal overrides.
196
+
197
+ GitHub's file tree shows only the router and the chunks. Teammates not using `md-gossip` still see the shared context — GitHub renders `AGENTS.md` fine and most agents read it natively even without local wiring.
198
+
199
+ ---
200
+
201
+ ## Design rules
202
+
203
+ The project follows three hard rules. If you contribute, follow them too.
204
+
205
+ | | |
206
+ |---|---|
207
+ | **Zero runtime dependencies** | Node stdlib only. devDeps are `typescript` + `@types/node`. If a feature needs a package, question whether the feature needs to exist. |
208
+ | **Search-first, not load-first** | `AGENTS.md` stays small and cache-friendly. Chunks live in `AGENTS.d/` and agents grep them. Features that stuff large payloads into context get rejected. |
209
+ | **Protocol-in-file beats protocol-in-code** | The header text inside `AGENTS.md` IS the skill. Native skill files (Claude, OpenCode, etc.) are polish. A read-only agent that only sees the file still participates. |
210
+
211
+ ### What's out of scope
212
+
213
+ RAG, embeddings, realtime sync daemons, web dashboards, telemetry, enterprise edition, per-agent API integrations (Devin Knowledge sync, Cursor settings sync), auto-conflict resolution. These stay closed on the tracker.
214
+
215
+ ---
216
+
217
+ ## How it's built
218
+
219
+ TypeScript workspace, strict mode, ESM, no bundler.
220
+
221
+ | Module | What it does |
222
+ |---|---|
223
+ | `src/cli.ts` | Argument parsing, command dispatch |
224
+ | `src/adapters/registry.ts` | One `Adapter` object per agent |
225
+ | `src/adapters/skillFormats.ts` | Render skill body with the right frontmatter per agent |
226
+ | `src/commands/install.ts` | The main command: seed `AGENTS.md`, wire targets, write skills, update `.gitignore` |
227
+ | `src/commands/status.ts` | Report what's wired per adapter |
228
+ | `src/commands/clean.ts` | Remove generated files; never touch `AGENTS.md` |
229
+ | `src/core/fs.ts` | `linkOrCopy` — symlink with copy fallback on Windows |
230
+ | `src/core/gitignore.ts` | Marker-block upsert in `.gitignore` |
231
+ | `src/core/wrappers.ts` | Frontmatter wrappers for Cursor `.mdc`, Windsurf rule, Continue rule |
232
+ | `src/templates/` | `AGENTS.md`, `AGENTS.d/*.md`, `SKILL.md` |
233
+
234
+ **Quality gates:**
235
+ - `tsc --strict` with `noUncheckedIndexedAccess`.
236
+ - 10 smoke tests covering install, idempotency, collision preservation, wrapper rendering, YAML safety.
237
+ - CI: Ubuntu / macOS / Windows × Node 18 / 20 / 22.
238
+
239
+ ---
240
+
241
+ ## Get started
242
+
243
+ Building needs Node 18 or later.
244
+
245
+ ```sh
246
+ git clone https://github.com/<you>/md-gossip
247
+ cd md-gossip
248
+ npm install
249
+ npm run build
250
+ npm test
251
+ ```
252
+
253
+ Run the CLI from source:
254
+
255
+ ```sh
256
+ node bin/md-gossip.js install --help
257
+ ```
258
+
259
+ ---
260
+
261
+ ## Contributing
262
+
263
+ 1. **Open an issue first** for feature ideas — the scope is deliberately locked.
264
+ 2. **Add a new agent** by appending to `src/adapters/registry.ts` and adding a smoke test. No other files should need to change unless the agent needs a new wrapper type.
265
+ 3. **No new runtime deps.** Ever.
266
+ 4. **Match the house style.** No comments unless the *why* is non-obvious. Small named functions. Strict types on exported functions.
267
+
268
+ ---
269
+
270
+ ## License
271
+
272
+ MIT — see [LICENSE](LICENSE). Copyright © 2026 the md-gossip contributors.
273
+
274
+ <p align="center">
275
+ <img src="assets/logo.png" width="32" height="32" alt="md-gossip"><br>
276
+ <sub>One file. Every agent. Done.</sub>
277
+ </p>
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/src/cli.js";
@@ -0,0 +1,3 @@
1
+ export * from "./types.js";
2
+ export * from "./registry.js";
3
+ export * from "./skillFormats.js";
@@ -0,0 +1,114 @@
1
+ export const ADAPTERS = [
2
+ {
3
+ name: "claude-code",
4
+ label: "Claude Code",
5
+ projectTargets: ["CLAUDE.md"],
6
+ globalTarget: "~/.claude/CLAUDE.md",
7
+ projectSkill: ".claude/skills/context-sync/SKILL.md",
8
+ globalSkill: "~/.claude/skills/context-sync/SKILL.md",
9
+ skillFormat: "claude-skill",
10
+ },
11
+ {
12
+ name: "codex",
13
+ label: "OpenAI Codex CLI",
14
+ projectTargets: ["AGENTS.md"],
15
+ globalTarget: "~/.codex/AGENTS.md",
16
+ globalSkill: "~/.codex/prompts/context-sync.md",
17
+ skillFormat: "plain",
18
+ },
19
+ {
20
+ name: "opencode",
21
+ label: "OpenCode",
22
+ projectTargets: ["AGENTS.md"],
23
+ globalTarget: "~/.config/opencode/AGENTS.md",
24
+ projectSkill: ".opencode/agent/context-sync.md",
25
+ globalSkill: "~/.config/opencode/agent/context-sync.md",
26
+ skillFormat: "opencode-agent",
27
+ },
28
+ {
29
+ name: "devin",
30
+ label: "Devin (CLI + cloud)",
31
+ projectTargets: ["AGENTS.md"],
32
+ globalTarget: null,
33
+ skillFormat: "none",
34
+ note: "Reads AGENTS.md from repo root automatically. No skill file format yet; the router header is the protocol.",
35
+ },
36
+ {
37
+ name: "antigravity",
38
+ label: "Google Antigravity",
39
+ projectTargets: ["AGENTS.md"],
40
+ globalTarget: null,
41
+ projectSkill: ".agent/profiles/context-sync.md",
42
+ skillFormat: "plain",
43
+ },
44
+ {
45
+ name: "cursor",
46
+ label: "Cursor",
47
+ projectTargets: [".cursor/rules/context-sync.mdc"],
48
+ globalTarget: null,
49
+ projectSkill: ".cursor/rules/context-sync.mdc",
50
+ skillFormat: "cursor-mdc",
51
+ wrapper: "cursor-mdc",
52
+ },
53
+ {
54
+ name: "copilot",
55
+ label: "GitHub Copilot",
56
+ projectTargets: [".github/copilot-instructions.md"],
57
+ globalTarget: null,
58
+ projectSkill: ".github/prompts/context-sync.prompt.md",
59
+ skillFormat: "copilot-prompt",
60
+ },
61
+ {
62
+ name: "windsurf",
63
+ label: "Windsurf",
64
+ projectTargets: [".windsurf/rules/context.md"],
65
+ globalTarget: null,
66
+ projectSkill: ".windsurf/workflows/context-sync.md",
67
+ skillFormat: "windsurf-workflow",
68
+ wrapper: "windsurf-rule",
69
+ },
70
+ {
71
+ name: "gemini-cli",
72
+ label: "Gemini CLI",
73
+ projectTargets: ["GEMINI.md"],
74
+ globalTarget: "~/.gemini/GEMINI.md",
75
+ globalSkill: "~/.gemini/commands/context-sync.toml",
76
+ skillFormat: "gemini-toml",
77
+ },
78
+ {
79
+ name: "cline",
80
+ label: "Cline",
81
+ projectTargets: [".clinerules/context.md"],
82
+ globalTarget: null,
83
+ projectSkill: ".clinerules/workflows/context-sync.md",
84
+ skillFormat: "plain",
85
+ },
86
+ {
87
+ name: "continue",
88
+ label: "Continue.dev",
89
+ projectTargets: [".continue/rules/context-sync.md"],
90
+ globalTarget: null,
91
+ projectSkill: ".continue/prompts/context-sync.prompt",
92
+ skillFormat: "plain",
93
+ wrapper: "continue-rule",
94
+ },
95
+ {
96
+ name: "zed",
97
+ label: "Zed",
98
+ projectTargets: [".rules"],
99
+ globalTarget: null,
100
+ skillFormat: "none",
101
+ note: "Zed reads .rules + AGENTS.md automatically. No skill file wired by default.",
102
+ },
103
+ {
104
+ name: "aider",
105
+ label: "Aider",
106
+ projectTargets: [],
107
+ globalTarget: null,
108
+ skillFormat: "none",
109
+ note: "install adds AGENTS.md to .aider.conf.yml read: list — that's all aider needs.",
110
+ },
111
+ ];
112
+ export function byName(name) {
113
+ return ADAPTERS.find((a) => a.name === name);
114
+ }
@@ -0,0 +1,37 @@
1
+ export function renderSkill(format, body) {
2
+ switch (format) {
3
+ case "plain":
4
+ return body;
5
+ case "claude-skill":
6
+ return frontmatter({
7
+ name: "context-sync",
8
+ description: "Shared agent memory via AGENTS.md + AGENTS.d/. Read first, grep on demand, append durable facts.",
9
+ }, body);
10
+ case "opencode-agent":
11
+ return frontmatter({
12
+ name: "context-sync",
13
+ mode: "subagent",
14
+ description: "Shared agent memory via AGENTS.md + AGENTS.d/. Read first, grep on demand, append durable facts.",
15
+ }, body);
16
+ case "cursor-mdc":
17
+ return frontmatter({
18
+ description: "Shared agent context. Read AGENTS.md, grep AGENTS.d/, append durable facts.",
19
+ alwaysApply: false,
20
+ }, body);
21
+ case "windsurf-workflow":
22
+ return frontmatter({ description: "Shared agent context via AGENTS.md" }, body);
23
+ case "copilot-prompt":
24
+ return frontmatter({
25
+ mode: "agent",
26
+ description: "Shared context via AGENTS.md + AGENTS.d/",
27
+ }, body);
28
+ case "gemini-toml":
29
+ return `description = "Use shared AGENTS.md context"\nprompt = """\n${body}\n"""\n`;
30
+ case "none":
31
+ return "";
32
+ }
33
+ }
34
+ function frontmatter(fields, body) {
35
+ const lines = Object.entries(fields).map(([k, v]) => typeof v === "string" ? `${k}: ${v}` : `${k}: ${JSON.stringify(v)}`);
36
+ return `---\n${lines.join("\n")}\n---\n\n${body}`;
37
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+ import { install } from "./commands/install.js";
3
+ import { status } from "./commands/status.js";
4
+ import { clean } from "./commands/clean.js";
5
+ import { log } from "./core/log.js";
6
+ function parse(argv) {
7
+ const [command = "install", ...rest] = argv;
8
+ const flags = {};
9
+ const positional = [];
10
+ for (let i = 0; i < rest.length; i++) {
11
+ const tok = rest[i];
12
+ if (tok.startsWith("--")) {
13
+ const eq = tok.indexOf("=");
14
+ if (eq > 0) {
15
+ flags[tok.slice(2, eq)] = tok.slice(eq + 1);
16
+ }
17
+ else {
18
+ const next = rest[i + 1];
19
+ if (next && !next.startsWith("--")) {
20
+ flags[tok.slice(2)] = next;
21
+ i++;
22
+ }
23
+ else {
24
+ flags[tok.slice(2)] = true;
25
+ }
26
+ }
27
+ }
28
+ else {
29
+ positional.push(tok);
30
+ }
31
+ }
32
+ return { command, flags, positional };
33
+ }
34
+ function help() {
35
+ console.log(`context-sync — one AGENTS.md for every coding agent
36
+
37
+ Usage:
38
+ context-sync [install] [options] install into current project (default)
39
+ context-sync status show which adapters are wired
40
+ context-sync clean [--global] remove generated links/skills (keeps AGENTS.md)
41
+
42
+ Install options:
43
+ --global also write user-level files (~/.claude, etc.)
44
+ --only <a,b,c> limit to specific adapters by name
45
+ --force overwrite existing files
46
+ --skip-agents-md don't create AGENTS.md / AGENTS.d/
47
+
48
+ Adapters:
49
+ claude-code, codex, opencode, devin, antigravity, cursor, copilot,
50
+ windsurf, gemini-cli, cline, continue, zed, aider
51
+ `);
52
+ }
53
+ async function main() {
54
+ const args = parse(process.argv.slice(2));
55
+ if (args.flags.help || args.command === "help") {
56
+ help();
57
+ return;
58
+ }
59
+ const cwd = process.cwd();
60
+ switch (args.command) {
61
+ case "install": {
62
+ const onlyRaw = args.flags.only;
63
+ const only = typeof onlyRaw === "string"
64
+ ? onlyRaw.split(",").map((s) => s.trim()).filter(Boolean)
65
+ : undefined;
66
+ install({
67
+ cwd,
68
+ only,
69
+ global: Boolean(args.flags.global),
70
+ force: Boolean(args.flags.force),
71
+ skipAgentsMd: Boolean(args.flags["skip-agents-md"]),
72
+ });
73
+ return;
74
+ }
75
+ case "status":
76
+ status(cwd);
77
+ return;
78
+ case "clean":
79
+ clean({ cwd, global: Boolean(args.flags.global) });
80
+ return;
81
+ default:
82
+ log.err(`Unknown command: ${args.command}`);
83
+ help();
84
+ process.exitCode = 1;
85
+ }
86
+ }
87
+ main().catch((e) => {
88
+ log.err(e instanceof Error ? e.message : String(e));
89
+ process.exitCode = 1;
90
+ });
@@ -0,0 +1,43 @@
1
+ import path from "node:path";
2
+ import { ADAPTERS } from "../adapters/index.js";
3
+ import { isSymlink, safeRemove } from "../core/fs.js";
4
+ import { removeGitignoreBlock } from "../core/gitignore.js";
5
+ import { log } from "../core/log.js";
6
+ import { expandHome } from "../core/paths.js";
7
+ /**
8
+ * Remove generated targets. AGENTS.md + AGENTS.d/ are NEVER touched —
9
+ * they are user content. Only wrappers, symlinks, and skill files go.
10
+ */
11
+ export function clean(opts) {
12
+ let removed = 0;
13
+ const agentsMd = path.resolve(opts.cwd, "AGENTS.md");
14
+ for (const a of ADAPTERS) {
15
+ for (const rel of a.projectTargets) {
16
+ const target = path.join(opts.cwd, rel);
17
+ if (path.resolve(target) === agentsMd)
18
+ continue;
19
+ // For non-wrapper targets we only remove if they're symlinks (we made them).
20
+ // For wrappers (cursor/windsurf) we remove regardless — they're generated.
21
+ if (a.wrapper || isSymlink(target)) {
22
+ if (safeRemove(target)) {
23
+ removed++;
24
+ log.info(`removed ${rel}`);
25
+ }
26
+ }
27
+ }
28
+ if (a.projectSkill && safeRemove(path.join(opts.cwd, a.projectSkill))) {
29
+ removed++;
30
+ log.info(`removed ${a.projectSkill}`);
31
+ }
32
+ if (opts.global) {
33
+ if (a.globalTarget && isSymlink(expandHome(a.globalTarget))) {
34
+ if (safeRemove(expandHome(a.globalTarget)))
35
+ removed++;
36
+ }
37
+ if (a.globalSkill && safeRemove(expandHome(a.globalSkill)))
38
+ removed++;
39
+ }
40
+ }
41
+ removeGitignoreBlock(opts.cwd);
42
+ log.ok(`Removed ${removed} file(s). AGENTS.md + AGENTS.d/ left untouched.`);
43
+ }
@@ -0,0 +1,186 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { ADAPTERS, byName } from "../adapters/index.js";
4
+ import { renderSkill } from "../adapters/skillFormats.js";
5
+ import { ensureDir, exists, linkOrCopy, writeFile } from "../core/fs.js";
6
+ import { upsertGitignore } from "../core/gitignore.js";
7
+ import { log } from "../core/log.js";
8
+ import { expandHome } from "../core/paths.js";
9
+ import { listChunkTemplates, loadTemplate } from "../core/templates.js";
10
+ import { continueRuleWrapper, cursorMdcWrapper, windsurfRuleWrapper, } from "../core/wrappers.js";
11
+ export function install(opts) {
12
+ const adapters = pickAdapters(opts.only);
13
+ if (adapters.length === 0) {
14
+ log.err("No adapters matched --only filter");
15
+ process.exitCode = 1;
16
+ return;
17
+ }
18
+ if (!opts.skipAgentsMd) {
19
+ seedAgentsMd(opts.cwd, opts.force);
20
+ }
21
+ const agentsMd = path.join(opts.cwd, "AGENTS.md");
22
+ // Always protect personal override files from accidental commit.
23
+ const ignoreEntries = ["AGENTS.local.md", "AGENTS.d/local/"];
24
+ for (const a of adapters) {
25
+ installProject(a, opts.cwd, agentsMd, ignoreEntries, opts.force);
26
+ if (opts.global)
27
+ installGlobal(a, agentsMd, opts.force);
28
+ if (a.note)
29
+ log.dim(` ${a.label}: ${a.note}`);
30
+ }
31
+ if (ignoreEntries.length > 0) {
32
+ upsertGitignore(opts.cwd, dedupe(ignoreEntries));
33
+ log.ok(".gitignore updated");
34
+ }
35
+ log.ok("Done. Commit AGENTS.md + AGENTS.d/ and push.");
36
+ }
37
+ function pickAdapters(only) {
38
+ if (!only || only.length === 0)
39
+ return ADAPTERS;
40
+ const picked = [];
41
+ for (const name of only) {
42
+ const a = byName(name);
43
+ if (!a) {
44
+ log.warn(`Unknown adapter: ${name}`);
45
+ continue;
46
+ }
47
+ picked.push(a);
48
+ }
49
+ return picked;
50
+ }
51
+ function seedAgentsMd(cwd, force) {
52
+ const dest = path.join(cwd, "AGENTS.md");
53
+ if (exists(dest) && !force) {
54
+ log.info("AGENTS.md already exists — keeping it. Use --force to overwrite.");
55
+ }
56
+ else {
57
+ writeFile(dest, loadTemplate("AGENTS.md"));
58
+ log.ok("Wrote AGENTS.md");
59
+ }
60
+ const chunksDir = path.join(cwd, "AGENTS.d");
61
+ ensureDir(chunksDir);
62
+ for (const chunk of listChunkTemplates()) {
63
+ const target = path.join(chunksDir, chunk);
64
+ if (exists(target) && !force)
65
+ continue;
66
+ writeFile(target, loadTemplate(path.join("AGENTS.d", chunk)));
67
+ }
68
+ log.ok("Seeded AGENTS.d/ chunks");
69
+ }
70
+ function installProject(a, cwd, agentsMd, ignoreEntries, force) {
71
+ // 1. Project instruction target
72
+ for (const rel of a.projectTargets) {
73
+ const target = path.join(cwd, rel);
74
+ // AGENTS.md is itself a project target for some adapters — skip, it's the source.
75
+ if (path.resolve(target) === path.resolve(agentsMd))
76
+ continue;
77
+ if (a.wrapper === "cursor-mdc") {
78
+ writeWrapper(target, cursorMdcWrapper(target, agentsMd), force);
79
+ log.info(`${a.label}: ${rel} (wrapper)`);
80
+ }
81
+ else if (a.wrapper === "windsurf-rule") {
82
+ writeWrapper(target, windsurfRuleWrapper(target, agentsMd), force);
83
+ log.info(`${a.label}: ${rel} (wrapper)`);
84
+ }
85
+ else if (a.wrapper === "continue-rule") {
86
+ writeWrapper(target, continueRuleWrapper(target, agentsMd), force);
87
+ log.info(`${a.label}: ${rel} (wrapper)`);
88
+ }
89
+ else {
90
+ const mode = linkOrCopy(agentsMd, target);
91
+ if (mode === "copy") {
92
+ log.warn(`${a.label}: ${rel} fell back to COPY (symlink unavailable). ` +
93
+ `Re-run \`context-sync install --force\` after editing AGENTS.md ` +
94
+ `to re-sync.`);
95
+ }
96
+ else {
97
+ log.info(`${a.label}: ${rel} (${mode})`);
98
+ }
99
+ }
100
+ ignoreEntries.push(normalizeIgnore(rel));
101
+ }
102
+ // 2. Project skill file
103
+ if (a.projectSkill && a.skillFormat !== "none") {
104
+ // Skip if the project skill is the same path as the project target
105
+ // (e.g. cursor .mdc file doubles as rule + skill).
106
+ const isAlsoTarget = a.projectTargets.includes(a.projectSkill);
107
+ if (!isAlsoTarget) {
108
+ const skillPath = path.join(cwd, a.projectSkill);
109
+ writeSkill(skillPath, a.skillFormat, force);
110
+ log.info(`${a.label}: ${a.projectSkill}`);
111
+ ignoreEntries.push(normalizeIgnore(a.projectSkill));
112
+ }
113
+ }
114
+ // 3. Aider special case — append to conf
115
+ if (a.name === "aider") {
116
+ writeAiderConf(cwd);
117
+ log.info("aider: .aider.conf.yml updated");
118
+ }
119
+ }
120
+ function installGlobal(a, agentsMd, force) {
121
+ if (a.globalTarget) {
122
+ const target = expandHome(a.globalTarget);
123
+ if (exists(target) && !force) {
124
+ log.info(`${a.label} (global): ${a.globalTarget} already exists`);
125
+ }
126
+ else {
127
+ const mode = linkOrCopy(agentsMd, target);
128
+ log.info(`${a.label} (global): ${a.globalTarget} (${mode})`);
129
+ }
130
+ }
131
+ if (a.globalSkill && a.skillFormat !== "none") {
132
+ const target = expandHome(a.globalSkill);
133
+ writeSkill(target, a.skillFormat, force);
134
+ log.info(`${a.label} (global skill): ${a.globalSkill}`);
135
+ }
136
+ }
137
+ function writeWrapper(target, content, force) {
138
+ if (exists(target) && !force) {
139
+ const existing = fs.readFileSync(target, "utf8");
140
+ if (existing === content)
141
+ return;
142
+ }
143
+ writeFile(target, content);
144
+ }
145
+ function writeSkill(target, format, force) {
146
+ const body = loadTemplate("SKILL.md");
147
+ const content = renderSkill(format, body);
148
+ if (exists(target) && !force) {
149
+ const existing = fs.readFileSync(target, "utf8");
150
+ if (existing === content)
151
+ return;
152
+ }
153
+ writeFile(target, content);
154
+ }
155
+ function writeAiderConf(cwd) {
156
+ const file = path.join(cwd, ".aider.conf.yml");
157
+ const existing = exists(file) ? fs.readFileSync(file, "utf8") : "";
158
+ // Already wired (block-form read: with AGENTS.md).
159
+ if (/^\s*read:\s*$/m.test(existing) && existing.includes("AGENTS.md"))
160
+ return;
161
+ // Inline list form: `read: [foo.md, bar.md]` — can't safely edit with regex.
162
+ // Bail with a visible warning rather than corrupt the YAML.
163
+ if (/^\s*read:\s*\[/m.test(existing)) {
164
+ log.warn("aider: .aider.conf.yml uses inline `read: [...]` form. " +
165
+ "Add `AGENTS.md` to that list manually.");
166
+ return;
167
+ }
168
+ // Inline scalar form: `read: foo.md` — also skip rather than guess.
169
+ if (/^\s*read:\s*\S/m.test(existing) && !/^\s*read:\s*$/m.test(existing)) {
170
+ log.warn("aider: .aider.conf.yml has a non-block `read:` entry. " +
171
+ "Convert it to list form and add `AGENTS.md`.");
172
+ return;
173
+ }
174
+ const addition = existing.includes("read:")
175
+ ? existing.replace(/read:\s*\n/, "read:\n - AGENTS.md\n")
176
+ : existing +
177
+ (existing.endsWith("\n") || existing === "" ? "" : "\n") +
178
+ "read:\n - AGENTS.md\n";
179
+ writeFile(file, addition);
180
+ }
181
+ function normalizeIgnore(rel) {
182
+ return rel.split(path.sep).join("/");
183
+ }
184
+ function dedupe(arr) {
185
+ return Array.from(new Set(arr));
186
+ }
@@ -0,0 +1,31 @@
1
+ import path from "node:path";
2
+ import { ADAPTERS } from "../adapters/index.js";
3
+ import { exists } from "../core/fs.js";
4
+ import { log } from "../core/log.js";
5
+ import { expandHome } from "../core/paths.js";
6
+ export function status(cwd) {
7
+ const agentsMd = path.join(cwd, "AGENTS.md");
8
+ if (exists(agentsMd))
9
+ log.ok(`AGENTS.md found at ${agentsMd}`);
10
+ else
11
+ log.warn("AGENTS.md not found in cwd — run `context-sync install`.");
12
+ console.log("");
13
+ console.log("Adapters:");
14
+ for (const a of ADAPTERS) {
15
+ const projectHits = a.projectTargets.filter((t) => exists(path.join(cwd, t)));
16
+ const globalHit = a.globalTarget ? exists(expandHome(a.globalTarget)) : null;
17
+ const skillProjectHit = a.projectSkill ? exists(path.join(cwd, a.projectSkill)) : null;
18
+ const skillGlobalHit = a.globalSkill ? exists(expandHome(a.globalSkill)) : null;
19
+ const parts = [];
20
+ if (a.projectTargets.length > 0) {
21
+ parts.push(`project ${projectHits.length}/${a.projectTargets.length}`);
22
+ }
23
+ if (a.globalTarget)
24
+ parts.push(`global ${globalHit ? "✓" : "✗"}`);
25
+ if (a.projectSkill)
26
+ parts.push(`skill-proj ${skillProjectHit ? "✓" : "✗"}`);
27
+ if (a.globalSkill)
28
+ parts.push(`skill-user ${skillGlobalHit ? "✓" : "✗"}`);
29
+ console.log(` ${a.name.padEnd(14)} ${a.label.padEnd(22)} ${parts.join(" · ")}`);
30
+ }
31
+ }
@@ -0,0 +1,65 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ export function ensureDir(dir) {
4
+ fs.mkdirSync(dir, { recursive: true });
5
+ }
6
+ export function writeFile(file, content) {
7
+ ensureDir(path.dirname(file));
8
+ fs.writeFileSync(file, content, "utf8");
9
+ }
10
+ export function exists(p) {
11
+ try {
12
+ fs.lstatSync(p);
13
+ return true;
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ }
19
+ /** True when `p` is a symlink (not a regular file). */
20
+ export function isSymlink(p) {
21
+ try {
22
+ return fs.lstatSync(p).isSymbolicLink();
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ }
28
+ /**
29
+ * Point `target` at `source`. Tries symlink first; falls back to copy on
30
+ * Windows without Dev Mode / without admin. Idempotent.
31
+ */
32
+ export function linkOrCopy(source, target) {
33
+ ensureDir(path.dirname(target));
34
+ if (exists(target)) {
35
+ if (isSymlink(target)) {
36
+ const current = fs.readlinkSync(target);
37
+ const resolved = path.resolve(path.dirname(target), current);
38
+ if (resolved === path.resolve(source))
39
+ return "unchanged";
40
+ }
41
+ else {
42
+ // regular file — only overwrite if contents differ and caller allowed it
43
+ const a = fs.readFileSync(target, "utf8");
44
+ const b = fs.readFileSync(source, "utf8");
45
+ if (a === b)
46
+ return "unchanged";
47
+ }
48
+ fs.rmSync(target, { force: true });
49
+ }
50
+ try {
51
+ fs.symlinkSync(path.resolve(source), target, "file");
52
+ return "symlink";
53
+ }
54
+ catch {
55
+ fs.copyFileSync(source, target);
56
+ return "copy";
57
+ }
58
+ }
59
+ /** Remove a file/symlink if it exists and the caller recognizes it. */
60
+ export function safeRemove(p) {
61
+ if (!exists(p))
62
+ return false;
63
+ fs.rmSync(p, { force: true });
64
+ return true;
65
+ }
@@ -0,0 +1,38 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ const MARK_START = "# >>> context-sync (generated, do not edit) >>>";
4
+ const MARK_END = "# <<< context-sync <<<";
5
+ /** Idempotently add a block of ignore entries between markers. */
6
+ export function upsertGitignore(repoRoot, entries) {
7
+ const file = path.join(repoRoot, ".gitignore");
8
+ const block = [MARK_START, ...entries, MARK_END, ""].join("\n");
9
+ const existing = fs.existsSync(file) ? fs.readFileSync(file, "utf8") : "";
10
+ const startIdx = existing.indexOf(MARK_START);
11
+ const endIdx = existing.indexOf(MARK_END);
12
+ let next;
13
+ if (startIdx >= 0 && endIdx > startIdx) {
14
+ next =
15
+ existing.slice(0, startIdx) +
16
+ block +
17
+ existing.slice(endIdx + MARK_END.length + 1);
18
+ }
19
+ else {
20
+ next = existing.endsWith("\n") || existing === "" ? existing : existing + "\n";
21
+ next += "\n" + block;
22
+ }
23
+ fs.writeFileSync(file, next, "utf8");
24
+ }
25
+ /** Remove the managed block entirely. */
26
+ export function removeGitignoreBlock(repoRoot) {
27
+ const file = path.join(repoRoot, ".gitignore");
28
+ if (!fs.existsSync(file))
29
+ return;
30
+ const existing = fs.readFileSync(file, "utf8");
31
+ const startIdx = existing.indexOf(MARK_START);
32
+ const endIdx = existing.indexOf(MARK_END);
33
+ if (startIdx < 0 || endIdx < 0)
34
+ return;
35
+ const next = existing.slice(0, startIdx).replace(/\n+$/, "\n") +
36
+ existing.slice(endIdx + MARK_END.length + 1);
37
+ fs.writeFileSync(file, next, "utf8");
38
+ }
@@ -0,0 +1,12 @@
1
+ const DIM = "\x1b[2m";
2
+ const RESET = "\x1b[0m";
3
+ const GREEN = "\x1b[32m";
4
+ const YELLOW = "\x1b[33m";
5
+ const RED = "\x1b[31m";
6
+ export const log = {
7
+ ok: (msg) => console.log(`${GREEN}✔${RESET} ${msg}`),
8
+ info: (msg) => console.log(` ${msg}`),
9
+ warn: (msg) => console.log(`${YELLOW}!${RESET} ${msg}`),
10
+ err: (msg) => console.error(`${RED}✗${RESET} ${msg}`),
11
+ dim: (msg) => console.log(`${DIM}${msg}${RESET}`),
12
+ };
@@ -0,0 +1,18 @@
1
+ import os from "node:os";
2
+ import path from "node:path";
3
+ /** Expand ~ and ~/ prefixes to the user's home dir. */
4
+ export function expandHome(p) {
5
+ if (p === "~")
6
+ return os.homedir();
7
+ if (p.startsWith("~/") || p.startsWith("~\\")) {
8
+ return path.join(os.homedir(), p.slice(2));
9
+ }
10
+ return p;
11
+ }
12
+ /** Relative path from one abs file to another, POSIX-style for symlinks. */
13
+ export function relFromTo(from, to) {
14
+ return path
15
+ .relative(path.dirname(from), to)
16
+ .split(path.sep)
17
+ .join(path.posix.sep);
18
+ }
@@ -0,0 +1,18 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
+ // Templates live next to this compiled file in dist/, mirrored from src/templates.
6
+ // We resolve relative to the compiled location.
7
+ const TEMPLATES_DIR = path.resolve(__dirname, "..", "templates");
8
+ export function loadTemplate(relPath) {
9
+ const abs = path.join(TEMPLATES_DIR, relPath);
10
+ return fs.readFileSync(abs, "utf8");
11
+ }
12
+ export function listChunkTemplates() {
13
+ const dir = path.join(TEMPLATES_DIR, "AGENTS.d");
14
+ return fs.readdirSync(dir).filter((f) => f.endsWith(".md"));
15
+ }
16
+ export function templatesRoot() {
17
+ return TEMPLATES_DIR;
18
+ }
@@ -0,0 +1,43 @@
1
+ import { relFromTo } from "./paths.js";
2
+ /**
3
+ * Cursor `.mdc` rule file that always applies and @includes AGENTS.md.
4
+ * Cursor honors frontmatter + `@file:` references.
5
+ */
6
+ export function cursorMdcWrapper(wrapperPath, agentsMdAbs) {
7
+ const rel = relFromTo(wrapperPath, agentsMdAbs);
8
+ return `---
9
+ description: Shared project context from AGENTS.md
10
+ alwaysApply: true
11
+ ---
12
+
13
+ @file:${rel}
14
+ `;
15
+ }
16
+ /** Windsurf rule with always-on activation that references AGENTS.md. */
17
+ export function windsurfRuleWrapper(wrapperPath, agentsMdAbs) {
18
+ const rel = relFromTo(wrapperPath, agentsMdAbs);
19
+ return `---
20
+ trigger: always_on
21
+ description: Shared project context from AGENTS.md
22
+ ---
23
+
24
+ See [AGENTS.md](${rel}) and \`AGENTS.d/\` for full protocol and chunks.
25
+ Read AGENTS.md first, then grep AGENTS.d/ on demand.
26
+ `;
27
+ }
28
+ /**
29
+ * Continue.dev rule with alwaysApply frontmatter that references AGENTS.md.
30
+ * Continue requires frontmatter for a rule file to auto-apply.
31
+ */
32
+ export function continueRuleWrapper(wrapperPath, agentsMdAbs) {
33
+ const rel = relFromTo(wrapperPath, agentsMdAbs);
34
+ return `---
35
+ name: Shared Agent Context
36
+ alwaysApply: true
37
+ description: Shared project context from AGENTS.md
38
+ ---
39
+
40
+ See [AGENTS.md](${rel}) and \`AGENTS.d/\` for the full protocol and chunks.
41
+ Read AGENTS.md first, then grep AGENTS.d/ on demand.
42
+ `;
43
+ }
@@ -0,0 +1,3 @@
1
+ # api
2
+
3
+ <!-- One fact per line. Format: `#api short fact` -->
@@ -0,0 +1,3 @@
1
+ # bugs
2
+
3
+ <!-- One fact per line. Format: `#bugs short fact` -->
@@ -0,0 +1,3 @@
1
+ # deploy
2
+
3
+ <!-- One fact per line. Format: `#deploy short fact` -->
@@ -0,0 +1,3 @@
1
+ # prefs
2
+
3
+ <!-- One fact per line. Format: `#prefs short fact` -->
@@ -0,0 +1,3 @@
1
+ # stack
2
+
3
+ <!-- One fact per line. Format: `#stack short fact` -->
@@ -0,0 +1,3 @@
1
+ # style
2
+
3
+ <!-- One fact per line. Format: `#style short fact` -->
@@ -0,0 +1,41 @@
1
+ # Shared Agent Context
2
+
3
+ > You're an AI coding agent reading this file. Follow the protocol below.
4
+ > This file is small on purpose. Most context lives in `AGENTS.d/`.
5
+ > Grep it. Don't load it all.
6
+
7
+ ## Protocol
8
+
9
+ **READ**
10
+ 1. These pinned facts (top of this file) always apply.
11
+ 2. Need more? Run: `rg "<keyword>" AGENTS.d/`
12
+ 3. Or read one chunk: `AGENTS.d/<tag>.md` (tags listed below).
13
+ 4. Never read all of `AGENTS.d/` at once — defeats the point.
14
+
15
+ **WRITE** (when you learn a durable fact)
16
+ Durable = stack choice, bug cause, convention, user preference, API contract,
17
+ deploy quirk. NOT ephemeral task state.
18
+
19
+ 1. Pick the right tag below (or create a new chunk file).
20
+ 2. Grep first: `rg "<key phrase>" AGENTS.d/<tag>.md` — if present, skip.
21
+ 3. Append ONE line to `AGENTS.d/<tag>.md`:
22
+ `#tag short fact under 120 chars`
23
+ 4. New tag? Add one line to the index below.
24
+ 5. Never delete lines you didn't write this session. Append-only.
25
+
26
+ **LOCAL OVERRIDES**
27
+ If `AGENTS.local.md` or `AGENTS.d/local/*.md` exist, read them after the
28
+ shared files. Later overrides earlier. Local files are gitignored.
29
+
30
+ ## Tag index
31
+
32
+ - `stack` — languages, frameworks, versions
33
+ - `style` — code conventions, what to avoid
34
+ - `bugs` — known issues + fixes
35
+ - `api` — endpoints, auth, contracts
36
+ - `deploy` — infra, env, release process
37
+ - `prefs` — user preferences
38
+
39
+ ## Pinned
40
+
41
+ <!-- Add !pinned lines here. One line per fact. Keep this section small. -->
@@ -0,0 +1,30 @@
1
+ # context-sync — shared agent memory
2
+
3
+ You are reading this because the user installed `context-sync`. Your job:
4
+
5
+ ## READ (before answering)
6
+ 1. Load `AGENTS.md` — tiny router with pinned facts + tag index.
7
+ 2. Need more? Run: `rg "<keyword>" AGENTS.d/`
8
+ 3. Or open one chunk file: `AGENTS.d/<tag>.md`
9
+ 4. Never read all of `AGENTS.d/` at once — defeats the point.
10
+
11
+ ## WRITE (when you learn something durable)
12
+ A durable fact = stack choice, bug cause, convention, user preference,
13
+ API contract, deploy quirk. NOT current task state or ephemeral TODOs.
14
+
15
+ 1. Pick the right tag from the index (or create a new chunk file).
16
+ 2. Grep first: `rg "<key phrase>" AGENTS.d/<tag>.md` — skip if present.
17
+ 3. Append ONE line to `AGENTS.d/<tag>.md`:
18
+ #tag short fact under 120 chars
19
+ 4. If you created a new tag, add one line to the index in AGENTS.md.
20
+ 5. Never delete lines you didn't write this session. Append-only.
21
+
22
+ ## PROJECT vs LOCAL
23
+ - `AGENTS.md` + `AGENTS.d/` → shared, committed.
24
+ - `AGENTS.local.md` + `AGENTS.d/local/` → personal, gitignored.
25
+ Read shared first, then local. Later overrides earlier.
26
+
27
+ ## WHEN TO APPLY
28
+ - At session start of any coding task in a repo with AGENTS.md.
29
+ - When the user says "remember", "note that", "for next time".
30
+ - After debugging something non-obvious — write it down so next session knows.
@@ -0,0 +1,103 @@
1
+ import { test } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import fs from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { install } from "../src/commands/install.js";
7
+ import { clean } from "../src/commands/clean.js";
8
+ function tmpRepo() {
9
+ return fs.mkdtempSync(path.join(os.tmpdir(), "csync-"));
10
+ }
11
+ test("install creates AGENTS.md and chunks", () => {
12
+ const cwd = tmpRepo();
13
+ install({ cwd, global: false, force: false, skipAgentsMd: false });
14
+ assert.ok(fs.existsSync(path.join(cwd, "AGENTS.md")), "AGENTS.md exists");
15
+ assert.ok(fs.existsSync(path.join(cwd, "AGENTS.d", "stack.md")), "stack chunk exists");
16
+ assert.ok(fs.existsSync(path.join(cwd, ".gitignore")), ".gitignore exists");
17
+ });
18
+ test("install wires claude + opencode targets", () => {
19
+ const cwd = tmpRepo();
20
+ install({
21
+ cwd,
22
+ only: ["claude-code", "opencode"],
23
+ global: false,
24
+ force: false,
25
+ skipAgentsMd: false,
26
+ });
27
+ assert.ok(fs.existsSync(path.join(cwd, "CLAUDE.md")), "CLAUDE.md wired");
28
+ // opencode's project target IS AGENTS.md itself, so nothing extra; skill file exists
29
+ assert.ok(fs.existsSync(path.join(cwd, ".opencode", "agent", "context-sync.md")), "opencode skill exists");
30
+ });
31
+ test("install wires cursor wrapper with alwaysApply: true", () => {
32
+ const cwd = tmpRepo();
33
+ install({ cwd, only: ["cursor"], global: false, force: false, skipAgentsMd: false });
34
+ const mdc = path.join(cwd, ".cursor", "rules", "context-sync.mdc");
35
+ assert.ok(fs.existsSync(mdc));
36
+ const content = fs.readFileSync(mdc, "utf8");
37
+ assert.match(content, /alwaysApply: true/);
38
+ assert.match(content, /@file:/);
39
+ });
40
+ test("install is idempotent", () => {
41
+ const cwd = tmpRepo();
42
+ const opts = { cwd, global: false, force: false, skipAgentsMd: false };
43
+ install(opts);
44
+ const before = fs.readFileSync(path.join(cwd, "AGENTS.md"), "utf8");
45
+ install(opts);
46
+ const after = fs.readFileSync(path.join(cwd, "AGENTS.md"), "utf8");
47
+ assert.equal(before, after);
48
+ });
49
+ test("clean removes generated files but keeps AGENTS.md + chunks", () => {
50
+ const cwd = tmpRepo();
51
+ install({ cwd, global: false, force: false, skipAgentsMd: false });
52
+ assert.ok(fs.existsSync(path.join(cwd, "CLAUDE.md")));
53
+ clean({ cwd, global: false });
54
+ assert.ok(fs.existsSync(path.join(cwd, "AGENTS.md")), "AGENTS.md preserved");
55
+ assert.ok(fs.existsSync(path.join(cwd, "AGENTS.d", "stack.md")), "chunks preserved");
56
+ });
57
+ test("aider conf is written with AGENTS.md read entry", () => {
58
+ const cwd = tmpRepo();
59
+ install({ cwd, only: ["aider"], global: false, force: false, skipAgentsMd: false });
60
+ const conf = fs.readFileSync(path.join(cwd, ".aider.conf.yml"), "utf8");
61
+ assert.match(conf, /read:/);
62
+ assert.match(conf, /AGENTS\.md/);
63
+ // Aider should not create a dead CONVENTIONS.md file.
64
+ assert.ok(!fs.existsSync(path.join(cwd, "CONVENTIONS.md")));
65
+ });
66
+ test("aider conf with inline read list is left alone with warning", () => {
67
+ const cwd = tmpRepo();
68
+ fs.writeFileSync(path.join(cwd, ".aider.conf.yml"), "read: [foo.md, bar.md]\n", "utf8");
69
+ install({ cwd, only: ["aider"], global: false, force: false, skipAgentsMd: false });
70
+ const conf = fs.readFileSync(path.join(cwd, ".aider.conf.yml"), "utf8");
71
+ // Original content preserved — no duplicate `read:` block appended.
72
+ assert.equal(conf, "read: [foo.md, bar.md]\n");
73
+ });
74
+ test("continue adapter writes frontmatter wrapper, not raw symlink", () => {
75
+ const cwd = tmpRepo();
76
+ install({
77
+ cwd,
78
+ only: ["continue"],
79
+ global: false,
80
+ force: false,
81
+ skipAgentsMd: false,
82
+ });
83
+ const rulePath = path.join(cwd, ".continue", "rules", "context-sync.md");
84
+ assert.ok(fs.existsSync(rulePath));
85
+ const content = fs.readFileSync(rulePath, "utf8");
86
+ assert.match(content, /alwaysApply: true/);
87
+ assert.match(content, /AGENTS\.md/);
88
+ });
89
+ test("gitignore includes AGENTS.local.md and AGENTS.d/local/", () => {
90
+ const cwd = tmpRepo();
91
+ install({ cwd, global: false, force: false, skipAgentsMd: false });
92
+ const gi = fs.readFileSync(path.join(cwd, ".gitignore"), "utf8");
93
+ assert.match(gi, /AGENTS\.local\.md/);
94
+ assert.match(gi, /AGENTS\.d\/local\//);
95
+ });
96
+ test("existing AGENTS.md is preserved without --force", () => {
97
+ const cwd = tmpRepo();
98
+ const original = "# my own AGENTS.md\n\nhand-written content\n";
99
+ fs.writeFileSync(path.join(cwd, "AGENTS.md"), original, "utf8");
100
+ install({ cwd, global: false, force: false, skipAgentsMd: false });
101
+ const after = fs.readFileSync(path.join(cwd, "AGENTS.md"), "utf8");
102
+ assert.equal(after, original);
103
+ });
package/package.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "md-gossip",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "One AGENTS.md for every coding agent. Agents gossip: read, write, and share project context — zero scripts.",
5
+ "keywords": [
6
+ "agents.md",
7
+ "ai",
8
+ "agent",
9
+ "gossip",
10
+ "claude",
11
+ "codex",
12
+ "devin",
13
+ "opencode",
14
+ "antigravity",
15
+ "cursor",
16
+ "copilot",
17
+ "context"
18
+ ],
19
+ "license": "MIT",
20
+ "type": "module",
21
+ "homepage": "https://github.com/aeiyannn/md-gossip#readme",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/aeiyannn/md-gossip.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/aeiyannn/md-gossip/issues"
28
+ },
29
+ "author": "aeiyankhan",
30
+ "bin": {
31
+ "md-gossip": "bin/context-sync.js",
32
+ "gossip": "bin/context-sync.js"
33
+ },
34
+ "files": [
35
+ "bin",
36
+ "dist",
37
+ "README.md"
38
+ ],
39
+ "scripts": {
40
+ "build": "tsc && node scripts/copy-templates.mjs",
41
+ "prepublishOnly": "npm run build",
42
+ "test": "npm run build && node --test dist/test/smoke.test.js"
43
+ },
44
+ "engines": {
45
+ "node": ">=18"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^20.11.0",
52
+ "typescript": "^5.4.0"
53
+ }
54
+ }