workflow-agent-cli 2.21.2 → 2.22.1

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 CHANGED
@@ -20,8 +20,6 @@ import {
20
20
  } from "../chunk-UWJ2ZGEI.js";
21
21
  import {
22
22
  DEPRECATED_SCRIPTS,
23
- SCRIPT_CATEGORIES,
24
- TOTAL_SCRIPTS,
25
23
  WORKFLOW_SCRIPTS,
26
24
  WORKFLOW_SCRIPTS_VERSION,
27
25
  findTemplatesDirectory,
@@ -29,8 +27,9 @@ import {
29
27
  getMandatoryTemplateFilenames,
30
28
  installMandatoryTemplates,
31
29
  templateMetadata,
32
- updateTemplates
33
- } from "../chunk-YR2X64TH.js";
30
+ updateTemplates,
31
+ validateAllScripts
32
+ } from "../chunk-WR3AL26Z.js";
34
33
  import {
35
34
  autoFixConfigFile,
36
35
  validateScopeDefinitions
@@ -46,6 +45,9 @@ import {
46
45
  // src/cli/index.ts
47
46
  import { Command as Command7 } from "commander";
48
47
  import chalk23 from "chalk";
48
+ import { readFileSync as readFileSync3 } from "fs";
49
+ import { fileURLToPath as fileURLToPath4 } from "url";
50
+ import { dirname as dirname5, join as join12 } from "path";
49
51
 
50
52
  // src/cli/commands/init.ts
51
53
  import * as p from "@clack/prompts";
@@ -925,91 +927,82 @@ async function setupCommand() {
925
927
  process.exit(1);
926
928
  }
927
929
  const packageJsonContent = readFileSync(packageJsonPath, "utf-8");
928
- const packageJson = JSON.parse(packageJsonContent);
929
- if (!packageJson.scripts) {
930
- packageJson.scripts = {};
930
+ const packageJson2 = JSON.parse(packageJsonContent);
931
+ if (!packageJson2.scripts) {
932
+ packageJson2.scripts = {};
931
933
  }
932
- const addedScripts = [];
933
- const updatedScripts = [];
934
+ let scriptAdded = false;
935
+ let scriptUpdated = false;
934
936
  const removedScripts = [];
935
937
  for (const deprecatedScript of DEPRECATED_SCRIPTS) {
936
- if (packageJson.scripts[deprecatedScript] !== void 0) {
937
- delete packageJson.scripts[deprecatedScript];
938
+ if (packageJson2.scripts[deprecatedScript] !== void 0) {
939
+ delete packageJson2.scripts[deprecatedScript];
938
940
  removedScripts.push(deprecatedScript);
939
941
  }
940
942
  }
941
- for (const [scriptName, scriptCommand] of Object.entries(WORKFLOW_SCRIPTS)) {
942
- if (!packageJson.scripts[scriptName]) {
943
- packageJson.scripts[scriptName] = scriptCommand;
944
- addedScripts.push(scriptName);
945
- } else if (packageJson.scripts[scriptName] !== scriptCommand) {
946
- packageJson.scripts[scriptName] = scriptCommand;
947
- updatedScripts.push(scriptName);
943
+ const oldScripts = validateAllScripts(packageJson2.scripts);
944
+ for (const oldScript of oldScripts) {
945
+ if (packageJson2.scripts[oldScript] !== void 0) {
946
+ delete packageJson2.scripts[oldScript];
947
+ if (!removedScripts.includes(oldScript)) {
948
+ removedScripts.push(oldScript);
949
+ }
948
950
  }
949
951
  }
950
- const totalChanges = addedScripts.length + updatedScripts.length + removedScripts.length;
951
- if (totalChanges === 0) {
952
+ const scriptName = "workflow";
953
+ const scriptCommand = WORKFLOW_SCRIPTS.workflow;
954
+ if (!packageJson2.scripts[scriptName]) {
955
+ packageJson2.scripts[scriptName] = scriptCommand;
956
+ scriptAdded = true;
957
+ } else if (packageJson2.scripts[scriptName] !== scriptCommand) {
958
+ packageJson2.scripts[scriptName] = scriptCommand;
959
+ scriptUpdated = true;
960
+ }
961
+ const hasChanges = scriptAdded || scriptUpdated || removedScripts.length > 0;
962
+ if (!hasChanges) {
952
963
  p3.outro(
953
- chalk6.green(
954
- `\u2713 All ${TOTAL_SCRIPTS} workflow scripts are already configured!`
955
- )
964
+ chalk6.green(`\u2713 Workflow script is already configured!`)
956
965
  );
957
966
  return;
958
967
  }
959
968
  writeFileSync(
960
969
  packageJsonPath,
961
- JSON.stringify(packageJson, null, 2) + "\n",
970
+ JSON.stringify(packageJson2, null, 2) + "\n",
962
971
  "utf-8"
963
972
  );
964
- const summaryParts = [];
965
- if (addedScripts.length > 0) {
966
- summaryParts.push(`${addedScripts.length} new`);
967
- }
968
- if (updatedScripts.length > 0) {
969
- summaryParts.push(`${updatedScripts.length} updated`);
970
- }
971
- if (removedScripts.length > 0) {
972
- summaryParts.push(`${removedScripts.length} deprecated removed`);
973
- }
974
973
  console.log(
975
- chalk6.green(
976
- `
977
- \u2713 Workflow scripts configured (${summaryParts.join(", ")}):`
978
- )
974
+ chalk6.green(`
975
+ \u2713 Workflow Agent v${WORKFLOW_SCRIPTS_VERSION} configured`)
979
976
  );
977
+ if (scriptAdded) {
978
+ console.log(chalk6.green(`
979
+ Added "workflow" script to package.json`));
980
+ } else if (scriptUpdated) {
981
+ console.log(chalk6.green(`
982
+ Updated "workflow" script in package.json`));
983
+ }
980
984
  if (removedScripts.length > 0) {
981
- console.log(chalk6.yellow(`
982
- \u26A0\uFE0F Removed deprecated scripts:`));
983
- for (const script of removedScripts) {
984
- console.log(chalk6.dim(` - ${script}`));
985
- }
986
985
  console.log(
987
- chalk6.cyan(
988
- `
989
- \u{1F4A1} Updated to workflow-agent v${WORKFLOW_SCRIPTS_VERSION} with new command syntax.`
986
+ chalk6.yellow(`
987
+ \u26A0\uFE0F Removed ${removedScripts.length} deprecated scripts`)
988
+ );
989
+ console.log(
990
+ chalk6.dim(
991
+ ` (Old workflow:* scripts replaced by single "workflow" command)`
990
992
  )
991
993
  );
992
- console.log(chalk6.dim(` Old: workflow-agent learn:list`));
993
- console.log(chalk6.dim(` New: workflow-agent learn list`));
994
994
  }
995
- console.log("");
996
- for (const [category, scripts] of Object.entries(SCRIPT_CATEGORIES)) {
997
- console.log(chalk6.cyan(` ${category}:`));
998
- for (const script of scripts) {
999
- const isNew = addedScripts.includes(script);
1000
- const isUpdated = updatedScripts.includes(script);
1001
- const marker = isNew ? chalk6.green(" (new)") : isUpdated ? chalk6.yellow(" (updated)") : "";
1002
- console.log(chalk6.dim(` - ${script}`) + marker);
1003
- }
1004
- }
1005
- p3.outro(
1006
- chalk6.green(
1007
- `\u2713 ${TOTAL_SCRIPTS} workflow scripts available in package.json!`
1008
- )
1009
- );
1010
- console.log(chalk6.dim("\nRun them with:"));
1011
- console.log(chalk6.dim(" pnpm run workflow:init"));
1012
- console.log(chalk6.dim(" npm run workflow:init\n"));
995
+ console.log(chalk6.cyan(`
996
+ Usage:`));
997
+ console.log(chalk6.dim(` npm run workflow -- init`));
998
+ console.log(chalk6.dim(` npm run workflow -- solution list`));
999
+ console.log(chalk6.dim(` npm run workflow -- --help`));
1000
+ console.log(chalk6.cyan(`
1001
+ Or with pnpm:`));
1002
+ console.log(chalk6.dim(` pnpm workflow init`));
1003
+ console.log(chalk6.dim(` pnpm workflow solution list`));
1004
+ console.log(chalk6.dim(` pnpm workflow --help`));
1005
+ p3.outro(chalk6.green(`\u2713 Workflow script ready!`));
1013
1006
  const guidelinesDir = join4(cwd, "guidelines");
1014
1007
  if (!existsSync4(guidelinesDir)) {
1015
1008
  const templatesDir = findTemplatesDirectory(__dirname2);
@@ -1383,7 +1376,7 @@ async function scopeCreateCommand(options) {
1383
1376
  spinner10.start("Creating package structure...");
1384
1377
  try {
1385
1378
  await mkdir3(join5(outputDir, "src"), { recursive: true });
1386
- const packageJson = {
1379
+ const packageJson2 = {
1387
1380
  name: `@workflow/scopes-${packageName}`,
1388
1381
  version: "1.0.0",
1389
1382
  description: `Scope preset for ${presetName}`,
@@ -1424,7 +1417,7 @@ async function scopeCreateCommand(options) {
1424
1417
  };
1425
1418
  await writeFile3(
1426
1419
  join5(outputDir, "package.json"),
1427
- JSON.stringify(packageJson, null, 2),
1420
+ JSON.stringify(packageJson2, null, 2),
1428
1421
  "utf-8"
1429
1422
  );
1430
1423
  const tsconfig = {
@@ -1695,7 +1688,7 @@ async function scopeMigrateCommand(options) {
1695
1688
  spinner10.start("Migrating scopes to package...");
1696
1689
  try {
1697
1690
  await mkdir4(join6(outputDir, "src"), { recursive: true });
1698
- const packageJson = {
1691
+ const packageJson2 = {
1699
1692
  name: `@workflow/scopes-${packageName}`,
1700
1693
  version: "1.0.0",
1701
1694
  description: `Migrated scope preset for ${presetName}`,
@@ -1736,7 +1729,7 @@ async function scopeMigrateCommand(options) {
1736
1729
  };
1737
1730
  await writeFile4(
1738
1731
  join6(outputDir, "package.json"),
1739
- JSON.stringify(packageJson, null, 2),
1732
+ JSON.stringify(packageJson2, null, 2),
1740
1733
  "utf-8"
1741
1734
  );
1742
1735
  const tsconfig = {
@@ -2387,9 +2380,9 @@ var AdvisoryAnalyzer = class {
2387
2380
  * Executive depth: High-level business summary only
2388
2381
  */
2389
2382
  async analyzeExecutive(timestamp, project) {
2390
- const packageJson = await this.readPackageJson();
2391
- const deps = packageJson.dependencies || {};
2392
- const devDeps = packageJson.devDependencies || {};
2383
+ const packageJson2 = await this.readPackageJson();
2384
+ const deps = packageJson2.dependencies || {};
2385
+ const devDeps = packageJson2.devDependencies || {};
2393
2386
  const techCategories = this.categorizeTechnologies(deps, devDeps);
2394
2387
  const risks = this.calculateExecutiveRisks(project, techCategories);
2395
2388
  const opportunities = this.calculateExecutiveOpportunities(
@@ -2423,18 +2416,18 @@ var AdvisoryAnalyzer = class {
2423
2416
  * Analyze project overview
2424
2417
  */
2425
2418
  async analyzeProject() {
2426
- const packageJson = await this.readPackageJson();
2419
+ const packageJson2 = await this.readPackageJson();
2427
2420
  const isMonorepoProject = await isMonorepo(this.options.cwd);
2428
2421
  const fileCount = await this.countFiles();
2429
2422
  const totalLines = await this.countTotalLines();
2430
2423
  let workspaceCount;
2431
- if (isMonorepoProject && packageJson.workspaces) {
2432
- workspaceCount = Array.isArray(packageJson.workspaces) ? packageJson.workspaces.length : 0;
2424
+ if (isMonorepoProject && packageJson2.workspaces) {
2425
+ workspaceCount = Array.isArray(packageJson2.workspaces) ? packageJson2.workspaces.length : 0;
2433
2426
  }
2434
2427
  return {
2435
- name: packageJson.name || "Unknown Project",
2436
- version: packageJson.version || "0.0.0",
2437
- description: packageJson.description,
2428
+ name: packageJson2.name || "Unknown Project",
2429
+ version: packageJson2.version || "0.0.0",
2430
+ description: packageJson2.description,
2438
2431
  isMonorepo: isMonorepoProject,
2439
2432
  packageManager: await detectPackageManager(this.options.cwd),
2440
2433
  workspaceCount,
@@ -2446,9 +2439,9 @@ var AdvisoryAnalyzer = class {
2446
2439
  * Analyze technology stack
2447
2440
  */
2448
2441
  async analyzeTechnology() {
2449
- const packageJson = await this.readPackageJson();
2450
- const deps = packageJson.dependencies || {};
2451
- const devDeps = packageJson.devDependencies || {};
2442
+ const packageJson2 = await this.readPackageJson();
2443
+ const deps = packageJson2.dependencies || {};
2444
+ const devDeps = packageJson2.devDependencies || {};
2452
2445
  const projectAnalysis = await analyzeProject(this.options.cwd);
2453
2446
  return {
2454
2447
  framework: projectAnalysis.framework,
@@ -2464,9 +2457,9 @@ var AdvisoryAnalyzer = class {
2464
2457
  * Analyze packages in detail
2465
2458
  */
2466
2459
  async analyzePackages() {
2467
- const packageJson = await this.readPackageJson();
2468
- const deps = packageJson.dependencies || {};
2469
- const devDeps = packageJson.devDependencies || {};
2460
+ const packageJson2 = await this.readPackageJson();
2461
+ const deps = packageJson2.dependencies || {};
2462
+ const devDeps = packageJson2.devDependencies || {};
2470
2463
  const production = this.analyzeDependencies(deps, "production");
2471
2464
  const development = this.analyzeDependencies(devDeps, "development");
2472
2465
  const categories = this.categorizeTechnologies(deps, devDeps);
@@ -7277,10 +7270,10 @@ async function inferTagsFromDependencies(cwd) {
7277
7270
  return tags;
7278
7271
  }
7279
7272
  try {
7280
- const packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
7273
+ const packageJson2 = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
7281
7274
  const allDeps = {
7282
- ...packageJson.dependencies,
7283
- ...packageJson.devDependencies
7275
+ ...packageJson2.dependencies,
7276
+ ...packageJson2.devDependencies
7284
7277
  };
7285
7278
  for (const dep of Object.keys(allDeps)) {
7286
7279
  const mappedTags = LIBRARY_TAG_MAP[dep];
@@ -8413,6 +8406,11 @@ ${chalk22.bold("Examples:")}
8413
8406
  }
8414
8407
 
8415
8408
  // src/cli/index.ts
8409
+ var __filename4 = fileURLToPath4(import.meta.url);
8410
+ var __dirname4 = dirname5(__filename4);
8411
+ var packageJson = JSON.parse(
8412
+ readFileSync3(join12(__dirname4, "../../package.json"), "utf-8")
8413
+ );
8416
8414
  function deprecationWarning(oldCmd, newCmd) {
8417
8415
  console.warn(chalk23.yellow(`\u26A0\uFE0F "${oldCmd}" is deprecated and will be removed in v2.0.`));
8418
8416
  console.warn(chalk23.yellow(` Use: ${newCmd}
@@ -8421,7 +8419,7 @@ function deprecationWarning(oldCmd, newCmd) {
8421
8419
  var program = new Command7();
8422
8420
  program.name("workflow").description(
8423
8421
  "A self-evolving workflow management system for AI agent development"
8424
- ).version("1.0.0");
8422
+ ).version(packageJson.version);
8425
8423
  program.addCommand(createDocsCommand());
8426
8424
  program.addCommand(createSolutionCommand());
8427
8425
  program.addCommand(createLearnCommand());