@oxog/codeguardian 1.0.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.
@@ -0,0 +1,169 @@
1
+ import { G as GuardianConfig, P as ProjectConfig, C as CodebaseGraph, I as IncrementalResult, R as RunOptions, a as RunResult, b as GuardianPlugin, D as DetectedPattern, F as FileNode, S as SymbolNode, c as Rule } from './types-CQZEdzEa.cjs';
2
+ export { A as ASTVisitors, d as Finding, e as FunctionNode, f as GuardianKernel, g as ImportEdge, h as ImportInfo, i as RuleCategory, j as RuleContext, k as RunStats, l as Severity, m as SeverityConfig } from './types-CQZEdzEa.cjs';
3
+ import 'typescript';
4
+
5
+ /**
6
+ * Create a Guardian instance for analyzing a TypeScript project.
7
+ *
8
+ * @param config - Guardian configuration
9
+ * @returns Guardian instance with scan, run, use methods
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const guardian = createGuardian({
14
+ * rootDir: process.cwd(),
15
+ * tsconfig: './tsconfig.json',
16
+ * });
17
+ *
18
+ * const graph = await guardian.scan();
19
+ * console.log(`Scanned ${graph.files.size} files`);
20
+ * ```
21
+ */
22
+ declare function createGuardian(config: GuardianConfig): {
23
+ /** The project configuration. */
24
+ config: ProjectConfig;
25
+ /** The codebase knowledge graph (available after scan). */
26
+ readonly graph: CodebaseGraph;
27
+ /**
28
+ * Perform a full codebase scan and build the knowledge graph.
29
+ *
30
+ * @returns The complete codebase graph
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const graph = await guardian.scan();
35
+ * console.log(`${graph.files.size} files, ${graph.symbols.size} symbols`);
36
+ * ```
37
+ */
38
+ scan(): Promise<CodebaseGraph>;
39
+ /**
40
+ * Perform an incremental scan based on git staged files.
41
+ *
42
+ * @returns Incremental result with changed and affected files
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const result = await guardian.scanIncremental();
47
+ * console.log(`Updated ${result.changedFiles.length} files`);
48
+ * ```
49
+ */
50
+ scanIncremental(): Promise<IncrementalResult>;
51
+ /**
52
+ * Run analysis rules on the codebase.
53
+ *
54
+ * @param options - Run options (staged, verbose, plugins, format)
55
+ * @returns Run result with findings, stats, and blocked status
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const result = await guardian.run({ staged: true });
60
+ * if (result.blocked) {
61
+ * console.error('Commit blocked!');
62
+ * process.exit(1);
63
+ * }
64
+ * ```
65
+ */
66
+ run(options?: RunOptions): Promise<RunResult>;
67
+ /**
68
+ * Register a plugin with the guardian.
69
+ *
70
+ * @param plugin - Plugin to register
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * import { definePlugin } from '@oxog/codeguardian';
75
+ * guardian.use(myPlugin);
76
+ * ```
77
+ */
78
+ use<TConfig>(plugin: GuardianPlugin<TConfig>): void;
79
+ /**
80
+ * Auto-discover project conventions.
81
+ *
82
+ * @returns Detected patterns
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const conventions = await guardian.discover();
87
+ * ```
88
+ */
89
+ discover(): Promise<DetectedPattern[]>;
90
+ /**
91
+ * Format run results for output.
92
+ *
93
+ * @param result - Run result
94
+ * @param format - Output format
95
+ * @param verbose - Include info-level findings
96
+ * @returns Formatted string
97
+ */
98
+ format(result: RunResult, format?: "terminal" | "json" | "sarif", verbose?: boolean): string;
99
+ /**
100
+ * Get graph query helpers.
101
+ */
102
+ query: {
103
+ getFile: (path: string) => FileNode | undefined;
104
+ getSymbol: (name: string) => SymbolNode | undefined;
105
+ getDependencies: (path: string) => string[];
106
+ getDependents: (path: string) => string[];
107
+ findCircularDeps: () => string[][];
108
+ getStats: () => {
109
+ totalFiles: number;
110
+ totalSymbols: number;
111
+ totalEdges: number;
112
+ totalFunctions: number;
113
+ totalLOC: number;
114
+ avgComplexity: number;
115
+ filesByRole: Record<string, number>;
116
+ filesByLayer: Record<string, number>;
117
+ } | null;
118
+ };
119
+ /**
120
+ * Get all registered rules.
121
+ */
122
+ getRules(): Rule[];
123
+ /**
124
+ * Get all installed plugin names.
125
+ */
126
+ getPlugins(): string[];
127
+ };
128
+ /**
129
+ * Define a custom analysis rule.
130
+ *
131
+ * @param rule - Rule definition
132
+ * @returns The same rule (for type-safe chaining)
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const noConsole = defineRule({
137
+ * name: 'custom/no-console',
138
+ * severity: 'warning',
139
+ * description: 'Disallow console.log',
140
+ * category: 'quality',
141
+ * check: (ctx) => {
142
+ * const findings: Finding[] = [];
143
+ * // ... analysis
144
+ * return findings;
145
+ * },
146
+ * });
147
+ * ```
148
+ */
149
+ declare function defineRule(rule: Rule): Rule;
150
+ /**
151
+ * Define a custom plugin.
152
+ *
153
+ * @param plugin - Plugin definition
154
+ * @returns The same plugin (for type-safe chaining)
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * const myPlugin = definePlugin({
159
+ * name: 'my-plugin',
160
+ * version: '1.0.0',
161
+ * install: (kernel) => {
162
+ * kernel.registerRule(myRule);
163
+ * },
164
+ * });
165
+ * ```
166
+ */
167
+ declare function definePlugin<TConfig = unknown>(plugin: GuardianPlugin<TConfig>): GuardianPlugin<TConfig>;
168
+
169
+ export { CodebaseGraph, FileNode, GuardianConfig, GuardianPlugin, IncrementalResult, ProjectConfig, Rule, RunOptions, RunResult, SymbolNode, createGuardian, definePlugin, defineRule };
@@ -0,0 +1,169 @@
1
+ import { G as GuardianConfig, P as ProjectConfig, C as CodebaseGraph, I as IncrementalResult, R as RunOptions, a as RunResult, b as GuardianPlugin, D as DetectedPattern, F as FileNode, S as SymbolNode, c as Rule } from './types-CQZEdzEa.js';
2
+ export { A as ASTVisitors, d as Finding, e as FunctionNode, f as GuardianKernel, g as ImportEdge, h as ImportInfo, i as RuleCategory, j as RuleContext, k as RunStats, l as Severity, m as SeverityConfig } from './types-CQZEdzEa.js';
3
+ import 'typescript';
4
+
5
+ /**
6
+ * Create a Guardian instance for analyzing a TypeScript project.
7
+ *
8
+ * @param config - Guardian configuration
9
+ * @returns Guardian instance with scan, run, use methods
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const guardian = createGuardian({
14
+ * rootDir: process.cwd(),
15
+ * tsconfig: './tsconfig.json',
16
+ * });
17
+ *
18
+ * const graph = await guardian.scan();
19
+ * console.log(`Scanned ${graph.files.size} files`);
20
+ * ```
21
+ */
22
+ declare function createGuardian(config: GuardianConfig): {
23
+ /** The project configuration. */
24
+ config: ProjectConfig;
25
+ /** The codebase knowledge graph (available after scan). */
26
+ readonly graph: CodebaseGraph;
27
+ /**
28
+ * Perform a full codebase scan and build the knowledge graph.
29
+ *
30
+ * @returns The complete codebase graph
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const graph = await guardian.scan();
35
+ * console.log(`${graph.files.size} files, ${graph.symbols.size} symbols`);
36
+ * ```
37
+ */
38
+ scan(): Promise<CodebaseGraph>;
39
+ /**
40
+ * Perform an incremental scan based on git staged files.
41
+ *
42
+ * @returns Incremental result with changed and affected files
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const result = await guardian.scanIncremental();
47
+ * console.log(`Updated ${result.changedFiles.length} files`);
48
+ * ```
49
+ */
50
+ scanIncremental(): Promise<IncrementalResult>;
51
+ /**
52
+ * Run analysis rules on the codebase.
53
+ *
54
+ * @param options - Run options (staged, verbose, plugins, format)
55
+ * @returns Run result with findings, stats, and blocked status
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const result = await guardian.run({ staged: true });
60
+ * if (result.blocked) {
61
+ * console.error('Commit blocked!');
62
+ * process.exit(1);
63
+ * }
64
+ * ```
65
+ */
66
+ run(options?: RunOptions): Promise<RunResult>;
67
+ /**
68
+ * Register a plugin with the guardian.
69
+ *
70
+ * @param plugin - Plugin to register
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * import { definePlugin } from '@oxog/codeguardian';
75
+ * guardian.use(myPlugin);
76
+ * ```
77
+ */
78
+ use<TConfig>(plugin: GuardianPlugin<TConfig>): void;
79
+ /**
80
+ * Auto-discover project conventions.
81
+ *
82
+ * @returns Detected patterns
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const conventions = await guardian.discover();
87
+ * ```
88
+ */
89
+ discover(): Promise<DetectedPattern[]>;
90
+ /**
91
+ * Format run results for output.
92
+ *
93
+ * @param result - Run result
94
+ * @param format - Output format
95
+ * @param verbose - Include info-level findings
96
+ * @returns Formatted string
97
+ */
98
+ format(result: RunResult, format?: "terminal" | "json" | "sarif", verbose?: boolean): string;
99
+ /**
100
+ * Get graph query helpers.
101
+ */
102
+ query: {
103
+ getFile: (path: string) => FileNode | undefined;
104
+ getSymbol: (name: string) => SymbolNode | undefined;
105
+ getDependencies: (path: string) => string[];
106
+ getDependents: (path: string) => string[];
107
+ findCircularDeps: () => string[][];
108
+ getStats: () => {
109
+ totalFiles: number;
110
+ totalSymbols: number;
111
+ totalEdges: number;
112
+ totalFunctions: number;
113
+ totalLOC: number;
114
+ avgComplexity: number;
115
+ filesByRole: Record<string, number>;
116
+ filesByLayer: Record<string, number>;
117
+ } | null;
118
+ };
119
+ /**
120
+ * Get all registered rules.
121
+ */
122
+ getRules(): Rule[];
123
+ /**
124
+ * Get all installed plugin names.
125
+ */
126
+ getPlugins(): string[];
127
+ };
128
+ /**
129
+ * Define a custom analysis rule.
130
+ *
131
+ * @param rule - Rule definition
132
+ * @returns The same rule (for type-safe chaining)
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const noConsole = defineRule({
137
+ * name: 'custom/no-console',
138
+ * severity: 'warning',
139
+ * description: 'Disallow console.log',
140
+ * category: 'quality',
141
+ * check: (ctx) => {
142
+ * const findings: Finding[] = [];
143
+ * // ... analysis
144
+ * return findings;
145
+ * },
146
+ * });
147
+ * ```
148
+ */
149
+ declare function defineRule(rule: Rule): Rule;
150
+ /**
151
+ * Define a custom plugin.
152
+ *
153
+ * @param plugin - Plugin definition
154
+ * @returns The same plugin (for type-safe chaining)
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * const myPlugin = definePlugin({
159
+ * name: 'my-plugin',
160
+ * version: '1.0.0',
161
+ * install: (kernel) => {
162
+ * kernel.registerRule(myRule);
163
+ * },
164
+ * });
165
+ * ```
166
+ */
167
+ declare function definePlugin<TConfig = unknown>(plugin: GuardianPlugin<TConfig>): GuardianPlugin<TConfig>;
168
+
169
+ export { CodebaseGraph, FileNode, GuardianConfig, GuardianPlugin, IncrementalResult, ProjectConfig, Rule, RunOptions, RunResult, SymbolNode, createGuardian, definePlugin, defineRule };