Skip to content

Commit 142c344

Browse files
bschellenberger2600cursoragentcoderabbitai[bot]CodeRabbit
authored
Add JSON CLI bridge and Python/Java wrappers (#4)
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Follow-up (latest) - **Strict stdin JSON:** `parseRequest` now rejects multiple JSON values or trailing garbage after the first object (single-request protocol). - **Python `GIT_HARNESS_CLI`:** Bare names (e.g. `git-harness-cli`) are resolved with `shutil.which` before falling back to a path under the repo root, matching Java `ProcessBuilder` PATH behavior. - **Tests:** Added coverage for trailing JSON rejection and PATH-based `_cli_cmd` resolution. All inline review threads on this PR are resolved as of the latest push. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b5ff7da1-12de-491e-87e3-bdb30815a92e"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/background-agent?bcId=bc-b5ff7da1-12de-491e-87e3-bdb30815a92e"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * JSON CLI bridge plus Python and Java client libraries with runnable smoke samples for both languages; CLI can be prebuilt and configured via an environment variable. * **Documentation** * New polyglot spec, plan, checklist, and testkit READMEs describing layout, usage, validation, and quality criteria. * **Tests** * Added Python pytest and Java JUnit smoke/integration tests exercising end-to-end bridge behavior. * **Chores** * CI updated to validate spec-kit artifacts, build the CLI once, and run wrapper tests across Linux/macOS/Windows; updated ignore rules. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Ben Schellenberger <bschellenberger2600@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
1 parent 077af2d commit 142c344

32 files changed

Lines changed: 2254 additions & 10 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 144 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ permissions:
1010
contents: read
1111

1212
jobs:
13+
spec-kit-conformance:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Validate spec-kit artifact set
19+
run: |
20+
test -f testkit/.specify/memory/constitution.md
21+
test -f testkit/.specify/specs/001-polyglot-harness/spec.md
22+
test -f testkit/.specify/specs/001-polyglot-harness/plan.md
23+
test -f testkit/.specify/specs/001-polyglot-harness/tasks.md
24+
test -f testkit/.specify/specs/001-polyglot-harness/contracts/cli-protocol.json
25+
test -f testkit/.specify/specs/001-polyglot-harness/checklists/quality.md
26+
27+
- name: Validate spec-kit scaffold and status
28+
run: ./testkit/.specify/scripts/validate_specify.sh
29+
1330
test:
1431
runs-on: ubuntu-latest
1532
steps:
@@ -21,7 +38,7 @@ jobs:
2138
cache: true
2239

2340
- name: Check gofmt
24-
run: test -z "$(gofmt -l git safety)"
41+
run: test -z "$(gofmt -l git safety cmd)"
2542

2643
- name: Build
2744
run: go build ./...
@@ -31,3 +48,129 @@ jobs:
3148

3249
- name: Test
3350
run: go test -race -count=1 ./...
51+
52+
testkit:
53+
runs-on: ubuntu-latest
54+
needs: [spec-kit-conformance, test]
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- uses: actions/setup-go@v5
59+
with:
60+
go-version-file: go.mod
61+
cache: true
62+
63+
- name: Build git-harness CLI binary once
64+
run: |
65+
mkdir -p bin
66+
go build -o ./bin/git-harness-cli ./cmd/git-harness-cli
67+
68+
- uses: actions/setup-python@v5
69+
with:
70+
python-version: "3.12"
71+
72+
- uses: actions/setup-java@v4
73+
with:
74+
distribution: temurin
75+
java-version: "21"
76+
cache: maven
77+
78+
- name: Run Python wrapper tests
79+
env:
80+
GIT_HARNESS_CLI: ./bin/git-harness-cli
81+
run: |
82+
cd testkit/python
83+
python -m pip install -e ".[dev]"
84+
python -m pytest tests/ -v
85+
86+
- name: Run Python sample smoke implementations
87+
env:
88+
GIT_HARNESS_CLI: ./bin/git-harness-cli
89+
run: |
90+
cd testkit/python
91+
python -m samples.smoke_repo_flow
92+
python -m samples.smoke_safety_flow
93+
94+
- name: Run Java wrapper tests
95+
env:
96+
GIT_HARNESS_CLI: ./bin/git-harness-cli
97+
run: |
98+
cd testkit/java
99+
mvn test
100+
101+
- name: Run Java sample smoke implementations
102+
env:
103+
GIT_HARNESS_CLI: ./bin/git-harness-cli
104+
run: |
105+
cd testkit/java
106+
mvn -Dtest=SampleRepoFlowSmoke,SampleSafetyFlowSmoke test
107+
108+
wrapper-cross-platform:
109+
runs-on: ${{ matrix.os }}
110+
needs: [spec-kit-conformance, test]
111+
strategy:
112+
fail-fast: false
113+
matrix:
114+
# Linux wrapper path is covered by the `testkit` job; matrix only cross-checks macOS + Windows.
115+
os: [macos-latest, windows-latest]
116+
steps:
117+
- uses: actions/checkout@v4
118+
119+
- uses: actions/setup-go@v5
120+
with:
121+
go-version-file: go.mod
122+
cache: true
123+
124+
- name: Build git-harness CLI binary once
125+
shell: bash
126+
run: |
127+
mkdir -p bin
128+
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
129+
go build -o ./bin/git-harness-cli.exe ./cmd/git-harness-cli
130+
else
131+
go build -o ./bin/git-harness-cli ./cmd/git-harness-cli
132+
fi
133+
134+
- uses: actions/setup-python@v5
135+
with:
136+
python-version: "3.12"
137+
138+
- uses: actions/setup-java@v4
139+
with:
140+
distribution: temurin
141+
java-version: "21"
142+
cache: maven
143+
144+
- name: Run Python wrapper smoke tests
145+
shell: bash
146+
env:
147+
GIT_HARNESS_CLI: ${{ matrix.os == 'windows-latest' && './bin/git-harness-cli.exe' || './bin/git-harness-cli' }}
148+
run: |
149+
cd testkit/python
150+
python -m pip install -e ".[dev]"
151+
python -m pytest tests/ -v
152+
153+
- name: Run Python sample smoke implementations
154+
shell: bash
155+
env:
156+
GIT_HARNESS_CLI: ${{ matrix.os == 'windows-latest' && './bin/git-harness-cli.exe' || './bin/git-harness-cli' }}
157+
run: |
158+
cd testkit/python
159+
python -m samples.smoke_repo_flow
160+
python -m samples.smoke_safety_flow
161+
162+
- name: Run Java wrapper smoke tests
163+
shell: bash
164+
env:
165+
GIT_HARNESS_CLI: ${{ matrix.os == 'windows-latest' && './bin/git-harness-cli.exe' || './bin/git-harness-cli' }}
166+
run: |
167+
cd testkit/java
168+
mvn test
169+
170+
- name: Run Java sample smoke implementations
171+
shell: bash
172+
env:
173+
GIT_HARNESS_CLI: ${{ matrix.os == 'windows-latest' && './bin/git-harness-cli.exe' || './bin/git-harness-cli' }}
174+
run: |
175+
cd testkit/java
176+
mvn -Dtest=SampleRepoFlowSmoke,SampleSafetyFlowSmoke test

‎.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
# Local reference clones (not part of this module)
22
/mnt/
3+
4+
# testkit (polyglot) build artifacts
5+
testkit/python/**/__pycache__/
6+
testkit/python/**/*.egg-info/
7+
testkit/python/.pytest_cache/
8+
testkit/java/target/

‎CURSOR_ULTRA_PLAN.md‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,10 @@ git-harness/
113113
.github/
114114
workflows/
115115
ci.yml # Go build + test + vet
116-
wrappers/ # placeholder dirs for Phase 5 & 6
116+
testkit/ # polyglot layout (mirror git-testkit)
117117
python/
118-
.gitkeep
119118
java/
120-
.gitkeep
119+
.specify/
121120
```
122121

123122
> **Local wiring (temporary):** Add `replace github.com/git-fire/git-harness => ../git-harness`
@@ -170,11 +169,11 @@ Commit: `refactor(git-harness): remove extracted internals from companion CLI`
170169
> Follow git-testkit's Python wrapper structure exactly. Read it before writing anything here.
171170
172171
### 5.1 Scaffold
173-
Mirror whatever structure git-testkit uses under `wrappers/python/`. This likely means:
174-
- A Python package under `wrappers/python/git_harness/`
172+
Mirror whatever structure git-testkit uses under `testkit/python/`. This likely means:
173+
- A Python package under `testkit/python/git_harness/`
175174
- Build tooling (cffi, ctypes, subprocess bridge, or whatever git-testkit uses)
176175
- `pyproject.toml` / `setup.py`
177-
- `wrappers/python/README.md`
176+
- `testkit/python/README.md`
178177

179178
### 5.2 Implement
180179
Expose the same surface area as the Go module — subprocess runner, safety/sanitize, repo introspection.
@@ -198,10 +197,10 @@ Commit: `feat(git-harness): Python wrapper`
198197
> Follow git-testkit's Java wrapper structure exactly. Read it before writing anything here.
199198
200199
### 6.1 Scaffold
201-
Mirror whatever structure git-testkit uses under `wrappers/java/`. Likely:
202-
- Maven or Gradle project under `wrappers/java/`
200+
Mirror whatever structure git-testkit uses under `testkit/java/`. Likely:
201+
- Maven or Gradle project under `testkit/java/`
203202
- `src/main/java/io/gitfire/harness/`
204-
- `wrappers/java/README.md`
203+
- `testkit/java/README.md`
205204

206205
### 6.2 Implement
207206
Expose the same surface area as the Go module.

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Go library extracted from [git-fire](https://github.com/git-fire/git-fire): subp
99
- **`git`** — repository scanning, status, commits, pushes, worktrees, and related helpers.
1010
- **`safety`** — redaction and secret-pattern scanning helpers used by git error paths.
1111

12+
## Polyglot wrappers
13+
14+
Python and Java clients use the same layout as [git-testkit](https://github.com/git-fire/git-testkit) under **`testkit/`**: build `cmd/git-harness-cli`, set **`GIT_HARNESS_CLI`** to that binary (or rely on `go run ./cmd/git-harness-cli` from the repo root). Code lives in `testkit/python` and `testkit/java`; runnable samples are `testkit/python/samples/` and the Java `Sample*Smoke` tests.
15+
1216
## Requirements
1317

1418
- Go **1.24**+ (see `go.mod`).

0 commit comments

Comments
 (0)