@ainova-systems/intelligence 0.11.0-rc.1 → 0.11.0-rc.10

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 (72) hide show
  1. package/README.md +19 -16
  2. package/cli/commands/adapter.sh +153 -0
  3. package/cli/commands/init.sh +171 -34
  4. package/cli/commands/package.sh +30 -0
  5. package/cli/commands/registry.sh +65 -30
  6. package/cli/commands/status.sh +20 -11
  7. package/cli/commands/sync.sh +9 -4
  8. package/cli/commands/update.sh +80 -46
  9. package/cli/engine-package.yaml +14 -0
  10. package/cli/intelligence +37 -26
  11. package/cli/internal/align-project.sh +134 -0
  12. package/cli/internal/check.sh +128 -0
  13. package/cli/internal/convert-legacy.sh +400 -0
  14. package/cli/{commands/add.sh → internal/package-add.sh} +37 -19
  15. package/cli/{commands/list.sh → internal/package-list.sh} +10 -5
  16. package/cli/{commands/remove.sh → internal/package-remove.sh} +16 -4
  17. package/cli/internal/package-search.sh +83 -0
  18. package/cli/internal/package-update.sh +103 -0
  19. package/cli/internal/restore.sh +130 -0
  20. package/cli/internal/target-state.sh +57 -0
  21. package/cli/lib/cli-common.sh +213 -63
  22. package/cli/lib/lockfile.sh +15 -9
  23. package/cli/lib/manifest.sh +257 -4
  24. package/cli/lib/registry.sh +96 -47
  25. package/cli/lib/semver.sh +12 -4
  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 +30 -538
  31. package/engine/lib/contract.sh +120 -0
  32. package/engine/sync.sh +238 -0
  33. package/package.json +5 -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 +7 -7
  39. package/{engine → packages/sync}/skills/intelligence-add-agent/SKILL.md +7 -7
  40. package/{engine → packages/sync}/skills/intelligence-add-rule/SKILL.md +5 -5
  41. package/{engine → packages/sync}/skills/intelligence-add-skill/SKILL.md +5 -5
  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 +7 -7
  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/cli/commands/doctor.sh +0 -100
  51. package/cli/commands/install.sh +0 -84
  52. package/cli/commands/migrate.sh +0 -251
  53. package/cli/commands/upgrade.sh +0 -27
  54. package/engine/INIT.md +0 -498
  55. package/engine/docs/ADAPTERS.md +0 -212
  56. package/engine/docs/CLI.md +0 -91
  57. package/engine/docs/CONVENTIONS.md +0 -440
  58. package/engine/scripts/lib/layout.sh +0 -51
  59. package/engine/scripts/lib/migrations.sh +0 -708
  60. package/engine/scripts/sync.sh +0 -311
  61. package/engine/scripts/update.sh +0 -237
  62. package/engine/skills/intelligence-install-adapter/SKILL.md +0 -31
  63. package/engine/skills/intelligence-sync/SKILL.md +0 -18
  64. package/engine/skills/intelligence-uninstall-adapter/SKILL.md +0 -42
  65. package/engine/skills/intelligence-update/SKILL.md +0 -159
  66. package/registry/index.yaml +0 -15
  67. /package/engine/{scripts/VERSION → VERSION} +0 -0
  68. /package/engine/{scripts/adapters → adapters}/claude.sh +0 -0
  69. /package/engine/{scripts/adapters → adapters}/codex.sh +0 -0
  70. /package/engine/{scripts/adapters → adapters}/copilot.sh +0 -0
  71. /package/engine/{scripts/adapters → adapters}/cursor.sh +0 -0
  72. /package/engine/{scripts/adapters → adapters}/pi.sh +0 -0
@@ -0,0 +1,252 @@
1
+ # Writing an Intelligence Adapter
2
+
3
+ An adapter transforms tool-neutral rules, agents and skills into one tool's native files. The sync engine discovers adapters by filename and calls one shell function for each enabled target.
4
+
5
+ ## Built-in and project adapters
6
+
7
+ | Location | Owner | Upgrade behavior |
8
+ |---|---|---|
9
+ | Installed CLI's `engine/adapters/` | Intelligence | Replaced when the CLI is upgraded |
10
+ | `<content-dir>/adapters/` | Project | Never changed by CLI upgrades |
11
+
12
+ The default content directory is `intelligence/`; `project.intelligence_dir` in `intelligence.yaml` may choose another. A project adapter with the same name as a built-in overrides it, and sync reports the override.
13
+
14
+ Contribute broadly useful integrations as built-ins. Keep organization-specific or experimental formats in the project.
15
+
16
+ ## Create and enable an adapter
17
+
18
+ Choose a lowercase shell-safe name matching `[a-z][a-z0-9_]*`, then scaffold from the template bundled with the installed engine:
19
+
20
+ ```bash
21
+ intelligence adapter create mytool
22
+ ```
23
+
24
+ This creates `<content-dir>/adapters/mytool.sh` and refuses to overwrite an existing file. Implement the generated functions, then enable its target:
25
+
26
+ ```bash
27
+ intelligence adapter enable mytool
28
+ ```
29
+
30
+ `adapter enable` adds or updates this manifest entry when the adapter exists, then runs a full sync so shared outputs such as `AGENTS.md` remain current:
31
+
32
+ ```yaml
33
+ targets:
34
+ mytool: { enabled: true, output: ".mytool" }
35
+ ```
36
+
37
+ Change `output` in `intelligence.yaml` if the tool expects another location. The engine validates the resolved path before calling the adapter.
38
+
39
+ To stop syncing a target:
40
+
41
+ ```bash
42
+ intelligence adapter disable mytool
43
+ ```
44
+
45
+ Disabling changes only target state. Generated output is deliberately kept because a generic command cannot know which paths a custom adapter owns. Remove only documented owned paths after reviewing them. A disabled project adapter can be deleted with `intelligence adapter remove mytool`; removal prompts by default, accepts `--apply` for explicit non-interactive use, and also keeps generated output. Built-in adapter source cannot be removed. Use `intelligence adapter list` to inspect source, state and output.
46
+
47
+ ## Required function
48
+
49
+ The file name and function name form the adapter's identity:
50
+
51
+ ```bash
52
+ # <content-dir>/adapters/mytool.sh
53
+ sync_to_mytool() {
54
+ local repo_root="$1"
55
+ local config_file="$2"
56
+ local output_dir="$3"
57
+
58
+ # transform sources into output_dir
59
+ }
60
+ ```
61
+
62
+ The engine calls:
63
+
64
+ ```text
65
+ sync_to_<name> <repo-root> <absolute-intelligence.yaml> <absolute-output-path>
66
+ ```
67
+
68
+ The engine has already loaded `engine/lib/common.sh` before it sources the adapter, so project adapters use its functions directly.
69
+
70
+ ## Source model
71
+
72
+ `sources.rules`, `sources.agents` and `sources.skills` contain repo-relative directory paths. Packages have already been resolved, fetched and pinned by the CLI, so package content appears as an ordinary path under `.intelligence/packages/`. Adapters never perform network access or parse `packages:`.
73
+
74
+ Iterate a source section in manifest order:
75
+
76
+ ```bash
77
+ while IFS= read -r src; do
78
+ [ -n "$src" ] || continue
79
+ dir="$(resolve_source_dir "$repo_root" "$src")"
80
+ [ -d "$dir" ] || continue
81
+
82
+ for file in "$dir"/*.md; do
83
+ [ -f "$file" ] || continue
84
+ # transform file
85
+ done
86
+ done < <(read_yaml_list "$config_file" "rules")
87
+ ```
88
+
89
+ Later sources intentionally overwrite same-named artifacts from earlier sources. Package sources are wired before project sources, so project content can override a package artifact by name.
90
+
91
+ ## Shared functions
92
+
93
+ Use the engine library instead of copying parsers or file-handling logic.
94
+
95
+ | Function | Purpose |
96
+ |---|---|
97
+ | `resolve_source_dir(repo_root, source)` | Resolve a manifest source to its local directory. |
98
+ | `read_yaml_list(config, section)` | Stream entries from `sources.<section>`. |
99
+ | `get_frontmatter_value(key, file)` | Read a scalar from the first frontmatter block. |
100
+ | `has_frontmatter(file)` / `has_paths(file)` | Inspect source shape. |
101
+ | `strip_frontmatter(file)` | Emit the body without its first frontmatter block. |
102
+ | `get_model(config, tool, tier)` | Resolve a `heavy`, `standard` or `light` model, including manifest overrides. |
103
+ | `get_model_default(tool, tier)` | Read the built-in model default. |
104
+ | `copy_skill_bundle(src, dest)` | Copy `SKILL.md` and all resources safely, normalize Markdown and quote free-text frontmatter. |
105
+ | `sync_open_skill_dirs(root, config, dest)` | Own and populate a shared Agent Skills directory such as `.agents/skills/`. |
106
+ | `finalize_output_file(file)` | Expand layout tokens and normalize line endings; required for every emitted text file. |
107
+ | `get_target_field(config, target, field)` | Read another field from the target configuration. |
108
+ | `repo_rel_link(root, path)` | Produce a stable repo-relative link for a committed output. |
109
+
110
+ `lint_frontmatter` is run across all inputs by the engine before adapters execute. It warns about common YAML hazards; adapters should not duplicate that pass.
111
+
112
+ ## Rules, skills and agents
113
+
114
+ ### Rules
115
+
116
+ Rules without `paths:` are always-on. Rules with `paths:` are scoped.
117
+
118
+ Intelligence routes always-on rules once through `AGENTS.md` for tools that consume it. An adapter for such a tool should not copy those rules again. If the tool has a native scoped-rule channel, transform `paths:` to the tool's equivalent.
119
+
120
+ | Built-in | Always-on rules | Scoped rules |
121
+ |---|---|---|
122
+ | `agents` | Inline in `AGENTS.md` | List with links |
123
+ | `claude` | Copy | Copy with `paths:` preserved |
124
+ | `cursor` | Omit; reads `AGENTS.md` | `.mdc` with `globs:` |
125
+ | `copilot` | Omit; reads `AGENTS.md` | `.instructions.md` with `applyTo:` |
126
+ | `codex` | Omit; reads `AGENTS.md` | No native channel |
127
+ | `pi` | Omit; reads `AGENTS.md` | Generated on-demand files and extension |
128
+ | `opencode` | Omit; reads `AGENTS.md` | No native channel |
129
+
130
+ If a new adapter relies on `AGENTS.md` for always-on rules, its target must require `agents`. Add that invariant to `engine/sync.sh` when contributing the adapter upstream.
131
+
132
+ ### Skills
133
+
134
+ Skills follow the [Agent Skills standard](https://agentskills.io). Copy each skill directory as a complete bundle—not only `SKILL.md`—because its body may reference `references/`, `scripts/` or `assets/` beside it.
135
+
136
+ ```bash
137
+ copy_skill_bundle "$source_skill_dir" "$output_dir/skills/$skill_name"
138
+ ```
139
+
140
+ Do not use plain `cp` for skill bundles. `copy_skill_bundle` preserves non-Markdown assets, avoids materializing symlink targets, normalizes Markdown, expands layout tokens and quotes `description` and `argument-hint` where strict YAML readers require strings.
141
+
142
+ Codex, Pi and OpenCode share `.agents/skills/`. Any adapter writing that open-standard directory must call `sync_open_skill_dirs`; it is the single lifecycle owner for immediate skill subdirectories.
143
+
144
+ ### Agents
145
+
146
+ Source agents use tool-neutral fields:
147
+
148
+ ```yaml
149
+ ---
150
+ name: backend-developer
151
+ description: "Implements backend features"
152
+ tier: heavy
153
+ access: full
154
+ ---
155
+ ```
156
+
157
+ Map `tier` through `get_model`, not a hardcoded model name. Transform `access: full|readonly` into the target tool's native permission model. Preserve the body as the agent's instructions.
158
+
159
+ Built-ins currently emit Claude and Cursor Markdown, Copilot `.agent.md`, Codex TOML, Pi prompt templates and OpenCode Markdown subagents. Read the closest built-in adapter before implementing a new transformation.
160
+
161
+ ## Layout tokens
162
+
163
+ Content shipped in `@ainova-systems/sync` cannot assume the project's content-directory name or package-store location. It uses these tokens:
164
+
165
+ | Token | Expansion |
166
+ |---|---|
167
+ | `<content-dir>` | Project content directory, usually `intelligence` |
168
+ | `<module>` | Installed sync package, usually `.intelligence/packages/@ainova-systems/sync` |
169
+ | `<manifest>` | `intelligence.yaml` |
170
+ | `<sync-cmd>` | `intelligence sync` |
171
+
172
+ Call `finalize_output_file` on every text file after transformation. It expands the tokens literally and converts CRLF to LF. A generated file containing an unexpanded token is an adapter bug.
173
+
174
+ `copy_skill_bundle` already finalizes Markdown within a skill; do not run a second custom token pass.
175
+
176
+ ## Cleanup and safety contract
177
+
178
+ Adapters regenerate output, so cleanup is part of their public contract.
179
+
180
+ 1. Delete only paths the adapter owns. Preserve sibling settings, commands, extensions, workflows and hand-authored files.
181
+ 2. Make ownership obvious in `sync_to_<name>()`; the same list is what a user removes after disabling or uninstalling the adapter.
182
+ 3. Use marker-based cleanup when generated and hand-authored files share a directory. The OpenCode adapter is the reference implementation.
183
+ 4. Use `sync_open_skill_dirs` for `.agents/skills/`; multiple adapters share it.
184
+ 5. Write only beneath the supplied `output_dir`, except for an explicitly shared standard path handled by a shared helper.
185
+ 6. Make repeated syncs idempotent.
186
+
187
+ Before an adapter runs, the engine canonicalizes and validates its configured output. It refuses the repository root, paths outside the repository, symlink escapes, the project content directory, `.intelligence/` and configured source paths. This guard does not make broad cleanup safe: an adapter must still avoid deleting unrelated files within a valid tool directory.
188
+
189
+ ## Minimal example
190
+
191
+ This example copies rules without frontmatter. A real adapter must decide how the target represents scoping and should also implement agents and skills.
192
+
193
+ ```bash
194
+ #!/bin/bash
195
+
196
+ sync_mytool_rules() {
197
+ local repo_root="$1" config_file="$2" output_dir="$3"
198
+ mkdir -p "$output_dir/rules"
199
+
200
+ while IFS= read -r src; do
201
+ [ -n "$src" ] || continue
202
+ local dir
203
+ dir="$(resolve_source_dir "$repo_root" "$src")"
204
+ [ -d "$dir" ] || continue
205
+
206
+ for file in "$dir"/*.md; do
207
+ [ -f "$file" ] || continue
208
+ strip_frontmatter "$file" > "$output_dir/rules/$(basename "$file")"
209
+ finalize_output_file "$output_dir/rules/$(basename "$file")"
210
+ done
211
+ done < <(read_yaml_list "$config_file" "rules")
212
+ }
213
+
214
+ sync_to_mytool() {
215
+ local repo_root="$1" config_file="$2" output_dir="$3"
216
+
217
+ rm -rf "$output_dir/rules"
218
+ sync_mytool_rules "$repo_root" "$config_file" "$output_dir"
219
+ }
220
+ ```
221
+
222
+ ## Testing
223
+
224
+ Use a disposable Git repository with an Intelligence manifest and representative always-on/scoped rules, agents, skills and bundled skill resources.
225
+
226
+ ```bash
227
+ intelligence sync mytool
228
+ ```
229
+
230
+ Verify:
231
+
232
+ - native file names, frontmatter and model/permission mappings;
233
+ - scoped and always-on routing without duplicated context;
234
+ - skill resources are present;
235
+ - no literal layout tokens remain;
236
+ - hand-authored siblings under the tool root survive;
237
+ - output paths cannot overlap sources or escape the repository;
238
+ - a second sync produces no Git diff.
239
+
240
+ For a built-in adapter, add the same assertions to the repository's smoke or lifecycle tests and run all five CLI suites before submitting the change.
241
+
242
+ ## Built-in outputs
243
+
244
+ | Adapter | Primary output |
245
+ |---|---|
246
+ | `agents` | `AGENTS.md` |
247
+ | `claude` | `.claude/rules`, `.claude/agents`, `.claude/skills` |
248
+ | `cursor` | `.cursor/rules`, `.cursor/agents`, `.cursor/skills` |
249
+ | `copilot` | `.github/instructions`, `.github/agents`, `.github/skills` |
250
+ | `codex` | `.codex/agents`, `.agents/skills` |
251
+ | `pi` | `.pi/intelligence-sync`, `.pi/extensions`, `.pi/prompts`, `.agents/skills` |
252
+ | `opencode` | `.opencode/agents`, marker-owned `.opencode/commands`, `.agents/skills` |
@@ -0,0 +1,385 @@
1
+ # Intelligence Authoring Conventions
2
+
3
+ Intelligence stores project-owned AI rules, agents and skills as tool-neutral Markdown. The CLI installs shared packages, and the sync engine renders each enabled target's native files.
4
+
5
+ ## Choose the right artifact
6
+
7
+ | Type | Intent | Loading | Content |
8
+ |---|---|---|---|
9
+ | **Rule** | The model respects a constraint or convention | Automatic: always-on or path-scoped | Required patterns, invariants, architecture and examples |
10
+ | **Skill** | The model performs a procedure | Explicit invocation | Ordered steps, decisions and verification |
11
+ | **Agent** | The model adopts a role or expertise boundary | Explicit selection or skill binding | Expertise, boundaries and build/verify behavior |
12
+
13
+ Use these tests:
14
+
15
+ - “The model should consider this during every task in scope” → rule.
16
+ - “The model should execute these steps” → skill.
17
+ - “The model should reason as this specialist” → agent.
18
+
19
+ Do not bury conventions in agents, workflows in rules or reusable expertise in skills. Each misplaced concern either fails to load when needed or consumes context when it is not needed.
20
+
21
+ ## Intelligence project structure
22
+
23
+ ```text
24
+ project/
25
+ ├── intelligence.yaml # root manifest and schema_version contract
26
+ ├── intelligence.lock # resolved packages; commit it
27
+ ├── intelligence/ # project-owned content; name is configurable
28
+ │ ├── rules/
29
+ │ │ ├── context.md
30
+ │ │ └── backend.md
31
+ │ ├── agents/
32
+ │ │ └── backend-developer.md
33
+ │ ├── skills/
34
+ │ │ └── backend-add-endpoint/
35
+ │ │ └── SKILL.md
36
+ │ └── adapters/ # optional project adapters
37
+ │ └── mytool.sh
38
+ ├── .intelligence/ # CLI-managed package store; gitignored
39
+ │ └── packages/
40
+ │ └── @scope/name/
41
+ ├── AGENTS.md # generated canonical context; normally committed
42
+ └── .claude/ .cursor/ ... # generated tool-native output
43
+ ```
44
+
45
+ The content directory defaults to `intelligence/`. A project may set `project.intelligence_dir` in `intelligence.yaml`; never infer or hardcode the default when the manifest is available.
46
+
47
+ Project-authored rules, agents, skills and adapters live in the content directory. Installed package content lives under `.intelligence/packages/` and is replaced by CLI lifecycle/package operations; edit it only in its source repository. The executable engine remains with the installed CLI, outside the project.
48
+
49
+ The `intelligence-` name prefix is reserved for artifacts shipped by `@ainova-systems/sync`. Project artifacts use their project or domain prefix.
50
+
51
+ ## Manifest, packages and sources
52
+
53
+ The engine consumes ordinary local source paths:
54
+
55
+ ```yaml
56
+ project:
57
+ name: payments
58
+ intelligence_dir: "intelligence" # optional; this is the default
59
+
60
+ schema_version: "0.11.0"
61
+
62
+ sources:
63
+ rules:
64
+ - ".intelligence/packages/@ainova-systems/sync/rules"
65
+ - "intelligence/rules"
66
+ agents:
67
+ - ".intelligence/packages/@ainova-systems/sync/agents"
68
+ - "intelligence/agents"
69
+ skills:
70
+ - ".intelligence/packages/@ainova-systems/sync/skills"
71
+ - "intelligence/skills"
72
+ ```
73
+
74
+ Missing project-owned source directories are skipped, so a package-only project need not create empty `rules/`, `agents/` or `skills/` directories. Source order matters: later files with the same artifact name overwrite earlier ones. Package sources are wired before project sources so the project can override a package artifact deliberately.
75
+
76
+ The CLI owns package and registry blocks:
77
+
78
+ ```yaml
79
+ packages:
80
+ "@acme/backend":
81
+ version: "^1.2.0"
82
+
83
+ registries:
84
+ - "https://github.com/acme/intelligence-registry.git"
85
+ ```
86
+
87
+ Do not put Git URLs or remote tokens directly in `sources:`. Use:
88
+
89
+ ```bash
90
+ intelligence package add @acme/backend
91
+ intelligence package add github:acme/backend-intelligence
92
+ intelligence package add 'git+https://git.example.com/acme/backend.git@main#package'
93
+ ```
94
+
95
+ Registries are an ordered trust list and the only resolver for a package name. There is no built-in catalog and no `@org/name` → GitHub guessing. An explicit `github:` or `git+` spec bypasses registry lookup. In every case the manifest stores only requested `version` or `ref`; resolved URL/path and SHA live in the lock.
96
+
97
+ Stable Git tags provide package versions. Semver ranges select the highest matching stable tag; a `ref:` pin names a branch or commit and does not move during `intelligence update`. One package name has one version per project.
98
+
99
+ Commit `intelligence.lock`. It records requested versions, source URLs and paths, resolved refs and commit SHAs. After cloning, `intelligence sync` restores a missing store strictly from that lock before rendering; manifest/lock or SHA drift is refused. Re-run `package add` when deliberately changing a source.
100
+
101
+ `@ainova-systems/sync` is ordinary package content exact-pinned to the bundled engine version. `intelligence init` installs it unless `--bare` is used. Lifecycle preflight keeps that pin and `schema_version` aligned with the installed CLI; package-range updates never move it independently.
102
+
103
+ ## Layout tokens
104
+
105
+ Package-owned artifacts cannot assume the project's content-directory name or their installed package path. They use tokens expanded by every adapter through `finalize_output_file`:
106
+
107
+ | Token | Expansion |
108
+ |---|---|
109
+ | `<content-dir>` | Repo-relative content directory, usually `intelligence` |
110
+ | `<module>` | Installed sync package, usually `.intelligence/packages/@ainova-systems/sync` |
111
+ | `<manifest>` | `intelligence.yaml` |
112
+ | `<sync-cmd>` | `intelligence sync` |
113
+
114
+ Expansion applies to frontmatter and bodies. Thus `paths: ["<content-dir>/**"]` reaches every native scoped-rule format with the project's real directory name.
115
+
116
+ Project-authored artifacts normally use their known project paths directly. Tokens are useful only when the same artifact must work under different content-directory or package-store locations.
117
+
118
+ ## Naming
119
+
120
+ Rule filenames, agent names and skill names share a domain prefix such as `backend-`, `frontend-`, `devops-`, `core-`, `tests-`, a project codename or a monorepo component. Pick the domain from repository structure and reuse it.
121
+
122
+ - Skills: `<domain>-<verb>-<noun>`, for example `backend-add-endpoint`.
123
+ - Agents: `<domain>-<role>`, for example `backend-code-reviewer`.
124
+ - Rules: `<domain>.md`, for example `backend.md`.
125
+
126
+ Common skill verbs:
127
+
128
+ | Verb | Meaning |
129
+ |---|---|
130
+ | `add-` | Add one member to an existing set |
131
+ | `create-` | Create a new container or top-level artifact |
132
+ | `update-` | Revise existing state selectively |
133
+ | `run-` | Execute an operation |
134
+ | `review-` | Perform read-only analysis |
135
+ | `test-` | Verify behavior |
136
+ | `remove-` | Remove an artifact safely |
137
+
138
+ The verb describes the outcome, not whether the skill implements the work or delegates to another command or skill.
139
+
140
+ ## Agent conventions
141
+
142
+ ```yaml
143
+ ---
144
+ name: backend-developer
145
+ description: "Implements backend features"
146
+ tier: heavy
147
+ access: full
148
+ skills:
149
+ - backend-add-endpoint
150
+ ---
151
+
152
+ # Backend developer
153
+
154
+ Agent instructions in Markdown.
155
+ ```
156
+
157
+ An agent stays thin: **Expertise** → **Boundaries** → **Build & Verify**. Its role, limits and proof of completion belong here; reusable constraints belong in rules and reusable procedures belong in skills.
158
+
159
+ Do not instruct an agent to read rules or restate their content. Claude loads its generated rules for its subagents, while Cursor, Copilot, Codex, Pi and OpenCode receive always-on rules through `AGENTS.md`. Duplicating a rule in an agent spends context twice and creates a copy that drifts.
160
+
161
+ ### Tier mappings
162
+
163
+ | Tier | Claude | Cursor | Copilot / Codex | OpenCode | Typical use |
164
+ |---|---|---|---|---|---|
165
+ | `heavy` | `opus` | `inherit` | `gpt-5.6-sol` | `anthropic/claude-opus-4-8` | implementation, complex reasoning, migration |
166
+ | `standard` | `sonnet` | `inherit` | `gpt-5.6-terra` | `anthropic/claude-sonnet-5` | review, validation, analysis |
167
+ | `light` | `haiku` | `fast` | `gpt-5.6-luna` | `anthropic/claude-haiku-4-5-20251001` | lookups and simple formatting |
168
+
169
+ The vocabulary is tool-neutral. Adapters resolve it through `get_model()`. Override a default under `models.<tool>.<tier>` in `intelligence.yaml` only when the project needs a pin; sync reports drift when that override differs from the current default.
170
+
171
+ ### Access mappings
172
+
173
+ `access: full` inherits ordinary tool permissions. `access: readonly` is transformed into the target's native restriction: for example Claude receives read/search/bash tools with writes disallowed, Cursor receives `readonly: true`, and Codex receives a read-only sandbox.
174
+
175
+ Use only `full` or `readonly` in source agents. Tool-specific permission syntax belongs in adapters.
176
+
177
+ ## Rule conventions
178
+
179
+ ```yaml
180
+ ---
181
+ paths:
182
+ - "src/backend/**"
183
+ - "config/**"
184
+ description: "Backend conventions"
185
+ ---
186
+
187
+ # Backend conventions
188
+
189
+ Rule content in Markdown.
190
+ ```
191
+
192
+ `paths:` is optional:
193
+
194
+ - With `paths:`, the rule is scoped to matching repository files.
195
+ - Without `paths:`, the rule is always-on project context.
196
+
197
+ ### Routing
198
+
199
+ | Source rule | Claude | Cursor | Copilot | Codex / Pi / OpenCode / `AGENTS.md` |
200
+ |---|---|---|---|---|
201
+ | Scoped | copied with `paths:` | `.mdc` with `globs:` | `.instructions.md` with `applyTo:` | listed in `AGENTS.md`; Pi also gets on-demand files and an extension |
202
+ | Always-on | copied | omitted | omitted | inlined once into `AGENTS.md` |
203
+
204
+ Cursor, Copilot, Codex, Pi and OpenCode consume `AGENTS.md`, so always-on rules are not duplicated in their tool-specific channels. Claude does not consume `AGENTS.md`, so it receives the full rule set. OpenCode and Codex have no generated path-scoped rule channel; OpenCode users may configure `instructions:` globs themselves.
205
+
206
+ Keep always-on rules small. Put narrow framework or component guidance behind `paths:` so unrelated tasks do not pay its context cost.
207
+
208
+ ## Skill conventions
209
+
210
+ Skills follow the [Agent Skills standard](https://agentskills.io). Required fields are `name` and `description`.
211
+
212
+ ```yaml
213
+ ---
214
+ name: backend-add-endpoint
215
+ description: "Add a backend endpoint"
216
+ argument-hint: "<route-name>"
217
+ ---
218
+
219
+ # Add a backend endpoint
220
+
221
+ 1. Inspect the existing route pattern.
222
+ 2. Implement the endpoint.
223
+ 3. Run focused tests.
224
+ 4. Report the changed route and verification.
225
+ ```
226
+
227
+ Standard optional fields (`license`, `compatibility`, `metadata`, `allowed-tools`) and tool extensions pass through unchanged. A tool ignores fields it does not understand.
228
+
229
+ These limits reject a skill instead of degrading it:
230
+
231
+ | Field | Limit | Failure mode |
232
+ |---|---|---|
233
+ | `name` | 64 characters | Rejected at load |
234
+ | `description` | 1024 characters | Rejected at load |
235
+ | `argument-hint` | Must be a string | An unquoted `[value]` is parsed as a YAML sequence |
236
+
237
+ Sync quotes free-text `description` and `argument-hint` values in generated copies. `lint_frontmatter` warns when a name or description exceeds its hard limit, but the author must shorten it.
238
+
239
+ ### Description budget
240
+
241
+ Descriptions share the tool's available-artifact context budget.
242
+
243
+ | Case | Format | Target |
244
+ |---|---|---|
245
+ | Unique skill | Plain verb–noun phrase | 4–8 words |
246
+ | Similar sibling skills | Verb–noun plus a distinguishing trigger | 10–20 words, roughly 250 characters or less |
247
+
248
+ The 1024-character limit is a rejection wall, not a writing target. Curate duplicate and orphaned artifacts before compressing every description into ambiguity.
249
+
250
+ ### Skill body and resources
251
+
252
+ A skill that performs work carries the decisions and verification needed for that work. A skill that dispatches to deterministic CLI behavior stays thin: it chooses the command, interprets status and adds only judgment that the program cannot provide.
253
+
254
+ Keep on-demand detail beside the skill:
255
+
256
+ ```text
257
+ skill-name/
258
+ ├── SKILL.md
259
+ ├── references/ # detailed material loaded only when needed
260
+ ├── scripts/ # deterministic or repetitive helpers
261
+ └── assets/ # templates and output resources
262
+ ```
263
+
264
+ The engine copies the complete skill directory. Promote a helper outside the skill only when multiple skills share it.
265
+
266
+ Size limits are backstops, not quotas:
267
+
268
+ | Artifact | Hard cap | Response |
269
+ |---|---|---|
270
+ | `SKILL.md` body | 1000 lines | Move detail to `references/` |
271
+ | Reference file | 500 lines | Add a contents list past 300; split if still oversized |
272
+ | Rule | 500 lines | Split by scope or move examples behind a skill reference |
273
+ | Agent | 200 lines | Move procedures and constraints into skills/rules |
274
+
275
+ ## Writing discipline
276
+
277
+ - Use imperative form: “Read the manifest,” not “You should read the manifest.”
278
+ - Explain why a decision rule exists so the model can apply it to adjacent cases.
279
+ - Reserve absolute language for genuine safety, security and output-format invariants.
280
+ - Lead with the positive behavior; keep anti-patterns after the actionable guidance.
281
+ - Remove instructions that repeat tool defaults, repository facts already discoverable from files, or another artifact.
282
+ - Turn repeated deterministic work into a script or CLI command and let the skill interpret it.
283
+
284
+ Every line enters a finite context budget. Prefer subtraction, consolidation and precise scope over exhaustive prose.
285
+
286
+ ## Generated output
287
+
288
+ | Target | Rules | Skills | Agents |
289
+ |---|---|---|---|
290
+ | `agents` | Always-on inlined; scoped listed in `AGENTS.md` | Listed | Listed |
291
+ | Claude | `.claude/rules/` | `.claude/skills/` | `.claude/agents/` |
292
+ | Cursor | scoped `.cursor/rules/*.mdc` | `.cursor/skills/` | `.cursor/agents/` |
293
+ | Copilot | scoped `.github/instructions/*.instructions.md` | `.github/skills/` | `.github/agents/` |
294
+ | Codex | `AGENTS.md` only | `.agents/skills/` | `.codex/agents/*.toml` |
295
+ | Pi | `AGENTS.md` plus scoped `.pi/intelligence-sync/rules/` | `.agents/skills/` | `.pi/prompts/intelligence-agent-*.md` |
296
+ | OpenCode | `AGENTS.md` only | `.agents/skills/` plus slash commands | `.opencode/agents/*.md` |
297
+
298
+ `AGENTS.md` is regenerated by the `agents` adapter. Its optional static header is `targets.agents.header` in `intelligence.yaml`; generated rule, agent and skill sections follow it. Commit `AGENTS.md` when it is the project's shared canonical context.
299
+
300
+ Generated IDE output may be gitignored when every collaborator can reproduce it with `intelligence sync`. Use narrow ownership patterns so hand-authored tool settings remain trackable:
301
+
302
+ ```gitignore
303
+ # CLI-managed package store
304
+ .intelligence/
305
+
306
+ # Generated Claude and Cursor content; settings remain trackable
307
+ .claude/rules/
308
+ .claude/agents/
309
+ .claude/skills/
310
+ .cursor/rules/
311
+ .cursor/agents/
312
+ .cursor/skills/
313
+
314
+ # Generated open-standard and Codex content
315
+ .agents/
316
+ .codex/agents/
317
+
318
+ # Generated Pi content
319
+ .pi/intelligence-sync/
320
+ .pi/extensions/intelligence-sync-rules.ts
321
+ .pi/prompts/intelligence-agent-*.md
322
+
323
+ # Generated OpenCode agents. Its commands directory may also contain
324
+ # hand-authored files, so choose per-project ignores there.
325
+ .opencode/agents/
326
+ ```
327
+
328
+ Copilot output lives under `.github/`; choose whether to commit it with other repository-level GitHub configuration. Do not ignore `.github/` wholesale.
329
+
330
+ ## Project-owned adapters
331
+
332
+ Create a project adapter with:
333
+
334
+ ```bash
335
+ intelligence adapter create mytool
336
+ # implement <content-dir>/adapters/mytool.sh
337
+ intelligence adapter enable mytool
338
+ ```
339
+
340
+ Project adapters survive CLI upgrades and may override a built-in by name. `intelligence adapter enable mytool` runs a full sync so shared context stays current. `intelligence adapter disable mytool` keeps generated output for explicit, adapter-aware cleanup; a disabled project adapter can then be deleted with `intelligence adapter remove mytool`. See `adapters.md` for the function, ownership and safety contracts.
341
+
342
+ ## Schema and command boundaries
343
+
344
+ The permanent applied-schema key is the top-level scalar `schema_version` in `intelligence.yaml`. It is not a dotfile and not the CLI package version. Do not rename, move or reshape this key: every engine must be able to decide compatibility before parsing the rest of the manifest.
345
+
346
+ The public lifecycle is deliberately compact:
347
+
348
+ - `intelligence init [--preview|--apply]` is universal: it creates a new setup, aligns an existing Intelligence project, or plans/applies conversion of an eligible legacy Intelligence Sync project.
349
+ - `intelligence sync [adapter]` first aligns an existing Intelligence project with the installed CLI, restores a missing store strictly from `intelligence.lock`, then renders. In CI it refuses an alignment that would change tracked files and points to a local `intelligence init --apply` plus review/commit.
350
+ - `intelligence update [@scope/name] [--preview|--apply]` is the only update surface. It prints the CLI/project/package plan; default mode prompts, `--preview` never writes, and `--apply` does not prompt. It never moves `ref:` pins.
351
+ - `intelligence package add|remove|list|search` owns package inventory.
352
+ - `intelligence adapter list|create|enable|disable|remove` owns adapter inventory and target state.
353
+ - `intelligence status [--check]` reports state; `--check` runs deep consistency checks.
354
+
355
+ Implement Intelligence schema changes as idempotent structural checks. Stage and verify replacement state before deleting or replacing prior state. A stale engine refuses a manifest whose `schema_version` is newer; normal project entry points close a behind-project gap through lifecycle preflight.
356
+
357
+ Breaking changelog entries use a `### Breaking` checklist of verifiable post-conditions. The update skill reads every release across the version gap, chooses the package/CLI/project command sequence and verifies those conditions after the deterministic command completes.
358
+
359
+ ### Engine status contract
360
+
361
+ The engine emits one machine-readable line, `IS_STATUS=<code> [IS_DETAIL=...]`, and exits with a stable code:
362
+
363
+ | `IS_STATUS` | Exit | Meaning |
364
+ |---|---:|---|
365
+ | `ok` | 0 | Sync or operation completed |
366
+ | `migrated` | 0 | Initialization converted an older layout |
367
+ | `error` | 1 | Generic failure |
368
+ | `config-missing` | 2 | Required manifest is absent |
369
+ | `ambiguous` | 3 | Conflicting state requiring agent/human judgment; reserved |
370
+ | `ahead-of-engine` | 4 | Manifest schema is newer than the engine |
371
+ | `aborted-incomplete` | 5 | Staged replacement was incomplete; prior state remains |
372
+ | `needs-update` | 6 | Project schema is behind the engine; rerun through a public lifecycle command |
373
+
374
+ Callers capture the real code with `command || rc=$?`. Do not use `if ! command; then rc=$?`; inside that branch `$?` is the status of the negation.
375
+
376
+ ## Project entry points
377
+
378
+ | Path | Role | Git status |
379
+ |---|---|---|
380
+ | `intelligence.yaml` | Manifest and schema contract | Tracked |
381
+ | `intelligence.lock` | Resolved package state | Tracked |
382
+ | `<content-dir>/{rules,agents,skills,adapters}/` | Project source of truth | Tracked |
383
+ | `.intelligence/` | Restorable package store | Ignored |
384
+ | `AGENTS.md` | Generated canonical project context | Normally tracked |
385
+ | Tool output directories | Generated native content | Project policy; use narrow ignores |