@ddse/acm-aicoder 0.5.0 → 0.5.2
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/src/capability-map.d.ts +4 -0
- package/dist/src/capability-map.d.ts.map +1 -0
- package/dist/src/capability-map.js +289 -0
- package/dist/src/capability-map.js.map +1 -0
- package/dist/src/registries.d.ts +3 -0
- package/dist/src/registries.d.ts.map +1 -1
- package/dist/src/registries.js +11 -0
- package/dist/src/registries.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -7
- package/.aicoder/index.json +0 -304
- package/AICODER_IMPLEMENTATION_PLAN_PHASE2.md +0 -284
- package/bin/interactive.tsx +0 -232
- package/docs/AICODER.png +0 -0
- package/docs/INTERACTIVE_CLI_GUIDE.md +0 -201
- package/docs/TUI_MOCKUP.md +0 -180
- package/src/config/providers.ts +0 -174
- package/src/config/session.ts +0 -143
- package/src/context/bm25.ts +0 -173
- package/src/context/code-search.ts +0 -188
- package/src/context/context-pack.ts +0 -133
- package/src/context/dependency-mapper.ts +0 -72
- package/src/context/index.ts +0 -8
- package/src/context/symbol-extractor.ts +0 -149
- package/src/context/test-mapper.ts +0 -77
- package/src/context/types.ts +0 -69
- package/src/context/workspace-indexer.ts +0 -249
- package/src/index.ts +0 -5
- package/src/registries.ts +0 -118
- package/src/runtime/budget-manager.ts +0 -118
- package/src/runtime/interactive-runtime.ts +0 -423
- package/src/tasks-v2/analysis-tasks.ts +0 -311
- package/src/tasks-v2/developer-tasks.ts +0 -437
- package/src/tasks-v2/index.ts +0 -3
- package/src/tools-v2/edit-tools.ts +0 -153
- package/src/tools-v2/index.ts +0 -6
- package/src/tools-v2/read-tools.ts +0 -286
- package/src/tools-v2/search-tools.ts +0 -175
- package/src/tools-v2/test-tools.ts +0 -147
- package/src/tools-v2/workspace-context.ts +0 -428
- package/src/ui/App.tsx +0 -392
- package/src/ui/components/ChatPane.tsx +0 -84
- package/src/ui/components/EventsPane.tsx +0 -81
- package/src/ui/components/GoalsTasksPane.tsx +0 -149
- package/src/ui/store.ts +0 -362
- package/tests/integration.test.ts +0 -537
- package/tsconfig.json +0 -22
package/src/ui/store.ts
DELETED
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
// Application state store for the interactive TUI
|
|
2
|
-
// Manages chat messages, tasks, events, and budget state
|
|
3
|
-
|
|
4
|
-
import { EventEmitter } from 'events';
|
|
5
|
-
import type { Plan, Goal, Context } from '@ddse/acm-sdk';
|
|
6
|
-
import type { TaskNarrative } from '@ddse/acm-runtime';
|
|
7
|
-
import type { BudgetStatus } from '../runtime/budget-manager.js';
|
|
8
|
-
|
|
9
|
-
export type MessageRole = 'user' | 'planner' | 'nucleus' | 'system';
|
|
10
|
-
|
|
11
|
-
export interface ChatMessage {
|
|
12
|
-
id: string;
|
|
13
|
-
role: MessageRole;
|
|
14
|
-
content: string;
|
|
15
|
-
timestamp: number;
|
|
16
|
-
streaming?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type TaskStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'retrying';
|
|
20
|
-
|
|
21
|
-
export interface TaskState {
|
|
22
|
-
id: string;
|
|
23
|
-
name: string;
|
|
24
|
-
title?: string;
|
|
25
|
-
objective?: string;
|
|
26
|
-
successCriteria?: string[];
|
|
27
|
-
status: TaskStatus;
|
|
28
|
-
progress?: number;
|
|
29
|
-
error?: string;
|
|
30
|
-
attempt?: number;
|
|
31
|
-
maxAttempts?: number;
|
|
32
|
-
outputSummary?: string;
|
|
33
|
-
rawOutput?: unknown;
|
|
34
|
-
narrative?: TaskNarrative;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface EventEntry {
|
|
38
|
-
id: string;
|
|
39
|
-
type: string;
|
|
40
|
-
timestamp: number;
|
|
41
|
-
data: any;
|
|
42
|
-
color?: 'green' | 'yellow' | 'red' | 'blue' | 'gray';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface AppState {
|
|
46
|
-
// Chat state
|
|
47
|
-
messages: ChatMessage[];
|
|
48
|
-
showReasoning: boolean;
|
|
49
|
-
|
|
50
|
-
// Goal/Plan state
|
|
51
|
-
currentGoal?: Goal;
|
|
52
|
-
currentContext?: Context;
|
|
53
|
-
currentPlan?: Plan;
|
|
54
|
-
tasks: TaskState[];
|
|
55
|
-
goalSummary?: string;
|
|
56
|
-
|
|
57
|
-
// Budget state
|
|
58
|
-
budgetStatus?: BudgetStatus;
|
|
59
|
-
|
|
60
|
-
// Event stream
|
|
61
|
-
events: EventEntry[];
|
|
62
|
-
taskOutputs: Record<string, TaskState['rawOutput']>;
|
|
63
|
-
|
|
64
|
-
// UI state
|
|
65
|
-
inputText: string;
|
|
66
|
-
isProcessing: boolean;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export class AppStore extends EventEmitter {
|
|
70
|
-
private state: AppState = {
|
|
71
|
-
messages: [],
|
|
72
|
-
showReasoning: true,
|
|
73
|
-
tasks: [],
|
|
74
|
-
events: [],
|
|
75
|
-
taskOutputs: {},
|
|
76
|
-
inputText: '',
|
|
77
|
-
isProcessing: false,
|
|
78
|
-
goalSummary: undefined,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
getState(): AppState {
|
|
82
|
-
return {
|
|
83
|
-
...this.state,
|
|
84
|
-
messages: [...this.state.messages],
|
|
85
|
-
showReasoning: this.state.showReasoning,
|
|
86
|
-
tasks: this.state.tasks.map(task => ({ ...task })),
|
|
87
|
-
events: [...this.state.events],
|
|
88
|
-
taskOutputs: { ...this.state.taskOutputs },
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Chat methods
|
|
93
|
-
addMessage(role: MessageRole, content: string, streaming = false): string {
|
|
94
|
-
const id = `msg-${Date.now()}-${Math.random()}`;
|
|
95
|
-
const message: ChatMessage = {
|
|
96
|
-
id,
|
|
97
|
-
role,
|
|
98
|
-
content,
|
|
99
|
-
timestamp: Date.now(),
|
|
100
|
-
streaming,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
this.state.messages.push(message);
|
|
104
|
-
this.emit('update', this.state);
|
|
105
|
-
return id;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
isReasoningVisible(): boolean {
|
|
109
|
-
return this.state.showReasoning;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
setReasoningVisible(visible: boolean): void {
|
|
113
|
-
if (this.state.showReasoning !== visible) {
|
|
114
|
-
this.state.showReasoning = visible;
|
|
115
|
-
this.emit('update', this.state);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
toggleReasoningVisible(): boolean {
|
|
120
|
-
this.state.showReasoning = !this.state.showReasoning;
|
|
121
|
-
this.emit('update', this.state);
|
|
122
|
-
return this.state.showReasoning;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
updateMessage(id: string, content: string, streaming = false): void {
|
|
126
|
-
const message = this.state.messages.find(m => m.id === id);
|
|
127
|
-
if (message) {
|
|
128
|
-
message.content = content;
|
|
129
|
-
message.streaming = streaming;
|
|
130
|
-
this.emit('update', this.state);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
appendToMessage(id: string, delta: string): void {
|
|
135
|
-
const message = this.state.messages.find(m => m.id === id);
|
|
136
|
-
if (message) {
|
|
137
|
-
message.content += delta;
|
|
138
|
-
this.emit('update', this.state);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Goal/Plan methods
|
|
143
|
-
setGoal(goal: Goal, context: Context, plan: Plan): void {
|
|
144
|
-
this.state.currentGoal = goal;
|
|
145
|
-
this.state.currentContext = context;
|
|
146
|
-
this.state.currentPlan = plan;
|
|
147
|
-
|
|
148
|
-
// Initialize tasks from plan
|
|
149
|
-
this.state.tasks = plan.tasks.map((task, idx) => {
|
|
150
|
-
const taskId = (task as any).id || task.capability || task.capabilityRef || `task-${idx}`;
|
|
151
|
-
const displayName =
|
|
152
|
-
(task as any).name || task.capability || task.capabilityRef || `Task ${idx + 1}`;
|
|
153
|
-
|
|
154
|
-
return {
|
|
155
|
-
id: String(taskId),
|
|
156
|
-
name: String(displayName),
|
|
157
|
-
title: (task as any).title ?? displayName,
|
|
158
|
-
objective: (task as any).objective,
|
|
159
|
-
successCriteria: Array.isArray((task as any).successCriteria)
|
|
160
|
-
? (task as any).successCriteria
|
|
161
|
-
: undefined,
|
|
162
|
-
status: 'pending' as TaskStatus,
|
|
163
|
-
};
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
this.state.taskOutputs = {};
|
|
167
|
-
this.state.goalSummary = undefined;
|
|
168
|
-
|
|
169
|
-
this.emit('update', this.state);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
updateTaskStatus(taskId: string, status: TaskStatus, progress?: number, error?: string): void {
|
|
173
|
-
const task = this.state.tasks.find(t => t.id === taskId);
|
|
174
|
-
if (task) {
|
|
175
|
-
task.status = status;
|
|
176
|
-
if (progress !== undefined) task.progress = progress;
|
|
177
|
-
if (error) task.error = error;
|
|
178
|
-
this.emit('update', this.state);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
setTaskRetry(taskId: string, attempt: number, maxAttempts: number): void {
|
|
183
|
-
const task = this.state.tasks.find(t => t.id === taskId);
|
|
184
|
-
if (task) {
|
|
185
|
-
task.attempt = attempt;
|
|
186
|
-
task.maxAttempts = maxAttempts;
|
|
187
|
-
task.status = 'retrying';
|
|
188
|
-
this.emit('update', this.state);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Budget methods
|
|
193
|
-
updateBudgetStatus(status: BudgetStatus): void {
|
|
194
|
-
this.state.budgetStatus = status;
|
|
195
|
-
this.emit('update', this.state);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Event methods
|
|
199
|
-
addEvent(type: string, data: any, color?: EventEntry['color']): void {
|
|
200
|
-
const event: EventEntry = {
|
|
201
|
-
id: `event-${Date.now()}-${Math.random()}`,
|
|
202
|
-
type,
|
|
203
|
-
timestamp: Date.now(),
|
|
204
|
-
data,
|
|
205
|
-
color,
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
this.state.events.push(event);
|
|
209
|
-
|
|
210
|
-
// Keep only last 100 events to prevent memory bloat
|
|
211
|
-
if (this.state.events.length > 100) {
|
|
212
|
-
this.state.events = this.state.events.slice(-100);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
this.emit('update', this.state);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// UI methods
|
|
219
|
-
setInputText(text: string): void {
|
|
220
|
-
this.state.inputText = text;
|
|
221
|
-
this.emit('update', this.state);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
setProcessing(isProcessing: boolean): void {
|
|
225
|
-
this.state.isProcessing = isProcessing;
|
|
226
|
-
this.emit('update', this.state);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// Lifecycle methods
|
|
230
|
-
clearGoal(): void {
|
|
231
|
-
this.state.currentGoal = undefined;
|
|
232
|
-
this.state.currentContext = undefined;
|
|
233
|
-
this.state.currentPlan = undefined;
|
|
234
|
-
this.state.tasks = [];
|
|
235
|
-
this.state.taskOutputs = {};
|
|
236
|
-
this.state.goalSummary = undefined;
|
|
237
|
-
this.emit('update', this.state);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
reset(): void {
|
|
241
|
-
this.state = {
|
|
242
|
-
messages: [
|
|
243
|
-
{
|
|
244
|
-
id: 'welcome',
|
|
245
|
-
role: 'system',
|
|
246
|
-
content: 'Session reset. Ready for new goal.',
|
|
247
|
-
timestamp: Date.now(),
|
|
248
|
-
}
|
|
249
|
-
],
|
|
250
|
-
showReasoning: true,
|
|
251
|
-
tasks: [],
|
|
252
|
-
events: [],
|
|
253
|
-
taskOutputs: {},
|
|
254
|
-
inputText: '',
|
|
255
|
-
isProcessing: false,
|
|
256
|
-
goalSummary: undefined,
|
|
257
|
-
};
|
|
258
|
-
this.emit('update', this.state);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
recordTaskOutput(taskId: string, output: unknown, narrative?: TaskNarrative): void {
|
|
262
|
-
this.state.taskOutputs[taskId] = output;
|
|
263
|
-
|
|
264
|
-
const task = this.state.tasks.find(t => t.id === taskId);
|
|
265
|
-
if (task) {
|
|
266
|
-
task.rawOutput = output;
|
|
267
|
-
task.outputSummary = this.formatOutputSummary(output);
|
|
268
|
-
task.narrative = narrative;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
this.emit('update', this.state);
|
|
272
|
-
|
|
273
|
-
const label = task?.name || taskId;
|
|
274
|
-
const summary = task?.outputSummary ?? this.formatOutputSummary(output);
|
|
275
|
-
const reasoning = narrative?.reasoning?.length ? narrative.reasoning.join(' ') : undefined;
|
|
276
|
-
|
|
277
|
-
if (summary || reasoning) {
|
|
278
|
-
const lines: string[] = [];
|
|
279
|
-
if (summary) {
|
|
280
|
-
lines.push(summary);
|
|
281
|
-
}
|
|
282
|
-
if (reasoning) {
|
|
283
|
-
lines.push(`Narrative: ${reasoning}`);
|
|
284
|
-
}
|
|
285
|
-
if (narrative?.postcheck && narrative.postcheck.status !== 'COMPLETE') {
|
|
286
|
-
lines.push(`Postcheck: ${narrative.postcheck.status}${narrative.postcheck.reason ? ` (${narrative.postcheck.reason})` : ''}`);
|
|
287
|
-
}
|
|
288
|
-
this.addMessage('system', `Task "${label}" output:\n${lines.join('\n')}`);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
setGoalSummary(summary?: string): void {
|
|
293
|
-
this.state.goalSummary = summary;
|
|
294
|
-
this.emit('update', this.state);
|
|
295
|
-
if (summary) {
|
|
296
|
-
this.addMessage('system', `Goal summary:\n${summary}`);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
private formatOutputSummary(output: unknown): string {
|
|
301
|
-
if (output === undefined || output === null) {
|
|
302
|
-
return 'No output produced.';
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (typeof output === 'string') {
|
|
306
|
-
const trimmed = output.trim();
|
|
307
|
-
return trimmed.length > 0 ? this.truncate(trimmed) : 'Output was an empty string.';
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (typeof output === 'number' || typeof output === 'boolean') {
|
|
311
|
-
return String(output);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (Array.isArray(output)) {
|
|
315
|
-
if (output.length === 0) {
|
|
316
|
-
return 'Output array was empty.';
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
const preview = output
|
|
320
|
-
.slice(0, 3)
|
|
321
|
-
.map(item => this.previewValue(item))
|
|
322
|
-
.join('\n');
|
|
323
|
-
|
|
324
|
-
const suffix = output.length > 3 ? `\n… ${output.length - 3} more item(s)` : '';
|
|
325
|
-
return this.truncate(preview + suffix);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
if (typeof output === 'object') {
|
|
329
|
-
return this.truncate(this.previewValue(output));
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
return this.truncate(String(output));
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
private previewValue(value: unknown): string {
|
|
336
|
-
if (value === null) return 'null';
|
|
337
|
-
if (typeof value === 'string') return value.trim() || '""';
|
|
338
|
-
if (typeof value === 'number' || typeof value === 'boolean') return String(value);
|
|
339
|
-
|
|
340
|
-
if (Array.isArray(value)) {
|
|
341
|
-
const items = value.slice(0, 3).map(v => this.previewValue(v)).join(', ');
|
|
342
|
-
return `[${items}${value.length > 3 ? ', …' : ''}]`;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (typeof value === 'object') {
|
|
346
|
-
const entries = Object.entries(value as Record<string, unknown>);
|
|
347
|
-
const preview = entries
|
|
348
|
-
.slice(0, 4)
|
|
349
|
-
.map(([key, val]) => `${key}: ${this.previewValue(val)}`)
|
|
350
|
-
.join(', ');
|
|
351
|
-
const suffix = entries.length > 4 ? ', …' : '';
|
|
352
|
-
return `{ ${preview}${suffix} }`;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return String(value);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
private truncate(value: string, max = 400): string {
|
|
359
|
-
if (value.length <= max) return value;
|
|
360
|
-
return `${value.slice(0, max - 1)}…`;
|
|
361
|
-
}
|
|
362
|
-
}
|