feat(wiki): gitea_wiki cannot create/edit/delete pages although the Forgejo API supports it #10

Closed
opened 2026-10-23 17:44:32 +00:00 by dsh · 1 comment
Owner

Symptom

gitea_wiki is read-only: list and get only. There is no create, update or delete, so a wiki page cannot be written with the toolset — the only working path is cloning <repo>.wiki.git, committing and pushing.

Verbatim tool output for an attempted write (t14btw, 2026-10-23):

gitea_wiki failed: unknown action: create

Observed vs expected

  • Observed: unknown action — no way to create the first page, edit or delete one.
  • Expected: create/update/delete through the toolset, since the instance already exposes the API.

Instance capability (verified against /swagger.v1.json, Forgejo 17.0.0+gitea-1.22.0)

Method Path Body
POST /api/v1/repos/{owner}/{repo}/wiki/new CreateWikiPageOptions{title, content_base64, message}
PATCH /api/v1/repos/{owner}/{repo}/wiki/page/{pageName} same
DELETE /api/v1/repos/{owner}/{repo}/wiki/page/{pageName} —

This path was used successfully via a direct API call to publish pvlb-infra/t14-deeps/wiki/DSH-Bootcamp; only the tool is missing.

Root cause (checkout available)

  • lib/tool-defs/repos.js:63-76 — gitea_wiki definition: description "list, get"; parameters only action, pageName, limit, page, owner, repo — no title/content/message.
  • lib/handlers/repos.js:133-141 — handler implements only the list and get branches; everything else returns unknown action.
  • lib/gitea-client.js:609-619 — client exposes only listWikiPages() and getWikiPage(); no create/update/delete methods.

Proposed fix

  1. lib/gitea-client.js: add createWikiPage(owner, repo, {title, content, message}) (base64 content_base64), updateWikiPage(owner, repo, pageName, …) and deleteWikiPage(owner, repo, pageName) using the three endpoints.
  2. lib/tool-defs/repos.js: extend gitea_wiki with action: create|update|delete plus title, content, message parameters; keep list/get untouched.
  3. lib/handlers/repos.js: add the branches, routed through wrap(); use the house confirm: true pattern for delete.
  4. Handle the API naming quirk in the tool or document it: title T14-Setup-Guide created T14-Setup-Guide.-.md (URL /wiki/T14-Setup-Guide.-), while canonical pages are managed as <Page-Title>.md via git. Prefer writing well-formed file names.

Acceptance

  • create on a repo with an empty wiki returns ok: true and the page is readable via get/API (this also unblocks the scenario in #9).
  • update changes content; delete removes the page (with confirm: true).
  • Tests with a mocked fetch cover create/update/delete success and 401/403.
  • Existing list/get behaviour unchanged.
  • README/AGENTS tool table updated.

Duplicate check

Searched open + closed: #4 covers the read half (get returns OK); no issue exists for wiki writes. Not a duplicate.

Layer

Plugin/tool gap → dsh-gitea (correct repo).

## Symptom `gitea_wiki` is read-only: `list` and `get` only. There is no `create`, `update` or `delete`, so a wiki page cannot be written with the toolset — the only working path is cloning `<repo>.wiki.git`, committing and pushing. Verbatim tool output for an attempted write (t14btw, 2026-10-23): ``` gitea_wiki failed: unknown action: create ``` ## Observed vs expected - **Observed:** `unknown action` — no way to create the first page, edit or delete one. - **Expected:** create/update/delete through the toolset, since the instance already exposes the API. ## Instance capability (verified against `/swagger.v1.json`, Forgejo `17.0.0+gitea-1.22.0`) | Method | Path | Body | |---|---|---| | `POST` | `/api/v1/repos/{owner}/{repo}/wiki/new` | `CreateWikiPageOptions{title, content_base64, message}` | | `PATCH` | `/api/v1/repos/{owner}/{repo}/wiki/page/{pageName}` | same | | `DELETE` | `/api/v1/repos/{owner}/{repo}/wiki/page/{pageName}` | — | This path was used successfully via a direct API call to publish `pvlb-infra/t14-deeps/wiki/DSH-Bootcamp`; only the tool is missing. ## Root cause (checkout available) - `lib/tool-defs/repos.js:63-76` — `gitea_wiki` definition: description "list, get"; parameters only `action`, `pageName`, `limit`, `page`, `owner`, `repo` — no `title`/`content`/`message`. - `lib/handlers/repos.js:133-141` — handler implements only the `list` and `get` branches; everything else returns `unknown action`. - `lib/gitea-client.js:609-619` — client exposes only `listWikiPages()` and `getWikiPage()`; no create/update/delete methods. ## Proposed fix 1. `lib/gitea-client.js`: add `createWikiPage(owner, repo, {title, content, message})` (base64 `content_base64`), `updateWikiPage(owner, repo, pageName, …)` and `deleteWikiPage(owner, repo, pageName)` using the three endpoints. 2. `lib/tool-defs/repos.js`: extend `gitea_wiki` with `action: create|update|delete` plus `title`, `content`, `message` parameters; keep `list`/`get` untouched. 3. `lib/handlers/repos.js`: add the branches, routed through `wrap()`; use the house `confirm: true` pattern for `delete`. 4. Handle the API naming quirk in the tool or document it: title `T14-Setup-Guide` created `T14-Setup-Guide.-.md` (URL `/wiki/T14-Setup-Guide.-`), while canonical pages are managed as `<Page-Title>.md` via git. Prefer writing well-formed file names. ## Acceptance - [ ] `create` on a repo with an empty wiki returns `ok: true` and the page is readable via `get`/API (this also unblocks the scenario in #9). - [ ] `update` changes content; `delete` removes the page (with `confirm: true`). - [ ] Tests with a mocked `fetch` cover create/update/delete success and 401/403. - [ ] Existing `list`/`get` behaviour unchanged. - [ ] README/AGENTS tool table updated. ## Duplicate check Searched open + closed: #4 covers the read half (`get` returns `OK`); no issue exists for wiki writes. Not a duplicate. ## Layer Plugin/tool gap → `dsh-gitea` (correct repo).
dsh closed this issue 2026-10-23 22:40:34 +00:00
Author
Owner

Implemented in fbca62a (PR #15).

gitea_wiki now supports create, update and delete against the Forgejo 17 endpoints (POST /wiki/new, PATCH|DELETE /wiki/page/{pageName}), with the body base64-encoded, confirm: true required for delete, and 401/403 failures passed through.

The naming quirk is handled in the tool: list now prints Title (pageName: <slug>), and the description says to address pages by that slug. Live, an API-created Probe-Page got the slug Probe-Page.-; get/update/delete only work with that slug.

Live CRUD through the running plugin, on the empty ml-lab/tardits wiki (cleaned up afterwards):

  • create → Wiki page created: Probe-Page
  • list → Probe-Page (pageName: Probe-Page.-)
  • get → metadata + Last commit: 45edfa83 …
  • update → new commit 83a1d1d8 test(wiki): update probe
  • delete confirm: true → deleted; list → No wiki pages.

Tests: test/wiki.test.mjs covers create/update/delete, base64 encoding, 401/403, missing title/content, delete confirmation, and failure passthrough; npm test 60/60.

Implemented in `fbca62a` (PR #15). `gitea_wiki` now supports `create`, `update` and `delete` against the Forgejo 17 endpoints (`POST /wiki/new`, `PATCH|DELETE /wiki/page/{pageName}`), with the body base64-encoded, `confirm: true` required for delete, and 401/403 failures passed through. The naming quirk is handled in the tool: `list` now prints `Title (pageName: <slug>)`, and the description says to address pages by that slug. Live, an API-created `Probe-Page` got the slug `Probe-Page.-`; `get`/`update`/`delete` only work with that slug. Live CRUD through the running plugin, on the empty `ml-lab/tardits` wiki (cleaned up afterwards): - create → `Wiki page created: Probe-Page` - list → `Probe-Page (pageName: Probe-Page.-)` - get → metadata + `Last commit: 45edfa83 …` - update → new commit `83a1d1d8 test(wiki): update probe` - delete `confirm: true` → deleted; list → `No wiki pages.` Tests: `test/wiki.test.mjs` covers create/update/delete, base64 encoding, 401/403, missing `title`/`content`, delete confirmation, and failure passthrough; `npm test` 60/60.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
dsh-plugins/dsh-gitea#10
No description provided.