@ainova-systems/intelligence 0.11.0-rc.9 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/adapter.sh +46 -6
- package/cli/commands/init.sh +138 -33
- package/cli/commands/package.sh +2 -2
- package/cli/commands/registry.sh +3 -3
- package/cli/commands/status.sh +4 -4
- package/cli/commands/sync.sh +76 -23
- package/cli/commands/update.sh +1 -1
- package/cli/intelligence +18 -3
- package/cli/internal/{upgrade-v2.sh → align-project.sh} +9 -8
- package/cli/internal/check.sh +42 -2
- package/cli/internal/{migrate-v1.sh → convert-legacy.sh} +33 -29
- package/cli/internal/package-add.sh +1 -1
- package/cli/internal/package-list.sh +1 -1
- package/cli/internal/package-remove.sh +1 -1
- package/cli/internal/package-search.sh +1 -1
- package/cli/internal/package-update.sh +1 -1
- package/cli/internal/restore.sh +1 -1
- package/cli/internal/target-state.sh +26 -18
- package/cli/lib/adapter-lifecycle.sh +33 -0
- package/cli/lib/cli-common.sh +12 -8
- package/cli/lib/gitignore.sh +174 -0
- package/cli/lib/manifest.sh +35 -1
- package/cli/lib/onboarding.sh +63 -0
- package/engine/ENGINE_SHA +1 -1
- package/engine/adapters/_template.sh +19 -2
- package/engine/adapters/agents.sh +14 -3
- package/engine/adapters/claude.sh +15 -0
- package/engine/adapters/codex.sh +11 -1
- package/engine/adapters/copilot.sh +11 -0
- package/engine/adapters/cursor.sh +15 -0
- package/engine/adapters/opencode.sh +11 -0
- package/engine/adapters/pi.sh +18 -5
- package/engine/lib/adapter-contract.sh +100 -0
- package/engine/lib/common.sh +5 -0
- package/engine/lib/contract.sh +2 -2
- package/engine/sync.sh +87 -25
- package/package.json +1 -1
- package/packages/sync/agents/intelligence-architect.md +2 -2
- package/packages/sync/references/adapters.md +51 -7
- package/packages/sync/references/conventions.md +55 -20
- package/packages/sync/references/onboarding-migration.md +79 -0
- package/packages/sync/skills/intelligence-install-adapter/SKILL.md +12 -5
- package/packages/sync/skills/intelligence-learn-from-context/SKILL.md +23 -4
- package/packages/sync/skills/intelligence-learn-from-repository/SKILL.md +90 -38
- package/packages/sync/skills/intelligence-review-skills/SKILL.md +1 -1
- package/packages/sync/skills/intelligence-sync/SKILL.md +1 -1
package/cli/commands/adapter.sh
CHANGED
|
@@ -9,7 +9,7 @@ name="${2:-}"
|
|
|
9
9
|
adapter_list() {
|
|
10
10
|
detect_project
|
|
11
11
|
local manifest="" content_dir="" seen=" " file item enabled output configured
|
|
12
|
-
if [ "$IP_MODE" = "
|
|
12
|
+
if [ "$IP_MODE" = "cli" ]; then
|
|
13
13
|
manifest="$IP_ROOT/intelligence.yaml"
|
|
14
14
|
content_dir="$(manifest_intelligence_dir "$manifest")"
|
|
15
15
|
fi
|
|
@@ -46,7 +46,7 @@ adapter_list() {
|
|
|
46
46
|
adapter_create() {
|
|
47
47
|
[ -n "$name" ] && [ $# -eq 0 ] || die "usage: intelligence adapter create <name>"
|
|
48
48
|
assert_valid_target_name "$name"
|
|
49
|
-
|
|
49
|
+
require_cli_project
|
|
50
50
|
ensure_project_current "$IP_ROOT"
|
|
51
51
|
local manifest="$IP_ROOT/intelligence.yaml" content_dir repo_phys probe old_ifs part probe_phys
|
|
52
52
|
local template adapter_dir adapter_phys dest tmp
|
|
@@ -94,7 +94,7 @@ adapter_remove() {
|
|
|
94
94
|
done
|
|
95
95
|
[ -n "$name" ] || die "usage: intelligence adapter remove <name> [--apply]"
|
|
96
96
|
assert_valid_target_name "$name"
|
|
97
|
-
|
|
97
|
+
require_cli_project
|
|
98
98
|
ensure_project_current "$IP_ROOT"
|
|
99
99
|
manifest="$IP_ROOT/intelligence.yaml"
|
|
100
100
|
content_dir="$(manifest_intelligence_dir "$manifest")"
|
|
@@ -135,12 +135,44 @@ case "$action" in
|
|
|
135
135
|
enable|disable)
|
|
136
136
|
[ -n "$name" ] && [ $# -eq 2 ] || die "usage: intelligence adapter <enable|disable> <name>"
|
|
137
137
|
assert_valid_target_name "$name"
|
|
138
|
-
|
|
138
|
+
require_cli_project
|
|
139
139
|
ensure_project_current "$IP_ROOT"
|
|
140
|
-
bash "$CLI_DIR/internal/target-state.sh" "$action" "$name"
|
|
141
140
|
if [ "$action" = "enable" ]; then
|
|
142
|
-
|
|
141
|
+
state_stage="$(mktemp -d -t intelligence-adapter-state-XXXXXX)"
|
|
142
|
+
cp "$IP_ROOT/intelligence.yaml" "$state_stage/intelligence.yaml"
|
|
143
|
+
gitignore_existed=0
|
|
144
|
+
if [ -f "$IP_ROOT/.gitignore" ]; then
|
|
145
|
+
gitignore_existed=1
|
|
146
|
+
cp "$IP_ROOT/.gitignore" "$state_stage/gitignore"
|
|
147
|
+
fi
|
|
148
|
+
while IFS= read -r policy_file; do
|
|
149
|
+
[ -f "$IP_ROOT/$policy_file" ] || continue
|
|
150
|
+
cp "$IP_ROOT/$policy_file" "$state_stage/$policy_file"
|
|
151
|
+
done < <(publisher_ignore_file_names)
|
|
152
|
+
enable_rc=0
|
|
153
|
+
bash "$CLI_DIR/internal/target-state.sh" "$action" "$name" || enable_rc=$?
|
|
154
|
+
if [ "$enable_rc" -eq 0 ]; then
|
|
155
|
+
bash "$CLI_DIR/commands/sync.sh" || enable_rc=$?
|
|
156
|
+
fi
|
|
157
|
+
if [ "$enable_rc" -ne 0 ]; then
|
|
158
|
+
cp "$state_stage/intelligence.yaml" "$IP_ROOT/intelligence.yaml"
|
|
159
|
+
if [ "$gitignore_existed" -eq 1 ]; then
|
|
160
|
+
cp "$state_stage/gitignore" "$IP_ROOT/.gitignore"
|
|
161
|
+
else
|
|
162
|
+
rm -f "$IP_ROOT/.gitignore"
|
|
163
|
+
fi
|
|
164
|
+
while IFS= read -r policy_file; do
|
|
165
|
+
[ -f "$state_stage/$policy_file" ] || continue
|
|
166
|
+
cp "$state_stage/$policy_file" "$IP_ROOT/$policy_file"
|
|
167
|
+
done < <(publisher_ignore_file_names)
|
|
168
|
+
echo "ERROR: adapter enable failed; manifest and ignore policies were restored." >&2
|
|
169
|
+
else
|
|
170
|
+
report_tracked_managed_ignores "$IP_ROOT" "$IP_ROOT/intelligence.yaml"
|
|
171
|
+
fi
|
|
172
|
+
rm -rf "$state_stage"
|
|
173
|
+
exit "$enable_rc"
|
|
143
174
|
fi
|
|
175
|
+
bash "$CLI_DIR/internal/target-state.sh" "$action" "$name"
|
|
144
176
|
;;
|
|
145
177
|
remove)
|
|
146
178
|
[ -n "$name" ] || die "usage: intelligence adapter remove <name> [--apply]"
|
|
@@ -148,6 +180,14 @@ case "$action" in
|
|
|
148
180
|
adapter_remove "$@"
|
|
149
181
|
;;
|
|
150
182
|
*)
|
|
183
|
+
case "$name" in
|
|
184
|
+
list)
|
|
185
|
+
die "adapter action comes first - run: intelligence adapter list"
|
|
186
|
+
;;
|
|
187
|
+
create|enable|disable|remove)
|
|
188
|
+
die "adapter action comes first - run: intelligence adapter $name $action"
|
|
189
|
+
;;
|
|
190
|
+
esac
|
|
151
191
|
die "usage: intelligence adapter <list|create|enable|disable|remove> [name]"
|
|
152
192
|
;;
|
|
153
193
|
esac
|
package/cli/commands/init.sh
CHANGED
|
@@ -12,6 +12,50 @@ source "$CLI_DIR/lib/cli-common.sh"
|
|
|
12
12
|
|
|
13
13
|
targets_arg="" no_sync=0 content_dir="intelligence" bare=0
|
|
14
14
|
targets_set=0 dir_set=0 bare_set=0 preview=0 apply=0 force=0
|
|
15
|
+
|
|
16
|
+
print_new_project_onboarding() {
|
|
17
|
+
local heading="Intelligence ready"
|
|
18
|
+
[ "$no_sync" -eq 0 ] || heading="Next steps"
|
|
19
|
+
|
|
20
|
+
echo ""
|
|
21
|
+
echo "=== $heading ==="
|
|
22
|
+
if [ -n "${ONBOARDING_BACKUP_REL:-}" ]; then
|
|
23
|
+
echo " Existing AI instructions preserved:"
|
|
24
|
+
echo " $ONBOARDING_BACKUP_REL ($ONBOARDING_BACKUP_COUNT path(s))"
|
|
25
|
+
if [ "$bare" -eq 0 ]; then
|
|
26
|
+
echo " The learn skill will migrate them before proposing backup removal."
|
|
27
|
+
else
|
|
28
|
+
echo " Review and migrate them before removing this backup."
|
|
29
|
+
fi
|
|
30
|
+
fi
|
|
31
|
+
if [ "$no_sync" -eq 1 ]; then
|
|
32
|
+
echo " Run first:"
|
|
33
|
+
echo " intelligence sync"
|
|
34
|
+
fi
|
|
35
|
+
if [ "$bare" -eq 0 ]; then
|
|
36
|
+
echo " Recommended starter package:"
|
|
37
|
+
echo " intelligence package add @ainova-systems/core"
|
|
38
|
+
echo " Install it before learning so package/project duplicates can be detected."
|
|
39
|
+
echo " Finalize repository onboarding:"
|
|
40
|
+
echo " Ask your agent to run /intelligence-learn-from-repository"
|
|
41
|
+
echo " It recognizes the initial backup, recovers setup if needed, then proposes repository-specific migration after approval."
|
|
42
|
+
fi
|
|
43
|
+
echo " Review adapters:"
|
|
44
|
+
echo " intelligence adapter list"
|
|
45
|
+
echo " intelligence adapter enable codex"
|
|
46
|
+
echo " intelligence adapter disable cursor"
|
|
47
|
+
echo " Version control:"
|
|
48
|
+
echo " Generated adapter output is gitignored by CLI-owned path."
|
|
49
|
+
echo " Commit intelligence.yaml, intelligence.lock, intelligence/, AGENTS.md, and .github/."
|
|
50
|
+
echo " Existing .vscodeignore, .npmignore, and .dockerignore files receive packaging exclusions."
|
|
51
|
+
echo " Shared tool settings remain trackable; review the exact ownership policy:"
|
|
52
|
+
echo " https://github.com/ainova-systems/intelligence/blob/main/packages/sync/references/conventions.md#generated-output-and-version-control"
|
|
53
|
+
report_tracked_managed_ignores "$root" "$manifest"
|
|
54
|
+
echo " Write your own:"
|
|
55
|
+
echo " create $content_dir/rules/context.md, then intelligence sync"
|
|
56
|
+
echo " Docs: https://github.com/ainova-systems/intelligence#readme"
|
|
57
|
+
}
|
|
58
|
+
|
|
15
59
|
while [ $# -gt 0 ]; do
|
|
16
60
|
case "$1" in
|
|
17
61
|
--targets) shift; targets_arg="${1:-}"; targets_set=1 ;;
|
|
@@ -34,14 +78,14 @@ esac
|
|
|
34
78
|
|
|
35
79
|
detect_project
|
|
36
80
|
case "$IP_MODE" in
|
|
37
|
-
|
|
81
|
+
cli)
|
|
38
82
|
[ "$targets_set" -eq 0 ] || die "--targets applies only when creating a new project"
|
|
39
83
|
[ "$dir_set" -eq 0 ] || die "--dir applies only when creating a new project"
|
|
40
84
|
[ "$bare_set" -eq 0 ] || die "--bare applies only when creating a new project"
|
|
41
|
-
[ "$force" -eq 0 ] || die "--force applies only when converting
|
|
85
|
+
[ "$force" -eq 0 ] || die "--force applies only when converting a legacy Intelligence Sync project"
|
|
42
86
|
if [ "$preview" -eq 1 ]; then
|
|
43
87
|
check_version_compat "$IP_ROOT/intelligence.yaml"
|
|
44
|
-
echo "project:
|
|
88
|
+
echo "project: Intelligence CLI at $IP_ROOT"
|
|
45
89
|
if project_needs_upgrade "$IP_ROOT"; then
|
|
46
90
|
echo " would align project lifecycle with engine $(bundled_engine_version)"
|
|
47
91
|
else
|
|
@@ -68,35 +112,53 @@ case "$IP_MODE" in
|
|
|
68
112
|
ensure_project_current "$IP_ROOT"
|
|
69
113
|
fi
|
|
70
114
|
restore_project_store_if_missing "$IP_ROOT"
|
|
115
|
+
ensure_manifest_gitignore "$IP_ROOT" "$IP_ROOT/intelligence.yaml"
|
|
116
|
+
ensure_manifest_publisher_ignores "$IP_ROOT" "$IP_ROOT/intelligence.yaml"
|
|
71
117
|
[ "$no_sync" -eq 1 ] && exit 0
|
|
72
118
|
cd "$IP_ROOT"
|
|
73
|
-
|
|
119
|
+
sync_rc=0
|
|
120
|
+
bash "$CLI_DIR/commands/sync.sh" || sync_rc=$?
|
|
121
|
+
if [ "$sync_rc" -ne 0 ]; then
|
|
122
|
+
content_dir="$(manifest_intelligence_dir "$IP_ROOT/intelligence.yaml")"
|
|
123
|
+
recovery_backup=""
|
|
124
|
+
if [ -f "$IP_ROOT/$content_dir/_backup/manifest.tsv" ]; then
|
|
125
|
+
recovery_backup="; initial backup: $content_dir/_backup/manifest.tsv"
|
|
126
|
+
fi
|
|
127
|
+
echo "" >&2
|
|
128
|
+
echo "=== Intelligence setup needs recovery ===" >&2
|
|
129
|
+
echo " No partial adapter update was kept; sync restored its pre-run outputs." >&2
|
|
130
|
+
echo " Ask your agent to read:" >&2
|
|
131
|
+
echo " $SYNC_PKG_STORE/skills/intelligence-learn-from-repository/SKILL.md" >&2
|
|
132
|
+
echo " and finalize this Intelligence setup$recovery_backup." >&2
|
|
133
|
+
fi
|
|
134
|
+
[ "$sync_rc" -ne 0 ] || report_tracked_managed_ignores "$IP_ROOT" "$IP_ROOT/intelligence.yaml"
|
|
135
|
+
exit "$sync_rc"
|
|
74
136
|
;;
|
|
75
137
|
legacy)
|
|
76
138
|
[ "$targets_set" -eq 0 ] || die "--targets applies only when creating a new project"
|
|
77
139
|
[ "$dir_set" -eq 0 ] || die "--dir applies only when creating a new project"
|
|
78
140
|
[ "$bare_set" -eq 0 ] || die "--bare applies only when creating a new project"
|
|
79
141
|
[ "$no_sync" -eq 0 ] || die "--no-sync cannot skip transactional conversion verification"
|
|
80
|
-
|
|
81
|
-
[ "$force" -eq 1 ] &&
|
|
142
|
+
conversion_args=()
|
|
143
|
+
[ "$force" -eq 1 ] && conversion_args+=(--force)
|
|
82
144
|
if [ "$preview" -eq 1 ]; then
|
|
83
|
-
exec bash "$CLI_DIR/internal/
|
|
145
|
+
exec bash "$CLI_DIR/internal/convert-legacy.sh" --dry-run ${conversion_args[@]+"${conversion_args[@]}"}
|
|
84
146
|
fi
|
|
85
147
|
if [ "$apply" -eq 1 ]; then
|
|
86
|
-
exec bash "$CLI_DIR/internal/
|
|
148
|
+
exec bash "$CLI_DIR/internal/convert-legacy.sh" ${conversion_args[@]+"${conversion_args[@]}"}
|
|
87
149
|
fi
|
|
88
|
-
bash "$CLI_DIR/internal/
|
|
89
|
-
[ -t 0 ] || die "
|
|
90
|
-
printf 'Apply this
|
|
150
|
+
bash "$CLI_DIR/internal/convert-legacy.sh" --dry-run ${conversion_args[@]+"${conversion_args[@]}"}
|
|
151
|
+
[ -t 0 ] || die "legacy project conversion requires confirmation — rerun 'intelligence init --apply'"
|
|
152
|
+
printf 'Apply this conversion? [Y/n] '
|
|
91
153
|
read -r answer
|
|
92
154
|
case "$answer" in
|
|
93
|
-
""|y|Y|yes|YES) exec bash "$CLI_DIR/internal/
|
|
94
|
-
*) echo "
|
|
155
|
+
""|y|Y|yes|YES) exec bash "$CLI_DIR/internal/convert-legacy.sh" ${conversion_args[@]+"${conversion_args[@]}"} ;;
|
|
156
|
+
*) echo "conversion cancelled"; exit 0 ;;
|
|
95
157
|
esac
|
|
96
158
|
;;
|
|
97
159
|
esac
|
|
98
160
|
|
|
99
|
-
[ "$force" -eq 0 ] || die "--force applies only when converting
|
|
161
|
+
[ "$force" -eq 0 ] || die "--force applies only when converting a legacy Intelligence Sync project"
|
|
100
162
|
root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
101
163
|
root="$(cd "$root" && pwd)"
|
|
102
164
|
assert_safe_content_dir "$root" "$content_dir"
|
|
@@ -117,17 +179,30 @@ if [ -n "$targets_arg" ]; then
|
|
|
117
179
|
done
|
|
118
180
|
else
|
|
119
181
|
if [ -d "$root/.claude" ] || [ -f "$root/CLAUDE.md" ]; then targets="$targets claude"; fi
|
|
120
|
-
[ -d "$root/.cursor" ]
|
|
121
|
-
[ -d "$root/.codex" ]
|
|
182
|
+
if [ -d "$root/.cursor" ] || [ -f "$root/.cursorrules" ]; then targets="$targets cursor"; fi
|
|
183
|
+
if [ -d "$root/.codex" ] || [ -d "$root/.agents" ]; then targets="$targets codex"; fi
|
|
122
184
|
[ -d "$root/.pi" ] && targets="$targets pi"
|
|
123
185
|
[ -d "$root/.opencode" ] && targets="$targets opencode"
|
|
124
|
-
|
|
186
|
+
if [ -f "$root/.github/copilot-instructions.md" ] \
|
|
187
|
+
|| [ -d "$root/.github/instructions" ] \
|
|
188
|
+
|| [ -d "$root/.github/agents" ] \
|
|
189
|
+
|| [ -d "$root/.github/skills" ]; then
|
|
190
|
+
targets="$targets copilot"
|
|
191
|
+
fi
|
|
125
192
|
if [ "$targets" = "agents" ]; then
|
|
126
193
|
echo " NOTE: no tool markers found (.claude/, CLAUDE.md, .cursor/, …) — only AGENTS.md is enabled." >&2
|
|
127
194
|
echo " Name your tools explicitly: intelligence init --targets claude,cursor (or edit targets: later)" >&2
|
|
128
195
|
fi
|
|
129
196
|
fi
|
|
130
197
|
|
|
198
|
+
onboarding_count="$(onboarding_source_count "$root" "$content_dir" "$targets")"
|
|
199
|
+
onboarding_has_agents=0
|
|
200
|
+
[ -f "$root/AGENTS.md" ] && onboarding_has_agents=1
|
|
201
|
+
if [ "$preview" -eq 0 ] && [ "$onboarding_count" -gt 0 ] \
|
|
202
|
+
&& [ -e "$root/$content_dir/_backup" ]; then
|
|
203
|
+
die "onboarding backup already exists at $content_dir/_backup - review or move it before rerunning init"
|
|
204
|
+
fi
|
|
205
|
+
|
|
131
206
|
if [ "$preview" -eq 1 ]; then
|
|
132
207
|
echo "project: no Intelligence setup found"
|
|
133
208
|
echo " would create intelligence.yaml and intelligence.lock"
|
|
@@ -141,6 +216,9 @@ if [ "$preview" -eq 1 ]; then
|
|
|
141
216
|
else
|
|
142
217
|
echo " would enable adapters:$targets, then sync"
|
|
143
218
|
fi
|
|
219
|
+
if [ "$onboarding_count" -gt 0 ]; then
|
|
220
|
+
echo " would preserve $onboarding_count existing AI instruction path(s) in $content_dir/_backup before sync"
|
|
221
|
+
fi
|
|
144
222
|
exit 0
|
|
145
223
|
fi
|
|
146
224
|
|
|
@@ -175,7 +253,21 @@ manifest="$root/intelligence.yaml"
|
|
|
175
253
|
echo "# Generated output, one entry per tool. Add or drop tools freely."
|
|
176
254
|
echo "targets:"
|
|
177
255
|
for t in $targets; do
|
|
178
|
-
|
|
256
|
+
if [ "$t" = "agents" ] && [ "$onboarding_has_agents" -eq 1 ]; then
|
|
257
|
+
echo " agents:"
|
|
258
|
+
echo " enabled: true"
|
|
259
|
+
echo " output: \"AGENTS.md\""
|
|
260
|
+
echo " header: |"
|
|
261
|
+
echo " > Intelligence onboarding is pending. Before repository work, read"
|
|
262
|
+
echo " > \`$content_dir/_backup/AGENTS.md\`, which preserves the original project instructions."
|
|
263
|
+
if [ "$bare" -eq 0 ]; then
|
|
264
|
+
echo " > Run /intelligence-learn-from-repository to migrate and verify them before removing the backup."
|
|
265
|
+
else
|
|
266
|
+
echo " > Review and migrate that backup before removing it."
|
|
267
|
+
fi
|
|
268
|
+
else
|
|
269
|
+
echo " $t: { enabled: true, output: \"$(default_target_output "$t")\" }"
|
|
270
|
+
fi
|
|
179
271
|
done
|
|
180
272
|
echo ""
|
|
181
273
|
echo "# Packages are managed with 'intelligence package add|search|list':"
|
|
@@ -202,13 +294,10 @@ manifest="$root/intelligence.yaml"
|
|
|
202
294
|
} > "$manifest"
|
|
203
295
|
|
|
204
296
|
# The package store is restorable state, never committed — the npm model.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
echo ".intelligence/"
|
|
210
|
-
} >> "$root/.gitignore"
|
|
211
|
-
fi
|
|
297
|
+
ensure_base_gitignore "$root"
|
|
298
|
+
for target in $targets; do
|
|
299
|
+
ensure_target_gitignore "$root" "$manifest" "$target"
|
|
300
|
+
done
|
|
212
301
|
|
|
213
302
|
# The engine's own content (meta-skills, authoring rule, engine agents) is an
|
|
214
303
|
# ordinary package: auto-selected, opted out with --bare, removable later with
|
|
@@ -218,16 +307,32 @@ if [ "$bare" -eq 0 ]; then
|
|
|
218
307
|
sync_pkg_install "$root"
|
|
219
308
|
fi
|
|
220
309
|
|
|
310
|
+
preserve_onboarding_sources "$root" "$content_dir" "$targets"
|
|
311
|
+
ensure_manifest_publisher_ignores "$root" "$manifest"
|
|
312
|
+
|
|
221
313
|
echo "initialized: intelligence.yaml (targets:$(printf ' %s' $targets))"
|
|
222
314
|
[ "$bare" -eq 1 ] && echo " bare setup: no packages — engine meta-skills not installed"
|
|
223
|
-
echo " add packages: intelligence package add @ainova-systems/core (browse: intelligence package search)"
|
|
224
|
-
echo " write your own: create $content_dir/rules/context.md, then intelligence sync"
|
|
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"
|
|
229
|
-
|
|
230
315
|
if [ "$no_sync" -eq 0 ]; then
|
|
231
316
|
cd "$root"
|
|
232
|
-
|
|
317
|
+
sync_rc=0
|
|
318
|
+
echo ""
|
|
319
|
+
echo "=== Sync started ==="
|
|
320
|
+
echo " Rendering enabled adapters in compact mode..."
|
|
321
|
+
bash "$CLI_DIR/commands/sync.sh" --compact || sync_rc=$?
|
|
322
|
+
if [ "$sync_rc" -ne 0 ]; then
|
|
323
|
+
echo "" >&2
|
|
324
|
+
echo "=== Intelligence setup needs recovery ===" >&2
|
|
325
|
+
echo " No partial adapter update was kept; sync restored its pre-run outputs." >&2
|
|
326
|
+
if [ "$bare" -eq 0 ]; then
|
|
327
|
+
echo " Ask your agent to read:" >&2
|
|
328
|
+
echo " $SYNC_PKG_STORE/skills/intelligence-learn-from-repository/SKILL.md" >&2
|
|
329
|
+
echo " and finalize the initial Intelligence setup. The snapshot is $content_dir/_backup/manifest.tsv." >&2
|
|
330
|
+
else
|
|
331
|
+
echo " Fix the reported error, then rerun: intelligence init" >&2
|
|
332
|
+
fi
|
|
333
|
+
exit "$sync_rc"
|
|
334
|
+
fi
|
|
335
|
+
echo "=== Sync completed ==="
|
|
233
336
|
fi
|
|
337
|
+
|
|
338
|
+
print_new_project_onboarding
|
package/cli/commands/package.sh
CHANGED
|
@@ -9,12 +9,12 @@ shift
|
|
|
9
9
|
|
|
10
10
|
case "$action" in
|
|
11
11
|
add)
|
|
12
|
-
|
|
12
|
+
require_cli_project
|
|
13
13
|
ensure_project_current "$IP_ROOT"
|
|
14
14
|
exec bash "$CLI_DIR/internal/package-add.sh" "$@"
|
|
15
15
|
;;
|
|
16
16
|
remove)
|
|
17
|
-
|
|
17
|
+
require_cli_project
|
|
18
18
|
ensure_project_current "$IP_ROOT"
|
|
19
19
|
exec bash "$CLI_DIR/internal/package-remove.sh" "$@"
|
|
20
20
|
;;
|
package/cli/commands/registry.sh
CHANGED
|
@@ -12,7 +12,7 @@ sub="${1:-list}"
|
|
|
12
12
|
case "$sub" in
|
|
13
13
|
list)
|
|
14
14
|
detect_project
|
|
15
|
-
if [ "$IP_MODE" = "
|
|
15
|
+
if [ "$IP_MODE" = "cli" ] && [ -f "$IP_ROOT/intelligence.yaml" ]; then
|
|
16
16
|
echo "Project registries (intelligence.yaml, trust order):"
|
|
17
17
|
found=0
|
|
18
18
|
while IFS= read -r url; do
|
|
@@ -39,7 +39,7 @@ case "$sub" in
|
|
|
39
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
41
|
assert_safe_source_url "${url#git+}"
|
|
42
|
-
|
|
42
|
+
require_cli_project
|
|
43
43
|
ensure_project_current "$IP_ROOT"
|
|
44
44
|
# Fail closed: a URL that cannot produce an index is not a registry,
|
|
45
45
|
# and recording it would turn a typo here into a confusing failure at
|
|
@@ -70,7 +70,7 @@ case "$sub" in
|
|
|
70
70
|
remove)
|
|
71
71
|
url="${2:-}"
|
|
72
72
|
[ -n "$url" ] || die "usage: intelligence registry remove <url>"
|
|
73
|
-
|
|
73
|
+
require_cli_project
|
|
74
74
|
ensure_project_current "$IP_ROOT"
|
|
75
75
|
registries_remove "$IP_ROOT/intelligence.yaml" "$url"
|
|
76
76
|
# The retired flat-map form also stored scope keys — drop one if the
|
package/cli/commands/status.sh
CHANGED
|
@@ -11,8 +11,8 @@ esac
|
|
|
11
11
|
|
|
12
12
|
detect_project
|
|
13
13
|
case "$IP_MODE" in
|
|
14
|
-
|
|
15
|
-
echo "Project: $IP_ROOT (
|
|
14
|
+
cli)
|
|
15
|
+
echo "Project: $IP_ROOT (Intelligence project)"
|
|
16
16
|
echo "Manifest: intelligence.yaml (schema_version $(read_schema_version "$IP_ROOT/intelligence.yaml"))"
|
|
17
17
|
if [ -f "$IP_ROOT/intelligence.lock" ]; then
|
|
18
18
|
echo "Lockfile: intelligence.lock"
|
|
@@ -30,12 +30,12 @@ case "$IP_MODE" in
|
|
|
30
30
|
echo "Engine: $(bundled_engine_version) (bundled with the CLI)"
|
|
31
31
|
;;
|
|
32
32
|
legacy)
|
|
33
|
-
echo "Project: $IP_ROOT (
|
|
33
|
+
echo "Project: $IP_ROOT (legacy Intelligence Sync)"
|
|
34
34
|
echo "Umbrella: $IP_UMBRELLA"
|
|
35
35
|
echo "Engine: $(tr -d ' \t\r\n' < "$IP_MODULE_DIR/scripts/VERSION") (vendored at $IP_MODULE_DIR)"
|
|
36
36
|
echo "Stamp: $(top_scalar "$IP_UMBRELLA/config.yaml" "sync_version")"
|
|
37
37
|
echo ""
|
|
38
|
-
echo "Convert to
|
|
38
|
+
echo "Convert to Intelligence: intelligence init"
|
|
39
39
|
;;
|
|
40
40
|
*)
|
|
41
41
|
echo "No intelligence project here. Start one: intelligence init"
|
package/cli/commands/sync.sh
CHANGED
|
@@ -1,27 +1,80 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# intelligence sync [target]
|
|
2
|
+
# intelligence sync [target] [--compact] - render intelligence to enabled tools.
|
|
3
3
|
set -euo pipefail
|
|
4
4
|
source "$CLI_DIR/lib/cli-common.sh"
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
compact=0
|
|
7
|
+
target=""
|
|
8
|
+
while [ $# -gt 0 ]; do
|
|
9
|
+
case "$1" in
|
|
10
|
+
--compact) compact=1 ;;
|
|
11
|
+
-*) die "unknown option '$1'" ;;
|
|
12
|
+
*)
|
|
13
|
+
[ -z "$target" ] || die "usage: intelligence sync [adapter] [--compact]"
|
|
14
|
+
target="$1"
|
|
15
|
+
;;
|
|
16
|
+
esac
|
|
17
|
+
shift
|
|
18
|
+
done
|
|
19
|
+
|
|
20
|
+
run_sync() {
|
|
21
|
+
detect_project || return $?
|
|
22
|
+
case "$IP_MODE" in
|
|
23
|
+
cli)
|
|
24
|
+
# `sync` is the normal fresh-clone command. A newer globally installed
|
|
25
|
+
# CLI aligns the current Intelligence project first (except in CI, where a
|
|
26
|
+
# tracked migration must be reviewed and committed locally), and a
|
|
27
|
+
# missing ignored store is restored strictly from the committed lock.
|
|
28
|
+
ensure_project_current "$IP_ROOT" || return $?
|
|
29
|
+
restore_project_store_if_missing "$IP_ROOT" || return $?
|
|
30
|
+
export_engine_env "$IP_ROOT" || return $?
|
|
31
|
+
if [ -n "$target" ]; then
|
|
32
|
+
bash "$IS_ENGINE_DIR/sync.sh" "$target" || return $?
|
|
33
|
+
else
|
|
34
|
+
bash "$IS_ENGINE_DIR/sync.sh" || return $?
|
|
35
|
+
fi
|
|
36
|
+
;;
|
|
37
|
+
legacy)
|
|
38
|
+
[ "$compact" -eq 0 ] || die "--compact is unavailable for a legacy Intelligence Sync project - run 'intelligence init' to convert it first"
|
|
39
|
+
# A vendored project syncs with its own engine: its pin is the
|
|
40
|
+
# contract, and a newer bundled engine must not generate against an
|
|
41
|
+
# older schema.
|
|
42
|
+
echo "NOTE: legacy Intelligence Sync project - delegating to $IP_MODULE_DIR/scripts/sync.sh. 'intelligence init' converts it into an Intelligence project." >&2
|
|
43
|
+
if [ -n "$target" ]; then
|
|
44
|
+
bash "$IP_MODULE_DIR/scripts/sync.sh" "$target" || return $?
|
|
45
|
+
else
|
|
46
|
+
bash "$IP_MODULE_DIR/scripts/sync.sh" || return $?
|
|
47
|
+
fi
|
|
48
|
+
;;
|
|
49
|
+
*)
|
|
50
|
+
die "no intelligence project found here - run 'intelligence init'"
|
|
51
|
+
;;
|
|
52
|
+
esac
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if [ "$compact" -eq 0 ]; then
|
|
56
|
+
run_sync
|
|
57
|
+
exit $?
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
# Compact mode is intentionally quiet only on success. Buffering the complete
|
|
61
|
+
# combined stream means a failure still returns every diagnostic emitted by
|
|
62
|
+
# lifecycle preflight, locked restore or the engine, together with its real rc.
|
|
63
|
+
compact_output="$(mktemp -t intelligence-sync-XXXXXX)"
|
|
64
|
+
trap 'rm -f "$compact_output"' EXIT
|
|
65
|
+
rc=0
|
|
66
|
+
(run_sync) > "$compact_output" 2>&1 || rc=$?
|
|
67
|
+
if [ "$rc" -ne 0 ]; then
|
|
68
|
+
cat "$compact_output" >&2
|
|
69
|
+
exit "$rc"
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
status_line="$(grep '^IS_STATUS=ok\($\| \)' "$compact_output" | tail -1 || true)"
|
|
73
|
+
done_line="$(grep '^=== Done:' "$compact_output" | tail -1 || true)"
|
|
74
|
+
if [ -z "$status_line" ] || [ -z "$done_line" ]; then
|
|
75
|
+
cat "$compact_output" >&2
|
|
76
|
+
echo "ERROR: sync succeeded without its final status contract" >&2
|
|
77
|
+
exit 1
|
|
78
|
+
fi
|
|
79
|
+
echo "$status_line"
|
|
80
|
+
echo "$done_line"
|
package/cli/commands/update.sh
CHANGED
|
@@ -19,7 +19,7 @@ while [ $# -gt 0 ]; do
|
|
|
19
19
|
done
|
|
20
20
|
[ "$preview_seen" -eq 0 ] || [ "$apply_seen" -eq 0 ] || die "choose either --preview or --apply"
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
require_cli_project
|
|
23
23
|
manifest="$IP_ROOT/intelligence.yaml"
|
|
24
24
|
check_version_compat "$manifest"
|
|
25
25
|
eng="$(bundled_engine_version)"
|
package/cli/intelligence
CHANGED
|
@@ -43,10 +43,11 @@ intelligence — build, version and distribute AI agent intelligence
|
|
|
43
43
|
|
|
44
44
|
Usage: intelligence <command> [args]
|
|
45
45
|
|
|
46
|
-
init [--preview|--apply] Initialize,
|
|
46
|
+
init [--preview|--apply] Initialize, convert, restore or align this project
|
|
47
47
|
--targets a,b --dir name --bare --no-sync New-project options
|
|
48
|
-
--force Accept a dirty worktree during
|
|
49
|
-
sync [adapter]
|
|
48
|
+
--force Accept a dirty worktree during legacy project conversion
|
|
49
|
+
sync [adapter] [--compact] Restore locked content, then render enabled adapters
|
|
50
|
+
--compact On success show only final status; on failure show diagnostics
|
|
50
51
|
update [@scope/name] Show an update plan; ask before applying it
|
|
51
52
|
--preview Show the plan without asking or writing
|
|
52
53
|
--apply Apply the plan without asking
|
|
@@ -76,6 +77,20 @@ case "$cmd" in
|
|
|
76
77
|
esac
|
|
77
78
|
cmd_file="$CLI_DIR/commands/$cmd.sh"
|
|
78
79
|
if [ ! -f "$cmd_file" ]; then
|
|
80
|
+
case "$cmd" in
|
|
81
|
+
adapters)
|
|
82
|
+
echo "ERROR: unknown command 'adapters'. Use the singular command: intelligence adapter list" >&2
|
|
83
|
+
exit 1
|
|
84
|
+
;;
|
|
85
|
+
packages)
|
|
86
|
+
echo "ERROR: unknown command 'packages'. Use the singular command: intelligence package list" >&2
|
|
87
|
+
exit 1
|
|
88
|
+
;;
|
|
89
|
+
registries)
|
|
90
|
+
echo "ERROR: unknown command 'registries'. Use the singular command: intelligence registry list" >&2
|
|
91
|
+
exit 1
|
|
92
|
+
;;
|
|
93
|
+
esac
|
|
79
94
|
echo "ERROR: unknown command '$cmd'. Run 'intelligence help'." >&2
|
|
80
95
|
exit 1
|
|
81
96
|
fi
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# Internal: bring
|
|
3
|
-
#
|
|
2
|
+
# Internal: bring an Intelligence project to this CLI's engine: apply schema
|
|
3
|
+
# migrations, align the engine-content package to the bundled version,
|
|
4
4
|
# restamp schema_version, sync.
|
|
5
5
|
set -euo pipefail
|
|
6
6
|
source "$CLI_DIR/lib/cli-common.sh"
|
|
@@ -14,7 +14,7 @@ while [ $# -gt 0 ]; do
|
|
|
14
14
|
shift
|
|
15
15
|
done
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
require_cli_project
|
|
18
18
|
manifest="$IP_ROOT/intelligence.yaml"
|
|
19
19
|
|
|
20
20
|
stamp="$(read_schema_version "$manifest")"
|
|
@@ -31,14 +31,15 @@ if [ -n "$legacy_stamp" ] && _ver_gt "$legacy_stamp" "$eng"; then
|
|
|
31
31
|
die "manifest schema $legacy_stamp is newer than this CLI's engine $eng — update the global CLI first"
|
|
32
32
|
fi
|
|
33
33
|
|
|
34
|
-
# ---
|
|
34
|
+
# --- project schema migrations --------------------------------------------
|
|
35
35
|
# The engine's own chain owns vendored layouts; this one owns the manifest.
|
|
36
36
|
# Same discipline: ascending, append-only, each migration self-detects and
|
|
37
37
|
# no-ops when already applied.
|
|
38
38
|
|
|
39
|
-
#
|
|
39
|
+
# migration 0: the original RC manifest called the permanent schema key
|
|
40
40
|
# `sync_version`. Rename it without changing its value; the final stamp below
|
|
41
|
-
# then aligns it with this engine. The
|
|
41
|
+
# then aligns it with this engine. The legacy Intelligence Sync reader remains
|
|
42
|
+
# separate.
|
|
42
43
|
if [ -n "$legacy_stamp" ]; then
|
|
43
44
|
if [ -n "$stamp" ]; then
|
|
44
45
|
[ "$stamp" = "$legacy_stamp" ] || die "manifest has conflicting schema_version '$stamp' and sync_version '$legacy_stamp'"
|
|
@@ -49,7 +50,7 @@ if [ -n "$legacy_stamp" ]; then
|
|
|
49
50
|
echo " migrating: sync_version -> schema_version"
|
|
50
51
|
fi
|
|
51
52
|
|
|
52
|
-
#
|
|
53
|
+
# migration 1: package entries contain requested intent only. Early RCs
|
|
53
54
|
# also copied resolved url/path into the manifest. Preserve the existing lock
|
|
54
55
|
# as the trusted source and remove that duplicate representation. A direct
|
|
55
56
|
# unversioned package becomes an explicit HEAD pin so its manifest entry stays
|
|
@@ -74,7 +75,7 @@ if [ "$source_fields_migrated" -eq 1 ]; then
|
|
|
74
75
|
echo " migrating: package url/path -> intelligence.lock"
|
|
75
76
|
fi
|
|
76
77
|
|
|
77
|
-
#
|
|
78
|
+
# migration 2: staged engine content -> the @ainova-systems/sync package.
|
|
78
79
|
# Pre-package manifests listed `.intelligence/engine/{rules,agents,skills}`
|
|
79
80
|
# as sources fed by a CLI-staged copy; that copy is now an ordinary package
|
|
80
81
|
# entry seeded from the bundle. Post-condition: no `.intelligence/engine`
|