MCPcopy Index your code
hub / github.com/github/spec-kit / _read_integration_json

Function _read_integration_json

src/specify_cli/integrations/_helpers.py:41–72  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

39# ---------------------------------------------------------------------------
40
41def _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
75def _write_integration_json(

Callers 8

integration_installFunction · 0.85
integration_uninstallFunction · 0.85
integration_listFunction · 0.85
integration_useFunction · 0.85
integration_searchFunction · 0.85
integration_infoFunction · 0.85
integration_switchFunction · 0.85
integration_upgradeFunction · 0.85

Calls 1

printMethod · 0.80

Tested by

no test coverage detected