@opentag/github 0.1.0

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.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # @opentag/github
2
+
3
+ GitHub adapter helpers for OpenTag.
4
+
5
+ Use this package to turn GitHub comments into `OpenTagEvent` objects and to render GitHub-friendly callback text.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @opentag/github
11
+ ```
12
+
13
+ ## Exports
14
+
15
+ - `normalizeGitHubIssueComment`: converts an issue comment payload shape into an `OpenTagEvent`.
16
+ - `normalizeGitHubPullRequestReviewComment`: converts a PR review comment payload shape into an `OpenTagEvent`.
17
+ - `renderAcknowledgement`, `renderProgress`, `renderFinalResult`: markdown text helpers for GitHub callbacks.
18
+ - `createPullRequest`: low-level GitHub REST helper for opening PRs from runner-created branches.
19
+
20
+ ## Example
21
+
22
+ ```ts
23
+ import { normalizeGitHubIssueComment } from "@opentag/github";
24
+
25
+ const event = normalizeGitHubIssueComment({
26
+ id: String(payload.comment.id),
27
+ commentBody: payload.comment.body,
28
+ commentUrl: payload.comment.html_url,
29
+ apiCommentsUrl: payload.issue.comments_url,
30
+ issueUrl: payload.issue.html_url,
31
+ issueNumber: payload.issue.number,
32
+ owner: payload.repository.owner.login,
33
+ repo: payload.repository.name,
34
+ actorId: payload.sender.id,
35
+ actorLogin: payload.sender.login,
36
+ private: payload.repository.private,
37
+ receivedAt: new Date().toISOString()
38
+ });
39
+
40
+ if (event) {
41
+ // Send event to @opentag/client or your own OpenTag-compatible control plane.
42
+ }
43
+ ```
44
+
45
+ ## Permissions
46
+
47
+ `fix` and `run` commands receive write-capable permissions such as `repo:write` and `pr:create`. Review, explain, and investigate-style commands stay read/comment oriented.
48
+
49
+ ## Stability
50
+
51
+ Normalizer input shapes are intentionally small and provider-specific. Prefer adding optional fields over changing existing fields.
@@ -0,0 +1,4 @@
1
+ export * from "./normalize.js";
2
+ export * from "./pull-request.js";
3
+ export * from "./render.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,201 @@
1
+ // src/normalize.ts
2
+ import { parseOpenTagMention } from "@opentag/core";
3
+ function permissionsForIntent(intent) {
4
+ const permissions = [
5
+ {
6
+ scope: "issue:comment",
7
+ reason: "reply to the source GitHub thread"
8
+ },
9
+ {
10
+ scope: "runner:local",
11
+ reason: "execute the run on a paired local daemon"
12
+ }
13
+ ];
14
+ if (intent === "fix" || intent === "run") {
15
+ permissions.push(
16
+ {
17
+ scope: "repo:read",
18
+ reason: "inspect the repository in the paired local checkout"
19
+ },
20
+ {
21
+ scope: "repo:write",
22
+ reason: "commit code changes on an isolated run branch"
23
+ },
24
+ {
25
+ scope: "pr:create",
26
+ reason: "open a pull request for completed code changes"
27
+ }
28
+ );
29
+ }
30
+ return permissions;
31
+ }
32
+ function normalizeGitHubIssueComment(input) {
33
+ const mention = parseOpenTagMention(input.commentBody);
34
+ if (!mention.matched) return null;
35
+ return {
36
+ id: `evt_github_comment_${input.id}`,
37
+ source: "github",
38
+ sourceEventId: input.id,
39
+ receivedAt: input.receivedAt,
40
+ actor: {
41
+ provider: "github",
42
+ providerUserId: String(input.actorId),
43
+ handle: input.actorLogin
44
+ },
45
+ target: {
46
+ mention: "@opentag",
47
+ agentId: "opentag"
48
+ },
49
+ command: {
50
+ rawText: mention.rawText,
51
+ intent: mention.intent,
52
+ args: mention.args
53
+ },
54
+ context: [
55
+ {
56
+ kind: "github.issue",
57
+ uri: input.issueUrl,
58
+ visibility: input.private ? "private" : "public"
59
+ },
60
+ {
61
+ kind: "github.comment",
62
+ uri: input.commentUrl,
63
+ visibility: input.private ? "private" : "public"
64
+ }
65
+ ],
66
+ permissions: permissionsForIntent(mention.intent),
67
+ callback: {
68
+ provider: "github",
69
+ uri: input.apiCommentsUrl,
70
+ threadKey: `${input.owner}/${input.repo}`
71
+ },
72
+ metadata: {
73
+ owner: input.owner,
74
+ repo: input.repo,
75
+ issueNumber: input.issueNumber,
76
+ ...typeof input.installationId === "number" ? { installationId: input.installationId } : {}
77
+ }
78
+ };
79
+ }
80
+ function normalizeGitHubPullRequestReviewComment(input) {
81
+ const mention = parseOpenTagMention(input.commentBody);
82
+ if (!mention.matched) return null;
83
+ return {
84
+ id: `evt_github_pr_review_comment_${input.id}`,
85
+ source: "github",
86
+ sourceEventId: input.id,
87
+ receivedAt: input.receivedAt,
88
+ actor: {
89
+ provider: "github",
90
+ providerUserId: String(input.actorId),
91
+ handle: input.actorLogin
92
+ },
93
+ target: {
94
+ mention: "@opentag",
95
+ agentId: "opentag"
96
+ },
97
+ command: {
98
+ rawText: mention.rawText,
99
+ intent: mention.intent,
100
+ args: mention.args
101
+ },
102
+ context: [
103
+ {
104
+ kind: "github.pull_request",
105
+ uri: input.pullRequestUrl,
106
+ visibility: input.private ? "private" : "public"
107
+ },
108
+ {
109
+ kind: "github.comment",
110
+ uri: input.commentUrl,
111
+ visibility: input.private ? "private" : "public"
112
+ }
113
+ ],
114
+ permissions: permissionsForIntent(mention.intent),
115
+ callback: {
116
+ provider: "github",
117
+ uri: input.apiCommentsUrl,
118
+ threadKey: `${input.owner}/${input.repo}#${input.pullRequestNumber}`
119
+ },
120
+ metadata: {
121
+ owner: input.owner,
122
+ repo: input.repo,
123
+ pullRequestNumber: input.pullRequestNumber,
124
+ ...typeof input.installationId === "number" ? { installationId: input.installationId } : {}
125
+ }
126
+ };
127
+ }
128
+
129
+ // src/pull-request.ts
130
+ function buildPullRequestBody(result) {
131
+ const lines = ["## Summary", "", result.summary];
132
+ if (result.changedFiles?.length) {
133
+ lines.push("", "## Changed Files");
134
+ for (const file of result.changedFiles) {
135
+ lines.push(`- \`${file}\``);
136
+ }
137
+ }
138
+ if (result.verification?.length) {
139
+ lines.push("", "## Verification");
140
+ for (const check of result.verification) {
141
+ lines.push(`- \`${check.command}\`: ${check.outcome}`);
142
+ }
143
+ }
144
+ return lines.join("\n");
145
+ }
146
+ async function createPullRequestViaFetch(input, fetchImpl = fetch) {
147
+ const response = await fetchImpl(`https://api.github.com/repos/${input.owner}/${input.repo}/pulls`, {
148
+ method: "POST",
149
+ headers: {
150
+ accept: "application/vnd.github+json",
151
+ authorization: `Bearer ${input.token}`,
152
+ "content-type": "application/json",
153
+ "x-github-api-version": "2022-11-28"
154
+ },
155
+ body: JSON.stringify({
156
+ title: input.title,
157
+ body: input.body,
158
+ head: input.head,
159
+ base: input.base
160
+ })
161
+ });
162
+ if (!response.ok) {
163
+ throw new Error(`create pull request failed: ${response.status} ${await response.text()}`);
164
+ }
165
+ const body = await response.json();
166
+ if (!body.html_url) {
167
+ throw new Error("create pull request response did not include html_url");
168
+ }
169
+ return body.html_url;
170
+ }
171
+
172
+ // src/render.ts
173
+ function renderAcknowledgement(runId) {
174
+ return `OpenTag picked this up. Run: \`${runId}\``;
175
+ }
176
+ function renderProgress(input) {
177
+ return `OpenTag progress for \`${input.runId}\`: ${input.message}`;
178
+ }
179
+ function renderFinalResult(result) {
180
+ const lines = [`OpenTag finished with **${result.conclusion}**.`, "", result.summary];
181
+ if (result.verification?.length) {
182
+ lines.push("", "Verification:");
183
+ for (const check of result.verification) {
184
+ lines.push(`- \`${check.command}\`: ${check.outcome}`);
185
+ }
186
+ }
187
+ if (result.nextAction) {
188
+ lines.push("", `Next action: ${result.nextAction}`);
189
+ }
190
+ return lines.join("\n");
191
+ }
192
+ export {
193
+ buildPullRequestBody,
194
+ createPullRequestViaFetch,
195
+ normalizeGitHubIssueComment,
196
+ normalizeGitHubPullRequestReviewComment,
197
+ renderAcknowledgement,
198
+ renderFinalResult,
199
+ renderProgress
200
+ };
201
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/normalize.ts","../src/pull-request.ts","../src/render.ts"],"sourcesContent":["import { parseOpenTagMention, type OpenTagEvent } from \"@opentag/core\";\nimport type { OpenTagCommand, PermissionGrant } from \"@opentag/core\";\n\nexport type GitHubIssueCommentInput = {\n id: string;\n commentBody: string;\n commentUrl: string;\n apiCommentsUrl: string;\n issueUrl: string;\n issueNumber: number;\n owner: string;\n repo: string;\n actorId: number;\n actorLogin: string;\n private: boolean;\n receivedAt: string;\n installationId?: number;\n};\n\nexport type GitHubPullRequestReviewCommentInput = {\n id: string;\n commentBody: string;\n commentUrl: string;\n pullRequestUrl: string;\n apiCommentsUrl: string;\n owner: string;\n repo: string;\n pullRequestNumber: number;\n actorId: number;\n actorLogin: string;\n private: boolean;\n receivedAt: string;\n installationId?: number;\n};\n\nfunction permissionsForIntent(intent: OpenTagCommand[\"intent\"]): PermissionGrant[] {\n const permissions: PermissionGrant[] = [\n {\n scope: \"issue:comment\",\n reason: \"reply to the source GitHub thread\"\n },\n {\n scope: \"runner:local\",\n reason: \"execute the run on a paired local daemon\"\n }\n ];\n if (intent === \"fix\" || intent === \"run\") {\n permissions.push(\n {\n scope: \"repo:read\",\n reason: \"inspect the repository in the paired local checkout\"\n },\n {\n scope: \"repo:write\",\n reason: \"commit code changes on an isolated run branch\"\n },\n {\n scope: \"pr:create\",\n reason: \"open a pull request for completed code changes\"\n }\n );\n }\n return permissions;\n}\n\nexport function normalizeGitHubIssueComment(input: GitHubIssueCommentInput): OpenTagEvent | null {\n const mention = parseOpenTagMention(input.commentBody);\n if (!mention.matched) return null;\n\n return {\n id: `evt_github_comment_${input.id}`,\n source: \"github\",\n sourceEventId: input.id,\n receivedAt: input.receivedAt,\n actor: {\n provider: \"github\",\n providerUserId: String(input.actorId),\n handle: input.actorLogin\n },\n target: {\n mention: \"@opentag\",\n agentId: \"opentag\"\n },\n command: {\n rawText: mention.rawText,\n intent: mention.intent,\n args: mention.args\n },\n context: [\n {\n kind: \"github.issue\",\n uri: input.issueUrl,\n visibility: input.private ? \"private\" : \"public\"\n },\n {\n kind: \"github.comment\",\n uri: input.commentUrl,\n visibility: input.private ? \"private\" : \"public\"\n }\n ],\n permissions: permissionsForIntent(mention.intent),\n callback: {\n provider: \"github\",\n uri: input.apiCommentsUrl,\n threadKey: `${input.owner}/${input.repo}`\n },\n metadata: {\n owner: input.owner,\n repo: input.repo,\n issueNumber: input.issueNumber,\n ...(typeof input.installationId === \"number\" ? { installationId: input.installationId } : {})\n }\n };\n}\n\nexport function normalizeGitHubPullRequestReviewComment(input: GitHubPullRequestReviewCommentInput): OpenTagEvent | null {\n const mention = parseOpenTagMention(input.commentBody);\n if (!mention.matched) return null;\n\n return {\n id: `evt_github_pr_review_comment_${input.id}`,\n source: \"github\",\n sourceEventId: input.id,\n receivedAt: input.receivedAt,\n actor: {\n provider: \"github\",\n providerUserId: String(input.actorId),\n handle: input.actorLogin\n },\n target: {\n mention: \"@opentag\",\n agentId: \"opentag\"\n },\n command: {\n rawText: mention.rawText,\n intent: mention.intent,\n args: mention.args\n },\n context: [\n {\n kind: \"github.pull_request\",\n uri: input.pullRequestUrl,\n visibility: input.private ? \"private\" : \"public\"\n },\n {\n kind: \"github.comment\",\n uri: input.commentUrl,\n visibility: input.private ? \"private\" : \"public\"\n }\n ],\n permissions: permissionsForIntent(mention.intent),\n callback: {\n provider: \"github\",\n uri: input.apiCommentsUrl,\n threadKey: `${input.owner}/${input.repo}#${input.pullRequestNumber}`\n },\n metadata: {\n owner: input.owner,\n repo: input.repo,\n pullRequestNumber: input.pullRequestNumber,\n ...(typeof input.installationId === \"number\" ? { installationId: input.installationId } : {})\n }\n };\n}\n","import type { OpenTagRunResult } from \"@opentag/core\";\n\nexport type CreatePullRequestInput = {\n token: string;\n owner: string;\n repo: string;\n title: string;\n body: string;\n head: string;\n base: string;\n};\n\nexport type FetchLike = typeof fetch;\n\nexport function buildPullRequestBody(result: OpenTagRunResult): string {\n const lines = [\"## Summary\", \"\", result.summary];\n\n if (result.changedFiles?.length) {\n lines.push(\"\", \"## Changed Files\");\n for (const file of result.changedFiles) {\n lines.push(`- \\`${file}\\``);\n }\n }\n\n if (result.verification?.length) {\n lines.push(\"\", \"## Verification\");\n for (const check of result.verification) {\n lines.push(`- \\`${check.command}\\`: ${check.outcome}`);\n }\n }\n\n return lines.join(\"\\n\");\n}\n\nexport async function createPullRequestViaFetch(input: CreatePullRequestInput, fetchImpl: FetchLike = fetch): Promise<string> {\n const response = await fetchImpl(`https://api.github.com/repos/${input.owner}/${input.repo}/pulls`, {\n method: \"POST\",\n headers: {\n accept: \"application/vnd.github+json\",\n authorization: `Bearer ${input.token}`,\n \"content-type\": \"application/json\",\n \"x-github-api-version\": \"2022-11-28\"\n },\n body: JSON.stringify({\n title: input.title,\n body: input.body,\n head: input.head,\n base: input.base\n })\n });\n\n if (!response.ok) {\n throw new Error(`create pull request failed: ${response.status} ${await response.text()}`);\n }\n\n const body = (await response.json()) as { html_url?: string };\n if (!body.html_url) {\n throw new Error(\"create pull request response did not include html_url\");\n }\n return body.html_url;\n}\n","import type { OpenTagRunResult } from \"@opentag/core\";\n\nexport function renderAcknowledgement(runId: string): string {\n return `OpenTag picked this up. Run: \\`${runId}\\``;\n}\n\nexport function renderProgress(input: { runId: string; message: string }): string {\n return `OpenTag progress for \\`${input.runId}\\`: ${input.message}`;\n}\n\nexport function renderFinalResult(result: OpenTagRunResult): string {\n const lines = [`OpenTag finished with **${result.conclusion}**.`, \"\", result.summary];\n\n if (result.verification?.length) {\n lines.push(\"\", \"Verification:\");\n for (const check of result.verification) {\n lines.push(`- \\`${check.command}\\`: ${check.outcome}`);\n }\n }\n\n if (result.nextAction) {\n lines.push(\"\", `Next action: ${result.nextAction}`);\n }\n\n return lines.join(\"\\n\");\n}\n"],"mappings":";AAAA,SAAS,2BAA8C;AAmCvD,SAAS,qBAAqB,QAAqD;AACjF,QAAM,cAAiC;AAAA,IACrC;AAAA,MACE,OAAO;AAAA,MACP,QAAQ;AAAA,IACV;AAAA,IACA;AAAA,MACE,OA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e,OAAmD;AAChF,SAAO,0BAA0B,MAAM,KAAK,OAAO,MAAM,OAAO;AAClE;AAEO,SAAS,kBAAkB,QAAkC;AAClE,QAAM,QAAQ,CAAC,2BAA2B,OAAO,UAAU,OAAO,IAAI,OAAO,OAAO;AAEpF,MAAI,OAAO,cAAc,QAAQ;AAC/B,UAAM,KAAK,IAAI,eAAe;AAC9B,eAAW,SAAS,OAAO,cAAc;AACvC,YAAM,KAAK,OAAO,MAAM,OAAO,OAAO,MAAM,OAAO,EAAE;AAAA,IACvD;AAAA,EACF;AAEA,MAAI,OAAO,YAAY;AACrB,UAAM,KAAK,IAAI,gBAAgB,OAAO,UAAU,EAAE;AAAA,EACpD;AAEA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
@@ -0,0 +1,34 @@
1
+ import { type OpenTagEvent } from "@opentag/core";
2
+ export type GitHubIssueCommentInput = {
3
+ id: string;
4
+ commentBody: string;
5
+ commentUrl: string;
6
+ apiCommentsUrl: string;
7
+ issueUrl: string;
8
+ issueNumber: number;
9
+ owner: string;
10
+ repo: string;
11
+ actorId: number;
12
+ actorLogin: string;
13
+ private: boolean;
14
+ receivedAt: string;
15
+ installationId?: number;
16
+ };
17
+ export type GitHubPullRequestReviewCommentInput = {
18
+ id: string;
19
+ commentBody: string;
20
+ commentUrl: string;
21
+ pullRequestUrl: string;
22
+ apiCommentsUrl: string;
23
+ owner: string;
24
+ repo: string;
25
+ pullRequestNumber: number;
26
+ actorId: number;
27
+ actorLogin: string;
28
+ private: boolean;
29
+ receivedAt: string;
30
+ installationId?: number;
31
+ };
32
+ export declare function normalizeGitHubIssueComment(input: GitHubIssueCommentInput): OpenTagEvent | null;
33
+ export declare function normalizeGitHubPullRequestReviewComment(input: GitHubPullRequestReviewCommentInput): OpenTagEvent | null;
34
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAGvE,MAAM,MAAM,uBAAuB,GAAG;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAgCF,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,uBAAuB,GAAG,YAAY,GAAG,IAAI,CAgD/F;AAED,wBAAgB,uCAAuC,CAAC,KAAK,EAAE,mCAAmC,GAAG,YAAY,GAAG,IAAI,CAgDvH"}
@@ -0,0 +1,14 @@
1
+ import type { OpenTagRunResult } from "@opentag/core";
2
+ export type CreatePullRequestInput = {
3
+ token: string;
4
+ owner: string;
5
+ repo: string;
6
+ title: string;
7
+ body: string;
8
+ head: string;
9
+ base: string;
10
+ };
11
+ export type FetchLike = typeof fetch;
12
+ export declare function buildPullRequestBody(result: OpenTagRunResult): string;
13
+ export declare function createPullRequestViaFetch(input: CreatePullRequestInput, fetchImpl?: FetchLike): Promise<string>;
14
+ //# sourceMappingURL=pull-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pull-request.d.ts","sourceRoot":"","sources":["../src/pull-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC;AAErC,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAkBrE;AAED,wBAAsB,yBAAyB,CAAC,KAAK,EAAE,sBAAsB,EAAE,SAAS,GAAE,SAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CA0B5H"}
@@ -0,0 +1,8 @@
1
+ import type { OpenTagRunResult } from "@opentag/core";
2
+ export declare function renderAcknowledgement(runId: string): string;
3
+ export declare function renderProgress(input: {
4
+ runId: string;
5
+ message: string;
6
+ }): string;
7
+ export declare function renderFinalResult(result: OpenTagRunResult): string;
8
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEhF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAelE"}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@opentag/github",
3
+ "version": "0.1.0",
4
+ "description": "GitHub event normalization and callback rendering for OpenTag.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "development": "./src/index.ts",
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "keywords": [
23
+ "opentag",
24
+ "github",
25
+ "probot",
26
+ "agents",
27
+ "webhooks"
28
+ ],
29
+ "license": "Apache-2.0",
30
+ "dependencies": {
31
+ "@opentag/core": "0.1.0"
32
+ },
33
+ "devDependencies": {
34
+ "tsup": "^8.3.5",
35
+ "typescript": "^5.7.2"
36
+ },
37
+ "scripts": {
38
+ "build": "tsup && tsc -b tsconfig.json --emitDeclarationOnly --force",
39
+ "lint": "tsc --noEmit"
40
+ }
41
+ }