Repository navigation
fix(tests): restore real plugin discovery coverage, drop CI adapter exclusion #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
79ee02f
90ac999
0fadc9c
fa3e6f8
e1c09e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| ## What kind of change is this? | ||
|
|
||
| - [ ] bug fix | ||
| - [ ] bug fix + test | ||
| - [ ] feature | ||
| - [ ] refactor / cleanup | ||
| - [ ] docs / comments | ||
| - [ ] test-only | ||
| - [ ] security fix | ||
|
|
||
| ## Summary | ||
|
|
||
| Briefly describe the change and why it is needed. | ||
|
|
||
| ## Branch | ||
|
|
||
| This PR was opened from a branch using one of: | ||
| - `fix/…` | ||
| - `bugs/…` | ||
| - `feature/…` | ||
|
|
||
| ## Checklist | ||
|
|
||
| - [ ] Tests pass: `python -m pytest -q` | ||
| - [ ] `verify.py` is green | ||
| - [ ] No raw tokens/secrets in code, logs, or tool output | ||
| - [ ] Adapter stays loopback-only unless an explicit guard is added | ||
| - [ ] Updated docs/README if user-facing behavior changed |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: PR auto-label by branch prefix | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| jobs: | ||
| label: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| steps: | ||
| - uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const branch = context.payload.pull_request.head.ref | ||
| const labels = { | ||
| 'fix/': 'bug', | ||
| 'bugs/': 'bug', | ||
| 'feature/': 'enhancement' | ||
| } | ||
| const mapping = Object.entries(labels).find(([prefix]) => branch.startsWith(prefix)) | ||
| if (!mapping) return | ||
| const [, label] = mapping | ||
| await github.rest.issues.addLabels({ | ||
| ...context.repo, | ||
| issue_number: context.issue.number, | ||
| labels: [label] | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,9 @@ | |
| # compatible adapter (adapter.py, launched by register()) that translates to | ||
| # Amazon Q. This script adds the providers: builder entry pointing at that | ||
| # adapter (localhost :8077) — NO :8088 bridge daemon, no orphaned ref. | ||
| # It ALSO adds builder to plugins.enabled so the plugin module loads and | ||
| # register() actually starts the adapter. Without both, the model picker | ||
| # shows a dead endpoint. | ||
| # | ||
| # SAFE: idempotent (skips if already present), always backs up config.yaml | ||
| # first. Does NOT touch any other provider. User-invoked (never auto-run by | ||
|
|
@@ -20,69 +23,112 @@ CONFIG="${HERMES_HOME:-$HOME/.hermes}/config.yaml" | |
| BACKUP="${CONFIG}.bak.$(date +%Y%m%d_%H%M%S)" | ||
| PORT="${AWS_BUILD_ADAPTER_PORT:-8077}" | ||
|
|
||
|
|
||
| if [[ ! -f "$CONFIG" ]]; then | ||
| echo "✗ config.yaml not found at $CONFIG" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Idempotency: already present? | ||
| if grep -qE '^[[:space:]]*builder:' "$CONFIG"; then | ||
| echo "✓ providers: builder already present in $CONFIG — nothing to do." | ||
| echo " Restart Hermes if you haven't since installing the plugin." | ||
| exit 0 | ||
| # Resolve a Python that has PyYAML. Prefer `python3` on PATH; fall back to | ||
| # the Hermes venv if the user's PATH is minimal. | ||
| PYTHON="$(command -v python3 || true)" | ||
| if [[ -z "$PYTHON" ]]; then | ||
|
Comment on lines
+33
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If system Python is on |
||
| # Try the Hermes venv under HERMES_HOME or ~/.hermes. | ||
| HM="${HERMES_HOME:-$HOME/.hermes}" | ||
| for candidate in \ | ||
| "$HM/hermes-agent/venv/bin/python3" \ | ||
| "$HM/venv/bin/python3"; do | ||
| if [[ -x "$candidate" ]]; then | ||
| PYTHON="$candidate" | ||
| break | ||
| fi | ||
| done | ||
| fi | ||
| if [[ -z "$PYTHON" ]]; then | ||
| echo "✗ python3 is required for config edits (install Python or add it to PATH)." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Backup | ||
| # Backup once | ||
| cp "$CONFIG" "$BACKUP" | ||
| echo "✓ backed up config → $BACKUP" | ||
|
|
||
| # Insert the block as a top-level providers: key, using Python | ||
| # (reliable indentation handling). Idempotent: only if absent. | ||
| # Write the block to a temp file (real newlines, not escaped). | ||
| # Resolve plugin root and manifest. | ||
| PLUGIN_DIR="${HERMES_HOME:-$HOME/.hermes}/plugins/builder" | ||
| PLUGIN_YAML="$PLUGIN_DIR/plugin.yaml" | ||
|
|
||
| # Write the provider block to a temp file. | ||
| # NOTE: model list is read from plugin.yaml at install time so setup.sh and | ||
| # backend.py cannot drift. key_env removed: the adapter does not need one. | ||
| BLOCK_FILE="$(mktemp)" | ||
| cat > "$BLOCK_FILE" <<EOF | ||
| builder: | ||
| name: AWS Builder ID | ||
| transport: openai_chat | ||
| base_url: http://127.0.0.1:${PORT}/v1 | ||
| key_env: AWS_BUILD_ADAPTER_DUMMY | ||
| models: | ||
| - auto | ||
| - claude-sonnet-4.5 | ||
| - claude-sonnet-4 | ||
| - claude-haiku-4.5 | ||
| EOF | ||
|
|
||
| python3 - "$CONFIG" "$BLOCK_FILE" <<'PY' | ||
| "$PYTHON" - "$PLUGIN_YAML" "$BLOCK_FILE" <<'PY' | ||
| import sys, yaml | ||
| from pathlib import Path | ||
| yaml_path = Path(sys.argv[1]) | ||
| block_path = Path(sys.argv[2]) | ||
| raw = yaml.safe_load(yaml_path.read_text()) or {} | ||
| models = raw.get("models") or [] | ||
| block = block_path.read_text() | ||
| if models: | ||
| for m in models: | ||
| block += f"\n - {m}" | ||
| else: | ||
| block += "\n - auto" | ||
| block_path.write_text(block) | ||
| PY | ||
|
|
||
| # 1) Insert providers: builder block (idempotent: Python exits 0 if already present) | ||
| "$PYTHON" - "$CONFIG" "$BLOCK_FILE" <<'PY' | ||
| import sys | ||
| cfg, blockfile = sys.argv[1], sys.argv[2] | ||
| block = open(blockfile).read().rstrip("\n") | ||
| lines = open(cfg).read().splitlines() | ||
| if any(l.strip() == "builder:" for l in lines): | ||
| sys.exit(0) # idempotent guard (shell already checked) | ||
| sys.exit(0) | ||
| # If no providers: block exists, insert one first. | ||
| if not any(l.strip() == "providers:" for l in lines): | ||
| lines.append("providers:") | ||
|
Comment on lines
+95
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new missing- |
||
| out, i, n, in_prov, done = [], 0, len(lines), False, False | ||
| while i < n: | ||
| out.append(lines[i]) | ||
| # We are inside the providers: block (set when we saw 'providers:' | ||
| # at col 0). Append the builder block once, right before the | ||
| # block closes (next line at col 0, or EOF). | ||
| if not done and in_prov and ( | ||
| i + 1 == n or (lines[i + 1] and not lines[i + 1].startswith(" ")) | ||
| ): | ||
| out.extend(block.splitlines()) | ||
| done = True | ||
| if lines[i] == "providers:": | ||
| if lines[i].strip() == "providers:": | ||
| in_prov = True | ||
| elif lines[i] and not lines[i].startswith(" ") and lines[i] != "providers:": | ||
| in_prov = False # left the providers block (next top-level key) | ||
| elif lines[i] and not lines[i].startswith(" ") and lines[i].strip() != "providers:": | ||
| in_prov = False | ||
| i += 1 | ||
| open(cfg, "w").write("\n".join(out) + "\n") | ||
| PY | ||
| rm -f "$BLOCK_FILE" | ||
|
|
||
| # 2) Ensure builder is in plugins.enabled (idempotent) | ||
| "$PYTHON" - "$CONFIG" <<'PY' | ||
| import sys | ||
| import yaml | ||
| cfg = sys.argv[1] | ||
| c = yaml.safe_load(open(cfg)) or {} | ||
| en = (c.get("plugins") or {}).get("enabled") or [] | ||
| if "builder" not in [str(x) for x in en]: | ||
| c.setdefault("plugins", {})["enabled"] = [str(x) for x in en] + ["builder"] | ||
| yaml.safe_dump(c, open(cfg, "w"), sort_keys=False, default_flow_style=False) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| print("added_builder_to_enabled") | ||
| else: | ||
| print("builder_already_enabled") | ||
| PY | ||
|
|
||
| if grep -qE '^[[:space:]]*builder:' "$CONFIG"; then | ||
| echo "✓ added providers: builder → http://127.0.0.1:${PORT}/v1 (transport: openai_chat)" | ||
| echo "✓ providers: builder → http://127.0.0.1:${PORT}/v1 (transport: openai_chat)" | ||
| echo "✓ NO :8088 bridge — adapter launches inside the plugin on register()." | ||
| echo | ||
| echo "NEXT: restart Hermes, then in TUI/CLI use '-m builder' or pick 'AWS Builder ID'." | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For normal fork PRs,
pull_requestsupplies a read-only token. Requestingpull-requests: writedoes not override that restriction. A fork branch namedfix/...orfeature/...therefore reachesaddLabelsand fails with a permission error. Usepull_request_targetfor this metadata-only job, without checking out or running PR code.