fix(agent-context): support multiple context files safely (#2969)

* fix(agent-context): support multiple context files safely

* fix(agent-context): harden context file validation

* fix(agent-context): preserve disabled context target

* fix(agent-context): address review follow-ups

* fix(agent-context): dedupe PowerShell context files

* fix(agent-context): align context file dedupe

* fix(agent-context): align bash context file dedupe

* fix(agent-context): preserve disabled display target

* fix(agent-context): require yaml-capable updater python

* fix(agent-context): preserve context files config

* fix(agent-context): align context file fallbacks

* fix(agent-context): share context file resolution

---------

Co-authored-by: AustinZ21 <AustinZ21@users.noreply.github.com>
This commit is contained in:
Austin Z.
2026-06-22 10:10:55 -07:00
committed by GitHub
parent cac16dd1d7
commit bbdf1b8f40
15 changed files with 1486 additions and 203 deletions

View File

@@ -29,6 +29,80 @@ class TestCodexInitFlow:
assert result.exit_code == 0, f"init --integration codex failed: {result.output}"
assert (target / ".agents" / "skills" / "speckit-plan" / "SKILL.md").exists()
def test_plan_skill_references_configured_context_files(self, tmp_path):
"""Plan skill should render all configured agent context files."""
from specify_cli import _save_agent_context_config
target = tmp_path / "test-proj"
target.mkdir()
_save_agent_context_config(
target,
{
"context_file": "AGENTS.md",
"context_files": ["AGENTS.md", "CLAUDE.md"],
"context_markers": {
"start": "<!-- SPECKIT START -->",
"end": "<!-- SPECKIT END -->",
},
},
)
integration = get_integration("codex")
manifest = IntegrationManifest("codex", target)
integration.setup(target, manifest, script_type="sh")
plan_skill = target / ".agents" / "skills" / "speckit-plan" / "SKILL.md"
content = plan_skill.read_text(encoding="utf-8")
assert "AGENTS.md, CLAUDE.md" in content
assert "__CONTEXT_FILE__" not in content
def test_plan_skill_ignores_context_files_when_agent_context_disabled(
self, tmp_path
):
"""Disabled agent-context must not leak stale context_files into commands."""
from specify_cli import _save_agent_context_config
target = tmp_path / "test-proj"
target.mkdir()
registry = target / ".specify" / "extensions" / ".registry"
registry.parent.mkdir(parents=True, exist_ok=True)
registry.write_text(
"""
{
"schema_version": "1.0",
"extensions": {
"agent-context": {
"version": "1.0.0",
"enabled": false
}
}
}
""".strip(),
encoding="utf-8",
)
_save_agent_context_config(
target,
{
"context_file": "AGENTS.md",
"context_files": ["../outside.md", "CLAUDE.md"],
"context_markers": {
"start": "<!-- SPECKIT START -->",
"end": "<!-- SPECKIT END -->",
},
},
)
integration = get_integration("codex")
manifest = IntegrationManifest("codex", target)
integration.setup(target, manifest, script_type="sh")
plan_skill = target / ".agents" / "skills" / "speckit-plan" / "SKILL.md"
content = plan_skill.read_text(encoding="utf-8")
assert "AGENTS.md, CLAUDE.md" not in content
assert "../outside.md" not in content
assert "AGENTS.md" in content
assert "__CONTEXT_FILE__" not in content
class TestCodexHookCommandNote:
"""Verify dot-to-hyphen normalization note is injected in hook sections.