feat(wiki): add create, update and delete actions #15

Merged
dsh merged 1 commit from feat/10-wiki-write into master 2026-10-23 22:40:34 +00:00
Owner

What

gitea_wiki was read-only: list and get only. This adds the three write actions Forgejo already exposes:

Action Endpoint Notes
create POST /wiki/new requires title; body sent as content_base64
update PATCH /wiki/page/{pageName} requires content; replaces the full page
delete DELETE /wiki/page/{pageName} requires confirm: true

list/get are unchanged.

Also handles the naming quirk from the issue: Forgejo may derive the page slug from the title (an API-created Probe-Page became Probe-Page.-). list now prints Title (pageName: <slug>), and the tool description says to address pages by that slug. Without this, a created page could not be fetched/edited by its display title.

Verification

  • Mocked-fetch tests: create POST body (content_base64, unicode round-trip), PATCH segment encoding, DELETE, and 401/403 failures; handler tests for missing title/content, confirm on delete, and API failure passthrough. test/wiki.test.mjs now covers all three.
  • npm test 60/60, leak scan clean, node --check clean.
  • Live CRUD on ml-lab/tardits (empty wiki), then cleaned up:
    • create Probe-Page → created + URL;
    • list → Probe-Page (pageName: Probe-Page.-);
    • get pageName: Probe-Page.- → metadata + last commit;
    • update → new commit 83a1d1d8;
    • delete confirm:true → deleted; list → No wiki pages.

Acceptance (from #10)

  • create on an empty wiki succeeds and the page is readable via get/API.
  • update changes content; delete removes the page (with confirm: true).
  • Mocked-fetch tests for create/update/delete success and 401/403.
  • Existing list/get behaviour unchanged.
  • README/AGENTS tool table updated (separate docs commit with the other wiki fixes).

Closes #10.

## What `gitea_wiki` was read-only: `list` and `get` only. This adds the three write actions Forgejo already exposes: | Action | Endpoint | Notes | |---|---|---| | `create` | `POST /wiki/new` | requires `title`; body sent as `content_base64` | | `update` | `PATCH /wiki/page/{pageName}` | requires `content`; replaces the full page | | `delete` | `DELETE /wiki/page/{pageName}` | requires `confirm: true` | `list`/`get` are unchanged. Also handles the naming quirk from the issue: Forgejo may derive the page slug from the title (an API-created `Probe-Page` became `Probe-Page.-`). `list` now prints `Title (pageName: <slug>)`, and the tool description says to address pages by that slug. Without this, a created page could not be fetched/edited by its display title. ## Verification - Mocked-fetch tests: create POST body (`content_base64`, unicode round-trip), PATCH segment encoding, DELETE, and 401/403 failures; handler tests for missing `title`/`content`, `confirm` on delete, and API failure passthrough. `test/wiki.test.mjs` now covers all three. - `npm test` 60/60, leak scan clean, `node --check` clean. - **Live CRUD on `ml-lab/tardits`** (empty wiki), then cleaned up: - `create` `Probe-Page` → created + URL; - `list` → `Probe-Page (pageName: Probe-Page.-)`; - `get pageName: Probe-Page.-` → metadata + last commit; - `update` → new commit `83a1d1d8`; - `delete confirm:true` → deleted; `list` → `No wiki pages.` ## Acceptance (from #10) - [x] `create` on an empty wiki succeeds and the page is readable via `get`/API. - [x] `update` changes content; `delete` removes the page (with `confirm: true`). - [x] Mocked-fetch tests for create/update/delete success and 401/403. - [x] Existing `list`/`get` behaviour unchanged. - [ ] README/AGENTS tool table updated (separate docs commit with the other wiki fixes). Closes #10.
Forgejo exposes POST /wiki/new and PATCH|DELETE /wiki/page/{pageName}; the tool only had list/get. Encode the body as content_base64, require confirm for delete, surface the canonical pageName slug in list output, and document the API's slug quirk.
dsh merged commit fbca62ab25 into master 2026-10-23 22:40:34 +00:00
Sign in to join this conversation.
No description provided.