Register 5 forgejo_action_* tools in src/index.ts #117

Closed
opened 2026-08-29 03:28:50 +00:00 by david · 0 comments
Owner

Summary

Register the five new tools in src/index.ts using the existing registration pattern (TypeBox schemas, promptSnippet/promptGuidelines, host/owner/repo overrides): forgejo_action_runs, forgejo_action_run_view, forgejo_action_jobs, forgejo_action_job_log, forgejo_action_run_logs.

Background

Part of the Forgejo Actions tooling feature (tracking issue #111 — branch feature/issue-111/forgejo-actions-tools, commits issue-111: ...). Depends on the API functions from #114 (metadata queries), #115 (job log), #116 (run logs). Mirror the existing tools in src/index.ts exactly: snake_case tool names, pi.registerTool({name, description, schema, invoke, promptSnippet, promptGuidelines}), shared host/owner/repo override handling, and the formatIssue()-style output helpers.

Implementation Details

  • Five tools:
    • forgejo_action_runs — list/search runs; all filters from #114; live JSON output.
    • forgejo_action_run_view — single run by run_id; live.
    • forgejo_action_jobs — jobs of a run by run_id; live.
    • forgejo_action_job_logrun_id, job_id, attempt?, refresh?; cache-first; returns path / sizeBytes / lineCount / cached.
    • forgejo_action_run_logsrun_id, refresh?; cache-first ZIP; returns paths + per-file listing.
  • Metadata tools are live; only log downloads are cached — say so in the tool descriptions.
  • TypeBox schemas with descriptions for every parameter (match the verbosity of existing tools).
  • promptGuidelines must include: "logs cache to ~/.cache/forgejo-actions (override with FORGEJO_ACTIONS_CACHE_DIR); pass refresh: true after a re-run or for in-progress runs" and "use forgejo_action_runs to find failed runs (status[]=failure), then forgejo_action_job_log".
  • Default host/owner/repo resolution via src/git.ts (detectForgejoHost() / parseRemoteUrl()) exactly like existing tools.

Acceptance Criteria

  • All 5 tools registered and discoverable (tool listing / pi --list-tools after /reload).
  • Each has a TypeBox schema with parameter descriptions; host/owner/repo optional with remote-derived defaults.
  • forgejo_action_job_log and forgejo_action_run_logs document cache + refresh semantics in their prompt guidance.
  • Tools return the documented shapes (live JSON for metadata; {path, sizeBytes, lineCount, cached} / paths+listing for logs).
  • Registration tests pass (schema shape + success/error passthrough, matching the existing index-test style).
  • npm run check passes.

Test Plan

  • cd extensions/forgejo && npm testtests/index.test.ts additions for the 5 tools.
  • Manual: /reload in pi, confirm the 5 tools appear; on a v16+ instance run forgejo_action_runs and a forgejo_action_job_log end-to-end.
### Summary Register the five new tools in `src/index.ts` using the existing registration pattern (TypeBox schemas, `promptSnippet`/`promptGuidelines`, host/owner/repo overrides): `forgejo_action_runs`, `forgejo_action_run_view`, `forgejo_action_jobs`, `forgejo_action_job_log`, `forgejo_action_run_logs`. ### Background Part of the Forgejo Actions tooling feature (tracking issue **#111** — branch `feature/issue-111/forgejo-actions-tools`, commits `issue-111: ...`). Depends on the API functions from **#114** (metadata queries), **#115** (job log), **#116** (run logs). Mirror the existing tools in `src/index.ts` exactly: snake_case tool names, `pi.registerTool({name, description, schema, invoke, promptSnippet, promptGuidelines})`, shared host/owner/repo override handling, and the `formatIssue()`-style output helpers. ### Implementation Details - Five tools: - `forgejo_action_runs` — list/search runs; all filters from #114; live JSON output. - `forgejo_action_run_view` — single run by `run_id`; live. - `forgejo_action_jobs` — jobs of a run by `run_id`; live. - `forgejo_action_job_log` — `run_id`, `job_id`, `attempt?`, `refresh?`; cache-first; returns `path` / `sizeBytes` / `lineCount` / `cached`. - `forgejo_action_run_logs` — `run_id`, `refresh?`; cache-first ZIP; returns paths + per-file listing. - Metadata tools are **live**; only log downloads are cached — say so in the tool descriptions. - TypeBox schemas with descriptions for every parameter (match the verbosity of existing tools). - `promptGuidelines` must include: "logs cache to `~/.cache/forgejo-actions` (override with `FORGEJO_ACTIONS_CACHE_DIR`); pass `refresh: true` after a re-run or for in-progress runs" and "use `forgejo_action_runs` to find failed runs (`status[]=failure`), then `forgejo_action_job_log`". - Default host/owner/repo resolution via `src/git.ts` (`detectForgejoHost()` / `parseRemoteUrl()`) exactly like existing tools. ### Acceptance Criteria - [ ] All 5 tools registered and discoverable (tool listing / `pi --list-tools` after `/reload`). - [ ] Each has a TypeBox schema with parameter descriptions; host/owner/repo optional with remote-derived defaults. - [ ] `forgejo_action_job_log` and `forgejo_action_run_logs` document cache + `refresh` semantics in their prompt guidance. - [ ] Tools return the documented shapes (live JSON for metadata; `{path, sizeBytes, lineCount, cached}` / paths+listing for logs). - [ ] Registration tests pass (schema shape + success/error passthrough, matching the existing index-test style). - [ ] `npm run check` passes. ### Test Plan - `cd extensions/forgejo && npm test` — `tests/index.test.ts` additions for the 5 tools. - Manual: `/reload` in pi, confirm the 5 tools appear; on a v16+ instance run `forgejo_action_runs` and a `forgejo_action_job_log` end-to-end.
david closed this issue 2026-09-18 05:44:09 +00:00
Sign in to join this conversation.
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
david/pi-extensions-and-skills#117
No description provided.