@hasna/todos 0.9.65 → 0.9.66

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.
Files changed (2) hide show
  1. package/dist/cli/index.js +56 -0
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -3030,6 +3030,12 @@ var init_audit = __esm(() => {
3030
3030
  });
3031
3031
 
3032
3032
  // src/lib/recurrence.ts
3033
+ var exports_recurrence = {};
3034
+ __export(exports_recurrence, {
3035
+ parseRecurrenceRule: () => parseRecurrenceRule,
3036
+ nextOccurrence: () => nextOccurrence,
3037
+ isValidRecurrenceRule: () => isValidRecurrenceRule
3038
+ });
3033
3039
  function parseRecurrenceRule(rule) {
3034
3040
  const normalized = rule.trim().toLowerCase();
3035
3041
  if (normalized === "every weekday" || normalized === "every weekdays") {
@@ -3068,6 +3074,14 @@ function parseRecurrenceRule(rule) {
3068
3074
  }
3069
3075
  throw new Error(`Invalid recurrence rule: "${rule}". Supported formats: "every day", "every weekday", "every week", "every 2 weeks", "every month", "every N days/weeks/months", "every monday", "every mon,wed,fri"`);
3070
3076
  }
3077
+ function isValidRecurrenceRule(rule) {
3078
+ try {
3079
+ parseRecurrenceRule(rule);
3080
+ return true;
3081
+ } catch {
3082
+ return false;
3083
+ }
3084
+ }
3071
3085
  function nextOccurrence(rule, from) {
3072
3086
  const parsed = parseRecurrenceRule(rule);
3073
3087
  const base = from || new Date;
@@ -15028,6 +15042,48 @@ program2.command("summary").description("Generate a markdown summary of recent t
15028
15042
  console.log(lines.join(`
15029
15043
  `));
15030
15044
  });
15045
+ program2.command("doctor").description("Diagnose common task data issues").option("--fix", "Auto-fix recoverable issues where possible").option("--json", "Output as JSON").action(async (opts) => {
15046
+ const globalOpts = program2.opts();
15047
+ const db = getDatabase();
15048
+ const issues = [];
15049
+ const stale = listTasks({ status: "in_progress" }).filter((t) => new Date(t.updated_at).getTime() < Date.now() - 30 * 60 * 1000);
15050
+ if (stale.length > 0)
15051
+ issues.push({ severity: "warn", type: "stale_tasks", message: `${stale.length} tasks stuck in_progress >30min`, count: stale.length });
15052
+ const { isValidRecurrenceRule: isValidRecurrenceRule2 } = (init_recurrence(), __toCommonJS(exports_recurrence));
15053
+ const recurring = listTasks({ status: ["pending", "in_progress"] }).filter((t) => t.recurrence_rule);
15054
+ const invalidRecurrence = recurring.filter((t) => !isValidRecurrenceRule2(t.recurrence_rule));
15055
+ if (invalidRecurrence.length > 0)
15056
+ issues.push({ severity: "error", type: "invalid_recurrence", message: `${invalidRecurrence.length} tasks with invalid recurrence_rule`, count: invalidRecurrence.length });
15057
+ const nowStr = new Date().toISOString();
15058
+ const overdueRecurring = recurring.filter((t) => t.due_at && t.due_at < nowStr);
15059
+ if (overdueRecurring.length > 0)
15060
+ issues.push({ severity: "warn", type: "overdue_recurring", message: `${overdueRecurring.length} recurring tasks past due date`, count: overdueRecurring.length });
15061
+ const allIds = new Set(listTasks({}).map((t) => t.id));
15062
+ const withParent = db.query("SELECT id, parent_id FROM tasks WHERE parent_id IS NOT NULL").all();
15063
+ const orphaned = withParent.filter((t) => !allIds.has(t.parent_id));
15064
+ if (orphaned.length > 0)
15065
+ issues.push({ severity: "error", type: "orphaned_parents", message: `${orphaned.length} tasks reference non-existent parent IDs`, count: orphaned.length });
15066
+ if (issues.length === 0)
15067
+ issues.push({ severity: "info", type: "healthy", message: "No issues found" });
15068
+ if (opts.json || globalOpts.json) {
15069
+ console.log(JSON.stringify({ issues, ok: !issues.some((i) => i.severity === "error") }));
15070
+ return;
15071
+ }
15072
+ console.log(chalk.bold(`todos doctor
15073
+ `));
15074
+ for (const issue of issues) {
15075
+ const icon = issue.severity === "error" ? chalk.red("\u2717") : issue.severity === "warn" ? chalk.yellow("\u26A0") : chalk.green("\u2713");
15076
+ console.log(` ${icon} ${issue.message}`);
15077
+ }
15078
+ const errors2 = issues.filter((i) => i.severity === "error").length;
15079
+ const warns = issues.filter((i) => i.severity === "warn").length;
15080
+ if (errors2 === 0 && warns === 0)
15081
+ console.log(chalk.green(`
15082
+ All clear.`));
15083
+ else
15084
+ console.log(chalk[errors2 > 0 ? "red" : "yellow"](`
15085
+ ${errors2} error(s), ${warns} warning(s). Run with --fix to auto-resolve where possible.`));
15086
+ });
15031
15087
  program2.command("health").description("Check todos system health \u2014 database, config, connectivity").option("--json", "Output as JSON").action(async (opts) => {
15032
15088
  const globalOpts = program2.opts();
15033
15089
  const checks = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/todos",
3
- "version": "0.9.65",
3
+ "version": "0.9.66",
4
4
  "description": "Universal task management for AI coding agents - CLI + MCP server + interactive TUI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",