@wjarka/cezarion 0.17.0-dev.5581 → 0.17.0-dev.5585

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.
@@ -1,3 +1,4 @@
1
+ import type { LiveIndexCheck } from '../git-private-index.ts';
1
2
  import type { RunManager } from '../workflows/run.ts';
2
3
  import type { RunRecord, RunStore } from '../runs/store.ts';
3
4
  export type CheckoutIntent = 'read' | 'mutate' | 'publish' | 'remove' | 'open';
@@ -8,7 +9,6 @@ export interface RunCheckoutHost {
8
9
  }
9
10
  type ReadDirectoryRule = 'working-directory' | 'existing-worktree' | 'recorded-path-or-root';
10
11
  interface ReadOptions<Rule extends ReadDirectoryRule> {
11
- checksAutosave: boolean;
12
12
  directory: Rule;
13
13
  }
14
14
  type CheckoutRefusal = {
@@ -21,6 +21,9 @@ type ReadHandle<Rule extends ReadDirectoryRule> = {
21
21
  run: RunRecord;
22
22
  directory: Rule extends 'existing-worktree' ? string | null : string;
23
23
  };
24
+ interface ReadActions {
25
+ beforeLiveIndex: LiveIndexCheck;
26
+ }
24
27
  interface OpenOptions {
25
28
  ignoresEngineOwnership: boolean;
26
29
  }
@@ -46,7 +49,7 @@ export declare function runCheckout(host: RunCheckoutHost, id: string, intent: '
46
49
  /** Admission stays synchronous: no yield between lookup and claim. */
47
50
  export declare function runCheckout(host: RunCheckoutHost, id: string, intent: 'publish'): CheckoutRefusal | ClaimedHandle;
48
51
  export declare function runCheckout(host: RunCheckoutHost, id: string, intent: 'remove', options: RemoveOptions): CheckoutRefusal | ClaimedHandle;
49
- export declare function runCheckout<Rule extends ReadDirectoryRule>(host: RunCheckoutHost, id: string, _intent: Extract<CheckoutIntent, 'read'>, options: ReadOptions<Rule>): CheckoutRefusal | ReadHandle<Rule>;
52
+ export declare function runCheckout<Rule extends ReadDirectoryRule>(host: RunCheckoutHost, id: string, _intent: Extract<CheckoutIntent, 'read'>, options: ReadOptions<Rule>): CheckoutRefusal | (ReadHandle<Rule> & ReadActions);
50
53
  export declare function runCheckout(host: RunCheckoutHost, id: string, intent: Extract<CheckoutIntent, 'mutate'>): CheckoutRefusal | ReadHandle<'working-directory'>;
51
54
  /** The caller holds publish admission's claim until all publish work finishes. */
52
55
  export declare function preparePublishCheckout({ root, store }: RunCheckoutHost, id: string): Promise<CheckoutRefusal | {
@@ -15,7 +15,7 @@ const workingDirectoryOf = (run, repoRoot) => run.worktree === false
15
15
  ? repoRoot
16
16
  : worktreeOf(run);
17
17
  const NO_WORKTREE = 'no worktree — this task ran directly in the repo working tree';
18
- export function runCheckout(host, id, intent, options = { checksAutosave: true, directory: 'existing-worktree' }) {
18
+ export function runCheckout(host, id, intent, options = { directory: 'existing-worktree' }) {
19
19
  if (intent === 'publish')
20
20
  return publishCheckout(host, id);
21
21
  if ('ignoresEngineOwnership' in options)
@@ -29,19 +29,27 @@ export function runCheckout(host, id, intent, options = { checksAutosave: true,
29
29
  const refusal = intent === 'mutate' && run.worktreePath && fallbackProjectWriteError(run.worktreePath);
30
30
  if (refusal)
31
31
  return { status: 409, body: { error: refusal } };
32
- if (options.checksAutosave) {
32
+ if (intent === 'mutate') {
33
33
  const blocker = autosaveCleanupBlocker(store.sourceDataDir(run.id), run.id);
34
34
  if (blocker)
35
35
  return { status: 409, body: { error: blocker } };
36
36
  }
37
37
  if (options.directory === 'recorded-path-or-root') {
38
- return { run, directory: run.worktreePath ?? root };
38
+ return readCheckoutHandle(host, run, run.worktreePath ?? root);
39
39
  }
40
40
  const directory = options.directory === 'existing-worktree' ? worktreeOf(run) : workingDirectoryOf(run, root);
41
41
  if (!directory && (intent === 'mutate' || options.directory === 'working-directory')) {
42
42
  return { status: 409, body: { error: NO_WORKTREE } };
43
43
  }
44
- return { run, directory };
44
+ return intent === 'read' ? readCheckoutHandle(host, run, directory) : { run, directory };
45
+ }
46
+ function readCheckoutHandle(host, run, directory) {
47
+ const beforeLiveIndex = () => autosaveCleanupBlocker(host.store.sourceDataDir(run.id), run.id);
48
+ return {
49
+ run,
50
+ directory,
51
+ beforeLiveIndex,
52
+ };
45
53
  }
46
54
  function publishCheckout({ store, manager }, id) {
47
55
  const held = store.getRun(id);
@@ -1 +1 @@
1
- {"version":3,"file":"run-checkout.js","sourceRoot":"","sources":["../../src/server/run-checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,+EAA+E;AAC/E,wFAAwF;AACxF,2EAA2E;AAC3E,yEAAyE;AACzE,qEAAqE;AACrE,MAAM,UAAU,GAAG,CAAC,GAAc,EAAiB,EAAE,CACnD,GAAG,CAAC,YAAY,IAAI,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7E,MAAM,kBAAkB,GAAG,CAAC,GAAc,EAAE,QAAgB,EAAiB,EAAE,CAC7E,GAAG,CAAC,QAAQ,KAAK,KAAK;IACpB,CAAC,CAAC,QAAQ;IACV,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACtB,MAAM,WAAW,GAAG,+DAA+D,CAAC;AAuDpF,MAAM,UAAU,WAAW,CACzB,IAAqB,EACrB,EAAU,EACV,MAAsB,EACtB,OAAO,GAAiE,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,mBAAmB,EAAE;IAEhI,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,eAAe,CAAC,IAAI,EAAE,EAAE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,CAAC,CAAC;IAChI,OAAO,KAAK,GAAG,CAAC;QACd,CAAC,CAAC,oBAAoB,KAAK,oBAAoB,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,yDAAyD;QAC9H,CAAC,CAAC,6CAA6C,CAAC;AACpD,CAAC;AAED,SAAS,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAmB,EAAE,EAAU,EAAE,OAAoB;IACtF,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC;IAC/D,OAAO;QACL,GAAG;QACH,SAAS,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI;QACxC,IAAI,QAAQ,KAAK,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC1C,eAAe;YACb,OAAO,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC;QACxF,CAAC;QACD,IAAI,aAAa,KAAK,OAAO,OAAO,CAAC,sBAAsB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KACtF,CAAC;AACJ,CAAC"}
@@ -3376,6 +3376,12 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
3376
3376
  output: {
3377
3377
  generation: string;
3378
3378
  results: ({
3379
+ projectId: string;
3380
+ runId: string;
3381
+ type: "error" | "reset";
3382
+ status: 400 | 404 | 409 | 413 | 503;
3383
+ error: string;
3384
+ } | {
3379
3385
  projectId: string;
3380
3386
  runId: string;
3381
3387
  type: "batch";
@@ -3389,12 +3395,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
3389
3395
  cursor: string;
3390
3396
  afterSeq: number;
3391
3397
  hasMore: boolean;
3392
- } | {
3393
- projectId: string;
3394
- runId: string;
3395
- type: "error" | "reset";
3396
- status: 400 | 404 | 409 | 413 | 503;
3397
- error: string;
3398
3398
  })[];
3399
3399
  };
3400
3400
  outputFormat: "json";
@@ -5289,19 +5289,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
5289
5289
  } & {
5290
5290
  "/repo/commit/:sha": {
5291
5291
  $get: {
5292
- output: string;
5293
- outputFormat: "text";
5294
- status: import("hono/utils/http-status").ContentfulStatusCode;
5295
- input: {
5296
- query: {
5297
- structured?: string | undefined;
5298
- };
5299
- } & {
5300
- param: {
5301
- sha: string;
5302
- };
5303
- };
5304
- } | {
5305
5292
  output: {
5306
5293
  error: string;
5307
5294
  code?: "invalid_input" | undefined;
@@ -5365,6 +5352,19 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
5365
5352
  sha: string;
5366
5353
  };
5367
5354
  };
5355
+ } | {
5356
+ output: string;
5357
+ outputFormat: "text";
5358
+ status: import("hono/utils/http-status").ContentfulStatusCode;
5359
+ input: {
5360
+ query: {
5361
+ structured?: string | undefined;
5362
+ };
5363
+ } & {
5364
+ param: {
5365
+ sha: string;
5366
+ };
5367
+ };
5368
5368
  };
5369
5369
  };
5370
5370
  } & {
@@ -18687,20 +18687,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
18687
18687
  } & {
18688
18688
  "/runs/:id/handoff": {
18689
18689
  $get: {
18690
- output: string;
18691
- outputFormat: "text";
18692
- status: 200;
18690
+ output: {
18691
+ error: string;
18692
+ };
18693
+ outputFormat: "json";
18694
+ status: 404;
18693
18695
  input: {
18694
18696
  param: {
18695
18697
  id: string;
18696
18698
  };
18697
18699
  };
18698
18700
  } | {
18699
- output: {
18700
- error: string;
18701
- };
18702
- outputFormat: "json";
18703
- status: 404;
18701
+ output: string;
18702
+ outputFormat: "text";
18703
+ status: 200;
18704
18704
  input: {
18705
18705
  param: {
18706
18706
  id: string;
@@ -18738,20 +18738,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
18738
18738
  } & {
18739
18739
  "/runs/:id/diff": {
18740
18740
  $get: {
18741
- output: string;
18742
- outputFormat: "text";
18743
- status: import("hono/utils/http-status").ContentfulStatusCode;
18741
+ output: {
18742
+ error: string;
18743
+ };
18744
+ outputFormat: "json";
18745
+ status: 404 | 409;
18744
18746
  input: {
18745
18747
  param: {
18746
18748
  id: string;
18747
18749
  };
18748
18750
  };
18749
18751
  } | {
18750
- output: {
18751
- error: string;
18752
- };
18753
- outputFormat: "json";
18754
- status: 404 | 409;
18752
+ output: string;
18753
+ outputFormat: "text";
18754
+ status: import("hono/utils/http-status").ContentfulStatusCode;
18755
18755
  input: {
18756
18756
  param: {
18757
18757
  id: string;
@@ -21151,19 +21151,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
21151
21151
  } & {
21152
21152
  "/repo/commit/:sha": {
21153
21153
  $get: {
21154
- output: string;
21155
- outputFormat: "text";
21156
- status: import("hono/utils/http-status").ContentfulStatusCode;
21157
- input: {
21158
- query: {
21159
- structured?: string | undefined;
21160
- };
21161
- } & {
21162
- param: {
21163
- sha: string;
21164
- };
21165
- };
21166
- } | {
21167
21154
  output: {
21168
21155
  error: string;
21169
21156
  code?: "invalid_input" | undefined;
@@ -21227,6 +21214,19 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
21227
21214
  sha: string;
21228
21215
  };
21229
21216
  };
21217
+ } | {
21218
+ output: string;
21219
+ outputFormat: "text";
21220
+ status: import("hono/utils/http-status").ContentfulStatusCode;
21221
+ input: {
21222
+ query: {
21223
+ structured?: string | undefined;
21224
+ };
21225
+ } & {
21226
+ param: {
21227
+ sha: string;
21228
+ };
21229
+ };
21230
21230
  };
21231
21231
  };
21232
21232
  } & {
@@ -34549,20 +34549,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
34549
34549
  } & {
34550
34550
  "/runs/:id/handoff": {
34551
34551
  $get: {
34552
- output: string;
34553
- outputFormat: "text";
34554
- status: 200;
34552
+ output: {
34553
+ error: string;
34554
+ };
34555
+ outputFormat: "json";
34556
+ status: 404;
34555
34557
  input: {
34556
34558
  param: {
34557
34559
  id: string;
34558
34560
  };
34559
34561
  };
34560
34562
  } | {
34561
- output: {
34562
- error: string;
34563
- };
34564
- outputFormat: "json";
34565
- status: 404;
34563
+ output: string;
34564
+ outputFormat: "text";
34565
+ status: 200;
34566
34566
  input: {
34567
34567
  param: {
34568
34568
  id: string;
@@ -34600,20 +34600,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
34600
34600
  } & {
34601
34601
  "/runs/:id/diff": {
34602
34602
  $get: {
34603
- output: string;
34604
- outputFormat: "text";
34605
- status: import("hono/utils/http-status").ContentfulStatusCode;
34603
+ output: {
34604
+ error: string;
34605
+ };
34606
+ outputFormat: "json";
34607
+ status: 404 | 409;
34606
34608
  input: {
34607
34609
  param: {
34608
34610
  id: string;
34609
34611
  };
34610
34612
  };
34611
34613
  } | {
34612
- output: {
34613
- error: string;
34614
- };
34615
- outputFormat: "json";
34616
- status: 404 | 409;
34614
+ output: string;
34615
+ outputFormat: "text";
34616
+ status: import("hono/utils/http-status").ContentfulStatusCode;
34617
34617
  input: {
34618
34618
  param: {
34619
34619
  id: string;
@@ -3300,21 +3300,23 @@ export function createApp(deps) {
3300
3300
  })
3301
3301
  // Task diff (spec 006): what this run changed — its worktree vs its base.
3302
3302
  .get('/runs/:id/diff', async (c) => {
3303
- const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { checksAutosave: true, directory: 'existing-worktree' });
3303
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { directory: 'existing-worktree' });
3304
3304
  if ('body' in checkout)
3305
3305
  return c.json(checkout.body, checkout.status);
3306
- const { run, directory: workingDirectory } = checkout;
3307
- if (!workingDirectory) {
3306
+ if (!checkout.directory)
3308
3307
  return c.text('(no worktree — this task ran directly in the repo working tree)');
3309
- }
3310
- return c.text(await worktreeDiff(workingDirectory, run.baseBranch ?? 'HEAD'));
3308
+ const result = await worktreeDiff(checkout.directory, checkout.run.baseBranch ?? 'HEAD', undefined, checkout.beforeLiveIndex);
3309
+ if (typeof result !== 'string')
3310
+ return c.json({ error: result.error }, 409);
3311
+ return c.text(result);
3311
3312
  })
3312
3313
  .get('/runs/:id/changes', async (c) => {
3313
- const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { checksAutosave: true, directory: 'working-directory' });
3314
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { directory: 'working-directory' });
3314
3315
  if ('body' in checkout)
3315
3316
  return c.json(checkout.body, checkout.status);
3316
3317
  const { run, directory: workingDirectory } = checkout;
3317
3318
  const result = await collectChanges(workingDirectory, run.baseBranch ?? 'HEAD', {
3319
+ beforeLiveIndex: checkout.beforeLiveIndex,
3318
3320
  taskBranch: run.branch,
3319
3321
  // Anchors a repointed worktree at the branch as this run found it (#751).
3320
3322
  runStartedAt: run.startedAt,
@@ -3327,7 +3329,7 @@ export function createApp(deps) {
3327
3329
  })
3328
3330
  // The run's own commits (<base>..HEAD on the worktree branch) — the Commits tab.
3329
3331
  .get('/runs/:id/commits', async (c) => {
3330
- const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { checksAutosave: false, directory: 'working-directory' });
3332
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { directory: 'working-directory' });
3331
3333
  if ('body' in checkout)
3332
3334
  return c.json(checkout.body, checkout.status);
3333
3335
  const { run, directory: workingDirectory } = checkout;
@@ -3338,7 +3340,7 @@ export function createApp(deps) {
3338
3340
  })
3339
3341
  // One of the run's commits, structured like the Changes tab (reuses collectCommitChanges).
3340
3342
  .get('/runs/:id/commit/:sha', async (c) => {
3341
- const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { checksAutosave: false, directory: 'working-directory' });
3343
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { directory: 'working-directory' });
3342
3344
  if ('body' in checkout)
3343
3345
  return c.json(checkout.body, checkout.status);
3344
3346
  const { directory: workingDirectory } = checkout;
@@ -3349,7 +3351,7 @@ export function createApp(deps) {
3349
3351
  })
3350
3352
  .get('/runs/:id/file-link', paramZodValidator(artifactParamsSchema.omit({ artifactId: true })), queryZodValidator(fileLinkQuerySchema), async (c) => {
3351
3353
  const { root, store } = c.get('project');
3352
- const checkout = runCheckout(c.get('project'), c.req.valid('param').id, 'read', { checksAutosave: false, directory: 'recorded-path-or-root' });
3354
+ const checkout = runCheckout(c.get('project'), c.req.valid('param').id, 'read', { directory: 'recorded-path-or-root' });
3353
3355
  if ('body' in checkout)
3354
3356
  return c.json(checkout.body, checkout.status);
3355
3357
  const { run, directory: workingDirectory } = checkout;
@@ -3438,7 +3440,7 @@ export function createApp(deps) {
3438
3440
  const wantsRaw = query.raw !== undefined
3439
3441
  ? query.raw === '1'
3440
3442
  : negotiate(c.req.header('accept'), FILE_FORMATS) === 'image/*';
3441
- const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { checksAutosave: false, directory: 'working-directory' });
3443
+ const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { directory: 'working-directory' });
3442
3444
  if ('body' in checkout)
3443
3445
  return c.json(checkout.body, checkout.status);
3444
3446
  const { directory: workingDirectory } = checkout;