checkpointer 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.
Files changed (2) hide show
  1. package/dist/cli.js +33 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -223,6 +223,22 @@ var Metadata = class _Metadata {
223
223
  unshipped() {
224
224
  return this.data.checkpoints.filter((cp) => cp.seq > this.data.shippedSeq && !cp.auto);
225
225
  }
226
+ // Returns seq ranges [from, to] that were abandoned by a restore. A restore
227
+ // to checkpoint X means everything between X+1 and the before-restore
228
+ // checkpoint is "set aside" — those checkpoints still exist for recovery but
229
+ // are not part of the current line of work.
230
+ abandonedRanges() {
231
+ const ranges = [];
232
+ for (const cp of this.data.checkpoints) {
233
+ if (cp.auto && cp.name.startsWith("before-restore-") && cp.restoredToSeq !== void 0) {
234
+ ranges.push({ from: cp.restoredToSeq + 1, to: cp.seq - 1 });
235
+ }
236
+ }
237
+ return ranges;
238
+ }
239
+ isAbandoned(seq) {
240
+ return this.abandonedRanges().some((r) => seq >= r.from && seq <= r.to);
241
+ }
226
242
  };
227
243
 
228
244
  // src/core/paths.ts
@@ -429,7 +445,8 @@ var Store = class _Store {
429
445
  session: input.session,
430
446
  intent: input.intent,
431
447
  auto,
432
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
448
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
449
+ ...input.restoredToSeq !== void 0 ? { restoredToSeq: input.restoredToSeq } : {}
433
450
  };
434
451
  this.meta.add(checkpoint);
435
452
  return checkpoint;
@@ -451,7 +468,8 @@ var Store = class _Store {
451
468
  agent: null,
452
469
  session: null,
453
470
  intent: null,
454
- auto: true
471
+ auto: true,
472
+ restoredToSeq: target.seq
455
473
  });
456
474
  this.git.restoreTree(target.sha);
457
475
  return safety;
@@ -482,7 +500,9 @@ function planShip(store, uptoRef) {
482
500
  const all = store.meta.all();
483
501
  const shippedSeq = store.meta.shippedSeq();
484
502
  const from = all.find((cp) => cp.seq === shippedSeq) ?? null;
485
- const included = all.filter((cp) => cp.seq > shippedSeq && cp.seq <= upto.seq && !cp.auto);
503
+ const included = all.filter(
504
+ (cp) => cp.seq > shippedSeq && cp.seq <= upto.seq && !cp.auto && !store.meta.isAbandoned(cp.seq)
505
+ );
486
506
  return {
487
507
  upto,
488
508
  from,
@@ -531,6 +551,9 @@ function latestOrFail(store) {
531
551
 
532
552
  // src/ui/format.ts
533
553
  import pc from "picocolors";
554
+ function restoreDivider(targetName) {
555
+ return pc.dim(` ${"\u2500".repeat(20)} restored to '${targetName}' \u2014 history above set aside ${"\u2500".repeat(20)}`);
556
+ }
534
557
  function statusBadge(status2) {
535
558
  switch (status2) {
536
559
  case "working":
@@ -622,7 +645,13 @@ function list(opts = {}) {
622
645
  return;
623
646
  }
624
647
  const shipped = store.meta.shippedSeq();
625
- for (const cp of checkpoints) console.log(checkpointLine(cp, shipped));
648
+ for (const cp of checkpoints) {
649
+ console.log(checkpointLine(cp, shipped));
650
+ if (cp.auto && cp.name.startsWith("before-restore-") && cp.restoredToSeq !== void 0) {
651
+ const target = store.meta.find(`#${cp.restoredToSeq}`);
652
+ if (target) console.log(restoreDivider(target.name));
653
+ }
654
+ }
626
655
  const legend = [];
627
656
  if (shipped > 0) legend.push("\u2713 shipped to git");
628
657
  if (checkpoints.some((cp) => cp.auto)) legend.push("\xB7 auto safety checkpoint");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "checkpointer",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Git-isolated checkpoints that humans and AI agents share — save working states, revert anytime, ship a range as one clean commit.",
5
5
  "keywords": [
6
6
  "checkpoint",