open-think 0.1.1 → 0.1.2

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/index.js +93 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env node --no-warnings=ExperimentalWarning
2
2
 
3
3
  // src/index.ts
4
- import { Command as Command17 } from "commander";
4
+ import { Command as Command18 } from "commander";
5
5
 
6
6
  // src/commands/log.ts
7
7
  import { Command } from "commander";
8
+ import { spawn } from "child_process";
8
9
  import chalk from "chalk";
9
10
 
10
11
  // src/db/queries.ts
@@ -358,6 +359,18 @@ var syncCommand = new Command("sync").description("Log a sync/work-log entry (sh
358
359
  console.log(`${chalk.green("\u2713")} ${badge} engram saved ${ts}`);
359
360
  console.log(` ${engram.content}`);
360
361
  }
362
+ const curateEveryN = config.cortex?.curateEveryN;
363
+ if (curateEveryN && curateEveryN > 0) {
364
+ const pending = getPendingEngrams(cortex);
365
+ if (pending.length >= curateEveryN) {
366
+ if (!opts.silent) {
367
+ console.log(chalk.dim(` ${pending.length} pending engrams \u2014 triggering curation...`));
368
+ }
369
+ closeEngramsDb(cortex);
370
+ spawn(process.execPath, [process.argv[1], "curate"], { detached: true, stdio: "ignore" }).unref();
371
+ return;
372
+ }
373
+ }
361
374
  closeEngramsDb(cortex);
362
375
  } else {
363
376
  const tags = opts.tags ? opts.tags.split(",").map((t) => t.trim()) : void 0;
@@ -1022,6 +1035,7 @@ cortexCommand.addCommand(new Command9("current").description("Show the active co
1022
1035
 
1023
1036
  // src/commands/curate.ts
1024
1037
  import { Command as Command10 } from "commander";
1038
+ import readline3 from "readline";
1025
1039
  import chalk10 from "chalk";
1026
1040
 
1027
1041
  // src/lib/curator.ts
@@ -1217,6 +1231,42 @@ var curateCommand = new Command10("curate").description("Run curation: evaluate
1217
1231
  closeEngramsDb(cortex);
1218
1232
  return;
1219
1233
  }
1234
+ if (config.cortex?.confirmBeforeCommit && newEntries.length > 0) {
1235
+ console.log();
1236
+ console.log(chalk10.cyan("Proposed memories:"));
1237
+ for (let i = 0; i < newEntries.length; i++) {
1238
+ console.log(chalk10.green(` ${i + 1}. `) + newEntries[i].content);
1239
+ }
1240
+ console.log();
1241
+ const rl = readline3.createInterface({ input: process.stdin, output: process.stdout });
1242
+ const answer = await new Promise((resolve) => {
1243
+ rl.question(" Commit these memories? [Y/n/edit] ", (ans) => {
1244
+ rl.close();
1245
+ resolve(ans.trim().toLowerCase());
1246
+ });
1247
+ });
1248
+ if (answer === "n" || answer === "no") {
1249
+ console.log(chalk10.dim(" Aborted. Engrams left as pending."));
1250
+ closeEngramsDb(cortex);
1251
+ return;
1252
+ }
1253
+ if (answer === "e" || answer === "edit") {
1254
+ for (let i = 0; i < newEntries.length; i++) {
1255
+ const editRl = readline3.createInterface({ input: process.stdin, output: process.stdout });
1256
+ const edited = await new Promise((resolve) => {
1257
+ editRl.question(` ${i + 1}. ${chalk10.dim("(enter to keep, or type replacement)")}
1258
+ ${newEntries[i].content}
1259
+ > `, (ans) => {
1260
+ editRl.close();
1261
+ resolve(ans.trim());
1262
+ });
1263
+ });
1264
+ if (edited) {
1265
+ newEntries[i].content = edited;
1266
+ }
1267
+ }
1268
+ }
1269
+ }
1220
1270
  if (newEntries.length > 0) {
1221
1271
  const newLines = newEntries.map((e) => JSON.stringify(e));
1222
1272
  const commitMsg = `curate: ${author}, ${pending.length} engrams, ${newEntries.length} memories`;
@@ -1463,8 +1513,48 @@ var resumeCommand = new Command16("resume").description("Resume engram creation
1463
1513
  console.log(chalk16.green("\u2713") + " Engram creation resumed.");
1464
1514
  });
1465
1515
 
1516
+ // src/commands/config-cmd.ts
1517
+ import { Command as Command17 } from "commander";
1518
+ import chalk17 from "chalk";
1519
+ var ALLOWED_KEYS = /* @__PURE__ */ new Set([
1520
+ "cortex.curateEveryN",
1521
+ "cortex.confirmBeforeCommit",
1522
+ "cortex.author",
1523
+ "cortex.repo",
1524
+ "cortex.active",
1525
+ "paused"
1526
+ ]);
1527
+ var configCommand = new Command17("config").description("View or update think configuration");
1528
+ configCommand.addCommand(new Command17("show").description("Print current configuration").action(() => {
1529
+ const config = getConfig();
1530
+ console.log(JSON.stringify(config, null, 2));
1531
+ }));
1532
+ configCommand.addCommand(new Command17("set").argument("<key>", "Config key (e.g., cortex.curateEveryN, cortex.confirmBeforeCommit)").argument("<value>", "Value to set").description("Set a configuration value").action((key, value) => {
1533
+ if (!ALLOWED_KEYS.has(key)) {
1534
+ console.error(chalk17.red(`Unknown config key: ${key}`));
1535
+ console.error(chalk17.dim(`Allowed keys: ${[...ALLOWED_KEYS].join(", ")}`));
1536
+ process.exit(1);
1537
+ }
1538
+ const config = getConfig();
1539
+ let parsed = value;
1540
+ if (value === "true") parsed = true;
1541
+ else if (value === "false") parsed = false;
1542
+ else if (/^\d+$/.test(value)) parsed = parseInt(value, 10);
1543
+ const parts = key.split(".");
1544
+ let target = config;
1545
+ for (let i = 0; i < parts.length - 1; i++) {
1546
+ if (!target[parts[i]] || typeof target[parts[i]] !== "object") {
1547
+ target[parts[i]] = {};
1548
+ }
1549
+ target = target[parts[i]];
1550
+ }
1551
+ target[parts[parts.length - 1]] = parsed;
1552
+ saveConfig(config);
1553
+ console.log(chalk17.green("\u2713") + ` ${key} = ${JSON.stringify(parsed)}`);
1554
+ }));
1555
+
1466
1556
  // src/index.ts
1467
- var program = new Command17();
1557
+ var program = new Command18();
1468
1558
  program.name("think").description("Local-first CLI tool for capturing notes, work logs, and ideas").version("0.1.0").option("-C, --cortex <name>", "Use a specific cortex for this command");
1469
1559
  program.addCommand(logCommand);
1470
1560
  program.addCommand(syncCommand);
@@ -1484,4 +1574,5 @@ program.addCommand(curatorCommand);
1484
1574
  program.addCommand(pullCommand);
1485
1575
  program.addCommand(pauseCommand);
1486
1576
  program.addCommand(resumeCommand);
1577
+ program.addCommand(configCommand);
1487
1578
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-think",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "Local-first CLI that gives AI agents persistent, curated memory",
6
6
  "bin": {