strray-ai 1.15.30 → 1.15.32
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/dist/cli/index.js +0 -0
- package/dist/scripts/integration.js +0 -0
- package/package.json +1 -1
- package/scripts/node/universal-version-manager.js +2 -2
- package/dist/cli/commands/agent-skills.d.ts +0 -10
- package/dist/cli/commands/agent-skills.d.ts.map +0 -1
- package/dist/cli/commands/agent-skills.js +0 -55
- package/dist/cli/commands/agent-skills.js.map +0 -1
- package/dist/cli/commands/skill-list.d.ts +0 -11
- package/dist/cli/commands/skill-list.d.ts.map +0 -1
- package/dist/cli/commands/skill-list.js +0 -54
- package/dist/cli/commands/skill-list.js.map +0 -1
- package/dist/delegation/complexity-calibrator.d.ts +0 -80
- package/dist/delegation/complexity-calibrator.d.ts.map +0 -1
- package/dist/delegation/complexity-calibrator.js +0 -275
- package/dist/delegation/complexity-calibrator.js.map +0 -1
- package/dist/plugin/quality-gate.d.ts +0 -38
- package/dist/plugin/quality-gate.d.ts.map +0 -1
- package/dist/plugin/quality-gate.js +0 -142
- package/dist/plugin/quality-gate.js.map +0 -1
- package/dist/plugins/marketplace/marketplace-service.d.ts +0 -22
- package/dist/plugins/marketplace/marketplace-service.d.ts.map +0 -1
- package/dist/plugins/marketplace/marketplace-service.js +0 -7
- package/dist/plugins/marketplace/marketplace-service.js.map +0 -1
- package/dist/skills/systematic-debugging/condition-based-waiting-example.d.ts +0 -52
- package/dist/skills/systematic-debugging/condition-based-waiting-example.d.ts.map +0 -1
- package/dist/skills/systematic-debugging/condition-based-waiting-example.js +0 -128
- package/dist/skills/systematic-debugging/condition-based-waiting-example.js.map +0 -1
package/dist/cli/index.js
CHANGED
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strray-ai",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.32",
|
|
4
4
|
"description": "⚡ StringRay ⚡: Bulletproof AI orchestration with systematic error prevention. Zero dead ends. Ship clean, tested, optimized code — every time.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -78,8 +78,8 @@ const CALCULATED_COUNTS = calculateCounts();
|
|
|
78
78
|
const OFFICIAL_VERSIONS = {
|
|
79
79
|
// Framework version
|
|
80
80
|
framework: {
|
|
81
|
-
version: "1.15.
|
|
82
|
-
displayName: "StringRay AI v1.15.
|
|
81
|
+
version: "1.15.32",
|
|
82
|
+
displayName: "StringRay AI v1.15.32",
|
|
83
83
|
lastUpdated: "2026-03-30",
|
|
84
84
|
// Counts (auto-calculated, but can be overridden)
|
|
85
85
|
...CALCULATED_COUNTS,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Skills CLI Command
|
|
3
|
-
*
|
|
4
|
-
* Shows which skills are bound to which agents.
|
|
5
|
-
*
|
|
6
|
-
* Usage: npx strray-ai agent:skills
|
|
7
|
-
*/
|
|
8
|
-
export declare function agentSkillsCommand(): Promise<void>;
|
|
9
|
-
export default agentSkillsCommand;
|
|
10
|
-
//# sourceMappingURL=agent-skills.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-skills.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/agent-skills.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CA+CxD;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Skills CLI Command
|
|
3
|
-
*
|
|
4
|
-
* Shows which skills are bound to which agents.
|
|
5
|
-
*
|
|
6
|
-
* Usage: npx strray-ai agent:skills
|
|
7
|
-
*/
|
|
8
|
-
import { initializeSkillRegistry, skillResolver } from "../../skills/index.js";
|
|
9
|
-
export async function agentSkillsCommand() {
|
|
10
|
-
console.log("");
|
|
11
|
-
console.log("╔══════════════════════════════════════════════════╗");
|
|
12
|
-
console.log("║ Agent-Skill Bindings ║");
|
|
13
|
-
console.log("╚══════════════════════════════════════════════════╝");
|
|
14
|
-
console.log("");
|
|
15
|
-
try {
|
|
16
|
-
await initializeSkillRegistry();
|
|
17
|
-
const summary = skillResolver.getAgentSkillSummary();
|
|
18
|
-
const agents = Object.keys(summary).sort();
|
|
19
|
-
if (agents.length === 0) {
|
|
20
|
-
console.log("No agent-skill bindings configured.");
|
|
21
|
-
console.log("");
|
|
22
|
-
console.log("Add to SKILL.md frontmatter:");
|
|
23
|
-
console.log(" agent_binding:");
|
|
24
|
-
console.log(" primary: agent-name");
|
|
25
|
-
console.log(" auto_invoke: true");
|
|
26
|
-
console.log("");
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
for (const agent of agents) {
|
|
30
|
-
if (!agent)
|
|
31
|
-
continue;
|
|
32
|
-
const binding = summary[agent];
|
|
33
|
-
if (!binding)
|
|
34
|
-
continue;
|
|
35
|
-
console.log(`🤖 @${agent}`);
|
|
36
|
-
if (binding.primary) {
|
|
37
|
-
console.log(` Primary: ${binding.primary}`);
|
|
38
|
-
}
|
|
39
|
-
if (binding.secondary.length > 1) {
|
|
40
|
-
console.log(` Skills: ${binding.secondary.join(", ")}`);
|
|
41
|
-
}
|
|
42
|
-
console.log("");
|
|
43
|
-
}
|
|
44
|
-
console.log("Legend:");
|
|
45
|
-
console.log(" Primary - Main skill for this agent");
|
|
46
|
-
console.log(" Skills - All skills bound to this agent");
|
|
47
|
-
console.log("");
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
console.error("Failed to get agent-skill bindings:", error);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
export default agentSkillsCommand;
|
|
55
|
-
//# sourceMappingURL=agent-skills.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-skills.js","source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,CAAC,GAAG,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;YAC5B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,GAAG,CAAC,eAAe,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;YAChD,CAAC;YACD,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACjC,OAAO,CAAC,GAAG,CAAC,cAAc,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC5D,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill List CLI Command
|
|
3
|
-
*
|
|
4
|
-
* Lists all discovered skills with detailed information.
|
|
5
|
-
* Uses the SkillRegistry for comprehensive skill information.
|
|
6
|
-
*
|
|
7
|
-
* Usage: npx strray-ai skill:list
|
|
8
|
-
*/
|
|
9
|
-
export declare function skillListCommand(): Promise<void>;
|
|
10
|
-
export default skillListCommand;
|
|
11
|
-
//# sourceMappingURL=skill-list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skill-list.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/skill-list.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiDtD;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill List CLI Command
|
|
3
|
-
*
|
|
4
|
-
* Lists all discovered skills with detailed information.
|
|
5
|
-
* Uses the SkillRegistry for comprehensive skill information.
|
|
6
|
-
*
|
|
7
|
-
* Usage: npx strray-ai skill:list
|
|
8
|
-
*/
|
|
9
|
-
import { initializeSkillRegistry } from "../../skills/index.js";
|
|
10
|
-
export async function skillListCommand() {
|
|
11
|
-
console.log("");
|
|
12
|
-
console.log("╔══════════════════════════════════════════════════╗");
|
|
13
|
-
console.log("║ StringRay Skills ║");
|
|
14
|
-
console.log("╚══════════════════════════════════════════════════╝");
|
|
15
|
-
console.log("");
|
|
16
|
-
try {
|
|
17
|
-
const registry = await initializeSkillRegistry(process.cwd());
|
|
18
|
-
const skills = registry.list();
|
|
19
|
-
const stats = registry.getStats();
|
|
20
|
-
console.log(`Total Skills: ${stats.total}`);
|
|
21
|
-
console.log(`With MCP: ${stats.with_mcp}`);
|
|
22
|
-
console.log("");
|
|
23
|
-
if (stats.by_source && Object.keys(stats.by_source).length > 0) {
|
|
24
|
-
console.log("By Source:");
|
|
25
|
-
for (const [source, count] of Object.entries(stats.by_source)) {
|
|
26
|
-
console.log(` • ${source}: ${count}`);
|
|
27
|
-
}
|
|
28
|
-
console.log("");
|
|
29
|
-
}
|
|
30
|
-
console.log("Skills:");
|
|
31
|
-
console.log("─".repeat(70));
|
|
32
|
-
for (const skill of skills) {
|
|
33
|
-
const hasMcp = skill.mcp ? ` [MCP: ${skill.mcp.tools.length} tools]` : "";
|
|
34
|
-
const autoInvoke = skill.agent_binding?.auto_invoke ? " ⚡" : "";
|
|
35
|
-
console.log(`📚 ${skill.name}${hasMcp}${autoInvoke}`);
|
|
36
|
-
console.log(` ${skill.description.slice(0, 60)}${skill.description.length > 60 ? "..." : ""}`);
|
|
37
|
-
if (skill.capabilities.length > 0) {
|
|
38
|
-
console.log(` Capabilities: ${skill.capabilities.slice(0, 3).join(", ")}${skill.capabilities.length > 3 ? "..." : ""}`);
|
|
39
|
-
}
|
|
40
|
-
console.log("");
|
|
41
|
-
}
|
|
42
|
-
console.log("Legend:");
|
|
43
|
-
console.log(" 📚 - Skill name");
|
|
44
|
-
console.log(" [MCP] - Has MCP server with tool count");
|
|
45
|
-
console.log(" ⚡ - Auto-invoke enabled");
|
|
46
|
-
console.log("");
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
console.error("Failed to list skills:", error);
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export default skillListCommand;
|
|
54
|
-
//# sourceMappingURL=skill-list.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skill-list.js","sourceRoot":"","sources":["../../../src/cli/commands/skill-list.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,uBAAuB,EAAoB,MAAM,uBAAuB,CAAC;AAElF,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;IACpE,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;IACpE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEhB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAElC,OAAO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AE,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAEjG,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClC,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC5H,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;QACxD,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Complexity Calibrator for StringRay
|
|
3
|
-
*
|
|
4
|
-
* Reads historical accuracy data → Adjusts complexity weights → Updates analyzer
|
|
5
|
-
*
|
|
6
|
-
* This is the "learning" system - calibrates complexity predictions based on
|
|
7
|
-
* actual vs predicted task duration and success rates.
|
|
8
|
-
*
|
|
9
|
-
* @version 1.0.0
|
|
10
|
-
*/
|
|
11
|
-
import type { ComplexityThresholds } from "./complexity-analyzer.js";
|
|
12
|
-
import type { ComplexityAccuracy } from "../core/framework-logger.js";
|
|
13
|
-
export interface CalibrationData {
|
|
14
|
-
timestamp: string;
|
|
15
|
-
complexityScore: number;
|
|
16
|
-
predictedDuration: number;
|
|
17
|
-
actualDuration: number;
|
|
18
|
-
accuracy: ComplexityAccuracy;
|
|
19
|
-
success: boolean;
|
|
20
|
-
}
|
|
21
|
-
export interface CalibrationResult {
|
|
22
|
-
adjustedWeights: {
|
|
23
|
-
operationType: Record<string, number>;
|
|
24
|
-
riskLevel: Record<string, number>;
|
|
25
|
-
};
|
|
26
|
-
adjustedThresholds: ComplexityThresholds;
|
|
27
|
-
accuracyHistory: {
|
|
28
|
-
underestimated: number;
|
|
29
|
-
accurate: number;
|
|
30
|
-
overestimated: number;
|
|
31
|
-
total: number;
|
|
32
|
-
};
|
|
33
|
-
sampleSize: number;
|
|
34
|
-
}
|
|
35
|
-
export declare class ComplexityCalibrator {
|
|
36
|
-
private logPath;
|
|
37
|
-
private outcomesPath;
|
|
38
|
-
private calibrationDataPath;
|
|
39
|
-
private defaultOperationWeights;
|
|
40
|
-
private defaultRiskMultipliers;
|
|
41
|
-
private defaultThresholds;
|
|
42
|
-
constructor(logPath?: string);
|
|
43
|
-
/**
|
|
44
|
-
* Main calibration method - reads logs, calculates adjustments, returns result
|
|
45
|
-
*/
|
|
46
|
-
calibrate(minSamples?: number): Promise<CalibrationResult | null>;
|
|
47
|
-
/**
|
|
48
|
-
* Read calibration data from routing outcomes
|
|
49
|
-
*/
|
|
50
|
-
private readCalibrationData;
|
|
51
|
-
/**
|
|
52
|
-
* Parse a log entry for calibration data
|
|
53
|
-
*/
|
|
54
|
-
private parseLogEntry;
|
|
55
|
-
/**
|
|
56
|
-
* Calculate weight adjustments based on historical accuracy
|
|
57
|
-
*/
|
|
58
|
-
private calculateWeightAdjustments;
|
|
59
|
-
/**
|
|
60
|
-
* Calculate threshold adjustments based on accuracy
|
|
61
|
-
*/
|
|
62
|
-
private calculateThresholdAdjustments;
|
|
63
|
-
/**
|
|
64
|
-
* Apply calibration results to complexity analyzer
|
|
65
|
-
*/
|
|
66
|
-
applyCalibration(analyzer: any): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Get default weights (for reset)
|
|
69
|
-
*/
|
|
70
|
-
getDefaultWeights(): {
|
|
71
|
-
operationType: Record<string, number>;
|
|
72
|
-
riskLevel: Record<string, number>;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Get default thresholds
|
|
76
|
-
*/
|
|
77
|
-
getDefaultThresholds(): ComplexityThresholds;
|
|
78
|
-
}
|
|
79
|
-
export declare const complexityCalibrator: ComplexityCalibrator;
|
|
80
|
-
//# sourceMappingURL=complexity-calibrator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"complexity-calibrator.d.ts","sourceRoot":"","sources":["../../src/delegation/complexity-calibrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAEV,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE;QACf,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACnC,CAAC;IACF,kBAAkB,EAAE,oBAAoB,CAAC;IACzC,eAAe,EAAE;QACf,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,mBAAmB,CAAS;IAGpC,OAAO,CAAC,uBAAuB,CAO7B;IAEF,OAAO,CAAC,sBAAsB,CAK5B;IAEF,OAAO,CAAC,iBAAiB,CAKvB;gBAEU,OAAO,CAAC,EAAE,MAAM;IAc5B;;OAEG;IACG,SAAS,CAAC,UAAU,GAAE,MAAU,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAkC1E;;OAEG;YACW,mBAAmB;IAwDjC;;OAEG;IACH,OAAO,CAAC,aAAa;IA4DrB;;OAEG;IACH,OAAO,CAAC,0BAA0B;IA0ClC;;OAEG;IACH,OAAO,CAAC,6BAA6B;IAoCrC;;OAEG;IACG,gBAAgB,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BpD;;OAEG;IACH,iBAAiB,IAAI;QACnB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACnC;IAOD;;OAEG;IACH,oBAAoB,IAAI,oBAAoB;CAG7C;AAGD,eAAO,MAAM,oBAAoB,sBAA6B,CAAC"}
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Complexity Calibrator for StringRay
|
|
3
|
-
*
|
|
4
|
-
* Reads historical accuracy data → Adjusts complexity weights → Updates analyzer
|
|
5
|
-
*
|
|
6
|
-
* This is the "learning" system - calibrates complexity predictions based on
|
|
7
|
-
* actual vs predicted task duration and success rates.
|
|
8
|
-
*
|
|
9
|
-
* @version 1.0.0
|
|
10
|
-
*/
|
|
11
|
-
import * as fs from "fs";
|
|
12
|
-
import * as path from "path";
|
|
13
|
-
export class ComplexityCalibrator {
|
|
14
|
-
logPath;
|
|
15
|
-
outcomesPath;
|
|
16
|
-
calibrationDataPath;
|
|
17
|
-
// Default weights (from complexity-analyzer.ts)
|
|
18
|
-
defaultOperationWeights = {
|
|
19
|
-
create: 1.0,
|
|
20
|
-
modify: 1.2,
|
|
21
|
-
refactor: 1.8,
|
|
22
|
-
analyze: 1.5,
|
|
23
|
-
debug: 2.0,
|
|
24
|
-
test: 1.3,
|
|
25
|
-
};
|
|
26
|
-
defaultRiskMultipliers = {
|
|
27
|
-
low: 0.8,
|
|
28
|
-
medium: 1.0,
|
|
29
|
-
high: 1.3,
|
|
30
|
-
critical: 1.6,
|
|
31
|
-
};
|
|
32
|
-
defaultThresholds = {
|
|
33
|
-
simple: 20,
|
|
34
|
-
moderate: 35,
|
|
35
|
-
complex: 75,
|
|
36
|
-
enterprise: 100,
|
|
37
|
-
};
|
|
38
|
-
constructor(logPath) {
|
|
39
|
-
const cwd = process.cwd();
|
|
40
|
-
this.logPath =
|
|
41
|
-
logPath || path.join(cwd, "logs", "framework", "activity.log");
|
|
42
|
-
// Only use outcomes path when using default log path
|
|
43
|
-
this.outcomesPath = logPath ? "" : path.join(cwd, "logs", "framework", "routing-outcomes.json");
|
|
44
|
-
this.calibrationDataPath = path.join(cwd, "logs", "framework", "calibration-data.json");
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Main calibration method - reads logs, calculates adjustments, returns result
|
|
48
|
-
*/
|
|
49
|
-
async calibrate(minSamples = 3) {
|
|
50
|
-
const data = await this.readCalibrationData();
|
|
51
|
-
if (data.length < minSamples) {
|
|
52
|
-
console.log(`📊 Not enough data for calibration: ${data.length}/${minSamples} samples`);
|
|
53
|
-
console.log(` (Found ${data.length} task completion entries)`);
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
// Calculate accuracy breakdown
|
|
57
|
-
const accuracyHistory = {
|
|
58
|
-
underestimated: data.filter((d) => d.accuracy === "underestimated")
|
|
59
|
-
.length,
|
|
60
|
-
accurate: data.filter((d) => d.accuracy === "accurate").length,
|
|
61
|
-
overestimated: data.filter((d) => d.accuracy === "overestimated").length,
|
|
62
|
-
total: data.length,
|
|
63
|
-
};
|
|
64
|
-
// Calculate weight adjustments based on accuracy patterns
|
|
65
|
-
const adjustedWeights = this.calculateWeightAdjustments(data);
|
|
66
|
-
// Calculate threshold adjustments
|
|
67
|
-
const adjustedThresholds = this.calculateThresholdAdjustments(data);
|
|
68
|
-
return {
|
|
69
|
-
adjustedWeights,
|
|
70
|
-
adjustedThresholds,
|
|
71
|
-
accuracyHistory,
|
|
72
|
-
sampleSize: data.length,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Read calibration data from routing outcomes
|
|
77
|
-
*/
|
|
78
|
-
async readCalibrationData() {
|
|
79
|
-
const data = [];
|
|
80
|
-
// First try routing-outcomes.json (has structured data)
|
|
81
|
-
// Only when using default paths (not custom test paths)
|
|
82
|
-
if (this.outcomesPath && fs.existsSync(this.outcomesPath)) {
|
|
83
|
-
try {
|
|
84
|
-
const outcomes = JSON.parse(fs.readFileSync(this.outcomesPath, "utf-8"));
|
|
85
|
-
for (const outcome of outcomes) {
|
|
86
|
-
if (outcome.success !== undefined && outcome.complexity !== undefined) {
|
|
87
|
-
// Use actual complexity from outcome
|
|
88
|
-
const complexityScore = outcome.complexity;
|
|
89
|
-
// Estimate accuracy based on success (simplified)
|
|
90
|
-
const accuracy = outcome.success ? "accurate" : "underestimated";
|
|
91
|
-
data.push({
|
|
92
|
-
timestamp: outcome.timestamp || new Date().toISOString(),
|
|
93
|
-
complexityScore,
|
|
94
|
-
predictedDuration: complexityScore * 1000,
|
|
95
|
-
actualDuration: complexityScore * 1000, // Placeholder
|
|
96
|
-
accuracy,
|
|
97
|
-
success: outcome.success,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (data.length > 0) {
|
|
102
|
-
return data;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
// Fall through to activity log parsing
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
// Fall back to activity log parsing
|
|
110
|
-
if (fs.existsSync(this.logPath)) {
|
|
111
|
-
const content = fs.readFileSync(this.logPath, "utf-8");
|
|
112
|
-
const lines = content.split("\n").filter((l) => l.trim());
|
|
113
|
-
for (const line of lines) {
|
|
114
|
-
// Accept both "job-completed" and "complex-task-completed"
|
|
115
|
-
const isCompleted = line.includes("job-completed") || line.includes("complex-task-completed");
|
|
116
|
-
if (!isCompleted)
|
|
117
|
-
continue;
|
|
118
|
-
// Parse the entry
|
|
119
|
-
const entry = this.parseLogEntry(line);
|
|
120
|
-
if (entry) {
|
|
121
|
-
data.push(entry);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return data;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Parse a log entry for calibration data
|
|
129
|
-
*/
|
|
130
|
-
parseLogEntry(line) {
|
|
131
|
-
// Try to extract complexity and accuracy from log line
|
|
132
|
-
// Format: timestamp [job-id] [component] action - STATUS
|
|
133
|
-
// Look for embedded details in the log (if logged with details)
|
|
134
|
-
const hasAccuracy = line.includes("underestimated") ||
|
|
135
|
-
line.includes("accurate") ||
|
|
136
|
-
line.includes("overestimated");
|
|
137
|
-
// If no explicit accuracy, estimate from duration vs baseline
|
|
138
|
-
let accuracy;
|
|
139
|
-
if (hasAccuracy) {
|
|
140
|
-
if (line.includes("underestimated"))
|
|
141
|
-
accuracy = "underestimated";
|
|
142
|
-
else if (line.includes("overestimated"))
|
|
143
|
-
accuracy = "overestimated";
|
|
144
|
-
else
|
|
145
|
-
accuracy = "accurate";
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
// Estimate accuracy based on duration patterns
|
|
149
|
-
// Fast tasks (<2s) are likely underestimated
|
|
150
|
-
// Slow tasks (>10s) are likely overestimated
|
|
151
|
-
const durationMatch = line.match(/duration[":\s]+(\d+)/i);
|
|
152
|
-
const duration = durationMatch ? parseInt(durationMatch[1] || "0") : 0;
|
|
153
|
-
if (duration > 10000) {
|
|
154
|
-
accuracy = "overestimated"; // Task took longer than expected
|
|
155
|
-
}
|
|
156
|
-
else if (duration > 0 && duration < 2000) {
|
|
157
|
-
accuracy = "underestimated"; // Task was quick, could have been simpler
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
accuracy = "accurate";
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
// Extract complexity score if available
|
|
164
|
-
const complexityMatch = line.match(/complexity[":\s]+(\d+)/i);
|
|
165
|
-
const complexityScore = complexityMatch
|
|
166
|
-
? parseInt(complexityMatch[1] || "50")
|
|
167
|
-
: 50;
|
|
168
|
-
// Extract duration if available
|
|
169
|
-
const durationMatch = line.match(/duration[":\s]+(\d+)/i);
|
|
170
|
-
const actualDuration = durationMatch
|
|
171
|
-
? parseInt(durationMatch[1] || "0")
|
|
172
|
-
: 0;
|
|
173
|
-
// Extract timestamp
|
|
174
|
-
const timestampMatch = line.match(/^(\d{4}-\d{2}-\d{2}T[\d:.]+Z)/);
|
|
175
|
-
const timestamp = timestampMatch
|
|
176
|
-
? timestampMatch[1] || new Date().toISOString()
|
|
177
|
-
: new Date().toISOString();
|
|
178
|
-
return {
|
|
179
|
-
timestamp,
|
|
180
|
-
complexityScore,
|
|
181
|
-
predictedDuration: complexityScore * 1000, // Estimate: 1 sec per point
|
|
182
|
-
actualDuration,
|
|
183
|
-
accuracy,
|
|
184
|
-
success: !line.includes("error") && !line.includes("ERROR"),
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Calculate weight adjustments based on historical accuracy
|
|
189
|
-
*/
|
|
190
|
-
calculateWeightAdjustments(data) {
|
|
191
|
-
// If we underestimated (tasks took longer), increase weights
|
|
192
|
-
// If we overestimated (tasks were faster), decrease weights
|
|
193
|
-
const underestimated = data.filter((d) => d.accuracy === "underestimated").length;
|
|
194
|
-
const overestimated = data.filter((d) => d.accuracy === "overestimated").length;
|
|
195
|
-
const total = data.length;
|
|
196
|
-
const adjustmentFactor = total > 0 ? (underestimated - overestimated) / total : 0;
|
|
197
|
-
// Apply adjustment (max +/- 20%)
|
|
198
|
-
const boundedAdjustment = Math.max(-0.2, Math.min(0.2, adjustmentFactor * 0.5));
|
|
199
|
-
// Adjust operation weights
|
|
200
|
-
const operationType = {};
|
|
201
|
-
for (const [op, weight] of Object.entries(this.defaultOperationWeights)) {
|
|
202
|
-
operationType[op] = Number((weight * (1 + boundedAdjustment)).toFixed(2));
|
|
203
|
-
}
|
|
204
|
-
// Risk multipliers tend to be underestimated more
|
|
205
|
-
const riskAdjustment = adjustmentFactor * 0.3; // Smaller adjustment for risk
|
|
206
|
-
const riskLevel = {};
|
|
207
|
-
for (const [risk, multiplier] of Object.entries(this.defaultRiskMultipliers)) {
|
|
208
|
-
riskLevel[risk] = Number((multiplier * (1 + riskAdjustment)).toFixed(2));
|
|
209
|
-
}
|
|
210
|
-
return { operationType, riskLevel };
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Calculate threshold adjustments based on accuracy
|
|
214
|
-
*/
|
|
215
|
-
calculateThresholdAdjustments(data) {
|
|
216
|
-
// If we're consistently underestimating, raise thresholds
|
|
217
|
-
// If we're consistently overestimating, lower thresholds
|
|
218
|
-
const underestimated = data.filter((d) => d.accuracy === "underestimated").length;
|
|
219
|
-
const overestimated = data.filter((d) => d.accuracy === "overestimated").length;
|
|
220
|
-
const total = data.length;
|
|
221
|
-
if (total === 0)
|
|
222
|
-
return { ...this.defaultThresholds };
|
|
223
|
-
const imbalance = (underestimated - overestimated) / total;
|
|
224
|
-
// Adjust thresholds by up to 10 points based on accuracy
|
|
225
|
-
const thresholdShift = Math.round(imbalance * 10);
|
|
226
|
-
// Apply to moderate and complex thresholds (not simple/enterprise extremes)
|
|
227
|
-
return {
|
|
228
|
-
simple: Math.max(5, this.defaultThresholds.simple),
|
|
229
|
-
moderate: Math.max(15, Math.min(50, this.defaultThresholds.moderate + thresholdShift)),
|
|
230
|
-
complex: Math.max(50, Math.min(90, this.defaultThresholds.complex + thresholdShift)),
|
|
231
|
-
enterprise: 100,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Apply calibration results to complexity analyzer
|
|
236
|
-
*/
|
|
237
|
-
async applyCalibration(analyzer) {
|
|
238
|
-
const result = await this.calibrate();
|
|
239
|
-
if (!result) {
|
|
240
|
-
console.log("⚠️ No calibration data available");
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
console.log(`📊 Applying calibration (${result.sampleSize} samples):`);
|
|
244
|
-
console.log(` - Underestimated: ${result.accuracyHistory.underestimated}`);
|
|
245
|
-
console.log(` - Accurate: ${result.accuracyHistory.accurate}`);
|
|
246
|
-
console.log(` - Overestimated: ${result.accuracyHistory.overestimated}`);
|
|
247
|
-
// Apply weights if analyzer has setter methods
|
|
248
|
-
if (analyzer.setOperationWeights && result.adjustedWeights.operationType) {
|
|
249
|
-
// Would need to add this method to ComplexityAnalyzer
|
|
250
|
-
console.log(" - Operation weights adjusted");
|
|
251
|
-
}
|
|
252
|
-
if (analyzer.setThresholds) {
|
|
253
|
-
analyzer.setThresholds(result.adjustedThresholds);
|
|
254
|
-
console.log(" - Thresholds calibrated");
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Get default weights (for reset)
|
|
259
|
-
*/
|
|
260
|
-
getDefaultWeights() {
|
|
261
|
-
return {
|
|
262
|
-
operationType: { ...this.defaultOperationWeights },
|
|
263
|
-
riskLevel: { ...this.defaultRiskMultipliers },
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Get default thresholds
|
|
268
|
-
*/
|
|
269
|
-
getDefaultThresholds() {
|
|
270
|
-
return { ...this.defaultThresholds };
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
// Export singleton for easy use
|
|
274
|
-
export const complexityCalibrator = new ComplexityCalibrator();
|
|
275
|
-
//# sourceMappingURL=complexity-calibrator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"complexity-calibrator.js","sourceRoot":"","sources":["../../src/delegation/complexity-calibrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AA+B7B,MAAM,OAAO,oBAAoB;IACvB,OAAO,CAAS;IAChB,YAAY,CAAS;IACrB,mBAAmB,CAAS;IAEpC,gDAAgD;IACxC,uBAAuB,GAAG;QAChC,MAAM,EAAE,GAAG;QACX,MAAM,EAAE,GAAG;QACX,QAAQ,EAAE,GAAG;QACb,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,GAAG;KACV,CAAC;IAEM,sBAAsB,GAAG;QAC/B,GAAG,EAAE,GAAG;QACR,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,GAAG;KACd,CAAC;IAEM,iBAAiB,GAAyB;QAChD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,GAAG;KAChB,CAAC;IAEF,YAAY,OAAgB;QAC1B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO;YACV,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QACjE,qDAAqD;QACrD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,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D,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED;;OAEG;IACH,iBAAiB;QAIf,OAAO;YACL,aAAa,EAAE,EAAE,GAAG,IAAI,CAAC,uBAAuB,EAAE;YAClD,SAAS,EAAE,EAAE,GAAG,IAAI,CAAC,sBAAsB,EAAE;SAC9C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,OAAO,EAAE,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACvC,CAAC;CACF;AAED,gCAAgC;AAChC,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight Quality Gate System
|
|
3
|
-
*
|
|
4
|
-
* Bridges plugin-level quality gates with enforcement validators.
|
|
5
|
-
* Does NOT require framework boot - uses validators directly.
|
|
6
|
-
*
|
|
7
|
-
* @version 1.0.0
|
|
8
|
-
*/
|
|
9
|
-
export interface QualityGateContext {
|
|
10
|
-
tool: string;
|
|
11
|
-
args?: {
|
|
12
|
-
content?: string;
|
|
13
|
-
filePath?: string;
|
|
14
|
-
command?: string;
|
|
15
|
-
} | undefined;
|
|
16
|
-
}
|
|
17
|
-
export interface QualityGateResult {
|
|
18
|
-
passed: boolean;
|
|
19
|
-
violations: string[];
|
|
20
|
-
checks: Array<{
|
|
21
|
-
id: string;
|
|
22
|
-
passed: boolean;
|
|
23
|
-
message?: string;
|
|
24
|
-
}>;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Lightweight quality gate runner
|
|
28
|
-
* Uses simple file checks without requiring framework boot
|
|
29
|
-
*/
|
|
30
|
-
export declare function runQualityGate(context: QualityGateContext): Promise<QualityGateResult>;
|
|
31
|
-
/**
|
|
32
|
-
* Run quality gate with detailed logging
|
|
33
|
-
*/
|
|
34
|
-
export declare function runQualityGateWithLogging(context: QualityGateContext, logger: {
|
|
35
|
-
log: (msg: string) => void;
|
|
36
|
-
error: (msg: string) => void;
|
|
37
|
-
}): Promise<QualityGateResult>;
|
|
38
|
-
//# sourceMappingURL=quality-gate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quality-gate.d.ts","sourceRoot":"","sources":["../../src/plugin/quality-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,SAAS,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,KAAK,CAAC;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;CACJ;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAgC5B;AA2GD;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE;IAAE,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GACnE,OAAO,CAAC,iBAAiB,CAAC,CAuB5B"}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight Quality Gate System
|
|
3
|
-
*
|
|
4
|
-
* Bridges plugin-level quality gates with enforcement validators.
|
|
5
|
-
* Does NOT require framework boot - uses validators directly.
|
|
6
|
-
*
|
|
7
|
-
* @version 1.0.0
|
|
8
|
-
*/
|
|
9
|
-
import * as fs from "fs";
|
|
10
|
-
import * as path from "path";
|
|
11
|
-
/**
|
|
12
|
-
* Lightweight quality gate runner
|
|
13
|
-
* Uses simple file checks without requiring framework boot
|
|
14
|
-
*/
|
|
15
|
-
export async function runQualityGate(context) {
|
|
16
|
-
const result = {
|
|
17
|
-
passed: true,
|
|
18
|
-
violations: [],
|
|
19
|
-
checks: [],
|
|
20
|
-
};
|
|
21
|
-
const { tool, args } = context;
|
|
22
|
-
// Check 1: Tests Required
|
|
23
|
-
const testsCheck = await checkTestsRequired(tool, args?.filePath);
|
|
24
|
-
result.checks.push(testsCheck);
|
|
25
|
-
if (!testsCheck.passed) {
|
|
26
|
-
result.violations.push(testsCheck.message);
|
|
27
|
-
}
|
|
28
|
-
// Check 2: Documentation Required
|
|
29
|
-
const docsCheck = checkDocumentationRequired(tool, args?.filePath);
|
|
30
|
-
result.checks.push(docsCheck);
|
|
31
|
-
if (!docsCheck.passed) {
|
|
32
|
-
result.violations.push(docsCheck.message);
|
|
33
|
-
}
|
|
34
|
-
// Check 3: Debug Patterns
|
|
35
|
-
const debugCheck = checkDebugPatterns(args?.content);
|
|
36
|
-
result.checks.push(debugCheck);
|
|
37
|
-
if (!debugCheck.passed) {
|
|
38
|
-
result.violations.push(debugCheck.message);
|
|
39
|
-
}
|
|
40
|
-
result.passed = result.violations.length === 0;
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Check if tests are required for the file
|
|
45
|
-
*/
|
|
46
|
-
async function checkTestsRequired(tool, filePath) {
|
|
47
|
-
const check = { id: "tests-required", passed: true };
|
|
48
|
-
if (tool !== "write" || !filePath) {
|
|
49
|
-
return check;
|
|
50
|
-
}
|
|
51
|
-
// Only check TypeScript source files
|
|
52
|
-
if (!filePath.endsWith(".ts") ||
|
|
53
|
-
filePath.includes(".test.") ||
|
|
54
|
-
filePath.includes(".spec.") ||
|
|
55
|
-
filePath.includes("__tests__")) {
|
|
56
|
-
return check;
|
|
57
|
-
}
|
|
58
|
-
const testPath = filePath.replace(".ts", ".test.ts");
|
|
59
|
-
const specPath = filePath.replace(".ts", ".spec.ts");
|
|
60
|
-
// Check if either test file exists
|
|
61
|
-
const testExists = fs.existsSync(testPath);
|
|
62
|
-
const specExists = fs.existsSync(specPath);
|
|
63
|
-
if (!testExists && !specExists) {
|
|
64
|
-
return {
|
|
65
|
-
...check,
|
|
66
|
-
passed: false,
|
|
67
|
-
message: `tests-required: No test file found for ${filePath} (expected ${testPath} or ${specPath})`,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
return check;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Check if documentation exists for new features
|
|
74
|
-
*/
|
|
75
|
-
function checkDocumentationRequired(tool, filePath) {
|
|
76
|
-
const check = { id: "documentation-required", passed: true };
|
|
77
|
-
if (tool !== "write" || !filePath?.includes("src/")) {
|
|
78
|
-
return check;
|
|
79
|
-
}
|
|
80
|
-
const cwd = process.cwd();
|
|
81
|
-
const docsDir = path.join(cwd, "docs");
|
|
82
|
-
const readmePath = path.join(cwd, "README.md");
|
|
83
|
-
// Allow if either docs dir or README exists
|
|
84
|
-
if (fs.existsSync(docsDir) || fs.existsSync(readmePath)) {
|
|
85
|
-
return check;
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
...check,
|
|
89
|
-
passed: false,
|
|
90
|
-
message: "documentation-required: No documentation found (docs/ directory or README.md)",
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Check for debug/error patterns in code
|
|
95
|
-
*/
|
|
96
|
-
function checkDebugPatterns(content) {
|
|
97
|
-
const check = { id: "resolve-all-errors", passed: true };
|
|
98
|
-
if (!content) {
|
|
99
|
-
return check;
|
|
100
|
-
}
|
|
101
|
-
// Patterns to check (same as original)
|
|
102
|
-
const patterns = [
|
|
103
|
-
{ regex: /console\.log\s*\(/g, name: "console.log" },
|
|
104
|
-
{ regex: /TODO\s*:/gi, name: "TODO" },
|
|
105
|
-
{ regex: /FIXME\s*:/gi, name: "FIXME" },
|
|
106
|
-
{ regex: /throw\s+new\s+Error\s*\(\s*['"]test['"]\s*\)/gi, name: "test error" },
|
|
107
|
-
];
|
|
108
|
-
for (const { regex, name } of patterns) {
|
|
109
|
-
if (regex.test(content)) {
|
|
110
|
-
return {
|
|
111
|
-
...check,
|
|
112
|
-
passed: false,
|
|
113
|
-
message: `resolve-all-errors: Found ${name} pattern in code`,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return check;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Run quality gate with detailed logging
|
|
121
|
-
*/
|
|
122
|
-
export async function runQualityGateWithLogging(context, logger) {
|
|
123
|
-
logger.log("🔍 Running quality gate checks...");
|
|
124
|
-
const result = await runQualityGate(context);
|
|
125
|
-
// Log individual checks
|
|
126
|
-
for (const check of result.checks) {
|
|
127
|
-
if (check.passed) {
|
|
128
|
-
logger.log(` ✅ ${check.id}`);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
logger.error(` ❌ ${check.id}: ${check.message}`);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (result.passed) {
|
|
135
|
-
logger.log("✅ Quality Gate PASSED");
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
logger.error(`🚫 Quality Gate FAILED with ${result.violations.length} violation(s)`);
|
|
139
|
-
}
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=quality-gate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quality-gate.js","sourceRoot":"","sources":["../../src/plugin/quality-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,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,OAAO,EAAE,6BAA6B,IAAI,kBAAkB;aAC7D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,OAA2B,EAC3B,MAAoE;IAEpE,MAAM,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IAEhD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;IAE7C,wBAAwB;IACxB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,KAAK,CACV,+BAA+B,MAAM,CAAC,UAAU,CAAC,MAAM,eAAe,CACvE,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface PluginInfo {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
tags: string[];
|
|
5
|
-
score: number;
|
|
6
|
-
}
|
|
7
|
-
export interface SearchResult {
|
|
8
|
-
plugins: PluginInfo[];
|
|
9
|
-
}
|
|
10
|
-
export interface SearchQuery {
|
|
11
|
-
query: string;
|
|
12
|
-
limit: number;
|
|
13
|
-
sortBy?: string;
|
|
14
|
-
minRating?: number;
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}
|
|
17
|
-
export declare const marketplaceService: {
|
|
18
|
-
search(query: SearchQuery): Promise<SearchResult>;
|
|
19
|
-
registerPlugin?(plugin: any): Promise<any>;
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=marketplace-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"marketplace-service.d.ts","sourceRoot":"","sources":["../../../src/plugins/marketplace/marketplace-service.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,eAAO,MAAM,kBAAkB,EAAE;IAC/B,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAClD,cAAc,CAAC,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CAKpB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"marketplace-service.js","sourceRoot":"","sources":["../../../src/plugins/marketplace/marketplace-service.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAqB5D,MAAM,CAAC,MAAM,kBAAkB,GAI3B;IACF,KAAK,CAAC,MAAM,CAAC,MAAmB;QAC9B,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;CACF,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { ThreadManager } from '~/threads/thread-manager';
|
|
2
|
-
import type { LaceEvent, LaceEventType } from '~/threads/types';
|
|
3
|
-
/**
|
|
4
|
-
* Wait for a specific event type to appear in thread
|
|
5
|
-
*
|
|
6
|
-
* @param threadManager - The thread manager to query
|
|
7
|
-
* @param threadId - Thread to check for events
|
|
8
|
-
* @param eventType - Type of event to wait for
|
|
9
|
-
* @param timeoutMs - Maximum time to wait (default 5000ms)
|
|
10
|
-
* @returns Promise resolving to the first matching event
|
|
11
|
-
*
|
|
12
|
-
* Example:
|
|
13
|
-
* await waitForEvent(threadManager, agentThreadId, 'TOOL_RESULT');
|
|
14
|
-
*/
|
|
15
|
-
export declare function waitForEvent(threadManager: ThreadManager, threadId: string, eventType: LaceEventType, timeoutMs?: number): Promise<LaceEvent>;
|
|
16
|
-
/**
|
|
17
|
-
* Wait for a specific number of events of a given type
|
|
18
|
-
*
|
|
19
|
-
* @param threadManager - The thread manager to query
|
|
20
|
-
* @param threadId - Thread to check for events
|
|
21
|
-
* @param eventType - Type of event to wait for
|
|
22
|
-
* @param count - Number of events to wait for
|
|
23
|
-
* @param timeoutMs - Maximum time to wait (default 5000ms)
|
|
24
|
-
* @returns Promise resolving to all matching events once count is reached
|
|
25
|
-
*
|
|
26
|
-
* Example:
|
|
27
|
-
* // Wait for 2 AGENT_MESSAGE events (initial response + continuation)
|
|
28
|
-
* await waitForEventCount(threadManager, agentThreadId, 'AGENT_MESSAGE', 2);
|
|
29
|
-
*/
|
|
30
|
-
export declare function waitForEventCount(threadManager: ThreadManager, threadId: string, eventType: LaceEventType, count: number, timeoutMs?: number): Promise<LaceEvent[]>;
|
|
31
|
-
/**
|
|
32
|
-
* Wait for an event matching a custom predicate
|
|
33
|
-
* Useful when you need to check event data, not just type
|
|
34
|
-
*
|
|
35
|
-
* @param threadManager - The thread manager to query
|
|
36
|
-
* @param threadId - Thread to check for events
|
|
37
|
-
* @param predicate - Function that returns true when event matches
|
|
38
|
-
* @param description - Human-readable description for error messages
|
|
39
|
-
* @param timeoutMs - Maximum time to wait (default 5000ms)
|
|
40
|
-
* @returns Promise resolving to the first matching event
|
|
41
|
-
*
|
|
42
|
-
* Example:
|
|
43
|
-
* // Wait for TOOL_RESULT with specific ID
|
|
44
|
-
* await waitForEventMatch(
|
|
45
|
-
* threadManager,
|
|
46
|
-
* agentThreadId,
|
|
47
|
-
* (e) => e.type === 'TOOL_RESULT' && e.data.id === 'call_123',
|
|
48
|
-
* 'TOOL_RESULT with id=call_123'
|
|
49
|
-
* );
|
|
50
|
-
*/
|
|
51
|
-
export declare function waitForEventMatch(threadManager: ThreadManager, threadId: string, predicate: (event: LaceEvent) => boolean, description: string, timeoutMs?: number): Promise<LaceEvent>;
|
|
52
|
-
//# sourceMappingURL=condition-based-waiting-example.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"condition-based-waiting-example.d.ts","sourceRoot":"","sources":["../../../src/skills/systematic-debugging/condition-based-waiting-example.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,aAAa,EACxB,SAAS,SAAO,GACf,OAAO,CAAC,SAAS,CAAC,CAmBpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,MAAM,EACb,SAAS,SAAO,GACf,OAAO,CAAC,SAAS,EAAE,CAAC,CAuBtB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,EACxC,WAAW,EAAE,MAAM,EACnB,SAAS,SAAO,GACf,OAAO,CAAC,SAAS,CAAC,CAmBpB"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// Complete implementation of condition-based waiting utilities
|
|
2
|
-
// From: Lace test infrastructure improvements (2025-10-03)
|
|
3
|
-
// Context: Fixed 15 flaky tests by replacing arbitrary timeouts
|
|
4
|
-
/**
|
|
5
|
-
* Wait for a specific event type to appear in thread
|
|
6
|
-
*
|
|
7
|
-
* @param threadManager - The thread manager to query
|
|
8
|
-
* @param threadId - Thread to check for events
|
|
9
|
-
* @param eventType - Type of event to wait for
|
|
10
|
-
* @param timeoutMs - Maximum time to wait (default 5000ms)
|
|
11
|
-
* @returns Promise resolving to the first matching event
|
|
12
|
-
*
|
|
13
|
-
* Example:
|
|
14
|
-
* await waitForEvent(threadManager, agentThreadId, 'TOOL_RESULT');
|
|
15
|
-
*/
|
|
16
|
-
export function waitForEvent(threadManager, threadId, eventType, timeoutMs = 5000) {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
const startTime = Date.now();
|
|
19
|
-
const check = () => {
|
|
20
|
-
const events = threadManager.getEvents(threadId);
|
|
21
|
-
const event = events.find((e) => e.type === eventType);
|
|
22
|
-
if (event) {
|
|
23
|
-
resolve(event);
|
|
24
|
-
}
|
|
25
|
-
else if (Date.now() - startTime > timeoutMs) {
|
|
26
|
-
reject(new Error(`Timeout waiting for ${eventType} event after ${timeoutMs}ms`));
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
setTimeout(check, 10); // Poll every 10ms for efficiency
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
check();
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Wait for a specific number of events of a given type
|
|
37
|
-
*
|
|
38
|
-
* @param threadManager - The thread manager to query
|
|
39
|
-
* @param threadId - Thread to check for events
|
|
40
|
-
* @param eventType - Type of event to wait for
|
|
41
|
-
* @param count - Number of events to wait for
|
|
42
|
-
* @param timeoutMs - Maximum time to wait (default 5000ms)
|
|
43
|
-
* @returns Promise resolving to all matching events once count is reached
|
|
44
|
-
*
|
|
45
|
-
* Example:
|
|
46
|
-
* // Wait for 2 AGENT_MESSAGE events (initial response + continuation)
|
|
47
|
-
* await waitForEventCount(threadManager, agentThreadId, 'AGENT_MESSAGE', 2);
|
|
48
|
-
*/
|
|
49
|
-
export function waitForEventCount(threadManager, threadId, eventType, count, timeoutMs = 5000) {
|
|
50
|
-
return new Promise((resolve, reject) => {
|
|
51
|
-
const startTime = Date.now();
|
|
52
|
-
const check = () => {
|
|
53
|
-
const events = threadManager.getEvents(threadId);
|
|
54
|
-
const matchingEvents = events.filter((e) => e.type === eventType);
|
|
55
|
-
if (matchingEvents.length >= count) {
|
|
56
|
-
resolve(matchingEvents);
|
|
57
|
-
}
|
|
58
|
-
else if (Date.now() - startTime > timeoutMs) {
|
|
59
|
-
reject(new Error(`Timeout waiting for ${count} ${eventType} events after ${timeoutMs}ms (got ${matchingEvents.length})`));
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
setTimeout(check, 10);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
check();
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Wait for an event matching a custom predicate
|
|
70
|
-
* Useful when you need to check event data, not just type
|
|
71
|
-
*
|
|
72
|
-
* @param threadManager - The thread manager to query
|
|
73
|
-
* @param threadId - Thread to check for events
|
|
74
|
-
* @param predicate - Function that returns true when event matches
|
|
75
|
-
* @param description - Human-readable description for error messages
|
|
76
|
-
* @param timeoutMs - Maximum time to wait (default 5000ms)
|
|
77
|
-
* @returns Promise resolving to the first matching event
|
|
78
|
-
*
|
|
79
|
-
* Example:
|
|
80
|
-
* // Wait for TOOL_RESULT with specific ID
|
|
81
|
-
* await waitForEventMatch(
|
|
82
|
-
* threadManager,
|
|
83
|
-
* agentThreadId,
|
|
84
|
-
* (e) => e.type === 'TOOL_RESULT' && e.data.id === 'call_123',
|
|
85
|
-
* 'TOOL_RESULT with id=call_123'
|
|
86
|
-
* );
|
|
87
|
-
*/
|
|
88
|
-
export function waitForEventMatch(threadManager, threadId, predicate, description, timeoutMs = 5000) {
|
|
89
|
-
return new Promise((resolve, reject) => {
|
|
90
|
-
const startTime = Date.now();
|
|
91
|
-
const check = () => {
|
|
92
|
-
const events = threadManager.getEvents(threadId);
|
|
93
|
-
const event = events.find(predicate);
|
|
94
|
-
if (event) {
|
|
95
|
-
resolve(event);
|
|
96
|
-
}
|
|
97
|
-
else if (Date.now() - startTime > timeoutMs) {
|
|
98
|
-
reject(new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`));
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
setTimeout(check, 10);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
check();
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
// Usage example from actual debugging session:
|
|
108
|
-
//
|
|
109
|
-
// BEFORE (flaky):
|
|
110
|
-
// ---------------
|
|
111
|
-
// const messagePromise = agent.sendMessage('Execute tools');
|
|
112
|
-
// await new Promise(r => setTimeout(r, 300)); // Hope tools start in 300ms
|
|
113
|
-
// agent.abort();
|
|
114
|
-
// await messagePromise;
|
|
115
|
-
// await new Promise(r => setTimeout(r, 50)); // Hope results arrive in 50ms
|
|
116
|
-
// expect(toolResults.length).toBe(2); // Fails randomly
|
|
117
|
-
//
|
|
118
|
-
// AFTER (reliable):
|
|
119
|
-
// ----------------
|
|
120
|
-
// const messagePromise = agent.sendMessage('Execute tools');
|
|
121
|
-
// await waitForEventCount(threadManager, threadId, 'TOOL_CALL', 2); // Wait for tools to start
|
|
122
|
-
// agent.abort();
|
|
123
|
-
// await messagePromise;
|
|
124
|
-
// await waitForEventCount(threadManager, threadId, 'TOOL_RESULT', 2); // Wait for results
|
|
125
|
-
// expect(toolResults.length).toBe(2); // Always succeeds
|
|
126
|
-
//
|
|
127
|
-
// Result: 60% pass rate → 100%, 40% faster execution
|
|
128
|
-
//# sourceMappingURL=condition-based-waiting-example.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"condition-based-waiting-example.js","sourceRoot":"","sources":["../../../src/skills/systematic-debugging/condition-based-waiting-example.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,2DAA2D;AAC3D,gEAAgE;AAKhE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAC1B,aAA4B,EAC5B,QAAgB,EAChB,SAAwB,EACxB,SAAS,GAAG,IAAI;IAEhB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,MAAM,KAAK,GAAG,GAAG,EAAE;YACjB,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YACjD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;YAEvD,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;iBAAM,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,SAAS,EAAE,CAAC;gBAC9C,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAuB,SAAS,gBAAgB,SAAS,IAAI,CAAC,CAAC,CAAC;YACnF,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,iCAAiC;YAC1D,CAAC;QACH,CAAC,CAAC;QAEF,KAAK,EAAE,C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