@dataparade/cli 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,617 +1,82 @@
1
- # Overview
1
+ # dataPARADE CLI
2
2
 
3
- The **dataPARADE CLI** scans a codebase and produces a **`dataflow.json`-compatible** output file that can be imported into the DataParade web app.
4
- It runs a structural pipeline (ingest → analyzers → classifier → data-flow detector → graph mapping) and writes a single JSON wrapper containing a `DiagramGraphJson` plus basic scan metadata.
3
+ The **dataPARADE CLI** (`@dataparade/cli`) scans a codebase and produces a **`dataflow.json`** file you can import into the DataParade web app. It runs a structural pipeline (ingest → analyzers → classifier → data-flow detector → graph mapping) and writes a JSON wrapper containing a `DiagramGraphJson` plus scan metadata.
5
4
 
6
- - **Package name**: `@dataparade/cli`
7
5
  - **Primary command**: `scan <path>`
8
- - **Entry point (local)**: `dist/bin/cli.js`
9
- - **Supported languages in P0.1**: TypeScript, JavaScript, Python, Terraform
6
+ - **Supported languages**: TypeScript, JavaScript, Python, Terraform
7
+ - **License**: GPL-3.0-or-later see [`LICENSE`](./LICENSE). Source: [DataParade-io/dataparade-cli](https://github.com/DataParade-io/dataparade-cli)
10
8
 
11
- Java and Go analyzers are planned for a future phase.
12
-
13
- **License:** GPL-3.0-or-later — see [`LICENSE`](./LICENSE). Published source lives in [DataParade-io/dataparade-cli](https://github.com/DataParade-io/dataparade-cli) (public); this monorepo copy is for development.
14
-
15
- For releases, see [`docs/cli/RELEASING.md`](../docs/cli/RELEASING.md).
9
+ **Full documentation:** [app.dataparade.com/docs/cli-import-and-zip](https://app.dataparade.com/docs/cli-import-and-zip)
16
10
 
17
11
  ---
18
12
 
19
- ## Local development in this monorepo
20
-
21
- From the **repo root** (`dataPARADE/`):
22
-
23
- ```bash
24
- pnpm install
25
- ```
26
-
27
- Then build the CLI package:
13
+ ## Quick start
28
14
 
29
15
  ```bash
30
- cd cli
31
- pnpm build
32
- ```
33
-
34
- To **refresh Terraform resource coverage** from CDKTF packages (mirroring HashiCorp **`aws_*`** and **`azurerm_*`** resource names in `.tf` files), run:
35
-
36
- ```bash
37
- cd cli
38
- pnpm run generate:terraform-provider-hints
39
- ```
40
-
41
- That rewrites:
42
-
43
- - `cli/patterns/aws-terraform-catalog.snapshot.json` + `aws-terraform-service-hints.generated.json` (merged before the generic `^aws_` rule).
44
- - `cli/patterns/azure-terraform-catalog.snapshot.json` + `azure-terraform-service-hints.generated.json` (merged before `^azurerm_`).
45
- - `cli/patterns/kubernetes-terraform-catalog.snapshot.json` + `kubernetes-terraform-service-hints.generated.json` (merged before `^kubernetes_`).
46
-
47
- Use `pnpm run generate:aws-terraform-hints`, `pnpm run generate:azure-terraform-hints`, or `pnpm run generate:kubernetes-terraform-hints` to regenerate one provider only. Environment variables `CDKTF_PROVIDER_TGZ` / `CDKTF_PROVIDER_AZURERM_TGZ` / `CDKTF_PROVIDER_KUBERNETES_TGZ` can point at local `.tgz` files instead of `npm pack`.
48
-
49
- After a successful build, you can see the CLI help:
50
-
51
- ```bash
52
- node dist/bin/cli.js --help
16
+ npx @dataparade/cli scan .
53
17
  ```
54
18
 
55
- ---
56
-
57
- ## Quickstart: scan a project
58
-
59
- The easiest way to sanity-check the CLI is to run it against a small project directory.
60
-
61
- From the **`cli/`** directory, after building:
19
+ Or with pnpm:
62
20
 
63
21
  ```bash
64
- cd cli
65
- pnpm build
66
- node dist/bin/cli.js scan .
22
+ pnpm dlx @dataparade/cli scan .
67
23
  ```
68
24
 
69
25
  **What to expect:**
70
26
 
71
- - The CLI prints progress messages such as:
72
- - `[scan] starting scan for .`
73
- - `[scan] ingest: Ingesting files from . ...`
74
- - `[scan] analyze: Running analyzers on ... files...`
75
- - `[scan] data_flow: Detecting data flows...`
76
- - `[scan] output: Scan complete.`
77
- - When the diagram graph is successfully built and written, it prints a final line similar to:
78
- - `[scan] dataflow.json written to /absolute/path/to/dataflow.json`
79
- - A file named `dataflow.json` is created in the **current working directory** (unless you override the output path).
80
-
81
- You can point the scanner at any other path:
27
+ - Progress messages such as `[scan] starting scan for .` and `[scan] output: Scan complete.`
28
+ - On success: `[scan] dataflow.json written to /absolute/path/to/dataflow.json`
29
+ - By default, `dataflow.json` is created in the **current working directory** (override with `-o` / `--output`).
82
30
 
83
31
  ```bash
84
- node dist/bin/cli.js scan path/to/your/project
32
+ npx @dataparade/cli scan path/to/your/project --output scan-my-project-dataflow.json
85
33
  ```
86
34
 
35
+ List commands and options: `npx @dataparade/cli --help` and `npx @dataparade/cli scan --help`.
36
+
87
37
  ---
88
38
 
89
39
  ## Upload to dashboard
90
40
 
91
- After a scan, the CLI **auto-uploads** `dataflow.json` when `DATAPARADE_WORKSPACE_API_KEY` is set (from **Workspace → Access keys**). This creates an **import preview draft** in the web app — not a finished assessment. Open the printed URL to review and edit before creating the diagram.
41
+ After a scan, the CLI **auto-uploads** `dataflow.json` when `DATAPARADE_WORKSPACE_API_KEY` is set (from **Workspace → Access keys**). This creates an **import preview draft** in the web app — not a finished assessment.
92
42
 
93
43
  - Opt out: `--skip-auto-upload` or `DATAPARADE_SKIP_AUTO_UPLOAD=true`
94
- - Without a workspace key, the scan still succeeds; the CLI suggests running `upload` later
95
- - Upload alone does **not** consume scan quota (platform AI scans still use preflight/complete as before)
44
+ - Without a workspace key, the scan still succeeds; run `upload` later
45
+ - Upload alone does **not** consume scan quota
96
46
 
97
47
  ```bash
98
- # Upload an existing file
99
- node dist/bin/cli.js upload ./dataflow.json --project-name "My service"
48
+ npx @dataparade/cli upload ./dataflow.json --project-name "My service"
100
49
  ```
101
50
 
102
- Environment:
103
-
104
- | Variable | Purpose |
105
- |----------|---------|
106
- | `DATAPARADE_WORKSPACE_API_KEY` | Auth for upload (same key as platform AI) |
107
- | `DATAPARADE_API_BASE_URL` | Backend API (default: production AWS) |
108
- | `DATAPARADE_APP_URL` | Frontend base for preview links (default: production app) |
109
- | `DATAPARADE_SKIP_AUTO_UPLOAD` | Skip post-scan upload when `true`/`1` |
51
+ **Full guide:** [Upload to dashboard](https://app.dataparade.com/docs/cli-import-and-zip/upload)
110
52
 
111
53
  ---
112
54
 
113
55
  ## Output: `dataflow.json`
114
56
 
115
- By default (no `--output` flag), the CLI writes `./dataflow.json` in the current working directory.
116
-
117
- - The file is a **wrapper** containing:
118
- - `schemaVersion` (currently `"1.0"`)
119
- - `graph`: a `DiagramGraphJson` (nodes, edges, viewport)
120
- - `metadata`: basic scan statistics (files scanned, duration, etc.)
121
- - The `graph` section is compatible with the existing import flow; you can treat it like any other `DiagramGraphJson` template.
122
-
123
- ### Which properties are filled
124
-
125
- The CLI emits **all** Engineering, Privacy, and Security property keys (from the DataParade property models) so the import UI can show every field. **Only a subset are set from code/config**; the rest are `null` or empty and are intended for the user to complete in the Preview & Edit step.
126
-
127
- **Third-party / external API (from pattern detection):**
128
-
129
- - Filled when we detect an external API (e.g. Auth0, Stripe): `integration_method`, `authentication_method`, `integration_status`, `vendor`, `documentation_url` (known doc URLs), `code_reference_package` (known npm package names), `api_type`, `sdk_available`, `https_enforced`.
130
- - `service_url_api_endpoint` is set when the detector saw a request URL (e.g. `fetch('https://...')`); otherwise `null`.
131
- - `api_version` only when the finding carries it (e.g. from code); otherwise `null`.
132
-
133
- **Other patterns (env, config, database, auth, routes):**
134
-
135
- - Env/config: `cloud_provider`, `region_location`, `encrypt_at_rest`, `connection_encryption`, `data_retention_period_days`, etc. when matching env or config keys.
136
- - Database: `connection_encryption`, `backup_frequency`, `audit_logging_enabled`, etc. when patterns match.
137
- - Auth: `mfa_required`, `authentication_method`, `sso_integration` from auth middleware patterns.
138
- - Routes: `request_validation`, `api_type`, `https_enforced` for route patterns.
139
- - Data flow edges (graph mapping): `engineering.protocol` is set to `rest` or `graphql` for `api_call` flows when the endpoint, method, or source code indicates HTTP REST vs GraphQL (see `infer-data-flow-protocol.ts`). Pattern rules in `property.patterns.yaml` also set `api_type` to `graphql` for `/graphql` URLs and paths.
140
-
141
- **Terraform / IaC (`.tf` / `.tfvars`):**
142
-
143
- - Structural resource/data/module/provider detection and **reference-based** edges between resources (see `cli/patterns/terraform.md`).
144
- - **Provider topology** (same pass as for TypeScript): after scan, **`applyDeterministicInferenceFallbacks`** applies `provider-topology.rules.yaml` so e.g. **Amazon Web Services** connects to managed service nodes such as **Aws S3**, **Aws Lambda**, and **Aws Pg** with `managed_by_provider` / `managed_service_key` where rules match. Other resources still attach to the declared `provider` with a generic edge from that fallback pass.
145
- - For **stable, reproducible** Terraform-only diagrams in tests or CI, set **`SCAN_AI_INFERENCE=false`** so optional AI merge does not reshape components.
146
-
147
- **Privacy and Security:**
148
-
149
- - Most Privacy and Security fields (e.g. `data_categories_received`, `compliance_certifications`, `risk_rating`, `last_assessment_date`) are **not** inferred from code; they stay `null` and are for manual or future AI enrichment.
57
+ By default, the CLI writes `./dataflow.json` in the current working directory.
150
58
 
151
- See `cli/src/classifier/enhance-defaults.ts` for the full default template and `DETECTABLE_PROPERTY_KEYS`, and `cli/src/analyzers/shared/property-inference.ts` for what is set from findings.
59
+ - **Wrapper** with `schemaVersion`, `graph` (`DiagramGraphJson`: nodes, edges, viewport), and `metadata` (files scanned, duration, etc.)
60
+ - The `graph` section is compatible with the DataParade import flow
61
+ - Most node properties are emitted with `null` defaults; only a subset are filled from code patterns — complete the rest in Preview & Edit
152
62
 
153
- Example usage with an explicit output path:
154
-
155
- ```bash
156
- # Writes ./dataflow.json in the current directory
157
- node dist/bin/cli.js scan .
158
-
159
- # Writes ./scan-my-project-dataflow.json instead
160
- node dist/bin/cli.js scan path/to/your/project --output scan-my-project-dataflow.json
161
- ```
63
+ **Full guide:** [Output and results](https://app.dataparade.com/docs/cli-import-and-zip/output)
162
64
 
163
65
  ---
164
66
 
165
- ## Configuration & flags
166
-
167
- The CLI supports configuration via **flags**, a **project config file**, and **environment variables**.
168
-
169
- - **Flags (scan command)**
170
- - `-o, --output <file>`: write the `dataflow.json` wrapper to the given file (defaults to `./dataflow.json` in the current working directory).
171
- - `--exclude <pattern...>`: one or more glob patterns to exclude from scanning (merged with built-in defaults; see **Default excludes** below).
172
- - `--minimum-confidence <number>`: minimum detection confidence between `0` and `1`.
173
- - `--language <language...>`: limit scanning to specific languages (e.g. `typescript`, `javascript`, `python`, `terraform`).
174
- - `--terraform-json <path>`: merge resource addresses from a saved `terraform show -json` file (relative to the scan root, or absolute if the resolved path stays **inside** the scan root).
175
- - `--terraform-plan <path>`: run `terraform show -json <path>` from the scan root and merge addresses (requires `terraform` on `PATH`; plan path is relative to scan root).
176
- - `--project-name <name>`: override the inferred project name used for the main application asset.
177
- - `--deep-analysis`: enable deeper, potentially slower, structural analysis where supported.
178
-
179
- - **Config file (`dataparade.config.json`)**
180
- - Optional JSON file in the current working directory:
181
-
182
- ```json
183
- {
184
- "projectName": "my-service",
185
- "excludePaths": ["node_modules", "dist", ".git"],
186
- "minimumConfidence": 0.6,
187
- "enableAPIDetection": true,
188
- "enableDatabaseDetection": true,
189
- "enableDataFlowDetection": true
190
- }
191
-
192
- ```
193
-
194
- - Unknown or invalid fields cause a clear error when running the CLI.
195
-
196
- - **Environment variables**
197
- - `DATAPARADE_EXCLUDES`: comma-separated exclude patterns (e.g. `node_modules,dist,.git`).
198
- - `DATAPARADE_MIN_CONFIDENCE`: minimum detection confidence between `0` and `1`.
199
- - AI inference variables (see **AI inference / enrichment** below): `SCAN_AI_INFERENCE`, `SCAN_BYOK_PROVIDER`, `SCAN_BYOK_MODEL`, `SCAN_BYOK_API_KEY`, `SCAN_AI_ENDPOINT`, token and budget controls.
200
-
201
- **Precedence rules:**
67
+ ## Documentation
202
68
 
203
- - CLI flags override env/config.
204
- - Environment variables override the config file for overlapping fields.
205
- - The config file overrides built-in defaults.
206
-
207
- **Default excludes (always applied during ingest):**
208
-
209
- In addition to directory skips (`node_modules`, `.git`, test trees, etc.), these file globs are excluded unless you deliberately narrow excludes (they are prepended to `excludePaths`):
210
-
211
- - `**/.env`, `**/.env.*`, `.env`, `.env.*` — secret-bearing env files are not scanned and are never embedded in AI provider prompts.
212
- - Common test/story spec patterns (`*.spec.ts`, `*.test.ts`, `*.stories.*`, Playwright config, etc.) — see `cli/src/patterns/scan-exclusions.ts`.
213
-
214
- **`dataparade config` command:**
215
-
216
- Prints the effective scan configuration as JSON. Optional project path: `dataparade config [path]` (default: current working directory). When `[path]` is a file, config loads from that file’s parent directory (same as `scan`). When `SCAN_BYOK_API_KEY` or config `aiApiKey` is set, the printed value is **`<redacted>`** so keys do not leak into logs.
217
-
218
- ### Config fields reference
219
-
220
- `dataparade.config.json` supports the following scan fields:
221
-
222
- - `projectName` (`string`, optional): override inferred application/project label.
223
- - `excludePaths` (`string[]`, optional): glob-like excludes.
224
- - `minimumConfidence` (`number`, optional): confidence threshold in `[0, 1]`.
225
- - `enableAPIDetection` (`boolean`, optional): include API-route/auth detections.
226
- - `enableDatabaseDetection` (`boolean`, optional): include DB detections.
227
- - `enableDataFlowDetection` (`boolean`, optional): run flow detection and rewiring.
228
- - `languages` (`("typescript" | "javascript" | "json" | "yaml" | "env" | "python" | "terraform")[]`, optional): language allow-list. Note: `.env` files are **excluded from default ingest** even when `env` is listed; use `process.env.*` patterns in source files instead.
229
- - `terraformJsonPath` (`string`, optional): same as `--terraform-json` (merge saved `terraform show -json` output; path must resolve under the scan root).
230
- - `terraformPlanPath` (`string`, optional): same as `--terraform-plan` (run `terraform show -json` on the given plan file from scan root; path must resolve **under** the scan root).
231
- - **Terraform stack sections (on by default):** when the scan root contains HCL `*.tf` files and `terraformStackSectionPathDepth` is unset, the CLI **infers** path depth `N` from `main.tf` layout and registers matching directories as service sections (Terraform findings are tagged there instead of `root`). No config or flags required for typical monorepos (e.g. Twenty `packages/twenty-docker/k8s/terraform` at depth **4**).
232
- - **Monorepo package sections (on by default):** default workspace depth is **2** (`packages/twenty-server`, `packages/twenty-apps`, …). Override with `monorepoPackageSectionPathDepth` or `--monorepo-package-section-path-depth` (e.g. **3** for one hub per `packages/twenty-apps/<app>`). Set `autoInferMonorepoPackageSectionPathDepth: false` and omit depth to infer from layout only.
233
- - `terraformStackSectionPathDepth` (`number`, optional): **override** inferred depth with a fixed `N` (exactly `N` POSIX path segments from scan root). Example: `terraform/deployments/my-service` → `3`; or scan from `terraform/deployments` with **`1`** for one section per child stack.
234
- - `autoInferTerraformStackSectionPathDepth` (`boolean`, optional, default **true**): set **`false`** in config or pass **`--no-terraform-stack-section-auto`** to disable Terraform-only sections entirely.
235
- - `deepAnalysis` (`boolean`, optional): enable deeper analyzer heuristics.
236
- - `enableAiInference` (`boolean`, optional): enable post-scan AI inference.
237
- - `aiProvider` (`"openai" | "anthropic" | "gemini" | "openrouter" | "local" | "mock"`, optional): model provider.
238
- - `aiModel` (`string`, optional): model identifier sent to provider.
239
- - `aiEndpoint` (`string`, optional): override provider endpoint URL.
240
- - `aiTemperature` (`number`, optional): temperature in `[0, 2]`.
241
- - `aiMaxTokens` (`number`, optional): max output tokens requested per call.
242
- - `aiMaxModelCalls` (`number`, optional): max provider calls per planned queue.
243
- - `aiBudgetTokens` (`number`, optional): estimated token budget per planned queue.
244
- - `aiMaxCandidatesPerAgent` (`number`, optional): per-agent queue cap (`0` means unlimited).
245
- - `aiProviderConcurrency` (`number`, optional): max in-flight provider calls for batched (non-`tpAgent`) enrichment queues (default **4**). Platform-billed scans (`DATAPARADE_WORKSPACE_API_KEY`) always use **1** because the hosted API HTTP gateway times out at **30s** per request.
246
- - `aiInferenceScope` (`"default" | "third_party_only"`, optional): constrain inference scope.
247
- - `aiVerbose` (`boolean`, optional): print per-proposal AI details (same as `--ai-verbose`).
69
+ | Topic | Link |
70
+ |-------|------|
71
+ | CLI hub (all topics) | [CLI Run and Export](https://app.dataparade.com/docs/cli-import-and-zip) |
72
+ | Scan arguments & flags | [Scan arguments](https://app.dataparade.com/docs/cli-import-and-zip/scan-arguments) |
73
+ | `dataparade.config.json` | [Config file](https://app.dataparade.com/docs/cli-import-and-zip/config-file) |
74
+ | Environment variables | [Environment variables](https://app.dataparade.com/docs/cli-import-and-zip/environment-variables) |
75
+ | AI inference | [AI inference](https://app.dataparade.com/docs/cli-import-and-zip/ai-inference) |
76
+ | Scan patterns (YAML) | [Scan patterns](https://app.dataparade.com/docs/cli-import-and-zip/scan-patterns) |
248
77
 
249
78
  ---
250
79
 
251
- ## AI inference / enrichment
252
-
253
- The CLI includes an optional **post-scan AI inference pipeline** that proposes metadata enrichments for detected components and flows.
254
- If not enabled, scans remain fully structural/pattern-based and make **no AI provider calls**.
255
-
256
- ### Security (open-source defaults)
257
-
258
- - **Explicit opt-in:** AI inference runs only when you set `--ai-inference`, `SCAN_AI_INFERENCE=true`, or `"enableAiInference": true` in config. Setting provider/model/API key alone does **not** enable AI.
259
- - **`.env` files:** Excluded from default ingest (`**/.env`, `**/.env.*`) and never embedded in provider prompts. Scanning a **single** `.env` file path is also skipped with a security warning.
260
- - **Custom endpoints:** `SCAN_AI_ENDPOINT` / `--ai-endpoint` can point to any HTTPS URL; prompts include bounded code excerpts from scanned files—only enable AI on codebases you would share with that endpoint.
261
- - **Terraform plan/state:** `--terraform-plan` and `--terraform-json` paths must stay under the scan root. Treat plan/state JSON as sensitive; the CLI merges resource addresses, not secret values from state.
262
- - **LangSmith:** When tracing is enabled, uploads are **summary-only** (counts and ids); trace failures never fail the scan.
263
- - **`dataparade config`:** Prints `aiApiKey` as `<redacted>` when configured.
264
- - **HTTP timeouts:** Platform-billed AI uses async infer tasks (submit + poll). Default wait is **180s** per call (`SCAN_AI_HTTP_TIMEOUT_MS`). Poll interval is ~1.5s between status checks.
265
- - **Evidence paths:** Provider proposals must cite exact repo-relative file paths present in the scan (no fuzzy suffix matching).
266
-
267
- ### How to enable
268
-
269
- Use either flags or env/config:
270
-
271
- - Flag: `--ai-inference`
272
- - Env: `SCAN_AI_INFERENCE=true`
273
- - Config file: `"enableAiInference": true`
274
-
275
- Example:
276
-
277
- ```bash
278
- node dist/bin/cli.js scan . --ai-inference --ai-provider openai --ai-model gpt-4o-mini
279
- ```
280
-
281
- ### Workspace scan quota (platform AI)
282
-
283
- When you use **platform billing** instead of BYOK:
284
-
285
- 1. Set `SCAN_AI_INFERENCE=true` (or `--ai-inference`).
286
- 2. Set `DATAPARADE_WORKSPACE_API_KEY` (or `--workspace-api-key`) from **Workspace → Access keys** in the app.
287
- 3. Optionally set `DATAPARADE_API_BASE_URL` for local backend dev (default targets the deployed API).
288
-
289
- The CLI calls **preflight** before scanning, runs LLM inference through the DataParade API (async infer tasks), then **complete** to report success or failure. Usage counts toward the workspace **scan slot** and **platform AI token** pools (see docs-site **Workspace scan quotas**).
290
-
291
- | Mode | Quota API | LLM |
292
- |------|-----------|-----|
293
- | Structural only (no `SCAN_AI_INFERENCE`) | No — even if a workspace key is set | Local heuristics only |
294
- | BYOK (`SCAN_BYOK_*`) | No | Your provider |
295
- | Platform (`DATAPARADE_WORKSPACE_API_KEY` + AI on) | Preflight + complete; tokens per infer | DataParade API proxy |
296
-
297
- If preflight fails, the CLI prints `[scan] workspace quota: …` (for example `No scan slots remaining in this workspace.`) and exits without scanning.
298
-
299
- ### Supported providers (presets)
300
-
301
- `--ai-provider` selects a **preset** (same names as before). Each preset maps to an **API family** — how the CLI formats HTTP requests — not a separate TypeScript class per vendor:
302
-
303
- | Preset | API family | Default endpoint |
304
- |--------|------------|------------------|
305
- | `openai` | Chat Completions | `https://api.openai.com/v1/chat/completions` |
306
- | `openrouter` | Chat Completions (OpenAI-compatible) | `https://openrouter.ai/api/v1/chat/completions` |
307
- | `anthropic` | Messages | `https://api.anthropic.com/v1/messages` |
308
- | `gemini` | `generateContent` | Google Generative Language API (`…/models/<model>:generateContent`) |
309
- | `local` | Ollama `generate` | `http://localhost:11434/api/generate` |
310
- | `mock` | (no HTTP) | testing / structural-only |
311
-
312
- All families return the same **proposal JSON** shape; `strictParseAndNormalizeProposals` merges patches the same way regardless of preset. Swap vendors with one flag plus `aiModel` / `SCAN_BYOK_API_KEY` — no code changes.
313
-
314
- Preset definitions live in `cli/src/ai-enrichment/providers/presets.ts`. Adding a future vendor (e.g. another OpenAI-compatible host) is a new preset row pointing at an existing family, not a new adapter class.
315
-
316
- Use `--ai-provider <preset>` or `SCAN_BYOK_PROVIDER`.
317
-
318
- ### Common AI options
319
-
320
- Flags:
321
-
322
- - `--ai-provider <provider>`
323
- - `--ai-model <model>`
324
- - `--ai-endpoint <url>`
325
- - `--ai-temperature <number>`
326
- - `--ai-max-tokens <number>`
327
- - `--ai-max-calls <number>`
328
- - `--ai-budget-tokens <number>`
329
- - `--ai-max-candidates-per-agent <number>`
330
- - `--ai-inference-scope <scope>` where scope is `default` or `third_party_only`:
331
- - `default`: runs the full AI enrichment flow (all supported candidate types, including third-party-related and other eligible entities/properties).
332
- - `third_party_only`: limits AI enrichment to third-party nodes only (skips non-third-party enrichment work).
333
- - `--ai-verbose`: print per-proposal apply/reject details with evidence snippets
334
-
335
- Note: API key input is environment-variable based (`SCAN_BYOK_API_KEY`) and does not currently have a CLI flag.
336
-
337
- `--ai-verbose` can also be set in `dataparade.config.json` as `"aiVerbose": true` or via `SCAN_AI_VERBOSE=true`.
338
-
339
- Environment variables:
340
-
341
- - `SCAN_AI_INFERENCE` (**required** to enable inference; provider/model/key alone are not enough)
342
- - `SCAN_BYOK_PROVIDER` (unknown values log a warning and are ignored)
343
- - `SCAN_BYOK_MODEL`
344
- - `SCAN_BYOK_API_KEY`
345
- - `SCAN_AI_ENDPOINT`
346
- - `SCAN_AI_TEMPERATURE`
347
- - `SCAN_AI_MAX_TOKENS`
348
- - `SCAN_AI_MAX_CALLS`
349
- - `SCAN_AI_BUDGET_TOKENS`
350
- - `SCAN_AI_PROVIDER_CONCURRENCY`
351
- - `SCAN_AI_MAX_CANDIDATES_PER_AGENT`
352
- - `SCAN_AI_INFERENCE_SCOPE`
353
- - `SCAN_AI_TOOL_LOOP_MAX_ROUNDS`
354
- - `SCAN_AI_TOOL_LOOP_MAX_FILES`
355
- - `SCAN_AI_TOOL_LOOP_MAX_SEARCHES`
356
- - `SCAN_AI_HTTP_TIMEOUT_MS` (provider HTTP timeout in milliseconds; default `120000`)
357
- - `SCAN_AI_VERBOSE` (enable per-proposal AI logging; same as `--ai-verbose` / `"aiVerbose": true`)
358
-
359
- ### Provider endpoint defaults and overrides
360
-
361
- `SCAN_AI_ENDPOINT` is the shared endpoint override for all AI providers.
362
- When unset, each provider uses a built-in default:
363
-
364
- - `openai`: `https://api.openai.com/v1/chat/completions`
365
- - `openrouter`: `https://openrouter.ai/api/v1/chat/completions` (use `aiModel` like `openai/gpt-4o-mini` or `anthropic/claude-sonnet-4`)
366
- - `anthropic`: `https://api.anthropic.com/v1/messages`
367
- - `gemini`: `https://generativelanguage.googleapis.com/v1beta/models/<model>:generateContent`
368
- - If you provide a base models URL in `SCAN_AI_ENDPOINT` (for example `.../v1beta/models`), the CLI appends `/<model>:generateContent`.
369
- - `local`: `http://localhost:11434/api/generate` (Ollama)
370
-
371
- Example local override:
372
-
373
- ```bash
374
- SCAN_AI_INFERENCE=true
375
- SCAN_BYOK_PROVIDER=local
376
- SCAN_BYOK_MODEL="llama3.1"
377
- SCAN_AI_ENDPOINT="http://YOUR_HOST:11434/api/generate"
378
- ```
379
-
380
- OpenAI debugging/response-shape toggles:
381
-
382
- - `SCAN_AI_DEBUG`
383
- - `DATAPARADE_AI_OPENAI_JSON_SCHEMA`
384
- - `DATAPARADE_AI_OPENAI_JSON_SCHEMA_STRICT`
385
-
386
- ### Inference scope (`SCAN_AI_INFERENCE_SCOPE`)
387
-
388
- This controls **where AI enrichment is allowed to run** during a scan.
389
-
390
- - `default`
391
- - Runs the normal/full inference scope.
392
- - AI can generate proposals for all supported enrichment candidates (not just third parties).
393
- - Use this when you want the most complete enrichment output.
394
-
395
- - `third_party_only`
396
- - Restricts inference to `third_party` nodes only.
397
- - Skips non-third-party AI enrichment candidates.
398
- - Use this when you only care about third-party enrichment, or want to reduce cost/time.
399
-
400
- Examples:
401
-
402
- ```bash
403
- # Full/default AI scope
404
- SCAN_AI_INFERENCE_SCOPE=default
405
-
406
- # Only enrich third-party nodes
407
- SCAN_AI_INFERENCE_SCOPE=third_party_only
408
- ```
409
-
410
- ### What you see at runtime
411
-
412
- When enabled, scan progress includes `Running AI inference pipeline...`, and the CLI prints an end-of-run summary like:
413
-
414
- ```text
415
- [scan] ai-inference summary: candidates=... proposals=... applied=... rejected=... (provider/model)
416
- ```
417
-
418
- With `--ai-verbose`, the CLI also prints one line per proposal showing:
419
-
420
- - whether it was `applied` or `rejected` (and reject reason),
421
- - proposal kind and target (`component_patch`/`flow_patch`),
422
- - confidence band, candidate type, agent, provider/model,
423
- - top evidence reference (`file:start-end`) and reason.
424
-
425
- If provider calls fail or proposals are rejected, warnings are emitted with troubleshooting hints (for example API key/model/network checks and `SCAN_AI_DEBUG=true`).
426
-
427
- ### Budget and call limits
428
-
429
- - `--ai-max-calls` / `SCAN_AI_MAX_CALLS`: maximum provider calls for each planned queue.
430
- - `--ai-budget-tokens` / `SCAN_AI_BUDGET_TOKENS`: queue token budget gate (estimated from prompt size + requested output tokens) used to stop additional provider calls when budget is exhausted.
431
- - `SCAN_AI_PROVIDER_CONCURRENCY`: max in-flight provider calls for third-party enrichment (`tpAgent`).
432
- Use this to batch calls in waves (for example, `SCAN_AI_MAX_CALLS=24` and `SCAN_AI_PROVIDER_CONCURRENCY=3` runs up to 24 total calls, with up to 3 at a time).
433
- - `SCAN_AI_TOOL_LOOP_MAX_ROUNDS` (default `3`): max iterative provider rounds per third-party candidate in the orchestrator loop.
434
- - `SCAN_AI_TOOL_LOOP_MAX_FILES` (default `48`): max distinct files kept in per-candidate `filesReviewed` context.
435
- - `SCAN_AI_TOOL_LOOP_MAX_SEARCHES` (default `12`): max seeded search terms per third-party candidate before provider rounds.
436
-
437
- ### Orchestrator tool-loop controls (third-party)
438
-
439
- These variables tune the bounded tpAgent loop (`seed_files -> search_text -> provider_infer -> expand_imports -> finalize`):
440
-
441
- - `SCAN_AI_TOOL_LOOP_MAX_ROUNDS`
442
- - Higher value can improve coverage for hard nodes, but increases latency/cost.
443
- - Lower value (for example `1`) is useful for format/debug passes.
444
- - `SCAN_AI_TOOL_LOOP_MAX_FILES`
445
- - Controls how many files can be included in candidate memory and provider prompt context.
446
- - Lowering reduces prompt size and cost; raising may improve evidence coverage.
447
- - `SCAN_AI_TOOL_LOOP_MAX_SEARCHES`
448
- - Caps deterministic keyword searches used to discover related files.
449
- - Lowering reduces exploration breadth and runtime noise.
450
-
451
- Example:
452
-
453
- ```bash
454
- SCAN_AI_INFERENCE_SCOPE=third_party_only
455
- SCAN_AI_MAX_CALLS=4
456
- SCAN_AI_TOOL_LOOP_MAX_ROUNDS=2
457
- SCAN_AI_TOOL_LOOP_MAX_FILES=32
458
- SCAN_AI_TOOL_LOOP_MAX_SEARCHES=8
459
- ```
460
-
461
- ### Security & privacy notes
462
-
463
- - Scan failures (structural errors, AI provider warnings, config validation, uncaught exceptions) are reported to **Sentry** from the CLI process (`scan_error_source=cli`), including **BYOK** scans that never call the workspace API. Disable with `SCAN_SENTRY_ENABLED=false` or override `SENTRY_DSN` in `cli/.env` (see `.env.example`).
464
- - AI inference uses snippets/context from scanned files to generate enrichment proposals (never from `.env` files, including single-file `.env` scan paths).
465
- - The CLI strips raw source snippet payloads from final `dataflow.json` graph output (file path and line ranges remain).
466
- - `dataflow.json` still writes to your local output path; AI inference only affects which inferred properties are populated.
467
- - When inference is enabled, the scan emits a warning that `.env` files are excluded from ingest and provider prompts.
468
- - Cloud providers without `SCAN_BYOK_API_KEY` log a warning and return no provider proposals.
469
- - Invalid merged configuration (for example `NaN` from bad numeric flags) fails the scan before ingest with exit code **2**.
470
- - Only `.env` / `.env.*` are excluded by default; other credential files (for example `*.pem`, `secrets.yaml`) are **not**—exclude them with `--exclude` if needed.
471
-
472
- ---
473
-
474
- ## Additional examples
475
-
476
- Run the scanner against the CLI package itself:
477
-
478
- ```bash
479
- cd cli
480
- pnpm build
481
- node dist/bin/cli.js scan .
482
- ```
483
-
484
- From the repo root, using the package filter:
485
-
486
- ```bash
487
- pnpm --filter @dataparade/cli exec node dist/bin/cli.js scan .
488
- ```
489
-
490
- Inspect the effective configuration for the current working directory (API keys redacted in output):
491
-
492
- ```bash
493
- cd cli
494
- node dist/bin/cli.js config
495
- ```
496
-
497
- For a project under scan, run `config` from that directory or compare with flags/env documented above; `scan` loads `dataparade.config.json` from the **scan root**, not necessarily from where you invoke `config`.
498
-
499
- These flows are useful for regression-testing changes to ingest, analyzers, graph mapping, and configuration.
500
-
501
- ---
502
-
503
- ## Runtime guarantees and failure behavior
504
-
505
- ### Deterministic output
506
-
507
- The scanner stabilizes ordering and deduplication in classifier and data-flow phases so repeated scans of the same codebase produce the same logical `graph.nodes` / `graph.edges` output (assuming unchanged inputs/config).
508
-
509
- ### Output safety (no raw source leakage)
510
-
511
- When mapping scan results to `dataflow.json`, raw snippet payloads such as `sourceLocation.code` are stripped from graph payloads. Source locations keep file path and line ranges only.
512
-
513
- ### Warning vs error semantics
514
-
515
- - **Warnings** are non-fatal (e.g., parser diagnostics, malformed manifests, manifest budget cutoffs). The scan continues and may still write output.
516
- - **Errors** in `scanResult.errors` indicate validation or pipeline problems and cause a non-zero CLI exit status.
517
-
518
- ### Manifest scanning performance budgets
519
-
520
- Dependency manifest scanners apply defensive limits to avoid worst-case traversals:
521
-
522
- - max manifest files scanned,
523
- - max total manifest bytes scanned,
524
- - max individual manifest file size.
525
-
526
- When a limit is hit, scanning stops early for manifest discovery and emits warnings; this is non-fatal.
527
-
528
- ### Exit codes
529
-
530
- `dataparade scan` returns:
531
-
532
- - `0` when scan and output writing complete without fatal conditions.
533
- - non-zero (currently `1`) when any fatal condition occurs, including:
534
- - `scanResult.errors` is non-empty,
535
- - graph construction fails,
536
- - output file writing fails.
537
-
538
- ---
539
-
540
- ## Notes & future work
541
-
542
- - The CLI supports structural scanning and optional AI inference with OpenAI, Anthropic, Gemini, Local (Ollama), and Mock providers.
543
- - Higher-level commands (such as `push`) are planned follow-up work.
544
-
545
- ### Running the scanner
546
-
547
- Run the CLI against the CLI package itself:
548
-
549
- ```bash
550
- node dist/bin/cli.js scan .
551
- ```
552
-
553
- This will run the scanner and write a **dataflow wrapper JSON** file:
554
-
555
- - By default (no `--output` flag), the CLI writes `./dataflow.json` in the **current working directory**.
556
- - You can override the path with `-o, --output <file>`.
557
-
558
- Example:
559
-
560
- ```bash
561
- # Writes ./dataflow.json in the current directory
562
- node dist/bin/cli.js scan .
563
-
564
- # Writes ./scan-my-project-dataflow.json instead
565
- node dist/bin/cli.js scan path/to/your/project --output scan-my-project-dataflow.json
566
- ```
567
-
568
- The output file has the shape:
569
-
570
- ```json
571
- {
572
- "schemaVersion": "1.0",
573
- "graph": {
574
- "nodes": [/* DiagramNode[] */],
575
- "edges": [/* DiagramEdge[] */],
576
- "viewport": { "x": 0, "y": 0, "zoom": 1 }
577
- },
578
- "metadata": {
579
- "componentsCount": 0,
580
- "dataFlowsCount": 0,
581
- "filesScanned": 0,
582
- "scanDurationMs": 0
583
- }
584
- }
585
- ```
586
-
587
- You can load `graph` directly into the DataParade import flow as a `DiagramGraphJson`.
588
-
589
- ---
590
-
591
- ## Using from another project (npm)
592
-
593
- Install as a dev dependency (pnpm):
594
-
595
- ```bash
596
- pnpm add -D @dataparade/cli
597
- ```
598
-
599
- or with npm:
600
-
601
- ```bash
602
- npm install --save-dev @dataparade/cli
603
- ```
604
-
605
- Then invoke it via:
606
-
607
- ```bash
608
- npx @dataparade/cli scan .
609
- ```
610
-
611
- or with pnpm:
612
-
613
- ```bash
614
- pnpm dlx @dataparade/cli scan .
615
- ```
80
+ ## License
616
81
 
617
- The `scan` command behavior described above reflects the current implementation.
82
+ GPL-3.0-or-later · Source: [github.com/DataParade-io/dataparade-cli](https://github.com/DataParade-io/dataparade-cli)
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataparade/cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "dataPARADE CLI — scan codebases for privacy and security data flows",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "license": "GPL-3.0-or-later",
10
10
  "author": "DataParade",
11
- "homepage": "https://github.com/DataParade-io/dataparade-cli#readme",
11
+ "homepage": "https://app.dataparade.com/docs/cli-import-and-zip",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "git+https://github.com/DataParade-io/dataparade-cli.git"
package/dist/src/cli.js CHANGED
@@ -371,11 +371,14 @@ function createProgram() {
371
371
  }
372
372
  if (diagramGraph) {
373
373
  const dataflowOutputPath = path_1.default.resolve(process.cwd(), options.output ?? "dataflow.json");
374
+ const resolvedProjectName = config.projectName?.trim() ||
375
+ path_1.default.basename(scanEntry.scanRootDir);
374
376
  try {
375
377
  (0, json_1.writeDataflowJson)({
376
378
  scanResult,
377
379
  graph: diagramGraph,
378
380
  outputPath: dataflowOutputPath,
381
+ projectName: resolvedProjectName,
379
382
  });
380
383
  // Always print a short message so non-interactive callers and
381
384
  // tests can rely on it.
@@ -392,11 +395,11 @@ function createProgram() {
392
395
  else {
393
396
  try {
394
397
  const { runDataflowUpload } = await Promise.resolve().then(() => __importStar(require("./upload/run-upload")));
395
- const dataflowWrapper = (0, json_1.buildDataflowWrapper)(scanResult, diagramGraph);
398
+ const dataflowWrapper = (0, json_1.buildDataflowWrapper)(scanResult, diagramGraph, { projectName: resolvedProjectName });
396
399
  await runDataflowUpload({
397
400
  apiKey: uploadApiKey,
398
401
  dataflow: dataflowWrapper,
399
- projectName: config.projectName,
402
+ projectName: resolvedProjectName,
400
403
  scanJobId: cliQuotaJobId,
401
404
  logPrefix: "[scan]",
402
405
  });
@@ -10,6 +10,8 @@ export interface BuildDataflowWrapperOptions {
10
10
  * dataflow.json schema version.
11
11
  */
12
12
  schemaVersion?: string;
13
+ /** Assessment / project name shown in the dashboard import preview. */
14
+ projectName?: string;
13
15
  }
14
16
  /**
15
17
  * Assemble the top-level `dataflow.json` wrapper object from a scan result and graph.
@@ -35,6 +37,8 @@ export interface WriteDataflowJsonOptions {
35
37
  * Optional schema version to pass through to `buildDataflowWrapper`.
36
38
  */
37
39
  schemaVersion?: string;
40
+ /** Assessment / project name stored in wrapper metadata for upload and preview. */
41
+ projectName?: string;
38
42
  }
39
43
  /**
40
44
  * Validate and write a `dataflow.json` wrapper to disk.
@@ -15,11 +15,13 @@ const dataflow_wrapper_schema_1 = require("../core/schema/dataflow-wrapper.schem
15
15
  */
16
16
  function buildDataflowWrapper(scanResult, graph, options = {}) {
17
17
  const schemaVersion = options.schemaVersion ?? "1.0";
18
+ const projectName = options.projectName?.trim();
18
19
  const metadata = {
19
20
  componentsCount: scanResult.components.length,
20
21
  dataFlowsCount: scanResult.dataFlows.length,
21
22
  filesScanned: scanResult.filesScanned,
22
23
  scanDurationMs: scanResult.scanDurationMs,
24
+ ...(projectName ? { projectName } : {}),
23
25
  };
24
26
  if (scanResult.aiInferenceSummary) {
25
27
  metadata.aiInference =
@@ -47,8 +49,11 @@ function buildDataflowWrapper(scanResult, graph, options = {}) {
47
49
  * can emit a non-zero exit code.
48
50
  */
49
51
  function writeDataflowJson(options) {
50
- const { scanResult, graph, outputPath, schemaVersion } = options;
51
- const wrapper = buildDataflowWrapper(scanResult, graph, { schemaVersion });
52
+ const { scanResult, graph, outputPath, schemaVersion, projectName } = options;
53
+ const wrapper = buildDataflowWrapper(scanResult, graph, {
54
+ schemaVersion,
55
+ projectName,
56
+ });
52
57
  const validation = (0, dataflow_wrapper_schema_1.validateDataflowJson)(wrapper);
53
58
  if (!validation.ok) {
54
59
  const messages = validation.errors.join("; ");
@@ -2,6 +2,6 @@
2
2
  * Default DataParade web app (frontend Lambda URL). Used when the CLI prints
3
3
  * dashboard preview links. Override with DATAPARADE_APP_URL for local dev.
4
4
  */
5
- export declare const DEFAULT_DATAPARADE_APP_URL = "https://tse3dlzv73va5vycctveedw27i0xwncj.lambda-url.us-east-1.on.aws";
5
+ export declare const DEFAULT_DATAPARADE_APP_URL = "https://app.dataparade.io";
6
6
  /** Resolve web app origin (no trailing slash). */
7
7
  export declare function getDataparadeAppBaseUrl(env?: NodeJS.ProcessEnv): string;
@@ -6,7 +6,7 @@ exports.getDataparadeAppBaseUrl = getDataparadeAppBaseUrl;
6
6
  * Default DataParade web app (frontend Lambda URL). Used when the CLI prints
7
7
  * dashboard preview links. Override with DATAPARADE_APP_URL for local dev.
8
8
  */
9
- exports.DEFAULT_DATAPARADE_APP_URL = "https://tse3dlzv73va5vycctveedw27i0xwncj.lambda-url.us-east-1.on.aws";
9
+ exports.DEFAULT_DATAPARADE_APP_URL = "https://app.dataparade.io";
10
10
  /** Resolve web app origin (no trailing slash). */
11
11
  function getDataparadeAppBaseUrl(env = process.env) {
12
12
  const base = env.DATAPARADE_APP_URL?.trim() || exports.DEFAULT_DATAPARADE_APP_URL;
@@ -16,7 +16,9 @@ describe("output/json - DP-P0-CLI-403", () => {
16
16
  const config = (0, orchestrator_1.createDefaultScanConfiguration)();
17
17
  const { scanResult } = await (0, orchestrator_1.scan)(fixturesRoot, config);
18
18
  const graph = (0, graph_mapping_1.buildDiagramGraphFromScanResult)(scanResult);
19
- const wrapper = (0, json_1.buildDataflowWrapper)(scanResult, graph);
19
+ const wrapper = (0, json_1.buildDataflowWrapper)(scanResult, graph, {
20
+ projectName: "typescript-basic",
21
+ });
20
22
  const validation = (0, dataflow_wrapper_schema_1.validateDataflowJson)(wrapper);
21
23
  expect(validation.ok).toBe(true);
22
24
  if (!validation.ok) {
@@ -26,6 +28,7 @@ describe("output/json - DP-P0-CLI-403", () => {
26
28
  expect(validation.value.metadata?.dataFlowsCount).toBe(scanResult.dataFlows.length);
27
29
  expect(validation.value.metadata?.filesScanned).toBe(scanResult.filesScanned);
28
30
  expect(validation.value.metadata?.scanDurationMs).toBe(scanResult.scanDurationMs);
31
+ expect(validation.value.metadata?.projectName).toBe("typescript-basic");
29
32
  const outputPath = path_1.default.join(os_1.default.tmpdir(), `dataparade-dataflow-${Date.now()}.json`);
30
33
  (0, json_1.writeDataflowJson)({
31
34
  scanResult,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataparade/cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "dataPARADE CLI — scan codebases for privacy and security data flows",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "license": "GPL-3.0-or-later",
10
10
  "author": "DataParade",
11
- "homepage": "https://github.com/DataParade-io/dataparade-cli#readme",
11
+ "homepage": "https://app.dataparade.com/docs/cli-import-and-zip",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "git+https://github.com/DataParade-io/dataparade-cli.git"