Skip to content

Commit a5d5b41

Browse files
authored
Merge pull request #3 from synadia-labs/claude/fix-ci-and-add-agents-md-6mflx
Fix CI warnings/errors, add AGENTS.md
2 parents de4641d + 889257f commit a5d5b41

File tree

2 files changed

+142
-4
lines changed

2 files changed

+142
-4
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ jobs:
1414
name: Test
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1818
with:
1919
persist-credentials: false
20-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
20+
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
2121
with:
2222
node-version-file: .tool-versions
2323
cache: npm
2424
- run: npm ci
2525
- uses: tree-sitter/setup-action@eeb902ac2f1be576edc296309872cf476a209b7f # v2
2626
with:
2727
install-lib: false
28-
- uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
28+
- uses: go-task/setup-task@0ab1b2a65bc55236a3bc64cde78f80e20e8885c2 # v1.0.0
2929
with:
3030
version: 3.x
3131
- run: task ci:test
@@ -34,8 +34,10 @@ jobs:
3434
name: Check GitHub Actions
3535
runs-on: ubuntu-latest
3636
steps:
37-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3838
with:
3939
persist-credentials: false
4040
- name: Run zizmor
4141
uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2
42+
with:
43+
advanced-security: false

AGENTS.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Agent Instructions
2+
3+
This repository contains a [tree-sitter](https://tree-sitter.github.io/)
4+
grammar for [NATS server](https://nats.io/) configuration files.
5+
6+
## Project overview
7+
8+
The grammar parses `.conf` files used by `nats-server`. Key source files:
9+
10+
- `grammar.js` — the grammar definition (entry point for tree-sitter)
11+
- `src/scanner.c` — external scanner for context-sensitive tokens (bare
12+
strings, comments, identifiers, booleans)
13+
- `queries/` — highlight, fold, indent, and locals queries (`.scm` files)
14+
- `test/corpus/` — tree-sitter test corpus (`.txt` files)
15+
- `examples/` — sample NATS config files used by `tree-sitter parse --stat`
16+
17+
## Prerequisites
18+
19+
- **Node.js 22.x** (see `.tool-versions`; Node 24+ is incompatible with
20+
tree-sitter-cli 0.25.x)
21+
- **tree-sitter CLI** — install via `cargo install tree-sitter-cli` (not an
22+
npm dependency)
23+
- **[Task](https://taskfile.dev/)** (optional but recommended) — task runner;
24+
see `Taskfile.yaml`
25+
26+
## Common workflows
27+
28+
All commands assume you are in the repository root.
29+
30+
### Setup
31+
32+
```sh
33+
npm ci
34+
command -v tree-sitter || cargo install tree-sitter-cli
35+
```
36+
37+
### Generate the parser
38+
39+
After editing `grammar.js`, regenerate the C parser:
40+
41+
```sh
42+
tree-sitter generate # or: task generate
43+
```
44+
45+
### Run tests
46+
47+
```sh
48+
tree-sitter test # or: task test
49+
```
50+
51+
This runs the corpus in `test/corpus/`. Every test file contains input
52+
fragments and expected S-expression parse trees. When adding or changing
53+
grammar rules, update or add corpus tests to cover them.
54+
55+
### Parse example files
56+
57+
```sh
58+
tree-sitter parse examples/*.conf --stat # or: task test:parse-examples
59+
```
60+
61+
All example files must parse without errors.
62+
63+
### Full CI check (locally)
64+
65+
```sh
66+
task ci:test
67+
```
68+
69+
This runs both `test` and `test:parse-examples`.
70+
71+
## Making changes
72+
73+
### Grammar changes (`grammar.js` / `src/scanner.c`)
74+
75+
1. Edit `grammar.js` (and `src/scanner.c` if the change involves external
76+
tokens).
77+
2. Run `tree-sitter generate` to regenerate `src/parser.c`.
78+
3. Add or update test cases in `test/corpus/`.
79+
4. Run `tree-sitter test` — all tests must pass.
80+
5. Run `tree-sitter parse examples/*.conf --stat` — no errors allowed.
81+
6. If the change adds or renames node types, update the queries in `queries/`
82+
to match.
83+
84+
### Query changes (`queries/*.scm`)
85+
86+
- `highlights.scm` — syntax highlighting
87+
- `folds.scm` — code folding regions
88+
- `indents.scm` — auto-indentation rules
89+
- `locals.scm` — scope/reference tracking
90+
91+
After editing queries, run `tree-sitter test` to ensure they are still valid
92+
against the grammar. Highlight queries can be previewed with
93+
`tree-sitter highlight examples/full.conf`.
94+
95+
### Test corpus (`test/corpus/*.txt`)
96+
97+
Tests use tree-sitter's standard format:
98+
99+
```
100+
===
101+
Test name
102+
===
103+
input text
104+
---
105+
(expected_sexpression)
106+
```
107+
108+
Group related tests in the appropriate file (e.g., `blocks.txt` for block
109+
syntax, `types.txt` for value types). Each test should be focused and minimal.
110+
111+
### Editor integration docs (`docs/editors/`)
112+
113+
These are per-editor setup guides. When changing grammar node names or query
114+
file structure, review and update affected editor docs.
115+
116+
## CI
117+
118+
The GitHub Actions workflow (`.github/workflows/ci.yaml`) runs on pushes to
119+
`main` and on pull requests. It runs two jobs:
120+
121+
- **Test**`task ci:test` (generate, test, parse examples)
122+
- **Check GitHub Actions** — lints workflows with
123+
[zizmor](https://github.com/woodruffw/zizmor)
124+
125+
All CI checks must pass before merging.
126+
127+
## Code style
128+
129+
- `grammar.js` uses the tree-sitter DSL (`grammar()`, `seq()`, `choice()`,
130+
`repeat()`, etc.). Keep rules concise and well-commented.
131+
- The external scanner (`src/scanner.c`) is plain C. Follow the existing style
132+
and keep functions short.
133+
- Query files (`.scm`) use S-expression syntax. One capture pattern per line.
134+
- Do not edit `src/parser.c` by hand — it is generated.
135+
- Do not commit `node_modules/`, build artifacts, or `.wasm` files (see
136+
`.gitignore`).

0 commit comments

Comments
 (0)