Skip to content

Commit 84a1175

Browse files
committed
fix(llm): trim compact prompt env value, document option, pin contract
Address rng1995 reviews on #542 (2026-09-16, 2026-09-18): normalize SKILLSPECTOR_COMPACT_PROMPTS with .strip().lower() matching the existing provider/SSL env parsers, document the option/default/truthy values in the README environment-variable table, and extend the focused test to pin the unset/default path plus normalized truthy inputs. Signed-off-by: Deepak Jain <[email protected]>
1 parent b328fd7 commit 84a1175

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ Issues (2)
613613
| `SKILLSPECTOR_OUTPUT_LANGUAGE` | Short, single-line language label (letters, numbers, spaces, `_`, or `-`; maximum 64 characters) for human-readable LLM finding text such as messages, explanations, and remediation. Rule IDs, severity values, paths, code, and other machine-readable values remain unchanged. Unset, blank, or invalid values preserve the default output language. | Optional |
614614
| `SKILLSPECTOR_TEMPERATURE` | Optional sampling temperature from `0` to `1` for hosted providers. Unset or blank preserves the provider default. Lower values can reduce run-to-run variation but do not guarantee identical output. | Optional |
615615
| `SKILLSPECTOR_SEED` | Optional integer sampling seed for OpenAI-compatible and Azure OpenAI providers. Other hosted providers and CLI providers do not receive it. Provider support remains model-dependent. | Optional |
616+
| `SKILLSPECTOR_COMPACT_PROMPTS` | Opt-in compact line numbering in LLM prompts: numbered lines render as `L1:`, `L2:` instead of zero-padded `L01:`, `L02:`. Accepted truthy values are `1`, `true`, and `yes` (case-insensitive; surrounding whitespace is trimmed). Unset or any other value keeps the default zero-padded format. | Optional |
616617
| `ANTHROPIC_API_KEY` | Credential for the Anthropic provider (`SKILLSPECTOR_PROVIDER=anthropic`). | Required for LLM analysis when `SKILLSPECTOR_PROVIDER=anthropic` |
617618
| `ANTHROPIC_BASE_URL` | Override the native Anthropic endpoint (default: `https://api.anthropic.com`). | Optional |
618619
| `ANTHROPIC_PROXY_ENDPOINT_URL` | Full endpoint URL for the Anthropic proxy provider (Vertex-style raw-predict). | Required when `SKILLSPECTOR_PROVIDER=anthropic_proxy` |

‎src/skillspector/llm_analyzer_base.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ def number_lines(content: str, start_line: int = 1) -> str:
592592
lines = content.splitlines()
593593
if not lines:
594594
return ""
595-
if os.environ.get("SKILLSPECTOR_COMPACT_PROMPTS", "").lower() in {"1", "true", "yes"}:
595+
if os.environ.get("SKILLSPECTOR_COMPACT_PROMPTS", "").strip().lower() in {"1", "true", "yes"}:
596596
return "\n".join(f"L{start_line + i}: {line}" for i, line in enumerate(lines))
597597
end = start_line + len(lines) - 1
598598
width = len(str(end))

‎tests/nodes/test_llm_analyzer_base.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,31 @@ def test_compact_prompts_disable_zero_padding(self, monkeypatch: pytest.MonkeyPa
311311
lines = "\n".join(f"line{i}" for i in range(11))
312312
assert number_lines(lines).startswith("L1: line0")
313313

314+
@pytest.mark.parametrize("value", ["1", "true", "TRUE", "yes", "Yes", " true "])
315+
def test_compact_prompts_normalized_truthy_values(
316+
self, monkeypatch: pytest.MonkeyPatch, value: str
317+
) -> None:
318+
monkeypatch.setenv("SKILLSPECTOR_COMPACT_PROMPTS", value)
319+
lines = "\n".join(f"line{i}" for i in range(11))
320+
assert number_lines(lines).startswith("L1: line0")
321+
322+
@pytest.mark.parametrize("value", ["0", "false", "no", ""])
323+
def test_compact_prompts_falsy_values_keep_default(
324+
self, monkeypatch: pytest.MonkeyPatch, value: str
325+
) -> None:
326+
monkeypatch.setenv("SKILLSPECTOR_COMPACT_PROMPTS", value)
327+
lines = "\n".join(f"line{i}" for i in range(11))
328+
result = number_lines(lines)
329+
assert result.startswith("L01: line0")
330+
assert "L11: line10" in result
331+
332+
def test_compact_prompts_unset_keeps_default(self, monkeypatch: pytest.MonkeyPatch) -> None:
333+
monkeypatch.delenv("SKILLSPECTOR_COMPACT_PROMPTS", raising=False)
334+
lines = "\n".join(f"line{i}" for i in range(11))
335+
result = number_lines(lines)
336+
assert result.startswith("L01: line0")
337+
assert "L11: line10" in result
338+
314339

315340
# ---------------------------------------------------------------------------
316341
# LLMAnalyzerBase.build_prompt (default implementation)

0 commit comments

Comments
 (0)