@satori-sh/cli 0.0.9 → 0.0.11
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 +15 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
-
import { readFileSync } from "fs";
|
|
5
|
+
import { readFileSync, realpathSync } from "fs";
|
|
6
6
|
import { dirname, join as join2 } from "path";
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
8
|
import chalk from "chalk";
|
|
@@ -49,10 +49,12 @@ async function saveMemoryId(memoryId) {
|
|
|
49
49
|
}
|
|
50
50
|
async function loadConfigFile() {
|
|
51
51
|
try {
|
|
52
|
+
const { promises: fs } = await import("fs");
|
|
52
53
|
const configPath = join(homedir(), ".config", "satori", "satori.json");
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const raw = await fs.readFile(configPath, "utf8");
|
|
55
|
+
const data = JSON.parse(raw);
|
|
56
|
+
if (data && typeof data === "object") {
|
|
57
|
+
return data;
|
|
56
58
|
}
|
|
57
59
|
} catch {
|
|
58
60
|
}
|
|
@@ -65,16 +67,12 @@ async function getConfig() {
|
|
|
65
67
|
let apiKey = null;
|
|
66
68
|
let memoryId = void 0;
|
|
67
69
|
try {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
if (data && typeof data.memory_id === "string") {
|
|
76
|
-
memoryId = data.memory_id;
|
|
77
|
-
}
|
|
70
|
+
const data = await loadConfigFile();
|
|
71
|
+
if (typeof data.api_key === "string") {
|
|
72
|
+
apiKey = data.api_key;
|
|
73
|
+
}
|
|
74
|
+
if (typeof data.memory_id === "string") {
|
|
75
|
+
memoryId = data.memory_id;
|
|
78
76
|
}
|
|
79
77
|
} catch {
|
|
80
78
|
}
|
|
@@ -395,7 +393,9 @@ ${memoryContext.instruction}`);
|
|
|
395
393
|
});
|
|
396
394
|
program.parse();
|
|
397
395
|
}
|
|
398
|
-
|
|
396
|
+
var entryPath = process.argv[1] ? realpathSync(process.argv[1]) : "";
|
|
397
|
+
var modulePath = realpathSync(fileURLToPath(import.meta.url));
|
|
398
|
+
if (entryPath === modulePath) {
|
|
399
399
|
main();
|
|
400
400
|
}
|
|
401
401
|
export {
|