@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
@@ -1,456 +0,0 @@
1
- # intelligence-sync: Conventions
2
-
3
- ## Choosing artifact type
4
-
5
- Three artifact types — each has a different intent and loading mechanism. Picking the right one is the first authoring decision.
6
-
7
- | Type | Intent | Loading | Content |
8
- |---|---|---|---|
9
- | **Rule** | LLM **respects** a constraint or convention in the background | Auto (path-scoped or always-on) | Required patterns, invariants, architecture, examples |
10
- | **Skill** | LLM **performs** a multi-step procedure on invocation | Explicit (`/skill-name`) | Numbered steps with verification |
11
- | **Agent** | LLM **adopts** a persona / domain expertise | Explicit (via agent picker) | Expertise scope, before-any-task checklist, build/verify |
12
-
13
- Plain rule of thumb:
14
- - "AI should consider X across any work in scope" → **rule**
15
- - "AI should execute a defined sequence of steps" → **skill**
16
- - "AI should think as an X-domain expert with these tools" → **agent**
17
-
18
- Common mistakes to avoid:
19
- - Conventions / standards embedded in an agent body → belongs in a **rule** (auto-loaded, shared across all agents working in scope)
20
- - A workflow embedded in a rule body → belongs in a **skill** (explicit invocation, not always-loaded context)
21
- - Expertise scope embedded in a skill body → belongs in an **agent** (persona reusable across many skills)
22
-
23
- ## Source Structure
24
-
25
- ```
26
- intelligence/ # Umbrella — name NOT hardcoded (whatever holds config.yaml)
27
- ├── config.yaml # Sync config + `sync_version` schema key (committed)
28
- ├── rules/ # Path-based rules (auto-loaded by context)
29
- │ ├── context.md # Always-loaded (no paths:)
30
- │ ├── backend.md # paths: ["src/backend/**"]
31
- │ └── frontend.md # paths: ["src/frontend/**"]
32
- ├── agents/ # Specialized agent definitions
33
- │ ├── backend-developer.md # tier: heavy, access: full
34
- │ └── backend-code-reviewer.md # tier: standard, access: readonly
35
- ├── skills/ # Reusable project skill commands
36
- │ ├── backend-add-endpoint/SKILL.md
37
- │ └── frontend-add-component/SKILL.md
38
- ├── adapters/ # OPTIONAL — project-owned adapters (survive updates)
39
- │ └── myide.sh # sync_to_myide(); overrides a built-in of the same name
40
- └── sync/ # intelligence-sync MODULE (upstream-owned)
41
- ├── INIT.md docs/ scripts/(+VERSION)
42
- ├── rules/intelligence-authoring.md # authoring discipline for this layer
43
- ├── agents/intelligence-architect.md # designs and prunes this layer
44
- ├── agents/intelligence-operator.md # runs sync, update, adapter flows
45
- └── skills/intelligence-* # meta-skills
46
- ```
47
-
48
- Everything project-authored lives at the umbrella level (`rules/ agents/ skills/ adapters/`); everything upstream-owned lives in the self-contained module `sync/`, updated independently via `sync/scripts/update.sh`. Additional modules (e.g. `domain/`) sit beside `sync/`. The umbrella folder name is derived at runtime as "the directory holding `config.yaml`" — never hardcoded. The `intelligence-` prefix is **reserved** for upstream artifacts; project rules, agents and skills must not use it (the updater prunes what matches it).
49
-
50
- The module ships three kinds of artifact, and `config.yaml` must list all three under `sources` for them to reach the IDEs — `<umbrella>/sync/rules`, `<umbrella>/sync/agents`, `<umbrella>/sync/skills`. INIT emits those entries on bootstrap; the `0.7.0` migration adds them to existing projects.
51
-
52
- ### Layout tokens in engine-shipped artifacts
53
-
54
- An artifact shipped *by the engine* cannot write the umbrella's name down — the project chooses it (`intelligence/`, `Intelligence/`, a codename). So engine artifacts spell it with tokens, and every adapter expands them on the way out (`finalize_output_file` in `lib/common.sh`):
55
-
56
- | Token | Expands to | Example |
57
- |---|---|---|
58
- | `<umbrella>` | repo-relative umbrella dir | `Intelligence` |
59
- | `<module>` | repo-relative engine module | `Intelligence/sync` (CLI setup: `.intelligence/packages/@ainova-systems/sync`) |
60
- | `<manifest>` | the project's config file, by name | vendored: `config.yaml`; CLI setup: `intelligence.yaml` |
61
- | `<sync-cmd>` | how a reader re-runs the sync | vendored: `bash Intelligence/sync/scripts/sync.sh`; CLI setup: `intelligence sync` |
62
-
63
- Expansion covers frontmatter and body alike, so `paths: ["<umbrella>/**"]` reaches Claude's `paths:`, Cursor's `globs:` and Copilot's `applyTo:` already carrying the project's real folder name. Project-authored artifacts may use the tokens too, but they have no reason to — they can simply name their own folders. `<sync-cmd>` exists because "run a sync" is spelled differently per setup: engine content says the token, and `IS_SYNC_CMD` (set by the CLI) picks the spelling; unset, it reproduces the vendored command string exactly.
64
-
65
- A custom adapter belongs in the umbrella's `adapters/`, never in the module's `sync/scripts/adapters/` — the module is replaced wholesale on every update, so an adapter written there disappears at the next one. See `docs/ADAPTERS.md`.
66
-
67
- Rule filenames, agent names, and skill names all share the same **domain prefix** (`backend-`, `frontend-`, `devops-`, `core-`, `tests-`, project codename, or monorepo component name). Pick the domain once from repo structure and reuse it — do not invent new domains without clear need.
68
-
69
- ### Packs (remote sources)
70
-
71
- A `sources.{rules,agents,skills}` entry is normally a **local path** relative to the repo root. It may instead reference a **pack** — a remote git repo that `sync` shallow-clones and treats exactly like a local source directory — so a team can keep shared intelligence in one repo and pull it into many projects.
72
-
73
- A pack is **declared once** under `packs:` and referenced by name from as many sections as need it:
74
-
75
- ```yaml
76
- packs:
77
- shared-intel:
78
- url: https://github.com/org/shared-intel.git
79
- ref: v1.2.0 # the pin — one place, not one per section
80
- mirror: "intelligence/external/shared-intel" # optional; see below
81
-
82
- sources:
83
- rules:
84
- - "intelligence/rules" # local
85
- - "@shared-intel/rules" # pack
86
- skills:
87
- - "@shared-intel/skills" # same pack, same clone, same pin
88
- ```
89
-
90
- Declaring the pack is what keeps the url and the ref in one place. Repeating them per section is how the two drift, and nothing catches it: rules pinned at one commit and skills at another is a config that looks fine and reads wrong.
91
-
92
- Reference format: `@<pack>[/<subpath>]`
93
-
94
- - `<pack>` — a key under `packs:`. It is a **reference handle, never a path component**, so it needs no sanitizing; it must simply contain no `/`.
95
- - `/<subpath>` — optional directory inside the pack repo holding the rules / agents / skills. Omit to use the repo root. The subpath is preserved in the mirror, so `@shared-intel/packs/core/rules` lands at `<mirror>/packs/core/rules`.
96
- - **An undeclared pack fails the run** (exit 1, naming the pack and listing the declared ones). This is deliberately unlike a missing local path, which only warns: the config claims to know that name, so a typo must not quietly drop a whole rule set.
97
-
98
- Pack fields:
99
-
100
- - `url:` — must carry an explicit scheme: `https://`, `http://`, `ssh://`, `git://`, or `file://`. Other transports (notably the command-executing `ext::` / `fd::`) are **rejected** with a warning and skipped.
101
- - `ref:` — optional tag, branch, or commit SHA. Omit for the default branch.
102
- - `mirror:` — optional; see [Mirroring a pack into the repo](#mirroring-a-pack-into-the-repo).
103
-
104
- #### Inline specs (`git+…`)
105
-
106
- A source entry may still carry the whole spec inline: `git+<url>[@<ref>][#<subpath>]`. This is an **anonymous pack** — it has no declared name and no mirror, so it is always transient and cannot be referenced from elsewhere. Declare the pack under `packs:` to pin it once or to commit it.
107
-
108
- The inline `@<ref>` is parsed as the segment after the last `@`, accepted as a ref only when it contains no `/` (so `ssh://git@host/...` userinfo is not mistaken for a ref). Branch names containing `/` (e.g. `feature/x`) can't be expressed this way — use `packs:` with a plain `ref:`, which has no such limit.
109
-
110
- Behavior and trust:
111
-
112
- - **Fresh every sync.** Each `sync` run clones into a run-scoped temp dir and removes it on exit, so branch refs always pick up the latest. Within one run the same `url@ref` is cloned only once, even when several entries (different subpaths) reference it.
113
- - **Reproducibility / supply chain.** A remote's content becomes rules, agents, and skills the LLM reads as project context. Pin to a tag or SHA so an upstream change can't silently alter behavior, and only reference repos you trust.
114
- - **Containment.** The clone can't be made to read outside itself: `..` in `#subpath` is refused, remote repos are checked out with `core.symlinks=false` (a hostile `skills -> /etc` link becomes an inert text file, not a path the copy step follows), and the resolved directory is verified to sit inside the clone.
115
- - **Line endings are the pack's, not the host's.** The clone pins `core.autocrlf=false` and `core.eol=lf`, so a pack that declares no `.gitattributes` still materializes the bytes it has stored. Without it, Git for Windows' `core.autocrlf=true` default would rewrite the checkout to CRLF and a `mirror:` — copied verbatim — would land CRLF in your repo, showing up as a whole-pack diff after every sync.
116
- - **Private repos** rely on ambient credentials (an SSH agent or git credential helper). `sync` runs git with `GIT_TERMINAL_PROMPT=0`, so a missing credential fails fast with a warning instead of hanging; local sources still sync.
117
- - **Best-effort.** A clone failure (offline, bad URL, missing subpath) warns on stderr and skips that one source — the rest of the sync proceeds and still reports `IS_STATUS=ok`.
118
-
119
- #### Mirroring a pack into the repo
120
-
121
- Without `mirror:` a pack exists only inside the run cache, so the only trace of an upstream change is a shifted diff in the *generated* output, mixed in with your own content. Give the pack a `mirror:` and it is additionally materialized there, which makes a version bump readable as an ordinary diff:
122
-
123
- ```yaml
124
- packs:
125
- shared-intel:
126
- url: https://github.com/org/shared-intel.git
127
- ref: v1.2.0
128
- mirror: "intelligence/external/shared-intel" # omit to keep the pack transient
129
- ```
130
-
131
- ```
132
- intelligence/external/
133
- └── shared-intel/ # the path you declared — nothing is derived
134
- ├── .pack # url + ref + resolved SHA, written by sync
135
- ├── rules/ # only the subpaths your sources reference
136
- └── skills/
137
- ```
138
-
139
- Commit that directory — being able to review `git diff` after bumping a pin is the entire point. `<umbrella>/external/<pack>` is the recommended location, but the value is a plain path, so packs can live wherever suits the repo, one per pack.
140
-
141
- - **The directory is declared, never derived.** `mirror:` says exactly where the pack goes, so there is no name to sanitize and no collision to resolve.
142
- - **`.pack` is output, not config.** sync writes it; nothing reads it as configuration and it is not meant to be hand-edited. The pin lives in `config.yaml`.
143
- - **Only the referenced subpaths are copied**, so a pack's `README`, CI config and tests never enter your repo. A reference with no subpath copies the whole repo.
144
- - **`.git` is never copied.** A nested repository would be recorded as a gitlink, whose contents git does not track — precisely the state this avoids.
145
- - **Cleared once per run.** The first entry to touch a pack clears its mirror, so content left by a previous ref (or by a source entry you have since deleted) does not linger; later entries only replace their own subpath.
146
- - **Never destructive.** The `.pack` stamp marks the directory as sync's to manage: a non-empty directory *without* one is left alone (with a warning) rather than deleted, so a directory of your own at that path is safe. A stamped directory stays the pack's even after you edit its `url:` — a moved or renamed upstream refreshes the mirror, which is the whole point of committing it. To hand a mirror path back to the project, delete the directory. A mirror that resolves to the repo root, escapes the repo, or sits inside a configured `sources.*` directory is refused outright — `sync` exits 1 before anything is written.
147
- - Mirrored files have committed paths, so `AGENTS.md` and the Pi adapter link to them like any local source instead of naming them bare. A transient pack has no such path and is still named bare.
148
-
149
- ## Agent Frontmatter
150
-
151
- ```yaml
152
- ---
153
- name: agent-name # Kebab-case identifier
154
- description: When to use this agent # Shown in IDE agent picker
155
- tier: heavy|standard|light # Model capability (tool-agnostic)
156
- access: full|readonly # Tool permissions (tool-agnostic)
157
- skills: # Optional: linked skills
158
- - skill-name-1
159
- - skill-name-2
160
- ---
161
-
162
- Agent instructions in markdown...
163
- ```
164
-
165
- ### An agent is thin — it never restates the rules
166
-
167
- Body sections: **Expertise** → **Boundaries** (where it stops) → **Build & Verify**. What belongs to the agent is its role, its limits, and how it proves the work is done.
168
-
169
- **Do not instruct an agent to read the rules.** They reach it on their own: Claude Code loads `.claude/rules/` into every custom subagent's startup context alongside `CLAUDE.md` (*Subagents → What loads at startup*), and Cursor, Copilot, Codex, Pi and opencode receive always-on rules inlined in `AGENTS.md`. A `Read intelligence/rules/<domain>.md before starting` line is duplication: it doubles the tokens and creates a second copy that drifts from the rule it copied. Point at a rule by name if you must; never restate it. The urge to copy a rule into an agent means the rule is in the wrong place — move it.
170
-
171
- ### Tier Mappings
172
-
173
- | Tier | Claude | Cursor | Copilot / Codex | opencode | Use for |
174
- |------|--------|--------|-----------------|----------|---------|
175
- | heavy | opus | (default) | gpt-5.6-sol | claude-opus-4-8 | Developers, complex reasoning, migration |
176
- | standard | sonnet | fast | gpt-5.6-terra | claude-sonnet-5 | Reviewers, validators, analysis |
177
- | light | haiku | fast | gpt-5.6-luna | claude-haiku-4-5 | Simple lookups, formatting |
178
-
179
- The vocabulary is tool-agnostic on purpose: the source says `tier: heavy`, and each adapter resolves it through `get_model()`. Defaults move forward as vendors ship new models — pin one per IDE/tier under `models:` in `config.yaml` only when you must, and expect a drift report on every sync once the default overtakes the pin.
180
-
181
- ### Access Mappings
182
-
183
- | Access | Claude | Cursor | Description |
184
- |--------|--------|--------|-------------|
185
- | full | (no `tools:` field - inherits every session tool, MCP servers included) | (default) | Full edit access |
186
- | readonly | tools: Read,Grep,Glob,Bash + disallowedTools: Write,Edit | readonly: true | Analysis only |
187
-
188
- ## Rule Frontmatter
189
-
190
- ```yaml
191
- ---
192
- paths: # Optional: path-based activation
193
- - "src/backend/**" # Glob patterns from repo root
194
- - "config/**"
195
- ---
196
-
197
- Rule content in markdown...
198
- ```
199
-
200
- - **With paths:** Rule auto-loads when user edits matching files
201
- - **Without paths:** Rule applies always (context rules)
202
-
203
- ### Sync Transformations (Rules)
204
-
205
- | Source | Claude | Cursor | Copilot | Codex / Pi / opencode / AGENTS.md |
206
- |--------|--------|--------|---------|------------------------|
207
- | `paths:` (scoped) | copied | `globs:` in `.mdc` | `applyTo:` in `.instructions.md` | listed in AGENTS.md; Pi also gets generated on-demand rule files + extension |
208
- | no `paths:` (always-on) | copied | skipped | skipped | inlined into AGENTS.md |
209
- | extension | `.md` | `.mdc` | `.instructions.md` | inline / generated extension / n/a |
210
-
211
- Always-on rule content is inlined once into AGENTS.md (which Cursor, Copilot, Codex, Pi, and opencode read natively); the per-IDE rule channels carry only path-scoped rules to preserve monorepo glob targeting without duplicating context. Claude Code does not read AGENTS.md, so its adapter receives the full rule set. opencode has no first-class path-scoped channel (users may opt in via `instructions:` globs in `opencode.json`), so the opencode adapter does not generate scoped-rule files.
212
-
213
- ## Skill Frontmatter
214
-
215
- Skills follow the [Agent Skills open standard](https://agentskills.io) (adopted by Claude Code, Cursor, GitHub Copilot, OpenAI Codex, Pi, Gemini CLI, OpenCode, Goose, Junie, and 30+ others). Required fields: `name` + `description`.
216
-
217
- ```yaml
218
- ---
219
- name: <domain>-<verb>-<noun> # e.g., backend-add-endpoint
220
- description: What the skill does # Shown in IDE skill picker
221
- argument-hint: <arg1> [arg2] # Optional: usage hint
222
- ---
223
-
224
- # Skill Title
225
-
226
- ## Steps
227
- 1. First step...
228
- 2. Second step...
229
- ```
230
-
231
- Standard optional fields (`license`, `compatibility`, `metadata`, `allowed-tools`) and IDE-specific extensions (Claude's `disable-model-invocation`, `model`, `effort`, `agent`, `context: fork`, `hooks`, `paths`, `shell`) pass through unchanged — adapters do not strip them. The engine's own flow skills declare `agent:` (`intelligence-review-skills` → `intelligence-architect`, the four sync/update/adapter flows → `intelligence-operator`); the binding takes effect where a tool honors it, and a skill invoked directly runs on the session model unless it also sets `context: fork`, as `intelligence-sync` does — the flows that can need the user mid-run (update, adapter install/removal) deliberately do not. Each tool ignores fields it does not understand.
232
-
233
- **Limits that reject the skill outright** (it does not degrade — it disappears from the picker):
234
-
235
- | Field | Limit | Failure |
236
- |---|---|---|
237
- | `description` | 1024 chars | *"Skill description must be at most 1024 characters"* |
238
- | `name` | 64 chars | rejected at load |
239
- | `argument-hint` | must be a **string** | `argument-hint: [pr-number]` is a YAML flow *sequence* unquoted → *"argument-hint must be a string"* |
240
-
241
- Sync quotes `description` and `argument-hint` for every target on the way out, so an unquoted hint is fixed automatically; the length limits it can only warn about (`lint_frontmatter` prints the file, line and actual length) — shortening the text is the author's call.
242
-
243
- ### Naming Conventions
244
-
245
- Skill names are `<domain>-<verb>-<noun>`. Both parts are required.
246
-
247
- **Domain prefix** (the scope — required, never omit):
248
-
249
- | Source | Domain |
250
- |--------|--------|
251
- | Single / root project | Project codename from `config.yaml` → `project.name` |
252
- | Backend service / API | `backend-` |
253
- | Frontend / web / UI | `frontend-` |
254
- | Infrastructure / IaC / CI/CD | `devops-` |
255
- | Shared library / common code | `core-` |
256
- | Test suites (e2e, integration) | `tests-` |
257
- | Monorepo named components | Component name (e.g., `billing-`, `auth-`) |
258
- | Tool-internal (intelligence-sync) | `intelligence-` |
259
-
260
- Reuse an existing domain whenever possible. Do not invent new domains without clear need.
261
-
262
- **Verb prefix** (the action):
263
-
264
- | Verb | Type | Description |
265
- |------|------|-------------|
266
- | `add-` | Append | Puts one new member into a set that already exists |
267
- | `create-` | Originate | Brings into existence the container nothing hosted before |
268
- | `update-` | Revise | Changes what is already there, selectively |
269
- | `run-` | Execution | Runs an operation (tests, sync, build) |
270
- | `review-` | Read-only | Analyzes code without changes |
271
- | `test-` | Testing | Manual or automated test verification |
272
- | `remove-` | Deletion | Safely removes an artifact |
273
-
274
- Agents follow the same domain prefix rule: `<domain>-<role>` (e.g., `backend-developer`, `frontend-code-reviewer`). Rule filenames use the domain without a verb: `<domain>.md` (e.g., `backend.md`).
275
-
276
- ### How much a skill body carries
277
-
278
- A skill that does the work itself carries the detail: the patterns, the code, the examples. A skill that dispatches to other skills stays thin — it names them and adds only what it alone knows (the discovery, the order, the check between steps), and it never restates their content, because two copies of a procedure disagree at the first edit.
279
-
280
- Which of the two a skill is has nothing to do with its verb. An `add-` skill may dispatch, and a `create-` skill may do the work itself: the verb answers what already existed (Verb prefix, above), not how the skill is built inside.
281
-
282
- ## Authoring Discipline
283
-
284
- ### Writing description fields
285
-
286
- Each skill, rule, and agent has a `description` field in frontmatter. This field is loaded into every IDE's available-skills context. **Total description tokens across all artifacts compete for a shared budget** — with a large registry, longer descriptions push other skills out of reach.
287
-
288
- Two cases:
289
-
290
- | Case | Format | Length target |
291
- |---|---|---|
292
- | **Unique skill** (no siblings doing similar action) | Plain verb-noun phrase | 4-8 words |
293
- | **Skill with siblings** (multiple similar skills in registry) | verb-noun + distinct trigger phrase | 10-20 words, ~250 chars |
294
-
295
- Two different numbers, do not confuse them: **~250 chars is the house budget** (what keeps the shared registry affordable), while **1024 chars is a wall** — Claude Code and the Agent Skills standard reject a longer `description` outright and the artifact disappears from the picker. Sync warns at the wall (`lint_frontmatter`); staying near the budget is the author's job.
296
-
297
- Examples:
298
-
299
- ```yaml
300
- # Unique skill — short is fine
301
- description: "Create new intelligence rule"
302
-
303
- # Sibling skill — needs distinguishing trigger
304
- description: "Run weekly check-up: retrospective + strategic analysis + next week planning"
305
- ```
306
-
307
- When the registry grows past comfortable budget, prefer **curation** (merge duplicates, archive orphans via `intelligence-review-skills`) over truncating descriptions individually.
308
-
309
- ### Size discipline — the backstop, not the goal
310
-
311
- The goal is **subtraction** (see the `intelligence-authoring` rule the engine ships): every line is loaded into someone's context out of a shared, finite budget, so the default answer to "should this be a rule?" is no. These caps are only the line past which something is definitely wrong.
312
-
313
- | Type | Hard cap | Over the cap |
314
- |---|---|---|
315
- | SKILL.md body | 1000 lines | Move detail into `references/<topic>.md` and point at it |
316
- | Reference file (`references/*.md`) | 500 lines | Add a table of contents past 300 lines |
317
- | Rule | 500 lines | Split by sub-scope, or move pattern detail to `references/` |
318
- | Agent | 200 lines | Refactor — agents stay thin; heavy content lives in skills and rules |
319
-
320
- **Ceilings, not quotas.** An artifact that says everything it needs to is finished, not underweight. Over the cap means it is doing two jobs, or the detail belongs behind a pointer: `Read references/<topic>.md when [condition].`
321
-
322
- Resource organization — **content lives inside the skill that uses it, by default**:
323
-
324
- ```
325
- skill-name/
326
- ├── SKILL.md (required)
327
- ├── references/ — Detailed docs, loaded on demand
328
- ├── scripts/ — Executable helpers for deterministic / repetitive steps
329
- └── assets/ — Files used in output (templates, fonts, icons)
330
- ```
331
-
332
- Sync copies the whole directory, so a bundled helper travels with its skill into every tool. **Promote a helper out of the skill folder only when a second skill needs it** — then it lives beside the source groups (e.g. `<umbrella>/scripts/`) and every skill resolves it the same way. The dividing line is reuse, not repetition: a helper one skill runs a hundred times still belongs to that skill.
333
-
334
- ### Writing principles
335
-
336
- Apply to skill bodies, rule bodies, and agent bodies — anywhere LLM-facing instructions are authored.
337
-
338
- **Use imperative form.** "Read the config file" works better than "You should read the config file."
339
-
340
- **Explain the WHY.** LLMs follow positive instructions better when reasoning is visible. "Use module boundaries — AI knows which imports are allowed without guessing" works better than "Use module boundaries (MUST)."
341
-
342
- **Reserve absolute language for true invariants.** ALL-CAPS MUSTs and NEVERs fit security, safety, output format — places where the constraint is non-negotiable. For judgment calls, write **decision rules** in positive form: "When X, do Y" instead of "NEVER do Z." If you find yourself writing ALWAYS or NEVER in all caps for a judgment call, that's a yellow flag — reframe and explain the reasoning.
343
-
344
- **Keep prompts lean.** Remove instructions that aren't pulling their weight. Padding wastes context and dilutes the instructions that matter.
345
-
346
- **Lead with positive defaults.** Rule body order: REQUIRED → Invariants → Architecture → Build & Test → Examples → Patterns to recognize and replace. The LLM acts on the positive instruction it reads first; anti-patterns sit at the end as reference documentation, not as instructions.
347
-
348
- **Bundle repeated patterns as scripts.** If the LLM reinvents the same helper on every invocation, encode it in `scripts/` and have the skill call it.
349
-
350
- ## Generated Output
351
-
352
- | Target | Rules output | Skills location | Agents location | Git-ignored |
353
- |--------|--------------|-----------------|-----------------|-------------|
354
- | `agents` | inlined into `AGENTS.md` (always-on); listed (scoped) | n/a | listed in `AGENTS.md` | No (committed) |
355
- | Claude Code | `.claude/rules/` (full) | `.claude/skills/` | `.claude/agents/` | Yes |
356
- | Cursor | `.cursor/rules/*.mdc` (scoped only) | `.cursor/skills/` | `.cursor/agents/` | Yes |
357
- | GitHub Copilot | `.github/instructions/*.instructions.md` (scoped only) | `.github/skills/` | `.github/agents/` | Partial |
358
- | OpenAI Codex | none (reads `AGENTS.md`) | `.agents/skills/` | `.codex/agents/*.toml` | Yes |
359
- | Pi | `.pi/intelligence-sync/rules/*.md` + `.pi/extensions/intelligence-sync-rules.ts` (scoped only; always-on via `AGENTS.md`) | `.agents/skills/` | `.pi/prompts/intelligence-agent-*.md` | Partial |
360
- | opencode | none (always-on via `AGENTS.md`; users may opt in to scoped rules via `instructions:` globs in `opencode.json`) | `.agents/skills/` | `.opencode/agents/*.md` (mode: subagent) | Yes |
361
-
362
- Skill locations all comply with the Agent Skills open standard. Cursor reads from `.cursor/skills/` and `.agents/skills/`; Copilot reads from `.github/skills/`, `.claude/skills/`, and `.agents/skills/`; Codex, Pi, and opencode all read from `.agents/skills/`; Claude Code reads from `.claude/skills/`.
363
-
364
- **Rule routing rationale:** AGENTS.md is canonical for Cursor/Copilot/Codex/Pi/opencode (all read it natively), so always-on rule content is inlined there once and the per-IDE rule directories carry only path-scoped rules — no duplication. Claude Code does not read AGENTS.md, so its adapter receives the full rule set.
365
-
366
- `AGENTS.md` is always enabled and regenerated on every sync. The static header (`targets.agents.header` in `config.yaml`) is the only hand-authored part; everything below it is rebuilt from frontmatter — agents/skills tables, the rules list, and the inlined content of every always-on rule (those without `paths:`). Path-scoped rules are listed by name only so AGENTS.md does not balloon in monorepos.
367
-
368
- ## Migration & Module Contract
369
-
370
- Structural changes to the module layout are handled by **versioned migrations**, not ad-hoc scripts or manual instructions. The model is designed for an *unbounded, uncoordinated* upgrade window — a project may sit on an old version indefinitely and still migrate safely whenever it finally runs.
371
-
372
- **Division of responsibility**
373
-
374
- - **Bash = deterministic, fail-closed core.** It performs only mechanically safe, reversible-until-committed steps and **never guesses**. Any state it cannot resolve safely is reported, not forced.
375
- - **`intelligence-update` skill = intelligent layer.** It detects project state, bootstraps the engine, runs bash, interprets the status, and resolves the cases bash refuses (asking the user when genuinely ambiguous).
376
-
377
- **The schema-version contract key.** The applied schema version is a managed, top-level scalar `sync_version` in `config.yaml` — *not* a dotfile, *not* `scripts/VERSION`. `config.yaml` is what most future breaking changes reshape, so the schema version lives with what it versions. **Invariant: this key is permanent and format-stable** — no migration may ever rename, move, or change its shape, so any engine (however old/new) can always read "what schema is this?" before parsing the rest. The bootstrap/INIT flow emits it for fresh projects (= engine `scripts/VERSION`) and must preserve it on re-bootstrap. `scripts/VERSION` = what the engine *is*; the key = what has been *applied*; the gap = pending breaking changes.
378
-
379
- **Every `migrate_to_<ver>` obeys this contract**
380
-
381
- 1. **Version-named & ordered.** Suffix is the target version (`migrate_to_0_3_1`); listed in `MIGRATIONS=()` ascending, append-only — never reorder or rewrite shipped migrations.
382
- 2. **Idempotent structural precondition is the correctness mechanism.** Each migration self-detects from the actual on-disk/config structure whether its change is already applied, and is a silent no-op if so. The dispatcher runs the whole chain in order; it does **not** gate on the version stamp — so a wrong/missing `sync_version` can never cause a needed migration to be skipped. Replaying any number of times never fails or duplicates.
383
- 3. **Transactional / fail-closed.** Stage → **verify postcondition (sentinel)** → commit → only then delete the old state. A crash or partial input leaves the prior state intact; nothing is destroyed before the replacement is verified.
384
- 4. **Version-compat guard.** A stale engine refuses to operate on a project whose `sync_version` is newer than it understands (`ahead-of-engine`). This is the *only* role of the stamp — a guard, never a gate.
385
- 5. **Status hand-off is first-class.** "Cannot safely automate" is a normal outcome, reported via the contract below — not an error to paper over.
386
-
387
- **Breaking-change releases carry a `### Breaking` CHANGELOG subsection**, each item stating its post-condition. The `intelligence-update` skill reads the changelog across the version gap, surfaces these, and verifies each post-condition after applying. `sync.sh` is a pure synchronizer — it never migrates; it fails closed (`needs-update`) across an un-applied gap so a stale engine can't generate against a newer schema. `update.sh` (+ the skill) is the sole migrator.
388
-
389
- **bash ↔ skill status contract** (codes are public; never renumber)
390
-
391
- | `IS_STATUS` | exit | Meaning |
392
- |---|---|---|
393
- | `ok` | 0 | Up to date / nothing to do |
394
- | `migrated` | 0 | Migration performed this run |
395
- | `error` | 1 | Generic failure (detail in message) |
396
- | `config-missing` | 2 | No `config.yaml` — project not bootstrapped |
397
- | `ambiguous` | 3 | Conflicting state; skill/human-only (bash never emits it) |
398
- | `ahead-of-engine` | 4 | Project schema newer than this engine |
399
- | `aborted-incomplete` | 5 | Staged module incomplete; prior state left intact |
400
- | `needs-update` | 6 | Pending breaking changes — run the update flow first |
401
-
402
- Bash emits `IS_STATUS=<code> [IS_DETAIL=...]` on stdout and exits with the matching code; callers capture it with `cmd || rc=$?` (never `if ! cmd; then exit $?` — that loses the code). The skill branches on the code.
403
-
404
- **Module model.** The engine self-locates by its own path; it does not assume a folder name (`sync/` by convention). Each `<umbrella>/<module>/` is self-contained: its own `scripts/`(+`VERSION`), `skills/`, `INIT.md`, `docs/`. Modules update independently and never touch sibling modules or project content (`rules/`, `agents/`, non-meta `skills/`) nor `config.yaml` beyond the idempotent additive `sources.skills` line and the `sync_version` key.
405
-
406
- **CLI mode (0.11.0+).** The `intelligence` CLI drives the same engine from outside the repo (the npm install dir); the project arrives through an env contract honored only when `IS_CLI=1` — with every variable unset the engine behaves byte-identically to the vendored flow (CI's `legacy-golden` job asserts that):
407
-
408
- | Variable | CLI-mode value |
409
- |---|---|
410
- | `CONFIG_FILE` | `<root>/intelligence.yaml` (the root manifest) |
411
- | `REPO_ROOT` | project root |
412
- | `IS_UMBRELLA_REL` / `IS_MODULE_REL` | content dir (default `intelligence`) / `.intelligence/packages/@ainova-systems/sync` |
413
- | `IS_MANIFEST_NAME` | `intelligence.yaml` — feeds the `<manifest>` token (vendored default: `config.yaml`) |
414
- | `IS_SYNC_CMD` | `intelligence sync` (feeds the `<sync-cmd>` token) |
415
- | `IS_PROTECTED_DIRS` | colon-separated dirs `validate_output_path` must refuse — restores the source-tree protection a root manifest would otherwise disable |
416
- | `IS_SUPPRESS_CLI_NOTE` | silences the vendored-flow recommendation NOTE (stderr-only either way) |
417
-
418
- In CLI projects the engine's content is the `@ainova-systems/sync` package (auto-added by `init`, pinned to the engine version, moved only by `intelligence upgrade`), so **every** meta-skill ships in both modes: `intelligence-sync` runs `<sync-cmd>` wherever it lands, and `intelligence-update` self-redirects to `intelligence upgrade` when it finds a root `intelligence.yaml`. `sync.sh` in CLI mode still never migrates: an outdated stamp exits `needs-update` and the CLI's own `upgrade` closes the gap. See `docs/CLI.md` for the full CLI surface.
419
-
420
- ## .gitignore Pattern
421
-
422
- ```
423
- # AI IDE tools (generated by intelligence-sync, local preferences)
424
- CLAUDE.md
425
- .cursorrules
426
- .agents/
427
- .codex/
428
- .pi/intelligence-sync/
429
- .pi/extensions/intelligence-sync-rules.ts
430
- .pi/prompts/intelligence-agent-*.md
431
-
432
- # opencode: the generated subagents and slash commands are owned by the adapter.
433
- # .opencode/opencode.json (and any other hand-authored config) stays tracked.
434
- .opencode/agents/
435
- .opencode/commands/
436
-
437
- # Claude Code: ignore everything except project-shared settings.
438
- .claude/*
439
- !.claude/settings.json
440
-
441
- # Cursor: same pattern.
442
- .cursor/*
443
- !.cursor/settings.json
444
- ```
445
-
446
- The inverse pattern (`.claude/*` + `!.claude/settings.json`) ignores every generated subdir (`rules/`, `skills/`, `agents/`) plus any per-machine state Claude writes (`settings.local.json`, `*.lock`, `scheduled_tasks.*`, `sessions/`, `cache/`, etc.) without having to enumerate filenames Claude may add later. Only `.claude/settings.json` (project-shared bash allowlist, tool permissions) is tracked. Same logic for `.cursor/`. Pi and opencode are narrower: only the generated adapter-owned paths are ignored (`.pi/intelligence-sync/`, `.pi/extensions/intelligence-sync-rules.ts`, `.pi/prompts/intelligence-agent-*.md`, `.opencode/agents/`, `.opencode/commands/`), so `.pi/settings.json`, `.opencode/opencode.json`, and any hand-authored Pi extensions/prompts remain available for tracking. The opencode adapter additionally protects hand-authored slash commands by an emit-marker (`<!-- Generated by intelligence-sync. Do not edit manually. -->`): re-sync only deletes marker-bearing files in `.opencode/commands/`, so a project may track a hand-authored command alongside the generated ones (typically by un-ignoring it). If a project needs to track another file under `.claude/` or `.cursor/` (e.g., a hand-authored `.claude/commands/<name>.md`), add another `!<path>` line.
447
-
448
- ## Project Entry Points
449
-
450
- | File | Role | Git status |
451
- |------|------|-----------|
452
- | `AGENTS.md` | Auto-generated canonical project doc for LLMs (do not edit manually) | Tracked |
453
- | `CLAUDE.md` | Local user preferences (gitignored) | Ignored |
454
- | `<umbrella>/config.yaml` | Sync config + `sync_version` schema-version contract key (committed) | Tracked |
455
- | `<umbrella>/{rules,agents,skills}/` | Project source of truth | Tracked |
456
- | `<umbrella>/sync/` | intelligence-sync module (engine+`scripts/VERSION`, meta-skills, INIT, docs) — vendored upstream-owned | Tracked |
@@ -1 +0,0 @@
1
- 3a5cd174c73bd3918ac0a01df8d54a6f3d98b485
@@ -1,51 +0,0 @@
1
- #!/bin/bash
2
- # shellcheck disable=SC2034 # LS_* are this lib's public API, consumed by the scripts that source it
3
- # intelligence-sync: layout detection
4
- # Source this file — never execute directly.
5
- #
6
- # The intelligence umbrella folder name is NOT hardcoded. It is whatever
7
- # directory holds config.yaml — `intelligence/`, `Intelligence/`, `prompts/`,
8
- # anything. The only fixed name is the module's own subfolder (`sync`), which
9
- # is the module's identity, not the project's choice.
10
- #
11
- # Two layouts exist during the 0.3.x transition:
12
- # legacy : <umbrella>/scripts/ (config.yaml at <umbrella>/config.yaml)
13
- # modular : <umbrella>/sync/scripts/ (config.yaml at <umbrella>/config.yaml)
14
- #
15
- # detect_layout sets these globals:
16
- # LS_LAYOUT legacy | modular | unknown
17
- # LS_MODULE_DIR dir that contains scripts/ (legacy: == umbrella; modular: <umbrella>/<module>)
18
- # LS_MODULE_NAME basename of LS_MODULE_DIR — messages only, never branched on
19
- # LS_UMBRELLA_DIR dir that holds (or will hold) config.yaml + project content
20
- # LS_CONFIG_FILE absolute path to config.yaml, or "" if none found yet
21
-
22
- # detect_layout <scripts_dir>
23
- detect_layout() {
24
- local scripts_dir="$1"
25
- local module_dir
26
- module_dir="$(cd "$scripts_dir/.." && pwd)"
27
-
28
- if [ -f "$module_dir/../config.yaml" ]; then
29
- # <umbrella>/<module>/scripts — umbrella is two levels up.
30
- LS_LAYOUT="modular"
31
- LS_UMBRELLA_DIR="$(cd "$module_dir/.." && pwd)"
32
- elif [ -f "$module_dir/config.yaml" ]; then
33
- # <umbrella>/scripts — flat pre-0.3.1 layout.
34
- LS_LAYOUT="legacy"
35
- LS_UMBRELLA_DIR="$module_dir"
36
- else
37
- # No config.yaml yet (upstream repo template, or pre-bootstrap).
38
- # Assume the umbrella is the module's parent; callers that need a
39
- # config will error out with their own message.
40
- LS_LAYOUT="unknown"
41
- LS_UMBRELLA_DIR="$(cd "$module_dir/.." && pwd)"
42
- fi
43
-
44
- LS_MODULE_DIR="$module_dir"
45
- LS_MODULE_NAME="$(basename "$module_dir")" # messages only
46
- if [ -f "$LS_UMBRELLA_DIR/config.yaml" ]; then
47
- LS_CONFIG_FILE="$LS_UMBRELLA_DIR/config.yaml"
48
- else
49
- LS_CONFIG_FILE=""
50
- fi
51
- }