akbo-cli 0.0.0-stage → 1.9.4

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.
Files changed (66) hide show
  1. package/README.md +706 -2
  2. package/dist/catalog_store.d.ts +78 -0
  3. package/dist/catalog_store.js +375 -0
  4. package/dist/cleaner.d.ts +11 -0
  5. package/dist/cleaner.js +92 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.js +1596 -0
  8. package/dist/extractors/base.d.ts +35 -0
  9. package/dist/extractors/base.js +17 -0
  10. package/dist/extractors/custom_extractor.d.ts +55 -0
  11. package/dist/extractors/custom_extractor.js +198 -0
  12. package/dist/extractors/dotnet_extractor.d.ts +11 -0
  13. package/dist/extractors/dotnet_extractor.js +579 -0
  14. package/dist/extractors/golang_extractor.d.ts +11 -0
  15. package/dist/extractors/golang_extractor.js +73 -0
  16. package/dist/extractors/index.d.ts +14 -0
  17. package/dist/extractors/index.js +30 -0
  18. package/dist/extractors/jvm_extractor.d.ts +11 -0
  19. package/dist/extractors/jvm_extractor.js +319 -0
  20. package/dist/extractors/node_extractor.d.ts +11 -0
  21. package/dist/extractors/node_extractor.js +306 -0
  22. package/dist/extractors/proto_graphql_extractor.d.ts +11 -0
  23. package/dist/extractors/proto_graphql_extractor.js +125 -0
  24. package/dist/extractors/python_extractor.d.ts +11 -0
  25. package/dist/extractors/python_extractor.js +298 -0
  26. package/dist/extractors/rust_extractor.d.ts +11 -0
  27. package/dist/extractors/rust_extractor.js +66 -0
  28. package/dist/graph_builder.d.ts +87 -0
  29. package/dist/graph_builder.js +1498 -0
  30. package/dist/harvester.d.ts +38 -0
  31. package/dist/harvester.js +461 -0
  32. package/dist/hook_generator.d.ts +26 -0
  33. package/dist/hook_generator.js +203 -0
  34. package/dist/importers/skill_importer.d.ts +43 -0
  35. package/dist/importers/skill_importer.js +470 -0
  36. package/dist/index.d.ts +17 -0
  37. package/dist/index.js +17 -0
  38. package/dist/indexer.d.ts +19 -0
  39. package/dist/indexer.js +108 -0
  40. package/dist/init_service.d.ts +37 -0
  41. package/dist/init_service.js +246 -0
  42. package/dist/mcp_server.d.ts +10 -0
  43. package/dist/mcp_server.js +632 -0
  44. package/dist/pool_resolver.d.ts +40 -0
  45. package/dist/pool_resolver.js +84 -0
  46. package/dist/provider.d.ts +135 -0
  47. package/dist/provider.js +880 -0
  48. package/dist/query_service.d.ts +33 -0
  49. package/dist/query_service.js +161 -0
  50. package/dist/schema_generator.d.ts +236 -0
  51. package/dist/schema_generator.js +264 -0
  52. package/dist/standards_loader.d.ts +7 -0
  53. package/dist/standards_loader.js +33 -0
  54. package/dist/types.d.ts +265 -0
  55. package/dist/types.js +105 -0
  56. package/dist/unit_synthesizer.d.ts +22 -0
  57. package/dist/unit_synthesizer.js +196 -0
  58. package/dist/validator.d.ts +13 -0
  59. package/dist/validator.js +152 -0
  60. package/dist/version.d.ts +6 -0
  61. package/dist/version.js +16 -0
  62. package/dist/watcher.d.ts +38 -0
  63. package/dist/watcher.js +132 -0
  64. package/package.json +56 -6
  65. package/schemas/index-schema.json +98 -0
  66. package/schemas/knowledge-unit.json +154 -0
@@ -0,0 +1,35 @@
1
+ import type { ManifestSummary, SchemaSummary, RouteOrSignature } from '../types.js';
2
+ /**
3
+ * Universal interface for language and framework AST extractors.
4
+ */
5
+ export interface CodebaseExtractor {
6
+ readonly name: string;
7
+ /**
8
+ * Returns true if this extractor can handle manifests for the given file.
9
+ */
10
+ canExtractManifest?(filePath: string): boolean;
11
+ /**
12
+ * Extracts manifest summaries from the given file and content.
13
+ */
14
+ extractManifest?(filePath: string, content: string): ManifestSummary | ManifestSummary[] | null;
15
+ /**
16
+ * Returns true if this extractor can handle schemas for the given file.
17
+ */
18
+ canExtractSchema?(filePath: string): boolean;
19
+ /**
20
+ * Extracts schema models, tables, or entities from the given file and content.
21
+ */
22
+ extractSchemas?(filePath: string, content: string): SchemaSummary[];
23
+ /**
24
+ * Returns true if this extractor can handle routes/commands/handlers for the given file.
25
+ */
26
+ canExtractRoutes?(filePath: string): boolean;
27
+ /**
28
+ * Extracts routes, commands, handlers, and RPCs from the given file and content.
29
+ */
30
+ extractRoutesAndCommands?(filePath: string, content: string): RouteOrSignature[];
31
+ }
32
+ /**
33
+ * Cleans and normalizes HTTP client target paths across all extractors.
34
+ */
35
+ export declare function cleanClientUrl(rawUrl: string): string;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Cleans and normalizes HTTP client target paths across all extractors.
3
+ */
4
+ export function cleanClientUrl(rawUrl) {
5
+ if (!rawUrl)
6
+ return '';
7
+ let p = rawUrl.trim();
8
+ p = p.replace(/^['"`]|['"`]$/g, '');
9
+ p = p.replace(/^https?:\/\/[^\/]+/, '');
10
+ p = p.split('?')[0];
11
+ p = p.replace(/\$\{[^}]+\}/g, '{param}');
12
+ if (!p.startsWith('/') && !p.startsWith('http'))
13
+ p = `/${p}`;
14
+ if (p.length > 1 && p.endsWith('/'))
15
+ p = p.slice(0, -1);
16
+ return p;
17
+ }
@@ -0,0 +1,55 @@
1
+ import type { CodebaseExtractor } from './base.js';
2
+ import type { SchemaSummary, RouteOrSignature, SchemaType } from '../types.js';
3
+ export interface CustomRuleEndpoint {
4
+ pattern: string;
5
+ filePattern?: string;
6
+ identifierGroup?: number;
7
+ signatureGroup?: number;
8
+ signatureTemplate?: string;
9
+ framework?: string;
10
+ method?: string;
11
+ }
12
+ export interface CustomRuleHandler {
13
+ pattern: string;
14
+ filePattern?: string;
15
+ identifierGroup?: number;
16
+ signatureTemplate?: string;
17
+ framework?: string;
18
+ implementsGroup?: number;
19
+ }
20
+ export interface CustomRuleSchema {
21
+ pattern: string;
22
+ filePattern?: string;
23
+ modelGroup?: number;
24
+ type?: SchemaType;
25
+ }
26
+ export interface CustomRuleCall {
27
+ pattern: string;
28
+ filePattern?: string;
29
+ targetGroup?: number;
30
+ type?: 'CALLS_RPC' | 'CALLS_HTTP' | 'CALLS_GRPC';
31
+ framework?: string;
32
+ method?: string;
33
+ }
34
+ export interface CustomExtractorConfig {
35
+ name?: string;
36
+ filePattern?: string;
37
+ endpoints?: CustomRuleEndpoint[];
38
+ handlers?: CustomRuleHandler[];
39
+ schemas?: CustomRuleSchema[];
40
+ calls?: CustomRuleCall[];
41
+ }
42
+ export declare class CustomRegexExtractor implements CodebaseExtractor {
43
+ readonly name: string;
44
+ private configs;
45
+ constructor(configs: CustomExtractorConfig[] | CustomExtractorConfig, name?: string);
46
+ /**
47
+ * Helper to load custom extractor configuration from a YAML or JSON file.
48
+ */
49
+ static fromFile(configPath: string): CustomRegexExtractor | null;
50
+ private matchesFile;
51
+ canExtractSchema(filePath: string): boolean;
52
+ extractSchemas(filePath: string, content: string): SchemaSummary[];
53
+ canExtractRoutes(filePath: string): boolean;
54
+ extractRoutesAndCommands(filePath: string, content: string): RouteOrSignature[];
55
+ }
@@ -0,0 +1,198 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs';
3
+ import YAML from 'yaml';
4
+ export class CustomRegexExtractor {
5
+ name;
6
+ configs;
7
+ constructor(configs, name = 'custom') {
8
+ this.name = name;
9
+ this.configs = Array.isArray(configs) ? configs : [configs];
10
+ }
11
+ /**
12
+ * Helper to load custom extractor configuration from a YAML or JSON file.
13
+ */
14
+ static fromFile(configPath) {
15
+ try {
16
+ if (!fs.existsSync(configPath))
17
+ return null;
18
+ const raw = fs.readFileSync(configPath, 'utf-8');
19
+ const parsed = configPath.endsWith('.json') ? JSON.parse(raw) : YAML.parse(raw);
20
+ if (!parsed)
21
+ return null;
22
+ let configs = [];
23
+ if (Array.isArray(parsed)) {
24
+ configs = parsed;
25
+ }
26
+ else if (Array.isArray(parsed.extractors)) {
27
+ configs = parsed.extractors;
28
+ }
29
+ else if (parsed.endpoints || parsed.handlers || parsed.schemas || parsed.calls) {
30
+ configs = [parsed];
31
+ }
32
+ if (configs.length === 0)
33
+ return null;
34
+ return new CustomRegexExtractor(configs, path.basename(configPath));
35
+ }
36
+ catch {
37
+ return null;
38
+ }
39
+ }
40
+ matchesFile(filePath, rulePattern, extractorPattern) {
41
+ const pattern = rulePattern || extractorPattern;
42
+ if (!pattern)
43
+ return true;
44
+ try {
45
+ const reg = new RegExp(pattern, 'i');
46
+ return reg.test(filePath) || reg.test(filePath.replace(/\\/g, '/'));
47
+ }
48
+ catch {
49
+ return filePath.includes(pattern);
50
+ }
51
+ }
52
+ canExtractSchema(filePath) {
53
+ return this.configs.some(c => (c.schemas && c.schemas.length > 0) &&
54
+ this.matchesFile(filePath, undefined, c.filePattern));
55
+ }
56
+ extractSchemas(filePath, content) {
57
+ const results = [];
58
+ const normalized = filePath.replace(/\\/g, '/');
59
+ for (const config of this.configs) {
60
+ if (!this.matchesFile(normalized, undefined, config.filePattern))
61
+ continue;
62
+ if (!config.schemas)
63
+ continue;
64
+ for (const rule of config.schemas) {
65
+ if (!this.matchesFile(normalized, rule.filePattern, config.filePattern))
66
+ continue;
67
+ try {
68
+ const reg = new RegExp(rule.pattern, 'gu');
69
+ const matches = Array.from(content.matchAll(reg));
70
+ const models = [];
71
+ for (const m of matches) {
72
+ const idx = rule.modelGroup !== undefined ? rule.modelGroup : 1;
73
+ const modelName = m[idx]?.trim();
74
+ if (modelName)
75
+ models.push(modelName);
76
+ }
77
+ if (models.length > 0) {
78
+ results.push({
79
+ file: normalized,
80
+ type: rule.type || 'sql',
81
+ tablesOrModels: [...new Set(models)]
82
+ });
83
+ }
84
+ }
85
+ catch {
86
+ // Ignore invalid regex
87
+ }
88
+ }
89
+ }
90
+ return results;
91
+ }
92
+ canExtractRoutes(filePath) {
93
+ return this.configs.some(c => ((c.endpoints && c.endpoints.length > 0) ||
94
+ (c.handlers && c.handlers.length > 0) ||
95
+ (c.calls && c.calls.length > 0)) &&
96
+ this.matchesFile(filePath, undefined, c.filePattern));
97
+ }
98
+ extractRoutesAndCommands(filePath, content) {
99
+ const results = [];
100
+ const normalized = filePath.replace(/\\/g, '/');
101
+ for (const config of this.configs) {
102
+ if (!this.matchesFile(normalized, undefined, config.filePattern))
103
+ continue;
104
+ // 1. Endpoints
105
+ if (config.endpoints) {
106
+ for (const rule of config.endpoints) {
107
+ if (!this.matchesFile(normalized, rule.filePattern, config.filePattern))
108
+ continue;
109
+ try {
110
+ const reg = new RegExp(rule.pattern, 'gu');
111
+ for (const m of content.matchAll(reg)) {
112
+ const idIdx = rule.identifierGroup !== undefined ? rule.identifierGroup : 1;
113
+ const identifier = m[idIdx]?.trim();
114
+ if (!identifier)
115
+ continue;
116
+ let signature = identifier;
117
+ if (rule.signatureTemplate) {
118
+ signature = rule.signatureTemplate.replace(/\{(\d+)\}/g, (_, g) => m[parseInt(g, 10)] || '');
119
+ }
120
+ else if (rule.signatureGroup !== undefined && m[rule.signatureGroup]) {
121
+ signature = m[rule.signatureGroup].trim();
122
+ }
123
+ results.push({
124
+ file: normalized,
125
+ framework: rule.framework || 'CustomRpc',
126
+ method: rule.method || 'RPC',
127
+ identifier,
128
+ signature
129
+ });
130
+ }
131
+ }
132
+ catch { }
133
+ }
134
+ }
135
+ // 2. Handlers
136
+ if (config.handlers) {
137
+ for (const rule of config.handlers) {
138
+ if (!this.matchesFile(normalized, rule.filePattern, config.filePattern))
139
+ continue;
140
+ try {
141
+ const reg = new RegExp(rule.pattern, 'gu');
142
+ for (const m of content.matchAll(reg)) {
143
+ const idIdx = rule.identifierGroup !== undefined ? rule.identifierGroup : 1;
144
+ const identifier = m[idIdx]?.trim();
145
+ if (!identifier)
146
+ continue;
147
+ let signature = identifier;
148
+ if (rule.signatureTemplate) {
149
+ signature = rule.signatureTemplate.replace(/\{(\d+)\}/g, (_, g) => m[parseInt(g, 10)] || '');
150
+ }
151
+ let implementsList;
152
+ if (rule.implementsGroup !== undefined && m[rule.implementsGroup]) {
153
+ const rawImplements = m[rule.implementsGroup].trim();
154
+ implementsList = rawImplements
155
+ .split(',')
156
+ .map(s => s.trim().replace(/^class\s+/, '').split(/\s+/)[0])
157
+ .filter(Boolean);
158
+ }
159
+ results.push({
160
+ file: normalized,
161
+ framework: rule.framework || 'CustomHandler',
162
+ identifier,
163
+ signature,
164
+ ...(implementsList && implementsList.length > 0 ? { implements: implementsList } : {})
165
+ });
166
+ }
167
+ }
168
+ catch { }
169
+ }
170
+ }
171
+ // 3. Client calls (e.g. CALLS_RPC, CALLS_HTTP)
172
+ if (config.calls) {
173
+ for (const rule of config.calls) {
174
+ if (!this.matchesFile(normalized, rule.filePattern, config.filePattern))
175
+ continue;
176
+ try {
177
+ const reg = new RegExp(rule.pattern, 'gu');
178
+ for (const m of content.matchAll(reg)) {
179
+ const targetIdx = rule.targetGroup !== undefined ? rule.targetGroup : 1;
180
+ const target = m[targetIdx]?.trim();
181
+ if (!target)
182
+ continue;
183
+ results.push({
184
+ file: normalized,
185
+ framework: rule.framework || (rule.type === 'CALLS_HTTP' ? 'HttpClient' : 'RpcClient'),
186
+ method: rule.method || (rule.type === 'CALLS_HTTP' ? 'GET' : 'RPC_CLIENT'),
187
+ identifier: target,
188
+ signature: target
189
+ });
190
+ }
191
+ }
192
+ catch { }
193
+ }
194
+ }
195
+ }
196
+ return results;
197
+ }
198
+ }
@@ -0,0 +1,11 @@
1
+ import type { CodebaseExtractor } from './base.js';
2
+ import type { ManifestSummary, SchemaSummary, RouteOrSignature } from '../types.js';
3
+ export declare class DotnetExtractor implements CodebaseExtractor {
4
+ readonly name = "dotnet";
5
+ canExtractManifest(filePath: string): boolean;
6
+ extractManifest(filePath: string, content: string): ManifestSummary | null;
7
+ canExtractSchema(filePath: string): boolean;
8
+ extractSchemas(filePath: string, content: string): SchemaSummary[];
9
+ canExtractRoutes(filePath: string): boolean;
10
+ extractRoutesAndCommands(filePath: string, content: string): RouteOrSignature[];
11
+ }