@yuaone/core 0.9.43 → 1.0.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/dist/agent-affordance.d.ts +37 -0
- package/dist/agent-affordance.d.ts.map +1 -0
- package/dist/agent-affordance.js +139 -0
- package/dist/agent-affordance.js.map +1 -0
- package/dist/agent-decision-types.d.ts +262 -0
- package/dist/agent-decision-types.d.ts.map +1 -0
- package/dist/agent-decision-types.js +19 -0
- package/dist/agent-decision-types.js.map +1 -0
- package/dist/agent-decision.d.ts +52 -0
- package/dist/agent-decision.d.ts.map +1 -0
- package/dist/agent-decision.js +767 -0
- package/dist/agent-decision.js.map +1 -0
- package/dist/agent-loop.d.ts +37 -79
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +730 -586
- package/dist/agent-loop.js.map +1 -1
- package/dist/agent-reasoning-engine.d.ts +48 -0
- package/dist/agent-reasoning-engine.d.ts.map +1 -0
- package/dist/agent-reasoning-engine.js +544 -0
- package/dist/agent-reasoning-engine.js.map +1 -0
- package/dist/codebase-context.d.ts +3 -0
- package/dist/codebase-context.d.ts.map +1 -1
- package/dist/codebase-context.js +15 -6
- package/dist/codebase-context.js.map +1 -1
- package/dist/command-plan-compiler.d.ts +43 -0
- package/dist/command-plan-compiler.d.ts.map +1 -0
- package/dist/command-plan-compiler.js +164 -0
- package/dist/command-plan-compiler.js.map +1 -0
- package/dist/dependency-guard.d.ts +18 -0
- package/dist/dependency-guard.d.ts.map +1 -0
- package/dist/dependency-guard.js +113 -0
- package/dist/dependency-guard.js.map +1 -0
- package/dist/execution-engine.d.ts +10 -1
- package/dist/execution-engine.d.ts.map +1 -1
- package/dist/execution-engine.js +162 -8
- package/dist/execution-engine.js.map +1 -1
- package/dist/execution-receipt.d.ts +62 -0
- package/dist/execution-receipt.d.ts.map +1 -0
- package/dist/execution-receipt.js +67 -0
- package/dist/execution-receipt.js.map +1 -0
- package/dist/failure-surface-writer.d.ts +13 -0
- package/dist/failure-surface-writer.d.ts.map +1 -0
- package/dist/failure-surface-writer.js +33 -0
- package/dist/failure-surface-writer.js.map +1 -0
- package/dist/file-chunker.d.ts +26 -0
- package/dist/file-chunker.d.ts.map +1 -0
- package/dist/file-chunker.js +103 -0
- package/dist/file-chunker.js.map +1 -0
- package/dist/image-observer.d.ts +22 -0
- package/dist/image-observer.d.ts.map +1 -0
- package/dist/image-observer.js +60 -0
- package/dist/image-observer.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -1
- package/dist/judgment-rules.d.ts +44 -0
- package/dist/judgment-rules.d.ts.map +1 -0
- package/dist/judgment-rules.js +185 -0
- package/dist/judgment-rules.js.map +1 -0
- package/dist/memory-decay.d.ts +41 -0
- package/dist/memory-decay.d.ts.map +1 -0
- package/dist/memory-decay.js +62 -0
- package/dist/memory-decay.js.map +1 -0
- package/dist/memory-manager.d.ts.map +1 -1
- package/dist/memory-manager.js +30 -0
- package/dist/memory-manager.js.map +1 -1
- package/dist/model-weakness-tracker.d.ts +42 -0
- package/dist/model-weakness-tracker.d.ts.map +1 -0
- package/dist/model-weakness-tracker.js +107 -0
- package/dist/model-weakness-tracker.js.map +1 -0
- package/dist/overhead-governor.d.ts +3 -1
- package/dist/overhead-governor.d.ts.map +1 -1
- package/dist/overhead-governor.js +5 -0
- package/dist/overhead-governor.js.map +1 -1
- package/dist/patch-scope-controller.d.ts +44 -0
- package/dist/patch-scope-controller.d.ts.map +1 -0
- package/dist/patch-scope-controller.js +107 -0
- package/dist/patch-scope-controller.js.map +1 -0
- package/dist/patch-transaction.d.ts +53 -0
- package/dist/patch-transaction.d.ts.map +1 -0
- package/dist/patch-transaction.js +119 -0
- package/dist/patch-transaction.js.map +1 -0
- package/dist/pre-write-validator.d.ts +29 -0
- package/dist/pre-write-validator.d.ts.map +1 -0
- package/dist/pre-write-validator.js +97 -0
- package/dist/pre-write-validator.js.map +1 -0
- package/dist/prompt-builder.d.ts +25 -0
- package/dist/prompt-builder.d.ts.map +1 -0
- package/dist/prompt-builder.js +93 -0
- package/dist/prompt-builder.js.map +1 -0
- package/dist/prompt-envelope.d.ts +40 -0
- package/dist/prompt-envelope.d.ts.map +1 -0
- package/dist/prompt-envelope.js +16 -0
- package/dist/prompt-envelope.js.map +1 -0
- package/dist/prompt-runtime.d.ts +66 -0
- package/dist/prompt-runtime.d.ts.map +1 -0
- package/dist/prompt-runtime.js +492 -0
- package/dist/prompt-runtime.js.map +1 -0
- package/dist/repo-capability-profile.d.ts +24 -0
- package/dist/repo-capability-profile.d.ts.map +1 -0
- package/dist/repo-capability-profile.js +113 -0
- package/dist/repo-capability-profile.js.map +1 -0
- package/dist/security-gate.d.ts +39 -0
- package/dist/security-gate.d.ts.map +1 -0
- package/dist/security-gate.js +121 -0
- package/dist/security-gate.js.map +1 -0
- package/dist/self-evaluation.d.ts +22 -0
- package/dist/self-evaluation.d.ts.map +1 -0
- package/dist/self-evaluation.js +43 -0
- package/dist/self-evaluation.js.map +1 -0
- package/dist/semantic-diff-reviewer.d.ts +28 -0
- package/dist/semantic-diff-reviewer.d.ts.map +1 -0
- package/dist/semantic-diff-reviewer.js +168 -0
- package/dist/semantic-diff-reviewer.js.map +1 -0
- package/dist/stall-detector.d.ts +26 -2
- package/dist/stall-detector.d.ts.map +1 -1
- package/dist/stall-detector.js +128 -3
- package/dist/stall-detector.js.map +1 -1
- package/dist/system-core.d.ts +27 -0
- package/dist/system-core.d.ts.map +1 -0
- package/dist/system-core.js +269 -0
- package/dist/system-core.js.map +1 -0
- package/dist/system-prompt.d.ts +4 -0
- package/dist/system-prompt.d.ts.map +1 -1
- package/dist/system-prompt.js +12 -218
- package/dist/system-prompt.js.map +1 -1
- package/dist/target-file-ranker.d.ts +38 -0
- package/dist/target-file-ranker.d.ts.map +1 -0
- package/dist/target-file-ranker.js +90 -0
- package/dist/target-file-ranker.js.map +1 -0
- package/dist/task-classifier.d.ts +6 -0
- package/dist/task-classifier.d.ts.map +1 -1
- package/dist/task-classifier.js +6 -0
- package/dist/task-classifier.js.map +1 -1
- package/dist/test-impact-planner.d.ts +16 -0
- package/dist/test-impact-planner.d.ts.map +1 -0
- package/dist/test-impact-planner.js +68 -0
- package/dist/test-impact-planner.js.map +1 -0
- package/dist/tool-outcome-cache.d.ts +41 -0
- package/dist/tool-outcome-cache.d.ts.map +1 -0
- package/dist/tool-outcome-cache.js +88 -0
- package/dist/tool-outcome-cache.js.map +1 -0
- package/dist/types.d.ts +39 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/verifier-rules.d.ts +15 -0
- package/dist/verifier-rules.d.ts.map +1 -0
- package/dist/verifier-rules.js +80 -0
- package/dist/verifier-rules.js.map +1 -0
- package/dist/workspace-mutation-policy.d.ts +28 -0
- package/dist/workspace-mutation-policy.d.ts.map +1 -0
- package/dist/workspace-mutation-policy.js +56 -0
- package/dist/workspace-mutation-policy.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent-affordance
|
|
3
|
+
* @description AgentAffordanceVector calculator.
|
|
4
|
+
* Pure math, NO LLM, NO async. Deterministic: same input → same output.
|
|
5
|
+
*
|
|
6
|
+
* Ported from YUA Decision Orchestrator's computeResponseAffordance
|
|
7
|
+
* into coding-agent execution-tendency vectors.
|
|
8
|
+
*/
|
|
9
|
+
import type { AgentReasoningResult, AgentAffordanceVector } from "./agent-decision-types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Smooth ease curve: 0→0, 0.5→0.5, 1→1.
|
|
12
|
+
* `0.5 * (1 - cos(PI * clamp01(x)))`
|
|
13
|
+
*/
|
|
14
|
+
export declare function cosineEase(x: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Cosine similarity between two affordance vectors.
|
|
17
|
+
* Returns a value in [-1, 1], though for non-negative vectors it's [0, 1].
|
|
18
|
+
*/
|
|
19
|
+
export declare function cosineSimilarity(a: AgentAffordanceVector, b: AgentAffordanceVector): number;
|
|
20
|
+
/**
|
|
21
|
+
* Compute the 5D agent affordance vector from reasoning output.
|
|
22
|
+
* Pure function — same inputs produce identical output.
|
|
23
|
+
*
|
|
24
|
+
* Pipeline: intentBias → stageMultiplier → depthDecay → cosineEase → clamp →
|
|
25
|
+
* hardGuards → trendCorrection → stuckBreaker
|
|
26
|
+
*/
|
|
27
|
+
export declare function computeAgentAffordance(reasoning: AgentReasoningResult, prevAffordance?: AgentAffordanceVector): AgentAffordanceVector;
|
|
28
|
+
/**
|
|
29
|
+
* If the same decision pattern repeats 3+ times, force a strategy shift
|
|
30
|
+
* to break out of repetitive loops.
|
|
31
|
+
*
|
|
32
|
+
* @param affordance - Current affordance vector (will be shallow-copied, not mutated)
|
|
33
|
+
* @param repeatCount - Number of consecutive similar decisions
|
|
34
|
+
* @returns Adjusted affordance vector, or the original if repeatCount < 3
|
|
35
|
+
*/
|
|
36
|
+
export declare function applyStuckBreaker(affordance: Readonly<AgentAffordanceVector>, repeatCount: number): AgentAffordanceVector;
|
|
37
|
+
//# sourceMappingURL=agent-affordance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-affordance.d.ts","sourceRoot":"","sources":["../src/agent-affordance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EAItB,MAAM,2BAA2B,CAAC;AASnC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,qBAAqB,EACxB,CAAC,EAAE,qBAAqB,GACvB,MAAM,CAeR;AAiDD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,oBAAoB,EAC/B,cAAc,CAAC,EAAE,qBAAqB,GACrC,qBAAqB,CAkDvB;AAID;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,QAAQ,CAAC,qBAAqB,CAAC,EAC3C,WAAW,EAAE,MAAM,GAClB,qBAAqB,CAWvB"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent-affordance
|
|
3
|
+
* @description AgentAffordanceVector calculator.
|
|
4
|
+
* Pure math, NO LLM, NO async. Deterministic: same input → same output.
|
|
5
|
+
*
|
|
6
|
+
* Ported from YUA Decision Orchestrator's computeResponseAffordance
|
|
7
|
+
* into coding-agent execution-tendency vectors.
|
|
8
|
+
*/
|
|
9
|
+
// ─── Math Utilities ───
|
|
10
|
+
/** Clamp a number to [0, 1]. */
|
|
11
|
+
function clamp01(x) {
|
|
12
|
+
return Math.max(0, Math.min(1, x));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Smooth ease curve: 0→0, 0.5→0.5, 1→1.
|
|
16
|
+
* `0.5 * (1 - cos(PI * clamp01(x)))`
|
|
17
|
+
*/
|
|
18
|
+
export function cosineEase(x) {
|
|
19
|
+
return 0.5 * (1 - Math.cos(Math.PI * clamp01(x)));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Cosine similarity between two affordance vectors.
|
|
23
|
+
* Returns a value in [-1, 1], though for non-negative vectors it's [0, 1].
|
|
24
|
+
*/
|
|
25
|
+
export function cosineSimilarity(a, b) {
|
|
26
|
+
const keys = [
|
|
27
|
+
"explain_plan", "inspect_more", "edit_now", "run_checks", "finalize",
|
|
28
|
+
];
|
|
29
|
+
let dot = 0;
|
|
30
|
+
let magA = 0;
|
|
31
|
+
let magB = 0;
|
|
32
|
+
for (const k of keys) {
|
|
33
|
+
dot += a[k] * b[k];
|
|
34
|
+
magA += a[k] * a[k];
|
|
35
|
+
magB += b[k] * b[k];
|
|
36
|
+
}
|
|
37
|
+
const denom = Math.sqrt(magA) * Math.sqrt(magB);
|
|
38
|
+
if (denom === 0)
|
|
39
|
+
return 0;
|
|
40
|
+
return dot / denom;
|
|
41
|
+
}
|
|
42
|
+
// ─── Intent Bias Table (9 intents → 5D base vectors, §5.1) ───
|
|
43
|
+
const INTENT_BIAS = {
|
|
44
|
+
inspect: { explain_plan: 0.3, inspect_more: 0.8, edit_now: 0.1, run_checks: 0.2, finalize: 0.1 },
|
|
45
|
+
plan: { explain_plan: 0.9, inspect_more: 0.5, edit_now: 0.2, run_checks: 0.3, finalize: 0.1 },
|
|
46
|
+
search: { explain_plan: 0.2, inspect_more: 0.9, edit_now: 0.1, run_checks: 0.1, finalize: 0.1 },
|
|
47
|
+
read: { explain_plan: 0.3, inspect_more: 0.7, edit_now: 0.1, run_checks: 0.2, finalize: 0.2 },
|
|
48
|
+
edit: { explain_plan: 0.3, inspect_more: 0.2, edit_now: 0.9, run_checks: 0.5, finalize: 0.3 },
|
|
49
|
+
test: { explain_plan: 0.2, inspect_more: 0.2, edit_now: 0.3, run_checks: 0.9, finalize: 0.4 },
|
|
50
|
+
verify: { explain_plan: 0.1, inspect_more: 0.2, edit_now: 0.2, run_checks: 0.8, finalize: 0.7 },
|
|
51
|
+
refactor: { explain_plan: 0.5, inspect_more: 0.4, edit_now: 0.8, run_checks: 0.7, finalize: 0.3 },
|
|
52
|
+
fix: { explain_plan: 0.2, inspect_more: 0.3, edit_now: 0.8, run_checks: 0.8, finalize: 0.4 },
|
|
53
|
+
};
|
|
54
|
+
const STAGE_MULTIPLIER = {
|
|
55
|
+
underspecified: { explain_plan: 1.3, inspect_more: 1.5, edit_now: 0.3 },
|
|
56
|
+
blocked: { inspect_more: 1.4, run_checks: 1.3, edit_now: 0.5 },
|
|
57
|
+
iterating: { edit_now: 1.2, run_checks: 1.1, finalize: 0.8 },
|
|
58
|
+
ready: {}, // no modifier
|
|
59
|
+
};
|
|
60
|
+
// ─── Depth Decay ───
|
|
61
|
+
const DEPTH_DECAY = {
|
|
62
|
+
deep: 0.95,
|
|
63
|
+
normal: 0.85,
|
|
64
|
+
shallow: 0.7,
|
|
65
|
+
};
|
|
66
|
+
// ─── Affordance Keys ───
|
|
67
|
+
const AFFORDANCE_KEYS = [
|
|
68
|
+
"explain_plan", "inspect_more", "edit_now", "run_checks", "finalize",
|
|
69
|
+
];
|
|
70
|
+
// ─── Main Calculator ───
|
|
71
|
+
/**
|
|
72
|
+
* Compute the 5D agent affordance vector from reasoning output.
|
|
73
|
+
* Pure function — same inputs produce identical output.
|
|
74
|
+
*
|
|
75
|
+
* Pipeline: intentBias → stageMultiplier → depthDecay → cosineEase → clamp →
|
|
76
|
+
* hardGuards → trendCorrection → stuckBreaker
|
|
77
|
+
*/
|
|
78
|
+
export function computeAgentAffordance(reasoning, prevAffordance) {
|
|
79
|
+
const { intent, taskStage, complexity, depthHint } = reasoning;
|
|
80
|
+
const base = INTENT_BIAS[intent];
|
|
81
|
+
const stageMul = STAGE_MULTIPLIER[taskStage];
|
|
82
|
+
const depthDecay = DEPTH_DECAY[depthHint];
|
|
83
|
+
// Compute raw vector with cosineEase
|
|
84
|
+
const raw = {
|
|
85
|
+
explain_plan: 0,
|
|
86
|
+
inspect_more: 0,
|
|
87
|
+
edit_now: 0,
|
|
88
|
+
run_checks: 0,
|
|
89
|
+
finalize: 0,
|
|
90
|
+
};
|
|
91
|
+
for (const k of AFFORDANCE_KEYS) {
|
|
92
|
+
raw[k] = cosineEase(base[k] * (stageMul[k] ?? 1) * depthDecay);
|
|
93
|
+
}
|
|
94
|
+
// Clamp all to [0, 1]
|
|
95
|
+
for (const k of AFFORDANCE_KEYS) {
|
|
96
|
+
raw[k] = clamp01(raw[k]);
|
|
97
|
+
}
|
|
98
|
+
// ─── Hard Guards ───
|
|
99
|
+
// underspecified → edit_now max 0.15
|
|
100
|
+
if (taskStage === "underspecified") {
|
|
101
|
+
raw.edit_now = Math.min(raw.edit_now, 0.15);
|
|
102
|
+
}
|
|
103
|
+
// trivial → explain_plan max 0.2, finalize min 0.7
|
|
104
|
+
if (complexity === "trivial") {
|
|
105
|
+
raw.explain_plan = Math.min(raw.explain_plan, 0.2);
|
|
106
|
+
raw.finalize = Math.max(raw.finalize, 0.7);
|
|
107
|
+
}
|
|
108
|
+
// ─── Trend Correction ───
|
|
109
|
+
if (prevAffordance) {
|
|
110
|
+
const similarity = cosineSimilarity(raw, prevAffordance);
|
|
111
|
+
if (similarity > 0.92) {
|
|
112
|
+
// Too similar — induce slight exploration boost
|
|
113
|
+
raw.inspect_more = clamp01(raw.inspect_more + 0.05);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return raw;
|
|
117
|
+
}
|
|
118
|
+
// ─── Stuck Breaker (GPT QA #15) ───
|
|
119
|
+
/**
|
|
120
|
+
* If the same decision pattern repeats 3+ times, force a strategy shift
|
|
121
|
+
* to break out of repetitive loops.
|
|
122
|
+
*
|
|
123
|
+
* @param affordance - Current affordance vector (will be shallow-copied, not mutated)
|
|
124
|
+
* @param repeatCount - Number of consecutive similar decisions
|
|
125
|
+
* @returns Adjusted affordance vector, or the original if repeatCount < 3
|
|
126
|
+
*/
|
|
127
|
+
export function applyStuckBreaker(affordance, repeatCount) {
|
|
128
|
+
if (repeatCount < 3)
|
|
129
|
+
return { ...affordance };
|
|
130
|
+
// 3+ repeats → force strategy shift
|
|
131
|
+
return {
|
|
132
|
+
explain_plan: clamp01(affordance.explain_plan + 0.2),
|
|
133
|
+
inspect_more: clamp01(affordance.inspect_more - 0.2),
|
|
134
|
+
edit_now: clamp01(affordance.edit_now - 0.1),
|
|
135
|
+
run_checks: clamp01(affordance.run_checks + 0.3),
|
|
136
|
+
finalize: clamp01(affordance.finalize + 0.2),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=agent-affordance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-affordance.js","sourceRoot":"","sources":["../src/agent-affordance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,yBAAyB;AAEzB,gCAAgC;AAChC,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,IAAI,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GAAG,GAAG,CAAC;QACpD,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,YAAY,GAAG,GAAG,CAAC;QACpD,QAAQ,EAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG,GAAG,CAAC;QAChD,UAAU,EAAI,OAAO,CAAC,UAAU,CAAC,UAAU,GAAG,GAAG,CAAC;QAClD,QAAQ,EAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG,GAAG,CAAC;KACjD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent-decision-types
|
|
3
|
+
* @description Type definitions for the YUAN Agent Decision Engine.
|
|
4
|
+
* All types are defined here as SSOT — no duplication across modules.
|
|
5
|
+
*
|
|
6
|
+
* Ported from YUA Decision Orchestrator types into coding-agent domain.
|
|
7
|
+
*/
|
|
8
|
+
import type { SubAgentRole } from "./sub-agent-prompts.js";
|
|
9
|
+
/** Coding agent task intent (9 variants) */
|
|
10
|
+
export type AgentIntent = "inspect" | "plan" | "search" | "read" | "edit" | "test" | "verify" | "refactor" | "fix";
|
|
11
|
+
/** User's task readiness stage */
|
|
12
|
+
export type AgentTaskStage = "underspecified" | "ready" | "blocked" | "iterating";
|
|
13
|
+
/** Task complexity */
|
|
14
|
+
export type AgentComplexity = "trivial" | "simple" | "moderate" | "complex" | "massive";
|
|
15
|
+
/** Next execution direction hint */
|
|
16
|
+
export type AgentFlowAnchor = "SEARCH_REPO" | "READ_FILES" | "PREPARE_PATCH" | "RUN_TESTS" | "VERIFY_RESULT" | "SUMMARIZE_CHANGE";
|
|
17
|
+
/** Intent family for downstream branching (GPT QA #11) */
|
|
18
|
+
export type IntentFamily = "explore" | "modify" | "validate";
|
|
19
|
+
/** Decision Engine이 결정하는 실행 모드 */
|
|
20
|
+
export type InteractionMode = "CHAT" | "AGENT" | "HYBRID";
|
|
21
|
+
export declare const INTENT_FAMILY: Record<AgentIntent, IntentFamily>;
|
|
22
|
+
export interface AgentReasoningResult {
|
|
23
|
+
intent: AgentIntent;
|
|
24
|
+
taskStage: AgentTaskStage;
|
|
25
|
+
complexity: AgentComplexity;
|
|
26
|
+
confidence: number;
|
|
27
|
+
depthHint: "shallow" | "normal" | "deep";
|
|
28
|
+
cognitiveLoad: "low" | "medium" | "high";
|
|
29
|
+
nextAnchors: AgentFlowAnchor[];
|
|
30
|
+
}
|
|
31
|
+
/** 5D execution-tendency vector (not response style) */
|
|
32
|
+
export interface AgentAffordanceVector {
|
|
33
|
+
explain_plan: number;
|
|
34
|
+
inspect_more: number;
|
|
35
|
+
edit_now: number;
|
|
36
|
+
run_checks: number;
|
|
37
|
+
finalize: number;
|
|
38
|
+
}
|
|
39
|
+
export interface AgentComputePolicy {
|
|
40
|
+
maxIterations: number;
|
|
41
|
+
maxTokenBudget: number;
|
|
42
|
+
modelTier: "fast" | "standard" | "deep";
|
|
43
|
+
parallelAgents: number;
|
|
44
|
+
}
|
|
45
|
+
/** Decision-determined next action mode */
|
|
46
|
+
export type AgentNextAction = "proceed" | "ask_user" | "blocked_external";
|
|
47
|
+
/** Structured clarification request for ask_user */
|
|
48
|
+
export interface ClarificationRequest {
|
|
49
|
+
reason: string;
|
|
50
|
+
missingFields: string[];
|
|
51
|
+
suggestedOptions: string[];
|
|
52
|
+
allowProceedWithAssumptions: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface AgentFailureSurface {
|
|
55
|
+
patchRisk: number;
|
|
56
|
+
buildRisk: number;
|
|
57
|
+
testRisk: number;
|
|
58
|
+
blastRadius: number;
|
|
59
|
+
ambiguityRisk: number;
|
|
60
|
+
}
|
|
61
|
+
export interface AgentVetoFlags {
|
|
62
|
+
/** patchRisk >= 0.8 and no plan -> direct edit forbidden */
|
|
63
|
+
editVetoed: boolean;
|
|
64
|
+
/** blastRadius >= 0.6 -> verifyDepth minimum quick */
|
|
65
|
+
verifyRequired: boolean;
|
|
66
|
+
/** ambiguityRisk >= 0.7 -> ask_user forced */
|
|
67
|
+
clarifyForced: boolean;
|
|
68
|
+
/** buildRisk >= 0.7 -> finalize forbidden, verify required */
|
|
69
|
+
finalizeBlocked: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface AgentToolBudget {
|
|
72
|
+
maxFileReads: number;
|
|
73
|
+
maxEdits: number;
|
|
74
|
+
maxShellExecs: number;
|
|
75
|
+
maxTestRuns: number;
|
|
76
|
+
maxSearches: number;
|
|
77
|
+
maxWebLookups: number;
|
|
78
|
+
shellCostUnits: number;
|
|
79
|
+
maxSameFileEdits: number;
|
|
80
|
+
}
|
|
81
|
+
/** Budget enforcement mode (GPT QA #9) */
|
|
82
|
+
export type BudgetEnforcementMode = "soft" | "hard";
|
|
83
|
+
export type AgentMemoryCategory = "tool_pattern" | "error_pattern" | "project_rule" | "file_structure" | "user_preference" | "failure_avoidance";
|
|
84
|
+
export interface AgentMemoryIntent {
|
|
85
|
+
shouldSave: boolean;
|
|
86
|
+
categories: AgentMemoryCategory[];
|
|
87
|
+
priority: "low" | "normal" | "high";
|
|
88
|
+
target: "local" | "backend" | "both";
|
|
89
|
+
}
|
|
90
|
+
export interface AgentTaskContinuation {
|
|
91
|
+
isContinuation: boolean;
|
|
92
|
+
continuityScore: number;
|
|
93
|
+
carryover: {
|
|
94
|
+
modifiedFiles: string[];
|
|
95
|
+
failedAttempts: string[];
|
|
96
|
+
prevIntent?: AgentIntent;
|
|
97
|
+
prevStage?: AgentTaskStage;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export interface AgentProjectContext {
|
|
101
|
+
hasTests: boolean;
|
|
102
|
+
fileCount: number;
|
|
103
|
+
language: string;
|
|
104
|
+
repoIndexed: boolean;
|
|
105
|
+
monorepo: boolean;
|
|
106
|
+
packageManager?: string;
|
|
107
|
+
testFrameworkPresent: boolean;
|
|
108
|
+
dirtyWorkingTree: boolean;
|
|
109
|
+
currentBranchProtected: boolean;
|
|
110
|
+
recentFailureCount: number;
|
|
111
|
+
changedFilesCount: number;
|
|
112
|
+
hasBuildErrors: boolean;
|
|
113
|
+
hasConflicts: boolean;
|
|
114
|
+
missingDeps: boolean;
|
|
115
|
+
buildTool?: string;
|
|
116
|
+
testRunner?: string;
|
|
117
|
+
avgCyclomaticComplexity?: number;
|
|
118
|
+
avgCognitiveComplexity?: number;
|
|
119
|
+
maxFileComplexity?: number;
|
|
120
|
+
avgLoc?: number;
|
|
121
|
+
}
|
|
122
|
+
/** FailureRecovery provides this hint — does NOT regenerate decision */
|
|
123
|
+
export interface RecoveryHint {
|
|
124
|
+
action: "retry" | "rollback" | "skip" | "ask_user" | "alternative_approach";
|
|
125
|
+
reason: string;
|
|
126
|
+
/** Stage hint for next run (replaces prevDecision stage) */
|
|
127
|
+
stageHint?: AgentTaskStage;
|
|
128
|
+
}
|
|
129
|
+
/** Sub-agent orchestration plan — Decision determines WHAT agents to use */
|
|
130
|
+
export interface AgentSubAgentPlan {
|
|
131
|
+
/** Whether to use sub-agents at all */
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
/** Maximum concurrent agents */
|
|
134
|
+
maxAgents: number;
|
|
135
|
+
/** Which roles to activate (from existing SubAgentRole type) */
|
|
136
|
+
roles: SubAgentRole[];
|
|
137
|
+
/** Execution strategy */
|
|
138
|
+
strategy: "parallel" | "sequential" | "pipeline";
|
|
139
|
+
}
|
|
140
|
+
/** Skill/Plugin activation — Decision determines WHAT to enable */
|
|
141
|
+
export interface AgentSkillActivation {
|
|
142
|
+
/** Enable ToolPlanner (tool sequence optimization) */
|
|
143
|
+
enableToolPlanning: boolean;
|
|
144
|
+
/** Enable SkillLearner (learn from execution patterns) */
|
|
145
|
+
enableSkillLearning: boolean;
|
|
146
|
+
/** Enable plugin system */
|
|
147
|
+
enablePlugins: boolean;
|
|
148
|
+
/** Enable specialist routing */
|
|
149
|
+
enableSpecialist: boolean;
|
|
150
|
+
/** Specialist domain (if detected from intent) */
|
|
151
|
+
specialistDomain?: string;
|
|
152
|
+
}
|
|
153
|
+
/** Persona/tone hint — Decision determines communication style */
|
|
154
|
+
export interface AgentPersonaHint {
|
|
155
|
+
/** Tone for responses */
|
|
156
|
+
tone: "casual" | "professional" | "technical" | "friendly";
|
|
157
|
+
/** Preferred language */
|
|
158
|
+
language: "ko" | "en" | "auto";
|
|
159
|
+
}
|
|
160
|
+
/** Direction strength for the agent's response */
|
|
161
|
+
export type AgentLeadHint = "NONE" | "SOFT" | "HARD";
|
|
162
|
+
/** Structured output guidance — determines response format and forbidden patterns */
|
|
163
|
+
export interface AgentResponseHint {
|
|
164
|
+
structure: "direct_answer" | "problem_solution" | "stepwise_explanation" | "code_first";
|
|
165
|
+
expansion: "none" | "soft" | "guided" | "full";
|
|
166
|
+
forbid: {
|
|
167
|
+
metaComment: boolean;
|
|
168
|
+
narration: boolean;
|
|
169
|
+
apology: boolean;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/** Tool access level — determines which tools are available */
|
|
173
|
+
export type AgentToolLevel = "FULL" | "LIMITED" | "READ_ONLY";
|
|
174
|
+
/** Tool gate — controls tool access based on intent/risk */
|
|
175
|
+
export interface AgentToolGate {
|
|
176
|
+
level: AgentToolLevel;
|
|
177
|
+
blockedTools: string[];
|
|
178
|
+
verifierBudget: number;
|
|
179
|
+
}
|
|
180
|
+
/** Execution pressure — how assertively the agent pushes forward */
|
|
181
|
+
export type AgentResponsePressure = "GENTLE" | "NEUTRAL" | "ASSERTIVE";
|
|
182
|
+
/** Pressure + momentum combined decision */
|
|
183
|
+
export interface AgentPressureDecision {
|
|
184
|
+
pressure: AgentResponsePressure;
|
|
185
|
+
momentum: "LOW" | "MEDIUM" | "HIGH";
|
|
186
|
+
}
|
|
187
|
+
/** Continuation context capsule — injected when resuming a previous task */
|
|
188
|
+
export interface AgentContinuityCapsule {
|
|
189
|
+
enabled: boolean;
|
|
190
|
+
summary?: string;
|
|
191
|
+
rules: string[];
|
|
192
|
+
}
|
|
193
|
+
/** Fine-grained style tracking derived from user message */
|
|
194
|
+
export interface AgentStyleHint {
|
|
195
|
+
formality: "casual" | "neutral" | "formal";
|
|
196
|
+
language: "ko" | "en" | "mixed";
|
|
197
|
+
brevity: "terse" | "normal" | "verbose";
|
|
198
|
+
}
|
|
199
|
+
/** Memory load decision — what to load at init */
|
|
200
|
+
export interface AgentMemoryLoad {
|
|
201
|
+
/** Whether to load memory at all */
|
|
202
|
+
shouldLoad: boolean;
|
|
203
|
+
/** Which categories to prioritize */
|
|
204
|
+
categories: AgentMemoryCategory[];
|
|
205
|
+
}
|
|
206
|
+
/** Code quality enforcement policy — set by Decision, consumed by PromptRuntime + AgentLoop */
|
|
207
|
+
export interface AgentCodeQualityPolicy {
|
|
208
|
+
/** Whether this task involves code modification */
|
|
209
|
+
isCodeTask: boolean;
|
|
210
|
+
/** Code task subtype */
|
|
211
|
+
codeTaskType: "generation" | "fix" | "refactor" | "review" | "test" | "none";
|
|
212
|
+
/** Primary risk category */
|
|
213
|
+
primaryRisk: "extension_pain" | "type_safety" | "async_race" | "state_corruption" | "blast_radius" | "none";
|
|
214
|
+
/** Quality constraints injected into prompt */
|
|
215
|
+
constraints: string[];
|
|
216
|
+
/** Whether to enforce strict mode (no TODO/stub/placeholder) */
|
|
217
|
+
strictMode: boolean;
|
|
218
|
+
/** Pre-edit verification required */
|
|
219
|
+
preEditVerify: boolean;
|
|
220
|
+
}
|
|
221
|
+
/** Deterministic core — same input yields same result */
|
|
222
|
+
export interface AgentDecisionCore {
|
|
223
|
+
readonly reasoning: AgentReasoningResult;
|
|
224
|
+
readonly affordance: AgentAffordanceVector;
|
|
225
|
+
readonly computePolicy: AgentComputePolicy;
|
|
226
|
+
readonly failureSurface: AgentFailureSurface;
|
|
227
|
+
readonly vetoFlags: AgentVetoFlags;
|
|
228
|
+
readonly toolBudget: AgentToolBudget;
|
|
229
|
+
readonly nextAction: AgentNextAction;
|
|
230
|
+
readonly clarification?: ClarificationRequest;
|
|
231
|
+
readonly planRequired: boolean;
|
|
232
|
+
readonly scanBreadth: "narrow" | "normal" | "wide";
|
|
233
|
+
readonly verifyDepth: "skip" | "quick" | "thorough";
|
|
234
|
+
readonly memoryIntent: AgentMemoryIntent;
|
|
235
|
+
readonly continuation: AgentTaskContinuation;
|
|
236
|
+
readonly microPlan?: readonly string[];
|
|
237
|
+
readonly interactionMode: InteractionMode;
|
|
238
|
+
readonly subAgentPlan: AgentSubAgentPlan;
|
|
239
|
+
readonly skillActivation: AgentSkillActivation;
|
|
240
|
+
readonly personaHint: AgentPersonaHint;
|
|
241
|
+
readonly memoryLoad: AgentMemoryLoad;
|
|
242
|
+
readonly codeQuality: AgentCodeQualityPolicy;
|
|
243
|
+
readonly leadHint: AgentLeadHint;
|
|
244
|
+
readonly responseHint: AgentResponseHint;
|
|
245
|
+
readonly toolGate: AgentToolGate;
|
|
246
|
+
readonly pressureDecision: AgentPressureDecision;
|
|
247
|
+
readonly continuityCapsule: AgentContinuityCapsule;
|
|
248
|
+
readonly styleHint: AgentStyleHint;
|
|
249
|
+
}
|
|
250
|
+
/** Runtime metadata — excluded from determinism verification (GPT QA #2) */
|
|
251
|
+
export interface AgentDecisionMeta {
|
|
252
|
+
readonly sessionId: string;
|
|
253
|
+
readonly createdAt: number;
|
|
254
|
+
/** Consecutive same-intent+stage count (for stuck breaker) */
|
|
255
|
+
readonly repeatCount: number;
|
|
256
|
+
}
|
|
257
|
+
/** Final SSOT — deep-frozen, immutable after creation (GPT QA #1) */
|
|
258
|
+
export interface AgentDecisionContext {
|
|
259
|
+
readonly core: AgentDecisionCore;
|
|
260
|
+
readonly meta: AgentDecisionMeta;
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=agent-decision-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-decision-types.d.ts","sourceRoot":"","sources":["../src/agent-decision-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D,4CAA4C;AAC5C,MAAM,MAAM,WAAW,G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AC7C,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;IACjD,QAAQ,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;IACnD,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;CACpC;AAED,4EAA4E;AAC5E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,qEAAqE;AACrE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;CAClC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent-decision-types
|
|
3
|
+
* @description Type definitions for the YUAN Agent Decision Engine.
|
|
4
|
+
* All types are defined here as SSOT — no duplication across modules.
|
|
5
|
+
*
|
|
6
|
+
* Ported from YUA Decision Orchestrator types into coding-agent domain.
|
|
7
|
+
*/
|
|
8
|
+
export const INTENT_FAMILY = {
|
|
9
|
+
inspect: "explore",
|
|
10
|
+
read: "explore",
|
|
11
|
+
search: "explore",
|
|
12
|
+
plan: "explore",
|
|
13
|
+
edit: "modify",
|
|
14
|
+
refactor: "modify",
|
|
15
|
+
fix: "modify",
|
|
16
|
+
test: "validate",
|
|
17
|
+
verify: "validate",
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=agent-decision-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-decision-types.js","sourceRoot":"","sources":["../src/agent-decision-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAmDH,MAAM,CAAC,MAAM,aAAa,GAAsC;IAC9D,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,UAAU;CACnB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent-decision
|
|
3
|
+
* @description Main Agent Decision Orchestrator.
|
|
4
|
+
* Single entry point: `agentDecide()` — called once per user message.
|
|
5
|
+
* Produces an immutable, deep-frozen `AgentDecisionContext` (SSOT).
|
|
6
|
+
*
|
|
7
|
+
* Pure function (except `crypto.randomUUID()` for session ID in meta).
|
|
8
|
+
* NO LLM calls, NO async.
|
|
9
|
+
*
|
|
10
|
+
* Design spec: docs/superpowers/specs/2026-03-17-yuan-agent-decision-engine-design.md, section 6
|
|
11
|
+
*/
|
|
12
|
+
import type { AgentDecisionContext, AgentProjectContext, AgentReasoningResult, InteractionMode, RecoveryHint } from "./agent-decision-types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Derive the interaction mode from reasoning result.
|
|
15
|
+
* Deterministic: same reasoning always yields the same mode.
|
|
16
|
+
*
|
|
17
|
+
* Rules:
|
|
18
|
+
* - CHAT: trivial + explore intents (inspect/read/search), OR underspecified
|
|
19
|
+
* - AGENT: complex/massive, OR plan/refactor intent, OR fix+moderate+
|
|
20
|
+
* - HYBRID: moderate edit/fix/test/verify, OR simple edit/fix
|
|
21
|
+
* - Default: CHAT
|
|
22
|
+
*/
|
|
23
|
+
export declare function deriveInteractionMode(reasoning: AgentReasoningResult): InteractionMode;
|
|
24
|
+
/**
|
|
25
|
+
* Single entry point for the Agent Decision Engine.
|
|
26
|
+
* Called once per user message. Produces an immutable `AgentDecisionContext`.
|
|
27
|
+
*
|
|
28
|
+
* Pipeline:
|
|
29
|
+
* agentReason → computeAgentAffordance → deriveComputePolicy →
|
|
30
|
+
* estimateFailureSurface → computeVetoFlags → deriveToolBudget →
|
|
31
|
+
* deriveMemoryIntent → detectTaskContinuation → deriveMicroPlan → deepFreeze
|
|
32
|
+
*
|
|
33
|
+
* Supports recoveryHint (GPT QA #8): if provided, adjusts the reasoning stage.
|
|
34
|
+
*/
|
|
35
|
+
export declare function agentDecide(input: {
|
|
36
|
+
message: string;
|
|
37
|
+
projectContext?: AgentProjectContext;
|
|
38
|
+
prevDecision?: AgentDecisionContext;
|
|
39
|
+
recoveryHint?: RecoveryHint;
|
|
40
|
+
}): AgentDecisionContext;
|
|
41
|
+
/**
|
|
42
|
+
* Safe default decision — used when agentDecide() fails or is skipped.
|
|
43
|
+
* Trivial/CHAT/proceed = most conservative, safest behavior.
|
|
44
|
+
* This ensures Decision is NEVER null in the pipeline.
|
|
45
|
+
*/
|
|
46
|
+
export declare const DEFAULT_DECISION: AgentDecisionContext;
|
|
47
|
+
/**
|
|
48
|
+
* Convert a WorldStateSnapshot into AgentProjectContext for Decision Engine input.
|
|
49
|
+
* This bridges the gap between runtime world state and decision-time project context.
|
|
50
|
+
*/
|
|
51
|
+
export declare function worldStateToProjectContext(ws: import("./world-state.js").WorldStateSnapshot): AgentProjectContext;
|
|
52
|
+
//# sourceMappingURL=agent-decision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-decision.d.ts","sourceRoot":"","sources":["../src/agent-decision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAMV,oBAAoB,EAYpB,mBAAmB,EACnB,oBAAoB,EAUpB,eAAe,EACf,YAAY,EACb,MAAM,2BAA2B,CAAC;AAuRnC;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,oBAAoB,GAAG,eAAe,CAwCtF;AAwTD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,GAAG,oBAAoB,CA+LvB;AAID;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,oBAyEL,CAAC;AAI3B;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,OAAO,kBAAkB,EAAE,kBAAkB,GAChD,mBAAmB,CAmBrB"}
|