surf-cli 0.7.0__tar.gz → 0.8.0__tar.gz
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.
- {surf_cli-0.7.0 → surf_cli-0.8.0}/.agents/skills/surf/SKILL.md +6 -13
- {surf_cli-0.7.0 → surf_cli-0.8.0}/.agents/skills/surf/references/about.md +1 -1
- {surf_cli-0.7.0 → surf_cli-0.8.0}/.agents/skills/surf/references/usage.md +18 -8
- {surf_cli-0.7.0 → surf_cli-0.8.0}/.claude-plugin/marketplace.json +2 -2
- surf_cli-0.8.0/CONTRIBUTING.md +54 -0
- surf_cli-0.8.0/PKG-INFO +278 -0
- surf_cli-0.8.0/README.md +243 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/flake.nix +1 -1
- {surf_cli-0.7.0 → surf_cli-0.8.0}/plugins/surf/.claude-plugin/plugin.json +1 -1
- {surf_cli-0.7.0 → surf_cli-0.8.0}/plugins/surf/plugin.json +1 -1
- {surf_cli-0.7.0 → surf_cli-0.8.0}/pyproject.toml +10 -2
- surf_cli-0.8.0/scripts/spec-coverage.py +193 -0
- surf_cli-0.8.0/spec/README.md +26 -0
- surf_cli-0.8.0/spec/features/command-line.md +53 -0
- surf_cli-0.8.0/spec/features/errors-and-exit-codes.md +67 -0
- surf_cli-0.8.0/spec/features/file-map.md +96 -0
- surf_cli-0.8.0/spec/features/filter-by-frontmatter.md +188 -0
- surf_cli-0.8.0/spec/features/frontmatter-grammar.md +55 -0
- surf_cli-0.8.0/spec/features/frontmatter-only.md +74 -0
- surf_cli-0.8.0/spec/features/heading-tree.md +96 -0
- surf_cli-0.8.0/spec/features/link-targets.md +61 -0
- surf_cli-0.8.0/spec/features/multiple-files.md +168 -0
- surf_cli-0.8.0/spec/features/no-structural-index.md +88 -0
- surf_cli-0.8.0/spec/features/pdf-addressing.md +89 -0
- surf_cli-0.8.0/spec/features/section-extraction.md +166 -0
- surf_cli-0.8.0/spec/features/tex-addressing.md +178 -0
- surf_cli-0.8.0/spec/features/what-counts-as-a-heading.md +127 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/src/surf/__init__.py +1 -1
- {surf_cli-0.7.0 → surf_cli-0.8.0}/src/surf/adapters.py +7 -5
- {surf_cli-0.7.0 → surf_cli-0.8.0}/src/surf/logic.py +461 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/src/surf/models.py +37 -1
- {surf_cli-0.7.0 → surf_cli-0.8.0}/src/surf/orchestrator.py +194 -45
- {surf_cli-0.7.0 → surf_cli-0.8.0}/src/surf/test_adapters.py +14 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/src/surf/test_logic.py +249 -0
- surf_cli-0.8.0/src/surf/test_orchestrator.py +1330 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/src/surf/test_tex_logic.py +22 -2
- {surf_cli-0.7.0 → surf_cli-0.8.0}/uv.lock +51 -1
- surf_cli-0.7.0/PKG-INFO +0 -177
- surf_cli-0.7.0/README.md +0 -142
- surf_cli-0.7.0/src/surf/test_orchestrator.py +0 -692
- {surf_cli-0.7.0 → surf_cli-0.8.0}/.agents/skills/surf/references/surf.pdf +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/.agents/skills/surf/references/surf.tex +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/.github/workflows/publish.yml +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/.gitignore +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/.grok-plugin/marketplace.json +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/LICENSE +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/RELEASING.md +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/flake.lock +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/scripts/deploy.sh +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/scripts/lint.sh +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/scripts/test.sh +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/src/surf/__main__.py +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/src/surf/test_extract_section_perf_smoke.py +0 -0
- {surf_cli-0.7.0 → surf_cli-0.8.0}/src/surf/test_models.py +0 -0
|
@@ -8,7 +8,7 @@ metadata:
|
|
|
8
8
|
github_username: saintx
|
|
9
9
|
email: alex@saintx.us
|
|
10
10
|
twitter: alexsaintx
|
|
11
|
-
surf-version: "0.
|
|
11
|
+
surf-version: "0.8.0"
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
# Surf: Progressive Context Disclosure
|
|
@@ -40,21 +40,14 @@ Resolve with `surf` against the section heading; do not bulk-ingest a whole refe
|
|
|
40
40
|
| Wikilink and link input | `surf references/usage.md "Wikilink and link input"` |
|
|
41
41
|
| Batch scanning | `surf references/usage.md "Batch scanning"` |
|
|
42
42
|
| Platform aggregation (batch section extraction) | `surf references/usage.md "Platform aggregation (batch section extraction)"` |
|
|
43
|
+
| Filter by frontmatter | `surf references/usage.md "Filter by frontmatter"` |
|
|
43
44
|
| Additional options | `surf references/usage.md "Additional options"` |
|
|
44
45
|
|
|
45
|
-
###
|
|
46
|
+
### TeX and PDF
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
`references/surf.tex` and `references/surf.pdf` are one document in two forms. The same address works on either.
|
|
48
49
|
|
|
49
50
|
| Intent | Section extraction |
|
|
50
51
|
|--------|--------------------|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
| Read the abstract | `surf references/surf.tex "abstract"` |
|
|
54
|
-
| Why surf exists | `surf references/surf.pdf "Background"` |
|
|
55
|
-
| What a thin index looks like | `surf references/surf.tex "A Thin Index Shaped by Intent"` |
|
|
56
|
-
| Who composes context | `surf references/surf.pdf "Agentic Context Composition"` |
|
|
57
|
-
| Check a skill mechanically | `surf references/surf.tex "Skills You Can Check"` |
|
|
58
|
-
| Compose indexes across skills | `surf references/surf.pdf "Indexes over Indexes"` |
|
|
59
|
-
| Formats and corpora surf addresses | `surf references/surf.tex "Markdown, TeX, and PDF"` |
|
|
60
|
-
| How the paper checks itself | `surf references/surf.pdf "This Paper"` |
|
|
52
|
+
| Extract a section from TeX | `surf references/surf.tex "Markdown, TeX, and PDF"` |
|
|
53
|
+
| Extract a section from PDF | `surf references/surf.pdf "Markdown, TeX, and PDF"` |
|
|
@@ -5,7 +5,7 @@ metadata:
|
|
|
5
5
|
github_username: saintx
|
|
6
6
|
email: alex@saintx.us
|
|
7
7
|
twitter: alexsaintx
|
|
8
|
-
surf-version: "0.
|
|
8
|
+
surf-version: "0.8.0"
|
|
9
9
|
---
|
|
10
10
|
# Surf Usage
|
|
11
11
|
|
|
@@ -101,25 +101,32 @@ The `.md` extension is implicit. `surf ~/path/to/file` resolves to `~/path/to/fi
|
|
|
101
101
|
Scan YAML across a directory without loading any body:
|
|
102
102
|
|
|
103
103
|
```bash
|
|
104
|
-
|
|
104
|
+
surf -f ~/path/to/*.md
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
Two or more files print under `==> path <==` headers. Nested trees:
|
|
108
108
|
|
|
109
109
|
```bash
|
|
110
|
-
|
|
110
|
+
surf -f ~/path/to/*/file.md
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
## Platform aggregation (batch section extraction)
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
Extract one heading from each matching file. Two or more files print under `==> path <==` headers:
|
|
116
116
|
|
|
117
117
|
```bash
|
|
118
|
-
|
|
119
|
-
| xargs -I{} sh -c 'echo "### {}" && surf {} "Some Heading" && echo'
|
|
118
|
+
surf -s "Some Heading" ~/path/to/*/file.md
|
|
120
119
|
```
|
|
121
120
|
|
|
122
|
-
Change the
|
|
121
|
+
Change the glob and the heading text to match the files you have.
|
|
122
|
+
|
|
123
|
+
## Filter by frontmatter
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
surf --where metadata.skill-family=skill-authoring -s Overview ~/path/to/*/references/about.md
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`--where KEY=VALUE` keeps files whose YAML frontmatter matches. Dotted keys walk nested maps. A list value matches on membership. Repeat `--where` to require every clause. With no other mode flag, print matching paths.
|
|
123
130
|
|
|
124
131
|
## Additional options
|
|
125
132
|
|
|
@@ -129,8 +136,11 @@ Change the `find` root, the path glob, and the heading text to match the files y
|
|
|
129
136
|
| heading, no flag | Section content without frontmatter |
|
|
130
137
|
| `--list` | Heading tree only |
|
|
131
138
|
| `-f` / `--frontmatter-only` | YAML only |
|
|
139
|
+
| `-s` / `--section` | Heading to extract from each file. Every positional is a file. |
|
|
140
|
+
| `--where KEY=VALUE` | Keep files whose frontmatter matches. Repeatable and conjunctive. |
|
|
132
141
|
| `--full` | With a named heading: YAML frontmatter, then that section. Without a heading: the file map. |
|
|
133
142
|
| `--content-only` / `--body-only` | Same as a named heading with no flag. This is the default extract. |
|
|
134
143
|
| `--level N` | List: ranks 1 through N. Extract: exact rank N. |
|
|
135
144
|
| `--no-heading` | Omit the heading line from section output |
|
|
136
145
|
| `-o <file>` | Write output to a file. |
|
|
146
|
+
| `-v` / `--verbose` | Name each skipped file on stderr. |
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
"owner": { "name": "Alexander R. Saint Croix", "email": "alex@saintx.us" },
|
|
4
4
|
"metadata": {
|
|
5
5
|
"description": "Plugins shipped with the surf CLI.",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.8.0"
|
|
7
7
|
},
|
|
8
8
|
"plugins": [
|
|
9
9
|
{
|
|
10
10
|
"name": "surf",
|
|
11
11
|
"source": "./plugins/surf",
|
|
12
12
|
"description": "Extract a markdown heading, TeX section, or PDF outline item without loading the rest of the file.",
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.8.0",
|
|
14
14
|
"category": "tooling",
|
|
15
15
|
"keywords": ["surf", "markdown", "tex", "pdf", "context", "skills"]
|
|
16
16
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Contributing to surf
|
|
2
|
+
|
|
3
|
+
How to get a working tree, run the tests, and pass lint. The release procedure is in [RELEASING.md](https://github.com/saintx/surf-cli/blob/main/RELEASING.md).
|
|
4
|
+
|
|
5
|
+
## Environment
|
|
6
|
+
|
|
7
|
+
Python 3.12+ and [uv](https://docs.astral.sh/uv/). Either of these gives a shell with the dev dependencies installed:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
nix develop # python312 + uv, then uv sync
|
|
11
|
+
uv sync # without Nix; the dev group is installed by default
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Run the checkout's `surf` without installing it:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
uv run surf --version
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Layout
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
src/surf/
|
|
24
|
+
models.py data types
|
|
25
|
+
logic.py heading trees, section extraction; pure, no I/O
|
|
26
|
+
adapters.py file reading, TeX expansion, pypdf
|
|
27
|
+
orchestrator.py CLI: argument parsing, dispatch, exit codes
|
|
28
|
+
test_*.py tests, beside the modules they cover
|
|
29
|
+
plugins/surf/ the agent skill and its manifests
|
|
30
|
+
scripts/ test.sh, lint.sh, deploy.sh, spec-coverage.py
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The layers only depend downward, and `pypdf` is confined to `adapters.py`. Four `import-linter` contracts in `pyproject.toml` enforce this, and `scripts/lint.sh` runs them.
|
|
34
|
+
|
|
35
|
+
## Tests
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
scripts/test.sh # uv run pytest src/surf -q
|
|
39
|
+
python scripts/spec-coverage.py # which spec scenarios have a passing test
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Unit tests live in `src/surf/test_*.py` and are excluded from the wheel. A test that demonstrates a scenario cites it with a docstring line `spec: <slug>#Scenario`. `python scripts/spec-coverage.py` reports which scenarios under `spec/features/` those citations cover.
|
|
43
|
+
|
|
44
|
+
## Lint
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
scripts/lint.sh
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Runs, in order: `isort`, `black` (line length 100), `autoflake` (unused imports), `pyright` (basic mode, unused imports are errors), and `lint-imports` against the layer contracts. The first three rewrite files in place; run it before committing.
|
|
51
|
+
|
|
52
|
+
## Version
|
|
53
|
+
|
|
54
|
+
`surf --version` must agree with the version in every location listed in [RELEASING.md](https://github.com/saintx/surf-cli/blob/main/RELEASING.md). Changes that are not a release do not bump it.
|
surf_cli-0.8.0/PKG-INFO
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: surf-cli
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Summary: List headings, or extract one section by name, from Markdown, TeX, or PDF.
|
|
5
|
+
Project-URL: Homepage, https://github.com/saintx/surf-cli
|
|
6
|
+
Project-URL: Repository, https://github.com/saintx/surf-cli
|
|
7
|
+
Project-URL: Issues, https://github.com/saintx/surf-cli/issues
|
|
8
|
+
Project-URL: Author, https://github.com/saintx
|
|
9
|
+
Author-email: "Alexander R. Saint Croix" <alex@saintx.us>
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 Alexander R. Saint Croix
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Requires-Python: >=3.12
|
|
33
|
+
Requires-Dist: pypdf>=6.17.0
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# surf
|
|
37
|
+
|
|
38
|
+
List headings, or extract one section by name, from Markdown, TeX, or PDF.
|
|
39
|
+
|
|
40
|
+
Distribution `surf-cli`. Command `surf`. Python 3.12+; pypdf is the one runtime dependency, for PDF outlines. Only the section you name is printed, so the rest of the file never enters an agent's context.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uv tool install surf-cli # or: pipx install surf-cli, or: pip install surf-cli
|
|
46
|
+
surf --version
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
With Nix:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
nix profile install github:saintx/surf-cli # add ?ref=X.Y.Z to pin a release
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Quick start
|
|
56
|
+
|
|
57
|
+
The examples run against the reference files shipped with the agent skill:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
cd plugins/surf/skills/surf/references
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
A file with no heading named returns the map: frontmatter, then the heading tree, none of the body.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
$ surf about.md
|
|
67
|
+
---
|
|
68
|
+
metadata:
|
|
69
|
+
author:
|
|
70
|
+
name: Alexander R. Saint Croix
|
|
71
|
+
github_username: saintx
|
|
72
|
+
email: alex@saintx.us
|
|
73
|
+
twitter: alexsaintx
|
|
74
|
+
surf-version: "0.8.0"
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
- Surf — About
|
|
78
|
+
- Overview
|
|
79
|
+
- When to use
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
A heading returns that section and stops at the next heading of the same or higher level.
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
$ surf about.md "When to use"
|
|
86
|
+
## When to use
|
|
87
|
+
|
|
88
|
+
Invoke when skimming markdown, TeX, or PDF files, checking what a file contains, ...
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The same two commands work on TeX, addressed by sectioning commands and the `abstract` environment, and on PDF, addressed by outline bookmarks. `surf.tex` and `surf.pdf` are one paper in two forms and list the same tree from either.
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
$ surf surf.tex --list
|
|
95
|
+
- abstract
|
|
96
|
+
- Background
|
|
97
|
+
- A Thin Index Shaped by Intent
|
|
98
|
+
- Agentic Context Composition
|
|
99
|
+
- Skills You Can Check
|
|
100
|
+
- Indexes over Indexes
|
|
101
|
+
- Markdown, TeX, and PDF
|
|
102
|
+
- This Paper
|
|
103
|
+
|
|
104
|
+
$ surf surf.tex "Markdown, TeX, and PDF"
|
|
105
|
+
\section{Markdown, TeX, and PDF}
|
|
106
|
+
|
|
107
|
+
surf addresses a markdown file by its ATX headings, a TeX file by its sectioning
|
|
108
|
+
commands and its \texttt{abstract} environment, and a PDF by its outline. ...
|
|
109
|
+
|
|
110
|
+
$ surf surf.pdf "Markdown, TeX, and PDF"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Addressing
|
|
114
|
+
|
|
115
|
+
Suppose `guide.md` is:
|
|
116
|
+
|
|
117
|
+
```markdown
|
|
118
|
+
---
|
|
119
|
+
title: Guide
|
|
120
|
+
tags: [cli, docs]
|
|
121
|
+
---
|
|
122
|
+
# Guide
|
|
123
|
+
|
|
124
|
+
Intro paragraph.
|
|
125
|
+
|
|
126
|
+
## Install
|
|
127
|
+
|
|
128
|
+
### Usage
|
|
129
|
+
|
|
130
|
+
Install usage text.
|
|
131
|
+
|
|
132
|
+
## API
|
|
133
|
+
|
|
134
|
+
### Usage
|
|
135
|
+
|
|
136
|
+
API usage text.
|
|
137
|
+
|
|
138
|
+
#### Examples
|
|
139
|
+
|
|
140
|
+
Deep example.
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Its map is:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
$ surf guide.md
|
|
147
|
+
---
|
|
148
|
+
title: Guide
|
|
149
|
+
tags: [cli, docs]
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
- Guide
|
|
153
|
+
- Install
|
|
154
|
+
- Usage
|
|
155
|
+
- API
|
|
156
|
+
- Usage
|
|
157
|
+
- Examples
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Get one section.** Name the heading. The section runs to the next heading of the same or higher level, so a parent brings its children.
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
$ surf guide.md "API"
|
|
164
|
+
## API
|
|
165
|
+
|
|
166
|
+
### Usage
|
|
167
|
+
|
|
168
|
+
API usage text.
|
|
169
|
+
|
|
170
|
+
#### Examples
|
|
171
|
+
|
|
172
|
+
Deep example.
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Pick between two headings with the same name.** Write the path from the parent. A bare name matches the first occurrence in the file.
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
$ surf guide.md "API#Usage"
|
|
179
|
+
### Usage
|
|
180
|
+
|
|
181
|
+
API usage text.
|
|
182
|
+
|
|
183
|
+
#### Examples
|
|
184
|
+
|
|
185
|
+
Deep example.
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**List only the top N levels.** `--level N` on a listing shows ranks 1 through N.
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
$ surf guide.md --list --level 2
|
|
192
|
+
- Guide
|
|
193
|
+
- Install
|
|
194
|
+
- API
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Extract only at an exact level.** `--level N` on an extract matches rank N and nothing else. `Usage` exists only at rank 3, so rank 2 is not found.
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
$ surf guide.md "Examples" --level 4
|
|
201
|
+
#### Examples
|
|
202
|
+
|
|
203
|
+
Deep example.
|
|
204
|
+
|
|
205
|
+
$ surf guide.md "Usage" --level 2
|
|
206
|
+
Error: heading "Usage" not found in guide.md.
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Use a link as the address.** Obsidian wikilinks and markdown links resolve directly, `#` segments included.
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
surf "[[guide#API#Usage]]"
|
|
213
|
+
surf "[API](guide.md#API)"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Frontmatter only, or headings only.** `-f` prints the YAML block and nothing else. `--list` prints the tree and no YAML. `--full` prints the YAML and then the named section.
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
surf -f guide.md
|
|
220
|
+
surf --list guide.md
|
|
221
|
+
surf guide.md "Install" --full
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Drop the heading line, or write to a file.**
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
surf guide.md "API" --no-heading
|
|
228
|
+
surf guide.md "API" -o api.md
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**What counts as a heading.** On markdown, the ATX heading text. On TeX, the brace title of a sectioning command, plus `abstract` for the abstract environment; `\input` and `\include` of `.tex` files expand relative to the file you name, while graphics, comments, shell pipes, absolute paths, `..` segments, and macro-built paths do not. On PDF, an outline bookmark title; the extract is the page text from that bookmark to the next, and when the next bookmark shares a page, that page is included. Rank 1 is `#` on markdown, the shallowest sectioning command in the TeX file (`\section` in an article), and the outline's top rank on PDF.
|
|
232
|
+
|
|
233
|
+
Matching ignores case. `surf guide` resolves to `guide.md`; `.tex` and `.pdf` need their suffix. Any other UTF-8 file is addressed as ATX markdown.
|
|
234
|
+
|
|
235
|
+
**When there is nothing to address.** A file with no headings, or a PDF with no outline, prints `no structural index` and line and byte counts (page and byte counts on PDF), and exits 0. A heading that is not there exits 1 with `Error: heading "X" not found in guide.md.` A missing file or bad usage exits 2.
|
|
236
|
+
|
|
237
|
+
**Scan a directory.** Frontmatter across many files, no body loaded:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
surf -f docs/*.md
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Keep files whose frontmatter matches a key:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
surf --where title=Guide docs/*.md
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
`surf --help` lists every flag.
|
|
250
|
+
|
|
251
|
+
## Agent skill
|
|
252
|
+
|
|
253
|
+
`plugins/surf` packages a skill that teaches an agent how to use surf. It carries a Claude Code manifest, an Agent Plugins 1.0.0 manifest, and the skill itself at `plugins/surf/skills/surf`, in the Agent Skills format that Claude Code, Codex, Gemini CLI, Cursor, and Grok Build read. The skill shells out to `surf`, so install the CLI first.
|
|
254
|
+
|
|
255
|
+
Claude Code installs it from the marketplace in this repo:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
claude plugin marketplace add saintx/surf-cli
|
|
259
|
+
claude plugin install surf@surf-cli
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Any harness that reads a skills directory takes a copy:
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
cp -R plugins/surf/skills/surf ~/.agents/skills/surf
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
This checkout links `.agents/skills/surf`, `.claude/skills/surf`, and `.grok/skills/surf` into the plugin, so an agent working in the repo already has it.
|
|
269
|
+
|
|
270
|
+
The paper in `plugins/surf/skills/surf/references/surf.pdf` (also `surf.tex`) is about what surf can be used to build. surf itself is the primitive.
|
|
271
|
+
|
|
272
|
+
## Contributing
|
|
273
|
+
|
|
274
|
+
Development setup, tests, and lint are in [CONTRIBUTING.md](https://github.com/saintx/surf-cli/blob/main/CONTRIBUTING.md). The release procedure is in [RELEASING.md](https://github.com/saintx/surf-cli/blob/main/RELEASING.md).
|
|
275
|
+
|
|
276
|
+
## License
|
|
277
|
+
|
|
278
|
+
[MIT](https://github.com/saintx/surf-cli/blob/main/LICENSE).
|
surf_cli-0.8.0/README.md
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# surf
|
|
2
|
+
|
|
3
|
+
List headings, or extract one section by name, from Markdown, TeX, or PDF.
|
|
4
|
+
|
|
5
|
+
Distribution `surf-cli`. Command `surf`. Python 3.12+; pypdf is the one runtime dependency, for PDF outlines. Only the section you name is printed, so the rest of the file never enters an agent's context.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
uv tool install surf-cli # or: pipx install surf-cli, or: pip install surf-cli
|
|
11
|
+
surf --version
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
With Nix:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
nix profile install github:saintx/surf-cli # add ?ref=X.Y.Z to pin a release
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
The examples run against the reference files shipped with the agent skill:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cd plugins/surf/skills/surf/references
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
A file with no heading named returns the map: frontmatter, then the heading tree, none of the body.
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
$ surf about.md
|
|
32
|
+
---
|
|
33
|
+
metadata:
|
|
34
|
+
author:
|
|
35
|
+
name: Alexander R. Saint Croix
|
|
36
|
+
github_username: saintx
|
|
37
|
+
email: alex@saintx.us
|
|
38
|
+
twitter: alexsaintx
|
|
39
|
+
surf-version: "0.8.0"
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
- Surf — About
|
|
43
|
+
- Overview
|
|
44
|
+
- When to use
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
A heading returns that section and stops at the next heading of the same or higher level.
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
$ surf about.md "When to use"
|
|
51
|
+
## When to use
|
|
52
|
+
|
|
53
|
+
Invoke when skimming markdown, TeX, or PDF files, checking what a file contains, ...
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The same two commands work on TeX, addressed by sectioning commands and the `abstract` environment, and on PDF, addressed by outline bookmarks. `surf.tex` and `surf.pdf` are one paper in two forms and list the same tree from either.
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
$ surf surf.tex --list
|
|
60
|
+
- abstract
|
|
61
|
+
- Background
|
|
62
|
+
- A Thin Index Shaped by Intent
|
|
63
|
+
- Agentic Context Composition
|
|
64
|
+
- Skills You Can Check
|
|
65
|
+
- Indexes over Indexes
|
|
66
|
+
- Markdown, TeX, and PDF
|
|
67
|
+
- This Paper
|
|
68
|
+
|
|
69
|
+
$ surf surf.tex "Markdown, TeX, and PDF"
|
|
70
|
+
\section{Markdown, TeX, and PDF}
|
|
71
|
+
|
|
72
|
+
surf addresses a markdown file by its ATX headings, a TeX file by its sectioning
|
|
73
|
+
commands and its \texttt{abstract} environment, and a PDF by its outline. ...
|
|
74
|
+
|
|
75
|
+
$ surf surf.pdf "Markdown, TeX, and PDF"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Addressing
|
|
79
|
+
|
|
80
|
+
Suppose `guide.md` is:
|
|
81
|
+
|
|
82
|
+
```markdown
|
|
83
|
+
---
|
|
84
|
+
title: Guide
|
|
85
|
+
tags: [cli, docs]
|
|
86
|
+
---
|
|
87
|
+
# Guide
|
|
88
|
+
|
|
89
|
+
Intro paragraph.
|
|
90
|
+
|
|
91
|
+
## Install
|
|
92
|
+
|
|
93
|
+
### Usage
|
|
94
|
+
|
|
95
|
+
Install usage text.
|
|
96
|
+
|
|
97
|
+
## API
|
|
98
|
+
|
|
99
|
+
### Usage
|
|
100
|
+
|
|
101
|
+
API usage text.
|
|
102
|
+
|
|
103
|
+
#### Examples
|
|
104
|
+
|
|
105
|
+
Deep example.
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Its map is:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
$ surf guide.md
|
|
112
|
+
---
|
|
113
|
+
title: Guide
|
|
114
|
+
tags: [cli, docs]
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
- Guide
|
|
118
|
+
- Install
|
|
119
|
+
- Usage
|
|
120
|
+
- API
|
|
121
|
+
- Usage
|
|
122
|
+
- Examples
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Get one section.** Name the heading. The section runs to the next heading of the same or higher level, so a parent brings its children.
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
$ surf guide.md "API"
|
|
129
|
+
## API
|
|
130
|
+
|
|
131
|
+
### Usage
|
|
132
|
+
|
|
133
|
+
API usage text.
|
|
134
|
+
|
|
135
|
+
#### Examples
|
|
136
|
+
|
|
137
|
+
Deep example.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Pick between two headings with the same name.** Write the path from the parent. A bare name matches the first occurrence in the file.
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
$ surf guide.md "API#Usage"
|
|
144
|
+
### Usage
|
|
145
|
+
|
|
146
|
+
API usage text.
|
|
147
|
+
|
|
148
|
+
#### Examples
|
|
149
|
+
|
|
150
|
+
Deep example.
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**List only the top N levels.** `--level N` on a listing shows ranks 1 through N.
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
$ surf guide.md --list --level 2
|
|
157
|
+
- Guide
|
|
158
|
+
- Install
|
|
159
|
+
- API
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Extract only at an exact level.** `--level N` on an extract matches rank N and nothing else. `Usage` exists only at rank 3, so rank 2 is not found.
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
$ surf guide.md "Examples" --level 4
|
|
166
|
+
#### Examples
|
|
167
|
+
|
|
168
|
+
Deep example.
|
|
169
|
+
|
|
170
|
+
$ surf guide.md "Usage" --level 2
|
|
171
|
+
Error: heading "Usage" not found in guide.md.
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Use a link as the address.** Obsidian wikilinks and markdown links resolve directly, `#` segments included.
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
surf "[[guide#API#Usage]]"
|
|
178
|
+
surf "[API](guide.md#API)"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Frontmatter only, or headings only.** `-f` prints the YAML block and nothing else. `--list` prints the tree and no YAML. `--full` prints the YAML and then the named section.
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
surf -f guide.md
|
|
185
|
+
surf --list guide.md
|
|
186
|
+
surf guide.md "Install" --full
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Drop the heading line, or write to a file.**
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
surf guide.md "API" --no-heading
|
|
193
|
+
surf guide.md "API" -o api.md
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**What counts as a heading.** On markdown, the ATX heading text. On TeX, the brace title of a sectioning command, plus `abstract` for the abstract environment; `\input` and `\include` of `.tex` files expand relative to the file you name, while graphics, comments, shell pipes, absolute paths, `..` segments, and macro-built paths do not. On PDF, an outline bookmark title; the extract is the page text from that bookmark to the next, and when the next bookmark shares a page, that page is included. Rank 1 is `#` on markdown, the shallowest sectioning command in the TeX file (`\section` in an article), and the outline's top rank on PDF.
|
|
197
|
+
|
|
198
|
+
Matching ignores case. `surf guide` resolves to `guide.md`; `.tex` and `.pdf` need their suffix. Any other UTF-8 file is addressed as ATX markdown.
|
|
199
|
+
|
|
200
|
+
**When there is nothing to address.** A file with no headings, or a PDF with no outline, prints `no structural index` and line and byte counts (page and byte counts on PDF), and exits 0. A heading that is not there exits 1 with `Error: heading "X" not found in guide.md.` A missing file or bad usage exits 2.
|
|
201
|
+
|
|
202
|
+
**Scan a directory.** Frontmatter across many files, no body loaded:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
surf -f docs/*.md
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Keep files whose frontmatter matches a key:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
surf --where title=Guide docs/*.md
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
`surf --help` lists every flag.
|
|
215
|
+
|
|
216
|
+
## Agent skill
|
|
217
|
+
|
|
218
|
+
`plugins/surf` packages a skill that teaches an agent how to use surf. It carries a Claude Code manifest, an Agent Plugins 1.0.0 manifest, and the skill itself at `plugins/surf/skills/surf`, in the Agent Skills format that Claude Code, Codex, Gemini CLI, Cursor, and Grok Build read. The skill shells out to `surf`, so install the CLI first.
|
|
219
|
+
|
|
220
|
+
Claude Code installs it from the marketplace in this repo:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
claude plugin marketplace add saintx/surf-cli
|
|
224
|
+
claude plugin install surf@surf-cli
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Any harness that reads a skills directory takes a copy:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
cp -R plugins/surf/skills/surf ~/.agents/skills/surf
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
This checkout links `.agents/skills/surf`, `.claude/skills/surf`, and `.grok/skills/surf` into the plugin, so an agent working in the repo already has it.
|
|
234
|
+
|
|
235
|
+
The paper in `plugins/surf/skills/surf/references/surf.pdf` (also `surf.tex`) is about what surf can be used to build. surf itself is the primitive.
|
|
236
|
+
|
|
237
|
+
## Contributing
|
|
238
|
+
|
|
239
|
+
Development setup, tests, and lint are in [CONTRIBUTING.md](https://github.com/saintx/surf-cli/blob/main/CONTRIBUTING.md). The release procedure is in [RELEASING.md](https://github.com/saintx/surf-cli/blob/main/RELEASING.md).
|
|
240
|
+
|
|
241
|
+
## License
|
|
242
|
+
|
|
243
|
+
[MIT](https://github.com/saintx/surf-cli/blob/main/LICENSE).
|