fix(cli): emptyHint statico dei tool ora arriva anche via CLI#49
Merged
Conversation
emit() scriveva solo result.hint dinamico, mai l'emptyHint statico del tool: scollamento col path MCP (server.ts: result.hint ?? emptyHint). Chi usava la CLI su una finestra vuota (es. fiducie COVID 2020 assenti dal LOD Senato) riceveva un CSV vuoto senza spiegazione. runTool() ora applica withEmptyHint() (helper puro condiviso, core/): su risultato vuoto senza hint dinamico valorizza result.hint con l'emptyHint del tool. emit() e i ~50 call site invariati. Beneficiano i 6 tool con emptyHint statico (senato-votes, bill-progress, amendments, bills, sindacato-ispettivo, votes). Artefatti spec-driven (openspec/) e 6 test sull'helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
| Filename | Overview |
|---|---|
| src/cli.ts | Routes CLI tool results through the empty-hint fallback before emitting output. |
| src/core/empty-hint.ts | Adds a pure helper that applies a static empty hint only when an empty result has no dynamic hint. |
| src/core/empty-hint.test.ts | Adds focused coverage for static fallback behavior and MCP-style hint precedence. |
| openspec/specs/cli-empty-result-hint/spec.md | Documents the CLI behavior for empty-result hint resolution. |
Reviews (3): Last reviewed commit: "docs(openspec): allinea design/spec al f..." | Re-trigger Greptile
There was a problem hiding this comment.
Pull request overview
Allinea il comportamento della CLI con quello del server MCP quando un tool produce un risultato vuoto: se manca un hint dinamico (result.hint), la CLI deve poter mostrare su stderr l’emptyHint statico del tool, senza contaminare lo stdout (CSV/JSONL) né cambiare exit code.
Changes:
- Introdotto l’helper puro
withEmptyHint()per valorizzareresult.hintconemptyHintsolo nel caso di risultato vuoto e assenza di hint dinamico. - Aggiornato
runTool()in CLI per applicarewithEmptyHint()prima di passare il risultato aemit(). - Aggiunta copertura test e documentazione/spec in
openspec/per il requisito “CLI empty result hint”.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/core/empty-hint.ts | Helper per applicare il fallback emptyHint al ToolResult in caso di risultato vuoto. |
| src/core/empty-hint.test.ts | Test unitari per la semantica e la parità con la risoluzione lato MCP. |
| src/cli.ts | Applica withEmptyHint() nel path CLI (in runTool) per propagare l’hint su stderr via emit(). |
| openspec/specs/cli-empty-result-hint/spec.md | Specifica del requisito e scenari attesi per la CLI su risultato vuoto. |
| openspec/config.yaml | Config di base per OpenSpec (spec-driven). |
| openspec/changes/archive/2026-07-11-fix-cli-emptyhint-fallback/tasks.md | Checklist di implementazione/verifica dell’intervento. |
| openspec/changes/archive/2026-07-11-fix-cli-emptyhint-fallback/specs/cli-empty-result-hint/spec.md | Snapshot dei requisiti aggiunti per l’archivio change. |
| openspec/changes/archive/2026-07-11-fix-cli-emptyhint-fallback/proposal.md | Motivazione e impatto del cambiamento CLI↔MCP. |
| openspec/changes/archive/2026-07-11-fix-cli-emptyhint-fallback/design.md | Decisioni di design (punto di modifica: runTool, precedenza, immutabilità). |
| openspec/changes/archive/2026-07-11-fix-cli-emptyhint-fallback/.openspec.yaml | Metadati change OpenSpec (schema + data). |
Da review Copilot: la guardia !result.hint sovrascriveva un hint dinamico stringa vuota, divergendo dalla precedenza result.hint ?? emptyHint del path MCP. Uso result.hint == null (nullish) e aggiungo il caso di test hint="". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ità MCP Da review Copilot: design.md citava ancora la guardia !result.hint (ora result.hint == null); le spec dicevano "coincidere col server MCP (result.hint ?? emptyHint)" senza notare che l'MCP applica anche ?? DEFAULT_EMPTY. Chiarito che è la precedenza a coincidere, non il default (che resta specifico dell'MCP; la CLI resta silenziosa). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problema
emit()insrc/cli.tsscriveva su stderr solo l'hint dinamico (result.hint), mai l'emptyHintstatico definito dai tool. Il server MCP invece li unisce (src/server.ts:result.hint ?? emptyHint ?? DEFAULT_EMPTY). Scollamento CLI↔MCP: chi usava la CLI su una finestra vuota — caso reale, le fiducie COVID 2020 assenti dal LOD Senato — riceveva un CSV vuoto, exit 0, senza alcuna spiegazione, pur essendo già scritta nel codice del tool.Fix
runTool()ora applicawithEmptyHint(), un helper puro insrc/core/empty-hint.ts: su risultato vuoto e senza hint dinamico, valorizzaresult.hintcon l'emptyHintstatico del tool (stessa precedenzaresult.hint ?? emptyHintdel path MCP).emit()resta invariato — già scriveresult.hintsu stderr — e i ~50 call site non cambiano.Beneficiano i 6 tool con
emptyHintstatico:senato-votes,bill-progress,amendments,bills,sindacato-ispettivo,votes.Verifica
emptyHintcompleto su stderr, exit 0.bill-progress,bills,sindacato-ispettivo,votes: hint ora visibile via CLI.tsc --noEmitpulito; 136/136 test passano (6 nuovi sull'helper: 4 casi della spec + non-mutazione + parità con la risoluzione MCP).Note
openspec/(proposta, design, spec, tasks) e la spec principaleopenspec/specs/cli-empty-result-hint/.🤖 Generated with Claude Code