Skip to content

Commit 551c626

Browse files
committed
Refactor AGENTS.md to point to detailed docs and shorten package.json description
1 parent cf1a542 commit 551c626

File tree

9 files changed

+160
-181
lines changed

9 files changed

+160
-181
lines changed

AGENTS.md

Lines changed: 18 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -1,182 +1,20 @@
11
# AGENTS.md
22

3-
This repository is a Node.js/Bun TypeScript CLI for managing AI agent configurations.
4-
It provides an adapter-based architecture to sync configs for Claude Code, Cursor,
5-
Windsurf, OpenCode, and VSCode across machines using git and symlinks/copies.
6-
7-
## Quick facts
8-
- Runtime: Node.js ≥20 or Bun
9-
- Language: TypeScript (ES modules)
10-
- Entry point: src/index.ts (shebang: `#!/usr/bin/env node`)
11-
- Build: tsup (outputs to dist/)
12-
- OS targets: macOS + Linux (Windows planned)
13-
- Package manager: npm or bun
14-
- Package name: @donnes/syncode
15-
16-
## Commands (build / lint / test)
17-
- Install dependencies: `bun install` or `npm install`
18-
- Run CLI in dev mode: `bun run dev` (uses tsx)
19-
- Build for production: `bun run build` (uses tsup)
20-
- Type check: `bun run typecheck`
21-
- Link the CLI globally: `bun link` or `npm link`
22-
- CLI usage help: `syncode help`
23-
24-
Notes
25-
- There is no lint script defined in `package.json`.
26-
- There is no test runner configured in this repo.
27-
- Build outputs to `dist/` directory via tsup.
28-
29-
## Single-test guidance
30-
- No test framework is configured, so there is no "single test" command.
31-
- If you add tests, also add a `package.json` script and document the single-test
32-
usage here.
33-
34-
## Repository structure
35-
- `src/index.ts` is the CLI entry and interactive menu.
36-
- `src/commands/` contains 3 user-facing commands: new, sync, status
37-
- `src/adapters/` contains agent adapters implementing AgentAdapter interface
38-
- `src/config/` contains configuration management (manager.ts, types.ts)
39-
- `src/utils/` contains shared helpers (fs/git/paths/shell/platform).
40-
- `configs/` (in user's repo) stores tracked agent configs
41-
42-
## Architecture
43-
44-
### Adapter System
45-
The project uses an adapter-based architecture where each AI agent has its own adapter:
46-
- **AgentAdapter interface** (`src/adapters/types.ts`) - defines the contract
47-
- **Built-in adapters** - claude, cursor, windsurf, opencode, vscode
48-
- **AdapterRegistry** (`src/adapters/registry.ts`) - central registry for all adapters
49-
- Each adapter handles platform-specific paths, import/export, and sync strategies
50-
51-
### Sync Strategies
52-
- **Symlink** (default): Live sync, changes reflected immediately
53-
- **Copy**: One-way copy (used for Claude to preserve cache/history)
54-
- Configured per adapter in `syncStrategy.import` and `syncStrategy.export`
55-
56-
### Configuration
57-
- Global config stored at `~/.syncode/config.json`
58-
- User's agent configs stored in their chosen repo (e.g., `~/agent-configs`)
59-
- Each adapter determines its own system paths per platform
60-
61-
## Code style guidelines
62-
63-
### Formatting
64-
- Use double quotes for strings.
65-
- Use semicolons.
66-
- Use trailing commas in object/array literals.
67-
- One statement per line; avoid clever one-liners.
68-
- Keep functions small and single-purpose.
69-
- Favor explicit spacing for readability.
70-
71-
### Imports
72-
- Use ES module syntax (import/export, not require).
73-
- Order: external packages first, then relative imports.
74-
- Use `import type` for types when possible.
75-
- Prefer named imports; use `import * as p` for @clack/prompts.
76-
77-
### Types and interfaces
78-
- Prefer interfaces for shared shapes (see `src/adapters/types.ts`).
79-
- Keep union types narrow and explicit (e.g. Platform: "macos" | "linux" | "windows").
80-
- Use `Record<string, T>` for indexed dictionaries.
81-
- Avoid `any`; if unavoidable, keep it local and explain with context.
82-
- Keep result types consistent (`success`, `message`, optional fields).
83-
84-
### Naming conventions
85-
- File names are lowercase with dashes only when needed.
86-
- Functions are `camelCase`.
87-
- Classes/Interfaces are `PascalCase` (e.g. `AgentAdapter`, `AdapterRegistry`).
88-
- Constants are `SCREAMING_SNAKE_CASE` only for true constants (e.g. `SUPPORTED_AGENTS`).
89-
- Adapter IDs are lowercase (e.g. "claude", "cursor", "opencode").
90-
91-
### Error handling
92-
- Use `try/catch` around filesystem and shell operations.
93-
- Return structured results (success + message) rather than throwing.
94-
- When catching, surface a clear message for the CLI user.
95-
- In CLI flows, cancel early on prompt cancellations.
96-
97-
### Async / sync usage
98-
- Use async/await for shell calls and long-running operations.
99-
- Synchronous fs calls are acceptable for small, controlled operations.
100-
- Keep CLI output responsive; use spinners for long operations.
101-
102-
### CLI UX
103-
- Use @clack/prompts for interactive flows.
104-
- Always handle cancellations with `p.isCancel`.
105-
- Use `p.intro` / `p.outro` for command boundaries.
106-
- Keep status output short and scannable.
107-
108-
### Filesystem operations
109-
- Use helpers from `src/utils/fs.ts` when available.
110-
- Always ensure parent directories exist before writing.
111-
- Respect symlink behavior: avoid overwriting without backups.
112-
- For config exports, back up existing paths when not symlinked.
113-
114-
### Git operations
115-
- Use helpers from `src/utils/git.ts`.
116-
- Prefer `git -C` with `REPO_ROOT`.
117-
- Keep git output minimal and user-friendly.
118-
119-
### Paths
120-
- Use `systemPaths` and `repoPaths` from `src/utils/paths.ts`.
121-
- Prefer `contractHome` for user-facing paths.
122-
- Avoid hardcoding OS-specific locations.
123-
124-
## Adding new commands
125-
- Place new command files in `src/commands/`.
126-
- Export a single `*Command` function (async, no parameters).
127-
- Import and register in `src/index.ts` in the `commands` object.
128-
- Add to the interactive menu options in the `p.select` call.
129-
- Add to `showHelp()` function for CLI help output.
130-
131-
## Adding new agent adapters
132-
- Implement `AgentAdapter` interface from `src/adapters/types.ts`.
133-
- Create new file in `src/adapters/` (e.g., `newagentagent.ts`).
134-
- Export adapter instance (e.g., `export const newAgentAdapter: AgentAdapter`).
135-
- Import and register in `src/adapters/registry.ts` in `registerBuiltinAdapters()`.
136-
- Add agent ID to `SUPPORTED_AGENTS` in `src/config/types.ts`.
137-
- Define sync strategy (symlink or copy) in adapter definition.
138-
- Implement platform-specific path resolution in `getConfigPath()`.
139-
- Keep import/export logic symmetric and idempotent.
140-
141-
## Agent adapter behavior
142-
- **Import**: Copy files from system to repo (preserves originals).
143-
- **Export**: Create symlink from system to repo OR copy from repo to system.
144-
- **Backup**: Always backup existing system configs before export.
145-
- Avoid destructive operations without user confirmation.
146-
147-
## CLI Commands
148-
149-
### `syncode new`
150-
- Initialize a new agent config repository
151-
- Auto-detects installed AI agents
152-
- Prompts for repo path, GitHub remote, agent selection
153-
- Creates directory structure and initial git commit
154-
- Imports existing configs from system
155-
- Creates global config at `~/.syncode/config.json`
156-
157-
### `syncode sync`
158-
- Sync agent configs between system and repo
159-
- Prompts for direction: import (system → repo) or export (repo → system)
160-
- Import: copies configs from system to repo
161-
- Export: creates symlinks (or copies for Claude) from system to repo
162-
- Automatic backups before destructive operations
163-
164-
### `syncode status`
165-
- Show status of synced agents
166-
- Lists enabled/detected agents
167-
- Shows sync method (symlink vs copy)
168-
- Shows git status of repo
169-
170-
## Common pitfalls
171-
- Do not use `require()` - this is an ES module project, use `import` instead.
172-
- Do not assume a test runner exists.
173-
- Do not add new scripts without updating this doc.
174-
- Do not add emoji output unless already used in command output.
175-
- Remember that adapters are registered at module load time (see registry.ts).
176-
- Always use platform detection for path resolution (don't hardcode paths).
177-
178-
## When editing AGENTS.md
179-
- Keep it under 200 lines to stay readable.
180-
- Update command sections as scripts or commands change.
181-
- Document any new adapters immediately.
182-
- Document any new lint/test tools immediately.
3+
Syncode is a Node.js/Bun TypeScript CLI that syncs AI agent configurations via adapter-based git + symlink/copy workflows.
4+
5+
## Essentials
6+
- Runtime: Node.js >=20
7+
- Package manager: npm (bun supported)
8+
- Non-standard commands:
9+
- `bun run dev`
10+
- `bun run build`
11+
- `bun run typecheck`
12+
13+
## More details
14+
- `docs/agents/commands.md`
15+
- `docs/agents/project-structure.md`
16+
- `docs/agents/architecture.md`
17+
- `docs/agents/code-style.md`
18+
- `docs/agents/feature-development.md`
19+
- `docs/agents/troubleshooting.md`
20+
- `docs/agents/roadmap.md`

docs/agents/architecture.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Architecture and Sync Logic
2+
3+
## Adapter system
4+
- Each agent has an adapter in `src/adapters/` registered in `registry.ts`.
5+
6+
## Sync strategies
7+
- `symlink` (default): Live sync between system and repo.
8+
- `copy`: One-way copy (used for Claude to preserve cache).
9+
10+
## Global config
11+
- `~/.syncode/config.json` tracks the repository location.
12+
13+
## Core interface: `AgentAdapter`
14+
- `id`: Unique lowercase identifier.
15+
- `getConfigPath(platform)`: Resolves the system path for the agent's config.
16+
- `getRepoPath(repoRoot)`: Determines where the config is stored in the sync repository.
17+
- `import(system, repo)`: Logic to bring configs into the repository.
18+
- `export(repo, system)`: Logic to apply configs to the system.
19+
- `isInstalled(platform)`: Detection logic for the agent.
20+
21+
## How to add a new adapter
22+
23+
1. Create `src/adapters/<name>.ts` implementing `AgentAdapter`
24+
2. Export the adapter in `src/adapters/index.ts`
25+
3. Register it in `src/registry.ts`
26+
4. Add platform detection in `src/platforms/` if needed
27+
5. Test with `syncode status` to verify detection

docs/agents/code-style.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Code Style Guidelines
2+
3+
## Formatting and imports
4+
- Use double quotes for strings and semicolons for statements.
5+
- Use trailing commas in object/array literals.
6+
- Use ES module syntax (`import`/`export`). No `require()`.
7+
- Order: external packages first, then relative imports.
8+
- Use `import type` for type-only imports.
9+
- Prefer named imports; use `import * as p` for `@clack/prompts`.
10+
11+
## Casing and naming
12+
- File names: lowercase with dashes (e.g., `agent-adapter.ts`).
13+
- Functions/variables: `camelCase`.
14+
- Classes/interfaces: `PascalCase`.
15+
- Constants: `SCREAMING_SNAKE_CASE` (only for true constants).
16+
- Adapter IDs: lowercase (e.g., "claude").
17+
18+
## Types and error handling
19+
- Prefer interfaces for shared shapes. Use JSDoc for public fields.
20+
- Avoid `any`. Use `unknown` if necessary with type guards.
21+
- Return structured results (`{ success: boolean, message: string }`) instead of throwing when possible in CLI flows.
22+
- Use `try/catch` around filesystem and shell operations.
23+
24+
## Async and filesystem
25+
- Use `async`/`await` for shell calls and long-running operations.
26+
- Use helpers from `src/utils/fs.ts` and `src/utils/git.ts`.
27+
- Always ensure parent directories exist before writing.
28+
- Respect symlinks: avoid overwriting without backups.

docs/agents/commands.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Commands
2+
3+
## Tooling
4+
- Install dependencies: `bun install` or `npm install`
5+
- Run CLI in dev mode: `bun run dev` (uses tsx)
6+
- Build for production: `bun run build` (uses tsup)
7+
- Type check: `bun run typecheck` (uses `tsc --noEmit`)
8+
- Link CLI globally: `bun link` or `npm link`
9+
- CLI usage help: `syncode help`
10+
11+
## Release/build checklist
12+
13+
- [ ] Update version in `package.json`
14+
- [ ] Run `bun run build` to verify production build
15+
- [ ] Run `bun run typecheck` to verify types
16+
- [ ] Test CLI locally: `bun link && syncode status`
17+
- [ ] Create git tag: `git tag v<x.y.z>`
18+
- [ ] Push tag: `git push --tags`
19+
- [ ] Publish to npm (if applicable): `npm publish`
20+
21+
## Notes
22+
- No lint script or test runner currently configured.
23+
- No single-test command available yet. If you add tests, document them here.
24+
25+
## CLI commands
26+
27+
### `syncode new`
28+
- Purpose: Initializes a new agent configuration repository.
29+
- Actions:
30+
- Detects installed AI agents on the current system.
31+
- Prompts for a local repository path and an optional GitHub remote.
32+
- Creates the directory structure, `.gitignore`, and an initial git commit.
33+
- Imports existing configurations from system paths to the repository.
34+
- Persists global settings in `~/.syncode/config.json`.
35+
36+
### `syncode sync`
37+
- Purpose: Synchronizes agent configurations between the system and the repository.
38+
- Modes:
39+
- Import (System -> Repo): Copies local configuration files into the repository.
40+
- Export (Repo -> System): Applies repository configurations to the system.
41+
- Safety: Automatically creates backups of existing system configurations.
42+
43+
### `syncode status`
44+
- Purpose: Displays the current synchronization state.
45+
- Output:
46+
- List of detected and enabled agents.
47+
- Active sync method for each agent (symlink vs. copy).
48+
- Current git status of the configuration repository.
49+
50+
### `syncode push`
51+
- Purpose: Commits and pushes changes to the remote repository.
52+
- Actions:
53+
- Stages all changes in the configuration directory.
54+
- Prompts for a commit message.
55+
- Executes `git push` to the configured remote.

docs/agents/feature-development.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Feature Development
2+
3+
## New agent adapters
4+
1. Implement `AgentAdapter` in `src/adapters/types.ts`.
5+
2. Register in `src/adapters/registry.ts`.
6+
3. Define platform-specific path resolution in `getConfigPath()`.
7+
8+
## New commands
9+
1. Place in `src/commands/` and export a single async function.
10+
2. Register in `src/index.ts` in the `commands` object and `showHelp()`.

docs/agents/project-structure.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Project Structure
2+
3+
- Entry point: `src/index.ts` (shebang: `#!/usr/bin/env node`)
4+
- Build output: `dist/`
5+
- `src/commands/`: User-facing commands (new, sync, status, push).
6+
- `src/adapters/`: Agent adapters implementing `AgentAdapter`.
7+
- `src/config/`: Configuration management (manager.ts, types.ts).
8+
- `src/utils/`: Shared helpers (fs, git, paths, shell, platform).
9+
- `configs/`: In the user's repo, stores tracked agent configs.

docs/agents/roadmap.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Future Roadmap
2+
3+
- Windows support (path resolution and symlink handling).
4+
- Canonical skill format implementation (Phase 4).
5+
- Automatic periodic background sync.
6+
- Support for more editors/agents.

docs/agents/troubleshooting.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Common Pitfalls and Troubleshooting
2+
3+
- Missing agents: If an agent is not detected, check `getConfigPath()` in its adapter.
4+
- Permission errors: Filesystem operations (symlinks) may require specific permissions.
5+
- Symlink conflicts: If a file exists where a symlink should be, the CLI prompts for backup/overwrite.
6+
- Claude history: Claude Code uses the `copy` strategy because local sqlite databases do not behave well with symlinks.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@donnes/syncode",
33
"version": "1.0.0",
4-
"description": "Agent Configuration Manager - Sync AI code agent configs (Claude Code, Cursor, Windsurf, OpenCode) across machines and projects.",
4+
"description": "Sync AI code agent configs (Claude Code, Cursor, Windsurf, OpenCode) across machines and projects.",
55
"private": false,
66
"type": "module",
77
"bin": {

0 commit comments

Comments
 (0)