shipbench 0.3.0 → 0.5.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.
- package/README.md +12 -7
- package/dist/index.js +786 -170
- 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
|
|
3344
|
-
if (
|
|
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 :
|
|
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
|
-
|
|
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(
|
|
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
|
|
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
|
|
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";
|
|
@@ -4029,7 +4049,12 @@ var CONFIG_PATH2 = ".shipbench/config.json";
|
|
|
4029
4049
|
var LAYOUT_PATH2 = ".shipbench/layout.json";
|
|
4030
4050
|
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
|
-
var
|
|
4052
|
+
var ATX_HEADING = /^(#{1,6})\s+(.+?)\s*$/;
|
|
4053
|
+
var ENTRY_HEADING_TEXT = /^\d{4}-\d{2}-\d{2}/;
|
|
4054
|
+
function taskPath(slug, directory = TASKS_DIR) {
|
|
4055
|
+
assertTaskSlug(slug);
|
|
4056
|
+
return `${directory}/${slug}.md`;
|
|
4057
|
+
}
|
|
4033
4058
|
var ArchiveBlockedError = class extends Error {
|
|
4034
4059
|
constructor(slug, dependentSlugs) {
|
|
4035
4060
|
super(
|
|
@@ -4042,6 +4067,16 @@ var ArchiveBlockedError = class extends Error {
|
|
|
4042
4067
|
slug;
|
|
4043
4068
|
dependentSlugs;
|
|
4044
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
|
+
};
|
|
4045
4080
|
var KNOWN_FRONTMATTER_FIELDS = /* @__PURE__ */ new Set([
|
|
4046
4081
|
"title",
|
|
4047
4082
|
"status",
|
|
@@ -4065,12 +4100,9 @@ function updateFence(line, current) {
|
|
|
4065
4100
|
return null;
|
|
4066
4101
|
return current;
|
|
4067
4102
|
}
|
|
4068
|
-
function
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
comments: [],
|
|
4072
|
-
warning: `Malformed Updates section: ${detail} Raw Markdown was preserved in the task body.`
|
|
4073
|
-
};
|
|
4103
|
+
function quoteLine(line) {
|
|
4104
|
+
const text = line.trim();
|
|
4105
|
+
return text.length > 60 ? `"${text.slice(0, 57)}..."` : `"${text}"`;
|
|
4074
4106
|
}
|
|
4075
4107
|
function parseTaskBody(rawBody) {
|
|
4076
4108
|
const body = rawBody.trim();
|
|
@@ -4085,18 +4117,24 @@ function parseTaskBody(rawBody) {
|
|
|
4085
4117
|
fence = updateFence(line, fence);
|
|
4086
4118
|
}
|
|
4087
4119
|
if (updatesHeadings.length === 0) return { body, comments: [] };
|
|
4088
|
-
if (updatesHeadings.length > 1) {
|
|
4089
|
-
return malformedUpdates(
|
|
4090
|
-
body,
|
|
4091
|
-
`found more than one "${UPDATES_HEADING}" heading.`
|
|
4092
|
-
);
|
|
4093
|
-
}
|
|
4094
4120
|
const updatesIndex = updatesHeadings[0];
|
|
4095
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
|
+
}
|
|
4096
4133
|
const updateLines = lines.slice(updatesIndex + 1);
|
|
4097
4134
|
const comments = [];
|
|
4098
4135
|
let timestamp = null;
|
|
4099
4136
|
let textLines = [];
|
|
4137
|
+
let unclosedFenceLine = null;
|
|
4100
4138
|
fence = null;
|
|
4101
4139
|
const finishComment = () => {
|
|
4102
4140
|
if (timestamp === null) return null;
|
|
@@ -4109,47 +4147,48 @@ function parseTaskBody(rawBody) {
|
|
|
4109
4147
|
const outsideFence = fence === null;
|
|
4110
4148
|
const fenceOnLine = /^\s{0,3}(`{3,}|~{3,})/.test(line);
|
|
4111
4149
|
if (outsideFence && !fenceOnLine) {
|
|
4112
|
-
const heading = line.match(
|
|
4113
|
-
if (heading) {
|
|
4150
|
+
const heading = line.match(ATX_HEADING);
|
|
4151
|
+
if (heading && ENTRY_HEADING_TEXT.test(heading[2])) {
|
|
4152
|
+
if (heading[1].length !== 3) {
|
|
4153
|
+
return unreadable(
|
|
4154
|
+
`expected each entry heading to use "### <ISO 8601 timestamp>", saw ${quoteLine(line)}.`
|
|
4155
|
+
);
|
|
4156
|
+
}
|
|
4114
4157
|
const previousError = finishComment();
|
|
4115
|
-
if (previousError) return
|
|
4116
|
-
const nextTimestamp = heading[
|
|
4158
|
+
if (previousError) return unreadable(previousError);
|
|
4159
|
+
const nextTimestamp = heading[2];
|
|
4117
4160
|
if (!ISO_8601_TIMESTAMP.test(nextTimestamp) || Number.isNaN(Date.parse(nextTimestamp))) {
|
|
4118
|
-
return
|
|
4119
|
-
|
|
4120
|
-
`"${nextTimestamp}" is not an ISO 8601 timestamp.`
|
|
4161
|
+
return unreadable(
|
|
4162
|
+
`"${nextTimestamp}" is not an ISO 8601 timestamp, in ${quoteLine(line)}.`
|
|
4121
4163
|
);
|
|
4122
4164
|
}
|
|
4123
4165
|
timestamp = nextTimestamp;
|
|
4124
4166
|
textLines = [];
|
|
4125
4167
|
continue;
|
|
4126
4168
|
}
|
|
4127
|
-
if (/^#{1,6}(?:\s|$)/.test(line)) {
|
|
4128
|
-
return malformedUpdates(
|
|
4129
|
-
body,
|
|
4130
|
-
`expected each entry heading to use "### <ISO 8601 timestamp>".`
|
|
4131
|
-
);
|
|
4132
|
-
}
|
|
4133
4169
|
}
|
|
4134
4170
|
if (timestamp === null) {
|
|
4135
4171
|
if (line.trim()) {
|
|
4136
|
-
return
|
|
4137
|
-
|
|
4138
|
-
`expected "### <ISO 8601 timestamp>" before entry text.`
|
|
4172
|
+
return unreadable(
|
|
4173
|
+
`expected "### <ISO 8601 timestamp>" before entry text, saw ${quoteLine(line)}.`
|
|
4139
4174
|
);
|
|
4140
4175
|
}
|
|
4141
4176
|
} else {
|
|
4142
4177
|
textLines.push(line);
|
|
4143
4178
|
}
|
|
4144
4179
|
fence = updateFence(line, fence);
|
|
4180
|
+
if (fence) unclosedFenceLine ??= line;
|
|
4181
|
+
else unclosedFenceLine = null;
|
|
4145
4182
|
}
|
|
4146
4183
|
if (fence) {
|
|
4147
|
-
return
|
|
4184
|
+
return unreadable(
|
|
4185
|
+
`an entry leaves the code fence opened by ${quoteLine(unclosedFenceLine ?? "")} unclosed.`
|
|
4186
|
+
);
|
|
4148
4187
|
}
|
|
4149
4188
|
const finalError = finishComment();
|
|
4150
|
-
if (finalError) return
|
|
4189
|
+
if (finalError) return unreadable(finalError);
|
|
4151
4190
|
if (comments.length === 0) {
|
|
4152
|
-
return
|
|
4191
|
+
return unreadable("the section contains no entries.");
|
|
4153
4192
|
}
|
|
4154
4193
|
return { body: description, comments };
|
|
4155
4194
|
}
|
|
@@ -4163,6 +4202,35 @@ function assertBodyWithoutUpdatesMarker(body) {
|
|
|
4163
4202
|
}
|
|
4164
4203
|
fence = updateFence(line, fence);
|
|
4165
4204
|
}
|
|
4205
|
+
if (fence) {
|
|
4206
|
+
throw new Error(
|
|
4207
|
+
"Invalid task description: close the code fence this description opens. An open fence runs past the end of the description and hides the Updates section from every read."
|
|
4208
|
+
);
|
|
4209
|
+
}
|
|
4210
|
+
}
|
|
4211
|
+
function assertCommentTextIsParsable(text) {
|
|
4212
|
+
let fence = null;
|
|
4213
|
+
for (const line of text.split(/\r?\n/)) {
|
|
4214
|
+
if (!fence) {
|
|
4215
|
+
if (line.trimEnd() === UPDATES_HEADING) {
|
|
4216
|
+
throw new Error(
|
|
4217
|
+
`Invalid task update: remove the "${UPDATES_HEADING}" heading \u2014 a second one would leave the section unreadable. Put it in a code fence if the update means it literally.`
|
|
4218
|
+
);
|
|
4219
|
+
}
|
|
4220
|
+
const heading = line.match(ATX_HEADING);
|
|
4221
|
+
if (heading && ENTRY_HEADING_TEXT.test(heading[2])) {
|
|
4222
|
+
throw new Error(
|
|
4223
|
+
`Invalid task update: "${line.trim()}" reads as an entry heading and would split this update in two. Indent it, fence it, or drop the leading "#".`
|
|
4224
|
+
);
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
fence = updateFence(line, fence);
|
|
4228
|
+
}
|
|
4229
|
+
if (fence) {
|
|
4230
|
+
throw new Error(
|
|
4231
|
+
"Invalid task update: close the code fence this update opens. An open fence runs past the end of the update and swallows the entries below it."
|
|
4232
|
+
);
|
|
4233
|
+
}
|
|
4166
4234
|
}
|
|
4167
4235
|
function parseFrontmatter(fileContent) {
|
|
4168
4236
|
try {
|
|
@@ -4172,8 +4240,28 @@ function parseFrontmatter(fileContent) {
|
|
|
4172
4240
|
throw error;
|
|
4173
4241
|
}
|
|
4174
4242
|
}
|
|
4175
|
-
function
|
|
4176
|
-
const
|
|
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
|
+
}
|
|
4177
4265
|
const parsedBody = parseTaskBody(bodyContent);
|
|
4178
4266
|
const frontmatter = {
|
|
4179
4267
|
...data,
|
|
@@ -4186,8 +4274,8 @@ function parseTaskFile(slug, fileContent) {
|
|
|
4186
4274
|
body: parsedBody.body,
|
|
4187
4275
|
comments: parsedBody.comments
|
|
4188
4276
|
};
|
|
4189
|
-
if (parsedBody.
|
|
4190
|
-
|
|
4277
|
+
if (parsedBody.unreadableUpdates) {
|
|
4278
|
+
task.unreadableUpdates = parsedBody.unreadableUpdates;
|
|
4191
4279
|
}
|
|
4192
4280
|
return task;
|
|
4193
4281
|
}
|
|
@@ -4201,7 +4289,9 @@ function stripUndefined(obj) {
|
|
|
4201
4289
|
function serializeTask(task) {
|
|
4202
4290
|
const sections = [];
|
|
4203
4291
|
if (task.body.trim()) sections.push(task.body.trim());
|
|
4204
|
-
if (
|
|
4292
|
+
if (task.unreadableUpdates) {
|
|
4293
|
+
sections.push(task.unreadableUpdates.text.trim());
|
|
4294
|
+
} else if ((task.comments ?? []).length > 0) {
|
|
4205
4295
|
const entries = task.comments.map((comment) => `### ${comment.timestamp}
|
|
4206
4296
|
${comment.text.trim()}`).join("\n\n");
|
|
4207
4297
|
sections.push(`${UPDATES_HEADING}
|
|
@@ -4256,16 +4346,20 @@ async function assertValidDependsOn(adapter, config, slug, dependsOn) {
|
|
|
4256
4346
|
}
|
|
4257
4347
|
}
|
|
4258
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
|
+
}
|
|
4259
4357
|
function validateTask(task, config, knownSlugs) {
|
|
4260
4358
|
const warnings = [];
|
|
4261
4359
|
const validStatuses = new Set(config.columns.map((c) => c.id));
|
|
4262
|
-
const updatesWarning =
|
|
4360
|
+
const updatesWarning = unreadableUpdatesWarning(task);
|
|
4263
4361
|
if (updatesWarning) {
|
|
4264
|
-
warnings.push(
|
|
4265
|
-
slug: task.slug,
|
|
4266
|
-
field: "updates",
|
|
4267
|
-
message: updatesWarning
|
|
4268
|
-
});
|
|
4362
|
+
warnings.push(updatesWarning);
|
|
4269
4363
|
}
|
|
4270
4364
|
if (!validStatuses.has(task.frontmatter.status)) {
|
|
4271
4365
|
warnings.push({
|
|
@@ -4314,22 +4408,24 @@ async function listTasksInDirectory(adapter, config, directory, additionalKnownS
|
|
|
4314
4408
|
const files = await adapter.listFiles(directory);
|
|
4315
4409
|
const mdFiles = files.filter((f) => f.endsWith(".md"));
|
|
4316
4410
|
if (mdFiles.length === 0) {
|
|
4317
|
-
return { tasks: [], warnings: [] };
|
|
4411
|
+
return { tasks: [], warnings: [], unreadable: [] };
|
|
4318
4412
|
}
|
|
4319
4413
|
const paths = mdFiles.map((f) => `${directory}/${f}`);
|
|
4320
4414
|
const contents = await adapter.readFiles(paths);
|
|
4321
4415
|
const tasks = [];
|
|
4322
4416
|
const warnings = [];
|
|
4417
|
+
const unreadable = [];
|
|
4323
4418
|
for (const [path, content] of contents) {
|
|
4324
4419
|
const slug = path.replace(`${directory}/`, "").replace(/\.md$/, "");
|
|
4325
4420
|
try {
|
|
4326
|
-
tasks.push(parseTaskFile(slug, content));
|
|
4421
|
+
tasks.push(parseTaskFile(slug, content, path));
|
|
4327
4422
|
} catch (error) {
|
|
4328
|
-
|
|
4423
|
+
if (!(error instanceof UnreadableTaskError)) throw error;
|
|
4424
|
+
unreadable.push(error.file);
|
|
4329
4425
|
warnings.push({
|
|
4330
4426
|
slug,
|
|
4331
4427
|
field: "frontmatter",
|
|
4332
|
-
message: `Could not parse frontmatter in "${path}": ${
|
|
4428
|
+
message: `Could not parse frontmatter in "${path}": ${error.file.reason}`
|
|
4333
4429
|
});
|
|
4334
4430
|
}
|
|
4335
4431
|
}
|
|
@@ -4340,7 +4436,7 @@ async function listTasksInDirectory(adapter, config, directory, additionalKnownS
|
|
|
4340
4436
|
for (const task of tasks) {
|
|
4341
4437
|
warnings.push(...validateTask(task, config, knownSlugs));
|
|
4342
4438
|
}
|
|
4343
|
-
return { tasks, warnings };
|
|
4439
|
+
return { tasks, warnings, unreadable };
|
|
4344
4440
|
}
|
|
4345
4441
|
async function listTasks(adapter, config, options2 = {}) {
|
|
4346
4442
|
const archivedSlugs = Promise.all([
|
|
@@ -4355,8 +4451,9 @@ async function listTasks(adapter, config, options2 = {}) {
|
|
|
4355
4451
|
async function getTask(adapter, config, slug, options2 = {}) {
|
|
4356
4452
|
void config;
|
|
4357
4453
|
const directory = options2.archived ? ARCHIVE_DIR : TASKS_DIR;
|
|
4358
|
-
const
|
|
4359
|
-
|
|
4454
|
+
const path = taskPath(slug, directory);
|
|
4455
|
+
const content = await adapter.readFileIfExists(path);
|
|
4456
|
+
return content === null ? null : parseTaskFile(slug, content, path);
|
|
4360
4457
|
}
|
|
4361
4458
|
async function listArchivedTasks(adapter, config) {
|
|
4362
4459
|
const liveFiles = await adapter.listFiles(TASKS_DIR);
|
|
@@ -4409,7 +4506,7 @@ async function createTask(adapter, config, title, fields, body) {
|
|
|
4409
4506
|
body: body ?? "",
|
|
4410
4507
|
comments: []
|
|
4411
4508
|
};
|
|
4412
|
-
await adapter.writeFile(
|
|
4509
|
+
await adapter.writeFile(taskPath(slug), serializeTask(task));
|
|
4413
4510
|
const currentLayout = config.layout ?? {};
|
|
4414
4511
|
const columnOrder = currentLayout[status] ?? [];
|
|
4415
4512
|
const nextLayout = status === config.done_column ? currentLayout : {
|
|
@@ -4421,11 +4518,16 @@ async function createTask(adapter, config, title, fields, body) {
|
|
|
4421
4518
|
}
|
|
4422
4519
|
async function updateTask(adapter, config, slug, fields, body) {
|
|
4423
4520
|
if (body !== void 0) assertBodyWithoutUpdatesMarker(body);
|
|
4424
|
-
const path =
|
|
4521
|
+
const path = taskPath(slug);
|
|
4425
4522
|
const content = await adapter.readFile(path);
|
|
4426
|
-
const task = parseTaskFile(slug, content);
|
|
4523
|
+
const task = parseTaskFile(slug, content, path);
|
|
4427
4524
|
if (fields.status) assertValidStatus(fields.status, config);
|
|
4428
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
|
+
}
|
|
4429
4531
|
const dependsOnProvided = "depends_on" in fields;
|
|
4430
4532
|
const dependsOn = dependsOnProvided ? normalizeDependsOn(fields.depends_on) : void 0;
|
|
4431
4533
|
if (dependsOnProvided) {
|
|
@@ -4462,10 +4564,11 @@ async function addComment(adapter, config, slug, text) {
|
|
|
4462
4564
|
if (!normalizedText) {
|
|
4463
4565
|
throw new Error("Task update text must not be blank.");
|
|
4464
4566
|
}
|
|
4465
|
-
|
|
4567
|
+
assertCommentTextIsParsable(normalizedText);
|
|
4568
|
+
const path = taskPath(slug);
|
|
4466
4569
|
const content = await adapter.readFile(path);
|
|
4467
|
-
const task = parseTaskFile(slug, content);
|
|
4468
|
-
if (
|
|
4570
|
+
const task = parseTaskFile(slug, content, path);
|
|
4571
|
+
if (task.unreadableUpdates) {
|
|
4469
4572
|
throw new Error(
|
|
4470
4573
|
`Cannot add an update to "${slug}" because its Updates section is malformed. Fix the section in the task file first.`
|
|
4471
4574
|
);
|
|
@@ -4477,7 +4580,7 @@ async function addComment(adapter, config, slug, text) {
|
|
|
4477
4580
|
return task;
|
|
4478
4581
|
}
|
|
4479
4582
|
function assertMutableComments(task, slug, action) {
|
|
4480
|
-
if (
|
|
4583
|
+
if (task.unreadableUpdates) {
|
|
4481
4584
|
throw new Error(
|
|
4482
4585
|
`Cannot ${action} an update on "${slug}" because its Updates section is malformed. Fix the section in the task file first.`
|
|
4483
4586
|
);
|
|
@@ -4497,9 +4600,10 @@ async function editComment(adapter, config, slug, index, text) {
|
|
|
4497
4600
|
if (!normalizedText) {
|
|
4498
4601
|
throw new Error("Task update text must not be blank.");
|
|
4499
4602
|
}
|
|
4500
|
-
|
|
4603
|
+
assertCommentTextIsParsable(normalizedText);
|
|
4604
|
+
const path = taskPath(slug);
|
|
4501
4605
|
const content = await adapter.readFile(path);
|
|
4502
|
-
const task = parseTaskFile(slug, content);
|
|
4606
|
+
const task = parseTaskFile(slug, content, path);
|
|
4503
4607
|
assertMutableComments(task, slug, "edit");
|
|
4504
4608
|
assertCommentIndex(task, slug, index);
|
|
4505
4609
|
const comment = task.comments[index];
|
|
@@ -4510,9 +4614,9 @@ async function editComment(adapter, config, slug, index, text) {
|
|
|
4510
4614
|
}
|
|
4511
4615
|
async function deleteComment(adapter, config, slug, index) {
|
|
4512
4616
|
void config;
|
|
4513
|
-
const path =
|
|
4617
|
+
const path = taskPath(slug);
|
|
4514
4618
|
const content = await adapter.readFile(path);
|
|
4515
|
-
const task = parseTaskFile(slug, content);
|
|
4619
|
+
const task = parseTaskFile(slug, content, path);
|
|
4516
4620
|
assertMutableComments(task, slug, "delete");
|
|
4517
4621
|
assertCommentIndex(task, slug, index);
|
|
4518
4622
|
task.comments.splice(index, 1);
|
|
@@ -4553,9 +4657,9 @@ async function writeLayout(adapter, config, layout) {
|
|
|
4553
4657
|
}
|
|
4554
4658
|
async function reorderTask(adapter, config, slug, toStatus, position) {
|
|
4555
4659
|
assertValidStatus(toStatus, config);
|
|
4556
|
-
const path =
|
|
4660
|
+
const path = taskPath(slug);
|
|
4557
4661
|
const content = await adapter.readFile(path);
|
|
4558
|
-
const task = parseTaskFile(slug, content);
|
|
4662
|
+
const task = parseTaskFile(slug, content, path);
|
|
4559
4663
|
if (task.frontmatter.status !== toStatus) {
|
|
4560
4664
|
task.frontmatter = {
|
|
4561
4665
|
...task.frontmatter,
|
|
@@ -4587,15 +4691,15 @@ async function moveTask(adapter, config, slug, toStatus) {
|
|
|
4587
4691
|
return task;
|
|
4588
4692
|
}
|
|
4589
4693
|
async function deleteTask(adapter, config, slug) {
|
|
4590
|
-
await adapter.deleteFile(
|
|
4694
|
+
await adapter.deleteFile(taskPath(slug));
|
|
4591
4695
|
const existingSlugs = await listExistingSlugs(adapter);
|
|
4592
4696
|
const layout = layoutWithoutTask(config.layout ?? {}, slug, existingSlugs);
|
|
4593
4697
|
await writeLayout(adapter, config, layout);
|
|
4594
4698
|
}
|
|
4595
4699
|
async function archiveTask(adapter, config, slug, options2) {
|
|
4596
|
-
const livePath =
|
|
4700
|
+
const livePath = taskPath(slug);
|
|
4597
4701
|
const content = await adapter.readFile(livePath);
|
|
4598
|
-
const task = parseTaskFile(slug, content);
|
|
4702
|
+
const task = parseTaskFile(slug, content, livePath);
|
|
4599
4703
|
if (task.frontmatter.status !== config.done_column && !options2?.force) {
|
|
4600
4704
|
const { tasks } = await listTasks(adapter, config);
|
|
4601
4705
|
const dependentSlugs = tasks.filter(
|
|
@@ -4605,7 +4709,7 @@ async function archiveTask(adapter, config, slug, options2) {
|
|
|
4605
4709
|
throw new ArchiveBlockedError(slug, dependentSlugs);
|
|
4606
4710
|
}
|
|
4607
4711
|
}
|
|
4608
|
-
await adapter.writeFile(
|
|
4712
|
+
await adapter.writeFile(taskPath(slug, ARCHIVE_DIR), content);
|
|
4609
4713
|
await adapter.deleteFile(livePath);
|
|
4610
4714
|
const existingSlugs = await listExistingSlugs(adapter);
|
|
4611
4715
|
const layout = layoutWithoutTask(config.layout ?? {}, slug, existingSlugs);
|
|
@@ -4619,10 +4723,10 @@ async function archiveTask(adapter, config, slug, options2) {
|
|
|
4619
4723
|
return task;
|
|
4620
4724
|
}
|
|
4621
4725
|
async function unarchiveTask(adapter, config, slug) {
|
|
4622
|
-
const archivedPath =
|
|
4726
|
+
const archivedPath = taskPath(slug, ARCHIVE_DIR);
|
|
4623
4727
|
const content = await adapter.readFile(archivedPath);
|
|
4624
|
-
const task = parseTaskFile(slug, content);
|
|
4625
|
-
await adapter.writeFile(
|
|
4728
|
+
const task = parseTaskFile(slug, content, archivedPath);
|
|
4729
|
+
await adapter.writeFile(taskPath(slug), content);
|
|
4626
4730
|
await adapter.deleteFile(archivedPath);
|
|
4627
4731
|
const status = task.frontmatter.status;
|
|
4628
4732
|
if (status !== config.done_column) {
|
|
@@ -4835,6 +4939,8 @@ Write a description with the task instead of after it: \`shipbench task create "
|
|
|
4835
4939
|
|
|
4836
4940
|
Each task may end with a reserved \`## Task Updates\` section. Use it for time-anchored decisions, pivots, and external events that would lose meaning without their timestamp. Keep timeless facts in the description instead. Append with \`shipbench task comment <slug> "What changed and why."\`, edit text with \`shipbench task comment edit <slug> <index> "Corrected text."\`, or delete with \`shipbench task comment delete <slug> <index>\`. Indices are zero-based. Edits preserve the entry's timestamp; Git preserves earlier text and deleted entries.
|
|
4837
4941
|
|
|
4942
|
+
Both commands also take \`--body <text>\` and \`--body-file <path>\` in place of the positional text, and \`--body-file\` is the one to reach for when an update runs to several lines: ShipBench reads the file as UTF-8 itself, so the prose never passes through shell quoting or a shell's encoding.
|
|
4943
|
+
|
|
4838
4944
|
Archived tasks live in \`tasks/archive/\` and are excluded from normal board reads. Archiving moves the file without changing its frontmatter or timestamps; unarchiving restores the same file to \`tasks/\`.
|
|
4839
4945
|
`;
|
|
4840
4946
|
}
|
|
@@ -4905,7 +5011,11 @@ This heuristic is guidance, not a validation rule. Core stores each entry as \`{
|
|
|
4905
5011
|
|
|
4906
5012
|
Append through \`shipbench task comment <slug> "What changed and why."\`. Edit text with \`shipbench task comment edit <slug> <index> "Corrected text."\`; delete an entry with \`shipbench task comment delete <slug> <index>\`. Indices are zero-based. Editing never changes the entry's timestamp. Git preserves earlier text and deleted entries.
|
|
4907
5013
|
|
|
4908
|
-
|
|
5014
|
+
Append and edit both accept \`--body <text>\` or \`--body-file <path>\` instead of the positional text, the same pair \`task create\` and \`task edit\` take. Use \`--body-file\` for anything multi-line: ShipBench reads the file as UTF-8, so the text never passes through shell quoting or encoding.
|
|
5015
|
+
|
|
5016
|
+
Update text is prose. Markdown headings inside it are yours to use \u2014 only a column-0 \`### <ISO 8601 timestamp>\` line opens a new entry. Three things are rejected on write, because the next read would mis-file them: a \`## Task Updates\` heading of its own, a column-0 heading whose text is a date, and an unclosed code fence.
|
|
5017
|
+
|
|
5018
|
+
A description may not contain a \`## Task Updates\` heading of its own \u2014 the next read would file part of it as entries, so ShipBench rejects the write. It also may not leave a code fence open, which would swallow the marker below it and hide every entry. Put the heading in a code fence when a description means it literally.
|
|
4909
5019
|
|
|
4910
5020
|
Do not hand-edit content below the \`## Task Updates\` marker when the CLI is available.
|
|
4911
5021
|
|
|
@@ -4923,6 +5033,8 @@ shipbench task list --available --json
|
|
|
4923
5033
|
|
|
4924
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.
|
|
4925
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
|
+
|
|
4926
5038
|
Narrow the candidate set without loading every description:
|
|
4927
5039
|
|
|
4928
5040
|
\`\`\`bash
|
|
@@ -4930,7 +5042,9 @@ shipbench task list --available --tag backend --json
|
|
|
4930
5042
|
shipbench task list --available --tag backend,auth --assignee agent --json
|
|
4931
5043
|
\`\`\`
|
|
4932
5044
|
|
|
4933
|
-
\`--tag\` accepts comma-separated values or repeated flags and uses AND semantics. \`--status\`, \`--assignee\`, \`--priority
|
|
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.
|
|
4934
5048
|
|
|
4935
5049
|
After selecting a slug, load that task's full frontmatter, description, and Updates:
|
|
4936
5050
|
|
|
@@ -4942,6 +5056,7 @@ Use the other discovery commands when the task needs more context:
|
|
|
4942
5056
|
|
|
4943
5057
|
- **Diagnose blocked work**: \`shipbench task list --blocked --json\`
|
|
4944
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\`
|
|
4945
5060
|
- **Load complete matching descriptions**: \`shipbench task search "<query>" --json --include-body\`
|
|
4946
5061
|
- **Search live and archived tasks**: \`shipbench task search "<query>" --all --json\`
|
|
4947
5062
|
- **Inspect the dependency DAG**: \`shipbench task graph --json\` (add \`--archived\` to resolve archived nodes)
|
|
@@ -4992,9 +5107,11 @@ Prefer the ShipBench CLI for task mutations when it is available. The CLI routes
|
|
|
4992
5107
|
- **Create a task**: \`shipbench task create "Task title" --status=todo\`
|
|
4993
5108
|
- **Create a task with a description**: \`shipbench task create "Task title" --body-file=description.md\` (or \`--body "One-line description."\`)
|
|
4994
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\`.
|
|
4995
5111
|
- **Create a dependent task**: \`shipbench task create "Task title" --depends-on=other-slug,another-slug\`
|
|
4996
5112
|
- **Add a time-anchored update**: \`shipbench task comment <slug> "What changed and why."\`
|
|
4997
|
-
- **
|
|
5113
|
+
- **Add a multi-line update**: \`shipbench task comment <slug> --body-file update.md\`
|
|
5114
|
+
- **Edit an update's text**: \`shipbench task comment edit <slug> <index> "Corrected text."\` (also takes \`--body-file\`)
|
|
4998
5115
|
- **Delete an update**: \`shipbench task comment delete <slug> <index>\`
|
|
4999
5116
|
- **Move a task**: \`shipbench task move <slug> --to=in-progress\`
|
|
5000
5117
|
- **Complete a task**: \`shipbench task move <slug> --to=done\`
|
|
@@ -5009,11 +5126,11 @@ Prefer the ShipBench CLI for task mutations when it is available. The CLI routes
|
|
|
5009
5126
|
|
|
5010
5127
|
### Direct File Operations
|
|
5011
5128
|
|
|
5012
|
-
Use direct edits only when the CLI is unavailable
|
|
5129
|
+
Use direct edits only when the CLI is unavailable.
|
|
5013
5130
|
|
|
5014
5131
|
- **Create a task**: Add a new \`.md\` file in \`tasks/\` following the format above.
|
|
5015
5132
|
- **Move a task**: Change the \`status\` field and update the \`updated\` timestamp.
|
|
5016
|
-
- **Edit a task**: Modify frontmatter fields and/or the description above \`## Task Updates\`. Always update \`updated\`.
|
|
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.
|
|
5017
5134
|
- **Add an Update without the CLI**: Append a \`### <ISO 8601 timestamp>\` heading and text below the trailing \`## Task Updates\` marker.
|
|
5018
5135
|
- **Edit an Update without the CLI**: Change only its text; preserve the \`###\` timestamp heading and update the frontmatter \`updated\` value.
|
|
5019
5136
|
- **Delete an Update without the CLI**: Remove its heading and text, remove an empty \`## Task Updates\` section, and update the frontmatter \`updated\` value.
|
|
@@ -5096,61 +5213,135 @@ async function initProject(adapter, options2) {
|
|
|
5096
5213
|
// ../../packages/core/src/search.ts
|
|
5097
5214
|
var SNIPPET_CONTEXT_BEFORE = 40;
|
|
5098
5215
|
var SNIPPET_CONTEXT_AFTER = 80;
|
|
5099
|
-
|
|
5100
|
-
|
|
5216
|
+
var FIELD_WEIGHT = {
|
|
5217
|
+
title: 12,
|
|
5218
|
+
tags: 6,
|
|
5219
|
+
body: 3,
|
|
5220
|
+
updates: 2
|
|
5221
|
+
};
|
|
5222
|
+
function escapeRegExp(text) {
|
|
5223
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5224
|
+
}
|
|
5225
|
+
function buildTermPattern(text, wholeWord) {
|
|
5226
|
+
const core = escapeRegExp(text).replace(/ /g, "\\s+");
|
|
5227
|
+
const lead = wholeWord && /^\w/.test(text) ? "(?<!\\w)" : "";
|
|
5228
|
+
const trail = wholeWord && /\w$/.test(text) ? "(?!\\w)" : "";
|
|
5229
|
+
return new RegExp(`${lead}${core}${trail}`);
|
|
5230
|
+
}
|
|
5231
|
+
function parseQueryTerms(query, wholeWord) {
|
|
5232
|
+
const terms = [];
|
|
5233
|
+
for (const token of query.matchAll(/"([^"]*)"|([^\s"]+)/g)) {
|
|
5234
|
+
const raw = (token[1] ?? token[2] ?? "").toLowerCase().trim().replace(/\s+/g, " ");
|
|
5235
|
+
if (!raw) continue;
|
|
5236
|
+
terms.push({ text: raw, pattern: buildTermPattern(raw, wholeWord) });
|
|
5237
|
+
}
|
|
5238
|
+
return terms;
|
|
5239
|
+
}
|
|
5240
|
+
function normalizeText(text) {
|
|
5241
|
+
return text.replace(/\s+/g, " ").trim();
|
|
5242
|
+
}
|
|
5243
|
+
function snippetAround(normalizedText, terms) {
|
|
5244
|
+
const lowercase = normalizedText.toLowerCase();
|
|
5101
5245
|
let matchIndex = -1;
|
|
5102
5246
|
let matchLength = 0;
|
|
5103
|
-
for (const term of
|
|
5104
|
-
const
|
|
5105
|
-
if (
|
|
5106
|
-
matchIndex =
|
|
5107
|
-
matchLength =
|
|
5247
|
+
for (const term of terms) {
|
|
5248
|
+
const found = term.pattern.exec(lowercase);
|
|
5249
|
+
if (found !== null && (matchIndex === -1 || found.index < matchIndex || found.index === matchIndex && found[0].length > matchLength)) {
|
|
5250
|
+
matchIndex = found.index;
|
|
5251
|
+
matchLength = found[0].length;
|
|
5108
5252
|
}
|
|
5109
5253
|
}
|
|
5110
5254
|
if (matchIndex === -1) return void 0;
|
|
5111
5255
|
const start = Math.max(0, matchIndex - SNIPPET_CONTEXT_BEFORE);
|
|
5112
5256
|
const end = Math.min(
|
|
5113
|
-
|
|
5257
|
+
normalizedText.length,
|
|
5114
5258
|
matchIndex + matchLength + SNIPPET_CONTEXT_AFTER
|
|
5115
5259
|
);
|
|
5116
|
-
const excerpt =
|
|
5117
|
-
return `${start > 0 ? "\u2026" : ""}${excerpt}${end <
|
|
5118
|
-
}
|
|
5119
|
-
function searchTasks(tasks, query) {
|
|
5120
|
-
const
|
|
5121
|
-
if (
|
|
5122
|
-
const
|
|
5123
|
-
const matches = [];
|
|
5260
|
+
const excerpt = normalizedText.slice(start, end).trim();
|
|
5261
|
+
return `${start > 0 ? "\u2026" : ""}${excerpt}${end < normalizedText.length ? "\u2026" : ""}`;
|
|
5262
|
+
}
|
|
5263
|
+
function searchTasks(tasks, query, options2 = {}) {
|
|
5264
|
+
const terms = parseQueryTerms(query, options2.wholeWord ?? false);
|
|
5265
|
+
if (terms.length === 0) return [];
|
|
5266
|
+
const scored = [];
|
|
5124
5267
|
for (const task of tasks) {
|
|
5125
5268
|
const normalizedTitle = task.frontmatter.title.toLowerCase();
|
|
5126
5269
|
const normalizedTags = (task.frontmatter.tags ?? []).map(
|
|
5127
5270
|
(tag) => tag.toLowerCase()
|
|
5128
5271
|
);
|
|
5129
|
-
const normalizedBody = task.body
|
|
5272
|
+
const normalizedBody = normalizeText(task.body);
|
|
5130
5273
|
const lowercaseBody = normalizedBody.toLowerCase();
|
|
5131
|
-
const
|
|
5132
|
-
|
|
5274
|
+
const rawUpdateSources = [
|
|
5275
|
+
...task.comments.map((comment, index) => ({
|
|
5276
|
+
kind: "entry",
|
|
5277
|
+
index,
|
|
5278
|
+
timestamp: comment.timestamp,
|
|
5279
|
+
text: comment.text
|
|
5280
|
+
})),
|
|
5281
|
+
...task.unreadableUpdates ? [{ kind: "unreadable", text: task.unreadableUpdates.text }] : []
|
|
5282
|
+
];
|
|
5283
|
+
const normalizedUpdateSources = rawUpdateSources.map((source) => {
|
|
5284
|
+
const normalized = normalizeText(source.text);
|
|
5285
|
+
return { ...source, normalized, lowercase: normalized.toLowerCase() };
|
|
5286
|
+
});
|
|
5287
|
+
const matchesTerm = (term) => term.pattern.test(normalizedTitle) || normalizedTags.some((tag) => term.pattern.test(tag)) || term.pattern.test(lowercaseBody) || normalizedUpdateSources.some(
|
|
5288
|
+
(source) => term.pattern.test(source.lowercase)
|
|
5133
5289
|
);
|
|
5134
|
-
if (!
|
|
5290
|
+
if (!terms.every(matchesTerm)) continue;
|
|
5291
|
+
const titleTerms = terms.filter(
|
|
5292
|
+
(term) => term.pattern.test(normalizedTitle)
|
|
5293
|
+
).length;
|
|
5294
|
+
const tagTerms = terms.filter(
|
|
5295
|
+
(term) => normalizedTags.some((tag) => term.pattern.test(tag))
|
|
5296
|
+
).length;
|
|
5297
|
+
const bodyTerms = terms.filter(
|
|
5298
|
+
(term) => term.pattern.test(lowercaseBody)
|
|
5299
|
+
).length;
|
|
5300
|
+
const updateTerms = terms.filter(
|
|
5301
|
+
(term) => normalizedUpdateSources.some(
|
|
5302
|
+
(source) => term.pattern.test(source.lowercase)
|
|
5303
|
+
)
|
|
5304
|
+
).length;
|
|
5135
5305
|
const matchedFields = [];
|
|
5136
|
-
if (
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
if (normalizedTerms.some(
|
|
5140
|
-
(term) => normalizedTags.some((tag) => tag.includes(term))
|
|
5141
|
-
)) {
|
|
5142
|
-
matchedFields.push("tags");
|
|
5143
|
-
}
|
|
5144
|
-
const snippet = bodySnippet(normalizedBody, normalizedTerms);
|
|
5306
|
+
if (titleTerms > 0) matchedFields.push("title");
|
|
5307
|
+
if (tagTerms > 0) matchedFields.push("tags");
|
|
5308
|
+
const snippet = snippetAround(normalizedBody, terms);
|
|
5145
5309
|
if (snippet !== void 0) matchedFields.push("body");
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5310
|
+
const updateMatches = [];
|
|
5311
|
+
for (const source of normalizedUpdateSources) {
|
|
5312
|
+
if (!terms.some((term) => term.pattern.test(source.lowercase))) {
|
|
5313
|
+
continue;
|
|
5314
|
+
}
|
|
5315
|
+
const entrySnippet = snippetAround(source.normalized, terms) ?? source.normalized;
|
|
5316
|
+
if (source.kind === "unreadable") {
|
|
5317
|
+
updateMatches.push({ unreadable: true, snippet: entrySnippet });
|
|
5318
|
+
} else {
|
|
5319
|
+
updateMatches.push({
|
|
5320
|
+
index: source.index,
|
|
5321
|
+
timestamp: source.timestamp,
|
|
5322
|
+
snippet: entrySnippet
|
|
5323
|
+
});
|
|
5324
|
+
}
|
|
5325
|
+
}
|
|
5326
|
+
if (updateMatches.length > 0) matchedFields.push("updates");
|
|
5327
|
+
const termCount = terms.length;
|
|
5328
|
+
const score = (FIELD_WEIGHT.title * titleTerms + FIELD_WEIGHT.tags * tagTerms + FIELD_WEIGHT.body * bodyTerms + FIELD_WEIGHT.updates * updateTerms) / termCount;
|
|
5329
|
+
scored.push({
|
|
5330
|
+
match: {
|
|
5331
|
+
slug: task.slug,
|
|
5332
|
+
title: task.frontmatter.title,
|
|
5333
|
+
status: task.frontmatter.status,
|
|
5334
|
+
matched_fields: matchedFields,
|
|
5335
|
+
...snippet !== void 0 ? { snippet } : {},
|
|
5336
|
+
...updateMatches.length > 0 ? { update_matches: updateMatches } : {}
|
|
5337
|
+
},
|
|
5338
|
+
score,
|
|
5339
|
+
updated: Date.parse(task.frontmatter.updated) || 0
|
|
5151
5340
|
});
|
|
5152
5341
|
}
|
|
5153
|
-
return
|
|
5342
|
+
return scored.map((entry, index) => ({ ...entry, index })).sort(
|
|
5343
|
+
(a, b) => b.score - a.score || b.updated - a.updated || a.index - b.index
|
|
5344
|
+
).map((entry) => entry.match);
|
|
5154
5345
|
}
|
|
5155
5346
|
|
|
5156
5347
|
// src/harborConnect.ts
|
|
@@ -5386,7 +5577,7 @@ import {
|
|
|
5386
5577
|
createServer
|
|
5387
5578
|
} from "http";
|
|
5388
5579
|
import { createRequire } from "module";
|
|
5389
|
-
import { dirname as dirname2, extname, join as join3, resolve as resolve2, sep } from "path";
|
|
5580
|
+
import { dirname as dirname2, extname, join as join3, resolve as resolve2, sep as sep2 } from "path";
|
|
5390
5581
|
import { platform } from "process";
|
|
5391
5582
|
|
|
5392
5583
|
// src/tui/paths.ts
|
|
@@ -5449,6 +5640,7 @@ function isValidationError(error) {
|
|
|
5449
5640
|
);
|
|
5450
5641
|
}
|
|
5451
5642
|
function coreErrorStatus(error) {
|
|
5643
|
+
if (error instanceof UnreadableTaskError) return 422;
|
|
5452
5644
|
if (isNotFoundError(error)) return 404;
|
|
5453
5645
|
if (error instanceof ArchiveBlockedError) return 409;
|
|
5454
5646
|
if (isValidationError(error)) return 400;
|
|
@@ -5529,10 +5721,10 @@ function contentType(path) {
|
|
|
5529
5721
|
async function serveStatic(req, res, bundleDir) {
|
|
5530
5722
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
5531
5723
|
const pathname = decodeURIComponent(url.pathname);
|
|
5532
|
-
const
|
|
5724
|
+
const relative2 = pathname === "/" ? "/standalone.html" : pathname;
|
|
5533
5725
|
const root = resolve2(bundleDir);
|
|
5534
|
-
const target = resolve2(root, `.${
|
|
5535
|
-
if (target !== root && !target.startsWith(`${root}${
|
|
5726
|
+
const target = resolve2(root, `.${relative2}`);
|
|
5727
|
+
if (target !== root && !target.startsWith(`${root}${sep2}`)) {
|
|
5536
5728
|
sendError(res, 403, "Forbidden");
|
|
5537
5729
|
return;
|
|
5538
5730
|
}
|
|
@@ -5549,6 +5741,24 @@ async function serveStatic(req, res, bundleDir) {
|
|
|
5549
5741
|
throw error;
|
|
5550
5742
|
}
|
|
5551
5743
|
}
|
|
5744
|
+
var STATE_CHANGING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
5745
|
+
function foreignRequestReason(req) {
|
|
5746
|
+
const port = req.socket.localPort;
|
|
5747
|
+
const authorities = /* @__PURE__ */ new Set([`${DEFAULT_HOST}:${port}`, `localhost:${port}`]);
|
|
5748
|
+
if (port === 80) {
|
|
5749
|
+
authorities.add(DEFAULT_HOST);
|
|
5750
|
+
authorities.add("localhost");
|
|
5751
|
+
}
|
|
5752
|
+
const host = req.headers.host?.toLowerCase();
|
|
5753
|
+
if (host === void 0 || !authorities.has(host)) {
|
|
5754
|
+
return `Forbidden: the board only answers requests addressed to ${DEFAULT_HOST}:${port} or localhost:${port}.`;
|
|
5755
|
+
}
|
|
5756
|
+
const origin = req.headers.origin?.toLowerCase();
|
|
5757
|
+
if (STATE_CHANGING_METHODS.has(req.method ?? "") && origin !== void 0 && ![...authorities].some((authority) => origin === `http://${authority}`)) {
|
|
5758
|
+
return "Forbidden: requests from other origins cannot change the board.";
|
|
5759
|
+
}
|
|
5760
|
+
return void 0;
|
|
5761
|
+
}
|
|
5552
5762
|
function createBoardRequestHandler(adapter, bundleDir, warn) {
|
|
5553
5763
|
const eventClients = /* @__PURE__ */ new Set();
|
|
5554
5764
|
const loadServerConfig = () => loadConfig(adapter, {
|
|
@@ -5715,6 +5925,11 @@ function createBoardRequestHandler(adapter, bundleDir, warn) {
|
|
|
5715
5925
|
return {
|
|
5716
5926
|
async handle(req, res) {
|
|
5717
5927
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
5928
|
+
const forbidden = foreignRequestReason(req);
|
|
5929
|
+
if (forbidden !== void 0) {
|
|
5930
|
+
sendError(res, 403, forbidden);
|
|
5931
|
+
return;
|
|
5932
|
+
}
|
|
5718
5933
|
try {
|
|
5719
5934
|
if (url.pathname.startsWith("/api/")) {
|
|
5720
5935
|
await handleApi(req, res, url);
|
|
@@ -6020,6 +6235,9 @@ async function readBoard(adapter, filters) {
|
|
|
6020
6235
|
archived.tasks,
|
|
6021
6236
|
archivedSlugs
|
|
6022
6237
|
);
|
|
6238
|
+
if (live.unreadable.length > 0) {
|
|
6239
|
+
model.unreadableCount = live.unreadable.length;
|
|
6240
|
+
}
|
|
6023
6241
|
const configWarning = configWarnings[0];
|
|
6024
6242
|
if (configWarning) {
|
|
6025
6243
|
model.notice = `${configWarning.path}: ${configWarning.message}`;
|
|
@@ -6354,6 +6572,11 @@ function statusLine(model, plan, width, options2) {
|
|
|
6354
6572
|
const alerts = [];
|
|
6355
6573
|
if (model.notice) alerts.push(style(`${BOX.warn} ${model.notice}`, "yellow"));
|
|
6356
6574
|
if (model.staleSince) alerts.push(style(`${BOX.warn} stale`, "yellow"));
|
|
6575
|
+
if (model.unreadableCount) {
|
|
6576
|
+
alerts.push(
|
|
6577
|
+
style(`${BOX.warn} ${model.unreadableCount} unreadable`, "yellow")
|
|
6578
|
+
);
|
|
6579
|
+
}
|
|
6357
6580
|
if (model.warnings.length > 0) {
|
|
6358
6581
|
alerts.push(
|
|
6359
6582
|
style(`${BOX.warn} ${model.warnings.length} warnings`, "yellow")
|
|
@@ -6587,13 +6810,70 @@ async function runTui(options2) {
|
|
|
6587
6810
|
}
|
|
6588
6811
|
|
|
6589
6812
|
// src/cli.ts
|
|
6590
|
-
var VERSION = true ? "0.
|
|
6813
|
+
var VERSION = true ? "0.5.0" : "0.0.0-dev";
|
|
6591
6814
|
function commaList(value) {
|
|
6592
6815
|
return value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
6593
6816
|
}
|
|
6594
6817
|
function accumulateCommaList(value, previous) {
|
|
6595
6818
|
return [...previous ?? [], ...commaList(value)];
|
|
6596
6819
|
}
|
|
6820
|
+
function dedupePreservingCase(values) {
|
|
6821
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6822
|
+
const result = [];
|
|
6823
|
+
for (const value of values) {
|
|
6824
|
+
const key = value.toLowerCase();
|
|
6825
|
+
if (seen.has(key)) continue;
|
|
6826
|
+
seen.add(key);
|
|
6827
|
+
result.push(value);
|
|
6828
|
+
}
|
|
6829
|
+
return result;
|
|
6830
|
+
}
|
|
6831
|
+
function assertKnownFilterValues(command, label, values, valid) {
|
|
6832
|
+
if (!values || values.length === 0) return;
|
|
6833
|
+
const validSet = new Set(valid);
|
|
6834
|
+
const unknown = values.filter((value) => !validSet.has(value));
|
|
6835
|
+
if (unknown.length > 0) {
|
|
6836
|
+
command.error(
|
|
6837
|
+
`Unknown ${label} ${unknown.map((value) => `"${value}"`).join(", ")}. Valid: ${valid.join(", ")}`
|
|
6838
|
+
);
|
|
6839
|
+
}
|
|
6840
|
+
}
|
|
6841
|
+
function resolveTaskFilters(command, raw, config) {
|
|
6842
|
+
const statuses = raw.status ?? [];
|
|
6843
|
+
const priorities = raw.priority ?? [];
|
|
6844
|
+
assertKnownFilterValues(
|
|
6845
|
+
command,
|
|
6846
|
+
"status",
|
|
6847
|
+
statuses,
|
|
6848
|
+
config.columns.map((column) => column.id)
|
|
6849
|
+
);
|
|
6850
|
+
assertKnownFilterValues(
|
|
6851
|
+
command,
|
|
6852
|
+
"priority",
|
|
6853
|
+
priorities,
|
|
6854
|
+
config.priority.values
|
|
6855
|
+
);
|
|
6856
|
+
return {
|
|
6857
|
+
statuses,
|
|
6858
|
+
priorities,
|
|
6859
|
+
assignees: raw.assignee ?? [],
|
|
6860
|
+
tags: raw.tag ?? []
|
|
6861
|
+
};
|
|
6862
|
+
}
|
|
6863
|
+
function taskMatchesFilters(task, filters, options2 = {}) {
|
|
6864
|
+
const { frontmatter } = task;
|
|
6865
|
+
if (!options2.ignoreStatus && filters.statuses.length > 0 && !filters.statuses.includes(frontmatter.status)) {
|
|
6866
|
+
return false;
|
|
6867
|
+
}
|
|
6868
|
+
if (filters.priorities.length > 0 && (frontmatter.priority === void 0 || !filters.priorities.includes(frontmatter.priority))) {
|
|
6869
|
+
return false;
|
|
6870
|
+
}
|
|
6871
|
+
if (filters.assignees.length > 0 && (frontmatter.assignee === void 0 || !filters.assignees.includes(frontmatter.assignee))) {
|
|
6872
|
+
return false;
|
|
6873
|
+
}
|
|
6874
|
+
const taskTags = (frontmatter.tags ?? []).map((tag) => tag.toLowerCase());
|
|
6875
|
+
return filters.tags.every((wanted) => taskTags.includes(wanted.toLowerCase()));
|
|
6876
|
+
}
|
|
6597
6877
|
function parsePort(value) {
|
|
6598
6878
|
const port = Number(value);
|
|
6599
6879
|
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
@@ -6677,10 +6957,9 @@ function formatTaskDependencyGraph(graph) {
|
|
|
6677
6957
|
return lines;
|
|
6678
6958
|
}
|
|
6679
6959
|
function bodyOption() {
|
|
6680
|
-
return new Option(
|
|
6681
|
-
"
|
|
6682
|
-
|
|
6683
|
-
).conflicts(["bodyFile"]);
|
|
6960
|
+
return new Option("--body <text>", "Description as Markdown text").conflicts([
|
|
6961
|
+
"bodyFile"
|
|
6962
|
+
]);
|
|
6684
6963
|
}
|
|
6685
6964
|
function bodyFileOption() {
|
|
6686
6965
|
return new Option(
|
|
@@ -6688,6 +6967,17 @@ function bodyFileOption() {
|
|
|
6688
6967
|
'Read the description from a UTF-8 file; "-" reads stdin'
|
|
6689
6968
|
).conflicts(["body"]);
|
|
6690
6969
|
}
|
|
6970
|
+
function updateTextOption() {
|
|
6971
|
+
return new Option("--body <text>", "Update text as Markdown").conflicts([
|
|
6972
|
+
"bodyFile"
|
|
6973
|
+
]);
|
|
6974
|
+
}
|
|
6975
|
+
function updateTextFileOption() {
|
|
6976
|
+
return new Option(
|
|
6977
|
+
"--body-file <path>",
|
|
6978
|
+
'Read the update text from a UTF-8 file; "-" reads stdin'
|
|
6979
|
+
).conflicts(["body"]);
|
|
6980
|
+
}
|
|
6691
6981
|
async function readProcessStdin() {
|
|
6692
6982
|
const chunks = [];
|
|
6693
6983
|
for await (const chunk of process.stdin) chunks.push(Buffer.from(chunk));
|
|
@@ -6697,6 +6987,17 @@ function enableExitOverride(command) {
|
|
|
6697
6987
|
command.exitOverride();
|
|
6698
6988
|
for (const child of command.commands) enableExitOverride(child);
|
|
6699
6989
|
}
|
|
6990
|
+
function formatUnreadableFile(file) {
|
|
6991
|
+
return `[unreadable] ${file.path}: ${file.reason} (${file.slug})`;
|
|
6992
|
+
}
|
|
6993
|
+
function unreadableFileJson(file, includeBody) {
|
|
6994
|
+
return {
|
|
6995
|
+
slug: file.slug,
|
|
6996
|
+
path: file.path,
|
|
6997
|
+
reason: file.reason,
|
|
6998
|
+
...includeBody ? { content: file.content } : {}
|
|
6999
|
+
};
|
|
7000
|
+
}
|
|
6700
7001
|
function formatProjectWarning(warning) {
|
|
6701
7002
|
const source = "path" in warning ? warning.path : warning.slug;
|
|
6702
7003
|
return `${source}: ${warning.message}`;
|
|
@@ -6734,7 +7035,17 @@ function createCli(opts) {
|
|
|
6734
7035
|
);
|
|
6735
7036
|
}
|
|
6736
7037
|
};
|
|
6737
|
-
const
|
|
7038
|
+
const resolveUpdateText = async (command, positional, raw) => {
|
|
7039
|
+
const fromOption = await resolveBody(raw);
|
|
7040
|
+
if (positional != null && fromOption !== void 0) {
|
|
7041
|
+
command.error(
|
|
7042
|
+
"Pass the update text once: either positionally or with --body / --body-file, not both."
|
|
7043
|
+
);
|
|
7044
|
+
return void 0;
|
|
7045
|
+
}
|
|
7046
|
+
return positional ?? fromOption;
|
|
7047
|
+
};
|
|
7048
|
+
const program = new Command().name("shipbench").description("Git-native project management for solo developers.").enablePositionalOptions().version(VERSION, "-v, --version", "output the version").option(
|
|
6738
7049
|
"-C <path>",
|
|
6739
7050
|
"Run as if ShipBench was started in the specified directory"
|
|
6740
7051
|
);
|
|
@@ -6889,15 +7200,79 @@ function createCli(opts) {
|
|
|
6889
7200
|
}
|
|
6890
7201
|
chrome(`Created task: ${created.slug}`);
|
|
6891
7202
|
});
|
|
6892
|
-
const
|
|
7203
|
+
const commaListOption = (flags, description) => new Option(flags, description).argParser(accumulateCommaList);
|
|
7204
|
+
const editCommand = task.command("edit <slug>").description("Revise a task's description or its validated metadata").option(
|
|
7205
|
+
"--title <text>",
|
|
7206
|
+
"Set the title (the slug and filename do not change)"
|
|
7207
|
+
).option("-p, --priority <value>", "Set the priority").addOption(
|
|
7208
|
+
new Option("-a, --assignee <label>", "Set the assignee label").conflicts([
|
|
7209
|
+
"clearAssignee"
|
|
7210
|
+
])
|
|
7211
|
+
).addOption(
|
|
7212
|
+
new Option("--clear-assignee", "Remove the assignee").conflicts([
|
|
7213
|
+
"assignee"
|
|
7214
|
+
])
|
|
7215
|
+
).addOption(
|
|
7216
|
+
commaListOption(
|
|
7217
|
+
"-t, --tags <tags>",
|
|
7218
|
+
"Replace every tag (comma-separated or repeatable)"
|
|
7219
|
+
).conflicts(["addTag", "removeTag", "clearTags"])
|
|
7220
|
+
).addOption(
|
|
7221
|
+
commaListOption(
|
|
7222
|
+
"--add-tag <tags>",
|
|
7223
|
+
"Add tags, keeping the others (comma-separated or repeatable)"
|
|
7224
|
+
).conflicts(["tags", "clearTags"])
|
|
7225
|
+
).addOption(
|
|
7226
|
+
commaListOption(
|
|
7227
|
+
"--remove-tag <tags>",
|
|
7228
|
+
"Remove tags, keeping the others (comma-separated or repeatable)"
|
|
7229
|
+
).conflicts(["tags", "clearTags"])
|
|
7230
|
+
).addOption(
|
|
7231
|
+
new Option("--clear-tags", "Remove every tag").conflicts([
|
|
7232
|
+
"tags",
|
|
7233
|
+
"addTag",
|
|
7234
|
+
"removeTag"
|
|
7235
|
+
])
|
|
7236
|
+
).addOption(
|
|
7237
|
+
commaListOption(
|
|
7238
|
+
"-d, --depends-on <slugs>",
|
|
7239
|
+
"Replace every dependency (comma-separated or repeatable)"
|
|
7240
|
+
).conflicts(["addDependsOn", "removeDependsOn", "clearDependsOn"])
|
|
7241
|
+
).addOption(
|
|
7242
|
+
commaListOption(
|
|
7243
|
+
"--add-depends-on <slugs>",
|
|
7244
|
+
"Add dependencies, keeping the others (comma-separated or repeatable)"
|
|
7245
|
+
).conflicts(["dependsOn", "clearDependsOn"])
|
|
7246
|
+
).addOption(
|
|
7247
|
+
commaListOption(
|
|
7248
|
+
"--remove-depends-on <slugs>",
|
|
7249
|
+
"Remove dependencies, keeping the others (comma-separated or repeatable)"
|
|
7250
|
+
).conflicts(["dependsOn", "clearDependsOn"])
|
|
7251
|
+
).addOption(
|
|
7252
|
+
new Option("--clear-depends-on", "Remove every dependency").conflicts([
|
|
7253
|
+
"dependsOn",
|
|
7254
|
+
"addDependsOn",
|
|
7255
|
+
"removeDependsOn"
|
|
7256
|
+
])
|
|
7257
|
+
).addOption(bodyOption()).addOption(bodyFileOption()).option("--json", "Output the edited task as JSON").addHelpText(
|
|
6893
7258
|
"after",
|
|
6894
|
-
"\
|
|
7259
|
+
"\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"
|
|
6895
7260
|
);
|
|
6896
7261
|
editCommand.action(async (slug, raw) => {
|
|
6897
7262
|
const body = await resolveBody(raw);
|
|
6898
|
-
|
|
7263
|
+
const clearAssignee = Boolean(raw.clearAssignee);
|
|
7264
|
+
const clearTags = Boolean(raw.clearTags);
|
|
7265
|
+
const clearDependsOn = Boolean(raw.clearDependsOn);
|
|
7266
|
+
const addTag = raw.addTag;
|
|
7267
|
+
const removeTag = raw.removeTag;
|
|
7268
|
+
const replaceTags = raw.tags;
|
|
7269
|
+
const addDependsOn = raw.addDependsOn;
|
|
7270
|
+
const removeDependsOn = raw.removeDependsOn;
|
|
7271
|
+
const replaceDependsOn = raw.dependsOn;
|
|
7272
|
+
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;
|
|
7273
|
+
if (!requestedAnything) {
|
|
6899
7274
|
editCommand.error(
|
|
6900
|
-
|
|
7275
|
+
"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."
|
|
6901
7276
|
);
|
|
6902
7277
|
return;
|
|
6903
7278
|
}
|
|
@@ -6910,7 +7285,95 @@ function createCli(opts) {
|
|
|
6910
7285
|
);
|
|
6911
7286
|
return;
|
|
6912
7287
|
}
|
|
6913
|
-
const
|
|
7288
|
+
const before = existing.frontmatter;
|
|
7289
|
+
const fields = {};
|
|
7290
|
+
const changes = [];
|
|
7291
|
+
const list = (values) => values.length > 0 ? `[${values.join(", ")}]` : "(none)";
|
|
7292
|
+
if (raw.title !== void 0 && raw.title !== before.title) {
|
|
7293
|
+
fields.title = raw.title;
|
|
7294
|
+
changes.push(`title "${before.title}" \u2192 "${raw.title}"`);
|
|
7295
|
+
}
|
|
7296
|
+
if (raw.priority !== void 0 && raw.priority !== before.priority) {
|
|
7297
|
+
fields.priority = raw.priority;
|
|
7298
|
+
changes.push(
|
|
7299
|
+
`priority ${before.priority ?? "(unset)"} \u2192 ${raw.priority}`
|
|
7300
|
+
);
|
|
7301
|
+
}
|
|
7302
|
+
if (raw.assignee !== void 0) {
|
|
7303
|
+
if (raw.assignee !== (before.assignee ?? void 0)) {
|
|
7304
|
+
fields.assignee = raw.assignee;
|
|
7305
|
+
changes.push(
|
|
7306
|
+
`assignee ${before.assignee ?? "(unset)"} \u2192 ${raw.assignee}`
|
|
7307
|
+
);
|
|
7308
|
+
}
|
|
7309
|
+
} else if (clearAssignee && before.assignee !== void 0) {
|
|
7310
|
+
fields.assignee = void 0;
|
|
7311
|
+
changes.push(`assignee ${before.assignee} \u2192 (unset)`);
|
|
7312
|
+
}
|
|
7313
|
+
const currentTags = before.tags ?? [];
|
|
7314
|
+
let nextTags;
|
|
7315
|
+
if (replaceTags !== void 0) {
|
|
7316
|
+
nextTags = dedupePreservingCase(replaceTags);
|
|
7317
|
+
} else if (clearTags) {
|
|
7318
|
+
nextTags = [];
|
|
7319
|
+
} else if (addTag !== void 0 || removeTag !== void 0) {
|
|
7320
|
+
const removed = new Set((removeTag ?? []).map((tag) => tag.toLowerCase()));
|
|
7321
|
+
nextTags = dedupePreservingCase([
|
|
7322
|
+
...currentTags.filter((tag) => !removed.has(tag.toLowerCase())),
|
|
7323
|
+
...addTag ?? []
|
|
7324
|
+
]);
|
|
7325
|
+
}
|
|
7326
|
+
if (nextTags !== void 0 && (nextTags.length !== currentTags.length || nextTags.some((tag, index) => tag !== currentTags[index]))) {
|
|
7327
|
+
fields.tags = nextTags.length > 0 ? nextTags : void 0;
|
|
7328
|
+
changes.push(`tags ${list(currentTags)} \u2192 ${list(nextTags)}`);
|
|
7329
|
+
}
|
|
7330
|
+
const currentDeps = before.depends_on ?? [];
|
|
7331
|
+
let nextDeps;
|
|
7332
|
+
if (replaceDependsOn !== void 0) {
|
|
7333
|
+
nextDeps = dedupePreservingCase(replaceDependsOn);
|
|
7334
|
+
} else if (clearDependsOn) {
|
|
7335
|
+
nextDeps = [];
|
|
7336
|
+
} else if (addDependsOn !== void 0 || removeDependsOn !== void 0) {
|
|
7337
|
+
const removed = new Set(removeDependsOn ?? []);
|
|
7338
|
+
nextDeps = dedupePreservingCase([
|
|
7339
|
+
...currentDeps.filter((dep) => !removed.has(dep)),
|
|
7340
|
+
...addDependsOn ?? []
|
|
7341
|
+
]);
|
|
7342
|
+
}
|
|
7343
|
+
if (nextDeps !== void 0 && (nextDeps.length !== currentDeps.length || nextDeps.some((dep, index) => dep !== currentDeps[index]))) {
|
|
7344
|
+
fields.depends_on = nextDeps;
|
|
7345
|
+
changes.push(`depends_on ${list(currentDeps)} \u2192 ${list(nextDeps)}`);
|
|
7346
|
+
}
|
|
7347
|
+
if (body !== void 0) {
|
|
7348
|
+
changes.push(body.trim() ? "description" : "description cleared");
|
|
7349
|
+
}
|
|
7350
|
+
if (changes.length === 0) {
|
|
7351
|
+
if (raw.json) {
|
|
7352
|
+
data(
|
|
7353
|
+
JSON.stringify(
|
|
7354
|
+
{
|
|
7355
|
+
slug: existing.slug,
|
|
7356
|
+
status: existing.frontmatter.status,
|
|
7357
|
+
frontmatter: existing.frontmatter,
|
|
7358
|
+
body: existing.body,
|
|
7359
|
+
comments: existing.comments
|
|
7360
|
+
},
|
|
7361
|
+
null,
|
|
7362
|
+
2
|
|
7363
|
+
)
|
|
7364
|
+
);
|
|
7365
|
+
return;
|
|
7366
|
+
}
|
|
7367
|
+
chrome(`No changes for ${slug}: every field already holds that value.`);
|
|
7368
|
+
return;
|
|
7369
|
+
}
|
|
7370
|
+
const { task: edited } = await updateTask(
|
|
7371
|
+
adapter,
|
|
7372
|
+
config,
|
|
7373
|
+
slug,
|
|
7374
|
+
fields,
|
|
7375
|
+
body
|
|
7376
|
+
);
|
|
6914
7377
|
if (raw.json) {
|
|
6915
7378
|
data(
|
|
6916
7379
|
JSON.stringify(
|
|
@@ -6927,23 +7390,35 @@ function createCli(opts) {
|
|
|
6927
7390
|
);
|
|
6928
7391
|
return;
|
|
6929
7392
|
}
|
|
6930
|
-
chrome(
|
|
6931
|
-
|
|
6932
|
-
|
|
7393
|
+
chrome(`Updated ${edited.slug}: ${changes.join("; ")}`);
|
|
7394
|
+
if (fields.title !== void 0) {
|
|
7395
|
+
chrome(`Slug and filename unchanged: ${edited.slug}`);
|
|
7396
|
+
}
|
|
6933
7397
|
});
|
|
6934
|
-
const
|
|
6935
|
-
|
|
7398
|
+
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";
|
|
7399
|
+
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);
|
|
7400
|
+
commentCommand.action(async (slug, text, raw) => {
|
|
7401
|
+
const resolved = await resolveUpdateText(commentCommand, text, raw);
|
|
7402
|
+
if (!slug || resolved === void 0) {
|
|
6936
7403
|
throw new InvalidArgumentError(
|
|
6937
|
-
"Append requires a task slug and update text."
|
|
7404
|
+
"Append requires a task slug and update text (positional, --body <text>, or --body-file <path>)."
|
|
6938
7405
|
);
|
|
6939
7406
|
}
|
|
6940
7407
|
const config = await loadCliConfig();
|
|
6941
|
-
const updated = await addComment(adapter, config, slug,
|
|
7408
|
+
const updated = await addComment(adapter, config, slug, resolved);
|
|
6942
7409
|
chrome(`Added update to ${updated.slug}`);
|
|
6943
7410
|
});
|
|
6944
|
-
|
|
7411
|
+
const commentEditCommand = commentCommand.command("edit <slug> <index> [text]").description(
|
|
6945
7412
|
"Edit an Updates entry by zero-based index without changing its timestamp"
|
|
6946
|
-
).
|
|
7413
|
+
).addOption(updateTextOption()).addOption(updateTextFileOption()).addHelpText("after", BODY_FILE_HELP);
|
|
7414
|
+
commentEditCommand.action(async (slug, index, text, raw) => {
|
|
7415
|
+
const resolved = await resolveUpdateText(commentEditCommand, text, raw);
|
|
7416
|
+
if (resolved === void 0) {
|
|
7417
|
+
commentEditCommand.error(
|
|
7418
|
+
"Provide the replacement text positionally, or with --body <text> or --body-file <path>."
|
|
7419
|
+
);
|
|
7420
|
+
return;
|
|
7421
|
+
}
|
|
6947
7422
|
const config = await loadCliConfig();
|
|
6948
7423
|
const parsedIndex = parseNonNegativeInteger(index);
|
|
6949
7424
|
const updated = await editComment(
|
|
@@ -6951,11 +7426,11 @@ function createCli(opts) {
|
|
|
6951
7426
|
config,
|
|
6952
7427
|
slug,
|
|
6953
7428
|
parsedIndex,
|
|
6954
|
-
|
|
7429
|
+
resolved
|
|
6955
7430
|
);
|
|
6956
7431
|
chrome(`Edited update ${parsedIndex} on ${updated.slug}`);
|
|
6957
7432
|
});
|
|
6958
|
-
|
|
7433
|
+
commentCommand.command("delete <slug> <index>").description("Delete an Updates entry by zero-based index").action(async (slug, index) => {
|
|
6959
7434
|
const config = await loadCliConfig();
|
|
6960
7435
|
const parsedIndex = parseNonNegativeInteger(index);
|
|
6961
7436
|
const updated = await deleteComment(adapter, config, slug, parsedIndex);
|
|
@@ -6982,6 +7457,10 @@ function createCli(opts) {
|
|
|
6982
7457
|
getTaskCommand.error(`Task '${slug}' not found.`);
|
|
6983
7458
|
return;
|
|
6984
7459
|
}
|
|
7460
|
+
const updatesWarning = unreadableUpdatesWarning(found);
|
|
7461
|
+
if (updatesWarning) {
|
|
7462
|
+
output.warning(`${found.slug}: ${updatesWarning.message}`);
|
|
7463
|
+
}
|
|
6985
7464
|
data(
|
|
6986
7465
|
JSON.stringify(
|
|
6987
7466
|
{
|
|
@@ -6989,7 +7468,8 @@ function createCli(opts) {
|
|
|
6989
7468
|
status: found.frontmatter.status,
|
|
6990
7469
|
frontmatter: found.frontmatter,
|
|
6991
7470
|
body: found.body,
|
|
6992
|
-
comments: found.comments
|
|
7471
|
+
comments: found.comments,
|
|
7472
|
+
...found.unreadableUpdates ? { unreadable_updates: found.unreadableUpdates } : {}
|
|
6993
7473
|
},
|
|
6994
7474
|
null,
|
|
6995
7475
|
2
|
|
@@ -7116,7 +7596,23 @@ function createCli(opts) {
|
|
|
7116
7596
|
);
|
|
7117
7597
|
chrome("Wrote .shipbench/layout.json");
|
|
7118
7598
|
});
|
|
7119
|
-
task.command("list").description("List live tasks in board order, optionally filtered")
|
|
7599
|
+
const listCommand = task.command("list").description("List live tasks in board order, optionally filtered");
|
|
7600
|
+
listCommand.addOption(
|
|
7601
|
+
new Option(
|
|
7602
|
+
"-s, --status <statuses>",
|
|
7603
|
+
"Filter by status (comma-separated or repeatable; matches any)"
|
|
7604
|
+
).argParser(accumulateCommaList)
|
|
7605
|
+
).addOption(
|
|
7606
|
+
new Option(
|
|
7607
|
+
"-a, --assignee <assignees>",
|
|
7608
|
+
"Filter by assignee (comma-separated or repeatable; matches any)"
|
|
7609
|
+
).argParser(accumulateCommaList)
|
|
7610
|
+
).addOption(
|
|
7611
|
+
new Option(
|
|
7612
|
+
"-p, --priority <priorities>",
|
|
7613
|
+
"Filter by priority (comma-separated or repeatable; matches any)"
|
|
7614
|
+
).argParser(accumulateCommaList)
|
|
7615
|
+
).option(
|
|
7120
7616
|
"--tag <tag>",
|
|
7121
7617
|
"Filter by tag (comma-separated or repeatable with AND semantics)",
|
|
7122
7618
|
accumulateCommaList
|
|
@@ -7144,6 +7640,8 @@ function createCli(opts) {
|
|
|
7144
7640
|
);
|
|
7145
7641
|
}
|
|
7146
7642
|
const config = await loadCliConfig();
|
|
7643
|
+
const filters = resolveTaskFilters(listCommand, raw, config);
|
|
7644
|
+
const availabilityStatus = filters.statuses.length > 0 ? filters.statuses : void 0;
|
|
7147
7645
|
const archivedPromise = raw.archived ? void 0 : listArchivedTasks(adapter, config);
|
|
7148
7646
|
const result = raw.archived ? await listArchivedTasks(adapter, config) : await listTasks(adapter, config, {
|
|
7149
7647
|
archivedTasks: archivedPromise?.then((result2) => result2.tasks),
|
|
@@ -7154,22 +7652,19 @@ function createCli(opts) {
|
|
|
7154
7652
|
let candidates = boardOrder?.tasks ?? result.tasks;
|
|
7155
7653
|
if (raw.available || raw.blocked) {
|
|
7156
7654
|
candidates = raw.available ? listAvailableTasks(candidates, config, {
|
|
7157
|
-
status:
|
|
7655
|
+
status: availabilityStatus,
|
|
7158
7656
|
archivedTasks: archived?.tasks,
|
|
7159
7657
|
archivedSlugs: archived ? taskFileSlugs(archived) : void 0
|
|
7160
7658
|
}) : listBlockedTasks(candidates, config, {
|
|
7161
|
-
status:
|
|
7659
|
+
status: availabilityStatus,
|
|
7162
7660
|
archivedTasks: archived?.tasks,
|
|
7163
7661
|
archivedSlugs: archived ? taskFileSlugs(archived) : void 0
|
|
7164
7662
|
});
|
|
7165
7663
|
}
|
|
7166
|
-
const requestedTags = raw.tag ?? [];
|
|
7167
7664
|
const filtered = candidates.filter(
|
|
7168
|
-
(t) => (
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
)
|
|
7172
|
-
)
|
|
7665
|
+
(t) => taskMatchesFilters(t, filters, {
|
|
7666
|
+
ignoreStatus: Boolean(raw.available || raw.blocked)
|
|
7667
|
+
})
|
|
7173
7668
|
).slice(0, raw.limit);
|
|
7174
7669
|
if (raw.json) {
|
|
7175
7670
|
const tasks = filtered.map((t) => ({
|
|
@@ -7177,9 +7672,16 @@ function createCli(opts) {
|
|
|
7177
7672
|
...t.frontmatter,
|
|
7178
7673
|
depends_on: t.frontmatter.depends_on ?? [],
|
|
7179
7674
|
...boardOrder ? { position: boardOrder.positions.get(t.slug) } : {},
|
|
7180
|
-
...raw.includeBody ? {
|
|
7675
|
+
...raw.includeBody ? {
|
|
7676
|
+
body: t.body,
|
|
7677
|
+
comments: t.comments,
|
|
7678
|
+
...t.unreadableUpdates ? { unreadable_updates: t.unreadableUpdates } : {}
|
|
7679
|
+
} : {}
|
|
7181
7680
|
}));
|
|
7182
|
-
const
|
|
7681
|
+
const unreadable = result.unreadable.map(
|
|
7682
|
+
(file) => unreadableFileJson(file, Boolean(raw.includeBody))
|
|
7683
|
+
);
|
|
7684
|
+
const payload = raw.archived ? { archived: true, tasks, unreadable, warnings: result.warnings } : { tasks, unreadable, warnings: result.warnings };
|
|
7183
7685
|
data(JSON.stringify(payload, null, 2));
|
|
7184
7686
|
return;
|
|
7185
7687
|
}
|
|
@@ -7187,6 +7689,7 @@ function createCli(opts) {
|
|
|
7187
7689
|
for (const t of filtered) {
|
|
7188
7690
|
data(`[${t.frontmatter.status}] ${t.frontmatter.title} (${t.slug})`);
|
|
7189
7691
|
}
|
|
7692
|
+
for (const file of result.unreadable) data(formatUnreadableFile(file));
|
|
7190
7693
|
if (result.warnings.length > 0) {
|
|
7191
7694
|
chrome("");
|
|
7192
7695
|
chrome("Warnings:");
|
|
@@ -7195,7 +7698,42 @@ function createCli(opts) {
|
|
|
7195
7698
|
}
|
|
7196
7699
|
}
|
|
7197
7700
|
});
|
|
7198
|
-
task.command("search <query>").description(
|
|
7701
|
+
const searchCommand = task.command("search <query>").description(
|
|
7702
|
+
"Search task titles, tags, Markdown descriptions, and Task Updates"
|
|
7703
|
+
);
|
|
7704
|
+
searchCommand.addOption(
|
|
7705
|
+
new Option(
|
|
7706
|
+
"-s, --status <statuses>",
|
|
7707
|
+
"Filter by status (comma-separated or repeatable; matches any)"
|
|
7708
|
+
).argParser(accumulateCommaList)
|
|
7709
|
+
).addOption(
|
|
7710
|
+
new Option(
|
|
7711
|
+
"-a, --assignee <assignees>",
|
|
7712
|
+
"Filter by assignee (comma-separated or repeatable; matches any)"
|
|
7713
|
+
).argParser(accumulateCommaList)
|
|
7714
|
+
).addOption(
|
|
7715
|
+
new Option(
|
|
7716
|
+
"-p, --priority <priorities>",
|
|
7717
|
+
"Filter by priority (comma-separated or repeatable; matches any)"
|
|
7718
|
+
).argParser(accumulateCommaList)
|
|
7719
|
+
).option(
|
|
7720
|
+
"--tag <tag>",
|
|
7721
|
+
"Filter by tag (comma-separated or repeatable with AND semantics)",
|
|
7722
|
+
accumulateCommaList
|
|
7723
|
+
).addOption(
|
|
7724
|
+
new Option(
|
|
7725
|
+
"--available",
|
|
7726
|
+
"Restrict to tasks whose dependencies are satisfied (ranked like `task list`, live tasks only)"
|
|
7727
|
+
).conflicts("blocked")
|
|
7728
|
+
).addOption(
|
|
7729
|
+
new Option(
|
|
7730
|
+
"--blocked",
|
|
7731
|
+
"Restrict to tasks with unsatisfied dependencies (live tasks only)"
|
|
7732
|
+
).conflicts("available")
|
|
7733
|
+
).option(
|
|
7734
|
+
"--whole-word",
|
|
7735
|
+
"Match each term on word boundaries instead of as a substring"
|
|
7736
|
+
).option("--archived", "Search archived tasks instead of live tasks").addOption(
|
|
7199
7737
|
new Option("--all", "Search both live and archived tasks").conflicts(
|
|
7200
7738
|
"archived"
|
|
7201
7739
|
)
|
|
@@ -7203,32 +7741,98 @@ function createCli(opts) {
|
|
|
7203
7741
|
"--limit <n>",
|
|
7204
7742
|
"Maximum number of matches to return (0 returns none)",
|
|
7205
7743
|
parseNonNegativeInteger
|
|
7206
|
-
).option("--json", "Emit machine-readable JSON instead of text").option(
|
|
7744
|
+
).option("--json", "Emit machine-readable JSON instead of text").option(
|
|
7745
|
+
"--include-body",
|
|
7746
|
+
"Include full descriptions and Task Updates in JSON output"
|
|
7747
|
+
).action(async (query, raw) => {
|
|
7207
7748
|
if (!query.trim()) {
|
|
7208
7749
|
throw new InvalidArgumentError("Search query must not be blank.");
|
|
7209
7750
|
}
|
|
7751
|
+
if ((raw.available || raw.blocked) && (raw.archived || raw.all)) {
|
|
7752
|
+
throw new InvalidArgumentError(
|
|
7753
|
+
"--available and --blocked cannot be used with --archived or --all."
|
|
7754
|
+
);
|
|
7755
|
+
}
|
|
7210
7756
|
const config = await loadCliConfig();
|
|
7211
|
-
const
|
|
7212
|
-
const
|
|
7213
|
-
const
|
|
7757
|
+
const filters = resolveTaskFilters(searchCommand, raw, config);
|
|
7758
|
+
const availabilityStatus = filters.statuses.length > 0 ? filters.statuses : void 0;
|
|
7759
|
+
const searchArchive = Boolean(raw.archived || raw.all);
|
|
7760
|
+
const searchLive = !raw.archived || Boolean(raw.all);
|
|
7761
|
+
const readArchive = searchArchive || Boolean(raw.available || raw.blocked);
|
|
7762
|
+
const liveResult = searchLive ? await listTasks(adapter, config) : void 0;
|
|
7763
|
+
const archivedResult = readArchive ? await listArchivedTasks(adapter, config) : void 0;
|
|
7764
|
+
let candidates = [
|
|
7214
7765
|
...liveResult?.tasks ?? [],
|
|
7215
|
-
...archivedResult?.tasks ?? []
|
|
7766
|
+
...searchArchive ? archivedResult?.tasks ?? [] : []
|
|
7216
7767
|
];
|
|
7217
|
-
|
|
7768
|
+
if (raw.available || raw.blocked) {
|
|
7769
|
+
const select = raw.available ? listAvailableTasks : listBlockedTasks;
|
|
7770
|
+
const eligible = new Set(
|
|
7771
|
+
select(candidates, config, {
|
|
7772
|
+
status: availabilityStatus,
|
|
7773
|
+
archivedTasks: archivedResult?.tasks,
|
|
7774
|
+
archivedSlugs: archivedResult ? taskFileSlugs(archivedResult) : void 0
|
|
7775
|
+
}).map((task2) => task2.slug)
|
|
7776
|
+
);
|
|
7777
|
+
candidates = candidates.filter((task2) => eligible.has(task2.slug));
|
|
7778
|
+
}
|
|
7779
|
+
candidates = candidates.filter(
|
|
7780
|
+
(task2) => taskMatchesFilters(task2, filters, {
|
|
7781
|
+
ignoreStatus: Boolean(raw.available || raw.blocked)
|
|
7782
|
+
})
|
|
7783
|
+
);
|
|
7784
|
+
const archivedSlugs = new Set(
|
|
7785
|
+
(searchArchive ? archivedResult?.tasks ?? [] : []).map(
|
|
7786
|
+
(candidate) => candidate.slug
|
|
7787
|
+
)
|
|
7788
|
+
);
|
|
7789
|
+
const locationOf = (slug) => archivedSlugs.has(slug) ? "archive" : "live";
|
|
7790
|
+
const allMatches = searchTasks(candidates, query, {
|
|
7791
|
+
wholeWord: Boolean(raw.wholeWord)
|
|
7792
|
+
});
|
|
7218
7793
|
const matches = allMatches.slice(0, raw.limit);
|
|
7219
7794
|
const warnings = [
|
|
7220
7795
|
...liveResult?.warnings ?? [],
|
|
7221
|
-
...archivedResult?.warnings ?? []
|
|
7796
|
+
...searchArchive ? archivedResult?.warnings ?? [] : []
|
|
7797
|
+
];
|
|
7798
|
+
const unreadable = [
|
|
7799
|
+
...liveResult?.unreadable ?? [],
|
|
7800
|
+
...searchArchive ? archivedResult?.unreadable ?? [] : []
|
|
7222
7801
|
];
|
|
7223
7802
|
if (raw.json) {
|
|
7224
7803
|
const tasksBySlug = new Map(
|
|
7225
7804
|
candidates.map((candidate) => [candidate.slug, candidate])
|
|
7226
7805
|
);
|
|
7227
|
-
const payloadMatches = matches.map((match) =>
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7806
|
+
const payloadMatches = matches.map((match) => {
|
|
7807
|
+
const source = tasksBySlug.get(match.slug);
|
|
7808
|
+
return {
|
|
7809
|
+
slug: match.slug,
|
|
7810
|
+
title: match.title,
|
|
7811
|
+
status: match.status,
|
|
7812
|
+
location: locationOf(match.slug),
|
|
7813
|
+
matched_fields: match.matched_fields,
|
|
7814
|
+
...match.snippet !== void 0 ? { snippet: match.snippet } : {},
|
|
7815
|
+
...match.update_matches ? { update_matches: match.update_matches } : {},
|
|
7816
|
+
...raw.includeBody ? {
|
|
7817
|
+
body: source?.body ?? "",
|
|
7818
|
+
comments: source?.comments ?? []
|
|
7819
|
+
} : {}
|
|
7820
|
+
};
|
|
7821
|
+
});
|
|
7822
|
+
data(
|
|
7823
|
+
JSON.stringify(
|
|
7824
|
+
{
|
|
7825
|
+
matches: payloadMatches,
|
|
7826
|
+
total_matches: allMatches.length,
|
|
7827
|
+
unreadable: unreadable.map(
|
|
7828
|
+
(file) => unreadableFileJson(file, Boolean(raw.includeBody))
|
|
7829
|
+
),
|
|
7830
|
+
warnings
|
|
7831
|
+
},
|
|
7832
|
+
null,
|
|
7833
|
+
2
|
|
7834
|
+
)
|
|
7835
|
+
);
|
|
7232
7836
|
return;
|
|
7233
7837
|
}
|
|
7234
7838
|
if (allMatches.length === 0) {
|
|
@@ -7239,11 +7843,23 @@ function createCli(opts) {
|
|
|
7239
7843
|
}
|
|
7240
7844
|
for (const match of matches) {
|
|
7241
7845
|
data(
|
|
7242
|
-
`${match.title} (${match.slug}) [${match.matched_fields.join(", ")}]`
|
|
7846
|
+
`${match.title} (${match.slug}) [${locationOf(match.slug)} \xB7 ${match.status}] [${match.matched_fields.join(", ")}]`
|
|
7243
7847
|
);
|
|
7244
7848
|
if (match.snippet) data(` ${match.snippet}`);
|
|
7849
|
+
for (const updateMatch of match.update_matches ?? []) {
|
|
7850
|
+
data(
|
|
7851
|
+
"unreadable" in updateMatch ? ` \u21B3 update (unreadable): ${updateMatch.snippet}` : ` \u21B3 update ${updateMatch.index} (${updateMatch.timestamp}): ${updateMatch.snippet}`
|
|
7852
|
+
);
|
|
7853
|
+
}
|
|
7854
|
+
}
|
|
7855
|
+
const omitted = allMatches.length - matches.length;
|
|
7856
|
+
if (omitted > 0) {
|
|
7857
|
+
data(
|
|
7858
|
+
`\u2026 ${omitted} of ${allMatches.length} ${allMatches.length === 1 ? "match" : "matches"} not shown (raise --limit)`
|
|
7859
|
+
);
|
|
7245
7860
|
}
|
|
7246
7861
|
}
|
|
7862
|
+
for (const file of unreadable) data(formatUnreadableFile(file));
|
|
7247
7863
|
if (warnings.length > 0) {
|
|
7248
7864
|
chrome("");
|
|
7249
7865
|
chrome("Warnings:");
|