workflow-agent-cli 2.4.1 → 2.4.2
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/index.js +457 -22
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -302,10 +302,10 @@ async function initCommand(options) {
|
|
|
302
302
|
try {
|
|
303
303
|
const presetModule = await import(`@workflow/scopes-${preset}`);
|
|
304
304
|
scopes = presetModule.scopes || presetModule.default.scopes;
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
await new Promise((
|
|
308
|
-
|
|
305
|
+
const spinner6 = p.spinner();
|
|
306
|
+
spinner6.start(`Loading ${presetModule.default?.name || preset} preset`);
|
|
307
|
+
await new Promise((resolve2) => setTimeout(resolve2, 500));
|
|
308
|
+
spinner6.stop(`\u2713 Loaded ${scopes.length} scopes from preset`);
|
|
309
309
|
} catch (error) {
|
|
310
310
|
console.log(
|
|
311
311
|
chalk.yellow(
|
|
@@ -352,8 +352,8 @@ async function initCommand(options) {
|
|
|
352
352
|
process.exit(0);
|
|
353
353
|
}
|
|
354
354
|
if (shouldGenerateGuidelines) {
|
|
355
|
-
const
|
|
356
|
-
|
|
355
|
+
const spinner6 = p.spinner();
|
|
356
|
+
spinner6.start("Generating guidelines...");
|
|
357
357
|
try {
|
|
358
358
|
const templatesDir = join(__dirname, "../../templates");
|
|
359
359
|
await validateTemplateDirectory(templatesDir);
|
|
@@ -365,9 +365,9 @@ async function initCommand(options) {
|
|
|
365
365
|
guidelinesDir,
|
|
366
366
|
context
|
|
367
367
|
);
|
|
368
|
-
|
|
368
|
+
spinner6.stop(`\u2713 Generated ${renderedFiles.length} guideline documents`);
|
|
369
369
|
} catch (error) {
|
|
370
|
-
|
|
370
|
+
spinner6.stop("\u26A0\uFE0F Could not generate guidelines");
|
|
371
371
|
console.log(
|
|
372
372
|
chalk.yellow(
|
|
373
373
|
`
|
|
@@ -837,8 +837,8 @@ async function scopeCreateCommand(options) {
|
|
|
837
837
|
process.exit(0);
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
const
|
|
841
|
-
|
|
840
|
+
const spinner6 = p4.spinner();
|
|
841
|
+
spinner6.start("Creating package structure...");
|
|
842
842
|
try {
|
|
843
843
|
await mkdir2(join3(outputDir, "src"), { recursive: true });
|
|
844
844
|
const packageJson = {
|
|
@@ -969,7 +969,7 @@ describe('${presetName} Scope Preset', () => {
|
|
|
969
969
|
"utf-8"
|
|
970
970
|
);
|
|
971
971
|
}
|
|
972
|
-
|
|
972
|
+
spinner6.stop("\u2713 Package structure created");
|
|
973
973
|
if (isMonorepo) {
|
|
974
974
|
const workspaceFile = join3(cwd, "pnpm-workspace.yaml");
|
|
975
975
|
const workspaceContent = await readFile(workspaceFile, "utf-8");
|
|
@@ -1021,7 +1021,7 @@ describe('${presetName} Scope Preset', () => {
|
|
|
1021
1021
|
);
|
|
1022
1022
|
}
|
|
1023
1023
|
} catch (error) {
|
|
1024
|
-
|
|
1024
|
+
spinner6.stop("\u2717 Failed to create package");
|
|
1025
1025
|
console.error(chalk7.red("\nError:"), error);
|
|
1026
1026
|
process.exit(1);
|
|
1027
1027
|
}
|
|
@@ -1149,8 +1149,8 @@ async function scopeMigrateCommand(options) {
|
|
|
1149
1149
|
process.exit(0);
|
|
1150
1150
|
}
|
|
1151
1151
|
}
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1152
|
+
const spinner6 = p5.spinner();
|
|
1153
|
+
spinner6.start("Migrating scopes to package...");
|
|
1154
1154
|
try {
|
|
1155
1155
|
await mkdir3(join4(outputDir, "src"), { recursive: true });
|
|
1156
1156
|
const packageJson = {
|
|
@@ -1278,7 +1278,7 @@ describe('${presetName} Scope Preset (Migrated)', () => {
|
|
|
1278
1278
|
});
|
|
1279
1279
|
`;
|
|
1280
1280
|
await writeFile3(join4(outputDir, "src", "index.test.ts"), testFile, "utf-8");
|
|
1281
|
-
|
|
1281
|
+
spinner6.stop("\u2713 Package created from migrated scopes");
|
|
1282
1282
|
if (isMonorepo) {
|
|
1283
1283
|
const workspaceFile = join4(cwd, "pnpm-workspace.yaml");
|
|
1284
1284
|
const workspaceContent = await readFile2(workspaceFile, "utf-8");
|
|
@@ -1350,7 +1350,7 @@ describe('${presetName} Scope Preset (Migrated)', () => {
|
|
|
1350
1350
|
)
|
|
1351
1351
|
);
|
|
1352
1352
|
} catch (error) {
|
|
1353
|
-
|
|
1353
|
+
spinner6.stop("\u2717 Migration failed");
|
|
1354
1354
|
console.error(chalk8.red("\nError:"), error);
|
|
1355
1355
|
process.exit(1);
|
|
1356
1356
|
}
|
|
@@ -1464,8 +1464,8 @@ async function recordSuccessfulFixes(cwd, result) {
|
|
|
1464
1464
|
let frameworkVersion = "0.0.0";
|
|
1465
1465
|
try {
|
|
1466
1466
|
const fs2 = await import("fs");
|
|
1467
|
-
const
|
|
1468
|
-
const packageJsonPath =
|
|
1467
|
+
const path3 = await import("path");
|
|
1468
|
+
const packageJsonPath = path3.join(cwd, "package.json");
|
|
1469
1469
|
const packageJson = JSON.parse(
|
|
1470
1470
|
await fs2.promises.readFile(packageJsonPath, "utf-8")
|
|
1471
1471
|
);
|
|
@@ -1584,14 +1584,14 @@ import chalk10 from "chalk";
|
|
|
1584
1584
|
async function autoSetupCommand(options) {
|
|
1585
1585
|
console.log(chalk10.bold.cyan("\n\u{1F527} Workflow Agent Auto-Setup\n"));
|
|
1586
1586
|
const cwd = process.cwd();
|
|
1587
|
-
const
|
|
1588
|
-
|
|
1587
|
+
const spinner6 = p6.spinner();
|
|
1588
|
+
spinner6.start("Analyzing project...");
|
|
1589
1589
|
let report;
|
|
1590
1590
|
try {
|
|
1591
1591
|
report = await generateAuditReport(cwd);
|
|
1592
|
-
|
|
1592
|
+
spinner6.stop("\u2713 Project analysis complete");
|
|
1593
1593
|
} catch (error) {
|
|
1594
|
-
|
|
1594
|
+
spinner6.stop("\u2717 Failed to analyze project");
|
|
1595
1595
|
console.error(
|
|
1596
1596
|
chalk10.red(
|
|
1597
1597
|
`Error: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -2314,6 +2314,435 @@ async function learnStatsCommand() {
|
|
|
2314
2314
|
console.log("");
|
|
2315
2315
|
}
|
|
2316
2316
|
|
|
2317
|
+
// src/cli/commands/solution.ts
|
|
2318
|
+
import chalk12 from "chalk";
|
|
2319
|
+
import * as p8 from "@clack/prompts";
|
|
2320
|
+
import * as path2 from "path";
|
|
2321
|
+
import {
|
|
2322
|
+
PatternStore as PatternStore3,
|
|
2323
|
+
CodeAnalyzer
|
|
2324
|
+
} from "@hawkinside_out/workflow-improvement-tracker";
|
|
2325
|
+
function getWorkspacePath2() {
|
|
2326
|
+
return process.cwd();
|
|
2327
|
+
}
|
|
2328
|
+
function formatDate2(isoString) {
|
|
2329
|
+
return new Date(isoString).toLocaleDateString("en-US", {
|
|
2330
|
+
year: "numeric",
|
|
2331
|
+
month: "short",
|
|
2332
|
+
day: "numeric"
|
|
2333
|
+
});
|
|
2334
|
+
}
|
|
2335
|
+
function formatCategory(category) {
|
|
2336
|
+
const icons = {
|
|
2337
|
+
auth: "\u{1F510}",
|
|
2338
|
+
api: "\u{1F310}",
|
|
2339
|
+
database: "\u{1F4BE}",
|
|
2340
|
+
ui: "\u{1F3A8}",
|
|
2341
|
+
testing: "\u{1F9EA}",
|
|
2342
|
+
deployment: "\u{1F680}",
|
|
2343
|
+
integrations: "\u{1F517}",
|
|
2344
|
+
performance: "\u26A1",
|
|
2345
|
+
security: "\u{1F6E1}\uFE0F",
|
|
2346
|
+
other: "\u{1F4E6}",
|
|
2347
|
+
state: "\u{1F504}",
|
|
2348
|
+
forms: "\u{1F4DD}",
|
|
2349
|
+
"error-handling": "\u26A0\uFE0F",
|
|
2350
|
+
caching: "\u{1F4A8}"
|
|
2351
|
+
};
|
|
2352
|
+
return `${icons[category]} ${category}`;
|
|
2353
|
+
}
|
|
2354
|
+
function truncate(str, maxLen) {
|
|
2355
|
+
if (str.length <= maxLen) return str;
|
|
2356
|
+
return str.slice(0, maxLen - 3) + "...";
|
|
2357
|
+
}
|
|
2358
|
+
async function solutionCaptureCommand(options) {
|
|
2359
|
+
const cwd = getWorkspacePath2();
|
|
2360
|
+
const store = new PatternStore3(cwd);
|
|
2361
|
+
console.log(chalk12.cyan("\n\u{1F4E6} Capture Solution Pattern\n"));
|
|
2362
|
+
let targetPath = options.path;
|
|
2363
|
+
if (!targetPath) {
|
|
2364
|
+
const pathInput = await p8.text({
|
|
2365
|
+
message: "Path to the solution directory:",
|
|
2366
|
+
placeholder: "./src/auth",
|
|
2367
|
+
validate: (val) => {
|
|
2368
|
+
if (!val) return "Path is required";
|
|
2369
|
+
return void 0;
|
|
2370
|
+
}
|
|
2371
|
+
});
|
|
2372
|
+
if (p8.isCancel(pathInput)) {
|
|
2373
|
+
p8.cancel("Operation cancelled");
|
|
2374
|
+
process.exit(0);
|
|
2375
|
+
}
|
|
2376
|
+
targetPath = pathInput;
|
|
2377
|
+
}
|
|
2378
|
+
const absolutePath = path2.isAbsolute(targetPath) ? targetPath : path2.resolve(cwd, targetPath);
|
|
2379
|
+
let name = options.name;
|
|
2380
|
+
if (!name) {
|
|
2381
|
+
const nameInput = await p8.text({
|
|
2382
|
+
message: "Solution name:",
|
|
2383
|
+
placeholder: "JWT Authentication",
|
|
2384
|
+
validate: (val) => {
|
|
2385
|
+
if (!val || val.length < 3) return "Name must be at least 3 characters";
|
|
2386
|
+
return void 0;
|
|
2387
|
+
}
|
|
2388
|
+
});
|
|
2389
|
+
if (p8.isCancel(nameInput)) {
|
|
2390
|
+
p8.cancel("Operation cancelled");
|
|
2391
|
+
process.exit(0);
|
|
2392
|
+
}
|
|
2393
|
+
name = nameInput;
|
|
2394
|
+
}
|
|
2395
|
+
let description = options.description;
|
|
2396
|
+
if (!description) {
|
|
2397
|
+
const descInput = await p8.text({
|
|
2398
|
+
message: "Solution description:",
|
|
2399
|
+
placeholder: "Complete JWT-based authentication with refresh tokens",
|
|
2400
|
+
validate: (val) => {
|
|
2401
|
+
if (!val || val.length < 10)
|
|
2402
|
+
return "Description must be at least 10 characters";
|
|
2403
|
+
return void 0;
|
|
2404
|
+
}
|
|
2405
|
+
});
|
|
2406
|
+
if (p8.isCancel(descInput)) {
|
|
2407
|
+
p8.cancel("Operation cancelled");
|
|
2408
|
+
process.exit(0);
|
|
2409
|
+
}
|
|
2410
|
+
description = descInput;
|
|
2411
|
+
}
|
|
2412
|
+
let category = options.category;
|
|
2413
|
+
if (!category) {
|
|
2414
|
+
const categoryChoice = await p8.select({
|
|
2415
|
+
message: "Solution category:",
|
|
2416
|
+
options: [
|
|
2417
|
+
{ value: "auth", label: "\u{1F510} Authentication" },
|
|
2418
|
+
{ value: "api", label: "\u{1F310} API" },
|
|
2419
|
+
{ value: "database", label: "\u{1F4BE} Database" },
|
|
2420
|
+
{ value: "ui", label: "\u{1F3A8} UI/Components" },
|
|
2421
|
+
{ value: "testing", label: "\u{1F9EA} Testing" },
|
|
2422
|
+
{ value: "deployment", label: "\u{1F680} Deployment" },
|
|
2423
|
+
{ value: "integrations", label: "\u{1F517} Integrations" },
|
|
2424
|
+
{ value: "performance", label: "\u26A1 Performance" },
|
|
2425
|
+
{ value: "security", label: "\u{1F6E1}\uFE0F Security" },
|
|
2426
|
+
{ value: "state", label: "\u{1F504} State Management" },
|
|
2427
|
+
{ value: "forms", label: "\u{1F4DD} Forms" },
|
|
2428
|
+
{ value: "error-handling", label: "\u26A0\uFE0F Error Handling" },
|
|
2429
|
+
{ value: "caching", label: "\u{1F4A8} Caching" },
|
|
2430
|
+
{ value: "other", label: "\u{1F4E6} Other" }
|
|
2431
|
+
]
|
|
2432
|
+
});
|
|
2433
|
+
if (p8.isCancel(categoryChoice)) {
|
|
2434
|
+
p8.cancel("Operation cancelled");
|
|
2435
|
+
process.exit(0);
|
|
2436
|
+
}
|
|
2437
|
+
category = categoryChoice;
|
|
2438
|
+
}
|
|
2439
|
+
let keywords = [];
|
|
2440
|
+
if (options.keywords) {
|
|
2441
|
+
keywords = options.keywords.split(",").map((k) => k.trim());
|
|
2442
|
+
} else {
|
|
2443
|
+
const keywordsInput = await p8.text({
|
|
2444
|
+
message: "Keywords (comma-separated):",
|
|
2445
|
+
placeholder: "jwt, authentication, login, refresh-token"
|
|
2446
|
+
});
|
|
2447
|
+
if (p8.isCancel(keywordsInput)) {
|
|
2448
|
+
p8.cancel("Operation cancelled");
|
|
2449
|
+
process.exit(0);
|
|
2450
|
+
}
|
|
2451
|
+
if (keywordsInput) {
|
|
2452
|
+
keywords = keywordsInput.split(",").map((k) => k.trim());
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
const spinner6 = p8.spinner();
|
|
2456
|
+
spinner6.start("Analyzing solution...");
|
|
2457
|
+
const analyzer = new CodeAnalyzer({
|
|
2458
|
+
anonymize: options.anonymize ?? false
|
|
2459
|
+
});
|
|
2460
|
+
try {
|
|
2461
|
+
const pattern = await analyzer.createSolutionPattern(
|
|
2462
|
+
absolutePath,
|
|
2463
|
+
name,
|
|
2464
|
+
description,
|
|
2465
|
+
category,
|
|
2466
|
+
keywords
|
|
2467
|
+
);
|
|
2468
|
+
spinner6.stop("Solution analyzed");
|
|
2469
|
+
console.log(chalk12.green("\n\u2713 Solution captured successfully!\n"));
|
|
2470
|
+
console.log(chalk12.dim("\u2500".repeat(50)));
|
|
2471
|
+
console.log(`${chalk12.bold("Name:")} ${pattern.name}`);
|
|
2472
|
+
console.log(`${chalk12.bold("Category:")} ${formatCategory(pattern.category)}`);
|
|
2473
|
+
console.log(`${chalk12.bold("Files:")} ${pattern.implementation.files.length}`);
|
|
2474
|
+
console.log(
|
|
2475
|
+
`${chalk12.bold("Dependencies:")} ${pattern.implementation.dependencies.length}`
|
|
2476
|
+
);
|
|
2477
|
+
console.log(
|
|
2478
|
+
`${chalk12.bold("Framework:")} ${pattern.compatibility.framework || "generic"}`
|
|
2479
|
+
);
|
|
2480
|
+
console.log(chalk12.dim("\u2500".repeat(50)));
|
|
2481
|
+
const confirm8 = await p8.confirm({
|
|
2482
|
+
message: "Save this solution pattern?",
|
|
2483
|
+
initialValue: true
|
|
2484
|
+
});
|
|
2485
|
+
if (p8.isCancel(confirm8) || !confirm8) {
|
|
2486
|
+
p8.cancel("Solution not saved");
|
|
2487
|
+
process.exit(0);
|
|
2488
|
+
}
|
|
2489
|
+
await store.saveSolution(pattern);
|
|
2490
|
+
console.log(chalk12.green(`
|
|
2491
|
+
\u2713 Solution saved with ID: ${pattern.id}
|
|
2492
|
+
`));
|
|
2493
|
+
} catch (error) {
|
|
2494
|
+
spinner6.stop("Analysis failed");
|
|
2495
|
+
console.error(chalk12.red(`
|
|
2496
|
+
\u2717 Error: ${error.message}
|
|
2497
|
+
`));
|
|
2498
|
+
process.exit(1);
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
async function solutionSearchCommand(query, options) {
|
|
2502
|
+
const cwd = getWorkspacePath2();
|
|
2503
|
+
const store = new PatternStore3(cwd);
|
|
2504
|
+
console.log(chalk12.cyan("\n\u{1F50D} Search Solution Patterns\n"));
|
|
2505
|
+
const keywords = query.split(/\s+/).filter((k) => k.length > 0);
|
|
2506
|
+
const result = await store.searchSolutions(keywords, {
|
|
2507
|
+
category: options.category,
|
|
2508
|
+
framework: options.framework,
|
|
2509
|
+
limit: options.limit ?? 10
|
|
2510
|
+
});
|
|
2511
|
+
if (!result.success || !result.data) {
|
|
2512
|
+
console.error(chalk12.red(`
|
|
2513
|
+
\u2717 Search failed: ${result.error}
|
|
2514
|
+
`));
|
|
2515
|
+
return;
|
|
2516
|
+
}
|
|
2517
|
+
const solutions = result.data;
|
|
2518
|
+
if (solutions.length === 0) {
|
|
2519
|
+
console.log(chalk12.yellow("No solutions found matching your query.\n"));
|
|
2520
|
+
console.log(chalk12.dim("Try different keywords or fewer filters."));
|
|
2521
|
+
return;
|
|
2522
|
+
}
|
|
2523
|
+
console.log(chalk12.green(`Found ${solutions.length} solution(s):
|
|
2524
|
+
`));
|
|
2525
|
+
console.log(chalk12.dim("\u2500".repeat(70)));
|
|
2526
|
+
for (const solution of solutions) {
|
|
2527
|
+
console.log(
|
|
2528
|
+
`${chalk12.bold(solution.name)} ${chalk12.dim(`(${solution.id.slice(0, 8)})`)}`
|
|
2529
|
+
);
|
|
2530
|
+
console.log(` ${formatCategory(solution.category)}`);
|
|
2531
|
+
console.log(` ${chalk12.dim(truncate(solution.description, 60))}`);
|
|
2532
|
+
console.log(
|
|
2533
|
+
` Files: ${solution.implementation.files.length} | Framework: ${solution.compatibility.framework || "generic"} | Uses: ${solution.metrics.applications}`
|
|
2534
|
+
);
|
|
2535
|
+
console.log(chalk12.dim("\u2500".repeat(70)));
|
|
2536
|
+
}
|
|
2537
|
+
console.log(chalk12.dim("\nUse 'workflow solution:apply <id>' to apply a solution."));
|
|
2538
|
+
}
|
|
2539
|
+
async function solutionListCommand(options) {
|
|
2540
|
+
const cwd = getWorkspacePath2();
|
|
2541
|
+
const store = new PatternStore3(cwd);
|
|
2542
|
+
console.log(chalk12.cyan("\n\u{1F4CB} Solution Patterns\n"));
|
|
2543
|
+
const result = await store.listSolutions({
|
|
2544
|
+
category: options.category,
|
|
2545
|
+
framework: options.framework,
|
|
2546
|
+
includeDeprecated: options.deprecated ?? false,
|
|
2547
|
+
limit: options.limit ?? 20
|
|
2548
|
+
});
|
|
2549
|
+
if (!result.success || !result.data) {
|
|
2550
|
+
console.error(chalk12.red(`
|
|
2551
|
+
\u2717 List failed: ${result.error}
|
|
2552
|
+
`));
|
|
2553
|
+
return;
|
|
2554
|
+
}
|
|
2555
|
+
const solutions = result.data;
|
|
2556
|
+
if (solutions.length === 0) {
|
|
2557
|
+
console.log(chalk12.yellow("No solutions found.\n"));
|
|
2558
|
+
console.log(chalk12.dim("Use 'workflow solution:capture' to capture a solution."));
|
|
2559
|
+
return;
|
|
2560
|
+
}
|
|
2561
|
+
console.log(chalk12.green(`${solutions.length} solution(s):
|
|
2562
|
+
`));
|
|
2563
|
+
const byCategory = /* @__PURE__ */ new Map();
|
|
2564
|
+
for (const solution of solutions) {
|
|
2565
|
+
const list = byCategory.get(solution.category) || [];
|
|
2566
|
+
list.push(solution);
|
|
2567
|
+
byCategory.set(solution.category, list);
|
|
2568
|
+
}
|
|
2569
|
+
for (const [category, items] of byCategory) {
|
|
2570
|
+
console.log(chalk12.bold(`
|
|
2571
|
+
${formatCategory(category)}`));
|
|
2572
|
+
console.log(chalk12.dim("\u2500".repeat(50)));
|
|
2573
|
+
for (const solution of items) {
|
|
2574
|
+
const deprecated = solution.deprecatedAt ? chalk12.red(" [DEPRECATED]") : "";
|
|
2575
|
+
console.log(
|
|
2576
|
+
` ${chalk12.cyan(solution.id.slice(0, 8))} ${solution.name}${deprecated}`
|
|
2577
|
+
);
|
|
2578
|
+
console.log(` ${chalk12.dim(truncate(solution.description, 50))}`);
|
|
2579
|
+
console.log(
|
|
2580
|
+
chalk12.dim(
|
|
2581
|
+
` Created: ${formatDate2(solution.createdAt)} | Files: ${solution.implementation.files.length}`
|
|
2582
|
+
)
|
|
2583
|
+
);
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
console.log(
|
|
2587
|
+
chalk12.dim("\nUse 'workflow solution:search <query>' to find specific solutions.")
|
|
2588
|
+
);
|
|
2589
|
+
}
|
|
2590
|
+
async function solutionApplyCommand(solutionId, options) {
|
|
2591
|
+
const cwd = getWorkspacePath2();
|
|
2592
|
+
const store = new PatternStore3(cwd);
|
|
2593
|
+
console.log(chalk12.cyan("\n\u{1F680} Apply Solution Pattern\n"));
|
|
2594
|
+
const result = await store.getSolution(solutionId);
|
|
2595
|
+
if (!result.success || !result.data) {
|
|
2596
|
+
console.error(chalk12.red(`
|
|
2597
|
+
\u2717 Solution not found: ${solutionId}
|
|
2598
|
+
`));
|
|
2599
|
+
process.exit(1);
|
|
2600
|
+
}
|
|
2601
|
+
const solution = result.data;
|
|
2602
|
+
if (solution.deprecatedAt) {
|
|
2603
|
+
console.log(
|
|
2604
|
+
chalk12.yellow(
|
|
2605
|
+
`\u26A0\uFE0F This solution is deprecated: ${solution.deprecationReason || "No reason provided"}
|
|
2606
|
+
`
|
|
2607
|
+
)
|
|
2608
|
+
);
|
|
2609
|
+
const proceed = await p8.confirm({
|
|
2610
|
+
message: "Do you want to continue?",
|
|
2611
|
+
initialValue: false
|
|
2612
|
+
});
|
|
2613
|
+
if (p8.isCancel(proceed) || !proceed) {
|
|
2614
|
+
p8.cancel("Operation cancelled");
|
|
2615
|
+
process.exit(0);
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
console.log(chalk12.bold(`Solution: ${solution.name}`));
|
|
2619
|
+
console.log(chalk12.dim(solution.description));
|
|
2620
|
+
console.log();
|
|
2621
|
+
console.log(chalk12.bold("Files to create:"));
|
|
2622
|
+
const filesToApply = options.includeTests ? solution.implementation.files : solution.implementation.files.filter((f) => f.role !== "test");
|
|
2623
|
+
for (const file of filesToApply) {
|
|
2624
|
+
console.log(chalk12.dim(` \u2022 ${file.path} (${file.role})`));
|
|
2625
|
+
}
|
|
2626
|
+
console.log();
|
|
2627
|
+
if (solution.implementation.dependencies.length > 0) {
|
|
2628
|
+
console.log(chalk12.bold("Dependencies to install:"));
|
|
2629
|
+
for (const dep of solution.implementation.dependencies) {
|
|
2630
|
+
console.log(chalk12.dim(` \u2022 ${dep.name}@${dep.version}`));
|
|
2631
|
+
}
|
|
2632
|
+
console.log();
|
|
2633
|
+
}
|
|
2634
|
+
if (solution.implementation.envVars.length > 0) {
|
|
2635
|
+
console.log(chalk12.bold("Environment variables needed:"));
|
|
2636
|
+
for (const env of solution.implementation.envVars) {
|
|
2637
|
+
const required = env.required ? chalk12.red("*") : "";
|
|
2638
|
+
console.log(chalk12.dim(` \u2022 ${env.name}${required}`));
|
|
2639
|
+
}
|
|
2640
|
+
console.log();
|
|
2641
|
+
}
|
|
2642
|
+
if (options.dryRun) {
|
|
2643
|
+
console.log(chalk12.yellow("Dry run mode - no files were created.\n"));
|
|
2644
|
+
return;
|
|
2645
|
+
}
|
|
2646
|
+
const confirm8 = await p8.confirm({
|
|
2647
|
+
message: "Apply this solution?",
|
|
2648
|
+
initialValue: true
|
|
2649
|
+
});
|
|
2650
|
+
if (p8.isCancel(confirm8) || !confirm8) {
|
|
2651
|
+
p8.cancel("Operation cancelled");
|
|
2652
|
+
process.exit(0);
|
|
2653
|
+
}
|
|
2654
|
+
const spinner6 = p8.spinner();
|
|
2655
|
+
spinner6.start("Applying solution...");
|
|
2656
|
+
try {
|
|
2657
|
+
const outputDir = options.output || cwd;
|
|
2658
|
+
const fs2 = await import("fs");
|
|
2659
|
+
const pathModule = await import("path");
|
|
2660
|
+
for (const file of filesToApply) {
|
|
2661
|
+
const filePath = pathModule.join(outputDir, file.path);
|
|
2662
|
+
const dir = pathModule.dirname(filePath);
|
|
2663
|
+
await fs2.promises.mkdir(dir, { recursive: true });
|
|
2664
|
+
await fs2.promises.writeFile(filePath, file.content);
|
|
2665
|
+
}
|
|
2666
|
+
await store.updateSolutionMetrics(solution.id, true);
|
|
2667
|
+
spinner6.stop("Solution applied");
|
|
2668
|
+
console.log(chalk12.green(`
|
|
2669
|
+
\u2713 Solution applied successfully!
|
|
2670
|
+
`));
|
|
2671
|
+
console.log(chalk12.dim(`Created ${filesToApply.length} file(s).`));
|
|
2672
|
+
if (solution.implementation.dependencies.length > 0) {
|
|
2673
|
+
console.log(
|
|
2674
|
+
chalk12.cyan("\nNext step: Install dependencies with:")
|
|
2675
|
+
);
|
|
2676
|
+
const deps = solution.implementation.dependencies.map((d) => `${d.name}@${d.version}`).join(" ");
|
|
2677
|
+
console.log(chalk12.dim(` npm install ${deps}`));
|
|
2678
|
+
}
|
|
2679
|
+
} catch (error) {
|
|
2680
|
+
spinner6.stop("Application failed");
|
|
2681
|
+
await store.updateSolutionMetrics(solution.id, false);
|
|
2682
|
+
console.error(chalk12.red(`
|
|
2683
|
+
\u2717 Error: ${error.message}
|
|
2684
|
+
`));
|
|
2685
|
+
process.exit(1);
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
async function solutionDeprecateCommand(solutionId, reason) {
|
|
2689
|
+
const cwd = getWorkspacePath2();
|
|
2690
|
+
const store = new PatternStore3(cwd);
|
|
2691
|
+
console.log(chalk12.cyan("\n\u26A0\uFE0F Deprecate Solution Pattern\n"));
|
|
2692
|
+
const result = await store.getSolution(solutionId);
|
|
2693
|
+
if (!result.success || !result.data) {
|
|
2694
|
+
console.error(chalk12.red(`
|
|
2695
|
+
\u2717 Solution not found: ${solutionId}
|
|
2696
|
+
`));
|
|
2697
|
+
process.exit(1);
|
|
2698
|
+
}
|
|
2699
|
+
const solution = result.data;
|
|
2700
|
+
console.log(`Solution: ${chalk12.bold(solution.name)}`);
|
|
2701
|
+
console.log(`Reason: ${reason}
|
|
2702
|
+
`);
|
|
2703
|
+
const confirm8 = await p8.confirm({
|
|
2704
|
+
message: "Deprecate this solution?",
|
|
2705
|
+
initialValue: false
|
|
2706
|
+
});
|
|
2707
|
+
if (p8.isCancel(confirm8) || !confirm8) {
|
|
2708
|
+
p8.cancel("Operation cancelled");
|
|
2709
|
+
process.exit(0);
|
|
2710
|
+
}
|
|
2711
|
+
await store.deprecateSolution(solutionId, reason);
|
|
2712
|
+
console.log(chalk12.green(`
|
|
2713
|
+
\u2713 Solution deprecated.
|
|
2714
|
+
`));
|
|
2715
|
+
}
|
|
2716
|
+
async function solutionStatsCommand() {
|
|
2717
|
+
const cwd = getWorkspacePath2();
|
|
2718
|
+
const store = new PatternStore3(cwd);
|
|
2719
|
+
console.log(chalk12.cyan("\n\u{1F4CA} Solution Pattern Statistics\n"));
|
|
2720
|
+
const stats = await store.getStats();
|
|
2721
|
+
console.log(chalk12.dim("\u2500".repeat(40)));
|
|
2722
|
+
console.log(`${chalk12.bold("Solutions:")} ${stats.totalSolutions}`);
|
|
2723
|
+
console.log(` Active: ${stats.totalSolutions - stats.deprecatedSolutions}`);
|
|
2724
|
+
console.log(` Deprecated: ${stats.deprecatedSolutions}`);
|
|
2725
|
+
console.log(` Private: ${stats.privateSolutions}`);
|
|
2726
|
+
console.log(` Synced: ${stats.syncedSolutions}`);
|
|
2727
|
+
console.log(chalk12.dim("\u2500".repeat(40)));
|
|
2728
|
+
console.log(`${chalk12.bold("Fixes:")} ${stats.totalFixes}`);
|
|
2729
|
+
console.log(`${chalk12.bold("Blueprints:")} ${stats.totalBlueprints}`);
|
|
2730
|
+
console.log(chalk12.dim("\u2500".repeat(40)));
|
|
2731
|
+
console.log(`
|
|
2732
|
+
${chalk12.bold("By Category:")}`);
|
|
2733
|
+
const listResult = await store.listSolutions({ limit: 1e3 });
|
|
2734
|
+
if (listResult.success && listResult.data) {
|
|
2735
|
+
const categories = /* @__PURE__ */ new Map();
|
|
2736
|
+
for (const s of listResult.data) {
|
|
2737
|
+
categories.set(s.category, (categories.get(s.category) || 0) + 1);
|
|
2738
|
+
}
|
|
2739
|
+
for (const [category, count] of categories) {
|
|
2740
|
+
console.log(` ${formatCategory(category)}: ${count}`);
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
console.log();
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2317
2746
|
// src/cli/index.ts
|
|
2318
2747
|
var program = new Command();
|
|
2319
2748
|
program.name("workflow").description(
|
|
@@ -2351,5 +2780,11 @@ program.command("learn:sync").description("Sync patterns with remote registry").
|
|
|
2351
2780
|
program.command("learn: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").action(learnConfigCommand);
|
|
2352
2781
|
program.command("learn:deprecate <patternId> <reason>").description("Deprecate an outdated pattern").argument("<patternId>", "Pattern ID to deprecate").argument("<reason>", "Reason for deprecation").action(learnDeprecateCommand);
|
|
2353
2782
|
program.command("learn:stats").description("Show learning statistics").action(learnStatsCommand);
|
|
2783
|
+
program.command("solution:capture").description("Capture a solution pattern from working code").option("--name <name>", "Solution name").option("--description <desc>", "Solution description").option("--category <cat>", "Category (auth, api, database, ui, testing, deployment, integration, performance, security, other)").option("--keywords <kw>", "Comma-separated keywords").option("--path <path>", "Path to the solution directory").option("--anonymize", "Anonymize sensitive data in code").action(solutionCaptureCommand);
|
|
2784
|
+
program.command("solution:search <query>").description("Search for solution patterns").argument("<query>", "Search query (keywords, problem description)").option("--category <cat>", "Filter by category").option("--framework <fw>", "Filter by framework").option("--limit <n>", "Maximum results", "10").action(solutionSearchCommand);
|
|
2785
|
+
program.command("solution:list").description("List all solution patterns").option("--category <cat>", "Filter by category").option("--framework <fw>", "Filter by framework").option("--deprecated", "Include deprecated solutions").option("--limit <n>", "Maximum results", "20").action(solutionListCommand);
|
|
2786
|
+
program.command("solution:apply <solutionId>").description("Apply a solution pattern to the current project").argument("<solutionId>", "Solution ID to apply").option("--output <dir>", "Output directory").option("--dry-run", "Preview without applying").option("--include-tests", "Include test files").action(solutionApplyCommand);
|
|
2787
|
+
program.command("solution:deprecate <solutionId> <reason>").description("Deprecate a solution pattern").argument("<solutionId>", "Solution ID to deprecate").argument("<reason>", "Reason for deprecation").action(solutionDeprecateCommand);
|
|
2788
|
+
program.command("solution:stats").description("Show solution pattern statistics").action(solutionStatsCommand);
|
|
2354
2789
|
program.parse();
|
|
2355
2790
|
//# sourceMappingURL=index.js.map
|