@haposoft/cafekit 0.5.3 → 0.5.4

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/bin/install.js +48 -8
  2. package/package.json +1 -1
package/bin/install.js CHANGED
@@ -816,13 +816,45 @@ async function promptInstallGemini() {
816
816
  });
817
817
  }
818
818
 
819
- function showGeminiKeyInstructions() {
820
- console.log('\nšŸ“ Gemini API Key Setup');
821
- console.log(' 1. Get your API key: https://aistudio.google.com/apikey');
822
- console.log(' 2. Set environment variable:');
823
- console.log(' export GEMINI_API_KEY="your-api-key-here"');
824
- console.log(' 3. Add to your shell profile (~/.zshrc or ~/.bashrc) to persist');
819
+ async function promptGeminiAPIKey() {
820
+ const rl = readline.createInterface({
821
+ input: process.stdin,
822
+ output: process.stdout
823
+ });
824
+
825
+ console.log('\nšŸ“ Gemini API Key Configuration');
826
+ console.log(' Get your API key: https://aistudio.google.com/apikey');
825
827
  console.log();
828
+
829
+ return new Promise((resolve) => {
830
+ rl.question('Enter your Gemini API key (or press Enter to skip): ', (answer) => {
831
+ rl.close();
832
+ resolve(answer.trim());
833
+ });
834
+ });
835
+ }
836
+
837
+ function configureGeminiKey(apiKey) {
838
+ try {
839
+ const geminiDir = path.join(os.homedir(), '.gemini');
840
+ const envFile = path.join(geminiDir, '.env');
841
+
842
+ // Ensure .gemini directory exists
843
+ if (!fs.existsSync(geminiDir)) {
844
+ fs.mkdirSync(geminiDir, { recursive: true });
845
+ }
846
+
847
+ // Write API key to .env file
848
+ fs.writeFileSync(envFile, `GEMINI_API_KEY=${apiKey}\n`, { mode: 0o600 });
849
+ console.log(' āœ“ Gemini API key configured successfully');
850
+ console.log(' āœ“ Saved to ~/.gemini/.env');
851
+ return true;
852
+ } catch (error) {
853
+ console.log(' āœ— Failed to configure Gemini API key');
854
+ console.log(` Error: ${error.message}`);
855
+ console.log(' You can manually set: export GEMINI_API_KEY="your-key"');
856
+ return false;
857
+ }
826
858
  }
827
859
 
828
860
  async function setupGeminiCLI() {
@@ -845,11 +877,19 @@ async function setupGeminiCLI() {
845
877
  const installed = installGeminiCLI();
846
878
 
847
879
  if (installed) {
848
- showGeminiKeyInstructions();
880
+ const apiKey = await promptGeminiAPIKey();
881
+
882
+ if (apiKey) {
883
+ configureGeminiKey(apiKey);
884
+ } else {
885
+ console.log('\n ℹ Skipped API key configuration');
886
+ console.log(' Set later: export GEMINI_API_KEY="your-key"');
887
+ }
849
888
  } else {
850
889
  console.log('\nšŸ“ Manual installation steps:');
851
890
  console.log(' 1. npm install -g @google/gemini-cli');
852
- showGeminiKeyInstructions();
891
+ console.log(' 2. Get API key: https://aistudio.google.com/apikey');
892
+ console.log(' 3. export GEMINI_API_KEY="your-key"');
853
893
  }
854
894
  }
855
895
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haposoft/cafekit",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Spec-Driven Development workflow for AI coding assistants. Supports Claude Code and Antigravity with spec-first workflows plus Claude Code hapo: skills.",
5
5
  "author": "Haposoft <nghialt@haposoft.com>",
6
6
  "license": "MIT",