@dataparade/cli 0.0.13 → 0.0.15

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.
Files changed (81) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/ai-enrichment/candidate-selector.d.ts +4 -4
  3. package/dist/src/ai-enrichment/candidate-selector.js +37 -32
  4. package/dist/src/ai-enrichment/fallbacks.js +130 -3
  5. package/dist/src/ai-enrichment/merge-rules.d.ts +3 -3
  6. package/dist/src/ai-enrichment/merge-rules.js +118 -40
  7. package/dist/src/ai-enrichment/prompts/provider-enrichment-prompts.d.ts +2 -2
  8. package/dist/src/ai-enrichment/prompts/provider-enrichment-prompts.js +3 -3
  9. package/dist/src/ai-enrichment/property-priority.d.ts +5 -0
  10. package/dist/src/ai-enrichment/property-priority.js +23 -0
  11. package/dist/src/ai-enrichment/provider-prompt.d.ts +5 -5
  12. package/dist/src/ai-enrichment/provider-prompt.js +24 -19
  13. package/dist/src/ai-enrichment/red-flags.d.ts +46 -0
  14. package/dist/src/ai-enrichment/red-flags.js +365 -0
  15. package/dist/src/ai-enrichment/third-party-evidence.d.ts +3 -3
  16. package/dist/src/ai-enrichment/third-party-evidence.js +96 -93
  17. package/dist/src/cli.d.ts +1 -1
  18. package/dist/src/cli.js +236 -143
  19. package/dist/src/core/pipeline/orchestrator-result.d.ts +9 -1
  20. package/dist/src/core/pipeline/orchestrator.d.ts +2 -2
  21. package/dist/src/core/pipeline/scan-pipeline.d.ts +2 -2
  22. package/dist/src/core/pipeline/scan-pipeline.js +46 -34
  23. package/dist/src/core/schema/dataflow-wrapper.schema.d.ts +33 -1
  24. package/dist/src/core/schema/dataflow-wrapper.schema.js +19 -3
  25. package/dist/src/output/json.d.ts +18 -3
  26. package/dist/src/output/json.js +14 -5
  27. package/dist/src/platform-api/cli-scan-failure-report.d.ts +9 -0
  28. package/dist/src/platform-api/cli-scan-failure-report.js +23 -0
  29. package/dist/tests/schema/dataflow-wrapper.schema.spec.js +142 -21
  30. package/dist/tests/unit/ai-enrichment/candidate-selector.spec.js +80 -49
  31. package/dist/tests/unit/ai-enrichment/fallbacks.spec.js +78 -0
  32. package/dist/tests/unit/ai-enrichment/merge-rules.spec.js +510 -264
  33. package/dist/tests/unit/ai-enrichment/provider-prompt.spec.js +80 -77
  34. package/dist/tests/unit/ai-enrichment/red-flags.spec.js +227 -0
  35. package/dist/tests/unit/ai-enrichment/third-party-evidence.spec.js +38 -34
  36. package/dist/tests/unit/cli/scan-command-e2e-backend-lambda-orphan.spec.d.ts +1 -0
  37. package/dist/tests/unit/cli/scan-command-e2e-backend-lambda-orphan.spec.js +60 -0
  38. package/dist/tests/unit/cli/scan-command-e2e-occupied-section-hubs.spec.d.ts +1 -0
  39. package/dist/tests/unit/cli/scan-command-e2e-occupied-section-hubs.spec.js +58 -0
  40. package/dist/tests/unit/cli/scan-command-e2e-ruby-basic.spec.d.ts +1 -0
  41. package/dist/tests/unit/cli/scan-command-e2e-ruby-basic.spec.js +46 -0
  42. package/dist/tests/unit/cli/scan-quota-flow.spec.js +57 -45
  43. package/dist/tests/unit/platform-api/cli-scan-failure-report.spec.d.ts +1 -0
  44. package/dist/tests/unit/platform-api/cli-scan-failure-report.spec.js +25 -0
  45. package/package.json +2 -2
  46. package/dist/tests/fixtures/e2e-ts-sample/db-client-import.d.ts +0 -2
  47. package/dist/tests/fixtures/e2e-ts-sample/db-client-import.js +0 -8
  48. package/dist/tests/fixtures/e2e-ts-sample/db.d.ts +0 -3
  49. package/dist/tests/fixtures/e2e-ts-sample/db.js +0 -7
  50. package/dist/tests/fixtures/e2e-ts-sample/external-api.d.ts +0 -1
  51. package/dist/tests/fixtures/e2e-ts-sample/external-api.js +0 -18
  52. package/dist/tests/fixtures/e2e-ts-sample/pg-client.d.ts +0 -3
  53. package/dist/tests/fixtures/e2e-ts-sample/pg-client.js +0 -7
  54. package/dist/tests/fixtures/e2e-ts-sample/server.d.ts +0 -14
  55. package/dist/tests/fixtures/e2e-ts-sample/server.js +0 -4
  56. package/dist/tests/fixtures/e2e-ts-sentry-route-env/server.js +0 -24
  57. package/dist/tests/fixtures/ingest-basic/src/index.d.ts +0 -1
  58. package/dist/tests/fixtures/ingest-basic/src/index.js +0 -6
  59. package/dist/tests/fixtures/mixed-language-basic/api.d.ts +0 -2
  60. package/dist/tests/fixtures/mixed-language-basic/api.js +0 -12
  61. package/dist/tests/fixtures/monorepo-app-plus-terraform/packages/app/app/route.d.ts +0 -1
  62. package/dist/tests/fixtures/monorepo-app-plus-terraform/packages/app/app/route.js +0 -6
  63. package/dist/tests/fixtures/monorepo-front-back-sections/backend/app/route.d.ts +0 -1
  64. package/dist/tests/fixtures/monorepo-front-back-sections/backend/app/route.js +0 -6
  65. package/dist/tests/fixtures/monorepo-front-back-sections/frontend/app/route.d.ts +0 -1
  66. package/dist/tests/fixtures/monorepo-front-back-sections/frontend/app/route.js +0 -7
  67. package/dist/tests/fixtures/typescript-basic/app/route.d.ts +0 -1
  68. package/dist/tests/fixtures/typescript-basic/app/route.js +0 -7
  69. package/dist/tests/fixtures/typescript-basic/db-client-import.d.ts +0 -2
  70. package/dist/tests/fixtures/typescript-basic/db-client-import.js +0 -8
  71. package/dist/tests/fixtures/typescript-basic/db.d.ts +0 -3
  72. package/dist/tests/fixtures/typescript-basic/db.js +0 -7
  73. package/dist/tests/fixtures/typescript-basic/external-api.d.ts +0 -1
  74. package/dist/tests/fixtures/typescript-basic/external-api.js +0 -18
  75. package/dist/tests/fixtures/typescript-basic/pg-client.d.ts +0 -3
  76. package/dist/tests/fixtures/typescript-basic/pg-client.js +0 -7
  77. package/dist/tests/fixtures/typescript-basic/server.d.ts +0 -14
  78. package/dist/tests/fixtures/typescript-basic/server.js +0 -4
  79. package/dist/tests/fixtures/typescript-dependency-manifests-basic/src/index.d.ts +0 -0
  80. package/dist/tests/fixtures/typescript-dependency-manifests-basic/src/index.js +0 -2
  81. /package/dist/tests/{fixtures/e2e-ts-sentry-route-env/server.d.ts → unit/ai-enrichment/red-flags.spec.d.ts} +0 -0
package/dist/src/cli.js CHANGED
@@ -43,6 +43,7 @@ const commander_1 = require("commander");
43
43
  const crypto_1 = require("crypto");
44
44
  const package_json_1 = __importDefault(require("../package.json"));
45
45
  const json_1 = require("./output/json");
46
+ const dataflow_wrapper_schema_1 = require("./core/schema/dataflow-wrapper.schema");
46
47
  const upload_env_1 = require("./config/upload-env");
47
48
  const types_1 = require("./ai-enrichment/types");
48
49
  const inference_scope_1 = require("./config/inference-scope");
@@ -52,21 +53,24 @@ const scan_env_1 = require("./config/scan-env");
52
53
  const validate_scan_ai_1 = require("./config/validate-scan-ai");
53
54
  const scan_sentry_1 = require("./observability/scan-sentry");
54
55
  const telemetry_client_1 = require("./platform-api/telemetry-client");
56
+ const cli_scan_failure_report_1 = require("./platform-api/cli-scan-failure-report");
55
57
  const scan_config_schema_1 = require("./core/schema/scan-config.schema");
56
58
  const scanner_1 = require("@dataparade/scanner");
57
59
  function formatEvidence(detail) {
58
60
  const evidence = detail.evidence;
59
61
  if (!evidence || evidence.length === 0) {
60
- return "none";
62
+ return 'none';
61
63
  }
62
64
  const head = evidence[0];
63
65
  const first = head != null
64
66
  ? `${head.filePath}:${head.startLine}-${head.endLine} (${head.reason})`
65
- : "none";
66
- return evidence.length === 1 ? first : `${first}; +${evidence.length - 1} more`;
67
+ : 'none';
68
+ return evidence.length === 1
69
+ ? first
70
+ : `${first}; +${evidence.length - 1} more`;
67
71
  }
68
72
  function formatProposalTarget(detail) {
69
- if (detail.kind === "component_patch" && detail.targetComponentId) {
73
+ if (detail.kind === 'component_patch' && detail.targetComponentId) {
70
74
  return `component:${detail.targetComponentId}`;
71
75
  }
72
76
  if (detail.targetFlowId)
@@ -74,18 +78,20 @@ function formatProposalTarget(detail) {
74
78
  if (detail.sourceComponentId && detail.targetFlowComponentId) {
75
79
  return `flow:${detail.sourceComponentId}->${detail.targetFlowComponentId}`;
76
80
  }
77
- return "unknown";
81
+ return 'unknown';
78
82
  }
79
83
  function printAiInferenceVerbose(details) {
80
84
  if (details.length === 0) {
81
85
  // eslint-disable-next-line no-console
82
- console.log("[scan] ai-inference details: no proposals generated");
86
+ console.log('[scan] ai-inference details: no proposals generated');
83
87
  return;
84
88
  }
85
89
  // eslint-disable-next-line no-console
86
- console.log("[scan] ai-inference details:");
90
+ console.log('[scan] ai-inference details:');
87
91
  for (const detail of details) {
88
- const status = detail.status === "applied" ? "applied" : `rejected (${detail.rejectionReason})`;
92
+ const status = detail.status === 'applied'
93
+ ? 'applied'
94
+ : `rejected (${detail.rejectionReason})`;
89
95
  const confidence = detail.confidence.toFixed(2);
90
96
  // eslint-disable-next-line no-console
91
97
  console.log(`[scan] - ${detail.id}: ${status} | ${detail.source} | ${detail.kind} | target=${formatProposalTarget(detail)} | confidence=${confidence} (${detail.confidenceBand})`);
@@ -93,7 +99,9 @@ function printAiInferenceVerbose(details) {
93
99
  console.log(`[scan] candidate=${detail.candidateType} agent=${detail.agent} provider=${detail.provider}/${detail.model}`);
94
100
  // eslint-disable-next-line no-console
95
101
  console.log(`[scan] evidence=${formatEvidence(detail)}`);
96
- if (detail.status === "applied" && detail.propertyChanges && detail.propertyChanges.length) {
102
+ if (detail.status === 'applied' &&
103
+ detail.propertyChanges &&
104
+ detail.propertyChanges.length) {
97
105
  const formatted = detail.propertyChanges.map((change) => {
98
106
  const from = JSON.stringify(change.from);
99
107
  const to = JSON.stringify(change.to);
@@ -107,71 +115,98 @@ function printAiInferenceVerbose(details) {
107
115
  }
108
116
  }
109
117
  function formatUsd(value) {
110
- if (typeof value !== "number" || !Number.isFinite(value))
111
- return "n/a";
118
+ if (typeof value !== 'number' || !Number.isFinite(value))
119
+ return 'n/a';
112
120
  return `$${value.toFixed(6)}`;
113
121
  }
114
122
  function createProgram() {
115
123
  const program = new commander_1.Command();
116
124
  program
117
- .name("dataparade")
118
- .description("DataParade CLI - scan codebases for data flow components")
125
+ .name('dataparade')
126
+ .description('DataParade CLI - scan codebases for data flow components')
119
127
  .version(package_json_1.default.version);
120
128
  program
121
- .command("scan <path>")
122
- .description("Scan a directory (or a single supported source file) for data flow components")
123
- .option("-o, --output <file>", "Write dataflow.json wrapper to the given file (default: ./dataflow.json)")
124
- .option("--exclude <pattern...>", "One or more glob patterns to exclude from scanning")
125
- .option("--minimum-confidence <number>", "Minimum confidence (0-1) for including detections")
126
- .option("--language <language...>", "Limit scanning to specific languages (e.g. typescript, javascript, python, go, java, kotlin, cpp, csharp, terraform)")
127
- .option("--project-name <name>", "Override the inferred project name used for the application asset")
128
- .option("--deep-analysis", "Enable deeper, potentially slower structural analysis where supported")
129
- .option("--terraform-json <path>", "Merge resource addresses from a saved `terraform show -json` file (absolute or relative to scan root)")
130
- .option("--terraform-plan <path>", "Merge addresses by running `terraform show -json <path>` from the scan root (path relative to scan root; requires terraform on PATH)")
131
- .option("--terraform-stack-section-path-depth <n>", "Register Terraform stack directories as service sections when their path has exactly N segments (e.g. 4 for packages/foo/k8s/terraform)")
132
- .option("--no-terraform-stack-section-auto", "Do not infer terraformStackSectionPathDepth from .tf layout when depth is unset")
133
- .option("--monorepo-package-section-path-depth <n>", "Workspace package section depth (max 3): primary packages and rollup use N POSIX path segments (e.g. 3 for packages/twenty-apps/hello)")
134
- .option("--no-monorepo-package-section-auto", "Do not infer monorepoPackageSectionPathDepth from package.json layout when depth is unset")
135
- .option("--ai-inference", "Enable post-scan AI inference (default: on; SCAN_AI_INFERENCE=false also disables)")
136
- .option("--no-ai-inference", "Disable post-scan AI inference")
137
- .option("--ai-provider <provider>", `AI provider: ${types_1.AI_PROVIDER_IDS.join("|")}`)
138
- .option("--ai-model <model>", "Model name for AI inference")
139
- .option("--ai-endpoint <url>", "Override provider endpoint URL")
140
- .option("--ai-temperature <number>", "Sampling temperature for model calls")
141
- .option("--ai-max-tokens <number>", "Max tokens per inference call")
142
- .option("--ai-max-calls <number>", "Max model calls for a scan")
143
- .option("--ai-budget-tokens <number>", "Total token budget for inference")
144
- .option("--ai-max-candidates-per-agent <number>", "Max inference queue items per agent (0 = no cap; default from config: 25)")
145
- .option("--ai-inference-scope <scope>", "default | third_party_only — third_party_only runs AI enrichment only on every third-party node")
146
- .option("--ai-verbose", "Print per-proposal AI inference details (applied/rejected + evidence)")
147
- .option("--workspace-api-key <key>", "DataParade workspace API key (platform AI + quota; env: DATAPARADE_WORKSPACE_API_KEY)")
148
- .option("--api-key <key>", "(deprecated) alias for --workspace-api-key")
149
- .option("--byok-provider <provider>", `BYOK LLM provider when using your own API key: ${types_1.AI_PROVIDER_IDS.join("|")}`)
150
- .option("--byok-model <model>", "BYOK model name (env: SCAN_BYOK_MODEL)")
151
- .option("--skip-auto-upload", "Do not upload dataflow.json to the dashboard after scan (env: DATAPARADE_SKIP_AUTO_UPLOAD)")
129
+ .command('scan <path>')
130
+ .description('Scan a directory (or a single supported source file) for data flow components')
131
+ .option('-o, --output <file>', 'Write dataflow.json wrapper to the given file (default: ./dataflow.json)')
132
+ .option('--exclude <pattern...>', 'One or more glob patterns to exclude from scanning')
133
+ .option('--minimum-confidence <number>', 'Minimum confidence (0-1) for including detections')
134
+ .option('--language <language...>', 'Limit scanning to specific languages (e.g. typescript, javascript, python, go, java, kotlin, cpp, csharp, terraform)')
135
+ .option('--project-name <name>', 'Override the inferred project name used for the application asset')
136
+ .option('--deep-analysis', 'Enable deeper, potentially slower structural analysis where supported')
137
+ .option('--terraform-json <path>', 'Merge resource addresses from a saved `terraform show -json` file (absolute or relative to scan root)')
138
+ .option('--terraform-plan <path>', 'Merge addresses by running `terraform show -json <path>` from the scan root (path relative to scan root; requires terraform on PATH)')
139
+ .option('--terraform-stack-section-path-depth <n>', 'Register Terraform stack directories as service sections when their path has exactly N segments (e.g. 4 for packages/foo/k8s/terraform)')
140
+ .option('--no-terraform-stack-section-auto', 'Do not infer terraformStackSectionPathDepth from .tf layout when depth is unset')
141
+ .option('--monorepo-package-section-path-depth <n>', 'Workspace package section depth (max 3): primary packages and rollup use N POSIX path segments (e.g. 3 for packages/twenty-apps/hello)')
142
+ .option('--no-monorepo-package-section-auto', 'Do not infer monorepoPackageSectionPathDepth from package.json layout when depth is unset')
143
+ .option('--ai-inference', 'Enable post-scan AI inference (default: on; SCAN_AI_INFERENCE=false also disables)')
144
+ .option('--no-ai-inference', 'Disable post-scan AI inference')
145
+ .option('--ai-provider <provider>', `AI provider: ${types_1.AI_PROVIDER_IDS.join('|')}`)
146
+ .option('--ai-model <model>', 'Model name for AI inference')
147
+ .option('--ai-endpoint <url>', 'Override provider endpoint URL')
148
+ .option('--ai-temperature <number>', 'Sampling temperature for model calls')
149
+ .option('--ai-max-tokens <number>', 'Max tokens per inference call')
150
+ .option('--ai-max-calls <number>', 'Max model calls for a scan')
151
+ .option('--ai-budget-tokens <number>', 'Total token budget for inference')
152
+ .option('--ai-max-candidates-per-agent <number>', 'Max inference queue items per agent (0 = no cap; default from config: 25)')
153
+ .option('--ai-inference-scope <scope>', 'default | third_party_only — third_party_only runs AI enrichment only on every third-party node')
154
+ .option('--ai-verbose', 'Print per-proposal AI inference details (applied/rejected + evidence)')
155
+ .option('--workspace-api-key <key>', 'DataParade workspace API key (platform AI + quota; env: DATAPARADE_WORKSPACE_API_KEY)')
156
+ .option('--api-key <key>', '(deprecated) alias for --workspace-api-key')
157
+ .option('--byok-provider <provider>', `BYOK LLM provider when using your own API key: ${types_1.AI_PROVIDER_IDS.join('|')}`)
158
+ .option('--byok-model <model>', 'BYOK model name (env: SCAN_BYOK_MODEL)')
159
+ .option('--skip-auto-upload', 'Do not upload dataflow.json to the dashboard after scan (env: DATAPARADE_SKIP_AUTO_UPLOAD)')
160
+ .option('--git-context <json>', 'Git repository context for evidence linking (JSON: {"provider":"github"|"gitlab","repository":"owner/repo","commitSha":"...","baseUrl?":"..."})')
152
161
  .action(async (path, options) => {
153
162
  let cliQuotaJobId;
154
163
  let platformQuotaApiKey;
155
164
  let quotaCompletionReported = false;
156
- let fallbackFailureMessage = "CLI scan did not complete successfully";
165
+ let fallbackFailureMessage = 'CLI scan did not complete successfully';
166
+ let reportedFailure;
157
167
  let sentryScanRoot;
158
168
  let sentryAiMode;
159
169
  let sentryAiProvider;
160
170
  const isInteractive = process.stdout.isTTY;
171
+ // Parse and validate --git-context if provided
172
+ let parsedGitContext;
173
+ if (options.gitContext) {
174
+ try {
175
+ const rawJson = JSON.parse(options.gitContext);
176
+ const validated = dataflow_wrapper_schema_1.gitContextSchema.safeParse(rawJson);
177
+ if (!validated.success) {
178
+ const errors = validated.error.issues
179
+ .map((i) => `${i.path.join('.') || '<root>'}: ${i.message}`)
180
+ .join('; ');
181
+ // eslint-disable-next-line no-console
182
+ console.error(`[scan] invalid --git-context: ${errors}`);
183
+ process.exitCode = 2;
184
+ return;
185
+ }
186
+ parsedGitContext = validated.data;
187
+ }
188
+ catch (parseErr) {
189
+ const message = parseErr instanceof Error ? parseErr.message : 'Invalid JSON';
190
+ // eslint-disable-next-line no-console
191
+ console.error(`[scan] failed to parse --git-context: ${message}`);
192
+ process.exitCode = 2;
193
+ return;
194
+ }
195
+ }
161
196
  const workspaceApiKey = options.workspaceApiKey?.trim() ||
162
197
  options.apiKey?.trim() ||
163
198
  (0, scan_env_1.resolveWorkspaceApiKey)(process.env);
164
199
  const usageSessionId = (0, crypto_1.randomUUID)();
165
200
  await (0, telemetry_client_1.reportCliUsageEvent)({
166
201
  sessionId: usageSessionId,
167
- event: "scan_started",
168
- command: "scan",
202
+ event: 'scan_started',
203
+ command: 'scan',
169
204
  hasApiKey: Boolean(workspaceApiKey),
170
205
  apiKey: workspaceApiKey,
171
206
  cliVersion: package_json_1.default.version,
172
207
  });
173
208
  try {
174
- const rootPathArg = path || ".";
209
+ const rootPathArg = path || '.';
175
210
  // Load dataparade.config.json from the directory being scanned, not
176
211
  // process.cwd(). Locally these often match; in Lambda the worker cwd
177
212
  // is the image root (/var/task) while the scan path is /tmp/.../project.
@@ -181,23 +216,27 @@ function createProgram() {
181
216
  scanEntry = await (0, scanner_1.resolveScanFilesystemEntry)(resolvedScanRoot);
182
217
  }
183
218
  catch (err) {
184
- const message = err instanceof Error ? err.message : "Path does not exist.";
219
+ const message = err instanceof Error ? err.message : 'Path does not exist.';
185
220
  sentryScanRoot = resolvedScanRoot;
221
+ reportedFailure = {
222
+ code: 'path_not_found',
223
+ message: (0, cli_scan_failure_report_1.truncateFailureMessage)(message),
224
+ };
186
225
  await (0, scan_sentry_1.reportScanCliError)({
187
226
  error: err,
188
227
  scanRoot: sentryScanRoot,
189
- failurePhase: "resolve_path",
190
- failureCode: "path_not_found",
228
+ failurePhase: 'resolve_path',
229
+ failureCode: 'path_not_found',
191
230
  });
192
231
  // eslint-disable-next-line no-console
193
232
  console.error(`[scan] error: ${message}`);
194
233
  process.exitCode = 2;
195
234
  return;
196
235
  }
197
- const [{ createDefaultScanConfiguration }, { runScanPipeline }, { buildDiagramGraphFromScanResult }] = await Promise.all([
198
- Promise.resolve().then(() => __importStar(require("./core/pipeline/orchestrator"))),
199
- Promise.resolve().then(() => __importStar(require("./core/pipeline/scan-pipeline"))),
200
- Promise.resolve().then(() => __importStar(require("./core/pipeline/graph-mapping"))),
236
+ const [{ createDefaultScanConfiguration }, { runScanPipeline }, { buildDiagramGraphFromScanResult },] = await Promise.all([
237
+ Promise.resolve().then(() => __importStar(require('./core/pipeline/orchestrator'))),
238
+ Promise.resolve().then(() => __importStar(require('./core/pipeline/scan-pipeline'))),
239
+ Promise.resolve().then(() => __importStar(require('./core/pipeline/graph-mapping'))),
201
240
  ]);
202
241
  if (isInteractive) {
203
242
  // eslint-disable-next-line no-console
@@ -205,7 +244,7 @@ function createProgram() {
205
244
  }
206
245
  const flags = {
207
246
  exclude: options.exclude,
208
- minimumConfidence: typeof options.minimumConfidence === "string"
247
+ minimumConfidence: typeof options.minimumConfidence === 'string'
209
248
  ? Number(options.minimumConfidence)
210
249
  : undefined,
211
250
  language: options.language,
@@ -213,11 +252,11 @@ function createProgram() {
213
252
  projectName: options.projectName,
214
253
  terraformJson: options.terraformJson,
215
254
  terraformPlan: options.terraformPlan,
216
- terraformStackSectionPathDepth: typeof options.terraformStackSectionPathDepth === "string"
255
+ terraformStackSectionPathDepth: typeof options.terraformStackSectionPathDepth === 'string'
217
256
  ? Number(options.terraformStackSectionPathDepth)
218
257
  : undefined,
219
258
  noTerraformStackSectionAuto: options.noTerraformStackSectionAuto,
220
- monorepoPackageSectionPathDepth: typeof options.monorepoPackageSectionPathDepth === "string"
259
+ monorepoPackageSectionPathDepth: typeof options.monorepoPackageSectionPathDepth === 'string'
221
260
  ? Number(options.monorepoPackageSectionPathDepth)
222
261
  : undefined,
223
262
  noMonorepoPackageSectionAuto: options.noMonorepoPackageSectionAuto,
@@ -225,19 +264,19 @@ function createProgram() {
225
264
  aiProvider: options.aiProvider,
226
265
  aiModel: options.aiModel,
227
266
  aiEndpoint: options.aiEndpoint,
228
- aiTemperature: typeof options.aiTemperature === "string"
267
+ aiTemperature: typeof options.aiTemperature === 'string'
229
268
  ? Number(options.aiTemperature)
230
269
  : undefined,
231
- aiMaxTokens: typeof options.aiMaxTokens === "string"
270
+ aiMaxTokens: typeof options.aiMaxTokens === 'string'
232
271
  ? Number(options.aiMaxTokens)
233
272
  : undefined,
234
- aiMaxModelCalls: typeof options.aiMaxCalls === "string"
273
+ aiMaxModelCalls: typeof options.aiMaxCalls === 'string'
235
274
  ? Number(options.aiMaxCalls)
236
275
  : undefined,
237
- aiBudgetTokens: typeof options.aiBudgetTokens === "string"
276
+ aiBudgetTokens: typeof options.aiBudgetTokens === 'string'
238
277
  ? Number(options.aiBudgetTokens)
239
278
  : undefined,
240
- aiMaxCandidatesPerAgent: typeof options.aiMaxCandidatesPerAgent === "string"
279
+ aiMaxCandidatesPerAgent: typeof options.aiMaxCandidatesPerAgent === 'string'
241
280
  ? Number(options.aiMaxCandidatesPerAgent)
242
281
  : undefined,
243
282
  aiInferenceScope: (0, inference_scope_1.parseAiInferenceScope)(options.aiInferenceScope),
@@ -255,15 +294,15 @@ function createProgram() {
255
294
  config.workspaceApiKey = workspaceApiKey;
256
295
  }
257
296
  const aiMode = (0, validate_scan_ai_1.resolveAiMode)(config);
258
- const usesByok = aiMode === "byok";
297
+ const usesByok = aiMode === 'byok';
259
298
  sentryScanRoot = scanEntry.scanRootDir;
260
299
  sentryAiMode = aiMode;
261
300
  sentryAiProvider = config.aiProvider;
262
301
  // Quota preflight for platform billing. Structural-only scans (AI off) do not use quota API.
263
302
  if (workspaceApiKey && !usesByok && config.enableAiInference) {
264
303
  const [{ cliScanPreflight }, { estimateScanFootprint }] = await Promise.all([
265
- Promise.resolve().then(() => __importStar(require("./platform-api/scan-quota-client"))),
266
- Promise.resolve().then(() => __importStar(require("./platform-api/estimate-scan-footprint"))),
304
+ Promise.resolve().then(() => __importStar(require('./platform-api/scan-quota-client'))),
305
+ Promise.resolve().then(() => __importStar(require('./platform-api/estimate-scan-footprint'))),
267
306
  ]);
268
307
  const footprint = await estimateScanFootprint(scanEntry.scanRootDir, config.excludePaths ?? []);
269
308
  const preflight = await cliScanPreflight({
@@ -283,8 +322,8 @@ function createProgram() {
283
322
  // budget above the configured default (or user override).
284
323
  config.aiBudgetTokens = Math.min(config.aiBudgetTokens ?? 12_000, preflight.suggestedAiBudgetTokens);
285
324
  }
286
- if (preflight.aiDelivery === "platform_proxy") {
287
- config.aiMode = "platform";
325
+ if (preflight.aiDelivery === 'platform_proxy') {
326
+ config.aiMode = 'platform';
288
327
  }
289
328
  if (isInteractive) {
290
329
  // eslint-disable-next-line no-console
@@ -293,9 +332,10 @@ function createProgram() {
293
332
  }
294
333
  else if (!workspaceApiKey &&
295
334
  !usesByok &&
335
+ aiMode !== 'hosted_worker' &&
296
336
  config.enableAiInference) {
297
337
  try {
298
- const { cliAnonymousAiSession } = await Promise.resolve().then(() => __importStar(require("./platform-api/anonymous-ai-session-client")));
338
+ const { cliAnonymousAiSession } = await Promise.resolve().then(() => __importStar(require('./platform-api/anonymous-ai-session-client')));
299
339
  const session = await cliAnonymousAiSession({
300
340
  projectName: config.projectName,
301
341
  });
@@ -307,8 +347,8 @@ function createProgram() {
307
347
  // Applying it as the working budget caused scans to burn ~100k tokens.
308
348
  config.aiBudgetTokens = Math.min(config.aiBudgetTokens ?? 12_000, session.suggestedAiBudgetTokens);
309
349
  }
310
- if (session.aiDelivery === "platform_proxy") {
311
- config.aiMode = "platform";
350
+ if (session.aiDelivery === 'platform_proxy') {
351
+ config.aiMode = 'platform';
312
352
  }
313
353
  if (isInteractive) {
314
354
  // eslint-disable-next-line no-console
@@ -316,10 +356,14 @@ function createProgram() {
316
356
  }
317
357
  }
318
358
  catch (anonSessionError) {
319
- const { CliAnonymousIpLimitError } = await Promise.resolve().then(() => __importStar(require("./platform-api/anonymous-ai-session-client")));
359
+ const { CliAnonymousIpLimitError } = await Promise.resolve().then(() => __importStar(require('./platform-api/anonymous-ai-session-client')));
320
360
  const message = anonSessionError instanceof Error
321
361
  ? anonSessionError.message
322
- : "Anonymous AI session failed.";
362
+ : 'Anonymous AI session failed.';
363
+ reportedFailure = {
364
+ code: 'anonymous_ai_session_failed',
365
+ message: (0, cli_scan_failure_report_1.truncateFailureMessage)(message),
366
+ };
323
367
  // eslint-disable-next-line no-console
324
368
  console.error(`[scan] ${message}`);
325
369
  process.exitCode =
@@ -329,29 +373,33 @@ function createProgram() {
329
373
  }
330
374
  const configValidation = (0, scan_config_schema_1.validateScanConfiguration)(config);
331
375
  if (!configValidation.ok) {
376
+ reportedFailure = {
377
+ code: 'invalid_configuration',
378
+ message: (0, cli_scan_failure_report_1.truncateFailureMessage)(configValidation.errors.join('; ')),
379
+ };
332
380
  await (0, scan_sentry_1.reportScanCliError)({
333
- error: configValidation.errors.join("\n"),
381
+ error: configValidation.errors.join('\n'),
334
382
  scanRoot: sentryScanRoot,
335
383
  jobId: cliQuotaJobId,
336
384
  aiMode: sentryAiMode,
337
385
  aiProvider: sentryAiProvider,
338
- failurePhase: "config_validation",
339
- failureCode: "invalid_configuration",
386
+ failurePhase: 'config_validation',
387
+ failureCode: 'invalid_configuration',
340
388
  });
341
389
  // eslint-disable-next-line no-console
342
- console.error(`[scan] invalid configuration:\n${configValidation.errors.map((e) => ` - ${e}`).join("\n")}`);
390
+ console.error(`[scan] invalid configuration:\n${configValidation.errors.map((e) => ` - ${e}`).join('\n')}`);
343
391
  process.exitCode = 2;
344
392
  return;
345
393
  }
346
394
  if (isInteractive && warnings.length > 0) {
347
395
  // eslint-disable-next-line no-console
348
- console.warn(`[scan] warnings:\n${warnings.map((w) => ` - ${w}`).join("\n")}`);
396
+ console.warn(`[scan] warnings:\n${warnings.map((w) => ` - ${w}`).join('\n')}`);
349
397
  }
350
- const { scanResult } = await runScanPipeline(resolvedScanRoot, config, (progress) => {
398
+ const { scanResult, redFlags } = await runScanPipeline(resolvedScanRoot, config, (progress) => {
351
399
  if (!isInteractive)
352
400
  return;
353
401
  // eslint-disable-next-line no-console
354
- console.log(`[scan] ${progress.phase}: ${progress.message ?? ""}`.trim());
402
+ console.log(`[scan] ${progress.phase}: ${progress.message ?? ''}`.trim());
355
403
  });
356
404
  if (scanResult.structuralEnrichmentSummary) {
357
405
  const st = scanResult.structuralEnrichmentSummary;
@@ -365,37 +413,45 @@ function createProgram() {
365
413
  // Always show real provider token usage (budget_cap is only a ceiling, not cost).
366
414
  // eslint-disable-next-line no-console
367
415
  console.log(`[scan] ai-usage: provider_calls=${s.providerCalls} tokens_in=${s.inputTokens} tokens_out=${s.outputTokens} tokens_total=${s.totalTokens}` +
368
- (typeof s.estimatedCostUsd === "number"
416
+ (typeof s.estimatedCostUsd === 'number'
369
417
  ? ` estimated_cost_usd=${formatUsd(s.estimatedCostUsd)}`
370
- : ""));
418
+ : ''));
371
419
  if (options.aiVerbose && scanResult.aiInferenceProposalDetails) {
372
420
  printAiInferenceVerbose(scanResult.aiInferenceProposalDetails);
373
421
  }
374
422
  }
375
423
  for (const w of scanResult.warnings ?? []) {
376
- if (w.startsWith("ai-provider:")) {
424
+ if (w.startsWith('ai-provider:')) {
377
425
  await (0, scan_sentry_1.reportScanCliError)({
378
426
  error: w,
379
427
  scanRoot: sentryScanRoot,
380
428
  jobId: cliQuotaJobId,
381
429
  aiMode: sentryAiMode,
382
430
  aiProvider: sentryAiProvider,
383
- failurePhase: "ai_provider",
384
- failureCode: "ai_provider_warning",
431
+ failurePhase: 'ai_provider',
432
+ failureCode: 'ai_provider_warning',
385
433
  });
386
434
  // eslint-disable-next-line no-console
387
435
  console.warn(`[scan] ${w}`);
388
436
  }
437
+ else if (w.startsWith('red-flag:')) {
438
+ // eslint-disable-next-line no-console
439
+ console.warn(`[scan] ${w}`);
440
+ }
389
441
  }
390
442
  if (scanResult.errors?.length) {
443
+ reportedFailure = {
444
+ code: 'scan_errors',
445
+ message: (0, cli_scan_failure_report_1.summarizeScanErrors)(scanResult.errors),
446
+ };
391
447
  await (0, scan_sentry_1.reportScanCliError)({
392
- error: scanResult.errors.join("\n"),
448
+ error: scanResult.errors.join('\n'),
393
449
  scanRoot: sentryScanRoot,
394
450
  jobId: cliQuotaJobId,
395
451
  aiMode: sentryAiMode,
396
452
  aiProvider: sentryAiProvider,
397
- failurePhase: "scan_pipeline",
398
- failureCode: "scan_errors",
453
+ failurePhase: 'scan_pipeline',
454
+ failureCode: 'scan_errors',
399
455
  extra: { errorCount: scanResult.errors.length },
400
456
  });
401
457
  process.exitCode = 1;
@@ -405,26 +461,32 @@ function createProgram() {
405
461
  diagramGraph = buildDiagramGraphFromScanResult(scanResult);
406
462
  }
407
463
  catch (graphError) {
464
+ reportedFailure = {
465
+ code: 'graph_build_failed',
466
+ message: (0, cli_scan_failure_report_1.truncateFailureMessage)(graphError instanceof Error
467
+ ? graphError.message
468
+ : 'Unknown error while building diagram graph.'),
469
+ };
408
470
  await (0, scan_sentry_1.reportScanCliError)({
409
471
  error: graphError,
410
472
  scanRoot: sentryScanRoot,
411
473
  jobId: cliQuotaJobId,
412
474
  aiMode: sentryAiMode,
413
475
  aiProvider: sentryAiProvider,
414
- failurePhase: "diagram_graph",
415
- failureCode: "graph_build_failed",
476
+ failurePhase: 'diagram_graph',
477
+ failureCode: 'graph_build_failed',
416
478
  });
417
479
  if (isInteractive) {
418
480
  const message = graphError instanceof Error
419
481
  ? graphError.message
420
- : "Unknown error while building diagram graph.";
482
+ : 'Unknown error while building diagram graph.';
421
483
  // eslint-disable-next-line no-console
422
484
  console.error(`[scan] warning: unable to build diagram graph: ${message}`);
423
485
  }
424
486
  process.exitCode = 1;
425
487
  }
426
488
  if (diagramGraph) {
427
- const dataflowOutputPath = path_1.default.resolve(process.cwd(), options.output ?? "dataflow.json");
489
+ const dataflowOutputPath = path_1.default.resolve(process.cwd(), options.output ?? 'dataflow.json');
428
490
  const resolvedProjectName = config.projectName?.trim() ||
429
491
  path_1.default.basename(scanEntry.scanRootDir);
430
492
  try {
@@ -433,6 +495,8 @@ function createProgram() {
433
495
  graph: diagramGraph,
434
496
  outputPath: dataflowOutputPath,
435
497
  projectName: resolvedProjectName,
498
+ redFlags,
499
+ gitContext: parsedGitContext,
436
500
  });
437
501
  // Always print a short message so non-interactive callers and
438
502
  // tests can rely on it.
@@ -442,84 +506,106 @@ function createProgram() {
442
506
  (0, upload_env_1.resolveSkipAutoUpload)(process.env);
443
507
  if (!skipAutoUpload) {
444
508
  try {
445
- const { runDataflowUpload } = await Promise.resolve().then(() => __importStar(require("./upload/run-upload")));
446
- const dataflowWrapper = (0, json_1.buildDataflowWrapper)(scanResult, diagramGraph, { projectName: resolvedProjectName });
509
+ const { runDataflowUpload } = await Promise.resolve().then(() => __importStar(require('./upload/run-upload')));
510
+ const dataflowWrapper = (0, json_1.buildDataflowWrapper)(scanResult, diagramGraph, {
511
+ projectName: resolvedProjectName,
512
+ redFlags,
513
+ gitContext: parsedGitContext,
514
+ });
447
515
  await runDataflowUpload({
448
516
  apiKey: workspaceApiKey,
449
517
  dataflow: dataflowWrapper,
450
518
  projectName: resolvedProjectName,
451
519
  scanJobId: cliQuotaJobId,
452
- logPrefix: "[scan]",
520
+ logPrefix: '[scan]',
453
521
  cliUsageSessionId: usageSessionId,
454
- command: "scan",
522
+ command: 'scan',
455
523
  });
456
524
  }
457
525
  catch (uploadError) {
458
526
  const uploadMessage = uploadError instanceof Error
459
527
  ? uploadError.message
460
- : "Unknown upload error.";
528
+ : 'Unknown upload error.';
461
529
  // eslint-disable-next-line no-console
462
530
  console.error(`[scan] Auto-upload failed: ${uploadMessage}`);
463
531
  }
464
532
  }
465
533
  }
466
534
  catch (dataflowError) {
535
+ reportedFailure = {
536
+ code: 'dataflow_write_failed',
537
+ message: (0, cli_scan_failure_report_1.truncateFailureMessage)(dataflowError instanceof Error
538
+ ? dataflowError.message
539
+ : 'Unknown error while writing dataflow.json.'),
540
+ };
467
541
  await (0, scan_sentry_1.reportScanCliError)({
468
542
  error: dataflowError,
469
543
  scanRoot: sentryScanRoot,
470
544
  jobId: cliQuotaJobId,
471
545
  aiMode: sentryAiMode,
472
546
  aiProvider: sentryAiProvider,
473
- failurePhase: "dataflow_output",
474
- failureCode: "dataflow_write_failed",
547
+ failurePhase: 'dataflow_output',
548
+ failureCode: 'dataflow_write_failed',
475
549
  });
476
550
  const message = dataflowError instanceof Error
477
551
  ? dataflowError.message
478
- : "Unknown error while writing dataflow.json.";
552
+ : 'Unknown error while writing dataflow.json.';
479
553
  // eslint-disable-next-line no-console
480
554
  console.error(`[scan] error: failed to write dataflow.json: ${message}`);
481
555
  process.exitCode = 1;
482
556
  }
483
557
  }
484
558
  if (platformQuotaApiKey && cliQuotaJobId) {
485
- const { cliScanComplete } = await Promise.resolve().then(() => __importStar(require("./platform-api/scan-quota-client")));
559
+ const { cliScanComplete } = await Promise.resolve().then(() => __importStar(require('./platform-api/scan-quota-client')));
486
560
  const exitFailed = (process.exitCode ?? 0) !== 0;
487
- const platformAiMode = (0, validate_scan_ai_1.resolveAiMode)(config) === "platform";
561
+ const platformAiMode = (0, validate_scan_ai_1.resolveAiMode)(config) === 'platform';
488
562
  await cliScanComplete({
489
563
  apiKey: platformQuotaApiKey,
490
564
  jobId: cliQuotaJobId,
491
- status: exitFailed ? "failed" : "completed",
565
+ status: exitFailed ? 'failed' : 'completed',
492
566
  aiTokensUsed: platformAiMode
493
567
  ? 0
494
568
  : (scanResult.aiInferenceSummary?.totalTokens ?? 0),
495
- failureCode: exitFailed ? "scan_failed" : undefined,
496
- failureMessage: exitFailed ? "CLI scan did not complete successfully" : undefined,
569
+ failureCode: exitFailed
570
+ ? (reportedFailure?.code ?? 'scan_failed')
571
+ : undefined,
572
+ failureMessage: exitFailed
573
+ ? (reportedFailure?.message ?? fallbackFailureMessage)
574
+ : undefined,
497
575
  });
498
576
  quotaCompletionReported = true;
499
577
  if (isInteractive) {
500
578
  // eslint-disable-next-line no-console
501
- console.log("[scan] Scan finished — you can start a new scan now.");
579
+ console.log('[scan] Scan finished — you can start a new scan now.');
502
580
  }
503
581
  }
504
582
  }
505
583
  catch (err) {
506
- const message = err instanceof Error ? err.message : "Unknown error during scan.";
584
+ const message = err instanceof Error ? err.message : 'Unknown error during scan.';
507
585
  fallbackFailureMessage = message;
508
- const { CliScanQuotaExceededError, CliScanAlreadyRunningError } = await Promise.resolve().then(() => __importStar(require("./platform-api/scan-quota-client")));
586
+ const { CliScanQuotaExceededError, CliScanAlreadyRunningError } = await Promise.resolve().then(() => __importStar(require('./platform-api/scan-quota-client')));
509
587
  const quotaBlocked = err instanceof CliScanQuotaExceededError;
510
588
  const scanInProgress = err instanceof CliScanAlreadyRunningError;
589
+ reportedFailure = {
590
+ code: quotaBlocked
591
+ ? 'scan_quota_exceeded'
592
+ : scanInProgress
593
+ ? 'scan_already_running'
594
+ : 'scan_exception',
595
+ message: (0, cli_scan_failure_report_1.truncateFailureMessage)(message),
596
+ };
511
597
  await (0, scan_sentry_1.reportScanCliError)({
512
598
  error: err,
513
599
  scanRoot: sentryScanRoot,
514
600
  jobId: cliQuotaJobId,
515
601
  aiMode: sentryAiMode,
516
602
  aiProvider: sentryAiProvider,
517
- failurePhase: quotaBlocked || scanInProgress ? "preflight" : "scan_command",
603
+ failurePhase: quotaBlocked || scanInProgress ? 'preflight' : 'scan_command',
518
604
  failureCode: quotaBlocked
519
- ? "scan_quota_exceeded"
605
+ ? 'scan_quota_exceeded'
520
606
  : scanInProgress
521
- ? "scan_already_running"
522
- : "scan_exception",
607
+ ? 'scan_already_running'
608
+ : 'scan_exception',
523
609
  });
524
610
  // eslint-disable-next-line no-console
525
611
  console.error(quotaBlocked
@@ -533,28 +619,34 @@ function createProgram() {
533
619
  const scanFailed = (process.exitCode ?? 0) !== 0;
534
620
  await (0, telemetry_client_1.reportCliUsageEvent)({
535
621
  sessionId: usageSessionId,
536
- event: scanFailed ? "scan_failed" : "scan_succeeded",
537
- command: "scan",
622
+ event: scanFailed ? 'scan_failed' : 'scan_succeeded',
623
+ command: 'scan',
538
624
  hasApiKey: Boolean(workspaceApiKey),
539
625
  apiKey: workspaceApiKey,
540
626
  cliVersion: package_json_1.default.version,
541
- errorCode: scanFailed ? "scan_failed" : undefined,
542
- errorMessage: scanFailed ? fallbackFailureMessage : undefined,
627
+ errorCode: scanFailed
628
+ ? (reportedFailure?.code ?? 'scan_failed')
629
+ : undefined,
630
+ errorMessage: scanFailed
631
+ ? (reportedFailure?.message ?? fallbackFailureMessage)
632
+ : undefined,
543
633
  });
544
- if (platformQuotaApiKey && cliQuotaJobId && !quotaCompletionReported) {
634
+ if (platformQuotaApiKey &&
635
+ cliQuotaJobId &&
636
+ !quotaCompletionReported) {
545
637
  try {
546
- const { cliScanComplete } = await Promise.resolve().then(() => __importStar(require("./platform-api/scan-quota-client")));
638
+ const { cliScanComplete } = await Promise.resolve().then(() => __importStar(require('./platform-api/scan-quota-client')));
547
639
  await cliScanComplete({
548
640
  apiKey: platformQuotaApiKey,
549
641
  jobId: cliQuotaJobId,
550
- status: "failed",
551
- failureCode: "scan_failed",
552
- failureMessage: fallbackFailureMessage,
642
+ status: 'failed',
643
+ failureCode: reportedFailure?.code ?? 'scan_failed',
644
+ failureMessage: reportedFailure?.message ?? fallbackFailureMessage,
553
645
  });
554
646
  quotaCompletionReported = true;
555
647
  if (isInteractive) {
556
648
  // eslint-disable-next-line no-console
557
- console.log("[scan] Scan finished — you can start a new scan now.");
649
+ console.log('[scan] Scan finished — you can start a new scan now.');
558
650
  }
559
651
  }
560
652
  catch {
@@ -564,64 +656,65 @@ function createProgram() {
564
656
  }
565
657
  });
566
658
  program
567
- .command("upload <file>")
568
- .description("Upload a dataflow.json file to the dashboard as an import preview")
569
- .option("--project-name <name>", "Assessment name shown in the preview (default: from file metadata if present)")
570
- .option("--workspace-api-key <key>", "DataParade workspace API key (env: DATAPARADE_WORKSPACE_API_KEY)")
571
- .option("--api-key <key>", "(deprecated) alias for --workspace-api-key")
659
+ .command('upload <file>')
660
+ .description('Upload a dataflow.json file to the dashboard as an import preview')
661
+ .option('--project-name <name>', 'Assessment name shown in the preview (default: from file metadata if present)')
662
+ .option('--workspace-api-key <key>', 'DataParade workspace API key (env: DATAPARADE_WORKSPACE_API_KEY)')
663
+ .option('--api-key <key>', '(deprecated) alias for --workspace-api-key')
572
664
  .action(async (file, options) => {
573
665
  const apiKey = options.workspaceApiKey?.trim() ||
574
666
  options.apiKey?.trim() ||
575
667
  (0, scan_env_1.resolveWorkspaceApiKey)(process.env);
576
668
  const usageSessionId = (0, crypto_1.randomUUID)();
577
- const filePath = path_1.default.resolve(process.cwd(), file || "dataflow.json");
669
+ const filePath = path_1.default.resolve(process.cwd(), file || 'dataflow.json');
578
670
  let dataflow;
579
671
  try {
580
- const { readFileSync } = await Promise.resolve().then(() => __importStar(require("fs")));
581
- dataflow = JSON.parse(readFileSync(filePath, "utf8"));
672
+ const { readFileSync } = await Promise.resolve().then(() => __importStar(require('fs')));
673
+ dataflow = JSON.parse(readFileSync(filePath, 'utf8'));
582
674
  }
583
675
  catch (err) {
584
- const message = err instanceof Error ? err.message : "Failed to read dataflow.json";
676
+ const message = err instanceof Error ? err.message : 'Failed to read dataflow.json';
585
677
  // eslint-disable-next-line no-console
586
678
  console.error(`[upload] error: ${message}`);
587
679
  process.exitCode = 1;
588
680
  return;
589
681
  }
590
682
  let projectName = options.projectName?.trim();
591
- if (!projectName && dataflow && typeof dataflow === "object") {
683
+ if (!projectName && dataflow && typeof dataflow === 'object') {
592
684
  const meta = dataflow
593
685
  .metadata;
594
- if (typeof meta?.projectName === "string" && meta.projectName.trim()) {
686
+ if (typeof meta?.projectName === 'string' &&
687
+ meta.projectName.trim()) {
595
688
  projectName = meta.projectName.trim();
596
689
  }
597
690
  }
598
691
  try {
599
- const { runDataflowUpload } = await Promise.resolve().then(() => __importStar(require("./upload/run-upload")));
692
+ const { runDataflowUpload } = await Promise.resolve().then(() => __importStar(require('./upload/run-upload')));
600
693
  await runDataflowUpload({
601
694
  apiKey,
602
695
  dataflow,
603
696
  projectName,
604
697
  cliUsageSessionId: usageSessionId,
605
- command: "upload",
698
+ command: 'upload',
606
699
  });
607
700
  }
608
701
  catch (err) {
609
- const message = err instanceof Error ? err.message : "Upload failed.";
702
+ const message = err instanceof Error ? err.message : 'Upload failed.';
610
703
  // eslint-disable-next-line no-console
611
704
  console.error(`[upload] error: ${message}`);
612
705
  process.exitCode = 1;
613
706
  }
614
707
  });
615
708
  program
616
- .command("config")
617
- .description("View the effective configuration for the current project")
618
- .argument("[path]", "Project directory (default: current working directory)")
709
+ .command('config')
710
+ .description('View the effective configuration for the current project')
711
+ .argument('[path]', 'Project directory (default: current working directory)')
619
712
  .action(async (pathArg) => {
620
713
  try {
621
714
  const [{ createDefaultScanConfiguration }] = await Promise.all([
622
- Promise.resolve().then(() => __importStar(require("./core/pipeline/orchestrator"))),
715
+ Promise.resolve().then(() => __importStar(require('./core/pipeline/orchestrator'))),
623
716
  ]);
624
- const rootPathArg = pathArg?.trim() || ".";
717
+ const rootPathArg = pathArg?.trim() || '.';
625
718
  const resolvedRoot = path_1.default.resolve(process.cwd(), rootPathArg);
626
719
  let configCwd = resolvedRoot;
627
720
  try {
@@ -643,9 +736,9 @@ function createProgram() {
643
736
  catch (err) {
644
737
  const message = err instanceof Error
645
738
  ? err.message
646
- : "Unknown error while loading configuration.";
739
+ : 'Unknown error while loading configuration.';
647
740
  // eslint-disable-next-line no-console
648
- console.error("Failed to read configuration:", message);
741
+ console.error('Failed to read configuration:', message);
649
742
  process.exitCode = 1;
650
743
  }
651
744
  });