@workscribe/cli 1.15.1 → 1.15.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/index.js +63 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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 {
|
|
@@ -745,13 +749,13 @@ var init_registry = __esm({
|
|
|
745
749
|
|
|
746
750
|
// src/config/index.ts
|
|
747
751
|
function readConfig() {
|
|
748
|
-
if (!import_fs7.default.existsSync(CONFIG_PATH)) return
|
|
752
|
+
if (!import_fs7.default.existsSync(CONFIG_PATH)) return deepMerge(DEFAULTS, {});
|
|
749
753
|
try {
|
|
750
754
|
const raw = import_fs7.default.readFileSync(CONFIG_PATH, "utf-8");
|
|
751
755
|
const parsed = JSON.parse(raw);
|
|
752
756
|
return deepMerge(DEFAULTS, parsed);
|
|
753
757
|
} catch {
|
|
754
|
-
return
|
|
758
|
+
return deepMerge(DEFAULTS, {});
|
|
755
759
|
}
|
|
756
760
|
}
|
|
757
761
|
function writeConfig(config) {
|
|
@@ -769,13 +773,17 @@ function ensureInstallId(config) {
|
|
|
769
773
|
return installId;
|
|
770
774
|
}
|
|
771
775
|
function ensureTelemetryFallback() {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
)
|
|
776
|
+
try {
|
|
777
|
+
const config = readConfig();
|
|
778
|
+
if (config.telemetry.installId) return;
|
|
779
|
+
config.telemetry.enabled = true;
|
|
780
|
+
config.telemetry.installId = ensureInstallId(config);
|
|
781
|
+
process.stderr.write(
|
|
782
|
+
"\n Workscribe collects anonymous install stats (install ID, CLI version, platform, Node version).\n Opt out: workscribe config set telemetry.enabled false\n\n"
|
|
783
|
+
);
|
|
784
|
+
} catch (error) {
|
|
785
|
+
debugLog("ensureTelemetryFallback", error);
|
|
786
|
+
}
|
|
779
787
|
}
|
|
780
788
|
function getConfigValue(config, key) {
|
|
781
789
|
const parts = key.split(".");
|
|
@@ -805,7 +813,7 @@ function setConfigValue(config, key, value) {
|
|
|
805
813
|
return result;
|
|
806
814
|
}
|
|
807
815
|
function deepMerge(defaults, overrides) {
|
|
808
|
-
const result =
|
|
816
|
+
const result = structuredClone(defaults);
|
|
809
817
|
for (const key of Object.keys(overrides)) {
|
|
810
818
|
const val = overrides[key];
|
|
811
819
|
if (val !== null && typeof val === "object" && !Array.isArray(val) && typeof defaults[key] === "object") {
|
|
@@ -824,6 +832,7 @@ var init_config = __esm({
|
|
|
824
832
|
import_fs7 = __toESM(require("fs"));
|
|
825
833
|
import_path5 = __toESM(require("path"));
|
|
826
834
|
init_paths();
|
|
835
|
+
init_logger();
|
|
827
836
|
DEFAULTS = {
|
|
828
837
|
ai: {
|
|
829
838
|
provider: "",
|
|
@@ -3230,18 +3239,23 @@ function registerSummary(program) {
|
|
|
3230
3239
|
const payload = { weekStart, weekEnd: today, days: weeklyDays };
|
|
3231
3240
|
log.plain("");
|
|
3232
3241
|
log.info(`Generating weekly summary via ${import_chalk6.default.cyan(config.ai.provider)}\u2026`);
|
|
3242
|
+
let summary;
|
|
3233
3243
|
try {
|
|
3234
|
-
|
|
3235
|
-
log.plain("");
|
|
3236
|
-
log.plain(summary);
|
|
3237
|
-
log.plain("");
|
|
3238
|
-
import_fs16.default.mkdirSync(WEEKLY_CACHE_DIR, { recursive: true });
|
|
3239
|
-
import_fs16.default.writeFileSync(cacheFile, summary, { encoding: "utf-8", mode: 384 });
|
|
3240
|
-
await handleWebhook(opts, config, summary);
|
|
3244
|
+
summary = provider.summarizeWeek ? await provider.summarizeWeek(payload) : await provider.summarize({ date: today, sessions: weeklyDays.flatMap((day) => day.sessions) });
|
|
3241
3245
|
} catch (error) {
|
|
3242
3246
|
log.error(`Weekly summary failed [${config.ai.provider}]: ${error.message}`);
|
|
3243
3247
|
process.exit(1);
|
|
3244
3248
|
}
|
|
3249
|
+
log.plain("");
|
|
3250
|
+
log.plain(summary);
|
|
3251
|
+
log.plain("");
|
|
3252
|
+
try {
|
|
3253
|
+
import_fs16.default.mkdirSync(WEEKLY_CACHE_DIR, { recursive: true });
|
|
3254
|
+
import_fs16.default.writeFileSync(cacheFile, summary, { encoding: "utf-8", mode: 384 });
|
|
3255
|
+
} catch (error) {
|
|
3256
|
+
debugLog("weekly-summary-cache", error);
|
|
3257
|
+
}
|
|
3258
|
+
await handleWebhook(opts, config, summary);
|
|
3245
3259
|
return;
|
|
3246
3260
|
}
|
|
3247
3261
|
let date = todayDate();
|
|
@@ -4058,18 +4072,23 @@ function registerWeek(program) {
|
|
|
4058
4072
|
const payload = { weekStart, weekEnd: today, days: weeklyDays };
|
|
4059
4073
|
log.plain("");
|
|
4060
4074
|
log.info(`Generating weekly digest via ${import_chalk11.default.cyan(config.ai.provider)}\u2026`);
|
|
4075
|
+
let summary;
|
|
4061
4076
|
try {
|
|
4062
|
-
|
|
4063
|
-
log.plain("");
|
|
4064
|
-
log.plain(summary);
|
|
4065
|
-
log.plain("");
|
|
4066
|
-
import_fs21.default.mkdirSync(WEEKLY_CACHE_DIR, { recursive: true });
|
|
4067
|
-
import_fs21.default.writeFileSync(cacheFile, summary, { encoding: "utf-8", mode: 384 });
|
|
4068
|
-
await postSummary(opts, config, summary);
|
|
4077
|
+
summary = provider.summarizeWeek ? await provider.summarizeWeek(payload) : await provider.summarize({ date: today, sessions: weeklyDays.flatMap((day) => day.sessions) });
|
|
4069
4078
|
} catch (error) {
|
|
4070
4079
|
log.error(`Weekly digest failed [${config.ai.provider}]: ${error.message}`);
|
|
4071
4080
|
process.exit(1);
|
|
4072
4081
|
}
|
|
4082
|
+
log.plain("");
|
|
4083
|
+
log.plain(summary);
|
|
4084
|
+
log.plain("");
|
|
4085
|
+
try {
|
|
4086
|
+
import_fs21.default.mkdirSync(WEEKLY_CACHE_DIR, { recursive: true });
|
|
4087
|
+
import_fs21.default.writeFileSync(cacheFile, summary, { encoding: "utf-8", mode: 384 });
|
|
4088
|
+
} catch (error) {
|
|
4089
|
+
debugLog("weekly-digest-cache", error);
|
|
4090
|
+
}
|
|
4091
|
+
await postSummary(opts, config, summary);
|
|
4073
4092
|
});
|
|
4074
4093
|
}
|
|
4075
4094
|
var import_chalk11, import_fs21, import_path16, import_os8;
|
|
@@ -4114,7 +4133,7 @@ function registerBugReport(program) {
|
|
|
4114
4133
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
4115
4134
|
const reportPath = import_path17.default.join(WORKSCRIBE_DIR, `bug-report-${timestamp}.txt`);
|
|
4116
4135
|
const systemInfo = [
|
|
4117
|
-
`Workscribe version : ${"1.15.
|
|
4136
|
+
`Workscribe version : ${"1.15.3"}`,
|
|
4118
4137
|
`Node.js version : ${process.version}`,
|
|
4119
4138
|
`Platform : ${process.platform}`,
|
|
4120
4139
|
`Architecture : ${process.arch}`,
|
|
@@ -4145,7 +4164,7 @@ function registerBugReport(program) {
|
|
|
4145
4164
|
process.exit(1);
|
|
4146
4165
|
}
|
|
4147
4166
|
const params = new URLSearchParams({
|
|
4148
|
-
title: `Bug report \u2014 workscribe ${"1.15.
|
|
4167
|
+
title: `Bug report \u2014 workscribe ${"1.15.3"}`,
|
|
4149
4168
|
body: `<!-- Attach ${import_path17.default.basename(reportPath)} or paste the relevant sections below -->
|
|
4150
4169
|
|
|
4151
4170
|
**Describe the issue:**
|
|
@@ -4345,7 +4364,7 @@ function isNewer(latest, current) {
|
|
|
4345
4364
|
return latestPatch > currentPatch;
|
|
4346
4365
|
}
|
|
4347
4366
|
function checkForUpdate() {
|
|
4348
|
-
const current = "1.15.
|
|
4367
|
+
const current = "1.15.3";
|
|
4349
4368
|
const cache = readCache();
|
|
4350
4369
|
if (cache && isNewer(cache.latestVersion, current)) {
|
|
4351
4370
|
process.stderr.write(
|
|
@@ -4368,7 +4387,7 @@ function checkForUpdate() {
|
|
|
4368
4387
|
function buildTelemetryPayload(config) {
|
|
4369
4388
|
return {
|
|
4370
4389
|
installId: config.telemetry.installId,
|
|
4371
|
-
cliVersion: "1.15.
|
|
4390
|
+
cliVersion: "1.15.3",
|
|
4372
4391
|
platform: import_os10.default.platform(),
|
|
4373
4392
|
nodeVersion: process.version
|
|
4374
4393
|
};
|
|
@@ -4383,7 +4402,14 @@ function pingTelemetry() {
|
|
|
4383
4402
|
method: "POST",
|
|
4384
4403
|
headers: { "Content-Type": "application/json" },
|
|
4385
4404
|
body: JSON.stringify(buildTelemetryPayload(config))
|
|
4386
|
-
}).then(() =>
|
|
4405
|
+
}).then((response) => {
|
|
4406
|
+
if (!response.ok) {
|
|
4407
|
+
debugLog("pingTelemetry", new Error(`Ping failed with HTTP ${response.status}`));
|
|
4408
|
+
return;
|
|
4409
|
+
}
|
|
4410
|
+
writeCache({ lastTelemetryPing: now });
|
|
4411
|
+
}).catch((error) => {
|
|
4412
|
+
debugLog("pingTelemetry", error);
|
|
4387
4413
|
});
|
|
4388
4414
|
}
|
|
4389
4415
|
var import_fs23, import_os10, CHECK_INTERVAL_MS;
|
|
@@ -4394,6 +4420,7 @@ var init_update_check = __esm({
|
|
|
4394
4420
|
import_os10 = __toESM(require("os"));
|
|
4395
4421
|
init_paths();
|
|
4396
4422
|
init_config();
|
|
4423
|
+
init_logger();
|
|
4397
4424
|
CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
4398
4425
|
}
|
|
4399
4426
|
});
|
|
@@ -4425,6 +4452,7 @@ var require_main = __commonJS({
|
|
|
4425
4452
|
init_context();
|
|
4426
4453
|
init_update_check();
|
|
4427
4454
|
init_config();
|
|
4455
|
+
init_logger();
|
|
4428
4456
|
var invokedCommand = process.argv[2];
|
|
4429
4457
|
if (shouldRunStartupChecks(invokedCommand)) {
|
|
4430
4458
|
checkForUpdate();
|
|
@@ -4434,7 +4462,7 @@ var require_main = __commonJS({
|
|
|
4434
4462
|
pingTelemetry();
|
|
4435
4463
|
}
|
|
4436
4464
|
var program = new import_commander.Command();
|
|
4437
|
-
program.name("workscribe").description("Automatic developer work journal").version("1.15.
|
|
4465
|
+
program.name("workscribe").description("Automatic developer work journal").version("1.15.3");
|
|
4438
4466
|
registerCapture(program);
|
|
4439
4467
|
registerHook(program);
|
|
4440
4468
|
registerInit(program);
|
|
@@ -4455,7 +4483,10 @@ var require_main = __commonJS({
|
|
|
4455
4483
|
registerCompletions(program);
|
|
4456
4484
|
registerAlerts(program);
|
|
4457
4485
|
registerContext(program);
|
|
4458
|
-
program.
|
|
4486
|
+
program.parseAsync().catch((error) => {
|
|
4487
|
+
log.error(error instanceof Error ? error.message : String(error));
|
|
4488
|
+
process.exit(1);
|
|
4489
|
+
});
|
|
4459
4490
|
}
|
|
4460
4491
|
});
|
|
4461
4492
|
|