akbo-cli 0.0.0-stage → 2.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.
Files changed (70) hide show
  1. package/README.md +786 -2
  2. package/dist/catalog_store.d.ts +131 -0
  3. package/dist/catalog_store.js +506 -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 +1961 -0
  8. package/dist/dream_engine.d.ts +61 -0
  9. package/dist/dream_engine.js +330 -0
  10. package/dist/extractors/base.d.ts +35 -0
  11. package/dist/extractors/base.js +17 -0
  12. package/dist/extractors/custom_extractor.d.ts +55 -0
  13. package/dist/extractors/custom_extractor.js +198 -0
  14. package/dist/extractors/dotnet_extractor.d.ts +11 -0
  15. package/dist/extractors/dotnet_extractor.js +579 -0
  16. package/dist/extractors/golang_extractor.d.ts +11 -0
  17. package/dist/extractors/golang_extractor.js +73 -0
  18. package/dist/extractors/index.d.ts +14 -0
  19. package/dist/extractors/index.js +30 -0
  20. package/dist/extractors/jvm_extractor.d.ts +11 -0
  21. package/dist/extractors/jvm_extractor.js +319 -0
  22. package/dist/extractors/node_extractor.d.ts +11 -0
  23. package/dist/extractors/node_extractor.js +306 -0
  24. package/dist/extractors/proto_graphql_extractor.d.ts +11 -0
  25. package/dist/extractors/proto_graphql_extractor.js +125 -0
  26. package/dist/extractors/python_extractor.d.ts +11 -0
  27. package/dist/extractors/python_extractor.js +298 -0
  28. package/dist/extractors/rust_extractor.d.ts +11 -0
  29. package/dist/extractors/rust_extractor.js +66 -0
  30. package/dist/graph_builder.d.ts +87 -0
  31. package/dist/graph_builder.js +1516 -0
  32. package/dist/guard_service.d.ts +33 -0
  33. package/dist/guard_service.js +167 -0
  34. package/dist/harvester.d.ts +38 -0
  35. package/dist/harvester.js +461 -0
  36. package/dist/hook_generator.d.ts +34 -0
  37. package/dist/hook_generator.js +269 -0
  38. package/dist/importers/skill_importer.d.ts +43 -0
  39. package/dist/importers/skill_importer.js +470 -0
  40. package/dist/index.d.ts +20 -0
  41. package/dist/index.js +20 -0
  42. package/dist/indexer.d.ts +19 -0
  43. package/dist/indexer.js +108 -0
  44. package/dist/init_service.d.ts +37 -0
  45. package/dist/init_service.js +246 -0
  46. package/dist/mcp_server.d.ts +10 -0
  47. package/dist/mcp_server.js +846 -0
  48. package/dist/pool_resolver.d.ts +40 -0
  49. package/dist/pool_resolver.js +84 -0
  50. package/dist/provider.d.ts +135 -0
  51. package/dist/provider.js +880 -0
  52. package/dist/query_service.d.ts +33 -0
  53. package/dist/query_service.js +161 -0
  54. package/dist/schema_generator.d.ts +236 -0
  55. package/dist/schema_generator.js +264 -0
  56. package/dist/standards_loader.d.ts +7 -0
  57. package/dist/standards_loader.js +33 -0
  58. package/dist/types.d.ts +323 -0
  59. package/dist/types.js +123 -0
  60. package/dist/unit_synthesizer.d.ts +22 -0
  61. package/dist/unit_synthesizer.js +196 -0
  62. package/dist/validator.d.ts +13 -0
  63. package/dist/validator.js +152 -0
  64. package/dist/version.d.ts +6 -0
  65. package/dist/version.js +16 -0
  66. package/dist/watcher.d.ts +38 -0
  67. package/dist/watcher.js +132 -0
  68. package/package.json +56 -6
  69. package/schemas/index-schema.json +98 -0
  70. package/schemas/knowledge-unit.json +154 -0
@@ -0,0 +1,7 @@
1
+ import { type StandardsConfig } from './types.js';
2
+ export declare class StandardsLoader {
3
+ /**
4
+ * Loads and validates .akb/standards.yaml or .akb/standards.json if present.
5
+ */
6
+ static load(repoRoot: string, poolDir?: string): StandardsConfig | null;
7
+ }
@@ -0,0 +1,33 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import YAML from 'yaml';
4
+ import { StandardsConfigSchema } from './types.js';
5
+ export class StandardsLoader {
6
+ /**
7
+ * Loads and validates .akb/standards.yaml or .akb/standards.json if present.
8
+ */
9
+ static load(repoRoot, poolDir) {
10
+ const searchDirs = poolDir && poolDir !== repoRoot ? [poolDir, repoRoot] : [repoRoot];
11
+ const candidatePaths = [];
12
+ for (const dir of searchDirs) {
13
+ candidatePaths.push(path.join(dir, '.akb', 'standards.yaml'), path.join(dir, '.akb', 'standards.yml'), path.join(dir, '.akb', 'standards.json'));
14
+ }
15
+ const configPath = candidatePaths.find(p => fs.existsSync(p));
16
+ if (!configPath)
17
+ return null;
18
+ try {
19
+ const raw = fs.readFileSync(configPath, 'utf-8');
20
+ const parsed = configPath.endsWith('.json') ? JSON.parse(raw) : YAML.parse(raw);
21
+ if (!parsed)
22
+ return null;
23
+ const validated = StandardsConfigSchema.safeParse(parsed);
24
+ if (validated.success) {
25
+ return validated.data;
26
+ }
27
+ return null;
28
+ }
29
+ catch {
30
+ return null;
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,323 @@
1
+ import { z } from 'zod';
2
+ export declare const SchemaTypeEnum: z.ZodEnum<{
3
+ prisma: "prisma";
4
+ sql: "sql";
5
+ rust_db: "rust_db";
6
+ python_models: "python_models";
7
+ typescript_types: "typescript_types";
8
+ drizzle: "drizzle";
9
+ typeorm: "typeorm";
10
+ gorm: "gorm";
11
+ graphql: "graphql";
12
+ efcore: "efcore";
13
+ edmx: "edmx";
14
+ protobuf: "protobuf";
15
+ fluentvalidation: "fluentvalidation";
16
+ dapper: "dapper";
17
+ wcf: "wcf";
18
+ jpa: "jpa";
19
+ sqlalchemy: "sqlalchemy";
20
+ }>;
21
+ export type SchemaType = z.infer<typeof SchemaTypeEnum>;
22
+ export interface ManifestSummary {
23
+ path: string;
24
+ type: 'npm' | 'cargo' | 'python' | 'go' | 'docker' | 'config' | 'dotnet' | 'maven' | 'gradle' | 'unknown';
25
+ contentSummary: Record<string, any>;
26
+ }
27
+ export interface RouteOrSignature {
28
+ file: string;
29
+ framework?: string;
30
+ method?: string;
31
+ identifier: string;
32
+ signature: string;
33
+ implements?: string[];
34
+ }
35
+ export interface SchemaSummary {
36
+ file: string;
37
+ type: SchemaType;
38
+ tablesOrModels: string[];
39
+ }
40
+ export interface TopologySummary {
41
+ totalFiles: number;
42
+ topLevelDirectories: string[];
43
+ keyDirectories: Record<string, string[]>;
44
+ entryPoints: string[];
45
+ }
46
+ export interface RepositorySkeleton {
47
+ timestamp: string;
48
+ repoPath: string;
49
+ topology: TopologySummary;
50
+ manifests: ManifestSummary[];
51
+ schemas: SchemaSummary[];
52
+ routesAndCommands: RouteOrSignature[];
53
+ scriptsAndWorkflows: {
54
+ packageScripts?: Record<string, string>;
55
+ githubWorkflows?: string[];
56
+ dockerServices?: string[];
57
+ };
58
+ }
59
+ export interface ProposedKnowledgeUnit {
60
+ id: string;
61
+ domain: 'architecture' | 'development' | 'product' | 'decisions' | 'security' | 'production' | string;
62
+ file: string;
63
+ title: string;
64
+ purpose: string;
65
+ targetFilesOrPatterns: string[];
66
+ }
67
+ export interface ProposedIndex {
68
+ system_name: string;
69
+ description: string;
70
+ domains: Record<string, ProposedKnowledgeUnit[]>;
71
+ }
72
+ export declare const AuthoritySchema: z.ZodDefault<z.ZodObject<{
73
+ level: z.ZodOptional<z.ZodDefault<z.ZodString>>;
74
+ confidence: z.ZodOptional<z.ZodDefault<z.ZodString>>;
75
+ }, z.core.$strip>>;
76
+ export declare const OwnerSchema: z.ZodDefault<z.ZodObject<{
77
+ team: z.ZodOptional<z.ZodDefault<z.ZodString>>;
78
+ }, z.core.$strip>>;
79
+ export declare const StandardKnowledgeUnitSchema: z.ZodObject<{
80
+ id: z.ZodString;
81
+ type: z.ZodUnion<[z.ZodEnum<{
82
+ architecture_standard: "architecture_standard";
83
+ development_standard: "development_standard";
84
+ product_rule: "product_rule";
85
+ security_standard: "security_standard";
86
+ }>, z.ZodString]>;
87
+ title: z.ZodString;
88
+ domain: z.ZodString;
89
+ status: z.ZodDefault<z.ZodEnum<{
90
+ approved: "approved";
91
+ draft: "draft";
92
+ deprecated: "deprecated";
93
+ accepted: "accepted";
94
+ proposed: "proposed";
95
+ locked: "locked";
96
+ }>>;
97
+ version: z.ZodDefault<z.ZodString>;
98
+ authority: z.ZodOptional<z.ZodDefault<z.ZodObject<{
99
+ level: z.ZodOptional<z.ZodDefault<z.ZodString>>;
100
+ confidence: z.ZodOptional<z.ZodDefault<z.ZodString>>;
101
+ }, z.core.$strip>>>;
102
+ owner: z.ZodOptional<z.ZodDefault<z.ZodObject<{
103
+ team: z.ZodOptional<z.ZodDefault<z.ZodString>>;
104
+ }, z.core.$strip>>>;
105
+ applies_to: z.ZodDefault<z.ZodArray<z.ZodString>>;
106
+ rule: z.ZodString;
107
+ do: z.ZodArray<z.ZodString>;
108
+ dont: z.ZodArray<z.ZodString>;
109
+ reason: z.ZodString;
110
+ related_items: z.ZodDefault<z.ZodArray<z.ZodString>>;
111
+ skill_file: z.ZodOptional<z.ZodString>;
112
+ reference_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
113
+ workflow_gates: z.ZodOptional<z.ZodArray<z.ZodString>>;
114
+ supersedes: z.ZodOptional<z.ZodString>;
115
+ superseded_by: z.ZodOptional<z.ZodString>;
116
+ valid_from: z.ZodOptional<z.ZodString>;
117
+ deprecated_since: z.ZodOptional<z.ZodString>;
118
+ lifecycle: z.ZodOptional<z.ZodObject<{
119
+ status: z.ZodOptional<z.ZodOptional<z.ZodString>>;
120
+ migration_target: z.ZodOptional<z.ZodOptional<z.ZodString>>;
121
+ notes: z.ZodOptional<z.ZodOptional<z.ZodString>>;
122
+ }, z.core.$strip>>;
123
+ }, z.core.$strip>;
124
+ export declare const DecisionKnowledgeUnitSchema: z.ZodObject<{
125
+ id: z.ZodString;
126
+ type: z.ZodUnion<[z.ZodLiteral<"architecture_decision">, z.ZodString]>;
127
+ title: z.ZodString;
128
+ domain: z.ZodDefault<z.ZodString>;
129
+ decision: z.ZodString;
130
+ context: z.ZodOptional<z.ZodString>;
131
+ status: z.ZodOptional<z.ZodEnum<{
132
+ approved: "approved";
133
+ draft: "draft";
134
+ deprecated: "deprecated";
135
+ accepted: "accepted";
136
+ proposed: "proposed";
137
+ locked: "locked";
138
+ }>>;
139
+ version: z.ZodOptional<z.ZodString>;
140
+ authority: z.ZodOptional<z.ZodDefault<z.ZodObject<{
141
+ level: z.ZodOptional<z.ZodDefault<z.ZodString>>;
142
+ confidence: z.ZodOptional<z.ZodDefault<z.ZodString>>;
143
+ }, z.core.$strip>>>;
144
+ owner: z.ZodOptional<z.ZodDefault<z.ZodObject<{
145
+ team: z.ZodOptional<z.ZodDefault<z.ZodString>>;
146
+ }, z.core.$strip>>>;
147
+ applies_to: z.ZodOptional<z.ZodArray<z.ZodString>>;
148
+ related_items: z.ZodDefault<z.ZodArray<z.ZodString>>;
149
+ skill_file: z.ZodOptional<z.ZodString>;
150
+ reference_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
151
+ workflow_gates: z.ZodOptional<z.ZodArray<z.ZodString>>;
152
+ supersedes: z.ZodOptional<z.ZodString>;
153
+ superseded_by: z.ZodOptional<z.ZodString>;
154
+ valid_from: z.ZodOptional<z.ZodString>;
155
+ deprecated_since: z.ZodOptional<z.ZodString>;
156
+ lifecycle: z.ZodOptional<z.ZodObject<{
157
+ status: z.ZodOptional<z.ZodOptional<z.ZodString>>;
158
+ migration_target: z.ZodOptional<z.ZodOptional<z.ZodString>>;
159
+ notes: z.ZodOptional<z.ZodOptional<z.ZodString>>;
160
+ }, z.core.$strip>>;
161
+ }, z.core.$strip>;
162
+ export declare const MasterIndexEntrySchema: z.ZodObject<{
163
+ id: z.ZodString;
164
+ file: z.ZodString;
165
+ title: z.ZodString;
166
+ purpose: z.ZodOptional<z.ZodString>;
167
+ }, z.core.$strip>;
168
+ export declare const DomainCatalogReferenceSchema: z.ZodObject<{
169
+ id: z.ZodString;
170
+ name: z.ZodOptional<z.ZodString>;
171
+ description: z.ZodOptional<z.ZodString>;
172
+ catalog: z.ZodString;
173
+ applies_to: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString>, z.ZodString]>>;
174
+ }, z.core.$strip>;
175
+ export declare const MasterIndexSchema: z.ZodObject<{
176
+ system_name: z.ZodString;
177
+ repository_root: z.ZodOptional<z.ZodString>;
178
+ description: z.ZodOptional<z.ZodString>;
179
+ knowledge_units_count: z.ZodOptional<z.ZodNumber>;
180
+ last_updated: z.ZodOptional<z.ZodString>;
181
+ knowledge_units: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
182
+ id: z.ZodString;
183
+ file: z.ZodString;
184
+ title: z.ZodString;
185
+ purpose: z.ZodOptional<z.ZodString>;
186
+ }, z.core.$strip>>>>>;
187
+ domains: z.ZodOptional<z.ZodArray<z.ZodObject<{
188
+ id: z.ZodString;
189
+ name: z.ZodOptional<z.ZodString>;
190
+ description: z.ZodOptional<z.ZodString>;
191
+ catalog: z.ZodString;
192
+ applies_to: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString>, z.ZodString]>>;
193
+ }, z.core.$strip>>>;
194
+ }, z.core.$strip>;
195
+ export type StandardKnowledgeUnit = z.infer<typeof StandardKnowledgeUnitSchema>;
196
+ export type DecisionKnowledgeUnit = z.infer<typeof DecisionKnowledgeUnitSchema>;
197
+ export type MasterIndex = z.infer<typeof MasterIndexSchema>;
198
+ export type MasterIndexEntry = z.infer<typeof MasterIndexEntrySchema>;
199
+ export type DomainCatalogReference = z.infer<typeof DomainCatalogReferenceSchema>;
200
+ export interface KnowledgeUnitContent {
201
+ id: string;
202
+ type: 'architecture_standard' | 'development_standard' | 'product_rule' | 'architecture_decision' | 'security_standard' | string;
203
+ title: string;
204
+ domain: string;
205
+ status: 'approved' | 'draft' | 'deprecated' | 'accepted' | 'proposed' | 'locked' | string;
206
+ version: string;
207
+ authority?: {
208
+ level?: 'official' | 'guideline' | 'experimental' | 'human_curated' | string;
209
+ confidence?: 'high' | 'medium' | 'low' | 'verified' | string;
210
+ };
211
+ owner?: {
212
+ team?: string;
213
+ };
214
+ applies_to: string[];
215
+ rule: string;
216
+ do: string[];
217
+ dont: string[];
218
+ reason: string;
219
+ related_items: string[];
220
+ skill_file?: string;
221
+ reference_files?: string[];
222
+ workflow_gates?: string[];
223
+ supersedes?: string;
224
+ superseded_by?: string;
225
+ valid_from?: string;
226
+ deprecated_since?: string;
227
+ lifecycle?: {
228
+ status?: string;
229
+ migration_target?: string;
230
+ notes?: string;
231
+ };
232
+ }
233
+ export interface AgentObservation {
234
+ id: string;
235
+ timestamp: string;
236
+ agentId?: string;
237
+ topic: string;
238
+ finding: string;
239
+ reproducible_fix?: string;
240
+ associated_files: string[];
241
+ status?: 'recorded' | 'consolidated' | 'discarded';
242
+ }
243
+ export interface SessionScratchpad {
244
+ agentId: string;
245
+ lastUpdated: string;
246
+ content: string;
247
+ }
248
+ export interface StagedKnowledgeUnitProposal {
249
+ id: string;
250
+ targetUnitId?: string;
251
+ domain: string;
252
+ action: 'create' | 'append_rules' | 'deprecate' | 'record_decision';
253
+ title?: string;
254
+ proposed_rule?: string;
255
+ proposed_do?: string[];
256
+ proposed_dont?: string[];
257
+ proposed_decision?: string;
258
+ reason: string;
259
+ origin_observations?: string[];
260
+ agent_id?: string;
261
+ timestamp: string;
262
+ status: 'staged' | 'approved' | 'rejected';
263
+ }
264
+ export type GraphNodeType = 'domain' | 'project' | 'endpoint' | 'message' | 'handler' | 'schema' | 'invariant';
265
+ export type GraphEdgeType = 'CONTAINS' | 'EXPOSES' | 'DISPATCHES' | 'HANDLES' | 'PERSISTS' | 'DEPENDS_ON' | 'CONSTRAINS' | 'RELATES_TO' | 'VALIDATES' | 'CONSUMES_EVENT' | 'CALLS_HTTP' | 'CALLS_GRPC' | 'CALLS_RPC' | 'IMPLEMENTS' | 'SUPERSEDES';
266
+ export interface GraphNode {
267
+ id: string;
268
+ type: GraphNodeType;
269
+ label: string;
270
+ file?: string;
271
+ domain?: string;
272
+ metadata?: Record<string, any>;
273
+ }
274
+ export interface GraphEdge {
275
+ source: string;
276
+ target: string;
277
+ type: GraphEdgeType;
278
+ metadata?: Record<string, any>;
279
+ }
280
+ export interface CodebaseKnowledgeGraph {
281
+ timestamp: string;
282
+ repoPath: string;
283
+ nodes: GraphNode[];
284
+ edges: GraphEdge[];
285
+ }
286
+ export interface GraphNeighborhood {
287
+ centerNode: GraphNode;
288
+ nodes: GraphNode[];
289
+ edges: GraphEdge[];
290
+ formattedContext: string;
291
+ activeInvariants?: KnowledgeUnitContent[];
292
+ deprecationWarnings?: string[];
293
+ }
294
+ export declare const CodeStandardPatternSchema: z.ZodObject<{
295
+ pattern: z.ZodString;
296
+ description: z.ZodOptional<z.ZodString>;
297
+ reason: z.ZodOptional<z.ZodString>;
298
+ appliesTo: z.ZodOptional<z.ZodString>;
299
+ deprecated: z.ZodOptional<z.ZodBoolean>;
300
+ migrationTarget: z.ZodOptional<z.ZodString>;
301
+ }, z.core.$strip>;
302
+ export type CodeStandardPattern = z.infer<typeof CodeStandardPatternSchema>;
303
+ export declare const StandardsConfigSchema: z.ZodObject<{
304
+ standards: z.ZodDefault<z.ZodObject<{
305
+ target_patterns: z.ZodDefault<z.ZodArray<z.ZodObject<{
306
+ pattern: z.ZodString;
307
+ description: z.ZodOptional<z.ZodString>;
308
+ reason: z.ZodOptional<z.ZodString>;
309
+ appliesTo: z.ZodOptional<z.ZodString>;
310
+ deprecated: z.ZodOptional<z.ZodBoolean>;
311
+ migrationTarget: z.ZodOptional<z.ZodString>;
312
+ }, z.core.$strip>>>;
313
+ deprecated_patterns: z.ZodDefault<z.ZodArray<z.ZodObject<{
314
+ pattern: z.ZodString;
315
+ description: z.ZodOptional<z.ZodString>;
316
+ reason: z.ZodOptional<z.ZodString>;
317
+ appliesTo: z.ZodOptional<z.ZodString>;
318
+ deprecated: z.ZodOptional<z.ZodBoolean>;
319
+ migrationTarget: z.ZodOptional<z.ZodString>;
320
+ }, z.core.$strip>>>;
321
+ }, z.core.$strip>>;
322
+ }, z.core.$strip>;
323
+ export type StandardsConfig = z.infer<typeof StandardsConfigSchema>;
package/dist/types.js ADDED
@@ -0,0 +1,123 @@
1
+ import { z } from 'zod';
2
+ export const SchemaTypeEnum = z.enum([
3
+ 'prisma',
4
+ 'sql',
5
+ 'rust_db',
6
+ 'python_models',
7
+ 'typescript_types',
8
+ 'drizzle',
9
+ 'typeorm',
10
+ 'gorm',
11
+ 'graphql',
12
+ 'efcore',
13
+ 'edmx',
14
+ 'protobuf',
15
+ 'fluentvalidation',
16
+ 'dapper',
17
+ 'wcf',
18
+ 'jpa',
19
+ 'sqlalchemy'
20
+ ]);
21
+ // Zod Schemas for Runtime Validation
22
+ export const AuthoritySchema = z.object({
23
+ level: z.string().default('official'),
24
+ confidence: z.string().default('high')
25
+ }).partial().default({});
26
+ export const OwnerSchema = z.object({
27
+ team: z.string().default('core_architecture')
28
+ }).partial().default({});
29
+ export const StandardKnowledgeUnitSchema = z.object({
30
+ id: z.string().min(1, 'Missing required field "id"'),
31
+ type: z.enum([
32
+ 'architecture_standard',
33
+ 'development_standard',
34
+ 'product_rule',
35
+ 'security_standard'
36
+ ]).or(z.string()),
37
+ title: z.string().min(1, 'Missing required field "title"'),
38
+ domain: z.string().min(1, 'Missing required field "domain"'),
39
+ status: z.enum(['approved', 'draft', 'deprecated', 'accepted', 'proposed', 'locked']).default('approved'),
40
+ version: z.string().default('1.0.0'),
41
+ authority: AuthoritySchema.optional(),
42
+ owner: OwnerSchema.optional(),
43
+ applies_to: z.array(z.string()).default([]),
44
+ rule: z.string().min(1, 'Missing required field "rule"'),
45
+ do: z.array(z.string()).min(1, '"do" list must contain at least one item'),
46
+ dont: z.array(z.string()).min(1, '"dont" list must contain at least one item'),
47
+ reason: z.string().min(1, 'Missing required field "reason"'),
48
+ related_items: z.array(z.string()).default([]),
49
+ skill_file: z.string().optional(),
50
+ reference_files: z.array(z.string()).optional(),
51
+ workflow_gates: z.array(z.string()).optional(),
52
+ supersedes: z.string().optional(),
53
+ superseded_by: z.string().optional(),
54
+ valid_from: z.string().optional(),
55
+ deprecated_since: z.string().optional(),
56
+ lifecycle: z.object({
57
+ status: z.string().optional(),
58
+ migration_target: z.string().optional(),
59
+ notes: z.string().optional()
60
+ }).partial().optional()
61
+ });
62
+ export const DecisionKnowledgeUnitSchema = z.object({
63
+ id: z.string().min(1, 'Missing required field "id"'),
64
+ type: z.literal('architecture_decision').or(z.string()),
65
+ title: z.string().min(1, 'Missing required field "title"'),
66
+ domain: z.string().default('decisions'),
67
+ decision: z.string().min(1, 'Decision missing required field "decision"'),
68
+ context: z.string().optional(),
69
+ status: z.enum(['approved', 'draft', 'deprecated', 'proposed', 'accepted', 'locked']).optional(),
70
+ version: z.string().optional(),
71
+ authority: AuthoritySchema.optional(),
72
+ owner: OwnerSchema.optional(),
73
+ applies_to: z.array(z.string()).optional(),
74
+ related_items: z.array(z.string()).default([]),
75
+ skill_file: z.string().optional(),
76
+ reference_files: z.array(z.string()).optional(),
77
+ workflow_gates: z.array(z.string()).optional(),
78
+ supersedes: z.string().optional(),
79
+ superseded_by: z.string().optional(),
80
+ valid_from: z.string().optional(),
81
+ deprecated_since: z.string().optional(),
82
+ lifecycle: z.object({
83
+ status: z.string().optional(),
84
+ migration_target: z.string().optional(),
85
+ notes: z.string().optional()
86
+ }).partial().optional()
87
+ });
88
+ export const MasterIndexEntrySchema = z.object({
89
+ id: z.string().min(1, 'Master index entry missing "id"'),
90
+ file: z.string().min(1, 'Master index entry missing "file"'),
91
+ title: z.string().min(1, 'Master index entry missing "title"'),
92
+ purpose: z.string().optional()
93
+ });
94
+ export const DomainCatalogReferenceSchema = z.object({
95
+ id: z.string().min(1, 'Domain catalog entry missing "id"'),
96
+ name: z.string().optional(),
97
+ description: z.string().optional(),
98
+ catalog: z.string().min(1, 'Domain catalog entry missing "catalog" path'),
99
+ applies_to: z.array(z.string()).or(z.string()).optional()
100
+ });
101
+ export const MasterIndexSchema = z.object({
102
+ system_name: z.string().min(1, 'Master index missing "system_name"'),
103
+ repository_root: z.string().optional(),
104
+ description: z.string().optional(),
105
+ knowledge_units_count: z.number().optional(),
106
+ last_updated: z.string().optional(),
107
+ knowledge_units: z.record(z.string(), z.array(MasterIndexEntrySchema)).optional().default({}),
108
+ domains: z.array(DomainCatalogReferenceSchema).optional()
109
+ });
110
+ export const CodeStandardPatternSchema = z.object({
111
+ pattern: z.string().min(1),
112
+ description: z.string().optional(),
113
+ reason: z.string().optional(),
114
+ appliesTo: z.string().optional(),
115
+ deprecated: z.boolean().optional(),
116
+ migrationTarget: z.string().optional()
117
+ });
118
+ export const StandardsConfigSchema = z.object({
119
+ standards: z.object({
120
+ target_patterns: z.array(CodeStandardPatternSchema).default([]),
121
+ deprecated_patterns: z.array(CodeStandardPatternSchema).default([])
122
+ }).default({ target_patterns: [], deprecated_patterns: [] })
123
+ });
@@ -0,0 +1,22 @@
1
+ import type { ProposedKnowledgeUnit, KnowledgeUnitContent } from './types.js';
2
+ import { type LLMProvider } from './provider.js';
3
+ export declare class UnitSynthesizer {
4
+ private provider;
5
+ client?: any;
6
+ private modelName;
7
+ private repoRoot;
8
+ private poolDir?;
9
+ private initialRetryDelay;
10
+ constructor(repoRoot: string, apiKeyOrProvider?: string | LLMProvider, modelName?: string, initialRetryDelay?: number, options?: {
11
+ forceCli?: boolean;
12
+ provider?: string;
13
+ baseUrl?: string;
14
+ apiKey?: string;
15
+ poolDir?: string;
16
+ });
17
+ get providerName(): string;
18
+ synthesizeUnit(unit: ProposedKnowledgeUnit): Promise<KnowledgeUnitContent>;
19
+ getFileRecencyScore(relPath: string): number;
20
+ private readTargetFiles;
21
+ private buildPrompt;
22
+ }