context-bank 0.0.3 → 0.0.5
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/commands/init.js +26 -11
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { intro, outro, confirm, spinner } from "@clack/prompts";
|
|
2
2
|
import fs from "fs-extra";
|
|
3
3
|
import path from "path";
|
|
4
|
+
import os from "os";
|
|
4
5
|
import { fileURLToPath } from "url";
|
|
5
6
|
import chalk from "chalk";
|
|
6
7
|
// Get __dirname equivalent in ESM
|
|
@@ -26,9 +27,6 @@ export async function initCommand(options) {
|
|
|
26
27
|
process.exit(0);
|
|
27
28
|
}
|
|
28
29
|
// Determine paths
|
|
29
|
-
// When running from source (ts-node), templates are in ../../templates
|
|
30
|
-
// When running from dist (node), templates are in ../../templates (copied during build)
|
|
31
|
-
// We need to ensure templates are included in the build or package.
|
|
32
30
|
const templateDir = path.resolve(__dirname, "../../templates");
|
|
33
31
|
const targetDir = process.cwd();
|
|
34
32
|
const s = spinner();
|
|
@@ -54,15 +52,7 @@ export async function initCommand(options) {
|
|
|
54
52
|
const srcPath = path.join(templateDir, item);
|
|
55
53
|
const destPath = path.join(targetDir, item);
|
|
56
54
|
if (fs.existsSync(srcPath)) {
|
|
57
|
-
// Check if destination exists
|
|
58
55
|
if (fs.existsSync(destPath)) {
|
|
59
|
-
// For now, we skip existing files to be safe, or we could ask.
|
|
60
|
-
// Let's just overwrite for MVP or maybe log it.
|
|
61
|
-
// A better UX would be to ask, but let's stick to simple first.
|
|
62
|
-
// We will use overwrite=false logic effectively by checking existence.
|
|
63
|
-
// Actually, let's just copy and overwrite for now as this is "init",
|
|
64
|
-
// but maybe backup?
|
|
65
|
-
// Let's stick to standard "copy" behavior (overwrite).
|
|
66
56
|
await fs.copy(srcPath, destPath, { overwrite: true });
|
|
67
57
|
}
|
|
68
58
|
else {
|
|
@@ -91,6 +81,31 @@ export async function initCommand(options) {
|
|
|
91
81
|
await fs.writeFile(readmePath, `${aiContextMarker}\n\n# ${projectName}\n`);
|
|
92
82
|
}
|
|
93
83
|
s.stop(chalk.green("Context initialized!"));
|
|
84
|
+
// Gemini CLI Global Memory Integration
|
|
85
|
+
const globalGeminiDir = path.join(os.homedir(), ".gemini");
|
|
86
|
+
const globalGeminiMemoryPath = path.join(globalGeminiDir, "GEMINI.md");
|
|
87
|
+
if (fs.existsSync(globalGeminiMemoryPath)) {
|
|
88
|
+
const memoryContent = await fs.readFile(globalGeminiMemoryPath, "utf-8");
|
|
89
|
+
// Only ask if the rule is not already present
|
|
90
|
+
if (!memoryContent.includes("[Context Bank]")) {
|
|
91
|
+
const addGlobalContext = await confirm({
|
|
92
|
+
message: "Found Gemini CLI global memory. Enable automatic context detection for all Context Bank projects?",
|
|
93
|
+
initialValue: true
|
|
94
|
+
});
|
|
95
|
+
if (addGlobalContext === true) {
|
|
96
|
+
const genericContextRule = "- [Context Bank] Always check the current working directory for '.ai/rules.md' and '.ai/active-context.md'. If they exist, follow their instructions as the primary source of truth.";
|
|
97
|
+
const newContent = memoryContent.endsWith("\n")
|
|
98
|
+
? `${memoryContent}${genericContextRule}\n`
|
|
99
|
+
: `${memoryContent}\n${genericContextRule}\n`;
|
|
100
|
+
await fs.writeFile(globalGeminiMemoryPath, newContent);
|
|
101
|
+
console.log(chalk.green(`✔ Enabled global context awareness for Context Bank.`));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// Optional: Let the user know it's already active
|
|
106
|
+
// console.log(chalk.gray(`ℹ Global context awareness is already active.`));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
94
109
|
outro(chalk.green(`
|
|
95
110
|
Context Bank setup complete! 🚀
|
|
96
111
|
|