@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
@@ -1 +1,9 @@
1
- export type { OrchestratorScanResult } from "@dataparade/scanner";
1
+ import type { OrchestratorScanResult as ScannerOrchestratorScanResult } from '@dataparade/scanner';
2
+ import type { ScanRedFlag } from '../../ai-enrichment/red-flags';
3
+ /**
4
+ * CLI scan result: scanner orchestrator payload plus optional connectivity RED flags
5
+ * collected after deterministic fallbacks / repair (soft gate; JSON still written).
6
+ */
7
+ export type OrchestratorScanResult = ScannerOrchestratorScanResult & {
8
+ redFlags?: ScanRedFlag[];
9
+ };
@@ -1,2 +1,2 @@
1
- export { createDefaultScanConfiguration, scan, } from "@dataparade/scanner";
2
- export type { OrchestratorScanResult } from "@dataparade/scanner";
1
+ export { createDefaultScanConfiguration, scan } from '@dataparade/scanner';
2
+ export type { OrchestratorScanResult } from './orchestrator-result';
@@ -1,5 +1,5 @@
1
- import type { ScanConfiguration, ScanProgress } from "../types";
2
- import type { OrchestratorScanResult } from "./orchestrator-result";
1
+ import type { ScanConfiguration, ScanProgress } from '../types';
2
+ import type { OrchestratorScanResult } from './orchestrator-result';
3
3
  /**
4
4
  * Full CLI scan pipeline: deterministic structural scan, optional structural enrichment,
5
5
  * optional LLM inference, and LangSmith tracing when enabled.
@@ -5,6 +5,7 @@ const ai_orchestrator_options_1 = require("./ai-orchestrator-options");
5
5
  const scanner_1 = require("@dataparade/scanner");
6
6
  const pipeline_1 = require("../../ai-enrichment/pipeline");
7
7
  const fallbacks_1 = require("../../ai-enrichment/fallbacks");
8
+ const red_flags_1 = require("../../ai-enrichment/red-flags");
8
9
  const agent_orchestrator_1 = require("../../ai-enrichment/agent-orchestrator");
9
10
  const third_party_data_flow_1 = require("../../ai-enrichment/third-party-data-flow");
10
11
  const third_party_subtype_1 = require("../../ai-enrichment/third-party-subtype");
@@ -15,8 +16,8 @@ function buildAiProposalDetails(input) {
15
16
  const beforeById = new Map(input.componentsBeforeAi.map((component) => [component.id, component]));
16
17
  return input.proposals.map(({ id, proposal }) => {
17
18
  const rejectionReason = rejectedById.get(id);
18
- const status = appliedSet.has(id) ? "applied" : "rejected";
19
- const propertyChanges = proposal.kind === "component_patch" && status === "applied"
19
+ const status = appliedSet.has(id) ? 'applied' : 'rejected';
20
+ const propertyChanges = proposal.kind === 'component_patch' && status === 'applied'
20
21
  ? Object.entries(proposal.setProperties).map(([key, to]) => ({
21
22
  key,
22
23
  from: beforeById.get(proposal.targetComponentId)?.properties?.[key],
@@ -25,9 +26,9 @@ function buildAiProposalDetails(input) {
25
26
  : undefined;
26
27
  return {
27
28
  id,
28
- source: id.startsWith("heuristic_") ? "heuristic" : "provider",
29
+ source: id.startsWith('heuristic_') ? 'heuristic' : 'provider',
29
30
  status,
30
- rejectionReason: status === "rejected" ? rejectionReason : undefined,
31
+ rejectionReason: status === 'rejected' ? rejectionReason : undefined,
31
32
  kind: proposal.kind,
32
33
  candidateType: proposal.candidateType,
33
34
  agent: proposal.agent,
@@ -35,10 +36,12 @@ function buildAiProposalDetails(input) {
35
36
  model: proposal.model,
36
37
  confidence: proposal.confidence.score,
37
38
  confidenceBand: proposal.confidence.band,
38
- targetComponentId: proposal.kind === "component_patch" ? proposal.targetComponentId : undefined,
39
- targetFlowId: proposal.kind === "flow_patch" ? proposal.targetFlowId : undefined,
40
- sourceComponentId: proposal.kind === "flow_patch" ? proposal.sourceComponentId : undefined,
41
- targetFlowComponentId: proposal.kind === "flow_patch" ? proposal.targetComponentId : undefined,
39
+ targetComponentId: proposal.kind === 'component_patch'
40
+ ? proposal.targetComponentId
41
+ : undefined,
42
+ targetFlowId: proposal.kind === 'flow_patch' ? proposal.targetFlowId : undefined,
43
+ sourceComponentId: proposal.kind === 'flow_patch' ? proposal.sourceComponentId : undefined,
44
+ targetFlowComponentId: proposal.kind === 'flow_patch' ? proposal.targetComponentId : undefined,
42
45
  evidence: proposal.evidence,
43
46
  propertyChanges,
44
47
  };
@@ -47,9 +50,9 @@ function buildAiProposalDetails(input) {
47
50
  function countRejectionsByReason(rejected, proposalById) {
48
51
  const counts = new Map();
49
52
  for (const item of rejected) {
50
- const source = proposalById.get(item.proposalId)?.id.startsWith("provider_")
51
- ? "provider"
52
- : "heuristic";
53
+ const source = proposalById.get(item.proposalId)?.id.startsWith('provider_')
54
+ ? 'provider'
55
+ : 'heuristic';
53
56
  const key = `${source}:${item.reason}`;
54
57
  counts.set(key, (counts.get(key) ?? 0) + 1);
55
58
  }
@@ -58,7 +61,7 @@ function countRejectionsByReason(rejected, proposalById) {
58
61
  function isSparse(value) {
59
62
  if (value === null || value === undefined)
60
63
  return true;
61
- if (typeof value === "string")
64
+ if (typeof value === 'string')
62
65
  return value.trim().length === 0;
63
66
  if (Array.isArray(value))
64
67
  return value.length === 0;
@@ -75,9 +78,9 @@ function buildThirdPartyCoverage(input) {
75
78
  const rejectedReasonById = new Map(input.rejectedProposalIds.map((entry) => [entry.proposalId, entry.reason]));
76
79
  for (const proposalEntry of input.proposals) {
77
80
  const proposal = proposalEntry.proposal;
78
- if (proposal.kind !== "component_patch")
81
+ if (proposal.kind !== 'component_patch')
79
82
  continue;
80
- if (proposal.candidateType !== "third_party")
83
+ if (proposal.candidateType !== 'third_party')
81
84
  continue;
82
85
  const keys = Object.keys(proposal.setProperties ?? {});
83
86
  if (keys.length === 0)
@@ -87,14 +90,14 @@ function buildThirdPartyCoverage(input) {
87
90
  incrementCounter(autofilled, key);
88
91
  continue;
89
92
  }
90
- const reason = rejectedReasonById.get(proposalEntry.id) ?? "";
91
- if (reason.startsWith("confidence_below_threshold")) {
93
+ const reason = rejectedReasonById.get(proposalEntry.id) ?? '';
94
+ if (reason.startsWith('confidence_below_threshold')) {
92
95
  for (const key of keys)
93
96
  incrementCounter(suggested, key);
94
97
  }
95
98
  }
96
99
  for (const component of input.componentsAfterAi) {
97
- if (component.type !== "third_party")
100
+ if (component.type !== 'third_party')
98
101
  continue;
99
102
  for (const [key, value] of Object.entries(component.properties ?? {})) {
100
103
  if (isSparse(value))
@@ -132,16 +135,16 @@ async function runScanPipelineInner(rootPath, config, onProgress) {
132
135
  sections,
133
136
  files,
134
137
  findings,
135
- inferenceScope: config.aiInferenceScope ?? "default",
138
+ inferenceScope: config.aiInferenceScope ?? 'default',
136
139
  plannerOptions: {
137
140
  maxModelCalls: config.aiMaxModelCalls,
138
141
  totalBudgetTokens: config.aiBudgetTokens,
139
- maxCandidatesPerAgent: (config.aiInferenceScope ?? "default") === "third_party_only"
142
+ maxCandidatesPerAgent: (config.aiInferenceScope ?? 'default') === 'third_party_only'
140
143
  ? (config.aiMaxCandidatesPerAgent ?? 0)
141
144
  : config.aiMaxCandidatesPerAgent,
142
145
  },
143
146
  };
144
- (0, scanner_1.emitScanProgress)(onProgress, "data_flow", 0.82, filesScanned, "Running structural enrichment...");
147
+ (0, scanner_1.emitScanProgress)(onProgress, 'data_flow', 0.82, filesScanned, 'Running structural enrichment...');
145
148
  const structuralInference = await (0, pipeline_1.runInferencePipeline)(plannerInputBase, {
146
149
  generateProposals: async (ctx) => (0, agent_orchestrator_1.generateAgenticProposals)({
147
150
  components: ctx.components,
@@ -163,12 +166,12 @@ async function runScanPipelineInner(rootPath, config, onProgress) {
163
166
  proposalsRejected: structuralInference.mergeResult.rejectedProposalIds.length,
164
167
  };
165
168
  if (config.enableAiInference) {
166
- warnings.push("ai-inference: .env files are excluded from scans and provider prompts for security.");
169
+ warnings.push('ai-inference: .env files are excluded from scans and provider prompts for security.');
167
170
  const componentsBeforeAi = components.map((component) => ({
168
171
  ...component,
169
172
  properties: { ...component.properties },
170
173
  }));
171
- (0, scanner_1.emitScanProgress)(onProgress, "data_flow", 0.85, filesScanned, "Running LLM inference...");
174
+ (0, scanner_1.emitScanProgress)(onProgress, 'data_flow', 0.85, filesScanned, 'Running LLM inference...');
172
175
  const orchOptions = (0, ai_orchestrator_options_1.buildAgentOrchestratorOptions)(config, {
173
176
  llmEnabled: true,
174
177
  skipStructuralHeuristics: true,
@@ -193,34 +196,34 @@ async function runScanPipelineInner(rootPath, config, onProgress) {
193
196
  properties: { ...component.properties },
194
197
  }));
195
198
  const appliedIds = inference.mergeResult.appliedProposalIds;
196
- const genP = inference.proposals.filter((p) => p.id.startsWith("provider_"));
197
- const appliedP = appliedIds.filter((id) => id.startsWith("provider_")).length;
199
+ const genP = inference.proposals.filter((p) => p.id.startsWith('provider_'));
200
+ const appliedP = appliedIds.filter((id) => id.startsWith('provider_')).length;
198
201
  warnings.push(`ai-inference: applied=${appliedIds.length} (provider=${appliedP}), rejected=${inference.mergeResult.rejectedProposalIds.length}`);
199
202
  const proposalById = new Map(inference.proposals.map((p) => [p.id, p]));
200
203
  const rejectionCounts = countRejectionsByReason(inference.mergeResult.rejectedProposalIds, proposalById);
201
- const providerTargetNotFound = rejectionCounts.get("provider:target_not_found") ?? 0;
204
+ const providerTargetNotFound = rejectionCounts.get('provider:target_not_found') ?? 0;
202
205
  if (providerTargetNotFound > 0) {
203
206
  warnings.push(`ai-provider: ${providerTargetNotFound} provider proposal(s) rejected as target_not_found (likely non-canonical targetComponentId; expected component IDs like cmp_*).`);
204
207
  }
205
- const providerEvidencePathMissing = rejectionCounts.get("provider:evidence_path_not_in_scan") ?? 0;
208
+ const providerEvidencePathMissing = rejectionCounts.get('provider:evidence_path_not_in_scan') ?? 0;
206
209
  if (providerEvidencePathMissing > 0) {
207
210
  warnings.push(`ai-provider: ${providerEvidencePathMissing} provider proposal(s) rejected due to evidence_path_not_in_scan.`);
208
211
  }
209
212
  const providerConfidenceRejected = [...rejectionCounts.entries()]
210
- .filter(([k]) => k.startsWith("provider:confidence_below_threshold:"))
213
+ .filter(([k]) => k.startsWith('provider:confidence_below_threshold:'))
211
214
  .reduce((acc, [, n]) => acc + n, 0);
212
215
  if (providerConfidenceRejected > 0) {
213
216
  warnings.push(`ai-provider: ${providerConfidenceRejected} provider proposal(s) rejected by confidence thresholds.`);
214
217
  }
215
218
  if (genP.length === 0) {
216
219
  warnings.push([
217
- "ai-provider: zero LLM proposals were accepted after inference.",
218
- "Check workspace API key, BYOK credentials, network, and SCAN_AI_MAX_TOKENS for large prompts.",
219
- "Set SCAN_AI_DEBUG=true to log provider HTTP status and parse/normalization details.",
220
- ].join(" "));
220
+ 'ai-provider: zero LLM proposals were accepted after inference.',
221
+ 'Check workspace API key, BYOK credentials, network, and SCAN_AI_MAX_TOKENS for large prompts.',
222
+ 'Set SCAN_AI_DEBUG=true to log provider HTTP status and parse/normalization details.',
223
+ ].join(' '));
221
224
  }
222
225
  else if (genP.length > 0 && appliedP === 0) {
223
- warnings.push("ai-provider: proposals were returned but none passed validation/merge (evidence paths, confidence, or thresholds).");
226
+ warnings.push('ai-provider: proposals were returned but none passed validation/merge (evidence paths, confidence, or thresholds).');
224
227
  }
225
228
  aiInferenceSummary = {
226
229
  ran: true,
@@ -232,7 +235,9 @@ async function runScanPipelineInner(rootPath, config, onProgress) {
232
235
  proposalsAppliedHeuristic: 0,
233
236
  proposalsGeneratedProvider: genP.length,
234
237
  proposalsAppliedProvider: appliedP,
235
- aiProvider: orchOptions.platformProxy ? "dataparade" : orchOptions.provider,
238
+ aiProvider: orchOptions.platformProxy
239
+ ? 'dataparade'
240
+ : orchOptions.provider,
236
241
  aiModel: orchOptions.model,
237
242
  providerCalls: inference.usageSummary?.providerCalls ?? 0,
238
243
  inputTokens: inference.usageSummary?.inputTokens ?? 0,
@@ -259,6 +264,13 @@ async function runScanPipelineInner(rootPath, config, onProgress) {
259
264
  const fallbackResult = (0, fallbacks_1.applyDeterministicInferenceFallbacks)(components, dataFlows);
260
265
  components.splice(0, components.length, ...fallbackResult.components);
261
266
  let finalizedFlows = fallbackResult.dataFlows;
267
+ const redFlagPass = (0, red_flags_1.applyConnectivityRedFlagPass)(components, finalizedFlows);
268
+ components.splice(0, components.length, ...redFlagPass.components);
269
+ finalizedFlows = redFlagPass.dataFlows;
270
+ const redFlags = redFlagPass.redFlags;
271
+ for (const flag of redFlags) {
272
+ warnings.push((0, red_flags_1.formatRedFlagWarning)(flag));
273
+ }
262
274
  const subTypesFilledLate = (0, third_party_subtype_1.ensureThirdPartySubTypes)(components);
263
275
  if (subTypesFilledLate > 0) {
264
276
  warnings.push(`third-party-subtype: filled subType for ${subTypesFilledLate} third-party component(s) after inference.`);
@@ -290,7 +302,7 @@ async function runScanPipelineInner(rootPath, config, onProgress) {
290
302
  }),
291
303
  };
292
304
  }
293
- return result;
305
+ return { ...result, redFlags };
294
306
  }
295
307
  /**
296
308
  * Full CLI scan pipeline: deterministic structural scan, optional structural enrichment,
@@ -1,4 +1,18 @@
1
- import { z } from "zod";
1
+ import { z } from 'zod';
2
+ /**
3
+ * Git repository context for evidence linking.
4
+ * Enables converting file paths in evidence to clickable GitHub/GitLab URLs.
5
+ */
6
+ export declare const gitContextSchema: z.ZodObject<{
7
+ provider: z.ZodEnum<{
8
+ github: "github";
9
+ gitlab: "gitlab";
10
+ }>;
11
+ repository: z.ZodString;
12
+ commitSha: z.ZodString;
13
+ baseUrl: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strip>;
15
+ export type GitContextSchema = z.infer<typeof gitContextSchema>;
2
16
  export declare const dataflowMetadataSchema: z.ZodObject<{
3
17
  componentsCount: z.ZodOptional<z.ZodNumber>;
4
18
  dataFlowsCount: z.ZodOptional<z.ZodNumber>;
@@ -14,6 +28,15 @@ export declare const dataflowMetadataSchema: z.ZodObject<{
14
28
  jsonInputPath: z.ZodOptional<z.ZodString>;
15
29
  jsonFindingsMerged: z.ZodNumber;
16
30
  }, z.core.$strict>>;
31
+ gitContext: z.ZodOptional<z.ZodObject<{
32
+ provider: z.ZodEnum<{
33
+ github: "github";
34
+ gitlab: "gitlab";
35
+ }>;
36
+ repository: z.ZodString;
37
+ commitSha: z.ZodString;
38
+ baseUrl: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>>;
17
40
  }, z.core.$loose>;
18
41
  export declare const dataflowWrapperSchema: z.ZodObject<{
19
42
  schemaVersion: z.ZodString;
@@ -69,6 +92,15 @@ export declare const dataflowWrapperSchema: z.ZodObject<{
69
92
  jsonInputPath: z.ZodOptional<z.ZodString>;
70
93
  jsonFindingsMerged: z.ZodNumber;
71
94
  }, z.core.$strict>>;
95
+ gitContext: z.ZodOptional<z.ZodObject<{
96
+ provider: z.ZodEnum<{
97
+ github: "github";
98
+ gitlab: "gitlab";
99
+ }>;
100
+ repository: z.ZodString;
101
+ commitSha: z.ZodString;
102
+ baseUrl: z.ZodOptional<z.ZodString>;
103
+ }, z.core.$strip>>;
72
104
  }, z.core.$loose>>;
73
105
  }, z.core.$strip>;
74
106
  export type DataflowMetadataSchema = z.infer<typeof dataflowMetadataSchema>;
@@ -1,13 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dataflowWrapperSchema = exports.dataflowMetadataSchema = void 0;
3
+ exports.dataflowWrapperSchema = exports.dataflowMetadataSchema = exports.gitContextSchema = void 0;
4
4
  exports.parseDataflowJson = parseDataflowJson;
5
5
  exports.validateDataflowJson = validateDataflowJson;
6
6
  const zod_1 = require("zod");
7
7
  const diagram_graph_schema_1 = require("./diagram-graph.schema");
8
+ /**
9
+ * Git repository context for evidence linking.
10
+ * Enables converting file paths in evidence to clickable GitHub/GitLab URLs.
11
+ */
12
+ exports.gitContextSchema = zod_1.z.object({
13
+ /** Git provider: github or gitlab */
14
+ provider: zod_1.z.enum(['github', 'gitlab']),
15
+ /** Repository in "owner/repo" format */
16
+ repository: zod_1.z.string().min(1),
17
+ /** Resolved commit SHA (40 character hex string) */
18
+ commitSha: zod_1.z.string().regex(/^[a-f0-9]{40}$/i, 'Must be a 40-character SHA'),
19
+ /** Base URL for self-hosted instances (e.g., "https://gitlab.mycompany.com"). Defaults to public GitHub/GitLab. */
20
+ baseUrl: zod_1.z.string().url().optional(),
21
+ });
8
22
  const terraformMetadataSchema = zod_1.z
9
23
  .object({
10
- mode: zod_1.z.enum(["static_tf", "json_overlay", "json_only"]),
24
+ mode: zod_1.z.enum(['static_tf', 'json_overlay', 'json_only']),
11
25
  staticTfFiles: zod_1.z.number().int().nonnegative(),
12
26
  jsonInputPath: zod_1.z.string().optional(),
13
27
  jsonFindingsMerged: zod_1.z.number().int().nonnegative(),
@@ -20,6 +34,8 @@ exports.dataflowMetadataSchema = zod_1.z
20
34
  filesScanned: zod_1.z.number().int().nonnegative().optional(),
21
35
  scanDurationMs: zod_1.z.number().int().nonnegative().optional(),
22
36
  terraform: terraformMetadataSchema.optional(),
37
+ /** Git repository context for evidence linking (GitHub/GitLab URLs) */
38
+ gitContext: exports.gitContextSchema.optional(),
23
39
  })
24
40
  .passthrough();
25
41
  exports.dataflowWrapperSchema = zod_1.z.object({
@@ -33,7 +49,7 @@ function parseDataflowJson(input) {
33
49
  function validateDataflowJson(input) {
34
50
  const result = exports.dataflowWrapperSchema.safeParse(input);
35
51
  if (!result.success) {
36
- const errors = result.error.issues.map((issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`);
52
+ const errors = result.error.issues.map((issue) => `${issue.path.join('.') || '<root>'}: ${issue.message}`);
37
53
  return { ok: false, errors };
38
54
  }
39
55
  return { ok: true, value: result.data };
@@ -1,6 +1,7 @@
1
- import type { DiagramGraphJsonSchema } from "../core/schema";
2
- import { type DataflowWrapperSchema } from "../core/schema/dataflow-wrapper.schema";
3
- import type { ScanResult } from "../core/types";
1
+ import type { DiagramGraphJsonSchema } from '../core/schema';
2
+ import { type DataflowWrapperSchema, type GitContextSchema } from '../core/schema/dataflow-wrapper.schema';
3
+ import type { ScanResult } from '../core/types';
4
+ import type { ScanRedFlag } from '../ai-enrichment/red-flags';
4
5
  export interface BuildDataflowWrapperOptions {
5
6
  /**
6
7
  * Optional schema version to embed in the wrapper.
@@ -12,6 +13,16 @@ export interface BuildDataflowWrapperOptions {
12
13
  schemaVersion?: string;
13
14
  /** Assessment / project name shown in the dashboard import preview. */
14
15
  projectName?: string;
16
+ /**
17
+ * Connectivity RED flags from the CLI soft gate (after repair).
18
+ * Written under `metadata.redFlags` (passthrough metadata schema).
19
+ */
20
+ redFlags?: ScanRedFlag[];
21
+ /**
22
+ * Git repository context for evidence linking.
23
+ * When provided, enables converting evidence file paths to clickable GitHub/GitLab URLs.
24
+ */
25
+ gitContext?: GitContextSchema;
15
26
  }
16
27
  /**
17
28
  * Assemble the top-level `dataflow.json` wrapper object from a scan result and graph.
@@ -39,6 +50,10 @@ export interface WriteDataflowJsonOptions {
39
50
  schemaVersion?: string;
40
51
  /** Assessment / project name stored in wrapper metadata for upload and preview. */
41
52
  projectName?: string;
53
+ /** Optional connectivity RED flags for `metadata.redFlags`. */
54
+ redFlags?: ScanRedFlag[];
55
+ /** Git repository context for evidence linking. */
56
+ gitContext?: GitContextSchema;
42
57
  }
43
58
  /**
44
59
  * Validate and write a `dataflow.json` wrapper to disk.
@@ -14,7 +14,7 @@ const dataflow_wrapper_schema_1 = require("../core/schema/dataflow-wrapper.schem
14
14
  * just constructs a value that can then be validated and written by callers.
15
15
  */
16
16
  function buildDataflowWrapper(scanResult, graph, options = {}) {
17
- const schemaVersion = options.schemaVersion ?? "1.0";
17
+ const schemaVersion = options.schemaVersion ?? '1.0';
18
18
  const projectName = options.projectName?.trim();
19
19
  const metadata = {
20
20
  componentsCount: scanResult.components.length,
@@ -28,7 +28,14 @@ function buildDataflowWrapper(scanResult, graph, options = {}) {
28
28
  scanResult.aiInferenceSummary;
29
29
  }
30
30
  if (scanResult.terraformScanSummary) {
31
- metadata.terraform = scanResult.terraformScanSummary;
31
+ metadata.terraform =
32
+ scanResult.terraformScanSummary;
33
+ }
34
+ if (options.redFlags && options.redFlags.length > 0) {
35
+ metadata.redFlags = options.redFlags;
36
+ }
37
+ if (options.gitContext) {
38
+ metadata.gitContext = options.gitContext;
32
39
  }
33
40
  return {
34
41
  schemaVersion,
@@ -49,16 +56,18 @@ function buildDataflowWrapper(scanResult, graph, options = {}) {
49
56
  * can emit a non-zero exit code.
50
57
  */
51
58
  function writeDataflowJson(options) {
52
- const { scanResult, graph, outputPath, schemaVersion, projectName } = options;
59
+ const { scanResult, graph, outputPath, schemaVersion, projectName, redFlags, gitContext, } = options;
53
60
  const wrapper = buildDataflowWrapper(scanResult, graph, {
54
61
  schemaVersion,
55
62
  projectName,
63
+ redFlags,
64
+ gitContext,
56
65
  });
57
66
  const validation = (0, dataflow_wrapper_schema_1.validateDataflowJson)(wrapper);
58
67
  if (!validation.ok) {
59
- const messages = validation.errors.join("; ");
68
+ const messages = validation.errors.join('; ');
60
69
  throw new Error(`Invalid dataflow.json wrapper: ${messages}`);
61
70
  }
62
71
  const json = JSON.stringify(validation.value, null, 2);
63
- fs_1.default.writeFileSync(outputPath, json, "utf8");
72
+ fs_1.default.writeFileSync(outputPath, json, 'utf8');
64
73
  }
@@ -0,0 +1,9 @@
1
+ /** Failure detail reported to the platform so the dashboard can explain what broke. */
2
+ export type CliScanFailureReport = {
3
+ code: string;
4
+ message: string;
5
+ };
6
+ /** Collapses whitespace and caps length so the message stays readable in the activity feed. */
7
+ export declare function truncateFailureMessage(message: string): string;
8
+ /** Reports the first scan error plus how many others followed it. */
9
+ export declare function summarizeScanErrors(errors: string[]): string;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.truncateFailureMessage = truncateFailureMessage;
4
+ exports.summarizeScanErrors = summarizeScanErrors;
5
+ const MAX_FAILURE_MESSAGE_CHARS = 300;
6
+ /** Collapses whitespace and caps length so the message stays readable in the activity feed. */
7
+ function truncateFailureMessage(message) {
8
+ const normalized = message.replace(/\s+/g, ' ').trim();
9
+ if (normalized.length <= MAX_FAILURE_MESSAGE_CHARS)
10
+ return normalized;
11
+ return `${normalized.slice(0, MAX_FAILURE_MESSAGE_CHARS - 1)}…`;
12
+ }
13
+ /** Reports the first scan error plus how many others followed it. */
14
+ function summarizeScanErrors(errors) {
15
+ const cleaned = errors.map((error) => error.trim()).filter(Boolean);
16
+ if (cleaned.length === 0)
17
+ return 'The scanner reported errors.';
18
+ const remaining = cleaned.length - 1;
19
+ const suffix = remaining > 0
20
+ ? ` (+${remaining} more error${remaining > 1 ? 's' : ''})`
21
+ : '';
22
+ return truncateFailureMessage(`${cleaned[0]}${suffix}`);
23
+ }