tuna-agent 0.1.3 → 0.1.4
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/daemon/index.js
CHANGED
|
@@ -155,6 +155,43 @@ export async function startDaemon(config) {
|
|
|
155
155
|
ws.send({ action: 'agent_skills_scanned', agent_id: agentId, skills });
|
|
156
156
|
console.log(`[Daemon] Scanned ${skills.length} skill(s) for agent ${agentId}`);
|
|
157
157
|
}
|
|
158
|
+
else if (command === 'create_agent') {
|
|
159
|
+
const agentId = msg.agent_id;
|
|
160
|
+
const agentName = msg.agent_name || 'agent';
|
|
161
|
+
const rawFolder = msg.folder_path || '';
|
|
162
|
+
const roleDesc = msg.role_description || '';
|
|
163
|
+
if (!rawFolder) {
|
|
164
|
+
console.error('[Daemon] create_agent: missing folder_path');
|
|
165
|
+
ws.send({ action: 'agent_folder_created', agent_id: agentId, success: false, error: 'Missing folder_path' });
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
const folderPath = rawFolder.startsWith('~')
|
|
169
|
+
? path.join(os.homedir(), rawFolder.slice(1))
|
|
170
|
+
: rawFolder;
|
|
171
|
+
console.log(`[Daemon] Creating agent folder: ${folderPath} for "${agentName}"`);
|
|
172
|
+
try {
|
|
173
|
+
// Create folder structure
|
|
174
|
+
fs.mkdirSync(path.join(folderPath, '.claude', 'commands'), { recursive: true });
|
|
175
|
+
fs.mkdirSync(path.join(folderPath, 'knowledge'), { recursive: true });
|
|
176
|
+
// Write CLAUDE.md only if it doesn't exist
|
|
177
|
+
const claudeMdPath = path.join(folderPath, 'CLAUDE.md');
|
|
178
|
+
if (!fs.existsSync(claudeMdPath)) {
|
|
179
|
+
const claudeContent = `# ${agentName}\n\n${roleDesc || `You are ${agentName}, an AI agent.`}\n`;
|
|
180
|
+
fs.writeFileSync(claudeMdPath, claudeContent, 'utf-8');
|
|
181
|
+
console.log(`[Daemon] Created CLAUDE.md for "${agentName}"`);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
console.log(`[Daemon] CLAUDE.md already exists, skipping`);
|
|
185
|
+
}
|
|
186
|
+
ws.send({ action: 'agent_folder_created', agent_id: agentId, success: true });
|
|
187
|
+
console.log(`[Daemon] Agent folder created: ${folderPath}`);
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
191
|
+
console.error(`[Daemon] Failed to create agent folder: ${errMsg}`);
|
|
192
|
+
ws.send({ action: 'agent_folder_created', agent_id: agentId, success: false, error: errMsg });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
158
195
|
else if (command === 'analyze_skill') {
|
|
159
196
|
const skillId = msg.skill_id;
|
|
160
197
|
const sourcePath = msg.source_path;
|
|
@@ -32,6 +32,8 @@ export declare const CommandMessageSchema: z.ZodObject<{
|
|
|
32
32
|
agent_folders: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
33
|
agent_id: z.ZodOptional<z.ZodString>;
|
|
34
34
|
folder_path: z.ZodOptional<z.ZodString>;
|
|
35
|
+
agent_name: z.ZodOptional<z.ZodString>;
|
|
36
|
+
role_description: z.ZodOptional<z.ZodString>;
|
|
35
37
|
skill_id: z.ZodOptional<z.ZodString>;
|
|
36
38
|
source_path: z.ZodOptional<z.ZodString>;
|
|
37
39
|
skill_name: z.ZodOptional<z.ZodString>;
|
|
@@ -26,6 +26,9 @@ export const CommandMessageSchema = z.object({
|
|
|
26
26
|
// For rescan_agent_skills command
|
|
27
27
|
agent_id: z.string().optional(),
|
|
28
28
|
folder_path: z.string().optional(),
|
|
29
|
+
// For create_agent command
|
|
30
|
+
agent_name: z.string().optional(),
|
|
31
|
+
role_description: z.string().optional(),
|
|
29
32
|
// For analyze_skill command
|
|
30
33
|
skill_id: z.string().optional(),
|
|
31
34
|
source_path: z.string().optional(),
|