reading-stone 0.0.0-stage → 0.2.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.
Files changed (72) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +11 -0
  3. package/README.md +301 -2
  4. package/dist/analysis.d.ts +341 -0
  5. package/dist/analysis.js +392 -0
  6. package/dist/cognitive.d.ts +163 -0
  7. package/dist/cognitive.js +380 -0
  8. package/dist/complexity.d.ts +102 -0
  9. package/dist/complexity.js +163 -0
  10. package/dist/coverage.d.ts +78 -0
  11. package/dist/coverage.js +635 -0
  12. package/dist/detector.d.ts +41 -0
  13. package/dist/detector.js +2134 -0
  14. package/dist/discovery.d.ts +330 -0
  15. package/dist/discovery.js +930 -0
  16. package/dist/doc-coverage.d.ts +155 -0
  17. package/dist/doc-coverage.js +543 -0
  18. package/dist/extract.d.ts +209 -0
  19. package/dist/extract.js +498 -0
  20. package/dist/index.d.ts +64 -0
  21. package/dist/index.js +63 -0
  22. package/dist/internal.d.ts +75 -0
  23. package/dist/internal.js +63 -0
  24. package/dist/main.d.ts +8 -0
  25. package/dist/main.js +39 -0
  26. package/dist/models.d.ts +185 -0
  27. package/dist/models.js +170 -0
  28. package/dist/program.d.ts +207 -0
  29. package/dist/program.js +662 -0
  30. package/dist/protocol.d.ts +88 -0
  31. package/dist/protocol.js +74 -0
  32. package/dist/quality/assertions.d.ts +81 -0
  33. package/dist/quality/assertions.js +425 -0
  34. package/dist/quality/collect.d.ts +66 -0
  35. package/dist/quality/collect.js +412 -0
  36. package/dist/quality/inference.d.ts +86 -0
  37. package/dist/quality/inference.js +603 -0
  38. package/dist/quality/matchers.d.ts +129 -0
  39. package/dist/quality/matchers.js +220 -0
  40. package/dist/quality/pairing.d.ts +133 -0
  41. package/dist/quality/pairing.js +770 -0
  42. package/dist/quality/pipeline.d.ts +59 -0
  43. package/dist/quality/pipeline.js +202 -0
  44. package/dist/quality/types.d.ts +127 -0
  45. package/dist/quality/types.js +92 -0
  46. package/dist/safeio.d.ts +107 -0
  47. package/dist/safeio.js +314 -0
  48. package/dist/server.d.ts +19 -0
  49. package/dist/server.js +451 -0
  50. package/dist/signals/adapter.d.ts +103 -0
  51. package/dist/signals/adapter.js +323 -0
  52. package/dist/signals/caller-index.d.ts +117 -0
  53. package/dist/signals/caller-index.js +147 -0
  54. package/dist/signals/caller.d.ts +76 -0
  55. package/dist/signals/caller.js +108 -0
  56. package/dist/signals/evidence.d.ts +233 -0
  57. package/dist/signals/evidence.js +578 -0
  58. package/dist/signals/interface.d.ts +68 -0
  59. package/dist/signals/interface.js +87 -0
  60. package/dist/signals/jsdoc.d.ts +27 -0
  61. package/dist/signals/jsdoc.js +233 -0
  62. package/dist/signals/naming.d.ts +26 -0
  63. package/dist/signals/naming.js +160 -0
  64. package/dist/signals/routing.d.ts +163 -0
  65. package/dist/signals/routing.js +416 -0
  66. package/dist/signals/types.d.ts +146 -0
  67. package/dist/signals/types.js +99 -0
  68. package/dist/signals/visibility.d.ts +23 -0
  69. package/dist/signals/visibility.js +82 -0
  70. package/dist/taxonomy.d.ts +89 -0
  71. package/dist/taxonomy.js +217 -0
  72. package/package.json +61 -4
@@ -0,0 +1,155 @@
1
+ /**
2
+ * The `doc_coverage` method (spec 005, FR-001 to FR-004 and FR-011;
3
+ * research R1-R4): the documented-symbol surface walk, its wire record,
4
+ * and the serializer that emits it.
5
+ *
6
+ * The walk enumerates the exported source-level symbols of an analysis
7
+ * scope and reports, per symbol, whether a JSDoc comment is attached
8
+ * (FR-002) and the first summary line of its description (FR-003). The
9
+ * symbol surface (FR-002): exported function declarations (anonymous
10
+ * `export default function` included), exported variable declarations —
11
+ * a const with a function-like initializer routes to "function", any
12
+ * other const to "constant", let and var to "variable" — exported
13
+ * classes with their public method members (constructors, methods,
14
+ * accessors), and exported type, interface, and enum declarations. An
15
+ * `export default` naming an identifier emits the rows of the
16
+ * module-level declaration it names, under that declaration's own name,
17
+ * kind, and documentation.
18
+ *
19
+ * Boundary forms emit no row by design, never by silent omission
20
+ * (Principle II): non-exported declarations; export clauses and
21
+ * re-exports, whose rows belong to the declaration's own export
22
+ * spelling; default exports of expressions (arrows, literals, object
23
+ * literals), which name no declaration; `export =` and `module.exports`,
24
+ * the CommonJS boundaries; destructuring binding patterns, which bind
25
+ * many spellings to no single named symbol; namespaces and their
26
+ * members; body-less overload and ambient signatures, whose
27
+ * implementation signature is the symbol's documentation site; and
28
+ * non-public class members (private, protected, #private).
29
+ *
30
+ * Constitution alignment:
31
+ *
32
+ * - Principle I (Protocol Fidelity): rows serialize to the doc_coverage
33
+ * wire shape — name, package, kind, file, line, documented, and
34
+ * doc_snippet only when a summary line exists — in the canonical
35
+ * sorted-key order the protocol layer's own serializer produces, so
36
+ * its pass is a structural no-op (the serializeComplexityEntry
37
+ * discipline).
38
+ * - Principle III (TypeScript-Native Analysis): JSDoc attachment is read
39
+ * from the compiler's jsDoc arrays and the parent-hosting walk
40
+ * evidence.ts mirrors from the compiler's own
41
+ * `getNextJSDocCommentLocation` (nextJSDocHost — one shared hosting
42
+ * surface, so the doc and signal pipelines cannot drift), and comment
43
+ * text through the compiler's own `getTextOfJSDocComment` renderer —
44
+ * no custom doc parser. Verified against typescript 7.0.2: the
45
+ * renderer strips the ` * ` line decoration and per-line leading
46
+ * whitespace, preserves interior newlines, and keeps block tags out of
47
+ * the description — so FR-003's leading-`*` trim is discharged by the
48
+ * compiler surface itself, and stripping another asterisk here would
49
+ * mangle content asterisks the renderer deliberately preserves (a
50
+ * `**bold**` summary line survives verbatim).
51
+ * - Principle IV (Testability): the walk core is a pure
52
+ * PreparedAnalysis-to-SymbolRow[] function; the entry owns the
53
+ * program-context lifetime and closes it in a finally, exactly as
54
+ * computeComplexity does, so no native compiler server outlives one
55
+ * analysis.
56
+ * - Principle V (Analysis Safety): static analysis only — the walk reads
57
+ * the compiler's AST and never executes analyzed source.
58
+ */
59
+ import type { Writable } from "node:stream";
60
+ /**
61
+ * The kind of a documented-symbol row (FR-001): the closed set the gaze
62
+ * protocol's doc_coverage schema accepts — function, type, constant,
63
+ * variable, class, method. Declared in full so every routed declaration
64
+ * shape lands in the existing vocabulary; the walk's routing widens,
65
+ * the wire set never does.
66
+ */
67
+ export type SymbolKind = "function" | "type" | "constant" | "variable" | "class" | "method";
68
+ /**
69
+ * One documented-symbol row (FR-001): the symbol identity, its
70
+ * documentation fact, and — when a summary line exists — the first line
71
+ * of the attached JSDoc description. Field names mirror the wire payload
72
+ * exactly, snake_case included (`doc_snippet`, the MappingRow and
73
+ * FunctionRecord.side_effects precedent), and the entity is an
74
+ * immutable value record (convention pack AP-004).
75
+ */
76
+ export interface SymbolRow {
77
+ /**
78
+ * The declared name; the literal "default" for an anonymous
79
+ * export-default function or class declaration.
80
+ */
81
+ readonly name: string;
82
+ /** Dotted module path derived by `derivePackage` from `file`. */
83
+ readonly package: string;
84
+ /** The symbol's kind; see SymbolKind. */
85
+ readonly kind: SymbolKind;
86
+ /** Root-relative POSIX path of the declaring file. */
87
+ readonly file: string;
88
+ /**
89
+ * 1-based line of the declaration's first token — modifiers included
90
+ * (`export` for statements, accessibility keywords for class members)
91
+ * — never its JSDoc.
92
+ */
93
+ readonly line: number;
94
+ /** True if and only if a JSDoc comment is attached to the declaration (FR-002). */
95
+ readonly documented: boolean;
96
+ /** The first summary line of the description (FR-003): omitted when absent, never empty. */
97
+ readonly doc_snippet?: string;
98
+ }
99
+ /**
100
+ * The `doc_coverage` method entry (FR-001 to FR-004; the analyze-shaped
101
+ * surface T018 established): the serialized SymbolRow array — one row
102
+ * per in-scope symbol of the FR-002 surface — assembled in the (file,
103
+ * line, name) total order and mapped through serializeSymbolRow so
104
+ * every element of the returned array is wire-final.
105
+ *
106
+ * The returned array — not a {symbols: [...]} wrapper — follows the
107
+ * computeComplexity split: the T009 server handler wraps the array into
108
+ * the doc_coverage result shape, exactly as it wraps the complexity
109
+ * entries. Both this entry and its payload are deterministic pure
110
+ * functions of the analyzed tree (Constitution Principle I).
111
+ *
112
+ * The program-mode context's lifetime is this handler's — closed in the
113
+ * finally whatever the walk outcome, exactly as analyze and
114
+ * computeComplexity close theirs; a parse-only context owns nothing to
115
+ * dispose.
116
+ *
117
+ * @param rootPath Absolute or relative project root; validated and
118
+ * realpath-resolved by prepareAnalysis (an invalid root throws
119
+ * InvalidRootPathError, which the server maps to -32602).
120
+ * @param patterns The raw patterns parameter value; shape-validated by
121
+ * the server (-32602) before analysis runs, normalized here.
122
+ * @param stderr Injected diagnostic sink (Testability principle);
123
+ * defaults to process.stderr. Stdout is never touched.
124
+ * @returns The serialized symbol rows, (file, line, name)-sorted.
125
+ * @throws InvalidRootPathError when the root does not exist, is not a
126
+ * directory, or cannot be accessed.
127
+ */
128
+ export declare function docCoverage(rootPath: string, patterns: unknown, stderr?: Writable): Promise<readonly Record<string, unknown>[]>;
129
+ /**
130
+ * Serializes a SymbolRow to its wire shape (FR-001, FR-003): exactly the
131
+ * six required fields, plus doc_snippet when set — omit-unset-optionals,
132
+ * the serializeSignal reasoning idiom — never null, never an empty
133
+ * string.
134
+ *
135
+ * Keys are emitted in the canonical sorted order the protocol layer's
136
+ * code-unit key sort produces (doc_snippet first when present — '_'
137
+ * sorts before 'u'), so that pass is a structural no-op: the
138
+ * serializeComplexityEntry discipline.
139
+ *
140
+ * Validation is the deliberate blend of the two house serializer
141
+ * patterns: a pure projection for fields whose validity is structural at
142
+ * this module's single walk construction site (the
143
+ * serializeComplexityEntry argument — no per-field revalidation of
144
+ * names, paths, lines, or booleans), plus the closed-set and
145
+ * never-empty guards the wire contract pins independently of
146
+ * construction (the AssertionKind and omit-unset-optionals patterns):
147
+ * kind membership in SymbolKind's set, and a present-but-empty
148
+ * doc_snippet fails loud rather than reaching the wire.
149
+ *
150
+ * @param row The symbol row to serialize.
151
+ * @returns A JSON-ready object with the wire fields in canonical order.
152
+ * @throws Error when kind is outside the closed set or doc_snippet is
153
+ * present but empty.
154
+ */
155
+ export declare function serializeSymbolRow(row: SymbolRow): Record<string, unknown>;