autokap 1.5.7 → 1.6.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.
package/dist/cli.js CHANGED
@@ -240,12 +240,54 @@ program
240
240
  }
241
241
  process.exit(0);
242
242
  });
243
+ async function runOutdatedPresetsLocally(opts) {
244
+ if (opts.output) {
245
+ fatal('`--output` is not supported with `--outdated`; run an individual preset when local copies are needed.');
246
+ }
247
+ const config = await requireConfig();
248
+ const search = new URLSearchParams({ freshness: 'outdated' });
249
+ const data = await requestJson(config, `/api/cli/projects/${opts.project}/auto-recapture-presets`, { headers: authHeaders(config) }, 'Failed to list outdated presets', search);
250
+ if (data.presets.length === 0) {
251
+ logger.info(`[capture] No outdated presets found for project ${opts.project}`);
252
+ process.exit(0);
253
+ }
254
+ const { runCapture } = await import('./cli-runner.js');
255
+ const failures = [];
256
+ logger.info(`[capture] Running ${data.presets.length} outdated preset(s)`);
257
+ for (const preset of data.presets) {
258
+ const label = preset.name ? `${preset.name} (${preset.id})` : preset.id;
259
+ logger.info(`[capture] Running outdated preset ${label}`);
260
+ const result = await runCapture({
261
+ presetId: preset.id,
262
+ env: opts.env,
263
+ headed: opts.headed,
264
+ allowUploadFailure: opts.allowUploadFailure,
265
+ dryRun: opts.dry,
266
+ regenerateTts: opts.regenerateTts,
267
+ });
268
+ if (!result.success) {
269
+ failures.push({
270
+ id: preset.id,
271
+ name: preset.name,
272
+ error: result.error ?? result.runResult?.error ?? 'capture failed',
273
+ });
274
+ }
275
+ }
276
+ if (failures.length > 0) {
277
+ logger.error(`[capture] ${failures.length}/${data.presets.length} outdated preset(s) failed: ${failures.map((failure) => failure.name ?? failure.id).join(', ')}`);
278
+ process.exit(1);
279
+ }
280
+ logger.success(`[capture] ${data.presets.length} outdated preset(s) captured successfully`);
281
+ process.exit(0);
282
+ }
243
283
  // ── run command (deterministic capture engine) ───────────────────────
244
284
  program
245
- .command('run <preset-id>')
285
+ .command('run [preset-id]')
246
286
  .description('Run a capture using the deterministic opcode engine (local Playwright)')
247
287
  .option('--headed', 'Show browser window for debugging', false)
248
288
  .option('--local', `Use the local AutoKap dev server (${LOCAL_API_BASE_URL})`, false)
289
+ .option('--project <id>', 'Project ID. Required with --outdated.')
290
+ .option('--outdated', 'Run all outdated presets in the project', false)
249
291
  .option('--env <name>', "Project environment to capture against. Falls back to the project's default environment when omitted.")
250
292
  .option('--allow-upload-failure', 'Keep a successful capture exit code even if artifact upload fails', false)
251
293
  .option('--output <dir>', 'Optional output directory for local artifact copies')
@@ -264,6 +306,19 @@ program
264
306
  process.env[WS_URL_ENV_VAR] = LOCAL_WS_URL;
265
307
  logger.info(`Using local AutoKap dev server: ${LOCAL_API_BASE_URL}`);
266
308
  }
309
+ if (opts.outdated) {
310
+ if (!opts.project) {
311
+ fatal('Missing --project <id> for `autokap run --outdated`.');
312
+ }
313
+ if (opts.program) {
314
+ fatal('`--program` cannot be combined with `--outdated`.');
315
+ }
316
+ await runOutdatedPresetsLocally(opts);
317
+ return;
318
+ }
319
+ if (!presetId) {
320
+ fatal('Missing preset ID. Use `autokap run <preset-id>` or `autokap run --outdated --project <project-id>`.');
321
+ }
267
322
  const { runLocal } = await import('./cli-runner-local.js');
268
323
  await runLocal(presetId, opts);
269
324
  });
@@ -279,6 +334,7 @@ program
279
334
  .option('--debug', 'Verbose logging: per-substep timing, opcode dumps, recovery strategy traces', false)
280
335
  .option('--cloud', 'Cloud runner mode: signals 4+ vCPU available, unblocks the conservative Linux FPS default (8 → 30)', false)
281
336
  .option('--preset-ids <ids>', 'Comma-separated preset IDs to capture. When omitted, captures all presets with auto_recapture_enabled=true.')
337
+ .option('--outdated', 'Capture only outdated auto-recapture presets.', false)
282
338
  .action(async (opts) => {
283
339
  if (opts.debug) {
284
340
  const { setDebugEnabled } = await import('./logger.js');
@@ -393,9 +449,10 @@ program
393
449
  // When `--preset-ids` is provided, restrict the run to that subset
394
450
  // (per-preset recapture launched from the dashboard).
395
451
  const presetIdsArg = opts.presetIds?.trim();
452
+ const freshnessSuffix = opts.outdated ? '?freshness=outdated' : '';
396
453
  const presetsPath = presetIdsArg
397
454
  ? `/api/cli/projects/${opts.project}/auto-recapture-presets?preset_ids=${encodeURIComponent(presetIdsArg)}`
398
- : `/api/cli/projects/${opts.project}/auto-recapture-presets`;
455
+ : `/api/cli/projects/${opts.project}/auto-recapture-presets${freshnessSuffix}`;
399
456
  let data;
400
457
  try {
401
458
  const response = await fetch(buildApiUrl(config, presetsPath), {
@@ -1,5 +1,5 @@
1
1
  import type { SupabaseClient } from '@supabase/supabase-js';
2
- export type CreditUsageType = 'screenshot' | 'clip' | 'video' | 'preset_analysis' | 'cloud_recapture' | 'ai_chat' | 'studio_creation' | 'studio_iteration';
2
+ export type CreditUsageType = 'screenshot' | 'clip' | 'video' | 'cloud_recapture' | 'ai_chat' | 'studio_creation' | 'studio_iteration';
3
3
  export declare function recordCreditUsage(supabase: SupabaseClient, params: {
4
4
  userId: string;
5
5
  projectId: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autokap",
3
- "version": "1.5.7",
3
+ "version": "1.6.0",
4
4
  "description": "AI-powered CLI tool for capturing clean screenshots of websites",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",