bilmem 0.1.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.
- package/README.md +439 -0
- package/dist/canonical-CglQQ0xc.d.ts +262 -0
- package/dist/cli/index.js +7601 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/index.d.ts +311 -0
- package/dist/core/index.js +1975 -0
- package/dist/core/index.js.map +1 -0
- package/dist/filesystem-B3qAej0l.d.ts +69 -0
- package/dist/index.d.ts +163 -0
- package/dist/index.js +7765 -0
- package/dist/index.js.map +1 -0
- package/dist/install/index.d.ts +373 -0
- package/dist/install/index.js +6632 -0
- package/dist/install/index.js.map +1 -0
- package/dist/jev/index.d.ts +32 -0
- package/dist/jev/index.js +269 -0
- package/dist/jev/index.js.map +1 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/index.js +5479 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/rules/index.d.ts +59 -0
- package/dist/rules/index.js +388 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/scanner/index.d.ts +169 -0
- package/dist/scanner/index.js +3829 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/search/index.d.ts +44 -0
- package/dist/search/index.js +301 -0
- package/dist/search/index.js.map +1 -0
- package/dist/stats/index.d.ts +60 -0
- package/dist/stats/index.js +1373 -0
- package/dist/stats/index.js.map +1 -0
- package/dist/storage/index.d.ts +82 -0
- package/dist/storage/index.js +1748 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/types-Nxq5Gzay.d.ts +390 -0
- package/package.json +71 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { S as Storage } from '../canonical-CglQQ0xc.js';
|
|
2
|
+
import '../types-Nxq5Gzay.js';
|
|
3
|
+
import '../search/index.js';
|
|
4
|
+
|
|
5
|
+
type InstallScope = 'project' | 'global';
|
|
6
|
+
interface InstallContext {
|
|
7
|
+
projectDir: string;
|
|
8
|
+
globalDir?: string;
|
|
9
|
+
scope: InstallScope;
|
|
10
|
+
bilmemCommand?: string;
|
|
11
|
+
bilmemArgs?: string[];
|
|
12
|
+
storage?: Storage;
|
|
13
|
+
}
|
|
14
|
+
interface DetectionResult {
|
|
15
|
+
detected: boolean;
|
|
16
|
+
confidence: 'high' | 'medium' | 'low';
|
|
17
|
+
reasons: string[];
|
|
18
|
+
supportedScopes: InstallScope[];
|
|
19
|
+
}
|
|
20
|
+
interface InstallState {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
detected: boolean;
|
|
24
|
+
scope: InstallScope;
|
|
25
|
+
mcpConfigured: boolean;
|
|
26
|
+
mcpCommandMatches: boolean;
|
|
27
|
+
instructionInstalled: boolean;
|
|
28
|
+
instructionVersion?: number;
|
|
29
|
+
currentInstructionVersion: number;
|
|
30
|
+
configPath: string;
|
|
31
|
+
instructionPath: string;
|
|
32
|
+
details?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
interface InstallOptions {
|
|
35
|
+
scope: InstallScope;
|
|
36
|
+
dryRun?: boolean;
|
|
37
|
+
force?: boolean;
|
|
38
|
+
}
|
|
39
|
+
interface InstallResult {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
success: boolean;
|
|
43
|
+
scope: InstallScope;
|
|
44
|
+
mcpChanged: boolean;
|
|
45
|
+
instructionChanged: boolean;
|
|
46
|
+
projectInitialized: boolean;
|
|
47
|
+
dryRun?: boolean;
|
|
48
|
+
message?: string;
|
|
49
|
+
warnings?: string[];
|
|
50
|
+
actionsTaken: string[];
|
|
51
|
+
}
|
|
52
|
+
interface UninstallOptions {
|
|
53
|
+
scope: InstallScope;
|
|
54
|
+
dryRun?: boolean;
|
|
55
|
+
}
|
|
56
|
+
interface UninstallResult {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
success: boolean;
|
|
60
|
+
scope: InstallScope;
|
|
61
|
+
mcpRemoved: boolean;
|
|
62
|
+
instructionRemoved: boolean;
|
|
63
|
+
dryRun?: boolean;
|
|
64
|
+
message?: string;
|
|
65
|
+
warnings?: string[];
|
|
66
|
+
actionsTaken: string[];
|
|
67
|
+
}
|
|
68
|
+
interface VerifyResult {
|
|
69
|
+
valid: boolean;
|
|
70
|
+
mcpValid: boolean;
|
|
71
|
+
instructionValid: boolean;
|
|
72
|
+
commandResolvable: boolean;
|
|
73
|
+
issues: string[];
|
|
74
|
+
recommendations: string[];
|
|
75
|
+
}
|
|
76
|
+
interface AgentInstaller {
|
|
77
|
+
readonly id: string;
|
|
78
|
+
readonly name: string;
|
|
79
|
+
readonly supportedScopes: InstallScope[];
|
|
80
|
+
detect(context: InstallContext): Promise<DetectionResult>;
|
|
81
|
+
inspect(context: InstallContext): Promise<InstallState>;
|
|
82
|
+
install(context: InstallContext, options: InstallOptions): Promise<InstallResult>;
|
|
83
|
+
uninstall(context: InstallContext, options: UninstallOptions): Promise<UninstallResult>;
|
|
84
|
+
verify(context: InstallContext): Promise<VerifyResult>;
|
|
85
|
+
}
|
|
86
|
+
interface IntegrationRecord {
|
|
87
|
+
scope: InstallScope;
|
|
88
|
+
mcp: boolean;
|
|
89
|
+
mcpConfigPath?: string;
|
|
90
|
+
instructions: boolean;
|
|
91
|
+
instructionPath?: string;
|
|
92
|
+
version: number;
|
|
93
|
+
installedAt: string;
|
|
94
|
+
updatedAt?: string;
|
|
95
|
+
}
|
|
96
|
+
interface IntegrationsMetadata {
|
|
97
|
+
version: number;
|
|
98
|
+
integrations: Record<string, IntegrationRecord>;
|
|
99
|
+
}
|
|
100
|
+
interface CoreDoctorReport {
|
|
101
|
+
storage: {
|
|
102
|
+
initialized: boolean;
|
|
103
|
+
path: string;
|
|
104
|
+
status: 'ok' | 'error' | 'warning';
|
|
105
|
+
details?: string;
|
|
106
|
+
};
|
|
107
|
+
knowledge: {
|
|
108
|
+
count: number;
|
|
109
|
+
status: 'ok' | 'warning';
|
|
110
|
+
details?: string;
|
|
111
|
+
};
|
|
112
|
+
searchIndex: {
|
|
113
|
+
status: 'ok' | 'warning' | 'error';
|
|
114
|
+
details?: string;
|
|
115
|
+
};
|
|
116
|
+
mcpRuntime: {
|
|
117
|
+
status: 'ok' | 'warning' | 'error';
|
|
118
|
+
details?: string;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
interface AgentDoctorReport {
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
detected: boolean;
|
|
125
|
+
scope: InstallScope;
|
|
126
|
+
mcp: {
|
|
127
|
+
status: 'ok' | 'missing' | 'outdated' | 'error';
|
|
128
|
+
details?: string;
|
|
129
|
+
};
|
|
130
|
+
instructions: {
|
|
131
|
+
status: 'ok' | 'missing' | 'outdated' | 'none';
|
|
132
|
+
details?: string;
|
|
133
|
+
};
|
|
134
|
+
command: {
|
|
135
|
+
status: 'ok' | 'warning' | 'error';
|
|
136
|
+
details?: string;
|
|
137
|
+
};
|
|
138
|
+
configPath: string;
|
|
139
|
+
instructionPath: string;
|
|
140
|
+
}
|
|
141
|
+
interface DoctorReport {
|
|
142
|
+
core: CoreDoctorReport;
|
|
143
|
+
agents: AgentDoctorReport[];
|
|
144
|
+
issuesCount: number;
|
|
145
|
+
canFix: boolean;
|
|
146
|
+
}
|
|
147
|
+
interface DoctorFixResult {
|
|
148
|
+
coreFixed: string[];
|
|
149
|
+
agentsFixed: Record<string, string[]>;
|
|
150
|
+
dryRun: boolean;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare const CURRENT_INTEGRATION_VERSION = 1;
|
|
154
|
+
declare const BILMEM_START_MARKER = "<!-- bilmem:start -->";
|
|
155
|
+
declare const BILMEM_END_MARKER = "<!-- bilmem:end -->";
|
|
156
|
+
/**
|
|
157
|
+
* Returns the minimal, token-efficient agent instruction snippet.
|
|
158
|
+
*/
|
|
159
|
+
declare function getAgentInstructionText(version?: number): string;
|
|
160
|
+
/**
|
|
161
|
+
* Extracts the installed integration version from markdown content, or null if none.
|
|
162
|
+
*/
|
|
163
|
+
declare function extractInstructionVersion(content: string): number | null;
|
|
164
|
+
/**
|
|
165
|
+
* Checks whether content contains a managed Bilmem instruction block.
|
|
166
|
+
*/
|
|
167
|
+
declare function hasBilmemInstruction(content: string): boolean;
|
|
168
|
+
|
|
169
|
+
interface JsonReadResult {
|
|
170
|
+
exists: boolean;
|
|
171
|
+
data?: any;
|
|
172
|
+
raw?: string;
|
|
173
|
+
error?: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Atomically writes content to a file via a temporary file and rename.
|
|
177
|
+
*/
|
|
178
|
+
declare function writeAtomic(filePath: string, content: string): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Safely reads and parses a JSON file without throwing on missing file.
|
|
181
|
+
* Returns error string if JSON syntax is malformed.
|
|
182
|
+
*/
|
|
183
|
+
declare function safeReadJson(filePath: string): Promise<JsonReadResult>;
|
|
184
|
+
/**
|
|
185
|
+
* Safely updates an MCP JSON configuration file by adding/updating the "bilmem" entry
|
|
186
|
+
* under "mcpServers", preserving all existing top-level keys and other MCP servers.
|
|
187
|
+
*/
|
|
188
|
+
declare function updateMcpJsonConfig(filePath: string, bilmemCommand?: string, bilmemArgs?: string[], dryRun?: boolean): Promise<{
|
|
189
|
+
changed: boolean;
|
|
190
|
+
created: boolean;
|
|
191
|
+
originalExisted: boolean;
|
|
192
|
+
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Safely removes the "bilmem" entry from an MCP JSON configuration file,
|
|
195
|
+
* preserving all other settings and servers.
|
|
196
|
+
*/
|
|
197
|
+
declare function removeMcpJsonConfig(filePath: string, dryRun?: boolean): Promise<{
|
|
198
|
+
removed: boolean;
|
|
199
|
+
fileDeleted: boolean;
|
|
200
|
+
}>;
|
|
201
|
+
/**
|
|
202
|
+
* Safely inserts or updates the managed Bilmem instruction block in a markdown file.
|
|
203
|
+
* Preserves all surrounding content.
|
|
204
|
+
*/
|
|
205
|
+
declare function updateMarkdownInstructionFile(filePath: string, desiredBlock?: string, dryRun?: boolean): Promise<{
|
|
206
|
+
changed: boolean;
|
|
207
|
+
created: boolean;
|
|
208
|
+
originalExisted: boolean;
|
|
209
|
+
}>;
|
|
210
|
+
/**
|
|
211
|
+
* Safely removes only the managed Bilmem instruction block from a markdown file.
|
|
212
|
+
* Preserves all surrounding user content. If the file contains only the Bilmem block,
|
|
213
|
+
* removes the file.
|
|
214
|
+
*/
|
|
215
|
+
declare function removeMarkdownInstructionFile(filePath: string, dryRun?: boolean): Promise<{
|
|
216
|
+
removed: boolean;
|
|
217
|
+
fileDeleted: boolean;
|
|
218
|
+
}>;
|
|
219
|
+
/**
|
|
220
|
+
* Checks if a file or directory exists.
|
|
221
|
+
*/
|
|
222
|
+
declare function pathExists(p: string): Promise<boolean>;
|
|
223
|
+
/**
|
|
224
|
+
* Fast cross-platform check whether a command executable is available in PATH.
|
|
225
|
+
*/
|
|
226
|
+
declare function isExecutableInPath(command: string): Promise<boolean>;
|
|
227
|
+
|
|
228
|
+
declare function getIntegrationsFilePath(rootDir: string): string;
|
|
229
|
+
/**
|
|
230
|
+
* Loads the current integrations metadata from .bilmem/integrations.json.
|
|
231
|
+
*/
|
|
232
|
+
declare function loadIntegrationsMetadata(rootDir: string): Promise<IntegrationsMetadata>;
|
|
233
|
+
/**
|
|
234
|
+
* Saves integrations metadata to .bilmem/integrations.json.
|
|
235
|
+
*/
|
|
236
|
+
declare function saveIntegrationsMetadata(rootDir: string, meta: IntegrationsMetadata, dryRun?: boolean): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Records or updates an agent integration in .bilmem/integrations.json.
|
|
239
|
+
*/
|
|
240
|
+
declare function recordIntegration(rootDir: string, agentId: string, record: IntegrationRecord, dryRun?: boolean): Promise<void>;
|
|
241
|
+
/**
|
|
242
|
+
* Removes an agent integration record from .bilmem/integrations.json.
|
|
243
|
+
*/
|
|
244
|
+
declare function removeIntegration(rootDir: string, agentId: string, dryRun?: boolean): Promise<void>;
|
|
245
|
+
/**
|
|
246
|
+
* Retrieves the integration record for a specific agent.
|
|
247
|
+
*/
|
|
248
|
+
declare function getIntegrationRecord(rootDir: string, agentId: string): Promise<IntegrationRecord | undefined>;
|
|
249
|
+
|
|
250
|
+
declare abstract class BaseAgentAdapter implements AgentInstaller {
|
|
251
|
+
abstract readonly id: string;
|
|
252
|
+
abstract readonly name: string;
|
|
253
|
+
readonly supportedScopes: InstallScope[];
|
|
254
|
+
abstract resolveConfigPath(context: InstallContext): string;
|
|
255
|
+
abstract resolveInstructionPath(context: InstallContext): string;
|
|
256
|
+
abstract detect(context: InstallContext): Promise<DetectionResult>;
|
|
257
|
+
inspect(context: InstallContext): Promise<InstallState>;
|
|
258
|
+
install(context: InstallContext, options: InstallOptions): Promise<InstallResult>;
|
|
259
|
+
uninstall(context: InstallContext, options: UninstallOptions): Promise<UninstallResult>;
|
|
260
|
+
verify(context: InstallContext): Promise<VerifyResult>;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
declare class CursorAdapter extends BaseAgentAdapter {
|
|
264
|
+
readonly id = "cursor";
|
|
265
|
+
readonly name = "Cursor";
|
|
266
|
+
resolveConfigPath(context: InstallContext): string;
|
|
267
|
+
resolveInstructionPath(context: InstallContext): string;
|
|
268
|
+
detect(context: InstallContext): Promise<DetectionResult>;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
declare class ClaudeAdapter extends BaseAgentAdapter {
|
|
272
|
+
readonly id = "claude";
|
|
273
|
+
readonly name = "Claude Code";
|
|
274
|
+
resolveConfigPath(context: InstallContext): string;
|
|
275
|
+
resolveInstructionPath(context: InstallContext): string;
|
|
276
|
+
detect(context: InstallContext): Promise<DetectionResult>;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
declare class CodexAdapter extends BaseAgentAdapter {
|
|
280
|
+
readonly id = "codex";
|
|
281
|
+
readonly name = "Codex";
|
|
282
|
+
resolveConfigPath(context: InstallContext): string;
|
|
283
|
+
resolveInstructionPath(context: InstallContext): string;
|
|
284
|
+
detect(context: InstallContext): Promise<DetectionResult>;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
declare class GeminiAdapter extends BaseAgentAdapter {
|
|
288
|
+
readonly id = "gemini";
|
|
289
|
+
readonly name = "Gemini CLI";
|
|
290
|
+
resolveConfigPath(context: InstallContext): string;
|
|
291
|
+
resolveInstructionPath(context: InstallContext): string;
|
|
292
|
+
detect(context: InstallContext): Promise<DetectionResult>;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
declare function getAllAdapters(): AgentInstaller[];
|
|
296
|
+
declare function getAdapter(id: string): AgentInstaller | undefined;
|
|
297
|
+
interface DetectedAgent {
|
|
298
|
+
adapter: AgentInstaller;
|
|
299
|
+
detection: DetectionResult;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Runs detection across all registered adapters deterministically and cheaply.
|
|
303
|
+
*/
|
|
304
|
+
declare function detectAgents(context: InstallContext): Promise<DetectedAgent[]>;
|
|
305
|
+
|
|
306
|
+
declare function runDoctor(context: InstallContext): Promise<DoctorReport>;
|
|
307
|
+
declare function runDoctorFix(context: InstallContext, dryRun?: boolean): Promise<DoctorFixResult>;
|
|
308
|
+
|
|
309
|
+
declare function formatInstallResult(results: InstallResult[], scope: InstallScope, projectDir: string, dryRun?: boolean): string;
|
|
310
|
+
declare function formatUninstallResult(result: UninstallResult, dryRun?: boolean): string;
|
|
311
|
+
declare function formatDoctorReport(report: DoctorReport): string;
|
|
312
|
+
declare function formatDoctorFixResult(fixed: DoctorFixResult): string;
|
|
313
|
+
|
|
314
|
+
interface CliInstallOptions {
|
|
315
|
+
detected?: boolean;
|
|
316
|
+
all?: boolean;
|
|
317
|
+
yes?: boolean;
|
|
318
|
+
global?: boolean;
|
|
319
|
+
dryRun?: boolean;
|
|
320
|
+
force?: boolean;
|
|
321
|
+
projectDir?: string;
|
|
322
|
+
globalDir?: string;
|
|
323
|
+
bilmemCommand?: string;
|
|
324
|
+
bilmemArgs?: string[];
|
|
325
|
+
}
|
|
326
|
+
interface CliUninstallOptions {
|
|
327
|
+
global?: boolean;
|
|
328
|
+
dryRun?: boolean;
|
|
329
|
+
projectDir?: string;
|
|
330
|
+
globalDir?: string;
|
|
331
|
+
}
|
|
332
|
+
interface CliDoctorOptions {
|
|
333
|
+
fix?: boolean;
|
|
334
|
+
dryRun?: boolean;
|
|
335
|
+
global?: boolean;
|
|
336
|
+
projectDir?: string;
|
|
337
|
+
globalDir?: string;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Creates an InstallContext from CLI arguments.
|
|
341
|
+
*/
|
|
342
|
+
declare function createInstallContext(options: {
|
|
343
|
+
scope?: InstallScope;
|
|
344
|
+
global?: boolean;
|
|
345
|
+
projectDir?: string;
|
|
346
|
+
globalDir?: string;
|
|
347
|
+
bilmemCommand?: string;
|
|
348
|
+
bilmemArgs?: string[];
|
|
349
|
+
}): InstallContext;
|
|
350
|
+
/**
|
|
351
|
+
* Main handler for `bilmem install [target]`.
|
|
352
|
+
*/
|
|
353
|
+
declare function handleInstallCommand(target?: string, options?: CliInstallOptions): Promise<{
|
|
354
|
+
success: boolean;
|
|
355
|
+
results: InstallResult[];
|
|
356
|
+
message?: string;
|
|
357
|
+
}>;
|
|
358
|
+
/**
|
|
359
|
+
* Main handler for `bilmem uninstall <target>`.
|
|
360
|
+
*/
|
|
361
|
+
declare function handleUninstallCommand(target: string, options?: CliUninstallOptions): Promise<{
|
|
362
|
+
success: boolean;
|
|
363
|
+
result: UninstallResult;
|
|
364
|
+
}>;
|
|
365
|
+
/**
|
|
366
|
+
* Main handler for `bilmem doctor`.
|
|
367
|
+
*/
|
|
368
|
+
declare function handleDoctorCommand(options?: CliDoctorOptions): Promise<{
|
|
369
|
+
report: DoctorReport;
|
|
370
|
+
fixed?: DoctorFixResult;
|
|
371
|
+
}>;
|
|
372
|
+
|
|
373
|
+
export { type AgentDoctorReport, type AgentInstaller, BILMEM_END_MARKER, BILMEM_START_MARKER, BaseAgentAdapter, CURRENT_INTEGRATION_VERSION, ClaudeAdapter, type CliDoctorOptions, type CliInstallOptions, type CliUninstallOptions, CodexAdapter, type CoreDoctorReport, CursorAdapter, type DetectedAgent, type DetectionResult, type DoctorFixResult, type DoctorReport, GeminiAdapter, type InstallContext, type InstallOptions, type InstallResult, type InstallScope, type InstallState, type IntegrationRecord, type IntegrationsMetadata, type JsonReadResult, type UninstallOptions, type UninstallResult, type VerifyResult, createInstallContext, detectAgents, extractInstructionVersion, formatDoctorFixResult, formatDoctorReport, formatInstallResult, formatUninstallResult, getAdapter, getAgentInstructionText, getAllAdapters, getIntegrationRecord, getIntegrationsFilePath, handleDoctorCommand, handleInstallCommand, handleUninstallCommand, hasBilmemInstruction, isExecutableInPath, loadIntegrationsMetadata, pathExists, recordIntegration, removeIntegration, removeMarkdownInstructionFile, removeMcpJsonConfig, runDoctor, runDoctorFix, safeReadJson, saveIntegrationsMetadata, updateMarkdownInstructionFile, updateMcpJsonConfig, writeAtomic };
|