Compare commits
5 Commits
claude/dep
...
claude/pha
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6727e073cc | ||
|
|
6ed639d1db | ||
|
|
38500b2781 | ||
|
|
aaf1b4274e | ||
|
|
1b31ef6396 |
36
.distignore
Executable file
36
.distignore
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
# Files excluded from the production zip.
|
||||||
|
# Used by the GitHub Actions deploy workflow (rsync --exclude-from).
|
||||||
|
# Keep in sync with .gitignore for dev-only artifacts.
|
||||||
|
|
||||||
|
.git
|
||||||
|
.github
|
||||||
|
.distignore
|
||||||
|
.gitignore
|
||||||
|
.phpcs.xml
|
||||||
|
.editorconfig
|
||||||
|
|
||||||
|
# Development & testing
|
||||||
|
tests/
|
||||||
|
phpunit.xml
|
||||||
|
phpunit.xml.dist
|
||||||
|
composer.json
|
||||||
|
composer.lock
|
||||||
|
vendor/
|
||||||
|
|
||||||
|
# Documentation (lives in repo, not in deployed plugin)
|
||||||
|
ARCHITECTURE.md
|
||||||
|
CONVENTIONS.md
|
||||||
|
CHANGELOG.md
|
||||||
|
CODE_OF_CONDUCT.md
|
||||||
|
CONTRIBUTING.md
|
||||||
|
|
||||||
|
# CI/CD tooling
|
||||||
|
scripts/
|
||||||
|
node_modules/
|
||||||
|
package.json
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
|
# OS artifacts
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
*.log
|
||||||
299
.github/workflows/cto-review.yml
vendored
299
.github/workflows/cto-review.yml
vendored
@@ -1,17 +1,20 @@
|
|||||||
name: CTO Review
|
name: CTO Review
|
||||||
|
|
||||||
# Automated PR review powered by Claude Haiku (via OpenRouter).
|
# Automated PR review powered by Claude + DeepSeek + Kimi (via OpenRouter)
|
||||||
|
# plus Neurometric PR-Summarizer (a Qwen3-4B task-specialist SLM).
|
||||||
#
|
#
|
||||||
# A/B panel decision 2026-06-12: panel dropped to Haiku-only.
|
# During the A/B window (until further notice), every PR gets reviewed by FOUR models
|
||||||
# Evidence: convo/cto/threads/2026-06-qa-ab-review/02-analyst-findings.md
|
# in parallel. The PR comment shows each model's verdict side-by-side so we can compare
|
||||||
# DeepSeek: high false-positive rate (absint()="code exec", PLUGIN_DIR="dir traversal").
|
# quality/cost on real PRs before picking a permanent default.
|
||||||
# Kimi: ~60% model failure rate across 13 PRs sampled.
|
|
||||||
# Neurometric: summarizer only, zero unique-real findings, unreliable heuristic verdict.
|
|
||||||
# Haiku: 0 failures, lowest noise, equivalent real-signal catch rate vs 4-voice panel.
|
|
||||||
#
|
#
|
||||||
# Does NOT merge. Posts formal APPROVE/REQUEST_CHANGES/COMMENT reviews.
|
# Neurometric is a "prose voice": it does not support OpenAI tool-calling, so its
|
||||||
|
# contribution is raw markdown + a heuristic verdict. It is never the primary voice.
|
||||||
#
|
#
|
||||||
# Requires repo secret: OPENROUTER_API_KEY
|
# Does NOT merge. Does NOT post formal APPROVE/REQUEST_CHANGES reviews — always COMMENT
|
||||||
|
# (GITHUB_TOKEN can't formally approve PRs without repo-setting toggle).
|
||||||
|
#
|
||||||
|
# Requires repo secrets: OPENROUTER_API_KEY, NEUROMETRIC_API_KEY (optional; the
|
||||||
|
# Neurometric voice self-skips with an inline error note if the key is missing).
|
||||||
#
|
#
|
||||||
# Cost cap: tracked in Repository Variables (CTO_REVIEW_SPEND_CENTS, CTO_REVIEW_CAP_CENTS).
|
# Cost cap: tracked in Repository Variables (CTO_REVIEW_SPEND_CENTS, CTO_REVIEW_CAP_CENTS).
|
||||||
# Default cap is 1000 cents ($10/month). Auto-resets on the 1st of each month.
|
# Default cap is 1000 cents ($10/month). Auto-resets on the 1st of each month.
|
||||||
@@ -122,8 +125,8 @@ jobs:
|
|||||||
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
|
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
|
||||||
# Write the diff to a file, not a step output / env var. Passing a
|
# Write the diff to a file, not a step output / env var. Passing a
|
||||||
# ~400KB diff through the process env (execve argv+envp) exceeds the
|
# ~400KB diff through the process env (execve argv+envp) exceeds the
|
||||||
# runner ARG_MAX and fails the next step with "Argument list too long".
|
# runner ARG_MAX and fails the next step with "Argument list too long"
|
||||||
# File transport also sidesteps the ~1MB step-output cap.
|
# (issue #110). File transport also sidesteps the ~1MB step-output cap.
|
||||||
git diff --no-color "$BASE_SHA" "$HEAD_SHA" | head -c 400000 > /tmp/cto-review-diff.txt
|
git diff --no-color "$BASE_SHA" "$HEAD_SHA" | head -c 400000 > /tmp/cto-review-diff.txt
|
||||||
FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")
|
FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")
|
||||||
SIZE=$(wc -c < /tmp/cto-review-diff.txt)
|
SIZE=$(wc -c < /tmp/cto-review-diff.txt)
|
||||||
@@ -148,11 +151,12 @@ jobs:
|
|||||||
echo "EOF_CONV"
|
echo "EOF_CONV"
|
||||||
} >> "$GITHUB_OUTPUT"
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Call Haiku via OpenRouter
|
- name: Call 4 models in parallel (OpenRouter + Neurometric)
|
||||||
if: steps.budget.outputs.skip != 'true'
|
if: steps.budget.outputs.skip != 'true'
|
||||||
id: review
|
id: review
|
||||||
env:
|
env:
|
||||||
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
|
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
|
||||||
|
NEUROMETRIC_API_KEY: ${{ secrets.NEUROMETRIC_API_KEY }}
|
||||||
PR_TITLE: ${{ github.event.pull_request.title }}
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
||||||
PR_BODY: ${{ github.event.pull_request.body }}
|
PR_BODY: ${{ github.event.pull_request.body }}
|
||||||
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
|
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
|
||||||
@@ -180,17 +184,24 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
import json, os, sys, urllib.request
|
import json, os, sys, urllib.request, concurrent.futures
|
||||||
|
|
||||||
api_key = os.environ["OPENROUTER_API_KEY"]
|
api_key = os.environ["OPENROUTER_API_KEY"]
|
||||||
|
|
||||||
# Haiku-only reviewer. A/B panel dropped 2026-06-12 per QA data:
|
# A/B harness: four models. Each gets the same prompt.
|
||||||
# DeepSeek high false-positive rate, Kimi ~60% failure rate,
|
# Primary model's verdict drives the heading. Others are labeled.
|
||||||
# Neurometric zero unique-real findings. Haiku retained as sole voice.
|
# Edit this list to change the roster (or drop to 1 after A/B window closes).
|
||||||
MODEL_SLUG = "anthropic/claude-haiku-4.5"
|
#
|
||||||
MODEL_DISPLAY = "Claude Haiku 4.5"
|
# provider_type semantics:
|
||||||
INPUT_PER_M_USD = 1.00
|
# - "openrouter_tools": OpenAI tool-calling via OpenRouter; structured verdict.
|
||||||
OUTPUT_PER_M_USD = 5.00
|
# - "neurometric_prose": Neurometric marketplace SLM; prose output + heuristic verdict.
|
||||||
|
MODELS = [
|
||||||
|
# (slug, display name, input_per_M_USD, output_per_M_USD, is_primary, provider_type)
|
||||||
|
("anthropic/claude-haiku-4.5", "Claude Haiku 4.5", 1.00, 5.00, True, "openrouter_tools"),
|
||||||
|
("deepseek/deepseek-chat-v3.1", "DeepSeek V3.1", 0.15, 0.75, False, "openrouter_tools"),
|
||||||
|
("moonshotai/kimi-k2-thinking", "Kimi K2 Thinking", 0.60, 2.50, False, "openrouter_tools"),
|
||||||
|
("neurometric/pr-summarizer", "Neurometric PR-Summarizer (Qwen3-4B)", 0.00, 0.00, False, "neurometric_prose"),
|
||||||
|
]
|
||||||
|
|
||||||
system = """You are the CTO and lead reviewer for the peptiderepo project. You are reviewing a pull request opened by an autonomous agent or human contributor.
|
system = """You are the CTO and lead reviewer for the peptiderepo project. You are reviewing a pull request opened by an autonomous agent or human contributor.
|
||||||
|
|
||||||
@@ -253,100 +264,218 @@ jobs:
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
body = {
|
PER_MODEL_TIMEOUT = 60 # seconds; one hung model should not block siblings
|
||||||
"model": MODEL_SLUG,
|
|
||||||
"max_tokens": 2048,
|
|
||||||
"messages": [
|
|
||||||
{"role": "system", "content": system},
|
|
||||||
{"role": "user", "content": user_message}
|
|
||||||
],
|
|
||||||
"tools": tools,
|
|
||||||
"tool_choice": {"type": "function", "function": {"name": "submit_review"}}
|
|
||||||
}
|
|
||||||
req = urllib.request.Request(
|
|
||||||
"https://openrouter.ai/api/v1/chat/completions",
|
|
||||||
data=json.dumps(body).encode(),
|
|
||||||
headers={
|
|
||||||
"Authorization": f"Bearer {api_key}",
|
|
||||||
"content-type": "application/json",
|
|
||||||
"HTTP-Referer": "https://github.com/peptiderepo",
|
|
||||||
"X-Title": f"peptiderepo CTO reviewer ({MODEL_DISPLAY})"
|
|
||||||
},
|
|
||||||
method="POST"
|
|
||||||
)
|
|
||||||
|
|
||||||
error = None
|
# Heuristic verdict inference for prose-voice models that can't do tool-calling.
|
||||||
review = None
|
# Keyword order matters: block markers beat approve markers.
|
||||||
cost_cents = 0.0
|
PROSE_BLOCK_MARKERS = [
|
||||||
ptok = 0
|
"do not merge", "do not approve", "should not be merged", "reject this",
|
||||||
ctok = 0
|
"critical security", "critical issue", "critical vulnerability",
|
||||||
|
"blocker", "blocking issue", "request_changes", "request changes",
|
||||||
|
"**critical**", "sql injection", "must be addressed before",
|
||||||
|
]
|
||||||
|
PROSE_APPROVE_MARKERS = [
|
||||||
|
"safe to merge", "ready to merge", "no blocking issues", "lgtm",
|
||||||
|
"approve this", "looks good to merge", "no concerns",
|
||||||
|
]
|
||||||
|
|
||||||
try:
|
def infer_verdict_from_prose(text):
|
||||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
t = (text or "").lower()
|
||||||
data = json.loads(resp.read())
|
if any(m in t for m in PROSE_BLOCK_MARKERS):
|
||||||
except Exception as e:
|
return "REQUEST_CHANGES"
|
||||||
error = str(e)[:300]
|
if any(m in t for m in PROSE_APPROVE_MARKERS):
|
||||||
data = {}
|
return "APPROVE"
|
||||||
|
return "COMMENT"
|
||||||
|
|
||||||
|
def call_openrouter_tools(slug, display, in_rate, out_rate, is_primary):
|
||||||
|
body = {
|
||||||
|
"model": slug,
|
||||||
|
"max_tokens": 2048,
|
||||||
|
"messages": [
|
||||||
|
{"role": "system", "content": system},
|
||||||
|
{"role": "user", "content": user_message}
|
||||||
|
],
|
||||||
|
"tools": tools,
|
||||||
|
"tool_choice": {"type": "function", "function": {"name": "submit_review"}}
|
||||||
|
}
|
||||||
|
req = urllib.request.Request(
|
||||||
|
"https://openrouter.ai/api/v1/chat/completions",
|
||||||
|
data=json.dumps(body).encode(),
|
||||||
|
headers={
|
||||||
|
"Authorization": f"Bearer {api_key}",
|
||||||
|
"content-type": "application/json",
|
||||||
|
"HTTP-Referer": "https://github.com/peptiderepo",
|
||||||
|
"X-Title": f"peptiderepo CTO reviewer ({display})"
|
||||||
|
},
|
||||||
|
method="POST"
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(req, timeout=PER_MODEL_TIMEOUT) as resp:
|
||||||
|
data = json.loads(resp.read())
|
||||||
|
except Exception as e:
|
||||||
|
return {
|
||||||
|
"slug": slug, "display": display, "is_primary": is_primary,
|
||||||
|
"provider_type": "openrouter_tools",
|
||||||
|
"error": str(e)[:300],
|
||||||
|
"cost_cents": 0,
|
||||||
|
}
|
||||||
|
|
||||||
if not error:
|
|
||||||
choice = data.get("choices", [{}])[0].get("message", {})
|
choice = data.get("choices", [{}])[0].get("message", {})
|
||||||
tool_calls = choice.get("tool_calls", [])
|
tool_calls = choice.get("tool_calls", [])
|
||||||
if not tool_calls:
|
if not tool_calls:
|
||||||
error = f"No tool_call in response. Raw content: {str(choice)[:300]}"
|
return {
|
||||||
else:
|
"slug": slug, "display": display, "is_primary": is_primary,
|
||||||
try:
|
"provider_type": "openrouter_tools",
|
||||||
review = json.loads(tool_calls[0]["function"]["arguments"])
|
"error": f"No tool_call in response. Raw content: {str(choice)[:300]}",
|
||||||
except Exception as e:
|
"cost_cents": 0,
|
||||||
error = f"Malformed tool args: {e}"
|
}
|
||||||
|
|
||||||
if not error:
|
try:
|
||||||
usage = data.get("usage", {})
|
review = json.loads(tool_calls[0]["function"]["arguments"])
|
||||||
ptok = usage.get("prompt_tokens", 0)
|
except Exception as e:
|
||||||
ctok = usage.get("completion_tokens", 0)
|
return {
|
||||||
cost_usd = (ptok * INPUT_PER_M_USD / 1_000_000) + (ctok * OUTPUT_PER_M_USD / 1_000_000)
|
"slug": slug, "display": display, "is_primary": is_primary,
|
||||||
cost_cents = cost_usd * 100
|
"provider_type": "openrouter_tools",
|
||||||
|
"error": f"Malformed tool args: {e}",
|
||||||
|
"cost_cents": 0,
|
||||||
|
}
|
||||||
|
|
||||||
# Build comment
|
usage = data.get("usage", {})
|
||||||
if error:
|
ptok = usage.get("prompt_tokens", 0)
|
||||||
heading_verdict = "ERROR"
|
ctok = usage.get("completion_tokens", 0)
|
||||||
lines = [f"## CTO Review — {heading_verdict}", ""]
|
cost_usd = (ptok * in_rate / 1_000_000) + (ctok * out_rate / 1_000_000)
|
||||||
lines.append(f"Model failed: `{error}`")
|
cost_cents = cost_usd * 100
|
||||||
|
return {
|
||||||
|
"slug": slug, "display": display, "is_primary": is_primary,
|
||||||
|
"provider_type": "openrouter_tools",
|
||||||
|
"review": review, "prompt_tokens": ptok, "completion_tokens": ctok,
|
||||||
|
"cost_cents": cost_cents,
|
||||||
|
}
|
||||||
|
|
||||||
|
def call_neurometric_prose(slug, display, is_primary):
|
||||||
|
nm_key = os.environ.get("NEUROMETRIC_API_KEY", "")
|
||||||
|
if not nm_key:
|
||||||
|
return {
|
||||||
|
"slug": slug, "display": display, "is_primary": is_primary,
|
||||||
|
"provider_type": "neurometric_prose",
|
||||||
|
"error": "NEUROMETRIC_API_KEY secret not set on this repo",
|
||||||
|
"cost_cents": 0,
|
||||||
|
}
|
||||||
|
body = {
|
||||||
|
"model": slug,
|
||||||
|
"max_tokens": 2048,
|
||||||
|
"messages": [
|
||||||
|
{"role": "system", "content": system},
|
||||||
|
{"role": "user", "content": user_message},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
req = urllib.request.Request(
|
||||||
|
"https://api.neurometric.ai/v1/chat/completions",
|
||||||
|
data=json.dumps(body).encode(),
|
||||||
|
headers={
|
||||||
|
"Authorization": f"Bearer {nm_key}",
|
||||||
|
"content-type": "application/json",
|
||||||
|
},
|
||||||
|
method="POST",
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(req, timeout=PER_MODEL_TIMEOUT) as resp:
|
||||||
|
data = json.loads(resp.read())
|
||||||
|
except Exception as e:
|
||||||
|
return {
|
||||||
|
"slug": slug, "display": display, "is_primary": is_primary,
|
||||||
|
"provider_type": "neurometric_prose",
|
||||||
|
"error": str(e)[:300],
|
||||||
|
"cost_cents": 0,
|
||||||
|
}
|
||||||
|
prose = data.get("choices", [{}])[0].get("message", {}).get("content") or ""
|
||||||
|
verdict = infer_verdict_from_prose(prose)
|
||||||
|
return {
|
||||||
|
"slug": slug, "display": display, "is_primary": is_primary,
|
||||||
|
"provider_type": "neurometric_prose",
|
||||||
|
"review": {"verdict": verdict, "prose": prose},
|
||||||
|
"prompt_tokens": 0, "completion_tokens": 0,
|
||||||
|
"cost_cents": 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
def call_model(slug, display, in_rate, out_rate, is_primary, provider_type="openrouter_tools"):
|
||||||
|
if provider_type == "neurometric_prose":
|
||||||
|
return call_neurometric_prose(slug, display, is_primary)
|
||||||
|
return call_openrouter_tools(slug, display, in_rate, out_rate, is_primary)
|
||||||
|
|
||||||
|
results = []
|
||||||
|
with concurrent.futures.ThreadPoolExecutor(max_workers=len(MODELS)) as pool:
|
||||||
|
futures = [pool.submit(call_model, *m) for m in MODELS]
|
||||||
|
for f in concurrent.futures.as_completed(futures):
|
||||||
|
results.append(f.result())
|
||||||
|
|
||||||
|
# Order: primary first, then alphabetical for stable comparison
|
||||||
|
results.sort(key=lambda r: (not r.get("is_primary"), r["display"]))
|
||||||
|
|
||||||
|
# Build combined comment
|
||||||
|
primary = next((r for r in results if r.get("is_primary") and "review" in r), None)
|
||||||
|
heading_verdict = primary["review"]["verdict"] if primary else "MIXED"
|
||||||
|
|
||||||
|
lines = [f"## CTO Review — {heading_verdict}", ""]
|
||||||
|
lines.append(f"_A/B harness active: {len(results)} models reviewing in parallel. Primary verdict drives heading; others are advisory._")
|
||||||
|
lines.append("")
|
||||||
|
|
||||||
|
total_cents = 0.0
|
||||||
|
for r in results:
|
||||||
|
lines.append(f"---")
|
||||||
|
primary_tag = " (primary)" if r.get("is_primary") else ""
|
||||||
|
lines.append(f"### {r['display']}{primary_tag}")
|
||||||
|
if "error" in r:
|
||||||
|
lines.append("")
|
||||||
|
lines.append(f"⚠️ Model failed: `{r['error']}`")
|
||||||
|
lines.append("")
|
||||||
|
continue
|
||||||
|
rev = r["review"]
|
||||||
lines.append("")
|
lines.append("")
|
||||||
lines.append(f"_reviewer: {MODEL_DISPLAY}_")
|
if r.get("provider_type") == "neurometric_prose":
|
||||||
else:
|
lines.append(f"**Verdict:** {rev['verdict']} _(heuristic, inferred from prose)_")
|
||||||
heading_verdict = review.get("verdict", "COMMENT")
|
lines.append("")
|
||||||
lines = [f"## CTO Review — {heading_verdict}", ""]
|
# Cap at 6KB to keep PR comments readable; 4B model output is rarely over this
|
||||||
lines.append(f"**Verdict:** {heading_verdict}")
|
prose = rev.get("prose", "")
|
||||||
|
if len(prose) > 6000:
|
||||||
|
prose = prose[:6000] + "\n\n_…output truncated for comment length…_"
|
||||||
|
lines.append(prose)
|
||||||
|
lines.append("")
|
||||||
|
lines.append("_free tier; per-call token usage not tracked_")
|
||||||
|
lines.append("")
|
||||||
|
continue
|
||||||
|
lines.append(f"**Verdict:** {rev.get('verdict', 'COMMENT')}")
|
||||||
lines.append("")
|
lines.append("")
|
||||||
lines.append(review.get("summary") or "_(model returned no summary)_")
|
lines.append(rev.get("summary") or "_(model returned no summary)_")
|
||||||
lines.append("")
|
lines.append("")
|
||||||
if review.get("concerns"):
|
if rev.get("concerns"):
|
||||||
lines.append("**Concerns:**")
|
lines.append("**Concerns:**")
|
||||||
for c in review["concerns"]:
|
for c in rev["concerns"]:
|
||||||
sev = c.get("severity", "UNKNOWN").upper()
|
sev = c.get("severity", "UNKNOWN").upper()
|
||||||
f = f"`{c['file']}`" if c.get("file") else ""
|
f = f"`{c['file']}`" if c.get("file") else ""
|
||||||
lines.append(f"- **{sev}** {f} — {c['issue']}")
|
lines.append(f"- **{sev}** {f} — {c['issue']}")
|
||||||
lines.append("")
|
lines.append("")
|
||||||
if review.get("positives"):
|
if rev.get("positives"):
|
||||||
lines.append("**Positives:** " + "; ".join(review["positives"]))
|
lines.append("**Positives:** " + "; ".join(rev["positives"]))
|
||||||
lines.append("")
|
lines.append("")
|
||||||
lines.append(f"_tokens in/out: {ptok}/{ctok} · cost: ${cost_cents/100:.4f}_")
|
lines.append(f"_tokens in/out: {r['prompt_tokens']}/{r['completion_tokens']} · cost: ${r['cost_cents']/100:.4f}_")
|
||||||
|
total_cents += r["cost_cents"]
|
||||||
lines.append("")
|
lines.append("")
|
||||||
|
|
||||||
lines.append("---")
|
lines.append("---")
|
||||||
lines.append(f"_Total review cost: **${cost_cents/100:.4f}**. Reviewer: {MODEL_DISPLAY}. Roster configured in `.github/workflows/cto-review.yml`._")
|
lines.append(f"_Total review cost: **${total_cents/100:.4f}**. A/B roster configured in `.github/workflows/cto-review.yml`._")
|
||||||
|
|
||||||
with open("/tmp/review-body.md", "w") as f:
|
with open("/tmp/review-body.md", "w") as f:
|
||||||
f.write("\n".join(lines))
|
f.write("\n".join(lines))
|
||||||
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
|
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
|
||||||
f.write(f"added_cents={int(round(cost_cents))}\n")
|
f.write(f"added_cents={int(round(total_cents))}\n")
|
||||||
f.write(f"skipped=0\n")
|
f.write(f"skipped=0\n")
|
||||||
f.write(f"primary_verdict={heading_verdict}\n")
|
f.write(f"primary_verdict={heading_verdict}\n")
|
||||||
PY
|
PY
|
||||||
|
|
||||||
- name: Post PR review (formal APPROVE / REQUEST_CHANGES / COMMENT)
|
- name: Post PR review (formal APPROVE / REQUEST_CHANGES / COMMENT)
|
||||||
# Uses Haiku's verdict as the formal event. Falls back to COMMENT
|
# Uses primary model's verdict as the formal event. Falls back to COMMENT
|
||||||
# if the model failed or returned something unexpected.
|
# if the primary model failed or returned something unexpected.
|
||||||
if: steps.budget.outputs.skip != 'true' && steps.review.outputs.skipped != '1'
|
if: steps.budget.outputs.skip != 'true' && steps.review.outputs.skipped != '1'
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
env:
|
env:
|
||||||
|
|||||||
26
CHANGELOG.md
26
CHANGELOG.md
@@ -5,30 +5,6 @@ All notable changes to PRAutoBlogger will be documented in this file.
|
|||||||
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project uses [Semantic Versioning](https://semver.org/).
|
and this project uses [Semantic Versioning](https://semver.org/).
|
||||||
|
|
||||||
## [0.20.2] - 2026-06-13
|
|
||||||
|
|
||||||
### Removed
|
|
||||||
- **`scripts/deploy.sh`** — belonged to the retired zip/REST deploy receiver flow
|
|
||||||
(`/wp-json/prautoblogger-deploy/v1/*`); the live pipeline is the shared rsync workflow
|
|
||||||
(`peptiderepo/peptide-e2e/.github/workflows/deploy-app.yml@main`).
|
|
||||||
- **`.distignore`** — used by `scripts/deploy.sh` to build the production zip; no longer
|
|
||||||
consumed by any workflow (the shared rsync pipeline uses hardcoded `--exclude` flags).
|
|
||||||
|
|
||||||
|
|
||||||
## [0.20.1] - 2026-06-12
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- **Restore three bootstrap constants deleted by the v0.19.0 constants-block regression**
|
|
||||||
(`PRAUTOBLOGGER_DEFAULT_RUN_CEILING_USD` 0.50, `PRAUTOBLOGGER_DEFAULT_REQUEST_JSON_RETENTION_DAYS` 14,
|
|
||||||
`PRAUTOBLOGGER_DEFAULT_REASONING_MAX_TOKENS` 2048 — verbatim v0.18.3 values). PR #156 (v0.19.0)
|
|
||||||
dropped them from `prautoblogger.php`; the gap was latent because `tests/bootstrap.php` defines
|
|
||||||
its own fallbacks (CI green) and no exercised v0.19.x runtime path read them (prod reasoning
|
|
||||||
disabled). v0.20.0's activator defaults + run-state ceiling read them on the admin
|
|
||||||
migration path -> fatal 500 on all plugin admin pages immediately after the v0.20.0 deploy
|
|
||||||
(2026-06-12; front-of-site unaffected; hot-patched on prod within minutes, this commit makes
|
|
||||||
it canonical). Follow-up owed: CI guard asserting every referenced PRAUTOBLOGGER_* constant
|
|
||||||
is production-defined or defined()-guarded (maintenance thread).
|
|
||||||
|
|
||||||
## [0.20.0] - 2026-06-12
|
## [0.20.0] - 2026-06-12
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -1230,4 +1206,4 @@ swap with no user-visible change in article quality.
|
|||||||
- AJAX-powered "Generate Now" and "Test Connections" buttons.
|
- AJAX-powered "Generate Now" and "Test Connections" buttons.
|
||||||
- Custom database tables for source data, analysis results, generation logs, and content scores.
|
- Custom database tables for source data, analysis results, generation logs, and content scores.
|
||||||
- Clean uninstall handler removing all plugin data.
|
- Clean uninstall handler removing all plugin data.
|
||||||
- ARCHITECTURE.md and CONVENTIONS.md for AI-readable codebase documentation.
|
- ARCHITECTURE.md and CONVENTIONS.md for AI-readable codebase documentation.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
* Plugin Name: PRAutoBlogger
|
* Plugin Name: PRAutoBlogger
|
||||||
* Plugin URI: https://peptiderepo.com/prautoblogger
|
* Plugin URI: https://peptiderepo.com/prautoblogger
|
||||||
* Description: Monitors social media for trending topics, generates SEO-friendly blog posts using AI, and publishes them on a daily schedule with full cost tracking and self-improvement metrics.
|
* Description: Monitors social media for trending topics, generates SEO-friendly blog posts using AI, and publishes them on a daily schedule with full cost tracking and self-improvement metrics.
|
||||||
* Version: 0.20.2
|
* Version: 0.20.0
|
||||||
* Requires at least: 6.0
|
* Requires at least: 6.0
|
||||||
* Requires PHP: 7.4
|
* Requires PHP: 7.4
|
||||||
* Author: PeptideRepo
|
* Author: PeptideRepo
|
||||||
@@ -35,16 +35,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
| Defined here so every file in the plugin can reference paths, versions,
|
| Defined here so every file in the plugin can reference paths, versions,
|
||||||
| and limits without magic strings.
|
| and limits without magic strings.
|
||||||
*/
|
*/
|
||||||
define( 'PRAUTOBLOGGER_VERSION', '0.20.2' );
|
define( 'PRAUTOBLOGGER_VERSION', '0.20.0' );
|
||||||
define( 'PRAUTOBLOGGER_DB_VERSION', '1.3.0' );
|
define( 'PRAUTOBLOGGER_DB_VERSION', '1.3.0' );
|
||||||
define( 'PRAUTOBLOGGER_DEFAULT_RUN_CEILING_USD', 0.50 );
|
|
||||||
define( 'PRAUTOBLOGGER_DEFAULT_REQUEST_JSON_RETENTION_DAYS', 14 );
|
|
||||||
// v0.18.1: ceiling on "thinking" tokens per reasoning-enabled LLM call. The
|
|
||||||
// request's completion budget (max_tokens) is RAISED by this amount so
|
|
||||||
// reasoning can never consume the visible-content budget and return an empty
|
|
||||||
// message (the 2026-06-11 empty-draft incident). SETTINGS-backed
|
|
||||||
// (prautoblogger_reasoning_max_tokens); 0 disables the cap (pure effort mode).
|
|
||||||
define( 'PRAUTOBLOGGER_DEFAULT_REASONING_MAX_TOKENS', 2048 );
|
|
||||||
define( 'PRAUTOBLOGGER_PLUGIN_FILE', __FILE__ );
|
define( 'PRAUTOBLOGGER_PLUGIN_FILE', __FILE__ );
|
||||||
define( 'PRAUTOBLOGGER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
define( 'PRAUTOBLOGGER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
define( 'PRAUTOBLOGGER_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
define( 'PRAUTOBLOGGER_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
|||||||
160
scripts/deploy.sh
Executable file
160
scripts/deploy.sh
Executable file
@@ -0,0 +1,160 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# ============================================================================
|
||||||
|
# PRAutoBlogger Manual Deploy Script
|
||||||
|
#
|
||||||
|
# Packages the plugin into a clean zip and deploys it to WordPress via the
|
||||||
|
# deploy-receiver REST endpoint. Use this for hotfixes or local deploys when
|
||||||
|
# you don't want to go through the full GitHub Actions pipeline.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# ./scripts/deploy.sh
|
||||||
|
#
|
||||||
|
# Environment variables (set in .env or export before running):
|
||||||
|
# DEPLOY_URL — Full URL to the deploy endpoint
|
||||||
|
# DEPLOY_KEY — The deploy authentication token
|
||||||
|
#
|
||||||
|
# If not set, the script will look for a .env file in the project root.
|
||||||
|
#
|
||||||
|
# @see .github/workflows/deploy.yml — Automated pipeline (same deploy step).
|
||||||
|
# @see ARCHITECTURE.md — Deploy architecture (Code Snippets snippet #8 on server).
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||||
|
|
||||||
|
# Colors for output.
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
info() { echo -e "${GREEN}[deploy]${NC} $*"; }
|
||||||
|
warn() { echo -e "${YELLOW}[deploy]${NC} $*"; }
|
||||||
|
error() { echo -e "${RED}[deploy]${NC} $*" >&2; }
|
||||||
|
|
||||||
|
# ── Load environment ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
if [[ -f "$PROJECT_ROOT/.env" ]]; then
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$PROJECT_ROOT/.env"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${DEPLOY_URL:-}" ]]; then
|
||||||
|
error "DEPLOY_URL not set. Export it or add to .env"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${DEPLOY_KEY:-}" ]]; then
|
||||||
|
error "DEPLOY_KEY not set. Export it or add to .env"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── Read version ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
VERSION=$(grep -oP 'Version:\s*\K[0-9]+\.[0-9]+\.[0-9]+' "$PROJECT_ROOT/prautoblogger.php" || echo "0.0.0")
|
||||||
|
info "PRAutoBlogger v${VERSION}"
|
||||||
|
|
||||||
|
# ── PHP lint check ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
info "Running PHP syntax check..."
|
||||||
|
LINT_ERRORS=0
|
||||||
|
while IFS= read -r -d '' file; do
|
||||||
|
if ! php -l "$file" > /dev/null 2>&1; then
|
||||||
|
error "Syntax error in: $file"
|
||||||
|
php -l "$file"
|
||||||
|
LINT_ERRORS=$((LINT_ERRORS + 1))
|
||||||
|
fi
|
||||||
|
done < <(find "$PROJECT_ROOT" -name '*.php' -not -path '*/vendor/*' -not -path '*/tests/*' -not -path '*/.github/*' -print0)
|
||||||
|
|
||||||
|
if [[ $LINT_ERRORS -gt 0 ]]; then
|
||||||
|
error "$LINT_ERRORS file(s) have syntax errors. Aborting deploy."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
info "Lint passed."
|
||||||
|
|
||||||
|
# ── Package ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
BUILD_DIR=$(mktemp -d)
|
||||||
|
PLUGIN_DIR="$BUILD_DIR/prautoblogger"
|
||||||
|
ZIP_PATH="$BUILD_DIR/prautoblogger-${VERSION}.zip"
|
||||||
|
|
||||||
|
info "Packaging plugin..."
|
||||||
|
|
||||||
|
mkdir -p "$PLUGIN_DIR"
|
||||||
|
|
||||||
|
# Copy production files, excluding dev artifacts.
|
||||||
|
rsync -a \
|
||||||
|
--exclude='.git' \
|
||||||
|
--exclude='.github' \
|
||||||
|
--exclude='.gitignore' \
|
||||||
|
--exclude='.distignore' \
|
||||||
|
--exclude='.env' \
|
||||||
|
--exclude='.env.local' \
|
||||||
|
--exclude='tests/' \
|
||||||
|
--exclude='scripts/' \
|
||||||
|
--exclude='vendor/' \
|
||||||
|
--exclude='node_modules/' \
|
||||||
|
--exclude='composer.json' \
|
||||||
|
--exclude='composer.lock' \
|
||||||
|
--exclude='phpunit.xml' \
|
||||||
|
--exclude='phpunit.xml.dist' \
|
||||||
|
--exclude='.phpcs.xml' \
|
||||||
|
--exclude='ARCHITECTURE.md' \
|
||||||
|
--exclude='CONVENTIONS.md' \
|
||||||
|
--exclude='CHANGELOG.md' \
|
||||||
|
--exclude='build/' \
|
||||||
|
--exclude='*.log' \
|
||||||
|
--exclude='.DS_Store' \
|
||||||
|
"$PROJECT_ROOT/" "$PLUGIN_DIR/"
|
||||||
|
|
||||||
|
cd "$BUILD_DIR"
|
||||||
|
zip -rq "$ZIP_PATH" prautoblogger/
|
||||||
|
|
||||||
|
ZIP_SIZE=$(du -h "$ZIP_PATH" | cut -f1)
|
||||||
|
info "Built ${ZIP_PATH} (${ZIP_SIZE})"
|
||||||
|
|
||||||
|
# ── Pre-deploy health check ────────────────────────────────────────────────
|
||||||
|
|
||||||
|
STATUS_URL="${DEPLOY_URL%/deploy}/status"
|
||||||
|
info "Checking deploy endpoint health..."
|
||||||
|
STATUS_RESPONSE=$(curl -sS -w "\n%{http_code}" \
|
||||||
|
-H "X-Deploy-Key: ${DEPLOY_KEY}" \
|
||||||
|
"${STATUS_URL}" 2>&1) || true
|
||||||
|
|
||||||
|
STATUS_HTTP=$(echo "$STATUS_RESPONSE" | tail -1)
|
||||||
|
if [[ "$STATUS_HTTP" == "200" ]]; then
|
||||||
|
STATUS_BODY=$(echo "$STATUS_RESPONSE" | head -n -1)
|
||||||
|
info "Endpoint healthy: ${STATUS_BODY}"
|
||||||
|
else
|
||||||
|
warn "Health check returned HTTP ${STATUS_HTTP} — proceeding anyway."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── Deploy ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
info "Deploying to ${DEPLOY_URL}..."
|
||||||
|
|
||||||
|
RESPONSE=$(curl -sS -w "\n%{http_code}" \
|
||||||
|
-X POST "${DEPLOY_URL}" \
|
||||||
|
-H "X-Deploy-Key: ${DEPLOY_KEY}" \
|
||||||
|
-F "plugin=@${ZIP_PATH}" \
|
||||||
|
--max-time 120)
|
||||||
|
|
||||||
|
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
|
||||||
|
BODY=$(echo "$RESPONSE" | head -n -1)
|
||||||
|
|
||||||
|
if [[ "$HTTP_CODE" -eq 200 ]]; then
|
||||||
|
info "Deployment successful!"
|
||||||
|
echo "$BODY" | python3 -m json.tool 2>/dev/null || echo "$BODY"
|
||||||
|
else
|
||||||
|
error "Deployment FAILED (HTTP ${HTTP_CODE}):"
|
||||||
|
echo "$BODY" | python3 -m json.tool 2>/dev/null || echo "$BODY"
|
||||||
|
rm -rf "$BUILD_DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── Cleanup ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
rm -rf "$BUILD_DIR"
|
||||||
|
info "Done. PRAutoBlogger v${VERSION} is live."
|
||||||
Reference in New Issue
Block a user