sonar-agent-kit (sak)
Unofficial.
sonar-agent-kitis a community tool. It is not affiliated with, sponsored by, or endorsed by SonarSource. "SonarQube" and "SonarCloud" are trademarks of SonarSource S.A.
Read-only local CLI that lets AI coding agents fetch SonarQube CI results and reports without the token ever leaving the developer machine.
Status: 0.0.1 — M0–M3 complete: setup/auth/diagnostics, Sonar+GitHub data plane, local dashboard, security docs and wheel packaging.
Security posture
- Token never leaves the machine. Tokens live in the OS credential store — Windows Credential Manager (
sak/sonar-token,sak/github-token) or, on Linux, libsecret viasecret-tool— with environment variables as a documented fallback. The CLI reads them at runtime; they are never printed, logged, or passed as CLI arguments. - Read-only. The HTTP client only issues GET requests. There is no code path that can write to SonarQube.
- Zero new outbound connections. Hosts are allowlisted in the HTTP client: the configured SonarQube host and the configured CI host only. No telemetry.
- Zero runtime dependencies. Pure Python standard library; credential access goes through
ctypesdirectly toadvapi32. - Auditable.
sak auditprints the exact endpoints, hosts, HTTP methods, dependencies, and storage locations. Seedocs/SECURITY.mdfor the full approval package.
Install
pip install .\dist\sak-0.0.1-py3-none-any.whl # wheel from the shared drive / internal index
Python 3.9+; no runtime dependencies.
Platform support
| Platform | Token storage | Notes |
|---|---|---|
| Windows | Credential Manager (ctypes, no extra tools) |
Full support |
| Linux | libsecret via secret-tool (install libsecret-tools) |
Full support; falls back to SONAR_TOKEN/GITHUB_TOKEN when secret-tool is missing |
| macOS | None yet | Use the environment-variable fallback |
Container image (published from the release tag):
docker run --rm ghcr.io/therain2020/sonar-agent-kit:0.0.1 --version
docker run --rm -e SONAR_TOKEN -v "$PWD:/repo" -w /repo \
ghcr.io/therain2020/sonar-agent-kit:0.0.1 report --repo owner/name --pr 123
Linux quickstart:
sudo apt install libsecret-tools # Debian/Ubuntu; needs a running secret service
pip install ./dist/sonar_agent_kit-0.0.1-py3-none-any.whl
sak init && sak auth set sonar && sak doctor
Quickstart
sak init # interactive setup wizard
sak auth set sonar # reads token from stdin / hidden prompt
sak auth set github # optional: PAT (auto-detects gh CLI too)
sak doctor # environment check
sak audit # endpoint + dependency inventory
sak report --repo owner/name --pr 123 # joint CI + Sonar digest
sak serve # dashboard at http://127.0.0.1:8765
Non-interactive setup:
sak init --non-interactive --sonar-host https://sonar.internal `
--repo owner/name --project-key org:project --github-auth auto
Commands (0.0.1)
| Command | Purpose |
|---|---|
sak init |
Configure Sonar host, repo→project mapping, GitHub auth mode, dashboard port |
sak auth set sonar|github |
Store a token in the Windows Credential Manager |
sak auth status |
Show masked token status and source |
sak auth delete sonar|github |
Remove a stored token |
sak report --repo o/r --pr N [--json] [--full] [--no-cache] [--repo-path P] |
Joint CI + Sonar digest with code context from the local checkout |
sak project <key> [--branch B] [--json] [--no-cache] |
Quality gate, measures, unresolved issue count |
sak issues <key> [--type T] [--severity S] [--branch B] [--json] [--repo-path P] |
Unresolved issues with code context |
sak serve [--port 8765] |
Local read-only dashboard (127.0.0.1 only) |
sak audit [--json] |
Print endpoint/host/method/dependency inventory |
sak doctor |
Check config, credentials, gh availability, Sonar reachability |
Exit codes (report)
0 pass · 1 fail (Sonar check failure or quality gate ERROR) · 2 unknown: tool, network, or configuration error, or no analysis result (gate: NONE).
When no Sonar-related CI check exists, the quality gate is authoritative. Community Edition (no PR analysis) degrades automatically to project-wide queries and the report is marked degraded: true with a reason.
Issue code context
Issues alone (file:line) are hard to act on, so report and issues read a
few lines of real code (±3 by default, report.snippet_context) from the
local git working copy — no new network endpoint, no source upload.
The CLI validates the checkout first:
report: localHEADmust equal the analyzed PR commit, otherwiselocal.status = "mismatch"and the hint saysgit checkout <branch/commit>; no snippet is attached until the branch is switched.issues --branch: the current branch must match the--branchvalue.
The repository is found from --repo-path, then ci.local_repos[repo] in the
config, then by walking up from the current directory. Bounded snippets are
stored with the issue in the local history database and highlighted in the
dashboard's PR page.
Dashboard
sak serve renders a read-only dashboard from the local history database
(%LOCALAPPDATA%\sonar-agent-kit\history.db) populated by previous report
and project runs. It binds to 127.0.0.1 only, serves no JavaScript or
external assets, and sets Content-Security-Policy with inline styles only
(style-src 'self' 'unsafe-inline', script-src 'none').
Pages: overview (portfolio KPIs, pull request reports, projects), per-project
KPI tiles with deltas vs the previous snapshot, type/severity distribution
bars (exact counts from Sonar facets), the complete issue list with
server-side pagination (25/page), severity/type/search filters and per-file
drilldown pages that show the highlighted code, trends (inline SVG), and a
per-PR view using the same table. JSON mirrors at /api/projects,
/api/project/<key>, /api/pr/<owner>/<repo>/<n>; a print stylesheet makes
pages screenshot/report friendly.
For AI agents
Give the agent the exit-code contract, not the token: see docs/agent.md for
the CLAUDE.md snippet, and .claude/skills/sonar-report/SKILL.md for a sample
skill. Add sak to the agent's Bash allowlist (e.g. Bash(sak:*)).
Development
pip install pytest
python -m pytest # 62 tests, mock Sonar + GitHub servers, no network
python -m pip wheel . --no-deps --no-build-isolation -w dist
Layout: src/sak/ (core), tests/, docs/.
License
Apache-2.0 — see LICENSE.
Metadata
Release files for sonar-agent-kit 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sonar_agent_kit-0.0.1.tar.gz | 57.4 kB | Without provenance | Details for sonar_agent_kit-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sonar_agent_kit-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for sonar_agent_kit-0.0.1-py3-none-any.whl |
Total release size: 105.4 kB
Release files / sonar_agent_kit-0.0.1.tar.gz
| Download URL | sonar_agent_kit-0.0.1.tar.gz |
|---|---|
| Size | 57.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3c9855ce93c1e508991b02cac55dc26975ff468f8a3924db64b9a537b2000b2
|
|
BLAKE2b-256 checksum How to use checksums |
99df78fba4bf346b0cceacfd0e6c9eb23cc53a788bae6e86f59798fa0173db96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Release files / sonar_agent_kit-0.0.1-py3-none-any.whl
| Download URL | sonar_agent_kit-0.0.1-py3-none-any.whl |
|---|---|
| Size | 48.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
558f51b244718da7dcfa25af427dc218f17b457fb36f219a9a4512ef0ae0ed31
|
|
BLAKE2b-256 checksum How to use checksums |
73c225ca535d7e4f31d60fd400814a6de504b1e6218c33bf00816ef969b5c606
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Security for sonar-agent-kit 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.