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

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 (51) hide show
  1. package/README.md +19 -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 +4 -2
  6. package/cli/commands/status.sh +12 -4
  7. package/cli/commands/sync.sh +7 -20
  8. package/cli/commands/update.sh +76 -70
  9. package/cli/engine-package.yaml +2 -2
  10. package/cli/intelligence +10 -12
  11. package/cli/{commands/doctor.sh → internal/check.sh} +30 -23
  12. package/cli/{commands/migrate.sh → internal/migrate-v1.sh} +117 -30
  13. package/cli/{commands/add.sh → internal/package-add.sh} +11 -16
  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 +103 -0
  18. package/cli/{commands/install.sh → internal/restore.sh} +7 -18
  19. package/cli/internal/target-state.sh +57 -0
  20. package/cli/internal/upgrade-v2.sh +133 -0
  21. package/cli/lib/cli-common.sh +142 -12
  22. package/cli/lib/lockfile.sh +1 -1
  23. package/cli/lib/manifest.sh +109 -0
  24. package/cli/lib/registry.sh +4 -4
  25. package/engine/ENGINE_SHA +1 -1
  26. package/engine/adapters/_template.sh +10 -9
  27. package/engine/adapters/agents.sh +11 -11
  28. package/engine/adapters/opencode.sh +1 -1
  29. package/engine/lib/common.sh +14 -22
  30. package/engine/lib/contract.sh +14 -14
  31. package/engine/sync.sh +25 -20
  32. package/package.json +1 -1
  33. package/packages/sync/agents/intelligence-architect.md +5 -3
  34. package/packages/sync/agents/intelligence-operator.md +10 -13
  35. package/packages/sync/references/adapters.md +252 -0
  36. package/packages/sync/references/conventions.md +385 -0
  37. package/packages/sync/rules/intelligence-authoring.md +6 -6
  38. package/packages/sync/skills/intelligence-add-agent/SKILL.md +5 -5
  39. package/packages/sync/skills/intelligence-add-rule/SKILL.md +3 -3
  40. package/packages/sync/skills/intelligence-add-skill/SKILL.md +3 -3
  41. package/packages/sync/skills/intelligence-extract-skill/SKILL.md +2 -2
  42. package/packages/sync/skills/intelligence-install-adapter/SKILL.md +29 -22
  43. package/packages/sync/skills/intelligence-learn-from-context/SKILL.md +3 -3
  44. package/packages/sync/skills/intelligence-learn-from-repository/SKILL.md +55 -0
  45. package/packages/sync/skills/intelligence-review-skills/SKILL.md +6 -6
  46. package/packages/sync/skills/intelligence-sync/SKILL.md +13 -9
  47. package/packages/sync/skills/intelligence-uninstall-adapter/SKILL.md +19 -37
  48. package/packages/sync/skills/intelligence-update/SKILL.md +34 -156
  49. package/cli/commands/upgrade.sh +0 -68
  50. package/packages/sync/docs/ADAPTERS.md +0 -214
  51. package/packages/sync/docs/CONVENTIONS.md +0 -456
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: intelligence-learn-from-repository
3
+ description: "Tailor Intelligence to an initialized repository"
4
+ ---
5
+
6
+ # Learn from Repository
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.
10
+
11
+ ## Analyze
12
+
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
17
+ `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
25
+ 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`;
30
+ - the source path;
31
+ - the repository evidence supporting it;
32
+ - the concise content or responsibility it would add.
33
+
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.
37
+
38
+ ## Apply after approval
39
+
40
+ 6. Apply only accepted proposals. Delegate new artifacts to
41
+ `intelligence-add-rule`, `intelligence-add-skill`, or
42
+ `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.
@@ -9,15 +9,15 @@ agent: intelligence-architect
9
9
 
10
10
  Read-only audit of the project's rules, agents and skills, ending in a punch-list. This skill owns the **generic** audit — everything true of any repository. A project that adds laws of its own layers a thin project audit on top and invokes this one; it never re-implements these checks.
11
11
 
12
- Name reflects the umbrella usage of "skills" for all AI artifacts (rules + agents + skills).
12
+ The name uses "skills" as shorthand for all AI artifacts (rules, agents, and skills).
13
13
 
14
14
  ## Scope: what to read, and what to leave alone
15
15
 
16
- 1. **Resolve the layout — never assume folder names.** `<umbrella>/` is the content dir, `<module>/` the engine's own files, `<manifest>` the config — all localized to this project at sync time. Read authoring conventions from `<module>/docs/CONVENTIONS.md` and the `intelligence-authoring` rule.
16
+ 1. **Resolve the layout — never assume folder names.** `<content-dir>/` is the project content directory, `<module>/` the installed sync package, `<manifest>` the root manifest — all localized to this project at sync time. Read authoring conventions from `<module>/references/conventions.md` and the `intelligence-authoring` rule.
17
17
 
18
- 2. **Enumerate from `<manifest>`, not from a guessed path.** The artifacts are exactly the directories listed under `sources.rules`, `sources.agents` and `sources.skills` — there may be several groups (e.g. a shared one and a project one), they may be nested, and a remote entry is a declared pack (vendored setups, `packs:`) or an installed package (CLI setups, `packages:`, content under `.intelligence/packages/`). Take the list from the config; a literal `intelligence/rules/` is wrong in any project that named things differently.
18
+ 2. **Enumerate from `<manifest>`, not from a guessed path.** The artifacts are exactly the directories listed under `sources.rules`, `sources.agents` and `sources.skills` — there may be several groups, they may be nested, and installed packages live under `.intelligence/packages/`. Take the list from the manifest; a literal `intelligence/rules/` is wrong in any project that named things differently.
19
19
 
20
- 3. **Skip everything the engine owns.** Sources under `<module>/` (`<module>/rules`, `<module>/agents`, `<module>/skills/intelligence-*`) are upstream-owned: every engine update replaces them wholesale, so a local "fix" there is deleted at the next update. Never propose an edit to them. If one of them is genuinely wrong, or a generic check is missing from this skill, that is a **proposal to upstream** — say so in the report rather than patching locally.
20
+ 3. **Skip installed package sources.** Sources under `<module>/` (`<module>/rules`, `<module>/agents`, `<module>/skills/intelligence-*`) are package-owned and restored by CLI lifecycle operations, so a local "fix" is not durable. Never propose a project-local edit to them. If one is wrong, make an upstream proposal instead.
21
21
 
22
22
  4. **Never read or edit generated output** (`.claude/`, `.cursor/`, `.github/`, `.codex/`, `.agents/`, `.pi/`, `.opencode/`, `AGENTS.md`). Sync owns those entirely; the finding always belongs to the source.
23
23
 
@@ -36,9 +36,9 @@ Name reflects the umbrella usage of "skills" for all AI artifacts (rules + agent
36
36
  | **Machine facts in a rule** | OS, shell, editor or a local absolute path (`R2`) | `MOVE` — these belong in a personal, gitignored `CLAUDE.md`; a rule is committed and read by everyone, including whoever is on another platform |
37
37
  | **Literal path or command in a skill** | A path *outside the skill's own folder* baked into a procedure (`R3`) | `PARAMETERIZE` — a skill is *executed*, so a literal path breaks the moment the layout moves; resolve it from a rule or from `<manifest>`. **Exempt:** the skill's own bundle (`references/`, `scripts/`, `assets/` — content is co-located with its skill by default); rules and agents (describing the repository is their job); an example inside an output-format block; the resolution step itself |
38
38
  | **Skill with no verification** | Nothing at the end proves the procedure worked (`R4`) | `FLAG` — a procedure that proves nothing is a note, or just the work: give it a verification, or delete it |
39
- | **Reserved prefix** | A project artifact named `intelligence-*` | `RENAME` — the prefix belongs to the engine, which replaces or removes everything under it on update |
39
+ | **Reserved prefix** | A project artifact named `intelligence-*` | `RENAME` — the prefix belongs to the sync package and collides in generated output |
40
40
  | **Naming** | A skill that is not `<domain>-<verb>-<noun>`, or a domain invented rather than reused | `RENAME` — or introduce the new domain deliberately |
41
- | **Stale** | No edits in 6+ months and nothing cross-references it | `ARCHIVE` — move to `<umbrella>/_archive/` |
41
+ | **Stale** | No edits in 6+ months and nothing cross-references it | `ARCHIVE` — move to `<content-dir>/_archive/` |
42
42
  | **Negative-framed judgement call** | "Never do X" where a positive default fits, outside safety / security / output-format | `REWRITE` — state the default; reserve NEVER for true must-nots |
43
43
  | **Unbacked reason** | A rule asserts a *why* — a number, a measurement, a tool's behaviour — that nothing in the repo or in that tool's documentation supports | `FLAG` — an invented reason is worse than none: it sounds like evidence. Surface it with a draft; never rewrite the meaning yourself |
44
44
  | **Always-on rule that should be scoped** | A concern that only matters in one area, loaded into every session and inlined into `AGENTS.md` | `SCOPE` — add `paths:`, or justify the cost out loud |
@@ -1,16 +1,20 @@
1
1
  ---
2
2
  name: intelligence-sync
3
- description: "Sync intelligence to enabled IDE targets"
3
+ description: "Sync intelligence to enabled adapters"
4
4
  agent: intelligence-operator
5
5
  context: fork
6
6
  ---
7
7
 
8
- Run the sync engine to transform rules, agents, and skills from the intelligence sources to each enabled IDE's native format.
8
+ # Sync intelligence
9
9
 
10
- > **The sync never migrates.** It is a pure synchronizer: across an un-applied schema it **fails closed** with `IS_STATUS=needs-update` (exit 6) and changes nothing. Bringing the project up to the engine is the update flow's job — in a vendored setup tell your agent *"Update intelligence-sync"* (the `intelligence-update` skill); in a CLI setup (root `intelligence.yaml`) run `npm i -g @ainova-systems/intelligence@latest` and `intelligence upgrade` — then re-run sync.
11
-
12
- ## Steps
13
-
14
- 1. Run `<sync-cmd>`.
15
- 2. Review the output — verify rule, agent, and skill counts per target, and that it ends with `IS_STATUS=ok`.
16
- 3. If warnings about unsynced directories appear, add the missing paths under `sources:` in `<manifest>`.
10
+ 1. Run `intelligence sync` (or `intelligence sync <adapter>` when one adapter
11
+ was requested). For v2, this command first aligns project schema/content
12
+ with the installed CLI and restores a missing package store strictly from
13
+ `intelligence.lock`.
14
+ 2. Require final `IS_STATUS=ok`; relay per-adapter counts and any model-drift
15
+ or unsynced-source warnings.
16
+ 3. In CI, a required tracked project upgrade is intentionally refused. Report
17
+ the instruction to run `intelligence init --apply` locally, review and
18
+ commit its diff; never bypass the gate. A frozen restore refusal means the
19
+ manifest and lock disagree or a pinned ref moved—report it without
20
+ hand-copying package content.
@@ -1,42 +1,24 @@
1
1
  ---
2
2
  name: intelligence-uninstall-adapter
3
- description: "Disable IDE adapter and clean up output"
4
- argument-hint: <target-name>
3
+ description: "Disable an adapter and assess its generated output"
4
+ argument-hint: <adapter-name>
5
5
  agent: intelligence-operator
6
6
  ---
7
7
 
8
- # Uninstall Adapter
9
-
10
- The project's config is `<manifest>`; the content dir is `<umbrella>/` (never assume the name or casing); the engine's own files live under `<module>/` — these paths are localized to this project at sync time.
11
-
12
- ## Steps
13
-
14
- 1. Set `enabled: false` for the target in `<manifest>`.
15
-
16
- 2. **Remove only the paths the adapter owns — never the output root.** Several adapters write into a shared root that also holds files nobody generated: `.github/` holds `workflows/`, `.claude/` holds `settings.json`, `.opencode/` holds `opencode.json`. Deleting the root destroys hand-authored work, and no adapter ever does that on re-sync.
17
-
18
- | Target | Remove | Keep (never adapter-owned) |
19
- |---|---|---|
20
- | `claude` | `.claude/rules/`, `.claude/agents/`, skill subdirs in `.claude/skills/` | `.claude/` itself, `settings.json`, `settings.local.json`, `commands/` |
21
- | `cursor` | `.cursor/rules/`, `.cursor/agents/`, `.cursor/skills/` | `.cursor/` itself, `settings.json` |
22
- | `copilot` | `.github/instructions/`, `.github/prompts/`, `.github/agents/`, skill subdirs in `.github/skills/` | `.github/` itself, `workflows/`, `ISSUE_TEMPLATE/`, a hand-authored `copilot-instructions.md` |
23
- | `codex` | `.codex/agents/` | `.codex/` itself |
24
- | `pi` | `.pi/intelligence-sync/`, `.pi/extensions/intelligence-sync-rules.ts`, `.pi/prompts/intelligence-agent-*.md` | `.pi/settings.json`, any other extension or prompt |
25
- | `opencode` | `.opencode/agents/`, and only the files in `.opencode/commands/` carrying the `<!-- Generated by intelligence-sync. Do not edit manually. -->` marker | `.opencode/opencode.json`, hand-authored commands |
26
- | `agents` | `AGENTS.md` — only if the user confirms; it is a committed project doc | — |
27
-
28
- `.agents/skills/` is **shared** by `codex`, `pi` and `opencode`. Remove it only when none of those three remains enabled.
29
-
30
- For an adapter not in this table (a project adapter under `<umbrella>/adapters/`), read its `sync_to_<name>()` cleanup block: whatever it deletes on every re-sync is exactly what it owns.
31
-
32
- 3. Remove the adapter's paths from `.gitignore` if nothing else needs them.
33
-
34
- 4. Run `/intelligence-sync` to regenerate the remaining targets.
35
-
36
- 5. **Verify** — an uninstall that removed the wrong thing must not pass quietly:
37
- - sync reports `IS_STATUS=ok`;
38
- - every path listed under *Remove* for this target is gone;
39
- - every path listed under *Keep* still exists, with its content intact (`.github/workflows/`, `.claude/settings.json`, `.opencode/opencode.json`, hand-authored commands);
40
- - the other enabled targets still produce their output.
41
-
42
- 6. Report: adapter disabled, which paths were removed, which were deliberately kept, and the verification result.
8
+ # Uninstall an adapter
9
+
10
+ 1. Run `intelligence adapter list`, then
11
+ `intelligence adapter disable $ARGUMENTS`. Disabling changes target state
12
+ and deliberately keeps generated output.
13
+ 2. If generated files should also be removed, inspect the adapter's cleanup
14
+ block to identify exactly what it owns. Show that list and obtain approval
15
+ before deleting it; never delete a shared output root.
16
+ 3. For a project adapter that should be deleted, run
17
+ `intelligence adapter remove $ARGUMENTS` after it is disabled. This prompts
18
+ by default (`--apply` is the explicit non-interactive form) and also keeps
19
+ generated output. Built-in adapter source cannot be removed.
20
+ 4. Remove obsolete `.gitignore` entries only when no remaining adapter needs
21
+ them. Sync the remaining enabled adapters when any exist.
22
+ 5. Verify with `intelligence adapter list` and `intelligence status --check`:
23
+ the adapter is disabled or removed as requested, retained files are intact,
24
+ and only approved adapter-owned output was deleted.
@@ -1,165 +1,43 @@
1
1
  ---
2
2
  name: intelligence-update
3
- description: "Update or migrate intelligence-sync: discover engine, read changelog, run migration chain, verify"
4
- argument-hint: "[--yes]"
3
+ description: "Interpret an update plan and verify breaking post-conditions"
4
+ argument-hint: "[@scope/name]"
5
5
  agent: intelligence-operator
6
6
  ---
7
7
 
8
- # Update intelligence-sync
8
+ # Update intelligence
9
9
 
10
- You are the **intelligent driver** of an update. The bash engine is
11
- deterministic and fail-closed — it never guesses; on any state it cannot
12
- resolve it prints `IS_STATUS=<code>` and stops. Your job: discover the engine,
13
- understand what is changing (read the CHANGELOG across the version gap), run
14
- the migration chain, branch on the status, and **verify afterward**. Ask the
15
- user only when genuinely ambiguous.
16
-
17
- Trigger: the user says something like *"update / migrate intelligence-sync"*.
18
- They never run shell commands by hand — you do.
19
-
20
- ## Key facts
21
-
22
- - **Umbrella** = whatever directory holds `config.yaml` (`intelligence/`,
23
- `Intelligence/`, …). Never assume the name — find it.
24
- - **Engine = a module discovered by ROLE, not by name**: a directory under
25
- the umbrella whose `scripts/sync.sh` **and** `scripts/VERSION` both exist
26
- (conventionally `sync/`, but never assume the folder name).
27
- - **Applied schema version** is the frozen contract key
28
- `sync_version` in `config.yaml` (a permanent top-level scalar;
29
- absent ⇒ pre-0.3.1). **Engine version** is `<module>/scripts/VERSION`.
30
- The gap between them is the set of breaking changes to apply.
31
- - Pre-0.3.1 projects have the engine flat at `<umbrella>/scripts/` and **no**
32
- `sync_version` key. Their frozen `update.sh` fails closed
33
- against the modular upstream (changes nothing) — you bootstrap the first hop.
34
- - The `intelligence-` skill prefix is **reserved** for upstream meta-skills.
10
+ The CLI owns planning and application. This skill interprets the plan, reads
11
+ the changelog across an engine-version gap, obtains approval, and verifies the
12
+ result.
35
13
 
36
14
  ## Steps
37
15
 
38
- ### 0. Vendored setups only
39
- If the project has a root `intelligence.yaml` (a CLI setup), **stop** — this
40
- flow is vendored-only. There the engine ships inside the CLI package: run
41
- `npm i -g @ainova-systems/intelligence@latest`, then `intelligence upgrade`,
42
- and verify with `intelligence doctor`.
43
-
44
- ### 1. Locate the umbrella & discover the engine
45
- Find the dir containing `config.yaml` → `<umbrella>`. Then find the engine by
46
- role: search `<umbrella>` (one level deep) for a directory `<M>` with both
47
- `<M>/scripts/sync.sh` and `<M>/scripts/VERSION`.
48
-
49
- - Several candidates → pick the one with the highest `scripts/VERSION`.
50
- - A module engine exists → use it; **never** fall back to a flat
51
- `<umbrella>/scripts/` even if present (that's stale legacy).
52
- - No module engine, only flat `<umbrella>/scripts/` (or nothing) → this is a
53
- pre-0.3.1 / un-bootstrapped project; go to step 2's bootstrap.
54
- - No `config.yaml` at all → not bootstrapped; point the user at upstream
55
- `INIT.md` and stop.
56
-
57
- ### 2. Fetch upstream (read-only) — do NOT write into the project yet
58
- Clone upstream into a temp dir (default
59
- `https://github.com/ainova-systems/intelligence-sync`, or the user's
60
- `REPO_URL`/fork). The upstream module is always `intelligence/sync/`.
61
-
62
- ```
63
- git clone --depth=1 <repo> <tmp>
64
- ```
65
-
66
- **Make no changes to the project before step 3's confirmation.** In
67
- particular do not copy anything into `<umbrella>/sync` yet — that would
68
- modify (and could downgrade) an already-modular project even if the user then
69
- declines. The temp clone is only for reading the CHANGELOG and as the source
70
- for the eventual write.
71
-
72
- ### 3. Understand what is changing (changelog-aware)
73
- Determine the project's current version = the `sync_version`
74
- value in `config.yaml`, or `0.0.0` if the key is absent (pre-0.3.1). The
75
- engine version = `<tmp>/intelligence/sync/scripts/VERSION`.
76
-
77
- Read `<tmp>/CHANGELOG.md`. For every release in the range
78
- **`current < release <= engine`** (inclusive of the target release — its
79
- entry holds the destination's breaking post-conditions), read its entry. Pay
80
- special attention to any **`### Breaking`** subsection (the
81
- machine-distinguishable marker). Build a short list of breaking items, new
82
- migrations, and anything to verify afterward. Surface it to the user; without
83
- `--yes`, let them confirm before any write.
84
-
85
- ### 3a. Ensure the engine to run (only now, post-confirmation)
86
- - **Modular project** (a module engine was discovered in step 1): run *its*
87
- `update.sh` — at the discovered module dir, whatever its name. `update.sh`
88
- re-clones upstream internally, shows the diff, and is authoritative; do not
89
- hand-copy over the module.
90
- - **No module engine** (pre-0.3.1 flat or un-bootstrapped): only here create
91
- the module from the temp clone, and only after confirmation:
92
- ```
93
- mkdir -p <umbrella>/sync
94
- cp -r <tmp>/intelligence/sync/. <umbrella>/sync/
95
- ```
96
- then run `<umbrella>/sync/scripts/update.sh`.
97
-
98
- ### 4. Run the engine
99
- Run the `update.sh` of the engine determined in 3a — the **discovered module
100
- dir** for a modular project (whatever its name), or the just-created
101
- `<umbrella>/sync` for the legacy bootstrap path:
102
-
103
- ```
104
- bash <engine-module>/scripts/update.sh --yes # omit --yes to confirm the diff
105
- ```
106
- Capture stdout; find the last `IS_STATUS=<code> [IS_DETAIL=...]` line.
107
-
108
- ### 5. Branch on `IS_STATUS`
109
-
110
- | Code | Meaning | Action |
111
- |---|---|---|
112
- | `ok` | Already current | Go to step 6. |
113
- | `migrated` | Migration chain applied | Go to step 6; note the relocation/changes. |
114
- | `aborted-incomplete` | Staged module incomplete; legacy intact (safe) | Re-run step 2–4 once (clone hiccup). Persists → show output, stop, don't hand-fix. |
115
- | `ahead-of-engine` | Project schema newer than this engine | Do **not** downgrade. Point `REPO_URL` at the correct/newer upstream, or accept it's already ahead. Stop. |
116
- | `needs-update` | Pending breaking changes (sync refused) | Expected pre-migration; proceed — `update.sh` is the migrator. If it persists *after* update, investigate. |
117
- | `config-missing` | No `config.yaml` | Not bootstrapped — direct user to `<umbrella>/sync/INIT.md`. Stop. |
118
- | `error` | Engine couldn't proceed | Show message; check `REPO_URL`. Stop. |
119
- | *(no status)* | Engine crashed before contract | Show full output; don't modify the tree. Stop. |
120
-
121
- On any failure code, first re-read the upstream `CHANGELOG.md` entries for `current < release <= engine` (esp. `### Breaking`) — the breaking change usually explains the error and what the user must do — before retrying or escalating.
122
-
123
- Genuinely **ambiguous** tree (e.g. both a legacy flat `<umbrella>/scripts/`
124
- and a populated module, no clear `sync_version`): inspect both,
125
- summarize the difference, ask the user which is authoritative, apply their
126
- choice. Never guess.
127
-
128
- ### 6. Verify (always, after `ok`/`migrated`)
129
-
130
- Structural — always:
131
- - No `intelligence-*` directory directly under `<umbrella>/skills/`
132
- (meta-skills live only in the module's `skills/`).
133
- - Project content intact: `<umbrella>/{rules,agents}/` and any
134
- non-`intelligence-` skills untouched.
135
- - `config.yaml` has `sync_version` equal to the engine
136
- `scripts/VERSION`, and `sources.skills` includes the module skills path
137
- exactly once.
138
-
139
- Changelog-driven — per release crossed:
140
- - For each **`### Breaking`** item in the crossed range, verify its stated
141
- post-condition actually holds (e.g. a removed/renamed file is gone, a
142
- config-schema change is reflected). If a breaking item has no verifiable
143
- post-condition, state that you could not auto-verify it.
144
-
145
- Then regenerate IDE outputs:
146
- ```
147
- bash <umbrella>/sync/scripts/sync.sh
148
- ```
149
- Relay any model-drift report. Finally summarize: versions before→after, the
150
- breaking changes applied, verification result, anything the user must act on.
151
- Clean up the temp clone.
152
-
153
- ## Notes
154
-
155
- - Everything is **idempotent**. Re-running on a current project is a safe
156
- no-op (`IS_STATUS=ok`).
157
- - Correctness rests on the engine's idempotent structural preconditions, not
158
- on the version stamp — a missing/wrong `sync_version` cannot
159
- cause a needed migration to be skipped; it only weakens the
160
- `ahead-of-engine` guard until re-stamped.
161
- - Never touch `config.yaml` beyond what the engine does (the idempotent
162
- `sources.skills` line and the `sync_version` key). Never
163
- move/delete project skills, rules, or agents.
164
- - Sibling modules beside the engine module are independent — only operate on
165
- the discovered engine module.
16
+ 1. Run `intelligence update --preview` (or
17
+ `intelligence update $ARGUMENTS --preview` for one named package). Use its
18
+ CLI, project, and package sections as the complete plan; do not re-resolve
19
+ versions independently.
20
+
21
+ 2. If the CLI or project engine version would change, read the authoritative
22
+ `CHANGELOG.md` at `https://github.com/ainova-systems/intelligence` for every
23
+ release in **`current < release <= target`**. If it is unavailable, stop
24
+ before changing versions. Turn every crossed `### Breaking` item into a
25
+ post-condition to verify.
26
+
27
+ 3. Show the plan and breaking checklist to the user. The command without a
28
+ mode also shows the plan and prompts; after approval, use `--apply` for an
29
+ unambiguous non-interactive execution.
30
+
31
+ 4. If the plan reports a newer global CLI, run exactly the npm command it
32
+ prints after approval, then rerun `intelligence update --preview` with the
33
+ new executable. Apply the resulting plan with `intelligence update --apply`,
34
+ or `intelligence update $ARGUMENTS --apply` when one package was requested.
35
+
36
+ 5. An applied update that renders must finish with `IS_STATUS=ok`; preserve and
37
+ stop on any other status. Then run `intelligence status --check`. Do not run
38
+ a duplicate sync after `update --apply`. Verify every crossed breaking
39
+ post-condition directly and report any item that cannot be machine-verified.
40
+
41
+ Report versions before and after, the applied plan, post-condition results,
42
+ and any remaining action. On a refusal, preserve the full error and stop
43
+ instead of invoking hidden lifecycle operations.
@@ -1,68 +0,0 @@
1
- #!/bin/bash
2
- # intelligence upgrade — bring the project to this CLI's engine: apply v2
3
- # schema migrations, align the engine-content package to the bundled version,
4
- # restamp sync_version, sync.
5
- set -euo pipefail
6
- source "$CLI_DIR/lib/cli-common.sh"
7
-
8
- require_v2
9
- manifest="$IP_ROOT/intelligence.yaml"
10
-
11
- stamp="$(read_engine_stamp "$manifest")"
12
- eng="$(bundled_engine_version)"
13
- if [ -n "$stamp" ] && _ver_gt "$stamp" "$eng"; then
14
- die "manifest schema $stamp is newer than this CLI's engine $eng — update the CLI first: npm i -g @ainova-systems/intelligence@latest"
15
- fi
16
-
17
- # --- v2 schema migrations -------------------------------------------------
18
- # The engine's own chain owns vendored layouts; this one owns the manifest.
19
- # Same discipline: ascending, append-only, each migration self-detects and
20
- # no-ops when already applied.
21
-
22
- # v2 migration 1: staged engine content -> the @ainova-systems/sync package.
23
- # Pre-package manifests listed `.intelligence/engine/{rules,agents,skills}`
24
- # as sources fed by a CLI-staged copy; that copy is now an ordinary package
25
- # entry seeded from the bundle. Post-condition: no `.intelligence/engine`
26
- # source entries, the package present in manifest+lock+store, stale dir gone.
27
- migrated=0
28
- for section in rules agents skills; do
29
- while IFS= read -r src; do
30
- case "$src" in
31
- .intelligence/engine/*)
32
- sources_remove_entry "$manifest" "$section" "$src"
33
- migrated=1
34
- ;;
35
- esac
36
- done < <(read_yaml_list "$manifest" "$section")
37
- done
38
- if [ "$migrated" -eq 1 ]; then
39
- echo " migrating: staged engine content -> $SYNC_PKG_NAME package"
40
- rm -rf "$IP_ROOT/.intelligence/engine"
41
- sync_pkg_entry "$manifest"
42
- sync_pkg_install "$IP_ROOT"
43
- fi
44
-
45
- # --- steady state ---------------------------------------------------------
46
- # Align the engine-content package with the bundled engine. Only a manifest
47
- # that HAS the entry is touched — a --bare project opted out, and upgrade
48
- # respects that.
49
- have_pkg=0
50
- while IFS= read -r name; do
51
- [ "$name" = "$SYNC_PKG_NAME" ] && have_pkg=1
52
- done < <(qmap_keys "$manifest" "packages")
53
- if [ "$have_pkg" -eq 1 ] && [ "$migrated" -eq 0 ]; then
54
- pinned="$(qmap_field "$manifest" "packages" "$SYNC_PKG_NAME" "version")"
55
- if [ "$pinned" != "$eng" ]; then
56
- echo " $SYNC_PKG_NAME: $pinned -> $eng"
57
- fi
58
- sync_pkg_entry "$manifest"
59
- sync_pkg_install "$IP_ROOT"
60
- fi
61
- if [ "$have_pkg" -eq 0 ] && [ "$migrated" -eq 0 ]; then
62
- echo " NOTE: $SYNC_PKG_NAME is not in this manifest (bare setup) — engine meta-skills stay uninstalled; 'intelligence add $SYNC_PKG_NAME' opts back in." >&2
63
- fi
64
-
65
- stamp_version "$manifest" "$eng"
66
- echo " sync_version -> $eng"
67
-
68
- exec bash "$CLI_DIR/commands/sync.sh"