ai-native-core 0.2.3 → 0.2.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/package.json +1 -1
- package/src/commands/init.js +10 -2
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const readline = require('readline');
|
|
6
|
+
const { execSync } = require('child_process');
|
|
7
|
+
|
|
8
|
+
function getProjectRoot() {
|
|
9
|
+
try { return execSync('git rev-parse --show-toplevel', { encoding: 'utf-8' }).trim(); }
|
|
10
|
+
catch { return process.cwd(); }
|
|
11
|
+
}
|
|
6
12
|
|
|
7
13
|
const VALID_STACKS = ['react-spa', 'nextjs', 'vue', 'backend-go', 'backend-python', 'backend-java'];
|
|
8
14
|
|
|
@@ -76,7 +82,7 @@ function interactiveInit(isForce) {
|
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
function doInit(stacks, isForce, answers = {}) {
|
|
79
|
-
const root =
|
|
85
|
+
const root = getProjectRoot();
|
|
80
86
|
const dirs = ['.ai-native/memory', '.ai-native/hooks', '.ai-native/reports', 'docs/.ai-native/memory', 'docs/decisions'];
|
|
81
87
|
|
|
82
88
|
console.log(`\n[ai-native] Initializing...\n`);
|
|
@@ -97,6 +103,8 @@ function doInit(stacks, isForce, answers = {}) {
|
|
|
97
103
|
};
|
|
98
104
|
|
|
99
105
|
copyFile('config/ai-native.config.toml', '.ai-native/config.toml', c => {
|
|
106
|
+
c = c.replace(/type = "frontend"/, `type = "${answers.type || 'frontend'}"`);
|
|
107
|
+
if (answers.type) c = c.replace(/name = "my-project"/, `name = "${path.basename(root)}"`);
|
|
100
108
|
c = c.replace(/adapter = "react-spa"/, stacks.length > 1
|
|
101
109
|
? `adapter = [${stacks.map(s => `"${s}"`).join(', ')}]`
|
|
102
110
|
: `adapter = "${stacks[0]}"`);
|
|
@@ -104,7 +112,7 @@ function doInit(stacks, isForce, answers = {}) {
|
|
|
104
112
|
if (answers.css) c = c.replace(/css = "tailwind-v4"/, `css = "${answers.css}"`);
|
|
105
113
|
if (answers.ui) c = c.replace(/ui_library = "shadcn"/, `ui_library = "${answers.ui}"`);
|
|
106
114
|
if (answers.test) c = c.replace(/test_framework = "vitest"/, `test_framework = "${answers.test}"`);
|
|
107
|
-
if (answers.ts) c = c.replace(/typescript = true/, `typescript = ${answers.ts === 'yes'}`);
|
|
115
|
+
if (answers.ts !== undefined) c = c.replace(/typescript = true/, `typescript = ${answers.ts === 'yes'}`);
|
|
108
116
|
return c;
|
|
109
117
|
});
|
|
110
118
|
|