@bigknoxy/hashpilot 4.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +777 -0
  3. package/docs/ADAPTER-CONTRACT.md +1260 -0
  4. package/docs/ARCHITECTURE.md +846 -0
  5. package/docs/CLI-QUICKREF.md +827 -0
  6. package/docs/COMPETITIVE-ANALYSIS.md +307 -0
  7. package/docs/INSTALL.md +403 -0
  8. package/docs/INTEGRATION-CLAUDE.md +126 -0
  9. package/docs/INTEGRATION-MCP.md +196 -0
  10. package/docs/INTEGRATION-OPENCODE.md +136 -0
  11. package/docs/INTEGRATION-PI.md +195 -0
  12. package/package.json +77 -0
  13. package/scripts/build-site.sh +39 -0
  14. package/scripts/doctor.sh +218 -0
  15. package/scripts/gen-cli-quickref.ts +232 -0
  16. package/scripts/install-cli.sh +60 -0
  17. package/scripts/install.sh +466 -0
  18. package/scripts/roadmap-lint.ts +200 -0
  19. package/scripts/uninstall.sh +202 -0
  20. package/src/cli-node.cjs +51 -0
  21. package/src/cli.ts +209 -0
  22. package/src/commands/ast.ts +255 -0
  23. package/src/commands/diff.ts +98 -0
  24. package/src/commands/edit.ts +93 -0
  25. package/src/commands/hash.ts +64 -0
  26. package/src/commands/intent.ts +68 -0
  27. package/src/commands/maintenance.ts +191 -0
  28. package/src/commands/mcp.ts +28 -0
  29. package/src/commands/provenance.ts +111 -0
  30. package/src/commands/read.ts +117 -0
  31. package/src/commands/route.ts +42 -0
  32. package/src/commands/shared.ts +65 -0
  33. package/src/commands/telemetry.ts +126 -0
  34. package/src/commands/verify.ts +61 -0
  35. package/src/core/ast-edit.ts +2357 -0
  36. package/src/core/batch-edit.ts +185 -0
  37. package/src/core/config.ts +189 -0
  38. package/src/core/diff-engine.ts +474 -0
  39. package/src/core/doctor.ts +303 -0
  40. package/src/core/encoding.ts +116 -0
  41. package/src/core/envelope.ts +163 -0
  42. package/src/core/exit-codes.ts +198 -0
  43. package/src/core/format.ts +339 -0
  44. package/src/core/grep.ts +180 -0
  45. package/src/core/hash-edit.ts +416 -0
  46. package/src/core/index.ts +155 -0
  47. package/src/core/intent.ts +584 -0
  48. package/src/core/locking.ts +292 -0
  49. package/src/core/module-system.ts +142 -0
  50. package/src/core/operations.ts +557 -0
  51. package/src/core/output.ts +122 -0
  52. package/src/core/path-normalize.ts +61 -0
  53. package/src/core/paths.ts +326 -0
  54. package/src/core/plan-executor.ts +437 -0
  55. package/src/core/platform.ts +132 -0
  56. package/src/core/provenance.ts +214 -0
  57. package/src/core/read.ts +111 -0
  58. package/src/core/redact.ts +98 -0
  59. package/src/core/resolve-content.ts +12 -0
  60. package/src/core/router.ts +463 -0
  61. package/src/core/snapshot.ts +346 -0
  62. package/src/core/telemetry.ts +838 -0
  63. package/src/core/utils.ts +7 -0
  64. package/src/core/verify-baseline.ts +186 -0
  65. package/src/core/verify-scope.ts +282 -0
  66. package/src/core/verify.ts +753 -0
  67. package/src/mcp/server.ts +325 -0
  68. package/templates/claude-section.md +12 -0
  69. package/templates/opencode-agent.md +106 -0
  70. package/templates/opencode-skill.md +241 -0
  71. package/templates/pi-extension.ts +288 -0
  72. package/templates/pi-skill.md +123 -0
  73. package/tsconfig.json +19 -0
@@ -0,0 +1,403 @@
1
+ # HashPilot — Installation Guide
2
+
3
+ ## Overview
4
+
5
+ HashPilot is a global, tool-agnostic structured editing core that improves coding-agent efficiency across multiple tools (Claude Code, OpenCode, Pi). It provides:
6
+
7
+ - **Hash-anchored editing**: Reliable content replacement using SHA-256 hashes
8
+ - **Syntax-aware editing**: AST-based operations via tree-sitter (see supported languages below)
9
+ - **Verification batching**: Run formatter + linter + tests in one call
10
+ - **Telemetry**: Structured JSONL logging of all operations
11
+ - **Routing**: Automatic AST → hash → diff fallback
12
+
13
+ ## Supported AST Languages
14
+
15
+ HashPilot Core supports AST-backed editing for these languages:
16
+
17
+ | Language | File extensions | Grammar package | Status |
18
+ |---------------|------------------------|-----------------------------|--------|
19
+ | TypeScript | `.ts` (not `.d.ts`) | `tree-sitter-typescript` | Full |
20
+ | TSX | `.tsx` | `tree-sitter-typescript` | Full |
21
+ | JavaScript | `.js`, `.jsx`, `.mjs`, `.cjs` | `tree-sitter-javascript` | Full |
22
+ | Python | `.py` | `tree-sitter-python` | Full |
23
+ | Go | `.go` | `tree-sitter-go` | Full |
24
+ | Rust | `.rs` | `tree-sitter-rust` | Full |
25
+
26
+ ### Per-language operation support
27
+
28
+ | Operation | TypeScript | TSX | JavaScript | Python | Go | Rust |
29
+ |------------------------|:----------:|:---:|:----------:|:------:|:---:|:----:|
30
+ | `find-symbols` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
31
+ | `rename-symbol` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
32
+ | `replace-body` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
33
+ | `add-import` | ✓ | ✓ | ✓ | ✓* | ✓* | ✓ |
34
+ | `remove-import` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
35
+ | `insert-before` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
36
+ | `insert-after` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
37
+
38
+ **Notes:**
39
+ - Python `add-import` supports `import X` (e.g., `json`), `from X import Y` (e.g., `from sys import argv`), and `from X import Y, Z` (multi-import). When adding to an existing `from X import ...` for the same module, it auto-merges the new names.
40
+ - Go `add-import`: with no existing imports inserts after the `package` clause; with a grouped `import ( ... )` block inserts inside the group; with mixed simple + grouped, inserts into the grouped block.
41
+ - Rust `remove-import`: simple `use X;` declarations use exact path-segment matching (no substring false positives). Grouped `use X::{Y, Z}` supports surgical per-item removal. Removing the last item from a group simplifies to `use X::Y`. Removing all items removes the entire declaration.
42
+ - `rename-symbol` renames identifier-like references (`identifier`, `type_identifier`, `property_identifier`). It does not rename string literals or comments.
43
+ - JavaScript `.jsx` files use the same grammar as `.js` (the `tree-sitter-javascript` grammar handles JSX syntax).
44
+
45
+ ### Installed grammar packages
46
+
47
+ ```
48
+ tree-sitter@^0.21.1 # Core parser library
49
+ tree-sitter-typescript@^0.21.2 # TypeScript + TSX
50
+ tree-sitter-javascript@^0.21.4 # JavaScript + JSX
51
+ tree-sitter-python@^0.21.0 # Python
52
+ tree-sitter-go@^0.21.2 # Go
53
+ tree-sitter-rust@^0.24.0 # Rust
54
+ ```
55
+
56
+ ## Requirements
57
+
58
+ - **Bun** 1.2+ (runtime)
59
+ - **grep** (for search operations)
60
+
61
+ > **Note:** HashPilot is Bun-only. It uses Bun-specific APIs (Bun.file(), Bun.write(), Bun.spawn()) and runs via `#!/usr/bin/env bun`. Node.js is not supported as a runtime.
62
+
63
+ ## Supported Environments
64
+
65
+ - **macOS** (arm64, x86_64) — bash, zsh
66
+ - **Linux** (any distro) — bash
67
+ - **User-scope install** — no admin privileges required
68
+ - **CI/containers** — same install path; set `HASHPILOT_SHELL_RC` env var to control rc file
69
+
70
+ ## Installation
71
+
72
+ ### Quick install (recommended)
73
+
74
+ ```bash
75
+ curl -fsSL https://raw.githubusercontent.com/bigknoxy/HashPilot/main/scripts/install.sh | sh
76
+ ```
77
+
78
+ This auto-detects your platform, clones HashPilot from GitHub, installs dependencies, and configures all adapters.
79
+
80
+ ### Clone and install (for development)
81
+
82
+ ```bash
83
+ git clone https://github.com/bigknoxy/HashPilot.git ~/hashpilot
84
+ cd ~/hashpilot
85
+ bash scripts/install.sh
86
+ ```
87
+
88
+ The installer handles all of these automatically:
89
+ - Copies HashPilot Core to `~/.agentic-tools/structured-editing`
90
+ - Installs dependencies via `bun install`
91
+ - Creates the `hashpilot` CLI launcher
92
+ - Adds `~/.agentic-tools/bin` to your PATH (via shell rc file)
93
+ - Installs Claude Code integration (appends to `~/.claude/CLAUDE.md`)
94
+ - Installs OpenCode skill + agent
95
+ - Installs Pi extension + skill
96
+ - Bootstraps a default config file (if one doesn't exist)
97
+ - Writes a manifest for clean upgrades and uninstall
98
+
99
+ ### Verification
100
+
101
+ After installation, verify with:
102
+
103
+ ```bash
104
+ hashpilot doctor
105
+ ```
106
+
107
+ This checks core files, CLI, PATH, config, and all adapter integrations.
108
+
109
+ ### Options
110
+
111
+ ```bash
112
+ # Install from a different source (tarball, dotfiles)
113
+ bash scripts/install.sh --source /path/to/hashpilot
114
+
115
+ # Install to a custom target directory
116
+ bash scripts/install.sh --target ~/custom-tools
117
+
118
+ # Reinstall without prompting
119
+ bash scripts/install.sh --force
120
+
121
+ # Preserve telemetry on reinstall
122
+ bash scripts/install.sh --keep-telemetry
123
+ ```
124
+
125
+ ## Configuration
126
+
127
+ HashPilot uses a layered config system. A default config is created at `~/.config/hashpilot/config.json` during install.
128
+
129
+ ```json
130
+ {
131
+ "routePolicy": {
132
+ "languageOverrides": { "python": "hash" },
133
+ "operationOverrides": { "add-import": "diff" }
134
+ },
135
+ "telemetry": {
136
+ "enabled": true
137
+ },
138
+ "provenance": {
139
+ "maxContextLength": 500
140
+ }
141
+ }
142
+ ```
143
+
144
+ Override priority (highest wins): `HASHPILOT_ROUTE_POLICY` env var > `--config` CLI flag > `.hashpilot.json` > `~/.config/hashpilot/config.json` > defaults.
145
+
146
+ View current config:
147
+ ```bash
148
+ hashpilot config
149
+ ```
150
+
151
+ ## Quick Start
152
+
153
+ ```bash
154
+ # Read files with hashes
155
+ hashpilot read-many src/core/read.ts src/core/hash-edit.ts
156
+
157
+ # Read a specific line with hash and context
158
+ hashpilot read-hash src/core/read.ts 10
159
+
160
+ # Search across paths
161
+ hashpilot grep-many "function\\s+\\w+" src/
162
+
163
+ # Replace content using hash anchor
164
+ # First read the hash, then replace
165
+ HASH=$(hashpilot read-many myfile.ts | jq -r '.[0].hash')
166
+ hashpilot replace-hash myfile.ts "$HASH" "// new content"
167
+
168
+ # Replace a specific line range
169
+ hashpilot replace-hash myfile.ts "$HASH" "new content" --range 5:10
170
+
171
+ # Rename a symbol (TypeScript/TSX)
172
+ hashpilot ast rename-symbol myfile.ts oldName newName
173
+
174
+ # Replace a function body
175
+ hashpilot ast replace-body myfile.ts myFunction "return 42;"
176
+
177
+ # Add/remove imports
178
+ hashpilot ast add-import myfile.ts "{ Foo } from './bar'"
179
+ hashpilot ast remove-import myfile.ts './bar'
180
+
181
+ # Find symbols
182
+ hashpilot ast find-symbols myfile.ts
183
+
184
+ # Show supported AST languages, operations, and limitations
185
+ hashpilot ast capabilities
186
+
187
+ # Verify changes (run formatter + linter + tests)
188
+ hashpilot verify-changes myfile.ts --formatter prettier --linter eslint
189
+
190
+ # Check routing decision with detailed explanation
191
+ hashpilot route myfile.ts rename-symbol
192
+ hashpilot route myfile.ts add-import --policy '{"operationOverrides":{"add-import":"diff"}}'
193
+
194
+ # View or test policy config
195
+ hashpilot config
196
+
197
+ # View telemetry
198
+ hashpilot telemetry summary
199
+ hashpilot telemetry show -n 50
200
+ hashpilot telemetry health -w 7
201
+ hashpilot telemetry sessions
202
+ hashpilot telemetry export --from 2026-01-01
203
+
204
+ # Telemetry health with trend comparison
205
+ hashpilot telemetry health -w 7 --trend
206
+
207
+ # Generate and apply unified diffs
208
+ hashpilot diff generate myfile.ts "$(cat old.ts)" "$(cat new.ts)"
209
+ hashpilot diff apply myfile.ts --patch changes.patch
210
+
211
+ # Batch edit across files
212
+ hashpilot batch add-import src/*.ts --import-spec "{ z } from zod"
213
+
214
+ # Route decisions and config
215
+ hashpilot route myfile.ts add-import --policy '{"operationOverrides":{"add-import":"diff"}}'
216
+ hashpilot config
217
+
218
+ # Edit history (provenance)
219
+ hashpilot provenance query myfile.ts --human
220
+ hashpilot provenance changeset <changeSetId> --human
221
+
222
+ # Intent-based multi-step editing
223
+ hashpilot intent '{"operation":"add-parameter","symbol":"myFunc","param":{"name":"x"}}' --dry-run
224
+ ```
225
+
226
+ ## Running Tests
227
+
228
+ ```bash
229
+ cd ~/.agentic-tools/structured-editing
230
+ bun test
231
+ ```
232
+
233
+ ## Updating / Upgrading
234
+
235
+ To upgrade an existing HashPilot installation:
236
+
237
+ ```bash
238
+ # From a cloned repo
239
+ cd ~/hashpilot
240
+ git pull
241
+ bash scripts/install.sh --force
242
+
243
+ # From a tarball/dotfiles
244
+ bash scripts/install.sh --source /path/to/new-version --force
245
+ ```
246
+
247
+ The installer detects the existing install, upgrades core files, preserves your config, and updates all adapters.
248
+
249
+ ## Uninstalling
250
+
251
+ To completely remove HashPilot:
252
+
253
+ ```bash
254
+ hashpilot uninstall # prompts for confirmation
255
+ hashpilot uninstall --force # skip prompt (non-interactive auto-detected)
256
+ hashpilot uninstall --keep-config # keep config + telemetry
257
+ hashpilot uninstall --dry-run # preview only
258
+ ```
259
+
260
+ Or via the standalone script:
261
+
262
+ ```bash
263
+ curl -fsSL https://raw.githubusercontent.com/bigknoxy/HashPilot/main/scripts/uninstall.sh | sh -s -- -f
264
+ ```
265
+
266
+ Or from a local clone:
267
+
268
+ ```bash
269
+ bash scripts/uninstall.sh
270
+ ```
271
+
272
+ This removes:
273
+ - HashPilot Core (`~/.agentic-tools/structured-editing`)
274
+ - CLI launcher (`~/.agentic-tools/bin/hashpilot`)
275
+ - Claude integration (removes section from `~/.claude/CLAUDE.md`)
276
+ - OpenCode skill and agent
277
+ - Pi extension and skill
278
+ - PATH entry from shell rc files
279
+ - Telemetry logs
280
+ - Config file
281
+ - Manifest
282
+
283
+ ### Options
284
+
285
+ ```bash
286
+ # Preserve config and telemetry data
287
+ bash scripts/uninstall.sh --keep-config
288
+
289
+ # Skip confirmation prompt
290
+ bash scripts/uninstall.sh --force
291
+ ```
292
+
293
+ ### What remains after uninstall
294
+
295
+ - `~/.agentic-tools/` (removed if empty; preserved if other files exist)
296
+ - Any custom modifications you made to adapter files (the uninstaller only touches files it installed)
297
+ - Your shell rc file (PATH marker line is removed, rest preserved)
298
+
299
+ ## Directory Structure
300
+
301
+ ```
302
+ ~/.agentic-tools/
303
+ manifest.json # Managed file inventory (installer writes, uninstaller reads)
304
+ bin/
305
+ hashpilot # CLI launcher (bash script)
306
+ structured-editing/ # Core source + dependencies
307
+ package.json
308
+ tsconfig.json
309
+ src/
310
+ cli.ts
311
+ core/
312
+ config.ts # Config loading and policy
313
+ router.ts # Routing logic
314
+ doctor.ts # Doctor check logic
315
+ ast-edit.ts # Tree-sitter AST operations
316
+ hash-edit.ts # Hash-anchored editing
317
+ read.ts # File reading
318
+ grep.ts # Search operations
319
+ verify.ts # Verification (bundled checks)
320
+ telemetry.ts # Telemetry logging and health
321
+ diff-engine.ts # LCS-based unified diff + patch
322
+ batch-edit.ts # Parallel/serial batch editing
323
+ intent.ts # M5 intent parsing and plan generation
324
+ plan-executor.ts # M5 plan execution with rollback
325
+ provenance.ts # M6 edit history tracking
326
+ utils.ts # Shared utilities
327
+ scripts/
328
+ install.sh # Portable installer
329
+ doctor.sh # Standalone doctor
330
+ uninstall.sh # Clean uninstall
331
+ templates/
332
+ claude-section.md # Claude integration section
333
+ opencode-skill.md # OpenCode skill definition
334
+ opencode-agent.md # OpenCode agent definition
335
+ pi-extension.ts # Pi extension
336
+ pi-skill.md # Pi skill definition
337
+ docs/ # Documentation
338
+ tests/ # Test suite
339
+ logs/
340
+ telemetry.jsonl # Telemetry event log
341
+
342
+ ~/.config/hashpilot/
343
+ config.json # Global config (bootstrapped by installer)
344
+
345
+ ~/.claude/CLAUDE.md # Claude Code integration (modified)
346
+ ~/.config/opencode/skills/hashpilot/SKILL.md
347
+ ~/.config/opencode/agent/hashpilot.md
348
+ ~/.pi/agent/extensions/hashpilot.ts
349
+ ~/.pi/agent/skills/hashpilot/SKILL.md
350
+ ```
351
+
352
+ ## OpenCode Integration
353
+
354
+ HashPilot integrates with OpenCode as both a **skill** and a **subagent**.
355
+
356
+ ### What's installed
357
+
358
+ - **Skill** at `~/.config/opencode/skills/hashpilot/SKILL.md` — Provides instructions for using HashPilot commands
359
+ - **Agent** at `~/.config/opencode/agent/hashpilot.md` — A subagent that uses HashPilot for precise editing
360
+
361
+ These are auto-discovered by OpenCode from the `skills/` and `agent/` directories under `~/.config/opencode/`.
362
+
363
+ ### Using in OpenCode
364
+
365
+ 1. **Skill trigger**: The skill activates when you ask to edit files precisely, use structured editing, or mention hash-anchored edits
366
+ 2. **Agent invocation**: Use the HashPilot subagent via `/agent hashpilot` (or OpenCode dispatches it automatically for editing tasks)
367
+
368
+ ### PATH requirement
369
+
370
+ Ensure `~/.agentic-tools/bin` is in PATH before launching OpenCode:
371
+
372
+ ```bash
373
+ export PATH="$HOME/.agentic-tools/bin:$PATH"
374
+ ```
375
+
376
+ ## Managed File Inventory
377
+
378
+ HashPilot maintains a manifest at `~/.agentic-tools/manifest.json`. This JSON file records every file and configuration that the installer creates or modifies. The uninstaller uses it for clean removal.
379
+
380
+ **What's tracked:**
381
+ - Core directory and source files
382
+ - CLI launcher binary
383
+ - Config file location
384
+ - Claude CLAUDE.md modifications
385
+ - OpenCode skill and agent files
386
+ - Pi extension and skill files
387
+ - Telemetry log directory
388
+ - Shell rc PATH entries
389
+
390
+ ## Troubleshooting
391
+
392
+ - **"command not found"**: Ensure `~/.agentic-tools/bin` is in your PATH (run `hashpilot doctor` to check)
393
+ - **"Module not found"**: Run `cd ~/.agentic-tools/structured-editing && bun install`
394
+ - **Installer fails**: Verify bun is installed (`bun --version`), check `~/.agentic-tools/` is writable
395
+ - **Tree-sitter errors**:
396
+ - Ensure all `tree-sitter-*` packages are installed via `bun install`
397
+ - If a grammar fails to load, check that the grammar version is compatible with `tree-sitter` v0.21.x
398
+ - On first load, prebuilds from `node_modules/*/prebuilds/` are used automatically
399
+ - If you see `"nodeTypeNamesById.length"` errors, a grammar is too new for the core parser — downgrade to the latest 0.21.x version of the grammar
400
+ - **Unsupported language**: Files with unsupported extensions (.rb, .java, .c, etc.) will route to hash or diff, never silently fall through to AST
401
+ - **Doctor reports failures after install**: Run `bash scripts/doctor.sh` for detailed diagnostics
402
+ - **OpenCode not finding skill**: Verify `~/.config/opencode/skills/hashpilot/SKILL.md` exists
403
+ - **Work/regulated environment**: Everything is user-scoped (no sudo, no /usr/local). All files go under `~/.agentic-tools/`, `~/.config/hashpilot/`, and adapter-specific config directories.
@@ -0,0 +1,126 @@
1
+ # HashPilot — Claude Code Integration Guide
2
+
3
+ ## Integration Pattern
4
+
5
+ Claude Code can call `hashpilot` as a shell command, capturing JSON output for structured editing operations.
6
+
7
+ ## Setup
8
+
9
+ Add to your project's `CLAUDE.md` or `~/.claude/CLAUDE.md`:
10
+
11
+ ```markdown
12
+ ## HashPilot Structured Editing
13
+
14
+ Use `hashpilot` for file operations instead of raw text editing when available.
15
+
16
+ ### Routing Rules
17
+ 1. For supported AST languages (TypeScript, TSX, JavaScript, Python, Go, Rust), prefer AST commands (`ast rename-symbol`, `ast replace-body`, etc.)
18
+ 2. For all other edits, use hash-anchored editing (`replace-hash`)
19
+ 3. Use `read-hash` to anchor before editing, then `replace-hash` with the hash
20
+ 4. Use `verify-changes` after editing to run formatter + linter + tests
21
+
22
+ ### Key Commands
23
+ - `hashpilot read-many <files>` — batch read with hashes
24
+ - `hashpilot read-hash <file> <line>` — read line with context hash
25
+ - `hashpilot replace-hash <file> <hash> <content> [--range start:end] [--actor] [--task-id] [--reason]` — hash-anchored edit
26
+ - `hashpilot ast capabilities` — show supported languages and limitations
27
+ - `hashpilot ast find-symbols <file>` — list symbols
28
+ - `hashpilot ast rename-symbol <file> <old> <new> [--actor] [--task-id] [--reason]` — rename
29
+ - `hashpilot ast replace-body <file> <symbol> <body> [--actor] [--task-id] [--reason]` — replace function body
30
+ - `hashpilot ast add-import <file> <spec> [--actor] [--task-id] [--reason]` — add import
31
+ - `hashpilot ast remove-import <file> <spec> [--actor] [--task-id] [--reason]` — remove import
32
+ - `hashpilot ast insert-before/insert-after <file> <symbol> <content> [--actor]` — insert around a symbol
33
+ - `hashpilot diff generate <file> <old> <new>` — generate unified diff
34
+ - `hashpilot diff apply <file> --patch <file>` — apply unified diff patch
35
+ - `hashpilot route <file> <op> [--policy <json>]` — detailed route explanation with policy testing
36
+ - `hashpilot route-edit <file> <op> [options]` — auto-routed edit via AST→hash→diff
37
+ - `hashpilot batch <op> <files...>` — apply same edit to multiple files
38
+ - `hashpilot intent '<json>'` — intent-based multi-step editing (auto-discovers references)
39
+ - `hashpilot config` — show current merged configuration
40
+ - `hashpilot verify-changes <files> [--auto-detect] [--revert-on-failure]` — run formatter + linter + typecheck + tests
41
+ - `hashpilot provenance query <file> [--human]` — edit history (like `git blame` for agent edits)
42
+ - `hashpilot provenance changeset <id> [--human]` — show all edits in a changeSet
43
+ - `hashpilot telemetry summary` — check usage stats
44
+ - `hashpilot telemetry health [-w <days>] [--trend]` — health report with per-language stats and trend comparison
45
+ - `hashpilot telemetry sessions` — list session summaries
46
+ - `hashpilot telemetry export [--from <date>] [--to <date>]` — export events as NDJSON
47
+ - `hashpilot telemetry prune [--older-than <days>]` — delete old rotated files
48
+
49
+ ### Config file
50
+
51
+ Create `~/.config/hashpilot/config.json` or `.hashpilot.json` in your project to set routing policies:
52
+
53
+ ```json
54
+ {
55
+ "routePolicy": {
56
+ "languageOverrides": { "python": "hash" },
57
+ "operationOverrides": { "add-import": "diff" }
58
+ }
59
+ }
60
+ ```
61
+ ```
62
+
63
+ ## Workflow Example
64
+
65
+ ### Edit a TypeScript function body
66
+ ```bash
67
+ # 1. Find the symbol
68
+ hashpilot ast find-symbols src/utils.ts
69
+ # → find "formatDate" at line 15
70
+
71
+ # 2. Replace its body
72
+ hashpilot ast replace-body src/utils.ts formatDate 'return new Date(d).toISOString();'
73
+ # → success, body replaced
74
+
75
+ # 3. Verify (auto-detect tools from package.json)
76
+ hashpilot verify-changes src/utils.ts --auto-detect
77
+ ```
78
+
79
+ ### Hash-anchored edit for a non-TS file
80
+ ```bash
81
+ # 1. Read file with hash
82
+ HASH=$(hashpilot read-many config.yaml | jq -r '.[0].hash')
83
+
84
+ # 2. Replace entire file via hash
85
+ hashpilot replace-hash config.yaml "$HASH" "new: content\nhere: true"
86
+
87
+ # 3. Or read a line range with hash
88
+ hashpilot read-hash config.yaml 5 -c 2
89
+ # → get contextHash for line 5
90
+
91
+ # 4. Replace a specific range
92
+ hashpilot replace-hash config.yaml "$HASH" " port: 8080" --range 5:6
93
+ ```
94
+
95
+ ## When to Use HashPilot vs Direct Editing
96
+
97
+ | Task | Use HashPilot | Use Direct |
98
+ |------|--------------|------------|
99
+ | Edit existing TS/JS/Python/Go/Rust files | ✅ AST commands | ❌ |
100
+ | Edit any file with hash safety | ✅ replace-hash | ❌ |
101
+ | Rename symbols across files | ✅ ast rename-symbol | ❌ |
102
+ | Add/remove imports | ✅ ast commands | ❌ |
103
+ | Replace function body | ✅ ast replace-body | ❌ |
104
+ | Batch read multiple files | ✅ read-many | ❌ |
105
+ | Verify changes | ✅ verify-changes | ❌ |
106
+ | Create new files | — | ✅ write/edit |
107
+ | Delete files/dirs | — | ✅ bash rm |
108
+ | Move/rename files | — | ✅ bash mv |
109
+ | Simple single-line edits | — | ✅ direct edit |
110
+ | Exploratory single-file reads | — | ✅ direct read |
111
+
112
+ **Bottom line**: HashPilot is for *precise edits to existing files*. Use direct commands for creation, deletion, and file operations.
113
+
114
+ ## Token Efficiency Tips
115
+
116
+ 1. **Batch reads**: Use `read-many` to read multiple files in one call
117
+ 2. **Use hashes**: Never re-read a file you just read — use the hash to anchor edits
118
+ 3. **Symbol-aware**: For TypeScript, use `ast` commands to avoid line-counting errors
119
+ 4. **Verify once**: Bundle all verification into one `verify-changes` call
120
+
121
+ ## Error Recovery
122
+
123
+ When `replace-hash` returns `"stale": true`:
124
+ 1. Re-read the file: `hashpilot read-many <file>`
125
+ 2. Get the new hash from the response
126
+ 3. Retry `replace-hash` with the new hash