@ainova-systems/intelligence 0.11.0-rc.9 → 0.11.0

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 (46) hide show
  1. package/cli/commands/adapter.sh +46 -6
  2. package/cli/commands/init.sh +138 -33
  3. package/cli/commands/package.sh +2 -2
  4. package/cli/commands/registry.sh +3 -3
  5. package/cli/commands/status.sh +4 -4
  6. package/cli/commands/sync.sh +76 -23
  7. package/cli/commands/update.sh +1 -1
  8. package/cli/intelligence +18 -3
  9. package/cli/internal/{upgrade-v2.sh → align-project.sh} +9 -8
  10. package/cli/internal/check.sh +42 -2
  11. package/cli/internal/{migrate-v1.sh → convert-legacy.sh} +33 -29
  12. package/cli/internal/package-add.sh +1 -1
  13. package/cli/internal/package-list.sh +1 -1
  14. package/cli/internal/package-remove.sh +1 -1
  15. package/cli/internal/package-search.sh +1 -1
  16. package/cli/internal/package-update.sh +1 -1
  17. package/cli/internal/restore.sh +1 -1
  18. package/cli/internal/target-state.sh +26 -18
  19. package/cli/lib/adapter-lifecycle.sh +33 -0
  20. package/cli/lib/cli-common.sh +12 -8
  21. package/cli/lib/gitignore.sh +174 -0
  22. package/cli/lib/manifest.sh +35 -1
  23. package/cli/lib/onboarding.sh +63 -0
  24. package/engine/ENGINE_SHA +1 -1
  25. package/engine/adapters/_template.sh +19 -2
  26. package/engine/adapters/agents.sh +14 -3
  27. package/engine/adapters/claude.sh +15 -0
  28. package/engine/adapters/codex.sh +11 -1
  29. package/engine/adapters/copilot.sh +11 -0
  30. package/engine/adapters/cursor.sh +15 -0
  31. package/engine/adapters/opencode.sh +11 -0
  32. package/engine/adapters/pi.sh +18 -5
  33. package/engine/lib/adapter-contract.sh +100 -0
  34. package/engine/lib/common.sh +5 -0
  35. package/engine/lib/contract.sh +2 -2
  36. package/engine/sync.sh +87 -25
  37. package/package.json +1 -1
  38. package/packages/sync/agents/intelligence-architect.md +2 -2
  39. package/packages/sync/references/adapters.md +51 -7
  40. package/packages/sync/references/conventions.md +55 -20
  41. package/packages/sync/references/onboarding-migration.md +79 -0
  42. package/packages/sync/skills/intelligence-install-adapter/SKILL.md +12 -5
  43. package/packages/sync/skills/intelligence-learn-from-context/SKILL.md +23 -4
  44. package/packages/sync/skills/intelligence-learn-from-repository/SKILL.md +90 -38
  45. package/packages/sync/skills/intelligence-review-skills/SKILL.md +1 -1
  46. package/packages/sync/skills/intelligence-sync/SKILL.md +1 -1
@@ -42,14 +42,25 @@ To stop syncing a target:
42
42
  intelligence adapter disable mytool
43
43
  ```
44
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.
45
+ Disabling changes only target state. Generated output is deliberately kept so disabling is reversible; the adapter contract identifies its paths for review. 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
46
 
47
- ## Required function
47
+ ## Required interface
48
48
 
49
- The file name and function name form the adapter's identity:
49
+ The file name, contract function and sync function form the adapter's identity:
50
50
 
51
51
  ```bash
52
52
  # <content-dir>/adapters/mytool.sh
53
+ adapter_contract_mytool() {
54
+ local output="${1%/}"
55
+ adapter_contract_version 1
56
+ adapter_contract_owned "$output/rules"
57
+ adapter_contract_owned "$output/agents"
58
+ adapter_contract_owned "$output/skills"
59
+ adapter_contract_ignore "$output/rules/"
60
+ adapter_contract_ignore "$output/agents/"
61
+ adapter_contract_ignore "$output/skills/"
62
+ }
63
+
53
64
  sync_to_mytool() {
54
65
  local repo_root="$1"
55
66
  local config_file="$2"
@@ -59,6 +70,30 @@ sync_to_mytool() {
59
70
  }
60
71
  ```
61
72
 
73
+ The contract accepts the configured repo-relative output path and emits only
74
+ records through these helpers:
75
+
76
+ | Record | Meaning |
77
+ |---|---|
78
+ | `adapter_contract_version 1` | Required interface version |
79
+ | `adapter_contract_requires <name>` | Another target that must be enabled for a full sync |
80
+ | `adapter_contract_owned <path>` | Path exclusively regenerated by this adapter |
81
+ | `adapter_contract_managed <path>` | Shared or marker-managed path modified by this adapter |
82
+ | `adapter_contract_legacy <path>` | Pre-Intelligence input preserved in the initial backup |
83
+ | `adapter_contract_preserve <path>` | Settings or state preserved in place and included in the initial backup |
84
+ | `adapter_contract_ignore <pattern>` | Exact `.gitignore` pattern managed on enable/init |
85
+ | `adapter_contract_include <pattern>` | Exact negated `.gitignore` pattern managed on enable/init |
86
+
87
+ All paths are repository-relative. The CLI refuses missing, malformed, unsafe,
88
+ or unsupported contracts before enabling or syncing an adapter. `owned` and
89
+ `managed` paths form the transactional write-set: if any adapter fails, the
90
+ engine restores every selected adapter path to its pre-sync state.
91
+
92
+ For an existing `.vscodeignore`, `.npmignore`, or `.dockerignore`, enable/init
93
+ also excludes the configured adapter output plus its `owned`, `managed`, and
94
+ `legacy` paths from published or build artifacts. This packaging policy is
95
+ separate from the narrower Git policy expressed by `ignore` and `include`.
96
+
62
97
  The engine calls:
63
98
 
64
99
  ```text
@@ -162,7 +197,7 @@ Built-ins currently emit Claude and Cursor Markdown, Copilot `.agent.md`, Codex
162
197
 
163
198
  Content shipped in `@ainova-systems/sync` cannot assume the project's content-directory name or package-store location. It uses these tokens:
164
199
 
165
- | Token | v2 expansion |
200
+ | Token | Expansion |
166
201
  |---|---|
167
202
  | `<content-dir>` | Project content directory, usually `intelligence` |
168
203
  | `<module>` | Installed sync package, usually `.intelligence/packages/@ainova-systems/sync` |
@@ -177,8 +212,8 @@ Call `finalize_output_file` on every text file after transformation. It expands
177
212
 
178
213
  Adapters regenerate output, so cleanup is part of their public contract.
179
214
 
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.
215
+ 1. Delete only paths declared `owned`. Preserve sibling settings, commands, extensions, workflows and hand-authored files.
216
+ 2. Keep `adapter_contract_<name>()` exactly aligned with every path `sync_to_<name>()` writes or deletes.
182
217
  3. Use marker-based cleanup when generated and hand-authored files share a directory. The OpenCode adapter is the reference implementation.
183
218
  4. Use `sync_open_skill_dirs` for `.agents/skills/`; multiple adapters share it.
184
219
  5. Write only beneath the supplied `output_dir`, except for an explicitly shared standard path handled by a shared helper.
@@ -211,6 +246,13 @@ sync_mytool_rules() {
211
246
  done < <(read_yaml_list "$config_file" "rules")
212
247
  }
213
248
 
249
+ adapter_contract_mytool() {
250
+ local output="${1%/}"
251
+ adapter_contract_version 1
252
+ adapter_contract_owned "$output/rules"
253
+ adapter_contract_ignore "$output/rules/"
254
+ }
255
+
214
256
  sync_to_mytool() {
215
257
  local repo_root="$1" config_file="$2" output_dir="$3"
216
258
 
@@ -221,7 +263,7 @@ sync_to_mytool() {
221
263
 
222
264
  ## Testing
223
265
 
224
- Use a disposable Git repository with a v2 manifest and representative always-on/scoped rules, agents, skills and bundled skill resources.
266
+ Use a disposable Git repository with an Intelligence manifest and representative always-on/scoped rules, agents, skills and bundled skill resources.
225
267
 
226
268
  ```bash
227
269
  intelligence sync mytool
@@ -234,6 +276,8 @@ Verify:
234
276
  - skill resources are present;
235
277
  - no literal layout tokens remain;
236
278
  - hand-authored siblings under the tool root survive;
279
+ - a deliberately failing later adapter restores all earlier output byte-for-byte;
280
+ - `intelligence status --check` accepts the contract and its Git policy;
237
281
  - output paths cannot overlap sources or escape the repository;
238
282
  - a second sync produces no Git diff.
239
283
 
@@ -18,7 +18,7 @@ Use these tests:
18
18
 
19
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
20
 
21
- ## v2 project structure
21
+ ## Intelligence project structure
22
22
 
23
23
  ```text
24
24
  project/
@@ -104,7 +104,7 @@ Commit `intelligence.lock`. It records requested versions, source URLs and paths
104
104
 
105
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
106
 
107
- | Token | v2 expansion |
107
+ | Token | Expansion |
108
108
  |---|---|
109
109
  | `<content-dir>` | Repo-relative content directory, usually `intelligence` |
110
110
  | `<module>` | Installed sync package, usually `.intelligence/packages/@ainova-systems/sync` |
@@ -283,7 +283,7 @@ Size limits are backstops, not quotas:
283
283
 
284
284
  Every line enters a finite context budget. Prefer subtraction, consolidation and precise scope over exhaustive prose.
285
285
 
286
- ## Generated output
286
+ ## Generated output and version control
287
287
 
288
288
  | Target | Rules | Skills | Agents |
289
289
  |---|---|---|---|
@@ -297,22 +297,24 @@ Every line enters a finite context budget. Prefer subtraction, consolidation and
297
297
 
298
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
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:
300
+ By default, commit the manifest, lock, project-owned content, `AGENTS.md`, and shared `.github/` output. Ignore the restorable package store and tool output owned by enabled adapters. `intelligence init` and `intelligence adapter enable` add these patterns without ignoring shared tool roots or settings:
301
301
 
302
302
  ```gitignore
303
303
  # CLI-managed package store
304
304
  .intelligence/
305
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/
306
+ # Local root instructions migrate into project rules; local preferences stay ignored
307
+ CLAUDE.md
308
+ .cursorrules
309
+
310
+ # Generated Claude and Cursor content; shared settings remain trackable
311
+ .claude/*
312
+ !.claude/settings.json
313
+ .cursor/*
314
+ !.cursor/settings.json
313
315
 
314
316
  # Generated open-standard and Codex content
315
- .agents/
317
+ .agents/skills/
316
318
  .codex/agents/
317
319
 
318
320
  # Generated Pi content
@@ -320,12 +322,45 @@ Generated IDE output may be gitignored when every collaborator can reproduce it
320
322
  .pi/extensions/intelligence-sync-rules.ts
321
323
  .pi/prompts/intelligence-agent-*.md
322
324
 
323
- # Generated OpenCode agents. Its commands directory may also contain
324
- # hand-authored files, so choose per-project ignores there.
325
+ # Generated OpenCode agents. Commands share a directory with hand-authored
326
+ # files, so they remain tracked unless the project chooses exact file ignores.
325
327
  .opencode/agents/
326
328
  ```
327
329
 
328
- Copilot output lives under `.github/`; choose whether to commit it with other repository-level GitHub configuration. Do not ignore `.github/` wholesale.
330
+ Copilot output lives under `.github/` and is committed with other repository-level GitHub configuration. Do not ignore `.github/` wholesale. `AGENTS.md` is also committed so every clone has the shared tool-neutral entry point before sync.
331
+
332
+ Git tracking and release packaging are separate policies. When a project
333
+ already has `.vscodeignore`, `.npmignore`, or `.dockerignore`, the CLI appends a
334
+ small idempotent block excluding the package store, `intelligence.yaml`,
335
+ `intelligence.lock`, the complete project content directory, and enabled
336
+ adapter output. Existing entries remain untouched and absent secondary ignore
337
+ files are not created.
338
+
339
+ An ignore rule does not untrack a file already in Git. After init or adapter
340
+ enable, the CLI reports each affected tracked path with an exact
341
+ `git rm --cached -- '<path>'` command; this preserves the local file while
342
+ removing it from the index.
343
+
344
+ Before release, inspect the packager's actual file list. An npm `files`
345
+ allowlist can force inclusion despite `.npmignore`, and a Dockerfile-specific
346
+ `<name>.Dockerfile.dockerignore` takes precedence over the root
347
+ `.dockerignore`. Use the relevant pack/list command as the final proof rather
348
+ than inferring contents from Git status.
349
+
350
+ `AGENTS.md` is the only shared root instruction entry point. During onboarding,
351
+ move useful repository guidance from legacy root files such as `.cursorrules`
352
+ and instruction-bearing `CLAUDE.md` into project-owned rules, verify the
353
+ generated tool output, then remove the legacy file. Keep a root tool-specific
354
+ file only when it contains genuinely local configuration that an adapter cannot
355
+ represent; keep that exception gitignored rather than maintaining a second
356
+ committed instruction source.
357
+
358
+ Before the first render, `intelligence init` preserves existing AI prompt paths
359
+ under `<content-dir>/_backup/`. Its `manifest.tsv` labels the snapshot
360
+ `initial-onboarding` and lists exact original paths. The context-learning skill
361
+ first recovers or verifies CLI setup, then routes that state through
362
+ `onboarding-migration.md` and repository learning. The backup remains until the
363
+ user approves removal.
329
364
 
330
365
  ## Project-owned adapters
331
366
 
@@ -337,7 +372,7 @@ intelligence adapter create mytool
337
372
  intelligence adapter enable mytool
338
373
  ```
339
374
 
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.
375
+ Project adapters survive CLI upgrades and may override a built-in by name. Each adapter declares a versioned ownership contract beside its sync function; backup, rollback, dependencies and Git policy all consume it. `intelligence adapter enable mytool` runs a full transactional sync so shared context stays current. `intelligence adapter disable mytool` keeps generated output for explicit cleanup; a disabled project adapter can then be deleted with `intelligence adapter remove mytool`. See `adapters.md` for the interface and safety contract.
341
376
 
342
377
  ## Schema and command boundaries
343
378
 
@@ -345,14 +380,14 @@ The permanent applied-schema key is the top-level scalar `schema_version` in `in
345
380
 
346
381
  The public lifecycle is deliberately compact:
347
382
 
348
- - `intelligence init [--preview|--apply]` is universal: it creates a new setup, aligns an existing v2 project, or plans/applies conversion of an eligible v1 project.
349
- - `intelligence sync [adapter]` first aligns an existing v2 project with the installed CLI, restores a missing store strictly from `intelligence.lock`, then renders. In CI it refuses an upgrade that would change tracked files and points to a local `intelligence init --apply` plus review/commit.
383
+ - `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.
384
+ - `intelligence sync [adapter] [--compact]` first aligns an existing Intelligence project with the installed CLI, restores a missing store strictly from `intelligence.lock`, then renders. Compact mode shows only final status on success and all diagnostics on failure. In CI it refuses an alignment that would change tracked files and points to a local `intelligence init --apply` plus review/commit.
350
385
  - `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
386
  - `intelligence package add|remove|list|search` owns package inventory.
352
387
  - `intelligence adapter list|create|enable|disable|remove` owns adapter inventory and target state.
353
388
  - `intelligence status [--check]` reports state; `--check` runs deep consistency checks.
354
389
 
355
- Implement v2 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 v2 entry points close a behind-project gap through lifecycle preflight.
390
+ 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
391
 
357
392
  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
393
 
@@ -382,4 +417,4 @@ Callers capture the real code with `command || rc=$?`. Do not use `if ! command;
382
417
  | `<content-dir>/{rules,agents,skills,adapters}/` | Project source of truth | Tracked |
383
418
  | `.intelligence/` | Restorable package store | Ignored |
384
419
  | `AGENTS.md` | Generated canonical project context | Normally tracked |
385
- | Tool output directories | Generated native content | Project policy; use narrow ignores |
420
+ | Tool output directories | Generated native content | Built-in adapter-owned paths ignored; shared settings tracked |
@@ -0,0 +1,79 @@
1
+ # Migrating Existing AI Instructions
2
+
3
+ Read this reference only when repository onboarding finds pre-existing AI
4
+ instructions, an `<content-dir>/_backup/` created by `intelligence init`, or a
5
+ Git diff showing that the first sync replaced tracked tool output.
6
+
7
+ ## Inventory and recovery
8
+
9
+ When `<content-dir>/_backup/manifest.tsv` contains
10
+ `state<TAB>initial-onboarding`, it is the authoritative inventory from before
11
+ the first generated write. Read each `target` and `path` record before looking
12
+ at current adapter output. If `path<TAB>AGENTS.md` is present, the backed-up
13
+ file is the original custom project contract; keep following it while deciding
14
+ how to migrate its durable guidance.
15
+
16
+ Treat these as migration inputs, not as current generated output:
17
+
18
+ - root `AGENTS.md`, `CLAUDE.md`, `.cursorrules`, and
19
+ `.github/copilot-instructions.md`;
20
+ - Claude and Cursor rules, agents, skills, and commands;
21
+ - Copilot instructions, prompts, agents, and skills;
22
+ - Codex/Open Agent Skills, Pi rules/prompts, and OpenCode agents/commands;
23
+ - scripts or documentation that describe an older sync path.
24
+
25
+ Prefer the copy under `<content-dir>/_backup/`. If it is absent and the first
26
+ sync changed tracked files, inspect their pre-sync content read-only through
27
+ Git (`git diff` and `git show HEAD:<path>`). Never restore old content directly
28
+ into an adapter output directory.
29
+
30
+ Build one conflict report before proposing changes:
31
+
32
+ - `MIGRATE`: instruction-bearing files whose useful content needs a
33
+ project-owned destination;
34
+ - `PRESERVE`: settings and unrelated shared files the adapters do not own;
35
+ - `REPLACE`: adapter-owned paths that sync regenerates;
36
+ - `STALE`: references to removed paths or commands requiring a decision.
37
+
38
+ Always preserve `.claude/settings.json`, `.claude/settings.local.json`,
39
+ `.cursor/settings.json`, Git metadata, workflows, and non-AI repository files.
40
+
41
+ ## Reverse mappings
42
+
43
+ Migrate meaning, not tool syntax:
44
+
45
+ | Existing format | Project-owned destination |
46
+ |---|---|
47
+ | Root `AGENTS.md`, `CLAUDE.md`, `.cursorrules`, Copilot root instructions | Split verified guidance by topic into rules; keep local machine preferences in a gitignored root file only when no adapter representation exists |
48
+ | `.claude/rules/*.md` | Rule; preserve valid `paths:` |
49
+ | `.cursor/rules/*.mdc` | Rule; rename `globs:` to `paths:` and remove `alwaysApply:` |
50
+ | Claude/Cursor/Copilot agents | Agent; map native model/readonly/tool fields back to `tier:` and `access:` |
51
+ | Claude/Cursor/Copilot skills or commands | Skill when the procedure is repeated, multi-step, stable, and verifiable; otherwise a rule or no artifact |
52
+ | Pi/OpenCode/Codex prompt artifacts | Rule, agent, or skill according to responsibility, after removing tool-specific wrappers |
53
+
54
+ Verify every retained claim against repository code or executable
55
+ configuration. Do not preserve stale instructions merely because they existed.
56
+ Prefer updating an existing project-owned artifact to creating a sibling.
57
+
58
+ ## Apply and cleanup
59
+
60
+ Obtain approval per `CREATE`, `UPDATE`, `REMOVE`, or `KEEP` proposal. Apply
61
+ project-owned source changes first, then run `intelligence sync` and
62
+ `intelligence status --check`. Inspect the enabled targets to prove the
63
+ migrated guidance arrived before removing old root instructions or tool files.
64
+
65
+ For every removed or renamed path, search all tracked files with `git ls-files`
66
+ and report remaining references with file and line number. Apply an unambiguous
67
+ replacement directly; ask about narrative or otherwise ambiguous references.
68
+
69
+ The CLI owns generated-output `.gitignore` entries and its blocks in existing
70
+ `.vscodeignore`, `.npmignore`, and `.dockerignore` files. Verify them against
71
+ the enabled adapters. Treat CLI-reported tracked ignored paths as unresolved
72
+ until the user approves the exact `git rm --cached` commands. Preserve
73
+ `AGENTS.md`, `.github/`, shared settings, and unrelated files under shared tool
74
+ roots in Git, while excluding development-only Intelligence content from
75
+ published artifacts. Inspect the packager's actual file list before release;
76
+ do not infer package or Docker context contents from Git status.
77
+
78
+ Keep `<content-dir>/_backup/` until the user separately approves its removal
79
+ after migration and reference checks pass. The backup remains gitignored.
@@ -22,17 +22,24 @@ rules, agents, and skills.
22
22
  agents, skills, and whether it reads `AGENTS.md`. Record links and separate
23
23
  verified behavior from assumptions.
24
24
 
25
- 3. Run `intelligence adapter create $ARGUMENTS`, then implement
26
- `sync_to_$ARGUMENTS()` in the scaffolded project adapter. Follow
25
+ 3. Run `intelligence adapter create $ARGUMENTS`, then keep
26
+ `adapter_contract_$ARGUMENTS()` aligned with every path the adapter writes
27
+ and implement `sync_to_$ARGUMENTS()` in the scaffolded project adapter. Follow
27
28
  `<module>/references/adapters.md` and the closest built-in. Keep writes beneath
28
- the configured output, make reruns idempotent, and make owned cleanup paths
29
- explicit. Ignore only those owned paths; shared roots remain trackable.
29
+ the configured output, make reruns idempotent, distinguish exclusive
30
+ `owned` paths from marker-based/shared `managed` paths, and declare exact
31
+ legacy, preserved, dependency, ignore, and include records when applicable.
30
32
 
31
33
  4. Run `bash -n` on the project adapter, then
32
34
  `intelligence adapter enable $ARGUMENTS`. If the CLI says the adapter
33
35
  requires `agents`, enable that adapter first.
34
36
 
37
+ The CLI derives generated-output ignores from the adapter contract. Do not
38
+ edit `.gitignore` manually; correct the contract when policy is wrong, and
39
+ never ignore a shared output root.
40
+
35
41
  5. Require `IS_STATUS=ok`, inspect generated files against the researched
36
- format, run the tool's validator when one exists, and finish with
42
+ format, deliberately fail a later test adapter to prove transactional
43
+ rollback when contributing a built-in, run the tool's validator when one exists, and finish with
37
44
  `intelligence status --check`. Report evidence, output paths, and any
38
45
  unsupported artifact type.
@@ -1,12 +1,29 @@
1
1
  ---
2
2
  name: intelligence-learn-from-context
3
- description: "Capture session lessons and apply to intelligence/ after approval"
4
- argument-hint: <optional-lesson-statement>
3
+ description: "Capture one approved lesson from a session in an established Intelligence project"
5
4
  ---
6
5
 
7
6
  # Learn from Context
8
7
 
9
- Use after a session where a meaningful preference, working pattern, or recurring friction emerged that should persist into future sessions. Runs in two phases — analyze (read-only) then apply (after user approval).
8
+ Use after repository onboarding is complete and a meaningful preference,
9
+ working pattern, or recurring friction emerged during the current session and
10
+ should persist. It runs analyze (read-only), then apply after approval. This
11
+ skill extends an established project; it does not perform first-run repository
12
+ analysis or migrate legacy instructions.
13
+
14
+ ## Onboarding gate
15
+
16
+ 1. Locate `<manifest>`, `<content-dir>`, and `<module>`, then run
17
+ `intelligence status --check`.
18
+ 2. If setup is missing or inconsistent, stop and ask the user to repair it with
19
+ `intelligence init`; then use `/intelligence-learn-from-repository`. Do not
20
+ reproduce CLI mechanics.
21
+ 3. If the generated header says onboarding is pending, or preserved legacy
22
+ evidence still has unresolved instructions, stop and route to
23
+ `/intelligence-learn-from-repository`. A retained
24
+ `<content-dir>/_backup/manifest.tsv` or converted legacy config alone does
25
+ not mean onboarding is incomplete; those may remain as intentionally kept
26
+ evidence after the transitional header and conflicts are resolved.
10
27
 
11
28
  ## Principle: positive framing
12
29
 
@@ -60,10 +77,12 @@ Present the proposal list to the user. User accepts or rejects per item. Only ac
60
77
  - `UPDATE` existing artifact → edit the file directly, applying the proposed change
61
78
  - `ARCHIVE` → move to `<content-dir>/_archive/` and update cross-references that point at it
62
79
 
63
- 8. **Run `/intelligence-sync`** once all accepted items are applied.
80
+ 8. Run `intelligence sync` once all accepted items are applied. Require
81
+ `IS_STATUS=ok`, then run `intelligence status --check`.
64
82
 
65
83
  ## Related skills
66
84
 
85
+ - `intelligence-learn-from-repository` — first-run onboarding and legacy instruction migration; use it before this skill
67
86
  - `intelligence-extract-skill` — when the lesson is a multi-step workflow to be made reusable
68
87
  - `intelligence-review-skills` — broader audit across existing intelligence/ artifacts
69
88
  - `intelligence-add-rule`, `intelligence-add-skill`, `intelligence-add-agent` — each authors one artifact; Phase B delegates to them
@@ -1,55 +1,107 @@
1
1
  ---
2
2
  name: intelligence-learn-from-repository
3
- description: "Tailor Intelligence to an initialized repository"
3
+ description: "Recover and complete first-time Intelligence repository onboarding"
4
4
  ---
5
5
 
6
6
  # Learn from Repository
7
7
 
8
- Use after `intelligence init` creates or converts a project. The CLI owns the
9
- mechanical setup; this skill adds only repository-specific judgement.
8
+ Use once after `intelligence init` creates or converts a project. This is the
9
+ only skill that owns initial backup migration, interrupted-setup recovery, and
10
+ the first repository-specific Intelligence layer. The CLI owns deterministic
11
+ mechanics; this skill supplies repository judgement.
10
12
 
11
- ## Analyze
13
+ ## Recover or verify setup
12
14
 
13
- 1. Run `intelligence status --check`. If setup is missing or incomplete, stop
14
- and ask the user to run `intelligence init`; do not reproduce CLI mechanics.
15
- 2. Read `<manifest>` and resolve `<content-dir>` and the configured source
16
- directories. Load `<module>/references/conventions.md` and the bundled
15
+ 1. Locate `<manifest>`, `<content-dir>`, and `<module>`. If first sync failed
16
+ before the slash command was installed, these instructions can be opened
17
+ directly from
18
+ `.intelligence/packages/@ainova-systems/sync/skills/intelligence-learn-from-repository/SKILL.md`.
19
+ 2. Inspect `<content-dir>/_backup/manifest.tsv`. A
20
+ `state<TAB>initial-onboarding` record identifies the byte-preserved state
21
+ from before Intelligence first wrote adapter output. Read every `path`
22
+ record and treat it as migration input, never generated output. A
23
+ `.intelligence/backup/config.yaml` file identifies a converted legacy
24
+ Intelligence Sync project; use the converted sources and that config as
25
+ migration evidence.
26
+ 3. Run `intelligence status --check`. If the project is missing, inconsistent,
27
+ or its first sync failed, run `intelligence init --preview`, show the exact
28
+ repair plan, and request approval. After approval run
29
+ `intelligence init --apply`. Do not reproduce manifest, package, adapter,
30
+ backup, or ignore-file mechanics manually.
31
+ 4. Run `intelligence sync`. Sync is transactional: a failure restores every
32
+ adapter-owned path. Resolve the reported cause and retry. Do not begin
33
+ semantic migration until `IS_STATUS=ok` and `intelligence status --check`
34
+ is clean.
35
+
36
+ ## Analyze repository evidence
37
+
38
+ 5. Read `<manifest>` and resolve the configured source directories. Load
39
+ `<module>/references/conventions.md` and the bundled
17
40
  `intelligence-add-rule`, `intelligence-add-skill`, and
18
- `intelligence-add-agent` skills before proposing authored content.
19
- 3. Inspect repository evidence: its README and contributor instructions,
20
- language and package manifests, build and test entry points, source layout,
21
- CI, existing agent instructions, and existing project-owned rules, agents,
22
- and skills. Treat documentation as a claim and verify important behavior in
23
- code or executable configuration.
24
- 4. Inventory what initialization already preserved or installed. Do not
41
+ `intelligence-add-agent` skills before proposing authored content. When
42
+ preserved or legacy instructions exist, also read
43
+ `<module>/references/onboarding-migration.md` and use its inventory,
44
+ reverse-mapping, packaging-safety, and stale-reference procedures.
45
+ 6. Inspect the README and contributor instructions, language and package
46
+ manifests, build and test entry points, source layout, CI, existing agent
47
+ instructions, and project-owned rules, agents, and skills. Detect
48
+ submodules and treat them as separate repositories unless the user includes
49
+ them. Treat documentation as a claim and verify important behavior in code
50
+ or executable configuration.
51
+ 7. Inventory what initialization preserved or installed. Compare project-owned
52
+ rules, agents, and skills with every configured package source. Do not
25
53
  recreate package-owned content, duplicate existing instructions, or convert
26
- generated target output into source content.
27
- 5. Propose the smallest useful project-owned layer. Prefer updating an existing
28
- artifact over creating a sibling. Each proposal must state:
29
- - `CREATE`, `UPDATE`, or `KEEP`;
54
+ generated target output into source content. When a project artifact is
55
+ materially covered by package content, propose `REMOVE` or a smaller
56
+ `UPDATE`; require a content comparison, not merely a matching name.
57
+
58
+ Treat committed legacy root instructions such as `.cursorrules` and an
59
+ instruction-bearing `CLAUDE.md` as migration sources, not permanent parallel
60
+ entry points. Propose moving still-valid guidance into project-owned rules
61
+ and removing the legacy file after generated output is verified. Keep one
62
+ only for genuinely local, gitignored configuration an adapter cannot
63
+ represent. `AGENTS.md` remains the shared root instruction entry point.
64
+
65
+ Review `.gitignore` and every existing `.vscodeignore`, `.npmignore`, and
66
+ `.dockerignore` against the CLI-managed policy. Detect tracked files which
67
+ still bypass newly added Git ignore rules. Treat missing managed patterns as
68
+ setup corrections, preserve unrelated entries, and verify actual package or
69
+ build contents before release.
70
+ 8. Propose the smallest useful project-owned layer. Prefer updating an existing
71
+ artifact over creating a sibling. Each proposal states:
72
+ - `CREATE`, `UPDATE`, `REMOVE`, or `KEEP`;
30
73
  - the source path;
31
- - the repository evidence supporting it;
32
- - the concise content or responsibility it would add.
74
+ - repository evidence;
75
+ - the concise content or responsibility it adds.
33
76
 
34
- Analysis is read-only. Present the proposal and request approval per change.
35
- It is valid to recommend no new artifacts when the repository already explains
36
- itself well.
77
+ When `targets.agents.header` is absent or generic, also propose a concise
78
+ manifest header with the project name, verified stack summary, and link to
79
+ its canonical context rule. Keep it to 3-5 lines. Replacing any
80
+ `onboarding is pending` backup pointer is part of completion.
81
+
82
+ Analysis is read-only. Present the proposal and request approval per change. It
83
+ is valid to recommend no authored artifacts when the repository already
84
+ explains itself well.
37
85
 
38
86
  ## Apply after approval
39
87
 
40
- 6. Apply only accepted proposals. Delegate new artifacts to
88
+ 9. Apply only accepted proposals. Delegate new artifacts to
41
89
  `intelligence-add-rule`, `intelligence-add-skill`, or
42
90
  `intelligence-add-agent`; update an existing project-owned artifact directly
43
- when that is the smaller change. Never edit installed package content or
44
- generated tool output.
45
- 7. Run `intelligence sync`, then `intelligence status --check`. Completion
46
- requires `IS_STATUS=ok` and a clean consistency check.
47
- 8. Report what was created, updated, or deliberately left unchanged. Remind the
48
- user to review and commit generated and source changes according to project
49
- policy.
50
-
51
- ## Related skill
52
-
53
- Use `intelligence-learn-from-context` later to preserve a lesson learned during
54
- a working session. This skill learns the repository's existing structure and
55
- workflow during onboarding.
91
+ when smaller, and edit an accepted manifest header directly. Never edit
92
+ installed package content or generated tool output.
93
+ 10. Run `intelligence sync`, then `intelligence status --check`. Inspect the
94
+ relevant generated `AGENTS.md`, Cursor rules, Claude rules, and any
95
+ packaging/build file list affected by ignore policy. Only then remove each
96
+ separately approved legacy root instruction file and rerun the consistency
97
+ check. Completion requires `IS_STATUS=ok`, a clean final check, and no
98
+ `onboarding is pending` header after accepted migration.
99
+ 11. Report what was created, updated, removed, or deliberately kept. Remind the
100
+ user to commit source, manifest, lock, `AGENTS.md`, and shared `.github/`
101
+ changes. Keep or remove the initial backup only by separate user approval.
102
+
103
+ ## Later learning
104
+
105
+ After onboarding is complete, use `/intelligence-learn-from-context` to capture
106
+ a durable lesson from a working session. It does not repeat repository
107
+ onboarding.
@@ -82,5 +82,5 @@ The user accepts items individually; bulk-accept for low-impact tweaks is fine.
82
82
 
83
83
  ## Related skills
84
84
 
85
- - `intelligence-learn-from-context` — single-lesson capture; this skill's apply phase delegates to its Phase B
85
+ - `intelligence-learn-from-context` — single-session lesson capture; this skill delegates accepted edits to its Phase B
86
86
  - `intelligence-extract-skill` — when the audit surfaces a workflow that should become a skill
@@ -8,7 +8,7 @@ context: fork
8
8
  # Sync intelligence
9
9
 
10
10
  1. Run `intelligence sync` (or `intelligence sync <adapter>` when one adapter
11
- was requested). For v2, this command first aligns project schema/content
11
+ was requested). For Intelligence projects, this command first aligns project schema/content
12
12
  with the installed CLI and restores a missing package store strictly from
13
13
  `intelligence.lock`.
14
14
  2. Require final `IS_STATUS=ok`; relay per-adapter counts and any model-drift