@ainova-systems/intelligence 0.11.0-rc.6 → 0.11.0-rc.8

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 (68) hide show
  1. package/README.md +15 -16
  2. package/cli/commands/adapter.sh +153 -0
  3. package/cli/commands/init.sh +113 -22
  4. package/cli/commands/package.sh +30 -0
  5. package/cli/commands/registry.sh +5 -2
  6. package/cli/commands/status.sh +12 -4
  7. package/cli/commands/sync.sh +8 -21
  8. package/cli/commands/update.sh +76 -61
  9. package/cli/engine-package.yaml +4 -4
  10. package/cli/intelligence +37 -27
  11. package/cli/{commands/doctor.sh → internal/check.sh} +32 -14
  12. package/cli/{commands/migrate.sh → internal/migrate-v1.sh} +161 -42
  13. package/cli/{commands/add.sh → internal/package-add.sh} +11 -10
  14. package/cli/{commands/list.sh → internal/package-list.sh} +9 -4
  15. package/cli/{commands/remove.sh → internal/package-remove.sh} +3 -3
  16. package/cli/{commands/search.sh → internal/package-search.sh} +4 -4
  17. package/cli/internal/package-update.sh +97 -0
  18. package/cli/{commands/install.sh → internal/restore.sh} +11 -4
  19. package/cli/internal/target-state.sh +57 -0
  20. package/cli/{commands/upgrade.sh → internal/upgrade-v2.sh} +48 -8
  21. package/cli/lib/cli-common.sh +167 -14
  22. package/cli/lib/lockfile.sh +15 -9
  23. package/cli/lib/manifest.sh +106 -1
  24. package/cli/lib/registry.sh +29 -15
  25. package/cli/lib/semver.sh +4 -2
  26. package/engine/ENGINE_SHA +1 -0
  27. package/engine/{scripts/adapters → adapters}/_template.sh +10 -9
  28. package/engine/{scripts/adapters → adapters}/agents.sh +20 -25
  29. package/engine/{scripts/adapters → adapters}/opencode.sh +1 -1
  30. package/engine/{scripts/lib → lib}/common.sh +29 -541
  31. package/engine/lib/contract.sh +120 -0
  32. package/engine/sync.sh +238 -0
  33. package/package.json +6 -5
  34. package/{engine → packages/sync}/agents/intelligence-architect.md +5 -3
  35. package/{engine → packages/sync}/agents/intelligence-operator.md +10 -13
  36. package/packages/sync/references/adapters.md +252 -0
  37. package/packages/sync/references/conventions.md +385 -0
  38. package/{engine → packages/sync}/rules/intelligence-authoring.md +6 -6
  39. package/{engine → packages/sync}/skills/intelligence-add-agent/SKILL.md +5 -5
  40. package/{engine → packages/sync}/skills/intelligence-add-rule/SKILL.md +3 -3
  41. package/{engine → packages/sync}/skills/intelligence-add-skill/SKILL.md +3 -3
  42. package/{engine → packages/sync}/skills/intelligence-extract-skill/SKILL.md +2 -2
  43. package/packages/sync/skills/intelligence-install-adapter/SKILL.md +38 -0
  44. package/{engine → packages/sync}/skills/intelligence-learn-from-context/SKILL.md +3 -3
  45. package/packages/sync/skills/intelligence-learn-from-repository/SKILL.md +55 -0
  46. package/{engine → packages/sync}/skills/intelligence-review-skills/SKILL.md +6 -6
  47. package/packages/sync/skills/intelligence-sync/SKILL.md +20 -0
  48. package/packages/sync/skills/intelligence-uninstall-adapter/SKILL.md +24 -0
  49. package/packages/sync/skills/intelligence-update/SKILL.md +43 -0
  50. package/engine/INIT.md +0 -500
  51. package/engine/docs/ADAPTERS.md +0 -214
  52. package/engine/docs/CLI.md +0 -90
  53. package/engine/docs/CONVENTIONS.md +0 -456
  54. package/engine/scripts/ENGINE_SHA +0 -1
  55. package/engine/scripts/lib/layout.sh +0 -51
  56. package/engine/scripts/lib/migrations.sh +0 -708
  57. package/engine/scripts/sync.sh +0 -311
  58. package/engine/scripts/update.sh +0 -237
  59. package/engine/skills/intelligence-install-adapter/SKILL.md +0 -31
  60. package/engine/skills/intelligence-sync/SKILL.md +0 -16
  61. package/engine/skills/intelligence-uninstall-adapter/SKILL.md +0 -42
  62. package/engine/skills/intelligence-update/SKILL.md +0 -165
  63. /package/engine/{scripts/VERSION → VERSION} +0 -0
  64. /package/engine/{scripts/adapters → adapters}/claude.sh +0 -0
  65. /package/engine/{scripts/adapters → adapters}/codex.sh +0 -0
  66. /package/engine/{scripts/adapters → adapters}/copilot.sh +0 -0
  67. /package/engine/{scripts/adapters → adapters}/cursor.sh +0 -0
  68. /package/engine/{scripts/adapters → adapters}/pi.sh +0 -0
package/engine/INIT.md DELETED
@@ -1,500 +0,0 @@
1
- # intelligence-sync: Initialize Your Project
2
-
3
- The sync engine is already installed in this directory's `scripts/` subfolder. Your job: analyze this codebase, ask the user targeted questions, and generate the project-specific configuration and content.
4
-
5
- > **The intelligence CLI is the recommended setup for new projects.** If `intelligence --version` works on this machine (or `npm i -g @ainova-systems/intelligence` is acceptable), prefer `intelligence init` + `intelligence add <package>` over this document — it automates what this bootstrap does by hand and adds versioned packages with a lockfile (see `docs/CLI.md`). This document remains the authoritative bootstrap for the **vendored** setup, which stays fully supported; a vendored project can convert later with `intelligence migrate`.
6
-
7
- **Execute phases sequentially. Do not skip or combine phases. Each phase has a gate — wait for it before proceeding.**
8
-
9
- ## Bootstrap: install the engine if it isn't here yet
10
-
11
- You can reach this file two ways:
12
-
13
- - **Already vendored in the project** (`intelligence/sync/INIT.md`) — the engine is installed. Skip straight to *Phase 0* below.
14
- - **Fetched remotely** (a raw GitHub URL) — the engine is **not** installed yet. Install it first, then continue:
15
-
16
- 1. Check whether `intelligence/sync/scripts/sync.sh` exists at the project root. If it does, the engine is already installed — skip the rest of this section.
17
- 2. If it does not, clone upstream into a temp directory and copy the `intelligence/` folder into the project root (never clone into the project tree itself). Adapt the temp path to the platform:
18
-
19
- ```bash
20
- tmp="$(mktemp -d)"
21
- git clone --depth=1 https://github.com/ainova-systems/intelligence-sync.git "$tmp"
22
- cp -r "$tmp/intelligence" ./intelligence
23
- rm -rf "$tmp"
24
- ```
25
-
26
- If the project already has an umbrella folder holding a `config.yaml` under a different name (see *Phase 0*), copy the `sync/` module into that existing folder instead of creating a second `intelligence/`.
27
- 3. From here on, work against the freshly copied, version-matched `intelligence/sync/INIT.md` and the rest of this document — that copy is authoritative.
28
-
29
- ## Phase 0: detect the source folder name
30
-
31
- This document is read by an AI agent and contains many literal references to `intelligence/` (lowercase). The folder you are reading from may have been **renamed** by the user (e.g. `Intelligence/`, `prompts/`, a project codename). Before doing anything else:
32
-
33
- 1. Identify the directory that contains this `INIT.md` and a `scripts/sync.sh` file. Call its basename `<intel>`.
34
- 2. Throughout the rest of this document, every reference to `intelligence/` means `<intel>/` — substitute it consistently in every path you write (`config.yaml` `sources:`, `targets.agents.header` Markdown links, generated content, skill instructions).
35
- 3. Do NOT create a second folder named `intelligence/` if `<intel>` is already different. The sync engine is folder-name-agnostic — `bash <intel>/sync/scripts/sync.sh` works regardless of casing or naming.
36
-
37
- If the user has not renamed it, `<intel>` is `intelligence` and the literal text below applies as-is.
38
-
39
- ## What You Will Generate
40
-
41
- 1. `intelligence/config.yaml` -- sync configuration
42
- 2. `intelligence/rules/` -- coding standards and conventions
43
- 3. `intelligence/agents/` -- specialized AI personas
44
- 4. `intelligence/skills/` -- reusable command sequences
45
- 5. `AGENTS.md` -- project documentation for LLMs (committed)
46
- 6. `CLAUDE.md` -- local user preferences (gitignored, if Claude enabled)
47
- 7. `.gitignore` updates
48
-
49
- ## Pre-check
50
-
51
- Before starting, verify:
52
-
53
- 1. `intelligence/sync/scripts/sync.sh` exists
54
- 2. `intelligence/sync/scripts/lib/common.sh` exists
55
- 3. `intelligence/sync/scripts/adapters/claude.sh` exists
56
- 4. Check initialization state:
57
- - **Already initialized** = `intelligence/config.yaml` exists AND `intelligence/rules/` contains at least one `.md` file
58
- - **Partially initialized** = either exists but not both
59
- - **Fresh** = neither exists
60
-
61
- If files from steps 1-3 are missing, the engine isn't installed yet — go back to **Bootstrap** above and install it (clone upstream, copy `intelligence/` in), then re-run this Pre-check. Do not proceed to Phase 1 until they exist.
62
-
63
- ### Already initialized → offer sync-only path
64
-
65
- If the project is **already initialized** (config + rules present), do NOT run the full bootstrap. Instead:
66
-
67
- 1. Check if local IDE output is missing or stale: for each enabled target in `config.yaml`, see whether the output path exists (e.g., `.claude/`, `.cursor/`, `AGENTS.md`). If any are missing, this is a new clone / new team member.
68
- 2. Tell the user: "This project is already initialized. I can just run `bash intelligence/sync/scripts/sync.sh` to generate your local IDE files from `intelligence/`."
69
- 3. Offer two options:
70
- - **Sync** — run `intelligence/sync/scripts/sync.sh` and exit (do not touch rules/agents/skills/config)
71
- - **Re-initialize** — wipe existing rules/agents/skills and regenerate (destructive; only if the user explicitly wants a fresh bootstrap)
72
- 4. Default to sync. Only proceed to Phase 1 if the user explicitly chooses re-initialize.
73
-
74
- ---
75
-
76
- ## Phase 1: Discovery
77
-
78
- Explore the codebase to detect:
79
-
80
- **Language & Framework** (check for these markers):
81
-
82
- | Marker files | Stack |
83
- |---|---|
84
- | `.sln`, `.csproj`, `global.json` | .NET / C# |
85
- | `package.json` | Node.js -- inspect `dependencies` for framework: |
86
- | -- `react`, `react-dom` | React |
87
- | -- `next` | Next.js |
88
- | -- `@angular/core` | Angular |
89
- | -- `vue` | Vue |
90
- | -- `svelte` | Svelte / SvelteKit |
91
- | -- `nuxt` | Nuxt |
92
- | -- `express`, `fastify`, `nestjs`, `hono` | Node.js backend |
93
- | -- `electron` | Electron desktop app |
94
- | -- `react-native`, `expo` | React Native mobile |
95
- | `go.mod` | Go |
96
- | `requirements.txt`, `pyproject.toml`, `setup.py`, `Pipfile` | Python |
97
- | -- `django` in deps | Django |
98
- | -- `fastapi` in deps | FastAPI |
99
- | -- `flask` in deps | Flask |
100
- | `pom.xml` | Java (Maven) |
101
- | `build.gradle`, `build.gradle.kts` | Java/Kotlin (Gradle) |
102
- | `Cargo.toml` | Rust |
103
- | `composer.json` | PHP |
104
- | -- `laravel/framework` in deps | Laravel |
105
- | `Gemfile` | Ruby |
106
- | -- `rails` in deps | Ruby on Rails |
107
- | `mix.exs` | Elixir / Phoenix |
108
- | `pubspec.yaml` | Dart / Flutter |
109
- | `Package.swift` | Swift |
110
- | `*.xcodeproj`, `*.xcworkspace` | iOS / macOS (Xcode) |
111
- | `CMakeLists.txt`, `Makefile` (with `.c`/`.cpp`) | C / C++ |
112
- | `terraform/`, `*.tf` | Terraform (IaC) |
113
- | `pulumi/`, `Pulumi.yaml` | Pulumi (IaC) |
114
- | `helm/`, `Chart.yaml` | Helm charts |
115
- | `docker-compose.yml`, `compose.yaml` | Docker Compose |
116
- | `serverless.yml` | Serverless Framework |
117
- | `deno.json`, `deno.jsonc` | Deno |
118
- | `bun.lockb`, `bunfig.toml` | Bun |
119
-
120
- **Project Components** -- identify what this project actually is:
121
-
122
- Scan the directory tree and determine which components exist. A project may have one or several:
123
- - Backend API, frontend app, BFF layer
124
- - Infrastructure / deployment configs
125
- - Shared libraries, CLI tools, workers
126
- - Mobile app, documentation site
127
- - Git submodules (check `.gitmodules`)
128
- - Workspace tooling (`pnpm-workspace.yaml`, `lerna.json`, `nx.json`, `turbo.json`)
129
-
130
- Describe what you find naturally: "This is a .NET 8 API with a React frontend and Terraform infrastructure" -- not abstract labels.
131
-
132
- **Build & Test:**
133
- - Build tools: Makefile, Dockerfile, docker-compose, Taskfile.yml, justfile
134
- - CI: `.github/workflows/`, `.gitlab-ci.yml`, `.circleci/`, `Jenkinsfile`
135
- - Test frameworks, linters, formatters, package managers
136
-
137
- **Existing AI Prompt Infrastructure** (CRITICAL -- check all):
138
- - `AGENTS.md`, `CLAUDE.md`, `.cursorrules`
139
- - `.github/copilot-instructions.md`
140
- - `.claude/` directory (rules, agents, skills)
141
- - `.cursor/` directory (rules, agents)
142
- - `.pi/` directory (`settings.json`, `extensions/`, `prompts/`)
143
- - `.opencode/` directory (`opencode.json`, `agents/`)
144
- - `.claude/settings.json`, `.claude/settings.local.json`
145
- - Any sync scripts (`sync.sh`, `sync-to-claude.sh`, etc.)
146
- - `.gitignore` entries for `.claude`, `.cursor`, `.pi`, `.opencode`, `CLAUDE.md`
147
-
148
- ---
149
-
150
- ## Phase 2: Present Recommended Setup
151
-
152
- Present everything in ONE summary. The user confirms once.
153
-
154
- Include these sections:
155
-
156
- 1. **Components detected**: list with paths
157
- 2. **Rules recommended**: N component rules + 1 shared context
158
- 3. **Targets to enable**:
159
- - `agents` is **always enabled** by default — it generates `AGENTS.md` (committed project index consumed by many LLM tools).
160
- - At least **one IDE adapter** must be enabled. Detect which by scanning for existing tool markers:
161
- - `.claude/`, `CLAUDE.md`, `.claude/settings.json` -> recommend `claude`
162
- - `.cursor/`, `.cursorrules` (legacy single-file Cursor format) -> recommend `cursor`
163
- - `.github/copilot-instructions.md` (legacy Copilot single-file), `.github/instructions/` -> recommend `copilot`
164
- - `.codex/`, `.agents/` -> recommend `codex`
165
- - `.pi/`, `.pi/settings.json`, `.pi/extensions/`, `.pi/prompts/` -> recommend `pi`
166
- - `.opencode/`, `.opencode/opencode.json`, `.opencode/agents/` -> recommend `opencode`
167
- - If nothing detected, default to `claude` (most common).
168
- - If the user explicitly names a tool, honor that instead.
169
- - Present as: "I detected [existing configs]. I will enable: `agents` + `<detected IDE>`. Other adapters (Claude, Cursor, Copilot, Codex, Pi, opencode) can be added any time via `/intelligence-install-adapter`."
170
- 4. **Agents recommended**: list with tier/access
171
- 5. **Skills recommended**: pre-installed + migrated + new suggestions (see Phase 3.5)
172
- 6. **Conventions detected**: key patterns from codebase
173
- 7. **Submodules** (if found): recommend excluding
174
- 8. **Migration** (only if existing AI infrastructure found): conflict report with file counts:
175
- ```
176
- WILL BE OVERWRITTEN: .claude/rules/ (N files), .cursor/rules/ (N files), etc.
177
- WILL BE PRESERVED: .claude/settings.local.json, .claude/settings.json
178
- NEEDS MIGRATION: CLAUDE.md, .cursorrules, existing skills/commands
179
- ```
180
-
181
- End with:
182
-
183
- > **Accept** to proceed (backup + migrate + generate), or **Cancel** to stop.
184
-
185
- If **Cancel** -- stop completely. intelligence-sync cannot coexist with manually managed IDE prompts.
186
-
187
- If **Accept** -- execute migration (if needed), then generate.
188
-
189
- ### Migration (only if existing AI infrastructure found)
190
-
191
- 1. **Backup:** Create `intelligence/_backup/`, move (not copy) all existing AI files. Add `intelligence/_backup/` to `.gitignore`.
192
- 2. **Migrate** to tool-agnostic format:
193
- - `.claude/rules/*.md` -- copy as-is
194
- - `.cursor/rules/*.mdc` -- rename `.md`, `globs:` -> `paths:`, remove `alwaysApply:`
195
- - `.github/copilot-instructions.md`, `.cursorrules` -- split by topic
196
- - `.claude/agents/*.md` -- reverse: `model:` -> `tier:`, remove IDE fields, add `access:`
197
- - `.cursor/agents/*.md` -- reverse: `model: fast` -> `tier: standard`, `readonly:` -> `access:`
198
- - `.claude/skills/*/SKILL.md`, `.cursor/skills/*/SKILL.md`, `.claude/commands/*.md`, `.cursor/commands/*.md` -- copy as skills
199
- 3. **Cleanup:** `git rm` tracked files, `rm` untracked. Remove empty directories.
200
- 4. **Post-migration validation** (CRITICAL -- do not skip):
201
- - Build a list of the paths that were removed/renamed (e.g., `dev/scripts/`, `dev/prompts/`, `.cursorrules`, `.claude/rules/`, old directory names).
202
- - Run `git ls-files` to enumerate every tracked file in the repository (no whitelist -- references to old paths live in `README.md`, scripts, config files, wikis, workflow YAML, not just `docs/`).
203
- - For each tracked file, grep for each removed path. Record findings.
204
- - For unambiguous replacements (e.g., `dev/scripts/sync-to-claude.sh` -> `intelligence/sync/scripts/sync.sh`), patch the file automatically.
205
- - For ambiguous references (path removed without a clear successor, references inside narrative prose, references to scripts that no longer exist), print them to the user grouped by file with line numbers and ask how to resolve.
206
- - Do not proceed to Phase 3 generation until stale references are resolved or explicitly deferred by the user.
207
-
208
- ### Files we NEVER touch
209
-
210
- - `.claude/settings.local.json`, `.claude/settings.json`
211
- - `.git/`
212
- - Anything outside AI prompt scope
213
-
214
- ---
215
-
216
- ## Phase 3: Generate
217
-
218
- **Principles:**
219
- 1. **Adopt, don't impose.** Use the repo's existing directory names and casing conventions.
220
- 2. **Derive from code, not general knowledge.** Read actual source files. Extract real patterns, real commands, real examples. Every FORBIDDEN/REQUIRED rule must be backed by something you observed in the codebase. Do not generate generic best-practice rules.
221
- 3. **Agents must reflect reality.** Read existing implementations to determine expertise, architecture patterns, and build commands. If you cannot verify a pattern exists in the code, do not include it.
222
-
223
- ### 3.1 `intelligence/config.yaml`
224
-
225
- Set `sync_version` to the engine version — read it verbatim from
226
- `intelligence/sync/scripts/VERSION`. This is a **managed contract key**: emit
227
- it on first bootstrap and **preserve its existing value if `config.yaml`
228
- already has one** when re-bootstrapping (never drop or guess it — the update
229
- flow owns its value).
230
-
231
- ```yaml
232
- project:
233
- name: "project-name"
234
-
235
- # Managed by intelligence-sync — applied schema version. Do not hand-edit;
236
- # preserve on re-bootstrap. (Value = intelligence/sync/scripts/VERSION.)
237
- sync_version: "0.11.0"
238
-
239
- sources:
240
- rules:
241
- - "intelligence/rules"
242
- - "intelligence/sync/rules" # engine-owned: intelligence-authoring
243
- agents:
244
- - "intelligence/agents"
245
- - "intelligence/sync/agents" # engine-owned: intelligence-architect, intelligence-operator
246
- skills:
247
- - "intelligence/skills"
248
- - "intelligence/sync/skills" # engine-owned: intelligence-* meta-skills
249
-
250
- targets:
251
- # agents: ALWAYS enabled — generates committed AGENTS.md as the
252
- # canonical project doc. Always-on rules (no `paths:`) are inlined
253
- # automatically; path-scoped rules stay in tool-specific channels
254
- # (.cursor/rules/, .github/instructions/) for monorepo scoping.
255
- agents:
256
- enabled: true
257
- output: "AGENTS.md"
258
- header: |
259
- # <Project Name>
260
-
261
- <one-line stack summary — e.g., ".NET 8 API + React 19 | Azure | Phase: MVP">
262
-
263
- **Full context**: [`intelligence/rules/context.md`](intelligence/rules/context.md)
264
- # At least one IDE adapter — pick based on detection or user preference
265
- claude: { enabled: true, output: ".claude" }
266
- # Optional adapters: cursor, copilot, codex, pi, opencode
267
- # pi: { enabled: false, output: ".pi" }
268
- # opencode: { enabled: false, output: ".opencode" }
269
-
270
- ignore:
271
- - "node_modules"
272
- - "vendor"
273
- - "dist"
274
-
275
- # Optional: override per-IDE tier -> model mappings. Defaults live in
276
- # intelligence/sync/scripts/lib/common.sh. Add only the entries you want to
277
- # pin; everything else uses the current default.
278
- # Example:
279
- # models:
280
- # copilot:
281
- # heavy: "gpt-5.6-sol"
282
- ```
283
-
284
- The `agents.header` block is the only hand-authored part of `AGENTS.md`. Everything else (tables for agents/skills, list of rules) is regenerated from frontmatter on every sync. Keep the header to 3–5 lines: project name, one-liner stack summary, link to `context.md`.
285
-
286
- Engine scripts (under `intelligence/sync/scripts/`):
287
-
288
- - `sync.sh` — generate IDE outputs from `intelligence/`
289
- - `update.sh` — pull latest scripts/INIT.md from upstream without touching project content
290
- - `lib/common.sh` — shared helpers (`get_model`, `lint_frontmatter`, frontmatter parsers, etc.)
291
-
292
- Built-in adapters:
293
-
294
- | Target | Adapter | Output | Notes |
295
- |--------|---------|--------|-------|
296
- | `agents` | `agents.sh` | `AGENTS.md` | Committed; canonical project doc with inlined always-on rules |
297
- | `claude` | `claude.sh` | `.claude/` | Full rule copy (Claude does not read AGENTS.md) |
298
- | `cursor` | `cursor.sh` | `.cursor/` | Path-scoped rules only (always-on come from AGENTS.md) |
299
- | `copilot` | `copilot.sh` | `.github/` | Path-scoped rules only; shares dir with workflows |
300
- | `codex` | `codex.sh` | `.agents/skills/` + `.codex/agents/` | Reads AGENTS.md for context |
301
- | `pi` | `pi.sh` | `.pi/` + `.agents/skills/` | Reads AGENTS.md for always-on context; generated extension surfaces scoped rules; agents become prompt templates |
302
- | `opencode` | `opencode.sh` | `.opencode/` + `.agents/skills/` | Reads AGENTS.md natively; agents become markdown subagents (`.opencode/agents/<name>.md`); skills via `.agents/skills/`; no scoped-rules emission (users may opt in via `instructions:` globs in `opencode.json`) |
303
-
304
- Need a target with no built-in adapter? Write it as `<intel>/adapters/<name>.sh` — beside `config.yaml`, using the folder name detected in *Phase 0*, and **never** inside `<intel>/sync/scripts/adapters/`, which `update.sh` replaces wholesale (an adapter written there is deleted by the next engine update). `sync.sh` scans both locations; a project adapter overrides a built-in of the same name. See `/intelligence-install-adapter` and `<intel>/sync/docs/ADAPTERS.md`.
305
-
306
- ### 3.2 `intelligence/rules/context.md`
307
-
308
- Always-loaded context (no `paths:` in frontmatter):
309
- - Project name and description
310
- - Repository structure
311
- - Build and test commands
312
- - Global rules (naming, formatting, forbidden patterns)
313
-
314
- ### 3.3 Component-specific rules
315
-
316
- One rule per component, scoped with `paths:` frontmatter:
317
- - REQUIRED patterns (positive defaults — what to do, judgment calls)
318
- - Invariants (true must-nots: safety, output format, security — never judgment calls)
319
- - Architecture patterns
320
- - Component-specific build/test commands
321
- - Code examples from the actual codebase
322
- - Patterns to recognize and replace (optional — anti-patterns documented as reference with positive replacements; documentation, not LLM instruction)
323
-
324
- ### 3.4 Agents
325
-
326
- **Developer agents** (tier: heavy, access: full) -- one per distinct stack:
327
- - Expertise based on detected patterns; boundaries (where the agent stops); build/verify commands
328
- - **Never instruct an agent to read the rules.** Rules load on their own — Claude Code loads `.claude/rules/` into every custom subagent's startup context, and Cursor / Copilot / Codex / Pi / opencode get always-on rules inlined in `AGENTS.md`. A "read `intelligence/rules/<domain>.md` first" line duplicates content the agent already has and drifts from the rule it copied.
329
- - Link relevant skills via `skills:` in frontmatter
330
-
331
- **Code reviewer** (tier: standard, access: readonly):
332
- - Review criteria per component, output format
333
- - Link review skills if created (e.g., `<domain>-review-` skills)
334
-
335
- ### 3.5 Skills
336
-
337
- Pre-installed by the engine — never recreate these, and never use the reserved `intelligence-` prefix for a project skill:
338
- - `/intelligence-sync` — sync to all enabled IDE targets
339
- - `/intelligence-update` — update or migrate the engine
340
- - `/intelligence-install-adapter` / `/intelligence-uninstall-adapter` — turn an IDE channel on or off
341
- - `/intelligence-add-rule`, `/intelligence-add-agent`, `/intelligence-add-skill` — author an artifact with the conventions applied
342
- - `/intelligence-extract-skill`, `/intelligence-learn-from-context`, `/intelligence-review-skills` — turn observed work into artifacts, and audit the layer
343
-
344
- The engine also ships the `intelligence-authoring` rule (authoring discipline, scoped to `<intel>/`) and two agents: `intelligence-architect` (designs and prunes this layer) and `intelligence-operator` (runs the sync, update, and adapter-install/removal flows). They are upstream-owned and arrive via `sources` — do not copy or rewrite them into project content.
345
-
346
- **Derive skills from this repository. Do not pick them from a catalogue.** A list of plausible skill names ("add-entity", "add-endpoint", "run-tests") is a trap: every one of them sounds right for every project, so working from such a list produces a registry that describes software in general rather than *this* codebase — and every entry costs context budget forever, whether or not anyone invokes it.
347
-
348
- A candidate skill has to clear all four bars:
349
-
350
- 1. **Repeated.** The operation has demonstrably been done more than once. Evidence: near-identical sibling files, a "how to add X" section in `README`/`CONTRIBUTING`, the same multi-file shape appearing across git history. Not "a project like this usually needs it".
351
- 2. **Multi-step and mechanical.** 3+ concrete steps in a predictable pattern, usually across more than one file. If it is one edit, the model does not need a procedure.
352
- 3. **Verifiable.** It ends in a command or check that proves it worked (build, test, lint, migration, sync). **If there is nothing to verify at the end, it is not a skill** — it is a note, or just work.
353
- 4. **Stable.** It describes the project *as it is meant to work*. A procedure that only exists to route around a current bug is not a skill — that belongs in a single rule that records known breakage, so it disappears when the bug is fixed instead of becoming permanent.
354
-
355
- **Show your evidence.** For every skill you propose, name the files it would touch and the concrete instance in the repo you derived it from. If you cannot point at one, do not propose it.
356
-
357
- **Start small: 0–3 skills at bootstrap.** Zero is a legitimate answer for a young or simple repository — say so plainly rather than padding. Skills can be added at any time with `/intelligence-add-skill`, and one added later, from a pattern the team actually hit twice, is worth more than five guessed today.
358
-
359
- Naming (details in `<intel>/sync/docs/CONVENTIONS.md`): `<domain>-<verb>-<noun>`, domain prefix taken from the set already in use. Two verbs are told apart by what already exists — **`add-` puts one new member into a set that is already there**, and **`create-` brings into existence the container nothing hosted before**; neither describes how the skill is factored inside. Other verbs (`run-`, `review-`, `update-`, `extract-`) read fine; prefer a verb already in use over a new synonym for the same thing. `intelligence-` is reserved for the engine's meta-skills.
360
-
361
- Present the shortlist with its evidence and let the user choose. Then create only what they pick.
362
-
363
- ### 3.6 `.gitignore`
364
-
365
- Add (if not present):
366
- ```
367
- # AI IDE tools (generated by intelligence-sync)
368
- CLAUDE.md
369
- .cursorrules
370
- .agents/
371
- .codex/
372
-
373
- # Pi: generated prompt templates, scoped-rule extension, and copied rule files.
374
- # Keep .pi/settings.json and any hand-authored extensions/prompts outside these
375
- # paths tracked if you want to share them.
376
- .pi/intelligence-sync/
377
- .pi/extensions/intelligence-sync-rules.ts
378
- .pi/prompts/intelligence-agent-*.md
379
-
380
- # opencode: only the generated subagents and slash commands are owned by the adapter.
381
- # Keep .opencode/opencode.json (and any hand-authored config) tracked.
382
- .opencode/agents/
383
- .opencode/commands/
384
-
385
- # Claude Code: ignore everything except project-shared settings.
386
- # This catches generated subdirs (rules/, skills/, agents/) plus any
387
- # per-machine state Claude writes (settings.local.json, *.lock,
388
- # scheduled_tasks.*, sessions/, cache/, etc.) without us having to
389
- # enumerate every filename Claude may add in the future.
390
- .claude/*
391
- !.claude/settings.json
392
-
393
- # Cursor: same pattern.
394
- .cursor/*
395
- !.cursor/settings.json
396
- ```
397
-
398
- Notes:
399
- - `.github/` and `AGENTS.md` are intentionally NOT gitignored — they contain shared content.
400
- - Only `.claude/settings.json` and `.cursor/settings.json` are tracked by default — they hold project-shared IDE settings (allowed bash commands, tool permissions). Everything else under those directories is either generated by sync or per-user state.
401
- - The Pi adapter writes only three generated paths: `.pi/intelligence-sync/`, `.pi/extensions/intelligence-sync-rules.ts`, and `.pi/prompts/intelligence-agent-*.md`. It does NOT own `.pi/settings.json` or any other `.pi/extensions/*.ts` / `.pi/prompts/*.md` files.
402
- - The opencode adapter writes only `.opencode/agents/` (one markdown subagent per source agent) and `.opencode/commands/` (one slash command per source skill, mirroring Claude Code's skill-as-command UX). It does NOT own `.opencode/opencode.json` or any other `.opencode/*` files — those remain hand-authored and tracked. Generated command files carry an `<!-- Generated by intelligence-sync. Do not edit manually. -->` marker; only marker-bearing files are removed on re-sync, so any hand-authored command in `.opencode/commands/` survives.
403
- - If you need to track another file under `.claude/` or `.cursor/` (e.g., `.claude/commands/<name>.md` for a hand-authored command), add another `!path` un-ignore line below.
404
-
405
- ### 3.7 `AGENTS.md` (auto-generated by `agents.sh`)
406
-
407
- `AGENTS.md` is produced by the `agents` adapter on every sync. It is NOT hand-authored. Do not create this file yourself in Phase 3 -- it will be generated in Phase 4 by `intelligence/sync/scripts/sync.sh`.
408
-
409
- Your job in Phase 3 is to fill `targets.agents.header` in `config.yaml` (see 3.1) with a 3-5 line project summary: title, stack one-liner, link to `intelligence/rules/context.md`. The adapter appends auto-built tables for agents/skills and a list of rules after the header.
410
-
411
- The file is committed (not gitignored) but carries a `<!-- Generated ... do not edit manually -->` marker. All regeneration happens via `bash intelligence/sync/scripts/sync.sh`.
412
-
413
- ### 3.8 `CLAUDE.md` (if Claude enabled)
414
-
415
- Gitignored user preferences:
416
- - Response language
417
- - Setup: `intelligence/sync/scripts/sync.sh`
418
- - Helper scripts, git commit rules
419
-
420
- ---
421
-
422
- ## Phase 4: Verify
423
-
424
- 1. Run `intelligence/sync/scripts/sync.sh`
425
- 2. If sync fails -- read the error, fix the cause (usually missing directory or malformed frontmatter), retry
426
- 3. Verify output counts match expectations
427
- 4. Report to user:
428
- - Files created (rules, agents, skills)
429
- - Sync results per target
430
- - **Enabled targets**: list what was configured (e.g., "claude, cursor, copilot")
431
- - **Available but not enabled**: list remaining adapters (e.g., "codex, pi, opencode — enable via `/intelligence-install-adapter <name>`")
432
- - **Available skills**: list all (pre-installed + generated)
433
- - "To add rules/agents/skills: `/intelligence-add-rule`, `/intelligence-add-agent`, `/intelligence-add-skill`"
434
- - "After manual edits: `/intelligence-sync` to re-sync"
435
-
436
- ---
437
-
438
- ## Reference
439
-
440
- ### Frontmatter
441
-
442
- **YAML safety (required):** **always wrap `description` and any other free-text string field in double quotes**, even when no special characters are present. Codex CLI uses strict YAML — an unquoted colon, hyphen, or word that parses as boolean (`yes`, `no`) silently breaks the file. Quoting unconditionally removes a whole class of bugs and makes lint trivial. If the value itself contains a double quote, escape it as `\"` or wrap the value in single quotes — an unescaped inner quote terminates the scalar early. The sync engine auto-escapes inner quotes when it quotes a value, as a backstop.
443
-
444
- **Agent:**
445
- ```yaml
446
- ---
447
- name: agent-name
448
- description: "When to use this agent"
449
- tier: heavy|standard|light # heavy=opus, standard=sonnet, light=haiku
450
- access: full|readonly # full=all tools, readonly=no write/edit
451
- skills: # optional: skills this agent can invoke
452
- - domain-add-something
453
- - domain-run-tests
454
- ---
455
- ```
456
-
457
- **Rule:**
458
- ```yaml
459
- ---
460
- paths: # omit for always-loaded rules
461
- - "src/backend/**"
462
- ---
463
- ```
464
-
465
- **Skill:**
466
- ```yaml
467
- ---
468
- name: domain-verb-noun
469
- description: "What the skill does"
470
- argument-hint: <arg1> [arg2] # optional
471
- agent: agent-name # optional: which agent executes this skill
472
- ---
473
- ```
474
-
475
- ### Content structure
476
-
477
- **Rule body:** REQUIRED -> Invariants -> Architecture -> Build & Test -> Examples (from actual codebase) -> Patterns to recognize and replace (optional reference section)
478
-
479
- - Lead with REQUIRED (positive defaults / judgment calls)
480
- - Reserve **Invariants** for true must-nots — safety, output format, security
481
- - **Patterns to recognize and replace** is reference documentation of anti-patterns with their positive replacement, not LLM instructions
482
-
483
- **Agent body:** Expertise -> Boundaries (where it stops) -> Build & Verify. An agent is thin — rules reach it automatically, so it never lists rules to read.
484
-
485
- **Skill body:** Steps (numbered, concrete, with verification at the end). A skill that dispatches to other skills names them and never restates their content.
486
-
487
- ### Skill naming
488
-
489
- Prefix with domain: `backend-`, `frontend-`, `devops-`, `intelligence-`, etc.
490
-
491
- | Prefix | Type |
492
- |--------|------|
493
- | `<domain>-add-` | Adds one member to a set that already exists |
494
- | `<domain>-create-` | Brings into existence a container nothing hosted before |
495
- | `<domain>-run-` | Runs an operation |
496
- | `<domain>-review-` | Analyzes without changes |
497
-
498
- ---
499
-
500
- intelligence-sync is created by [Ainova Systems](https://www.ainovasystems.com). MIT License.