This repository was archived by the owner on Jul 2, 2026. It is now read-only.
Commit a01f749
committed
index: add a per-doc
Each entry in the index now carries `size: "<N> tokens, <M> lines"` —
a body-size hint scanDocs() synthesizes from the parsed body. Token
count uses the canonical chars/4 estimate (±15% on prose / markdown
for any major LLM tokenizer); line count matches markdown.ts so
--section line numbers and the `size` line count agree.
Why now: the index is exactly the place an agent decides whether to
read the whole body or jump to --toc / --section. Without a size
signal it can't make that decision without a probe read; with one,
it's a glance. Naming: `size` (not `metrics`/`stats`) — the field
IS the doc's size; spread order lets a hand-written frontmatter
`size` win, same principle that keeps us from synthesizing other
fields.
Drive-by: pad the inline injection block with blank lines around the
fenced YAML. CommonMark formatters (oxfmt, prettier) would insert
them anyway, and emitting them ourselves prevents a hook → format →
hook ping-pong on mtime. Locked in with a regression test.size hint so agents pre-decide --toc vs full read1 parent 732ffa9 commit a01f749
4 files changed
Lines changed: 109 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
74 | 99 | | |
75 | 100 | | |
76 | 101 | | |
| 102 | + | |
77 | 103 | | |
78 | 104 | | |
79 | | - | |
| 105 | + | |
80 | 106 | | |
81 | 107 | | |
82 | 108 | | |
| 109 | + | |
83 | 110 | | |
84 | 111 | | |
85 | | - | |
| 112 | + | |
86 | 113 | | |
87 | | - | |
88 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
89 | 136 | | |
| 137 | + | |
90 | 138 | | |
91 | 139 | | |
92 | 140 | | |
93 | 141 | | |
94 | 142 | | |
95 | 143 | | |
96 | 144 | | |
97 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
98 | 148 | | |
99 | 149 | | |
100 | 150 | | |
101 | 151 | | |
102 | 152 | | |
103 | 153 | | |
104 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
105 | 164 | | |
106 | | - | |
| 165 | + | |
107 | 166 | | |
108 | 167 | | |
109 | 168 | | |
110 | 169 | | |
111 | 170 | | |
112 | | - | |
| 171 | + | |
113 | 172 | | |
114 | 173 | | |
115 | 174 | | |
| |||
118 | 177 | | |
119 | 178 | | |
120 | 179 | | |
121 | | - | |
| 180 | + | |
122 | 181 | | |
123 | 182 | | |
124 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
47 | | - | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
54 | 73 | | |
55 | 74 | | |
56 | 75 | | |
| |||
84 | 103 | | |
85 | 104 | | |
86 | 105 | | |
87 | | - | |
88 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
89 | 111 | | |
90 | | - | |
| 112 | + | |
91 | 113 | | |
92 | 114 | | |
93 | 115 | | |
94 | 116 | | |
95 | 117 | | |
96 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
97 | 123 | | |
98 | 124 | | |
99 | 125 | | |
100 | 126 | | |
| 127 | + | |
101 | 128 | | |
102 | 129 | | |
103 | 130 | | |
| 131 | + | |
104 | 132 | | |
105 | 133 | | |
106 | 134 | | |
| |||
0 commit comments