create-project-cortex-agent 1.0.0
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 +86 -0
- package/dist/cli.js +135 -0
- package/dist/utils/fileops.js +99 -0
- package/package.json +39 -0
- package/templates/.agents/rules/arch_hard_tech_stack.md +21 -0
- package/templates/.agents/workflows/init.md +12 -0
- package/templates/.agents/workflows/save-memory.md +19 -0
- package/templates/code/README.md +17 -0
- package/templates/memory/README.md +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# create-project-cortex-agent
|
|
2
|
+
|
|
3
|
+
A command-line tool to instantly initialize your workspace with the **Project Cortex** AI Agent directory structure.
|
|
4
|
+
|
|
5
|
+
This package bootstraps the foundational architecture needed for long-term AI-assisted development by preventing context degradation. It sets up strict boundaries, rules, and calendar-based memory logs for AI coding agents (such as Claude, Gemini, ChatGPT, or IDEs like Cursor and Copilot).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🚀 Installation & Usage
|
|
10
|
+
|
|
11
|
+
### Option 1: Using `npx` (Recommended)
|
|
12
|
+
If this package is published to npm, you don't need to install anything globally. You can run it directly:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Initialize into the current directory
|
|
16
|
+
npx create-project-cortex-agent .
|
|
17
|
+
|
|
18
|
+
# Initialize into a specific directory
|
|
19
|
+
npx create-project-cortex-agent ./my-new-project
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Option 2: Global Install
|
|
23
|
+
You can install the CLI globally and use it anywhere:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g create-project-cortex-agent
|
|
27
|
+
|
|
28
|
+
# Run the initialization
|
|
29
|
+
create-project-cortex-agent .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Option 3: Local Development (from source)
|
|
33
|
+
If you are developing this tool locally:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# 1. Clone the repository and navigate to this folder
|
|
37
|
+
cd create-project-cortex-agent
|
|
38
|
+
|
|
39
|
+
# 2. Install dependencies
|
|
40
|
+
npm install
|
|
41
|
+
|
|
42
|
+
# 3. Build the CLI
|
|
43
|
+
npm run build
|
|
44
|
+
|
|
45
|
+
# 4. Link or run directly via node
|
|
46
|
+
node dist/cli.js /path/to/target/project
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 📂 What it Scaffolds
|
|
52
|
+
|
|
53
|
+
The CLI safely injects the necessary constraints and guidelines into your repository without destroying existing source code. It sets up the following structure:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
├── .agents/
|
|
57
|
+
│ ├── rules/
|
|
58
|
+
│ │ └── arch_hard_tech_stack.md # Immutable tech stack rules for the AI
|
|
59
|
+
│ └── workflows/
|
|
60
|
+
│ ├── init.md # Workflow to start a new session
|
|
61
|
+
│ └── save-memory.md # Workflow template for memory operations
|
|
62
|
+
├── code/
|
|
63
|
+
│ └── README.md # Codebase operating rules for the AI
|
|
64
|
+
└── memory/
|
|
65
|
+
└── README.md # Instructions on calendar-based long-term memory
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## ⚙️ Post-Initialization (Next Steps)
|
|
71
|
+
|
|
72
|
+
After running the initializer, your project is ready for smart AI assistance, but you should take one final step:
|
|
73
|
+
|
|
74
|
+
1. **Configure Your Stack:** Open `.agents/rules/arch_hard_tech_stack.md` and define the strict technologies (Language, Framework, DB) your AI should stick to.
|
|
75
|
+
2. **Start Your Agent:** Whenever you start a *new* conversation window with your AI agent, you should trigger the initialization workflow so the agent loads up the necessary architectural context. You can do this by saying:
|
|
76
|
+
|
|
77
|
+
> "Run Cortex" / "hey cortex, lets start" / "hey cortex, lets continue"
|
|
78
|
+
|
|
79
|
+
*\*If your agent requires explicit file references (like Cursor), you can type `@init.md Run Cortex`.*
|
|
80
|
+
3. **Log Your Sessions:** Simply use natural language like "that's it for today", "we are done", or "see ya later" to trigger the chronological summary in the `memory/` logs!
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 🛠 Features
|
|
85
|
+
- **Idempotency**: Safe to run multiple times; it will not overwrite modified files if you already customized your configuration.
|
|
86
|
+
- **Git Awareness**: Warns you if the target directory doesn't have a git repository initialized yet.
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const commander_1 = require("commander");
|
|
41
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
42
|
+
const ora_1 = __importDefault(require("ora"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const fs = __importStar(require("fs-extra"));
|
|
45
|
+
const fileops_1 = require("./utils/fileops");
|
|
46
|
+
const program = new commander_1.Command();
|
|
47
|
+
program
|
|
48
|
+
.name('create-project-cortex-agent')
|
|
49
|
+
.description('Initializes a clean directory structure and deploy Markdown-based instruction files into an existing project.')
|
|
50
|
+
.version('1.0.0');
|
|
51
|
+
program
|
|
52
|
+
.argument('[target-directory]', 'The directory to initialize', '.')
|
|
53
|
+
.action(async (targetDirStr) => {
|
|
54
|
+
try {
|
|
55
|
+
const targetDir = path.resolve(targetDirStr);
|
|
56
|
+
console.log(`\nInitializing Project Cortex Agent Structure in: ${chalk_1.default.cyan(targetDir)}\n`);
|
|
57
|
+
// 1. Check Context
|
|
58
|
+
if (!(0, fileops_1.isGitRepo)(targetDir)) {
|
|
59
|
+
console.warn(chalk_1.default.yellow('⚠ Warning: The target directory does not appear to be inside a Git repository.'));
|
|
60
|
+
}
|
|
61
|
+
const spinner = (0, ora_1.default)('Creating directories...').start();
|
|
62
|
+
// 2. Ensure Directories
|
|
63
|
+
const dirs = [
|
|
64
|
+
path.join(targetDir, '.agents', 'rules'),
|
|
65
|
+
path.join(targetDir, '.agents', 'workflows'),
|
|
66
|
+
path.join(targetDir, 'code'),
|
|
67
|
+
];
|
|
68
|
+
for (const dir of dirs) {
|
|
69
|
+
await (0, fileops_1.ensureDirectory)(dir);
|
|
70
|
+
}
|
|
71
|
+
spinner.succeed('Directories created.');
|
|
72
|
+
// 3. Inject Markdown Files & Special Handling (Workflows)
|
|
73
|
+
const injectSpinner = (0, ora_1.default)('Injecting Markdown files...').start();
|
|
74
|
+
const __dirnameLocal = __dirname;
|
|
75
|
+
const templatesDir = path.join(__dirnameLocal, '..', 'templates');
|
|
76
|
+
// Defining the template mapping
|
|
77
|
+
const filesToInject = [
|
|
78
|
+
{
|
|
79
|
+
src: path.join(templatesDir, '.agents', 'rules', 'arch_hard_tech_stack.md'),
|
|
80
|
+
dest: path.join(targetDir, '.agents', 'rules', 'arch_hard_tech_stack.md')
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
src: path.join(templatesDir, '.agents', 'workflows', 'save-memory.md'),
|
|
84
|
+
dest: path.join(targetDir, '.agents', 'workflows', 'save-memory.md')
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
src: path.join(templatesDir, '.agents', 'workflows', 'init.md'),
|
|
88
|
+
dest: path.join(targetDir, '.agents', 'workflows', 'init.md')
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
src: path.join(templatesDir, 'memory', 'README.md'),
|
|
92
|
+
dest: path.join(targetDir, 'memory', 'README.md')
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
src: path.join(templatesDir, 'code', 'README.md'),
|
|
96
|
+
dest: path.join(targetDir, 'code', 'README.md')
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
injectSpinner.info('Checking for existing template files...');
|
|
100
|
+
let allSuccess = true;
|
|
101
|
+
for (const file of filesToInject) {
|
|
102
|
+
if (await fs.pathExists(file.src)) {
|
|
103
|
+
const copied = await (0, fileops_1.safeCopy)(file.src, file.dest);
|
|
104
|
+
if (copied) {
|
|
105
|
+
console.log(chalk_1.default.green(` ✔ Injected: ${path.relative(targetDir, file.dest)}`));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
allSuccess = false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
console.warn(chalk_1.default.yellow(` ⚠ Template missing in package: ${path.relative(templatesDir, file.src)}`));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (allSuccess) {
|
|
116
|
+
console.log(chalk_1.default.green('\n✔ Initialization Complete!'));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
console.log(chalk_1.default.yellow('\n⚠ Initialization Finished with skipped files.'));
|
|
120
|
+
}
|
|
121
|
+
// 4. Final Message
|
|
122
|
+
console.log();
|
|
123
|
+
console.log(chalk_1.default.green('Project Cortex Agent has been successfully initialized.'));
|
|
124
|
+
console.log();
|
|
125
|
+
console.log(chalk_1.default.yellow('Next Steps:'));
|
|
126
|
+
console.log(chalk_1.default.yellow(' 1. Initialize Antigravity in this project: ag init.'));
|
|
127
|
+
console.log(chalk_1.default.yellow(' 2. Edit .agents/rules/arch_hard_tech_stack.md to define your stack.'));
|
|
128
|
+
console.log(chalk_1.default.yellow(' 3. Enjoy!'));
|
|
129
|
+
console.log();
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
(0, fileops_1.handleError)(error);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.isGitRepo = isGitRepo;
|
|
40
|
+
exports.ensureDirectory = ensureDirectory;
|
|
41
|
+
exports.safeCopy = safeCopy;
|
|
42
|
+
exports.handleError = handleError;
|
|
43
|
+
const fs = __importStar(require("fs-extra"));
|
|
44
|
+
const child_process_1 = require("child_process");
|
|
45
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
46
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
47
|
+
/**
|
|
48
|
+
* Checks if the current directory is within a Git repository.
|
|
49
|
+
*/
|
|
50
|
+
function isGitRepo(targetDir) {
|
|
51
|
+
try {
|
|
52
|
+
(0, child_process_1.execSync)('git rev-parse --is-inside-work-tree', { stdio: 'ignore', cwd: targetDir });
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
catch (_a) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Ensures a directory exists, creating it if necessary.
|
|
61
|
+
*/
|
|
62
|
+
async function ensureDirectory(dirPath) {
|
|
63
|
+
await fs.ensureDir(dirPath);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Safely copies a template file to the target location.
|
|
67
|
+
* Prompts for confirmation if the file already exists.
|
|
68
|
+
*/
|
|
69
|
+
async function safeCopy(src, dest) {
|
|
70
|
+
if (await fs.pathExists(dest)) {
|
|
71
|
+
const { overwrite } = await inquirer_1.default.prompt([
|
|
72
|
+
{
|
|
73
|
+
type: 'confirm',
|
|
74
|
+
name: 'overwrite',
|
|
75
|
+
message: `File ${chalk_1.default.cyan(dest)} already exists. Overwrite?`,
|
|
76
|
+
default: false,
|
|
77
|
+
},
|
|
78
|
+
]);
|
|
79
|
+
if (!overwrite) {
|
|
80
|
+
console.log(chalk_1.default.yellow(`Skipped ${dest}`));
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
await fs.copy(src, dest);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Centralized error handler
|
|
89
|
+
*/
|
|
90
|
+
function handleError(error) {
|
|
91
|
+
console.error(chalk_1.default.red('\n✖ An error occurred during initialization:'));
|
|
92
|
+
if (error instanceof Error) {
|
|
93
|
+
console.error(chalk_1.default.red(error.message));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
console.error(chalk_1.default.red(String(error)));
|
|
97
|
+
}
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-project-cortex-agent",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI tool to initialize the Project Cortex agent directory structure and rules",
|
|
5
|
+
"main": "dist/cli.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-project-cortex-agent": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"start": "node dist/cli.js",
|
|
12
|
+
"prepublishOnly": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"templates"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"cli",
|
|
20
|
+
"project-cortex",
|
|
21
|
+
"agent",
|
|
22
|
+
"init"
|
|
23
|
+
],
|
|
24
|
+
"author": "Project Cortex",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"chalk": "^4.1.2",
|
|
28
|
+
"commander": "^11.1.0",
|
|
29
|
+
"fs-extra": "^11.2.0",
|
|
30
|
+
"inquirer": "^8.2.6",
|
|
31
|
+
"ora": "^5.4.1"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/fs-extra": "^11.0.4",
|
|
35
|
+
"@types/inquirer": "^8.2.10",
|
|
36
|
+
"@types/node": "^20.11.16",
|
|
37
|
+
"typescript": "^5.3.3"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# System Constraints & Architecture
|
|
2
|
+
|
|
3
|
+
> **Important: [AI-ONLY SYSTEM INSTRUCTION]**
|
|
4
|
+
> This file defines the immutable architectural rules, tech stack, and hard boundaries for Project Cortex.
|
|
5
|
+
> You MUST strictly adhere to these constraints in every task, code generation, and refactoring step. Do not alter these rules unless explicitly instructed by the human developer.
|
|
6
|
+
|
|
7
|
+
## 1. Core Tech Stack
|
|
8
|
+
* **Language:** [e.g., TypeScript strictly enforced. No generic `any` types.]
|
|
9
|
+
* **Framework:** [e.g., Next.js 14 with App Router.]
|
|
10
|
+
* **Styling:** [e.g., Tailwind CSS.]
|
|
11
|
+
* **Database/ORM:** [e.g., PostgreSQL with Prisma ORM.]
|
|
12
|
+
|
|
13
|
+
## 2. Hard Architectural Rules
|
|
14
|
+
* **Rule 1: Component Paradigms:** [e.g., Default to Server Components in Next.js. Only use `"use client"` when DOM manipulation or React lifecycle hooks are strictly required.]
|
|
15
|
+
* **Rule 2: State Management:** [e.g., Use React Context for localized state. Do not introduce Redux without permission.]
|
|
16
|
+
* **Rule 3: Error Handling:** [e.g., All external API calls must be wrapped in try/catch blocks with proper error logging. Never silently swallow errors.]
|
|
17
|
+
|
|
18
|
+
## 3. AI Operational Boundaries
|
|
19
|
+
* **Dependency Rule:** Before installing any new third-party library or package (via npm/yarn/pnpm/pip), you MUST explicitly ask the user for permission. Provide the package name, size, and rationale.
|
|
20
|
+
* **Destructive Actions:** Before running any commands that drop databases, delete non-temporary files, or force-push to git, you MUST halt and request human confirmation.
|
|
21
|
+
* **Decision Tracking:** If you and the human user agree on a fundamental shift in architecture or a new core library, you must immediately update this file to reflect the new state, and log the change in the daily `log_` file using the `[ADR]` tag.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Bootstraps the AI's context for a new coding session.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Initialization Workflow
|
|
6
|
+
|
|
7
|
+
When the human says something like "Run Cortex", "hey cortex, lets start", "hey cortex, lets continue", "hey, let's start a new session", "initialize", or directly referring to this file, you must strictly follow these steps before answering any other prompt or writing any code.
|
|
8
|
+
|
|
9
|
+
1. **Read System Rules:** Read the AI-only documentation in `memory/README.md`, `.agents/rules/arch_hard_tech_stack.md`, and `code/README.md`.
|
|
10
|
+
2. **Contextualize Memory:** Review the `memory/` directory to understand what was done in the previous session (read the most recent log or rolling summary).
|
|
11
|
+
3. **Check for Ghost Changes:** Check the state of the `code/` directory (e.g., using `git status` or `git diff`). If there are undocumented code changes that occurred after the last recorded memory log, you MUST retroactively create a `log_*.md` file summarizing those changes in the proper week's folder.
|
|
12
|
+
4. **Ready:** Acknowledge you have loaded the context and ask the user what they want to work on.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Trigger memory rollup on natural language '/save-memory' or 'thats it for today'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Save Memory Workflow
|
|
6
|
+
|
|
7
|
+
## Triggers
|
|
8
|
+
The user signals the end of a chat session using phrases like:
|
|
9
|
+
- `/save-memory`
|
|
10
|
+
- `thats it for today`
|
|
11
|
+
- `wrap it up`
|
|
12
|
+
- `see ya later`
|
|
13
|
+
|
|
14
|
+
## Execution
|
|
15
|
+
When the above intent is detected:
|
|
16
|
+
1. Generate an overview log of the current conversation.
|
|
17
|
+
2. Store this log inside `memory/` or update `.agents/rules/` if an architecture rule changed.
|
|
18
|
+
3. Archive older logs to ensure a maximum of 30 active files in the working directory.
|
|
19
|
+
4. Announce that the session memory has been effectively committed.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Codebase Operating Rules
|
|
2
|
+
|
|
3
|
+
> **Important: [AI-ONLY SYSTEM INSTRUCTION]**
|
|
4
|
+
> This file dictates how the AI agent should write, format, and manage code within the `code/` directory.
|
|
5
|
+
|
|
6
|
+
## 1. Coding Standards
|
|
7
|
+
* **Clean Code:** Write modular, highly cohesive, and loosely coupled code. Keep functions small and focused on a single responsibility.
|
|
8
|
+
* **No Dead Code:** Do not leave commented-out code blocks, unused variables, or `console.log` statements in final production files unless explicitly asked for debugging.
|
|
9
|
+
* **Self-Documenting:** Prefer descriptive variable and function names over inline comments. Write comments only to explain *why* something complex was done, not *what* the code does.
|
|
10
|
+
|
|
11
|
+
## 2. File Organization
|
|
12
|
+
* Keep the directory structure flat where possible, but group files by feature rather than type (e.g., `/features/auth/` instead of throwing everything into one massive `/components/` folder).
|
|
13
|
+
* Ensure all files follow a consistent naming convention (e.g., `kebab-case` for file names, `PascalCase` for React components).
|
|
14
|
+
|
|
15
|
+
## 3. Execution & Testing
|
|
16
|
+
* **Do Not Guess:** If a piece of code requires a specific environment variable or a database migration to run, you must inform the human user before considering the task complete.
|
|
17
|
+
* **Refactoring:** When modifying existing code, ensure you do not break the surrounding context. If in doubt, output the planned changes for human review before applying them directly to the file.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Memory Context
|
|
2
|
+
|
|
3
|
+
> **Important: [AI-ONLY SYSTEM INSTRUCTION]**
|
|
4
|
+
> This file establishes the operational requirements for AI agents managing the project's memory. Humans do not need to read or edit this file unless fundamentally changing the rules of the template.
|
|
5
|
+
> This folder stores conversation logs organized into a nested calendar structure, acting as the long-term memory for the AI.
|
|
6
|
+
|
|
7
|
+
## Folder Hierarchy
|
|
8
|
+
|
|
9
|
+
* **`.agents/rules/`**: Holds system constraints, architectural rules, and core states that bypass all standard archiving rules. These files are permanently kept.
|
|
10
|
+
* **`memory/[YYYY]/`**: The root folder for a given year.
|
|
11
|
+
* `year_[YYYY].md`: Annual summary of the months.
|
|
12
|
+
* **`[MM]/`**: Folder for the month (01 to 12).
|
|
13
|
+
* `month_[YYYY]-[MM].md`: Monthly summary of the weeks.
|
|
14
|
+
* **`W[WW]/`**: Folder for the week of the year (e.g., W14).
|
|
15
|
+
* `week_[YYYY]-W[WW].md`: Weekly summary of the days.
|
|
16
|
+
* `log_[YYYYMMDD]_[HHMM]_[Topic].md`: Up to 30 raw conversation logs for the active days inside this week.
|
|
17
|
+
|
|
18
|
+
## Rules & Processing
|
|
19
|
+
|
|
20
|
+
1. **Today (Raw Logs):** Current work is stored directly in the active week's folder (`W[WW]`). A maximum of 30 log files are kept at any time.
|
|
21
|
+
2. **Week (Summarization):** At the week's end, the active week's `log_` files are synthesized into `week_[YYYY]-W[WW].md` and the raw log files are deleted.
|
|
22
|
+
3. **Month (Summarization):** At the month's end, the `week_` summaries are synthesized into `month_[YYYY]-[MM].md`.
|
|
23
|
+
4. **Year (Summarization):** At the year's end, the `month_` summaries are synthesized into `year_[YYYY].md`.
|
|
24
|
+
5. **Overrides:** Files in `.agents/rules/` are permanently kept and NEVER summarized or deleted by the calendar cleanup process.
|
|
25
|
+
6. **Session Termination Trigger:** Whenever the human user uses natural language indicating the end of a session (e.g., "that's it for today", "we are done", "wrap it up", "see ya later"), you MUST automatically initiate the memory rollup process, generating the required summaries and `log_` files in the `memory/` directory.
|
|
26
|
+
7. **Auto-Recovery (Missing Logs):** If you are initialized in a new session and detect that the `code/` directory contains updates, new files, or Git changes that are NOT documented in the most recent `log_` or `week_` file, you must assume the previous session ended without a proper rollup. You MUST immediately analyze the undocumented code changes and generate a retroactive `log_` file summarizing them before proceeding with new human requests.
|
|
27
|
+
|
|
28
|
+
## Mandatory Formatting & Retention Rules
|
|
29
|
+
|
|
30
|
+
To prevent knowledge loss and context degradation during the summarization process, you MUST strictly adhere to the following rules:
|
|
31
|
+
|
|
32
|
+
* **Summary Structure:** All `week_`, `month_`, and `year_` summaries MUST be formatted using this exact Markdown structure:
|
|
33
|
+
* **Completed Goals:** High-level overview of what was built, fixed, or explored.
|
|
34
|
+
* **Technical Decisions:** Specific architectural choices, dependencies added/removed, or workarounds implemented (including the rationale).
|
|
35
|
+
* **Unresolved Issues & WIP:** Tasks started but not finished, known bugs, or blockers.
|
|
36
|
+
* **Context & Notes:** Any specific commands, environment variables, or quirks needed to run the current codebase.
|
|
37
|
+
* **Critical Retention Tags:** If a raw daily log or a lower-level summary contains the tag `[CRITICAL_DECISION]` or `[ADR]`, the exact text associated with that tag MUST be copied verbatim into the higher-level summaries. Do not paraphrase or compress these points.
|
|
38
|
+
* **Task Rollover:** Any incomplete tasks or open bugs mentioned in the active period MUST be explicitly listed under "Unresolved Issues & WIP" in the newly generated summary so the next AI session can immediately resume work.
|
|
39
|
+
* **Knowledge Extraction:** While summarizing at the end of a week/month, if a core architectural pattern, tech stack, or global rule has changed, you MUST automatically update the relevant files in `.agents/rules/` to reflect the current state of the project.
|