feat(plugin): resolve session project from git remote, not a pinned project_id #65

Merged
bvandeusen merged 1 commits from dev into main 2026-06-10 01:37:48 -04:00
Owner

Why

The plugin's SessionStart hook asked for a project_id via plugin userConfig — which pins a single install to one project. The operator works across many repos/projects, so that assumption was wrong. Resolve the active project server-side from the working repo's git remote instead (a stable identifier, not a dir-name guess).

What changed

  • repo_bindings table (migration 0064) + RepoBinding model — (user, repo_key) → project, FKs CASCADE.
  • services/repo_bindingsnormalize_repo_key collapses ssh/https/scp/creds/port/.git to host/owner/repo; resolve_project / set / list / delete.
  • GET /api/plugin/context?repo=<remote> — resolves the bound project; an unbound repo returns standing rules + a "bind this repo" hint with a ready bind_repo() call. project_id kept only as a manual override.
  • MCP toolsbind_repo / list_repo_bindings / unbind_repo.
  • Hook — sends ?repo=$(git remote get-url origin) URL-encoded; all project_id handling removed.
  • plugin.json — drops the project_id userConfig (0.1.2 → 0.1.3).
  • Tests — normalization equivalence classes + unbound-hint rendering.

Refs task 755 (Scribe-as-plugin push channel). CI green on dev (run 809).

Post-merge

Rebuild the instance (the running image predates /api/plugin/context), then bind this repo once: bind_repo("https://git.fabledsword.com/bvandeusen/FabledScribe.git", 2).

🤖 Generated with Claude Code

## Why The plugin's SessionStart hook asked for a `project_id` via plugin userConfig — which pins a single install to one project. The operator works across many repos/projects, so that assumption was wrong. Resolve the active project **server-side from the working repo's git remote** instead (a stable identifier, not a dir-name guess). ## What changed - **`repo_bindings` table** (migration `0064`) + `RepoBinding` model — `(user, repo_key) → project`, FKs CASCADE. - **`services/repo_bindings`** — `normalize_repo_key` collapses ssh/https/scp/creds/port/`.git` to `host/owner/repo`; `resolve_project` / `set` / `list` / `delete`. - **`GET /api/plugin/context?repo=<remote>`** — resolves the bound project; an unbound repo returns standing rules + a "bind this repo" hint with a ready `bind_repo()` call. `project_id` kept only as a manual override. - **MCP tools** — `bind_repo` / `list_repo_bindings` / `unbind_repo`. - **Hook** — sends `?repo=$(git remote get-url origin)` URL-encoded; all `project_id` handling removed. - **`plugin.json`** — drops the `project_id` userConfig (`0.1.2 → 0.1.3`). - **Tests** — normalization equivalence classes + unbound-hint rendering. Refs task 755 (Scribe-as-plugin push channel). CI green on `dev` (run 809). ## Post-merge Rebuild the instance (the running image predates `/api/plugin/context`), then bind this repo once: `bind_repo("https://git.fabledsword.com/bvandeusen/FabledScribe.git", 2)`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
bvandeusen added 1 commit 2026-06-10 01:37:40 -04:00
feat(plugin): resolve session project from git remote, not a pinned project_id
CI & Build / Python lint (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Successful in 51s
CI & Build / Build & push image (push) Successful in 1m0s
8fe571e175
The SessionStart hook asked for a project_id via plugin userConfig, which pins
one install to a single project — wrong for an operator working across many
repos/projects. Resolve the active project server-side from the working repo's
git remote instead (a stable identifier, not a dir-name guess).

- repo_bindings table (migration 0064) + RepoBinding model: (user, repo_key) ->
  project, FKs CASCADE.
- services/repo_bindings: normalize_repo_key collapses ssh/https/scp/creds/port/
  .git to host/owner/repo; resolve/set/list/delete.
- GET /api/plugin/context takes ?repo=<remote>; unbound repo -> a "bind this
  repo" hint with a ready bind_repo() call. project_id kept as manual override.
- MCP tools: bind_repo / list_repo_bindings / unbind_repo.
- Hook sends ?repo=$(git remote get-url origin) URL-encoded; all project_id
  handling removed. plugin.json drops the project_id userConfig (0.1.2 -> 0.1.3).
- Tests: normalize equivalence classes + unbound-hint rendering.

Refs task 755 (Scribe-as-plugin push channel).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bvandeusen merged commit 2c36249c15 into main 2026-06-10 01:37:48 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bvandeusen/FabledScribe#65