groove-dev 0.14.2 → 0.15.0

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.
@@ -406,6 +406,33 @@ export function createApi(app, daemon) {
406
406
  res.json({ id: req.params.id, content });
407
407
  });
408
408
 
409
+ // --- Agent Skills (attach/detach) ---
410
+
411
+ app.post('/api/agents/:agentId/skills/:skillId', (req, res) => {
412
+ const agent = daemon.registry.get(req.params.agentId);
413
+ if (!agent) return res.status(404).json({ error: 'Agent not found' });
414
+ const skillId = req.params.skillId;
415
+ if (!daemon.skills.getContent(skillId)) {
416
+ return res.status(400).json({ error: 'Skill not installed. Install it first.' });
417
+ }
418
+ const skills = agent.skills || [];
419
+ if (skills.includes(skillId)) {
420
+ return res.json({ id: agent.id, skills });
421
+ }
422
+ daemon.registry.update(agent.id, { skills: [...skills, skillId] });
423
+ daemon.audit.log('skill.attach', { agentId: agent.id, skillId });
424
+ res.json({ id: agent.id, skills: [...skills, skillId] });
425
+ });
426
+
427
+ app.delete('/api/agents/:agentId/skills/:skillId', (req, res) => {
428
+ const agent = daemon.registry.get(req.params.agentId);
429
+ if (!agent) return res.status(404).json({ error: 'Agent not found' });
430
+ const skills = (agent.skills || []).filter((s) => s !== req.params.skillId);
431
+ daemon.registry.update(agent.id, { skills });
432
+ daemon.audit.log('skill.detach', { agentId: agent.id, skillId: req.params.skillId });
433
+ res.json({ id: agent.id, skills });
434
+ });
435
+
409
436
  // --- Directory Browser ---
410
437
 
411
438
  app.get('/api/browse', (req, res) => {
@@ -162,6 +162,32 @@ export class Introducer {
162
162
  lines.push(archContent);
163
163
  }
164
164
 
165
+ // Skills injection — load attached skill content and inject into context
166
+ if (newAgent.skills && newAgent.skills.length > 0 && this.daemon.skills) {
167
+ const skillSections = [];
168
+ for (const skillId of newAgent.skills) {
169
+ const content = this.daemon.skills.getContent(skillId);
170
+ if (content) {
171
+ // Strip YAML frontmatter, keep the instruction body
172
+ const body = content.replace(/^---[\s\S]*?---\n*/, '').trim();
173
+ if (body) {
174
+ // Find the skill name from registry or frontmatter
175
+ const regEntry = this.daemon.skills.registry.find((s) => s.id === skillId);
176
+ const name = regEntry?.name || skillId;
177
+ skillSections.push(`### ${name}\n\n${body}`);
178
+ }
179
+ }
180
+ }
181
+ if (skillSections.length > 0) {
182
+ lines.push('');
183
+ lines.push(`## Skills (${skillSections.length} attached)`);
184
+ lines.push('');
185
+ lines.push(`The following skills have been attached to this agent. Follow their instructions:`);
186
+ lines.push('');
187
+ lines.push(skillSections.join('\n\n---\n\n'));
188
+ }
189
+ }
190
+
165
191
  return lines.join('\n');
166
192
  }
167
193
 
@@ -22,6 +22,7 @@ export class Registry extends EventEmitter {
22
22
  prompt: config.prompt || '',
23
23
  permission: config.permission || 'full',
24
24
  workingDir: config.workingDir || process.cwd(),
25
+ skills: config.skills || [],
25
26
  status: 'starting',
26
27
  pid: null,
27
28
  spawnedAt: new Date().toISOString(),
@@ -48,7 +49,7 @@ export class Registry extends EventEmitter {
48
49
  if (!agent) return null;
49
50
 
50
51
  // Only allow known fields to prevent prototype pollution
51
- const SAFE_FIELDS = ['status', 'pid', 'tokensUsed', 'contextUsage', 'lastActivity', 'model', 'name', 'routingMode', 'routingReason', 'sessionId'];
52
+ const SAFE_FIELDS = ['status', 'pid', 'tokensUsed', 'contextUsage', 'lastActivity', 'model', 'name', 'routingMode', 'routingReason', 'sessionId', 'skills'];
52
53
  for (const key of Object.keys(updates)) {
53
54
  if (SAFE_FIELDS.includes(key)) {
54
55
  agent[key] = updates[key];
@@ -57,6 +57,15 @@ export function validateAgentConfig(config) {
57
57
  const validPermissions = ['auto', 'full'];
58
58
  const permission = validPermissions.includes(config.permission) ? config.permission : 'full';
59
59
 
60
+ // Validate skills (array of skill IDs)
61
+ let skills = [];
62
+ if (config.skills !== undefined && config.skills !== null) {
63
+ if (!Array.isArray(config.skills)) {
64
+ throw new Error('Skills must be an array');
65
+ }
66
+ skills = config.skills.filter((s) => typeof s === 'string' && s.length > 0 && s.length <= 100);
67
+ }
68
+
60
69
  // Return sanitized config (only known fields)
61
70
  return {
62
71
  role: config.role,
@@ -67,6 +76,7 @@ export function validateAgentConfig(config) {
67
76
  model: typeof config.model === 'string' ? config.model : null,
68
77
  workingDir: typeof config.workingDir === 'string' ? config.workingDir : undefined,
69
78
  permission,
79
+ skills,
70
80
  };
71
81
  }
72
82