shipbench 0.4.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 +694 -149
- 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";
|
|
@@ -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
|
-
|
|
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
|
|
4071
|
-
|
|
4072
|
-
|
|
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
|
|
4118
|
-
|
|
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
|
|
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
|
|
4127
|
-
|
|
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
|
|
4139
|
-
|
|
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
|
|
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
|
|
4189
|
+
if (finalError) return unreadable(finalError);
|
|
4153
4190
|
if (comments.length === 0) {
|
|
4154
|
-
return
|
|
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
|
|
4207
|
-
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
|
+
}
|
|
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.
|
|
4221
|
-
|
|
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 (
|
|
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 =
|
|
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
|
-
|
|
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}": ${
|
|
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
|
|
4390
|
-
|
|
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(
|
|
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 =
|
|
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 =
|
|
4568
|
+
const path = taskPath(slug);
|
|
4498
4569
|
const content = await adapter.readFile(path);
|
|
4499
|
-
const task = parseTaskFile(slug, content);
|
|
4500
|
-
if (
|
|
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 (
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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(
|
|
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 =
|
|
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(
|
|
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 =
|
|
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(
|
|
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
|
|
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
|
|
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\`.
|
|
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.
|
|
@@ -5136,61 +5213,135 @@ async function initProject(adapter, options2) {
|
|
|
5136
5213
|
// ../../packages/core/src/search.ts
|
|
5137
5214
|
var SNIPPET_CONTEXT_BEFORE = 40;
|
|
5138
5215
|
var SNIPPET_CONTEXT_AFTER = 80;
|
|
5139
|
-
|
|
5140
|
-
|
|
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();
|
|
5141
5245
|
let matchIndex = -1;
|
|
5142
5246
|
let matchLength = 0;
|
|
5143
|
-
for (const term of
|
|
5144
|
-
const
|
|
5145
|
-
if (
|
|
5146
|
-
matchIndex =
|
|
5147
|
-
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;
|
|
5148
5252
|
}
|
|
5149
5253
|
}
|
|
5150
5254
|
if (matchIndex === -1) return void 0;
|
|
5151
5255
|
const start = Math.max(0, matchIndex - SNIPPET_CONTEXT_BEFORE);
|
|
5152
5256
|
const end = Math.min(
|
|
5153
|
-
|
|
5257
|
+
normalizedText.length,
|
|
5154
5258
|
matchIndex + matchLength + SNIPPET_CONTEXT_AFTER
|
|
5155
5259
|
);
|
|
5156
|
-
const excerpt =
|
|
5157
|
-
return `${start > 0 ? "\u2026" : ""}${excerpt}${end <
|
|
5158
|
-
}
|
|
5159
|
-
function searchTasks(tasks, query) {
|
|
5160
|
-
const
|
|
5161
|
-
if (
|
|
5162
|
-
const
|
|
5163
|
-
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 = [];
|
|
5164
5267
|
for (const task of tasks) {
|
|
5165
5268
|
const normalizedTitle = task.frontmatter.title.toLowerCase();
|
|
5166
5269
|
const normalizedTags = (task.frontmatter.tags ?? []).map(
|
|
5167
5270
|
(tag) => tag.toLowerCase()
|
|
5168
5271
|
);
|
|
5169
|
-
const normalizedBody = task.body
|
|
5272
|
+
const normalizedBody = normalizeText(task.body);
|
|
5170
5273
|
const lowercaseBody = normalizedBody.toLowerCase();
|
|
5171
|
-
const
|
|
5172
|
-
|
|
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)
|
|
5173
5289
|
);
|
|
5174
|
-
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;
|
|
5175
5305
|
const matchedFields = [];
|
|
5176
|
-
if (
|
|
5177
|
-
|
|
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);
|
|
5306
|
+
if (titleTerms > 0) matchedFields.push("title");
|
|
5307
|
+
if (tagTerms > 0) matchedFields.push("tags");
|
|
5308
|
+
const snippet = snippetAround(normalizedBody, terms);
|
|
5185
5309
|
if (snippet !== void 0) matchedFields.push("body");
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
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
|
|
5191
5340
|
});
|
|
5192
5341
|
}
|
|
5193
|
-
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);
|
|
5194
5345
|
}
|
|
5195
5346
|
|
|
5196
5347
|
// src/harborConnect.ts
|
|
@@ -5426,7 +5577,7 @@ import {
|
|
|
5426
5577
|
createServer
|
|
5427
5578
|
} from "http";
|
|
5428
5579
|
import { createRequire } from "module";
|
|
5429
|
-
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";
|
|
5430
5581
|
import { platform } from "process";
|
|
5431
5582
|
|
|
5432
5583
|
// src/tui/paths.ts
|
|
@@ -5489,6 +5640,7 @@ function isValidationError(error) {
|
|
|
5489
5640
|
);
|
|
5490
5641
|
}
|
|
5491
5642
|
function coreErrorStatus(error) {
|
|
5643
|
+
if (error instanceof UnreadableTaskError) return 422;
|
|
5492
5644
|
if (isNotFoundError(error)) return 404;
|
|
5493
5645
|
if (error instanceof ArchiveBlockedError) return 409;
|
|
5494
5646
|
if (isValidationError(error)) return 400;
|
|
@@ -5569,10 +5721,10 @@ function contentType(path) {
|
|
|
5569
5721
|
async function serveStatic(req, res, bundleDir) {
|
|
5570
5722
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
5571
5723
|
const pathname = decodeURIComponent(url.pathname);
|
|
5572
|
-
const
|
|
5724
|
+
const relative2 = pathname === "/" ? "/standalone.html" : pathname;
|
|
5573
5725
|
const root = resolve2(bundleDir);
|
|
5574
|
-
const target = resolve2(root, `.${
|
|
5575
|
-
if (target !== root && !target.startsWith(`${root}${
|
|
5726
|
+
const target = resolve2(root, `.${relative2}`);
|
|
5727
|
+
if (target !== root && !target.startsWith(`${root}${sep2}`)) {
|
|
5576
5728
|
sendError(res, 403, "Forbidden");
|
|
5577
5729
|
return;
|
|
5578
5730
|
}
|
|
@@ -5589,6 +5741,24 @@ async function serveStatic(req, res, bundleDir) {
|
|
|
5589
5741
|
throw error;
|
|
5590
5742
|
}
|
|
5591
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
|
+
}
|
|
5592
5762
|
function createBoardRequestHandler(adapter, bundleDir, warn) {
|
|
5593
5763
|
const eventClients = /* @__PURE__ */ new Set();
|
|
5594
5764
|
const loadServerConfig = () => loadConfig(adapter, {
|
|
@@ -5755,6 +5925,11 @@ function createBoardRequestHandler(adapter, bundleDir, warn) {
|
|
|
5755
5925
|
return {
|
|
5756
5926
|
async handle(req, res) {
|
|
5757
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
|
+
}
|
|
5758
5933
|
try {
|
|
5759
5934
|
if (url.pathname.startsWith("/api/")) {
|
|
5760
5935
|
await handleApi(req, res, url);
|
|
@@ -6060,6 +6235,9 @@ async function readBoard(adapter, filters) {
|
|
|
6060
6235
|
archived.tasks,
|
|
6061
6236
|
archivedSlugs
|
|
6062
6237
|
);
|
|
6238
|
+
if (live.unreadable.length > 0) {
|
|
6239
|
+
model.unreadableCount = live.unreadable.length;
|
|
6240
|
+
}
|
|
6063
6241
|
const configWarning = configWarnings[0];
|
|
6064
6242
|
if (configWarning) {
|
|
6065
6243
|
model.notice = `${configWarning.path}: ${configWarning.message}`;
|
|
@@ -6394,6 +6572,11 @@ function statusLine(model, plan, width, options2) {
|
|
|
6394
6572
|
const alerts = [];
|
|
6395
6573
|
if (model.notice) alerts.push(style(`${BOX.warn} ${model.notice}`, "yellow"));
|
|
6396
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
|
+
}
|
|
6397
6580
|
if (model.warnings.length > 0) {
|
|
6398
6581
|
alerts.push(
|
|
6399
6582
|
style(`${BOX.warn} ${model.warnings.length} warnings`, "yellow")
|
|
@@ -6627,13 +6810,70 @@ async function runTui(options2) {
|
|
|
6627
6810
|
}
|
|
6628
6811
|
|
|
6629
6812
|
// src/cli.ts
|
|
6630
|
-
var VERSION = true ? "0.
|
|
6813
|
+
var VERSION = true ? "0.5.0" : "0.0.0-dev";
|
|
6631
6814
|
function commaList(value) {
|
|
6632
6815
|
return value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
6633
6816
|
}
|
|
6634
6817
|
function accumulateCommaList(value, previous) {
|
|
6635
6818
|
return [...previous ?? [], ...commaList(value)];
|
|
6636
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
|
+
}
|
|
6637
6877
|
function parsePort(value) {
|
|
6638
6878
|
const port = Number(value);
|
|
6639
6879
|
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
@@ -6747,6 +6987,17 @@ function enableExitOverride(command) {
|
|
|
6747
6987
|
command.exitOverride();
|
|
6748
6988
|
for (const child of command.commands) enableExitOverride(child);
|
|
6749
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
|
+
}
|
|
6750
7001
|
function formatProjectWarning(warning) {
|
|
6751
7002
|
const source = "path" in warning ? warning.path : warning.slug;
|
|
6752
7003
|
return `${source}: ${warning.message}`;
|
|
@@ -6949,15 +7200,79 @@ function createCli(opts) {
|
|
|
6949
7200
|
}
|
|
6950
7201
|
chrome(`Created task: ${created.slug}`);
|
|
6951
7202
|
});
|
|
6952
|
-
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(
|
|
6953
7258
|
"after",
|
|
6954
|
-
"\
|
|
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"
|
|
6955
7260
|
);
|
|
6956
7261
|
editCommand.action(async (slug, raw) => {
|
|
6957
7262
|
const body = await resolveBody(raw);
|
|
6958
|
-
|
|
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) {
|
|
6959
7274
|
editCommand.error(
|
|
6960
|
-
|
|
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."
|
|
6961
7276
|
);
|
|
6962
7277
|
return;
|
|
6963
7278
|
}
|
|
@@ -6970,7 +7285,95 @@ function createCli(opts) {
|
|
|
6970
7285
|
);
|
|
6971
7286
|
return;
|
|
6972
7287
|
}
|
|
6973
|
-
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
|
+
);
|
|
6974
7377
|
if (raw.json) {
|
|
6975
7378
|
data(
|
|
6976
7379
|
JSON.stringify(
|
|
@@ -6987,9 +7390,10 @@ function createCli(opts) {
|
|
|
6987
7390
|
);
|
|
6988
7391
|
return;
|
|
6989
7392
|
}
|
|
6990
|
-
chrome(
|
|
6991
|
-
|
|
6992
|
-
|
|
7393
|
+
chrome(`Updated ${edited.slug}: ${changes.join("; ")}`);
|
|
7394
|
+
if (fields.title !== void 0) {
|
|
7395
|
+
chrome(`Slug and filename unchanged: ${edited.slug}`);
|
|
7396
|
+
}
|
|
6993
7397
|
});
|
|
6994
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";
|
|
6995
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);
|
|
@@ -7053,6 +7457,10 @@ function createCli(opts) {
|
|
|
7053
7457
|
getTaskCommand.error(`Task '${slug}' not found.`);
|
|
7054
7458
|
return;
|
|
7055
7459
|
}
|
|
7460
|
+
const updatesWarning = unreadableUpdatesWarning(found);
|
|
7461
|
+
if (updatesWarning) {
|
|
7462
|
+
output.warning(`${found.slug}: ${updatesWarning.message}`);
|
|
7463
|
+
}
|
|
7056
7464
|
data(
|
|
7057
7465
|
JSON.stringify(
|
|
7058
7466
|
{
|
|
@@ -7060,7 +7468,8 @@ function createCli(opts) {
|
|
|
7060
7468
|
status: found.frontmatter.status,
|
|
7061
7469
|
frontmatter: found.frontmatter,
|
|
7062
7470
|
body: found.body,
|
|
7063
|
-
comments: found.comments
|
|
7471
|
+
comments: found.comments,
|
|
7472
|
+
...found.unreadableUpdates ? { unreadable_updates: found.unreadableUpdates } : {}
|
|
7064
7473
|
},
|
|
7065
7474
|
null,
|
|
7066
7475
|
2
|
|
@@ -7187,7 +7596,23 @@ function createCli(opts) {
|
|
|
7187
7596
|
);
|
|
7188
7597
|
chrome("Wrote .shipbench/layout.json");
|
|
7189
7598
|
});
|
|
7190
|
-
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(
|
|
7191
7616
|
"--tag <tag>",
|
|
7192
7617
|
"Filter by tag (comma-separated or repeatable with AND semantics)",
|
|
7193
7618
|
accumulateCommaList
|
|
@@ -7215,6 +7640,8 @@ function createCli(opts) {
|
|
|
7215
7640
|
);
|
|
7216
7641
|
}
|
|
7217
7642
|
const config = await loadCliConfig();
|
|
7643
|
+
const filters = resolveTaskFilters(listCommand, raw, config);
|
|
7644
|
+
const availabilityStatus = filters.statuses.length > 0 ? filters.statuses : void 0;
|
|
7218
7645
|
const archivedPromise = raw.archived ? void 0 : listArchivedTasks(adapter, config);
|
|
7219
7646
|
const result = raw.archived ? await listArchivedTasks(adapter, config) : await listTasks(adapter, config, {
|
|
7220
7647
|
archivedTasks: archivedPromise?.then((result2) => result2.tasks),
|
|
@@ -7225,22 +7652,19 @@ function createCli(opts) {
|
|
|
7225
7652
|
let candidates = boardOrder?.tasks ?? result.tasks;
|
|
7226
7653
|
if (raw.available || raw.blocked) {
|
|
7227
7654
|
candidates = raw.available ? listAvailableTasks(candidates, config, {
|
|
7228
|
-
status:
|
|
7655
|
+
status: availabilityStatus,
|
|
7229
7656
|
archivedTasks: archived?.tasks,
|
|
7230
7657
|
archivedSlugs: archived ? taskFileSlugs(archived) : void 0
|
|
7231
7658
|
}) : listBlockedTasks(candidates, config, {
|
|
7232
|
-
status:
|
|
7659
|
+
status: availabilityStatus,
|
|
7233
7660
|
archivedTasks: archived?.tasks,
|
|
7234
7661
|
archivedSlugs: archived ? taskFileSlugs(archived) : void 0
|
|
7235
7662
|
});
|
|
7236
7663
|
}
|
|
7237
|
-
const requestedTags = raw.tag ?? [];
|
|
7238
7664
|
const filtered = candidates.filter(
|
|
7239
|
-
(t) => (
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
)
|
|
7243
|
-
)
|
|
7665
|
+
(t) => taskMatchesFilters(t, filters, {
|
|
7666
|
+
ignoreStatus: Boolean(raw.available || raw.blocked)
|
|
7667
|
+
})
|
|
7244
7668
|
).slice(0, raw.limit);
|
|
7245
7669
|
if (raw.json) {
|
|
7246
7670
|
const tasks = filtered.map((t) => ({
|
|
@@ -7248,9 +7672,16 @@ function createCli(opts) {
|
|
|
7248
7672
|
...t.frontmatter,
|
|
7249
7673
|
depends_on: t.frontmatter.depends_on ?? [],
|
|
7250
7674
|
...boardOrder ? { position: boardOrder.positions.get(t.slug) } : {},
|
|
7251
|
-
...raw.includeBody ? {
|
|
7675
|
+
...raw.includeBody ? {
|
|
7676
|
+
body: t.body,
|
|
7677
|
+
comments: t.comments,
|
|
7678
|
+
...t.unreadableUpdates ? { unreadable_updates: t.unreadableUpdates } : {}
|
|
7679
|
+
} : {}
|
|
7252
7680
|
}));
|
|
7253
|
-
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 };
|
|
7254
7685
|
data(JSON.stringify(payload, null, 2));
|
|
7255
7686
|
return;
|
|
7256
7687
|
}
|
|
@@ -7258,6 +7689,7 @@ function createCli(opts) {
|
|
|
7258
7689
|
for (const t of filtered) {
|
|
7259
7690
|
data(`[${t.frontmatter.status}] ${t.frontmatter.title} (${t.slug})`);
|
|
7260
7691
|
}
|
|
7692
|
+
for (const file of result.unreadable) data(formatUnreadableFile(file));
|
|
7261
7693
|
if (result.warnings.length > 0) {
|
|
7262
7694
|
chrome("");
|
|
7263
7695
|
chrome("Warnings:");
|
|
@@ -7266,7 +7698,42 @@ function createCli(opts) {
|
|
|
7266
7698
|
}
|
|
7267
7699
|
}
|
|
7268
7700
|
});
|
|
7269
|
-
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(
|
|
7270
7737
|
new Option("--all", "Search both live and archived tasks").conflicts(
|
|
7271
7738
|
"archived"
|
|
7272
7739
|
)
|
|
@@ -7274,32 +7741,98 @@ function createCli(opts) {
|
|
|
7274
7741
|
"--limit <n>",
|
|
7275
7742
|
"Maximum number of matches to return (0 returns none)",
|
|
7276
7743
|
parseNonNegativeInteger
|
|
7277
|
-
).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) => {
|
|
7278
7748
|
if (!query.trim()) {
|
|
7279
7749
|
throw new InvalidArgumentError("Search query must not be blank.");
|
|
7280
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
|
+
}
|
|
7281
7756
|
const config = await loadCliConfig();
|
|
7282
|
-
const
|
|
7283
|
-
const
|
|
7284
|
-
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 = [
|
|
7285
7765
|
...liveResult?.tasks ?? [],
|
|
7286
|
-
...archivedResult?.tasks ?? []
|
|
7766
|
+
...searchArchive ? archivedResult?.tasks ?? [] : []
|
|
7287
7767
|
];
|
|
7288
|
-
|
|
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
|
+
});
|
|
7289
7793
|
const matches = allMatches.slice(0, raw.limit);
|
|
7290
7794
|
const warnings = [
|
|
7291
7795
|
...liveResult?.warnings ?? [],
|
|
7292
|
-
...archivedResult?.warnings ?? []
|
|
7796
|
+
...searchArchive ? archivedResult?.warnings ?? [] : []
|
|
7797
|
+
];
|
|
7798
|
+
const unreadable = [
|
|
7799
|
+
...liveResult?.unreadable ?? [],
|
|
7800
|
+
...searchArchive ? archivedResult?.unreadable ?? [] : []
|
|
7293
7801
|
];
|
|
7294
7802
|
if (raw.json) {
|
|
7295
7803
|
const tasksBySlug = new Map(
|
|
7296
7804
|
candidates.map((candidate) => [candidate.slug, candidate])
|
|
7297
7805
|
);
|
|
7298
|
-
const payloadMatches = matches.map((match) =>
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
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
|
+
);
|
|
7303
7836
|
return;
|
|
7304
7837
|
}
|
|
7305
7838
|
if (allMatches.length === 0) {
|
|
@@ -7310,11 +7843,23 @@ function createCli(opts) {
|
|
|
7310
7843
|
}
|
|
7311
7844
|
for (const match of matches) {
|
|
7312
7845
|
data(
|
|
7313
|
-
`${match.title} (${match.slug}) [${match.matched_fields.join(", ")}]`
|
|
7846
|
+
`${match.title} (${match.slug}) [${locationOf(match.slug)} \xB7 ${match.status}] [${match.matched_fields.join(", ")}]`
|
|
7314
7847
|
);
|
|
7315
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
|
+
);
|
|
7316
7860
|
}
|
|
7317
7861
|
}
|
|
7862
|
+
for (const file of unreadable) data(formatUnreadableFile(file));
|
|
7318
7863
|
if (warnings.length > 0) {
|
|
7319
7864
|
chrome("");
|
|
7320
7865
|
chrome("Warnings:");
|