shipbench 0.7.1 → 0.8.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/dist/index.js +151 -372
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3521,10 +3521,19 @@ var require_gray_matter = __commonJS({
|
|
|
3521
3521
|
}
|
|
3522
3522
|
});
|
|
3523
3523
|
|
|
3524
|
-
// src/
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3524
|
+
// src/errors.ts
|
|
3525
|
+
var CliExitError = class extends Error {
|
|
3526
|
+
constructor(message2, exitCode) {
|
|
3527
|
+
super(message2);
|
|
3528
|
+
this.exitCode = exitCode;
|
|
3529
|
+
this.name = "CliExitError";
|
|
3530
|
+
}
|
|
3531
|
+
exitCode;
|
|
3532
|
+
};
|
|
3533
|
+
|
|
3534
|
+
// src/processCli.ts
|
|
3535
|
+
import { existsSync, statSync } from "fs";
|
|
3536
|
+
import { basename, dirname as dirname3, join as join4, resolve as resolve2 } from "path";
|
|
3528
3537
|
|
|
3529
3538
|
// ../../packages/core/src/adapters/fs.ts
|
|
3530
3539
|
import { mkdir, readdir, readFile, unlink, writeFile } from "fs/promises";
|
|
@@ -3926,49 +3935,6 @@ function isTaskFlagged(task) {
|
|
|
3926
3935
|
return taskFlag(task) !== null;
|
|
3927
3936
|
}
|
|
3928
3937
|
|
|
3929
|
-
// ../../packages/core/src/github-url.ts
|
|
3930
|
-
var GITHUB_URL_RE = /^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9._-]*)\/([A-Za-z0-9][A-Za-z0-9._-]*?)(?:\.git)?\/?$/;
|
|
3931
|
-
var GITHUB_SCP_REMOTE_RE = /^git@github\.com:([A-Za-z0-9][A-Za-z0-9._-]*)\/([A-Za-z0-9][A-Za-z0-9._-]*?)(?:\.git)?$/;
|
|
3932
|
-
var GITHUB_SSH_PATH_RE = /^\/([A-Za-z0-9][A-Za-z0-9._-]*)\/([A-Za-z0-9][A-Za-z0-9._-]*?)(?:\.git)?\/?$/;
|
|
3933
|
-
function validParts(owner, repo) {
|
|
3934
|
-
return owner !== "." && owner !== ".." && repo !== "." && repo !== "..";
|
|
3935
|
-
}
|
|
3936
|
-
function parseGithubUrl(input) {
|
|
3937
|
-
const match = GITHUB_URL_RE.exec(input.trim());
|
|
3938
|
-
if (!match) return null;
|
|
3939
|
-
const owner = match[1];
|
|
3940
|
-
const repo = match[2];
|
|
3941
|
-
return validParts(owner, repo) ? { owner, repo } : null;
|
|
3942
|
-
}
|
|
3943
|
-
function parseGithubRemoteUrl(input) {
|
|
3944
|
-
const https = parseGithubUrl(input);
|
|
3945
|
-
if (https) return https;
|
|
3946
|
-
const trimmed = input.trim();
|
|
3947
|
-
const scpMatch = GITHUB_SCP_REMOTE_RE.exec(trimmed);
|
|
3948
|
-
if (scpMatch) {
|
|
3949
|
-
const owner = scpMatch[1];
|
|
3950
|
-
const repo = scpMatch[2];
|
|
3951
|
-
return validParts(owner, repo) ? { owner, repo } : null;
|
|
3952
|
-
}
|
|
3953
|
-
try {
|
|
3954
|
-
const url = new URL(trimmed);
|
|
3955
|
-
if (url.protocol !== "ssh:" || url.hostname !== "github.com" || url.username !== "git" || url.password || url.port || url.search || url.hash) {
|
|
3956
|
-
return null;
|
|
3957
|
-
}
|
|
3958
|
-
const pathMatch = GITHUB_SSH_PATH_RE.exec(url.pathname);
|
|
3959
|
-
if (!pathMatch) return null;
|
|
3960
|
-
const owner = pathMatch[1];
|
|
3961
|
-
const repo = pathMatch[2];
|
|
3962
|
-
return validParts(owner, repo) ? { owner, repo } : null;
|
|
3963
|
-
} catch {
|
|
3964
|
-
return null;
|
|
3965
|
-
}
|
|
3966
|
-
}
|
|
3967
|
-
function normalizeGithubRemoteUrl(input) {
|
|
3968
|
-
const parsed = parseGithubRemoteUrl(input);
|
|
3969
|
-
return parsed ? `https://github.com/${parsed.owner}/${parsed.repo}` : null;
|
|
3970
|
-
}
|
|
3971
|
-
|
|
3972
3938
|
// ../../packages/core/src/tasks.ts
|
|
3973
3939
|
var import_gray_matter = __toESM(require_gray_matter(), 1);
|
|
3974
3940
|
|
|
@@ -4905,7 +4871,6 @@ Tasks can be managed through any combination of:
|
|
|
4905
4871
|
- **The ShipBench CLI** (\`shipbench\` commands) \u2014 recommended for scripted or agent-driven changes; centralizes slug generation, validation, timestamps, and layout updates.
|
|
4906
4872
|
- **The Board UI** (\`shipbench board\`) \u2014 local kanban in your browser, with live file watching.
|
|
4907
4873
|
- **The terminal board** (\`shipbench board terminal\`) \u2014 the same board as a read-only live view, for leaving open in a pane beside your work.
|
|
4908
|
-
- **Harbor** \u2014 hosted view for browsing project boards across repos.
|
|
4909
4874
|
- **Direct file editing** \u2014 always valid; task files are plain Markdown.
|
|
4910
4875
|
|
|
4911
4876
|
## \`config.json\` reference
|
|
@@ -4918,7 +4883,7 @@ Schema version. Currently informational. Leave as \`1\`.
|
|
|
4918
4883
|
|
|
4919
4884
|
### \`name\`
|
|
4920
4885
|
|
|
4921
|
-
The project's display name. Every consumer (CLI
|
|
4886
|
+
The project's display name. Every consumer (the CLI and the Board) reads this for the breadcrumb root. Defaults to the basename of the current directory when \`shipbench init\` runs; override with \`--name\`.
|
|
4922
4887
|
|
|
4923
4888
|
### \`columns\`
|
|
4924
4889
|
|
|
@@ -4972,7 +4937,7 @@ Visible order comes from \`config.json\`, the task files, and this partial index
|
|
|
4972
4937
|
- The Uncategorized column and the \`done_column\` both ignore \`layout\` entirely.
|
|
4973
4938
|
- The CLI and Board do not record \`layout[done_column]\`; any existing entry is removed on the next layout write.
|
|
4974
4939
|
|
|
4975
|
-
Do not read \`layout.json\` alone to determine board order. \`shipbench task list --json\` returns live tasks in canonical board order, including each task's zero-based \`position\` within its column. Direct file readers must apply the rules above. Treat the index as machine-managed: do not hand-edit or hand-order it. You may gitignore it if ordering should stay machine-local, but
|
|
4940
|
+
Do not read \`layout.json\` alone to determine board order. \`shipbench task list --json\` returns live tasks in canonical board order, including each task's zero-based \`position\` within its column. Direct file readers must apply the rules above. Treat the index as machine-managed: do not hand-edit or hand-order it. You may gitignore it if ordering should stay machine-local, but fresh clones will then fall back to deterministic \`created\`-descending order for unlisted tasks.
|
|
4976
4941
|
|
|
4977
4942
|
## Task files
|
|
4978
4943
|
|
|
@@ -5405,228 +5370,6 @@ function searchTasks(tasks, query, options2 = {}) {
|
|
|
5405
5370
|
).map((entry) => entry.match);
|
|
5406
5371
|
}
|
|
5407
5372
|
|
|
5408
|
-
// src/harborConnect.ts
|
|
5409
|
-
var CliExitError = class extends Error {
|
|
5410
|
-
constructor(message2, exitCode) {
|
|
5411
|
-
super(message2);
|
|
5412
|
-
this.exitCode = exitCode;
|
|
5413
|
-
this.name = "CliExitError";
|
|
5414
|
-
}
|
|
5415
|
-
exitCode;
|
|
5416
|
-
};
|
|
5417
|
-
var HARBOR_ERROR_MESSAGES = {
|
|
5418
|
-
INVALID_REQUEST: "Harbor rejected the connection request.",
|
|
5419
|
-
INVALID_REMOTE_URL: "The origin remote is not a supported GitHub repository URL.",
|
|
5420
|
-
INVALID_CONNECT_TOKEN: "This connect URL is invalid.",
|
|
5421
|
-
PROJECT_NOT_FOUND: "The Harbor project no longer exists.",
|
|
5422
|
-
PROJECT_ALREADY_CONNECTED: "This Harbor project is already connected to another repository.",
|
|
5423
|
-
REPOSITORY_ALREADY_CONNECTED: "This repository is already connected to another Harbor project.",
|
|
5424
|
-
CONNECT_TOKEN_USED: "This Harbor connect URL has already been used or superseded. Generate a new URL in Harbor.",
|
|
5425
|
-
CONNECT_TOKEN_EXPIRED: "This connect URL has expired. Generate a new URL in Harbor."
|
|
5426
|
-
};
|
|
5427
|
-
var runGitCommand = (cwd, args) => new Promise((resolveResult) => {
|
|
5428
|
-
execFile(
|
|
5429
|
-
"git",
|
|
5430
|
-
args,
|
|
5431
|
-
{ cwd, encoding: "utf8", windowsHide: true },
|
|
5432
|
-
(error, stdout) => {
|
|
5433
|
-
resolveResult({
|
|
5434
|
-
exitCode: typeof error?.code === "number" ? error.code : error ? 1 : 0,
|
|
5435
|
-
stdout: stdout.trim()
|
|
5436
|
-
});
|
|
5437
|
-
}
|
|
5438
|
-
);
|
|
5439
|
-
});
|
|
5440
|
-
function isLoopbackHost(hostname) {
|
|
5441
|
-
const normalized = hostname.toLowerCase();
|
|
5442
|
-
if (normalized === "localhost" || normalized === "::1" || normalized === "[::1]") {
|
|
5443
|
-
return true;
|
|
5444
|
-
}
|
|
5445
|
-
const match = /^127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(normalized);
|
|
5446
|
-
return match?.slice(1).every((part) => Number(part) >= 0 && Number(part) <= 255) === true;
|
|
5447
|
-
}
|
|
5448
|
-
function validateHarborConnectUrl(input) {
|
|
5449
|
-
const trimmed = input.trim();
|
|
5450
|
-
let parsed;
|
|
5451
|
-
try {
|
|
5452
|
-
parsed = new URL(trimmed);
|
|
5453
|
-
} catch {
|
|
5454
|
-
throw new CliExitError(
|
|
5455
|
-
"The Harbor connect URL is invalid. Generate a fresh command in Harbor.",
|
|
5456
|
-
2
|
|
5457
|
-
);
|
|
5458
|
-
}
|
|
5459
|
-
const allowedProtocol = parsed.protocol === "https:" || parsed.protocol === "http:" && isLoopbackHost(parsed.hostname);
|
|
5460
|
-
if (!allowedProtocol || parsed.username || parsed.password || parsed.hash) {
|
|
5461
|
-
throw new CliExitError(
|
|
5462
|
-
"The Harbor connect URL must use HTTPS, contain no credentials or fragment, and may use HTTP only on a loopback host.",
|
|
5463
|
-
2
|
|
5464
|
-
);
|
|
5465
|
-
}
|
|
5466
|
-
return trimmed;
|
|
5467
|
-
}
|
|
5468
|
-
async function comparablePath(path) {
|
|
5469
|
-
let canonical;
|
|
5470
|
-
try {
|
|
5471
|
-
canonical = await realpath(path);
|
|
5472
|
-
} catch {
|
|
5473
|
-
canonical = resolve(path);
|
|
5474
|
-
}
|
|
5475
|
-
const normalized = canonical.replace(/[\\/]+$/, "");
|
|
5476
|
-
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
5477
|
-
}
|
|
5478
|
-
async function prepareHarborConnection(input, cwd, runGit) {
|
|
5479
|
-
const connectUrl = validateHarborConnectUrl(input);
|
|
5480
|
-
const rootResult = await runGit(cwd, ["rev-parse", "--show-toplevel"]);
|
|
5481
|
-
if (rootResult.exitCode !== 0 || !rootResult.stdout) {
|
|
5482
|
-
throw new CliExitError(
|
|
5483
|
-
"The current directory is not a Git worktree. Run this command from a Git repository root.",
|
|
5484
|
-
2
|
|
5485
|
-
);
|
|
5486
|
-
}
|
|
5487
|
-
const [gitRoot, currentDirectory] = await Promise.all([
|
|
5488
|
-
comparablePath(rootResult.stdout),
|
|
5489
|
-
comparablePath(cwd)
|
|
5490
|
-
]);
|
|
5491
|
-
if (gitRoot !== currentDirectory) {
|
|
5492
|
-
throw new CliExitError(
|
|
5493
|
-
"Run this command from the Git worktree root, not a nested directory.",
|
|
5494
|
-
2
|
|
5495
|
-
);
|
|
5496
|
-
}
|
|
5497
|
-
return { connectUrl, cwd };
|
|
5498
|
-
}
|
|
5499
|
-
function isHarborConnectResponse(value) {
|
|
5500
|
-
return typeof value === "object" && value !== null && typeof value.message === "string" && (value.already_connected === void 0 || typeof value.already_connected === "boolean");
|
|
5501
|
-
}
|
|
5502
|
-
function isHarborConnectErrorResponse(value) {
|
|
5503
|
-
return typeof value === "object" && value !== null && typeof value.code === "string" && typeof value.error === "string";
|
|
5504
|
-
}
|
|
5505
|
-
function redactConnectCredential(text, connectUrl) {
|
|
5506
|
-
let redacted = text.replaceAll(connectUrl, "[redacted connect URL]");
|
|
5507
|
-
try {
|
|
5508
|
-
const token = new URL(connectUrl).searchParams.get("token");
|
|
5509
|
-
if (token) redacted = redacted.replaceAll(token, "[redacted token]");
|
|
5510
|
-
} catch {
|
|
5511
|
-
}
|
|
5512
|
-
return redacted;
|
|
5513
|
-
}
|
|
5514
|
-
async function collectGitVisibilityWarnings(cwd, runGit) {
|
|
5515
|
-
const [headConfig, status, upstream] = await Promise.all([
|
|
5516
|
-
runGit(cwd, ["cat-file", "-e", "HEAD:.shipbench/config.json"]),
|
|
5517
|
-
runGit(cwd, [
|
|
5518
|
-
"status",
|
|
5519
|
-
"--porcelain=v1",
|
|
5520
|
-
"--untracked-files=all",
|
|
5521
|
-
"--",
|
|
5522
|
-
".shipbench"
|
|
5523
|
-
]),
|
|
5524
|
-
runGit(cwd, [
|
|
5525
|
-
"rev-parse",
|
|
5526
|
-
"--abbrev-ref",
|
|
5527
|
-
"--symbolic-full-name",
|
|
5528
|
-
"@{upstream}"
|
|
5529
|
-
])
|
|
5530
|
-
]);
|
|
5531
|
-
const warnings = [];
|
|
5532
|
-
if (headConfig.exitCode !== 0) {
|
|
5533
|
-
warnings.push(
|
|
5534
|
-
".shipbench/config.json is absent from HEAD. Commit and push the ShipBench project before opening its board in Harbor."
|
|
5535
|
-
);
|
|
5536
|
-
}
|
|
5537
|
-
if (status.exitCode !== 0) {
|
|
5538
|
-
warnings.push("Git could not inspect uncommitted ShipBench changes.");
|
|
5539
|
-
} else if (status.stdout) {
|
|
5540
|
-
warnings.push(
|
|
5541
|
-
"ShipBench files have uncommitted changes. Commit and push them so Harbor can see the current project."
|
|
5542
|
-
);
|
|
5543
|
-
}
|
|
5544
|
-
if (upstream.exitCode !== 0 || !upstream.stdout) {
|
|
5545
|
-
warnings.push(
|
|
5546
|
-
"The current branch has no upstream. ShipBench files may not be pushed."
|
|
5547
|
-
);
|
|
5548
|
-
return warnings;
|
|
5549
|
-
}
|
|
5550
|
-
const ahead = await runGit(cwd, ["rev-list", "--count", "@{upstream}..HEAD"]);
|
|
5551
|
-
if (ahead.exitCode !== 0) {
|
|
5552
|
-
warnings.push("Git could not determine whether the branch is pushed.");
|
|
5553
|
-
return warnings;
|
|
5554
|
-
}
|
|
5555
|
-
const aheadCount = Number.parseInt(ahead.stdout, 10);
|
|
5556
|
-
if (Number.isInteger(aheadCount) && aheadCount > 0) {
|
|
5557
|
-
warnings.push(
|
|
5558
|
-
`The current branch is ${aheadCount} ${aheadCount === 1 ? "commit" : "commits"} ahead of its upstream. Push it so Harbor can see the current project.`
|
|
5559
|
-
);
|
|
5560
|
-
}
|
|
5561
|
-
return warnings;
|
|
5562
|
-
}
|
|
5563
|
-
function indeterminateError(operationStatus) {
|
|
5564
|
-
return new CliExitError(
|
|
5565
|
-
`${operationStatus} Harbor's result is unknown. Check the project in Harbor before retrying. No automatic retry was sent.`,
|
|
5566
|
-
4
|
|
5567
|
-
);
|
|
5568
|
-
}
|
|
5569
|
-
async function connectPreparedProjectToHarbor(options2) {
|
|
5570
|
-
const { prepared, runGit, fetch: fetchImpl, warn, operationStatus } = options2;
|
|
5571
|
-
const remote = await runGit(prepared.cwd, ["remote", "get-url", "origin"]);
|
|
5572
|
-
if (remote.exitCode !== 0 || !remote.stdout) {
|
|
5573
|
-
throw new CliExitError(
|
|
5574
|
-
`${operationStatus} No GitHub origin remote was found. Add an origin, then rerun the command. Harbor was not contacted.`,
|
|
5575
|
-
2
|
|
5576
|
-
);
|
|
5577
|
-
}
|
|
5578
|
-
const normalizedRemote = normalizeGithubRemoteUrl(remote.stdout);
|
|
5579
|
-
if (!normalizedRemote) {
|
|
5580
|
-
throw new CliExitError(
|
|
5581
|
-
`${operationStatus} The origin is not a supported GitHub repository URL. Use a GitHub HTTPS, scp-style SSH, or ssh://git@github.com remote. Harbor was not contacted.`,
|
|
5582
|
-
2
|
|
5583
|
-
);
|
|
5584
|
-
}
|
|
5585
|
-
for (const warning of await collectGitVisibilityWarnings(
|
|
5586
|
-
prepared.cwd,
|
|
5587
|
-
runGit
|
|
5588
|
-
)) {
|
|
5589
|
-
warn(`Warning: ${warning}`);
|
|
5590
|
-
}
|
|
5591
|
-
let response;
|
|
5592
|
-
try {
|
|
5593
|
-
response = await fetchImpl(prepared.connectUrl, {
|
|
5594
|
-
method: "POST",
|
|
5595
|
-
headers: { "content-type": "application/json" },
|
|
5596
|
-
body: JSON.stringify({ remote_url: normalizedRemote })
|
|
5597
|
-
});
|
|
5598
|
-
} catch {
|
|
5599
|
-
throw indeterminateError(operationStatus);
|
|
5600
|
-
}
|
|
5601
|
-
if (response.status >= 500 || response.status < 200) {
|
|
5602
|
-
throw indeterminateError(operationStatus);
|
|
5603
|
-
}
|
|
5604
|
-
let body;
|
|
5605
|
-
try {
|
|
5606
|
-
body = await response.json();
|
|
5607
|
-
} catch {
|
|
5608
|
-
throw indeterminateError(operationStatus);
|
|
5609
|
-
}
|
|
5610
|
-
if (response.ok) {
|
|
5611
|
-
if (!isHarborConnectResponse(body)) {
|
|
5612
|
-
throw indeterminateError(operationStatus);
|
|
5613
|
-
}
|
|
5614
|
-
return redactConnectCredential(body.message, prepared.connectUrl);
|
|
5615
|
-
}
|
|
5616
|
-
if (response.status < 400 || response.status >= 500 || !isHarborConnectErrorResponse(body)) {
|
|
5617
|
-
throw indeterminateError(operationStatus);
|
|
5618
|
-
}
|
|
5619
|
-
const detail = HARBOR_ERROR_MESSAGES[body.code] ?? `Harbor rejected this connection (HTTP ${response.status}).`;
|
|
5620
|
-
throw new CliExitError(
|
|
5621
|
-
`${operationStatus} Harbor definitively rejected the connection. ${detail}`,
|
|
5622
|
-
3
|
|
5623
|
-
);
|
|
5624
|
-
}
|
|
5625
|
-
|
|
5626
|
-
// src/processCli.ts
|
|
5627
|
-
import { statSync } from "fs";
|
|
5628
|
-
import { basename, resolve as resolve3 } from "path";
|
|
5629
|
-
|
|
5630
5373
|
// src/cli.ts
|
|
5631
5374
|
import { readFile as readFile3 } from "fs/promises";
|
|
5632
5375
|
import { Command, InvalidArgumentError, Option } from "commander";
|
|
@@ -5638,7 +5381,7 @@ import {
|
|
|
5638
5381
|
createServer
|
|
5639
5382
|
} from "http";
|
|
5640
5383
|
import { createRequire } from "module";
|
|
5641
|
-
import { dirname as dirname2, extname, join as join3, resolve
|
|
5384
|
+
import { dirname as dirname2, extname, join as join3, resolve, sep as sep2 } from "path";
|
|
5642
5385
|
import { platform } from "process";
|
|
5643
5386
|
|
|
5644
5387
|
// src/tui/paths.ts
|
|
@@ -5665,8 +5408,8 @@ async function watchProject(cwd, onChange, debounceMs = DEBOUNCE_MS) {
|
|
|
5665
5408
|
if (debounce) clearTimeout(debounce);
|
|
5666
5409
|
debounce = setTimeout(() => void onChange(), debounceMs);
|
|
5667
5410
|
});
|
|
5668
|
-
await new Promise((
|
|
5669
|
-
watcher.once("ready",
|
|
5411
|
+
await new Promise((resolve3, reject) => {
|
|
5412
|
+
watcher.once("ready", resolve3);
|
|
5670
5413
|
watcher.once("error", reject);
|
|
5671
5414
|
});
|
|
5672
5415
|
return {
|
|
@@ -5788,8 +5531,8 @@ async function serveStatic(req, res, bundleDir) {
|
|
|
5788
5531
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
5789
5532
|
const pathname = decodeURIComponent(url.pathname);
|
|
5790
5533
|
const relative2 = pathname === "/" ? "/standalone.html" : pathname;
|
|
5791
|
-
const root =
|
|
5792
|
-
const target =
|
|
5534
|
+
const root = resolve(bundleDir);
|
|
5535
|
+
const target = resolve(root, `.${relative2}`);
|
|
5793
5536
|
if (target !== root && !target.startsWith(`${root}${sep2}`)) {
|
|
5794
5537
|
sendError(res, 403, "Forbidden");
|
|
5795
5538
|
return;
|
|
@@ -6120,15 +5863,18 @@ function shouldUseColor(env, isStdoutTty) {
|
|
|
6120
5863
|
}
|
|
6121
5864
|
|
|
6122
5865
|
// src/output.ts
|
|
6123
|
-
function formatInitNextSteps(
|
|
5866
|
+
function formatInitNextSteps() {
|
|
6124
5867
|
return [
|
|
6125
5868
|
"",
|
|
6126
5869
|
"Next steps:",
|
|
6127
5870
|
' 1. Create a task: shipbench task create "My first task"',
|
|
6128
5871
|
" 2. Open the board: shipbench board",
|
|
6129
|
-
|
|
5872
|
+
" 3. Read .shipbench/README.md to learn the project workflow."
|
|
6130
5873
|
];
|
|
6131
5874
|
}
|
|
5875
|
+
function formatMissingBoard(location) {
|
|
5876
|
+
return `No .shipbench/config.json found ${location}. Run shipbench init first.`;
|
|
5877
|
+
}
|
|
6132
5878
|
function formatBoardStatus(url, cwd) {
|
|
6133
5879
|
return [
|
|
6134
5880
|
`Board ready at ${url}`,
|
|
@@ -6870,10 +6616,10 @@ async function runTui(options2) {
|
|
|
6870
6616
|
paint();
|
|
6871
6617
|
const watcher = await watch(options2.cwd, () => refresh());
|
|
6872
6618
|
const keepalive = setInterval(() => void 0, 1 << 30);
|
|
6873
|
-
await new Promise((
|
|
6619
|
+
await new Promise((resolve3) => {
|
|
6874
6620
|
if (!signal) return;
|
|
6875
|
-
if (signal.aborted)
|
|
6876
|
-
else signal.addEventListener("abort", () =>
|
|
6621
|
+
if (signal.aborted) resolve3();
|
|
6622
|
+
else signal.addEventListener("abort", () => resolve3(), { once: true });
|
|
6877
6623
|
});
|
|
6878
6624
|
clearInterval(keepalive);
|
|
6879
6625
|
await watcher.close();
|
|
@@ -6881,7 +6627,7 @@ async function runTui(options2) {
|
|
|
6881
6627
|
}
|
|
6882
6628
|
|
|
6883
6629
|
// src/cli.ts
|
|
6884
|
-
var VERSION = true ? "0.
|
|
6630
|
+
var VERSION = true ? "0.8.0" : "0.0.0-dev";
|
|
6885
6631
|
function commaList(value) {
|
|
6886
6632
|
return value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
6887
6633
|
}
|
|
@@ -7093,13 +6839,24 @@ function createCli(opts) {
|
|
|
7093
6839
|
env: opts.env ?? process.env
|
|
7094
6840
|
});
|
|
7095
6841
|
const { data, chrome } = output;
|
|
7096
|
-
const
|
|
7097
|
-
|
|
7098
|
-
|
|
6842
|
+
const missingBoardMessage = opts.missingBoardMessage ?? formatMissingBoard(`in ${cwd}`);
|
|
6843
|
+
const requireBoard = async () => {
|
|
6844
|
+
if (await adapter.readFileIfExists(CONFIG_PATH4) === null) {
|
|
6845
|
+
throw new Error(missingBoardMessage);
|
|
7099
6846
|
}
|
|
7100
|
-
}
|
|
7101
|
-
const
|
|
7102
|
-
|
|
6847
|
+
};
|
|
6848
|
+
const loadCliConfig = async () => {
|
|
6849
|
+
try {
|
|
6850
|
+
return await loadConfig(adapter, {
|
|
6851
|
+
onWarning: (warning) => {
|
|
6852
|
+
output.warning(`${warning.path}: ${warning.message}`);
|
|
6853
|
+
}
|
|
6854
|
+
});
|
|
6855
|
+
} catch (error) {
|
|
6856
|
+
await requireBoard();
|
|
6857
|
+
throw error;
|
|
6858
|
+
}
|
|
6859
|
+
};
|
|
7103
6860
|
const readTextFile = opts.readTextFile ?? ((path) => readFile3(path, "utf8"));
|
|
7104
6861
|
const readStdin = opts.readStdin ?? readProcessStdin;
|
|
7105
6862
|
const resolveBody = async (raw) => {
|
|
@@ -7134,8 +6891,33 @@ function createCli(opts) {
|
|
|
7134
6891
|
};
|
|
7135
6892
|
const program = new Command().name("shipbench").description("Git-native project management for solo developers.").enablePositionalOptions().version(VERSION, "-v, --version", "output the version").option(
|
|
7136
6893
|
"-C <path>",
|
|
7137
|
-
"
|
|
6894
|
+
"Use the board in the specified directory, without searching above it"
|
|
7138
6895
|
);
|
|
6896
|
+
const writingCommands = /* @__PURE__ */ new Set([
|
|
6897
|
+
"task create",
|
|
6898
|
+
"task edit",
|
|
6899
|
+
"task comment",
|
|
6900
|
+
"task comment edit",
|
|
6901
|
+
"task comment delete",
|
|
6902
|
+
"task flag",
|
|
6903
|
+
"task unflag",
|
|
6904
|
+
"task move",
|
|
6905
|
+
"task archive",
|
|
6906
|
+
"task unarchive",
|
|
6907
|
+
"task delete"
|
|
6908
|
+
]);
|
|
6909
|
+
if (opts.searchedFrom !== void 0 && opts.searchedFrom !== cwd) {
|
|
6910
|
+
program.hook("preAction", (_root, action) => {
|
|
6911
|
+
const names = [];
|
|
6912
|
+
for (let command = action; command?.parent; ) {
|
|
6913
|
+
names.unshift(command.name());
|
|
6914
|
+
command = command.parent;
|
|
6915
|
+
}
|
|
6916
|
+
if (writingCommands.has(names.join(" "))) {
|
|
6917
|
+
chrome(`Using .shipbench/ from ${cwd}`);
|
|
6918
|
+
}
|
|
6919
|
+
});
|
|
6920
|
+
}
|
|
7139
6921
|
program.configureOutput({
|
|
7140
6922
|
writeOut: (line) => data(line.replace(/\n$/, "")),
|
|
7141
6923
|
writeErr: (line) => chrome(line.replace(/\n$/, ""))
|
|
@@ -7145,37 +6927,20 @@ function createCli(opts) {
|
|
|
7145
6927
|
).option(
|
|
7146
6928
|
"-n, --name <name>",
|
|
7147
6929
|
"Project name (defaults to current directory name)"
|
|
7148
|
-
).option(
|
|
7149
|
-
"--harbor <connect-url>",
|
|
7150
|
-
"Safely initialize, then connect the repository origin to Harbor with a signed URL"
|
|
7151
6930
|
).action(async (raw) => {
|
|
7152
6931
|
const name = (raw.name ?? defaultProjectName).trim() || defaultProjectName;
|
|
7153
|
-
let prepared;
|
|
7154
|
-
if (raw.harbor) {
|
|
7155
|
-
try {
|
|
7156
|
-
prepared = await prepareHarborConnection(raw.harbor, cwd, runGit);
|
|
7157
|
-
} catch (error) {
|
|
7158
|
-
if (error instanceof CliExitError) {
|
|
7159
|
-
throw new CliExitError(
|
|
7160
|
-
`ShipBench initialization did not run, and Harbor was not contacted. ${error.message}`,
|
|
7161
|
-
error.exitCode
|
|
7162
|
-
);
|
|
7163
|
-
}
|
|
7164
|
-
throw error;
|
|
7165
|
-
}
|
|
7166
|
-
}
|
|
7167
6932
|
let result;
|
|
7168
6933
|
try {
|
|
7169
6934
|
result = await initProject(adapter, { name });
|
|
7170
6935
|
} catch (error) {
|
|
7171
6936
|
throw new CliExitError(
|
|
7172
|
-
`ShipBench files were not modified
|
|
6937
|
+
`ShipBench files were not modified. ${error instanceof Error ? error.message : "Initialization failed."}`,
|
|
7173
6938
|
2
|
|
7174
6939
|
);
|
|
7175
6940
|
}
|
|
7176
6941
|
if (!result.created && raw.name !== void 0 && result.config.name !== name) {
|
|
7177
6942
|
throw new CliExitError(
|
|
7178
|
-
`ShipBench files were not modified
|
|
6943
|
+
`ShipBench files were not modified. Existing project name "${result.config.name}" does not match --name "${name}".`,
|
|
7179
6944
|
2
|
|
7180
6945
|
);
|
|
7181
6946
|
}
|
|
@@ -7183,67 +6948,20 @@ function createCli(opts) {
|
|
|
7183
6948
|
for (const warning of result.warnings) {
|
|
7184
6949
|
output.warning(formatProjectWarning(warning));
|
|
7185
6950
|
}
|
|
7186
|
-
const operationStatus = result.created ? "ShipBench initialization completed." : "ShipBench was already initialized and remains unchanged.";
|
|
7187
6951
|
if (result.created) {
|
|
7188
6952
|
chrome(`Initialized .shipbench/ for "${name}" in current directory.`);
|
|
6953
|
+
if (opts.ancestorBoard !== void 0) {
|
|
6954
|
+
chrome(
|
|
6955
|
+
`Note: ${opts.ancestorBoard} already has a .shipbench/ board. This one is separate, and tasks on one cannot depend on tasks on the other.`
|
|
6956
|
+
);
|
|
6957
|
+
}
|
|
7189
6958
|
} else {
|
|
7190
6959
|
chrome(`ShipBench is already initialized for "${result.config.name}".`);
|
|
7191
6960
|
}
|
|
7192
|
-
if (prepared) {
|
|
7193
|
-
const message2 = await connectPreparedProjectToHarbor({
|
|
7194
|
-
prepared,
|
|
7195
|
-
runGit,
|
|
7196
|
-
fetch: fetchImpl,
|
|
7197
|
-
warn: chrome,
|
|
7198
|
-
operationStatus
|
|
7199
|
-
});
|
|
7200
|
-
chrome(message2);
|
|
7201
|
-
}
|
|
7202
6961
|
if (result.created) {
|
|
7203
|
-
for (const line of formatInitNextSteps(
|
|
6962
|
+
for (const line of formatInitNextSteps()) chrome(line);
|
|
7204
6963
|
}
|
|
7205
6964
|
});
|
|
7206
|
-
program.command("connect").description(
|
|
7207
|
-
"Connect an existing ShipBench project to Harbor without modifying project files"
|
|
7208
|
-
).requiredOption("--harbor <connect-url>", "Signed Harbor connect URL").action(async (raw) => {
|
|
7209
|
-
let prepared;
|
|
7210
|
-
try {
|
|
7211
|
-
prepared = await prepareHarborConnection(raw.harbor, cwd, runGit);
|
|
7212
|
-
} catch (error) {
|
|
7213
|
-
if (error instanceof CliExitError) {
|
|
7214
|
-
throw new CliExitError(
|
|
7215
|
-
`ShipBench project files were not modified, and Harbor was not contacted. ${error.message}`,
|
|
7216
|
-
error.exitCode
|
|
7217
|
-
);
|
|
7218
|
-
}
|
|
7219
|
-
throw error;
|
|
7220
|
-
}
|
|
7221
|
-
const state = await inspectProjectInitialization(adapter);
|
|
7222
|
-
if (state.kind === "missing") {
|
|
7223
|
-
throw new CliExitError(
|
|
7224
|
-
"ShipBench project files were not modified, and Harbor was not contacted. This repository is not initialized. Run shipbench init first.",
|
|
7225
|
-
2
|
|
7226
|
-
);
|
|
7227
|
-
}
|
|
7228
|
-
if (state.kind !== "initialized") {
|
|
7229
|
-
const detail = state.kind === "incomplete" ? `ShipBench project is incomplete because .shipbench/config.json is missing while these files exist: ${state.paths.join(", ")}.` : `ShipBench project is ${state.kind}: ${state.errors.join(" ")}`;
|
|
7230
|
-
throw new CliExitError(
|
|
7231
|
-
`ShipBench project files were not modified, and Harbor was not contacted. ${detail}`,
|
|
7232
|
-
2
|
|
7233
|
-
);
|
|
7234
|
-
}
|
|
7235
|
-
for (const warning of state.warnings) {
|
|
7236
|
-
output.warning(formatProjectWarning(warning));
|
|
7237
|
-
}
|
|
7238
|
-
const message2 = await connectPreparedProjectToHarbor({
|
|
7239
|
-
prepared,
|
|
7240
|
-
runGit,
|
|
7241
|
-
fetch: fetchImpl,
|
|
7242
|
-
warn: chrome,
|
|
7243
|
-
operationStatus: "ShipBench project files remain unchanged."
|
|
7244
|
-
});
|
|
7245
|
-
chrome(message2);
|
|
7246
|
-
});
|
|
7247
6965
|
const task = program.command("task").description("Manage tasks");
|
|
7248
6966
|
task.command("create <title>").description("Create a new task").option("-s, --status <status>", "Column to place the task in").option("-a, --assignee <assignee>", "Assignee label").option("-p, --priority <priority>", "Priority value").option(
|
|
7249
6967
|
"-t, --tags <tags>",
|
|
@@ -8086,6 +7804,7 @@ function createCli(opts) {
|
|
|
8086
7804
|
});
|
|
8087
7805
|
const board = program.command("board").description("Open the board UI");
|
|
8088
7806
|
board.command("web", { isDefault: true }).description("Open the board UI in a browser (the default for `board`)").option("--port <number>", "Port to listen on", parsePort, 4321).option("--no-open", "Do not open the browser automatically").action(async (raw) => {
|
|
7807
|
+
await requireBoard();
|
|
8089
7808
|
const server = await startBoardServer({
|
|
8090
7809
|
adapter,
|
|
8091
7810
|
cwd,
|
|
@@ -8121,6 +7840,7 @@ function createCli(opts) {
|
|
|
8121
7840
|
"after",
|
|
8122
7841
|
"\nTakes no keyboard input: Ctrl-C exits. Never writes to the board.\nWith stdout redirected it prints one 80x24 frame and exits.\n"
|
|
8123
7842
|
).action(async (raw) => {
|
|
7843
|
+
await requireBoard();
|
|
8124
7844
|
await runTui({
|
|
8125
7845
|
adapter,
|
|
8126
7846
|
cwd,
|
|
@@ -8138,14 +7858,16 @@ function createCli(opts) {
|
|
|
8138
7858
|
}
|
|
8139
7859
|
|
|
8140
7860
|
// src/processCli.ts
|
|
8141
|
-
function
|
|
7861
|
+
function rootArguments(argv) {
|
|
8142
7862
|
let directory;
|
|
8143
7863
|
for (let index = 2; index < argv.length; index += 1) {
|
|
8144
7864
|
const argument = argv[index];
|
|
8145
7865
|
if (argument === "--") break;
|
|
8146
7866
|
if (argument === "-C") {
|
|
8147
7867
|
const value = argv[index + 1];
|
|
8148
|
-
if (value === void 0 || value === "--")
|
|
7868
|
+
if (value === void 0 || value === "--") {
|
|
7869
|
+
return { directory, command: void 0 };
|
|
7870
|
+
}
|
|
8149
7871
|
directory = value;
|
|
8150
7872
|
index += 1;
|
|
8151
7873
|
continue;
|
|
@@ -8154,14 +7876,16 @@ function projectDirectoryOption(argv) {
|
|
|
8154
7876
|
directory = argument.slice(2);
|
|
8155
7877
|
continue;
|
|
8156
7878
|
}
|
|
8157
|
-
if (!argument
|
|
7879
|
+
if (argument !== void 0 && !argument.startsWith("-")) {
|
|
7880
|
+
return { directory, command: argument };
|
|
7881
|
+
}
|
|
8158
7882
|
}
|
|
8159
|
-
return directory;
|
|
7883
|
+
return { directory, command: void 0 };
|
|
8160
7884
|
}
|
|
8161
7885
|
function resolveProjectDirectory(argv, shellCwd) {
|
|
8162
|
-
const option =
|
|
7886
|
+
const option = rootArguments(argv).directory;
|
|
8163
7887
|
if (option === void 0) return shellCwd;
|
|
8164
|
-
const directory =
|
|
7888
|
+
const directory = resolve2(shellCwd, option);
|
|
8165
7889
|
let stats;
|
|
8166
7890
|
try {
|
|
8167
7891
|
stats = statSync(directory);
|
|
@@ -8181,12 +7905,67 @@ function resolveProjectDirectory(argv, shellCwd) {
|
|
|
8181
7905
|
}
|
|
8182
7906
|
return directory;
|
|
8183
7907
|
}
|
|
7908
|
+
var BOARD_DIRECTORY = ".shipbench";
|
|
7909
|
+
function isDirectory(path) {
|
|
7910
|
+
try {
|
|
7911
|
+
return statSync(path).isDirectory();
|
|
7912
|
+
} catch {
|
|
7913
|
+
return false;
|
|
7914
|
+
}
|
|
7915
|
+
}
|
|
7916
|
+
function findBoard(start) {
|
|
7917
|
+
let directory = start;
|
|
7918
|
+
for (; ; ) {
|
|
7919
|
+
if (isDirectory(join4(directory, BOARD_DIRECTORY))) {
|
|
7920
|
+
return existsSync(join4(directory, BOARD_DIRECTORY, "config.json")) ? { kind: "found", root: directory } : { kind: "incomplete", root: directory };
|
|
7921
|
+
}
|
|
7922
|
+
if (existsSync(join4(directory, ".git"))) {
|
|
7923
|
+
return { kind: "none", boundary: directory };
|
|
7924
|
+
}
|
|
7925
|
+
const parent = dirname3(directory);
|
|
7926
|
+
if (parent === directory) return { kind: "none", boundary: null };
|
|
7927
|
+
directory = parent;
|
|
7928
|
+
}
|
|
7929
|
+
}
|
|
7930
|
+
function missingMessage(start, search) {
|
|
7931
|
+
if (search.kind !== "none") return formatMissingBoard(`in ${search.root}`);
|
|
7932
|
+
if (search.boundary === start) return formatMissingBoard(`in ${start}`);
|
|
7933
|
+
if (search.boundary === null) {
|
|
7934
|
+
return formatMissingBoard(`in ${start} or any directory above it`);
|
|
7935
|
+
}
|
|
7936
|
+
return formatMissingBoard(`in ${start} or above it up to ${search.boundary}`);
|
|
7937
|
+
}
|
|
7938
|
+
function resolveBoard(argv, shellCwd) {
|
|
7939
|
+
const start = resolveProjectDirectory(argv, shellCwd);
|
|
7940
|
+
const { directory: option, command } = rootArguments(argv);
|
|
7941
|
+
const exact = {
|
|
7942
|
+
directory: start,
|
|
7943
|
+
start,
|
|
7944
|
+
missingMessage: formatMissingBoard(`in ${start}`)
|
|
7945
|
+
};
|
|
7946
|
+
if (command === "init") {
|
|
7947
|
+
if (existsSync(join4(start, ".git"))) return exact;
|
|
7948
|
+
const parent = dirname3(start);
|
|
7949
|
+
const above = parent === start ? void 0 : findBoard(parent);
|
|
7950
|
+
return above?.kind === "found" ? { ...exact, ancestorBoard: above.root } : exact;
|
|
7951
|
+
}
|
|
7952
|
+
if (option !== void 0) return exact;
|
|
7953
|
+
const search = findBoard(start);
|
|
7954
|
+
return {
|
|
7955
|
+
directory: search.kind === "none" ? start : search.root,
|
|
7956
|
+
start,
|
|
7957
|
+
missingMessage: missingMessage(start, search)
|
|
7958
|
+
};
|
|
7959
|
+
}
|
|
8184
7960
|
function createProcessCli(opts) {
|
|
8185
|
-
const
|
|
7961
|
+
const board = resolveBoard(opts.argv, opts.shellCwd);
|
|
8186
7962
|
return createCli({
|
|
8187
|
-
adapter: new FsAdapter(
|
|
8188
|
-
defaultProjectName: basename(
|
|
8189
|
-
cwd,
|
|
7963
|
+
adapter: new FsAdapter(board.directory),
|
|
7964
|
+
defaultProjectName: basename(board.start),
|
|
7965
|
+
cwd: board.directory,
|
|
7966
|
+
searchedFrom: board.start,
|
|
7967
|
+
missingBoardMessage: board.missingMessage,
|
|
7968
|
+
ancestorBoard: board.ancestorBoard,
|
|
8190
7969
|
out: opts.out,
|
|
8191
7970
|
err: opts.err,
|
|
8192
7971
|
exitOverride: opts.exitOverride
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shipbench",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Git-native project management for solo developers. Each task is a Markdown file in your repository, with a CLI and a local board on top.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"chokidar": "^5.0.0",
|
|
35
35
|
"commander": "^15.0.0",
|
|
36
|
-
"@shipbench/board": "0.
|
|
36
|
+
"@shipbench/board": "0.8.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^26.0.1",
|
|
40
40
|
"gray-matter": "^4.0.3",
|
|
41
41
|
"tsup": "^8.0.0",
|
|
42
42
|
"typescript": "^5.5.0",
|
|
43
|
-
"@shipbench/core": "0.
|
|
43
|
+
"@shipbench/core": "0.8.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsup",
|