@jazpiper/rules-doctor 0.2.0 → 0.3.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/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## 0.3.0 - 2026-02-25
6
+
7
+ - Added `copilot` adapter support for `.github/copilot-instructions.md`.
8
+ - Switched Copilot output to marker-managed mode to preserve user-authored content.
9
+ - Added target presets for `init` (`all`, `core`, `copilot`).
10
+ - Added `preset apply` command for applying presets to existing `.agentrules/rules.yaml`.
11
+ - Added CI workflow template for drift detection via `rules-doctor check`.
12
+ - Expanded tests for shared `AGENTS.md`, Copilot marker re-sync, and `--import` + preset behavior.
13
+ - Improved README with troubleshooting and CI examples.
14
+
15
+ ## 0.2.0 - 2026-02-25
16
+
17
+ - Added multi-target adapters for `claude`, `codex`, `cursor`, `gemini`, and `opencode`.
18
+ - Added `init --import`, dry-run default for `sync`, drift `check`, and structural `doctor`.
package/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # @jazpiper/rules-doctor
2
2
 
3
- `rules-doctor` is a Node.js CLI that keeps agent instruction files in sync from one source of truth: `.agentrules/rules.yaml`.
3
+ `rules-doctor` keeps coding-rule files in sync across multiple agent CLIs from one source of truth: `.agentrules/rules.yaml`.
4
4
 
5
- It is designed for multi-agent workflows where each coding CLI reads a different file format.
5
+ It is optimized for real project adoption:
6
+ - import existing docs (`init --import`)
7
+ - safe previews by default (`sync` is dry-run unless `--write`)
8
+ - drift detection for CI (`check`)
6
9
 
7
- By default, commands resolve paths relative to the project root (`.git` ancestor), not the current subdirectory.
10
+ All paths are resolved from project root (`.git` ancestor), not current subdirectory.
8
11
 
9
12
  ## Install
10
13
 
@@ -12,143 +15,129 @@ By default, commands resolve paths relative to the project root (`.git` ancestor
12
15
  npm install -D @jazpiper/rules-doctor
13
16
  ```
14
17
 
15
- Or run directly:
18
+ Run with:
16
19
 
17
20
  ```bash
18
- npx @jazpiper/rules-doctor init
21
+ npx rules-doctor --help
19
22
  ```
20
23
 
21
- ## Usage
24
+ ## Quick Start
22
25
 
23
- ### 1) Initialize rules
26
+ ### 1) Initialize (recommended with import)
24
27
 
25
28
  ```bash
26
- rules-doctor init
29
+ npx rules-doctor init --import
27
30
  ```
28
31
 
29
- Creates `.agentrules/rules.yaml` if it does not exist.
32
+ - Creates `.agentrules/rules.yaml`
33
+ - Reads existing docs when found (`CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, `.cursor/rules/*.mdc`, `.github/copilot-instructions.md`)
34
+ - Writes `.agentrules/import-report.md`
30
35
 
31
- - If `package.json` has scripts for `lint`, `test`, or `build`, they are inferred as:
32
- - `npm run lint`
33
- - `npm run test`
34
- - `npm run build`
35
- - Missing scripts are created as TODO placeholders.
36
-
37
- ### 2) Sync generated docs
36
+ ### 2) Preview changes safely
38
37
 
39
38
  ```bash
40
- rules-doctor sync
41
- rules-doctor sync --target claude
42
- rules-doctor sync --target codex
43
- rules-doctor sync --target cursor,gemini,opencode,antigravity
39
+ npx rules-doctor sync --diff
44
40
  ```
45
41
 
46
- Generates/updates:
47
- - `CLAUDE.md` (`claude`, fully managed)
48
- - `AGENTS.md` (`codex`, `opencode`, marker-managed)
49
- - `.cursor/rules/rules-doctor.mdc` (`cursor`, fully managed)
50
- - `GEMINI.md` (`gemini`, fully managed)
51
- - `GEMINI.md` (`antigravity`, inferred-compatible mapping)
42
+ `sync` is dry-run by default. Nothing is written yet.
52
43
 
53
- Managed marker block in `AGENTS.md`:
44
+ ### 3) Apply changes
54
45
 
55
- ```md
56
- <!-- RULES_DOCTOR:BEGIN -->
57
- ... managed content ...
58
- <!-- RULES_DOCTOR:END -->
46
+ ```bash
47
+ npx rules-doctor sync --write
59
48
  ```
60
49
 
61
- If markers are missing, a new managed block is appended to the end of `AGENTS.md`.
50
+ Optional backups:
51
+
52
+ ```bash
53
+ npx rules-doctor sync --write --backup
54
+ ```
62
55
 
63
- ### 3) Analyze docs
56
+ ### 4) Verify drift in CI/local
64
57
 
65
58
  ```bash
66
- rules-doctor analyze
59
+ npx rules-doctor check
67
60
  ```
68
61
 
69
- Reads enabled target files from `rules.yaml`, then prints a concise report about:
70
- - missing markers
71
- - missing verify commands (`lint`/`test`/`build`)
72
- - obvious contradictions (simple heuristics across generated targets)
62
+ Returns non-zero when generated targets are out of sync.
63
+
64
+ ## Supported Targets
73
65
 
74
- `--strict` makes `analyze` fail with non-zero exit code when findings exist.
66
+ Built-in adapters:
67
+ - `claude` -> `CLAUDE.md` (full-managed)
68
+ - `codex` -> `AGENTS.md` (marker-managed)
69
+ - `copilot` -> `.github/copilot-instructions.md` (marker-managed, preserves existing text outside managed block)
70
+ - `opencode` -> `AGENTS.md` (marker-managed)
71
+ - `cursor` -> `.cursor/rules/rules-doctor.mdc` (full-managed)
72
+ - `gemini` -> `GEMINI.md` (full-managed)
75
73
 
76
- ### 4) List supported adapters
74
+ ## Command Reference
75
+
76
+ ### `init`
77
77
 
78
78
  ```bash
79
- rules-doctor targets list
79
+ npx rules-doctor init [--import]
80
80
  ```
81
81
 
82
- Shows built-in adapters and default file paths.
82
+ ### `sync`
83
83
 
84
- ### 5) Directory/Path Notes
84
+ ```bash
85
+ npx rules-doctor sync [--target all|claude,codex,...] [--diff] [--write] [--backup]
86
+ ```
85
87
 
86
- - `claude`: searches `CLAUDE.md` from current directory upward; also supports `.claude/CLAUDE.md` and `.claude/rules/*.md`.
87
- - `codex`: looks for `AGENTS.override.md` or `AGENTS.md` from project root down to current directory.
88
- - `opencode`: reads project `AGENTS.md`, plus user global `~/.config/opencode/AGENTS.md`.
89
- - `cursor`: project rules live in `.cursor/rules/*.mdc` (legacy `.cursorrules` still exists).
90
- - `gemini`: uses `GEMINI.md` in workspace/ancestor directories and `~/.gemini/GEMINI.md`.
91
- - `antigravity`: currently mapped to `GEMINI.md` as an inferred default; verify in your environment.
88
+ ### `check`
92
89
 
93
- ## Rules Schema (v2 Draft)
90
+ ```bash
91
+ npx rules-doctor check [--target all|claude,codex,...] [--diff]
92
+ ```
93
+
94
+ ## CI Template
95
+
96
+ Copy [docs/workflows/rules-doctor-check.yml](docs/workflows/rules-doctor-check.yml) to your repository as `.github/workflows/rules-doctor-check.yml`.
97
+ It runs `npx rules-doctor check` on push and pull requests.
94
98
 
95
- `init` now creates a v2-compatible draft with `targets` configuration:
99
+ Inline workflow example:
96
100
 
97
101
  ```yaml
98
- version: 2
99
- mission: "Ship safe changes quickly while keeping agent instructions consistent."
100
- workflow:
101
- - "Read relevant files before editing."
102
- - "Make the smallest correct change."
103
- - "Run verification commands before finalizing."
104
- commands:
105
- lint: "npm run lint"
106
- test: "npm run test"
107
- build: "npm run build"
108
- done:
109
- - "Commands pass or blockers are documented."
110
- - "Changed behavior is reflected in docs where needed."
111
- approvals:
112
- mode: "ask-before-destructive"
113
- notes:
114
- - "Ask before destructive actions or privileged operations."
115
- targets:
116
- claude:
117
- enabled: true
118
- path: "CLAUDE.md"
119
- codex:
120
- enabled: true
121
- path: "AGENTS.md"
122
- cursor:
123
- enabled: true
124
- path: ".cursor/rules/rules-doctor.mdc"
125
- gemini:
126
- enabled: true
127
- path: "GEMINI.md"
128
- opencode:
129
- enabled: true
130
- path: "AGENTS.md"
131
- antigravity:
132
- enabled: true
133
- path: "GEMINI.md"
102
+ name: Rules Doctor Check
103
+
104
+ on:
105
+ push:
106
+ pull_request:
107
+
108
+ jobs:
109
+ rules-doctor:
110
+ runs-on: ubuntu-latest
111
+ steps:
112
+ - uses: actions/checkout@v4
113
+ - uses: actions/setup-node@v4
114
+ with:
115
+ node-version: "20"
116
+ cache: npm
117
+ - run: npm ci
118
+ - run: npx rules-doctor check
134
119
  ```
135
120
 
136
- You can disable or relocate any target by editing `targets.<id>.enabled/path`.
121
+ ## Troubleshooting
122
+
123
+ - `rules-doctor: command not found` after `npm install -D @jazpiper/rules-doctor`:
124
+ - Use `npx rules-doctor ...` (recommended for local dev dependency).
125
+ - Or add an npm script in your project: `"rules:check": "rules-doctor check"`, then run `npm run rules:check`.
126
+ - Global install (`npm i -g @jazpiper/rules-doctor`) works, but local + `npx` is safer for version consistency.
127
+ - `init` says `rules.yaml already exists`:
128
+ - Edit `.agentrules/rules.yaml` directly, then run `npx rules-doctor sync --write`.
129
+
130
+ ## Rules Schema (v2 Draft)
131
+
132
+ See [docs/rules-v2-draft.yaml](docs/rules-v2-draft.yaml).
137
133
 
138
134
  ## Development
139
135
 
140
136
  ```bash
141
137
  npm ci
142
- npm run build
138
+ npm test
143
139
  ```
144
140
 
145
141
  ## License
146
142
 
147
143
  MIT
148
-
149
-
150
- ## CI
151
-
152
- This repo includes a GitHub Actions workflow template at `docs/workflows/ci.yml`.
153
-
154
- If you want CI, copy it to `.github/workflows/ci.yml` and push the change.
@@ -0,0 +1,15 @@
1
+ const { renderManagedRulesBody } = require("./common");
2
+
3
+ module.exports = {
4
+ id: "copilot",
5
+ name: "GitHub Copilot",
6
+ description:
7
+ "Manage .github/copilot-instructions.md via marker-managed section to preserve user content.",
8
+ defaultPath: ".github/copilot-instructions.md",
9
+ management: "marker",
10
+ markerBegin: "<!-- RULES_DOCTOR:COPILOT:BEGIN -->",
11
+ markerEnd: "<!-- RULES_DOCTOR:COPILOT:END -->",
12
+ render(rules) {
13
+ return ["# Copilot Instructions", "", renderManagedRulesBody(rules)].join("\n");
14
+ },
15
+ };
@@ -1,11 +1,11 @@
1
1
  const claude = require("./claude");
2
2
  const codex = require("./codex");
3
+ const copilot = require("./copilot");
3
4
  const cursor = require("./cursor");
4
5
  const gemini = require("./gemini");
5
6
  const opencode = require("./opencode");
6
- const antigravity = require("./antigravity");
7
7
 
8
- const ADAPTERS = [claude, codex, cursor, gemini, opencode, antigravity];
8
+ const ADAPTERS = [claude, codex, copilot, cursor, gemini, opencode];
9
9
  const ADAPTERS_BY_ID = Object.fromEntries(ADAPTERS.map((adapter) => [adapter.id, adapter]));
10
10
 
11
11
  module.exports = {