@pellux/goodvibes-agent 0.1.114 → 0.1.116

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.
@@ -1,5 +1,7 @@
1
1
  import {
2
2
  createAgentRuntimeProfile,
3
+ createAgentRuntimeProfileFromDiscovered,
4
+ createAgentRuntimeProfileTemplateFromDiscovered,
3
5
  deleteAgentRuntimeProfile,
4
6
  exportAgentRuntimeProfileTemplate,
5
7
  importAgentRuntimeProfileTemplate,
@@ -16,6 +18,7 @@ import type { CliCommandOutput, GoodVibesCliParseResult } from './types.ts';
16
18
  interface ProfilesCommandRuntime {
17
19
  readonly cli: GoodVibesCliParseResult;
18
20
  readonly homeDirectory: string;
21
+ readonly workingDirectory: string;
19
22
  }
20
23
 
21
24
  function hasYes(args: readonly string[]): boolean {
@@ -53,6 +56,12 @@ function parseTemplate(args: readonly string[]): AgentRuntimeProfileTemplateId |
53
56
  throw new Error(`Unknown Agent starter profile template: ${raw}. Use profiles templates to list starters.`);
54
57
  }
55
58
 
59
+ function parseCsvFlag(args: readonly string[], names: readonly string[]): readonly string[] | undefined {
60
+ const raw = flagValue(args, names);
61
+ if (!raw) return undefined;
62
+ return raw.split(',').map((entry) => entry.trim()).filter(Boolean);
63
+ }
64
+
56
65
  function profileLine(profile: AgentRuntimeProfileInfo): string {
57
66
  const created = profile.createdAt ? ` created=${profile.createdAt}` : '';
58
67
  const starter = profile.starterTemplateId ? ` starter=${profile.starterTemplateId}` : '';
@@ -99,6 +108,27 @@ function renderProfilesResult(result: AgentRuntimeProfileCommandResult): string
99
108
  ` use: goodvibes-agent profiles create <name> --template ${result.data.template.id} --yes`,
100
109
  ].join('\n');
101
110
  }
111
+ if (result.kind === 'agent.profiles.template.from_discovered' && result.data?.template) {
112
+ return [
113
+ `Agent starter template created from discovered behavior: ${result.data.template.id}`,
114
+ ` name: ${result.data.template.name}`,
115
+ ` persona: ${result.data.template.personaName}`,
116
+ ` skills: ${result.data.template.skillNames.join(', ')}`,
117
+ ` routines: ${result.data.template.routineNames.join(', ')}`,
118
+ ` use: goodvibes-agent profiles create <name> --template ${result.data.template.id} --yes`,
119
+ ].join('\n');
120
+ }
121
+ if (result.kind === 'agent.profiles.create_from_discovered' && result.data?.profile && result.data.template) {
122
+ return [
123
+ `Agent profile created from discovered behavior: ${result.data.profile.id}`,
124
+ ` home: ${result.data.profile.homeDirectory}`,
125
+ ` starter: ${result.data.template.id}`,
126
+ ` persona: ${result.data.template.personaName}`,
127
+ ` skills: ${result.data.template.skillNames.join(', ')}`,
128
+ ` routines: ${result.data.template.routineNames.join(', ')}`,
129
+ ` launch: ${result.data.nextCommand ?? `goodvibes-agent --agent-profile ${result.data.profile.id}`}`,
130
+ ].join('\n');
131
+ }
102
132
  const profile = result.data?.profile;
103
133
  if (result.kind === 'agent.profiles.create' && profile) {
104
134
  const template = result.data?.appliedTemplate;
@@ -142,6 +172,51 @@ export async function handleProfilesCommand(runtime: ProfilesCommandRuntime): Pr
142
172
 
143
173
  if (sub === 'templates' || sub === 'starters') {
144
174
  const [templateAction, templateId, templatePath] = values;
175
+ if (templateAction === 'from-discovered' || templateAction === 'import-discovered') {
176
+ if (!templateId) {
177
+ const result: AgentRuntimeProfileCommandResult = {
178
+ ok: false,
179
+ kind: 'agent.profiles.error',
180
+ error: 'Usage: goodvibes-agent profiles templates from-discovered <id> [--name <name>] [--description <summary>] [--persona <name>] [--skills all|name,name] [--routines all|name,name] [--replace] --yes',
181
+ };
182
+ return {
183
+ output: renderProfilesOutput(result, runtime.cli.flags.outputFormat),
184
+ exitCode: 2,
185
+ };
186
+ }
187
+ if (!hasYes(rawRest)) {
188
+ const result: AgentRuntimeProfileCommandResult = {
189
+ ok: false,
190
+ kind: 'agent.profiles.error',
191
+ error: `Refusing to create Agent starter template ${templateId} from discovered behavior without --yes.`,
192
+ };
193
+ return {
194
+ output: renderProfilesOutput(result, runtime.cli.flags.outputFormat),
195
+ exitCode: 2,
196
+ };
197
+ }
198
+ const template = await createAgentRuntimeProfileTemplateFromDiscovered({
199
+ homeDirectory: runtime.homeDirectory,
200
+ workingDirectory: runtime.workingDirectory,
201
+ }, {
202
+ id: templateId,
203
+ name: flagValue(rawRest, ['--name']) ?? undefined,
204
+ description: flagValue(rawRest, ['--description']) ?? undefined,
205
+ persona: flagValue(rawRest, ['--persona']) ?? undefined,
206
+ skills: parseCsvFlag(rawRest, ['--skills']),
207
+ routines: parseCsvFlag(rawRest, ['--routines']),
208
+ replace: hasYes(rawRest) && rawRest.includes('--replace'),
209
+ });
210
+ const result: AgentRuntimeProfileCommandResult = {
211
+ ok: true,
212
+ kind: 'agent.profiles.template.from_discovered',
213
+ data: { template },
214
+ };
215
+ return {
216
+ output: renderProfilesOutput(result, runtime.cli.flags.outputFormat),
217
+ exitCode: 0,
218
+ };
219
+ }
145
220
  if (templateAction === 'export') {
146
221
  if (!templateId || !templatePath) {
147
222
  const result: AgentRuntimeProfileCommandResult = {
@@ -290,6 +365,59 @@ export async function handleProfilesCommand(runtime: ProfilesCommandRuntime): Pr
290
365
  };
291
366
  }
292
367
 
368
+ if (sub === 'create-from-discovered' || sub === 'create-discovered') {
369
+ const name = values[0];
370
+ if (!name) {
371
+ const result: AgentRuntimeProfileCommandResult = {
372
+ ok: false,
373
+ kind: 'agent.profiles.error',
374
+ error: 'Usage: goodvibes-agent profiles create-from-discovered <name> [--template-id <id>] [--profile-name <display>] [--description <summary>] [--persona <name>] [--skills all|name,name] [--routines all|name,name] [--replace] --yes',
375
+ };
376
+ return {
377
+ output: renderProfilesOutput(result, runtime.cli.flags.outputFormat),
378
+ exitCode: 2,
379
+ };
380
+ }
381
+ if (!hasYes(rawRest)) {
382
+ const result: AgentRuntimeProfileCommandResult = {
383
+ ok: false,
384
+ kind: 'agent.profiles.error',
385
+ error: `Refusing to create Agent profile ${name} from discovered behavior without --yes.`,
386
+ };
387
+ return {
388
+ output: renderProfilesOutput(result, runtime.cli.flags.outputFormat),
389
+ exitCode: 2,
390
+ };
391
+ }
392
+ const created = await createAgentRuntimeProfileFromDiscovered({
393
+ homeDirectory: runtime.homeDirectory,
394
+ workingDirectory: runtime.workingDirectory,
395
+ }, {
396
+ profileName: name,
397
+ templateId: flagValue(rawRest, ['--template-id', '--starter-id']) ?? undefined,
398
+ name: flagValue(rawRest, ['--profile-name', '--name']) ?? undefined,
399
+ description: flagValue(rawRest, ['--description']) ?? undefined,
400
+ persona: flagValue(rawRest, ['--persona']) ?? undefined,
401
+ skills: parseCsvFlag(rawRest, ['--skills']),
402
+ routines: parseCsvFlag(rawRest, ['--routines']),
403
+ replace: rawRest.includes('--replace'),
404
+ });
405
+ const result: AgentRuntimeProfileCommandResult = {
406
+ ok: true,
407
+ kind: 'agent.profiles.create_from_discovered',
408
+ data: {
409
+ profile: created.profile,
410
+ appliedTemplate: created.profile.starterTemplateApplication,
411
+ template: created.template,
412
+ nextCommand: `goodvibes-agent --agent-profile ${created.profile.id}`,
413
+ },
414
+ };
415
+ return {
416
+ output: renderProfilesOutput(result, runtime.cli.flags.outputFormat),
417
+ exitCode: 0,
418
+ };
419
+ }
420
+
293
421
  if (sub === 'delete' || sub === 'remove') {
294
422
  const name = values[0];
295
423
  if (!name) {