layermap 0.1.42 → 0.1.43
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/analyzers/project-map-java/java-map.jar +0 -0
- package/dist/cli.mjs +224 -107
- package/package.json +1 -1
- package/pi/layermap.mjs +1 -1
|
Binary file
|
package/dist/cli.mjs
CHANGED
|
@@ -19033,6 +19033,9 @@ var PythonMapAnalyzer = class {
|
|
|
19033
19033
|
}
|
|
19034
19034
|
};
|
|
19035
19035
|
|
|
19036
|
+
// src/project-map-language-typescript.ts
|
|
19037
|
+
import { availableParallelism } from "node:os";
|
|
19038
|
+
|
|
19036
19039
|
// src/project-map-miniprogram.ts
|
|
19037
19040
|
import path9 from "node:path";
|
|
19038
19041
|
import {
|
|
@@ -19073,6 +19076,49 @@ var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
|
|
|
19073
19076
|
create: () => new TypeScriptMapAnalyzer()
|
|
19074
19077
|
});
|
|
19075
19078
|
var CONFIGURATIONS_KEPT = 4;
|
|
19079
|
+
var WORKERS_AT_ONCE = Math.min(4, availableParallelism());
|
|
19080
|
+
function limit(atOnce) {
|
|
19081
|
+
let running = 0;
|
|
19082
|
+
const waiting = [];
|
|
19083
|
+
return async (work) => {
|
|
19084
|
+
if (running < atOnce) running++;
|
|
19085
|
+
else await new Promise((resolve) => waiting.push(resolve));
|
|
19086
|
+
try {
|
|
19087
|
+
return await work();
|
|
19088
|
+
} finally {
|
|
19089
|
+
const next = waiting.shift();
|
|
19090
|
+
if (next) next();
|
|
19091
|
+
else running--;
|
|
19092
|
+
}
|
|
19093
|
+
};
|
|
19094
|
+
}
|
|
19095
|
+
var MODULE_NAMES = /\b(?:from|import|require)\s*\(?\s*(["'`])([^"'`\n]+)\1|\/\/\/\s*<reference\s+(?:path|types|lib)\s*=\s*(["'])([^"'\n]+)\3/gu;
|
|
19096
|
+
var moduleNames = (text) => digestValue([...text.matchAll(MODULE_NAMES)].map((match) => match[2] ?? match[4] ?? ""));
|
|
19097
|
+
var sameShape = (left, right) => left.installed === right.installed && left.files.size === right.files.size && [...left.files].every(([path19, { shape }]) => right.files.get(path19)?.shape === shape);
|
|
19098
|
+
var stopUnconfirmed = async (runs) => (await Promise.allSettled(runs)).flatMap((settled) => settled.status === "rejected" ? [settled.reason] : []).find((reason) => reason instanceof ProjectMapStopUnconfirmedError);
|
|
19099
|
+
async function inOrder(tasks, take, signal, sizes) {
|
|
19100
|
+
const stopping = new AbortController();
|
|
19101
|
+
const stop = () => stopping.abort();
|
|
19102
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
19103
|
+
if (signal.aborted) stop();
|
|
19104
|
+
let failure;
|
|
19105
|
+
const results = [];
|
|
19106
|
+
for (const index of tasks.map((_, index2) => index2).sort((left, right) => (sizes[right] ?? 0) - (sizes[left] ?? 0)))
|
|
19107
|
+
results[index] = tasks[index](stopping.signal);
|
|
19108
|
+
for (const result of results)
|
|
19109
|
+
result.catch((error51) => {
|
|
19110
|
+
failure ??= { error: error51 };
|
|
19111
|
+
stop();
|
|
19112
|
+
});
|
|
19113
|
+
try {
|
|
19114
|
+
for (const result of results) take(await result);
|
|
19115
|
+
} catch (error51) {
|
|
19116
|
+
stop();
|
|
19117
|
+
throw await stopUnconfirmed(results) ?? (failure ? failure.error : error51);
|
|
19118
|
+
} finally {
|
|
19119
|
+
signal.removeEventListener("abort", stop);
|
|
19120
|
+
}
|
|
19121
|
+
}
|
|
19076
19122
|
var TypeScriptMapAnalyzer = class {
|
|
19077
19123
|
constructor(resources = installedMapParserResources()) {
|
|
19078
19124
|
this.resources = resources;
|
|
@@ -19084,6 +19130,8 @@ var TypeScriptMapAnalyzer = class {
|
|
|
19084
19130
|
// Discovery reads the texts of the files the language reads and what is installed, nothing else,
|
|
19085
19131
|
// so a result stands while they are the same, as they are when only other languages' files changed.
|
|
19086
19132
|
configurations = /* @__PURE__ */ new Map();
|
|
19133
|
+
// The last configuration discovered, and the shape of the code it was discovered from.
|
|
19134
|
+
last;
|
|
19087
19135
|
async operation(input, schema, signal, observe) {
|
|
19088
19136
|
const start = performance.now();
|
|
19089
19137
|
const event = {
|
|
@@ -19133,13 +19181,10 @@ var TypeScriptMapAnalyzer = class {
|
|
|
19133
19181
|
if (gap.code === "SYNTAX_ERROR" && gap.path) syntaxFailed.add(gap.path);
|
|
19134
19182
|
session.accept(analysis);
|
|
19135
19183
|
};
|
|
19136
|
-
|
|
19137
|
-
const
|
|
19184
|
+
const workers = limit(WORKERS_AT_ONCE);
|
|
19185
|
+
const plan = (workspace, configPath, rootFiles, inputFiles) => {
|
|
19138
19186
|
const texts = /* @__PURE__ */ Object.create(null);
|
|
19139
|
-
for (const file2 of [
|
|
19140
|
-
...workspace?.configurationFiles ?? [],
|
|
19141
|
-
...configPath ? [configPath] : []
|
|
19142
|
-
]) {
|
|
19187
|
+
for (const file2 of [...workspace.configurationFiles, ...configPath ? [configPath] : []]) {
|
|
19143
19188
|
const text = unitTexts[file2];
|
|
19144
19189
|
if (text === void 0)
|
|
19145
19190
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
@@ -19163,48 +19208,60 @@ var TypeScriptMapAnalyzer = class {
|
|
|
19163
19208
|
configPath: configPath ?? null,
|
|
19164
19209
|
rootFiles: rootFiles ?? null
|
|
19165
19210
|
});
|
|
19166
|
-
const
|
|
19211
|
+
const input = {
|
|
19167
19212
|
contextRef,
|
|
19168
|
-
{
|
|
19213
|
+
...configPath ? { configPath } : {},
|
|
19214
|
+
...rootFiles ? { rootFiles } : {},
|
|
19215
|
+
files: texts,
|
|
19216
|
+
inventory,
|
|
19217
|
+
syntaxOnly: false,
|
|
19218
|
+
workspace,
|
|
19219
|
+
dependencies: installed.directory
|
|
19220
|
+
};
|
|
19221
|
+
return {
|
|
19222
|
+
contextRef,
|
|
19223
|
+
// What the context is. What it read is the previous analysis's input files, which
|
|
19224
|
+
// replaying requires to be unchanged; the files given to it may be more than it reads,
|
|
19225
|
+
// since discovery opens the inferred project under options other than its own.
|
|
19226
|
+
request: {
|
|
19169
19227
|
configPath: configPath ?? null,
|
|
19170
19228
|
rootFiles: rootFiles ?? null,
|
|
19171
19229
|
inventory,
|
|
19172
|
-
workspace
|
|
19230
|
+
workspace,
|
|
19173
19231
|
installed: installed.digest
|
|
19174
19232
|
},
|
|
19175
|
-
[
|
|
19176
|
-
...workspace
|
|
19233
|
+
files: [
|
|
19234
|
+
...workspace.configurationFiles,
|
|
19177
19235
|
...configPath ? [configPath] : [],
|
|
19178
19236
|
...rootFiles ?? inventory
|
|
19179
|
-
]
|
|
19180
|
-
|
|
19237
|
+
],
|
|
19238
|
+
texts,
|
|
19239
|
+
input,
|
|
19240
|
+
// The texts are the captured ones of these paths, so the paths stand for them.
|
|
19241
|
+
key: digestValue({ ...input, files: Object.keys(texts) })
|
|
19242
|
+
};
|
|
19243
|
+
};
|
|
19244
|
+
const build = (input, signal2) => workers(
|
|
19245
|
+
() => this.operation({ ...input, operation: "BUILD" }, MapAnalysisSchema, signal2, observe)
|
|
19246
|
+
);
|
|
19247
|
+
const context = async (signal2, { contextRef, request, files, texts, input }, started) => {
|
|
19248
|
+
const reused = session.reuse(contextRef, request, files);
|
|
19181
19249
|
if (reused) {
|
|
19182
|
-
|
|
19183
|
-
return;
|
|
19250
|
+
started?.controller.abort();
|
|
19251
|
+
return reused;
|
|
19252
|
+
}
|
|
19253
|
+
if (started) {
|
|
19254
|
+
const stop = () => started.controller.abort();
|
|
19255
|
+
signal2.addEventListener("abort", stop, { once: true });
|
|
19256
|
+
if (signal2.aborted) stop();
|
|
19184
19257
|
}
|
|
19258
|
+
let first = started?.analysis;
|
|
19185
19259
|
for (; ; ) {
|
|
19186
|
-
if (
|
|
19187
|
-
const
|
|
19188
|
-
|
|
19189
|
-
...configPath ? { configPath } : {},
|
|
19190
|
-
...rootFiles ? { rootFiles } : {},
|
|
19191
|
-
files: texts,
|
|
19192
|
-
inventory,
|
|
19193
|
-
syntaxOnly: false,
|
|
19194
|
-
...workspace ? { workspace } : {},
|
|
19195
|
-
dependencies: installed.directory
|
|
19196
|
-
};
|
|
19197
|
-
const analysis = await this.operation(
|
|
19198
|
-
{ ...input, operation: "BUILD" },
|
|
19199
|
-
MapAnalysisSchema,
|
|
19200
|
-
signal,
|
|
19201
|
-
observe
|
|
19202
|
-
);
|
|
19260
|
+
if (signal2.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
19261
|
+
const analysis = await (first ?? build(input, signal2));
|
|
19262
|
+
first = void 0;
|
|
19203
19263
|
validateMapAnalysis(analysis, input);
|
|
19204
|
-
if (!analysis.requiredFiles.length)
|
|
19205
|
-
accept(analysis);
|
|
19206
|
-
return;
|
|
19207
|
-
}
|
|
19264
|
+
if (!analysis.requiredFiles.length) return analysis;
|
|
19208
19265
|
const required2 = analysis.requiredFiles.map((path19) => {
|
|
19209
19266
|
const entry = byPath.get(path19);
|
|
19210
19267
|
if (!entry || Object.hasOwn(texts, path19))
|
|
@@ -19215,46 +19272,106 @@ var TypeScriptMapAnalyzer = class {
|
|
|
19215
19272
|
texts[entry.path] = unitTexts[entry.path] ?? await session.read(entry);
|
|
19216
19273
|
}
|
|
19217
19274
|
};
|
|
19275
|
+
const admitted = (discovered) => discovered.projects.every(
|
|
19276
|
+
(project) => (!project.configPath || byPath.has(project.configPath)) && project.rootFiles.every((file2) => byPath.has(file2)) && project.inputFiles.every((file2) => byPath.has(file2))
|
|
19277
|
+
) && discovered.workspace.configurationFiles.every((file2) => byPath.has(file2));
|
|
19218
19278
|
const configurationKey = digestValue({
|
|
19219
19279
|
files: session.readable.map((entry) => [entry.path, entry.contentDigest ?? null]),
|
|
19220
19280
|
installed: installed.digest
|
|
19221
19281
|
});
|
|
19222
|
-
const
|
|
19223
|
-
|
|
19224
|
-
|
|
19225
|
-
|
|
19226
|
-
|
|
19227
|
-
|
|
19228
|
-
|
|
19229
|
-
|
|
19230
|
-
|
|
19231
|
-
|
|
19232
|
-
|
|
19233
|
-
|
|
19234
|
-
|
|
19235
|
-
|
|
19236
|
-
|
|
19237
|
-
|
|
19238
|
-
|
|
19239
|
-
|
|
19240
|
-
|
|
19282
|
+
const known = this.configurations.get(configurationKey);
|
|
19283
|
+
const shape = {
|
|
19284
|
+
installed: installed.digest,
|
|
19285
|
+
files: new Map(
|
|
19286
|
+
session.readable.map((entry) => {
|
|
19287
|
+
const digest = entry.contentDigest ?? null;
|
|
19288
|
+
const before = this.last?.shape.files.get(entry.path);
|
|
19289
|
+
return [
|
|
19290
|
+
entry.path,
|
|
19291
|
+
{
|
|
19292
|
+
digest,
|
|
19293
|
+
shape: !this.claims(entry.path) ? digest : before && before.digest === digest ? before.shape : moduleNames(unitTexts[entry.path] ?? "")
|
|
19294
|
+
}
|
|
19295
|
+
];
|
|
19296
|
+
})
|
|
19297
|
+
)
|
|
19298
|
+
};
|
|
19299
|
+
const guess = !known && this.last && sameShape(this.last.shape, shape) ? this.last.discovered : void 0;
|
|
19300
|
+
const speculative = /* @__PURE__ */ new Map();
|
|
19301
|
+
try {
|
|
19302
|
+
if (guess && admitted(guess))
|
|
19303
|
+
for (const project of [...guess.projects].sort(
|
|
19304
|
+
(left, right) => right.rootFiles.length - left.rootFiles.length
|
|
19305
|
+
)) {
|
|
19306
|
+
const guessed = plan(
|
|
19307
|
+
guess.workspace,
|
|
19308
|
+
project.configPath,
|
|
19309
|
+
project.rootFiles,
|
|
19310
|
+
project.inputFiles
|
|
19311
|
+
);
|
|
19312
|
+
if (session.replays(guessed.contextRef, guessed.request, guessed.files)) continue;
|
|
19313
|
+
const controller = new AbortController();
|
|
19314
|
+
const analysis = build(guessed.input, AbortSignal.any([signal, controller.signal]));
|
|
19315
|
+
analysis.catch(() => {
|
|
19316
|
+
});
|
|
19317
|
+
speculative.set(guessed.key, { analysis, controller });
|
|
19318
|
+
}
|
|
19319
|
+
const discovered = known ?? await this.operation(
|
|
19320
|
+
{
|
|
19321
|
+
operation: "CONFIGURE",
|
|
19322
|
+
contextRef: digestValue({ entries, purpose: "CONFIGURE" }),
|
|
19323
|
+
files: unitTexts,
|
|
19324
|
+
inventory,
|
|
19325
|
+
syntaxOnly: false,
|
|
19326
|
+
dependencies: installed.directory
|
|
19327
|
+
},
|
|
19328
|
+
MapConfigurationResultSchema,
|
|
19329
|
+
signal,
|
|
19330
|
+
observe
|
|
19331
|
+
);
|
|
19332
|
+
this.configurations.delete(configurationKey);
|
|
19333
|
+
this.configurations.set(configurationKey, discovered);
|
|
19334
|
+
this.last = { shape, discovered };
|
|
19335
|
+
for (const key of this.configurations.keys())
|
|
19336
|
+
if (this.configurations.size > CONFIGURATIONS_KEPT) this.configurations.delete(key);
|
|
19337
|
+
if (!admitted(discovered))
|
|
19241
19338
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
19242
|
-
|
|
19243
|
-
|
|
19244
|
-
|
|
19245
|
-
|
|
19246
|
-
session.configuration(file2);
|
|
19247
|
-
}
|
|
19248
|
-
for (const project of discovered.projects)
|
|
19249
|
-
await context(project.configPath, project.rootFiles, project.inputFiles);
|
|
19250
|
-
const orphaned = session.readable.filter(
|
|
19251
|
-
(entry) => this.claims(entry.path) && !parsed.has(entry.path) && !syntaxFailed.has(entry.path)
|
|
19252
|
-
);
|
|
19253
|
-
if (orphaned.length)
|
|
19254
|
-
await context(
|
|
19255
|
-
void 0,
|
|
19256
|
-
orphaned.map((entry) => entry.path)
|
|
19339
|
+
const { workspace } = discovered;
|
|
19340
|
+
for (const file2 of workspace.configurationFiles) session.configuration(file2);
|
|
19341
|
+
const plans = discovered.projects.map(
|
|
19342
|
+
(project) => plan(workspace, project.configPath, project.rootFiles, project.inputFiles)
|
|
19257
19343
|
);
|
|
19344
|
+
const started = plans.map((planned) => speculative.get(planned.key));
|
|
19345
|
+
for (const [key, unused] of speculative)
|
|
19346
|
+
if (!plans.some((planned) => planned.key === key)) unused.controller.abort();
|
|
19347
|
+
await inOrder(
|
|
19348
|
+
plans.map(
|
|
19349
|
+
(planned, index) => (signal2) => context(signal2, planned, started[index])
|
|
19350
|
+
),
|
|
19351
|
+
accept,
|
|
19352
|
+
signal,
|
|
19353
|
+
discovered.projects.map((project) => project.rootFiles.length)
|
|
19354
|
+
);
|
|
19355
|
+
const orphaned = session.readable.filter(
|
|
19356
|
+
(entry) => this.claims(entry.path) && !parsed.has(entry.path) && !syntaxFailed.has(entry.path)
|
|
19357
|
+
);
|
|
19358
|
+
if (orphaned.length)
|
|
19359
|
+
accept(
|
|
19360
|
+
await context(
|
|
19361
|
+
signal,
|
|
19362
|
+
plan(
|
|
19363
|
+
workspace,
|
|
19364
|
+
void 0,
|
|
19365
|
+
orphaned.map((entry) => entry.path)
|
|
19366
|
+
)
|
|
19367
|
+
)
|
|
19368
|
+
);
|
|
19369
|
+
} catch (error51) {
|
|
19370
|
+
for (const unused of speculative.values()) unused.controller.abort();
|
|
19371
|
+
throw await stopUnconfirmed([...speculative.values()].map((run2) => run2.analysis)) ?? error51;
|
|
19372
|
+
}
|
|
19373
|
+
const unconfirmed = await stopUnconfirmed([...speculative.values()].map((run2) => run2.analysis));
|
|
19374
|
+
if (unconfirmed) throw unconfirmed;
|
|
19258
19375
|
}
|
|
19259
19376
|
};
|
|
19260
19377
|
|
|
@@ -19327,13 +19444,13 @@ var byCount = ([leftName, left], [rightName, right]) => right - left || compareT
|
|
|
19327
19444
|
var increment = (counts, key, count = 1) => counts.set(key, (counts.get(key) ?? 0) + count);
|
|
19328
19445
|
var decoratorTag = (name, argument, route) => `@${name}${argument === void 0 ? "" : `(${JSON.stringify(argument)})`}${route === void 0 ? "" : ` route ${JSON.stringify(route)}`}`;
|
|
19329
19446
|
var targetText = (target) => {
|
|
19330
|
-
const
|
|
19331
|
-
if (target.length <=
|
|
19447
|
+
const limit2 = MAP_VIEW_LIMITS.targetText;
|
|
19448
|
+
if (target.length <= limit2) return target;
|
|
19332
19449
|
const head = target.slice(0, Math.max(target.indexOf("."), 0));
|
|
19333
19450
|
let tail = target.indexOf(".", head.length + 1);
|
|
19334
|
-
while (tail >= 0 && head.length + 1 + target.length - tail >
|
|
19451
|
+
while (tail >= 0 && head.length + 1 + target.length - tail > limit2)
|
|
19335
19452
|
tail = target.indexOf(".", tail + 1);
|
|
19336
|
-
return head && tail >= 0 ? `${head}\u2026${target.slice(tail)}` : `${target.slice(0,
|
|
19453
|
+
return head && tail >= 0 ? `${head}\u2026${target.slice(tail)}` : `${target.slice(0, limit2 / 2)}\u2026${target.slice(target.length - limit2 / 2 + 1)}`;
|
|
19337
19454
|
};
|
|
19338
19455
|
var sites = (lines) => {
|
|
19339
19456
|
const unique = [...new Set(lines)].sort((left, right) => left - right);
|
|
@@ -19341,16 +19458,16 @@ var sites = (lines) => {
|
|
|
19341
19458
|
const more2 = unique.length - MAP_VIEW_LIMITS.sites;
|
|
19342
19459
|
return `@${shown}${more2 > 0 ? `,+${more2}` : ""}`;
|
|
19343
19460
|
};
|
|
19344
|
-
function splitBlock(block,
|
|
19345
|
-
if (Buffer.byteLength(block) <=
|
|
19461
|
+
function splitBlock(block, limit2) {
|
|
19462
|
+
if (Buffer.byteLength(block) <= limit2) return [block];
|
|
19346
19463
|
const lines = block.split("\n").flatMap((line) => {
|
|
19347
|
-
if (Buffer.byteLength(line) <=
|
|
19464
|
+
if (Buffer.byteLength(line) <= limit2) return [line];
|
|
19348
19465
|
const colon = line.indexOf(": ");
|
|
19349
19466
|
const label = colon < 0 ? "" : line.slice(0, colon + 2);
|
|
19350
19467
|
const pieces = [];
|
|
19351
19468
|
let piece = "";
|
|
19352
19469
|
for (const item of (colon < 0 ? line : line.slice(colon + 2)).split(", ")) {
|
|
19353
|
-
if (piece && Buffer.byteLength(label + piece + item) + 2 >
|
|
19470
|
+
if (piece && Buffer.byteLength(label + piece + item) + 2 > limit2) {
|
|
19354
19471
|
pieces.push(label + piece);
|
|
19355
19472
|
piece = "";
|
|
19356
19473
|
}
|
|
@@ -19362,7 +19479,7 @@ function splitBlock(block, limit) {
|
|
|
19362
19479
|
const chunks = [];
|
|
19363
19480
|
let chunk = [];
|
|
19364
19481
|
for (const line of lines) {
|
|
19365
|
-
if (chunk.length && Buffer.byteLength([...chunk, line].join("\n")) >
|
|
19482
|
+
if (chunk.length && Buffer.byteLength([...chunk, line].join("\n")) > limit2) {
|
|
19366
19483
|
chunks.push(chunk.join("\n"));
|
|
19367
19484
|
chunk = [];
|
|
19368
19485
|
}
|
|
@@ -19372,8 +19489,8 @@ function splitBlock(block, limit) {
|
|
|
19372
19489
|
return chunks;
|
|
19373
19490
|
}
|
|
19374
19491
|
function pageBlocks(view, head, whole, offset, budget) {
|
|
19375
|
-
const
|
|
19376
|
-
const blocks = whole.flatMap((block) => splitBlock(block,
|
|
19492
|
+
const limit2 = Math.floor((budget?.maxBytes ?? PROJECT_MAP_LIMITS.queryBytes) / 4);
|
|
19493
|
+
const blocks = whole.flatMap((block) => splitBlock(block, limit2));
|
|
19377
19494
|
if (!Number.isSafeInteger(offset) || offset < 0 || offset > blocks.length) return invalid2();
|
|
19378
19495
|
const materialize = (count) => {
|
|
19379
19496
|
const end = offset + count;
|
|
@@ -19620,8 +19737,8 @@ function loadCoverageNotes(store, version2) {
|
|
|
19620
19737
|
continue;
|
|
19621
19738
|
}
|
|
19622
19739
|
if (gap.path === void 0) {
|
|
19623
|
-
const
|
|
19624
|
-
if (
|
|
19740
|
+
const limit2 = MAP_LIMITS[gap.code];
|
|
19741
|
+
if (limit2) limits.add(limit2);
|
|
19625
19742
|
continue;
|
|
19626
19743
|
}
|
|
19627
19744
|
if (!mapCodePath(gap.path) && !mapMiniprogramTemplate(gap.path)) continue;
|
|
@@ -20314,10 +20431,10 @@ function mapView(store, input, cache = new MapViewCache()) {
|
|
|
20314
20431
|
}
|
|
20315
20432
|
|
|
20316
20433
|
// src/project-map-query.ts
|
|
20317
|
-
var admission = (input,
|
|
20434
|
+
var admission = (input, limit2 = PROJECT_MAP_LIMITS.queryItems) => {
|
|
20318
20435
|
const offset = input.offset ?? 0;
|
|
20319
|
-
const maxResults = input.maxResults ??
|
|
20320
|
-
if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(maxResults) || maxResults < 1 || maxResults >
|
|
20436
|
+
const maxResults = input.maxResults ?? limit2;
|
|
20437
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(maxResults) || maxResults < 1 || maxResults > limit2) {
|
|
20321
20438
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
20322
20439
|
}
|
|
20323
20440
|
const prefixes = (input.allowedPathPrefixes ?? ["."]).map(
|
|
@@ -21511,7 +21628,7 @@ var CodeIndexStore = class {
|
|
|
21511
21628
|
* Earlier versions of a project's scope built by the same analyzer, most recent first; with
|
|
21512
21629
|
* another project, that project's versions of the same scope and analyzer as well.
|
|
21513
21630
|
*/
|
|
21514
|
-
mapParentCandidates(version2,
|
|
21631
|
+
mapParentCandidates(version2, limit2, otherProjectRef) {
|
|
21515
21632
|
return this.database.prepare(`SELECT version.version_ref FROM project_code_versions version
|
|
21516
21633
|
JOIN project_code_index_state state ON state.version_ref = version.version_ref
|
|
21517
21634
|
WHERE version.project_ref IN (?, ?) AND version.analyzer = ? AND version.scope_json = ?
|
|
@@ -21522,7 +21639,7 @@ var CodeIndexStore = class {
|
|
|
21522
21639
|
version2.analyzer,
|
|
21523
21640
|
canonicalJson(version2.pathPrefixes),
|
|
21524
21641
|
version2.version,
|
|
21525
|
-
|
|
21642
|
+
limit2
|
|
21526
21643
|
).map((row) => String(row.version_ref));
|
|
21527
21644
|
}
|
|
21528
21645
|
/** A version's analysis contexts with the request digest each was built from, if recorded. */
|
|
@@ -21619,8 +21736,8 @@ var CodeIndexStore = class {
|
|
|
21619
21736
|
return result;
|
|
21620
21737
|
}
|
|
21621
21738
|
/** The next files of a version, in path order, whose navigation documents do not exist yet. */
|
|
21622
|
-
listDerivedIndexEntries(version2, afterPath,
|
|
21623
|
-
if (!Number.isInteger(
|
|
21739
|
+
listDerivedIndexEntries(version2, afterPath, limit2) {
|
|
21740
|
+
if (!Number.isInteger(limit2) || limit2 < 1)
|
|
21624
21741
|
throw new ProjectEvidenceError("PROJECT_EVIDENCE_INDEX_INPUT_INVALID", false);
|
|
21625
21742
|
return this.database.prepare(`SELECT entry.path, coalesce(unit.unit_ref, '') AS unit, coalesce((
|
|
21626
21743
|
SELECT group_concat(name, ' ') FROM project_map_objects object
|
|
@@ -21637,7 +21754,7 @@ var CodeIndexStore = class {
|
|
|
21637
21754
|
WHERE entry.version_ref = ? AND entry.entry_state = 'TEXT' AND entry.path > ?
|
|
21638
21755
|
AND NOT EXISTS (SELECT 1 FROM project_map_navigation_documents document
|
|
21639
21756
|
WHERE document.path = entry.path AND document.unit_ref = coalesce(unit.unit_ref, ''))
|
|
21640
|
-
ORDER BY entry.path LIMIT ?`).all(version2, afterPath,
|
|
21757
|
+
ORDER BY entry.path LIMIT ?`).all(version2, afterPath, limit2).map((row) => ({
|
|
21641
21758
|
path: String(row.path),
|
|
21642
21759
|
unit: String(row.unit),
|
|
21643
21760
|
content: `${String(row.path)} ${String(row.names)}`
|
|
@@ -21857,14 +21974,13 @@ var ProjectMapAnalyzer = class {
|
|
|
21857
21974
|
const linked = /* @__PURE__ */ new Set();
|
|
21858
21975
|
const analyzedFiles = /* @__PURE__ */ new Set();
|
|
21859
21976
|
const stagedPaths = /* @__PURE__ */ new Set();
|
|
21977
|
+
const requestDigest = (request, files2) => digestValue({ request, files: files2.map((path19) => [path19, digests.get(path19) ?? null]) });
|
|
21978
|
+
const replaysDigest = (contextRef2, digest) => parent !== void 0 && replayable.has(contextRef2) && parent.contexts.get(contextRef2)?.requestDigest === digest;
|
|
21979
|
+
const replays = (contextRef2, request, files2) => replaysDigest(contextRef2, requestDigest(request, files2));
|
|
21860
21980
|
const reuse = (contextRef2, request, files2) => {
|
|
21861
|
-
const digest =
|
|
21862
|
-
request,
|
|
21863
|
-
files: files2.map((path19) => [path19, digests.get(path19) ?? null])
|
|
21864
|
-
});
|
|
21981
|
+
const digest = requestDigest(request, files2);
|
|
21865
21982
|
requests.set(contextRef2, digest);
|
|
21866
|
-
if (!parent || !
|
|
21867
|
-
if (parent.contexts.get(contextRef2)?.requestDigest !== digest) return void 0;
|
|
21983
|
+
if (!parent || !replaysDigest(contextRef2, digest)) return void 0;
|
|
21868
21984
|
const { analysis, state, paths } = parent.shell(contextRef2);
|
|
21869
21985
|
if (!paths) return invalidParent();
|
|
21870
21986
|
if (state !== void 0) states.set(contextRef2, state);
|
|
@@ -21934,10 +22050,10 @@ var ProjectMapAnalyzer = class {
|
|
|
21934
22050
|
analyzedFiles.add(file2);
|
|
21935
22051
|
}
|
|
21936
22052
|
for (const gap of analysis.gaps) result.gaps.push(gap);
|
|
21937
|
-
const
|
|
22053
|
+
const requestDigest2 = requests.get(ref);
|
|
21938
22054
|
const state = states.get(ref);
|
|
21939
22055
|
consume(analysis, {
|
|
21940
|
-
...
|
|
22056
|
+
...requestDigest2 ? { requestDigest: requestDigest2 } : {},
|
|
21941
22057
|
...state !== void 0 ? { state } : {},
|
|
21942
22058
|
paths: replayed.get(ref) ?? [.../* @__PURE__ */ new Set([...staged, ...options?.linked ?? []])].sort()
|
|
21943
22059
|
});
|
|
@@ -21955,6 +22071,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21955
22071
|
read,
|
|
21956
22072
|
accept,
|
|
21957
22073
|
reuse,
|
|
22074
|
+
replays,
|
|
21958
22075
|
previous,
|
|
21959
22076
|
configuration: (path19) => configurationInputs.add(path19),
|
|
21960
22077
|
observe: this.observe
|
|
@@ -24317,10 +24434,10 @@ async function mapRemovedImpact(input) {
|
|
|
24317
24434
|
}
|
|
24318
24435
|
|
|
24319
24436
|
// src/project-map-change-text.ts
|
|
24320
|
-
function testNames(names,
|
|
24437
|
+
function testNames(names, limit2 = LIST.names) {
|
|
24321
24438
|
if (!names.length) return "";
|
|
24322
24439
|
const tests = names.filter((name) => /(?:^|\.)(?:test|Test|should|it_)\w*$/u.test(name));
|
|
24323
|
-
const shown = (tests.length ? tests : names).slice(0,
|
|
24440
|
+
const shown = (tests.length ? tests : names).slice(0, limit2);
|
|
24324
24441
|
const more2 = (tests.length ? tests : names).length - shown.length;
|
|
24325
24442
|
return `: ${shown.join(", ")}${more2 > 0 ? `, +${more2} more` : ""}`;
|
|
24326
24443
|
}
|
|
@@ -24334,10 +24451,10 @@ function mapChangesText(changes, impact, clients = { routes: [] }, similar = [],
|
|
|
24334
24451
|
];
|
|
24335
24452
|
if (!files) return `${lines[0]}
|
|
24336
24453
|
Nothing changed against ${changes.base}.`;
|
|
24337
|
-
const list = (title, items,
|
|
24454
|
+
const list = (title, items, limit2) => {
|
|
24338
24455
|
if (!items.length) return;
|
|
24339
|
-
lines.push(title, ...items.slice(0,
|
|
24340
|
-
if (items.length >
|
|
24456
|
+
lines.push(title, ...items.slice(0, limit2).map((item) => ` ${item}`));
|
|
24457
|
+
if (items.length > limit2) lines.push(` +${items.length - limit2} more`);
|
|
24341
24458
|
};
|
|
24342
24459
|
list("CHANGED", impact.changed, LIST.changed);
|
|
24343
24460
|
list(
|
|
@@ -24446,9 +24563,9 @@ Nothing changed against ${changes.base}.`;
|
|
|
24446
24563
|
);
|
|
24447
24564
|
if (impact.untested) {
|
|
24448
24565
|
const { changed, entries, throughRoutes, routes: routes2, missing, truncated } = impact.untested;
|
|
24449
|
-
const items = (shown,
|
|
24450
|
-
lines.push(...shown.slice(0,
|
|
24451
|
-
if (shown.length >
|
|
24566
|
+
const items = (shown, limit2) => {
|
|
24567
|
+
lines.push(...shown.slice(0, limit2).map((item) => ` ${item}`));
|
|
24568
|
+
if (shown.length > limit2) lines.push(` +${shown.length - limit2} more`);
|
|
24452
24569
|
};
|
|
24453
24570
|
lines.push("NOT REACHED BY THE GIVEN TESTS");
|
|
24454
24571
|
if (missing.length)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layermap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.43",
|
|
4
4
|
"mcpName": "io.github.coffeecoproject/layermap",
|
|
5
5
|
"description": "A layered map of a codebase for coding agents: directories, modules and call chains across TypeScript, JavaScript, Go, Python and Java.",
|
|
6
6
|
"license": "Apache-2.0",
|
package/pi/layermap.mjs
CHANGED
|
@@ -293,7 +293,7 @@ function layermap(pi) {
|
|
|
293
293
|
if (server && !server.dead) return server;
|
|
294
294
|
starting ??= (async () => {
|
|
295
295
|
const next = new MapServer(cwd);
|
|
296
|
-
const tools = await next.start("0.1.
|
|
296
|
+
const tools = await next.start("0.1.43");
|
|
297
297
|
for (const tool of tools) {
|
|
298
298
|
if (registered.has(tool.name)) continue;
|
|
299
299
|
registered.add(tool.name);
|