Commit 83f8806
feat: content extractors for manifests and entry points
Adds an optional `extract` field to priority rules that transforms file
content before budget accounting. Instead of including a full Cargo.toml
or truncating package.json to its first two lines, extractors produce a
focused summary (just the dependencies, just the pub mod declarations)
that fits in the content budget and actually orients an agent.
Four built-in extractors:
- json_keys: extract named top-level keys from JSON
- toml_sections: extract named sections from TOML
- lines_matching: extract lines starting with given prefixes
- api_surface: first 5 lines + all pub/export declarations
Default rules auto-extract for:
- Cargo.toml -> dependencies, dev-dependencies
- package.json -> dependencies, devDependencies, scripts
- go.mod -> require and module lines
- src/lib.*, **/mod.rs -> public API surface
The extract field is optional and defaults to None, so existing configs
work unchanged. Users can add extract specs to any priority rule in
dirpack.toml.
New file: src/packer/extractors.rs (~330 lines incl. 14 unit tests)
Modified: src/config.rs (extract field + defaults), src/packer/mod.rs
(3-line integration), src/priority.rs (test fixes), CHANGELOG.md,
default_config.toml
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 5ebffb3 commit 83f8806
6 files changed
Lines changed: 531 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| |||
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| 69 | + | |
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
| 74 | + | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
| 79 | + | |
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
| |||
76 | 85 | | |
77 | 86 | | |
78 | 87 | | |
| 88 | + | |
79 | 89 | | |
80 | 90 | | |
81 | 91 | | |
82 | 92 | | |
| 93 | + | |
83 | 94 | | |
84 | 95 | | |
85 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
256 | 267 | | |
257 | 268 | | |
258 | 269 | | |
| |||
400 | 411 | | |
401 | 412 | | |
402 | 413 | | |
| 414 | + | |
403 | 415 | | |
404 | 416 | | |
405 | 417 | | |
406 | 418 | | |
| 419 | + | |
407 | 420 | | |
408 | 421 | | |
409 | 422 | | |
410 | 423 | | |
| 424 | + | |
411 | 425 | | |
412 | 426 | | |
413 | 427 | | |
414 | 428 | | |
| 429 | + | |
415 | 430 | | |
416 | 431 | | |
417 | 432 | | |
418 | 433 | | |
| 434 | + | |
419 | 435 | | |
420 | 436 | | |
421 | 437 | | |
422 | 438 | | |
| 439 | + | |
423 | 440 | | |
424 | 441 | | |
425 | 442 | | |
426 | 443 | | |
| 444 | + | |
427 | 445 | | |
428 | 446 | | |
429 | 447 | | |
430 | 448 | | |
| 449 | + | |
431 | 450 | | |
432 | 451 | | |
433 | 452 | | |
434 | 453 | | |
| 454 | + | |
435 | 455 | | |
436 | 456 | | |
437 | 457 | | |
438 | 458 | | |
| 459 | + | |
439 | 460 | | |
440 | 461 | | |
441 | 462 | | |
442 | 463 | | |
| 464 | + | |
443 | 465 | | |
444 | 466 | | |
445 | 467 | | |
446 | 468 | | |
| 469 | + | |
447 | 470 | | |
448 | 471 | | |
449 | 472 | | |
| |||
0 commit comments