tuna-agent 0.1.2 → 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/cli/index.js CHANGED
@@ -1,14 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from 'commander';
3
+ import { readFileSync } from 'fs';
4
+ import { fileURLToPath } from 'url';
5
+ import { dirname, join } from 'path';
3
6
  import { connect } from './commands/connect.js';
4
7
  import { start } from './commands/start.js';
5
8
  import { stop } from './commands/stop.js';
6
9
  import { status } from './commands/status.js';
7
10
  import { extensionConnect, extensionList } from './commands/extension.js';
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = dirname(__filename);
13
+ const pkg = JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf-8'));
8
14
  const program = new Command()
9
15
  .name('tuna-agent')
10
16
  .description('Tuna Agent - Run AI coding tasks on your machine')
11
- .version('0.1.0');
17
+ .version(pkg.version);
12
18
  program
13
19
  .command('connect <code>')
14
20
  .description('Connect this machine to your Tuna account')
@@ -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(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuna-agent",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Tuna Agent - Run AI coding tasks on your machine",
5
5
  "bin": {
6
6
  "tuna-agent": "dist/cli/index.js"