@pellux/goodvibes-agent 0.1.112 → 0.1.114

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,3 +1,4 @@
1
+ import { discoverRoutines, type DiscoveredRoutineRecord } from '../../agent/routine-discovery.ts';
1
2
  import { AgentRoutineRegistry, type AgentRoutineRecord } from '../../agent/routine-registry.ts';
2
3
  import {
3
4
  buildRoutineSchedulePreview,
@@ -111,10 +112,86 @@ function renderRoutine(routine: AgentRoutineRecord): string {
111
112
  ].filter(Boolean).join('\n');
112
113
  }
113
114
 
115
+ function summarizeDiscoveredRoutine(routine: DiscoveredRoutineRecord): string {
116
+ const description = routine.description ? ` - ${routine.description}` : '';
117
+ return ` ${routine.name} ${routine.origin}${description}\n path: ${routine.path}`;
118
+ }
119
+
120
+ function renderDiscoveredRoutines(routines: readonly DiscoveredRoutineRecord[]): string {
121
+ if (routines.length === 0) {
122
+ return [
123
+ 'Discovered Agent routine files',
124
+ ' No routine markdown files found in project/global Agent routine folders.',
125
+ ' Search roots: .goodvibes/routines, .goodvibes/agent/routines, ~/.goodvibes/routines, ~/.goodvibes/agent/routines',
126
+ ].join('\n');
127
+ }
128
+ return [
129
+ `Discovered Agent routine files (${routines.length})`,
130
+ ...routines.map(summarizeDiscoveredRoutine),
131
+ '',
132
+ 'Import one with: /routines import-discovered <name> --yes',
133
+ ].join('\n');
134
+ }
135
+
136
+ function discoveredRoutineLookupValues(routine: DiscoveredRoutineRecord): readonly string[] {
137
+ const slug = routine.name.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
138
+ const basename = routine.path.split(/[\\/]/).pop()?.replace(/\.md$/i, '') ?? '';
139
+ return [routine.name, slug, routine.path, basename].map((value) => value.trim().toLowerCase()).filter(Boolean);
140
+ }
141
+
142
+ function findDiscoveredRoutine(routines: readonly DiscoveredRoutineRecord[], idOrName: string): DiscoveredRoutineRecord | null {
143
+ const lookup = idOrName.trim().toLowerCase();
144
+ if (!lookup) return null;
145
+ return routines.find((routine) => discoveredRoutineLookupValues(routine).includes(lookup)) ?? null;
146
+ }
147
+
148
+ function frontmatterList(routine: DiscoveredRoutineRecord, key: string): readonly string[] {
149
+ const value = routine.frontmatter[key];
150
+ if (!value) return [];
151
+ return splitList(value);
152
+ }
153
+
114
154
  function printError(ctx: CommandContext, error: unknown): void {
115
155
  ctx.print(`Error: ${error instanceof Error ? error.message : String(error)}`);
116
156
  }
117
157
 
158
+ async function importDiscoveredRoutine(args: readonly string[], ctx: CommandContext, routineRegistry: AgentRoutineRegistry): Promise<void> {
159
+ const parsed = parseRoutineArgs(args);
160
+ const name = parsed.rest.join(' ').trim();
161
+ if (!name) {
162
+ ctx.print('Usage: /routines import-discovered <name> [--enabled] --yes');
163
+ return;
164
+ }
165
+ const discovered = findDiscoveredRoutine(await discoverRoutines(requireShellPaths(ctx)), name);
166
+ if (!discovered) {
167
+ ctx.print(`Unknown discovered Agent routine: ${name}\nRun /routines discover to inspect available routine files.`);
168
+ return;
169
+ }
170
+ if (!parsed.yes) {
171
+ ctx.print([
172
+ 'Agent routine import preview',
173
+ ` name: ${discovered.name}`,
174
+ ` origin: ${discovered.origin}`,
175
+ ` path: ${discovered.path}`,
176
+ ` description: ${discovered.description || '(none)'}`,
177
+ ` steps characters: ${discovered.steps.length}`,
178
+ ' next: rerun with --yes to import into the Agent-local routine registry',
179
+ ].join('\n'));
180
+ return;
181
+ }
182
+ const routine = routineRegistry.create({
183
+ name: discovered.name,
184
+ description: discovered.description || `Imported routine from ${discovered.origin} markdown file.`,
185
+ steps: discovered.steps,
186
+ tags: frontmatterList(discovered, 'tags'),
187
+ triggers: frontmatterList(discovered, 'triggers'),
188
+ enabled: parsed.flags.get('enabled') === 'true',
189
+ source: 'imported',
190
+ provenance: `discovered:${discovered.origin}:${discovered.path}`,
191
+ });
192
+ ctx.print(`Imported Agent routine ${routine.id}: ${routine.name}${routine.enabled ? ' (enabled)' : ''}`);
193
+ }
194
+
118
195
  async function promoteRoutine(args: readonly string[], routineRegistry: AgentRoutineRegistry, ctx: CommandContext): Promise<void> {
119
196
  const parsed = parseRoutineSchedulePromotionArgs(args);
120
197
  if (parsed.errors.length > 0) {
@@ -154,6 +231,14 @@ export async function runRoutinesRuntimeCommand(args: readonly string[], ctx: Co
154
231
  ctx.print(renderList('Enabled Agent Routines', routineRegistry, snapshot.enabledRoutines));
155
232
  return;
156
233
  }
234
+ if (sub === 'discover' || sub === 'discovered') {
235
+ ctx.print(renderDiscoveredRoutines(await discoverRoutines(requireShellPaths(ctx))));
236
+ return;
237
+ }
238
+ if (sub === 'import-discovered' || sub === 'import-routine') {
239
+ await importDiscoveredRoutine(args.slice(1), ctx, routineRegistry);
240
+ return;
241
+ }
157
242
  if (sub === 'search') {
158
243
  const query = args.slice(1).join(' ').trim();
159
244
  ctx.print(renderList(query ? `Agent Routines matching "${query}"` : 'Agent Routines', routineRegistry, routineRegistry.search(query)));
@@ -288,7 +373,7 @@ export async function runRoutinesRuntimeCommand(args: readonly string[], ctx: Co
288
373
  ctx.print(`Deleted Agent routine ${removed.id}: ${removed.name}`);
289
374
  return;
290
375
  }
291
- ctx.print('Usage: /routines [list|enabled|search|show|receipts|reconcile|receipt|create|update|enable|disable|start|review|stale|promote|delete]');
376
+ ctx.print('Usage: /routines [list|enabled|discover|import-discovered|search|show|receipts|reconcile|receipt|create|update|enable|disable|start|review|stale|promote|delete]');
292
377
  } catch (error) {
293
378
  printError(ctx, error);
294
379
  }
@@ -299,7 +384,7 @@ export function registerRoutinesRuntimeCommands(registry: CommandRegistry): void
299
384
  name: 'routines',
300
385
  aliases: ['routine'],
301
386
  description: 'Manage local GoodVibes Agent routines',
302
- usage: '[list|enabled|search <query>|show <id>|receipts|reconcile|receipt <id>|create --name <name> --description <summary> --steps <steps>|update <id> [--name ...] [--description ...] [--steps ...]|enable <id>|disable <id>|start <id>|review <id>|stale <id> <reason...>|promote <id> --cron <expr> [--delivery-channel slack] --yes|delete <id> --yes]',
387
+ usage: '[list|enabled|discover|import-discovered <name> --yes|search <query>|show <id>|receipts|reconcile|receipt <id>|create --name <name> --description <summary> --steps <steps>|update <id> [--name ...] [--description ...] [--steps ...]|enable <id>|disable <id>|start <id>|review <id>|stale <id> <reason...>|promote <id> --cron <expr> [--delivery-channel slack] --yes|delete <id> --yes]',
303
388
  handler: runRoutinesRuntimeCommand,
304
389
  });
305
390
  }
@@ -28,7 +28,7 @@ export class UIFactory {
28
28
  const CYAN = '#00ffff';
29
29
  const GREY = '244';
30
30
  const TITLE_COLOR = '250';
31
- const brand = ` GoodVibes `;
31
+ const brand = ` GoodVibes Agent `;
32
32
  const ver = `v${VERSION} `;
33
33
  const stats = ` ${model} `;
34
34
  const prov = `(${provider}) `;
package/src/version.ts CHANGED
@@ -6,7 +6,7 @@ import { join } from 'node:path';
6
6
  // The prebuild script updates the fallback value before compilation.
7
7
  // Uses import.meta.dir (Bun) to locate package.json relative to this file,
8
8
  // which is correct regardless of the process working directory.
9
- let _version = '0.1.112';
9
+ let _version = '0.1.114';
10
10
  let _sdkVersion = '0.33.35';
11
11
  try {
12
12
  const pkg = JSON.parse(readFileSync(join(import.meta.dir, '..', 'package.json'), 'utf-8')) as {