@causyne/agent 1.20.55 → 1.20.62
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/acp/agentCatalog.js +1 -1
- package/src/acp/agentCatalog.ts +1 -1
- package/src/acp/peerProfiles.js +3 -3
- package/src/acp/peerProfiles.ts +3 -3
- package/src/agentLoop.js +91 -19
- package/src/agentLoop.ts +102 -22
- package/src/checkpoints.js +23 -5
- package/src/cliMode.js +4 -2
- package/src/commands.js +503 -78
- package/src/contextManager.d.ts +3 -0
- package/src/contextManager.js +78 -5
- package/src/cortex/autoCondenser.js +105 -145
- package/src/cortex/autoCondenser.ts +185 -0
- package/src/cortex/cortexEngine.js +179 -0
- package/src/cortex/cortexEngine.ts +209 -0
- package/src/cortex/provisioner.js +12 -14
- package/src/cortex/provisioner.ts +29 -0
- package/src/cortex/vectorDb.js +307 -386
- package/src/cortex/vectorDb.ts +473 -0
- package/src/decisionPolicy.js +3 -3
- package/src/decisionPolicy.ts +3 -3
- package/src/observer/coldObserver.js +10 -4
- package/src/observer/coldObserver.ts +10 -4
- package/src/observer/evidence.js +8 -3
- package/src/observer/evidence.ts +8 -3
- package/src/reporting.js +30 -7
- package/src/sessionJournal.js +13 -0
- package/src/sessionJournal.ts +13 -0
- package/src/tokenTracker.js +22 -0
- package/src/tokenTracker.ts +28 -0
- package/src/tools/memoryWrite.js +11 -3
- package/src/tools/memoryWrite.ts +12 -3
- package/src/tools/toolSelfRepair.js +11 -0
- package/src/tools/toolSelfRepair.ts +10 -0
- package/src/tui/chatRenderer.js +8 -4
- package/src/tui/completion.js +34 -15
- package/src/tui/composerControls.js +5 -0
- package/src/tui/composerControls.ts +5 -0
- package/src/tui/layout.js +1 -1
- package/src/tui/layout.ts +1 -1
- package/src/tui/messageInteraction.js +1 -1
- package/src/tui/messageInteraction.ts +1 -1
- package/src/tui/observerPicker.js +323 -0
- package/src/tui/observerPicker.ts +386 -0
- package/src/tui/prompt.js +185 -23
- package/src/tui/stage.js +2 -2
- package/src/tui/stageSurface.js +22 -27
- package/src/tui/thinkingBox.js +2 -2
- package/src/tui/thinkingBox.ts +2 -2
- package/src/tui/usageCard.js +178 -0
- package/src/tui/usageCard.ts +240 -0
- package/src/utils/paths.js +30 -1
- package/src/utils/paths.ts +32 -1
- package/src/cortex/autoCondenser.d.ts +0 -2
- package/src/cortex/vectorDb.d.ts +0 -1
package/src/reporting.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { TOOL_DEFINITIONS } from './tools/registry.js';
|
|
4
4
|
import { CORE_TOOLS, PACKS, PACK_PLAYBOOKS } from './toolPacks.js';
|
|
5
|
-
import { resolveCharPool } from './contextManager.js';
|
|
5
|
+
import { resolveCharPool, resolveModelContextTokens } from './contextManager.js';
|
|
6
6
|
import { TokenTracker } from './tokenTracker.js';
|
|
7
7
|
import { loadConfig } from './config.js';
|
|
8
8
|
import { listSpills, getOutputDir } from './outputStore.js';
|
|
@@ -53,7 +53,23 @@ function schemaTokens(names) {
|
|
|
53
53
|
export function buildContextReport() {
|
|
54
54
|
const config = loadConfig();
|
|
55
55
|
const tier = config.tier || 'premium';
|
|
56
|
-
const
|
|
56
|
+
const provider = config.provider || 'default';
|
|
57
|
+
const model = config.model || 'default';
|
|
58
|
+
const charPool = resolveCharPool(tier, config.contextCharPool, {
|
|
59
|
+
provider,
|
|
60
|
+
model,
|
|
61
|
+
overrideTokens: config.contextTokens || config.maxContextTokens
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const modelTokens = resolveModelContextTokens({
|
|
65
|
+
provider,
|
|
66
|
+
model,
|
|
67
|
+
overrideTokens: config.contextTokens || config.maxContextTokens
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const approxTokenPool = modelTokens > 0
|
|
71
|
+
? modelTokens
|
|
72
|
+
: Math.round(charPool / APPROX_CHARS_PER_TOKEN);
|
|
57
73
|
|
|
58
74
|
const packs = Object.entries(PACKS).map(([name, tools]) => ({
|
|
59
75
|
name,
|
|
@@ -66,10 +82,10 @@ export function buildContextReport() {
|
|
|
66
82
|
|
|
67
83
|
return {
|
|
68
84
|
tier,
|
|
69
|
-
provider
|
|
70
|
-
model
|
|
85
|
+
provider,
|
|
86
|
+
model,
|
|
71
87
|
charPool,
|
|
72
|
-
approxTokenPool
|
|
88
|
+
approxTokenPool,
|
|
73
89
|
core: { tools: CORE_TOOLS.length, tokens: schemaTokens(CORE_TOOLS) },
|
|
74
90
|
packs,
|
|
75
91
|
allTools: TOOL_DEFINITIONS.length,
|
|
@@ -124,7 +140,14 @@ export async function buildUsageText() {
|
|
|
124
140
|
const budget = config.tokenBudget || {};
|
|
125
141
|
const lines = [];
|
|
126
142
|
|
|
127
|
-
|
|
143
|
+
const provider = config.provider || 'default';
|
|
144
|
+
const isAgy = isAntigravityProvider(provider);
|
|
145
|
+
const isAcp = isAcpProvider(provider);
|
|
146
|
+
const billingNote = (isAgy || isAcp)
|
|
147
|
+
? '(Local CLI / ACP peer)'
|
|
148
|
+
: '(BYOK — billed by your provider, not by Causyne)';
|
|
149
|
+
|
|
150
|
+
lines.push(`Token usage ${billingNote}`);
|
|
128
151
|
lines.push(` Provider / model : ${config.provider || 'default'} / ${config.model || 'default'}`);
|
|
129
152
|
lines.push(` This task : ${formatNumber(usage.taskTokens)} tokens $${Number(usage.taskCostUsd || 0).toFixed(4)}`);
|
|
130
153
|
lines.push(` Today : ${formatNumber(usage.dailyTokens)} tokens $${Number(usage.costUsd || 0).toFixed(4)}`);
|
|
@@ -215,7 +238,7 @@ export function printCheckpoints(limit = 15) {
|
|
|
215
238
|
* here, in one place, and each surface renders the single result it is given.
|
|
216
239
|
*/
|
|
217
240
|
function runUndo(taskId, options = {}) {
|
|
218
|
-
const opts = { dryRun: options.dryRun, full: options.full };
|
|
241
|
+
const opts = { dryRun: options.dryRun, full: options.full, workspaceRoot: options.workspaceRoot };
|
|
219
242
|
return options.step
|
|
220
243
|
? undoStep({ dryRun: options.dryRun })
|
|
221
244
|
: (taskId ? undoTask(taskId, opts) : undoLast(opts));
|
package/src/sessionJournal.js
CHANGED
|
@@ -489,6 +489,19 @@ export function restoreSessionFromSnapshot(file, snapshot) {
|
|
|
489
489
|
return false;
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
|
+
export function renameSession(id, newTitle) {
|
|
493
|
+
const session = readSession(id);
|
|
494
|
+
const cleanTitle = String(newTitle ?? '').trim();
|
|
495
|
+
if (!session || !cleanTitle)
|
|
496
|
+
return false;
|
|
497
|
+
return appendEvent(sessionTranscriptFile(session.id), {
|
|
498
|
+
version: 1,
|
|
499
|
+
type: 'messages.replaced',
|
|
500
|
+
at: Date.now(),
|
|
501
|
+
messages: session.messages,
|
|
502
|
+
title: cleanTitle
|
|
503
|
+
});
|
|
504
|
+
}
|
|
492
505
|
export function deleteSession(id) {
|
|
493
506
|
const safe = safeSessionId(id);
|
|
494
507
|
if (!safe)
|
package/src/sessionJournal.ts
CHANGED
|
@@ -537,6 +537,19 @@ export function restoreSessionFromSnapshot(file: string, snapshot: Buffer): bool
|
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
539
|
|
|
540
|
+
export function renameSession(id: unknown, newTitle: string): boolean {
|
|
541
|
+
const session = readSession(id);
|
|
542
|
+
const cleanTitle = String(newTitle ?? '').trim();
|
|
543
|
+
if (!session || !cleanTitle) return false;
|
|
544
|
+
return appendEvent(sessionTranscriptFile(session.id), {
|
|
545
|
+
version: 1,
|
|
546
|
+
type: 'messages.replaced',
|
|
547
|
+
at: Date.now(),
|
|
548
|
+
messages: session.messages,
|
|
549
|
+
title: cleanTitle
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
|
|
540
553
|
export function deleteSession(id: unknown): boolean {
|
|
541
554
|
const safe = safeSessionId(id);
|
|
542
555
|
if (!safe) return false;
|
package/src/tokenTracker.js
CHANGED
|
@@ -24,12 +24,16 @@ export class TokenTracker {
|
|
|
24
24
|
budget;
|
|
25
25
|
taskTokens;
|
|
26
26
|
taskCostUsd;
|
|
27
|
+
sessionTokens;
|
|
28
|
+
sessionCostUsd;
|
|
27
29
|
largestStepTokens;
|
|
28
30
|
constructor() {
|
|
29
31
|
this.config = loadConfig();
|
|
30
32
|
this.budget = this.config.tokenBudget || { enabled: false };
|
|
31
33
|
this.taskTokens = 0;
|
|
32
34
|
this.taskCostUsd = 0;
|
|
35
|
+
this.sessionTokens = 0;
|
|
36
|
+
this.sessionCostUsd = 0;
|
|
33
37
|
this.largestStepTokens = 0;
|
|
34
38
|
this.ensureUsageDir();
|
|
35
39
|
}
|
|
@@ -178,7 +182,9 @@ export class TokenTracker {
|
|
|
178
182
|
const cost = unitPrice * (quantityUnits || 1);
|
|
179
183
|
const equivalentTokens = Math.round(cost / 0.000002);
|
|
180
184
|
this.taskTokens += equivalentTokens;
|
|
185
|
+
this.sessionTokens = (this.sessionTokens || 0) + equivalentTokens;
|
|
181
186
|
this.taskCostUsd += cost;
|
|
187
|
+
this.sessionCostUsd = (this.sessionCostUsd || 0) + cost;
|
|
182
188
|
const cumulative = await this.getCumulativeUsage();
|
|
183
189
|
const daily = await this.getDailyUsage();
|
|
184
190
|
daily.totalTokens += equivalentTokens;
|
|
@@ -313,9 +319,11 @@ export class TokenTracker {
|
|
|
313
319
|
usedTokens: daily.totalTokens,
|
|
314
320
|
dailyTokens: daily.totalTokens,
|
|
315
321
|
taskTokens: this.taskTokens,
|
|
322
|
+
sessionTokens: this.sessionTokens || this.taskTokens || 0,
|
|
316
323
|
lifetimeTokens: cumulative.totalTokens,
|
|
317
324
|
costUsd: daily.totalCostUsd,
|
|
318
325
|
taskCostUsd: this.taskCostUsd,
|
|
326
|
+
sessionCostUsd: this.sessionCostUsd || this.taskCostUsd || 0,
|
|
319
327
|
lifetimeCostUsd: cumulative.totalCostUsd,
|
|
320
328
|
isDemo: false
|
|
321
329
|
};
|
|
@@ -351,12 +359,24 @@ export class TokenTracker {
|
|
|
351
359
|
this.taskCostUsd = 0;
|
|
352
360
|
this.largestStepTokens = 0;
|
|
353
361
|
}
|
|
362
|
+
resetSession() {
|
|
363
|
+
this.sessionTokens = 0;
|
|
364
|
+
this.sessionCostUsd = 0;
|
|
365
|
+
this.taskTokens = 0;
|
|
366
|
+
this.taskCostUsd = 0;
|
|
367
|
+
this.largestStepTokens = 0;
|
|
368
|
+
}
|
|
369
|
+
reset() {
|
|
370
|
+
this.resetSession();
|
|
371
|
+
}
|
|
354
372
|
settle(extra, daily, cumulative) {
|
|
355
373
|
return {
|
|
356
374
|
usedTokens: daily.totalTokens,
|
|
357
375
|
dailyTokens: daily.totalTokens,
|
|
358
376
|
dailyCostUsd: daily.totalCostUsd || 0,
|
|
359
377
|
dailyLimit: Number(this.budget && this.budget.maxTokensPerDay) || 0,
|
|
378
|
+
sessionTokens: this.sessionTokens || this.taskTokens || 0,
|
|
379
|
+
sessionCostUsd: this.sessionCostUsd || this.taskCostUsd || 0,
|
|
360
380
|
taskTokens: this.taskTokens,
|
|
361
381
|
taskCostUsd: this.taskCostUsd,
|
|
362
382
|
taskLimit: Number(this.budget && this.budget.maxTokensPerTask) || 0,
|
|
@@ -393,9 +413,11 @@ export class TokenTracker {
|
|
|
393
413
|
}
|
|
394
414
|
const freshStep = freshInput + cTokens;
|
|
395
415
|
this.taskTokens += freshStep;
|
|
416
|
+
this.sessionTokens = (this.sessionTokens || 0) + freshStep;
|
|
396
417
|
this.largestStepTokens = Math.max(this.largestStepTokens || 0, freshStep);
|
|
397
418
|
const cost = this.calculateCost(promptTokens, completionTokens, usageDetail);
|
|
398
419
|
this.taskCostUsd += cost;
|
|
420
|
+
this.sessionCostUsd = (this.sessionCostUsd || 0) + cost;
|
|
399
421
|
const { daily, cumulative } = await withUsageLock(async () => {
|
|
400
422
|
const cumulative = await this.getCumulativeUsage();
|
|
401
423
|
const daily = await this.getDailyUsage();
|
package/src/tokenTracker.ts
CHANGED
|
@@ -85,6 +85,8 @@ export interface SettledUsage {
|
|
|
85
85
|
dailyTokens: number;
|
|
86
86
|
dailyCostUsd: number;
|
|
87
87
|
dailyLimit: number;
|
|
88
|
+
sessionTokens?: number;
|
|
89
|
+
sessionCostUsd?: number;
|
|
88
90
|
taskTokens: number;
|
|
89
91
|
taskCostUsd: number;
|
|
90
92
|
taskLimit: number;
|
|
@@ -102,6 +104,8 @@ export class TokenTracker {
|
|
|
102
104
|
budget: TokenBudgetConfig;
|
|
103
105
|
taskTokens: number;
|
|
104
106
|
taskCostUsd: number;
|
|
107
|
+
sessionTokens: number;
|
|
108
|
+
sessionCostUsd: number;
|
|
105
109
|
largestStepTokens: number;
|
|
106
110
|
|
|
107
111
|
constructor() {
|
|
@@ -109,6 +113,8 @@ export class TokenTracker {
|
|
|
109
113
|
this.budget = this.config.tokenBudget || { enabled: false };
|
|
110
114
|
this.taskTokens = 0;
|
|
111
115
|
this.taskCostUsd = 0;
|
|
116
|
+
this.sessionTokens = 0;
|
|
117
|
+
this.sessionCostUsd = 0;
|
|
112
118
|
this.largestStepTokens = 0;
|
|
113
119
|
this.ensureUsageDir();
|
|
114
120
|
}
|
|
@@ -261,7 +267,9 @@ export class TokenTracker {
|
|
|
261
267
|
const equivalentTokens = Math.round(cost / 0.000002);
|
|
262
268
|
|
|
263
269
|
this.taskTokens += equivalentTokens;
|
|
270
|
+
this.sessionTokens = (this.sessionTokens || 0) + equivalentTokens;
|
|
264
271
|
this.taskCostUsd += cost;
|
|
272
|
+
this.sessionCostUsd = (this.sessionCostUsd || 0) + cost;
|
|
265
273
|
|
|
266
274
|
const cumulative = await this.getCumulativeUsage();
|
|
267
275
|
const daily = await this.getDailyUsage();
|
|
@@ -408,9 +416,11 @@ export class TokenTracker {
|
|
|
408
416
|
usedTokens: number;
|
|
409
417
|
dailyTokens: number;
|
|
410
418
|
taskTokens: number;
|
|
419
|
+
sessionTokens: number;
|
|
411
420
|
lifetimeTokens: number;
|
|
412
421
|
costUsd: number;
|
|
413
422
|
taskCostUsd: number;
|
|
423
|
+
sessionCostUsd: number;
|
|
414
424
|
lifetimeCostUsd: number;
|
|
415
425
|
isDemo: boolean;
|
|
416
426
|
}> {
|
|
@@ -420,9 +430,11 @@ export class TokenTracker {
|
|
|
420
430
|
usedTokens: daily.totalTokens,
|
|
421
431
|
dailyTokens: daily.totalTokens,
|
|
422
432
|
taskTokens: this.taskTokens,
|
|
433
|
+
sessionTokens: this.sessionTokens || this.taskTokens || 0,
|
|
423
434
|
lifetimeTokens: cumulative.totalTokens,
|
|
424
435
|
costUsd: daily.totalCostUsd,
|
|
425
436
|
taskCostUsd: this.taskCostUsd,
|
|
437
|
+
sessionCostUsd: this.sessionCostUsd || this.taskCostUsd || 0,
|
|
426
438
|
lifetimeCostUsd: cumulative.totalCostUsd,
|
|
427
439
|
isDemo: false
|
|
428
440
|
};
|
|
@@ -462,12 +474,26 @@ export class TokenTracker {
|
|
|
462
474
|
this.largestStepTokens = 0;
|
|
463
475
|
}
|
|
464
476
|
|
|
477
|
+
resetSession(): void {
|
|
478
|
+
this.sessionTokens = 0;
|
|
479
|
+
this.sessionCostUsd = 0;
|
|
480
|
+
this.taskTokens = 0;
|
|
481
|
+
this.taskCostUsd = 0;
|
|
482
|
+
this.largestStepTokens = 0;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
reset(): void {
|
|
486
|
+
this.resetSession();
|
|
487
|
+
}
|
|
488
|
+
|
|
465
489
|
settle(extra: Record<string, unknown>, daily: DailyUsage, cumulative: CumulativeUsage): SettledUsage {
|
|
466
490
|
return {
|
|
467
491
|
usedTokens: daily.totalTokens,
|
|
468
492
|
dailyTokens: daily.totalTokens,
|
|
469
493
|
dailyCostUsd: daily.totalCostUsd || 0,
|
|
470
494
|
dailyLimit: Number(this.budget && this.budget.maxTokensPerDay) || 0,
|
|
495
|
+
sessionTokens: this.sessionTokens || this.taskTokens || 0,
|
|
496
|
+
sessionCostUsd: this.sessionCostUsd || this.taskCostUsd || 0,
|
|
471
497
|
taskTokens: this.taskTokens,
|
|
472
498
|
taskCostUsd: this.taskCostUsd,
|
|
473
499
|
taskLimit: Number(this.budget && this.budget.maxTokensPerTask) || 0,
|
|
@@ -511,10 +537,12 @@ export class TokenTracker {
|
|
|
511
537
|
const freshStep = freshInput + cTokens;
|
|
512
538
|
|
|
513
539
|
this.taskTokens += freshStep;
|
|
540
|
+
this.sessionTokens = (this.sessionTokens || 0) + freshStep;
|
|
514
541
|
this.largestStepTokens = Math.max(this.largestStepTokens || 0, freshStep);
|
|
515
542
|
|
|
516
543
|
const cost = this.calculateCost(promptTokens, completionTokens, usageDetail);
|
|
517
544
|
this.taskCostUsd += cost;
|
|
545
|
+
this.sessionCostUsd = (this.sessionCostUsd || 0) + cost;
|
|
518
546
|
|
|
519
547
|
const { daily, cumulative } = await withUsageLock(async () => {
|
|
520
548
|
const cumulative = await this.getCumulativeUsage();
|
package/src/tools/memoryWrite.js
CHANGED
|
@@ -24,12 +24,20 @@ export const memoryWrite = {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
-
required: [
|
|
27
|
+
required: []
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
execute: async (args, dependencies) => {
|
|
31
|
-
if (!args || !args.fact) {
|
|
32
|
-
return { success: false, error: "Missing 'fact' parameter." };
|
|
31
|
+
if (!args || (!args.fact && !args.creativePattern)) {
|
|
32
|
+
return { success: false, error: "Missing 'fact' or 'creativePattern' parameter." };
|
|
33
|
+
}
|
|
34
|
+
if (!args.fact && args.creativePattern) {
|
|
35
|
+
const cp = args.creativePattern;
|
|
36
|
+
const project = cp.project || 'project';
|
|
37
|
+
const approach = cp.designApproach ? ` ${cp.designApproach}` : '';
|
|
38
|
+
const palette = cp.colorPalette ? ` with ${cp.colorPalette}` : '';
|
|
39
|
+
const fonts = cp.fonts ? ` (${cp.fonts})` : '';
|
|
40
|
+
args.fact = `Creative pattern for ${project}:${approach}${palette}${fonts}`.trim();
|
|
33
41
|
}
|
|
34
42
|
try {
|
|
35
43
|
const memory = getMemory();
|
package/src/tools/memoryWrite.ts
CHANGED
|
@@ -43,7 +43,7 @@ export const memoryWrite = {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
required: [
|
|
46
|
+
required: []
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
|
|
@@ -51,8 +51,17 @@ export const memoryWrite = {
|
|
|
51
51
|
args: MemoryWriteArgs | null | undefined,
|
|
52
52
|
dependencies?: MemoryWriteDependencies
|
|
53
53
|
): Promise<{ success: boolean; output?: string; error?: string }> => {
|
|
54
|
-
if (!args || !args.fact) {
|
|
55
|
-
return { success: false, error: "Missing 'fact' parameter." };
|
|
54
|
+
if (!args || (!args.fact && !args.creativePattern)) {
|
|
55
|
+
return { success: false, error: "Missing 'fact' or 'creativePattern' parameter." };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!args.fact && args.creativePattern) {
|
|
59
|
+
const cp = args.creativePattern;
|
|
60
|
+
const project = cp.project || 'project';
|
|
61
|
+
const approach = cp.designApproach ? ` ${cp.designApproach}` : '';
|
|
62
|
+
const palette = cp.colorPalette ? ` with ${cp.colorPalette}` : '';
|
|
63
|
+
const fonts = cp.fonts ? ` (${cp.fonts})` : '';
|
|
64
|
+
args.fact = `Creative pattern for ${project}:${approach}${palette}${fonts}`.trim();
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
try {
|
|
@@ -515,6 +515,17 @@ export function resolveParameterAliases(toolName, args, schema) {
|
|
|
515
515
|
});
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
+
else if (canonicalName === 'memory_write') {
|
|
519
|
+
if (!modified.fact && modified.creativePattern && typeof modified.creativePattern === 'object') {
|
|
520
|
+
const cp = modified.creativePattern;
|
|
521
|
+
const project = cp.project || 'project';
|
|
522
|
+
const approach = cp.designApproach ? ` ${cp.designApproach}` : '';
|
|
523
|
+
const palette = cp.colorPalette ? ` with ${cp.colorPalette}` : '';
|
|
524
|
+
const fonts = cp.fonts ? ` (${cp.fonts})` : '';
|
|
525
|
+
modified.fact = `Creative pattern for ${project}:${approach}${palette}${fonts}`.trim();
|
|
526
|
+
repairs.push("Synthesized required fact from creativePattern for 'memory_write'");
|
|
527
|
+
}
|
|
528
|
+
}
|
|
518
529
|
else if (canonicalName === 'native_engine') {
|
|
519
530
|
if (Array.isArray(modified.steps)) {
|
|
520
531
|
modified.steps = modified.steps.map((item) => {
|
|
@@ -570,6 +570,16 @@ export function resolveParameterAliases(
|
|
|
570
570
|
return normalizedItem;
|
|
571
571
|
});
|
|
572
572
|
}
|
|
573
|
+
} else if (canonicalName === 'memory_write') {
|
|
574
|
+
if (!modified.fact && modified.creativePattern && typeof modified.creativePattern === 'object') {
|
|
575
|
+
const cp = modified.creativePattern as Record<string, unknown>;
|
|
576
|
+
const project = cp.project || 'project';
|
|
577
|
+
const approach = cp.designApproach ? ` ${cp.designApproach}` : '';
|
|
578
|
+
const palette = cp.colorPalette ? ` with ${cp.colorPalette}` : '';
|
|
579
|
+
const fonts = cp.fonts ? ` (${cp.fonts})` : '';
|
|
580
|
+
modified.fact = `Creative pattern for ${project}:${approach}${palette}${fonts}`.trim();
|
|
581
|
+
repairs.push("Synthesized required fact from creativePattern for 'memory_write'");
|
|
582
|
+
}
|
|
573
583
|
} else if (canonicalName === 'native_engine') {
|
|
574
584
|
if (Array.isArray(modified.steps)) {
|
|
575
585
|
modified.steps = (modified.steps as Record<string, unknown>[]).map((item) => {
|
package/src/tui/chatRenderer.js
CHANGED
|
@@ -324,7 +324,11 @@ export class ChatRenderer {
|
|
|
324
324
|
this.rowSink = previousSink;
|
|
325
325
|
this.forcedWidth = previousWidth;
|
|
326
326
|
}
|
|
327
|
-
|
|
327
|
+
const maxAvailable = this.transcript?.surface?.composeAvailableWidth
|
|
328
|
+
? this.transcript.surface.composeAvailableWidth()
|
|
329
|
+
: width;
|
|
330
|
+
const availableWidth = Math.min(width, maxAvailable);
|
|
331
|
+
return sessionRows(sink, availableWidth).rows;
|
|
328
332
|
}
|
|
329
333
|
|
|
330
334
|
/**
|
|
@@ -350,7 +354,7 @@ export class ChatRenderer {
|
|
|
350
354
|
|
|
351
355
|
/** Prose follows the current conversation column with a small text inset. */
|
|
352
356
|
measure() {
|
|
353
|
-
return chatProseWidth(this.width());
|
|
357
|
+
return this.transcript ? sessionComposerWidth(this.width()) : chatProseWidth(this.width());
|
|
354
358
|
}
|
|
355
359
|
|
|
356
360
|
// -------------------------------------------------------------------------
|
|
@@ -504,12 +508,12 @@ export class ChatRenderer {
|
|
|
504
508
|
|
|
505
509
|
this.frame('user', () => {
|
|
506
510
|
const width = this.transcript
|
|
507
|
-
? sessionComposerWidth(this.width())
|
|
511
|
+
? (this.transcript.surface?.composeWidth?.() ?? sessionComposerWidth(this.width()))
|
|
508
512
|
: composerWidth(this.measure());
|
|
509
513
|
const blockWidth = Math.max(8, width);
|
|
510
514
|
const innerWidth = Math.max(8, blockWidth - visibleWidth(GLYPHS.barHeavy || GLYPHS.bar) - 1);
|
|
511
515
|
const rows = barBlock(
|
|
512
|
-
wrapBlock(safeDisplay(text), innerWidth),
|
|
516
|
+
wrapBlock(safeDisplay(text), innerWidth, { hang: 0 }),
|
|
513
517
|
{ width: blockWidth, role: 'user', filled: true, surface: 'surfaceHi' }
|
|
514
518
|
);
|
|
515
519
|
this.write();
|
package/src/tui/completion.js
CHANGED
|
@@ -106,6 +106,9 @@ function rank(items, query, limit = 50, focusDir = null) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
if (value >= 0) {
|
|
109
|
+
if (item.isCommand) {
|
|
110
|
+
value += 2000;
|
|
111
|
+
}
|
|
109
112
|
if (focusPrefix && val.toLowerCase().startsWith(focusPrefix)) {
|
|
110
113
|
value += 3000;
|
|
111
114
|
}
|
|
@@ -131,7 +134,7 @@ const ARGUMENT_LIMIT = 500;
|
|
|
131
134
|
// `/` commands
|
|
132
135
|
// ---------------------------------------------------------------------------
|
|
133
136
|
|
|
134
|
-
function commandItems() {
|
|
137
|
+
function commandItems(query = '') {
|
|
135
138
|
// Suggested/high-frequency commands prioritized at the top on a bare '/' (OpenCode architecture)
|
|
136
139
|
const SUGGESTED_ORDER = ['model', 'sessions', 'new', 'clear', 'continuum', 'help', 'status', 'setup', 'mcp'];
|
|
137
140
|
const allCommands = listCommands('terminal');
|
|
@@ -157,27 +160,43 @@ function commandItems() {
|
|
|
157
160
|
match: command.name,
|
|
158
161
|
aliases: Array.isArray(command.aliases) ? command.aliases.filter(isTerminalSafe) : [],
|
|
159
162
|
label: primaryLabel,
|
|
160
|
-
description: sanitize(command.description || '')
|
|
163
|
+
description: sanitize(command.description || ''),
|
|
164
|
+
isCommand: true
|
|
161
165
|
});
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
// On a bare '/' (no query entered), keep the menu purely focused on genuine slash commands.
|
|
170
|
+
// Skills belong in `/skills` and must never pollute the top-level palette.
|
|
171
|
+
if (!query) {
|
|
172
|
+
return commands;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// When a user explicitly searches for a skill keyword (e.g. `/docker`), offer matching skills,
|
|
176
|
+
// but commands always retain strict priority in ranking.
|
|
177
|
+
//
|
|
178
|
+
// Skills match only on a CONTIGUOUS piece of their own id, and only once the
|
|
179
|
+
// query is long enough to mean something. Loose subsequence matching over
|
|
180
|
+
// "id + domain" let `/p` and `/plu` pull 70+ unrelated skills into the
|
|
181
|
+
// command palette ("... 72 more"), burying the command being typed.
|
|
182
|
+
const needle = query.toLowerCase();
|
|
183
|
+
if (needle.length < SKILL_QUERY_MIN) return commands;
|
|
184
|
+
const skills = listSkillsForCompletion()
|
|
185
|
+
.filter((skill) => String(skill.id || '').toLowerCase().includes(needle))
|
|
186
|
+
.map((skill) => ({
|
|
187
|
+
value: `/skills ${skill.domain}/${skill.id}`,
|
|
188
|
+
match: skill.id,
|
|
189
|
+
label: `/${skill.id}`,
|
|
190
|
+
description: sanitize(skill.description || ''),
|
|
191
|
+
isCommand: false
|
|
192
|
+
}));
|
|
175
193
|
|
|
176
|
-
// Commands first: on a bare `/` every entry scores 0, and a stable sort then
|
|
177
|
-
// leaves the real commands above the library.
|
|
178
194
|
return commands.concat(skills);
|
|
179
195
|
}
|
|
180
196
|
|
|
197
|
+
// Below this many characters a query is still a command prefix, not a skill search.
|
|
198
|
+
const SKILL_QUERY_MIN = 3;
|
|
199
|
+
|
|
181
200
|
/**
|
|
182
201
|
* A command's own argument suggestions.
|
|
183
202
|
*
|
|
@@ -401,7 +420,7 @@ export function suggest(text, cursor, options = {}) {
|
|
|
401
420
|
if (!trigger) return null;
|
|
402
421
|
|
|
403
422
|
if (trigger.kind === 'command') {
|
|
404
|
-
const items = rank(commandItems(), trigger.query);
|
|
423
|
+
const items = rank(commandItems(trigger.query), trigger.query);
|
|
405
424
|
if (items.length === 0) return null;
|
|
406
425
|
return { ...trigger, items, total: items.total };
|
|
407
426
|
}
|
|
@@ -130,6 +130,11 @@ export function handlePromptEscape(prompt, formatInterruptedRow) {
|
|
|
130
130
|
prompt.scheduleDraw();
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
|
+
if (prompt.usageCard) {
|
|
134
|
+
prompt.usageCard = null;
|
|
135
|
+
prompt.scheduleDraw();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
133
138
|
if (prompt.completion) {
|
|
134
139
|
prompt.completion = null;
|
|
135
140
|
if (prompt.editor.getText().startsWith('/')) {
|
|
@@ -183,6 +183,11 @@ export function handlePromptEscape(
|
|
|
183
183
|
prompt.scheduleDraw();
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
|
+
if ((prompt as any).usageCard) {
|
|
187
|
+
(prompt as any).usageCard = null;
|
|
188
|
+
prompt.scheduleDraw();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
186
191
|
if (prompt.completion) {
|
|
187
192
|
prompt.completion = null;
|
|
188
193
|
if (prompt.editor.getText().startsWith('/')) {
|
package/src/tui/layout.js
CHANGED
|
@@ -15,7 +15,7 @@ export function centerRows(rows, columns) {
|
|
|
15
15
|
/** Conversation content starts at the left margin while Home stays centered. */
|
|
16
16
|
export function sessionRows(rows, columns) {
|
|
17
17
|
const available = Number.isFinite(columns) ? Math.max(1, Math.floor(columns)) : 80;
|
|
18
|
-
const inset = Math.min(
|
|
18
|
+
const inset = Math.min(3, Math.max(0, available - 3));
|
|
19
19
|
const prefix = ' '.repeat(inset);
|
|
20
20
|
return {
|
|
21
21
|
rows: rows.map(row => row ? prefix + truncate(row, Math.max(1, available - inset - 1), '') : ''),
|
package/src/tui/layout.ts
CHANGED
|
@@ -18,7 +18,7 @@ export function centerRows(rows: string[], columns: number): { rows: string[]; i
|
|
|
18
18
|
/** Conversation content starts at the left margin while Home stays centered. */
|
|
19
19
|
export function sessionRows(rows: string[], columns: number): { rows: string[]; inset: number } {
|
|
20
20
|
const available = Number.isFinite(columns) ? Math.max(1, Math.floor(columns)) : 80;
|
|
21
|
-
const inset = Math.min(
|
|
21
|
+
const inset = Math.min(3, Math.max(0, available - 3));
|
|
22
22
|
const prefix = ' '.repeat(inset);
|
|
23
23
|
return {
|
|
24
24
|
rows: rows.map(row => row ? prefix + truncate(row, Math.max(1, available - inset - 1), '') : ''),
|
|
@@ -225,7 +225,7 @@ export function markHoveredMessage(rows, surface, contentWidth) {
|
|
|
225
225
|
continue;
|
|
226
226
|
const existingRow = rows[row] ?? '';
|
|
227
227
|
const plainTrimmed = stripAnsi(existingRow).trimStart();
|
|
228
|
-
const alreadyHasMarker =
|
|
228
|
+
const alreadyHasMarker = /^[▸│┃|▌┌└├╭╰▪●•]/.test(plainTrimmed);
|
|
229
229
|
const content = transcriptRow === firstContentRow && !alreadyHasMarker
|
|
230
230
|
? `${paint('accent', '▸')} ${truncate(existingRow, Math.max(0, contentWidth - 2), '')}`
|
|
231
231
|
: existingRow;
|
|
@@ -309,7 +309,7 @@ export function markHoveredMessage(
|
|
|
309
309
|
if (row < padding || row >= rows.length) continue;
|
|
310
310
|
const existingRow = rows[row] ?? '';
|
|
311
311
|
const plainTrimmed = stripAnsi(existingRow).trimStart();
|
|
312
|
-
const alreadyHasMarker =
|
|
312
|
+
const alreadyHasMarker = /^[▸│┃|▌┌└├╭╰▪●•]/.test(plainTrimmed);
|
|
313
313
|
const content = transcriptRow === firstContentRow && !alreadyHasMarker
|
|
314
314
|
? `${paint('accent', '▸')} ${truncate(existingRow, Math.max(0, contentWidth - 2), '')}`
|
|
315
315
|
: existingRow;
|