vigthoria-cli 1.10.37 → 1.10.48
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/dist/commands/agent-session-menu.d.ts +19 -0
- package/dist/commands/agent-session-menu.js +155 -0
- package/dist/commands/chat.js +407 -1254
- package/dist/index.js +5 -2
- package/dist/utils/api.js +95 -14
- package/dist/utils/tools.js +6 -0
- package/package.json +3 -6
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface AgentSessionConfig {
|
|
2
|
+
workspacePath: string;
|
|
3
|
+
debugMode: boolean;
|
|
4
|
+
autoApprove: boolean;
|
|
5
|
+
autoSave: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface AgentSessionMenuDefaults {
|
|
8
|
+
workspacePath?: string;
|
|
9
|
+
debugMode?: boolean;
|
|
10
|
+
autoApprove?: boolean;
|
|
11
|
+
autoSave?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface AgentSessionMenuOptions {
|
|
14
|
+
prompt?: string;
|
|
15
|
+
json?: boolean;
|
|
16
|
+
projectProvided?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function shouldShowAgentSessionMenu(options?: AgentSessionMenuOptions): boolean;
|
|
19
|
+
export declare function runAgentSessionMenu(defaults?: AgentSessionMenuDefaults): Promise<AgentSessionConfig>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive agent/operator session setup menu (Node inquirer — CLI equivalent of InquirerPy).
|
|
3
|
+
*/
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import * as fs from 'fs';
|
|
7
|
+
import * as os from 'os';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
|
|
10
|
+
function validateExistingDirectory(input) {
|
|
11
|
+
const trimmed = String(input || '').trim().replace(/^['"]|['"]$/g, '');
|
|
12
|
+
if (!trimmed) {
|
|
13
|
+
return 'Path is required.';
|
|
14
|
+
}
|
|
15
|
+
const resolved = path.resolve(trimmed);
|
|
16
|
+
try {
|
|
17
|
+
if (!fs.existsSync(resolved)) {
|
|
18
|
+
return `Directory does not exist: ${resolved}`;
|
|
19
|
+
}
|
|
20
|
+
if (!fs.statSync(resolved).isDirectory()) {
|
|
21
|
+
return `Not a directory: ${resolved}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return `Cannot access path: ${error?.message || error}`;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function shouldShowAgentSessionMenu(options = {}) {
|
|
31
|
+
if (options.prompt) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (options.json) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (options.projectProvided) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (/^(1|true|yes)$/i.test(String(process.env.VIGTHORIA_NO_SESSION_MENU || ''))) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return Boolean(process.stdout.isTTY && process.stdin.isTTY);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function runAgentSessionMenu(defaults = {}) {
|
|
47
|
+
const session = {
|
|
48
|
+
workspacePath: path.resolve(String(defaults.workspacePath || process.cwd())),
|
|
49
|
+
debugMode: defaults.debugMode === true,
|
|
50
|
+
autoApprove: defaults.autoApprove === true,
|
|
51
|
+
autoSave: defaults.autoSave !== false,
|
|
52
|
+
};
|
|
53
|
+
const recentHint = String(defaults.configuredRoot || '').trim();
|
|
54
|
+
let done = false;
|
|
55
|
+
let menuPass = 0;
|
|
56
|
+
while (!done) {
|
|
57
|
+
if (menuPass === 0) {
|
|
58
|
+
console.log();
|
|
59
|
+
console.log(chalk.cyan('═══ Agent Session Setup ═══'));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
console.log();
|
|
63
|
+
console.log(chalk.cyan('── Session settings ──'));
|
|
64
|
+
}
|
|
65
|
+
menuPass += 1;
|
|
66
|
+
console.log(chalk.gray(`Workspace: ${session.workspacePath}`));
|
|
67
|
+
if (recentHint && recentHint !== session.workspacePath) {
|
|
68
|
+
console.log(chalk.gray(`Configured default: ${recentHint}`));
|
|
69
|
+
}
|
|
70
|
+
console.log(chalk.gray(`Debug: ${session.debugMode ? 'on' : 'off'} | Auto-approve: ${session.autoApprove ? 'on' : 'off'} | Auto-save: ${session.autoSave ? 'on' : 'off'}`));
|
|
71
|
+
console.log();
|
|
72
|
+
const { action } = await inquirer.prompt([
|
|
73
|
+
{
|
|
74
|
+
type: 'list',
|
|
75
|
+
name: 'action',
|
|
76
|
+
message: 'Configure your session',
|
|
77
|
+
choices: [
|
|
78
|
+
{ name: 'Set workspace path (existing directory)', value: 'set-workspace' },
|
|
79
|
+
{ name: 'Create new directory and set as workspace', value: 'create-workspace' },
|
|
80
|
+
{ name: 'Session settings (debug, auto-save, auto-approve)', value: 'settings' },
|
|
81
|
+
{ name: 'Start session with current settings', value: 'start' },
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
if (action === 'set-workspace') {
|
|
86
|
+
const { workspacePath } = await inquirer.prompt([
|
|
87
|
+
{
|
|
88
|
+
type: 'input',
|
|
89
|
+
name: 'workspacePath',
|
|
90
|
+
message: 'Workspace directory path:',
|
|
91
|
+
default: session.workspacePath,
|
|
92
|
+
validate: validateExistingDirectory,
|
|
93
|
+
},
|
|
94
|
+
]);
|
|
95
|
+
session.workspacePath = path.resolve(workspacePath);
|
|
96
|
+
}
|
|
97
|
+
else if (action === 'create-workspace') {
|
|
98
|
+
const { basePath, folderName } = await inquirer.prompt([
|
|
99
|
+
{
|
|
100
|
+
type: 'input',
|
|
101
|
+
name: 'basePath',
|
|
102
|
+
message: 'Base directory:',
|
|
103
|
+
default: os.homedir(),
|
|
104
|
+
validate: validateExistingDirectory,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'input',
|
|
108
|
+
name: 'folderName',
|
|
109
|
+
message: 'New folder name:',
|
|
110
|
+
validate: (value) => {
|
|
111
|
+
const trimmed = String(value || '').trim();
|
|
112
|
+
if (!trimmed) {
|
|
113
|
+
return 'Folder name is required.';
|
|
114
|
+
}
|
|
115
|
+
if (/[<>:"|?*\x00]/.test(trimmed)) {
|
|
116
|
+
return 'Folder name contains invalid characters.';
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
]);
|
|
122
|
+
const target = path.join(path.resolve(basePath), String(folderName).trim());
|
|
123
|
+
fs.mkdirSync(target, { recursive: true });
|
|
124
|
+
session.workspacePath = target;
|
|
125
|
+
console.log(chalk.green(`Created workspace: ${target}`));
|
|
126
|
+
}
|
|
127
|
+
else if (action === 'settings') {
|
|
128
|
+
const settings = await inquirer.prompt([
|
|
129
|
+
{
|
|
130
|
+
type: 'confirm',
|
|
131
|
+
name: 'debugMode',
|
|
132
|
+
message: 'Enable debug mode (verbose logging)?',
|
|
133
|
+
default: session.debugMode,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
type: 'confirm',
|
|
137
|
+
name: 'autoSave',
|
|
138
|
+
message: 'Auto-save session on exit?',
|
|
139
|
+
default: session.autoSave,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
type: 'confirm',
|
|
143
|
+
name: 'autoApprove',
|
|
144
|
+
message: 'Auto-approve tool actions (dangerous)?',
|
|
145
|
+
default: session.autoApprove,
|
|
146
|
+
},
|
|
147
|
+
]);
|
|
148
|
+
Object.assign(session, settings);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
done = true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return session;
|
|
155
|
+
}
|