@ainova-systems/intelligence 0.11.0-rc.8 → 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 (47) hide show
  1. package/README.md +4 -0
  2. package/cli/commands/adapter.sh +46 -6
  3. package/cli/commands/init.sh +138 -33
  4. package/cli/commands/package.sh +2 -2
  5. package/cli/commands/registry.sh +3 -3
  6. package/cli/commands/status.sh +4 -4
  7. package/cli/commands/sync.sh +76 -23
  8. package/cli/commands/update.sh +1 -1
  9. package/cli/intelligence +18 -3
  10. package/cli/internal/{upgrade-v2.sh → align-project.sh} +33 -7
  11. package/cli/internal/check.sh +49 -20
  12. package/cli/internal/{migrate-v1.sh → convert-legacy.sh} +36 -34
  13. package/cli/internal/package-add.sh +9 -14
  14. package/cli/internal/package-list.sh +1 -1
  15. package/cli/internal/package-remove.sh +1 -1
  16. package/cli/internal/package-search.sh +1 -1
  17. package/cli/internal/package-update.sh +31 -25
  18. package/cli/internal/restore.sh +5 -16
  19. package/cli/internal/target-state.sh +26 -18
  20. package/cli/lib/adapter-lifecycle.sh +33 -0
  21. package/cli/lib/cli-common.sh +28 -20
  22. package/cli/lib/gitignore.sh +174 -0
  23. package/cli/lib/manifest.sh +58 -1
  24. package/cli/lib/onboarding.sh +63 -0
  25. package/engine/ENGINE_SHA +1 -1
  26. package/engine/adapters/_template.sh +19 -2
  27. package/engine/adapters/agents.sh +14 -3
  28. package/engine/adapters/claude.sh +15 -0
  29. package/engine/adapters/codex.sh +11 -1
  30. package/engine/adapters/copilot.sh +11 -0
  31. package/engine/adapters/cursor.sh +15 -0
  32. package/engine/adapters/opencode.sh +11 -0
  33. package/engine/adapters/pi.sh +18 -5
  34. package/engine/lib/adapter-contract.sh +100 -0
  35. package/engine/lib/common.sh +5 -0
  36. package/engine/lib/contract.sh +2 -2
  37. package/engine/sync.sh +87 -25
  38. package/package.json +1 -1
  39. package/packages/sync/agents/intelligence-architect.md +2 -2
  40. package/packages/sync/references/adapters.md +51 -7
  41. package/packages/sync/references/conventions.md +57 -22
  42. package/packages/sync/references/onboarding-migration.md +79 -0
  43. package/packages/sync/skills/intelligence-install-adapter/SKILL.md +12 -5
  44. package/packages/sync/skills/intelligence-learn-from-context/SKILL.md +23 -4
  45. package/packages/sync/skills/intelligence-learn-from-repository/SKILL.md +90 -38
  46. package/packages/sync/skills/intelligence-review-skills/SKILL.md +1 -1
  47. package/packages/sync/skills/intelligence-sync/SKILL.md +1 -1
@@ -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