@dataparade/cli 0.0.20 → 0.0.22

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 (34) hide show
  1. package/README.md +12 -10
  2. package/dist/package.json +2 -1
  3. package/dist/src/ai-enrichment/agent-orchestrator.d.ts +8 -2
  4. package/dist/src/ai-enrichment/agent-orchestrator.js +140 -70
  5. package/dist/src/ai-enrichment/provider-prompt.js +36 -2
  6. package/dist/src/cli.js +98 -51
  7. package/dist/src/config/scan-env.d.ts +5 -0
  8. package/dist/src/config/scan-env.js +12 -1
  9. package/dist/src/core/pipeline/scan-pipeline.d.ts +2 -1
  10. package/dist/src/core/pipeline/scan-pipeline.js +7 -4
  11. package/dist/src/ui/brand.d.ts +28 -0
  12. package/dist/src/ui/brand.js +72 -0
  13. package/dist/src/ui/scan-progress-renderer.d.ts +69 -0
  14. package/dist/src/ui/scan-progress-renderer.js +386 -0
  15. package/dist/src/ui/teaching-lines.d.ts +9 -0
  16. package/dist/src/ui/teaching-lines.js +144 -0
  17. package/dist/src/ui/types.d.ts +33 -0
  18. package/dist/src/ui/types.js +2 -0
  19. package/dist/src/upload/run-upload.d.ts +1 -1
  20. package/dist/src/upload/run-upload.js +21 -16
  21. package/dist/src/upload/types.d.ts +4 -0
  22. package/dist/tests/cli/cli.spec.js +77 -40
  23. package/dist/tests/unit/ai-enrichment/agent-orchestrator.spec.js +227 -147
  24. package/dist/tests/unit/ai-enrichment/provider-prompt.spec.js +35 -0
  25. package/dist/tests/unit/cli/scan-quota-flow.spec.js +9 -0
  26. package/dist/tests/unit/config/scan-env-debug.spec.js +17 -8
  27. package/dist/tests/unit/ui/brand.spec.d.ts +1 -0
  28. package/dist/tests/unit/ui/brand.spec.js +52 -0
  29. package/dist/tests/unit/ui/scan-progress-renderer.spec.d.ts +1 -0
  30. package/dist/tests/unit/ui/scan-progress-renderer.spec.js +275 -0
  31. package/dist/tests/unit/ui/teaching-lines.spec.d.ts +1 -0
  32. package/dist/tests/unit/ui/teaching-lines.spec.js +62 -0
  33. package/dist/tests/unit/upload/run-upload.spec.js +29 -27
  34. package/package.json +2 -1
package/dist/src/cli.js CHANGED
@@ -57,6 +57,7 @@ const telemetry_client_1 = require("./platform-api/telemetry-client");
57
57
  const cli_scan_failure_report_1 = require("./platform-api/cli-scan-failure-report");
58
58
  const scan_config_schema_1 = require("./core/schema/scan-config.schema");
59
59
  const scanner_1 = require("@dataparade/scanner");
60
+ const scan_progress_renderer_1 = require("./ui/scan-progress-renderer");
60
61
  function formatEvidence(detail) {
61
62
  const evidence = detail.evidence;
62
63
  if (!evidence || evidence.length === 0) {
@@ -81,25 +82,17 @@ function formatProposalTarget(detail) {
81
82
  }
82
83
  return 'unknown';
83
84
  }
84
- function printAiInferenceVerbose(details) {
85
+ function formatAiInferenceVerbose(details) {
85
86
  if (details.length === 0) {
86
- // eslint-disable-next-line no-console
87
- console.log('[scan] ai-inference details: no proposals generated');
88
- return;
87
+ return ['[scan] ai-inference details: no proposals generated'];
89
88
  }
90
- // eslint-disable-next-line no-console
91
- console.log('[scan] ai-inference details:');
89
+ const lines = ['[scan] ai-inference details:'];
92
90
  for (const detail of details) {
93
91
  const status = detail.status === 'applied'
94
92
  ? 'applied'
95
93
  : `rejected (${detail.rejectionReason})`;
96
94
  const confidence = detail.confidence.toFixed(2);
97
- // eslint-disable-next-line no-console
98
- console.log(`[scan] - ${detail.id}: ${status} | ${detail.source} | ${detail.kind} | target=${formatProposalTarget(detail)} | confidence=${confidence} (${detail.confidenceBand})`);
99
- // eslint-disable-next-line no-console
100
- console.log(`[scan] candidate=${detail.candidateType} agent=${detail.agent} provider=${detail.provider}/${detail.model}`);
101
- // eslint-disable-next-line no-console
102
- console.log(`[scan] evidence=${formatEvidence(detail)}`);
95
+ lines.push(`[scan] - ${detail.id}: ${status} | ${detail.source} | ${detail.kind} | target=${formatProposalTarget(detail)} | confidence=${confidence} (${detail.confidenceBand})`, `[scan] candidate=${detail.candidateType} agent=${detail.agent} provider=${detail.provider}/${detail.model}`, `[scan] evidence=${formatEvidence(detail)}`);
103
96
  if (detail.status === 'applied' &&
104
97
  detail.propertyChanges &&
105
98
  detail.propertyChanges.length) {
@@ -109,11 +102,11 @@ function printAiInferenceVerbose(details) {
109
102
  return `${change.key}: ${from} -> ${to}`;
110
103
  });
111
104
  for (const line of formatted) {
112
- // eslint-disable-next-line no-console
113
- console.log(`[scan] changes=${line}`);
105
+ lines.push(`[scan] changes=${line}`);
114
106
  }
115
107
  }
116
108
  }
109
+ return lines;
117
110
  }
118
111
  function formatUsd(value) {
119
112
  if (typeof value !== 'number' || !Number.isFinite(value))
@@ -169,6 +162,9 @@ function createProgram() {
169
162
  let sentryAiMode;
170
163
  let sentryAiProvider;
171
164
  const isInteractive = process.stdout.isTTY;
165
+ // True once Clack owns the terminal: raw `[scan]` lines would break its
166
+ // guide rail, so they go through the renderer or are skipped.
167
+ let friendlyTty = false;
172
168
  // Parse and validate --git-context if provided
173
169
  let parsedGitContext;
174
170
  if (options.gitContext) {
@@ -239,10 +235,19 @@ function createProgram() {
239
235
  Promise.resolve().then(() => __importStar(require('./core/pipeline/scan-pipeline'))),
240
236
  Promise.resolve().then(() => __importStar(require('./core/pipeline/graph-mapping'))),
241
237
  ]);
242
- if (isInteractive) {
243
- // eslint-disable-next-line no-console
244
- console.log(`[scan] starting scan for ${resolvedScanRoot}`);
245
- }
238
+ const progressUi = await (0, scan_progress_renderer_1.createScanProgressRenderer)({
239
+ isTTY: Boolean(isInteractive),
240
+ noColor: Boolean(typeof process.env.NO_COLOR === 'string' &&
241
+ process.env.NO_COLOR.length > 0),
242
+ projectLabel: resolvedScanRoot,
243
+ version: package_json_1.default.version,
244
+ });
245
+ progressUi.start();
246
+ friendlyTty = progressUi.usesClackChrome;
247
+ (0, scan_env_1.setScanAiDebugSuppressed)(friendlyTty && !options.aiVerbose);
248
+ // Technical meters, shown as one block after the scan (TTY) or
249
+ // printed as before (non-TTY).
250
+ const technicalLines = [];
246
251
  const flags = {
247
252
  exclude: options.exclude,
248
253
  minimumConfidence: typeof options.minimumConfidence === 'string'
@@ -327,8 +332,14 @@ function createProgram() {
327
332
  config.aiMode = 'platform';
328
333
  }
329
334
  if (isInteractive) {
330
- // eslint-disable-next-line no-console
331
- console.log(`[scan] quota: scans_remaining=${preflight.scansRemaining} ai_tokens_remaining=${preflight.aiTokensRemaining} job_id=${preflight.jobId} working_budget=${config.aiBudgetTokens ?? 0}`);
335
+ const quotaLine = `[scan] quota: scans_remaining=${preflight.scansRemaining} ai_tokens_remaining=${preflight.aiTokensRemaining} job_id=${preflight.jobId} working_budget=${config.aiBudgetTokens ?? 0}`;
336
+ if (friendlyTty) {
337
+ technicalLines.push(quotaLine);
338
+ }
339
+ else {
340
+ // eslint-disable-next-line no-console
341
+ console.log(quotaLine);
342
+ }
332
343
  }
333
344
  }
334
345
  else if (!workspaceApiKey &&
@@ -352,8 +363,14 @@ function createProgram() {
352
363
  config.aiMode = 'platform';
353
364
  }
354
365
  if (isInteractive) {
355
- // eslint-disable-next-line no-console
356
- console.log(`[scan] anonymous platform AI: job_id=${session.jobId} working_budget=${config.aiBudgetTokens ?? 0} server_cap=${session.suggestedAiBudgetTokens} (claim debits actual tokens used)`);
366
+ const sessionLine = `[scan] anonymous platform AI: job_id=${session.jobId} working_budget=${config.aiBudgetTokens ?? 0} server_cap=${session.suggestedAiBudgetTokens} (claim debits actual tokens used)`;
367
+ if (friendlyTty) {
368
+ technicalLines.push(sessionLine);
369
+ }
370
+ else {
371
+ // eslint-disable-next-line no-console
372
+ console.log(sessionLine);
373
+ }
357
374
  }
358
375
  }
359
376
  catch (anonSessionError) {
@@ -393,33 +410,50 @@ function createProgram() {
393
410
  return;
394
411
  }
395
412
  if (isInteractive && warnings.length > 0) {
396
- // eslint-disable-next-line no-console
397
- console.warn(`[scan] warnings:\n${warnings.map((w) => ` - ${w}`).join('\n')}`);
413
+ if (friendlyTty) {
414
+ for (const w of warnings)
415
+ progressUi.warn(w);
416
+ }
417
+ else {
418
+ // eslint-disable-next-line no-console
419
+ console.warn(`[scan] warnings:\n${warnings.map((w) => ` - ${w}`).join('\n')}`);
420
+ }
398
421
  }
399
422
  const { scanResult, redFlags } = await runScanPipeline(resolvedScanRoot, config, (progress) => {
400
- if (!isInteractive)
401
- return;
402
- // eslint-disable-next-line no-console
403
- console.log(`[scan] ${progress.phase}: ${progress.message ?? ''}`.trim());
423
+ progressUi.onProgress(progress);
424
+ }, (recognition) => {
425
+ progressUi.onRecognition(recognition);
404
426
  });
405
- if (scanResult.structuralEnrichmentSummary) {
427
+ if (scanResult.aiInferenceSummary) {
428
+ progressUi.onAiResult({
429
+ proposalsApplied: scanResult.aiInferenceSummary.proposalsApplied,
430
+ });
431
+ }
432
+ // Keep technical enrichment/AI meter lines out of the friendly TTY
433
+ // progress UI; still print in CI / non-TTY, or with --ai-verbose.
434
+ const showTechnicalScanMeters = !isInteractive || Boolean(options.aiVerbose);
435
+ if (showTechnicalScanMeters &&
436
+ scanResult.structuralEnrichmentSummary) {
406
437
  const st = scanResult.structuralEnrichmentSummary;
407
- // eslint-disable-next-line no-console
408
- console.log(`[scan] structural enrichment: proposals=${st.proposalsGenerated} applied=${st.proposalsApplied} rejected=${st.proposalsRejected}`);
438
+ technicalLines.push(`[scan] structural enrichment: proposals=${st.proposalsGenerated} applied=${st.proposalsApplied} rejected=${st.proposalsRejected}`);
409
439
  }
410
- if (scanResult.aiInferenceSummary) {
440
+ if (showTechnicalScanMeters && scanResult.aiInferenceSummary) {
411
441
  const s = scanResult.aiInferenceSummary;
412
- // eslint-disable-next-line no-console
413
- console.log(`[scan] llm-inference summary: candidates=${s.candidatesConsidered} proposals=${s.proposalsGenerated} (provider=${s.proposalsGeneratedProvider}) applied=${s.proposalsApplied} (provider=${s.proposalsAppliedProvider}) rejected=${s.proposalsRejected} (${s.aiProvider}/${s.aiModel})`);
442
+ technicalLines.push(`[scan] llm-inference summary: candidates=${s.candidatesConsidered} proposals=${s.proposalsGenerated} (provider=${s.proposalsGeneratedProvider}) applied=${s.proposalsApplied} (provider=${s.proposalsAppliedProvider}) rejected=${s.proposalsRejected} (${s.aiProvider}/${s.aiModel})`,
414
443
  // Always show real provider token usage (budget_cap is only a ceiling, not cost).
415
- // eslint-disable-next-line no-console
416
- console.log(`[scan] ai-usage: provider_calls=${s.providerCalls} tokens_in=${s.inputTokens} tokens_out=${s.outputTokens} tokens_total=${s.totalTokens}` +
444
+ `[scan] ai-usage: provider_calls=${s.providerCalls} tokens_in=${s.inputTokens} tokens_out=${s.outputTokens} tokens_total=${s.totalTokens}` +
417
445
  (typeof s.estimatedCostUsd === 'number'
418
446
  ? ` estimated_cost_usd=${formatUsd(s.estimatedCostUsd)}`
419
447
  : ''));
420
- if (options.aiVerbose && scanResult.aiInferenceProposalDetails) {
421
- printAiInferenceVerbose(scanResult.aiInferenceProposalDetails);
422
- }
448
+ }
449
+ if (options.aiVerbose &&
450
+ scanResult.aiInferenceSummary &&
451
+ scanResult.aiInferenceProposalDetails) {
452
+ technicalLines.push(...formatAiInferenceVerbose(scanResult.aiInferenceProposalDetails));
453
+ }
454
+ // Friendly TTY only shows the block on request (--ai-verbose).
455
+ if (!friendlyTty || options.aiVerbose) {
456
+ progressUi.showTechnicalDetails('Scan details', technicalLines);
423
457
  }
424
458
  for (const w of scanResult.warnings ?? []) {
425
459
  if (w.startsWith('ai-provider:')) {
@@ -432,12 +466,10 @@ function createProgram() {
432
466
  failurePhase: 'ai_provider',
433
467
  failureCode: 'ai_provider_warning',
434
468
  });
435
- // eslint-disable-next-line no-console
436
- console.warn(`[scan] ${w}`);
469
+ progressUi.warn(w);
437
470
  }
438
471
  else if (w.startsWith('red-flag:')) {
439
- // eslint-disable-next-line no-console
440
- console.warn(`[scan] ${w}`);
472
+ progressUi.warn(w);
441
473
  }
442
474
  }
443
475
  if (scanResult.errors?.length) {
@@ -499,10 +531,14 @@ function createProgram() {
499
531
  redFlags,
500
532
  gitContext: parsedGitContext,
501
533
  });
502
- // Always print a short message so non-interactive callers and
503
- // tests can rely on it.
504
- // eslint-disable-next-line no-console
505
- console.log(`[scan] dataflow.json written to ${dataflowOutputPath}`);
534
+ // Friendly TTY/plain progress line (additive).
535
+ progressUi.onWroteDataflow(dataflowOutputPath);
536
+ // Machine line for scripts / CI (non-TTY). The friendly TTY UI
537
+ // shows the path in its own success line instead.
538
+ if (!friendlyTty) {
539
+ // eslint-disable-next-line no-console
540
+ console.log(`[scan] dataflow.json written to ${dataflowOutputPath}`);
541
+ }
506
542
  const skipAutoUpload = Boolean(options.skipAutoUpload) ||
507
543
  (0, upload_env_1.resolveSkipAutoUpload)(process.env);
508
544
  if (!skipAutoUpload) {
@@ -513,7 +549,7 @@ function createProgram() {
513
549
  redFlags,
514
550
  gitContext: parsedGitContext,
515
551
  });
516
- await runDataflowUpload({
552
+ const uploadResult = await runDataflowUpload({
517
553
  apiKey: workspaceApiKey,
518
554
  dataflow: dataflowWrapper,
519
555
  projectName: resolvedProjectName,
@@ -521,16 +557,26 @@ function createProgram() {
521
557
  logPrefix: '[scan]',
522
558
  cliUsageSessionId: usageSessionId,
523
559
  command: 'scan',
560
+ quiet: friendlyTty,
524
561
  });
562
+ if (uploadResult.previewUrl) {
563
+ progressUi.onPreviewUrl(uploadResult.previewUrl, uploadResult.notice);
564
+ }
525
565
  }
526
566
  catch (uploadError) {
527
567
  const uploadMessage = uploadError instanceof Error
528
568
  ? uploadError.message
529
569
  : 'Unknown upload error.';
530
- // eslint-disable-next-line no-console
531
- console.error(`[scan] Auto-upload failed: ${uploadMessage}`);
570
+ if (friendlyTty) {
571
+ progressUi.warn(`Auto-upload failed: ${uploadMessage}`);
572
+ }
573
+ else {
574
+ // eslint-disable-next-line no-console
575
+ console.error(`[scan] Auto-upload failed: ${uploadMessage}`);
576
+ }
532
577
  }
533
578
  }
579
+ progressUi.finish();
534
580
  }
535
581
  catch (dataflowError) {
536
582
  reportedFailure = {
@@ -575,7 +621,8 @@ function createProgram() {
575
621
  : undefined,
576
622
  });
577
623
  quotaCompletionReported = true;
578
- if (isInteractive) {
624
+ // The Clack outro already closes the run in friendly TTY.
625
+ if (isInteractive && !friendlyTty) {
579
626
  // eslint-disable-next-line no-console
580
627
  console.log('[scan] Scan finished — you can start a new scan now.');
581
628
  }
@@ -4,5 +4,10 @@ export declare function resolveByokProvider(env: NodeJS.ProcessEnv): string | un
4
4
  export declare function resolveByokModel(env: NodeJS.ProcessEnv): string | undefined;
5
5
  export declare function resolveScanAiInference(env: NodeJS.ProcessEnv): string | undefined;
6
6
  export declare function resolveHostedInferProxyUrl(env: NodeJS.ProcessEnv): string | undefined;
7
+ /**
8
+ * Mute SCAN_AI_DEBUG logs for this run. The interactive progress UI sets this:
9
+ * raw `[dataparade-ai]` lines written mid-spinner break its layout.
10
+ */
11
+ export declare function setScanAiDebugSuppressed(suppressed: boolean): void;
7
12
  /** Extra provider HTTP / normalization logging (all providers, not OpenAI-only). */
8
13
  export declare function isScanAiDebugEnabled(env?: NodeJS.ProcessEnv): boolean;
@@ -6,6 +6,7 @@ exports.resolveByokProvider = resolveByokProvider;
6
6
  exports.resolveByokModel = resolveByokModel;
7
7
  exports.resolveScanAiInference = resolveScanAiInference;
8
8
  exports.resolveHostedInferProxyUrl = resolveHostedInferProxyUrl;
9
+ exports.setScanAiDebugSuppressed = setScanAiDebugSuppressed;
9
10
  exports.isScanAiDebugEnabled = isScanAiDebugEnabled;
10
11
  function resolveWorkspaceApiKey(env) {
11
12
  const value = env.DATAPARADE_WORKSPACE_API_KEY?.trim();
@@ -35,9 +36,19 @@ function parseTruthyEnvFlag(value) {
35
36
  if (!value)
36
37
  return false;
37
38
  const normalized = value.trim().toLowerCase();
38
- return normalized === "true";
39
+ return normalized === 'true';
40
+ }
41
+ let scanAiDebugSuppressed = false;
42
+ /**
43
+ * Mute SCAN_AI_DEBUG logs for this run. The interactive progress UI sets this:
44
+ * raw `[dataparade-ai]` lines written mid-spinner break its layout.
45
+ */
46
+ function setScanAiDebugSuppressed(suppressed) {
47
+ scanAiDebugSuppressed = suppressed;
39
48
  }
40
49
  /** Extra provider HTTP / normalization logging (all providers, not OpenAI-only). */
41
50
  function isScanAiDebugEnabled(env = process.env) {
51
+ if (scanAiDebugSuppressed)
52
+ return false;
42
53
  return parseTruthyEnvFlag(env.SCAN_AI_DEBUG);
43
54
  }
@@ -1,7 +1,8 @@
1
1
  import type { ScanConfiguration, ScanProgress } from '../types';
2
2
  import type { OrchestratorScanResult } from './orchestrator-result';
3
+ import type { ScanRecognitionPayload } from '../../ui/types';
3
4
  /**
4
5
  * Full CLI scan pipeline: deterministic structural scan, optional structural enrichment,
5
6
  * optional LLM inference, and LangSmith tracing when enabled.
6
7
  */
7
- export declare function runScanPipeline(rootPath: string, config: ScanConfiguration, onProgress?: (progress: ScanProgress) => void): Promise<OrchestratorScanResult>;
8
+ export declare function runScanPipeline(rootPath: string, config: ScanConfiguration, onProgress?: (progress: ScanProgress) => void, onRecognition?: (payload: ScanRecognitionPayload) => void): Promise<OrchestratorScanResult>;
@@ -106,7 +106,7 @@ function buildThirdPartyCoverage(input) {
106
106
  }
107
107
  return { autofilled, suggested, unknown };
108
108
  }
109
- async function runScanPipelineInner(rootPath, config, onProgress) {
109
+ async function runScanPipelineInner(rootPath, config, onProgress, onRecognition) {
110
110
  const start = Date.now();
111
111
  const warnings = [];
112
112
  const errors = [];
@@ -120,6 +120,9 @@ async function runScanPipelineInner(rootPath, config, onProgress) {
120
120
  const components = work.components;
121
121
  const dataFlows = work.dataFlows;
122
122
  const { files, findings, sections, filesScanned } = work;
123
+ // Stable recognition surface for teaching lines (findings + components after
124
+ // deterministic phases). No scanner-internal coupling beyond this payload.
125
+ onRecognition?.({ findings, components });
123
126
  const subTypesFilledEarly = (0, third_party_subtype_1.ensureThirdPartySubTypes)(components);
124
127
  if (subTypesFilledEarly > 0) {
125
128
  warnings.push(`third-party-subtype: inferred subType for ${subTypesFilledEarly} third-party component(s) from vendor/name heuristics.`);
@@ -171,7 +174,7 @@ async function runScanPipelineInner(rootPath, config, onProgress) {
171
174
  ...component,
172
175
  properties: { ...component.properties },
173
176
  }));
174
- (0, scanner_1.emitScanProgress)(onProgress, 'data_flow', 0.85, filesScanned, 'Running LLM inference...');
177
+ (0, scanner_1.emitScanProgress)(onProgress, 'ai_enrichment', 0.85, filesScanned, 'Running LLM inference...');
175
178
  const orchOptions = (0, ai_orchestrator_options_1.buildAgentOrchestratorOptions)(config, {
176
179
  llmEnabled: true,
177
180
  skipStructuralHeuristics: true,
@@ -308,11 +311,11 @@ async function runScanPipelineInner(rootPath, config, onProgress) {
308
311
  * Full CLI scan pipeline: deterministic structural scan, optional structural enrichment,
309
312
  * optional LLM inference, and LangSmith tracing when enabled.
310
313
  */
311
- async function runScanPipeline(rootPath, config, onProgress) {
314
+ async function runScanPipeline(rootPath, config, onProgress, onRecognition) {
312
315
  return (0, langsmith_tracing_1.traceDataparadeScan)({
313
316
  rootPath: rootPath.toString(),
314
317
  projectName: config.projectName,
315
318
  enableAiInference: config.enableAiInference,
316
- run: () => runScanPipelineInner(rootPath, config, onProgress),
319
+ run: () => runScanPipelineInner(rootPath, config, onProgress, onRecognition),
317
320
  });
318
321
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Compact terminal brand mark. PNG logos don't render reliably in most
3
+ * terminals, so we ship a small ASCII wordmark for TTY sessions.
4
+ *
5
+ * Upright mixed-case "DataParade". Letter gaps tuned so the second "a"
6
+ * (after "t" in Data) is not more open than the rest.
7
+ */
8
+ export declare const DATAPARADE_ASCII_LOGO: string;
9
+ export declare const DATAPARADE_TAGLINE = "Map privacy data flows from your code";
10
+ /** Below this width the figlet wraps, so we fall back to a one-line header. */
11
+ export declare const BRAND_LOGO_MIN_COLUMNS = 64;
12
+ export interface BrandHeaderOptions {
13
+ /** CLI version shown under the logo. */
14
+ version?: string;
15
+ /** When false, never emit ANSI escape codes. */
16
+ color: boolean;
17
+ /** Terminal color depth in bits (1, 4, 8, 24). */
18
+ colorDepth?: number;
19
+ /** Terminal width; undefined means "assume wide enough". */
20
+ columns?: number;
21
+ /** When false (CI / non-TTY), print only the one-line header. */
22
+ showLogo: boolean;
23
+ }
24
+ /**
25
+ * Brand header lines: teal-gradient figlet + version/tagline on wide TTYs,
26
+ * a single `DataParade vX · tagline` line otherwise.
27
+ */
28
+ export declare function renderBrandHeader(options: BrandHeaderOptions): string[];
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BRAND_LOGO_MIN_COLUMNS = exports.DATAPARADE_TAGLINE = exports.DATAPARADE_ASCII_LOGO = void 0;
4
+ exports.renderBrandHeader = renderBrandHeader;
5
+ /**
6
+ * Compact terminal brand mark. PNG logos don't render reliably in most
7
+ * terminals, so we ship a small ASCII wordmark for TTY sessions.
8
+ *
9
+ * Upright mixed-case "DataParade". Letter gaps tuned so the second "a"
10
+ * (after "t" in Data) is not more open than the rest.
11
+ */
12
+ exports.DATAPARADE_ASCII_LOGO = [
13
+ ' ____ _ ____ _',
14
+ '| _ \\ __ _ | |_ __ _ | _ \\ __ _ _ __ __ _ __| | ___',
15
+ "| | | |/ _` || __|/ _` || |_) |/ _` || '__|/ _` |/ _` | / _ \\",
16
+ '| |_| ||(_| || |_ |(_| || __/ |(_| || | |(_| ||(_| || __/',
17
+ '|____/ \\__,_| \\__|\\__,_||_| \\__,_||_| \\__,_|\\__,_| \\___|',
18
+ ].join('\n');
19
+ exports.DATAPARADE_TAGLINE = 'Map privacy data flows from your code';
20
+ /** Below this width the figlet wraps, so we fall back to a one-line header. */
21
+ exports.BRAND_LOGO_MIN_COLUMNS = 64;
22
+ // Top → bottom gradient, ending on --color-brand (#0c7377). The light end keeps
23
+ // the logo readable on dark terminals; the brand end on light ones.
24
+ const GRADIENT_FROM = [0x3f, 0xb1, 0xb5];
25
+ const GRADIENT_TO = [0x0c, 0x73, 0x77];
26
+ // xterm-256 approximations of the same ramp.
27
+ const GRADIENT_256 = [73, 73, 37, 30, 30];
28
+ const BRAND_256 = 30;
29
+ const ESC = String.fromCharCode(27);
30
+ const RESET = `${ESC}[0m`;
31
+ const BOLD = `${ESC}[1m`;
32
+ const DIM = `${ESC}[2m`;
33
+ function lerp(from, to, t) {
34
+ return [0, 1, 2].map((i) => Math.round(from[i] + (to[i] - from[i]) * t));
35
+ }
36
+ function foreground(colorDepth, rgb, ansi256) {
37
+ if (colorDepth >= 24)
38
+ return `${ESC}[38;2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
39
+ if (colorDepth >= 8)
40
+ return `${ESC}[38;5;${ansi256}m`;
41
+ return `${ESC}[36m`;
42
+ }
43
+ /**
44
+ * Brand header lines: teal-gradient figlet + version/tagline on wide TTYs,
45
+ * a single `DataParade vX · tagline` line otherwise.
46
+ */
47
+ function renderBrandHeader(options) {
48
+ const { color, version } = options;
49
+ const depth = options.colorDepth ?? 4;
50
+ const brand = color ? foreground(depth, GRADIENT_TO, BRAND_256) : '';
51
+ const bold = color ? BOLD : '';
52
+ const dim = color ? DIM : '';
53
+ const reset = color ? RESET : '';
54
+ const versionLabel = version ? `v${version}` : '';
55
+ const wide = options.columns === undefined || options.columns >= exports.BRAND_LOGO_MIN_COLUMNS;
56
+ if (!options.showLogo || !wide) {
57
+ const name = `${bold}${brand}DataParade${reset}`;
58
+ const ver = versionLabel ? ` ${dim}${versionLabel}${reset}` : '';
59
+ return [`${name}${ver} ${dim}· ${exports.DATAPARADE_TAGLINE}${reset}`];
60
+ }
61
+ const logoLines = exports.DATAPARADE_ASCII_LOGO.split('\n');
62
+ const last = logoLines.length - 1;
63
+ const lines = logoLines.map((line, i) => {
64
+ if (!color)
65
+ return line;
66
+ const rgb = lerp(GRADIENT_FROM, GRADIENT_TO, last > 0 ? i / last : 1);
67
+ return `${bold}${foreground(depth, rgb, GRADIENT_256[i] ?? BRAND_256)}${line}${reset}`;
68
+ });
69
+ const ver = versionLabel ? `${bold}${brand}${versionLabel}${reset} ` : '';
70
+ lines.push('', ` ${ver}${dim}${exports.DATAPARADE_TAGLINE}${reset}`);
71
+ return lines;
72
+ }
@@ -0,0 +1,69 @@
1
+ import type { ScanProgress } from '../core/types';
2
+ import type { ScanAiStepResult, ScanProgressRendererOptions, ScanRecognitionPayload } from './types';
3
+ type ClackPrompts = typeof import('@clack/prompts');
4
+ /**
5
+ * Make the preview URL stand out in the next-step block.
6
+ * Uses explicit CSI sequences so our colorEnabled flag wins even when
7
+ * process.env.NO_COLOR would make util.styleText a no-op.
8
+ */
9
+ export declare function formatPreviewLink(url: string, colorEnabled: boolean): string;
10
+ export declare function formatAiStepResult(result: ScanAiStepResult): string;
11
+ /** Output path relative to cwd when it lives below it, otherwise the ~ form. */
12
+ export declare function formatOutputPath(outputPath: string): string;
13
+ /** Prefer a short, human path in the header (home → ~). */
14
+ export declare function formatProjectLabel(projectPath: string): string;
15
+ /**
16
+ * Staged scan progress for TTY (Clack) and plain logs for non-TTY / NO_COLOR.
17
+ */
18
+ export declare class ScanProgressRenderer {
19
+ private readonly isTTY;
20
+ private readonly noColor;
21
+ private readonly writeLine;
22
+ private readonly useClack;
23
+ private readonly colorEnabled;
24
+ private readonly projectLabel?;
25
+ private readonly version?;
26
+ private readonly columns?;
27
+ private readonly colorDepth?;
28
+ private readonly clack;
29
+ private started;
30
+ private recognitionHandled;
31
+ private activeStep;
32
+ private spinner;
33
+ private readonly completedSteps;
34
+ private teachingSummaryLines;
35
+ private previewUrl;
36
+ private previewNotice;
37
+ constructor(options: ScanProgressRendererOptions, clack: ClackPrompts | null);
38
+ /** Test helper: true when Clack chrome is active. */
39
+ get usesClackChrome(): boolean;
40
+ start(): void;
41
+ onProgress(progress: ScanProgress): void;
42
+ onRecognition(payload: ScanRecognitionPayload): void;
43
+ /** Close the AI step with one plain-language result line. */
44
+ onAiResult(result: ScanAiStepResult): void;
45
+ onWroteDataflow(outputPath?: string): void;
46
+ /** Store preview URL for the "What to do next" note. Machine line stays in upload. */
47
+ onPreviewUrl(previewUrl: string, notice?: string): void;
48
+ /**
49
+ * Non-fatal scan warning. Clack renders it inside the guide rail; plain mode
50
+ * keeps the `[scan] …` stderr line scripts may grep for.
51
+ */
52
+ warn(message: string): void;
53
+ /**
54
+ * Technical meters (`--ai-verbose`, quota). Plain mode prints the raw lines;
55
+ * Clack folds them into one dimmed note so they don't break the guide rail.
56
+ */
57
+ showTechnicalDetails(title: string, lines: string[]): void;
58
+ finish(): void;
59
+ private transitionTo;
60
+ private completeActiveStep;
61
+ private runTeachingStep;
62
+ private prompts;
63
+ private writePlain;
64
+ }
65
+ export declare function createScanProgressRenderer(options?: Partial<ScanProgressRendererOptions>): Promise<ScanProgressRenderer>;
66
+ /** Exported for tests. */
67
+ export declare function stripAnsi(text: string): string;
68
+ export declare function hasAnsi(text: string): boolean;
69
+ export {};