compound-agent 1.5.0 → 1.6.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/CHANGELOG.md +61 -1
- package/README.md +53 -40
- package/dist/cli.js +2754 -1923
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +149 -15
- package/dist/index.js +1984 -1368
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2559,6 +2559,8 @@ declare function readLessons(repoRoot: string, options?: ReadLessonsOptions): Pr
|
|
|
2559
2559
|
interface CachedEmbeddingData {
|
|
2560
2560
|
embedding: Buffer;
|
|
2561
2561
|
contentHash: string;
|
|
2562
|
+
embeddingInsight?: Buffer | null;
|
|
2563
|
+
contentHashInsight?: string | null;
|
|
2562
2564
|
}
|
|
2563
2565
|
|
|
2564
2566
|
/**
|
|
@@ -2691,7 +2693,11 @@ declare const MODEL_URI = "hf:ggml-org/embeddinggemma-300M-qat-q4_0-GGUF/embeddi
|
|
|
2691
2693
|
*/
|
|
2692
2694
|
declare const MODEL_FILENAME = "hf_ggml-org_embeddinggemma-300M-qat-Q4_0.gguf";
|
|
2693
2695
|
/**
|
|
2694
|
-
* Check if the embedding model is available locally.
|
|
2696
|
+
* Check if the embedding model is available locally (fs existence only).
|
|
2697
|
+
*
|
|
2698
|
+
* Use this for cheap pre-flight checks (e.g. spawnBackgroundEmbed) where
|
|
2699
|
+
* failure is handled gracefully. Use {@link isModelUsable} when you need
|
|
2700
|
+
* runtime verification that the model can actually initialize.
|
|
2695
2701
|
*
|
|
2696
2702
|
* @returns true if model file exists
|
|
2697
2703
|
*/
|
|
@@ -2722,6 +2728,12 @@ type UsabilityResult = {
|
|
|
2722
2728
|
* 4. Attempts to create embedding context
|
|
2723
2729
|
* 5. Cleans up all resources after check
|
|
2724
2730
|
*
|
|
2731
|
+
* WARNING: This function allocates ~150MB of native C++ memory for the probe.
|
|
2732
|
+
* NEVER call at module top-level in test files. When dispose() SIGABRTs in
|
|
2733
|
+
* vitest workers, that memory is permanently leaked. For test skip-gating,
|
|
2734
|
+
* use isModelAvailable() instead (zero native allocation). Reserve this
|
|
2735
|
+
* function for production code paths where runtime verification is needed.
|
|
2736
|
+
*
|
|
2725
2737
|
* @returns UsabilityResult with usable status and actionable error if failed
|
|
2726
2738
|
*/
|
|
2727
2739
|
declare function isModelUsable(): Promise<UsabilityResult>;
|
|
@@ -2841,7 +2853,7 @@ declare function unloadEmbedding(): void;
|
|
|
2841
2853
|
* Subsequent calls use the cached model and complete in milliseconds.
|
|
2842
2854
|
*
|
|
2843
2855
|
* @param text - The text to embed
|
|
2844
|
-
* @returns A 768-dimensional vector
|
|
2856
|
+
* @returns A 768-dimensional Float32Array vector
|
|
2845
2857
|
* @throws Error if model download fails
|
|
2846
2858
|
*
|
|
2847
2859
|
* @example
|
|
@@ -2856,7 +2868,7 @@ declare function unloadEmbedding(): void;
|
|
|
2856
2868
|
* @see {@link embedTexts} for batch embedding
|
|
2857
2869
|
* @see {@link unloadEmbedding} for releasing memory
|
|
2858
2870
|
*/
|
|
2859
|
-
declare function embedText(text: string): Promise<
|
|
2871
|
+
declare function embedText(text: string): Promise<Float32Array>;
|
|
2860
2872
|
/**
|
|
2861
2873
|
* Embed multiple texts into vectors.
|
|
2862
2874
|
*
|
|
@@ -2884,7 +2896,7 @@ declare function embedText(text: string): Promise<number[]>;
|
|
|
2884
2896
|
* @see {@link embedText} for single text embedding
|
|
2885
2897
|
* @see {@link unloadEmbedding} for releasing memory
|
|
2886
2898
|
*/
|
|
2887
|
-
declare function embedTexts(texts: string[]): Promise<
|
|
2899
|
+
declare function embedTexts(texts: string[]): Promise<Float32Array[]>;
|
|
2888
2900
|
|
|
2889
2901
|
/**
|
|
2890
2902
|
* Multi-factor memory item ranking system
|
|
@@ -2948,8 +2960,9 @@ interface NoveltyOptions {
|
|
|
2948
2960
|
threshold?: number;
|
|
2949
2961
|
}
|
|
2950
2962
|
/**
|
|
2951
|
-
* Check if an insight is novel (not a duplicate of existing lessons).
|
|
2952
|
-
* Uses
|
|
2963
|
+
* Check if an insight is novel (not a near-duplicate of existing lessons).
|
|
2964
|
+
* Uses semantic embeddings with cosine similarity.
|
|
2965
|
+
* Falls back to novel: true when model is unavailable or on error.
|
|
2953
2966
|
*/
|
|
2954
2967
|
declare function isNovel(repoRoot: string, insight: string, options?: NoveltyOptions): Promise<NoveltyResult>;
|
|
2955
2968
|
/** Result of specificity check */
|
|
@@ -3270,6 +3283,8 @@ interface IndexOptions {
|
|
|
3270
3283
|
force?: boolean;
|
|
3271
3284
|
/** Directory to index (default: 'docs') */
|
|
3272
3285
|
docsDir?: string;
|
|
3286
|
+
/** Embed chunks after indexing (default: false) */
|
|
3287
|
+
embed?: boolean;
|
|
3273
3288
|
}
|
|
3274
3289
|
interface IndexResult {
|
|
3275
3290
|
filesIndexed: number;
|
|
@@ -3277,6 +3292,7 @@ interface IndexResult {
|
|
|
3277
3292
|
filesErrored: number;
|
|
3278
3293
|
chunksCreated: number;
|
|
3279
3294
|
chunksDeleted: number;
|
|
3295
|
+
chunksEmbedded: number;
|
|
3280
3296
|
durationMs: number;
|
|
3281
3297
|
}
|
|
3282
3298
|
/**
|
|
@@ -3310,6 +3326,124 @@ declare function searchKnowledgeVector(repoRoot: string, query: string, options?
|
|
|
3310
3326
|
*/
|
|
3311
3327
|
declare function searchKnowledge(repoRoot: string, query: string, options?: KnowledgeSearchOptions): Promise<GenericScoredItem<KnowledgeChunk>[]>;
|
|
3312
3328
|
|
|
3329
|
+
/**
|
|
3330
|
+
* Core embedding function for knowledge chunks.
|
|
3331
|
+
*
|
|
3332
|
+
* Embeds unembedded (or all) knowledge chunks using the local embedding model.
|
|
3333
|
+
* Uses batch embedding and transactional writes for performance.
|
|
3334
|
+
*/
|
|
3335
|
+
interface EmbedChunksOptions {
|
|
3336
|
+
/** Only embed chunks with no embedding (default: true) */
|
|
3337
|
+
onlyMissing?: boolean;
|
|
3338
|
+
}
|
|
3339
|
+
interface EmbedChunksResult {
|
|
3340
|
+
chunksEmbedded: number;
|
|
3341
|
+
chunksSkipped: number;
|
|
3342
|
+
durationMs: number;
|
|
3343
|
+
}
|
|
3344
|
+
/**
|
|
3345
|
+
* Count chunks that have no embedding stored.
|
|
3346
|
+
* @param repoRoot - Absolute path to repository root
|
|
3347
|
+
*/
|
|
3348
|
+
declare function getUnembeddedChunkCount(repoRoot: string): number;
|
|
3349
|
+
/**
|
|
3350
|
+
* Embed knowledge chunks using the local embedding model.
|
|
3351
|
+
*
|
|
3352
|
+
* Processes chunks in batches of BATCH_SIZE for efficient embedding and
|
|
3353
|
+
* wraps each batch's DB writes in a transaction (1 fsync per batch).
|
|
3354
|
+
*
|
|
3355
|
+
* @param repoRoot - Absolute path to repository root
|
|
3356
|
+
* @param options - Embedding options
|
|
3357
|
+
* @returns Stats about the embedding run
|
|
3358
|
+
*/
|
|
3359
|
+
declare function embedChunks(repoRoot: string, options?: EmbedChunksOptions): Promise<EmbedChunksResult>;
|
|
3360
|
+
|
|
3361
|
+
/**
|
|
3362
|
+
* PID-based lock file for embedding processes.
|
|
3363
|
+
*
|
|
3364
|
+
* Prevents concurrent embedding when background embed (ca init/setup)
|
|
3365
|
+
* and post-commit hook run simultaneously.
|
|
3366
|
+
*
|
|
3367
|
+
* Lock file: {repoRoot}/.claude/.cache/embed.lock
|
|
3368
|
+
* Content: { pid: number, startedAt: string } (ISO timestamp)
|
|
3369
|
+
*/
|
|
3370
|
+
interface LockAcquired {
|
|
3371
|
+
acquired: true;
|
|
3372
|
+
release: () => void;
|
|
3373
|
+
}
|
|
3374
|
+
interface LockBusy {
|
|
3375
|
+
acquired: false;
|
|
3376
|
+
holder: number;
|
|
3377
|
+
}
|
|
3378
|
+
type LockResult = LockAcquired | LockBusy;
|
|
3379
|
+
/**
|
|
3380
|
+
* Acquire the embed lock for this process.
|
|
3381
|
+
*
|
|
3382
|
+
* Uses writeFileSync with 'wx' flag for atomic exclusive creation.
|
|
3383
|
+
* On EEXIST: reads holder PID and checks staleness via process.kill(pid, 0).
|
|
3384
|
+
* If stale (holder dead): overwrites lock. If alive: returns acquired: false.
|
|
3385
|
+
*/
|
|
3386
|
+
declare function acquireEmbedLock(repoRoot: string): LockResult;
|
|
3387
|
+
/** Check if an embed lock is currently held by a live process. */
|
|
3388
|
+
declare function isEmbedLocked(repoRoot: string): boolean;
|
|
3389
|
+
|
|
3390
|
+
/**
|
|
3391
|
+
* Embedding status file: tracks state of background embedding process.
|
|
3392
|
+
*
|
|
3393
|
+
* Status file lives at {repoRoot}/.claude/.cache/embed-status.json
|
|
3394
|
+
*/
|
|
3395
|
+
type EmbedStatus = {
|
|
3396
|
+
state: 'idle';
|
|
3397
|
+
} | {
|
|
3398
|
+
state: 'running';
|
|
3399
|
+
startedAt: string;
|
|
3400
|
+
} | {
|
|
3401
|
+
state: 'completed';
|
|
3402
|
+
chunksEmbedded: number;
|
|
3403
|
+
completedAt: string;
|
|
3404
|
+
durationMs: number;
|
|
3405
|
+
} | {
|
|
3406
|
+
state: 'failed';
|
|
3407
|
+
error: string;
|
|
3408
|
+
durationMs: number;
|
|
3409
|
+
};
|
|
3410
|
+
/** Write embedding status to disk. Creates parent directories if needed. */
|
|
3411
|
+
declare function writeEmbedStatus(repoRoot: string, status: EmbedStatus): void;
|
|
3412
|
+
/** Read embedding status from disk. Returns null on missing file or parse error. */
|
|
3413
|
+
declare function readEmbedStatus(repoRoot: string): EmbedStatus | null;
|
|
3414
|
+
|
|
3415
|
+
/**
|
|
3416
|
+
* Background embedding: spawn a detached worker or run embedding in-process.
|
|
3417
|
+
*
|
|
3418
|
+
* spawnBackgroundEmbed(repoRoot) - spawns detached child process (sync, non-blocking)
|
|
3419
|
+
* runBackgroundEmbed(repoRoot) - worker entry point that does the actual embedding
|
|
3420
|
+
*/
|
|
3421
|
+
interface SpawnEmbedResult {
|
|
3422
|
+
spawned: boolean;
|
|
3423
|
+
reason?: string;
|
|
3424
|
+
pid?: number;
|
|
3425
|
+
}
|
|
3426
|
+
/**
|
|
3427
|
+
* Spawn a detached background process to embed chunks.
|
|
3428
|
+
* Synchronous -- fires and forgets.
|
|
3429
|
+
*
|
|
3430
|
+
* Pre-flight checks (lock, model, count) are advisory only. The worker
|
|
3431
|
+
* acquires its own lock, so TOCTOU here cannot cause double-embedding --
|
|
3432
|
+
* at worst we spawn a worker that exits immediately.
|
|
3433
|
+
*/
|
|
3434
|
+
declare function spawnBackgroundEmbed(repoRoot: string): SpawnEmbedResult;
|
|
3435
|
+
/**
|
|
3436
|
+
* Worker entry point: acquire lock, embed chunks, write status, clean up.
|
|
3437
|
+
*/
|
|
3438
|
+
declare function runBackgroundEmbed(repoRoot: string): Promise<void>;
|
|
3439
|
+
/**
|
|
3440
|
+
* Index docs/ and spawn background embedding if docs/ exists.
|
|
3441
|
+
* Shared helper for init and setup commands.
|
|
3442
|
+
*
|
|
3443
|
+
* @returns SpawnEmbedResult or null if docs/ doesn't exist
|
|
3444
|
+
*/
|
|
3445
|
+
declare function indexAndSpawnEmbed(repoRoot: string): Promise<SpawnEmbedResult | null>;
|
|
3446
|
+
|
|
3313
3447
|
/**
|
|
3314
3448
|
* Prime command - Context recovery for Claude Code with Beads-style trust language.
|
|
3315
3449
|
*
|
|
@@ -3343,14 +3477,14 @@ declare const AuditFindingSchema: z.ZodObject<{
|
|
|
3343
3477
|
}, "strip", z.ZodTypeAny, {
|
|
3344
3478
|
file: string;
|
|
3345
3479
|
source: "lesson" | "pattern" | "rule";
|
|
3346
|
-
severity: "
|
|
3480
|
+
severity: "warning" | "error" | "info";
|
|
3347
3481
|
issue: string;
|
|
3348
3482
|
relatedLessonId?: string | undefined;
|
|
3349
3483
|
suggestedFix?: string | undefined;
|
|
3350
3484
|
}, {
|
|
3351
3485
|
file: string;
|
|
3352
3486
|
source: "lesson" | "pattern" | "rule";
|
|
3353
|
-
severity: "
|
|
3487
|
+
severity: "warning" | "error" | "info";
|
|
3354
3488
|
issue: string;
|
|
3355
3489
|
relatedLessonId?: string | undefined;
|
|
3356
3490
|
suggestedFix?: string | undefined;
|
|
@@ -3367,14 +3501,14 @@ declare const AuditReportSchema: z.ZodObject<{
|
|
|
3367
3501
|
}, "strip", z.ZodTypeAny, {
|
|
3368
3502
|
file: string;
|
|
3369
3503
|
source: "lesson" | "pattern" | "rule";
|
|
3370
|
-
severity: "
|
|
3504
|
+
severity: "warning" | "error" | "info";
|
|
3371
3505
|
issue: string;
|
|
3372
3506
|
relatedLessonId?: string | undefined;
|
|
3373
3507
|
suggestedFix?: string | undefined;
|
|
3374
3508
|
}, {
|
|
3375
3509
|
file: string;
|
|
3376
3510
|
source: "lesson" | "pattern" | "rule";
|
|
3377
|
-
severity: "
|
|
3511
|
+
severity: "warning" | "error" | "info";
|
|
3378
3512
|
issue: string;
|
|
3379
3513
|
relatedLessonId?: string | undefined;
|
|
3380
3514
|
suggestedFix?: string | undefined;
|
|
@@ -3401,7 +3535,7 @@ declare const AuditReportSchema: z.ZodObject<{
|
|
|
3401
3535
|
findings: {
|
|
3402
3536
|
file: string;
|
|
3403
3537
|
source: "lesson" | "pattern" | "rule";
|
|
3404
|
-
severity: "
|
|
3538
|
+
severity: "warning" | "error" | "info";
|
|
3405
3539
|
issue: string;
|
|
3406
3540
|
relatedLessonId?: string | undefined;
|
|
3407
3541
|
suggestedFix?: string | undefined;
|
|
@@ -3417,7 +3551,7 @@ declare const AuditReportSchema: z.ZodObject<{
|
|
|
3417
3551
|
findings: {
|
|
3418
3552
|
file: string;
|
|
3419
3553
|
source: "lesson" | "pattern" | "rule";
|
|
3420
|
-
severity: "
|
|
3554
|
+
severity: "warning" | "error" | "info";
|
|
3421
3555
|
issue: string;
|
|
3422
3556
|
relatedLessonId?: string | undefined;
|
|
3423
3557
|
suggestedFix?: string | undefined;
|
|
@@ -3511,7 +3645,7 @@ interface ClusterResult {
|
|
|
3511
3645
|
* @param embeddings - Array of embedding vectors
|
|
3512
3646
|
* @returns NxN similarity matrix
|
|
3513
3647
|
*/
|
|
3514
|
-
declare function buildSimilarityMatrix(embeddings: number[]
|
|
3648
|
+
declare function buildSimilarityMatrix(embeddings: ArrayLike<number>[]): number[][];
|
|
3515
3649
|
/**
|
|
3516
3650
|
* Cluster memory items by embedding similarity using single-linkage
|
|
3517
3651
|
* agglomerative clustering.
|
|
@@ -3521,7 +3655,7 @@ declare function buildSimilarityMatrix(embeddings: number[][]): number[][];
|
|
|
3521
3655
|
* @param threshold - Minimum similarity to merge clusters (default: 0.75)
|
|
3522
3656
|
* @returns Clusters of similar items and noise (unclustered items)
|
|
3523
3657
|
*/
|
|
3524
|
-
declare function clusterBySimilarity(items: MemoryItem[], embeddings: number[]
|
|
3658
|
+
declare function clusterBySimilarity(items: MemoryItem[], embeddings: ArrayLike<number>[], threshold?: number): ClusterResult;
|
|
3525
3659
|
|
|
3526
3660
|
/**
|
|
3527
3661
|
* I/O module for CctPattern persistence.
|
|
@@ -3561,4 +3695,4 @@ declare function writeCctPatterns(repoRoot: string, patterns: CctPattern[]): Pro
|
|
|
3561
3695
|
*/
|
|
3562
3696
|
declare function synthesizePattern(cluster: MemoryItem[], clusterId: string): CctPattern;
|
|
3563
3697
|
|
|
3564
|
-
export { type ActionabilityResult, type AuditFinding, AuditFindingSchema, type AuditOptions, type AuditReport, AuditReportSchema, CANDIDATE_MULTIPLIER, CCT_PATTERNS_PATH, type CctPattern, CctPatternSchema, type ClusterResult, type Context, type CorrectionSignal, DB_PATH, DEFAULT_TEXT_WEIGHT, DEFAULT_VECTOR_WEIGHT, type DetectedCorrection, type DetectedSelfCorrection, type DetectedTestFailure, type EditEntry, type EditHistory, type HybridMergeOptions, type IndexOptions, type IndexResult, KNOWLEDGE_DB_PATH, KNOWLEDGE_SCHEMA_VERSION, type KnowledgeChunk, type KnowledgeDbOptions, type KnowledgeSearchOptions, LESSONS_PATH, type Lesson, LessonItemSchema, type LessonRecord, LessonSchema, type LessonType, MODEL_FILENAME, MODEL_URI, type MemoryItem, type MemoryItemRecord, MemoryItemRecordSchema, MemoryItemSchema, type MemoryItemType, MemoryItemTypeSchema, type NoveltyOptions, type NoveltyResult, type ParseError, type PatternItem, PatternItemSchema, type PlanRetrievalResult, type Preference, PreferenceItemSchema, type ProposeResult, type RankedLesson, type ReadLessonsOptions, type ReadLessonsResult, type ReadMemoryItemsResult, type ScoredChunk, type ScoredKeywordResult, type ScoredLesson, type SearchVectorOptions, type Severity, type Solution, SolutionItemSchema, type Source, type SpecificityResult, type TestResult, type UsabilityResult, VERSION, appendLesson, appendMemoryItem, buildSimilarityMatrix, calculateScore, chunkFile, closeDb, closeKnowledgeDb, clusterBySimilarity, collectCachedChunkEmbeddings, confirmationBoost, cosineSimilarity, detectSelfCorrection, detectTestFailure, detectUserCorrection, embedText, embedTexts, formatLessonsCheck, generateId, getCachedChunkEmbedding, getEmbedding, getPrimeContext, indexDocs, isActionable, isModelAvailable, isModelUsable, isNovel, isSpecific, loadSessionLessons, mergeHybridResults, normalizeBm25Rank, openKnowledgeDb, rankLessons, readCctPatterns, readLessons, readMemoryItems, rebuildIndex, recencyBoost, resolveModel, retrieveForPlan, runAudit, searchChunksKeywordScored, searchKeyword, searchKnowledge, searchKnowledgeVector, searchVector, setCachedChunkEmbedding, severityBoost, shouldPropose, synthesizePattern, unloadEmbedding, writeCctPatterns };
|
|
3698
|
+
export { type ActionabilityResult, type AuditFinding, AuditFindingSchema, type AuditOptions, type AuditReport, AuditReportSchema, CANDIDATE_MULTIPLIER, CCT_PATTERNS_PATH, type CctPattern, CctPatternSchema, type ClusterResult, type Context, type CorrectionSignal, DB_PATH, DEFAULT_TEXT_WEIGHT, DEFAULT_VECTOR_WEIGHT, type DetectedCorrection, type DetectedSelfCorrection, type DetectedTestFailure, type EditEntry, type EditHistory, type EmbedChunksOptions, type EmbedChunksResult, type EmbedStatus, type HybridMergeOptions, type IndexOptions, type IndexResult, KNOWLEDGE_DB_PATH, KNOWLEDGE_SCHEMA_VERSION, type KnowledgeChunk, type KnowledgeDbOptions, type KnowledgeSearchOptions, LESSONS_PATH, type Lesson, LessonItemSchema, type LessonRecord, LessonSchema, type LessonType, type LockResult, MODEL_FILENAME, MODEL_URI, type MemoryItem, type MemoryItemRecord, MemoryItemRecordSchema, MemoryItemSchema, type MemoryItemType, MemoryItemTypeSchema, type NoveltyOptions, type NoveltyResult, type ParseError, type PatternItem, PatternItemSchema, type PlanRetrievalResult, type Preference, PreferenceItemSchema, type ProposeResult, type RankedLesson, type ReadLessonsOptions, type ReadLessonsResult, type ReadMemoryItemsResult, type ScoredChunk, type ScoredKeywordResult, type ScoredLesson, type SearchVectorOptions, type Severity, type Solution, SolutionItemSchema, type Source, type SpawnEmbedResult, type SpecificityResult, type TestResult, type UsabilityResult, VERSION, acquireEmbedLock, appendLesson, appendMemoryItem, buildSimilarityMatrix, calculateScore, chunkFile, closeDb, closeKnowledgeDb, clusterBySimilarity, collectCachedChunkEmbeddings, confirmationBoost, cosineSimilarity, detectSelfCorrection, detectTestFailure, detectUserCorrection, embedChunks, embedText, embedTexts, formatLessonsCheck, generateId, getCachedChunkEmbedding, getEmbedding, getPrimeContext, getUnembeddedChunkCount, indexAndSpawnEmbed, indexDocs, isActionable, isEmbedLocked, isModelAvailable, isModelUsable, isNovel, isSpecific, loadSessionLessons, mergeHybridResults, normalizeBm25Rank, openKnowledgeDb, rankLessons, readCctPatterns, readEmbedStatus, readLessons, readMemoryItems, rebuildIndex, recencyBoost, resolveModel, retrieveForPlan, runAudit, runBackgroundEmbed, searchChunksKeywordScored, searchKeyword, searchKnowledge, searchKnowledgeVector, searchVector, setCachedChunkEmbedding, severityBoost, shouldPropose, spawnBackgroundEmbed, synthesizePattern, unloadEmbedding, writeCctPatterns, writeEmbedStatus };
|