maskweaver 0.9.4 → 0.9.6
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.ko.md +638 -592
- package/README.md +671 -667
- package/dist/cli/doctor.js +5 -21
- package/dist/cli/install.d.ts +0 -8
- package/dist/cli/install.js +0 -39
- package/dist/context/config.d.ts +0 -22
- package/dist/context/config.js +0 -28
- package/dist/context/feature.d.ts +0 -39
- package/dist/context/feature.js +0 -77
- package/dist/context/files.d.ts +0 -13
- package/dist/context/files.js +1 -24
- package/dist/context/index.d.ts +0 -7
- package/dist/context/index.js +0 -12
- package/dist/context/project.d.ts +0 -21
- package/dist/context/project.js +0 -30
- package/dist/context/types.d.ts +0 -48
- package/dist/context/types.js +0 -12
- package/dist/context/utils.d.ts +0 -18
- package/dist/context/utils.js +0 -27
- package/dist/core/engine/promptBuilder.d.ts +0 -17
- package/dist/core/engine/promptBuilder.js +0 -28
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.js +0 -9
- package/dist/core/loader/MaskLoader.d.ts +0 -23
- package/dist/core/loader/MaskLoader.js +0 -29
- package/dist/core/schema/types.d.ts +0 -47
- package/dist/core/schema/types.js +0 -6
- package/dist/core/schema/validator.d.ts +0 -14
- package/dist/core/schema/validator.js +0 -18
- package/dist/i18n/index.d.ts +0 -18
- package/dist/i18n/index.js +4 -23
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/lib.d.ts +0 -5
- package/dist/lib.js +0 -12
- package/dist/memory/chunking.d.ts +0 -22
- package/dist/memory/chunking.js +2 -37
- package/dist/memory/core.d.ts +0 -29
- package/dist/memory/core.js +1 -52
- package/dist/memory/index.d.ts +0 -5
- package/dist/memory/index.js +0 -10
- package/dist/memory/indexer.d.ts +0 -21
- package/dist/memory/indexer.js +0 -44
- package/dist/memory/providers/examples.d.ts +0 -5
- package/dist/memory/providers/examples.js +4 -64
- package/dist/memory/providers/factory.d.ts +0 -44
- package/dist/memory/providers/factory.js +0 -46
- package/dist/memory/providers/index.d.ts +0 -26
- package/dist/memory/providers/index.js +0 -28
- package/dist/memory/providers/ollama.d.ts +0 -6
- package/dist/memory/providers/ollama.js +1 -8
- package/dist/memory/providers/openai.d.ts +0 -6
- package/dist/memory/providers/openai.js +1 -8
- package/dist/memory/providers/openrouter.d.ts +0 -6
- package/dist/memory/providers/openrouter.js +0 -8
- package/dist/memory/providers/text-only.d.ts +0 -13
- package/dist/memory/providers/text-only.js +0 -17
- package/dist/memory/providers/types.d.ts +0 -39
- package/dist/memory/providers/types.js +0 -7
- package/dist/memory/providers/voyage.d.ts +0 -22
- package/dist/memory/providers/voyage.js +1 -24
- package/dist/memory/search/hybrid.d.ts +0 -12
- package/dist/memory/search/hybrid.js +1 -22
- package/dist/memory/store/sqlite.d.ts +0 -72
- package/dist/memory/store/sqlite.js +4 -127
- package/dist/plugin/config/index.d.ts +0 -112
- package/dist/plugin/config/index.js +0 -115
- package/dist/plugin/index.d.ts +0 -13
- package/dist/plugin/index.js +1 -123
- package/dist/plugin/tools/command-registry.d.ts +0 -6
- package/dist/plugin/tools/command-registry.js +0 -14
- package/dist/plugin/tools/context.d.ts +0 -12
- package/dist/plugin/tools/context.js +0 -58
- package/dist/plugin/tools/maskSave.d.ts +0 -3
- package/dist/plugin/tools/maskSave.js +0 -3
- package/dist/plugin/tools/memoryGet.d.ts +0 -3
- package/dist/plugin/tools/memoryGet.js +0 -3
- package/dist/plugin/tools/memoryIndexer.d.ts +0 -3
- package/dist/plugin/tools/memoryIndexer.js +0 -10
- package/dist/plugin/tools/memorySearch.d.ts +0 -31
- package/dist/plugin/tools/memorySearch.js +0 -79
- package/dist/plugin/tools/memoryWrite.d.ts +0 -8
- package/dist/plugin/tools/memoryWrite.js +0 -32
- package/dist/plugin/tools/retrospect.d.ts +0 -3
- package/dist/plugin/tools/retrospect.js +0 -3
- package/dist/plugin/tools/slashcommand.d.ts +0 -11
- package/dist/plugin/tools/slashcommand.js +0 -38
- package/dist/plugin/tools/squad.d.ts +0 -12
- package/dist/plugin/tools/squad.js +11 -83
- package/dist/plugin/tools/weave.d.ts +0 -6
- package/dist/plugin/tools/weave.js +0 -78
- package/dist/plugin/types.d.ts +0 -20
- package/dist/plugin/types.js +0 -7
- package/dist/retrospect/index.d.ts +0 -7
- package/dist/retrospect/index.js +0 -9
- package/dist/retrospect/mask-save.d.ts +0 -12
- package/dist/retrospect/mask-save.js +1 -80
- package/dist/retrospect/retrospect.d.ts +0 -18
- package/dist/retrospect/retrospect.js +0 -63
- package/dist/retrospect/strategies/base.d.ts +0 -15
- package/dist/retrospect/strategies/base.js +0 -7
- package/dist/retrospect/strategies/deep.d.ts +0 -12
- package/dist/retrospect/strategies/deep.js +0 -24
- package/dist/retrospect/strategies/index.d.ts +0 -12
- package/dist/retrospect/strategies/index.js +0 -12
- package/dist/retrospect/strategies/quick.d.ts +0 -12
- package/dist/retrospect/strategies/quick.js +0 -19
- package/dist/retrospect/strategies/standard.d.ts +0 -12
- package/dist/retrospect/strategies/standard.js +0 -15
- package/dist/retrospect/types.d.ts +0 -7
- package/dist/retrospect/types.js +0 -7
- package/dist/shared/config.d.ts +0 -105
- package/dist/shared/config.js +0 -33
- package/dist/shared/errors.d.ts +0 -18
- package/dist/shared/errors.js +0 -19
- package/dist/shared/generate-agents.d.ts +0 -69
- package/dist/shared/generate-agents.js +2 -86
- package/dist/shared/image.d.ts +0 -67
- package/dist/shared/image.js +6 -104
- package/dist/shared/index.d.ts +0 -5
- package/dist/shared/index.js +0 -7
- package/dist/shared/model-registry.d.ts +0 -72
- package/dist/shared/model-registry.js +5 -95
- package/dist/shared/types.d.ts +0 -15
- package/dist/shared/types.js +0 -3
- package/dist/shared-context/dag.d.ts +0 -105
- package/dist/shared-context/dag.js +3 -114
- package/dist/shared-context/index.d.ts +0 -5
- package/dist/shared-context/index.js +0 -15
- package/dist/shared-context/logger.d.ts +0 -37
- package/dist/shared-context/logger.js +0 -41
- package/dist/shared-context/parallel-executor.d.ts +0 -54
- package/dist/shared-context/parallel-executor.js +4 -56
- package/dist/shared-context/session.d.ts +0 -56
- package/dist/shared-context/session.js +0 -47
- package/dist/shared-context/squad.d.ts +0 -68
- package/dist/shared-context/squad.js +0 -63
- package/dist/shared-context/storage.d.ts +0 -132
- package/dist/shared-context/storage.js +0 -116
- package/dist/shared-context/task.d.ts +0 -120
- package/dist/shared-context/task.js +0 -152
- package/dist/shared-context/test/dag.test.js +9 -14
- package/dist/shared-context/test/logger.test.d.ts +0 -8
- package/dist/shared-context/test/logger.test.js +0 -52
- package/dist/shared-context/test/session.test.d.ts +0 -7
- package/dist/shared-context/test/session.test.js +0 -63
- package/dist/shared-context/test/squad.test.d.ts +0 -10
- package/dist/shared-context/test/squad.test.js +2 -68
- package/dist/shared-context/test/storage.test.d.ts +0 -8
- package/dist/shared-context/test/storage.test.js +0 -68
- package/dist/shared-context/test/task.test.d.ts +0 -7
- package/dist/shared-context/test/task.test.js +0 -54
- package/dist/shared-context/test/watchdog.test.d.ts +0 -7
- package/dist/shared-context/test/watchdog.test.js +3 -58
- package/dist/shared-context/types.d.ts +0 -215
- package/dist/shared-context/types.js +0 -125
- package/dist/shared-context/watchdog.d.ts +0 -127
- package/dist/shared-context/watchdog.js +0 -148
- package/dist/shared-context/worktree.d.ts +0 -68
- package/dist/shared-context/worktree.js +2 -34
- package/dist/verify/budget.d.ts +0 -29
- package/dist/verify/budget.js +0 -34
- package/dist/verify/critical-files.d.ts +0 -17
- package/dist/verify/critical-files.js +0 -37
- package/dist/verify/escalation.d.ts +0 -20
- package/dist/verify/escalation.js +0 -22
- package/dist/verify/index.d.ts +0 -5
- package/dist/verify/index.js +0 -11
- package/dist/verify/prompts.d.ts +0 -20
- package/dist/verify/prompts.js +0 -20
- package/dist/verify/types.d.ts +0 -26
- package/dist/verify/types.js +1 -12
- package/dist/verify/verifier.d.ts +0 -29
- package/dist/verify/verifier.js +0 -54
- package/dist/version.d.ts +1 -16
- package/dist/version.js +1 -16
- package/dist/weave/bridge.d.ts +0 -35
- package/dist/weave/bridge.js +0 -51
- package/dist/weave/environment/detector.d.ts +0 -6
- package/dist/weave/environment/detector.js +4 -45
- package/dist/weave/environment/index.d.ts +0 -19
- package/dist/weave/environment/index.js +1 -39
- package/dist/weave/environment/issues.d.ts +0 -35
- package/dist/weave/environment/issues.js +0 -59
- package/dist/weave/git.d.ts +0 -8
- package/dist/weave/git.js +0 -8
- package/dist/weave/index.d.ts +0 -13
- package/dist/weave/index.js +2 -28
- package/dist/weave/knowledge/global.d.ts +0 -39
- package/dist/weave/knowledge/global.js +2 -78
- package/dist/weave/loop.js +0 -3
- package/dist/weave/orchestrator.d.ts +0 -69
- package/dist/weave/orchestrator.js +1 -101
- package/dist/weave/phase-manager.d.ts +0 -64
- package/dist/weave/phase-manager.js +0 -89
- package/dist/weave/security/secret-scan.d.ts +0 -14
- package/dist/weave/security/secret-scan.js +0 -19
- package/dist/weave/stages/build.js +0 -15
- package/dist/weave/stages/execute.d.ts +0 -42
- package/dist/weave/stages/execute.js +4 -86
- package/dist/weave/stages/handoff.d.ts +0 -7
- package/dist/weave/stages/handoff.js +0 -43
- package/dist/weave/stages/index.d.ts +0 -3
- package/dist/weave/stages/index.js +0 -3
- package/dist/weave/stages/intake.d.ts +0 -8
- package/dist/weave/stages/intake.js +5 -65
- package/dist/weave/stages/map.d.ts +0 -1
- package/dist/weave/stages/openspec.d.ts +0 -1
- package/dist/weave/stages/plan.d.ts +0 -11
- package/dist/weave/stages/plan.js +1 -53
- package/dist/weave/stages/refine.d.ts +0 -7
- package/dist/weave/stages/refine.js +0 -7
- package/dist/weave/stages/research.d.ts +0 -6
- package/dist/weave/stages/research.js +0 -6
- package/dist/weave/stages/spec.d.ts +0 -12
- package/dist/weave/stages/spec.js +0 -17
- package/dist/weave/types.d.ts +0 -20
- package/dist/weave/types.js +0 -5
- package/dist/weave/verification/commands.d.ts +0 -12
- package/dist/weave/verification/commands.js +0 -19
- package/dist/weave/verification/index.d.ts +0 -6
- package/dist/weave/verification/index.js +1 -19
- package/dist/weave/verification/playwright.d.ts +0 -47
- package/dist/weave/verification/playwright.js +1 -90
- package/dist/weave/worktree.d.ts +0 -16
- package/dist/weave/worktree.js +0 -23
- package/dist/weave/yaml-repair.d.ts +0 -39
- package/dist/weave/yaml-repair.js +13 -116
- package/package.json +1 -1
|
@@ -1,47 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SQLite Storage - Persistent chunk and embedding storage
|
|
3
|
-
*
|
|
4
|
-
* Uses better-sqlite3 for Node.js compatibility.
|
|
5
|
-
* WAL mode for concurrent access.
|
|
6
|
-
*
|
|
7
|
-
* NOTE: better-sqlite3 is an optional dependency.
|
|
8
|
-
* This module uses dynamic import to avoid errors when not installed.
|
|
9
|
-
*/
|
|
10
1
|
import { existsSync, mkdirSync } from 'fs';
|
|
11
2
|
import { dirname } from 'path';
|
|
12
3
|
import { cosineSimilarityFloat32, embeddingToBlob, blobToEmbedding, toFloat32Array, } from '../core.js';
|
|
13
|
-
// Dynamic import for better-sqlite3 or bun:sqlite
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
4
|
let DatabaseConstructor = null;
|
|
16
5
|
let isBun = false;
|
|
17
6
|
let sqliteUnavailable = false;
|
|
18
7
|
let sqliteUnavailableReason = '';
|
|
19
|
-
// Check if running in Bun at module level
|
|
20
|
-
// @ts-ignore
|
|
21
8
|
const IS_BUN = typeof Bun !== 'undefined';
|
|
22
|
-
/**
|
|
23
|
-
* Check if SQLite is available without throwing.
|
|
24
|
-
* Returns true if SQLite can be loaded, false otherwise.
|
|
25
|
-
*/
|
|
26
9
|
export function isSqliteAvailable() {
|
|
27
10
|
return !sqliteUnavailable;
|
|
28
11
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Get the reason SQLite is unavailable.
|
|
31
|
-
*/
|
|
32
12
|
export function getSqliteUnavailableReason() {
|
|
33
13
|
return sqliteUnavailableReason;
|
|
34
14
|
}
|
|
35
15
|
async function loadDatabase() {
|
|
36
16
|
if (DatabaseConstructor)
|
|
37
17
|
return DatabaseConstructor;
|
|
38
|
-
// If we already know SQLite is unavailable, return null immediately
|
|
39
18
|
if (sqliteUnavailable)
|
|
40
19
|
return null;
|
|
41
|
-
// In Bun environment, use bun:sqlite exclusively
|
|
42
20
|
if (IS_BUN) {
|
|
43
21
|
try {
|
|
44
|
-
// @ts-ignore
|
|
45
22
|
const { Database } = await import('bun:sqlite');
|
|
46
23
|
DatabaseConstructor = Database;
|
|
47
24
|
isBun = true;
|
|
@@ -54,8 +31,6 @@ async function loadDatabase() {
|
|
|
54
31
|
return null;
|
|
55
32
|
}
|
|
56
33
|
}
|
|
57
|
-
// In Node.js environment, use better-sqlite3
|
|
58
|
-
// Use Function constructor to avoid Bun's static analysis of import()
|
|
59
34
|
try {
|
|
60
35
|
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
61
36
|
const module = await dynamicImport('better-sqlite3');
|
|
@@ -72,35 +47,23 @@ async function loadDatabase() {
|
|
|
72
47
|
return null;
|
|
73
48
|
}
|
|
74
49
|
}
|
|
75
|
-
// ============================================================================
|
|
76
|
-
// Database Class
|
|
77
|
-
// ============================================================================
|
|
78
50
|
export class MemoryDatabase {
|
|
79
|
-
db;
|
|
51
|
+
db;
|
|
80
52
|
statements = new Map();
|
|
81
53
|
ftsAvailable = false;
|
|
82
54
|
constructor(db) {
|
|
83
55
|
this.db = db;
|
|
84
56
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Create a new MemoryDatabase instance.
|
|
87
|
-
* Uses async factory pattern because better-sqlite3 is dynamically imported.
|
|
88
|
-
* Returns null if SQLite is not available (graceful degradation).
|
|
89
|
-
*/
|
|
90
57
|
static async create(dbPath) {
|
|
91
58
|
const DatabaseClass = await loadDatabase();
|
|
92
|
-
// SQLite not available - graceful degradation
|
|
93
59
|
if (!DatabaseClass) {
|
|
94
60
|
return null;
|
|
95
61
|
}
|
|
96
|
-
// Ensure directory exists
|
|
97
62
|
const dir = dirname(dbPath);
|
|
98
63
|
if (!existsSync(dir)) {
|
|
99
64
|
mkdirSync(dir, { recursive: true });
|
|
100
65
|
}
|
|
101
|
-
// Open database
|
|
102
66
|
const db = new DatabaseClass(dbPath);
|
|
103
|
-
// Enable WAL mode for concurrency
|
|
104
67
|
if (isBun) {
|
|
105
68
|
db.exec('PRAGMA journal_mode = WAL');
|
|
106
69
|
db.exec('PRAGMA synchronous = NORMAL');
|
|
@@ -108,19 +71,14 @@ export class MemoryDatabase {
|
|
|
108
71
|
else {
|
|
109
72
|
db.pragma('journal_mode = WAL');
|
|
110
73
|
db.pragma('synchronous = NORMAL');
|
|
111
|
-
db.pragma('cache_size = -64000');
|
|
74
|
+
db.pragma('cache_size = -64000');
|
|
112
75
|
db.pragma('temp_store = MEMORY');
|
|
113
76
|
}
|
|
114
77
|
const instance = new MemoryDatabase(db);
|
|
115
|
-
// Initialize schema
|
|
116
78
|
instance.initSchema();
|
|
117
|
-
// Prepare statements
|
|
118
79
|
instance.prepareStatements();
|
|
119
80
|
return instance;
|
|
120
81
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Initialize database schema.
|
|
123
|
-
*/
|
|
124
82
|
initSchema() {
|
|
125
83
|
this.db.exec(`
|
|
126
84
|
-- Chunks table
|
|
@@ -158,7 +116,6 @@ export class MemoryDatabase {
|
|
|
158
116
|
CREATE INDEX IF NOT EXISTS idx_chunks_hash ON chunks(hash);
|
|
159
117
|
CREATE INDEX IF NOT EXISTS idx_mask_usage_name ON mask_usage(mask_name);
|
|
160
118
|
`);
|
|
161
|
-
// FTS5 virtual table
|
|
162
119
|
this.ftsAvailable = false;
|
|
163
120
|
try {
|
|
164
121
|
this.db.exec(`
|
|
@@ -172,10 +129,8 @@ export class MemoryDatabase {
|
|
|
172
129
|
this.ftsAvailable = true;
|
|
173
130
|
}
|
|
174
131
|
catch (error) {
|
|
175
|
-
// FTS5 not supported by this SQLite build
|
|
176
132
|
console.warn('[Memory DB] FTS5 not available. Text search will be disabled:', error);
|
|
177
133
|
}
|
|
178
|
-
// FTS triggers — only if FTS table was created successfully
|
|
179
134
|
if (this.ftsAvailable) {
|
|
180
135
|
try {
|
|
181
136
|
this.db.exec(`
|
|
@@ -202,9 +157,6 @@ export class MemoryDatabase {
|
|
|
202
157
|
}
|
|
203
158
|
}
|
|
204
159
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Prepare SQL statements for reuse.
|
|
207
|
-
*/
|
|
208
160
|
prepareStatements() {
|
|
209
161
|
this.statements.set('upsertChunk', this.db.prepare(`
|
|
210
162
|
INSERT INTO chunks (path, start_line, end_line, text, hash, source)
|
|
@@ -236,7 +188,6 @@ export class MemoryDatabase {
|
|
|
236
188
|
FROM chunks c
|
|
237
189
|
JOIN embeddings e ON c.id = e.chunk_id
|
|
238
190
|
`));
|
|
239
|
-
// FTS statement — only prepare if FTS table exists
|
|
240
191
|
if (this.ftsAvailable) {
|
|
241
192
|
this.statements.set('searchFts', this.db.prepare(`
|
|
242
193
|
SELECT rowid, text, rank
|
|
@@ -264,23 +215,12 @@ export class MemoryDatabase {
|
|
|
264
215
|
ORDER BY usage_count DESC
|
|
265
216
|
`));
|
|
266
217
|
}
|
|
267
|
-
// ==========================================================================
|
|
268
|
-
// CRUD Operations
|
|
269
|
-
// ==========================================================================
|
|
270
|
-
/**
|
|
271
|
-
* Insert or update chunk.
|
|
272
|
-
*
|
|
273
|
-
* If embedding is empty (e.g., text-only mode), the chunk is stored
|
|
274
|
-
* but the embedding row is skipped. This allows text search to work
|
|
275
|
-
* while vector search gracefully returns no results for these chunks.
|
|
276
|
-
*/
|
|
277
218
|
upsertChunk(chunk, embedding) {
|
|
278
219
|
const stmt = this.statements.get('upsertChunk');
|
|
279
220
|
const result = stmt.get(chunk.path, chunk.startLine, chunk.endLine, chunk.text, chunk.hash, chunk.source);
|
|
280
221
|
if (!result?.id) {
|
|
281
222
|
throw new Error('[Memory DB] Failed to upsert chunk');
|
|
282
223
|
}
|
|
283
|
-
// Only save embedding if it has actual content
|
|
284
224
|
if (embedding && embedding.length > 0) {
|
|
285
225
|
const embStmt = this.statements.get('upsertEmbedding');
|
|
286
226
|
const embeddingBlob = embeddingToBlob(embedding);
|
|
@@ -288,9 +228,6 @@ export class MemoryDatabase {
|
|
|
288
228
|
}
|
|
289
229
|
return result.id;
|
|
290
230
|
}
|
|
291
|
-
/**
|
|
292
|
-
* Bulk insert chunks in transaction.
|
|
293
|
-
*/
|
|
294
231
|
upsertChunks(chunks) {
|
|
295
232
|
const ids = [];
|
|
296
233
|
const transaction = this.db.transaction(() => {
|
|
@@ -302,25 +239,16 @@ export class MemoryDatabase {
|
|
|
302
239
|
transaction();
|
|
303
240
|
return ids;
|
|
304
241
|
}
|
|
305
|
-
/**
|
|
306
|
-
* Delete chunks by path.
|
|
307
|
-
*/
|
|
308
242
|
deleteChunksByPath(path) {
|
|
309
243
|
const stmt = this.statements.get('deleteChunksByPath');
|
|
310
244
|
const result = stmt.run(path);
|
|
311
245
|
return result.changes;
|
|
312
246
|
}
|
|
313
|
-
/**
|
|
314
|
-
* Check if chunk changed.
|
|
315
|
-
*/
|
|
316
247
|
isChunkChanged(path, hash) {
|
|
317
248
|
const stmt = this.statements.get('checkChunkByHash');
|
|
318
249
|
const result = stmt.get(path, hash);
|
|
319
250
|
return result === undefined;
|
|
320
251
|
}
|
|
321
|
-
/**
|
|
322
|
-
* Get chunks by path.
|
|
323
|
-
*/
|
|
324
252
|
getChunksByPath(path) {
|
|
325
253
|
const stmt = this.statements.get('getChunksByPath');
|
|
326
254
|
const rows = stmt.all(path);
|
|
@@ -335,34 +263,19 @@ export class MemoryDatabase {
|
|
|
335
263
|
createdAt: row.created_at,
|
|
336
264
|
}));
|
|
337
265
|
}
|
|
338
|
-
// ==========================================================================
|
|
339
|
-
// Search Operations
|
|
340
|
-
// ==========================================================================
|
|
341
|
-
/**
|
|
342
|
-
* Vector similarity search.
|
|
343
|
-
*
|
|
344
|
-
* Returns empty results if queryEmbedding is empty (e.g., text-only mode).
|
|
345
|
-
* Skips stored embeddings with dimension mismatches instead of crashing.
|
|
346
|
-
*/
|
|
347
266
|
searchByVector(queryEmbedding, limit = 6, sourceFilter) {
|
|
348
|
-
// Empty embedding = text-only mode. Skip vector search entirely.
|
|
349
267
|
if (!queryEmbedding || queryEmbedding.length === 0) {
|
|
350
268
|
return [];
|
|
351
269
|
}
|
|
352
270
|
const queryVec = toFloat32Array(queryEmbedding);
|
|
353
|
-
// Get all embeddings
|
|
354
271
|
const stmt = this.statements.get('getAllEmbeddings');
|
|
355
272
|
let rows = stmt.all();
|
|
356
|
-
// Filter by source if specified
|
|
357
273
|
if (sourceFilter && sourceFilter.length > 0) {
|
|
358
274
|
rows = rows.filter(row => sourceFilter.includes(row.source));
|
|
359
275
|
}
|
|
360
|
-
// Calculate similarities and sort
|
|
361
|
-
// cosineSimilarityFloat32 returns 0 on dimension mismatch (no throw)
|
|
362
276
|
const scored = [];
|
|
363
277
|
for (const row of rows) {
|
|
364
278
|
const embeddingVec = blobToEmbedding(row.embedding);
|
|
365
|
-
// Skip rows with empty or invalid embeddings
|
|
366
279
|
if (embeddingVec.length === 0) {
|
|
367
280
|
continue;
|
|
368
281
|
}
|
|
@@ -386,10 +299,6 @@ export class MemoryDatabase {
|
|
|
386
299
|
.sort((a, b) => b.score - a.score)
|
|
387
300
|
.slice(0, limit);
|
|
388
301
|
}
|
|
389
|
-
/**
|
|
390
|
-
* Full-text search using FTS5.
|
|
391
|
-
* Returns empty results if FTS is not available.
|
|
392
|
-
*/
|
|
393
302
|
searchByText(query, limit = 6) {
|
|
394
303
|
if (!this.ftsAvailable) {
|
|
395
304
|
return [];
|
|
@@ -408,7 +317,6 @@ export class MemoryDatabase {
|
|
|
408
317
|
const chunk = chunkStmt.get(fts.rowid);
|
|
409
318
|
if (!chunk)
|
|
410
319
|
continue;
|
|
411
|
-
// Normalize BM25 score to 0-1 range
|
|
412
320
|
const normalizedScore = Math.min(1, Math.max(0, -fts.rank / 10));
|
|
413
321
|
results.push({
|
|
414
322
|
chunk: {
|
|
@@ -432,9 +340,6 @@ export class MemoryDatabase {
|
|
|
432
340
|
return [];
|
|
433
341
|
}
|
|
434
342
|
}
|
|
435
|
-
/**
|
|
436
|
-
* Normalize FTS query.
|
|
437
|
-
*/
|
|
438
343
|
normalizeFtsQuery(query) {
|
|
439
344
|
const tokens = query
|
|
440
345
|
.replace(/[^\w\s가-힣]/g, ' ')
|
|
@@ -444,9 +349,6 @@ export class MemoryDatabase {
|
|
|
444
349
|
return '';
|
|
445
350
|
return tokens.map(t => `${t}*`).join(' OR ');
|
|
446
351
|
}
|
|
447
|
-
// ==========================================================================
|
|
448
|
-
// Mask Usage
|
|
449
|
-
// ==========================================================================
|
|
450
352
|
recordMaskUsage(maskName, taskDescription, effectivenessScore) {
|
|
451
353
|
const stmt = this.statements.get('insertMaskUsage');
|
|
452
354
|
stmt.run(maskName, taskDescription ?? null, effectivenessScore ?? null);
|
|
@@ -455,9 +357,6 @@ export class MemoryDatabase {
|
|
|
455
357
|
const stmt = this.statements.get('getMaskStats');
|
|
456
358
|
return stmt.all();
|
|
457
359
|
}
|
|
458
|
-
// ==========================================================================
|
|
459
|
-
// Utilities
|
|
460
|
-
// ==========================================================================
|
|
461
360
|
getStats() {
|
|
462
361
|
const chunkCount = this.db.prepare('SELECT COUNT(*) as count FROM chunks').get().count;
|
|
463
362
|
const embeddingCount = this.db.prepare('SELECT COUNT(*) as count FROM embeddings').get().count;
|
|
@@ -491,14 +390,7 @@ export class MemoryDatabase {
|
|
|
491
390
|
this.db.close();
|
|
492
391
|
}
|
|
493
392
|
}
|
|
494
|
-
// ============================================================================
|
|
495
|
-
// Singleton Instance
|
|
496
|
-
// ============================================================================
|
|
497
393
|
let defaultInstance = null;
|
|
498
|
-
/**
|
|
499
|
-
* Initialize the database.
|
|
500
|
-
* Returns null if SQLite is not available (graceful degradation).
|
|
501
|
-
*/
|
|
502
394
|
export async function initDatabase(dbPath) {
|
|
503
395
|
if (defaultInstance) {
|
|
504
396
|
defaultInstance.close();
|
|
@@ -506,30 +398,15 @@ export async function initDatabase(dbPath) {
|
|
|
506
398
|
defaultInstance = await MemoryDatabase.create(dbPath);
|
|
507
399
|
return defaultInstance;
|
|
508
400
|
}
|
|
509
|
-
/**
|
|
510
|
-
* Get the database instance.
|
|
511
|
-
* Returns null if SQLite is not available or not initialized.
|
|
512
|
-
* Use this for optional memory features.
|
|
513
|
-
*/
|
|
514
401
|
export function getDatabase() {
|
|
515
402
|
if (!defaultInstance && !isSqliteAvailable()) {
|
|
516
|
-
// SQLite not available - return null instead of throwing
|
|
517
403
|
return null;
|
|
518
404
|
}
|
|
519
405
|
return defaultInstance;
|
|
520
406
|
}
|
|
521
|
-
/**
|
|
522
|
-
* Try to get the database instance, returning null if not initialized.
|
|
523
|
-
* Use this when database access is optional (e.g., in intake stage).
|
|
524
|
-
*/
|
|
525
407
|
export function tryGetDatabase() {
|
|
526
408
|
return defaultInstance;
|
|
527
409
|
}
|
|
528
|
-
// ============================================================================
|
|
529
|
-
// Convenience Functions
|
|
530
|
-
// These throw errors if SQLite is not available. Use getDatabase() directly
|
|
531
|
-
// for optional access with null checks.
|
|
532
|
-
// ============================================================================
|
|
533
410
|
export function upsertChunk(chunk, embedding) {
|
|
534
411
|
const db = getDatabase();
|
|
535
412
|
if (!db)
|
|
@@ -539,13 +416,13 @@ export function upsertChunk(chunk, embedding) {
|
|
|
539
416
|
export function searchByVector(embedding, limit) {
|
|
540
417
|
const db = getDatabase();
|
|
541
418
|
if (!db)
|
|
542
|
-
return [];
|
|
419
|
+
return [];
|
|
543
420
|
return db.searchByVector(embedding, limit);
|
|
544
421
|
}
|
|
545
422
|
export function searchByText(query, limit) {
|
|
546
423
|
const db = getDatabase();
|
|
547
424
|
if (!db)
|
|
548
|
-
return [];
|
|
425
|
+
return [];
|
|
549
426
|
return db.searchByText(query, limit);
|
|
550
427
|
}
|
|
551
428
|
export function deleteChunksByPath(path) {
|
|
@@ -1,153 +1,41 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Maskweaver Plugin Configuration Loader
|
|
3
|
-
*
|
|
4
|
-
* Loads maskweaver.json(c) configuration files with support for:
|
|
5
|
-
* - Project-level configuration (.opencode/maskweaver.json)
|
|
6
|
-
* - Global configuration (~/.config/opencode/maskweaver.json)
|
|
7
|
-
* - JSONC format (comments, trailing commas)
|
|
8
|
-
*
|
|
9
|
-
* Based on oh-my-opencode pattern for plugin configuration management.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Logger interface for config loading.
|
|
13
|
-
* Accepts the SDK client (or any compatible object).
|
|
14
|
-
*/
|
|
15
1
|
interface ConfigLoaderContext {
|
|
16
2
|
client: unknown;
|
|
17
3
|
verbose?: boolean;
|
|
18
4
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Agent override configuration
|
|
21
|
-
*/
|
|
22
5
|
export interface AgentOverride {
|
|
23
6
|
model?: string;
|
|
24
7
|
systemPrompt?: string;
|
|
25
8
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Mask-specific configuration
|
|
28
|
-
*/
|
|
29
9
|
export interface MaskConfig {
|
|
30
|
-
/** Default mask ID to activate on session start */
|
|
31
10
|
default?: string;
|
|
32
|
-
/** Automatically activate default mask on session start */
|
|
33
11
|
autoActivate?: boolean;
|
|
34
12
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Logging configuration
|
|
37
|
-
*/
|
|
38
13
|
export interface LoggingConfig {
|
|
39
|
-
/** Enable verbose logging */
|
|
40
14
|
verbose?: boolean;
|
|
41
15
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Completion sound notification configuration
|
|
44
|
-
*/
|
|
45
16
|
export interface CompletionSoundConfig {
|
|
46
|
-
/** Play sound when the active session becomes idle */
|
|
47
17
|
enabled?: boolean;
|
|
48
18
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Notification configuration
|
|
51
|
-
*/
|
|
52
19
|
export interface NotificationsConfig {
|
|
53
20
|
completionSound?: CompletionSoundConfig;
|
|
54
21
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Maskweaver Plugin Configuration
|
|
57
|
-
*/
|
|
58
22
|
export interface MaskweaverPluginConfig {
|
|
59
|
-
/** JSON Schema reference (for IDE support) */
|
|
60
23
|
$schema?: string;
|
|
61
|
-
/** List of disabled mask IDs */
|
|
62
24
|
disabled_masks?: string[];
|
|
63
|
-
/** List of disabled tool names */
|
|
64
25
|
disabled_tools?: string[];
|
|
65
|
-
/** Agent overrides (model, system prompt) */
|
|
66
26
|
agents?: Record<string, AgentOverride>;
|
|
67
|
-
/** Mask configuration */
|
|
68
27
|
masks?: MaskConfig;
|
|
69
|
-
/** Logging configuration */
|
|
70
28
|
logging?: LoggingConfig;
|
|
71
|
-
/** Notifications configuration */
|
|
72
29
|
notifications?: NotificationsConfig;
|
|
73
30
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Load plugin configuration from directory
|
|
76
|
-
*
|
|
77
|
-
* Searches for configuration files in priority order and returns
|
|
78
|
-
* the first found configuration. Returns empty object if no config found.
|
|
79
|
-
*
|
|
80
|
-
* @param directory - Project directory to search for config
|
|
81
|
-
* @param ctx - Optional plugin context (for logging)
|
|
82
|
-
* @returns Parsed configuration object
|
|
83
|
-
*/
|
|
84
31
|
export declare function loadPluginConfig(directory: string, ctx?: ConfigLoaderContext): MaskweaverPluginConfig;
|
|
85
|
-
/**
|
|
86
|
-
* Check if a tool is enabled in the configuration
|
|
87
|
-
*
|
|
88
|
-
* A tool is considered enabled if:
|
|
89
|
-
* - No disabled_tools list exists, OR
|
|
90
|
-
* - disabled_tools list exists but doesn't include the tool name
|
|
91
|
-
*
|
|
92
|
-
* @param config - Plugin configuration
|
|
93
|
-
* @param toolName - Name of the tool to check
|
|
94
|
-
* @returns true if tool is enabled, false otherwise
|
|
95
|
-
*/
|
|
96
32
|
export declare function isToolEnabled(config: MaskweaverPluginConfig, toolName: string): boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Check if a mask is enabled in the configuration
|
|
99
|
-
*
|
|
100
|
-
* A mask is considered enabled if:
|
|
101
|
-
* - No disabled_masks list exists, OR
|
|
102
|
-
* - disabled_masks list exists but doesn't include the mask ID
|
|
103
|
-
*
|
|
104
|
-
* @param config - Plugin configuration
|
|
105
|
-
* @param maskId - ID of the mask to check
|
|
106
|
-
* @returns true if mask is enabled, false otherwise
|
|
107
|
-
*/
|
|
108
33
|
export declare function isMaskEnabled(config: MaskweaverPluginConfig, maskId: string): boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Get the default mask ID from configuration
|
|
111
|
-
*
|
|
112
|
-
* @param config - Plugin configuration
|
|
113
|
-
* @returns Default mask ID if configured, undefined otherwise
|
|
114
|
-
*/
|
|
115
34
|
export declare function getDefaultMask(config: MaskweaverPluginConfig): string | undefined;
|
|
116
|
-
/**
|
|
117
|
-
* Check if auto-activation is enabled for the default mask
|
|
118
|
-
*
|
|
119
|
-
* @param config - Plugin configuration
|
|
120
|
-
* @returns true if auto-activation is enabled, false otherwise
|
|
121
|
-
*/
|
|
122
35
|
export declare function isAutoActivateEnabled(config: MaskweaverPluginConfig): boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Get agent override for a specific agent
|
|
125
|
-
*
|
|
126
|
-
* @param config - Plugin configuration
|
|
127
|
-
* @param agentName - Name of the agent
|
|
128
|
-
* @returns Agent override config if exists, undefined otherwise
|
|
129
|
-
*/
|
|
130
36
|
export declare function getAgentOverride(config: MaskweaverPluginConfig, agentName: string): AgentOverride | undefined;
|
|
131
|
-
/**
|
|
132
|
-
* Check if verbose logging is enabled
|
|
133
|
-
*
|
|
134
|
-
* @param config - Plugin configuration
|
|
135
|
-
* @returns true if verbose logging is enabled, false otherwise
|
|
136
|
-
*/
|
|
137
37
|
export declare function isVerboseLoggingEnabled(config: MaskweaverPluginConfig): boolean;
|
|
138
|
-
/**
|
|
139
|
-
* Check if completion sound notification is enabled
|
|
140
|
-
*
|
|
141
|
-
* @param config - Plugin configuration
|
|
142
|
-
* @returns true if completion sound is enabled, false otherwise
|
|
143
|
-
*/
|
|
144
38
|
export declare function isCompletionSoundEnabled(config: MaskweaverPluginConfig): boolean;
|
|
145
|
-
/**
|
|
146
|
-
* Validate configuration structure
|
|
147
|
-
*
|
|
148
|
-
* @param config - Configuration to validate
|
|
149
|
-
* @returns Array of validation error messages (empty if valid)
|
|
150
|
-
*/
|
|
151
39
|
export declare function validateConfig(config: MaskweaverPluginConfig): string[];
|
|
152
40
|
declare const _default: {
|
|
153
41
|
loadPluginConfig: typeof loadPluginConfig;
|