@aiready/context-analyzer 0.22.4 → 0.22.6

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/src/provider.ts CHANGED
@@ -10,7 +10,11 @@ import {
10
10
  SpokeOutputSchema,
11
11
  } from '@aiready/core';
12
12
  import { calculateContextScore } from './scoring';
13
- import type { ContextAnalyzerOptions, ContextAnalysisResult } from './types';
13
+ import type {
14
+ ContextAnalyzerOptions,
15
+ ContextAnalysisResult,
16
+ ContextSummary,
17
+ } from './types';
14
18
 
15
19
  /**
16
20
  * Context Analyzer Tool Provider
@@ -58,8 +62,8 @@ export const ContextAnalyzerProvider: ToolProvider = {
58
62
  },
59
63
 
60
64
  score(output: SpokeOutput, options: ScanOptions): ToolScoringOutput {
61
- const summary = output.summary as any;
62
- return calculateContextScore(summary, (options as any).costConfig);
65
+ const summary = output.summary as unknown as ContextSummary;
66
+ return calculateContextScore(summary, options.costConfig);
63
67
  },
64
68
 
65
69
  defaultWeight: 19,
@@ -155,5 +155,9 @@ export function getGeneralRecommendations(
155
155
  if (severity === 'info') severity = 'minor';
156
156
  }
157
157
 
158
- return { recommendations, issues, severity: severity as any };
158
+ return {
159
+ recommendations,
160
+ issues,
161
+ severity: severity as 'critical' | 'major' | 'minor' | 'info',
162
+ };
159
163
  }
@@ -2,8 +2,8 @@ import type {
2
2
  DependencyGraph,
3
3
  DomainAssignment,
4
4
  DomainSignals,
5
- ExportInfo,
6
5
  } from '../types';
6
+ import type { ExportInfo } from '@aiready/core';
7
7
  import { singularize } from '../utils/string-utils';
8
8
 
9
9
  /**
@@ -59,8 +59,12 @@ export function inferDomainFromSemantics(
59
59
  const coNode = graph.nodes.get(coFile);
60
60
  if (coNode) {
61
61
  for (const exp of coNode.exports) {
62
- if (exp.inferredDomain && exp.inferredDomain !== 'unknown') {
63
- const domain = exp.inferredDomain;
62
+ const expAny = exp as {
63
+ inferredDomain?: string;
64
+ domains?: Array<{ domain: string }>;
65
+ };
66
+ if (expAny.inferredDomain && expAny.inferredDomain !== 'unknown') {
67
+ const domain = expAny.inferredDomain;
64
68
  if (!domainSignals.has(domain)) {
65
69
  domainSignals.set(domain, {
66
70
  coUsage: false,
@@ -85,8 +89,15 @@ export function inferDomainFromSemantics(
85
89
  const typeNode = graph.nodes.get(typeFile);
86
90
  if (typeNode) {
87
91
  for (const exp of typeNode.exports) {
88
- if (exp.inferredDomain && exp.inferredDomain !== 'unknown') {
89
- const domain = exp.inferredDomain;
92
+ const expAny = exp as {
93
+ inferredDomain?: string;
94
+ domains?: Array<{ domain: string }>;
95
+ };
96
+ if (
97
+ expAny.inferredDomain &&
98
+ expAny.inferredDomain !== 'unknown'
99
+ ) {
100
+ const domain = expAny.inferredDomain;
90
101
  if (!domainSignals.has(domain)) {
91
102
  domainSignals.set(domain, {
92
103
  coUsage: false,
@@ -160,7 +171,7 @@ export function extractExports(
160
171
  domainOptions,
161
172
  fileImports
162
173
  );
163
- exports.push({ name, type, inferredDomain });
174
+ exports.push({ name, type, inferredDomain } as any);
164
175
  }
165
176
  });
166
177
 
package/src/types.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { ScanOptions, Severity } from '@aiready/core';
1
+ import type { ScanOptions, Severity, ExportInfo } from '@aiready/core';
2
+ export type { ExportInfo };
2
3
 
3
4
  /**
4
5
  * Options for the Context Analyzer tool.
@@ -159,16 +160,6 @@ export interface DependencyNode {
159
160
  sharedTypes?: string[]; // Types shared with other files
160
161
  }
161
162
 
162
- export interface ExportInfo {
163
- name: string;
164
- type: 'function' | 'class' | 'const' | 'type' | 'interface' | 'default';
165
- inferredDomain?: string; // Inferred from name/usage (legacy single domain)
166
- domains?: DomainAssignment[]; // Multi-domain support with confidence scores
167
- imports?: string[]; // Imports used by this export (for import-based cohesion)
168
- dependencies?: string[]; // Other exports from same file this depends on
169
- typeReferences?: string[]; // TypeScript types referenced by this export
170
- }
171
-
172
163
  export interface DomainAssignment {
173
164
  domain: string;
174
165
  confidence: number; // 0-1, how confident are we in this assignment