@causyne/agent 1.20.116 → 1.20.117
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/package.json +1 -1
- package/src/agentLoop.js +81 -31
- package/src/agentLoop.ts +82 -33
- package/src/browser/causyneBrowser.js +30 -7
- package/src/browser/causyneBrowser.ts +29 -7
- package/src/cliMode.js +5 -1
- package/src/memory/scopedFacts.js +171 -0
- package/src/memory/scopedFacts.ts +214 -0
- package/src/memory.d.ts +13 -1
- package/src/memory.js +9 -12
- package/src/perception.js +124 -3
- package/src/perception.ts +128 -4
- package/src/planCache.js +17 -3
- package/src/planCache.ts +17 -3
- package/src/smartToolsUse.js +4 -5
- package/src/smartToolsUse.ts +4 -6
- package/src/taskShape.js +49 -7
- package/src/taskShape.ts +55 -7
- package/src/toolPacks.js +27 -5
- package/src/toolPacks.ts +32 -5
- package/src/tools/memoryWrite.js +8 -10
- package/src/tools/memoryWrite.ts +13 -11
- package/src/tui/chatRenderer.js +4 -1
- package/src/tui/codeProgress.js +3 -2
- package/src/tui/codeProgress.ts +3 -2
- package/src/tui/codeStreamRenderer.js +41 -15
- package/src/tui/codeStreamRenderer.ts +40 -15
- package/src/tui/keys.js +3 -1
- package/src/tui/prompt.js +24 -0
- package/src/tui/scrollInteraction.js +2 -2
- package/src/tui/scrollInteraction.ts +2 -2
- package/src/tui/stageSurface.js +114 -4
- package/src/tui/turnRail.js +21 -14
- package/src/tui/turnRail.ts +19 -14
- package/src/tui/usageCard.js +89 -68
- package/src/tui/usageCard.ts +98 -91
- package/src/types/contracts.ts +3 -0
package/src/taskShape.ts
CHANGED
|
@@ -109,6 +109,19 @@ const ARCHETYPES: Record<string, ArchetypeDefinition> = {
|
|
|
109
109
|
{ name: 'Report', tools: [], note: 'Answer concisely and cite exact file paths or URLs. Do not modify anything unless asked.' }
|
|
110
110
|
]
|
|
111
111
|
},
|
|
112
|
+
modify_repo: {
|
|
113
|
+
label: 'Inspect and update an existing project or build release artifact',
|
|
114
|
+
match: {
|
|
115
|
+
strong: ['bump', 'version code', 'version name', 'aab', 'apk', 'release', 'export', 'synchronize', 'sync', 'upgrade', 'migrate', 'rebuild'],
|
|
116
|
+
weak: ['version', 'bundle', 'existing', 'repo', 'repository', 'docs']
|
|
117
|
+
},
|
|
118
|
+
phases: [
|
|
119
|
+
{ name: 'Orient in docs and structure', tools: ['fs_read', 'fs_list'], note: 'Read the workspace README, docs/ guides (e.g. ANDROID_RELEASE.md, ENGINEERING.md), and build scripts/manifests FIRST to follow the repository conventions.' },
|
|
120
|
+
{ name: 'Apply targeted updates', tools: ['fs_read', 'fs_edit', 'MultiEdit'], note: 'Modify only the exact configuration, version fields, or source files required by the user request.' },
|
|
121
|
+
{ name: 'Run documented build', tools: ['sysRun'], note: 'Execute the project’s documented build/export command for the requested deliverable only. Do not build unrelated web or side targets.' },
|
|
122
|
+
{ name: 'Verify artifact', tools: ['sysRun', 'fs_read'], note: 'Verify the exact produced output (version, signature, alignment, tests) before reporting.' }
|
|
123
|
+
]
|
|
124
|
+
},
|
|
112
125
|
maintain: {
|
|
113
126
|
label: 'Operate on files, processes or the machine itself',
|
|
114
127
|
match: {
|
|
@@ -153,6 +166,12 @@ function scoreSignals(text: string, signals: SignalSet): { score: number; hits:
|
|
|
153
166
|
return { score, hits };
|
|
154
167
|
}
|
|
155
168
|
|
|
169
|
+
function isPureGreeting(prompt: string): boolean {
|
|
170
|
+
const cleaned = String(prompt || '').trim().toLowerCase().replace(/[!?.]+$/g, '');
|
|
171
|
+
if (!cleaned) return false;
|
|
172
|
+
return /^(?:hi+|hello+|hey+|yo+|sup|greetings|good\s+(?:morning|afternoon|evening)|thanks|thank\s+you|ok(?:ay)?)$/.test(cleaned);
|
|
173
|
+
}
|
|
174
|
+
|
|
156
175
|
/**
|
|
157
176
|
* Analyse a request into the shape of the work it implies.
|
|
158
177
|
*
|
|
@@ -160,11 +179,13 @@ function scoreSignals(text: string, signals: SignalSet): { score: number; hits:
|
|
|
160
179
|
export function analyzeTask(prompt: string, workspaceContext: WorkspaceContext | null = null): TaskShape {
|
|
161
180
|
const rawPrompt = String(prompt || '');
|
|
162
181
|
const pureSkillLookup = isPureSkillOrCapabilityLookup(rawPrompt);
|
|
182
|
+
const pureGreeting = !pureSkillLookup && isPureGreeting(rawPrompt);
|
|
183
|
+
const lightweightLookup = pureSkillLookup || pureGreeting;
|
|
163
184
|
const text = (pureSkillLookup ? redactSkillAndQueryLiterals(rawPrompt) : rawPrompt).toLowerCase();
|
|
164
185
|
|
|
165
186
|
// Which capability packs are worth their token cost for this request.
|
|
166
187
|
const packScores: TaskPackScore[] = [];
|
|
167
|
-
if (!
|
|
188
|
+
if (!lightweightLookup) {
|
|
168
189
|
for (const packName of Object.keys(PACK_SIGNALS)) {
|
|
169
190
|
const signals = PACK_SIGNALS[packName];
|
|
170
191
|
if (!signals) continue;
|
|
@@ -178,12 +199,14 @@ export function analyzeTask(prompt: string, workspaceContext: WorkspaceContext |
|
|
|
178
199
|
// Workspace evidence outranks keywords: a Godot project on disk is far more
|
|
179
200
|
// reliable than any phrasing in the prompt. Pure skill/capability lookups
|
|
180
201
|
// stay lightweight and never preload workspace app packs.
|
|
181
|
-
if (workspaceContext && !
|
|
202
|
+
if (workspaceContext && !lightweightLookup) {
|
|
182
203
|
const signals = [
|
|
183
204
|
workspaceContext.framework,
|
|
184
205
|
workspaceContext.projectType,
|
|
185
206
|
workspaceContext.designSystem,
|
|
186
|
-
Array.isArray(workspaceContext.keyFiles) ? workspaceContext.keyFiles.join(' ') : ''
|
|
207
|
+
Array.isArray(workspaceContext.keyFiles) ? workspaceContext.keyFiles.join(' ') : '',
|
|
208
|
+
Array.isArray(workspaceContext.subprojectStacks) ? workspaceContext.subprojectStacks.join(' ') : '',
|
|
209
|
+
Array.isArray(workspaceContext.buildFiles) ? workspaceContext.buildFiles.join(' ') : ''
|
|
187
210
|
].filter(Boolean).join(' ').toLowerCase();
|
|
188
211
|
|
|
189
212
|
const bump = (name: string, amount: number): void => {
|
|
@@ -192,8 +215,14 @@ export function analyzeTask(prompt: string, workspaceContext: WorkspaceContext |
|
|
|
192
215
|
else packScores.push({ name, score: amount });
|
|
193
216
|
};
|
|
194
217
|
|
|
195
|
-
|
|
196
|
-
|
|
218
|
+
const hasGameProject = /godot|project\.godot|unity|\.tscn/.test(signals);
|
|
219
|
+
const hasExplicitWebFramework = /\b(react|vue|svelte|next|nuxt|astro|angular|tailwind|vite)\b/.test(signals);
|
|
220
|
+
const explicitNonWebTarget = /\b(aab|apk|gradle|android|godot|export_presets|tscn|gdscript|xcode|ipa|ios|rust|cargo)\b/.test(text);
|
|
221
|
+
const hasPromptWebSignal = /\b(web|website|html|css|browser|frontend|page|ui|dom|react|vue|svelte|vite|next|playwright|lighthouse|localhost)\b/.test(text);
|
|
222
|
+
if (hasGameProject) bump('game', 5);
|
|
223
|
+
if (!explicitNonWebTarget && (hasExplicitWebFramework || (!hasGameProject && /index\.html/.test(signals)) || (hasGameProject && /index\.html/.test(signals) && hasPromptWebSignal))) {
|
|
224
|
+
bump('web', 4);
|
|
225
|
+
}
|
|
197
226
|
}
|
|
198
227
|
|
|
199
228
|
packScores.sort((a, b) => b.score - a.score);
|
|
@@ -222,12 +251,31 @@ export function analyzeTask(prompt: string, workspaceContext: WorkspaceContext |
|
|
|
222
251
|
bestScore = integrationScore;
|
|
223
252
|
}
|
|
224
253
|
|
|
225
|
-
|
|
254
|
+
const hasExistingRepo = Boolean(
|
|
255
|
+
workspaceContext && (
|
|
256
|
+
(Array.isArray(workspaceContext.keyFiles) && workspaceContext.keyFiles.length > 0)
|
|
257
|
+
|| (Array.isArray(workspaceContext.buildFiles) && workspaceContext.buildFiles.length > 0)
|
|
258
|
+
|| (Array.isArray(workspaceContext.docFiles) && workspaceContext.docFiles.length > 0)
|
|
259
|
+
|| (Array.isArray(workspaceContext.subprojectStacks) && workspaceContext.subprojectStacks.length > 0)
|
|
260
|
+
|| (workspaceContext.framework && !/^(?:none|unknown)$/i.test(String(workspaceContext.framework)))
|
|
261
|
+
|| (workspaceContext.projectType && !/^(?:none|unknown)$/i.test(String(workspaceContext.projectType)))
|
|
262
|
+
)
|
|
263
|
+
);
|
|
264
|
+
const explicitGreenfield = /\b(?:from\s+scratch|new\s+app(?:lication)?|new\s+project|greenfield|scaffold)\b/.test(text);
|
|
265
|
+
const explicitRepoReleaseOrModify = /\b(?:aab|apk|gradle|android|release|bump|versioncode|version|export|rebuild|update|upgrade|modify|extend|add\s+feature|existing|script)\b/.test(text);
|
|
266
|
+
if (!lightweightLookup && hasExistingRepo && (bestArchetype === 'build_app' || !bestArchetype) && !explicitGreenfield) {
|
|
267
|
+
if (bestArchetype !== 'build_app' || explicitRepoReleaseOrModify) {
|
|
268
|
+
bestArchetype = 'modify_repo';
|
|
269
|
+
bestScore = Math.max(bestScore, STRONG_WEIGHT);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (lightweightLookup) {
|
|
226
274
|
bestArchetype = 'research';
|
|
227
275
|
bestScore = Math.max(bestScore, STRONG_WEIGHT);
|
|
228
276
|
}
|
|
229
277
|
|
|
230
|
-
const archetype = bestArchetype || 'build_app';
|
|
278
|
+
const archetype = bestArchetype || (hasExistingRepo ? 'modify_repo' : 'build_app');
|
|
231
279
|
const confidence = bestScore >= 6 ? 'high' : (bestScore >= 3 ? 'medium' : 'low');
|
|
232
280
|
|
|
233
281
|
const definition = ARCHETYPES[archetype];
|
package/src/toolPacks.js
CHANGED
|
@@ -335,7 +335,9 @@ const WEB_INTENT = /\b(web|webpage|website|frontend|front-end|landing page|homep
|
|
|
335
335
|
const MEDIA_INTENT = /\b(image|images|picture|photo|photoshop|premiere|after\s*effects|illustrator|indesign|media\s*encoder|uxp|render|3d model|blender|animation|animate|video|movie|film|audio|sound|sfx|music|song|voice|tts|text.to.speech|narration|podcast|thumbnail|poster|illustration|logo)\b|\.(psd|prproj|aep|ai|indd|ccx)\b/i;
|
|
336
336
|
const SYSTEM_INTENT = /\b(process|processes|pid|kill|port|zip|unzip|tar|archive|compress|extract|clipboard|copy to clipboard|print|printer|open in browser|launch app|computer use|vision grounding|desktop vision|gui agent|coordinate click|desktop control)\b/i;
|
|
337
337
|
const ADVANCED_INTENT = /\b(pdf|document|proposal|screenplay|shotlist|shot list|voiceover|dubbing|forge a tool|custom tool|new tool|plugin|plugins|custom plugin|plugins? factory|python bridge|mcp|mcp server|subagent|sub-agent|parallel agent|swarm|ast|symbols|refactor across)\b/i;
|
|
338
|
-
const REVERSE_ENGINEERING_INTENT = /\b(rea|rea-agents|decompile|decompiling|decompilation|disassemble|disassembly|disassembling|binary|binaries|
|
|
338
|
+
const REVERSE_ENGINEERING_INTENT = /\b(rea|rea-agents|decompile|decompiling|decompilation|disassemble|disassembly|disassembling|disasm|binary|binaries|elf binary|mach-o|portable executable|coff|reverse[\s_-]?engineer(ing)?|sourcemap|deobfuscate|ghidra|rizin|radare|jadx|apktool|hopper|frida|hook script|mitigations|clean[- ]?room)\b|\.(dylib|so|dll|exe|wasm|asar)\b/i;
|
|
339
|
+
const RE_BUNDLE_TARGET = /(?:\b(?:apk|aab|dex|asar)\b|\.(?:apk|aab|dex)\b)/i;
|
|
340
|
+
const RE_INSPECTION_VERB = /\b(?:inspect|analyze|analyse|examine|unpack|extract|dump|audit|reconstruct|decode|parse|strings)\b|what(?:'s| is) inside/i;
|
|
339
341
|
const INTENT_MATCHERS = {
|
|
340
342
|
game: GAME_INTENT,
|
|
341
343
|
web: WEB_INTENT,
|
|
@@ -344,6 +346,13 @@ const INTENT_MATCHERS = {
|
|
|
344
346
|
advanced: ADVANCED_INTENT,
|
|
345
347
|
reverse_engineering: REVERSE_ENGINEERING_INTENT
|
|
346
348
|
};
|
|
349
|
+
/** True when the prompt genuinely asks for reverse engineering or binary inspection rather than building/exporting our own APK/AAB. */
|
|
350
|
+
export function isReverseEngineeringIntent(prompt) {
|
|
351
|
+
const value = prompt || '';
|
|
352
|
+
if (REVERSE_ENGINEERING_INTENT.test(value))
|
|
353
|
+
return true;
|
|
354
|
+
return RE_BUNDLE_TARGET.test(value) && RE_INSPECTION_VERB.test(value);
|
|
355
|
+
}
|
|
347
356
|
/** True when the prompt genuinely describes game development work. */
|
|
348
357
|
export function isGameIntent(prompt) {
|
|
349
358
|
return GAME_INTENT.test(prompt || '');
|
|
@@ -366,27 +375,40 @@ export function routePacks(prompt, workspaceContext = null) {
|
|
|
366
375
|
const unlocked = new Set();
|
|
367
376
|
const text = prompt || '';
|
|
368
377
|
for (const packName of PACK_NAMES) {
|
|
369
|
-
|
|
378
|
+
const matched = packName === 'reverse_engineering'
|
|
379
|
+
? isReverseEngineeringIntent(text)
|
|
380
|
+
: INTENT_MATCHERS[packName].test(text);
|
|
381
|
+
if (matched) {
|
|
370
382
|
unlocked.add(packName);
|
|
371
383
|
}
|
|
372
384
|
}
|
|
385
|
+
// Greetings and pure non-actionable prompts must not preload heavy workspace packs.
|
|
386
|
+
const trimmed = text.trim();
|
|
387
|
+
const isGreeting = /^(?:hi|hello|hey|yo|halo|hai|p|good\s+(?:morning|afternoon|evening))[.!?, ]*$/i.test(trimmed);
|
|
388
|
+
const explicitNonWebTarget = /\b(?:aab|apk|gradle|bundleRelease|android|godot|\.gd\b|rust|cargo|xcode|ipa)\b/i.test(trimmed)
|
|
389
|
+
&& !isWebIntent(trimmed);
|
|
373
390
|
// Workspace signals. A Godot project on disk is far more reliable evidence of
|
|
374
391
|
// game work than any keyword, and a detected web framework means the agent
|
|
375
392
|
// will eventually need to look at what it built.
|
|
376
|
-
if (workspaceContext) {
|
|
393
|
+
if (workspaceContext && !isGreeting) {
|
|
377
394
|
const signals = [
|
|
378
395
|
workspaceContext.framework,
|
|
379
396
|
workspaceContext.projectType,
|
|
380
397
|
workspaceContext.designSystem,
|
|
398
|
+
Array.isArray(workspaceContext.subprojectStacks) ? workspaceContext.subprojectStacks.join(' ') : '',
|
|
381
399
|
Array.isArray(workspaceContext.keyFiles) ? workspaceContext.keyFiles.join(' ') : ''
|
|
382
400
|
]
|
|
383
401
|
.filter(Boolean)
|
|
384
402
|
.join(' ')
|
|
385
403
|
.toLowerCase();
|
|
386
|
-
|
|
404
|
+
const hasGameProject = /godot|project\.godot|unity|\.tscn/.test(signals);
|
|
405
|
+
const hasFrontendFramework = /react|vue|svelte|next|nuxt|astro|angular|tailwind|vite/.test(signals);
|
|
406
|
+
const hasHtmlEntry = /\bhtml\b/.test(signals);
|
|
407
|
+
if (hasGameProject)
|
|
387
408
|
unlocked.add('game');
|
|
388
|
-
if (
|
|
409
|
+
if (hasFrontendFramework || (hasHtmlEntry && !hasGameProject && !explicitNonWebTarget)) {
|
|
389
410
|
unlocked.add('web');
|
|
411
|
+
}
|
|
390
412
|
}
|
|
391
413
|
return [...unlocked];
|
|
392
414
|
}
|
package/src/toolPacks.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface WorkspaceRoutingContext {
|
|
|
24
24
|
projectType?: string | null | undefined;
|
|
25
25
|
designSystem?: string | null | undefined;
|
|
26
26
|
keyFiles?: string[] | null | undefined;
|
|
27
|
+
subprojectStacks?: string[] | null | undefined;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export interface ToolDefinitionLike {
|
|
@@ -380,7 +381,10 @@ const SYSTEM_INTENT = /\b(process|processes|pid|kill|port|zip|unzip|tar|archive|
|
|
|
380
381
|
|
|
381
382
|
const ADVANCED_INTENT = /\b(pdf|document|proposal|screenplay|shotlist|shot list|voiceover|dubbing|forge a tool|custom tool|new tool|plugin|plugins|custom plugin|plugins? factory|python bridge|mcp|mcp server|subagent|sub-agent|parallel agent|swarm|ast|symbols|refactor across)\b/i;
|
|
382
383
|
|
|
383
|
-
const REVERSE_ENGINEERING_INTENT = /\b(rea|rea-agents|decompile|decompiling|decompilation|disassemble|disassembly|disassembling|binary|binaries|
|
|
384
|
+
const REVERSE_ENGINEERING_INTENT = /\b(rea|rea-agents|decompile|decompiling|decompilation|disassemble|disassembly|disassembling|disasm|binary|binaries|elf binary|mach-o|portable executable|coff|reverse[\s_-]?engineer(ing)?|sourcemap|deobfuscate|ghidra|rizin|radare|jadx|apktool|hopper|frida|hook script|mitigations|clean[- ]?room)\b|\.(dylib|so|dll|exe|wasm|asar)\b/i;
|
|
385
|
+
|
|
386
|
+
const RE_BUNDLE_TARGET = /(?:\b(?:apk|aab|dex|asar)\b|\.(?:apk|aab|dex)\b)/i;
|
|
387
|
+
const RE_INSPECTION_VERB = /\b(?:inspect|analyze|analyse|examine|unpack|extract|dump|audit|reconstruct|decode|parse|strings)\b|what(?:'s| is) inside/i;
|
|
384
388
|
|
|
385
389
|
const INTENT_MATCHERS: Record<PackName, RegExp> = {
|
|
386
390
|
game: GAME_INTENT,
|
|
@@ -391,6 +395,13 @@ const INTENT_MATCHERS: Record<PackName, RegExp> = {
|
|
|
391
395
|
reverse_engineering: REVERSE_ENGINEERING_INTENT
|
|
392
396
|
};
|
|
393
397
|
|
|
398
|
+
/** True when the prompt genuinely asks for reverse engineering or binary inspection rather than building/exporting our own APK/AAB. */
|
|
399
|
+
export function isReverseEngineeringIntent(prompt?: string | null): boolean {
|
|
400
|
+
const value = prompt || '';
|
|
401
|
+
if (REVERSE_ENGINEERING_INTENT.test(value)) return true;
|
|
402
|
+
return RE_BUNDLE_TARGET.test(value) && RE_INSPECTION_VERB.test(value);
|
|
403
|
+
}
|
|
404
|
+
|
|
394
405
|
/** True when the prompt genuinely describes game development work. */
|
|
395
406
|
export function isGameIntent(prompt?: string | null): boolean {
|
|
396
407
|
return GAME_INTENT.test(prompt || '');
|
|
@@ -418,27 +429,43 @@ export function routePacks(
|
|
|
418
429
|
const text = prompt || '';
|
|
419
430
|
|
|
420
431
|
for (const packName of PACK_NAMES) {
|
|
421
|
-
|
|
432
|
+
const matched = packName === 'reverse_engineering'
|
|
433
|
+
? isReverseEngineeringIntent(text)
|
|
434
|
+
: INTENT_MATCHERS[packName].test(text);
|
|
435
|
+
if (matched) {
|
|
422
436
|
unlocked.add(packName);
|
|
423
437
|
}
|
|
424
438
|
}
|
|
425
439
|
|
|
440
|
+
// Greetings and pure non-actionable prompts must not preload heavy workspace packs.
|
|
441
|
+
const trimmed = text.trim();
|
|
442
|
+
const isGreeting = /^(?:hi|hello|hey|yo|halo|hai|p|good\s+(?:morning|afternoon|evening))[.!?, ]*$/i.test(trimmed);
|
|
443
|
+
const explicitNonWebTarget = /\b(?:aab|apk|gradle|bundleRelease|android|godot|\.gd\b|rust|cargo|xcode|ipa)\b/i.test(trimmed)
|
|
444
|
+
&& !isWebIntent(trimmed);
|
|
445
|
+
|
|
426
446
|
// Workspace signals. A Godot project on disk is far more reliable evidence of
|
|
427
447
|
// game work than any keyword, and a detected web framework means the agent
|
|
428
448
|
// will eventually need to look at what it built.
|
|
429
|
-
if (workspaceContext) {
|
|
449
|
+
if (workspaceContext && !isGreeting) {
|
|
430
450
|
const signals = [
|
|
431
451
|
workspaceContext.framework,
|
|
432
452
|
workspaceContext.projectType,
|
|
433
453
|
workspaceContext.designSystem,
|
|
454
|
+
Array.isArray(workspaceContext.subprojectStacks) ? workspaceContext.subprojectStacks.join(' ') : '',
|
|
434
455
|
Array.isArray(workspaceContext.keyFiles) ? workspaceContext.keyFiles.join(' ') : ''
|
|
435
456
|
]
|
|
436
457
|
.filter(Boolean)
|
|
437
458
|
.join(' ')
|
|
438
459
|
.toLowerCase();
|
|
439
460
|
|
|
440
|
-
|
|
441
|
-
|
|
461
|
+
const hasGameProject = /godot|project\.godot|unity|\.tscn/.test(signals);
|
|
462
|
+
const hasFrontendFramework = /react|vue|svelte|next|nuxt|astro|angular|tailwind|vite/.test(signals);
|
|
463
|
+
const hasHtmlEntry = /\bhtml\b/.test(signals);
|
|
464
|
+
|
|
465
|
+
if (hasGameProject) unlocked.add('game');
|
|
466
|
+
if (hasFrontendFramework || (hasHtmlEntry && !hasGameProject && !explicitNonWebTarget)) {
|
|
467
|
+
unlocked.add('web');
|
|
468
|
+
}
|
|
442
469
|
}
|
|
443
470
|
|
|
444
471
|
return [...unlocked];
|
package/src/tools/memoryWrite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// @ts-expect-error Legacy memory module has no TypeScript declarations yet.
|
|
2
1
|
import { getMemory, saveMemory } from '../memory.js';
|
|
2
|
+
import { recordScopedFact } from '../memory/scopedFacts.js';
|
|
3
3
|
import { cortexDb } from '../cortex/vectorDb.js';
|
|
4
4
|
const MAX_FACTS = 100;
|
|
5
5
|
export const memoryWrite = {
|
|
@@ -41,16 +41,14 @@ export const memoryWrite = {
|
|
|
41
41
|
}
|
|
42
42
|
try {
|
|
43
43
|
const memory = getMemory();
|
|
44
|
-
if (!Array.isArray(memory.facts))
|
|
45
|
-
memory.facts = [];
|
|
46
44
|
const fact = String(args.fact).trim();
|
|
47
|
-
const
|
|
45
|
+
const workspace = dependencies?.parentLoop?.workspaceRoot || dependencies?.workspaceRoot;
|
|
46
|
+
const { memory: updated, alreadyKnown } = recordScopedFact(memory, fact, {
|
|
47
|
+
workspace,
|
|
48
|
+
maxFacts: MAX_FACTS
|
|
49
|
+
});
|
|
48
50
|
if (!alreadyKnown) {
|
|
49
|
-
|
|
50
|
-
while (memory.facts.length > MAX_FACTS) {
|
|
51
|
-
memory.facts.shift();
|
|
52
|
-
}
|
|
53
|
-
saveMemory(memory);
|
|
51
|
+
saveMemory(updated);
|
|
54
52
|
}
|
|
55
53
|
let creativeSaved = false;
|
|
56
54
|
if (args.creativePattern && args.creativePattern.designApproach) {
|
|
@@ -76,7 +74,7 @@ export const memoryWrite = {
|
|
|
76
74
|
}
|
|
77
75
|
const notes = [
|
|
78
76
|
alreadyKnown ? 'Fact already known, not duplicated.' : 'Fact saved.',
|
|
79
|
-
`Total persistent facts: ${
|
|
77
|
+
`Total persistent facts: ${updated.facts.length}.`,
|
|
80
78
|
creativeSaved ? 'Creative pattern recorded in the V5 Cortex.' : ''
|
|
81
79
|
].filter(Boolean);
|
|
82
80
|
return { success: true, output: notes.join(' ') };
|
package/src/tools/memoryWrite.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// @ts-expect-error Legacy memory module has no TypeScript declarations yet.
|
|
2
1
|
import { getMemory, saveMemory } from '../memory.js';
|
|
2
|
+
import { recordScopedFact } from '../memory/scopedFacts.js';
|
|
3
3
|
import { cortexDb } from '../cortex/vectorDb.js';
|
|
4
4
|
|
|
5
5
|
const MAX_FACTS = 100;
|
|
@@ -17,6 +17,10 @@ export interface MemoryWriteArgs {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface MemoryWriteDependencies {
|
|
20
|
+
workspaceRoot?: string | undefined;
|
|
21
|
+
parentLoop?: {
|
|
22
|
+
workspaceRoot?: string | undefined;
|
|
23
|
+
} | undefined;
|
|
20
24
|
broadcast?: (event: { type: string; content: string }) => void;
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -65,18 +69,16 @@ export const memoryWrite = {
|
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
try {
|
|
68
|
-
const memory = getMemory()
|
|
69
|
-
if (!Array.isArray(memory.facts)) memory.facts = [];
|
|
70
|
-
|
|
72
|
+
const memory = getMemory();
|
|
71
73
|
const fact = String(args.fact).trim();
|
|
72
|
-
const
|
|
74
|
+
const workspace = dependencies?.parentLoop?.workspaceRoot || dependencies?.workspaceRoot;
|
|
75
|
+
const { memory: updated, alreadyKnown } = recordScopedFact(memory, fact, {
|
|
76
|
+
workspace,
|
|
77
|
+
maxFacts: MAX_FACTS
|
|
78
|
+
});
|
|
73
79
|
|
|
74
80
|
if (!alreadyKnown) {
|
|
75
|
-
|
|
76
|
-
while (memory.facts.length > MAX_FACTS) {
|
|
77
|
-
memory.facts.shift();
|
|
78
|
-
}
|
|
79
|
-
saveMemory(memory);
|
|
81
|
+
saveMemory(updated);
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
let creativeSaved = false;
|
|
@@ -104,7 +106,7 @@ export const memoryWrite = {
|
|
|
104
106
|
|
|
105
107
|
const notes = [
|
|
106
108
|
alreadyKnown ? 'Fact already known, not duplicated.' : 'Fact saved.',
|
|
107
|
-
`Total persistent facts: ${
|
|
109
|
+
`Total persistent facts: ${updated.facts.length}.`,
|
|
108
110
|
creativeSaved ? 'Creative pattern recorded in the V5 Cortex.' : ''
|
|
109
111
|
].filter(Boolean);
|
|
110
112
|
|
package/src/tui/chatRenderer.js
CHANGED
|
@@ -822,7 +822,10 @@ export class ChatRenderer {
|
|
|
822
822
|
this.status.contextChars = finalMeasured;
|
|
823
823
|
}
|
|
824
824
|
if (!this.status.contextLimit) {
|
|
825
|
-
this.status.contextLimit = resolveCharPool(this.status.tier
|
|
825
|
+
this.status.contextLimit = resolveCharPool(this.status.tier, undefined, {
|
|
826
|
+
provider: sessionInfo?.provider || this.status.provider,
|
|
827
|
+
model: sessionInfo?.model || this.status.model
|
|
828
|
+
});
|
|
826
829
|
}
|
|
827
830
|
if (sessionInfo) {
|
|
828
831
|
this.status.setSession({
|
package/src/tui/codeProgress.js
CHANGED
|
@@ -10,14 +10,15 @@ export const CODE_PANEL_LINES = 10;
|
|
|
10
10
|
const MAX_STREAM_PREVIEW_CHARS = 256_000;
|
|
11
11
|
const FILE_TOOLS = {
|
|
12
12
|
fs_write: 'Creating', fs_edit: 'Editing', MultiEdit: 'Editing',
|
|
13
|
+
write: 'Creating', edit: 'Editing', multiedit: 'Editing', multi_edit: 'Editing',
|
|
13
14
|
'fs.write': 'Creating', 'fs.edit': 'Editing',
|
|
14
15
|
fs_delete: 'Removing', fs_move: 'Moving',
|
|
15
|
-
write_file: 'Creating', edit_file: 'Editing', delete_file: 'Removing',
|
|
16
|
+
write_file: 'Creating', write_to_file: 'Creating', edit_file: 'Editing', delete_file: 'Removing',
|
|
16
17
|
create_file: 'Creating', new_file: 'Creating',
|
|
17
18
|
remove_file: 'Removing', unlink: 'Removing', move_file: 'Moving',
|
|
18
19
|
replace_file_content: 'Editing', multi_replace_file_content: 'Editing',
|
|
19
20
|
apply_patch: 'Editing', patch: 'Editing', str_replace_editor: 'Editing',
|
|
20
|
-
WriteFile: 'Creating', EditFile: 'Editing', DeleteFile: 'Removing',
|
|
21
|
+
WriteFile: 'Creating', WriteToFile: 'Creating', EditFile: 'Editing', DeleteFile: 'Removing',
|
|
21
22
|
CreateFile: 'Creating', RemoveFile: 'Removing', MoveFile: 'Moving',
|
|
22
23
|
ReplaceFileContent: 'Editing', MultiReplaceFileContent: 'Editing'
|
|
23
24
|
};
|
package/src/tui/codeProgress.ts
CHANGED
|
@@ -28,14 +28,15 @@ const MAX_STREAM_PREVIEW_CHARS = 256_000;
|
|
|
28
28
|
|
|
29
29
|
const FILE_TOOLS: Record<string, string> = {
|
|
30
30
|
fs_write: 'Creating', fs_edit: 'Editing', MultiEdit: 'Editing',
|
|
31
|
+
write: 'Creating', edit: 'Editing', multiedit: 'Editing', multi_edit: 'Editing',
|
|
31
32
|
'fs.write': 'Creating', 'fs.edit': 'Editing',
|
|
32
33
|
fs_delete: 'Removing', fs_move: 'Moving',
|
|
33
|
-
write_file: 'Creating', edit_file: 'Editing', delete_file: 'Removing',
|
|
34
|
+
write_file: 'Creating', write_to_file: 'Creating', edit_file: 'Editing', delete_file: 'Removing',
|
|
34
35
|
create_file: 'Creating', new_file: 'Creating',
|
|
35
36
|
remove_file: 'Removing', unlink: 'Removing', move_file: 'Moving',
|
|
36
37
|
replace_file_content: 'Editing', multi_replace_file_content: 'Editing',
|
|
37
38
|
apply_patch: 'Editing', patch: 'Editing', str_replace_editor: 'Editing',
|
|
38
|
-
WriteFile: 'Creating', EditFile: 'Editing', DeleteFile: 'Removing',
|
|
39
|
+
WriteFile: 'Creating', WriteToFile: 'Creating', EditFile: 'Editing', DeleteFile: 'Removing',
|
|
39
40
|
CreateFile: 'Creating', RemoveFile: 'Removing', MoveFile: 'Moving',
|
|
40
41
|
ReplaceFileContent: 'Editing', MultiReplaceFileContent: 'Editing'
|
|
41
42
|
};
|
|
@@ -21,6 +21,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
21
21
|
modelNote = '';
|
|
22
22
|
lastReasoning = '';
|
|
23
23
|
currentActivity = 'thinking';
|
|
24
|
+
lastReasoningActivity = 'thinking';
|
|
24
25
|
streamingNowMs = 320;
|
|
25
26
|
streamingTick = undefined;
|
|
26
27
|
codePanels = new WeakMap();
|
|
@@ -189,6 +190,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
189
190
|
this.activeCode = null;
|
|
190
191
|
this.modelNote = '';
|
|
191
192
|
this.lastReasoning = '';
|
|
193
|
+
this.lastReasoningActivity = 'thinking';
|
|
192
194
|
this.collapseFinishedReasoningFrames(true);
|
|
193
195
|
super.resetTurn();
|
|
194
196
|
}
|
|
@@ -225,30 +227,48 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
225
227
|
if (message?.type === 'agent_activity') {
|
|
226
228
|
const rawActivity = safeDisplay(String(message.activity || message.message || '')).replace(/\s+/g, ' ').trim();
|
|
227
229
|
if (rawActivity) {
|
|
228
|
-
|
|
230
|
+
const normalizedActivity = stripTrailingEllipsisText(rawActivity);
|
|
231
|
+
this.currentActivity = normalizedActivity;
|
|
232
|
+
const isRespondingPhase = /^responding\b/i.test(normalizedActivity);
|
|
229
233
|
if (this._activeReasoning && this.lastReasoning) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
if (isRespondingPhase) {
|
|
235
|
+
// Finalize an open reasoning / native-step frame with its real
|
|
236
|
+
// activity instead of relabeling executed steps as "responding".
|
|
237
|
+
super.onAgentReasoning({
|
|
238
|
+
content: this.lastReasoning,
|
|
239
|
+
streaming: false,
|
|
240
|
+
activity: this.lastReasoningActivity || 'thinking'
|
|
241
|
+
});
|
|
242
|
+
this._activeReasoning = false;
|
|
243
|
+
this.lastReasoning = '';
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
this.lastReasoningActivity = normalizedActivity;
|
|
247
|
+
super.onAgentReasoning({
|
|
248
|
+
content: this.lastReasoning,
|
|
249
|
+
streaming: true,
|
|
250
|
+
activity: normalizedActivity,
|
|
251
|
+
title: rawActivity
|
|
252
|
+
});
|
|
253
|
+
}
|
|
236
254
|
if (selfStatus.quietStatus) {
|
|
237
255
|
selfStatus.currentStatus = rawActivity;
|
|
238
256
|
selfStatus.onStatusChange?.(rawActivity);
|
|
239
257
|
}
|
|
240
258
|
return true;
|
|
241
259
|
}
|
|
242
|
-
const handled = super.handle({
|
|
243
|
-
...message,
|
|
244
|
-
activity: rawActivity,
|
|
245
|
-
message: rawActivity
|
|
246
|
-
});
|
|
247
260
|
if (selfStatus.quietStatus) {
|
|
261
|
+
// Full-screen quietStatus owns live phase indicators via the footer;
|
|
262
|
+
// do not append transient phase notices into the permanent transcript.
|
|
248
263
|
selfStatus.currentStatus = rawActivity;
|
|
249
264
|
selfStatus.onStatusChange?.(rawActivity);
|
|
265
|
+
return true;
|
|
250
266
|
}
|
|
251
|
-
return
|
|
267
|
+
return super.handle({
|
|
268
|
+
...message,
|
|
269
|
+
activity: rawActivity,
|
|
270
|
+
message: rawActivity
|
|
271
|
+
});
|
|
252
272
|
}
|
|
253
273
|
}
|
|
254
274
|
if (message?.type === 'notice' && message.nativeStep === true) {
|
|
@@ -273,6 +293,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
273
293
|
activity = 'planning';
|
|
274
294
|
}
|
|
275
295
|
this.currentActivity = activity;
|
|
296
|
+
this.lastReasoningActivity = activity;
|
|
276
297
|
if (selfStatus.quietStatus) {
|
|
277
298
|
const statusLabel = `${activity.charAt(0).toUpperCase() + activity.slice(1)}…`;
|
|
278
299
|
selfStatus.currentStatus = statusLabel;
|
|
@@ -312,9 +333,14 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
312
333
|
return true;
|
|
313
334
|
}
|
|
314
335
|
const preservedStatus = selfStatus.quietStatus ? selfStatus.currentStatus : '';
|
|
336
|
+
const rawReasonActivity = message.activity || this.currentActivity || 'thinking';
|
|
337
|
+
const reasonActivity = /^responding\b/i.test(String(rawReasonActivity))
|
|
338
|
+
? (this.lastReasoningActivity || 'thinking')
|
|
339
|
+
: String(rawReasonActivity);
|
|
340
|
+
this.lastReasoningActivity = reasonActivity;
|
|
315
341
|
const handled = super.handle({
|
|
316
342
|
...message,
|
|
317
|
-
activity:
|
|
343
|
+
activity: reasonActivity
|
|
318
344
|
});
|
|
319
345
|
if (message.streaming === false) {
|
|
320
346
|
this.lastReasoning = '';
|
|
@@ -341,7 +367,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
341
367
|
super.onAgentReasoning({
|
|
342
368
|
content: this.lastReasoning,
|
|
343
369
|
streaming: false,
|
|
344
|
-
activity: this.currentActivity
|
|
370
|
+
activity: this.lastReasoningActivity || this.currentActivity
|
|
345
371
|
});
|
|
346
372
|
}
|
|
347
373
|
this._activeReasoning = false;
|
|
@@ -48,6 +48,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
48
48
|
private modelNote = '';
|
|
49
49
|
private lastReasoning = '';
|
|
50
50
|
private currentActivity = 'thinking';
|
|
51
|
+
private lastReasoningActivity = 'thinking';
|
|
51
52
|
private streamingNowMs = 320;
|
|
52
53
|
private streamingTick: number | undefined = undefined;
|
|
53
54
|
private readonly codePanels = new WeakMap<CodeFrame, CodePanelState>();
|
|
@@ -231,6 +232,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
231
232
|
this.activeCode = null;
|
|
232
233
|
this.modelNote = '';
|
|
233
234
|
this.lastReasoning = '';
|
|
235
|
+
this.lastReasoningActivity = 'thinking';
|
|
234
236
|
this.collapseFinishedReasoningFrames(true);
|
|
235
237
|
super.resetTurn();
|
|
236
238
|
}
|
|
@@ -274,30 +276,47 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
274
276
|
if (message?.type === 'agent_activity') {
|
|
275
277
|
const rawActivity = safeDisplay(String((message as any).activity || (message as any).message || '')).replace(/\s+/g, ' ').trim();
|
|
276
278
|
if (rawActivity) {
|
|
277
|
-
|
|
279
|
+
const normalizedActivity = stripTrailingEllipsisText(rawActivity);
|
|
280
|
+
this.currentActivity = normalizedActivity;
|
|
281
|
+
const isRespondingPhase = /^responding\b/i.test(normalizedActivity);
|
|
278
282
|
if (this._activeReasoning && this.lastReasoning) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
if (isRespondingPhase) {
|
|
284
|
+
// Finalize an open reasoning / native-step frame with its real
|
|
285
|
+
// activity instead of relabeling executed steps as "responding".
|
|
286
|
+
super.onAgentReasoning({
|
|
287
|
+
content: this.lastReasoning,
|
|
288
|
+
streaming: false,
|
|
289
|
+
activity: this.lastReasoningActivity || 'thinking'
|
|
290
|
+
});
|
|
291
|
+
this._activeReasoning = false;
|
|
292
|
+
this.lastReasoning = '';
|
|
293
|
+
} else {
|
|
294
|
+
this.lastReasoningActivity = normalizedActivity;
|
|
295
|
+
super.onAgentReasoning({
|
|
296
|
+
content: this.lastReasoning,
|
|
297
|
+
streaming: true,
|
|
298
|
+
activity: normalizedActivity,
|
|
299
|
+
title: rawActivity
|
|
300
|
+
});
|
|
301
|
+
}
|
|
285
302
|
if (selfStatus.quietStatus) {
|
|
286
303
|
selfStatus.currentStatus = rawActivity;
|
|
287
304
|
selfStatus.onStatusChange?.(rawActivity);
|
|
288
305
|
}
|
|
289
306
|
return true;
|
|
290
307
|
}
|
|
291
|
-
const handled = super.handle({
|
|
292
|
-
...message,
|
|
293
|
-
activity: rawActivity,
|
|
294
|
-
message: rawActivity
|
|
295
|
-
});
|
|
296
308
|
if (selfStatus.quietStatus) {
|
|
309
|
+
// Full-screen quietStatus owns live phase indicators via the footer;
|
|
310
|
+
// do not append transient phase notices into the permanent transcript.
|
|
297
311
|
selfStatus.currentStatus = rawActivity;
|
|
298
312
|
selfStatus.onStatusChange?.(rawActivity);
|
|
313
|
+
return true;
|
|
299
314
|
}
|
|
300
|
-
return
|
|
315
|
+
return super.handle({
|
|
316
|
+
...message,
|
|
317
|
+
activity: rawActivity,
|
|
318
|
+
message: rawActivity
|
|
319
|
+
});
|
|
301
320
|
}
|
|
302
321
|
}
|
|
303
322
|
|
|
@@ -319,6 +338,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
319
338
|
activity = 'planning';
|
|
320
339
|
}
|
|
321
340
|
this.currentActivity = activity;
|
|
341
|
+
this.lastReasoningActivity = activity;
|
|
322
342
|
if (selfStatus.quietStatus) {
|
|
323
343
|
const statusLabel = `${activity.charAt(0).toUpperCase() + activity.slice(1)}…`;
|
|
324
344
|
selfStatus.currentStatus = statusLabel;
|
|
@@ -360,9 +380,14 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
360
380
|
return true;
|
|
361
381
|
}
|
|
362
382
|
const preservedStatus = selfStatus.quietStatus ? selfStatus.currentStatus : '';
|
|
383
|
+
const rawReasonActivity = (message as any).activity || this.currentActivity || 'thinking';
|
|
384
|
+
const reasonActivity = /^responding\b/i.test(String(rawReasonActivity))
|
|
385
|
+
? (this.lastReasoningActivity || 'thinking')
|
|
386
|
+
: String(rawReasonActivity);
|
|
387
|
+
this.lastReasoningActivity = reasonActivity;
|
|
363
388
|
const handled = super.handle({
|
|
364
389
|
...message,
|
|
365
|
-
activity:
|
|
390
|
+
activity: reasonActivity
|
|
366
391
|
});
|
|
367
392
|
if (message.streaming === false) {
|
|
368
393
|
this.lastReasoning = '';
|
|
@@ -388,7 +413,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
388
413
|
super.onAgentReasoning({
|
|
389
414
|
content: this.lastReasoning,
|
|
390
415
|
streaming: false,
|
|
391
|
-
activity: this.currentActivity
|
|
416
|
+
activity: this.lastReasoningActivity || this.currentActivity
|
|
392
417
|
});
|
|
393
418
|
}
|
|
394
419
|
this._activeReasoning = false;
|
package/src/tui/keys.js
CHANGED
|
@@ -479,7 +479,9 @@ function partialSuffixLength(text, marker) {
|
|
|
479
479
|
* There is no mode that reports the wheel alone. UX-02.
|
|
480
480
|
*/
|
|
481
481
|
export function mouseTracking(enabled) {
|
|
482
|
-
|
|
482
|
+
// Select SGR encoding before enabling reporting. Disable reporting before
|
|
483
|
+
// tearing down its encoding so no event can arrive as legacy X10 bytes.
|
|
484
|
+
return enabled ? '\x1b[?1006h\x1b[?1000h' : '\x1b[?1000l\x1b[?1006l';
|
|
483
485
|
}
|
|
484
486
|
|
|
485
487
|
/** Turn bracketed paste on/off. Paired with the editor's lifecycle. */
|