@ainova-systems/intelligence 0.11.0-rc.6 → 0.11.0-rc.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +15 -16
  2. package/cli/commands/adapter.sh +153 -0
  3. package/cli/commands/init.sh +113 -22
  4. package/cli/commands/package.sh +30 -0
  5. package/cli/commands/registry.sh +5 -2
  6. package/cli/commands/status.sh +12 -4
  7. package/cli/commands/sync.sh +8 -21
  8. package/cli/commands/update.sh +76 -61
  9. package/cli/engine-package.yaml +4 -4
  10. package/cli/intelligence +37 -27
  11. package/cli/{commands/doctor.sh → internal/check.sh} +32 -14
  12. package/cli/{commands/migrate.sh → internal/migrate-v1.sh} +161 -42
  13. package/cli/{commands/add.sh → internal/package-add.sh} +11 -10
  14. package/cli/{commands/list.sh → internal/package-list.sh} +9 -4
  15. package/cli/{commands/remove.sh → internal/package-remove.sh} +3 -3
  16. package/cli/{commands/search.sh → internal/package-search.sh} +4 -4
  17. package/cli/internal/package-update.sh +97 -0
  18. package/cli/{commands/install.sh → internal/restore.sh} +11 -4
  19. package/cli/internal/target-state.sh +57 -0
  20. package/cli/{commands/upgrade.sh → internal/upgrade-v2.sh} +48 -8
  21. package/cli/lib/cli-common.sh +167 -14
  22. package/cli/lib/lockfile.sh +15 -9
  23. package/cli/lib/manifest.sh +106 -1
  24. package/cli/lib/registry.sh +29 -15
  25. package/cli/lib/semver.sh +4 -2
  26. package/engine/ENGINE_SHA +1 -0
  27. package/engine/{scripts/adapters → adapters}/_template.sh +10 -9
  28. package/engine/{scripts/adapters → adapters}/agents.sh +20 -25
  29. package/engine/{scripts/adapters → adapters}/opencode.sh +1 -1
  30. package/engine/{scripts/lib → lib}/common.sh +29 -541
  31. package/engine/lib/contract.sh +120 -0
  32. package/engine/sync.sh +238 -0
  33. package/package.json +6 -5
  34. package/{engine → packages/sync}/agents/intelligence-architect.md +5 -3
  35. package/{engine → packages/sync}/agents/intelligence-operator.md +10 -13
  36. package/packages/sync/references/adapters.md +252 -0
  37. package/packages/sync/references/conventions.md +385 -0
  38. package/{engine → packages/sync}/rules/intelligence-authoring.md +6 -6
  39. package/{engine → packages/sync}/skills/intelligence-add-agent/SKILL.md +5 -5
  40. package/{engine → packages/sync}/skills/intelligence-add-rule/SKILL.md +3 -3
  41. package/{engine → packages/sync}/skills/intelligence-add-skill/SKILL.md +3 -3
  42. package/{engine → packages/sync}/skills/intelligence-extract-skill/SKILL.md +2 -2
  43. package/packages/sync/skills/intelligence-install-adapter/SKILL.md +38 -0
  44. package/{engine → packages/sync}/skills/intelligence-learn-from-context/SKILL.md +3 -3
  45. package/packages/sync/skills/intelligence-learn-from-repository/SKILL.md +55 -0
  46. package/{engine → packages/sync}/skills/intelligence-review-skills/SKILL.md +6 -6
  47. package/packages/sync/skills/intelligence-sync/SKILL.md +20 -0
  48. package/packages/sync/skills/intelligence-uninstall-adapter/SKILL.md +24 -0
  49. package/packages/sync/skills/intelligence-update/SKILL.md +43 -0
  50. package/engine/INIT.md +0 -500
  51. package/engine/docs/ADAPTERS.md +0 -214
  52. package/engine/docs/CLI.md +0 -90
  53. package/engine/docs/CONVENTIONS.md +0 -456
  54. package/engine/scripts/ENGINE_SHA +0 -1
  55. package/engine/scripts/lib/layout.sh +0 -51
  56. package/engine/scripts/lib/migrations.sh +0 -708
  57. package/engine/scripts/sync.sh +0 -311
  58. package/engine/scripts/update.sh +0 -237
  59. package/engine/skills/intelligence-install-adapter/SKILL.md +0 -31
  60. package/engine/skills/intelligence-sync/SKILL.md +0 -16
  61. package/engine/skills/intelligence-uninstall-adapter/SKILL.md +0 -42
  62. package/engine/skills/intelligence-update/SKILL.md +0 -165
  63. /package/engine/{scripts/VERSION → VERSION} +0 -0
  64. /package/engine/{scripts/adapters → adapters}/claude.sh +0 -0
  65. /package/engine/{scripts/adapters → adapters}/codex.sh +0 -0
  66. /package/engine/{scripts/adapters → adapters}/copilot.sh +0 -0
  67. /package/engine/{scripts/adapters → adapters}/cursor.sh +0 -0
  68. /package/engine/{scripts/adapters → adapters}/pi.sh +0 -0
package/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
  **npm for AI agent intelligence.** One CLI that builds, versions and distributes the rules, agents and skills your AI coding tools run on — rendered natively for Claude Code, Cursor, GitHub Copilot, OpenAI Codex, Pi, OpenCode and `AGENTS.md`.
4
4
 
5
5
  ```bash
6
- npm install -g @ainova-systems/intelligence
6
+ npm install -g @ainova-systems/intelligence@next
7
7
 
8
8
  cd your-project
9
9
  intelligence init
10
- intelligence add @ainova-systems/core
10
+ intelligence package add @ainova-systems/core
11
11
  intelligence sync
12
12
  ```
13
13
 
@@ -22,25 +22,24 @@ intelligence/ # your own rules / agents / skills
22
22
  AGENTS.md
23
23
  ```
24
24
 
25
- Teammates need one command after cloning:
25
+ Teammates need one command after cloning; it restores the locked package store before rendering:
26
26
 
27
27
  ```bash
28
- intelligence install
28
+ intelligence sync
29
29
  ```
30
30
 
31
31
  ## Commands
32
32
 
33
33
  | Command | What it does |
34
34
  |---|---|
35
- | `intelligence init` | Detect your tools, write the manifest, first sync |
36
- | `intelligence add <pkg>` | `@scope/name[@range]`, `github:org/repo[#path]`, or `git+<url>[@ref][#path]` |
37
- | `intelligence install [--frozen]` | Restore `.intelligence/` exactly from the lockfile |
38
- | `intelligence update [pkg]` | Re-resolve version ranges, rewrite the lock |
39
- | `intelligence sync [target]` | Render intelligence to every enabled tool |
40
- | `intelligence list` / `doctor` / `status` | Inspect and verify |
41
- | `intelligence registry add @scope <url>` | Bind a scope to a private registry index |
42
- | `intelligence migrate` | Convert a vendored intelligence-sync setup to the CLI |
43
-
44
- Any git repo with `rules/`, `agents/` or `skills/` at its root is already an Intelligence Package: `intelligence add @your-org/your-repo` resolves it straight from GitHub — versions come from its `x.y.z` git tags. A monorepo of packages needs one line in a registry index.
45
-
46
- Requires `git` (and on Windows the bash it ships with — Git for Windows). Engine and docs: [ainova-systems/intelligence-sync](https://github.com/ainova-systems/intelligence-sync).
35
+ | `intelligence init [--preview\|--apply]` | Create, convert, restore or align a project |
36
+ | `intelligence sync [adapter]` | Restore locked content if needed, then render all or one enabled adapter |
37
+ | `intelligence update [@scope/name] [--preview\|--apply]` | Plan or apply project and ranged-package updates |
38
+ | `intelligence package add\|remove\|list\|search` | Manage versioned Intelligence Packages |
39
+ | `intelligence adapter list\|create\|enable\|disable\|remove` | Manage render adapters |
40
+ | `intelligence status [--check]` | Inspect project state and consistency |
41
+ | `intelligence registry list\|add\|remove` | Manage trusted registry repositories |
42
+
43
+ Any git repo with `rules/`, `agents/` or `skills/` at its root is already an Intelligence Package: install it from an explicit source — `intelligence package add github:your-org/your-repo` — with versions from its `x.y.z` git tags. Names (`@scope/name`) resolve only through registries this project explicitly trusts; a monorepo of packages needs one line in such an index.
44
+
45
+ Requires `git` (and on Windows the bash it ships with — Git for Windows). Engine and docs: [ainova-systems/intelligence](https://github.com/ainova-systems/intelligence).
@@ -0,0 +1,153 @@
1
+ #!/bin/bash
2
+ # intelligence adapter <list|create|enable|disable|remove> [name]
3
+ set -euo pipefail
4
+ source "$CLI_DIR/lib/cli-common.sh"
5
+
6
+ action="${1:-}"
7
+ name="${2:-}"
8
+
9
+ adapter_list() {
10
+ detect_project
11
+ local manifest="" content_dir="" seen=" " file item enabled output configured
12
+ if [ "$IP_MODE" = "v2" ]; then
13
+ manifest="$IP_ROOT/intelligence.yaml"
14
+ content_dir="$(manifest_intelligence_dir "$manifest")"
15
+ fi
16
+
17
+ printf '%-16s %-10s %-10s %s\n' "NAME" "SOURCE" "STATE" "OUTPUT"
18
+ # Project adapters come first because they override built-ins by name.
19
+ if [ -n "$content_dir" ] && [ -d "$IP_ROOT/$content_dir/adapters" ]; then
20
+ for file in "$IP_ROOT/$content_dir/adapters"/*.sh; do
21
+ [ -f "$file" ] || continue
22
+ item="$(basename "$file" .sh)"
23
+ seen="$seen$item "
24
+ enabled="disabled"; output="$(default_target_output "$item")"
25
+ [ "$(is_target_enabled "$manifest" "$item")" = "1" ] && enabled="enabled"
26
+ configured="$(get_target_output "$manifest" "$item")"
27
+ [ -z "$configured" ] || output="$configured"
28
+ printf '%-16s %-10s %-10s %s\n' "$item" "project" "$enabled" "$output"
29
+ done
30
+ fi
31
+ for file in "$IS_ENGINE_DIR/adapters"/*.sh; do
32
+ [ -f "$file" ] || continue
33
+ item="$(basename "$file" .sh)"
34
+ [ "$item" = "_template" ] && continue
35
+ case "$seen" in *" $item "*) continue ;; esac
36
+ enabled="disabled"; output="$(default_target_output "$item")"
37
+ if [ -n "$manifest" ]; then
38
+ [ "$(is_target_enabled "$manifest" "$item")" = "1" ] && enabled="enabled"
39
+ configured="$(get_target_output "$manifest" "$item")"
40
+ [ -z "$configured" ] || output="$configured"
41
+ fi
42
+ printf '%-16s %-10s %-10s %s\n' "$item" "built-in" "$enabled" "$output"
43
+ done
44
+ }
45
+
46
+ adapter_create() {
47
+ [ -n "$name" ] && [ $# -eq 0 ] || die "usage: intelligence adapter create <name>"
48
+ assert_valid_target_name "$name"
49
+ require_v2
50
+ ensure_project_current "$IP_ROOT"
51
+ local manifest="$IP_ROOT/intelligence.yaml" content_dir repo_phys probe old_ifs part probe_phys
52
+ local template adapter_dir adapter_phys dest tmp
53
+ local -a parts
54
+ content_dir="$(manifest_intelligence_dir "$manifest")"
55
+ case "$content_dir" in
56
+ ""|/*|.|..|../*|*/../*|*/..|.intelligence|.intelligence/*)
57
+ die "unsafe project.intelligence_dir '$content_dir'"
58
+ ;;
59
+ esac
60
+ repo_phys="$(cd "$IP_ROOT" && pwd -P)"
61
+ probe="$IP_ROOT"
62
+ old_ifs="$IFS"; IFS='/'; read -r -a parts <<< "$content_dir"; IFS="$old_ifs"
63
+ for part in "${parts[@]}"; do
64
+ [ -n "$part" ] || continue
65
+ probe="$probe/$part"
66
+ if [ -e "$probe" ] || [ -L "$probe" ]; then
67
+ probe_phys="$(cd "$probe" 2>/dev/null && pwd -P)" || die "cannot resolve project content path '$content_dir'"
68
+ case "$probe_phys" in "$repo_phys"|"$repo_phys"/*) ;; *) die "project.intelligence_dir resolves outside the repository: '$content_dir'" ;; esac
69
+ fi
70
+ done
71
+ template="$IS_ENGINE_DIR/adapters/_template.sh"
72
+ [ -f "$template" ] || die "corrupt CLI installation: bundled adapter template is missing"
73
+ adapter_dir="$IP_ROOT/$content_dir/adapters"
74
+ dest="$adapter_dir/$name.sh"
75
+ [ ! -e "$dest" ] || die "project adapter already exists: $content_dir/adapters/$name.sh"
76
+ mkdir -p "$adapter_dir"
77
+ adapter_phys="$(cd "$adapter_dir" && pwd -P)"
78
+ case "$adapter_phys" in "$repo_phys"|"$repo_phys"/*) ;; *) die "project adapter directory resolves outside the repository" ;; esac
79
+ tmp="$(mktemp "$adapter_dir/.${name}.XXXXXX")"
80
+ trap '[ -z "${tmp:-}" ] || rm -f "$tmp"' EXIT
81
+ awk -v name="$name" '{ gsub(/<agent-name>/, name); gsub(/<Agent Name>/, name); gsub(/<name>/, name); print }' "$template" > "$tmp"
82
+ [ -s "$tmp" ] || die "adapter template produced an empty file"
83
+ mv "$tmp" "$dest"
84
+ tmp=""
85
+ echo "created: $content_dir/adapters/$name.sh"
86
+ echo " implement sync_to_${name}(), then run: intelligence adapter enable $name"
87
+ }
88
+
89
+ adapter_remove() {
90
+ local apply=0 manifest content_dir file answer repo_phys adapter_dir adapter_phys
91
+ while [ $# -gt 0 ]; do
92
+ case "$1" in --apply) apply=1 ;; *) die "unknown option '$1'" ;; esac
93
+ shift
94
+ done
95
+ [ -n "$name" ] || die "usage: intelligence adapter remove <name> [--apply]"
96
+ assert_valid_target_name "$name"
97
+ require_v2
98
+ ensure_project_current "$IP_ROOT"
99
+ manifest="$IP_ROOT/intelligence.yaml"
100
+ content_dir="$(manifest_intelligence_dir "$manifest")"
101
+ case "$content_dir" in
102
+ ""|/*|.|..|../*|*/../*|*/..|.intelligence|.intelligence/*)
103
+ die "unsafe project.intelligence_dir '$content_dir'"
104
+ ;;
105
+ esac
106
+ repo_phys="$(cd "$IP_ROOT" && pwd -P)"
107
+ adapter_dir="$IP_ROOT/$content_dir/adapters"
108
+ [ -d "$adapter_dir" ] || die "project adapter '$name' does not exist"
109
+ adapter_phys="$(cd "$adapter_dir" 2>/dev/null && pwd -P)" || die "cannot resolve project adapter directory"
110
+ case "$adapter_phys" in "$repo_phys"|"$repo_phys"/*) ;; *) die "project adapter directory resolves outside the repository" ;; esac
111
+ file="$adapter_dir/$name.sh"
112
+ [ -f "$file" ] || die "project adapter '$name' does not exist"
113
+ [ "$(is_target_enabled "$manifest" "$name")" != "1" ] || die "adapter '$name' is enabled — disable it first"
114
+ echo "remove project adapter source: $content_dir/adapters/$name.sh"
115
+ if [ "$apply" -ne 1 ]; then
116
+ [ -t 0 ] || die "removal requires confirmation — rerun with --apply"
117
+ printf 'Remove it? [y/N] '
118
+ read -r answer
119
+ case "$answer" in y|Y|yes|YES) ;; *) echo "removal cancelled"; exit 0 ;; esac
120
+ fi
121
+ rm -f "$file"
122
+ echo "removed: $content_dir/adapters/$name.sh"
123
+ echo " generated output was kept"
124
+ }
125
+
126
+ case "$action" in
127
+ list)
128
+ [ $# -eq 1 ] || die "usage: intelligence adapter list"
129
+ adapter_list
130
+ ;;
131
+ create)
132
+ shift 2 || true
133
+ adapter_create "$@"
134
+ ;;
135
+ enable|disable)
136
+ [ -n "$name" ] && [ $# -eq 2 ] || die "usage: intelligence adapter <enable|disable> <name>"
137
+ assert_valid_target_name "$name"
138
+ require_v2
139
+ ensure_project_current "$IP_ROOT"
140
+ bash "$CLI_DIR/internal/target-state.sh" "$action" "$name"
141
+ if [ "$action" = "enable" ]; then
142
+ exec bash "$CLI_DIR/commands/sync.sh"
143
+ fi
144
+ ;;
145
+ remove)
146
+ [ -n "$name" ] || die "usage: intelligence adapter remove <name> [--apply]"
147
+ shift 2 || true
148
+ adapter_remove "$@"
149
+ ;;
150
+ *)
151
+ die "usage: intelligence adapter <list|create|enable|disable|remove> [name]"
152
+ ;;
153
+ esac
@@ -1,24 +1,32 @@
1
1
  #!/bin/bash
2
- # intelligence init [--targets a,b,c] [--no-sync]
2
+ # intelligence init [--targets a,b,c] [--dir name] [--bare] [--no-sync]
3
+ # [--preview | --apply] [--force]
3
4
  #
4
5
  # Set up a project: root manifest, content skeleton, .gitignore, staged
5
6
  # engine content, first sync. Targets are detected from IDE markers unless
6
- # named explicitly; `agents` and `claude` are always on (AGENTS.md is the
7
- # canonical carrier of always-on rules, Claude Code does not read it).
7
+ # named explicitly. Only `agents` is unconditional: AGENTS.md is the
8
+ # tool-neutral carrier of always-on rules; tool targets come from markers or
9
+ # --targets.
8
10
  set -euo pipefail
9
11
  source "$CLI_DIR/lib/cli-common.sh"
10
12
 
11
13
  targets_arg="" no_sync=0 content_dir="intelligence" bare=0
14
+ targets_set=0 dir_set=0 bare_set=0 preview=0 apply=0 force=0
12
15
  while [ $# -gt 0 ]; do
13
16
  case "$1" in
14
- --targets) shift; targets_arg="${1:-}" ;;
15
- --dir) shift; content_dir="${1:-}" ;;
17
+ --targets) shift; targets_arg="${1:-}"; targets_set=1 ;;
18
+ --dir) shift; content_dir="${1:-}"; dir_set=1 ;;
16
19
  --no-sync) no_sync=1 ;;
17
- --bare) bare=1 ;;
20
+ --bare) bare=1; bare_set=1 ;;
21
+ --preview) preview=1 ;;
22
+ --apply) apply=1 ;;
23
+ --force) force=1 ;;
18
24
  *) die "unknown option '$1'" ;;
19
25
  esac
20
26
  shift || true
21
27
  done
28
+ [ "$preview" -eq 0 ] || [ "$apply" -eq 0 ] || die "choose either --preview or --apply"
29
+ [ "$targets_set" -eq 0 ] || [ -n "$targets_arg" ] || die "--targets needs a comma-separated adapter list"
22
30
  [ -n "$content_dir" ] || die "--dir needs a directory name"
23
31
  case "$content_dir" in
24
32
  /*|*..*|.intelligence|.intelligence/*) die "--dir must be a plain directory inside the repo, and not the package store" ;;
@@ -26,12 +34,72 @@ esac
26
34
 
27
35
  detect_project
28
36
  case "$IP_MODE" in
29
- v2) die "already set up — manifest at $IP_ROOT/intelligence.yaml (use 'intelligence status')" ;;
30
- legacy) die "this is a vendored (v1) setup at $IP_UMBRELLA — run 'intelligence migrate' instead" ;;
37
+ v2)
38
+ [ "$targets_set" -eq 0 ] || die "--targets applies only when creating a new project"
39
+ [ "$dir_set" -eq 0 ] || die "--dir applies only when creating a new project"
40
+ [ "$bare_set" -eq 0 ] || die "--bare applies only when creating a new project"
41
+ [ "$force" -eq 0 ] || die "--force applies only when converting an archived v1 project"
42
+ if [ "$preview" -eq 1 ]; then
43
+ check_version_compat "$IP_ROOT/intelligence.yaml"
44
+ echo "project: v2 at $IP_ROOT"
45
+ if project_needs_upgrade "$IP_ROOT"; then
46
+ echo " would align project lifecycle with engine $(bundled_engine_version)"
47
+ else
48
+ echo " schema/content already match engine $(bundled_engine_version)"
49
+ fi
50
+ if project_has_packages "$IP_ROOT" && [ ! -f "$IP_ROOT/intelligence.lock" ]; then
51
+ die "manifest declares packages but intelligence.lock is absent — restore the committed lock before applying"
52
+ fi
53
+ if project_store_missing "$IP_ROOT"; then
54
+ echo " would restore .intelligence/ from intelligence.lock"
55
+ else
56
+ echo " package store already present"
57
+ fi
58
+ if [ "$no_sync" -eq 1 ]; then
59
+ echo " would stop before intelligence sync"
60
+ else
61
+ echo " would run intelligence sync"
62
+ fi
63
+ exit 0
64
+ fi
65
+ if [ "$apply" -eq 1 ]; then
66
+ ensure_project_current "$IP_ROOT" --explicit
67
+ else
68
+ ensure_project_current "$IP_ROOT"
69
+ fi
70
+ restore_project_store_if_missing "$IP_ROOT"
71
+ [ "$no_sync" -eq 1 ] && exit 0
72
+ cd "$IP_ROOT"
73
+ exec bash "$CLI_DIR/commands/sync.sh"
74
+ ;;
75
+ legacy)
76
+ [ "$targets_set" -eq 0 ] || die "--targets applies only when creating a new project"
77
+ [ "$dir_set" -eq 0 ] || die "--dir applies only when creating a new project"
78
+ [ "$bare_set" -eq 0 ] || die "--bare applies only when creating a new project"
79
+ [ "$no_sync" -eq 0 ] || die "--no-sync cannot skip transactional conversion verification"
80
+ migrate_args=()
81
+ [ "$force" -eq 1 ] && migrate_args+=(--force)
82
+ if [ "$preview" -eq 1 ]; then
83
+ exec bash "$CLI_DIR/internal/migrate-v1.sh" --dry-run ${migrate_args[@]+"${migrate_args[@]}"}
84
+ fi
85
+ if [ "$apply" -eq 1 ]; then
86
+ exec bash "$CLI_DIR/internal/migrate-v1.sh" ${migrate_args[@]+"${migrate_args[@]}"}
87
+ fi
88
+ bash "$CLI_DIR/internal/migrate-v1.sh" --dry-run ${migrate_args[@]+"${migrate_args[@]}"}
89
+ [ -t 0 ] || die "v1 migration requires confirmation — rerun 'intelligence init --apply'"
90
+ printf 'Apply this migration? [Y/n] '
91
+ read -r answer
92
+ case "$answer" in
93
+ ""|y|Y|yes|YES) exec bash "$CLI_DIR/internal/migrate-v1.sh" ${migrate_args[@]+"${migrate_args[@]}"} ;;
94
+ *) echo "migration cancelled"; exit 0 ;;
95
+ esac
96
+ ;;
31
97
  esac
32
98
 
99
+ [ "$force" -eq 0 ] || die "--force applies only when converting an archived v1 project"
33
100
  root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
34
101
  root="$(cd "$root" && pwd)"
102
+ assert_safe_content_dir "$root" "$content_dir"
35
103
 
36
104
  # Never invent a tool the project shows no trace of: every per-tool target is
37
105
  # DETECTED from repo markers or named explicitly via --targets. Only `agents`
@@ -39,7 +107,14 @@ root="$(cd "$root" && pwd)"
39
107
  # the invariant-required carrier once any of them is on) is unconditional.
40
108
  targets="agents"
41
109
  if [ -n "$targets_arg" ]; then
42
- targets="agents $(printf '%s' "$targets_arg" | tr ',' ' ')"
110
+ for target in $(printf '%s' "$targets_arg" | tr ',' ' '); do
111
+ assert_valid_target_name "$target"
112
+ if [ ! -f "$IS_ENGINE_DIR/adapters/$target.sh" ] \
113
+ && [ ! -f "$root/$content_dir/adapters/$target.sh" ]; then
114
+ die "adapter '$target' not found — create it after init with: intelligence adapter create $target"
115
+ fi
116
+ case " $targets " in *" $target "*) ;; *) targets="$targets $target" ;; esac
117
+ done
43
118
  else
44
119
  if [ -d "$root/.claude" ] || [ -f "$root/CLAUDE.md" ]; then targets="$targets claude"; fi
45
120
  [ -d "$root/.cursor" ] && targets="$targets cursor"
@@ -53,16 +128,32 @@ else
53
128
  fi
54
129
  fi
55
130
 
131
+ if [ "$preview" -eq 1 ]; then
132
+ echo "project: no Intelligence setup found"
133
+ echo " would create intelligence.yaml and intelligence.lock"
134
+ if [ "$bare" -eq 1 ]; then
135
+ echo " would omit the bundled sync-content package (--bare)"
136
+ else
137
+ echo " would install the bundled sync-content package"
138
+ fi
139
+ if [ "$no_sync" -eq 1 ]; then
140
+ echo " would enable adapters:$targets and stop before sync"
141
+ else
142
+ echo " would enable adapters:$targets, then sync"
143
+ fi
144
+ exit 0
145
+ fi
146
+
56
147
  manifest="$root/intelligence.yaml"
57
148
  {
58
149
  echo "# Intelligence manifest — what this project's AI tooling knows and where it goes."
59
- echo "# Managed by the intelligence CLI. Reference: https://github.com/ainova-systems/intelligence-sync"
150
+ echo "# Managed by the intelligence CLI. Reference: https://github.com/ainova-systems/intelligence"
60
151
  echo "project:"
61
152
  echo " name: \"$(basename "$root")\""
62
153
  [ "$content_dir" = "intelligence" ] || echo " intelligence_dir: \"$content_dir\""
63
154
  echo ""
64
155
  echo "# Schema version of this manifest. The CLI keeps it in step with its engine."
65
- echo "sync_version: \"$(bundled_engine_version)\""
156
+ echo "schema_version: \"$(bundled_engine_version)\""
66
157
  echo ""
67
158
  echo "# Where content comes from. Nothing here has to exist: a directory that is"
68
159
  echo "# absent is skipped, so a project consuming only packages authors nothing of"
@@ -84,15 +175,12 @@ manifest="$root/intelligence.yaml"
84
175
  echo "# Generated output, one entry per tool. Add or drop tools freely."
85
176
  echo "targets:"
86
177
  for t in $targets; do
87
- case "$t" in
88
- agents) echo " agents: { enabled: true, output: \"AGENTS.md\" }" ;;
89
- *) echo " $t: { enabled: true, output: \".$t\" }" ;;
90
- esac
178
+ echo " $t: { enabled: true, output: \"$(default_target_output "$t")\" }"
91
179
  done
92
180
  echo ""
93
- echo "# Packages are managed with 'intelligence add' / 'search' / 'list':"
94
- echo "# intelligence add @ainova-systems/core from the registry"
95
- echo "# intelligence add github:org/repo any repo with rules|agents|skills"
181
+ echo "# Packages are managed with 'intelligence package add|search|list':"
182
+ echo "# intelligence package add @ainova-systems/core from the registry"
183
+ echo "# intelligence package add github:org/repo any repo with rules|agents|skills"
96
184
  echo "# packages:"
97
185
  echo "# \"@ainova-systems/core\":"
98
186
  echo "# version: \"^0.3.0\""
@@ -117,14 +205,14 @@ manifest="$root/intelligence.yaml"
117
205
  if [ ! -f "$root/.gitignore" ] || ! grep -q '^\.intelligence/' "$root/.gitignore"; then
118
206
  {
119
207
  [ -f "$root/.gitignore" ] && [ -n "$(tail -c 1 "$root/.gitignore" 2>/dev/null)" ] && echo ""
120
- echo "# intelligence CLI package store (restored by 'intelligence install')"
208
+ echo "# intelligence CLI package store (restored automatically by 'intelligence sync')"
121
209
  echo ".intelligence/"
122
210
  } >> "$root/.gitignore"
123
211
  fi
124
212
 
125
213
  # The engine's own content (meta-skills, authoring rule, engine agents) is an
126
214
  # ordinary package: auto-selected, opted out with --bare, removable later with
127
- # 'intelligence remove @ainova-systems/sync --force'.
215
+ # 'intelligence package remove @ainova-systems/sync --force'.
128
216
  if [ "$bare" -eq 0 ]; then
129
217
  sync_pkg_entry "$manifest"
130
218
  sync_pkg_install "$root"
@@ -132,9 +220,12 @@ fi
132
220
 
133
221
  echo "initialized: intelligence.yaml (targets:$(printf ' %s' $targets))"
134
222
  [ "$bare" -eq 1 ] && echo " bare setup: no packages — engine meta-skills not installed"
135
- echo " add packages: intelligence add @ainova-systems/core (browse: intelligence search)"
223
+ echo " add packages: intelligence package add @ainova-systems/core (browse: intelligence package search)"
136
224
  echo " write your own: create $content_dir/rules/context.md, then intelligence sync"
137
- echo " docs: https://github.com/ainova-systems/intelligence-sync#readme"
225
+ if [ "$bare" -eq 0 ]; then
226
+ echo " tailor this repository: ask your agent to run /intelligence-learn-from-repository after sync"
227
+ fi
228
+ echo " docs: https://github.com/ainova-systems/intelligence#readme"
138
229
 
139
230
  if [ "$no_sync" -eq 0 ]; then
140
231
  cd "$root"
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+ # intelligence package <add|remove|list|search> ...
3
+ set -euo pipefail
4
+ source "$CLI_DIR/lib/cli-common.sh"
5
+
6
+ action="${1:-}"
7
+ [ -n "$action" ] || die "usage: intelligence package <add|remove|list|search> [args]"
8
+ shift
9
+
10
+ case "$action" in
11
+ add)
12
+ require_v2
13
+ ensure_project_current "$IP_ROOT"
14
+ exec bash "$CLI_DIR/internal/package-add.sh" "$@"
15
+ ;;
16
+ remove)
17
+ require_v2
18
+ ensure_project_current "$IP_ROOT"
19
+ exec bash "$CLI_DIR/internal/package-remove.sh" "$@"
20
+ ;;
21
+ list)
22
+ exec bash "$CLI_DIR/internal/package-list.sh" "$@"
23
+ ;;
24
+ search)
25
+ exec bash "$CLI_DIR/internal/package-search.sh" "$@"
26
+ ;;
27
+ *)
28
+ die "usage: intelligence package <add|remove|list|search> [args]"
29
+ ;;
30
+ esac
@@ -36,9 +36,11 @@ case "$sub" in
36
36
  [ "${3:-}" = "--force" ] && force=1
37
37
  [ -n "$url" ] || die "usage: intelligence registry add <registry-repo-url> [--force]"
38
38
  case "$url" in
39
- @*) die "registries are added by URL — names carry their own scope. To install a package: intelligence add $url/<name>" ;;
39
+ @*) die "registries are added by URL — names carry their own scope. To install a package: intelligence package add $url/<name>" ;;
40
40
  esac
41
+ assert_safe_source_url "${url#git+}"
41
42
  require_v2
43
+ ensure_project_current "$IP_ROOT"
42
44
  # Fail closed: a URL that cannot produce an index is not a registry,
43
45
  # and recording it would turn a typo here into a confusing failure at
44
46
  # the first add. --force covers the one honest case: the registry is
@@ -58,7 +60,7 @@ case "$sub" in
58
60
  echo " url: \"https://github.com/acme/intelligence.git\"" >&2
59
61
  echo " path: \"packs/backend\" # omit when the repo IS the package" >&2
60
62
  echo " Format and an example: https://github.com/ainova-systems/intelligence-registry" >&2
61
- echo " A single repository needs no registry at all: intelligence add github:org/repo" >&2
63
+ echo " A single repository needs no registry at all: intelligence package add github:org/repo" >&2
62
64
  echo " Recording it ahead of a registry that does not exist yet: --force" >&2
63
65
  exit 1
64
66
  fi
@@ -69,6 +71,7 @@ case "$sub" in
69
71
  url="${2:-}"
70
72
  [ -n "$url" ] || die "usage: intelligence registry remove <url>"
71
73
  require_v2
74
+ ensure_project_current "$IP_ROOT"
72
75
  registries_remove "$IP_ROOT/intelligence.yaml" "$url"
73
76
  # The retired flat-map form also stored scope keys — drop one if the
74
77
  # argument names it, so old manifests clean up with the old command.
@@ -1,15 +1,23 @@
1
1
  #!/bin/bash
2
- # intelligence status — project state at a glance.
2
+ # intelligence status [--check] — project state or deep consistency checks.
3
3
  set -euo pipefail
4
4
  source "$CLI_DIR/lib/cli-common.sh"
5
5
 
6
+ case "${1:-}" in
7
+ "") ;;
8
+ --check) [ $# -eq 1 ] || die "usage: intelligence status [--check]"; exec bash "$CLI_DIR/internal/check.sh" ;;
9
+ *) die "usage: intelligence status [--check]" ;;
10
+ esac
11
+
6
12
  detect_project
7
13
  case "$IP_MODE" in
8
14
  v2)
9
15
  echo "Project: $IP_ROOT (CLI setup)"
10
- echo "Manifest: intelligence.yaml (sync_version $(read_engine_stamp "$IP_ROOT/intelligence.yaml"))"
16
+ echo "Manifest: intelligence.yaml (schema_version $(read_schema_version "$IP_ROOT/intelligence.yaml"))"
11
17
  if [ -f "$IP_ROOT/intelligence.lock" ]; then
12
18
  echo "Lockfile: intelligence.lock"
19
+ elif [ -n "$(qmap_keys "$IP_ROOT/intelligence.yaml" "packages")" ]; then
20
+ echo "Lockfile: MISSING (manifest declares packages)"
13
21
  else
14
22
  echo "Lockfile: none (no packages added yet)"
15
23
  fi
@@ -25,9 +33,9 @@ case "$IP_MODE" in
25
33
  echo "Project: $IP_ROOT (vendored v1 setup)"
26
34
  echo "Umbrella: $IP_UMBRELLA"
27
35
  echo "Engine: $(tr -d ' \t\r\n' < "$IP_MODULE_DIR/scripts/VERSION") (vendored at $IP_MODULE_DIR)"
28
- echo "Stamp: $(read_engine_stamp "$IP_UMBRELLA/config.yaml")"
36
+ echo "Stamp: $(top_scalar "$IP_UMBRELLA/config.yaml" "sync_version")"
29
37
  echo ""
30
- echo "Convert to the CLI setup: intelligence migrate"
38
+ echo "Convert to the CLI setup: intelligence init"
31
39
  ;;
32
40
  *)
33
41
  echo "No intelligence project here. Start one: intelligence init"
@@ -6,32 +6,19 @@ source "$CLI_DIR/lib/cli-common.sh"
6
6
  detect_project
7
7
  case "$IP_MODE" in
8
8
  v2)
9
- # Fail closed, never skip silently: a store-backed source that is not
10
- # on disk means the project is not installed (or predates the package
11
- # model) — syncing would quietly drop whole rule sets.
12
- missing="" stale=0
13
- for section in rules agents skills; do
14
- while IFS= read -r src; do
15
- [ -n "$src" ] || continue
16
- case "$src" in
17
- .intelligence/engine/*) stale=1 ;;
18
- .intelligence/*) [ -d "$IP_ROOT/$src" ] || missing="$missing $src" ;;
19
- esac
20
- done < <(read_yaml_list "$IP_ROOT/intelligence.yaml" "$section")
21
- done
22
- if [ "$stale" -eq 1 ]; then
23
- die "this manifest predates the engine-content package (.intelligence/engine sources) — run 'intelligence upgrade'"
24
- fi
25
- if [ -n "$missing" ]; then
26
- die "installed content missing on disk:$missing — run 'intelligence install'"
27
- fi
9
+ # `sync` is the normal fresh-clone command. A newer globally installed
10
+ # CLI upgrades the current v2 project first (except in CI, where a
11
+ # tracked migration must be reviewed and committed locally), and a
12
+ # missing ignored store is restored strictly from the committed lock.
13
+ ensure_project_current "$IP_ROOT"
14
+ restore_project_store_if_missing "$IP_ROOT"
28
15
  export_engine_env "$IP_ROOT"
29
- exec bash "$IS_ENGINE_DIR/scripts/sync.sh" "$@"
16
+ exec bash "$IS_ENGINE_DIR/sync.sh" "$@"
30
17
  ;;
31
18
  legacy)
32
19
  # A vendored project syncs with ITS engine — its pin is the contract,
33
20
  # and a newer bundled engine must not generate against an older schema.
34
- echo "NOTE: vendored (v1) setup — delegating to its own engine. 'intelligence migrate' converts it to the CLI setup." >&2
21
+ echo "NOTE: vendored (v1) setup — delegating to $IP_MODULE_DIR/scripts/sync.sh. 'intelligence init' converts it to the CLI setup." >&2
35
22
  exec bash "$IP_MODULE_DIR/scripts/sync.sh" "$@"
36
23
  ;;
37
24
  *)