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
@@ -0,0 +1,216 @@
1
+ /**
2
+ * One-time setup script to create the required Notion databases.
3
+ * Run: npm run setup:notion
4
+ *
5
+ * Prerequisites:
6
+ * 1. Create a Notion integration at https://www.notion.so/my-integrations
7
+ * 2. Copy the integration token into NOTION_TOKEN in your .env
8
+ * 3. Create a parent page in Notion and share it with your integration
9
+ * 4. Set NOTION_PARENT_PAGE_ID in your .env (the page ID from the URL)
10
+ */
11
+
12
+ import 'dotenv/config';
13
+ import { Client } from '@notionhq/client';
14
+
15
+ const NOTION_TOKEN = process.env.NOTION_TOKEN;
16
+ const NOTION_PARENT_PAGE_ID = process.env.NOTION_PARENT_PAGE_ID;
17
+
18
+ if (!NOTION_TOKEN) {
19
+ console.error('ERROR: NOTION_TOKEN environment variable is required');
20
+ process.exit(1);
21
+ }
22
+
23
+ if (!NOTION_PARENT_PAGE_ID) {
24
+ console.error('ERROR: NOTION_PARENT_PAGE_ID environment variable is required');
25
+ console.error(' Set this to the ID of the Notion page where databases will be created.');
26
+ console.error(' You can find the page ID in the Notion page URL:');
27
+ console.error(' https://notion.so/Your-Page-<PAGE_ID>');
28
+ process.exit(1);
29
+ }
30
+
31
+ const notion = new Client({ auth: NOTION_TOKEN });
32
+
33
+ interface DatabaseSpec {
34
+ name: string;
35
+ envKey: string;
36
+ icon: string;
37
+ description: string;
38
+ properties: Record<string, unknown>;
39
+ }
40
+
41
+ const databases: DatabaseSpec[] = [
42
+ {
43
+ name: 'ADR — Architecture Decision Records',
44
+ envKey: 'NOTION_DATABASE_ADR',
45
+ icon: '🏛️',
46
+ description: 'Architectural decisions made during development',
47
+ properties: {
48
+ title: { title: {} },
49
+ github_pr_number: { rich_text: {} },
50
+ github_pr_url: { url: {} },
51
+ author: { rich_text: {} },
52
+ status: {
53
+ select: {
54
+ options: [
55
+ { name: 'Proposed', color: 'yellow' },
56
+ { name: 'Accepted', color: 'green' },
57
+ { name: 'Deprecated', color: 'red' },
58
+ { name: 'Superseded', color: 'gray' },
59
+ ],
60
+ },
61
+ },
62
+ created_at: { date: {} },
63
+ },
64
+ },
65
+ {
66
+ name: 'Changelog',
67
+ envKey: 'NOTION_DATABASE_CHANGELOG',
68
+ icon: '📋',
69
+ description: 'History of changes per PR/release',
70
+ properties: {
71
+ title: { title: {} },
72
+ github_pr_number: { rich_text: {} },
73
+ github_pr_url: { url: {} },
74
+ author: { rich_text: {} },
75
+ status: {
76
+ select: {
77
+ options: [
78
+ { name: 'open', color: 'blue' },
79
+ { name: 'merged', color: 'green' },
80
+ ],
81
+ },
82
+ },
83
+ merged_at: { date: {} },
84
+ },
85
+ },
86
+ {
87
+ name: 'API Reference',
88
+ envKey: 'NOTION_DATABASE_API_REF',
89
+ icon: '📡',
90
+ description: 'Auto-generated API documentation',
91
+ properties: {
92
+ title: { title: {} },
93
+ github_pr_number: { rich_text: {} },
94
+ github_pr_url: { url: {} },
95
+ last_updated: { date: {} },
96
+ changed_files: { rich_text: {} },
97
+ github_ref: { rich_text: {} },
98
+ },
99
+ },
100
+ {
101
+ name: 'Runbooks',
102
+ envKey: 'NOTION_DATABASE_RUNBOOKS',
103
+ icon: '📖',
104
+ description: 'Operational runbooks for infrastructure and deployments',
105
+ properties: {
106
+ title: { title: {} },
107
+ github_ref: { rich_text: {} },
108
+ changed_files: { rich_text: {} },
109
+ created_at: { date: {} },
110
+ status: {
111
+ select: {
112
+ options: [
113
+ { name: 'Active', color: 'green' },
114
+ { name: 'Outdated', color: 'red' },
115
+ { name: 'Draft', color: 'yellow' },
116
+ ],
117
+ },
118
+ },
119
+ },
120
+ },
121
+ {
122
+ name: 'Tasks',
123
+ envKey: 'NOTION_DATABASE_TASKS',
124
+ icon: '✅',
125
+ description: 'Engineering tasks synced bidirectionally with GitHub Issues',
126
+ properties: {
127
+ title: { title: {} },
128
+ github_issue_number: { number: {} },
129
+ github_issue_url: { url: {} },
130
+ github_sync: { checkbox: {} },
131
+ github_repo: { rich_text: {} },
132
+ status: {
133
+ select: {
134
+ options: [
135
+ { name: 'Open', color: 'blue' },
136
+ { name: 'In Progress', color: 'yellow' },
137
+ { name: 'Done', color: 'green' },
138
+ { name: 'Cancelled', color: 'gray' },
139
+ ],
140
+ },
141
+ },
142
+ body: { rich_text: {} },
143
+ labels: { multi_select: { options: [] } },
144
+ assignees: { rich_text: {} },
145
+ author: { rich_text: {} },
146
+ closed_at: { date: {} },
147
+ },
148
+ },
149
+ ];
150
+
151
+ async function createDatabase(spec: DatabaseSpec): Promise<string> {
152
+ const response = await notion.databases.create({
153
+ parent: { page_id: NOTION_PARENT_PAGE_ID! },
154
+ icon: { type: 'emoji', emoji: spec.icon as never },
155
+ title: [{ type: 'text', text: { content: spec.name } }],
156
+ properties: spec.properties as never,
157
+ });
158
+
159
+ return response.id;
160
+ }
161
+
162
+ async function main() {
163
+ console.log('');
164
+ console.log('='.repeat(60));
165
+ console.log(' Notion Database Setup — Engineering Intelligence Hub');
166
+ console.log('='.repeat(60));
167
+ console.log(` Parent page: ${NOTION_PARENT_PAGE_ID}`);
168
+ console.log('');
169
+
170
+ const results: Record<string, string> = {};
171
+
172
+ for (const spec of databases) {
173
+ process.stdout.write(` Creating "${spec.name}"...`);
174
+ try {
175
+ const id = await createDatabase(spec);
176
+ results[spec.envKey] = id;
177
+ console.log(` ✓ ${id}`);
178
+ } catch (err) {
179
+ const error = err as Error;
180
+ console.error(` ✗ FAILED: ${error.message}`);
181
+ console.error('');
182
+ console.error(' Common causes:');
183
+ console.error(' - The parent page is not shared with your integration');
184
+ console.error(' - Share the page: click "..." → "Add connections" → select your integration');
185
+ process.exit(1);
186
+ }
187
+ }
188
+
189
+ console.log('');
190
+ console.log('='.repeat(60));
191
+ console.log(' SUCCESS! Copy these values into your .env file:');
192
+ console.log('='.repeat(60));
193
+ console.log('');
194
+
195
+ for (const [key, value] of Object.entries(results)) {
196
+ console.log(`${key}=${value}`);
197
+ }
198
+
199
+ console.log('');
200
+ console.log('='.repeat(60));
201
+ console.log(' Next steps:');
202
+ console.log(' 1. Copy the values above into your .env file');
203
+ console.log(' 2. Configure your GitHub webhook:');
204
+ console.log(' - URL: https://your-server.com/webhooks/github');
205
+ console.log(' - Content type: application/json');
206
+ console.log(' - Events: Pull requests, Pushes, Issues');
207
+ console.log(' - Secret: same as GITHUB_WEBHOOK_SECRET in .env');
208
+ console.log(' 3. Start the server: npm run dev');
209
+ console.log('='.repeat(60));
210
+ console.log('');
211
+ }
212
+
213
+ main().catch((err) => {
214
+ console.error('Setup failed:', (err as Error).message);
215
+ process.exit(1);
216
+ });