@ainova-systems/intelligence 0.11.0-rc.1 → 0.11.0-rc.10
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.
- package/README.md +19 -16
- package/cli/commands/adapter.sh +153 -0
- package/cli/commands/init.sh +171 -34
- package/cli/commands/package.sh +30 -0
- package/cli/commands/registry.sh +65 -30
- package/cli/commands/status.sh +20 -11
- package/cli/commands/sync.sh +9 -4
- package/cli/commands/update.sh +80 -46
- package/cli/engine-package.yaml +14 -0
- package/cli/intelligence +37 -26
- package/cli/internal/align-project.sh +134 -0
- package/cli/internal/check.sh +128 -0
- package/cli/internal/convert-legacy.sh +400 -0
- package/cli/{commands/add.sh → internal/package-add.sh} +37 -19
- package/cli/{commands/list.sh → internal/package-list.sh} +10 -5
- package/cli/{commands/remove.sh → internal/package-remove.sh} +16 -4
- package/cli/internal/package-search.sh +83 -0
- package/cli/internal/package-update.sh +103 -0
- package/cli/internal/restore.sh +130 -0
- package/cli/internal/target-state.sh +57 -0
- package/cli/lib/cli-common.sh +213 -63
- package/cli/lib/lockfile.sh +15 -9
- package/cli/lib/manifest.sh +257 -4
- package/cli/lib/registry.sh +96 -47
- package/cli/lib/semver.sh +12 -4
- package/engine/ENGINE_SHA +1 -0
- package/engine/{scripts/adapters → adapters}/_template.sh +10 -9
- package/engine/{scripts/adapters → adapters}/agents.sh +20 -25
- package/engine/{scripts/adapters → adapters}/opencode.sh +1 -1
- package/engine/{scripts/lib → lib}/common.sh +30 -538
- package/engine/lib/contract.sh +120 -0
- package/engine/sync.sh +238 -0
- package/package.json +5 -5
- package/{engine → packages/sync}/agents/intelligence-architect.md +5 -3
- package/{engine → packages/sync}/agents/intelligence-operator.md +10 -13
- package/packages/sync/references/adapters.md +252 -0
- package/packages/sync/references/conventions.md +385 -0
- package/{engine → packages/sync}/rules/intelligence-authoring.md +7 -7
- package/{engine → packages/sync}/skills/intelligence-add-agent/SKILL.md +7 -7
- package/{engine → packages/sync}/skills/intelligence-add-rule/SKILL.md +5 -5
- package/{engine → packages/sync}/skills/intelligence-add-skill/SKILL.md +5 -5
- package/{engine → packages/sync}/skills/intelligence-extract-skill/SKILL.md +2 -2
- package/packages/sync/skills/intelligence-install-adapter/SKILL.md +38 -0
- package/{engine → packages/sync}/skills/intelligence-learn-from-context/SKILL.md +3 -3
- package/packages/sync/skills/intelligence-learn-from-repository/SKILL.md +55 -0
- package/{engine → packages/sync}/skills/intelligence-review-skills/SKILL.md +7 -7
- package/packages/sync/skills/intelligence-sync/SKILL.md +20 -0
- package/packages/sync/skills/intelligence-uninstall-adapter/SKILL.md +24 -0
- package/packages/sync/skills/intelligence-update/SKILL.md +43 -0
- package/cli/commands/doctor.sh +0 -100
- package/cli/commands/install.sh +0 -84
- package/cli/commands/migrate.sh +0 -251
- package/cli/commands/upgrade.sh +0 -27
- package/engine/INIT.md +0 -498
- package/engine/docs/ADAPTERS.md +0 -212
- package/engine/docs/CLI.md +0 -91
- package/engine/docs/CONVENTIONS.md +0 -440
- package/engine/scripts/lib/layout.sh +0 -51
- package/engine/scripts/lib/migrations.sh +0 -708
- package/engine/scripts/sync.sh +0 -311
- package/engine/scripts/update.sh +0 -237
- package/engine/skills/intelligence-install-adapter/SKILL.md +0 -31
- package/engine/skills/intelligence-sync/SKILL.md +0 -18
- package/engine/skills/intelligence-uninstall-adapter/SKILL.md +0 -42
- package/engine/skills/intelligence-update/SKILL.md +0 -159
- package/registry/index.yaml +0 -15
- /package/engine/{scripts/VERSION → VERSION} +0 -0
- /package/engine/{scripts/adapters → adapters}/claude.sh +0 -0
- /package/engine/{scripts/adapters → adapters}/codex.sh +0 -0
- /package/engine/{scripts/adapters → adapters}/copilot.sh +0 -0
- /package/engine/{scripts/adapters → adapters}/cursor.sh +0 -0
- /package/engine/{scripts/adapters → adapters}/pi.sh +0 -0
package/cli/commands/install.sh
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# intelligence install [--frozen] [--force] [--no-sync]
|
|
3
|
-
#
|
|
4
|
-
# Restore .intelligence/ from intelligence.lock — the fresh-clone command.
|
|
5
|
-
# --frozen additionally refuses any manifest/lock divergence (CI mode) and
|
|
6
|
-
# fails on a sha mismatch instead of re-resolving.
|
|
7
|
-
set -euo pipefail
|
|
8
|
-
source "$CLI_DIR/lib/cli-common.sh"
|
|
9
|
-
|
|
10
|
-
frozen=0 force=0 no_sync=0
|
|
11
|
-
while [ $# -gt 0 ]; do
|
|
12
|
-
case "$1" in
|
|
13
|
-
--frozen) frozen=1 ;;
|
|
14
|
-
--force) force=1 ;;
|
|
15
|
-
--no-sync) no_sync=1 ;;
|
|
16
|
-
*) die "unknown option '$1'" ;;
|
|
17
|
-
esac
|
|
18
|
-
shift || true
|
|
19
|
-
done
|
|
20
|
-
|
|
21
|
-
require_v2
|
|
22
|
-
manifest="$IP_ROOT/intelligence.yaml"
|
|
23
|
-
lock="$IP_ROOT/intelligence.lock"
|
|
24
|
-
|
|
25
|
-
ensure_engine_staged "$IP_ROOT"
|
|
26
|
-
|
|
27
|
-
# Manifest packages missing from the lock: resolve them now (npm install
|
|
28
|
-
# semantics). Under --frozen that is an error instead.
|
|
29
|
-
missing=""
|
|
30
|
-
while IFS= read -r name; do
|
|
31
|
-
[ -n "$name" ] || continue
|
|
32
|
-
if [ ! -f "$lock" ] || [ -z "$(qmap_field "$lock" "packages" "$name" "url")" ]; then
|
|
33
|
-
missing="$missing $name"
|
|
34
|
-
fi
|
|
35
|
-
done < <(qmap_keys "$manifest" "packages")
|
|
36
|
-
if [ -n "$missing" ]; then
|
|
37
|
-
[ "$frozen" -eq 1 ] && die "lockfile is missing packages:$missing — run 'intelligence install' without --frozen"
|
|
38
|
-
for name in $missing; do
|
|
39
|
-
url="$(qmap_field "$manifest" "packages" "$name" "url")"
|
|
40
|
-
path="$(qmap_field "$manifest" "packages" "$name" "path")"
|
|
41
|
-
ref="$(qmap_field "$manifest" "packages" "$name" "ref")"
|
|
42
|
-
range="$(qmap_field "$manifest" "packages" "$name" "version")"
|
|
43
|
-
if [ -z "$url" ]; then
|
|
44
|
-
resolve_package_source "$manifest" "$name"
|
|
45
|
-
url="$RES_URL"; path="$RES_PATH"
|
|
46
|
-
fi
|
|
47
|
-
resolved_tag=""
|
|
48
|
-
if [ -z "$ref" ]; then
|
|
49
|
-
picked="$(list_remote_versions "$url" | semver_pick_highest "$range")"
|
|
50
|
-
[ -n "$picked" ] || die "no tag of $url satisfies '${range:-*}' for $name"
|
|
51
|
-
read -r resolved_tag _ <<< "$(remote_tag_for_version "$url" "$picked")"
|
|
52
|
-
fi
|
|
53
|
-
rel=".intelligence/packages/$name"
|
|
54
|
-
sha="$(fetch_package "$url" "${ref:-$resolved_tag}" "$path" "$IP_ROOT/$rel")"
|
|
55
|
-
wire_package_sources "$manifest" "$name" "$rel" "$IP_ROOT"
|
|
56
|
-
lock_upsert "$lock" "$name" "$range" "$url" "$path" "${ref:-$resolved_tag}" "$sha"
|
|
57
|
-
echo "+ $name@${resolved_tag:-${ref:-HEAD}} (resolved)"
|
|
58
|
-
done
|
|
59
|
-
fi
|
|
60
|
-
|
|
61
|
-
# Restore every locked package that is not already in the store.
|
|
62
|
-
if [ -f "$lock" ]; then
|
|
63
|
-
while IFS="$LOCK_SEP" read -r name requested url path resolved sha; do
|
|
64
|
-
[ -n "$name" ] || continue
|
|
65
|
-
rel=".intelligence/packages/$name"
|
|
66
|
-
if [ -d "$IP_ROOT/$rel" ] && [ "$force" -eq 0 ]; then
|
|
67
|
-
continue
|
|
68
|
-
fi
|
|
69
|
-
got="$(fetch_package "$url" "$resolved" "$path" "$IP_ROOT/$rel")"
|
|
70
|
-
if [ -n "$sha" ] && [ "$got" != "$sha" ]; then
|
|
71
|
-
if [ "$frozen" -eq 1 ]; then
|
|
72
|
-
die "$name: fetched $got but the lock pins $sha — the ref moved; refusing under --frozen"
|
|
73
|
-
fi
|
|
74
|
-
echo " WARN: $name resolved to $got, lock had $sha — updating the lock" >&2
|
|
75
|
-
lock_upsert "$lock" "$name" "$requested" "$url" "$path" "$resolved" "$got"
|
|
76
|
-
fi
|
|
77
|
-
wire_package_sources "$manifest" "$name" "$rel" "$IP_ROOT"
|
|
78
|
-
echo "= $name@${resolved:-HEAD}"
|
|
79
|
-
done < <(lock_to_tsv "$lock")
|
|
80
|
-
fi
|
|
81
|
-
|
|
82
|
-
if [ "$no_sync" -eq 0 ]; then
|
|
83
|
-
exec bash "$CLI_DIR/commands/sync.sh"
|
|
84
|
-
fi
|
package/cli/commands/migrate.sh
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# intelligence migrate [--dry-run] [--force] — convert a vendored (v1) setup
|
|
3
|
-
# to the CLI setup: root intelligence.yaml, .intelligence/ store,
|
|
4
|
-
# intelligence.lock, no vendored engine.
|
|
5
|
-
#
|
|
6
|
-
# Transactional in the migrations.sh spirit: STAGE everything next to the
|
|
7
|
-
# project, VERIFY the staged state, then COMMIT in an order where every
|
|
8
|
-
# destructive step happens only after a real sync of the new state reported
|
|
9
|
-
# IS_STATUS=ok. Any earlier failure leaves the project untouched.
|
|
10
|
-
set -euo pipefail
|
|
11
|
-
source "$CLI_DIR/lib/cli-common.sh"
|
|
12
|
-
|
|
13
|
-
dry_run=0 force=0
|
|
14
|
-
while [ $# -gt 0 ]; do
|
|
15
|
-
case "$1" in
|
|
16
|
-
--dry-run) dry_run=1 ;;
|
|
17
|
-
--force) force=1 ;;
|
|
18
|
-
*) die "unknown option '$1'" ;;
|
|
19
|
-
esac
|
|
20
|
-
shift || true
|
|
21
|
-
done
|
|
22
|
-
|
|
23
|
-
# ---- Preconditions (fail closed, nothing written) -------------------------
|
|
24
|
-
detect_project
|
|
25
|
-
case "$IP_MODE" in
|
|
26
|
-
legacy) ;;
|
|
27
|
-
v2) die "already on the CLI setup ($IP_ROOT/intelligence.yaml)" ;;
|
|
28
|
-
*) die "no vendored setup found here — 'intelligence init' starts a fresh project" ;;
|
|
29
|
-
esac
|
|
30
|
-
root="$IP_ROOT"
|
|
31
|
-
umbrella="$IP_UMBRELLA"
|
|
32
|
-
module_dir="$IP_MODULE_DIR"
|
|
33
|
-
config="$umbrella/config.yaml"
|
|
34
|
-
module_rel="${module_dir#"$root"/}"
|
|
35
|
-
|
|
36
|
-
[ -f "$root/intelligence.yaml" ] && die "intelligence.yaml already exists at the root — half-migrated state; resolve it manually"
|
|
37
|
-
if [ "$dry_run" -eq 0 ] && [ "$force" -eq 0 ]; then
|
|
38
|
-
if [ -n "$(git -C "$root" status --porcelain 2>/dev/null)" ]; then
|
|
39
|
-
die "working tree is not clean — commit or stash first (or --force); migrate wants a one-commit diff you can review and revert"
|
|
40
|
-
fi
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
stamp="$(read_engine_stamp "$config")"
|
|
44
|
-
eng="$(bundled_engine_version)"
|
|
45
|
-
[ -n "$stamp" ] && _ver_gt "$stamp" "$eng" && die "project schema $stamp is newer than this CLI's engine $eng — update the CLI first"
|
|
46
|
-
|
|
47
|
-
# A schema gap is closed by the engine's own proven chain before conversion.
|
|
48
|
-
if [ "$dry_run" -eq 0 ] && { [ -z "$stamp" ] || _ver_gt "$eng" "$stamp"; }; then
|
|
49
|
-
echo "== applying the engine migration chain ($stamp -> $eng) =="
|
|
50
|
-
run_migrations "$umbrella" "$(basename "$module_dir")" "" || die "engine migration chain failed (IS_STATUS above) — nothing converted"
|
|
51
|
-
stamp_version "$config" "$eng"
|
|
52
|
-
fi
|
|
53
|
-
|
|
54
|
-
# ---- Stage ----------------------------------------------------------------
|
|
55
|
-
stage="$root/.intelligence-migrate-stage.$$"
|
|
56
|
-
[ "$dry_run" -eq 1 ] && stage="$(mktemp -d -t intelligence-migrate-XXXXXX 2>/dev/null || mktemp -d)"
|
|
57
|
-
cleanup_stage() { rm -rf "$stage"; }
|
|
58
|
-
trap cleanup_stage EXIT INT TERM
|
|
59
|
-
mkdir -p "$stage/.intelligence/packages"
|
|
60
|
-
|
|
61
|
-
echo "== staging =="
|
|
62
|
-
stage_engine_content "$stage/.intelligence/engine"
|
|
63
|
-
|
|
64
|
-
# Legacy pack name -> v2 package name (@org/repo derived from the url), plus
|
|
65
|
-
# per-pack source facts. Recorded as rows for the config rewrite and the lock.
|
|
66
|
-
pack_rows="$stage/packs.rows"
|
|
67
|
-
: > "$pack_rows"
|
|
68
|
-
while IFS= read -r pack; do
|
|
69
|
-
[ -n "$pack" ] || continue
|
|
70
|
-
url="$(get_pack_field "$config" "$pack" "url")"
|
|
71
|
-
ref="$(get_pack_field "$config" "$pack" "ref")"
|
|
72
|
-
mirror="$(get_pack_field "$config" "$pack" "mirror")"
|
|
73
|
-
[ -n "$url" ] || die "pack '$pack' has no url in config.yaml"
|
|
74
|
-
base="${url%.git}"; base="${base%/}"
|
|
75
|
-
repo="$(basename "$base")"
|
|
76
|
-
org="$(basename "$(dirname "$base")")"
|
|
77
|
-
case "$org" in ""|*[!A-Za-z0-9._-]*) org="local" ;; esac
|
|
78
|
-
case "$repo" in ""|*[!A-Za-z0-9._-]*) repo="$(printf '%s' "$repo" | tr -c 'A-Za-z0-9._-' '-')" ;; esac
|
|
79
|
-
name="@$org/$repo"
|
|
80
|
-
assert_valid_pkg_name "$name"
|
|
81
|
-
printf '%s\n' "$pack$LOCK_SEP$name$LOCK_SEP$url$LOCK_SEP$ref$LOCK_SEP$mirror"
|
|
82
|
-
done < <(read_yaml_keys "$config" "packs") >> "$pack_rows"
|
|
83
|
-
|
|
84
|
-
# Stage the store: mirrored packs are COPIED from their mirrors (content the
|
|
85
|
-
# repo already holds — the network is not consulted, and the mirror is not
|
|
86
|
-
# touched); transient packs are fetched.
|
|
87
|
-
lock_rows="$stage/lock.rows"
|
|
88
|
-
: > "$lock_rows"
|
|
89
|
-
while IFS="$LOCK_SEP" read -r pack name url ref mirror; do
|
|
90
|
-
[ -n "$pack" ] || continue
|
|
91
|
-
dest="$stage/.intelligence/packages/$name"
|
|
92
|
-
sha=""
|
|
93
|
-
if [ -n "$mirror" ] && [ -d "$root/$mirror" ]; then
|
|
94
|
-
mkdir -p "$dest"
|
|
95
|
-
cp -R "$root/$mirror/." "$dest/"
|
|
96
|
-
if [ -f "$dest/.pack" ]; then
|
|
97
|
-
sha="$(awk -F= '$1 == "sha" {print $2; exit}' "$dest/.pack")"
|
|
98
|
-
rm -f "$dest/.pack"
|
|
99
|
-
fi
|
|
100
|
-
echo " pack '$pack' -> $name (from mirror $mirror)"
|
|
101
|
-
else
|
|
102
|
-
sha="$(fetch_package "$url" "$ref" "" "$dest")"
|
|
103
|
-
echo " pack '$pack' -> $name (fetched)"
|
|
104
|
-
fi
|
|
105
|
-
if [ -z "$sha" ] || [ "$sha" = "unknown" ]; then
|
|
106
|
-
sha="$(GIT_TERMINAL_PROMPT=0 git ls-remote "$url" "$ref" 2>/dev/null | awk '{print $1; exit}')"
|
|
107
|
-
fi
|
|
108
|
-
printf '%s\037%s\037%s\037%s\037%s\037%s\n' \
|
|
109
|
-
"$name" "" "$url" "" "$ref" "$sha" >> "$lock_rows"
|
|
110
|
-
done < "$pack_rows"
|
|
111
|
-
|
|
112
|
-
# The manifest: config.yaml transformed line by line — comments and unknown
|
|
113
|
-
# blocks survive verbatim; `sync_version` and `packs:` are dropped (restamped
|
|
114
|
-
# / converted); sources entries are rewritten onto the store.
|
|
115
|
-
manifest_stage="$stage/intelligence.yaml"
|
|
116
|
-
rewrite_source_value() {
|
|
117
|
-
local v="$1" pack name rest
|
|
118
|
-
case "$v" in
|
|
119
|
-
"$module_rel"/rules|"$module_rel"/agents|"$module_rel"/skills)
|
|
120
|
-
printf '.intelligence/engine/%s' "${v##*/}"
|
|
121
|
-
return 0 ;;
|
|
122
|
-
@*)
|
|
123
|
-
rest="${v#@}"
|
|
124
|
-
pack="${rest%%/*}"
|
|
125
|
-
while IFS="$LOCK_SEP" read -r p name _ _ _; do
|
|
126
|
-
if [ "$p" = "$pack" ]; then
|
|
127
|
-
if [ "$rest" = "$pack" ]; then
|
|
128
|
-
printf '.intelligence/packages/%s' "$name"
|
|
129
|
-
else
|
|
130
|
-
printf '.intelligence/packages/%s/%s' "$name" "${rest#*/}"
|
|
131
|
-
fi
|
|
132
|
-
return 0
|
|
133
|
-
fi
|
|
134
|
-
done < "$pack_rows"
|
|
135
|
-
;;
|
|
136
|
-
esac
|
|
137
|
-
printf '%s' "$v"
|
|
138
|
-
}
|
|
139
|
-
in_packs=0 in_sources=0
|
|
140
|
-
while IFS= read -r line || [ -n "$line" ]; do
|
|
141
|
-
line="${line%$'\r'}"
|
|
142
|
-
case "$line" in
|
|
143
|
-
sync_version:*) continue ;;
|
|
144
|
-
packs:*) in_packs=1; continue ;;
|
|
145
|
-
sources:*) in_sources=1; in_packs=0; echo "$line"; continue ;;
|
|
146
|
-
[!\ \#]*) in_packs=0; in_sources=0 ;;
|
|
147
|
-
esac
|
|
148
|
-
[ "$in_packs" -eq 1 ] && continue
|
|
149
|
-
if [ "$in_sources" -eq 1 ]; then
|
|
150
|
-
case "$line" in
|
|
151
|
-
*"- "*)
|
|
152
|
-
indent="${line%%-*}"
|
|
153
|
-
v="${line#*- }"
|
|
154
|
-
v="${v%\"}"; v="${v#\"}"; v="${v%\'}"; v="${v#\'}"
|
|
155
|
-
echo "$indent- \"$(rewrite_source_value "$v")\""
|
|
156
|
-
continue
|
|
157
|
-
;;
|
|
158
|
-
esac
|
|
159
|
-
fi
|
|
160
|
-
echo "$line"
|
|
161
|
-
done < "$config" > "$manifest_stage"
|
|
162
|
-
stamp_version "$manifest_stage" "$eng"
|
|
163
|
-
|
|
164
|
-
# packages: entries (pin preserved — no invented ranges).
|
|
165
|
-
while IFS="$LOCK_SEP" read -r pack name url ref mirror; do
|
|
166
|
-
[ -n "$pack" ] || continue
|
|
167
|
-
qmap_set "$manifest_stage" "packages" "$name" "url" "$url"
|
|
168
|
-
[ -n "$ref" ] && qmap_set "$manifest_stage" "packages" "$name" "ref" "$ref"
|
|
169
|
-
done < "$pack_rows"
|
|
170
|
-
|
|
171
|
-
# ---- Verify ---------------------------------------------------------------
|
|
172
|
-
echo "== verifying staged state =="
|
|
173
|
-
fail=0
|
|
174
|
-
for section in rules agents skills; do
|
|
175
|
-
while IFS= read -r src; do
|
|
176
|
-
[ -n "$src" ] || continue
|
|
177
|
-
case "$src" in
|
|
178
|
-
.intelligence/*) [ -d "$stage/$src" ] || { echo " MISSING (staged): $src"; fail=1; } ;;
|
|
179
|
-
git+*|@*) echo " UNCONVERTED source token: $src"; fail=1 ;;
|
|
180
|
-
*) [ -d "$root/$src" ] || echo " NOTE: local source '$src' does not exist (kept — same as before)" ;;
|
|
181
|
-
esac
|
|
182
|
-
done < <(read_yaml_list "$manifest_stage" "$section")
|
|
183
|
-
done
|
|
184
|
-
for adapter in agents claude cursor copilot codex pi opencode; do
|
|
185
|
-
old_e="$(is_target_enabled "$config" "$adapter")"
|
|
186
|
-
new_e="$(is_target_enabled "$manifest_stage" "$adapter")"
|
|
187
|
-
[ "$old_e" = "$new_e" ] || { echo " TARGET DRIFT: $adapter enabled '$old_e' -> '$new_e'"; fail=1; }
|
|
188
|
-
old_o="$(get_target_output "$config" "$adapter")"
|
|
189
|
-
new_o="$(get_target_output "$manifest_stage" "$adapter")"
|
|
190
|
-
[ "$old_o" = "$new_o" ] || { echo " TARGET DRIFT: $adapter output '$old_o' -> '$new_o'"; fail=1; }
|
|
191
|
-
done
|
|
192
|
-
[ "$fail" -eq 0 ] || die "staged state failed verification — nothing changed"
|
|
193
|
-
|
|
194
|
-
if [ "$dry_run" -eq 1 ]; then
|
|
195
|
-
echo ""
|
|
196
|
-
echo "== dry run — the project is untouched. Staged manifest: =="
|
|
197
|
-
cat "$manifest_stage"
|
|
198
|
-
echo ""
|
|
199
|
-
echo "Would: write intelligence.yaml + intelligence.lock, move the store in,"
|
|
200
|
-
echo "sync, then remove $module_rel/, config.yaml and the pack mirrors."
|
|
201
|
-
exit 0
|
|
202
|
-
fi
|
|
203
|
-
|
|
204
|
-
# ---- Commit ---------------------------------------------------------------
|
|
205
|
-
echo "== committing =="
|
|
206
|
-
if [ ! -f "$root/.gitignore" ] || ! grep -q '^\.intelligence/' "$root/.gitignore"; then
|
|
207
|
-
{
|
|
208
|
-
[ -f "$root/.gitignore" ] && [ -n "$(tail -c 1 "$root/.gitignore" 2>/dev/null)" ] && echo ""
|
|
209
|
-
echo "# intelligence CLI package store (restored by 'intelligence install')"
|
|
210
|
-
echo ".intelligence/"
|
|
211
|
-
} >> "$root/.gitignore"
|
|
212
|
-
fi
|
|
213
|
-
rollback() {
|
|
214
|
-
rm -rf "$root/.intelligence" "$root/intelligence.yaml" "$root/intelligence.lock"
|
|
215
|
-
echo "rolled back — the vendored setup is untouched" >&2
|
|
216
|
-
}
|
|
217
|
-
mv "$stage/.intelligence" "$root/.intelligence"
|
|
218
|
-
cp "$manifest_stage" "$root/intelligence.yaml"
|
|
219
|
-
lock_write_from_tsv "$root/intelligence.lock" "$lock_rows"
|
|
220
|
-
|
|
221
|
-
sync_out="$(cd "$root" && IS_SUPPRESS_CLI_NOTE=1 bash "$CLI_DIR/commands/sync.sh" 2>&1)" || {
|
|
222
|
-
echo "$sync_out"
|
|
223
|
-
rollback
|
|
224
|
-
die "sync of the migrated state failed — rolled back"
|
|
225
|
-
}
|
|
226
|
-
echo "$sync_out" | grep -q '^IS_STATUS=ok' || {
|
|
227
|
-
echo "$sync_out"
|
|
228
|
-
rollback
|
|
229
|
-
die "sync of the migrated state did not report ok — rolled back"
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
# Only now is anything of the old setup removed — and config.yaml is kept as
|
|
233
|
-
# a reviewable backup inside the store.
|
|
234
|
-
mkdir -p "$root/.intelligence/backup"
|
|
235
|
-
cp "$config" "$root/.intelligence/backup/config.yaml"
|
|
236
|
-
while IFS="$LOCK_SEP" read -r pack name url ref mirror; do
|
|
237
|
-
if [ -n "$mirror" ] && [ -d "$root/$mirror" ]; then
|
|
238
|
-
rm -rf "${root:?}/$mirror"
|
|
239
|
-
# An emptied mirror parent (e.g. <umbrella>/external/) goes with it.
|
|
240
|
-
rmdir "$(dirname "$root/$mirror")" 2>/dev/null || true
|
|
241
|
-
fi
|
|
242
|
-
done < "$pack_rows"
|
|
243
|
-
rm -rf "$module_dir"
|
|
244
|
-
rm -f "$config"
|
|
245
|
-
# An emptied umbrella dir (config-only setups) is dropped; one with project
|
|
246
|
-
# content stays.
|
|
247
|
-
rmdir "$umbrella" 2>/dev/null || true
|
|
248
|
-
|
|
249
|
-
echo ""
|
|
250
|
-
echo "migrated. Review the diff, then commit. The old config.yaml is kept at .intelligence/backup/config.yaml."
|
|
251
|
-
echo "From now on: intelligence sync | add | install | doctor."
|
package/cli/commands/upgrade.sh
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# intelligence upgrade — bring the project to this CLI's engine: restage the
|
|
3
|
-
# engine content, apply v2 schema migrations (none yet — the chain starts
|
|
4
|
-
# empty by design), 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 live HERE, not in the engine's chain (that one owns
|
|
18
|
-
# vendored layouts). Same discipline: ascending, append-only, each migration
|
|
19
|
-
# self-detects and no-ops when already applied.
|
|
20
|
-
# V2_MIGRATIONS=( ) — first entry arrives with the first breaking v2 change.
|
|
21
|
-
|
|
22
|
-
stage_engine_content "$IP_ROOT/.intelligence/engine"
|
|
23
|
-
echo " engine content restaged ($eng)"
|
|
24
|
-
stamp_version "$manifest" "$eng"
|
|
25
|
-
echo " sync_version -> $eng"
|
|
26
|
-
|
|
27
|
-
exec bash "$CLI_DIR/commands/sync.sh"
|