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

Class IntegrationManifest

src/specify_cli/integrations/manifest.py:104–486  ·  view source on GitHub ↗

Tracks files installed by a single integration. Parameters: key: Integration identifier (e.g. ``"copilot"``). project_root: Absolute path to the project directory. version: CLI version string recorded in the manifest. resolve_project_root: Resolve `

Source from the content-addressed store, hash-verified

102
103
104class IntegrationManifest:
105 """Tracks files installed by a single integration.
106
107 Parameters:
108 key: Integration identifier (e.g. ``"copilot"``).
109 project_root: Absolute path to the project directory.
110 version: CLI version string recorded in the manifest.
111 resolve_project_root: Resolve ``project_root`` before using it.
112 """
113
114 def __init__(
115 self,
116 key: str,
117 project_root: Path,
118 version: str = "",
119 *,
120 resolve_project_root: bool = True,
121 ) -> None:
122 self.key = key
123 self.project_root = (
124 project_root.resolve()
125 if resolve_project_root
126 else project_root.absolute()
127 )
128 self.version = version
129 self._files: dict[str, str] = {} # rel_path → sha256 hex
130 self._recovered_files: set[str] = set()
131 self._installed_at: str = ""
132
133 # -- Manifest file location -------------------------------------------
134
135 @property
136 def manifest_path(self) -> Path:
137 """Path to the on-disk manifest JSON."""
138 return self.project_root / ".specify" / "integrations" / f"{self.key}.manifest.json"
139
140 # -- Recording files --------------------------------------------------
141
142 def record_file(self, rel_path: str | Path, content: bytes | str) -> Path:
143 """Write *content* to *rel_path* (relative to project root) and record its hash.
144
145 Creates parent directories as needed. Returns the absolute path
146 of the written file.
147 If the path was previously marked as recovered via
148 ``record_existing(recovered=True)``, the recovered marker is
149 cleared because the bytes are now produced, not merely observed.
150
151 Raises ``ValueError`` if *rel_path* resolves outside the project root.
152 """
153 rel = Path(rel_path)
154 abs_path = _validate_rel_path(rel, self.project_root)
155 abs_path.parent.mkdir(parents=True, exist_ok=True)
156
157 if isinstance(content, str):
158 content = content.encode("utf-8")
159 abs_path.write_bytes(content)
160
161 normalized = abs_path.relative_to(self.project_root).as_posix()

Calls

no outgoing calls