@ainova-systems/intelligence 0.11.0-rc.9 → 0.11.1
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 +182 -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 +51 -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 +43 -0
- package/cli/lib/cli-common.sh +12 -8
- package/cli/lib/gitignore.sh +215 -0
- package/cli/lib/manifest.sh +35 -1
- package/cli/lib/onboarding.sh +137 -0
- package/engine/ENGINE_SHA +1 -1
- package/engine/VERSION +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 +13 -2
- 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 +60 -21
- package/packages/sync/references/onboarding-migration.md +87 -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 +94 -38
- package/packages/sync/skills/intelligence-review-skills/SKILL.md +1 -1
- package/packages/sync/skills/intelligence-sync/SKILL.md +9 -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,88 @@ 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
|
+
onboarding_tx_active=0 onboarding_tx_root="" onboarding_tx_content=""
|
|
16
|
+
|
|
17
|
+
onboarding_transaction_exit() {
|
|
18
|
+
local rc=$?
|
|
19
|
+
trap - EXIT
|
|
20
|
+
if [ "$onboarding_tx_active" -eq 1 ]; then
|
|
21
|
+
restore_onboarding_legacy_sources "$onboarding_tx_root" "$onboarding_tx_content"
|
|
22
|
+
fi
|
|
23
|
+
exit "$rc"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
onboarding_transaction_begin() {
|
|
27
|
+
local tx_root="$1" tx_content="$2"
|
|
28
|
+
onboarding_quarantine_is_pending "$tx_root" "$tx_content" || return 0
|
|
29
|
+
onboarding_tx_root="$tx_root"
|
|
30
|
+
onboarding_tx_content="$tx_content"
|
|
31
|
+
onboarding_tx_active=1
|
|
32
|
+
trap onboarding_transaction_exit EXIT
|
|
33
|
+
quarantine_onboarding_legacy_sources "$tx_root" "$tx_content"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
onboarding_transaction_rollback() {
|
|
37
|
+
trap - EXIT
|
|
38
|
+
if [ "$onboarding_tx_active" -eq 1 ]; then
|
|
39
|
+
restore_onboarding_legacy_sources "$onboarding_tx_root" "$onboarding_tx_content"
|
|
40
|
+
fi
|
|
41
|
+
onboarding_tx_active=0
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
onboarding_transaction_commit() {
|
|
45
|
+
local tx_root="$1" tx_content="$2"
|
|
46
|
+
complete_onboarding_quarantine "$tx_root" "$tx_content"
|
|
47
|
+
onboarding_tx_active=0
|
|
48
|
+
trap - EXIT
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
print_new_project_onboarding() {
|
|
52
|
+
local heading="Intelligence ready"
|
|
53
|
+
[ "$no_sync" -eq 0 ] || heading="Next steps"
|
|
54
|
+
|
|
55
|
+
echo ""
|
|
56
|
+
echo "=== $heading ==="
|
|
57
|
+
if [ -n "${ONBOARDING_BACKUP_REL:-}" ]; then
|
|
58
|
+
echo " Existing AI instructions preserved:"
|
|
59
|
+
echo " $ONBOARDING_BACKUP_REL ($ONBOARDING_BACKUP_COUNT path(s))"
|
|
60
|
+
if [ "${ONBOARDING_LEGACY_COUNT:-0}" -gt 0 ]; then
|
|
61
|
+
echo " Legacy root entry points were quarantined before the successful render."
|
|
62
|
+
fi
|
|
63
|
+
if [ "$bare" -eq 0 ]; then
|
|
64
|
+
echo " The learn skill will migrate them before proposing backup removal."
|
|
65
|
+
else
|
|
66
|
+
echo " Review and migrate them before removing this backup."
|
|
67
|
+
fi
|
|
68
|
+
fi
|
|
69
|
+
if [ "$no_sync" -eq 1 ]; then
|
|
70
|
+
echo " Run first:"
|
|
71
|
+
echo " intelligence sync"
|
|
72
|
+
fi
|
|
73
|
+
if [ "$bare" -eq 0 ]; then
|
|
74
|
+
echo " Recommended starter package:"
|
|
75
|
+
echo " intelligence package add @ainova-systems/core"
|
|
76
|
+
echo " Install it before learning so package/project duplicates can be detected."
|
|
77
|
+
echo " Finalize repository onboarding:"
|
|
78
|
+
echo " Ask your agent to run /intelligence-learn-from-repository"
|
|
79
|
+
echo " It recognizes the initial backup, recovers setup if needed, then proposes repository-specific migration after approval."
|
|
80
|
+
fi
|
|
81
|
+
echo " Review adapters:"
|
|
82
|
+
echo " intelligence adapter list"
|
|
83
|
+
echo " intelligence adapter enable codex"
|
|
84
|
+
echo " intelligence adapter disable cursor"
|
|
85
|
+
echo " Version control:"
|
|
86
|
+
echo " Generated adapter output is gitignored by CLI-owned path."
|
|
87
|
+
echo " Commit intelligence.yaml, intelligence.lock, intelligence/, AGENTS.md, and .github/."
|
|
88
|
+
echo " Existing .vscodeignore, .npmignore, and .dockerignore files receive packaging exclusions."
|
|
89
|
+
echo " Shared tool settings remain trackable; review the exact ownership policy:"
|
|
90
|
+
echo " https://github.com/ainova-systems/intelligence/blob/main/packages/sync/references/conventions.md#generated-output-and-version-control"
|
|
91
|
+
report_tracked_managed_ignores "$root" "$manifest"
|
|
92
|
+
echo " Write your own:"
|
|
93
|
+
echo " create $content_dir/rules/context.md, then intelligence sync"
|
|
94
|
+
echo " Docs: https://github.com/ainova-systems/intelligence#readme"
|
|
95
|
+
}
|
|
96
|
+
|
|
15
97
|
while [ $# -gt 0 ]; do
|
|
16
98
|
case "$1" in
|
|
17
99
|
--targets) shift; targets_arg="${1:-}"; targets_set=1 ;;
|
|
@@ -34,14 +116,14 @@ esac
|
|
|
34
116
|
|
|
35
117
|
detect_project
|
|
36
118
|
case "$IP_MODE" in
|
|
37
|
-
|
|
119
|
+
cli)
|
|
38
120
|
[ "$targets_set" -eq 0 ] || die "--targets applies only when creating a new project"
|
|
39
121
|
[ "$dir_set" -eq 0 ] || die "--dir applies only when creating a new project"
|
|
40
122
|
[ "$bare_set" -eq 0 ] || die "--bare applies only when creating a new project"
|
|
41
|
-
[ "$force" -eq 0 ] || die "--force applies only when converting
|
|
123
|
+
[ "$force" -eq 0 ] || die "--force applies only when converting a legacy Intelligence Sync project"
|
|
42
124
|
if [ "$preview" -eq 1 ]; then
|
|
43
125
|
check_version_compat "$IP_ROOT/intelligence.yaml"
|
|
44
|
-
echo "project:
|
|
126
|
+
echo "project: Intelligence CLI at $IP_ROOT"
|
|
45
127
|
if project_needs_upgrade "$IP_ROOT"; then
|
|
46
128
|
echo " would align project lifecycle with engine $(bundled_engine_version)"
|
|
47
129
|
else
|
|
@@ -68,35 +150,56 @@ case "$IP_MODE" in
|
|
|
68
150
|
ensure_project_current "$IP_ROOT"
|
|
69
151
|
fi
|
|
70
152
|
restore_project_store_if_missing "$IP_ROOT"
|
|
153
|
+
ensure_manifest_gitignore "$IP_ROOT" "$IP_ROOT/intelligence.yaml"
|
|
154
|
+
ensure_manifest_publisher_ignores "$IP_ROOT" "$IP_ROOT/intelligence.yaml"
|
|
71
155
|
[ "$no_sync" -eq 1 ] && exit 0
|
|
156
|
+
content_dir="$(manifest_intelligence_dir "$IP_ROOT/intelligence.yaml")"
|
|
157
|
+
onboarding_transaction_begin "$IP_ROOT" "$content_dir"
|
|
72
158
|
cd "$IP_ROOT"
|
|
73
|
-
|
|
159
|
+
sync_rc=0
|
|
160
|
+
bash "$CLI_DIR/commands/sync.sh" || sync_rc=$?
|
|
161
|
+
if [ "$sync_rc" -ne 0 ]; then
|
|
162
|
+
onboarding_transaction_rollback
|
|
163
|
+
recovery_backup=""
|
|
164
|
+
if [ -f "$IP_ROOT/$content_dir/_backup/manifest.tsv" ]; then
|
|
165
|
+
recovery_backup="; initial backup: $content_dir/_backup/manifest.tsv"
|
|
166
|
+
fi
|
|
167
|
+
echo "" >&2
|
|
168
|
+
echo "=== Intelligence setup needs recovery ===" >&2
|
|
169
|
+
echo " No partial adapter update was kept; sync restored its pre-run outputs." >&2
|
|
170
|
+
echo " Ask your agent to read:" >&2
|
|
171
|
+
echo " $SYNC_PKG_STORE/skills/intelligence-learn-from-repository/SKILL.md" >&2
|
|
172
|
+
echo " and finalize this Intelligence setup$recovery_backup." >&2
|
|
173
|
+
fi
|
|
174
|
+
[ "$sync_rc" -ne 0 ] || onboarding_transaction_commit "$IP_ROOT" "$content_dir"
|
|
175
|
+
[ "$sync_rc" -ne 0 ] || report_tracked_managed_ignores "$IP_ROOT" "$IP_ROOT/intelligence.yaml"
|
|
176
|
+
exit "$sync_rc"
|
|
74
177
|
;;
|
|
75
178
|
legacy)
|
|
76
179
|
[ "$targets_set" -eq 0 ] || die "--targets applies only when creating a new project"
|
|
77
180
|
[ "$dir_set" -eq 0 ] || die "--dir applies only when creating a new project"
|
|
78
181
|
[ "$bare_set" -eq 0 ] || die "--bare applies only when creating a new project"
|
|
79
182
|
[ "$no_sync" -eq 0 ] || die "--no-sync cannot skip transactional conversion verification"
|
|
80
|
-
|
|
81
|
-
[ "$force" -eq 1 ] &&
|
|
183
|
+
conversion_args=()
|
|
184
|
+
[ "$force" -eq 1 ] && conversion_args+=(--force)
|
|
82
185
|
if [ "$preview" -eq 1 ]; then
|
|
83
|
-
exec bash "$CLI_DIR/internal/
|
|
186
|
+
exec bash "$CLI_DIR/internal/convert-legacy.sh" --dry-run ${conversion_args[@]+"${conversion_args[@]}"}
|
|
84
187
|
fi
|
|
85
188
|
if [ "$apply" -eq 1 ]; then
|
|
86
|
-
exec bash "$CLI_DIR/internal/
|
|
189
|
+
exec bash "$CLI_DIR/internal/convert-legacy.sh" ${conversion_args[@]+"${conversion_args[@]}"}
|
|
87
190
|
fi
|
|
88
|
-
bash "$CLI_DIR/internal/
|
|
89
|
-
[ -t 0 ] || die "
|
|
90
|
-
printf 'Apply this
|
|
191
|
+
bash "$CLI_DIR/internal/convert-legacy.sh" --dry-run ${conversion_args[@]+"${conversion_args[@]}"}
|
|
192
|
+
[ -t 0 ] || die "legacy project conversion requires confirmation — rerun 'intelligence init --apply'"
|
|
193
|
+
printf 'Apply this conversion? [Y/n] '
|
|
91
194
|
read -r answer
|
|
92
195
|
case "$answer" in
|
|
93
|
-
""|y|Y|yes|YES) exec bash "$CLI_DIR/internal/
|
|
94
|
-
*) echo "
|
|
196
|
+
""|y|Y|yes|YES) exec bash "$CLI_DIR/internal/convert-legacy.sh" ${conversion_args[@]+"${conversion_args[@]}"} ;;
|
|
197
|
+
*) echo "conversion cancelled"; exit 0 ;;
|
|
95
198
|
esac
|
|
96
199
|
;;
|
|
97
200
|
esac
|
|
98
201
|
|
|
99
|
-
[ "$force" -eq 0 ] || die "--force applies only when converting
|
|
202
|
+
[ "$force" -eq 0 ] || die "--force applies only when converting a legacy Intelligence Sync project"
|
|
100
203
|
root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
101
204
|
root="$(cd "$root" && pwd)"
|
|
102
205
|
assert_safe_content_dir "$root" "$content_dir"
|
|
@@ -117,17 +220,30 @@ if [ -n "$targets_arg" ]; then
|
|
|
117
220
|
done
|
|
118
221
|
else
|
|
119
222
|
if [ -d "$root/.claude" ] || [ -f "$root/CLAUDE.md" ]; then targets="$targets claude"; fi
|
|
120
|
-
[ -d "$root/.cursor" ]
|
|
121
|
-
[ -d "$root/.codex" ]
|
|
223
|
+
if [ -d "$root/.cursor" ] || [ -f "$root/.cursorrules" ]; then targets="$targets cursor"; fi
|
|
224
|
+
if [ -d "$root/.codex" ] || [ -d "$root/.agents" ]; then targets="$targets codex"; fi
|
|
122
225
|
[ -d "$root/.pi" ] && targets="$targets pi"
|
|
123
226
|
[ -d "$root/.opencode" ] && targets="$targets opencode"
|
|
124
|
-
|
|
227
|
+
if [ -f "$root/.github/copilot-instructions.md" ] \
|
|
228
|
+
|| [ -d "$root/.github/instructions" ] \
|
|
229
|
+
|| [ -d "$root/.github/agents" ] \
|
|
230
|
+
|| [ -d "$root/.github/skills" ]; then
|
|
231
|
+
targets="$targets copilot"
|
|
232
|
+
fi
|
|
125
233
|
if [ "$targets" = "agents" ]; then
|
|
126
234
|
echo " NOTE: no tool markers found (.claude/, CLAUDE.md, .cursor/, …) — only AGENTS.md is enabled." >&2
|
|
127
235
|
echo " Name your tools explicitly: intelligence init --targets claude,cursor (or edit targets: later)" >&2
|
|
128
236
|
fi
|
|
129
237
|
fi
|
|
130
238
|
|
|
239
|
+
onboarding_count="$(onboarding_source_count "$root" "$content_dir" "$targets")"
|
|
240
|
+
onboarding_has_agents=0
|
|
241
|
+
[ -f "$root/AGENTS.md" ] && onboarding_has_agents=1
|
|
242
|
+
if [ "$preview" -eq 0 ] && [ "$onboarding_count" -gt 0 ] \
|
|
243
|
+
&& [ -e "$root/$content_dir/_backup" ]; then
|
|
244
|
+
die "onboarding backup already exists at $content_dir/_backup - review or move it before rerunning init"
|
|
245
|
+
fi
|
|
246
|
+
|
|
131
247
|
if [ "$preview" -eq 1 ]; then
|
|
132
248
|
echo "project: no Intelligence setup found"
|
|
133
249
|
echo " would create intelligence.yaml and intelligence.lock"
|
|
@@ -141,6 +257,9 @@ if [ "$preview" -eq 1 ]; then
|
|
|
141
257
|
else
|
|
142
258
|
echo " would enable adapters:$targets, then sync"
|
|
143
259
|
fi
|
|
260
|
+
if [ "$onboarding_count" -gt 0 ]; then
|
|
261
|
+
echo " would preserve $onboarding_count existing AI instruction path(s) in $content_dir/_backup before sync"
|
|
262
|
+
fi
|
|
144
263
|
exit 0
|
|
145
264
|
fi
|
|
146
265
|
|
|
@@ -175,7 +294,21 @@ manifest="$root/intelligence.yaml"
|
|
|
175
294
|
echo "# Generated output, one entry per tool. Add or drop tools freely."
|
|
176
295
|
echo "targets:"
|
|
177
296
|
for t in $targets; do
|
|
178
|
-
|
|
297
|
+
if [ "$t" = "agents" ] && [ "$onboarding_has_agents" -eq 1 ]; then
|
|
298
|
+
echo " agents:"
|
|
299
|
+
echo " enabled: true"
|
|
300
|
+
echo " output: \"AGENTS.md\""
|
|
301
|
+
echo " header: |"
|
|
302
|
+
echo " > Intelligence onboarding is pending. Before repository work, read"
|
|
303
|
+
echo " > \`$content_dir/_backup/AGENTS.md\`, which preserves the original project instructions."
|
|
304
|
+
if [ "$bare" -eq 0 ]; then
|
|
305
|
+
echo " > Run /intelligence-learn-from-repository to migrate and verify them before removing the backup."
|
|
306
|
+
else
|
|
307
|
+
echo " > Review and migrate that backup before removing it."
|
|
308
|
+
fi
|
|
309
|
+
else
|
|
310
|
+
echo " $t: { enabled: true, output: \"$(default_target_output "$t")\" }"
|
|
311
|
+
fi
|
|
179
312
|
done
|
|
180
313
|
echo ""
|
|
181
314
|
echo "# Packages are managed with 'intelligence package add|search|list':"
|
|
@@ -202,13 +335,10 @@ manifest="$root/intelligence.yaml"
|
|
|
202
335
|
} > "$manifest"
|
|
203
336
|
|
|
204
337
|
# The package store is restorable state, never committed — the npm model.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
echo ".intelligence/"
|
|
210
|
-
} >> "$root/.gitignore"
|
|
211
|
-
fi
|
|
338
|
+
ensure_base_gitignore "$root"
|
|
339
|
+
for target in $targets; do
|
|
340
|
+
ensure_target_gitignore "$root" "$manifest" "$target"
|
|
341
|
+
done
|
|
212
342
|
|
|
213
343
|
# The engine's own content (meta-skills, authoring rule, engine agents) is an
|
|
214
344
|
# ordinary package: auto-selected, opted out with --bare, removable later with
|
|
@@ -218,16 +348,35 @@ if [ "$bare" -eq 0 ]; then
|
|
|
218
348
|
sync_pkg_install "$root"
|
|
219
349
|
fi
|
|
220
350
|
|
|
351
|
+
preserve_onboarding_sources "$root" "$content_dir" "$targets"
|
|
352
|
+
ensure_manifest_publisher_ignores "$root" "$manifest"
|
|
353
|
+
|
|
221
354
|
echo "initialized: intelligence.yaml (targets:$(printf ' %s' $targets))"
|
|
222
355
|
[ "$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
356
|
if [ "$no_sync" -eq 0 ]; then
|
|
357
|
+
onboarding_transaction_begin "$root" "$content_dir"
|
|
231
358
|
cd "$root"
|
|
232
|
-
|
|
359
|
+
sync_rc=0
|
|
360
|
+
echo ""
|
|
361
|
+
echo "=== Sync started ==="
|
|
362
|
+
echo " Rendering enabled adapters in compact mode..."
|
|
363
|
+
bash "$CLI_DIR/commands/sync.sh" --compact || sync_rc=$?
|
|
364
|
+
if [ "$sync_rc" -ne 0 ]; then
|
|
365
|
+
onboarding_transaction_rollback
|
|
366
|
+
echo "" >&2
|
|
367
|
+
echo "=== Intelligence setup needs recovery ===" >&2
|
|
368
|
+
echo " No partial adapter update was kept; sync restored its pre-run outputs." >&2
|
|
369
|
+
if [ "$bare" -eq 0 ]; then
|
|
370
|
+
echo " Ask your agent to read:" >&2
|
|
371
|
+
echo " $SYNC_PKG_STORE/skills/intelligence-learn-from-repository/SKILL.md" >&2
|
|
372
|
+
echo " and finalize the initial Intelligence setup. The snapshot is $content_dir/_backup/manifest.tsv." >&2
|
|
373
|
+
else
|
|
374
|
+
echo " Fix the reported error, then rerun: intelligence init" >&2
|
|
375
|
+
fi
|
|
376
|
+
exit "$sync_rc"
|
|
377
|
+
fi
|
|
378
|
+
onboarding_transaction_commit "$root" "$content_dir"
|
|
379
|
+
echo "=== Sync completed ==="
|
|
233
380
|
fi
|
|
381
|
+
|
|
382
|
+
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
|