spritecook-mcp 0.2.6 → 0.2.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spritecook-mcp",
3
- "version": "0.2.6",
3
+ "version": "0.2.9",
4
4
  "mcpName": "ai.spritecook/generate",
5
5
  "description": "SpriteCook MCP Server - Connect your AI agent (Cursor, VS Code, Claude) to SpriteCook for pixel art and game asset generation.",
6
6
  "keywords": [
package/src/editors.mjs CHANGED
@@ -437,15 +437,19 @@ function writeCodexConfig(configPath, apiKey) {
437
437
  try { content = readFileSync(configPath, 'utf-8'); } catch { /* start fresh */ }
438
438
  }
439
439
 
440
- // Remove any existing [mcp_servers.spritecook] block
441
- content = content.replace(/\[mcp_servers\.spritecook\][^\[]*/, '');
440
+ // Remove any existing [mcp_servers.spritecook] block (including sub-tables)
441
+ content = content.replace(/\[mcp_servers\.spritecook[^\]]*\][^\[]*/g, '');
442
442
 
443
- // Append the new block
443
+ // Codex uses Streamable HTTP format per https://developers.openai.com/codex/mcp/
444
+ // - url: required, the server address
445
+ // - http_headers: map of header names to static values (for auth)
444
446
  const block = [
445
447
  '',
446
448
  '[mcp_servers.spritecook]',
447
449
  `url = "${mcpUrl}"`,
448
- `bearer_token = "${apiKey}"`,
450
+ '',
451
+ '[mcp_servers.spritecook.http_headers]',
452
+ `Authorization = "Bearer ${apiKey}"`,
449
453
  '',
450
454
  ].join('\n');
451
455
 
package/src/setup.mjs CHANGED
@@ -124,7 +124,7 @@ export async function run() {
124
124
 
125
125
  // ── Step 4: Optional agent skill ─────────────────────────────────
126
126
  step(4, 'Agent Skill (optional)');
127
- await maybeInstallSkill();
127
+ await maybeInstallSkill(selected);
128
128
 
129
129
  // ── Done ──────────────────────────────────────────────────────────
130
130
  const configuredNames = selected.map((e) => e.name);
package/src/skill.mjs CHANGED
@@ -1,14 +1,68 @@
1
1
  import { execSync } from 'node:child_process';
2
2
  import { platform } from 'node:os';
3
+ import { mkdirSync, writeFileSync } from 'node:fs';
4
+ import { join } from 'node:path';
3
5
  import prompts from 'prompts';
4
6
  import { success, info, warn } from './ui.mjs';
5
7
 
8
+ const SKILL_RAW_URL =
9
+ 'https://raw.githubusercontent.com/SpriteCook/skills/main/skills/spritecook-generate-sprites/SKILL.md';
10
+
11
+ /**
12
+ * Download SKILL.md directly from GitHub and write it into each
13
+ * selected editor's skill directory. Used as a fallback when
14
+ * `npx skills add` fails (e.g. git not installed).
15
+ *
16
+ * @param {Array<{skillDirs:{project:string|null,global:string|null}, _chosenScope?:string}>} editors
17
+ */
18
+ async function fallbackInstall(editors) {
19
+ info('Trying direct download fallback...');
20
+
21
+ let body;
22
+ try {
23
+ const res = await fetch(SKILL_RAW_URL);
24
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
25
+ body = await res.text();
26
+ } catch (e) {
27
+ warn(`Could not download skill file: ${e.message}`);
28
+ return false;
29
+ }
30
+
31
+ let wrote = 0;
32
+ for (const editor of editors) {
33
+ const dirs = editor.skillDirs;
34
+ if (!dirs) continue;
35
+
36
+ const scope = editor._chosenScope || 'project';
37
+ const dir = dirs[scope] || dirs.project || dirs.global;
38
+ if (!dir) continue;
39
+
40
+ try {
41
+ mkdirSync(dir, { recursive: true });
42
+ writeFileSync(join(dir, 'SKILL.md'), body, 'utf-8');
43
+ wrote++;
44
+ } catch {
45
+ // best-effort, skip on failure
46
+ }
47
+ }
48
+
49
+ if (wrote > 0) {
50
+ success(`Agent skill installed to ${wrote} editor(s) via direct download.`);
51
+ return true;
52
+ }
53
+ return false;
54
+ }
55
+
6
56
  /**
7
- * Install or update the SpriteCook agent skill using the standard
8
- * `npx skills add` CLI. This handles editor detection and correct
9
- * file placement for all supported editors automatically.
57
+ * Install or update the SpriteCook agent skill.
58
+ *
59
+ * Primary: `npx skills add SpriteCook/skills` (requires git).
60
+ * Fallback: download SKILL.md directly from GitHub and place it
61
+ * in each selected editor's skill directory.
62
+ *
63
+ * @param {Array} [selectedEditors] - editors the user chose in step 3
10
64
  */
11
- export async function maybeInstallSkill() {
65
+ export async function maybeInstallSkill(selectedEditors = []) {
12
66
  info('The agent skill teaches your AI how to generate sprites autonomously.');
13
67
  const response = await prompts({
14
68
  type: 'confirm',
@@ -30,8 +84,19 @@ export async function maybeInstallSkill() {
30
84
  timeout: 60_000,
31
85
  });
32
86
  success('Agent skill installed.');
33
- } catch (err) {
34
- warn('Skill install failed. You can install it manually later:');
35
- console.log(' npx skills add SpriteCook/skills');
87
+ return;
88
+ } catch {
89
+ // Primary method failed -- try fallback
90
+ }
91
+
92
+ // ── Fallback: direct download ────────────────────────────────────
93
+ if (selectedEditors.length > 0) {
94
+ const ok = await fallbackInstall(selectedEditors);
95
+ if (ok) return;
36
96
  }
97
+
98
+ warn('Skill install failed (git may not be installed).');
99
+ console.log(' You can install it manually later:');
100
+ console.log(' npx skills add SpriteCook/skills');
101
+ console.log(' Or install git and re-run this setup.');
37
102
  }