@orkestrel/guide 0.0.8 → 0.0.9

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 CHANGED
@@ -18,35 +18,42 @@ npm install -D @orkestrel/guide
18
18
 
19
19
  ## Requirements
20
20
 
21
- - Node.js >= 24
22
- - ESM-only (no CommonJS build)
21
+ - Node.js >= 22.12.0
22
+ - ESM and CommonJS
23
23
 
24
24
  ## Usage
25
25
 
26
26
  The entire consumer-side footprint is one short test file. An excerpt of the
27
27
  drop-in pattern (`tests/guides/src/parity.test.ts`):
28
28
 
29
- The consumer supplies the file inventory `Source` reflects over — gathered
30
- with `node:fs` in a Node test file, or `import.meta.glob` under a browser
31
- vitest project. This excerpt uses a Node `readFileSync`-backed inventory:
29
+ The consumer supplies the file inventory `Source` reflects over. The inventory
30
+ below is an illustrative, non-runnable placeholder until the consumer supplies
31
+ real workspace text; the complete runnable implementation is
32
+ [`tests/guides/src/parity.test.ts`](tests/guides/src/parity.test.ts).
32
33
 
33
34
  ```ts
34
- import { readFileSync } from 'node:fs'
35
- import { fileURLToPath } from 'node:url'
35
+ import { expect, it } from 'vitest'
36
36
  import { createGuide, createSource, missingSymbols, parseManifest } from '@orkestrel/guide'
37
37
 
38
- const ROOT = fileURLToPath(new URL('../../../', import.meta.url))
39
- const files: Record<string, string> = {/* root-relative path → file text */}
40
- const readText = (relative: string) =>
41
- files[relative] ?? readFileSync(new URL(relative, ROOT), 'utf8')
38
+ declare const files: Readonly<Record<string, string>> // illustrative root-relative inventory
39
+ declare function readText(relative: string): string // required exact lookup supplied by the consumer
40
+
42
41
  const manifest = parseManifest(readText('guides/README.md'), 'guides')
43
42
 
43
+ it('lists at least one guide', () => {
44
+ expect(manifest.length).toBeGreaterThan(0)
45
+ })
46
+
44
47
  for (const entry of manifest) {
45
48
  const guide = createGuide(readText(entry.spec))
46
49
  const source = createSource({ files, module: entry.source })
47
50
 
48
- it('documents every source export', () => {
49
- expect(missingSymbols(source.exports(), guide.surface())).toEqual([])
51
+ it('keeps direct declarations, the public barrel, and the guide equal', () => {
52
+ expect(guide.surface().length).toBeGreaterThan(0)
53
+ expect(missingSymbols(source.exports(), source.surface())).toEqual([])
54
+ expect(missingSymbols(source.surface(), source.exports())).toEqual([])
55
+ expect(missingSymbols(source.surface(), guide.surface())).toEqual([])
56
+ expect(missingSymbols(guide.surface(), source.surface())).toEqual([])
50
57
  })
51
58
  }
52
59
  ```
@@ -54,10 +61,47 @@ for (const entry of manifest) {
54
61
  Every row added to the consumer's `guides/README.md` manifest auto-extends
55
62
  coverage with zero test edits.
56
63
 
64
+ `exports()` inventories direct `type`, `interface`, `const`, `function`, and
65
+ `class` declarations in the selected directories' canonical-segment module
66
+ keys. `hidden()` reflects the same five declaration kinds without `export`.
67
+ Both use the one structured physical-line projection: each record retains exact
68
+ raw source, equal-length projected code, and an equal-length genuine JSDoc view
69
+ that retains every genuine span at its physical column. Comment and template
70
+ payload is excluded, but projection does not grant membership. Direct/hidden
71
+ declaration heads remain uninterrupted and column-zero. `enum` is outside this reflection
72
+ population, not forbidden by general package policy.
73
+
74
+ `surface()` inventories declarations reachable through exact `index.ts` for the
75
+ canonical workspace-root module `'.'`, or exact `<dir>/index.ts` for a nested
76
+ module. It follows only complete relative `.js` star
77
+ rows, maps the terminal `.js` to an exact `.ts` inventory key, and recursively
78
+ follows exact workspace-root `index.ts` and nested `/index.ts` targets. Missing
79
+ roots and targets, unsupported export forms, and declarations written directly
80
+ in an index contribute nothing. `resolvePath(directory, target)` owns pure
81
+ directory-relative dot-segment reduction; `resolveLink(file, target)` adapts a
82
+ declaring file to that engine. Neither performs filesystem or extension
83
+ inference. Module spellings canonicalize through
84
+ `resolvePath`/`normalizeDirectories`, while `hasCanonicalSegments` excludes
85
+ opaque inventory keys containing empty, `.` or `..` segments without rewriting
86
+ them; ordinary dotfiles remain eligible. Both initial barrels and resolved row
87
+ targets must be canonical after relative-row reduction, while parent rows that
88
+ reduce to canonical inventory keys remain valid. Barrel rows have their own
89
+ whitespace-tolerant whole-line grammar.
90
+
91
+ Regex preservation follows a bounded lexical goal rather than full TypeScript
92
+ parser grammar. Literal ECMAScript Unicode identifiers participate in slash-state
93
+ recognition without claiming general TypeScript parsing or escaped-identifier
94
+ decoding. Slash immediately after bare `}` is division; a regex statement after
95
+ a closing brace needs an explicit `;` to enter the supported population. General
96
+ semicolonless declaration/ASI classification is also outside the finite projector,
97
+ so callers use an explicit `;` before a slash-leading statement after such a
98
+ declaration.
99
+
57
100
  ## Checks
58
101
 
59
- - **Surface bijection** — every documented `## Surface` symbol (name + kind)
60
- matches a real export, and vice versa.
102
+ - **Surface parity** — intentional direct declarations, the conventional
103
+ barrel-reachable surface, and documented `## Surface` symbols match by name
104
+ and kind in both directions.
61
105
  - **Methods bijection + class-no-extra** — every documented `## Methods`
62
106
  member matches the interface's implementer, and the implementing class
63
107
  exposes no undocumented public method.
@@ -68,36 +112,64 @@ coverage with zero test edits.
68
112
  - **Non-vacuousness guards** — the manifest, each guide's surface, and each
69
113
  method group must extract non-empty, so a renamed heading fails loudly
70
114
  instead of passing vacuously.
115
+ - **Examples presence** — every documented function and method appears in a
116
+ TypeScript fence or carries an immediately preceding eligible genuine JSDoc
117
+ chain whose final authoritative span has an exact block-position `@example`
118
+ tag. Title text is allowed; intervening material severs association.
119
+ - **Fence-import reality** — every self-package name imported in a TypeScript
120
+ fence exists on the conventional public/barrel surface.
71
121
 
72
122
  ## API
73
123
 
74
124
  - `createGuide(source)` — parses one guide's markdown into a structured,
75
- cached view (`surface()`, `methods()`, `links()`, `tests()`).
76
- - `createSource(options)` — reflects real exports/members/existence over a
77
- consumer-supplied file inventory (`options.files`), for one or more source
78
- directories.
79
- - `parseManifest(markdown, base)` — extracts the `## By concept` rows from a
80
- `guides/README.md` manifest.
125
+ cached view with six projections (`sections()`, `surface()`, `methods()`,
126
+ `links()`, `tests()`, `patterns()`).
127
+ - `createSource(options)` — reflects intentional direct declarations with
128
+ `exports()`, conventional barrel reachability with `surface()`, members with
129
+ `methods()`, path presence with `exists()`, hidden declarations with
130
+ `hidden()`, and TSDoc example membership with `examples()`, over a
131
+ consumer-supplied file inventory for one or more source directories. Both
132
+ declaration projections are lazy, cached, deduplicated by name and kind, and
133
+ sorted by name.
134
+ - `parseManifest(markdown, directory)` — extracts the `## By concept` rows
135
+ from a manifest directory, including nested directories.
81
136
  - `missingSymbols(symbols, source)` — the `(name, kind)` set difference
82
137
  driving surface bijection.
138
+ - `extractSourceLines(source)` — returns one `SourceLine` per physical line,
139
+ including the final line, with exact `source`, equal-length masked `code`, and
140
+ equal-length genuine `jsdoc` retaining every span at its physical column, or
141
+ `undefined`.
142
+ - `extractExampleLines(lines)` — selects the single physical candidate line
143
+ after an eligible leading JSDoc chain whose last whitespace-separated span
144
+ carries an exact block-position `@example`; title text is allowed, intervening
145
+ material severs association, and the next physical record is consumed once.
146
+ - `hasCanonicalSegments(key)` — rejects empty, `.` and `..` opaque key
147
+ segments without normalization while retaining dotfiles.
148
+ - `normalizeDirectories(module)` — canonicalizes one or more module spellings
149
+ through `resolvePath` and removes duplicates in first-seen order.
150
+ - `selectModuleKeys(files, module)` — selects sorted canonical-segment `.ts`
151
+ keys under a module scope, excluding selected indexes and test files.
83
152
  - `findMissing(names, source)` — the plain set difference driving methods
84
153
  bijection and link/test checks.
85
154
  - `isExternalLink(href)` — true for `http`/`https`/`mailto`/`tel`/`#` links.
86
- - `resolveLink(from, target)` — resolves a guide-relative link against the
87
- guide's own directory.
155
+ - `resolvePath(directory, target)` — normalizes a directory-relative target,
156
+ returns `'.'` when all segments cancel, and preserves excess leading parents.
157
+ - `resolveLink(file, target)` — resolves a relative target from its declaring
158
+ file, including files at the workspace root.
88
159
 
89
160
  ## Guide
90
161
 
91
162
  For the full surface — the guide anatomy, the manifest format, and the check
92
163
  catalog — see [`guides/src/guide.md`](guides/src/guide.md). For the design
93
- rationale, see [`PROPOSAL.md`](./PROPOSAL.md). For the guide index, see
94
- [`guides/`](./guides/).
164
+ and guide index, see [`guides/`](./guides/).
95
165
 
96
166
  ## Package
97
167
 
98
- Published as a single pure, typed entry point — `@orkestrel/guide` — per the
99
- `exports` field in `package.json`. No filesystem or network access; the
100
- consumer supplies the file inventory `Source` reflects over.
168
+ Published as one pure, I/O-free typed entry point — `@orkestrel/guide` — per
169
+ the `exports` field in `package.json`, with both ESM and CommonJS output. The
170
+ consumer supplies the file inventory `Source` reflects over; runtime
171
+ dependencies provide parsing and contract primitives without changing that
172
+ boundary.
101
173
 
102
174
  ## License
103
175