pi-harness-runtime 1.1.348 → 1.1.350
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/index.ts +12 -0
- package/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/dist/delegation-assessor.d.ts +27 -0
- package/packages/contracts/dist/delegation-assessor.js +210 -0
- package/packages/contracts/dist/delegation.d.ts +142 -0
- package/packages/contracts/dist/delegation.js +33 -0
- package/packages/contracts/dist/index.d.ts +3 -0
- package/packages/contracts/dist/index.js +3 -0
- package/packages/contracts/dist/scope-discovery.d.ts +65 -0
- package/packages/contracts/dist/scope-discovery.js +247 -0
- package/packages/contracts/package.json +1 -1
- package/packages/contracts/src/delegation-assessor.ts +268 -0
- package/packages/contracts/src/delegation.ts +174 -0
- package/packages/contracts/src/index.ts +3 -0
- package/packages/contracts/src/scope-discovery.ts +352 -0
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/voice-api/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
package/index.ts
CHANGED
|
@@ -134,6 +134,8 @@ const sharedState = {
|
|
|
134
134
|
todoContinuationController: null as unknown,
|
|
135
135
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
136
|
updateAutoContinueStatus: null as any,
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
+
pqController: null as any,
|
|
137
139
|
};
|
|
138
140
|
|
|
139
141
|
async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
|
|
@@ -170,6 +172,7 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
|
|
|
170
172
|
const mod = await import("./packages/jev-judge/src/auto-continue.js");
|
|
171
173
|
const { createPendingQuestionController } = await import("./packages/notification/dist/index.js");
|
|
172
174
|
const pqController = createPendingQuestionController();
|
|
175
|
+
sharedState.pqController = pqController;
|
|
173
176
|
|
|
174
177
|
// Track waiting state
|
|
175
178
|
let waitingForUserSince: Date | null = null;
|
|
@@ -461,6 +464,9 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
|
|
|
461
464
|
waitingForUserSince = null;
|
|
462
465
|
_lastNotifiedQuestion = "";
|
|
463
466
|
updateAutoContinueStatus("IDLE");
|
|
467
|
+
// Cancel pending question on user response
|
|
468
|
+
// (User answered via Pi instead of button)
|
|
469
|
+
sharedState.pqController?.cancel("User responded via Pi");
|
|
464
470
|
}
|
|
465
471
|
}
|
|
466
472
|
});
|
|
@@ -523,6 +529,8 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
|
|
|
523
529
|
|
|
524
530
|
// Check session validity and user response before applying
|
|
525
531
|
if (checkSessionId !== _sessionId) {
|
|
532
|
+
// Session changed - cancel pending question
|
|
533
|
+
sharedState.pqController?.cancel("Session switched");
|
|
526
534
|
_inferenceInProgress = false;
|
|
527
535
|
updateAutoContinueStatus("IDLE");
|
|
528
536
|
return;
|
|
@@ -1199,12 +1207,16 @@ async function initTelegram(pi: ExtensionAPI): Promise<void> {
|
|
|
1199
1207
|
logToFile("[TelegramCallback] Approved - user clicked Continue, resuming work");
|
|
1200
1208
|
sharedState.waitingForUserSince = null;
|
|
1201
1209
|
sharedState.updateAutoContinueStatus?.("IDLE");
|
|
1210
|
+
// Resolve pending question with yes
|
|
1211
|
+
sharedState.pqController?.resolve({ resolution: "yes", by: "user" });
|
|
1202
1212
|
// Also resume continuation controller
|
|
1203
1213
|
(sharedState.todoContinuationController as any)?.resume?.();
|
|
1204
1214
|
break;
|
|
1205
1215
|
case CallbackActions.REJECT:
|
|
1206
1216
|
// User clicked Not yet - just dismiss, don't resume
|
|
1207
1217
|
logToFile("[TelegramCallback] Rejected - user clicked Not yet, pausing");
|
|
1218
|
+
// Resolve pending question with no
|
|
1219
|
+
sharedState.pqController?.resolve({ resolution: "no", by: "user" });
|
|
1208
1220
|
// Explicitly pause the continuation
|
|
1209
1221
|
(sharedState.todoContinuationController as any)?.explicitPause?.();
|
|
1210
1222
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-harness/capability-registry",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.350",
|
|
4
4
|
"description": "Capability Registry for pi-harness-runtime — tracks model capabilities and enables capability-based routing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation Assessor
|
|
3
|
+
*
|
|
4
|
+
* Assesses whether work should be delegated to sub-agents based on scope.
|
|
5
|
+
*/
|
|
6
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import type { ScopeFacts, DelegationDecision, DelegationTriggerConfig, ExtensionCapability } from "./delegation.js";
|
|
8
|
+
/**
|
|
9
|
+
* Discover extension capabilities for delegation
|
|
10
|
+
*/
|
|
11
|
+
export declare function discoverDelegationCapability(pi: ExtensionAPI): Promise<ExtensionCapability | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Estimate scope from file analysis
|
|
14
|
+
*/
|
|
15
|
+
export declare function estimateScope(_pi: ExtensionAPI, patterns: string[]): Promise<ScopeFacts>;
|
|
16
|
+
/**
|
|
17
|
+
* Make deterministic assessment without Jev
|
|
18
|
+
*/
|
|
19
|
+
export declare function makeDeterministicAssessment(facts: ScopeFacts, capability: ExtensionCapability | null): DelegationDecision;
|
|
20
|
+
/**
|
|
21
|
+
* Assess delegation need
|
|
22
|
+
*/
|
|
23
|
+
export declare function assessDelegation(pi: ExtensionAPI, facts: ScopeFacts, config?: DelegationTriggerConfig): Promise<DelegationDecision | null>;
|
|
24
|
+
/**
|
|
25
|
+
* Validate assessment is still valid
|
|
26
|
+
*/
|
|
27
|
+
export declare function isAssessmentStale(decision: DelegationDecision, currentFacts: ScopeFacts, originalFacts: ScopeFacts): boolean;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation Assessor
|
|
3
|
+
*
|
|
4
|
+
* Assesses whether work should be delegated to sub-agents based on scope.
|
|
5
|
+
*/
|
|
6
|
+
import { shouldTriggerAssessment } from "./delegation.js";
|
|
7
|
+
/**
|
|
8
|
+
* Sub-agent extension names to check for
|
|
9
|
+
*/
|
|
10
|
+
const SUBAGENT_EXTENSIONS = [
|
|
11
|
+
"pi-subagents",
|
|
12
|
+
"@earendil-works/pi-subagents",
|
|
13
|
+
"subagent",
|
|
14
|
+
"spawn",
|
|
15
|
+
"delegate",
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Tool names that indicate sub-agent capability
|
|
19
|
+
*/
|
|
20
|
+
const SUBAGENT_TOOLS = [
|
|
21
|
+
"subagent",
|
|
22
|
+
"spawn",
|
|
23
|
+
"delegate",
|
|
24
|
+
"run_subagent",
|
|
25
|
+
"run_agent",
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Discover extension capabilities for delegation
|
|
29
|
+
*/
|
|
30
|
+
export async function discoverDelegationCapability(pi) {
|
|
31
|
+
// Get all available tools
|
|
32
|
+
const allTools = pi.getAllTools();
|
|
33
|
+
const toolNames = allTools.map((t) => t.name);
|
|
34
|
+
const activeTools = pi.getActiveTools();
|
|
35
|
+
// Check for sub-agent tools
|
|
36
|
+
const hasSubagentTool = SUBAGENT_TOOLS.some((tool) => toolNames.includes(tool) || activeTools.includes(tool));
|
|
37
|
+
// Check for subagent extension registration
|
|
38
|
+
// The extension might register tools under different names
|
|
39
|
+
const possibleCapabilities = [];
|
|
40
|
+
// Verify by attempting a capability check
|
|
41
|
+
// If subagent tools exist, assume capability
|
|
42
|
+
if (hasSubagentTool) {
|
|
43
|
+
return {
|
|
44
|
+
name: "subagent-extension",
|
|
45
|
+
supportsSubagents: true,
|
|
46
|
+
supportsWorkIsolation: true, // Assume based on tool presence
|
|
47
|
+
supportsCancellation: true,
|
|
48
|
+
availableTools: activeTools.filter((t) => SUBAGENT_TOOLS.some((st) => t.includes(st))),
|
|
49
|
+
verified: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// Check if pi-subagents skill is mentioned in available tools
|
|
53
|
+
const subagentMentioned = toolNames.some((t) => t.includes("subagent") || t.includes("spawn"));
|
|
54
|
+
if (subagentMentioned) {
|
|
55
|
+
return {
|
|
56
|
+
name: "pi-subagents",
|
|
57
|
+
supportsSubagents: true,
|
|
58
|
+
supportsWorkIsolation: true,
|
|
59
|
+
supportsCancellation: true,
|
|
60
|
+
availableTools: toolNames.filter((t) => t.includes("subagent")),
|
|
61
|
+
verified: false, // Not verified - just mentioned
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Estimate scope from file analysis
|
|
68
|
+
*/
|
|
69
|
+
export async function estimateScope(_pi, patterns) {
|
|
70
|
+
// TODO: Implement actual file discovery
|
|
71
|
+
// For now, return placeholder
|
|
72
|
+
return {
|
|
73
|
+
estimatedFiles: patterns.length,
|
|
74
|
+
observedFiles: 0,
|
|
75
|
+
estimatedCallSites: 0,
|
|
76
|
+
observedCallSites: 0,
|
|
77
|
+
independentComponents: 1,
|
|
78
|
+
tightlyCoupled: false,
|
|
79
|
+
isMechanical: true,
|
|
80
|
+
isComplex: false,
|
|
81
|
+
fileTypes: {},
|
|
82
|
+
fingerprint: "",
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Make deterministic assessment without Jev
|
|
87
|
+
*/
|
|
88
|
+
export function makeDeterministicAssessment(facts, capability) {
|
|
89
|
+
// No capability - must use single agent
|
|
90
|
+
if (!capability?.verified) {
|
|
91
|
+
return {
|
|
92
|
+
strategy: "unavailable",
|
|
93
|
+
reason: "No verified sub-agent capability available",
|
|
94
|
+
workGroups: [],
|
|
95
|
+
validationExpectations: "Parent handles all validation",
|
|
96
|
+
confidence: "high",
|
|
97
|
+
jevUsed: false,
|
|
98
|
+
reassessmentTriggers: ["Extension becomes available"],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// Small scope - single agent
|
|
102
|
+
if (facts.observedFiles < 5 && facts.observedCallSites < 20) {
|
|
103
|
+
return {
|
|
104
|
+
strategy: "single_agent",
|
|
105
|
+
reason: "Small scope - delegation overhead not justified",
|
|
106
|
+
workGroups: [],
|
|
107
|
+
validationExpectations: "Standard parent validation",
|
|
108
|
+
confidence: "high",
|
|
109
|
+
jevUsed: false,
|
|
110
|
+
reassessmentTriggers: [],
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
// Mechanical transformation with reliable script
|
|
114
|
+
if (facts.isMechanical && !facts.isComplex) {
|
|
115
|
+
return {
|
|
116
|
+
strategy: "script_only",
|
|
117
|
+
reason: "Mechanical transformation - script approach is reliable",
|
|
118
|
+
workGroups: [],
|
|
119
|
+
validationExpectations: "Script output validation + test run",
|
|
120
|
+
confidence: "high",
|
|
121
|
+
jevUsed: false,
|
|
122
|
+
reassessmentTriggers: ["Transformation proves unreliable"],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
// Multiple independent components
|
|
126
|
+
if (facts.independentComponents >= 2 && !facts.tightlyCoupled) {
|
|
127
|
+
const groups = partitionIntoGroups(facts);
|
|
128
|
+
return {
|
|
129
|
+
strategy: "delegate",
|
|
130
|
+
reason: `${facts.independentComponents} independent components - delegation recommended`,
|
|
131
|
+
workGroups: groups,
|
|
132
|
+
validationExpectations: "Each group validated independently, then integrated",
|
|
133
|
+
confidence: "medium",
|
|
134
|
+
jevUsed: false,
|
|
135
|
+
reassessmentTriggers: ["Scope expands significantly", "Component coupling discovered"],
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
// Tightly coupled - sequential or single agent
|
|
139
|
+
if (facts.tightlyCoupled) {
|
|
140
|
+
return {
|
|
141
|
+
strategy: "script_then_delegate",
|
|
142
|
+
reason: "Coupled components - script shared parts, delegate isolated changes",
|
|
143
|
+
workGroups: [],
|
|
144
|
+
validationExpectations: "Script validates shared API, delegate validates components",
|
|
145
|
+
confidence: "medium",
|
|
146
|
+
jevUsed: false,
|
|
147
|
+
reassessmentTriggers: ["Coupling reduced after refactoring"],
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
// Default - single agent with monitoring
|
|
151
|
+
return {
|
|
152
|
+
strategy: "single_agent",
|
|
153
|
+
reason: "Default to single agent for bounded scope",
|
|
154
|
+
workGroups: [],
|
|
155
|
+
validationExpectations: "Parent validates all changes",
|
|
156
|
+
confidence: "low",
|
|
157
|
+
jevUsed: false,
|
|
158
|
+
reassessmentTriggers: ["Scope exceeds threshold"],
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Partition work into groups
|
|
163
|
+
*/
|
|
164
|
+
function partitionIntoGroups(facts) {
|
|
165
|
+
const groups = [];
|
|
166
|
+
const filesPerGroup = Math.ceil(facts.observedFiles / facts.independentComponents);
|
|
167
|
+
for (let i = 0; i < facts.independentComponents; i++) {
|
|
168
|
+
groups.push({
|
|
169
|
+
groupId: `group-${i + 1}`,
|
|
170
|
+
description: `Component ${i + 1} of ${facts.independentComponents}`,
|
|
171
|
+
ownedPaths: [], // TODO: Populate with actual files
|
|
172
|
+
isMechanical: facts.isMechanical,
|
|
173
|
+
status: "pending",
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return groups;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Assess delegation need
|
|
180
|
+
*/
|
|
181
|
+
export async function assessDelegation(pi, facts, config = { minFiles: 10, minCallSites: 50, minIndependentComponents: 2, assessOnDiscovery: true }) {
|
|
182
|
+
// Check if assessment should trigger
|
|
183
|
+
if (!shouldTriggerAssessment(facts, config)) {
|
|
184
|
+
return null; // No assessment needed
|
|
185
|
+
}
|
|
186
|
+
// Discover capability
|
|
187
|
+
const capability = await discoverDelegationCapability(pi);
|
|
188
|
+
// Make deterministic assessment
|
|
189
|
+
return makeDeterministicAssessment(facts, capability);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Validate assessment is still valid
|
|
193
|
+
*/
|
|
194
|
+
export function isAssessmentStale(decision, currentFacts, originalFacts) {
|
|
195
|
+
// Scope significantly expanded
|
|
196
|
+
if (currentFacts.observedFiles > originalFacts.observedFiles * 1.5) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
// New coupling discovered
|
|
200
|
+
if (currentFacts.tightlyCoupled && !originalFacts.tightlyCoupled) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
// Reassessment triggers
|
|
204
|
+
return decision.reassessmentTriggers.some((trigger) => {
|
|
205
|
+
if (trigger.includes("scope expands")) {
|
|
206
|
+
return currentFacts.observedFiles > originalFacts.observedFiles * 1.5;
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
});
|
|
210
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation Assessment Types
|
|
3
|
+
*
|
|
4
|
+
* Types for consistent delegation assessment for large refactors.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Scope estimation for a refactoring task
|
|
8
|
+
*/
|
|
9
|
+
export interface ScopeFacts {
|
|
10
|
+
/** Estimated number of relevant files affected */
|
|
11
|
+
estimatedFiles: number;
|
|
12
|
+
/** Actual observed number of files (after scanning) */
|
|
13
|
+
observedFiles: number;
|
|
14
|
+
/** Estimated number of call sites/changes */
|
|
15
|
+
estimatedCallSites: number;
|
|
16
|
+
/** Actual observed call sites */
|
|
17
|
+
observedCallSites: number;
|
|
18
|
+
/** Number of independent components/groups */
|
|
19
|
+
independentComponents: number;
|
|
20
|
+
/** Whether changes are tightly coupled (shared APIs) */
|
|
21
|
+
tightlyCoupled: boolean;
|
|
22
|
+
/** Whether transformation is mechanical (safe for scripts) */
|
|
23
|
+
isMechanical: boolean;
|
|
24
|
+
/** Whether transformation is complex (needs reasoning) */
|
|
25
|
+
isComplex: boolean;
|
|
26
|
+
/** File type breakdown */
|
|
27
|
+
fileTypes: Record<string, number>;
|
|
28
|
+
/** Scope fingerprint for change detection */
|
|
29
|
+
fingerprint: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Delegation strategy decision
|
|
33
|
+
*/
|
|
34
|
+
export type DelegationStrategy = "delegate" | "script_then_delegate" | "script_only" | "single_agent" | "unavailable";
|
|
35
|
+
/**
|
|
36
|
+
* Work group for delegation
|
|
37
|
+
*/
|
|
38
|
+
export interface WorkGroup {
|
|
39
|
+
/** Unique group ID */
|
|
40
|
+
groupId: string;
|
|
41
|
+
/** Human-readable description */
|
|
42
|
+
description: string;
|
|
43
|
+
/** Files owned by this group */
|
|
44
|
+
ownedPaths: string[];
|
|
45
|
+
/** Whether this group is mechanical (script-friendly) */
|
|
46
|
+
isMechanical: boolean;
|
|
47
|
+
/** Assigned child agent ID (if delegated) */
|
|
48
|
+
childId?: string;
|
|
49
|
+
/** Status of this group */
|
|
50
|
+
status: "pending" | "dispatched" | "running" | "completed" | "failed" | "cancelled";
|
|
51
|
+
/** Validation evidence */
|
|
52
|
+
validation?: {
|
|
53
|
+
passed: boolean;
|
|
54
|
+
details: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Delegation decision from Jev or fallback
|
|
59
|
+
*/
|
|
60
|
+
export interface DelegationDecision {
|
|
61
|
+
/** Strategy selected */
|
|
62
|
+
strategy: DelegationStrategy;
|
|
63
|
+
/** Reason for the decision */
|
|
64
|
+
reason: string;
|
|
65
|
+
/** Proposed work groups (for delegate strategies) */
|
|
66
|
+
workGroups: WorkGroup[];
|
|
67
|
+
/** Validation expectations */
|
|
68
|
+
validationExpectations: string;
|
|
69
|
+
/** Confidence level */
|
|
70
|
+
confidence: "high" | "medium" | "low";
|
|
71
|
+
/** Whether Jev was used */
|
|
72
|
+
jevUsed: boolean;
|
|
73
|
+
/** Reassessment triggers */
|
|
74
|
+
reassessmentTriggers: string[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Delegation receipt for persistence
|
|
78
|
+
*/
|
|
79
|
+
export interface DelegationReceipt {
|
|
80
|
+
/** Version for schema compatibility */
|
|
81
|
+
version: number;
|
|
82
|
+
/** Workspace canonical path */
|
|
83
|
+
workspacePath: string;
|
|
84
|
+
/** Session ID */
|
|
85
|
+
sessionId: string;
|
|
86
|
+
/** Parent task ID */
|
|
87
|
+
parentTaskId: string;
|
|
88
|
+
/** Scope fingerprint */
|
|
89
|
+
scopeFingerprint: string;
|
|
90
|
+
/** Decision made */
|
|
91
|
+
decision: DelegationDecision;
|
|
92
|
+
/** Created timestamp */
|
|
93
|
+
createdAt: number;
|
|
94
|
+
/** Last updated timestamp */
|
|
95
|
+
updatedAt: number;
|
|
96
|
+
/** Status */
|
|
97
|
+
status: "assessing" | "in_progress" | "completed" | "failed" | "cancelled";
|
|
98
|
+
/** Active child IDs */
|
|
99
|
+
childIds: string[];
|
|
100
|
+
/** Outstanding validation items */
|
|
101
|
+
pendingValidation: string[];
|
|
102
|
+
/** User constraints (e.g., no delegation) */
|
|
103
|
+
userConstraints: string[];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Delegation assessment trigger config
|
|
107
|
+
*/
|
|
108
|
+
export interface DelegationTriggerConfig {
|
|
109
|
+
/** Minimum files to trigger assessment */
|
|
110
|
+
minFiles: number;
|
|
111
|
+
/** Minimum call sites to trigger assessment */
|
|
112
|
+
minCallSites: number;
|
|
113
|
+
/** Minimum independent components to suggest delegation */
|
|
114
|
+
minIndependentComponents: number;
|
|
115
|
+
/** Whether to assess on scope discovery vs mutation */
|
|
116
|
+
assessOnDiscovery: boolean;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Default trigger config
|
|
120
|
+
*/
|
|
121
|
+
export declare const DEFAULT_DELEGATION_TRIGGERS: DelegationTriggerConfig;
|
|
122
|
+
/**
|
|
123
|
+
* Extension capability for delegation
|
|
124
|
+
*/
|
|
125
|
+
export interface ExtensionCapability {
|
|
126
|
+
/** Extension name */
|
|
127
|
+
name: string;
|
|
128
|
+
/** Whether it supports sub-agents */
|
|
129
|
+
supportsSubagents: boolean;
|
|
130
|
+
/** Whether it supports work isolation */
|
|
131
|
+
supportsWorkIsolation: boolean;
|
|
132
|
+
/** Whether it supports cancellation */
|
|
133
|
+
supportsCancellation: boolean;
|
|
134
|
+
/** Supported tool names */
|
|
135
|
+
availableTools: string[];
|
|
136
|
+
/** Verified working */
|
|
137
|
+
verified: boolean;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Check if delegation should be triggered
|
|
141
|
+
*/
|
|
142
|
+
export declare function shouldTriggerAssessment(facts: ScopeFacts, config?: DelegationTriggerConfig): boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation Assessment Types
|
|
3
|
+
*
|
|
4
|
+
* Types for consistent delegation assessment for large refactors.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Default trigger config
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_DELEGATION_TRIGGERS = {
|
|
10
|
+
minFiles: 10,
|
|
11
|
+
minCallSites: 50,
|
|
12
|
+
minIndependentComponents: 2,
|
|
13
|
+
assessOnDiscovery: true,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Check if delegation should be triggered
|
|
17
|
+
*/
|
|
18
|
+
export function shouldTriggerAssessment(facts, config = DEFAULT_DELEGATION_TRIGGERS) {
|
|
19
|
+
// Check file count
|
|
20
|
+
if (facts.observedFiles >= config.minFiles)
|
|
21
|
+
return true;
|
|
22
|
+
if (facts.estimatedFiles >= config.minFiles)
|
|
23
|
+
return true;
|
|
24
|
+
// Check call sites
|
|
25
|
+
if (facts.observedCallSites >= config.minCallSites)
|
|
26
|
+
return true;
|
|
27
|
+
if (facts.estimatedCallSites >= config.minCallSites)
|
|
28
|
+
return true;
|
|
29
|
+
// Check independent components
|
|
30
|
+
if (facts.independentComponents >= config.minIndependentComponents)
|
|
31
|
+
return true;
|
|
32
|
+
return false;
|
|
33
|
+
}
|