richfrem/agent-plugins-skills / plugins/agent-exploration-cycle/.apm/skills/running-exploration-cycle
running-exploration-cycle
VerifiedRuns the business exploration cycle end to end: starts or resumes a session (intake interview, session brief), enforces the Discovery Plan HARD-GATE, routes the four phases (Discovery Plan, Visual Blueprinting, Prototype, Handoff) to the sibling skills and keeps session state. Use when the user says "let's explore this idea", "I have an idea I want to explore", "help me plan this out", "start discovery", "resume my exploration", "where did we leave off", or starts any conversation about a need, problem or idea before building. Not for hardening an existing prototype (use reengineering-vibe-code) or for engineering build work.
scripts/test_dispatch_authorization_gate.py
View on GitHub"""
Purpose:
Unit tests verifying dispatch.py's authorization gate fires before any
subprocess call, plus agent alias index resolution and handoff envelope
truncation limits.
Key Input Dependencies:
- dispatch.py (in ../scripts/, invoked both as subprocess and imported directly)
- pytest tmp_path fixture
"""
import json, subprocess, sys, unittest.mock
from pathlib import Path
import pytest
sys.path.insert(0, str(Path(__file__).parent))
DISPATCH = Path(__file__).parent / "dispatch.py"
MINIMAL_ARGS = [
"--agent", "agents/intake-agent.md",
"--instruction", "run",
"--output", "/tmp/test_out.md",
]
def _base_cmd(extra: list) -> list:
"""Build a dispatch.py subprocess command line with MINIMAL_ARGS plus extra flags."""
return [sys.executable, str(DISPATCH)] + MINIMAL_ARGS + extra
def test_dispatch_blocks_without_approval(tmp_path):
"""Gate must fire before CLI subprocess — even with otherwise valid args."""
# Provide valid-looking but nonexistent db and key so the gate fires, not arg parsing
db = tmp_path / "test.sqlite"
db.touch()
key = tmp_path / "test.key"
key.write_bytes(b"\x00" * 32)
envelope = json.dumps({"payload": "x", "hmac": "bad", "nonce": "n1"})
result = subprocess.run(
_base_cmd([
"--db-path", str(db),
"--approval-id", "nonexistent-id",
"--dispatch-action", "run_agent",
"--envelope-json", envelope,
"--hmac-key-path", str(key),
]),
capture_output=True, text=True,
)
assert result.returncode != 0
assert "authorization" in result.stderr.lower() or "approval" in result.stderr.lower()
def test_dispatch_gate_fires_before_subprocess(tmp_path):
"""Verify the CLI subprocess is never called on auth failure."""
import importlib.util
spec = importlib.util.spec_from_file_location("dispatch", DISPATCH)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
db = tmp_path / "test.sqlite"
key = tmp_path / "test.key"
key.write_bytes(b"\x00" * 32)
envelope = json.dumps({"payload": "x", "hmac": "bad", "nonce": "n1"})
test_argv = [str(DISPATCH)] + MINIMAL_ARGS + [
"--db-path", str(db),
"--approval-id", "test-id",
"--envelope-json", envelope,
"--hmac-key-path", str(key),
]
with unittest.mock.patch("subprocess.run") as mock_run, \
unittest.mock.patch.object(mod, "check_dispatch_authorization",
return_value=(False, "mock rejection")) as mock_auth, \
unittest.mock.patch("sys.argv", test_argv):
with pytest.raises(SystemExit) as exc:
mod.main()
assert exc.value.code != 0
mock_auth.assert_called_once()
mock_run.assert_not_called()
def test_alias_index_three_way_resolution(tmp_path):
"""Verify build_agent_index resolves an agent by stem, stem-without-suffix, and frontmatter name."""
agents = tmp_path / "agents"
agents.mkdir()
(agents / "intake-agent.md").write_text("---\nname: Intake Agent\n---\nBody")
from dispatch import build_agent_index
idx = build_agent_index(agents)
assert "intake-agent" in idx # stem
assert "intake" in idx # stem-without-agent
assert "Intake Agent" in idx # frontmatter name
# All three resolve to the same file
assert idx["intake-agent"] == idx["intake"] == idx["Intake Agent"]
def test_handoff_envelope_caps_turns_and_chars():
"""Verify build_handoff_envelope caps transcript to 8 lines and 300 chars per line."""
transcript = [("user", "x" * 500), ("agent", "y" * 500)] * 10
from dispatch import build_handoff_envelope
env = build_handoff_envelope("intake-agent", "vibe-orchestrator",
"prototype detected", "I have code", transcript)
lines = [l for l in env.split("\n")
if l.startswith("user:") or l.startswith("agent:")]
assert len(lines) <= 8
for line in lines:
payload = line.split(": ", 1)[1] if ": " in line else line
assert len(payload) <= 300
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |