@aiready/agent-grounding 0.9.3 → 0.11.0

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @aiready/agent-grounding@0.9.2 build /Users/pengcao/projects/aiready/packages/agent-grounding
3
+ > @aiready/agent-grounding@0.10.0 build /Users/pengcao/projects/aiready/packages/agent-grounding
4
4
  > tsup src/index.ts src/cli.ts --format cjs,esm --dts
5
5
 
6
6
  CLI Building entry: src/cli.ts, src/index.ts
@@ -9,16 +9,16 @@
9
9
  CLI Target: es2020
10
10
  CJS Build start
11
11
  ESM Build start
12
+ ESM dist/index.mjs 1.30 KB
12
13
  ESM dist/cli.mjs 5.16 KB
13
- ESM dist/chunk-L3MLD6K4.mjs 9.65 KB
14
- ESM dist/index.mjs 154.00 B
15
- ESM ⚡️ Build success in 214ms
16
- CJS dist/index.js 10.96 KB
17
- CJS dist/cli.js 16.44 KB
18
- CJS ⚡️ Build success in 214ms
14
+ ESM dist/chunk-T5YTLYD6.mjs 9.69 KB
15
+ ESM ⚡️ Build success in 60ms
16
+ CJS dist/index.js 12.27 KB
17
+ CJS dist/cli.js 16.50 KB
18
+ CJS ⚡️ Build success in 60ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 2292ms
20
+ DTS ⚡️ Build success in 2662ms
21
21
  DTS dist/cli.d.ts 20.00 B
22
- DTS dist/index.d.ts 2.36 KB
22
+ DTS dist/index.d.ts 2.49 KB
23
23
  DTS dist/cli.d.mts 20.00 B
24
- DTS dist/index.d.mts 2.36 KB
24
+ DTS dist/index.d.mts 2.49 KB
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > @aiready/agent-grounding@0.1.6 lint /Users/pengcao/projects/aiready/packages/agent-grounding
3
+ > @aiready/agent-grounding@0.9.5 lint /Users/pengcao/projects/aiready/packages/agent-grounding
4
4
  > eslint src
5
5
 
@@ -1,16 +1,16 @@
1
1
 
2
2
  
3
- > @aiready/agent-grounding@0.9.2 test /Users/pengcao/projects/aiready/packages/agent-grounding
3
+ > @aiready/agent-grounding@0.10.0 test /Users/pengcao/projects/aiready/packages/agent-grounding
4
4
  > vitest run
5
5
 
6
6
  [?25l
7
7
   RUN  v4.0.18 /Users/pengcao/projects/aiready/packages/agent-grounding
8
8
 
9
- ✓ src/__tests__/analyzer.test.ts (3 tests) 317ms
9
+ ✓ src/__tests__/analyzer.test.ts (3 tests) 135ms
10
10
 
11
11
   Test Files  1 passed (1)
12
12
   Tests  3 passed (3)
13
-  Start at  20:00:26
14
-  Duration  2.35s (transform 316ms, setup 0ms, import 1.51s, tests 317ms, environment 0ms)
13
+  Start at  09:33:02
14
+  Duration  1.11s (transform 351ms, setup 0ms, import 812ms, tests 135ms, environment 0ms)
15
15
 
16
16
  [?25h
@@ -0,0 +1,297 @@
1
+ // src/analyzer.ts
2
+ import {
3
+ scanEntries,
4
+ calculateAgentGrounding,
5
+ VAGUE_FILE_NAMES,
6
+ Severity,
7
+ IssueType
8
+ } from "@aiready/core";
9
+ import { readFileSync, existsSync, statSync } from "fs";
10
+ import { join, extname, basename, relative } from "path";
11
+ import { parse } from "@typescript-eslint/typescript-estree";
12
+ function analyzeFile(filePath) {
13
+ let code;
14
+ try {
15
+ code = readFileSync(filePath, "utf-8");
16
+ } catch {
17
+ return {
18
+ isBarrel: false,
19
+ exportedNames: [],
20
+ untypedExports: 0,
21
+ totalExports: 0,
22
+ domainTerms: []
23
+ };
24
+ }
25
+ let ast;
26
+ try {
27
+ ast = parse(code, {
28
+ jsx: filePath.endsWith(".tsx") || filePath.endsWith(".jsx"),
29
+ range: false,
30
+ loc: false
31
+ });
32
+ } catch {
33
+ return {
34
+ isBarrel: false,
35
+ exportedNames: [],
36
+ untypedExports: 0,
37
+ totalExports: 0,
38
+ domainTerms: []
39
+ };
40
+ }
41
+ let isBarrel = false;
42
+ const exportedNames = [];
43
+ let untypedExports = 0;
44
+ let totalExports = 0;
45
+ const domainTerms = [];
46
+ for (const node of ast.body) {
47
+ if (node.type === "ExportAllDeclaration") {
48
+ isBarrel = true;
49
+ continue;
50
+ }
51
+ if (node.type === "ExportNamedDeclaration") {
52
+ totalExports++;
53
+ const decl = node.declaration;
54
+ if (decl) {
55
+ const name = decl.id?.name ?? decl.declarations?.[0]?.id?.name;
56
+ if (name) {
57
+ exportedNames.push(name);
58
+ domainTerms.push(
59
+ ...name.replace(/([A-Z])/g, " $1").toLowerCase().split(/\s+/).filter(Boolean)
60
+ );
61
+ const hasType = decl.returnType != null || decl.declarations?.[0]?.id?.typeAnnotation != null || decl.typeParameters != null;
62
+ if (!hasType) untypedExports++;
63
+ }
64
+ } else if (node.specifiers && node.specifiers.length > 0) {
65
+ isBarrel = true;
66
+ }
67
+ }
68
+ if (node.type === "ExportDefaultDeclaration") {
69
+ totalExports++;
70
+ }
71
+ }
72
+ return { isBarrel, exportedNames, untypedExports, totalExports, domainTerms };
73
+ }
74
+ function detectInconsistentTerms(allTerms) {
75
+ const termFreq = /* @__PURE__ */ new Map();
76
+ for (const term of allTerms) {
77
+ if (term.length >= 3) {
78
+ termFreq.set(term, (termFreq.get(term) ?? 0) + 1);
79
+ }
80
+ }
81
+ const orphans = [...termFreq.values()].filter((count) => count === 1).length;
82
+ const common = [...termFreq.values()].filter((count) => count >= 3).length;
83
+ const vocabularySize = termFreq.size;
84
+ const inconsistent = Math.max(0, orphans - common * 2);
85
+ return { inconsistent, vocabularySize };
86
+ }
87
+ async function analyzeAgentGrounding(options) {
88
+ const rootDir = options.rootDir;
89
+ const maxRecommendedDepth = options.maxRecommendedDepth ?? 4;
90
+ const readmeStaleDays = options.readmeStaleDays ?? 90;
91
+ const { files, dirs: rawDirs } = await scanEntries({
92
+ ...options,
93
+ include: options.include || ["**/*.{ts,tsx,js,jsx}"]
94
+ });
95
+ const dirs = rawDirs.map((d) => ({
96
+ path: d,
97
+ depth: relative(rootDir, d).split(/[/\\]/).filter(Boolean).length
98
+ }));
99
+ const deepDirectories = dirs.filter(
100
+ (d) => d.depth > maxRecommendedDepth
101
+ ).length;
102
+ const additionalVague = new Set(
103
+ (options.additionalVagueNames ?? []).map((n) => n.toLowerCase())
104
+ );
105
+ let vagueFileNames = 0;
106
+ for (const f of files) {
107
+ const base = basename(f, extname(f)).toLowerCase();
108
+ if (VAGUE_FILE_NAMES.has(base) || additionalVague.has(base)) {
109
+ vagueFileNames++;
110
+ }
111
+ }
112
+ const readmePath = join(rootDir, "README.md");
113
+ const hasRootReadme = existsSync(readmePath);
114
+ let readmeIsFresh = false;
115
+ if (hasRootReadme) {
116
+ try {
117
+ const stat = statSync(readmePath);
118
+ const ageDays = (Date.now() - stat.mtimeMs) / (1e3 * 60 * 60 * 24);
119
+ readmeIsFresh = ageDays < readmeStaleDays;
120
+ } catch {
121
+ }
122
+ }
123
+ const allDomainTerms = [];
124
+ let barrelExports = 0;
125
+ let untypedExports = 0;
126
+ let totalExports = 0;
127
+ let processed = 0;
128
+ for (const f of files) {
129
+ processed++;
130
+ options.onProgress?.(
131
+ processed,
132
+ files.length,
133
+ `agent-grounding: analyzing files`
134
+ );
135
+ const analysis = analyzeFile(f);
136
+ if (analysis.isBarrel) barrelExports++;
137
+ untypedExports += analysis.untypedExports;
138
+ totalExports += analysis.totalExports;
139
+ allDomainTerms.push(...analysis.domainTerms);
140
+ }
141
+ const {
142
+ inconsistent: inconsistentDomainTerms,
143
+ vocabularySize: domainVocabularySize
144
+ } = detectInconsistentTerms(allDomainTerms);
145
+ const groundingResult = calculateAgentGrounding({
146
+ deepDirectories,
147
+ totalDirectories: dirs.length,
148
+ vagueFileNames,
149
+ totalFiles: files.length,
150
+ hasRootReadme,
151
+ readmeIsFresh,
152
+ barrelExports,
153
+ untypedExports,
154
+ totalExports: Math.max(1, totalExports),
155
+ inconsistentDomainTerms,
156
+ domainVocabularySize: Math.max(1, domainVocabularySize)
157
+ });
158
+ const issues = [];
159
+ if (groundingResult.dimensions.structureClarityScore < 70) {
160
+ issues.push({
161
+ type: IssueType.AgentNavigationFailure,
162
+ dimension: "structure-clarity",
163
+ severity: Severity.Major,
164
+ message: `${deepDirectories} directories exceed recommended depth of ${maxRecommendedDepth} \u2014 agents struggle to navigate deep trees.`,
165
+ location: { file: rootDir, line: 0 },
166
+ suggestion: `Flatten nested directories to ${maxRecommendedDepth} levels or fewer.`
167
+ });
168
+ }
169
+ if (groundingResult.dimensions.selfDocumentationScore < 70) {
170
+ issues.push({
171
+ type: IssueType.AgentNavigationFailure,
172
+ dimension: "self-documentation",
173
+ severity: Severity.Major,
174
+ message: `${vagueFileNames} files use vague names (utils, helpers, misc) \u2014 an agent cannot determine their purpose from the name alone.`,
175
+ location: { file: rootDir, line: 0 },
176
+ suggestion: "Rename to domain-specific names: e.g., userAuthUtils \u2192 tokenValidator."
177
+ });
178
+ }
179
+ if (!hasRootReadme) {
180
+ issues.push({
181
+ type: IssueType.AgentNavigationFailure,
182
+ dimension: "entry-point",
183
+ severity: Severity.Critical,
184
+ message: "No root README.md found \u2014 agents have no orientation document to start from.",
185
+ location: { file: join(rootDir, "README.md"), line: 0 },
186
+ suggestion: "Add a README.md explaining the project structure, entry points, and key conventions."
187
+ });
188
+ } else if (!readmeIsFresh) {
189
+ issues.push({
190
+ type: IssueType.AgentNavigationFailure,
191
+ dimension: "entry-point",
192
+ severity: Severity.Minor,
193
+ message: `README.md is stale (>${readmeStaleDays} days without updates) \u2014 agents may be misled by outdated context.`,
194
+ location: { file: readmePath, line: 0 },
195
+ suggestion: "Update README.md to reflect the current codebase structure."
196
+ });
197
+ }
198
+ if (groundingResult.dimensions.apiClarityScore < 70) {
199
+ issues.push({
200
+ type: IssueType.AgentNavigationFailure,
201
+ dimension: "api-clarity",
202
+ severity: Severity.Major,
203
+ message: `${untypedExports} of ${totalExports} public exports lack TypeScript type annotations \u2014 agents cannot infer the API contract.`,
204
+ location: { file: rootDir, line: 0 },
205
+ suggestion: "Add explicit return type and parameter annotations to all exported functions."
206
+ });
207
+ }
208
+ if (groundingResult.dimensions.domainConsistencyScore < 70) {
209
+ issues.push({
210
+ type: IssueType.AgentNavigationFailure,
211
+ dimension: "domain-consistency",
212
+ severity: Severity.Major,
213
+ message: `${inconsistentDomainTerms} domain terms appear to be used inconsistently \u2014 agents get confused when one concept has multiple names.`,
214
+ location: { file: rootDir, line: 0 },
215
+ suggestion: "Establish a domain glossary and enforce one term per concept across the codebase."
216
+ });
217
+ }
218
+ return {
219
+ summary: {
220
+ filesAnalyzed: files.length,
221
+ directoriesAnalyzed: dirs.length,
222
+ score: groundingResult.score,
223
+ rating: groundingResult.rating,
224
+ dimensions: groundingResult.dimensions
225
+ },
226
+ issues,
227
+ rawData: {
228
+ deepDirectories,
229
+ totalDirectories: dirs.length,
230
+ vagueFileNames,
231
+ totalFiles: files.length,
232
+ hasRootReadme,
233
+ readmeIsFresh,
234
+ barrelExports,
235
+ untypedExports,
236
+ totalExports,
237
+ inconsistentDomainTerms,
238
+ domainVocabularySize
239
+ },
240
+ recommendations: groundingResult.recommendations
241
+ };
242
+ }
243
+
244
+ // src/scoring.ts
245
+ import { ToolName } from "@aiready/core";
246
+ function calculateGroundingScore(report) {
247
+ const { summary, rawData, recommendations } = report;
248
+ const factors = [
249
+ {
250
+ name: "Structure Clarity",
251
+ impact: Math.round(summary.dimensions.structureClarityScore - 50),
252
+ description: `${rawData.deepDirectories} of ${rawData.totalDirectories} dirs exceed recommended depth`
253
+ },
254
+ {
255
+ name: "Self-Documentation",
256
+ impact: Math.round(summary.dimensions.selfDocumentationScore - 50),
257
+ description: `${rawData.vagueFileNames} of ${rawData.totalFiles} files have vague names`
258
+ },
259
+ {
260
+ name: "Entry Points",
261
+ impact: Math.round(summary.dimensions.entryPointScore - 50),
262
+ description: rawData.hasRootReadme ? rawData.readmeIsFresh ? "README present and fresh" : "README present but stale" : "No root README"
263
+ },
264
+ {
265
+ name: "API Clarity",
266
+ impact: Math.round(summary.dimensions.apiClarityScore - 50),
267
+ description: `${rawData.untypedExports} of ${rawData.totalExports} exports lack type annotations`
268
+ },
269
+ {
270
+ name: "Domain Consistency",
271
+ impact: Math.round(summary.dimensions.domainConsistencyScore - 50),
272
+ description: `${rawData.inconsistentDomainTerms} inconsistent domain terms detected`
273
+ }
274
+ ];
275
+ const recs = recommendations.map(
276
+ (action) => ({
277
+ action,
278
+ estimatedImpact: 6,
279
+ priority: summary.score < 50 ? "high" : "medium"
280
+ })
281
+ );
282
+ return {
283
+ toolName: ToolName.AgentGrounding,
284
+ score: summary.score,
285
+ rawMetrics: {
286
+ ...rawData,
287
+ rating: summary.rating
288
+ },
289
+ factors,
290
+ recommendations: recs
291
+ };
292
+ }
293
+
294
+ export {
295
+ analyzeAgentGrounding,
296
+ calculateGroundingScore
297
+ };
package/dist/cli.js CHANGED
@@ -264,6 +264,7 @@ async function analyzeAgentGrounding(options) {
264
264
  }
265
265
 
266
266
  // src/scoring.ts
267
+ var import_core2 = require("@aiready/core");
267
268
  function calculateGroundingScore(report) {
268
269
  const { summary, rawData, recommendations } = report;
269
270
  const factors = [
@@ -301,7 +302,7 @@ function calculateGroundingScore(report) {
301
302
  })
302
303
  );
303
304
  return {
304
- toolName: "agent-grounding",
305
+ toolName: import_core2.ToolName.AgentGrounding,
305
306
  score: summary.score,
306
307
  rawMetrics: {
307
308
  ...rawData,
@@ -316,7 +317,7 @@ function calculateGroundingScore(report) {
316
317
  var import_chalk = __toESM(require("chalk"));
317
318
  var import_fs2 = require("fs");
318
319
  var import_path2 = require("path");
319
- var import_core2 = require("@aiready/core");
320
+ var import_core3 = require("@aiready/core");
320
321
  var program = new import_commander.Command();
321
322
  program.name("aiready-agent-grounding").description(
322
323
  "Measure how well an AI agent can navigate your codebase autonomously"
@@ -346,8 +347,8 @@ EXAMPLES:
346
347
  ).option("--include <patterns>", "File patterns to include (comma-separated)").option("--exclude <patterns>", "File patterns to exclude (comma-separated)").option("-o, --output <format>", "Output format: console|json", "console").option("--output-file <path>", "Output file path (for json)").action(async (directory, options) => {
347
348
  console.log(import_chalk.default.blue("\u{1F9ED} Analyzing agent grounding...\n"));
348
349
  const startTime = Date.now();
349
- const config = await (0, import_core2.loadConfig)(directory);
350
- const mergedConfig = (0, import_core2.mergeConfigWithDefaults)(config, {
350
+ const config = await (0, import_core3.loadConfig)(directory);
351
+ const mergedConfig = (0, import_core3.mergeConfigWithDefaults)(config, {
351
352
  maxRecommendedDepth: 4,
352
353
  readmeStaleDays: 90
353
354
  });
@@ -363,7 +364,7 @@ EXAMPLES:
363
364
  const elapsed = ((Date.now() - startTime) / 1e3).toFixed(2);
364
365
  if (options.output === "json") {
365
366
  const payload = { report, score: scoring };
366
- const outputPath = (0, import_core2.resolveOutputPath)(
367
+ const outputPath = (0, import_core3.resolveOutputPath)(
367
368
  options.outputFile,
368
369
  `agent-grounding-report-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.json`,
369
370
  directory
package/dist/cli.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  analyzeAgentGrounding,
4
4
  calculateGroundingScore
5
- } from "./chunk-L3MLD6K4.mjs";
5
+ } from "./chunk-T5YTLYD6.mjs";
6
6
 
7
7
  // src/cli.ts
8
8
  import { Command } from "commander";
package/dist/index.d.mts CHANGED
@@ -1,4 +1,9 @@
1
- import { Issue, IssueType, ScanOptions, ToolScoringOutput } from '@aiready/core';
1
+ import { ToolProvider, Issue, IssueType, ScanOptions, ToolScoringOutput } from '@aiready/core';
2
+
3
+ /**
4
+ * Agent Grounding Tool Provider
5
+ */
6
+ declare const AgentGroundingProvider: ToolProvider;
2
7
 
3
8
  interface AgentGroundingOptions extends ScanOptions {
4
9
  /** Max directory depth before flagging as "too deep" */
@@ -63,4 +68,4 @@ declare function analyzeAgentGrounding(options: AgentGroundingOptions): Promise<
63
68
  */
64
69
  declare function calculateGroundingScore(report: AgentGroundingReport): ToolScoringOutput;
65
70
 
66
- export { type AgentGroundingIssue, type AgentGroundingOptions, type AgentGroundingReport, analyzeAgentGrounding, calculateGroundingScore };
71
+ export { type AgentGroundingIssue, type AgentGroundingOptions, AgentGroundingProvider, type AgentGroundingReport, analyzeAgentGrounding, calculateGroundingScore };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,9 @@
1
- import { Issue, IssueType, ScanOptions, ToolScoringOutput } from '@aiready/core';
1
+ import { ToolProvider, Issue, IssueType, ScanOptions, ToolScoringOutput } from '@aiready/core';
2
+
3
+ /**
4
+ * Agent Grounding Tool Provider
5
+ */
6
+ declare const AgentGroundingProvider: ToolProvider;
2
7
 
3
8
  interface AgentGroundingOptions extends ScanOptions {
4
9
  /** Max directory depth before flagging as "too deep" */
@@ -63,4 +68,4 @@ declare function analyzeAgentGrounding(options: AgentGroundingOptions): Promise<
63
68
  */
64
69
  declare function calculateGroundingScore(report: AgentGroundingReport): ToolScoringOutput;
65
70
 
66
- export { type AgentGroundingIssue, type AgentGroundingOptions, type AgentGroundingReport, analyzeAgentGrounding, calculateGroundingScore };
71
+ export { type AgentGroundingIssue, type AgentGroundingOptions, AgentGroundingProvider, type AgentGroundingReport, analyzeAgentGrounding, calculateGroundingScore };
package/dist/index.js CHANGED
@@ -20,10 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ AgentGroundingProvider: () => AgentGroundingProvider,
23
24
  analyzeAgentGrounding: () => analyzeAgentGrounding,
24
25
  calculateGroundingScore: () => calculateGroundingScore
25
26
  });
26
27
  module.exports = __toCommonJS(index_exports);
28
+ var import_core4 = require("@aiready/core");
29
+
30
+ // src/provider.ts
31
+ var import_core3 = require("@aiready/core");
27
32
 
28
33
  // src/analyzer.ts
29
34
  var import_core = require("@aiready/core");
@@ -263,6 +268,7 @@ async function analyzeAgentGrounding(options) {
263
268
  }
264
269
 
265
270
  // src/scoring.ts
271
+ var import_core2 = require("@aiready/core");
266
272
  function calculateGroundingScore(report) {
267
273
  const { summary, rawData, recommendations } = report;
268
274
  const factors = [
@@ -300,7 +306,7 @@ function calculateGroundingScore(report) {
300
306
  })
301
307
  );
302
308
  return {
303
- toolName: "agent-grounding",
309
+ toolName: import_core2.ToolName.AgentGrounding,
304
310
  score: summary.score,
305
311
  rawMetrics: {
306
312
  ...rawData,
@@ -310,8 +316,49 @@ function calculateGroundingScore(report) {
310
316
  recommendations: recs
311
317
  };
312
318
  }
319
+
320
+ // src/provider.ts
321
+ var AgentGroundingProvider = {
322
+ id: import_core3.ToolName.AgentGrounding,
323
+ alias: ["agent-grounding", "grounding", "navigation"],
324
+ async analyze(options) {
325
+ const report = await analyzeAgentGrounding(
326
+ options
327
+ );
328
+ const results = report.issues.map((i) => ({
329
+ fileName: i.location.file,
330
+ issues: [i],
331
+ metrics: {
332
+ agentGroundingScore: report.summary.score
333
+ }
334
+ }));
335
+ return import_core3.SpokeOutputSchema.parse({
336
+ results,
337
+ summary: report.summary,
338
+ metadata: {
339
+ toolName: import_core3.ToolName.AgentGrounding,
340
+ version: "0.9.5",
341
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
342
+ rawData: report.rawData
343
+ }
344
+ });
345
+ },
346
+ score(output, options) {
347
+ const report = {
348
+ summary: output.summary,
349
+ rawData: output.metadata.rawData,
350
+ recommendations: output.summary.recommendations || []
351
+ };
352
+ return calculateGroundingScore(report);
353
+ },
354
+ defaultWeight: 10
355
+ };
356
+
357
+ // src/index.ts
358
+ import_core4.ToolRegistry.register(AgentGroundingProvider);
313
359
  // Annotate the CommonJS export names for ESM import in node:
314
360
  0 && (module.exports = {
361
+ AgentGroundingProvider,
315
362
  analyzeAgentGrounding,
316
363
  calculateGroundingScore
317
364
  });
package/dist/index.mjs CHANGED
@@ -1,8 +1,56 @@
1
1
  import {
2
2
  analyzeAgentGrounding,
3
3
  calculateGroundingScore
4
- } from "./chunk-L3MLD6K4.mjs";
4
+ } from "./chunk-T5YTLYD6.mjs";
5
+
6
+ // src/index.ts
7
+ import { ToolRegistry } from "@aiready/core";
8
+
9
+ // src/provider.ts
10
+ import {
11
+ ToolName,
12
+ SpokeOutputSchema
13
+ } from "@aiready/core";
14
+ var AgentGroundingProvider = {
15
+ id: ToolName.AgentGrounding,
16
+ alias: ["agent-grounding", "grounding", "navigation"],
17
+ async analyze(options) {
18
+ const report = await analyzeAgentGrounding(
19
+ options
20
+ );
21
+ const results = report.issues.map((i) => ({
22
+ fileName: i.location.file,
23
+ issues: [i],
24
+ metrics: {
25
+ agentGroundingScore: report.summary.score
26
+ }
27
+ }));
28
+ return SpokeOutputSchema.parse({
29
+ results,
30
+ summary: report.summary,
31
+ metadata: {
32
+ toolName: ToolName.AgentGrounding,
33
+ version: "0.9.5",
34
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
35
+ rawData: report.rawData
36
+ }
37
+ });
38
+ },
39
+ score(output, options) {
40
+ const report = {
41
+ summary: output.summary,
42
+ rawData: output.metadata.rawData,
43
+ recommendations: output.summary.recommendations || []
44
+ };
45
+ return calculateGroundingScore(report);
46
+ },
47
+ defaultWeight: 10
48
+ };
49
+
50
+ // src/index.ts
51
+ ToolRegistry.register(AgentGroundingProvider);
5
52
  export {
53
+ AgentGroundingProvider,
6
54
  analyzeAgentGrounding,
7
55
  calculateGroundingScore
8
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/agent-grounding",
3
- "version": "0.9.3",
3
+ "version": "0.11.0",
4
4
  "description": "Measures how well an AI agent can navigate a codebase autonomously without human assistance",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -40,7 +40,7 @@
40
40
  "chalk": "^5.3.0",
41
41
  "commander": "^14.0.0",
42
42
  "glob": "^13.0.0",
43
- "@aiready/core": "0.19.3"
43
+ "@aiready/core": "0.21.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^24.0.0",
package/src/index.ts CHANGED
@@ -1,5 +1,12 @@
1
+ import { ToolRegistry } from '@aiready/core';
2
+ import { AgentGroundingProvider } from './provider';
3
+
4
+ // Register with global registry
5
+ ToolRegistry.register(AgentGroundingProvider);
6
+
1
7
  export { analyzeAgentGrounding } from './analyzer';
2
8
  export { calculateGroundingScore } from './scoring';
9
+ export { AgentGroundingProvider };
3
10
  export type {
4
11
  AgentGroundingOptions,
5
12
  AgentGroundingReport,
@@ -0,0 +1,57 @@
1
+ import {
2
+ ToolProvider,
3
+ ToolName,
4
+ SpokeOutput,
5
+ ScanOptions,
6
+ ToolScoringOutput,
7
+ AnalysisResult,
8
+ SpokeOutputSchema,
9
+ } from '@aiready/core';
10
+ import { analyzeAgentGrounding } from './analyzer';
11
+ import { calculateGroundingScore } from './scoring';
12
+ import { AgentGroundingOptions, AgentGroundingReport } from './types';
13
+
14
+ /**
15
+ * Agent Grounding Tool Provider
16
+ */
17
+ export const AgentGroundingProvider: ToolProvider = {
18
+ id: ToolName.AgentGrounding,
19
+ alias: ['agent-grounding', 'grounding', 'navigation'],
20
+
21
+ async analyze(options: ScanOptions): Promise<SpokeOutput> {
22
+ const report = await analyzeAgentGrounding(
23
+ options as AgentGroundingOptions
24
+ );
25
+
26
+ const results: AnalysisResult[] = report.issues.map((i) => ({
27
+ fileName: i.location.file,
28
+ issues: [i] as any[],
29
+ metrics: {
30
+ agentGroundingScore: report.summary.score,
31
+ },
32
+ }));
33
+
34
+ return SpokeOutputSchema.parse({
35
+ results,
36
+ summary: report.summary,
37
+ metadata: {
38
+ toolName: ToolName.AgentGrounding,
39
+ version: '0.9.5',
40
+ timestamp: new Date().toISOString(),
41
+ rawData: report.rawData,
42
+ },
43
+ });
44
+ },
45
+
46
+ score(output: SpokeOutput, options: ScanOptions): ToolScoringOutput {
47
+ const report = {
48
+ summary: output.summary,
49
+ rawData: (output.metadata as any).rawData,
50
+ recommendations: (output.summary as any).recommendations || [],
51
+ } as unknown as AgentGroundingReport;
52
+
53
+ return calculateGroundingScore(report);
54
+ },
55
+
56
+ defaultWeight: 10,
57
+ };
package/src/scoring.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ToolScoringOutput } from '@aiready/core';
1
+ import { type ToolScoringOutput, ToolName } from '@aiready/core';
2
2
  import type { AgentGroundingReport } from './types';
3
3
 
4
4
  /**
@@ -51,7 +51,7 @@ export function calculateGroundingScore(
51
51
  );
52
52
 
53
53
  return {
54
- toolName: 'agent-grounding',
54
+ toolName: ToolName.AgentGrounding,
55
55
  score: summary.score,
56
56
  rawMetrics: {
57
57
  ...rawData,