diff --git a/agents/conductors/clone/_clone.py b/agents/conductors/clone/_clone.py index 93acd6d0..7f67bf16 100644 --- a/agents/conductors/clone/_clone.py +++ b/agents/conductors/clone/_clone.py @@ -81,6 +81,7 @@ "modes/*", # Teacher/Assistant mode machinery "skills/_style.md", "skills/_bootstrap_skill.md", "skills/README.md", "skills/start-new-project*", "skills/contribute-upstream*", + "skills/feedback.md", # portable user-reviewed feedback, no domain "sources.yaml", "sources/*", # the source-registry pattern "autoassistant/*", # API gate + wiki-currency + benchmark tooling ".mcp.json", # wires the results-inspector MCP, which is @@ -97,8 +98,10 @@ ".claude/hooks/*", ".claude/settings.json", ".codex/hooks.json", ".gemini/*", ".claude/skills/_*", ".claude/skills/start-new-project*", ".claude/skills/contribute-upstream*", + ".claude/skills/feedback.md", ".claude/commands/_*", ".claude/commands/start-new-project*", ".claude/commands/contribute-upstream*", + ".claude/commands/feedback.md", ] # Domain content a newborn regenerates/stubs rather than copies blind, shared @@ -184,6 +187,8 @@ "wiki/literature/*", # the near-empty literature scaffold ], "domain": [ + "scripts/start_here/*", # bundled Gaussian example, regrow per domain + "scripts/experimental_colab.py", "notebooks/experimental_colab.ipynb", "docs/*", # setup + archive pages: agent-access # mechanics read the same everywhere, # the worked prompts are domain diff --git a/bin/sync_feedback.py b/bin/sync_feedback.py new file mode 100644 index 00000000..2b219a63 --- /dev/null +++ b/bin/sync_feedback.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +"""Build a standalone assistant skill from Brain's canonical feedback resources. + +Write the reference assistant, then use clone sync for sibling propagation. +This does not install skills globally or change any harness configuration. +""" +from __future__ import annotations + +import argparse +from pathlib import Path + + +SOURCE = Path(__file__).resolve().parents[1] / "skills" / "feedback" + + +def render(source: Path = SOURCE) -> str: + metadata = (source / "SKILL.md").read_text().split("---", 2)[1].strip() + workflow = (source / "feedback.md").read_text() + workflow = workflow.replace("[template.md](template.md)", "[report template](#report-template)") + workflow = workflow.replace("[invitation.md](invitation.md)", "[portable invitation](#portable-invitation)") + template = (source / "template.md").read_text().split("\n", 1)[1].lstrip() + invitation = (source / "invitation.md").read_text().split("\n", 1)[1].lstrip() + return ( + f"---\n{metadata}\n---\n\n" + "\n\n" + "This is a feedback-drafting skill, not a science-code skill. Its output is\n" + "a user-reviewed draft, not a script or a wiki entry. All resources are\n" + "embedded below; using this skill needs no Brain checkout or setup.\n\n" + + workflow.rstrip() + "\n\n## Report template\n\n" + template.rstrip() + + "\n\n## Portable invitation\n\n" + invitation.rstrip() + "\n" + ) + + +def main(argv=None) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("assistant", type=Path, nargs="+", help="explicit assistant checkout(s)") + parser.add_argument("--check", action="store_true", help="report drift, write nothing") + args = parser.parse_args(argv) + expected = render() + failed = False + for root in args.assistant: + if not (root / "skills").is_dir() or not (root / "AGENTS.md").is_file(): + parser.error(f"not an assistant checkout: {root}") + path = root / "skills" / "feedback.md" + if path.is_symlink(): + parser.error(f"refusing to write through a skill symlink: {path}") + current = path.read_text() if path.is_file() else None + if current == expected: + print(f"current: {path}") + elif args.check: + print(f"drift: {path}") + failed = True + else: + path.write_text(expected) + print(f"wrote: {path}") + return int(failed) + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/skills/feedback/SKILL.md b/skills/feedback/SKILL.md index 1c1c3392..6c0acffa 100644 --- a/skills/feedback/SKILL.md +++ b/skills/feedback/SKILL.md @@ -9,3 +9,11 @@ Follow [feedback.md](feedback.md). Use [template.md](template.md) for the report and [invitation.md](invitation.md) when inviting another user to contribute. This is the Community Agent's session-side drafting workflow, not a new conductor. It needs no GitHub access or local checkout in quick mode. + +## Assistant distribution (maintainers) + +These files are the canonical workflow, template and invitation. Generate the +standalone reference with `python3 bin/sync_feedback.py ../autolens_assistant`; +use `--check` to detect drift without writing. Propagate the resulting generic +reference diff with `pyauto-brain clone sync`, then regenerate each assistant's +own project-discovery adapters. The embedded copy runs without Brain installed. diff --git a/tests/test_feedback_distribution.py b/tests/test_feedback_distribution.py new file mode 100644 index 00000000..d0fc9daa --- /dev/null +++ b/tests/test_feedback_distribution.py @@ -0,0 +1,45 @@ +"""The distributed feedback command must work without a Brain checkout.""" +import importlib.util +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +spec = importlib.util.spec_from_file_location('sync_feedback', ROOT / 'bin/sync_feedback.py') +sync = importlib.util.module_from_spec(spec) +spec.loader.exec_module(sync) + + +def test_standalone_embeds_canonical_template_and_invitation(): + text = sync.render() + for filename in ('template.md', 'invitation.md'): + source = (sync.SOURCE / filename).read_text().split('\n', 1)[1].strip() + assert source in text + assert '(template.md)' not in text and '(invitation.md)' not in text + assert '(#report-template)' in text and '(#portable-invitation)' in text + assert 'needs no Brain checkout' in text + assert 'feedback-report: v1' in text + + +def test_generator_check_reports_drift_without_writing(tmp_path): + (tmp_path / 'skills').mkdir() + (tmp_path / 'AGENTS.md').write_text('assistant') + output = tmp_path / 'skills/feedback.md' + assert sync.main([str(tmp_path), '--check']) == 1 + assert not output.exists() + assert sync.main([str(tmp_path)]) == 0 + assert output.read_text() == sync.render() + assert sync.main([str(tmp_path), '--check']) == 0 + output.write_text('user edit') + assert sync.main([str(tmp_path), '--check']) == 1 + assert output.read_text() == 'user edit' + + +def test_clone_boundary_keeps_portable_skill_generic(): + import sys + sys.path.insert(0, str(ROOT / 'agents/conductors/clone')) + import _clone + for reference in _clone.REFERENCE_PROFILES: + patterns = _clone.reference_profile(reference)['generic'] + for path in ('skills/feedback.md', '.claude/skills/feedback.md', '.claude/commands/feedback.md'): + assert _clone.match_any(path, patterns) + namespace = reference.replace('_', '-') + assert not _clone.match_any(f'.codex/skills/{namespace}-feedback/SKILL.md', patterns)