context-bank 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kadir Esen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # 🏦 Context Bank
2
+
3
+ > **The `git init` for AI Context.**
4
+ > Standardize, persist, and evolve your project's AI context with a single command.
5
+
6
+ ![License](https://img.shields.io/npm/l/context-bank)
7
+ ![Version](https://img.shields.io/npm/v/context-bank)
8
+
9
+ ## ⚡ The Problem
10
+ Every time you start a new chat with an AI (Cursor, Windsurf, Copilot), you face the same issues:
11
+ 1. **Amnesia:** You have to re-explain the tech stack and coding rules.
12
+ 2. **Token Waste:** Pasting huge context files burns through your token limit and money.
13
+ 3. **Inconsistency:** `Cursor` follows one rule, `Copilot` follows another.
14
+
15
+ ## 🚀 The Solution
16
+ **Context Bank** creates a standardized, self-evolving brain for your project.
17
+
18
+ Run one command:
19
+ ```bash
20
+ npx context-bank init
21
+ ```
22
+
23
+ And get a fully configured `.ai` environment that works across **Cursor**, **Windsurf**, and **GitHub Copilot**.
24
+
25
+ ## ✨ Key Features
26
+
27
+ ### 1. 🧠 Self-Evolving Rules (The "Living" Standard)
28
+ Instead of static rules, Context Bank sets up a **Single Source of Truth** (`.ai/rules.md`).
29
+ - The AI is instructed to **update this file itself** when you change a preference.
30
+ - *Example:* You tell the AI "Don't use `any`". The AI updates `rules.md`. Next time, it remembers.
31
+
32
+ ### 2. 💾 Smart Memory & Token Saving
33
+ **Stop reading the entire chat history.**
34
+ Context Bank introduces a "State Management" system for your AI:
35
+ - **`.ai/active-context.md` (Short-term Memory):** Keeps track of *current* tasks.
36
+ - *Benefit:* You can delete your chat history to save tokens, start a fresh session, and the AI knows exactly where it left off by reading this 20-line file instead of a 10k token history.
37
+ - **`.ai/story.md` (Long-term Memory):** logs major milestones and architectural decisions.
38
+
39
+ ### 3. 🔌 Tool Agnostic
40
+ Whether you switch from Cursor to Windsurf, or use Copilot in VS Code, they all share the same brain.
41
+ - Generates `.cursorrules` pointing to the master rules.
42
+ - Generates `.windsurfrules` pointing to the master rules.
43
+ - Generates `.github/copilot-instructions.md` pointing to the master rules.
44
+
45
+ ## 🛠 Usage
46
+
47
+ 1. **Go to your project root:**
48
+ ```bash
49
+ cd my-awesome-project
50
+ ```
51
+
52
+ 2. **Initialize the bank:**
53
+ ```bash
54
+ npx context-bank init
55
+ ```
56
+
57
+ 3. **That's it!**
58
+ You will see a new `.ai/` directory.
59
+ - **Edit `.ai/rules.md`** initially to set your stack (e.g., "React, Tailwind").
60
+ - **Start coding.** Your AI is now context-aware.
61
+
62
+ ## 📂 File Structure
63
+
64
+ ```text
65
+ .
66
+ ├── .ai/
67
+ │ ├── rules.md # The Master Brain. SSOT for all rules.
68
+ │ ├── active-context.md # Current focus. "What are we doing now?"
69
+ │ └── story.md # Project history. "What have we done?"
70
+ ├── .cursorrules # Pointer for Cursor AI
71
+ ├── .windsurfrules # Pointer for Windsurf IDE
72
+ └── .github/
73
+ └── copilot-instructions.md # Pointer for GitHub Copilot
74
+ ```
75
+
76
+ ## 🤝 Contributing
77
+ Contributions are welcome! Please feel free to submit a Pull Request.
78
+
79
+ ## 📄 License
80
+ ISC
@@ -0,0 +1,89 @@
1
+ import { intro, outro, confirm, spinner } from "@clack/prompts";
2
+ import fs from "fs-extra";
3
+ import path from "path";
4
+ import { fileURLToPath } from "url";
5
+ import chalk from "chalk";
6
+ // Get __dirname equivalent in ESM
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+ export async function initCommand(options) {
10
+ intro(chalk.bgCyan(chalk.black(" Context Bank ")));
11
+ let proceed = options.yes;
12
+ if (!proceed) {
13
+ const response = await confirm({
14
+ message: "Do you want to initialize AI context in this project?",
15
+ });
16
+ if (typeof response === "boolean") {
17
+ proceed = response;
18
+ }
19
+ else {
20
+ // Handle cancellation (ctrl+c) which returns symbol or strictly check boolean
21
+ proceed = false;
22
+ }
23
+ }
24
+ if (!proceed) {
25
+ outro("Operation cancelled.");
26
+ process.exit(0);
27
+ }
28
+ // 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
+ const templateDir = path.resolve(__dirname, "../../templates");
33
+ const targetDir = process.cwd();
34
+ const s = spinner();
35
+ s.start("Analyzing project structure...");
36
+ // Check if templates exist
37
+ if (!fs.existsSync(templateDir)) {
38
+ s.stop("Error");
39
+ console.error(chalk.red(`\nTemplate directory not found at: ${templateDir}`));
40
+ console.error(chalk.yellow("Ensure you are running this from the package root or the package is built correctly."));
41
+ process.exit(1);
42
+ }
43
+ s.message("Copying context files...");
44
+ try {
45
+ // List of files/folders to copy
46
+ const itemsToCopy = [".ai", ".cursorrules", ".windsurfrules", ".github"];
47
+ for (const item of itemsToCopy) {
48
+ const srcPath = path.join(templateDir, item);
49
+ const destPath = path.join(targetDir, item);
50
+ if (fs.existsSync(srcPath)) {
51
+ // Check if destination exists
52
+ if (fs.existsSync(destPath)) {
53
+ // For now, we skip existing files to be safe, or we could ask.
54
+ // Let's just overwrite for MVP or maybe log it.
55
+ // A better UX would be to ask, but let's stick to simple first.
56
+ // We will use overwrite=false logic effectively by checking existence.
57
+ // Actually, let's just copy and overwrite for now as this is "init",
58
+ // but maybe backup?
59
+ // Let's stick to standard "copy" behavior (overwrite).
60
+ await fs.copy(srcPath, destPath, { overwrite: true });
61
+ }
62
+ else {
63
+ await fs.copy(srcPath, destPath);
64
+ }
65
+ }
66
+ }
67
+ // Special handling for story.md date
68
+ const storyPath = path.join(targetDir, ".ai/story.md");
69
+ if (fs.existsSync(storyPath)) {
70
+ let storyContent = await fs.readFile(storyPath, "utf-8");
71
+ storyContent = storyContent.replace("[Auto-filled by init]", new Date().toISOString().split("T")[0]);
72
+ await fs.writeFile(storyPath, storyContent);
73
+ }
74
+ s.stop(chalk.green("Context initialized!"));
75
+ outro(chalk.green(`
76
+ Context Bank setup complete! 🚀
77
+
78
+ Next steps:
79
+ 1. Review .ai/rules.md and fill in your project details.
80
+ 2. Update .ai/active-context.md with your current task.
81
+ 3. Commit the new files to git.
82
+ `));
83
+ }
84
+ catch (error) {
85
+ s.stop("Error");
86
+ console.error(chalk.red("Failed to copy files:"), error);
87
+ process.exit(1);
88
+ }
89
+ }
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { initCommand } from "./commands/init.js";
4
+ import fs from "fs-extra";
5
+ import path from "path";
6
+ import { fileURLToPath } from "url";
7
+ const program = new Command();
8
+ // Read package.json to get version
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+ const packageJson = fs.readJsonSync(path.join(__dirname, "../package.json"));
11
+ program
12
+ .name("context-bank")
13
+ .description("CLI to standardize AI context in projects")
14
+ .version(packageJson.version);
15
+ program
16
+ .command("init")
17
+ .description("Initialize AI context files in the current directory")
18
+ .option("-y, --yes", "Skip confirmation prompt")
19
+ .action(initCommand);
20
+ program.parse(process.argv);
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "context-bank",
3
+ "version": "0.0.1",
4
+ "description": "A CLI tool to standardise AI context in projects.",
5
+ "type": "module",
6
+ "bin": {
7
+ "context-bank": "./dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "dev": "ts-node src/index.ts",
12
+ "start": "node dist/index.js",
13
+ "lint": "eslint src/**/*.ts",
14
+ "format": "prettier --write ."
15
+ },
16
+ "keywords": [
17
+ "cli",
18
+ "ai",
19
+ "context",
20
+ "developer-tools"
21
+ ],
22
+ "files": [
23
+ "dist",
24
+ "templates"
25
+ ],
26
+ "author": "",
27
+ "license": "MIT",
28
+ "dependencies": {
29
+ "@clack/prompts": "^0.7.0",
30
+ "chalk": "^5.3.0",
31
+ "commander": "^12.0.0",
32
+ "fs-extra": "^11.2.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/fs-extra": "^11.0.4",
36
+ "@types/node": "^20.11.0",
37
+ "ts-node": "^10.9.2",
38
+ "typescript": "^5.3.3"
39
+ }
40
+ }
@@ -0,0 +1,23 @@
1
+ # 🚀 Active Context & Current State
2
+
3
+ > **AI AGENT INSTRUCTION:**
4
+ > This file contains the **current focus** of the project.
5
+ > **Update this file** at the end of every significant task or session.
6
+ > When starting a new session, **READ THIS FIRST** to understand where we left off.
7
+
8
+ ## 🎯 Current Focus
9
+ *What are we working on right now? (e.g., "Implementing the Auth system", "Refactoring the API")*
10
+
11
+ - [ ] Task 1
12
+ - [ ] Task 2
13
+
14
+ ## 🔄 Recent Changes
15
+ *Briefly list what was just completed.*
16
+ - ...
17
+
18
+ ## 🚧 Known Issues / Blockers
19
+ - ...
20
+
21
+ ## 🔜 Next Steps
22
+ *What should happen immediately after the current task?*
23
+ - ...
@@ -0,0 +1,44 @@
1
+ # 🧠 Project Context & Rules (Master File)
2
+
3
+ > **AI AGENT INSTRUCTION (CRITICAL):**
4
+ > This file is your **Long-Term Memory**. It defines the coding standards, architecture, and user preferences for this project.
5
+ >
6
+ > **YOUR CORE MISSION: SELF-EVOLUTION & MEMORY MANAGEMENT**
7
+ > You are responsible for keeping this `.ai/` directory up-to-date.
8
+ >
9
+ > 1. **Capture Preferences:** If the user specifies a preference, update **`rules.md`**.
10
+ > 2. **Track Progress:** At the end of a task, update **`active-context.md`** with the current status and next steps.
11
+ > 3. **Log History:** When a major milestone is reached, append it to **`story.md`**.
12
+ >
13
+ > **TOKEN SAVING STRATEGY:**
14
+ > Do not rely on chat history for long-term memory. Rely on these files.
15
+ > If the user starts a new chat, you should be able to resume work instantly by reading `active-context.md`.
16
+ >
17
+ > ---
18
+
19
+ ## 🏢 Project Overview
20
+ *Replace this with a 1-sentence description of the project.*
21
+
22
+ ## 🛠 Tech Stack
23
+ - **Language:** [e.g., TypeScript, Python, Go]
24
+ - **Framework:** [e.g., React, Django, Laravel]
25
+ - **Database:** [e.g., PostgreSQL, MongoDB]
26
+ - **Tools:** [e.g., Docker, PNPM, Vite]
27
+
28
+ ## 📏 Coding Standards (Mutable)
29
+ *AI: Update this section based on user feedback.*
30
+
31
+ - **General:** Write clean, modular, and robust code.
32
+ - **Comments:** Explain "why", not "what".
33
+ - **Error Handling:** Fail gracefully and log errors.
34
+ - [AI: Add new rules here...]
35
+
36
+ ## 🏗 Architecture Patterns
37
+ *AI: Update this section as the architecture evolves.*
38
+
39
+ - [e.g., "Use Feature-Sliced Design"]
40
+ - [e.g., "Service Repository Pattern"]
41
+
42
+ ## 📝 Workflow & Git
43
+ - **Commits:** Use Conventional Commits (feat: ..., fix: ...).
44
+ - **Branches:** feature/name-of-feature.
@@ -0,0 +1,20 @@
1
+ # 📜 Project Story & Decisions Log
2
+
3
+ > **AI AGENT INSTRUCTION:**
4
+ > This file records the **history and evolution** of the project.
5
+ > append to this file when:
6
+ > 1. A major feature is completed.
7
+ > 2. A significant architectural decision is made (ADR).
8
+ > 3. The user clarifies the long-term vision.
9
+
10
+ ## 📅 Project Inception
11
+ - **Date:** [Auto-filled by init]
12
+ - **Vision:** [Initial project goal]
13
+
14
+ ## 🪵 Development Log
15
+
16
+ ### [Date] - Phase 1: Initialization
17
+ - Project structure created.
18
+ - Basic configuration files added.
19
+
20
+ *(AI: Append new major events below...)*
@@ -0,0 +1,13 @@
1
+ You are an expert AI software engineer.
2
+
3
+ # CRITICAL CONTEXT SOURCE
4
+ You MUST read and follow the rules defined in **`.ai/rules.md`**.
5
+ That file contains the single source of truth for:
6
+ 1. Tech Stack
7
+ 2. Coding Standards
8
+ 3. Architecture
9
+ 4. **Your instruction to update rules when they change.**
10
+
11
+ If you cannot read `.ai/rules.md` automatically, ask the user to provide it, or check the file system.
12
+
13
+ When the user gives you a new constraint, **UPDATE `.ai/rules.md`**, not this file.
@@ -0,0 +1,9 @@
1
+ # GitHub Copilot Instructions
2
+
3
+ You are an expert developer assisting with this project.
4
+
5
+ ## Context & Rules
6
+ Please refer to **`.ai/rules.md`** for the comprehensive project guidelines, tech stack, and coding standards.
7
+
8
+ ## Memory Update
9
+ If the user establishes a new convention (e.g., "We only use functional components"), please suggest an update to `.ai/rules.md` to persist this rule.
@@ -0,0 +1,8 @@
1
+ You are Windsurf, an expert AI coding assistant.
2
+
3
+ # PRIMARY DIRECTIVE
4
+ Your configuration and behavioral rules are stored in **`.ai/rules.md`**.
5
+ Always prioritize the instructions found in that file.
6
+
7
+ # SELF-IMPROVEMENT
8
+ If the user provides a new coding rule or preference during this session, use your file editing capabilities to update **`.ai/rules.md`** so that the preference is remembered for future sessions.