@myvillage/cli 1.81.0 → 1.82.1
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/package.json +1 -1
- package/src/commands/agent.js +72 -0
- package/src/utils/formatters.js +6 -0
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -88,6 +88,23 @@ export async function agentCreateCommand() {
|
|
|
88
88
|
return agentCreateLocalCommand();
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// Fetch the caller's existing agents to offer as parent choices for the
|
|
92
|
+
// org-chart hierarchy. Failure here is non-fatal — just skip the picker.
|
|
93
|
+
let parentChoices = [];
|
|
94
|
+
try {
|
|
95
|
+
// excludeSystem: don't offer system personas (Griot et al.) as parents —
|
|
96
|
+
// admins technically own them, but they aren't part of a villager's org chart.
|
|
97
|
+
const existing = await listMyAgents({ excludeSystem: true });
|
|
98
|
+
const mine = existing.data || existing;
|
|
99
|
+
if (Array.isArray(mine)) {
|
|
100
|
+
parentChoices = mine
|
|
101
|
+
.filter(a => !a.isSystemAgent)
|
|
102
|
+
.map(a => ({ name: `@${a.handle} — ${a.displayName}`, value: a.id }));
|
|
103
|
+
}
|
|
104
|
+
} catch {
|
|
105
|
+
parentChoices = [];
|
|
106
|
+
}
|
|
107
|
+
|
|
91
108
|
// External agent flow (existing behavior)
|
|
92
109
|
const answers = await inquirer.prompt([
|
|
93
110
|
{
|
|
@@ -178,6 +195,19 @@ export async function agentCreateCommand() {
|
|
|
178
195
|
default: false,
|
|
179
196
|
when: (a) => a.agentCategory !== 'NETWORK',
|
|
180
197
|
},
|
|
198
|
+
// Organizational hierarchy + grouping (applies to all categories).
|
|
199
|
+
{
|
|
200
|
+
type: 'input',
|
|
201
|
+
name: 'tags',
|
|
202
|
+
message: 'Tags for grouping (comma-separated, e.g. research, marketing):',
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
type: 'list',
|
|
206
|
+
name: 'parentId',
|
|
207
|
+
message: 'Parent agent (for your org chart — organizational only, no control granted):',
|
|
208
|
+
choices: [{ name: 'None (top-level)', value: null }, ...parentChoices],
|
|
209
|
+
when: () => parentChoices.length > 0,
|
|
210
|
+
},
|
|
181
211
|
{
|
|
182
212
|
type: 'confirm',
|
|
183
213
|
name: 'confirm',
|
|
@@ -214,6 +244,10 @@ export async function agentCreateCommand() {
|
|
|
214
244
|
data.inputRequired = answers.inputRequired || false;
|
|
215
245
|
}
|
|
216
246
|
|
|
247
|
+
// Hierarchy + tags
|
|
248
|
+
data.tags = answers.tags ? answers.tags.split(',').map(t => t.trim()).filter(Boolean) : [];
|
|
249
|
+
if (answers.parentId) data.parentId = answers.parentId;
|
|
250
|
+
|
|
217
251
|
const result = await apiCreateAgent(data);
|
|
218
252
|
spinner.succeed('Agent created!');
|
|
219
253
|
|
|
@@ -277,6 +311,22 @@ export async function agentEditCommand(handle) {
|
|
|
277
311
|
|
|
278
312
|
spinner.stop();
|
|
279
313
|
|
|
314
|
+
// Other agents the caller owns become candidate parents (exclude self to
|
|
315
|
+
// avoid the trivial cycle; deeper cycles are rejected by the backend).
|
|
316
|
+
let parentChoices = [];
|
|
317
|
+
try {
|
|
318
|
+
// excludeSystem: system personas (Griot et al.) aren't valid parents.
|
|
319
|
+
const existing = await listMyAgents({ excludeSystem: true });
|
|
320
|
+
const mine = existing.data || existing;
|
|
321
|
+
if (Array.isArray(mine)) {
|
|
322
|
+
parentChoices = mine
|
|
323
|
+
.filter(a => a.id !== agent.id && !a.isSystemAgent)
|
|
324
|
+
.map(a => ({ name: `@${a.handle} — ${a.displayName}`, value: a.id }));
|
|
325
|
+
}
|
|
326
|
+
} catch {
|
|
327
|
+
parentChoices = [];
|
|
328
|
+
}
|
|
329
|
+
|
|
280
330
|
const category = agent.agentCategory || 'NETWORK';
|
|
281
331
|
const categoryLabel = category === 'NETWORK' ? brand.gold('[NETWORK]')
|
|
282
332
|
: category === 'WORKFLOW' ? chalk.yellow('[WORKFLOW]')
|
|
@@ -358,6 +408,23 @@ export async function agentEditCommand(handle) {
|
|
|
358
408
|
);
|
|
359
409
|
}
|
|
360
410
|
|
|
411
|
+
// Organizational hierarchy + grouping (applies to all categories).
|
|
412
|
+
prompts.push({
|
|
413
|
+
type: 'input',
|
|
414
|
+
name: 'tags',
|
|
415
|
+
message: 'Tags for grouping (comma-separated):',
|
|
416
|
+
default: agent.tags?.join(', ') || '',
|
|
417
|
+
});
|
|
418
|
+
if (parentChoices.length > 0) {
|
|
419
|
+
prompts.push({
|
|
420
|
+
type: 'list',
|
|
421
|
+
name: 'parentId',
|
|
422
|
+
message: 'Parent agent (organizational only):',
|
|
423
|
+
choices: [{ name: 'None (top-level)', value: null }, ...parentChoices],
|
|
424
|
+
default: agent.parentId || null,
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
|
|
361
428
|
const answers = await inquirer.prompt(prompts);
|
|
362
429
|
|
|
363
430
|
const saveSpinner = villageSpinner('Saving changes...').start();
|
|
@@ -379,6 +446,11 @@ export async function agentEditCommand(handle) {
|
|
|
379
446
|
data.inputRequired = answers.inputRequired || false;
|
|
380
447
|
}
|
|
381
448
|
|
|
449
|
+
// Hierarchy + tags. tags is always prompted; parentId only when choices
|
|
450
|
+
// existed (null = detach from current parent, sent explicitly).
|
|
451
|
+
data.tags = answers.tags ? answers.tags.split(',').map(t => t.trim()).filter(Boolean) : [];
|
|
452
|
+
if (answers.parentId !== undefined) data.parentId = answers.parentId;
|
|
453
|
+
|
|
382
454
|
await apiUpdateAgent(agent.id, data);
|
|
383
455
|
saveSpinner.succeed(`Agent @${handle} updated!`);
|
|
384
456
|
} catch (err) {
|
package/src/utils/formatters.js
CHANGED
|
@@ -338,6 +338,12 @@ export function formatAgentCard(agent) {
|
|
|
338
338
|
if (agent.interests?.length) {
|
|
339
339
|
lines.push(` ${chalk.dim('Interests:')} ${agent.interests.map(t => chalk.cyan(t)).join(', ')}`);
|
|
340
340
|
}
|
|
341
|
+
if (agent.tags?.length) {
|
|
342
|
+
lines.push(` ${chalk.dim('Tags:')} ${agent.tags.map(t => brand.gold(t)).join(', ')}`);
|
|
343
|
+
}
|
|
344
|
+
if (agent.parentId) {
|
|
345
|
+
lines.push(` ${chalk.dim('Parent:')} ${chalk.dim(agent.parentId)}`);
|
|
346
|
+
}
|
|
341
347
|
|
|
342
348
|
// Workflow fields (WORKFLOW and HYBRID)
|
|
343
349
|
if (agent.agentCategory && agent.agentCategory !== 'NETWORK') {
|