workflow-agent-cli 2.22.5 → 2.22.6

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.
@@ -270,25 +270,46 @@ async function syncCommand(options) {
270
270
  if (options.dryRun) {
271
271
  console.log(chalk.yellow("\n\u{1F4CB} DRY-RUN MODE: No changes will be synced\n"));
272
272
  }
273
- console.log(chalk.cyan("\n\u{1F4E6} Sync scope:"));
273
+ console.log(chalk.cyan("\n\u{1F4E6} Syncing:"));
274
274
  if (syncLearn) console.log(chalk.dim(" \u2022 Learning patterns (fixes, blueprints)"));
275
275
  if (syncSolutions) console.log(chalk.dim(" \u2022 Solution patterns"));
276
276
  if (syncScopes) console.log(chalk.dim(" \u2022 Custom scopes"));
277
277
  console.log(chalk.dim(` \u2022 Direction: ${direction === "both" ? "push + pull" : direction}`));
278
+ if (options.includePrivate) console.log(chalk.dim(" \u2022 Including private patterns"));
278
279
  console.log("");
279
280
  const store = new PatternStore(cwd);
280
281
  const anonymizer = new PatternAnonymizer();
281
282
  const syncData = await store.getPatternsForSync();
282
- const fixes = syncData.fixes ?? [];
283
- const blueprints = syncData.blueprints ?? [];
284
- const solutions = syncData.solutions ?? [];
283
+ let fixes = syncData.fixes ?? [];
284
+ let blueprints = syncData.blueprints ?? [];
285
+ let solutions = syncData.solutions ?? [];
286
+ const stats = await store.getStats();
287
+ const totalLocalFixes = stats.totalFixes;
288
+ const totalLocalBlueprints = stats.totalBlueprints;
289
+ const totalLocalSolutions = stats.totalSolutions;
290
+ const privateFixes = stats.privateFixes;
291
+ const privateBlueprints = stats.privateBlueprints;
292
+ const privateSolutions = stats.privateSolutions;
293
+ if (options.includePrivate) {
294
+ const allFixes = await store.listFixPatterns({ includeDeprecated: false });
295
+ const allBlueprints = await store.listBlueprints({ includeDeprecated: false });
296
+ const allSolutions = await store.listSolutions({ includeDeprecated: false });
297
+ fixes = allFixes.data ?? [];
298
+ blueprints = allBlueprints.data ?? [];
299
+ solutions = allSolutions.data ?? [];
300
+ }
285
301
  const patternsToSync = [];
286
302
  if (syncLearn) {
287
- console.log(
288
- chalk.dim(
289
- ` Found ${fixes.length} fixes, ${blueprints.length} blueprints ready to sync`
290
- )
291
- );
303
+ const publicCount = fixes.length;
304
+ const privateCount = privateFixes;
305
+ if (options.includePrivate) {
306
+ console.log(chalk.dim(` Found ${publicCount} fixes, ${blueprints.length} blueprints to sync (including private)`));
307
+ } else if (publicCount === 0 && privateCount > 0) {
308
+ console.log(chalk.yellow(` Found 0 fixes ready to sync (${privateCount} are private)`));
309
+ console.log(chalk.dim(` Use --include-private to include them, or run 'workflow learn migrate --public'`));
310
+ } else {
311
+ console.log(chalk.dim(` Found ${publicCount} fixes, ${blueprints.length} blueprints ready to sync`));
312
+ }
292
313
  for (const fix of fixes) {
293
314
  const result = anonymizer.anonymizeFixPattern(fix);
294
315
  if (result.success && result.data) {
@@ -311,11 +332,16 @@ async function syncCommand(options) {
311
332
  }
312
333
  }
313
334
  if (syncSolutions) {
314
- console.log(
315
- chalk.dim(
316
- ` Found ${solutions.length} solutions ready to sync`
317
- )
318
- );
335
+ const publicCount = solutions.length;
336
+ const privateCount = privateSolutions;
337
+ if (options.includePrivate) {
338
+ console.log(chalk.dim(` Found ${publicCount} solutions to sync (including private)`));
339
+ } else if (publicCount === 0 && privateCount > 0) {
340
+ console.log(chalk.yellow(` Found 0 solutions ready to sync (${privateCount} are private)`));
341
+ console.log(chalk.dim(` Use --include-private to include them, or run 'workflow solution migrate --public'`));
342
+ } else {
343
+ console.log(chalk.dim(` Found ${publicCount} solutions ready to sync`));
344
+ }
319
345
  for (const solution of solutions) {
320
346
  const result = anonymizer.anonymizeSolution(solution);
321
347
  if (result.success && result.data) {
@@ -438,10 +464,12 @@ async function syncCommand(options) {
438
464
  }
439
465
  let totalPatterns = 0;
440
466
  let savedCount = 0;
467
+ const typeCounts = {};
441
468
  for (const pullType of pullTypes) {
442
469
  const pullResult = await registryClient.pull({
443
470
  type: pullType
444
471
  });
472
+ typeCounts[pullType] = pullResult.patterns.length;
445
473
  totalPatterns += pullResult.patterns.length;
446
474
  for (const pulled of pullResult.patterns) {
447
475
  try {
@@ -459,13 +487,24 @@ async function syncCommand(options) {
459
487
  }
460
488
  }
461
489
  }
490
+ if (syncSolutions && typeCounts["solution"] !== void 0) {
491
+ console.log(chalk.dim(` Registry has ${typeCounts["solution"]} solution(s) available`));
492
+ }
493
+ if (syncLearn) {
494
+ const fixCount = typeCounts["fix"] ?? 0;
495
+ const bpCount = typeCounts["blueprint"] ?? 0;
496
+ console.log(chalk.dim(` Registry has ${fixCount} fix(es), ${bpCount} blueprint(s) available`));
497
+ }
462
498
  if (totalPatterns === 0) {
463
499
  console.log(chalk.dim(" No new patterns to pull"));
464
500
  } else {
465
501
  console.log(
466
502
  chalk.green(`
467
- \u2705 Pulled ${savedCount} patterns from registry`)
503
+ \u2705 Pulled ${savedCount} new patterns from registry`)
468
504
  );
505
+ if (savedCount < totalPatterns) {
506
+ console.log(chalk.dim(` (${totalPatterns - savedCount} already existed locally)`));
507
+ }
469
508
  }
470
509
  } catch (error) {
471
510
  if (error instanceof RateLimitedException) {
@@ -496,4 +535,4 @@ async function syncCommand(options) {
496
535
  export {
497
536
  syncCommand
498
537
  };
499
- //# sourceMappingURL=chunk-YBRWXMVK.js.map
538
+ //# sourceMappingURL=chunk-K5O7GGHK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/commands/sync.ts","../src/sync/registry-client.ts"],"sourcesContent":["/**\n * Unified Sync Command\n *\n * Orchestrates syncing of patterns and solutions with the registry.\n * Combines functionality from learn:sync and solution sync.\n *\n * Usage:\n * workflow sync # Interactive sync (prompts for direction)\n * workflow sync --push # Push local patterns to registry\n * workflow sync --pull # Pull patterns from registry\n * workflow sync --solutions # Include solution patterns\n * workflow sync --learn # Include learning patterns (default)\n * workflow sync --scopes # Sync custom scope packages\n * workflow sync --all # Sync everything\n * workflow sync --dry-run # Preview without syncing\n */\n\nimport * as p from \"@clack/prompts\";\nimport chalk from \"chalk\";\nimport {\n PatternStore,\n PatternAnonymizer,\n ContributorManager,\n type FixPattern,\n type Blueprint,\n type SolutionPattern,\n} from \"@hawkinside_out/workflow-improvement-tracker\";\nimport {\n RegistryClient,\n RateLimitedException,\n RegistryError,\n} from \"../../sync/registry-client.js\";\n\nexport interface UnifiedSyncOptions {\n push?: boolean;\n pull?: boolean;\n solutions?: boolean;\n learn?: boolean;\n scopes?: boolean;\n all?: boolean;\n dryRun?: boolean;\n enableSync?: boolean;\n disableSync?: boolean;\n includePrivate?: boolean;\n}\n\nfunction getWorkspacePath(): string {\n return process.cwd();\n}\n\n/**\n * Unified sync command that orchestrates all sync operations\n */\nexport async function syncCommand(options: UnifiedSyncOptions): Promise<void> {\n const cwd = getWorkspacePath();\n const contributorManager = new ContributorManager(cwd);\n\n p.intro(chalk.bgBlue(\" workflow sync \"));\n\n // Handle --enable-sync option\n if (options.enableSync) {\n const enableResult = await contributorManager.enableSync();\n if (enableResult.success) {\n console.log(chalk.green(\"\\n✅ Sync enabled!\"));\n console.log(chalk.dim(\" Your anonymized patterns can now be shared with the community.\\n\"));\n } else {\n console.log(chalk.red(`\\n❌ Failed to enable sync: ${enableResult.error}\\n`));\n process.exit(1);\n }\n // If only --enable-sync was passed, exit after enabling\n if (!options.push && !options.pull && !options.all && !options.solutions && !options.scopes) {\n p.outro(chalk.green(\"Sync enabled\"));\n return;\n }\n }\n\n // Handle --disable-sync option\n if (options.disableSync) {\n const disableResult = await contributorManager.disableSync();\n if (disableResult.success) {\n console.log(chalk.green(\"\\n✅ Sync disabled!\"));\n console.log(chalk.dim(\" Your patterns will no longer be shared.\\n\"));\n } else {\n console.log(chalk.red(`\\n❌ Failed to disable sync: ${disableResult.error}\\n`));\n process.exit(1);\n }\n p.outro(chalk.green(\"Sync disabled\"));\n return;\n }\n\n // Check if sync is enabled\n const config = await contributorManager.getConfig();\n if (!config.success || !config.data?.syncOptIn) {\n console.log(chalk.yellow(\"\\n⚠️ Sync is not enabled.\\n\"));\n console.log(chalk.dim(\" To enable sync, run:\"));\n console.log(chalk.dim(\" workflow learn config --enable-sync\\n\"));\n console.log(\n chalk.dim(\n \" This allows you to share anonymized patterns with the community.\",\n ),\n );\n p.outro(chalk.yellow(\"Sync not enabled\"));\n process.exit(0);\n }\n\n // Determine what to sync\n const syncLearn = options.learn || options.all || (!options.solutions && !options.scopes);\n const syncSolutions = options.solutions || options.all;\n const syncScopes = options.scopes || options.all;\n\n // Determine direction\n let direction: \"push\" | \"pull\" | \"both\" = \"both\";\n if (options.push && !options.pull) {\n direction = \"push\";\n } else if (options.pull && !options.push) {\n direction = \"pull\";\n } else if (!options.push && !options.pull) {\n // Interactive mode - ask user\n const choice = await p.select({\n message: \"Sync direction:\",\n options: [\n { value: \"push\", label: \"📤 Push - Upload local patterns to registry\" },\n { value: \"pull\", label: \"📥 Pull - Download patterns from registry\" },\n { value: \"both\", label: \"🔄 Both - Push then pull\" },\n ],\n });\n\n if (p.isCancel(choice)) {\n p.cancel(\"Sync cancelled\");\n process.exit(0);\n }\n direction = choice as \"push\" | \"pull\" | \"both\";\n }\n\n if (options.dryRun) {\n console.log(chalk.yellow(\"\\n📋 DRY-RUN MODE: No changes will be synced\\n\"));\n }\n\n // Show what will be synced\n console.log(chalk.cyan(\"\\n📦 Syncing:\"));\n if (syncLearn) console.log(chalk.dim(\" • Learning patterns (fixes, blueprints)\"));\n if (syncSolutions) console.log(chalk.dim(\" • Solution patterns\"));\n if (syncScopes) console.log(chalk.dim(\" • Custom scopes\"));\n console.log(chalk.dim(` • Direction: ${direction === \"both\" ? \"push + pull\" : direction}`));\n if (options.includePrivate) console.log(chalk.dim(\" • Including private patterns\"));\n console.log(\"\");\n\n const store = new PatternStore(cwd);\n const anonymizer = new PatternAnonymizer();\n\n // Get patterns to sync\n // If --include-private is set, get all patterns; otherwise filter to public only\n const syncData = await store.getPatternsForSync();\n let fixes = syncData.fixes ?? [];\n let blueprints = syncData.blueprints ?? [];\n let solutions = syncData.solutions ?? [];\n\n // Get stats for all patterns to show why some might be excluded\n const stats = await store.getStats();\n const totalLocalFixes = stats.totalFixes;\n const totalLocalBlueprints = stats.totalBlueprints;\n const totalLocalSolutions = stats.totalSolutions;\n const privateFixes = stats.privateFixes;\n const privateBlueprints = stats.privateBlueprints;\n const privateSolutions = stats.privateSolutions;\n\n // If --include-private, we need to get all patterns including private ones\n if (options.includePrivate) {\n const allFixes = await store.listFixPatterns({ includeDeprecated: false });\n const allBlueprints = await store.listBlueprints({ includeDeprecated: false });\n const allSolutions = await store.listSolutions({ includeDeprecated: false });\n fixes = allFixes.data ?? [];\n blueprints = allBlueprints.data ?? [];\n solutions = allSolutions.data ?? [];\n }\n\n // Filter based on options\n const patternsToSync: Array<{\n pattern: FixPattern | Blueprint | SolutionPattern;\n type: \"fix\" | \"blueprint\" | \"solution\";\n originalId: string;\n }> = [];\n\n if (syncLearn) {\n const publicCount = fixes.length;\n const privateCount = privateFixes;\n \n if (options.includePrivate) {\n console.log(chalk.dim(` Found ${publicCount} fixes, ${blueprints.length} blueprints to sync (including private)`));\n } else if (publicCount === 0 && privateCount > 0) {\n console.log(chalk.yellow(` Found 0 fixes ready to sync (${privateCount} are private)`));\n console.log(chalk.dim(` Use --include-private to include them, or run 'workflow learn migrate --public'`));\n } else {\n console.log(chalk.dim(` Found ${publicCount} fixes, ${blueprints.length} blueprints ready to sync`));\n }\n\n for (const fix of fixes) {\n const result = anonymizer.anonymizeFixPattern(fix);\n if (result.success && result.data) {\n patternsToSync.push({\n pattern: result.data,\n type: \"fix\",\n originalId: fix.id,\n });\n }\n }\n\n for (const bp of blueprints) {\n const result = anonymizer.anonymizeBlueprint(bp);\n if (result.success && result.data) {\n patternsToSync.push({\n pattern: result.data,\n type: \"blueprint\",\n originalId: bp.id,\n });\n }\n }\n }\n\n if (syncSolutions) {\n const publicCount = solutions.length;\n const privateCount = privateSolutions;\n \n if (options.includePrivate) {\n console.log(chalk.dim(` Found ${publicCount} solutions to sync (including private)`));\n } else if (publicCount === 0 && privateCount > 0) {\n console.log(chalk.yellow(` Found 0 solutions ready to sync (${privateCount} are private)`));\n console.log(chalk.dim(` Use --include-private to include them, or run 'workflow solution migrate --public'`));\n } else {\n console.log(chalk.dim(` Found ${publicCount} solutions ready to sync`));\n }\n\n for (const solution of solutions) {\n const result = anonymizer.anonymizeSolution(solution);\n if (result.success && result.data) {\n patternsToSync.push({\n pattern: result.data,\n type: \"solution\",\n originalId: solution.id,\n });\n }\n }\n }\n\n if (syncScopes) {\n // TODO: Implement scope sync when scope registry is available\n console.log(chalk.dim(\" Scope sync: Coming soon\"));\n }\n\n // PUSH operation\n if (direction === \"push\" || direction === \"both\") {\n console.log(chalk.cyan(\"\\n📤 Pushing patterns...\\n\"));\n\n if (patternsToSync.length === 0) {\n console.log(chalk.yellow(\" No patterns to push\\n\"));\n } else {\n const fixCount = patternsToSync.filter((p) => p.type === \"fix\").length;\n const bpCount = patternsToSync.filter((p) => p.type === \"blueprint\").length;\n const solutionCount = patternsToSync.filter((p) => p.type === \"solution\").length;\n\n console.log(\n chalk.dim(\n ` Ready to push: ${fixCount} fixes, ${bpCount} blueprints, ${solutionCount} solutions`,\n ),\n );\n\n if (options.dryRun) {\n console.log(chalk.yellow(\"\\n [DRY-RUN] Would push patterns to registry\"));\n } else {\n // Get contributor ID\n const contributorResult = await contributorManager.getOrCreateId();\n if (!contributorResult.success || !contributorResult.data) {\n console.log(chalk.red(\"\\n ❌ Failed to get contributor ID\"));\n process.exit(1);\n }\n\n // Push to registry\n const registryClient = new RegistryClient();\n\n try {\n console.log(chalk.dim(\"\\n Connecting to registry...\"));\n\n const pushResult = await registryClient.push(\n patternsToSync.map((p) => ({\n pattern: p.pattern,\n type: p.type,\n })),\n contributorResult.data,\n );\n\n // Mark pushed patterns as synced\n if (pushResult.pushed > 0) {\n const pushedFixIds = patternsToSync\n .filter((p) => p.type === \"fix\")\n .map((p) => p.originalId);\n const pushedBpIds = patternsToSync\n .filter((p) => p.type === \"blueprint\")\n .map((p) => p.originalId);\n const pushedSolutionIds = patternsToSync\n .filter((p) => p.type === \"solution\")\n .map((p) => p.originalId);\n\n if (pushedFixIds.length > 0) {\n await store.markAsSynced(pushedFixIds, \"fix\");\n }\n if (pushedBpIds.length > 0) {\n await store.markAsSynced(pushedBpIds, \"blueprint\");\n }\n if (pushedSolutionIds.length > 0) {\n await store.markAsSynced(pushedSolutionIds, \"solution\");\n }\n }\n\n console.log(\n chalk.green(`\\n ✅ Pushed ${pushResult.pushed} patterns to registry`),\n );\n\n if (pushResult.skipped > 0) {\n console.log(\n chalk.dim(` (${pushResult.skipped} already existed)`),\n );\n }\n\n if (pushResult.errors && pushResult.errors.length > 0) {\n console.log(chalk.yellow(`\\n ⚠️ Some patterns had errors:`));\n for (const err of pushResult.errors) {\n console.log(chalk.dim(` - ${err}`));\n }\n }\n\n console.log(\n chalk.dim(\n `\\n Rate limit: ${pushResult.rateLimit.remaining} patterns remaining this hour`,\n ),\n );\n } catch (error) {\n if (error instanceof RateLimitedException) {\n console.log(chalk.red(\"\\n ❌ Rate limit exceeded\"));\n console.log(\n chalk.dim(\n ` Try again in ${error.getTimeUntilReset()}`,\n ),\n );\n } else if (error instanceof RegistryError) {\n console.log(chalk.red(`\\n ❌ Registry error: ${error.message}`));\n } else {\n console.log(\n chalk.red(\n `\\n ❌ Failed to push: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n process.exit(1);\n }\n }\n }\n }\n\n // PULL operation\n if (direction === \"pull\" || direction === \"both\") {\n console.log(chalk.cyan(\"\\n📥 Pulling patterns from registry...\\n\"));\n\n if (options.dryRun) {\n console.log(chalk.yellow(\" [DRY-RUN] Would pull patterns from registry\"));\n } else {\n const registryClient = new RegistryClient();\n\n try {\n console.log(chalk.dim(\" Connecting to registry...\"));\n\n // Pull patterns based on sync options - need to call separately for each type\n const pullTypes: (\"fix\" | \"blueprint\" | \"solution\")[] = [];\n if (syncLearn) {\n pullTypes.push(\"fix\", \"blueprint\");\n }\n if (syncSolutions) {\n pullTypes.push(\"solution\");\n }\n\n let totalPatterns = 0;\n let savedCount = 0;\n const typeCounts: Record<string, number> = {};\n\n for (const pullType of pullTypes) {\n const pullResult = await registryClient.pull({\n type: pullType,\n });\n\n typeCounts[pullType] = pullResult.patterns.length;\n totalPatterns += pullResult.patterns.length;\n\n for (const pulled of pullResult.patterns) {\n try {\n if (pulled.type === \"fix\" && pulled.data) {\n await store.saveFixPattern(pulled.data as FixPattern);\n savedCount++;\n } else if (pulled.type === \"blueprint\" && pulled.data) {\n await store.saveBlueprint(pulled.data as Blueprint);\n savedCount++;\n } else if (pulled.type === \"solution\" && pulled.data) {\n await store.saveSolution(pulled.data as SolutionPattern);\n savedCount++;\n }\n } catch {\n // Pattern might already exist\n }\n }\n }\n\n // Show registry stats\n if (syncSolutions && typeCounts[\"solution\"] !== undefined) {\n console.log(chalk.dim(` Registry has ${typeCounts[\"solution\"]} solution(s) available`));\n }\n if (syncLearn) {\n const fixCount = typeCounts[\"fix\"] ?? 0;\n const bpCount = typeCounts[\"blueprint\"] ?? 0;\n console.log(chalk.dim(` Registry has ${fixCount} fix(es), ${bpCount} blueprint(s) available`));\n }\n\n if (totalPatterns === 0) {\n console.log(chalk.dim(\" No new patterns to pull\"));\n } else {\n console.log(\n chalk.green(`\\n ✅ Pulled ${savedCount} new patterns from registry`),\n );\n if (savedCount < totalPatterns) {\n console.log(chalk.dim(` (${totalPatterns - savedCount} already existed locally)`));\n }\n }\n } catch (error) {\n if (error instanceof RateLimitedException) {\n console.log(chalk.red(\"\\n ❌ Rate limit exceeded\"));\n console.log(\n chalk.dim(\n ` Try again in ${error.getTimeUntilReset()}`,\n ),\n );\n } else if (error instanceof RegistryError) {\n console.log(chalk.red(`\\n ❌ Registry error: ${error.message}`));\n } else {\n console.log(\n chalk.red(\n `\\n ❌ Failed to pull: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n process.exit(1);\n }\n }\n }\n\n p.outro(chalk.green(\"Sync complete!\"));\n}\n","/**\n * Registry Client for pattern sync\n *\n * HTTP client for pushing patterns to and pulling patterns from\n * the community pattern registry.\n */\n\nimport type { FixPattern, Blueprint, SolutionPattern } from \"@hawkinside_out/workflow-improvement-tracker\";\n\n// Default registry URL\nconst DEFAULT_REGISTRY_URL = \"https://registry-api-rust.vercel.app\";\n\n/**\n * Pattern payload for push/pull operations\n */\nexport interface RegistryPattern {\n id: string;\n type: \"fix\" | \"blueprint\" | \"solution\";\n data: Record<string, unknown>;\n hash?: string;\n createdAt?: string;\n}\n\n/**\n * Push response from registry\n */\nexport interface PushResponse {\n status: \"ok\" | \"error\";\n pushed: number;\n skipped: number;\n errors?: string[];\n rateLimit: {\n remaining: number;\n resetAt: string | null;\n };\n}\n\n/**\n * Pull response from registry\n */\nexport interface PullResponse {\n patterns: RegistryPattern[];\n pagination: {\n offset: number;\n limit: number;\n total: number;\n hasMore: boolean;\n };\n}\n\n/**\n * Rate limit error details\n */\nexport interface RateLimitError {\n message: string;\n resetAt: string | null;\n remaining: number;\n}\n\n/**\n * Registry client options\n */\nexport interface RegistryClientOptions {\n /**\n * Base URL of the registry API\n * Defaults to https://patterns.workflow-agent.dev\n * Can be overridden via WORKFLOW_REGISTRY_URL env var\n */\n baseUrl?: string;\n\n /**\n * Request timeout in milliseconds\n * Defaults to 30000 (30 seconds)\n */\n timeout?: number;\n\n /**\n * Number of retry attempts for failed requests\n * Defaults to 3\n */\n retries?: number;\n}\n\n/**\n * Registry Client\n *\n * Handles HTTP communication with the pattern registry API\n */\nexport class RegistryClient {\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly retries: number;\n\n constructor(options: RegistryClientOptions = {}) {\n // Priority: options > env var > default\n this.baseUrl =\n options.baseUrl ||\n process.env.WORKFLOW_REGISTRY_URL ||\n DEFAULT_REGISTRY_URL;\n\n // Ensure no trailing slash\n this.baseUrl = this.baseUrl.replace(/\\/$/, \"\");\n\n this.timeout = options.timeout ?? 30000;\n this.retries = options.retries ?? 3;\n }\n\n /**\n * Push patterns to the registry\n *\n * @param patterns - Array of anonymized patterns to push\n * @param contributorId - Anonymous contributor ID\n * @returns Push result with count of pushed/skipped patterns\n * @throws Error if rate limited or push fails\n */\n async push(\n patterns: Array<{\n pattern: FixPattern | Blueprint | SolutionPattern;\n type: \"fix\" | \"blueprint\" | \"solution\";\n hash?: string;\n }>,\n contributorId: string,\n ): Promise<PushResponse> {\n const payload = {\n patterns: patterns.map((p) => ({\n id: p.pattern.id,\n type: p.type,\n data: p.pattern as unknown as Record<string, unknown>,\n hash: p.hash,\n })),\n };\n\n const response = await this.request<PushResponse>(\n \"/api/patterns/push\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-contributor-id\": contributorId,\n },\n body: JSON.stringify(payload),\n },\n );\n\n return response;\n }\n\n /**\n * Pull patterns from the registry\n *\n * @param options - Pull options\n * @returns Array of patterns from the registry\n */\n async pull(options: {\n type?: \"fix\" | \"blueprint\" | \"solution\";\n limit?: number;\n offset?: number;\n since?: string;\n } = {}): Promise<PullResponse> {\n const params = new URLSearchParams();\n\n if (options.type) {\n params.set(\"type\", options.type);\n }\n if (options.limit) {\n params.set(\"limit\", options.limit.toString());\n }\n if (options.offset) {\n params.set(\"offset\", options.offset.toString());\n }\n if (options.since) {\n params.set(\"since\", options.since);\n }\n\n const queryString = params.toString();\n const url = `/api/patterns/pull${queryString ? `?${queryString}` : \"\"}`;\n\n return this.request<PullResponse>(url, {\n method: \"GET\",\n });\n }\n\n /**\n * Get a single pattern by ID\n *\n * @param patternId - UUID of the pattern\n * @returns Pattern data or null if not found\n */\n async getPattern(patternId: string): Promise<RegistryPattern | null> {\n try {\n return await this.request<RegistryPattern>(`/api/patterns/${patternId}`, {\n method: \"GET\",\n });\n } catch (error) {\n if (error instanceof RegistryError && error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Check if the registry is available\n */\n async healthCheck(): Promise<boolean> {\n try {\n await this.request<{ status: string }>(\"/api/health\", {\n method: \"GET\",\n });\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Make an HTTP request to the registry\n */\n private async request<T>(\n path: string,\n options: RequestInit,\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n let lastError: Error | null = null;\n\n for (let attempt = 1; attempt <= this.retries; attempt++) {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n const response = await fetch(url, {\n ...options,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (response.status === 429) {\n // Rate limited\n const body = await response.json() as { message?: string; resetAt?: string | null; remaining?: number };\n throw new RateLimitedException(\n body.message || \"Rate limit exceeded\",\n body.resetAt ?? null,\n body.remaining ?? 0,\n );\n }\n\n if (!response.ok) {\n const body = await response.json().catch(() => ({})) as { error?: string };\n throw new RegistryError(\n body.error || `Request failed with status ${response.status}`,\n response.status,\n body,\n );\n }\n\n return await response.json() as T;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n // Don't retry rate limit errors\n if (error instanceof RateLimitedException) {\n throw error;\n }\n\n // Don't retry on 4xx errors (except timeout)\n if (\n error instanceof RegistryError &&\n error.statusCode >= 400 &&\n error.statusCode < 500\n ) {\n throw error;\n }\n\n // Wait before retrying (exponential backoff)\n if (attempt < this.retries) {\n await new Promise((resolve) =>\n setTimeout(resolve, Math.pow(2, attempt) * 1000)\n );\n }\n }\n }\n\n throw lastError ?? new Error(\"Request failed after retries\");\n }\n}\n\n/**\n * Registry API error\n */\nexport class RegistryError extends Error {\n constructor(\n message: string,\n public readonly statusCode: number,\n public readonly body?: unknown,\n ) {\n super(message);\n this.name = \"RegistryError\";\n }\n}\n\n/**\n * Rate limit exceeded error\n */\nexport class RateLimitedException extends Error {\n constructor(\n message: string,\n public readonly resetAt: string | null,\n public readonly remaining: number,\n ) {\n super(message);\n this.name = \"RateLimitedException\";\n }\n\n /**\n * Get human-readable time until rate limit resets\n */\n getTimeUntilReset(): string {\n if (!this.resetAt) {\n return \"unknown\";\n }\n\n const resetTime = new Date(this.resetAt).getTime();\n const now = Date.now();\n const diffMs = resetTime - now;\n\n if (diffMs <= 0) {\n return \"now\";\n }\n\n const minutes = Math.ceil(diffMs / 60000);\n if (minutes < 60) {\n return `${minutes} minute${minutes === 1 ? \"\" : \"s\"}`;\n }\n\n const hours = Math.ceil(minutes / 60);\n return `${hours} hour${hours === 1 ? \"\" : \"s\"}`;\n }\n}\n"],"mappings":";AAiBA,YAAY,OAAO;AACnB,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;;;AChBP,IAAM,uBAAuB;AA8EtB,IAAM,iBAAN,MAAqB;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,UAAiC,CAAC,GAAG;AAE/C,SAAK,UACH,QAAQ,WACR,QAAQ,IAAI,yBACZ;AAGF,SAAK,UAAU,KAAK,QAAQ,QAAQ,OAAO,EAAE;AAE7C,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,UAAU,QAAQ,WAAW;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,KACJ,UAKA,eACuB;AACvB,UAAM,UAAU;AAAA,MACd,UAAU,SAAS,IAAI,CAACA,QAAO;AAAA,QAC7B,IAAIA,GAAE,QAAQ;AAAA,QACd,MAAMA,GAAE;AAAA,QACR,MAAMA,GAAE;AAAA,QACR,MAAMA,GAAE;AAAA,MACV,EAAE;AAAA,IACJ;AAEA,UAAM,WAAW,MAAM,KAAK;AAAA,MAC1B;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,oBAAoB;AAAA,QACtB;AAAA,QACA,MAAM,KAAK,UAAU,OAAO;AAAA,MAC9B;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,KAAK,UAKP,C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,IAAI,MAAM,IAAI,gCAA2B,CAAC;AAClD,kBAAQ;AAAA,YACN,MAAM;AAAA,cACJ,qBAAqB,MAAM,kBAAkB,CAAC;AAAA,YAChD;AAAA,UACF;AAAA,QACF,WAAW,iBAAiB,eAAe;AACzC,kBAAQ,IAAI,MAAM,IAAI;AAAA,2BAAyB,MAAM,OAAO,EAAE,CAAC;AAAA,QACjE,OAAO;AACL,kBAAQ;AAAA,YACN,MAAM;AAAA,cACJ;AAAA,2BAAyB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,YACjF;AAAA,UACF;AAAA,QACF;AACA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAEA,EAAE,QAAM,MAAM,MAAM,gBAAgB,CAAC;AACvC;","names":["p","p"]}
package/dist/cli/index.js CHANGED
@@ -40,7 +40,7 @@ import {
40
40
  import "../chunk-3ADL5QDN.js";
41
41
  import {
42
42
  syncCommand
43
- } from "../chunk-YBRWXMVK.js";
43
+ } from "../chunk-K5O7GGHK.js";
44
44
 
45
45
  // src/cli/index.ts
46
46
  import { Command as Command7 } from "commander";
@@ -5265,7 +5265,8 @@ import * as p11 from "@clack/prompts";
5265
5265
  import * as path2 from "path";
5266
5266
  import {
5267
5267
  PatternStore,
5268
- CodeAnalyzer
5268
+ CodeAnalyzer,
5269
+ ContributorManager
5269
5270
  } from "@hawkinside_out/workflow-improvement-tracker";
5270
5271
  function getWorkspacePath() {
5271
5272
  return process.cwd();
@@ -5403,6 +5404,12 @@ async function solutionCaptureCommand(options) {
5403
5404
  const analyzer = new CodeAnalyzer({
5404
5405
  anonymize: options.anonymize ?? false
5405
5406
  });
5407
+ let isPrivate = options.private ?? false;
5408
+ if (options.private === void 0) {
5409
+ const contributorManager = new ContributorManager(cwd);
5410
+ const syncEnabled = await contributorManager.isSyncEnabled();
5411
+ isPrivate = !syncEnabled;
5412
+ }
5406
5413
  try {
5407
5414
  const pattern = await analyzer.createSolutionPattern(
5408
5415
  absolutePath,
@@ -5410,7 +5417,7 @@ async function solutionCaptureCommand(options) {
5410
5417
  description,
5411
5418
  category,
5412
5419
  keywords,
5413
- { isPrivate: options.private ?? false }
5420
+ { isPrivate }
5414
5421
  );
5415
5422
  spinner10.stop("Solution analyzed");
5416
5423
  console.log(chalk18.green("\n\u2713 Solution captured successfully!\n"));
@@ -6043,6 +6050,128 @@ async function solutionAnalyzeCommand() {
6043
6050
  console.log(chalk18.dim(" To capture a solution:"));
6044
6051
  console.log(chalk18.cyan(" workflow solution capture --path <path> --name <name>"));
6045
6052
  }
6053
+ async function solutionMigrateCommand(options) {
6054
+ const cwd = getWorkspacePath();
6055
+ const store = new PatternStore(cwd);
6056
+ await store.initialize();
6057
+ console.log(chalk18.cyan("\n\u{1F504} Migrate Solution Patterns\n"));
6058
+ if (!options.public && !options.private) {
6059
+ console.log(chalk18.yellow(" Please specify --public or --private"));
6060
+ console.log(chalk18.dim("\n Examples:"));
6061
+ console.log(chalk18.dim(" workflow solution migrate --public # Make all solutions public"));
6062
+ console.log(chalk18.dim(" workflow solution migrate --private # Make all solutions private"));
6063
+ return;
6064
+ }
6065
+ const targetPrivate = options.private ?? false;
6066
+ const targetLabel = targetPrivate ? "private" : "public";
6067
+ const result = await store.listSolutions({ limit: 1e3 });
6068
+ if (!result.success || !result.data) {
6069
+ console.log(chalk18.red(` \u2717 Failed to load solutions: ${result.error}`));
6070
+ return;
6071
+ }
6072
+ const solutions = result.data;
6073
+ const toMigrate = solutions.filter((s) => s.isPrivate !== targetPrivate);
6074
+ if (toMigrate.length === 0) {
6075
+ console.log(chalk18.green(` \u2713 All ${solutions.length} solutions are already ${targetLabel}`));
6076
+ return;
6077
+ }
6078
+ console.log(chalk18.dim(` Found ${toMigrate.length} solutions to make ${targetLabel}:
6079
+ `));
6080
+ for (const solution of toMigrate) {
6081
+ console.log(chalk18.dim(` \u2022 ${solution.name} (${solution.id.slice(0, 8)})`));
6082
+ }
6083
+ if (options.dryRun) {
6084
+ console.log(chalk18.yellow(`
6085
+ [DRY-RUN] Would migrate ${toMigrate.length} solutions to ${targetLabel}`));
6086
+ return;
6087
+ }
6088
+ const confirm10 = await p11.confirm({
6089
+ message: `Migrate ${toMigrate.length} solutions to ${targetLabel}?`,
6090
+ initialValue: true
6091
+ });
6092
+ if (p11.isCancel(confirm10) || !confirm10) {
6093
+ p11.cancel("Migration cancelled");
6094
+ return;
6095
+ }
6096
+ let migrated = 0;
6097
+ for (const solution of toMigrate) {
6098
+ const updated = {
6099
+ ...solution,
6100
+ isPrivate: targetPrivate,
6101
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
6102
+ };
6103
+ const saveResult = await store.saveSolution(updated);
6104
+ if (saveResult.success) {
6105
+ migrated++;
6106
+ }
6107
+ }
6108
+ console.log(chalk18.green(`
6109
+ \u2713 Migrated ${migrated} solutions to ${targetLabel}`));
6110
+ if (!targetPrivate) {
6111
+ console.log(chalk18.dim(" These solutions can now be synced with 'workflow sync --solutions --push'"));
6112
+ }
6113
+ }
6114
+ async function solutionEditCommand(solutionId, options) {
6115
+ const cwd = getWorkspacePath();
6116
+ const store = new PatternStore(cwd);
6117
+ await store.initialize();
6118
+ console.log(chalk18.cyan("\n\u270F\uFE0F Edit Solution Pattern\n"));
6119
+ const result = await store.getSolution(solutionId);
6120
+ if (!result.success || !result.data) {
6121
+ const allResult = await store.listSolutions({ limit: 1e3 });
6122
+ if (allResult.success && allResult.data) {
6123
+ const match = allResult.data.find((s) => s.id.startsWith(solutionId));
6124
+ if (match) {
6125
+ return solutionEditCommand(match.id, options);
6126
+ }
6127
+ }
6128
+ console.log(chalk18.red(` \u2717 Solution not found: ${solutionId}`));
6129
+ return;
6130
+ }
6131
+ const solution = result.data;
6132
+ let updated = { ...solution };
6133
+ const changes = [];
6134
+ if (options.name) {
6135
+ updated.name = options.name;
6136
+ changes.push(`name: "${options.name}"`);
6137
+ }
6138
+ if (options.description) {
6139
+ updated.description = options.description;
6140
+ changes.push(`description: "${options.description.slice(0, 30)}..."`);
6141
+ }
6142
+ if (options.public !== void 0 && options.public) {
6143
+ updated.isPrivate = false;
6144
+ changes.push("visibility: public");
6145
+ } else if (options.private !== void 0 && options.private) {
6146
+ updated.isPrivate = true;
6147
+ changes.push("visibility: private");
6148
+ }
6149
+ if (changes.length === 0) {
6150
+ console.log(chalk18.yellow(" No changes specified"));
6151
+ console.log(chalk18.dim("\n Options:"));
6152
+ console.log(chalk18.dim(" --name <name> Update name"));
6153
+ console.log(chalk18.dim(" --description <desc> Update description"));
6154
+ console.log(chalk18.dim(" --public Make public (syncable)"));
6155
+ console.log(chalk18.dim(" --private Make private"));
6156
+ return;
6157
+ }
6158
+ console.log(chalk18.dim(` Solution: ${solution.name} (${solution.id.slice(0, 8)})`));
6159
+ console.log(chalk18.dim(" Changes:"));
6160
+ for (const change of changes) {
6161
+ console.log(chalk18.dim(` \u2022 ${change}`));
6162
+ }
6163
+ updated.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
6164
+ const saveResult = await store.saveSolution(updated);
6165
+ if (saveResult.success) {
6166
+ console.log(chalk18.green("\n \u2713 Solution updated"));
6167
+ if (options.public) {
6168
+ console.log(chalk18.dim(" This solution can now be synced with 'workflow sync --solutions --push'"));
6169
+ }
6170
+ } else {
6171
+ console.log(chalk18.red(`
6172
+ \u2717 Failed to save: ${saveResult.error}`));
6173
+ }
6174
+ }
6046
6175
 
6047
6176
  // src/cli/commands/solution/index.ts
6048
6177
  function createSolutionCommand() {
@@ -6171,6 +6300,24 @@ ${chalk19.bold("Examples:")}
6171
6300
  $ workflow solution stats ${chalk19.dim("# Show all statistics")}
6172
6301
  `
6173
6302
  ).action(solutionStatsCommand);
6303
+ solutionCmd.command("migrate").description("Migrate solution patterns (make public/private)").option("--public", "Make all solutions public (syncable)").option("--private", "Make all solutions private").option("--dry-run", "Preview changes without applying").addHelpText(
6304
+ "after",
6305
+ `
6306
+ ${chalk19.bold("Examples:")}
6307
+ $ workflow solution migrate --public ${chalk19.dim("# Make all public")}
6308
+ $ workflow solution migrate --private ${chalk19.dim("# Make all private")}
6309
+ $ workflow solution migrate --public --dry-run ${chalk19.dim("# Preview changes")}
6310
+ `
6311
+ ).action(solutionMigrateCommand);
6312
+ solutionCmd.command("edit <solutionId>").description("Edit a solution pattern's properties").option("--name <name>", "Update solution name").option("--description <desc>", "Update description").option("--public", "Make solution public (syncable)").option("--private", "Make solution private").addHelpText(
6313
+ "after",
6314
+ `
6315
+ ${chalk19.bold("Examples:")}
6316
+ $ workflow solution edit abc123 --public ${chalk19.dim("# Make public")}
6317
+ $ workflow solution edit abc123 --private ${chalk19.dim("# Make private")}
6318
+ $ workflow solution edit abc123 --name "New Name" ${chalk19.dim("# Rename")}
6319
+ `
6320
+ ).action(solutionEditCommand);
6174
6321
  return solutionCmd;
6175
6322
  }
6176
6323
 
@@ -6185,7 +6332,7 @@ import * as fs2 from "fs";
6185
6332
  import * as path3 from "path";
6186
6333
  import {
6187
6334
  PatternStore as PatternStore2,
6188
- ContributorManager,
6335
+ ContributorManager as ContributorManager2,
6189
6336
  PatternAnonymizer,
6190
6337
  TelemetryCollector,
6191
6338
  FixPatternSchema,
@@ -6663,7 +6810,7 @@ async function learnApplyCommand(patternId, options) {
6663
6810
  }
6664
6811
  async function learnConfigCommand(options) {
6665
6812
  const cwd = getWorkspacePath2();
6666
- const contributorManager = new ContributorManager(cwd);
6813
+ const contributorManager = new ContributorManager2(cwd);
6667
6814
  console.log(chalk20.cyan("\n\u2699\uFE0F Learning Configuration\n"));
6668
6815
  if (options.enableSync) {
6669
6816
  const result = await contributorManager.enableSync();
@@ -7610,7 +7757,7 @@ async function learnCaptureCommand(paths, options) {
7610
7757
  }
7611
7758
  const primaryLanguage = Object.entries(languageCounts).sort((a, b) => b[1] - a[1])[0]?.[0] || "typescript";
7612
7759
  const now = (/* @__PURE__ */ new Date()).toISOString();
7613
- const contributorManager = new ContributorManager(cwd);
7760
+ const contributorManager = new ContributorManager2(cwd);
7614
7761
  const contributorResult = await contributorManager.getOrCreateId();
7615
7762
  const contributorId = contributorResult.success && contributorResult.data ? contributorResult.data : void 0;
7616
7763
  const keyFiles = files.map((f) => ({
@@ -8111,7 +8258,7 @@ ${chalk21.bold("Pro Tip:")}
8111
8258
  $ workflow sync --all ${chalk21.dim("# Sync everything")}
8112
8259
  `
8113
8260
  ).action(async (options) => {
8114
- const { syncCommand: syncCommand2 } = await import("../sync-TLICCJNH.js");
8261
+ const { syncCommand: syncCommand2 } = await import("../sync-RLFJZ5BC.js");
8115
8262
  return syncCommand2({ ...options, learn: true });
8116
8263
  });
8117
8264
  learnCmd.command("config").description("Configure learning settings").option("--enable-sync", "Enable pattern sync").option("--disable-sync", "Disable pattern sync").option("--enable-telemetry", "Enable anonymous telemetry").option("--disable-telemetry", "Disable telemetry").option("--reset-id", "Reset contributor ID").option("--show", "Show current configuration").addHelpText(
@@ -8308,7 +8455,7 @@ async function scopeRemoveCommand(name) {
8308
8455
  }
8309
8456
  async function scopeSyncCommand(options) {
8310
8457
  console.log(chalk22.bold.cyan("\n\u{1F504} Syncing Scopes\n"));
8311
- const { syncCommand: syncCommand2 } = await import("../sync-TLICCJNH.js");
8458
+ const { syncCommand: syncCommand2 } = await import("../sync-RLFJZ5BC.js");
8312
8459
  await syncCommand2({
8313
8460
  ...options,
8314
8461
  scopes: true,
@@ -8472,7 +8619,7 @@ program.addCommand(createSolutionCommand());
8472
8619
  program.addCommand(createLearnCommand());
8473
8620
  program.addCommand(createScopeCommand());
8474
8621
  program.addCommand(createHooksCommand());
8475
- program.command("sync").description("Sync patterns and solutions with the community registry").option("--push", "Push local patterns to registry").option("--pull", "Pull patterns from registry").option("--solutions", "Include solution patterns").option("--learn", "Include learning patterns (default)").option("--scopes", "Sync custom scope packages").option("--all", "Sync everything").option("--dry-run", "Preview without syncing").option("--enable-sync", "Enable pattern sync").option("--disable-sync", "Disable pattern sync").addHelpText(
8622
+ program.command("sync").description("Sync patterns and solutions with the community registry").option("--push", "Push local patterns to registry").option("--pull", "Pull patterns from registry").option("--solutions", "Include solution patterns").option("--learn", "Include learning patterns (default)").option("--scopes", "Sync custom scope packages").option("--all", "Sync everything").option("--dry-run", "Preview without syncing").option("--enable-sync", "Enable pattern sync").option("--disable-sync", "Disable pattern sync").option("--include-private", "Include private patterns in push").addHelpText(
8476
8623
  "after",
8477
8624
  `
8478
8625
  ${chalk23.bold("Examples:")}
@@ -8494,6 +8641,9 @@ ${chalk23.bold("Examples:")}
8494
8641
  ${chalk23.dim("# Sync solutions only")}
8495
8642
  $ workflow sync --solutions --push
8496
8643
 
8644
+ ${chalk23.dim("# Include private patterns in push")}
8645
+ $ workflow sync --solutions --push --include-private
8646
+
8497
8647
  ${chalk23.dim("# Preview what would be synced")}
8498
8648
  $ workflow sync --all --dry-run
8499
8649
  `