kanbo-cli 0.1.2 → 0.1.3
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 +1 -0
- package/dist/cli.cjs +10533 -8390
- package/dist/cli.cjs.map +1 -1
- package/dist/{dist-Cd6wg8pp.cjs → dist-BsCwQFEl.cjs} +48 -1
- package/dist/dist-BsCwQFEl.cjs.map +1 -0
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/lib/{manifest-CmiuDqH-.cjs → manifest-BBJIrMw7.cjs} +1287 -347
- package/dist/lib/manifest-BBJIrMw7.cjs.map +1 -0
- package/dist/lib/{manifest-NRhhhOkC.mjs → manifest-mkDJmxt2.mjs} +1178 -238
- package/dist/lib/manifest-mkDJmxt2.mjs.map +1 -0
- package/dist/lib/mcp/index.cjs +1 -1
- package/dist/lib/mcp/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/dist-Cd6wg8pp.cjs.map +0 -1
- package/dist/lib/manifest-CmiuDqH-.cjs.map +0 -1
- package/dist/lib/manifest-NRhhhOkC.mjs.map +0 -1
|
@@ -3,18 +3,20 @@ import { c as getBoardMigrationsPath, i as BOARD_PERSON_ROLE, l as createPostgre
|
|
|
3
3
|
import { a as openBoardDatabase, c as createSqliteBoardStore, i as markBoardFileOwnedByKanbo, n as migrateBoardFile, o as readBoardFileContents, r as assertBoardSchema$1 } from "./migrate-BhYi9cXw.mjs";
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import { hostname, userInfo } from "node:os";
|
|
6
|
+
import { homedir, hostname, userInfo } from "node:os";
|
|
7
7
|
import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
8
8
|
import { sql } from "drizzle-orm";
|
|
9
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
10
|
-
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
9
|
+
import { accessSync, chmodSync, constants, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
11
11
|
import { drizzle } from "drizzle-orm/postgres-js";
|
|
12
12
|
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
|
13
13
|
import postgres from "postgres";
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
16
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
17
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
15
18
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
16
19
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
17
|
-
import { spawn } from "node:child_process";
|
|
18
20
|
import { createServer } from "node:http";
|
|
19
21
|
/**
|
|
20
22
|
* Every exit code this tool promises, and what it means — the capabilities
|
|
@@ -4301,6 +4303,866 @@ function readRequestedRules(options) {
|
|
|
4301
4303
|
return options.require.split(",").map((rule) => rule.trim()).filter(Boolean);
|
|
4302
4304
|
}
|
|
4303
4305
|
//#endregion
|
|
4306
|
+
//#region src/package-version.ts
|
|
4307
|
+
dirname(fileURLToPath(import.meta.url));
|
|
4308
|
+
/**
|
|
4309
|
+
* This build's own version, one source for the CLI's `--version`, the MCP
|
|
4310
|
+
* server's reported version and the capabilities manifest's
|
|
4311
|
+
* `package.version`. A build carries it as a literal; running from source
|
|
4312
|
+
* (tests, `tsx`) reads the package's own `package.json` instead.
|
|
4313
|
+
*/
|
|
4314
|
+
const KANBO_PACKAGE_VERSION = "0.1.3";
|
|
4315
|
+
//#endregion
|
|
4316
|
+
//#region src/cli/failure.ts
|
|
4317
|
+
/**
|
|
4318
|
+
* What a failed command says, and what it leaves with.
|
|
4319
|
+
*
|
|
4320
|
+
* One place, because a failure is output as much as a result is: the exit code
|
|
4321
|
+
* a caller may branch on, the sentence a person reads, and the chain underneath
|
|
4322
|
+
* it that says what actually went wrong.
|
|
4323
|
+
*/
|
|
4324
|
+
/** How far down a chain of causes is still worth reading. */
|
|
4325
|
+
const CAUSE_DEPTH_LIMIT = 5;
|
|
4326
|
+
/**
|
|
4327
|
+
* What to say about a failure, and what to leave with.
|
|
4328
|
+
*
|
|
4329
|
+
* A `CliError` already carries both. A `BoardError` is a rule of the board the
|
|
4330
|
+
* caller broke: its code is the honest name of what happened, and its details
|
|
4331
|
+
* say which value did it, so both are printed rather than translated into a
|
|
4332
|
+
* sentence that could drift away from the rule. The one exception is a card
|
|
4333
|
+
* held at a column's door: its details are a list, and a person reads it as
|
|
4334
|
+
* one line per rule the card does not meet yet (`describeColumnRefusal`).
|
|
4335
|
+
*
|
|
4336
|
+
* Whatever it is, its causes are printed under it. A driver's failure arrives
|
|
4337
|
+
* wrapped — `Failed query: create schema …` with the connection refused
|
|
4338
|
+
* underneath — and the wrapper alone tells a person nothing they can act on.
|
|
4339
|
+
* Every line goes through the masking on its way out, because a message this
|
|
4340
|
+
* tool did not write is free to carry the whole connection string in it.
|
|
4341
|
+
*/
|
|
4342
|
+
function describeFailure(error) {
|
|
4343
|
+
const { message, exitCode } = readFailure(error);
|
|
4344
|
+
return {
|
|
4345
|
+
message: maskDatabaseUrls([message, ...describeCauses(error, 1)].join("\n")),
|
|
4346
|
+
exitCode
|
|
4347
|
+
};
|
|
4348
|
+
}
|
|
4349
|
+
function readFailure(error) {
|
|
4350
|
+
if (error instanceof CliError) return {
|
|
4351
|
+
message: error.message,
|
|
4352
|
+
exitCode: error.exitCode
|
|
4353
|
+
};
|
|
4354
|
+
if (error instanceof BoardError && error.code === "board_column_rules_unmet") return {
|
|
4355
|
+
message: describeColumnRefusal(error.details),
|
|
4356
|
+
exitCode: 1
|
|
4357
|
+
};
|
|
4358
|
+
if (error instanceof BoardError) {
|
|
4359
|
+
const details = error.details ? ` ${JSON.stringify(error.details)}` : "";
|
|
4360
|
+
return {
|
|
4361
|
+
message: `${error.code}${details}`,
|
|
4362
|
+
exitCode: 1
|
|
4363
|
+
};
|
|
4364
|
+
}
|
|
4365
|
+
return {
|
|
4366
|
+
message: error instanceof Error ? error.message : String(error),
|
|
4367
|
+
exitCode: 1
|
|
4368
|
+
};
|
|
4369
|
+
}
|
|
4370
|
+
/**
|
|
4371
|
+
* The chain under a failure, one indented line per link.
|
|
4372
|
+
*
|
|
4373
|
+
* Bounded, because `cause` is an ordinary property and nothing stops it
|
|
4374
|
+
* pointing back at the error it came from; a chain longer than this has stopped
|
|
4375
|
+
* explaining anything anyway.
|
|
4376
|
+
*/
|
|
4377
|
+
function describeCauses(error, depth) {
|
|
4378
|
+
const cause = error instanceof Error ? error.cause : void 0;
|
|
4379
|
+
if (cause === void 0 || cause === null || depth > CAUSE_DEPTH_LIMIT) return [];
|
|
4380
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
4381
|
+
return [`${" ".repeat(depth)}Caused by: ${message}`, ...describeCauses(cause, depth + 1)];
|
|
4382
|
+
}
|
|
4383
|
+
//#endregion
|
|
4384
|
+
//#region src/cli/setup/instructions.ts
|
|
4385
|
+
/**
|
|
4386
|
+
* The instruction block kanbo writes into an agent's standing instructions,
|
|
4387
|
+
* and the three things done to it: written, found again, taken out.
|
|
4388
|
+
*
|
|
4389
|
+
* Two versions of the block exist. The project block says "this project is on
|
|
4390
|
+
* a board"; the global one, for a person's user-level file, says "a project
|
|
4391
|
+
* with `.kanbo/` is on a board" and binds nothing — one user file serves every
|
|
4392
|
+
* project, and most of them have no board.
|
|
4393
|
+
*/
|
|
4394
|
+
/** The markers that make the block something this tool can find again. */
|
|
4395
|
+
const INSTRUCTION_START = "<!-- KANBO_START -->";
|
|
4396
|
+
const INSTRUCTION_END = "<!-- KANBO_END -->";
|
|
4397
|
+
/**
|
|
4398
|
+
* What to run and when, and nothing about how to do the work: the method is
|
|
4399
|
+
* the person's own instructions to their agent. The rules are the sentences
|
|
4400
|
+
* `ops/agent-rules.ts` holds for every surface, with the command beside each.
|
|
4401
|
+
*/
|
|
4402
|
+
const RULE_LINES = [
|
|
4403
|
+
"- Take a card from `kanbo ready`.",
|
|
4404
|
+
`- ${MOVE_CARD_RULE} (\`kanbo card move <id> <column>\`)`,
|
|
4405
|
+
`- ${STATUS_LINE_RULE} (\`kanbo card status-line <id> --text "..."\`)`,
|
|
4406
|
+
`- ${SUBTASK_RULE} (\`kanbo card create --description "..." --parent <id>\`)`,
|
|
4407
|
+
`- ${COMMENT_RULE} (\`kanbo card comment <id> --content "..."\`)`,
|
|
4408
|
+
`- ${WAIT_FOR_PERSON_RULE} (\`kanbo card wait-approval <id>\`)`,
|
|
4409
|
+
`- ${PERSON_ONLY_RULE}`,
|
|
4410
|
+
`- ${OWN_SESSION_RULE} (\`kanbo run start <id> --agent <name> --session <ref>\`)`,
|
|
4411
|
+
"- Run `kanbo capabilities` for the full list of tools, commands and rules."
|
|
4412
|
+
];
|
|
4413
|
+
/** The block `kanbo init --instructions …` writes into a project's own file. */
|
|
4414
|
+
const INSTRUCTION_BLOCK = [
|
|
4415
|
+
INSTRUCTION_START,
|
|
4416
|
+
"## Kanbo board",
|
|
4417
|
+
"",
|
|
4418
|
+
"Work on this project is tracked on a kanbo board. Before starting a task run `kanbo prime` — it prints the board's columns and what each one means.",
|
|
4419
|
+
"",
|
|
4420
|
+
...RULE_LINES,
|
|
4421
|
+
INSTRUCTION_END
|
|
4422
|
+
].join("\n");
|
|
4423
|
+
/** The block `kanbo init --global` writes into a person's user-level file. */
|
|
4424
|
+
const GLOBAL_INSTRUCTION_BLOCK = [
|
|
4425
|
+
INSTRUCTION_START,
|
|
4426
|
+
"## Kanbo boards",
|
|
4427
|
+
"",
|
|
4428
|
+
"A project with a `.kanbo/` directory tracks its work on a kanbo board. In such a project, before starting a task run `kanbo prime` (or call the `kanbo_prime` tool) — it prints the board's columns and what each one means. A project without `.kanbo/` has no board: ignore this section there, and do not create one — a person sets a board up with `kanbo init`.",
|
|
4429
|
+
"",
|
|
4430
|
+
...RULE_LINES,
|
|
4431
|
+
INSTRUCTION_END
|
|
4432
|
+
].join("\n");
|
|
4433
|
+
/**
|
|
4434
|
+
* The block in that file, once.
|
|
4435
|
+
*
|
|
4436
|
+
* A file that already carries the markers has its block replaced rather than
|
|
4437
|
+
* appended to, so a current block changes nothing at all and an outdated one is
|
|
4438
|
+
* brought forward. Everything outside the markers is the person's own writing
|
|
4439
|
+
* and is never touched.
|
|
4440
|
+
*/
|
|
4441
|
+
function planInstructionBlock(path, block) {
|
|
4442
|
+
const existing = readText(path);
|
|
4443
|
+
const next = withBlock(existing, block);
|
|
4444
|
+
return {
|
|
4445
|
+
path,
|
|
4446
|
+
next: existing === next ? null : next
|
|
4447
|
+
};
|
|
4448
|
+
}
|
|
4449
|
+
/**
|
|
4450
|
+
* The file without the block, or no change when it carries none. The file
|
|
4451
|
+
* itself stays even when nothing is left in it: kanbo does not record which
|
|
4452
|
+
* files it created, and a person's file is not this tool's to delete.
|
|
4453
|
+
*/
|
|
4454
|
+
function planInstructionBlockRemoval(path) {
|
|
4455
|
+
const existing = readText(path);
|
|
4456
|
+
const bounds = existing === null ? null : findBlock(existing);
|
|
4457
|
+
if (existing === null || bounds === null) return {
|
|
4458
|
+
path,
|
|
4459
|
+
next: null
|
|
4460
|
+
};
|
|
4461
|
+
const joined = [existing.slice(0, bounds.start).replace(/\s*$/, ""), existing.slice(bounds.end).trim()].filter((part) => part.length > 0).join("\n\n");
|
|
4462
|
+
return {
|
|
4463
|
+
path,
|
|
4464
|
+
next: joined ? `${joined}\n` : ""
|
|
4465
|
+
};
|
|
4466
|
+
}
|
|
4467
|
+
/** The block a file carries, markers included, or `null` when it carries none. */
|
|
4468
|
+
function readInstructionBlock(path) {
|
|
4469
|
+
const existing = readText(path);
|
|
4470
|
+
const bounds = existing === null ? null : findBlock(existing);
|
|
4471
|
+
return existing === null || bounds === null ? null : existing.slice(bounds.start, bounds.end);
|
|
4472
|
+
}
|
|
4473
|
+
function withBlock(existing, block) {
|
|
4474
|
+
if (existing === null || !existing.trim()) return `${block}\n`;
|
|
4475
|
+
const bounds = findBlock(existing);
|
|
4476
|
+
if (bounds) return existing.slice(0, bounds.start) + block + existing.slice(bounds.end);
|
|
4477
|
+
return `${existing.replace(/\s*$/, "")}\n\n${block}\n`;
|
|
4478
|
+
}
|
|
4479
|
+
function findBlock(text) {
|
|
4480
|
+
const start = text.indexOf(INSTRUCTION_START);
|
|
4481
|
+
const end = text.indexOf(INSTRUCTION_END);
|
|
4482
|
+
return start >= 0 && end > start ? {
|
|
4483
|
+
start,
|
|
4484
|
+
end: end + 18
|
|
4485
|
+
} : null;
|
|
4486
|
+
}
|
|
4487
|
+
function readText(path) {
|
|
4488
|
+
return existsSync(path) ? readFileSync(path, "utf8") : null;
|
|
4489
|
+
}
|
|
4490
|
+
//#endregion
|
|
4491
|
+
//#region src/cli/setup/paths.ts
|
|
4492
|
+
/**
|
|
4493
|
+
* Where each agent tool keeps the files kanbo writes into, for one project and
|
|
4494
|
+
* for the person's whole machine.
|
|
4495
|
+
*
|
|
4496
|
+
* Resolved on every call rather than at import, so `HOME` and `CODEX_HOME` set
|
|
4497
|
+
* by a test (or a person) are the ones obeyed. Each path was checked against
|
|
4498
|
+
* the tool's own documentation; `docs/agents.md` lists the pages.
|
|
4499
|
+
*/
|
|
4500
|
+
/** The tools whose user-level instruction file `kanbo init --global` can write. */
|
|
4501
|
+
const GLOBAL_INSTRUCTION_CLIENTS = [
|
|
4502
|
+
"claude",
|
|
4503
|
+
"codex",
|
|
4504
|
+
"gemini"
|
|
4505
|
+
];
|
|
4506
|
+
/** The files a project's agents read their standing instructions from. */
|
|
4507
|
+
const PROJECT_INSTRUCTION_FILES = {
|
|
4508
|
+
claude: "CLAUDE.md",
|
|
4509
|
+
agents: "AGENTS.md"
|
|
4510
|
+
};
|
|
4511
|
+
/** The tools that can be told about the board's MCP server. */
|
|
4512
|
+
const MCP_CLIENTS = [
|
|
4513
|
+
"claude",
|
|
4514
|
+
"codex",
|
|
4515
|
+
"cursor"
|
|
4516
|
+
];
|
|
4517
|
+
/** Where Codex keeps its global files: `$CODEX_HOME`, else `~/.codex`. */
|
|
4518
|
+
function codexHome() {
|
|
4519
|
+
return process.env.CODEX_HOME?.trim() || join(homedir(), ".codex");
|
|
4520
|
+
}
|
|
4521
|
+
/** The user-level instruction file of each tool. */
|
|
4522
|
+
function globalInstructionPath(client) {
|
|
4523
|
+
switch (client) {
|
|
4524
|
+
case "claude": return join(homedir(), ".claude", "CLAUDE.md");
|
|
4525
|
+
case "codex": return join(codexHome(), "AGENTS.md");
|
|
4526
|
+
case "gemini": return join(homedir(), ".gemini", "GEMINI.md");
|
|
4527
|
+
}
|
|
4528
|
+
}
|
|
4529
|
+
/**
|
|
4530
|
+
* The user-level MCP configuration of each tool. Claude Code's is
|
|
4531
|
+
* `~/.claude.json`, its own state file: kanbo reads it but never writes it —
|
|
4532
|
+
* `claude mcp add` and `claude mcp remove` do.
|
|
4533
|
+
*/
|
|
4534
|
+
function globalMcpConfigPath(client) {
|
|
4535
|
+
switch (client) {
|
|
4536
|
+
case "claude": return join(homedir(), ".claude.json");
|
|
4537
|
+
case "codex": return join(codexHome(), "config.toml");
|
|
4538
|
+
case "cursor": return join(homedir(), ".cursor", "mcp.json");
|
|
4539
|
+
}
|
|
4540
|
+
}
|
|
4541
|
+
/** The project-level MCP configuration of each tool. */
|
|
4542
|
+
function projectMcpConfigPath(projectDir, client) {
|
|
4543
|
+
switch (client) {
|
|
4544
|
+
case "claude": return join(projectDir, ".mcp.json");
|
|
4545
|
+
case "codex": return join(projectDir, ".codex", "config.toml");
|
|
4546
|
+
case "cursor": return join(projectDir, ".cursor", "mcp.json");
|
|
4547
|
+
}
|
|
4548
|
+
}
|
|
4549
|
+
/**
|
|
4550
|
+
* Every executable of that name on `PATH`, in the order a shell would find
|
|
4551
|
+
* them. A path with a separator in it is looked at directly, as a shell does.
|
|
4552
|
+
*/
|
|
4553
|
+
function findAllOnPath(command) {
|
|
4554
|
+
if (isAbsolute(command) || command.includes("/")) return isExecutableFile(command) ? [command] : [];
|
|
4555
|
+
const extensions = process.platform === "win32" ? ["", ...(process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";")] : [""];
|
|
4556
|
+
const found = [];
|
|
4557
|
+
for (const directory of (process.env.PATH ?? "").split(delimiter).filter(Boolean)) for (const extension of extensions) {
|
|
4558
|
+
const candidate = join(directory, command + extension);
|
|
4559
|
+
if (isExecutableFile(candidate) && !found.includes(candidate)) found.push(candidate);
|
|
4560
|
+
}
|
|
4561
|
+
return found;
|
|
4562
|
+
}
|
|
4563
|
+
/** The executable a shell would start for that command, or `null` when there is none. */
|
|
4564
|
+
function findOnPath(command) {
|
|
4565
|
+
return findAllOnPath(command)[0] ?? null;
|
|
4566
|
+
}
|
|
4567
|
+
function isExecutableFile(path) {
|
|
4568
|
+
try {
|
|
4569
|
+
if (!statSync(path).isFile()) return false;
|
|
4570
|
+
accessSync(path, constants.X_OK);
|
|
4571
|
+
return true;
|
|
4572
|
+
} catch {
|
|
4573
|
+
return false;
|
|
4574
|
+
}
|
|
4575
|
+
}
|
|
4576
|
+
//#endregion
|
|
4577
|
+
//#region src/cli/setup/mcp-config.ts
|
|
4578
|
+
/**
|
|
4579
|
+
* The board's MCP server entry, in the two formats the tools keep it in: the
|
|
4580
|
+
* `mcpServers` JSON map Claude Code (`.mcp.json`) and Cursor (`mcp.json`) read,
|
|
4581
|
+
* and the `[mcp_servers.<name>]` TOML table Codex reads (`config.toml`). Each
|
|
4582
|
+
* is planned before anything is written, found again by the doctor, and taken
|
|
4583
|
+
* out by `kanbo uninstall` without touching any other server.
|
|
4584
|
+
*/
|
|
4585
|
+
/** The name the board's MCP server is registered under, in every tool. */
|
|
4586
|
+
const MCP_SERVER_NAME = "kanbo";
|
|
4587
|
+
/** How every registration kanbo writes starts the server. */
|
|
4588
|
+
const MCP_COMMAND = "kanbo";
|
|
4589
|
+
const MCP_ARGS = ["mcp"];
|
|
4590
|
+
/** The line that registers the server with Claude Code for every project of this user. */
|
|
4591
|
+
const CLAUDE_USER_ADD = [
|
|
4592
|
+
"claude",
|
|
4593
|
+
"mcp",
|
|
4594
|
+
"add",
|
|
4595
|
+
"--scope",
|
|
4596
|
+
"user",
|
|
4597
|
+
MCP_SERVER_NAME,
|
|
4598
|
+
"--",
|
|
4599
|
+
MCP_COMMAND,
|
|
4600
|
+
...MCP_ARGS
|
|
4601
|
+
];
|
|
4602
|
+
/** The line that takes that registration out again. */
|
|
4603
|
+
const CLAUDE_USER_REMOVE = [
|
|
4604
|
+
"claude",
|
|
4605
|
+
"mcp",
|
|
4606
|
+
"remove",
|
|
4607
|
+
MCP_SERVER_NAME,
|
|
4608
|
+
"--scope",
|
|
4609
|
+
"user"
|
|
4610
|
+
];
|
|
4611
|
+
/**
|
|
4612
|
+
* A Codex table header naming this server or one of its subtables
|
|
4613
|
+
* (`[mcp_servers.kanbo.env]`), in every spelling TOML allows for the key: bare,
|
|
4614
|
+
* double-quoted and single-quoted all name the same server, and a check that
|
|
4615
|
+
* only knew the bare one would write a second table beside a registration the
|
|
4616
|
+
* person already has.
|
|
4617
|
+
*/
|
|
4618
|
+
const CODEX_HEADER_PATTERN = new RegExp(String.raw`^\s*\[\s*mcp_servers\s*\.\s*(?:${MCP_SERVER_NAME}|"${MCP_SERVER_NAME}"|'${MCP_SERVER_NAME}')\s*(\.[^\]]*)?\]`);
|
|
4619
|
+
/** Any table header, which is where a table's keys end. */
|
|
4620
|
+
const TOML_HEADER_PATTERN = /^\s*\[/;
|
|
4621
|
+
/** A `command = "..."` line, either string spelling. */
|
|
4622
|
+
const TOML_COMMAND_PATTERN = /^\s*command\s*=\s*(?:"([^"]*)"|'([^']*)')/m;
|
|
4623
|
+
/**
|
|
4624
|
+
* The `mcpServers` map, merged rather than replaced: the file may already
|
|
4625
|
+
* describe servers that have nothing to do with this board. A `kanbo` entry
|
|
4626
|
+
* that is already there belongs to the person — it may point at a different
|
|
4627
|
+
* binary or carry arguments of its own — and is left as it is.
|
|
4628
|
+
*/
|
|
4629
|
+
function planJsonMcpServer(path) {
|
|
4630
|
+
const existing = readJsonConfig(path);
|
|
4631
|
+
if (existing.mcpServers && "kanbo" in existing.mcpServers) return {
|
|
4632
|
+
path,
|
|
4633
|
+
next: null
|
|
4634
|
+
};
|
|
4635
|
+
const next = {
|
|
4636
|
+
...existing,
|
|
4637
|
+
mcpServers: {
|
|
4638
|
+
...existing.mcpServers,
|
|
4639
|
+
[MCP_SERVER_NAME]: {
|
|
4640
|
+
type: "stdio",
|
|
4641
|
+
command: MCP_COMMAND,
|
|
4642
|
+
args: [...MCP_ARGS]
|
|
4643
|
+
}
|
|
4644
|
+
}
|
|
4645
|
+
};
|
|
4646
|
+
return {
|
|
4647
|
+
path,
|
|
4648
|
+
next: `${JSON.stringify(next, null, 2)}\n`
|
|
4649
|
+
};
|
|
4650
|
+
}
|
|
4651
|
+
/**
|
|
4652
|
+
* The same file without the `kanbo` entry. Everything else stays, the
|
|
4653
|
+
* `mcpServers` object included when nothing else is left in it: kanbo does not
|
|
4654
|
+
* record which files it created, so it leaves the structure rather than guess.
|
|
4655
|
+
* A file it cannot read as a JSON object is not touched at all.
|
|
4656
|
+
*/
|
|
4657
|
+
function planJsonMcpServerRemoval(path) {
|
|
4658
|
+
const existing = readJsonIfObject(path);
|
|
4659
|
+
if (!existing || !isPlainObject(existing.mcpServers) || !("kanbo" in existing.mcpServers)) return {
|
|
4660
|
+
path,
|
|
4661
|
+
next: null
|
|
4662
|
+
};
|
|
4663
|
+
const { [MCP_SERVER_NAME]: _removed, ...others } = existing.mcpServers;
|
|
4664
|
+
return {
|
|
4665
|
+
path,
|
|
4666
|
+
next: `${JSON.stringify({
|
|
4667
|
+
...existing,
|
|
4668
|
+
mcpServers: others
|
|
4669
|
+
}, null, 2)}\n`
|
|
4670
|
+
};
|
|
4671
|
+
}
|
|
4672
|
+
/**
|
|
4673
|
+
* The command a JSON registration starts the server with: `undefined` when the
|
|
4674
|
+
* file registers no `kanbo` server, `null` when it does but names no command
|
|
4675
|
+
* (a URL server, say).
|
|
4676
|
+
*/
|
|
4677
|
+
function readJsonMcpCommand(path) {
|
|
4678
|
+
const servers = readJsonIfObject(path)?.mcpServers;
|
|
4679
|
+
if (!isPlainObject(servers) || !isPlainObject(servers["kanbo"])) return;
|
|
4680
|
+
const command = servers[MCP_SERVER_NAME].command;
|
|
4681
|
+
return typeof command === "string" && command.trim() ? command.trim() : null;
|
|
4682
|
+
}
|
|
4683
|
+
/** Codex keeps its servers in TOML tables, so the table is appended rather than merged. */
|
|
4684
|
+
function planCodexMcpServer(path) {
|
|
4685
|
+
const existing = existsSync(path) ? readFileSync(path, "utf8") : "";
|
|
4686
|
+
if (findCodexSections(existing).length > 0) return {
|
|
4687
|
+
path,
|
|
4688
|
+
next: null
|
|
4689
|
+
};
|
|
4690
|
+
const table = `[mcp_servers.${MCP_SERVER_NAME}]\ncommand = "${MCP_COMMAND}"\nargs = ${JSON.stringify(MCP_ARGS)}\n`;
|
|
4691
|
+
return {
|
|
4692
|
+
path,
|
|
4693
|
+
next: existing.trim() ? `${existing.replace(/\s*$/, "")}\n\n${table}` : table
|
|
4694
|
+
};
|
|
4695
|
+
}
|
|
4696
|
+
/**
|
|
4697
|
+
* The same file without the `kanbo` table and its subtables. A table runs from
|
|
4698
|
+
* its header to the next header, so every other table — and every line before
|
|
4699
|
+
* the first — is kept byte for byte.
|
|
4700
|
+
*/
|
|
4701
|
+
function planCodexMcpServerRemoval(path) {
|
|
4702
|
+
if (!existsSync(path)) return {
|
|
4703
|
+
path,
|
|
4704
|
+
next: null
|
|
4705
|
+
};
|
|
4706
|
+
const existing = readFileSync(path, "utf8");
|
|
4707
|
+
const sections = findCodexSections(existing);
|
|
4708
|
+
if (sections.length === 0) return {
|
|
4709
|
+
path,
|
|
4710
|
+
next: null
|
|
4711
|
+
};
|
|
4712
|
+
const lines = existing.split("\n");
|
|
4713
|
+
const removed = new Set(sections.flatMap(({ start, end }) => range(start, end)));
|
|
4714
|
+
const next = lines.filter((_, index) => !removed.has(index)).join("\n").replace(/^\n+/, "");
|
|
4715
|
+
return {
|
|
4716
|
+
path,
|
|
4717
|
+
next: next.trim() ? `${next.replace(/\s*$/, "")}\n` : ""
|
|
4718
|
+
};
|
|
4719
|
+
}
|
|
4720
|
+
/** The command the Codex table starts the server with, with the same `undefined`/`null` meaning as the JSON one. */
|
|
4721
|
+
function readCodexMcpCommand(path) {
|
|
4722
|
+
if (!existsSync(path)) return;
|
|
4723
|
+
const text = readFileSync(path, "utf8");
|
|
4724
|
+
const main = findCodexSections(text).find((section) => section.main);
|
|
4725
|
+
if (!main) return;
|
|
4726
|
+
const body = text.split("\n").slice(main.start, main.end).join("\n");
|
|
4727
|
+
const match = TOML_COMMAND_PATTERN.exec(body);
|
|
4728
|
+
return match ? match[1] ?? match[2] ?? null : null;
|
|
4729
|
+
}
|
|
4730
|
+
/** Is the server registered with Claude Code for every project of this user (`~/.claude.json`, read only)? */
|
|
4731
|
+
function readClaudeUserMcpCommand() {
|
|
4732
|
+
return readJsonMcpCommand(globalMcpConfigPath("claude"));
|
|
4733
|
+
}
|
|
4734
|
+
/**
|
|
4735
|
+
* Run `claude mcp …` when Claude Code is here to run it, and hand the line to
|
|
4736
|
+
* the person when it is not — or when it failed, with the first line it said.
|
|
4737
|
+
* `~/.claude.json` is Claude Code's own state file and is never edited by hand.
|
|
4738
|
+
*/
|
|
4739
|
+
function runClaudeMcp(argv) {
|
|
4740
|
+
const command = argv.join(" ");
|
|
4741
|
+
const executable = findOnPath(argv[0]);
|
|
4742
|
+
if (!executable) return {
|
|
4743
|
+
state: "manual",
|
|
4744
|
+
command,
|
|
4745
|
+
reason: `${argv[0]} is not on PATH`
|
|
4746
|
+
};
|
|
4747
|
+
const result = spawnSync(executable, argv.slice(1), {
|
|
4748
|
+
encoding: "utf8",
|
|
4749
|
+
timeout: 6e4
|
|
4750
|
+
});
|
|
4751
|
+
if (result.status === 0) return {
|
|
4752
|
+
state: "ran",
|
|
4753
|
+
command
|
|
4754
|
+
};
|
|
4755
|
+
const said = `${result.stderr ?? ""}${result.stdout ?? ""}`.trim().split("\n")[0];
|
|
4756
|
+
return {
|
|
4757
|
+
state: "manual",
|
|
4758
|
+
command,
|
|
4759
|
+
reason: result.error ? result.error.message : `${argv[0]} exited ${result.status ?? "on a signal"}${said ? `: ${said}` : ""}`
|
|
4760
|
+
};
|
|
4761
|
+
}
|
|
4762
|
+
/** The line ranges (`end` exclusive) of the `kanbo` table and its subtables. */
|
|
4763
|
+
function findCodexSections(text) {
|
|
4764
|
+
const lines = text.split("\n");
|
|
4765
|
+
const sections = [];
|
|
4766
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
4767
|
+
const match = CODEX_HEADER_PATTERN.exec(lines[index]);
|
|
4768
|
+
if (!match) continue;
|
|
4769
|
+
let end = index + 1;
|
|
4770
|
+
while (end < lines.length && !TOML_HEADER_PATTERN.test(lines[end])) end += 1;
|
|
4771
|
+
sections.push({
|
|
4772
|
+
start: index,
|
|
4773
|
+
end,
|
|
4774
|
+
main: match[1] === void 0
|
|
4775
|
+
});
|
|
4776
|
+
index = end - 1;
|
|
4777
|
+
}
|
|
4778
|
+
return sections;
|
|
4779
|
+
}
|
|
4780
|
+
function range(start, end) {
|
|
4781
|
+
return Array.from({ length: end - start }, (_, offset) => start + offset);
|
|
4782
|
+
}
|
|
4783
|
+
/**
|
|
4784
|
+
* The tool's configuration file as an object to merge into — or a refusal.
|
|
4785
|
+
*
|
|
4786
|
+
* A file that is valid JSON but not an object (a list, a string, `null`) is
|
|
4787
|
+
* something this command has no idea how to merge into, and spreading it would
|
|
4788
|
+
* quietly throw the person's file away. The file is left exactly as it is and
|
|
4789
|
+
* they are told which one to look at.
|
|
4790
|
+
*/
|
|
4791
|
+
function readJsonConfig(path) {
|
|
4792
|
+
if (!existsSync(path)) return {};
|
|
4793
|
+
let parsed;
|
|
4794
|
+
try {
|
|
4795
|
+
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
4796
|
+
} catch {
|
|
4797
|
+
throw new CliError(1, `${path} is not valid JSON. Fix or remove it, then run kanbo init again.`);
|
|
4798
|
+
}
|
|
4799
|
+
if (!isPlainObject(parsed)) throw new CliError(1, `${path} does not hold a JSON object. Fix or remove it, then run kanbo init again.`);
|
|
4800
|
+
if (parsed.mcpServers !== void 0 && !isPlainObject(parsed.mcpServers)) throw new CliError(1, `${path} has an "mcpServers" that is not an object. Fix it, then run kanbo init again.`);
|
|
4801
|
+
return parsed;
|
|
4802
|
+
}
|
|
4803
|
+
/** The file as a JSON object, or `null` when it is missing or anything else — for reading and removal, which never refuse. */
|
|
4804
|
+
function readJsonIfObject(path) {
|
|
4805
|
+
if (!existsSync(path)) return null;
|
|
4806
|
+
try {
|
|
4807
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
4808
|
+
return isPlainObject(parsed) ? parsed : null;
|
|
4809
|
+
} catch {
|
|
4810
|
+
return null;
|
|
4811
|
+
}
|
|
4812
|
+
}
|
|
4813
|
+
function isPlainObject(value) {
|
|
4814
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4815
|
+
}
|
|
4816
|
+
//#endregion
|
|
4817
|
+
//#region src/cli/doctor.ts
|
|
4818
|
+
/** How long an external board may take to answer before the doctor gives up on it. */
|
|
4819
|
+
const POSTGRES_TIMEOUT_MS = 5e3;
|
|
4820
|
+
async function collectDoctorFindings(input) {
|
|
4821
|
+
const findings = [{
|
|
4822
|
+
check: "version",
|
|
4823
|
+
status: "ok",
|
|
4824
|
+
detail: `kanbo ${KANBO_PACKAGE_VERSION}${input.self ? ` (${input.self})` : ""}`
|
|
4825
|
+
}, checkPath(input.self)];
|
|
4826
|
+
const project = findKanboProject(input.cwd);
|
|
4827
|
+
findings.push(checkProject(project));
|
|
4828
|
+
const target = project?.binding ? resolveTarget(project.root) : null;
|
|
4829
|
+
if (project?.binding && !project.binding.databaseUrl) findings.push(await checkSqlite());
|
|
4830
|
+
if (project?.binding && findings.every((finding) => finding.check !== "sqlite" || finding.status === "ok")) findings.push(...await checkBoard(target));
|
|
4831
|
+
findings.push(...checkInstructions(project?.root ?? null));
|
|
4832
|
+
const registrations = findRegistrations(project?.root ?? null);
|
|
4833
|
+
findings.push(...checkRegistrations(registrations));
|
|
4834
|
+
if (project?.binding && !(target instanceof Error)) findings.push(await checkHandshake(registrations, project.root, input.handshakeTimeoutMs));
|
|
4835
|
+
findings.push(checkActor());
|
|
4836
|
+
return findings;
|
|
4837
|
+
}
|
|
4838
|
+
/** Is the `kanbo` a client would start this one? */
|
|
4839
|
+
function checkPath(self) {
|
|
4840
|
+
const all = findAllOnPath(MCP_COMMAND);
|
|
4841
|
+
if (all.length === 0) return {
|
|
4842
|
+
check: "path",
|
|
4843
|
+
status: "warn",
|
|
4844
|
+
detail: "No kanbo on PATH: a shell or MCP client that runs `kanbo` will not find it.",
|
|
4845
|
+
fix: "Install kanbo globally (see docs/installation.md), or put the directory that holds it on PATH."
|
|
4846
|
+
};
|
|
4847
|
+
const first = all[0];
|
|
4848
|
+
if (self && realPath(first) !== realPath(self)) return {
|
|
4849
|
+
check: "path",
|
|
4850
|
+
status: "warn",
|
|
4851
|
+
detail: `${first} comes first on PATH and is not this kanbo (${self}): agents and MCP clients start that one.`,
|
|
4852
|
+
fix: "Remove the other install, or put this one first on PATH."
|
|
4853
|
+
};
|
|
4854
|
+
return {
|
|
4855
|
+
check: "path",
|
|
4856
|
+
status: "ok",
|
|
4857
|
+
detail: `kanbo on PATH: ${first}`
|
|
4858
|
+
};
|
|
4859
|
+
}
|
|
4860
|
+
/** The nearest folder at or above `cwd` with a `.kanbo/` directory, and its binding. */
|
|
4861
|
+
function findKanboProject(cwd) {
|
|
4862
|
+
let directory = resolve(cwd);
|
|
4863
|
+
while (true) {
|
|
4864
|
+
const kanboDirectory = join(directory, dirname(BINDING_FILE_PATH));
|
|
4865
|
+
if (existsSync(kanboDirectory) && statSync(kanboDirectory).isDirectory()) return {
|
|
4866
|
+
root: directory,
|
|
4867
|
+
binding: readBinding(join(directory, BINDING_FILE_PATH))
|
|
4868
|
+
};
|
|
4869
|
+
const parent = dirname(directory);
|
|
4870
|
+
if (parent === directory) return null;
|
|
4871
|
+
directory = parent;
|
|
4872
|
+
}
|
|
4873
|
+
}
|
|
4874
|
+
function checkProject(project) {
|
|
4875
|
+
if (!project) return {
|
|
4876
|
+
check: "binding",
|
|
4877
|
+
status: "warn",
|
|
4878
|
+
detail: "Not inside a kanbo project (no .kanbo/ here or above); board checks are skipped.",
|
|
4879
|
+
fix: "Run kanbo init --file in a project to give it a board."
|
|
4880
|
+
};
|
|
4881
|
+
const path = join(project.root, BINDING_FILE_PATH);
|
|
4882
|
+
if (!project.binding) return {
|
|
4883
|
+
check: "binding",
|
|
4884
|
+
status: "fail",
|
|
4885
|
+
detail: existsSync(path) ? `${path} is not a binding this build can read.` : `${join(project.root, dirname(BINDING_FILE_PATH))} has no ${BINDING_FILE_PATH.split(/[\\/]/).pop()}: nothing says which board this project is on.`,
|
|
4886
|
+
fix: `Run kanbo init (with --file, or the --database-url you used) in ${project.root} to bind it again.`
|
|
4887
|
+
};
|
|
4888
|
+
return {
|
|
4889
|
+
check: "binding",
|
|
4890
|
+
status: "ok",
|
|
4891
|
+
detail: `${path}: workspace ${project.binding.workspaceId}`
|
|
4892
|
+
};
|
|
4893
|
+
}
|
|
4894
|
+
function resolveTarget(root) {
|
|
4895
|
+
try {
|
|
4896
|
+
return resolveDbTarget({ cwd: root });
|
|
4897
|
+
} catch (error) {
|
|
4898
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
4901
|
+
/** The native module a board file needs, loaded on a database of its own in memory. */
|
|
4902
|
+
async function checkSqlite() {
|
|
4903
|
+
try {
|
|
4904
|
+
(await openBoardDatabase(":memory:")).close();
|
|
4905
|
+
return {
|
|
4906
|
+
check: "sqlite",
|
|
4907
|
+
status: "ok",
|
|
4908
|
+
detail: "better-sqlite3 loads."
|
|
4909
|
+
};
|
|
4910
|
+
} catch (error) {
|
|
4911
|
+
return {
|
|
4912
|
+
check: "sqlite",
|
|
4913
|
+
status: "fail",
|
|
4914
|
+
detail: `better-sqlite3 cannot be loaded: ${describeFailure(error).message}`,
|
|
4915
|
+
fix: "Install better-sqlite3 next to kanbo (npm install -g better-sqlite3 for a global kanbo)."
|
|
4916
|
+
};
|
|
4917
|
+
}
|
|
4918
|
+
}
|
|
4919
|
+
/** The board itself: it opens, and its schema is this build's. */
|
|
4920
|
+
async function checkBoard(target) {
|
|
4921
|
+
if (target === null) return [];
|
|
4922
|
+
if (target instanceof Error) return [{
|
|
4923
|
+
check: "board",
|
|
4924
|
+
status: "fail",
|
|
4925
|
+
detail: describeFailure(target).message,
|
|
4926
|
+
fix: "Run kanbo init in the project to bind it to a board."
|
|
4927
|
+
}];
|
|
4928
|
+
if (target.kind === "postgres") return [await checkPostgresBoard(target.url)];
|
|
4929
|
+
const board = await openBoardDatabase(target.path);
|
|
4930
|
+
try {
|
|
4931
|
+
assertBoardSchema$1(board.database);
|
|
4932
|
+
return [{
|
|
4933
|
+
check: "board",
|
|
4934
|
+
status: "ok",
|
|
4935
|
+
detail: `${target.path} opens; its schema is current.`
|
|
4936
|
+
}];
|
|
4937
|
+
} catch (error) {
|
|
4938
|
+
const outdated = error instanceof BoardError && error.code === "board_schema_outdated";
|
|
4939
|
+
const ownFile = target.owner === "kanbo";
|
|
4940
|
+
return [{
|
|
4941
|
+
check: "board",
|
|
4942
|
+
status: "fail",
|
|
4943
|
+
detail: outdated ? `${target.path}: ${ownFile ? FILE_SCHEMA_OUTDATED_MESSAGE : SCHEMA_OUTDATED_MESSAGE}` : `${target.path}: ${describeFailure(error).message}`,
|
|
4944
|
+
fix: ownFile ? "Run kanbo migrate." : "Start the app this database belongs to, so it applies its migrations."
|
|
4945
|
+
}];
|
|
4946
|
+
} finally {
|
|
4947
|
+
board.close();
|
|
4948
|
+
}
|
|
4949
|
+
}
|
|
4950
|
+
async function checkPostgresBoard(url) {
|
|
4951
|
+
const where = maskDatabaseUrl(url);
|
|
4952
|
+
let timer;
|
|
4953
|
+
const timeout = new Promise((_, reject) => {
|
|
4954
|
+
timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`no answer within ${POSTGRES_TIMEOUT_MS / 1e3}s`)), POSTGRES_TIMEOUT_MS);
|
|
4955
|
+
});
|
|
4956
|
+
try {
|
|
4957
|
+
const board = await Promise.race([openPostgresBoard(url), timeout]);
|
|
4958
|
+
try {
|
|
4959
|
+
await Promise.race([assertInstalledBoard(board.database), timeout]);
|
|
4960
|
+
} finally {
|
|
4961
|
+
board.close();
|
|
4962
|
+
}
|
|
4963
|
+
return {
|
|
4964
|
+
check: "board",
|
|
4965
|
+
status: "ok",
|
|
4966
|
+
detail: `${where} answers; its schema is current.`
|
|
4967
|
+
};
|
|
4968
|
+
} catch (error) {
|
|
4969
|
+
return {
|
|
4970
|
+
check: "board",
|
|
4971
|
+
status: "fail",
|
|
4972
|
+
detail: `${where}: ${describeFailure(error).message}`,
|
|
4973
|
+
fix: "Check the connection string, then run kanbo migrate."
|
|
4974
|
+
};
|
|
4975
|
+
} finally {
|
|
4976
|
+
clearTimeout(timer);
|
|
4977
|
+
}
|
|
4978
|
+
}
|
|
4979
|
+
/**
|
|
4980
|
+
* Every instruction block kanbo could have written, compared with the one this
|
|
4981
|
+
* build writes. Only files that carry a block are reported: a file without one
|
|
4982
|
+
* is not a fault, but having no block anywhere is worth a warning.
|
|
4983
|
+
*/
|
|
4984
|
+
function checkInstructions(root) {
|
|
4985
|
+
const findings = [];
|
|
4986
|
+
if (root) for (const [target, name] of Object.entries(PROJECT_INSTRUCTION_FILES)) {
|
|
4987
|
+
const path = join(root, name);
|
|
4988
|
+
const block = readInstructionBlock(path);
|
|
4989
|
+
if (block !== null) findings.push(blockFinding(path, block === INSTRUCTION_BLOCK, `cd ${root} && kanbo init --instructions ${target} --yes`));
|
|
4990
|
+
}
|
|
4991
|
+
for (const client of GLOBAL_INSTRUCTION_CLIENTS) {
|
|
4992
|
+
const path = globalInstructionPath(client);
|
|
4993
|
+
const block = readInstructionBlock(path);
|
|
4994
|
+
if (block !== null) findings.push(blockFinding(path, block === GLOBAL_INSTRUCTION_BLOCK, `kanbo init --global --instructions ${client}`));
|
|
4995
|
+
}
|
|
4996
|
+
if (findings.length === 0) findings.push({
|
|
4997
|
+
check: "instructions",
|
|
4998
|
+
status: "warn",
|
|
4999
|
+
detail: "No kanbo instruction block in this project's or your own agent files: agents learn the rules only from the MCP server.",
|
|
5000
|
+
fix: "Run kanbo init --instructions claude in the project, or kanbo init --global."
|
|
5001
|
+
});
|
|
5002
|
+
return findings;
|
|
5003
|
+
}
|
|
5004
|
+
function blockFinding(path, current, fix) {
|
|
5005
|
+
return current ? {
|
|
5006
|
+
check: "instructions",
|
|
5007
|
+
status: "ok",
|
|
5008
|
+
detail: `${path}: block is current.`
|
|
5009
|
+
} : {
|
|
5010
|
+
check: "instructions",
|
|
5011
|
+
status: "fail",
|
|
5012
|
+
detail: `${path}: block differs from the one this kanbo writes (stale).`,
|
|
5013
|
+
fix: `Run ${fix} to rewrite it.`
|
|
5014
|
+
};
|
|
5015
|
+
}
|
|
5016
|
+
/** Every `kanbo` registration in the project's and the person's own tool configuration. */
|
|
5017
|
+
function findRegistrations(root) {
|
|
5018
|
+
const found = [];
|
|
5019
|
+
for (const client of MCP_CLIENTS) {
|
|
5020
|
+
const paths = [...root ? [projectMcpConfigPath(root, client)] : [], globalMcpConfigPath(client)];
|
|
5021
|
+
for (const path of paths) {
|
|
5022
|
+
const command = client === "codex" ? readCodexMcpCommand(path) : readJsonMcpCommand(path);
|
|
5023
|
+
if (command !== void 0) found.push({
|
|
5024
|
+
client,
|
|
5025
|
+
path,
|
|
5026
|
+
command
|
|
5027
|
+
});
|
|
5028
|
+
}
|
|
5029
|
+
}
|
|
5030
|
+
return found;
|
|
5031
|
+
}
|
|
5032
|
+
function checkRegistrations(registrations) {
|
|
5033
|
+
if (registrations.length === 0) return [{
|
|
5034
|
+
check: "mcp",
|
|
5035
|
+
status: "warn",
|
|
5036
|
+
detail: "No MCP client has the kanbo server registered.",
|
|
5037
|
+
fix: "Run kanbo init --mcp claude,codex,cursor in the project, or kanbo init --global."
|
|
5038
|
+
}];
|
|
5039
|
+
return registrations.map(({ client, path, command }) => {
|
|
5040
|
+
const check = `mcp:${client}`;
|
|
5041
|
+
if (command === null) return {
|
|
5042
|
+
check,
|
|
5043
|
+
status: "warn",
|
|
5044
|
+
detail: `${path}: the kanbo entry names no command.`,
|
|
5045
|
+
fix: `Set "command" to kanbo in ${path}.`
|
|
5046
|
+
};
|
|
5047
|
+
const resolved = findOnPath(command);
|
|
5048
|
+
return resolved ? {
|
|
5049
|
+
check,
|
|
5050
|
+
status: "ok",
|
|
5051
|
+
detail: `${path}: starts ${command} (${resolved}).`
|
|
5052
|
+
} : {
|
|
5053
|
+
check,
|
|
5054
|
+
status: "fail",
|
|
5055
|
+
detail: `${path}: starts ${command}, which is not on PATH — the client cannot start the server.`,
|
|
5056
|
+
fix: `Install kanbo globally, or change the command in ${path} to a path that exists.`
|
|
5057
|
+
};
|
|
5058
|
+
});
|
|
5059
|
+
}
|
|
5060
|
+
/**
|
|
5061
|
+
* Start the server a client would start, from the project folder, and ask it
|
|
5062
|
+
* `initialize`. It has to call itself `kanbo` and send its instructions.
|
|
5063
|
+
*/
|
|
5064
|
+
async function checkHandshake(registrations, root, timeoutMs) {
|
|
5065
|
+
const command = registrations.map((entry) => entry.command && findOnPath(entry.command)).find(Boolean) ?? findOnPath("kanbo");
|
|
5066
|
+
if (!command) return {
|
|
5067
|
+
check: "mcp:handshake",
|
|
5068
|
+
status: "warn",
|
|
5069
|
+
detail: "No kanbo to start, so the MCP server was not tried.",
|
|
5070
|
+
fix: "Put kanbo on PATH."
|
|
5071
|
+
};
|
|
5072
|
+
const transport = new StdioClientTransport({
|
|
5073
|
+
command,
|
|
5074
|
+
args: ["mcp"],
|
|
5075
|
+
cwd: root,
|
|
5076
|
+
env: stringEnvironment(),
|
|
5077
|
+
stderr: "pipe"
|
|
5078
|
+
});
|
|
5079
|
+
let stderr = "";
|
|
5080
|
+
transport.stderr?.on("data", (chunk) => {
|
|
5081
|
+
stderr += chunk.toString();
|
|
5082
|
+
});
|
|
5083
|
+
const client = new Client({
|
|
5084
|
+
name: "kanbo-doctor",
|
|
5085
|
+
version: KANBO_PACKAGE_VERSION
|
|
5086
|
+
});
|
|
5087
|
+
try {
|
|
5088
|
+
await client.connect(transport, { timeout: timeoutMs });
|
|
5089
|
+
const name = client.getServerVersion()?.name;
|
|
5090
|
+
const instructions = client.getInstructions();
|
|
5091
|
+
if (name !== "kanbo" || !instructions?.trim()) return {
|
|
5092
|
+
check: "mcp:handshake",
|
|
5093
|
+
status: "fail",
|
|
5094
|
+
detail: `${command} mcp answered as ${name ?? "nothing"}${instructions?.trim() ? "" : ", without instructions"}.`,
|
|
5095
|
+
fix: "Put a current kanbo first on PATH."
|
|
5096
|
+
};
|
|
5097
|
+
return {
|
|
5098
|
+
check: "mcp:handshake",
|
|
5099
|
+
status: "ok",
|
|
5100
|
+
detail: `${command} mcp answers initialize as kanbo, with instructions.`
|
|
5101
|
+
};
|
|
5102
|
+
} catch (error) {
|
|
5103
|
+
return {
|
|
5104
|
+
check: "mcp:handshake",
|
|
5105
|
+
status: "fail",
|
|
5106
|
+
detail: `${command} mcp did not answer initialize: ${stderr.trim().split("\n")[0] || describeFailure(error).message}`,
|
|
5107
|
+
fix: "Run kanbo mcp in the project yourself to see why it does not start."
|
|
5108
|
+
};
|
|
5109
|
+
} finally {
|
|
5110
|
+
await client.close().catch(() => {});
|
|
5111
|
+
}
|
|
5112
|
+
}
|
|
5113
|
+
function checkActor() {
|
|
5114
|
+
if (isAgentShell()) return {
|
|
5115
|
+
check: "actor",
|
|
5116
|
+
status: "warn",
|
|
5117
|
+
detail: "This shell says it belongs to an agent (KANBO_ACTOR_KIND=agent): approve and return refuse here.",
|
|
5118
|
+
fix: "If this is your own terminal, remove KANBO_ACTOR_KIND from your shell profile."
|
|
5119
|
+
};
|
|
5120
|
+
return {
|
|
5121
|
+
check: "actor",
|
|
5122
|
+
status: "ok",
|
|
5123
|
+
detail: "This shell is a person's."
|
|
5124
|
+
};
|
|
5125
|
+
}
|
|
5126
|
+
/** The environment as the SDK wants it: every value a string, so `KANBO_*` reaches the server as it would from a client. */
|
|
5127
|
+
function stringEnvironment() {
|
|
5128
|
+
return Object.fromEntries(Object.entries(process.env).filter((entry) => entry[1] !== void 0));
|
|
5129
|
+
}
|
|
5130
|
+
function realPath(path) {
|
|
5131
|
+
try {
|
|
5132
|
+
return realpathSync(path);
|
|
5133
|
+
} catch {
|
|
5134
|
+
return path;
|
|
5135
|
+
}
|
|
5136
|
+
}
|
|
5137
|
+
//#endregion
|
|
5138
|
+
//#region src/cli/commands/doctor.ts
|
|
5139
|
+
/** How long `kanbo mcp` may take to answer `initialize`. */
|
|
5140
|
+
const HANDSHAKE_TIMEOUT_MS = 1e4;
|
|
5141
|
+
const MARKS = {
|
|
5142
|
+
ok: "ok ",
|
|
5143
|
+
warn: "warn",
|
|
5144
|
+
fail: "FAIL"
|
|
5145
|
+
};
|
|
5146
|
+
function registerDoctorCommand(program) {
|
|
5147
|
+
program.command("doctor").description("check this install, this project's binding and board, instruction blocks and MCP registrations").option("--json", "print the findings as JSON").action(async (options) => {
|
|
5148
|
+
const findings = await collectDoctorFindings({
|
|
5149
|
+
cwd: process.cwd(),
|
|
5150
|
+
self: process.argv[1] ?? null,
|
|
5151
|
+
handshakeTimeoutMs: HANDSHAKE_TIMEOUT_MS
|
|
5152
|
+
});
|
|
5153
|
+
if (options.json) console.log(JSON.stringify({
|
|
5154
|
+
version: KANBO_PACKAGE_VERSION,
|
|
5155
|
+
findings
|
|
5156
|
+
}, null, 2));
|
|
5157
|
+
else for (const finding of findings) {
|
|
5158
|
+
console.log(`${MARKS[finding.status]} ${finding.check.padEnd(14)} ${finding.detail}`);
|
|
5159
|
+
if (finding.fix) console.log(`${" ".repeat(21)}fix: ${finding.fix}`);
|
|
5160
|
+
}
|
|
5161
|
+
const failed = findings.filter((finding) => finding.status === "fail").length;
|
|
5162
|
+
if (failed > 0) throw new CliError(1, `kanbo doctor: ${failed} check${failed === 1 ? "" : "s"} failed.`);
|
|
5163
|
+
});
|
|
5164
|
+
}
|
|
5165
|
+
//#endregion
|
|
4304
5166
|
//#region src/default-board-file-path.ts
|
|
4305
5167
|
/**
|
|
4306
5168
|
* Where a board file of a project's own goes when nobody names a path —
|
|
@@ -4309,6 +5171,168 @@ function readRequestedRules(options) {
|
|
|
4309
5171
|
*/
|
|
4310
5172
|
const DEFAULT_BOARD_FILE_PATH = join(".kanbo", "board.db");
|
|
4311
5173
|
//#endregion
|
|
5174
|
+
//#region src/cli/setup/confirm.ts
|
|
5175
|
+
/**
|
|
5176
|
+
* Show a plan of file changes and ask before carrying it out.
|
|
5177
|
+
*
|
|
5178
|
+
* `--yes` is the answer given in advance. A shell with nobody at its terminal
|
|
5179
|
+
* cannot be asked, so it is refused rather than taken as a yes: these commands
|
|
5180
|
+
* write into a person's own configuration, which is the kind of thing a person
|
|
5181
|
+
* says yes to. When the caller asked for machine output, stdout belongs to the
|
|
5182
|
+
* result and the plan goes to stderr.
|
|
5183
|
+
*/
|
|
5184
|
+
async function confirmPlan(input) {
|
|
5185
|
+
(input.machineOutput ? console.error : console.log)(input.preview);
|
|
5186
|
+
if (input.yes) return true;
|
|
5187
|
+
if (!isInteractive()) throw new CliError(1, `Nothing was changed. Run ${input.command} again with --yes to do this without being asked.`);
|
|
5188
|
+
return await (await import("@clack/prompts")).confirm({ message: input.question }) === true;
|
|
5189
|
+
}
|
|
5190
|
+
/** Is there a person on the other end of this shell to ask? */
|
|
5191
|
+
function isInteractive() {
|
|
5192
|
+
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
5193
|
+
}
|
|
5194
|
+
//#endregion
|
|
5195
|
+
//#region src/cli/setup/file-change.ts
|
|
5196
|
+
/** Write the change, creating the directory it lives in, and say what happened. */
|
|
5197
|
+
function applyFileChange(change) {
|
|
5198
|
+
if (change.next === null) return {
|
|
5199
|
+
path: change.path,
|
|
5200
|
+
state: "unchanged"
|
|
5201
|
+
};
|
|
5202
|
+
mkdirSync(dirname(change.path), { recursive: true });
|
|
5203
|
+
writeFileSync(change.path, change.next);
|
|
5204
|
+
return {
|
|
5205
|
+
path: change.path,
|
|
5206
|
+
state: "written"
|
|
5207
|
+
};
|
|
5208
|
+
}
|
|
5209
|
+
//#endregion
|
|
5210
|
+
//#region src/cli/commands/init-global.ts
|
|
5211
|
+
/**
|
|
5212
|
+
* `kanbo init --global` — this person's own agent tools, told about kanbo once
|
|
5213
|
+
* for every project.
|
|
5214
|
+
*
|
|
5215
|
+
* It binds no board and creates none: the block it writes says "a project with
|
|
5216
|
+
* `.kanbo/` is on a board", and a project becomes one with a plain `kanbo init`.
|
|
5217
|
+
* The MCP registrations are the same `kanbo mcp` every project registration
|
|
5218
|
+
* starts, which resolves the board from the folder the client starts it in.
|
|
5219
|
+
*
|
|
5220
|
+
* Every change is worked out first and shown; nothing is written until the
|
|
5221
|
+
* person says yes (or said `--yes`), and a file that already says it is
|
|
5222
|
+
* reported `unchanged`.
|
|
5223
|
+
*/
|
|
5224
|
+
/** Written when `--instructions` is not given. Gemini is asked for by name. */
|
|
5225
|
+
const DEFAULT_INSTRUCTION_CLIENTS = ["claude", "codex"];
|
|
5226
|
+
/** The flags that are about binding a project, which `--global` does not do. */
|
|
5227
|
+
const PROJECT_ONLY_FLAGS = [
|
|
5228
|
+
["file", "--file"],
|
|
5229
|
+
["db", "--db"],
|
|
5230
|
+
["databaseUrl", "--database-url"],
|
|
5231
|
+
["workspace", "--workspace"],
|
|
5232
|
+
["board", "--board"],
|
|
5233
|
+
["identifier", "--identifier"],
|
|
5234
|
+
["agentUrl", "--agent-url"]
|
|
5235
|
+
];
|
|
5236
|
+
async function initGlobal(options) {
|
|
5237
|
+
const format = readFormat(options);
|
|
5238
|
+
const given = PROJECT_ONLY_FLAGS.filter(([key]) => options[key] !== void 0).map(([, flag]) => flag);
|
|
5239
|
+
if (given.length > 0) throw new CliError(1, `--global binds no board; ${given.join(", ")} ${given.length === 1 ? "is" : "are"} for a project. Run kanbo init in the project for that.`);
|
|
5240
|
+
const instructionClients = parseGlobalInstructions(options.instructions);
|
|
5241
|
+
const mcpClients = options.mcp ?? [...MCP_CLIENTS];
|
|
5242
|
+
const instructionChanges = instructionClients.map((client) => ({
|
|
5243
|
+
client,
|
|
5244
|
+
change: planInstructionBlock(globalInstructionPath(client), GLOBAL_INSTRUCTION_BLOCK)
|
|
5245
|
+
}));
|
|
5246
|
+
const fileMcpChanges = mcpClients.filter((client) => client !== "claude").map((client) => ({
|
|
5247
|
+
client,
|
|
5248
|
+
change: planGlobalMcpFile(client)
|
|
5249
|
+
}));
|
|
5250
|
+
const claudeNeeded = mcpClients.includes("claude") && readClaudeUserMcpCommand() === void 0;
|
|
5251
|
+
const pending = [...instructionChanges, ...fileMcpChanges].filter(({ change }) => change.next !== null);
|
|
5252
|
+
let confirmed = true;
|
|
5253
|
+
if (pending.length > 0 || claudeNeeded) confirmed = await confirmPlan({
|
|
5254
|
+
preview: describePlan$1(pending.map(({ change }) => change), claudeNeeded),
|
|
5255
|
+
question: "Make these changes?",
|
|
5256
|
+
yes: options.yes,
|
|
5257
|
+
machineOutput: Boolean(options.json || format),
|
|
5258
|
+
command: "kanbo init --global"
|
|
5259
|
+
});
|
|
5260
|
+
if (!confirmed) throw new CliError(1, "Nothing was changed.");
|
|
5261
|
+
printResult(describeResult(instructionChanges.map(({ client, change }) => ({
|
|
5262
|
+
client,
|
|
5263
|
+
...applyFileChange(change)
|
|
5264
|
+
})), mcpClients.map((client) => {
|
|
5265
|
+
if (client === "claude") return registerWithClaude(claudeNeeded);
|
|
5266
|
+
return {
|
|
5267
|
+
client,
|
|
5268
|
+
...applyFileChange(fileMcpChanges.find((entry) => entry.client === client).change)
|
|
5269
|
+
};
|
|
5270
|
+
})), options);
|
|
5271
|
+
}
|
|
5272
|
+
function planGlobalMcpFile(client) {
|
|
5273
|
+
const path = globalMcpConfigPath(client);
|
|
5274
|
+
return client === "codex" ? planCodexMcpServer(path) : planJsonMcpServer(path);
|
|
5275
|
+
}
|
|
5276
|
+
/** Claude Code's user-scope registration goes through its own command, never an edit of `~/.claude.json`. */
|
|
5277
|
+
function registerWithClaude(needed) {
|
|
5278
|
+
const path = globalMcpConfigPath("claude");
|
|
5279
|
+
if (!needed) return {
|
|
5280
|
+
client: "claude",
|
|
5281
|
+
path,
|
|
5282
|
+
state: "unchanged"
|
|
5283
|
+
};
|
|
5284
|
+
const outcome = runClaudeMcp(CLAUDE_USER_ADD);
|
|
5285
|
+
return outcome.state === "ran" ? {
|
|
5286
|
+
client: "claude",
|
|
5287
|
+
path,
|
|
5288
|
+
state: "written",
|
|
5289
|
+
command: outcome.command
|
|
5290
|
+
} : {
|
|
5291
|
+
client: "claude",
|
|
5292
|
+
path,
|
|
5293
|
+
state: "manual",
|
|
5294
|
+
command: outcome.command,
|
|
5295
|
+
reason: outcome.reason
|
|
5296
|
+
};
|
|
5297
|
+
}
|
|
5298
|
+
function describePlan$1(changes, claudeNeeded) {
|
|
5299
|
+
const lines = ["kanbo init --global will:"];
|
|
5300
|
+
for (const change of changes) lines.push(` write ${change.path}`);
|
|
5301
|
+
if (claudeNeeded) lines.push(` run ${CLAUDE_USER_ADD.join(" ")}`);
|
|
5302
|
+
lines.push("No board is created. Narrow this with --instructions and --mcp.");
|
|
5303
|
+
return lines.join("\n");
|
|
5304
|
+
}
|
|
5305
|
+
function describeResult(instructions, mcp) {
|
|
5306
|
+
const lines = [];
|
|
5307
|
+
for (const outcome of instructions) lines.push(`Instructions: ${outcome.path} (${outcome.state})`);
|
|
5308
|
+
for (const outcome of mcp) if (outcome.state === "manual") lines.push(`MCP: ${outcome.client} — run this yourself: ${outcome.command} (${outcome.reason})`);
|
|
5309
|
+
else lines.push(`MCP: ${outcome.path} (${outcome.state})`);
|
|
5310
|
+
lines.push("A project uses the board once it has run kanbo init. Check everything with kanbo doctor.");
|
|
5311
|
+
return {
|
|
5312
|
+
value: {
|
|
5313
|
+
scope: "global",
|
|
5314
|
+
instructions,
|
|
5315
|
+
mcp
|
|
5316
|
+
},
|
|
5317
|
+
text: lines.join("\n"),
|
|
5318
|
+
fields: [
|
|
5319
|
+
"scope",
|
|
5320
|
+
"instructions",
|
|
5321
|
+
"mcp"
|
|
5322
|
+
]
|
|
5323
|
+
};
|
|
5324
|
+
}
|
|
5325
|
+
function parseGlobalInstructions(value) {
|
|
5326
|
+
if (value === void 0) return DEFAULT_INSTRUCTION_CLIENTS;
|
|
5327
|
+
const names = value.split(",").map((name) => name.trim()).filter((name) => name.length > 0);
|
|
5328
|
+
if (names.length === 1 && names[0] === "none") return [];
|
|
5329
|
+
return names.map((name) => {
|
|
5330
|
+
const client = GLOBAL_INSTRUCTION_CLIENTS.find((candidate) => candidate === name);
|
|
5331
|
+
if (!client) throw new CliError(1, `Unknown instructions target "${name}" for --global. Use one or more of ${GLOBAL_INSTRUCTION_CLIENTS.join(", ")}, or none.`);
|
|
5332
|
+
return client;
|
|
5333
|
+
});
|
|
5334
|
+
}
|
|
5335
|
+
//#endregion
|
|
4312
5336
|
//#region src/cli/commands/init.ts
|
|
4313
5337
|
/**
|
|
4314
5338
|
* `kanbo init` — tying a project folder to a board, and telling the agents
|
|
@@ -4321,22 +5345,6 @@ const DEFAULT_BOARD_FILE_PATH = join(".kanbo", "board.db");
|
|
|
4321
5345
|
* whichever tools the person actually uses. Nothing is written to a file the
|
|
4322
5346
|
* person did not ask for, and nothing is written twice.
|
|
4323
5347
|
*/
|
|
4324
|
-
/** The markers that make the instruction block something this tool can find again. */
|
|
4325
|
-
const INSTRUCTION_START = "<!-- KANBO_START -->";
|
|
4326
|
-
const INSTRUCTION_END = "<!-- KANBO_END -->";
|
|
4327
|
-
/** The files an agent reads its standing instructions from. */
|
|
4328
|
-
const INSTRUCTION_FILES = {
|
|
4329
|
-
claude: "CLAUDE.md",
|
|
4330
|
-
agents: "AGENTS.md"
|
|
4331
|
-
};
|
|
4332
|
-
/** The tools that can be told about the board's MCP server. */
|
|
4333
|
-
const MCP_CLIENTS = [
|
|
4334
|
-
"claude",
|
|
4335
|
-
"codex",
|
|
4336
|
-
"cursor"
|
|
4337
|
-
];
|
|
4338
|
-
/** The name the board's MCP server is registered under, in every tool. */
|
|
4339
|
-
const MCP_SERVER_NAME = "kanbo";
|
|
4340
5348
|
/**
|
|
4341
5349
|
* What a person is told when an external board is named and nothing says which
|
|
4342
5350
|
* workspace it is about. There is no table to look the answer up in, and a card
|
|
@@ -4351,40 +5359,13 @@ const FILE_AND_DATABASE_URL_MESSAGE = "One board at a time: pass --file for a bo
|
|
|
4351
5359
|
* rule an agent is missing is one the database keeps, not this command.
|
|
4352
5360
|
*/
|
|
4353
5361
|
const AGENT_URL_MISSING_WARNING = "kanbo: agents in this project will reach the board with the connection string you gave, which owns it. Until you run \"kanbo roles apply\" and record the agent role's own string with --agent-url, an agent here can approve its own work.";
|
|
4354
|
-
/**
|
|
4355
|
-
* The Codex table this command writes, in every spelling TOML allows for the
|
|
4356
|
-
* key: bare, double-quoted and single-quoted all name the same server, and a
|
|
4357
|
-
* check that only knew the bare one would write a second table beside a
|
|
4358
|
-
* registration the person already has.
|
|
4359
|
-
*/
|
|
4360
|
-
const CODEX_TABLE_PATTERN = new RegExp(String.raw`^\s*\[\s*mcp_servers\s*\.\s*(?:${MCP_SERVER_NAME}|"${MCP_SERVER_NAME}"|'${MCP_SERVER_NAME}')\s*\]`, "m");
|
|
4361
|
-
/**
|
|
4362
|
-
* What an agent working in this project is told about the board.
|
|
4363
|
-
*
|
|
4364
|
-
* It says what to run and when, and nothing about how to do the work: the
|
|
4365
|
-
* method is the person's own instructions to their agent, and the board only
|
|
4366
|
-
* insists on the part that keeps the card honest. The rules are the sentences
|
|
4367
|
-
* `ops/agent-rules.ts` holds for every surface, with the command beside each.
|
|
4368
|
-
*/
|
|
4369
|
-
const INSTRUCTION_BLOCK = [
|
|
4370
|
-
INSTRUCTION_START,
|
|
4371
|
-
"## Kanbo board",
|
|
4372
|
-
"",
|
|
4373
|
-
"Work on this project is tracked on a kanbo board. Before starting a task run `kanbo prime` — it prints the board's columns and what each one means.",
|
|
4374
|
-
"",
|
|
4375
|
-
"- Take a card from `kanbo ready`.",
|
|
4376
|
-
`- ${MOVE_CARD_RULE} (\`kanbo card move <id> <column>\`)`,
|
|
4377
|
-
`- ${STATUS_LINE_RULE} (\`kanbo card status-line <id> --text "..."\`)`,
|
|
4378
|
-
`- ${SUBTASK_RULE} (\`kanbo card create --description "..." --parent <id>\`)`,
|
|
4379
|
-
`- ${COMMENT_RULE} (\`kanbo card comment <id> --content "..."\`)`,
|
|
4380
|
-
`- ${WAIT_FOR_PERSON_RULE} (\`kanbo card wait-approval <id>\`)`,
|
|
4381
|
-
`- ${PERSON_ONLY_RULE}`,
|
|
4382
|
-
`- ${OWN_SESSION_RULE} (\`kanbo run start <id> --agent <name> --session <ref>\`)`,
|
|
4383
|
-
"- Run `kanbo capabilities` for the full list of tools, commands and rules.",
|
|
4384
|
-
INSTRUCTION_END
|
|
4385
|
-
].join("\n");
|
|
4386
5362
|
function registerInitCommand(program) {
|
|
4387
|
-
program.command("init").description("bind this project to a board, and tell its agents about it").option("--db <path>", "host database file to read this project's workspace from").option("--database-url <url>", "external Postgres board to bind this project to").option("--file [path]", `use a board file of this project's own instead of a host database or an external board (default ${DEFAULT_BOARD_FILE_PATH})`).option("--workspace <nameOrId>", "workspace this project is").option("--json <fields>", "print only these comma-separated fields, as JSON").option("--format <format>", "output format: json or pretty").option("--board <id>", "the board inside the workspace, when it has more than one").option("--identifier <key>", "what this workspace's card keys start with, for an external board").option("--agent-url <url>", "the connection string agents get, when it is not the one above").option("--instructions <file>", "where to write the instruction block: claude, agents or none
|
|
5363
|
+
program.command("init").description("bind this project to a board, and tell its agents about it").option("--db <path>", "host database file to read this project's workspace from").option("--database-url <url>", "external Postgres board to bind this project to").option("--file [path]", `use a board file of this project's own instead of a host database or an external board (default ${DEFAULT_BOARD_FILE_PATH})`).option("--workspace <nameOrId>", "workspace this project is").option("--json <fields>", "print only these comma-separated fields, as JSON").option("--format <format>", "output format: json or pretty").option("--board <id>", "the board inside the workspace, when it has more than one").option("--identifier <key>", "what this workspace's card keys start with, for an external board").option("--agent-url <url>", "the connection string agents get, when it is not the one above").option("--instructions <file>", "where to write the instruction block: claude, agents or none; with --global, a comma-separated list of claude, codex, gemini, or none").option("--mcp <clients>", `register the board's MCP server with ${MCP_CLIENTS.join(", ")}`, parseMcpClients).option("--global", "set up your own agent tools for every project instead of binding this one; binds no board").option("--yes", "take the defaults instead of asking").action(async (options) => {
|
|
5364
|
+
if (options.global) {
|
|
5365
|
+
await initGlobal(options);
|
|
5366
|
+
return;
|
|
5367
|
+
}
|
|
5368
|
+
if (options.instructions !== void 0) parseInstructions(options.instructions);
|
|
4388
5369
|
const projectDir = process.cwd();
|
|
4389
5370
|
if (options.file !== void 0) {
|
|
4390
5371
|
await initOwnFile(projectDir, options);
|
|
@@ -4717,9 +5698,9 @@ function warnAboutOwnerAccess(target, options) {
|
|
|
4717
5698
|
* instructions is the kind of thing a person says yes to.
|
|
4718
5699
|
*/
|
|
4719
5700
|
async function writeInstructions(projectDir, options) {
|
|
4720
|
-
const target = options.instructions
|
|
5701
|
+
const target = options.instructions === void 0 ? await askInstructionTarget(options) : parseInstructions(options.instructions);
|
|
4721
5702
|
if (target === "none") return null;
|
|
4722
|
-
return
|
|
5703
|
+
return applyFileChange(planInstructionBlock(join(projectDir, PROJECT_INSTRUCTION_FILES[target]), INSTRUCTION_BLOCK));
|
|
4723
5704
|
}
|
|
4724
5705
|
async function askInstructionTarget(options) {
|
|
4725
5706
|
showBlock(options);
|
|
@@ -4753,35 +5734,6 @@ function showBlock(options) {
|
|
|
4753
5734
|
if (!options.json && !options.format) console.log(`${INSTRUCTION_BLOCK}\n`);
|
|
4754
5735
|
}
|
|
4755
5736
|
/**
|
|
4756
|
-
* The block, in that file, once.
|
|
4757
|
-
*
|
|
4758
|
-
* A file that already carries the markers has its block replaced rather than
|
|
4759
|
-
* appended to, so running `init` again on a project whose block is current
|
|
4760
|
-
* changes nothing at all, and running it after an upgrade brings the block
|
|
4761
|
-
* forward. Everything outside the markers is the person's own writing and is
|
|
4762
|
-
* never touched.
|
|
4763
|
-
*/
|
|
4764
|
-
function writeInstructionBlock(path) {
|
|
4765
|
-
const existing = existsSync(path) ? readFileSync(path, "utf8") : null;
|
|
4766
|
-
const next = buildInstructionFile(existing);
|
|
4767
|
-
if (existing === next) return {
|
|
4768
|
-
path,
|
|
4769
|
-
state: "unchanged"
|
|
4770
|
-
};
|
|
4771
|
-
writeFileSync(path, next);
|
|
4772
|
-
return {
|
|
4773
|
-
path,
|
|
4774
|
-
state: "written"
|
|
4775
|
-
};
|
|
4776
|
-
}
|
|
4777
|
-
function buildInstructionFile(existing) {
|
|
4778
|
-
if (existing === null) return `${INSTRUCTION_BLOCK}\n`;
|
|
4779
|
-
const start = existing.indexOf(INSTRUCTION_START);
|
|
4780
|
-
const end = existing.indexOf(INSTRUCTION_END);
|
|
4781
|
-
if (start >= 0 && end > start) return existing.slice(0, start) + INSTRUCTION_BLOCK + existing.slice(end + 18);
|
|
4782
|
-
return `${existing.replace(/\s*$/, "")}\n\n${INSTRUCTION_BLOCK}\n`;
|
|
4783
|
-
}
|
|
4784
|
-
/**
|
|
4785
5737
|
* Tell the tools the person uses about the board's MCP server.
|
|
4786
5738
|
*
|
|
4787
5739
|
* Only the ones they named, and only when the tool does not already know: a
|
|
@@ -4816,81 +5768,8 @@ async function askMcpClients(options) {
|
|
|
4816
5768
|
return prompts.isCancel(answer) ? [] : answer;
|
|
4817
5769
|
}
|
|
4818
5770
|
function registerMcpServer(projectDir, client) {
|
|
4819
|
-
|
|
4820
|
-
return
|
|
4821
|
-
}
|
|
4822
|
-
/**
|
|
4823
|
-
* The `mcpServers` map Claude Code and Cursor both read, merged rather than
|
|
4824
|
-
* replaced: the file is the project's, and it may already describe servers that
|
|
4825
|
-
* have nothing to do with this board.
|
|
4826
|
-
*/
|
|
4827
|
-
function writeJsonMcpServer(path) {
|
|
4828
|
-
const existing = readJsonFile(path);
|
|
4829
|
-
if (existing.mcpServers && MCP_SERVER_NAME in existing.mcpServers) return {
|
|
4830
|
-
path,
|
|
4831
|
-
state: "unchanged"
|
|
4832
|
-
};
|
|
4833
|
-
const next = {
|
|
4834
|
-
...existing,
|
|
4835
|
-
mcpServers: {
|
|
4836
|
-
...existing.mcpServers,
|
|
4837
|
-
[MCP_SERVER_NAME]: {
|
|
4838
|
-
type: "stdio",
|
|
4839
|
-
command: "kanbo",
|
|
4840
|
-
args: ["mcp"]
|
|
4841
|
-
}
|
|
4842
|
-
}
|
|
4843
|
-
};
|
|
4844
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
4845
|
-
writeFileSync(path, `${JSON.stringify(next, null, 2)}\n`);
|
|
4846
|
-
return {
|
|
4847
|
-
path,
|
|
4848
|
-
state: "written"
|
|
4849
|
-
};
|
|
4850
|
-
}
|
|
4851
|
-
/**
|
|
4852
|
-
* The tool's configuration file as an object to merge into — or a refusal.
|
|
4853
|
-
*
|
|
4854
|
-
* A file that is valid JSON but not an object (a list, a string, `null`) is
|
|
4855
|
-
* something this command has no idea how to merge into, and spreading it would
|
|
4856
|
-
* quietly throw the person's file away. The file is left exactly as it is and
|
|
4857
|
-
* they are told which one to look at.
|
|
4858
|
-
*/
|
|
4859
|
-
function readJsonFile(path) {
|
|
4860
|
-
if (!existsSync(path)) return {};
|
|
4861
|
-
const parsed = parseJsonFile(path);
|
|
4862
|
-
if (!isPlainObject(parsed)) throw new CliError(1, `${path} does not hold a JSON object. Fix or remove it, then run kanbo init again.`);
|
|
4863
|
-
if (parsed.mcpServers !== void 0 && !isPlainObject(parsed.mcpServers)) throw new CliError(1, `${path} has an "mcpServers" that is not an object. Fix it, then run kanbo init again.`);
|
|
4864
|
-
return parsed;
|
|
4865
|
-
}
|
|
4866
|
-
function parseJsonFile(path) {
|
|
4867
|
-
try {
|
|
4868
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
4869
|
-
} catch {
|
|
4870
|
-
throw new CliError(1, `${path} is not valid JSON. Fix or remove it, then run kanbo init again.`);
|
|
4871
|
-
}
|
|
4872
|
-
}
|
|
4873
|
-
function isPlainObject(value) {
|
|
4874
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4875
|
-
}
|
|
4876
|
-
/** Codex keeps its servers in TOML tables, so the table is appended rather than merged. */
|
|
4877
|
-
function writeCodexMcpServer(path) {
|
|
4878
|
-
const existing = existsSync(path) ? readFileSync(path, "utf8") : "";
|
|
4879
|
-
const table = `[mcp_servers.${MCP_SERVER_NAME}]\ncommand = "kanbo"\nargs = ["mcp"]\n`;
|
|
4880
|
-
if (CODEX_TABLE_PATTERN.test(existing)) return {
|
|
4881
|
-
path,
|
|
4882
|
-
state: "unchanged"
|
|
4883
|
-
};
|
|
4884
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
4885
|
-
writeFileSync(path, existing.trim() ? `${existing.replace(/\s*$/, "")}\n\n${table}` : table);
|
|
4886
|
-
return {
|
|
4887
|
-
path,
|
|
4888
|
-
state: "written"
|
|
4889
|
-
};
|
|
4890
|
-
}
|
|
4891
|
-
/** Is there a person on the other end of this shell to ask? */
|
|
4892
|
-
function isInteractive() {
|
|
4893
|
-
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
5771
|
+
const path = projectMcpConfigPath(projectDir, client);
|
|
5772
|
+
return applyFileChange(client === "codex" ? planCodexMcpServer(path) : planJsonMcpServer(path));
|
|
4894
5773
|
}
|
|
4895
5774
|
function describeInit(workspace, target, bindingPath, instructions, mcp) {
|
|
4896
5775
|
const lines = [`Bound this project to ${workspace.name} — ${bindingPath}`];
|
|
@@ -5163,16 +6042,6 @@ async function createDbTransport(input) {
|
|
|
5163
6042
|
};
|
|
5164
6043
|
}
|
|
5165
6044
|
//#endregion
|
|
5166
|
-
//#region src/package-version.ts
|
|
5167
|
-
dirname(fileURLToPath(import.meta.url));
|
|
5168
|
-
/**
|
|
5169
|
-
* This build's own version, one source for the CLI's `--version`, the MCP
|
|
5170
|
-
* server's reported version and the capabilities manifest's
|
|
5171
|
-
* `package.version`. A build carries it as a literal; running from source
|
|
5172
|
-
* (tests, `tsx`) reads the package's own `package.json` instead.
|
|
5173
|
-
*/
|
|
5174
|
-
const KANBO_PACKAGE_VERSION = "0.1.2";
|
|
5175
|
-
//#endregion
|
|
5176
6045
|
//#region src/mcp/resources.ts
|
|
5177
6046
|
/** The URI a client reads the manifest as JSON from. */
|
|
5178
6047
|
const KANBO_CAPABILITIES_RESOURCE_URI = "kanbo://capabilities";
|
|
@@ -5625,74 +6494,6 @@ function createKanboMcpServer(transport, options) {
|
|
|
5625
6494
|
return server;
|
|
5626
6495
|
}
|
|
5627
6496
|
//#endregion
|
|
5628
|
-
//#region src/cli/failure.ts
|
|
5629
|
-
/**
|
|
5630
|
-
* What a failed command says, and what it leaves with.
|
|
5631
|
-
*
|
|
5632
|
-
* One place, because a failure is output as much as a result is: the exit code
|
|
5633
|
-
* a caller may branch on, the sentence a person reads, and the chain underneath
|
|
5634
|
-
* it that says what actually went wrong.
|
|
5635
|
-
*/
|
|
5636
|
-
/** How far down a chain of causes is still worth reading. */
|
|
5637
|
-
const CAUSE_DEPTH_LIMIT = 5;
|
|
5638
|
-
/**
|
|
5639
|
-
* What to say about a failure, and what to leave with.
|
|
5640
|
-
*
|
|
5641
|
-
* A `CliError` already carries both. A `BoardError` is a rule of the board the
|
|
5642
|
-
* caller broke: its code is the honest name of what happened, and its details
|
|
5643
|
-
* say which value did it, so both are printed rather than translated into a
|
|
5644
|
-
* sentence that could drift away from the rule. The one exception is a card
|
|
5645
|
-
* held at a column's door: its details are a list, and a person reads it as
|
|
5646
|
-
* one line per rule the card does not meet yet (`describeColumnRefusal`).
|
|
5647
|
-
*
|
|
5648
|
-
* Whatever it is, its causes are printed under it. A driver's failure arrives
|
|
5649
|
-
* wrapped — `Failed query: create schema …` with the connection refused
|
|
5650
|
-
* underneath — and the wrapper alone tells a person nothing they can act on.
|
|
5651
|
-
* Every line goes through the masking on its way out, because a message this
|
|
5652
|
-
* tool did not write is free to carry the whole connection string in it.
|
|
5653
|
-
*/
|
|
5654
|
-
function describeFailure(error) {
|
|
5655
|
-
const { message, exitCode } = readFailure(error);
|
|
5656
|
-
return {
|
|
5657
|
-
message: maskDatabaseUrls([message, ...describeCauses(error, 1)].join("\n")),
|
|
5658
|
-
exitCode
|
|
5659
|
-
};
|
|
5660
|
-
}
|
|
5661
|
-
function readFailure(error) {
|
|
5662
|
-
if (error instanceof CliError) return {
|
|
5663
|
-
message: error.message,
|
|
5664
|
-
exitCode: error.exitCode
|
|
5665
|
-
};
|
|
5666
|
-
if (error instanceof BoardError && error.code === "board_column_rules_unmet") return {
|
|
5667
|
-
message: describeColumnRefusal(error.details),
|
|
5668
|
-
exitCode: 1
|
|
5669
|
-
};
|
|
5670
|
-
if (error instanceof BoardError) {
|
|
5671
|
-
const details = error.details ? ` ${JSON.stringify(error.details)}` : "";
|
|
5672
|
-
return {
|
|
5673
|
-
message: `${error.code}${details}`,
|
|
5674
|
-
exitCode: 1
|
|
5675
|
-
};
|
|
5676
|
-
}
|
|
5677
|
-
return {
|
|
5678
|
-
message: error instanceof Error ? error.message : String(error),
|
|
5679
|
-
exitCode: 1
|
|
5680
|
-
};
|
|
5681
|
-
}
|
|
5682
|
-
/**
|
|
5683
|
-
* The chain under a failure, one indented line per link.
|
|
5684
|
-
*
|
|
5685
|
-
* Bounded, because `cause` is an ordinary property and nothing stops it
|
|
5686
|
-
* pointing back at the error it came from; a chain longer than this has stopped
|
|
5687
|
-
* explaining anything anyway.
|
|
5688
|
-
*/
|
|
5689
|
-
function describeCauses(error, depth) {
|
|
5690
|
-
const cause = error instanceof Error ? error.cause : void 0;
|
|
5691
|
-
if (cause === void 0 || cause === null || depth > CAUSE_DEPTH_LIMIT) return [];
|
|
5692
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
5693
|
-
return [`${" ".repeat(depth)}Caused by: ${message}`, ...describeCauses(cause, depth + 1)];
|
|
5694
|
-
}
|
|
5695
|
-
//#endregion
|
|
5696
6497
|
//#region src/cli/commands/mcp.ts
|
|
5697
6498
|
function registerMcpCommand(program) {
|
|
5698
6499
|
program.command("mcp").description("serve this board to an MCP client over stdio").option("--db <path>", "board database file to open").option("--database-url <url>", "external Postgres board to serve instead of a board file").option("--workspace <nameOrId>", "workspace the board tools are about").action(async (options) => {
|
|
@@ -7784,6 +8585,143 @@ function registerSprintCommands(program) {
|
|
|
7784
8585
|
});
|
|
7785
8586
|
}
|
|
7786
8587
|
//#endregion
|
|
8588
|
+
//#region src/cli/commands/uninstall.ts
|
|
8589
|
+
function registerUninstallCommand(program) {
|
|
8590
|
+
program.command("uninstall").description("remove what kanbo init wrote: instruction blocks and kanbo MCP entries; boards stay unless --purge").option("--project", "only this project's files").option("--global", "only your own user-level files").option("--purge", "also remove this project's .kanbo/binding.json, and its board file after a confirmation naming it").option("--yes", "do it without asking (never deletes a board file)").option("--json", "print what was done as JSON").action(async (options) => {
|
|
8591
|
+
await uninstall(options);
|
|
8592
|
+
});
|
|
8593
|
+
}
|
|
8594
|
+
async function uninstall(options) {
|
|
8595
|
+
const both = !options.project && !options.global;
|
|
8596
|
+
const withProject = both || Boolean(options.project);
|
|
8597
|
+
const withGlobal = both || Boolean(options.global);
|
|
8598
|
+
if (options.purge && !withProject) throw new CliError(1, "--purge removes a project's binding and board; run it without --global, in the project.");
|
|
8599
|
+
const projectRoot = withProject ? findKanboProject(process.cwd())?.root ?? process.cwd() : null;
|
|
8600
|
+
const edits = [...projectRoot ? planProjectEdits(projectRoot) : [], ...withGlobal ? planGlobalEdits() : []].filter((edit) => edit.change.next !== null);
|
|
8601
|
+
const claudeUser = withGlobal && readClaudeUserMcpCommand() !== void 0;
|
|
8602
|
+
const bindingPath = projectRoot && options.purge ? join(projectRoot, BINDING_FILE_PATH) : null;
|
|
8603
|
+
const purgeBinding = bindingPath !== null && existsSync(bindingPath);
|
|
8604
|
+
const boardFile = projectRoot && options.purge ? findOwnBoardFile(projectRoot) : null;
|
|
8605
|
+
const actions = [];
|
|
8606
|
+
if (edits.length > 0 || claudeUser || purgeBinding || boardFile) {
|
|
8607
|
+
if (!await confirmPlan({
|
|
8608
|
+
preview: describePlan(edits, claudeUser, purgeBinding ? bindingPath : null, boardFile),
|
|
8609
|
+
question: "Remove these?",
|
|
8610
|
+
yes: options.yes,
|
|
8611
|
+
machineOutput: Boolean(options.json),
|
|
8612
|
+
command: "kanbo uninstall"
|
|
8613
|
+
})) throw new CliError(1, "Nothing was changed.");
|
|
8614
|
+
for (const edit of edits) {
|
|
8615
|
+
applyFileChange(edit.change);
|
|
8616
|
+
actions.push({
|
|
8617
|
+
path: edit.change.path,
|
|
8618
|
+
action: "edited",
|
|
8619
|
+
note: edit.what
|
|
8620
|
+
});
|
|
8621
|
+
}
|
|
8622
|
+
if (claudeUser) {
|
|
8623
|
+
const outcome = runClaudeMcp(CLAUDE_USER_REMOVE);
|
|
8624
|
+
actions.push({
|
|
8625
|
+
path: globalMcpConfigPath("claude"),
|
|
8626
|
+
action: outcome.state,
|
|
8627
|
+
note: outcome.state === "ran" ? outcome.command : `run this yourself: ${outcome.command} (${outcome.reason})`
|
|
8628
|
+
});
|
|
8629
|
+
}
|
|
8630
|
+
if (purgeBinding) {
|
|
8631
|
+
rmSync(bindingPath);
|
|
8632
|
+
actions.push({
|
|
8633
|
+
path: bindingPath,
|
|
8634
|
+
action: "deleted",
|
|
8635
|
+
note: "project binding"
|
|
8636
|
+
});
|
|
8637
|
+
}
|
|
8638
|
+
if (boardFile) actions.push(await purgeBoardFile(boardFile));
|
|
8639
|
+
}
|
|
8640
|
+
printActions(actions, options);
|
|
8641
|
+
}
|
|
8642
|
+
function planProjectEdits(root) {
|
|
8643
|
+
return [...Object.values(PROJECT_INSTRUCTION_FILES).map((name) => ({
|
|
8644
|
+
change: planInstructionBlockRemoval(join(root, name)),
|
|
8645
|
+
what: "kanbo instruction block"
|
|
8646
|
+
})), ...[
|
|
8647
|
+
"claude",
|
|
8648
|
+
"codex",
|
|
8649
|
+
"cursor"
|
|
8650
|
+
].map((client) => ({
|
|
8651
|
+
change: planMcpRemoval(projectMcpConfigPath(root, client), client),
|
|
8652
|
+
what: "kanbo MCP server"
|
|
8653
|
+
}))];
|
|
8654
|
+
}
|
|
8655
|
+
function planGlobalEdits() {
|
|
8656
|
+
return [...GLOBAL_INSTRUCTION_CLIENTS.map((client) => ({
|
|
8657
|
+
change: planInstructionBlockRemoval(globalInstructionPath(client)),
|
|
8658
|
+
what: "kanbo instruction block"
|
|
8659
|
+
})), ...["codex", "cursor"].map((client) => ({
|
|
8660
|
+
change: planMcpRemoval(globalMcpConfigPath(client), client),
|
|
8661
|
+
what: "kanbo MCP server"
|
|
8662
|
+
}))];
|
|
8663
|
+
}
|
|
8664
|
+
function planMcpRemoval(path, client) {
|
|
8665
|
+
return client === "codex" ? planCodexMcpServerRemoval(path) : planJsonMcpServerRemoval(path);
|
|
8666
|
+
}
|
|
8667
|
+
/**
|
|
8668
|
+
* The board file `kanbo init --file` made for this project — the only board
|
|
8669
|
+
* `--purge` may offer to delete. A host app's database or an external board is
|
|
8670
|
+
* not kanbo's to delete, and a binding that names none offers nothing.
|
|
8671
|
+
*/
|
|
8672
|
+
function findOwnBoardFile(root) {
|
|
8673
|
+
const binding = findKanboProject(root)?.binding;
|
|
8674
|
+
if (!binding?.dbPath) return null;
|
|
8675
|
+
const path = resolve(root, binding.dbPath);
|
|
8676
|
+
return existsSync(path) ? path : null;
|
|
8677
|
+
}
|
|
8678
|
+
/** Delete the board file only on a yes to a question that names it; `--yes` is not that answer. */
|
|
8679
|
+
async function purgeBoardFile(path) {
|
|
8680
|
+
if (!isInteractive()) return {
|
|
8681
|
+
path,
|
|
8682
|
+
action: "kept",
|
|
8683
|
+
note: "board file: deleting it needs a confirmation in a terminal; delete it yourself if you mean to"
|
|
8684
|
+
};
|
|
8685
|
+
if (await (await import("@clack/prompts")).confirm({
|
|
8686
|
+
message: `Delete the board file ${path} and every card in it? This cannot be undone.`,
|
|
8687
|
+
initialValue: false
|
|
8688
|
+
}) !== true) return {
|
|
8689
|
+
path,
|
|
8690
|
+
action: "kept",
|
|
8691
|
+
note: "board file"
|
|
8692
|
+
};
|
|
8693
|
+
for (const file of [
|
|
8694
|
+
path,
|
|
8695
|
+
`${path}-wal`,
|
|
8696
|
+
`${path}-shm`
|
|
8697
|
+
]) rmSync(file, { force: true });
|
|
8698
|
+
return {
|
|
8699
|
+
path,
|
|
8700
|
+
action: "deleted",
|
|
8701
|
+
note: "board file"
|
|
8702
|
+
};
|
|
8703
|
+
}
|
|
8704
|
+
function describePlan(edits, claudeUser, bindingPath, boardFile) {
|
|
8705
|
+
const lines = ["kanbo uninstall will:"];
|
|
8706
|
+
for (const edit of edits) lines.push(` edit ${edit.change.path} (remove the ${edit.what})`);
|
|
8707
|
+
if (claudeUser) lines.push(` run ${CLAUDE_USER_REMOVE.join(" ")}`);
|
|
8708
|
+
if (bindingPath) lines.push(` delete ${bindingPath}`);
|
|
8709
|
+
if (boardFile) lines.push(` ask whether to delete the board file ${boardFile} (only in a terminal; --yes does not answer this)`);
|
|
8710
|
+
lines.push("Files stay even when nothing is left in them. Boards stay unless you confirm deleting one.");
|
|
8711
|
+
return lines.join("\n");
|
|
8712
|
+
}
|
|
8713
|
+
function printActions(actions, options) {
|
|
8714
|
+
if (options.json) {
|
|
8715
|
+
console.log(JSON.stringify({ actions }, null, 2));
|
|
8716
|
+
return;
|
|
8717
|
+
}
|
|
8718
|
+
if (actions.length === 0) {
|
|
8719
|
+
console.log("Nothing to remove: no kanbo block or MCP entry in the files kanbo writes.");
|
|
8720
|
+
return;
|
|
8721
|
+
}
|
|
8722
|
+
for (const action of actions) console.log(`${action.action.padEnd(8)} ${action.path}${action.note ? ` (${action.note})` : ""}`);
|
|
8723
|
+
}
|
|
8724
|
+
//#endregion
|
|
7787
8725
|
//#region src/cli/commands/index.ts
|
|
7788
8726
|
/**
|
|
7789
8727
|
* Every command the `kanbo` binary answers to, put on one program.
|
|
@@ -7797,6 +8735,8 @@ function registerSprintCommands(program) {
|
|
|
7797
8735
|
*/
|
|
7798
8736
|
function registerKanboCommands(program) {
|
|
7799
8737
|
registerInitCommand(program);
|
|
8738
|
+
registerDoctorCommand(program);
|
|
8739
|
+
registerUninstallCommand(program);
|
|
7800
8740
|
registerCapabilitiesCommand(program);
|
|
7801
8741
|
registerPrimeCommand(program);
|
|
7802
8742
|
registerReadyCommand(program);
|
|
@@ -8010,4 +8950,4 @@ function buildCapabilitiesManifest() {
|
|
|
8010
8950
|
//#endregion
|
|
8011
8951
|
export { commentAuthorReference as $, maskDatabaseUrls as A, readEntryRules as B, cardDisplayTitle as C, readProjectBinding as D, readBinding as E, ENTRY_RULES as F, normalizeStatusName as G, readChangeSeq as H, ENTRY_RULE_DESCRIPTIONS as I, BOARD_ACTOR as J, TRACKED_FIELDS as K, UNMET_ENTRY_RULE_REASONS as L, formatExternalSessionRef as M, parseExternalSessionRef as N, writeBinding as O, pullRequestFactKeys as P, activityToken as Q, evaluateEntryRules as R, renderCapabilitiesMarkdown as S, ignoreBoardFile as T, runBoardWrite as U, serializeEntryRules as V, DEFAULT_STATUSES as W, activityKindOrder as X, currentUnixSeconds as Y, activityText as Z, projectKanboPullRequest as _, BOARD_ERROR_RESPONSES as a, isOutsideWriter as at, projectKanboSubCard as b, registerKanboTools as c, formatIssueId as ct, KANBO_MCP_INSTRUCTIONS as d, nextIssueOrder as dt, formatActivityIssueReference as et, KANBO_CAPABILITIES_MARKDOWN_RESOURCE_URI as f, readIssuePrefix as ft, projectKanboColumn as g, projectKanboCard as h, KANBO_TOOL_NAMES as i, readSystemCommentKind as it, createBoardOps as j, maskDatabaseUrl as k, KANBO_TOOLS as l, nextIssueIdentity as lt, registerKanboCapabilitiesResources as m, buildCapabilitiesManifest as n, isEmptyActivityValue as nt, KANBO_MCP_SERVER_NAME as o, normalizeCommentAuthorKind as ot, KANBO_CAPABILITIES_RESOURCE_URI as p, diffFieldChanges as q, KANBO_TOOL_CLI_EQUIVALENTS as r, parseActivityStringArray as rt, createKanboMcpServer as s, toIssueView as st, CAPABILITIES_MANIFEST_VERSION as t, formatPlainActivityValue as tt, buildKanboTools as u, nextIssueNumber as ut, projectKanboRun as v, BINDING_FILE_PATH as w, DEFAULT_BOARD_FILE_PATH as x, projectKanboSprint as y, readChecklist as z };
|
|
8012
8952
|
|
|
8013
|
-
//# sourceMappingURL=manifest-
|
|
8953
|
+
//# sourceMappingURL=manifest-mkDJmxt2.mjs.map
|