create-zero-json-app 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/bin/index.js +102 -0
- package/package.json +13 -0
package/bin/index.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const projectName = process.argv[2];
|
|
8
|
+
|
|
9
|
+
if (!projectName) {
|
|
10
|
+
console.error("Please specify a project name: npx create-zero-app <project-name>");
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const currentDir = process.cwd();
|
|
15
|
+
const projectDir = path.join(currentDir, projectName);
|
|
16
|
+
|
|
17
|
+
if (fs.existsSync(projectDir)) {
|
|
18
|
+
console.error(`Directory ${projectName} already exists.`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
console.log(`Creating a new Zero-JSON app in ${projectDir}...`);
|
|
23
|
+
fs.mkdirSync(projectDir);
|
|
24
|
+
|
|
25
|
+
// 1. Create package.json
|
|
26
|
+
const packageJson = {
|
|
27
|
+
name: projectName,
|
|
28
|
+
version: "1.0.0",
|
|
29
|
+
private: true,
|
|
30
|
+
scripts: {
|
|
31
|
+
"dev": "zero-watch"
|
|
32
|
+
},
|
|
33
|
+
dependencies: {
|
|
34
|
+
"react": "^18.2.0",
|
|
35
|
+
"react-dom": "^18.2.0"
|
|
36
|
+
},
|
|
37
|
+
devDependencies: {
|
|
38
|
+
"zero-json-engine": "^1.0.0"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
fs.writeFileSync(path.join(projectDir, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
42
|
+
|
|
43
|
+
// 2. Create basic src files
|
|
44
|
+
fs.mkdirSync(path.join(projectDir, 'src'));
|
|
45
|
+
fs.writeFileSync(path.join(projectDir, 'src', 'App.json'), `["div", "p-4 text-center text-blue-600 font-bold", "Welcome to Zero-JSON!"]`);
|
|
46
|
+
|
|
47
|
+
// 3. Generate Unified AI Rules
|
|
48
|
+
console.log("Generating multi-agent AI rules...");
|
|
49
|
+
const dictPath = path.join(__dirname, '..', '..', 'dictionaries');
|
|
50
|
+
|
|
51
|
+
let unifiedRules = "# Zero-JSON Universal AI Rules\n\n";
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const reactRules = fs.readFileSync(path.join(dictPath, 'zero-react.md'), 'utf-8');
|
|
55
|
+
const tailwindRules = fs.readFileSync(path.join(dictPath, 'zero-tailwind.md'), 'utf-8');
|
|
56
|
+
const nodeRules = fs.readFileSync(path.join(dictPath, 'zero-node.md'), 'utf-8');
|
|
57
|
+
const sqlRules = fs.readFileSync(path.join(dictPath, 'zero-sql.md'), 'utf-8');
|
|
58
|
+
|
|
59
|
+
unifiedRules += reactRules + "\n\n" + tailwindRules + "\n\n" + nodeRules + "\n\n" + sqlRules;
|
|
60
|
+
} catch (e) {
|
|
61
|
+
console.log("Warning: Could not read all dictionaries. Ensure you are running this from the dev workspace.", e.message);
|
|
62
|
+
unifiedRules += "System Prompt: Always use Zero-JSON and Zero-SDK for token savings.";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 4. Distribute rules to multi-agent locations
|
|
66
|
+
const rulesLocations = [
|
|
67
|
+
'.cursorrules', // Cursor
|
|
68
|
+
'.windsurfrules', // Windsurf / Devin
|
|
69
|
+
'zero-instructions.md' // Claude / ChatGPT / Perplexity
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
rulesLocations.forEach(file => {
|
|
73
|
+
fs.writeFileSync(path.join(projectDir, file), unifiedRules);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// GitHub Copilot
|
|
77
|
+
const githubDir = path.join(projectDir, '.github');
|
|
78
|
+
fs.mkdirSync(githubDir);
|
|
79
|
+
fs.writeFileSync(path.join(githubDir, 'copilot-instructions.md'), unifiedRules);
|
|
80
|
+
|
|
81
|
+
// Antigravity IDE
|
|
82
|
+
const agentsDir = path.join(projectDir, '.agents');
|
|
83
|
+
fs.mkdirSync(agentsDir);
|
|
84
|
+
fs.writeFileSync(path.join(agentsDir, 'AGENTS.md'), unifiedRules);
|
|
85
|
+
|
|
86
|
+
console.log("Multi-agent rules generated successfully.");
|
|
87
|
+
|
|
88
|
+
// 5. Run npm install
|
|
89
|
+
console.log("Installing dependencies (including zero-engine)...");
|
|
90
|
+
try {
|
|
91
|
+
execSync('npm install', { cwd: projectDir, stdio: 'inherit' });
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.error("Failed to install dependencies.");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
console.log(`\nSuccess! Created ${projectName} at ${projectDir}`);
|
|
97
|
+
console.log('Inside that directory, you can run several commands:');
|
|
98
|
+
console.log('\n npm run dev');
|
|
99
|
+
console.log(' Starts the zero-watch compiler daemon.');
|
|
100
|
+
console.log('\nGet started by typing:');
|
|
101
|
+
console.log(` cd ${projectName}`);
|
|
102
|
+
console.log(' npm run dev');
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-zero-json-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Scaffolding tool for Zero-JSON architecture",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-zero-app": "./bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {}
|
|
13
|
+
}
|