@happyvertical/smrt-scanner 0.57.9 → 0.57.11
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/AGENTS.md +4 -1
- package/dist/chunks/{scanner-AeB0tDx4.js → scanner-DPJwlSPw.js} +59 -9
- package/dist/chunks/scanner-DPJwlSPw.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/inheritance-resolver.d.ts +21 -0
- package/dist/inheritance-resolver.d.ts.map +1 -1
- package/dist/knowledge-graph.d.ts.map +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/knowledge.js.map +1 -1
- package/dist/manifest-adapter.d.ts +22 -1
- package/dist/manifest-adapter.d.ts.map +1 -1
- package/dist/oxc-parser.d.ts +2 -0
- package/dist/oxc-parser.d.ts.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/scanner-AeB0tDx4.js.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -35,7 +35,10 @@ executes the source.
|
|
|
35
35
|
- `parseFile` / `parseSource` — parse a single file or a source string to a
|
|
36
36
|
`FileScanResult` (classes, errors, type aliases, SMRT imports). Each class
|
|
37
37
|
carries the parser's `bodyStart` offset; core's library build inserts its
|
|
38
|
-
package stamp there and never rescans source text (#3490).
|
|
38
|
+
package stamp there and never rescans source text (#3490). A class whose
|
|
39
|
+
parent is a named, aliased, or namespace value import carries
|
|
40
|
+
`extendsSource`; `ManifestAdapter` turns a scoped package other than its own
|
|
41
|
+
into `extendsQualified` (#4145). Never infer it from relative paths or names.
|
|
39
42
|
- `extractSmrtImports` — pull SMRT-related imports from a parsed file.
|
|
40
43
|
- `lintNumericPrecision(classes, sourceText?)` — flags persisted `number` fields
|
|
41
44
|
whose declared precision contradicts their name (#2361), returning a `kind`
|
|
@@ -2537,7 +2537,8 @@ function parseFile(filePath) {
|
|
|
2537
2537
|
const ctx = {
|
|
2538
2538
|
constants: extractModuleObjectConstants(program.body, sourceText),
|
|
2539
2539
|
unresolved: [],
|
|
2540
|
-
importAliases
|
|
2540
|
+
importAliases,
|
|
2541
|
+
importBindings: extractImportBindings(program.body)
|
|
2541
2542
|
};
|
|
2542
2543
|
for (const node of program.body) {
|
|
2543
2544
|
const extracted = extractClassFromNode(node, filePath, sourceText, importAliases, ctx);
|
|
@@ -2676,7 +2677,8 @@ function parseSource(sourceText, filename = "test.ts") {
|
|
|
2676
2677
|
const ctx = {
|
|
2677
2678
|
constants: extractModuleObjectConstants(program.body, sourceText),
|
|
2678
2679
|
unresolved: [],
|
|
2679
|
-
importAliases
|
|
2680
|
+
importAliases,
|
|
2681
|
+
importBindings: extractImportBindings(program.body)
|
|
2680
2682
|
};
|
|
2681
2683
|
for (const node of program.body) {
|
|
2682
2684
|
const extracted = extractClassFromNode(node, filename, sourceText, importAliases, ctx);
|
|
@@ -2732,6 +2734,28 @@ function extractImportAliases(body) {
|
|
|
2732
2734
|
}
|
|
2733
2735
|
return aliases;
|
|
2734
2736
|
}
|
|
2737
|
+
function extractImportBindings(body) {
|
|
2738
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
2739
|
+
for (const node of body) {
|
|
2740
|
+
if (node.type !== "ImportDeclaration" || node.importKind === "type") continue;
|
|
2741
|
+
const source = node.source?.value;
|
|
2742
|
+
if (typeof source !== "string" || !node.specifiers) continue;
|
|
2743
|
+
for (const spec of node.specifiers) {
|
|
2744
|
+
if (!spec.local?.name) continue;
|
|
2745
|
+
if (spec.type === "ImportSpecifier") {
|
|
2746
|
+
if (spec.importKind === "type" || !spec.imported?.name) continue;
|
|
2747
|
+
bindings.set(spec.local.name, {
|
|
2748
|
+
source,
|
|
2749
|
+
imported: spec.imported.name
|
|
2750
|
+
});
|
|
2751
|
+
} else if (spec.type === "ImportNamespaceSpecifier") bindings.set(spec.local.name, {
|
|
2752
|
+
source,
|
|
2753
|
+
imported: null
|
|
2754
|
+
});
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
return bindings;
|
|
2758
|
+
}
|
|
2735
2759
|
function extractSmrtImports(body) {
|
|
2736
2760
|
const imports = /* @__PURE__ */ new Map();
|
|
2737
2761
|
for (const node of body) {
|
|
@@ -3060,7 +3084,7 @@ function extractClassDeclaration(node, filePath, sourceText, importAliases, ctx,
|
|
|
3060
3084
|
...reportDecorator ? { report: extractDecoratorConfig(reportDecorator, sourceText, ctx) } : {},
|
|
3061
3085
|
...tenantScopedDecorator ? { tenantScoped: extractDecoratorConfig(tenantScopedDecorator, sourceText, ctx) } : {}
|
|
3062
3086
|
} : smrtConfig;
|
|
3063
|
-
const { extendsClause, extendsTypeArg } = extractExtendsClause(node, importAliases);
|
|
3087
|
+
const { extendsClause, extendsTypeArg, extendsSource } = extractExtendsClause(node, importAliases, ctx?.importBindings);
|
|
3064
3088
|
const fields = [];
|
|
3065
3089
|
const methods = [];
|
|
3066
3090
|
for (const member of node.body.body) if (member.type === "PropertyDefinition") {
|
|
@@ -3080,6 +3104,7 @@ function extractClassDeclaration(node, filePath, sourceText, importAliases, ctx,
|
|
|
3080
3104
|
filePath,
|
|
3081
3105
|
extendsClause,
|
|
3082
3106
|
extendsTypeArg,
|
|
3107
|
+
...extendsSource ? { extendsSource } : {},
|
|
3083
3108
|
decoratorConfig,
|
|
3084
3109
|
hasSmartDecorator,
|
|
3085
3110
|
...description ? { description } : {},
|
|
@@ -3253,16 +3278,27 @@ function extractValue(node, sourceText, ctx) {
|
|
|
3253
3278
|
return rawSrc;
|
|
3254
3279
|
}
|
|
3255
3280
|
}
|
|
3256
|
-
function extractExtendsClause(node, importAliases) {
|
|
3281
|
+
function extractExtendsClause(node, importAliases, importBindings) {
|
|
3257
3282
|
if (!node.superClass) return {
|
|
3258
3283
|
extendsClause: null,
|
|
3259
3284
|
extendsTypeArg: null
|
|
3260
3285
|
};
|
|
3261
3286
|
let extendsClause = null;
|
|
3262
3287
|
let extendsTypeArg = null;
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3288
|
+
let extendsSource;
|
|
3289
|
+
if (node.superClass.type === "Identifier") {
|
|
3290
|
+
extendsClause = node.superClass.name;
|
|
3291
|
+
const binding = importBindings?.get(extendsClause);
|
|
3292
|
+
if (binding?.imported) extendsSource = binding.source;
|
|
3293
|
+
} else if (node.superClass.type === "MemberExpression") {
|
|
3294
|
+
const member = node.superClass;
|
|
3295
|
+
const namespace = !member.computed && member.object.type === "Identifier" && member.property.type === "Identifier" ? importBindings?.get(member.object.name) : void 0;
|
|
3296
|
+
if (namespace && namespace.imported === null && member.property.type === "Identifier") {
|
|
3297
|
+
extendsClause = member.property.name;
|
|
3298
|
+
extendsSource = namespace.source;
|
|
3299
|
+
} else extendsClause = getMemberExpressionString(member);
|
|
3300
|
+
}
|
|
3301
|
+
if (node.superClass.type === "Identifier" && extendsClause && importAliases.has(extendsClause)) {
|
|
3266
3302
|
const aliasedExtends = importAliases.get(extendsClause);
|
|
3267
3303
|
if (aliasedExtends) extendsClause = aliasedExtends;
|
|
3268
3304
|
}
|
|
@@ -3273,7 +3309,8 @@ function extractExtendsClause(node, importAliases) {
|
|
|
3273
3309
|
}
|
|
3274
3310
|
return {
|
|
3275
3311
|
extendsClause,
|
|
3276
|
-
extendsTypeArg
|
|
3312
|
+
extendsTypeArg,
|
|
3313
|
+
...extendsSource ? { extendsSource } : {}
|
|
3277
3314
|
};
|
|
3278
3315
|
}
|
|
3279
3316
|
function getMemberExpressionString(node) {
|
|
@@ -3684,6 +3721,17 @@ function resolveRelatedArgument(raw) {
|
|
|
3684
3721
|
function createQualifiedName(packageName, className) {
|
|
3685
3722
|
return `${packageName}:${className}`;
|
|
3686
3723
|
}
|
|
3724
|
+
function scopedPackageOfSpecifier(specifier) {
|
|
3725
|
+
return /^(@[a-z0-9][\w.~-]*\/[a-z0-9][\w.~-]*)(?:\/.*)?$/i.exec(specifier)?.[1];
|
|
3726
|
+
}
|
|
3727
|
+
function importedParentQualifiedName(classDef, ownPackageName) {
|
|
3728
|
+
const parent = classDef.extendsClause;
|
|
3729
|
+
if (!parent || !classDef.extendsSource) return void 0;
|
|
3730
|
+
if (FRAMEWORK_BASE_CLASSES.has(parent)) return void 0;
|
|
3731
|
+
const parentPackage = scopedPackageOfSpecifier(classDef.extendsSource);
|
|
3732
|
+
if (!parentPackage || parentPackage === ownPackageName) return void 0;
|
|
3733
|
+
return createQualifiedName(parentPackage, parent);
|
|
3734
|
+
}
|
|
3687
3735
|
function defaultCollectionName(className) {
|
|
3688
3736
|
const lower = className.toLowerCase();
|
|
3689
3737
|
if (/[^aeiou]y$/.test(lower)) return `${lower.slice(0, -1)}ies`;
|
|
@@ -3824,6 +3872,7 @@ var ManifestAdapter = class ManifestAdapter {
|
|
|
3824
3872
|
const collection = typeof classDef.decoratorConfig?.collection === "string" ? classDef.decoratorConfig.collection : defaultCollectionName(classDef.className);
|
|
3825
3873
|
const packageName = options.packageName || classDef.packageName;
|
|
3826
3874
|
const qualifiedName = packageName ? createQualifiedName(packageName, classDef.className) : void 0;
|
|
3875
|
+
const extendsQualified = importedParentQualifiedName(classDef, packageName || void 0);
|
|
3827
3876
|
return {
|
|
3828
3877
|
name: classDef.className.toLowerCase(),
|
|
3829
3878
|
className: classDef.className,
|
|
@@ -3836,6 +3885,7 @@ var ManifestAdapter = class ManifestAdapter {
|
|
|
3836
3885
|
methods,
|
|
3837
3886
|
decoratorConfig: classDef.decoratorConfig || {},
|
|
3838
3887
|
extends: classDef.extendsClause || void 0,
|
|
3888
|
+
...extendsQualified ? { extendsQualified } : {},
|
|
3839
3889
|
extendsTypeArg: classDef.extendsTypeArg || void 0,
|
|
3840
3890
|
exportName: classDef.className,
|
|
3841
3891
|
collectionExportName: `${classDef.className}Collection`,
|
|
@@ -4926,4 +4976,4 @@ var OxcScanner = class {
|
|
|
4926
4976
|
//#endregion
|
|
4927
4977
|
export { isPrunedAgentSurfacePath as C, sourceMayDeclareAgentSurface as E, isAgentSurfaceSourcePath as S, scanSvelteAgentSurface as T, normalizeGlobSeparators as _, extractSmrtImports as a, emptyAgentSurface as b, parseRecipeFile as c, extractRecipes as d, resolveRecipes as f, discoverSourceFiles as g, resolveEnumValues as h, defaultCollectionName as i, parseSource as l, InheritanceResolver as m, parseUiSelectorsFile as n, parseAgentSurfaceFile as o, sourceMayDeclareRecipe as p, ManifestAdapter as r, parseFile as s, OxcScanner as t, deriveHelpFieldRefs as u, relativeGlobToCwd as v, mergeAgentSurfaces as w, extractAgentSurface as x, checkAgentSurfaceToolNames as y };
|
|
4928
4978
|
|
|
4929
|
-
//# sourceMappingURL=scanner-
|
|
4979
|
+
//# sourceMappingURL=scanner-DPJwlSPw.js.map
|