Skip to content

Commit 2fe0087

Browse files
Merge pull request #22 from push-based/feat/extend-reporter
feat: extend reporter
2 parents ed8665b + e041ed1 commit 2fe0087

File tree

10 files changed

+354
-367
lines changed

10 files changed

+354
-367
lines changed

packages/angular-mcp-server/src/lib/angular-mcp-server.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { TOOLS } from './tools/tools.js';
1515
import { toolNotFound } from './tools/utils.js';
1616
import * as fs from 'node:fs';
1717
import * as path from 'node:path';
18+
import { fileURLToPath } from 'node:url';
1819
import {
1920
AngularMcpServerOptionsSchema,
2021
AngularMcpServerOptions,
@@ -94,11 +95,11 @@ export class AngularMcpServerWrapper {
9495

9596
// Try to read the llms.txt file from the package root (optional)
9697
try {
97-
const filePath = path.resolve(__dirname, '../../llms.txt');
98+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
99+
const filePath = path.resolve(currentDir, '../../llms.txt');
98100

99101
// Only attempt to read if file exists
100102
if (fs.existsSync(filePath)) {
101-
console.log('Reading llms.txt from:', filePath);
102103
const content = fs.readFileSync(filePath, 'utf-8');
103104
const lines = content.split('\n');
104105

@@ -143,13 +144,9 @@ export class AngularMcpServerWrapper {
143144
});
144145
}
145146
}
146-
} else {
147-
console.log('llms.txt not found at:', filePath, '(skipping)');
148-
}
149-
} catch (ctx: unknown) {
150-
if (ctx instanceof Error) {
151-
console.error('Error reading llms.txt (non-fatal):', ctx.message);
152147
}
148+
} catch {
149+
// Silently ignore errors reading llms.txt (non-fatal)
153150
}
154151

155152
// Scan available design system components to add them as discoverable resources
@@ -183,13 +180,8 @@ export class AngularMcpServerWrapper {
183180
}
184181
}
185182
}
186-
} catch (ctx: unknown) {
187-
if (ctx instanceof Error) {
188-
console.error(
189-
'Error scanning DS components (non-fatal):',
190-
ctx.message,
191-
);
192-
}
183+
} catch {
184+
// Silently ignore errors scanning DS components (non-fatal)
193185
}
194186

195187
return {

packages/angular-mcp-server/src/lib/tools/ds/report-violations/index.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ export { reportViolationsTools } from './report-violations.tool.js';
22
export { reportAllViolationsTools } from './report-all-violations.tool.js';
33

44
export type {
5-
ReportViolationsOptions,
6-
ViolationResult,
7-
ViolationIssue,
8-
ViolationAudit,
9-
FileViolation,
10-
FileViolationGroup,
11-
FileViolationGroups,
12-
FolderViolationSummary,
13-
FolderViolationGroups,
5+
ViolationEntry,
6+
ComponentViolationReport,
7+
AllViolationsEntry,
8+
AllViolationsComponentReport,
9+
AllViolationsReport,
10+
ComponentViolationInFile,
11+
FileViolationReport,
12+
AllViolationsReportByFile,
1413
} from './models/types.js';
Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,45 @@
1-
import {
2-
BaseViolationOptions,
3-
BaseViolationResult,
4-
BaseViolationIssue,
5-
BaseViolationAudit,
6-
} from '../../shared/violation-analysis/types.js';
7-
8-
export interface ReportViolationsOptions extends BaseViolationOptions {
9-
groupBy?: 'file' | 'folder';
1+
// Types for report-violations (single component, no replacement field needed)
2+
export interface ViolationEntry {
3+
file: string;
4+
lines: number[];
5+
violation: string;
106
}
117

12-
export type ViolationResult = BaseViolationResult;
13-
export type ViolationIssue = BaseViolationIssue;
14-
export type ViolationAudit = BaseViolationAudit;
8+
export interface ComponentViolationReport {
9+
component: string;
10+
violations: ViolationEntry[];
11+
}
1512

16-
// File-specific types (when groupBy: 'file')
17-
export interface FileViolation {
18-
fileName: string;
19-
message: string;
13+
// Types for report-all-violations (multiple components, replacement field needed)
14+
export interface AllViolationsEntry {
15+
file: string;
2016
lines: number[];
17+
violation: string;
18+
replacement: string;
2119
}
2220

23-
export interface FileViolationGroup {
24-
message: string;
25-
lines: number[];
21+
export interface AllViolationsComponentReport {
22+
component: string;
23+
violations: AllViolationsEntry[];
2624
}
2725

28-
export interface FileViolationGroups {
29-
[fileName: string]: FileViolationGroup;
26+
export interface AllViolationsReport {
27+
components: AllViolationsComponentReport[];
28+
}
29+
30+
// File-grouped output types for report-all-violations
31+
export interface ComponentViolationInFile {
32+
component: string;
33+
lines: number[];
34+
violation: string;
35+
replacement: string;
3036
}
3137

32-
// Folder-specific types (when groupBy: 'folder')
33-
export interface FolderViolationSummary {
34-
violations: number;
35-
files: string[];
38+
export interface FileViolationReport {
39+
file: string;
40+
components: ComponentViolationInFile[];
3641
}
3742

38-
export interface FolderViolationGroups {
39-
[folderPath: string]: FolderViolationSummary;
43+
export interface AllViolationsReportByFile {
44+
files: FileViolationReport[];
4045
}

0 commit comments

Comments
 (0)