Commit a03931a
feat: add DAP debugger for argsh scripts (#98)
## Summary
Adds a Debug Adapter Protocol (DAP) server (`argsh-dap`) that enables
step-through debugging of argsh/bash scripts in VSCode. Uses bash's
built-in `DEBUG` trap — no bashdb or external dependencies required.
## Features
### Core DAP
- Breakpoints (file:line) with runtime updates
- Stepping: step in (F11), step over (F10), step out (Shift+F11),
continue (F5)
- Stack trace via `FUNCNAME`/`BASH_LINENO`/`BASH_SOURCE`
- Named pipe (FIFO) communication between debugger and bash process
### argsh-specific enhancements (#92-#97)
| Feature | Issue | Description |
|---------|-------|-------------|
| Smart breakpoints | #92 | Set breakpoints by subcommand name —
resolves through `:usage` namespace chain |
| Args inspector | #93 | "argsh Args" scope shows structured `:args`
definitions with field types |
| Auto-launch configs | #94 | Generate launch configs for all subcommand
paths from `:usage` tree |
| Import-aware resolution | #95 | Smart breakpoints search imported
files via the shared resolver |
| Variable tooltips | #96 | Hover shows argsh type annotations (`:~int`,
`:+`, etc.) |
| Command tree breakpoints | #97 | Function breakpoints use `:usage`
resolution |
### VSCode extension
- `argsh` debug type registered with launch config schema
- Auto-detect `argsh-dap` binary (bundled or PATH)
- Default "Debug Current File" config with `stopOnEntry`
- Configuration snippet for `launch.json`
### Architecture
```
VSCode ←── DAP (stdin/stdout) ──→ argsh-dap
│
├── analyzes script via argsh_syntax
├── spawns bash with DEBUG trap prelude
└── communicates via named pipes (FIFOs)
```
No `dap` crate — hand-rolled DAP types with `serde_json` (both available
crates are stale/alpha).
## Files changed
| File | Description |
|------|-------------|
| `crates/argsh-lsp/Cargo.toml` | Add `libc` dep, `[[bin]] argsh-dap` |
| `crates/argsh-lsp/src/bin/argsh-dap.rs` | DAP server binary (~600
lines) |
| `crates/argsh-lsp/tests/dap_integration.rs` | 8 integration tests |
| `vscode-argsh/src/debugProvider.ts` | Debug adapter factory + config
provider |
| `vscode-argsh/src/extension.ts` | Register debug provider |
| `vscode-argsh/package.json` | Debugger contributions, breakpoints,
settings |
| `docs/development/tools/debugger.mdx` | User documentation |
| `docs/sidebars.js` | Sidebar entry under Tools |
## Tests
- 8 DAP integration tests: version/help, initialize capabilities,
threads, breakpoints, configurationDone, scopes with argsh Args
- All 135 existing tests pass (55 LSP + 27 lint + 26 syntax + 19 unit +
8 DAP)
- Extension compiles clean
## Test plan
- [x] `cargo test --release` — all 135 tests pass
- [x] `npm run compile` — extension compiles
- [x] `argsh-dap --version` / `--help` works
- [ ] Manual testing: F5 in VSCode with a script, breakpoints, stepping
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent e629934 commit a03931a
12 files changed
Lines changed: 3050 additions & 21 deletions
File tree
- crates/argsh-lsp
- src/bin
- tests
- docs
- development/tools
- todos
- vscode-argsh
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
| 289 | + | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
304 | 306 | | |
305 | | - | |
306 | | - | |
307 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
308 | 311 | | |
309 | 312 | | |
310 | | - | |
311 | | - | |
312 | | - | |
| 313 | + | |
313 | 314 | | |
314 | | - | |
| 315 | + | |
315 | 316 | | |
316 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
317 | 323 | | |
318 | | - | |
| 324 | + | |
319 | 325 | | |
320 | | - | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
321 | 331 | | |
322 | | - | |
| 332 | + | |
323 | 333 | | |
324 | 334 | | |
325 | 335 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
22 | 29 | | |
23 | 30 | | |
24 | 31 | | |
| |||
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
30 | 41 | | |
31 | 42 | | |
32 | | - | |
33 | 43 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
24 | 38 | | |
25 | 39 | | |
26 | 40 | | |
| |||
84 | 98 | | |
85 | 99 | | |
86 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
87 | 108 | | |
88 | 109 | | |
89 | 110 | | |
| |||
141 | 162 | | |
142 | 163 | | |
143 | 164 | | |
144 | | - | |
145 | | - | |
146 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
147 | 168 | | |
148 | 169 | | |
149 | 170 | | |
150 | 171 | | |
151 | | - | |
| 172 | + | |
152 | 173 | | |
0 commit comments