Coverage for smith / application / update.py: 100%

0 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-01 18:48 +0000

1"""Update use-case — refresh agentic files in a connected project.""" 

2 

3from __future__ import annotations 

4 

5from pathlib import Path 

6 

7from smith.domain.connection import Connection 

8from smith.domain.value_objects import TemplateSource 

9from smith.infrastructure.filesystem import AtomicFileSystem 

10from smith.infrastructure.gitignore import GitignoreManager 

11from smith.infrastructure.metadata import SectionMetadata 

12from smith.infrastructure.template_source import TemplateSourceAdapter 

13 

14 

15class UpdateUseCase: 

16 """Orchestrate updating agentic files in an already-connected project.""" 

17 

18 def __init__(self, project_dir: Path) -> None: 

19 """Initialise with the target project directory.""" 

20 self._project_dir = project_dir 

21 

22 def execute(self, source: TemplateSource | None = None) -> None: 

23 """Update the project's agentic files, optionally from a new source.""" 

24 connection = Connection( 

25 template_source_port=TemplateSourceAdapter( 

26 source or TemplateSource(kind="bundled", location="agents-smith"), 

27 ), 

28 filesystem_port=AtomicFileSystem(self._project_dir), 

29 gitignore_port=GitignoreManager(self._project_dir), 

30 metadata_port=SectionMetadata(self._project_dir), 

31 ) 

32 connection.update(source=source)