@happyvertical/smrt-scanner 0.55.6 → 0.55.7
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/dist/chunks/{scanner-CeTWAIar.js → scanner-CcSYWHNX.js} +66 -6
- package/dist/chunks/scanner-CcSYWHNX.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/manifest-adapter.d.ts +2 -0
- package/dist/manifest-adapter.d.ts.map +1 -1
- package/dist/oxc-parser.d.ts +10 -0
- package/dist/oxc-parser.d.ts.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/scanner-CeTWAIar.js.map +0 -1
|
@@ -2306,13 +2306,13 @@ function reportUnresolvedSpreads(unresolved, filePath, sourceText, errors) {
|
|
|
2306
2306
|
});
|
|
2307
2307
|
}
|
|
2308
2308
|
}
|
|
2309
|
-
function extractClassFromNode(node, filePath, sourceText, importAliases, ctx) {
|
|
2310
|
-
if (node.type === "ExportNamedDeclaration" && node.declaration) return extractClassFromNode(node.declaration, filePath, sourceText, importAliases, ctx);
|
|
2311
|
-
if (node.type === "ExportDefaultDeclaration" && node.declaration) return extractClassFromNode(node.declaration, filePath, sourceText, importAliases, ctx);
|
|
2312
|
-
if (node.type === "ClassDeclaration") return extractClassDeclaration(node, filePath, sourceText, importAliases, ctx);
|
|
2309
|
+
function extractClassFromNode(node, filePath, sourceText, importAliases, ctx, outerStart) {
|
|
2310
|
+
if (node.type === "ExportNamedDeclaration" && node.declaration) return extractClassFromNode(node.declaration, filePath, sourceText, importAliases, ctx, node.start ?? outerStart);
|
|
2311
|
+
if (node.type === "ExportDefaultDeclaration" && node.declaration) return extractClassFromNode(node.declaration, filePath, sourceText, importAliases, ctx, node.start ?? outerStart);
|
|
2312
|
+
if (node.type === "ClassDeclaration") return extractClassDeclaration(node, filePath, sourceText, importAliases, ctx, outerStart);
|
|
2313
2313
|
return null;
|
|
2314
2314
|
}
|
|
2315
|
-
function extractClassDeclaration(node, filePath, sourceText, importAliases, ctx) {
|
|
2315
|
+
function extractClassDeclaration(node, filePath, sourceText, importAliases, ctx, outerStart) {
|
|
2316
2316
|
const className = node.id?.name || "AnonymousClass";
|
|
2317
2317
|
const decorators = node.decorators || [];
|
|
2318
2318
|
const smrtDecorator = decorators.find((d) => isSmrtDecorator(d, importAliases));
|
|
@@ -2338,6 +2338,11 @@ function extractClassDeclaration(node, filePath, sourceText, importAliases, ctx)
|
|
|
2338
2338
|
const method = extractMethodDefinition(member, sourceText, ctx);
|
|
2339
2339
|
if (method) methods.push(method);
|
|
2340
2340
|
}
|
|
2341
|
+
const description = (typeof smrtConfig?.description === "string" ? normalizeModelDescription(smrtConfig.description) : void 0) ?? extractClassJsDocDescription(sourceText, className, [
|
|
2342
|
+
node.start,
|
|
2343
|
+
outerStart,
|
|
2344
|
+
...decorators.map((d) => d.start)
|
|
2345
|
+
].filter((n) => typeof n === "number"));
|
|
2341
2346
|
return {
|
|
2342
2347
|
className,
|
|
2343
2348
|
filePath,
|
|
@@ -2345,6 +2350,7 @@ function extractClassDeclaration(node, filePath, sourceText, importAliases, ctx)
|
|
|
2345
2350
|
extendsTypeArg,
|
|
2346
2351
|
decoratorConfig,
|
|
2347
2352
|
hasSmartDecorator,
|
|
2353
|
+
...description ? { description } : {},
|
|
2348
2354
|
fields,
|
|
2349
2355
|
methods,
|
|
2350
2356
|
startLine: node.loc?.start.line || 1,
|
|
@@ -2352,6 +2358,59 @@ function extractClassDeclaration(node, filePath, sourceText, importAliases, ctx)
|
|
|
2352
2358
|
...typeof node.body?.start === "number" ? { bodyStart: node.body.start } : {}
|
|
2353
2359
|
};
|
|
2354
2360
|
}
|
|
2361
|
+
var MODEL_DESCRIPTION_MAX = 200;
|
|
2362
|
+
function normalizeModelDescription(raw) {
|
|
2363
|
+
const text = raw.replace(/\s+/g, " ").trim();
|
|
2364
|
+
if (!text) return void 0;
|
|
2365
|
+
if (text.length <= MODEL_DESCRIPTION_MAX) return text;
|
|
2366
|
+
const head = text.slice(0, MODEL_DESCRIPTION_MAX);
|
|
2367
|
+
const sentenceEnd = Math.max(head.lastIndexOf(". "), head.lastIndexOf("! "), head.lastIndexOf("? "));
|
|
2368
|
+
if (sentenceEnd > 0) return head.slice(0, sentenceEnd + 1);
|
|
2369
|
+
const wordEnd = head.lastIndexOf(" ");
|
|
2370
|
+
return `${(wordEnd > 0 ? head.slice(0, wordEnd) : head).replace(/[,;:\s]+$/, "")}\u2026`;
|
|
2371
|
+
}
|
|
2372
|
+
function extractClassJsDocDescription(sourceText, className, anchors) {
|
|
2373
|
+
if (anchors.length === 0) return void 0;
|
|
2374
|
+
const before = sourceText.slice(0, Math.min(...anchors)).trimEnd();
|
|
2375
|
+
if (!before.endsWith("*/")) return void 0;
|
|
2376
|
+
const open = before.lastIndexOf("/**");
|
|
2377
|
+
if (open < 0 || before.indexOf("*/", open) !== before.length - 2) return;
|
|
2378
|
+
return summarizeJsDoc(before.slice(open, before.length), className);
|
|
2379
|
+
}
|
|
2380
|
+
function summarizeJsDoc(block, className) {
|
|
2381
|
+
const lines = block.replace(/^\/\*\*/, "").replace(/\*\/$/, "").split("\n").map((line) => line.replace(/^\s*\*\s?/, "").trimEnd());
|
|
2382
|
+
const summary = [];
|
|
2383
|
+
let internal = false;
|
|
2384
|
+
let inFence = false;
|
|
2385
|
+
for (const line of lines) {
|
|
2386
|
+
if (/^\s*@internal\b/.test(line)) internal = true;
|
|
2387
|
+
if (/^\s*```/.test(line)) {
|
|
2388
|
+
inFence = !inFence;
|
|
2389
|
+
continue;
|
|
2390
|
+
}
|
|
2391
|
+
if (inFence) continue;
|
|
2392
|
+
if (/^\s*@\w+/.test(line)) {
|
|
2393
|
+
summary.push("\0");
|
|
2394
|
+
continue;
|
|
2395
|
+
}
|
|
2396
|
+
summary.push(line);
|
|
2397
|
+
}
|
|
2398
|
+
if (internal) return void 0;
|
|
2399
|
+
const paragraph = [];
|
|
2400
|
+
for (const line of summary) {
|
|
2401
|
+
if (line === "\0") break;
|
|
2402
|
+
if (line.trim() === "") {
|
|
2403
|
+
if (paragraph.length > 0) break;
|
|
2404
|
+
continue;
|
|
2405
|
+
}
|
|
2406
|
+
paragraph.push(line.trim());
|
|
2407
|
+
}
|
|
2408
|
+
let text = paragraph.join(" ");
|
|
2409
|
+
const escaped = className.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2410
|
+
text = text.replace(new RegExp(`^${escaped}\\s*(?:[-\u2013\u2014:]+)\\s*`), "").replace(/\{@(?:link|linkcode|linkplain)\s+([^}|\s]+)(?:[|\s]+([^}]*))?\}/g, (_m, target, label) => label?.trim() ? label.trim() : target).replace(/\{@\w+\s*([^}]*)\}/g, "$1").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/`([^`]*)`/g, "$1").replace(/<\/?[a-zA-Z][^>]*>/g, "").replace(/(\*\*|__)(.+?)\1/g, "$2");
|
|
2411
|
+
if (text.length > 0) text = text[0].toUpperCase() + text.slice(1);
|
|
2412
|
+
return normalizeModelDescription(text);
|
|
2413
|
+
}
|
|
2355
2414
|
function isSmrtDecorator(decorator, importAliases) {
|
|
2356
2415
|
return isNamedDecorator(decorator, "smrt", importAliases);
|
|
2357
2416
|
}
|
|
@@ -3031,6 +3090,7 @@ var ManifestAdapter = class ManifestAdapter {
|
|
|
3031
3090
|
className: classDef.className,
|
|
3032
3091
|
qualifiedName,
|
|
3033
3092
|
collection,
|
|
3093
|
+
...classDef.description ? { description: classDef.description } : {},
|
|
3034
3094
|
filePath: classDef.filePath,
|
|
3035
3095
|
packageName: packageName || void 0,
|
|
3036
3096
|
fields,
|
|
@@ -4138,4 +4198,4 @@ var OxcScanner = class {
|
|
|
4138
4198
|
//#endregion
|
|
4139
4199
|
export { mergeAgentSurfaces as C, isPrunedAgentSurfacePath as S, sourceMayDeclareAgentSurface as T, relativeGlobToCwd as _, parseAgentSurfaceFile as a, extractAgentSurface as b, parseSource as c, resolveRecipes as d, sourceMayDeclareRecipe as f, normalizeGlobSeparators as g, discoverSourceFiles as h, extractSmrtImports as i, deriveHelpFieldRefs as l, resolveEnumValues as m, parseUiSelectorsFile as n, parseFile as o, InheritanceResolver as p, ManifestAdapter as r, parseRecipeFile as s, OxcScanner as t, extractRecipes as u, checkAgentSurfaceToolNames as v, scanSvelteAgentSurface as w, isAgentSurfaceSourcePath as x, emptyAgentSurface as y };
|
|
4140
4200
|
|
|
4141
|
-
//# sourceMappingURL=scanner-
|
|
4201
|
+
//# sourceMappingURL=scanner-CcSYWHNX.js.map
|