@fyow/copilot-everything 1.0.9 → 1.0.11

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "servers": {
2
+ "mcpServers": {
3
3
  "context7": {
4
4
  "command": "npx",
5
5
  "args": ["-y", "@upstash/context7-mcp@latest"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fyow/copilot-everything",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Everything you need for GitHub Copilot CLI - agents, skills, instructions, and hooks configurations",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -82,6 +82,77 @@ function copyFile(src, dest, options = {}) {
82
82
  }
83
83
  }
84
84
 
85
+ /**
86
+ * Process MCP config and substitute environment variables
87
+ * Returns { content, substituted, missing } where:
88
+ * - content: the processed JSON string
89
+ * - substituted: array of env var names that were found and substituted
90
+ * - missing: array of env var names that are still placeholders
91
+ */
92
+ function processMcpConfig(src) {
93
+ const content = fs.readFileSync(src, 'utf-8');
94
+ const substituted = [];
95
+ const missing = [];
96
+
97
+ // Find all ${VAR_NAME} patterns
98
+ const envVarPattern = /\$\{([A-Z_][A-Z0-9_]*)\}/g;
99
+ const matches = content.matchAll(envVarPattern);
100
+
101
+ // Collect unique env var names
102
+ const envVars = new Set();
103
+ for (const match of matches) {
104
+ envVars.add(match[1]);
105
+ }
106
+
107
+ // Check which ones exist in environment and substitute
108
+ let processedContent = content;
109
+ for (const varName of envVars) {
110
+ const envValue = process.env[varName];
111
+ if (envValue) {
112
+ // Replace all occurrences of ${VAR_NAME} with actual value
113
+ processedContent = processedContent.replace(
114
+ new RegExp(`\\$\\{${varName}\\}`, 'g'),
115
+ envValue
116
+ );
117
+ substituted.push(varName);
118
+ } else {
119
+ missing.push(varName);
120
+ }
121
+ }
122
+
123
+ return { content: processedContent, substituted, missing };
124
+ }
125
+
126
+ /**
127
+ * Copy MCP config file with environment variable substitution
128
+ */
129
+ function copyMcpConfig(src, dest, options = {}) {
130
+ const { force = false, dryRun = false } = options;
131
+
132
+ if (!fs.existsSync(src)) {
133
+ return { copied: 0, skipped: 0, errors: [{ path: dest, error: 'Source not found' }], substituted: [], missing: [] };
134
+ }
135
+
136
+ if (fs.existsSync(dest) && !force) {
137
+ return { copied: 0, skipped: 1, errors: [], substituted: [], missing: [] };
138
+ }
139
+
140
+ try {
141
+ const { content, substituted, missing } = processMcpConfig(src);
142
+
143
+ if (!dryRun) {
144
+ const destDir = path.dirname(dest);
145
+ if (!fs.existsSync(destDir)) {
146
+ fs.mkdirSync(destDir, { recursive: true });
147
+ }
148
+ fs.writeFileSync(dest, content, 'utf-8');
149
+ }
150
+ return { copied: 1, skipped: 0, errors: [], substituted, missing };
151
+ } catch (error) {
152
+ return { copied: 0, skipped: 0, errors: [{ path: dest, error: error.message }], substituted: [], missing: [] };
153
+ }
154
+ }
155
+
85
156
  const readline = require('readline');
86
157
 
87
158
  /**
@@ -257,9 +328,17 @@ async function init(flags = {}) {
257
328
  console.log(` 💡 Template available at: ${mcpConfigSrc}`);
258
329
  totalSkipped += 1;
259
330
  } else {
260
- const mcpResult = copyFile(mcpConfigSrc, mcpConfigDest, { force: forceMcp });
331
+ const mcpResult = copyMcpConfig(mcpConfigSrc, mcpConfigDest, { force: forceMcp });
261
332
  if (mcpResult.copied > 0) {
262
333
  console.log(` ✅ MCP config: ${forceMcp ? 'overwritten' : 'installed'} to ${mcpConfigDest}`);
334
+
335
+ // Report env var substitution results
336
+ if (mcpResult.substituted.length > 0) {
337
+ console.log(` 🔑 Auto-filled from environment: ${mcpResult.substituted.join(', ')}`);
338
+ }
339
+ if (mcpResult.missing.length > 0) {
340
+ console.log(` 📝 Need to configure: ${mcpResult.missing.join(', ')}`);
341
+ }
263
342
  }
264
343
  totalCopied += mcpResult.copied;
265
344
  totalSkipped += mcpResult.skipped;