claudeguide-engineer 1.15.1 → 1.16.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.
Files changed (2) hide show
  1. package/index.js +87 -51
  2. package/package.json +7 -1
package/index.js CHANGED
@@ -3,63 +3,75 @@
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
5
  const { execSync } = require('child_process');
6
+ const os = require('os');
6
7
 
7
- const args = process.argv.slice(2);
8
- const command = args[0];
8
+ // Professional CLI dependencies
9
+ const chalk = require('chalk');
10
+ const ora = require('ora');
11
+ const inquirer = require('inquirer');
12
+ const { program } = require('commander');
9
13
 
10
- // Your Private Repository URL
14
+ // Configuration
11
15
  const PRIVATE_REPO_URL = "https://github.com/nstung463/claude-guide.git";
16
+ const CONFIG_FILE = path.join(os.homedir(), '.claudeguide-config.json');
12
17
 
13
- if (!command || command === '--help' || command === '-h') {
14
- console.log(`
15
- Usage: cg <command>
16
-
17
- Commands:
18
- init, new Initialize a new project with ClaudeGuide Engineer Kit
19
- update Update the kit from the private repository
20
- version, -v Show version
21
- help, -h Show this help
22
- `);
23
- process.exit(0);
18
+ /**
19
+ * Load or save GitHub Token
20
+ */
21
+ function getSavedToken() {
22
+ if (fs.existsSync(CONFIG_FILE)) {
23
+ try {
24
+ const config = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
25
+ return config.GITHUB_TOKEN;
26
+ } catch (e) {
27
+ return null;
28
+ }
29
+ }
30
+ return null;
24
31
  }
25
32
 
26
- if (command === 'version' || command === '-v') {
27
- const pkg = require('./package.json');
28
- console.log(`claudeguide-engineer CLI v${pkg.version}`);
29
- process.exit(0);
33
+ function saveToken(token) {
34
+ fs.writeFileSync(CONFIG_FILE, JSON.stringify({ GITHUB_TOKEN: token }, null, 2));
30
35
  }
31
36
 
32
- if (command === 'init' || command === 'new' || command === 'update') {
33
- console.log('šŸš€ Checking access to ClaudeGuide Private Kit...');
34
-
35
- // Get Token from environment variables
36
- const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
37
-
38
- if (!GITHUB_TOKEN) {
39
- console.error('āŒ Error: GITHUB_TOKEN not found.');
40
- console.log('\nInstructions:');
41
- console.log('1. Create a Personal Access Token (PAT) at: https://github.com/settings/tokens');
42
- console.log('2. Ensure it has "repo" scope (to access private repositories).');
43
- console.log('3. Set the environment variable:');
44
- console.log(' Windows: set GITHUB_TOKEN=your_token');
45
- console.log(' Linux/macOS: export GITHUB_TOKEN=your_token');
46
- console.log('4. Try running "cg init" again.');
47
- process.exit(1);
37
+ /**
38
+ * Main Initialization Logic
39
+ */
40
+ async function initializeKit(options) {
41
+ console.log(chalk.cyan.bold('\nšŸš€ ClaudeGuide Engineer Kit Initializer\n'));
42
+
43
+ let token = process.env.GITHUB_TOKEN || getSavedToken();
44
+
45
+ // Prompt for token if missing
46
+ if (!token) {
47
+ console.log(chalk.yellow('šŸ’” No GitHub Token found. You need a Personal Access Token (PAT) with "repo" scope.'));
48
+ const answers = await inquirer.prompt([
49
+ {
50
+ type: 'password',
51
+ name: 'token',
52
+ message: 'Enter your GitHub Personal Access Token:',
53
+ validate: (input) => input.length > 0 || 'Token is required'
54
+ }
55
+ ]);
56
+ token = answers.token;
57
+ saveToken(token);
58
+ console.log(chalk.green('āœ… Token saved to ' + CONFIG_FILE + '\n'));
48
59
  }
49
60
 
61
+ const spinner = ora('Checking access to Private Kit...').start();
50
62
  const targetDir = process.cwd();
51
63
  const tempDir = path.join(targetDir, '.cg-temp-' + Date.now());
52
64
 
53
65
  try {
54
- // Attempt to clone using the token
55
- console.log('šŸ”‘ Authenticating with GitHub...');
56
- const authRepoUrl = PRIVATE_REPO_URL.replace("https://", `https://${GITHUB_TOKEN}@`);
66
+ // Authenticate and Clone
67
+ const authRepoUrl = PRIVATE_REPO_URL.replace("https://", `https://${token}@`);
57
68
 
69
+ spinner.text = 'Authenticating and downloading from GitHub...';
58
70
  execSync(`git clone --depth 1 ${authRepoUrl} "${tempDir}"`, { stdio: 'ignore' });
59
71
 
60
- console.log('āœ… Access Granted! Initializing files...');
72
+ spinner.succeed(chalk.green('Access Granted! Repository downloaded.'));
73
+ spinner.start('Initializing files in ' + targetDir + '...');
61
74
 
62
- // List of files and directories to copy from the private repo
63
75
  const filesToCopy = [
64
76
  ".claude",
65
77
  ".opencode",
@@ -83,31 +95,55 @@ if (command === 'init' || command === 'new' || command === 'update') {
83
95
  } else {
84
96
  fs.copyFileSync(src, dest);
85
97
  }
86
- console.log(` āž• Added: ${file}`);
87
98
  }
88
99
  });
89
100
 
90
- // Clean up temporary directory
101
+ spinner.succeed(chalk.green('Files initialized successfully.'));
102
+
103
+ // Clean up
91
104
  fs.rmSync(tempDir, { recursive: true, force: true });
92
105
 
93
- console.log('\n✨ Done! Project initialized successfully.');
94
- console.log('\nNext steps:');
95
- console.log('1. Run "npm install"');
96
- console.log('2. Type "claude" to start building.');
106
+ console.log(chalk.blue.bold('\n✨ All set! ClaudeGuide is ready.'));
107
+ console.log(chalk.white('\nNext steps:'));
108
+ console.log(chalk.gray(' 1. ') + chalk.white('Run ') + chalk.cyan('npm install'));
109
+ console.log(chalk.gray(' 2. ') + chalk.white('Type ') + chalk.cyan('claude') + chalk.white(' to start building.\n'));
97
110
 
98
111
  } catch (err) {
99
- console.error('āŒ Access Denied: You do not have permission to access this Kit.');
100
- console.error(' Please ensure your Token has "repo" scope and you have been invited to the repository.');
112
+ spinner.fail(chalk.red('Access Denied or Connection Error.'));
113
+ console.error(chalk.red('\nError Details: ') + chalk.white(err.message));
114
+ console.log(chalk.yellow('\nTips:'));
115
+ console.log(' - Ensure your PAT has "repo" scope.');
116
+ console.log(' - Ensure you are a contributor to ' + PRIVATE_REPO_URL);
117
+ console.log(' - To reset your token, delete ' + CONFIG_FILE);
118
+
101
119
  if (fs.existsSync(tempDir)) fs.rmSync(tempDir, { recursive: true, force: true });
102
120
  process.exit(1);
103
121
  }
104
- } else {
105
- console.log(`Unknown command: ${command}`);
106
- console.log('Type "cg --help" for available commands.');
107
122
  }
108
123
 
109
124
  /**
110
- * Recursive copy function
125
+ * CLI Configuration
126
+ */
127
+ program
128
+ .name('cg')
129
+ .description('CLI tool for ClaudeGuide AI Agent Framework')
130
+ .version(require('./package.json').version, '-v, --version');
131
+
132
+ program
133
+ .command('init')
134
+ .alias('new')
135
+ .description('Initialize a new project with the Engineer Kit')
136
+ .action(initializeKit);
137
+
138
+ program
139
+ .command('update')
140
+ .description('Update the framework files from the private repository')
141
+ .action(initializeKit);
142
+
143
+ program.parse(process.argv);
144
+
145
+ /**
146
+ * Helper: Recursive Copy
111
147
  */
112
148
  function copyRecursiveSync(src, dest) {
113
149
  if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudeguide-engineer",
3
- "version": "1.15.1",
3
+ "version": "1.16.0",
4
4
  "description": "A comprehensive boilerplate template for building professional software projects with CLI Coding Agents (Claude Code and Open Code).",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -35,6 +35,12 @@
35
35
  "LICENSE",
36
36
  ".claude/metadata.json"
37
37
  ],
38
+ "dependencies": {
39
+ "chalk": "^4.1.2",
40
+ "ora": "^5.4.1",
41
+ "inquirer": "^8.2.4",
42
+ "commander": "^9.4.1"
43
+ },
38
44
  "devDependencies": {
39
45
  "@commitlint/cli": "^18.4.3",
40
46
  "@commitlint/config-conventional": "^18.4.3",