Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: OpenCode PR review
name: OpenCode PR docs review

on:
pull_request_target:
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
steps:
# The reusable workflow's scripts are not present until the caller
# repository is checked out. Use only the trusted PR base revision.
- uses: actions/checkout@v6
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
ref: ${{ github.event.pull_request.base.sha || github.sha }}
persist-credentials: false
Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:
jq '{number, title, body, user: {login: .user.login}, base: {sha: .base.sha, ref: .base.ref}, head: {sha: .head.sha, ref: .head.ref}}' \
<<< "$pull_request" > "$RUNNER_TEMP/pr-metadata.json"

- uses: actions/setup-python@v6
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
if: steps.resolve.outputs.validate_only != 'true'
with:
python-version: '3.12'
Expand Down Expand Up @@ -346,6 +346,7 @@ jobs:
--resolved-config "$RUNNER_TEMP/resolved-agentic-configuration.json"
--effective-policy "$RUNNER_TEMP/effective-policy.json"
--provenance "$RUNNER_TEMP/resolved-agentic-provenance.json"
--response-diagnostics "$RUNNER_TEMP/opencode-response-diagnostics.json"
)
if [[ "$FAIL_IF_REVIEWED" == "true" ]]; then
review_args+=(--fail-if-reviewed)
Expand Down Expand Up @@ -383,13 +384,14 @@ jobs:

- name: Upload resolved invocation artifact
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: resolved-invocation-pr-review
path: |
${{ runner.temp }}/resolved-invocation.json
${{ runner.temp }}/resolved-agentic-configuration.json
${{ runner.temp }}/effective-policy.json
${{ runner.temp }}/resolved-agentic-provenance.json
${{ runner.temp }}/opencode-response-diagnostics.json
retention-days: 14
if-no-files-found: ignore
6 changes: 3 additions & 3 deletions .github/workflows/opencode-issue-feedback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
steps:
# Check out before running repository-owned helper scripts. This is the
# trusted workflow revision for issue and reusable-workflow runs.
- uses: actions/checkout@v6
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false

Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
PY
echo "::notice::Resolved configuration written to job summary and artifact."

- uses: actions/setup-python@v6
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
if: steps.resolve.outputs.validate_only != 'true'
with:
python-version: '3.12'
Expand Down Expand Up @@ -321,7 +321,7 @@ jobs:

- name: Upload resolved invocation artifact
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: resolved-invocation-issue-feedback
path: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/opencode-issue-implementation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
validate_only: ${{ steps.resolve.outputs.validate_only }}
steps:
# The resolver is stored in the caller repository checkout.
- uses: actions/checkout@v6
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false

Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:

- name: Upload resolved invocation artifact
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: resolved-invocation-issue-implementation
path: ${{ runner.temp }}/resolved-invocation.json
Expand All @@ -190,12 +190,12 @@ jobs:
ISSUE: ${{ needs.select-issue.outputs.issue }}
DRY_RUN: ${{ needs.select-issue.outputs.dry_run }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: true
fetch-depth: 0

- uses: actions/setup-python@v6
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.12'

Expand Down Expand Up @@ -664,7 +664,7 @@ jobs:

- name: Upload provenance artifact
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: resolved-configuration-issue-implementation
path: |
Expand Down
56 changes: 33 additions & 23 deletions .github/workflows/verify-reusable-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,35 @@ jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false

- uses: actions/setup-python@v6
- name: Install UV
uses: astral-sh/setup-uv@d0d8abe699bfb85fec6de9f7adb5ae17292296ff # v6
with:
python-version: '3.12'
enable-cache: true
cache-dependency-glob: pyproject.toml

- name: Install validation dependencies
run: python3 -m pip install --disable-pip-version-check PyYAML
- name: Sync development dependencies
run: uv sync --extra dev

- name: Lint with ruff
run: uv run ruff check scripts tests

- name: Validate workflow YAML
run: |
set -euo pipefail
python3 - <<'PY'
uv run python - <<'PY'
import sys
from pathlib import Path
import yaml
files = [
".github/workflows/opencode-review.yml",
".github/workflows/opencode-documentation-review.yml",
".github/workflows/opencode-issue-feedback.yml",
".github/workflows/opencode-issue-implementation.yml",
".github/workflows/verify-reusable-workflows.yml",
"docs/examples/opencode-review.yml",
"docs/examples/opencode-documentation-review.yml",
"docs/examples/opencode-issue-feedback.yml",
"docs/examples/opencode-issue-implementation.yml",
]
Expand All @@ -68,30 +73,35 @@ jobs:
- name: Compile all scripts
run: |
set -euo pipefail
python3 -m py_compile scripts/*.py
uv run python -m py_compile scripts/*.py

- name: Install OpenCode for schema smoke checks
run: npm install -g opencode-ai@1.18.16

- name: Run unit tests (includes real OpenCode smoke when binary present)
run: |
python3 -m unittest discover -s tests -v
uv run python -m unittest discover -s tests -v

- name: Verify bundle hashes are up to date
run: |
set -euo pipefail
uv run scripts/update_hashes.py --dry-run

- name: Exercise resolver in validate_only mode
run: |
set -euo pipefail
python3 scripts/resolve_invocation.py \
uv run python scripts/resolve_invocation.py \
--workflow pr-documentation-review \
--configuration-profile documentation-review \
--target-number 1 \
--validate-only true \
--result "$RUNNER_TEMP/pr-review.json"
python3 scripts/resolve_invocation.py \
uv run python scripts/resolve_invocation.py \
--workflow issue-feedback \
--configuration-profile issue-feedback \
--validate-only true \
--result "$RUNNER_TEMP/issue-feedback.json"
python3 scripts/resolve_invocation.py \
uv run python scripts/resolve_invocation.py \
--workflow issue-implementation \
--configuration-profile default-implementation \
--target-number 1 \
Expand All @@ -101,7 +111,7 @@ jobs:
- name: Confirm resolver rejects invalid inputs
run: |
set +e
python3 scripts/resolve_invocation.py \
uv run python scripts/resolve_invocation.py \
--workflow pr-documentation-review \
--configuration-profile 'Bad Profile' \
--target-number 1
Expand All @@ -115,7 +125,7 @@ jobs:
- name: Confirm resolver rejects mutable ref
run: |
set +e
python3 scripts/resolve_invocation.py \
uv run python scripts/resolve_invocation.py \
--workflow pr-documentation-review \
--configuration-profile documentation-review \
--configuration-ref main \
Expand All @@ -130,7 +140,7 @@ jobs:
- name: Resolve and validate every local bundle
run: |
set -euo pipefail
python3 - <<'PY'
uv run python - <<'PY'
import json, sys, tempfile
from pathlib import Path
import importlib.util
Expand Down Expand Up @@ -179,7 +189,7 @@ jobs:
- name: Validate changed-path enforcement includes untracked files
run: |
set -euo pipefail
python3 - <<'PY'
uv run python - <<'PY'
import importlib.util, sys, tempfile, subprocess
from pathlib import Path
spec = importlib.util.spec_from_file_location(
Expand Down Expand Up @@ -207,7 +217,7 @@ jobs:
- name: Validate model profiles and policy escalation rejection
run: |
set -euo pipefail
python3 - <<'PY'
uv run python - <<'PY'
import importlib.util
import sys
spec = importlib.util.spec_from_file_location(
Expand Down Expand Up @@ -238,7 +248,7 @@ jobs:
- name: Validate prompt composition and injection delimiter behaviour
run: |
set -euo pipefail
python3 - <<'PY'
uv run python - <<'PY'
import importlib.util
import sys
spec = importlib.util.spec_from_file_location(
Expand Down Expand Up @@ -275,7 +285,7 @@ jobs:
- name: Validate provenance redaction and v1/v2 marker behaviour
run: |
set -euo pipefail
python3 - <<'PY'
uv run python - <<'PY'
import importlib.util
import sys
spec = importlib.util.spec_from_file_location(
Expand Down Expand Up @@ -316,7 +326,7 @@ jobs:
- name: Confirm configuration rejects traversal and bad hashes
run: |
set +e
python3 scripts/agentic_configuration.py \
uv run python scripts/agentic_configuration.py \
--workflow pr-documentation-review \
--bundle-root .opencode/configuration \
--configuration-profile '../escape'
Expand All @@ -330,7 +340,7 @@ jobs:
- name: Parse every JSON bundle/policy/contract file
run: |
set -euo pipefail
python3 - <<'PY'
uv run python - <<'PY'
import json
from pathlib import Path
for path in Path(".opencode/configuration").rglob("*.json"):
Expand All @@ -340,7 +350,7 @@ jobs:

- name: Upload validation artifacts
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: reusable-workflow-validation
path: |
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
__pycache__/
*.py[cod]
*.py[cod]

# UV / Python tooling
.ruff_cache/
File renamed without changes.
49 changes: 41 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@ Thanks for contributing to `generic-agentic-workflows`.

1. Create a branch from the current default branch.
2. Keep changes focused; do not mix workflow, agent, and dependency changes unless they are required together.
3. Run the relevant tests before opening a pull request:
3. Install [UV](https://docs.astral.sh/uv/) and sync the development environment:

```text
python3 -m unittest
uv sync --extra dev
```

4. Run `git diff --check` to catch whitespace errors.
5. Describe the behavior change, the configuration bundles affected, and validation performed in the pull request.
4. Run the linter and the relevant tests before opening a pull request:

```text
uv run ruff check scripts tests
uv run python -m unittest discover -s tests -v
```

Do not pass a shell glob such as `tests/*` to `unittest`. Python creates
`tests/__pycache__/` during test runs, and shell expansion can pass that
directory to `unittest` as though it were a test module. Use discovery so
test selection is independent of generated bytecode directories.

5. Run `git diff --check` to catch whitespace errors.
6. Describe the behavior change, the configuration bundles affected, and validation performed in the pull request.

## Editing OpenCode configuration bundles

Expand All @@ -35,7 +47,27 @@ Do not introduce credentials, endpoints, headers, or caller-controlled model ide

## Updating `hashes.json`

From the repository root, calculate SHA-256 values for every edited bundle content file:
Every content edit must update the corresponding SHA-256 hash in the bundle's `hashes.json`. Use the bundled helper script to recompute hashes automatically for one or more bundles:

```text
uv run scripts/update_hashes.py
```

Update a single profile:

```text
uv run scripts/update_hashes.py --profile documentation-review
```

Preview the changes without writing (`--dry-run`):

```text
uv run scripts/update_hashes.py --dry-run
```

The script reuses the resolver's own hashing and path-normalization helpers, so the digests it writes are byte-for-byte identical to what `scripts/agentic_configuration.py` validates at runtime. It only hashes files declared in `bundle.json` (`agent_file`, `skill_files`, `additional_agent_files`, and `prompt_template`); it never hashes `bundle.json` itself.

To compute a digest manually (for example, when verifying a single file), run:

```text
sha256sum .opencode/configuration/<profile>/agent.md
Expand All @@ -60,13 +92,13 @@ Do not hash `manifest.json` into `hashes.json` unless the resolver is explicitly
Resolve each changed bundle directly before opening a pull request:

```text
python3 scripts/agentic_configuration.py \
uv run python scripts/agentic_configuration.py \
--workflow pr-documentation-review \
--bundle-root .opencode/configuration \
--configuration-profile documentation-review \
--result /tmp/documentation-review.json

python3 scripts/agentic_configuration.py \
uv run python scripts/agentic_configuration.py \
--workflow issue-feedback \
--bundle-root .opencode/configuration \
--configuration-profile issue-feedback \
Expand All @@ -76,7 +108,8 @@ python3 scripts/agentic_configuration.py \
Use the appropriate workflow and profile for other bundles, such as `issue-implementation` and `default-implementation`. Then run the focused configuration and policy tests:

```text
python3 -m unittest -q \
uv run ruff check scripts tests
uv run python -m unittest -q \
tests.test_agentic_policy \
tests.test_agentic_configuration \
tests.test_revision2
Expand Down
12 changes: 12 additions & 0 deletions docs/plans/fix-line-number-feedback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Fix line number feedback

When reviewing https://github.com/SecondSkoll/generic-agentic-workflows/pull/12 the review agent used vastly incorrect line numbers when providing additional feedback:

```
Additional feedback (CONTRIBUTING.md:287): This says to calculate hashes for every edited bundle content file, but the examples do not cover the additional agent files mentioned above. Please either include an example for those files or point contributors to the authoritative hash-generation procedure so the examples do not appear exhaustive.
Additional feedback (CONTRIBUTING.md:334): “Obsolete model identifiers” is not defined, so contributors cannot tell which identifiers they must search for or what source of truth to use. Name the deprecated values or link to the policy/test that defines this check.
Additional feedback (docs/plans/documentation.md:354): This description is too vague to orient readers, and the bullets below are not links or actionable plan items. Clarify the intended audience and indicate where each planned topic will be documented.
Additional feedback (docs/plans/documentation.md:363): “the opencode application in GitHub” is ambiguous and uses inconsistent capitalization. Name the specific GitHub integration or project being compared and state which security or operational properties this approach improves.
```

This issue should be investigated and resolved.
Loading
Loading