@tduyng/pi-outline 0.0.2 → 0.0.4

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 (2) hide show
  1. package/README.md +35 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,23 +1,48 @@
1
1
  # @tduyng/pi-outline
2
2
 
3
- Declarations of a source file with the line span of each, so a read fetches one body by offset and limit instead of the whole file.
3
+ A map of a source file instead of the file. One call lists every declaration with its line span, so the read that follows fetches one body.
4
4
 
5
- ## The tool
5
+ A 1,213-line TypeScript file puts 51 KB into the transcript, and every later turn of the session re-reads it. The depth-1 outline of that file is 47 rows, about 3 KB, and it names the lines worth reading.
6
6
 
7
- `outline` takes a `path` and an optional `depth` (0 to 5, default 1). It prints one row per declaration: the span, then the declaration line. Members sit under their class or impl, one indent per level. A row whose declaration has children beyond `depth` ends in `[N nested]`.
7
+ ## How it works
8
8
 
9
- Covered: TypeScript and JavaScript (functions, classes, interfaces, type aliases, enums, and class methods), Python (`def` and `class`), Go (`func` and `type`), Rust (`fn`, `struct`, `enum`, `trait`, `impl`, `mod`), and Markdown headings. Headings inside code fences are ignored.
9
+ ```text
10
+ outline(path: "src/goal.ts", depth: 1)
11
+ ```
10
12
 
11
- ## Why it is cheap
13
+ Depth runs from 0 to 5 and defaults to 1. Depth 0 lists top-level declarations, each extra level adds members, and a row with children past the depth ends in `[N nested]`.
12
14
 
13
- A big read is blocked by pi-subagent's bulk-read guard, and the block message now names `outline` first. On pi-goal's `goal.ts` (1,213 lines, 51KB) the depth-1 outline is 47 rows, 3.4KB. A whole read would put all 51KB into context and re-bill it on every later turn.
15
+ | Language | Declarations |
16
+ | --- | --- |
17
+ | TypeScript, JavaScript | functions, classes, interfaces, type aliases, enums, class methods |
18
+ | Python | `def`, `class` |
19
+ | Go | `func`, `type` |
20
+ | Rust | `fn`, `struct`, `enum`, `trait`, `impl`, `mod` |
21
+ | Markdown | headings |
14
22
 
15
- ## Limits
23
+ Headings inside code fences are ignored.
24
+
25
+ There is no parser. A parser means a dependency, a language server, and a version of both that disagrees with the repository. The outline is built from single-line rules over the text, and spans come from indentation: a declaration runs until the next line at the same or a lower indent, and includes the closing brace that follows its body.
26
+
27
+ That covers the languages people actually outline, and a miss is visible. A file the rules do not cover gets a line saying so, with grep and a ranged read as the fallback.
28
+
29
+ ## With the read guard
16
30
 
17
- No parser is used, so the rules are regular expressions over single lines. Spans come from indentation: a span runs to the next line at the same or a lower indent, and includes the closing brace that follows the body. Expect an occasional missed declaration on unusual formatting, and an object-literal method may show as a member. A file the rules do not cover gets a line saying so, with grep or a ranged read as the fallback.
31
+ pi-subagent's bulk-read guard blocks a read of a file over 350 lines, and its block message names `outline` first. The intended path is outline, then a ranged read of the one body needed.
18
32
 
19
- Files over 2MB are refused.
33
+ Without the guard the tool still works, it just stops being the thing that catches an oversized read.
20
34
 
21
35
  ## Install
22
36
 
23
- Local checkout, as part of this dotfiles package: the root `package.json` lists `./extensions/pi-outline/src/outline.ts`.
37
+ ```bash
38
+ pi install npm:@tduyng/pi-outline
39
+ ```
40
+
41
+ Local checkout: `pi install /path/to/dotfiles/pi/agent/extensions/pi-outline`
42
+
43
+ ## Limits
44
+
45
+ - Files over 2 MB are refused, since the map would be bigger than the useful part.
46
+ - At most 200 rows, and a row is cut at 120 characters.
47
+ - Spans come from indentation, so unusual formatting can miss a declaration, and an object-literal method can show up as a member.
48
+ - No types, no imports, no call graph.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tduyng/pi-outline",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Declarations of a source file with line spans, so a read fetches one body instead of the whole file.",
5
5
  "keywords": [
6
6
  "pi",