@bretwardjames/tw-bridge 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +79 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -290,6 +290,7 @@ var commands = {
290
290
  add: addBackend,
291
291
  install,
292
292
  sync,
293
+ timewarrior: timewarriorCmd,
293
294
  which,
294
295
  config: showConfig
295
296
  };
@@ -300,9 +301,10 @@ async function main() {
300
301
  console.log("Commands:");
301
302
  console.log(" add Add a new backend instance");
302
303
  console.log(" install Install Taskwarrior hooks and shell integration");
303
- console.log(" sync Pull tasks from all backends");
304
- console.log(" which Print the context for the current directory");
305
- console.log(" config Show current configuration");
304
+ console.log(" sync Pull tasks from all backends");
305
+ console.log(" timewarrior Manage Timewarrior integration");
306
+ console.log(" which Print the context for the current directory");
307
+ console.log(" config Show current configuration");
306
308
  return;
307
309
  }
308
310
  const handler = commands[command];
@@ -393,14 +395,83 @@ async function install() {
393
395
  console.log("urgency.user.tag.in_review.coefficient=-2.0");
394
396
  console.log("urgency.user.tag.ready_for_beta.coefficient=-4.0");
395
397
  console.log("urgency.user.tag.in_beta.coefficient=-6.0");
396
- const timewHook = path3.join(HOOKS_DIR, "on-modify.timewarrior");
397
- if (fs2.existsSync(timewHook)) {
398
- console.log("\nNote: Found on-modify.timewarrior hook.");
399
- console.log("If you enable tw-bridge Timewarrior management, disable it to avoid double-tracking:");
400
- console.log(` mv ${timewHook} ${timewHook}.disabled`);
398
+ if (fs2.existsSync(STANDARD_TIMEW_HOOK)) {
399
+ console.log("\nTimewarrior hook detected. To enable tw-bridge time tracking:");
400
+ console.log(" tw-bridge timewarrior enable-overlaps");
401
401
  }
402
402
  installShellFunction();
403
403
  }
404
+ var STANDARD_TIMEW_HOOK = path3.join(HOOKS_DIR, "on-modify.timewarrior");
405
+ async function timewarriorCmd() {
406
+ const sub = process.argv[3];
407
+ if (!sub || sub === "--help") {
408
+ console.log("Usage: tw-bridge timewarrior <subcommand>\n");
409
+ console.log("Subcommands:");
410
+ console.log(" enable Enable Timewarrior tracking");
411
+ console.log(" enable-overlaps Enable with overlapping intervals (for parallel work)");
412
+ console.log(" disable Disable Timewarrior tracking");
413
+ console.log(" status Show current Timewarrior configuration");
414
+ return;
415
+ }
416
+ const config = loadConfig();
417
+ if (sub === "status") {
418
+ const tw = config.timewarrior;
419
+ if (!tw?.enabled) {
420
+ console.log("Timewarrior: disabled");
421
+ } else {
422
+ console.log(`Timewarrior: enabled (overlaps: ${tw.allow_overlaps ? "yes" : "no"})`);
423
+ }
424
+ const hookExists = fs2.existsSync(STANDARD_TIMEW_HOOK);
425
+ const hookDisabled = fs2.existsSync(STANDARD_TIMEW_HOOK + ".disabled");
426
+ if (hookExists) {
427
+ console.log(`Standard hook: active (${STANDARD_TIMEW_HOOK})`);
428
+ if (tw?.enabled) {
429
+ console.log(" Warning: may cause double-tracking. Run `tw-bridge timewarrior enable` to fix.");
430
+ }
431
+ } else if (hookDisabled) {
432
+ console.log("Standard hook: disabled");
433
+ } else {
434
+ console.log("Standard hook: not found");
435
+ }
436
+ return;
437
+ }
438
+ if (sub === "enable" || sub === "enable-overlaps") {
439
+ const allowOverlaps = sub === "enable-overlaps";
440
+ config.timewarrior = {
441
+ enabled: true,
442
+ allow_overlaps: allowOverlaps
443
+ };
444
+ const configPath = saveConfig(config);
445
+ console.log(`Timewarrior tracking enabled (overlaps: ${allowOverlaps ? "yes" : "no"})`);
446
+ console.log(`Config: ${configPath}`);
447
+ if (fs2.existsSync(STANDARD_TIMEW_HOOK)) {
448
+ const disabled = STANDARD_TIMEW_HOOK + ".disabled";
449
+ fs2.renameSync(STANDARD_TIMEW_HOOK, disabled);
450
+ console.log(`
451
+ Disabled standard hook: ${STANDARD_TIMEW_HOOK} -> .disabled`);
452
+ console.log("tw-bridge will handle Timewarrior tracking directly.");
453
+ }
454
+ return;
455
+ }
456
+ if (sub === "disable") {
457
+ config.timewarrior = {
458
+ enabled: false,
459
+ allow_overlaps: false
460
+ };
461
+ const configPath = saveConfig(config);
462
+ console.log("Timewarrior tracking disabled");
463
+ console.log(`Config: ${configPath}`);
464
+ const disabled = STANDARD_TIMEW_HOOK + ".disabled";
465
+ if (fs2.existsSync(disabled)) {
466
+ fs2.renameSync(disabled, STANDARD_TIMEW_HOOK);
467
+ console.log(`
468
+ Restored standard hook: ${STANDARD_TIMEW_HOOK}`);
469
+ }
470
+ return;
471
+ }
472
+ console.error(`Unknown subcommand: ${sub}`);
473
+ process.exit(1);
474
+ }
404
475
  var SHELL_FUNCTION = `
405
476
  # tw-bridge: auto-context task wrapper
406
477
  task() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bretwardjames/tw-bridge",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Taskwarrior backend bridge — unified sync and hooks for multiple task management platforms",
5
5
  "type": "module",
6
6
  "license": "MIT",