@wundr.io/cli 1.0.10 → 1.0.12
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/bin/wundr.js +8 -4
- package/package.json +23 -23
- package/src/ai/ai-service.ts +16 -17
- package/src/ai/claude-client.ts +16 -16
- package/src/ai/conversation-manager.ts +29 -29
- package/src/cli.ts +4 -4
- package/src/commands/ai.ts +246 -78
- package/src/commands/alignment.ts +74 -74
- package/src/commands/analyze-optimized.ts +111 -78
- package/src/commands/analyze.ts +14 -14
- package/src/commands/batch.ts +179 -42
- package/src/commands/chat.ts +37 -30
- package/src/commands/claude-init.ts +41 -45
- package/src/commands/claude-setup.ts +204 -119
- package/src/commands/computer-setup.ts +85 -43
- package/src/commands/create-command.ts +4 -4
- package/src/commands/create.ts +27 -27
- package/src/commands/dashboard.ts +24 -24
- package/src/commands/govern.ts +25 -25
- package/src/commands/governance.ts +34 -34
- package/src/commands/guardian.ts +56 -56
- package/src/commands/init.ts +25 -22
- package/src/commands/orchestrator.ts +68 -41
- package/src/commands/performance-optimizer.ts +34 -35
- package/src/commands/plugins.ts +27 -27
- package/src/commands/project-update.ts +175 -72
- package/src/commands/rag.ts +185 -78
- package/src/commands/session.ts +35 -35
- package/src/commands/setup.ts +40 -344
- package/src/commands/test-init.ts +3 -3
- package/src/commands/test.ts +4 -4
- package/src/commands/watch.ts +28 -29
- package/src/commands/worktree.ts +49 -49
- package/src/context/context-manager.ts +10 -10
- package/src/context/session-manager.ts +41 -41
- package/src/framework/command-interface.ts +520 -0
- package/src/framework/command-registry.ts +942 -0
- package/src/framework/completion-exporter.ts +383 -0
- package/src/framework/debug-logger.ts +519 -0
- package/src/framework/error-handler.ts +867 -0
- package/src/framework/help-generator.ts +540 -0
- package/src/framework/index.ts +169 -0
- package/src/framework/interactive-repl.ts +703 -0
- package/src/framework/output-formatter.ts +834 -0
- package/src/framework/progress-manager.ts +539 -0
- package/src/index.ts +4 -4
- package/src/interactive/interactive-mode.ts +16 -16
- package/src/lib/conflict-resolution.ts +799 -9
- package/src/lib/merge-strategy.ts +529 -7
- package/src/lib/safety-mechanisms.ts +422 -18
- package/src/lib/state-detection.ts +1015 -13
- package/src/nlp/command-mapper.ts +29 -29
- package/src/nlp/command-parser.ts +17 -17
- package/src/nlp/intent-classifier.ts +7 -7
- package/src/nlp/intent-parser.ts +54 -52
- package/src/plugins/plugin-manager.ts +61 -39
- package/src/tests/computer-setup-integration.test.ts +46 -15
- package/src/types/modules.d.ts +424 -1
- package/src/utils/backup-rollback-manager.ts +11 -8
- package/src/utils/config-manager.ts +3 -3
- package/src/utils/error-handler.ts +2 -2
- package/src/utils/logger.ts +22 -22
- package/templates/batch/ci-cd.yaml +7 -7
- package/test-suites/api/health.spec.ts +20 -23
- package/test-suites/helpers/test-config.ts +14 -13
- package/test-suites/ui/accessibility.spec.ts +27 -22
- package/test-suites/ui/smoke.spec.ts +26 -21
- package/LICENSE +0 -21
- package/dist/ai/ai-service.d.ts +0 -152
- package/dist/ai/ai-service.d.ts.map +0 -1
- package/dist/ai/ai-service.js +0 -430
- package/dist/ai/ai-service.js.map +0 -1
- package/dist/ai/claude-client.d.ts +0 -130
- package/dist/ai/claude-client.d.ts.map +0 -1
- package/dist/ai/claude-client.js +0 -340
- package/dist/ai/claude-client.js.map +0 -1
- package/dist/ai/conversation-manager.d.ts +0 -164
- package/dist/ai/conversation-manager.d.ts.map +0 -1
- package/dist/ai/conversation-manager.js +0 -614
- package/dist/ai/conversation-manager.js.map +0 -1
- package/dist/ai/index.d.ts +0 -5
- package/dist/ai/index.d.ts.map +0 -1
- package/dist/ai/index.js +0 -8
- package/dist/ai/index.js.map +0 -1
- package/dist/cli.d.ts +0 -36
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -192
- package/dist/cli.js.map +0 -1
- package/dist/commands/ai.d.ts +0 -89
- package/dist/commands/ai.d.ts.map +0 -1
- package/dist/commands/ai.js +0 -799
- package/dist/commands/ai.js.map +0 -1
- package/dist/commands/alignment.d.ts +0 -78
- package/dist/commands/alignment.d.ts.map +0 -1
- package/dist/commands/alignment.js +0 -817
- package/dist/commands/alignment.js.map +0 -1
- package/dist/commands/analyze-optimized.d.ts +0 -14
- package/dist/commands/analyze-optimized.d.ts.map +0 -1
- package/dist/commands/analyze-optimized.js +0 -600
- package/dist/commands/analyze-optimized.js.map +0 -1
- package/dist/commands/analyze.d.ts +0 -65
- package/dist/commands/analyze.d.ts.map +0 -1
- package/dist/commands/analyze.js +0 -435
- package/dist/commands/analyze.js.map +0 -1
- package/dist/commands/batch.d.ts +0 -71
- package/dist/commands/batch.d.ts.map +0 -1
- package/dist/commands/batch.js +0 -738
- package/dist/commands/batch.js.map +0 -1
- package/dist/commands/chat.d.ts +0 -71
- package/dist/commands/chat.d.ts.map +0 -1
- package/dist/commands/chat.js +0 -674
- package/dist/commands/chat.js.map +0 -1
- package/dist/commands/claude-init.d.ts +0 -28
- package/dist/commands/claude-init.d.ts.map +0 -1
- package/dist/commands/claude-init.js +0 -591
- package/dist/commands/claude-init.js.map +0 -1
- package/dist/commands/claude-setup.d.ts +0 -119
- package/dist/commands/claude-setup.d.ts.map +0 -1
- package/dist/commands/claude-setup.js +0 -1073
- package/dist/commands/claude-setup.js.map +0 -1
- package/dist/commands/computer-setup-commands.d.ts +0 -53
- package/dist/commands/computer-setup-commands.d.ts.map +0 -1
- package/dist/commands/computer-setup-commands.js +0 -705
- package/dist/commands/computer-setup-commands.js.map +0 -1
- package/dist/commands/computer-setup.d.ts +0 -7
- package/dist/commands/computer-setup.d.ts.map +0 -1
- package/dist/commands/computer-setup.js +0 -849
- package/dist/commands/computer-setup.js.map +0 -1
- package/dist/commands/create-command.d.ts +0 -7
- package/dist/commands/create-command.d.ts.map +0 -1
- package/dist/commands/create-command.js +0 -158
- package/dist/commands/create-command.js.map +0 -1
- package/dist/commands/create.d.ts +0 -74
- package/dist/commands/create.d.ts.map +0 -1
- package/dist/commands/create.js +0 -556
- package/dist/commands/create.js.map +0 -1
- package/dist/commands/dashboard.d.ts +0 -91
- package/dist/commands/dashboard.d.ts.map +0 -1
- package/dist/commands/dashboard.js +0 -538
- package/dist/commands/dashboard.js.map +0 -1
- package/dist/commands/govern.d.ts +0 -70
- package/dist/commands/govern.d.ts.map +0 -1
- package/dist/commands/govern.js +0 -481
- package/dist/commands/govern.js.map +0 -1
- package/dist/commands/governance.d.ts +0 -17
- package/dist/commands/governance.d.ts.map +0 -1
- package/dist/commands/governance.js +0 -703
- package/dist/commands/governance.js.map +0 -1
- package/dist/commands/guardian.d.ts +0 -20
- package/dist/commands/guardian.d.ts.map +0 -1
- package/dist/commands/guardian.js +0 -597
- package/dist/commands/guardian.js.map +0 -1
- package/dist/commands/init.d.ts +0 -59
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -650
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/orchestrator.d.ts +0 -7
- package/dist/commands/orchestrator.d.ts.map +0 -1
- package/dist/commands/orchestrator.js +0 -571
- package/dist/commands/orchestrator.js.map +0 -1
- package/dist/commands/performance-optimizer.d.ts +0 -30
- package/dist/commands/performance-optimizer.d.ts.map +0 -1
- package/dist/commands/performance-optimizer.js +0 -650
- package/dist/commands/performance-optimizer.js.map +0 -1
- package/dist/commands/plugins.d.ts +0 -87
- package/dist/commands/plugins.d.ts.map +0 -1
- package/dist/commands/plugins.js +0 -685
- package/dist/commands/plugins.js.map +0 -1
- package/dist/commands/rag.d.ts +0 -7
- package/dist/commands/rag.d.ts.map +0 -1
- package/dist/commands/rag.js +0 -748
- package/dist/commands/rag.js.map +0 -1
- package/dist/commands/session.d.ts +0 -41
- package/dist/commands/session.d.ts.map +0 -1
- package/dist/commands/session.js +0 -441
- package/dist/commands/session.js.map +0 -1
- package/dist/commands/setup.d.ts +0 -29
- package/dist/commands/setup.d.ts.map +0 -1
- package/dist/commands/setup.js +0 -397
- package/dist/commands/setup.js.map +0 -1
- package/dist/commands/test-init.d.ts +0 -9
- package/dist/commands/test-init.d.ts.map +0 -1
- package/dist/commands/test-init.js +0 -222
- package/dist/commands/test-init.js.map +0 -1
- package/dist/commands/test.d.ts +0 -25
- package/dist/commands/test.d.ts.map +0 -1
- package/dist/commands/test.js +0 -217
- package/dist/commands/test.js.map +0 -1
- package/dist/commands/vp.d.ts +0 -7
- package/dist/commands/vp.d.ts.map +0 -1
- package/dist/commands/vp.js +0 -571
- package/dist/commands/vp.js.map +0 -1
- package/dist/commands/watch.d.ts +0 -76
- package/dist/commands/watch.d.ts.map +0 -1
- package/dist/commands/watch.js +0 -613
- package/dist/commands/watch.js.map +0 -1
- package/dist/commands/worktree.d.ts +0 -63
- package/dist/commands/worktree.d.ts.map +0 -1
- package/dist/commands/worktree.js +0 -774
- package/dist/commands/worktree.js.map +0 -1
- package/dist/context/context-manager.d.ts +0 -155
- package/dist/context/context-manager.d.ts.map +0 -1
- package/dist/context/context-manager.js +0 -383
- package/dist/context/context-manager.js.map +0 -1
- package/dist/context/index.d.ts +0 -3
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -6
- package/dist/context/index.js.map +0 -1
- package/dist/context/session-manager.d.ts +0 -207
- package/dist/context/session-manager.d.ts.map +0 -1
- package/dist/context/session-manager.js +0 -686
- package/dist/context/session-manager.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -51
- package/dist/index.js.map +0 -1
- package/dist/interactive/interactive-mode.d.ts +0 -76
- package/dist/interactive/interactive-mode.d.ts.map +0 -1
- package/dist/interactive/interactive-mode.js +0 -732
- package/dist/interactive/interactive-mode.js.map +0 -1
- package/dist/nlp/command-mapper.d.ts +0 -174
- package/dist/nlp/command-mapper.d.ts.map +0 -1
- package/dist/nlp/command-mapper.js +0 -624
- package/dist/nlp/command-mapper.js.map +0 -1
- package/dist/nlp/command-parser.d.ts +0 -106
- package/dist/nlp/command-parser.d.ts.map +0 -1
- package/dist/nlp/command-parser.js +0 -417
- package/dist/nlp/command-parser.js.map +0 -1
- package/dist/nlp/index.d.ts +0 -5
- package/dist/nlp/index.d.ts.map +0 -1
- package/dist/nlp/index.js +0 -8
- package/dist/nlp/index.js.map +0 -1
- package/dist/nlp/intent-classifier.d.ts +0 -59
- package/dist/nlp/intent-classifier.d.ts.map +0 -1
- package/dist/nlp/intent-classifier.js +0 -384
- package/dist/nlp/intent-classifier.js.map +0 -1
- package/dist/nlp/intent-parser.d.ts +0 -152
- package/dist/nlp/intent-parser.d.ts.map +0 -1
- package/dist/nlp/intent-parser.js +0 -744
- package/dist/nlp/intent-parser.js.map +0 -1
- package/dist/plugins/plugin-manager.d.ts +0 -120
- package/dist/plugins/plugin-manager.d.ts.map +0 -1
- package/dist/plugins/plugin-manager.js +0 -595
- package/dist/plugins/plugin-manager.js.map +0 -1
- package/dist/types/index.d.ts +0 -224
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/utils/backup-rollback-manager.d.ts +0 -72
- package/dist/utils/backup-rollback-manager.d.ts.map +0 -1
- package/dist/utils/backup-rollback-manager.js +0 -289
- package/dist/utils/backup-rollback-manager.js.map +0 -1
- package/dist/utils/claude-config-installer.d.ts +0 -98
- package/dist/utils/claude-config-installer.d.ts.map +0 -1
- package/dist/utils/claude-config-installer.js +0 -678
- package/dist/utils/claude-config-installer.js.map +0 -1
- package/dist/utils/config-manager.d.ts +0 -73
- package/dist/utils/config-manager.d.ts.map +0 -1
- package/dist/utils/config-manager.js +0 -339
- package/dist/utils/config-manager.js.map +0 -1
- package/dist/utils/error-handler.d.ts +0 -46
- package/dist/utils/error-handler.d.ts.map +0 -1
- package/dist/utils/error-handler.js +0 -169
- package/dist/utils/error-handler.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -25
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -105
- package/dist/utils/logger.js.map +0 -1
- package/src/commands/computer-setup-commands.ts +0 -872
package/dist/commands/chat.js
DELETED
|
@@ -1,674 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChatCommands = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
8
|
-
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
9
|
-
const error_handler_1 = require("../utils/error-handler");
|
|
10
|
-
const logger_1 = require("../utils/logger");
|
|
11
|
-
/**
|
|
12
|
-
* Chat commands for natural language interface
|
|
13
|
-
*/
|
|
14
|
-
class ChatCommands {
|
|
15
|
-
program;
|
|
16
|
-
configManager;
|
|
17
|
-
pluginManager;
|
|
18
|
-
activeSessions = new Map();
|
|
19
|
-
constructor(program, configManager, pluginManager) {
|
|
20
|
-
this.program = program;
|
|
21
|
-
this.configManager = configManager;
|
|
22
|
-
this.pluginManager = pluginManager;
|
|
23
|
-
this.registerCommands();
|
|
24
|
-
}
|
|
25
|
-
registerCommands() {
|
|
26
|
-
const chatCmd = this.program
|
|
27
|
-
.command('chat')
|
|
28
|
-
.alias('c')
|
|
29
|
-
.description('natural language chat interface');
|
|
30
|
-
// Start chat session
|
|
31
|
-
chatCmd
|
|
32
|
-
.command('start')
|
|
33
|
-
.description('start a new chat session')
|
|
34
|
-
.option('--model <model>', 'AI model to use', 'claude-3')
|
|
35
|
-
.option('--context <path>', 'include project context from path')
|
|
36
|
-
.option('--persona <persona>', 'AI persona (developer, architect, reviewer)', 'developer')
|
|
37
|
-
.option('--session-name <name>', 'custom session name')
|
|
38
|
-
.action(async (options) => {
|
|
39
|
-
await this.startChatSession(options);
|
|
40
|
-
});
|
|
41
|
-
// Resume chat session
|
|
42
|
-
chatCmd
|
|
43
|
-
.command('resume <sessionId>')
|
|
44
|
-
.description('resume existing chat session')
|
|
45
|
-
.action(async (sessionId) => {
|
|
46
|
-
await this.resumeChatSession(sessionId);
|
|
47
|
-
});
|
|
48
|
-
// List chat sessions
|
|
49
|
-
chatCmd
|
|
50
|
-
.command('list')
|
|
51
|
-
.alias('ls')
|
|
52
|
-
.description('list chat sessions')
|
|
53
|
-
.option('--active-only', 'show only active sessions')
|
|
54
|
-
.action(async (options) => {
|
|
55
|
-
await this.listChatSessions(options);
|
|
56
|
-
});
|
|
57
|
-
// Send single message
|
|
58
|
-
chatCmd
|
|
59
|
-
.command('ask <message>')
|
|
60
|
-
.description('send a single message and get response')
|
|
61
|
-
.option('--session <sessionId>', 'use specific session')
|
|
62
|
-
.option('--model <model>', 'AI model to use')
|
|
63
|
-
.option('--context <path>', 'include context from path')
|
|
64
|
-
.action(async (message, options) => {
|
|
65
|
-
await this.askSingleQuestion(message, options);
|
|
66
|
-
});
|
|
67
|
-
// Export chat session
|
|
68
|
-
chatCmd
|
|
69
|
-
.command('export <sessionId>')
|
|
70
|
-
.description('export chat session')
|
|
71
|
-
.option('--format <format>', 'export format (json, markdown, txt)', 'markdown')
|
|
72
|
-
.option('--output <path>', 'output file path')
|
|
73
|
-
.action(async (sessionId, options) => {
|
|
74
|
-
await this.exportChatSession(sessionId, options);
|
|
75
|
-
});
|
|
76
|
-
// Import chat session
|
|
77
|
-
chatCmd
|
|
78
|
-
.command('import <file>')
|
|
79
|
-
.description('import chat session')
|
|
80
|
-
.option('--format <format>', 'import format (json, markdown)')
|
|
81
|
-
.action(async (file, options) => {
|
|
82
|
-
await this.importChatSession(file, options);
|
|
83
|
-
});
|
|
84
|
-
// Delete chat session
|
|
85
|
-
chatCmd
|
|
86
|
-
.command('delete <sessionId>')
|
|
87
|
-
.description('delete chat session')
|
|
88
|
-
.option('--force', 'skip confirmation')
|
|
89
|
-
.action(async (sessionId, options) => {
|
|
90
|
-
await this.deleteChatSession(sessionId, options);
|
|
91
|
-
});
|
|
92
|
-
// Configure chat
|
|
93
|
-
chatCmd.command('config').description('configure chat settings');
|
|
94
|
-
chatCmd
|
|
95
|
-
.command('config set <key> <value>')
|
|
96
|
-
.description('set chat configuration')
|
|
97
|
-
.action(async (key, value) => {
|
|
98
|
-
await this.setChatConfig(key, value);
|
|
99
|
-
});
|
|
100
|
-
chatCmd
|
|
101
|
-
.command('config get [key]')
|
|
102
|
-
.description('get chat configuration')
|
|
103
|
-
.action(async (key) => {
|
|
104
|
-
await this.getChatConfig(key);
|
|
105
|
-
});
|
|
106
|
-
// Chat with files
|
|
107
|
-
chatCmd
|
|
108
|
-
.command('file <file>')
|
|
109
|
-
.description('chat about specific file')
|
|
110
|
-
.option('--action <action>', 'action to perform (explain, review, improve)', 'explain')
|
|
111
|
-
.option('--model <model>', 'AI model to use')
|
|
112
|
-
.action(async (file, options) => {
|
|
113
|
-
await this.chatWithFile(file, options);
|
|
114
|
-
});
|
|
115
|
-
// Chat with code
|
|
116
|
-
chatCmd
|
|
117
|
-
.command('code')
|
|
118
|
-
.description('chat about code from clipboard or input')
|
|
119
|
-
.option('--clipboard', 'read code from clipboard')
|
|
120
|
-
.option('--action <action>', 'action to perform (explain, review, improve)', 'explain')
|
|
121
|
-
.action(async (options) => {
|
|
122
|
-
await this.chatWithCode(options);
|
|
123
|
-
});
|
|
124
|
-
// Chat templates
|
|
125
|
-
chatCmd.command('template').description('manage chat templates');
|
|
126
|
-
chatCmd
|
|
127
|
-
.command('template list')
|
|
128
|
-
.description('list available chat templates')
|
|
129
|
-
.action(async () => {
|
|
130
|
-
await this.listChatTemplates();
|
|
131
|
-
});
|
|
132
|
-
chatCmd
|
|
133
|
-
.command('template use <name>')
|
|
134
|
-
.description('start chat with template')
|
|
135
|
-
.option('--vars <vars>', 'template variables (JSON or key=value)')
|
|
136
|
-
.action(async (name, options) => {
|
|
137
|
-
await this.useChatTemplate(name, options);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Start a new chat session
|
|
142
|
-
*/
|
|
143
|
-
async startChatSession(options) {
|
|
144
|
-
try {
|
|
145
|
-
logger_1.logger.info('Starting new chat session...');
|
|
146
|
-
const session = await this.createNewSession(options);
|
|
147
|
-
this.activeSessions.set(session.id, session);
|
|
148
|
-
console.log(chalk_1.default.green(`\n🤖 Chat Session Started (${session.model})`));
|
|
149
|
-
console.log(chalk_1.default.gray(`Session ID: ${session.id}`));
|
|
150
|
-
if (session.context) {
|
|
151
|
-
console.log(chalk_1.default.gray(`Context: ${session.context}`));
|
|
152
|
-
}
|
|
153
|
-
console.log(chalk_1.default.gray('Type "exit" to end the session, "help" for commands\n'));
|
|
154
|
-
await this.runChatLoop(session);
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
throw error_handler_1.errorHandler.createError('WUNDR_CHAT_START_FAILED', 'Failed to start chat session', { options }, true);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Resume existing chat session
|
|
162
|
-
*/
|
|
163
|
-
async resumeChatSession(sessionId) {
|
|
164
|
-
try {
|
|
165
|
-
logger_1.logger.info(`Resuming chat session: ${sessionId}`);
|
|
166
|
-
const session = await this.loadChatSession(sessionId);
|
|
167
|
-
if (!session) {
|
|
168
|
-
throw new Error(`Chat session not found: ${sessionId}`);
|
|
169
|
-
}
|
|
170
|
-
this.activeSessions.set(sessionId, session);
|
|
171
|
-
console.log(chalk_1.default.green(`\n🤖 Chat Session Resumed (${session.model})`));
|
|
172
|
-
console.log(chalk_1.default.gray(`Session ID: ${session.id}`));
|
|
173
|
-
console.log(chalk_1.default.gray(`Messages: ${session.history.length}`));
|
|
174
|
-
console.log(chalk_1.default.gray(`Last updated: ${session.updated.toLocaleString()}\n`));
|
|
175
|
-
// Show recent messages
|
|
176
|
-
if (session.history.length > 0) {
|
|
177
|
-
console.log(chalk_1.default.blue('Recent messages:'));
|
|
178
|
-
session.history.slice(-3).forEach(msg => {
|
|
179
|
-
const role = msg.role === 'user' ? 'You' : 'AI';
|
|
180
|
-
const content = msg.content.length > 100
|
|
181
|
-
? msg.content.substring(0, 100) + '...'
|
|
182
|
-
: msg.content;
|
|
183
|
-
console.log(` ${chalk_1.default.cyan(role)}: ${content}`);
|
|
184
|
-
});
|
|
185
|
-
console.log();
|
|
186
|
-
}
|
|
187
|
-
await this.runChatLoop(session);
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
throw error_handler_1.errorHandler.createError('WUNDR_CHAT_RESUME_FAILED', 'Failed to resume chat session', { sessionId }, true);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* List chat sessions
|
|
195
|
-
*/
|
|
196
|
-
async listChatSessions(options) {
|
|
197
|
-
try {
|
|
198
|
-
const sessions = await this.getAllChatSessions();
|
|
199
|
-
const filteredSessions = options.activeOnly
|
|
200
|
-
? sessions.filter(s => this.activeSessions.has(s.id))
|
|
201
|
-
: sessions;
|
|
202
|
-
if (filteredSessions.length === 0) {
|
|
203
|
-
logger_1.logger.info('No chat sessions found');
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
logger_1.logger.info(`Chat sessions (${filteredSessions.length}):`);
|
|
207
|
-
const sessionData = filteredSessions.map(session => ({
|
|
208
|
-
ID: session.id,
|
|
209
|
-
Model: session.model,
|
|
210
|
-
Messages: session.history.length,
|
|
211
|
-
Created: session.created.toLocaleDateString(),
|
|
212
|
-
Updated: session.updated.toLocaleDateString(),
|
|
213
|
-
Active: this.activeSessions.has(session.id) ? '✓' : '✗',
|
|
214
|
-
}));
|
|
215
|
-
console.table(sessionData);
|
|
216
|
-
}
|
|
217
|
-
catch (error) {
|
|
218
|
-
throw error_handler_1.errorHandler.createError('WUNDR_CHAT_LIST_FAILED', 'Failed to list chat sessions', { options }, true);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Ask a single question
|
|
223
|
-
*/
|
|
224
|
-
async askSingleQuestion(message, options) {
|
|
225
|
-
try {
|
|
226
|
-
logger_1.logger.debug('Processing single question...');
|
|
227
|
-
let session;
|
|
228
|
-
if (options.session) {
|
|
229
|
-
session = await this.loadChatSession(options.session);
|
|
230
|
-
if (!session) {
|
|
231
|
-
throw new Error(`Chat session not found: ${options.session}`);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
session = await this.createNewSession({
|
|
236
|
-
model: options.model,
|
|
237
|
-
context: options.context,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
const response = await this.sendMessage(session, message);
|
|
241
|
-
console.log(chalk_1.default.cyan('\nAI Response:'));
|
|
242
|
-
console.log(response);
|
|
243
|
-
console.log();
|
|
244
|
-
// Save session if it was created for this question
|
|
245
|
-
if (!options.session) {
|
|
246
|
-
await this.saveChatSession(session);
|
|
247
|
-
logger_1.logger.debug(`Session saved: ${session.id}`);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
catch (error) {
|
|
251
|
-
throw error_handler_1.errorHandler.createError('WUNDR_CHAT_ASK_FAILED', 'Failed to process question', { message, options }, true);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Export chat session
|
|
256
|
-
*/
|
|
257
|
-
async exportChatSession(sessionId, options) {
|
|
258
|
-
try {
|
|
259
|
-
logger_1.logger.info(`Exporting chat session: ${sessionId}`);
|
|
260
|
-
const session = await this.loadChatSession(sessionId);
|
|
261
|
-
if (!session) {
|
|
262
|
-
throw new Error(`Chat session not found: ${sessionId}`);
|
|
263
|
-
}
|
|
264
|
-
let exportedContent;
|
|
265
|
-
switch (options.format) {
|
|
266
|
-
case 'json':
|
|
267
|
-
exportedContent = JSON.stringify(session, null, 2);
|
|
268
|
-
break;
|
|
269
|
-
case 'markdown':
|
|
270
|
-
exportedContent = this.convertToMarkdown(session);
|
|
271
|
-
break;
|
|
272
|
-
case 'txt':
|
|
273
|
-
exportedContent = this.convertToText(session);
|
|
274
|
-
break;
|
|
275
|
-
default:
|
|
276
|
-
throw new Error(`Unsupported export format: ${options.format}`);
|
|
277
|
-
}
|
|
278
|
-
const outputPath = options.output || `chat-${sessionId}.${options.format}`;
|
|
279
|
-
await fs_extra_1.default.writeFile(outputPath, exportedContent);
|
|
280
|
-
logger_1.logger.success(`Chat session exported: ${outputPath}`);
|
|
281
|
-
}
|
|
282
|
-
catch (error) {
|
|
283
|
-
throw error_handler_1.errorHandler.createError('WUNDR_CHAT_EXPORT_FAILED', 'Failed to export chat session', { sessionId, options }, true);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Import chat session
|
|
288
|
-
*/
|
|
289
|
-
async importChatSession(file, options) {
|
|
290
|
-
try {
|
|
291
|
-
logger_1.logger.info(`Importing chat session: ${file}`);
|
|
292
|
-
if (!(await fs_extra_1.default.pathExists(file))) {
|
|
293
|
-
throw new Error(`File not found: ${file}`);
|
|
294
|
-
}
|
|
295
|
-
let session;
|
|
296
|
-
switch (options.format) {
|
|
297
|
-
case 'json':
|
|
298
|
-
session = await fs_extra_1.default.readJson(file);
|
|
299
|
-
break;
|
|
300
|
-
case 'markdown':
|
|
301
|
-
session = await this.parseMarkdown(file);
|
|
302
|
-
break;
|
|
303
|
-
default:
|
|
304
|
-
throw new Error(`Unsupported import format: ${options.format}`);
|
|
305
|
-
}
|
|
306
|
-
// Generate new ID for imported session
|
|
307
|
-
session.id = `imported-${Date.now()}`;
|
|
308
|
-
session.created = new Date();
|
|
309
|
-
session.updated = new Date();
|
|
310
|
-
await this.saveChatSession(session);
|
|
311
|
-
logger_1.logger.success(`Chat session imported: ${session.id}`);
|
|
312
|
-
}
|
|
313
|
-
catch (error) {
|
|
314
|
-
throw error_handler_1.errorHandler.createError('WUNDR_CHAT_IMPORT_FAILED', 'Failed to import chat session', { file, options }, true);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Delete chat session
|
|
319
|
-
*/
|
|
320
|
-
async deleteChatSession(sessionId, options) {
|
|
321
|
-
try {
|
|
322
|
-
const session = await this.loadChatSession(sessionId);
|
|
323
|
-
if (!session) {
|
|
324
|
-
throw new Error(`Chat session not found: ${sessionId}`);
|
|
325
|
-
}
|
|
326
|
-
if (!options.force) {
|
|
327
|
-
const { confirm } = await inquirer_1.default.prompt([
|
|
328
|
-
{
|
|
329
|
-
type: 'confirm',
|
|
330
|
-
name: 'confirm',
|
|
331
|
-
message: `Delete chat session ${sessionId}? (${session.history.length} messages)`,
|
|
332
|
-
default: false,
|
|
333
|
-
},
|
|
334
|
-
]);
|
|
335
|
-
if (!confirm) {
|
|
336
|
-
logger_1.logger.info('Deletion cancelled');
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
await this.deleteChatSessionFile(sessionId);
|
|
341
|
-
this.activeSessions.delete(sessionId);
|
|
342
|
-
logger_1.logger.success(`Chat session deleted: ${sessionId}`);
|
|
343
|
-
}
|
|
344
|
-
catch (error) {
|
|
345
|
-
throw error_handler_1.errorHandler.createError('WUNDR_CHAT_DELETE_FAILED', 'Failed to delete chat session', { sessionId, options }, true);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Chat with specific file
|
|
350
|
-
*/
|
|
351
|
-
async chatWithFile(file, options) {
|
|
352
|
-
try {
|
|
353
|
-
if (!(await fs_extra_1.default.pathExists(file))) {
|
|
354
|
-
throw new Error(`File not found: ${file}`);
|
|
355
|
-
}
|
|
356
|
-
const fileContent = await fs_extra_1.default.readFile(file, 'utf8');
|
|
357
|
-
const fileName = path_1.default.basename(file);
|
|
358
|
-
const actionPrompts = {
|
|
359
|
-
explain: `Please explain this code from ${fileName}:`,
|
|
360
|
-
review: `Please review this code from ${fileName} for potential issues:`,
|
|
361
|
-
improve: `Please suggest improvements for this code from ${fileName}:`,
|
|
362
|
-
};
|
|
363
|
-
const prompt = actionPrompts[options.action] ||
|
|
364
|
-
actionPrompts.explain;
|
|
365
|
-
const message = `${prompt}\n\n\`\`\`\n${fileContent}\n\`\`\``;
|
|
366
|
-
await this.askSingleQuestion(message, { model: options.model });
|
|
367
|
-
}
|
|
368
|
-
catch (error) {
|
|
369
|
-
throw error_handler_1.errorHandler.createError('WUNDR_CHAT_FILE_FAILED', 'Failed to chat with file', { file, options }, true);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Chat with code
|
|
374
|
-
*/
|
|
375
|
-
async chatWithCode(options) {
|
|
376
|
-
try {
|
|
377
|
-
let code;
|
|
378
|
-
if (options.clipboard) {
|
|
379
|
-
// Read from clipboard (would need clipboard library)
|
|
380
|
-
code = 'Code from clipboard'; // Placeholder
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
const { codeInput } = await inquirer_1.default.prompt([
|
|
384
|
-
{
|
|
385
|
-
type: 'editor',
|
|
386
|
-
name: 'codeInput',
|
|
387
|
-
message: 'Enter your code:',
|
|
388
|
-
},
|
|
389
|
-
]);
|
|
390
|
-
code = codeInput;
|
|
391
|
-
}
|
|
392
|
-
const actionPrompts = {
|
|
393
|
-
explain: 'Please explain this code:',
|
|
394
|
-
review: 'Please review this code for potential issues:',
|
|
395
|
-
improve: 'Please suggest improvements for this code:',
|
|
396
|
-
};
|
|
397
|
-
const prompt = actionPrompts[options.action] ||
|
|
398
|
-
actionPrompts.explain;
|
|
399
|
-
const message = `${prompt}\n\n\`\`\`\n${code}\n\`\`\``;
|
|
400
|
-
await this.askSingleQuestion(message, {});
|
|
401
|
-
}
|
|
402
|
-
catch (error) {
|
|
403
|
-
throw error_handler_1.errorHandler.createError('WUNDR_CHAT_CODE_FAILED', 'Failed to chat with code', { options }, true);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Helper methods for chat operations
|
|
408
|
-
*/
|
|
409
|
-
async createNewSession(options) {
|
|
410
|
-
const config = this.configManager.getConfig();
|
|
411
|
-
return {
|
|
412
|
-
id: options.sessionName || `session-${Date.now()}`,
|
|
413
|
-
model: options.model || config.ai.model,
|
|
414
|
-
context: options.context,
|
|
415
|
-
history: [],
|
|
416
|
-
created: new Date(),
|
|
417
|
-
updated: new Date(),
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
async runChatLoop(session) {
|
|
421
|
-
while (true) {
|
|
422
|
-
try {
|
|
423
|
-
const { message } = await inquirer_1.default.prompt([
|
|
424
|
-
{
|
|
425
|
-
type: 'input',
|
|
426
|
-
name: 'message',
|
|
427
|
-
message: chalk_1.default.green('You:'),
|
|
428
|
-
validate: input => input.length > 0 || 'Message cannot be empty',
|
|
429
|
-
},
|
|
430
|
-
]);
|
|
431
|
-
if (message.toLowerCase() === 'exit') {
|
|
432
|
-
break;
|
|
433
|
-
}
|
|
434
|
-
if (message.toLowerCase() === 'help') {
|
|
435
|
-
this.showChatHelp();
|
|
436
|
-
continue;
|
|
437
|
-
}
|
|
438
|
-
if (message.startsWith('/')) {
|
|
439
|
-
await this.handleChatCommand(session, message);
|
|
440
|
-
continue;
|
|
441
|
-
}
|
|
442
|
-
const response = await this.sendMessage(session, message);
|
|
443
|
-
console.log(chalk_1.default.cyan(`\nAI: ${response}\n`));
|
|
444
|
-
}
|
|
445
|
-
catch (error) {
|
|
446
|
-
logger_1.logger.error('Chat error:', error);
|
|
447
|
-
console.log(chalk_1.default.red('Sorry, there was an error processing your message.\n'));
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
// Save session when exiting
|
|
451
|
-
await this.saveChatSession(session);
|
|
452
|
-
this.activeSessions.delete(session.id);
|
|
453
|
-
logger_1.logger.success('Chat session ended and saved');
|
|
454
|
-
}
|
|
455
|
-
async sendMessage(session, message) {
|
|
456
|
-
// Add user message to history
|
|
457
|
-
const userMessage = {
|
|
458
|
-
role: 'user',
|
|
459
|
-
content: message,
|
|
460
|
-
timestamp: new Date(),
|
|
461
|
-
};
|
|
462
|
-
session.history.push(userMessage);
|
|
463
|
-
// Call AI service (mock implementation)
|
|
464
|
-
const response = await this.callAI(session, message);
|
|
465
|
-
// Add AI response to history
|
|
466
|
-
const aiMessage = {
|
|
467
|
-
role: 'assistant',
|
|
468
|
-
content: response,
|
|
469
|
-
timestamp: new Date(),
|
|
470
|
-
};
|
|
471
|
-
session.history.push(aiMessage);
|
|
472
|
-
session.updated = new Date();
|
|
473
|
-
return response;
|
|
474
|
-
}
|
|
475
|
-
async callAI(session, message) {
|
|
476
|
-
// Mock AI service call
|
|
477
|
-
// In a real implementation, this would call Claude, GPT, etc.
|
|
478
|
-
return `This is a mock response to: "${message}". The AI would provide a helpful response here based on the context and conversation history.`;
|
|
479
|
-
}
|
|
480
|
-
showChatHelp() {
|
|
481
|
-
console.log(chalk_1.default.blue('\nChat Commands:'));
|
|
482
|
-
console.log(' exit - End the chat session');
|
|
483
|
-
console.log(' help - Show this help message');
|
|
484
|
-
console.log(' /clear - Clear chat history');
|
|
485
|
-
console.log(' /save - Save chat session');
|
|
486
|
-
console.log(' /export - Export chat session');
|
|
487
|
-
console.log(' /context - Show current context');
|
|
488
|
-
console.log(' /model - Change AI model');
|
|
489
|
-
console.log();
|
|
490
|
-
}
|
|
491
|
-
async handleChatCommand(session, command) {
|
|
492
|
-
const [cmd, ...args] = command.slice(1).split(' ');
|
|
493
|
-
switch (cmd) {
|
|
494
|
-
case 'clear':
|
|
495
|
-
session.history = [];
|
|
496
|
-
console.log(chalk_1.default.green('Chat history cleared\n'));
|
|
497
|
-
break;
|
|
498
|
-
case 'save':
|
|
499
|
-
await this.saveChatSession(session);
|
|
500
|
-
console.log(chalk_1.default.green(`Session saved: ${session.id}\n`));
|
|
501
|
-
break;
|
|
502
|
-
case 'export':
|
|
503
|
-
const format = args[0] || 'markdown';
|
|
504
|
-
await this.exportChatSession(session.id, {
|
|
505
|
-
format,
|
|
506
|
-
output: `${session.id}.${format}`,
|
|
507
|
-
});
|
|
508
|
-
break;
|
|
509
|
-
case 'context':
|
|
510
|
-
console.log(chalk_1.default.blue('Current Context:'));
|
|
511
|
-
console.log(` Model: ${session.model}`);
|
|
512
|
-
console.log(` Messages: ${session.history.length}`);
|
|
513
|
-
console.log(` Context: ${session.context || 'None'}\n`);
|
|
514
|
-
break;
|
|
515
|
-
case 'model':
|
|
516
|
-
if (args[0]) {
|
|
517
|
-
session.model = args[0];
|
|
518
|
-
console.log(chalk_1.default.green(`Model changed to: ${args[0]}\n`));
|
|
519
|
-
}
|
|
520
|
-
else {
|
|
521
|
-
console.log(chalk_1.default.yellow('Current model: ' + session.model + '\n'));
|
|
522
|
-
}
|
|
523
|
-
break;
|
|
524
|
-
default:
|
|
525
|
-
console.log(chalk_1.default.red(`Unknown command: /${cmd}\n`));
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
async saveChatSession(session) {
|
|
529
|
-
const sessionPath = path_1.default.join(process.cwd(), '.wundr', 'chat', `${session.id}.json`);
|
|
530
|
-
await fs_extra_1.default.ensureDir(path_1.default.dirname(sessionPath));
|
|
531
|
-
await fs_extra_1.default.writeJson(sessionPath, session, { spaces: 2 });
|
|
532
|
-
}
|
|
533
|
-
async loadChatSession(sessionId) {
|
|
534
|
-
const sessionPath = path_1.default.join(process.cwd(), '.wundr', 'chat', `${sessionId}.json`);
|
|
535
|
-
if (await fs_extra_1.default.pathExists(sessionPath)) {
|
|
536
|
-
const data = await fs_extra_1.default.readJson(sessionPath);
|
|
537
|
-
data.created = new Date(data.created);
|
|
538
|
-
data.updated = new Date(data.updated);
|
|
539
|
-
data.history = data.history.map((msg) => ({
|
|
540
|
-
...msg,
|
|
541
|
-
timestamp: new Date(msg.timestamp),
|
|
542
|
-
}));
|
|
543
|
-
return data;
|
|
544
|
-
}
|
|
545
|
-
return null;
|
|
546
|
-
}
|
|
547
|
-
async getAllChatSessions() {
|
|
548
|
-
const chatDir = path_1.default.join(process.cwd(), '.wundr', 'chat');
|
|
549
|
-
if (!(await fs_extra_1.default.pathExists(chatDir))) {
|
|
550
|
-
return [];
|
|
551
|
-
}
|
|
552
|
-
const files = await fs_extra_1.default.readdir(chatDir);
|
|
553
|
-
const jsonFiles = files.filter(f => f.endsWith('.json'));
|
|
554
|
-
const sessions = [];
|
|
555
|
-
for (const file of jsonFiles) {
|
|
556
|
-
try {
|
|
557
|
-
const sessionId = path_1.default.basename(file, '.json');
|
|
558
|
-
const session = await this.loadChatSession(sessionId);
|
|
559
|
-
if (session) {
|
|
560
|
-
sessions.push(session);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
catch (error) {
|
|
564
|
-
logger_1.logger.debug(`Failed to load session ${file}:`, error);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
return sessions;
|
|
568
|
-
}
|
|
569
|
-
async deleteChatSessionFile(sessionId) {
|
|
570
|
-
const sessionPath = path_1.default.join(process.cwd(), '.wundr', 'chat', `${sessionId}.json`);
|
|
571
|
-
if (await fs_extra_1.default.pathExists(sessionPath)) {
|
|
572
|
-
await fs_extra_1.default.remove(sessionPath);
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
convertToMarkdown(session) {
|
|
576
|
-
let markdown = `# Chat Session: ${session.id}\n\n`;
|
|
577
|
-
markdown += `**Model:** ${session.model}\n`;
|
|
578
|
-
markdown += `**Created:** ${session.created.toLocaleString()}\n`;
|
|
579
|
-
markdown += `**Updated:** ${session.updated.toLocaleString()}\n`;
|
|
580
|
-
if (session.context) {
|
|
581
|
-
markdown += `**Context:** ${session.context}\n`;
|
|
582
|
-
}
|
|
583
|
-
markdown += `**Messages:** ${session.history.length}\n\n`;
|
|
584
|
-
markdown += '---\n\n';
|
|
585
|
-
session.history.forEach(msg => {
|
|
586
|
-
const role = msg.role === 'user' ? '**You**' : '**AI**';
|
|
587
|
-
markdown += `${role} (${msg.timestamp.toLocaleTimeString()}):\n\n`;
|
|
588
|
-
markdown += `${msg.content}\n\n`;
|
|
589
|
-
markdown += '---\n\n';
|
|
590
|
-
});
|
|
591
|
-
return markdown;
|
|
592
|
-
}
|
|
593
|
-
convertToText(session) {
|
|
594
|
-
let text = `Chat Session: ${session.id}\n`;
|
|
595
|
-
text += `Model: ${session.model}\n`;
|
|
596
|
-
text += `Created: ${session.created.toLocaleString()}\n`;
|
|
597
|
-
text += `Updated: ${session.updated.toLocaleString()}\n`;
|
|
598
|
-
text += `Messages: ${session.history.length}\n\n`;
|
|
599
|
-
text += '='.repeat(50) + '\n\n';
|
|
600
|
-
session.history.forEach(msg => {
|
|
601
|
-
const role = msg.role === 'user' ? 'You' : 'AI';
|
|
602
|
-
text += `[${msg.timestamp.toLocaleTimeString()}] ${role}:\n`;
|
|
603
|
-
text += `${msg.content}\n\n`;
|
|
604
|
-
text += '-'.repeat(30) + '\n\n';
|
|
605
|
-
});
|
|
606
|
-
return text;
|
|
607
|
-
}
|
|
608
|
-
async parseMarkdown(file) {
|
|
609
|
-
// Implementation to parse markdown format back to session
|
|
610
|
-
const content = await fs_extra_1.default.readFile(file, 'utf8');
|
|
611
|
-
// This is a simplified parser - a real implementation would be more robust
|
|
612
|
-
return {
|
|
613
|
-
id: `parsed-${Date.now()}`,
|
|
614
|
-
model: 'claude-3',
|
|
615
|
-
history: [],
|
|
616
|
-
created: new Date(),
|
|
617
|
-
updated: new Date(),
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
|
-
// Configuration methods
|
|
621
|
-
async setChatConfig(key, value) {
|
|
622
|
-
this.configManager.set(`chat.${key}`, value);
|
|
623
|
-
await this.configManager.saveConfig();
|
|
624
|
-
logger_1.logger.success(`Chat configuration updated: ${key} = ${value}`);
|
|
625
|
-
}
|
|
626
|
-
async getChatConfig(key) {
|
|
627
|
-
if (key) {
|
|
628
|
-
const value = this.configManager.get(`chat.${key}`);
|
|
629
|
-
console.log(`${key}: ${value}`);
|
|
630
|
-
}
|
|
631
|
-
else {
|
|
632
|
-
const chatConfig = this.configManager.get('chat') || {};
|
|
633
|
-
console.log(JSON.stringify(chatConfig, null, 2));
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
// Template methods
|
|
637
|
-
async listChatTemplates() {
|
|
638
|
-
const templates = [
|
|
639
|
-
'code-review',
|
|
640
|
-
'explain-code',
|
|
641
|
-
'debug-help',
|
|
642
|
-
'architecture-review',
|
|
643
|
-
'performance-optimization',
|
|
644
|
-
];
|
|
645
|
-
console.log('Available chat templates:');
|
|
646
|
-
templates.forEach(template => {
|
|
647
|
-
console.log(` - ${template}`);
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
async useChatTemplate(name, options) {
|
|
651
|
-
const templates = {
|
|
652
|
-
'code-review': 'Please review the following code for best practices, potential bugs, and improvements:',
|
|
653
|
-
'explain-code': 'Please explain what this code does and how it works:',
|
|
654
|
-
'debug-help': "I'm having trouble with this code. Can you help me debug it?",
|
|
655
|
-
'architecture-review': 'Please review this architectural design and suggest improvements:',
|
|
656
|
-
'performance-optimization': 'Please suggest performance optimizations for this code:',
|
|
657
|
-
};
|
|
658
|
-
const template = templates[name];
|
|
659
|
-
if (!template) {
|
|
660
|
-
throw new Error(`Template not found: ${name}`);
|
|
661
|
-
}
|
|
662
|
-
// Process template variables if provided
|
|
663
|
-
let processedTemplate = template;
|
|
664
|
-
if (options.vars) {
|
|
665
|
-
const variables = JSON.parse(options.vars);
|
|
666
|
-
Object.entries(variables).forEach(([key, value]) => {
|
|
667
|
-
processedTemplate = processedTemplate.replace(`{{${key}}}`, String(value));
|
|
668
|
-
});
|
|
669
|
-
}
|
|
670
|
-
await this.askSingleQuestion(processedTemplate, {});
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
exports.ChatCommands = ChatCommands;
|
|
674
|
-
//# sourceMappingURL=chat.js.map
|