dirban 0.1.7 → 0.1.8

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/dirban.js +385 -213
  2. package/package.json +1 -1
package/dist/dirban.js CHANGED
@@ -7198,7 +7198,7 @@ import * as process8 from "process";
7198
7198
  // package.json
7199
7199
  var package_default = {
7200
7200
  name: "dirban",
7201
- version: "0.1.7",
7201
+ version: "0.1.8",
7202
7202
  description: "Zero-Database, Agent-Native Kanban Engine & TUI Backed by the File System and Google Open Knowledge Format (OKF)",
7203
7203
  type: "module",
7204
7204
  main: "./dist/dirban.js",
@@ -7742,6 +7742,7 @@ var DEFAULT_CONFIG = Object.freeze({
7742
7742
  defaultPriority: DEFAULT_PRIORITY,
7743
7743
  branchStrategy: DEFAULT_BRANCH_STRATEGY,
7744
7744
  autoMerge: true,
7745
+ mergeStrategy: "merge",
7745
7746
  worktreesDir: DEFAULT_WORKTREES_DIR,
7746
7747
  branchPrefix: DEFAULT_BRANCH_PREFIX,
7747
7748
  focusColumn: undefined
@@ -7769,6 +7770,8 @@ var parseRawConfigObject = (raw, isVsCodeSettings = false) => {
7769
7770
  const branchStrategy = branchStrategyRaw === "checkout" || branchStrategyRaw === "worktree" || branchStrategyRaw === "none" ? branchStrategyRaw : undefined;
7770
7771
  const autoMergeRaw = getVal("autoMerge");
7771
7772
  const autoMerge = typeof autoMergeRaw === "boolean" ? autoMergeRaw : undefined;
7773
+ const mergeStrategyRaw = getVal("mergeStrategy");
7774
+ const mergeStrategy = mergeStrategyRaw === "merge" || mergeStrategyRaw === "squash" || mergeStrategyRaw === "rebase" ? mergeStrategyRaw : undefined;
7772
7775
  const worktreesDirRaw = getVal("worktreesDir");
7773
7776
  const worktreesDir = typeof worktreesDirRaw === "string" && worktreesDirRaw.trim() !== "" ? worktreesDirRaw.trim() : undefined;
7774
7777
  const branchPrefixRaw = getVal("branchPrefix");
@@ -7782,6 +7785,7 @@ var parseRawConfigObject = (raw, isVsCodeSettings = false) => {
7782
7785
  defaultPriority,
7783
7786
  branchStrategy,
7784
7787
  autoMerge,
7788
+ mergeStrategy,
7785
7789
  worktreesDir,
7786
7790
  branchPrefix,
7787
7791
  focusColumn
@@ -7825,6 +7829,7 @@ var loadConfig = (workspaceRoot = process.cwd()) => {
7825
7829
  defaultPriority: parsed.defaultPriority ?? DEFAULT_CONFIG.defaultPriority,
7826
7830
  branchStrategy: parsed.branchStrategy ?? DEFAULT_CONFIG.branchStrategy,
7827
7831
  autoMerge: parsed.autoMerge ?? DEFAULT_CONFIG.autoMerge,
7832
+ mergeStrategy: parsed.mergeStrategy ?? DEFAULT_CONFIG.mergeStrategy,
7828
7833
  worktreesDir: parsed.worktreesDir ?? DEFAULT_CONFIG.worktreesDir,
7829
7834
  branchPrefix: parsed.branchPrefix ?? DEFAULT_CONFIG.branchPrefix,
7830
7835
  focusColumn: parsed.focusColumn ?? DEFAULT_CONFIG.focusColumn
@@ -8111,7 +8116,7 @@ var import_picocolors2 = __toESM(require_picocolors2(), 1);
8111
8116
  import * as process3 from "node:process";
8112
8117
 
8113
8118
  // src/board/discovery.ts
8114
- import * as fs5 from "node:fs";
8119
+ import * as fs6 from "node:fs";
8115
8120
  import * as path7 from "node:path";
8116
8121
 
8117
8122
  // src/config/config.ts
@@ -8138,6 +8143,7 @@ var DEFAULT_CONFIG2 = Object.freeze({
8138
8143
  defaultPriority: DEFAULT_PRIORITY2,
8139
8144
  branchStrategy: DEFAULT_BRANCH_STRATEGY2,
8140
8145
  autoMerge: true,
8146
+ mergeStrategy: "merge",
8141
8147
  worktreesDir: DEFAULT_WORKTREES_DIR2,
8142
8148
  branchPrefix: DEFAULT_BRANCH_PREFIX2,
8143
8149
  focusColumn: undefined
@@ -8423,15 +8429,24 @@ var parseTaskDocument = (rawContent, filename) => {
8423
8429
 
8424
8430
  // src/vcs/git/commit.ts
8425
8431
  import { spawnSync } from "node:child_process";
8432
+ import * as fs3 from "node:fs";
8433
+ var isTrackedInGit = (filePath, cwd) => {
8434
+ const res = spawnSync("git", ["ls-files", "--error-unmatch", "--", filePath], {
8435
+ cwd,
8436
+ stdio: "ignore"
8437
+ });
8438
+ return res.status === 0;
8439
+ };
8426
8440
  var commitSingleGitFile = (context, filePaths, message, cwd = process.cwd()) => {
8427
8441
  if (!context.isAvailable || context.repoRoot == null) {
8428
8442
  return $ok(undefined);
8429
8443
  }
8430
- if (filePaths.length === 0) {
8444
+ const stageablePaths = filePaths.filter((p) => fs3.existsSync(p) || isTrackedInGit(p, cwd));
8445
+ if (stageablePaths.length === 0) {
8431
8446
  return $ok(undefined);
8432
8447
  }
8433
8448
  try {
8434
- const addRes = spawnSync("git", ["add", "--", ...filePaths], {
8449
+ const addRes = spawnSync("git", ["add", "--", ...stageablePaths], {
8435
8450
  cwd,
8436
8451
  encoding: "utf-8",
8437
8452
  stdio: ["pipe", "pipe", "pipe"]
@@ -8439,10 +8454,10 @@ var commitSingleGitFile = (context, filePaths, message, cwd = process.cwd()) =>
8439
8454
  if (addRes.status !== 0) {
8440
8455
  return $err({
8441
8456
  kind: "COMMAND_ERROR",
8442
- message: `Failed to stage file(s) '${filePaths.join(", ")}': ${addRes.stderr.trim()}`
8457
+ message: `Failed to stage file(s) '${stageablePaths.join(", ")}': ${addRes.stderr.trim()}`
8443
8458
  });
8444
8459
  }
8445
- const commitRes = spawnSync("git", ["commit", "-m", message, "--", ...filePaths], {
8460
+ const commitRes = spawnSync("git", ["commit", "-m", message, "--", ...stageablePaths], {
8446
8461
  cwd,
8447
8462
  encoding: "utf-8",
8448
8463
  stdio: ["pipe", "pipe", "pipe"]
@@ -8450,7 +8465,7 @@ var commitSingleGitFile = (context, filePaths, message, cwd = process.cwd()) =>
8450
8465
  if (commitRes.status !== 0) {
8451
8466
  return $err({
8452
8467
  kind: "COMMAND_ERROR",
8453
- message: `Failed to commit file(s) '${filePaths.join(", ")}': ${commitRes.stderr.trim()}`
8468
+ message: `Failed to commit file(s) '${stageablePaths.join(", ")}': ${commitRes.stderr.trim()}`
8454
8469
  });
8455
8470
  }
8456
8471
  return $ok(undefined);
@@ -8463,19 +8478,185 @@ var commitSingleGitFile = (context, filePaths, message, cwd = process.cwd()) =>
8463
8478
  }
8464
8479
  };
8465
8480
  // src/vcs/git/git.ts
8466
- import { spawnSync as spawnSync3 } from "node:child_process";
8467
- import * as fs3 from "node:fs";
8481
+ import { spawnSync as spawnSync4 } from "node:child_process";
8482
+ import * as fs4 from "node:fs";
8468
8483
  import * as path4 from "node:path";
8469
8484
 
8470
- // src/vcs/git/status.ts
8485
+ // src/vcs/git/merge.ts
8471
8486
  import { spawnSync as spawnSync2 } from "node:child_process";
8487
+ var integrateSquash = (repoRoot, taskBranch, baseBranch, commitMessage) => {
8488
+ const squashRes = spawnSync2("git", ["merge", "--squash", taskBranch], {
8489
+ cwd: repoRoot,
8490
+ encoding: "utf-8",
8491
+ stdio: ["pipe", "pipe", "pipe"]
8492
+ });
8493
+ if (squashRes.status !== 0) {
8494
+ spawnSync2("git", ["reset", "--merge"], { cwd: repoRoot, stdio: "ignore" });
8495
+ return $err({
8496
+ kind: "MERGE_ERROR",
8497
+ message: `Failed to squash merge ${taskBranch} into ${baseBranch}: ${squashRes.stderr.trim()}`
8498
+ });
8499
+ }
8500
+ const msg = commitMessage ?? `chore(task): squash ${taskBranch}`;
8501
+ const commitRes = spawnSync2("git", ["commit", "-m", msg], {
8502
+ cwd: repoRoot,
8503
+ encoding: "utf-8",
8504
+ stdio: ["pipe", "pipe", "pipe"]
8505
+ });
8506
+ if (commitRes.status !== 0) {
8507
+ return $err({
8508
+ kind: "MERGE_ERROR",
8509
+ message: `Failed to commit squashed ${taskBranch}: ${commitRes.stderr.trim()}`
8510
+ });
8511
+ }
8512
+ spawnSync2("git", ["branch", "-D", taskBranch], { cwd: repoRoot, stdio: "ignore" });
8513
+ return $ok(undefined);
8514
+ };
8515
+ var integrateRebase = (repoRoot, taskBranch, baseBranch) => {
8516
+ const rebaseRes = spawnSync2("git", ["rebase", baseBranch, taskBranch], {
8517
+ cwd: repoRoot,
8518
+ encoding: "utf-8",
8519
+ stdio: ["pipe", "pipe", "pipe"]
8520
+ });
8521
+ if (rebaseRes.status !== 0) {
8522
+ spawnSync2("git", ["rebase", "--abort"], { cwd: repoRoot, stdio: "ignore" });
8523
+ return $err({
8524
+ kind: "MERGE_ERROR",
8525
+ message: `Failed to rebase ${taskBranch} onto ${baseBranch}: ${rebaseRes.stderr.trim()}`
8526
+ });
8527
+ }
8528
+ const checkoutRes = spawnSync2("git", ["checkout", baseBranch], {
8529
+ cwd: repoRoot,
8530
+ encoding: "utf-8",
8531
+ stdio: ["pipe", "pipe", "pipe"]
8532
+ });
8533
+ if (checkoutRes.status !== 0) {
8534
+ return $err({
8535
+ kind: "COMMAND_ERROR",
8536
+ message: `Failed to checkout ${baseBranch}: ${checkoutRes.stderr.trim()}`
8537
+ });
8538
+ }
8539
+ const ffRes = spawnSync2("git", ["merge", "--ff-only", taskBranch], {
8540
+ cwd: repoRoot,
8541
+ encoding: "utf-8",
8542
+ stdio: ["pipe", "pipe", "pipe"]
8543
+ });
8544
+ if (ffRes.status !== 0) {
8545
+ return $err({
8546
+ kind: "MERGE_ERROR",
8547
+ message: `Failed to fast-forward ${baseBranch} to ${taskBranch}: ${ffRes.stderr.trim()}`
8548
+ });
8549
+ }
8550
+ spawnSync2("git", ["branch", "-d", taskBranch], { cwd: repoRoot, stdio: "ignore" });
8551
+ return $ok(undefined);
8552
+ };
8553
+ var integrateMerge = (repoRoot, taskBranch, baseBranch) => {
8554
+ const mergeResult = spawnSync2("git", ["merge", "--no-ff", "-m", `Merge branch '${taskBranch}' into ${baseBranch}`, taskBranch], { cwd: repoRoot, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
8555
+ if (mergeResult.status !== 0) {
8556
+ spawnSync2("git", ["merge", "--abort"], { cwd: repoRoot, stdio: "ignore" });
8557
+ return $err({
8558
+ kind: "MERGE_ERROR",
8559
+ message: `Failed to merge ${taskBranch} into ${baseBranch}: ${mergeResult.stderr.trim()}`
8560
+ });
8561
+ }
8562
+ return $ok(undefined);
8563
+ };
8564
+ var integrateBranch = (repoRoot, taskBranch, baseBranch, strategy, commitMessage) => {
8565
+ const strategies = {
8566
+ squash: () => integrateSquash(repoRoot, taskBranch, baseBranch, commitMessage),
8567
+ rebase: () => integrateRebase(repoRoot, taskBranch, baseBranch),
8568
+ merge: () => integrateMerge(repoRoot, taskBranch, baseBranch)
8569
+ };
8570
+ return strategies[strategy]();
8571
+ };
8572
+ var mergeWorktreeAndCleanup = (repoRoot, cwd, options, strategy) => {
8573
+ const headRes = spawnSync2("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
8574
+ cwd: repoRoot,
8575
+ encoding: "utf-8",
8576
+ stdio: ["pipe", "pipe", "pipe"]
8577
+ });
8578
+ const currentBranch = headRes.stdout?.trim();
8579
+ if (currentBranch !== options.baseBranch) {
8580
+ const checkoutBase = spawnSync2("git", ["checkout", options.baseBranch], {
8581
+ cwd: repoRoot,
8582
+ encoding: "utf-8",
8583
+ stdio: ["pipe", "pipe", "pipe"]
8584
+ });
8585
+ if (checkoutBase.status !== 0) {
8586
+ return $err({
8587
+ kind: "COMMAND_ERROR",
8588
+ message: `Failed to checkout ${options.baseBranch} in ${repoRoot}: ${checkoutBase.stderr.trim()}`
8589
+ });
8590
+ }
8591
+ }
8592
+ if (strategy === "rebase") {
8593
+ const rebaseRes = spawnSync2("git", ["rebase", options.baseBranch], {
8594
+ cwd,
8595
+ encoding: "utf-8",
8596
+ stdio: ["pipe", "pipe", "pipe"]
8597
+ });
8598
+ if (rebaseRes.status !== 0) {
8599
+ spawnSync2("git", ["rebase", "--abort"], { cwd, stdio: "ignore" });
8600
+ return $err({
8601
+ kind: "MERGE_ERROR",
8602
+ message: `Failed to rebase ${options.taskBranch} onto ${options.baseBranch}: ${rebaseRes.stderr.trim()}`
8603
+ });
8604
+ }
8605
+ const ffRes = spawnSync2("git", ["merge", "--ff-only", options.taskBranch], {
8606
+ cwd: repoRoot,
8607
+ encoding: "utf-8",
8608
+ stdio: ["pipe", "pipe", "pipe"]
8609
+ });
8610
+ if (ffRes.status !== 0) {
8611
+ return $err({
8612
+ kind: "MERGE_ERROR",
8613
+ message: `Failed to fast-forward ${options.baseBranch} to ${options.taskBranch}: ${ffRes.stderr.trim()}`
8614
+ });
8615
+ }
8616
+ } else {
8617
+ const integrateRes = integrateBranch(repoRoot, options.taskBranch, options.baseBranch, strategy, options.commitMessage);
8618
+ if (integrateRes.isErr())
8619
+ return $err(integrateRes.error);
8620
+ }
8621
+ const removeResult = spawnSync2("git", ["worktree", "remove", cwd], {
8622
+ cwd: repoRoot,
8623
+ encoding: "utf-8",
8624
+ stdio: ["pipe", "pipe", "pipe"]
8625
+ });
8626
+ const branchDeleteFlag = strategy === "squash" ? "-D" : "-d";
8627
+ spawnSync2("git", ["branch", branchDeleteFlag, options.taskBranch], {
8628
+ cwd: repoRoot,
8629
+ stdio: "ignore"
8630
+ });
8631
+ return $ok({ worktreeRemoved: removeResult.status === 0 });
8632
+ };
8633
+ var mergeInPlaceBranch = (repoRoot, options, strategy) => {
8634
+ const checkoutBase = spawnSync2("git", ["checkout", options.baseBranch], {
8635
+ cwd: repoRoot,
8636
+ encoding: "utf-8",
8637
+ stdio: ["pipe", "pipe", "pipe"]
8638
+ });
8639
+ if (checkoutBase.status !== 0) {
8640
+ return $err({
8641
+ kind: "COMMAND_ERROR",
8642
+ message: `Failed to checkout ${options.baseBranch}: ${checkoutBase.stderr.trim()}`
8643
+ });
8644
+ }
8645
+ const integrateRes = integrateBranch(repoRoot, options.taskBranch, options.baseBranch, strategy, options.commitMessage);
8646
+ if (integrateRes.isErr())
8647
+ return $err(integrateRes.error);
8648
+ return $ok({ worktreeRemoved: false });
8649
+ };
8650
+
8651
+ // src/vcs/git/status.ts
8652
+ import { spawnSync as spawnSync3 } from "node:child_process";
8472
8653
  var checkGitWorkingTreeClean = (context, options) => {
8473
8654
  const cwd = options?.cwd ?? process.cwd();
8474
8655
  if (!context.isAvailable || context.repoRoot == null) {
8475
8656
  return $ok(undefined);
8476
8657
  }
8477
8658
  try {
8478
- const statusRes = spawnSync2("git", ["status", "--porcelain=v1", "-uall"], {
8659
+ const statusRes = spawnSync3("git", ["status", "--porcelain=v1", "-uall"], {
8479
8660
  cwd,
8480
8661
  encoding: "utf-8",
8481
8662
  stdio: ["pipe", "pipe", "pipe"]
@@ -8543,7 +8724,7 @@ class GitVcsProvider {
8543
8724
  name = "git";
8544
8725
  getContext(cwd = process.cwd()) {
8545
8726
  try {
8546
- const isInsideWorktreeResult = spawnSync3("git", ["rev-parse", "--is-inside-work-tree"], {
8727
+ const isInsideWorktreeResult = spawnSync4("git", ["rev-parse", "--is-inside-work-tree"], {
8547
8728
  cwd,
8548
8729
  encoding: "utf-8",
8549
8730
  stdio: ["pipe", "pipe", "pipe"]
@@ -8552,19 +8733,19 @@ class GitVcsProvider {
8552
8733
  if (!isGitRepo) {
8553
8734
  return { isAvailable: false };
8554
8735
  }
8555
- const branchResult = spawnSync3("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
8736
+ const branchResult = spawnSync4("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
8556
8737
  cwd,
8557
8738
  encoding: "utf-8",
8558
8739
  stdio: ["pipe", "pipe", "pipe"]
8559
8740
  });
8560
8741
  const branchName = branchResult.status === 0 ? branchResult.stdout.trim() : undefined;
8561
- const rootResult = spawnSync3("git", ["rev-parse", "--show-toplevel"], {
8742
+ const rootResult = spawnSync4("git", ["rev-parse", "--show-toplevel"], {
8562
8743
  cwd,
8563
8744
  encoding: "utf-8",
8564
8745
  stdio: ["pipe", "pipe", "pipe"]
8565
8746
  });
8566
8747
  const repoRoot = rootResult.status === 0 ? rootResult.stdout.trim() : undefined;
8567
- const gitDirResult = spawnSync3("git", ["rev-parse", "--git-dir"], {
8748
+ const gitDirResult = spawnSync4("git", ["rev-parse", "--git-dir"], {
8568
8749
  cwd,
8569
8750
  encoding: "utf-8",
8570
8751
  stdio: ["pipe", "pipe", "pipe"]
@@ -8624,7 +8805,7 @@ class GitVcsProvider {
8624
8805
  const trimmedTarget = taskIdOrTarget?.trim().toLowerCase();
8625
8806
  const isTargetingMain = trimmedTarget == null || trimmedTarget === "" || trimmedTarget === "main" || trimmedTarget === "root";
8626
8807
  if (isTargetingMain) {
8627
- const commonDirResult = spawnSync3("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
8808
+ const commonDirResult = spawnSync4("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
8628
8809
  if (commonDirResult.status === 0 && commonDirResult.stdout.trim() !== "") {
8629
8810
  const commonDir = commonDirResult.stdout.trim();
8630
8811
  const mainRoot = path4.resolve(commonDir, "..");
@@ -8632,7 +8813,7 @@ class GitVcsProvider {
8632
8813
  }
8633
8814
  return $ok(ctx.repoRoot);
8634
8815
  }
8635
- const worktreeListResult = spawnSync3("git", ["worktree", "list", "--porcelain"], {
8816
+ const worktreeListResult = spawnSync4("git", ["worktree", "list", "--porcelain"], {
8636
8817
  cwd: ctx.repoRoot,
8637
8818
  encoding: "utf-8",
8638
8819
  stdio: ["pipe", "pipe", "pipe"]
@@ -8661,7 +8842,7 @@ class GitVcsProvider {
8661
8842
  message: "Git repository not detected"
8662
8843
  });
8663
8844
  }
8664
- const worktreeListResult = spawnSync3("git", ["worktree", "list", "--porcelain"], {
8845
+ const worktreeListResult = spawnSync4("git", ["worktree", "list", "--porcelain"], {
8665
8846
  cwd: ctx.repoRoot,
8666
8847
  encoding: "utf-8",
8667
8848
  stdio: ["pipe", "pipe", "pipe"]
@@ -8689,7 +8870,7 @@ class GitVcsProvider {
8689
8870
  });
8690
8871
  }
8691
8872
  const args = force ? ["worktree", "remove", "--force", targetPath] : ["worktree", "remove", targetPath];
8692
- const removeResult = spawnSync3("git", args, {
8873
+ const removeResult = spawnSync4("git", args, {
8693
8874
  cwd: ctx.repoRoot,
8694
8875
  encoding: "utf-8",
8695
8876
  stdio: ["pipe", "pipe", "pipe"]
@@ -8713,14 +8894,14 @@ class GitVcsProvider {
8713
8894
  if (ctx.currentBranch === branchName) {
8714
8895
  return $ok({ alreadyOnBranch: true });
8715
8896
  }
8716
- const branchCheck = spawnSync3("git", ["rev-parse", "--verify", `refs/heads/${branchName}`], {
8897
+ const branchCheck = spawnSync4("git", ["rev-parse", "--verify", `refs/heads/${branchName}`], {
8717
8898
  cwd: ctx.repoRoot,
8718
8899
  encoding: "utf-8",
8719
8900
  stdio: ["pipe", "pipe", "pipe"]
8720
8901
  });
8721
8902
  const branchExists = branchCheck.status === 0;
8722
8903
  const checkoutArgs = branchExists ? ["checkout", branchName] : ["checkout", "-b", branchName];
8723
- const checkoutResult = spawnSync3("git", checkoutArgs, {
8904
+ const checkoutResult = spawnSync4("git", checkoutArgs, {
8724
8905
  cwd: ctx.repoRoot,
8725
8906
  encoding: "utf-8",
8726
8907
  stdio: ["pipe", "pipe", "pipe"]
@@ -8741,21 +8922,21 @@ class GitVcsProvider {
8741
8922
  message: "Git repository not detected"
8742
8923
  });
8743
8924
  }
8744
- if (fs3.existsSync(targetPath)) {
8925
+ if (fs4.existsSync(targetPath)) {
8745
8926
  return $err({
8746
8927
  kind: "WORKTREE_ERROR",
8747
8928
  message: `Worktree path already exists: ${targetPath}`
8748
8929
  });
8749
8930
  }
8750
- fs3.mkdirSync(path4.dirname(targetPath), { recursive: true });
8751
- const branchCheck = spawnSync3("git", ["rev-parse", "--verify", `refs/heads/${branchName}`], {
8931
+ fs4.mkdirSync(path4.dirname(targetPath), { recursive: true });
8932
+ const branchCheck = spawnSync4("git", ["rev-parse", "--verify", `refs/heads/${branchName}`], {
8752
8933
  cwd: ctx.repoRoot,
8753
8934
  encoding: "utf-8",
8754
8935
  stdio: ["pipe", "pipe", "pipe"]
8755
8936
  });
8756
8937
  const branchExists = branchCheck.status === 0;
8757
8938
  const worktreeArgs = branchExists ? ["worktree", "add", targetPath, branchName] : ["worktree", "add", "-b", branchName, targetPath];
8758
- const worktreeResult = spawnSync3("git", worktreeArgs, {
8939
+ const worktreeResult = spawnSync4("git", worktreeArgs, {
8759
8940
  cwd: ctx.repoRoot,
8760
8941
  encoding: "utf-8",
8761
8942
  stdio: ["pipe", "pipe", "pipe"]
@@ -8789,64 +8970,23 @@ class GitVcsProvider {
8789
8970
  }
8790
8971
  const repoRoot = ctx.repoRoot;
8791
8972
  const commitMsg = options.commitMessage ?? `docs: complete task and move to done`;
8792
- const addResult = spawnSync3("git", ["add", "-A"], {
8973
+ const addResult = spawnSync4("git", ["add", "-A"], {
8793
8974
  cwd,
8794
8975
  encoding: "utf-8",
8795
8976
  stdio: ["pipe", "pipe", "pipe"]
8796
8977
  });
8797
8978
  if (addResult.status === 0) {
8798
- spawnSync3("git", ["commit", "-m", commitMsg], {
8979
+ spawnSync4("git", ["commit", "-m", commitMsg], {
8799
8980
  cwd,
8800
8981
  encoding: "utf-8",
8801
8982
  stdio: ["pipe", "pipe", "pipe"]
8802
8983
  });
8803
8984
  }
8985
+ const strategy = options.mergeStrategy ?? "merge";
8804
8986
  if (options.isWorktree) {
8805
- const mergeResult = spawnSync3("git", [
8806
- "merge",
8807
- "--no-ff",
8808
- "-m",
8809
- `Merge branch '${options.taskBranch}' into ${options.baseBranch}`,
8810
- options.taskBranch
8811
- ], { cwd: repoRoot, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
8812
- if (mergeResult.status !== 0) {
8813
- return $err({
8814
- kind: "MERGE_ERROR",
8815
- message: `Failed to merge ${options.taskBranch} into ${options.baseBranch}: ${mergeResult.stderr.trim()}`
8816
- });
8817
- }
8818
- const removeResult = spawnSync3("git", ["worktree", "remove", cwd], {
8819
- cwd: repoRoot,
8820
- encoding: "utf-8",
8821
- stdio: ["pipe", "pipe", "pipe"]
8822
- });
8823
- return $ok({ worktreeRemoved: removeResult.status === 0 });
8987
+ return mergeWorktreeAndCleanup(repoRoot, cwd, options, strategy);
8824
8988
  }
8825
- const checkoutBase = spawnSync3("git", ["checkout", options.baseBranch], {
8826
- cwd: repoRoot,
8827
- encoding: "utf-8",
8828
- stdio: ["pipe", "pipe", "pipe"]
8829
- });
8830
- if (checkoutBase.status !== 0) {
8831
- return $err({
8832
- kind: "COMMAND_ERROR",
8833
- message: `Failed to checkout ${options.baseBranch}: ${checkoutBase.stderr.trim()}`
8834
- });
8835
- }
8836
- const mergeResult = spawnSync3("git", [
8837
- "merge",
8838
- "--no-ff",
8839
- "-m",
8840
- `Merge branch '${options.taskBranch}' into ${options.baseBranch}`,
8841
- options.taskBranch
8842
- ], { cwd: repoRoot, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
8843
- if (mergeResult.status !== 0) {
8844
- return $err({
8845
- kind: "MERGE_ERROR",
8846
- message: `Failed to merge ${options.taskBranch} into ${options.baseBranch}: ${mergeResult.stderr.trim()}`
8847
- });
8848
- }
8849
- return $ok({ worktreeRemoved: false });
8989
+ return mergeInPlaceBranch(repoRoot, options, strategy);
8850
8990
  }
8851
8991
  }
8852
8992
  // src/vcs/noop.ts
@@ -8927,7 +9067,7 @@ var getVcsProvider = (cwd = process.cwd()) => {
8927
9067
  };
8928
9068
 
8929
9069
  // src/board/overlay.ts
8930
- import * as fs4 from "node:fs";
9070
+ import * as fs5 from "node:fs";
8931
9071
  import * as path6 from "node:path";
8932
9072
  var buildWorktreeTaskMap = (vcs, workspaceRoot) => {
8933
9073
  const vcsCtx = vcs.getContext(workspaceRoot);
@@ -8959,11 +9099,11 @@ var overlayWorktreeTask = (task, worktreeMap, tasksDir) => {
8959
9099
  return task;
8960
9100
  }
8961
9101
  const worktreeTaskFile = path6.join(worktreePath, tasksDir, task.column, task.filename);
8962
- if (!fs4.existsSync(worktreeTaskFile)) {
9102
+ if (!fs5.existsSync(worktreeTaskFile)) {
8963
9103
  return task;
8964
9104
  }
8965
9105
  try {
8966
- const content = fs4.readFileSync(worktreeTaskFile, "utf-8");
9106
+ const content = fs5.readFileSync(worktreeTaskFile, "utf-8");
8967
9107
  const parseRes = parseTaskDocument(content, task.filename);
8968
9108
  if (parseRes.isErr()) {
8969
9109
  return task;
@@ -9064,7 +9204,7 @@ var filterTasks = (tasks, filter) => {
9064
9204
  var discoverBoard = (config, workspaceRoot = process.cwd(), options) => {
9065
9205
  const rootDir = path7.isAbsolute(config.tasksDir) ? config.tasksDir : path7.join(workspaceRoot, config.tasksDir);
9066
9206
  try {
9067
- const dirInfo = fs5.statSync(rootDir);
9207
+ const dirInfo = fs6.statSync(rootDir);
9068
9208
  if (!dirInfo.isDirectory()) {
9069
9209
  return $err({
9070
9210
  kind: "DIRECTORY_NOT_FOUND",
@@ -9088,7 +9228,7 @@ var discoverBoard = (config, workspaceRoot = process.cwd(), options) => {
9088
9228
  }
9089
9229
  const discoveredDirNames = [];
9090
9230
  try {
9091
- for (const entry of fs5.readdirSync(rootDir, { withFileTypes: true })) {
9231
+ for (const entry of fs6.readdirSync(rootDir, { withFileTypes: true })) {
9092
9232
  if (entry.isDirectory() && !entry.name.startsWith(".")) {
9093
9233
  discoveredDirNames.push(entry.name);
9094
9234
  }
@@ -9123,10 +9263,10 @@ var discoverBoard = (config, workspaceRoot = process.cwd(), options) => {
9123
9263
  const colPath = path7.join(rootDir, colName);
9124
9264
  const taskList = [];
9125
9265
  try {
9126
- for (const entry of fs5.readdirSync(colPath, { withFileTypes: true })) {
9266
+ for (const entry of fs6.readdirSync(colPath, { withFileTypes: true })) {
9127
9267
  if (entry.isFile() && entry.name.endsWith(".md")) {
9128
9268
  const filePath = path7.join(colPath, entry.name);
9129
- const content = fs5.readFileSync(filePath, "utf-8");
9269
+ const content = fs6.readFileSync(filePath, "utf-8");
9130
9270
  const parseResult = parseTaskDocument(content, entry.name);
9131
9271
  if (parseResult.isOk()) {
9132
9272
  let doc = parseResult.value;
@@ -9239,10 +9379,10 @@ var findTaskByIdOrName = (board, idOrPath) => {
9239
9379
  };
9240
9380
 
9241
9381
  // src/tasks/mutation/check.ts
9242
- import * as fs7 from "node:fs";
9382
+ import * as fs8 from "node:fs";
9243
9383
 
9244
9384
  // src/tasks/mutation/move.ts
9245
- import * as fs6 from "node:fs";
9385
+ import * as fs7 from "node:fs";
9246
9386
  import * as path8 from "node:path";
9247
9387
  var getIsoDate = () => {
9248
9388
  if (typeof Temporal !== "undefined" && Temporal?.Now != null) {
@@ -9272,7 +9412,7 @@ var moveTask = (board, taskIdOrPath, targetColumnName) => {
9272
9412
  }
9273
9413
  const newFilePath = path8.join(targetCol.path, task.filename);
9274
9414
  try {
9275
- fs6.renameSync(task.filePath, newFilePath);
9415
+ fs7.renameSync(task.filePath, newFilePath);
9276
9416
  const updatedDoc = Object.freeze({
9277
9417
  ...task.document,
9278
9418
  frontmatter: Object.freeze({
@@ -9330,7 +9470,7 @@ var checkTaskItem = (board, taskIdOrPath, targetIndex, forcedState) => {
9330
9470
  });
9331
9471
  let fileContent;
9332
9472
  try {
9333
- fileContent = fs7.readFileSync(task.filePath, "utf-8");
9473
+ fileContent = fs8.readFileSync(task.filePath, "utf-8");
9334
9474
  } catch (readErr) {
9335
9475
  return $err({
9336
9476
  kind: "FS_ERROR",
@@ -9360,7 +9500,7 @@ var checkTaskItem = (board, taskIdOrPath, targetIndex, forcedState) => {
9360
9500
  rawBody: updatedLines.join(eol)
9361
9501
  });
9362
9502
  try {
9363
- fs7.writeFileSync(task.filePath, updatedLines.join(eol), "utf-8");
9503
+ fs8.writeFileSync(task.filePath, updatedLines.join(eol), "utf-8");
9364
9504
  return $ok(Object.freeze({
9365
9505
  ...task,
9366
9506
  document: updatedDoc
@@ -9729,7 +9869,7 @@ var viewCommand = {
9729
9869
 
9730
9870
  // src/tasks/lifecycle/current.cli.ts
9731
9871
  var import_picocolors4 = __toESM(require_picocolors2(), 1);
9732
- import * as fs8 from "node:fs";
9872
+ import * as fs9 from "node:fs";
9733
9873
  import * as process5 from "node:process";
9734
9874
 
9735
9875
  // src/tasks/lifecycle/current.ts
@@ -9820,7 +9960,7 @@ var handleCurrent = (ctx) => {
9820
9960
  const { task, multipleInDoing, doingCount } = currentRes.value;
9821
9961
  if (ctx.flags.raw) {
9822
9962
  try {
9823
- const rawContent = fs8.readFileSync(task.filePath, "utf-8");
9963
+ const rawContent = fs9.readFileSync(task.filePath, "utf-8");
9824
9964
  process5.stdout.write(rawContent);
9825
9965
  return 0;
9826
9966
  } catch (readErr) {
@@ -9993,7 +10133,8 @@ class GitBranchStrategy {
9993
10133
  baseBranch,
9994
10134
  isWorktree: false,
9995
10135
  cwd: ctx.cwd,
9996
- commitMessage
10136
+ commitMessage,
10137
+ mergeStrategy: options?.mergeStrategy ?? ctx.config.mergeStrategy
9997
10138
  });
9998
10139
  if (mergeResult.isErr()) {
9999
10140
  return $err({
@@ -10056,6 +10197,18 @@ class GitWorktreeStrategy {
10056
10197
  gitSkipped: false
10057
10198
  });
10058
10199
  }
10200
+ validateDone(task, ctx, options) {
10201
+ const willMerge = options?.noMerge !== undefined ? !options.noMerge : ctx.config.autoMerge !== false;
10202
+ if (ctx.vcsCtx.isWorktree && willMerge) {
10203
+ const displayId = task.document.id ?? task.filename;
10204
+ const mainRepo = ctx.vcsCtx.repoRoot ?? "the main repository";
10205
+ return $err({
10206
+ kind: "GIT_ERROR",
10207
+ message: `Cannot run 'dirban done' with auto-merge from inside a linked worktree. Run 'dirban done ${displayId}' from ${mainRepo} instead, or pass --no-merge.`
10208
+ });
10209
+ }
10210
+ return $ok(undefined);
10211
+ }
10059
10212
  onDone(task, ctx, options) {
10060
10213
  const effectiveId = getEffectiveTaskId(task);
10061
10214
  const detectedId = ctx.vcs.extractTaskId(ctx.vcsCtx.currentBranch, ctx.cwd);
@@ -10090,7 +10243,8 @@ class GitWorktreeStrategy {
10090
10243
  baseBranch,
10091
10244
  isWorktree: ctx.vcsCtx.isWorktree ?? false,
10092
10245
  cwd: ctx.cwd,
10093
- commitMessage
10246
+ commitMessage,
10247
+ mergeStrategy: options?.mergeStrategy ?? ctx.config.mergeStrategy
10094
10248
  });
10095
10249
  if (mergeResult.isErr()) {
10096
10250
  return $err({
@@ -10165,12 +10319,12 @@ var detectWorkspaceDoneStrategy = (task, options, vcsCtx, vcs, config, cwd) => {
10165
10319
  return new GitBranchStrategy;
10166
10320
  };
10167
10321
  // src/tasks/mutation/archive.ts
10168
- import * as fs9 from "node:fs";
10322
+ import * as fs10 from "node:fs";
10169
10323
  import * as path9 from "node:path";
10170
10324
  var archiveTasks = (board, config, taskIdOrAll, workspaceRoot = process.cwd()) => {
10171
10325
  const archiveBaseDir = path9.isAbsolute(config.archiveDir) ? config.archiveDir : path9.join(workspaceRoot, config.archiveDir);
10172
10326
  try {
10173
- fs9.mkdirSync(archiveBaseDir, { recursive: true });
10327
+ fs10.mkdirSync(archiveBaseDir, { recursive: true });
10174
10328
  } catch (mkdirErr) {
10175
10329
  return $err({
10176
10330
  kind: "FS_ERROR",
@@ -10199,7 +10353,7 @@ var archiveTasks = (board, config, taskIdOrAll, workspaceRoot = process.cwd()) =
10199
10353
  for (const task of tasksToArchive) {
10200
10354
  const destPath = path9.join(archiveBaseDir, task.filename);
10201
10355
  try {
10202
- fs9.renameSync(task.filePath, destPath);
10356
+ fs10.renameSync(task.filePath, destPath);
10203
10357
  archived.push({
10204
10358
  ...task,
10205
10359
  filePath: destPath,
@@ -10222,100 +10376,97 @@ var archiveTasks = (board, config, taskIdOrAll, workspaceRoot = process.cwd()) =
10222
10376
  var countUncheckedCriteria = (task) => {
10223
10377
  return task.document.acceptanceCriteria.filter((item) => !item.checked).length;
10224
10378
  };
10225
- var doneTask = (board, config, taskId, options) => {
10226
- const cwd = options?.cwd ?? process.cwd();
10227
- const vcs = options?.vcsProvider ?? getVcsProvider(cwd);
10228
- const focusColName = resolveFocusColumn(config);
10229
- let taskToDone;
10230
- if (taskId != null && taskId.trim() !== "") {
10231
- const trimmedId = taskId.trim();
10232
- const found = findTaskByIdOrName(board, trimmedId) ?? findTaskExact(board, trimmedId);
10233
- if (found == null) {
10234
- return $err({
10235
- kind: "TASK_NOT_FOUND",
10236
- id: trimmedId,
10237
- message: `Task not found: ${trimmedId}`
10238
- });
10239
- }
10240
- taskToDone = found;
10241
- if (focusColName != null && taskToDone.column !== focusColName) {
10242
- const displayId = taskToDone.document.id ?? taskToDone.filename;
10243
- const isCompleted = taskToDone.column === ARCHIVE_COLUMN2 || taskToDone.column === "archive" || taskToDone.column === DEFAULT_COLUMNS2[DEFAULT_COLUMNS2.length - 1];
10244
- if (isCompleted) {
10245
- return $err({
10246
- kind: "ALREADY_COMPLETED",
10247
- message: `Task ${displayId} is already completed in '${taskToDone.column}'.`
10248
- });
10249
- }
10250
- if (taskToDone.column === BACKLOG_COLUMN2 || taskToDone.column === "backlog") {
10251
- return $err({
10252
- kind: "INVALID_COLUMN_TRANSITION",
10253
- message: `Cannot mark task ${displayId} as done: task is in '${taskToDone.column}'. Run 'dirban ready ${displayId}' first.`,
10254
- currentColumn: taskToDone.column,
10255
- expectedColumn: focusColName,
10256
- id: trimmedId,
10257
- suggestion: `dirban ready ${displayId}`
10258
- });
10259
- }
10260
- const preFocusCol = resolvePreviousColumn(config, focusColName) ?? DEFAULT_COLUMNS2[0];
10261
- if (taskToDone.column === preFocusCol) {
10262
- return $err({
10263
- kind: "INVALID_COLUMN_TRANSITION",
10264
- message: `Cannot mark task ${displayId} as done: task is in '${taskToDone.column}'. Run 'dirban start ${displayId}' first.`,
10265
- currentColumn: taskToDone.column,
10266
- expectedColumn: focusColName,
10267
- id: trimmedId,
10268
- suggestion: `dirban start ${displayId}`
10269
- });
10270
- }
10271
- return $err({
10272
- kind: "INVALID_COLUMN_TRANSITION",
10273
- message: `Cannot mark task ${displayId} as done: task is in '${taskToDone.column}' (expected '${focusColName}').`,
10274
- currentColumn: taskToDone.column,
10275
- expectedColumn: focusColName,
10276
- id: trimmedId
10277
- });
10278
- }
10279
- } else {
10379
+ var resolveDoneTarget = (board, config, taskId, focusColName, cwd, vcs) => {
10380
+ if (taskId == null || taskId.trim() === "") {
10280
10381
  const currentResult = resolveCurrentTask(board, config, undefined, cwd, vcs);
10281
10382
  if (currentResult.isErr()) {
10282
- return $err({
10283
- kind: "NO_ACTIVE_TASK",
10284
- message: currentResult.error.message
10285
- });
10383
+ return $err({ kind: "NO_ACTIVE_TASK", message: currentResult.error.message });
10286
10384
  }
10287
- taskToDone = currentResult.value.task;
10385
+ return $ok(currentResult.value.task);
10288
10386
  }
10289
- const uncheckedCount = countUncheckedCriteria(taskToDone);
10290
- let updatedTask = taskToDone;
10387
+ const trimmedId = taskId.trim();
10388
+ const found = findTaskByIdOrName(board, trimmedId) ?? findTaskExact(board, trimmedId);
10389
+ if (found == null) {
10390
+ return $err({ kind: "TASK_NOT_FOUND", id: trimmedId, message: `Task not found: ${trimmedId}` });
10391
+ }
10392
+ if (focusColName == null || found.column === focusColName) {
10393
+ return $ok(found);
10394
+ }
10395
+ const displayId = found.document.id ?? found.filename;
10396
+ const isCompleted = found.column === ARCHIVE_COLUMN2 || found.column === "archive" || found.column === DEFAULT_COLUMNS2[DEFAULT_COLUMNS2.length - 1];
10397
+ if (isCompleted) {
10398
+ return $err({
10399
+ kind: "ALREADY_COMPLETED",
10400
+ message: `Task ${displayId} is already completed in '${found.column}'.`
10401
+ });
10402
+ }
10403
+ if (found.column === BACKLOG_COLUMN2 || found.column === "backlog") {
10404
+ return $err({
10405
+ kind: "INVALID_COLUMN_TRANSITION",
10406
+ message: `Cannot mark task ${displayId} as done: task is in '${found.column}'. Run 'dirban ready ${displayId}' first.`,
10407
+ currentColumn: found.column,
10408
+ expectedColumn: focusColName,
10409
+ id: trimmedId,
10410
+ suggestion: `dirban ready ${displayId}`
10411
+ });
10412
+ }
10413
+ const preFocusCol = resolvePreviousColumn(config, focusColName) ?? DEFAULT_COLUMNS2[0];
10414
+ if (found.column === preFocusCol) {
10415
+ return $err({
10416
+ kind: "INVALID_COLUMN_TRANSITION",
10417
+ message: `Cannot mark task ${displayId} as done: task is in '${found.column}'. Run 'dirban start ${displayId}' first.`,
10418
+ currentColumn: found.column,
10419
+ expectedColumn: focusColName,
10420
+ id: trimmedId,
10421
+ suggestion: `dirban start ${displayId}`
10422
+ });
10423
+ }
10424
+ return $err({
10425
+ kind: "INVALID_COLUMN_TRANSITION",
10426
+ message: `Cannot mark task ${displayId} as done: task is in '${found.column}' (expected '${focusColName}').`,
10427
+ currentColumn: found.column,
10428
+ expectedColumn: focusColName,
10429
+ id: trimmedId
10430
+ });
10431
+ };
10432
+ var transitionCompletedTaskFile = (board, config, taskToDone, focusColName, cwd) => {
10291
10433
  if (focusColName == null) {
10292
10434
  const archiveResult = archiveTasks(board, config, taskToDone.document.id ?? taskToDone.filename, cwd);
10293
10435
  if (archiveResult.isErr()) {
10294
- return $err({
10295
- kind: "MOVE_ERROR",
10296
- message: archiveResult.error.message
10297
- });
10298
- }
10299
- const archivedTask = archiveResult.value.archivedTasks[0];
10300
- if (archivedTask != null) {
10301
- updatedTask = archivedTask;
10302
- }
10303
- } else {
10304
- const targetColName = resolveNextColumn(config, focusColName);
10305
- if (taskToDone.column !== targetColName) {
10306
- const moveResult = moveTask(board, taskToDone.document.id ?? taskToDone.filename, targetColName);
10307
- if (moveResult.isErr()) {
10308
- return $err({
10309
- kind: "MOVE_ERROR",
10310
- message: moveResult.error.message
10311
- });
10312
- }
10313
- updatedTask = moveResult.value;
10436
+ return $err({ kind: "MOVE_ERROR", message: archiveResult.error.message });
10314
10437
  }
10438
+ return $ok(archiveResult.value.archivedTasks[0] ?? taskToDone);
10315
10439
  }
10440
+ const targetColName = resolveNextColumn(config, focusColName);
10441
+ if (taskToDone.column === targetColName) {
10442
+ return $ok(taskToDone);
10443
+ }
10444
+ const moveResult = moveTask(board, taskToDone.document.id ?? taskToDone.filename, targetColName);
10445
+ if (moveResult.isErr()) {
10446
+ return $err({ kind: "MOVE_ERROR", message: moveResult.error.message });
10447
+ }
10448
+ return $ok(moveResult.value);
10449
+ };
10450
+ var doneTask = (board, config, taskId, options) => {
10451
+ const cwd = options?.cwd ?? process.cwd();
10452
+ const vcs = options?.vcsProvider ?? getVcsProvider(cwd);
10453
+ const focusColName = resolveFocusColumn(config);
10454
+ const targetRes = resolveDoneTarget(board, config, taskId, focusColName, cwd, vcs);
10455
+ if (targetRes.isErr())
10456
+ return $err(targetRes.error);
10457
+ const taskToDone = targetRes.value;
10458
+ const uncheckedCount = countUncheckedCriteria(taskToDone);
10316
10459
  const vcsCtx = vcs.getContext(cwd);
10317
- const strategy = options?.workspaceStrategy ?? detectWorkspaceDoneStrategy(updatedTask, options, vcsCtx, vcs, config, cwd);
10460
+ const strategy = options?.workspaceStrategy ?? detectWorkspaceDoneStrategy(taskToDone, options, vcsCtx, vcs, config, cwd);
10318
10461
  const workspaceCtx = { vcs, vcsCtx, config, cwd };
10462
+ const validateRes = strategy.validateDone?.(taskToDone, workspaceCtx, options);
10463
+ if (validateRes?.isErr()) {
10464
+ return $err({ kind: "GIT_ERROR", message: validateRes.error.message });
10465
+ }
10466
+ const transitionRes = transitionCompletedTaskFile(board, config, taskToDone, focusColName, cwd);
10467
+ if (transitionRes.isErr())
10468
+ return $err(transitionRes.error);
10469
+ const updatedTask = transitionRes.value;
10319
10470
  const doneResult = strategy.onDone(updatedTask, workspaceCtx, options);
10320
10471
  if (doneResult.isErr()) {
10321
10472
  return $err(doneResult.error);
@@ -10337,17 +10488,29 @@ var parseDone = (ctx) => {
10337
10488
  if (ctx.flags.merge && ctx.flags["no-merge"]) {
10338
10489
  return $err({ message: "Cannot specify both --merge and --no-merge." });
10339
10490
  }
10491
+ if (ctx.flags.squash && ctx.flags.rebase) {
10492
+ return $err({ message: "Cannot specify both --squash and --rebase." });
10493
+ }
10340
10494
  const taskId = ctx.positionals[1];
10341
10495
  const strategyParam = ctx.flags.strategy;
10342
10496
  const isNoneStrategy = strategyParam === "none" || ctx.flags.current || ctx.flags["no-branch"];
10343
10497
  const strategy = isNoneStrategy ? "none" : strategyParam === "worktree" || strategyParam === "checkout" || strategyParam === "directory-only" ? strategyParam : ctx.flags.worktree ? "worktree" : ctx.flags.checkout ? "checkout" : undefined;
10344
10498
  const noGit = ctx.flags["no-git"];
10345
10499
  const noMerge = ctx.flags.merge === true ? false : ctx.flags["no-merge"];
10500
+ let mergeStrategy;
10501
+ if (ctx.flags.squash === true) {
10502
+ mergeStrategy = "squash";
10503
+ } else if (ctx.flags.rebase === true) {
10504
+ mergeStrategy = "rebase";
10505
+ } else if (ctx.flags.merge === true) {
10506
+ mergeStrategy = "merge";
10507
+ }
10346
10508
  return $ok({
10347
10509
  taskId,
10348
10510
  strategy,
10349
10511
  noGit,
10350
- noMerge
10512
+ noMerge,
10513
+ mergeStrategy
10351
10514
  });
10352
10515
  };
10353
10516
  var printDoneError = (err) => {
@@ -10382,7 +10545,8 @@ var handleDone = (ctx) => {
10382
10545
  cwd: ctx.cwd,
10383
10546
  strategy: params.strategy,
10384
10547
  noGit: params.noGit,
10385
- noMerge: params.noMerge
10548
+ noMerge: params.noMerge,
10549
+ mergeStrategy: params.mergeStrategy
10386
10550
  });
10387
10551
  if (doneRes.isErr()) {
10388
10552
  printDoneError(doneRes.error);
@@ -10419,6 +10583,14 @@ var doneCommand = {
10419
10583
  flag: "--merge",
10420
10584
  description: "Force merge into base branch even if autoMerge is disabled in config"
10421
10585
  },
10586
+ {
10587
+ flag: "--squash",
10588
+ description: "Squash task branch commits into a single commit on base branch"
10589
+ },
10590
+ {
10591
+ flag: "--rebase",
10592
+ description: "Rebase task branch onto base branch and fast-forward"
10593
+ },
10422
10594
  {
10423
10595
  flag: "--no-merge",
10424
10596
  description: "Preserve active branch/worktree without merging into base branch"
@@ -10782,11 +10954,11 @@ var readyCommand = {
10782
10954
  var import_picocolors9 = __toESM(require_picocolors2(), 1);
10783
10955
 
10784
10956
  // src/tasks/lifecycle/resume.ts
10785
- import * as fs11 from "node:fs";
10957
+ import * as fs12 from "node:fs";
10786
10958
  import * as path11 from "node:path";
10787
10959
 
10788
10960
  // src/tasks/planning/block.ts
10789
- import * as fs10 from "node:fs";
10961
+ import * as fs11 from "node:fs";
10790
10962
  import * as path10 from "node:path";
10791
10963
  var FRONTMATTER_DELIMITER2 = "---";
10792
10964
  var COMMA_SPLIT_REGEX = /\s*,\s*/;
@@ -10828,7 +11000,7 @@ var parseBlockerReasons = (rawReasons, board) => {
10828
11000
  var writeTaskRelationships = (task, updatedRelationships) => {
10829
11001
  let rawContent;
10830
11002
  try {
10831
- rawContent = fs10.readFileSync(task.filePath, "utf-8");
11003
+ rawContent = fs11.readFileSync(task.filePath, "utf-8");
10832
11004
  } catch (readErr) {
10833
11005
  return $err({
10834
11006
  kind: "FS_ERROR",
@@ -10881,7 +11053,7 @@ ${yamlStr}
10881
11053
  ---${eol}${eol}${rawContent.trim()}${eol}`;
10882
11054
  }
10883
11055
  try {
10884
- fs10.writeFileSync(task.filePath, updatedContent, "utf-8");
11056
+ fs11.writeFileSync(task.filePath, updatedContent, "utf-8");
10885
11057
  } catch (fsErr) {
10886
11058
  return $err({
10887
11059
  kind: "FS_ERROR",
@@ -10932,10 +11104,10 @@ var validateWorktreeClean = (vcs, vcsCtx, worktreePath, effectiveId, cwd, option
10932
11104
  var syncBlockedTaskToRoot = (taskFile, rootOldPath, repoRoot, tasksDir, taskFilename, effectiveId, blockers, vcs) => {
10933
11105
  const rootTarget = path10.join(repoRoot, tasksDir, BACKLOG_COLUMN2, taskFilename);
10934
11106
  try {
10935
- fs10.mkdirSync(path10.dirname(rootTarget), { recursive: true });
10936
- fs10.copyFileSync(taskFile, rootTarget);
10937
- if (rootOldPath !== rootTarget && fs10.existsSync(rootOldPath)) {
10938
- fs10.unlinkSync(rootOldPath);
11107
+ fs11.mkdirSync(path10.dirname(rootTarget), { recursive: true });
11108
+ fs11.copyFileSync(taskFile, rootTarget);
11109
+ if (rootOldPath !== rootTarget && fs11.existsSync(rootOldPath)) {
11110
+ fs11.unlinkSync(rootOldPath);
10939
11111
  }
10940
11112
  const commitMsg = `chore(task): block ${effectiveId} (${blockers.join(", ")})`;
10941
11113
  const filesToCommit = rootOldPath !== rootTarget ? [rootOldPath, rootTarget] : [rootTarget];
@@ -10986,7 +11158,7 @@ var blockTask = (board, taskIdOrPath, reasons, options) => {
10986
11158
  if (worktreePath != null) {
10987
11159
  const relTaskPath = path10.relative(vcsCtx.repoRoot ?? cwd, task.filePath);
10988
11160
  const worktreeTaskFile = path10.join(worktreePath, relTaskPath);
10989
- if (fs10.existsSync(worktreeTaskFile)) {
11161
+ if (fs11.existsSync(worktreeTaskFile)) {
10990
11162
  primaryTask = { ...task, filePath: worktreeTaskFile };
10991
11163
  }
10992
11164
  }
@@ -11002,8 +11174,8 @@ var blockTask = (board, taskIdOrPath, reasons, options) => {
11002
11174
  const targetPath = path10.join(parentDir, backlogColName, finalTask.filename);
11003
11175
  if (targetPath !== finalTask.filePath) {
11004
11176
  try {
11005
- fs10.mkdirSync(path10.dirname(targetPath), { recursive: true });
11006
- fs10.renameSync(finalTask.filePath, targetPath);
11177
+ fs11.mkdirSync(path10.dirname(targetPath), { recursive: true });
11178
+ fs11.renameSync(finalTask.filePath, targetPath);
11007
11179
  demoted = true;
11008
11180
  finalTask = {
11009
11181
  ...finalTask,
@@ -11140,11 +11312,11 @@ var syncResumedFileToWorktree = (activeWorktreePath, tasksDir, focusColName, fil
11140
11312
  const worktreeTarget = path11.join(activeWorktreePath, tasksDir, focusColName, filename);
11141
11313
  const worktreeOld = path11.join(activeWorktreePath, tasksDir, "backlog", filename);
11142
11314
  try {
11143
- fs11.mkdirSync(path11.dirname(worktreeTarget), { recursive: true });
11144
- if (fs11.existsSync(worktreeOld) && worktreeOld !== worktreeTarget) {
11145
- fs11.unlinkSync(worktreeOld);
11315
+ fs12.mkdirSync(path11.dirname(worktreeTarget), { recursive: true });
11316
+ if (fs12.existsSync(worktreeOld) && worktreeOld !== worktreeTarget) {
11317
+ fs12.unlinkSync(worktreeOld);
11146
11318
  }
11147
- fs11.copyFileSync(sourceFilePath, worktreeTarget);
11319
+ fs12.copyFileSync(sourceFilePath, worktreeTarget);
11148
11320
  } catch {}
11149
11321
  };
11150
11322
  var resumeTask = (board, config, taskId, options) => {
@@ -11198,13 +11370,13 @@ var resumeTask = (board, config, taskId, options) => {
11198
11370
  const { worktreePath: activeWorktreePath, branchName } = resolveWorktreeOrBranch(strategy.name, effectiveId, vcs, vcsCtx, config, cwd);
11199
11371
  const tasksDir = config.tasksDir ?? "docs/tasks";
11200
11372
  const repoRoot = vcsCtx.repoRoot;
11201
- const tasksRoot = repoRoot != null && fs11.existsSync(repoRoot) ? path11.join(repoRoot, tasksDir) : path11.dirname(path11.dirname(workingTask.filePath));
11373
+ const tasksRoot = repoRoot != null && fs12.existsSync(repoRoot) ? path11.join(repoRoot, tasksDir) : path11.dirname(path11.dirname(workingTask.filePath));
11202
11374
  const targetColDir = path11.join(tasksRoot, focusColName);
11203
11375
  const targetFilePath = path11.join(targetColDir, workingTask.filename);
11204
11376
  try {
11205
- fs11.mkdirSync(targetColDir, { recursive: true });
11206
- if (workingTask.filePath !== targetFilePath && fs11.existsSync(workingTask.filePath)) {
11207
- fs11.renameSync(workingTask.filePath, targetFilePath);
11377
+ fs12.mkdirSync(targetColDir, { recursive: true });
11378
+ if (workingTask.filePath !== targetFilePath && fs12.existsSync(workingTask.filePath)) {
11379
+ fs12.renameSync(workingTask.filePath, targetFilePath);
11208
11380
  }
11209
11381
  } catch (fsErr) {
11210
11382
  return $err({
@@ -11769,7 +11941,7 @@ var checkCommand = {
11769
11941
  var import_picocolors14 = __toESM(require_picocolors2(), 1);
11770
11942
 
11771
11943
  // src/tasks/mutation/create.ts
11772
- import * as fs12 from "node:fs";
11944
+ import * as fs13 from "node:fs";
11773
11945
  import * as path12 from "node:path";
11774
11946
  var SLUGIFY = (text) => {
11775
11947
  return text.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
@@ -11827,7 +11999,7 @@ var createTask = (board, options, referenceDate = new Date) => {
11827
11999
  const slug = SLUGIFY(trimmedTitle);
11828
12000
  const filename = slug !== "" ? `${nextId}-${slug}.md` : `${nextId}.md`;
11829
12001
  const filePath = path12.join(targetCol.path, filename);
11830
- if (fs12.existsSync(filePath)) {
12002
+ if (fs13.existsSync(filePath)) {
11831
12003
  return $err({
11832
12004
  kind: "FS_ERROR",
11833
12005
  message: `File already exists: ${filePath}`
@@ -11873,7 +12045,7 @@ var createTask = (board, options, referenceDate = new Date) => {
11873
12045
  ${bodyLines.join(`
11874
12046
  `)}`;
11875
12047
  try {
11876
- fs12.writeFileSync(filePath, fullContent, "utf-8");
12048
+ fs13.writeFileSync(filePath, fullContent, "utf-8");
11877
12049
  } catch (e) {
11878
12050
  return $err({
11879
12051
  kind: "FS_ERROR",
@@ -12026,7 +12198,7 @@ var nextIdCommand = {
12026
12198
  var import_picocolors17 = __toESM(require_picocolors2(), 1);
12027
12199
 
12028
12200
  // src/tasks/mutation/set.ts
12029
- import * as fs13 from "node:fs";
12201
+ import * as fs14 from "node:fs";
12030
12202
  var detectEol3 = (content) => content.includes(`\r
12031
12203
  `) ? `\r
12032
12204
  ` : `
@@ -12063,7 +12235,7 @@ var setTaskMetadata = (board, taskIdOrPath, options) => {
12063
12235
  });
12064
12236
  let rawContent;
12065
12237
  try {
12066
- rawContent = fs13.readFileSync(task.filePath, "utf-8");
12238
+ rawContent = fs14.readFileSync(task.filePath, "utf-8");
12067
12239
  } catch (readErr) {
12068
12240
  return $err({
12069
12241
  kind: "FS_ERROR",
@@ -12116,7 +12288,7 @@ ${yamlStr}
12116
12288
  frontmatter: updatedFm
12117
12289
  });
12118
12290
  try {
12119
- fs13.writeFileSync(task.filePath, updatedContent, "utf-8");
12291
+ fs14.writeFileSync(task.filePath, updatedContent, "utf-8");
12120
12292
  return $ok(Object.freeze({
12121
12293
  ...task,
12122
12294
  document: updatedDoc
@@ -12629,7 +12801,7 @@ var helpCommand = {
12629
12801
  var import_picocolors22 = __toESM(require_picocolors2(), 1);
12630
12802
 
12631
12803
  // src/tasks/project/init.ts
12632
- import * as fs14 from "node:fs";
12804
+ import * as fs15 from "node:fs";
12633
12805
  import * as path13 from "node:path";
12634
12806
  var initializeBoard = (config = DEFAULT_CONFIG2, workspaceRoot = process.cwd(), options = {}) => {
12635
12807
  const rootDir = path13.isAbsolute(config.tasksDir) ? config.tasksDir : path13.join(workspaceRoot, config.tasksDir);
@@ -12651,16 +12823,16 @@ var initializeBoard = (config = DEFAULT_CONFIG2, workspaceRoot = process.cwd(),
12651
12823
  ];
12652
12824
  for (const dirPath of directoriesToEnsure) {
12653
12825
  try {
12654
- if (fs14.existsSync(dirPath)) {
12826
+ if (fs15.existsSync(dirPath)) {
12655
12827
  alreadyExisted.push(dirPath);
12656
12828
  } else {
12657
- fs14.mkdirSync(dirPath, { recursive: true });
12829
+ fs15.mkdirSync(dirPath, { recursive: true });
12658
12830
  created.push(dirPath);
12659
12831
  }
12660
12832
  if (directoriesForGitkeep.includes(dirPath)) {
12661
12833
  const gitkeepPath = path13.join(dirPath, GITKEEP_FILE_NAME);
12662
- if (!fs14.existsSync(gitkeepPath)) {
12663
- fs14.writeFileSync(gitkeepPath, "", "utf-8");
12834
+ if (!fs15.existsSync(gitkeepPath)) {
12835
+ fs15.writeFileSync(gitkeepPath, "", "utf-8");
12664
12836
  }
12665
12837
  }
12666
12838
  } catch (e) {
@@ -12676,14 +12848,14 @@ var initializeBoard = (config = DEFAULT_CONFIG2, workspaceRoot = process.cwd(),
12676
12848
  let configFileCreated;
12677
12849
  let configFileUpdated;
12678
12850
  const target = options.configTarget ?? "auto";
12679
- const useVsCode = target === "vscode" || target === "auto" && fs14.existsSync(vscodeDir) && !fs14.existsSync(dirbanConfigPath);
12851
+ const useVsCode = target === "vscode" || target === "auto" && fs15.existsSync(vscodeDir) && !fs15.existsSync(dirbanConfigPath);
12680
12852
  try {
12681
12853
  if (useVsCode) {
12682
- fs14.mkdirSync(vscodeDir, { recursive: true });
12854
+ fs15.mkdirSync(vscodeDir, { recursive: true });
12683
12855
  let currentSettings = {};
12684
- if (fs14.existsSync(vscodeSettingsPath)) {
12856
+ if (fs15.existsSync(vscodeSettingsPath)) {
12685
12857
  try {
12686
- const content = fs14.readFileSync(vscodeSettingsPath, "utf-8");
12858
+ const content = fs15.readFileSync(vscodeSettingsPath, "utf-8");
12687
12859
  currentSettings = JSON.parse(content);
12688
12860
  } catch {
12689
12861
  currentSettings = {};
@@ -12703,23 +12875,23 @@ var initializeBoard = (config = DEFAULT_CONFIG2, workspaceRoot = process.cwd(),
12703
12875
  modified = true;
12704
12876
  }
12705
12877
  if (modified) {
12706
- fs14.writeFileSync(vscodeSettingsPath, `${JSON.stringify(currentSettings, null, 2)}
12878
+ fs15.writeFileSync(vscodeSettingsPath, `${JSON.stringify(currentSettings, null, 2)}
12707
12879
  `, "utf-8");
12708
- if (fs14.existsSync(vscodeSettingsPath)) {
12880
+ if (fs15.existsSync(vscodeSettingsPath)) {
12709
12881
  configFileUpdated = path13.relative(workspaceRoot, vscodeSettingsPath);
12710
12882
  } else {
12711
12883
  configFileCreated = path13.relative(workspaceRoot, vscodeSettingsPath);
12712
12884
  }
12713
12885
  }
12714
12886
  } else {
12715
- if (!fs14.existsSync(dirbanConfigPath)) {
12887
+ if (!fs15.existsSync(dirbanConfigPath)) {
12716
12888
  const configContent = {
12717
12889
  tasksDir: config.tasksDir,
12718
12890
  priorities: [...config.priorities],
12719
12891
  defaultPriority: config.defaultPriority,
12720
12892
  archiveDir: config.archiveDir
12721
12893
  };
12722
- fs14.writeFileSync(dirbanConfigPath, `${JSON.stringify(configContent, null, 2)}
12894
+ fs15.writeFileSync(dirbanConfigPath, `${JSON.stringify(configContent, null, 2)}
12723
12895
  `, "utf-8");
12724
12896
  configFileCreated = CONFIG_FILE_NAME2;
12725
12897
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirban",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Zero-Database, Agent-Native Kanban Engine & TUI Backed by the File System and Google Open Knowledge Format (OKF)",
5
5
  "type": "module",
6
6
  "main": "./dist/dirban.js",