sid-harness 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. sid_harness/__init__.py +13 -0
  2. sid_harness/__main__.py +4 -0
  3. sid_harness/_native.py +1639 -0
  4. sid_harness/brave_proof.py +246 -0
  5. sid_harness/bridge.py +851 -0
  6. sid_harness/cli.py +937 -0
  7. sid_harness/client.py +161 -0
  8. sid_harness/companion.py +151 -0
  9. sid_harness/config.py +68 -0
  10. sid_harness/context/__init__.py +40 -0
  11. sid_harness/context/index.py +267 -0
  12. sid_harness/context/retrieval.py +74 -0
  13. sid_harness/editor.py +231 -0
  14. sid_harness/gateway.py +106 -0
  15. sid_harness/git_write.py +598 -0
  16. sid_harness/local_workspace.py +421 -0
  17. sid_harness/loop.py +394 -0
  18. sid_harness/lsp.py +598 -0
  19. sid_harness/policy/__init__.py +44 -0
  20. sid_harness/policy/repo_policy.py +626 -0
  21. sid_harness/receipt.py +142 -0
  22. sid_harness/runner.py +468 -0
  23. sid_harness/selftest.py +149 -0
  24. sid_harness/session/__init__.py +33 -0
  25. sid_harness/session/bounds.py +140 -0
  26. sid_harness/session/diff_gate.py +93 -0
  27. sid_harness/session/session.py +427 -0
  28. sid_harness/session/store.py +88 -0
  29. sid_harness/tools/__init__.py +52 -0
  30. sid_harness/tools/mcp_client.py +285 -0
  31. sid_harness/tools/plan.py +138 -0
  32. sid_harness/tools/registry.py +159 -0
  33. sid_harness/tools/skills.py +185 -0
  34. sid_harness/tools/subagents.py +112 -0
  35. sid_harness/tui.py +96 -0
  36. sid_harness/workspace.py +107 -0
  37. sid_harness-0.3.0.data/data/share/sid-harness/editors/README.md +46 -0
  38. sid_harness-0.3.0.data/data/share/sid-harness/editors/vscode/README.md +32 -0
  39. sid_harness-0.3.0.data/data/share/sid-harness/editors/vscode/extension.js +395 -0
  40. sid_harness-0.3.0.data/data/share/sid-harness/editors/vscode/package.json +120 -0
  41. sid_harness-0.3.0.dist-info/METADATA +229 -0
  42. sid_harness-0.3.0.dist-info/RECORD +45 -0
  43. sid_harness-0.3.0.dist-info/WHEEL +5 -0
  44. sid_harness-0.3.0.dist-info/entry_points.txt +2 -0
  45. sid_harness-0.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.4
2
+ Name: sid-harness
3
+ Version: 0.3.0
4
+ Summary: SID first-party local coding harness (CLI/TUI) — drives the SID native loop against SID's OpenAI-compatible /v1.
5
+ License: Proprietary
6
+ Project-URL: Homepage, https://superintelligencedog.com
7
+ Project-URL: Documentation, https://superintelligencedog.com/docs
8
+ Project-URL: Source, https://superintelligencedog.com
9
+ Keywords: sid,coding-agent,cli,harness
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Environment :: Console
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ Provides-Extra: publish
17
+ Requires-Dist: build>=1.2; extra == "publish"
18
+ Requires-Dist: twine>=6.0; extra == "publish"
19
+ Requires-Dist: sigstore>=3.0; extra == "publish"
20
+
21
+ # sid-harness — SID first-party local coding client (v1)
22
+
23
+ A small CLI/TUI client that runs a coding task through **SID's own native
24
+ loop** against SID's OpenAI-compatible `/v1`. Running a model on your desktop no
25
+ longer requires a third-party coding harness: SID *is* the harness.
26
+
27
+ - **One engine.** The loop, its four-tool contract, and its path denylist are
28
+ the gateway's `app/native_agent.py`, vendored **verbatim** into the package as
29
+ `sid_harness/_native.py` — one loop, mirrored, and kept byte-identical by a
30
+ parity test. Never reimplemented.
31
+ - **One backend.** SID routes, meters, and caps every call under **your** key.
32
+ No aggregator, no other provider SDK.
33
+ - **One command.**
34
+
35
+ ```bash
36
+ sid setup # verify your key via /v1/me, save it, pick a dir
37
+ sid run --task "Fix the off-by-one in add()." --dir ./my-project
38
+ ```
39
+
40
+ Output: the workspace selection, the model + diff, the final response, and a
41
+ **run receipt** written to `<dir>/.sid/runs/<run_id>.json` (override with
42
+ `--receipt`). The CLI prints the receipt as a `file://` link.
43
+
44
+ ## Install / run
45
+
46
+ No third-party dependencies (stdlib only), and no monorepo checkout — the
47
+ package is self-contained. Either:
48
+
49
+ ```bash
50
+ pipx run --spec infra/sid-harness sid run --task "..." --dir ./proj # install + run
51
+ pipx install infra/sid-harness # or install the `sid` console script
52
+ pip install infra/sid-harness # plain pip works too
53
+ # or run straight from the tree:
54
+ python -m sid_harness run --task "..." --dir ./proj
55
+ ```
56
+
57
+ The loop ships in the package, so nothing under `infra/sid-gateway` is needed at
58
+ runtime. The one optional seam that does use the gateway is `--context`
59
+ (repo-scale retrieval over `app.rag`); it is discovered when a gateway checkout
60
+ is present and overridable with `SID_HARNESS_GATEWAY_PATH`. Every other command
61
+ works with no checkout.
62
+
63
+ ## First run
64
+
65
+ `sid setup` verifies the key against `GET /v1/me`, then writes
66
+ `~/.sid/config.json` (owner-only) with the key, base URL, and your default
67
+ project directory. Later commands read that file when the env var or flag is
68
+ absent, so `sid run --task "..."` works with no `export` and no `--dir`.
69
+ Override the location with `SID_CONFIG_PATH`.
70
+
71
+ ```bash
72
+ sid setup --dir ./my-project # non-interactive: key from SID_API_KEY
73
+ sid setup --api-key "<your-key>" --dir . # or pass it explicitly
74
+ ```
75
+
76
+ Maintainers publish the signed wheel with `scripts/publish_sid_harness.sh`
77
+ (Sigstore attestations via `twine upload --attestations`). Public install
78
+ commands are wired into the landing/docs pages only after the PyPI probe
79
+ returns 200; the commands above remain the source-tree install until then.
80
+
81
+ ## Commands
82
+
83
+ ```bash
84
+ sid run --task "<goal>" --dir <path> [--model auto] [--verify] [--write] [--json]
85
+ sid run ... --git-write [--git-branch NAME] [--git-message MSG] [--no-pr] # opt-in branch/commit/PR (SUB-95)
86
+ sid run ... --context [--context-k N] # prepend repo-scale retrieved context (SUB-55)
87
+ sid run ... --mcp "<server cmd>" # expose an MCP server's tools (SUB-56, repeatable)
88
+ sid run ... --bounds-config <file> # override loop bounds (SUB-58)
89
+ sid run ... --test-cmd "python -m pytest -q" # run the approved tests locally (SUB-80)
90
+ sid tui --dir <path> # interactive terminal loop, same engine
91
+ sid status --dir <path> [--diff] # local git/worktree status (read-only)
92
+ sid session start|resume|replay # durable local sessions (SUB-58)
93
+ sid tools [--mcp "<server cmd>"] [--json] # list the loop's tool contract
94
+ sid policy --dir <path> [--json] # show the platform worktree/gate policy
95
+ sid lsp [--dir <path>] # LSP: compiler diagnostics -> loop (SUB-96)
96
+ sid apply --dir <path> --receipt <p> [--approve] # apply an approved run receipt
97
+ sid editor install [--target-dir <p>] [--force] # one-command VS Code install
98
+ sid selftest [--receipt <path>] # one loop turn against a local stub endpoint
99
+ ```
100
+
101
+ Common options: `--base-url` (env `SID_BASE_URL`, default
102
+ `https://superintelligencedog.com/v1`), `--api-key` (env `SID_API_KEY`),
103
+ `--routing-profile` (default `agent`), `--criteria` / `--out-of-scope`
104
+ (repeatable), `--max-tokens`, `--reasoning-effort`, `--receipt`, `--quiet`.
105
+
106
+ `--verify` reviews the produced diff through the gateway's existing
107
+ `POST /v1/verify/patch` — the harness does not carry a second verify path.
108
+
109
+ `--write` applies the loop's changed files to the **real working tree**
110
+ (SUB-54). It is off by default (read-only). Deletions are never applied. Inside
111
+ the platform repo, a source write from the MAIN checkout is refused by the repo
112
+ policy (SUB-57), which delegates to the platform's own Gate 31.
113
+
114
+ `--git-write` is the explicit opt-in that finishes the coder loop (SUB-95):
115
+ create a branch (`--git-branch`, default `sid/<run_id>`), commit **only** the
116
+ files that `--write` applied, push that branch, and open a pull request with
117
+ `gh` (`--git-base`, `--no-pr` to skip). Each step asks for its own approval;
118
+ `--approve` pre-approves the steps for non-interactive use, and without a
119
+ terminal or `--approve` every step fails closed. The path hard-refuses
120
+ `main`/`master` (including sub-refs), never force-pushes, and the receipt's
121
+ `git_write` block names the branch, commit SHA, and PR URL. Without
122
+ `--git-write` the harness remains read-only and never commits or pushes.
123
+
124
+ `--test-cmd` is the human-approved test command (SUB-80). The CLI splits it into
125
+ an **argv list** and executes it with `subprocess` in the `--dir` root —
126
+ never through a shell. The runner must be allowlisted (`python -m pytest`,
127
+ `pytest`, `python -m unittest`, `npm test`, `yarn/pnpm test`, `cargo test`,
128
+ `go test`), argv may not point outside the workspace, and the run is bounded
129
+ (timeout + output capture). The receipt records `tests_executed`, the test
130
+ backend, exit code, and pass/fail. Nothing is committed or pushed.
131
+
132
+ ## What v1 is (and is not)
133
+
134
+ **Is:** a bounded workspace loaded from `--dir`, the existing native loop, SID as
135
+ the only model backend, and a written run receipt. As of SUB-54 the workspace is
136
+ a **local driver**: real file read/write (`--write`), real `git` **status/diff**
137
+ (read-only — `sid status`), worktree awareness (linked worktree vs main
138
+ checkout), and a `.gitignore` filter layered on the shared `native_agent._safe_path`
139
+ secret/VCS/dependency denylist. The receipt records the git block and the files
140
+ written.
141
+
142
+ **Also wired (SUB-55/56/57/58):** repo-scale **context** (`--context` indexes the
143
+ whole tree and prepends sanitized, data-boundaried retrieval — reuses the
144
+ gateway's `app.rag`), the **tool ecosystem** (`sid_harness.tools`: a registry
145
+ over the one loop, an MCP stdio/HTTP client, a skills loader, a plan/todo gate,
146
+ subagent fan-out — reachable via `sid run --mcp` and `sid tools`), **durable
147
+ sessions** (`sid session`), configurable **bounds** (`--bounds-config`), and
148
+ **repo policy** (a write from the platform MAIN checkout is refused).
149
+
150
+ **Tests (SUB-80):** with `--test-cmd`, the loop's `run_approved_tests` tool and
151
+ the final verification step execute the approved argv locally against the
152
+ workspace root; the receipt records backend/exit/passed and
153
+ `tests_executed: true`. Without an approved command the receipt stays
154
+ `tests_executed: false` — never a claim. By default the harness **never commits
155
+ and never pushes**; only the explicit `--git-write` opt-in branches, commits,
156
+ pushes a feature branch, and opens a PR (SUB-95), and it never touches
157
+ main/master.
158
+
159
+ ## Localhost bridge (for the web Studio)
160
+
161
+ The web Studio runs in a browser and cannot read your disk (Brave also blocks the
162
+ File System Access API by default). Claude Code / Codex / OpenCode avoid this by
163
+ running a local process with filesystem tools. The **desktop companion** is that
164
+ local process for the Studio, and it removes the old URL/token paste:
165
+
166
+ ```bash
167
+ # one click: starts the loopback bridge, then opens the Studio already paired
168
+ python -m sid_harness companion --dir C:\Users\jerry\JB # read-only
169
+ python -m sid_harness companion --dir C:\Users\jerry\JB --write # write available
170
+ # the Studio shows "Enable write access" until the user explicitly grants it
171
+ ```
172
+
173
+ The companion binds **127.0.0.1 only**, exchanges a per-launch pairing code (in
174
+ the URL fragment, never a server log) for the bearer token, and accepts browser
175
+ requests only from the SID origins. The workspace is fixed to `--dir`. The loop
176
+ reads the **real tree on demand** (`list_files` / `read_file`), not a snapshot.
177
+
178
+ Write mode is opt-in twice: `--write` makes it *available*, and the user then
179
+ clicks **Enable write access** in the Studio (a per-session grant). Applying a
180
+ change requires the exact proposal the bridge generated and the user reviewed:
181
+ the digest is bound, every path goes through the shared secret/VCS denylist plus
182
+ an atomic all-or-nothing write, and a receipt lands in
183
+ `~/.sid/bridge/receipts/apply_*.json`. Endpoints: `GET /health`; `POST /pair`,
184
+ `/grant-write`, `/revoke-write`, `/run` `{task, model?, test_argv?}` (with
185
+ `X-SID-Api-Key`), and `/apply` `{proposal_id, digest}`. The browser cannot choose
186
+ the model backend or run tests without the write grant.
187
+
188
+ Installers (Windows/macOS/Linux, private venv + login autostart) and the
189
+ sign/verify chain live in `install/`. `install/prove_brave_apply.py` drives the
190
+ whole pair → grant → run → review → apply path in real Brave headless and checks
191
+ the disk plus the receipt.
192
+
193
+ The Studio ships the client half: a **Local bridge** control in the composer
194
+ shows the paired workspace and read-only/write state; `pairFromLocation()` takes
195
+ the companion's one-click code from the URL fragment, a Chat turn routes to
196
+ `POST {url}/run`, and the receipt (model, tools, tests, diff, changed, final
197
+ response) plus the real workspace preview render in place. **Enable write
198
+ access** posts the explicit grant, and **Apply** posts the reviewed proposal id
199
+ and digest. It fails closed and names the reason when the bridge is unreachable
200
+ or the pairing is stale — there is no silent fallback to the remote gateway. The harness CLI (`sid run` /
201
+ `sid tui`) remains the full-parity product (including `--write`); the Studio's
202
+ bridge path is read-only.
203
+
204
+ ## Editor integration + LSP diagnostics (SUB-96)
205
+
206
+ The VS Code extension under `editors/vscode` is a thin client over this same
207
+ engine: **SID: Open Coding Session** runs `sid session start`, **Show Proposed
208
+ Diff** opens the receipt's diff, **Approve and Apply** calls `sid apply` (the
209
+ same `LocalWorkspace` + repo-policy write path), and **Attach Selection as
210
+ Context** prepends the editor selection to the next task.
211
+
212
+ ```bash
213
+ python -m sid_harness editor install # one command; reload VS Code
214
+ ```
215
+
216
+ `sid lsp` is the diagnostics server. It publishes real Python compiler
217
+ diagnostics (`compile`) on open/change/save and accepts diagnostics forwarded
218
+ from VS Code's other language servers through `sid/diagnostics`. The merged feed
219
+ is written to `<workspace>/.sid/diagnostics.json`; `sid run` and `sid session`
220
+ prepend a data-boundaried `COMPILER DIAGNOSTICS` block to the task and record
221
+ `diagnostics: {count, sources, path}` on the receipt. `--no-diagnostics` opts
222
+ out for one run. No model call, no tool contract, and no write path are added by
223
+ the LSP — it is a diagnostic source for the one loop.
224
+
225
+ ## Scope guards
226
+ - SID stays the only model backend (no aggregator).
227
+ - No new pricing surface; your plan's unit is unchanged.
228
+ - No reimplemented verify/scan — the harness calls the gateway's.
229
+ - No vendor/model name is hardcoded into a rule, script default, or gate.
@@ -0,0 +1,45 @@
1
+ sid_harness/__init__.py,sha256=FlZxkV9TKoN7s6DhHUfFTbBmKfDZCcqdYCiwBf0cKPY,567
2
+ sid_harness/__main__.py,sha256=0iDYjdmiXNBinFF23WUyotsdpA6wFKjoB5aw3esTSRg,83
3
+ sid_harness/_native.py,sha256=A77-vI0xreIKN_uZBi085DObrHyxKDDyTnus7newj8U,68450
4
+ sid_harness/brave_proof.py,sha256=iCi62RkqdCTxJALhN9gtKhdg6OCNdDIc1Y_GjiPU_mA,9081
5
+ sid_harness/bridge.py,sha256=PE1ooqyvGICjYZ5a67NSAkFhncL3rHh3YGOGs4WhW5g,34066
6
+ sid_harness/cli.py,sha256=l1-WTcwwycJEUpC65o_oouJRauW-OYjv6WcooWnCiRg,36362
7
+ sid_harness/client.py,sha256=Y80_4Vl82NtJhxGNILmm4PiVFm4Y4wJk9xE3P84c5mk,5816
8
+ sid_harness/companion.py,sha256=G2G7UtrK72_L07J4CVZ8tMjIfuNb05bepYPU61kxUao,5698
9
+ sid_harness/config.py,sha256=rNTEc6JysGFtVMfbSh8rZ4u8IXDg2se-5BscaHoMTrc,2064
10
+ sid_harness/editor.py,sha256=0TJs1puEju7IDdvAs52QQhY3M752Ebp5fREIbK798QE,8952
11
+ sid_harness/gateway.py,sha256=FQbkVK6SK4BFdvIlWZkiHllkzayVZuOe08iHa4SlR18,3535
12
+ sid_harness/git_write.py,sha256=RAvmvtz1Clx7S4Rf2AoVNyNQ2LDFX8wJq34SUhOrQsY,19720
13
+ sid_harness/local_workspace.py,sha256=oJegI9wg2uDl_buiiPFiD0V6bkExiABIzwtpH6g2o0M,15574
14
+ sid_harness/loop.py,sha256=RbLVTcLCY4gi7sJW1sH3gY9AoNSxhoAqnEWa9wq2-O0,14264
15
+ sid_harness/lsp.py,sha256=N6XaSVpjumzfowzKL9_8aoTWgV26ovp8MGTPSM-uPG8,22056
16
+ sid_harness/receipt.py,sha256=mV9pkex75jIGVgmvB_UpNjd8bQoyyyvPXQI-4ZyciLs,4899
17
+ sid_harness/runner.py,sha256=wbtgq-nO2-_bhzfNo96ADPiKq4LENn-rbhjKdersibY,17801
18
+ sid_harness/selftest.py,sha256=nJmAXgbHtM3TMQopVV6SJOOf4XB2L8e1wY31vFj2jrk,5607
19
+ sid_harness/tui.py,sha256=RN0-uepRr7dV7uY3HEK1Z1U6PrEWkuKLqmM-Bm9ZJHs,3840
20
+ sid_harness/workspace.py,sha256=Ck4DWzie27lDJIWwCfSIRCym5IORU95lKxtA2wj5JCQ,3904
21
+ sid_harness/context/__init__.py,sha256=dA2CZv300FFz-_C-r_rFWGyjH6zMEMkESqOML6d7GYk,1269
22
+ sid_harness/context/index.py,sha256=NSJrVHoNEmydWe2r_e3LwuLqCP-cLC7DX74rfO8qy7Y,8473
23
+ sid_harness/context/retrieval.py,sha256=GnZdwk8lu9Ocr4jPj24ysrel1SDFUGOIbjVcwqFt1BI,2674
24
+ sid_harness/policy/__init__.py,sha256=MzKWyCkW48d7-eVbT71dDO0A9TE0SaY7uHEYdO8Kf18,1071
25
+ sid_harness/policy/repo_policy.py,sha256=zhZKE6SYRqm1iQY0XLEZ9--Y7pFWi4z336vE90CdlqM,23556
26
+ sid_harness/session/__init__.py,sha256=3mdbZ3U2EwnrBJ92mJUSL8sUopgvFZ6GY3KWl2EB2os,1118
27
+ sid_harness/session/bounds.py,sha256=gfbR2UbJFaaSH9vuKltAArYF4bM9CBzA0j2RC0U4wgE,5064
28
+ sid_harness/session/diff_gate.py,sha256=hVD1VaVjIa2Wudmb1DyjD4Ai0GfC1ckf9GhvocPLVWg,2990
29
+ sid_harness/session/session.py,sha256=a4EmD9bQMfJYfCj-5yubZyETJZesqQv8l7q6A5p09zs,16541
30
+ sid_harness/session/store.py,sha256=GbVDuSJ95lu2Vq3KT5BCg1DB9UcY1yo_fKiOhKN4Gfc,3426
31
+ sid_harness/tools/__init__.py,sha256=a7mYMqt7QuQQWKFe_PQ9oA7Hmm3nZ-FDs22qoARYzEQ,1355
32
+ sid_harness/tools/mcp_client.py,sha256=nvrKxsbfe-c_7DLwzYBJ7SJmkoZOZuPBR--3WWoW9Gs,9897
33
+ sid_harness/tools/plan.py,sha256=L7iXbLZrGSuQx4IpzFbM3LFGIuO_tH7DEs9xfgmywso,4595
34
+ sid_harness/tools/registry.py,sha256=kN6YO4xOOEbbQScd9icjdixDH6q4ie7wtK2UjmbSxdY,5527
35
+ sid_harness/tools/skills.py,sha256=7u6RBvOO364h-DxHGngZBrRWpz6z7_O8hqNN7jre0zE,6054
36
+ sid_harness/tools/subagents.py,sha256=K7unNx69-yOGnMUVWa-M8mXyIPYiRoKMSzcy9C0x2Pw,3730
37
+ sid_harness-0.3.0.data/data/share/sid-harness/editors/README.md,sha256=QBjhYFY7K3XZNTXjuFamHwdFRfT1IB2paVpSJWBEuUk,1924
38
+ sid_harness-0.3.0.data/data/share/sid-harness/editors/vscode/README.md,sha256=pfYgIM2bYhFzJ9uY8gu00aMA8zJMYGDm872WAaWoP1Q,1157
39
+ sid_harness-0.3.0.data/data/share/sid-harness/editors/vscode/extension.js,sha256=p9Liief0ClCLvrusHe7iEBGrx-CeNHVzaZiCQkNM-MY,13062
40
+ sid_harness-0.3.0.data/data/share/sid-harness/editors/vscode/package.json,sha256=avz5s3B4O8ZStzfmtlkb1aCXBR7LEWc21Kmi25px-iI,3257
41
+ sid_harness-0.3.0.dist-info/METADATA,sha256=li4Nfu5fNYe7Y7lWi_MPSKB09xZVrxTXde5TZLc4Zrc,12604
42
+ sid_harness-0.3.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
43
+ sid_harness-0.3.0.dist-info/entry_points.txt,sha256=om_58K5b0llEOc8JbfNkK2a7eOlqtT6M7_WzSiWosJg,45
44
+ sid_harness-0.3.0.dist-info/top_level.txt,sha256=vOs5L6R4jm8sy8EXZrWCkBpWZxYaGUx5JmXj6gstfnM,12
45
+ sid_harness-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ sid = sid_harness.cli:main
@@ -0,0 +1 @@
1
+ sid_harness