shipbench 0.4.0 → 0.6.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 +12 -7
  2. package/dist/index.js +700 -149
  3. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -3340,11 +3340,11 @@ var require_excerpt = __commonJS({
3340
3340
  if (typeof opts.excerpt === "function") {
3341
3341
  return opts.excerpt(file, opts);
3342
3342
  }
3343
- const sep2 = file.data.excerpt_separator || opts.excerpt_separator;
3344
- if (sep2 == null && (opts.excerpt === false || opts.excerpt == null)) {
3343
+ const sep3 = file.data.excerpt_separator || opts.excerpt_separator;
3344
+ if (sep3 == null && (opts.excerpt === false || opts.excerpt == null)) {
3345
3345
  return file;
3346
3346
  }
3347
- const delimiter = typeof opts.excerpt === "string" ? opts.excerpt : sep2 || opts.delimiters[0];
3347
+ const delimiter = typeof opts.excerpt === "string" ? opts.excerpt : sep3 || opts.delimiters[0];
3348
3348
  const idx = file.content.indexOf(delimiter);
3349
3349
  if (idx !== -1) {
3350
3350
  file.excerpt = file.content.slice(0, idx);
@@ -3528,14 +3528,23 @@ import { resolve } from "path";
3528
3528
 
3529
3529
  // ../../packages/core/src/adapters/fs.ts
3530
3530
  import { mkdir, readdir, readFile, unlink, writeFile } from "fs/promises";
3531
- import { dirname, join } from "path";
3531
+ import { dirname, isAbsolute, join, relative, sep } from "path";
3532
3532
  var FsAdapter = class {
3533
3533
  constructor(rootDir) {
3534
3534
  this.rootDir = rootDir;
3535
3535
  }
3536
3536
  rootDir;
3537
+ // Refuse any path that lands outside the root, whatever the caller: core
3538
+ // validates slugs, but nothing else guarantees a path stays in the repo.
3537
3539
  resolve(path) {
3538
- return join(this.rootDir, path);
3540
+ const fullPath = join(this.rootDir, path);
3541
+ const fromRoot = relative(this.rootDir, fullPath);
3542
+ if (fromRoot === ".." || fromRoot.startsWith(`..${sep}`) || isAbsolute(fromRoot)) {
3543
+ throw new Error(
3544
+ `Invalid path ${JSON.stringify(path)}: it resolves outside the project root.`
3545
+ );
3546
+ }
3547
+ return fullPath;
3539
3548
  }
3540
3549
  async readFile(path) {
3541
3550
  return readFile(this.resolve(path), "utf-8");
@@ -3557,8 +3566,9 @@ var FsAdapter = class {
3557
3566
  await unlink(this.resolve(path));
3558
3567
  }
3559
3568
  async listFiles(directory) {
3569
+ const fullPath = this.resolve(directory);
3560
3570
  try {
3561
- return await readdir(this.resolve(directory));
3571
+ return await readdir(fullPath);
3562
3572
  } catch {
3563
3573
  return [];
3564
3574
  }
@@ -3691,14 +3701,17 @@ function compareTaskReadiness(a, b, config) {
3691
3701
  return a.slug.localeCompare(b.slug);
3692
3702
  }
3693
3703
  function listTasksByAvailability(tasks, config, mode, options2 = {}) {
3694
- const status = options2.status ?? config.default_column;
3704
+ const statusOption = options2.status ?? config.default_column;
3705
+ const statuses = new Set(
3706
+ typeof statusOption === "string" ? [statusOption] : statusOption
3707
+ );
3695
3708
  const dependencyIndex = createTaskDependencyIndex(
3696
3709
  tasks,
3697
3710
  options2.archivedTasks,
3698
3711
  options2.archivedSlugs
3699
3712
  );
3700
3713
  return tasks.filter((task) => {
3701
- if (task.frontmatter.status !== status) return false;
3714
+ if (!statuses.has(task.frontmatter.status)) return false;
3702
3715
  const available = taskDependenciesAreSatisfied(
3703
3716
  task,
3704
3717
  dependencyIndex,
@@ -4021,6 +4034,13 @@ function resolveSlugCollision(slug, existingSlugs) {
4021
4034
  }
4022
4035
  return `${slug}-${counter}`;
4023
4036
  }
4037
+ function assertTaskSlug(slug) {
4038
+ if (slug === "" || slug === "." || slug === ".." || /[/\\\0]/.test(slug)) {
4039
+ throw new Error(
4040
+ `Invalid task slug ${JSON.stringify(slug)}: a slug names one file in the tasks directory, so it cannot be empty, "." or "..", or contain "/", "\\", or a NUL character.`
4041
+ );
4042
+ }
4043
+ }
4024
4044
 
4025
4045
  // ../../packages/core/src/tasks.ts
4026
4046
  var TASKS_DIR = ".shipbench/tasks";
@@ -4031,7 +4051,10 @@ var UPDATES_HEADING = "## Task Updates";
4031
4051
  var ISO_8601_TIMESTAMP = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
4032
4052
  var ATX_HEADING = /^(#{1,6})\s+(.+?)\s*$/;
4033
4053
  var ENTRY_HEADING_TEXT = /^\d{4}-\d{2}-\d{2}/;
4034
- var updatesParseWarnings = /* @__PURE__ */ new WeakMap();
4054
+ function taskPath(slug, directory = TASKS_DIR) {
4055
+ assertTaskSlug(slug);
4056
+ return `${directory}/${slug}.md`;
4057
+ }
4035
4058
  var ArchiveBlockedError = class extends Error {
4036
4059
  constructor(slug, dependentSlugs) {
4037
4060
  super(
@@ -4044,6 +4067,16 @@ var ArchiveBlockedError = class extends Error {
4044
4067
  slug;
4045
4068
  dependentSlugs;
4046
4069
  };
4070
+ var UnreadableTaskError = class extends Error {
4071
+ constructor(file) {
4072
+ super(
4073
+ `Cannot read task "${file.slug}": the frontmatter in ${file.path} does not parse. ${file.reason} Fix the file to restore the task.`
4074
+ );
4075
+ this.file = file;
4076
+ this.name = "UnreadableTaskError";
4077
+ }
4078
+ file;
4079
+ };
4047
4080
  var KNOWN_FRONTMATTER_FIELDS = /* @__PURE__ */ new Set([
4048
4081
  "title",
4049
4082
  "status",
@@ -4067,12 +4100,9 @@ function updateFence(line, current) {
4067
4100
  return null;
4068
4101
  return current;
4069
4102
  }
4070
- function malformedUpdates(body, detail) {
4071
- return {
4072
- body: body.trim(),
4073
- comments: [],
4074
- warning: `Malformed Updates section: ${detail} Raw Markdown was preserved in the task body.`
4075
- };
4103
+ function quoteLine(line) {
4104
+ const text = line.trim();
4105
+ return text.length > 60 ? `"${text.slice(0, 57)}..."` : `"${text}"`;
4076
4106
  }
4077
4107
  function parseTaskBody(rawBody) {
4078
4108
  const body = rawBody.trim();
@@ -4087,18 +4117,24 @@ function parseTaskBody(rawBody) {
4087
4117
  fence = updateFence(line, fence);
4088
4118
  }
4089
4119
  if (updatesHeadings.length === 0) return { body, comments: [] };
4090
- if (updatesHeadings.length > 1) {
4091
- return malformedUpdates(
4092
- body,
4093
- `found more than one "${UPDATES_HEADING}" heading.`
4094
- );
4095
- }
4096
4120
  const updatesIndex = updatesHeadings[0];
4097
4121
  const description = lines.slice(0, updatesIndex).join("\n").trim();
4122
+ const unreadable = (reason) => ({
4123
+ body: description,
4124
+ comments: [],
4125
+ unreadableUpdates: {
4126
+ text: lines.slice(updatesIndex).join("\n").trim(),
4127
+ reason
4128
+ }
4129
+ });
4130
+ if (updatesHeadings.length > 1) {
4131
+ return unreadable(`found more than one "${UPDATES_HEADING}" heading.`);
4132
+ }
4098
4133
  const updateLines = lines.slice(updatesIndex + 1);
4099
4134
  const comments = [];
4100
4135
  let timestamp = null;
4101
4136
  let textLines = [];
4137
+ let unclosedFenceLine = null;
4102
4138
  fence = null;
4103
4139
  const finishComment = () => {
4104
4140
  if (timestamp === null) return null;
@@ -4114,18 +4150,16 @@ function parseTaskBody(rawBody) {
4114
4150
  const heading = line.match(ATX_HEADING);
4115
4151
  if (heading && ENTRY_HEADING_TEXT.test(heading[2])) {
4116
4152
  if (heading[1].length !== 3) {
4117
- return malformedUpdates(
4118
- body,
4119
- `expected each entry heading to use "### <ISO 8601 timestamp>".`
4153
+ return unreadable(
4154
+ `expected each entry heading to use "### <ISO 8601 timestamp>", saw ${quoteLine(line)}.`
4120
4155
  );
4121
4156
  }
4122
4157
  const previousError = finishComment();
4123
- if (previousError) return malformedUpdates(body, previousError);
4158
+ if (previousError) return unreadable(previousError);
4124
4159
  const nextTimestamp = heading[2];
4125
4160
  if (!ISO_8601_TIMESTAMP.test(nextTimestamp) || Number.isNaN(Date.parse(nextTimestamp))) {
4126
- return malformedUpdates(
4127
- body,
4128
- `"${nextTimestamp}" is not an ISO 8601 timestamp.`
4161
+ return unreadable(
4162
+ `"${nextTimestamp}" is not an ISO 8601 timestamp, in ${quoteLine(line)}.`
4129
4163
  );
4130
4164
  }
4131
4165
  timestamp = nextTimestamp;
@@ -4135,23 +4169,26 @@ function parseTaskBody(rawBody) {
4135
4169
  }
4136
4170
  if (timestamp === null) {
4137
4171
  if (line.trim()) {
4138
- return malformedUpdates(
4139
- body,
4140
- `expected "### <ISO 8601 timestamp>" before entry text.`
4172
+ return unreadable(
4173
+ `expected "### <ISO 8601 timestamp>" before entry text, saw ${quoteLine(line)}.`
4141
4174
  );
4142
4175
  }
4143
4176
  } else {
4144
4177
  textLines.push(line);
4145
4178
  }
4146
4179
  fence = updateFence(line, fence);
4180
+ if (fence) unclosedFenceLine ??= line;
4181
+ else unclosedFenceLine = null;
4147
4182
  }
4148
4183
  if (fence) {
4149
- return malformedUpdates(body, "an entry contains an unclosed code fence.");
4184
+ return unreadable(
4185
+ `an entry leaves the code fence opened by ${quoteLine(unclosedFenceLine ?? "")} unclosed.`
4186
+ );
4150
4187
  }
4151
4188
  const finalError = finishComment();
4152
- if (finalError) return malformedUpdates(body, finalError);
4189
+ if (finalError) return unreadable(finalError);
4153
4190
  if (comments.length === 0) {
4154
- return malformedUpdates(body, "the section contains no entries.");
4191
+ return unreadable("the section contains no entries.");
4155
4192
  }
4156
4193
  return { body: description, comments };
4157
4194
  }
@@ -4203,8 +4240,28 @@ function parseFrontmatter(fileContent) {
4203
4240
  throw error;
4204
4241
  }
4205
4242
  }
4206
- function parseTaskFile(slug, fileContent) {
4207
- const { data, content: bodyContent } = parseFrontmatter(fileContent);
4243
+ function frontmatterFailureReason(error) {
4244
+ const yaml2 = error;
4245
+ if (typeof yaml2.reason === "string" && typeof yaml2.mark?.line === "number") {
4246
+ const reason = yaml2.reason.charAt(0).toUpperCase() + yaml2.reason.slice(1);
4247
+ return `${reason} at line ${yaml2.mark.line + 1}.`;
4248
+ }
4249
+ return error instanceof Error ? error.message : String(error);
4250
+ }
4251
+ function parseTaskFile(slug, fileContent, path) {
4252
+ const unreadable = (reason) => new UnreadableTaskError({ slug, path, content: fileContent, reason });
4253
+ let parsed;
4254
+ try {
4255
+ parsed = parseFrontmatter(fileContent);
4256
+ } catch (error) {
4257
+ throw unreadable(frontmatterFailureReason(error));
4258
+ }
4259
+ const { data, content: bodyContent } = parsed;
4260
+ if (typeof data !== "object" || data === null || Array.isArray(data)) {
4261
+ throw unreadable(
4262
+ "The frontmatter is not a set of `key: value` fields, so it has no title or status."
4263
+ );
4264
+ }
4208
4265
  const parsedBody = parseTaskBody(bodyContent);
4209
4266
  const frontmatter = {
4210
4267
  ...data,
@@ -4217,8 +4274,8 @@ function parseTaskFile(slug, fileContent) {
4217
4274
  body: parsedBody.body,
4218
4275
  comments: parsedBody.comments
4219
4276
  };
4220
- if (parsedBody.warning) {
4221
- updatesParseWarnings.set(task, parsedBody.warning);
4277
+ if (parsedBody.unreadableUpdates) {
4278
+ task.unreadableUpdates = parsedBody.unreadableUpdates;
4222
4279
  }
4223
4280
  return task;
4224
4281
  }
@@ -4232,7 +4289,9 @@ function stripUndefined(obj) {
4232
4289
  function serializeTask(task) {
4233
4290
  const sections = [];
4234
4291
  if (task.body.trim()) sections.push(task.body.trim());
4235
- if ((task.comments ?? []).length > 0) {
4292
+ if (task.unreadableUpdates) {
4293
+ sections.push(task.unreadableUpdates.text.trim());
4294
+ } else if ((task.comments ?? []).length > 0) {
4236
4295
  const entries = task.comments.map((comment) => `### ${comment.timestamp}
4237
4296
  ${comment.text.trim()}`).join("\n\n");
4238
4297
  sections.push(`${UPDATES_HEADING}
@@ -4287,16 +4346,20 @@ async function assertValidDependsOn(adapter, config, slug, dependsOn) {
4287
4346
  }
4288
4347
  }
4289
4348
  }
4349
+ function unreadableUpdatesWarning(task) {
4350
+ if (!task.unreadableUpdates) return void 0;
4351
+ return {
4352
+ slug: task.slug,
4353
+ field: "updates",
4354
+ message: `Malformed Updates section: ${task.unreadableUpdates.reason} The section is preserved verbatim in the file and is not part of the description.`
4355
+ };
4356
+ }
4290
4357
  function validateTask(task, config, knownSlugs) {
4291
4358
  const warnings = [];
4292
4359
  const validStatuses = new Set(config.columns.map((c) => c.id));
4293
- const updatesWarning = updatesParseWarnings.get(task);
4360
+ const updatesWarning = unreadableUpdatesWarning(task);
4294
4361
  if (updatesWarning) {
4295
- warnings.push({
4296
- slug: task.slug,
4297
- field: "updates",
4298
- message: updatesWarning
4299
- });
4362
+ warnings.push(updatesWarning);
4300
4363
  }
4301
4364
  if (!validStatuses.has(task.frontmatter.status)) {
4302
4365
  warnings.push({
@@ -4345,22 +4408,24 @@ async function listTasksInDirectory(adapter, config, directory, additionalKnownS
4345
4408
  const files = await adapter.listFiles(directory);
4346
4409
  const mdFiles = files.filter((f) => f.endsWith(".md"));
4347
4410
  if (mdFiles.length === 0) {
4348
- return { tasks: [], warnings: [] };
4411
+ return { tasks: [], warnings: [], unreadable: [] };
4349
4412
  }
4350
4413
  const paths = mdFiles.map((f) => `${directory}/${f}`);
4351
4414
  const contents = await adapter.readFiles(paths);
4352
4415
  const tasks = [];
4353
4416
  const warnings = [];
4417
+ const unreadable = [];
4354
4418
  for (const [path, content] of contents) {
4355
4419
  const slug = path.replace(`${directory}/`, "").replace(/\.md$/, "");
4356
4420
  try {
4357
- tasks.push(parseTaskFile(slug, content));
4421
+ tasks.push(parseTaskFile(slug, content, path));
4358
4422
  } catch (error) {
4359
- const detail = error instanceof Error ? error.message : String(error);
4423
+ if (!(error instanceof UnreadableTaskError)) throw error;
4424
+ unreadable.push(error.file);
4360
4425
  warnings.push({
4361
4426
  slug,
4362
4427
  field: "frontmatter",
4363
- message: `Could not parse frontmatter in "${path}": ${detail}`
4428
+ message: `Could not parse frontmatter in "${path}": ${error.file.reason}`
4364
4429
  });
4365
4430
  }
4366
4431
  }
@@ -4371,7 +4436,7 @@ async function listTasksInDirectory(adapter, config, directory, additionalKnownS
4371
4436
  for (const task of tasks) {
4372
4437
  warnings.push(...validateTask(task, config, knownSlugs));
4373
4438
  }
4374
- return { tasks, warnings };
4439
+ return { tasks, warnings, unreadable };
4375
4440
  }
4376
4441
  async function listTasks(adapter, config, options2 = {}) {
4377
4442
  const archivedSlugs = Promise.all([
@@ -4386,8 +4451,9 @@ async function listTasks(adapter, config, options2 = {}) {
4386
4451
  async function getTask(adapter, config, slug, options2 = {}) {
4387
4452
  void config;
4388
4453
  const directory = options2.archived ? ARCHIVE_DIR : TASKS_DIR;
4389
- const content = await adapter.readFileIfExists(`${directory}/${slug}.md`);
4390
- return content === null ? null : parseTaskFile(slug, content);
4454
+ const path = taskPath(slug, directory);
4455
+ const content = await adapter.readFileIfExists(path);
4456
+ return content === null ? null : parseTaskFile(slug, content, path);
4391
4457
  }
4392
4458
  async function listArchivedTasks(adapter, config) {
4393
4459
  const liveFiles = await adapter.listFiles(TASKS_DIR);
@@ -4440,7 +4506,7 @@ async function createTask(adapter, config, title, fields, body) {
4440
4506
  body: body ?? "",
4441
4507
  comments: []
4442
4508
  };
4443
- await adapter.writeFile(`${TASKS_DIR}/${slug}.md`, serializeTask(task));
4509
+ await adapter.writeFile(taskPath(slug), serializeTask(task));
4444
4510
  const currentLayout = config.layout ?? {};
4445
4511
  const columnOrder = currentLayout[status] ?? [];
4446
4512
  const nextLayout = status === config.done_column ? currentLayout : {
@@ -4452,11 +4518,16 @@ async function createTask(adapter, config, title, fields, body) {
4452
4518
  }
4453
4519
  async function updateTask(adapter, config, slug, fields, body) {
4454
4520
  if (body !== void 0) assertBodyWithoutUpdatesMarker(body);
4455
- const path = `${TASKS_DIR}/${slug}.md`;
4521
+ const path = taskPath(slug);
4456
4522
  const content = await adapter.readFile(path);
4457
- const task = parseTaskFile(slug, content);
4523
+ const task = parseTaskFile(slug, content, path);
4458
4524
  if (fields.status) assertValidStatus(fields.status, config);
4459
4525
  if (fields.priority) assertValidPriority(fields.priority, config);
4526
+ if ("title" in fields && !slugify(fields.title ?? "")) {
4527
+ throw new Error(
4528
+ "Task title must contain at least one slug-able character."
4529
+ );
4530
+ }
4460
4531
  const dependsOnProvided = "depends_on" in fields;
4461
4532
  const dependsOn = dependsOnProvided ? normalizeDependsOn(fields.depends_on) : void 0;
4462
4533
  if (dependsOnProvided) {
@@ -4494,10 +4565,10 @@ async function addComment(adapter, config, slug, text) {
4494
4565
  throw new Error("Task update text must not be blank.");
4495
4566
  }
4496
4567
  assertCommentTextIsParsable(normalizedText);
4497
- const path = `${TASKS_DIR}/${slug}.md`;
4568
+ const path = taskPath(slug);
4498
4569
  const content = await adapter.readFile(path);
4499
- const task = parseTaskFile(slug, content);
4500
- if (updatesParseWarnings.has(task)) {
4570
+ const task = parseTaskFile(slug, content, path);
4571
+ if (task.unreadableUpdates) {
4501
4572
  throw new Error(
4502
4573
  `Cannot add an update to "${slug}" because its Updates section is malformed. Fix the section in the task file first.`
4503
4574
  );
@@ -4509,7 +4580,7 @@ async function addComment(adapter, config, slug, text) {
4509
4580
  return task;
4510
4581
  }
4511
4582
  function assertMutableComments(task, slug, action) {
4512
- if (updatesParseWarnings.has(task)) {
4583
+ if (task.unreadableUpdates) {
4513
4584
  throw new Error(
4514
4585
  `Cannot ${action} an update on "${slug}" because its Updates section is malformed. Fix the section in the task file first.`
4515
4586
  );
@@ -4530,9 +4601,9 @@ async function editComment(adapter, config, slug, index, text) {
4530
4601
  throw new Error("Task update text must not be blank.");
4531
4602
  }
4532
4603
  assertCommentTextIsParsable(normalizedText);
4533
- const path = `${TASKS_DIR}/${slug}.md`;
4604
+ const path = taskPath(slug);
4534
4605
  const content = await adapter.readFile(path);
4535
- const task = parseTaskFile(slug, content);
4606
+ const task = parseTaskFile(slug, content, path);
4536
4607
  assertMutableComments(task, slug, "edit");
4537
4608
  assertCommentIndex(task, slug, index);
4538
4609
  const comment = task.comments[index];
@@ -4543,9 +4614,9 @@ async function editComment(adapter, config, slug, index, text) {
4543
4614
  }
4544
4615
  async function deleteComment(adapter, config, slug, index) {
4545
4616
  void config;
4546
- const path = `${TASKS_DIR}/${slug}.md`;
4617
+ const path = taskPath(slug);
4547
4618
  const content = await adapter.readFile(path);
4548
- const task = parseTaskFile(slug, content);
4619
+ const task = parseTaskFile(slug, content, path);
4549
4620
  assertMutableComments(task, slug, "delete");
4550
4621
  assertCommentIndex(task, slug, index);
4551
4622
  task.comments.splice(index, 1);
@@ -4586,9 +4657,9 @@ async function writeLayout(adapter, config, layout) {
4586
4657
  }
4587
4658
  async function reorderTask(adapter, config, slug, toStatus, position) {
4588
4659
  assertValidStatus(toStatus, config);
4589
- const path = `${TASKS_DIR}/${slug}.md`;
4660
+ const path = taskPath(slug);
4590
4661
  const content = await adapter.readFile(path);
4591
- const task = parseTaskFile(slug, content);
4662
+ const task = parseTaskFile(slug, content, path);
4592
4663
  if (task.frontmatter.status !== toStatus) {
4593
4664
  task.frontmatter = {
4594
4665
  ...task.frontmatter,
@@ -4620,15 +4691,15 @@ async function moveTask(adapter, config, slug, toStatus) {
4620
4691
  return task;
4621
4692
  }
4622
4693
  async function deleteTask(adapter, config, slug) {
4623
- await adapter.deleteFile(`${TASKS_DIR}/${slug}.md`);
4694
+ await adapter.deleteFile(taskPath(slug));
4624
4695
  const existingSlugs = await listExistingSlugs(adapter);
4625
4696
  const layout = layoutWithoutTask(config.layout ?? {}, slug, existingSlugs);
4626
4697
  await writeLayout(adapter, config, layout);
4627
4698
  }
4628
4699
  async function archiveTask(adapter, config, slug, options2) {
4629
- const livePath = `${TASKS_DIR}/${slug}.md`;
4700
+ const livePath = taskPath(slug);
4630
4701
  const content = await adapter.readFile(livePath);
4631
- const task = parseTaskFile(slug, content);
4702
+ const task = parseTaskFile(slug, content, livePath);
4632
4703
  if (task.frontmatter.status !== config.done_column && !options2?.force) {
4633
4704
  const { tasks } = await listTasks(adapter, config);
4634
4705
  const dependentSlugs = tasks.filter(
@@ -4638,7 +4709,7 @@ async function archiveTask(adapter, config, slug, options2) {
4638
4709
  throw new ArchiveBlockedError(slug, dependentSlugs);
4639
4710
  }
4640
4711
  }
4641
- await adapter.writeFile(`${ARCHIVE_DIR}/${slug}.md`, content);
4712
+ await adapter.writeFile(taskPath(slug, ARCHIVE_DIR), content);
4642
4713
  await adapter.deleteFile(livePath);
4643
4714
  const existingSlugs = await listExistingSlugs(adapter);
4644
4715
  const layout = layoutWithoutTask(config.layout ?? {}, slug, existingSlugs);
@@ -4652,10 +4723,10 @@ async function archiveTask(adapter, config, slug, options2) {
4652
4723
  return task;
4653
4724
  }
4654
4725
  async function unarchiveTask(adapter, config, slug) {
4655
- const archivedPath = `${ARCHIVE_DIR}/${slug}.md`;
4726
+ const archivedPath = taskPath(slug, ARCHIVE_DIR);
4656
4727
  const content = await adapter.readFile(archivedPath);
4657
- const task = parseTaskFile(slug, content);
4658
- await adapter.writeFile(`${TASKS_DIR}/${slug}.md`, content);
4728
+ const task = parseTaskFile(slug, content, archivedPath);
4729
+ await adapter.writeFile(taskPath(slug), content);
4659
4730
  await adapter.deleteFile(archivedPath);
4660
4731
  const status = task.frontmatter.status;
4661
4732
  if (status !== config.done_column) {
@@ -4962,6 +5033,8 @@ shipbench task list --available --json
4962
5033
 
4963
5034
  That ranking is not the board's order. \`--available\` sorts by priority and age and does not read manual placement, while a plain \`shipbench task list\` returns the order the columns are actually arranged in. The two can disagree \u2014 a task sitting first in its column may come back third here \u2014 and neither is the more correct answer. JSON carries both: the array is in ranked order, and each task's \`position\` is its board placement, computed before the ranking. Read whichever answers the question you have.
4964
5035
 
5036
+ JSON from \`task list\` and \`task search\` also carries an \`unreadable\` array, which is empty on a healthy board. Each entry is a task file whose frontmatter does not parse \u2014 a hand edit that repeated a key, say \u2014 so it is missing from \`tasks\`, whatever the filters. If the array is not empty, tell the user which files are listed and the \`reason\` for each. Do not guess what the task says, and do not recreate it under a new slug. Fix the frontmatter only when asked: which value is the right one is the user's call.
5037
+
4965
5038
  Narrow the candidate set without loading every description:
4966
5039
 
4967
5040
  \`\`\`bash
@@ -4969,7 +5042,9 @@ shipbench task list --available --tag backend --json
4969
5042
  shipbench task list --available --tag backend,auth --assignee agent --json
4970
5043
  \`\`\`
4971
5044
 
4972
- \`--tag\` accepts comma-separated values or repeated flags and uses AND semantics. \`--status\`, \`--assignee\`, \`--priority\`, and \`--limit\` can narrow the same query. Use \`--status\` when the project's actionable column differs from its configured default.
5045
+ \`--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.
5046
+
5047
+ \`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.
4973
5048
 
4974
5049
  After selecting a slug, load that task's full frontmatter, description, and Updates:
4975
5050
 
@@ -4981,6 +5056,7 @@ Use the other discovery commands when the task needs more context:
4981
5056
 
4982
5057
  - **Diagnose blocked work**: \`shipbench task list --blocked --json\`
4983
5058
  - **Search titles, tags, and descriptions**: \`shipbench task search "<query>" --json\`
5059
+ - **Search only ready work that mentions a term**: \`shipbench task search "<query>" --available --tag backend --json\`
4984
5060
  - **Load complete matching descriptions**: \`shipbench task search "<query>" --json --include-body\`
4985
5061
  - **Search live and archived tasks**: \`shipbench task search "<query>" --all --json\`
4986
5062
  - **Inspect the dependency DAG**: \`shipbench task graph --json\` (add \`--archived\` to resolve archived nodes)
@@ -5031,6 +5107,7 @@ Prefer the ShipBench CLI for task mutations when it is available. The CLI routes
5031
5107
  - **Create a task**: \`shipbench task create "Task title" --status=todo\`
5032
5108
  - **Create a task with a description**: \`shipbench task create "Task title" --body-file=description.md\` (or \`--body "One-line description."\`)
5033
5109
  - **Rewrite a description**: \`shipbench task edit <slug> --body-file=description.md\` (replaces it whole; \`--body ""\` clears it)
5110
+ - **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\`.
5034
5111
  - **Create a dependent task**: \`shipbench task create "Task title" --depends-on=other-slug,another-slug\`
5035
5112
  - **Add a time-anchored update**: \`shipbench task comment <slug> "What changed and why."\`
5036
5113
  - **Add a multi-line update**: \`shipbench task comment <slug> --body-file update.md\`
@@ -5049,11 +5126,11 @@ Prefer the ShipBench CLI for task mutations when it is available. The CLI routes
5049
5126
 
5050
5127
  ### Direct File Operations
5051
5128
 
5052
- Use direct edits only when the CLI is unavailable or when changing task description/frontmatter fields the CLI does not support yet.
5129
+ Use direct edits only when the CLI is unavailable.
5053
5130
 
5054
5131
  - **Create a task**: Add a new \`.md\` file in \`tasks/\` following the format above.
5055
5132
  - **Move a task**: Change the \`status\` field and update the \`updated\` timestamp.
5056
- - **Edit a task**: Modify frontmatter fields and/or the description above \`## Task Updates\`. Always update \`updated\`. The CLI reaches descriptions \u2014 use \`task edit\` rather than rewriting a file by hand.
5133
+ - **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.
5057
5134
  - **Add an Update without the CLI**: Append a \`### <ISO 8601 timestamp>\` heading and text below the trailing \`## Task Updates\` marker.
5058
5135
  - **Edit an Update without the CLI**: Change only its text; preserve the \`###\` timestamp heading and update the frontmatter \`updated\` value.
5059
5136
  - **Delete an Update without the CLI**: Remove its heading and text, remove an empty \`## Task Updates\` section, and update the frontmatter \`updated\` value.
@@ -5089,7 +5166,13 @@ Your ShipBench project board for **${name}** is set up and ready to go.
5089
5166
 
5090
5167
  - Create new tasks with \`shipbench task create "My first task"\`
5091
5168
  - Open the board with \`shipbench board\`, or watch it in a terminal pane with \`shipbench board terminal\`
5169
+ - Record a decision with \`shipbench task comment welcome-to-shipbench "What changed and why."\` It lands under Task Updates with a timestamp, like the entry below.
5092
5170
  - Edit this file or delete it when you're ready
5171
+
5172
+ ## Task Updates
5173
+
5174
+ ### ${now}
5175
+ Set up this board with \`shipbench init\`.
5093
5176
  `;
5094
5177
  }
5095
5178
  async function initProject(adapter, options2) {
@@ -5136,61 +5219,135 @@ async function initProject(adapter, options2) {
5136
5219
  // ../../packages/core/src/search.ts
5137
5220
  var SNIPPET_CONTEXT_BEFORE = 40;
5138
5221
  var SNIPPET_CONTEXT_AFTER = 80;
5139
- function bodySnippet(normalizedBody, normalizedTerms) {
5140
- const lowercaseBody = normalizedBody.toLowerCase();
5222
+ var FIELD_WEIGHT = {
5223
+ title: 12,
5224
+ tags: 6,
5225
+ body: 3,
5226
+ updates: 2
5227
+ };
5228
+ function escapeRegExp(text) {
5229
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5230
+ }
5231
+ function buildTermPattern(text, wholeWord) {
5232
+ const core = escapeRegExp(text).replace(/ /g, "\\s+");
5233
+ const lead = wholeWord && /^\w/.test(text) ? "(?<!\\w)" : "";
5234
+ const trail = wholeWord && /\w$/.test(text) ? "(?!\\w)" : "";
5235
+ return new RegExp(`${lead}${core}${trail}`);
5236
+ }
5237
+ function parseQueryTerms(query, wholeWord) {
5238
+ const terms = [];
5239
+ for (const token of query.matchAll(/"([^"]*)"|([^\s"]+)/g)) {
5240
+ const raw = (token[1] ?? token[2] ?? "").toLowerCase().trim().replace(/\s+/g, " ");
5241
+ if (!raw) continue;
5242
+ terms.push({ text: raw, pattern: buildTermPattern(raw, wholeWord) });
5243
+ }
5244
+ return terms;
5245
+ }
5246
+ function normalizeText(text) {
5247
+ return text.replace(/\s+/g, " ").trim();
5248
+ }
5249
+ function snippetAround(normalizedText, terms) {
5250
+ const lowercase = normalizedText.toLowerCase();
5141
5251
  let matchIndex = -1;
5142
5252
  let matchLength = 0;
5143
- for (const term of normalizedTerms) {
5144
- const termIndex = lowercaseBody.indexOf(term);
5145
- if (termIndex !== -1 && (matchIndex === -1 || termIndex < matchIndex || termIndex === matchIndex && term.length > matchLength)) {
5146
- matchIndex = termIndex;
5147
- matchLength = term.length;
5253
+ for (const term of terms) {
5254
+ const found = term.pattern.exec(lowercase);
5255
+ if (found !== null && (matchIndex === -1 || found.index < matchIndex || found.index === matchIndex && found[0].length > matchLength)) {
5256
+ matchIndex = found.index;
5257
+ matchLength = found[0].length;
5148
5258
  }
5149
5259
  }
5150
5260
  if (matchIndex === -1) return void 0;
5151
5261
  const start = Math.max(0, matchIndex - SNIPPET_CONTEXT_BEFORE);
5152
5262
  const end = Math.min(
5153
- normalizedBody.length,
5263
+ normalizedText.length,
5154
5264
  matchIndex + matchLength + SNIPPET_CONTEXT_AFTER
5155
5265
  );
5156
- const excerpt = normalizedBody.slice(start, end).trim();
5157
- return `${start > 0 ? "\u2026" : ""}${excerpt}${end < normalizedBody.length ? "\u2026" : ""}`;
5158
- }
5159
- function searchTasks(tasks, query) {
5160
- const normalizedQuery = query.trim().toLowerCase();
5161
- if (!normalizedQuery) return [];
5162
- const normalizedTerms = normalizedQuery.split(/\s+/);
5163
- const matches = [];
5266
+ const excerpt = normalizedText.slice(start, end).trim();
5267
+ return `${start > 0 ? "\u2026" : ""}${excerpt}${end < normalizedText.length ? "\u2026" : ""}`;
5268
+ }
5269
+ function searchTasks(tasks, query, options2 = {}) {
5270
+ const terms = parseQueryTerms(query, options2.wholeWord ?? false);
5271
+ if (terms.length === 0) return [];
5272
+ const scored = [];
5164
5273
  for (const task of tasks) {
5165
5274
  const normalizedTitle = task.frontmatter.title.toLowerCase();
5166
5275
  const normalizedTags = (task.frontmatter.tags ?? []).map(
5167
5276
  (tag) => tag.toLowerCase()
5168
5277
  );
5169
- const normalizedBody = task.body.replace(/\s+/g, " ").trim();
5278
+ const normalizedBody = normalizeText(task.body);
5170
5279
  const lowercaseBody = normalizedBody.toLowerCase();
5171
- const everyTermMatches = normalizedTerms.every(
5172
- (term) => normalizedTitle.includes(term) || normalizedTags.some((tag) => tag.includes(term)) || lowercaseBody.includes(term)
5280
+ const rawUpdateSources = [
5281
+ ...task.comments.map((comment, index) => ({
5282
+ kind: "entry",
5283
+ index,
5284
+ timestamp: comment.timestamp,
5285
+ text: comment.text
5286
+ })),
5287
+ ...task.unreadableUpdates ? [{ kind: "unreadable", text: task.unreadableUpdates.text }] : []
5288
+ ];
5289
+ const normalizedUpdateSources = rawUpdateSources.map((source) => {
5290
+ const normalized = normalizeText(source.text);
5291
+ return { ...source, normalized, lowercase: normalized.toLowerCase() };
5292
+ });
5293
+ const matchesTerm = (term) => term.pattern.test(normalizedTitle) || normalizedTags.some((tag) => term.pattern.test(tag)) || term.pattern.test(lowercaseBody) || normalizedUpdateSources.some(
5294
+ (source) => term.pattern.test(source.lowercase)
5173
5295
  );
5174
- if (!everyTermMatches) continue;
5296
+ if (!terms.every(matchesTerm)) continue;
5297
+ const titleTerms = terms.filter(
5298
+ (term) => term.pattern.test(normalizedTitle)
5299
+ ).length;
5300
+ const tagTerms = terms.filter(
5301
+ (term) => normalizedTags.some((tag) => term.pattern.test(tag))
5302
+ ).length;
5303
+ const bodyTerms = terms.filter(
5304
+ (term) => term.pattern.test(lowercaseBody)
5305
+ ).length;
5306
+ const updateTerms = terms.filter(
5307
+ (term) => normalizedUpdateSources.some(
5308
+ (source) => term.pattern.test(source.lowercase)
5309
+ )
5310
+ ).length;
5175
5311
  const matchedFields = [];
5176
- if (normalizedTerms.some((term) => normalizedTitle.includes(term))) {
5177
- matchedFields.push("title");
5178
- }
5179
- if (normalizedTerms.some(
5180
- (term) => normalizedTags.some((tag) => tag.includes(term))
5181
- )) {
5182
- matchedFields.push("tags");
5183
- }
5184
- const snippet = bodySnippet(normalizedBody, normalizedTerms);
5312
+ if (titleTerms > 0) matchedFields.push("title");
5313
+ if (tagTerms > 0) matchedFields.push("tags");
5314
+ const snippet = snippetAround(normalizedBody, terms);
5185
5315
  if (snippet !== void 0) matchedFields.push("body");
5186
- matches.push({
5187
- slug: task.slug,
5188
- title: task.frontmatter.title,
5189
- matched_fields: matchedFields,
5190
- ...snippet !== void 0 ? { snippet } : {}
5316
+ const updateMatches = [];
5317
+ for (const source of normalizedUpdateSources) {
5318
+ if (!terms.some((term) => term.pattern.test(source.lowercase))) {
5319
+ continue;
5320
+ }
5321
+ const entrySnippet = snippetAround(source.normalized, terms) ?? source.normalized;
5322
+ if (source.kind === "unreadable") {
5323
+ updateMatches.push({ unreadable: true, snippet: entrySnippet });
5324
+ } else {
5325
+ updateMatches.push({
5326
+ index: source.index,
5327
+ timestamp: source.timestamp,
5328
+ snippet: entrySnippet
5329
+ });
5330
+ }
5331
+ }
5332
+ if (updateMatches.length > 0) matchedFields.push("updates");
5333
+ const termCount = terms.length;
5334
+ const score = (FIELD_WEIGHT.title * titleTerms + FIELD_WEIGHT.tags * tagTerms + FIELD_WEIGHT.body * bodyTerms + FIELD_WEIGHT.updates * updateTerms) / termCount;
5335
+ scored.push({
5336
+ match: {
5337
+ slug: task.slug,
5338
+ title: task.frontmatter.title,
5339
+ status: task.frontmatter.status,
5340
+ matched_fields: matchedFields,
5341
+ ...snippet !== void 0 ? { snippet } : {},
5342
+ ...updateMatches.length > 0 ? { update_matches: updateMatches } : {}
5343
+ },
5344
+ score,
5345
+ updated: Date.parse(task.frontmatter.updated) || 0
5191
5346
  });
5192
5347
  }
5193
- return matches;
5348
+ return scored.map((entry, index) => ({ ...entry, index })).sort(
5349
+ (a, b) => b.score - a.score || b.updated - a.updated || a.index - b.index
5350
+ ).map((entry) => entry.match);
5194
5351
  }
5195
5352
 
5196
5353
  // src/harborConnect.ts
@@ -5426,7 +5583,7 @@ import {
5426
5583
  createServer
5427
5584
  } from "http";
5428
5585
  import { createRequire } from "module";
5429
- import { dirname as dirname2, extname, join as join3, resolve as resolve2, sep } from "path";
5586
+ import { dirname as dirname2, extname, join as join3, resolve as resolve2, sep as sep2 } from "path";
5430
5587
  import { platform } from "process";
5431
5588
 
5432
5589
  // src/tui/paths.ts
@@ -5489,6 +5646,7 @@ function isValidationError(error) {
5489
5646
  );
5490
5647
  }
5491
5648
  function coreErrorStatus(error) {
5649
+ if (error instanceof UnreadableTaskError) return 422;
5492
5650
  if (isNotFoundError(error)) return 404;
5493
5651
  if (error instanceof ArchiveBlockedError) return 409;
5494
5652
  if (isValidationError(error)) return 400;
@@ -5569,10 +5727,10 @@ function contentType(path) {
5569
5727
  async function serveStatic(req, res, bundleDir) {
5570
5728
  const url = new URL(req.url ?? "/", "http://localhost");
5571
5729
  const pathname = decodeURIComponent(url.pathname);
5572
- const relative = pathname === "/" ? "/standalone.html" : pathname;
5730
+ const relative2 = pathname === "/" ? "/standalone.html" : pathname;
5573
5731
  const root = resolve2(bundleDir);
5574
- const target = resolve2(root, `.${relative}`);
5575
- if (target !== root && !target.startsWith(`${root}${sep}`)) {
5732
+ const target = resolve2(root, `.${relative2}`);
5733
+ if (target !== root && !target.startsWith(`${root}${sep2}`)) {
5576
5734
  sendError(res, 403, "Forbidden");
5577
5735
  return;
5578
5736
  }
@@ -5589,6 +5747,24 @@ async function serveStatic(req, res, bundleDir) {
5589
5747
  throw error;
5590
5748
  }
5591
5749
  }
5750
+ var STATE_CHANGING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
5751
+ function foreignRequestReason(req) {
5752
+ const port = req.socket.localPort;
5753
+ const authorities = /* @__PURE__ */ new Set([`${DEFAULT_HOST}:${port}`, `localhost:${port}`]);
5754
+ if (port === 80) {
5755
+ authorities.add(DEFAULT_HOST);
5756
+ authorities.add("localhost");
5757
+ }
5758
+ const host = req.headers.host?.toLowerCase();
5759
+ if (host === void 0 || !authorities.has(host)) {
5760
+ return `Forbidden: the board only answers requests addressed to ${DEFAULT_HOST}:${port} or localhost:${port}.`;
5761
+ }
5762
+ const origin = req.headers.origin?.toLowerCase();
5763
+ if (STATE_CHANGING_METHODS.has(req.method ?? "") && origin !== void 0 && ![...authorities].some((authority) => origin === `http://${authority}`)) {
5764
+ return "Forbidden: requests from other origins cannot change the board.";
5765
+ }
5766
+ return void 0;
5767
+ }
5592
5768
  function createBoardRequestHandler(adapter, bundleDir, warn) {
5593
5769
  const eventClients = /* @__PURE__ */ new Set();
5594
5770
  const loadServerConfig = () => loadConfig(adapter, {
@@ -5755,6 +5931,11 @@ function createBoardRequestHandler(adapter, bundleDir, warn) {
5755
5931
  return {
5756
5932
  async handle(req, res) {
5757
5933
  const url = new URL(req.url ?? "/", "http://localhost");
5934
+ const forbidden = foreignRequestReason(req);
5935
+ if (forbidden !== void 0) {
5936
+ sendError(res, 403, forbidden);
5937
+ return;
5938
+ }
5758
5939
  try {
5759
5940
  if (url.pathname.startsWith("/api/")) {
5760
5941
  await handleApi(req, res, url);
@@ -6060,6 +6241,9 @@ async function readBoard(adapter, filters) {
6060
6241
  archived.tasks,
6061
6242
  archivedSlugs
6062
6243
  );
6244
+ if (live.unreadable.length > 0) {
6245
+ model.unreadableCount = live.unreadable.length;
6246
+ }
6063
6247
  const configWarning = configWarnings[0];
6064
6248
  if (configWarning) {
6065
6249
  model.notice = `${configWarning.path}: ${configWarning.message}`;
@@ -6394,6 +6578,11 @@ function statusLine(model, plan, width, options2) {
6394
6578
  const alerts = [];
6395
6579
  if (model.notice) alerts.push(style(`${BOX.warn} ${model.notice}`, "yellow"));
6396
6580
  if (model.staleSince) alerts.push(style(`${BOX.warn} stale`, "yellow"));
6581
+ if (model.unreadableCount) {
6582
+ alerts.push(
6583
+ style(`${BOX.warn} ${model.unreadableCount} unreadable`, "yellow")
6584
+ );
6585
+ }
6397
6586
  if (model.warnings.length > 0) {
6398
6587
  alerts.push(
6399
6588
  style(`${BOX.warn} ${model.warnings.length} warnings`, "yellow")
@@ -6627,13 +6816,70 @@ async function runTui(options2) {
6627
6816
  }
6628
6817
 
6629
6818
  // src/cli.ts
6630
- var VERSION = true ? "0.4.0" : "0.0.0-dev";
6819
+ var VERSION = true ? "0.6.0" : "0.0.0-dev";
6631
6820
  function commaList(value) {
6632
6821
  return value.split(",").map((s) => s.trim()).filter(Boolean);
6633
6822
  }
6634
6823
  function accumulateCommaList(value, previous) {
6635
6824
  return [...previous ?? [], ...commaList(value)];
6636
6825
  }
6826
+ function dedupePreservingCase(values) {
6827
+ const seen = /* @__PURE__ */ new Set();
6828
+ const result = [];
6829
+ for (const value of values) {
6830
+ const key = value.toLowerCase();
6831
+ if (seen.has(key)) continue;
6832
+ seen.add(key);
6833
+ result.push(value);
6834
+ }
6835
+ return result;
6836
+ }
6837
+ function assertKnownFilterValues(command, label, values, valid) {
6838
+ if (!values || values.length === 0) return;
6839
+ const validSet = new Set(valid);
6840
+ const unknown = values.filter((value) => !validSet.has(value));
6841
+ if (unknown.length > 0) {
6842
+ command.error(
6843
+ `Unknown ${label} ${unknown.map((value) => `"${value}"`).join(", ")}. Valid: ${valid.join(", ")}`
6844
+ );
6845
+ }
6846
+ }
6847
+ function resolveTaskFilters(command, raw, config) {
6848
+ const statuses = raw.status ?? [];
6849
+ const priorities = raw.priority ?? [];
6850
+ assertKnownFilterValues(
6851
+ command,
6852
+ "status",
6853
+ statuses,
6854
+ config.columns.map((column) => column.id)
6855
+ );
6856
+ assertKnownFilterValues(
6857
+ command,
6858
+ "priority",
6859
+ priorities,
6860
+ config.priority.values
6861
+ );
6862
+ return {
6863
+ statuses,
6864
+ priorities,
6865
+ assignees: raw.assignee ?? [],
6866
+ tags: raw.tag ?? []
6867
+ };
6868
+ }
6869
+ function taskMatchesFilters(task, filters, options2 = {}) {
6870
+ const { frontmatter } = task;
6871
+ if (!options2.ignoreStatus && filters.statuses.length > 0 && !filters.statuses.includes(frontmatter.status)) {
6872
+ return false;
6873
+ }
6874
+ if (filters.priorities.length > 0 && (frontmatter.priority === void 0 || !filters.priorities.includes(frontmatter.priority))) {
6875
+ return false;
6876
+ }
6877
+ if (filters.assignees.length > 0 && (frontmatter.assignee === void 0 || !filters.assignees.includes(frontmatter.assignee))) {
6878
+ return false;
6879
+ }
6880
+ const taskTags = (frontmatter.tags ?? []).map((tag) => tag.toLowerCase());
6881
+ return filters.tags.every((wanted) => taskTags.includes(wanted.toLowerCase()));
6882
+ }
6637
6883
  function parsePort(value) {
6638
6884
  const port = Number(value);
6639
6885
  if (!Number.isInteger(port) || port < 1 || port > 65535) {
@@ -6747,6 +6993,17 @@ function enableExitOverride(command) {
6747
6993
  command.exitOverride();
6748
6994
  for (const child of command.commands) enableExitOverride(child);
6749
6995
  }
6996
+ function formatUnreadableFile(file) {
6997
+ return `[unreadable] ${file.path}: ${file.reason} (${file.slug})`;
6998
+ }
6999
+ function unreadableFileJson(file, includeBody) {
7000
+ return {
7001
+ slug: file.slug,
7002
+ path: file.path,
7003
+ reason: file.reason,
7004
+ ...includeBody ? { content: file.content } : {}
7005
+ };
7006
+ }
6750
7007
  function formatProjectWarning(warning) {
6751
7008
  const source = "path" in warning ? warning.path : warning.slug;
6752
7009
  return `${source}: ${warning.message}`;
@@ -6949,15 +7206,79 @@ function createCli(opts) {
6949
7206
  }
6950
7207
  chrome(`Created task: ${created.slug}`);
6951
7208
  });
6952
- const editCommand = task.command("edit <slug>").description("Replace a task's Markdown description").addOption(bodyOption()).addOption(bodyFileOption()).option("--json", "Output the edited task as JSON").addHelpText(
7209
+ const commaListOption = (flags, description) => new Option(flags, description).argParser(accumulateCommaList);
7210
+ const editCommand = task.command("edit <slug>").description("Revise a task's description or its validated metadata").option(
7211
+ "--title <text>",
7212
+ "Set the title (the slug and filename do not change)"
7213
+ ).option("-p, --priority <value>", "Set the priority").addOption(
7214
+ new Option("-a, --assignee <label>", "Set the assignee label").conflicts([
7215
+ "clearAssignee"
7216
+ ])
7217
+ ).addOption(
7218
+ new Option("--clear-assignee", "Remove the assignee").conflicts([
7219
+ "assignee"
7220
+ ])
7221
+ ).addOption(
7222
+ commaListOption(
7223
+ "-t, --tags <tags>",
7224
+ "Replace every tag (comma-separated or repeatable)"
7225
+ ).conflicts(["addTag", "removeTag", "clearTags"])
7226
+ ).addOption(
7227
+ commaListOption(
7228
+ "--add-tag <tags>",
7229
+ "Add tags, keeping the others (comma-separated or repeatable)"
7230
+ ).conflicts(["tags", "clearTags"])
7231
+ ).addOption(
7232
+ commaListOption(
7233
+ "--remove-tag <tags>",
7234
+ "Remove tags, keeping the others (comma-separated or repeatable)"
7235
+ ).conflicts(["tags", "clearTags"])
7236
+ ).addOption(
7237
+ new Option("--clear-tags", "Remove every tag").conflicts([
7238
+ "tags",
7239
+ "addTag",
7240
+ "removeTag"
7241
+ ])
7242
+ ).addOption(
7243
+ commaListOption(
7244
+ "-d, --depends-on <slugs>",
7245
+ "Replace every dependency (comma-separated or repeatable)"
7246
+ ).conflicts(["addDependsOn", "removeDependsOn", "clearDependsOn"])
7247
+ ).addOption(
7248
+ commaListOption(
7249
+ "--add-depends-on <slugs>",
7250
+ "Add dependencies, keeping the others (comma-separated or repeatable)"
7251
+ ).conflicts(["dependsOn", "clearDependsOn"])
7252
+ ).addOption(
7253
+ commaListOption(
7254
+ "--remove-depends-on <slugs>",
7255
+ "Remove dependencies, keeping the others (comma-separated or repeatable)"
7256
+ ).conflicts(["dependsOn", "clearDependsOn"])
7257
+ ).addOption(
7258
+ new Option("--clear-depends-on", "Remove every dependency").conflicts([
7259
+ "dependsOn",
7260
+ "addDependsOn",
7261
+ "removeDependsOn"
7262
+ ])
7263
+ ).addOption(bodyOption()).addOption(bodyFileOption()).option("--json", "Output the edited task as JSON").addHelpText(
6953
7264
  "after",
6954
- "\nThe description is replaced whole and an empty value clears it. The Task\nUpdates section is never touched \u2014 use `shipbench task comment` for those.\n"
7265
+ "\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"
6955
7266
  );
6956
7267
  editCommand.action(async (slug, raw) => {
6957
7268
  const body = await resolveBody(raw);
6958
- if (body === void 0) {
7269
+ const clearAssignee = Boolean(raw.clearAssignee);
7270
+ const clearTags = Boolean(raw.clearTags);
7271
+ const clearDependsOn = Boolean(raw.clearDependsOn);
7272
+ const addTag = raw.addTag;
7273
+ const removeTag = raw.removeTag;
7274
+ const replaceTags = raw.tags;
7275
+ const addDependsOn = raw.addDependsOn;
7276
+ const removeDependsOn = raw.removeDependsOn;
7277
+ const replaceDependsOn = raw.dependsOn;
7278
+ 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;
7279
+ if (!requestedAnything) {
6959
7280
  editCommand.error(
6960
- 'Provide --body <text> or --body-file <path> (use "-" to read stdin).'
7281
+ "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."
6961
7282
  );
6962
7283
  return;
6963
7284
  }
@@ -6970,7 +7291,95 @@ function createCli(opts) {
6970
7291
  );
6971
7292
  return;
6972
7293
  }
6973
- const { task: edited } = await updateTask(adapter, config, slug, {}, body);
7294
+ const before = existing.frontmatter;
7295
+ const fields = {};
7296
+ const changes = [];
7297
+ const list = (values) => values.length > 0 ? `[${values.join(", ")}]` : "(none)";
7298
+ if (raw.title !== void 0 && raw.title !== before.title) {
7299
+ fields.title = raw.title;
7300
+ changes.push(`title "${before.title}" \u2192 "${raw.title}"`);
7301
+ }
7302
+ if (raw.priority !== void 0 && raw.priority !== before.priority) {
7303
+ fields.priority = raw.priority;
7304
+ changes.push(
7305
+ `priority ${before.priority ?? "(unset)"} \u2192 ${raw.priority}`
7306
+ );
7307
+ }
7308
+ if (raw.assignee !== void 0) {
7309
+ if (raw.assignee !== (before.assignee ?? void 0)) {
7310
+ fields.assignee = raw.assignee;
7311
+ changes.push(
7312
+ `assignee ${before.assignee ?? "(unset)"} \u2192 ${raw.assignee}`
7313
+ );
7314
+ }
7315
+ } else if (clearAssignee && before.assignee !== void 0) {
7316
+ fields.assignee = void 0;
7317
+ changes.push(`assignee ${before.assignee} \u2192 (unset)`);
7318
+ }
7319
+ const currentTags = before.tags ?? [];
7320
+ let nextTags;
7321
+ if (replaceTags !== void 0) {
7322
+ nextTags = dedupePreservingCase(replaceTags);
7323
+ } else if (clearTags) {
7324
+ nextTags = [];
7325
+ } else if (addTag !== void 0 || removeTag !== void 0) {
7326
+ const removed = new Set((removeTag ?? []).map((tag) => tag.toLowerCase()));
7327
+ nextTags = dedupePreservingCase([
7328
+ ...currentTags.filter((tag) => !removed.has(tag.toLowerCase())),
7329
+ ...addTag ?? []
7330
+ ]);
7331
+ }
7332
+ if (nextTags !== void 0 && (nextTags.length !== currentTags.length || nextTags.some((tag, index) => tag !== currentTags[index]))) {
7333
+ fields.tags = nextTags.length > 0 ? nextTags : void 0;
7334
+ changes.push(`tags ${list(currentTags)} \u2192 ${list(nextTags)}`);
7335
+ }
7336
+ const currentDeps = before.depends_on ?? [];
7337
+ let nextDeps;
7338
+ if (replaceDependsOn !== void 0) {
7339
+ nextDeps = dedupePreservingCase(replaceDependsOn);
7340
+ } else if (clearDependsOn) {
7341
+ nextDeps = [];
7342
+ } else if (addDependsOn !== void 0 || removeDependsOn !== void 0) {
7343
+ const removed = new Set(removeDependsOn ?? []);
7344
+ nextDeps = dedupePreservingCase([
7345
+ ...currentDeps.filter((dep) => !removed.has(dep)),
7346
+ ...addDependsOn ?? []
7347
+ ]);
7348
+ }
7349
+ if (nextDeps !== void 0 && (nextDeps.length !== currentDeps.length || nextDeps.some((dep, index) => dep !== currentDeps[index]))) {
7350
+ fields.depends_on = nextDeps;
7351
+ changes.push(`depends_on ${list(currentDeps)} \u2192 ${list(nextDeps)}`);
7352
+ }
7353
+ if (body !== void 0) {
7354
+ changes.push(body.trim() ? "description" : "description cleared");
7355
+ }
7356
+ if (changes.length === 0) {
7357
+ if (raw.json) {
7358
+ data(
7359
+ JSON.stringify(
7360
+ {
7361
+ slug: existing.slug,
7362
+ status: existing.frontmatter.status,
7363
+ frontmatter: existing.frontmatter,
7364
+ body: existing.body,
7365
+ comments: existing.comments
7366
+ },
7367
+ null,
7368
+ 2
7369
+ )
7370
+ );
7371
+ return;
7372
+ }
7373
+ chrome(`No changes for ${slug}: every field already holds that value.`);
7374
+ return;
7375
+ }
7376
+ const { task: edited } = await updateTask(
7377
+ adapter,
7378
+ config,
7379
+ slug,
7380
+ fields,
7381
+ body
7382
+ );
6974
7383
  if (raw.json) {
6975
7384
  data(
6976
7385
  JSON.stringify(
@@ -6987,9 +7396,10 @@ function createCli(opts) {
6987
7396
  );
6988
7397
  return;
6989
7398
  }
6990
- chrome(
6991
- body.trim() ? `Updated description on ${edited.slug}` : `Cleared description on ${edited.slug}`
6992
- );
7399
+ chrome(`Updated ${edited.slug}: ${changes.join("; ")}`);
7400
+ if (fields.title !== void 0) {
7401
+ chrome(`Slug and filename unchanged: ${edited.slug}`);
7402
+ }
6993
7403
  });
6994
7404
  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";
6995
7405
  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);
@@ -7053,6 +7463,10 @@ function createCli(opts) {
7053
7463
  getTaskCommand.error(`Task '${slug}' not found.`);
7054
7464
  return;
7055
7465
  }
7466
+ const updatesWarning = unreadableUpdatesWarning(found);
7467
+ if (updatesWarning) {
7468
+ output.warning(`${found.slug}: ${updatesWarning.message}`);
7469
+ }
7056
7470
  data(
7057
7471
  JSON.stringify(
7058
7472
  {
@@ -7060,7 +7474,8 @@ function createCli(opts) {
7060
7474
  status: found.frontmatter.status,
7061
7475
  frontmatter: found.frontmatter,
7062
7476
  body: found.body,
7063
- comments: found.comments
7477
+ comments: found.comments,
7478
+ ...found.unreadableUpdates ? { unreadable_updates: found.unreadableUpdates } : {}
7064
7479
  },
7065
7480
  null,
7066
7481
  2
@@ -7187,7 +7602,23 @@ function createCli(opts) {
7187
7602
  );
7188
7603
  chrome("Wrote .shipbench/layout.json");
7189
7604
  });
7190
- task.command("list").description("List live tasks in board order, optionally filtered").option("-s, --status <status>", "Filter by status").option("-a, --assignee <assignee>", "Filter by assignee").option("-p, --priority <priority>", "Filter by priority").option(
7605
+ const listCommand = task.command("list").description("List live tasks in board order, optionally filtered");
7606
+ listCommand.addOption(
7607
+ new Option(
7608
+ "-s, --status <statuses>",
7609
+ "Filter by status (comma-separated or repeatable; matches any)"
7610
+ ).argParser(accumulateCommaList)
7611
+ ).addOption(
7612
+ new Option(
7613
+ "-a, --assignee <assignees>",
7614
+ "Filter by assignee (comma-separated or repeatable; matches any)"
7615
+ ).argParser(accumulateCommaList)
7616
+ ).addOption(
7617
+ new Option(
7618
+ "-p, --priority <priorities>",
7619
+ "Filter by priority (comma-separated or repeatable; matches any)"
7620
+ ).argParser(accumulateCommaList)
7621
+ ).option(
7191
7622
  "--tag <tag>",
7192
7623
  "Filter by tag (comma-separated or repeatable with AND semantics)",
7193
7624
  accumulateCommaList
@@ -7215,6 +7646,8 @@ function createCli(opts) {
7215
7646
  );
7216
7647
  }
7217
7648
  const config = await loadCliConfig();
7649
+ const filters = resolveTaskFilters(listCommand, raw, config);
7650
+ const availabilityStatus = filters.statuses.length > 0 ? filters.statuses : void 0;
7218
7651
  const archivedPromise = raw.archived ? void 0 : listArchivedTasks(adapter, config);
7219
7652
  const result = raw.archived ? await listArchivedTasks(adapter, config) : await listTasks(adapter, config, {
7220
7653
  archivedTasks: archivedPromise?.then((result2) => result2.tasks),
@@ -7225,22 +7658,19 @@ function createCli(opts) {
7225
7658
  let candidates = boardOrder?.tasks ?? result.tasks;
7226
7659
  if (raw.available || raw.blocked) {
7227
7660
  candidates = raw.available ? listAvailableTasks(candidates, config, {
7228
- status: raw.status,
7661
+ status: availabilityStatus,
7229
7662
  archivedTasks: archived?.tasks,
7230
7663
  archivedSlugs: archived ? taskFileSlugs(archived) : void 0
7231
7664
  }) : listBlockedTasks(candidates, config, {
7232
- status: raw.status,
7665
+ status: availabilityStatus,
7233
7666
  archivedTasks: archived?.tasks,
7234
7667
  archivedSlugs: archived ? taskFileSlugs(archived) : void 0
7235
7668
  });
7236
7669
  }
7237
- const requestedTags = raw.tag ?? [];
7238
7670
  const filtered = candidates.filter(
7239
- (t) => (raw.available || raw.blocked || !raw.status || t.frontmatter.status === raw.status) && (!raw.assignee || t.frontmatter.assignee === raw.assignee) && (!raw.priority || t.frontmatter.priority === raw.priority) && requestedTags.every(
7240
- (requestedTag) => (t.frontmatter.tags ?? []).some(
7241
- (tag) => tag.toLowerCase() === requestedTag.toLowerCase()
7242
- )
7243
- )
7671
+ (t) => taskMatchesFilters(t, filters, {
7672
+ ignoreStatus: Boolean(raw.available || raw.blocked)
7673
+ })
7244
7674
  ).slice(0, raw.limit);
7245
7675
  if (raw.json) {
7246
7676
  const tasks = filtered.map((t) => ({
@@ -7248,9 +7678,16 @@ function createCli(opts) {
7248
7678
  ...t.frontmatter,
7249
7679
  depends_on: t.frontmatter.depends_on ?? [],
7250
7680
  ...boardOrder ? { position: boardOrder.positions.get(t.slug) } : {},
7251
- ...raw.includeBody ? { body: t.body, comments: t.comments } : {}
7681
+ ...raw.includeBody ? {
7682
+ body: t.body,
7683
+ comments: t.comments,
7684
+ ...t.unreadableUpdates ? { unreadable_updates: t.unreadableUpdates } : {}
7685
+ } : {}
7252
7686
  }));
7253
- const payload = raw.archived ? { archived: true, tasks, warnings: result.warnings } : { tasks, warnings: result.warnings };
7687
+ const unreadable = result.unreadable.map(
7688
+ (file) => unreadableFileJson(file, Boolean(raw.includeBody))
7689
+ );
7690
+ const payload = raw.archived ? { archived: true, tasks, unreadable, warnings: result.warnings } : { tasks, unreadable, warnings: result.warnings };
7254
7691
  data(JSON.stringify(payload, null, 2));
7255
7692
  return;
7256
7693
  }
@@ -7258,6 +7695,7 @@ function createCli(opts) {
7258
7695
  for (const t of filtered) {
7259
7696
  data(`[${t.frontmatter.status}] ${t.frontmatter.title} (${t.slug})`);
7260
7697
  }
7698
+ for (const file of result.unreadable) data(formatUnreadableFile(file));
7261
7699
  if (result.warnings.length > 0) {
7262
7700
  chrome("");
7263
7701
  chrome("Warnings:");
@@ -7266,7 +7704,42 @@ function createCli(opts) {
7266
7704
  }
7267
7705
  }
7268
7706
  });
7269
- task.command("search <query>").description("Search task titles, tags, and Markdown bodies").option("--archived", "Search archived tasks instead of live tasks").addOption(
7707
+ const searchCommand = task.command("search <query>").description(
7708
+ "Search task titles, tags, Markdown descriptions, and Task Updates"
7709
+ );
7710
+ searchCommand.addOption(
7711
+ new Option(
7712
+ "-s, --status <statuses>",
7713
+ "Filter by status (comma-separated or repeatable; matches any)"
7714
+ ).argParser(accumulateCommaList)
7715
+ ).addOption(
7716
+ new Option(
7717
+ "-a, --assignee <assignees>",
7718
+ "Filter by assignee (comma-separated or repeatable; matches any)"
7719
+ ).argParser(accumulateCommaList)
7720
+ ).addOption(
7721
+ new Option(
7722
+ "-p, --priority <priorities>",
7723
+ "Filter by priority (comma-separated or repeatable; matches any)"
7724
+ ).argParser(accumulateCommaList)
7725
+ ).option(
7726
+ "--tag <tag>",
7727
+ "Filter by tag (comma-separated or repeatable with AND semantics)",
7728
+ accumulateCommaList
7729
+ ).addOption(
7730
+ new Option(
7731
+ "--available",
7732
+ "Restrict to tasks whose dependencies are satisfied (ranked like `task list`, live tasks only)"
7733
+ ).conflicts("blocked")
7734
+ ).addOption(
7735
+ new Option(
7736
+ "--blocked",
7737
+ "Restrict to tasks with unsatisfied dependencies (live tasks only)"
7738
+ ).conflicts("available")
7739
+ ).option(
7740
+ "--whole-word",
7741
+ "Match each term on word boundaries instead of as a substring"
7742
+ ).option("--archived", "Search archived tasks instead of live tasks").addOption(
7270
7743
  new Option("--all", "Search both live and archived tasks").conflicts(
7271
7744
  "archived"
7272
7745
  )
@@ -7274,32 +7747,98 @@ function createCli(opts) {
7274
7747
  "--limit <n>",
7275
7748
  "Maximum number of matches to return (0 returns none)",
7276
7749
  parseNonNegativeInteger
7277
- ).option("--json", "Emit machine-readable JSON instead of text").option("--include-body", "Include Markdown bodies in JSON output").action(async (query, raw) => {
7750
+ ).option("--json", "Emit machine-readable JSON instead of text").option(
7751
+ "--include-body",
7752
+ "Include full descriptions and Task Updates in JSON output"
7753
+ ).action(async (query, raw) => {
7278
7754
  if (!query.trim()) {
7279
7755
  throw new InvalidArgumentError("Search query must not be blank.");
7280
7756
  }
7757
+ if ((raw.available || raw.blocked) && (raw.archived || raw.all)) {
7758
+ throw new InvalidArgumentError(
7759
+ "--available and --blocked cannot be used with --archived or --all."
7760
+ );
7761
+ }
7281
7762
  const config = await loadCliConfig();
7282
- const liveResult = raw.archived && !raw.all ? void 0 : await listTasks(adapter, config);
7283
- const archivedResult = raw.archived || raw.all ? await listArchivedTasks(adapter, config) : void 0;
7284
- const candidates = [
7763
+ const filters = resolveTaskFilters(searchCommand, raw, config);
7764
+ const availabilityStatus = filters.statuses.length > 0 ? filters.statuses : void 0;
7765
+ const searchArchive = Boolean(raw.archived || raw.all);
7766
+ const searchLive = !raw.archived || Boolean(raw.all);
7767
+ const readArchive = searchArchive || Boolean(raw.available || raw.blocked);
7768
+ const liveResult = searchLive ? await listTasks(adapter, config) : void 0;
7769
+ const archivedResult = readArchive ? await listArchivedTasks(adapter, config) : void 0;
7770
+ let candidates = [
7285
7771
  ...liveResult?.tasks ?? [],
7286
- ...archivedResult?.tasks ?? []
7772
+ ...searchArchive ? archivedResult?.tasks ?? [] : []
7287
7773
  ];
7288
- const allMatches = searchTasks(candidates, query);
7774
+ if (raw.available || raw.blocked) {
7775
+ const select = raw.available ? listAvailableTasks : listBlockedTasks;
7776
+ const eligible = new Set(
7777
+ select(candidates, config, {
7778
+ status: availabilityStatus,
7779
+ archivedTasks: archivedResult?.tasks,
7780
+ archivedSlugs: archivedResult ? taskFileSlugs(archivedResult) : void 0
7781
+ }).map((task2) => task2.slug)
7782
+ );
7783
+ candidates = candidates.filter((task2) => eligible.has(task2.slug));
7784
+ }
7785
+ candidates = candidates.filter(
7786
+ (task2) => taskMatchesFilters(task2, filters, {
7787
+ ignoreStatus: Boolean(raw.available || raw.blocked)
7788
+ })
7789
+ );
7790
+ const archivedSlugs = new Set(
7791
+ (searchArchive ? archivedResult?.tasks ?? [] : []).map(
7792
+ (candidate) => candidate.slug
7793
+ )
7794
+ );
7795
+ const locationOf = (slug) => archivedSlugs.has(slug) ? "archive" : "live";
7796
+ const allMatches = searchTasks(candidates, query, {
7797
+ wholeWord: Boolean(raw.wholeWord)
7798
+ });
7289
7799
  const matches = allMatches.slice(0, raw.limit);
7290
7800
  const warnings = [
7291
7801
  ...liveResult?.warnings ?? [],
7292
- ...archivedResult?.warnings ?? []
7802
+ ...searchArchive ? archivedResult?.warnings ?? [] : []
7803
+ ];
7804
+ const unreadable = [
7805
+ ...liveResult?.unreadable ?? [],
7806
+ ...searchArchive ? archivedResult?.unreadable ?? [] : []
7293
7807
  ];
7294
7808
  if (raw.json) {
7295
7809
  const tasksBySlug = new Map(
7296
7810
  candidates.map((candidate) => [candidate.slug, candidate])
7297
7811
  );
7298
- const payloadMatches = matches.map((match) => ({
7299
- ...match,
7300
- ...raw.includeBody ? { body: tasksBySlug.get(match.slug)?.body ?? "" } : {}
7301
- }));
7302
- data(JSON.stringify({ matches: payloadMatches, warnings }, null, 2));
7812
+ const payloadMatches = matches.map((match) => {
7813
+ const source = tasksBySlug.get(match.slug);
7814
+ return {
7815
+ slug: match.slug,
7816
+ title: match.title,
7817
+ status: match.status,
7818
+ location: locationOf(match.slug),
7819
+ matched_fields: match.matched_fields,
7820
+ ...match.snippet !== void 0 ? { snippet: match.snippet } : {},
7821
+ ...match.update_matches ? { update_matches: match.update_matches } : {},
7822
+ ...raw.includeBody ? {
7823
+ body: source?.body ?? "",
7824
+ comments: source?.comments ?? []
7825
+ } : {}
7826
+ };
7827
+ });
7828
+ data(
7829
+ JSON.stringify(
7830
+ {
7831
+ matches: payloadMatches,
7832
+ total_matches: allMatches.length,
7833
+ unreadable: unreadable.map(
7834
+ (file) => unreadableFileJson(file, Boolean(raw.includeBody))
7835
+ ),
7836
+ warnings
7837
+ },
7838
+ null,
7839
+ 2
7840
+ )
7841
+ );
7303
7842
  return;
7304
7843
  }
7305
7844
  if (allMatches.length === 0) {
@@ -7310,11 +7849,23 @@ function createCli(opts) {
7310
7849
  }
7311
7850
  for (const match of matches) {
7312
7851
  data(
7313
- `${match.title} (${match.slug}) [${match.matched_fields.join(", ")}]`
7852
+ `${match.title} (${match.slug}) [${locationOf(match.slug)} \xB7 ${match.status}] [${match.matched_fields.join(", ")}]`
7314
7853
  );
7315
7854
  if (match.snippet) data(` ${match.snippet}`);
7855
+ for (const updateMatch of match.update_matches ?? []) {
7856
+ data(
7857
+ "unreadable" in updateMatch ? ` \u21B3 update (unreadable): ${updateMatch.snippet}` : ` \u21B3 update ${updateMatch.index} (${updateMatch.timestamp}): ${updateMatch.snippet}`
7858
+ );
7859
+ }
7860
+ }
7861
+ const omitted = allMatches.length - matches.length;
7862
+ if (omitted > 0) {
7863
+ data(
7864
+ `\u2026 ${omitted} of ${allMatches.length} ${allMatches.length === 1 ? "match" : "matches"} not shown (raise --limit)`
7865
+ );
7316
7866
  }
7317
7867
  }
7868
+ for (const file of unreadable) data(formatUnreadableFile(file));
7318
7869
  if (warnings.length > 0) {
7319
7870
  chrome("");
7320
7871
  chrome("Warnings:");