feat(git-tools): add git_repo_info tool with Forgejo repo metadata #36

Merged
lucas merged 2 commits from 29-add-git-repo-info-tool-local-repo-forgejo-metadata into main 2026-10-20 10:14:30 +02:00
Collaborator

Adds a read-only, parameterless git_repo_info tool. It returns the work-tree root, branch/detached state, HEAD, upstream and ahead/behind, plus a resolved default branch with its source (Forgejo API first, then the local refs/remotes/origin/HEAD). When origin is on the configured Forgejo instance, it also returns the repo's metadata: URLs, private/fork/archived/empty flags and the fork parent. A Forgejo API failure is reported under forgejo.error; the call still succeeds. buildForgejoTools now exposes its context, and buildGitTools takes it. The tool is allowed in Forgejo trigger sessions and listed in the git bash rule and orientation prompt. It also gets a dedicated web renderer (GitRepoInfoView) and three preview fixtures.

Decisions

  • ApiRepo.description is typed string | null (Forgejo may send null) and mapped with ?? "".
  • fullName falls back to owner/repo when the API omits full_name, because ApiRepo.full_name was already optional.
  • The tc-git-repo-info-forgejo-error fixture shows the realistic origin_head fallback rather than an unknown default branch.
  • One extra test covers a status-0 (network) failure, which reports the bare message.

Verification

  • bun test src/bridge/git-tools/repo-info.test.ts: 6 pass. Covers origin/HEAD only, Forgejo wins with metadata mapping, Forgejo 500 fallback, network error, unborn repo, and non-repo error.
  • bun test src/bridge src/forgejo/tools (server): 497 pass, 0 fail.
  • bun test src/lib/git-format.test.ts (web): 9 pass.
  • bun run typecheck (root): protocol, web and server all pass.
  • Not run: the manual live-session call and the visual check of the /preview fixtures.

Closes #29

Adds a read-only, parameterless `git_repo_info` tool. It returns the work-tree root, branch/detached state, HEAD, upstream and ahead/behind, plus a resolved default branch with its source (Forgejo API first, then the local `refs/remotes/origin/HEAD`). When origin is on the configured Forgejo instance, it also returns the repo's metadata: URLs, private/fork/archived/empty flags and the fork parent. A Forgejo API failure is reported under `forgejo.error`; the call still succeeds. `buildForgejoTools` now exposes its `context`, and `buildGitTools` takes it. The tool is allowed in Forgejo trigger sessions and listed in the git bash rule and orientation prompt. It also gets a dedicated web renderer (`GitRepoInfoView`) and three preview fixtures. ## Decisions - `ApiRepo.description` is typed `string | null` (Forgejo may send null) and mapped with `?? ""`. - `fullName` falls back to `owner/repo` when the API omits `full_name`, because `ApiRepo.full_name` was already optional. - The `tc-git-repo-info-forgejo-error` fixture shows the realistic `origin_head` fallback rather than an unknown default branch. - One extra test covers a status-0 (network) failure, which reports the bare message. ## Verification - `bun test src/bridge/git-tools/repo-info.test.ts`: 6 pass. Covers origin/HEAD only, Forgejo wins with metadata mapping, Forgejo 500 fallback, network error, unborn repo, and non-repo error. - `bun test src/bridge src/forgejo/tools` (server): 497 pass, 0 fail. - `bun test src/lib/git-format.test.ts` (web): 9 pass. - `bun run typecheck` (root): protocol, web and server all pass. - Not run: the manual live-session call and the visual check of the `/preview` fixtures. Closes #29
omp-deck force-pushed 29-add-git-repo-info-tool-local-repo-forgejo-metadata from c01ee6ab2c to cb7c7fe6dd 2026-10-20 10:09:19 +02:00 Compare
Author
Collaborator

Rebased onto main (f58cc74).

Conflicts resolved

  • git-tools/index.ts: combined main's commitEnv object and the new git_rebase tool with the forgejo parameter and buildRepoInfoTool.
  • git-bash-rule.ts, orientation-store.ts: the tool lists now name both git_repo_info and git_rebase, and keep main's updated wording about force-pushing after a rebase.

Integration check against main

  • in-process.ts merged cleanly. Both buildGitTools(cwd, forgejoCtx) callers sit inside the new wrapRebaseGate wrapper. git_repo_info is read-only, so the gate rightly leaves it ungated.
  • #35 trigger sessions run in per-artifact clones whose origin is the workspace's Forgejo URL, so the Forgejo context still resolves there. Those clones start on a detached HEAD with no local branches, which makes the tool's default-branch answer more useful in trigger sessions.
  • Idea mode: main added git_rebase to the blocklist. git_repo_info stays available.
  • New commit cb7c7fe: main now has docs/git-tools.md and CHANGELOG entries for the git tools. It adds git_repo_info to the tool table, the idea-mode note, the card list and the CHANGELOG, and updates the read-only tool comment in idea-mode-bridge.ts.

Verification

  • bun run typecheck: protocol, server and web pass.
  • bun test src/bridge src/forgejo (server): 627 pass, 0 fail.
  • bun test src/lib/git-format.test.ts (web): 9 pass.
  • Still not run: a live-session call and a visual check of the /preview fixtures.
Rebased onto `main` (f58cc74). **Conflicts resolved** - `git-tools/index.ts`: combined main's `commitEnv` object and the new `git_rebase` tool with the `forgejo` parameter and `buildRepoInfoTool`. - `git-bash-rule.ts`, `orientation-store.ts`: the tool lists now name both `git_repo_info` and `git_rebase`, and keep main's updated wording about force-pushing after a rebase. **Integration check against main** - `in-process.ts` merged cleanly. Both `buildGitTools(cwd, forgejoCtx)` callers sit inside the new `wrapRebaseGate` wrapper. `git_repo_info` is read-only, so the gate rightly leaves it ungated. - #35 trigger sessions run in per-artifact clones whose `origin` is the workspace's Forgejo URL, so the Forgejo context still resolves there. Those clones start on a detached HEAD with no local branches, which makes the tool's default-branch answer more useful in trigger sessions. - Idea mode: main added `git_rebase` to the blocklist. `git_repo_info` stays available. - New commit cb7c7fe: main now has `docs/git-tools.md` and CHANGELOG entries for the git tools. It adds `git_repo_info` to the tool table, the idea-mode note, the card list and the CHANGELOG, and updates the read-only tool comment in `idea-mode-bridge.ts`. **Verification** - `bun run typecheck`: protocol, server and web pass. - `bun test src/bridge src/forgejo` (server): 627 pass, 0 fail. - `bun test src/lib/git-format.test.ts` (web): 9 pass. - Still not run: a live-session call and a visual check of the `/preview` fixtures.
lucas approved these changes 2026-10-20 10:14:25 +02:00
lucas merged commit ef7a43851a into main 2026-10-20 10:14:30 +02:00
lucas deleted branch 29-add-git-repo-info-tool-local-repo-forgejo-metadata 2026-10-20 10:14:30 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lucas/omp-deck!36
No description provided.