@yuaone/core 0.8.5 → 0.9.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.
Files changed (95) hide show
  1. package/README.md +73 -2
  2. package/dist/agent-loop.d.ts +8 -0
  3. package/dist/agent-loop.d.ts.map +1 -1
  4. package/dist/agent-loop.js +34 -0
  5. package/dist/agent-loop.js.map +1 -1
  6. package/dist/dag-orchestrator.d.ts +3 -0
  7. package/dist/dag-orchestrator.d.ts.map +1 -1
  8. package/dist/dag-orchestrator.js +1 -0
  9. package/dist/dag-orchestrator.js.map +1 -1
  10. package/dist/execution-engine.d.ts.map +1 -1
  11. package/dist/execution-engine.js +1 -0
  12. package/dist/execution-engine.js.map +1 -1
  13. package/dist/index.d.ts +5 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +7 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/language-detector.d.ts.map +1 -1
  18. package/dist/language-detector.js +43 -122
  19. package/dist/language-detector.js.map +1 -1
  20. package/dist/language-registry.d.ts +45 -0
  21. package/dist/language-registry.d.ts.map +1 -0
  22. package/dist/language-registry.js +893 -0
  23. package/dist/language-registry.js.map +1 -0
  24. package/dist/llm-client.d.ts +7 -0
  25. package/dist/llm-client.d.ts.map +1 -1
  26. package/dist/llm-client.js +58 -8
  27. package/dist/llm-client.js.map +1 -1
  28. package/dist/skill-loader.d.ts +9 -16
  29. package/dist/skill-loader.d.ts.map +1 -1
  30. package/dist/skill-loader.js +116 -52
  31. package/dist/skill-loader.js.map +1 -1
  32. package/dist/skill-mode-bridge.d.ts +17 -0
  33. package/dist/skill-mode-bridge.d.ts.map +1 -0
  34. package/dist/skill-mode-bridge.js +27 -0
  35. package/dist/skill-mode-bridge.js.map +1 -0
  36. package/dist/skills/code-review.md +58 -0
  37. package/dist/skills/debug.md +45 -0
  38. package/dist/skills/languages/python.md +89 -0
  39. package/dist/skills/languages/react.md +86 -0
  40. package/dist/skills/languages/typescript.md +110 -0
  41. package/dist/skills/plan.md +49 -0
  42. package/dist/skills/refactor.md +46 -0
  43. package/dist/skills/security-scan.md +59 -0
  44. package/dist/skills/skills/code-review.md +58 -0
  45. package/dist/skills/skills/debug.md +45 -0
  46. package/dist/skills/skills/languages/bash.md +74 -0
  47. package/dist/skills/skills/languages/c.md +76 -0
  48. package/dist/skills/skills/languages/cpp.md +75 -0
  49. package/dist/skills/skills/languages/csharp.md +77 -0
  50. package/dist/skills/skills/languages/cuda.md +80 -0
  51. package/dist/skills/skills/languages/dart.md +75 -0
  52. package/dist/skills/skills/languages/docker.md +80 -0
  53. package/dist/skills/skills/languages/elixir.md +80 -0
  54. package/dist/skills/skills/languages/gdscript.md +80 -0
  55. package/dist/skills/skills/languages/go.md +77 -0
  56. package/dist/skills/skills/languages/haskell.md +80 -0
  57. package/dist/skills/skills/languages/java.md +77 -0
  58. package/dist/skills/skills/languages/javascript.md +73 -0
  59. package/dist/skills/skills/languages/kotlin.md +75 -0
  60. package/dist/skills/skills/languages/lua.md +79 -0
  61. package/dist/skills/skills/languages/php.md +73 -0
  62. package/dist/skills/skills/languages/python.md +89 -0
  63. package/dist/skills/skills/languages/r.md +80 -0
  64. package/dist/skills/skills/languages/react.md +86 -0
  65. package/dist/skills/skills/languages/ruby.md +78 -0
  66. package/dist/skills/skills/languages/rust.md +77 -0
  67. package/dist/skills/skills/languages/solidity.md +81 -0
  68. package/dist/skills/skills/languages/sql.md +74 -0
  69. package/dist/skills/skills/languages/svelte.md +74 -0
  70. package/dist/skills/skills/languages/swift.md +74 -0
  71. package/dist/skills/skills/languages/terraform.md +80 -0
  72. package/dist/skills/skills/languages/typescript.md +110 -0
  73. package/dist/skills/skills/languages/verilog.md +80 -0
  74. package/dist/skills/skills/languages/vue.md +73 -0
  75. package/dist/skills/skills/plan.md +49 -0
  76. package/dist/skills/skills/refactor.md +46 -0
  77. package/dist/skills/skills/security-scan.md +59 -0
  78. package/dist/skills/skills/test-driven.md +51 -0
  79. package/dist/skills/test-driven.md +51 -0
  80. package/dist/strategy-selector.d.ts +11 -0
  81. package/dist/strategy-selector.d.ts.map +1 -0
  82. package/dist/strategy-selector.js +85 -0
  83. package/dist/strategy-selector.js.map +1 -0
  84. package/dist/sub-agent.d.ts +3 -0
  85. package/dist/sub-agent.d.ts.map +1 -1
  86. package/dist/sub-agent.js +10 -0
  87. package/dist/sub-agent.js.map +1 -1
  88. package/dist/system-prompt.d.ts +2 -0
  89. package/dist/system-prompt.d.ts.map +1 -1
  90. package/dist/system-prompt.js +469 -94
  91. package/dist/system-prompt.js.map +1 -1
  92. package/dist/types.d.ts +3 -0
  93. package/dist/types.d.ts.map +1 -1
  94. package/dist/types.js.map +1 -1
  95. package/package.json +2 -2
@@ -7,6 +7,41 @@
7
7
  * - Match skill triggers against runtime context
8
8
  * - Load local skills from .yuan/skills/ directory
9
9
  */
10
+ import { fileURLToPath } from "node:url";
11
+ import { dirname, join } from "node:path";
12
+ // Built-in skills shipped with @yuaone/core
13
+ const __dirname = dirname(fileURLToPath(import.meta.url));
14
+ export const BUILTIN_SKILLS_PATH = join(__dirname, "skills");
15
+ // ─── Multilingual field alias map ───
16
+ /** Map of lowercase field label → canonical key */
17
+ const FIELD_ALIASES = {
18
+ // Symptom
19
+ symptom: "symptom",
20
+ symptoms: "symptom",
21
+ "증상": "symptom",
22
+ // Cause
23
+ cause: "cause",
24
+ causes: "cause",
25
+ "원인": "cause",
26
+ // Strategy
27
+ strategy: "strategy",
28
+ solution: "strategy",
29
+ fix: "strategy",
30
+ "전략": "strategy",
31
+ "해결": "strategy",
32
+ // Tool sequence
33
+ "tool sequence": "toolSequence",
34
+ tool_sequence: "toolSequence",
35
+ tools: "toolSequence",
36
+ "도구 시퀀스": "toolSequence",
37
+ "도구": "toolSequence",
38
+ // Pitfall
39
+ pitfall: "pitfall",
40
+ pitfalls: "pitfall",
41
+ warning: "pitfall",
42
+ "함정": "pitfall",
43
+ "주의": "pitfall",
44
+ };
10
45
  export class SkillLoader {
11
46
  /**
12
47
  * Match + parse in one pass.
@@ -124,25 +159,19 @@ export class SkillLoader {
124
159
  return result;
125
160
  }
126
161
  /**
127
- * Parse ### Known Error Patterns subsections.
162
+ * Parse ### pattern subsections under any H2 with "pattern", "error",
163
+ * "known", "패턴", or "에러" in the heading (case-insensitive).
128
164
  *
129
- * Expected format:
130
- * ```
131
- * ### Pattern Name
132
- * - **증상**: "..."
133
- * - **원인**: ...
134
- * - **전략**: 1. ... 2. ...
135
- * - **도구 시퀀스**: grep → file_read → ...
136
- * - **함정**: ...
137
- * ```
165
+ * Fields inside each block are parsed via language-agnostic `**Label:**`
166
+ * detection and normalized through FIELD_ALIASES.
138
167
  */
139
168
  parseKnownPatterns(content) {
140
169
  const patterns = [];
141
- // Find sections that start with ### under ## Known Error Patterns
142
- const knownSection = content.match(/## Known (?:Error )?Patterns\s*\n([\s\S]*?)(?=\n## |\n---|$)/);
143
- if (!knownSection)
170
+ // Match any H2 heading that contains pattern/error/known keywords (multilingual)
171
+ const sectionMatch = content.match(/## [^\n]*(?:pattern|error|known|패턴|에러)[^\n]*\s*\n([\s\S]*?)(?=\n## |\n---|$)/i);
172
+ if (!sectionMatch)
144
173
  return patterns;
145
- const sectionContent = knownSection[1];
174
+ const sectionContent = sectionMatch[1];
146
175
  // Split by ### headers
147
176
  const subsections = sectionContent.split(/\n### /).filter(Boolean);
148
177
  for (const sub of subsections) {
@@ -151,13 +180,49 @@ export class SkillLoader {
151
180
  if (!name)
152
181
  continue;
153
182
  const body = lines.slice(1).join("\n");
183
+ // Parse all **Label:** or **Label**: fields in a language-agnostic way
184
+ const fieldMap = {};
185
+ const fieldRegex = /\*\*([^*]+)\*\*:?\s*(.+)/g;
186
+ let m;
187
+ while ((m = fieldRegex.exec(body)) !== null) {
188
+ const rawLabel = m[1].trim().toLowerCase();
189
+ const canonical = FIELD_ALIASES[rawLabel];
190
+ if (canonical) {
191
+ fieldMap[canonical] = m[2].trim();
192
+ }
193
+ }
194
+ const parseFieldList = (key) => {
195
+ const val = fieldMap[key];
196
+ if (!val)
197
+ return [];
198
+ const quoted = val.match(/"([^"]+)"/);
199
+ if (quoted)
200
+ return [quoted[1]];
201
+ return val.split(/,|;/).map((s) => s.trim()).filter(Boolean);
202
+ };
203
+ const parseToolSeqField = (key) => {
204
+ const val = fieldMap[key];
205
+ if (!val)
206
+ return [];
207
+ return val.split(/→|->|,/).map((t) => t.trim()).filter(Boolean);
208
+ };
209
+ const parseNumberedField = (key) => {
210
+ const val = fieldMap[key];
211
+ if (!val)
212
+ return [];
213
+ // Try numbered items first
214
+ const numbered = [...val.matchAll(/\d+\.\s*(.+)/g)].map((x) => x[1].trim());
215
+ if (numbered.length > 0)
216
+ return numbered;
217
+ return val.split(/,|;/).map((s) => s.trim()).filter(Boolean);
218
+ };
154
219
  const pattern = {
155
220
  name,
156
- symptoms: this.extractListItems(body, /\*\*증상\*\*[:\s]*/i),
157
- causes: this.extractListItems(body, /\*\*원인\*\*[:\s]*/i),
158
- strategy: this.extractNumberedItems(body, /\*\*전략\*\*[:\s]*/i),
159
- tools: this.extractToolSequence(body),
160
- pitfalls: this.extractListItems(body, /\*\*함정\*\*[:\s]*/i),
221
+ symptoms: parseFieldList("symptom"),
222
+ causes: parseFieldList("cause"),
223
+ strategy: parseNumberedField("strategy"),
224
+ tools: parseToolSeqField("toolSequence"),
225
+ pitfalls: parseFieldList("pitfall"),
161
226
  };
162
227
  patterns.push(pattern);
163
228
  }
@@ -196,20 +261,24 @@ export class SkillLoader {
196
261
  /**
197
262
  * Score how well a skill matches the given context.
198
263
  * Returns 0 for no match, higher for better match.
264
+ * Evaluates trigger.requires and trigger.exclude as hard gates.
199
265
  */
200
266
  scoreTriggerMatch(skill, context) {
201
267
  const trigger = skill.trigger;
268
+ let rawScore = 0;
202
269
  switch (trigger.kind) {
203
270
  case "file_pattern": {
204
271
  if (!context.filePath || !trigger.pattern)
205
272
  return 0;
206
- return this.globMatch(trigger.pattern, context.filePath) ? 1 : 0;
273
+ rawScore = this.globMatch(trigger.pattern, context.filePath) ? 1 : 0;
274
+ break;
207
275
  }
208
276
  case "command": {
209
277
  if (!context.command || !trigger.command)
210
278
  return 0;
211
279
  const cmd = context.command.replace(/^\//, "");
212
- return cmd === trigger.command ? 10 : 0; // High score for exact command match
280
+ rawScore = cmd === trigger.command ? 10 : 0; // High score for exact command match
281
+ break;
213
282
  }
214
283
  case "auto": {
215
284
  let score = 0;
@@ -240,48 +309,43 @@ export class SkillLoader {
240
309
  }
241
310
  }
242
311
  }
243
- return score;
312
+ rawScore = score;
313
+ break;
244
314
  }
245
315
  case "manual":
246
316
  return 0;
247
317
  default:
248
318
  return 0;
249
319
  }
250
- }
251
- // ─── Utility Helpers ───
252
- /**
253
- * Extract list items following a marker pattern.
254
- */
255
- extractListItems(content, markerPattern) {
256
- const match = content.match(new RegExp(markerPattern.source + "(.+)", "i"));
257
- if (!match)
258
- return [];
259
- const text = match[1].trim();
260
- // Handle quoted content
261
- const quoted = text.match(/"([^"]+)"/);
262
- if (quoted)
263
- return [quoted[1]];
264
- // Handle comma-separated
265
- return text
266
- .split(/,|;/)
267
- .map((s) => s.trim())
268
- .filter(Boolean);
320
+ // Bug Fix 3: evaluate requires/exclude as hard gates
321
+ return this.applyRequiresExclude(trigger, context, rawScore);
269
322
  }
270
323
  /**
271
- * Extract numbered items (1. ... 2. ... 3. ...).
324
+ * Evaluate trigger.requires and trigger.exclude against context.
325
+ * Returns the adjusted score (0 = hard block, otherwise original score).
272
326
  */
273
- extractNumberedItems(content, markerPattern) {
274
- const markerMatch = content.match(new RegExp(markerPattern.source + "[\\s\\S]*?(?=\\n- \\*\\*|$)", "i"));
275
- if (!markerMatch)
276
- return [];
277
- const section = markerMatch[0];
278
- const items = [];
279
- const matches = section.matchAll(/\d+\.\s*(.+)/g);
280
- for (const match of matches) {
281
- items.push(match[1].trim());
327
+ applyRequiresExclude(trigger, context, score) {
328
+ if (score === 0)
329
+ return 0;
330
+ const ctx = [context.filePath, context.errorMessage, context.taskDescription]
331
+ .filter(Boolean)
332
+ .join(" ")
333
+ .toLowerCase();
334
+ // requires: ALL items must be present in context
335
+ if (trigger.requires?.length) {
336
+ const allPresent = trigger.requires.every((req) => ctx.includes(req.toLowerCase()));
337
+ if (!allPresent)
338
+ return 0; // Hard block — required context missing
282
339
  }
283
- return items;
340
+ // exclude: if ANY exclusion pattern matches, skip this skill
341
+ if (trigger.exclude?.length) {
342
+ const anyExcluded = trigger.exclude.some((exc) => ctx.includes(exc.toLowerCase()));
343
+ if (anyExcluded)
344
+ return 0; // Hard block — exclusion matched
345
+ }
346
+ return score;
284
347
  }
348
+ // ─── Utility Helpers ───
285
349
  /**
286
350
  * Extract tool sequence from a pattern section.
287
351
  */
@@ -1 +1 @@
1
- {"version":3,"file":"skill-loader.js","sourceRoot":"","sources":["../src/skill-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH,MAAM,OAAO,WAAW;IACtB;;OAEG;IACH,oBAAoB,CAClB,MAAyB,EACzB,OAAqB;QAErB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACvD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CACzB,CAAC;IACJ,CAAC;IACD;;;;OAIG;IACH,YAAY,CAAC,KAAsB,EAAE,eAAwB;QAC3D,MAAM,OAAO,GAAG,eAAe,IAAI,KAAK,CAAC,QAAQ,CAAC;QAElD,8DAA8D;QAC9D,IAAI,OAAO,IAAI,2BAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YAChE,2EAA2E;YAC3E,OAAO;gBACL,UAAU,EAAE,KAAK;gBACjB,OAAO;gBACP,aAAa,EAAE,EAAE;gBACjB,mBAAmB,EAAE,EAAE;gBACvB,YAAY,EAAE,EAAE;aACjB,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAA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O,KAAK,CAAC;IACf,CAAC;IAED,0BAA0B;IAE1B;;OAEG;IACK,mBAAmB,CAAC,OAAe;QACzC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CACzB,8CAA8C,CAC/C,CAAC;QACF,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QAEtB,OAAO,KAAK,CAAC,CAAC,CAAC;aACZ,KAAK,CAAC,QAAQ,CAAC;aACf,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,MAAM,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAED;;OAEG;IACK,SAAS,CAAC,OAAe,EAAE,QAAgB;QACjD,MAAM,QAAQ,GAAG,OAAO;aACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;aACrB,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC;aAChC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC;aACvB,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAElC,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC;YAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module skill-mode-bridge
3
+ * @description Maps built-in skill IDs to their corresponding AgentMode values.
4
+ *
5
+ * When a skill is enabled via `/skills enable <id>`, the CLI can use this map
6
+ * to also apply the corresponding agent mode, giving the LLM the right
7
+ * system-prompt suffix and tool restrictions for that skill's domain.
8
+ */
9
+ import type { AgentMode } from "./agent-modes.js";
10
+ /** Map from built-in skill ID to the AgentMode it corresponds to. */
11
+ export declare const SKILL_TO_MODE: Record<string, AgentMode>;
12
+ /**
13
+ * Resolve the AgentMode for a given skill ID.
14
+ * Returns undefined if the skill has no mode mapping.
15
+ */
16
+ export declare function skillToMode(skillId: string): AgentMode | undefined;
17
+ //# sourceMappingURL=skill-mode-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-mode-bridge.d.ts","sourceRoot":"","sources":["../src/skill-mode-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,qEAAqE;AACrE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CASnD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAElE"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @module skill-mode-bridge
3
+ * @description Maps built-in skill IDs to their corresponding AgentMode values.
4
+ *
5
+ * When a skill is enabled via `/skills enable <id>`, the CLI can use this map
6
+ * to also apply the corresponding agent mode, giving the LLM the right
7
+ * system-prompt suffix and tool restrictions for that skill's domain.
8
+ */
9
+ /** Map from built-in skill ID to the AgentMode it corresponds to. */
10
+ export const SKILL_TO_MODE = {
11
+ "code-review": "review",
12
+ "security-scan": "security",
13
+ "test-driven": "test",
14
+ "test-gen": "test",
15
+ refactor: "refactor",
16
+ debug: "debug",
17
+ plan: "plan",
18
+ architect: "architect",
19
+ };
20
+ /**
21
+ * Resolve the AgentMode for a given skill ID.
22
+ * Returns undefined if the skill has no mode mapping.
23
+ */
24
+ export function skillToMode(skillId) {
25
+ return SKILL_TO_MODE[skillId];
26
+ }
27
+ //# sourceMappingURL=skill-mode-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-mode-bridge.js","sourceRoot":"","sources":["../src/skill-mode-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,qEAAqE;AACrE,MAAM,CAAC,MAAM,aAAa,GAA8B;IACtD,aAAa,EAAE,QAAQ;IACvB,eAAe,EAAE,UAAU;IAC3B,aAAa,EAAE,MAAM;IACrB,UAAU,EAAE,MAAM;IAClB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,WAAW;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,58 @@
1
+ ## Identity
2
+ - domain: general
3
+ - type: review
4
+ - confidence: 0.95
5
+
6
+ # Code Review — Correctness, Security, Performance
7
+
8
+ Review in priority order: Correctness → Security → Performance → Style.
9
+ Style comments without correctness/security concerns are noise.
10
+
11
+ ## Severity Levels
12
+ - **CRITICAL** — Will cause data loss, security breach, or crash in production. Must fix before merge.
13
+ - **HIGH** — Likely bug under realistic conditions. Fix before merge.
14
+ - **MEDIUM** — Potential issue under edge cases. Fix recommended.
15
+ - **LOW** — Style, readability, minor improvement. Optional.
16
+
17
+ ## Review Checklist
18
+
19
+ ### Correctness
20
+ - [ ] Does the logic match the intended behavior?
21
+ - [ ] Are all edge cases handled (null, empty, boundary)?
22
+ - [ ] Are error conditions handled or explicitly ignored?
23
+ - [ ] Are async operations awaited where needed?
24
+ - [ ] Are race conditions possible?
25
+
26
+ ### Security
27
+ - [ ] User input validated and sanitized before use?
28
+ - [ ] No string interpolation into SQL/shell/HTML?
29
+ - [ ] No secrets, API keys, or credentials in code?
30
+ - [ ] File paths validated to prevent traversal?
31
+ - [ ] Permissions checked before operations?
32
+
33
+ ### Performance
34
+ - [ ] No N+1 queries in loops?
35
+ - [ ] No unbounded operations on user-controlled input size?
36
+ - [ ] Expensive operations cached where appropriate?
37
+
38
+ ## Known Error Patterns
39
+
40
+ ### Logic Bug — Off By One
41
+ - **Symptom**: Array access, loop bounds, or range checks produce wrong results at edges
42
+ - **Cause**: < vs <=, 0 vs 1 as start index, missing last element
43
+ - **Strategy**: Test with length=0, length=1, and at-boundary inputs
44
+ - **Tool sequence**: file_read → grep (similar patterns) → file_edit
45
+ - **Pitfall**: Do NOT approve logic that was not tested at its boundaries.
46
+
47
+ ### Silent Failure
48
+ - **Symptom**: Function catches error and returns undefined/null/false without logging
49
+ - **Cause**: catch block swallows errors
50
+ - **Strategy**: Flag all catch blocks that do not log or rethrow
51
+ - **Tool sequence**: grep (catch) → file_read → comment
52
+ - **Pitfall**: Do NOT approve silent error suppression in production code paths.
53
+
54
+ ## Validation Checklist
55
+ - [ ] All CRITICAL issues flagged
56
+ - [ ] All HIGH issues flagged
57
+ - [ ] Security review completed
58
+ - [ ] Review output formatted as severity-labeled list
@@ -0,0 +1,45 @@
1
+ ## Identity
2
+ - domain: general
3
+ - type: debug
4
+ - confidence: 0.9
5
+
6
+ # Debug — Reproduce, Trace, Fix, Verify
7
+
8
+ Always reproduce the bug before touching any code. A fix you can't verify didn't happen.
9
+
10
+ ## Workflow
11
+ 1. **Reproduce** — Write a minimal script or test that triggers the bug. Run it. Confirm it fails.
12
+ 2. **Trace** — Read the error message completely. Find the deepest frame in YOUR code (not library internals). Read that file.
13
+ 3. **Localize** — Grep for the function/symbol in the error. Read 3 levels of call hierarchy.
14
+ 4. **Fix** — Smallest change that resolves the root cause. Not the symptom.
15
+ 5. **Verify** — Rerun the reproduction script. Run full test suite. Confirm no regressions.
16
+
17
+ ## Known Error Patterns
18
+
19
+ ### Fixing the Wrong Location
20
+ - **Symptom**: Fix applied, error persists or appears elsewhere
21
+ - **Cause**: Patched a caller when the bug is in the callee, or patched a copy/subclass instead of the source
22
+ - **Strategy**: 1. Grep all files containing the error pattern 2. Read the deepest implementation, not the surface call 3. Fix the source, not the symptom
23
+ - **Tool sequence**: grep → file_read (implementation) → file_edit → shell_exec (reproduce)
24
+ - **Pitfall**: Do NOT assume the first grep result is the right location. Read at least 2 candidates.
25
+
26
+ ### Same Error Repeating After Fix
27
+ - **Symptom**: Retried same fix 2+ times, error unchanged
28
+ - **Cause**: Mental model of the bug is wrong
29
+ - **Strategy**: 1. Stop retrying 2. Read the full error message again from scratch 3. Search for the exact error string in the codebase 4. Try a structurally different approach
30
+ - **Tool sequence**: grep (exact error string) → file_read → re-analyze
31
+ - **Pitfall**: Do NOT make a third attempt with the same approach. The model of the problem is broken.
32
+
33
+ ### Test Passes But Bug Persists
34
+ - **Symptom**: Test green, but reported behavior still broken
35
+ - **Cause**: Test does not cover the actual failure path
36
+ - **Strategy**: 1. Read the bug report carefully 2. Write a reproduction that exactly matches the reported flow 3. If test passes, the reproduction is wrong — fix the test first
37
+ - **Tool sequence**: file_read (test) → write_file (reproduction) → shell_exec
38
+ - **Pitfall**: Do NOT declare fixed based on passing tests alone. Run the exact reported scenario.
39
+
40
+ ## Validation Checklist
41
+ - [ ] Reproduction script confirms the bug exists before fix
42
+ - [ ] Reproduction script confirms the bug is gone after fix
43
+ - [ ] Full test suite passes (no regressions)
44
+ - [ ] Root cause addressed, not just symptom
45
+ - [ ] No unrelated code changed
@@ -0,0 +1,89 @@
1
+ ## Identity
2
+ - domain: python
3
+ - type: language
4
+ - confidence: 0.9
5
+
6
+ # Python — Common Errors and Patterns
7
+
8
+ Read the full traceback from bottom to top. The bottom frame is the immediate cause; the top is the entry point.
9
+
10
+ ## Known Error Patterns
11
+
12
+ ### ModuleNotFoundError
13
+ - **Symptom**: `ModuleNotFoundError: No module named 'x'`
14
+ - **Cause**: Package not installed in the active environment, wrong virtual environment active, or a relative import missing the leading dot (`.`).
15
+ - **Strategy**: 1. Run `pip show <package>` to confirm installation. 2. Confirm the correct virtualenv is active (`which python`). 3. If it is a local module, check whether the import should be relative (`.module`) vs. absolute. 4. If the package is missing, install it and add to requirements.txt or pyproject.toml.
16
+ - **Tool sequence**: shell_exec (`pip show package`) → file_read (requirements.txt or pyproject.toml) → shell_exec (`pip install package`) → file_edit (update requirements)
17
+ - **Pitfall**: Do NOT install globally if the project uses a virtualenv. Installing globally can shadow the wrong version and break other projects.
18
+
19
+ ### IndentationError / TabError
20
+ - **Symptom**: `IndentationError: unexpected indent`, `IndentationError: expected an indented block after ...`, or `TabError: inconsistent use of tabs and spaces`
21
+ - **Cause**: Mixed tabs and spaces in the same file, or wrong indent level after a block opener (`def`, `if`, `for`, `class`, `with`, `try`).
22
+ - **Strategy**: 1. Run `python -m py_compile file.py` to get the exact line. 2. Read that line and the line above it. 3. Use `expand` or editor settings to convert all tabs to 4 spaces. 4. Run `black file.py` or `autopep8 --in-place file.py` to auto-fix indentation.
23
+ - **Tool sequence**: shell_exec (`python -m py_compile file.py`) → file_read (reported line) → shell_exec (`black file.py` or `autopep8 --in-place file.py`)
24
+ - **Pitfall**: Do NOT fix indentation by eye in a file with mixed tabs and spaces. Convert all tabs to spaces first, then fix the structure.
25
+
26
+ ### AttributeError: 'NoneType' has no attribute 'x'
27
+ - **Symptom**: `AttributeError: 'NoneType' object has no attribute 'foo'`
28
+ - **Cause**: A variable expected to hold an object is `None`. Typically from a function that returns `None` on failure, an uninitialized field, or a failed ORM query.
29
+ - **Strategy**: 1. Find where the variable is assigned (trace the traceback up). 2. Determine whether `None` is a valid value or an error. 3. If `None` is unexpected, add an assertion or raise early: `if obj is None: raise ValueError(...)`. 4. If `None` is valid, add a guard: `if obj is not None: obj.foo`.
30
+ - **Tool sequence**: file_read (assignment site from traceback) → file_edit (add None check or early raise)
31
+ - **Pitfall**: Do NOT use `getattr(obj, 'foo', None)` to hide the `None` object — that shifts the error downstream. Fix the root cause.
32
+
33
+ ### TypeError — Wrong Number of Arguments
34
+ - **Symptom**: `TypeError: foo() takes X positional arguments but Y were given` or `TypeError: foo() missing Y required positional arguments`
35
+ - **Cause**: Calling a function with wrong argument count. Common: forgetting `self` when calling a method as a function, or passing too many positional args when some should be keyword args.
36
+ - **Strategy**: 1. Grep the function definition to read its signature. 2. Count the parameters. 3. Check if it is a method (requires `self`). 4. Fix the call site to match the signature.
37
+ - **Tool sequence**: grep (function/method name `def`) → file_read → file_edit (fix call site)
38
+ - **Pitfall**: Do NOT add `*args` or `**kwargs` to the function signature to silence the error. Fix the call.
39
+
40
+ ### TypeError — Unsupported Operand Types
41
+ - **Symptom**: `TypeError: unsupported operand type(s) for +: 'int' and 'str'`
42
+ - **Cause**: Mixing incompatible types in an arithmetic or comparison operation. Often from user input (always a string) or mixed data sources.
43
+ - **Strategy**: 1. Read the line in the traceback. 2. Identify which variable has the unexpected type. 3. Add an explicit conversion: `int(x)`, `str(x)`, `float(x)` at the right point. 4. Add a type check if the input source is untrusted.
44
+ - **Tool sequence**: file_read (traceback line) → file_edit (add explicit conversion)
45
+ - **Pitfall**: Do NOT add a bare `try/except` around the operation to hide the error. Convert the type before the operation.
46
+
47
+ ### KeyError on Dictionary Access
48
+ - **Symptom**: `KeyError: 'foo'`
49
+ - **Cause**: Accessing `dict['key']` when the key does not exist.
50
+ - **Strategy**: 1. Use `dict.get('key')` to return `None` when missing, or `dict.get('key', default)` for a default value. 2. If the key must exist, add an assertion or raise with a descriptive message: `if 'key' not in d: raise KeyError(f"Expected key 'key' in {d}")`. 3. If reading from external data, validate the schema before access.
51
+ - **Tool sequence**: file_read (traceback line) → file_edit (replace `dict[key]` with `dict.get(key)` or add guard)
52
+ - **Pitfall**: Do NOT wrap the access in bare `except KeyError: pass`. That hides missing data bugs.
53
+
54
+ ### Circular Import
55
+ - **Symptom**: `ImportError: cannot import name 'X' from partially initialized module 'y'`
56
+ - **Cause**: Module A imports from module B, and module B imports from module A at the top level.
57
+ - **Strategy**: 1. Grep import statements in both modules to confirm the cycle. 2. Move shared types or functions to a third module that neither imports from the other two. 3. Alternatively, use a lazy import (move the import inside the function that needs it). 4. Avoid restructuring via `importlib.import_module` — that just hides the problem.
58
+ - **Tool sequence**: grep (import statements in both modules) → file_read → file_edit (move shared code to third module or use lazy import)
59
+ - **Pitfall**: Do NOT move the import to the bottom of the file as a workaround. That makes the dependency order implicit and fragile.
60
+
61
+ ### RecursionError — Maximum Depth Exceeded
62
+ - **Symptom**: `RecursionError: maximum recursion depth exceeded`
63
+ - **Cause**: A recursive function has no base case, or the base case is never reached for the given input, or two functions call each other indefinitely.
64
+ - **Strategy**: 1. Read the function and identify the base case. 2. Add a print or log to confirm the base case is reachable. 3. If depth is legitimately large, increase with `sys.setrecursionlimit(N)` as a last resort. 4. Convert deep recursion to an iterative loop with an explicit stack.
65
+ - **Tool sequence**: file_read (recursive function) → file_edit (add/fix base case or convert to loop)
66
+ - **Pitfall**: Do NOT just increase the recursion limit without fixing the base case — that defers the crash.
67
+
68
+ ### ValueError from Type Conversion
69
+ - **Symptom**: `ValueError: invalid literal for int() with base 10: 'abc'`
70
+ - **Cause**: Attempting to convert a string that does not represent the target type.
71
+ - **Strategy**: 1. Validate the input before conversion. 2. Wrap in a try/except and handle the ValueError specifically. 3. For user-facing input, return an error message rather than crashing.
72
+ - **Tool sequence**: file_read (conversion site) → file_edit (add try/except ValueError or pre-validation)
73
+ - **Pitfall**: Do NOT use a bare `except:` or `except Exception:`. Catch `ValueError` specifically.
74
+
75
+ ## Verification
76
+ - Syntax: `python -m py_compile file.py` — exit 0 means no syntax errors.
77
+ - Tests: `pytest` or `python -m pytest` — all tests must pass.
78
+ - Type check (if project uses mypy): `mypy .` — zero errors.
79
+ - Linting: `flake8 .` or `ruff check .`
80
+
81
+ ## Validation Checklist
82
+ - [ ] `python -m py_compile` exits 0 on all modified files
83
+ - [ ] All imports resolve in the active virtual environment
84
+ - [ ] No mixed tabs and spaces (run `black` or `autopep8`)
85
+ - [ ] All None-returning function calls guarded before attribute access
86
+ - [ ] All dict accesses use `.get()` or have key existence check
87
+ - [ ] Recursive functions have a reachable base case
88
+ - [ ] Tests pass with `pytest`
89
+ - [ ] mypy exits 0 if the project has a mypy configuration
@@ -0,0 +1,86 @@
1
+ ## Identity
2
+ - domain: react
3
+ - type: language
4
+ - confidence: 0.9
5
+
6
+ # React — Hook Rules, Rendering, and Common Errors
7
+
8
+ Read the full error message and component stack before touching any code.
9
+
10
+ ## Hook Rules (Enforced by eslint-plugin-react-hooks)
11
+ - Call hooks only at the top level of a function component — never inside conditions, loops, or nested functions.
12
+ - Call hooks only from React function components or other custom hooks.
13
+ - Custom hooks must start with `use`.
14
+ - These rules are not style preferences — violating them causes non-deterministic behavior and crashes that are hard to reproduce.
15
+
16
+ ## Known Error Patterns
17
+
18
+ ### Hook Called Conditionally
19
+ - **Symptom**: ESLint error `React Hook "useX" is called conditionally` — or a runtime crash: `Rendered more hooks than during the previous render`
20
+ - **Cause**: Hook call placed inside an `if` block, after an early `return`, or inside a loop. React requires the same hooks to run in the same order on every render.
21
+ - **Strategy**: Move all hook calls to the top of the component function, above any conditional logic. If the hook should only do something conditionally, move the condition inside the hook's callback or pass a flag to the hook.
22
+ - **Tool sequence**: file_read (component) → file_edit (move hook calls above all conditionals)
23
+ - **Pitfall**: Do NOT wrap hook calls in try/catch or ternary expressions. Restructure the component so all hooks run unconditionally.
24
+
25
+ ### Stale Closure in useEffect
26
+ - **Symptom**: Effect reads an old value of state or props. The callback always has the value from the first render regardless of updates.
27
+ - **Cause**: The dependency array is incomplete — it is missing variables that are read inside the effect.
28
+ - **Strategy**: Add every variable read inside the effect body to the dependency array. If adding a function reference creates an infinite loop, wrap the function in `useCallback` with its own deps. If adding an object creates an infinite loop, use `useMemo` or restructure to pass only primitive values.
29
+ - **Tool sequence**: file_read (useEffect block and deps array) → file_edit (add missing deps)
30
+ - **Pitfall**: Do NOT add `// eslint-disable-next-line react-hooks/exhaustive-deps` to suppress the exhaustive-deps warning. Fix the missing dependencies.
31
+
32
+ ### Infinite Re-render Loop
33
+ - **Symptom**: Component re-renders continuously; browser tab becomes unresponsive or crashes.
34
+ - **Cause**: One of: (a) `setState` called unconditionally inside `useEffect` with no deps or with deps that always change, (b) an object or array literal created inline is in the dependency array (new reference every render), (c) parent passes a new object/function prop on every render.
35
+ - **Strategy**: 1. Read every `useEffect` in the component. Find any `setState` call without a guard condition. 2. Check the deps array for inline object/array literals — move them outside the component or wrap in `useMemo`/`useCallback`. 3. If the loop comes from a parent prop, memoize the prop at the parent.
36
+ - **Tool sequence**: file_read (all useEffect blocks) → file_edit (add condition or memoize deps)
37
+ - **Pitfall**: Do NOT add an empty dependency array `[]` to stop the loop without understanding why it loops. That causes stale closure bugs.
38
+
39
+ ### Hydration Mismatch (Next.js / SSR)
40
+ - **Symptom**: `Error: Text content does not match server-rendered HTML` or `Error: Hydration failed because the initial UI does not match what was rendered on the server`
41
+ - **Cause**: Component renders different content on server vs. client. Common sources: `Date.now()`, `Math.random()`, `window` access, browser-only APIs, locale-dependent formatting.
42
+ - **Strategy**: 1. Identify the value that differs between server and client renders. 2. Move it into a `useEffect` with a local state variable — `useEffect` only runs on the client. 3. Render a placeholder or `null` on first render, then update after mount. 4. Use `suppressHydrationWarning` only on elements with genuinely intentional dynamic content such as timestamps.
43
+ - **Tool sequence**: file_read (component) → file_edit (move dynamic value to useEffect + useState)
44
+ - **Pitfall**: Do NOT use `suppressHydrationWarning` as a general fix. It hides real bugs where content genuinely differs.
45
+
46
+ ### Missing key Prop in List
47
+ - **Symptom**: React warning `Each child in a list should have a unique "key" prop`
48
+ - **Cause**: `Array.map()` renders JSX elements without a `key` prop, or key is not unique within the list.
49
+ - **Strategy**: Add a stable, unique `key` to each element. Use the item's ID from data, not the array index.
50
+ - **Tool sequence**: grep (`\.map(`) → file_read (render section) → file_edit (add key prop)
51
+ - **Pitfall**: Do NOT use array index as key when the list can reorder, filter, or have items added or removed. Index keys cause incorrect reconciliation and state bugs.
52
+
53
+ ### Cannot Read Property of Undefined (During Render)
54
+ - **Symptom**: `TypeError: Cannot read properties of undefined (reading 'x')` thrown during render
55
+ - **Cause**: Component accesses a property on a value that is `undefined` or `null` at mount time — typically async data, optional props, or uninitialized store state.
56
+ - **Strategy**: 1. Add a loading/null guard before the access: `if (!data) return null` or `data?.property`. 2. Provide a default value in the prop type or initial state. 3. Never assume async data is available at first render.
57
+ - **Tool sequence**: file_read (render return and prop types) → file_edit (add guard)
58
+ - **Pitfall**: Do NOT add `!` non-null assertion in TypeScript to hide this — the crash will still happen at runtime.
59
+
60
+ ### Context Value Lost After Rerender
61
+ - **Symptom**: Component reads default context value instead of the provided value; context updates do not propagate.
62
+ - **Cause**: Provider is placed too low in the tree, or `value` prop creates a new object every render causing unnecessary re-renders and sometimes missed updates.
63
+ - **Strategy**: 1. Confirm the consuming component is inside the Provider in the tree. 2. Memoize the context value with `useMemo` to prevent new object reference on every render. 3. Split contexts if one high-frequency value is causing all consumers to re-render.
64
+ - **Tool sequence**: file_read (Provider placement) → file_read (consumer component) → file_edit (add useMemo to context value)
65
+ - **Pitfall**: Do NOT create the context value inline in the JSX without memoization — `value={{ foo, bar }}` creates a new object on every render.
66
+
67
+ ### useRef Value Not Triggering Re-render
68
+ - **Symptom**: Component does not update when a `ref.current` value changes.
69
+ - **Cause**: `useRef` mutations do not trigger re-renders — this is by design.
70
+ - **Strategy**: If you need UI to update when a value changes, use `useState` or `useReducer` instead. Use `useRef` only for values that should NOT trigger re-renders: DOM references, timers, previous value tracking, and imperative handles.
71
+ - **Tool sequence**: file_read (ref usage) → file_edit (convert to useState if re-render is needed)
72
+ - **Pitfall**: Do NOT try to force a re-render after mutating a ref. Switch to state.
73
+
74
+ ## Verification
75
+ - ESLint: `eslint --ext .tsx,.ts src/` — look for `react-hooks/rules-of-hooks` and `react-hooks/exhaustive-deps` violations.
76
+ - Type check: `tsc --noEmit`
77
+ - Dev server: confirm no console errors beginning with `Warning: ` or `Error: ` in the browser.
78
+
79
+ ## Validation Checklist
80
+ - [ ] All hooks called unconditionally at component top level, before any early returns
81
+ - [ ] useEffect dependency arrays include all referenced variables (no exhaustive-deps suppressions)
82
+ - [ ] No inline object or array literals in dependency arrays
83
+ - [ ] All list renders have stable unique keys from data (not array index)
84
+ - [ ] Browser-only code wrapped in useEffect or guarded with `typeof window !== "undefined"`
85
+ - [ ] Context values memoized with useMemo if they are object or array literals
86
+ - [ ] Async data access guarded with null/undefined check at render time