@arcteninc/core 0.0.176 → 0.0.177
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 +73 -78
- package/dist/index.cjs +3 -16
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +851 -8410
- package/dist/lib/useAgent.d.ts +1 -2
- package/dist/lib/useAgent.d.ts.map +1 -1
- package/dist/types/use-agent.d.ts +3 -44
- package/dist/types/use-agent.d.ts.map +1 -1
- package/dist/utils/extract-tool-metadata.d.ts.map +1 -1
- package/package.json +7 -46
- package/scripts/arcten-cli.cjs +14 -108
- package/scripts/cli-extract-types-auto.ts +22 -4
- package/scripts/update-core.cjs +124 -0
- package/dist/components/ArctenAgent.d.ts +0 -52
- package/dist/components/ArctenAgent.d.ts.map +0 -1
- package/dist/components/ai-elements/prompt-input.d.ts +0 -187
- package/dist/components/ai-elements/prompt-input.d.ts.map +0 -1
- package/dist/components/ai-elements/reasoning.d.ts +0 -17
- package/dist/components/ai-elements/reasoning.d.ts.map +0 -1
- package/dist/components/ai-elements/response.d.ts +0 -8
- package/dist/components/ai-elements/response.d.ts.map +0 -1
- package/dist/components/ai-elements/shimmer.d.ts +0 -10
- package/dist/components/ai-elements/shimmer.d.ts.map +0 -1
- package/dist/components/citation-button.d.ts +0 -14
- package/dist/components/citation-button.d.ts.map +0 -1
- package/dist/components/citation-text-renderer.d.ts +0 -31
- package/dist/components/citation-text-renderer.d.ts.map +0 -1
- package/dist/components/secure-modals/EmailModal.d.ts +0 -10
- package/dist/components/secure-modals/EmailModal.d.ts.map +0 -1
- package/dist/components/secure-modals/FormModal.d.ts +0 -20
- package/dist/components/secure-modals/FormModal.d.ts.map +0 -1
- package/dist/components/secure-modals/PasswordModal.d.ts +0 -10
- package/dist/components/secure-modals/PasswordModal.d.ts.map +0 -1
- package/dist/components/secure-modals/PhoneModal.d.ts +0 -10
- package/dist/components/secure-modals/PhoneModal.d.ts.map +0 -1
- package/dist/components/secure-modals/PinModal.d.ts +0 -11
- package/dist/components/secure-modals/PinModal.d.ts.map +0 -1
- package/dist/components/secure-modals/SecureModalProvider.d.ts +0 -13
- package/dist/components/secure-modals/SecureModalProvider.d.ts.map +0 -1
- package/dist/components/secure-modals/TextModal.d.ts +0 -11
- package/dist/components/secure-modals/TextModal.d.ts.map +0 -1
- package/dist/components/secure-modals/index.d.ts +0 -10
- package/dist/components/secure-modals/index.d.ts.map +0 -1
- package/dist/components/secure-modals/types.d.ts +0 -34
- package/dist/components/secure-modals/types.d.ts.map +0 -1
- package/dist/components/tool-call-approval.d.ts +0 -9
- package/dist/components/tool-call-approval.d.ts.map +0 -1
- package/dist/components/tool-call-result.d.ts +0 -8
- package/dist/components/tool-call-result.d.ts.map +0 -1
- package/dist/components/ui/autotextarea.d.ts +0 -19
- package/dist/components/ui/autotextarea.d.ts.map +0 -1
- package/dist/components/ui/badge.d.ts +0 -10
- package/dist/components/ui/badge.d.ts.map +0 -1
- package/dist/components/ui/button.d.ts +0 -14
- package/dist/components/ui/button.d.ts.map +0 -1
- package/dist/components/ui/collapsible.d.ts +0 -6
- package/dist/components/ui/collapsible.d.ts.map +0 -1
- package/dist/components/ui/command.d.ts +0 -19
- package/dist/components/ui/command.d.ts.map +0 -1
- package/dist/components/ui/dialog.d.ts +0 -16
- package/dist/components/ui/dialog.d.ts.map +0 -1
- package/dist/components/ui/dropdown-menu.d.ts +0 -26
- package/dist/components/ui/dropdown-menu.d.ts.map +0 -1
- package/dist/components/ui/hover-card.d.ts +0 -7
- package/dist/components/ui/hover-card.d.ts.map +0 -1
- package/dist/components/ui/input-group.d.ts +0 -17
- package/dist/components/ui/input-group.d.ts.map +0 -1
- package/dist/components/ui/input.d.ts +0 -4
- package/dist/components/ui/input.d.ts.map +0 -1
- package/dist/components/ui/kbd.d.ts +0 -4
- package/dist/components/ui/kbd.d.ts.map +0 -1
- package/dist/components/ui/select.d.ts +0 -16
- package/dist/components/ui/select.d.ts.map +0 -1
- package/dist/components/ui/textarea.d.ts +0 -4
- package/dist/components/ui/textarea.d.ts.map +0 -1
- package/dist/components/ui/tooltip.d.ts +0 -8
- package/dist/components/ui/tooltip.d.ts.map +0 -1
- package/dist/core.css +0 -1
- package/dist/utils/form-generator.d.ts +0 -29
- package/dist/utils/form-generator.d.ts.map +0 -1
- package/dist/utils/secure-param-detector.d.ts +0 -26
- package/dist/utils/secure-param-detector.d.ts.map +0 -1
- package/scripts/cli-agent-inject.ts +0 -205
- package/scripts/cli-agent-wrapper.cjs +0 -51
- package/scripts/cli-agent.ts +0 -483
- package/scripts/cli-create-project.ts +0 -608
- package/scripts/cli-create-wrapper.cjs +0 -60
- package/scripts/cli-init-wizard-wrapper.cjs +0 -58
- package/scripts/cli-init-wizard.ts +0 -646
- package/scripts/cli-prompt-wrapper.cjs +0 -51
- package/scripts/cli-prompt.ts +0 -306
- package/scripts/cli-sync-wrapper.cjs +0 -69
- package/scripts/cli-sync.ts +0 -915
- package/scripts/cli-tools-wrapper.cjs +0 -51
- package/scripts/cli-tools.ts +0 -320
- package/scripts/cli-uninstall-wrapper.cjs +0 -66
- package/scripts/cli-uninstall.ts +0 -173
- package/scripts/config-parser.ts +0 -432
- package/scripts/dashboard-sync.ts +0 -454
- package/scripts/tree-sitter-discover.ts +0 -526
- package/scripts/wasm/tree-sitter-tsx.wasm +0 -0
- package/scripts/wasm/tree-sitter-typescript.wasm +0 -0
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Wrapper script for cli-agent.ts
|
|
4
|
-
* Handles TypeScript execution via tsx or ts-node
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const { spawn } = require('child_process');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
|
|
11
|
-
const scriptPath = path.join(__dirname, 'cli-agent.ts');
|
|
12
|
-
|
|
13
|
-
// Check if script exists
|
|
14
|
-
if (!fs.existsSync(scriptPath)) {
|
|
15
|
-
console.error(` Script not found: ${scriptPath}`);
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Try tsx first (faster), then ts-node, then bun
|
|
20
|
-
const runners = [
|
|
21
|
-
{ cmd: 'tsx', args: [scriptPath, ...process.argv.slice(2)] },
|
|
22
|
-
{ cmd: 'npx', args: ['tsx', scriptPath, ...process.argv.slice(2)] },
|
|
23
|
-
{ cmd: 'bun', args: ['run', scriptPath, ...process.argv.slice(2)] },
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
function tryRunner(index) {
|
|
27
|
-
if (index >= runners.length) {
|
|
28
|
-
console.error(' Could not find a TypeScript runner (tsx, ts-node, or bun)');
|
|
29
|
-
console.error(' Install tsx: npm install -g tsx');
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const { cmd, args } = runners[index];
|
|
34
|
-
|
|
35
|
-
const child = spawn(cmd, args, {
|
|
36
|
-
stdio: 'inherit',
|
|
37
|
-
cwd: process.cwd(),
|
|
38
|
-
shell: process.platform === 'win32',
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
child.on('error', () => {
|
|
42
|
-
// Try next runner
|
|
43
|
-
tryRunner(index + 1);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
child.on('exit', (code) => {
|
|
47
|
-
process.exit(code || 0);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
tryRunner(0);
|
package/scripts/cli-agent.ts
DELETED
|
@@ -1,483 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
/**
|
|
3
|
-
* arcten agent - Agent configuration management
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
* arcten agent create <name> Create a new agent configuration
|
|
7
|
-
* arcten agent list List all agents
|
|
8
|
-
* arcten agent edit <name> Edit an agent configuration
|
|
9
|
-
* arcten agent delete <name> Delete an agent
|
|
10
|
-
* arcten agent set-default <name> Set agent as default
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import * as fs from "fs";
|
|
14
|
-
import * as path from "path";
|
|
15
|
-
import * as readline from "readline";
|
|
16
|
-
import { execSync, spawn } from "child_process";
|
|
17
|
-
|
|
18
|
-
const AGENT_TEMPLATE = (name: string, description: string = "") => `name: ${name}
|
|
19
|
-
description: ${description}
|
|
20
|
-
isDefault: false
|
|
21
|
-
toolMode: inherit
|
|
22
|
-
|
|
23
|
-
# System prompt for this agent
|
|
24
|
-
# This overrides the project-level prompt when this agent is active
|
|
25
|
-
systemPrompt: |
|
|
26
|
-
You are a helpful AI assistant named ${name}.
|
|
27
|
-
|
|
28
|
-
## Your Role
|
|
29
|
-
- Help users with their requests
|
|
30
|
-
- Use available tools appropriately
|
|
31
|
-
|
|
32
|
-
## Guidelines
|
|
33
|
-
- Be concise and professional
|
|
34
|
-
|
|
35
|
-
# Tools this agent can access (only used if toolMode is 'custom' or 'additive')
|
|
36
|
-
# enabledTools:
|
|
37
|
-
# - getOrders
|
|
38
|
-
# - getOrderDetails
|
|
39
|
-
`;
|
|
40
|
-
|
|
41
|
-
interface AgentConfig {
|
|
42
|
-
name: string;
|
|
43
|
-
description?: string;
|
|
44
|
-
isDefault?: boolean;
|
|
45
|
-
toolMode?: "inherit" | "custom" | "additive";
|
|
46
|
-
systemPrompt?: string;
|
|
47
|
-
enabledTools?: string[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function findProjectRoot(): string {
|
|
51
|
-
let dir = process.cwd();
|
|
52
|
-
while (dir !== path.dirname(dir)) {
|
|
53
|
-
if (fs.existsSync(path.join(dir, "package.json"))) {
|
|
54
|
-
return dir;
|
|
55
|
-
}
|
|
56
|
-
dir = path.dirname(dir);
|
|
57
|
-
}
|
|
58
|
-
return process.cwd();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function getAgentsDir(projectRoot: string): string {
|
|
62
|
-
return path.join(projectRoot, ".arcten", "agents");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function ensureAgentsDir(projectRoot: string): void {
|
|
66
|
-
const agentsDir = getAgentsDir(projectRoot);
|
|
67
|
-
if (!fs.existsSync(agentsDir)) {
|
|
68
|
-
fs.mkdirSync(agentsDir, { recursive: true });
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function listAgents(projectRoot: string): string[] {
|
|
73
|
-
const agentsDir = getAgentsDir(projectRoot);
|
|
74
|
-
if (!fs.existsSync(agentsDir)) {
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
return fs
|
|
78
|
-
.readdirSync(agentsDir)
|
|
79
|
-
.filter((f) => f.endsWith(".yaml") || f.endsWith(".yml"))
|
|
80
|
-
.map((f) => f.replace(/\.ya?ml$/, ""));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function parseYamlSimple(content: string): AgentConfig {
|
|
84
|
-
const config: AgentConfig = { name: "" };
|
|
85
|
-
const lines = content.split("\n");
|
|
86
|
-
|
|
87
|
-
let inSystemPrompt = false;
|
|
88
|
-
let inEnabledTools = false;
|
|
89
|
-
let systemPromptLines: string[] = [];
|
|
90
|
-
let enabledTools: string[] = [];
|
|
91
|
-
|
|
92
|
-
for (const line of lines) {
|
|
93
|
-
// Check for multi-line string continuation
|
|
94
|
-
if (inSystemPrompt) {
|
|
95
|
-
if (line.match(/^[a-zA-Z]/) || line.match(/^#/)) {
|
|
96
|
-
inSystemPrompt = false;
|
|
97
|
-
config.systemPrompt = systemPromptLines.join("\n").trim();
|
|
98
|
-
} else {
|
|
99
|
-
// Remove the leading 2-space indent
|
|
100
|
-
systemPromptLines.push(line.replace(/^ /, ""));
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (inEnabledTools) {
|
|
106
|
-
if (line.match(/^\s*-\s+/)) {
|
|
107
|
-
const tool = line.replace(/^\s*-\s+/, "").trim();
|
|
108
|
-
if (tool && !tool.startsWith("#")) {
|
|
109
|
-
enabledTools.push(tool);
|
|
110
|
-
}
|
|
111
|
-
continue;
|
|
112
|
-
} else if (!line.match(/^\s*#/) && line.trim()) {
|
|
113
|
-
inEnabledTools = false;
|
|
114
|
-
config.enabledTools = enabledTools;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Skip comments
|
|
119
|
-
if (line.trim().startsWith("#")) continue;
|
|
120
|
-
|
|
121
|
-
// Parse key-value pairs
|
|
122
|
-
const match = line.match(/^(\w+):\s*(.*)$/);
|
|
123
|
-
if (match) {
|
|
124
|
-
const [, key, value] = match;
|
|
125
|
-
|
|
126
|
-
if (key === "systemPrompt" && value.includes("|")) {
|
|
127
|
-
inSystemPrompt = true;
|
|
128
|
-
systemPromptLines = [];
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (key === "enabledTools" && !value.trim()) {
|
|
133
|
-
inEnabledTools = true;
|
|
134
|
-
enabledTools = [];
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
switch (key) {
|
|
139
|
-
case "name":
|
|
140
|
-
config.name = value.trim();
|
|
141
|
-
break;
|
|
142
|
-
case "description":
|
|
143
|
-
config.description = value.trim();
|
|
144
|
-
break;
|
|
145
|
-
case "isDefault":
|
|
146
|
-
config.isDefault = value.trim().toLowerCase() === "true";
|
|
147
|
-
break;
|
|
148
|
-
case "toolMode":
|
|
149
|
-
config.toolMode = value.trim() as "inherit" | "custom" | "additive";
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Handle trailing multiline content
|
|
156
|
-
if (inSystemPrompt) {
|
|
157
|
-
config.systemPrompt = systemPromptLines.join("\n").trim();
|
|
158
|
-
}
|
|
159
|
-
if (inEnabledTools && enabledTools.length > 0) {
|
|
160
|
-
config.enabledTools = enabledTools;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return config;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function readAgentConfig(projectRoot: string, name: string): AgentConfig | null {
|
|
167
|
-
const agentsDir = getAgentsDir(projectRoot);
|
|
168
|
-
const yamlPath = path.join(agentsDir, `${name}.yaml`);
|
|
169
|
-
const ymlPath = path.join(agentsDir, `${name}.yml`);
|
|
170
|
-
|
|
171
|
-
const filePath = fs.existsSync(yamlPath) ? yamlPath : fs.existsSync(ymlPath) ? ymlPath : null;
|
|
172
|
-
|
|
173
|
-
if (!filePath) {
|
|
174
|
-
return null;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
try {
|
|
178
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
179
|
-
return parseYamlSimple(content);
|
|
180
|
-
} catch {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function createAgent(projectRoot: string, name: string, description?: string): void {
|
|
186
|
-
ensureAgentsDir(projectRoot);
|
|
187
|
-
|
|
188
|
-
const agentPath = path.join(getAgentsDir(projectRoot), `${name}.yaml`);
|
|
189
|
-
|
|
190
|
-
if (fs.existsSync(agentPath)) {
|
|
191
|
-
console.error(`\n Agent "${name}" already exists.`);
|
|
192
|
-
console.error(` Run 'arcten agent edit ${name}' to modify it.`);
|
|
193
|
-
process.exit(1);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Validate name
|
|
197
|
-
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
198
|
-
console.error(`\n Invalid agent name: ${name}`);
|
|
199
|
-
console.error(` Names must start with a letter and contain only lowercase letters, numbers, and hyphens.`);
|
|
200
|
-
process.exit(1);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
fs.writeFileSync(agentPath, AGENT_TEMPLATE(name, description || ""));
|
|
204
|
-
console.log(`\n Created agent: .arcten/agents/${name}.yaml`);
|
|
205
|
-
console.log(`\n Next steps:`);
|
|
206
|
-
console.log(` 1. Edit the agent config: arcten agent edit ${name}`);
|
|
207
|
-
console.log(` 2. Sync to dashboard: arcten sync --agents`);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function showAgentList(projectRoot: string): void {
|
|
211
|
-
const agents = listAgents(projectRoot);
|
|
212
|
-
|
|
213
|
-
if (agents.length === 0) {
|
|
214
|
-
console.log(`\n No agents found.`);
|
|
215
|
-
console.log(` Create one with: arcten agent create <name>`);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
console.log(`\n Agents (.arcten/agents/):\n`);
|
|
220
|
-
|
|
221
|
-
for (const name of agents) {
|
|
222
|
-
const config = readAgentConfig(projectRoot, name);
|
|
223
|
-
const isDefault = config?.isDefault ? " (default)" : "";
|
|
224
|
-
const toolMode = config?.toolMode || "inherit";
|
|
225
|
-
const description = config?.description || "";
|
|
226
|
-
|
|
227
|
-
console.log(` ${config?.isDefault ? "" : " "} ${name}${isDefault}`);
|
|
228
|
-
if (description) {
|
|
229
|
-
console.log(` ${description}`);
|
|
230
|
-
}
|
|
231
|
-
console.log(` toolMode: ${toolMode}`);
|
|
232
|
-
if (config?.enabledTools?.length) {
|
|
233
|
-
console.log(` tools: ${config.enabledTools.join(", ")}`);
|
|
234
|
-
}
|
|
235
|
-
console.log();
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
console.log(` Total: ${agents.length} agent(s)`);
|
|
239
|
-
console.log(`\n Commands:`);
|
|
240
|
-
console.log(` arcten agent create <name> Create new agent`);
|
|
241
|
-
console.log(` arcten agent edit <name> Edit agent config`);
|
|
242
|
-
console.log(` arcten agent delete <name> Delete agent`);
|
|
243
|
-
console.log(` arcten sync --agents Sync to dashboard`);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function openInEditor(filePath: string): void {
|
|
247
|
-
const editors = [
|
|
248
|
-
process.env.EDITOR,
|
|
249
|
-
process.env.VISUAL,
|
|
250
|
-
"code",
|
|
251
|
-
"cursor",
|
|
252
|
-
"vim",
|
|
253
|
-
"nano",
|
|
254
|
-
"notepad",
|
|
255
|
-
].filter(Boolean);
|
|
256
|
-
|
|
257
|
-
for (const editor of editors) {
|
|
258
|
-
try {
|
|
259
|
-
if (process.platform === "win32") {
|
|
260
|
-
const child = spawn(editor!, ["--wait", filePath], {
|
|
261
|
-
stdio: "inherit",
|
|
262
|
-
shell: true,
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
child.on("error", () => {});
|
|
266
|
-
|
|
267
|
-
child.on("exit", (code) => {
|
|
268
|
-
if (code === 0) {
|
|
269
|
-
console.log(`\n Agent config saved.`);
|
|
270
|
-
console.log(` Run 'arcten sync --agents' to sync to dashboard.`);
|
|
271
|
-
}
|
|
272
|
-
process.exit(code || 0);
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
return;
|
|
276
|
-
} else {
|
|
277
|
-
try {
|
|
278
|
-
execSync(`which ${editor}`, { stdio: "ignore" });
|
|
279
|
-
} catch {
|
|
280
|
-
continue;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const child = spawn(editor!, [filePath], {
|
|
284
|
-
stdio: "inherit",
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
child.on("exit", (code) => {
|
|
288
|
-
if (code === 0) {
|
|
289
|
-
console.log(`\n Agent config saved.`);
|
|
290
|
-
console.log(` Run 'arcten sync --agents' to sync to dashboard.`);
|
|
291
|
-
}
|
|
292
|
-
process.exit(code || 0);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
} catch {
|
|
298
|
-
continue;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
console.error(" Could not find an editor. Set $EDITOR environment variable.");
|
|
303
|
-
console.log(` File location: ${filePath}`);
|
|
304
|
-
process.exit(1);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function editAgent(projectRoot: string, name: string): void {
|
|
308
|
-
const agentsDir = getAgentsDir(projectRoot);
|
|
309
|
-
const yamlPath = path.join(agentsDir, `${name}.yaml`);
|
|
310
|
-
const ymlPath = path.join(agentsDir, `${name}.yml`);
|
|
311
|
-
|
|
312
|
-
const filePath = fs.existsSync(yamlPath) ? yamlPath : fs.existsSync(ymlPath) ? ymlPath : null;
|
|
313
|
-
|
|
314
|
-
if (!filePath) {
|
|
315
|
-
console.error(`\n Agent "${name}" not found.`);
|
|
316
|
-
console.error(` Create it with: arcten agent create ${name}`);
|
|
317
|
-
process.exit(1);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
console.log(`\n Opening ${name} in editor...`);
|
|
321
|
-
console.log(` File: ${path.relative(process.cwd(), filePath)}`);
|
|
322
|
-
|
|
323
|
-
openInEditor(filePath);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
async function deleteAgent(projectRoot: string, name: string): Promise<void> {
|
|
327
|
-
const agentsDir = getAgentsDir(projectRoot);
|
|
328
|
-
const yamlPath = path.join(agentsDir, `${name}.yaml`);
|
|
329
|
-
const ymlPath = path.join(agentsDir, `${name}.yml`);
|
|
330
|
-
|
|
331
|
-
const filePath = fs.existsSync(yamlPath) ? yamlPath : fs.existsSync(ymlPath) ? ymlPath : null;
|
|
332
|
-
|
|
333
|
-
if (!filePath) {
|
|
334
|
-
console.error(`\n Agent "${name}" not found.`);
|
|
335
|
-
process.exit(1);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const rl = readline.createInterface({
|
|
339
|
-
input: process.stdin,
|
|
340
|
-
output: process.stdout,
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
const answer = await new Promise<string>((resolve) => {
|
|
344
|
-
rl.question(`\n Delete agent "${name}"? This cannot be undone. (y/n): `, resolve);
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
rl.close();
|
|
348
|
-
|
|
349
|
-
if (answer.toLowerCase() !== "y") {
|
|
350
|
-
console.log(" Cancelled.");
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
fs.unlinkSync(filePath);
|
|
355
|
-
console.log(`\n Deleted: ${path.relative(process.cwd(), filePath)}`);
|
|
356
|
-
console.log(` Run 'arcten sync --agents' to update dashboard.`);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
function setDefaultAgent(projectRoot: string, name: string): void {
|
|
360
|
-
const agents = listAgents(projectRoot);
|
|
361
|
-
|
|
362
|
-
if (!agents.includes(name)) {
|
|
363
|
-
console.error(`\n Agent "${name}" not found.`);
|
|
364
|
-
console.error(` Available agents: ${agents.join(", ") || "(none)"}`);
|
|
365
|
-
process.exit(1);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
const agentsDir = getAgentsDir(projectRoot);
|
|
369
|
-
|
|
370
|
-
// Update all agents - remove isDefault from others, set on target
|
|
371
|
-
for (const agentName of agents) {
|
|
372
|
-
const yamlPath = path.join(agentsDir, `${agentName}.yaml`);
|
|
373
|
-
const ymlPath = path.join(agentsDir, `${agentName}.yml`);
|
|
374
|
-
const filePath = fs.existsSync(yamlPath) ? yamlPath : ymlPath;
|
|
375
|
-
|
|
376
|
-
if (!fs.existsSync(filePath)) continue;
|
|
377
|
-
|
|
378
|
-
let content = fs.readFileSync(filePath, "utf-8");
|
|
379
|
-
|
|
380
|
-
if (agentName === name) {
|
|
381
|
-
// Set as default
|
|
382
|
-
content = content.replace(/isDefault:\s*(true|false)/, "isDefault: true");
|
|
383
|
-
} else {
|
|
384
|
-
// Remove default
|
|
385
|
-
content = content.replace(/isDefault:\s*true/, "isDefault: false");
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
fs.writeFileSync(filePath, content);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
console.log(`\n Set "${name}" as the default agent.`);
|
|
392
|
-
console.log(` Run 'arcten sync --agents' to update dashboard.`);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
async function main(): Promise<void> {
|
|
396
|
-
const args = process.argv.slice(2);
|
|
397
|
-
|
|
398
|
-
if (args.length === 0) {
|
|
399
|
-
console.log(`
|
|
400
|
-
arcten agent - Manage agent configurations
|
|
401
|
-
|
|
402
|
-
Usage:
|
|
403
|
-
arcten agent create <name> Create a new agent
|
|
404
|
-
arcten agent list List all agents
|
|
405
|
-
arcten agent edit <name> Edit an agent
|
|
406
|
-
arcten agent delete <name> Delete an agent
|
|
407
|
-
arcten agent set-default <name> Set as default agent
|
|
408
|
-
|
|
409
|
-
Examples:
|
|
410
|
-
arcten agent create support
|
|
411
|
-
arcten agent edit support
|
|
412
|
-
arcten agent set-default support
|
|
413
|
-
`);
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
const subCommand = args[0];
|
|
418
|
-
const projectRoot = findProjectRoot();
|
|
419
|
-
|
|
420
|
-
switch (subCommand) {
|
|
421
|
-
case "create":
|
|
422
|
-
case "new":
|
|
423
|
-
case "add": {
|
|
424
|
-
const name = args[1];
|
|
425
|
-
if (!name) {
|
|
426
|
-
console.error(" Usage: arcten agent create <name>");
|
|
427
|
-
process.exit(1);
|
|
428
|
-
}
|
|
429
|
-
createAgent(projectRoot, name, args[2]);
|
|
430
|
-
break;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
case "list":
|
|
434
|
-
case "ls": {
|
|
435
|
-
showAgentList(projectRoot);
|
|
436
|
-
break;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
case "edit":
|
|
440
|
-
case "modify": {
|
|
441
|
-
const name = args[1];
|
|
442
|
-
if (!name) {
|
|
443
|
-
console.error(" Usage: arcten agent edit <name>");
|
|
444
|
-
process.exit(1);
|
|
445
|
-
}
|
|
446
|
-
editAgent(projectRoot, name);
|
|
447
|
-
break;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
case "delete":
|
|
451
|
-
case "remove":
|
|
452
|
-
case "rm": {
|
|
453
|
-
const name = args[1];
|
|
454
|
-
if (!name) {
|
|
455
|
-
console.error(" Usage: arcten agent delete <name>");
|
|
456
|
-
process.exit(1);
|
|
457
|
-
}
|
|
458
|
-
await deleteAgent(projectRoot, name);
|
|
459
|
-
break;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
case "set-default":
|
|
463
|
-
case "default": {
|
|
464
|
-
const name = args[1];
|
|
465
|
-
if (!name) {
|
|
466
|
-
console.error(" Usage: arcten agent set-default <name>");
|
|
467
|
-
process.exit(1);
|
|
468
|
-
}
|
|
469
|
-
setDefaultAgent(projectRoot, name);
|
|
470
|
-
break;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
default:
|
|
474
|
-
console.error(` Unknown subcommand: ${subCommand}`);
|
|
475
|
-
console.error(` Run 'arcten agent' for help.`);
|
|
476
|
-
process.exit(1);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
main().catch((error) => {
|
|
481
|
-
console.error(" Error:", error.message);
|
|
482
|
-
process.exit(1);
|
|
483
|
-
});
|