reading-stone 0.0.0-stage → 0.2.0
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/LICENSE +201 -0
- package/NOTICE +11 -0
- package/README.md +274 -2
- package/dist/analysis.d.ts +341 -0
- package/dist/analysis.js +392 -0
- package/dist/cognitive.d.ts +163 -0
- package/dist/cognitive.js +380 -0
- package/dist/complexity.d.ts +102 -0
- package/dist/complexity.js +163 -0
- package/dist/coverage.d.ts +78 -0
- package/dist/coverage.js +635 -0
- package/dist/detector.d.ts +41 -0
- package/dist/detector.js +2134 -0
- package/dist/discovery.d.ts +330 -0
- package/dist/discovery.js +930 -0
- package/dist/doc-coverage.d.ts +155 -0
- package/dist/doc-coverage.js +543 -0
- package/dist/extract.d.ts +209 -0
- package/dist/extract.js +498 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +54 -0
- package/dist/internal.d.ts +75 -0
- package/dist/internal.js +63 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.js +39 -0
- package/dist/models.d.ts +185 -0
- package/dist/models.js +170 -0
- package/dist/program.d.ts +207 -0
- package/dist/program.js +662 -0
- package/dist/protocol.d.ts +88 -0
- package/dist/protocol.js +74 -0
- package/dist/quality/assertions.d.ts +81 -0
- package/dist/quality/assertions.js +425 -0
- package/dist/quality/collect.d.ts +66 -0
- package/dist/quality/collect.js +412 -0
- package/dist/quality/inference.d.ts +86 -0
- package/dist/quality/inference.js +603 -0
- package/dist/quality/matchers.d.ts +129 -0
- package/dist/quality/matchers.js +220 -0
- package/dist/quality/pairing.d.ts +133 -0
- package/dist/quality/pairing.js +770 -0
- package/dist/quality/pipeline.d.ts +59 -0
- package/dist/quality/pipeline.js +202 -0
- package/dist/quality/types.d.ts +127 -0
- package/dist/quality/types.js +92 -0
- package/dist/safeio.d.ts +107 -0
- package/dist/safeio.js +314 -0
- package/dist/server.d.ts +19 -0
- package/dist/server.js +451 -0
- package/dist/signals/adapter.d.ts +103 -0
- package/dist/signals/adapter.js +323 -0
- package/dist/signals/caller-index.d.ts +117 -0
- package/dist/signals/caller-index.js +147 -0
- package/dist/signals/caller.d.ts +76 -0
- package/dist/signals/caller.js +108 -0
- package/dist/signals/evidence.d.ts +233 -0
- package/dist/signals/evidence.js +578 -0
- package/dist/signals/interface.d.ts +68 -0
- package/dist/signals/interface.js +87 -0
- package/dist/signals/jsdoc.d.ts +27 -0
- package/dist/signals/jsdoc.js +233 -0
- package/dist/signals/naming.d.ts +26 -0
- package/dist/signals/naming.js +160 -0
- package/dist/signals/routing.d.ts +163 -0
- package/dist/signals/routing.js +416 -0
- package/dist/signals/types.d.ts +146 -0
- package/dist/signals/types.js +99 -0
- package/dist/signals/visibility.d.ts +23 -0
- package/dist/signals/visibility.js +82 -0
- package/dist/taxonomy.d.ts +89 -0
- package/dist/taxonomy.js +217 -0
- package/package.json +61 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
reading-stone
|
|
2
|
+
Copyright 2026 zero-dot-force
|
|
3
|
+
|
|
4
|
+
This product includes software originally developed in snake-eyes
|
|
5
|
+
(https://github.com/zero-dot-force/snake-eyes), licensed under
|
|
6
|
+
Apache License 2.0. The JSON-RPC protocol layer, the classification
|
|
7
|
+
signal pipeline design, and the test-mapping pipeline design (pairing
|
|
8
|
+
strategies and pinned confidences, matcher classification semantics,
|
|
9
|
+
fallback chains, provenance boundaries), and the doc-coverage
|
|
10
|
+
symbol-surface design (the exported-surface walk) are ported from
|
|
11
|
+
snake-eyes' Python implementation of the Gaze analyzer protocol.
|
package/README.md
CHANGED
|
@@ -1,3 +1,275 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Reading Stone
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**TypeScript analyzer backend for [Gaze](https://github.com/unbound-force/gaze).**
|
|
4
|
+
|
|
5
|
+
Reading Stone is a Gaze-spawned subprocess. It speaks JSON-RPC 2.0 over stdin/stdout
|
|
6
|
+
(protocol v1.2.0). Gaze owns the CLI, scoring, and reports.
|
|
7
|
+
|
|
8
|
+
## Current status (v0.2.0)
|
|
9
|
+
|
|
10
|
+
| Method | Status |
|
|
11
|
+
|--------|--------|
|
|
12
|
+
| `initialize` | Implemented |
|
|
13
|
+
| `shutdown` | Implemented |
|
|
14
|
+
| `discover` | Implemented (params `{root_path}`; result `{source_files, test_files, framework}`) |
|
|
15
|
+
| `analyze` | Implemented (params `{root_path, patterns}`; result `{"functions": [...]}` — FunctionRecords with `side_effects` arrays, every effect carrying `classification: {label, confidence}`) |
|
|
16
|
+
| `analyze/stream` | Not implemented (`-32601`) |
|
|
17
|
+
| `complexity` | Implemented (params `{root_path, patterns}`; result `{"functions": [...]}` — ComplexityEntry records) |
|
|
18
|
+
| `coverage` | Implemented (params `{root_path, patterns}`; result `{"functions": [...]}` — CoverageEntry records) |
|
|
19
|
+
| `classify_signals` | Implemented (params `{root_path, patterns}`; result `{"signals": [...]}` — the raw classification signal feed) |
|
|
20
|
+
| `test_mapping` | Implemented (params `{root_path, patterns}`; result `{"mappings": [...]}` — test-to-assertion MappingRows with pairing confidences and `side_effect_type` inference) |
|
|
21
|
+
| `doc_coverage` | Implemented (params `{root_path, patterns}`; result `{"symbols": [...]}` — SymbolRows with the closed kind set `function | type | constant | variable | class | method`) |
|
|
22
|
+
| `cognitive_complexity` | Implemented (params `{root_path, patterns}`; result `{"functions": [...]}` — CognitiveRows with SonarSource cognitive complexity scores) |
|
|
23
|
+
|
|
24
|
+
`discover` is implemented and advertised via `capabilities.discover: true`.
|
|
25
|
+
`analyze`, `complexity`, and `coverage` are implemented as core protocol
|
|
26
|
+
methods — not gated behind a capability flag — and share one params surface:
|
|
27
|
+
`root_path` plus an optional `patterns` array of path-prefix strings.
|
|
28
|
+
`classify_signals` is implemented and advertised via
|
|
29
|
+
`capabilities.classify_signals: true`; Gaze calls it only when that flag is
|
|
30
|
+
true, with the same params surface. `test_mapping` is implemented and
|
|
31
|
+
advertised via `capabilities.test_mapping: true` the same way.
|
|
32
|
+
`doc_coverage` and `cognitive_complexity` are implemented and advertised
|
|
33
|
+
via `capabilities.doc_coverage: true` and
|
|
34
|
+
`capabilities.cognitive_complexity: true` the same way. The remaining
|
|
35
|
+
capability flag (`streaming`) is `false` at handshake, with
|
|
36
|
+
`analyze/stream` the sole reserved method (`-32601`).
|
|
37
|
+
|
|
38
|
+
The side effects `analyze` reports are governed by the disposition table:
|
|
39
|
+
for each of the 48 canonical taxonomy types it records the tier, the
|
|
40
|
+
disposition (how completely Reading Stone detects it), the TypeScript
|
|
41
|
+
constructs detected, and the rationale for `N/A` rows — see
|
|
42
|
+
[docs/effect-disposition.md](docs/effect-disposition.md).
|
|
43
|
+
|
|
44
|
+
## Classification
|
|
45
|
+
|
|
46
|
+
Every effect in an `analyze` response carries a
|
|
47
|
+
`classification: {label, confidence}` computed by a deterministic signal
|
|
48
|
+
pipeline that runs per (function, effect-type) pair. Six signal sources
|
|
49
|
+
produce the evidence — five extractors plus one synthesized penalty:
|
|
50
|
+
|
|
51
|
+
- `interface` — the function satisfies a declared interface member (+30)
|
|
52
|
+
- `visibility` — exported function (+8), exported return type (+6), exported
|
|
53
|
+
receiver (+6), clamped at +20
|
|
54
|
+
- `caller_count` — 1, 2–3, or 4+ distinct modules calling the function
|
|
55
|
+
(+5/+10/+15; zero callers emits no signal)
|
|
56
|
+
- `naming_convention` — contractual or incidental name prefixes (±10), plus
|
|
57
|
+
an `Err`-prefixed name on a `SentinelError` effect (+30)
|
|
58
|
+
- `docstring` — JSDoc `@returns`/`@throws` tags (+15), indirect prose verbs
|
|
59
|
+
(+5), incidental verbs (−15)
|
|
60
|
+
- `contradiction` — synthesized (−20) when a pair's evidence mixes positive
|
|
61
|
+
and negative weights
|
|
62
|
+
|
|
63
|
+
Confidence is `50 + tier_boost + Σ(signal weights) − 20` when a
|
|
64
|
+
contradiction is present (`tier_boost`: +25 for P0, +10 for P1, +0 for
|
|
65
|
+
P2–P4), clamped to [0, 100]. Labels derive from the clamped confidence:
|
|
66
|
+
`contractual` ≥ 80, `ambiguous` [50, 80), `incidental` < 50. An effect with
|
|
67
|
+
no matching signals is never dropped — it classifies at the ambiguous floor
|
|
68
|
+
(50 + tier_boost).
|
|
69
|
+
|
|
70
|
+
Without a usable `tsconfig.json` (parse-only mode), the three
|
|
71
|
+
checker-dependent components — the `interface` signal, the `caller_count`
|
|
72
|
+
signal, and the exported-return-type (+6) component of `visibility` — are
|
|
73
|
+
absent, so classifications drift toward `ambiguous`; every effect is still
|
|
74
|
+
classified (degradation reduces precision, never availability).
|
|
75
|
+
|
|
76
|
+
The `classify_signals` method returns the raw feed behind those
|
|
77
|
+
classifications: one signal per matched (function, effect-type, source)
|
|
78
|
+
triple — `function`, `package`, `side_effect_type`, `source`, integer
|
|
79
|
+
`weight`, and a short `reasoning` — deterministically ordered by
|
|
80
|
+
`(package, function, side_effect_type, source)`. Both methods share one
|
|
81
|
+
pipeline: summing a pair's emitted signal weights (the contradiction row
|
|
82
|
+
included) back into `50 + tier_boost` reproduces the confidence `analyze`
|
|
83
|
+
reports.
|
|
84
|
+
|
|
85
|
+
## Installation
|
|
86
|
+
|
|
87
|
+
Requires Node.js 22+.
|
|
88
|
+
|
|
89
|
+
### From npm
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm i -g reading-stone
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The package's only runtime dependency is `typescript`, pinned exactly
|
|
96
|
+
(currently `7.0.2`): Reading Stone uses the compiler's
|
|
97
|
+
`typescript/unstable/*` API, which carries no semver stability
|
|
98
|
+
guarantee, so the pin moves only in a Reading Stone release. It is
|
|
99
|
+
independent of the TypeScript version the analyzed project uses.
|
|
100
|
+
|
|
101
|
+
### From a clone (local development)
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm install
|
|
105
|
+
npm run build
|
|
106
|
+
node dist/main.js --stdio
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The package installs two bin entry points that both launch the JSON-RPC
|
|
110
|
+
analyzer over stdin/stdout:
|
|
111
|
+
|
|
112
|
+
- `reading-stone` — the primary entry point.
|
|
113
|
+
- `gaze-analyzer-typescript` — an alias that Gaze's tier-3 PATH
|
|
114
|
+
auto-discovery looks for; either name works in `.gaze.yaml`.
|
|
115
|
+
|
|
116
|
+
## Configuration
|
|
117
|
+
|
|
118
|
+
Gaze auto-discovers external analyzers by PATH naming convention:
|
|
119
|
+
run gaze with `--language typescript` (e.g.
|
|
120
|
+
`gaze quality --language typescript ./src`) and any
|
|
121
|
+
`gaze-analyzer-typescript` on PATH is used automatically — no
|
|
122
|
+
`.gaze.yaml` needed. Gaze does not infer the project language, so
|
|
123
|
+
without the flag it falls back to its built-in Go analysis. The
|
|
124
|
+
global install puts the alias on PATH alongside `reading-stone`.
|
|
125
|
+
|
|
126
|
+
To name the analyzer explicitly in `.gaze.yaml`, point it at the
|
|
127
|
+
convention binary:
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
analyzers:
|
|
131
|
+
typescript:
|
|
132
|
+
command: gaze-analyzer-typescript
|
|
133
|
+
args: ["--stdio"]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Gaze spawns a `.gaze.yaml` entry with exactly the configured args —
|
|
137
|
+
the `args: ["--stdio"]` line is required. The other two discovery
|
|
138
|
+
tiers, the `--analyzer` CLI flag and the `gaze-analyzer-typescript`
|
|
139
|
+
PATH convention, get `--stdio` passed automatically by Gaze.
|
|
140
|
+
|
|
141
|
+
To dogfood from a checkout: `npm install && npm run build && npm link`
|
|
142
|
+
puts the same two bins on PATH.
|
|
143
|
+
|
|
144
|
+
## Project structure
|
|
145
|
+
|
|
146
|
+
```text
|
|
147
|
+
reading-stone/
|
|
148
|
+
├── src/
|
|
149
|
+
│ ├── index.ts # Package surface (VERSION + taxonomy/model/signal/mapping/doc-coverage/cognitive re-exports)
|
|
150
|
+
│ ├── main.ts # Entry point (reading-stone --stdio)
|
|
151
|
+
│ ├── server.ts # JSON-RPC server (stdin/stdout)
|
|
152
|
+
│ ├── protocol.ts # Request/response types
|
|
153
|
+
│ ├── taxonomy.ts # Side-effect taxonomy (48 types, tiers, aliases)
|
|
154
|
+
│ ├── models.ts # Effect/FunctionRecord/classification records, serializers, derivePackage
|
|
155
|
+
│ ├── safeio.ts # Bounded safe file reader with skip diagnostics
|
|
156
|
+
│ ├── discovery.ts # Project walking, file classification, framework detection, discover()
|
|
157
|
+
│ ├── analysis.ts # Pattern rules + shared prepareAnalysis pipeline; analyze() and classifySignals() entries
|
|
158
|
+
│ ├── program.ts # TypeScript analysis context (program mode with type checker; parse-only fallback)
|
|
159
|
+
│ ├── extract.ts # Table-driven function extraction (ExtractionRecord set)
|
|
160
|
+
│ ├── detector.ts # Side-effect detection rules + FunctionRecord assembly
|
|
161
|
+
│ ├── complexity.ts # Cyclomatic complexity engine (ComplexityEntry)
|
|
162
|
+
│ ├── cognitive.ts # SonarSource cognitive complexity engine (CognitiveRow)
|
|
163
|
+
│ ├── coverage.ts # Istanbul coverage-final.json artifact parser (CoverageEntry)
|
|
164
|
+
│ ├── doc-coverage.ts # Exported-symbol documentation coverage (SymbolRow, symbol-surface walk)
|
|
165
|
+
│ ├── quality/ # Test-mapping pipeline (test_mapping method)
|
|
166
|
+
│ │ ├── assertions.ts # Assertion detection (vitest/jest expect chains, node:assert forms)
|
|
167
|
+
│ │ ├── collect.ts # Test-function collection (it/test/describe walk, qualified titles)
|
|
168
|
+
│ │ ├── inference.ts # Assertion-to-effect inference (fallback chains + four provenance passes)
|
|
169
|
+
│ │ ├── matchers.ts # Normative matcher tables + classification lookups
|
|
170
|
+
│ │ ├── pairing.ts # Test-target pairing strategies (naming 90/70, calls 80, imports 75)
|
|
171
|
+
│ │ ├── pipeline.ts # testMapping() orchestration over the shared prepareAnalysis test arm
|
|
172
|
+
│ │ └── types.ts # MappingRow wire record + serializer (closed assertion-kind set)
|
|
173
|
+
│ └── signals/ # Classification signal pipeline (classify_signals + analyze wiring)
|
|
174
|
+
│ ├── adapter.ts # Pair fan-out, contradiction synthesis, confidence formula (classifyPairs)
|
|
175
|
+
│ ├── caller-index.ts # Import-graph caller index (distinct-module counts via the type checker)
|
|
176
|
+
│ ├── caller.ts # caller_count bucket rule (+5/+10/+15)
|
|
177
|
+
│ ├── evidence.ts # RecordEvidence snapshot (exportedness, JSDoc, interface, callers)
|
|
178
|
+
│ ├── interface.ts # interface signal (+30)
|
|
179
|
+
│ ├── jsdoc.ts # docstring signal (+15 tags / +5 indirect / -15 incidental)
|
|
180
|
+
│ ├── naming.ts # naming_convention signal (prefix rules + Err sentinel case)
|
|
181
|
+
│ ├── routing.ts # Effect-type routing table (48 types → agreeing vocabulary)
|
|
182
|
+
│ ├── types.ts # Signal wire record + serializer (closed source set)
|
|
183
|
+
│ └── visibility.ts # visibility signal (exported components, clamp +20)
|
|
184
|
+
├── tests/
|
|
185
|
+
├── docs/
|
|
186
|
+
│ └── effect-disposition.md # 48-type disposition table (tier, disposition, TypeScript mapping, rationale)
|
|
187
|
+
├── openspec/
|
|
188
|
+
├── package.json
|
|
189
|
+
├── tsconfig.json
|
|
190
|
+
├── biome.json
|
|
191
|
+
└── NOTICE
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Limits & Troubleshooting
|
|
195
|
+
|
|
196
|
+
Reading Stone performs static analysis only on untrusted source and enforces
|
|
197
|
+
fixed transport bounds (not configurable in v1):
|
|
198
|
+
|
|
199
|
+
- **Line size cap** — request lines longer than 16 MiB (`MAX_LINE_CHARS`) are
|
|
200
|
+
rejected with `-32600` before parsing.
|
|
201
|
+
- **Method echo cap** — the method name echoed in `-32601` responses is
|
|
202
|
+
truncated to 64 characters.
|
|
203
|
+
- **Coverage semantics** — the `coverage` method reads a pre-existing
|
|
204
|
+
Istanbul artifact at the fixed location
|
|
205
|
+
`<root>/coverage/coverage-final.json`. When that artifact is absent,
|
|
206
|
+
unreadable, or invalid, `coverage` returns `{"functions": []}` and never
|
|
207
|
+
errors (FR-025). It never runs the project's tests.
|
|
208
|
+
- **Per-request pipeline cost** — each `analyze`, `complexity`,
|
|
209
|
+
`classify_signals`, `test_mapping`, `doc_coverage`, or
|
|
210
|
+
`cognitive_complexity` request boots a fresh TypeScript compiler context
|
|
211
|
+
(tree walk, pre-read, bootstrap, extraction) and disposes it before
|
|
212
|
+
responding; no pipeline state is reused across requests. `coverage`
|
|
213
|
+
reads a pre-existing artifact and is cheap.
|
|
214
|
+
- **Assertion-library scope** — the `test_mapping` method collects
|
|
215
|
+
assertions from vitest/jest `expect(...)` chains and `node:assert`
|
|
216
|
+
forms only; chai, should.js, and other assertion libraries are never
|
|
217
|
+
collected (fixed scope, v1).
|
|
218
|
+
- **Doc-surface scope** — the `doc_coverage` method walks the exported
|
|
219
|
+
module surface plus public members of exported classes; non-exported
|
|
220
|
+
declarations, private/protected/`#private` members, re-exports,
|
|
221
|
+
namespaces, and interface members are out of scope, and overload
|
|
222
|
+
documentation counts only on the implementation signature.
|
|
223
|
+
`doc_snippet` is omitted when absent, never empty (fixed scope, v1).
|
|
224
|
+
- **Cognitive-complexity scope** — the `cognitive_complexity` method
|
|
225
|
+
scores SonarSource cognitive complexity with the documented divergences
|
|
226
|
+
from Gaze's Go port: conditions are walked, ternaries are scored,
|
|
227
|
+
labeled breaks are counted, and nesting resets at anonymous function
|
|
228
|
+
boundaries; the SonarJS lint carve-outs are not applied (fixed scope,
|
|
229
|
+
v1).
|
|
230
|
+
- **Parse-only pairing degradation** — without a usable
|
|
231
|
+
`tsconfig.json`, `test_mapping` pairs through lexical import/call
|
|
232
|
+
matching: barrel re-exports are uncrossed and same-named bindings can
|
|
233
|
+
collide, so pairing precision drops while rows and confidences stay
|
|
234
|
+
available (degradation reduces precision, never availability).
|
|
235
|
+
- **Same-titled sibling tests** — two tests sharing one title inside a
|
|
236
|
+
`describe` block share the identical `test_function` value; their rows
|
|
237
|
+
stay distinct through `assertion_location`.
|
|
238
|
+
- **Wire-key pair collapse** — same-named targets in one file, or in
|
|
239
|
+
different files whose paths derive one package (for example `pkg.ts`
|
|
240
|
+
vs `pkg/index.ts`), are wire-indistinguishable
|
|
241
|
+
(`target_package` + `target_function`); rows emit only for the first
|
|
242
|
+
record in analyze record order — a documented conservative imprecision,
|
|
243
|
+
never duplicate rows.
|
|
244
|
+
|
|
245
|
+
Empty `coverage` results usually mean no artifact exists yet: run the
|
|
246
|
+
project's own test command with an Istanbul reporter writing
|
|
247
|
+
`coverage/coverage-final.json` first, then request `coverage`. When the
|
|
248
|
+
document parses but no file entry matches the Istanbul shape, or entries
|
|
249
|
+
are skipped for size (per-file record caps, or the document-level
|
|
250
|
+
attribution work budget), Reading Stone says so on stderr — one line per
|
|
251
|
+
skipped document or file — while stdout still carries only the JSON-RPC
|
|
252
|
+
response.
|
|
253
|
+
|
|
254
|
+
The read-don't-run coverage behavior is a deliberate, recorded divergence
|
|
255
|
+
from the Gaze analyzer protocol (FR-025), which frames coverage as the
|
|
256
|
+
analyzer being responsible for running the project's tests. Reading Stone
|
|
257
|
+
is static-analysis-only (Constitution Principle V — analyzed code is never
|
|
258
|
+
executed), so it consumes the artifact the project's own test run produced
|
|
259
|
+
instead of producing one itself.
|
|
260
|
+
|
|
261
|
+
When input is malformed, Reading Stone emits a one-line diagnostic to
|
|
262
|
+
**stderr** and continues. **stdout carries only the JSON-RPC response.**
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
Apache 2.0 -- see [LICENSE](LICENSE). The JSON-RPC protocol layer, the
|
|
267
|
+
classification signal pipeline design, the test-mapping pipeline design
|
|
268
|
+
(pairing strategies and pinned confidences, matcher classification
|
|
269
|
+
semantics, fallback chains, provenance boundaries), and the doc-coverage
|
|
270
|
+
symbol-surface design (the exported-surface walk) are ported from
|
|
271
|
+
[snake-eyes](https://github.com/zero-dot-force/snake-eyes)
|
|
272
|
+
(zero-dot-force, Apache 2.0); see [NOTICE](NOTICE) for attribution. The
|
|
273
|
+
cognitive-complexity algorithm follows SonarSource cognitive complexity,
|
|
274
|
+
with eslint-plugin-sonarjs as the normative TypeScript/JavaScript
|
|
275
|
+
reference implementation.
|