maskweaver 0.7.13 → 0.7.16

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 (50) hide show
  1. package/LICENSE +21 -21
  2. package/assets/agents/dummy-human.md +31 -31
  3. package/assets/agents/dummy-template.md +57 -57
  4. package/assets/agents/mask-weaver.md +412 -412
  5. package/assets/agents/squad-operator.md +0 -1
  6. package/assets/masks/ai-ml/andrew-ng.yaml +207 -207
  7. package/assets/masks/architecture/jeff-dean.yaml +208 -208
  8. package/assets/masks/index.json +65 -65
  9. package/assets/masks/software-engineering/dan-abramov.yaml +188 -188
  10. package/assets/masks/software-engineering/kent-beck.yaml +191 -191
  11. package/assets/masks/software-engineering/linus-torvalds.yaml +152 -152
  12. package/assets/masks/software-engineering/martin-fowler.yaml +173 -173
  13. package/dist/memory/core.d.ts +6 -0
  14. package/dist/memory/core.d.ts.map +1 -1
  15. package/dist/memory/core.js +26 -6
  16. package/dist/memory/core.js.map +1 -1
  17. package/dist/memory/providers/text-only.d.ts +6 -0
  18. package/dist/memory/providers/text-only.d.ts.map +1 -1
  19. package/dist/memory/providers/text-only.js +12 -5
  20. package/dist/memory/providers/text-only.js.map +1 -1
  21. package/dist/memory/search/hybrid.d.ts +4 -0
  22. package/dist/memory/search/hybrid.d.ts.map +1 -1
  23. package/dist/memory/search/hybrid.js +23 -6
  24. package/dist/memory/search/hybrid.js.map +1 -1
  25. package/dist/memory/store/sqlite.d.ts +9 -0
  26. package/dist/memory/store/sqlite.d.ts.map +1 -1
  27. package/dist/memory/store/sqlite.js +85 -39
  28. package/dist/memory/store/sqlite.js.map +1 -1
  29. package/dist/plugin/tools/context.js +15 -15
  30. package/dist/plugin/tools/maskSave.js +8 -8
  31. package/dist/plugin/tools/memoryIndexer.js +5 -5
  32. package/dist/plugin/tools/memoryWrite.js +3 -3
  33. package/dist/plugin/tools/retrospect.js +3 -3
  34. package/dist/plugin/tools/squad.js +2 -2
  35. package/dist/retrospect/mask-save.js +21 -21
  36. package/dist/retrospect/retrospect.js +9 -9
  37. package/dist/verify/prompts.js +114 -114
  38. package/dist/weave/knowledge/global.d.ts +1 -0
  39. package/dist/weave/knowledge/global.d.ts.map +1 -1
  40. package/dist/weave/knowledge/global.js +63 -56
  41. package/dist/weave/knowledge/global.js.map +1 -1
  42. package/masks/ai-ml/andrew-ng.yaml +207 -207
  43. package/masks/architecture/jeff-dean.yaml +208 -208
  44. package/masks/index.json +65 -65
  45. package/masks/orchestration/squad-operator.yaml +205 -205
  46. package/masks/software-engineering/dan-abramov.yaml +188 -188
  47. package/masks/software-engineering/kent-beck.yaml +191 -191
  48. package/masks/software-engineering/linus-torvalds.yaml +152 -152
  49. package/masks/software-engineering/martin-fowler.yaml +173 -173
  50. package/package.json +1 -1
@@ -43,21 +43,21 @@ function errorResponse(action, message) {
43
43
  // ============================================================================
44
44
  export function createContextTool() {
45
45
  return {
46
- description: `작업 컨텍스트를 관리합니다.
47
-
48
- **액션:**
49
- - \`start\`: 새 피처 시작 (name, goal 필요)
50
- - \`switch\`: 피처 전환 (id 또는 name 필요)
51
- - \`status\`: 현재 활성 피처 상태 표시
52
- - \`done\`: 피처 완료 처리 (id 없으면 현재 피처)
53
- - \`add\`: 현재 피처에 파일 추가 (file 필요)
54
- - \`drop\`: 현재 피처에서 파일 제거 (file 필요)
55
- - \`goal\`: 현재 피처 목표 변경 (goal 필요)
56
- - \`list\`: 모든 피처 목록 조회
57
-
58
- **예시:**
59
- - 피처 시작: action="start", name="login-oauth", goal="OAuth 로그인 구현"
60
- - 파일 추가: action="add", file="src/auth/oauth.ts"
46
+ description: `작업 컨텍스트를 관리합니다.
47
+
48
+ **액션:**
49
+ - \`start\`: 새 피처 시작 (name, goal 필요)
50
+ - \`switch\`: 피처 전환 (id 또는 name 필요)
51
+ - \`status\`: 현재 활성 피처 상태 표시
52
+ - \`done\`: 피처 완료 처리 (id 없으면 현재 피처)
53
+ - \`add\`: 현재 피처에 파일 추가 (file 필요)
54
+ - \`drop\`: 현재 피처에서 파일 제거 (file 필요)
55
+ - \`goal\`: 현재 피처 목표 변경 (goal 필요)
56
+ - \`list\`: 모든 피처 목록 조회
57
+
58
+ **예시:**
59
+ - 피처 시작: action="start", name="login-oauth", goal="OAuth 로그인 구현"
60
+ - 파일 추가: action="add", file="src/auth/oauth.ts"
61
61
  - 상태 확인: action="status"`,
62
62
  args: contextSchema,
63
63
  async execute(args, context) {
@@ -5,14 +5,14 @@ import { z } from "zod";
5
5
  import { saveMask } from "../../retrospect/index.js";
6
6
  export function createMaskSaveTool() {
7
7
  return {
8
- description: `효과적인 가면을 라이브러리에 저장합니다.
9
- 새로운 가면을 추가하거나, 기존 가면의 효과성 점수와 사용 기록을 업데이트합니다.
10
-
11
- 사용 시점:
12
- - 가면 사용 후 효과적이었을 때
13
- - 새로운 전문가 가면을 발견했을 때
14
- - 기존 가면의 효과성을 기록할 때
15
-
8
+ description: `효과적인 가면을 라이브러리에 저장합니다.
9
+ 새로운 가면을 추가하거나, 기존 가면의 효과성 점수와 사용 기록을 업데이트합니다.
10
+
11
+ 사용 시점:
12
+ - 가면 사용 후 효과적이었을 때
13
+ - 새로운 전문가 가면을 발견했을 때
14
+ - 기존 가면의 효과성을 기록할 때
15
+
16
16
  효과성 점수는 이동 평균으로 계산됩니다 (새 점수 가중치: 0.3)`,
17
17
  args: z.object({
18
18
  name: z.string(),
@@ -40,11 +40,11 @@ async function getConfiguredProvider(worktree) {
40
40
  }
41
41
  export function createMemoryIndexerTool() {
42
42
  return {
43
- description: `Index memory files for semantic search. Chunks markdown files and stores embeddings.
44
-
45
- Actions:
46
- - index: Index a single file (only re-embeds changed chunks)
47
- - reindex: Force reindex a file (deletes and re-embeds all chunks)
43
+ description: `Index memory files for semantic search. Chunks markdown files and stores embeddings.
44
+
45
+ Actions:
46
+ - index: Index a single file (only re-embeds changed chunks)
47
+ - reindex: Force reindex a file (deletes and re-embeds all chunks)
48
48
  - index-all: Index all memory files (MEMORY.md, MASKS.md, RETROSPECT.md, USER.md)`,
49
49
  args: z.object({
50
50
  action: z.enum(["index", "reindex", "index-all"]),
@@ -23,9 +23,9 @@ const memoryWriteArgsSchema = z.object({
23
23
  // ============================================================================
24
24
  export function createMemoryWriteTool() {
25
25
  return {
26
- description: `Saves content to memory files.
27
- - daily: Today's work log (appends to today's date file)
28
- - memory: Long-term memory (adds to MEMORY.md)
26
+ description: `Saves content to memory files.
27
+ - daily: Today's work log (appends to today's date file)
28
+ - memory: Long-term memory (adds to MEMORY.md)
29
29
  - user: User information (updates USER.md)`,
30
30
  args: memoryWriteArgsSchema,
31
31
  async execute(args, context) {
@@ -5,9 +5,9 @@ import { z } from "zod";
5
5
  import { performRetrospect } from "../../retrospect/index.js";
6
6
  export function createRetrospectTool() {
7
7
  return {
8
- description: `회고를 수행합니다.
9
- - daily: 오늘의 작업 기록 (자동으로 오늘 날짜 파일에 추가)
10
- - memory: 장기 기억 (MEMORY.md에 추가)
8
+ description: `회고를 수행합니다.
9
+ - daily: 오늘의 작업 기록 (자동으로 오늘 날짜 파일에 추가)
10
+ - memory: 장기 기억 (MEMORY.md에 추가)
11
11
  - user: 유저 정보 (USER.md 업데이트)`,
12
12
  args: z.object({
13
13
  trigger: z.enum(["manual", "session_end", "periodic"]),
@@ -177,8 +177,8 @@ Direct use of assign/update/complete by primary agent pollutes strategic context
177
177
  - \`complete\`: Complete task (squadId, taskId, success required)
178
178
  - \`status\`: View session or squad status (squadId optional)
179
179
  - \`watchdog\`: Run timeout watchdog (dryRun optional)
180
- - \`list\`: List all squads in session
181
- - \`plan\`: Analyze task dependencies and create parallel execution plan (squadId required)
180
+ - \`list\`: List all squads in session
181
+ - \`plan\`: Analyze task dependencies and create parallel execution plan (squadId required)
182
182
 
183
183
  **Examples:**
184
184
  - Start session: action="start", goal="Implement OAuth login"
@@ -108,14 +108,14 @@ function generateNewMaskSection(input) {
108
108
  const usageRecord = input.usageNote
109
109
  ? ` - ${timestamp} (점수: ${input.effectivenessScore}) - ${input.usageNote}`
110
110
  : ` - ${timestamp} (점수: ${input.effectivenessScore})`;
111
- return `### ${input.name}
112
- - **전문 분야**: ${input.expertise}
113
- - **사고 방식**: ${input.thinkingStyle}
114
- - **강점**: ${input.strengths}
115
- - **적합한 작업**: ${input.suitableFor}
116
- - **효과성 점수**: ${input.effectivenessScore}
117
- - **사용 기록**:
118
- ${usageRecord}
111
+ return `### ${input.name}
112
+ - **전문 분야**: ${input.expertise}
113
+ - **사고 방식**: ${input.thinkingStyle}
114
+ - **강점**: ${input.strengths}
115
+ - **적합한 작업**: ${input.suitableFor}
116
+ - **효과성 점수**: ${input.effectivenessScore}
117
+ - **사용 기록**:
118
+ ${usageRecord}
119
119
  `;
120
120
  }
121
121
  /**
@@ -185,19 +185,19 @@ function readMasksFile(basePath) {
185
185
  const masksPath = getMemoryPath('masks', basePath);
186
186
  if (!existsSync(masksPath)) {
187
187
  // 기본 템플릿 반환
188
- return `# 가면 라이브러리 (Mask Library)
189
-
190
- 이 파일은 가면술사가 사용하는 가면들의 정의와 효과성을 기록합니다.
191
- 성공적으로 사용된 가면들을 저장하여 향후 유사한 작업에 활용합니다.
192
-
193
- ---
194
-
195
- ## 검증된 가면 목록
196
-
197
- ---
198
-
199
- ${CUSTOM_SECTION_HEADER}
200
-
188
+ return `# 가면 라이브러리 (Mask Library)
189
+
190
+ 이 파일은 가면술사가 사용하는 가면들의 정의와 효과성을 기록합니다.
191
+ 성공적으로 사용된 가면들을 저장하여 향후 유사한 작업에 활용합니다.
192
+
193
+ ---
194
+
195
+ ## 검증된 가면 목록
196
+
197
+ ---
198
+
199
+ ${CUSTOM_SECTION_HEADER}
200
+
201
201
  `;
202
202
  }
203
203
  return readFileSync(masksPath, 'utf-8');
@@ -37,15 +37,15 @@ function readRetrospectFile(basePath) {
37
37
  const retrospectPath = getMemoryPath('retrospect', basePath);
38
38
  if (!existsSync(retrospectPath)) {
39
39
  // 기본 템플릿 반환
40
- return `# 회고록 (Retrospective Journal)
41
-
42
- 이 파일은 가면술사의 회고와 성찰을 기록합니다.
43
- 세션 종료 시, 주기적으로, 또는 수동 요청 시 회고를 수행하고 기록합니다.
44
-
45
- ---
46
-
47
- ${RETROSPECT_SECTION_HEADER}
48
-
40
+ return `# 회고록 (Retrospective Journal)
41
+
42
+ 이 파일은 가면술사의 회고와 성찰을 기록합니다.
43
+ 세션 종료 시, 주기적으로, 또는 수동 요청 시 회고를 수행하고 기록합니다.
44
+
45
+ ---
46
+
47
+ ${RETROSPECT_SECTION_HEADER}
48
+
49
49
  `;
50
50
  }
51
51
  return readFileSync(retrospectPath, 'utf-8');
@@ -6,128 +6,128 @@
6
6
  /**
7
7
  * Flash reviewer prompt - Quick checks only
8
8
  */
9
- export const FLASH_REVIEW_PROMPT = `You are a fast code reviewer. Perform a quick check for:
10
-
11
- 1. **Syntax errors** - obvious compilation/parsing issues
12
- 2. **Critical bugs** - null pointer dereferences, infinite loops, etc.
13
- 3. **Security vulnerabilities** - SQL injection, XSS, hardcoded credentials
14
- 4. **Missing error handling** - unhandled exceptions, missing validation
15
-
16
- Keep it quick and focused. Only flag clear, serious issues.
17
-
18
- Respond in JSON format:
19
- {
20
- "result": "pass" | "warn" | "fail",
21
- "summary": "Brief overall assessment",
22
- "issues": [
23
- {
24
- "severity": "error" | "warning" | "info",
25
- "message": "Description of the issue",
26
- "line": 42,
27
- "suggestion": "How to fix it"
28
- }
29
- ],
30
- "suggestions": ["Optional improvement suggestions"]
31
- }
32
-
33
- Result guide:
34
- - "pass": No issues found
35
- - "warn": Minor issues or potential concerns
36
- - "fail": Critical issues that must be fixed
37
-
38
- Code to review:
39
-
40
- \`\`\`
41
- {{CONTENT}}
42
- \`\`\`
43
-
9
+ export const FLASH_REVIEW_PROMPT = `You are a fast code reviewer. Perform a quick check for:
10
+
11
+ 1. **Syntax errors** - obvious compilation/parsing issues
12
+ 2. **Critical bugs** - null pointer dereferences, infinite loops, etc.
13
+ 3. **Security vulnerabilities** - SQL injection, XSS, hardcoded credentials
14
+ 4. **Missing error handling** - unhandled exceptions, missing validation
15
+
16
+ Keep it quick and focused. Only flag clear, serious issues.
17
+
18
+ Respond in JSON format:
19
+ {
20
+ "result": "pass" | "warn" | "fail",
21
+ "summary": "Brief overall assessment",
22
+ "issues": [
23
+ {
24
+ "severity": "error" | "warning" | "info",
25
+ "message": "Description of the issue",
26
+ "line": 42,
27
+ "suggestion": "How to fix it"
28
+ }
29
+ ],
30
+ "suggestions": ["Optional improvement suggestions"]
31
+ }
32
+
33
+ Result guide:
34
+ - "pass": No issues found
35
+ - "warn": Minor issues or potential concerns
36
+ - "fail": Critical issues that must be fixed
37
+
38
+ Code to review:
39
+
40
+ \`\`\`
41
+ {{CONTENT}}
42
+ \`\`\`
43
+
44
44
  {{CONTEXT}}`;
45
45
  /**
46
46
  * Human reviewer prompt - Standard review
47
47
  */
48
- export const HUMAN_REVIEW_PROMPT = `You are an experienced code reviewer. Perform a thorough review:
49
-
50
- 1. **Code quality** - readability, maintainability, style
51
- 2. **Logic correctness** - algorithm correctness, edge cases
52
- 3. **Best practices** - design patterns, SOLID principles
53
- 4. **Error handling** - comprehensive error handling and validation
54
- 5. **Security** - authentication, authorization, data validation
55
- 6. **Performance** - obvious performance issues
56
- 7. **Testing** - testability, missing test cases
57
-
58
- Provide constructive feedback with specific suggestions.
59
-
60
- Respond in JSON format:
61
- {
62
- "result": "pass" | "warn" | "fail",
63
- "summary": "Comprehensive review summary",
64
- "issues": [
65
- {
66
- "severity": "error" | "warning" | "info",
67
- "message": "Detailed issue description",
68
- "line": 42,
69
- "suggestion": "Specific fix or improvement"
70
- }
71
- ],
72
- "suggestions": ["General improvement suggestions"]
73
- }
74
-
75
- Result guide:
76
- - "pass": Code meets quality standards
77
- - "warn": Has issues but acceptable with improvements
78
- - "fail": Significant issues requiring fixes
79
-
80
- Code to review:
81
-
82
- \`\`\`
83
- {{CONTENT}}
84
- \`\`\`
85
-
48
+ export const HUMAN_REVIEW_PROMPT = `You are an experienced code reviewer. Perform a thorough review:
49
+
50
+ 1. **Code quality** - readability, maintainability, style
51
+ 2. **Logic correctness** - algorithm correctness, edge cases
52
+ 3. **Best practices** - design patterns, SOLID principles
53
+ 4. **Error handling** - comprehensive error handling and validation
54
+ 5. **Security** - authentication, authorization, data validation
55
+ 6. **Performance** - obvious performance issues
56
+ 7. **Testing** - testability, missing test cases
57
+
58
+ Provide constructive feedback with specific suggestions.
59
+
60
+ Respond in JSON format:
61
+ {
62
+ "result": "pass" | "warn" | "fail",
63
+ "summary": "Comprehensive review summary",
64
+ "issues": [
65
+ {
66
+ "severity": "error" | "warning" | "info",
67
+ "message": "Detailed issue description",
68
+ "line": 42,
69
+ "suggestion": "Specific fix or improvement"
70
+ }
71
+ ],
72
+ "suggestions": ["General improvement suggestions"]
73
+ }
74
+
75
+ Result guide:
76
+ - "pass": Code meets quality standards
77
+ - "warn": Has issues but acceptable with improvements
78
+ - "fail": Significant issues requiring fixes
79
+
80
+ Code to review:
81
+
82
+ \`\`\`
83
+ {{CONTENT}}
84
+ \`\`\`
85
+
86
86
  {{CONTEXT}}`;
87
87
  /**
88
88
  * Premium reviewer prompt - Deep analysis
89
89
  */
90
- export const PREMIUM_REVIEW_PROMPT = `You are a senior architect and security expert. Perform a comprehensive, deep review:
91
-
92
- 1. **Architecture** - system design, modularity, scalability
93
- 2. **Security** - comprehensive security analysis (OWASP Top 10)
94
- 3. **Performance** - algorithmic complexity, memory usage, bottlenecks
95
- 4. **Maintainability** - long-term code health, technical debt
96
- 5. **Reliability** - error recovery, fault tolerance, edge cases
97
- 6. **Best practices** - industry standards, design patterns
98
- 7. **Testing strategy** - test coverage, test quality
99
- 8. **Documentation** - code clarity, comments, API documentation
100
- 9. **Compliance** - licensing, regulatory requirements
101
- 10. **Future-proofing** - extensibility, backward compatibility
102
-
103
- Provide expert-level analysis with architectural insights.
104
-
105
- Respond in JSON format:
106
- {
107
- "result": "pass" | "warn" | "fail",
108
- "summary": "Expert architectural and security assessment",
109
- "issues": [
110
- {
111
- "severity": "error" | "warning" | "info",
112
- "message": "In-depth issue analysis",
113
- "line": 42,
114
- "suggestion": "Expert recommendation with rationale"
115
- }
116
- ],
117
- "suggestions": ["Strategic improvement recommendations"]
118
- }
119
-
120
- Result guide:
121
- - "pass": Production-ready, meets enterprise standards
122
- - "warn": Acceptable but has architectural concerns
123
- - "fail": Requires significant redesign or security fixes
124
-
125
- Code to review:
126
-
127
- \`\`\`
128
- {{CONTENT}}
129
- \`\`\`
130
-
90
+ export const PREMIUM_REVIEW_PROMPT = `You are a senior architect and security expert. Perform a comprehensive, deep review:
91
+
92
+ 1. **Architecture** - system design, modularity, scalability
93
+ 2. **Security** - comprehensive security analysis (OWASP Top 10)
94
+ 3. **Performance** - algorithmic complexity, memory usage, bottlenecks
95
+ 4. **Maintainability** - long-term code health, technical debt
96
+ 5. **Reliability** - error recovery, fault tolerance, edge cases
97
+ 6. **Best practices** - industry standards, design patterns
98
+ 7. **Testing strategy** - test coverage, test quality
99
+ 8. **Documentation** - code clarity, comments, API documentation
100
+ 9. **Compliance** - licensing, regulatory requirements
101
+ 10. **Future-proofing** - extensibility, backward compatibility
102
+
103
+ Provide expert-level analysis with architectural insights.
104
+
105
+ Respond in JSON format:
106
+ {
107
+ "result": "pass" | "warn" | "fail",
108
+ "summary": "Expert architectural and security assessment",
109
+ "issues": [
110
+ {
111
+ "severity": "error" | "warning" | "info",
112
+ "message": "In-depth issue analysis",
113
+ "line": 42,
114
+ "suggestion": "Expert recommendation with rationale"
115
+ }
116
+ ],
117
+ "suggestions": ["Strategic improvement recommendations"]
118
+ }
119
+
120
+ Result guide:
121
+ - "pass": Production-ready, meets enterprise standards
122
+ - "warn": Acceptable but has architectural concerns
123
+ - "fail": Requires significant redesign or security fixes
124
+
125
+ Code to review:
126
+
127
+ \`\`\`
128
+ {{CONTENT}}
129
+ \`\`\`
130
+
131
131
  {{CONTEXT}}`;
132
132
  /**
133
133
  * Get prompt template for reviewer tier
@@ -19,6 +19,7 @@ export declare class GlobalKnowledge {
19
19
  private initialized;
20
20
  private usingSqlJs;
21
21
  private sqlJsDb;
22
+ private ftsAvailable;
22
23
  init(): Promise<void>;
23
24
  /**
24
25
  * Create a wrapper that mimics better-sqlite3 API using sql.js
@@ -1 +1 @@
1
- {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/weave/knowledge/global.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAS/E,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAYD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAe7D;AAMD,qBAAa,eAAe;IACxB,OAAO,CAAC,EAAE,CAAa;IACvB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAa;IAEtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAkD3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAwF1B,OAAO,CAAC,YAAY;IAsDpB;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,oBAAoB,EAAE,IAAI,GAAG,gBAAgB,GAAG,WAAW,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAkCrH;;OAEG;IACG,MAAM,CACR,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE;QACL,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;KACxB,GACP,OAAO,CAAC,qBAAqB,EAAE,CAAC;IA4EnC;;OAEG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAezC;;OAEG;IACG,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;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AC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,GACF,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAGlC"}
@@ -54,6 +54,7 @@ export class GlobalKnowledge {
54
54
  initialized = false;
55
55
  usingSqlJs = false;
56
56
  sqlJsDb = null;
57
+ ftsAvailable = false;
57
58
  async init() {
58
59
  if (this.initialized)
59
60
  return;
@@ -117,13 +118,8 @@ export class GlobalKnowledge {
117
118
  };
118
119
  return {
119
120
  exec: (sql) => {
120
- try {
121
- sqlJsDb.run(sql);
122
- saveToFile();
123
- }
124
- catch (e) {
125
- console.warn('[sql.js] exec error:', e);
126
- }
121
+ sqlJsDb.run(sql);
122
+ saveToFile();
127
123
  },
128
124
  prepare: (sql) => {
129
125
  return {
@@ -198,55 +194,66 @@ export class GlobalKnowledge {
198
194
  createTables() {
199
195
  if (!this.db)
200
196
  return;
201
- this.db.exec(`
202
- CREATE TABLE IF NOT EXISTS troubleshooting (
203
- id INTEGER PRIMARY KEY AUTOINCREMENT,
204
- error_signature TEXT NOT NULL,
205
- error_message TEXT NOT NULL,
206
- context TEXT NOT NULL,
207
- solution TEXT NOT NULL,
208
- project_type TEXT,
209
- tech_stack TEXT,
210
- tags TEXT,
211
- effectiveness INTEGER DEFAULT 5,
212
- created_at TEXT NOT NULL,
213
- used_count INTEGER DEFAULT 0,
214
- last_used_at TEXT
215
- );
216
-
217
- CREATE INDEX IF NOT EXISTS idx_error_signature
218
- ON troubleshooting(error_signature);
219
-
220
- CREATE INDEX IF NOT EXISTS idx_project_type
221
- ON troubleshooting(project_type);
222
-
223
- CREATE VIRTUAL TABLE IF NOT EXISTS troubleshooting_fts USING fts5(
224
- error_message,
225
- context,
226
- solution,
227
- tags,
228
- content='troubleshooting',
229
- content_rowid='id'
230
- );
231
-
232
- -- Triggers to keep FTS in sync
233
- CREATE TRIGGER IF NOT EXISTS troubleshooting_ai AFTER INSERT ON troubleshooting BEGIN
234
- INSERT INTO troubleshooting_fts(rowid, error_message, context, solution, tags)
235
- VALUES (new.id, new.error_message, new.context, new.solution, new.tags);
236
- END;
237
-
238
- CREATE TRIGGER IF NOT EXISTS troubleshooting_ad AFTER DELETE ON troubleshooting BEGIN
239
- INSERT INTO troubleshooting_fts(troubleshooting_fts, rowid, error_message, context, solution, tags)
240
- VALUES ('delete', old.id, old.error_message, old.context, old.solution, old.tags);
241
- END;
242
-
243
- CREATE TRIGGER IF NOT EXISTS troubleshooting_au AFTER UPDATE ON troubleshooting BEGIN
244
- INSERT INTO troubleshooting_fts(troubleshooting_fts, rowid, error_message, context, solution, tags)
245
- VALUES ('delete', old.id, old.error_message, old.context, old.solution, old.tags);
246
- INSERT INTO troubleshooting_fts(rowid, error_message, context, solution, tags)
247
- VALUES (new.id, new.error_message, new.context, new.solution, new.tags);
248
- END;
197
+ // Core table and indexes — always works
198
+ this.db.exec(`
199
+ CREATE TABLE IF NOT EXISTS troubleshooting (
200
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
201
+ error_signature TEXT NOT NULL,
202
+ error_message TEXT NOT NULL,
203
+ context TEXT NOT NULL,
204
+ solution TEXT NOT NULL,
205
+ project_type TEXT,
206
+ tech_stack TEXT,
207
+ tags TEXT,
208
+ effectiveness INTEGER DEFAULT 5,
209
+ created_at TEXT NOT NULL,
210
+ used_count INTEGER DEFAULT 0,
211
+ last_used_at TEXT
212
+ );
213
+
214
+ CREATE INDEX IF NOT EXISTS idx_error_signature
215
+ ON troubleshooting(error_signature);
216
+
217
+ CREATE INDEX IF NOT EXISTS idx_project_type
218
+ ON troubleshooting(project_type);
249
219
  `);
220
+ // FTS5 virtual table and sync triggers — requires FTS5 extension
221
+ // (available in better-sqlite3 but NOT in default sql.js WASM builds)
222
+ try {
223
+ this.db.exec(`
224
+ CREATE VIRTUAL TABLE IF NOT EXISTS troubleshooting_fts USING fts5(
225
+ error_message,
226
+ context,
227
+ solution,
228
+ tags,
229
+ content='troubleshooting',
230
+ content_rowid='id'
231
+ );
232
+
233
+ -- Triggers to keep FTS in sync
234
+ CREATE TRIGGER IF NOT EXISTS troubleshooting_ai AFTER INSERT ON troubleshooting BEGIN
235
+ INSERT INTO troubleshooting_fts(rowid, error_message, context, solution, tags)
236
+ VALUES (new.id, new.error_message, new.context, new.solution, new.tags);
237
+ END;
238
+
239
+ CREATE TRIGGER IF NOT EXISTS troubleshooting_ad AFTER DELETE ON troubleshooting BEGIN
240
+ INSERT INTO troubleshooting_fts(troubleshooting_fts, rowid, error_message, context, solution, tags)
241
+ VALUES ('delete', old.id, old.error_message, old.context, old.solution, old.tags);
242
+ END;
243
+
244
+ CREATE TRIGGER IF NOT EXISTS troubleshooting_au AFTER UPDATE ON troubleshooting BEGIN
245
+ INSERT INTO troubleshooting_fts(troubleshooting_fts, rowid, error_message, context, solution, tags)
246
+ VALUES ('delete', old.id, old.error_message, old.context, old.solution, old.tags);
247
+ INSERT INTO troubleshooting_fts(rowid, error_message, context, solution, tags)
248
+ VALUES (new.id, new.error_message, new.context, new.solution, new.tags);
249
+ END;
250
+ `);
251
+ this.ftsAvailable = true;
252
+ }
253
+ catch {
254
+ // FTS5 not available (e.g. sql.js WASM build) — search falls back to exact matches only
255
+ this.ftsAvailable = false;
256
+ }
250
257
  }
251
258
  /**
252
259
  * Record a troubleshooting experience for future reference.
@@ -296,7 +303,7 @@ export class GlobalKnowledge {
296
303
  });
297
304
  }
298
305
  // 2. FTS search for similar errors (if not enough exact matches)
299
- if (results.length < limit) {
306
+ if (this.ftsAvailable && results.length < limit) {
300
307
  const remaining = limit - results.length;
301
308
  const existingIds = results.map(r => r.entry.id);
302
309
  // Extract key terms from error