borgmcp 0.9.35 → 0.9.37

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 +1 @@
1
- {"version":3,"file":"roster-render.js","sourceRoot":"","sources":["../src/roster-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA8BH,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACpE,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC/C,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAE7C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;IAC5C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,IAAI,aAAa,EAAE,CAAC;QAClB,kEAAkE;QAClE,sDAAsD;QACtD,KAAK,CAAC,IAAI,CACR,yBAAyB,aAAa,KAAK,QAAQ,CACjD,aAAa,CACd,gEAAgE,CAClE,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QACtC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACrC,MAAM,QAAQ,GAAG,IAAI,EAAE,IAAI,IAAI,SAAS,CAAC;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,SAAS,CAAC;YAC/C,KAAK,CAAC,IAAI,CACR,OAAO,CAAC,CAAC,KAAK,OAAO,SAAS,iBAAiB,QAAQ,MAAM,MAAM,EAAE,CACtE,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CACR,OAAO,CAAC,CAAC,KAAK,OAAO,SAAS,iBAAiB,QAAQ,EAAE,CAC1D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
package/dist/sync.d.ts CHANGED
@@ -1,61 +1,54 @@
1
1
  /**
2
2
  * `borg sync` — worktree lifecycle management subcommand (gh#33).
3
3
  *
4
- * Detects the current state of the operator's git worktree and either
5
- * advances it (fast-forward main, merge origin/main into a feature
6
- * branch, switch to main after a feature branch was merged + deleted
7
- * on origin) or refuses cleanly (dirty tree, network failure).
4
+ * Reconciled to the per-worktree `wt-<suffix>` branch model (PR-B,
5
+ * ruling ea643b33). Replaces the previous main-centric semantics
6
+ * ("idle = on main"; "post-merge = checkout main") under the approved
7
+ * gh#33 model `main` is NEVER a working branch in any worktree; it is
8
+ * purely the integration target. Every worktree works on a named
9
+ * `wt-<suffix>` branch and `borg sync` keeps it current with
10
+ * origin/main, returns to it after a feature branch merges, and absorbs
11
+ * upstream into an in-progress feature branch — never touching `main`
12
+ * as a checkout.
8
13
  *
9
- * Five lifecycle states:
10
- * 1. dirty — uncommitted changes present; refuse + tell
11
- * operator to commit/stash/restore first.
12
- * 2. idle — on main, clean, up-to-date with origin/main
13
- * (or fast-forwarded). Nothing to sync.
14
- * 3. mid-sprint-noop — on a feature branch; origin/main has not
15
- * advanced since the branch's merge base.
16
- * Nothing to do.
17
- * 4. mid-sprint-merge — on a feature branch; origin/main advanced.
18
- * Merge origin/main into the feature branch
19
- * (no rebase, per cube workflow rule (a)).
20
- * 5. post-merge — on a local branch whose remote was deleted
21
- * (typical post-PR-merge state); switch to
22
- * main and pull. Local merged branch is left
23
- * intact for the operator to delete manually.
14
+ * All git mutation/decision logic is delegated to
15
+ * `client/src/worktree-lifecycle.ts` (the seam PR-A added:
16
+ * `adoptWorktree`, `syncWorktree`, `cleanupMerged`, `isMerged`,
17
+ * `localBranchExists`) so the never-discard guards (dirty / unmerged
18
+ * HEAD / unmerged target wt- branch) and the args-array subprocess
19
+ * shape are shared, not duplicated.
24
20
  *
25
- * The subcommand mirrors `borg spawn`'s dependency-injection shape so
26
- * tests can stub every external interaction (git, filesystem, output).
21
+ * Lifecycle states:
22
+ * 1. dirty — uncommitted changes; refuse (never discard).
23
+ * 2. on-wt — on the per-worktree `wt-<suffix>` branch;
24
+ * fast-forward it to origin/main (ff-only).
25
+ * 3. on-main — on `main`/`master` (or detached at a merged
26
+ * point); adopt the `wt-<suffix>` branch
27
+ * (Q4: main is never a working branch).
28
+ * 4. feature-mid-sprint — on a feature branch not yet merged; absorb
29
+ * origin/main into it via `git merge --no-edit`
30
+ * (no rebase — cube workflow rule (a)) when
31
+ * origin/main advanced; else no-op.
32
+ * 5. feature-merged — on a feature branch fully merged into
33
+ * origin/main; return to `wt-<suffix>` and
34
+ * ANNOUNCE the prunable feature branch (prune
35
+ * only with `--prune`, Q3).
27
36
  *
28
- * Anti-features (intentional):
29
- * - No auto-stash, no auto-commit, no auto-discard on dirty tree.
30
- * Fail-loud per cube discipline.
31
- * - No force-push, no rebase, no --force-with-lease (cube rules a, b).
32
- * - No local-branch deletion (operator decides; sync just announces).
33
- * - No remote-branch deletion (Coordinator owns merge actions, not
34
- * this subcommand).
37
+ * Anti-features (intentional, unchanged):
38
+ * - No auto-stash / auto-commit / auto-discard on dirty tree.
39
+ * - No force-push, no rebase, no --force-with-lease.
40
+ * - No remote-branch deletion (Coordinator owns merge actions).
41
+ * - Local feature-branch deletion only on explicit `--prune` (Q3).
35
42
  */
36
- export type SyncState = {
37
- kind: 'dirty';
38
- files: string[];
39
- } | {
40
- kind: 'idle';
41
- branch: string;
42
- head: string;
43
- } | {
44
- kind: 'mid-sprint-noop';
45
- branch: string;
46
- head: string;
47
- } | {
48
- kind: 'mid-sprint-merge';
49
- branch: string;
50
- commits: number;
51
- } | {
52
- kind: 'post-merge';
53
- branch: string;
54
- mergedSha: string;
55
- };
43
+ import { type RunSync } from './worktree-lifecycle.js';
44
+ export interface SpawnSyncResult {
45
+ status: number | null;
46
+ stdout: string;
47
+ stderr: string;
48
+ }
56
49
  export interface SyncDeps {
57
50
  /** Synchronous spawn — used for `git ...` invocations. */
58
- runSync?: (cmd: string, args: string[], cwd?: string) => SpawnSyncResult;
51
+ runSync?: RunSync;
59
52
  /** Inject for tests; defaults to `process.cwd()`. */
60
53
  cwd?: () => string;
61
54
  /** stderr sink — overridable for tests. */
@@ -63,37 +56,74 @@ export interface SyncDeps {
63
56
  /** stdout sink — overridable for tests. */
64
57
  stdout?: (line: string) => void;
65
58
  }
66
- export interface SpawnSyncResult {
67
- status: number | null;
68
- stdout: string;
69
- stderr: string;
59
+ export interface SyncOptions {
60
+ /** Q3: prune a merged feature branch instead of only announcing it. */
61
+ prune: boolean;
70
62
  }
71
63
  /**
72
- * Detect the worktree's current lifecycle state. Read-only performs
73
- * a `git fetch origin` before measuring so origin/main reflects the
74
- * latest remote tip.
64
+ * Resolve the per-worktree `wt-` branch for the current checkout,
65
+ * DETERMINISTICALLY per worktree.
66
+ *
67
+ * - current branch is already `wt-*` → that is the branch.
68
+ * - otherwise → derive `wt-<suffix>` from THIS worktree's directory
69
+ * basename minus the main worktree's (repo) basename prefix — the
70
+ * same `perWorktreeBranchName` derivation the spawn path uses, so
71
+ * the name matches what `borg assimilate --worktree` created.
75
72
  *
76
- * Returns an error variant if the worktree is not a git repository
77
- * OR if the remote fetch fails.
73
+ * This must NOT list `git branch --list wt-*`: in linked worktrees the
74
+ * local branch namespace is SHARED across all siblings (gh#33 CR-v2
75
+ * blocker 32bc45da), so every drone's `wt-` branch is visible and a
76
+ * "single match" heuristic is never satisfied in a real multi-drone
77
+ * cube. The directory-derivation is unique per worktree and never
78
+ * ambiguous. The first `worktree <path>` line of
79
+ * `git worktree list --porcelain` is the main worktree (the repo dir);
80
+ * its basename is the prefix to strip. For an independent clone the
81
+ * main worktree IS this worktree, so the prefix == basename and the
82
+ * result is `wt-<basename>` (no strip) — consistent with PR-A's
83
+ * in-place adoption.
78
84
  */
79
- export declare function detectState(deps: Required<SyncDeps>): SyncState | {
85
+ export declare function resolveWtBranch(runSync: RunSync, cwd: string, currentBranch: string): string;
86
+ export type SyncState = {
87
+ kind: 'dirty';
88
+ files: string[];
89
+ } | {
90
+ kind: 'on-wt';
91
+ branch: string;
92
+ wtBranch: string;
93
+ } | {
94
+ kind: 'on-main';
95
+ branch: string;
96
+ wtBranch: string;
97
+ } | {
98
+ kind: 'feature-mid-sprint';
99
+ branch: string;
100
+ wtBranch: string;
101
+ commits: number;
102
+ } | {
103
+ kind: 'feature-merged';
104
+ branch: string;
105
+ wtBranch: string;
106
+ } | {
80
107
  kind: 'error';
81
108
  reason: string;
82
109
  };
83
110
  /**
84
- * Run the `borg sync` flow. Returns the desired process exit code.
111
+ * Detect the worktree's lifecycle state. Read-only except for the
112
+ * `git fetch origin --prune` needed to measure against the latest tip.
85
113
  */
86
- export declare function runSync(deps?: SyncDeps): Promise<number>;
114
+ export declare function detectState(deps: Required<SyncDeps>): SyncState;
115
+ export declare function runSync(deps?: SyncDeps, opts?: SyncOptions): Promise<number>;
87
116
  export type ParseResult = {
88
117
  ok: true;
118
+ options: SyncOptions;
89
119
  } | {
90
120
  ok: false;
91
121
  error: string;
92
122
  };
93
123
  /**
94
- * Parse args passed after `borg sync`. No positional args, no flags
95
- * today; reject anything that looks like one to keep room for future
96
- * extensions (e.g., --dry-run).
124
+ * Parse args after `borg sync`. Supports `--prune` (Q3: delete a merged
125
+ * feature branch after returning to the wt- branch). Rejects anything
126
+ * else to keep room for future flags.
97
127
  */
98
128
  export declare function parseSyncArgs(rawArgs: string[]): ParseResult;
99
129
  //# sourceMappingURL=sync.d.ts.map
@@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