apero-kit-cli 1.5.0 ā 1.7.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/package.json +1 -1
- package/src/commands/help.js +9 -37
- package/src/utils/paths.js +64 -4
package/package.json
CHANGED
package/src/commands/help.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import http from 'http';
|
|
2
|
-
import { join } from 'path';
|
|
3
1
|
import { exec } from 'child_process';
|
|
4
|
-
import fs from 'fs-extra';
|
|
5
2
|
import chalk from 'chalk';
|
|
6
|
-
import { CLI_ROOT, TEMPLATES_DIR, resolveSource } from '../utils/paths.js';
|
|
7
|
-
|
|
8
|
-
const PORT = 3457;
|
|
9
3
|
|
|
10
4
|
// Bilingual content
|
|
11
5
|
const i18n = {
|
|
@@ -1403,38 +1397,16 @@ function generateWorkflowsSection(t, lang) {
|
|
|
1403
1397
|
`;
|
|
1404
1398
|
}
|
|
1405
1399
|
|
|
1400
|
+
const HELP_URL = 'https://www.vividkit.dev/vi/guides/what-is-claudekit';
|
|
1401
|
+
|
|
1406
1402
|
/**
|
|
1407
|
-
* Help command - open
|
|
1403
|
+
* Help command - open VividKit documentation in browser
|
|
1408
1404
|
*/
|
|
1409
1405
|
export async function helpCommand(options) {
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
const section = url.searchParams.get('section') || 'overview';
|
|
1417
|
-
const lang = url.searchParams.get('lang') || 'vi';
|
|
1418
|
-
|
|
1419
|
-
const html = generateHelpPage(section, lang, source);
|
|
1420
|
-
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
1421
|
-
res.end(html);
|
|
1422
|
-
});
|
|
1423
|
-
|
|
1424
|
-
server.listen(PORT, () => {
|
|
1425
|
-
const url = `http://localhost:${PORT}`;
|
|
1426
|
-
console.log(chalk.green(` Help server running at: ${url}`));
|
|
1427
|
-
console.log(chalk.gray(' Press Ctrl+C to stop\n'));
|
|
1428
|
-
|
|
1429
|
-
// Open browser
|
|
1430
|
-
const openCommand = process.platform === 'darwin' ? 'open' :
|
|
1431
|
-
process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
1432
|
-
exec(`${openCommand} ${url}`);
|
|
1433
|
-
});
|
|
1434
|
-
|
|
1435
|
-
// Handle shutdown
|
|
1436
|
-
process.on('SIGINT', () => {
|
|
1437
|
-
console.log(chalk.yellow('\nš Help server stopped'));
|
|
1438
|
-
process.exit(0);
|
|
1439
|
-
});
|
|
1406
|
+
console.log(chalk.cyan('\nš Opening VividKit documentation...\n'));
|
|
1407
|
+
console.log(chalk.green(` ${HELP_URL}\n`));
|
|
1408
|
+
|
|
1409
|
+
const openCommand = process.platform === 'darwin' ? 'open' :
|
|
1410
|
+
process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
1411
|
+
exec(`${openCommand} ${HELP_URL}`);
|
|
1440
1412
|
}
|
package/src/utils/paths.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
2
|
import { dirname, join, resolve } from 'path';
|
|
3
|
-
import { existsSync, statSync } from 'fs';
|
|
3
|
+
import { existsSync, statSync, mkdirSync } from 'fs';
|
|
4
4
|
import { execSync } from 'child_process';
|
|
5
|
+
import { homedir } from 'os';
|
|
5
6
|
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = dirname(__filename);
|
|
@@ -12,6 +13,10 @@ export const CLI_ROOT = resolve(__dirname, '../..');
|
|
|
12
13
|
// Embedded templates directory (inside CLI package)
|
|
13
14
|
export const TEMPLATES_DIR = join(CLI_ROOT, 'templates');
|
|
14
15
|
|
|
16
|
+
// Remote templates config
|
|
17
|
+
const REMOTE_REPO_URL = 'https://github.com/Thanhnguyen6702/CK-Internal.git';
|
|
18
|
+
const CACHE_DIR = join(homedir(), '.apero-kit', 'CK-Internal');
|
|
19
|
+
|
|
15
20
|
// Target folder mappings
|
|
16
21
|
export const TARGETS = {
|
|
17
22
|
claude: '.claude',
|
|
@@ -19,6 +24,55 @@ export const TARGETS = {
|
|
|
19
24
|
generic: '.agent'
|
|
20
25
|
};
|
|
21
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Fetch or update remote templates from CK-Internal GitHub repo.
|
|
29
|
+
* Clones on first run, pulls on subsequent runs.
|
|
30
|
+
* Returns source object or null on failure.
|
|
31
|
+
*/
|
|
32
|
+
export function fetchRemoteTemplates() {
|
|
33
|
+
try {
|
|
34
|
+
const cacheParent = join(homedir(), '.apero-kit');
|
|
35
|
+
if (!existsSync(cacheParent)) {
|
|
36
|
+
mkdirSync(cacheParent, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (existsSync(join(CACHE_DIR, '.git'))) {
|
|
40
|
+
// Already cloned ā pull latest
|
|
41
|
+
try {
|
|
42
|
+
execSync('git pull --ff-only', {
|
|
43
|
+
cwd: CACHE_DIR,
|
|
44
|
+
encoding: 'utf-8',
|
|
45
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
46
|
+
timeout: 30000
|
|
47
|
+
});
|
|
48
|
+
} catch {
|
|
49
|
+
// pull failed (offline, etc.) ā use cached version
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
// First time ā clone
|
|
53
|
+
execSync(`git clone --depth 1 "${REMOTE_REPO_URL}" "${CACHE_DIR}"`, {
|
|
54
|
+
encoding: 'utf-8',
|
|
55
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
56
|
+
timeout: 60000
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const claudeDir = join(CACHE_DIR, '.claude');
|
|
61
|
+
if (existsSync(claudeDir) && statSync(claudeDir).isDirectory()) {
|
|
62
|
+
const agentsMd = join(CACHE_DIR, 'AGENTS.md');
|
|
63
|
+
return {
|
|
64
|
+
path: CACHE_DIR,
|
|
65
|
+
type: 'remote',
|
|
66
|
+
claudeDir,
|
|
67
|
+
agentsMd: existsSync(agentsMd) ? agentsMd : null
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
// Clone failed (no network, etc.) ā fall through
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
22
76
|
/**
|
|
23
77
|
* Get embedded templates (bundled with CLI)
|
|
24
78
|
*/
|
|
@@ -177,19 +231,25 @@ export function resolveSource(sourceFlag) {
|
|
|
177
231
|
return { error: `No .claude/ or .opencode/ found in: ${sourceFlag}` };
|
|
178
232
|
}
|
|
179
233
|
|
|
180
|
-
// 2.
|
|
234
|
+
// 2. Fetch from remote CK-Internal repo - PREFERRED
|
|
235
|
+
const remote = fetchRemoteTemplates();
|
|
236
|
+
if (remote) {
|
|
237
|
+
return remote;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// 3. Use embedded templates (bundled with CLI) - FALLBACK
|
|
181
241
|
const embedded = getEmbeddedTemplates();
|
|
182
242
|
if (embedded) {
|
|
183
243
|
return embedded;
|
|
184
244
|
}
|
|
185
245
|
|
|
186
|
-
//
|
|
246
|
+
// 4. Fallback: auto-detect in parent directories
|
|
187
247
|
const found = findSource();
|
|
188
248
|
if (found) {
|
|
189
249
|
return found;
|
|
190
250
|
}
|
|
191
251
|
|
|
192
252
|
return {
|
|
193
|
-
error: 'No templates found.
|
|
253
|
+
error: 'No templates found. Check your network connection or try reinstalling: npm install -g apero-kit-cli'
|
|
194
254
|
};
|
|
195
255
|
}
|