@snag-run/core 0.3.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 +5 -0
- package/README.md +22 -0
- package/dist/anchor.d.ts +58 -0
- package/dist/anchor.d.ts.map +1 -0
- package/dist/anchor.js +145 -0
- package/dist/anchor.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/lint.d.ts +19 -0
- package/dist/lint.d.ts.map +1 -0
- package/dist/lint.js +153 -0
- package/dist/lint.js.map +1 -0
- package/dist/log.d.ts +81 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +63 -0
- package/dist/log.js.map +1 -0
- package/dist/reconcile.d.ts +66 -0
- package/dist/reconcile.d.ts.map +1 -0
- package/dist/reconcile.js +173 -0
- package/dist/reconcile.js.map +1 -0
- package/dist/schema.d.ts +567 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +573 -0
- package/dist/schema.js.map +1 -0
- package/dist/severity.d.ts +5 -0
- package/dist/severity.d.ts.map +1 -0
- package/dist/severity.js +16 -0
- package/dist/severity.js.map +1 -0
- package/package.json +46 -0
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 2026 David Taing
|
|
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
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @snag-run/core
|
|
2
|
+
|
|
3
|
+
Snag Map deterministic core — the `failure-map/v1` Zod schema plus the pure map
|
|
4
|
+
machinery (severity banding, source-anchor normalization, lint, and
|
|
5
|
+
embedding-free reconciliation). Browser-safe by construction (zod only, no Node
|
|
6
|
+
built-ins), so both [`@snag-run/cli`](https://www.npmjs.com/package/@snag-run/cli)
|
|
7
|
+
and the browser renderer depend on it directly.
|
|
8
|
+
|
|
9
|
+
> Status: pre-v1.0.0 — early release. The map schema may change before `1.0`.
|
|
10
|
+
|
|
11
|
+
Part of [snag](https://snag.run) — see [snag.run/docs](https://snag.run/docs) for
|
|
12
|
+
the full documentation and a live demo.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @snag-run/core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## License
|
|
21
|
+
|
|
22
|
+
Apache-2.0 © David Taing. See [LICENSE](./LICENSE).
|
package/dist/anchor.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Lowercase the text and split into the set of content tokens: alphanumeric
|
|
2
|
+
* runs, longer than one char, that are not stopwords. */
|
|
3
|
+
export declare function tokenize(text: string): Set<string>;
|
|
4
|
+
/** Jaccard similarity of two token sets (|A∩B| / |A∪B|). 0 when either is
|
|
5
|
+
* empty or they share nothing. */
|
|
6
|
+
export declare function jaccard(a: ReadonlySet<string>, b: ReadonlySet<string>): number;
|
|
7
|
+
/**
|
|
8
|
+
* Extract the ordered H2/H3 heading texts from a Markdown document — the closed
|
|
9
|
+
* anchor vocabulary for a document subject. Parenthetical qualifiers and
|
|
10
|
+
* backticks are stripped so the heading matches the way the model tends to cite
|
|
11
|
+
* it (`## Generation (structured output)` → `Generation`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractHeadings(markdown: string): string[];
|
|
14
|
+
/** A named symbol and the line it starts on — the closed anchor vocabulary for a
|
|
15
|
+
* code subject. */
|
|
16
|
+
export interface SymbolDef {
|
|
17
|
+
readonly file: string;
|
|
18
|
+
readonly line: number;
|
|
19
|
+
readonly name: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Extract named function declarations from a TS/JS source file — the closed
|
|
23
|
+
* anchor vocabulary for a code subject. A deliberately naive port of the M1.5
|
|
24
|
+
* probe: it catches `function foo` / `export async function foo`, the clean
|
|
25
|
+
* enclosing-function boundaries, and nothing richer (arrow consts, class methods,
|
|
26
|
+
* other languages). Symbol resolution via AST/LSP is deferred (#290); this is
|
|
27
|
+
* enough for the exact-anchor spine and its golden fixtures.
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractSymbols(file: string, source: string): SymbolDef[];
|
|
30
|
+
/**
|
|
31
|
+
* Normalize a document `sourceRef` to its nearest H2/H3 heading by token-Jaccard.
|
|
32
|
+
* Composite refs are split on `;` and `:` and the best (fragment, heading) pair
|
|
33
|
+
* wins. Returns `null` when no fragment shares a content token with any heading
|
|
34
|
+
* — an unanchored ref must NOT collide with others (returning a default heading
|
|
35
|
+
* would bucket every no-match node together and cause false carries).
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeDocAnchor(ref: string | undefined, headings: readonly string[]): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Normalize a code `sourceRef` (`file:line` or `file:line-line`) to its
|
|
40
|
+
* enclosing named symbol, as `"<file>:<symbol>"`. Returns `null` when the ref is
|
|
41
|
+
* unparseable or the line sits above the first symbol (top-level) — a top-level
|
|
42
|
+
* ref must NOT collide, same safety rationale as the doc anchor.
|
|
43
|
+
*/
|
|
44
|
+
export declare function normalizeCodeAnchor(ref: string | undefined, symbols: readonly SymbolDef[]): string | null;
|
|
45
|
+
/** The closed source vocabulary a subject's refs are normalized against —
|
|
46
|
+
* headings for a document subject, symbols for a code subject. The caller
|
|
47
|
+
* extracts it from the artifact on disk so the engine stays source-free. */
|
|
48
|
+
export type AnchorVocab = {
|
|
49
|
+
readonly kind: "headings";
|
|
50
|
+
readonly headings: readonly string[];
|
|
51
|
+
} | {
|
|
52
|
+
readonly kind: "symbols";
|
|
53
|
+
readonly symbols: readonly SymbolDef[];
|
|
54
|
+
};
|
|
55
|
+
/** Normalize a `sourceRef` against the supplied vocabulary, dispatching on its
|
|
56
|
+
* kind. `null` means the ref anchored to nothing (it will not carry an id). */
|
|
57
|
+
export declare function anchorForRef(ref: string | undefined, vocab: AnchorVocab): string | null;
|
|
58
|
+
//# sourceMappingURL=anchor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../src/anchor.ts"],"names":[],"mappings":"AAyBA;yDACyD;AACzD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAOlD;AAED;kCACkC;AAClC,wBAAgB,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAK9E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAa1D;AAED;mBACmB;AACnB,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CASxE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,MAAM,GAAG,IAAI,CAsBf;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,SAAS,SAAS,EAAE,GAC5B,MAAM,GAAG,IAAI,CAiBf;AAED;;4EAE4E;AAC5E,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACnE;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,CAAC;AAEzE;+EAC+E;AAC/E,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,KAAK,EAAE,WAAW,GACjB,MAAM,GAAG,IAAI,CAIf"}
|
package/dist/anchor.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Source-anchor normalization for reconcile() (#305, EXP 0001 M1.5 / ADR 0002).
|
|
2
|
+
//
|
|
3
|
+
// A failure node's free-text `sourceRef` is too noisy to key reconciliation on
|
|
4
|
+
// directly (the backend PRD collapsed to 0% exact-carry on raw refs). The lever
|
|
5
|
+
// that works is to normalize each ref to the subject's CLOSED vocabulary — the
|
|
6
|
+
// document's H2/H3 headings, or the code's enclosing symbol — so that the same
|
|
7
|
+
// failure mode lands on the same anchor across regenerations even when the model
|
|
8
|
+
// rewords the citation. M1.5 measured this carrying 43%→89% (doc) and 68%→92%
|
|
9
|
+
// (code). The anchor is the Layer-1 match key; it replaces the content
|
|
10
|
+
// `fingerprint`, which carries ~0% across regenerations (the model rewords prose
|
|
11
|
+
// every run) and survives only as a byte-identical fast-path in reconcile().
|
|
12
|
+
//
|
|
13
|
+
// The engine stays source-free at runtime: the caller supplies the closed
|
|
14
|
+
// vocabulary ({@link AnchorVocab}) extracted from the artifact on disk (see
|
|
15
|
+
// {@link extractHeadings} / {@link extractSymbols}). This keeps reconcile() pure.
|
|
16
|
+
/** Stopwords dropped before token-Jaccard so heading matching keys on the
|
|
17
|
+
* content words, not connective tissue. Ported from the EXP 0001 M1.5 probe. */
|
|
18
|
+
const STOPWORDS = new Set(("the a an of to and or for with in on at by from is are be this that it as " +
|
|
19
|
+
"into when then than but not no yes via per its their our your you we they").split(" "));
|
|
20
|
+
/** Lowercase the text and split into the set of content tokens: alphanumeric
|
|
21
|
+
* runs, longer than one char, that are not stopwords. */
|
|
22
|
+
export function tokenize(text) {
|
|
23
|
+
const out = new Set();
|
|
24
|
+
for (const match of text.toLowerCase().matchAll(/[a-z0-9]+/g)) {
|
|
25
|
+
const token = match[0];
|
|
26
|
+
if (token.length > 1 && !STOPWORDS.has(token))
|
|
27
|
+
out.add(token);
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
/** Jaccard similarity of two token sets (|A∩B| / |A∪B|). 0 when either is
|
|
32
|
+
* empty or they share nothing. */
|
|
33
|
+
export function jaccard(a, b) {
|
|
34
|
+
if (a.size === 0 || b.size === 0)
|
|
35
|
+
return 0;
|
|
36
|
+
let intersection = 0;
|
|
37
|
+
for (const token of a)
|
|
38
|
+
if (b.has(token))
|
|
39
|
+
intersection += 1;
|
|
40
|
+
return intersection / (a.size + b.size - intersection);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Extract the ordered H2/H3 heading texts from a Markdown document — the closed
|
|
44
|
+
* anchor vocabulary for a document subject. Parenthetical qualifiers and
|
|
45
|
+
* backticks are stripped so the heading matches the way the model tends to cite
|
|
46
|
+
* it (`## Generation (structured output)` → `Generation`).
|
|
47
|
+
*/
|
|
48
|
+
export function extractHeadings(markdown) {
|
|
49
|
+
const out = [];
|
|
50
|
+
for (const line of markdown.split(/\r?\n/)) {
|
|
51
|
+
const match = /^(#{2,3})\s+(.*)/.exec(line);
|
|
52
|
+
if (match) {
|
|
53
|
+
const heading = match[2]
|
|
54
|
+
.replace(/\(.*?\)/g, "")
|
|
55
|
+
.replace(/`/g, "")
|
|
56
|
+
.trim();
|
|
57
|
+
if (heading)
|
|
58
|
+
out.push(heading);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Extract named function declarations from a TS/JS source file — the closed
|
|
65
|
+
* anchor vocabulary for a code subject. A deliberately naive port of the M1.5
|
|
66
|
+
* probe: it catches `function foo` / `export async function foo`, the clean
|
|
67
|
+
* enclosing-function boundaries, and nothing richer (arrow consts, class methods,
|
|
68
|
+
* other languages). Symbol resolution via AST/LSP is deferred (#290); this is
|
|
69
|
+
* enough for the exact-anchor spine and its golden fixtures.
|
|
70
|
+
*/
|
|
71
|
+
export function extractSymbols(file, source) {
|
|
72
|
+
const out = [];
|
|
73
|
+
source.split(/\r?\n/).forEach((line, index) => {
|
|
74
|
+
const match = /^\s*(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(line);
|
|
75
|
+
if (match)
|
|
76
|
+
out.push({ file, line: index + 1, name: match[1] });
|
|
77
|
+
});
|
|
78
|
+
return out.sort((a, b) => a.line - b.line);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Normalize a document `sourceRef` to its nearest H2/H3 heading by token-Jaccard.
|
|
82
|
+
* Composite refs are split on `;` and `:` and the best (fragment, heading) pair
|
|
83
|
+
* wins. Returns `null` when no fragment shares a content token with any heading
|
|
84
|
+
* — an unanchored ref must NOT collide with others (returning a default heading
|
|
85
|
+
* would bucket every no-match node together and cause false carries).
|
|
86
|
+
*/
|
|
87
|
+
export function normalizeDocAnchor(ref, headings) {
|
|
88
|
+
if (!ref)
|
|
89
|
+
return null;
|
|
90
|
+
const headingTokens = headings.map((h) => [h, tokenize(h)]);
|
|
91
|
+
const fragments = ref
|
|
92
|
+
.split(/[;:]/)
|
|
93
|
+
.map((f) => f.trim())
|
|
94
|
+
.filter((f) => f.length > 0);
|
|
95
|
+
const candidates = fragments.length > 0 ? fragments : [ref];
|
|
96
|
+
let best = null;
|
|
97
|
+
let bestScore = 0; // strict `>` from 0 means a zero-overlap ref stays null
|
|
98
|
+
for (const fragment of candidates) {
|
|
99
|
+
const fragmentTokens = tokenize(fragment);
|
|
100
|
+
for (const [heading, tokens] of headingTokens) {
|
|
101
|
+
const score = jaccard(fragmentTokens, tokens);
|
|
102
|
+
if (score > bestScore) {
|
|
103
|
+
bestScore = score;
|
|
104
|
+
best = heading;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return best;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Normalize a code `sourceRef` (`file:line` or `file:line-line`) to its
|
|
112
|
+
* enclosing named symbol, as `"<file>:<symbol>"`. Returns `null` when the ref is
|
|
113
|
+
* unparseable or the line sits above the first symbol (top-level) — a top-level
|
|
114
|
+
* ref must NOT collide, same safety rationale as the doc anchor.
|
|
115
|
+
*/
|
|
116
|
+
export function normalizeCodeAnchor(ref, symbols) {
|
|
117
|
+
if (!ref)
|
|
118
|
+
return null;
|
|
119
|
+
const lastColon = ref.lastIndexOf(":");
|
|
120
|
+
if (lastColon <= 0)
|
|
121
|
+
return null;
|
|
122
|
+
const file = ref.slice(0, lastColon);
|
|
123
|
+
const lineMatch = /^(\d+)/.exec(ref.slice(lastColon + 1).trim());
|
|
124
|
+
if (!lineMatch)
|
|
125
|
+
return null;
|
|
126
|
+
const lineno = Number.parseInt(lineMatch[1], 10);
|
|
127
|
+
let enclosing = null;
|
|
128
|
+
for (const symbol of symbols
|
|
129
|
+
.filter((s) => s.file === file)
|
|
130
|
+
.sort((a, b) => a.line - b.line)) {
|
|
131
|
+
if (symbol.line <= lineno)
|
|
132
|
+
enclosing = symbol.name;
|
|
133
|
+
else
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
return enclosing ? `${file}:${enclosing}` : null;
|
|
137
|
+
}
|
|
138
|
+
/** Normalize a `sourceRef` against the supplied vocabulary, dispatching on its
|
|
139
|
+
* kind. `null` means the ref anchored to nothing (it will not carry an id). */
|
|
140
|
+
export function anchorForRef(ref, vocab) {
|
|
141
|
+
return vocab.kind === "headings"
|
|
142
|
+
? normalizeDocAnchor(ref, vocab.headings)
|
|
143
|
+
: normalizeCodeAnchor(ref, vocab.symbols);
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=anchor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchor.js","sourceRoot":"","sources":["../src/anchor.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,iFAAiF;AACjF,8EAA8E;AAC9E,uEAAuE;AACvE,iFAAiF;AACjF,6EAA6E;AAC7E,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,kFAAkF;AAElF;gFACgF;AAChF,MAAM,SAAS,GAAG,IAAI,GAAG,CACvB,CACE,4EAA4E;IAC5E,2EAA2E,CAC5E,CAAC,KAAK,CAAC,GAAG,CAAC,CACb,CAAC;AAEF;yDACyD;AACzD,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9D,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;kCACkC;AAClC,MAAM,UAAU,OAAO,CAAC,CAAsB,EAAE,CAAsB;IACpE,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC3C,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,KAAK,MAAM,KAAK,IAAI,CAAC;QAAE,IAAI,CAAC,C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QACzC,CAAC,CAAC,mBAAmB,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const CORE_PACKAGE: "@snag-run/core";
|
|
2
|
+
export { failureMapSchema, generationSchema, generationSchemaNoNumericBounds, generationSchemaCode, generationSchemaCodeNoNumericBounds, flatGenerationSchema, nodeSchema, flowNodeSchema, failureNodeSchema, edgeSchema, scoresSchema, subjectSchema, metaSchema, HARNESSES, DEFAULT_HARNESS, SCHEMA_ID, parseGeneration, parseFailureMap, normalizeFlatGeneration, coerceNodeIds, isCodeIntakeKind, scopePathsFromRef, sourceRefProblem, } from "./schema.js";
|
|
3
|
+
export type { FailureMap, Generation, FlatGeneration, Node, FlowNode, FailureNode, Edge, Scores, Subject, Meta, Harness, } from "./schema.js";
|
|
4
|
+
export { reconcile, applyReconcile } from "./reconcile.js";
|
|
5
|
+
export type { ReconcileDelta, ReconcileOptions, CarriedNode, CandidateContinuation, } from "./reconcile.js";
|
|
6
|
+
export { tokenize, jaccard, extractHeadings, extractSymbols, normalizeDocAnchor, normalizeCodeAnchor, anchorForRef, } from "./anchor.js";
|
|
7
|
+
export type { AnchorVocab, SymbolDef } from "./anchor.js";
|
|
8
|
+
export { severityBand, SEVERITY_BANDS } from "./severity.js";
|
|
9
|
+
export type { SeverityBand } from "./severity.js";
|
|
10
|
+
export { lintGeneration } from "./lint.js";
|
|
11
|
+
export type { LintWarning, LintCode } from "./lint.js";
|
|
12
|
+
export { noopOnLog, summarizeToolArgs } from "./log.js";
|
|
13
|
+
export type { HarnessLogEvent, OnLogFn } from "./log.js";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,EAAG,gBAAyB,CAAC;AAEt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snag Map deterministic core (the "stays" half of the engine
|
|
2
|
+
// split, ADR 0011). Browser-safe by construction: zod only, zero `node:`
|
|
3
|
+
// built-ins — enforced via tsconfig `types: []` (no node globals compile). The
|
|
4
|
+
// CLI and renderer depend on this; the archived engine leaves depend on it too.
|
|
5
|
+
export const CORE_PACKAGE = "@snag-run/core";
|
|
6
|
+
export {
|
|
7
|
+
// schemas
|
|
8
|
+
failureMapSchema, generationSchema, generationSchemaNoNumericBounds, generationSchemaCode, generationSchemaCodeNoNumericBounds, flatGenerationSchema, nodeSchema, flowNodeSchema, failureNodeSchema, edgeSchema, scoresSchema, subjectSchema, metaSchema, HARNESSES, DEFAULT_HARNESS, SCHEMA_ID,
|
|
9
|
+
// parse/validate fns
|
|
10
|
+
parseGeneration, parseFailureMap, normalizeFlatGeneration, coerceNodeIds,
|
|
11
|
+
// code-intake sourceRef grounding (#272)
|
|
12
|
+
isCodeIntakeKind, scopePathsFromRef, sourceRefProblem, } from "./schema.js";
|
|
13
|
+
// reconcile() — exact-anchor identity carry (#305, ADR 0002). The OSS,
|
|
14
|
+
// embedding-free Layer-1 reconciliation: match a fresh proposal to the committed
|
|
15
|
+
// prior map so an unchanged failure mode keeps its id.
|
|
16
|
+
export { reconcile, applyReconcile } from "./reconcile.js";
|
|
17
|
+
// Source-anchor normalization (the Layer-1 match key for reconcile()).
|
|
18
|
+
export { tokenize, jaccard, extractHeadings, extractSymbols, normalizeDocAnchor, normalizeCodeAnchor, anchorForRef, } from "./anchor.js";
|
|
19
|
+
export { severityBand, SEVERITY_BANDS } from "./severity.js";
|
|
20
|
+
export { lintGeneration } from "./lint.js";
|
|
21
|
+
// Harness logging seam (#45) — the structured, opt-in side-channel event the
|
|
22
|
+
// engine emits during a run; the type + no-op sink land in core (ADR 0011:
|
|
23
|
+
// parked, retire if unused post-extraction).
|
|
24
|
+
export { noopOnLog, summarizeToolArgs } from "./log.js";
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,yEAAyE;AACzE,+EAA+E;AAC/E,gFAAgF;AAEhF,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAyB,CAAC;AAEtD,OAAO;AACL,UAAU;AACV,gBAAgB,EAChB,gBAAgB,EAChB,+BAA+B,EAC/B,oBAAoB,EACpB,mCAAmC,EACnC,oBAAoB,EACpB,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,SAAS,EACT,eAAe,EACf,SAAS;AACT,qBAAqB;AACrB,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,aAAa;AACb,yCAAyC;AACzC,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAgBrB,uEAAuE;AACvE,iFAAiF;AACjF,uDAAuD;AACvD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQ3D,uEAAuE;AACvE,OAAO,EACL,QAAQ,EACR,OAAO,EACP,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACb,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,6EAA6E;AAC7E,2EAA2E;AAC3E,6CAA6C;AAC7C,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/lint.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Generation, type Subject } from "./schema.js";
|
|
2
|
+
export type LintCode = "orphan-failure" | "no-terminal-reach" | "unreachable-node" | "oversize-document" | "gather-incomplete" | "temperature-ignored" | "degenerate-duplicate" | "uncited-code-failure";
|
|
3
|
+
export interface LintWarning {
|
|
4
|
+
code: LintCode;
|
|
5
|
+
message: string;
|
|
6
|
+
/** The node id the warning concerns, when applicable. */
|
|
7
|
+
nodeId?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Run the soft lint checks over a generation analysis. Returns warnings;
|
|
11
|
+
* an empty array means clean. Never throws on lint findings.
|
|
12
|
+
*
|
|
13
|
+
* `subject` is optional: when it is a code intake (`module`/`capability`), each
|
|
14
|
+
* failure node is additionally checked for a valid in-scope `file:line` sourceRef
|
|
15
|
+
* (#272) and an `uncited-code-failure` warning is emitted for any that lack one.
|
|
16
|
+
* Omitted/spec subjects skip that check entirely.
|
|
17
|
+
*/
|
|
18
|
+
export declare function lintGeneration(generation: Generation, subject?: Subject): LintWarning[];
|
|
19
|
+
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,OAAO,EACb,MAAM,aAAa,CAAC;AAOrB,MAAM,MAAM,QAAQ,GAChB,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,GAIlB,mBAAmB,GAInB,mBAAmB,GAKnB,qBAAqB,GAQrB,sBAAsB,GAQtB,sBAAsB,CAAC;AAE3B,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,OAAO,GAChB,WAAW,EAAE,CAmJf"}
|