shipbench 0.7.1 → 0.9.0

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 (3) hide show
  1. package/README.md +5 -5
  2. package/dist/index.js +721 -459
  3. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -3521,10 +3521,19 @@ var require_gray_matter = __commonJS({
3521
3521
  }
3522
3522
  });
3523
3523
 
3524
- // src/harborConnect.ts
3525
- import { execFile } from "child_process";
3526
- import { realpath } from "fs/promises";
3527
- import { resolve } from "path";
3524
+ // src/errors.ts
3525
+ var CliExitError = class extends Error {
3526
+ constructor(message2, exitCode) {
3527
+ super(message2);
3528
+ this.exitCode = exitCode;
3529
+ this.name = "CliExitError";
3530
+ }
3531
+ exitCode;
3532
+ };
3533
+
3534
+ // src/processCli.ts
3535
+ import { existsSync, statSync } from "fs";
3536
+ import { basename, dirname as dirname3, join as join4, resolve as resolve2 } from "path";
3528
3537
 
3529
3538
  // ../../packages/core/src/adapters/fs.ts
3530
3539
  import { mkdir, readdir, readFile, unlink, writeFile } from "fs/promises";
@@ -3632,11 +3641,13 @@ function dependencyStatus(slug, index) {
3632
3641
  function taskDependenciesAreSatisfied(task, index, doneColumn) {
3633
3642
  const dependencies = dependencySlugs(task);
3634
3643
  if (dependencies === null) return false;
3635
- return dependencies.every((dependency) => {
3636
- if (dependency === task.slug) return false;
3637
- const resolution = resolveTaskDependency(dependency, index);
3638
- return resolution.kind === "archived" || resolution.kind === "live" && resolution.status === doneColumn;
3639
- });
3644
+ return dependencies.every(
3645
+ (dependency) => dependency !== task.slug && dependencyIsSatisfied(dependency, index, doneColumn)
3646
+ );
3647
+ }
3648
+ function dependencyIsSatisfied(slug, index, doneColumn) {
3649
+ const resolution = resolveTaskDependency(slug, index);
3650
+ return resolution.kind === "archived" || resolution.kind === "live" && resolution.status === doneColumn;
3640
3651
  }
3641
3652
  function buildTaskDependencyGraph(liveTasks, options2 = {}) {
3642
3653
  const archivedTasks = options2.archivedTasks ?? [];
@@ -3679,6 +3690,124 @@ function buildTaskDependencyGraph(liveTasks, options2 = {}) {
3679
3690
  ])
3680
3691
  );
3681
3692
  }
3693
+ function queryTaskDependencies(slug, liveTasks, config, options2 = {}) {
3694
+ const archivedTasks = options2.archivedTasks ?? [];
3695
+ const index = createTaskDependencyIndex(
3696
+ liveTasks,
3697
+ archivedTasks,
3698
+ options2.archivedSlugs
3699
+ );
3700
+ const unreadable = new Set(options2.unreadableSlugs);
3701
+ const sourceTasks = new Map([
3702
+ ...archivedTasks.map((task) => [task.slug, task]),
3703
+ ...liveTasks.map((task) => [task.slug, task])
3704
+ ]);
3705
+ const root = sourceTasks.get(slug);
3706
+ if (!root) return null;
3707
+ const dependentsOf = /* @__PURE__ */ new Map();
3708
+ for (const task of sourceTasks.values()) {
3709
+ for (const dependency of dependencySlugs(task) ?? []) {
3710
+ const list = dependentsOf.get(dependency) ?? [];
3711
+ list.push(task.slug);
3712
+ dependentsOf.set(dependency, list);
3713
+ }
3714
+ }
3715
+ const neighbors = (direction2, of) => {
3716
+ const task = sourceTasks.get(of);
3717
+ const found = direction2 === "blockers" ? task ? dependencySlugs(task) ?? [] : [] : dependentsOf.get(of) ?? [];
3718
+ return [...new Set(found)].sort((a, b) => a.localeCompare(b));
3719
+ };
3720
+ const statusOf = (of) => {
3721
+ const resolution = resolveTaskDependency(of, index);
3722
+ if (resolution.kind === "missing" && unreadable.has(of)) {
3723
+ return "unreadable";
3724
+ }
3725
+ return resolution.status;
3726
+ };
3727
+ const satisfied = (of) => dependencyIsSatisfied(of, index, config.done_column);
3728
+ const rootSatisfied = satisfied(slug);
3729
+ const maxDepth = options2.depth ?? Number.POSITIVE_INFINITY;
3730
+ let truncated = false;
3731
+ const walk = (direction2) => {
3732
+ const shallowest = /* @__PURE__ */ new Map([[slug, 0]]);
3733
+ let frontier = [slug];
3734
+ for (let level = 1; frontier.length > 0 && level <= maxDepth; level++) {
3735
+ const next = [];
3736
+ for (const current of frontier) {
3737
+ for (const neighbor of neighbors(direction2, current)) {
3738
+ if (shallowest.has(neighbor)) continue;
3739
+ shallowest.set(neighbor, level);
3740
+ next.push(neighbor);
3741
+ }
3742
+ }
3743
+ frontier = next;
3744
+ }
3745
+ const expanded = /* @__PURE__ */ new Set();
3746
+ const build = (current, level, path, parent) => {
3747
+ const task = sourceTasks.get(current);
3748
+ const dependencies = task ? dependencySlugs(task) : [];
3749
+ const node = {
3750
+ slug: current,
3751
+ status: statusOf(current),
3752
+ ...task ? { title: task.frontmatter.title } : {}
3753
+ };
3754
+ let children = [];
3755
+ if (direction2 === "blockers") node.satisfied = satisfied(current);
3756
+ if (dependencies === null) node.invalid_depends_on = true;
3757
+ if (direction2 === "dependents" && level === 1) {
3758
+ const waiting = (dependencies ?? []).filter(
3759
+ (dependency) => (
3760
+ // A self-reference never resolves, even when it is the parent.
3761
+ dependency === current || dependency !== parent && !satisfied(dependency)
3762
+ )
3763
+ );
3764
+ node.unblocks_on_completion = index.liveTasksBySlug.has(current) && task?.frontmatter.status === config.default_column && dependencies !== null && !rootSatisfied && waiting.length === 0;
3765
+ node.waiting_on = waiting;
3766
+ }
3767
+ const next = neighbors(direction2, current);
3768
+ if (next.length === 0) return { ...node, children };
3769
+ if (path.has(current)) {
3770
+ node.omitted = "cycle";
3771
+ } else if (expanded.has(current) || shallowest.get(current) !== level) {
3772
+ node.omitted = "repeat";
3773
+ } else if (level >= maxDepth) {
3774
+ node.omitted = "depth";
3775
+ truncated = true;
3776
+ } else {
3777
+ expanded.add(current);
3778
+ const childPath = new Set(path).add(current);
3779
+ children = next.map(
3780
+ (child) => build(child, level + 1, childPath, current)
3781
+ );
3782
+ }
3783
+ return { ...node, children };
3784
+ };
3785
+ const rootPath = /* @__PURE__ */ new Set([slug]);
3786
+ return neighbors(direction2, slug).map(
3787
+ (child) => build(child, 1, rootPath, slug)
3788
+ );
3789
+ };
3790
+ const direction = options2.direction ?? "both";
3791
+ const dependenciesSatisfied = taskDependenciesAreSatisfied(
3792
+ root,
3793
+ index,
3794
+ config.done_column
3795
+ );
3796
+ const result = {
3797
+ slug,
3798
+ status: statusOf(slug),
3799
+ title: root.frontmatter.title,
3800
+ dependencies_satisfied: dependenciesSatisfied,
3801
+ available: index.liveTasksBySlug.has(slug) && root.frontmatter.status === config.default_column && dependenciesSatisfied,
3802
+ ...dependencySlugs(root) === null ? { invalid_depends_on: true } : {},
3803
+ depth: options2.depth ?? null,
3804
+ truncated: false
3805
+ };
3806
+ if (direction !== "dependents") result.blockers = walk("blockers");
3807
+ if (direction !== "blockers") result.dependents = walk("dependents");
3808
+ result.truncated = truncated;
3809
+ return result;
3810
+ }
3682
3811
 
3683
3812
  // ../../packages/core/src/availability.ts
3684
3813
  function compareTaskReadiness(a, b, config) {
@@ -3926,49 +4055,6 @@ function isTaskFlagged(task) {
3926
4055
  return taskFlag(task) !== null;
3927
4056
  }
3928
4057
 
3929
- // ../../packages/core/src/github-url.ts
3930
- var GITHUB_URL_RE = /^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9._-]*)\/([A-Za-z0-9][A-Za-z0-9._-]*?)(?:\.git)?\/?$/;
3931
- var GITHUB_SCP_REMOTE_RE = /^git@github\.com:([A-Za-z0-9][A-Za-z0-9._-]*)\/([A-Za-z0-9][A-Za-z0-9._-]*?)(?:\.git)?$/;
3932
- var GITHUB_SSH_PATH_RE = /^\/([A-Za-z0-9][A-Za-z0-9._-]*)\/([A-Za-z0-9][A-Za-z0-9._-]*?)(?:\.git)?\/?$/;
3933
- function validParts(owner, repo) {
3934
- return owner !== "." && owner !== ".." && repo !== "." && repo !== "..";
3935
- }
3936
- function parseGithubUrl(input) {
3937
- const match = GITHUB_URL_RE.exec(input.trim());
3938
- if (!match) return null;
3939
- const owner = match[1];
3940
- const repo = match[2];
3941
- return validParts(owner, repo) ? { owner, repo } : null;
3942
- }
3943
- function parseGithubRemoteUrl(input) {
3944
- const https = parseGithubUrl(input);
3945
- if (https) return https;
3946
- const trimmed = input.trim();
3947
- const scpMatch = GITHUB_SCP_REMOTE_RE.exec(trimmed);
3948
- if (scpMatch) {
3949
- const owner = scpMatch[1];
3950
- const repo = scpMatch[2];
3951
- return validParts(owner, repo) ? { owner, repo } : null;
3952
- }
3953
- try {
3954
- const url = new URL(trimmed);
3955
- if (url.protocol !== "ssh:" || url.hostname !== "github.com" || url.username !== "git" || url.password || url.port || url.search || url.hash) {
3956
- return null;
3957
- }
3958
- const pathMatch = GITHUB_SSH_PATH_RE.exec(url.pathname);
3959
- if (!pathMatch) return null;
3960
- const owner = pathMatch[1];
3961
- const repo = pathMatch[2];
3962
- return validParts(owner, repo) ? { owner, repo } : null;
3963
- } catch {
3964
- return null;
3965
- }
3966
- }
3967
- function normalizeGithubRemoteUrl(input) {
3968
- const parsed = parseGithubRemoteUrl(input);
3969
- return parsed ? `https://github.com/${parsed.owner}/${parsed.repo}` : null;
3970
- }
3971
-
3972
4058
  // ../../packages/core/src/tasks.ts
3973
4059
  var import_gray_matter = __toESM(require_gray_matter(), 1);
3974
4060
 
@@ -4033,6 +4119,55 @@ function orderedTasksForColumn(tasks, layout, columnId, validStatuses, doneColum
4033
4119
  return [...ordered, ...leftovers];
4034
4120
  }
4035
4121
 
4122
+ // ../../packages/core/src/related.ts
4123
+ function relatedSlugs(task) {
4124
+ const { related } = task.frontmatter;
4125
+ if (!Array.isArray(related)) return [];
4126
+ const slugs = related.filter((slug) => typeof slug === "string").map((slug) => slug.trim()).filter(Boolean);
4127
+ return [...new Set(slugs)];
4128
+ }
4129
+ function createRelatedIndex(input) {
4130
+ const archivedTasks = input.archivedTasks ?? [];
4131
+ const liveBySlug = new Map(input.tasks.map((task) => [task.slug, task]));
4132
+ const archivedBySlug = new Map(archivedTasks.map((task) => [task.slug, task]));
4133
+ const archivedSlugs = /* @__PURE__ */ new Set([
4134
+ ...input.archivedSlugs ?? [],
4135
+ ...archivedBySlug.keys()
4136
+ ]);
4137
+ const incoming = /* @__PURE__ */ new Map();
4138
+ for (const source of [...input.tasks, ...archivedTasks]) {
4139
+ for (const target of relatedSlugs(source)) {
4140
+ if (target === source.slug) continue;
4141
+ const sources = incoming.get(target) ?? [];
4142
+ if (!sources.includes(source.slug)) sources.push(source.slug);
4143
+ incoming.set(target, sources);
4144
+ }
4145
+ }
4146
+ const resolve3 = (slug, direction) => {
4147
+ const live = liveBySlug.get(slug);
4148
+ const archived = live ? void 0 : archivedBySlug.get(slug);
4149
+ const found = live ?? archived;
4150
+ return {
4151
+ slug,
4152
+ direction,
4153
+ title: found?.frontmatter.title ?? null,
4154
+ status: found?.frontmatter.status ?? null,
4155
+ archived: !live && archivedSlugs.has(slug)
4156
+ };
4157
+ };
4158
+ return (task) => {
4159
+ const outgoing = relatedSlugs(task).filter((slug) => slug !== task.slug);
4160
+ const fromOthers = incoming.get(task.slug) ?? [];
4161
+ const own = new Set(outgoing);
4162
+ return [
4163
+ ...outgoing.map(
4164
+ (slug) => resolve3(slug, fromOthers.includes(slug) ? "both" : "outgoing")
4165
+ ),
4166
+ ...fromOthers.filter((slug) => !own.has(slug)).map((slug) => resolve3(slug, "incoming"))
4167
+ ];
4168
+ };
4169
+ }
4170
+
4036
4171
  // ../../packages/core/src/slug.ts
4037
4172
  function slugify(title) {
4038
4173
  return title.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "").toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
@@ -4095,6 +4230,7 @@ var KNOWN_FRONTMATTER_FIELDS = /* @__PURE__ */ new Set([
4095
4230
  "assignee",
4096
4231
  "tags",
4097
4232
  "depends_on",
4233
+ "related",
4098
4234
  "flag",
4099
4235
  "created",
4100
4236
  "updated"
@@ -4357,6 +4493,28 @@ function normalizeFlag(value) {
4357
4493
  }
4358
4494
  return reason;
4359
4495
  }
4496
+ async function assertValidRelated(adapter, slug, related, existing = []) {
4497
+ if (!related || related.length === 0) return;
4498
+ if (related.includes(slug)) {
4499
+ throw new Error(`Task "${slug}" cannot be related to itself.`);
4500
+ }
4501
+ const added = related.filter((target) => !existing.includes(target));
4502
+ if (added.length === 0) return;
4503
+ const [liveFiles, archivedFiles] = await Promise.all([
4504
+ adapter.listFiles(TASKS_DIR),
4505
+ adapter.listFiles(ARCHIVE_DIR)
4506
+ ]);
4507
+ const known = new Set(
4508
+ [...liveFiles, ...archivedFiles].filter((file) => file.endsWith(".md")).map((file) => file.replace(/\.md$/, ""))
4509
+ );
4510
+ for (const target of added) {
4511
+ if (!known.has(target)) {
4512
+ throw new Error(
4513
+ `Unknown related task "${target}" \u2014 no live or archived task file matches that slug.`
4514
+ );
4515
+ }
4516
+ }
4517
+ }
4360
4518
  async function assertValidDependsOn(adapter, config, slug, dependsOn) {
4361
4519
  if (!dependsOn || dependsOn.length === 0) return;
4362
4520
  if (dependsOn.includes(slug)) {
@@ -4386,7 +4544,7 @@ function unreadableUpdatesWarning(task) {
4386
4544
  message: `Malformed Updates section: ${task.unreadableUpdates.reason} The section is preserved verbatim in the file and is not part of the description.`
4387
4545
  };
4388
4546
  }
4389
- function validateTask(task, config, knownSlugs) {
4547
+ function validateTask(task, config, knownSlugs, knownRelatedSlugs) {
4390
4548
  const warnings = [];
4391
4549
  const validStatuses = new Set(config.columns.map((c) => c.id));
4392
4550
  const updatesWarning = unreadableUpdatesWarning(task);
@@ -4425,6 +4583,23 @@ function validateTask(task, config, knownSlugs) {
4425
4583
  }
4426
4584
  }
4427
4585
  }
4586
+ const related = task.frontmatter.related;
4587
+ if (related !== void 0 && related !== null && (!Array.isArray(related) || related.some((entry) => typeof entry !== "string"))) {
4588
+ warnings.push({
4589
+ slug: task.slug,
4590
+ field: "related",
4591
+ message: "Expected related to be a list of task slugs."
4592
+ });
4593
+ }
4594
+ for (const target of relatedSlugs(task)) {
4595
+ if (!knownRelatedSlugs.has(target)) {
4596
+ warnings.push({
4597
+ slug: task.slug,
4598
+ field: "related",
4599
+ message: `Dangling related task "${target}" \u2014 no live or archived task file matches that slug.`
4600
+ });
4601
+ }
4602
+ }
4428
4603
  const flag = task.frontmatter.flag;
4429
4604
  if (flag !== void 0 && flag !== null && !taskFlag(task)) {
4430
4605
  warnings.push({
@@ -4444,7 +4619,7 @@ function validateTask(task, config, knownSlugs) {
4444
4619
  }
4445
4620
  return warnings;
4446
4621
  }
4447
- async function listTasksInDirectory(adapter, config, directory, additionalKnownSlugs = []) {
4622
+ async function listTasksInDirectory(adapter, config, directory, additionalKnownSlugs = [], otherDirectorySlugs = []) {
4448
4623
  const files = await adapter.listFiles(directory);
4449
4624
  const mdFiles = files.filter((f) => f.endsWith(".md"));
4450
4625
  if (mdFiles.length === 0) {
@@ -4469,12 +4644,17 @@ async function listTasksInDirectory(adapter, config, directory, additionalKnownS
4469
4644
  });
4470
4645
  }
4471
4646
  }
4647
+ const directorySlugs = mdFiles.map((file) => file.replace(/\.md$/, ""));
4472
4648
  const knownSlugs = /* @__PURE__ */ new Set([
4473
4649
  ...await additionalKnownSlugs,
4474
- ...mdFiles.map((file) => file.replace(/\.md$/, ""))
4650
+ ...directorySlugs
4651
+ ]);
4652
+ const knownRelatedSlugs = /* @__PURE__ */ new Set([
4653
+ ...await otherDirectorySlugs,
4654
+ ...directorySlugs
4475
4655
  ]);
4476
4656
  for (const task of tasks) {
4477
- warnings.push(...validateTask(task, config, knownSlugs));
4657
+ warnings.push(...validateTask(task, config, knownSlugs, knownRelatedSlugs));
4478
4658
  }
4479
4659
  return { tasks, warnings, unreadable };
4480
4660
  }
@@ -4486,7 +4666,17 @@ async function listTasks(adapter, config, options2 = {}) {
4486
4666
  ...tasks.map((task) => task.slug),
4487
4667
  ...fileSlugs
4488
4668
  ]);
4489
- return listTasksInDirectory(adapter, config, TASKS_DIR, archivedSlugs);
4669
+ const archiveFiles = adapter.listFiles(ARCHIVE_DIR).then(
4670
+ (files) => files.filter((file) => file.endsWith(".md")).map((file) => file.replace(/\.md$/, ""))
4671
+ );
4672
+ const result = await listTasksInDirectory(
4673
+ adapter,
4674
+ config,
4675
+ TASKS_DIR,
4676
+ archivedSlugs,
4677
+ archiveFiles
4678
+ );
4679
+ return { ...result, archivedSlugs: await archiveFiles };
4490
4680
  }
4491
4681
  async function getTask(adapter, config, slug, options2 = {}) {
4492
4682
  void config;
@@ -4498,7 +4688,13 @@ async function getTask(adapter, config, slug, options2 = {}) {
4498
4688
  async function listArchivedTasks(adapter, config) {
4499
4689
  const liveFiles = await adapter.listFiles(TASKS_DIR);
4500
4690
  const liveSlugs = liveFiles.filter((file) => file.endsWith(".md")).map((file) => file.replace(/\.md$/, ""));
4501
- return listTasksInDirectory(adapter, config, ARCHIVE_DIR, liveSlugs);
4691
+ return listTasksInDirectory(
4692
+ adapter,
4693
+ config,
4694
+ ARCHIVE_DIR,
4695
+ liveSlugs,
4696
+ liveSlugs
4697
+ );
4502
4698
  }
4503
4699
  function taskFileSlugs(result) {
4504
4700
  return [
@@ -4531,6 +4727,8 @@ async function createTask(adapter, config, title, fields, body) {
4531
4727
  assertValidPriority(priority, config);
4532
4728
  const dependsOn = normalizeDependsOn(fields?.depends_on);
4533
4729
  await assertValidDependsOn(adapter, config, slug, dependsOn);
4730
+ const related = normalizeDependsOn(fields?.related);
4731
+ await assertValidRelated(adapter, slug, related);
4534
4732
  const flag = normalizeFlag(fields?.flag);
4535
4733
  const task = {
4536
4734
  slug,
@@ -4541,6 +4739,7 @@ async function createTask(adapter, config, title, fields, body) {
4541
4739
  assignee: fields?.assignee,
4542
4740
  tags: fields?.tags,
4543
4741
  depends_on: dependsOn,
4742
+ related,
4544
4743
  flag,
4545
4744
  created: now,
4546
4745
  updated: now
@@ -4575,6 +4774,11 @@ async function updateTask(adapter, config, slug, fields, body) {
4575
4774
  if (dependsOnProvided) {
4576
4775
  await assertValidDependsOn(adapter, config, slug, dependsOn);
4577
4776
  }
4777
+ const relatedProvided = "related" in fields;
4778
+ const related = relatedProvided ? normalizeDependsOn(fields.related) : void 0;
4779
+ if (relatedProvided) {
4780
+ await assertValidRelated(adapter, slug, related, relatedSlugs(task));
4781
+ }
4578
4782
  const flagProvided = "flag" in fields;
4579
4783
  const flag = flagProvided ? normalizeFlag(fields.flag) : void 0;
4580
4784
  const statusChanged = fields.status !== void 0 && fields.status !== task.frontmatter.status;
@@ -4582,6 +4786,7 @@ async function updateTask(adapter, config, slug, fields, body) {
4582
4786
  ...task.frontmatter,
4583
4787
  ...fields,
4584
4788
  ...dependsOnProvided ? { depends_on: dependsOn } : {},
4789
+ ...relatedProvided ? { related } : {},
4585
4790
  ...flagProvided ? { flag } : {},
4586
4791
  // `created` is set once at creation and is not user-modifiable.
4587
4792
  created: task.frontmatter.created,
@@ -4905,7 +5110,6 @@ Tasks can be managed through any combination of:
4905
5110
  - **The ShipBench CLI** (\`shipbench\` commands) \u2014 recommended for scripted or agent-driven changes; centralizes slug generation, validation, timestamps, and layout updates.
4906
5111
  - **The Board UI** (\`shipbench board\`) \u2014 local kanban in your browser, with live file watching.
4907
5112
  - **The terminal board** (\`shipbench board terminal\`) \u2014 the same board as a read-only live view, for leaving open in a pane beside your work.
4908
- - **Harbor** \u2014 hosted view for browsing project boards across repos.
4909
5113
  - **Direct file editing** \u2014 always valid; task files are plain Markdown.
4910
5114
 
4911
5115
  ## \`config.json\` reference
@@ -4918,7 +5122,7 @@ Schema version. Currently informational. Leave as \`1\`.
4918
5122
 
4919
5123
  ### \`name\`
4920
5124
 
4921
- The project's display name. Every consumer (CLI, Board, Harbor) reads this for the breadcrumb root. Defaults to the basename of the current directory when \`shipbench init\` runs; override with \`--name\`.
5125
+ The project's display name. Every consumer (the CLI and the Board) reads this for the breadcrumb root. Defaults to the basename of the current directory when \`shipbench init\` runs; override with \`--name\`.
4922
5126
 
4923
5127
  ### \`columns\`
4924
5128
 
@@ -4972,7 +5176,7 @@ Visible order comes from \`config.json\`, the task files, and this partial index
4972
5176
  - The Uncategorized column and the \`done_column\` both ignore \`layout\` entirely.
4973
5177
  - The CLI and Board do not record \`layout[done_column]\`; any existing entry is removed on the next layout write.
4974
5178
 
4975
- Do not read \`layout.json\` alone to determine board order. \`shipbench task list --json\` returns live tasks in canonical board order, including each task's zero-based \`position\` within its column. Direct file readers must apply the rules above. Treat the index as machine-managed: do not hand-edit or hand-order it. You may gitignore it if ordering should stay machine-local, but Harbor and fresh clones will then fall back to deterministic \`created\`-descending order for unlisted tasks.
5179
+ Do not read \`layout.json\` alone to determine board order. \`shipbench task list --json\` returns live tasks in canonical board order, including each task's zero-based \`position\` within its column. Direct file readers must apply the rules above. Treat the index as machine-managed: do not hand-edit or hand-order it. You may gitignore it if ordering should stay machine-local, but fresh clones will then fall back to deterministic \`created\`-descending order for unlisted tasks.
4976
5180
 
4977
5181
  ## Task files
4978
5182
 
@@ -5021,6 +5225,7 @@ priority: medium
5021
5225
  assignee:
5022
5226
  tags: []
5023
5227
  depends_on: []
5228
+ related: []
5024
5229
  created: 2024-01-01T00:00:00.000Z
5025
5230
  updated: 2024-01-01T00:00:00.000Z
5026
5231
  ---
@@ -5036,6 +5241,7 @@ Task description in Markdown.
5036
5241
  - **assignee** (optional): Freeform string label (e.g. \`claude\`, \`antigravity\`, or \`human\`). Informational only \u2014 task eligibility is governed strictly by \`status\` and \`depends_on\`. Moving a task to \`in-progress\` signals that work has started.
5037
5242
  - **tags** (optional): Array of freeform strings.
5038
5243
  - **depends_on** (optional): Array of task slugs that must be finished before this task can start. An omitted field and an empty array mean the same thing. A slug must name a task file that exists; a task may not depend on itself, and two tasks may not depend on each other.
5244
+ - **related** (optional): Array of task slugs this task is associated with \u2014 the spike behind a decision, a sibling task sharing a surface. It points at other work without ordering it: it gates nothing, never blocks archiving, and stays out of the dependency graph. A slug must name a live or archived task file, and a task may not name itself. The association reads in both directions: JSON from \`task list\` and \`task search\` shows it from either task in \`related_tasks\`, while \`task get\` reports the file as written. Use \`depends_on\` when one task has to finish first, and \`related\` when the other task only explains or shares context.
5039
5245
  - **flag** (optional): Marks the task for attention without changing its column \u2014 a one-line reason, or \`true\` when there is none to give. What a flag means is this project's call. Informational only: it gates nothing, and nothing clears it automatically. Omit the field when the task is not flagged.
5040
5246
  - **created** (required): ISO 8601 timestamp. Set once on creation, never modify.
5041
5247
  - **updated** (required): ISO 8601 timestamp. Update on every modification.
@@ -5088,7 +5294,7 @@ shipbench task list --available --tag backend --json
5088
5294
  shipbench task list --available --tag backend,auth --assignee agent --json
5089
5295
  \`\`\`
5090
5296
 
5091
- \`--tag\` accepts comma-separated values or repeated flags and uses AND semantics. \`--status\`, \`--assignee\`, and \`--priority\` take the same comma-separated or repeated form but match a task whose value is any of the ones listed; \`--limit\` caps the count. A \`--status\` or \`--priority\` value that is not configured is an error naming the valid set, not a silently empty result. Use \`--status\` when the project's actionable column differs from its configured default. \`shipbench task search\` takes the same filters \u2014 including \`--available\` / \`--blocked\` \u2014 so "ready work that mentions X" is one query rather than a search plus a hand filter.
5297
+ \`--tag\` accepts comma-separated values or repeated flags and uses AND semantics. \`--exclude-tag\` takes the same form and drops a task carrying any of the listed tags, so \`--available --exclude-tag plan\` leaves out tasks that are not work items. \`--status\`, \`--assignee\`, and \`--priority\` take the same comma-separated or repeated form but match a task whose value is any of the ones listed; \`--limit\` caps the count. A \`--status\` or \`--priority\` value that is not configured is an error naming the valid set, not a silently empty result. Use \`--status\` when the project's actionable column differs from its configured default. \`shipbench task search\` takes the same filters \u2014 including \`--available\` / \`--blocked\` \u2014 so "ready work that mentions X" is one query rather than a search plus a hand filter.
5092
5298
 
5093
5299
  \`task search\` matches each term as a case-insensitive substring by default. Add \`--whole-word\` to match on word boundaries, and wrap a run in literal double quotes (\`task search '"exact phrase"'\`) to require it to match contiguously.
5094
5300
 
@@ -5106,6 +5312,7 @@ Use the other discovery commands when the task needs more context:
5106
5312
  - **Load complete matching descriptions**: \`shipbench task search "<query>" --json --include-body\`
5107
5313
  - **Search live and archived tasks**: \`shipbench task search "<query>" --all --json\`
5108
5314
  - **Inspect the dependency DAG**: \`shipbench task graph --json\` (add \`--archived\` to resolve archived nodes)
5315
+ - **Trace one task's dependencies**: \`shipbench task graph <slug> --json\` shows what it waits on and what finishing it would unblock (\`--blockers\` or \`--dependents\` for one side, \`--depth 1\` for direct neighbors only)
5109
5316
  - **List archived tasks**: \`shipbench task list --archived --json\`
5110
5317
 
5111
5318
  Following that principle, add \`--include-body\` to a JSON \`task list\` only when you need every returned description and Updates array. Add it to a JSON \`task search\` when you need complete matching descriptions instead of snippets. Prefer \`task get\` after narrowing when one matching task answers the question.
@@ -5114,6 +5321,8 @@ Following that principle, add \`--include-body\` to a JSON \`task list\` only wh
5114
5321
 
5115
5322
  A task with unfinished dependencies is not ready, even if nothing prevents you from editing it \u2014 \`depends_on\` is data, not a lock.
5116
5323
 
5324
+ \`related\` never affects readiness. It names work worth reading for context, not work that has to land first.
5325
+
5117
5326
  Prose sections in a task body (\`## Depends on\`, \`## Blocked by\`, and similar) are commentary. Read them for context, but do not treat them as the dependency graph.
5118
5327
 
5119
5328
  Note that \`depends_on\` and the task's column are orthogonal. A column says where a task is; \`depends_on\` says what has to land first.
@@ -5145,14 +5354,16 @@ Ordering is a human judgment call, so reorder only when the user explicitly asks
5145
5354
 
5146
5355
  ## Operations
5147
5356
 
5148
- Prefer the ShipBench CLI for task mutations when it is available. The CLI routes through core, so slug generation, validation, timestamps, collision handling, and layout updates stay consistent.
5357
+ Prefer the ShipBench CLI for task mutations when it is available. The CLI routes through core, so slug generation, validation, timestamps, collision handling, and layout updates stay consistent. Every \`task\` command accepts \`--json\`. A write with \`--json\` prints the resulting task in the \`task get\` shape, so you can confirm it without a second read.
5358
+
5359
+ Commands work from any subdirectory of the board: the CLI uses the nearest \`.shipbench/\` at or above the current directory. \`-C <path>\` names a board's directory exactly.
5149
5360
 
5150
5361
  ### Preferred CLI Operations
5151
5362
 
5152
5363
  - **List available tasks**: \`shipbench task list --available --json\`
5153
5364
  - **List blocked tasks**: \`shipbench task list --blocked --json\`
5154
5365
  - **List flagged tasks**: \`shipbench task list --flagged --json\`
5155
- - **Filter by tags**: \`shipbench task list --available --tag backend,auth --json\`
5366
+ - **Filter by tags**: \`shipbench task list --available --tag backend,auth --json\` (\`--exclude-tag\` leaves out tasks carrying any listed tag)
5156
5367
  - **Read one task**: \`shipbench task get <slug>\`
5157
5368
  - **Search tasks**: \`shipbench task search "<query>" --json\`
5158
5369
  - **Inspect dependencies**: \`shipbench task graph --json\`
@@ -5160,8 +5371,9 @@ Prefer the ShipBench CLI for task mutations when it is available. The CLI routes
5160
5371
  - **Create a task**: \`shipbench task create "Task title" --status=todo\`
5161
5372
  - **Create a task with a description**: \`shipbench task create "Task title" --body-file=description.md\` (or \`--body "One-line description."\`)
5162
5373
  - **Rewrite a description**: \`shipbench task edit <slug> --body-file=description.md\` (replaces it whole; \`--body ""\` clears it)
5163
- - **Revise task metadata**: \`shipbench task edit <slug> --priority=high --assignee=agent --add-tag=urgent --remove-tag=stale\` (also \`--title\`, \`--tags\`, \`--clear-tags\`, \`--clear-assignee\`, \`--depends-on\`, \`--add-depends-on\`, \`--remove-depends-on\`, \`--clear-depends-on\`). Every flag is applied in one validated write, so a rejected value leaves the task untouched. A title edit keeps the existing slug and filename. Status and board placement stay with \`task move\`.
5374
+ - **Revise task metadata**: \`shipbench task edit <slug> --priority=high --assignee=agent --add-tag=urgent --remove-tag=stale\` (also \`--title\`, \`--tags\`, \`--clear-tags\`, \`--clear-assignee\`, \`--depends-on\`, \`--add-depends-on\`, \`--remove-depends-on\`, \`--clear-depends-on\`, \`--related\`, \`--add-related\`, \`--remove-related\`, \`--clear-related\`). Every flag is applied in one validated write, so a rejected value leaves the task untouched. The related flags edit only this task's own list; removing a link the other task's file records is rejected with the task to edit instead. A title edit keeps the existing slug and filename. Status and board placement stay with \`task move\`.
5164
5375
  - **Create a dependent task**: \`shipbench task create "Task title" --depends-on=other-slug,another-slug\`
5376
+ - **Link related work**: \`shipbench task create "Task title" --related=spike-slug\` (or \`task edit <slug> --add-related=other-slug\`)
5165
5377
  - **Add a time-anchored update**: \`shipbench task comment <slug> "What changed and why."\`
5166
5378
  - **Add a multi-line update**: \`shipbench task comment <slug> --body-file update.md\`
5167
5379
  - **Edit an update's text**: \`shipbench task comment edit <slug> <index> "Corrected text."\` (also takes \`--body-file\`)
@@ -5176,7 +5388,7 @@ Prefer the ShipBench CLI for task mutations when it is available. The CLI routes
5176
5388
  - **Unarchive a task**: \`shipbench task unarchive <slug>\`
5177
5389
  - **Delete a task**: \`shipbench task delete <slug>\`
5178
5390
  - **Open the board**: \`shipbench board\`
5179
- - **Watch the board in the terminal**: \`shipbench board terminal\` (read-only; \`--status\`, \`--tag\`, \`--assignee\`, \`--priority\`, \`--flagged\` narrow it)
5391
+ - **Watch the board in the terminal**: \`shipbench board terminal\` (read-only; \`--status\`, \`--tag\`, \`--exclude-tag\`, \`--assignee\`, \`--priority\`, \`--flagged\` narrow it)
5180
5392
 
5181
5393
  ### Direct File Operations
5182
5394
 
@@ -5184,7 +5396,7 @@ Use direct edits only when the CLI is unavailable.
5184
5396
 
5185
5397
  - **Create a task**: Add a new \`.md\` file in \`tasks/\` following the format above.
5186
5398
  - **Move a task**: Change the \`status\` field and update the \`updated\` timestamp.
5187
- - **Edit a task**: Modify frontmatter fields and/or the description above \`## Task Updates\`. Always update \`updated\`. \`shipbench task edit\` reaches the description and the validated metadata fields (title, priority, assignee, tags, depends_on) \u2014 use it rather than rewriting a file by hand.
5399
+ - **Edit a task**: Modify frontmatter fields and/or the description above \`## Task Updates\`. Always update \`updated\`. \`shipbench task edit\` reaches the description and the validated metadata fields (title, priority, assignee, tags, depends_on, related) \u2014 use it rather than rewriting a file by hand.
5188
5400
  - **Add an Update without the CLI**: Append a \`### <ISO 8601 timestamp>\` heading and text below the trailing \`## Task Updates\` marker.
5189
5401
  - **Edit an Update without the CLI**: Change only its text; preserve the \`###\` timestamp heading and update the frontmatter \`updated\` value.
5190
5402
  - **Flag a task without the CLI**: Set \`flag\` to a one-line reason or \`true\`, remove the field to clear it, and update \`updated\`.
@@ -5405,228 +5617,6 @@ function searchTasks(tasks, query, options2 = {}) {
5405
5617
  ).map((entry) => entry.match);
5406
5618
  }
5407
5619
 
5408
- // src/harborConnect.ts
5409
- var CliExitError = class extends Error {
5410
- constructor(message2, exitCode) {
5411
- super(message2);
5412
- this.exitCode = exitCode;
5413
- this.name = "CliExitError";
5414
- }
5415
- exitCode;
5416
- };
5417
- var HARBOR_ERROR_MESSAGES = {
5418
- INVALID_REQUEST: "Harbor rejected the connection request.",
5419
- INVALID_REMOTE_URL: "The origin remote is not a supported GitHub repository URL.",
5420
- INVALID_CONNECT_TOKEN: "This connect URL is invalid.",
5421
- PROJECT_NOT_FOUND: "The Harbor project no longer exists.",
5422
- PROJECT_ALREADY_CONNECTED: "This Harbor project is already connected to another repository.",
5423
- REPOSITORY_ALREADY_CONNECTED: "This repository is already connected to another Harbor project.",
5424
- CONNECT_TOKEN_USED: "This Harbor connect URL has already been used or superseded. Generate a new URL in Harbor.",
5425
- CONNECT_TOKEN_EXPIRED: "This connect URL has expired. Generate a new URL in Harbor."
5426
- };
5427
- var runGitCommand = (cwd, args) => new Promise((resolveResult) => {
5428
- execFile(
5429
- "git",
5430
- args,
5431
- { cwd, encoding: "utf8", windowsHide: true },
5432
- (error, stdout) => {
5433
- resolveResult({
5434
- exitCode: typeof error?.code === "number" ? error.code : error ? 1 : 0,
5435
- stdout: stdout.trim()
5436
- });
5437
- }
5438
- );
5439
- });
5440
- function isLoopbackHost(hostname) {
5441
- const normalized = hostname.toLowerCase();
5442
- if (normalized === "localhost" || normalized === "::1" || normalized === "[::1]") {
5443
- return true;
5444
- }
5445
- const match = /^127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(normalized);
5446
- return match?.slice(1).every((part) => Number(part) >= 0 && Number(part) <= 255) === true;
5447
- }
5448
- function validateHarborConnectUrl(input) {
5449
- const trimmed = input.trim();
5450
- let parsed;
5451
- try {
5452
- parsed = new URL(trimmed);
5453
- } catch {
5454
- throw new CliExitError(
5455
- "The Harbor connect URL is invalid. Generate a fresh command in Harbor.",
5456
- 2
5457
- );
5458
- }
5459
- const allowedProtocol = parsed.protocol === "https:" || parsed.protocol === "http:" && isLoopbackHost(parsed.hostname);
5460
- if (!allowedProtocol || parsed.username || parsed.password || parsed.hash) {
5461
- throw new CliExitError(
5462
- "The Harbor connect URL must use HTTPS, contain no credentials or fragment, and may use HTTP only on a loopback host.",
5463
- 2
5464
- );
5465
- }
5466
- return trimmed;
5467
- }
5468
- async function comparablePath(path) {
5469
- let canonical;
5470
- try {
5471
- canonical = await realpath(path);
5472
- } catch {
5473
- canonical = resolve(path);
5474
- }
5475
- const normalized = canonical.replace(/[\\/]+$/, "");
5476
- return process.platform === "win32" ? normalized.toLowerCase() : normalized;
5477
- }
5478
- async function prepareHarborConnection(input, cwd, runGit) {
5479
- const connectUrl = validateHarborConnectUrl(input);
5480
- const rootResult = await runGit(cwd, ["rev-parse", "--show-toplevel"]);
5481
- if (rootResult.exitCode !== 0 || !rootResult.stdout) {
5482
- throw new CliExitError(
5483
- "The current directory is not a Git worktree. Run this command from a Git repository root.",
5484
- 2
5485
- );
5486
- }
5487
- const [gitRoot, currentDirectory] = await Promise.all([
5488
- comparablePath(rootResult.stdout),
5489
- comparablePath(cwd)
5490
- ]);
5491
- if (gitRoot !== currentDirectory) {
5492
- throw new CliExitError(
5493
- "Run this command from the Git worktree root, not a nested directory.",
5494
- 2
5495
- );
5496
- }
5497
- return { connectUrl, cwd };
5498
- }
5499
- function isHarborConnectResponse(value) {
5500
- return typeof value === "object" && value !== null && typeof value.message === "string" && (value.already_connected === void 0 || typeof value.already_connected === "boolean");
5501
- }
5502
- function isHarborConnectErrorResponse(value) {
5503
- return typeof value === "object" && value !== null && typeof value.code === "string" && typeof value.error === "string";
5504
- }
5505
- function redactConnectCredential(text, connectUrl) {
5506
- let redacted = text.replaceAll(connectUrl, "[redacted connect URL]");
5507
- try {
5508
- const token = new URL(connectUrl).searchParams.get("token");
5509
- if (token) redacted = redacted.replaceAll(token, "[redacted token]");
5510
- } catch {
5511
- }
5512
- return redacted;
5513
- }
5514
- async function collectGitVisibilityWarnings(cwd, runGit) {
5515
- const [headConfig, status, upstream] = await Promise.all([
5516
- runGit(cwd, ["cat-file", "-e", "HEAD:.shipbench/config.json"]),
5517
- runGit(cwd, [
5518
- "status",
5519
- "--porcelain=v1",
5520
- "--untracked-files=all",
5521
- "--",
5522
- ".shipbench"
5523
- ]),
5524
- runGit(cwd, [
5525
- "rev-parse",
5526
- "--abbrev-ref",
5527
- "--symbolic-full-name",
5528
- "@{upstream}"
5529
- ])
5530
- ]);
5531
- const warnings = [];
5532
- if (headConfig.exitCode !== 0) {
5533
- warnings.push(
5534
- ".shipbench/config.json is absent from HEAD. Commit and push the ShipBench project before opening its board in Harbor."
5535
- );
5536
- }
5537
- if (status.exitCode !== 0) {
5538
- warnings.push("Git could not inspect uncommitted ShipBench changes.");
5539
- } else if (status.stdout) {
5540
- warnings.push(
5541
- "ShipBench files have uncommitted changes. Commit and push them so Harbor can see the current project."
5542
- );
5543
- }
5544
- if (upstream.exitCode !== 0 || !upstream.stdout) {
5545
- warnings.push(
5546
- "The current branch has no upstream. ShipBench files may not be pushed."
5547
- );
5548
- return warnings;
5549
- }
5550
- const ahead = await runGit(cwd, ["rev-list", "--count", "@{upstream}..HEAD"]);
5551
- if (ahead.exitCode !== 0) {
5552
- warnings.push("Git could not determine whether the branch is pushed.");
5553
- return warnings;
5554
- }
5555
- const aheadCount = Number.parseInt(ahead.stdout, 10);
5556
- if (Number.isInteger(aheadCount) && aheadCount > 0) {
5557
- warnings.push(
5558
- `The current branch is ${aheadCount} ${aheadCount === 1 ? "commit" : "commits"} ahead of its upstream. Push it so Harbor can see the current project.`
5559
- );
5560
- }
5561
- return warnings;
5562
- }
5563
- function indeterminateError(operationStatus) {
5564
- return new CliExitError(
5565
- `${operationStatus} Harbor's result is unknown. Check the project in Harbor before retrying. No automatic retry was sent.`,
5566
- 4
5567
- );
5568
- }
5569
- async function connectPreparedProjectToHarbor(options2) {
5570
- const { prepared, runGit, fetch: fetchImpl, warn, operationStatus } = options2;
5571
- const remote = await runGit(prepared.cwd, ["remote", "get-url", "origin"]);
5572
- if (remote.exitCode !== 0 || !remote.stdout) {
5573
- throw new CliExitError(
5574
- `${operationStatus} No GitHub origin remote was found. Add an origin, then rerun the command. Harbor was not contacted.`,
5575
- 2
5576
- );
5577
- }
5578
- const normalizedRemote = normalizeGithubRemoteUrl(remote.stdout);
5579
- if (!normalizedRemote) {
5580
- throw new CliExitError(
5581
- `${operationStatus} The origin is not a supported GitHub repository URL. Use a GitHub HTTPS, scp-style SSH, or ssh://git@github.com remote. Harbor was not contacted.`,
5582
- 2
5583
- );
5584
- }
5585
- for (const warning of await collectGitVisibilityWarnings(
5586
- prepared.cwd,
5587
- runGit
5588
- )) {
5589
- warn(`Warning: ${warning}`);
5590
- }
5591
- let response;
5592
- try {
5593
- response = await fetchImpl(prepared.connectUrl, {
5594
- method: "POST",
5595
- headers: { "content-type": "application/json" },
5596
- body: JSON.stringify({ remote_url: normalizedRemote })
5597
- });
5598
- } catch {
5599
- throw indeterminateError(operationStatus);
5600
- }
5601
- if (response.status >= 500 || response.status < 200) {
5602
- throw indeterminateError(operationStatus);
5603
- }
5604
- let body;
5605
- try {
5606
- body = await response.json();
5607
- } catch {
5608
- throw indeterminateError(operationStatus);
5609
- }
5610
- if (response.ok) {
5611
- if (!isHarborConnectResponse(body)) {
5612
- throw indeterminateError(operationStatus);
5613
- }
5614
- return redactConnectCredential(body.message, prepared.connectUrl);
5615
- }
5616
- if (response.status < 400 || response.status >= 500 || !isHarborConnectErrorResponse(body)) {
5617
- throw indeterminateError(operationStatus);
5618
- }
5619
- const detail = HARBOR_ERROR_MESSAGES[body.code] ?? `Harbor rejected this connection (HTTP ${response.status}).`;
5620
- throw new CliExitError(
5621
- `${operationStatus} Harbor definitively rejected the connection. ${detail}`,
5622
- 3
5623
- );
5624
- }
5625
-
5626
- // src/processCli.ts
5627
- import { statSync } from "fs";
5628
- import { basename, resolve as resolve3 } from "path";
5629
-
5630
5620
  // src/cli.ts
5631
5621
  import { readFile as readFile3 } from "fs/promises";
5632
5622
  import { Command, InvalidArgumentError, Option } from "commander";
@@ -5638,7 +5628,7 @@ import {
5638
5628
  createServer
5639
5629
  } from "http";
5640
5630
  import { createRequire } from "module";
5641
- import { dirname as dirname2, extname, join as join3, resolve as resolve2, sep as sep2 } from "path";
5631
+ import { dirname as dirname2, extname, join as join3, resolve, sep as sep2 } from "path";
5642
5632
  import { platform } from "process";
5643
5633
 
5644
5634
  // src/tui/paths.ts
@@ -5665,8 +5655,8 @@ async function watchProject(cwd, onChange, debounceMs = DEBOUNCE_MS) {
5665
5655
  if (debounce) clearTimeout(debounce);
5666
5656
  debounce = setTimeout(() => void onChange(), debounceMs);
5667
5657
  });
5668
- await new Promise((resolve4, reject) => {
5669
- watcher.once("ready", resolve4);
5658
+ await new Promise((resolve3, reject) => {
5659
+ watcher.once("ready", resolve3);
5670
5660
  watcher.once("error", reject);
5671
5661
  });
5672
5662
  return {
@@ -5788,8 +5778,8 @@ async function serveStatic(req, res, bundleDir) {
5788
5778
  const url = new URL(req.url ?? "/", "http://localhost");
5789
5779
  const pathname = decodeURIComponent(url.pathname);
5790
5780
  const relative2 = pathname === "/" ? "/standalone.html" : pathname;
5791
- const root = resolve2(bundleDir);
5792
- const target = resolve2(root, `.${relative2}`);
5781
+ const root = resolve(bundleDir);
5782
+ const target = resolve(root, `.${relative2}`);
5793
5783
  if (target !== root && !target.startsWith(`${root}${sep2}`)) {
5794
5784
  sendError(res, 403, "Forbidden");
5795
5785
  return;
@@ -6120,15 +6110,18 @@ function shouldUseColor(env, isStdoutTty) {
6120
6110
  }
6121
6111
 
6122
6112
  // src/output.ts
6123
- function formatInitNextSteps(harborConnected) {
6113
+ function formatInitNextSteps() {
6124
6114
  return [
6125
6115
  "",
6126
6116
  "Next steps:",
6127
6117
  ' 1. Create a task: shipbench task create "My first task"',
6128
6118
  " 2. Open the board: shipbench board",
6129
- harborConnected ? " 3. Open Harbor to view this ShipBench project." : " 3. Read .shipbench/README.md to learn the project workflow."
6119
+ " 3. Read .shipbench/README.md to learn the project workflow."
6130
6120
  ];
6131
6121
  }
6122
+ function formatMissingBoard(location) {
6123
+ return `No .shipbench/config.json found ${location}. Run shipbench init first.`;
6124
+ }
6132
6125
  function formatBoardStatus(url, cwd) {
6133
6126
  return [
6134
6127
  `Board ready at ${url}`,
@@ -6165,16 +6158,15 @@ function matchesFilters(task, filters) {
6165
6158
  return false;
6166
6159
  }
6167
6160
  if (filters.flagged && !isTaskFlagged(task)) return false;
6161
+ const tags = (task.frontmatter.tags ?? []).map((tag) => tag.toLowerCase());
6162
+ const unwanted = filters.excludedTags ?? [];
6163
+ if (unwanted.some((tag) => tags.includes(tag.toLowerCase()))) return false;
6168
6164
  const wanted = filters.tags ?? [];
6169
- if (wanted.length > 0) {
6170
- const tags = (task.frontmatter.tags ?? []).map((tag) => tag.toLowerCase());
6171
- if (!wanted.every((tag) => tags.includes(tag.toLowerCase()))) return false;
6172
- }
6173
- return true;
6165
+ return wanted.every((tag) => tags.includes(tag.toLowerCase()));
6174
6166
  }
6175
6167
  function hasTaskFilters(filters) {
6176
6168
  return Boolean(
6177
- filters.assignee || filters.priority || filters.flagged || filters.tags && filters.tags.length > 0
6169
+ filters.assignee || filters.priority || filters.flagged || filters.tags && filters.tags.length > 0 || filters.excludedTags && filters.excludedTags.length > 0
6178
6170
  );
6179
6171
  }
6180
6172
  function buildBoardModel(config, tasks, warnings, filters = {}, archivedTasks = [], archivedSlugs = [], now = /* @__PURE__ */ new Date()) {
@@ -6870,10 +6862,10 @@ async function runTui(options2) {
6870
6862
  paint();
6871
6863
  const watcher = await watch(options2.cwd, () => refresh());
6872
6864
  const keepalive = setInterval(() => void 0, 1 << 30);
6873
- await new Promise((resolve4) => {
6865
+ await new Promise((resolve3) => {
6874
6866
  if (!signal) return;
6875
- if (signal.aborted) resolve4();
6876
- else signal.addEventListener("abort", () => resolve4(), { once: true });
6867
+ if (signal.aborted) resolve3();
6868
+ else signal.addEventListener("abort", () => resolve3(), { once: true });
6877
6869
  });
6878
6870
  clearInterval(keepalive);
6879
6871
  await watcher.close();
@@ -6881,7 +6873,7 @@ async function runTui(options2) {
6881
6873
  }
6882
6874
 
6883
6875
  // src/cli.ts
6884
- var VERSION = true ? "0.7.1" : "0.0.0-dev";
6876
+ var VERSION = true ? "0.9.0" : "0.0.0-dev";
6885
6877
  function commaList(value) {
6886
6878
  return value.split(",").map((s) => s.trim()).filter(Boolean);
6887
6879
  }
@@ -6929,6 +6921,7 @@ function resolveTaskFilters(command, raw, config) {
6929
6921
  priorities,
6930
6922
  assignees: raw.assignee ?? [],
6931
6923
  tags: raw.tag ?? [],
6924
+ excludedTags: raw.excludeTag ?? [],
6932
6925
  flagged: Boolean(raw.flagged)
6933
6926
  };
6934
6927
  }
@@ -6945,6 +6938,11 @@ function taskMatchesFilters(task, filters, options2 = {}) {
6945
6938
  }
6946
6939
  if (filters.flagged && !isTaskFlagged(task)) return false;
6947
6940
  const taskTags = (frontmatter.tags ?? []).map((tag) => tag.toLowerCase());
6941
+ if (filters.excludedTags.some(
6942
+ (unwanted) => taskTags.includes(unwanted.toLowerCase())
6943
+ )) {
6944
+ return false;
6945
+ }
6948
6946
  return filters.tags.every((wanted) => taskTags.includes(wanted.toLowerCase()));
6949
6947
  }
6950
6948
  function flagSuffix(task) {
@@ -6966,6 +6964,13 @@ function parseNonNegativeInteger(value) {
6966
6964
  }
6967
6965
  return parsed;
6968
6966
  }
6967
+ function parsePositiveInteger(value) {
6968
+ const parsed = Number(value);
6969
+ if (!Number.isInteger(parsed) || parsed < 1) {
6970
+ throw new InvalidArgumentError("Value must be a positive integer.");
6971
+ }
6972
+ return parsed;
6973
+ }
6969
6974
  function parseLayoutPosition(value) {
6970
6975
  const parsed = Number(value);
6971
6976
  if (!Number.isInteger(parsed) || parsed < -1) {
@@ -7034,6 +7039,52 @@ function formatTaskDependencyGraph(graph) {
7034
7039
  }
7035
7040
  return lines;
7036
7041
  }
7042
+ function formatTaskDependencyQuery(query) {
7043
+ const state = query.available ? "available" : query.dependencies_satisfied ? "dependencies satisfied" : "blocked";
7044
+ const lines = [
7045
+ `${query.slug} [${query.status}]: ${state}${query.invalid_depends_on ? ", invalid depends_on" : ""}`
7046
+ ];
7047
+ const describe = (node) => {
7048
+ const notes = [];
7049
+ if (node.satisfied !== void 0) {
7050
+ notes.push(node.satisfied ? "satisfied" : "unsatisfied");
7051
+ }
7052
+ if (node.unblocks_on_completion) notes.push("unblocks on completion");
7053
+ if (node.waiting_on?.length) {
7054
+ notes.push(`waiting on ${node.waiting_on.join(", ")}`);
7055
+ }
7056
+ if (node.invalid_depends_on) notes.push("invalid depends_on");
7057
+ if (node.omitted === "repeat") notes.push("expanded above");
7058
+ if (node.omitted === "cycle") notes.push("cycle");
7059
+ if (node.omitted === "depth") notes.push("more beyond --depth");
7060
+ const suffix = notes.length > 0 ? ` (${notes.join("; ")})` : "";
7061
+ return `${node.slug} [${node.status}]${suffix}`;
7062
+ };
7063
+ const tree = (nodes, prefix) => {
7064
+ nodes.forEach((node, index) => {
7065
+ const isLast = index === nodes.length - 1;
7066
+ lines.push(`${prefix}${isLast ? "`-" : "+-"} ${describe(node)}`);
7067
+ tree(node.children, `${prefix}${isLast ? " " : "| "}`);
7068
+ });
7069
+ };
7070
+ const section = (label, nodes) => {
7071
+ if (!nodes) return;
7072
+ if (nodes.length === 0) {
7073
+ lines.push(`${label}: none`);
7074
+ return;
7075
+ }
7076
+ lines.push(`${label}:`);
7077
+ tree(nodes, "");
7078
+ };
7079
+ section("Blockers", query.blockers);
7080
+ section("Dependents", query.dependents);
7081
+ if (query.truncated) {
7082
+ lines.push(
7083
+ `Stopped at --depth ${query.depth}; some branches continue past it.`
7084
+ );
7085
+ }
7086
+ return lines;
7087
+ }
7037
7088
  function bodyOption() {
7038
7089
  return new Option("--body <text>", "Description as Markdown text").conflicts([
7039
7090
  "bodyFile"
@@ -7068,6 +7119,15 @@ function enableExitOverride(command) {
7068
7119
  function formatUnreadableFile(file) {
7069
7120
  return `[unreadable] ${file.path}: ${file.reason} (${file.slug})`;
7070
7121
  }
7122
+ function taskJson(task) {
7123
+ return {
7124
+ slug: task.slug,
7125
+ status: task.frontmatter.status,
7126
+ frontmatter: task.frontmatter,
7127
+ body: task.body,
7128
+ comments: task.comments
7129
+ };
7130
+ }
7071
7131
  function unreadableFileJson(file, includeBody) {
7072
7132
  return {
7073
7133
  slug: file.slug,
@@ -7093,13 +7153,24 @@ function createCli(opts) {
7093
7153
  env: opts.env ?? process.env
7094
7154
  });
7095
7155
  const { data, chrome } = output;
7096
- const loadCliConfig = () => loadConfig(adapter, {
7097
- onWarning: (warning) => {
7098
- output.warning(`${warning.path}: ${warning.message}`);
7156
+ const missingBoardMessage = opts.missingBoardMessage ?? formatMissingBoard(`in ${cwd}`);
7157
+ const requireBoard = async () => {
7158
+ if (await adapter.readFileIfExists(CONFIG_PATH4) === null) {
7159
+ throw new Error(missingBoardMessage);
7099
7160
  }
7100
- });
7101
- const fetchImpl = opts.fetch ?? ((input, init) => fetch(input, init));
7102
- const runGit = opts.runGit ?? runGitCommand;
7161
+ };
7162
+ const loadCliConfig = async () => {
7163
+ try {
7164
+ return await loadConfig(adapter, {
7165
+ onWarning: (warning) => {
7166
+ output.warning(`${warning.path}: ${warning.message}`);
7167
+ }
7168
+ });
7169
+ } catch (error) {
7170
+ await requireBoard();
7171
+ throw error;
7172
+ }
7173
+ };
7103
7174
  const readTextFile = opts.readTextFile ?? ((path) => readFile3(path, "utf8"));
7104
7175
  const readStdin = opts.readStdin ?? readProcessStdin;
7105
7176
  const resolveBody = async (raw) => {
@@ -7132,10 +7203,36 @@ function createCli(opts) {
7132
7203
  );
7133
7204
  return null;
7134
7205
  };
7206
+ const printTask = (task2) => data(JSON.stringify(taskJson(task2), null, 2));
7135
7207
  const program = new Command().name("shipbench").description("Git-native project management for solo developers.").enablePositionalOptions().version(VERSION, "-v, --version", "output the version").option(
7136
7208
  "-C <path>",
7137
- "Run as if ShipBench was started in the specified directory"
7209
+ "Use the board in the specified directory, without searching above it"
7138
7210
  );
7211
+ const writingCommands = /* @__PURE__ */ new Set([
7212
+ "task create",
7213
+ "task edit",
7214
+ "task comment",
7215
+ "task comment edit",
7216
+ "task comment delete",
7217
+ "task flag",
7218
+ "task unflag",
7219
+ "task move",
7220
+ "task archive",
7221
+ "task unarchive",
7222
+ "task delete"
7223
+ ]);
7224
+ if (opts.searchedFrom !== void 0 && opts.searchedFrom !== cwd) {
7225
+ program.hook("preAction", (_root, action) => {
7226
+ const names = [];
7227
+ for (let command = action; command?.parent; ) {
7228
+ names.unshift(command.name());
7229
+ command = command.parent;
7230
+ }
7231
+ if (writingCommands.has(names.join(" "))) {
7232
+ chrome(`Using .shipbench/ from ${cwd}`);
7233
+ }
7234
+ });
7235
+ }
7139
7236
  program.configureOutput({
7140
7237
  writeOut: (line) => data(line.replace(/\n$/, "")),
7141
7238
  writeErr: (line) => chrome(line.replace(/\n$/, ""))
@@ -7145,37 +7242,20 @@ function createCli(opts) {
7145
7242
  ).option(
7146
7243
  "-n, --name <name>",
7147
7244
  "Project name (defaults to current directory name)"
7148
- ).option(
7149
- "--harbor <connect-url>",
7150
- "Safely initialize, then connect the repository origin to Harbor with a signed URL"
7151
7245
  ).action(async (raw) => {
7152
7246
  const name = (raw.name ?? defaultProjectName).trim() || defaultProjectName;
7153
- let prepared;
7154
- if (raw.harbor) {
7155
- try {
7156
- prepared = await prepareHarborConnection(raw.harbor, cwd, runGit);
7157
- } catch (error) {
7158
- if (error instanceof CliExitError) {
7159
- throw new CliExitError(
7160
- `ShipBench initialization did not run, and Harbor was not contacted. ${error.message}`,
7161
- error.exitCode
7162
- );
7163
- }
7164
- throw error;
7165
- }
7166
- }
7167
7247
  let result;
7168
7248
  try {
7169
7249
  result = await initProject(adapter, { name });
7170
7250
  } catch (error) {
7171
7251
  throw new CliExitError(
7172
- `ShipBench files were not modified, and Harbor was not contacted. ${error instanceof Error ? error.message : "Initialization failed."}`,
7252
+ `ShipBench files were not modified. ${error instanceof Error ? error.message : "Initialization failed."}`,
7173
7253
  2
7174
7254
  );
7175
7255
  }
7176
7256
  if (!result.created && raw.name !== void 0 && result.config.name !== name) {
7177
7257
  throw new CliExitError(
7178
- `ShipBench files were not modified, and Harbor was not contacted. Existing project name "${result.config.name}" does not match --name "${name}".`,
7258
+ `ShipBench files were not modified. Existing project name "${result.config.name}" does not match --name "${name}".`,
7179
7259
  2
7180
7260
  );
7181
7261
  }
@@ -7183,67 +7263,20 @@ function createCli(opts) {
7183
7263
  for (const warning of result.warnings) {
7184
7264
  output.warning(formatProjectWarning(warning));
7185
7265
  }
7186
- const operationStatus = result.created ? "ShipBench initialization completed." : "ShipBench was already initialized and remains unchanged.";
7187
7266
  if (result.created) {
7188
7267
  chrome(`Initialized .shipbench/ for "${name}" in current directory.`);
7268
+ if (opts.ancestorBoard !== void 0) {
7269
+ chrome(
7270
+ `Note: ${opts.ancestorBoard} already has a .shipbench/ board. This one is separate, and tasks on one cannot depend on tasks on the other.`
7271
+ );
7272
+ }
7189
7273
  } else {
7190
7274
  chrome(`ShipBench is already initialized for "${result.config.name}".`);
7191
7275
  }
7192
- if (prepared) {
7193
- const message2 = await connectPreparedProjectToHarbor({
7194
- prepared,
7195
- runGit,
7196
- fetch: fetchImpl,
7197
- warn: chrome,
7198
- operationStatus
7199
- });
7200
- chrome(message2);
7201
- }
7202
7276
  if (result.created) {
7203
- for (const line of formatInitNextSteps(Boolean(prepared))) chrome(line);
7277
+ for (const line of formatInitNextSteps()) chrome(line);
7204
7278
  }
7205
7279
  });
7206
- program.command("connect").description(
7207
- "Connect an existing ShipBench project to Harbor without modifying project files"
7208
- ).requiredOption("--harbor <connect-url>", "Signed Harbor connect URL").action(async (raw) => {
7209
- let prepared;
7210
- try {
7211
- prepared = await prepareHarborConnection(raw.harbor, cwd, runGit);
7212
- } catch (error) {
7213
- if (error instanceof CliExitError) {
7214
- throw new CliExitError(
7215
- `ShipBench project files were not modified, and Harbor was not contacted. ${error.message}`,
7216
- error.exitCode
7217
- );
7218
- }
7219
- throw error;
7220
- }
7221
- const state = await inspectProjectInitialization(adapter);
7222
- if (state.kind === "missing") {
7223
- throw new CliExitError(
7224
- "ShipBench project files were not modified, and Harbor was not contacted. This repository is not initialized. Run shipbench init first.",
7225
- 2
7226
- );
7227
- }
7228
- if (state.kind !== "initialized") {
7229
- const detail = state.kind === "incomplete" ? `ShipBench project is incomplete because .shipbench/config.json is missing while these files exist: ${state.paths.join(", ")}.` : `ShipBench project is ${state.kind}: ${state.errors.join(" ")}`;
7230
- throw new CliExitError(
7231
- `ShipBench project files were not modified, and Harbor was not contacted. ${detail}`,
7232
- 2
7233
- );
7234
- }
7235
- for (const warning of state.warnings) {
7236
- output.warning(formatProjectWarning(warning));
7237
- }
7238
- const message2 = await connectPreparedProjectToHarbor({
7239
- prepared,
7240
- runGit,
7241
- fetch: fetchImpl,
7242
- warn: chrome,
7243
- operationStatus: "ShipBench project files remain unchanged."
7244
- });
7245
- chrome(message2);
7246
- });
7247
7280
  const task = program.command("task").description("Manage tasks");
7248
7281
  task.command("create <title>").description("Create a new task").option("-s, --status <status>", "Column to place the task in").option("-a, --assignee <assignee>", "Assignee label").option("-p, --priority <priority>", "Priority value").option(
7249
7282
  "-t, --tags <tags>",
@@ -7254,6 +7287,11 @@ function createCli(opts) {
7254
7287
  "Slugs this task depends on (comma-separated, repeatable)",
7255
7288
  accumulateCommaList,
7256
7289
  []
7290
+ ).option(
7291
+ "--related <slugs>",
7292
+ "Slugs of live or archived tasks this one relates to, without depending on them (comma-separated, repeatable)",
7293
+ accumulateCommaList,
7294
+ []
7257
7295
  ).addOption(bodyOption()).addOption(bodyFileOption()).option("--json", "Output the created task as JSON").addHelpText(
7258
7296
  "after",
7259
7297
  "\nPrefer --body-file for anything multi-line: the file is read as UTF-8 by\nShipBench, so the description never passes through shell quoting or encoding.\n"
@@ -7269,24 +7307,13 @@ function createCli(opts) {
7269
7307
  assignee: raw.assignee,
7270
7308
  priority: raw.priority,
7271
7309
  tags: raw.tags && dedupePreservingCase(raw.tags),
7272
- depends_on: raw.dependsOn
7310
+ depends_on: raw.dependsOn,
7311
+ related: raw.related
7273
7312
  },
7274
7313
  body
7275
7314
  );
7276
7315
  if (raw.json) {
7277
- data(
7278
- JSON.stringify(
7279
- {
7280
- slug: created.slug,
7281
- status: created.frontmatter.status,
7282
- frontmatter: created.frontmatter,
7283
- body: created.body,
7284
- comments: created.comments
7285
- },
7286
- null,
7287
- 2
7288
- )
7289
- );
7316
+ printTask(created);
7290
7317
  return;
7291
7318
  }
7292
7319
  chrome(`Created task: ${created.slug}`);
@@ -7345,6 +7372,26 @@ function createCli(opts) {
7345
7372
  "addDependsOn",
7346
7373
  "removeDependsOn"
7347
7374
  ])
7375
+ ).addOption(
7376
+ commaListOption(
7377
+ "--related <slugs>",
7378
+ "Replace every related task (comma-separated or repeatable)"
7379
+ ).conflicts(["addRelated", "removeRelated", "clearRelated"])
7380
+ ).addOption(
7381
+ commaListOption(
7382
+ "--add-related <slugs>",
7383
+ "Add related tasks, keeping the others (comma-separated or repeatable)"
7384
+ ).conflicts(["related", "clearRelated"])
7385
+ ).addOption(
7386
+ commaListOption(
7387
+ "--remove-related <slugs>",
7388
+ "Remove related tasks, keeping the others (comma-separated or repeatable)"
7389
+ ).conflicts(["related", "clearRelated"])
7390
+ ).addOption(
7391
+ new Option(
7392
+ "--clear-related",
7393
+ "Remove every related task this task's file records"
7394
+ ).conflicts(["related", "addRelated", "removeRelated"])
7348
7395
  ).addOption(bodyOption()).addOption(bodyFileOption()).option("--json", "Output the edited task as JSON").addHelpText(
7349
7396
  "after",
7350
7397
  "\nPass at least one change. Every change is applied in a single validated\nwrite: if any value is rejected the task is left exactly as it was. Status\nand board placement stay with `shipbench task move`; the Task Updates section\nstays with `shipbench task comment`. A title edit never renames the file.\n"
@@ -7360,10 +7407,14 @@ function createCli(opts) {
7360
7407
  const addDependsOn = raw.addDependsOn;
7361
7408
  const removeDependsOn = raw.removeDependsOn;
7362
7409
  const replaceDependsOn = raw.dependsOn;
7363
- const requestedAnything = body !== void 0 || raw.title !== void 0 || raw.priority !== void 0 || raw.assignee !== void 0 || clearAssignee || replaceTags !== void 0 || addTag !== void 0 || removeTag !== void 0 || clearTags || replaceDependsOn !== void 0 || addDependsOn !== void 0 || removeDependsOn !== void 0 || clearDependsOn;
7410
+ const clearRelated = Boolean(raw.clearRelated);
7411
+ const addRelated = raw.addRelated;
7412
+ const removeRelated = raw.removeRelated;
7413
+ const replaceRelated = raw.related;
7414
+ const requestedAnything = body !== void 0 || raw.title !== void 0 || raw.priority !== void 0 || raw.assignee !== void 0 || clearAssignee || replaceTags !== void 0 || addTag !== void 0 || removeTag !== void 0 || clearTags || replaceDependsOn !== void 0 || addDependsOn !== void 0 || removeDependsOn !== void 0 || clearDependsOn || replaceRelated !== void 0 || addRelated !== void 0 || removeRelated !== void 0 || clearRelated;
7364
7415
  if (!requestedAnything) {
7365
7416
  editCommand.error(
7366
- "Provide at least one change: --body/--body-file, --title, --priority, --assignee/--clear-assignee, --tags/--add-tag/--remove-tag/--clear-tags, or --depends-on/--add-depends-on/--remove-depends-on/--clear-depends-on."
7417
+ "Provide at least one change: --body/--body-file, --title, --priority, --assignee/--clear-assignee, --tags/--add-tag/--remove-tag/--clear-tags, --depends-on/--add-depends-on/--remove-depends-on/--clear-depends-on, or --related/--add-related/--remove-related/--clear-related."
7367
7418
  );
7368
7419
  return;
7369
7420
  }
@@ -7434,24 +7485,53 @@ function createCli(opts) {
7434
7485
  fields.depends_on = nextDeps;
7435
7486
  changes.push(`depends_on ${list(currentDeps)} \u2192 ${list(nextDeps)}`);
7436
7487
  }
7488
+ const currentRelated = relatedSlugs(existing);
7489
+ let nextRelated;
7490
+ if (replaceRelated !== void 0) {
7491
+ nextRelated = dedupePreservingCase(replaceRelated);
7492
+ } else if (clearRelated) {
7493
+ nextRelated = [];
7494
+ } else if (addRelated !== void 0 || removeRelated !== void 0) {
7495
+ const notOwn = (removeRelated ?? []).filter(
7496
+ (target) => !currentRelated.includes(target)
7497
+ );
7498
+ if (notOwn.length > 0) {
7499
+ const [live, archived] = await Promise.all([
7500
+ listTasks(adapter, config),
7501
+ listArchivedTasks(adapter, config)
7502
+ ]);
7503
+ const holds = (candidate, target) => candidate.slug === target && relatedSlugs(candidate).includes(slug);
7504
+ for (const target of notOwn) {
7505
+ if (live.tasks.some((candidate) => holds(candidate, target))) {
7506
+ editCommand.error(
7507
+ `Cannot remove related task "${target}" from ${slug}: the link is recorded in ${target}'s file, not this one. Remove it there: shipbench task edit ${target} --remove-related ${slug}`
7508
+ );
7509
+ return;
7510
+ }
7511
+ if (archived.tasks.some((candidate) => holds(candidate, target))) {
7512
+ editCommand.error(
7513
+ `Cannot remove related task "${target}" from ${slug}: the link is recorded in the archived task ${target}'s file, not this one. Unarchive ${target} to edit it.`
7514
+ );
7515
+ return;
7516
+ }
7517
+ }
7518
+ }
7519
+ const removed = new Set(removeRelated ?? []);
7520
+ nextRelated = dedupePreservingCase([
7521
+ ...currentRelated.filter((target) => !removed.has(target)),
7522
+ ...addRelated ?? []
7523
+ ]);
7524
+ }
7525
+ if (nextRelated !== void 0 && (nextRelated.length !== currentRelated.length || nextRelated.some((target, index) => target !== currentRelated[index]))) {
7526
+ fields.related = nextRelated;
7527
+ changes.push(`related ${list(currentRelated)} \u2192 ${list(nextRelated)}`);
7528
+ }
7437
7529
  if (body !== void 0) {
7438
7530
  changes.push(body.trim() ? "description" : "description cleared");
7439
7531
  }
7440
7532
  if (changes.length === 0) {
7441
7533
  if (raw.json) {
7442
- data(
7443
- JSON.stringify(
7444
- {
7445
- slug: existing.slug,
7446
- status: existing.frontmatter.status,
7447
- frontmatter: existing.frontmatter,
7448
- body: existing.body,
7449
- comments: existing.comments
7450
- },
7451
- null,
7452
- 2
7453
- )
7454
- );
7534
+ printTask(existing);
7455
7535
  return;
7456
7536
  }
7457
7537
  chrome(`No changes for ${slug}: every field already holds that value.`);
@@ -7465,19 +7545,7 @@ function createCli(opts) {
7465
7545
  body
7466
7546
  );
7467
7547
  if (raw.json) {
7468
- data(
7469
- JSON.stringify(
7470
- {
7471
- slug: edited.slug,
7472
- status: edited.frontmatter.status,
7473
- frontmatter: edited.frontmatter,
7474
- body: edited.body,
7475
- comments: edited.comments
7476
- },
7477
- null,
7478
- 2
7479
- )
7480
- );
7548
+ printTask(edited);
7481
7549
  return;
7482
7550
  }
7483
7551
  chrome(`Updated ${edited.slug}: ${changes.join("; ")}`);
@@ -7486,7 +7554,7 @@ function createCli(opts) {
7486
7554
  }
7487
7555
  });
7488
7556
  const BODY_FILE_HELP = "\nPrefer --body-file for anything multi-line: the file is read as UTF-8 by\nShipBench, so the text never passes through shell quoting or encoding.\n";
7489
- const commentCommand = task.command("comment").description("Manage timestamped entries in the task Updates section").argument("[slug]", "Task slug").argument("[text]", "Update text").addOption(updateTextOption()).addOption(updateTextFileOption()).addHelpText("after", BODY_FILE_HELP);
7557
+ const commentCommand = task.command("comment").description("Manage timestamped entries in the task Updates section").argument("[slug]", "Task slug").argument("[text]", "Update text").addOption(updateTextOption()).addOption(updateTextFileOption()).option("--json", "Output the resulting task as JSON").addHelpText("after", BODY_FILE_HELP);
7490
7558
  commentCommand.action(async (slug, text, raw) => {
7491
7559
  const resolved = await resolveUpdateText(commentCommand, text, raw);
7492
7560
  if (!slug || resolved === void 0) {
@@ -7496,11 +7564,15 @@ function createCli(opts) {
7496
7564
  }
7497
7565
  const config = await loadCliConfig();
7498
7566
  const updated = await addComment(adapter, config, slug, resolved);
7567
+ if (raw.json) {
7568
+ printTask(updated);
7569
+ return;
7570
+ }
7499
7571
  chrome(`Added update to ${updated.slug}`);
7500
7572
  });
7501
7573
  const commentEditCommand = commentCommand.command("edit <slug> <index> [text]").description(
7502
7574
  "Edit an Updates entry by zero-based index without changing its timestamp"
7503
- ).addOption(updateTextOption()).addOption(updateTextFileOption()).addHelpText("after", BODY_FILE_HELP);
7575
+ ).addOption(updateTextOption()).addOption(updateTextFileOption()).option("--json", "Output the resulting task as JSON").addHelpText("after", BODY_FILE_HELP);
7504
7576
  commentEditCommand.action(async (slug, index, text, raw) => {
7505
7577
  const resolved = await resolveUpdateText(commentEditCommand, text, raw);
7506
7578
  if (resolved === void 0) {
@@ -7518,15 +7590,26 @@ function createCli(opts) {
7518
7590
  parsedIndex,
7519
7591
  resolved
7520
7592
  );
7593
+ if (raw.json) {
7594
+ printTask(updated);
7595
+ return;
7596
+ }
7521
7597
  chrome(`Edited update ${parsedIndex} on ${updated.slug}`);
7522
7598
  });
7523
- commentCommand.command("delete <slug> <index>").description("Delete an Updates entry by zero-based index").action(async (slug, index) => {
7599
+ commentCommand.command("delete <slug> <index>").description("Delete an Updates entry by zero-based index").option("--json", "Output the resulting task as JSON").action(async (slug, index, raw) => {
7524
7600
  const config = await loadCliConfig();
7525
7601
  const parsedIndex = parseNonNegativeInteger(index);
7526
7602
  const updated = await deleteComment(adapter, config, slug, parsedIndex);
7603
+ if (raw.json) {
7604
+ printTask(updated);
7605
+ return;
7606
+ }
7527
7607
  chrome(`Deleted update ${parsedIndex} from ${updated.slug}`);
7528
7608
  });
7529
- const getTaskCommand = task.command("get <slug>").alias("show").description("Retrieve one task as JSON").option("--archived", "Retrieve the task from the archive instead");
7609
+ const getTaskCommand = task.command("get <slug>").alias("show").description("Retrieve one task as JSON").option("--archived", "Retrieve the task from the archive instead").option(
7610
+ "--json",
7611
+ "Accepted for consistency; the output is JSON either way"
7612
+ );
7530
7613
  getTaskCommand.action(async (slug, raw) => {
7531
7614
  const config = await loadCliConfig();
7532
7615
  const found = await getTask(adapter, config, slug, {
@@ -7554,11 +7637,7 @@ function createCli(opts) {
7554
7637
  data(
7555
7638
  JSON.stringify(
7556
7639
  {
7557
- slug: found.slug,
7558
- status: found.frontmatter.status,
7559
- frontmatter: found.frontmatter,
7560
- body: found.body,
7561
- comments: found.comments,
7640
+ ...taskJson(found),
7562
7641
  ...found.unreadableUpdates ? { unreadable_updates: found.unreadableUpdates } : {}
7563
7642
  },
7564
7643
  null,
@@ -7566,12 +7645,12 @@ function createCli(opts) {
7566
7645
  )
7567
7646
  );
7568
7647
  });
7569
- const flagCommand = task.command("flag <slug> [reason]").description("Flag a task for attention, with an optional one-line reason").addHelpText(
7648
+ const flagCommand = task.command("flag <slug> [reason]").description("Flag a task for attention, with an optional one-line reason").option("--json", "Output the resulting task as JSON").addHelpText(
7570
7649
  "after",
7571
7650
  "\nWhat a flag means is the project's call. A flag never moves the task, and\nnothing clears it for you: run `shipbench task unflag <slug>` once it no\nlonger applies. Flagging a flagged task replaces its reason.\n"
7572
7651
  );
7573
7652
  flagCommand.action(
7574
- async (slug, reason) => {
7653
+ async (slug, reason, raw) => {
7575
7654
  const config = await loadCliConfig();
7576
7655
  const existing = await requireLiveTask(
7577
7656
  flagCommand,
@@ -7583,20 +7662,28 @@ function createCli(opts) {
7583
7662
  const flag = reason == null ? true : reason;
7584
7663
  const before = taskFlag(existing);
7585
7664
  if (before && before.reason === (flag === true ? null : flag.trim())) {
7665
+ if (raw.json) {
7666
+ printTask(existing);
7667
+ return;
7668
+ }
7586
7669
  chrome(`No changes for ${slug}: it already carries that flag.`);
7587
7670
  return;
7588
7671
  }
7589
7672
  const { task: flagged } = await updateTask(adapter, config, slug, {
7590
7673
  flag
7591
7674
  });
7675
+ if (raw.json) {
7676
+ printTask(flagged);
7677
+ return;
7678
+ }
7592
7679
  const after = taskFlag(flagged);
7593
7680
  chrome(
7594
7681
  after?.reason ? `Flagged ${flagged.slug}: ${after.reason}` : `Flagged ${flagged.slug}`
7595
7682
  );
7596
7683
  }
7597
7684
  );
7598
- const unflagCommand = task.command("unflag <slug>").description("Clear a task's flag");
7599
- unflagCommand.action(async (slug) => {
7685
+ const unflagCommand = task.command("unflag <slug>").description("Clear a task's flag").option("--json", "Output the resulting task as JSON");
7686
+ unflagCommand.action(async (slug, raw) => {
7600
7687
  const config = await loadCliConfig();
7601
7688
  const existing = await requireLiveTask(
7602
7689
  unflagCommand,
@@ -7606,10 +7693,20 @@ function createCli(opts) {
7606
7693
  );
7607
7694
  if (!existing) return;
7608
7695
  if (existing.frontmatter.flag === void 0) {
7696
+ if (raw.json) {
7697
+ printTask(existing);
7698
+ return;
7699
+ }
7609
7700
  chrome(`No changes for ${slug}: it is not flagged.`);
7610
7701
  return;
7611
7702
  }
7612
- await updateTask(adapter, config, slug, { flag: void 0 });
7703
+ const { task: unflagged } = await updateTask(adapter, config, slug, {
7704
+ flag: void 0
7705
+ });
7706
+ if (raw.json) {
7707
+ printTask(unflagged);
7708
+ return;
7709
+ }
7613
7710
  chrome(`Unflagged ${slug}`);
7614
7711
  });
7615
7712
  const moveCommand = task.command("move <slug>").description("Move a task to another column and/or another position").option(
@@ -7641,7 +7738,7 @@ function createCli(opts) {
7641
7738
  ).conflicts(["top", "bottom", "before", "position"])
7642
7739
  ).addOption(
7643
7740
  new Option("--position <n>", "Place at this 0-based index (-1 appends)").argParser(parseLayoutPosition).conflicts(["top", "bottom", "before", "after"])
7644
- ).addHelpText(
7741
+ ).option("--json", "Output the resulting task as JSON").addHelpText(
7645
7742
  "after",
7646
7743
  "\nPlacement flags are mutually exclusive and cannot target the done column,\nwhich is always ordered by last update. Reorder only when asked to.\n"
7647
7744
  ).action(async (slug, raw) => {
@@ -7655,6 +7752,10 @@ function createCli(opts) {
7655
7752
  return;
7656
7753
  }
7657
7754
  const moved2 = await moveTask(adapter, config, slug, raw.to);
7755
+ if (raw.json) {
7756
+ printTask(moved2);
7757
+ return;
7758
+ }
7658
7759
  chrome(`Moved ${moved2.slug} \u2192 ${moved2.frontmatter.status}`);
7659
7760
  return;
7660
7761
  }
@@ -7726,6 +7827,10 @@ function createCli(opts) {
7726
7827
  toStatus,
7727
7828
  position
7728
7829
  );
7830
+ if (raw.json) {
7831
+ printTask(moved);
7832
+ return;
7833
+ }
7729
7834
  const placedAt = position < 0 || position > column.length ? column.length : position;
7730
7835
  chrome(
7731
7836
  fromStatus === toStatus ? `Reordered ${moved.slug} in ${toStatus} \u2192 position ${placedAt} of ${column.length + 1}` : `Moved ${moved.slug} \u2192 ${toStatus} at position ${placedAt} of ${column.length + 1}`
@@ -7752,6 +7857,10 @@ function createCli(opts) {
7752
7857
  "--tag <tag>",
7753
7858
  "Filter by tag (comma-separated or repeatable with AND semantics)",
7754
7859
  accumulateCommaList
7860
+ ).option(
7861
+ "--exclude-tag <tag>",
7862
+ "Leave out tasks carrying any of these tags (comma-separated or repeatable)",
7863
+ accumulateCommaList
7755
7864
  ).option("--flagged", "Only tasks with a flag set").addOption(
7756
7865
  new Option(
7757
7866
  "--available",
@@ -7803,10 +7912,23 @@ function createCli(opts) {
7803
7912
  })
7804
7913
  ).slice(0, raw.limit);
7805
7914
  if (raw.json) {
7915
+ const relatedOf = createRelatedIndex(
7916
+ raw.archived ? {
7917
+ tasks: (await listTasks(adapter, config)).tasks,
7918
+ archivedTasks: result.tasks,
7919
+ archivedSlugs: taskFileSlugs(result)
7920
+ } : {
7921
+ tasks: result.tasks,
7922
+ archivedTasks: archived?.tasks,
7923
+ archivedSlugs: result.archivedSlugs
7924
+ }
7925
+ );
7806
7926
  const tasks = filtered.map((t) => ({
7807
7927
  slug: t.slug,
7808
7928
  ...t.frontmatter,
7809
7929
  depends_on: t.frontmatter.depends_on ?? [],
7930
+ related: t.frontmatter.related ?? [],
7931
+ related_tasks: relatedOf(t),
7810
7932
  ...boardOrder ? { position: boardOrder.positions.get(t.slug) } : {},
7811
7933
  ...raw.includeBody ? {
7812
7934
  body: t.body,
@@ -7858,6 +7980,10 @@ function createCli(opts) {
7858
7980
  "--tag <tag>",
7859
7981
  "Filter by tag (comma-separated or repeatable with AND semantics)",
7860
7982
  accumulateCommaList
7983
+ ).option(
7984
+ "--exclude-tag <tag>",
7985
+ "Leave out tasks carrying any of these tags (comma-separated or repeatable)",
7986
+ accumulateCommaList
7861
7987
  ).option("--flagged", "Only tasks with a flag set").addOption(
7862
7988
  new Option(
7863
7989
  "--available",
@@ -7941,6 +8067,13 @@ function createCli(opts) {
7941
8067
  ...searchArchive ? archivedResult?.unreadable ?? [] : []
7942
8068
  ];
7943
8069
  if (raw.json) {
8070
+ const relatedLive = liveResult ?? await listTasks(adapter, config);
8071
+ const relatedArchive = archivedResult ?? await listArchivedTasks(adapter, config);
8072
+ const relatedOf = createRelatedIndex({
8073
+ tasks: relatedLive.tasks,
8074
+ archivedTasks: relatedArchive.tasks,
8075
+ archivedSlugs: taskFileSlugs(relatedArchive)
8076
+ });
7944
8077
  const payloadMatches = matches.map((match) => {
7945
8078
  const source = candidatesBySlug.get(match.slug);
7946
8079
  return {
@@ -7949,6 +8082,7 @@ function createCli(opts) {
7949
8082
  status: match.status,
7950
8083
  location: locationOf(match.slug),
7951
8084
  matched_fields: match.matched_fields,
8085
+ related_tasks: source ? relatedOf(source) : [],
7952
8086
  ...source && isTaskFlagged(source) ? { flag: source.frontmatter.flag } : {},
7953
8087
  ...match.snippet !== void 0 ? { snippet: match.snippet } : {},
7954
8088
  ...match.update_matches ? { update_matches: match.update_matches } : {},
@@ -8011,10 +8145,50 @@ function createCli(opts) {
8011
8145
  }
8012
8146
  }
8013
8147
  });
8014
- task.command("graph").description("Show the task dependency graph").option("--archived", "Include archived tasks as graph nodes").option("--json", "Emit machine-readable JSON").action(async (raw) => {
8148
+ const graphCommand = task.command("graph [slug]").description("Show the task dependency graph, or the chain around one task").option("--archived", "Include archived tasks as graph nodes").option("--blockers", "With a slug: walk only what the task depends on").option("--dependents", "With a slug: walk only what depends on the task").option(
8149
+ "--depth <n>",
8150
+ "With a slug: levels to walk (1 lists direct neighbors only)",
8151
+ parsePositiveInteger
8152
+ ).option("--json", "Emit machine-readable JSON");
8153
+ graphCommand.action(async (slug, raw) => {
8015
8154
  const config = await loadCliConfig();
8155
+ if (slug === void 0) {
8156
+ if (raw.blockers || raw.dependents || raw.depth !== void 0) {
8157
+ graphCommand.error(
8158
+ "--blockers, --dependents, and --depth need a task slug."
8159
+ );
8160
+ return;
8161
+ }
8162
+ }
8016
8163
  const liveResult = await listTasks(adapter, config);
8017
8164
  const archivedResult = raw.archived ? await listArchivedTasks(adapter, config) : void 0;
8165
+ if (slug !== void 0) {
8166
+ const query = queryTaskDependencies(slug, liveResult.tasks, config, {
8167
+ direction: raw.blockers && !raw.dependents ? "blockers" : raw.dependents && !raw.blockers ? "dependents" : "both",
8168
+ depth: raw.depth,
8169
+ archivedTasks: archivedResult?.tasks,
8170
+ // Readiness matches `task list`: an archived dependency is
8171
+ // satisfied whether or not --archived walks into it.
8172
+ archivedSlugs: archivedResult ? taskFileSlugs(archivedResult) : liveResult.archivedSlugs,
8173
+ unreadableSlugs: liveResult.unreadable.map((file) => file.slug)
8174
+ });
8175
+ if (!query) {
8176
+ if (!raw.archived && liveResult.archivedSlugs?.includes(slug)) {
8177
+ graphCommand.error(
8178
+ `Task '${slug}' is archived. Pass --archived to query it.`
8179
+ );
8180
+ } else {
8181
+ graphCommand.error(`Task '${slug}' not found.`);
8182
+ }
8183
+ return;
8184
+ }
8185
+ if (raw.json || !isInteractive) {
8186
+ data(JSON.stringify(query, null, 2));
8187
+ return;
8188
+ }
8189
+ for (const line of formatTaskDependencyQuery(query)) data(line);
8190
+ return;
8191
+ }
8018
8192
  const graph = buildTaskDependencyGraph(liveResult.tasks, {
8019
8193
  archivedTasks: archivedResult?.tasks,
8020
8194
  archivedSlugs: archivedResult ? taskFileSlugs(archivedResult) : void 0
@@ -8032,6 +8206,9 @@ function createCli(opts) {
8032
8206
  ).option(
8033
8207
  "--force",
8034
8208
  "Archive a non-done task even when live tasks depend on it"
8209
+ ).option(
8210
+ "--json",
8211
+ "Output the archived task as JSON (an array of them with --done)"
8035
8212
  ).addHelpText(
8036
8213
  "after",
8037
8214
  "\nA non-done task with live dependents is blocked unless --force is used.\n"
@@ -8055,15 +8232,26 @@ function createCli(opts) {
8055
8232
  );
8056
8233
  const keep = raw.keep === void 0 && config.done_display.max <= 0 ? doneTasks.length : raw.keep ?? config.done_display.max;
8057
8234
  const candidates = doneTasks.slice(keep);
8235
+ const archived = [];
8058
8236
  for (const candidate of candidates) {
8059
- await archiveTask(adapter, config, candidate.slug);
8060
- chrome(`Archived task: ${candidate.slug}`);
8237
+ archived.push(await archiveTask(adapter, config, candidate.slug));
8238
+ if (!raw.json) chrome(`Archived task: ${candidate.slug}`);
8239
+ }
8240
+ if (raw.json) {
8241
+ data(JSON.stringify(archived.map(taskJson), null, 2));
8242
+ return;
8061
8243
  }
8062
8244
  if (candidates.length === 0) chrome("No done tasks archived.");
8063
8245
  return;
8064
8246
  }
8065
8247
  try {
8066
- await archiveTask(adapter, config, slug, { force: raw.force });
8248
+ const archived = await archiveTask(adapter, config, slug, {
8249
+ force: raw.force
8250
+ });
8251
+ if (raw.json) {
8252
+ printTask(archived);
8253
+ return;
8254
+ }
8067
8255
  chrome(`Archived task: ${slug}`);
8068
8256
  } catch (error) {
8069
8257
  if (error instanceof ArchiveBlockedError) {
@@ -8074,18 +8262,27 @@ function createCli(opts) {
8074
8262
  throw error;
8075
8263
  }
8076
8264
  });
8077
- task.command("unarchive <slug>").description("Restore an archived task").action(async (slug) => {
8265
+ task.command("unarchive <slug>").description("Restore an archived task").option("--json", "Output the resulting task as JSON").action(async (slug, raw) => {
8078
8266
  const config = await loadCliConfig();
8079
- await unarchiveTask(adapter, config, slug);
8267
+ const restored = await unarchiveTask(adapter, config, slug);
8268
+ if (raw.json) {
8269
+ printTask(restored);
8270
+ return;
8271
+ }
8080
8272
  chrome(`Unarchived task: ${slug}`);
8081
8273
  });
8082
- task.command("delete <slug>").description("Delete a task").action(async (slug) => {
8274
+ task.command("delete <slug>").description("Delete a task").option("--json", "Output the deleted slug as JSON").action(async (slug, raw) => {
8083
8275
  const config = await loadCliConfig();
8084
8276
  await deleteTask(adapter, config, slug);
8277
+ if (raw.json) {
8278
+ data(JSON.stringify({ slug, deleted: true }, null, 2));
8279
+ return;
8280
+ }
8085
8281
  chrome(`Deleted task: ${slug}`);
8086
8282
  });
8087
8283
  const board = program.command("board").description("Open the board UI");
8088
8284
  board.command("web", { isDefault: true }).description("Open the board UI in a browser (the default for `board`)").option("--port <number>", "Port to listen on", parsePort, 4321).option("--no-open", "Do not open the browser automatically").action(async (raw) => {
8285
+ await requireBoard();
8089
8286
  const server = await startBoardServer({
8090
8287
  adapter,
8091
8288
  cwd,
@@ -8117,16 +8314,22 @@ function createCli(opts) {
8117
8314
  "--tag <tag>",
8118
8315
  "Filter by tag (comma-separated or repeatable with AND semantics)",
8119
8316
  accumulateCommaList
8317
+ ).option(
8318
+ "--exclude-tag <tag>",
8319
+ "Leave out tasks carrying any of these tags (comma-separated or repeatable)",
8320
+ accumulateCommaList
8120
8321
  ).option("--flagged", "Only tasks with a flag set").addHelpText(
8121
8322
  "after",
8122
8323
  "\nTakes no keyboard input: Ctrl-C exits. Never writes to the board.\nWith stdout redirected it prints one 80x24 frame and exits.\n"
8123
8324
  ).action(async (raw) => {
8325
+ await requireBoard();
8124
8326
  await runTui({
8125
8327
  adapter,
8126
8328
  cwd,
8127
8329
  filters: {
8128
8330
  statuses: raw.status,
8129
8331
  tags: raw.tag,
8332
+ excludedTags: raw.excludeTag,
8130
8333
  assignee: raw.assignee,
8131
8334
  priority: raw.priority,
8132
8335
  flagged: raw.flagged
@@ -8138,14 +8341,16 @@ function createCli(opts) {
8138
8341
  }
8139
8342
 
8140
8343
  // src/processCli.ts
8141
- function projectDirectoryOption(argv) {
8344
+ function rootArguments(argv) {
8142
8345
  let directory;
8143
8346
  for (let index = 2; index < argv.length; index += 1) {
8144
8347
  const argument = argv[index];
8145
8348
  if (argument === "--") break;
8146
8349
  if (argument === "-C") {
8147
8350
  const value = argv[index + 1];
8148
- if (value === void 0 || value === "--") return directory;
8351
+ if (value === void 0 || value === "--") {
8352
+ return { directory, command: void 0 };
8353
+ }
8149
8354
  directory = value;
8150
8355
  index += 1;
8151
8356
  continue;
@@ -8154,14 +8359,16 @@ function projectDirectoryOption(argv) {
8154
8359
  directory = argument.slice(2);
8155
8360
  continue;
8156
8361
  }
8157
- if (!argument?.startsWith("-")) break;
8362
+ if (argument !== void 0 && !argument.startsWith("-")) {
8363
+ return { directory, command: argument };
8364
+ }
8158
8365
  }
8159
- return directory;
8366
+ return { directory, command: void 0 };
8160
8367
  }
8161
8368
  function resolveProjectDirectory(argv, shellCwd) {
8162
- const option = projectDirectoryOption(argv);
8369
+ const option = rootArguments(argv).directory;
8163
8370
  if (option === void 0) return shellCwd;
8164
- const directory = resolve3(shellCwd, option);
8371
+ const directory = resolve2(shellCwd, option);
8165
8372
  let stats;
8166
8373
  try {
8167
8374
  stats = statSync(directory);
@@ -8181,12 +8388,67 @@ function resolveProjectDirectory(argv, shellCwd) {
8181
8388
  }
8182
8389
  return directory;
8183
8390
  }
8391
+ var BOARD_DIRECTORY = ".shipbench";
8392
+ function isDirectory(path) {
8393
+ try {
8394
+ return statSync(path).isDirectory();
8395
+ } catch {
8396
+ return false;
8397
+ }
8398
+ }
8399
+ function findBoard(start) {
8400
+ let directory = start;
8401
+ for (; ; ) {
8402
+ if (isDirectory(join4(directory, BOARD_DIRECTORY))) {
8403
+ return existsSync(join4(directory, BOARD_DIRECTORY, "config.json")) ? { kind: "found", root: directory } : { kind: "incomplete", root: directory };
8404
+ }
8405
+ if (existsSync(join4(directory, ".git"))) {
8406
+ return { kind: "none", boundary: directory };
8407
+ }
8408
+ const parent = dirname3(directory);
8409
+ if (parent === directory) return { kind: "none", boundary: null };
8410
+ directory = parent;
8411
+ }
8412
+ }
8413
+ function missingMessage(start, search) {
8414
+ if (search.kind !== "none") return formatMissingBoard(`in ${search.root}`);
8415
+ if (search.boundary === start) return formatMissingBoard(`in ${start}`);
8416
+ if (search.boundary === null) {
8417
+ return formatMissingBoard(`in ${start} or any directory above it`);
8418
+ }
8419
+ return formatMissingBoard(`in ${start} or above it up to ${search.boundary}`);
8420
+ }
8421
+ function resolveBoard(argv, shellCwd) {
8422
+ const start = resolveProjectDirectory(argv, shellCwd);
8423
+ const { directory: option, command } = rootArguments(argv);
8424
+ const exact = {
8425
+ directory: start,
8426
+ start,
8427
+ missingMessage: formatMissingBoard(`in ${start}`)
8428
+ };
8429
+ if (command === "init") {
8430
+ if (existsSync(join4(start, ".git"))) return exact;
8431
+ const parent = dirname3(start);
8432
+ const above = parent === start ? void 0 : findBoard(parent);
8433
+ return above?.kind === "found" ? { ...exact, ancestorBoard: above.root } : exact;
8434
+ }
8435
+ if (option !== void 0) return exact;
8436
+ const search = findBoard(start);
8437
+ return {
8438
+ directory: search.kind === "none" ? start : search.root,
8439
+ start,
8440
+ missingMessage: missingMessage(start, search)
8441
+ };
8442
+ }
8184
8443
  function createProcessCli(opts) {
8185
- const cwd = resolveProjectDirectory(opts.argv, opts.shellCwd);
8444
+ const board = resolveBoard(opts.argv, opts.shellCwd);
8186
8445
  return createCli({
8187
- adapter: new FsAdapter(cwd),
8188
- defaultProjectName: basename(cwd),
8189
- cwd,
8446
+ adapter: new FsAdapter(board.directory),
8447
+ defaultProjectName: basename(board.start),
8448
+ cwd: board.directory,
8449
+ searchedFrom: board.start,
8450
+ missingBoardMessage: board.missingMessage,
8451
+ ancestorBoard: board.ancestorBoard,
8190
8452
  out: opts.out,
8191
8453
  err: opts.err,
8192
8454
  exitOverride: opts.exitOverride