Skip to content

Commit 5cce80f

Browse files
committed
feat: Stage 2 completion — integration scripts, integration.json, shared manifest
- Added copilot/scripts/update-context.sh and .ps1 (thin wrappers that delegate to the shared update-agent-context script) - CopilotIntegration.setup() installs integration scripts to .specify/integrations/copilot/scripts/ - Renamed agent.json → integration.json with script paths - _install_shared_infra() now tracks files in integration-shared.manifest.json - Updated tests: scripts installed, integration.json has script paths, shared manifest recorded (74 tests) Part of github#1924
1 parent ebb909f commit 5cce80f

5 files changed

Lines changed: 87 additions & 12 deletions

File tree

‎src/specify_cli/__init__.py‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,9 +1206,13 @@ def _install_shared_infra(
12061206
12071207
Copies ``.specify/scripts/``, ``.specify/templates/``, and
12081208
``.specify/memory/`` from the bundled core_pack or source checkout.
1209+
Tracks all installed files in ``_framework.manifest.json``.
12091210
Returns ``True`` on success.
12101211
"""
1212+
from .integrations.manifest import IntegrationManifest
1213+
12111214
core = _locate_core_pack()
1215+
manifest = IntegrationManifest("integration-shared", project_path, version=get_speckit_version())
12121216

12131217
# Scripts
12141218
if core and (core / "scripts").is_dir():
@@ -1227,6 +1231,10 @@ def _install_shared_infra(
12271231
if dest_variant.exists():
12281232
shutil.rmtree(dest_variant)
12291233
shutil.copytree(variant_src, dest_variant)
1234+
for f in dest_variant.rglob("*"):
1235+
if f.is_file():
1236+
rel = f.relative_to(project_path).as_posix()
1237+
manifest.record_existing(rel)
12301238

12311239
# Page templates (not command templates, not vscode-settings.json)
12321240
if core and (core / "templates").is_dir():
@@ -1240,9 +1248,12 @@ def _install_shared_infra(
12401248
dest_templates.mkdir(parents=True, exist_ok=True)
12411249
for f in templates_src.iterdir():
12421250
if f.is_file() and f.name != "vscode-settings.json" and not f.name.startswith("."):
1243-
# Skip command templates directory
1244-
shutil.copy2(f, dest_templates / f.name)
1251+
dst = dest_templates / f.name
1252+
shutil.copy2(f, dst)
1253+
rel = dst.relative_to(project_path).as_posix()
1254+
manifest.record_existing(rel)
12451255

1256+
manifest.save()
12461257
return True
12471258

12481259

@@ -2186,12 +2197,16 @@ def init(
21862197
)
21872198
manifest.save()
21882199

2189-
# Write .specify/agent.json
2190-
agent_json = project_path / ".specify" / "agent.json"
2191-
agent_json.parent.mkdir(parents=True, exist_ok=True)
2192-
agent_json.write_text(json.dumps({
2200+
# Write .specify/integration.json
2201+
script_ext = "sh" if selected_script == "sh" else "ps1"
2202+
integration_json = project_path / ".specify" / "integration.json"
2203+
integration_json.parent.mkdir(parents=True, exist_ok=True)
2204+
integration_json.write_text(json.dumps({
21932205
"integration": resolved_integration.key,
21942206
"version": get_speckit_version(),
2207+
"scripts": {
2208+
"update-context": f".specify/integrations/{resolved_integration.key}/scripts/update-context.{script_ext}",
2209+
},
21952210
}, indent=2) + "\n", encoding="utf-8")
21962211

21972212
tracker.complete("integration", resolved_integration.config.get("name", resolved_integration.key))

‎src/specify_cli/integrations/copilot/__init__.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,21 @@ def setup(
109109
self.record_file_in_manifest(dst_settings, project_root, manifest)
110110
created.append(dst_settings)
111111

112+
# 4. Install integration-specific update-context scripts
113+
scripts_src = Path(__file__).resolve().parent / "scripts"
114+
if scripts_src.is_dir():
115+
scripts_dest = project_root / ".specify" / "integrations" / "copilot" / "scripts"
116+
scripts_dest.mkdir(parents=True, exist_ok=True)
117+
for src_script in sorted(scripts_src.iterdir()):
118+
if src_script.is_file():
119+
dst_script = scripts_dest / src_script.name
120+
shutil.copy2(src_script, dst_script)
121+
# Make shell scripts executable
122+
if dst_script.suffix == ".sh":
123+
dst_script.chmod(dst_script.stat().st_mode | 0o111)
124+
self.record_file_in_manifest(dst_script, project_root, manifest)
125+
created.append(dst_script)
126+
112127
return created
113128

114129
def _vscode_settings_path(self) -> Path | None:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# update-context.ps1 — Copilot integration update-context script
2+
#
3+
# Thin wrapper that delegates to the shared update-agent-context.ps1
4+
# with the copilot agent type. Installed by the integration into
5+
# .specify/integrations/copilot/scripts/ and referenced from
6+
# .specify/agent.json so the shared dispatcher can find it.
7+
8+
$ErrorActionPreference = 'Stop'
9+
10+
$repoRoot = git rev-parse --show-toplevel 2>$null
11+
if (-not $repoRoot) { $repoRoot = $PWD.Path }
12+
13+
# Delegate to the shared update-agent-context script
14+
& "$repoRoot/.specify/scripts/powershell/update-agent-context.ps1" -AgentType copilot @args
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
# update-context.sh — Copilot integration update-context script
3+
#
4+
# Thin wrapper that delegates to the shared update-agent-context.sh
5+
# with the copilot agent type. Installed by the integration into
6+
# .specify/integrations/copilot/scripts/ and referenced from
7+
# .specify/agent.json so the shared dispatcher can find it.
8+
9+
set -euo pipefail
10+
11+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
13+
14+
# Delegate to the shared update-agent-context script
15+
exec "$REPO_ROOT/.specify/scripts/bash/update-agent-context.sh" copilot "$@"

‎tests/test_integrations.py‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,10 @@ def test_directory_structure(self, tmp_path):
724724
data = json.loads(settings.read_text(encoding="utf-8"))
725725
assert "chat.promptFilesRecommendations" in data
726726

727-
# No other top-level directories created
727+
# Only expected top-level directories
728728
top_dirs = {d.name for d in tmp_path.iterdir() if d.is_dir()}
729-
assert top_dirs == {".github", ".vscode"} or top_dirs == {".github"}
729+
expected = {".github", ".vscode", ".specify"}
730+
assert top_dirs.issubset(expected)
730731

731732
def test_templates_are_processed(self, tmp_path):
732733
"""Verify raw placeholders are replaced in generated command files."""
@@ -820,10 +821,10 @@ def test_integration_copilot_creates_files(self, tmp_path):
820821
assert (project / ".specify" / "scripts" / "bash" / "common.sh").exists()
821822
assert (project / ".specify" / "templates" / "spec-template.md").exists()
822823

823-
# agent.json
824-
agent_json = project / ".specify" / "agent.json"
825-
assert agent_json.exists()
826-
data = json.loads(agent_json.read_text(encoding="utf-8"))
824+
# integration.json
825+
integration_json = project / ".specify" / "integration.json"
826+
assert integration_json.exists()
827+
data = json.loads(integration_json.read_text(encoding="utf-8"))
827828
assert data["integration"] == "copilot"
828829

829830
# init-options.json
@@ -837,6 +838,21 @@ def test_integration_copilot_creates_files(self, tmp_path):
837838
manifest = project / ".specify" / "integrations" / "copilot.manifest.json"
838839
assert manifest.exists()
839840

841+
# Integration-specific scripts installed
842+
update_script = project / ".specify" / "integrations" / "copilot" / "scripts" / "update-context.sh"
843+
assert update_script.exists()
844+
845+
# integration.json has script paths
846+
assert "scripts" in data
847+
assert "update-context" in data["scripts"]
848+
849+
# Shared infrastructure manifest
850+
shared_manifest = project / ".specify" / "integrations" / "integration-shared.manifest.json"
851+
assert shared_manifest.exists()
852+
shared_data = json.loads(shared_manifest.read_text(encoding="utf-8"))
853+
assert shared_data["integration"] == "integration-shared"
854+
assert len(shared_data["files"]) > 0
855+
840856
def test_ai_copilot_auto_promotes(self, tmp_path):
841857
"""--ai copilot should auto-promote to integration path with a nudge."""
842858
from typer.testing import CliRunner

0 commit comments

Comments
 (0)