@causyne/agent 1.20.63 → 1.20.68
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 +23 -15
- package/src/agentLoop.ts +23 -15
- package/src/approvalPolicy.js +19 -0
- package/src/approvalPolicy.ts +18 -0
- package/src/browser/causyneBrowser.js +34 -4
- package/src/browser/causyneBrowser.ts +32 -4
- package/src/cliMode.js +65 -36
- package/src/commands.js +48 -19
- package/src/contextManager.js +1 -1
- package/src/continuum/ui/continuumPicker.js +1 -1
- package/src/continuum/ui/continuumPicker.ts +1 -1
- package/src/embodimentSession.js +1 -1
- package/src/planCache.js +1 -1
- package/src/planCache.ts +1 -1
- package/src/promptMentions.js +7 -7
- package/src/promptMentions.ts +7 -7
- package/src/providers/dashscope-byok.js +1 -1
- package/src/providers/qwen-byok.js +1 -1
- package/src/skillsManager.d.ts +4 -1
- package/src/tokenTracker.js +1 -1
- package/src/tokenTracker.ts +1 -1
- package/src/tool-scripts/ax_snapshot.ps1 +10 -10
- package/src/tools/fsList.js +1 -1
- package/src/tools/memoryWrite.js +1 -1
- package/src/tools/memoryWrite.ts +1 -1
- package/src/tui/chatRenderer.js +3 -2
- package/src/tui/codeStreamRenderer.js +8 -5
- package/src/tui/codeStreamRenderer.ts +10 -5
- package/src/tui/composerControls.js +2 -0
- package/src/tui/composerControls.ts +2 -0
- package/src/tui/dialogs.js +36 -4
- package/src/tui/lineEditor.js +14 -21
- package/src/tui/modelPicker.js +1 -1
- package/src/tui/modelPicker.ts +1 -1
- package/src/tui/prompt.js +48 -16
- package/src/tui/sessionPicker.js +1 -1
- package/src/tui/sessionPicker.ts +1 -1
- package/src/tui/sessionSidebar.js +13 -0
- package/src/tui/sessionSidebar.ts +15 -0
- package/src/tui/skillAuthoring.js +147 -0
- package/src/tui/skillAuthoring.ts +172 -0
- package/src/tui/stage.js +1 -1
- package/src/tui/stageSurface.js +8 -10
- package/src/tui/theme.js +3 -0
- package/src/vfeTracker.js +1 -1
- package/src/vfeTracker.ts +1 -1
package/src/tui/lineEditor.js
CHANGED
|
@@ -374,12 +374,14 @@ export class LineEditor {
|
|
|
374
374
|
|
|
375
375
|
let pos = 0;
|
|
376
376
|
while (pos <= line.length) {
|
|
377
|
-
if (
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
377
|
+
if (pos === line.length) {
|
|
378
|
+
if (isCurrentLine && pos === this.col && !placed) {
|
|
379
|
+
cursorRow = rows.length;
|
|
380
|
+
cursorCol = prefixWidth + used;
|
|
381
|
+
placed = true;
|
|
382
|
+
}
|
|
383
|
+
break;
|
|
381
384
|
}
|
|
382
|
-
if (pos === line.length) break;
|
|
383
385
|
|
|
384
386
|
const isSpace = /\s/.test(line[pos]);
|
|
385
387
|
let nextPos = pos;
|
|
@@ -389,24 +391,14 @@ export class LineEditor {
|
|
|
389
391
|
nextPos++;
|
|
390
392
|
}
|
|
391
393
|
|
|
392
|
-
// If non-whitespace word exceeds remaining space on non-empty line: wrap to next line!
|
|
394
|
+
// If non-whitespace word exceeds remaining space on non-empty line: wrap to next line first!
|
|
393
395
|
if (used > 0 && used + tokenWidth > budget && !isSpace) {
|
|
394
396
|
rows.push(row);
|
|
395
397
|
row = prefix;
|
|
396
398
|
used = 0;
|
|
397
|
-
if (isCurrentLine && pos === this.col && !placed) {
|
|
398
|
-
cursorRow = rows.length;
|
|
399
|
-
cursorCol = prefixWidth;
|
|
400
|
-
placed = true;
|
|
401
|
-
}
|
|
402
399
|
}
|
|
403
400
|
|
|
404
401
|
while (pos < nextPos) {
|
|
405
|
-
if (isCurrentLine && pos === this.col && !placed) {
|
|
406
|
-
cursorRow = rows.length;
|
|
407
|
-
cursorCol = prefixWidth + used;
|
|
408
|
-
placed = true;
|
|
409
|
-
}
|
|
410
402
|
const char = line[pos];
|
|
411
403
|
const charWidth = visibleWidth(char);
|
|
412
404
|
|
|
@@ -414,11 +406,12 @@ export class LineEditor {
|
|
|
414
406
|
rows.push(row);
|
|
415
407
|
row = prefix;
|
|
416
408
|
used = 0;
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (isCurrentLine && pos === this.col && !placed) {
|
|
412
|
+
cursorRow = rows.length;
|
|
413
|
+
cursorCol = prefixWidth + used;
|
|
414
|
+
placed = true;
|
|
422
415
|
}
|
|
423
416
|
|
|
424
417
|
const isSelected = range ? isInsideRange(index, pos, range) : false;
|
package/src/tui/modelPicker.js
CHANGED
|
@@ -367,7 +367,7 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
367
367
|
// Case 1: ACP Peer Agent or Antigravity
|
|
368
368
|
if (target.type === 'acp') {
|
|
369
369
|
if (!target.installed) {
|
|
370
|
-
return (
|
|
370
|
+
return (`△ Notice: "${target.providerLabel}" is not installed on this machine.\n` +
|
|
371
371
|
`Setup: ${target.setupInstruction || 'Install the CLI binary.'}\n\n` +
|
|
372
372
|
`Model was not changed.`);
|
|
373
373
|
}
|
package/src/tui/modelPicker.ts
CHANGED
|
@@ -468,7 +468,7 @@ export async function runInteractiveModelPicker(
|
|
|
468
468
|
if (target.type === 'acp') {
|
|
469
469
|
if (!target.installed) {
|
|
470
470
|
return (
|
|
471
|
-
|
|
471
|
+
`△ Notice: "${target.providerLabel}" is not installed on this machine.\n` +
|
|
472
472
|
`Setup: ${target.setupInstruction || 'Install the CLI binary.'}\n\n` +
|
|
473
473
|
`Model was not changed.`
|
|
474
474
|
);
|
package/src/tui/prompt.js
CHANGED
|
@@ -138,7 +138,7 @@ export class ChatPrompt {
|
|
|
138
138
|
this.cursorRow = 0;
|
|
139
139
|
|
|
140
140
|
// The status row of the live region, and the clock that animates it.
|
|
141
|
-
this.renderer = null;
|
|
141
|
+
this.renderer = options.renderer || null;
|
|
142
142
|
this.statusMessage = '';
|
|
143
143
|
this.tick = 0;
|
|
144
144
|
this.tickTimer = null;
|
|
@@ -421,6 +421,13 @@ export class ChatPrompt {
|
|
|
421
421
|
const plan = this.renderer && Array.isArray(this.renderer.latestPlan) ? this.renderer.latestPlan : [];
|
|
422
422
|
if (plan.length === 0) return [];
|
|
423
423
|
const completed = plan.filter(item => item.status === 'completed').length;
|
|
424
|
+
const stageMax = this.surface?.stage?.maxHeight || this.out?.rows || 24;
|
|
425
|
+
if (stageMax < 22) {
|
|
426
|
+
const activeStep = plan.find(item => item.status === 'in_progress') || plan.find(item => item.status !== 'completed') || plan[0];
|
|
427
|
+
const stepText = activeStep ? (activeStep.text || activeStep.step || '') : '';
|
|
428
|
+
const summary = `${paint('accent', GLYPHS.skill || '✦')} ${bold('plan')} ${dim(`(${completed}/${plan.length})`)} ${dim('·')} ${truncate(safeDisplay(stepText), Math.max(8, width - 24), GLYPHS.ellipsis)}`;
|
|
429
|
+
return [summary, ''];
|
|
430
|
+
}
|
|
424
431
|
const rows = [`${bold(paint('accent', 'implementation plan'))} ${dim(`${completed}/${plan.length}`)}`];
|
|
425
432
|
const limit = Math.min(plan.length, 5);
|
|
426
433
|
for (const item of plan.slice(0, limit)) {
|
|
@@ -672,9 +679,30 @@ export class ChatPrompt {
|
|
|
672
679
|
// Reading
|
|
673
680
|
// -------------------------------------------------------------------------
|
|
674
681
|
|
|
682
|
+
/**
|
|
683
|
+
* Render submitted user message into the chat transcript.
|
|
684
|
+
*/
|
|
685
|
+
renderSubmittedUserMessage(text) {
|
|
686
|
+
if (this.surface?.homeInfo) this.surface.leaveHome();
|
|
687
|
+
if (this.renderer?.renderUserMessage) this.renderer.renderUserMessage(text);
|
|
688
|
+
else this.commit('user', (width) => {
|
|
689
|
+
const blockWidth = Math.max(8, width);
|
|
690
|
+
return barBlock(
|
|
691
|
+
wrapBlock(safeDisplay(text), Math.max(8, blockWidth - visibleWidth(GLYPHS.barHeavy || GLYPHS.bar) - GUTTER), { hang: 0 }),
|
|
692
|
+
{ width: blockWidth, role: 'user', filled: true, surface: 'surfaceHi' }
|
|
693
|
+
);
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
|
|
675
697
|
/** Next submitted line. Resolves immediately if one was queued while busy. */
|
|
676
698
|
read() {
|
|
677
|
-
if (this.queue.length > 0)
|
|
699
|
+
if (this.queue.length > 0) {
|
|
700
|
+
const text = this.queue.shift();
|
|
701
|
+
if (typeof text === 'string' && !this.isCommand(text)) {
|
|
702
|
+
this.renderSubmittedUserMessage(text);
|
|
703
|
+
}
|
|
704
|
+
return Promise.resolve(text);
|
|
705
|
+
}
|
|
678
706
|
return new Promise((resolve) => { this.waiter = resolve; });
|
|
679
707
|
}
|
|
680
708
|
|
|
@@ -805,15 +833,9 @@ export class ChatPrompt {
|
|
|
805
833
|
}
|
|
806
834
|
|
|
807
835
|
// Render live submissions through the same path used when history reflows.
|
|
808
|
-
if (this.
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
const blockWidth = Math.max(8, width);
|
|
812
|
-
return barBlock(
|
|
813
|
-
wrapBlock(safeDisplay(text), Math.max(8, blockWidth - visibleWidth(GLYPHS.barHeavy || GLYPHS.bar) - GUTTER), { hang: 0 }),
|
|
814
|
-
{ width: blockWidth, role: 'user', filled: true, surface: 'surfaceHi' }
|
|
815
|
-
);
|
|
816
|
-
});
|
|
836
|
+
if (!this.isCommand(text)) {
|
|
837
|
+
this.renderSubmittedUserMessage(text);
|
|
838
|
+
}
|
|
817
839
|
const resolve = this.waiter;
|
|
818
840
|
this.waiter = null;
|
|
819
841
|
if (resolve) resolve(text);
|
|
@@ -896,11 +918,12 @@ export class ChatPrompt {
|
|
|
896
918
|
if (this.completion && this.handleCompletionKey(key)) return;
|
|
897
919
|
if (this.handleScrollKey(key)) return;
|
|
898
920
|
|
|
899
|
-
const
|
|
921
|
+
const isModeControl = Boolean(key.ctrl && key.name === 'g');
|
|
922
|
+
const control = isModeControl ? this.onOpenMode
|
|
900
923
|
: key.alt && key.name === 'm' ? this.onOpenModel
|
|
901
924
|
: key.ctrl && key.name === 't' ? this.onOpenVariant : null;
|
|
902
925
|
if (control) {
|
|
903
|
-
if (this.busy) {
|
|
926
|
+
if (this.busy && !isModeControl) {
|
|
904
927
|
this.notice = 'Finish or interrupt the current turn before switching controls';
|
|
905
928
|
this.scheduleDraw();
|
|
906
929
|
} else {
|
|
@@ -915,7 +938,7 @@ export class ChatPrompt {
|
|
|
915
938
|
switch (key.name) {
|
|
916
939
|
case 'escape': return this.handleEscape();
|
|
917
940
|
case 'enter':
|
|
918
|
-
if (key.alt) { this.editor.newline(); return; }
|
|
941
|
+
if (key.alt || key.shift) { this.editor.newline(); return; }
|
|
919
942
|
return this.submit();
|
|
920
943
|
case 'tab':
|
|
921
944
|
if (key.shift) return;
|
|
@@ -1690,13 +1713,22 @@ export class ChatPrompt {
|
|
|
1690
1713
|
const inline = this.surface && !this.surface.homeInfo;
|
|
1691
1714
|
const availableWidth = inline ? sessionMainWidth(this.surface.width) : width;
|
|
1692
1715
|
const panelWidth = dialogWidth(availableWidth, this.layer.width || 64);
|
|
1693
|
-
const
|
|
1716
|
+
const stageMax = this.surface?.stage?.maxHeight || this.out?.rows || 24;
|
|
1717
|
+
const statusReserve = 2; // status row + margin
|
|
1718
|
+
const availableDialogRows = Math.max(4, stageMax - statusReserve);
|
|
1719
|
+
const maxHeight = dialogHeight(availableDialogRows, this.layer.preferredHeight());
|
|
1694
1720
|
const panel = panelRows(this.layer, panelWidth, maxHeight);
|
|
1695
|
-
const
|
|
1721
|
+
const status = this.statusRow(width);
|
|
1722
|
+
const all = this.clampRows(panel.concat(status), width);
|
|
1696
1723
|
|
|
1697
1724
|
// panelRows() called body(), which is where a layer publishes its cursor.
|
|
1698
1725
|
const cursor = this.layer.cursor;
|
|
1699
1726
|
const centered = this.surface ? centerRows(all, availableWidth) : { rows: all, inset: 0 };
|
|
1727
|
+
const stageHeight = this.surface?.stage?.height || this.out?.rows || all.length;
|
|
1728
|
+
this.layer.panelGeometry = {
|
|
1729
|
+
inset: centered.inset,
|
|
1730
|
+
optionScreenRow: stageHeight - status.length - 1
|
|
1731
|
+
};
|
|
1700
1732
|
this.present(centered.rows, cursor ? 1 + cursor.y : 0,
|
|
1701
1733
|
(cursor ? 2 + cursor.x : 0) + centered.inset);
|
|
1702
1734
|
}
|
package/src/tui/sessionPicker.js
CHANGED
|
@@ -244,7 +244,7 @@ export async function runInteractiveSessionPicker(prompt, options = {}) {
|
|
|
244
244
|
}
|
|
245
245
|
if (!switched) {
|
|
246
246
|
cleanPrompt();
|
|
247
|
-
return
|
|
247
|
+
return `△ Could not switch to session "${targetId}". File may have been removed.`;
|
|
248
248
|
}
|
|
249
249
|
const historyMessages = options.loop?.memoryManager && typeof options.loop.memoryManager.loadHistory === 'function'
|
|
250
250
|
? options.loop.memoryManager.loadHistory()
|
package/src/tui/sessionPicker.ts
CHANGED
|
@@ -323,7 +323,7 @@ export async function runInteractiveSessionPicker(
|
|
|
323
323
|
|
|
324
324
|
if (!switched) {
|
|
325
325
|
cleanPrompt();
|
|
326
|
-
return
|
|
326
|
+
return `△ Could not switch to session "${targetId}". File may have been removed.`;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
const historyMessages = options.loop?.memoryManager && typeof options.loop.memoryManager.loadHistory === 'function'
|
|
@@ -61,6 +61,19 @@ export function sessionSidebarRows(facts, height) {
|
|
|
61
61
|
line();
|
|
62
62
|
styled(bold('Workspace'));
|
|
63
63
|
line(facts.cwd || 'Unknown');
|
|
64
|
+
if (facts.activeSkill) {
|
|
65
|
+
const raw = facts.activeSkill;
|
|
66
|
+
const skillId = typeof raw === 'string' ? raw : (raw.id || raw.name || '');
|
|
67
|
+
const skillDesc = typeof raw === 'object' && raw ? raw.description || '' : '';
|
|
68
|
+
if (skillId) {
|
|
69
|
+
line();
|
|
70
|
+
styled(bold('Active Skill'));
|
|
71
|
+
styled(paint('accent', `✦ ${truncate(skillId, inner - 4, '…')}`));
|
|
72
|
+
if (skillDesc) {
|
|
73
|
+
line(truncate(skillDesc, inner, '…'));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
64
77
|
if (facts.plan?.length) {
|
|
65
78
|
const completed = facts.plan.filter(item => item.status === 'completed').length;
|
|
66
79
|
line();
|
|
@@ -15,6 +15,7 @@ export interface SidebarFacts {
|
|
|
15
15
|
contextChars?: number;
|
|
16
16
|
contextLimit?: number;
|
|
17
17
|
plan?: Array<{ text?: string; step?: string; content?: string; status?: string }>;
|
|
18
|
+
activeSkill?: { id?: string; name?: string; domain?: string; description?: string } | string | null;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
/** A side panel is useful only when a readable conversation column remains. */
|
|
@@ -76,6 +77,20 @@ export function sessionSidebarRows(facts: SidebarFacts, height: number): string[
|
|
|
76
77
|
styled(bold('Workspace'));
|
|
77
78
|
line(facts.cwd || 'Unknown');
|
|
78
79
|
|
|
80
|
+
if (facts.activeSkill) {
|
|
81
|
+
const raw = facts.activeSkill;
|
|
82
|
+
const skillId = typeof raw === 'string' ? raw : (raw.id || raw.name || '');
|
|
83
|
+
const skillDesc = typeof raw === 'object' && raw ? raw.description || '' : '';
|
|
84
|
+
if (skillId) {
|
|
85
|
+
line();
|
|
86
|
+
styled(bold('Active Skill'));
|
|
87
|
+
styled(paint('accent', `✦ ${truncate(skillId, inner - 4, '…')}`));
|
|
88
|
+
if (skillDesc) {
|
|
89
|
+
line(truncate(skillDesc, inner, '…'));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
79
94
|
if (facts.plan?.length) {
|
|
80
95
|
const completed = facts.plan.filter(item => item.status === 'completed').length;
|
|
81
96
|
line();
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// @ts-expect-error userSkills.js is awaiting TypeScript migration.
|
|
2
|
+
import { writeUserSkill, validateSegment, skillTemplate } from '../userSkills.js';
|
|
3
|
+
import { invalidateUserSkills } from '../skillsManager.js';
|
|
4
|
+
// @ts-expect-error theme.js has no TypeScript declaration yet.
|
|
5
|
+
import { paint, bold, dim } from './theme.js';
|
|
6
|
+
// @ts-expect-error dialogs.js is awaiting TypeScript migration.
|
|
7
|
+
import { InputLayer, SelectLayer } from './dialogs.js';
|
|
8
|
+
const COMMON_DOMAINS = [
|
|
9
|
+
{ value: 'custom', label: 'custom', description: 'General project & personal workflow skills' },
|
|
10
|
+
{ value: 'engineering', label: 'engineering', description: 'Software architecture, refactoring & review' },
|
|
11
|
+
{ value: 'frontend', label: 'frontend', description: 'Web UI, CSS, React, components & layout' },
|
|
12
|
+
{ value: 'backend', label: 'backend', description: 'APIs, databases, server infrastructure' },
|
|
13
|
+
{ value: 'devops', label: 'devops', description: 'CI/CD, Docker, deployment & releases' },
|
|
14
|
+
{ value: 'testing', label: 'testing', description: 'Unit, integration & regression tests' },
|
|
15
|
+
{ value: 'mobile', label: 'mobile', description: 'Android, iOS, Flutter, React Native' },
|
|
16
|
+
{ value: '__other__', label: '+ Enter custom category...', description: 'Specify any category name' }
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Interactive wizard hosted on ChatPrompt to scaffold and create a new skill.
|
|
20
|
+
*/
|
|
21
|
+
export async function runInteractiveSkillWizard(prompt) {
|
|
22
|
+
// Step 1: Select or enter domain/category
|
|
23
|
+
const chosenDomain = await new Promise((resolve) => {
|
|
24
|
+
let resolved = false;
|
|
25
|
+
const finish = (val) => {
|
|
26
|
+
if (!resolved) {
|
|
27
|
+
resolved = true;
|
|
28
|
+
resolve(val);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const layer = new SelectLayer({
|
|
32
|
+
title: 'create skill · category',
|
|
33
|
+
placeholder: 'choose or type category',
|
|
34
|
+
items: COMMON_DOMAINS,
|
|
35
|
+
width: 72,
|
|
36
|
+
height: 14,
|
|
37
|
+
onPick: (item) => {
|
|
38
|
+
finish(item?.value || null);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
prompt.openLayer(layer);
|
|
42
|
+
});
|
|
43
|
+
if (!chosenDomain)
|
|
44
|
+
return null;
|
|
45
|
+
let domain = chosenDomain;
|
|
46
|
+
if (domain === '__other__') {
|
|
47
|
+
const customDomain = await new Promise((resolve) => {
|
|
48
|
+
let resolved = false;
|
|
49
|
+
const finish = (val) => {
|
|
50
|
+
if (!resolved) {
|
|
51
|
+
resolved = true;
|
|
52
|
+
resolve(val);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const layer = new InputLayer({
|
|
56
|
+
title: 'create skill · category name',
|
|
57
|
+
lines: ['Category / domain name (e.g. data, analytics, cloud, tools):'],
|
|
58
|
+
placeholder: 'category-name',
|
|
59
|
+
onSubmit: (val) => finish(val.trim().toLowerCase()),
|
|
60
|
+
onCancel: () => finish(null)
|
|
61
|
+
});
|
|
62
|
+
prompt.openLayer(layer);
|
|
63
|
+
});
|
|
64
|
+
if (!customDomain)
|
|
65
|
+
return null;
|
|
66
|
+
const err = validateSegment(customDomain, 'category');
|
|
67
|
+
if (err) {
|
|
68
|
+
if (typeof prompt.showText === 'function') {
|
|
69
|
+
prompt.showText('Invalid Category', err, { danger: true });
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
domain = customDomain;
|
|
74
|
+
}
|
|
75
|
+
// Step 2: Skill name
|
|
76
|
+
const skillName = await new Promise((resolve) => {
|
|
77
|
+
let resolved = false;
|
|
78
|
+
const finish = (val) => {
|
|
79
|
+
if (!resolved) {
|
|
80
|
+
resolved = true;
|
|
81
|
+
resolve(val);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const layer = new InputLayer({
|
|
85
|
+
title: 'create skill · name',
|
|
86
|
+
lines: [
|
|
87
|
+
`Category: ${paint('accent', domain)}`,
|
|
88
|
+
'Skill name (lowercase letters, numbers, hyphens — e.g. play-store-release, pr-review):'
|
|
89
|
+
],
|
|
90
|
+
placeholder: 'my-new-skill',
|
|
91
|
+
onSubmit: (val) => finish(val.trim().toLowerCase()),
|
|
92
|
+
onCancel: () => finish(null)
|
|
93
|
+
});
|
|
94
|
+
prompt.openLayer(layer);
|
|
95
|
+
});
|
|
96
|
+
if (!skillName)
|
|
97
|
+
return null;
|
|
98
|
+
const nameErr = validateSegment(skillName, 'skill name');
|
|
99
|
+
if (nameErr) {
|
|
100
|
+
if (typeof prompt.showText === 'function') {
|
|
101
|
+
prompt.showText('Invalid Skill Name', nameErr, { danger: true });
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
// Step 3: Skill description
|
|
106
|
+
const skillDesc = await new Promise((resolve) => {
|
|
107
|
+
let resolved = false;
|
|
108
|
+
const finish = (val) => {
|
|
109
|
+
if (!resolved) {
|
|
110
|
+
resolved = true;
|
|
111
|
+
resolve(val);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const layer = new InputLayer({
|
|
115
|
+
title: 'create skill · description',
|
|
116
|
+
lines: [
|
|
117
|
+
`Skill: ${paint('accent', `${domain}/${skillName}`)}`,
|
|
118
|
+
'Short description: what this skill does and when the agent should use it:'
|
|
119
|
+
],
|
|
120
|
+
placeholder: 'e.g. Prepares and validates Android app bundles for Google Play Store release.',
|
|
121
|
+
onSubmit: (val) => finish(val.trim()),
|
|
122
|
+
onCancel: () => finish(null)
|
|
123
|
+
});
|
|
124
|
+
prompt.openLayer(layer);
|
|
125
|
+
});
|
|
126
|
+
if (!skillDesc)
|
|
127
|
+
return null;
|
|
128
|
+
// Step 4: Write skill file
|
|
129
|
+
const content = skillTemplate(domain, skillName, skillDesc);
|
|
130
|
+
const written = writeUserSkill({ domain, name: skillName, content, overwrite: false });
|
|
131
|
+
if (!written.ok) {
|
|
132
|
+
if (typeof prompt.showText === 'function') {
|
|
133
|
+
prompt.showText('Skill Creation Failed', written.error || 'Failed to write skill file', { danger: true });
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
invalidateUserSkills();
|
|
138
|
+
return {
|
|
139
|
+
domain,
|
|
140
|
+
id: skillName,
|
|
141
|
+
name: skillName,
|
|
142
|
+
description: skillDesc,
|
|
143
|
+
content,
|
|
144
|
+
path: written.path,
|
|
145
|
+
source: 'user'
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// @ts-expect-error userSkills.js is awaiting TypeScript migration.
|
|
2
|
+
import { writeUserSkill, validateSegment, skillTemplate } from '../userSkills.js';
|
|
3
|
+
import { invalidateUserSkills } from '../skillsManager.js';
|
|
4
|
+
// @ts-expect-error theme.js has no TypeScript declaration yet.
|
|
5
|
+
import { paint, bold, dim } from './theme.js';
|
|
6
|
+
// @ts-expect-error dialogs.js is awaiting TypeScript migration.
|
|
7
|
+
import { InputLayer, SelectLayer } from './dialogs.js';
|
|
8
|
+
// @ts-expect-error prompt.js is awaiting TypeScript migration.
|
|
9
|
+
import type { ChatPrompt } from './prompt.js';
|
|
10
|
+
|
|
11
|
+
export interface CreatedUserSkill {
|
|
12
|
+
domain: string;
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
content: string;
|
|
17
|
+
path?: string;
|
|
18
|
+
source: 'user';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface CommonDomainChoice {
|
|
22
|
+
value: string;
|
|
23
|
+
label: string;
|
|
24
|
+
description: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const COMMON_DOMAINS: CommonDomainChoice[] = [
|
|
28
|
+
{ value: 'custom', label: 'custom', description: 'General project & personal workflow skills' },
|
|
29
|
+
{ value: 'engineering', label: 'engineering', description: 'Software architecture, refactoring & review' },
|
|
30
|
+
{ value: 'frontend', label: 'frontend', description: 'Web UI, CSS, React, components & layout' },
|
|
31
|
+
{ value: 'backend', label: 'backend', description: 'APIs, databases, server infrastructure' },
|
|
32
|
+
{ value: 'devops', label: 'devops', description: 'CI/CD, Docker, deployment & releases' },
|
|
33
|
+
{ value: 'testing', label: 'testing', description: 'Unit, integration & regression tests' },
|
|
34
|
+
{ value: 'mobile', label: 'mobile', description: 'Android, iOS, Flutter, React Native' },
|
|
35
|
+
{ value: '__other__', label: '+ Enter custom category...', description: 'Specify any category name' }
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Interactive wizard hosted on ChatPrompt to scaffold and create a new skill.
|
|
40
|
+
*/
|
|
41
|
+
export async function runInteractiveSkillWizard(prompt: ChatPrompt): Promise<CreatedUserSkill | null> {
|
|
42
|
+
// Step 1: Select or enter domain/category
|
|
43
|
+
const chosenDomain = await new Promise<string | null>((resolve) => {
|
|
44
|
+
let resolved = false;
|
|
45
|
+
const finish = (val: string | null): void => {
|
|
46
|
+
if (!resolved) {
|
|
47
|
+
resolved = true;
|
|
48
|
+
resolve(val);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const layer = new SelectLayer({
|
|
52
|
+
title: 'create skill · category',
|
|
53
|
+
placeholder: 'choose or type category',
|
|
54
|
+
items: COMMON_DOMAINS,
|
|
55
|
+
width: 72,
|
|
56
|
+
height: 14,
|
|
57
|
+
onPick: (item: { value?: string } | null) => {
|
|
58
|
+
finish(item?.value || null);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
prompt.openLayer(layer);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (!chosenDomain) return null;
|
|
65
|
+
|
|
66
|
+
let domain = chosenDomain;
|
|
67
|
+
if (domain === '__other__') {
|
|
68
|
+
const customDomain = await new Promise<string | null>((resolve) => {
|
|
69
|
+
let resolved = false;
|
|
70
|
+
const finish = (val: string | null): void => {
|
|
71
|
+
if (!resolved) {
|
|
72
|
+
resolved = true;
|
|
73
|
+
resolve(val);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const layer = new InputLayer({
|
|
77
|
+
title: 'create skill · category name',
|
|
78
|
+
lines: ['Category / domain name (e.g. data, analytics, cloud, tools):'],
|
|
79
|
+
placeholder: 'category-name',
|
|
80
|
+
onSubmit: (val: string) => finish(val.trim().toLowerCase()),
|
|
81
|
+
onCancel: () => finish(null)
|
|
82
|
+
});
|
|
83
|
+
prompt.openLayer(layer);
|
|
84
|
+
});
|
|
85
|
+
if (!customDomain) return null;
|
|
86
|
+
const err = validateSegment(customDomain, 'category');
|
|
87
|
+
if (err) {
|
|
88
|
+
if (typeof prompt.showText === 'function') {
|
|
89
|
+
prompt.showText('Invalid Category', err, { danger: true });
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
domain = customDomain;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Step 2: Skill name
|
|
97
|
+
const skillName = await new Promise<string | null>((resolve) => {
|
|
98
|
+
let resolved = false;
|
|
99
|
+
const finish = (val: string | null): void => {
|
|
100
|
+
if (!resolved) {
|
|
101
|
+
resolved = true;
|
|
102
|
+
resolve(val);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const layer = new InputLayer({
|
|
106
|
+
title: 'create skill · name',
|
|
107
|
+
lines: [
|
|
108
|
+
`Category: ${paint('accent', domain)}`,
|
|
109
|
+
'Skill name (lowercase letters, numbers, hyphens — e.g. play-store-release, pr-review):'
|
|
110
|
+
],
|
|
111
|
+
placeholder: 'my-new-skill',
|
|
112
|
+
onSubmit: (val: string) => finish(val.trim().toLowerCase()),
|
|
113
|
+
onCancel: () => finish(null)
|
|
114
|
+
});
|
|
115
|
+
prompt.openLayer(layer);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
if (!skillName) return null;
|
|
119
|
+
const nameErr = validateSegment(skillName, 'skill name');
|
|
120
|
+
if (nameErr) {
|
|
121
|
+
if (typeof prompt.showText === 'function') {
|
|
122
|
+
prompt.showText('Invalid Skill Name', nameErr, { danger: true });
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Step 3: Skill description
|
|
128
|
+
const skillDesc = await new Promise<string | null>((resolve) => {
|
|
129
|
+
let resolved = false;
|
|
130
|
+
const finish = (val: string | null): void => {
|
|
131
|
+
if (!resolved) {
|
|
132
|
+
resolved = true;
|
|
133
|
+
resolve(val);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const layer = new InputLayer({
|
|
137
|
+
title: 'create skill · description',
|
|
138
|
+
lines: [
|
|
139
|
+
`Skill: ${paint('accent', `${domain}/${skillName}`)}`,
|
|
140
|
+
'Short description: what this skill does and when the agent should use it:'
|
|
141
|
+
],
|
|
142
|
+
placeholder: 'e.g. Prepares and validates Android app bundles for Google Play Store release.',
|
|
143
|
+
onSubmit: (val: string) => finish(val.trim()),
|
|
144
|
+
onCancel: () => finish(null)
|
|
145
|
+
});
|
|
146
|
+
prompt.openLayer(layer);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
if (!skillDesc) return null;
|
|
150
|
+
|
|
151
|
+
// Step 4: Write skill file
|
|
152
|
+
const content = skillTemplate(domain, skillName, skillDesc);
|
|
153
|
+
const written = writeUserSkill({ domain, name: skillName, content, overwrite: false });
|
|
154
|
+
if (!written.ok) {
|
|
155
|
+
if (typeof prompt.showText === 'function') {
|
|
156
|
+
prompt.showText('Skill Creation Failed', written.error || 'Failed to write skill file', { danger: true });
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
invalidateUserSkills();
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
domain,
|
|
165
|
+
id: skillName,
|
|
166
|
+
name: skillName,
|
|
167
|
+
description: skillDesc,
|
|
168
|
+
content,
|
|
169
|
+
path: written.path,
|
|
170
|
+
source: 'user'
|
|
171
|
+
};
|
|
172
|
+
}
|
package/src/tui/stage.js
CHANGED
|
@@ -246,7 +246,7 @@ export class Stage {
|
|
|
246
246
|
this.moveTo(target.row);
|
|
247
247
|
this.write('\r');
|
|
248
248
|
if (target.col > 0) this.write(`\x1b[${target.col}C`);
|
|
249
|
-
this.write((target.hideCursor ? HIDE_CURSOR : SHOW_CURSOR
|
|
249
|
+
this.write((target.hideCursor ? HIDE_CURSOR : SHOW_CURSOR + '\x1b[6 q') + SYNC_OFF);
|
|
250
250
|
|
|
251
251
|
this.prev = next;
|
|
252
252
|
this.caret = target;
|
package/src/tui/stageSurface.js
CHANGED
|
@@ -417,15 +417,12 @@ export class StageSurface {
|
|
|
417
417
|
|
|
418
418
|
const height = this.stage.height;
|
|
419
419
|
|
|
420
|
-
//
|
|
421
|
-
//
|
|
422
|
-
//
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
? Math.max(MIN_VIEWPORT_ROWS, this.messageActionOverlay?.panel.length || 0)
|
|
427
|
-
: 0;
|
|
428
|
-
const maxBlock = Math.max(1, height - floor);
|
|
420
|
+
// An active prompt block or modal dialog is the focal point of user interaction.
|
|
421
|
+
// Never slice the top border, title, or input area when the block fits within the stage height.
|
|
422
|
+
// The transcript viewport receives the remaining vertical budget (height - block.length).
|
|
423
|
+
const maxBlock = this.messageActionOverlay?.panel.length
|
|
424
|
+
? Math.max(1, height - this.messageActionOverlay.panel.length)
|
|
425
|
+
: height;
|
|
429
426
|
if (block.length > maxBlock) {
|
|
430
427
|
const cut = block.length - maxBlock;
|
|
431
428
|
block = block.slice(cut);
|
|
@@ -496,7 +493,8 @@ export class StageSurface {
|
|
|
496
493
|
model: this.sidebarStatus?.model || this.sessionInfo?.model,
|
|
497
494
|
contextChars: this.sidebarStatus?.contextChars,
|
|
498
495
|
contextLimit: this.sidebarStatus?.contextLimit,
|
|
499
|
-
plan: this.sidebarPlan
|
|
496
|
+
plan: this.sidebarPlan,
|
|
497
|
+
activeSkill: this.sessionInfo?.activeSkill
|
|
500
498
|
}, mainRows.length) : [];
|
|
501
499
|
const painted = sidebar ? joinSessionSidebar(mainRows, panelRows, mainWidth) : mainRows;
|
|
502
500
|
return this.stage.paint(painted, {
|
package/src/tui/theme.js
CHANGED
|
@@ -254,6 +254,8 @@ export const GLYPHS = HAS_UNICODE
|
|
|
254
254
|
// The left accent bar of a block. Uses box-drawing heavy vertical ('┃')
|
|
255
255
|
// so it joins seamlessly from row to row without font line-height leading gaps.
|
|
256
256
|
bar: '┃', step: '▪',
|
|
257
|
+
// Clean icon glyphs for skills and status indicators (no color emoticons).
|
|
258
|
+
skill: '✦', sparkle: '✦', diamond: '◆',
|
|
257
259
|
// The permission marker. opencode shows a warning triangle and NO risk
|
|
258
260
|
// word — the level is internal plumbing, and printing 'DANGEROUS' at
|
|
259
261
|
// someone just makes them numb to it. Colour still carries the tier.
|
|
@@ -272,6 +274,7 @@ export const GLYPHS = HAS_UNICODE
|
|
|
272
274
|
spinner: getEngineFrames({ unicode: false }),
|
|
273
275
|
hLine: '-', vLine: '|', corner: '`', tee: '+', ellipsis: '...',
|
|
274
276
|
bar: '|', step: '*',
|
|
277
|
+
skill: '*', sparkle: '*', diamond: '*',
|
|
275
278
|
warnMark: '!',
|
|
276
279
|
barHeavy: '|',
|
|
277
280
|
topLeft: '+', topRight: '+', bottomLeft: '+', bottomRight: '+'
|
package/src/vfeTracker.js
CHANGED
|
@@ -150,7 +150,7 @@ export class VFETracker {
|
|
|
150
150
|
* Format the high-priority paradigm shift prompt directive.
|
|
151
151
|
*/
|
|
152
152
|
getParadigmShiftDirective() {
|
|
153
|
-
return (`\n\n
|
|
153
|
+
return (`\n\n△ [PARADIGM SHIFT REQUIRED — ACTIVE INFERENCE DEADLOCK DETECTED]\n` +
|
|
154
154
|
`Variational Free Energy tracking detected a persistent error plateau with zero convergence.\n` +
|
|
155
155
|
`Your current mental model and execution route are trapped in a local minimum.\n` +
|
|
156
156
|
`DO NOT retry previous variations, tweak parameters, or repeat failed commands.\n` +
|