@ainova-systems/intelligence 0.11.0-rc.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/LICENSE +21 -0
- package/README.md +46 -0
- package/bin/intelligence.js +59 -0
- package/cli/commands/add.sh +133 -0
- package/cli/commands/doctor.sh +100 -0
- package/cli/commands/init.sh +96 -0
- package/cli/commands/install.sh +84 -0
- package/cli/commands/list.sh +28 -0
- package/cli/commands/migrate.sh +251 -0
- package/cli/commands/registry.sh +51 -0
- package/cli/commands/remove.sh +39 -0
- package/cli/commands/status.sh +34 -0
- package/cli/commands/sync.sh +22 -0
- package/cli/commands/update.sh +59 -0
- package/cli/commands/upgrade.sh +27 -0
- package/cli/intelligence +71 -0
- package/cli/lib/cli-common.sh +149 -0
- package/cli/lib/lockfile.sh +97 -0
- package/cli/lib/manifest.sh +211 -0
- package/cli/lib/registry.sh +141 -0
- package/cli/lib/semver.sh +127 -0
- package/engine/INIT.md +498 -0
- package/engine/agents/intelligence-architect.md +53 -0
- package/engine/agents/intelligence-operator.md +49 -0
- package/engine/docs/ADAPTERS.md +212 -0
- package/engine/docs/CLI.md +91 -0
- package/engine/docs/CONVENTIONS.md +440 -0
- package/engine/rules/intelligence-authoring.md +114 -0
- package/engine/scripts/VERSION +1 -0
- package/engine/scripts/adapters/_template.sh +86 -0
- package/engine/scripts/adapters/agents.sh +299 -0
- package/engine/scripts/adapters/claude.sh +136 -0
- package/engine/scripts/adapters/codex.sh +118 -0
- package/engine/scripts/adapters/copilot.sh +193 -0
- package/engine/scripts/adapters/cursor.sh +146 -0
- package/engine/scripts/adapters/opencode.sh +200 -0
- package/engine/scripts/adapters/pi.sh +256 -0
- package/engine/scripts/lib/common.sh +1602 -0
- package/engine/scripts/lib/layout.sh +51 -0
- package/engine/scripts/lib/migrations.sh +708 -0
- package/engine/scripts/sync.sh +311 -0
- package/engine/scripts/update.sh +237 -0
- package/engine/skills/intelligence-add-agent/SKILL.md +62 -0
- package/engine/skills/intelligence-add-rule/SKILL.md +54 -0
- package/engine/skills/intelligence-add-skill/SKILL.md +53 -0
- package/engine/skills/intelligence-extract-skill/SKILL.md +47 -0
- package/engine/skills/intelligence-install-adapter/SKILL.md +31 -0
- package/engine/skills/intelligence-learn-from-context/SKILL.md +69 -0
- package/engine/skills/intelligence-review-skills/SKILL.md +86 -0
- package/engine/skills/intelligence-sync/SKILL.md +18 -0
- package/engine/skills/intelligence-uninstall-adapter/SKILL.md +42 -0
- package/engine/skills/intelligence-update/SKILL.md +159 -0
- package/package.json +39 -0
- package/registry/index.yaml +15 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# intelligence-sync: Pi adapter
|
|
3
|
+
# Transforms source prompts to Pi's native resource model.
|
|
4
|
+
#
|
|
5
|
+
# Rules:
|
|
6
|
+
# - Always-on (no `paths:`) -> SKIPPED here. Pi reads AGENTS.md natively.
|
|
7
|
+
# - Path-scoped (with `paths:`) -> copied to .pi/intelligence-sync/rules/
|
|
8
|
+
# and surfaced via a generated Pi extension that lists them in the system
|
|
9
|
+
# prompt so the model can `read` the relevant rule on demand.
|
|
10
|
+
# Skills:
|
|
11
|
+
# - Copied to .agents/skills/ (Agent Skills open standard, read by Pi)
|
|
12
|
+
# Agents:
|
|
13
|
+
# - Converted to .pi/prompts/intelligence-agent-<name>.md prompt templates
|
|
14
|
+
# so users can invoke a persona explicitly via `/intelligence-agent-<name>`.
|
|
15
|
+
|
|
16
|
+
source "$(dirname "${BASH_SOURCE[0]}")/../lib/common.sh"
|
|
17
|
+
|
|
18
|
+
pi_ts_escape() {
|
|
19
|
+
local s="$1"
|
|
20
|
+
s="${s//\\/\\\\}"
|
|
21
|
+
s="${s//\"/\\\"}"
|
|
22
|
+
s="${s//$'\r'/}"
|
|
23
|
+
s="${s//$'\n'/ }"
|
|
24
|
+
printf '%s' "$s"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
pi_rule_paths() {
|
|
28
|
+
local file="$1"
|
|
29
|
+
awk '
|
|
30
|
+
{ sub(/\r$/, "") }
|
|
31
|
+
NR == 1 && $0 != "---" { exit }
|
|
32
|
+
NR == 1 { in_fm = 1; next }
|
|
33
|
+
in_fm && $0 == "---" { exit }
|
|
34
|
+
!in_fm { next }
|
|
35
|
+
|
|
36
|
+
/^paths:[[:space:]]*$/ { in_paths = 1; next }
|
|
37
|
+
in_paths && /^ - / {
|
|
38
|
+
val = $0
|
|
39
|
+
sub(/^ - /, "", val)
|
|
40
|
+
gsub(/^["\047]|["\047]$/, "", val)
|
|
41
|
+
print val
|
|
42
|
+
next
|
|
43
|
+
}
|
|
44
|
+
in_paths && !/^ - / && !/^[[:space:]]*$/ { exit }
|
|
45
|
+
' "$file"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
pi_agent_body() {
|
|
49
|
+
# Thin alias around the shared helper in lib/common.sh; kept so older call
|
|
50
|
+
# sites (and any future adapter logic) read symmetrically with sync_pi_*.
|
|
51
|
+
strip_frontmatter "$1"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
sync_pi_rules() {
|
|
55
|
+
local repo_root="$1"
|
|
56
|
+
local config_file="$2"
|
|
57
|
+
local output_dir="$3"
|
|
58
|
+
|
|
59
|
+
local rules_root="$output_dir/intelligence-sync/rules"
|
|
60
|
+
local extension_file="$output_dir/extensions/intelligence-sync-rules.ts"
|
|
61
|
+
local output_rel="${output_dir#$repo_root/}"
|
|
62
|
+
local manifest=""
|
|
63
|
+
local count=0
|
|
64
|
+
|
|
65
|
+
mkdir -p "$rules_root" "$(dirname "$extension_file")"
|
|
66
|
+
|
|
67
|
+
while IFS= read -r src; do
|
|
68
|
+
[ -z "$src" ] && continue
|
|
69
|
+
local dir
|
|
70
|
+
dir="$(resolve_source_dir "$repo_root" "$src")"
|
|
71
|
+
[ -d "$dir" ] || continue
|
|
72
|
+
for f in "$dir"/*.md; do
|
|
73
|
+
[ -f "$f" ] || continue
|
|
74
|
+
local hp
|
|
75
|
+
hp=$(has_paths "$f")
|
|
76
|
+
[ "$hp" -eq 0 ] && continue
|
|
77
|
+
|
|
78
|
+
local base rel_rule_path patterns_js display sep display_sep
|
|
79
|
+
base="$(basename "$f")"
|
|
80
|
+
rel_rule_path="$output_rel/intelligence-sync/rules/$base"
|
|
81
|
+
patterns_js=""
|
|
82
|
+
display=""
|
|
83
|
+
sep=""
|
|
84
|
+
display_sep=""
|
|
85
|
+
|
|
86
|
+
cp "$f" "$rules_root/$base"
|
|
87
|
+
finalize_output_file "$rules_root/$base"
|
|
88
|
+
|
|
89
|
+
while IFS= read -r pat; do
|
|
90
|
+
[ -z "$pat" ] && continue
|
|
91
|
+
local pat_escaped
|
|
92
|
+
pat_escaped="$(pi_ts_escape "$pat")"
|
|
93
|
+
patterns_js+="$sep\"$pat_escaped\""
|
|
94
|
+
display+="$display_sep$pat"
|
|
95
|
+
sep=", "
|
|
96
|
+
display_sep=", "
|
|
97
|
+
done < <(pi_rule_paths "$f")
|
|
98
|
+
|
|
99
|
+
manifest+=" { path: \"$(pi_ts_escape "$rel_rule_path")\", patterns: [$patterns_js] },"$'\n'
|
|
100
|
+
count=$((count + 1))
|
|
101
|
+
echo " rule: $base (scoped${display:+ — $display})"
|
|
102
|
+
done
|
|
103
|
+
done < <(read_yaml_list "$config_file" "rules")
|
|
104
|
+
|
|
105
|
+
if [ "$count" -gt 0 ]; then
|
|
106
|
+
{
|
|
107
|
+
cat <<'EOF'
|
|
108
|
+
/**
|
|
109
|
+
* Generated by intelligence-sync. Do not edit manually.
|
|
110
|
+
* Lists path-scoped project rules generated from intelligence/rules/.
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
114
|
+
|
|
115
|
+
const scopedRules: Array<{ path: string; patterns: string[] }> = [
|
|
116
|
+
EOF
|
|
117
|
+
printf '%s' "$manifest"
|
|
118
|
+
cat <<'EOF'
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
export default function intelligenceSyncRulesExtension(pi: ExtensionAPI) {
|
|
122
|
+
pi.on("before_agent_start", async (event) => {
|
|
123
|
+
if (scopedRules.length === 0) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const rulesList = scopedRules
|
|
128
|
+
.map((rule) => `- ${rule.path} — paths: ${rule.patterns.join(", ")}`)
|
|
129
|
+
.join("\n");
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
systemPrompt:
|
|
133
|
+
event.systemPrompt +
|
|
134
|
+
`
|
|
135
|
+
|
|
136
|
+
## Scoped Project Rules
|
|
137
|
+
|
|
138
|
+
AGENTS.md already carries the always-on project rules. Additional path-scoped rules are available on demand:
|
|
139
|
+
|
|
140
|
+
${rulesList}
|
|
141
|
+
|
|
142
|
+
When the task touches files that match one of these path patterns, use the read tool to load the relevant rule file before making changes.`,
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
EOF
|
|
147
|
+
} > "$extension_file"
|
|
148
|
+
finalize_output_file "$extension_file"
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
echo " -> Rules: $count scoped"
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
sync_pi_skills() {
|
|
155
|
+
local repo_root="$1"
|
|
156
|
+
local config_file="$2"
|
|
157
|
+
local _output_dir="$3"
|
|
158
|
+
|
|
159
|
+
# Skills -> .agents/skills/ (open standard; Pi reads it natively).
|
|
160
|
+
# `sync_open_skill_dirs` owns clean + populate of this shared dir.
|
|
161
|
+
local skills_dir="$repo_root/.agents/skills"
|
|
162
|
+
sync_open_skill_dirs "$repo_root" "$config_file" "$skills_dir"
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
sync_pi_agents() {
|
|
166
|
+
local repo_root="$1"
|
|
167
|
+
local config_file="$2"
|
|
168
|
+
local output_dir="$3"
|
|
169
|
+
|
|
170
|
+
local prompts_dir="$output_dir/prompts"
|
|
171
|
+
local count=0
|
|
172
|
+
|
|
173
|
+
mkdir -p "$prompts_dir"
|
|
174
|
+
|
|
175
|
+
while IFS= read -r src; do
|
|
176
|
+
[ -z "$src" ] && continue
|
|
177
|
+
local dir
|
|
178
|
+
dir="$(resolve_source_dir "$repo_root" "$src")"
|
|
179
|
+
[ -d "$dir" ] || continue
|
|
180
|
+
for f in "$dir"/*.md; do
|
|
181
|
+
[ -f "$f" ] || continue
|
|
182
|
+
|
|
183
|
+
local name rel desc access template_desc body prompt_file access_note
|
|
184
|
+
name="$(basename "$f" .md)"
|
|
185
|
+
rel="$(repo_rel_link "$repo_root" "$f")"
|
|
186
|
+
desc="$(get_frontmatter_value "description" "$f")"
|
|
187
|
+
access="$(get_frontmatter_value "access" "$f")"
|
|
188
|
+
body="$(pi_agent_body "$f")"
|
|
189
|
+
prompt_file="$prompts_dir/intelligence-agent-$name.md"
|
|
190
|
+
|
|
191
|
+
template_desc="Use $name persona"
|
|
192
|
+
[ -n "$desc" ] && template_desc="$template_desc — $desc"
|
|
193
|
+
|
|
194
|
+
access_note=""
|
|
195
|
+
if [ "$access" = "readonly" ]; then
|
|
196
|
+
access_note=$(cat <<'EOF'
|
|
197
|
+
## Access Mode
|
|
198
|
+
|
|
199
|
+
Default to read-only analysis. Do not change files or run mutating commands unless the user explicitly asks you to override this agent's normal restriction.
|
|
200
|
+
|
|
201
|
+
EOF
|
|
202
|
+
)
|
|
203
|
+
fi
|
|
204
|
+
|
|
205
|
+
{
|
|
206
|
+
echo "---"
|
|
207
|
+
echo "description: \"$(yaml_dq_escape "$template_desc")\""
|
|
208
|
+
echo "argument-hint: \"[task]\""
|
|
209
|
+
echo "---"
|
|
210
|
+
echo ""
|
|
211
|
+
echo "<!-- Generated by intelligence-sync. Do not edit manually. -->"
|
|
212
|
+
echo ""
|
|
213
|
+
printf 'Adopt the `%s` agent persona for this task.\n' "$name"
|
|
214
|
+
echo ""
|
|
215
|
+
printf 'Source: `%s`\n' "${rel:-$name (remote pack)}"
|
|
216
|
+
if [ -n "$desc" ]; then
|
|
217
|
+
echo "Use this persona when: $desc"
|
|
218
|
+
echo ""
|
|
219
|
+
fi
|
|
220
|
+
if [ -n "$access_note" ]; then
|
|
221
|
+
printf '%s\n' "$access_note"
|
|
222
|
+
fi
|
|
223
|
+
echo "## Agent Instructions"
|
|
224
|
+
echo ""
|
|
225
|
+
printf '%s\n' "$body"
|
|
226
|
+
echo ""
|
|
227
|
+
echo "User task: \$@"
|
|
228
|
+
} > "$prompt_file"
|
|
229
|
+
finalize_output_file "$prompt_file"
|
|
230
|
+
count=$((count + 1))
|
|
231
|
+
echo " agent: intelligence-agent-$name.md"
|
|
232
|
+
done
|
|
233
|
+
done < <(read_yaml_list "$config_file" "agents")
|
|
234
|
+
|
|
235
|
+
echo " -> Agents: $count prompt template(s)"
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
sync_to_pi() {
|
|
239
|
+
local repo_root="$1"
|
|
240
|
+
local config_file="$2"
|
|
241
|
+
local output_dir="$3"
|
|
242
|
+
|
|
243
|
+
echo "=== Pi ==="
|
|
244
|
+
|
|
245
|
+
local prompts_dir="$output_dir/prompts"
|
|
246
|
+
local extensions_dir="$output_dir/extensions"
|
|
247
|
+
|
|
248
|
+
rm -rf "$output_dir/intelligence-sync"
|
|
249
|
+
mkdir -p "$prompts_dir" "$extensions_dir"
|
|
250
|
+
find "$prompts_dir" -mindepth 1 -maxdepth 1 -type f -name 'intelligence-agent-*.md' -delete 2>/dev/null || true
|
|
251
|
+
rm -f "$extensions_dir/intelligence-sync-rules.ts"
|
|
252
|
+
|
|
253
|
+
sync_pi_rules "$repo_root" "$config_file" "$output_dir"
|
|
254
|
+
sync_pi_skills "$repo_root" "$config_file" "$output_dir"
|
|
255
|
+
sync_pi_agents "$repo_root" "$config_file" "$output_dir"
|
|
256
|
+
}
|