Load ``.specify/integration.json``. Returns normalized state when present. Delegates the parse / schema-guard logic to the shared :func:`_try_read_integration_json` helper so the CLI and workflow engine cannot drift on validation rules. Each error variant is translated into the exis
(project_root: Path)
| 39 | # --------------------------------------------------------------------------- |
| 40 | |
| 41 | def _read_integration_json(project_root: Path) -> dict[str, Any]: |
| 42 | """Load ``.specify/integration.json``. Returns normalized state when present. |
| 43 | |
| 44 | Delegates the parse / schema-guard logic to the shared |
| 45 | :func:`_try_read_integration_json` helper so the CLI and workflow engine |
| 46 | cannot drift on validation rules. Each error variant is translated into |
| 47 | the existing loud-fail UX (console message + ``typer.Exit(1)``). |
| 48 | """ |
| 49 | path = project_root / INTEGRATION_JSON |
| 50 | state, error = _try_read_integration_json(project_root) |
| 51 | if error is None: |
| 52 | return state or {} |
| 53 | if error.kind == "decode": |
| 54 | console.print(f"[red]Error:[/red] {path} contains invalid JSON or is not valid UTF-8.") |
| 55 | console.print(f"Please fix or delete {INTEGRATION_JSON} and retry.") |
| 56 | console.print(f"[dim]Details:[/dim] {error.detail}") |
| 57 | elif error.kind == "os": |
| 58 | console.print(f"[red]Error:[/red] Could not read {path}.") |
| 59 | console.print(f"Please fix file permissions or delete {INTEGRATION_JSON} and retry.") |
| 60 | console.print(f"[dim]Details:[/dim] {error.detail}") |
| 61 | elif error.kind == "not_object": |
| 62 | console.print( |
| 63 | f"[red]Error:[/red] {path} must contain a JSON object, got {error.detail}." |
| 64 | ) |
| 65 | console.print(f"Please fix or delete {INTEGRATION_JSON} and retry.") |
| 66 | elif error.kind == "schema_too_new": |
| 67 | console.print( |
| 68 | f"[red]Error:[/red] {path} uses integration state schema {error.schema}, " |
| 69 | f"but this CLI only supports schema {INTEGRATION_STATE_SCHEMA}." |
| 70 | ) |
| 71 | console.print("Please upgrade Spec Kit before modifying integrations.") |
| 72 | raise typer.Exit(1) |
| 73 | |
| 74 | |
| 75 | def _write_integration_json( |
no test coverage detected