@codedir/mimir-code 0.1.4 → 0.1.6
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 +133 -12
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -3908,7 +3908,9 @@ function locateWasmFile() {
|
|
|
3908
3908
|
const wasmFileName = "sql-wasm.wasm";
|
|
3909
3909
|
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
3910
3910
|
const nodeModulesPaths = [
|
|
3911
|
-
// Relative to the built module (dist/
|
|
3911
|
+
// Relative to the built module (bundled dist/cli.mjs)
|
|
3912
|
+
join(currentDir, "..", "node_modules", "sql.js", "dist", wasmFileName),
|
|
3913
|
+
// Relative to the built module (unbundled dist/storage/Database.js)
|
|
3912
3914
|
join(currentDir, "..", "..", "node_modules", "sql.js", "dist", wasmFileName),
|
|
3913
3915
|
// Relative to current working directory (for local development)
|
|
3914
3916
|
join(process.cwd(), "node_modules", "sql.js", "dist", wasmFileName)
|
|
@@ -4424,9 +4426,56 @@ var MimirInitializer = class {
|
|
|
4424
4426
|
this.fs = fs4;
|
|
4425
4427
|
this.configLoader = configLoader2;
|
|
4426
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
|
+
}
|
|
4427
4475
|
/**
|
|
4428
4476
|
* Initialize workspace with full Mimir setup
|
|
4429
4477
|
* Creates directories, database, config, and gitignore
|
|
4478
|
+
* This is for project-local configuration
|
|
4430
4479
|
*/
|
|
4431
4480
|
async initializeWorkspace(workspaceRoot) {
|
|
4432
4481
|
const result = {
|
|
@@ -4434,10 +4483,13 @@ var MimirInitializer = class {
|
|
|
4434
4483
|
created: [],
|
|
4435
4484
|
errors: [],
|
|
4436
4485
|
dbInitialized: false,
|
|
4437
|
-
configCreated: false
|
|
4486
|
+
configCreated: false,
|
|
4487
|
+
globalCreated: false,
|
|
4488
|
+
localCreated: false
|
|
4438
4489
|
};
|
|
4439
4490
|
try {
|
|
4440
4491
|
const mimirDir = path6.join(workspaceRoot, ".mimir");
|
|
4492
|
+
result.localCreated = true;
|
|
4441
4493
|
if (!await this.fs.exists(mimirDir)) {
|
|
4442
4494
|
await this.fs.mkdir(mimirDir, { recursive: true });
|
|
4443
4495
|
result.created.push(".mimir/");
|
|
@@ -4542,7 +4594,10 @@ checkpoints/
|
|
|
4542
4594
|
const executablePath = process.argv[0] || process.execPath;
|
|
4543
4595
|
const binaryDir = dirname2(executablePath);
|
|
4544
4596
|
const possibleSourceDirs = [
|
|
4545
|
-
// npm package: <package-root>/src/cli/themes/
|
|
4597
|
+
// npm package (bundled CLI): <package-root>/src/cli/themes/
|
|
4598
|
+
path6.join(currentDir, "../src/cli/themes"),
|
|
4599
|
+
// From dist/ -> src/cli/themes (bundled)
|
|
4600
|
+
// npm package (unbundled): <package-root>/src/cli/themes/
|
|
4546
4601
|
path6.join(currentDir, "../../src/cli/themes"),
|
|
4547
4602
|
// From dist/core/ -> src/cli/themes
|
|
4548
4603
|
// Development: dist/core/../cli/themes
|
|
@@ -4593,7 +4648,10 @@ checkpoints/
|
|
|
4593
4648
|
const executablePath = process.argv[0] || process.execPath;
|
|
4594
4649
|
const binaryDir = dirname2(executablePath);
|
|
4595
4650
|
const possibleSourceDirs = [
|
|
4596
|
-
// npm package: <package-root>/scripts/templates/commands/
|
|
4651
|
+
// npm package (bundled CLI): <package-root>/scripts/templates/commands/
|
|
4652
|
+
path6.join(currentDir, "../scripts/templates/commands"),
|
|
4653
|
+
// From dist/ -> scripts/templates/commands (bundled)
|
|
4654
|
+
// npm package (unbundled): <package-root>/scripts/templates/commands/
|
|
4597
4655
|
path6.join(currentDir, "../../scripts/templates/commands"),
|
|
4598
4656
|
// From dist/core/ -> scripts/templates/commands
|
|
4599
4657
|
// Development: dist/core/../../scripts/templates/commands
|
|
@@ -4658,10 +4716,14 @@ checkpoints/
|
|
|
4658
4716
|
result.errors.push("Database file was not created on disk");
|
|
4659
4717
|
}
|
|
4660
4718
|
} catch (error) {
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
);
|
|
4664
|
-
logger.error("Failed to initialize database", {
|
|
4719
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4720
|
+
const errorStack = error instanceof Error ? error.stack : void 0;
|
|
4721
|
+
result.errors.push(`Database initialization failed: ${errorMessage}`);
|
|
4722
|
+
logger.error("Failed to initialize database", {
|
|
4723
|
+
errorMessage,
|
|
4724
|
+
errorStack,
|
|
4725
|
+
errorType: error instanceof Error ? error.constructor.name : typeof error
|
|
4726
|
+
});
|
|
4665
4727
|
}
|
|
4666
4728
|
}
|
|
4667
4729
|
/**
|
|
@@ -6129,6 +6191,8 @@ Available providers: deepseek, anthropic`
|
|
|
6129
6191
|
};
|
|
6130
6192
|
|
|
6131
6193
|
// src/cli/commands/InitCommand.ts
|
|
6194
|
+
import { join as join2 } from "path";
|
|
6195
|
+
import { homedir } from "os";
|
|
6132
6196
|
var InitCommand = class {
|
|
6133
6197
|
initializer;
|
|
6134
6198
|
constructor(_fs, _configLoader) {
|
|
@@ -6136,24 +6200,81 @@ var InitCommand = class {
|
|
|
6136
6200
|
}
|
|
6137
6201
|
async execute(projectRoot, options = {}) {
|
|
6138
6202
|
const root = projectRoot || process.cwd();
|
|
6203
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || homedir();
|
|
6139
6204
|
if (!options.quiet) {
|
|
6140
|
-
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
|
+
});
|
|
6141
6212
|
}
|
|
6142
6213
|
if (await this.initializer.isWorkspaceInitialized(root)) {
|
|
6143
6214
|
if (!options.quiet) {
|
|
6144
6215
|
logger.info("Mimir workspace is already initialized in this directory.");
|
|
6145
6216
|
logger.info('Run "mimir" to start an interactive chat session.');
|
|
6146
6217
|
}
|
|
6218
|
+
if (globalResult.created.length > 0 && !options.quiet) {
|
|
6219
|
+
this.printGlobalSummary(globalResult, homeDir);
|
|
6220
|
+
}
|
|
6147
6221
|
return;
|
|
6148
6222
|
}
|
|
6149
|
-
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
|
+
};
|
|
6150
6231
|
if (!options.quiet) {
|
|
6151
|
-
this.
|
|
6232
|
+
this.printCombinedSummary(combinedResult, homeDir, root);
|
|
6152
6233
|
}
|
|
6153
|
-
if (!
|
|
6234
|
+
if (!globalResult.success || !localResult.success) {
|
|
6154
6235
|
process.exit(1);
|
|
6155
6236
|
}
|
|
6156
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
|
+
}
|
|
6157
6278
|
};
|
|
6158
6279
|
|
|
6159
6280
|
// src/cli/commands/UninstallCommand.ts
|