@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/cli/lib/semver.sh CHANGED
@@ -75,10 +75,11 @@ semver_match() {
75
75
  # onto their tag.
76
76
  list_remote_versions() {
77
77
  local url="$1"
78
+ assert_safe_source_url "$url"
78
79
  # `|| true` inside the pipeline: an unreachable repo must read as "no
79
80
  # versions", not kill a pipefail caller mid-command-substitution —
80
81
  # reachability is the CALLER's question (add probes it explicitly).
81
- { GIT_TERMINAL_PROMPT=0 git ls-remote --tags "$url" 2>/dev/null || true; } \
82
+ { GIT_TERMINAL_PROMPT=0 git ls-remote --tags -- "$url" 2>/dev/null || true; } \
82
83
  | awk '{
83
84
  sub(/\r$/, "")
84
85
  ref = $2
@@ -95,7 +96,8 @@ list_remote_versions() {
95
96
  # prints "<tag> <sha>". Peeled sha (the commit a tag object points at) wins.
96
97
  remote_tag_for_version() {
97
98
  local url="$1" ver="${2#v}"
98
- { GIT_TERMINAL_PROMPT=0 git ls-remote --tags "$url" 2>/dev/null || true; } \
99
+ assert_safe_source_url "$url"
100
+ { GIT_TERMINAL_PROMPT=0 git ls-remote --tags -- "$url" 2>/dev/null || true; } \
99
101
  | awk -v want="$ver" '
100
102
  {
101
103
  sub(/\r$/, "")
@@ -0,0 +1 @@
1
+ f2bfc5e3722bf6fb2f7309db2d248368d5b0cc5e
@@ -1,22 +1,21 @@
1
1
  #!/bin/bash
2
- # intelligence-sync: Adapter template
3
- # Copy this file to create a new IDE adapter.
2
+ # Intelligence CLI: project adapter template
3
+ # Scaffold this file with: intelligence adapter create <name>
4
4
  #
5
5
  # This file is NOT executable as-is — `<name>` placeholders below would be
6
6
  # parsed by bash as input redirection (`<` operator). Replace every
7
7
  # occurrence with your adapter name before sourcing.
8
8
  #
9
9
  # Required:
10
- # 1. Name the file: <ide-name>.sh (e.g., myide.sh)
11
- # 2. Replace every `<name>` placeholder with your adapter name
12
- # 3. Implement sync_to_<name>() function
13
- # 4. Add target to config.yaml:
10
+ # 1. Implement sync_to_<name>() and its three content transforms
11
+ # 2. Enable it after implementation: intelligence adapter enable <name>
12
+ # This adds the target to intelligence.yaml when it is absent:
14
13
  # targets:
15
14
  # <name>: { enabled: true, output: ".<name>" }
16
15
  #
17
16
  # The sync_to_<name>() function receives:
18
17
  # $1 = repo_root — absolute path to the project root
19
- # $2 = config_file — absolute path to config.yaml
18
+ # $2 = config_file — absolute path to intelligence.yaml
20
19
  # $3 = output_dir — absolute path to the output directory (e.g., .myide/)
21
20
  #
22
21
  # Available library functions (from lib/common.sh):
@@ -29,10 +28,12 @@
29
28
  # get_model_default(ide, tier) — hardcoded default for ide:tier
30
29
  # map_access_to_claude_tools(access) — full->"" (no tools list; inherits all), readonly->restricted
31
30
  # map_access_to_claude_disallowed(access) — readonly->"Write, Edit", full->""
32
- # read_yaml_list(config, section) — read list from config.yaml
31
+ # read_yaml_list(manifest, section) — read a source list from intelligence.yaml
33
32
  # get_target_field(config, target, field) — read a target's config field
34
33
 
35
- source "$(dirname "${BASH_SOURCE[0]}")/../lib/common.sh"
34
+ # Project adapters are sourced by engine/sync.sh after the shared library is
35
+ # loaded. Keep this template position-independent: after scaffolding it lives
36
+ # under the project's content directory, not beside engine/lib/.
36
37
 
37
38
  # Sync rules for <agent-name>
38
39
  # Typical transformations:
@@ -13,25 +13,20 @@
13
13
 
14
14
  source "$(dirname "${BASH_SOURCE[0]}")/../lib/common.sh"
15
15
 
16
- # Repo-relative paths to the umbrella folder and the engine module, DERIVED —
17
- # never hardcoded. The umbrella is named by the project (`intelligence/`,
18
- # `Intelligence/`, a codename) and the engine lives in a module inside it;
19
- # detect_layout resolved both before any adapter ran. A literal path here would
20
- # print a sync command that does not exist, and would be wrong outright on a
21
- # case-sensitive filesystem — in the one document Cursor, Copilot and Codex all
22
- # read as canonical.
23
- # sync.sh exports both as layout tokens; recompute only when an adapter is
24
- # driven directly (tests), never assume a folder name.
25
- agents_md_umbrella_rel() {
26
- local repo_root="$1" rel="${IS_UMBRELLA_REL:-}"
27
- [ -n "$rel" ] || rel="$(repo_rel_dir "$repo_root" "${LS_UMBRELLA_DIR:-$repo_root/intelligence}")"
28
- printf '%s' "${rel:-intelligence}"
16
+ # Repo-relative paths to the project's content dir and to the installed sync
17
+ # package, taken from the env contract — never hardcoded. The content dir is
18
+ # named by the project (`intelligence/`, a codename) and the package sits in
19
+ # the store; a literal path here would print a sync command that does not
20
+ # exist, and would be wrong outright on a case-sensitive filesystem — in the
21
+ # one document Cursor, Copilot and Codex all read as canonical.
22
+ # The defaults only cover an adapter driven directly (tests); sync.sh always
23
+ # exports both.
24
+ agents_md_content_rel() {
25
+ printf '%s' "${IS_CONTENT_REL:-intelligence}"
29
26
  }
30
27
 
31
28
  agents_md_module_rel() {
32
- local repo_root="$1" rel="${IS_MODULE_REL:-}"
33
- [ -n "$rel" ] || rel="$(repo_rel_dir "$repo_root" "${LS_MODULE_DIR:-$repo_root/intelligence/sync}")"
34
- printf '%s' "${rel:-intelligence/sync}"
29
+ printf '%s' "${IS_MODULE_REL:-.intelligence/packages/@ainova-systems/sync}"
35
30
  }
36
31
 
37
32
  # Append the static header block from config.yaml (or a fallback).
@@ -201,14 +196,14 @@ agents_md_append_rules_list() {
201
196
  # Path-scoped rules stay in tool-specific channels (.cursor/rules/,
202
197
  # .github/instructions/) so monorepo scoping is preserved.
203
198
  if [ "${#global_rule_files[@]}" -gt 0 ]; then
204
- local umbrella_rel
205
- umbrella_rel="$(agents_md_umbrella_rel "$repo_root")"
199
+ local content_rel
200
+ content_rel="$(agents_md_content_rel "$repo_root")"
206
201
  {
207
202
  echo "---"
208
203
  echo ""
209
204
  echo "## Project Context"
210
205
  echo ""
211
- echo "<!-- Inlined from always-on rules in $umbrella_rel/rules/ -->"
206
+ echo "<!-- Inlined from always-on rules in $content_rel/rules/ -->"
212
207
  echo ""
213
208
  } >> "$output"
214
209
  local rf
@@ -245,17 +240,17 @@ sync_to_agents() {
245
240
 
246
241
  mkdir -p "$(dirname "$output_file")"
247
242
 
248
- local umbrella_rel module_rel
249
- umbrella_rel="$(agents_md_umbrella_rel "$repo_root")"
243
+ local content_rel module_rel
244
+ content_rel="$(agents_md_content_rel "$repo_root")"
250
245
  module_rel="$(agents_md_module_rel "$repo_root")"
251
246
 
252
247
  # These two strings are written into a COMMITTED file. An absolute path here
253
248
  # means the derivation failed, and a machine-specific path in AGENTS.md is
254
249
  # worse than a failed sync — fail loudly instead.
255
- case "$umbrella_rel$module_rel" in
250
+ case "$content_rel$module_rel" in
256
251
  /*|*:[\\/]*)
257
252
  echo " ERROR: AGENTS.md paths did not resolve relative to the repo root:" >&2
258
- echo " umbrella='$umbrella_rel' module='$module_rel' repo_root='$repo_root'" >&2
253
+ echo " content='$content_rel' module='$module_rel' repo_root='$repo_root'" >&2
259
254
  return 1
260
255
  ;;
261
256
  esac
@@ -266,7 +261,7 @@ sync_to_agents() {
266
261
 
267
262
  {
268
263
  echo "<!-- Generated by intelligence-sync. Do not edit manually. -->"
269
- echo "<!-- Source: $umbrella_rel/ | Sync: $sync_cmd -->"
264
+ echo "<!-- Source: $content_rel/ | Sync: $sync_cmd -->"
270
265
  echo ""
271
266
  } > "$output_file"
272
267
 
@@ -275,7 +270,7 @@ sync_to_agents() {
275
270
  {
276
271
  echo "## Intelligence"
277
272
  echo ""
278
- echo "Source of truth: \`$umbrella_rel/\` | Sync: \`$sync_cmd\`"
273
+ echo "Source of truth: \`$content_rel/\` | Sync: \`$sync_cmd\`"
279
274
  echo ""
280
275
  } >> "$output_file"
281
276
 
@@ -29,7 +29,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/../lib/common.sh"
29
29
  # Strip frontmatter, return body only.
30
30
  # Direct call to the shared `strip_frontmatter` helper in lib/common.sh —
31
31
  # duplicating the awk block here would violate the "all parsing in common.sh"
32
- # convention (see CLAUDE.md / docs/CONVENTIONS.md).
32
+ # convention (see CLAUDE.md / packages/sync/references/conventions.md).
33
33
 
34
34
  sync_opencode_skills() {
35
35
  local repo_root="$1"