@causyne/agent 1.19.0 → 1.20.5
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/README.md +0 -18
- package/package.json +1 -1
- package/src/acp/client.js +2 -1
- package/src/acp/client.ts +2 -1
- package/src/acp/server.js +5 -6
- package/src/acp/server.ts +4 -6
- package/src/agentLoop.d.ts +1 -0
- package/src/agentLoop.js +505 -241
- package/src/agentLoop.ts +527 -258
- package/src/agentPolicy.js +9 -0
- package/src/agentPolicy.ts +9 -0
- package/src/approvalPolicy.js +55 -0
- package/src/approvalPolicy.ts +66 -0
- package/src/browser/browserRuntime.js +217 -14
- package/src/browser/browserRuntime.ts +255 -14
- package/src/browser/causyneBrowser.js +1215 -68
- package/src/browser/causyneBrowser.ts +1340 -72
- package/src/cliMode.js +66 -37
- package/src/commands.js +343 -72
- package/src/config.js +22 -12
- package/src/continuum/ingest.js +1 -1
- package/src/continuum/ingest.ts +1 -1
- package/src/continuum/ui/continuumPicker.js +18 -1
- package/src/continuum/ui/continuumPicker.ts +19 -1
- package/src/dynamicCatalogue.js +87 -20
- package/src/dynamicCatalogue.ts +85 -15
- package/src/launchIntent.js +40 -0
- package/src/launchIntent.ts +49 -0
- package/src/memoryManager.js +36 -8
- package/src/modelCatalogue.js +2 -0
- package/src/planCache.js +320 -11
- package/src/planCache.ts +402 -13
- package/src/providers/acp.js +67 -1
- package/src/providers/acp.ts +65 -2
- package/src/providers/antigravity.d.ts +5 -1
- package/src/providers/antigravity.js +643 -32
- package/src/providers/antigravity.ts +671 -33
- package/src/providers/base.d.ts +9 -0
- package/src/providers/factory.js +2 -0
- package/src/providers/pi.js +157 -0
- package/src/providers/pi.ts +144 -0
- package/src/provisioning/capabilityProvisioner.js +17 -0
- package/src/provisioning/capabilityTools.js +1 -1
- package/src/sandbox.js +30 -39
- package/src/sessionJournal.js +66 -10
- package/src/sessionJournal.ts +84 -10
- package/src/taskShape.js +9 -9
- package/src/taskShape.ts +9 -9
- package/src/timeMachine.js +124 -0
- package/src/timeMachine.ts +141 -0
- package/src/toolPacks.js +4 -10
- package/src/tools/archive.js +196 -59
- package/src/tools/archive.ts +220 -0
- package/src/tools/browserAutomator.js +78 -9
- package/src/tools/browserAutomator.ts +90 -9
- package/src/tools/desktopOpen.js +114 -31
- package/src/tools/desktopOpen.ts +144 -0
- package/src/tools/gitExec.js +5 -3
- package/src/tools/nativeEngine.js +4 -3
- package/src/tools/nativeEngine.ts +5 -3
- package/src/tools/openSourceToolProvisioner.js +5 -4
- package/src/tools/openSourceToolProvisioner.ts +5 -4
- package/src/tools/registry.js +3 -0
- package/src/tools/screenshot.js +55 -71
- package/src/tools/screenshot.ts +70 -0
- package/src/tools/sysRun.js +284 -117
- package/src/tools/sysRun.ts +347 -0
- package/src/tools/toolSelfRepair.js +109 -2
- package/src/tools/toolSelfRepair.ts +100 -2
- package/src/tools/updatePlan.js +49 -1
- package/src/tools/updatePlan.ts +43 -1
- package/src/tools/viewImage.js +93 -78
- package/src/tools/viewImage.ts +116 -0
- package/src/tools/webFetch.js +20 -6
- package/src/tools/webFetch.ts +26 -6
- package/src/tui/block.d.ts +1 -0
- package/src/tui/chatRenderer.d.ts +21 -0
- package/src/tui/chatRenderer.js +118 -45
- package/src/tui/clipboardSync.js +28 -1
- package/src/tui/clipboardSync.ts +26 -1
- package/src/tui/codeProgress.js +299 -0
- package/src/tui/codeProgress.ts +304 -0
- package/src/tui/codeStreamRenderer.js +116 -0
- package/src/tui/codeStreamRenderer.ts +124 -0
- package/src/tui/commandPresentation.js +11 -0
- package/src/tui/commandPresentation.ts +18 -0
- package/src/tui/completion.js +45 -13
- package/src/tui/composerControls.js +66 -0
- package/src/tui/composerControls.ts +78 -0
- package/src/tui/diff.d.ts +2 -0
- package/src/tui/home.js +4 -2
- package/src/tui/homeTransition.js +21 -0
- package/src/tui/homeTransition.ts +27 -0
- package/src/tui/homeView.js +62 -0
- package/src/tui/homeView.ts +91 -0
- package/src/tui/layout.js +46 -0
- package/src/tui/layout.ts +52 -0
- package/src/tui/messageActionPlacement.js +16 -0
- package/src/tui/messageActionPlacement.ts +25 -0
- package/src/tui/messageInteraction.js +221 -0
- package/src/tui/messageInteraction.ts +275 -0
- package/src/tui/modelPicker.js +13 -0
- package/src/tui/modelPicker.ts +12 -0
- package/src/tui/mouseHover.js +6 -0
- package/src/tui/mouseHover.ts +5 -0
- package/src/tui/prompt.js +199 -52
- package/src/tui/resizeRecovery.js +15 -0
- package/src/tui/resizeRecovery.ts +27 -0
- package/src/tui/scrollInteraction.js +97 -0
- package/src/tui/scrollInteraction.ts +189 -0
- package/src/tui/sessionLayout.js +12 -0
- package/src/tui/sessionLayout.ts +12 -0
- package/src/tui/sessionPicker.js +280 -0
- package/src/tui/sessionPicker.ts +364 -0
- package/src/tui/sessionSidebar.js +78 -0
- package/src/tui/sessionSidebar.ts +95 -0
- package/src/tui/setup.js +1 -1
- package/src/tui/setup.ts +1 -1
- package/src/tui/stageSurface.js +128 -57
- package/src/tui/statusLine.js +5 -5
- package/src/tui/text.d.ts +5 -0
- package/src/tui/textLayout.js +23 -0
- package/src/tui/textLayout.ts +28 -0
- package/src/tui/viewport.js +204 -279
- package/src/tui/viewport.ts +326 -0
- package/src/types/contracts.ts +54 -0
- package/src/utils/paths.js +5 -4
- package/src/utils/paths.ts +5 -5
package/src/commands.js
CHANGED
|
@@ -21,8 +21,9 @@ import {
|
|
|
21
21
|
import { buildContextText, buildUsageText, buildCheckpointsText, buildUndoText, buildStatusText } from './reporting.js';
|
|
22
22
|
import { loadConfig, saveConfig } from './config.js';
|
|
23
23
|
import { resolveAvailableModels, getCuratedModels, getAvailableProvidersOverview } from './dynamicCatalogue.js';
|
|
24
|
-
import { DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
|
|
24
|
+
import { DEFAULT_MODEL_BY_PROVIDER, PEER_MODEL_CATALOGUE } from './modelCatalogue.js';
|
|
25
25
|
import { isAcpProvider } from './providers/acp.js';
|
|
26
|
+
import { listSessions, getActiveSessionId } from './sessionStore.js';
|
|
26
27
|
import {
|
|
27
28
|
serverStatus, grantServer, revokeServer, addServer, removeServer,
|
|
28
29
|
connectServer, disconnectServer, refreshServer
|
|
@@ -581,30 +582,167 @@ export const COMMANDS = [
|
|
|
581
582
|
}
|
|
582
583
|
},
|
|
583
584
|
|
|
585
|
+
{
|
|
586
|
+
name: 'new',
|
|
587
|
+
aliases: ['new-session'],
|
|
588
|
+
scope: 'local',
|
|
589
|
+
usage: '/new',
|
|
590
|
+
description: 'Start a new clean chat session in this workspace',
|
|
591
|
+
dialogTitle: 'New Session',
|
|
592
|
+
run: async (_args = [], context = {}) => {
|
|
593
|
+
const store = await import('./sessionStore.js');
|
|
594
|
+
const memory = context.loop && context.loop.memoryManager;
|
|
595
|
+
const workspace = context.loop?.workspaceRoot || process.cwd();
|
|
596
|
+
const next = memory ? memory.startNewSession('Untitled') : store.createSession(workspace, 'Untitled', true);
|
|
597
|
+
if (context.loop) {
|
|
598
|
+
context.loop.messages = [];
|
|
599
|
+
context.loop.taskId = `cli_chat_${Date.now()}`;
|
|
600
|
+
if (context.loop.tokenTracker && typeof context.loop.tokenTracker.reset === 'function') {
|
|
601
|
+
context.loop.tokenTracker.reset();
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
const renderer = context.prompt?.renderer || context.loop?.connection?.renderer;
|
|
605
|
+
if (renderer && typeof renderer.renderSessionHistory === 'function') {
|
|
606
|
+
renderer.renderSessionHistory([], { id: next.id, title: next.title, messagesCount: 0 });
|
|
607
|
+
}
|
|
608
|
+
if (context.prompt?.surface?.viewport && typeof context.prompt.surface.viewport.toBottom === 'function') {
|
|
609
|
+
context.prompt.surface.viewport.toBottom();
|
|
610
|
+
}
|
|
611
|
+
if (context.prompt?.editor?.clear) {
|
|
612
|
+
context.prompt.editor.clear();
|
|
613
|
+
if (typeof context.prompt.scheduleDraw === 'function') context.prompt.scheduleDraw();
|
|
614
|
+
}
|
|
615
|
+
return ok(`Started new session: "${next.title}" (${next.id}).`, { effect: 'inline' });
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
|
|
584
619
|
{
|
|
585
620
|
name: 'sessions',
|
|
586
621
|
aliases: ['session'],
|
|
587
622
|
scope: 'local',
|
|
588
|
-
usage: '/sessions [switch <id> | delete <id>]',
|
|
623
|
+
usage: '/sessions [new | switch <id> | delete <id>]',
|
|
589
624
|
description: 'List chat sessions, or switch to one',
|
|
590
625
|
dialogTitle: 'Sessions',
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
626
|
+
complete: () => {
|
|
627
|
+
try {
|
|
628
|
+
const rows = listSessions().slice(0, 15);
|
|
629
|
+
return [
|
|
630
|
+
{ value: 'new', label: 'new', description: 'start a fresh conversation in this workspace' },
|
|
631
|
+
...rows.map(r => ({
|
|
632
|
+
value: `switch ${r.id}`,
|
|
633
|
+
label: `switch ${r.id}`,
|
|
634
|
+
description: `${r.title} (${r.messageCount} msgs)`
|
|
635
|
+
}))
|
|
636
|
+
];
|
|
637
|
+
} catch (e) {
|
|
638
|
+
return [{ value: 'new', label: 'new', description: 'start a fresh conversation' }];
|
|
639
|
+
}
|
|
640
|
+
},
|
|
594
641
|
run: async (args = [], context = {}) => {
|
|
595
642
|
const store = await import('./sessionStore.js');
|
|
596
643
|
const verb = String(args[0] || '').toLowerCase();
|
|
597
644
|
const memory = context.loop && context.loop.memoryManager;
|
|
645
|
+
const workspace = context.loop?.workspaceRoot || process.cwd();
|
|
646
|
+
|
|
647
|
+
// If interactive TUI prompt is available and no sub-arguments are given, open interactive picker modal
|
|
648
|
+
if ((!args || args.length === 0 || (args.length === 1 && args[0] === '')) && context.prompt) {
|
|
649
|
+
const { runInteractiveSessionPicker } = await import('./tui/sessionPicker.js');
|
|
650
|
+
const message = await runInteractiveSessionPicker(context.prompt, {
|
|
651
|
+
loop: context.loop,
|
|
652
|
+
workspace
|
|
653
|
+
});
|
|
654
|
+
return ok(message, { effect: 'silent' });
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
if (verb === 'new') {
|
|
658
|
+
const next = memory ? memory.startNewSession('Untitled') : store.createSession(workspace, 'Untitled', true);
|
|
659
|
+
if (context.loop) {
|
|
660
|
+
context.loop.messages = [];
|
|
661
|
+
context.loop.taskId = `cli_chat_${Date.now()}`;
|
|
662
|
+
if (context.loop.tokenTracker && typeof context.loop.tokenTracker.reset === 'function') {
|
|
663
|
+
context.loop.tokenTracker.reset();
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
if (context.prompt?.editor?.clear) {
|
|
667
|
+
context.prompt.editor.clear();
|
|
668
|
+
if (typeof context.prompt.scheduleDraw === 'function') context.prompt.scheduleDraw();
|
|
669
|
+
}
|
|
670
|
+
return ok(`Started new session: "${next.title}" (${next.id}).`, { effect: 'inline' });
|
|
671
|
+
}
|
|
598
672
|
|
|
599
673
|
if (verb === 'switch' && args[1]) {
|
|
600
674
|
const next = memory ? memory.useSession(args[1]) : store.switchSession(args[1]);
|
|
601
675
|
if (!next) return fail(`No session "${args[1]}".`);
|
|
602
|
-
|
|
603
|
-
|
|
676
|
+
const historyMessages = memory ? memory.loadHistory() : next.messages.filter(m => m.role !== 'system');
|
|
677
|
+
if (context.loop) {
|
|
678
|
+
context.loop.messages = historyMessages;
|
|
679
|
+
context.loop.taskId = `cli_chat_${Date.now()}`;
|
|
680
|
+
if (context.loop.tokenTracker && typeof context.loop.tokenTracker.reset === 'function') {
|
|
681
|
+
context.loop.tokenTracker.reset();
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
const renderer = context.prompt?.renderer || context.loop?.connection?.renderer;
|
|
685
|
+
if (renderer && typeof renderer.renderSessionHistory === 'function') {
|
|
686
|
+
renderer.renderSessionHistory(historyMessages, {
|
|
687
|
+
id: next.id,
|
|
688
|
+
title: next.title,
|
|
689
|
+
messagesCount: next.messages.length
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
if (context.prompt?.surface?.viewport && typeof context.prompt.surface.viewport.toBottom === 'function') {
|
|
693
|
+
context.prompt.surface.viewport.toBottom();
|
|
694
|
+
}
|
|
695
|
+
if (context.prompt?.editor?.clear) {
|
|
696
|
+
context.prompt.editor.clear();
|
|
697
|
+
if (typeof context.prompt.scheduleDraw === 'function') context.prompt.scheduleDraw();
|
|
698
|
+
}
|
|
699
|
+
return ok(`Switched to "${next.title}" (${next.messages.length} messages, ${next.id}).`, { effect: 'inline' });
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
if (verb === 'fork') {
|
|
703
|
+
const sourceId = args[1] || (memory ? memory.sessionId : store.getActiveSessionId());
|
|
704
|
+
if (!sourceId) return fail('No session specified to fork.');
|
|
705
|
+
const forked = memory && memory.sessionId === sourceId
|
|
706
|
+
? memory.forkSession()
|
|
707
|
+
: store.forkSession(sourceId, { makeActive: true });
|
|
708
|
+
if (!forked) return fail(`Could not fork session "${sourceId}".`);
|
|
709
|
+
|
|
710
|
+
// CRITICAL TRUST INVARIANT (Claude Code Architecture, p. 24):
|
|
711
|
+
// Permissions and allowlists NEVER carry across forks.
|
|
712
|
+
const { revokeAllAlways } = await import('./approvalGrants.js');
|
|
713
|
+
revokeAllAlways();
|
|
714
|
+
if (context.loop && typeof context.loop.resetApprovalScope === 'function') {
|
|
715
|
+
context.loop.resetApprovalScope();
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const historyMessages = memory ? memory.loadHistory() : forked.messages.filter(m => m.role !== 'system');
|
|
719
|
+
if (context.loop) {
|
|
720
|
+
context.loop.messages = historyMessages;
|
|
721
|
+
context.loop.taskId = `cli_chat_${Date.now()}`;
|
|
722
|
+
if (context.loop.tokenTracker && typeof context.loop.tokenTracker.reset === 'function') {
|
|
723
|
+
context.loop.tokenTracker.reset();
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
const renderer = context.prompt?.renderer || context.loop?.connection?.renderer;
|
|
727
|
+
if (renderer && typeof renderer.renderSessionHistory === 'function') {
|
|
728
|
+
renderer.renderSessionHistory(historyMessages, {
|
|
729
|
+
id: forked.id,
|
|
730
|
+
title: forked.title,
|
|
731
|
+
messagesCount: forked.messages.length
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
if (context.prompt?.surface?.viewport && typeof context.prompt.surface.viewport.toBottom === 'function') {
|
|
735
|
+
context.prompt.surface.viewport.toBottom();
|
|
736
|
+
}
|
|
737
|
+
if (context.prompt?.editor?.clear) {
|
|
738
|
+
context.prompt.editor.clear();
|
|
739
|
+
if (typeof context.prompt.scheduleDraw === 'function') context.prompt.scheduleDraw();
|
|
740
|
+
}
|
|
741
|
+
return ok(`Forked session into "${forked.title}" (${forked.messages.length} messages, ${forked.id}).\nPermissions and standing approvals were reset; any gated actions will request authorization anew.`, { effect: 'inline' });
|
|
604
742
|
}
|
|
605
743
|
|
|
606
744
|
if (verb === 'delete' && args[1]) {
|
|
607
|
-
return store.deleteSession(args[1]) ? ok(
|
|
745
|
+
return store.deleteSession(args[1]) ? ok(`Deleted session "${args[1]}".`) : fail(`No session "${args[1]}".`);
|
|
608
746
|
}
|
|
609
747
|
|
|
610
748
|
const rows = store.listSessions();
|
|
@@ -624,12 +762,93 @@ export const COMMANDS = [
|
|
|
624
762
|
return ok(
|
|
625
763
|
`${rows.length} session${rows.length === 1 ? '' : 's'} (* = active):\n`
|
|
626
764
|
+ lines.join('\n')
|
|
627
|
-
+ '\n\nSwitch with /sessions switch <id
|
|
765
|
+
+ '\n\nSwitch with /sessions switch <id>, fork with /fork [id], or run /sessions to open interactive modal picker.',
|
|
628
766
|
{ effect: 'pick-session', items: rows, active }
|
|
629
767
|
);
|
|
630
768
|
}
|
|
631
769
|
},
|
|
632
770
|
|
|
771
|
+
{
|
|
772
|
+
name: 'fork',
|
|
773
|
+
aliases: ['branch', 'fork-session'],
|
|
774
|
+
scope: 'local',
|
|
775
|
+
usage: '/fork [sessionId]',
|
|
776
|
+
description: 'Fork the conversation into a new session without copying permissions',
|
|
777
|
+
dialogTitle: 'Fork Session',
|
|
778
|
+
complete: () => {
|
|
779
|
+
try {
|
|
780
|
+
const rows = listSessions().slice(0, 15);
|
|
781
|
+
return rows.map(r => ({
|
|
782
|
+
value: r.id,
|
|
783
|
+
label: r.id,
|
|
784
|
+
description: `${r.title} (${r.messageCount} msgs)`
|
|
785
|
+
}));
|
|
786
|
+
} catch (e) {
|
|
787
|
+
return [];
|
|
788
|
+
}
|
|
789
|
+
},
|
|
790
|
+
run: async (args = [], context = {}) => {
|
|
791
|
+
const store = await import('./sessionStore.js');
|
|
792
|
+
const { revokeAllAlways } = await import('./approvalGrants.js');
|
|
793
|
+
const memory = context.loop && context.loop.memoryManager;
|
|
794
|
+
|
|
795
|
+
const sourceId = args[0] || (memory ? memory.sessionId : store.getActiveSessionId());
|
|
796
|
+
if (!sourceId) {
|
|
797
|
+
return fail('No active or specified session to fork.');
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
const sourceSession = store.getSession(sourceId);
|
|
801
|
+
if (!sourceSession) {
|
|
802
|
+
return fail(`Session "${sourceId}" not found.`);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
const forked = memory && memory.sessionId === sourceId
|
|
806
|
+
? memory.forkSession()
|
|
807
|
+
: store.forkSession(sourceId, { makeActive: true });
|
|
808
|
+
|
|
809
|
+
if (!forked) {
|
|
810
|
+
return fail(`Could not fork session "${sourceId}".`);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
// CRITICAL SECURITY INVARIANT (Claude Code Architecture, p. 24):
|
|
814
|
+
// Permissions and allowlists MUST NOT be copied across the fork.
|
|
815
|
+
revokeAllAlways();
|
|
816
|
+
if (context.loop && typeof context.loop.resetApprovalScope === 'function') {
|
|
817
|
+
context.loop.resetApprovalScope();
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
if (memory) {
|
|
821
|
+
memory.session = forked;
|
|
822
|
+
}
|
|
823
|
+
const historyMessages = memory ? memory.loadHistory() : forked.messages.filter(m => m.role !== 'system');
|
|
824
|
+
if (context.loop) {
|
|
825
|
+
context.loop.messages = historyMessages;
|
|
826
|
+
context.loop.taskId = `cli_chat_${Date.now()}`;
|
|
827
|
+
if (context.loop.tokenTracker && typeof context.loop.tokenTracker.reset === 'function') {
|
|
828
|
+
context.loop.tokenTracker.reset();
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
const renderer = context.prompt?.renderer || context.loop?.connection?.renderer;
|
|
833
|
+
if (renderer && typeof renderer.renderSessionHistory === 'function') {
|
|
834
|
+
renderer.renderSessionHistory(historyMessages, {
|
|
835
|
+
id: forked.id,
|
|
836
|
+
title: forked.title,
|
|
837
|
+
messagesCount: forked.messages.length
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
if (context.prompt?.surface?.viewport && typeof context.prompt.surface.viewport.toBottom === 'function') {
|
|
841
|
+
context.prompt.surface.viewport.toBottom();
|
|
842
|
+
}
|
|
843
|
+
if (context.prompt?.editor?.clear) {
|
|
844
|
+
context.prompt.editor.clear();
|
|
845
|
+
if (typeof context.prompt.scheduleDraw === 'function') context.prompt.scheduleDraw();
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
return ok(`Forked session "${sourceSession.title}" into "${forked.title}" (${forked.id}) with ${forked.messages.length} messages.\nPermissions and allowlists reset: tools will request approval anew.`, { effect: 'inline' });
|
|
849
|
+
}
|
|
850
|
+
},
|
|
851
|
+
|
|
633
852
|
{
|
|
634
853
|
name: 'continuum',
|
|
635
854
|
aliases: ['resume'],
|
|
@@ -653,7 +872,7 @@ export const COMMANDS = [
|
|
|
653
872
|
const resultText = await runInteractiveContinuum(context.prompt, {
|
|
654
873
|
loop: context.loop
|
|
655
874
|
});
|
|
656
|
-
return ok(resultText, { effect: '
|
|
875
|
+
return ok(resultText, { effect: 'silent' });
|
|
657
876
|
}
|
|
658
877
|
|
|
659
878
|
const scanner = context.scanner || new ContinuumScanner();
|
|
@@ -737,7 +956,7 @@ export const COMMANDS = [
|
|
|
737
956
|
|
|
738
957
|
{
|
|
739
958
|
name: 'clear',
|
|
740
|
-
aliases: ['reset'
|
|
959
|
+
aliases: ['reset'],
|
|
741
960
|
scope: 'local',
|
|
742
961
|
usage: '/clear',
|
|
743
962
|
description: 'Clear the conversation and start from a fresh context',
|
|
@@ -752,6 +971,14 @@ export const COMMANDS = [
|
|
|
752
971
|
loop.isInitialized = false;
|
|
753
972
|
if (typeof loop.rearmAbortController === 'function') loop.rearmAbortController();
|
|
754
973
|
if (loop.memoryManager) loop.memoryManager.clearHistory();
|
|
974
|
+
const renderer = ctx.prompt?.renderer || loop.connection?.renderer;
|
|
975
|
+
if (renderer && typeof renderer.clearTranscript === 'function') {
|
|
976
|
+
renderer.clearTranscript();
|
|
977
|
+
}
|
|
978
|
+
if (ctx.prompt?.surface?.viewport && typeof ctx.prompt.surface.viewport.toBottom === 'function') {
|
|
979
|
+
ctx.prompt.surface.viewport.toBottom();
|
|
980
|
+
}
|
|
981
|
+
if (ctx.prompt?.scheduleDraw) ctx.prompt.scheduleDraw();
|
|
755
982
|
return ok('Conversation cleared. The next task starts from a clean context.');
|
|
756
983
|
}
|
|
757
984
|
return fail('No active session to clear.');
|
|
@@ -855,7 +1082,7 @@ export const COMMANDS = [
|
|
|
855
1082
|
ctx.loop.updateTierLimits();
|
|
856
1083
|
}
|
|
857
1084
|
}
|
|
858
|
-
return ok(output, { effect: '
|
|
1085
|
+
return ok(output, { effect: 'silent' });
|
|
859
1086
|
}
|
|
860
1087
|
|
|
861
1088
|
const lines = [
|
|
@@ -954,84 +1181,128 @@ export const COMMANDS = [
|
|
|
954
1181
|
return ok(`Refreshed ${config.provider} models (${result.models.length} available, source: ${result.source}). Run /model list to view.`);
|
|
955
1182
|
}
|
|
956
1183
|
|
|
957
|
-
const
|
|
1184
|
+
const rawRequested = argv.join(' ').trim().replace(/^\/model\s+/i, '');
|
|
958
1185
|
|
|
959
|
-
//
|
|
960
|
-
const
|
|
1186
|
+
// Helper to cleanly activate a provider + model, persist config, update live loop & prompt
|
|
1187
|
+
const activateModel = (nextProvider, nextModel, feedbackMessage) => {
|
|
1188
|
+
const isProviderChange = nextProvider !== config.provider;
|
|
1189
|
+
if (isProviderChange) {
|
|
1190
|
+
if (nextProvider === 'antigravity' || nextProvider === 'pi' || nextProvider.startsWith('acp/')) {
|
|
1191
|
+
config.apiKey = '';
|
|
1192
|
+
delete config.baseUrl;
|
|
1193
|
+
} else {
|
|
1194
|
+
config.apiKey = (config.providerKeys && config.providerKeys[nextProvider]) || '';
|
|
1195
|
+
delete config.baseUrl;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
config.provider = nextProvider;
|
|
1199
|
+
config.model = nextModel;
|
|
1200
|
+
saveConfig(config);
|
|
1201
|
+
|
|
1202
|
+
if (ctx.loop) {
|
|
1203
|
+
ctx.loop.config = loadConfig();
|
|
1204
|
+
if (typeof ctx.loop.updateTierLimits === 'function') {
|
|
1205
|
+
ctx.loop.updateTierLimits();
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
if (ctx.prompt) {
|
|
1209
|
+
if (typeof ctx.prompt.updateModel === 'function') {
|
|
1210
|
+
ctx.prompt.updateModel(config.provider, config.model);
|
|
1211
|
+
} else if (ctx.prompt.renderer?.status) {
|
|
1212
|
+
ctx.prompt.renderer.status.setSession({ provider: config.provider, model: config.model });
|
|
1213
|
+
if (typeof ctx.prompt.scheduleDraw === 'function') ctx.prompt.scheduleDraw();
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
return ok(feedbackMessage || `Now using ${config.provider} / ${config.model}.`, { effect: 'inline' });
|
|
1217
|
+
};
|
|
1218
|
+
|
|
1219
|
+
// 1. Antigravity provider (e.g. antigravity or antigravity/Gemini 3.8 Flash (High))
|
|
1220
|
+
// 1. Antigravity provider (e.g. antigravity or antigravity/Gemini 3.8 Flash (High))
|
|
1221
|
+
if (rawRequested.toLowerCase() === 'antigravity' || rawRequested.toLowerCase().startsWith('antigravity/')) {
|
|
1222
|
+
const agyModel = rawRequested.includes('/')
|
|
1223
|
+
? rawRequested.slice(rawRequested.indexOf('/') + 1).trim()
|
|
1224
|
+
: (DEFAULT_MODEL_BY_PROVIDER['antigravity'] || 'Gemini 3.8 Flash (Low)');
|
|
1225
|
+
const agyPeer = overview.acp.find(p => p.id === 'antigravity');
|
|
1226
|
+
if (agyPeer && !agyPeer.installed) {
|
|
1227
|
+
return fail(`Notice: Antigravity CLI (agy) is not installed on this machine.\nSetup: ${agyPeer.setupInstruction}\n\nModel was not changed.`);
|
|
1228
|
+
}
|
|
1229
|
+
return activateModel('antigravity', agyModel, `Now using Google Antigravity / ${agyModel}.`);
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
// 2. acp/<peer> or acp/<peer>/<model>
|
|
1233
|
+
const acpTarget = rawRequested.match(/^acp\/([a-z0-9_-]+)(?:\/(.+))?$/i);
|
|
961
1234
|
if (acpTarget) {
|
|
962
1235
|
const peer = acpTarget[1].toLowerCase();
|
|
963
1236
|
const nextProvider = `acp/${peer}`;
|
|
1237
|
+
const peerModel = acpTarget[2] ? acpTarget[2].trim() : (DEFAULT_MODEL_BY_PROVIDER[nextProvider] || peer);
|
|
964
1238
|
const peerInfo = overview.acp.find(p => p.id === peer);
|
|
965
|
-
|
|
966
|
-
if (nextProvider !== config.provider) { config.apiKey = ''; delete config.baseUrl; }
|
|
967
|
-
config.provider = nextProvider;
|
|
968
|
-
config.model = acpTarget[2] || DEFAULT_MODEL_BY_PROVIDER[nextProvider] || peer;
|
|
969
|
-
saveConfig(config);
|
|
970
|
-
if (ctx.loop) ctx.loop.config = loadConfig();
|
|
971
|
-
|
|
972
1239
|
if (peerInfo && !peerInfo.installed) {
|
|
973
|
-
return
|
|
974
|
-
`⚠️ Notice: "${peerInfo.label}" CLI is not installed on this machine.\n` +
|
|
975
|
-
`Binary "${peerInfo.id}" was not found on PATH.\n` +
|
|
976
|
-
`Setup: ${peerInfo.setupInstruction}\n\n` +
|
|
977
|
-
`Now using ${config.provider} / ${config.model}.`
|
|
978
|
-
);
|
|
1240
|
+
return fail(`Notice: "${peerInfo.label}" CLI is not installed on this machine.\nBinary "${peerInfo.id}" was not found on PATH.\nSetup: ${peerInfo.setupInstruction}\n\nModel was not changed.`);
|
|
979
1241
|
}
|
|
980
|
-
return
|
|
1242
|
+
return activateModel(nextProvider, peerModel, `Now using ${nextProvider} / ${peerModel}.`);
|
|
981
1243
|
}
|
|
982
1244
|
|
|
983
|
-
//
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1245
|
+
// 3. Known ACP peer directly (e.g. opencode, opencode/deepseek-v4.1-flash-free, claude)
|
|
1246
|
+
const slashIndex = rawRequested.indexOf('/');
|
|
1247
|
+
const prefix = (slashIndex > 0 ? rawRequested.slice(0, slashIndex) : rawRequested).toLowerCase();
|
|
1248
|
+
const acpPeer = overview.acp.find(p => p.id === prefix || p.providerKey === prefix);
|
|
1249
|
+
if (acpPeer && acpPeer.id !== 'antigravity') {
|
|
1250
|
+
const nextProvider = acpPeer.providerKey;
|
|
1251
|
+
if (!acpPeer.installed) {
|
|
1252
|
+
return fail(`Notice: "${acpPeer.label}" CLI is not installed on this machine.\nBinary "${acpPeer.id}" was not found on PATH.\nSetup: ${acpPeer.setupInstruction}\n\nModel was not changed.`);
|
|
990
1253
|
}
|
|
991
|
-
|
|
1254
|
+
let peerModel;
|
|
1255
|
+
if (slashIndex > 0) {
|
|
1256
|
+
const rest = rawRequested.slice(slashIndex + 1).trim();
|
|
1257
|
+
if (
|
|
1258
|
+
(PEER_MODEL_CATALOGUE[acpPeer.id] && PEER_MODEL_CATALOGUE[acpPeer.id].includes(rawRequested)) ||
|
|
1259
|
+
(acpPeer.id === 'opencode' && rawRequested.startsWith('opencode/'))
|
|
1260
|
+
) {
|
|
1261
|
+
peerModel = rawRequested;
|
|
1262
|
+
} else {
|
|
1263
|
+
peerModel = rest;
|
|
1264
|
+
}
|
|
1265
|
+
} else {
|
|
1266
|
+
peerModel = DEFAULT_MODEL_BY_PROVIDER[nextProvider] || acpPeer.id;
|
|
1267
|
+
}
|
|
1268
|
+
return activateModel(nextProvider, peerModel, `Now using ${nextProvider} / ${peerModel}.`);
|
|
992
1269
|
}
|
|
993
1270
|
|
|
994
|
-
//
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1271
|
+
// 4. Known BYOK provider prefix (e.g. gemini/gemini-2.5-flash, anthropic/claude-3-7-sonnet)
|
|
1272
|
+
const byokProvider = overview.byok.find(p => p.id === prefix || (p.id === 'qwen' && prefix === 'dashscope-byok'));
|
|
1273
|
+
if (byokProvider) {
|
|
1274
|
+
const nextProvider = byokProvider.id;
|
|
1275
|
+
const byokModel = slashIndex > 0 ? rawRequested.slice(slashIndex + 1).trim() : (DEFAULT_MODEL_BY_PROVIDER[nextProvider] || byokProvider.defaultModel);
|
|
1276
|
+
return activateModel(nextProvider, byokModel, `Now using ${nextProvider} / ${byokModel}.`);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
// 5. Look up by model name across BYOK and ACP catalogues
|
|
1280
|
+
for (const p of overview.byok) {
|
|
1281
|
+
if (p.models && p.models.some(m => m.toLowerCase() === rawRequested.toLowerCase())) {
|
|
1282
|
+
const exactModel = p.models.find(m => m.toLowerCase() === rawRequested.toLowerCase()) || rawRequested;
|
|
1283
|
+
return activateModel(p.id, exactModel, `Now using ${p.id} / ${exactModel}.`);
|
|
1004
1284
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
`Now using antigravity / ${config.model}.`,
|
|
1011
|
-
{ effect: 'inline' }
|
|
1012
|
-
);
|
|
1285
|
+
}
|
|
1286
|
+
for (const peer of overview.acp) {
|
|
1287
|
+
if (peer.models && peer.models.some(m => m.toLowerCase() === rawRequested.toLowerCase())) {
|
|
1288
|
+
const exactModel = peer.models.find(m => m.toLowerCase() === rawRequested.toLowerCase()) || rawRequested;
|
|
1289
|
+
return activateModel(peer.providerKey, exactModel, `Now using ${peer.providerKey} / ${exactModel}.`);
|
|
1013
1290
|
}
|
|
1014
|
-
return ok(`Now using antigravity / ${config.model}.`, { effect: 'inline' });
|
|
1015
1291
|
}
|
|
1016
1292
|
|
|
1017
|
-
|
|
1018
|
-
if (
|
|
1019
|
-
|
|
1020
|
-
if (provider !== config.provider) {
|
|
1021
|
-
config.apiKey = config.providerKeys?.[provider] || '';
|
|
1022
|
-
delete config.baseUrl;
|
|
1023
|
-
}
|
|
1024
|
-
config.provider = provider;
|
|
1025
|
-
config.model = requested.slice(separator + 1);
|
|
1026
|
-
} else {
|
|
1027
|
-
config.model = requested;
|
|
1293
|
+
// 6. If currently in ACP and model is custom for that peer
|
|
1294
|
+
if (isAcpProvider(config.provider)) {
|
|
1295
|
+
return activateModel(config.provider, rawRequested, `Now using ${config.provider} / ${rawRequested}.`);
|
|
1028
1296
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1297
|
+
|
|
1298
|
+
// 7. Generic provider/model separator or bare model
|
|
1299
|
+
if (slashIndex > 0) {
|
|
1300
|
+
const prov = rawRequested.slice(0, slashIndex).trim();
|
|
1301
|
+
const mod = rawRequested.slice(slashIndex + 1).trim();
|
|
1302
|
+
return activateModel(prov, mod, `Now using ${prov} / ${mod}.`);
|
|
1303
|
+
} else {
|
|
1304
|
+
return activateModel(config.provider || 'antigravity', rawRequested, `Now using ${config.provider || 'antigravity'} / ${rawRequested}.`);
|
|
1033
1305
|
}
|
|
1034
|
-
return ok(`Now using ${config.provider} / ${config.model}.`, { effect: 'inline' });
|
|
1035
1306
|
}
|
|
1036
1307
|
},
|
|
1037
1308
|
|
package/src/config.js
CHANGED
|
@@ -6,25 +6,33 @@ import { canonicalModelId } from './modelIds.js';
|
|
|
6
6
|
import { DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
|
|
7
7
|
import { causyneHome } from './utils/paths.js';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function configDir() {
|
|
10
|
+
return causyneHome();
|
|
11
|
+
}
|
|
12
|
+
function configFile() {
|
|
13
|
+
return path.join(causyneHome(), 'config.json');
|
|
14
|
+
}
|
|
15
|
+
function keyFile() {
|
|
16
|
+
return path.join(causyneHome(), '.vault_key');
|
|
17
|
+
}
|
|
12
18
|
|
|
13
19
|
function ensureConfigDir() {
|
|
14
|
-
|
|
20
|
+
const dir = configDir();
|
|
21
|
+
if (!fs.existsSync(dir)) {
|
|
15
22
|
// SECURITY: Directory must only be accessible by the owner
|
|
16
|
-
fs.mkdirSync(
|
|
23
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
function getVaultKey() {
|
|
21
28
|
ensureConfigDir();
|
|
22
|
-
|
|
29
|
+
const kf = keyFile();
|
|
30
|
+
if (!fs.existsSync(kf)) {
|
|
23
31
|
const key = crypto.randomBytes(32);
|
|
24
|
-
fs.writeFileSync(
|
|
32
|
+
fs.writeFileSync(kf, key, { mode: 0o600 });
|
|
25
33
|
return key;
|
|
26
34
|
}
|
|
27
|
-
return fs.readFileSync(
|
|
35
|
+
return fs.readFileSync(kf);
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
function encryptString(text) {
|
|
@@ -61,9 +69,10 @@ function decryptString(encryptedText) {
|
|
|
61
69
|
|
|
62
70
|
export function loadConfig() {
|
|
63
71
|
ensureConfigDir();
|
|
64
|
-
|
|
72
|
+
const file = configFile();
|
|
73
|
+
if (fs.existsSync(file)) {
|
|
65
74
|
try {
|
|
66
|
-
const parsed = JSON.parse(fs.readFileSync(
|
|
75
|
+
const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
67
76
|
|
|
68
77
|
// Decrypt API key into memory
|
|
69
78
|
if (parsed.apiKey) {
|
|
@@ -289,6 +298,7 @@ export function saveConfig(config) {
|
|
|
289
298
|
}
|
|
290
299
|
|
|
291
300
|
// SECURITY: Config file contains encrypted keys, must be 0600 (owner read/write only)
|
|
292
|
-
|
|
293
|
-
fs.
|
|
301
|
+
const file = configFile();
|
|
302
|
+
fs.writeFileSync(file, JSON.stringify(configToSave, null, 2), { encoding: 'utf8', mode: 0o600 });
|
|
303
|
+
fs.chmodSync(file, 0o600); // Enforce on existing files
|
|
294
304
|
}
|
package/src/continuum/ingest.js
CHANGED
|
@@ -42,7 +42,7 @@ export async function adoptContinuumSession(target, options = {}) {
|
|
|
42
42
|
originalWorkspace: detail.workspacePath
|
|
43
43
|
});
|
|
44
44
|
// 3. Create a new sovereign Causyne session
|
|
45
|
-
const targetWorkspace = options.workspace ||
|
|
45
|
+
const targetWorkspace = options.workspace || process.cwd();
|
|
46
46
|
const title = `[Adopted] ${detail.title}`;
|
|
47
47
|
const newSession = createSession(targetWorkspace, title, true);
|
|
48
48
|
// 4. Ingest compacted messages into journal
|
package/src/continuum/ingest.ts
CHANGED
|
@@ -65,7 +65,7 @@ export async function adoptContinuumSession(
|
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
// 3. Create a new sovereign Causyne session
|
|
68
|
-
const targetWorkspace = options.workspace ||
|
|
68
|
+
const targetWorkspace = options.workspace || process.cwd();
|
|
69
69
|
const title = `[Adopted] ${detail.title}`;
|
|
70
70
|
const newSession = createSession(targetWorkspace, title, true);
|
|
71
71
|
|
|
@@ -69,14 +69,31 @@ export async function runInteractiveContinuum(prompt, options = {}) {
|
|
|
69
69
|
return `Failed to adopt session: ${adoptRes.error}`;
|
|
70
70
|
}
|
|
71
71
|
if (options.loop) {
|
|
72
|
+
options.loop.taskId = `cli_chat_${Date.now()}`;
|
|
72
73
|
if (options.loop.memoryManager) {
|
|
73
74
|
options.loop.memoryManager.useSession(adoptRes.sessionId);
|
|
74
75
|
if (typeof options.loop.memoryManager.loadHistory === 'function') {
|
|
75
76
|
options.loop.messages = options.loop.memoryManager.loadHistory();
|
|
76
77
|
}
|
|
77
78
|
}
|
|
79
|
+
const renderer = prompt.renderer || options.loop?.connection?.renderer;
|
|
80
|
+
if (renderer && typeof renderer.renderSessionHistory === 'function') {
|
|
81
|
+
renderer.renderSessionHistory(options.loop.messages || [], {
|
|
82
|
+
id: adoptRes.sessionId,
|
|
83
|
+
title: adoptRes.title,
|
|
84
|
+
messagesCount: adoptRes.messageCount
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (prompt.surface?.viewport && typeof prompt.surface.viewport.toBottom === 'function') {
|
|
88
|
+
prompt.surface.viewport.toBottom();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (prompt.editor && typeof prompt.editor.clear === 'function') {
|
|
92
|
+
prompt.editor.clear();
|
|
93
|
+
if (typeof prompt.scheduleDraw === 'function')
|
|
94
|
+
prompt.scheduleDraw();
|
|
78
95
|
}
|
|
79
|
-
return
|
|
96
|
+
return `Successfully adopted session "${adoptRes.title}" from ${adoptRes.sourcePlatform.toUpperCase()} (${adoptRes.messageCount} messages compacted).\nActive Causyne session: ${adoptRes.sessionId}.`;
|
|
80
97
|
}
|
|
81
98
|
/**
|
|
82
99
|
* Open a preview text modal showing the full conversation transcript for a session.
|