ework-web 0.10.115 → 0.10.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +60 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-web",
3
- "version": "0.10.115",
3
+ "version": "0.10.116",
4
4
  "type": "module",
5
5
  "description": "ework-web — standalone multi-project issue tracker. Local SQLite-backed, no external API dependency. Bun + TypeScript + SSR HTML.",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -43,6 +43,7 @@ import {
43
43
  updateIssueModel,
44
44
  updateIssueRuntime,
45
45
  listIssues,
46
+ listCommentsForIssue,
46
47
  createAttachment,
47
48
  getAttachment,
48
49
  verifyUserPassword,
@@ -625,6 +626,65 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
625
626
  .split(/[\s,]+/).map((s) => s.trim()).filter(Boolean);
626
627
  return json({ logins });
627
628
  }
629
+
630
+ // Issues JSON API — read side for the ework-issue CLI (pull/open).
631
+ if (url.pathname === "/api/v1/issues" && req.method === "GET") {
632
+ const owner = url.searchParams.get("owner") ?? "";
633
+ const repo = url.searchParams.get("repo") ?? "";
634
+ if (!owner || !repo) return json({ error: "owner, repo required" }, 400);
635
+ const project = await getProject(owner, repo);
636
+ if (!project) return json({ error: "project not found" }, 404);
637
+ const sp = url.searchParams.get("state");
638
+ const state = sp === "open" || sp === "closed" ? sp : "all";
639
+ const rows = await listIssues(project.id, { state, limit: 200 });
640
+ return json({
641
+ project: { owner, name: repo },
642
+ issues: rows.map((i) => ({
643
+ number: i.number,
644
+ title: i.title,
645
+ state: i.state,
646
+ author: i.author,
647
+ ai_status: i.ai_status ?? "",
648
+ model: i.model ?? "",
649
+ comment_count: i.comment_count,
650
+ created_at: i.created_at,
651
+ updated_at: i.updated_at,
652
+ })),
653
+ });
654
+ }
655
+ const apiIssueDetail = url.pathname.match(/^\/api\/v1\/issues\/(\d+)$/);
656
+ if (apiIssueDetail && req.method === "GET") {
657
+ const owner = url.searchParams.get("owner") ?? "";
658
+ const repo = url.searchParams.get("repo") ?? "";
659
+ if (!owner || !repo) return json({ error: "owner, repo required" }, 400);
660
+ const project = await getProject(owner, repo);
661
+ if (!project) return json({ error: "project not found" }, 404);
662
+ const issue = await getIssueWithMeta(project.id, Number(apiIssueDetail[1]));
663
+ if (!issue) return json({ error: "issue not found" }, 404);
664
+ const comments = await listCommentsForIssue(issue.id);
665
+ return json({
666
+ issue: {
667
+ number: issue.number,
668
+ title: issue.title,
669
+ body: issue.body,
670
+ state: issue.state,
671
+ author: issue.author,
672
+ ai_status: issue.ai_status ?? "",
673
+ model: issue.model ?? "",
674
+ created_at: issue.created_at,
675
+ updated_at: issue.updated_at,
676
+ },
677
+ comments: comments.map((c) => ({
678
+ id: c.id,
679
+ author: c.author,
680
+ author_kind: c.author_kind ?? "",
681
+ model: c.model ?? "",
682
+ upstream_comment_id: c.upstream_comment_id ?? null,
683
+ created_at: c.created_at,
684
+ body: c.body,
685
+ })),
686
+ });
687
+ }
628
688
  const evStatus = url.pathname.match(/^\/api\/v1\/repos\/([^/]+)\/([^/]+)\/issues\/(\d+)\/status$/);
629
689
  if (evStatus && req.method === "POST") {
630
690
  const [, owner, repo, numStr] = evStatus;