@nghiapt/kit 1.0.1 → 1.0.3
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 +166 -0
- package/index.js +0 -0
- package/package.json +5 -5
package/bin/index.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const readline = require('readline');
|
|
6
|
+
|
|
7
|
+
// Enable keypress events
|
|
8
|
+
readline.emitKeypressEvents(process.stdin);
|
|
9
|
+
if (process.stdin.isTTY) {
|
|
10
|
+
process.stdin.setRawMode(true);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const HEADER = `
|
|
14
|
+
==========================================
|
|
15
|
+
Antigravity Kit Setup
|
|
16
|
+
==========================================
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
// Paths
|
|
20
|
+
const WORKFLOWS_SRC = path.join(__dirname, '..', 'workflows');
|
|
21
|
+
const USER_HOME = os.homedir();
|
|
22
|
+
const GLOBAL_DEST = path.join(USER_HOME, '.gemini', 'antigravity', 'global_workflows');
|
|
23
|
+
const LOCAL_DEST = path.join(process.cwd(), '.agent', 'workflows');
|
|
24
|
+
|
|
25
|
+
// Menu Options
|
|
26
|
+
const OPTIONS = [
|
|
27
|
+
{
|
|
28
|
+
label: 'Install Global (Recommended)',
|
|
29
|
+
desc: 'Copies to ~/.gemini/antigravity/global_workflows',
|
|
30
|
+
action: async () => await installWorkflows(GLOBAL_DEST, 'Global')
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: 'Install Only on Context Project',
|
|
34
|
+
desc: 'Copies to ./.agent/workflows',
|
|
35
|
+
action: async () => await installWorkflows(LOCAL_DEST, 'Local Project')
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: 'Exit',
|
|
39
|
+
desc: 'Close the setup wizard',
|
|
40
|
+
action: () => process.exit(0)
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
let selectedIndex = 0;
|
|
45
|
+
|
|
46
|
+
// --- Helper Functions ---
|
|
47
|
+
|
|
48
|
+
function ensureDirectoryExists(dir) {
|
|
49
|
+
if (!fs.existsSync(dir)) {
|
|
50
|
+
try {
|
|
51
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
52
|
+
// console.log(`Created directory: ${dir}`); // keep output clean
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.error(`❌ Error creating directory ${dir}: ${err.message}`);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function installWorkflows(destination, typeLabel) {
|
|
62
|
+
// restore standard input for logging
|
|
63
|
+
// (optional, but raw mode can accept keypress artifacts if we type during async ops)
|
|
64
|
+
|
|
65
|
+
console.log(`\n\n[Installing Workflows (${typeLabel})]...`);
|
|
66
|
+
|
|
67
|
+
if (!fs.existsSync(WORKFLOWS_SRC)) {
|
|
68
|
+
console.error('❌ Source workflows directory not found:', WORKFLOWS_SRC);
|
|
69
|
+
await waitForKey();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!ensureDirectoryExists(destination)) {
|
|
74
|
+
await waitForKey();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
const files = fs.readdirSync(WORKFLOWS_SRC);
|
|
80
|
+
let count = 0;
|
|
81
|
+
|
|
82
|
+
for (const file of files) {
|
|
83
|
+
if (path.extname(file) === '.md') {
|
|
84
|
+
const srcFile = path.join(WORKFLOWS_SRC, file);
|
|
85
|
+
const destFile = path.join(destination, file);
|
|
86
|
+
fs.copyFileSync(srcFile, destFile);
|
|
87
|
+
count++;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
console.log(`✅ Successfully copied ${count} workflows to:`);
|
|
92
|
+
console.log(` ${destination}`);
|
|
93
|
+
|
|
94
|
+
} catch (err) {
|
|
95
|
+
console.error('❌ Failed to copy workflows:', err.message);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
await waitForKey();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function waitForKey() {
|
|
102
|
+
return new Promise(resolve => {
|
|
103
|
+
console.log('\nPress any key to continue...');
|
|
104
|
+
const onKey = () => {
|
|
105
|
+
process.stdin.removeListener('keypress', onKey);
|
|
106
|
+
resolve();
|
|
107
|
+
};
|
|
108
|
+
process.stdin.on('keypress', onKey);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// --- Render Logic ---
|
|
113
|
+
|
|
114
|
+
function renderMenu() {
|
|
115
|
+
console.clear();
|
|
116
|
+
console.log(HEADER);
|
|
117
|
+
console.log('Use Arrow Keys to Navigate, ENTER to Select.\n');
|
|
118
|
+
|
|
119
|
+
OPTIONS.forEach((opt, index) => {
|
|
120
|
+
const isSelected = index === selectedIndex;
|
|
121
|
+
const pointer = isSelected ? '👉' : ' ';
|
|
122
|
+
const color = isSelected ? '\x1b[36m' : '\x1b[0m'; // Cyan if selected
|
|
123
|
+
const reset = '\x1b[0m';
|
|
124
|
+
|
|
125
|
+
console.log(`${pointer} ${color}${opt.label}${reset}`);
|
|
126
|
+
if (isSelected && opt.desc) {
|
|
127
|
+
console.log(` \x1b[90m${opt.desc}\x1b[0m`); // Gray description
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// --- Input Handling ---
|
|
133
|
+
|
|
134
|
+
async function handleSelection() {
|
|
135
|
+
const selectedOption = OPTIONS[selectedIndex];
|
|
136
|
+
|
|
137
|
+
// Temporarily disable raw mode if needed or just handle execution
|
|
138
|
+
// Ideally keep raw mode but stop listening to nav keys during execution
|
|
139
|
+
process.stdin.removeListener('keypress', handleInput);
|
|
140
|
+
|
|
141
|
+
await selectedOption.action();
|
|
142
|
+
|
|
143
|
+
// Resume menu
|
|
144
|
+
renderMenu();
|
|
145
|
+
process.stdin.on('keypress', handleInput);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function handleInput(str, key) {
|
|
149
|
+
if (key.name === 'c' && key.ctrl) {
|
|
150
|
+
process.exit();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (key.name === 'up') {
|
|
154
|
+
selectedIndex = (selectedIndex - 1 + OPTIONS.length) % OPTIONS.length;
|
|
155
|
+
renderMenu();
|
|
156
|
+
} else if (key.name === 'down') {
|
|
157
|
+
selectedIndex = (selectedIndex + 1) % OPTIONS.length;
|
|
158
|
+
renderMenu();
|
|
159
|
+
} else if (key.name === 'return') {
|
|
160
|
+
handleSelection();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Init
|
|
165
|
+
process.stdin.on('keypress', handleInput);
|
|
166
|
+
renderMenu();
|
package/index.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nghiapt/kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "The 'Native Gemini' Agentic Framework. Turn your IDE into an autonomous coding partner.",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "./bin/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"antigravity-kit": "./index.js"
|
|
7
|
+
"antigravity-kit": "./bin/index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"setup": "node index.js",
|
|
11
|
-
"postinstall": "node index.js",
|
|
10
|
+
"setup": "node bin/index.js",
|
|
11
|
+
"postinstall": "node bin/index.js",
|
|
12
12
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|