projview 0.4.0 → 0.4.1
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.
- package/README.md +19 -0
- package/docs/README.md +1 -0
- package/docs/ai-tests/search.md +120 -0
- package/docs/how-to-set-up.md +17 -2
- package/docs/reference/api.md +17 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,25 @@ projview ./docs --port 5000
|
|
|
26
26
|
projview /path/to/notes --no-open
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
## use it from scripts or an AI
|
|
30
|
+
|
|
31
|
+
projview also has a **machine interface** - subcommands that print JSON to stdout
|
|
32
|
+
and exit (no server, no browser), so an agent or script can query your docs:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
projview search "<query>" [path] # ranked: filename matches + in-content hits w/ line snippets
|
|
36
|
+
projview tree [path] # the file tree as JSON
|
|
37
|
+
projview search "mermaid" --demo # quick test on the bundled docs
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```jsonc
|
|
41
|
+
// projview search "live reload"
|
|
42
|
+
{ "query": "live reload",
|
|
43
|
+
"files": [ /* fuzzy filename matches: {path, name, score} */ ],
|
|
44
|
+
"content": [ { "path": "reference/api.md", "count": 4,
|
|
45
|
+
"snippets": [ { "line": 68, "text": "### live reload" } ] } ] }
|
|
46
|
+
```
|
|
47
|
+
|
|
29
48
|
## what it does
|
|
30
49
|
|
|
31
50
|
| step | detail |
|
package/docs/README.md
CHANGED
|
@@ -21,6 +21,7 @@ faults. use this tree while iterating on the tool.
|
|
|
21
21
|
| edge | [syntax stress](edge-cases/syntax-stress.md) | gnarly markdown + inline broken fence |
|
|
22
22
|
| edge | [faulty refs](edge-cases/faulty-refs.md) | **several dead links** on purpose |
|
|
23
23
|
| edge | [buried file](edge-cases/deep/nested/buried.md) | deep nesting - indentation + auto-expand |
|
|
24
|
+
| ai-tests | [search test](ai-tests/search.md) | AI-run test of the `projview search` machine interface |
|
|
24
25
|
|
|
25
26
|
## intentional faults (should NOT crash the app)
|
|
26
27
|
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# search functionality - AI test
|
|
2
|
+
|
|
3
|
+
An AI-driven test of projview's `search` **machine interface** (`projview search
|
|
4
|
+
<query>` → JSON on stdout). The goal: probe distinct behaviours of the engine -
|
|
5
|
+
content search, fuzzy filenames, multi-term logic, ranking, and edge cases - by
|
|
6
|
+
running the published CLI and inspecting the JSON it returns.
|
|
7
|
+
|
|
8
|
+
## experimental parameters
|
|
9
|
+
|
|
10
|
+
| parameter | value |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| tool | `projview` (global install) |
|
|
13
|
+
| version | `0.4.0` |
|
|
14
|
+
| command form | `projview search "<query>" --demo` |
|
|
15
|
+
| dataset | the bundled demo docs (`--demo`) - **14 files** at time of test |
|
|
16
|
+
| output | JSON: `{ query, files[], content[] }` parsed from stdout |
|
|
17
|
+
| ranking | filenames by fuzzy subsequence score; contents by term frequency |
|
|
18
|
+
|
|
19
|
+
> Note: this very report is the 15th file in the set, so re-running the probes
|
|
20
|
+
> below will now also surface `ai-tests/search.md` itself.
|
|
21
|
+
|
|
22
|
+
## method
|
|
23
|
+
|
|
24
|
+
Five search terms were chosen, each targeting a different aspect of the engine:
|
|
25
|
+
|
|
26
|
+
| # | term | aspect under test |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| 1 | `live reload` | content search across multiple files + snippet line numbers |
|
|
29
|
+
| 2 | `mermaid` | frequency ranking + case-insensitivity (`MERMAID` vs `mermaid`) |
|
|
30
|
+
| 3 | `cfg` | fuzzy **filename** match (subsequence), independent of content |
|
|
31
|
+
| 4 | `broken diagram` | multi-term **AND** logic + cross-file ranking |
|
|
32
|
+
| 5 | `kubernetes` | graceful **no-match** behaviour |
|
|
33
|
+
|
|
34
|
+
## results
|
|
35
|
+
|
|
36
|
+
### 1. content search - `live reload`
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
projview search "live reload" --demo
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Three files matched, ranked by frequency, each snippet carrying a line number:
|
|
43
|
+
|
|
44
|
+
| file | hits | top snippet |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| `reference/api.md` | 4 | L68 `### live reload` |
|
|
47
|
+
| `diagrams/sequence.mmd` | 2 | L13 `edit a file -> SSE -> live reload` |
|
|
48
|
+
| `reference/glossary.md` | 2 | L9 `live reload - SSE-driven refresh` |
|
|
49
|
+
|
|
50
|
+
✅ Multi-file content search, frequency-ordered, with usable `file:line` citations.
|
|
51
|
+
|
|
52
|
+
### 2. ranking + case-insensitivity - `mermaid`
|
|
53
|
+
|
|
54
|
+
`mermaid` returned **8** content matches. Crucially, `MERMAID` (uppercase)
|
|
55
|
+
returned the **same 8** - the query is lower-cased before matching.
|
|
56
|
+
|
|
57
|
+
✅ Case-insensitive; ranked by occurrence count.
|
|
58
|
+
|
|
59
|
+
### 3. fuzzy filename match - `cfg`
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
projview search "cfg" --demo
|
|
63
|
+
# files: ["guides/configuration.md"]
|
|
64
|
+
# content: (none)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`cfg` is not a substring of any document body, but it **is** a subsequence of
|
|
68
|
+
`configuration.md`, so it surfaces in the `files` block while `content` stays empty.
|
|
69
|
+
|
|
70
|
+
✅ Filename matching is fuzzy (subsequence) and independent of content search.
|
|
71
|
+
|
|
72
|
+
### 4. multi-term AND + ranking - `broken diagram`
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
projview search "broken diagram" --demo
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| file | hits |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `README.md` | 12 |
|
|
81
|
+
| `guides/troubleshooting.md` | 7 |
|
|
82
|
+
| `edge-cases/syntax-stress.md` | 6 |
|
|
83
|
+
| `guides/configuration.md` | 3 |
|
|
84
|
+
| `edge-cases/faulty-refs.md` | 2 |
|
|
85
|
+
|
|
86
|
+
Only files containing **both** terms appear; ranking is by total term frequency.
|
|
87
|
+
|
|
88
|
+
✅ Multi-term is a **file-level AND** (every term must appear somewhere in the
|
|
89
|
+
file), ranked by combined frequency.
|
|
90
|
+
|
|
91
|
+
### 5. graceful no-match - `kubernetes`
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
projview search "kubernetes" --demo
|
|
95
|
+
# { "query": "kubernetes", "files": [], "content": [] }
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
✅ Empty arrays, exit code `0` - a clean "nothing found", not an error.
|
|
99
|
+
|
|
100
|
+
## observations & limitations
|
|
101
|
+
|
|
102
|
+
- **Case-insensitive** matching (query is lower-cased).
|
|
103
|
+
- **Multi-term = file-level AND**, not phrase match - the words can be anywhere in
|
|
104
|
+
the file, ranked by total frequency.
|
|
105
|
+
- **Snippets are first-occurrence**: the shown snippet is the first line containing
|
|
106
|
+
*any* query term, which isn't always the most relevant line for multi-term
|
|
107
|
+
queries. (A future improvement: prefer lines matching the most terms.)
|
|
108
|
+
- **Two independent result blocks**: `files` (fuzzy filename) and `content`
|
|
109
|
+
(full-text) - either can be populated without the other.
|
|
110
|
+
|
|
111
|
+
## reproduce
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm i -g projview@latest
|
|
115
|
+
projview search "live reload" --demo
|
|
116
|
+
projview search "cfg" --demo
|
|
117
|
+
projview search "broken diagram" --demo
|
|
118
|
+
projview search "kubernetes" --demo
|
|
119
|
+
projview tree --demo # list the dataset
|
|
120
|
+
```
|
package/docs/how-to-set-up.md
CHANGED
|
@@ -66,7 +66,7 @@ npm install
|
|
|
66
66
|
npm run demo # preview the bundled docs/ (alias for --demo)
|
|
67
67
|
npm start # index the current directory
|
|
68
68
|
node bin/projview.js ./docs # or call the CLI directly
|
|
69
|
-
npm test # run the test suite (node:test,
|
|
69
|
+
npm test # run the test suite (node:test, 29 tests)
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
See the [project README](README.md) for the architecture and the
|
|
@@ -74,12 +74,27 @@ See the [project README](README.md) for the architecture and the
|
|
|
74
74
|
|
|
75
75
|
## CLI reference
|
|
76
76
|
|
|
77
|
+
**Commands**
|
|
78
|
+
|
|
79
|
+
| command | meaning |
|
|
80
|
+
| --- | --- |
|
|
81
|
+
| `projview [path]` | start the viewer (default) |
|
|
82
|
+
| `projview search <query> [path]` | print ranked search results as JSON, then exit |
|
|
83
|
+
| `projview tree [path]` | print the file tree as JSON, then exit |
|
|
84
|
+
|
|
85
|
+
The `search` and `tree` subcommands are projview's **machine interface** - JSON on
|
|
86
|
+
stdout, no server, no browser - built for agents and scripts. See
|
|
87
|
+
[ai-tests/search.md](ai-tests/search.md) for a worked test.
|
|
88
|
+
|
|
89
|
+
**Options**
|
|
90
|
+
|
|
77
91
|
| argument / flag | meaning |
|
|
78
92
|
| --- | --- |
|
|
79
93
|
| `[path]` | directory to index (default: current directory) |
|
|
80
|
-
| `--demo` |
|
|
94
|
+
| `--demo` | use projview's own bundled sample docs (works with the subcommands too) |
|
|
81
95
|
| `-p`, `--port <n>` | preferred port (default `4321`, climbs if taken) |
|
|
82
96
|
| `--no-open` | don't auto-open the browser |
|
|
97
|
+
| `-v`, `--version` | print the version and exit |
|
|
83
98
|
| `-h`, `--help` | show help |
|
|
84
99
|
|
|
85
100
|
**Environment variables** (handy for containers / servers):
|
package/docs/reference/api.md
CHANGED
|
@@ -21,6 +21,22 @@ Renders a single file to HTML on demand. Query param `p` is the relative path.
|
|
|
21
21
|
|
|
22
22
|
Server-sent events stream for live reload.
|
|
23
23
|
|
|
24
|
+
## machine interface (CLI)
|
|
25
|
+
|
|
26
|
+
Besides the HTTP server, two subcommands print JSON to stdout and exit - no
|
|
27
|
+
server, no browser - for agents and scripts.
|
|
28
|
+
|
|
29
|
+
### projview search
|
|
30
|
+
|
|
31
|
+
`projview search "<query>" [path]` returns `{ query, files[], content[] }`.
|
|
32
|
+
Filenames match fuzzily (subsequence); contents are ranked by term frequency with
|
|
33
|
+
line-numbered snippets. See [the AI search test](../ai-tests/search.md).
|
|
34
|
+
|
|
35
|
+
### projview tree
|
|
36
|
+
|
|
37
|
+
`projview tree [path]` returns `{ root, files, tree[] }` - the same structure
|
|
38
|
+
`/api/tree` serves.
|
|
39
|
+
|
|
24
40
|
## the walker
|
|
25
41
|
|
|
26
42
|
### ignored directories
|
|
@@ -59,7 +75,7 @@ Requested paths are resolved and confined to the root.
|
|
|
59
75
|
|
|
60
76
|
### tree nav
|
|
61
77
|
|
|
62
|
-
Collapsible dirs,
|
|
78
|
+
Collapsible dirs, cmd+K search palette, auto-expand on navigate.
|
|
63
79
|
|
|
64
80
|
### viewer
|
|
65
81
|
|