@hasna/todos 0.2.2 → 0.3.1
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/cli/index.js +310 -38
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -6975,27 +6975,27 @@ __export(exports_serve, {
|
|
|
6975
6975
|
startServer: () => startServer
|
|
6976
6976
|
});
|
|
6977
6977
|
import { execSync } from "child_process";
|
|
6978
|
-
import { existsSync as
|
|
6979
|
-
import { join as
|
|
6978
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
6979
|
+
import { join as join3, dirname as dirname2, extname } from "path";
|
|
6980
6980
|
import { fileURLToPath } from "url";
|
|
6981
6981
|
function resolveDashboardDir() {
|
|
6982
6982
|
const candidates = [];
|
|
6983
6983
|
try {
|
|
6984
6984
|
const scriptDir = dirname2(fileURLToPath(import.meta.url));
|
|
6985
|
-
candidates.push(
|
|
6986
|
-
candidates.push(
|
|
6985
|
+
candidates.push(join3(scriptDir, "..", "dashboard", "dist"));
|
|
6986
|
+
candidates.push(join3(scriptDir, "..", "..", "dashboard", "dist"));
|
|
6987
6987
|
} catch {}
|
|
6988
6988
|
if (process.argv[1]) {
|
|
6989
6989
|
const mainDir = dirname2(process.argv[1]);
|
|
6990
|
-
candidates.push(
|
|
6991
|
-
candidates.push(
|
|
6990
|
+
candidates.push(join3(mainDir, "..", "dashboard", "dist"));
|
|
6991
|
+
candidates.push(join3(mainDir, "..", "..", "dashboard", "dist"));
|
|
6992
6992
|
}
|
|
6993
|
-
candidates.push(
|
|
6993
|
+
candidates.push(join3(process.cwd(), "dashboard", "dist"));
|
|
6994
6994
|
for (const candidate of candidates) {
|
|
6995
|
-
if (
|
|
6995
|
+
if (existsSync3(candidate))
|
|
6996
6996
|
return candidate;
|
|
6997
6997
|
}
|
|
6998
|
-
return
|
|
6998
|
+
return join3(process.cwd(), "dashboard", "dist");
|
|
6999
6999
|
}
|
|
7000
7000
|
function json(data, status = 200, port) {
|
|
7001
7001
|
return new Response(JSON.stringify(data), {
|
|
@@ -7009,14 +7009,14 @@ function json(data, status = 200, port) {
|
|
|
7009
7009
|
}
|
|
7010
7010
|
function getPackageVersion() {
|
|
7011
7011
|
try {
|
|
7012
|
-
const pkgPath =
|
|
7013
|
-
return JSON.parse(
|
|
7012
|
+
const pkgPath = join3(dirname2(fileURLToPath(import.meta.url)), "..", "..", "package.json");
|
|
7013
|
+
return JSON.parse(readFileSync2(pkgPath, "utf-8")).version || "0.0.0";
|
|
7014
7014
|
} catch {
|
|
7015
7015
|
return "0.0.0";
|
|
7016
7016
|
}
|
|
7017
7017
|
}
|
|
7018
7018
|
function serveStaticFile(filePath) {
|
|
7019
|
-
if (!
|
|
7019
|
+
if (!existsSync3(filePath))
|
|
7020
7020
|
return null;
|
|
7021
7021
|
const ext = extname(filePath);
|
|
7022
7022
|
const contentType = MIME_TYPES[ext] || "application/octet-stream";
|
|
@@ -7027,7 +7027,7 @@ function serveStaticFile(filePath) {
|
|
|
7027
7027
|
async function startServer(port, options) {
|
|
7028
7028
|
const shouldOpen = options?.open ?? true;
|
|
7029
7029
|
const dashboardDir = resolveDashboardDir();
|
|
7030
|
-
const dashboardExists =
|
|
7030
|
+
const dashboardExists = existsSync3(dashboardDir);
|
|
7031
7031
|
if (!dashboardExists) {
|
|
7032
7032
|
console.error(`
|
|
7033
7033
|
Dashboard not found at: ${dashboardDir}`);
|
|
@@ -7297,12 +7297,12 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
7297
7297
|
}
|
|
7298
7298
|
if (dashboardExists && (method === "GET" || method === "HEAD")) {
|
|
7299
7299
|
if (path !== "/") {
|
|
7300
|
-
const filePath =
|
|
7300
|
+
const filePath = join3(dashboardDir, path);
|
|
7301
7301
|
const res2 = serveStaticFile(filePath);
|
|
7302
7302
|
if (res2)
|
|
7303
7303
|
return res2;
|
|
7304
7304
|
}
|
|
7305
|
-
const indexPath =
|
|
7305
|
+
const indexPath = join3(dashboardDir, "index.html");
|
|
7306
7306
|
const res = serveStaticFile(indexPath);
|
|
7307
7307
|
if (res)
|
|
7308
7308
|
return res;
|
|
@@ -8433,13 +8433,184 @@ init_comments();
|
|
|
8433
8433
|
init_search();
|
|
8434
8434
|
import chalk from "chalk";
|
|
8435
8435
|
import { execSync as execSync2 } from "child_process";
|
|
8436
|
-
import { existsSync as
|
|
8437
|
-
import { basename, dirname as dirname3, join as
|
|
8436
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
8437
|
+
import { basename, dirname as dirname3, join as join4, resolve as resolve2 } from "path";
|
|
8438
8438
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
8439
|
+
|
|
8440
|
+
// src/lib/claude-tasks.ts
|
|
8441
|
+
init_tasks();
|
|
8442
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, readdirSync, writeFileSync } from "fs";
|
|
8443
|
+
import { join as join2 } from "path";
|
|
8444
|
+
var HOME = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
8445
|
+
function getTaskListDir(taskListId) {
|
|
8446
|
+
return join2(HOME, ".claude", "tasks", taskListId);
|
|
8447
|
+
}
|
|
8448
|
+
function readHighWaterMark(dir) {
|
|
8449
|
+
const path = join2(dir, ".highwatermark");
|
|
8450
|
+
if (!existsSync2(path))
|
|
8451
|
+
return 1;
|
|
8452
|
+
const val = parseInt(readFileSync(path, "utf-8").trim(), 10);
|
|
8453
|
+
return isNaN(val) ? 1 : val;
|
|
8454
|
+
}
|
|
8455
|
+
function writeHighWaterMark(dir, value) {
|
|
8456
|
+
writeFileSync(join2(dir, ".highwatermark"), String(value));
|
|
8457
|
+
}
|
|
8458
|
+
function readClaudeTask(dir, filename) {
|
|
8459
|
+
try {
|
|
8460
|
+
const content = readFileSync(join2(dir, filename), "utf-8");
|
|
8461
|
+
return JSON.parse(content);
|
|
8462
|
+
} catch {
|
|
8463
|
+
return null;
|
|
8464
|
+
}
|
|
8465
|
+
}
|
|
8466
|
+
function writeClaudeTask(dir, task) {
|
|
8467
|
+
writeFileSync(join2(dir, `${task.id}.json`), JSON.stringify(task, null, 2) + `
|
|
8468
|
+
`);
|
|
8469
|
+
}
|
|
8470
|
+
function toClaudeStatus(status) {
|
|
8471
|
+
if (status === "pending" || status === "in_progress" || status === "completed") {
|
|
8472
|
+
return status;
|
|
8473
|
+
}
|
|
8474
|
+
return "completed";
|
|
8475
|
+
}
|
|
8476
|
+
function toSqliteStatus(status) {
|
|
8477
|
+
return status;
|
|
8478
|
+
}
|
|
8479
|
+
function taskToClaudeTask(task, claudeTaskId) {
|
|
8480
|
+
return {
|
|
8481
|
+
id: claudeTaskId,
|
|
8482
|
+
subject: task.title,
|
|
8483
|
+
description: task.description || "",
|
|
8484
|
+
activeForm: "",
|
|
8485
|
+
status: toClaudeStatus(task.status),
|
|
8486
|
+
owner: task.assigned_to || task.agent_id || "",
|
|
8487
|
+
blocks: [],
|
|
8488
|
+
blockedBy: [],
|
|
8489
|
+
metadata: {
|
|
8490
|
+
todos_id: task.id,
|
|
8491
|
+
priority: task.priority
|
|
8492
|
+
}
|
|
8493
|
+
};
|
|
8494
|
+
}
|
|
8495
|
+
function pushToClaudeTaskList(taskListId, projectId) {
|
|
8496
|
+
const dir = getTaskListDir(taskListId);
|
|
8497
|
+
if (!existsSync2(dir))
|
|
8498
|
+
mkdirSync2(dir, { recursive: true });
|
|
8499
|
+
const filter = {};
|
|
8500
|
+
if (projectId)
|
|
8501
|
+
filter["project_id"] = projectId;
|
|
8502
|
+
const tasks = listTasks(filter);
|
|
8503
|
+
const existingByTodosId = new Map;
|
|
8504
|
+
const files = readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
8505
|
+
for (const f of files) {
|
|
8506
|
+
const ct = readClaudeTask(dir, f);
|
|
8507
|
+
if (ct?.metadata?.["todos_id"]) {
|
|
8508
|
+
existingByTodosId.set(ct.metadata["todos_id"], ct);
|
|
8509
|
+
}
|
|
8510
|
+
}
|
|
8511
|
+
let hwm = readHighWaterMark(dir);
|
|
8512
|
+
let pushed = 0;
|
|
8513
|
+
const errors = [];
|
|
8514
|
+
for (const task of tasks) {
|
|
8515
|
+
try {
|
|
8516
|
+
const existing = existingByTodosId.get(task.id);
|
|
8517
|
+
if (existing) {
|
|
8518
|
+
const updated = taskToClaudeTask(task, existing.id);
|
|
8519
|
+
updated.blocks = existing.blocks;
|
|
8520
|
+
updated.blockedBy = existing.blockedBy;
|
|
8521
|
+
updated.activeForm = existing.activeForm;
|
|
8522
|
+
writeClaudeTask(dir, updated);
|
|
8523
|
+
} else {
|
|
8524
|
+
const claudeId = String(hwm);
|
|
8525
|
+
hwm++;
|
|
8526
|
+
const ct = taskToClaudeTask(task, claudeId);
|
|
8527
|
+
writeClaudeTask(dir, ct);
|
|
8528
|
+
const current = getTask(task.id);
|
|
8529
|
+
if (current) {
|
|
8530
|
+
const newMeta = { ...current.metadata, claude_task_id: claudeId };
|
|
8531
|
+
updateTask(task.id, { version: current.version, metadata: newMeta });
|
|
8532
|
+
}
|
|
8533
|
+
}
|
|
8534
|
+
pushed++;
|
|
8535
|
+
} catch (e) {
|
|
8536
|
+
errors.push(`push ${task.id}: ${e instanceof Error ? e.message : String(e)}`);
|
|
8537
|
+
}
|
|
8538
|
+
}
|
|
8539
|
+
writeHighWaterMark(dir, hwm);
|
|
8540
|
+
return { pushed, pulled: 0, errors };
|
|
8541
|
+
}
|
|
8542
|
+
function pullFromClaudeTaskList(taskListId, projectId) {
|
|
8543
|
+
const dir = getTaskListDir(taskListId);
|
|
8544
|
+
if (!existsSync2(dir)) {
|
|
8545
|
+
return { pushed: 0, pulled: 0, errors: [`Task list directory not found: ${dir}`] };
|
|
8546
|
+
}
|
|
8547
|
+
const files = readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
8548
|
+
let pulled = 0;
|
|
8549
|
+
const errors = [];
|
|
8550
|
+
const allTasks = listTasks({});
|
|
8551
|
+
const byClaudeId = new Map;
|
|
8552
|
+
for (const t of allTasks) {
|
|
8553
|
+
const cid = t.metadata["claude_task_id"];
|
|
8554
|
+
if (cid)
|
|
8555
|
+
byClaudeId.set(String(cid), t);
|
|
8556
|
+
}
|
|
8557
|
+
const byTodosId = new Map;
|
|
8558
|
+
for (const t of allTasks) {
|
|
8559
|
+
byTodosId.set(t.id, t);
|
|
8560
|
+
}
|
|
8561
|
+
for (const f of files) {
|
|
8562
|
+
try {
|
|
8563
|
+
const ct = readClaudeTask(dir, f);
|
|
8564
|
+
if (!ct)
|
|
8565
|
+
continue;
|
|
8566
|
+
if (ct.metadata?.["_internal"])
|
|
8567
|
+
continue;
|
|
8568
|
+
const todosId = ct.metadata?.["todos_id"];
|
|
8569
|
+
const existingByMapping = byClaudeId.get(ct.id);
|
|
8570
|
+
const existingByTodos = todosId ? byTodosId.get(todosId) : undefined;
|
|
8571
|
+
const existing = existingByMapping || existingByTodos;
|
|
8572
|
+
if (existing) {
|
|
8573
|
+
updateTask(existing.id, {
|
|
8574
|
+
version: existing.version,
|
|
8575
|
+
title: ct.subject,
|
|
8576
|
+
description: ct.description || undefined,
|
|
8577
|
+
status: toSqliteStatus(ct.status),
|
|
8578
|
+
assigned_to: ct.owner || undefined,
|
|
8579
|
+
metadata: { ...existing.metadata, claude_task_id: ct.id }
|
|
8580
|
+
});
|
|
8581
|
+
} else {
|
|
8582
|
+
createTask({
|
|
8583
|
+
title: ct.subject,
|
|
8584
|
+
description: ct.description || undefined,
|
|
8585
|
+
status: toSqliteStatus(ct.status),
|
|
8586
|
+
assigned_to: ct.owner || undefined,
|
|
8587
|
+
project_id: projectId,
|
|
8588
|
+
metadata: { claude_task_id: ct.id },
|
|
8589
|
+
priority: ct.metadata?.["priority"] || "medium"
|
|
8590
|
+
});
|
|
8591
|
+
}
|
|
8592
|
+
pulled++;
|
|
8593
|
+
} catch (e) {
|
|
8594
|
+
errors.push(`pull ${f}: ${e instanceof Error ? e.message : String(e)}`);
|
|
8595
|
+
}
|
|
8596
|
+
}
|
|
8597
|
+
return { pushed: 0, pulled, errors };
|
|
8598
|
+
}
|
|
8599
|
+
function syncClaudeTaskList(taskListId, projectId) {
|
|
8600
|
+
const pullResult = pullFromClaudeTaskList(taskListId, projectId);
|
|
8601
|
+
const pushResult = pushToClaudeTaskList(taskListId, projectId);
|
|
8602
|
+
return {
|
|
8603
|
+
pushed: pushResult.pushed,
|
|
8604
|
+
pulled: pullResult.pulled,
|
|
8605
|
+
errors: [...pullResult.errors, ...pushResult.errors]
|
|
8606
|
+
};
|
|
8607
|
+
}
|
|
8608
|
+
|
|
8609
|
+
// src/cli/index.tsx
|
|
8439
8610
|
function getPackageVersion2() {
|
|
8440
8611
|
try {
|
|
8441
|
-
const pkgPath =
|
|
8442
|
-
return JSON.parse(
|
|
8612
|
+
const pkgPath = join4(dirname3(fileURLToPath2(import.meta.url)), "..", "..", "package.json");
|
|
8613
|
+
return JSON.parse(readFileSync3(pkgPath, "utf-8")).version || "0.0.0";
|
|
8443
8614
|
} catch {
|
|
8444
8615
|
return "0.0.0";
|
|
8445
8616
|
}
|
|
@@ -8909,6 +9080,107 @@ program2.command("export").description("Export tasks").option("-f, --format <for
|
|
|
8909
9080
|
console.log(JSON.stringify(tasks, null, 2));
|
|
8910
9081
|
}
|
|
8911
9082
|
});
|
|
9083
|
+
program2.command("sync").description("Sync tasks with a Claude Code task list").option("--task-list <id>", "Claude Code task list ID (or env TODOS_CLAUDE_TASK_LIST)").option("--push", "One-way: push SQLite tasks to Claude task list").option("--pull", "One-way: pull Claude task list into SQLite").action((opts) => {
|
|
9084
|
+
const globalOpts = program2.opts();
|
|
9085
|
+
const projectId = autoProject(globalOpts);
|
|
9086
|
+
const taskListId = opts.taskList || process.env["TODOS_CLAUDE_TASK_LIST"];
|
|
9087
|
+
if (!taskListId) {
|
|
9088
|
+
console.error(chalk.red("Task list ID required. Use --task-list <id> or set TODOS_CLAUDE_TASK_LIST."));
|
|
9089
|
+
process.exit(1);
|
|
9090
|
+
}
|
|
9091
|
+
let result;
|
|
9092
|
+
if (opts.push && !opts.pull) {
|
|
9093
|
+
result = pushToClaudeTaskList(taskListId, projectId);
|
|
9094
|
+
} else if (opts.pull && !opts.push) {
|
|
9095
|
+
result = pullFromClaudeTaskList(taskListId, projectId);
|
|
9096
|
+
} else {
|
|
9097
|
+
result = syncClaudeTaskList(taskListId, projectId);
|
|
9098
|
+
}
|
|
9099
|
+
if (globalOpts.json) {
|
|
9100
|
+
output(result, true);
|
|
9101
|
+
return;
|
|
9102
|
+
}
|
|
9103
|
+
if (result.pulled > 0)
|
|
9104
|
+
console.log(chalk.green(`Pulled ${result.pulled} task(s) from Claude task list.`));
|
|
9105
|
+
if (result.pushed > 0)
|
|
9106
|
+
console.log(chalk.green(`Pushed ${result.pushed} task(s) to Claude task list.`));
|
|
9107
|
+
if (result.pulled === 0 && result.pushed === 0 && result.errors.length === 0) {
|
|
9108
|
+
console.log(chalk.dim("Nothing to sync."));
|
|
9109
|
+
}
|
|
9110
|
+
for (const err of result.errors) {
|
|
9111
|
+
console.error(chalk.red(` Error: ${err}`));
|
|
9112
|
+
}
|
|
9113
|
+
});
|
|
9114
|
+
var hooks = program2.command("hooks").description("Manage Claude Code hook integration");
|
|
9115
|
+
hooks.command("install").description("Install Claude Code hooks for auto-sync").option("--task-list <id>", "Claude Code task list ID (or env TODOS_CLAUDE_TASK_LIST)").action((opts) => {
|
|
9116
|
+
const taskListId = opts.taskList || process.env["TODOS_CLAUDE_TASK_LIST"];
|
|
9117
|
+
if (!taskListId) {
|
|
9118
|
+
console.error(chalk.red("Task list ID required. Use --task-list <id> or set TODOS_CLAUDE_TASK_LIST."));
|
|
9119
|
+
process.exit(1);
|
|
9120
|
+
}
|
|
9121
|
+
let todosBin = "todos";
|
|
9122
|
+
try {
|
|
9123
|
+
const p = execSync2("which todos", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
9124
|
+
if (p)
|
|
9125
|
+
todosBin = p;
|
|
9126
|
+
} catch {}
|
|
9127
|
+
const hooksDir = join4(process.cwd(), ".claude", "hooks");
|
|
9128
|
+
if (!existsSync4(hooksDir))
|
|
9129
|
+
mkdirSync3(hooksDir, { recursive: true });
|
|
9130
|
+
const hookScript = `#!/usr/bin/env bash
|
|
9131
|
+
# Auto-generated by: todos hooks install
|
|
9132
|
+
# Syncs todos with Claude Code task list on tool use events.
|
|
9133
|
+
# Reads hook JSON from stdin; determines sync direction from tool_name.
|
|
9134
|
+
|
|
9135
|
+
set -e
|
|
9136
|
+
|
|
9137
|
+
TASK_LIST="\${TODOS_CLAUDE_TASK_LIST:-${taskListId}}"
|
|
9138
|
+
TOOL_NAME=$(cat /dev/stdin | grep -o '"tool_name":"[^"]*"' | head -1 | cut -d'"' -f4 2>/dev/null || true)
|
|
9139
|
+
|
|
9140
|
+
case "$TOOL_NAME" in
|
|
9141
|
+
TaskCreate|TaskUpdate)
|
|
9142
|
+
${todosBin} sync --pull --task-list "$TASK_LIST" 2>/dev/null || true
|
|
9143
|
+
;;
|
|
9144
|
+
mcp__todos__*)
|
|
9145
|
+
${todosBin} sync --push --task-list "$TASK_LIST" 2>/dev/null || true
|
|
9146
|
+
;;
|
|
9147
|
+
*)
|
|
9148
|
+
# Unknown tool, run bidirectional sync
|
|
9149
|
+
${todosBin} sync --task-list "$TASK_LIST" 2>/dev/null || true
|
|
9150
|
+
;;
|
|
9151
|
+
esac
|
|
9152
|
+
|
|
9153
|
+
exit 0
|
|
9154
|
+
`;
|
|
9155
|
+
const hookPath = join4(hooksDir, "todos-sync.sh");
|
|
9156
|
+
writeFileSync2(hookPath, hookScript);
|
|
9157
|
+
execSync2(`chmod +x "${hookPath}"`);
|
|
9158
|
+
console.log(chalk.green(`Hook script created: ${hookPath}`));
|
|
9159
|
+
const settingsPath = join4(process.cwd(), ".claude", "settings.json");
|
|
9160
|
+
const settings = readJsonFile(settingsPath);
|
|
9161
|
+
if (!settings["hooks"]) {
|
|
9162
|
+
settings["hooks"] = {};
|
|
9163
|
+
}
|
|
9164
|
+
const hooksConfig = settings["hooks"];
|
|
9165
|
+
if (!hooksConfig["PostToolUse"]) {
|
|
9166
|
+
hooksConfig["PostToolUse"] = [];
|
|
9167
|
+
}
|
|
9168
|
+
const postToolUse = hooksConfig["PostToolUse"];
|
|
9169
|
+
const filtered = postToolUse.filter((h) => !(h["command"] || "").includes("todos-sync.sh"));
|
|
9170
|
+
filtered.push({
|
|
9171
|
+
matcher: "TaskCreate|TaskUpdate",
|
|
9172
|
+
command: hookPath
|
|
9173
|
+
});
|
|
9174
|
+
filtered.push({
|
|
9175
|
+
matcher: "mcp__todos__create_task|mcp__todos__update_task|mcp__todos__complete_task|mcp__todos__start_task",
|
|
9176
|
+
command: hookPath
|
|
9177
|
+
});
|
|
9178
|
+
hooksConfig["PostToolUse"] = filtered;
|
|
9179
|
+
writeJsonFile(settingsPath, settings);
|
|
9180
|
+
console.log(chalk.green(`Claude Code hooks configured in: ${settingsPath}`));
|
|
9181
|
+
console.log(chalk.dim(`Task list ID: ${taskListId}`));
|
|
9182
|
+
console.log(chalk.dim("Set TODOS_CLAUDE_TASK_LIST env var to override at runtime."));
|
|
9183
|
+
});
|
|
8912
9184
|
program2.command("mcp").description("Start MCP server (stdio)").option("--register <agent>", "Register MCP server with an agent (claude, codex, gemini, all)").option("--unregister <agent>", "Unregister MCP server from an agent (claude, codex, gemini, all)").option("-g, --global", "Register/unregister globally (user-level) instead of project-level").action(async (opts) => {
|
|
8913
9185
|
if (opts.register) {
|
|
8914
9186
|
registerMcp(opts.register, opts.global);
|
|
@@ -8920,47 +9192,47 @@ program2.command("mcp").description("Start MCP server (stdio)").option("--regist
|
|
|
8920
9192
|
}
|
|
8921
9193
|
await Promise.resolve().then(() => (init_mcp(), exports_mcp));
|
|
8922
9194
|
});
|
|
8923
|
-
var
|
|
9195
|
+
var HOME2 = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
8924
9196
|
function getMcpBinaryPath() {
|
|
8925
9197
|
try {
|
|
8926
9198
|
const p = execSync2("which todos-mcp", { encoding: "utf-8" }).trim();
|
|
8927
9199
|
if (p)
|
|
8928
9200
|
return p;
|
|
8929
9201
|
} catch {}
|
|
8930
|
-
const bunBin =
|
|
8931
|
-
if (
|
|
9202
|
+
const bunBin = join4(HOME2, ".bun", "bin", "todos-mcp");
|
|
9203
|
+
if (existsSync4(bunBin))
|
|
8932
9204
|
return bunBin;
|
|
8933
9205
|
return "todos-mcp";
|
|
8934
9206
|
}
|
|
8935
9207
|
function readJsonFile(path) {
|
|
8936
|
-
if (!
|
|
9208
|
+
if (!existsSync4(path))
|
|
8937
9209
|
return {};
|
|
8938
9210
|
try {
|
|
8939
|
-
return JSON.parse(
|
|
9211
|
+
return JSON.parse(readFileSync3(path, "utf-8"));
|
|
8940
9212
|
} catch {
|
|
8941
9213
|
return {};
|
|
8942
9214
|
}
|
|
8943
9215
|
}
|
|
8944
9216
|
function writeJsonFile(path, data) {
|
|
8945
9217
|
const dir = dirname3(path);
|
|
8946
|
-
if (!
|
|
8947
|
-
|
|
8948
|
-
|
|
9218
|
+
if (!existsSync4(dir))
|
|
9219
|
+
mkdirSync3(dir, { recursive: true });
|
|
9220
|
+
writeFileSync2(path, JSON.stringify(data, null, 2) + `
|
|
8949
9221
|
`);
|
|
8950
9222
|
}
|
|
8951
9223
|
function readTomlFile(path) {
|
|
8952
|
-
if (!
|
|
9224
|
+
if (!existsSync4(path))
|
|
8953
9225
|
return "";
|
|
8954
|
-
return
|
|
9226
|
+
return readFileSync3(path, "utf-8");
|
|
8955
9227
|
}
|
|
8956
9228
|
function writeTomlFile(path, content) {
|
|
8957
9229
|
const dir = dirname3(path);
|
|
8958
|
-
if (!
|
|
8959
|
-
|
|
8960
|
-
|
|
9230
|
+
if (!existsSync4(dir))
|
|
9231
|
+
mkdirSync3(dir, { recursive: true });
|
|
9232
|
+
writeFileSync2(path, content);
|
|
8961
9233
|
}
|
|
8962
9234
|
function registerClaude(binPath, global) {
|
|
8963
|
-
const configPath = global ?
|
|
9235
|
+
const configPath = global ? join4(HOME2, ".claude", ".mcp.json") : join4(process.cwd(), ".mcp.json");
|
|
8964
9236
|
const config = readJsonFile(configPath);
|
|
8965
9237
|
if (!config["mcpServers"]) {
|
|
8966
9238
|
config["mcpServers"] = {};
|
|
@@ -8975,7 +9247,7 @@ function registerClaude(binPath, global) {
|
|
|
8975
9247
|
console.log(chalk.green(`Claude Code (${scope}): registered in ${configPath}`));
|
|
8976
9248
|
}
|
|
8977
9249
|
function unregisterClaude(global) {
|
|
8978
|
-
const configPath = global ?
|
|
9250
|
+
const configPath = global ? join4(HOME2, ".claude", ".mcp.json") : join4(process.cwd(), ".mcp.json");
|
|
8979
9251
|
const config = readJsonFile(configPath);
|
|
8980
9252
|
const servers = config["mcpServers"];
|
|
8981
9253
|
if (!servers || !("todos" in servers)) {
|
|
@@ -8988,7 +9260,7 @@ function unregisterClaude(global) {
|
|
|
8988
9260
|
console.log(chalk.green(`Claude Code (${scope}): unregistered from ${configPath}`));
|
|
8989
9261
|
}
|
|
8990
9262
|
function registerCodex(binPath) {
|
|
8991
|
-
const configPath =
|
|
9263
|
+
const configPath = join4(HOME2, ".codex", "config.toml");
|
|
8992
9264
|
let content = readTomlFile(configPath);
|
|
8993
9265
|
content = removeTomlBlock(content, "mcp_servers.todos");
|
|
8994
9266
|
const block = `
|
|
@@ -9002,7 +9274,7 @@ args = []
|
|
|
9002
9274
|
console.log(chalk.green(`Codex CLI: registered in ${configPath}`));
|
|
9003
9275
|
}
|
|
9004
9276
|
function unregisterCodex() {
|
|
9005
|
-
const configPath =
|
|
9277
|
+
const configPath = join4(HOME2, ".codex", "config.toml");
|
|
9006
9278
|
let content = readTomlFile(configPath);
|
|
9007
9279
|
if (!content.includes("[mcp_servers.todos]")) {
|
|
9008
9280
|
console.log(chalk.dim(`Codex CLI: todos not found in ${configPath}`));
|
|
@@ -9035,7 +9307,7 @@ function removeTomlBlock(content, blockName) {
|
|
|
9035
9307
|
`);
|
|
9036
9308
|
}
|
|
9037
9309
|
function registerGemini(binPath) {
|
|
9038
|
-
const configPath =
|
|
9310
|
+
const configPath = join4(HOME2, ".gemini", "settings.json");
|
|
9039
9311
|
const config = readJsonFile(configPath);
|
|
9040
9312
|
if (!config["mcpServers"]) {
|
|
9041
9313
|
config["mcpServers"] = {};
|
|
@@ -9049,7 +9321,7 @@ function registerGemini(binPath) {
|
|
|
9049
9321
|
console.log(chalk.green(`Gemini CLI: registered in ${configPath}`));
|
|
9050
9322
|
}
|
|
9051
9323
|
function unregisterGemini() {
|
|
9052
|
-
const configPath =
|
|
9324
|
+
const configPath = join4(HOME2, ".gemini", "settings.json");
|
|
9053
9325
|
const config = readJsonFile(configPath);
|
|
9054
9326
|
const servers = config["mcpServers"];
|
|
9055
9327
|
if (!servers || !("todos" in servers)) {
|