@myrialabs/clopen 0.4.37 → 0.4.39
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 +2 -2
- package/backend/auth/permissions.ts +39 -0
- package/backend/bootstrap.ts +16 -0
- package/backend/chat/stream-manager.ts +1 -1
- package/backend/database/crypto/envelope.test.ts +93 -0
- package/backend/database/crypto/envelope.ts +127 -0
- package/backend/database/crypto/index.ts +22 -0
- package/backend/database/crypto/master-key.ts +129 -0
- package/backend/database/crypto/secret-columns.ts +151 -0
- package/backend/database/migrations/071_create_notes_tables.ts +90 -0
- package/backend/database/migrations/072_encrypt_stored_secrets.ts +107 -0
- package/backend/database/migrations/073_create_integration_tables.ts +119 -0
- package/backend/database/migrations/074_create_work_tables.ts +94 -0
- package/backend/database/migrations/075_create_deploy_bindings.ts +54 -0
- package/backend/database/migrations/076_remove_memory_code_graph.ts +229 -0
- package/backend/database/migrations/077_create_integration_db_links.ts +150 -0
- package/backend/database/migrations/index.ts +49 -0
- package/backend/database/queries/db-client-connection-queries.ts +42 -12
- package/backend/database/queries/deploy-queries.ts +124 -0
- package/backend/database/queries/engine-queries.ts +23 -10
- package/backend/database/queries/graph-queries.ts +291 -247
- package/backend/database/queries/index.ts +10 -1
- package/backend/database/queries/integration-db-link-queries.ts +168 -0
- package/backend/database/queries/integration-queries.ts +325 -0
- package/backend/database/queries/mcp-server-queries.ts +38 -11
- package/backend/database/queries/note-queries.test.ts +190 -0
- package/backend/database/queries/note-queries.ts +269 -0
- package/backend/database/queries/profile-queries.ts +1 -1
- package/backend/database/queries/ssh-connection-queries.ts +19 -8
- package/backend/database/queries/work-queries.ts +210 -0
- package/backend/db-client/integrations/index.ts +37 -0
- package/backend/db-client/integrations/links.ts +533 -0
- package/backend/db-client/integrations/projector.test.ts +280 -0
- package/backend/db-client/integrations/projector.ts +256 -0
- package/backend/db-client/integrations/supabase-service.ts +266 -0
- package/backend/db-client/providers/registry.ts +27 -0
- package/backend/db-client/providers/supabase/adapter.ts +500 -0
- package/backend/db-client/providers/supabase/api-types.ts +92 -0
- package/backend/db-client/providers/supabase/apply-migration.ts +104 -0
- package/backend/db-client/providers/supabase/client.ts +259 -0
- package/backend/db-client/providers/supabase/features.ts +502 -0
- package/backend/db-client/providers/supabase/local.test.ts +78 -0
- package/backend/db-client/providers/supabase/local.ts +137 -0
- package/backend/db-client/providers/types.ts +137 -0
- package/backend/deployments/bindings.test.ts +43 -0
- package/backend/deployments/bindings.ts +216 -0
- package/backend/deployments/index.ts +53 -0
- package/backend/deployments/log-streams.ts +214 -0
- package/backend/deployments/prompts.ts +70 -0
- package/backend/deployments/providers/vercel/adapter.ts +757 -0
- package/backend/deployments/providers/vercel/build-logs.test.ts +80 -0
- package/backend/deployments/providers/vercel/build-logs.ts +211 -0
- package/backend/deployments/providers/vercel/client.ts +203 -0
- package/backend/deployments/providers/vercel/list.test.ts +624 -0
- package/backend/deployments/providers/vercel/normalise.test.ts +115 -0
- package/backend/deployments/providers/vercel/normalise.ts +113 -0
- package/backend/deployments/providers/vercel/types.ts +104 -0
- package/backend/deployments/registry.ts +27 -0
- package/backend/deployments/service.ts +458 -0
- package/backend/deployments/types.ts +278 -0
- package/backend/engine/docs/artifacts.md +22 -9
- package/backend/files/os-clipboard.test.ts +209 -0
- package/backend/files/os-clipboard.ts +567 -0
- package/backend/http/integration-hooks.ts +42 -0
- package/backend/http/notes-images.test.ts +228 -0
- package/backend/http/notes-images.ts +196 -0
- package/backend/index.ts +13 -0
- package/backend/integrations/accounts.ts +229 -0
- package/backend/integrations/health.ts +146 -0
- package/backend/integrations/index.ts +36 -0
- package/backend/integrations/projections/index.ts +0 -0
- package/backend/integrations/projections/mcp-projector.test.ts +204 -0
- package/backend/integrations/projections/mcp-projector.ts +163 -0
- package/backend/integrations/projections/types.ts +63 -0
- package/backend/integrations/registry/define.ts +38 -0
- package/backend/integrations/registry/index.ts +60 -0
- package/backend/integrations/registry/providers/context7.ts +44 -0
- package/backend/integrations/registry/providers/firecrawl.ts +41 -0
- package/backend/integrations/registry/providers/github.ts +78 -0
- package/backend/integrations/registry/providers/supabase.ts +61 -0
- package/backend/integrations/registry/providers/vercel.ts +46 -0
- package/backend/integrations/registry/types.ts +96 -0
- package/backend/integrations/webhooks/gateway.ts +160 -0
- package/backend/integrations/webhooks/verify.ts +65 -0
- package/backend/mcp/README.md +25 -3
- package/backend/mcp/external/config.ts +35 -1
- package/backend/mcp/index.ts +1 -1
- package/backend/mcp/internal/config.ts +1 -1
- package/backend/mcp/internal/servers/memory-graph/description.ts +3 -3
- package/backend/mcp/internal/servers/memory-graph/runner.ts +4 -9
- package/backend/mcp/internal/servers/memory-graph/schema.ts +0 -4
- package/backend/memory/README.md +57 -34
- package/backend/memory/compose.test.ts +3 -3
- package/backend/memory/compose.ts +6 -9
- package/backend/memory/config.ts +0 -5
- package/backend/memory/consolidate.ts +1 -2
- package/backend/memory/context.test.ts +8 -54
- package/backend/memory/context.ts +19 -25
- package/backend/memory/extract/episodic.ts +10 -12
- package/backend/memory/extract/index.ts +23 -52
- package/backend/memory/extract/scheduler.ts +3 -6
- package/backend/memory/index.ts +6 -5
- package/backend/memory/invalidate.ts +36 -48
- package/backend/memory/layout.ts +319 -130
- package/backend/memory/retention.ts +12 -42
- package/backend/memory/retrieval.eval.test.ts +2 -2
- package/backend/memory/retrieval.test.ts +228 -183
- package/backend/memory/retrieval.ts +22 -21
- package/backend/memory/revise.test.ts +62 -116
- package/backend/memory/revise.ts +0 -1
- package/backend/memory/view.ts +8 -5
- package/backend/notes/access.test.ts +82 -0
- package/backend/notes/access.ts +27 -0
- package/backend/notes/storage.test.ts +77 -0
- package/backend/notes/storage.ts +114 -0
- package/backend/permissions/service.ts +2 -2
- package/backend/profiles/service.ts +1 -1
- package/backend/projects/project-cleanup.ts +6 -0
- package/backend/snapshot/helpers.ts +35 -41
- package/backend/snapshot/snapshot-service.ts +90 -0
- package/backend/snapshot/turn-changes.test.ts +163 -0
- package/backend/snapshot/turn-changes.ts +131 -0
- package/backend/work/bindings.ts +124 -0
- package/backend/work/index.ts +42 -0
- package/backend/work/prompts.ts +150 -0
- package/backend/work/providers/github/actions-logs.ts +180 -0
- package/backend/work/providers/github/adapter.test.ts +88 -0
- package/backend/work/providers/github/adapter.ts +1255 -0
- package/backend/work/providers/github/client.ts +280 -0
- package/backend/work/providers/github/list-range.test.ts +158 -0
- package/backend/work/providers/github/token-kind.test.ts +42 -0
- package/backend/work/pull-requests.ts +242 -0
- package/backend/work/registry.ts +27 -0
- package/backend/work/service.ts +436 -0
- package/backend/work/start-work.test.ts +71 -0
- package/backend/work/start-work.ts +232 -0
- package/backend/work/types.ts +180 -0
- package/backend/ws/db-client/accounts.ts +225 -0
- package/backend/ws/db-client/connections.ts +34 -3
- package/backend/ws/db-client/context.ts +37 -0
- package/backend/ws/db-client/index.ts +20 -1
- package/backend/ws/db-client/supabase.ts +188 -0
- package/backend/ws/deployments/actions.ts +360 -0
- package/backend/ws/deployments/context.ts +43 -0
- package/backend/ws/deployments/crud.ts +152 -0
- package/backend/ws/deployments/index.ts +15 -0
- package/backend/ws/deployments/schemas.ts +183 -0
- package/backend/ws/files/clipboard.ts +78 -0
- package/backend/ws/files/index.ts +5 -0
- package/backend/ws/git/diff-budget.ts +70 -11
- package/backend/ws/index.ts +16 -2
- package/backend/ws/integrations/crud.ts +219 -0
- package/backend/ws/integrations/index.ts +22 -0
- package/backend/ws/mcp/crud.ts +25 -1
- package/backend/ws/memory/crud.ts +4 -16
- package/backend/ws/notes/index.ts +278 -0
- package/backend/ws/profiles/crud.ts +1 -1
- package/backend/ws/snapshot/changes.ts +279 -0
- package/backend/ws/snapshot/index.ts +4 -3
- package/backend/ws/work/actions.ts +206 -0
- package/backend/ws/work/context.ts +51 -0
- package/backend/ws/work/crud.ts +347 -0
- package/backend/ws/work/index.ts +17 -0
- package/backend/ws/work/pull-requests.ts +177 -0
- package/backend/ws/work/schemas.ts +226 -0
- package/dist/assets/{index-sJmS_CCm.js → index-BrF6nqld.js} +1 -1
- package/dist/assets/{index-Bik9TCBi.js → index-C8Gi-b6U.js} +1 -1
- package/dist/assets/main-Bd3gb79F.css +1 -0
- package/dist/assets/main-Bo1hD7mt.js +1191 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/shared/constants/engine-tools.ts +1 -1
- package/shared/constants/tool-icons.ts +42 -0
- package/shared/types/database/schema.ts +41 -0
- package/shared/types/db-client/connection.ts +6 -0
- package/shared/types/db-client/index.ts +2 -0
- package/shared/types/db-client/integrations.ts +174 -0
- package/shared/types/db-client/supabase.ts +131 -0
- package/shared/types/deployments.ts +382 -0
- package/shared/types/integrations.ts +140 -0
- package/shared/types/memory.ts +34 -51
- package/shared/types/stores/settings.ts +8 -0
- package/shared/types/ui/components.ts +1 -1
- package/shared/types/work.ts +426 -0
- package/shared/utils/diff-calculator.test.ts +89 -0
- package/shared/utils/diff-calculator.ts +30 -65
- package/shared/utils/logger.ts +4 -0
- package/backend/memory/extract/languages.ts +0 -176
- package/backend/memory/extract/structural.test.ts +0 -215
- package/backend/memory/extract/structural.ts +0 -364
- package/backend/ws/snapshot/content.ts +0 -85
- package/dist/assets/main-DLqolBI2.css +0 -1
- package/dist/assets/main-Df1I3hnw.js +0 -1096
package/shared/types/memory.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Memory Graph types.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The graph holds MEMORIES: what happened, what was decided, what broke and how
|
|
5
|
+
* the user wants to work. It used to hold the codebase alongside them as nodes
|
|
6
|
+
* of its own (migration 066), which migration 076 removed — the agent can read
|
|
7
|
+
* the repository, and those nodes were four fifths of the store while never
|
|
8
|
+
* reaching a prompt. What survives of that half is `relatedPaths`: the files a
|
|
9
|
+
* memory claims something about, carried as an attribute of the memory.
|
|
8
10
|
*
|
|
9
11
|
* Shared between backend and frontend — the visualization, the MCP tool surface
|
|
10
12
|
* and the retrieval engine all speak these shapes.
|
|
@@ -14,9 +16,7 @@
|
|
|
14
16
|
// Nodes
|
|
15
17
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/** What kind of memory an episodic node holds. */
|
|
19
|
+
/** What kind of memory a node holds. */
|
|
20
20
|
export type EpisodicSubkind =
|
|
21
21
|
| 'decision'
|
|
22
22
|
| 'pattern'
|
|
@@ -25,10 +25,7 @@ export type EpisodicSubkind =
|
|
|
25
25
|
| 'observation'
|
|
26
26
|
| 'entity';
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
export type StructuralSubkind = 'file' | 'symbol' | 'module' | 'dependency';
|
|
30
|
-
|
|
31
|
-
export type GraphNodeSubkind = EpisodicSubkind | StructuralSubkind;
|
|
28
|
+
export type GraphNodeSubkind = EpisodicSubkind;
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
31
|
* How LONG a claim holds — its durability, not its geography.
|
|
@@ -103,7 +100,7 @@ export const AUTHORITY_RANK: Record<GraphAssertedBy, number> = {
|
|
|
103
100
|
* distinction, because both are a model reading text and deciding what to store.
|
|
104
101
|
* Meanwhile `auto` was doing the work of the real question every consumer
|
|
105
102
|
* actually asks: *did a person say this, or did a model infer it?* Retention,
|
|
106
|
-
*
|
|
103
|
+
* staleness decay, consolidation and the trust line in the injected block all
|
|
107
104
|
* branch on precisely that. Two values answer it without ambiguity; three
|
|
108
105
|
* invited every reader to guess which of the two model-written kinds a predicate
|
|
109
106
|
* meant.
|
|
@@ -112,21 +109,22 @@ export type GraphSource = 'agent' | 'user';
|
|
|
112
109
|
|
|
113
110
|
export interface GraphNode {
|
|
114
111
|
id: string;
|
|
115
|
-
kind: GraphNodeKind;
|
|
116
112
|
subkind: GraphNodeSubkind;
|
|
117
113
|
scope: GraphScope;
|
|
118
114
|
projectId: string | null;
|
|
119
115
|
sessionId: string | null;
|
|
120
116
|
/** Short, human-readable title shown on the graph and in listings. */
|
|
121
117
|
label: string;
|
|
122
|
-
/** Full memory text
|
|
118
|
+
/** Full memory text. */
|
|
123
119
|
body: string;
|
|
124
|
-
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Repo-relative paths this memory claims something about.
|
|
122
|
+
*
|
|
123
|
+
* Loaded on demand — listings that draw thousands of nodes do not pay for it.
|
|
124
|
+
* This is what invalidation ages a memory against and what an anchored query
|
|
125
|
+
* seeds from, and it replaces the file nodes those two used to walk through.
|
|
126
|
+
*/
|
|
127
|
+
relatedPaths?: string[];
|
|
130
128
|
/** Stable identity hash used to upsert instead of duplicating. */
|
|
131
129
|
digest: string;
|
|
132
130
|
/** How much the writer trusts this memory, 0–1. */
|
|
@@ -160,7 +158,7 @@ export interface GraphNode {
|
|
|
160
158
|
usefulCount: number;
|
|
161
159
|
/** Times a later turn found this memory wrong or misleading. */
|
|
162
160
|
unhelpfulCount: number;
|
|
163
|
-
/** When
|
|
161
|
+
/** When code this memory claims something about last changed underneath it. */
|
|
164
162
|
staleAt: string | null;
|
|
165
163
|
/** Canonical identity for `entity` nodes — the slug every statement hangs off. */
|
|
166
164
|
entityKey: string | null;
|
|
@@ -171,25 +169,18 @@ export interface GraphNode {
|
|
|
171
169
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
172
170
|
|
|
173
171
|
/**
|
|
174
|
-
* Relation types
|
|
172
|
+
* Relation types.
|
|
175
173
|
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
174
|
+
* All of them now connect one memory to another. The code-shaped relations
|
|
175
|
+
* (`imports`, `defines`, `contains`, and `about` pointing at a file node) went
|
|
176
|
+
* with the structural half in migration 076 — what a memory is about is a list
|
|
177
|
+
* of paths on the memory, not an edge to a node standing in for a file.
|
|
179
178
|
*/
|
|
180
179
|
export type GraphRelation =
|
|
181
|
-
// structural ↔ structural
|
|
182
|
-
| 'imports'
|
|
183
|
-
| 'calls'
|
|
184
|
-
| 'defines'
|
|
185
|
-
| 'contains'
|
|
186
|
-
// episodic ↔ episodic
|
|
187
180
|
| 'caused_by'
|
|
188
181
|
| 'supersedes'
|
|
189
182
|
| 'contradicts'
|
|
190
183
|
| 'generalizes'
|
|
191
|
-
// episodic → structural
|
|
192
|
-
| 'about'
|
|
193
184
|
// anything, drawn by hand
|
|
194
185
|
| 'relates_to';
|
|
195
186
|
|
|
@@ -208,16 +199,12 @@ export interface GraphEdge {
|
|
|
208
199
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
209
200
|
|
|
210
201
|
export interface GraphNodeInput {
|
|
211
|
-
kind: GraphNodeKind;
|
|
212
202
|
subkind: GraphNodeSubkind;
|
|
213
203
|
scope?: GraphScope;
|
|
214
204
|
projectId?: string | null;
|
|
215
205
|
sessionId?: string | null;
|
|
216
206
|
label: string;
|
|
217
207
|
body?: string;
|
|
218
|
-
path?: string | null;
|
|
219
|
-
symbol?: string | null;
|
|
220
|
-
language?: string | null;
|
|
221
208
|
/** Supply to control identity; otherwise derived from the node's content. */
|
|
222
209
|
digest?: string;
|
|
223
210
|
confidence?: number;
|
|
@@ -291,9 +278,7 @@ export interface RetrievalOptions {
|
|
|
291
278
|
sessionId?: string | null;
|
|
292
279
|
/** Restrict which scopes may match. Defaults to all three. */
|
|
293
280
|
scopes?: GraphScope[];
|
|
294
|
-
/** Restrict to
|
|
295
|
-
kinds?: GraphNodeKind[];
|
|
296
|
-
/** Restrict to particular subkinds (decision, failure, entity, file, …). */
|
|
281
|
+
/** Restrict to particular subkinds (decision, failure, entity, …). */
|
|
297
282
|
subkinds?: string[];
|
|
298
283
|
/** Restrict by who wrote it: inferred, asked for by an agent, or hand-written. */
|
|
299
284
|
sources?: GraphSource[];
|
|
@@ -306,9 +291,9 @@ export interface RetrievalOptions {
|
|
|
306
291
|
* action turn it on, because that is where "we already solved this in the
|
|
307
292
|
* other repo" has to arrive without being asked for.
|
|
308
293
|
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
* filter was originally added to stop.
|
|
294
|
+
* A memory only travels when it has been judged `anywhere`, which is what
|
|
295
|
+
* keeps one repository's local conventions out of another's results — the
|
|
296
|
+
* leak the hard project filter was originally added to stop.
|
|
312
297
|
*/
|
|
313
298
|
crossProject?: boolean;
|
|
314
299
|
/** Maximum hits returned after fusion. */
|
|
@@ -318,10 +303,10 @@ export interface RetrievalOptions {
|
|
|
318
303
|
/** Include archived nodes. Defaults to false. */
|
|
319
304
|
includeArchived?: boolean;
|
|
320
305
|
/**
|
|
321
|
-
* Repo-relative paths the session is currently working in.
|
|
322
|
-
*
|
|
323
|
-
* ("continue", "fix it") still reaches
|
|
324
|
-
* front of it.
|
|
306
|
+
* Repo-relative paths the session is currently working in. The memories that
|
|
307
|
+
* claim something about them join the query's seeds, so a turn whose text
|
|
308
|
+
* carries no signal ("continue", "fix it") still reaches what is known about
|
|
309
|
+
* the code in front of it.
|
|
325
310
|
*/
|
|
326
311
|
anchorPaths?: string[];
|
|
327
312
|
/**
|
|
@@ -369,7 +354,6 @@ export interface RetrievalResult {
|
|
|
369
354
|
/** A node as sent to the graph view: display fields plus its community. */
|
|
370
355
|
export interface GraphViewNode {
|
|
371
356
|
id: string;
|
|
372
|
-
kind: GraphNodeKind;
|
|
373
357
|
subkind: GraphNodeSubkind;
|
|
374
358
|
scope: GraphScope;
|
|
375
359
|
label: string;
|
|
@@ -534,10 +518,9 @@ export interface MemoryReadiness {
|
|
|
534
518
|
}
|
|
535
519
|
|
|
536
520
|
export interface GraphStats {
|
|
521
|
+
/** Live memories — every node in the graph is one. */
|
|
537
522
|
nodes: number;
|
|
538
523
|
edges: number;
|
|
539
|
-
episodic: number;
|
|
540
|
-
structural: number;
|
|
541
524
|
vectors: number;
|
|
542
525
|
byScope: Record<GraphScope, number>;
|
|
543
526
|
byProject: { projectId: string | null; count: number }[];
|
|
@@ -545,7 +528,7 @@ export interface GraphStats {
|
|
|
545
528
|
superseded: number;
|
|
546
529
|
/** Memories whose code changed underneath them since they were written. */
|
|
547
530
|
stale: number;
|
|
548
|
-
/**
|
|
531
|
+
/** Memories carrying a canonical entity key (a person, a tool, a system). */
|
|
549
532
|
entities: number;
|
|
550
533
|
/** Memories a later turn confirmed it actually used. */
|
|
551
534
|
confirmedUseful: number;
|
|
@@ -71,6 +71,14 @@ export interface AppSettings {
|
|
|
71
71
|
chatAppearance: 'classic' | 'compact';
|
|
72
72
|
/** Git diff viewer layout — true = side-by-side (2 columns), false = inline (1 column). Default: true. */
|
|
73
73
|
gitDiffSideBySide: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Issue/pull-request diff layout. Default: false (inline, 1 column).
|
|
76
|
+
*
|
|
77
|
+
* Separate from the Git panel's: a review diff shares its pane with a file
|
|
78
|
+
* tree and a header, so two columns start narrow, and reading someone
|
|
79
|
+
* else's change is mostly reading the new side.
|
|
80
|
+
*/
|
|
81
|
+
workDiffSideBySide: boolean;
|
|
74
82
|
/** AI commit message generator configuration */
|
|
75
83
|
commitGenerator: CommitGeneratorSettings;
|
|
76
84
|
/** AI authoring model for artifact generation (optional; falls back to assistant model) */
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Issues & PRs surface — shared vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* The panel talks about WORK ITEMS, not about GitHub. Every provider that can
|
|
5
|
+
* offer the `issues` capability is normalised into these shapes by an adapter,
|
|
6
|
+
* and the panel never learns which one answered. That is the whole test for
|
|
7
|
+
* this surface: if a second provider needs a second panel, these types are
|
|
8
|
+
* wrong and fixing them is the work — not adding a panel.
|
|
9
|
+
*
|
|
10
|
+
* Nothing here carries a credential. The adapter resolves the account's secret
|
|
11
|
+
* on the server and it never crosses this line.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** An issue and a pull request are the same kind of thing to this surface. */
|
|
15
|
+
export type WorkItemKind = 'issue' | 'pull-request';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The one state fact the UI is allowed to reason about.
|
|
19
|
+
*
|
|
20
|
+
* Providers name their states whatever they like — "closed", "Done",
|
|
21
|
+
* "Won't Fix" — and those names are shown verbatim. The category is what
|
|
22
|
+
* decides colour and grouping, so a Linear workflow with nine states still
|
|
23
|
+
* renders without the panel knowing any of them.
|
|
24
|
+
*/
|
|
25
|
+
export type WorkItemStateCategory = 'open' | 'closed' | 'merged' | 'draft';
|
|
26
|
+
|
|
27
|
+
export interface WorkItem {
|
|
28
|
+
/** Opaque provider id. Used for API calls, never shown. */
|
|
29
|
+
id: string;
|
|
30
|
+
/**
|
|
31
|
+
* The identifier a human uses: `123` on GitHub, `ENG-45` on Linear. This is
|
|
32
|
+
* what branch names and prompts are built from, so it must survive a round
|
|
33
|
+
* trip through a filesystem path.
|
|
34
|
+
*/
|
|
35
|
+
identifier: string;
|
|
36
|
+
kind: WorkItemKind;
|
|
37
|
+
title: string;
|
|
38
|
+
url: string;
|
|
39
|
+
/** The provider's own state name, shown as-is. */
|
|
40
|
+
state: string;
|
|
41
|
+
stateCategory: WorkItemStateCategory;
|
|
42
|
+
labels: string[];
|
|
43
|
+
assignees: string[];
|
|
44
|
+
author: string | null;
|
|
45
|
+
commentCount: number;
|
|
46
|
+
createdAt: string;
|
|
47
|
+
updatedAt: string;
|
|
48
|
+
/** Pull requests only. */
|
|
49
|
+
headBranch?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The commit the pull request currently points at.
|
|
52
|
+
*
|
|
53
|
+
* Carried because a BRANCH name is not a reliable way to read a pull
|
|
54
|
+
* request's files: a fork's branch does not exist in the base repository,
|
|
55
|
+
* and a merged pull request's branch is usually deleted. The sha does.
|
|
56
|
+
*/
|
|
57
|
+
headSha?: string;
|
|
58
|
+
baseBranch?: string;
|
|
59
|
+
isDraft?: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Where a comment came from.
|
|
64
|
+
*
|
|
65
|
+
* `review-summary` is the body a reviewer wrote when submitting a review, and
|
|
66
|
+
* it lives on a third endpoint with its own edit semantics. It is shown because
|
|
67
|
+
* leaving it out makes Clopen's thread disagree with the provider's — a bot
|
|
68
|
+
* that posts its findings as a review appeared to have vanished — but it is not
|
|
69
|
+
* editable here, and saying so is better than an edit that 404s.
|
|
70
|
+
*/
|
|
71
|
+
export type CommentSource = 'conversation' | 'review' | 'review-summary';
|
|
72
|
+
|
|
73
|
+
export interface WorkItemComment {
|
|
74
|
+
id: string;
|
|
75
|
+
author: string;
|
|
76
|
+
body: string;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
url?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Which conversation this belongs to.
|
|
81
|
+
*
|
|
82
|
+
* GitHub keeps review comments on a different endpoint from the discussion
|
|
83
|
+
* thread, and editing one through the other's URL is a 404. The surface
|
|
84
|
+
* shows them together, so the origin has to travel with the comment.
|
|
85
|
+
*/
|
|
86
|
+
source: CommentSource;
|
|
87
|
+
/** True when the signed-in user may edit or delete it. */
|
|
88
|
+
canModify: boolean;
|
|
89
|
+
/** File a review comment was left on, when it was left on one. */
|
|
90
|
+
path?: string;
|
|
91
|
+
line?: number | null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** How a pull request may be merged. */
|
|
95
|
+
export type MergeMethod = 'merge' | 'squash' | 'rebase';
|
|
96
|
+
|
|
97
|
+
export const MERGE_METHOD_LABELS: Record<MergeMethod, string> = {
|
|
98
|
+
merge: 'Create a merge commit',
|
|
99
|
+
squash: 'Squash and merge',
|
|
100
|
+
rebase: 'Rebase and merge'
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Whether this pull request can be merged right now.
|
|
105
|
+
*
|
|
106
|
+
* `mergeable` is deliberately nullable: GitHub computes it asynchronously and
|
|
107
|
+
* answers null while it is still thinking. Rendering null as "cannot merge"
|
|
108
|
+
* would tell the user their branch is broken when it is merely young.
|
|
109
|
+
*/
|
|
110
|
+
export interface PullRequestMergeability {
|
|
111
|
+
mergeable: boolean | null;
|
|
112
|
+
/** The provider's own word — `clean`, `blocked`, `dirty`, `behind`. */
|
|
113
|
+
state: string;
|
|
114
|
+
/** Methods the repository allows. A repo can disable squash or rebase. */
|
|
115
|
+
allowedMethods: MergeMethod[];
|
|
116
|
+
merged: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface CommitRef {
|
|
120
|
+
hash: string;
|
|
121
|
+
subject: string;
|
|
122
|
+
author: string | null;
|
|
123
|
+
date: string;
|
|
124
|
+
url: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** One commit, opened: the rest of its message and everything it touched. */
|
|
128
|
+
export interface CommitDetail {
|
|
129
|
+
commit: CommitRef;
|
|
130
|
+
/** The message below the subject line. Empty for a one-line commit. */
|
|
131
|
+
body: string;
|
|
132
|
+
additions: number;
|
|
133
|
+
deletions: number;
|
|
134
|
+
files: FileChange[];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** One file in a pull request's diff. */
|
|
138
|
+
export interface FileChange {
|
|
139
|
+
path: string;
|
|
140
|
+
status: string;
|
|
141
|
+
additions: number;
|
|
142
|
+
deletions: number;
|
|
143
|
+
/** Unified diff. Absent for binary files and for anything over the cap. */
|
|
144
|
+
patch?: string;
|
|
145
|
+
url: string;
|
|
146
|
+
/**
|
|
147
|
+
* The blob this file's content lives in, at this revision.
|
|
148
|
+
*
|
|
149
|
+
* This is what "view the whole file" reads, in preference to a path plus a
|
|
150
|
+
* ref: a blob id needs no branch to still exist, no repository to be the
|
|
151
|
+
* one the branch lives in, and no guess about which side of a rename the
|
|
152
|
+
* path is on. It is the difference between the viewer working on a fork's
|
|
153
|
+
* pull request and the viewer reporting that the repository is unreachable.
|
|
154
|
+
*/
|
|
155
|
+
sha?: string;
|
|
156
|
+
/** Where the file moved from, when the provider says it was renamed. */
|
|
157
|
+
previousPath?: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* A file's text, as much of it as is worth sending.
|
|
162
|
+
*
|
|
163
|
+
* `truncated` exists so a partial file can be SHOWN and labelled instead of
|
|
164
|
+
* refused. "Open it on the web instead" is the viewer admitting it would rather
|
|
165
|
+
* not, and a generated bundle or a big lockfile is exactly the sort of file a
|
|
166
|
+
* reviewer needs a look at rather than a lecture about.
|
|
167
|
+
*/
|
|
168
|
+
export interface FileContent {
|
|
169
|
+
content: string;
|
|
170
|
+
truncated: boolean;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Something that HAPPENED to an item, other than a comment.
|
|
175
|
+
*
|
|
176
|
+
* Labels, references, assignments and closures are what turn a thread into a
|
|
177
|
+
* history: "aanfaisal mentioned this in #454" is often the answer to why an
|
|
178
|
+
* issue looks the way it does, and reading only the comments hides it.
|
|
179
|
+
*
|
|
180
|
+
* `kind` is normalised; unknown provider events are dropped rather than
|
|
181
|
+
* rendered as a shrug, because a timeline of "something happened" entries is
|
|
182
|
+
* worse than a shorter honest one.
|
|
183
|
+
*/
|
|
184
|
+
export type TimelineEventKind =
|
|
185
|
+
| 'labeled'
|
|
186
|
+
| 'unlabeled'
|
|
187
|
+
| 'assigned'
|
|
188
|
+
| 'unassigned'
|
|
189
|
+
| 'renamed'
|
|
190
|
+
| 'referenced'
|
|
191
|
+
| 'cross-referenced'
|
|
192
|
+
| 'closed'
|
|
193
|
+
| 'reopened'
|
|
194
|
+
| 'merged'
|
|
195
|
+
| 'review-requested';
|
|
196
|
+
|
|
197
|
+
export interface WorkItemEvent {
|
|
198
|
+
id: string;
|
|
199
|
+
kind: TimelineEventKind;
|
|
200
|
+
actor: string | null;
|
|
201
|
+
createdAt: string;
|
|
202
|
+
/** Label name, assignee login, new title — whatever the event carries. */
|
|
203
|
+
subject?: string;
|
|
204
|
+
/** The thing referenced, for reference events. */
|
|
205
|
+
referenceTitle?: string;
|
|
206
|
+
referenceUrl?: string;
|
|
207
|
+
referenceIdentifier?: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface WorkItemDetail extends WorkItem {
|
|
211
|
+
body: string;
|
|
212
|
+
comments: WorkItemComment[];
|
|
213
|
+
/** Non-comment history, newest last, interleaved by the UI. */
|
|
214
|
+
events: WorkItemEvent[];
|
|
215
|
+
/** Pull requests only, and only when the provider can merge. */
|
|
216
|
+
mergeability?: PullRequestMergeability;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** One state an item can be moved to, as the provider names it. */
|
|
220
|
+
export interface WorkItemStateOption {
|
|
221
|
+
value: string;
|
|
222
|
+
label: string;
|
|
223
|
+
category: WorkItemStateCategory;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export type CheckStatus =
|
|
227
|
+
| 'queued'
|
|
228
|
+
| 'running'
|
|
229
|
+
| 'success'
|
|
230
|
+
| 'failure'
|
|
231
|
+
| 'cancelled'
|
|
232
|
+
| 'skipped'
|
|
233
|
+
| 'unknown';
|
|
234
|
+
|
|
235
|
+
/** One CI run against a branch. GitHub Actions is the first shape; others fit. */
|
|
236
|
+
export interface CheckRun {
|
|
237
|
+
id: string;
|
|
238
|
+
name: string;
|
|
239
|
+
status: CheckStatus;
|
|
240
|
+
url: string;
|
|
241
|
+
headBranch: string | null;
|
|
242
|
+
headSha: string;
|
|
243
|
+
event: string;
|
|
244
|
+
startedAt: string | null;
|
|
245
|
+
finishedAt: string | null;
|
|
246
|
+
/** False when the provider exposes no log endpoint for this run. */
|
|
247
|
+
canFetchLogs: boolean;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** A failing run's logs, already trimmed to something a prompt can carry. */
|
|
251
|
+
export interface CheckLogBundle {
|
|
252
|
+
runId: string;
|
|
253
|
+
runName: string;
|
|
254
|
+
text: string;
|
|
255
|
+
truncated: boolean;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** What a provider is actually able to do, so the UI hides what it cannot. */
|
|
259
|
+
export interface WorkProviderCapabilities {
|
|
260
|
+
pullRequests: boolean;
|
|
261
|
+
checks: boolean;
|
|
262
|
+
comments: boolean;
|
|
263
|
+
/** Editing and deleting comments, which not every tracker permits. */
|
|
264
|
+
editComments: boolean;
|
|
265
|
+
transitions: boolean;
|
|
266
|
+
/** Editing an item's title. */
|
|
267
|
+
editTitle: boolean;
|
|
268
|
+
createPullRequest: boolean;
|
|
269
|
+
createIssue: boolean;
|
|
270
|
+
merge: boolean;
|
|
271
|
+
assign: boolean;
|
|
272
|
+
/** Commits and per-file diffs for a pull request. */
|
|
273
|
+
diff: boolean;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* How a work item's identifier becomes a branch name.
|
|
278
|
+
*
|
|
279
|
+
* `{kind}` → `issue` / `pr`, `{identifier}` → `123`, `{slug}` → the title
|
|
280
|
+
* slugified. Kept as a template rather than a boolean so a team with a naming
|
|
281
|
+
* convention does not have to fight the default.
|
|
282
|
+
*/
|
|
283
|
+
export const DEFAULT_BRANCH_TEMPLATE = '{kind}/{identifier}-{slug}';
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Per-binding behaviour. Every transition is null by default: moving someone
|
|
287
|
+
* else's ticket is a visible, outward-facing act, and a tool that starts doing
|
|
288
|
+
* it because it was installed is a tool people stop trusting.
|
|
289
|
+
*/
|
|
290
|
+
export interface WorkBindingConfig {
|
|
291
|
+
/** State to move the item to when "Start work" runs. Null = do nothing. */
|
|
292
|
+
transitionOnStartWork: string | null;
|
|
293
|
+
/** State to move the item to when a PR is opened for it. Null = do nothing. */
|
|
294
|
+
transitionOnPrOpen: string | null;
|
|
295
|
+
branchTemplate: string;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export const DEFAULT_BINDING_CONFIG: WorkBindingConfig = {
|
|
299
|
+
transitionOnStartWork: null,
|
|
300
|
+
transitionOnPrOpen: null,
|
|
301
|
+
branchTemplate: DEFAULT_BRANCH_TEMPLATE
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/** Which remote project this Clopen project is looking at, through one account. */
|
|
305
|
+
export interface IssueBinding {
|
|
306
|
+
/** Provider-specific locator. `owner/repo` for GitHub. */
|
|
307
|
+
locator: string;
|
|
308
|
+
/** How to print it. */
|
|
309
|
+
displayName: string;
|
|
310
|
+
/**
|
|
311
|
+
* True when nobody chose this — it was read off the git remote. A detected
|
|
312
|
+
* binding is still editable; the flag exists so the UI can say where it came
|
|
313
|
+
* from instead of presenting a guess as a decision.
|
|
314
|
+
*/
|
|
315
|
+
detected: boolean;
|
|
316
|
+
defaultBranch: string | null;
|
|
317
|
+
config: WorkBindingConfig;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** One connected account that can serve work items for the current project. */
|
|
321
|
+
export interface WorkSource {
|
|
322
|
+
accountId: string;
|
|
323
|
+
provider: string;
|
|
324
|
+
providerName: string;
|
|
325
|
+
label: string;
|
|
326
|
+
/** Who the credential belongs to, used to decide what the user may edit. */
|
|
327
|
+
viewer: string | null;
|
|
328
|
+
capabilities: WorkProviderCapabilities;
|
|
329
|
+
binding: IssueBinding | null;
|
|
330
|
+
/** Candidate locators read off the project's git remotes, for the picker. */
|
|
331
|
+
suggestedLocators: string[];
|
|
332
|
+
status: 'ok' | 'needs_auth' | 'needs_config' | 'error' | 'unknown';
|
|
333
|
+
statusDetail: string | null;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Provider-side state filter. Separate from "mine", which is about people. */
|
|
337
|
+
export type WorkItemState = 'open' | 'closed' | 'all';
|
|
338
|
+
|
|
339
|
+
export interface WorkItemQuery {
|
|
340
|
+
kind: WorkItemKind;
|
|
341
|
+
state: WorkItemState;
|
|
342
|
+
/** Only items assigned to — or, for pull requests, opened by — the viewer. */
|
|
343
|
+
mineOnly: boolean;
|
|
344
|
+
author?: string;
|
|
345
|
+
labels?: string[];
|
|
346
|
+
/** ISO dates, inclusive, applied to the item's last update. */
|
|
347
|
+
since?: string;
|
|
348
|
+
until?: string;
|
|
349
|
+
search?: string;
|
|
350
|
+
/** 1-based. The list appends rather than replaces for anything above 1. */
|
|
351
|
+
page?: number;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** Remaining API budget, shown in the panel footer rather than discovered by a 403. */
|
|
355
|
+
export interface WorkRateLimit {
|
|
356
|
+
remaining: number;
|
|
357
|
+
limit: number;
|
|
358
|
+
resetAt: string | null;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface WorkItemPage {
|
|
362
|
+
items: WorkItem[];
|
|
363
|
+
rateLimit: WorkRateLimit | null;
|
|
364
|
+
/** True when the provider reported another page after this one. */
|
|
365
|
+
hasMore: boolean;
|
|
366
|
+
/**
|
|
367
|
+
* Provider page to resume from.
|
|
368
|
+
*
|
|
369
|
+
* NOT `page + 1`: a filtered page can drain several provider pages, and
|
|
370
|
+
* guessing would re-request everything the last call already consumed.
|
|
371
|
+
*/
|
|
372
|
+
nextPage: number | null;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** The link between a work item and the local work started for it. */
|
|
376
|
+
export interface WorkItemLink {
|
|
377
|
+
itemKind: WorkItemKind;
|
|
378
|
+
itemIdentifier: string;
|
|
379
|
+
worktreeId: string | null;
|
|
380
|
+
worktreeName: string | null;
|
|
381
|
+
sessionId: string | null;
|
|
382
|
+
branch: string | null;
|
|
383
|
+
createdAt: string;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export interface StartWorkResult {
|
|
387
|
+
worktreeId: string;
|
|
388
|
+
worktreeName: string;
|
|
389
|
+
sessionId: string;
|
|
390
|
+
branch: string;
|
|
391
|
+
/** The first message, already composed. The client sends it. */
|
|
392
|
+
prompt: string;
|
|
393
|
+
/** Null when no transition was configured, or when one was and it failed. */
|
|
394
|
+
transitionedTo: string | null;
|
|
395
|
+
transitionError: string | null;
|
|
396
|
+
/** True when the clone could not carry ignored files, so deps need installing. */
|
|
397
|
+
needsSetup: boolean;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export interface PullRequestDraft {
|
|
401
|
+
title: string;
|
|
402
|
+
body: string;
|
|
403
|
+
base: string;
|
|
404
|
+
head: string;
|
|
405
|
+
isDraft: boolean;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** Everything the PR composer needs to open, resolved server-side in one call. */
|
|
409
|
+
export interface PullRequestContext {
|
|
410
|
+
/** Local branch the PR would come from. */
|
|
411
|
+
head: string;
|
|
412
|
+
base: string;
|
|
413
|
+
baseCandidates: string[];
|
|
414
|
+
/** Local branches the PR could come from instead. */
|
|
415
|
+
headCandidates: string[];
|
|
416
|
+
/** False when the branch has never been pushed — the composer offers to. */
|
|
417
|
+
isPushed: boolean;
|
|
418
|
+
/** Where an unpushed branch would go, so the offer can name it. */
|
|
419
|
+
pushRemote: string;
|
|
420
|
+
/** Commits on head that are not on base, newest first. */
|
|
421
|
+
commits: { hash: string; subject: string }[];
|
|
422
|
+
/** An open PR for this branch, when one already exists. */
|
|
423
|
+
existing: WorkItem | null;
|
|
424
|
+
/** The work item this branch was started from, when "Start work" made it. */
|
|
425
|
+
linkedItem: WorkItemLink | null;
|
|
426
|
+
}
|