@plannotator/sem-jiff 0.0.0-stage → 0.2.2
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/CHANGELOG.md +77 -0
- package/LICENSE-APACHE +191 -0
- package/LICENSE-MIT +21 -0
- package/README.md +122 -2
- package/THIRD-PARTY-NOTICES +367 -0
- package/dist/candidate.d.ts +14 -0
- package/dist/candidate.js +1 -0
- package/dist/classifier.d.ts +25 -0
- package/dist/classifier.js +32 -0
- package/dist/copy-wasm-bin.d.ts +2 -0
- package/dist/copy-wasm-bin.js +11 -0
- package/dist/copy-wasm.d.ts +3 -0
- package/dist/copy-wasm.js +43 -0
- package/dist/coverage.d.ts +7 -0
- package/dist/coverage.js +43 -0
- package/dist/edits.d.ts +10 -0
- package/dist/edits.js +230 -0
- package/dist/extract.d.ts +5 -0
- package/dist/extract.js +24 -0
- package/dist/grammars.d.ts +22 -0
- package/dist/grammars.js +37 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +581 -0
- package/dist/inline.d.ts +21 -0
- package/dist/inline.js +959 -0
- package/dist/languages.d.ts +2 -0
- package/dist/languages.js +28 -0
- package/dist/linediff.d.ts +28 -0
- package/dist/linediff.js +205 -0
- package/dist/opinions.d.ts +84 -0
- package/dist/opinions.js +201 -0
- package/dist/pairing.d.ts +10 -0
- package/dist/pairing.js +269 -0
- package/dist/parse.d.ts +119 -0
- package/dist/parse.js +1293 -0
- package/dist/pierre-types.d.ts +101 -0
- package/dist/pierre-types.js +5 -0
- package/dist/runtime.d.ts +48 -0
- package/dist/runtime.js +60 -0
- package/dist/structure.d.ts +23 -0
- package/dist/structure.js +1111 -0
- package/dist/summary.d.ts +19 -0
- package/dist/summary.js +15 -0
- package/dist/symbol-types.d.ts +18 -0
- package/dist/symbol-types.js +1 -0
- package/dist/symbols.d.ts +6 -0
- package/dist/symbols.js +458 -0
- package/dist/syntax.d.ts +69 -0
- package/dist/syntax.js +450 -0
- package/dist/textdiff.d.ts +15 -0
- package/dist/textdiff.js +64 -0
- package/dist/textmoves.d.ts +8 -0
- package/dist/textmoves.js +143 -0
- package/package.json +108 -4
- package/src/candidate.ts +10 -0
- package/src/grammars.ts +44 -0
- package/src/opinions.ts +271 -0
- package/wasm/SHA256SUMS +12 -0
- package/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/wasm/tree-sitter-go.wasm +0 -0
- package/wasm/tree-sitter-java.wasm +0 -0
- package/wasm/tree-sitter-kotlin.wasm +0 -0
- package/wasm/tree-sitter-php.wasm +0 -0
- package/wasm/tree-sitter-python.wasm +0 -0
- package/wasm/tree-sitter-ruby.wasm +0 -0
- package/wasm/tree-sitter-rust.wasm +0 -0
- package/wasm/tree-sitter-swift.wasm +0 -0
- package/wasm/tree-sitter-tsx.wasm +0 -0
- package/wasm/tree-sitter-typescript.wasm +0 -0
- package/wasm/web-tree-sitter.wasm +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.2 (trust release)
|
|
4
|
+
|
|
5
|
+
Two safety fixes from the held4 blind set (110 projects, 11 languages). Both only take claims away.
|
|
6
|
+
|
|
7
|
+
- `reformatted` now needs the same words, inside strings and docstrings too. A Python string holding an escape
|
|
8
|
+
sequence (`\\_`, `\n`) parses as the escape alone, so the words around it were never compared: reworded
|
|
9
|
+
docstrings, deleted `.. versionadded::` notes and renamed doctest variables were called formatting (58 of 150
|
|
10
|
+
sampled Python claims wrong). Rewrapping keeps the claim; changing a word makes the lines plain edits. Rule
|
|
11
|
+
`REFORMAT_WORDS`.
|
|
12
|
+
- Moved-with-edits is held back in every language: about 1 in 3 sampled claims paired two different functions or
|
|
13
|
+
blocks (Go about 8%, Kotlin about 63%). Its lines show as plain edits.
|
|
14
|
+
|
|
15
|
+
Also in the code, switched off: eleven trial rules (`SEMANTIC_TRY_*`) that were scored on the same blind set and did
|
|
16
|
+
not pass. They change nothing unless switched on.
|
|
17
|
+
|
|
18
|
+
Packaging: published to npm again (0.2.1 was not published; this version includes its changes). The declarations
|
|
19
|
+
for `.` no longer import web-tree-sitter's types through the `symbol` types (now in `dist/symbol-types.d.ts`), so a
|
|
20
|
+
consumer with `skipLibCheck` off again needs no `@types/emscripten`.
|
|
21
|
+
|
|
22
|
+
## 0.2.1
|
|
23
|
+
|
|
24
|
+
Held back in Swift, Ruby and Kotlin: claims whose wrong rate, measured on a fresh blind set, could be above our
|
|
25
|
+
1-in-50 bar. Their lines show as plain edits. The set: 30 projects never used before (10 per language), every claim
|
|
26
|
+
labelled blind by two raters and a third where they disagreed; the bar is the one-sided 95% upper bound on the wrong
|
|
27
|
+
rate, at most 2%.
|
|
28
|
+
|
|
29
|
+
| Language | Held back (wrong in n, 95% upper bound) | Still claimed |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| Swift | moved 4 in 131 (6.9%), renamed 3 in 149 (5.1%), extract/inline 6 in 142 (8.2%) | reformatted (0 in 150) |
|
|
32
|
+
| Ruby | moved 2 in 96 (6.4%), renamed 2 in 146 (4.3%), extract/inline 2 in 145 (4.3%) | reformatted (0 in 150) |
|
|
33
|
+
| Kotlin | renamed 2 in 143 (4.3%), extract/inline 4 in 142 (6.3%) | moved (0 in 138, under 2.2%), reformatted (0 in 150) |
|
|
34
|
+
|
|
35
|
+
Moved-with-edits stays held back in all three (wrong 30 in 125, 7 in 50, 69 in 131). No second opinion is asked
|
|
36
|
+
about an extract or inline a language holds back. 0.3 brings these back once each is measured under the bar.
|
|
37
|
+
The other eight languages are unchanged.
|
|
38
|
+
|
|
39
|
+
- Each operation can carry an optional `symbol: { name, kind, oldName?, container? }`: the declaration it is about
|
|
40
|
+
(docs/symbols.md). Additive: no other field changes, and it is left out when the engine is unsure.
|
|
41
|
+
- Docs: `copyWasm` in the README; the `sem-jiff-copy-wasm` bin needs Node 24 or later, or Bun; vendoring the source
|
|
42
|
+
tree needs the devDependencies (PACKAGING.md).
|
|
43
|
+
|
|
44
|
+
## 0.2.0 (2026-11-15)
|
|
45
|
+
|
|
46
|
+
The engine Plannotator's code review runs, now as one package. Languages, and the claims each holds back in this version
|
|
47
|
+
(their lines show as plain edits):
|
|
48
|
+
|
|
49
|
+
- TypeScript and TSX: none held back.
|
|
50
|
+
- JavaScript (read with the TSX grammar): none held back.
|
|
51
|
+
- Python: none held back.
|
|
52
|
+
- Go: none held back.
|
|
53
|
+
- Rust: none held back.
|
|
54
|
+
- Java: none held back. A method moved into another class, or into or out of a nested class, is now an edit, not a move (the decided rule; the class a line sits in is its context). Sorted imports still show as moves, not a reorder.
|
|
55
|
+
- C#: none held back. A move into another class or namespace, or into or out of a nested class, is now an edit; the parts of a partial class share one member scope, so a member moved between them is moved; `Foo` and `Foo<T>` are different classes. Of two swapped members the unchanged one is often named as the move.
|
|
56
|
+
- PHP (tree-sitter-php 0.24.2): none held back.
|
|
57
|
+
- Ruby (tree-sitter-ruby 0.23.1): holds back moved-with-edits.
|
|
58
|
+
- Kotlin (tree-sitter-kotlin 1.1.0, vendored release wasm): holds back moved-with-edits.
|
|
59
|
+
- Swift (tree-sitter-swift 0.7.3, vendored release wasm): holds back moved-with-edits.
|
|
60
|
+
|
|
61
|
+
Java and C# context fix, measured on their existing sets (13 projects, 9,962 files; these sets have been seen, so this is
|
|
62
|
+
practice): moved-with-edits claims 71 -> 60, moved 81, renamed 32 and reformatted 495 unchanged. The 11 claims removed
|
|
63
|
+
were all judged wrong by a blind strict audit; no claim judged correct was lost and none was added. The 4 Java/C# trap
|
|
64
|
+
cases that failed on false claims now pass. These sets are spent: a fresh held-out measurement for Java and C# is owed.
|
|
65
|
+
|
|
66
|
+
Packaging:
|
|
67
|
+
- Entry points `.`, `./summary`, `./opinions`, `./candidate`, `./languages` and `./grammars`, built JavaScript with declarations.
|
|
68
|
+
- Every grammar and web-tree-sitter's runtime prebuilt in `wasm/` (`./wasm/*`), with `wasm/SHA256SUMS`.
|
|
69
|
+
- `src/opinions.ts`, `src/candidate.ts` and `src/grammars.ts` shipped as source for hosts that vendor them (none imports anything).
|
|
70
|
+
- Runtime dependencies are web-tree-sitter, diff and @vscode/diff; the grammar packages are build-time only.
|
|
71
|
+
- Second-opinion answers are kept and reported (`secondOpinion` on the result, `jevAnswers`/`clefAnswers`, `rejectedCandidates`).
|
|
72
|
+
- A Vite build of a page that imports the engine keeps the wasm files out of its output; the pack test builds a small
|
|
73
|
+
Vite consumer and checks that.
|
|
74
|
+
- `SEM_DIFF_GRAMMARS`, `SEM_DIFF_GRAMMAR_FILES` and `SEM_DIFF_WASM_FILES` keep their exact file names as types, and
|
|
75
|
+
`SemDiffWasmFile` names one of them.
|
|
76
|
+
- `copyWasm(destDir)` (`./copy-wasm`) and the `sem-jiff-copy-wasm` bin copy the wasm files out of the installed package,
|
|
77
|
+
checking each against `wasm/SHA256SUMS`.
|
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 backnotprop
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 backnotprop
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,123 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @plannotator/sem-jiff
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Part of Plannotator, try [Plannotator Inbox](https://github.com/backnotprop/plannotator); an inbox to stay in the loop and organize better code review.
|
|
4
|
+
|
|
5
|
+
A diff shows lines that were added and deleted. Much of that is not a real change: a function moved,
|
|
6
|
+
a variable renamed, code reformatted, a block pulled out into a helper. sem-jiff reads both versions of a
|
|
7
|
+
file and says what each change really is, so a reviewer can skip what kept its meaning. It returns plain
|
|
8
|
+
data (`semanticOperations`, `semanticFolds` and the matching patch) that any diff viewer can draw.
|
|
9
|
+
The operation types in `src/pierre-types.ts` are copied from
|
|
10
|
+
[Pierre](https://github.com/pierrecomputer/pierre) (Apache-2.0).
|
|
11
|
+
|
|
12
|
+
Example, rendered in Plannotator:<br/>
|
|
13
|
+
<img width="800" height="" alt="Screenshot 2026-11-15 at 11 39 21 AM" src="https://github.com/user-attachments/assets/a54a923c-d2f9-408f-b5da-48ce40755bfb" />
|
|
14
|
+
|
|
15
|
+
## What it finds
|
|
16
|
+
|
|
17
|
+
| Change | Example |
|
|
18
|
+
|---|---|
|
|
19
|
+
| Moved | `loadUser` moved below `saveUser`, unchanged |
|
|
20
|
+
| Moved and edited | moved, with a line changed on the way |
|
|
21
|
+
| Renamed | `MAX_RETRIES` became `MAX_ATTEMPTS` everywhere, nothing else changed |
|
|
22
|
+
| Reformatted | the same code laid out differently (line breaks, Prettier) |
|
|
23
|
+
| Reordered | imports or members re-sorted |
|
|
24
|
+
| Extracted function | a loop left `checkout` and now lives in a new `sumLineItems` it calls |
|
|
25
|
+
| Inlined function | a helper was removed and its body pasted where it was called |
|
|
26
|
+
| Added, deleted, edited | everything else, as a plain diff |
|
|
27
|
+
|
|
28
|
+
It prefers saying nothing to saying something wrong: a missed change falls back to
|
|
29
|
+
the plain diff, while a wrong label would mislead the reviewer.
|
|
30
|
+
|
|
31
|
+
**Held back.** A fresh blind test on 30 new Swift, Ruby and Kotlin projects found some labels wrong more
|
|
32
|
+
often than our 1-in-50 bar, so for now those lines show as plain edits:
|
|
33
|
+
Swift and Ruby moves, renames and extracts; Kotlin renames and extracts.
|
|
34
|
+
Since 0.2.2, "moved with edits" is held back in every language, and "reformatted" needs the same words,
|
|
35
|
+
docstrings included. Numbers in [CHANGELOG.md](CHANGELOG.md). Each comes back once it passes the bar.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm install @plannotator/sem-jiff
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { semanticDiffFile, languageForPath } from '@plannotator/sem-jiff';
|
|
47
|
+
|
|
48
|
+
const language = languageForPath('src/users.ts'); // 'typescript'
|
|
49
|
+
const { semanticOperations, semanticFolds, patch } =
|
|
50
|
+
await semanticDiffFile(language, oldText, newText, 'src/users.ts');
|
|
51
|
+
|
|
52
|
+
// Give your diff viewer the patch too, so its layout matches the operations,
|
|
53
|
+
// then draw semanticOperations over it.
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
In Node nothing else is needed. In a browser, copy the grammars next to your app
|
|
57
|
+
(`npx sem-jiff-copy-wasm <dir>`, which needs Node 24+ or Bun, or `copyWasm(dir)` from `@plannotator/sem-jiff/copy-wasm`) and tell the engine where they are served from with
|
|
58
|
+
`configure({ locateGrammar, locateRuntime })`. Options, `reviewSummary` and browser setup: [docs/usage.md](docs/usage.md).
|
|
59
|
+
|
|
60
|
+
## Power Up: Jev and Clef
|
|
61
|
+
|
|
62
|
+
The rules are strict, so they miss extracted functions whose code was reworded on the way out.
|
|
63
|
+
Add a decision model and the engine asks it about exactly those candidates, once per file.
|
|
64
|
+
Your key, your account; call it from a server or your own machine.
|
|
65
|
+
|
|
66
|
+
**Try it with Jev** (by TypeSafe):
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { jevOpinion } from '@plannotator/sem-jiff/opinions';
|
|
70
|
+
|
|
71
|
+
const diff = await semanticDiffFile('typescript', oldText, newText, 'src/cart.ts', {
|
|
72
|
+
secondOpinion: jevOpinion({ apiKey }),
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Or with both:** Clef (Cloudflare) breaks the tie when Jev is unsure.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { jevOpinion, clefScore } from '@plannotator/sem-jiff/opinions';
|
|
80
|
+
|
|
81
|
+
const secondOpinion = jevOpinion({ apiKey, tieBreaker: { ask: clefScore({ accountId, apiToken }) } });
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
<picture>
|
|
85
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/plannotator/sem-jiff/main/docs/assets/power-up-dark.svg">
|
|
86
|
+
<img src="https://raw.githubusercontent.com/plannotator/sem-jiff/main/docs/assets/power-up-light.svg" width="800" alt="Fresh final set, 193 real extract and inline cases in TypeScript, Go, Rust, Python, Java and C#. Engine alone: 127 found (66%), 1 wrong of 133 claims. With Jev: 168 found (87%), 5 wrong of 181 claims. With Jev and Clef as tie-breaker: 171 found (89%), 5 wrong of 186 claims.">
|
|
87
|
+
</picture>
|
|
88
|
+
|
|
89
|
+
About $0.0004 per 500-line change with Jev. Answers are remembered, so opening the same diff again
|
|
90
|
+
costs nothing. More in [docs/usage.md](docs/usage.md#second-opinion-power-up).
|
|
91
|
+
|
|
92
|
+
## How it compares
|
|
93
|
+
|
|
94
|
+
<picture>
|
|
95
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/plannotator/sem-jiff/main/docs/assets/compare-dark.svg">
|
|
96
|
+
<img src="https://raw.githubusercontent.com/plannotator/sem-jiff/main/docs/assets/compare-light.svg" width="800" alt="Extract and inline on real Java commits, 122 real cases in Guava, Kafka, Spring Boot and Netty: RefactoringMiner 96 found (79%), 19 wrong; sem-jiff 74 found (61%), 1 wrong. Wrong claims on held-out commits, moves, renames and formatting. Kotlin (ktor, Exposed): sem-jiff 0 of 46, difftastic 51 of 70, sem 0.8.0 40 of 164 audited. Swift (swift-nio, swift-composable-architecture): sem-jiff 0 of 158, difftastic 13 of 88 audited, sem 0.8.0 4 of 95 audited.">
|
|
97
|
+
</picture>
|
|
98
|
+
|
|
99
|
+
On TypeScript practice commits (187 real cases): RefactoringMiner 73 found, 14 wrong; sem-jiff 105, 1 wrong;
|
|
100
|
+
with Jev 148, 1 wrong. Every comparison: [harness/compare/README.md](harness/compare/README.md).
|
|
101
|
+
How the engine is tested: [docs/verification.md](docs/verification.md).
|
|
102
|
+
The Kotlin and Swift figures above are from earlier held-out sets; the newer blind set is in the 0.2.1 notes.
|
|
103
|
+
|
|
104
|
+
## Languages
|
|
105
|
+
|
|
106
|
+
TypeScript and TSX, JavaScript, Python, Go, Rust, Java, C#, PHP, Ruby, Kotlin and Swift.
|
|
107
|
+
What each one holds back in this version is in [CHANGELOG.md](CHANGELOG.md).
|
|
108
|
+
|
|
109
|
+
## More
|
|
110
|
+
|
|
111
|
+
- [docs/usage.md](docs/usage.md): options, `reviewSummary`, browser setup, second opinion, development commands
|
|
112
|
+
- [docs/verification.md](docs/verification.md): how it is verified, every result, the known erratum in Pierre's fixture
|
|
113
|
+
- [docs/history.md](docs/history.md): development milestones
|
|
114
|
+
- [docs/layout.md](docs/layout.md): source layout and how a language is added
|
|
115
|
+
- [PACKAGING.md](PACKAGING.md), [CHANGELOG.md](CHANGELOG.md)
|
|
116
|
+
|
|
117
|
+
## Licence
|
|
118
|
+
|
|
119
|
+
MIT or Apache-2.0, at your choice (`LICENSE-MIT`, `LICENSE-APACHE`), like Plannotator.
|
|
120
|
+
`src/pierre-types.ts` and the Pierre fixture are Apache-2.0, copied from
|
|
121
|
+
[Pierre](https://github.com/pierrecomputer/pierre).
|
|
122
|
+
The WebAssembly files in `wasm/` (web-tree-sitter and the grammars) keep their own licences: see
|
|
123
|
+
`THIRD-PARTY-NOTICES`.
|