lockwire 0.1.31 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -4
- package/dist/actions.d.ts +82 -5
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +395 -10
- package/dist/actions.js.map +1 -1
- package/dist/cli.js +69 -6
- package/dist/cli.js.map +1 -1
- package/dist/compat.d.ts +21 -0
- package/dist/compat.d.ts.map +1 -0
- package/dist/compat.js +59 -0
- package/dist/compat.js.map +1 -0
- package/dist/format.d.ts +3 -1
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +42 -9
- package/dist/format.js.map +1 -1
- package/dist/hook-claude.d.ts +6 -0
- package/dist/hook-claude.d.ts.map +1 -1
- package/dist/hook-claude.js +26 -0
- package/dist/hook-claude.js.map +1 -1
- package/dist/hook-common.d.ts +5 -0
- package/dist/hook-common.d.ts.map +1 -1
- package/dist/hook-common.js +12 -2
- package/dist/hook-common.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lockfile.d.ts +2 -0
- package/dist/lockfile.d.ts.map +1 -1
- package/dist/lockfile.js +13 -2
- package/dist/lockfile.js.map +1 -1
- package/dist/mcp-protocol.d.ts +118 -0
- package/dist/mcp-protocol.d.ts.map +1 -0
- package/dist/mcp-protocol.js +237 -0
- package/dist/mcp-protocol.js.map +1 -0
- package/dist/mcp-server.d.ts +1 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +45 -6
- package/dist/mcp-server.js.map +1 -1
- package/dist/moves.d.ts +49 -0
- package/dist/moves.d.ts.map +1 -0
- package/dist/moves.js +243 -0
- package/dist/moves.js.map +1 -0
- package/dist/reexports.d.ts +26 -0
- package/dist/reexports.d.ts.map +1 -0
- package/dist/reexports.js +174 -0
- package/dist/reexports.js.map +1 -0
- package/dist/tasks.d.ts.map +1 -1
- package/dist/tasks.js +33 -5
- package/dist/tasks.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/moves.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-file moves: a bound symbol that is gone from its file (or whose code there changed) may have
|
|
3
|
+
* moved, unchanged, to another one. This finds where its code as stamped lives now, so `check` can say
|
|
4
|
+
* so and `lockwire repoint` can re-point the claim in one step instead of by hand.
|
|
5
|
+
*
|
|
6
|
+
* "The same code" means the symbol's normalized body hashes as stamped, so comments, formatting and
|
|
7
|
+
* local names don't matter, but any change to what it does does. A symbol with no body to compare (an
|
|
8
|
+
* interface, a type alias) must match on its signature instead. The search reads every source file once
|
|
9
|
+
* per run, parses only the files that declare the symbol (or its class), and gives up at a deadline rather
|
|
10
|
+
* than hold a hook up: an unfinished search names no new home, since the one it missed could be another.
|
|
11
|
+
*/
|
|
12
|
+
import { readFile } from "node:fs/promises";
|
|
13
|
+
import { fileAtCommit } from "./changed.js";
|
|
14
|
+
import { langForPath } from "./grammar.js";
|
|
15
|
+
import { fingerprint, fingerprintSet } from "./hash.js";
|
|
16
|
+
import { resolveInsideRepo, walkFilesWithin } from "./repo.js";
|
|
17
|
+
import { dataFormatOf } from "./values.js";
|
|
18
|
+
/**
|
|
19
|
+
* `body` fingerprints that say nothing about a symbol: none at all (a type, an overload signature) or an
|
|
20
|
+
* empty block (`{}`). Two functions with the same parameters "match" on these without being related.
|
|
21
|
+
*/
|
|
22
|
+
const NO_BODY = new Set([fingerprint(""), fingerprint("{ }")]);
|
|
23
|
+
export const isTrivialBody = (bodyFingerprint) => bodyFingerprint === "" || NO_BODY.has(bodyFingerprint);
|
|
24
|
+
/** The `deps` of a symbol that calls nothing: likewise no evidence. */
|
|
25
|
+
export const NO_DEPS = fingerprintSet([]);
|
|
26
|
+
/**
|
|
27
|
+
* A signature's fingerprints with the `export` modifier as written, removed and added: moving a
|
|
28
|
+
* private helper into a module of its own usually means exporting it, and that is part of the move,
|
|
29
|
+
* not a change to the contract a claim describes.
|
|
30
|
+
*/
|
|
31
|
+
export function sigFingerprints(sig) {
|
|
32
|
+
const out = new Set([fingerprint(sig)]);
|
|
33
|
+
const tail = / \[([^[\]]*)\]$/;
|
|
34
|
+
const lines = sig.split("\n");
|
|
35
|
+
if (!lines.every((l) => tail.test(l)))
|
|
36
|
+
return out;
|
|
37
|
+
const rewrite = (withExport) => lines
|
|
38
|
+
.map((l) => l.replace(tail, (_, mods) => {
|
|
39
|
+
const set = new Set(mods ? mods.split(",") : []);
|
|
40
|
+
if (withExport)
|
|
41
|
+
set.add("export");
|
|
42
|
+
else
|
|
43
|
+
set.delete("export");
|
|
44
|
+
return ` [${[...set].sort().join(",")}]`;
|
|
45
|
+
}))
|
|
46
|
+
.join("\n");
|
|
47
|
+
out.add(fingerprint(rewrite(false)));
|
|
48
|
+
out.add(fingerprint(rewrite(true)));
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
/** Files over this size (minified bundles, generated code) are neither indexed nor parsed. */
|
|
52
|
+
const MAX_FILE_CHARS = 2_000_000;
|
|
53
|
+
const PY_DECL = /\b(?:def|class)\s+([A-Za-z_]\w*)/g;
|
|
54
|
+
/**
|
|
55
|
+
* The ways a TS/JS symbol is declared, for finding the files that might define one: a declaration
|
|
56
|
+
* keyword, a method or field at the start of a line (modifiers allowed), and `x.name = …` for CommonJS
|
|
57
|
+
* exports and prototype methods. It only narrows what is parsed, so it errs towards matching too much.
|
|
58
|
+
*/
|
|
59
|
+
const JS_DECL = [
|
|
60
|
+
/\b(?:function\*?|class|interface|type|enum|namespace|const|let|var)\s+([A-Za-z_$][\w$]*)/g,
|
|
61
|
+
/^[ \t]*(?:(?:public|private|protected|static|async|readonly|abstract|override|declare|get|set)\s+)*\*?\s*([A-Za-z_$][\w$]*)\s*[(<=:?!]/gm,
|
|
62
|
+
/\.([A-Za-z_$][\w$]*)\s*=[^=]/g,
|
|
63
|
+
];
|
|
64
|
+
/** The names a source file declares (see {@link JS_DECL}), for the index. */
|
|
65
|
+
function declaredNames(path, content) {
|
|
66
|
+
const names = new Set();
|
|
67
|
+
for (const re of langForPath(path) === "python" ? [PY_DECL] : JS_DECL) {
|
|
68
|
+
re.lastIndex = 0;
|
|
69
|
+
for (let m = re.exec(content); m; m = re.exec(content))
|
|
70
|
+
if (m[1])
|
|
71
|
+
names.add(m[1]);
|
|
72
|
+
}
|
|
73
|
+
return names;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The repository's source files for one run: read once into an index of the names each one declares
|
|
77
|
+
* (not their text, which in a big repository is more than is worth holding), and parsed on demand,
|
|
78
|
+
* only the files that declare the name being looked for. A name every file uses (`get`) is declared
|
|
79
|
+
* in far fewer.
|
|
80
|
+
*/
|
|
81
|
+
export class SourceIndex {
|
|
82
|
+
repoRoot;
|
|
83
|
+
config;
|
|
84
|
+
symbolsOf;
|
|
85
|
+
deadline;
|
|
86
|
+
byName = null;
|
|
87
|
+
complete = true;
|
|
88
|
+
parsed = new Map();
|
|
89
|
+
constructor(repoRoot, config, symbolsOf,
|
|
90
|
+
/** A `Date.now()` timestamp to stop at. */
|
|
91
|
+
deadline = Number.POSITIVE_INFINITY) {
|
|
92
|
+
this.repoRoot = repoRoot;
|
|
93
|
+
this.config = config;
|
|
94
|
+
this.symbolsOf = symbolsOf;
|
|
95
|
+
this.deadline = deadline;
|
|
96
|
+
}
|
|
97
|
+
async load() {
|
|
98
|
+
if (this.byName)
|
|
99
|
+
return this.byName;
|
|
100
|
+
const byName = new Map();
|
|
101
|
+
const walk = walkFilesWithin(this.repoRoot, this.config.exclude, this.deadline, {
|
|
102
|
+
skipSymlinks: true,
|
|
103
|
+
});
|
|
104
|
+
this.complete = walk.complete;
|
|
105
|
+
for (const rel of walk.files) {
|
|
106
|
+
if (!langForPath(rel))
|
|
107
|
+
continue;
|
|
108
|
+
if (Date.now() > this.deadline) {
|
|
109
|
+
this.complete = false;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
const content = await this.read(rel);
|
|
113
|
+
if (content === null || content.length > MAX_FILE_CHARS)
|
|
114
|
+
continue;
|
|
115
|
+
for (const id of declaredNames(rel, content)) {
|
|
116
|
+
const list = byName.get(id);
|
|
117
|
+
if (list)
|
|
118
|
+
list.push(rel);
|
|
119
|
+
else
|
|
120
|
+
byName.set(id, [rel]);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
this.byName = byName;
|
|
124
|
+
return byName;
|
|
125
|
+
}
|
|
126
|
+
async read(rel) {
|
|
127
|
+
const abs = resolveInsideRepo(this.repoRoot, rel);
|
|
128
|
+
if (!abs)
|
|
129
|
+
return null;
|
|
130
|
+
try {
|
|
131
|
+
return await readFile(abs, "utf8");
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return null; // unreadable: it can't be where the code went
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async symbolsIn(path, version) {
|
|
138
|
+
const key = `${version}|${path}`;
|
|
139
|
+
const hit = this.parsed.get(key);
|
|
140
|
+
if (hit)
|
|
141
|
+
return hit;
|
|
142
|
+
let symbols = null;
|
|
143
|
+
try {
|
|
144
|
+
const content = await this.read(path);
|
|
145
|
+
if (content !== null)
|
|
146
|
+
symbols = await this.symbolsOf(path, content, version);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// a file that doesn't parse has no symbols to offer
|
|
150
|
+
}
|
|
151
|
+
const list = [];
|
|
152
|
+
for (const [symbol, s] of symbols?.bySymbolPath ?? [])
|
|
153
|
+
list.push({
|
|
154
|
+
path,
|
|
155
|
+
symbol,
|
|
156
|
+
body: fingerprint(s.bodyNormalized),
|
|
157
|
+
sigs: sigFingerprints(s.sigTokens),
|
|
158
|
+
});
|
|
159
|
+
this.parsed.set(key, list);
|
|
160
|
+
return list;
|
|
161
|
+
}
|
|
162
|
+
/** Whether `s`'s file already held this code, under the same name, at `commit`. */
|
|
163
|
+
async existedAt(commit, s, stamped, trivialBody, version) {
|
|
164
|
+
const text = fileAtCommit(this.repoRoot, commit, s.path);
|
|
165
|
+
if (text === null)
|
|
166
|
+
return false;
|
|
167
|
+
try {
|
|
168
|
+
const before = (await this.symbolsOf(s.path, text, version))?.bySymbolPath.get(s.symbol);
|
|
169
|
+
if (!before)
|
|
170
|
+
return false;
|
|
171
|
+
return trivialBody
|
|
172
|
+
? sigFingerprints(before.sigTokens).has(stamped.sig)
|
|
173
|
+
: fingerprint(before.bodyNormalized) === stamped.body;
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Where `anchor`'s symbol, as stamped, lives now outside `anchor.target.path`, or null when nowhere
|
|
181
|
+
* (or when the search ran out of time before it could be sure).
|
|
182
|
+
*/
|
|
183
|
+
async findMove(anchor, version,
|
|
184
|
+
/** `path#symbol`s other claims are bound to: that code is theirs, not where this claim's went. */
|
|
185
|
+
taken = new Set()) {
|
|
186
|
+
const { path, symbol } = anchor.target;
|
|
187
|
+
if (!symbol || dataFormatOf(path) || !langForPath(path))
|
|
188
|
+
return null;
|
|
189
|
+
// A method is found through its class, under the same dotted path (`Client.get` in another file):
|
|
190
|
+
// a class that moved takes its methods along, while a method of the same name and body in some
|
|
191
|
+
// other class (`__init__` in hundreds of them) isn't where this one went.
|
|
192
|
+
const head = symbol.slice(0, symbol.indexOf(".") < 0 ? undefined : symbol.indexOf("."));
|
|
193
|
+
const stamped = anchor.fingerprints;
|
|
194
|
+
const trivialBody = isTrivialBody(stamped.body);
|
|
195
|
+
const python = langForPath(path) === "python";
|
|
196
|
+
const files = (await this.load()).get(head) ?? [];
|
|
197
|
+
// An unfinished search can't tell "in one place" from "in one of the places it got to".
|
|
198
|
+
if (!this.complete)
|
|
199
|
+
return null;
|
|
200
|
+
const found = [];
|
|
201
|
+
for (const file of files) {
|
|
202
|
+
if (file === path)
|
|
203
|
+
continue;
|
|
204
|
+
// Code doesn't move between Python and the TS/JS family: the fingerprints can't agree anyway.
|
|
205
|
+
if ((langForPath(file) === "python") !== python)
|
|
206
|
+
continue;
|
|
207
|
+
if (Date.now() > this.deadline)
|
|
208
|
+
return null;
|
|
209
|
+
for (const s of await this.symbolsIn(file, version)) {
|
|
210
|
+
if (s.symbol !== symbol || taken.has(`${s.path}#${s.symbol}`))
|
|
211
|
+
continue;
|
|
212
|
+
const sigMatches = s.sigs.has(stamped.sig);
|
|
213
|
+
if (trivialBody ? sigMatches : s.body === stamped.body)
|
|
214
|
+
found.push(s);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// Code that was already in that file when the claim was stamped is a twin that was always there, not
|
|
218
|
+
// where this claim's code went (two copies of a helper, one of them deleted).
|
|
219
|
+
const stampedAt = anchor.linked.commit;
|
|
220
|
+
if (stampedAt && found.length > 0) {
|
|
221
|
+
const fresh = [];
|
|
222
|
+
for (const s of found)
|
|
223
|
+
if (!(await this.existedAt(stampedAt, s, stamped, trivialBody, version)))
|
|
224
|
+
fresh.push(s);
|
|
225
|
+
found.splice(0, found.length, ...fresh);
|
|
226
|
+
}
|
|
227
|
+
if (found.length === 0)
|
|
228
|
+
return null;
|
|
229
|
+
const candidates = found.map((s) => ({ path: s.path, symbol: s.symbol }));
|
|
230
|
+
// Several copies of the same code: prefer the one whose signature also matches.
|
|
231
|
+
let best = found;
|
|
232
|
+
for (const narrow of [(s) => s.sigs.has(stamped.sig)]) {
|
|
233
|
+
if (best.length <= 1)
|
|
234
|
+
break;
|
|
235
|
+
const fewer = best.filter(narrow);
|
|
236
|
+
if (fewer.length > 0)
|
|
237
|
+
best = fewer;
|
|
238
|
+
}
|
|
239
|
+
const only = best.length === 1 ? best[0] : undefined;
|
|
240
|
+
return { ...(only ? { to: { path: only.path, symbol: only.symbol } } : {}), candidates };
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=moves.js.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AI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAEpC,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC1E,gFAAgF;QAChF,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,KAAK,MAAM,MAAM,IAAI,CAAC,CAAC,CAAgB,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACrE,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;gBAAE,MAAM;YAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,IAAI,GAAG,KAAK,CAAC;QACrC,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrD,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3F,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Node } from "web-tree-sitter";
|
|
2
|
+
import { type LangId } from "./grammar.js";
|
|
3
|
+
export interface ReExport {
|
|
4
|
+
/** The name this module exposes. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Where it comes from, as written: `./new`, `.core`, `pkg.core`. */
|
|
7
|
+
from: string;
|
|
8
|
+
/** Its name in that module; `*` when `name` is the whole module (`export * as ns`, `import * as ns`). */
|
|
9
|
+
imported: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ReExports {
|
|
12
|
+
named: ReExport[];
|
|
13
|
+
/** Modules re-exported whole: `export * from "./x"`, `from .x import *`. */
|
|
14
|
+
star: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare const NO_REEXPORTS: ReExports;
|
|
17
|
+
export declare function extractReExports(root: Node, lang: LangId): ReExports;
|
|
18
|
+
/**
|
|
19
|
+
* The repo-relative file `specifier` names when imported from `fromFile`, or null when it isn't a
|
|
20
|
+
* file in this repository lockwire can read (a package, a path alias, a compiled extension module).
|
|
21
|
+
* TS/JS: relative specifiers only, with the usual extension and `index` lookups, and `./x.js` for
|
|
22
|
+
* `x.ts`. Python: relative imports from the file's package, and absolute ones from the repository
|
|
23
|
+
* root or any directory above the file (`src/`), as a module or a package `__init__.py`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveModule(repoRoot: string, fromFile: string, specifier: string): string | null;
|
|
26
|
+
//# sourceMappingURL=reexports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reexports.d.ts","sourceRoot":"","sources":["../src/reexports.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,MAAM,EAAe,MAAM,cAAc,CAAC;AAGxD,MAAM,WAAW,QAAQ;IACvB,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,yGAAyG;IACzG,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,4EAA4E;IAC5E,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,eAAO,MAAM,YAAY,EAAE,SAAmC,CAAC;AAoF/D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAEpE;AAaD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAmCf"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names a module makes available without defining them: `export { foo } from "./new"`, `export *`,
|
|
3
|
+
* `import { foo } from "./new"; export { foo }`, and Python's module-level `from .new import foo`.
|
|
4
|
+
* A file that keeps a moved symbol's old name this way for compatibility still answers for it, so an
|
|
5
|
+
* anchor on `old.ts#foo` resolves to where `foo` is really defined (see `resolveTarget`).
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, statSync } from "node:fs";
|
|
8
|
+
import { posix } from "node:path";
|
|
9
|
+
import { langForPath } from "./grammar.js";
|
|
10
|
+
import { resolveInsideRepo } from "./repo.js";
|
|
11
|
+
export const NO_REEXPORTS = { named: [], star: [] };
|
|
12
|
+
const stringValue = (n) => {
|
|
13
|
+
if (!n)
|
|
14
|
+
return null;
|
|
15
|
+
const frag = n.namedChildren.find((c) => c?.type === "string_fragment");
|
|
16
|
+
return frag ? frag.text : n.text.replace(/^['"`]|['"`]$/g, "");
|
|
17
|
+
};
|
|
18
|
+
function tsReExports(root) {
|
|
19
|
+
const out = { named: [], star: [] };
|
|
20
|
+
// What each imported name is, for `import { foo } from "./x"; export { foo }`.
|
|
21
|
+
const imports = new Map();
|
|
22
|
+
for (const imp of root.namedChildren) {
|
|
23
|
+
if (imp?.type !== "import_statement")
|
|
24
|
+
continue;
|
|
25
|
+
const from = stringValue(imp.childForFieldName("source"));
|
|
26
|
+
const clause = imp.namedChildren.find((c) => c?.type === "import_clause");
|
|
27
|
+
if (!from || !clause)
|
|
28
|
+
continue;
|
|
29
|
+
for (const c of clause.namedChildren) {
|
|
30
|
+
if (!c)
|
|
31
|
+
continue;
|
|
32
|
+
if (c.type === "identifier")
|
|
33
|
+
imports.set(c.text, { from, imported: "default" });
|
|
34
|
+
else if (c.type === "namespace_import") {
|
|
35
|
+
const id = c.namedChildren.find((x) => x?.type === "identifier");
|
|
36
|
+
if (id)
|
|
37
|
+
imports.set(id.text, { from, imported: "*" });
|
|
38
|
+
}
|
|
39
|
+
else if (c.type === "named_imports")
|
|
40
|
+
for (const s of c.namedChildren) {
|
|
41
|
+
if (s?.type !== "import_specifier")
|
|
42
|
+
continue;
|
|
43
|
+
const name = s.childForFieldName("name")?.text;
|
|
44
|
+
const alias = s.childForFieldName("alias")?.text;
|
|
45
|
+
if (name)
|
|
46
|
+
imports.set(alias ?? name, { from, imported: name });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (const exp of root.namedChildren) {
|
|
51
|
+
if (exp?.type !== "export_statement")
|
|
52
|
+
continue;
|
|
53
|
+
const from = stringValue(exp.childForFieldName("source"));
|
|
54
|
+
const clause = exp.namedChildren.find((c) => c?.type === "export_clause");
|
|
55
|
+
const ns = exp.namedChildren.find((c) => c?.type === "namespace_export");
|
|
56
|
+
if (clause) {
|
|
57
|
+
for (const s of clause.namedChildren) {
|
|
58
|
+
if (s?.type !== "export_specifier")
|
|
59
|
+
continue;
|
|
60
|
+
const local = s.childForFieldName("name")?.text;
|
|
61
|
+
const name = s.childForFieldName("alias")?.text ?? local;
|
|
62
|
+
if (!local || !name)
|
|
63
|
+
continue;
|
|
64
|
+
if (from)
|
|
65
|
+
out.named.push({ name, from, imported: local });
|
|
66
|
+
else {
|
|
67
|
+
const imp = imports.get(local);
|
|
68
|
+
if (imp)
|
|
69
|
+
out.named.push({ name, ...imp });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (ns && from) {
|
|
74
|
+
const id = ns.namedChildren.find((c) => c?.type === "identifier");
|
|
75
|
+
if (id)
|
|
76
|
+
out.named.push({ name: id.text, from, imported: "*" });
|
|
77
|
+
}
|
|
78
|
+
else if (from && exp.children.some((c) => c?.type === "*"))
|
|
79
|
+
out.star.push(from);
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
/** Module-level only: an import inside a function is that function's business, not the module's. */
|
|
84
|
+
function pyReExports(root) {
|
|
85
|
+
const out = { named: [], star: [] };
|
|
86
|
+
for (const imp of root.descendantsOfType("import_from_statement")) {
|
|
87
|
+
if (!imp)
|
|
88
|
+
continue;
|
|
89
|
+
let local = false;
|
|
90
|
+
for (let p = imp.parent; p; p = p.parent)
|
|
91
|
+
if (["function_definition", "class_definition", "lambda"].includes(p.type))
|
|
92
|
+
local = true;
|
|
93
|
+
if (local)
|
|
94
|
+
continue;
|
|
95
|
+
const from = imp.childForFieldName("module_name")?.text;
|
|
96
|
+
if (!from)
|
|
97
|
+
continue;
|
|
98
|
+
if (imp.namedChildren.some((c) => c?.type === "wildcard_import")) {
|
|
99
|
+
out.star.push(from);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
for (const n of imp.childrenForFieldName("name")) {
|
|
103
|
+
if (!n)
|
|
104
|
+
continue;
|
|
105
|
+
if (n.type === "aliased_import") {
|
|
106
|
+
const name = n.childForFieldName("name")?.text;
|
|
107
|
+
const alias = n.childForFieldName("alias")?.text;
|
|
108
|
+
if (name && alias)
|
|
109
|
+
out.named.push({ name: alias, from, imported: name });
|
|
110
|
+
}
|
|
111
|
+
else
|
|
112
|
+
out.named.push({ name: n.text, from, imported: n.text });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
export function extractReExports(root, lang) {
|
|
118
|
+
return lang === "python" ? pyReExports(root) : tsReExports(root);
|
|
119
|
+
}
|
|
120
|
+
const isFile = (repoRoot, rel) => {
|
|
121
|
+
const abs = resolveInsideRepo(repoRoot, rel);
|
|
122
|
+
try {
|
|
123
|
+
return abs !== null && existsSync(abs) && statSync(abs).isFile();
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const TS_EXTS = [".ts", ".tsx", ".mts", ".cts", ".d.ts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
130
|
+
/**
|
|
131
|
+
* The repo-relative file `specifier` names when imported from `fromFile`, or null when it isn't a
|
|
132
|
+
* file in this repository lockwire can read (a package, a path alias, a compiled extension module).
|
|
133
|
+
* TS/JS: relative specifiers only, with the usual extension and `index` lookups, and `./x.js` for
|
|
134
|
+
* `x.ts`. Python: relative imports from the file's package, and absolute ones from the repository
|
|
135
|
+
* root or any directory above the file (`src/`), as a module or a package `__init__.py`.
|
|
136
|
+
*/
|
|
137
|
+
export function resolveModule(repoRoot, fromFile, specifier) {
|
|
138
|
+
const lang = langForPath(fromFile);
|
|
139
|
+
if (!lang)
|
|
140
|
+
return null;
|
|
141
|
+
const dir = posix.dirname(fromFile);
|
|
142
|
+
const pick = (paths) => paths.find((p) => !p.startsWith("..") && langForPath(p) && isFile(repoRoot, p)) ?? null;
|
|
143
|
+
if (lang !== "python") {
|
|
144
|
+
if (!specifier.startsWith("./") && !specifier.startsWith("../"))
|
|
145
|
+
return null;
|
|
146
|
+
const base = posix.normalize(posix.join(dir, specifier));
|
|
147
|
+
const stem = base.replace(/\.(m|c)?jsx?$/, "");
|
|
148
|
+
return pick([
|
|
149
|
+
base,
|
|
150
|
+
...(stem !== base ? [`${stem}.ts`, `${stem}.tsx`, `${stem}.mts`, `${stem}.cts`] : []),
|
|
151
|
+
...TS_EXTS.map((e) => `${base}${e}`),
|
|
152
|
+
...TS_EXTS.map((e) => `${base}/index${e}`),
|
|
153
|
+
]);
|
|
154
|
+
}
|
|
155
|
+
const dots = /^\.*/.exec(specifier)?.[0].length ?? 0;
|
|
156
|
+
const parts = specifier.slice(dots).split(".").filter(Boolean);
|
|
157
|
+
const asModule = (root) => {
|
|
158
|
+
const p = posix.join(root, ...parts);
|
|
159
|
+
return parts.length === 0
|
|
160
|
+
? [posix.join(root, "__init__.py")]
|
|
161
|
+
: [`${p}.py`, `${p}.pyi`, posix.join(p, "__init__.py")];
|
|
162
|
+
};
|
|
163
|
+
if (dots > 0) {
|
|
164
|
+
let root = dir;
|
|
165
|
+
for (let i = 1; i < dots; i++)
|
|
166
|
+
root = posix.dirname(root);
|
|
167
|
+
return pick(asModule(root === "." ? "" : root));
|
|
168
|
+
}
|
|
169
|
+
const roots = [""];
|
|
170
|
+
for (let d = dir; d !== "." && d !== "" && d !== "/"; d = posix.dirname(d))
|
|
171
|
+
roots.splice(1, 0, d);
|
|
172
|
+
return pick(roots.flatMap(asModule));
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=reexports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reexports.js","sourceRoot":"","sources":["../src/reexports.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAe,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAiB9C,MAAM,CAAC,MAAM,YAAY,GAAc,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AAE/D,MAAM,WAAW,GAAG,CAAC,CAAc,EAAiB,EAAE;IACpD,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,MAAM,IAAI,GAAG,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,iBAAiB,CAAC,CAAC;IACxE,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAA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G,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;YACvB,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC;IACF,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,IAAI,IAAI,GAAG,GAAG,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE;YAAE,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAClG,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/tasks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../src/tasks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../src/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,CAAC;IACX,8DAA8D;IAC9D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,0EAA0E;IAC1E,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,GAAG,EAAE,cAAc,CAAC;IACpB,gFAAgF;IAChF,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAqGD,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,EACtB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,WAAW,CAAC,CA+BtB;AAID,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,MAAM,EAAE,UAAU,GAAG,eAAe,GAAG,SAAS,CAAC;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,SAAS,EAAE,IAAI,EAAE,CAAC;CACnB;AAeD;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,EACtB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,KAAK,EACZ,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,cAAc,CAAC,CAEzB;AAyJD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,CAYxE"}
|
package/dist/tasks.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { existsSync } from "node:fs";
|
|
13
13
|
import { readFile } from "node:fs/promises";
|
|
14
|
-
import { ack, check, linkDoc, markerReader, resolveTargetInText, versionOf } from "./actions.js";
|
|
14
|
+
import { ack, check, linkDoc, markerReader, resolveTarget, resolveTargetInText, versionOf, } from "./actions.js";
|
|
15
15
|
import { commitsTouching, fileAtCommit } from "./changed.js";
|
|
16
16
|
import { describeDrift } from "./format.js";
|
|
17
17
|
import { fingerprint } from "./hash.js";
|
|
@@ -59,9 +59,31 @@ const RESOLUTIONS = {
|
|
|
59
59
|
"Check the sentence is true of its target (lockwire_task_context shows the target), fix it if not, then call lockwire_resolve to start checking it.",
|
|
60
60
|
],
|
|
61
61
|
};
|
|
62
|
+
/** The usual resolutions, with re-pointing first when the claim's code moved to another file. */
|
|
63
|
+
function resolutionsOf(kind, r) {
|
|
64
|
+
const to = r.moved?.to;
|
|
65
|
+
if (to)
|
|
66
|
+
return [
|
|
67
|
+
`The code this claim describes moved, unchanged, to ${label(to)}: call lockwire_repoint for this anchor to point the claim and its marker there. If the sentence names the old file, fix that wording too.`,
|
|
68
|
+
...RESOLUTIONS[kind],
|
|
69
|
+
];
|
|
70
|
+
if (r.similar)
|
|
71
|
+
return [
|
|
72
|
+
`${label(r.similar)} has the same signature as the missing symbol: if it was renamed to it, call lockwire_repoint for this anchor with \`to\` set to ${label(r.similar)}; the claim stays flagged if its code also changed, so you can review it.`,
|
|
73
|
+
...RESOLUTIONS[kind],
|
|
74
|
+
];
|
|
75
|
+
if (r.moved)
|
|
76
|
+
return [
|
|
77
|
+
`The code this claim describes is now in several places (${r.moved.candidates.map(label).join(", ")}): pick the one the claim is about and call lockwire_repoint with it as \`to\`.`,
|
|
78
|
+
...RESOLUTIONS[kind],
|
|
79
|
+
];
|
|
80
|
+
return RESOLUTIONS[kind];
|
|
81
|
+
}
|
|
62
82
|
function summaryOf(kind, r) {
|
|
63
83
|
const target = label(r.anchor.target);
|
|
64
84
|
const what = describeDrift(r);
|
|
85
|
+
if (r.moved?.to)
|
|
86
|
+
return `${target} moved to ${label(r.moved.to)}`;
|
|
65
87
|
switch (kind) {
|
|
66
88
|
case "value-wrong":
|
|
67
89
|
return `the claim says ${r.value?.claimed.join(", ") || "something else"} but ${target} is ${r.value?.now}`;
|
|
@@ -133,7 +155,7 @@ export async function listTasks(repoRoot, config, paths) {
|
|
|
133
155
|
claim: marker?.claimExcerpt ?? r.anchor.claim?.excerpt ?? null,
|
|
134
156
|
target: label(r.anchor.target),
|
|
135
157
|
summary: summaryOf(kind, r),
|
|
136
|
-
resolutions:
|
|
158
|
+
resolutions: resolutionsOf(kind, r),
|
|
137
159
|
});
|
|
138
160
|
}
|
|
139
161
|
for (const u of result.unlinked) {
|
|
@@ -184,10 +206,16 @@ async function snapshotNow(repoRoot, config, target) {
|
|
|
184
206
|
if (!existsSync(abs))
|
|
185
207
|
return { source: null, note: `${target.path} does not exist` };
|
|
186
208
|
try {
|
|
187
|
-
|
|
188
|
-
|
|
209
|
+
// Through re-exports, as `check` resolves it: a name kept at the old path shows the code it stands for.
|
|
210
|
+
const r = await resolveTarget(repoRoot, target, config);
|
|
211
|
+
if (!r?.found)
|
|
189
212
|
return { source: null, note: `${label(target)} was not found in ${target.path}` };
|
|
190
|
-
return
|
|
213
|
+
return {
|
|
214
|
+
...cap(r.source ?? ""),
|
|
215
|
+
...(r.definedAt
|
|
216
|
+
? { note: `defined in ${label(r.definedAt)}, re-exported from ${target.path}` }
|
|
217
|
+
: {}),
|
|
218
|
+
};
|
|
191
219
|
}
|
|
192
220
|
catch (err) {
|
|
193
221
|
return { source: null, note: err instanceof Error ? err.message : String(err) };
|