srclawyer 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Static analysis engine that derives privacy policy documentation directly from source code, and keeps it in sync as the code changes.
4
4
 
5
- > **Beta.** The CLI (`init`, `scan`), the Layer 1 static analysis engine, and markdown privacy policy generation all work today. JavaScript/TypeScript (Express, Next.js) is the most tested path; Python (Flask) is newer, with FastAPI and Django explicitly detected and flagged as unsupported rather than silently skipped — see [Supported languages and frameworks](#supported-languages-and-frameworks) and [Known gaps](#known-gaps) below. LLM-assisted reasoning for ambiguous findings (Layer 2) is available now under the bring-your-own-key tier, documented below as one optional step in `init` — a managed (hosted) tier is planned but not yet available.
5
+ > **Beta.** The CLI (`init`, `scan`), the Layer 1 static analysis engine, and markdown privacy policy generation all work today. JavaScript/TypeScript (Express, Next.js) is the most tested path; Python (Flask) is newer, with FastAPI and Django explicitly detected and flagged as unsupported rather than silently skipped — see [Supported languages and frameworks](#supported-languages-and-frameworks) and [Known gaps](#known-gaps) below. Optional AI-assisted review of ambiguous findings (Layer 2) is available as an advanced option with your own Anthropic API key — see [AI-assisted review](#ai-assisted-review-advanced) below; a hosted tier that needs no key is planned but not yet available.
6
6
  >
7
7
  > Scanning is manual-only (`srclawyer scan`, run on demand) — this is the free/solo tier's permanent behavior, not a placeholder. Automatic CI/CD updating (a scan that runs itself on every PR, or on a schedule) isn't available yet; it's scoped for a future paid/team tier. See `PRODUCT_SPEC.md` Section 8.5 for the plan.
8
8
 
@@ -93,9 +93,38 @@ Every finding traces back to a file and line (`src/engine/types.ts#Finding`).
93
93
  - **Flask support covers direct request reads and same-function aliases only.** It detects `request.form[...]`, `request.args.get(...)`, `request.json[...]` and the like, plus one assignment hop within a function (`data = request.get_json()`, then `data['x']`). Form classes — Flask-WTF/WTForms `FlaskForm` subclasses with `StringField`/`PasswordField` declarations read via `form.email.data` — are not detected, and neither are fields rendered by template helpers such as `{{ form.email() }}`. A Flask app that collects data through WTForms may therefore show fewer collected fields than it actually has.
94
94
  - **Server-side template syntax inside HTML is not analyzed.** Jinja, Django, ERB and similar delimiters (`{{`, `{%`, `<%`, `{#`) are not interpreted: an inline `<script>` that isn't valid JavaScript until the template engine runs is skipped (listed in `--json` as `template-syntax`, with a one-line note), and form fields that a template generates rather than spells out as `<input>` tags are not seen.
95
95
 
96
+ ## AI-assisted review (advanced)
97
+
98
+ Off by default, and not part of `init`'s questions. `scan` already surfaces anything it can't confidently classify under "Items Requiring Manual Review"; with AI-assisted review enabled it first asks Anthropic, under **your own API key**, to classify each such item. For each item Anthropic receives: an opaque per-scan id, the item's data category, its short description (which names the field), and the one source line it was found on with secrets redacted — plus a fixed instruction prompt and the model name. **Not sent:** the file's path, its line number, or any surrounding code (the source line itself goes as written, apart from redacted secrets). Items the model declines stay in the manual-review list, and items involving children's data are never auto-resolved.
99
+
100
+ Enable it when creating the config:
101
+
102
+ ```bash
103
+ srclawyer init --enable-ai-review # asks which env var holds your key (default ANTHROPIC_API_KEY)
104
+ srclawyer init --enable-ai-review --api-key-env-var MY_KEY # same, non-interactive
105
+ export ANTHROPIC_API_KEY=... # or whichever name you chose
106
+ srclawyer scan
107
+ ```
108
+
109
+ or, for an existing config (`init` never overwrites one), add this to `.srclawyer.config.yml` by hand:
110
+
111
+ ```yaml
112
+ tier: byok
113
+ llm:
114
+ provider: anthropic
115
+ apiKeyEnvVar: ANTHROPIC_API_KEY
116
+ ```
117
+
118
+ Only the variable's *name* is stored in the config — the key itself is never written to disk. When it's enabled, `scan` prints a notice that redacted snippets are being sent to Anthropic; `scan --no-llm` skips it for a single run. A hosted tier, where SrcLawyer supplies the model access and no key is needed, is planned but not yet available: a config with `tier: managed` gets a clear "not available yet" error rather than silently doing nothing.
119
+
96
120
  ## Network calls
97
121
 
98
- Detection itself is fully local and offline — no code leaves your machine for pattern matching. Once detection completes, `scan` makes one batched network call to grade the confidence of what it found (field names and derived yes/no signals only, never source code), and, for scans that use Zod schemas as request validators, one additional call sending a small redacted code fragment. This runs on every scan regardless of tier and is unrelated to the separate, optional LLM-assisted (Layer 2) reasoning described above. See `PRODUCT_SPEC.md`'s "Static Analysis Depth" section for the precise wording.
122
+ Detection itself is fully local and offline — no code leaves your machine for pattern matching. Once detection completes, every `scan` makes these calls to a SrcLawyer-run service:
123
+
124
+ - **Confidence grading** (one batched call). For each detected field: an opaque per-scan id (`f0`, `f1`, …), the data category its name maps to (e.g. `email`), and three derived signals — whether the name is ambiguous, whether it was read directly from the request in code (rather than inferred from a type), and how many confidently classified fields sit alongside it. **Not sent:** the field's name, file paths, line numbers, or source code.
125
+ - **Zod-schema detection** (one more batched call, only for scans where Zod schemas appear to validate request data). Per schema: an opaque id (`c0`, `c1`, …) and a small, secret-redacted code fragment — the schema, the call that validates with it, and the imports it uses, as source text (so it includes the schema's field names and those import specifiers). **Not sent:** the schema's file path or line number.
126
+
127
+ Ids are numbered per scan; the mapping back to files and lines never leaves your machine. Requests carry a shared API key (`x-api-key`) and the standard headers Node.js adds (such as `user-agent: node`); there is no install ID, machine information, or telemetry. These calls run on every scan, with or without the optional [AI-assisted review](#ai-assisted-review-advanced), and are separate from it. See `PRODUCT_SPEC.md`'s "Static Analysis Depth" section for the same wording.
99
128
 
100
129
  ## Secret handling
101
130
 
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import { readFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { Command } from "commander";
6
- import { runInit } from "./commands/init.js";
6
+ import { isValidEnvVarName, runInit } from "./commands/init.js";
7
7
  import { runScan } from "./commands/scan.js";
8
8
  // Read from package.json rather than hardcoding, so --version can't silently drift out of sync with
9
9
  // the published version the way a literal string did through every prior release.
@@ -37,7 +37,15 @@ program
37
37
  .option("--minimum-age <number>", "minimum age required to use this product")
38
38
  .option("--sends-data-to-ai-services", "declare that user data is sent to third-party AI services")
39
39
  .option("--no-sends-data-to-ai-services", "declare that user data is not sent to third-party AI services")
40
+ .option("--enable-ai-review", "advanced: enable optional AI-assisted review of ambiguous findings with your own Anthropic API key (sets tier: byok)")
41
+ .option("--api-key-env-var <name>", "with --enable-ai-review: the environment variable holding your Anthropic API key (default ANTHROPIC_API_KEY)")
40
42
  .action(async (opts) => {
43
+ if (opts.apiKeyEnvVar !== undefined) {
44
+ if (!opts.enableAiReview)
45
+ program.error("error: --api-key-env-var requires --enable-ai-review");
46
+ if (!isValidEnvVarName(opts.apiKeyEnvVar))
47
+ program.error(`error: --api-key-env-var must be a valid environment variable name (got "${opts.apiKeyEnvVar}")`);
48
+ }
41
49
  let minimumAge;
42
50
  if (opts.minimumAge !== undefined) {
43
51
  const parsed = Number(opts.minimumAge);
@@ -60,6 +68,8 @@ program
60
68
  accountDeletionInstructions: opts.accountDeletionInstructions,
61
69
  minimumAge,
62
70
  sendsDataToAiServices: opts.sendsDataToAiServices,
71
+ enableAiReview: opts.enableAiReview,
72
+ apiKeyEnvVar: opts.apiKeyEnvVar,
63
73
  });
64
74
  });
65
75
  program
@@ -39,6 +39,22 @@ function chunkByCountAndBytes(items, maxCount, maxBytes) {
39
39
  batches.push(current);
40
40
  return batches;
41
41
  }
42
+ /**
43
+ * The one place ids are assigned for anything sent to the Worker. Callers identify items by their own
44
+ * ids (finding ids embed file path, line and field name; Zod candidate ids ARE the file path), but
45
+ * those never leave this process: every item goes out under an opaque per-scan id (f0, f1, ... /
46
+ * c0, c1, ...), unique across all batches, and responses are mapped back here. The Worker only echoes
47
+ * ids (it never parses them), so nothing about the wire format depends on their shape.
48
+ */
49
+ function toOpaque(items, prefix) {
50
+ const originalByOpaque = new Map();
51
+ const wire = items.map((item, i) => {
52
+ const opaque = `${prefix}${i}`;
53
+ originalByOpaque.set(opaque, item.id);
54
+ return { ...item, id: opaque };
55
+ });
56
+ return { wire, originalByOpaque };
57
+ }
42
58
  function sleep(ms) {
43
59
  return new Promise((resolve) => setTimeout(resolve, ms));
44
60
  }
@@ -79,11 +95,15 @@ export async function scoreFields(items, options) {
79
95
  const batchMaxBytes = options.batchMaxBytes ?? DEFAULT_BATCH_MAX_BYTES;
80
96
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
81
97
  let error = null;
82
- for (const batch of chunkByCountAndBytes(items, batchSize, batchMaxBytes)) {
98
+ const { wire, originalByOpaque } = toOpaque(items, "f");
99
+ for (const batch of chunkByCountAndBytes(wire, batchSize, batchMaxBytes)) {
83
100
  try {
84
101
  const response = await postJson(`${options.baseUrl}/v1/score-fields`, options.apiKey, { fields: batch }, timeoutMs);
85
- for (const result of response.results)
86
- results.set(result.id, result);
102
+ for (const result of response.results) {
103
+ const original = originalByOpaque.get(result.id);
104
+ if (original !== undefined)
105
+ results.set(original, { ...result, id: original });
106
+ }
87
107
  }
88
108
  catch (err) {
89
109
  error = err instanceof Error ? err.message : String(err);
@@ -99,11 +119,15 @@ export async function detectZodSchemas(items, options) {
99
119
  const batchMaxBytes = options.batchMaxBytes ?? DEFAULT_BATCH_MAX_BYTES;
100
120
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
101
121
  let error = null;
102
- for (const batch of chunkByCountAndBytes(items, batchSize, batchMaxBytes)) {
122
+ const { wire, originalByOpaque } = toOpaque(items, "c");
123
+ for (const batch of chunkByCountAndBytes(wire, batchSize, batchMaxBytes)) {
103
124
  try {
104
125
  const response = await postJson(`${options.baseUrl}/v1/detect-zod-schema`, options.apiKey, { candidates: batch }, timeoutMs);
105
- for (const result of response.results)
106
- results.set(result.id, result);
126
+ for (const result of response.results) {
127
+ const original = originalByOpaque.get(result.id);
128
+ if (original !== undefined)
129
+ results.set(original, { ...result, id: original });
130
+ }
107
131
  }
108
132
  catch (err) {
109
133
  error = err instanceof Error ? err.message : String(err);
@@ -12,5 +12,10 @@ export interface InitFlags {
12
12
  accountDeletionInstructions?: string;
13
13
  minimumAge?: number;
14
14
  sendsDataToAiServices?: boolean;
15
+ /** Advanced, opt-in: sets tier: byok. Never asked about in the default flow. */
16
+ enableAiReview?: boolean;
17
+ apiKeyEnvVar?: string;
15
18
  }
19
+ export declare const DEFAULT_API_KEY_ENV_VAR = "ANTHROPIC_API_KEY";
20
+ export declare function isValidEnvVarName(name: string): boolean;
16
21
  export declare function runInit(root: string, flags?: InitFlags): Promise<void>;
@@ -2,8 +2,13 @@ import { existsSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { createInterface } from "node:readline/promises";
4
4
  import { CONFIG_FILENAME, DEFAULT_CONFIG, configPath, hasUnmigratedLegacyConfig, legacyConfigMessage, writeConfig, } from "../config/config.js";
5
- import { NETWORK_CALLS_NOTICE } from "../policy/legalNotices.js";
5
+ import { NETWORK_CALLS_NOTICE, byokNetworkNotice } from "../policy/legalNotices.js";
6
6
  import { runScan } from "./scan.js";
7
+ export const DEFAULT_API_KEY_ENV_VAR = "ANTHROPIC_API_KEY";
8
+ const ENV_VAR_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
9
+ export function isValidEnvVarName(name) {
10
+ return ENV_VAR_NAME.test(name);
11
+ }
7
12
  function guessIndustry(root) {
8
13
  const pkgPath = join(root, "package.json");
9
14
  if (!existsSync(pkgPath))
@@ -132,17 +137,22 @@ export async function runInit(root, flags = {}) {
132
137
  // Deliberately about the SCANNED PRODUCT's own behavior (does it send its end-users' data to AI
133
138
  // services as part of its own functionality) -- not about SrcLawyer's own, separately-documented
134
139
  // BYOK network calls described in NETWORK_CALLS_NOTICE above.
135
- const sendsDataToAiServices = await resolveField(flags.sendsDataToAiServices, gateYes, () => askYesNoOptional(lines, "Does this product send user data to third-party AI services (e.g. OpenAI, Anthropic) as part of its own functionality?"));
136
- // "managed" is deliberately not offered here -- it's a real SrcLawyerTier value and config.ts/
137
- // resolveProviderForTier.ts both still support it fully (a hand-edited config with tier: managed
138
- // still gets a clear, accurate error at scan time), but there's no advertised path to it from this
139
- // prompt, so a tester reading the choices here can't select a dead end during setup.
140
- const enableByokRaw = await ask(lines, "Enable optional AI-assisted review with your own Anthropic key? (advanced)", "n");
141
- const tier = /^y(es)?$/i.test(enableByokRaw.trim()) ? "byok" : "free";
140
+ const sendsDataToAiServices = await resolveField(flags.sendsDataToAiServices, gateYes, () => askYesNoOptional(lines, "Does this product send user data to third-party AI services as part of its own functionality?"));
141
+ // AI-assisted review (tier: byok) is an advanced opt-in, reached only via --enable-ai-review (or by
142
+ // hand-editing the config) -- the default flow never asks about it or mentions an API key. "managed"
143
+ // is likewise not offered here: it's still a real SrcLawyerTier value that config.ts and
144
+ // resolveProviderForTier.ts support, so a hand-edited tier: managed keeps its clear "not available
145
+ // yet" error at scan time, but nothing advertises a path to it.
146
+ const tier = flags.enableAiReview ? "byok" : "free";
142
147
  let apiKeyEnvVar = null;
143
148
  if (tier === "byok") {
144
- apiKeyEnvVar = await ask(lines, "Which environment variable holds your Anthropic API key?", "ANTHROPIC_API_KEY");
149
+ apiKeyEnvVar = flags.apiKeyEnvVar ?? (await ask(lines, "Which environment variable holds your Anthropic API key?", DEFAULT_API_KEY_ENV_VAR));
150
+ if (!isValidEnvVarName(apiKeyEnvVar)) {
151
+ console.log(`\n"${apiKeyEnvVar}" is not a valid environment variable name; using ${DEFAULT_API_KEY_ENV_VAR} instead. Edit ${CONFIG_FILENAME} to change it.`);
152
+ apiKeyEnvVar = DEFAULT_API_KEY_ENV_VAR;
153
+ }
145
154
  console.log(`\nNote: only the name "${apiKeyEnvVar}" is written to ${CONFIG_FILENAME} — the key itself is never written to disk. It's read from your environment at scan time.`);
155
+ console.log(byokNetworkNotice(apiKeyEnvVar));
146
156
  }
147
157
  const config = {
148
158
  entityLocation: entityLocation || null,
@@ -60,7 +60,7 @@ export async function runScan(root, options) {
60
60
  if (config.tier === "byok" && config.llm) {
61
61
  console.log(byokNetworkNotice(config.llm.apiKeyEnvVar));
62
62
  }
63
- console.log(`Sending ${ambiguous.length} ambiguous item(s) to ${provider.name}...`);
63
+ console.log(`Sending ${ambiguous.length} ambiguous item(s) to ${provider.name} (an opaque id, category, description and one redacted source line each)...`);
64
64
  const resolved = await resolveAmbiguousFindings(ambiguous, provider, {
65
65
  // Preserves today's exact override behavior bit-for-bit: a missing/legacy key already
66
66
  // behaved as false before collectsChildrensData became nullable. Only the generated
@@ -84,7 +84,7 @@ export async function runScan(root, options) {
84
84
  console.log(JSON.stringify({ ...finalResult, policyPath, llmError, protectedLogicWarning, legacyConfigWarning }, null, 2));
85
85
  return;
86
86
  }
87
- console.log(formatText(finalResult));
87
+ console.log(formatText(finalResult, { aiReviewEnabled: config?.tier === "byok" }));
88
88
  if (protectedLogicWarning)
89
89
  console.log(`\n${protectedLogicWarning}`);
90
90
  if (legacyConfigWarning)
@@ -6,5 +6,9 @@ import type { LlmRequestItem } from "./types.js";
6
6
  * they leave this function — LlmRequestItem has no raw-evidence field, so a
7
7
  * provider implementation is structurally incapable of receiving
8
8
  * unredacted content.
9
+ *
10
+ * `requestId` is an opaque per-scan identifier (f0, f1, ...), never finding.id: finding ids embed the
11
+ * file path, line number and field name, and none of those may reach the provider. The caller
12
+ * (resolveAmbiguousFindings) owns the mapping back to findings and never sends it anywhere.
9
13
  */
10
- export declare function buildRequestItem(finding: Finding, collectsChildrensData: boolean): LlmRequestItem;
14
+ export declare function buildRequestItem(finding: Finding, collectsChildrensData: boolean, requestId: string): LlmRequestItem;
@@ -5,10 +5,14 @@ import { redactSecrets } from "../engine/secretRedaction.js";
5
5
  * they leave this function — LlmRequestItem has no raw-evidence field, so a
6
6
  * provider implementation is structurally incapable of receiving
7
7
  * unredacted content.
8
+ *
9
+ * `requestId` is an opaque per-scan identifier (f0, f1, ...), never finding.id: finding ids embed the
10
+ * file path, line number and field name, and none of those may reach the provider. The caller
11
+ * (resolveAmbiguousFindings) owns the mapping back to findings and never sends it anywhere.
8
12
  */
9
- export function buildRequestItem(finding, collectsChildrensData) {
13
+ export function buildRequestItem(finding, collectsChildrensData, requestId) {
10
14
  return {
11
- findingId: finding.id,
15
+ findingId: requestId,
12
16
  redactedEvidence: redactSecrets(finding.evidence),
13
17
  redactedDescription: redactSecrets(finding.description),
14
18
  dataCategories: finding.dataCategories,
@@ -6,8 +6,11 @@ const DEFAULT_BATCH_CHAR_BUDGET = 6000;
6
6
  export async function resolveAmbiguousFindings(findings, provider, options) {
7
7
  const batches = chunkFindings(findings, options.batchSize ?? DEFAULT_BATCH_SIZE);
8
8
  const resolvedById = new Map();
9
+ // Opaque per-scan ids (f0, f1, ...), unique across all batches. Finding ids embed file paths and
10
+ // line numbers, so only these ever go on the wire; the mapping back lives here and nowhere else.
11
+ const requestIdOf = new Map(findings.map((finding, i) => [finding, `f${i}`]));
9
12
  for (const batch of batches) {
10
- const items = batch.map((finding) => buildRequestItem(finding, options.collectsChildrensData));
13
+ const items = batch.map((finding) => buildRequestItem(finding, options.collectsChildrensData, requestIdOf.get(finding)));
11
14
  const isHighStakesById = new Map(items.map((item) => [item.findingId, item.isHighStakes]));
12
15
  let responses;
13
16
  try {
@@ -27,8 +30,9 @@ export async function resolveAmbiguousFindings(findings, provider, options) {
27
30
  }
28
31
  const responseById = new Map(responses.map((response) => [response.findingId, response]));
29
32
  for (const finding of batch) {
30
- const response = responseById.get(finding.id);
31
- const isHighStakes = isHighStakesById.get(finding.id) ?? false;
33
+ const requestId = requestIdOf.get(finding);
34
+ const response = responseById.get(requestId);
35
+ const isHighStakes = isHighStakesById.get(requestId) ?? false;
32
36
  resolvedById.set(finding.id, toResolution(response, isHighStakes, provider));
33
37
  }
34
38
  }
@@ -10,7 +10,7 @@ export function resolveProviderForTier(config) {
10
10
  if (!envVar) {
11
11
  return {
12
12
  provider: null,
13
- error: `Tier is "byok" but no API key environment variable is configured in ${CONFIG_FILENAME}. Run "srclawyer init" to set one.`,
13
+ error: `Tier is "byok" but no API key environment variable is configured in ${CONFIG_FILENAME}. Add "llm: { provider: anthropic, apiKeyEnvVar: <ENV_VAR_NAME> }" to it, or delete the file and re-run "srclawyer init --enable-ai-review".`,
14
14
  };
15
15
  }
16
16
  const apiKey = process.env[envVar];
@@ -8,16 +8,20 @@
8
8
  // notice and disclaimer, not a substitute for either.
9
9
  export const PRIVACY_POLICY_URL = "https://github.com/SrcLawyer/srclawyer#legal";
10
10
  export const TERMS_URL = "https://github.com/SrcLawyer/srclawyer#legal";
11
- // Verbatim from README.md's own "Network calls" section (minus markdown backticks, since this prints
12
- // to a terminal) -- one wording for this claim, not a second paraphrase that can drift from the first.
11
+ // Mirrors README.md's own "Network calls" section (condensed, minus markdown backticks since this
12
+ // prints to a terminal) -- the same claims in the same terms, not a second paraphrase that can drift.
13
+ // What is actually on the wire is pinned by tests/requestBodiesNoPaths.test.ts.
13
14
  export const NETWORK_CALLS_NOTICE = [
14
15
  "Heads up: SrcLawyer makes network calls.",
15
16
  "",
16
17
  "Detection itself is fully local and offline — no code leaves your machine for pattern matching.",
17
- "Once detection completes, scan makes one batched network call to grade the confidence of what it",
18
- "found (field names and derived yes/no signals only, never source code), and, for scans that use Zod",
19
- "schemas as request validators, one additional call sending a small redacted code fragment. This runs",
20
- "on every scan regardless of tier.",
18
+ "Once detection completes, every scan makes one batched call to grade the confidence of what it",
19
+ "found. For each field it sends an opaque id (f0, f1, ...), the data category the field's name maps",
20
+ "to, and three derived signals (is the name ambiguous, was it read directly from the request, how",
21
+ "many similar fields sit alongside it) -- no field names, file paths, line numbers or source code.",
22
+ "Scans that use Zod schemas as request validators make one additional batched call, sending an",
23
+ "opaque id and a small secret-redacted code fragment per schema (the schema, its validation call",
24
+ "and the imports it uses) -- never a file path or line number.",
21
25
  "",
22
26
  `Legal notice and disclaimer: ${PRIVACY_POLICY_URL}`,
23
27
  "(A dedicated privacy policy and terms of service are coming; this points to what exists today.)",
@@ -25,5 +29,5 @@ export const NETWORK_CALLS_NOTICE = [
25
29
  export const SCAN_DISCLAIMER_REMINDER = "Reminder: this is automated analysis, not legal advice — review the generated policy before publishing it.";
26
30
  export function byokNetworkNotice(apiKeyEnvVar) {
27
31
  const keySource = apiKeyEnvVar ? `env var ${apiKeyEnvVar}` : "your configured key";
28
- return `BYOK is configured: redacted code snippets for ambiguous findings will be sent to Anthropic under your own API key (${keySource}), for AI-assisted classification only.`;
32
+ return `BYOK is configured: for each finding scan couldn't classify, it will send Anthropic, under your own API key (${keySource}), an opaque id, the finding's data category and description (which names the field), and the one source line it was found on with secrets redacted — not the file's path or line number, and no other code — for AI-assisted classification only.`;
29
33
  }
@@ -1,2 +1,7 @@
1
1
  import type { ScanResult } from "../engine/types.js";
2
- export declare function formatText(result: ScanResult): string;
2
+ export interface FormatTextOptions {
3
+ /** True when the config has AI-assisted review (tier: byok) turned on -- the hint about that
4
+ * advanced option is only relevant when it isn't. */
5
+ aiReviewEnabled?: boolean;
6
+ }
7
+ export declare function formatText(result: ScanResult, options?: FormatTextOptions): string;
@@ -1,5 +1,5 @@
1
1
  const BANNER_RULE = "=".repeat(72);
2
- export function formatText(result) {
2
+ export function formatText(result, options = {}) {
3
3
  const lines = [];
4
4
  if (result.unsupportedStackWarning) {
5
5
  lines.push(BANNER_RULE);
@@ -54,7 +54,12 @@ export function formatText(result) {
54
54
  }
55
55
  else if (result.ambiguousCount > 0) {
56
56
  lines.push("");
57
- lines.push(`${result.ambiguousCount} item(s) require deeper analysis before they can be included in a policy. Run "srclawyer scan" with the "byok" tier configured (bring your own Anthropic key) to attempt AI-assisted resolution, or resolve manually. A "managed" tier is planned but not yet available.`);
57
+ const base = `${result.ambiguousCount} item(s) require deeper analysis before they can be included in a policy; review them manually.`;
58
+ // Only worth mentioning when the advanced option isn't already on, and only as a pointer -- it is
59
+ // opt-in (init --enable-ai-review, or a hand-edited config), not something to recommend to everyone.
60
+ lines.push(options.aiReviewEnabled
61
+ ? base
62
+ : `${base} (Optional, advanced: AI-assisted resolution with your own Anthropic API key — see "AI-assisted review" in the README.)`);
58
63
  }
59
64
  return lines.join("\n");
60
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "srclawyer",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Static analysis engine that derives privacy policy documentation directly from source code",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",