@hasna/todos 0.3.2 → 0.3.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/dist/cli/index.js +16 -17
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -9089,12 +9089,15 @@ program2.command("export").description("Export tasks").option("-f, --format <for
|
|
|
9089
9089
|
console.log(JSON.stringify(tasks, null, 2));
|
|
9090
9090
|
}
|
|
9091
9091
|
});
|
|
9092
|
-
|
|
9092
|
+
function resolveClaudeTaskListId(explicit) {
|
|
9093
|
+
return explicit || process.env["TODOS_CLAUDE_TASK_LIST"] || process.env["CLAUDE_CODE_TASK_LIST_ID"] || process.env["CLAUDE_CODE_SESSION_ID"] || null;
|
|
9094
|
+
}
|
|
9095
|
+
program2.command("sync").description("Sync tasks with a Claude Code task list").option("--task-list <id>", "Task list ID (auto-detects from CLAUDE_CODE_TASK_LIST_ID or CLAUDE_CODE_SESSION_ID)").option("--push", "One-way: push SQLite tasks to Claude task list").option("--pull", "One-way: pull Claude task list into SQLite").action((opts) => {
|
|
9093
9096
|
const globalOpts = program2.opts();
|
|
9094
9097
|
const projectId = autoProject(globalOpts);
|
|
9095
|
-
const taskListId = opts.taskList
|
|
9098
|
+
const taskListId = resolveClaudeTaskListId(opts.taskList);
|
|
9096
9099
|
if (!taskListId) {
|
|
9097
|
-
console.error(chalk.red("
|
|
9100
|
+
console.error(chalk.red("Could not detect task list ID. Use --task-list <id>, or run inside a Claude Code session."));
|
|
9098
9101
|
process.exit(1);
|
|
9099
9102
|
}
|
|
9100
9103
|
let result;
|
|
@@ -9121,12 +9124,7 @@ program2.command("sync").description("Sync tasks with a Claude Code task list").
|
|
|
9121
9124
|
}
|
|
9122
9125
|
});
|
|
9123
9126
|
var hooks = program2.command("hooks").description("Manage Claude Code hook integration");
|
|
9124
|
-
hooks.command("install").description("Install Claude Code hooks for auto-sync").
|
|
9125
|
-
const taskListId = opts.taskList || process.env["TODOS_CLAUDE_TASK_LIST"];
|
|
9126
|
-
if (!taskListId) {
|
|
9127
|
-
console.error(chalk.red("Task list ID required. Use --task-list <id> or set TODOS_CLAUDE_TASK_LIST."));
|
|
9128
|
-
process.exit(1);
|
|
9129
|
-
}
|
|
9127
|
+
hooks.command("install").description("Install Claude Code hooks for auto-sync").action(() => {
|
|
9130
9128
|
let todosBin = "todos";
|
|
9131
9129
|
try {
|
|
9132
9130
|
const p = execSync2("which todos", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
@@ -9139,11 +9137,17 @@ hooks.command("install").description("Install Claude Code hooks for auto-sync").
|
|
|
9139
9137
|
const hookScript = `#!/usr/bin/env bash
|
|
9140
9138
|
# Auto-generated by: todos hooks install
|
|
9141
9139
|
# Syncs todos with Claude Code task list on tool use events.
|
|
9142
|
-
#
|
|
9140
|
+
# Auto-detects task list ID from Claude Code env vars.
|
|
9143
9141
|
|
|
9144
9142
|
set -e
|
|
9145
9143
|
|
|
9146
|
-
|
|
9144
|
+
# Auto-detect: explicit override > Claude task list > Claude session ID
|
|
9145
|
+
TASK_LIST="\${TODOS_CLAUDE_TASK_LIST:-\${CLAUDE_CODE_TASK_LIST_ID:-\${CLAUDE_CODE_SESSION_ID:-}}}"
|
|
9146
|
+
|
|
9147
|
+
if [ -z "$TASK_LIST" ]; then
|
|
9148
|
+
exit 0
|
|
9149
|
+
fi
|
|
9150
|
+
|
|
9147
9151
|
TOOL_NAME=$(cat /dev/stdin | grep -o '"tool_name":"[^"]*"' | head -1 | cut -d'"' -f4 2>/dev/null || true)
|
|
9148
9152
|
|
|
9149
9153
|
case "$TOOL_NAME" in
|
|
@@ -9153,10 +9157,6 @@ case "$TOOL_NAME" in
|
|
|
9153
9157
|
mcp__todos__*)
|
|
9154
9158
|
${todosBin} sync --push --task-list "$TASK_LIST" 2>/dev/null || true
|
|
9155
9159
|
;;
|
|
9156
|
-
*)
|
|
9157
|
-
# Unknown tool, run bidirectional sync
|
|
9158
|
-
${todosBin} sync --task-list "$TASK_LIST" 2>/dev/null || true
|
|
9159
|
-
;;
|
|
9160
9160
|
esac
|
|
9161
9161
|
|
|
9162
9162
|
exit 0
|
|
@@ -9187,8 +9187,7 @@ exit 0
|
|
|
9187
9187
|
hooksConfig["PostToolUse"] = filtered;
|
|
9188
9188
|
writeJsonFile(settingsPath, settings);
|
|
9189
9189
|
console.log(chalk.green(`Claude Code hooks configured in: ${settingsPath}`));
|
|
9190
|
-
console.log(chalk.dim(
|
|
9191
|
-
console.log(chalk.dim("Set TODOS_CLAUDE_TASK_LIST env var to override at runtime."));
|
|
9190
|
+
console.log(chalk.dim("Task list ID auto-detected from CLAUDE_CODE_TASK_LIST_ID or CLAUDE_CODE_SESSION_ID."));
|
|
9192
9191
|
});
|
|
9193
9192
|
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) => {
|
|
9194
9193
|
if (opts.register) {
|