@codedir/mimir-code 0.1.5 → 0.1.7
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.mjs +155 -69
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -3907,11 +3907,6 @@ import { readFileSync, existsSync } from "fs";
|
|
|
3907
3907
|
function locateWasmFile() {
|
|
3908
3908
|
const wasmFileName = "sql-wasm.wasm";
|
|
3909
3909
|
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
3910
|
-
console.log("WASM file search - debugging:", {
|
|
3911
|
-
"import.meta.url": import.meta.url,
|
|
3912
|
-
currentDir,
|
|
3913
|
-
"process.cwd()": process.cwd()
|
|
3914
|
-
});
|
|
3915
3910
|
const nodeModulesPaths = [
|
|
3916
3911
|
// Relative to the built module (bundled dist/cli.mjs)
|
|
3917
3912
|
join(currentDir, "..", "node_modules", "sql.js", "dist", wasmFileName),
|
|
@@ -3921,10 +3916,8 @@ function locateWasmFile() {
|
|
|
3921
3916
|
join(process.cwd(), "node_modules", "sql.js", "dist", wasmFileName)
|
|
3922
3917
|
];
|
|
3923
3918
|
for (const modulePath of nodeModulesPaths) {
|
|
3924
|
-
console.log(` Checking: ${modulePath} - ${existsSync(modulePath) ? "FOUND" : "not found"}`);
|
|
3925
3919
|
if (existsSync(modulePath)) {
|
|
3926
3920
|
const buffer = readFileSync(modulePath);
|
|
3927
|
-
console.log(" \u2705 Loaded WASM from node_modules");
|
|
3928
3921
|
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
3929
3922
|
}
|
|
3930
3923
|
}
|
|
@@ -3939,12 +3932,8 @@ function locateWasmFile() {
|
|
|
3939
3932
|
join(binaryDir, "..", "resources", wasmFileName)
|
|
3940
3933
|
];
|
|
3941
3934
|
for (const resourcePath of resourcesPaths) {
|
|
3942
|
-
console.log(
|
|
3943
|
-
` Checking: ${resourcePath} - ${existsSync(resourcePath) ? "FOUND" : "not found"}`
|
|
3944
|
-
);
|
|
3945
3935
|
if (existsSync(resourcePath)) {
|
|
3946
3936
|
const buffer = readFileSync(resourcePath);
|
|
3947
|
-
console.log(" \u2705 Loaded WASM from resources/");
|
|
3948
3937
|
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
3949
3938
|
}
|
|
3950
3939
|
}
|
|
@@ -4437,9 +4426,56 @@ var MimirInitializer = class {
|
|
|
4437
4426
|
this.fs = fs4;
|
|
4438
4427
|
this.configLoader = configLoader2;
|
|
4439
4428
|
}
|
|
4429
|
+
/**
|
|
4430
|
+
* Initialize global user directory at ~/.mimir
|
|
4431
|
+
* Contains: global config, global commands, themes (shared resources)
|
|
4432
|
+
*/
|
|
4433
|
+
async initializeGlobalDirectory(homeDir) {
|
|
4434
|
+
const result = {
|
|
4435
|
+
success: true,
|
|
4436
|
+
created: [],
|
|
4437
|
+
errors: [],
|
|
4438
|
+
dbInitialized: false,
|
|
4439
|
+
configCreated: false,
|
|
4440
|
+
globalCreated: false,
|
|
4441
|
+
localCreated: false
|
|
4442
|
+
};
|
|
4443
|
+
try {
|
|
4444
|
+
const globalMimirDir = path6.join(homeDir, ".mimir");
|
|
4445
|
+
if (!await this.fs.exists(globalMimirDir)) {
|
|
4446
|
+
await this.fs.mkdir(globalMimirDir, { recursive: true });
|
|
4447
|
+
result.created.push("~/.mimir/");
|
|
4448
|
+
result.globalCreated = true;
|
|
4449
|
+
logger.info("Created global .mimir directory", { path: globalMimirDir });
|
|
4450
|
+
}
|
|
4451
|
+
const globalSubdirs = [
|
|
4452
|
+
{ name: "commands", purpose: "Global custom slash commands" },
|
|
4453
|
+
{ name: "themes", purpose: "Global UI theme definitions" }
|
|
4454
|
+
];
|
|
4455
|
+
for (const { name, purpose } of globalSubdirs) {
|
|
4456
|
+
const subdir = path6.join(globalMimirDir, name);
|
|
4457
|
+
if (!await this.fs.exists(subdir)) {
|
|
4458
|
+
await this.fs.mkdir(subdir, { recursive: true });
|
|
4459
|
+
result.created.push(`~/.mimir/${name}/`);
|
|
4460
|
+
logger.info(`Created global ${name} directory`, { path: subdir, purpose });
|
|
4461
|
+
}
|
|
4462
|
+
}
|
|
4463
|
+
await this.copyDefaultThemes(globalMimirDir, result);
|
|
4464
|
+
await this.copyExampleCommands(globalMimirDir, result);
|
|
4465
|
+
await this.createConfigIfNeeded(globalMimirDir, result);
|
|
4466
|
+
} catch (error) {
|
|
4467
|
+
result.success = false;
|
|
4468
|
+
result.errors.push(
|
|
4469
|
+
`Global directory initialization failed: ${error instanceof Error ? error.message : String(error)}`
|
|
4470
|
+
);
|
|
4471
|
+
logger.error("Global directory initialization failed", { error });
|
|
4472
|
+
}
|
|
4473
|
+
return result;
|
|
4474
|
+
}
|
|
4440
4475
|
/**
|
|
4441
4476
|
* Initialize workspace with full Mimir setup
|
|
4442
4477
|
* Creates directories, database, config, and gitignore
|
|
4478
|
+
* This is for project-local configuration
|
|
4443
4479
|
*/
|
|
4444
4480
|
async initializeWorkspace(workspaceRoot) {
|
|
4445
4481
|
const result = {
|
|
@@ -4447,10 +4483,13 @@ var MimirInitializer = class {
|
|
|
4447
4483
|
created: [],
|
|
4448
4484
|
errors: [],
|
|
4449
4485
|
dbInitialized: false,
|
|
4450
|
-
configCreated: false
|
|
4486
|
+
configCreated: false,
|
|
4487
|
+
globalCreated: false,
|
|
4488
|
+
localCreated: false
|
|
4451
4489
|
};
|
|
4452
4490
|
try {
|
|
4453
4491
|
const mimirDir = path6.join(workspaceRoot, ".mimir");
|
|
4492
|
+
result.localCreated = true;
|
|
4454
4493
|
if (!await this.fs.exists(mimirDir)) {
|
|
4455
4494
|
await this.fs.mkdir(mimirDir, { recursive: true });
|
|
4456
4495
|
result.created.push(".mimir/");
|
|
@@ -4554,13 +4593,6 @@ checkpoints/
|
|
|
4554
4593
|
const currentDir = dirname2(fileURLToPath2(import.meta.url));
|
|
4555
4594
|
const executablePath = process.argv[0] || process.execPath;
|
|
4556
4595
|
const binaryDir = dirname2(executablePath);
|
|
4557
|
-
logger.info("Theme copy - path debugging", {
|
|
4558
|
-
"import.meta.url": import.meta.url,
|
|
4559
|
-
currentDir,
|
|
4560
|
-
executablePath,
|
|
4561
|
-
binaryDir,
|
|
4562
|
-
"process.cwd()": process.cwd()
|
|
4563
|
-
});
|
|
4564
4596
|
const possibleSourceDirs = [
|
|
4565
4597
|
// npm package (bundled CLI): <package-root>/src/cli/themes/
|
|
4566
4598
|
path6.join(currentDir, "../src/cli/themes"),
|
|
@@ -4615,13 +4647,6 @@ checkpoints/
|
|
|
4615
4647
|
const currentDir = dirname2(fileURLToPath2(import.meta.url));
|
|
4616
4648
|
const executablePath = process.argv[0] || process.execPath;
|
|
4617
4649
|
const binaryDir = dirname2(executablePath);
|
|
4618
|
-
logger.info("Command copy - path debugging", {
|
|
4619
|
-
"import.meta.url": import.meta.url,
|
|
4620
|
-
currentDir,
|
|
4621
|
-
executablePath,
|
|
4622
|
-
binaryDir,
|
|
4623
|
-
"process.cwd()": process.cwd()
|
|
4624
|
-
});
|
|
4625
4650
|
const possibleSourceDirs = [
|
|
4626
4651
|
// npm package (bundled CLI): <package-root>/scripts/templates/commands/
|
|
4627
4652
|
path6.join(currentDir, "../scripts/templates/commands"),
|
|
@@ -6166,6 +6191,8 @@ Available providers: deepseek, anthropic`
|
|
|
6166
6191
|
};
|
|
6167
6192
|
|
|
6168
6193
|
// src/cli/commands/InitCommand.ts
|
|
6194
|
+
import { join as join2 } from "path";
|
|
6195
|
+
import { homedir } from "os";
|
|
6169
6196
|
var InitCommand = class {
|
|
6170
6197
|
initializer;
|
|
6171
6198
|
constructor(_fs, _configLoader) {
|
|
@@ -6173,24 +6200,81 @@ var InitCommand = class {
|
|
|
6173
6200
|
}
|
|
6174
6201
|
async execute(projectRoot, options = {}) {
|
|
6175
6202
|
const root = projectRoot || process.cwd();
|
|
6203
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || homedir();
|
|
6176
6204
|
if (!options.quiet) {
|
|
6177
|
-
logger.info("Initializing Mimir
|
|
6205
|
+
logger.info("Initializing Mimir", { projectRoot: root, homeDir });
|
|
6206
|
+
}
|
|
6207
|
+
const globalResult = await this.initializer.initializeGlobalDirectory(homeDir);
|
|
6208
|
+
if (!globalResult.success && !options.quiet) {
|
|
6209
|
+
logger.warn("Global directory initialization had errors", {
|
|
6210
|
+
errors: globalResult.errors
|
|
6211
|
+
});
|
|
6178
6212
|
}
|
|
6179
6213
|
if (await this.initializer.isWorkspaceInitialized(root)) {
|
|
6180
6214
|
if (!options.quiet) {
|
|
6181
6215
|
logger.info("Mimir workspace is already initialized in this directory.");
|
|
6182
6216
|
logger.info('Run "mimir" to start an interactive chat session.');
|
|
6183
6217
|
}
|
|
6218
|
+
if (globalResult.created.length > 0 && !options.quiet) {
|
|
6219
|
+
this.printGlobalSummary(globalResult, homeDir);
|
|
6220
|
+
}
|
|
6184
6221
|
return;
|
|
6185
6222
|
}
|
|
6186
|
-
const
|
|
6223
|
+
const localResult = await this.initializer.initializeWorkspace(root);
|
|
6224
|
+
const combinedResult = {
|
|
6225
|
+
...localResult,
|
|
6226
|
+
created: [...globalResult.created, ...localResult.created],
|
|
6227
|
+
errors: [...globalResult.errors, ...localResult.errors],
|
|
6228
|
+
globalCreated: globalResult.globalCreated,
|
|
6229
|
+
localCreated: localResult.localCreated
|
|
6230
|
+
};
|
|
6187
6231
|
if (!options.quiet) {
|
|
6188
|
-
this.
|
|
6232
|
+
this.printCombinedSummary(combinedResult, homeDir, root);
|
|
6189
6233
|
}
|
|
6190
|
-
if (!
|
|
6234
|
+
if (!globalResult.success || !localResult.success) {
|
|
6191
6235
|
process.exit(1);
|
|
6192
6236
|
}
|
|
6193
6237
|
}
|
|
6238
|
+
printGlobalSummary(result, homeDir) {
|
|
6239
|
+
if (result.created.length > 0) {
|
|
6240
|
+
console.log("\n\u{1F30D} Global Mimir Directory:");
|
|
6241
|
+
result.created.forEach((item) => console.log(` \u2713 ${item}`));
|
|
6242
|
+
console.log(`
|
|
6243
|
+
\u{1F4C1} Location: ${join2(homeDir, ".mimir")}`);
|
|
6244
|
+
}
|
|
6245
|
+
}
|
|
6246
|
+
printCombinedSummary(result, homeDir, projectRoot) {
|
|
6247
|
+
console.log("\n\u{1F680} Mimir Initialized!\n");
|
|
6248
|
+
if (result.globalCreated) {
|
|
6249
|
+
console.log("\u{1F30D} Global Directory Created:");
|
|
6250
|
+
console.log(` ${join2(homeDir, ".mimir")}`);
|
|
6251
|
+
console.log(" \u251C\u2500\u2500 config.yml (user preferences)");
|
|
6252
|
+
console.log(" \u251C\u2500\u2500 commands/ (global custom commands)");
|
|
6253
|
+
console.log(" \u2514\u2500\u2500 themes/ (global UI themes)");
|
|
6254
|
+
console.log("");
|
|
6255
|
+
}
|
|
6256
|
+
if (result.localCreated) {
|
|
6257
|
+
console.log("\u{1F4C2} Project Workspace Created:");
|
|
6258
|
+
console.log(` ${join2(projectRoot, ".mimir")}`);
|
|
6259
|
+
console.log(" \u251C\u2500\u2500 mimir.db (conversation history - ignored)");
|
|
6260
|
+
console.log(" \u251C\u2500\u2500 logs/ (application logs - ignored)");
|
|
6261
|
+
console.log(" \u251C\u2500\u2500 commands/ (project commands - tracked)");
|
|
6262
|
+
console.log(" \u251C\u2500\u2500 themes/ (project themes - tracked)");
|
|
6263
|
+
console.log(" \u2514\u2500\u2500 checkpoints/ (undo/restore - ignored)");
|
|
6264
|
+
console.log("");
|
|
6265
|
+
}
|
|
6266
|
+
if (result.errors.length > 0) {
|
|
6267
|
+
console.log("\u26A0\uFE0F Warnings:");
|
|
6268
|
+
result.errors.forEach((error) => console.log(` ! ${error}`));
|
|
6269
|
+
console.log("");
|
|
6270
|
+
}
|
|
6271
|
+
console.log("\u{1F4A1} Configuration Hierarchy:");
|
|
6272
|
+
console.log(" 1. ~/.mimir/config.yml (user defaults)");
|
|
6273
|
+
console.log(" 2. ./.mimir/config.yml (project overrides)");
|
|
6274
|
+
console.log(" 3. .env (API keys)");
|
|
6275
|
+
console.log(" 4. CLI flags (runtime overrides)");
|
|
6276
|
+
console.log('\n\u2728 Ready to use! Run "mimir" to start an interactive chat session.\n');
|
|
6277
|
+
}
|
|
6194
6278
|
};
|
|
6195
6279
|
|
|
6196
6280
|
// src/cli/commands/UninstallCommand.ts
|
|
@@ -6356,6 +6440,7 @@ var UninstallCommand = class {
|
|
|
6356
6440
|
await this.removeBinaryInstallation(homeDir, result, quiet);
|
|
6357
6441
|
}
|
|
6358
6442
|
if (installType === "npm") {
|
|
6443
|
+
result.isNpmInstall = true;
|
|
6359
6444
|
await this.removeNpmInstallation(result, quiet);
|
|
6360
6445
|
}
|
|
6361
6446
|
if (!keepConfig) {
|
|
@@ -6391,6 +6476,23 @@ var UninstallCommand = class {
|
|
|
6391
6476
|
logger.debug("Detected npm installation (node_modules in path)");
|
|
6392
6477
|
return "npm";
|
|
6393
6478
|
}
|
|
6479
|
+
let currentPath = path8.dirname(scriptPath);
|
|
6480
|
+
for (let i = 0; i < 5; i++) {
|
|
6481
|
+
const packageJsonPath = path8.join(currentPath, "package.json");
|
|
6482
|
+
if (await this.fs.exists(packageJsonPath)) {
|
|
6483
|
+
try {
|
|
6484
|
+
const packageJson = JSON.parse(await this.fs.readFile(packageJsonPath, "utf-8"));
|
|
6485
|
+
if (packageJson.name === "@codedir/mimir-code") {
|
|
6486
|
+
logger.debug("Detected npm installation (found package.json)");
|
|
6487
|
+
return "npm";
|
|
6488
|
+
}
|
|
6489
|
+
} catch (error) {
|
|
6490
|
+
}
|
|
6491
|
+
}
|
|
6492
|
+
const parentPath = path8.dirname(currentPath);
|
|
6493
|
+
if (parentPath === currentPath) break;
|
|
6494
|
+
currentPath = parentPath;
|
|
6495
|
+
}
|
|
6394
6496
|
const homeDir = os6.homedir();
|
|
6395
6497
|
const mimirBinPath = path8.normalize(path8.join(homeDir, ".mimir", "bin")).toLowerCase();
|
|
6396
6498
|
const localBinPath = path8.normalize(path8.join(homeDir, ".local", "bin")).toLowerCase();
|
|
@@ -6425,41 +6527,10 @@ var UninstallCommand = class {
|
|
|
6425
6527
|
return "unknown";
|
|
6426
6528
|
}
|
|
6427
6529
|
}
|
|
6428
|
-
async removeNpmInstallation(
|
|
6429
|
-
if (!
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
logger.info("Please run manually: npm uninstall -g @codedir/mimir-code");
|
|
6433
|
-
}
|
|
6434
|
-
return;
|
|
6435
|
-
}
|
|
6436
|
-
try {
|
|
6437
|
-
if (!quiet) {
|
|
6438
|
-
logger.info("Removing npm global package...");
|
|
6439
|
-
}
|
|
6440
|
-
const npmResult = await this.executor.execute(
|
|
6441
|
-
"npm",
|
|
6442
|
-
["uninstall", "-g", "@codedir/mimir-code"],
|
|
6443
|
-
{
|
|
6444
|
-
cwd: process.cwd()
|
|
6445
|
-
}
|
|
6446
|
-
);
|
|
6447
|
-
if (npmResult.exitCode === 0) {
|
|
6448
|
-
result.removed.push("npm global package (@codedir/mimir-code)");
|
|
6449
|
-
if (!quiet) {
|
|
6450
|
-
logger.info("Successfully uninstalled npm package");
|
|
6451
|
-
}
|
|
6452
|
-
} else {
|
|
6453
|
-
throw new Error(`npm uninstall failed: ${npmResult.stderr}`);
|
|
6454
|
-
}
|
|
6455
|
-
} catch (error) {
|
|
6456
|
-
if (!quiet) {
|
|
6457
|
-
logger.error("Failed to uninstall npm package", { error });
|
|
6458
|
-
logger.info("Please run manually: npm uninstall -g @codedir/mimir-code");
|
|
6459
|
-
}
|
|
6460
|
-
result.errors.push(
|
|
6461
|
-
`npm uninstall failed: ${error instanceof Error ? error.message : String(error)}`
|
|
6462
|
-
);
|
|
6530
|
+
async removeNpmInstallation(_result, quiet = false) {
|
|
6531
|
+
if (!quiet) {
|
|
6532
|
+
logger.warn("Detected npm installation");
|
|
6533
|
+
logger.info("To uninstall, please run: npm uninstall -g @codedir/mimir-code");
|
|
6463
6534
|
}
|
|
6464
6535
|
}
|
|
6465
6536
|
async removeBinaryInstallation(homeDir, result, quiet = false) {
|
|
@@ -6603,12 +6674,22 @@ del /f /q "%~f0" >nul 2>&1
|
|
|
6603
6674
|
printSummary(result) {
|
|
6604
6675
|
console.log("");
|
|
6605
6676
|
console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
|
|
6606
|
-
if (result.
|
|
6677
|
+
if (result.isNpmInstall) {
|
|
6678
|
+
console.log("\u2139\uFE0F npm Installation Detected");
|
|
6679
|
+
} else if (result.success) {
|
|
6607
6680
|
console.log("\u2705 Mimir has been uninstalled");
|
|
6608
6681
|
} else {
|
|
6609
6682
|
console.log("\u274C Uninstall completed with errors");
|
|
6610
6683
|
}
|
|
6611
6684
|
console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
|
|
6685
|
+
if (result.isNpmInstall) {
|
|
6686
|
+
console.log("");
|
|
6687
|
+
console.log("To uninstall the npm package, run:");
|
|
6688
|
+
console.log(" npm uninstall -g @codedir/mimir-code");
|
|
6689
|
+
console.log("");
|
|
6690
|
+
console.log("or with yarn:");
|
|
6691
|
+
console.log(" yarn global remove @codedir/mimir-code");
|
|
6692
|
+
}
|
|
6612
6693
|
if (result.removed.length > 0) {
|
|
6613
6694
|
console.log("");
|
|
6614
6695
|
console.log("Removed:");
|
|
@@ -6619,9 +6700,14 @@ del /f /q "%~f0" >nul 2>&1
|
|
|
6619
6700
|
console.log("Configuration preserved:");
|
|
6620
6701
|
console.log(" - ~/.mimir/ (your settings and data)");
|
|
6621
6702
|
console.log("");
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6703
|
+
if (!result.isNpmInstall) {
|
|
6704
|
+
console.log("To remove it later, run:");
|
|
6705
|
+
console.log(" mimir uninstall --yes --remove-config");
|
|
6706
|
+
console.log(" or manually: rm -rf ~/.mimir");
|
|
6707
|
+
} else {
|
|
6708
|
+
console.log("Note: npm uninstall will not remove your configuration");
|
|
6709
|
+
console.log("To remove it manually: rm -rf ~/.mimir");
|
|
6710
|
+
}
|
|
6625
6711
|
}
|
|
6626
6712
|
if (result.errors.length > 0) {
|
|
6627
6713
|
console.log("");
|