ray-finance 0.3.2 → 0.3.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.
Files changed (2) hide show
  1. package/dist/ai/context.js +17 -10
  2. package/package.json +1 -1
@@ -1,27 +1,33 @@
1
1
  import { readFileSync, writeFileSync, existsSync, mkdirSync, chmodSync } from "fs";
2
- import { resolve } from "path";
3
- import { homedir } from "os";
4
- const CONTEXT_PATH = resolve(homedir(), ".ray", "context.md");
2
+ import { resolve, dirname, basename } from "path";
3
+ import { config } from "../config.js";
4
+ function getContextFilePath() {
5
+ const dbFile = basename(config.dbPath, ".db");
6
+ const contextFile = dbFile === "finance" ? "context.md" : `context-${dbFile}.md`;
7
+ return resolve(dirname(config.dbPath), "..", contextFile);
8
+ }
5
9
  export function getContextPath() {
6
- return CONTEXT_PATH;
10
+ return getContextFilePath();
7
11
  }
8
12
  export function readContext() {
9
- if (!existsSync(CONTEXT_PATH))
13
+ const contextPath = getContextFilePath();
14
+ if (!existsSync(contextPath))
10
15
  return "";
11
16
  try {
12
- return readFileSync(CONTEXT_PATH, "utf-8");
17
+ return readFileSync(contextPath, "utf-8");
13
18
  }
14
19
  catch {
15
20
  return "";
16
21
  }
17
22
  }
18
23
  export function writeContext(content) {
19
- const dir = resolve(homedir(), ".ray");
24
+ const contextPath = getContextFilePath();
25
+ const dir = dirname(contextPath);
20
26
  if (!existsSync(dir))
21
27
  mkdirSync(dir, { recursive: true });
22
- writeFileSync(CONTEXT_PATH, content, { encoding: "utf-8", mode: 0o600 });
28
+ writeFileSync(contextPath, content, { encoding: "utf-8", mode: 0o600 });
23
29
  try {
24
- chmodSync(CONTEXT_PATH, 0o600);
30
+ chmodSync(contextPath, 0o600);
25
31
  }
26
32
  catch { }
27
33
  }
@@ -64,7 +70,8 @@ export function replaceContextSection(section, content) {
64
70
  writeContext(current);
65
71
  }
66
72
  export function createContextTemplate(userName) {
67
- if (existsSync(CONTEXT_PATH))
73
+ const contextPath = getContextFilePath();
74
+ if (existsSync(contextPath))
68
75
  return; // don't overwrite existing
69
76
  const template = `# Financial Context for ${userName}
70
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ray-finance",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Local-first CLI that turns your bank data into a personal AI financial advisor",
5
5
  "type": "module",
6
6
  "license": "MIT",