open-think 0.3.3 → 0.3.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/{chunk-ZKUJ5M2W.js → chunk-BBCWF24H.js} +1 -1
- package/dist/{chunk-DCTG6IK4.js → chunk-HUBRLTY3.js} +1 -0
- package/dist/{chunk-OFGWR45G.js → chunk-LN2TIS5R.js} +1 -1
- package/dist/{git-TG6OJFBT.js → git-CMDUX3KB.js} +2 -2
- package/dist/index.js +245 -25
- package/dist/{memory-queries-N4VT5G2E.js → memory-queries-QKGOKRFR.js} +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
setLongtermSummary,
|
|
15
15
|
setSyncCursor,
|
|
16
16
|
tombstoneMemory
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-LN2TIS5R.js";
|
|
18
18
|
import {
|
|
19
19
|
appendAndCommit,
|
|
20
20
|
countBranchFileLines,
|
|
@@ -28,18 +28,19 @@ import {
|
|
|
28
28
|
migrateToBuckets,
|
|
29
29
|
readFileFromBranch,
|
|
30
30
|
saveConfig
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-BBCWF24H.js";
|
|
32
32
|
import {
|
|
33
33
|
ensureThinkDirs,
|
|
34
34
|
getCuratorMdPath,
|
|
35
35
|
getEngramsDir,
|
|
36
36
|
getLongtermPath,
|
|
37
|
-
getThinkDataDir
|
|
38
|
-
|
|
37
|
+
getThinkDataDir,
|
|
38
|
+
getThinkDir
|
|
39
|
+
} from "./chunk-HUBRLTY3.js";
|
|
39
40
|
|
|
40
41
|
// src/index.ts
|
|
41
|
-
import
|
|
42
|
-
import
|
|
42
|
+
import fs12 from "fs";
|
|
43
|
+
import path6 from "path";
|
|
43
44
|
import { Command as Command20 } from "commander";
|
|
44
45
|
|
|
45
46
|
// src/commands/log.ts
|
|
@@ -1010,7 +1011,7 @@ ${shown.length} events` + (entries.length > limit ? ` (showing last ${limit} of
|
|
|
1010
1011
|
});
|
|
1011
1012
|
|
|
1012
1013
|
// src/commands/cortex.ts
|
|
1013
|
-
import
|
|
1014
|
+
import fs9 from "fs";
|
|
1014
1015
|
import { Command as Command9 } from "commander";
|
|
1015
1016
|
import chalk9 from "chalk";
|
|
1016
1017
|
import readline2 from "readline";
|
|
@@ -1555,6 +1556,146 @@ function getSyncAdapter() {
|
|
|
1555
1556
|
return null;
|
|
1556
1557
|
}
|
|
1557
1558
|
|
|
1559
|
+
// src/lib/auto-curate.ts
|
|
1560
|
+
import fs8 from "fs";
|
|
1561
|
+
import path5 from "path";
|
|
1562
|
+
import crypto2 from "crypto";
|
|
1563
|
+
import { execFileSync } from "child_process";
|
|
1564
|
+
var DEFAULT_INTERVAL_SECONDS = 300;
|
|
1565
|
+
function getHome() {
|
|
1566
|
+
const home = process.env.HOME;
|
|
1567
|
+
if (!home) throw new Error("HOME environment variable is not set");
|
|
1568
|
+
return home;
|
|
1569
|
+
}
|
|
1570
|
+
function getLaunchAgentsDir() {
|
|
1571
|
+
return path5.join(getHome(), "Library", "LaunchAgents");
|
|
1572
|
+
}
|
|
1573
|
+
function getAgentLabel() {
|
|
1574
|
+
const thinkHome = process.env.THINK_HOME;
|
|
1575
|
+
if (!thinkHome) return "ai.openthink.curate.default";
|
|
1576
|
+
const hash = crypto2.createHash("sha1").update(thinkHome).digest("hex").slice(0, 8);
|
|
1577
|
+
return `ai.openthink.curate.${hash}`;
|
|
1578
|
+
}
|
|
1579
|
+
function getPlistPath(label = getAgentLabel()) {
|
|
1580
|
+
return path5.join(getLaunchAgentsDir(), `${label}.plist`);
|
|
1581
|
+
}
|
|
1582
|
+
function getLogPath() {
|
|
1583
|
+
return path5.join(getThinkDir(), "auto-curate.log");
|
|
1584
|
+
}
|
|
1585
|
+
function resolveThinkBinary() {
|
|
1586
|
+
const arg1 = process.argv[1];
|
|
1587
|
+
if (arg1 && fs8.existsSync(arg1)) return arg1;
|
|
1588
|
+
throw new Error("Could not resolve think binary path");
|
|
1589
|
+
}
|
|
1590
|
+
function resolveNodeBinary() {
|
|
1591
|
+
return process.execPath;
|
|
1592
|
+
}
|
|
1593
|
+
function renderPlist(opts) {
|
|
1594
|
+
const envBlock = opts.thinkHome ? ` <key>EnvironmentVariables</key>
|
|
1595
|
+
<dict>
|
|
1596
|
+
<key>THINK_HOME</key>
|
|
1597
|
+
<string>${escapeXml(opts.thinkHome)}</string>
|
|
1598
|
+
</dict>
|
|
1599
|
+
` : "";
|
|
1600
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
1601
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
1602
|
+
<plist version="1.0">
|
|
1603
|
+
<dict>
|
|
1604
|
+
<key>Label</key>
|
|
1605
|
+
<string>${escapeXml(opts.label)}</string>
|
|
1606
|
+
<key>ProgramArguments</key>
|
|
1607
|
+
<array>
|
|
1608
|
+
<string>${escapeXml(opts.nodePath)}</string>
|
|
1609
|
+
<string>${escapeXml(opts.thinkPath)}</string>
|
|
1610
|
+
<string>curate</string>
|
|
1611
|
+
<string>--if-idle</string>
|
|
1612
|
+
</array>
|
|
1613
|
+
<key>StartInterval</key>
|
|
1614
|
+
<integer>${opts.intervalSeconds}</integer>
|
|
1615
|
+
<key>RunAtLoad</key>
|
|
1616
|
+
<false/>
|
|
1617
|
+
${envBlock} <key>StandardOutPath</key>
|
|
1618
|
+
<string>${escapeXml(opts.logPath)}</string>
|
|
1619
|
+
<key>StandardErrorPath</key>
|
|
1620
|
+
<string>${escapeXml(opts.logPath)}</string>
|
|
1621
|
+
</dict>
|
|
1622
|
+
</plist>
|
|
1623
|
+
`;
|
|
1624
|
+
}
|
|
1625
|
+
function escapeXml(s) {
|
|
1626
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1627
|
+
}
|
|
1628
|
+
function installAgent(opts = {}) {
|
|
1629
|
+
if (process.platform !== "darwin") {
|
|
1630
|
+
throw new Error("auto-curate install currently supports macOS only. For Linux, run `think curate --if-idle` from cron or systemd.");
|
|
1631
|
+
}
|
|
1632
|
+
const label = getAgentLabel();
|
|
1633
|
+
const plistPath = getPlistPath(label);
|
|
1634
|
+
const agentsDir = getLaunchAgentsDir();
|
|
1635
|
+
fs8.mkdirSync(agentsDir, { recursive: true });
|
|
1636
|
+
fs8.mkdirSync(getThinkDir(), { recursive: true });
|
|
1637
|
+
const plist = renderPlist({
|
|
1638
|
+
label,
|
|
1639
|
+
nodePath: resolveNodeBinary(),
|
|
1640
|
+
thinkPath: resolveThinkBinary(),
|
|
1641
|
+
thinkHome: process.env.THINK_HOME,
|
|
1642
|
+
intervalSeconds: opts.intervalSeconds ?? DEFAULT_INTERVAL_SECONDS,
|
|
1643
|
+
logPath: getLogPath()
|
|
1644
|
+
});
|
|
1645
|
+
fs8.writeFileSync(plistPath, plist, { mode: 420 });
|
|
1646
|
+
try {
|
|
1647
|
+
execFileSync("launchctl", ["unload", plistPath], { stdio: "ignore" });
|
|
1648
|
+
} catch {
|
|
1649
|
+
}
|
|
1650
|
+
execFileSync("launchctl", ["load", plistPath], { stdio: "ignore" });
|
|
1651
|
+
return { label, plistPath };
|
|
1652
|
+
}
|
|
1653
|
+
function uninstallAgent() {
|
|
1654
|
+
const plistPath = getPlistPath();
|
|
1655
|
+
if (!fs8.existsSync(plistPath)) {
|
|
1656
|
+
return { removed: false, plistPath };
|
|
1657
|
+
}
|
|
1658
|
+
if (process.platform === "darwin") {
|
|
1659
|
+
try {
|
|
1660
|
+
execFileSync("launchctl", ["unload", plistPath], { stdio: "ignore" });
|
|
1661
|
+
} catch {
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
fs8.unlinkSync(plistPath);
|
|
1665
|
+
return { removed: true, plistPath };
|
|
1666
|
+
}
|
|
1667
|
+
function getAgentStatus() {
|
|
1668
|
+
const label = getAgentLabel();
|
|
1669
|
+
const plistPath = getPlistPath(label);
|
|
1670
|
+
const installed = fs8.existsSync(plistPath);
|
|
1671
|
+
let loaded = false;
|
|
1672
|
+
let intervalSeconds = null;
|
|
1673
|
+
if (installed && process.platform === "darwin") {
|
|
1674
|
+
try {
|
|
1675
|
+
const out = execFileSync("launchctl", ["list", label], { stdio: ["ignore", "pipe", "ignore"] }).toString();
|
|
1676
|
+
loaded = out.trim().length > 0;
|
|
1677
|
+
} catch {
|
|
1678
|
+
loaded = false;
|
|
1679
|
+
}
|
|
1680
|
+
try {
|
|
1681
|
+
const plist = fs8.readFileSync(plistPath, "utf-8");
|
|
1682
|
+
const match = plist.match(/<key>StartInterval<\/key>\s*<integer>(\d+)<\/integer>/);
|
|
1683
|
+
if (match) intervalSeconds = parseInt(match[1], 10);
|
|
1684
|
+
} catch {
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
let lastRunAt = null;
|
|
1688
|
+
const logPath = getLogPath();
|
|
1689
|
+
if (fs8.existsSync(logPath)) {
|
|
1690
|
+
try {
|
|
1691
|
+
const stat = fs8.statSync(logPath);
|
|
1692
|
+
lastRunAt = stat.mtime;
|
|
1693
|
+
} catch {
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
return { installed, label, plistPath, loaded, lastRunAt, intervalSeconds };
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1558
1699
|
// src/commands/cortex.ts
|
|
1559
1700
|
function prompt2(question, defaultValue) {
|
|
1560
1701
|
const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -1595,7 +1736,7 @@ cortexCommand.addCommand(new Command9("setup").description("Configure a sync bac
|
|
|
1595
1736
|
const adapter = getSyncAdapter();
|
|
1596
1737
|
if (adapter) {
|
|
1597
1738
|
try {
|
|
1598
|
-
const { ensureRepoCloned: ensureRepoCloned2 } = await import("./git-
|
|
1739
|
+
const { ensureRepoCloned: ensureRepoCloned2 } = await import("./git-CMDUX3KB.js");
|
|
1599
1740
|
ensureRepoCloned2();
|
|
1600
1741
|
console.log(chalk9.green("\u2713") + " Repo cloned");
|
|
1601
1742
|
} catch (err) {
|
|
@@ -1636,8 +1777,8 @@ cortexCommand.addCommand(new Command9("list").description("Show all cortexes").a
|
|
|
1636
1777
|
const config = getConfig();
|
|
1637
1778
|
const engramsDir = getEngramsDir();
|
|
1638
1779
|
const localCortexes = [];
|
|
1639
|
-
if (
|
|
1640
|
-
for (const file of
|
|
1780
|
+
if (fs9.existsSync(engramsDir)) {
|
|
1781
|
+
for (const file of fs9.readdirSync(engramsDir)) {
|
|
1641
1782
|
if (file.endsWith(".db") && !file.endsWith("-shm") && !file.endsWith("-wal")) {
|
|
1642
1783
|
localCortexes.push(file.replace(".db", ""));
|
|
1643
1784
|
}
|
|
@@ -1678,7 +1819,7 @@ cortexCommand.addCommand(new Command9("switch").argument("<name>", "Cortex name"
|
|
|
1678
1819
|
}
|
|
1679
1820
|
const engramsDir = getEngramsDir();
|
|
1680
1821
|
const dbPath = `${engramsDir}/${name}.db`;
|
|
1681
|
-
if (!
|
|
1822
|
+
if (!fs9.existsSync(dbPath)) {
|
|
1682
1823
|
const adapter = getSyncAdapter();
|
|
1683
1824
|
if (adapter?.isAvailable()) {
|
|
1684
1825
|
try {
|
|
@@ -1792,19 +1933,74 @@ cortexCommand.addCommand(new Command9("status").description("Show sync status fo
|
|
|
1792
1933
|
}
|
|
1793
1934
|
closeCortexDb(cortex);
|
|
1794
1935
|
}));
|
|
1936
|
+
var autoCurateCommand = new Command9("auto-curate").description("Manage scheduled background curation (macOS LaunchAgent)");
|
|
1937
|
+
autoCurateCommand.addCommand(new Command9("enable").description("Install a LaunchAgent that runs `think curate --if-idle` every 5 minutes").option("--interval <seconds>", "Scheduler cadence in seconds (default 300)", (v) => parseInt(v, 10)).action((opts) => {
|
|
1938
|
+
try {
|
|
1939
|
+
const { label, plistPath } = installAgent({ intervalSeconds: opts.interval });
|
|
1940
|
+
console.log(chalk9.green("\u2713") + ` Auto-curation enabled`);
|
|
1941
|
+
console.log(chalk9.dim(` Label: ${label}`));
|
|
1942
|
+
console.log(chalk9.dim(` Plist: ${plistPath}`));
|
|
1943
|
+
if (process.env.THINK_HOME) {
|
|
1944
|
+
console.log(chalk9.dim(` THINK_HOME: ${process.env.THINK_HOME}`));
|
|
1945
|
+
}
|
|
1946
|
+
} catch (err) {
|
|
1947
|
+
console.error(chalk9.red(err instanceof Error ? err.message : String(err)));
|
|
1948
|
+
process.exit(1);
|
|
1949
|
+
}
|
|
1950
|
+
}));
|
|
1951
|
+
autoCurateCommand.addCommand(new Command9("disable").description("Remove the auto-curation LaunchAgent for this workspace").action(() => {
|
|
1952
|
+
const { removed, plistPath } = uninstallAgent();
|
|
1953
|
+
if (removed) {
|
|
1954
|
+
console.log(chalk9.green("\u2713") + ` Auto-curation disabled (${plistPath})`);
|
|
1955
|
+
} else {
|
|
1956
|
+
console.log(chalk9.dim(`No auto-curation agent installed (${plistPath})`));
|
|
1957
|
+
}
|
|
1958
|
+
}));
|
|
1959
|
+
autoCurateCommand.addCommand(new Command9("status").description("Show auto-curation scheduler status").action(() => {
|
|
1960
|
+
const s = getAgentStatus();
|
|
1961
|
+
console.log(`Label: ${chalk9.cyan(s.label)}`);
|
|
1962
|
+
console.log(`Installed: ${s.installed ? chalk9.green("yes") : chalk9.dim("no")}`);
|
|
1963
|
+
console.log(`Loaded: ${s.loaded ? chalk9.green("yes") : chalk9.dim("no")}`);
|
|
1964
|
+
if (s.intervalSeconds) {
|
|
1965
|
+
console.log(`Interval: ${s.intervalSeconds}s`);
|
|
1966
|
+
}
|
|
1967
|
+
console.log(`Plist: ${s.plistPath}`);
|
|
1968
|
+
if (s.lastRunAt) {
|
|
1969
|
+
console.log(`Last log: ${s.lastRunAt.toISOString()}`);
|
|
1970
|
+
} else {
|
|
1971
|
+
console.log(`Last log: ${chalk9.dim("(no log file yet)")}`);
|
|
1972
|
+
}
|
|
1973
|
+
}));
|
|
1974
|
+
cortexCommand.addCommand(autoCurateCommand);
|
|
1795
1975
|
|
|
1796
1976
|
// src/commands/curate.ts
|
|
1797
1977
|
import { Command as Command10 } from "commander";
|
|
1798
1978
|
import readline3 from "readline";
|
|
1799
1979
|
import chalk10 from "chalk";
|
|
1800
|
-
var curateCommand = new Command10("curate").description("Run curation: evaluate pending engrams and promote to memories").option("--dry-run", "Preview what would be committed without saving").option("--consolidate", "Run long-term memory consolidation only (no curation)").option("--episode <key>", "Curate a specific episode into a narrative memory").action(async (opts) => {
|
|
1980
|
+
var curateCommand = new Command10("curate").description("Run curation: evaluate pending engrams and promote to memories").option("--dry-run", "Preview what would be committed without saving").option("--consolidate", "Run long-term memory consolidation only (no curation)").option("--episode <key>", "Curate a specific episode into a narrative memory").option("--if-idle", "Only curate if the user appears idle (used by auto-curation scheduler)").action(async (opts) => {
|
|
1801
1981
|
const config = getConfig();
|
|
1802
1982
|
const cortex = config.cortex?.active;
|
|
1803
1983
|
if (!cortex) {
|
|
1984
|
+
if (opts.ifIdle) {
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
1804
1987
|
console.error(chalk10.red("No active cortex. Run: think cortex switch <name>"));
|
|
1805
1988
|
process.exit(1);
|
|
1806
1989
|
}
|
|
1807
1990
|
const author = config.cortex.author;
|
|
1991
|
+
if (opts.ifIdle && !opts.episode && !opts.consolidate) {
|
|
1992
|
+
const shouldRun = shouldRunIdleCuration(cortex, config.cortex);
|
|
1993
|
+
if (!shouldRun.run) {
|
|
1994
|
+
if (process.env.THINK_IDLE_DEBUG) {
|
|
1995
|
+
console.log(chalk10.dim(`[auto-curate] skipped: ${shouldRun.reason}`));
|
|
1996
|
+
}
|
|
1997
|
+
closeCortexDb(cortex);
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
if (process.env.THINK_IDLE_DEBUG) {
|
|
2001
|
+
console.log(chalk10.dim(`[auto-curate] running: ${shouldRun.reason}`));
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
1808
2004
|
const adapter = getSyncAdapter();
|
|
1809
2005
|
if (adapter?.isAvailable()) {
|
|
1810
2006
|
try {
|
|
@@ -2058,6 +2254,28 @@ var curateCommand = new Command10("curate").description("Run curation: evaluate
|
|
|
2058
2254
|
}
|
|
2059
2255
|
closeCortexDb(cortex);
|
|
2060
2256
|
});
|
|
2257
|
+
var DEFAULT_IDLE_WINDOW_MINUTES = 3;
|
|
2258
|
+
var DEFAULT_STALE_WINDOW_MINUTES = 60;
|
|
2259
|
+
function shouldRunIdleCuration(cortex, cortexConfig) {
|
|
2260
|
+
const pending = getPendingEngrams(cortex);
|
|
2261
|
+
if (pending.length === 0) {
|
|
2262
|
+
return { run: false, reason: "no pending engrams" };
|
|
2263
|
+
}
|
|
2264
|
+
const idleMinutes = cortexConfig?.idleWindowMinutes ?? DEFAULT_IDLE_WINDOW_MINUTES;
|
|
2265
|
+
const staleMinutes = cortexConfig?.staleWindowMinutes ?? DEFAULT_STALE_WINDOW_MINUTES;
|
|
2266
|
+
const now = Date.now();
|
|
2267
|
+
const oldest = pending[0];
|
|
2268
|
+
const newest = pending[pending.length - 1];
|
|
2269
|
+
const oldestAgeMin = (now - new Date(oldest.created_at).getTime()) / 6e4;
|
|
2270
|
+
const newestAgeMin = (now - new Date(newest.created_at).getTime()) / 6e4;
|
|
2271
|
+
if (oldestAgeMin >= staleMinutes) {
|
|
2272
|
+
return { run: true, reason: `staleness cap hit (oldest pending ${oldestAgeMin.toFixed(1)}min old)` };
|
|
2273
|
+
}
|
|
2274
|
+
if (newestAgeMin < idleMinutes) {
|
|
2275
|
+
return { run: false, reason: `still active (newest engram ${newestAgeMin.toFixed(1)}min old, idle threshold ${idleMinutes}min)` };
|
|
2276
|
+
}
|
|
2277
|
+
return { run: true, reason: `idle (${pending.length} pending, newest ${newestAgeMin.toFixed(1)}min old)` };
|
|
2278
|
+
}
|
|
2061
2279
|
|
|
2062
2280
|
// src/commands/monitor.ts
|
|
2063
2281
|
import { Command as Command11 } from "commander";
|
|
@@ -2122,7 +2340,7 @@ var recallCommand = new Command12("recall").argument("<query>", "What to recall"
|
|
|
2122
2340
|
}
|
|
2123
2341
|
const limit = parseInt(opts.limit, 10);
|
|
2124
2342
|
if (opts.all) {
|
|
2125
|
-
const { getMemories: getMemories2 } = await import("./memory-queries-
|
|
2343
|
+
const { getMemories: getMemories2 } = await import("./memory-queries-QKGOKRFR.js");
|
|
2126
2344
|
const days = parseInt(opts.days, 10);
|
|
2127
2345
|
const cutoff = new Date(Date.now() - days * 864e5).toISOString();
|
|
2128
2346
|
const recentMemories = getMemories2(cortex, { since: cutoff });
|
|
@@ -2278,7 +2496,7 @@ memoryCommand.addCommand(addCommand);
|
|
|
2278
2496
|
// src/commands/curator-cmd.ts
|
|
2279
2497
|
import { Command as Command14 } from "commander";
|
|
2280
2498
|
import { spawnSync } from "child_process";
|
|
2281
|
-
import
|
|
2499
|
+
import fs10 from "fs";
|
|
2282
2500
|
import chalk14 from "chalk";
|
|
2283
2501
|
var CURATOR_TEMPLATE = `# Curator Guidance
|
|
2284
2502
|
|
|
@@ -2297,8 +2515,8 @@ var curatorCommand = new Command14("curator").description("Manage personal curat
|
|
|
2297
2515
|
curatorCommand.addCommand(new Command14("edit").description("Edit your curator guidance in $EDITOR").action(() => {
|
|
2298
2516
|
ensureThinkDirs();
|
|
2299
2517
|
const mdPath = getCuratorMdPath();
|
|
2300
|
-
if (!
|
|
2301
|
-
|
|
2518
|
+
if (!fs10.existsSync(mdPath)) {
|
|
2519
|
+
fs10.writeFileSync(mdPath, CURATOR_TEMPLATE, "utf-8");
|
|
2302
2520
|
}
|
|
2303
2521
|
const editor = process.env.EDITOR || "vi";
|
|
2304
2522
|
const result = spawnSync(editor, [mdPath], { stdio: "inherit" });
|
|
@@ -2310,8 +2528,8 @@ curatorCommand.addCommand(new Command14("edit").description("Edit your curator g
|
|
|
2310
2528
|
}));
|
|
2311
2529
|
curatorCommand.addCommand(new Command14("show").description("Print your current curator guidance").action(() => {
|
|
2312
2530
|
const mdPath = getCuratorMdPath();
|
|
2313
|
-
if (
|
|
2314
|
-
console.log(
|
|
2531
|
+
if (fs10.existsSync(mdPath)) {
|
|
2532
|
+
console.log(fs10.readFileSync(mdPath, "utf-8"));
|
|
2315
2533
|
} else {
|
|
2316
2534
|
console.log(chalk14.dim("No curator guidance configured. Run: think curator edit"));
|
|
2317
2535
|
}
|
|
@@ -2375,6 +2593,8 @@ var ALLOWED_KEYS = /* @__PURE__ */ new Set([
|
|
|
2375
2593
|
"cortex.repo",
|
|
2376
2594
|
"cortex.active",
|
|
2377
2595
|
"cortex.engramTTLDays",
|
|
2596
|
+
"cortex.idleWindowMinutes",
|
|
2597
|
+
"cortex.staleWindowMinutes",
|
|
2378
2598
|
"paused"
|
|
2379
2599
|
]);
|
|
2380
2600
|
var configCommand = new Command17("config").description("View or update think configuration");
|
|
@@ -2408,12 +2628,12 @@ configCommand.addCommand(new Command17("set").argument("<key>", "Config key (e.g
|
|
|
2408
2628
|
|
|
2409
2629
|
// src/commands/update.ts
|
|
2410
2630
|
import { Command as Command18 } from "commander";
|
|
2411
|
-
import { execFileSync } from "child_process";
|
|
2631
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
2412
2632
|
import chalk18 from "chalk";
|
|
2413
2633
|
var updateCommand = new Command18("update").description("Update think to the latest version").action(() => {
|
|
2414
2634
|
console.log(chalk18.cyan("Checking for updates..."));
|
|
2415
2635
|
try {
|
|
2416
|
-
const result =
|
|
2636
|
+
const result = execFileSync2("npm", ["install", "-g", "open-think@latest"], {
|
|
2417
2637
|
encoding: "utf-8",
|
|
2418
2638
|
stdio: ["pipe", "pipe", "pipe"]
|
|
2419
2639
|
});
|
|
@@ -2431,7 +2651,7 @@ var updateCommand = new Command18("update").description("Update think to the lat
|
|
|
2431
2651
|
|
|
2432
2652
|
// src/commands/migrate-data.ts
|
|
2433
2653
|
import { Command as Command19 } from "commander";
|
|
2434
|
-
import
|
|
2654
|
+
import fs11 from "fs";
|
|
2435
2655
|
import chalk19 from "chalk";
|
|
2436
2656
|
var migrateDataCommand = new Command19("migrate-data").description("Import existing memories from git into local SQLite (one-time migration)").action(async () => {
|
|
2437
2657
|
const config = getConfig();
|
|
@@ -2469,8 +2689,8 @@ var migrateDataCommand = new Command19("migrate-data").description("Import exist
|
|
|
2469
2689
|
if (wasInserted) inserted++;
|
|
2470
2690
|
}
|
|
2471
2691
|
const ltPath = getLongtermPath(cortex);
|
|
2472
|
-
if (
|
|
2473
|
-
const ltContent =
|
|
2692
|
+
if (fs11.existsSync(ltPath)) {
|
|
2693
|
+
const ltContent = fs11.readFileSync(ltPath, "utf-8").trim();
|
|
2474
2694
|
if (ltContent) {
|
|
2475
2695
|
setLongtermSummary(cortex, ltContent);
|
|
2476
2696
|
console.log(chalk19.green(" \u2713") + " Long-term summary migrated");
|
|
@@ -2489,8 +2709,8 @@ var migrateDataCommand = new Command19("migrate-data").description("Import exist
|
|
|
2489
2709
|
// src/index.ts
|
|
2490
2710
|
function readPackageVersion() {
|
|
2491
2711
|
try {
|
|
2492
|
-
const pkgPath =
|
|
2493
|
-
return JSON.parse(
|
|
2712
|
+
const pkgPath = path6.join(import.meta.dirname, "..", "package.json");
|
|
2713
|
+
return JSON.parse(fs12.readFileSync(pkgPath, "utf-8")).version ?? "0.0.0";
|
|
2494
2714
|
} catch {
|
|
2495
2715
|
return "0.0.0";
|
|
2496
2716
|
}
|