Forgejo: Issue Handler on configured label + .omp/forgejo.yaml #79

Merged
lucas merged 1 commit from agent/issue-78-issue-handler into main 2026-10-26 16:28:15 +01:00
Collaborator

Implements plan step 18.

  • forgejo/repo-config.ts: parser for .omp/forgejo.yaml (issue_handler.label only; unknown keys ignored; missing/empty file → defaults; invalid → error).
  • DispatchApi: readRepoFile (default branch, 404 → null, 64 KiB cap) and listLabelEvents (timeline type: "label", body === "1" = add).
  • Webhook: issue_label / issues+label_updated accepted; label_cleared, agent-authored, and pull_request_label ignored.
  • Dispatcher: issue-labeled reason; config read fresh per event; fires only when the newest label batch adds the configured label; invalid config → new config failure kind (public comment names the file as invalid, parse error stays in the row). Permission/workspace gates unchanged; session is the issue's forgejo_conversation session (created or reused).
  • Issue-handler seed (analysis only, no labeling); conversation policy wording mentions label changes.
  • Protocol ForgejoTriggerSummary event/action unions extended with issue_label / label_updated. This wasn't in the plan, but the change needed it to typecheck.

Verification: bun test src/forgejo (264 pass), bun run typecheck in server and web. I didn't run the manual end-to-end check against the live instance.

Closes: #78

Implements plan step 18. - `forgejo/repo-config.ts`: parser for `.omp/forgejo.yaml` (`issue_handler.label` only; unknown keys ignored; missing/empty file → defaults; invalid → error). - `DispatchApi`: `readRepoFile` (default branch, 404 → null, 64 KiB cap) and `listLabelEvents` (timeline `type: "label"`, `body === "1"` = add). - Webhook: `issue_label` / `issues`+`label_updated` accepted; `label_cleared`, agent-authored, and `pull_request_label` ignored. - Dispatcher: `issue-labeled` reason; config read fresh per event; fires only when the newest label batch adds the configured label; invalid config → new `config` failure kind (public comment names the file as invalid, parse error stays in the row). Permission/workspace gates unchanged; session is the issue's `forgejo_conversation` session (created or reused). - Issue-handler seed (analysis only, no labeling); conversation policy wording mentions label changes. - Protocol `ForgejoTriggerSummary` event/action unions extended with `issue_label` / `label_updated`. This wasn't in the plan, but the change needed it to typecheck. Verification: `bun test src/forgejo` (264 pass), `bun run typecheck` in server and web. I didn't run the manual end-to-end check against the live instance. Closes: #78
Owner

Please give me an example of the repo config file

Please give me an example of the repo config file
Author
Collaborator

Example .omp/forgejo.yaml, committed at the repository root on the default branch:

issue_handler:
  label: needs-triage

When someone with write access adds the needs-triage label to an issue, the agent posts an analysis comment on it. Label matching is exact and case-sensitive.

  • issue_handler.label is the only key this PR reads. Other keys, including future sections like review:, are ignored.
  • If the file is missing or empty, or has no issue_handler, label changes trigger nothing. @mentions and review requests still work.
  • If the file is invalid, the agent posts a failure comment on the issue saying .omp/forgejo.yaml is invalid, and doesn't run. Examples of invalid content: bad YAML, issue_handler: x, or an empty label.
Example `.omp/forgejo.yaml`, committed at the repository root on the default branch: ```yaml issue_handler: label: needs-triage ``` When someone with write access adds the `needs-triage` label to an issue, the agent posts an analysis comment on it. Label matching is exact and case-sensitive. - `issue_handler.label` is the only key this PR reads. Other keys, including future sections like `review:`, are ignored. - If the file is missing or empty, or has no `issue_handler`, label changes trigger nothing. @mentions and review requests still work. - If the file is invalid, the agent posts a failure comment on the issue saying `.omp/forgejo.yaml` is invalid, and doesn't run. Examples of invalid content: bad YAML, `issue_handler: x`, or an empty `label`.
Owner

Please fix the conflicts

Please fix the conflicts
omp-deck force-pushed agent/issue-78-issue-handler from 91689f948a to 6bd3ad50ec 2026-10-26 15:50:42 +01:00 Compare
Author
Collaborator

I've rebased onto current main (cdee4b8) and force-pushed; the branch head is now 6bd3ad5. The conflicts were in dispatch-api.ts and dispatcher.test.ts. In both files, this PR and main had each added new methods in the same spot: main added listLabels/replaceIssueLabels, and this PR added readRepoFile/listLabelEvents. The resolution keeps both sets. Typecheck passes and bun test src/forgejo passes (275 tests).

I've rebased onto current `main` (`cdee4b8`) and force-pushed; the branch head is now `6bd3ad5`. The conflicts were in `dispatch-api.ts` and `dispatcher.test.ts`. In both files, this PR and main had each added new methods in the same spot: `main` added `listLabels`/`replaceIssueLabels`, and this PR added `readRepoFile`/`listLabelEvents`. The resolution keeps both sets. Typecheck passes and `bun test src/forgejo` passes (275 tests).
Owner

More conflicts, though

More conflicts, though
omp-deck force-pushed agent/issue-78-issue-handler from 6bd3ad50ec to cd0681c4a6 2026-10-26 16:07:19 +01:00 Compare
Author
Collaborator

I've rebased onto the current main (b433e29) and force-pushed; the branch head is now cd0681c. The conflicts were the same kind as before. main added createIssue/updateIssueBody to DispatchApi and its test fake, at the spot where this PR adds readRepoFile/listLabelEvents. I kept all four methods. Typecheck passes for server and web, and bun test src/forgejo passes (282 tests).

I've rebased onto the current `main` (`b433e29`) and force-pushed; the branch head is now `cd0681c`. The conflicts were the same kind as before. `main` added `createIssue`/`updateIssueBody` to `DispatchApi` and its test fake, at the spot where this PR adds `readRepoFile`/`listLabelEvents`. I kept all four methods. Typecheck passes for server and web, and `bun test src/forgejo` passes (282 tests).
lucas approved these changes 2026-10-26 16:25:34 +01:00
Dismissed
lucas left a comment

Looks good, but needs a final conflict fix

Looks good, but needs a final conflict fix
omp-deck force-pushed agent/issue-78-issue-handler from cd0681c4a6 to 58d99bfd01 2026-10-26 16:27:01 +01:00 Compare
Author
Collaborator

I've rebased onto main (93b1ade) and force-pushed; the branch head is now 58d99bf. The conflicts came from #90 (base-push conflict checks), which touched the same places as this PR. Every conflict was an addition on both sides, and I kept both:

  • push/pushed/base_pushed alongside issue_label/label_updated in the protocol unions.
  • The base-pushed and issue-labeled reasons.
  • The gate and seed branches for both.
  • listOpenPulls alongside readRepoFile/listLabelEvents.
  • Both notes in the webhook doc comment.

Server and web typecheck pass, and bun test src/forgejo passes (290 tests).

I've rebased onto `main` (`93b1ade`) and force-pushed; the branch head is now `58d99bf`. The conflicts came from #90 (base-push conflict checks), which touched the same places as this PR. Every conflict was an addition on both sides, and I kept both: - `push`/`pushed`/`base_pushed` alongside `issue_label`/`label_updated` in the protocol unions. - The `base-pushed` and `issue-labeled` reasons. - The gate and seed branches for both. - `listOpenPulls` alongside `readRepoFile`/`listLabelEvents`. - Both notes in the webhook doc comment. Server and web typecheck pass, and `bun test src/forgejo` passes (290 tests).
lucas approved these changes 2026-10-26 16:28:09 +01:00
lucas merged commit b464a0d840 into main 2026-10-26 16:28:15 +01:00
lucas deleted branch agent/issue-78-issue-handler 2026-10-26 16:28:15 +01: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!79
No description provided.