notican 1.0.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.
Files changed (56) hide show
  1. package/.env.example +14 -0
  2. package/README.md +175 -0
  3. package/dist/__fixtures__/index.d.ts +11 -0
  4. package/dist/__fixtures__/index.d.ts.map +1 -0
  5. package/dist/__fixtures__/index.js +160 -0
  6. package/dist/__fixtures__/index.js.map +1 -0
  7. package/dist/config.d.ts +17 -0
  8. package/dist/config.d.ts.map +1 -0
  9. package/dist/config.js +37 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/github/client.d.ts +29 -0
  12. package/dist/github/client.d.ts.map +1 -0
  13. package/dist/github/client.js +121 -0
  14. package/dist/github/client.js.map +1 -0
  15. package/dist/handlers/index.d.ts +11 -0
  16. package/dist/handlers/index.d.ts.map +1 -0
  17. package/dist/handlers/index.js +35 -0
  18. package/dist/handlers/index.js.map +1 -0
  19. package/dist/handlers/issue.d.ts +6 -0
  20. package/dist/handlers/issue.d.ts.map +1 -0
  21. package/dist/handlers/issue.js +114 -0
  22. package/dist/handlers/issue.js.map +1 -0
  23. package/dist/handlers/pr.d.ts +6 -0
  24. package/dist/handlers/pr.d.ts.map +1 -0
  25. package/dist/handlers/pr.js +126 -0
  26. package/dist/handlers/pr.js.map +1 -0
  27. package/dist/handlers/push.d.ts +7 -0
  28. package/dist/handlers/push.d.ts.map +1 -0
  29. package/dist/handlers/push.js +151 -0
  30. package/dist/handlers/push.js.map +1 -0
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +37 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/notion/client.d.ts +40 -0
  36. package/dist/notion/client.d.ts.map +1 -0
  37. package/dist/notion/client.js +289 -0
  38. package/dist/notion/client.js.map +1 -0
  39. package/dist/processors/claude.d.ts +29 -0
  40. package/dist/processors/claude.d.ts.map +1 -0
  41. package/dist/processors/claude.js +245 -0
  42. package/dist/processors/claude.js.map +1 -0
  43. package/dist/server/index.d.ts +4 -0
  44. package/dist/server/index.d.ts.map +1 -0
  45. package/dist/server/index.js +77 -0
  46. package/dist/server/index.js.map +1 -0
  47. package/dist/types/index.d.ts +142 -0
  48. package/dist/types/index.d.ts.map +1 -0
  49. package/dist/types/index.js +12 -0
  50. package/dist/types/index.js.map +1 -0
  51. package/dist/watcher/notion-tasks.d.ts +10 -0
  52. package/dist/watcher/notion-tasks.d.ts.map +1 -0
  53. package/dist/watcher/notion-tasks.js +135 -0
  54. package/dist/watcher/notion-tasks.js.map +1 -0
  55. package/package.json +61 -0
  56. package/scripts/setup-notion.ts +216 -0
package/.env.example ADDED
@@ -0,0 +1,14 @@
1
+ GITHUB_WEBHOOK_SECRET=your_webhook_secret
2
+ GITHUB_TOKEN=ghp_your_token
3
+ GITHUB_OWNER=your-org-or-username
4
+ GITHUB_REPO=your-repo
5
+ NOTION_TOKEN=secret_your_notion_token
6
+ NOTION_PARENT_PAGE_ID=notion_page_id # Required for setup:notion — the parent page ID from the Notion URL
7
+ NOTION_DATABASE_ADR=notion_database_id
8
+ NOTION_DATABASE_CHANGELOG=notion_database_id
9
+ NOTION_DATABASE_API_REF=notion_database_id
10
+ NOTION_DATABASE_RUNBOOKS=notion_database_id
11
+ NOTION_DATABASE_TASKS=notion_database_id
12
+ ANTHROPIC_API_KEY=sk-ant-your_key
13
+ PORT=4000
14
+ POLL_INTERVAL_SECONDS=60
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # Notican — Autonomous Engineering Intelligence Hub
2
+
3
+ > **Notion MCP Challenge Entry** — Bidirectional GitHub ↔ Notion sync powered by Claude AI.
4
+
5
+ Every PR, commit, and issue automatically becomes living documentation in Notion. Zero manual work.
6
+
7
+ ---
8
+
9
+ ## How It Works
10
+
11
+ ```
12
+ GitHub Events (webhook)
13
+
14
+ Express Server (port 4000)
15
+
16
+ Event Handlers (pr / push / issues)
17
+
18
+ Claude Sonnet 4.6 (diff analysis + doc generation)
19
+
20
+ Notion MCP → 5 auto-maintained databases
21
+
22
+ Notion Watcher (polls every 60s)
23
+
24
+ Tasks tagged github_sync=true
25
+
26
+ GitHub Issues API → creates issue, marks task synced
27
+ ```
28
+
29
+ ## What Gets Generated
30
+
31
+ | GitHub Event | Notion Output |
32
+ |---|---|
33
+ | PR merged to `main` | Changelog entry + ADR (if architecture change) |
34
+ | Push with API file changes | API Reference update |
35
+ | Push with infra changes (Dockerfile, k8s, Terraform) | Runbook create/update |
36
+ | Issue opened | Task created in Notion Tasks database |
37
+ | Issue closed/reopened | Task status synced |
38
+ | Notion task with `github_sync=true` | GitHub Issue created |
39
+
40
+ ## Notion Workspace
41
+
42
+ Five databases — created automatically by `npm run setup:notion`:
43
+
44
+ | Database | Auto-maintained from |
45
+ |---|---|
46
+ | 📐 Architecture Decisions | Significant PRs |
47
+ | 📋 Changelog | Every merge to main |
48
+ | 📡 API Reference | API/route file changes |
49
+ | 📖 Runbooks | Infrastructure changes |
50
+ | ✅ Tasks | GitHub Issues (bidirectional) |
51
+
52
+ ## Setup
53
+
54
+ ### 1. Prerequisites
55
+
56
+ - Node.js 22+
57
+ - A GitHub repo with webhook access
58
+ - A Notion workspace with an integration token
59
+ - An Anthropic API key
60
+
61
+ ### 2. Install
62
+
63
+ ```bash
64
+ git clone https://github.com/your-org/notican-mcp-challange
65
+ cd notican-mcp-challange
66
+ npm install
67
+ ```
68
+
69
+ ### 3. Configure
70
+
71
+ ```bash
72
+ cp .env.example .env
73
+ # Fill in your tokens — see .env.example for all required vars
74
+ ```
75
+
76
+ ### 4. Create Notion workspace structure
77
+
78
+ ```bash
79
+ # Add NOTION_TOKEN and NOTION_PARENT_PAGE_ID to .env first
80
+ npm run setup:notion
81
+ # Prints 5 database IDs — paste them back into .env
82
+ ```
83
+
84
+ ### 5. Configure GitHub webhook
85
+
86
+ - Go to your repo → Settings → Webhooks → Add webhook
87
+ - Payload URL: `https://your-domain/webhooks/github` (use `ngrok http 4000` for local dev)
88
+ - Content type: `application/json`
89
+ - Secret: your `GITHUB_WEBHOOK_SECRET`
90
+ - Events: Pull requests, Pushes, Issues
91
+
92
+ ### 6. Start
93
+
94
+ ```bash
95
+ npm run dev # development with hot reload
96
+ npm start # production
97
+ ```
98
+
99
+ Server starts on port 4000. Webhook endpoint: `POST /webhooks/github`. Health check: `GET /health`.
100
+
101
+ ## Development
102
+
103
+ ```bash
104
+ npm test # run all tests
105
+ npm run test:watch # watch mode
106
+ npm run test:coverage # with coverage report
107
+ npm run build # TypeScript compile
108
+ npm run lint # ESLint
109
+ npx jest src/handlers/pr.test.ts # single test file
110
+ ```
111
+
112
+ **Coverage thresholds:** 80% minimum on statements, branches, functions, lines (currently ~94%).
113
+
114
+ See [DEVELOPMENT_RULES.md](DEVELOPMENT_RULES.md) for layer boundaries, TDD approach, and Claude prompt rules.
115
+
116
+ ## Architecture
117
+
118
+ ```
119
+ src/
120
+ server/ Express webhook server — HMAC verification, routing
121
+ handlers/ Parse GitHub events, decide what to generate
122
+ processors/ Claude AI — diff analysis, doc generation
123
+ notion/ Notion API client — idempotent read/write
124
+ github/ Octokit — diffs, changed files, issue creation
125
+ watcher/ Cron polling — Notion tasks → GitHub Issues
126
+ types/ Shared TypeScript interfaces
127
+ __fixtures__/ Test fixtures — GitHub event payloads, Notion responses
128
+ scripts/
129
+ setup-notion.ts One-time Notion workspace creation
130
+ landing/
131
+ index.html Standalone marketing page (open in browser)
132
+ ```
133
+
134
+ **Key design decisions:**
135
+ - Webhook server always returns `200` to GitHub — no retries, no duplicates
136
+ - All Notion writes use `createOrUpdatePage()` keyed by GitHub external ID — fully idempotent
137
+ - Claude receives only relevant diff portions (lock files stripped, 200-line file cap)
138
+ - Notion watcher uses `Promise.allSettled()` — one failing task never stops the batch
139
+
140
+ ## Tech Stack
141
+
142
+ | Layer | Technology |
143
+ |---|---|
144
+ | Runtime | Node.js 22 + TypeScript |
145
+ | Web server | Express.js |
146
+ | AI | Claude Sonnet 4.6 (`@anthropic-ai/sdk`) |
147
+ | GitHub | Octokit REST + `@octokit/webhooks` |
148
+ | Notion | `@notionhq/client` |
149
+ | Testing | Jest + ts-jest + supertest |
150
+ | CI/CD | GitHub Actions |
151
+
152
+ ## Environment Variables
153
+
154
+ See [`.env.example`](.env.example) for the full list. Required:
155
+
156
+ ```
157
+ GITHUB_WEBHOOK_SECRET Webhook HMAC secret
158
+ GITHUB_TOKEN Personal access token (repo scope)
159
+ GITHUB_OWNER Org or username
160
+ GITHUB_REPO Repository name
161
+ NOTION_TOKEN Notion integration token
162
+ NOTION_DATABASE_* 5 database IDs (output of setup:notion)
163
+ ANTHROPIC_API_KEY Claude API key
164
+ PORT Default: 4000
165
+ ```
166
+
167
+ ## Landing Page
168
+
169
+ Open `landing/index.html` directly in a browser — no server needed.
170
+
171
+ Dark + neon design, fully responsive (desktop + mobile). Sections: hero with live pipeline diagram, stats, how it works, features, terminal setup, architecture, Notion databases, CTA.
172
+
173
+ ---
174
+
175
+ Built with [Claude Sonnet 4.6](https://anthropic.com) + [Notion MCP](https://developers.notion.com) · Notion MCP Challenge 2026
@@ -0,0 +1,11 @@
1
+ import type { PullRequestEvent, PushEvent, IssueEvent, NotionTask } from '../types';
2
+ export declare const prMergedToMain: PullRequestEvent;
3
+ export declare const prOpened: PullRequestEvent;
4
+ export declare const pushToMain: PushEvent;
5
+ export declare const pushWithApiChanges: PushEvent;
6
+ export declare const pushWithInfraChanges: PushEvent;
7
+ export declare const issueOpened: IssueEvent;
8
+ export declare const issueClosed: IssueEvent;
9
+ export declare const notionTaskPendingSync: NotionTask;
10
+ export declare const sampleDiff: string;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/__fixtures__/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAIpF,eAAO,MAAM,cAAc,EAAE,gBAiC5B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,gBAStB,CAAC;AAIF,eAAO,MAAM,UAAU,EAAE,SA6BxB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,SAShC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,SAUlC,CAAC;AAIF,eAAO,MAAM,WAAW,EAAE,UAqBzB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,UAIzB,CAAC;AAIF,eAAO,MAAM,qBAAqB,EAAE,UAOnC,CAAC;AAIF,eAAO,MAAM,UAAU,QAoBf,CAAC"}
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sampleDiff = exports.notionTaskPendingSync = exports.issueClosed = exports.issueOpened = exports.pushWithInfraChanges = exports.pushWithApiChanges = exports.pushToMain = exports.prOpened = exports.prMergedToMain = void 0;
4
+ // ── Pull Request Fixtures ────────────────────────────────────────────────────
5
+ exports.prMergedToMain = {
6
+ action: 'closed',
7
+ number: 42,
8
+ pull_request: {
9
+ id: 1001,
10
+ number: 42,
11
+ title: 'feat: add user authentication with JWT',
12
+ body: 'Implements JWT-based auth. Adds /auth/login and /auth/refresh endpoints.',
13
+ state: 'closed',
14
+ merged: true,
15
+ merge_commit_sha: 'abc123def456',
16
+ base: { ref: 'main', sha: 'base-sha-123' },
17
+ head: { ref: 'feat/jwt-auth', sha: 'head-sha-456' },
18
+ user: { login: 'octocat' },
19
+ html_url: 'https://github.com/test-owner/test-repo/pull/42',
20
+ diff_url: 'https://github.com/test-owner/test-repo/pull/42.diff',
21
+ patch_url: 'https://github.com/test-owner/test-repo/pull/42.patch',
22
+ additions: 312,
23
+ deletions: 45,
24
+ changed_files: 8,
25
+ },
26
+ repository: {
27
+ id: 9001,
28
+ name: 'test-repo',
29
+ full_name: 'test-owner/test-repo',
30
+ html_url: 'https://github.com/test-owner/test-repo',
31
+ default_branch: 'main',
32
+ },
33
+ sender: {
34
+ login: 'octocat',
35
+ avatar_url: 'https://github.com/octocat.png',
36
+ html_url: 'https://github.com/octocat',
37
+ },
38
+ };
39
+ exports.prOpened = {
40
+ ...exports.prMergedToMain,
41
+ action: 'opened',
42
+ pull_request: {
43
+ ...exports.prMergedToMain.pull_request,
44
+ state: 'open',
45
+ merged: false,
46
+ merge_commit_sha: null,
47
+ },
48
+ };
49
+ // ── Push Fixtures ────────────────────────────────────────────────────────────
50
+ exports.pushToMain = {
51
+ ref: 'refs/heads/main',
52
+ before: 'before-sha-111',
53
+ after: 'after-sha-222',
54
+ commits: [
55
+ {
56
+ id: 'after-sha-222',
57
+ message: 'feat: add authentication endpoints',
58
+ timestamp: '2026-03-15T10:00:00Z',
59
+ url: 'https://github.com/test-owner/test-repo/commit/after-sha-222',
60
+ author: { name: 'Octocat', email: 'octocat@github.com' },
61
+ added: ['src/routes/auth.ts'],
62
+ removed: [],
63
+ modified: ['src/index.ts'],
64
+ },
65
+ ],
66
+ repository: {
67
+ id: 9001,
68
+ name: 'test-repo',
69
+ full_name: 'test-owner/test-repo',
70
+ html_url: 'https://github.com/test-owner/test-repo',
71
+ default_branch: 'main',
72
+ },
73
+ pusher: { name: 'octocat', email: 'octocat@github.com' },
74
+ sender: {
75
+ login: 'octocat',
76
+ avatar_url: 'https://github.com/octocat.png',
77
+ html_url: 'https://github.com/octocat',
78
+ },
79
+ };
80
+ exports.pushWithApiChanges = {
81
+ ...exports.pushToMain,
82
+ commits: [
83
+ {
84
+ ...exports.pushToMain.commits[0],
85
+ added: ['src/routes/users.ts'],
86
+ modified: ['src/routes/auth.ts', 'swagger.yaml'],
87
+ },
88
+ ],
89
+ };
90
+ exports.pushWithInfraChanges = {
91
+ ...exports.pushToMain,
92
+ commits: [
93
+ {
94
+ ...exports.pushToMain.commits[0],
95
+ message: 'chore: update Dockerfile and k8s deployment',
96
+ added: ['k8s/deployment.yaml'],
97
+ modified: ['Dockerfile'],
98
+ },
99
+ ],
100
+ };
101
+ // ── Issue Fixtures ───────────────────────────────────────────────────────────
102
+ exports.issueOpened = {
103
+ action: 'opened',
104
+ issue: {
105
+ id: 2001,
106
+ number: 15,
107
+ title: 'Bug: login fails with special characters in password',
108
+ body: 'When the password contains special characters like @#$, login returns 500.',
109
+ state: 'open',
110
+ html_url: 'https://github.com/test-owner/test-repo/issues/15',
111
+ user: { login: 'octocat', avatar_url: '', html_url: '' },
112
+ labels: [{ name: 'bug', color: 'd73a4a' }],
113
+ assignees: [],
114
+ },
115
+ repository: {
116
+ id: 9001,
117
+ name: 'test-repo',
118
+ full_name: 'test-owner/test-repo',
119
+ html_url: 'https://github.com/test-owner/test-repo',
120
+ default_branch: 'main',
121
+ },
122
+ sender: { login: 'octocat', avatar_url: '', html_url: '' },
123
+ };
124
+ exports.issueClosed = {
125
+ ...exports.issueOpened,
126
+ action: 'closed',
127
+ issue: { ...exports.issueOpened.issue, state: 'closed' },
128
+ };
129
+ // ── Notion Task Fixtures ─────────────────────────────────────────────────────
130
+ exports.notionTaskPendingSync = {
131
+ id: 'notion-page-id-abc123',
132
+ title: 'Implement rate limiting on API endpoints',
133
+ body: 'We need to add rate limiting to prevent abuse. Use express-rate-limit.',
134
+ labels: ['enhancement', 'backend'],
135
+ assignees: ['octocat'],
136
+ githubSync: true,
137
+ };
138
+ // ── GitHub API Response Fixtures ─────────────────────────────────────────────
139
+ exports.sampleDiff = `
140
+ diff --git a/src/routes/auth.ts b/src/routes/auth.ts
141
+ new file mode 100644
142
+ index 0000000..1234567
143
+ --- /dev/null
144
+ +++ b/src/routes/auth.ts
145
+ @@ -0,0 +1,45 @@
146
+ +import { Router } from 'express';
147
+ +import jwt from 'jsonwebtoken';
148
+ +
149
+ +const router = Router();
150
+ +
151
+ +router.post('/login', async (req, res) => {
152
+ + const { email, password } = req.body;
153
+ + // authenticate user
154
+ + const token = jwt.sign({ email }, process.env.JWT_SECRET!, { expiresIn: '1h' });
155
+ + res.json({ token });
156
+ +});
157
+ +
158
+ +export default router;
159
+ `.trim();
160
+ //# sourceMappingURL=index.js.map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ET: string;
3
+ GITHUB_TOKEN: string;
4
+ GITHUB_OWNER: string;
5
+ GITHUB_REPO: string;
6
+ NOTION_TOKEN: string;
7
+ NOTION_DATABASE_ADR: string;
8
+ NOTION_DATABASE_CHANGELOG: string;
9
+ NOTION_DATABASE_API_REF: string;
10
+ NOTION_DATABASE_RUNBOOKS: string;
11
+ NOTION_DATABASE_TASKS: string;
12
+ ANTHROPIC_API_KEY: string;
13
+ PORT: number;
14
+ POLL_INTERVAL_SECONDS: number;
15
+ };
16
+ export type Config = typeof config;
17
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;CAAgB,CAAC;AAEpC,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.config = void 0;
7
+ const zod_1 = require("zod");
8
+ const dotenv_1 = __importDefault(require("dotenv"));
9
+ dotenv_1.default.config();
10
+ const envSchema = zod_1.z.object({
11
+ GITHUB_WEBHOOK_SECRET: zod_1.z.string().min(1, 'GITHUB_WEBHOOK_SECRET is required'),
12
+ GITHUB_TOKEN: zod_1.z.string().min(1, 'GITHUB_TOKEN is required'),
13
+ GITHUB_OWNER: zod_1.z.string().min(1, 'GITHUB_OWNER is required'),
14
+ GITHUB_REPO: zod_1.z.string().min(1, 'GITHUB_REPO is required'),
15
+ NOTION_TOKEN: zod_1.z.string().min(1, 'NOTION_TOKEN is required'),
16
+ NOTION_DATABASE_ADR: zod_1.z.string().min(1, 'NOTION_DATABASE_ADR is required'),
17
+ NOTION_DATABASE_CHANGELOG: zod_1.z.string().min(1, 'NOTION_DATABASE_CHANGELOG is required'),
18
+ NOTION_DATABASE_API_REF: zod_1.z.string().min(1, 'NOTION_DATABASE_API_REF is required'),
19
+ NOTION_DATABASE_RUNBOOKS: zod_1.z.string().min(1, 'NOTION_DATABASE_RUNBOOKS is required'),
20
+ NOTION_DATABASE_TASKS: zod_1.z.string().min(1, 'NOTION_DATABASE_TASKS is required'),
21
+ ANTHROPIC_API_KEY: zod_1.z.string().min(1, 'ANTHROPIC_API_KEY is required'),
22
+ PORT: zod_1.z.string().default('3000').transform(Number),
23
+ POLL_INTERVAL_SECONDS: zod_1.z.string().default('60').transform(Number),
24
+ });
25
+ function validateEnv() {
26
+ const result = envSchema.safeParse(process.env);
27
+ if (!result.success) {
28
+ console.error('Invalid environment variables:');
29
+ result.error.issues.forEach((issue) => {
30
+ console.error(` ${issue.path.join('.')}: ${issue.message}`);
31
+ });
32
+ process.exit(1);
33
+ }
34
+ return result.data;
35
+ }
36
+ exports.config = validateEnv();
37
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;AAAA,6BAAwB;AACxB,oDAA4B;AAE5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,SAAS,GAAG,OAAC,CAAC,MAAM,CAAC;IACzB,qBAAqB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,mCAAmC,CAAC;IAC7E,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,0BAA0B,CAAC;IAC3D,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,0BAA0B,CAAC;IAC3D,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,yBAAyB,CAAC;IACzD,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,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AI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAEY,QAAA,MAAM,GAAG,WAAW,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { ChangedFile } from '../types';
2
+ declare const octokit: import("@octokit/core").Octokit & {
3
+ paginate: import("@octokit/plugin-paginate-rest").PaginateInterface;
4
+ } & import("@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types").RestEndpointMethods & import("@octokit/plugin-rest-endpoint-methods").Api;
5
+ /**
6
+ * Fetch the full unified diff for a pull request.
7
+ */
8
+ export declare function getPRDiff(owner: string, repo: string, prNumber: number): Promise<string>;
9
+ /**
10
+ * Get the list of files changed in a specific commit or ref range.
11
+ */
12
+ export declare function getChangedFiles(owner: string, repo: string, ref: string): Promise<ChangedFile[]>;
13
+ /**
14
+ * Get files changed in a pull request.
15
+ */
16
+ export declare function getPRChangedFiles(owner: string, repo: string, prNumber: number): Promise<ChangedFile[]>;
17
+ /**
18
+ * Create a GitHub issue.
19
+ */
20
+ export declare function createIssue(owner: string, repo: string, title: string, body: string, labels: string[]): Promise<{
21
+ number: number;
22
+ url: string;
23
+ }>;
24
+ /**
25
+ * Update a GitHub issue (e.g., close it or add a comment).
26
+ */
27
+ export declare function updateIssueState(owner: string, repo: string, issueNumber: number, state: 'open' | 'closed'): Promise<void>;
28
+ export { octokit };
29
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/github/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,QAAA,MAAM,OAAO;;+JAEX,CAAC;AAEH;;GAEG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAc9F;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAoBtG;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAoB7G;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EAAE,GACf,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAkB1C;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,GAAG,QAAQ,GACvB,OAAO,CAAC,IAAI,CAAC,CAYf;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.octokit = void 0;
4
+ exports.getPRDiff = getPRDiff;
5
+ exports.getChangedFiles = getChangedFiles;
6
+ exports.getPRChangedFiles = getPRChangedFiles;
7
+ exports.createIssue = createIssue;
8
+ exports.updateIssueState = updateIssueState;
9
+ const rest_1 = require("@octokit/rest");
10
+ const config_1 = require("../config");
11
+ const octokit = new rest_1.Octokit({
12
+ auth: config_1.config.GITHUB_TOKEN,
13
+ });
14
+ exports.octokit = octokit;
15
+ /**
16
+ * Fetch the full unified diff for a pull request.
17
+ */
18
+ async function getPRDiff(owner, repo, prNumber) {
19
+ try {
20
+ const response = await octokit.rest.pulls.get({
21
+ owner,
22
+ repo,
23
+ pull_number: prNumber,
24
+ mediaType: { format: 'diff' },
25
+ });
26
+ // The diff is returned as a string when mediaType.format is 'diff'
27
+ return response.data;
28
+ }
29
+ catch (err) {
30
+ const error = err;
31
+ throw new Error(`Failed to fetch PR diff for #${prNumber}: ${error.message}`);
32
+ }
33
+ }
34
+ /**
35
+ * Get the list of files changed in a specific commit or ref range.
36
+ */
37
+ async function getChangedFiles(owner, repo, ref) {
38
+ try {
39
+ const response = await octokit.rest.repos.getCommit({
40
+ owner,
41
+ repo,
42
+ ref,
43
+ });
44
+ const files = response.data.files ?? [];
45
+ return files.map((file) => ({
46
+ filename: file.filename,
47
+ status: file.status,
48
+ additions: file.additions,
49
+ deletions: file.deletions,
50
+ patch: file.patch,
51
+ }));
52
+ }
53
+ catch (err) {
54
+ const error = err;
55
+ throw new Error(`Failed to get changed files for ref ${ref}: ${error.message}`);
56
+ }
57
+ }
58
+ /**
59
+ * Get files changed in a pull request.
60
+ */
61
+ async function getPRChangedFiles(owner, repo, prNumber) {
62
+ try {
63
+ const response = await octokit.rest.pulls.listFiles({
64
+ owner,
65
+ repo,
66
+ pull_number: prNumber,
67
+ per_page: 100,
68
+ });
69
+ return response.data.map((file) => ({
70
+ filename: file.filename,
71
+ status: file.status,
72
+ additions: file.additions,
73
+ deletions: file.deletions,
74
+ patch: file.patch,
75
+ }));
76
+ }
77
+ catch (err) {
78
+ const error = err;
79
+ throw new Error(`Failed to get PR files for #${prNumber}: ${error.message}`);
80
+ }
81
+ }
82
+ /**
83
+ * Create a GitHub issue.
84
+ */
85
+ async function createIssue(owner, repo, title, body, labels) {
86
+ try {
87
+ const response = await octokit.rest.issues.create({
88
+ owner,
89
+ repo,
90
+ title,
91
+ body,
92
+ labels,
93
+ });
94
+ return {
95
+ number: response.data.number,
96
+ url: response.data.html_url,
97
+ };
98
+ }
99
+ catch (err) {
100
+ const error = err;
101
+ throw new Error(`Failed to create GitHub issue "${title}": ${error.message}`);
102
+ }
103
+ }
104
+ /**
105
+ * Update a GitHub issue (e.g., close it or add a comment).
106
+ */
107
+ async function updateIssueState(owner, repo, issueNumber, state) {
108
+ try {
109
+ await octokit.rest.issues.update({
110
+ owner,
111
+ repo,
112
+ issue_number: issueNumber,
113
+ state,
114
+ });
115
+ }
116
+ catch (err) {
117
+ const error = err;
118
+ throw new Error(`Failed to update issue #${issueNumber} state: ${error.message}`);
119
+ }
120
+ }
121
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/github/client.ts"],"names":[],"mappings":";;;AAWA,8BAcC;AAKD,0CAoBC;AAKD,8CAoBC;AAKD,kCAwBC;AAKD,4CAiBC;AA9HD,wCAAwC;AACxC,sCAAmC;AAGnC,MAAM,OAAO,GAAG,IAAI,cAAO,CAAC;IAC1B,IAAI,EAAE,eAAM,CAAC,YAAY;CAC1B,CAAC,CAAC;AA0HM,0BAAO;AAxHhB;;GAEG;AACI,KAAK,UAAU,SAAS,CAAC,KAAa,EAAE,IAAY,EAAE,QAAgB;IAC3E,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;YAC5C,KAAK;YACL,IAAI;YACJ,WAAW,EAAE,QAAQ;YACrB,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;SAC9B,CAAC,CAAC;QACH,mEAAmE;QACnE,OAAO,QAAQ,CAAC,IAAyB,CAAC;IAC5C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,GAAY,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,gCAAgC,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,eAAe,CAAC,KAAa,EAAE,IAAY,EAAE,GAAW;IAC5E,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,OAA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3
+ import { handleIssueEvent } from './issue';
4
+ /**
5
+ * Route a GitHub webhook event to the appropriate handler.
6
+ * @param eventType - Value of the X-GitHub-Event header
7
+ * @param payload - Parsed JSON payload from the webhook body
8
+ */
9
+ export declare function routeEvent(eventType: string, payload: unknown): Promise<void>;
10
+ export { handlePullRequestEvent, handlePushEvent, handleIssueEvent };
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBnF;AAED,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleIssueEvent = exports.handlePushEvent = exports.handlePullRequestEvent = void 0;
4
+ exports.routeEvent = routeEvent;
5
+ const pr_1 = require("./pr");
6
+ Object.defineProperty(exports, "handlePullRequestEvent", { enumerable: true, get: function () { return pr_1.handlePullRequestEvent; } });
7
+ const push_1 = require("./push");
8
+ Object.defineProperty(exports, "handlePushEvent", { enumerable: true, get: function () { return push_1.handlePushEvent; } });
9
+ const issue_1 = require("./issue");
10
+ Object.defineProperty(exports, "handleIssueEvent", { enumerable: true, get: function () { return issue_1.handleIssueEvent; } });
11
+ /**
12
+ * Route a GitHub webhook event to the appropriate handler.
13
+ * @param eventType - Value of the X-GitHub-Event header
14
+ * @param payload - Parsed JSON payload from the webhook body
15
+ */
16
+ async function routeEvent(eventType, payload) {
17
+ console.log(`[Router] Routing event: ${eventType}`);
18
+ switch (eventType) {
19
+ case 'pull_request':
20
+ await (0, pr_1.handlePullRequestEvent)(payload);
21
+ break;
22
+ case 'push':
23
+ await (0, push_1.handlePushEvent)(payload);
24
+ break;
25
+ case 'issues':
26
+ await (0, issue_1.handleIssueEvent)(payload);
27
+ break;
28
+ case 'ping':
29
+ console.log('[Router] GitHub ping received — webhook configured successfully');
30
+ break;
31
+ default:
32
+ console.log(`[Router] Unhandled event type: ${eventType}`);
33
+ }
34
+ }
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":";;;AAUA,gCAuBC;AAhCD,6BAA8C;AAkCrC,uGAlCA,2BAAsB,OAkCA;AAjC/B,iCAAyC;AAiCR,gGAjCxB,sBAAe,OAiCwB;AAhChD,mCAA2C;AAgCO,iGAhCzC,wBAAgB,OAgCyC;AA9BlE;;;;GAIG;AACI,KAAK,UAAU,UAAU,CAAC,SAAiB,EAAE,OAAgB;IAClE,OAAO,CAAC,GAAG,CAAC,2BAA2B,SAAS,EAAE,CAAC,CAAC;IAEpD,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,cAAc;YACjB,MAAM,IAAA,2BAAsB,EAAC,OAA2B,CAAC,CAAC;YAC1D,MAAM;QAER,KAAK,MAAM;YACT,MAAM,IAAA,sBAAe,EAAC,OAAoB,CAAC,CAAC;YAC5C,MAAM;QAER,KAAK,QAAQ;YACX,MAAM,IAAA,wBAAgB,EAAC,OAAqB,CAAC,CAAC;YAC9C,MAAM;QAER,KAAK,MAAM;YACT,OAAO,CAAC,GAAG,CAAC,iEAAiE,CAAC,CAAC;YAC/E,MAAM;QAER;YACE,OAAO,CAAC,GAAG,CAAC,kCAAkC,SAAS,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { IssueEvent } from '../types';
2
+ /**
3
+ * Handle GitHub issue events.
4
+ */
5
+ export declare function handleIssueEvent(payload: IssueEvent): Promise<void>;
6
+ //# sourceMappingURL=issue.d.ts.map