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.
- package/README.md +706 -2
- package/dist/catalog_store.d.ts +78 -0
- package/dist/catalog_store.js +375 -0
- package/dist/cleaner.d.ts +11 -0
- package/dist/cleaner.js +92 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1596 -0
- package/dist/extractors/base.d.ts +35 -0
- package/dist/extractors/base.js +17 -0
- package/dist/extractors/custom_extractor.d.ts +55 -0
- package/dist/extractors/custom_extractor.js +198 -0
- package/dist/extractors/dotnet_extractor.d.ts +11 -0
- package/dist/extractors/dotnet_extractor.js +579 -0
- package/dist/extractors/golang_extractor.d.ts +11 -0
- package/dist/extractors/golang_extractor.js +73 -0
- package/dist/extractors/index.d.ts +14 -0
- package/dist/extractors/index.js +30 -0
- package/dist/extractors/jvm_extractor.d.ts +11 -0
- package/dist/extractors/jvm_extractor.js +319 -0
- package/dist/extractors/node_extractor.d.ts +11 -0
- package/dist/extractors/node_extractor.js +306 -0
- package/dist/extractors/proto_graphql_extractor.d.ts +11 -0
- package/dist/extractors/proto_graphql_extractor.js +125 -0
- package/dist/extractors/python_extractor.d.ts +11 -0
- package/dist/extractors/python_extractor.js +298 -0
- package/dist/extractors/rust_extractor.d.ts +11 -0
- package/dist/extractors/rust_extractor.js +66 -0
- package/dist/graph_builder.d.ts +87 -0
- package/dist/graph_builder.js +1498 -0
- package/dist/harvester.d.ts +38 -0
- package/dist/harvester.js +461 -0
- package/dist/hook_generator.d.ts +26 -0
- package/dist/hook_generator.js +203 -0
- package/dist/importers/skill_importer.d.ts +43 -0
- package/dist/importers/skill_importer.js +470 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +17 -0
- package/dist/indexer.d.ts +19 -0
- package/dist/indexer.js +108 -0
- package/dist/init_service.d.ts +37 -0
- package/dist/init_service.js +246 -0
- package/dist/mcp_server.d.ts +10 -0
- package/dist/mcp_server.js +632 -0
- package/dist/pool_resolver.d.ts +40 -0
- package/dist/pool_resolver.js +84 -0
- package/dist/provider.d.ts +135 -0
- package/dist/provider.js +880 -0
- package/dist/query_service.d.ts +33 -0
- package/dist/query_service.js +161 -0
- package/dist/schema_generator.d.ts +236 -0
- package/dist/schema_generator.js +264 -0
- package/dist/standards_loader.d.ts +7 -0
- package/dist/standards_loader.js +33 -0
- package/dist/types.d.ts +265 -0
- package/dist/types.js +105 -0
- package/dist/unit_synthesizer.d.ts +22 -0
- package/dist/unit_synthesizer.js +196 -0
- package/dist/validator.d.ts +13 -0
- package/dist/validator.js +152 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +16 -0
- package/dist/watcher.d.ts +38 -0
- package/dist/watcher.js +132 -0
- package/package.json +56 -6
- package/schemas/index-schema.json +98 -0
- package/schemas/knowledge-unit.json +154 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import crypto from 'node:crypto';
|
|
4
|
+
export class KnowledgePoolResolver {
|
|
5
|
+
/**
|
|
6
|
+
* Resolves targetDir and poolDir using precedence:
|
|
7
|
+
* 1. Explicit argument (--pool / options.explicitPoolDir)
|
|
8
|
+
* 2. Environment variable AKBO_POOL_DIR
|
|
9
|
+
* 3. Upward directory walk from targetDir looking for knowledge/index.yaml, .akb/, or .git
|
|
10
|
+
* 4. Fallback: targetDir
|
|
11
|
+
*/
|
|
12
|
+
static resolve(targetDirInput = '.', options = {}) {
|
|
13
|
+
const targetDir = path.resolve(targetDirInput);
|
|
14
|
+
let poolDir;
|
|
15
|
+
let isExternalPool = false;
|
|
16
|
+
const envPool = options.overrideEnv !== undefined ? options.overrideEnv : process.env.AKBO_POOL_DIR;
|
|
17
|
+
if (options.explicitPoolDir && options.explicitPoolDir.trim().length > 0) {
|
|
18
|
+
poolDir = path.resolve(options.explicitPoolDir.trim());
|
|
19
|
+
isExternalPool = path.resolve(poolDir).toLowerCase() !== path.resolve(targetDir).toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
else if (envPool && envPool.trim().length > 0) {
|
|
22
|
+
poolDir = path.resolve(envPool.trim());
|
|
23
|
+
isExternalPool = path.resolve(poolDir).toLowerCase() !== path.resolve(targetDir).toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
else if (!fs.existsSync(targetDir)) {
|
|
26
|
+
poolDir = targetDir;
|
|
27
|
+
isExternalPool = false;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const discovered = this.findNearestPool(targetDir);
|
|
31
|
+
if (discovered) {
|
|
32
|
+
poolDir = discovered;
|
|
33
|
+
isExternalPool = path.resolve(poolDir).toLowerCase() !== path.resolve(targetDir).toLowerCase();
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
poolDir = targetDir;
|
|
37
|
+
isExternalPool = false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Canonicalize targetDir for cache keying (case-insensitive on Windows)
|
|
41
|
+
const normalizedTarget = targetDir.replace(/\\/g, '/').toLowerCase();
|
|
42
|
+
const hash8 = crypto.createHash('sha1').update(normalizedTarget).digest('hex').slice(0, 8);
|
|
43
|
+
const scopeSlug = path.basename(targetDir).replace(/[^a-zA-Z0-9_-]/g, '_').toLowerCase() || 'root';
|
|
44
|
+
const cacheDir = path.join(poolDir, '.akb', 'caches');
|
|
45
|
+
const cacheFile = path.join(cacheDir, `${scopeSlug}-${hash8}.json`);
|
|
46
|
+
return {
|
|
47
|
+
targetDir,
|
|
48
|
+
poolDir,
|
|
49
|
+
isExternalPool,
|
|
50
|
+
knowledgeDir: path.join(poolDir, 'knowledge'),
|
|
51
|
+
standardsFile: path.join(poolDir, '.akb', 'standards.yaml'),
|
|
52
|
+
customExtractorsFile: path.join(poolDir, '.akb', 'custom-extractors.yaml'),
|
|
53
|
+
cacheDir,
|
|
54
|
+
cacheFile
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Traverses upward from startDir seeking an existing knowledge/ or .akb/ directory.
|
|
59
|
+
*/
|
|
60
|
+
static findNearestPool(startDir) {
|
|
61
|
+
let current = path.resolve(startDir);
|
|
62
|
+
while (true) {
|
|
63
|
+
const hasKnowledge = fs.existsSync(path.join(current, 'knowledge'));
|
|
64
|
+
const hasAkb = fs.existsSync(path.join(current, '.akb'));
|
|
65
|
+
if (hasKnowledge || hasAkb) {
|
|
66
|
+
return current;
|
|
67
|
+
}
|
|
68
|
+
const parent = path.dirname(current);
|
|
69
|
+
if (parent === current) {
|
|
70
|
+
break; // Root reached
|
|
71
|
+
}
|
|
72
|
+
current = parent;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Helper to ensure cache directory exists before writing cache files.
|
|
78
|
+
*/
|
|
79
|
+
static ensureCacheDir(config) {
|
|
80
|
+
if (!fs.existsSync(config.cacheDir)) {
|
|
81
|
+
fs.mkdirSync(config.cacheDir, { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export interface LLMProvider {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
generateJson<T>(prompt: string): Promise<T>;
|
|
4
|
+
}
|
|
5
|
+
export interface ProviderResolutionOptions {
|
|
6
|
+
provider?: string;
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
forceCli?: boolean;
|
|
11
|
+
forceAgy?: boolean;
|
|
12
|
+
initialRetryDelay?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolves an API key from explicit parameters, environment variables, or provider configuration.
|
|
16
|
+
* Fully supports multi-provider lookup (Gemini, OpenAI, Anthropic, DeepSeek, Groq, Ollama, generic).
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveApiKey(explicitKeyOrProvider?: string, explicitKeyIfProviderGiven?: string): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Checks if the Gemini CLI binary is available on PATH.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isGeminiCliAvailable(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the absolute path to the Antigravity CLI (agy) binary, checking PATH and common fallback locations.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAgyBinaryPath(): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if the Google Antigravity CLI (agy) binary is available on PATH or fallback locations.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isAgyCliAvailable(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Robustly extracts and parses JSON from LLM or CLI output.
|
|
33
|
+
* Handles markdown fences, preamble warnings, and trailing text.
|
|
34
|
+
*/
|
|
35
|
+
export declare function extractJson<T = any>(text: string): T;
|
|
36
|
+
/**
|
|
37
|
+
* Executes the Gemini CLI non-interactively using headless options.
|
|
38
|
+
*/
|
|
39
|
+
export declare function executeGeminiCli(prompt: string, model?: string, options?: {
|
|
40
|
+
timeoutMs?: number;
|
|
41
|
+
}): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Executes the Google Antigravity CLI (agy) non-interactively using headless options.
|
|
44
|
+
* Streams prompt via stdin using stream-json to prevent Windows command-line length limits (ENAMETOOLONG).
|
|
45
|
+
*/
|
|
46
|
+
export declare function executeAgyCli(prompt: string, model?: string, options?: {
|
|
47
|
+
timeoutMs?: number;
|
|
48
|
+
}): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Determines whether an error returned from Gemini API is transient and retryable.
|
|
51
|
+
* Non-retryable errors (e.g. 401 Unauthorized, 403 Forbidden, 404 Model Not Found, 400 Bad Request)
|
|
52
|
+
* fail fast immediately to avoid stalling execution.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isRetryableError(err: any): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Direct Gemini API provider using Node 20+ native fetch (zero third-party SDK dependencies).
|
|
57
|
+
*/
|
|
58
|
+
export declare class GeminiApiProvider implements LLMProvider {
|
|
59
|
+
readonly name = "gemini-api";
|
|
60
|
+
private apiKey;
|
|
61
|
+
private modelName;
|
|
62
|
+
private baseUrl;
|
|
63
|
+
private initialRetryDelay;
|
|
64
|
+
client: {
|
|
65
|
+
models: {
|
|
66
|
+
generateContent: (req: {
|
|
67
|
+
model?: string;
|
|
68
|
+
contents: string;
|
|
69
|
+
config?: any;
|
|
70
|
+
}) => Promise<{
|
|
71
|
+
text: string;
|
|
72
|
+
}>;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
constructor(apiKey: string, modelName?: string, initialRetryDelay?: number, baseUrl?: string);
|
|
76
|
+
generateJson<T>(prompt: string): Promise<T>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Direct OpenAI API provider supporting GPT-4o, GPT-4o-mini, o1, o3, etc.
|
|
80
|
+
*/
|
|
81
|
+
export declare class OpenAiApiProvider implements LLMProvider {
|
|
82
|
+
readonly name = "openai";
|
|
83
|
+
private apiKey;
|
|
84
|
+
private modelName;
|
|
85
|
+
private baseUrl;
|
|
86
|
+
private initialRetryDelay;
|
|
87
|
+
constructor(apiKey: string, modelName?: string, baseUrl?: string, initialRetryDelay?: number);
|
|
88
|
+
generateJson<T>(prompt: string): Promise<T>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Direct Anthropic API provider supporting Claude 3.5 Sonnet, Claude 3.7 Sonnet, Claude 3.5 Haiku, etc.
|
|
92
|
+
*/
|
|
93
|
+
export declare class AnthropicApiProvider implements LLMProvider {
|
|
94
|
+
readonly name = "anthropic";
|
|
95
|
+
private apiKey;
|
|
96
|
+
private modelName;
|
|
97
|
+
private baseUrl;
|
|
98
|
+
private initialRetryDelay;
|
|
99
|
+
constructor(apiKey: string, modelName?: string, baseUrl?: string, initialRetryDelay?: number);
|
|
100
|
+
generateJson<T>(prompt: string): Promise<T>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Universal OpenAI-compatible provider supporting DeepSeek, Groq, Mistral, Ollama, OpenRouter, and custom endpoints.
|
|
104
|
+
*/
|
|
105
|
+
export declare class OpenAiCompatibleProvider implements LLMProvider {
|
|
106
|
+
readonly name: string;
|
|
107
|
+
private apiKey;
|
|
108
|
+
private modelName;
|
|
109
|
+
private baseUrl;
|
|
110
|
+
private initialRetryDelay;
|
|
111
|
+
constructor(providerName: string, apiKey: string, modelName: string, baseUrl: string, initialRetryDelay?: number);
|
|
112
|
+
generateJson<T>(prompt: string): Promise<T>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* CLI provider delegating generation to the installed system Gemini CLI.
|
|
116
|
+
*/
|
|
117
|
+
export declare class GeminiCliProvider implements LLMProvider {
|
|
118
|
+
readonly name = "gemini-cli";
|
|
119
|
+
private modelName?;
|
|
120
|
+
constructor(modelName?: string);
|
|
121
|
+
generateJson<T>(prompt: string): Promise<T>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* CLI provider delegating generation to Google Antigravity CLI (agy).
|
|
125
|
+
*/
|
|
126
|
+
export declare class AgyCliProvider implements LLMProvider {
|
|
127
|
+
readonly name = "agy-cli";
|
|
128
|
+
private modelName?;
|
|
129
|
+
constructor(modelName?: string);
|
|
130
|
+
generateJson<T>(prompt: string): Promise<T>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Factory creating the appropriate LLMProvider based on configuration, model name, and available keys.
|
|
134
|
+
*/
|
|
135
|
+
export declare function createLLMProvider(options?: ProviderResolutionOptions): LLMProvider;
|