Merge commit '35e6a301aa36e43df8458cb7c6ed40f60c642b78' into lsp-server

This commit is contained in:
csh
2026-03-04 15:56:24 +08:00
26 changed files with 842 additions and 59 deletions
+2
View File
@@ -11,10 +11,12 @@ tests/
│ └── test_playbook_cli.py # playbook.py 基础功能测试
├── test_format_md_action.py # format_md 动作测试
├── test_gitattributes_modes.py # gitattr_mode 行为测试
├── test_no_backup_flags.py # no_backup 行为测试
├── test_sync_directory_actions.py # sync_memory_bank/sync_prompts 行为测试
├── test_vendor_snapshot_templates.py # vendor 快照模板完整性测试
├── test_plan_progress_cli.py # plan_progress CLI 测试
├── test_superpowers_list_sync.py # superpowers 列表一致性测试
├── test_superpowers_workflows.py # superpowers 工作流配置校验
├── test_sync_templates_placeholders.py # 占位符替换测试(sync_rules/sync_standards
├── test_toml_edge_cases.py # TOML 解析边界测试
├── templates/ # 模板验证测试
@@ -126,6 +126,27 @@ langs = ["tsl"]
self.assertEqual(block[bullet_idx - 1], "")
def test_install_skills(self):
with tempfile.TemporaryDirectory() as tmp_dir:
target = Path(tmp_dir) / "agents"
config_body = f"""
[playbook]
project_root = "{tmp_dir}"
[install_skills]
agents_home = "{target}"
mode = "list"
skills = ["brainstorming"]
"""
config_path = Path(tmp_dir) / "playbook.toml"
config_path.write_text(config_body, encoding="utf-8")
result = run_cli("-config", str(config_path))
skill_file = target / "skills/brainstorming/SKILL.md"
self.assertEqual(result.returncode, 0)
self.assertTrue(skill_file.is_file())
def test_install_skills_rejects_codex_home(self):
with tempfile.TemporaryDirectory() as tmp_dir:
target = Path(tmp_dir) / "codex"
config_body = f"""
@@ -142,9 +163,8 @@ skills = ["brainstorming"]
result = run_cli("-config", str(config_path))
skill_file = target / "skills/brainstorming/SKILL.md"
self.assertEqual(result.returncode, 0)
self.assertTrue(skill_file.is_file())
self.assertNotEqual(result.returncode, 0)
self.assertIn("codex_home", result.stdout + result.stderr)
if __name__ == "__main__":
unittest.main()
@@ -15,11 +15,8 @@ VALID_LINKS=0
BROKEN_LINKS=0
SKIPPED_LINKS=0
BROKEN_LINKS_FILE="/tmp/broken_links.txt"
REPORT_FILE="/tmp/doc_links_report.txt"
> "$BROKEN_LINKS_FILE"
> "$REPORT_FILE"
BROKEN_LINKS_FILE="$(mktemp "${TMPDIR:-/tmp}/broken_links.XXXXXX")"
REPORT_FILE="$(mktemp "${TMPDIR:-/tmp}/doc_links_report.XXXXXX")"
echo "📁 Playbook 根目录: $PLAYBOOK_ROOT"
echo ""
@@ -91,6 +91,7 @@ validate_file_exists "$PROMPTS_DIR/README.md" "prompts/README.md"
validate_file_exists "$PROMPTS_DIR/system/agent-behavior.template.md" "prompts/system/agent-behavior.template.md"
validate_file_exists "$PROMPTS_DIR/coding/clarify.template.md" "prompts/coding/clarify.template.md"
validate_file_exists "$PROMPTS_DIR/coding/review.template.md" "prompts/coding/review.template.md"
validate_file_exists "$PROMPTS_DIR/coding/code-review.template.md" "prompts/coding/code-review.template.md"
validate_file_exists "$PROMPTS_DIR/meta/prompt-generator.template.md" "prompts/meta/prompt-generator.template.md"
echo ""
@@ -0,0 +1,15 @@
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
README = ROOT / "README.md"
class ReadmeLanguageListsTests(unittest.TestCase):
def test_rulesets_list_includes_typescript(self):
text = README.read_text(encoding="utf-8")
self.assertIn("- `rulesets/typescript/index.md`TypeScript 核心约定", text)
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,56 @@
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SYNC_WORKFLOW = ROOT / ".gitea" / "workflows" / "sync-superpowers.yml"
AUTO_UPDATE_WORKFLOW = ROOT / ".gitea" / "workflows" / "update-thirdparty-superpowers.yml"
AUTO_UPDATE_SCRIPT = ROOT / ".gitea" / "ci" / "update_thirdparty_superpowers.sh"
SYNC_SCRIPT = ROOT / ".gitea" / "ci" / "sync_superpowers.sh"
class SuperpowersWorkflowTests(unittest.TestCase):
def test_sync_workflow_uses_manual_trigger(self):
text = SYNC_WORKFLOW.read_text(encoding="utf-8")
self.assertIn("workflow_dispatch:", text)
def test_sync_workflow_runs_from_latest_main(self):
text = SYNC_WORKFLOW.read_text(encoding="utf-8")
self.assertIn('TARGET_BRANCH: "main"', text)
self.assertIn('git fetch origin "${{ env.TARGET_BRANCH }}"', text)
self.assertIn(
'git checkout -B "${{ env.TARGET_BRANCH }}" "origin/${{ env.TARGET_BRANCH }}"',
text,
)
def test_auto_update_workflow_triggers_on_main_push(self):
text = AUTO_UPDATE_WORKFLOW.read_text(encoding="utf-8")
self.assertIn("push:", text)
self.assertIn("- main", text)
self.assertIn("workflow_dispatch:", text)
def test_auto_update_workflow_runs_update_script(self):
text = AUTO_UPDATE_WORKFLOW.read_text(encoding="utf-8")
self.assertIn("bash .gitea/ci/update_thirdparty_superpowers.sh", text)
def test_auto_update_script_targets_thirdparty_branch(self):
text = AUTO_UPDATE_SCRIPT.read_text(encoding="utf-8")
self.assertIn('TARGET_BRANCH="${TARGET_BRANCH:-thirdparty/skill}"', text)
self.assertIn("api.github.com/repos", text)
self.assertIn("ls-remote", text)
self.assertIn('git checkout -B "$TARGET_BRANCH" "origin/$TARGET_BRANCH"', text)
def test_ci_scripts_use_ci_bot_identity(self):
sync_text = SYNC_SCRIPT.read_text(encoding="utf-8")
update_text = AUTO_UPDATE_SCRIPT.read_text(encoding="utf-8")
self.assertIn('COMMIT_AUTHOR_NAME="${COMMIT_AUTHOR_NAME:-ci-bot}"', sync_text)
self.assertIn('COMMIT_AUTHOR_EMAIL="${COMMIT_AUTHOR_EMAIL:-ci-bot@local}"', sync_text)
self.assertIn('COMMIT_AUTHOR_NAME="${COMMIT_AUTHOR_NAME:-ci-bot}"', update_text)
self.assertIn(
'COMMIT_AUTHOR_EMAIL="${COMMIT_AUTHOR_EMAIL:-ci-bot@local}"',
update_text,
)
if __name__ == "__main__":
unittest.main()
@@ -16,6 +16,15 @@ def run_cli(*args):
)
def run_script(script_path: Path, *args, cwd: Path | None = None):
return subprocess.run(
[sys.executable, str(script_path), *args],
capture_output=True,
text=True,
cwd=str(cwd) if cwd else None,
)
class SyncTemplatesPlaceholdersTests(unittest.TestCase):
def test_main_language_placeholder_replaced(self):
with tempfile.TemporaryDirectory() as tmp_dir:
@@ -44,6 +53,49 @@ langs = [\"cpp\", \"tsl\"]
self.assertIn("docs/standards/playbook/scripts/plan_progress.py", rules_text)
self.assertNotIn("{{PLAYBOOK_SCRIPTS}}", rules_text)
def test_sync_standards_rewrites_typescript_docs_prefix_for_vendored_playbook(self):
with tempfile.TemporaryDirectory() as tmp_dir:
root = Path(tmp_dir)
vendor_config = root / "vendor.toml"
vendor_config.write_text(
f"""
[playbook]
project_root = "{tmp_dir}"
[vendor]
langs = ["typescript"]
""",
encoding="utf-8",
)
vendor_result = run_cli("-config", str(vendor_config))
self.assertEqual(vendor_result.returncode, 0, msg=vendor_result.stderr)
sync_config = root / "sync.toml"
sync_config.write_text(
f"""
[playbook]
project_root = "{tmp_dir}"
[sync_standards]
langs = ["typescript"]
""",
encoding="utf-8",
)
vendored_script = (
root / "docs" / "standards" / "playbook" / "scripts" / "playbook.py"
)
sync_result = run_script(
vendored_script, "-config", str(sync_config), cwd=root
)
self.assertEqual(sync_result.returncode, 0, msg=sync_result.stderr)
agents_index = root / ".agents" / "typescript" / "index.md"
text = agents_index.read_text(encoding="utf-8")
self.assertIn("`docs/standards/playbook/docs/typescript/", text)
self.assertNotIn("`docs/typescript/", text)
if __name__ == "__main__":
unittest.main()