Files
pipelines/scripts/smoke-first-install.py
T
alan c9b904186a Update templates and authoring skill to the current pipeline contract
Bring the packaged starters and the pipelines skill up to the guidelines the
project now works to.

Templates:
- task and three-stage now end in a committer stage that stages the union of the
  runner's captured input.server_changed_files and the producer's declared
  changed_files, runs the repository's checks, commits locally and never pushes;
  their producers no longer commit.
- Every model/agent prompt states the line-oriented result contract (outcome on the
  first non-empty line, "# output" JSON map, other "# <heading>" sections kept
  verbatim as evidence) and an "# evidence" section for exact commands and results,
  with proportionate verification and no fabricated checks.
- Stages that can write save their reports, logs and screenshots into the runtime
  artifacts directory.
- Remove the summary starter: a tool-free single-prompt text transform with no
  repository interaction, artifact or commit is a format demonstration, not a
  reusable workflow. No starter invents a pretend approval stage; a decision point
  is a type=human stage.

Skill:
- references/format.md gains a Result format section (line form, legacy JSON
  precedence, result_parse, raw-output.md, artifacts) and a Committer stages
  section with the pre-commit checklist; the role-split and envelope notes mention
  the line form and the committer.
- orchestration.md points at the checklist and records that a genuine gate is a
  human stage; operations.md and the SKILL.md index drop the removed starter and
  name the result format and committer. No new reference, so the managed inventory
  is unchanged.

Docs/tests: examples/README, README, docs/cli, docs/first-version-testing, the CLI
help example and the smoke script track the four starters; catalog, tool-role,
server, tui and pipeline tests are updated, with a new test pinning the committer
ending and server-captured change set.

Commands run: go build ./...; go vet ./...; go test ./...; python3 -m unittest
discover -s scripts -p 'test_*.py'; python3 scripts/smoke-first-install.py. All
passed. Templates inspected through an isolated CLI server (pipelines templates;
pipelines template KEY --source). No server, service or device was restarted, and
nothing was pushed.
2026-10-17 01:09:42 +01:00

108 lines
5.1 KiB
Python

#!/usr/bin/env python3
"""Developer-only source lifecycle check; not an alternative installer. No inference."""
import argparse
import json
import os
from pathlib import Path
import socket
import subprocess
import tempfile
import time
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--temp-dir", help="Parent directory for disposable test files")
args = parser.parse_args()
repo = Path(__file__).resolve().parent.parent
with tempfile.TemporaryDirectory(prefix="pipelines-first-install-", dir=args.temp_dir) as temporary:
root = Path(temporary)
env = {k: v for k, v in os.environ.items() if not k.startswith("PIPELINES_")}
env.update(GOBIN=str(root / "bin"), XDG_CONFIG_HOME=str(root / "config"),
XDG_DATA_HOME=str(root / "data"), PIPELINES_DRAFT_DIR=str(root / "drafts"))
subprocess.run(["go", "install", "-trimpath", "./cmd/..."], cwd=repo, env=env, check=True, timeout=180)
subprocess.run([str(root / "bin/pipelines"), "skill", "install"], cwd=repo, env=env, check=True, timeout=30)
cli = root / "bin/pipelines"
assert (root / "bin/pipelines-tui").is_file(), "TUI binary missing"
assert (root / "config/opencode/skills/pipelines/references/operations.md").is_file(), "Skill not installed"
workspace = root / "workspace"
workspace.mkdir()
def local(*command):
return subprocess.run([str(cli), *command], cwd=workspace, env=env,
capture_output=True, text=True, check=True, timeout=30).stdout
version = json.loads(local("version", "--json"))
assert version == json.loads(local("--version", "--json"))
assert "import [FILE.zip]" in local("help")
with socket.socket() as sock:
sock.bind(("127.0.0.1", 0))
port = sock.getsockname()[1]
endpoint = f"ws://127.0.0.1:{port}/connect"
database = root / "runs.db"
def rpc(*command):
return json.loads(local("--url", endpoint, *command, "--json"))
def start(log):
process = subprocess.Popen([str(root / "bin/pipelines-server"), "-addr", f"127.0.0.1:{port}",
"-db", str(database)], cwd=workspace, env=env, stdout=log, stderr=log)
try:
deadline = time.monotonic() + 15
while time.monotonic() < deadline:
if process.poll() is not None:
raise RuntimeError("Test server exited; see " + str(root / "server.log"))
try:
with socket.create_connection(("127.0.0.1", port), timeout=.1):
return process
except OSError:
time.sleep(.05)
raise RuntimeError("Test server did not become ready")
except BaseException:
stop(process)
raise
def stop(process):
process.terminate()
try:
process.wait(timeout=10)
except subprocess.TimeoutExpired:
process.kill()
process.wait()
raise
with (root / "server.log").open("w") as log:
process = start(log)
try:
pong = rpc("ping")
assert pong["build"] == version, "Client/server build mismatch"
assert not rpc("list").get("pipelines"), "Fresh database must be empty"
assert not rpc("runs").get("runs"), "Fresh database must have no runs"
assert len(rpc("templates")["templates"]) == 4
draft = rpc("new", "First test", "Review the repository", "--template", "review", "--no-open", "--yes")
assert not rpc("list").get("pipelines"), "Draft creation must not publish"
rpc("validate", draft["path"])
rpc("submit", draft["path"], "--yes")
published = rpc("show", "First test")
assert published["version"] == 1
archive = root / "definitions.zip"
rpc("export", "First test", "--output", str(archive))
result = rpc("import", str(archive), "--all", "--yes")
assert not result["imported"], "Identical import must not republish"
assert rpc("show", "First test")["version"] == 1
assert Path(draft["path"]).is_file(), "Published draft must remain"
finally:
stop(process)
process = start(log)
try:
assert rpc("show", "First test")["source"] == published["source"], "Definition lost on restart"
assert rpc("ping")["build"] == version
assert not rpc("runs").get("runs"), "Smoke check must not execute a workflow"
finally:
stop(process)
print("PASS developer lifecycle fixture: isolated source binaries/skill, offline version, empty DB, four templates, draft/validate/publish, ZIP identical import, restart persistence. Not an installation option; no inference or notifications.")
if __name__ == "__main__":
main()