1
0

test-plugin-manifest.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
  4. REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
  5. MANIFEST="$REPO_ROOT/.kimi-plugin/plugin.json"
  6. python3 - "$MANIFEST" <<'PY'
  7. import json
  8. import sys
  9. from pathlib import Path
  10. manifest_path = Path(sys.argv[1])
  11. manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
  12. def assert_equal(actual, expected, label):
  13. if actual != expected:
  14. raise AssertionError(f"{label}: expected {expected!r}, got {actual!r}")
  15. def assert_present(text, needle, label):
  16. if needle not in text:
  17. raise AssertionError(f"{label}: missing {needle!r}")
  18. assert_equal(manifest.get("name"), "superpowers", "plugin name")
  19. assert_equal(manifest.get("skills"), "./skills/", "skills path")
  20. assert_equal(
  21. manifest.get("sessionStart", {}).get("skill"),
  22. "using-superpowers",
  23. "sessionStart.skill",
  24. )
  25. instructions = manifest.get("skillInstructions")
  26. if not isinstance(instructions, str) or not instructions.strip():
  27. raise AssertionError("skillInstructions must be a non-empty string")
  28. for token in [
  29. "AskUserQuestion",
  30. "TodoList",
  31. "Agent",
  32. "Skill",
  33. "Read",
  34. "Write",
  35. "Edit",
  36. "Bash",
  37. "Grep",
  38. "Glob",
  39. "FetchURL",
  40. "WebSearch",
  41. ]:
  42. assert_present(instructions, token, "skillInstructions")
  43. version_config = json.loads(
  44. (manifest_path.parents[1] / ".version-bump.json").read_text(encoding="utf-8")
  45. )
  46. version_entries = version_config.get("files")
  47. if not isinstance(version_entries, list):
  48. raise AssertionError(".version-bump.json must contain files list")
  49. if not any(
  50. entry.get("path") == ".kimi-plugin/plugin.json" and entry.get("field") == "version"
  51. for entry in version_entries
  52. if isinstance(entry, dict)
  53. ):
  54. raise AssertionError(
  55. ".version-bump.json must update .kimi-plugin/plugin.json version"
  56. )
  57. unsupported_fields = [
  58. "tools",
  59. "commands",
  60. "hooks",
  61. "apps",
  62. "inject",
  63. "configFile",
  64. "config_file",
  65. "bootstrap",
  66. ]
  67. present_unsupported = sorted(field for field in unsupported_fields if field in manifest)
  68. if present_unsupported:
  69. raise AssertionError(
  70. "unsupported Kimi runtime fields present: "
  71. + ", ".join(present_unsupported)
  72. )
  73. print("Kimi plugin manifest looks good")
  74. PY