@workscribe/cli 1.15.2 → 1.15.4

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/index.js CHANGED
@@ -187,7 +187,11 @@ var init_migrations = __esm({
187
187
  function getDb() {
188
188
  if (_db) return _db;
189
189
  if (!import_fs2.default.existsSync(WORKSCRIBE_DIR)) {
190
- import_fs2.default.mkdirSync(WORKSCRIBE_DIR, { recursive: true });
190
+ try {
191
+ import_fs2.default.mkdirSync(WORKSCRIBE_DIR, { recursive: true });
192
+ } catch (error) {
193
+ throw new Error(`Could not create data directory ${WORKSCRIBE_DIR}: ${error.message}`);
194
+ }
191
195
  }
192
196
  const db = new import_node_sqlite.DatabaseSync(DB_PATH);
193
197
  try {
@@ -278,6 +282,10 @@ function getLastEvent() {
278
282
  const stmt = db.prepare("SELECT * FROM events ORDER BY id DESC LIMIT 1");
279
283
  return stmt.get();
280
284
  }
285
+ function getLastEventForCwd(cwd) {
286
+ const db = getDb();
287
+ return db.prepare("SELECT * FROM events WHERE cwd = $cwd ORDER BY id DESC LIMIT 1").get({ cwd });
288
+ }
281
289
  function getEventsForDate(date) {
282
290
  const db = getDb();
283
291
  const stmt = db.prepare(`
@@ -745,13 +753,13 @@ var init_registry = __esm({
745
753
 
746
754
  // src/config/index.ts
747
755
  function readConfig() {
748
- if (!import_fs7.default.existsSync(CONFIG_PATH)) return { ...DEFAULTS };
756
+ if (!import_fs7.default.existsSync(CONFIG_PATH)) return deepMerge(DEFAULTS, {});
749
757
  try {
750
758
  const raw = import_fs7.default.readFileSync(CONFIG_PATH, "utf-8");
751
759
  const parsed = JSON.parse(raw);
752
760
  return deepMerge(DEFAULTS, parsed);
753
761
  } catch {
754
- return { ...DEFAULTS };
762
+ return deepMerge(DEFAULTS, {});
755
763
  }
756
764
  }
757
765
  function writeConfig(config) {
@@ -809,7 +817,7 @@ function setConfigValue(config, key, value) {
809
817
  return result;
810
818
  }
811
819
  function deepMerge(defaults, overrides) {
812
- const result = { ...defaults };
820
+ const result = structuredClone(defaults);
813
821
  for (const key of Object.keys(overrides)) {
814
822
  const val = overrides[key];
815
823
  if (val !== null && typeof val === "object" && !Array.isArray(val) && typeof defaults[key] === "object") {
@@ -1356,11 +1364,12 @@ var init_filter = __esm({
1356
1364
  });
1357
1365
 
1358
1366
  // src/capture/ide.ts
1359
- var IDE_DEDUP_WINDOW_MS;
1367
+ var IDE_DEDUP_WINDOW_MS, TASK_RUN_DEDUP_WINDOW_MS;
1360
1368
  var init_ide = __esm({
1361
1369
  "src/capture/ide.ts"() {
1362
1370
  "use strict";
1363
1371
  IDE_DEDUP_WINDOW_MS = 3e4;
1372
+ TASK_RUN_DEDUP_WINDOW_MS = 5e3;
1364
1373
  }
1365
1374
  });
1366
1375
 
@@ -1377,6 +1386,13 @@ function captureCommand(opts) {
1377
1386
  if (Date.now() - lastTime < IDE_DEDUP_WINDOW_MS) return;
1378
1387
  }
1379
1388
  }
1389
+ if (opts.type === "task_run") {
1390
+ const lastForCwd = getLastEventForCwd(cwd);
1391
+ if (lastForCwd && !lastForCwd.source) {
1392
+ const lastTime = new Date(lastForCwd.captured_at).getTime();
1393
+ if (Date.now() - lastTime < TASK_RUN_DEDUP_WINDOW_MS) return;
1394
+ }
1395
+ }
1380
1396
  const command2 = opts.command ?? opts.file ?? opts.type;
1381
1397
  const nameOverride2 = config.projects?.[cwd] ?? null;
1382
1398
  const { repoName: repoName2, branch: branch2 } = getGitContext(cwd, nameOverride2, config.git.qualifyRepoName);
@@ -4129,7 +4145,7 @@ function registerBugReport(program) {
4129
4145
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
4130
4146
  const reportPath = import_path17.default.join(WORKSCRIBE_DIR, `bug-report-${timestamp}.txt`);
4131
4147
  const systemInfo = [
4132
- `Workscribe version : ${"1.15.2"}`,
4148
+ `Workscribe version : ${"1.15.4"}`,
4133
4149
  `Node.js version : ${process.version}`,
4134
4150
  `Platform : ${process.platform}`,
4135
4151
  `Architecture : ${process.arch}`,
@@ -4160,7 +4176,7 @@ function registerBugReport(program) {
4160
4176
  process.exit(1);
4161
4177
  }
4162
4178
  const params = new URLSearchParams({
4163
- title: `Bug report \u2014 workscribe ${"1.15.2"}`,
4179
+ title: `Bug report \u2014 workscribe ${"1.15.4"}`,
4164
4180
  body: `<!-- Attach ${import_path17.default.basename(reportPath)} or paste the relevant sections below -->
4165
4181
 
4166
4182
  **Describe the issue:**
@@ -4360,7 +4376,7 @@ function isNewer(latest, current) {
4360
4376
  return latestPatch > currentPatch;
4361
4377
  }
4362
4378
  function checkForUpdate() {
4363
- const current = "1.15.2";
4379
+ const current = "1.15.4";
4364
4380
  const cache = readCache();
4365
4381
  if (cache && isNewer(cache.latestVersion, current)) {
4366
4382
  process.stderr.write(
@@ -4383,7 +4399,7 @@ function checkForUpdate() {
4383
4399
  function buildTelemetryPayload(config) {
4384
4400
  return {
4385
4401
  installId: config.telemetry.installId,
4386
- cliVersion: "1.15.2",
4402
+ cliVersion: "1.15.4",
4387
4403
  platform: import_os10.default.platform(),
4388
4404
  nodeVersion: process.version
4389
4405
  };
@@ -4448,6 +4464,7 @@ var require_main = __commonJS({
4448
4464
  init_context();
4449
4465
  init_update_check();
4450
4466
  init_config();
4467
+ init_logger();
4451
4468
  var invokedCommand = process.argv[2];
4452
4469
  if (shouldRunStartupChecks(invokedCommand)) {
4453
4470
  checkForUpdate();
@@ -4457,7 +4474,7 @@ var require_main = __commonJS({
4457
4474
  pingTelemetry();
4458
4475
  }
4459
4476
  var program = new import_commander.Command();
4460
- program.name("workscribe").description("Automatic developer work journal").version("1.15.2");
4477
+ program.name("workscribe").description("Automatic developer work journal").version("1.15.4");
4461
4478
  registerCapture(program);
4462
4479
  registerHook(program);
4463
4480
  registerInit(program);
@@ -4478,7 +4495,10 @@ var require_main = __commonJS({
4478
4495
  registerCompletions(program);
4479
4496
  registerAlerts(program);
4480
4497
  registerContext(program);
4481
- program.parse();
4498
+ program.parseAsync().catch((error) => {
4499
+ log.error(error instanceof Error ? error.message : String(error));
4500
+ process.exit(1);
4501
+ });
4482
4502
  }
4483
4503
  });
4484
4504