Skip to content

Commit fcdee2d

Browse files
cli: Migrate embedded asset installation to hexagonal vertical slice
install_embedded_setup_assets combined optional-workflow selection, embedded asset installation, config persistence, and CLI rendering in one services::setup module that also owned Git discovery, hook installation, filesystem staging, and prompting. Extract the embedded-asset installation capability into the internal hexagonal architecture, following the pattern established by the context-baseline slice: a pure domain model for integration targets/assets (domain/integration), two application ports (IntegrationAssetCatalog, IntegrationInstaller), one use case (InstallIntegrationAssets), and two outbound adapters (an embedded-asset catalog wrapping the existing generated catalog, and a filesystem installer owning staging/replace/rename/cleanup). Co-authored-by: SCE <sce@crocoder.dev>
1 parent 0e8d28b commit fcdee2d

18 files changed

Lines changed: 1098 additions & 187 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
//! `EmbeddedIntegrationAssetCatalog`: the `IntegrationAssetCatalog` outbound
2+
//! adapter wrapping the existing generated embedded-asset catalog in
3+
//! `services::setup`.
4+
5+
use std::convert::Infallible;
6+
7+
use crate::application::ports::integration_asset_catalog::IntegrationAssetCatalog;
8+
use crate::domain::integration::{IntegrationAsset, IntegrationTarget};
9+
use crate::services::setup;
10+
11+
fn setup_target_for(target: IntegrationTarget) -> setup::SetupTarget {
12+
match target {
13+
IntegrationTarget::OpenCode => setup::SetupTarget::OpenCode,
14+
IntegrationTarget::Claude => setup::SetupTarget::Claude,
15+
IntegrationTarget::Pi => setup::SetupTarget::Pi,
16+
}
17+
}
18+
19+
/// Resolves embedded assets for a concrete integration target by delegating
20+
/// to `services::setup::iter_embedded_assets_for_setup_target_with_selection`.
21+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
22+
pub(crate) struct EmbeddedIntegrationAssetCatalog;
23+
24+
impl IntegrationAssetCatalog for EmbeddedIntegrationAssetCatalog {
25+
type Error = Infallible;
26+
27+
fn assets_for(
28+
&self,
29+
target: IntegrationTarget,
30+
optional_workflows: &[String],
31+
) -> Result<Vec<IntegrationAsset>, Self::Error> {
32+
let assets = setup::iter_embedded_assets_for_setup_target_with_selection(
33+
setup_target_for(target),
34+
optional_workflows,
35+
)
36+
.map(|asset| IntegrationAsset {
37+
relative_path: asset.relative_path.to_string(),
38+
bytes: asset.bytes,
39+
})
40+
.collect();
41+
42+
Ok(assets)
43+
}
44+
}
45+
46+
#[cfg(test)]
47+
mod tests {
48+
use super::*;
49+
50+
#[test]
51+
fn assets_for_matches_the_underlying_generated_catalog() {
52+
let optional_workflows = vec!["research".to_string()];
53+
54+
let adapter_assets = EmbeddedIntegrationAssetCatalog
55+
.assets_for(IntegrationTarget::Claude, &optional_workflows)
56+
.expect("adapter catalog lookup");
57+
58+
let expected: Vec<IntegrationAsset> =
59+
setup::iter_embedded_assets_for_setup_target_with_selection(
60+
setup::SetupTarget::Claude,
61+
&optional_workflows,
62+
)
63+
.map(|asset| IntegrationAsset {
64+
relative_path: asset.relative_path.to_string(),
65+
bytes: asset.bytes,
66+
})
67+
.collect();
68+
69+
assert_eq!(adapter_assets, expected);
70+
}
71+
72+
#[test]
73+
fn assets_for_maps_every_concrete_target() {
74+
for target in [
75+
IntegrationTarget::OpenCode,
76+
IntegrationTarget::Claude,
77+
IntegrationTarget::Pi,
78+
] {
79+
let adapter_assets = EmbeddedIntegrationAssetCatalog
80+
.assets_for(target, &[])
81+
.expect("adapter catalog lookup");
82+
83+
let expected: Vec<IntegrationAsset> =
84+
setup::iter_embedded_assets_for_setup_target_with_selection(
85+
setup_target_for(target),
86+
&[] as &[String],
87+
)
88+
.map(|asset| IntegrationAsset {
89+
relative_path: asset.relative_path.to_string(),
90+
bytes: asset.bytes,
91+
})
92+
.collect();
93+
94+
assert_eq!(adapter_assets, expected);
95+
}
96+
}
97+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Outbound adapters over the generated embedded-asset catalogs.
2+
3+
pub(crate) mod embedded_integration_assets;

0 commit comments

Comments
 (0)