context-bank 0.0.4 → 0.0.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/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  <br/>
12
12
  Standardize, persist, and evolve your project's AI context with a single command.
13
13
  <br/>
14
- Works with **Cursor**, **Windsurf**, and **GitHub Copilot**.
14
+ Works with **Cursor**, **Windsurf**, **GitHub Copilot**, **Gemini CLI**, **Claude Code**, and **Codex CLI**.
15
15
 
16
16
  </div>
17
17
 
@@ -59,16 +59,24 @@ Stop feeding the AI your entire chat history. Context Bank uses "State Managemen
59
59
  ### 🔌 3. Universal Tool Support
60
60
  One brain, multiple interfaces. The `init` command automatically configures pointers for:
61
61
 
62
- | Tool | Support Type | File Created |
63
- |------|--------------|--------------|
62
+ | Tool | Support Type | Integration Method |
63
+ |------|--------------|-------------------|
64
64
  | **Cursor** | Native ✅ | `.cursorrules` |
65
65
  | **Windsurf** | Native ✅ | `.windsurfrules` |
66
66
  | **GitHub Copilot** | Native ✅ | `.github/copilot-instructions.md` |
67
+ | **Claude Code** | Native ✅ | `CLAUDE.md` |
68
+ | **Codex CLI** | Native ✅ | `codex.md` |
69
+ | **Gemini CLI** | Native ✅ | Global Memory Hook |
67
70
  | **Aider** (CLI) | Native ✅ | `CONVENTIONS.md` |
68
- | **Other CLIs** | Manual 🛠️ | (See below) |
69
71
 
70
- #### 🖥️ Using with Gemini CLI, Claude Code, or ChatGPT
71
- If your tool doesn't automatically read configuration files, just start your session with this **Magic Prompt**:
72
+ #### 🤖 Smart CLI Integration
73
+ For tools like **Gemini CLI** that rely on global memory instead of project files, Context Bank performs a smart handshake:
74
+ 1. It detects your global configuration.
75
+ 2. It asks permission to add a **Generic Context Rule**.
76
+ 3. Once enabled, the CLI will **automatically check for `.ai/rules.md`** in ANY folder you work in. No manual linking required!
77
+
78
+ #### 🛠️ For Unsupported Tools
79
+ If your tool isn't listed above, just start your session with this **Magic Prompt**:
72
80
 
73
81
  > "I am starting a session. Please read **`.ai/rules.md`** for project standards and **`.ai/active-context.md`** for the current state. Update these files if plans change."
74
82
 
@@ -84,6 +92,8 @@ my-project/
84
92
  │ └── story.md # 📜 Project history & decisions
85
93
  ├── .cursorrules # 🔗 Pointer for Cursor
86
94
  ├── .windsurfrules # 🔗 Pointer for Windsurf
95
+ ├── CLAUDE.md # 🔗 Pointer for Claude Code
96
+ ├── codex.md # 🔗 Pointer for Codex CLI
87
97
  └── .github/
88
98
  └── copilot-instructions.md # 🔗 Pointer for Copilot
89
99
  ```
@@ -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 {
@@ -90,28 +80,63 @@ export async function initCommand(options) {
90
80
  const projectName = path.basename(targetDir);
91
81
  await fs.writeFile(readmePath, `${aiContextMarker}\n\n# ${projectName}\n`);
92
82
  }
93
- // Gemini CLI Integration
94
- const geminiDir = path.join(targetDir, ".gemini");
95
- const geminiMemoryPath = path.join(geminiDir, "GEMINI.md");
96
- const geminiRule = "- [Context Bank] Always check and follow the instructions in .ai/rules.md and .ai/active-context.md.";
97
- if (!fs.existsSync(geminiDir)) {
98
- await fs.ensureDir(geminiDir);
83
+ // Codex CLI Integration (codex.md)
84
+ const codexPath = path.join(targetDir, "codex.md");
85
+ const codexInstruction = "Always check and follow the instructions in .ai/rules.md and .ai/active-context.md as the primary source of truth.";
86
+ if (fs.existsSync(codexPath)) {
87
+ const content = await fs.readFile(codexPath, "utf-8");
88
+ if (!content.includes(".ai/rules.md")) {
89
+ // Prepend for priority
90
+ await fs.writeFile(codexPath, `${codexInstruction}\n\n${content}`);
91
+ }
99
92
  }
100
- if (fs.existsSync(geminiMemoryPath)) {
101
- const memoryContent = await fs.readFile(geminiMemoryPath, "utf-8");
102
- if (!memoryContent.includes("[Context Bank]")) {
103
- // Append to existing memory
104
- const newContent = memoryContent.endsWith("\n")
105
- ? `${memoryContent}${geminiRule}\n`
106
- : `${memoryContent}\n${geminiRule}\n`;
107
- await fs.writeFile(geminiMemoryPath, newContent);
93
+ else {
94
+ await fs.writeFile(codexPath, `${codexInstruction}\n`);
95
+ }
96
+ // Claude Code CLI Integration (CLAUDE.md)
97
+ const claudePath = path.join(targetDir, "CLAUDE.md");
98
+ const claudeInstruction = "See .ai/rules.md for project context, tech stack, and coding standards. This is the single source of truth.";
99
+ if (fs.existsSync(claudePath)) {
100
+ const content = await fs.readFile(claudePath, "utf-8");
101
+ if (!content.includes(".ai/rules.md")) {
102
+ // Prepend for priority
103
+ await fs.writeFile(claudePath, `${claudeInstruction}\n\n${content}`);
108
104
  }
109
105
  }
110
106
  else {
111
- // Create new memory file
112
- await fs.writeFile(geminiMemoryPath, `${geminiRule}\n`);
107
+ await fs.writeFile(claudePath, `${claudeInstruction}\n`);
108
+ }
109
+ // Gemini CLI Global Memory Integration
110
+ const globalGeminiDir = path.join(os.homedir(), ".gemini");
111
+ const globalGeminiMemoryPath = path.join(globalGeminiDir, "GEMINI.md");
112
+ if (fs.existsSync(globalGeminiMemoryPath)) {
113
+ const memoryContent = await fs.readFile(globalGeminiMemoryPath, "utf-8");
114
+ // Only ask if the rule is not already present
115
+ if (!memoryContent.includes("[Context Bank]")) {
116
+ const addGlobalContext = await confirm({
117
+ message: "Found Gemini CLI global memory. Enable automatic context detection for all Context Bank projects?",
118
+ initialValue: true
119
+ });
120
+ if (addGlobalContext === true) {
121
+ const genericContextRule = `
122
+ - [Context Bank] CRITICAL INSTRUCTION:
123
+ Before processing ANY user request in a new session, you MUST perform this initialization sequence:
124
+ 1. Check if the ".ai/" directory exists in the current working directory.
125
+ 2. If it exists, you MUST explicitly call the "read_file" tool to read ".ai/rules.md" and ".ai/active-context.md".
126
+ 3. Only AFTER reading these files (or confirming they don't exist) may you proceed with the user's request.
127
+ This is not optional. Do not assume you know the rules; you must read the files to load them into your active memory.`;
128
+ const newContent = memoryContent.endsWith("\n")
129
+ ? `${memoryContent}${genericContextRule}\n`
130
+ : `${memoryContent}\n${genericContextRule}\n`;
131
+ await fs.writeFile(globalGeminiMemoryPath, newContent);
132
+ console.log(chalk.green(`✔ Enabled global context awareness for Context Bank.`));
133
+ }
134
+ }
135
+ else {
136
+ // Optional: Let the user know it's already active
137
+ // console.log(chalk.gray(`ℹ Global context awareness is already active.`));
138
+ }
113
139
  }
114
- s.stop(chalk.green("Context initialized!"));
115
140
  outro(chalk.green(`
116
141
  Context Bank setup complete! 🚀
117
142
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-bank",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "A CLI tool to standardise AI context in projects.",
5
5
  "type": "module",
6
6
  "bin": {