limitcast 0.19.1 → 0.19.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/package.json +1 -1
- package/src/optimize.mjs +8 -2
- package/src/repomap.mjs +5 -3
package/package.json
CHANGED
package/src/optimize.mjs
CHANGED
|
@@ -71,6 +71,12 @@ export function commandShape(command) {
|
|
|
71
71
|
return null;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
function checkIdentity(command) {
|
|
75
|
+
return commandShape(command)
|
|
76
|
+
?.replace(/^(?:python3?|\.venv\/bin\/python3?) -m (pytest|unittest)$/, '$1')
|
|
77
|
+
.replace(/^npm run test$/, 'npm test');
|
|
78
|
+
}
|
|
79
|
+
|
|
74
80
|
function responseText(value) {
|
|
75
81
|
if (typeof value === 'string') return value.slice(0, 16000);
|
|
76
82
|
if (!value || typeof value !== 'object') return '';
|
|
@@ -219,7 +225,7 @@ function learn(state, session, e) {
|
|
|
219
225
|
if (!e.succeeded) return;
|
|
220
226
|
for (const from of session.failed ?? []) {
|
|
221
227
|
if (from === e.command) continue;
|
|
222
|
-
if (
|
|
228
|
+
if (checkIdentity(from) !== checkIdentity(e.command)) continue;
|
|
223
229
|
let fact = state.facts.find((f) => f.from === from && f.to === e.command);
|
|
224
230
|
if (!fact) {
|
|
225
231
|
fact = { id: digest(`${from}\0${e.command}`).slice(0, 16), from, to: e.command, state: 'candidate', sessions: [] };
|
|
@@ -236,7 +242,7 @@ function learn(state, session, e) {
|
|
|
236
242
|
export function learnedContext(state) {
|
|
237
243
|
if (!state.config.learn) return '';
|
|
238
244
|
return state.facts
|
|
239
|
-
.filter((f) => f.state === 'active' && commandShape(f.to) && (f.kind === 'check' ||
|
|
245
|
+
.filter((f) => f.state === 'active' && commandShape(f.to) && (f.kind === 'check' || checkIdentity(f.from) === checkIdentity(f.to)))
|
|
240
246
|
.slice(0, 4)
|
|
241
247
|
.map((f) =>
|
|
242
248
|
f.kind === 'check'
|
package/src/repomap.mjs
CHANGED
|
@@ -16,7 +16,7 @@ export function repositoryMap(repo, { refresh = false, maxChars = 6000 } = {}) {
|
|
|
16
16
|
const path = join(stateDir(), 'optimize', `${repo.id}.map.json`);
|
|
17
17
|
if (!refresh && !dirty && existsSync(path)) {
|
|
18
18
|
const cached = JSON.parse(readFileSync(path, 'utf8'));
|
|
19
|
-
if (cached.head === head && cached.budget === maxChars) return cached.text;
|
|
19
|
+
if (cached.version === 2 && cached.head === head && cached.budget === maxChars) return cached.text;
|
|
20
20
|
}
|
|
21
21
|
const files = git('ls-files', '-z')
|
|
22
22
|
.split('\0')
|
|
@@ -47,7 +47,9 @@ export function repositoryMap(repo, { refresh = false, maxChars = 6000 } = {}) {
|
|
|
47
47
|
const line = `${row.name}${row.symbols.length ? `: ${row.symbols.join(', ')}` : ''}\n`;
|
|
48
48
|
if (text.length + line.length <= maxChars) text += line;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
if (!dirty) {
|
|
51
|
+
mkdirSync(join(stateDir(), 'optimize'), { recursive: true, mode: 0o700 });
|
|
52
|
+
writeAtomic(path, JSON.stringify({ version: 2, head, budget: maxChars, fingerprint: digest(text), text }));
|
|
53
|
+
}
|
|
52
54
|
return text;
|
|
53
55
|
}
|