@laoyuehanni/dsh-git-worktree 0.4.15 → 0.4.16

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/lib/wire.d.ts CHANGED
@@ -118,6 +118,12 @@ export declare const ROUTE_DEFERRED_EVENTS = "/plugin/git-worktree/deferred/even
118
118
  export declare const ROUTE_DEFERRED_ARM = "/plugin/git-worktree/deferred/arm";
119
119
  /** POST ROUTE_PREFIX/deferred/action — cancel, retry, or withdraw a deferred worktree. */
120
120
  export declare const ROUTE_DEFERRED_ACTION = "/plugin/git-worktree/deferred/action";
121
+ /** POST ROUTE_PREFIX/pr-context — remotes, optional forge readiness, and open PR/MR candidates. */
122
+ export declare const ROUTE_PR_CONTEXT = "/plugin/git-worktree/pr-context";
123
+ /** POST ROUTE_PREFIX/pr-resolve — resolve a PR/MR ID or URL to its fetch ref, branch, and path. */
124
+ export declare const ROUTE_PR_RESOLVE = "/plugin/git-worktree/pr-resolve";
125
+ /** POST ROUTE_PREFIX/pr-checkout — stream PR/MR fetch + isolated worktree creation. */
126
+ export declare const ROUTE_PR_CHECKOUT = "/plugin/git-worktree/pr-checkout";
121
127
  /** One selectable branch row. */
122
128
  export interface BranchEntry {
123
129
  /** Display name: a bare local name (`main`) or `<remote>/<name>`. */
@@ -377,6 +383,9 @@ export type SyncEvent = {
377
383
  remote?: string;
378
384
  } | {
379
385
  type: 'merge';
386
+ } | {
387
+ type: 'stage';
388
+ stage: 'fetch' | 'worktree' | 'copy';
380
389
  };
381
390
  /**
382
391
  * One line of a streamed route response. The last line is always `done`,
@@ -391,6 +400,10 @@ export type SyncFrame = SyncEvent | {
391
400
  /** Error envelope every non-2xx response carries. */
392
401
  export interface RouteError {
393
402
  error: string;
403
+ /** Optional machine-readable error code for localized client presentation. */
404
+ code?: string;
405
+ /** Optional structured parameters accompanying `code`. */
406
+ params?: Record<string, string | number>;
394
407
  }
395
408
  /** Git belonging facts of one workspace directory; null = not a git repository. */
396
409
  export interface WorkspaceGitFacts {
@@ -550,6 +563,15 @@ export interface SetSessionDirectoryResult {
550
563
  }
551
564
  /** Phases reported while a deferred worktree creation runs on the first user turn. */
552
565
  export type DeferredWorktreePhase = 'fetch' | 'create' | 'copy' | 'switch';
566
+ /** PR/MR checkout payload attached to a deferred worktree request in shared-workspace mode. */
567
+ export interface DeferredPrCheckoutSpec {
568
+ readonly input: string;
569
+ readonly remote?: string;
570
+ readonly provider?: PrProviderKind;
571
+ readonly ifExists?: 'reuse' | 'update' | 'reset';
572
+ /** Canonical PR/MR web URL to track in host forge panel after completion, or null when auto-track was opted out. */
573
+ readonly canonicalUrl?: string | null;
574
+ }
553
575
  /** Specification of a deferred worktree creation armed on a blank session. */
554
576
  export interface DeferredWorktreeSpec {
555
577
  /** Main repository path (or any path inside the repository). */
@@ -562,6 +584,8 @@ export interface DeferredWorktreeSpec {
562
584
  readonly name?: string;
563
585
  /** Generate a random `<stem>-<4hex>` branch name when `cutout` is true and `name` is absent. */
564
586
  readonly random?: boolean;
587
+ /** Present when this deferred slot checks out or enters a PR/MR worktree on the first turn. */
588
+ readonly pr?: DeferredPrCheckoutSpec;
565
589
  }
566
590
  /** Live state of a deferred worktree for one session. */
567
591
  export type DeferredWorktreeState = {
@@ -588,6 +612,7 @@ export interface DeferredWorktreeCompleted {
588
612
  readonly fetchWarning?: string;
589
613
  readonly excludeWarning?: string;
590
614
  readonly copyWarning?: string;
615
+ readonly trackPrUrl?: string;
591
616
  }
592
617
  /** Snapshot / SSE payload pushed for a session's deferred worktree. */
593
618
  export interface DeferredWorktreeSnapshot {
@@ -602,9 +627,120 @@ export interface ArmDeferredWorktreeBody {
602
627
  readonly cutout?: boolean;
603
628
  readonly name?: string;
604
629
  readonly random?: boolean;
630
+ readonly pr?: DeferredPrCheckoutSpec;
605
631
  }
606
632
  /** POST deferred/action request body. */
607
633
  export interface DeferredWorktreeActionBody {
608
634
  readonly sessionId: string;
609
635
  readonly action: 'cancel' | 'retry' | 'withdraw';
610
636
  }
637
+ /** Supported code-hosting provider kinds for PR/MR checkout. */
638
+ export type PrProviderKind = 'github' | 'gitlab';
639
+ /** Machine-readable error codes emitted by PR/MR routes for localized UI handling. */
640
+ export type PrErrorCode = 'no_remotes' | 'empty_input' | 'invalid_input' | 'unsupported_provider' | 'url_repo_mismatch' | 'remote_not_found' | 'provider_undetected' | 'occupied_by_main' | 'worktree_dirty' | 'worktree_diverged' | 'pr_ref_not_found' | 'pr_auth_failed' | 'pr_timeout' | 'pr_network_failed';
641
+ /** One Git remote classified for PR/MR resolution. */
642
+ export interface PrRemoteInfo {
643
+ name: string;
644
+ url: string;
645
+ /** Classified provider kind (`github` or `gitlab`), or null when unrecognized. */
646
+ provider: PrProviderKind | null;
647
+ host: string | null;
648
+ owner: string | null;
649
+ repo: string | null;
650
+ }
651
+ /** One candidate PR/MR returned by optional host `ctx.forge` integration. */
652
+ export interface PrCandidateItem {
653
+ provider: PrProviderKind;
654
+ host: string;
655
+ owner: string;
656
+ repo: string;
657
+ number: number;
658
+ url: string;
659
+ title: string;
660
+ author: string | null;
661
+ draft: boolean;
662
+ checksRollup: 'none' | 'pending' | 'success' | 'failure';
663
+ reviewDecision: 'approved' | 'changes-requested' | 'review-required' | 'none';
664
+ filter: 'review-requested' | 'authored' | 'involved';
665
+ updatedAt: string;
666
+ remote: string;
667
+ localBranch: string;
668
+ existingWorktreePath?: string;
669
+ }
670
+ /** POST pr-context request body. */
671
+ export interface PrContextBody {
672
+ repoPath: string;
673
+ /** Optional explicit remote to scope optional Forge readiness & candidates. */
674
+ remote?: string;
675
+ }
676
+ /** POST pr-context response body. */
677
+ export interface PrContextResult {
678
+ repoRoot: string;
679
+ repoName: string;
680
+ remotes: PrRemoteInfo[];
681
+ defaultRemote: string | null;
682
+ forge: {
683
+ available: boolean;
684
+ readiness: 'ready' | 'unauthenticated' | 'unavailable' | 'unsupported';
685
+ signInCommand?: string;
686
+ message?: string;
687
+ /** True when the host `ctx.forge` service is ready but does not expose viewer PR list queries yet. */
688
+ listUnsupported?: boolean;
689
+ };
690
+ candidates: PrCandidateItem[];
691
+ }
692
+ /** POST pr-resolve request body. */
693
+ export interface PrResolveBody {
694
+ repoPath: string;
695
+ /** Numeric ID (`42`, `#42`, `!42`) or full PR/MR web URL. */
696
+ input: string;
697
+ remote?: string;
698
+ provider?: PrProviderKind;
699
+ /** Verify the target ref exists on the remote via `git ls-remote` (default: `true`). Pass `false` for items just picked from the live Forge candidate list. */
700
+ verifyRemote?: boolean;
701
+ }
702
+ /** POST pr-resolve response body. */
703
+ export interface PrResolveResult {
704
+ provider: PrProviderKind;
705
+ number: number;
706
+ remote: string;
707
+ refSpec: string;
708
+ localBranch: string;
709
+ targetPath: string;
710
+ canonicalUrl: string | null;
711
+ existingWorktreePath?: string;
712
+ existingBranch?: boolean;
713
+ /** True when the main checkout itself currently holds `localBranch` (blocks linked worktree creation). */
714
+ occupiedByMain?: boolean;
715
+ meta?: {
716
+ title: string;
717
+ author: string | null;
718
+ state: 'open' | 'closed' | 'merged';
719
+ draft: boolean;
720
+ headBranch: string;
721
+ baseBranch: string;
722
+ };
723
+ }
724
+ /** POST pr-checkout request body. */
725
+ export interface PrCheckoutBody {
726
+ repoPath: string;
727
+ input: string;
728
+ remote?: string;
729
+ provider?: PrProviderKind;
730
+ /** When the PR's worktree already exists: reuse immediately, fast-forward/safe-sync when clean, or force-reset after confirmation. */
731
+ ifExists?: 'reuse' | 'update' | 'reset';
732
+ }
733
+ /** POST pr-checkout response body. */
734
+ export interface PrCheckoutResult extends CreateWorktreeResult {
735
+ branch: string;
736
+ provider: PrProviderKind;
737
+ number: number;
738
+ canonicalUrl: string | null;
739
+ updated?: boolean;
740
+ /** True when remote PR history was force-pushed and the clean local PR worktree had no local commits so it was safely synced. */
741
+ forceUpdated?: boolean;
742
+ /** True when the user explicitly confirmed resetting a diverged local PR worktree to the latest remote PR tip. */
743
+ reset?: boolean;
744
+ /** True when an existing local branch with diverged local commits was preserved as-is. */
745
+ preservedLocalBranch?: boolean;
746
+ }
package/lib/wire.js CHANGED
@@ -70,5 +70,11 @@ export const ROUTE_DEFERRED_EVENTS = `${ROUTE_PREFIX}/deferred/events`;
70
70
  export const ROUTE_DEFERRED_ARM = `${ROUTE_PREFIX}/deferred/arm`;
71
71
  /** POST ROUTE_PREFIX/deferred/action — cancel, retry, or withdraw a deferred worktree. */
72
72
  export const ROUTE_DEFERRED_ACTION = `${ROUTE_PREFIX}/deferred/action`;
73
+ /** POST ROUTE_PREFIX/pr-context — remotes, optional forge readiness, and open PR/MR candidates. */
74
+ export const ROUTE_PR_CONTEXT = `${ROUTE_PREFIX}/pr-context`;
75
+ /** POST ROUTE_PREFIX/pr-resolve — resolve a PR/MR ID or URL to its fetch ref, branch, and path. */
76
+ export const ROUTE_PR_RESOLVE = `${ROUTE_PREFIX}/pr-resolve`;
77
+ /** POST ROUTE_PREFIX/pr-checkout — stream PR/MR fetch + isolated worktree creation. */
78
+ export const ROUTE_PR_CHECKOUT = `${ROUTE_PREFIX}/pr-checkout`;
73
79
  /** Content type of a streamed route: one JSON {@link SyncFrame} per line. */
74
80
  export const NDJSON_TYPE = 'application/x-ndjson';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laoyuehanni/dsh-git-worktree",
3
- "version": "0.4.15",
3
+ "version": "0.4.16",
4
4
  "description": "DSH plugin: branch visibility and git worktree isolation for Web UI sessions",
5
5
  "icon": "./icon.svg",
6
6
  "keywords": [