feat(repo): add and remove one topic without replacing the whole list #813

Closed
opened 2026-10-19 22:10:20 +00:00 by hexajon · 1 comment
Owner

Problem

madtea repo topics set and madt_repos action=topics_set replace the full topic list. There is no way to add or remove one topic. To add a single topic, a caller must read the current list, merge it by hand, and send the whole list back. A stale read, a typo, or a skipped read drops topics, and nothing warns.

Today I added one topic to about 40 of my repos. Each one took a read and a full rewrite of its list.

The forge already has the operation: PUT /repos/{owner}/{repo}/topics/{topic} adds one topic, and DELETE on the same path removes one (docs/api-specs/forgejo-15.0.json, repoAddTopic).

Proposal

Follow gh repo edit --add-topic and --remove-topic:

  • CLI: madtea repo edit --add-topic <topic> and --remove-topic <topic>, each repeatable.
  • MCP: madt_repos action=edit takes add_topics and remove_topics, the same incremental shape as add_labels and remove_labels on madt_issues action=edit.
  • Each one calls the per-topic endpoint, so the rest of the list is never sent and never lost.
  • Adding a topic that is already set, or removing one that is not, is a no-op with a notice.

topics set stays for the case where the caller wants to replace the whole list.

Acceptance criteria

  • repo edit --add-topic x on a repo with topics a b leaves a b x.
  • repo edit --remove-topic a leaves b x.
  • The MCP add_topics and remove_topics give the same results.
  • A repeat add and a remove of a missing topic are no-ops with a notice.
  • Tests cover each case on both surfaces.

Related: #723 (a typed read of description and topics).

## Problem `madtea repo topics set` and `madt_repos action=topics_set` replace the full topic list. There is no way to add or remove one topic. To add a single topic, a caller must read the current list, merge it by hand, and send the whole list back. A stale read, a typo, or a skipped read drops topics, and nothing warns. Today I added one topic to about 40 of my repos. Each one took a read and a full rewrite of its list. The forge already has the operation: `PUT /repos/{owner}/{repo}/topics/{topic}` adds one topic, and `DELETE` on the same path removes one (`docs/api-specs/forgejo-15.0.json`, `repoAddTopic`). ## Proposal Follow `gh repo edit --add-topic` and `--remove-topic`: - CLI: `madtea repo edit --add-topic <topic>` and `--remove-topic <topic>`, each repeatable. - MCP: `madt_repos action=edit` takes `add_topics` and `remove_topics`, the same incremental shape as `add_labels` and `remove_labels` on `madt_issues action=edit`. - Each one calls the per-topic endpoint, so the rest of the list is never sent and never lost. - Adding a topic that is already set, or removing one that is not, is a no-op with a notice. `topics set` stays for the case where the caller wants to replace the whole list. ## Acceptance criteria - `repo edit --add-topic x` on a repo with topics `a b` leaves `a b x`. - `repo edit --remove-topic a` leaves `b x`. - The MCP `add_topics` and `remove_topics` give the same results. - A repeat add and a remove of a missing topic are no-ops with a notice. - Tests cover each case on both surfaces. Related: #723 (a typed read of description and topics).
Author
Owner

Closed as resolved. The append-only topic add shipped in PR #816: repo edit --add-topic and add_topics on madt_repos action=edit append through the per-topic endpoint, and repo topics set / topics_set now refuses a set that would drop a topic. The per-topic remove half of this issue is intentionally not implemented: topics are append-only, recorded in ADR 0057. The full-list replace stays reachable only through the raw API passthrough.

Closed as resolved. The append-only topic add shipped in PR #816: `repo edit --add-topic` and `add_topics` on `madt_repos action=edit` append through the per-topic endpoint, and `repo topics set` / `topics_set` now refuses a set that would drop a topic. The per-topic remove half of this issue is intentionally not implemented: topics are append-only, recorded in ADR 0057. The full-list replace stays reachable only through the raw API passthrough.
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
sixfold-space/madtea#813
No description provided.