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,152 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import YAML from 'yaml';
4
+ import { globby } from 'globby';
5
+ import { MasterIndexSchema, StandardKnowledgeUnitSchema, DecisionKnowledgeUnitSchema } from './types.js';
6
+ import { KnowledgePoolResolver } from './pool_resolver.js';
7
+ export class KnowledgeValidator {
8
+ repoRoot;
9
+ poolConfig;
10
+ constructor(repoRoot, poolDir) {
11
+ this.repoRoot = path.resolve(repoRoot);
12
+ this.poolConfig = KnowledgePoolResolver.resolve(this.repoRoot, { explicitPoolDir: poolDir });
13
+ }
14
+ async validate() {
15
+ const errors = [];
16
+ const warnings = [];
17
+ const indexPath = path.join(this.poolConfig.knowledgeDir, 'index.yaml');
18
+ if (!fs.existsSync(indexPath)) {
19
+ return {
20
+ valid: false,
21
+ errors: [`Missing master index at ${indexPath}`],
22
+ warnings: [],
23
+ unitCount: 0
24
+ };
25
+ }
26
+ let indexData;
27
+ try {
28
+ indexData = YAML.parse(fs.readFileSync(indexPath, 'utf-8'));
29
+ }
30
+ catch (err) {
31
+ return {
32
+ valid: false,
33
+ errors: [`Syntax error in knowledge/index.yaml: ${err}`],
34
+ warnings: [],
35
+ unitCount: 0
36
+ };
37
+ }
38
+ // Runtime Zod schema validation for master index
39
+ const parsedIndex = MasterIndexSchema.safeParse(indexData);
40
+ if (!parsedIndex.success) {
41
+ for (const issue of parsedIndex.error.issues) {
42
+ const pathStr = issue.path.length > 0 ? ` [${issue.path.join('.')}]` : '';
43
+ errors.push(`knowledge/index.yaml:${pathStr} ${issue.message}`);
44
+ }
45
+ }
46
+ // Scan all unit files, excluding index.yaml and domain catalog index.yaml files
47
+ const unitFiles = await globby(['knowledge/**/*.yaml', '!knowledge/index.yaml', '!knowledge/**/index.yaml'], {
48
+ cwd: this.poolConfig.poolDir,
49
+ onlyFiles: true
50
+ });
51
+ const definedIds = new Set();
52
+ for (const relFile of unitFiles) {
53
+ const fullPath = path.join(this.poolConfig.poolDir, relFile);
54
+ let content;
55
+ try {
56
+ content = YAML.parse(fs.readFileSync(fullPath, 'utf-8'));
57
+ }
58
+ catch (err) {
59
+ errors.push(`${relFile}: Invalid YAML syntax (${err})`);
60
+ continue;
61
+ }
62
+ if (typeof content !== 'object' || content === null) {
63
+ errors.push(`${relFile}: Knowledge unit content must be a valid YAML mapping object`);
64
+ continue;
65
+ }
66
+ const rawUnit = content;
67
+ const isDecision = rawUnit.type === 'architecture_decision' || relFile.includes('decisions/');
68
+ if (isDecision) {
69
+ const parsedDecision = DecisionKnowledgeUnitSchema.safeParse(rawUnit);
70
+ if (!parsedDecision.success) {
71
+ for (const issue of parsedDecision.error.issues) {
72
+ const pathStr = issue.path.length > 0 ? ` [${issue.path.join('.')}]` : '';
73
+ errors.push(`${relFile}:${pathStr} ${issue.message}`);
74
+ }
75
+ }
76
+ else {
77
+ definedIds.add(parsedDecision.data.id);
78
+ if (!parsedDecision.data.context) {
79
+ warnings.push(`${relFile}: Decision missing recommended field 'context'`);
80
+ }
81
+ }
82
+ }
83
+ else {
84
+ const parsedUnit = StandardKnowledgeUnitSchema.safeParse(rawUnit);
85
+ if (!parsedUnit.success) {
86
+ for (const issue of parsedUnit.error.issues) {
87
+ const pathStr = issue.path.length > 0 ? ` [${issue.path.join('.')}]` : '';
88
+ errors.push(`${relFile}:${pathStr} ${issue.message}`);
89
+ }
90
+ }
91
+ else {
92
+ definedIds.add(parsedUnit.data.id);
93
+ }
94
+ }
95
+ }
96
+ // Verify index references against physical files
97
+ if (parsedIndex.success) {
98
+ // 1. Check flat knowledge_units
99
+ const knowledgeUnits = parsedIndex.data.knowledge_units || {};
100
+ for (const [, list] of Object.entries(knowledgeUnits)) {
101
+ if (Array.isArray(list)) {
102
+ for (const item of list) {
103
+ if (item.file && !fs.existsSync(path.join(this.poolConfig.poolDir, item.file))) {
104
+ errors.push(`index.yaml references non-existent file: ${item.file}`);
105
+ }
106
+ }
107
+ }
108
+ }
109
+ // 2. Check Namespaced Central Hub domain sub-catalogs
110
+ if (parsedIndex.data.domains && Array.isArray(parsedIndex.data.domains)) {
111
+ for (const domainRef of parsedIndex.data.domains) {
112
+ const catalogPath = path.join(this.poolConfig.poolDir, domainRef.catalog);
113
+ if (!fs.existsSync(catalogPath)) {
114
+ errors.push(`index.yaml references non-existent domain catalog: ${domainRef.catalog}`);
115
+ }
116
+ else {
117
+ try {
118
+ const subData = YAML.parse(fs.readFileSync(catalogPath, 'utf-8'));
119
+ const parsedSub = MasterIndexSchema.safeParse(subData);
120
+ if (!parsedSub.success) {
121
+ for (const issue of parsedSub.error.issues) {
122
+ const pathStr = issue.path.length > 0 ? ` [${issue.path.join('.')}]` : '';
123
+ errors.push(`${domainRef.catalog}:${pathStr} ${issue.message}`);
124
+ }
125
+ }
126
+ else {
127
+ for (const [, list] of Object.entries(parsedSub.data.knowledge_units || {})) {
128
+ if (Array.isArray(list)) {
129
+ for (const item of list) {
130
+ if (item.file && !fs.existsSync(path.join(this.poolConfig.poolDir, item.file))) {
131
+ errors.push(`${domainRef.catalog} references non-existent file: ${item.file}`);
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ catch (err) {
139
+ errors.push(`Syntax error in domain catalog ${domainRef.catalog}: ${err}`);
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+ return {
146
+ valid: errors.length === 0,
147
+ errors,
148
+ warnings,
149
+ unitCount: unitFiles.length
150
+ };
151
+ }
152
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the current semantic version of akbo-cli.
3
+ * Dynamically resolves from package.json with a fallback to the build-time constant.
4
+ */
5
+ export declare function getVersion(): string;
6
+ export declare const VERSION: string;
@@ -0,0 +1,16 @@
1
+ import fs from 'node:fs';
2
+ /**
3
+ * Returns the current semantic version of akbo-cli.
4
+ * Dynamically resolves from package.json with a fallback to the build-time constant.
5
+ */
6
+ export function getVersion() {
7
+ try {
8
+ const pkgPath = new URL('../package.json', import.meta.url);
9
+ const content = fs.readFileSync(pkgPath, 'utf-8');
10
+ return JSON.parse(content).version || '1.9.4';
11
+ }
12
+ catch {
13
+ return '1.9.4';
14
+ }
15
+ }
16
+ export const VERSION = getVersion();
@@ -0,0 +1,38 @@
1
+ import type { CodebaseKnowledgeGraph } from './types.js';
2
+ export interface WatchOptions {
3
+ dir?: string;
4
+ out?: string;
5
+ format?: 'json' | 'mermaid' | 'markdown';
6
+ clustered?: boolean;
7
+ maxNodes?: number;
8
+ nodeTypes?: string[] | string;
9
+ debounceMs?: number;
10
+ onUpdate?: (event: {
11
+ timestamp: string;
12
+ nodesCount: number;
13
+ edgesCount: number;
14
+ outPath?: string;
15
+ durationMs: number;
16
+ }) => void;
17
+ }
18
+ export declare class CodebaseWatcher {
19
+ private repoRoot;
20
+ private poolDir?;
21
+ private isWatching;
22
+ private watcher;
23
+ private debounceTimer;
24
+ constructor(repoRoot?: string, poolDir?: string);
25
+ /**
26
+ * Re-builds and writes the graph snapshot once.
27
+ */
28
+ rebuildGraph(options?: WatchOptions): Promise<{
29
+ graph: CodebaseKnowledgeGraph;
30
+ outPath?: string;
31
+ durationMs: number;
32
+ }>;
33
+ /**
34
+ * Starts watching the target directory for file updates and automatically re-renders the CKG.
35
+ */
36
+ start(options?: WatchOptions): Promise<void>;
37
+ stop(): void;
38
+ }
@@ -0,0 +1,132 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs';
3
+ import { Harvester } from './harvester.js';
4
+ import { GraphBuilder } from './graph_builder.js';
5
+ export class CodebaseWatcher {
6
+ repoRoot;
7
+ poolDir;
8
+ isWatching = false;
9
+ watcher = null;
10
+ debounceTimer = null;
11
+ constructor(repoRoot = process.cwd(), poolDir) {
12
+ this.repoRoot = path.resolve(repoRoot).replace(/\\/g, '/');
13
+ this.poolDir = poolDir;
14
+ }
15
+ /**
16
+ * Re-builds and writes the graph snapshot once.
17
+ */
18
+ async rebuildGraph(options = {}) {
19
+ const startTime = Date.now();
20
+ const targetDir = path.resolve(options.dir || this.repoRoot);
21
+ const harvester = new Harvester(targetDir, undefined, this.poolDir);
22
+ const skeleton = await harvester.harvest({ useCache: true });
23
+ const graphBuilder = new GraphBuilder(targetDir, this.poolDir);
24
+ const graph = await graphBuilder.buildGraph(skeleton, undefined, { useCache: true });
25
+ const clustered = options.clustered !== false;
26
+ const format = options.format || 'json';
27
+ let outPath;
28
+ if (options.out) {
29
+ outPath = path.isAbsolute(options.out)
30
+ ? options.out
31
+ : path.resolve(targetDir, options.out);
32
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
33
+ if (format === 'mermaid') {
34
+ const mermaid = graphBuilder.exportMermaid(graph, {
35
+ clustered,
36
+ maxNodes: options.maxNodes,
37
+ nodeTypes: options.nodeTypes
38
+ });
39
+ fs.writeFileSync(outPath, mermaid, 'utf-8');
40
+ }
41
+ else if (format === 'markdown') {
42
+ let md = `# Codebase Knowledge Graph\n\n`;
43
+ md += `Total Entities: ${graph.nodes.length} | Relationships: ${graph.edges.length}\n\n`;
44
+ md += `\`\`\`mermaid\n${graphBuilder.exportMermaid(graph, {
45
+ clustered,
46
+ maxNodes: options.maxNodes,
47
+ nodeTypes: options.nodeTypes
48
+ })}\n\`\`\`\n\n`;
49
+ md += `## Entities\n| ID | Type | Label | File |\n| :--- | :--- | :--- | :--- |\n`;
50
+ for (const n of graph.nodes) {
51
+ md += `| \`${n.id}\` | ${n.type} | ${n.label} | ${n.file || '-'} |\n`;
52
+ }
53
+ fs.writeFileSync(outPath, md, 'utf-8');
54
+ }
55
+ else {
56
+ fs.writeFileSync(outPath, JSON.stringify(graph, null, 2), 'utf-8');
57
+ }
58
+ }
59
+ const durationMs = Date.now() - startTime;
60
+ return { graph, outPath, durationMs };
61
+ }
62
+ /**
63
+ * Starts watching the target directory for file updates and automatically re-renders the CKG.
64
+ */
65
+ async start(options = {}) {
66
+ const targetDir = path.resolve(options.dir || this.repoRoot);
67
+ const debounceMs = options.debounceMs || 500;
68
+ // Initial build
69
+ const initial = await this.rebuildGraph(options);
70
+ if (options.onUpdate) {
71
+ options.onUpdate({
72
+ timestamp: new Date().toISOString(),
73
+ nodesCount: initial.graph.nodes.length,
74
+ edgesCount: initial.graph.edges.length,
75
+ outPath: initial.outPath,
76
+ durationMs: initial.durationMs
77
+ });
78
+ }
79
+ this.isWatching = true;
80
+ try {
81
+ this.watcher = fs.watch(targetDir, { recursive: true }, (_eventType, filename) => {
82
+ if (!this.isWatching)
83
+ return;
84
+ if (!filename)
85
+ return;
86
+ // Skip ignored directories & dotfiles
87
+ const norm = filename.replace(/\\/g, '/');
88
+ if (norm.startsWith('.git') ||
89
+ norm.startsWith('node_modules') ||
90
+ norm.startsWith('dist') ||
91
+ norm.startsWith('.akb') ||
92
+ norm.endsWith('.tmp')) {
93
+ return;
94
+ }
95
+ if (this.debounceTimer) {
96
+ clearTimeout(this.debounceTimer);
97
+ }
98
+ this.debounceTimer = setTimeout(async () => {
99
+ try {
100
+ const update = await this.rebuildGraph(options);
101
+ if (options.onUpdate) {
102
+ options.onUpdate({
103
+ timestamp: new Date().toISOString(),
104
+ nodesCount: update.graph.nodes.length,
105
+ edgesCount: update.graph.edges.length,
106
+ outPath: update.outPath,
107
+ durationMs: update.durationMs
108
+ });
109
+ }
110
+ }
111
+ catch {
112
+ // Silently continue watching on transient file-lock errors
113
+ }
114
+ }, debounceMs);
115
+ });
116
+ }
117
+ catch {
118
+ // Fallback gracefully if recursive watch is unavailable on host filesystem
119
+ }
120
+ }
121
+ stop() {
122
+ this.isWatching = false;
123
+ if (this.debounceTimer) {
124
+ clearTimeout(this.debounceTimer);
125
+ this.debounceTimer = null;
126
+ }
127
+ if (this.watcher) {
128
+ this.watcher.close();
129
+ this.watcher = null;
130
+ }
131
+ }
132
+ }
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
- {
2
- "name": "akbo-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "akbo-cli",
3
+ "version": "1.9.4",
4
+ "description": "AI-Native Knowledge Base Oracle & Operator (AKBO) - Deterministic AST/Manifest Harvester & Agent Invariant Synthesizer",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "akbo": "dist/cli.js",
10
+ "akbo-cli": "dist/cli.js",
11
+ "akb": "dist/cli.js",
12
+ "akbo-mcp": "dist/cli.js"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "schemas",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "tsx src/cli.ts",
22
+ "start": "node dist/cli.js",
23
+ "test": "vitest run",
24
+ "release": "node scripts/publish-release.mjs",
25
+ "prepublishOnly": "npm run test && npm run build"
26
+ },
27
+ "keywords": [
28
+ "ai",
29
+ "knowledge-base",
30
+ "oracle",
31
+ "operator",
32
+ "agents",
33
+ "cursor",
34
+ "antigravity",
35
+ "claude-code",
36
+ "architecture-invariants"
37
+ ],
38
+ "author": "",
39
+ "license": "MIT",
40
+ "dependencies": {
41
+ "@modelcontextprotocol/sdk": "^1.32.2",
42
+ "chalk": "^5.4.1",
43
+ "commander": "^12.1.0",
44
+ "dotenv": "^16.4.7",
45
+ "globby": "^14.0.2",
46
+ "ignore": "^7.0.3",
47
+ "yaml": "^2.7.0",
48
+ "zod": "^4.6.7"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^22.13.5",
52
+ "tsx": "^4.19.3",
53
+ "typescript": "^5.7.3",
54
+ "vitest": "^3.0.6"
55
+ }
56
+ }
@@ -0,0 +1,98 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "AKB Master Index & Catalog Router Specification",
4
+ "description": "Schema defining the root knowledge/index.yaml and domain sub-catalogs.",
5
+ "type": "object",
6
+ "required": [
7
+ "system_name"
8
+ ],
9
+ "properties": {
10
+ "system_name": {
11
+ "type": "string",
12
+ "description": "System name or platform identifier."
13
+ },
14
+ "repository_root": {
15
+ "type": "string",
16
+ "description": "Normalized repository root directory path."
17
+ },
18
+ "description": {
19
+ "type": "string",
20
+ "description": "Overview description of the system or bounded context."
21
+ },
22
+ "knowledge_units_count": {
23
+ "type": "integer",
24
+ "description": "Total number of active knowledge units indexed."
25
+ },
26
+ "last_updated": {
27
+ "type": "string",
28
+ "description": "Date string when the catalog was last updated (YYYY-MM-DD)."
29
+ },
30
+ "knowledge_units": {
31
+ "type": "object",
32
+ "description": "Inventory of knowledge units grouped by domain.",
33
+ "additionalProperties": {
34
+ "type": "array",
35
+ "items": {
36
+ "type": "object",
37
+ "required": [
38
+ "id",
39
+ "file",
40
+ "title"
41
+ ],
42
+ "properties": {
43
+ "id": {
44
+ "type": "string"
45
+ },
46
+ "file": {
47
+ "type": "string"
48
+ },
49
+ "title": {
50
+ "type": "string"
51
+ },
52
+ "purpose": {
53
+ "type": "string"
54
+ }
55
+ }
56
+ }
57
+ }
58
+ },
59
+ "domains": {
60
+ "type": "array",
61
+ "description": "Federated domain catalog references (Namespaced Central Hub).",
62
+ "items": {
63
+ "type": "object",
64
+ "required": [
65
+ "id",
66
+ "catalog"
67
+ ],
68
+ "properties": {
69
+ "id": {
70
+ "type": "string"
71
+ },
72
+ "name": {
73
+ "type": "string"
74
+ },
75
+ "description": {
76
+ "type": "string"
77
+ },
78
+ "catalog": {
79
+ "type": "string"
80
+ },
81
+ "applies_to": {
82
+ "oneOf": [
83
+ {
84
+ "type": "array",
85
+ "items": {
86
+ "type": "string"
87
+ }
88
+ },
89
+ {
90
+ "type": "string"
91
+ }
92
+ ]
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
@@ -0,0 +1,154 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "AKB Knowledge Unit Specification",
4
+ "description": "Schema defining atomic YAML knowledge units (standards, rules, and architecture decisions) for AI coding assistants.",
5
+ "type": "object",
6
+ "required": [
7
+ "id",
8
+ "type",
9
+ "title",
10
+ "domain"
11
+ ],
12
+ "properties": {
13
+ "id": {
14
+ "type": "string",
15
+ "description": "Unique immutable identifier for this knowledge unit (e.g. ARCH-SYS-001, DEV-TS-001, ADR-001).",
16
+ "pattern": "^[A-Z0-9]+(-[A-Z0-9]+)*$"
17
+ },
18
+ "type": {
19
+ "type": "string",
20
+ "description": "Category type of the knowledge unit.",
21
+ "enum": [
22
+ "architecture_standard",
23
+ "development_standard",
24
+ "product_rule",
25
+ "security_standard",
26
+ "architecture_decision"
27
+ ]
28
+ },
29
+ "title": {
30
+ "type": "string",
31
+ "description": "Human-readable title summarizing the unit directive."
32
+ },
33
+ "domain": {
34
+ "type": "string",
35
+ "description": "Bounded context or architectural domain (e.g. architecture, development, product, decisions, billing, core)."
36
+ },
37
+ "status": {
38
+ "type": "string",
39
+ "description": "Current lifecycle status.",
40
+ "enum": [
41
+ "approved",
42
+ "draft",
43
+ "deprecated",
44
+ "accepted",
45
+ "proposed",
46
+ "locked"
47
+ ],
48
+ "default": "approved"
49
+ },
50
+ "version": {
51
+ "type": "string",
52
+ "description": "Semantic version of this knowledge unit specification.",
53
+ "default": "1.0.0"
54
+ },
55
+ "authority": {
56
+ "type": "object",
57
+ "description": "Organizational authority and confidence level.",
58
+ "properties": {
59
+ "level": {
60
+ "type": "string",
61
+ "enum": [
62
+ "official",
63
+ "guideline",
64
+ "experimental",
65
+ "human_curated"
66
+ ],
67
+ "default": "official"
68
+ },
69
+ "confidence": {
70
+ "type": "string",
71
+ "enum": [
72
+ "high",
73
+ "medium",
74
+ "low",
75
+ "verified"
76
+ ],
77
+ "default": "high"
78
+ }
79
+ }
80
+ },
81
+ "owner": {
82
+ "type": "object",
83
+ "description": "Ownership team or persona.",
84
+ "properties": {
85
+ "team": {
86
+ "type": "string",
87
+ "description": "Team name responsible for enforcing this rule."
88
+ }
89
+ }
90
+ },
91
+ "applies_to": {
92
+ "type": "array",
93
+ "description": "List of file globs, directory paths, or component tags to which this invariant strictly applies.",
94
+ "items": {
95
+ "type": "string"
96
+ }
97
+ },
98
+ "rule": {
99
+ "type": "string",
100
+ "description": "Primary normative architectural rule or directive enforced by this unit."
101
+ },
102
+ "decision": {
103
+ "type": "string",
104
+ "description": "Architectural decision statement (for type: architecture_decision)."
105
+ },
106
+ "context": {
107
+ "type": "string",
108
+ "description": "Problem context and historical motivation."
109
+ },
110
+ "do": {
111
+ "type": "array",
112
+ "description": "Prescriptive action items and best practices that developers and AI agents must follow.",
113
+ "items": {
114
+ "type": "string"
115
+ }
116
+ },
117
+ "dont": {
118
+ "type": "array",
119
+ "description": "Strict prohibitions and anti-patterns that must not be introduced.",
120
+ "items": {
121
+ "type": "string"
122
+ }
123
+ },
124
+ "reason": {
125
+ "type": "string",
126
+ "description": "Architectural rationale explaining why this invariant is necessary."
127
+ },
128
+ "related_items": {
129
+ "type": "array",
130
+ "description": "Cross-reference IDs to related Knowledge Units (e.g. ARCH-SYS-001).",
131
+ "items": {
132
+ "type": "string"
133
+ }
134
+ },
135
+ "skill_file": {
136
+ "type": "string",
137
+ "description": "Relative path to the original human-curated SKILL.md file if imported from an agent skill."
138
+ },
139
+ "reference_files": {
140
+ "type": "array",
141
+ "description": "Discovered companion reference documentation files (e.g. references/*.md) supporting this skill.",
142
+ "items": {
143
+ "type": "string"
144
+ }
145
+ },
146
+ "workflow_gates": {
147
+ "type": "array",
148
+ "description": "Ordered procedural implementation gates or verification steps extracted from the skill.",
149
+ "items": {
150
+ "type": "string"
151
+ }
152
+ }
153
+ }
154
+ }