|
1 | 1 | # Default: list available recipes |
| 2 | +set windows-shell := ["powershell.exe", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"] |
| 3 | + |
| 4 | +cargo_script := if os_family() == "windows" { "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/just/cargo.ps1" } else { "bash scripts/just/cargo.sh" } |
| 5 | +build_script := if os_family() == "windows" { "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/just/build.ps1" } else { "bash scripts/just/build.sh" } |
| 6 | +install_script := if os_family() == "windows" { "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/just/install.ps1" } else { "bash scripts/just/install.sh" } |
| 7 | +migration_check_script := if os_family() == "windows" { "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/migration/check-immutability.ps1" } else { "bash scripts/migration/check-immutability.sh" } |
| 8 | +migration_check_test_script := if os_family() == "windows" { "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/migration/check-immutability.test.ps1" } else { "bash scripts/migration/check-immutability.test.sh" } |
| 9 | +auto_commit_script := if os_family() == "windows" { "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/just/auto-commit-fixes.ps1" } else { "bash scripts/just/auto-commit-fixes.sh" } |
| 10 | +update_aionrs_script := if os_family() == "windows" { "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/just/update-aionrs.ps1" } else { "bash scripts/just/update-aionrs.sh" } |
| 11 | +cat_config_script := if os_family() == "windows" { "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/just/cat-config.ps1" } else { "bash scripts/just/cat-config.sh" } |
| 12 | + |
2 | 13 | default: |
3 | 14 | @just --list |
4 | 15 |
|
5 | 16 | # Enable pre-commit hooks (run once after clone) |
6 | 17 | setup: |
7 | 18 | git config core.hooksPath .githooks |
8 | | - @echo "✅ Git hooks enabled" |
| 19 | + @echo "Git hooks enabled" |
9 | 20 |
|
10 | 21 | # Run cargo with optional local aionrs SDK patches. |
11 | 22 | _cargo *ARGS: |
12 | | - #!/usr/bin/env bash |
13 | | - set -euo pipefail |
14 | | -
|
15 | | - restore_cargo_lock=false |
16 | | - cargo_lock_snapshot="" |
17 | | - cargo_config_file=".cargo/config.toml" |
18 | | - cargo_config_snapshot="" |
19 | | - cargo_config_created=false |
20 | | - aionrs_root="" |
21 | | -
|
22 | | - restore_local_state() { |
23 | | - local status=$? |
24 | | -
|
25 | | - if [[ -n "$cargo_lock_snapshot" && -f "$cargo_lock_snapshot" ]]; then |
26 | | - if [[ "$restore_cargo_lock" == "true" || "$status" -ne 0 ]]; then |
27 | | - cp "$cargo_lock_snapshot" Cargo.lock || status=$? |
28 | | - fi |
29 | | - fi |
30 | | - if [[ -n "$cargo_lock_snapshot" ]]; then |
31 | | - rm -f "$cargo_lock_snapshot" |
32 | | - fi |
33 | | -
|
34 | | - if [[ -n "$cargo_config_snapshot" && -f "$cargo_config_snapshot" ]]; then |
35 | | - cp "$cargo_config_snapshot" "$cargo_config_file" || status=$? |
36 | | - rm -f "$cargo_config_snapshot" |
37 | | - elif [[ "$cargo_config_created" == "true" ]]; then |
38 | | - rm -f "$cargo_config_file" |
39 | | - rmdir .cargo 2>/dev/null || true |
40 | | - fi |
41 | | -
|
42 | | - return "$status" |
43 | | - } |
44 | | - trap restore_local_state EXIT |
45 | | -
|
46 | | - verify_local_aionrs_patch() { |
47 | | - local crate expected_path pkgid |
48 | | - for crate in "${crates[@]}"; do |
49 | | - expected_path="$aionrs_root/crates/$crate" |
50 | | - pkgid=$(cargo pkgid -p "$crate") |
51 | | -
|
52 | | - if ! python3 -c 'import sys; from pathlib import Path; from urllib.parse import unquote, urlparse; pkgid=sys.argv[1]; expected=str(Path(sys.argv[2]).resolve()); ok=pkgid.startswith("path+file://") and str(Path(unquote(urlparse(pkgid[len("path+"):]).path)).resolve()) == expected; sys.exit(0 if ok else 1)' "$pkgid" "$expected_path" |
53 | | - then |
54 | | - echo "AIONRS patch was not used for $crate." >&2 |
55 | | - echo " resolved: $pkgid" >&2 |
56 | | - echo " expected: $expected_path" >&2 |
57 | | - exit 1 |
58 | | - fi |
59 | | - done |
60 | | - } |
61 | | -
|
62 | | - if [[ -n "${AIONRS:-}" ]]; then |
63 | | - if [[ ! -d "$AIONRS" ]]; then |
64 | | - echo "AIONRS does not exist or is not a directory: $AIONRS" >&2 |
65 | | - exit 1 |
66 | | - fi |
67 | | -
|
68 | | - aionrs_root=$(cd "$AIONRS" && pwd -P) |
69 | | - crates=( |
70 | | - aion-agent |
71 | | - aion-compact |
72 | | - aion-config |
73 | | - aion-mcp |
74 | | - aion-memory |
75 | | - aion-process |
76 | | - aion-protocol |
77 | | - aion-providers |
78 | | - aion-skills |
79 | | - aion-tools |
80 | | - aion-types |
81 | | - ) |
82 | | -
|
83 | | - patch_config=$(mktemp) |
84 | | - { |
85 | | - echo |
86 | | - echo "[patch.'https://github.com/iOfficeAI/aionrs.git']" |
87 | | - } > "$patch_config" |
88 | | -
|
89 | | - for crate in "${crates[@]}"; do |
90 | | - crate_dir="$aionrs_root/crates/$crate" |
91 | | - if [[ ! -f "$crate_dir/Cargo.toml" ]]; then |
92 | | - echo "AIONRS is missing $crate: $crate_dir/Cargo.toml" >&2 |
93 | | - exit 1 |
94 | | - fi |
95 | | -
|
96 | | - toml_path=${crate_dir//\\/\\\\} |
97 | | - toml_path=${toml_path//\"/\\\"} |
98 | | - echo "$crate = { path = \"$toml_path\" }" >> "$patch_config" |
99 | | - done |
100 | | -
|
101 | | - mkdir -p .cargo |
102 | | - if [[ -f "$cargo_config_file" ]]; then |
103 | | - cargo_config_snapshot=$(mktemp) |
104 | | - cp "$cargo_config_file" "$cargo_config_snapshot" |
105 | | - else |
106 | | - cargo_config_created=true |
107 | | - fi |
108 | | - cat "$patch_config" >> "$cargo_config_file" |
109 | | - rm -f "$patch_config" |
110 | | -
|
111 | | - echo "Using local aionrs SDK: $aionrs_root" >&2 |
112 | | -
|
113 | | - if [[ -f Cargo.lock ]]; then |
114 | | - cargo_lock_snapshot=$(mktemp) |
115 | | - cp Cargo.lock "$cargo_lock_snapshot" |
116 | | -
|
117 | | - if git diff --quiet -- Cargo.lock && git diff --cached --quiet -- Cargo.lock; then |
118 | | - restore_cargo_lock=true |
119 | | - else |
120 | | - echo "Cargo.lock already has changes; leaving successful AIONRS lockfile updates in place." >&2 |
121 | | - fi |
122 | | - fi |
123 | | -
|
124 | | - echo "Resolving Cargo.lock against local aionrs SDK" >&2 |
125 | | - update_args=() |
126 | | - for crate in "${crates[@]}"; do |
127 | | - update_args+=(-p "$crate") |
128 | | - done |
129 | | - cargo update "${update_args[@]}" |
130 | | - verify_local_aionrs_patch |
131 | | - fi |
132 | | -
|
133 | | - args=({{ARGS}}) |
134 | | -
|
135 | | - set +e |
136 | | - cargo "${args[@]}" |
137 | | - status=$? |
138 | | - set -e |
139 | | - exit "$status" |
| 23 | + @{{cargo_script}} {{ARGS}} |
140 | 24 |
|
141 | | -# Build in release mode and install to ~/.cargo/bin |
| 25 | +# Build in release mode and install to cargo bin |
142 | 26 | # Use `just build --force` to skip cache check |
143 | 27 | build *FLAGS: lint-fix fmt |
144 | | - #!/usr/bin/env bash |
145 | | - set -euo pipefail |
146 | | - just _cargo build --release |
147 | | - new_sum=$(shasum -a 256 target/release/aioncore | cut -d' ' -f1) |
148 | | - force=false |
149 | | - for flag in {{FLAGS}}; do |
150 | | - if [[ "$flag" == "--force" || "$flag" == "-f" ]]; then |
151 | | - force=true |
152 | | - fi |
153 | | - done |
154 | | - old_sum="" |
155 | | - if [[ -f target/.build-sum ]] && [[ "$force" == "false" ]]; then |
156 | | - old_sum=$(cat target/.build-sum) |
157 | | - fi |
158 | | - if [[ "$new_sum" == "$old_sum" ]]; then |
159 | | - echo -e "\n⏭️ Binary unchanged — skipping install (sha256: ${new_sum:0:16}…)" |
160 | | - else |
161 | | - cp target/release/aioncore ~/.cargo/bin/ |
162 | | - codesign --force --sign - ~/.cargo/bin/aioncore |
163 | | - echo "$new_sum" > target/.build-sum |
164 | | - echo -e "\n✅ Build complete — sha256: ${new_sum:0:16}…" |
165 | | - fi |
| 28 | + @{{build_script}} release {{FLAGS}} |
166 | 29 |
|
167 | 30 | # Build in debug mode |
168 | 31 | # Use `just build-debug --force` to skip cache check |
169 | 32 | build-debug *FLAGS: |
170 | | - #!/usr/bin/env bash |
171 | | - set -euo pipefail |
172 | | - just _cargo build |
173 | | - new_sum=$(shasum -a 256 target/debug/aioncore | cut -d' ' -f1) |
174 | | - force=false |
175 | | - for flag in {{FLAGS}}; do |
176 | | - if [[ "$flag" == "--force" || "$flag" == "-f" ]]; then |
177 | | - force=true |
178 | | - fi |
179 | | - done |
180 | | - old_sum="" |
181 | | - if [[ -f target/.build-debug-sum ]] && [[ "$force" == "false" ]]; then |
182 | | - old_sum=$(cat target/.build-debug-sum) |
183 | | - fi |
184 | | - if [[ "$new_sum" == "$old_sum" ]]; then |
185 | | - echo -e "\n⏭️ Debug binary unchanged (sha256: ${new_sum:0:16}…)" |
186 | | - else |
187 | | - echo "$new_sum" > target/.build-debug-sum |
188 | | - echo -e "\n✅ Debug build complete — sha256: ${new_sum:0:16}…" |
189 | | - fi |
| 33 | + @{{build_script}} debug {{FLAGS}} |
190 | 34 |
|
191 | 35 | install: |
192 | | - cp target/release/aioncore ~/.cargo/bin/ |
193 | | - codesign --force --sign - ~/.cargo/bin/aioncore |
| 36 | + @{{install_script}} release |
194 | 37 |
|
195 | 38 | # Run all tests |
196 | 39 | test: |
197 | | - just _cargo nextest run --workspace |
| 40 | + @just _cargo nextest run --workspace |
198 | 41 |
|
199 | 42 | # Ensure already-shipped database migrations stay immutable |
200 | 43 | migration-check: |
201 | | - scripts/check-migration-immutability.sh |
| 44 | + @{{migration_check_script}} |
202 | 45 |
|
203 | 46 | # Test the migration immutability guard itself |
204 | 47 | migration-check-test: |
205 | | - scripts/check-migration-immutability.test.sh |
| 48 | + @{{migration_check_test_script}} |
206 | 49 |
|
207 | 50 | # Lint (warnings = errors) |
208 | 51 | lint: |
209 | | - just _cargo clippy --workspace -- -D warnings |
| 52 | + @just _cargo clippy --workspace -- -D warnings |
210 | 53 |
|
211 | 54 | lint-fix: |
212 | | - just _cargo fix --allow-dirty --allow-staged |
213 | | - just _cargo clippy --fix --workspace --allow-dirty --allow-staged -- -D warnings |
| 55 | + @just _cargo fix --allow-dirty --allow-staged |
| 56 | + @just _cargo clippy --fix --workspace --allow-dirty --allow-staged -- -D warnings |
214 | 57 |
|
215 | 58 | # Format code |
216 | 59 | fmt: |
217 | | - cargo fmt --all |
| 60 | + @cargo fmt --all |
218 | 61 |
|
219 | 62 | # Check formatting (CI) |
220 | 63 | fmt-check: |
221 | | - cargo fmt --all -- --check |
| 64 | + @cargo fmt --all -- --check |
222 | 65 |
|
223 | 66 | # Lint + format check + migration check + test |
224 | 67 | check: migration-check lint fmt-check test |
225 | 68 |
|
226 | 69 | # Run the server (debug) |
227 | 70 | run *ARGS: |
228 | | - just _cargo run --bin aioncore -- {{ARGS}} |
| 71 | + @just _cargo run --bin aioncore -- {{ARGS}} |
229 | 72 |
|
230 | 73 | # Run the server (release) |
231 | 74 | run-release *ARGS: |
232 | | - just _cargo run --release --bin aioncore -- {{ARGS}} |
| 75 | + @just _cargo run --release --bin aioncore -- {{ARGS}} |
233 | 76 |
|
234 | 77 | # Pre-push gate: migration check, format, lint, auto-commit fixes, test, then push |
235 | 78 | push *ARGS: migration-check lint-fix fmt _auto-commit-fixes test |
236 | | - git push {{ ARGS }} |
| 79 | + git push {{ARGS}} |
237 | 80 |
|
238 | 81 | # Auto-commit any formatting/lint fixes if there are changes |
239 | 82 | _auto-commit-fixes: |
240 | | - #!/usr/bin/env bash |
241 | | - if [ -n "$(git diff --name-only)" ]; then |
242 | | - git add -A |
243 | | - git commit -m "chore: apply auto-fixes (fmt + clippy)" |
244 | | - fi |
| 83 | + @{{auto_commit_script}} |
245 | 84 |
|
246 | 85 | # Update aionrs dependency (e.g. just update-aionrs or just update-aionrs v0.1.19) |
247 | 86 | update-aionrs *TAG: |
248 | | - #!/usr/bin/env bash |
249 | | - set -euo pipefail |
250 | | - tag="{{ TAG }}" |
251 | | - if [ -z "$tag" ]; then |
252 | | - tag=$(git ls-remote --tags https://github.com/iOfficeAI/aionrs.git | awk -F/ '{print $NF}' | grep -v '\\^{}' | sort -V | tail -1) |
253 | | - echo "Using latest tag: $tag" |
254 | | - fi |
255 | | - sed -i '' "s|git = \"https://github.com/iOfficeAI/aionrs.git\", tag = \"[^\"]*\"|git = \"https://github.com/iOfficeAI/aionrs.git\", tag = \"$tag\"|g" Cargo.toml |
256 | | - cargo check --workspace |
| 87 | + @{{update_aionrs_script}} {{TAG}} |
257 | 88 |
|
258 | 89 | # Security audit |
259 | 90 | audit: |
260 | | - cargo audit |
| 91 | + @cargo audit |
261 | 92 |
|
262 | 93 | # Clean build artifacts |
263 | 94 | clean: |
264 | | - cargo clean |
| 95 | + @cargo clean |
265 | 96 |
|
266 | | -# Decode dev config and copy to clipboard |
| 97 | +# Decode dev config and copy to clipboard when possible |
267 | 98 | cat-config: |
268 | | - @base64 -D -i ~/.aionui-config-dev/aionui-config.txt | python3 -c 'import sys, urllib.parse; print(urllib.parse.unquote(sys.stdin.read()))' | pbcopy |
| 99 | + @{{cat_config_script}} |
0 commit comments