cortex-kit 1.0.0 → 1.1.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 CHANGED
@@ -34,6 +34,17 @@ cd my-awesome-project
34
34
  npx cortex-kit init .
35
35
  ```
36
36
 
37
+ ### Enable AI features in an existing project
38
+ ```bash
39
+ cd your-existing-project
40
+ npx cortex-kit enable
41
+ ```
42
+
43
+ The `enable` command is perfect for adding AI context to existing projects:
44
+ - Skips `AGENTS.md` if it already exists
45
+ - Appends AI setup section to existing `README.md` (or creates new one)
46
+ - Always creates `CLAUDE.md` and `docs/` directory
47
+
37
48
  ## What Gets Generated
38
49
 
39
50
  - `AGENTS.md` - Project context for AI coding agents (workflows, testing, conventions)
@@ -66,3 +77,27 @@ Learn more: [agents.md](https://agents.md/)
66
77
  ## License
67
78
 
68
79
  MIT
80
+
81
+
82
+ ---
83
+
84
+ ## AI-Native Development
85
+
86
+ This project is configured for AI-native development with AI coding assistants.
87
+
88
+ ### AI Configuration Files
89
+
90
+ - **AGENTS.md**: Project context and conventions for AI coding agents (Claude Code, GitHub Copilot, Cursor, etc.)
91
+ - **CLAUDE.md**: Reference file that points Claude Code to AGENTS.md
92
+
93
+ ### Working with AI Assistants
94
+
95
+ AI coding assistants will automatically read `AGENTS.md` to understand:
96
+ - How to build and test your project
97
+ - Code quality standards to follow
98
+ - Testing requirements
99
+ - Documentation expectations
100
+
101
+ Customize `AGENTS.md` with your project-specific build commands, test commands, and conventions.
102
+
103
+ Generated with [cortex-kit](https://www.npmjs.com/package/cortex-kit)
package/bin/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { init } from '../src/index.js';
3
+ import { init, enable } from '../src/index.js';
4
4
 
5
5
  // Parse command line arguments
6
6
  const args = process.argv.slice(2);
@@ -12,18 +12,23 @@ if (!command) {
12
12
  console.error('Error: No command provided');
13
13
  console.log('Usage: cortex-kit init [project-name]');
14
14
  console.log(' cortex-kit init . (for current directory)');
15
+ console.log(' cortex-kit enable (enable AI features in existing project)');
15
16
  process.exit(1);
16
17
  }
17
18
 
18
- if (command !== 'init') {
19
+ if (command !== 'init' && command !== 'enable') {
19
20
  console.error(`Error: Unknown command "${command}"`);
20
- console.log('Available commands: init');
21
+ console.log('Available commands: init, enable');
21
22
  process.exit(1);
22
23
  }
23
24
 
24
- // Execute init command
25
+ // Execute command
25
26
  try {
26
- await init(projectName);
27
+ if (command === 'init') {
28
+ await init(projectName);
29
+ } else if (command === 'enable') {
30
+ await enable();
31
+ }
27
32
  } catch (error) {
28
33
  console.error('Error:', error.message);
29
34
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortex-kit",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "CLI tool that scaffolds AI-native projects with AGENTS.md specifications",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/generator.js CHANGED
@@ -1,4 +1,4 @@
1
- import { writeFile, readFile } from 'fs/promises';
1
+ import { writeFile, readFile, access, appendFile } from 'fs/promises';
2
2
  import { join, dirname } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
 
@@ -29,3 +29,84 @@ export async function generateFiles(targetDir) {
29
29
  }
30
30
  }
31
31
  }
32
+
33
+ /**
34
+ * Check if a file exists
35
+ * @param {string} filePath - Path to check
36
+ * @returns {Promise<boolean>} - True if file exists
37
+ */
38
+ async function fileExists(filePath) {
39
+ try {
40
+ await access(filePath);
41
+ return true;
42
+ } catch {
43
+ return false;
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Enable AI features in existing project
49
+ * @param {string} targetDir - Target directory path
50
+ */
51
+ export async function enableFiles(targetDir) {
52
+ // Check if AGENTS.md exists
53
+ const agentsPath = join(targetDir, 'AGENTS.md');
54
+ const agentsExists = await fileExists(agentsPath);
55
+
56
+ if (agentsExists) {
57
+ console.log('⊘ Skipped AGENTS.md (already exists)');
58
+ } else {
59
+ const templatePath = join(__dirname, 'templates', 'AGENTS.md');
60
+ const content = await readFile(templatePath, 'utf-8');
61
+ await writeFile(agentsPath, content, 'utf-8');
62
+ console.log('✓ Generated AGENTS.md');
63
+ }
64
+
65
+ // Always create CLAUDE.md
66
+ const claudePath = join(targetDir, 'CLAUDE.md');
67
+ const claudeTemplatePath = join(__dirname, 'templates', 'CLAUDE.md');
68
+ const claudeContent = await readFile(claudeTemplatePath, 'utf-8');
69
+ await writeFile(claudePath, claudeContent, 'utf-8');
70
+ console.log('✓ Generated CLAUDE.md');
71
+
72
+ // Check if README.md exists
73
+ const readmePath = join(targetDir, 'README.md');
74
+ const readmeExists = await fileExists(readmePath);
75
+
76
+ if (readmeExists) {
77
+ // Append AI setup section to existing README
78
+ const aiSection = `
79
+
80
+ ---
81
+
82
+ ## AI-Native Development
83
+
84
+ This project is configured for AI-native development with AI coding assistants.
85
+
86
+ ### AI Configuration Files
87
+
88
+ - **AGENTS.md**: Project context and conventions for AI coding agents (Claude Code, GitHub Copilot, Cursor, etc.)
89
+ - **CLAUDE.md**: Reference file that points Claude Code to AGENTS.md
90
+
91
+ ### Working with AI Assistants
92
+
93
+ AI coding assistants will automatically read \`AGENTS.md\` to understand:
94
+ - How to build and test your project
95
+ - Code quality standards to follow
96
+ - Testing requirements
97
+ - Documentation expectations
98
+
99
+ Customize \`AGENTS.md\` with your project-specific build commands, test commands, and conventions.
100
+
101
+ Generated with [cortex-kit](https://www.npmjs.com/package/cortex-kit)
102
+ `;
103
+ await appendFile(readmePath, aiSection, 'utf-8');
104
+ console.log('✓ Appended AI setup section to README.md');
105
+ } else {
106
+ // Create new README.md
107
+ const readmeTemplatePath = join(__dirname, 'templates', 'README.md');
108
+ const readmeContent = await readFile(readmeTemplatePath, 'utf-8');
109
+ await writeFile(readmePath, readmeContent, 'utf-8');
110
+ console.log('✓ Generated README.md');
111
+ }
112
+ }
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { resolve, join } from 'path';
2
2
  import { mkdir } from 'fs/promises';
3
- import { generateFiles } from './generator.js';
3
+ import { generateFiles, enableFiles } from './generator.js';
4
4
 
5
5
  /**
6
6
  * Initialize a new AI-native project
@@ -57,3 +57,30 @@ export async function init(projectName) {
57
57
  console.log(' - README.md: Setup instructions');
58
58
  console.log(' - docs/: Architecture documentation folder');
59
59
  }
60
+
61
+ /**
62
+ * Enable AI features in an existing project
63
+ */
64
+ export async function enable() {
65
+ const targetDir = process.cwd();
66
+
67
+ console.log('🚀 Enabling AI features in current directory...');
68
+
69
+ // Create docs directory
70
+ const docsDir = join(targetDir, 'docs');
71
+ try {
72
+ await mkdir(docsDir, { recursive: true });
73
+ console.log('✓ Created docs/ directory');
74
+ } catch (error) {
75
+ throw new Error(`Failed to create docs directory: ${error.message}`);
76
+ }
77
+
78
+ // Generate files for existing project (skip AGENTS.md if exists, append README.md)
79
+ await enableFiles(targetDir);
80
+
81
+ console.log('\n✨ AI features enabled!');
82
+ console.log('\nNext steps:');
83
+ console.log(' 1. Customize AGENTS.md with your project details');
84
+ console.log(' 2. Add build and test commands to AGENTS.md');
85
+ console.log(' 3. Open your project with Claude Code or other AI tools');
86
+ }