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
17 changes: 17 additions & 0 deletions .cursor/agents/ci-watcher.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: ci-watcher
description: >-
Waits for the current PR's CI and returns only the failing jobs with the
tail of their logs. Use after every push instead of watching runs in the
main thread.
model: composer-2.5[fast=false]
readonly: true
---

# ci-watcher

1. Run `gh pr checks --watch --fail-fast > /dev/null 2>&1 || true`, then
`gh pr checks`.
2. For each failing check, run `gh run view RUN_ID --log-failed | tail -n 80`.
3. Report PASS, or for each failure: the job name, the run URL and those 80
lines. No analysis, no fixes, never full logs.
36 changes: 36 additions & 0 deletions .cursor/agents/ci-workflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: ci-workflow
description: >-
Makes GitHub Actions workflow and dependabot.yml edits that the parent has
fully specified (SHA pins, timeouts, permissions, env indirection,
concurrency, branch filters). Not for designing new workflows or release
flows.
model: composer-2.5[fast=false]
---

# ci-workflow

Rules:

- Pin every action to a full 40-character commit SHA with an exact
`# vX.Y.Z` comment. Look the SHA up, never guess:
`gh api repos/OWNER/REPO/git/ref/tags/vX.Y.Z --jq .object`; if its type
is "tag", dereference with
`gh api repos/OWNER/REPO/git/tags/SHA --jq .object.sha`.
Reuse SHAs already pinned in this repo's other workflows.
- `runs-on: ubuntu-24.04`. `timeout-minutes` on every job.
- Workflow-level `permissions: {}` or `contents: read`; write scopes only on
the job that needs them.
- `persist-credentials: false` on checkout unless the job pushes.
- No `${{ }}` inside `run:`. Pass values through `env:` and quote them
("$VAR"). For a list: `read -r -a args <<< "$VAR"`, then
`cmd "${args[@]}"`.
- No `pull_request_target` or `workflow_run`.
- Do not change triggers, job names or the job graph unless told to.

Steps: make the edits, run `actionlint` and
`zizmor --offline .github/workflows`, and fix until both are clean for the
files you touched.

Report: changes per file, each SHA with its tag, and the actionlint and
zizmor output.
23 changes: 23 additions & 0 deletions .cursor/agents/lint-fixer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: lint-fixer
description: >-
Fixes findings from scripts/lint.sh (actionlint, zizmor, shellcheck, shfmt,
eslint) that need no design change. Use whenever scripts/lint.sh fails.
model: composer-2.5[fast=false]
---

# lint-fixer

You fix lint findings in this repo and nothing else.

1. Run `scripts/lint.sh`.
2. Fix each finding at its file:line with the smallest change that follows
AGENTS.md.
3. Never add disable comments, eslint-disable, ignore files or `|| true`. Never change
workflow triggers, permissions or the job graph to silence a finding. If a
finding needs a design change, stop and report it.
4. Rerun `scripts/lint.sh`. Stop when it passes or after 3 rounds.
5. Do not commit or push.

Report: each fix as file:line and rule, anything left and why, and the last
10 lines of `scripts/lint.sh` output.
1 change: 1 addition & 0 deletions .cursor/environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"install": "bash scripts/install-lint-tools.sh && npm ci"}
6 changes: 6 additions & 0 deletions .cursor/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": 1,
"hooks": {
"stop": [{ "command": ".cursor/hooks/lint-on-stop.sh", "loop_limit": 2 }]
}
}
18 changes: 18 additions & 0 deletions .cursor/hooks/lint-on-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Cursor stop hook: when scripts/lint.sh fails, send its output back to the
# agent as a follow-up. hooks.json caps the re-prompts with loop_limit.

set -euo pipefail

main() {
local output
if output="$(scripts/lint.sh 2>&1 </dev/null)"; then
echo '{}'
return
fi
python3 -c 'import json, sys
print(json.dumps({"followup_message": "scripts/lint.sh failed:\n" + sys.stdin.read()[-4000:]}))' \
<<<"${output}"
}

main "$@"
35 changes: 33 additions & 2 deletions .github/workflows/proxy_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# under Settings → Secrets and variables → Actions, then mark this workflow as a required
# status check under branch protection (pull_request events only receive secrets for PRs
# from the same repository, not from forks).
# - lint: scripts/lint.sh
# Runners are ubuntu-24.04. Do not switch these jobs to ubuntu-latest.

name: Proxy integration tests

Expand All @@ -10,12 +12,15 @@ on:

permissions:
contents: read
# Required for setup-node npm cache save under restricted GITHUB_TOKEN scopes.
actions: write

jobs:
integration:
runs-on: ubuntu-24.04
timeout-minutes: 30
# Required for setup-node npm cache save under restricted GITHUB_TOKEN scopes.
permissions:
contents: read
actions: write

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -55,3 +60,29 @@ jobs:
env:
PROXY_URL: ${{ secrets.PROXY_URL }}
run: npm run test:ts

lint:
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "22"
cache: npm

- name: Install dependencies
run: npm ci

- name: Install lint tools
run: bash scripts/install-lint-tools.sh

- name: Lint
run: scripts/lint.sh
73 changes: 73 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Agent instructions

Read `.cursor/rules/github-actions.mdc` for workflow SHA pins and Node 24 action majors.

## Checks (run before every push)

- `scripts/lint.sh` must pass. CI runs the same command. Tools come from
`scripts/install-lint-tools.sh` plus `npm ci` for eslint; never download
linters yourself.
- Unit tests: `npm run test:unit && npm run test:types`.
- Integration tests need `PROXY_URL`: `npm test` and `npm run test:ts`.
- Prove it works: paste the command and its output for any behavior you
claim. CI green alone is not proof.

## Context and CI

- Never print full CI logs or whole large files.
- For the same edit in several places, write and run a small script
(sed, node) instead of many single edits, and show the script.
- Rewrite a file in one edit when you change most of it.

## Subagents

- After each push: use `ci-watcher` for CI; use `lint-fixer` when
`scripts/lint.sh` fails; use `ci-workflow` only for fully specified
workflow edits.
- Launch subagents only on composer-2.5 (standard speed) or grok-4.7.
No screenshots or computer use unless the task asks.

## Code standards

- Follow idiomatic JavaScript for this repo (ES modules, Node 18+). Run the
repo linters and fix everything.
- Imports at the top of the module. No imports inside functions or class bodies
unless a dynamic import is required for optional peers.
- Simple, direct code. No defensive scaffolding for APIs that exist in every
supported version. Tests and CI catch breakage.
- DRY with judgment: reuse existing helpers, no duplicate helpers, no thin
wrappers, no single-caller helpers extracted for neatness, no dead code.
Grep for unused functions before finishing.
- Match existing patterns and naming in the repo; smallest diff that does the
job. Do not reformat or restructure unrelated code.
- Use standard linters and tools instead of writing custom checkers or dev
servers.
- Shell scripts follow the Google Shell Style Guide (`main`, `set -euo
pipefail`, quoted vars, errors to stderr) and pass shellcheck + shfmt
`-i 2 -ci`.
- Workflows: actions pinned to full SHAs with version comments,
`ubuntu-24.04`, read-only default permissions with write only where
needed, `persist-credentials: false` unless pushing, timeouts, no
`${{ }}` inside `run:`; pass actionlint and zizmor.
- CI: extend existing workflows before adding new ones. A new workflow
must justify itself in the PR body and stay small.
- One concern per PR, ideally under ~400 changed lines. Say what you would
split if it is bigger.
- Before finishing, re-read your full diff as a strict reviewer and fix
anything this list would flag. Report per-file line counts.

## Rules and what enforces them

| Rule | Enforced by |
| --- | --- |
| Workflows pass actionlint | `scripts/lint.sh`, CI lint job |
| Scoped permissions, no dangerous triggers | zizmor in `scripts/lint.sh` |
| No `${{ }}` in `run:` | zizmor in `scripts/lint.sh` |
| Shell scripts pass shellcheck and shfmt | `scripts/lint.sh` (style: review) |
| JavaScript passes eslint | `npm run lint` in `scripts/lint.sh` |
| Actions pinned to full SHAs | zizmor; SHA comment: review |
| Focused PRs under ~400 lines, no version bumps | review |

When a reviewer corrects the same mistake twice, add a check that fails on
it (lint rule, grep in `lint.sh`, or test) and add a row here. Docs-only
rules are for judgment calls nothing can check.
22 changes: 22 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import js from "@eslint/js";
import globals from "globals";

export default [
js.configs.recommended,
{
files: ["lib/**/*.js", "test/**/*.js"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
...globals.node,
},
},
rules: {
"no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" },
],
},
},
];
2 changes: 1 addition & 1 deletion lib/core/proxy-headers-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class ProxyHeadersAgent extends Agent {
if (this.onProxyConnect) {
try {
this.onProxyConnect(response.headers);
} catch (e) {
} catch (_e) {
// Ignore callback errors
}
}
Expand Down
38 changes: 37 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@
}
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"axios": "^1.7.0",
"eslint": "^10.0.3",
"globals": "^16.5.0",
"got": "^16.0.0",
"ky": "^2.0.0",
"make-fetch-happen": "^16.0.1",
Expand Down
Loading