@shahmilsaari/memory-core 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.
- package/dist/cli.js +37 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Command } from "commander";
|
|
|
5
5
|
import { input, select, confirm } from "@inquirer/prompts";
|
|
6
6
|
import chalk2 from "chalk";
|
|
7
7
|
import ora from "ora";
|
|
8
|
-
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync5, mkdirSync as mkdirSync2 } from "fs";
|
|
8
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync5, mkdirSync as mkdirSync2, appendFileSync } from "fs";
|
|
9
9
|
import { join as join5, dirname as dirname2 } from "path";
|
|
10
10
|
import { homedir } from "os";
|
|
11
11
|
import { execSync as execSync2 } from "child_process";
|
|
@@ -829,6 +829,42 @@ program.name("memory-core").description("Universal AI memory core \u2014 generat
|
|
|
829
829
|
program.command("init").description("Initialize memory-core in the current project").action(async () => {
|
|
830
830
|
console.log(chalk2.bold.cyan("\n memory-core init\n"));
|
|
831
831
|
const detected = detectProject();
|
|
832
|
+
const envPath = join5(process.cwd(), ".memory-core.env");
|
|
833
|
+
const hasEnv = existsSync5(envPath) || existsSync5(join5(process.cwd(), ".env")) || !!process.env.DATABASE_URL;
|
|
834
|
+
if (!hasEnv) {
|
|
835
|
+
console.log(chalk2.dim(" No .memory-core.env found \u2014 let's set up your database connection.\n"));
|
|
836
|
+
const dbUser = process.env.USER ?? process.env.USERNAME ?? "postgres";
|
|
837
|
+
const dbUrl = await input({
|
|
838
|
+
message: "PostgreSQL connection URL?",
|
|
839
|
+
default: `postgresql://${dbUser}@localhost:5432/memory_core`
|
|
840
|
+
});
|
|
841
|
+
const ollamaUrl = await input({
|
|
842
|
+
message: "Ollama URL?",
|
|
843
|
+
default: "http://localhost:11434"
|
|
844
|
+
});
|
|
845
|
+
const envContent = [
|
|
846
|
+
`DATABASE_URL=${dbUrl}`,
|
|
847
|
+
`OLLAMA_URL=${ollamaUrl}`,
|
|
848
|
+
`OLLAMA_MODEL=nomic-embed-text`,
|
|
849
|
+
`OLLAMA_CHAT_MODEL=llama3.2`
|
|
850
|
+
].join("\n") + "\n";
|
|
851
|
+
writeFileSync3(envPath, envContent);
|
|
852
|
+
process.env.DATABASE_URL = dbUrl;
|
|
853
|
+
process.env.OLLAMA_URL = ollamaUrl;
|
|
854
|
+
process.env.OLLAMA_MODEL = "nomic-embed-text";
|
|
855
|
+
process.env.OLLAMA_CHAT_MODEL = "llama3.2";
|
|
856
|
+
const gitignorePath = join5(process.cwd(), ".gitignore");
|
|
857
|
+
if (existsSync5(gitignorePath)) {
|
|
858
|
+
const gi = readFileSync4(gitignorePath, "utf-8");
|
|
859
|
+
if (!gi.includes(".memory-core.env")) {
|
|
860
|
+
appendFileSync(gitignorePath, "\n.memory-core.env\n");
|
|
861
|
+
}
|
|
862
|
+
} else {
|
|
863
|
+
writeFileSync3(gitignorePath, ".memory-core.env\n");
|
|
864
|
+
}
|
|
865
|
+
console.log(chalk2.green("\n \u2713 .memory-core.env created"));
|
|
866
|
+
console.log(chalk2.gray(" Added to .gitignore \u2014 your DB credentials stay local.\n"));
|
|
867
|
+
}
|
|
832
868
|
const projectName = await input({
|
|
833
869
|
message: "Project name?",
|
|
834
870
|
default: process.cwd().split("/").pop() ?? "my-project"
|