Skip to content

Commit 8e9a30b

Browse files
committed
agnix setup
1 parent da595b5 commit 8e9a30b

4 files changed

Lines changed: 119 additions & 10 deletions

File tree

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,45 @@ This repository contains system prompts, agent configuration patterns, and evals
1212

1313
Built by [CroCoder](https://www.crocoder.dev/)
1414

15+
## Dev shell agnix tooling
16+
17+
This repository exposes `agnix` and `agnix-lsp` through `nix develop` using a Nix-first shell with Rust toolchain support.
18+
19+
### Quick start
20+
21+
```bash
22+
nix develop
23+
agnix --help
24+
agnix-lsp --help
25+
```
26+
27+
### Shell behavior
28+
29+
- On shell entry, `shellHook` adds `~/.cargo/bin` to `PATH`.
30+
- If `agnix` is missing, `shellHook` automatically runs `cargo install --locked agnix-cli`.
31+
- `agnix-lsp` is provided by a shim that resolves in this order:
32+
1. `AGNIX_LSP_BIN` (when set to an executable path)
33+
2. `~/.cargo/bin/agnix-lsp`
34+
3. A manual-install guidance message (non-zero exit)
35+
36+
### Manual fallback for agnix-lsp
37+
38+
```bash
39+
cargo install --locked agnix-lsp
40+
```
41+
42+
Optional explicit override:
43+
44+
```bash
45+
export AGNIX_LSP_BIN="$HOME/.cargo/bin/agnix-lsp"
46+
```
47+
48+
### Verification
49+
50+
```bash
51+
nix flake check
52+
nix develop -c which agnix
53+
nix develop -c which agnix-lsp
54+
nix develop -c agnix --help
55+
nix develop -c agnix-lsp --help
56+
```

context/patterns.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
- Use the Nix dev shell as the canonical toolchain entrypoint for generation work.
66
- `flake.nix` includes `pkl` so contributors can run validation commands with `nix develop -c ...` without host-level installs.
77

8+
## Dev-shell fallback shims for unavailable nixpkgs tools
9+
10+
- When required CLI tools are not available as direct nixpkgs attrs, use the least-friction dev-shell fallback that keeps commands usable in `nix develop`.
11+
- Current repo behavior: include `cargo` and `rustc` in `devShells.default`, export `~/.cargo/bin` on `PATH`, and auto-run `cargo install --locked agnix-cli` in `shellHook` when `agnix` is missing.
12+
- `agnix-lsp` currently remains shim-based: use `AGNIX_LSP_BIN` when set and executable, otherwise use `~/.cargo/bin/agnix-lsp` when present, otherwise print manual install guidance and exit non-zero.
13+
- `shellHook` prints a version banner for `bun`, `pkl`, `tsc`, `typescript-language-server`, `rustc`, and `agnix` so shell state is visible on entry.
14+
815
## Pkl renderer layering
916

1017
- Keep target-agnostic canonical content in `config/pkl/base/shared-content.pkl`.

context/plans/agnix-dev-shell.md

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Plan: agnix-dev-shell
22

33
## 1) Change summary
4-
Add `agnix` and `agnix-lsp` to the repository Nix dev environment in `flake.nix` using a reproducible Nix-first approach, without automatic networked Cargo installs during `nix develop`.
4+
Add `agnix` and `agnix-lsp` to the repository Nix dev environment in `flake.nix` using a reproducible Nix-first approach, with automatic `cargo install` for `agnix-cli` during `nix develop` when `agnix` is missing.
55

66
## 2) Success criteria
77
- `nix develop` exposes `agnix` and `agnix-lsp` on `PATH` for contributors.
8-
- The solution is Nix-first and does not auto-run `cargo install` from shell startup.
9-
- If direct Nix packages are unavailable, the fallback behavior is explicitly documented and non-automatic.
8+
- The solution is Nix-first and auto-runs `cargo install --locked agnix-cli` from shell startup when `agnix` is missing.
9+
- If direct Nix packages are unavailable, fallback behavior is explicitly documented for remaining tools.
1010
- Verification steps for command availability and basic execution are documented and pass.
1111

1212
## 3) Constraints and non-goals
1313
- In scope: dev-shell changes in `flake.nix` and related developer docs/context updates.
1414
- In scope: package resolution for both `agnix` and `agnix-lsp` in nixpkgs (or explicit non-auto fallback guidance).
1515
- Out of scope: Home Manager activation logic and system-level package installation.
1616
- Out of scope: changing application/runtime code outside environment and docs/context artifacts.
17-
- Non-goal: adding networked auto-install behavior in `shellHook`.
17+
- Non-goal: adding networked auto-install behavior in `shellHook` for tools other than `agnix`.
1818

1919
## 4) Task stack (T01..T05)
20-
- [ ] T01: Confirm package sourcing strategy and exact package attrs (status:todo)
20+
- [x] T01: Confirm package sourcing strategy and exact package attrs (status:done)
2121
- Task ID: T01
2222
- Goal: Resolve the concrete Nix package names/attrs for `agnix` and `agnix-lsp` (or define explicit documented fallback if one is missing).
2323
- Boundaries (in/out of scope):
@@ -28,8 +28,12 @@ Add `agnix` and `agnix-lsp` to the repository Nix dev environment in `flake.nix`
2828
- Strategy remains Nix-first and non-networked at shell startup.
2929
- Verification notes (commands or checks):
3030
- Evaluate package availability via flake/package checks used in this repo workflow.
31+
- Evidence:
32+
- Verified nixpkgs attribute availability in this repo flake context with `nix eval --json --impure --expr 'let flake = builtins.getFlake (toString ./.); pkgs = import flake.inputs.nixpkgs { system = builtins.currentSystem; }; in { agnix = builtins.hasAttr "agnix" pkgs; agnix_lsp = builtins.hasAttr "agnix-lsp" pkgs; }'`, which returned `{ "agnix": false, "agnix_lsp": false }`.
33+
- Confirmed strategy for follow-up tasks: no direct nixpkgs attrs currently exist for `agnix` or `agnix-lsp`, so maintain Nix-first behavior where possible and document any fallback as explicit manual/non-automatic guidance (no networked install in `shellHook`).
34+
- Ran repository light check `nix flake check` after resolution; dev shell derivation evaluates successfully on the current system.
3135

32-
- [ ] T02: Update `flake.nix` dev shell to include agnix tooling (status:todo)
36+
- [x] T02: Update `flake.nix` dev shell to include agnix tooling (status:done)
3337
- Task ID: T02
3438
- Goal: Modify `devShells.default` package set so both commands are available in `nix develop`.
3539
- Boundaries (in/out of scope):
@@ -42,8 +46,12 @@ Add `agnix` and `agnix-lsp` to the repository Nix dev environment in `flake.nix`
4246
- `nix flake check`
4347
- `nix develop -c which agnix`
4448
- `nix develop -c which agnix-lsp`
49+
- Evidence:
50+
- Updated `flake.nix` to add `agnix` and `agnix-lsp` fallback-safe PATH shims via `pkgs.writeShellScriptBin`, keeping behavior non-automatic and avoiding networked installs in `shellHook`.
51+
- Ran `nix flake check`; dev shell derivation evaluates successfully on the current system.
52+
- Ran `nix develop -c which agnix` and `nix develop -c which agnix-lsp`; both commands resolve to Nix store shim binaries in the dev shell.
4553

46-
- [ ] T03: Add developer-facing usage and fallback notes (status:todo)
54+
- [x] T03: Add developer-facing usage and fallback notes (status:done)
4755
- Task ID: T03
4856
- Goal: Document how contributors get `agnix` tooling in dev shell and what to do if a package is unavailable.
4957
- Boundaries (in/out of scope):
@@ -54,8 +62,11 @@ Add `agnix` and `agnix-lsp` to the repository Nix dev environment in `flake.nix`
5462
- Manual fallback instructions (if required) are clear and isolated.
5563
- Verification notes (commands or checks):
5664
- Docs dry-run review: follow written steps from clean shell entry to command verification.
65+
- Evidence:
66+
- Added `README.md` section "Dev shell agnix tooling" with Nix-first usage, explicit non-automatic fallback policy, manual Cargo fallback commands, optional `AGNIX_BIN`/`AGNIX_LSP_BIN` overrides, and `which`-based verification steps.
67+
- Performed docs dry-run command checks: `nix develop -c which agnix` and `nix develop -c which agnix-lsp`.
5768

58-
- [ ] T04: Sync context records for current-state environment behavior (status:todo)
69+
- [x] T04: Sync context records for current-state environment behavior (status:done)
5970
- Task ID: T04
6071
- Goal: Update relevant `context/` files so future sessions reflect the new dev-shell tooling state.
6172
- Boundaries (in/out of scope):
@@ -65,8 +76,13 @@ Add `agnix` and `agnix-lsp` to the repository Nix dev environment in `flake.nix`
6576
- Context files accurately describe how `agnix` and `agnix-lsp` are provided in this repo.
6677
- Verification notes (commands or checks):
6778
- Context/code consistency spot-check between `flake.nix` and updated context entries.
79+
- Evidence:
80+
- Updated `context/patterns.md` to reflect current state: dev shell now includes `cargo` and `rustc`, exports `~/.cargo/bin` on `PATH`, and auto-installs `agnix-cli` when `agnix` is missing.
81+
- Updated `README.md` to match shell behavior and clarify that `agnix-lsp` remains shim/manual fallback based.
82+
- Applied user-approved scope change to include automatic networked install of `agnix-cli` during shell startup.
83+
- Spot-checked behavior with `nix flake check`, `nix develop -c which agnix`, `nix develop -c agnix --help`, and `nix develop -c which agnix-lsp`.
6884

69-
- [ ] T05: Validation and cleanup (status:todo)
85+
- [x] T05: Validation and cleanup (status:done)
7086
- Task ID: T05
7187
- Goal: Run full verification, confirm success criteria evidence, and remove temporary artifacts.
7288
- Boundaries (in/out of scope):
@@ -82,6 +98,14 @@ Add `agnix` and `agnix-lsp` to the repository Nix dev environment in `flake.nix`
8298
- `nix develop -c agnix-lsp --help`
8399
- `nix develop -c which agnix`
84100
- `nix develop -c which agnix-lsp`
101+
- Evidence:
102+
- Ran `nix flake check` (exit 0): `devShells.x86_64-linux.default` evaluated successfully; incompatible-system warning reported for non-host platforms only.
103+
- Ran `nix develop -c which agnix` (exit 0): resolved to `/home/davidabram/.cargo/bin/agnix`.
104+
- Ran `nix develop -c which agnix-lsp` (exit 0): resolved to `/home/davidabram/.cargo/bin/agnix-lsp`.
105+
- Ran `nix develop -c agnix --help` (exit 0): help text printed with command set (`validate`, `init`, `eval`, `telemetry`, `schema`).
106+
- Ran `nix develop -c agnix-lsp --help` (exit 0): command returned successfully in the dev shell.
107+
- Cleanup: removed temporary verification artifact directory `context/tmp/pkl-generated`; `context/tmp/` now only contains `.gitignore`.
108+
- Success-criteria check: all plan success criteria now have explicit command evidence and passing verification on the current host.
85109

86110
## 5) Open questions
87-
- None. Scope and install-policy choices were confirmed: Nix packages first, and no auto network installs during shell startup.
111+
- None. Scope and install-policy choices are currently: Nix-first shell, automatic `cargo install --locked agnix-cli` when `agnix` is absent, and manual fallback behavior retained for `agnix-lsp`.

flake.nix

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,30 @@
1919
inherit system;
2020
};
2121

22+
agnixLspShim = pkgs.writeShellScriptBin "agnix-lsp" ''
23+
set -euo pipefail
24+
25+
if [ -n "''${AGNIX_LSP_BIN:-}" ] && [ -x "''${AGNIX_LSP_BIN}" ]; then
26+
exec "''${AGNIX_LSP_BIN}" "$@"
27+
fi
28+
29+
if [ -x "$HOME/.cargo/bin/agnix-lsp" ]; then
30+
exec "$HOME/.cargo/bin/agnix-lsp" "$@"
31+
fi
32+
33+
cat >&2 <<'EOF'
34+
agnix-lsp is not bundled in nixpkgs for this dev shell yet.
35+
36+
Manual fallback (non-automatic):
37+
cargo install --locked agnix-lsp
38+
39+
Then either:
40+
- ensure ~/.cargo/bin is on PATH, or
41+
- set AGNIX_LSP_BIN to the agnix-lsp binary path.
42+
EOF
43+
exit 1
44+
'';
45+
2246
in
2347
{
2448
devShells.default = pkgs.mkShell {
@@ -28,17 +52,29 @@
2852
pkl
2953
typescript
3054
nodePackages.typescript-language-server
55+
agnixLspShim
56+
cargo
57+
rustc
3158
];
3259

3360
shellHook = ''
3461
version_of() {
3562
"$1" --version 2>/dev/null | awk 'match($0, /[0-9]+(\.[0-9]+)+/) { print substr($0, RSTART, RLENGTH); exit }'
3663
}
3764
65+
export PATH="$HOME/.cargo/bin:$PATH"
66+
67+
if [ ! -x "$HOME/.cargo/bin/agnix" ]; then
68+
echo "- agnix: installing agnix-cli via cargo"
69+
cargo install --locked agnix-cli
70+
fi
71+
3872
echo "- bun: $(version_of bun)"
3973
echo "- pkl: $(version_of pkl)"
4074
echo "- tsc: $(version_of tsc)"
4175
echo "- tsserver-lsp: $(version_of typescript-language-server)"
76+
echo "- rust: $(version_of rustc)"
77+
echo "- agnix: $(version_of agnix)"
4278
'';
4379
};
4480
}

0 commit comments

Comments
 (0)