Skip to content

Commit 9a63f43

Browse files
Define skill artifact roles in bundle layout
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent 0300ad4 commit 9a63f43

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/code2skill/domain/artifacts.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from collections.abc import Sequence
34
from dataclasses import dataclass
45
from pathlib import Path
56

@@ -49,3 +50,26 @@ def from_repo_root(
4950
state_dir=state_dir,
5051
state_path=state_dir / "analysis-state.json",
5152
)
53+
54+
def partition_bundle_paths(
55+
self,
56+
paths: Sequence[Path | str],
57+
) -> tuple[list[Path], list[Path]]:
58+
final_products: list[Path] = []
59+
intermediates: list[Path] = []
60+
for path in paths:
61+
resolved = self._resolve_bundle_path(path)
62+
if self._is_final_product_path(resolved):
63+
final_products.append(resolved)
64+
continue
65+
intermediates.append(resolved)
66+
return final_products, intermediates
67+
68+
def _resolve_bundle_path(self, path: Path | str) -> Path:
69+
candidate = Path(path).expanduser()
70+
if candidate.is_absolute():
71+
return candidate.resolve()
72+
return (self.root / candidate).resolve()
73+
74+
def _is_final_product_path(self, path: Path) -> bool:
75+
return path.suffix == ".md" and path.parent == self.skills_dir.resolve()

tests/test_workflow_requests.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,30 @@ def test_adapt_request_resolves_source_dir_from_repo_root(tmp_path: Path) -> Non
4444

4545
assert request.source_dir == (repo_path / "generated-skills").resolve()
4646
assert request.destination_root == repo_path.resolve()
47+
48+
49+
def test_artifact_layout_partitions_final_skill_products_from_intermediates(tmp_path: Path) -> None:
50+
repo_path = tmp_path / "repo"
51+
repo_path.mkdir()
52+
53+
layout = ArtifactLayout.from_repo_root(repo_path)
54+
55+
final_products, intermediates = layout.partition_bundle_paths(
56+
[
57+
"project-summary.md",
58+
"skill-plan.json",
59+
"skills/index.md",
60+
"skills/backend.md",
61+
"state/analysis-state.json",
62+
]
63+
)
64+
65+
assert final_products == [
66+
layout.skills_dir / "index.md",
67+
layout.skills_dir / "backend.md",
68+
]
69+
assert intermediates == [
70+
layout.project_summary_path,
71+
layout.skill_plan_path,
72+
layout.state_path,
73+
]

0 commit comments

Comments
 (0)