patchrelay 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +3 -3
- package/dist/cli/args.js +73 -0
- package/dist/cli/command-types.js +1 -0
- package/dist/cli/commands/connect.js +28 -0
- package/dist/cli/commands/issues.js +147 -0
- package/dist/cli/commands/project.js +140 -0
- package/dist/cli/commands/setup.js +140 -0
- package/dist/cli/connect-flow.js +52 -0
- package/dist/cli/data.js +17 -63
- package/dist/cli/index.js +59 -615
- package/dist/cli/interactive.js +48 -0
- package/dist/cli/output.js +13 -0
- package/dist/cli/service-commands.js +31 -0
- package/dist/db/issue-projection-store.js +54 -0
- package/dist/db/issue-workflow-coordinator.js +280 -0
- package/dist/db/issue-workflow-store.js +53 -550
- package/dist/db/run-report-store.js +33 -0
- package/dist/db.js +20 -1
- package/dist/index.js +13 -4
- package/dist/install.js +4 -3
- package/dist/linear-oauth.js +8 -7
- package/dist/service-stage-finalizer.js +2 -2
- package/dist/service-stage-runner.js +4 -4
- package/dist/service.js +1 -0
- package/dist/stage-failure.js +3 -17
- package/dist/stage-lifecycle-publisher.js +5 -28
- package/dist/webhook-desired-stage-recorder.js +4 -35
- package/infra/patchrelay.path +2 -0
- package/infra/patchrelay.service +2 -0
- package/package.json +1 -1
package/dist/cli/data.js
CHANGED
|
@@ -200,14 +200,10 @@ export class CliDataAccess {
|
|
|
200
200
|
projectId: issue.projectId,
|
|
201
201
|
linearIssueId: issue.linearIssueId,
|
|
202
202
|
});
|
|
203
|
-
this.db.
|
|
204
|
-
projectId: issue.projectId,
|
|
205
|
-
linearIssueId: issue.linearIssueId,
|
|
206
|
-
desiredStage: stage,
|
|
203
|
+
this.db.workflowCoordinator.setIssueDesiredStage(issue.projectId, issue.linearIssueId, stage, {
|
|
207
204
|
desiredReceiptId: receipt.id,
|
|
208
205
|
lifecycleStatus: "queued",
|
|
209
206
|
});
|
|
210
|
-
this.db.issueWorkflows.setIssueDesiredStage(issue.projectId, issue.linearIssueId, stage, webhookId);
|
|
211
207
|
const updated = this.db.issueWorkflows.getTrackedIssue(issue.projectId, issue.linearIssueId);
|
|
212
208
|
return {
|
|
213
209
|
issue: updated,
|
|
@@ -278,13 +274,19 @@ export class CliDataAccess {
|
|
|
278
274
|
: {}),
|
|
279
275
|
...(row.latest_stage !== null
|
|
280
276
|
? { latestStage: row.latest_stage }
|
|
281
|
-
: ledger?.
|
|
282
|
-
? { latestStage: ledger.
|
|
277
|
+
: ledger?.runLease
|
|
278
|
+
? { latestStage: ledger.runLease.stage }
|
|
283
279
|
: {}),
|
|
284
280
|
...(row.latest_stage_status !== null
|
|
285
281
|
? { latestStageStatus: String(row.latest_stage_status) }
|
|
286
|
-
: ledger?.
|
|
287
|
-
? {
|
|
282
|
+
: ledger?.runLease
|
|
283
|
+
? {
|
|
284
|
+
latestStageStatus: ledger.runLease.status === "failed"
|
|
285
|
+
? "failed"
|
|
286
|
+
: ledger.runLease.status === "completed" || ledger.runLease.status === "released" || ledger.runLease.status === "paused"
|
|
287
|
+
? "completed"
|
|
288
|
+
: "running",
|
|
289
|
+
}
|
|
288
290
|
: {}),
|
|
289
291
|
updatedAt: String(row.updated_at),
|
|
290
292
|
};
|
|
@@ -302,20 +304,16 @@ export class CliDataAccess {
|
|
|
302
304
|
getLedgerIssueContext(projectId, linearIssueId) {
|
|
303
305
|
const issueControl = this.db.issueControl.getIssueControl(projectId, linearIssueId);
|
|
304
306
|
const runLease = issueControl?.activeRunLeaseId ? this.db.runLeases.getRunLease(issueControl.activeRunLeaseId) : undefined;
|
|
305
|
-
const workspaceOwnership = issueControl?.activeWorkspaceOwnershipId
|
|
306
|
-
? this.db.workspaceOwnership.getWorkspaceOwnership(issueControl.activeWorkspaceOwnershipId)
|
|
307
|
-
: undefined;
|
|
308
|
-
const mirroredStageRun = issueControl?.activeRunLeaseId ? this.db.issueWorkflows.getStageRun(issueControl.activeRunLeaseId) : undefined;
|
|
309
307
|
return {
|
|
310
308
|
...(issueControl ? { issueControl } : {}),
|
|
311
309
|
...(runLease ? { runLease } : {}),
|
|
312
|
-
...(workspaceOwnership ? { workspaceOwnership } : {}),
|
|
313
|
-
...(mirroredStageRun ? { mirroredStageRun } : {}),
|
|
314
310
|
};
|
|
315
311
|
}
|
|
316
312
|
getActiveStageRunForIssue(issue, ledger) {
|
|
317
313
|
const context = ledger ?? this.getLedgerIssueContext(issue.projectId, issue.linearIssueId);
|
|
318
|
-
const activeStageRun = context.
|
|
314
|
+
const activeStageRun = context.issueControl?.activeRunLeaseId
|
|
315
|
+
? this.db.issueWorkflows.getStageRun(context.issueControl.activeRunLeaseId)
|
|
316
|
+
: undefined;
|
|
319
317
|
if (!activeStageRun) {
|
|
320
318
|
return undefined;
|
|
321
319
|
}
|
|
@@ -323,59 +321,15 @@ export class CliDataAccess {
|
|
|
323
321
|
? activeStageRun
|
|
324
322
|
: undefined;
|
|
325
323
|
}
|
|
326
|
-
synthesizeStageRunFromLease(ledger) {
|
|
327
|
-
if (!ledger.runLease) {
|
|
328
|
-
return undefined;
|
|
329
|
-
}
|
|
330
|
-
return {
|
|
331
|
-
id: -ledger.runLease.id,
|
|
332
|
-
pipelineRunId: 0,
|
|
333
|
-
projectId: ledger.runLease.projectId,
|
|
334
|
-
linearIssueId: ledger.runLease.linearIssueId,
|
|
335
|
-
workspaceId: 0,
|
|
336
|
-
stage: ledger.runLease.stage,
|
|
337
|
-
status: ledger.runLease.status === "failed"
|
|
338
|
-
? "failed"
|
|
339
|
-
: ledger.runLease.status === "completed" || ledger.runLease.status === "released" || ledger.runLease.status === "paused"
|
|
340
|
-
? "completed"
|
|
341
|
-
: "running",
|
|
342
|
-
triggerWebhookId: "ledger-active-run",
|
|
343
|
-
workflowFile: ledger.runLease.workflowFile,
|
|
344
|
-
promptText: ledger.runLease.promptText,
|
|
345
|
-
...(ledger.runLease.threadId ? { threadId: ledger.runLease.threadId } : {}),
|
|
346
|
-
...(ledger.runLease.parentThreadId ? { parentThreadId: ledger.runLease.parentThreadId } : {}),
|
|
347
|
-
...(ledger.runLease.turnId ? { turnId: ledger.runLease.turnId } : {}),
|
|
348
|
-
startedAt: ledger.runLease.startedAt,
|
|
349
|
-
...(ledger.runLease.endedAt ? { endedAt: ledger.runLease.endedAt } : {}),
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
324
|
getWorkspaceForIssue(issue, ledger) {
|
|
353
325
|
const context = ledger ?? this.getLedgerIssueContext(issue.projectId, issue.linearIssueId);
|
|
354
|
-
if (
|
|
355
|
-
const activeWorkspace = this.db.issueWorkflows.
|
|
326
|
+
if (context.issueControl?.activeWorkspaceOwnershipId !== undefined) {
|
|
327
|
+
const activeWorkspace = this.db.issueWorkflows.getWorkspace(context.issueControl.activeWorkspaceOwnershipId);
|
|
356
328
|
if (activeWorkspace) {
|
|
357
329
|
return activeWorkspace;
|
|
358
330
|
}
|
|
359
331
|
}
|
|
360
|
-
|
|
361
|
-
if (!workspaceOwnership) {
|
|
362
|
-
return this.db.issueWorkflows.getActiveWorkspaceForIssue(issue.projectId, issue.linearIssueId);
|
|
363
|
-
}
|
|
364
|
-
return {
|
|
365
|
-
id: workspaceOwnership.id,
|
|
366
|
-
projectId: workspaceOwnership.projectId,
|
|
367
|
-
linearIssueId: workspaceOwnership.linearIssueId,
|
|
368
|
-
branchName: workspaceOwnership.branchName,
|
|
369
|
-
worktreePath: workspaceOwnership.worktreePath,
|
|
370
|
-
status: workspaceOwnership.status === "released"
|
|
371
|
-
? "closed"
|
|
372
|
-
: workspaceOwnership.status === "paused"
|
|
373
|
-
? "paused"
|
|
374
|
-
: "active",
|
|
375
|
-
...(context.runLease?.threadId ? { lastThreadId: context.runLease.threadId } : {}),
|
|
376
|
-
createdAt: workspaceOwnership.createdAt,
|
|
377
|
-
updatedAt: workspaceOwnership.updatedAt,
|
|
378
|
-
};
|
|
332
|
+
return this.db.issueWorkflows.getActiveWorkspaceForIssue(issue.projectId, issue.linearIssueId);
|
|
379
333
|
}
|
|
380
334
|
async connect(projectId) {
|
|
381
335
|
return await this.requestJson("/api/oauth/linear/start", {
|