@ghcrawl/api-contract 0.1.0 → 0.1.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,gBAAgB,sCAAoC,CAAC;AAClE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,gBAAgB,8CAA4C,CAAC;AAC1E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAO3B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE7D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAavB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAErD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;EAQ/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAErC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,iBAAiB,8CAA4C,CAAC;AAC3E,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;EAK9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;EAK/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,174 @@
1
+ import { z } from 'zod';
2
+ export const threadKindSchema = z.enum(['issue', 'pull_request']);
3
+ export const searchModeSchema = z.enum(['keyword', 'semantic', 'hybrid']);
4
+ export const repositorySchema = z.object({
5
+ id: z.number().int().positive(),
6
+ owner: z.string(),
7
+ name: z.string(),
8
+ fullName: z.string(),
9
+ githubRepoId: z.string().nullable(),
10
+ updatedAt: z.string(),
11
+ });
12
+ export const threadSchema = z.object({
13
+ id: z.number().int().positive(),
14
+ repoId: z.number().int().positive(),
15
+ number: z.number().int().positive(),
16
+ kind: threadKindSchema,
17
+ state: z.string(),
18
+ title: z.string(),
19
+ body: z.string().nullable(),
20
+ authorLogin: z.string().nullable(),
21
+ htmlUrl: z.string().url(),
22
+ labels: z.array(z.string()),
23
+ updatedAtGh: z.string().nullable(),
24
+ clusterId: z.number().int().positive().nullable().optional(),
25
+ });
26
+ export const healthResponseSchema = z.object({
27
+ ok: z.boolean(),
28
+ configPath: z.string(),
29
+ configFileExists: z.boolean(),
30
+ dbPath: z.string(),
31
+ apiPort: z.number().int().positive(),
32
+ githubConfigured: z.boolean(),
33
+ openaiConfigured: z.boolean(),
34
+ });
35
+ export const repositoriesResponseSchema = z.object({
36
+ repositories: z.array(repositorySchema),
37
+ });
38
+ export const threadsResponseSchema = z.object({
39
+ repository: repositorySchema,
40
+ threads: z.array(threadSchema),
41
+ });
42
+ export const neighborSchema = z.object({
43
+ threadId: z.number().int().positive(),
44
+ number: z.number().int().positive(),
45
+ kind: threadKindSchema,
46
+ title: z.string(),
47
+ score: z.number(),
48
+ });
49
+ export const searchHitSchema = z.object({
50
+ thread: threadSchema,
51
+ keywordScore: z.number().nullable(),
52
+ semanticScore: z.number().nullable(),
53
+ hybridScore: z.number(),
54
+ neighbors: z.array(neighborSchema).default([]),
55
+ });
56
+ export const searchResponseSchema = z.object({
57
+ repository: repositorySchema,
58
+ query: z.string(),
59
+ mode: searchModeSchema,
60
+ hits: z.array(searchHitSchema),
61
+ });
62
+ export const neighborsResponseSchema = z.object({
63
+ repository: repositorySchema,
64
+ thread: threadSchema,
65
+ neighbors: z.array(neighborSchema),
66
+ });
67
+ export const clusterMemberSchema = z.object({
68
+ threadId: z.number().int().positive(),
69
+ number: z.number().int().positive(),
70
+ kind: threadKindSchema,
71
+ title: z.string(),
72
+ scoreToRepresentative: z.number().nullable(),
73
+ });
74
+ export const clusterSchema = z.object({
75
+ id: z.number().int().positive(),
76
+ repoId: z.number().int().positive(),
77
+ representativeThreadId: z.number().int().positive().nullable(),
78
+ memberCount: z.number().int().nonnegative(),
79
+ members: z.array(clusterMemberSchema),
80
+ });
81
+ export const clustersResponseSchema = z.object({
82
+ repository: repositorySchema,
83
+ clusters: z.array(clusterSchema),
84
+ });
85
+ export const repoStatsSchema = z.object({
86
+ openIssueCount: z.number().int().nonnegative(),
87
+ openPullRequestCount: z.number().int().nonnegative(),
88
+ lastGithubReconciliationAt: z.string().nullable(),
89
+ lastEmbedRefreshAt: z.string().nullable(),
90
+ staleEmbedThreadCount: z.number().int().nonnegative(),
91
+ staleEmbedSourceCount: z.number().int().nonnegative(),
92
+ latestClusterRunId: z.number().int().positive().nullable(),
93
+ latestClusterRunFinishedAt: z.string().nullable(),
94
+ });
95
+ export const clusterSummarySchema = z.object({
96
+ clusterId: z.number().int().positive(),
97
+ displayTitle: z.string(),
98
+ totalCount: z.number().int().nonnegative(),
99
+ issueCount: z.number().int().nonnegative(),
100
+ pullRequestCount: z.number().int().nonnegative(),
101
+ latestUpdatedAt: z.string().nullable(),
102
+ representativeThreadId: z.number().int().positive().nullable(),
103
+ representativeNumber: z.number().int().positive().nullable(),
104
+ representativeKind: threadKindSchema.nullable(),
105
+ });
106
+ export const clusterSummariesResponseSchema = z.object({
107
+ repository: repositorySchema,
108
+ stats: repoStatsSchema,
109
+ clusters: z.array(clusterSummarySchema),
110
+ });
111
+ export const threadSummariesSchema = z.object({
112
+ problem_summary: z.string().optional(),
113
+ solution_summary: z.string().optional(),
114
+ maintainer_signal_summary: z.string().optional(),
115
+ dedupe_summary: z.string().optional(),
116
+ });
117
+ export const clusterThreadDumpSchema = z.object({
118
+ thread: threadSchema,
119
+ bodySnippet: z.string().nullable(),
120
+ summaries: threadSummariesSchema,
121
+ });
122
+ export const clusterDetailResponseSchema = z.object({
123
+ repository: repositorySchema,
124
+ stats: repoStatsSchema,
125
+ cluster: clusterSummarySchema,
126
+ members: z.array(clusterThreadDumpSchema),
127
+ });
128
+ export const syncResultSchema = z.object({
129
+ runId: z.number().int().positive(),
130
+ threadsSynced: z.number().int().nonnegative(),
131
+ commentsSynced: z.number().int().nonnegative(),
132
+ threadsClosed: z.number().int().nonnegative(),
133
+ });
134
+ export const embedResultSchema = z.object({
135
+ runId: z.number().int().positive(),
136
+ embedded: z.number().int().nonnegative(),
137
+ });
138
+ export const clusterResultSchema = z.object({
139
+ runId: z.number().int().positive(),
140
+ edges: z.number().int().nonnegative(),
141
+ clusters: z.number().int().nonnegative(),
142
+ });
143
+ export const refreshRequestSchema = z.object({
144
+ owner: z.string(),
145
+ repo: z.string(),
146
+ sync: z.boolean().optional(),
147
+ embed: z.boolean().optional(),
148
+ cluster: z.boolean().optional(),
149
+ });
150
+ export const refreshResponseSchema = z.object({
151
+ repository: repositorySchema,
152
+ selected: z.object({
153
+ sync: z.boolean(),
154
+ embed: z.boolean(),
155
+ cluster: z.boolean(),
156
+ }),
157
+ sync: syncResultSchema.nullable(),
158
+ embed: embedResultSchema.nullable(),
159
+ cluster: clusterResultSchema.nullable(),
160
+ });
161
+ export const rerunActionSchema = z.enum(['summarize', 'embed', 'cluster']);
162
+ export const actionRequestSchema = z.object({
163
+ owner: z.string(),
164
+ repo: z.string(),
165
+ action: rerunActionSchema,
166
+ threadNumber: z.number().int().positive().optional(),
167
+ });
168
+ export const actionResponseSchema = z.object({
169
+ ok: z.boolean(),
170
+ action: rerunActionSchema,
171
+ runId: z.number().int().positive().nullable(),
172
+ message: z.string(),
173
+ });
174
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;AAGlE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAG1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EA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MAAM,EAAE,iBAAiB;IACzB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC7C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './client.js';
2
+ export * from './contracts.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from './client.js';
2
2
  export * from './contracts.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghcrawl/api-contract",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "ghcrawl shared transport contracts and validation schemas",
6
6
  "author": "PwrDrvr LLC <harold@pwrdrvr.com>",
@@ -23,21 +23,22 @@
23
23
  "node": ">=22"
24
24
  },
25
25
  "files": [
26
- "src"
26
+ "dist"
27
27
  ],
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
31
  "exports": {
32
32
  ".": {
33
- "types": "./src/index.ts",
34
- "default": "./src/index.ts"
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.js"
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
38
  "zod": "^3.24.1"
39
39
  },
40
40
  "scripts": {
41
+ "build": "tsc -p tsconfig.build.json",
41
42
  "typecheck": "tsc -p tsconfig.json --noEmit",
42
43
  "test": "tsx --test src/*.test.ts src/**/*.test.ts"
43
44
  }
package/src/client.ts DELETED
@@ -1,135 +0,0 @@
1
- import {
2
- actionRequestSchema,
3
- actionResponseSchema,
4
- clusterDetailResponseSchema,
5
- clusterSummariesResponseSchema,
6
- clustersResponseSchema,
7
- healthResponseSchema,
8
- refreshRequestSchema,
9
- refreshResponseSchema,
10
- repositoriesResponseSchema,
11
- searchResponseSchema,
12
- threadsResponseSchema,
13
- type ActionRequest,
14
- type ActionResponse,
15
- type ClusterDetailResponse,
16
- type ClusterSummariesResponse,
17
- type ClustersResponse,
18
- type HealthResponse,
19
- type RefreshRequest,
20
- type RefreshResponse,
21
- type RepositoriesResponse,
22
- type SearchMode,
23
- type SearchResponse,
24
- type ThreadsResponse,
25
- } from './contracts.js';
26
-
27
- export type GitcrawlClient = {
28
- health: () => Promise<HealthResponse>;
29
- listRepositories: () => Promise<RepositoriesResponse>;
30
- listThreads: (params: { owner: string; repo: string; kind?: 'issue' | 'pull_request' }) => Promise<ThreadsResponse>;
31
- search: (params: { owner: string; repo: string; query: string; mode?: SearchMode }) => Promise<SearchResponse>;
32
- listClusters: (params: { owner: string; repo: string }) => Promise<ClustersResponse>;
33
- listClusterSummaries: (params: {
34
- owner: string;
35
- repo: string;
36
- minSize?: number;
37
- limit?: number;
38
- sort?: 'recent' | 'size';
39
- search?: string;
40
- }) => Promise<ClusterSummariesResponse>;
41
- getClusterDetail: (params: {
42
- owner: string;
43
- repo: string;
44
- clusterId: number;
45
- memberLimit?: number;
46
- bodyChars?: number;
47
- }) => Promise<ClusterDetailResponse>;
48
- refresh: (request: RefreshRequest) => Promise<RefreshResponse>;
49
- rerun: (request: ActionRequest) => Promise<ActionResponse>;
50
- };
51
-
52
- type FetchLike = typeof fetch;
53
-
54
- async function readJson<T>(res: Response, schema: { parse: (value: unknown) => T }): Promise<T> {
55
- if (!res.ok) {
56
- const text = await res.text().catch(() => '');
57
- throw new Error(`API request failed ${res.status} ${res.statusText}: ${text.slice(0, 2000)}`);
58
- }
59
- const value = (await res.json()) as unknown;
60
- return schema.parse(value);
61
- }
62
-
63
- export function createGitcrawlClient(baseUrl: string, fetchImpl: FetchLike = fetch): GitcrawlClient {
64
- const normalized = baseUrl.replace(/\/+$/, '');
65
-
66
- return {
67
- async health() {
68
- const res = await fetchImpl(`${normalized}/health`);
69
- return readJson(res, healthResponseSchema);
70
- },
71
- async listRepositories() {
72
- const res = await fetchImpl(`${normalized}/repositories`);
73
- return readJson(res, repositoriesResponseSchema);
74
- },
75
- async listThreads(params) {
76
- const search = new URLSearchParams({ owner: params.owner, repo: params.repo });
77
- if (params.kind) search.set('kind', params.kind);
78
- const res = await fetchImpl(`${normalized}/threads?${search.toString()}`);
79
- return readJson(res, threadsResponseSchema);
80
- },
81
- async search(params) {
82
- const search = new URLSearchParams({
83
- owner: params.owner,
84
- repo: params.repo,
85
- query: params.query,
86
- });
87
- if (params.mode) search.set('mode', params.mode);
88
- const res = await fetchImpl(`${normalized}/search?${search.toString()}`);
89
- return readJson(res, searchResponseSchema);
90
- },
91
- async listClusters(params) {
92
- const search = new URLSearchParams({ owner: params.owner, repo: params.repo });
93
- const res = await fetchImpl(`${normalized}/clusters?${search.toString()}`);
94
- return readJson(res, clustersResponseSchema);
95
- },
96
- async listClusterSummaries(params) {
97
- const search = new URLSearchParams({ owner: params.owner, repo: params.repo });
98
- if (params.minSize !== undefined) search.set('minSize', String(params.minSize));
99
- if (params.limit !== undefined) search.set('limit', String(params.limit));
100
- if (params.sort) search.set('sort', params.sort);
101
- if (params.search) search.set('search', params.search);
102
- const res = await fetchImpl(`${normalized}/cluster-summaries?${search.toString()}`);
103
- return readJson(res, clusterSummariesResponseSchema);
104
- },
105
- async getClusterDetail(params) {
106
- const search = new URLSearchParams({
107
- owner: params.owner,
108
- repo: params.repo,
109
- clusterId: String(params.clusterId),
110
- });
111
- if (params.memberLimit !== undefined) search.set('memberLimit', String(params.memberLimit));
112
- if (params.bodyChars !== undefined) search.set('bodyChars', String(params.bodyChars));
113
- const res = await fetchImpl(`${normalized}/cluster-detail?${search.toString()}`);
114
- return readJson(res, clusterDetailResponseSchema);
115
- },
116
- async refresh(request) {
117
- const body = refreshRequestSchema.parse(request);
118
- const res = await fetchImpl(`${normalized}/actions/refresh`, {
119
- method: 'POST',
120
- headers: { 'content-type': 'application/json' },
121
- body: JSON.stringify(body),
122
- });
123
- return readJson(res, refreshResponseSchema);
124
- },
125
- async rerun(request) {
126
- const body = actionRequestSchema.parse(request);
127
- const res = await fetchImpl(`${normalized}/actions/rerun`, {
128
- method: 'POST',
129
- headers: { 'content-type': 'application/json' },
130
- body: JSON.stringify(body),
131
- });
132
- return readJson(res, actionResponseSchema);
133
- },
134
- };
135
- }
@@ -1,85 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
-
4
- import { actionRequestSchema, healthResponseSchema, neighborsResponseSchema, searchResponseSchema } from './contracts.js';
5
-
6
- test('health schema accepts configured status payload', () => {
7
- const parsed = healthResponseSchema.parse({
8
- ok: true,
9
- configPath: '/Users/example/.config/ghcrawl/config.json',
10
- configFileExists: true,
11
- dbPath: 'data/ghcrawl.db',
12
- apiPort: 5179,
13
- githubConfigured: true,
14
- openaiConfigured: false,
15
- });
16
-
17
- assert.equal(parsed.apiPort, 5179);
18
- });
19
-
20
- test('search schema rejects invalid mode', () => {
21
- assert.throws(() =>
22
- searchResponseSchema.parse({
23
- repository: {
24
- id: 1,
25
- owner: 'openclaw',
26
- name: 'openclaw',
27
- fullName: 'openclaw/openclaw',
28
- githubRepoId: null,
29
- updatedAt: new Date().toISOString(),
30
- },
31
- query: 'panic',
32
- mode: 'invalid',
33
- hits: [],
34
- }),
35
- );
36
- });
37
-
38
- test('action request accepts optional thread number', () => {
39
- const parsed = actionRequestSchema.parse({
40
- owner: 'openclaw',
41
- repo: 'openclaw',
42
- action: 'summarize',
43
- threadNumber: 42,
44
- });
45
-
46
- assert.equal(parsed.threadNumber, 42);
47
- });
48
-
49
- test('neighbors schema accepts repository, source thread, and neighbor list', () => {
50
- const parsed = neighborsResponseSchema.parse({
51
- repository: {
52
- id: 1,
53
- owner: 'openclaw',
54
- name: 'openclaw',
55
- fullName: 'openclaw/openclaw',
56
- githubRepoId: null,
57
- updatedAt: new Date().toISOString(),
58
- },
59
- thread: {
60
- id: 10,
61
- repoId: 1,
62
- number: 42,
63
- kind: 'issue',
64
- state: 'open',
65
- title: 'Downloader hangs',
66
- body: 'The transfer never finishes.',
67
- authorLogin: 'alice',
68
- htmlUrl: 'https://github.com/openclaw/openclaw/issues/42',
69
- labels: ['bug'],
70
- updatedAtGh: new Date().toISOString(),
71
- clusterId: null,
72
- },
73
- neighbors: [
74
- {
75
- threadId: 11,
76
- number: 43,
77
- kind: 'pull_request',
78
- title: 'Fix downloader hang',
79
- score: 0.93,
80
- },
81
- ],
82
- });
83
-
84
- assert.equal(parsed.neighbors[0].number, 43);
85
- });