@yuaone/core 0.8.5 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -2
- package/dist/agent-loop.d.ts +8 -0
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +34 -0
- package/dist/agent-loop.js.map +1 -1
- package/dist/dag-orchestrator.d.ts +3 -0
- package/dist/dag-orchestrator.d.ts.map +1 -1
- package/dist/dag-orchestrator.js +1 -0
- package/dist/dag-orchestrator.js.map +1 -1
- package/dist/execution-engine.d.ts.map +1 -1
- package/dist/execution-engine.js +1 -0
- package/dist/execution-engine.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/language-detector.d.ts.map +1 -1
- package/dist/language-detector.js +43 -122
- package/dist/language-detector.js.map +1 -1
- package/dist/language-registry.d.ts +45 -0
- package/dist/language-registry.d.ts.map +1 -0
- package/dist/language-registry.js +893 -0
- package/dist/language-registry.js.map +1 -0
- package/dist/llm-client.d.ts +7 -0
- package/dist/llm-client.d.ts.map +1 -1
- package/dist/llm-client.js +58 -8
- package/dist/llm-client.js.map +1 -1
- package/dist/skill-loader.d.ts +9 -16
- package/dist/skill-loader.d.ts.map +1 -1
- package/dist/skill-loader.js +116 -52
- package/dist/skill-loader.js.map +1 -1
- package/dist/skill-mode-bridge.d.ts +17 -0
- package/dist/skill-mode-bridge.d.ts.map +1 -0
- package/dist/skill-mode-bridge.js +27 -0
- package/dist/skill-mode-bridge.js.map +1 -0
- package/dist/skills/code-review.md +58 -0
- package/dist/skills/debug.md +45 -0
- package/dist/skills/languages/bash.md +74 -0
- package/dist/skills/languages/c.md +76 -0
- package/dist/skills/languages/cpp.md +75 -0
- package/dist/skills/languages/csharp.md +77 -0
- package/dist/skills/languages/cuda.md +80 -0
- package/dist/skills/languages/dart.md +75 -0
- package/dist/skills/languages/docker.md +80 -0
- package/dist/skills/languages/elixir.md +80 -0
- package/dist/skills/languages/gdscript.md +80 -0
- package/dist/skills/languages/go.md +77 -0
- package/dist/skills/languages/haskell.md +80 -0
- package/dist/skills/languages/java.md +77 -0
- package/dist/skills/languages/javascript.md +73 -0
- package/dist/skills/languages/kotlin.md +75 -0
- package/dist/skills/languages/lua.md +79 -0
- package/dist/skills/languages/php.md +73 -0
- package/dist/skills/languages/python.md +89 -0
- package/dist/skills/languages/r.md +80 -0
- package/dist/skills/languages/react.md +86 -0
- package/dist/skills/languages/ruby.md +78 -0
- package/dist/skills/languages/rust.md +77 -0
- package/dist/skills/languages/solidity.md +81 -0
- package/dist/skills/languages/sql.md +74 -0
- package/dist/skills/languages/svelte.md +74 -0
- package/dist/skills/languages/swift.md +74 -0
- package/dist/skills/languages/terraform.md +80 -0
- package/dist/skills/languages/typescript.md +110 -0
- package/dist/skills/languages/verilog.md +80 -0
- package/dist/skills/languages/vue.md +73 -0
- package/dist/skills/plan.md +49 -0
- package/dist/skills/refactor.md +46 -0
- package/dist/skills/security-scan.md +59 -0
- package/dist/skills/test-driven.md +51 -0
- package/dist/strategy-selector.d.ts +11 -0
- package/dist/strategy-selector.d.ts.map +1 -0
- package/dist/strategy-selector.js +85 -0
- package/dist/strategy-selector.js.map +1 -0
- package/dist/sub-agent.d.ts +3 -0
- package/dist/sub-agent.d.ts.map +1 -1
- package/dist/sub-agent.js +10 -0
- package/dist/sub-agent.js.map +1 -1
- package/dist/system-prompt.d.ts +2 -0
- package/dist/system-prompt.d.ts.map +1 -1
- package/dist/system-prompt.js +469 -94
- package/dist/system-prompt.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/skill-loader.js
CHANGED
|
@@ -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 ###
|
|
162
|
+
* Parse ### pattern subsections under any H2 with "pattern", "error",
|
|
163
|
+
* "known", "패턴", or "에러" in the heading (case-insensitive).
|
|
128
164
|
*
|
|
129
|
-
*
|
|
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
|
-
//
|
|
142
|
-
const
|
|
143
|
-
if (!
|
|
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 =
|
|
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:
|
|
157
|
-
causes:
|
|
158
|
-
strategy:
|
|
159
|
-
tools:
|
|
160
|
-
pitfalls:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
324
|
+
* Evaluate trigger.requires and trigger.exclude against context.
|
|
325
|
+
* Returns the adjusted score (0 = hard block, otherwise original score).
|
|
272
326
|
*/
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
-
|
|
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
|
*/
|
package/dist/skill-loader.js.map
CHANGED
|
@@ -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,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,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,74 @@
|
|
|
1
|
+
## Identity
|
|
2
|
+
- domain: bash
|
|
3
|
+
- type: language
|
|
4
|
+
- confidence: 0.90
|
|
5
|
+
|
|
6
|
+
# Bash/Shell — Error Pattern Reference
|
|
7
|
+
|
|
8
|
+
Always start scripts with `#!/usr/bin/env bash` and `set -euo pipefail`. Most Bash bugs are invisible without these settings. Use `shellcheck` for static analysis.
|
|
9
|
+
|
|
10
|
+
## Quick Reference
|
|
11
|
+
- **exit code 127** — Command not found.
|
|
12
|
+
- **exit code 126** — Command found but not executable (permission issue).
|
|
13
|
+
- **exit code 1** — General error; check the command's stderr.
|
|
14
|
+
- **unbound variable** — `set -u` is active and an unset variable was used.
|
|
15
|
+
- **broken pipe** — Consumer of a pipeline exited before producer finished.
|
|
16
|
+
|
|
17
|
+
## Known Error Patterns
|
|
18
|
+
|
|
19
|
+
### Unbound Variable (set -u)
|
|
20
|
+
- **Symptom**: `bash: FOO: unbound variable` — script exits immediately.
|
|
21
|
+
- **Cause**: `set -u` (nounset) is active and a variable is referenced before being assigned. Common with optional variables, unset environment variables, or array out-of-bounds access.
|
|
22
|
+
- **Strategy**: 1. Identify the variable. 2. Provide a default: `${FOO:-default_value}`. Use `${FOO:-}` (empty default) if an empty string is acceptable. 3. For required variables, add an explicit check before use: `if [[ -z "${FOO:-}" ]]; then echo "FOO is required" >&2; exit 1; fi`.
|
|
23
|
+
- **Tool sequence**: file_read (script lines around error) → file_edit (add `${VAR:-default}` or explicit check)
|
|
24
|
+
- **Pitfall**: Do NOT remove `set -u` to silence the error. The unbound variable is the real bug.
|
|
25
|
+
|
|
26
|
+
### Word Splitting on Unquoted Variable
|
|
27
|
+
- **Symptom**: Script fails or behaves wrong when a variable contains spaces or glob characters. A filename like `my file.txt` becomes two arguments.
|
|
28
|
+
- **Cause**: Unquoted variable expansion in Bash: `$var` undergoes word splitting and pathname expansion. `"$var"` does not.
|
|
29
|
+
- **Strategy**: 1. Quote all variable expansions: `"$var"`, `"$@"`, `"${array[@]}"`. 2. Run `shellcheck <script>` — it flags all unquoted variables. 3. For arrays, always use `"${arr[@]}"` not `${arr[*]}`.
|
|
30
|
+
- **Tool sequence**: shell_exec (`shellcheck <script>`) → file_read (flagged lines) → file_edit (add quotes)
|
|
31
|
+
- **Pitfall**: Do NOT use single quotes `'$var'` — that prevents expansion entirely. Use double quotes `"$var"`.
|
|
32
|
+
|
|
33
|
+
### Missing pipefail (set -eo pipefail)
|
|
34
|
+
- **Symptom**: Script reports success even when a command in a pipeline fails. E.g., `false | tee output.txt` exits 0 without `pipefail`.
|
|
35
|
+
- **Cause**: Without `set -o pipefail`, a pipeline's exit code is only the last command's exit code. Failures in earlier pipeline stages are silently ignored.
|
|
36
|
+
- **Strategy**: 1. Add `set -euo pipefail` at the top of every script (after the shebang). 2. For individual pipelines where partial failure is expected, use `set +o pipefail` around that block and restore it after.
|
|
37
|
+
- **Tool sequence**: file_read (top of script) → file_edit (add `set -euo pipefail` after shebang)
|
|
38
|
+
- **Pitfall**: `set -e` alone is not enough for pipelines. Always pair it with `set -o pipefail`.
|
|
39
|
+
|
|
40
|
+
### Command Not Found in PATH
|
|
41
|
+
- **Symptom**: `command not found: foo` — exit code 127.
|
|
42
|
+
- **Cause**: The command is not in any directory listed in `$PATH`. Common when running scripts as a different user (cron, sudo), in Docker containers with minimal PATH, or when a tool is installed in a non-standard location.
|
|
43
|
+
- **Strategy**: 1. Run `which foo` or `type foo` to verify presence in the current shell. 2. For cron and CI, always use absolute paths: `/usr/bin/foo` or `/usr/local/bin/foo`. 3. If the tool is optional, check before use: `if ! command -v foo &>/dev/null; then echo "foo not installed" >&2; exit 1; fi`. 4. Source the correct profile/environment if the tool is installed via a version manager (nvm, rbenv, pyenv).
|
|
44
|
+
- **Tool sequence**: shell_exec (`which foo`) → shell_exec (`echo $PATH`) → file_edit (use absolute path or add PATH setup)
|
|
45
|
+
- **Pitfall**: Do NOT hardcode `/usr/bin/foo` if the tool may be in `/usr/local/bin` on some systems. Use `command -v` to find it dynamically when portability matters.
|
|
46
|
+
|
|
47
|
+
### Wrong or Missing Shebang
|
|
48
|
+
- **Symptom**: Script runs with the wrong interpreter (e.g., `sh` instead of `bash`), causing `[[`, arrays, or `local` to fail with syntax errors. Or: permission denied / bad interpreter.
|
|
49
|
+
- **Cause**: Shebang (`#!`) is missing, wrong (`#!/bin/sh` when bashisms are used), or the path is wrong for the target system.
|
|
50
|
+
- **Strategy**: 1. Use `#!/usr/bin/env bash` for portability — `env` finds bash in PATH. 2. Use `#!/bin/sh` only if the script is strictly POSIX sh. 3. If using `[[`, arrays, `local`, `$((...))`, `declare`, or `source`, the shebang must be `bash`. 4. Ensure the file has execute permission: `chmod +x script.sh`.
|
|
51
|
+
- **Tool sequence**: file_read (first line of script) → file_edit (fix shebang) → shell_exec (`chmod +x`)
|
|
52
|
+
- **Pitfall**: On some systems (Alpine Linux, minimal Docker), `/bin/bash` does not exist. Use `#!/usr/bin/env bash` instead.
|
|
53
|
+
|
|
54
|
+
### Arithmetic — Unintended Glob Expansion
|
|
55
|
+
- **Symptom**: Script exits unexpectedly, or `*` in an expression matches files instead of meaning multiplication.
|
|
56
|
+
- **Cause**: In `[[ ]]` or `$(( ))`, operators like `*`, `?`, `[` have special meanings. Outside these contexts they trigger pathname expansion.
|
|
57
|
+
- **Strategy**: 1. Always use `$(( expr ))` for arithmetic, never `expr` or `let` in new scripts. 2. Quote file patterns that should be treated as literals. 3. Use `[[ ]]` instead of `[ ]` for conditionals — `[[ ]]` does not perform pathname or word splitting.
|
|
58
|
+
- **Tool sequence**: file_read (expression line) → file_edit (replace `[ ]` with `[[ ]]`, wrap arithmetic in `$(( ))`)
|
|
59
|
+
- **Pitfall**: `(( ))` arithmetic returns exit code 1 when the result is 0, which triggers `set -e`. Use `(( expr )) || true` or wrap in an `if`.
|
|
60
|
+
|
|
61
|
+
## Verification
|
|
62
|
+
Run: `shellcheck <script>` — address all SC#### warnings before deployment.
|
|
63
|
+
- For syntax check only: `bash -n <script>`.
|
|
64
|
+
- Test with edge-case inputs: empty strings, paths with spaces, special characters.
|
|
65
|
+
|
|
66
|
+
## Validation Checklist
|
|
67
|
+
- [ ] `#!/usr/bin/env bash` on first line
|
|
68
|
+
- [ ] `set -euo pipefail` on second line
|
|
69
|
+
- [ ] `shellcheck` reports zero warnings
|
|
70
|
+
- [ ] All variable expansions quoted: `"$var"`, `"${arr[@]}"`
|
|
71
|
+
- [ ] All external commands referenced by absolute path in cron/CI contexts
|
|
72
|
+
- [ ] `command -v` used to check optional tools before use
|
|
73
|
+
- [ ] No `[ ]` — replaced with `[[ ]]` for conditionals
|
|
74
|
+
- [ ] Arithmetic done in `$(( ))` not with `expr`
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
## Identity
|
|
2
|
+
- domain: c
|
|
3
|
+
- type: language
|
|
4
|
+
- confidence: 0.93
|
|
5
|
+
|
|
6
|
+
# C — Error Pattern Reference
|
|
7
|
+
|
|
8
|
+
Compile with warnings enabled: `-Wall -Wextra -Werror`. Many C bugs are silent at compile time but fatal at runtime. Always use a sanitizer (`-fsanitize=address,undefined`) during development.
|
|
9
|
+
|
|
10
|
+
## Compiler Warning Quick Reference
|
|
11
|
+
- **-Wimplicit-function-declaration** — Calling a function without a prototype.
|
|
12
|
+
- **-Wuninitialized** — Variable used before assignment.
|
|
13
|
+
- **-Wformat** — printf/scanf format string mismatch.
|
|
14
|
+
- **-Wreturn-type** — Missing return in non-void function.
|
|
15
|
+
- **-Warray-bounds** — Array index out of declared bounds (static analysis only).
|
|
16
|
+
- **-Wconversion** — Implicit narrowing conversion.
|
|
17
|
+
- **-Wnull-dereference** — Pointer that may be NULL is dereferenced.
|
|
18
|
+
|
|
19
|
+
## Known Error Patterns
|
|
20
|
+
|
|
21
|
+
### Segmentation Fault — Null Pointer Dereference
|
|
22
|
+
- **Symptom**: Program crashes with `Segmentation fault (core dumped)`. GDB shows crash at a pointer dereference.
|
|
23
|
+
- **Cause**: Dereferencing a pointer that is NULL, uninitialized, or has been freed. Common after `malloc` failure (returns NULL), a function returning NULL on error, or using a pointer before assignment.
|
|
24
|
+
- **Strategy**: 1. Run under GDB: `gdb ./program core` then `bt` for backtrace. 2. Identify the faulting line. 3. Add a NULL check before every pointer dereference. 4. For `malloc`: always check `if (ptr == NULL) { /* handle */ }` immediately after allocation. 5. Run with AddressSanitizer: `gcc -fsanitize=address -g` for detailed diagnostics.
|
|
25
|
+
- **Tool sequence**: shell_exec (`gcc -g -fsanitize=address`) → shell_exec (run program) → file_read (faulting line) → file_edit (add NULL check)
|
|
26
|
+
- **Pitfall**: Do NOT assume `malloc` always succeeds. Check the return value every time.
|
|
27
|
+
|
|
28
|
+
### Buffer Overflow — strcpy / gets / sprintf
|
|
29
|
+
- **Symptom**: Program writes garbage data, crashes unpredictably, or behaves differently between debug and release builds. ASan reports `heap-buffer-overflow` or `stack-buffer-overflow`.
|
|
30
|
+
- **Cause**: `strcpy`, `gets`, `sprintf`, or manual loop writes beyond the allocated buffer. `gets` has no length argument and is inherently unsafe.
|
|
31
|
+
- **Strategy**: 1. Replace `gets` with `fgets(buf, sizeof(buf), stdin)`. 2. Replace `strcpy(dst, src)` with `strncpy(dst, src, sizeof(dst) - 1); dst[sizeof(dst)-1] = '\0';` or use `strlcpy` if available. 3. Replace `sprintf` with `snprintf(buf, sizeof(buf), fmt, ...)`. 4. Audit every buffer write in the file for bound checks.
|
|
32
|
+
- **Tool sequence**: grep (`strcpy\|gets\|sprintf`) → file_read → file_edit (replace with safe variants)
|
|
33
|
+
- **Pitfall**: `strncpy` does NOT null-terminate if the source is longer than n. Always manually set `dst[n-1] = '\0'`.
|
|
34
|
+
|
|
35
|
+
### Memory Leak — malloc Without free
|
|
36
|
+
- **Symptom**: Program memory usage grows unboundedly. Valgrind reports `definitely lost` or `indirectly lost` blocks.
|
|
37
|
+
- **Cause**: Memory allocated with `malloc`/`calloc`/`realloc` is not freed on all code paths, especially error paths.
|
|
38
|
+
- **Strategy**: 1. Run with Valgrind: `valgrind --leak-check=full ./program`. 2. For each allocation, trace all code paths and confirm `free` is called. 3. Use a consistent pattern: allocate near the start of a scope, free at the end via a cleanup label (`goto cleanup`). 4. Ensure error paths also reach the cleanup label.
|
|
39
|
+
- **Tool sequence**: shell_exec (`valgrind --leak-check=full`) → grep (`malloc\|calloc`) → file_read (all exit paths) → file_edit (add free on all paths)
|
|
40
|
+
- **Pitfall**: Do NOT free a pointer and then use it. Set it to NULL after freeing: `free(p); p = NULL;`.
|
|
41
|
+
|
|
42
|
+
### Undefined Behavior — Signed Integer Overflow
|
|
43
|
+
- **Symptom**: Unexpected values or crashes only in optimized builds (`-O2`). UBSan reports `signed integer overflow`.
|
|
44
|
+
- **Cause**: Signed integer overflow is undefined behavior in C. Compilers exploit this for optimization, leading to code elimination or wrong values. Common in loop counters, hash functions, and arithmetic.
|
|
45
|
+
- **Strategy**: 1. Compile with `-fsanitize=undefined` to detect overflows. 2. For arithmetic that may overflow, use unsigned types or check before the operation: `if (a > INT_MAX - b) { /* overflow */ }`. 3. Do NOT rely on signed wrap-around behavior.
|
|
46
|
+
- **Tool sequence**: shell_exec (`gcc -fsanitize=undefined -g`) → file_read (arithmetic code) → file_edit (add overflow check or use unsigned)
|
|
47
|
+
- **Pitfall**: Do NOT use `(int)(a + b)` cast to suppress the warning. The overflow happens before the cast.
|
|
48
|
+
|
|
49
|
+
### Implicit Function Declaration
|
|
50
|
+
- **Symptom**: Compiler warning: `implicit declaration of function 'foo'`; in C99 and later this is an error.
|
|
51
|
+
- **Cause**: Calling a function before its prototype is declared. Missing `#include` for a library function, or a function defined later in the file without a forward declaration.
|
|
52
|
+
- **Strategy**: 1. For standard library functions, identify and add the correct `#include`. 2. For project-internal functions, add a forward declaration at the top of the file or move the definition above the call site. 3. Always compile with `-Wimplicit-function-declaration -Werror`.
|
|
53
|
+
- **Tool sequence**: grep (`#include`) → file_read (function call line) → shell_exec (`man <function>` for required header) → file_edit (add include or forward declaration)
|
|
54
|
+
- **Pitfall**: Do NOT add an implicit `int` return type declaration manually — add the full correct prototype.
|
|
55
|
+
|
|
56
|
+
### Use of Uninitialized Variable
|
|
57
|
+
- **Symptom**: Garbage values read, random behavior, or UBSan reports `use of uninitialized value`.
|
|
58
|
+
- **Cause**: Local variable declared but not assigned before first read. Conditional initialization that misses a code path.
|
|
59
|
+
- **Strategy**: 1. Compile with `-Wuninitialized`. 2. Initialize all local variables at declaration: `int count = 0;`, `char *p = NULL;`. 3. For structs, use `= {0}` to zero-initialize: `struct Foo f = {0};`.
|
|
60
|
+
- **Tool sequence**: shell_exec (`gcc -Wall -Wuninitialized`) → file_read (variable declaration) → file_edit (add initializer)
|
|
61
|
+
- **Pitfall**: Do NOT rely on global/static variables being zero-initialized to justify skipping local initialization. Be explicit.
|
|
62
|
+
|
|
63
|
+
## Verification
|
|
64
|
+
Compile command: `gcc -Wall -Wextra -Werror -g -fsanitize=address,undefined -o program main.c`
|
|
65
|
+
- Fix all warnings before proceeding — `-Werror` enforces this.
|
|
66
|
+
- Run Valgrind for memory checks in CI: `valgrind --error-exitcode=1 ./program`
|
|
67
|
+
|
|
68
|
+
## Validation Checklist
|
|
69
|
+
- [ ] `gcc -Wall -Wextra -Werror` produces zero warnings
|
|
70
|
+
- [ ] Every `malloc`/`calloc`/`realloc` return value checked for NULL
|
|
71
|
+
- [ ] Every `free` followed by setting pointer to NULL
|
|
72
|
+
- [ ] No `gets`, `strcpy`, or unbounded `sprintf` in codebase
|
|
73
|
+
- [ ] All local variables initialized at declaration
|
|
74
|
+
- [ ] No signed integer arithmetic that can overflow without a guard
|
|
75
|
+
- [ ] All functions declared before first use (via include or forward declaration)
|
|
76
|
+
- [ ] Tested with `-fsanitize=address,undefined` during development
|