30 Commits
Author SHA1 Message Date
John Smith fc24751b2e feat: consolidate harness-audit into heretek-actions monorepo 2026-08-13 12:55:40 -04:00
BillyOutlast c648460aa1 Merge pull request #2 from Heretek-AI/feat/lint-ultimate-action
feat(lint): add lint-ultimate action wrapping MegaLinter with envelope
2026-07-30 19:41:46 -04:00
BillyOutlastandCopilot Autofix powered by AI c72d6a9967 Potential fix for pull request finding 'CodeQL / Code injection'
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-07-30 19:40:44 -04:00
John Smith b68cb2ba0f fix: resolve CodeQL injection, CI fork-permissions, and vitest CVE
- lint-ultimate/action.yml: Add input validation step for linter-version
  (regex allowlist) and linter type before shell interpolation, resolving
  CodeQL code-injection findings (#discussion_r3685339915, #discussion_r3685339933)
- pr-summary.yml & review.yml: Switch from pull_request to
  pull_request_target with explicit head SHA checkout, so fork PRs get
  a write-capable GITHUB_TOKEN for comment posting
- tests/fixtures/js-{failing,passing}/package.json: Bump vitest from
  ^2.0.0 to ^3.2.6, resolving GHSA-5xrq-8626-4rwp (critical CVE)
2026-07-30 19:38:56 -04:00
John Smith 6ae3e16aba feat(lint): add lint-ultimate action wrapping MegaLinter with envelope
Tier 1.1 of the quality expansion design. Adds the lint-ultimate
composite action that runs MegaLinter (or Super-Linter) over the
repo and emits a per-linter checks[] plus per-finding findings[]
envelope, matching the standard .agent/output.json contract.

## Changes

### Action
- .github/actions/lint-ultimate/action.yml: composite action, runs
  oxsecurity/megalinter:v7 via Docker, uploads the JSON report and
  stdout as lint-ultimate-reports artifact, uploads the envelope as
  agent-output-lint for downstream consumers.
- .github/actions/lint-ultimate/build-envelope.sh: parses
  megalinter-report.json, maps each linter category to a check[]
  entry and each finding to a findings[] entry. Falls back to an
  empty envelope when the report is missing or unreadable.

### Library
- .github/actions/agent-envelope.sh: add add_finding() helper
  mirroring add_check(). Optional fields (rule, file, line, column,
  suggested_fix) default to null; numbers coerce when non-empty.

### Library fixes (pre-existing bugs surfaced by the new test)
- GITHUB_REPOSITORY default and owner/repo prefix strip now set -u
  safe. Previously the original --arg repo_name reference threw on
  unbound-variable in any non-GitHub runner.
- GITHUB_RUN_ID now passed as --argjson (numeric or null) instead of
  --arg with tonumber? in the filter. The prior form silently
  produced empty output when run_id was unset (jq 1.8.2 quirk where
  tonumber? on null returns Empty and jq emits no output).

### Schema
- .agent/schema.json: enum agent_action extended with all twelve new
  values from the quality-check expansion design (lint-ultimate,
  coverage, actionlint, codeql, lefthook-ci, test-matrix, reviewdog,
  quality-gate, semantic-release, dependabot, docker-ci). Future
  Tier 1/2/3 PRs pick the right value.

### Tests
- tests/: ship the previously untracked harness (run-action.sh,
  run-all.sh, README.md, fixtures for all CI actions) plus the
  new megalinter-passing and megalinter-failing fixtures.
- tests/unit/test-lint-ultimate-parser.sh: parser unit test that
  runs build-envelope.sh against a fabricated megalinter-report.json
  and asserts the envelope shape. No Docker required.
- tests/golden/lint-ultimate/README.md: documents that goldens are
  generated on first real-CI run (per tests/README.md first-run
  convention) and provides a no-Docker local check.

### Matrix
- tests/run-all.sh: megalinter-passing and megalinter-failing added
  to MATRIX (paired with lint-ultimate action).

### Docs
- README.md: lint-ultimate row added to the CI Composite Actions
  table; full example block added between python-ci and ---.

## Risk

- Pre-existing agent-envelope.sh changes affect all envelope-writing
  callers; the same fixes apply everywhere (none had a green test
  before). Behavior is unchanged when GITHUB_* env vars are set
  (real CI).
- No existing tests to regress against (tests/ was untracked).
  Unit test added in this PR exercises the new parser path.

Refs: docs/superpowers/specs/2026-07-30-code-quality-expansion-design.md
2026-07-30 14:38:20 -04:00
BillyOutlast 2db7db4fd5 Merge pull request #1 from Heretek-AI/docs/quality-expansion-review-feedback
docs(specs): resolve review feedback on code quality expansion design
2026-07-30 14:30:39 -04:00
John Smith 75ec8944b6 docs(specs): resolve review feedback on code quality expansion design
Capture five decisions + one re-sequencing note that unblock Tier 1:

- semantic-release emits agent_action 'semantic-release'; chain on
  outputs.next-version rather than colliding with 'release'
- coverage artifacts use coverage-{lang} names; coverage action
  downloads with pattern: coverage-*, merge-multiple: true
- codeql-analysis.yml uploads agent-output-codeql so the
  quality-gate orchestrator can consume it via the standard channel
- semantic-release.yml trigger model: push -> version -> commit ->
  tag -> repository_dispatch -> release.yml
- split dependabot config (3.2.1) from dependency-review workflow
  (3.2.2); remove the standalone dependabot-envelope action
- single coverage-baseline mechanism: explicit commit only; remove
  threshold-diff input and the auto-write baseline paragraph
- reorder Tier 1: actionlint before coverage so the upload-artifact
  pattern is established first
- reframe reviewdog (#7) as a helper script in agent-envelope.sh,
  not a standalone composite action

Refs: review of 2026-07-30-code-quality-expansion-design.md
2026-07-30 14:28:39 -04:00
John SmithandClaude 401fd85d07 Fix ocr scan: enumerate files explicitly for CI checkout
On a fresh CI checkout (actions/checkout), git diff is empty, so ocr
scan's auto-discovery finds 0 files to review. Replace the bare
--path '.' with an explicit comma-separated file list built from find.

This ensures every file under SCAN_PATH is reviewed, matching the
behavior ocr scan shows when run locally with a dirty working tree.

Co-Authored-By: Claude <[email protected]>
2026-07-30 13:45:35 -04:00
John SmithandClaude 0f7bfb29bc Fix ocr-scan: replace broken eval with direct command invocation
The eval-based flag building used embedded quotes inside variables,
which shell interprets as literal quote characters. This caused
ocr scan --path '. to become --path with value '.'\'' (including
quotes), making it scan an empty directory set and exit immediately.

Fix: invoke ocr scan directly with properly quoted arguments,
using shell conditional expansion for the optional --no-plan flag.

Co-Authored-By: Claude <[email protected]>
2026-07-30 13:34:52 -04:00
John SmithandClaude 1d1cf3ef23 Optimize OCR workflows: direct CLI, provider config, credential validation, concurrency/background/no-plan flags
Rewrite both ocr-review.yml and ocr-scan.yml to use direct CLI
invocation instead of the marketplace composite action, matching the
official OCR CI/CD documentation patterns.

Changes:
- ocr-review.yml: Replace alibaba/open-code-review@main action with
  direct 'ocr review' CLI. Add --background (PR title context),
  --concurrency (default 5), provider-based config (custom_providers.*),
  credential validation via 'ocr llm test', version pin to 1.8.1.
- ocr-scan.yml: Switch to same provider config model. Add --concurrency
  (default 5), --no-plan toggle (opt-out for speed, 'false' for quality).
  Fix default model from claude-sonnet-4-20250514 to deepseek-v4-flash.
  Add credential validation step.
- Design spec: docs/superpowers/specs/2026-07-30-ocr-workflow-optimization-design.md

Co-Authored-By: Claude <[email protected]>
2026-07-30 13:31:41 -04:00
John SmithandClaude f49ec53ecc docs: add code quality expansion design spec
Design doc covering 12 additions across 3 tiers:
- Tier 1: MegaLinter lint, coverage upload/gates, actionlint, CodeQL
- Tier 2: Lefthook config, test sharding, reviewdog, quality gates
- Tier 3: Semantic release, dependabot, Docker CI, AI slop checker

All additions follow existing composite action + envelope patterns.
Includes quality-check.yml orchestrator for one-stop adoption.

Co-Authored-By: Claude <[email protected]>
2026-07-30 13:30:05 -04:00
John Smith 287924977f Fix ${VAR:-{}} shell expansion corrupting .agent/output.json
Root cause: bash parses ${VAR:-{}} as "word={, default}" with the
trailing } treated as a literal append. Result: ${VAR:-{}} with
VAR set to {a:b,c:d} produces {a:b,c:d}} — the extra } closes
the root object early, making the rest of the JSON trailing garbage.

Verified from artifact hex at offset 0x103:
  7d 7d 2c 0a  =  }},\n   (double close brace before comma)

This corrupted .agent/output.json in scan PR #30561172584, causing
the Summarize step to fail with "Expected value before ',' at
line 11, column 3".

Fix: assign defaults via explicit if/then, then reference the
variable directly. Applies to all 5 JSON variables in BOTH the
primary jq path AND the heredoc fallback:
  AGENT_OUTPUTS, AGENT_SUGGESTIONS, AGENT_CHECKS, AGENT_FINDINGS,
  AGENT_RELEASE

Verified pre/post-fix produces:
  pre  : {"a":"b"}}    (extra })
  post : {"a":"b"}      (clean)
2026-07-30 12:38:37 -04:00
John Smith 6eb60ecb84 Align ocr-scan LLM config with official CI/CD docs pattern
From official docs at integrations/ci.md:
- Use llm.* config keys (llm.url, llm.auth_token, llm.model,
  llm.use_anthropic) instead of custom_providers
- Add llm.extra_body to disable thinking mode for provider compat
- Model is configured via ocr config set, not --model flag

Docs ref: github.com/alibaba/open-code-review/blob/main/
  pages/src/content/docs/en/integrations/ci.md
2026-07-30 12:20:07 -04:00
John Smith b378f5b67d Fix ocr-scan: correct package, add LLM config, fix output handling
Root cause analysis (5-perspective adversarial review):

1. Wrong NPM package — used @open-code-review/cli (doesn't exist),
   correct is @alibaba-group/open-code-review (verified on npmjs.com)

2. Missing LLM config — OCR_LLM_URL/OCR_LLM_TOKEN are custom env vars
   OCR doesn't read. Added ocr config set step mapping to a custom
   provider with the protocol/url/key from workflow secrets.

3. No install verification — previous install step swallowed all
   errors with 2>/dev/null || true. Now uses npm install -g + ocr
   scan --help + ocr llm test for fail-fast verification.

4. Wrong output path — scan --format json writes JSON to stdout, not
   .ocr/result.json. Now captures stdout directly to .ocr/result.json.

5. Missing comments field in envelope — build-envelope.sh didn't
   handle .comments[] from scan output (only handled .issues and
   .review_comments). Added .comments extraction with field mapping.

Fixes:
- .github/workflows/ocr-scan.yml: Split into Install & Configure +
  Run Scan steps. Correct package, LLM config via custom provider,
  direct output capture, explicit --model flag.
- .github/actions/ocr-envelope/build-envelope.sh: Handle .comments[]
  from scan output, map to uniform findings format with file/line/
  message/severity, handle object-typed .summary field.
2026-07-30 12:18:44 -04:00
John Smith 23bd0ccee3 Fix jq stdin hang and broken OCR CLI install
Two bugs from previous 'cat | jq' fix commit:

1. All Summarize/Read Agent Output steps used 'jq -r ...'
   without file argument — jq reads stdin, hangs in GH Actions
   (stdin = /dev/null, parse error, empty output).
   Added '.agent/output.json' arg to every jq call.

2. ocr-scan.yml Install step swallowed errors (2>/dev/null || true),
   silently installing old OCR binary without 'scan' subcommand.
   Removed install step, replaced with 'npx @open-code-review/cli@latest
   scan' — always pulls latest from npm.

Also fixed jq in disabled Create Issues step.
2026-07-30 12:06:43 -04:00
John SmithandClaude 8cf36d27de Fix 'cat | jq' pipefail crashes in summarize steps
All workflow 'Summarize' / 'Read Agent Output' steps used
'cat file | jq ... >> ' pipelines. With
set -o pipefail (GitHub Actions default), a jq exit code 5 (parse
error on malformed JSON) would kill the entire step — even though
the envelope was written successfully.

Fix: Replace all cat|jq pipe patterns with direct 'jq -r ... file'
invocations. jq can read files directly without cat, and the error
handling uses 2>/dev/null || true for robust fallback when the file
happens to be malformed between write and read.

Co-Authored-By: Claude <[email protected]>
v1 v2
2026-07-30 11:43:53 -04:00
John Smith c1075322b2 Fix remaining CI failures: pre-commit heredoc, secrets baseline, agent-context log step 2026-07-30 11:41:26 -04:00
John SmithandClaude 5c21ddf729 Fix jq invalid JSON crash and clean up agent-envelope.sh structure
agent-envelope.sh's write_envelope was failing with 'jq: invalid JSON
text passed to --argjson' when AGENT_OUTPUTS contained malformed JSON
from uninitialized variables.

Fix: merged the jq call into a single 'if command -v jq && jq -n ...; then'
block with 2>/dev/null on the jq call. When jq fails (command not found or
bad --argjson input), it falls through to the simple cat fallback instead of
crashing with exit code 2.

This is the simpler and more robust approach — no extra validation logic,
no nested ifs. jq failure is non-fatal, period.

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:39:09 -04:00
John SmithandClaude d05b726eca Fix 'unbound variable' error in build-context.sh
detect_stack/detect_hooks/query_github functions write variables to
GITHUB_ENV for downstream workflow steps, but the same shell session
needs them as local variables too. Added explicit defaults before the
function calls.

Also removed heredoc expansion fallback syntax (:-) since variables
now have guaranteed defaults set before they're used.

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:35:39 -04:00
John SmithandClaude 1858458954 Fix unclosed command substitutions in all shell scripts
All scripts using the pattern AGENT_OUTPUTS=$(cat <<OUTPUTS ... OUTPUTS
were missing the closing ')' for the  command substitution. This caused
'unexpected EOF while looking for matching )' errors at runtime.

Fixed 7 files: build-context.sh, watch-checks.sh, triage-issue.sh,
analyze-pr.sh, run-review.sh, run-release.sh, and the 3 write-envelope.sh
files (rust-ci, js-ci, python-ci).

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:34:10 -04:00
John SmithandClaude 2638c11cb8 Fix shell syntax error in agent-envelope.sh
Missing closing parentheses in  command substitution on the
jq-less fallback path of add_suggestion and add_check:
- line 130: .../cat && echo ...])) was missing the final ))
- line 154: same pattern
Also removed set -euo pipefail since this is a sourced library,
not a standalone script.

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:30:43 -04:00
John SmithandClaude 5edce69249 Fix internal action references: use relative paths not org/repo@tag
When a workflow inside a repo references a composite action from the same
repo, it must use './.github/actions/name' — not 'org/repo/.github/actions/name@tag'.
The latter is for external repos and fails with 'Can't find action.yml'.

Fixed across all 10 workflow files.

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:29:18 -04:00
John SmithandClaude ebcc07a52f Fix pre-commit CI: remove invalid self-reference and broken types-all dep
- Removed Heretek-AI/heretek-actions self-reference from pre-commit config
  (repo has no .pre-commit-hooks.yaml manifest)
- Removed mypy's types-all additional_dependencies which has yanked
  packages (types-pkg-resources not found)
- Updated mypy rev to v1.15.0

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:27:41 -04:00
John SmithandClaude 6bb22674a7 Remove invalid pre-commit self-reference
pre-commit config referenced Heretek-AI/heretek-actions as a hook repo
but this repo doesn't have a .pre-commit-hooks.yaml manifest, causing
InvalidManifestError in CI.

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:25:41 -04:00
John SmithandClaude 929f0a9c23 Fix CI failures: permissions, reserved secret name, pre-commit types
Three issues causing all workflow runs to fail:

1. github_token is a reserved name in workflow_call secrets
   - Renamed to repo_token across ocr-review, ocr-scan, release, and
     check-status workflows. Updated all secrets.repo_token refs.

2. Shell scripts not executable (exit code 126)
   - chmod +x all .sh files in .github/actions/

3. pre-commit types_or rejected 'typescript' type tag
   - Changed to 'ts' in .pre-commit-config.yaml for eslint and prettier hooks

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:24:16 -04:00
John SmithandClaude c20975e3d2 Add ocr_llm_model secret for default model configuration
Users can now set OCR_LLM_MODEL as a GitHub secret to configure the
LLM model once at the repo/org level without exposing it in workflow files.

Resolution order: secrets.ocr_llm_model -> inputs.ocr-llm-model ->
vars.OCR_LLM_MODEL -> built-in default (claude-sonnet-4-20250514)

Updated both ocr-review and ocr-scan workflows plus README documentation.

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:17:12 -04:00
John SmithandClaude d931be0fb8 Fix invalid GitHub secret names (hyphens -> underscores)
GitHub secret names can only contain alphanumeric and underscore characters.
Renamed all hyphenated secret names in workflow_call definitions to use
underscores instead:

- ocr-llm-url -> ocr_llm_url
- ocr-llm-token -> ocr_llm_token
- github-token -> github_token (across ocr-review, ocr-scan, release, check-status)
- npm-token -> npm_token (release.yml)

Updated all corresponding secrets.X references and README documentation.

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:15:41 -04:00
John SmithandClaude fb2dcbbf25 Add Open Code Review (OCR) workflows for PR review and full codebase scan
Two new optional reusable workflows integrating alibaba/open-code-review into
the heretek-actions ecosystem:

- ocr-review.yml — AI-powered PR review on pull_request_target, with
  re-trigger support via /open-code-review or @open-code-review comments.
  Outputs .agent/output.json with findings for agent consumption.

- ocr-scan.yml — Full codebase scan on workflow_dispatch, scans the entire
  repo (or a sub-path) using OCR CLI. Outputs agent envelope with scan
  findings. Optional issue creation from findings.

Shared component:
- .github/actions/ocr-envelope/ — Composite action that reads OCR output
  and writes the standardized .agent/output.json with status, findings, and
  suggestions for agents to act upon.

Documentation:
- Updated README with OCR usage examples, configuration guide (secrets/vars),
  and workflow table entries

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:05:50 -04:00
John SmithandClaude 5523b46c62 Fix the github.action_path references in shell scripts
Shell scripts (.sh) were sourcing agent-envelope.sh via the literal
GitHub Actions expression '${{ github.action_path }}', which doesn't get
evaluated by the shell — only in run: blocks in action YAML files.

Fix: Pass AGENT_ACTION_PATH as an environment variable from the action.yml
env block (where the runner evaluates the expression) and reference it as
${AGENT_ACTION_PATH} in shell scripts.

Also fix: date format bug (%Y repeated twice) in agent-envelope.sh

Co-Authored-By: Claude <[email protected]>
2026-07-30 11:00:53 -04:00
John SmithandClaude c3633b2b14 Initial commit: Heretek Actions — agent-facing GitHub Actions
Complete implementation of all 7 phases:

Phase 1: Foundation
- Repository directory structure
- .agent/schema.json — Standard JSON envelope schema
- .github/CODEOWNERS, LICENSE (MIT), .gitignore
- README.md shell

Phase 2: Agent-Facing Actions (5 composite actions)
- agent-context — Scans repo, detects stack, queries GitHub API
- pr-summary — Analyzes PR diff, categorizes files, links issues
- issue-triage — Classifies, labels, detects duplicates
- check-status — Watches CI checks, produces merged status
- review — Lightweight structural code analysis
- Shared agent-envelope.sh helper for standardized .agent/output.json

Phase 3: Pre-commit Hooks
- .pre-commit-config.yaml — Universal hook config
- pre-commit-ci.yml — CI workflow running pre-commit

Phase 4: CI Composite Actions
- rust-ci — fmt, clippy, test, coverage (opt), audit (opt)
- js-ci — lint, typecheck, test (npm/pnpm/yarn/bun)
- python-ci — lint (ruff), typecheck (mypy), test (pytest)

Phase 5: Universal CI Orchestrator
- check.yml — Auto-detects languages, routes to CI actions

Phase 6: Universal Release
- release action — Docker, Flatpak, npm, GitHub releases
- release.yml — workflow_call reusable workflow

Phase 7: Documentation
- Full README with quick start, per-action docs, agent integration guide

Co-Authored-By: Claude <[email protected]>
2026-07-30 10:58:06 -04:00