@@ -2239,6 +2239,7 @@ def test_extension_command_skipped_when_extension_missing(self, project_dir, tem
22392239 "description" : "Test" ,
22402240 },
22412241 "requires" : {"speckit_version" : ">=0.1.0" },
2242+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
22422243 "provides" : {
22432244 "templates" : [
22442245 {
@@ -2283,6 +2284,7 @@ def test_extension_command_registered_when_extension_present(self, project_dir,
22832284 "description" : "Test" ,
22842285 },
22852286 "requires" : {"speckit_version" : ">=0.1.0" },
2287+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
22862288 "provides" : {
22872289 "templates" : [
22882290 {
@@ -2542,6 +2544,7 @@ def _create_command_preset(self, temp_dir, preset_id, command_name, description,
25422544 "description" : "Test" ,
25432545 },
25442546 "requires" : {"speckit_version" : ">=0.1.0" },
2547+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
25452548 "provides" : {
25462549 "templates" : [
25472550 {
@@ -2699,6 +2702,7 @@ def test_extension_restore_resolves_command_refs(self, project_dir, temp_dir):
26992702 "description" : "Test" ,
27002703 },
27012704 "requires" : {"speckit_version" : ">=0.1.0" },
2705+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
27022706 "provides" : {
27032707 "commands" : [
27042708 {
@@ -2752,6 +2756,7 @@ def test_core_command_override_skill_uses_preset_command_description(self, proje
27522756 "description" : "Test" ,
27532757 },
27542758 "requires" : {"speckit_version" : ">=0.1.0" },
2759+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
27552760 "provides" : {
27562761 "templates" : [
27572762 {
@@ -2992,6 +2997,7 @@ def test_extension_skill_override_matches_hyphenated_multisegment_name(self, pro
29922997 "description" : "Test" ,
29932998 },
29942999 "requires" : {"speckit_version" : ">=0.1.0" },
3000+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
29953001 "provides" : {
29963002 "templates" : [
29973003 {
@@ -3044,6 +3050,7 @@ def test_extension_skill_restored_on_preset_remove(self, project_dir, temp_dir):
30443050 "description" : "Test" ,
30453051 },
30463052 "requires" : {"speckit_version" : ">=0.1.0" },
3053+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
30473054 "provides" : {
30483055 "commands" : [
30493056 {
@@ -3072,6 +3079,7 @@ def test_extension_skill_restored_on_preset_remove(self, project_dir, temp_dir):
30723079 "description" : "Test" ,
30733080 },
30743081 "requires" : {"speckit_version" : ">=0.1.0" },
3082+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
30753083 "provides" : {
30763084 "templates" : [
30773085 {
@@ -3125,6 +3133,7 @@ def test_preset_remove_skips_skill_dir_without_skill_file(self, project_dir, tem
31253133 "description" : "Test" ,
31263134 },
31273135 "requires" : {"speckit_version" : ">=0.1.0" },
3136+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
31283137 "provides" : {
31293138 "templates" : [
31303139 {
@@ -3221,6 +3230,7 @@ def test_kimi_new_skill_created_even_when_ai_skills_disabled(self, project_dir,
32213230 "description" : "Test" ,
32223231 },
32233232 "requires" : {"speckit_version" : ">=0.1.0" },
3233+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
32243234 "provides" : {
32253235 "templates" : [
32263236 {
@@ -3274,6 +3284,7 @@ def test_kimi_preset_skill_override_resolves_script_placeholders(self, project_d
32743284 "description" : "Test" ,
32753285 },
32763286 "requires" : {"speckit_version" : ">=0.1.0" },
3287+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
32773288 "provides" : {
32783289 "templates" : [
32793290 {
@@ -3330,6 +3341,7 @@ def test_agy_skill_restored_on_preset_remove(self, project_dir, temp_dir):
33303341 "description" : "Test" ,
33313342 },
33323343 "requires" : {"speckit_version" : ">=0.1.0" },
3344+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
33333345 "provides" : {
33343346 "templates" : [
33353347 {
@@ -3896,6 +3908,119 @@ def test_bundled_preset_missing_locally_cli_error(self, project_dir):
38963908 assert "reinstall" in output , result .output
38973909
38983910
3911+ class TestPresetAddFromUrlResolution :
3912+ """CLI-level tests for preset add --from <url> GitHub release resolution."""
3913+
3914+ def test_preset_add_from_github_release_url_resolves_and_downloads (self , project_dir ):
3915+ """'preset add --from <github-release-url>' resolves to API asset URL."""
3916+ from typer .testing import CliRunner
3917+ from unittest .mock import patch , MagicMock
3918+ from specify_cli import app
3919+
3920+ manifest_content = yaml .dump ({
3921+ "schema_version" : "1.0" ,
3922+ "preset" : {"id" : "my-preset" , "name" : "My Preset" , "version" : "1.0.0" , "description" : "Test preset" , "author" : "Test" , "license" : "MIT" },
3923+ "requires" : {"speckit_version" : ">=0.1.0" },
3924+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
3925+ })
3926+ zip_buf = __import__ ("io" ).BytesIO ()
3927+ with zipfile .ZipFile (zip_buf , "w" ) as zf :
3928+ zf .writestr ("preset.yml" , manifest_content )
3929+ zip_bytes = zip_buf .getvalue ()
3930+
3931+ captured_urls = []
3932+
3933+ class FakeResponse :
3934+ def __init__ (self , data ):
3935+ self ._data = data
3936+
3937+ def read (self ):
3938+ return self ._data
3939+
3940+ def __enter__ (self ):
3941+ return self
3942+
3943+ def __exit__ (self , * a ):
3944+ return False
3945+
3946+ def fake_open_url (url , timeout = None , extra_headers = None ):
3947+ captured_urls .append ((url , extra_headers ))
3948+ if "releases/tags/" in url :
3949+ return FakeResponse (json .dumps ({
3950+ "assets" : [{"name" : "preset.zip" , "url" : "https://api.github.com/repos/org/repo/releases/assets/42" }]
3951+ }).encode ())
3952+ return FakeResponse (zip_bytes )
3953+
3954+ runner = CliRunner ()
3955+ with patch .object (Path , "cwd" , return_value = project_dir ), \
3956+ patch ("specify_cli.get_speckit_version" , return_value = "1.0.0" ), \
3957+ patch ("specify_cli.authentication.http.open_url" , side_effect = fake_open_url ):
3958+ result = runner .invoke (app , [
3959+ "preset" , "add" ,
3960+ "--from" , "https://github.com/org/repo/releases/download/v1.0/preset.zip" ,
3961+ ])
3962+
3963+ assert result .exit_code == 0 , result .output
3964+ assert "My Preset" in result .output
3965+ # First call should resolve the release tag
3966+ assert any ("releases/tags/v1.0" in url for url , _ in captured_urls )
3967+ # Second call should download from the resolved asset URL with octet-stream
3968+ asset_calls = [(url , h ) for url , h in captured_urls if "releases/assets/" in url ]
3969+ assert len (asset_calls ) >= 1
3970+ assert asset_calls [0 ][1 ] == {"Accept" : "application/octet-stream" }
3971+
3972+ def test_preset_add_from_direct_api_asset_url_passes_through (self , project_dir ):
3973+ """'preset add --from <api-asset-url>' uses URL directly with octet-stream."""
3974+ from typer .testing import CliRunner
3975+ from unittest .mock import patch
3976+ from specify_cli import app
3977+
3978+ manifest_content = yaml .dump ({
3979+ "schema_version" : "1.0" ,
3980+ "preset" : {"id" : "my-preset" , "name" : "My Preset" , "version" : "1.0.0" , "description" : "Test preset" , "author" : "Test" , "license" : "MIT" },
3981+ "requires" : {"speckit_version" : ">=0.1.0" },
3982+ "provides" : {"templates" : [{"type" : "template" , "name" : "t" , "file" : "templates/t.md" , "description" : "t" }]},
3983+ })
3984+ zip_buf = __import__ ("io" ).BytesIO ()
3985+ with zipfile .ZipFile (zip_buf , "w" ) as zf :
3986+ zf .writestr ("preset.yml" , manifest_content )
3987+ zip_bytes = zip_buf .getvalue ()
3988+
3989+ captured_urls = []
3990+
3991+ class FakeResponse :
3992+ def __init__ (self , data ):
3993+ self ._data = data
3994+
3995+ def read (self ):
3996+ return self ._data
3997+
3998+ def __enter__ (self ):
3999+ return self
4000+
4001+ def __exit__ (self , * a ):
4002+ return False
4003+
4004+ def fake_open_url (url , timeout = None , extra_headers = None ):
4005+ captured_urls .append ((url , extra_headers ))
4006+ return FakeResponse (zip_bytes )
4007+
4008+ runner = CliRunner ()
4009+ with patch .object (Path , "cwd" , return_value = project_dir ), \
4010+ patch ("specify_cli.get_speckit_version" , return_value = "1.0.0" ), \
4011+ patch ("specify_cli.authentication.http.open_url" , side_effect = fake_open_url ):
4012+ result = runner .invoke (app , [
4013+ "preset" , "add" ,
4014+ "--from" , "https://api.github.com/repos/org/repo/releases/assets/42" ,
4015+ ])
4016+
4017+ assert result .exit_code == 0 , result .output
4018+ # Should go directly to the asset URL with Accept header
4019+ assert len (captured_urls ) == 1
4020+ assert captured_urls [0 ][0 ] == "https://api.github.com/repos/org/repo/releases/assets/42"
4021+ assert captured_urls [0 ][1 ] == {"Accept" : "application/octet-stream" }
4022+
4023+
38994024class TestWrapStrategy :
39004025 """Tests for strategy: wrap preset command substitution."""
39014026
0 commit comments