diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 060813b..4a9f025 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -5,56 +5,114 @@ on:
branches: [main, master]
pull_request:
branches: [main, master]
+ workflow_call:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' }}
jobs:
test:
runs-on: ubuntu-latest
+ timeout-minutes: 15
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v5
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ matrix.python-version }}
- cache: "pip"
+
+ - name: Set up uv
+ uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
+ with:
+ enable-cache: true
- name: Set up Bun
- uses: oven-sh/setup-bun@v2
+ uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
- bun-version: latest
+ bun-version: "1.3.14"
- - name: Install dependencies
+ - name: Install Python dependencies
run: |
- python -m pip install --upgrade pip
- pip install -e ".[test]"
+ uv sync --python "${{ matrix.python-version }}" --frozen --extra test
- - name: Run linter
+ - name: Run Python linter
run: |
- ruff check .
+ uv run ruff check .
- - name: Validate plugin manifest and assets
+ - name: Run shell script checks
run: |
- pytest -v tests/test_plugin_manifest.py
+ bash -n scripts/package-plugin.sh skills/poteto-mode/scripts/worktree-audit.sh skills/show-me-your-work/scripts/log.sh
+ shellcheck -S warning scripts/package-plugin.sh skills/poteto-mode/scripts/worktree-audit.sh skills/show-me-your-work/scripts/log.sh
- name: Run setup runtime doctor
run: |
- python skills/setup-agystack/scripts/setup_runtime.py --doctor
+ uv run python skills/setup-agystack/scripts/setup_runtime.py --doctor
- name: Run pytest test suite
run: |
- pytest -v --timeout=60 tests/
+ uv run pytest -v --timeout=60 tests/
- name: Install script dependencies
working-directory: skills/poteto-mode/scripts
run: |
bun install --frozen-lockfile
+ - name: Typecheck TypeScript tools
+ working-directory: skills/poteto-mode/scripts
+ run: |
+ bun run typecheck
+
- name: Run TypeScript unit tests
working-directory: skills/poteto-mode/scripts
run: |
bun test
+ - name: Verify plugin packaging archive
+ run: |
+ pkg_dir="$RUNNER_TEMP/pkg-test"
+ rm -rf "$pkg_dir"
+ bash scripts/package-plugin.sh --output-dir "$pkg_dir"
+ archive=$(find "$pkg_dir" -maxdepth 1 -name '*.zip' | head -n 1)
+ test -n "$archive"
+ unzip -t "$archive" >/dev/null
+ python3 - "$archive" <<'PY'
+ import sys
+ import zipfile
+ from pathlib import Path
+
+ with zipfile.ZipFile(sys.argv[1]) as zf:
+ if zf.testzip() is not None:
+ raise SystemExit("Corrupt zip entry detected")
+ names = set(zf.namelist())
+
+ required = {
+ "plugin.json",
+ "README.md",
+ "LICENSE",
+ "agystack-models.md",
+ "agystack-runtime.json.example",
+ "hooks.json.example",
+ }
+ missing = sorted(required - names)
+ if missing:
+ raise SystemExit(f"Missing required root assets: {missing}")
+
+ forbidden = [
+ name for name in sorted(names)
+ if name.endswith(".test.ts")
+ or name.endswith(".test-helper.ts")
+ or "__pycache__" in Path(name).parts
+ or "node_modules" in Path(name).parts
+ ]
+ if forbidden:
+ raise SystemExit(f"Forbidden entries in archive: {forbidden[:10]}")
+ PY
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 4926fc1..9cee166 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -5,37 +5,54 @@ on:
tags:
- "v*"
+permissions:
+ contents: read
+
jobs:
+ ci:
+ uses: ./.github/workflows/ci.yml
+
build-and-release:
+ needs: ci
runs-on: ubuntu-latest
+ timeout-minutes: 15
permissions:
contents: write
steps:
- - uses: actions/checkout@v4
-
- - name: Set up Python
- uses: actions/setup-python@v5
- with:
- python-version: "3.12"
- cache: "pip"
-
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install -e ".[test]"
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- - name: Validate manifest and run test suite
+ - name: Verify release tag matches manifest versions
run: |
- pytest -v tests/test_plugin_manifest.py
- pytest -v tests/test_skill_catalog.py
+ tag_version="${GITHUB_REF_NAME#v}"
+ python3 - "$tag_version" <<'PY'
+ import json
+ import sys
+ import tomllib
+ from pathlib import Path
+
+ tag_version = sys.argv[1]
+ plugin_version = json.loads(Path("plugin.json").read_text(encoding="utf-8"))["version"]
+ pyproject_version = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))["project"]["version"]
+ marketplace_version = json.loads(Path("docs/marketplace-submission.json").read_text(encoding="utf-8"))["version"]
+
+ versions = {
+ "tag": tag_version,
+ "plugin.json": plugin_version,
+ "pyproject.toml": pyproject_version,
+ "docs/marketplace-submission.json": marketplace_version,
+ }
+ if len(set(versions.values())) != 1:
+ raise SystemExit(f"Release version mismatch: {versions}")
+ print(f"Verified release version parity: {tag_version}")
+ PY
- name: Package plugin distribution archive
run: |
bash scripts/package-plugin.sh
- name: Create GitHub Release
- uses: softprops/action-gh-release@v2
+ uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
with:
files: dist/*.zip
generate_release_notes: true
diff --git a/Makefile b/Makefile
index 8cd3525..453b046 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,28 @@
-.PHONY: test lint doctor clean
+.PHONY: test lint typecheck doctor package-check ci clean
test:
- pytest -v tests/
+ uv run pytest -v --timeout=60 tests/
+ cd skills/poteto-mode/scripts && bun test
lint:
- ruff check .
+ uv run ruff check .
+ bash -n scripts/package-plugin.sh skills/poteto-mode/scripts/worktree-audit.sh skills/show-me-your-work/scripts/log.sh
+ @if command -v shellcheck >/dev/null 2>&1; then \
+ shellcheck -S warning scripts/package-plugin.sh skills/poteto-mode/scripts/worktree-audit.sh skills/show-me-your-work/scripts/log.sh; \
+ else \
+ echo "WARNING: shellcheck not found on PATH; skipping shellcheck."; \
+ fi
+
+typecheck:
+ cd skills/poteto-mode/scripts && bun run typecheck
doctor:
- python3 skills/setup-agystack/scripts/setup_runtime.py --doctor
+ uv run python skills/setup-agystack/scripts/setup_runtime.py --doctor
+
+package-check:
+ bash scripts/package-plugin.sh --test
+
+ci: lint typecheck doctor test package-check
clean:
rm -rf .pytest_cache .ruff_cache __pycache__ *.egg-info dist build
diff --git a/pyproject.toml b/pyproject.toml
index 993551b..2e1a9c3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -46,10 +46,9 @@ exclude = [
]
[tool.ruff.lint]
-select = ["E4", "E7", "E9", "F"]
-ignore = ["E402", "E501", "E722"]
+select = ["E4", "E7", "E9", "F", "W", "B"]
+ignore = ["E402", "E501"]
[tool.ruff.lint.per-file-ignores]
"tests/*" = ["F401", "F841"]
-"skills/poteto-mode/scripts/*" = ["ALL"]
diff --git a/scripts/package-plugin.sh b/scripts/package-plugin.sh
index 862acbe..ae9a2db 100755
--- a/scripts/package-plugin.sh
+++ b/scripts/package-plugin.sh
@@ -2,7 +2,60 @@
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-cd "${REPO_ROOT}"
+
+TEST_MODE=false
+OUTPUT_DIR=""
+
+usage() {
+ cat <<'EOF'
+Usage: package-plugin.sh [--test] [--output-dir
]
+
+Options:
+ --test Validate plugin.json, run agy validate if installed, and verify archive invariants
+ --output-dir Write archive to instead of /dist
+ -h, --help Show this help message and exit
+EOF
+}
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --test)
+ TEST_MODE=true
+ shift
+ ;;
+ --output-dir)
+ if [[ $# -lt 2 || -z "$2" ]]; then
+ echo "Error: --output-dir requires a directory argument" >&2
+ exit 1
+ fi
+ OUTPUT_DIR="$2"
+ shift 2
+ ;;
+ --output-dir=*)
+ OUTPUT_DIR="${1#--output-dir=}"
+ if [[ -z "${OUTPUT_DIR}" ]]; then
+ echo "Error: --output-dir requires a non-empty directory" >&2
+ exit 1
+ fi
+ shift
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "Error: unknown argument: $1" >&2
+ usage >&2
+ exit 1
+ ;;
+ esac
+done
+
+if [[ -n "${OUTPUT_DIR}" && "${OUTPUT_DIR}" != /* ]]; then
+ OUTPUT_DIR="$(pwd)/${OUTPUT_DIR}"
+fi
+
+cd "${REPO_ROOT}" || exit 1
MANIFEST="${REPO_ROOT}/plugin.json"
if [[ ! -f "${MANIFEST}" ]]; then
@@ -10,43 +63,103 @@ if [[ ! -f "${MANIFEST}" ]]; then
exit 1
fi
-VERSION=$(python3 -c "import json; print(json.load(open('${MANIFEST}'))['version'])")
-NAME=$(python3 -c "import json; print(json.load(open('${MANIFEST}'))['name'])")
+MANIFEST_INFO=$(python3 -c '
+import json
+import sys
+
+with open(sys.argv[1], encoding="utf-8") as f:
+ data = json.load(f)
+if not isinstance(data, dict):
+ raise SystemExit("Error: plugin.json root must be a JSON object")
+name = data.get("name")
+version = data.get("version")
+if not isinstance(name, str) or not name.strip():
+ raise SystemExit("Error: plugin.json missing non-empty string \"name\"")
+if not isinstance(version, str) or not version.strip():
+ raise SystemExit("Error: plugin.json missing non-empty string \"version\"")
+print(f"{name.strip()}\t{version.strip()}")
+' "${MANIFEST}")
+IFS=$'\t' read -r NAME VERSION <<< "${MANIFEST_INFO}"
+
+build_archive() {
+ local dest_dir="$1"
+ mkdir -p "${dest_dir}"
+ local archive="${dest_dir}/${NAME}-${VERSION}.zip"
+ rm -f "${archive}"
+ zip -r -q "${archive}" \
+ plugin.json \
+ README.md \
+ LICENSE \
+ assets/ \
+ rules/ \
+ agents/ \
+ skills/ \
+ agystack-models.md \
+ agystack-runtime.json.example \
+ hooks.json.example \
+ -x "*.DS_Store" \
+ -x "*__pycache__*" \
+ -x "*.pytest_cache*" \
+ -x "*.ruff_cache*" \
+ -x "*.venv*" \
+ -x "*node_modules*" \
+ -x "*.test.ts" \
+ -x "*.test-helper.ts"
+ printf '%s\n' "${archive}"
+}
-if [[ "${1:-}" == "--test" ]]; then
+verify_archive() {
+ local archive="$1"
+ unzip -t "${archive}" >/dev/null
+ python3 -c '
+import sys
+import zipfile
+
+with zipfile.ZipFile(sys.argv[1]) as zf:
+ names = zf.namelist()
+required = [
+ "plugin.json",
+ "README.md",
+ "LICENSE",
+ "agystack-models.md",
+ "agystack-runtime.json.example",
+ "hooks.json.example",
+]
+missing = [r for r in required if r not in names]
+if missing:
+ raise SystemExit(f"Error: archive missing required files: {missing}")
+forbidden = [
+ n for n in names
+ if n.endswith(".test.ts")
+ or n.endswith(".test-helper.ts")
+ or "__pycache__" in n.split("/")
+ or "node_modules" in n.split("/")
+]
+if forbidden:
+ raise SystemExit(f"Error: archive contains forbidden entries: {forbidden[:10]}")
+' "${archive}"
+}
+
+if [[ "${TEST_MODE}" == "true" ]]; then
echo "Testing package readiness for ${NAME} v${VERSION}..."
- if command -v /Users/joeltaroreh/.gemini/bin/agy >/dev/null 2>&1; then
- /Users/joeltaroreh/.gemini/bin/agy plugin validate "${REPO_ROOT}" --strict
+ TMP_PKG_DIR="$(mktemp -d)"
+ trap 'rm -rf "${TMP_PKG_DIR}"' EXIT
+ TEST_ARCHIVE="$(build_archive "${TMP_PKG_DIR}")"
+ verify_archive "${TEST_ARCHIVE}"
+
+ if command -v agy >/dev/null 2>&1; then
+ agy plugin validate "${REPO_ROOT}" --strict
+ echo "Package dry-run verified successfully for ${NAME} v${VERSION}"
+ else
+ echo "WARNING: agy CLI not found on PATH; skipping strict CLI validation." >&2
+ echo "Package archive dry-run verified for ${NAME} v${VERSION} (strict CLI validation skipped)"
fi
- echo "Package dry-run verified successfully for ${NAME} v${VERSION}"
exit 0
fi
-DIST_DIR="${REPO_ROOT}/dist"
-mkdir -p "${DIST_DIR}"
-ARCHIVE="${DIST_DIR}/${NAME}-${VERSION}.zip"
-
-rm -f "${ARCHIVE}"
-
-echo "Packaging ${NAME} v${VERSION} into ${ARCHIVE}..."
-
-zip -r -q "${ARCHIVE}" \
- plugin.json \
- README.md \
- LICENSE \
- assets/ \
- rules/ \
- agents/ \
- skills/ \
- agystack-models.md \
- agystack-runtime.json.example \
- hooks.json.example \
- -x "*.DS_Store" \
- -x "*__pycache__*" \
- -x "*.pytest_cache*" \
- -x "*.ruff_cache*" \
- -x "*.venv*" \
- -x "*node_modules*"
+DIST_DIR="${OUTPUT_DIR:-${REPO_ROOT}/dist}"
+echo "Packaging ${NAME} v${VERSION} into ${DIST_DIR}/${NAME}-${VERSION}.zip..."
+ARCHIVE="$(build_archive "${DIST_DIR}")"
echo "Archive created: ${ARCHIVE}"
ls -lh "${ARCHIVE}"
diff --git a/skills/cloud-swarm/scripts/cloud_dispatch.py b/skills/cloud-swarm/scripts/cloud_dispatch.py
index 0c6f9a5..818e575 100644
--- a/skills/cloud-swarm/scripts/cloud_dispatch.py
+++ b/skills/cloud-swarm/scripts/cloud_dispatch.py
@@ -1626,7 +1626,7 @@ def main() -> None:
session_id = args.session_id or f"swarm-{int(time.time())}"
env_vars["SWARM_SESSION_ID"] = session_id
env_vars["SESSION_ID"] = session_id
- for name, env_key in LIMIT_ENV.items():
+ for _name, env_key in LIMIT_ENV.items():
if env_key in os.environ:
env_vars[env_key] = os.environ[env_key]
if args.orchestrator_timeout:
@@ -1830,7 +1830,7 @@ def main() -> None:
log_read_args.extend(["--project", project])
log_cmd_str += f" --project={project}"
- for attempt in range(2):
+ for _attempt in range(2):
try:
log_res = subprocess.run(
log_read_args,
diff --git a/skills/cloud-swarm/scripts/result_harvester.py b/skills/cloud-swarm/scripts/result_harvester.py
index 48eb40a..b6f55a5 100644
--- a/skills/cloud-swarm/scripts/result_harvester.py
+++ b/skills/cloud-swarm/scripts/result_harvester.py
@@ -47,7 +47,7 @@ def extract_pareto_frontier(
for i, trial_a in enumerate(candidates):
ma, sa = points[i]
dominated = False
- for j, trial_b in enumerate(candidates):
+ for j, _trial_b in enumerate(candidates):
if i == j:
continue
mb, sb = points[j]
diff --git a/skills/cloud-swarm/scripts/steer_cloud_task.py b/skills/cloud-swarm/scripts/steer_cloud_task.py
index 1045122..e8a2e20 100755
--- a/skills/cloud-swarm/scripts/steer_cloud_task.py
+++ b/skills/cloud-swarm/scripts/steer_cloud_task.py
@@ -39,8 +39,8 @@ def validate_task_target(
return "all"
try:
task_idx = int(cleaned)
- except ValueError:
- raise ValueError(f"Invalid task target '{task}': must be an integer index or 'all'")
+ except ValueError as err:
+ raise ValueError(f"Invalid task target '{task}': must be an integer index or 'all'") from err
elif isinstance(task, int):
task_idx = task
else:
diff --git a/skills/cloud-swarm/scripts/storage_messenger.py b/skills/cloud-swarm/scripts/storage_messenger.py
index d4169e5..b738c20 100644
--- a/skills/cloud-swarm/scripts/storage_messenger.py
+++ b/skills/cloud-swarm/scripts/storage_messenger.py
@@ -273,8 +273,8 @@ def upload_from_string(
flags = os.O_CREAT | os.O_EXCL | os.O_WRONLY
try:
fd = os.open(str(self.path), flags, 0o666)
- except FileExistsError:
- raise FileExistsError(f"Target object already exists: {self.path}")
+ except FileExistsError as err:
+ raise FileExistsError(f"Target object already exists: {self.path}") from err
with open(fd, "w", encoding="utf-8") as f:
f.write(data)
else:
@@ -354,7 +354,7 @@ def __init__(
try:
from google.cloud import storage
self.client = storage.Client()
- except Exception:
+ except Exception as err:
token = None
try:
import storage_uploader
@@ -365,7 +365,7 @@ def __init__(
self.client = _GcsRestClient(token)
else:
if bool(os.environ.get("K_SERVICE") or os.environ.get("CLOUD_RUN_TASK_INDEX")):
- raise RuntimeError("GCS credentials unavailable in Cloud Run environment; cannot use local fallback")
+ raise RuntimeError("GCS credentials unavailable in Cloud Run environment; cannot use local fallback") from err
import tempfile
self.client = _LocalClient(Path(tempfile.gettempdir()) / "agystack_storage")
@@ -610,16 +610,16 @@ def _resolve_max_seq():
obj_path = self._inbox_steer_path(task_index, steer_seq)
blob = self.bucket.blob(obj_path)
- def _upload_blob():
+ def _upload_blob(target_blob=blob, target_envelope=envelope):
try:
- blob.upload_from_string(
- envelope.to_json(),
+ target_blob.upload_from_string(
+ target_envelope.to_json(),
content_type="application/json",
if_generation_match=0,
)
except TypeError:
- blob.upload_from_string(
- envelope.to_json(),
+ target_blob.upload_from_string(
+ target_envelope.to_json(),
content_type="application/json",
)
diff --git a/skills/cloud-swarm/scripts/worker/agent_hooks.py b/skills/cloud-swarm/scripts/worker/agent_hooks.py
index 6ac6f44..8611c3a 100644
--- a/skills/cloud-swarm/scripts/worker/agent_hooks.py
+++ b/skills/cloud-swarm/scripts/worker/agent_hooks.py
@@ -37,7 +37,7 @@ def emit_tool_invocation(
) -> None:
cw = sys.modules.get("cloud_worker")
if cw and hasattr(cw, "emit_tool_invocation"):
- return cw.emit_tool_invocation(task_index, tool_name, args, call_id=call_id, *extra_args, **kwargs)
+ return cw.emit_tool_invocation(task_index, tool_name, args, call_id, *extra_args, **kwargs)
def emit_tool_result(
@@ -56,9 +56,9 @@ def emit_tool_result(
task_index,
tool_name,
output,
- success=success,
- call_id=call_id,
- duration_s=duration_s,
+ success,
+ call_id,
+ duration_s,
*extra_args,
**kwargs,
)
diff --git a/skills/cloud-swarm/scripts/worker/execution.py b/skills/cloud-swarm/scripts/worker/execution.py
index 6ae710b..6e7126a 100644
--- a/skills/cloud-swarm/scripts/worker/execution.py
+++ b/skills/cloud-swarm/scripts/worker/execution.py
@@ -149,7 +149,7 @@ def drain(stream, buffer):
readers = [
threading.Thread(target=drain, args=(stream, buffer), daemon=True)
- for stream, buffer in zip((process.stdout, process.stderr), buffers)
+ for stream, buffer in zip((process.stdout, process.stderr), buffers, strict=True)
]
for reader in readers:
reader.start()
diff --git a/skills/cloud-swarm/scripts/worker/partner_engine.py b/skills/cloud-swarm/scripts/worker/partner_engine.py
index 35fa420..4224588 100644
--- a/skills/cloud-swarm/scripts/worker/partner_engine.py
+++ b/skills/cloud-swarm/scripts/worker/partner_engine.py
@@ -518,7 +518,7 @@ def execute_claude_model_agent(
last_tool = ""
last_text = ""
- for turn in range(max_turns):
+ for _turn in range(max_turns):
last_text = ""
consumed += 1
response = client.messages.create(
@@ -828,7 +828,7 @@ def execute_deepseek_model_agent(
last_tool = ""
last_text = ""
- for turn in range(max_turns):
+ for _turn in range(max_turns):
if consumed >= max_turns:
return exhaustion_result(repo_dir, max_turns, consumed, last_tool, last_text)
last_text = ""
diff --git a/skills/poteto-mode/scripts/bun.lock b/skills/poteto-mode/scripts/bun.lock
index 65f0c66..49ec30e 100644
--- a/skills/poteto-mode/scripts/bun.lock
+++ b/skills/poteto-mode/scripts/bun.lock
@@ -8,8 +8,8 @@
"commander": "14.0.0",
},
"devDependencies": {
- "bun-types": "latest",
- "typescript": "latest",
+ "bun-types": "1.3.14",
+ "typescript": "7.0.2",
},
},
},
diff --git a/skills/poteto-mode/scripts/hooks/pre_tool_safety.py b/skills/poteto-mode/scripts/hooks/pre_tool_safety.py
old mode 100644
new mode 100755
diff --git a/skills/poteto-mode/scripts/package.json b/skills/poteto-mode/scripts/package.json
index b20709d..676c3bb 100644
--- a/skills/poteto-mode/scripts/package.json
+++ b/skills/poteto-mode/scripts/package.json
@@ -3,14 +3,14 @@
"private": true,
"type": "module",
"scripts": {
- "test": "bun test watch-pr",
- "typecheck": "tsc --project watch-pr/tsconfig.json --noEmit --strict"
+ "test": "bun test",
+ "typecheck": "tsc --project tsconfig.json --noEmit --strict"
},
"dependencies": {
"commander": "14.0.0"
},
"devDependencies": {
- "bun-types": "latest",
- "typescript": "latest"
+ "bun-types": "1.3.14",
+ "typescript": "7.0.2"
}
}
diff --git a/skills/poteto-mode/scripts/tsconfig.json b/skills/poteto-mode/scripts/tsconfig.json
new file mode 100644
index 0000000..f183497
--- /dev/null
+++ b/skills/poteto-mode/scripts/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "allowImportingTsExtensions": true,
+ "module": "esnext",
+ "moduleResolution": "bundler",
+ "noEmit": true,
+ "skipLibCheck": true,
+ "strict": true,
+ "target": "esnext",
+ "types": ["bun-types"]
+ },
+ "include": ["bootstrap.ts", "check-plan.test.ts", "watch-pr/*.ts"]
+}
diff --git a/skills/setup-agystack/scripts/setup_runtime.py b/skills/setup-agystack/scripts/setup_runtime.py
index b02797e..f6c7629 100644
--- a/skills/setup-agystack/scripts/setup_runtime.py
+++ b/skills/setup-agystack/scripts/setup_runtime.py
@@ -26,7 +26,7 @@ def check_gcloud():
res = run_cmd(["gcloud", "--version"], check=False)
if res.returncode != 0:
return {"installed": False, "account": None}
-
+
res = run_cmd(["gcloud", "auth", "list", "--filter=status:ACTIVE", "--format=value(account)"], check=False)
account = res.stdout.strip()
return {"installed": True, "account": account if account else None}
@@ -718,7 +718,7 @@ def build_and_deploy_worker(project_id, region, image_tag, scripts_dir, job_name
f"--location={region}",
f"--project={project_id}"
], check=False)
-
+
if res.returncode != 0:
run_cmd([
"gcloud", "artifacts", "repositories", "create", "agystack",
@@ -726,7 +726,7 @@ def build_and_deploy_worker(project_id, region, image_tag, scripts_dir, job_name
f"--location={region}",
f"--project={project_id}"
])
-
+
staged_dirs = []
scripts_path = Path(scripts_dir).resolve()
repo_root = scripts_path.parents[2] if len(scripts_path.parents) >= 3 else scripts_path
@@ -748,7 +748,7 @@ def build_and_deploy_worker(project_id, region, image_tag, scripts_dir, job_name
if src.is_dir():
dst_resolved = dst.resolve()
- def _ignore_copy(directory, contents):
+ def _ignore_copy(directory, contents, dst_resolved=dst_resolved):
dir_p = Path(directory).resolve()
ignored = set()
for item in contents:
@@ -777,14 +777,14 @@ def _ignore_copy(directory, contents):
shutil.rmtree(staged, ignore_errors=True)
except Exception:
pass
-
+
print("Creating/Updating Cloud Run Job...")
res = run_cmd([
"gcloud", "run", "jobs", "describe", job_name,
f"--region={region}",
f"--project={project_id}"
], check=False)
-
+
action = "update" if res.returncode == 0 else "create"
cmd = [
"gcloud", "run", "jobs", action, job_name,
@@ -819,11 +819,11 @@ def write_runtime_config(project_id, region, job_name, image_tag, auth_mode="ver
config["service_account"] = service_account
if secrets:
config["secrets"] = secrets
-
+
paths = target_paths or [
Path.home() / ".gemini" / "config" / "plugins" / "agystack" / "agystack-runtime.json"
]
-
+
for p in paths:
p = Path(p)
try:
@@ -865,7 +865,7 @@ def run_provisioning(
enable_apis(project_id)
ensure_gcs_bucket(bucket_name, project_id, region)
sa_email = configure_iam_permissions(project_id, service_account)
-
+
configured_secrets = dict(secrets) if isinstance(secrets, dict) else {}
if gh_token or secret_name:
sec_name = secret_name or "agystack-gh-token"
@@ -907,9 +907,9 @@ def main():
parser.add_argument("--bucket", type=str, help="GCS bucket name for swarm results")
parser.add_argument("--service-account", type=str, help="Cloud Run compute service account")
parser.add_argument("--check-model-garden", action="store_true", help="Check Vertex AI Model Garden partner model availability and permissions")
-
+
args = parser.parse_args()
-
+
if args.check_model_garden:
proj = args.project or get_active_project()
status = check_model_garden(project_id=proj, region=args.region)
@@ -926,24 +926,24 @@ def main():
status["active_project"] = get_active_project()
print(json.dumps(status, indent=2))
return
-
+
if args.list_projects:
projects = list_projects()
print(json.dumps(projects, indent=2))
return
-
+
project_id = args.project
if args.create_project:
create_project(args.create_project)
project_id = args.create_project
-
+
if args.auto_provision:
if not project_id:
project_id = get_active_project()
if not project_id:
print("Error: No project specified and no active project found. Use --project or --create-project.")
sys.exit(1)
-
+
run_provisioning(
project_id=project_id,
region=args.region,
diff --git a/tests/test_hooks.py b/tests/test_hooks.py
index 22e9420..6c6a121 100644
--- a/tests/test_hooks.py
+++ b/tests/test_hooks.py
@@ -93,11 +93,12 @@ def test_formatter_formats_unformatted_python(self):
self.assertEqual(result.returncode, 0)
self.assertEqual(json.loads(result.stdout.strip()), {})
- if shutil.which("ruff"):
- formatted_content = temp_py.read_text(encoding="utf-8")
- self.assertNotEqual(formatted_content, "x=1;y=2\n")
- self.assertIn("x = 1", formatted_content)
- self.assertIn("y = 2", formatted_content)
+ if not shutil.which("ruff"):
+ self.skipTest("ruff not installed")
+ formatted_content = temp_py.read_text(encoding="utf-8")
+ self.assertNotEqual(formatted_content, "x=1;y=2\n")
+ self.assertIn("x = 1", formatted_content)
+ self.assertIn("y = 2", formatted_content)
def test_replace_file_content_never_formats(self):
with tempfile.TemporaryDirectory(dir=REPO_ROOT) as tmp_dir:
@@ -170,8 +171,9 @@ def test_argument_aliases(self):
}
result = run_hook(json.dumps(payload))
self.assertEqual(result.returncode, 0)
- if shutil.which("ruff"):
- self.assertIn("a = 10", temp_py.read_text(encoding="utf-8"))
+ if not shutil.which("ruff"):
+ self.skipTest("ruff not installed")
+ self.assertIn("a = 10", temp_py.read_text(encoding="utf-8"))
class TestPreToolSafetyHook(unittest.TestCase):
diff --git a/tests/test_plugin_manifest.py b/tests/test_plugin_manifest.py
index d2e56ae..eef731d 100644
--- a/tests/test_plugin_manifest.py
+++ b/tests/test_plugin_manifest.py
@@ -1,6 +1,12 @@
import json
+import re
+import shlex
+import subprocess
+import tempfile
+import tomllib
from pathlib import Path
import xml.etree.ElementTree as ET
+import zipfile
REPO_ROOT = Path(__file__).resolve().parent.parent
@@ -39,3 +45,91 @@ def test_plugin_manifest_structure():
width = int(root.attrib.get("width", 0))
height = int(root.attrib.get("height", 0))
assert width >= 128 and height >= 128, "Logo dimensions should be at least 128x128"
+
+
+def test_version_parity_and_semver():
+ plugin_data = json.loads((REPO_ROOT / "plugin.json").read_text(encoding="utf-8"))
+ pyproject_data = tomllib.loads((REPO_ROOT / "pyproject.toml").read_text(encoding="utf-8"))
+ marketplace_data = json.loads((REPO_ROOT / "docs" / "marketplace-submission.json").read_text(encoding="utf-8"))
+
+ plugin_version = plugin_data["version"]
+ pyproject_version = pyproject_data["project"]["version"]
+ marketplace_version = marketplace_data["version"]
+
+ assert re.fullmatch(r"\d+\.\d+\.\d+", plugin_version), f"Invalid semver version: {plugin_version!r}"
+ assert plugin_version == pyproject_version == marketplace_version, (
+ f"Version mismatch across manifests: plugin.json={plugin_version!r}, "
+ f"pyproject.toml={pyproject_version!r}, "
+ f"docs/marketplace-submission.json={marketplace_version!r}"
+ )
+
+
+def test_example_configs_and_hook_paths():
+ runtime_example = json.loads((REPO_ROOT / "agystack-runtime.json.example").read_text(encoding="utf-8"))
+ assert isinstance(runtime_example, dict) and runtime_example
+
+ hooks_example = json.loads((REPO_ROOT / "hooks.json.example").read_text(encoding="utf-8"))
+ assert isinstance(hooks_example, dict)
+
+ prefix = "~/.gemini/config/plugins/agystack/"
+ referenced_scripts = []
+ for hook_group in hooks_example.values():
+ if not isinstance(hook_group, dict):
+ continue
+ for event_entries in hook_group.values():
+ if not isinstance(event_entries, list):
+ continue
+ for entry in event_entries:
+ for hook in entry.get("hooks", []):
+ cmd = hook.get("command", "")
+ tokens = shlex.split(cmd)
+ script_tokens = [tok for tok in tokens if tok.startswith(prefix)]
+ assert script_tokens, f"Hook command missing expected plugin prefix: {cmd!r}"
+ for tok in script_tokens:
+ rel_path = tok.removeprefix(prefix)
+ referenced_scripts.append(rel_path)
+ assert (REPO_ROOT / rel_path).is_file(), f"Referenced hook script missing: {rel_path}"
+
+ assert len(referenced_scripts) > 0, "Expected at least one hook script in hooks.json.example"
+
+
+def test_packaging_archive_invariants():
+ manifest = json.loads((REPO_ROOT / "plugin.json").read_text(encoding="utf-8"))
+ expected_name = f"{manifest['name']}-{manifest['version']}.zip"
+
+ with tempfile.TemporaryDirectory() as tmp_dir:
+ proc = subprocess.run(
+ ["bash", str(REPO_ROOT / "scripts" / "package-plugin.sh"), "--output-dir", tmp_dir],
+ cwd=REPO_ROOT,
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+ assert proc.returncode == 0, f"package-plugin.sh failed:\n{proc.stdout}\n{proc.stderr}"
+
+ archive_path = Path(tmp_dir) / expected_name
+ assert archive_path.is_file(), f"Expected archive at {archive_path}"
+
+ with zipfile.ZipFile(archive_path) as zf:
+ assert zf.testzip() is None
+ names = set(zf.namelist())
+
+ required_root = {
+ "plugin.json",
+ "README.md",
+ "LICENSE",
+ "agystack-models.md",
+ "agystack-runtime.json.example",
+ "hooks.json.example",
+ }
+ missing = required_root - names
+ assert not missing, f"Archive missing required root files: {sorted(missing)}"
+
+ forbidden = [
+ name for name in names
+ if name.endswith(".test.ts")
+ or name.endswith(".test-helper.ts")
+ or "__pycache__" in Path(name).parts
+ or "node_modules" in Path(name).parts
+ ]
+ assert not forbidden, f"Archive contains forbidden entries: {forbidden}"
diff --git a/tests/test_setup_runtime.py b/tests/test_setup_runtime.py
index 4705286..c5f0fa1 100644
--- a/tests/test_setup_runtime.py
+++ b/tests/test_setup_runtime.py
@@ -143,14 +143,15 @@ def test_doctor_main_exit_success(self, mock_check_deps):
"gcloud": {"installed": False, "version": None, "ok": False, "error": "not found", "required": False},
}
- with patch("sys.argv", ["setup_runtime.py", "--doctor"]):
- with patch("sys.stdout", new_callable=io.StringIO) as mock_out:
- with self.assertRaises(SystemExit) as cm:
- setup_runtime.main()
- self.assertEqual(cm.exception.code, 0)
- output = json.loads(mock_out.getvalue().strip())
- self.assertTrue(output["bun"]["ok"])
- self.assertTrue(output["gh"]["ok"])
+ with isolated_home():
+ with patch("sys.argv", ["setup_runtime.py", "--doctor"]):
+ with patch("sys.stdout", new_callable=io.StringIO) as mock_out:
+ with self.assertRaises(SystemExit) as cm:
+ setup_runtime.main()
+ self.assertEqual(cm.exception.code, 0)
+ output = json.loads(mock_out.getvalue().strip())
+ self.assertTrue(output["bun"]["ok"])
+ self.assertTrue(output["gh"]["ok"])
@patch("setup_runtime.check_dependencies")
def test_doctor_main_exit_failure_missing_gh(self, mock_check_deps):
@@ -161,11 +162,12 @@ def test_doctor_main_exit_failure_missing_gh(self, mock_check_deps):
"gcloud": {"installed": True, "version": "583.0.0", "ok": True, "error": None, "required": False},
}
- with patch("sys.argv", ["setup_runtime.py", "--doctor"]):
- with patch("sys.stdout", new_callable=io.StringIO):
- with self.assertRaises(SystemExit) as cm:
- setup_runtime.main()
- self.assertEqual(cm.exception.code, 1)
+ with isolated_home():
+ with patch("sys.argv", ["setup_runtime.py", "--doctor"]):
+ with patch("sys.stdout", new_callable=io.StringIO):
+ with self.assertRaises(SystemExit) as cm:
+ setup_runtime.main()
+ self.assertEqual(cm.exception.code, 1)
@patch("setup_runtime.check_dependencies")
def test_doctor_main_exit_failure_bun_sub_v1(self, mock_check_deps):
@@ -174,11 +176,12 @@ def test_doctor_main_exit_failure_bun_sub_v1(self, mock_check_deps):
"gh": {"installed": True, "version": "2.97.0", "ok": True, "error": None, "required": True},
}
- with patch("sys.argv", ["setup_runtime.py", "--doctor"]):
- with patch("sys.stdout", new_callable=io.StringIO):
- with self.assertRaises(SystemExit) as cm:
- setup_runtime.main()
- self.assertEqual(cm.exception.code, 1)
+ with isolated_home():
+ with patch("sys.argv", ["setup_runtime.py", "--doctor"]):
+ with patch("sys.stdout", new_callable=io.StringIO):
+ with self.assertRaises(SystemExit) as cm:
+ setup_runtime.main()
+ self.assertEqual(cm.exception.code, 1)
@patch("setup_runtime.check_dependencies")
def test_doctor_main_evaluates_all_required_metadata(self, mock_check_deps):
@@ -188,23 +191,24 @@ def test_doctor_main_evaluates_all_required_metadata(self, mock_check_deps):
"gt": {"installed": False, "version": None, "ok": False, "error": "not found", "required": False},
"gcloud": {"installed": False, "version": None, "ok": False, "error": "not found", "required": False},
}
- with patch("sys.argv", ["setup_runtime.py", "--doctor"]):
- with patch("sys.stdout", new_callable=io.StringIO):
- with self.assertRaises(SystemExit) as cm:
- setup_runtime.main()
- self.assertEqual(cm.exception.code, 0)
+ with isolated_home():
+ with patch("sys.argv", ["setup_runtime.py", "--doctor"]):
+ with patch("sys.stdout", new_callable=io.StringIO):
+ with self.assertRaises(SystemExit) as cm:
+ setup_runtime.main()
+ self.assertEqual(cm.exception.code, 0)
- mock_check_deps.return_value = {
- "bun": {"installed": True, "version": "1.3.14", "ok": True, "error": None, "required": True},
- "gh": {"installed": False, "version": None, "ok": False, "error": "gh not found", "required": True},
- "gt": {"installed": True, "version": "0.21.0", "ok": True, "error": None, "required": False},
- "gcloud": {"installed": True, "version": "583.0.0", "ok": True, "error": None, "required": False},
- }
- with patch("sys.argv", ["setup_runtime.py", "--doctor"]):
- with patch("sys.stdout", new_callable=io.StringIO):
- with self.assertRaises(SystemExit) as cm:
- setup_runtime.main()
- self.assertEqual(cm.exception.code, 1)
+ mock_check_deps.return_value = {
+ "bun": {"installed": True, "version": "1.3.14", "ok": True, "error": None, "required": True},
+ "gh": {"installed": False, "version": None, "ok": False, "error": "gh not found", "required": True},
+ "gt": {"installed": True, "version": "0.21.0", "ok": True, "error": None, "required": False},
+ "gcloud": {"installed": True, "version": "583.0.0", "ok": True, "error": None, "required": False},
+ }
+ with patch("sys.argv", ["setup_runtime.py", "--doctor"]):
+ with patch("sys.stdout", new_callable=io.StringIO):
+ with self.assertRaises(SystemExit) as cm:
+ setup_runtime.main()
+ self.assertEqual(cm.exception.code, 1)
class TestSetupRuntimeProvisioning(unittest.TestCase):
diff --git a/tests/test_simulation_scenario.py b/tests/test_simulation_scenario.py
index 868fb32..fb63ddf 100644
--- a/tests/test_simulation_scenario.py
+++ b/tests/test_simulation_scenario.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
+import contextlib
import json
import os
from pathlib import Path
@@ -172,19 +173,20 @@ def test_probe_vertex_ai_success(self, mock_subproc, mock_urlopen):
)
def test_end_to_end_simulation_run(self):
- result = run_simulation(
- model="gemini-2.5-flash",
- project="test-agystack-project",
- gcs_bucket="test-swarm-results",
- tasks=3,
- skip_live_probe=True,
- temp_base_dir=self.base_dir,
- )
+ with contextlib.chdir(self.base_dir):
+ result = run_simulation(
+ model="gemini-2.5-flash",
+ project="test-agystack-project",
+ gcs_bucket="test-swarm-results",
+ tasks=3,
+ skip_live_probe=True,
+ temp_base_dir=self.base_dir,
+ )
self.assertEqual(result["status"], "PASS")
self.assertEqual(result["tasks"], 3)
self.assertEqual(len(result["harvested_scores"]), 3)
- out_slices = Path(".slices/harvested_scores.json")
+ out_slices = self.base_dir / ".slices" / "harvested_scores.json"
self.assertTrue(out_slices.is_file())
with open(out_slices, "r", encoding="utf-8") as f:
slices_data = json.load(f)
@@ -211,10 +213,11 @@ def test_cli_execution_clean_exit(self):
"--skip-live-probe",
"--tasks", "3",
]
- proc = subprocess.run(cmd, capture_output=True, text=True)
+ proc = subprocess.run(cmd, cwd=self.base_dir, capture_output=True, text=True)
self.assertEqual(proc.returncode, 0, f"CLI exited with {proc.returncode}:\n{proc.stderr}")
self.assertIn("SWARM SIMULATION REPORT", proc.stdout)
self.assertIn("[STATUS: PASS]", proc.stdout)
+ self.assertTrue((self.base_dir / ".slices" / "harvested_scores.json").is_file())
if __name__ == "__main__":
diff --git a/tests/test_skill_catalog.py b/tests/test_skill_catalog.py
index 58d3196..0ba2b7f 100644
--- a/tests/test_skill_catalog.py
+++ b/tests/test_skill_catalog.py
@@ -46,8 +46,8 @@ def test_readme_indexes_all_principles():
readme = (REPO_ROOT / "README.md").read_text(encoding="utf-8")
for skill_file in get_principle_skills():
slug = skill_file.parent.name.replace("principle-", "")
- assert (f"./skills/{skill_file.parent.name}/SKILL.md" in readme or
- f"skills/{skill_file.parent.name}" in readme or
+ assert (f"./skills/{skill_file.parent.name}/SKILL.md" in readme or
+ f"skills/{skill_file.parent.name}" in readme or
slug in readme), f"README.md missing reference to {skill_file.parent.name}"
@@ -55,8 +55,8 @@ def test_guide_indexes_all_principles():
guide_principles = (REPO_ROOT / "docs" / "guide" / "08-principles.md").read_text(encoding="utf-8")
for skill_file in get_principle_skills():
slug = skill_file.parent.name.replace("principle-", "")
- assert (skill_file.parent.name in guide_principles or
- f"skills/{skill_file.parent.name}" in guide_principles or
+ assert (skill_file.parent.name in guide_principles or
+ f"skills/{skill_file.parent.name}" in guide_principles or
slug in guide_principles), f"08-principles.md missing reference to {skill_file.parent.name}"
@@ -73,7 +73,9 @@ def test_all_skills_match_directory():
frontmatter = parts[1]
name_match = re.search(r"^name:\s*(.+)$", frontmatter, re.MULTILINE)
+ desc_match = re.search(r"^description:\s*(.+)$", frontmatter, re.MULTILINE)
assert name_match, f"{skill_file} missing 'name:' in frontmatter"
+ assert desc_match, f"{skill_file} missing 'description:' in frontmatter"
dir_name = skill_file.parent.name
skill_name = name_match.group(1).strip().strip("'\"")