@superdesign/cli 0.1.2 → 0.1.3

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.
@@ -7,9 +7,10 @@ export interface CreateDraftRequest {
7
7
  deviceMode?: 'mobile' | 'tablet' | 'desktop';
8
8
  }
9
9
  export interface IterateDraftRequest {
10
- prompt: string;
11
- mode: 'replace' | 'branch';
10
+ prompts?: string[];
11
+ prompt?: string;
12
12
  count?: 1 | 2 | 3 | 4;
13
+ mode: 'replace' | 'branch';
13
14
  }
14
15
  export interface PlanFlowRequest {
15
16
  sourceNodeId: string;
package/dist/index.cjs CHANGED
@@ -1094,33 +1094,65 @@ superdesign get-design --draft-id <id> --json
1094
1094
  });
1095
1095
  return command;
1096
1096
  }
1097
+ const VALID_MODES = [
1098
+ 'replace',
1099
+ 'branch'
1100
+ ];
1101
+ const MAX_VARIATIONS = 4;
1102
+ function parseCount(countStr) {
1103
+ if (void 0 === countStr) return;
1104
+ const count = parseInt(countStr, 10);
1105
+ return isNaN(count) ? NaN : count;
1106
+ }
1107
+ function validateOptions(options) {
1108
+ if (!VALID_MODES.includes(options.mode)) {
1109
+ output_error('Invalid mode. Must be: replace or branch');
1110
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
1111
+ }
1112
+ const prompts = options.prompt;
1113
+ const count = parseCount(options.count);
1114
+ if (void 0 !== count && (isNaN(count) || count < 1 || count > MAX_VARIATIONS)) {
1115
+ output_error(`Invalid count. Must be between 1 and ${MAX_VARIATIONS}`);
1116
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
1117
+ }
1118
+ if (prompts.length > 1 && void 0 !== count) {
1119
+ output_error('Cannot use --count with multiple prompts. Either provide multiple -p prompts OR single -p with --count.');
1120
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
1121
+ }
1122
+ if (prompts.length > MAX_VARIATIONS) {
1123
+ output_error(`Must provide 1-${MAX_VARIATIONS} prompts`);
1124
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
1125
+ }
1126
+ if ('replace' === options.mode && (prompts.length > 1 || count && count > 1)) {
1127
+ output_error('Replace mode only supports 1 prompt/variation');
1128
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
1129
+ }
1130
+ return {
1131
+ prompts,
1132
+ count,
1133
+ mode: options.mode
1134
+ };
1135
+ }
1097
1136
  function createIterateDesignDraftCommand() {
1098
- const command = new external_commander_namespaceObject.Command('iterate-design-draft').description('Iterate on an existing draft using AI').requiredOption('--draft-id <id>', 'Draft ID to iterate on').requiredOption('--prompt <prompt>', 'Iteration prompt').requiredOption('--mode <mode>', 'Iteration mode (replace or branch)').option('--count <count>', 'Number of variations to generate (1-4)', '1').option('--json', 'Output in JSON format').action(async (options)=>{
1137
+ const command = new external_commander_namespaceObject.Command('iterate-design-draft').description('Iterate on an existing draft using AI').requiredOption('--draft-id <id>', 'Draft ID to iterate on').requiredOption('-p, --prompt <prompt...>', 'Iteration prompt(s). Use multiple -p for specific prompts per variation.').requiredOption('--mode <mode>', 'Iteration mode (replace or branch)').option('--count <count>', 'Number of variations (1-4). Only used when single prompt provided.').option('--json', 'Output in JSON format').action(async (options)=>{
1099
1138
  if (options.json) setJsonMode(true);
1100
1139
  job_runner_requireAuth(manager_isAuthenticated);
1101
- if (![
1102
- 'replace',
1103
- 'branch'
1104
- ].includes(options.mode)) {
1105
- output_error('Invalid mode. Must be: replace or branch');
1106
- process.exit(EXIT_CODES.VALIDATION_ERROR);
1107
- }
1108
- const count = parseInt(options.count || '1', 10);
1109
- if (isNaN(count) || count < 1 || count > 4) {
1110
- output_error('Invalid count. Must be between 1 and 4');
1111
- process.exit(EXIT_CODES.VALIDATION_ERROR);
1112
- }
1140
+ const { prompts, count, mode } = validateOptions(options);
1141
+ const requestData = prompts.length > 1 ? {
1142
+ prompts,
1143
+ mode
1144
+ } : {
1145
+ prompt: prompts[0],
1146
+ count: count,
1147
+ mode
1148
+ };
1113
1149
  await runJob({
1114
1150
  startLabel: 'Starting iteration...',
1115
1151
  pollingLabel: 'Iterating design with AI...',
1116
1152
  successLabel: 'Iteration complete!',
1117
1153
  timeoutLabel: 'Iteration timed out',
1118
1154
  failureLabel: 'Failed to iterate draft',
1119
- startJob: ()=>iterateDraft(options.draftId, {
1120
- prompt: options.prompt,
1121
- mode: options.mode,
1122
- count: count
1123
- }),
1155
+ startJob: ()=>iterateDraft(options.draftId, requestData),
1124
1156
  transformResult: (job)=>({
1125
1157
  drafts: job.result.drafts,
1126
1158
  projectUrl: job.result.projectUrl,
package/dist/index.js CHANGED
@@ -1004,33 +1004,65 @@ function createCreateDesignDraftCommand() {
1004
1004
  });
1005
1005
  return command;
1006
1006
  }
1007
+ const VALID_MODES = [
1008
+ 'replace',
1009
+ 'branch'
1010
+ ];
1011
+ const MAX_VARIATIONS = 4;
1012
+ function parseCount(countStr) {
1013
+ if (void 0 === countStr) return;
1014
+ const count = parseInt(countStr, 10);
1015
+ return isNaN(count) ? NaN : count;
1016
+ }
1017
+ function validateOptions(options) {
1018
+ if (!VALID_MODES.includes(options.mode)) {
1019
+ output_error('Invalid mode. Must be: replace or branch');
1020
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
1021
+ }
1022
+ const prompts = options.prompt;
1023
+ const count = parseCount(options.count);
1024
+ if (void 0 !== count && (isNaN(count) || count < 1 || count > MAX_VARIATIONS)) {
1025
+ output_error(`Invalid count. Must be between 1 and ${MAX_VARIATIONS}`);
1026
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
1027
+ }
1028
+ if (prompts.length > 1 && void 0 !== count) {
1029
+ output_error('Cannot use --count with multiple prompts. Either provide multiple -p prompts OR single -p with --count.');
1030
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
1031
+ }
1032
+ if (prompts.length > MAX_VARIATIONS) {
1033
+ output_error(`Must provide 1-${MAX_VARIATIONS} prompts`);
1034
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
1035
+ }
1036
+ if ('replace' === options.mode && (prompts.length > 1 || count && count > 1)) {
1037
+ output_error('Replace mode only supports 1 prompt/variation');
1038
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
1039
+ }
1040
+ return {
1041
+ prompts,
1042
+ count,
1043
+ mode: options.mode
1044
+ };
1045
+ }
1007
1046
  function createIterateDesignDraftCommand() {
1008
- const command = new Command('iterate-design-draft').description('Iterate on an existing draft using AI').requiredOption('--draft-id <id>', 'Draft ID to iterate on').requiredOption('--prompt <prompt>', 'Iteration prompt').requiredOption('--mode <mode>', 'Iteration mode (replace or branch)').option('--count <count>', 'Number of variations to generate (1-4)', '1').option('--json', 'Output in JSON format').action(async (options)=>{
1047
+ const command = new Command('iterate-design-draft').description('Iterate on an existing draft using AI').requiredOption('--draft-id <id>', 'Draft ID to iterate on').requiredOption('-p, --prompt <prompt...>', 'Iteration prompt(s). Use multiple -p for specific prompts per variation.').requiredOption('--mode <mode>', 'Iteration mode (replace or branch)').option('--count <count>', 'Number of variations (1-4). Only used when single prompt provided.').option('--json', 'Output in JSON format').action(async (options)=>{
1009
1048
  if (options.json) setJsonMode(true);
1010
1049
  job_runner_requireAuth(manager_isAuthenticated);
1011
- if (![
1012
- 'replace',
1013
- 'branch'
1014
- ].includes(options.mode)) {
1015
- output_error('Invalid mode. Must be: replace or branch');
1016
- process.exit(EXIT_CODES.VALIDATION_ERROR);
1017
- }
1018
- const count = parseInt(options.count || '1', 10);
1019
- if (isNaN(count) || count < 1 || count > 4) {
1020
- output_error('Invalid count. Must be between 1 and 4');
1021
- process.exit(EXIT_CODES.VALIDATION_ERROR);
1022
- }
1050
+ const { prompts, count, mode } = validateOptions(options);
1051
+ const requestData = prompts.length > 1 ? {
1052
+ prompts,
1053
+ mode
1054
+ } : {
1055
+ prompt: prompts[0],
1056
+ count: count,
1057
+ mode
1058
+ };
1023
1059
  await runJob({
1024
1060
  startLabel: 'Starting iteration...',
1025
1061
  pollingLabel: 'Iterating design with AI...',
1026
1062
  successLabel: 'Iteration complete!',
1027
1063
  timeoutLabel: 'Iteration timed out',
1028
1064
  failureLabel: 'Failed to iterate draft',
1029
- startJob: ()=>iterateDraft(options.draftId, {
1030
- prompt: options.prompt,
1031
- mode: options.mode,
1032
- count: count
1033
- }),
1065
+ startJob: ()=>iterateDraft(options.draftId, requestData),
1034
1066
  transformResult: (job)=>({
1035
1067
  drafts: job.result.drafts,
1036
1068
  projectUrl: job.result.projectUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdesign/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "CLI for SuperDesign Platform - agent skills for Claude Code",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",