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
package/README.md CHANGED
@@ -1,3 +1,787 @@
1
- # Temporary Holding Version
1
+ # ๐Ÿง  akbo-cli โ€” AI-Native Knowledge Base Oracle & Operator
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![Version](https://img.shields.io/badge/version-2.0.0-blue.svg)](https://www.npmjs.com/package/akbo-cli)
4
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue.svg)](https://www.typescriptlang.org/)
5
+ [![Model Context Protocol](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io/)
6
+ [![Vitest Tests](https://img.shields.io/badge/tests-229%20passed-brightgreen.svg)](https://vitest.dev/)
7
+ [![Security: 0 Vulnerabilities](https://img.shields.io/badge/vulnerabilities-0%20production-brightgreen.svg)](https://www.npmjs.com/package/akbo-cli)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
9
+
10
+ > **Deterministic AST Harvester, Agent Memory Consolidation ("Dreaming"), CKG Engine & Runtime Guardrails**
11
+ > Empowers AI coding assistants (**Google Antigravity, Cursor, Claude Code, Gemini CLI, Windsurf, Copilot, Codex**) with zero-token topological context slices, out-of-band memory consolidation, cross-lingual GraphRAG query grounding, pre-tool runtime execution rails, and strict architectural invariant enforcement.
12
+
13
+ ---
14
+
15
+ ## ๐ŸŽฏ Why AKBO?
16
+
17
+ AI agents modifying large, polyglot, or enterprise codebases frequently suffer from:
18
+ 1. **Speculative Grepping & Hallucination**: Blindly querying code files without understanding high-level architectural patterns, database schemas, or messaging boundaries.
19
+ 2. **Context Dilution**: Flooding LLM context windows with thousands of lines of irrelevant source code instead of focused architectural rules.
20
+ 3. **Cross-Lingual Mismatch**: Inability to map English developer prompts to codebases named in Spanish (`Factura`, `Pedido`), Chinese (`ๅ‘็ฅจ`, `็”จๆˆท`), German (`Rechnung`, `Kunde`), or domain-specific jargon.
21
+ 4. **Tool Incompatibility**: Agents lack standardized interfaces to query architecture invariants dynamically prior to code execution.
22
+ 5. **Heavy SDK Bloat**: Traditional CLI tools pull in hundreds of megabytes of third-party vendor SDKs. AKBO uses **100% Node 20+ native `fetch`** across all providers, completely eliminating heavy AI SDKs and transitive bloat.
23
+
24
+ **AKBO (AI Knowledge Base Oracle & Operator)** solves this through a **6-stage deterministic pipeline** and a native **Model Context Protocol (MCP)** server:
25
+
26
+ ```mermaid
27
+ flowchart LR
28
+ A["Source Codebase"] --> B["Stage 1: Deterministic Harvester<br/>(0 Tokens AST)"]
29
+ B --> C["Codebase Knowledge Graph<br/>(CKG Engine)"]
30
+ C --> D["Stage 2 & 3: Master Planner & Synthesizer<br/>(Multi-LLM / CLI)"]
31
+ D --> E["knowledge/ Standard Catalogs<br/>(Atomic Invariant YAMLs)"]
32
+ E --> F["Stage 4: Multi-Agent Hooks<br/>(AGENTS.md, CLAUDE.md, .cursorrules)"]
33
+ E --> G["Stage 5: Runtime Schema Validator<br/>(Zod Federation)"]
34
+ C & E --> H["Stage 6: Native MCP Server & CLI<br/>(0-Token Context & GraphRAG)"]
35
+ H --> I["AI Agents: Antigravity, Cursor, Claude Code, Gemini CLI"]
36
+ ```
37
+
38
+ ---
39
+
40
+ ## โœจ Key Features
41
+
42
+ - **๐Ÿ›ก๏ธ External Knowledge Pool (Zero-Touch Monorepo Isolation)**: Completely separates scanned code (`targetDir`) from knowledge bases and caches (`poolDir`) via `--pool <path>` or `AKBO_POOL_DIR`. Zero files (`.akb`, `cache.json`, `AGENTS.md`) are ever created in your target repository or subprojects. Caches are safely keyed by target directory inside `poolDir/.akb/caches/${scopeSlug}-${hash8}.json`, walks ancestor `.gitignore` files up to the git repository root with rebasing, supports zero-touch exclusions via `poolDir/.akb/ignore`, and dual-path `applies_to` matching ensures central architectural rules match when scanning any subproject.
43
+ - **๐ŸŒ™ Out-of-Band Memory Consolidation ("Dreaming") (`akbo dream`)**: Asynchronous offline cognitive pipeline inspired by biological sleep cycles. Ingests session observations, tool invocations, and error traces across past runs, discards one-off transient noise, and synthesizes recurring trial-and-error patterns into compounding Architecture Decision Records (`ADR-xxx.yaml`) and patched standards (`authority: synthesized_dream`), allowing daytime agents to wake up sharper with continuously compounding intelligence.
44
+ - **๐Ÿ›ก๏ธ Active Runtime Guardrails (`akbo guard` & `akbo_guard`)**: Pre-tool execution rail intercepting proposed file modifications, snippets, or diffs before execution. Evaluates proposed changes against active `dont` directives and `.akb/standards.yaml` deprecated patterns, blocking violations before code is written or committed.
45
+ - **๐Ÿšฆ Deterministic Git Pre-Commit & CI Gates (`akbo check --staged`)**: Fast, zero-token pre-commit and CI verification gate that scans git staged diffs against repository invariants, blocking PR merges that violate approved standards.
46
+ - **๐Ÿ“Š In-Memory Code-Execution & Projection Filter (`akbo filter` & `akbo_filter`)**: Evaluates sandboxed JavaScript predicate expressions against in-memory CKG nodes, edges, or invariants with strict field projection, eliminating context window saturation on massive monorepos.
47
+ - **๐Ÿ“ Multi-Agent Ephemeral Scratchpads & Observation Logging (`akbo scratchpad`, `akbo observe`, `akbo_scratchpad`, `akbo_record_observation`)**: Dedicated isolated session notes (`.akb/sessions/<agent_id>/scratchpad.md` and `observations.jsonl`) eliminating multi-agent write collisions and preventing short-term scratchpads from polluting durable organizational knowledge.
48
+ - **๐Ÿ“œ Declarative Operational Contracts (`llms.txt` & `llms-full.txt`)**: Generates standard `llms.txt` and `llms-full.txt` manifests alongside `AGENTS.md` and `CLAUDE.md`, providing clean machine-readable documentation indexes and API manifests for LLM crawlers and agents.
49
+ - **โณ Bi-Temporal CKG & State Invalidation (`SUPERSEDES` links)**: Tracks invariant lineage (`supersedes`, `superseded_by`, `valid_from`) and alerts when code matches superseded conventions, preventing stale memory poisoning.
50
+ - **โšก Native Model Context Protocol (MCP 2.0) Server**: Built on `@modelcontextprotocol/sdk` over STDIO (`akbo mcp` / `akbo-mcp`), exposing 18 high-performance tools (`akbo_search`, `akbo_impact`, `akbo_context`, `akbo_query`, `akbo_harvest`, `akbo_validate`, `akbo_graph`, `akbo_list_invariants`, `akbo_upsert_unit`, `akbo_upsert_units`, `akbo_get_unit`, `akbo_delete_unit`, `akbo_import_skills`, `akbo_filter`, `akbo_record_observation`, `akbo_scratchpad`, `akbo_dream`, `akbo_guard`) and direct catalog resources with native Google Antigravity CLI (`agy`) support, tool allowlist/denylist flags (`--disable-tools`, `--zero-token-only`, `--disallow-root-scan`), `summaryOnly` payload capping, and recursive agent spawning protection (`AKBO_NESTED_AGENT: '1'`).
51
+ - **๐Ÿ“ฆ Atomic Knowledge Store & Batch Upserts (`akbo upsert`, `akbo get-unit`, `akbo delete-unit`)**: Exposes programmatic and CLI-driven atomic knowledge unit management powered by `CatalogStore`. Supports single or batch JSON/YAML unit arrays, automatic PowerShell UTF-8 BOM stripping, path normalization on `applies_to`, atomic `knowledge/index.yaml` updates via rename, built-in validation, and Windows CRLF line ending preservation.
52
+ - **๐Ÿ”ค Windows-1252 (CP1252) Source File Decoding**: Decodes non-UTF-8 legacy C# source files (e.g. Western European Windows-1252/CP1252 files with `รฑ`, `รฉ`, `รผ`, `รค`, `รถ`) using native `TextDecoder` fallback, preventing Unicode replacement character corruption and regex breakdown.
53
+ - **๐Ÿ”— Interface-to-Class `IMPLEMENTS` Edge Wiring**: Connects interface symbols directly to their concrete implementation classes (`implementsGroup` in custom extractors and Pass 2 graph linking), enabling bidirectional blast-radius impact analysis across interface abstraction layers.
54
+ - **๐Ÿ” 0-Token Symbol Search & Directional Blast-Radius (`akbo_search` & `akbo_impact`)**: Sub-5ms in-memory substring/token search across all indexed symbols, endpoints, schemas, and invariants without LLM token consumption. Directional blast-radius calculation tracing inbound callers and dependents with topological build order and interface traversal.
55
+ - **๐Ÿ•ธ๏ธ Deterministic Codebase Knowledge Graph (CKG)**: 2-pass deterministic graph construction linking projects, controllers, endpoints, serverless triggers, messages, schemas, and invariants with 0 LLM tokens, supporting domain-clustered Mermaid subgraphs (`subgraph Domain`), $O(1)$ edge deduplication, $O(\text{depth})$ project ownership lookups, inverted schema model indexing eliminating $O(R \times S \times M)$ loops, two-tier in-memory + persistent caching (`.akb/cache.json`), in-memory mtime Knowledge Unit caching, and dot-guarded non-endpoint file fallback to owning project nodes.
56
+ - **๐Ÿ“ 0-Token Topological Neighborhood & Invariant Lookup (`akbo context` & `akbo invariants`)**: Sub-second BFS extraction of 1-hop and 2-hop topological subgraphs surrounding any entity or file, alongside instant pre-execution invariant lookup (`akbo_list_invariants`) to eliminate hallucinations before code edits.
57
+ - **๐ŸŒ Cross-Lingual & Multi-Seed Semantic GraphRAG (`akbo query` / `akbo ask`)**: Polyglot entity resolver with punctuation-trimmed tokenization that strips trailing sentence periods, filters question stopwords, and fuses multi-entity topological neighborhoods across codebases written in Spanish, Chinese, German, or domain dialects.
58
+ - **๐Ÿš€ Zero-SDK Native Fetch Engine**: Zero third-party AI SDKs! All generative operations (Gemini, OpenAI, Anthropic, DeepSeek, Groq, Mistral, Ollama) execute over Node 20+ native `fetch`, eliminating 40+ transitive packages and deprecated dependencies.
59
+ - **๐ŸชŸ Windows-Safe NDJSON Stdin Streaming & Error Resilience**: Headless `agy` and `gemini` CLI integration piping prompts via NDJSON stdin streaming with defensive `EPIPE`/`EOF` error listeners, completely bypassing Windows `CreateProcess` 32,767-character command-line limits (`ENAMETOOLONG`) and preventing stream crashes on early child process exit.
60
+ - **๐ŸŽฏ First-Class Curated Skill Ingestion (`akbo import-skills`)**: Converts `.agents/skills/**/SKILL.md` into protected Knowledge Units with targeted directory glob inference (filtering prose shorthand slashes and capturing description paths) and hierarchical workflow gate heading prioritization (`##`, `####`, nested steps).
61
+ - **๐Ÿšœ Enterprise Polyglot Harvester**: Deterministically extracts manifests, schemas, endpoints, serverless triggers, and messaging abstractions across .NET (Modern .NET 8/9, legacy .NET Framework 4.x, ASP.NET MVC 5, Web API 2, Azure Functions, WCF, EF Core, Dapper, FluentValidation, MassTransit, NServiceBus, Wolverine, MediatR, gRPC/Protobuf), Java & Kotlin (Maven, Gradle, Spring Boot, Quarkus, JPA/Hibernate, Spring Data Repositories, Spring Kafka, Spring RabbitMQ), TypeScript & Node.js (NestJS, Next.js App Router, Express, Prisma, BullMQ, pnpm/turbo/nx workspaces), Python (FastAPI, Flask, Django, SQLAlchemy, Pydantic, Celery, Dramatiq), Rust, and Go.
62
+ - **๐Ÿข Enterprise Bounded Contexts (DDD Federated Catalogs)**: Two-tier Namespaced Central Hub architecture (`--domain core`, `--domain billing`) avoiding context bloat in 100+ project enterprise repositories.
63
+ - **๐Ÿค– Universal Agent Pre-Execution Hooks**: Emits synchronized instruction hooks across `AGENTS.md`, `GEMINI.md`, `CLAUDE.md`, `.cursorrules`, `.cursor/mcp.json`, and `.vscode/mcp.json`.
64
+ - **๐Ÿ’ป Machine-Readable `--json` Output**: Clean, banner-free JSON output modes across all primary commands for automated agent terminal tool execution.
65
+
66
+ ---
67
+
68
+ ## ๐Ÿš€ Quick Start
69
+
70
+ ### Installation
71
+
72
+ ```bash
73
+ # Global installation via npm
74
+ npm install -g akbo-cli
75
+
76
+ # Or run instantly with npx (zero installation)
77
+ npx akbo-cli harvest .
78
+ ```
79
+
80
+ ### Development Setup
81
+
82
+ ```bash
83
+ # Clone the repository
84
+ git clone https://github.com/sureshjsreddy/akb-cli.git
85
+ cd akb-cli
86
+
87
+ # Install dependencies & build
88
+ npm install
89
+ npm run build
90
+
91
+ # Link CLI locally for testing
92
+ npm link
93
+ ```
94
+
95
+ ### Provider & Authentication Configuration
96
+
97
+ AKBO supports **Multi-LLM execution providers** via native Node 20+ `fetch` or local system CLIs:
98
+
99
+ #### 1. Google Antigravity CLI (`--agy`, Recommended for Local AGY Users)
100
+ Zero API key required; connects directly to your authenticated Antigravity CLI session:
101
+ ```bash
102
+ akbo init . --agy
103
+ akbo query "Explain the billing flow" --agy
104
+ ```
105
+
106
+ #### 2. Direct Gemini API (Fast, Zero SDK)
107
+ Configure a `.env` file or export your API key:
108
+ ```ini
109
+ GEMINI_API_KEY=your_gemini_api_key_here
110
+ GEMINI_MODEL=gemini-3.5-flash
111
+ ```
112
+ *(Also automatically resolves `GOOGLE_API_KEY` or `GOOGLE_GENAI_API_KEY`)*
113
+
114
+ #### 3. System Gemini CLI (Zero API Key Setup)
115
+ ```bash
116
+ akbo plan . --cli
117
+ akbo generate . --cli
118
+ akbo query "Explain the billing flow" --cli
119
+ ```
120
+
121
+ #### 4. OpenAI, Anthropic, DeepSeek, Groq & Ollama
122
+ ```bash
123
+ # OpenAI
124
+ export OPENAI_API_KEY=sk-...
125
+ akbo ask "Explain the architecture" -p openai -m gpt-4o
126
+
127
+ # Anthropic Claude
128
+ export ANTHROPIC_API_KEY=sk-ant-...
129
+ akbo ask "Explain the architecture" -p anthropic -m claude-3-7-sonnet
130
+
131
+ # DeepSeek
132
+ export DEEPSEEK_API_KEY=...
133
+ akbo ask "Explain the architecture" -p deepseek -m deepseek-chat
134
+
135
+ # Ollama (100% Offline, Zero Cost)
136
+ akbo query "Explain the architecture" -p ollama
137
+ ```
138
+
139
+ ---
140
+
141
+ ## ๐Ÿ”Œ Model Context Protocol (MCP) Server Integration
142
+
143
+ AKBO includes a native MCP server (`src/mcp_server.ts`) operating over STDIO. It allows autonomous AI agents to introspect codebase architecture, query invariants, and harvest topology directly.
144
+
145
+ ### Running the MCP Server
146
+ ```bash
147
+ # Direct CLI command
148
+ akbo mcp [dir]
149
+
150
+ # Executable binary alias
151
+ akbo-mcp [dir]
152
+
153
+ # Or via npx
154
+ npx -y akbo-cli mcp
155
+ ```
156
+
157
+ ### Agent Configuration Matrix
158
+
159
+ | AI Tool / IDE | Setup Method | Configuration File |
160
+ | :--- | :--- | :--- |
161
+ | **Google Antigravity** | Native MCP Server Settings | Add command `akbo mcp` in Antigravity MCP settings |
162
+ | **Cursor AI** | Auto-detected Project MCP | Generated at [`.cursor/mcp.json`](.cursor/mcp.json) |
163
+ | **Claude Code** | Global or Project CLI Command | Run `claude mcp add akbo -- npx -y akbo-cli mcp` |
164
+ | **VS Code / Copilot** | VS Code MCP Extension | Generated at [`.vscode/mcp.json`](.vscode/mcp.json) |
165
+ | **Gemini CLI** | Pre-Execution Terminal Hooks | Configured via [`GEMINI.md`](GEMINI.md) calling `akbo context <target> --json` |
166
+
167
+ ### MCP Configuration with External Knowledge Pool
168
+ For enterprise monorepos, configure your AI coding agent (e.g. `~/.gemini/config/mcp_config.json` or project MCP settings) with an external pool:
169
+
170
+ ```json
171
+ {
172
+ "mcpServers": {
173
+ "akbo": {
174
+ "command": "akbo-mcp",
175
+ "args": ["C:/repos/EnterpriseApp/Services"],
176
+ "env": {
177
+ "AKBO_POOL_DIR": "C:/AKBO/EnterprisePool",
178
+ "AKB_PROVIDER": "agy"
179
+ }
180
+ }
181
+ }
182
+ }
183
+ ```
184
+ - **Zero repository files**: All knowledge YAMLs, standards, and per-target caches live in the external pool.
185
+ - **Cross-subfolder flexibility**: Run from any subfolder (e.g. `Services/Billing`); AKBO matches central rules and keeps caches cleanly separated.
186
+
187
+ ### Auto-Generated MCP Configuration
188
+ Running `akbo init-hooks .` or `akbo generate .` automatically generates `.cursor/mcp.json` and `.vscode/mcp.json`:
189
+
190
+ ```json
191
+ {
192
+ "mcpServers": {
193
+ "akbo": {
194
+ "command": "npx",
195
+ "args": ["-y", "akbo-cli", "mcp"],
196
+ "env": {}
197
+ }
198
+ }
199
+ }
200
+ ```
201
+
202
+ ### Exposed MCP 2.0 Tools & Resources
203
+
204
+ | Tool / Resource | Type | Description |
205
+ | :--- | :--- | :--- |
206
+ | **`akbo_search`** | Tool | Fast, zero-token in-memory symbol search across symbols, endpoints, schemas (<5ms). |
207
+ | **`akbo_impact`** | Tool | Directional blast-radius and inbound dependent calculation with topological build ordering and `IMPLEMENTS` interface traversal. |
208
+ | **`akbo_context`** | Tool | Extracts 0-token topological neighborhood (1โ€“2 hops) & active invariants for an entity, class, file, or endpoint. |
209
+ | **`akbo_filter`** | Tool | Fast in-memory sandboxed JavaScript projection and filtering of CKG nodes, edges, or invariants without flooding context. |
210
+ | **`akbo_record_observation`** | Tool | Records runtime observations, bug fixes, or convention discoveries into isolated agent session logs for offline consolidation. |
211
+ | **`akbo_scratchpad`** | Tool | Reads or updates an agent's isolated session scratchpad (`.akb/sessions/<agent_id>/scratchpad.md`) avoiding write collisions. |
212
+ | **`akbo_dream`** | Tool | Runs out-of-band memory consolidation ("Dreaming") to synthesize durable compounding knowledge units or staged proposals from session observations. |
213
+ | **`akbo_guard`** | Tool | Evaluates proposed code modifications, snippets, or diffs against active invariants and standards as a pre-tool execution rail. |
214
+ | **`akbo_query`** | Tool | Executes GraphRAG query strictly grounded in the CKG (supports `provider: 'agy'`, Gemini, OpenAI, Claude). |
215
+ | **`akbo_harvest`** | Tool | Deterministically scans codebase topology, manifests, schemas, endpoints, and validation rules (0 tokens). |
216
+ | **`akbo_validate`** | Tool | Validates `knowledge/` directory against runtime Zod schemas and cross-reference standards. |
217
+ | **`akbo_graph`** | Tool | Deterministically builds and exports CKG with `nodeTypes`, `domain`, and `maxNodes` filtering. |
218
+ | **`akbo_list_invariants`** | Tool | Retrieves active architectural invariants filtered by target file, domain, or search query (`query`) with complete metadata (0 tokens). |
219
+ | **`akbo_upsert_unit`** | Tool | Atomically adds or updates a knowledge standard or decision in the central pool (supports single unit or batch array with built-in validation). |
220
+ | **`akbo_upsert_units`** | Tool | Batch upserts multiple knowledge units atomically into the pool and returns catalog validation. |
221
+ | **`akbo_get_unit`** | Tool | Fetches complete knowledge unit YAML and metadata by unique ID. |
222
+ | **`akbo_delete_unit`** | Tool | Deletes a knowledge unit from the pool, updates `index.yaml`, decrements counts, and clears caches. |
223
+ | **`akbo_import_skills`** | Tool | Ingests agent skills (`.agents/skills/**/SKILL.md`) directly into the external knowledge pool. |
224
+ | **`akbo://knowledge/index`** | Resource | Provides real-time read access to the project's master `knowledge/index.yaml` catalog. |
225
+
226
+ ---
227
+
228
+ ## ๐Ÿ› ๏ธ Complete CLI Command Reference
229
+
230
+ ### Staged Pipeline & Onboarding Commands
231
+
232
+ #### 0. `akbo init [dir] [-m <model>] [--cli] [-d <domain>] [--no-clean] [-j, --json]` (All-In-One Onboarding)
233
+ Executes the full automated 5-stage setup: harvest -> plan -> generate -> hooks -> schemas -> validate in one single command:
234
+ ```bash
235
+ # Initialize current workspace with default Gemini Flash
236
+ akbo init .
237
+
238
+ # Initialize using local Gemini CLI (0 API key required)
239
+ akbo init . --cli
240
+
241
+ # Initialize a specific bounded context domain
242
+ akbo init src/Billing --domain billing
243
+
244
+ # Machine-readable JSON output for automated agent tooling
245
+ akbo init . --json
246
+ ```
247
+
248
+ #### 1. `akbo harvest [dir] [-o <path>] [-j, --json]` (Stage 1)
249
+ Deterministically harvests repository manifests, schemas, endpoints, serverless triggers, and messaging handlers with **0 LLM tokens**:
250
+ ```bash
251
+ akbo harvest .
252
+ akbo harvest . --json
253
+ akbo harvest src/Billing -o .akb/billing-skeleton.json
254
+ ```
255
+
256
+ #### 2. `akbo plan [dir] [-d <domain>] [--pool <path>] [--cli]` (Stage 2)
257
+ Synthesizes a proposed master index (`.akb/proposed-index.yaml`) proposing 4 to 8 high-impact atomic Knowledge Units using Gemini Flash (~3k tokens):
258
+ ```bash
259
+ akbo plan .
260
+ akbo plan src/Billing --domain billing
261
+ akbo plan . --pool C:/AKBO/Pool
262
+ akbo plan . --cli
263
+ ```
264
+
265
+ #### 3. `akbo generate [dir] [-d <domain>] [--clean] [--cli]` (Stage 3 & 4)
266
+ Synthesizes atomic YAML knowledge units with strict `rule`, `do`, and `dont` directives, runs runtime validation, and bootstraps multi-agent pre-execution hooks:
267
+ ```bash
268
+ akbo generate .
269
+ akbo generate . --clean
270
+ akbo generate src/Billing --domain billing --clean
271
+ ```
272
+
273
+ #### 4. `akbo validate [dir] [--pool <path>] [-j, --json]` (Stage 5)
274
+ Verifies that all knowledge units strictly conform to runtime Zod schemas, path normalization rules, and cross-references:
275
+ ```bash
276
+ akbo validate .
277
+ akbo validate . --pool C:/AKBO/Enterprise
278
+ akbo validate . --json
279
+ ```
280
+
281
+ #### 5. `akbo init-hooks [dir]` (Multi-Agent Bootstrapper)
282
+ Bootstraps or updates multi-agent instruction files and MCP configurations across `AGENTS.md`, `GEMINI.md`, `CLAUDE.md`, `.cursorrules`, `.cursor/mcp.json`, and `.vscode/mcp.json`:
283
+ ```bash
284
+ akbo init-hooks .
285
+ ```
286
+
287
+ #### 6. `akbo mcp [dir] [--pool <path>] [--disable-tools <csv>] [--zero-token-only] [--disallow-root-scan] [--disallow-dirs <csv>]` (Stage 6)
288
+ Launches the native Model Context Protocol (MCP) server over STDIO for AI agent integration with configurable tool allowlists and monorepo root scan guards:
289
+ ```bash
290
+ # Standard MCP server launch
291
+ akbo mcp .
292
+
293
+ # MCP server with external knowledge pool
294
+ akbo mcp . --pool C:/AKBO/EnterprisePool
295
+
296
+ # Zero-token mode (disables LLM-backed akbo_query) and protects root directory from accidental scans
297
+ akbo mcp . --zero-token-only --disallow-root-scan
298
+
299
+ # Selective tool disabling via CLI flag or AKBO_DISABLE_TOOLS environment variable
300
+ akbo mcp . --disable-tools akbo_query,akbo_import_skills
301
+
302
+ # Executable alias
303
+ akbo-mcp --pool C:/AKBO/EnterprisePool
304
+ ```
305
+
306
+ #### 7. `akbo upsert [dir] --pool <path> --from-file <file> [--stdin] [--validate] [-j, --json]` (Knowledge Unit Upsert)
307
+ Atomically upserts 1 to $N$ knowledge units or architecture decisions into the external pool, updates `knowledge/index.yaml` once via atomic rename, and runs validation:
308
+ ```bash
309
+ # Upsert single standard from JSON file
310
+ akbo upsert . --pool C:/AKBO/EnterprisePool --from-file unit.json
311
+
312
+ # Upsert batch of units with machine-readable JSON output
313
+ akbo upsert . --pool C:/AKBO/EnterprisePool --from-file batch-units.json -j
314
+
315
+ # Stream unit via STDIN (PowerShell UTF-8 BOM automatically stripped)
316
+ cat new-standard.yaml | akbo upsert . --pool C:/AKBO/EnterprisePool --stdin
317
+ ```
318
+
319
+ #### 8. `akbo get-unit <id> [dir] [--pool <path>] [-j, --json]` (Knowledge Unit Retrieval)
320
+ Fetches the full YAML definition or parsed JSON representation of any knowledge unit or decision by ID:
321
+ ```bash
322
+ # Fetch full unit YAML
323
+ akbo get-unit ARCH-SYS-001 . --pool C:/AKBO/EnterprisePool
324
+
325
+ # Fetch unit in machine-readable JSON
326
+ akbo get-unit ARCH-SYS-001 . --pool C:/AKBO/EnterprisePool -j
327
+ ```
328
+
329
+ #### 9. `akbo delete-unit <id> [dir] [--pool <path>] [--validate] [-j, --json]` (Knowledge Unit Deletion)
330
+ Deletes `knowledge/<domain>/<id>.yaml`, removes its entry from `knowledge/index.yaml`, decrements `knowledge_units_count`, clears caches, and re-validates:
331
+ ```bash
332
+ akbo delete-unit DEV-OLD-001 . --pool C:/AKBO/EnterprisePool
333
+ akbo delete-unit DEV-OLD-001 . --pool C:/AKBO/EnterprisePool -j
334
+ ```
335
+
336
+ #### 10. External Knowledge Pool & Monorepo Isolation (`--pool <path>`)
337
+ Pass `--pool <path>` (or set `AKBO_POOL_DIR`) on any command to keep the scanned code directory 100% clean and untouched:
338
+ ```bash
339
+ # Harvest subproject into external pool
340
+ akbo harvest src/Billing --pool C:/AKBO/Enterprise
341
+
342
+ # Extract context for an endpoint using rules from external pool
343
+ akbo context "POST /api/invoices" --pool C:/AKBO/Enterprise
344
+
345
+ # Validate external knowledge pool
346
+ akbo validate . --pool C:/AKBO/Enterprise
347
+ ```
348
+
349
+ ---
350
+
351
+ ### GraphRAG & Pre-Execution Engine Commands
352
+
353
+ #### 11. `akbo graph [dir] [--format json|mermaid|markdown] [--no-cluster] [--no-cache] [--pool <path>] [-o <path>] [-j, --json]`
354
+ Deterministically builds the Codebase Knowledge Graph (CKG) linking projects, endpoints, handlers, messages, schemas, validators, and invariants:
355
+ ```bash
356
+ # Export raw JSON AST (with mtime caching)
357
+ akbo graph . --json
358
+
359
+ # Export domain-clustered Mermaid diagram (subgraphs by bounded context)
360
+ akbo graph . --format mermaid -o docs/architecture.mmd
361
+
362
+ # Export using external pool for caches
363
+ akbo graph . --pool C:/AKBO/EnterprisePool --format mermaid -o docs/architecture.mmd
364
+
365
+ # Export flat Mermaid diagram without subgraphs
366
+ akbo graph . --format mermaid --no-cluster
367
+
368
+ # Export full Markdown report with Mermaid diagram and entity table
369
+ akbo graph . --format markdown -o docs/architecture-graph.md
370
+ ```
371
+
372
+ #### 12. `akbo invariants [dir] [-f <file>] [-d <domain>] [-q <query>] [--pool <path>] [-j, --json]`
373
+ Retrieves active architectural standards and invariants directly from knowledge units with 0 LLM tokens, supporting file-pattern, domain, and substring/keyword query filtering:
374
+ ```bash
375
+ # Inspect all loaded invariants
376
+ akbo invariants .
377
+
378
+ # Find invariants strictly applicable to a target file
379
+ akbo invariants . -f src/cli.ts
380
+
381
+ # Fast substring / keyword search across rules, titles, and directives (0ms)
382
+ akbo invariants . -q Invoice -j
383
+
384
+ # Query invariants using an external knowledge pool
385
+ akbo invariants . -f src/cli.ts --pool C:/AKBO/EnterprisePool
386
+
387
+ # Filter invariants by domain in machine-readable JSON (includes reason, type, status, authority)
388
+ akbo invariants . -d architecture --json
389
+ ```
390
+
391
+ #### 13. `akbo context <target> [dir] [-h <hops>] [--no-cache] [--pool <path>] [-j, --json]`
392
+ Extracts the 0-token topological neighborhood (1 or 2 hops) and active invariants around a target entity before modifying code:
393
+ ```bash
394
+ # Target controller or class
395
+ akbo context InvoicesController.cs
396
+
397
+ # Target controller with external pool
398
+ akbo context InvoicesController.cs --pool C:/AKBO/EnterprisePool
399
+
400
+ # Target HTTP endpoint with machine-readable JSON
401
+ akbo context "POST /api/invoices" -h 2 --json
402
+
403
+ # Target database context or validator
404
+ akbo context BillingDbContext -h 1
405
+ akbo context CreateInvoiceValidator
406
+
407
+ # Target localized or non-English identifiers
408
+ akbo context FacturaController
409
+ akbo context "ObtenerFactura"
410
+ ```
411
+
412
+ #### 14. `akbo query <prompt> [dir] [-m <model>] [--cli] [--agy] [--no-cache] [--pool <path>] [-j, --json]` (Alias: `akbo ask`)
413
+ Answers architectural questions strictly grounded in the Codebase Knowledge Graph with zero hallucinations and cross-lingual seed resolution:
414
+ ```bash
415
+ # English architectural query
416
+ akbo query "How are invoices created and what data models are used?"
417
+
418
+ # Query with external pool
419
+ akbo query "How are invoices created and what data models are used?" --pool C:/AKBO/EnterprisePool
420
+
421
+ # Query with machine-readable JSON output
422
+ akbo query "What validation rules are enforced for CreateInvoiceCommand?" --json
423
+
424
+ # Local Antigravity CLI query (0 API key)
425
+ akbo ask "Explain the customer billing architecture" --agy
426
+
427
+ # Local Gemini CLI query (0 API key)
428
+ akbo ask "Explain the customer billing architecture" --cli
429
+
430
+ # Query non-English codebase in English
431
+ akbo query "Which Azure Functions consume ServiceBus messages?"
432
+ ```
433
+
434
+ #### 15. `akbo clean [dir] [-a, --all] [--pool <path>]`
435
+ Purges intermediate `.akb/` artifacts to keep private repositories lean and save disk space:
436
+ ```bash
437
+ # Clean .akb/ temporary skeletons and plans
438
+ akbo clean .
439
+
440
+ # Clean .akb/ in external pool
441
+ akbo clean . --pool C:/AKBO/EnterprisePool
442
+
443
+ # Clean .akb/ and compiled TypeScript build files (dist/)
444
+ akbo clean . --all
445
+ ```
446
+
447
+ #### 16. `akbo watch [dir] [-o <path>] [--format <format>] [--no-cluster] [--pool <path>]`
448
+ Continuously watches the codebase filesystem for changes and auto-regenerates the Codebase Knowledge Graph and live architecture diagrams:
449
+ ```bash
450
+ # Live watch and auto-render Mermaid architecture
451
+ akbo watch . -o docs/architecture.mmd
452
+
453
+ # Live watch using external pool for caches
454
+ akbo watch . --pool C:/AKBO/Pool -o docs/architecture.mmd
455
+
456
+ # Live watch and auto-render Markdown graph document
457
+ akbo watch . --format markdown -o docs/architecture-graph.md
458
+ ```
459
+
460
+ #### 17. `akbo schema [dir] [--pool <path>] [-j, --json]`
461
+ Emits standard JSON Schemas (`schemas/knowledge-unit.json` and `schemas/index-schema.json`) and configures `.vscode/settings.json` with `yaml.schemas` associations to provide real-time IDE hover docs, validation, and autocompletion:
462
+ ```bash
463
+ # Generate schemas and configure VS Code / Cursor IDE settings
464
+ akbo schema .
465
+
466
+ # Generate schemas inside an external knowledge pool
467
+ akbo schema . --pool C:/AKBO/Pool
468
+
469
+ # Output schemas as JSON
470
+ akbo schema . --json
471
+ ```
472
+
473
+ #### 18. `akbo import-skills [dir] [--domain <domain>] [--pool <path>] [-j, --json]`
474
+ Ingests and converts curated agent skills (`.agents/skills/**/SKILL.md` or custom skill trees) into first-class **Skill Pointer Knowledge Units**:
475
+ - Preserves explicit references (`skill_file`, `reference_files`) without duplicating markdown bodies.
476
+ - Intelligently infers targeted `applies_to` directory globs from backticked paths and descriptions before falling back to language wildcards.
477
+ - Restricts and prioritizes workflow gate checklists extracted from dedicated verification sections (`## Implementation Gates`, `## Completion Gates`, etc.).
478
+ - Sets `authority.level: human_curated` to protect human-authored skills from overwrites during automatic regeneration.
479
+ ```bash
480
+ # Import all repository skills into knowledge units
481
+ akbo import-skills .
482
+
483
+ # Import into an external knowledge pool
484
+ akbo import-skills . --pool C:/AKBO/Enterprise
485
+
486
+ # Import into a specific domain
487
+ akbo import-skills . --domain billing
488
+ ```
489
+
490
+ #### 19. Standards & Deprecation Enforcement (`.akb/standards.yaml`)
491
+ Enforce modern architecture patterns and flag deprecated anti-patterns across the Codebase Knowledge Graph. When defined in `.akb/standards.yaml`, `akbo context` and `akbo query` automatically surface proactive warnings and guidance:
492
+ ```yaml
493
+ standards:
494
+ - name: Modern Async Repository Pattern
495
+ target: "Use IAsyncRepository<T> and async EF Core operations"
496
+ deprecated: "Synchronous DbContext queries or direct SQL execution without parameters"
497
+ applies_to:
498
+ - "**/*Repository.cs"
499
+ - "**/*Service.cs"
500
+ ```
501
+
502
+ #### 20. `akbo dream [dir] [--since <hours>] [--stage-only] [--no-auto-approve] [--provider <llm>] [--cli] [--agy] [--pool <path>] [-j, --json]` (Out-of-Band Memory Consolidation)
503
+ Runs the asynchronous offline memory consolidation pipeline ("Dreaming"):
504
+ - Ingests task observations (`observations.jsonl`) and error traces from past agent sessions.
505
+ - Distills recurring patterns and traps while discarding transient noise.
506
+ - Synthesizes durable Architecture Decisions (`ADR-xxx.yaml`) or patches existing knowledge units with updated `do`/`dont` rules (`authority.level: synthesized_dream`).
507
+ ```bash
508
+ # Run consolidation across all recent session observations
509
+ akbo dream .
510
+
511
+ # Stage proposals into .akb/staged/ without directly updating knowledge/index.yaml
512
+ akbo dream . --stage-only
513
+
514
+ # Run dreaming using local Antigravity agy CLI
515
+ akbo dream . --agy
516
+
517
+ # Consolidate observations inside an external knowledge pool
518
+ akbo dream . --pool C:/AKBO/EnterprisePool --json
519
+ ```
520
+
521
+ #### 21. `akbo guard <file> [dir] [-c <content>] [--file-content <path>] [--pool <path>] [-j, --json]` (Runtime Pre-Tool Guardrails)
522
+ Pre-tool execution rail that intercepts proposed code modifications before files are touched:
523
+ - Matches applicable invariants by file path (`applies_to`).
524
+ - Verifies proposed changes against `dont` directives (e.g. forbidden CommonJS `require`, raw `eval`, dangerous SQL statements) and `.akb/standards.yaml` deprecated patterns.
525
+ - Exits with code 0 if allowed; exits with code 1 and prints actionable failure reasons if blocked.
526
+ ```bash
527
+ # Evaluate a code snippet against applicable repository invariants
528
+ akbo guard src/data/UserRepository.ts -c "const mysql = require('mysql');"
529
+
530
+ # Output machine-readable JSON for agent pre-tool hooks
531
+ akbo guard src/controllers/OrderController.cs --file-content proposed_patch.diff --json
532
+ ```
533
+
534
+ #### 22. `akbo check [dir] [--staged] [--pool <path>] [-j, --json]` (Git Pre-Commit & CI Verification Gate)
535
+ Fast deterministic verification gate that scans git staged diffs against repository invariants:
536
+ ```bash
537
+ # Check all git staged files before committing
538
+ akbo check . --staged
539
+
540
+ # Use in pre-commit hooks or CI/CD pipelines
541
+ akbo check . --staged --json
542
+ ```
543
+
544
+ #### 23. `akbo filter <target> [dir] [-p <expr>] [--fields <list>] [--limit <n>] [--pool <path>] [-j, --json]` (In-Memory Graph Projection)
545
+ Executes sandboxed in-memory JavaScript expressions against CKG nodes, edges, or invariants without bloating context:
546
+ ```bash
547
+ # Filter endpoints in billing domain with field projection
548
+ akbo filter nodes . -p "n.type === 'endpoint' && n.domain === 'billing'" --fields id,label,file
549
+
550
+ # Filter invariants applicable to TypeScript
551
+ akbo filter invariants . -p "inv.applies_to.some(p => p.includes('ts'))" --limit 10 -j
552
+ ```
553
+
554
+ #### 24. `akbo observe [dir] -t <topic> -f <finding> [--fix <fix>] [--files <list>] [--agent <id>] [--pool <path>] [-j, --json]`
555
+ Records an ephemeral runtime finding or bug workaround into an isolated session log for offline dreaming:
556
+ ```bash
557
+ akbo observe . -t "MassTransit" -f "Consumers must not swallow exceptions directly" --fix "Allow exceptions to bubble to retry middleware" --files "Consumers/OrderConsumer.cs" --agent "agent-1"
558
+ ```
559
+
560
+ #### 25. `akbo scratchpad [dir] [--agent <id>] [--set <text>] [--append <text>] [--pool <path>] [-j, --json]`
561
+ Reads or updates an agent's isolated session scratchpad (`.akb/sessions/<agent_id>/scratchpad.md`), eliminating multi-agent write collisions:
562
+ ```bash
563
+ # Read scratchpad for agent
564
+ akbo scratchpad . --agent "agent-1"
565
+
566
+ # Append working notes
567
+ akbo scratchpad . --agent "agent-1" --append "- Investigating deadlock in event queue"
568
+ ```
569
+
570
+ ---
571
+
572
+ ### ๐Ÿค– Execution Providers (Multi-LLM & CLI Engines)
573
+
574
+ `akbo-cli` supports seamless synthesis and GraphRAG querying across cloud API keys, local offline models, and system CLIs without heavy third-party SDK dependencies (powered by Node 20+ native `fetch`):
575
+
576
+ | Provider | Flags / Environment | Supported Models / Notes |
577
+ | :--- | :--- | :--- |
578
+ | **Gemini (Default)** | `--provider gemini` or `GEMINI_API_KEY` | `gemini-3.5-flash`, `gemini-2.5-pro` |
579
+ | **Google Antigravity CLI** | `--agy` or `--provider agy` | Uses local `agy` session on PATH (0 API key required) |
580
+ | **System Gemini CLI** | `--cli` or `--provider cli` | Uses local `gemini` CLI on PATH (0 API key required) |
581
+ | **OpenAI** | `--provider openai` or `OPENAI_API_KEY` | `gpt-4o`, `gpt-4o-mini`, `o1`, `o3-mini` (auto-detected via `-m gpt-*`) |
582
+ | **Anthropic Claude** | `--provider anthropic` or `ANTHROPIC_API_KEY` | `claude-3-7-sonnet`, `claude-3-5-haiku` (auto-detected via `-m claude-*`) |
583
+ | **DeepSeek** | `--provider deepseek` or `DEEPSEEK_API_KEY` | `deepseek-chat`, `deepseek-reasoner` (auto-detected via `-m deepseek-*`) |
584
+ | **Groq** | `--provider groq` or `GROQ_API_KEY` | `llama-3.3-70b-versatile`, `mixtral-8x7b-32768` |
585
+ | **Ollama / Local** | `--provider ollama` `[--base-url <url>]` | `http://localhost:11434/v1` (100% offline, zero-token cost) |
586
+ | **OpenAI-Compatible** | `--provider openai-compatible --base-url <url>` | Any custom or enterprise private endpoint |
587
+
588
+ ```bash
589
+ # Query via OpenAI
590
+ akbo ask "Explain the customer billing architecture" -p openai -m gpt-4o
591
+
592
+ # Query via Anthropic Claude
593
+ akbo query "Explain the customer billing architecture" -p anthropic -m claude-3-7-sonnet
594
+
595
+ # Query via Google Antigravity CLI (0 API key)
596
+ akbo query "Explain the customer billing architecture" --agy
597
+
598
+ # Query via local Ollama
599
+ akbo query "What validation rules are enforced for CreateInvoiceCommand?" -p ollama
600
+ ```
601
+
602
+ ---
603
+
604
+ ## ๐Ÿšœ Multi-Ecosystem Harvester Matrix
605
+
606
+ AKBO extracts topology, schemas, and routes deterministically with 0 tokens across diverse language ecosystems:
607
+
608
+ | Ecosystem / Framework | Discovered Manifests & Schemas | Discovered Routes, Triggers & RPCs |
609
+ | :--- | :--- | :--- |
610
+ | **Java & Kotlin (JVM)** | Maven (`pom.xml` with reactor modules), Gradle (`build.gradle.kts`, `settings.gradle.kts`), JPA / Hibernate (`@Entity`, `@Table`), Spring Data (`JpaRepository<T, ID>`) | Spring Boot (`@RestController`, `@RequestMapping`, `@GetMapping`, `@PostMapping`), Quarkus / JAX-RS (`@Path`), Spring Kafka (`@KafkaListener`), Spring RabbitMQ (`@RabbitListener`) |
611
+ | **Modern .NET (8/9)** | `*.sln`, `*.csproj`, `Directory.Build.props`, `Directory.Packages.props`, EF Core (`DbContext`, `DbSet<T>`, `IEntityTypeConfiguration<T>`, `ToTable`) | ASP.NET Core Controllers, Minimal APIs (`app.MapGet`), Route tokens (`[controller]`, `[action]`), MediatR commands/queries |
612
+ | **Legacy .NET Framework (4.x)** | Legacy `*.csproj` (`v4.x`), NuGet `packages.config`, `web.config` (connection strings, auth), EDMX (`*.edmx`) Database-First models | ASP.NET MVC 5 Controllers (`ActionResult`), ASP.NET Web API 2 (`ApiController`), `Global.asax.cs` entry points |
613
+ | **Serverless & Functions** | Trigger bindings across in-process and isolated worker models | Azure Functions (`[FunctionName]`, `[Function]`) with `HttpTrigger`, `ServiceBusTrigger`, `QueueTrigger`, `BlobTrigger`, `CosmosDBTrigger`, `TimerTrigger` |
614
+ | **Enterprise Persistence** | EF Core Fluent API table mappings (`ToTable("table_name")`), Dapper raw SQL queries (`SELECT ... FROM ...`) | Relational data persistence wiring (`PERSISTED_BY` graph edges) |
615
+ | **Validation & Messaging** | FluentValidation (`AbstractValidator<T>`, `RuleFor(...)`) | MassTransit (`IConsumer<T>`), NServiceBus (`IHandleMessages<T>`), Wolverine conventional handlers (`Handle`, `Consume`), MediatR notifications |
616
+ | **gRPC & Protobuf** | Direct `*.proto` schema extraction (services, RPCs, messages) | Overridden C# gRPC service implementations (`*GrpcBase`), Java gRPC service implementations (`*Grpc.*ImplBase`), and cross-language gRPC client calls |
617
+ | **Node.js & TypeScript** | `package.json` workspaces, `pnpm-workspace.yaml`, `turbo.json`, `nx.json`, Prisma (`schema.prisma` models & enums), Drizzle ORM (`pgTable`), TypeORM (`@Entity`) | NestJS (`@Controller`, `@MessagePattern`), Next.js App Router (`route.ts`) & Pages Router (`pages/api`), Express/Fastify routes, BullMQ workers & queues (`new Worker`, `new Queue`, `@Processor`, `@Process`), `fetch()` and `axios` client calls |
618
+ | **Rust** | `Cargo.toml`, DB entity structs | Tauri commands (`#[tauri::command]`), Actix-web, Axum |
619
+ | **Python** | `pyproject.toml` (Poetry & PEP 621), `requirements.txt`, `Pipfile`, SQLAlchemy (models & `__tablename__`), Pydantic (`BaseModel`), SQLModel, Django models | FastAPI (`@app.get`, `@router.post`), Flask (Blueprints, `@app.route`), Django (`urls.py`, ViewSets), Celery tasks (`@app.task`, `@shared_task`), Dramatiq actors (`@dramatiq.actor`), `requests` and `httpx` client calls |
620
+ | **Go** | `go.mod`, GORM models | Gin, Echo, Chi, Fiber HTTP routers |
621
+ | **Polyglot Cross-Boundary Wiring** | Cross-language HTTP calls (`fetch`, `axios`, `HttpClient`, `requests`, `httpx`, `WebClient`, `RestTemplate`), cross-language gRPC calls (`stub.Method`, `client.MethodAsync`), canonical event normalization | Directed `CALLS_HTTP` and `CALLS_GRPC` graph edges connecting client callers and projects to server endpoints across boundaries; `RELATES_TO` unifying canonical events (`InvoiceCreated` โ†” `invoice-created` โ†” `invoice_created`) with `CONSUMES_EVENT` and `DISPATCHES` |
622
+
623
+ ---
624
+
625
+ ## ๐ŸŒ Polyglot Monorepo Graphs & Cross-Boundary Wiring
626
+
627
+ In modern enterprise architectures, services written in different programming languages interact over network boundaries via HTTP APIs, gRPC contracts, and distributed message brokers.
628
+
629
+ AKBO constructs a unified, multi-ecosystem **Codebase Knowledge Graph (CKG)** with **0 LLM tokens**, deterministically connecting callers, servers, publishers, and subscribers across language boundaries:
630
+
631
+ ```mermaid
632
+ flowchart LR
633
+ subgraph Frontend["TypeScript / Next.js"]
634
+ NEXT["fetch('/api/invoices')<br/><i>[HTTP Client]</i>"]
635
+ end
636
+
637
+ subgraph BackendAPI[".NET 9 ASP.NET Core"]
638
+ API["InvoicesController<br/>[HttpPost] CreateInvoice"]
639
+ BUS["MassTransit<br/>Publish&lt;InvoiceCreated&gt;"]
640
+ end
641
+
642
+ subgraph WorkerService["Java / Spring Boot"]
643
+ KAFKA["@KafkaListener<br/>topic = 'invoice-created'"]
644
+ JPA["InvoiceRepository.save()"]
645
+ end
646
+
647
+ subgraph AIService["Python / FastAPI & Celery"]
648
+ PY_EP["@app.post('/api/ai/audit')<br/>def audit_invoice(...)"]
649
+ CELERY["@celery.task<br/>invoice_created"]
650
+ end
651
+
652
+ NEXT -->|CALLS_HTTP| API
653
+ API -->|EXPOSES| BUS
654
+ BUS -->|DISPATCHES| KAFKA
655
+ BUS -->|DISPATCHES| CELERY
656
+ KAFKA -->|PERSISTS| JPA
657
+ API -.->|CALLS_HTTP| PY_EP
658
+ ```
659
+
660
+ ### Key Capabilities:
661
+ 1. **HTTP/REST Call Bridging (`CALLS_HTTP`)**:
662
+ - Detects client-side HTTP calls across languages: `fetch()`, `axios`, C# `HttpClient` (`GetAsync`, `PostAsync`), Python `requests`/`httpx`, and Java `WebClient`/`RestTemplate`.
663
+ - Supports wildcard and parameterized route matching (e.g. `fetch('/api/orders/${id}')` connects directly to `router.get('/api/orders/:id')`).
664
+ - Connects both the client caller node and the caller project node to the target server endpoint.
665
+ 2. **gRPC Cross-Language Linking (`CALLS_GRPC`)**:
666
+ - Matches Python stubs (`stub.CreateInvoice`), TypeScript clients (`client.CreateInvoice`), and Java stubs (`blockingStub.createInvoice`) to C# and Java service implementations (`*GrpcBase`, `*Grpc.*ImplBase`) via shared `.proto` definitions.
667
+ 3. **Canonical Event Matching (`RELATES_TO`)**:
668
+ - Unifies disparate naming conventions across languages:
669
+ - .NET: `InvoiceCreated` (PascalCase)
670
+ - Java / Kafka: `invoice-created` (kebab-case)
671
+ - Python / Celery: `invoice_created` (snake_case)
672
+ - Wires bidirectional `RELATES_TO` edges between message variants, allowing 2-hop neighborhood extraction (`akbo context`) to trace the entire lifecycle from producer to consumers across all languages in **0 tokens**.
673
+
674
+ ### Cross-Boundary Context Extraction:
675
+ ```bash
676
+ # Trace an endpoint and all upstream frontend callers + downstream services
677
+ akbo context "POST /api/invoices" -h 2 --json
678
+
679
+ # Trace an event across .NET publisher, Java Kafka consumer, and Python Celery worker
680
+ akbo context "InvoiceCreated" -h 2
681
+
682
+ # Grounded GraphRAG query tracing cross-language flows
683
+ akbo query "Trace the full lifecycle of an invoice from the Next.js frontend to background workers"
684
+ ```
685
+
686
+ ---
687
+
688
+ ## ๐Ÿข Enterprise Bounded Contexts (DDD Namespaced Central Hub)
689
+
690
+ In large enterprise repositories (e.g. 100+ microservice projects in a single monorepo), a flat `knowledge/index.yaml` causes context window bloat. AKBO addresses this with a two-tier **Namespaced Central Hub**:
691
+
692
+ ```
693
+ knowledge/
694
+ โ”œโ”€โ”€ index.yaml # Master Catalog Router (routes to domains)
695
+ โ”œโ”€โ”€ core/
696
+ โ”‚ โ”œโ”€โ”€ index.yaml # Core enterprise standards catalog
697
+ โ”‚ โ”œโ”€โ”€ ARCH-SYS-001.yaml
698
+ โ”‚ โ””โ”€โ”€ DEV-TS-001.yaml
699
+ โ””โ”€โ”€ domains/
700
+ โ”œโ”€โ”€ billing/
701
+ โ”‚ โ”œโ”€โ”€ index.yaml # Billing bounded context catalog
702
+ โ”‚ โ””โ”€โ”€ ARCH-BILLING-001.yaml
703
+ โ””โ”€โ”€ ordering/
704
+ โ”œโ”€โ”€ index.yaml # Ordering bounded context catalog
705
+ โ””โ”€โ”€ ARCH-ORDER-001.yaml
706
+ ```
707
+
708
+ ```bash
709
+ # 1. Harvest & generate enterprise core catalog (applies to all code)
710
+ akbo harvest . -o .akb/core-skeleton.json
711
+ akbo plan . --domain core
712
+ akbo generate . --domain core --clean
713
+
714
+ # 2. Harvest & generate a Bounded Context (scoped via applies_to)
715
+ akbo harvest src/Billing -o .akb/billing-skeleton.json
716
+ akbo plan src/Billing --domain billing
717
+ akbo generate src/Billing --domain billing --clean
718
+
719
+ # 3. Validate entire federated catalog hierarchy
720
+ akbo validate .
721
+ ```
722
+
723
+ ---
724
+
725
+ ## ๐Ÿ“‹ Knowledge Unit Standard Specification
726
+
727
+ Every knowledge unit is persisted as an atomic YAML file adhering to runtime Zod validation:
728
+
729
+ ```yaml
730
+ id: ARCH-SYS-001
731
+ type: architecture_standard
732
+ title: CLI Command Engine & Dependency Architecture
733
+ domain: architecture
734
+ status: approved
735
+ version: 1.1.0
736
+ authority:
737
+ level: official
738
+ confidence: high
739
+ owner:
740
+ team: core_architecture
741
+ applies_to:
742
+ - cli
743
+ - backend
744
+ - tooling
745
+ rule: "The CLI application must strictly operate as a native ES Module ('type': 'module') using NodeNext module resolution, requiring explicit '.js' file extensions on all relative TypeScript imports, top-level executable shebang bindings, dual CLI/MCP dispatch (akbo mcp / akbo-mcp), and machine-readable --json output modes."
746
+ do:
747
+ - Include '#!/usr/bin/env node' at line 1 of 'src/cli.ts' and load 'dotenv/config' at top-level initialization.
748
+ - Append explicit '.js' relative path extensions for all local module imports.
749
+ - Normalize cross-platform directory paths using path.resolve() and backslash normalization.
750
+ - Expose native Model Context Protocol (MCP) server over STDIO via 'akbo mcp [dir]' and executable binary alias 'akbo-mcp'.
751
+ - Support machine-readable '-j, --json' output flags across pipeline commands, suppressing console decorative banners.
752
+ dont:
753
+ - Do not use CommonJS require() or omit '.js' file extensions in relative import specifiers.
754
+ - Do not write un-normalized Windows-style path strings containing raw backslashes into target configuration files.
755
+ - Do not print chalk or decorative text to stdout when --json mode is activated.
756
+ reason: Explicit ES module resolution prevents module runtime errors in modern Node.js environments, path normalization ensures deterministic cross-platform execution (Windows vs POSIX), and dual CLI/MCP stdio interfaces allow autonomous AI agents to execute tools deterministically.
757
+ related_items:
758
+ - ARCH-GRAPH-001
759
+ - PROD-TOOL-001
760
+ ```
761
+
762
+ ---
763
+
764
+ ## ๐Ÿงช Testing & Verification
765
+
766
+ AKBO enforces strict quality gates using **Vitest** in single-pass ESM mode:
767
+
768
+ ```bash
769
+ # Run the complete test suite (194 tests across 32 test files)
770
+ npm test
771
+
772
+ # Run tests in watch mode during development
773
+ npx vitest
774
+
775
+ # Run CLI directly during development via tsx
776
+ npx tsx src/cli.ts --help
777
+ npx tsx src/cli.ts context ARCH-SYS-001 --json
778
+
779
+ # Build TypeScript
780
+ npm run build
781
+ ```
782
+
783
+ ---
784
+
785
+ ## ๐Ÿ“„ License
786
+
787
+ MIT ยฉ [akb-cli](LICENSE)