Skip to content

Commit b6e9fa9

Browse files
committed
build: replace vitest with node test
Move the remaining TypeScript package tests to Node built-in test runner so Vitest and its transitive dependency tree can leave the workspace. Use oxlint type-aware type checking as the root typecheck entry point and remove tsgo from the dev shell. Keep hermetic Nix formatter/check paths on a lightweight oxlint config because pure Nix checks do not include npm dependencies. Refresh repo-local skills and agent guidance for Node tests and Nushell scripts.
1 parent 03a7087 commit b6e9fa9

40 files changed

Lines changed: 401 additions & 782 deletions

‎.agents/skills/commit/references/revertable-commits.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ Good: keep both sides of a move together.
2626

2727
One commit contains:
2828

29-
- `A .agents/skills/tdd/references/vitest.md`
29+
- `A .agents/skills/tdd/references/new-runner.md`
3030
- `M .agents/skills/tdd/SKILL.md`
31-
- `D .agents/skills/tdd/vitest-example.md`
31+
- `D .agents/skills/tdd/references/old-runner.md`
3232

3333
The commit is still small, but it is complete: the old path is removed, the new
3434
path is added, and every reference points to the new path.
@@ -37,12 +37,12 @@ Bad: split one move across incomplete commits.
3737

3838
First commit:
3939

40-
- `A .agents/skills/tdd/references/vitest.md`
40+
- `A .agents/skills/tdd/references/new-runner.md`
4141

4242
Second commit:
4343

4444
- `M .agents/skills/tdd/SKILL.md`
45-
- `D .agents/skills/tdd/vitest-example.md`
45+
- `D .agents/skills/tdd/references/old-runner.md`
4646

4747
The first commit is not independently revertable because it leaves duplicate or
4848
unreachable guidance until the second commit lands.

‎.agents/skills/development/references/environment-and-validation.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Environment
44

55
This repo requires the Nix flake development environment with nix-direnv for
6-
contributor setup. Use the activated direnv shell so the pinned Rust, Bun, pnpm,
6+
contributor setup. Use the activated direnv shell so the pinned Rust, pnpm,
77
git hooks, agent skills, and repository CLIs are all on `PATH`.
88

99
Use the activated `direnv` environment for normal work. For non-interactive

‎.agents/skills/nushell/SKILL.md‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: nushell
3+
description: Guides ccusage Nushell scripts. Use when adding, editing, formatting, or validating .nu scripts, Nix shebangs, GitHub Actions script calls, or just recipes that invoke Nushell.
4+
paths:
5+
- '**/*.nu'
6+
globs: '*.nu'
7+
---
8+
9+
# ccusage Nushell
10+
11+
Use this skill for repository scripts written in Nushell, especially under
12+
`.github/scripts/` and `apps/ccusage/scripts/`.
13+
14+
## Runtime Shape
15+
16+
- Prefer executable `.nu` scripts with a Nix shebang over adding `nushell` to a
17+
GitHub Actions profile install.
18+
- Use `#!/usr/bin/env nix` plus a `nix shell --inputs-from` line when the script
19+
needs tools that should be pinned by the flake.
20+
- Keep the shebang tool list to commands the script directly invokes.
21+
- It is acceptable for a Nu script to call external tools such as `gh`, `jq`,
22+
`git`, `hyperfine`, `pnpm`, `node`, or `bun` when those tools are the right
23+
boundary. Prefer the shebang Nix shell to global installs.
24+
25+
Example:
26+
27+
```nu
28+
#!/usr/bin/env nix
29+
#! nix shell --inputs-from ../../.. nixpkgs#nushell nixpkgs#git --command nu
30+
```
31+
32+
Adjust the `--inputs-from` relative path to the script location.
33+
34+
## Style
35+
36+
- Use structured Nushell data operations (`open`, records, lists, `from json`,
37+
`to json`, `transpose`, `where`, `each`) instead of ad hoc string parsing.
38+
- Use `run-external` for commands where flags may be parsed by Nushell, and quote
39+
short flags such as `'-L'`, `'-x'`, `'-c'`, and `'-change'`.
40+
- Keep command arguments as lists until the external boundary. When a string
41+
command is required, quote arguments that may contain spaces.
42+
- Use `complete` when you need exit code, stdout, and stderr without throwing.
43+
- Print progress to stderr for CI scripts whose stdout is a data artifact.
44+
45+
## Validation
46+
47+
Run syntax checks through Nix instead of assuming `nu` is on `PATH`:
48+
49+
```sh
50+
nix shell --inputs-from . nixpkgs#nushell --command nu --commands 'nu-check path/to/script.nu'
51+
```
52+
53+
Run formatting after edits:
54+
55+
```sh
56+
just fmt
57+
```
58+
59+
For behavior changes, add a focused smoke command that invokes the script via
60+
its executable shebang, then run the repo check that owns the caller.

‎.agents/skills/profile/SKILL.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ description: Profiles ccusage performance. Use when debugging slow Rust CLI comm
66
# ccusage Profile
77

88
Use this skill for ccusage performance work. The production CLI is Rust-first,
9-
but TypeScript launcher, benchmark, and packaging scripts still need Bun
10-
profiling when those paths are in scope.
9+
but the TypeScript launcher and Nushell benchmark/package scripts still need
10+
focused profiling when those paths are in scope.
1111

1212
## Rust
1313

1414
Read `references/rust.md` for native CLI profiling, branch-vs-main worktree
1515
setup, `hyperfine` validation, JSON parity checks, and PR performance workflow
1616
reproduction.
1717

18-
## TypeScript And Bun
18+
## TypeScript And Scripts
1919

20-
Read `references/typescript.md` for Bun profiler commands, package script
21-
profiling, TypeScript launcher/benchmark setup, profile reading, local Bun docs,
22-
and ccusage-specific performance lessons.
20+
Read `references/typescript.md` for Node profiler commands, package script
21+
profiling, TypeScript launcher/Nushell benchmark setup, profile reading, and
22+
ccusage-specific performance lessons.

‎.agents/skills/profile/references/rust.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ When CI performance comments are relevant, inspect options with `--help`, but do
7272
not treat help output as a profiling workload:
7373

7474
```sh
75-
nix develop --command pnpm exec bun apps/ccusage/scripts/compare-pr-performance.ts --head-runtime rust --help
75+
apps/ccusage/scripts/compare-pr-performance.nu --head-runtime rust --help
7676
```
7777

7878
To reproduce the workflow shape locally, pass real fixture and worktree inputs:
7979

8080
```sh
81-
nix develop --command pnpm exec bun apps/ccusage/scripts/compare-pr-performance.ts \
81+
apps/ccusage/scripts/compare-pr-performance.nu \
8282
--base-dir /tmp/ccusage-main \
8383
--head-dir "$PWD" \
8484
--head-runtime rust \

‎.agents/skills/profile/references/typescript.md‎

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
# TypeScript And Bun Profiling
1+
# TypeScript And Script Profiling
22

33
Use this reference for TypeScript launcher, benchmark, and packaging script
44
performance. The production CLI is Rust-first, so native command performance
55
work should use `references/rust.md`.
66

7-
## Bun Profiler Commands
7+
## Node Profiler Commands
88

9-
Use Bun's markdown CPU profile first because it is grep-friendly and compact
10-
enough for agent analysis. Generate `.cpuprofile` as well when a flamegraph or
11-
Chrome DevTools / VS Code inspection is useful. Inspect script options with
12-
`--help`, but do not treat help output as a profiling workload.
9+
Use Node's CPU profiler when launcher startup or package tooling is in scope.
10+
Inspect script options with `--help`, but do not treat help output as a
11+
profiling workload.
1312

1413
```sh
15-
pnpm exec bun --cpu-prof --cpu-prof-md --cpu-prof-dir ./profiles <script> <args>
14+
node --cpu-prof --cpu-prof-dir ./profiles apps/ccusage/dist/cli.js <args>
1615
```
1716

1817
For package scripts, inject profiler flags without rewriting the command:
1918

2019
```sh
21-
BUN_OPTIONS="--cpu-prof --cpu-prof-md --cpu-prof-dir ./profiles" pnpm <script>
20+
NODE_OPTIONS="--cpu-prof --cpu-prof-dir=./profiles" pnpm <script>
2221
```
2322

2423
Keep benchmark runs quiet and deterministic:
2524

2625
```sh
27-
LOG_LEVEL=0 COLUMNS=200 pnpm exec bun --cpu-prof-md <script> <args>
26+
LOG_LEVEL=0 COLUMNS=200 node --cpu-prof apps/ccusage/dist/cli.js <args>
2827
```
2928

3029
## Branch Comparison
@@ -89,35 +88,6 @@ rg -n "Map#set|JSON.parse|Intl|postMessage|write|data-loader|table" profiles/*.m
8988
For `.cpuprofile`, open Chrome DevTools Performance tab or VS Code's CPU
9089
profiler and inspect both bottom-up self time and call tree context.
9190

92-
## Bun References
93-
94-
Use Bun's local agent-readable docs before web docs. In this repo, the useful
95-
Bun docs live in `node_modules/bun-types`.
96-
97-
Read this first for profiling flags and benchmarking guidance:
98-
99-
```sh
100-
sed -n '1,280p' node_modules/bun-types/docs/project/benchmarking.mdx
101-
```
102-
103-
Use the type files for runtime APIs used in this repo, such as `Bun.$`,
104-
`Bun.file()`, `Bun.write()`, `Bun.spawn()`, `Bun.argv`, `Bun.deepEquals()`,
105-
`Bun.file().writer()`, `Bun.stdout`, `Bun.stderr`, and `Bun.stringWidth()`:
106-
107-
```sh
108-
rg -n "cpu-prof|cpu-prof-md|Bun\\.\\$|function file|function write|function spawn|argv|deepEquals|stringWidth" \
109-
node_modules/bun-types
110-
```
111-
112-
Relevant local docs are usually under:
113-
114-
- `node_modules/bun-types/README.md`
115-
- `node_modules/.pnpm/bun-types*/node_modules/bun-types/docs/project/benchmarking.mdx`
116-
- `node_modules/.pnpm/bun-types*/node_modules/bun-types/bun.d.ts`
117-
118-
If local docs are unavailable, use Bun's benchmarking docs:
119-
`https://bun.com/docs/project/benchmarking`.
120-
12191
## ccusage Lessons
12292

12393
- Past ccusage performance work found wins by profiling the real bundled CLI on
@@ -130,9 +100,9 @@ If local docs are unavailable, use Bun's benchmarking docs:
130100
`blocks` JSON when changing aggregation order.
131101
- Replace hot exact-key `Map` indexes with null-prototype object indexes only
132102
when keys are plain strings and inherited keys are covered.
133-
- Pipe large JSON output through `jq -e .` because Bun CLIs can expose stdout
134-
flushing bugs under benchmark-style piping.
103+
- Pipe large JSON output through `jq -e .` so benchmark-style piping still
104+
verifies JSON parity.
135105

136106
Use microbenchmarks for isolated language/runtime questions, not as proof of CLI
137-
wins. Prefer `mitata` for JavaScript microbenchmarks. Confirm any
138-
microbenchmark-driven change with the full CLI profile and hyperfine A/B run.
107+
wins. Confirm any microbenchmark-driven change with the full CLI profile and
108+
hyperfine A/B run.

‎.agents/skills/tdd/SKILL.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Example prompts:
1212

1313
You are following strict t-wada style Test-Driven Development. All code changes that involve logic (bug fixes, new features, refactors) **must** follow Red-Green-Refactor. No exceptions.
1414

15-
**Project test environment:** ccusage uses Vitest for TypeScript/package
15+
**Project test environment:** ccusage uses Node's built-in test runner for TypeScript/package
1616
tooling tests and `cargo test` for Rust CLI tests. Use the `testing` skill for
1717
ccusage-specific fixture, adapter, pricing, model, schema, and CLI-output test
1818
rules.
@@ -39,7 +39,7 @@ Repeat until the feature or fix is complete.
3939

4040
## Workflow
4141

42-
1. **Sketch behaviors** — Before writing any code, list the behaviors to implement as placeholder tests, such as `it.todo(...)` in Vitest or `#[ignore]` in Rust.
42+
1. **Sketch behaviors** — Before writing any code, list the behaviors to implement as placeholder tests, such as `it.todo(...)` in Node test or `#[ignore]` in Rust.
4343
2. **Pick one behavior** — Start with the simplest or most fundamental one.
4444
3. **Red** — Write the test. Run it. Confirm it fails for the right reason.
4545
4. **Green** — Write the minimum code to pass. Run the test. Confirm it passes.
@@ -52,7 +52,7 @@ Prefer running only the tests affected by your changes during the Red-Green-Refa
5252

5353
**Runner-specific guidance** — Read the relevant example file alongside this skill for detailed test modifiers, idioms, and runner-specific tips:
5454

55-
- **Vitest**: See `references/vitest.md` for focused commands, modifiers, a
55+
- **Node test**: See `references/node-test.md` for focused commands, modifiers, a
5656
compact Red-Green-Refactor example, and assertion/readability examples.
5757
- **Rust (cargo test)**: See `references/rust.md` for focused cargo commands,
5858
attributes, Result tests, doc tests, and a compact Red-Green-Refactor example.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Node Test TDD Reference
2+
3+
## Running
4+
5+
```bash
6+
# Run every TypeScript package/tooling test.
7+
just test-node
8+
9+
# Run a specific test file.
10+
node --test apps/ccusage/src/cli.test.ts
11+
12+
# Run tests matching a name pattern.
13+
node --test --test-name-pattern "returns 0 for an empty cart" path/to/file.test.ts
14+
```
15+
16+
## Modifiers
17+
18+
Import runner APIs explicitly from `node:test`:
19+
20+
```typescript
21+
import assert from 'node:assert/strict';
22+
import { describe, it } from 'node:test';
23+
```
24+
25+
Use built-in modifiers instead of commenting out or deleting tests:
26+
27+
- `it.todo("description")` - placeholder for a test you plan to write.
28+
- `it.skip("description", ...)` - temporarily disable a blocked test with an
29+
explanation.
30+
- `it.only("description", ...)` - focus during Red-Green; remove before
31+
committing.
32+
33+
## Red-Green Example
34+
35+
```typescript
36+
import assert from 'node:assert/strict';
37+
import { describe, it } from 'node:test';
38+
import { calculateTotal } from './cart.ts';
39+
40+
describe(calculateTotal.name, () => {
41+
it('returns 0 for an empty cart', () => {
42+
assert.equal(calculateTotal([]), 0);
43+
});
44+
45+
it('sums item prices', () => {
46+
const items = [{ price: 10 }, { price: 20 }];
47+
48+
assert.equal(calculateTotal(items), 30);
49+
});
50+
});
51+
```
52+
53+
## Expected Failures
54+
55+
Avoid `try`/`catch` for expected failures. Assert the rejection or thrown error
56+
directly:
57+
58+
```typescript
59+
it('rejects invalid config', async () => {
60+
await assert.rejects(loadConfig('bad.json'), Error);
61+
});
62+
```

0 commit comments

Comments
 (0)