@defai.digital/ax-cli 2.6.7 ā 2.8.0
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/.ax-cli/checkpoints/2025-11-20/checkpoint-2dd84869-e62d-46c8-9885-7e45f37f36e2.json +69 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-484dc350-353f-4808-9ed1-ebb3cefdab37.json +24 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-74a18b87-6172-4215-962b-44bb9f46a662.json +69 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-870a5fb9-6e82-4ff2-8ec8-af4c251cc514.json +44 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-93946601-0e83-456c-ba47-def9713124dd.json +24 -0
- package/.ax-cli/checkpoints/metadata.json +62 -0
- package/README.md +46 -2
- package/dist/agent/context-manager.d.ts +3 -2
- package/dist/agent/context-manager.js +35 -20
- package/dist/agent/context-manager.js.map +1 -1
- package/dist/agent/dependency-resolver.d.ts +83 -0
- package/dist/agent/dependency-resolver.js +302 -0
- package/dist/agent/dependency-resolver.js.map +1 -0
- package/dist/agent/index.js +7 -3
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/llm-agent.d.ts +63 -0
- package/dist/agent/llm-agent.js +250 -0
- package/dist/agent/llm-agent.js.map +1 -1
- package/dist/agent/specialized/analysis-agent.d.ts +11 -0
- package/dist/agent/specialized/analysis-agent.js +33 -0
- package/dist/agent/specialized/analysis-agent.js.map +1 -0
- package/dist/agent/specialized/debug-agent.d.ts +11 -0
- package/dist/agent/specialized/debug-agent.js +33 -0
- package/dist/agent/specialized/debug-agent.js.map +1 -0
- package/dist/agent/specialized/documentation-agent.d.ts +11 -0
- package/dist/agent/specialized/documentation-agent.js +33 -0
- package/dist/agent/specialized/documentation-agent.js.map +1 -0
- package/dist/agent/specialized/index.d.ts +11 -0
- package/dist/agent/specialized/index.js +12 -0
- package/dist/agent/specialized/index.js.map +1 -0
- package/dist/agent/specialized/performance-agent.d.ts +11 -0
- package/dist/agent/specialized/performance-agent.js +33 -0
- package/dist/agent/specialized/performance-agent.js.map +1 -0
- package/dist/agent/specialized/refactoring-agent.d.ts +11 -0
- package/dist/agent/specialized/refactoring-agent.js +33 -0
- package/dist/agent/specialized/refactoring-agent.js.map +1 -0
- package/dist/agent/specialized/testing-agent.d.ts +11 -0
- package/dist/agent/specialized/testing-agent.js +33 -0
- package/dist/agent/specialized/testing-agent.js.map +1 -0
- package/dist/agent/subagent-orchestrator.d.ts +124 -0
- package/dist/agent/subagent-orchestrator.js +345 -0
- package/dist/agent/subagent-orchestrator.js.map +1 -0
- package/dist/agent/subagent-types.d.ts +262 -0
- package/dist/agent/subagent-types.js +152 -0
- package/dist/agent/subagent-types.js.map +1 -0
- package/dist/agent/subagent.d.ts +88 -0
- package/dist/agent/subagent.js +402 -0
- package/dist/agent/subagent.js.map +1 -0
- package/dist/checkpoint/index.d.ts +9 -0
- package/dist/checkpoint/index.js +11 -0
- package/dist/checkpoint/index.js.map +1 -0
- package/dist/checkpoint/manager.d.ts +99 -0
- package/dist/checkpoint/manager.js +281 -0
- package/dist/checkpoint/manager.js.map +1 -0
- package/dist/checkpoint/storage.d.ts +31 -0
- package/dist/checkpoint/storage.js +265 -0
- package/dist/checkpoint/storage.js.map +1 -0
- package/dist/checkpoint/types.d.ts +111 -0
- package/dist/checkpoint/types.js +17 -0
- package/dist/checkpoint/types.js.map +1 -0
- package/dist/commands/rewind.d.ts +19 -0
- package/dist/commands/rewind.js +221 -0
- package/dist/commands/rewind.js.map +1 -0
- package/dist/hooks/use-input-handler.js +176 -0
- package/dist/hooks/use-input-handler.js.map +1 -1
- package/dist/index.js +25 -2
- package/dist/index.js.map +1 -1
- package/dist/llm/client.js +3 -2
- package/dist/llm/client.js.map +1 -1
- package/dist/mcp/client.d.ts +1 -0
- package/dist/mcp/client.js +27 -12
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/transports.d.ts +0 -1
- package/dist/mcp/transports.js +10 -7
- package/dist/mcp/transports.js.map +1 -1
- package/dist/schemas/api-schemas.js +4 -0
- package/dist/schemas/api-schemas.js.map +1 -1
- package/dist/tools/bash.js +26 -1
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/search.js +21 -9
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/text-editor.d.ts +16 -0
- package/dist/tools/text-editor.js +33 -0
- package/dist/tools/text-editor.js.map +1 -1
- package/dist/ui/components/chat-interface.d.ts +2 -1
- package/dist/ui/components/chat-interface.js +14 -10
- package/dist/ui/components/chat-interface.js.map +1 -1
- package/dist/ui/components/subagent-monitor.d.ts +29 -0
- package/dist/ui/components/subagent-monitor.js +150 -0
- package/dist/ui/components/subagent-monitor.js.map +1 -0
- package/dist/utils/history-manager.d.ts +16 -3
- package/dist/utils/history-manager.js +89 -9
- package/dist/utils/history-manager.js.map +1 -1
- package/dist/utils/incremental-analyzer.js +9 -3
- package/dist/utils/incremental-analyzer.js.map +1 -1
- package/dist/utils/json-utils.d.ts +7 -0
- package/dist/utils/json-utils.js +70 -2
- package/dist/utils/json-utils.js.map +1 -1
- package/dist/utils/settings-manager.js +12 -10
- package/dist/utils/settings-manager.js.map +1 -1
- package/dist/utils/text-utils.js +3 -3
- package/dist/utils/text-utils.js.map +1 -1
- package/dist/utils/token-counter.d.ts +5 -0
- package/dist/utils/token-counter.js +18 -3
- package/dist/utils/token-counter.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkpoint System Types
|
|
3
|
+
*/
|
|
4
|
+
import type { ChatEntry } from '../agent/llm-agent.js';
|
|
5
|
+
/**
|
|
6
|
+
* File snapshot with content and hash
|
|
7
|
+
*/
|
|
8
|
+
export interface FileSnapshot {
|
|
9
|
+
path: string;
|
|
10
|
+
content: string;
|
|
11
|
+
hash: string;
|
|
12
|
+
size: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Checkpoint metadata
|
|
16
|
+
*/
|
|
17
|
+
export interface CheckpointMetadata {
|
|
18
|
+
model: string;
|
|
19
|
+
triggeredBy: string;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Complete checkpoint
|
|
24
|
+
*/
|
|
25
|
+
export interface Checkpoint {
|
|
26
|
+
id: string;
|
|
27
|
+
timestamp: Date;
|
|
28
|
+
description: string;
|
|
29
|
+
files: FileSnapshot[];
|
|
30
|
+
conversationState: ChatEntry[];
|
|
31
|
+
metadata: CheckpointMetadata;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Checkpoint info for listing
|
|
35
|
+
*/
|
|
36
|
+
export interface CheckpointInfo {
|
|
37
|
+
id: string;
|
|
38
|
+
timestamp: Date;
|
|
39
|
+
description: string;
|
|
40
|
+
filesChanged: string[];
|
|
41
|
+
size: number;
|
|
42
|
+
compressed: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Checkpoint statistics
|
|
46
|
+
*/
|
|
47
|
+
export interface CheckpointStats {
|
|
48
|
+
totalCount: number;
|
|
49
|
+
totalSize: number;
|
|
50
|
+
compressedCount: number;
|
|
51
|
+
oldestDate: Date | null;
|
|
52
|
+
newestDate: Date | null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Checkpoint configuration
|
|
56
|
+
*/
|
|
57
|
+
export interface CheckpointConfig {
|
|
58
|
+
enabled: boolean;
|
|
59
|
+
maxCheckpoints: number;
|
|
60
|
+
compressAfterDays: number;
|
|
61
|
+
pruneAfterDays: number;
|
|
62
|
+
createBeforeOperations: string[];
|
|
63
|
+
storageLimit: number;
|
|
64
|
+
storageDir: string;
|
|
65
|
+
conversationDepth: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Checkpoint filter options
|
|
69
|
+
*/
|
|
70
|
+
export interface CheckpointFilter {
|
|
71
|
+
limit?: number;
|
|
72
|
+
beforeDate?: Date;
|
|
73
|
+
afterDate?: Date;
|
|
74
|
+
until?: Date;
|
|
75
|
+
since?: Date;
|
|
76
|
+
filesChanged?: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Checkpoint creation options
|
|
80
|
+
*/
|
|
81
|
+
export interface CheckpointOptions {
|
|
82
|
+
files: Array<{
|
|
83
|
+
path: string;
|
|
84
|
+
content: string;
|
|
85
|
+
}>;
|
|
86
|
+
conversationState: ChatEntry[];
|
|
87
|
+
description?: string;
|
|
88
|
+
metadata?: Partial<CheckpointMetadata>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Checkpoint restore result
|
|
92
|
+
*/
|
|
93
|
+
export interface CheckpointRestoreResult {
|
|
94
|
+
success: boolean;
|
|
95
|
+
filesRestored: string[];
|
|
96
|
+
filesFailed: string[];
|
|
97
|
+
conversationIndex?: number;
|
|
98
|
+
error?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Checkpoint index
|
|
102
|
+
*/
|
|
103
|
+
export interface CheckpointIndex {
|
|
104
|
+
checkpoints: CheckpointInfo[];
|
|
105
|
+
stats: CheckpointStats;
|
|
106
|
+
lastUpdated: Date;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Default configuration
|
|
110
|
+
*/
|
|
111
|
+
export declare const DEFAULT_CHECKPOINT_CONFIG: CheckpointConfig;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkpoint System Types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Default configuration
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_CHECKPOINT_CONFIG = {
|
|
8
|
+
enabled: true,
|
|
9
|
+
maxCheckpoints: 100,
|
|
10
|
+
compressAfterDays: 7,
|
|
11
|
+
pruneAfterDays: 30,
|
|
12
|
+
createBeforeOperations: ['write', 'edit', 'delete'],
|
|
13
|
+
storageLimit: 100,
|
|
14
|
+
storageDir: 'checkpoints',
|
|
15
|
+
conversationDepth: 50,
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/checkpoint/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkHH;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAqB;IACzD,OAAO,EAAE,IAAI;IACb,cAAc,EAAE,GAAG;IACnB,iBAAiB,EAAE,CAAC;IACpB,cAAc,EAAE,EAAE;IAClB,sBAAsB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;IACnD,YAAY,EAAE,GAAG;IACjB,UAAU,EAAE,aAAa;IACzB,iBAAiB,EAAE,EAAE;CACtB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewind Command
|
|
3
|
+
*
|
|
4
|
+
* Allows users to rewind to a previous checkpoint, restoring both
|
|
5
|
+
* file state and conversation history.
|
|
6
|
+
*/
|
|
7
|
+
import type { LLMAgent } from '../agent/llm-agent.js';
|
|
8
|
+
/**
|
|
9
|
+
* Handle /rewind command
|
|
10
|
+
*/
|
|
11
|
+
export declare function handleRewindCommand(agent: LLMAgent): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* List checkpoints (for /checkpoints command)
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleCheckpointsCommand(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Clean old checkpoints (for /checkpoint-clean command)
|
|
18
|
+
*/
|
|
19
|
+
export declare function handleCheckpointCleanCommand(): Promise<void>;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewind Command
|
|
3
|
+
*
|
|
4
|
+
* Allows users to rewind to a previous checkpoint, restoring both
|
|
5
|
+
* file state and conversation history.
|
|
6
|
+
*/
|
|
7
|
+
import { getCheckpointManager } from '../checkpoint/index.js';
|
|
8
|
+
import * as readline from 'readline';
|
|
9
|
+
/**
|
|
10
|
+
* Format timestamp as relative time (e.g., "5 minutes ago")
|
|
11
|
+
*/
|
|
12
|
+
function formatTimeAgo(date) {
|
|
13
|
+
const now = new Date();
|
|
14
|
+
const seconds = Math.floor((now.getTime() - date.getTime()) / 1000);
|
|
15
|
+
if (seconds < 60) {
|
|
16
|
+
return `${seconds} second${seconds !== 1 ? 's' : ''} ago`;
|
|
17
|
+
}
|
|
18
|
+
const minutes = Math.floor(seconds / 60);
|
|
19
|
+
if (minutes < 60) {
|
|
20
|
+
return `${minutes} minute${minutes !== 1 ? 's' : ''} ago`;
|
|
21
|
+
}
|
|
22
|
+
const hours = Math.floor(minutes / 60);
|
|
23
|
+
if (hours < 24) {
|
|
24
|
+
return `${hours} hour${hours !== 1 ? 's' : ''} ago`;
|
|
25
|
+
}
|
|
26
|
+
const days = Math.floor(hours / 24);
|
|
27
|
+
if (days < 30) {
|
|
28
|
+
return `${days} day${days !== 1 ? 's' : ''} ago`;
|
|
29
|
+
}
|
|
30
|
+
const months = Math.floor(days / 30);
|
|
31
|
+
return `${months} month${months !== 1 ? 's' : ''} ago`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Prompt user for input
|
|
35
|
+
*/
|
|
36
|
+
async function promptUser(question) {
|
|
37
|
+
const rl = readline.createInterface({
|
|
38
|
+
input: process.stdin,
|
|
39
|
+
output: process.stdout,
|
|
40
|
+
});
|
|
41
|
+
return new Promise((resolve) => {
|
|
42
|
+
rl.question(question, (answer) => {
|
|
43
|
+
rl.close();
|
|
44
|
+
resolve(answer.trim());
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Display checkpoint diff preview
|
|
50
|
+
*/
|
|
51
|
+
async function previewCheckpoint(checkpointId) {
|
|
52
|
+
const manager = getCheckpointManager();
|
|
53
|
+
const checkpoint = await manager.getCheckpoint(checkpointId);
|
|
54
|
+
if (!checkpoint) {
|
|
55
|
+
console.log('ā Checkpoint not found');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
console.log('\nš Preview of changes:');
|
|
59
|
+
console.log('ā'.repeat(60));
|
|
60
|
+
for (const file of checkpoint.files) {
|
|
61
|
+
console.log(`\nFile: ${file.path}`);
|
|
62
|
+
console.log(`Size: ${file.size} bytes`);
|
|
63
|
+
console.log(`Hash: ${file.hash.substring(0, 12)}...`);
|
|
64
|
+
// Show first/last few lines of content
|
|
65
|
+
const lines = file.content.split('\n');
|
|
66
|
+
const preview = lines.length > 10
|
|
67
|
+
? [...lines.slice(0, 5), '...', ...lines.slice(-5)]
|
|
68
|
+
: lines;
|
|
69
|
+
console.log('\nContent preview:');
|
|
70
|
+
preview.forEach((line, i) => {
|
|
71
|
+
if (line === '...') {
|
|
72
|
+
console.log(' ...');
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const lineNum = i < 5 ? i + 1 : lines.length - (preview.length - i) + 1;
|
|
76
|
+
console.log(` ${lineNum}: ${line.substring(0, 80)}`);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
console.log('\nā'.repeat(60));
|
|
81
|
+
console.log(`Conversation state: ${checkpoint.conversationState.length} messages`);
|
|
82
|
+
console.log(`Metadata: model=${checkpoint.metadata.model}, triggeredBy=${checkpoint.metadata.triggeredBy}`);
|
|
83
|
+
console.log('ā'.repeat(60));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Handle /rewind command
|
|
87
|
+
*/
|
|
88
|
+
export async function handleRewindCommand(agent) {
|
|
89
|
+
try {
|
|
90
|
+
const manager = getCheckpointManager();
|
|
91
|
+
const checkpoints = await manager.listCheckpoints({ limit: 20 });
|
|
92
|
+
if (checkpoints.length === 0) {
|
|
93
|
+
console.log('\nš No checkpoints available');
|
|
94
|
+
console.log('\nCheckpoints are created automatically before file modifications.');
|
|
95
|
+
console.log('Make some changes to your code and checkpoints will be created.');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// Display available checkpoints
|
|
99
|
+
console.log('\nš Available Checkpoints (last 20):');
|
|
100
|
+
console.log('ā'.repeat(60));
|
|
101
|
+
checkpoints.forEach((cp, i) => {
|
|
102
|
+
const timeAgo = formatTimeAgo(cp.timestamp);
|
|
103
|
+
const filesStr = cp.filesChanged.length === 1
|
|
104
|
+
? cp.filesChanged[0]
|
|
105
|
+
: `${cp.filesChanged.length} files`;
|
|
106
|
+
console.log(`${i + 1}. ${cp.description}`);
|
|
107
|
+
console.log(` Time: ${timeAgo}`);
|
|
108
|
+
console.log(` Files: ${filesStr}`);
|
|
109
|
+
console.log(` Size: ${(cp.size / 1024).toFixed(2)} KB${cp.compressed ? ' (compressed)' : ''}`);
|
|
110
|
+
console.log('');
|
|
111
|
+
});
|
|
112
|
+
console.log('ā'.repeat(60));
|
|
113
|
+
// Get user selection
|
|
114
|
+
const selection = await promptUser('\nSelect checkpoint number (or \'q\' to quit): ');
|
|
115
|
+
if (selection.toLowerCase() === 'q' || selection === '') {
|
|
116
|
+
console.log('Cancelled.');
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const selectedIndex = parseInt(selection, 10) - 1;
|
|
120
|
+
if (isNaN(selectedIndex) || selectedIndex < 0 || selectedIndex >= checkpoints.length) {
|
|
121
|
+
console.log('ā Invalid selection');
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const selectedCheckpoint = checkpoints[selectedIndex];
|
|
125
|
+
// Show preview
|
|
126
|
+
await previewCheckpoint(selectedCheckpoint.id);
|
|
127
|
+
// Confirm
|
|
128
|
+
const confirm = await promptUser('\nā ļø This will restore files and rewind conversation. Continue? (y/N): ');
|
|
129
|
+
if (confirm.toLowerCase() !== 'y' && confirm.toLowerCase() !== 'yes') {
|
|
130
|
+
console.log('Cancelled.');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// Apply checkpoint
|
|
134
|
+
console.log('\nš Applying checkpoint...');
|
|
135
|
+
const result = await manager.applyCheckpoint(selectedCheckpoint.id);
|
|
136
|
+
if (result.success) {
|
|
137
|
+
console.log(`\nā
Successfully rewound to: ${selectedCheckpoint.description}`);
|
|
138
|
+
console.log(`\nš Files restored (${result.filesRestored.length}):`);
|
|
139
|
+
result.filesRestored.forEach(file => {
|
|
140
|
+
console.log(` ā ${file}`);
|
|
141
|
+
});
|
|
142
|
+
if (result.filesFailed.length > 0) {
|
|
143
|
+
console.log(`\nā ļø Files failed to restore (${result.filesFailed.length}):`);
|
|
144
|
+
result.filesFailed.forEach(file => {
|
|
145
|
+
console.log(` ā ${file}`);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// Rewind conversation
|
|
149
|
+
const rewindResult = await agent.rewindConversation(selectedCheckpoint.id);
|
|
150
|
+
if (rewindResult.success) {
|
|
151
|
+
console.log(`\nš¬ Conversation rewound successfully`);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
console.log(`\nā ļø Failed to rewind conversation: ${rewindResult.error}`);
|
|
155
|
+
}
|
|
156
|
+
console.log('\n⨠Rewind complete!');
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
console.log(`\nā Failed to apply checkpoint: ${result.error}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
console.error('\nā Error during rewind:', error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* List checkpoints (for /checkpoints command)
|
|
168
|
+
*/
|
|
169
|
+
export async function handleCheckpointsCommand() {
|
|
170
|
+
try {
|
|
171
|
+
const manager = getCheckpointManager();
|
|
172
|
+
const stats = await manager.getStats();
|
|
173
|
+
console.log('\nš Checkpoint Statistics:');
|
|
174
|
+
console.log('ā'.repeat(60));
|
|
175
|
+
console.log(`Total checkpoints: ${stats.totalCount}`);
|
|
176
|
+
console.log(`Total storage: ${(stats.totalSize / 1024 / 1024).toFixed(2)} MB`);
|
|
177
|
+
console.log(`Compressed: ${stats.compressedCount}`);
|
|
178
|
+
if (stats.oldestDate) {
|
|
179
|
+
console.log(`Oldest: ${stats.oldestDate.toLocaleDateString()}`);
|
|
180
|
+
}
|
|
181
|
+
if (stats.newestDate) {
|
|
182
|
+
console.log(`Newest: ${stats.newestDate.toLocaleDateString()}`);
|
|
183
|
+
}
|
|
184
|
+
const checkpoints = await manager.listCheckpoints({ limit: 10 });
|
|
185
|
+
if (checkpoints.length > 0) {
|
|
186
|
+
console.log('\nš Recent Checkpoints:');
|
|
187
|
+
console.log('ā'.repeat(60));
|
|
188
|
+
checkpoints.forEach((cp, i) => {
|
|
189
|
+
const timeAgo = formatTimeAgo(cp.timestamp);
|
|
190
|
+
console.log(`${i + 1}. ${cp.description} (${timeAgo})`);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
console.log('ā'.repeat(60));
|
|
194
|
+
console.log('\nUse /rewind to restore a checkpoint');
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
console.error('ā Error listing checkpoints:', error);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Clean old checkpoints (for /checkpoint-clean command)
|
|
202
|
+
*/
|
|
203
|
+
export async function handleCheckpointCleanCommand() {
|
|
204
|
+
try {
|
|
205
|
+
const manager = getCheckpointManager();
|
|
206
|
+
console.log('\nš§¹ Cleaning old checkpoints...');
|
|
207
|
+
// Compress old checkpoints
|
|
208
|
+
const compressed = await manager.compressOldCheckpoints();
|
|
209
|
+
console.log(`ā Compressed ${compressed} old checkpoints`);
|
|
210
|
+
// Prune very old checkpoints
|
|
211
|
+
const pruned = await manager.pruneOldCheckpoints();
|
|
212
|
+
console.log(`ā Pruned ${pruned} very old checkpoints`);
|
|
213
|
+
const stats = await manager.getStats();
|
|
214
|
+
console.log(`\nš Storage after cleanup: ${(stats.totalSize / 1024 / 1024).toFixed(2)} MB`);
|
|
215
|
+
console.log('\n⨠Cleanup complete!');
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
console.error('ā Error cleaning checkpoints:', error);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=rewind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewind.js","sourceRoot":"","sources":["../../src/commands/rewind.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,SAAS,aAAa,CAAC,IAAU;IAC/B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IAEpE,IAAI,OAAO,GAAG,EAAE,EAAE,CAAC;QACjB,OAAO,GAAG,OAAO,UAAU,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAC5D,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IACzC,IAAI,OAAO,GAAG,EAAE,EAAE,CAAC;QACjB,OAAO,GAAG,OAAO,UAAU,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAC5D,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IACvC,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QACf,OAAO,GAAG,KAAK,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACtD,CAAC;IAED,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AAsB,EAAE,CAAC;QAC1D,OAAO,CAAC,GAAG,CAAC,gBAAgB,UAAU,kBAAkB,CAAC,CAAC;QAE1D,6BAA6B;QAC7B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,mBAAmB,EAAE,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,uBAAuB,CAAC,CAAC;QAEvD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAE5F,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { ProjectAnalyzer } from "../utils/project-analyzer.js";
|
|
|
8
8
|
import { InstructionGenerator } from "../utils/instruction-generator.js";
|
|
9
9
|
import { getUsageTracker } from "../utils/usage-tracker.js";
|
|
10
10
|
import { getHistoryManager } from "../utils/history-manager.js";
|
|
11
|
+
import { handleRewindCommand, handleCheckpointsCommand, handleCheckpointCleanCommand } from "../commands/rewind.js";
|
|
11
12
|
import * as fs from "fs";
|
|
12
13
|
import * as path from "path";
|
|
13
14
|
export function useInputHandler({ agent, setChatHistory, setIsProcessing, setIsStreaming, setTokenCount, setProcessingTime, processingStartTime, isProcessing, isStreaming, isConfirmationActive = false, }) {
|
|
@@ -129,9 +130,13 @@ export function useInputHandler({ agent, setChatHistory, setIsProcessing, setIsS
|
|
|
129
130
|
}, [input, handleInputChange]);
|
|
130
131
|
const commandSuggestions = [
|
|
131
132
|
{ command: "/help", description: "Show help information" },
|
|
133
|
+
{ command: "/continue", description: "Continue incomplete response" },
|
|
132
134
|
{ command: "/clear", description: "Clear chat history" },
|
|
133
135
|
{ command: "/init", description: "Initialize project with smart analysis" },
|
|
134
136
|
{ command: "/usage", description: "Show API usage statistics" },
|
|
137
|
+
{ command: "/rewind", description: "Rewind to previous checkpoint" },
|
|
138
|
+
{ command: "/checkpoints", description: "List checkpoint statistics" },
|
|
139
|
+
{ command: "/checkpoint-clean", description: "Clean old checkpoints" },
|
|
135
140
|
{ command: "/commit-and-push", description: "AI commit & push to remote" },
|
|
136
141
|
{ command: "/exit", description: "Exit the application" },
|
|
137
142
|
];
|
|
@@ -143,6 +148,156 @@ export function useInputHandler({ agent, setChatHistory, setIsProcessing, setIsS
|
|
|
143
148
|
}, []);
|
|
144
149
|
const handleDirectCommand = async (input) => {
|
|
145
150
|
const trimmedInput = input.trim();
|
|
151
|
+
if (trimmedInput === "/continue") {
|
|
152
|
+
// Send a shorter, more focused continuation prompt to avoid timeout
|
|
153
|
+
// Using a brief prompt reduces token overhead for large contexts
|
|
154
|
+
const continuePrompt = "Continue from where you left off.";
|
|
155
|
+
// Add user continue command to history (showing the actual command for clarity)
|
|
156
|
+
const userEntry = {
|
|
157
|
+
type: "user",
|
|
158
|
+
content: "/continue",
|
|
159
|
+
timestamp: new Date(),
|
|
160
|
+
};
|
|
161
|
+
setChatHistory((prev) => [...prev, userEntry]);
|
|
162
|
+
// Process through agent
|
|
163
|
+
setIsProcessing(true);
|
|
164
|
+
setIsStreaming(true);
|
|
165
|
+
processingStartTime.current = Date.now();
|
|
166
|
+
(async () => {
|
|
167
|
+
try {
|
|
168
|
+
let streamingEntry = null;
|
|
169
|
+
for await (const chunk of agent.processUserMessageStream(continuePrompt)) {
|
|
170
|
+
switch (chunk.type) {
|
|
171
|
+
case "reasoning":
|
|
172
|
+
if (chunk.reasoningContent) {
|
|
173
|
+
if (!streamingEntry) {
|
|
174
|
+
const newStreamingEntry = {
|
|
175
|
+
type: "assistant",
|
|
176
|
+
content: "",
|
|
177
|
+
timestamp: new Date(),
|
|
178
|
+
isStreaming: true,
|
|
179
|
+
reasoningContent: chunk.reasoningContent,
|
|
180
|
+
isReasoningStreaming: true,
|
|
181
|
+
};
|
|
182
|
+
setChatHistory((prev) => [...prev, newStreamingEntry]);
|
|
183
|
+
streamingEntry = newStreamingEntry;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
setChatHistory((prev) => prev.map((entry, idx) => idx === prev.length - 1 && entry.isStreaming
|
|
187
|
+
? {
|
|
188
|
+
...entry,
|
|
189
|
+
reasoningContent: (entry.reasoningContent || "") +
|
|
190
|
+
chunk.reasoningContent,
|
|
191
|
+
isReasoningStreaming: true,
|
|
192
|
+
}
|
|
193
|
+
: entry));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
case "content":
|
|
198
|
+
if (chunk.content) {
|
|
199
|
+
if (!streamingEntry) {
|
|
200
|
+
const newStreamingEntry = {
|
|
201
|
+
type: "assistant",
|
|
202
|
+
content: chunk.content,
|
|
203
|
+
timestamp: new Date(),
|
|
204
|
+
isStreaming: true,
|
|
205
|
+
};
|
|
206
|
+
setChatHistory((prev) => [...prev, newStreamingEntry]);
|
|
207
|
+
streamingEntry = newStreamingEntry;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
setChatHistory((prev) => prev.map((entry, idx) => idx === prev.length - 1 && entry.isStreaming
|
|
211
|
+
? {
|
|
212
|
+
...entry,
|
|
213
|
+
content: entry.content + chunk.content,
|
|
214
|
+
isReasoningStreaming: false,
|
|
215
|
+
}
|
|
216
|
+
: entry));
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
case "token_count":
|
|
221
|
+
if (chunk.tokenCount !== undefined) {
|
|
222
|
+
setTokenCount(chunk.tokenCount);
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
case "tool_calls":
|
|
226
|
+
if (chunk.toolCalls) {
|
|
227
|
+
setChatHistory((prev) => prev.map((entry) => entry.isStreaming
|
|
228
|
+
? {
|
|
229
|
+
...entry,
|
|
230
|
+
isStreaming: false,
|
|
231
|
+
toolCalls: chunk.toolCalls,
|
|
232
|
+
}
|
|
233
|
+
: entry));
|
|
234
|
+
streamingEntry = null;
|
|
235
|
+
chunk.toolCalls.forEach((toolCall) => {
|
|
236
|
+
const toolCallEntry = {
|
|
237
|
+
type: "tool_call",
|
|
238
|
+
content: "Executing...",
|
|
239
|
+
timestamp: new Date(),
|
|
240
|
+
toolCall: toolCall,
|
|
241
|
+
};
|
|
242
|
+
setChatHistory((prev) => [...prev, toolCallEntry]);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
246
|
+
case "tool_result":
|
|
247
|
+
if (chunk.toolCall && chunk.toolResult) {
|
|
248
|
+
setChatHistory((prev) => prev.map((entry) => {
|
|
249
|
+
if (entry.isStreaming) {
|
|
250
|
+
return { ...entry, isStreaming: false };
|
|
251
|
+
}
|
|
252
|
+
if (entry.type === "tool_call" &&
|
|
253
|
+
entry.toolCall?.id === chunk.toolCall?.id) {
|
|
254
|
+
return {
|
|
255
|
+
...entry,
|
|
256
|
+
type: "tool_result",
|
|
257
|
+
content: chunk.toolResult?.success
|
|
258
|
+
? chunk.toolResult?.output || "Success"
|
|
259
|
+
: chunk.toolResult?.error || "Error occurred",
|
|
260
|
+
toolResult: chunk.toolResult,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return entry;
|
|
264
|
+
}));
|
|
265
|
+
streamingEntry = null;
|
|
266
|
+
}
|
|
267
|
+
break;
|
|
268
|
+
case "done":
|
|
269
|
+
if (streamingEntry) {
|
|
270
|
+
setChatHistory((prev) => prev.map((entry) => entry.isStreaming ? { ...entry, isStreaming: false } : entry));
|
|
271
|
+
}
|
|
272
|
+
setIsStreaming(false);
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
let errorMessage = `Error: ${error.message}`;
|
|
279
|
+
// Provide helpful guidance for timeout errors during /continue
|
|
280
|
+
if (error.message && error.message.includes('timeout')) {
|
|
281
|
+
errorMessage += `\n\nš” Tip: For very long conversations, try:\n`;
|
|
282
|
+
errorMessage += ` ⢠Use /clear to start fresh and ask a more focused question\n`;
|
|
283
|
+
errorMessage += ` ⢠Break down your request into smaller parts\n`;
|
|
284
|
+
errorMessage += ` ⢠Use --continue flag to start a new session with history`;
|
|
285
|
+
}
|
|
286
|
+
const errorEntry = {
|
|
287
|
+
type: "assistant",
|
|
288
|
+
content: errorMessage,
|
|
289
|
+
timestamp: new Date(),
|
|
290
|
+
};
|
|
291
|
+
setChatHistory((prev) => [...prev, errorEntry]);
|
|
292
|
+
setIsStreaming(false);
|
|
293
|
+
}
|
|
294
|
+
setIsProcessing(false);
|
|
295
|
+
processingStartTime.current = 0;
|
|
296
|
+
})();
|
|
297
|
+
clearInput();
|
|
298
|
+
resetHistory();
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
146
301
|
if (trimmedInput === "/clear") {
|
|
147
302
|
// Reset chat history
|
|
148
303
|
setChatHistory([]);
|
|
@@ -261,6 +416,7 @@ export function useInputHandler({ agent, setChatHistory, setIsProcessing, setIsS
|
|
|
261
416
|
content: `AX CLI Help:
|
|
262
417
|
|
|
263
418
|
Built-in Commands:
|
|
419
|
+
/continue - Continue incomplete response from where it left off
|
|
264
420
|
/clear - Clear chat history
|
|
265
421
|
/init - Initialize project with smart analysis
|
|
266
422
|
/help - Show this help
|
|
@@ -268,6 +424,11 @@ Built-in Commands:
|
|
|
268
424
|
/exit - Exit application
|
|
269
425
|
exit, quit - Exit application
|
|
270
426
|
|
|
427
|
+
Checkpoint Commands:
|
|
428
|
+
/rewind - Rewind to a previous checkpoint (interactive)
|
|
429
|
+
/checkpoints - Show checkpoint statistics
|
|
430
|
+
/checkpoint-clean - Clean old checkpoints (compress and prune)
|
|
431
|
+
|
|
271
432
|
Git Commands:
|
|
272
433
|
/commit-and-push - AI-generated commit + push to remote
|
|
273
434
|
|
|
@@ -364,6 +525,21 @@ Examples:
|
|
|
364
525
|
process.exit(0);
|
|
365
526
|
return true;
|
|
366
527
|
}
|
|
528
|
+
if (trimmedInput === "/rewind") {
|
|
529
|
+
await handleRewindCommand(agent);
|
|
530
|
+
clearInput();
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
if (trimmedInput === "/checkpoints") {
|
|
534
|
+
await handleCheckpointsCommand();
|
|
535
|
+
clearInput();
|
|
536
|
+
return true;
|
|
537
|
+
}
|
|
538
|
+
if (trimmedInput === "/checkpoint-clean") {
|
|
539
|
+
await handleCheckpointCleanCommand();
|
|
540
|
+
clearInput();
|
|
541
|
+
return true;
|
|
542
|
+
}
|
|
367
543
|
if (trimmedInput === "/commit-and-push") {
|
|
368
544
|
const userEntry = {
|
|
369
545
|
type: "user",
|