star-sdk-cli 0.1.2 → 0.1.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/dist/cli.mjs +200 -45
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -8,7 +8,7 @@ import * as os from "os";
8
8
  // src/skills.ts
9
9
  var SKILL_CONTENT = `---
10
10
  name: star-sdk
11
- description: Star SDK for browser game development. Use when building games, adding audio/sound effects, canvas rendering, leaderboards, or multiplayer. Covers Star.game(), Star.audio, Star.leaderboard, and Star.multiplayer APIs.
11
+ description: Use when you need a game that works on mobile without audio issues, has leaderboards without building a backend, or needs multiplayer without WebSocket complexity. Handles iOS Safari audio unlocking, DPR scaling, and coordinate conversion automatically.
12
12
  ---
13
13
 
14
14
  # Star SDK
@@ -72,9 +72,14 @@ function gameOver(finalScore) {
72
72
  }
73
73
  \`\`\`
74
74
 
75
- ### Mobile Audio (IMPORTANT)
75
+ ### Audio (It Just Works)
76
76
 
77
- Audio on mobile requires user interaction first. Star.audio handles unlocking automatically - just make sure the first \`play()\` call happens after a user interaction (click/tap).
77
+ Star.audio handles mobile audio unlocking automatically. Just call \`play()\` - no special handling needed.
78
+
79
+ \`\`\`javascript
80
+ Star.audio.preload({ coin: 'coin', jump: 'jump' });
81
+ Star.audio.play('coin'); // Works on mobile, desktop, everywhere
82
+ \`\`\`
78
83
 
79
84
  ### Coordinate Handling
80
85
 
@@ -1655,14 +1660,22 @@ function showHelp() {
1655
1660
  ${colors.bright}Star SDK CLI${colors.reset} v${VERSION}
1656
1661
 
1657
1662
  ${colors.dim}Commands:${colors.reset}
1658
- ${colors.cyan}init <name>${colors.reset} Register a new game
1659
- ${colors.cyan}install${colors.reset} Install Star SDK skill for Claude Code
1660
- ${colors.cyan}docs [topic]${colors.reset} Print API documentation (topics: audio, canvas, leaderboard, multiplayer)
1661
- ${colors.cyan}whoami${colors.reset} Show current configuration
1663
+ ${colors.cyan}init <name>${colors.reset} Register a new game
1664
+ ${colors.cyan}install [agent]${colors.reset} Install Star SDK docs for AI coding agents
1665
+ ${colors.cyan}docs [topic]${colors.reset} Print API documentation (default: all docs)
1666
+ ${colors.cyan}whoami${colors.reset} Show current configuration
1667
+
1668
+ ${colors.dim}Supported agents:${colors.reset}
1669
+ ${colors.cyan}claude${colors.reset} ${colors.dim}(default)${colors.reset} Claude Code \u2192 ~/.claude/skills/star-sdk/
1670
+ ${colors.cyan}codex${colors.reset} OpenAI Codex \u2192 ./AGENTS.md
1671
+ ${colors.cyan}cursor${colors.reset} Cursor \u2192 .cursor/rules/star-sdk.mdc
1672
+ ${colors.cyan}windsurf${colors.reset} Windsurf \u2192 .windsurf/rules/star-sdk.md
1673
+ ${colors.cyan}aider${colors.reset} Aider \u2192 ./CONVENTIONS.md
1662
1674
 
1663
1675
  ${colors.dim}Options:${colors.reset}
1664
1676
  --email <email> Email for higher rate limits (optional)
1665
- --project Install skill to project instead of personal (~/.claude)
1677
+ --global Install to global location (codex: ~/.codex/)
1678
+ --project Install to project directory
1666
1679
  --help Show this help message
1667
1680
  --version Show version
1668
1681
 
@@ -1670,14 +1683,19 @@ ${colors.dim}Examples:${colors.reset}
1670
1683
  ${colors.dim}# Register a new game${colors.reset}
1671
1684
  npx star-sdk init "My Awesome Game"
1672
1685
 
1673
- ${colors.dim}# Install SDK skill for Claude Code${colors.reset}
1674
- npx star-sdk install
1686
+ ${colors.dim}# Install for different AI agents${colors.reset}
1687
+ npx star-sdk install ${colors.dim}# Claude Code (default)${colors.reset}
1688
+ npx star-sdk install codex ${colors.dim}# OpenAI Codex${colors.reset}
1689
+ npx star-sdk install cursor ${colors.dim}# Cursor${colors.reset}
1690
+ npx star-sdk install windsurf ${colors.dim}# Windsurf${colors.reset}
1691
+ npx star-sdk install aider ${colors.dim}# Aider${colors.reset}
1675
1692
 
1676
- ${colors.dim}# Print API documentation${colors.reset}
1677
- npx star-sdk docs
1678
- npx star-sdk docs audio
1693
+ ${colors.dim}# Print API docs (works with any LLM)${colors.reset}
1694
+ npx star-sdk docs ${colors.dim}# All docs${colors.reset}
1695
+ npx star-sdk docs audio ${colors.dim}# Just audio API${colors.reset}
1696
+ npx star-sdk docs skill ${colors.dim}# Just main skill file${colors.reset}
1679
1697
 
1680
- ${colors.dim}Learn more:${colors.reset} https://buildwithstar.com/docs/sdk
1698
+ ${colors.dim}Learn more:${colors.reset} https://buildwithstar.com/docs
1681
1699
  `);
1682
1700
  }
1683
1701
  function showVersion() {
@@ -1756,13 +1774,11 @@ async function initCommand(name, email) {
1756
1774
  log(` ${colors.cyan}import Star from 'star-sdk';${colors.reset}`);
1757
1775
  log(` ${colors.cyan}Star.leaderboard.submit(1500);${colors.reset}`);
1758
1776
  log("");
1759
- if (process.env.CLAUDE_SESSION_ID) {
1760
- info(`Claude Code detected! Run ${colors.cyan}npx star-sdk install${colors.reset} to enable auto-discovery.`);
1761
- log("");
1762
- }
1777
+ log(`${colors.dim}Using an AI coding agent?${colors.reset}`);
1778
+ log(` ${colors.cyan}npx star-sdk install${colors.reset} ${colors.dim}Claude Code, Codex, Cursor, Windsurf, Aider${colors.reset}`);
1779
+ log("");
1763
1780
  log(`${colors.dim}Documentation:${colors.reset}`);
1764
- log(` ${colors.dim}Full docs:${colors.reset} ${colors.cyan}https://buildwithstar.com/docs/sdk${colors.reset}`);
1765
- log(` ${colors.dim}CLI docs:${colors.reset} ${colors.cyan}npx star-sdk docs${colors.reset}`);
1781
+ log(` ${colors.cyan}https://buildwithstar.com/docs${colors.reset}`);
1766
1782
  log("");
1767
1783
  } catch (err) {
1768
1784
  if (err.code === "ECONNREFUSED" || err.code === "ENOTFOUND") {
@@ -1794,47 +1810,183 @@ function whoamiCommand() {
1794
1810
  }
1795
1811
  log("");
1796
1812
  }
1797
- function installCommand(scope = "personal") {
1798
- const skillDir = scope === "personal" ? path.join(os.homedir(), ".claude", "skills", "star-sdk") : path.join(process.cwd(), ".claude", "skills", "star-sdk");
1813
+ function transformForStdout(content) {
1814
+ return content.replace(/\[(\w+)\.md\]\(\.\/\1\.md\)/g, "$1 (`npx star-sdk docs $1`)").replace(/see (\w+)\.md/g, "run `npx star-sdk docs $1`").replace(
1815
+ /For detailed API documentation, see the linked files above\./,
1816
+ "For detailed API docs: `npx star-sdk docs <topic>` where topic is audio, canvas, leaderboard, or multiplayer."
1817
+ );
1818
+ }
1819
+ function getAllDocsContent() {
1820
+ return `${SKILL_CONTENT}
1821
+
1822
+ ---
1823
+
1824
+ # Audio API
1825
+
1826
+ ${AUDIO_DOCS}
1827
+
1828
+ ---
1829
+
1830
+ # Canvas API
1831
+
1832
+ ${CANVAS_DOCS}
1833
+
1834
+ ---
1835
+
1836
+ # Leaderboard API
1837
+
1838
+ ${LEADERBOARD_DOCS}
1839
+
1840
+ ---
1841
+
1842
+ # Multiplayer API
1843
+
1844
+ ${MULTIPLAYER_DOCS}`;
1845
+ }
1846
+ function installClaudeCode(scope) {
1847
+ const skillDir = scope === "global" ? path.join(os.homedir(), ".claude", "skills", "star-sdk") : path.join(process.cwd(), ".claude", "skills", "star-sdk");
1848
+ fs.mkdirSync(skillDir, { recursive: true });
1849
+ fs.writeFileSync(path.join(skillDir, "SKILL.md"), SKILL_CONTENT);
1850
+ fs.writeFileSync(path.join(skillDir, "audio.md"), AUDIO_DOCS);
1851
+ fs.writeFileSync(path.join(skillDir, "canvas.md"), CANVAS_DOCS);
1852
+ fs.writeFileSync(path.join(skillDir, "leaderboard.md"), LEADERBOARD_DOCS);
1853
+ fs.writeFileSync(path.join(skillDir, "multiplayer.md"), MULTIPLAYER_DOCS);
1854
+ log("");
1855
+ success(`Star SDK skill installed to ${skillDir}`);
1856
+ log("");
1857
+ log(`${colors.dim}Claude Code will now auto-discover the Star SDK when you work on games.${colors.reset}`);
1858
+ log("");
1859
+ log(`${colors.dim}Installed files:${colors.reset}`);
1860
+ log(` SKILL.md ${colors.dim}Main skill entry point${colors.reset}`);
1861
+ log(` audio.md ${colors.dim}Star.audio API docs${colors.reset}`);
1862
+ log(` canvas.md ${colors.dim}Star.game() API docs${colors.reset}`);
1863
+ log(` leaderboard.md ${colors.dim}Star.leaderboard API docs${colors.reset}`);
1864
+ log(` multiplayer.md ${colors.dim}Star.multiplayer API docs${colors.reset}`);
1865
+ log("");
1866
+ }
1867
+ function installCodex(scope) {
1868
+ const content = `# Star SDK - Browser Game Development
1869
+
1870
+ ${getAllDocsContent()}`;
1871
+ const filePath = scope === "global" ? path.join(os.homedir(), ".codex", "AGENTS.md") : path.join(process.cwd(), "AGENTS.md");
1872
+ if (scope === "global") {
1873
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
1874
+ }
1875
+ if (fs.existsSync(filePath)) {
1876
+ const existing = fs.readFileSync(filePath, "utf-8");
1877
+ if (existing.includes("Star SDK")) {
1878
+ info(`Star SDK already present in ${filePath}`);
1879
+ return;
1880
+ }
1881
+ fs.writeFileSync(filePath, existing + "\n\n" + content);
1882
+ success(`Star SDK appended to ${filePath}`);
1883
+ } else {
1884
+ fs.writeFileSync(filePath, content);
1885
+ success(`Star SDK installed to ${filePath}`);
1886
+ }
1887
+ log("");
1888
+ log(`${colors.dim}Codex will now have access to Star SDK documentation.${colors.reset}`);
1889
+ log("");
1890
+ }
1891
+ function installCursor() {
1892
+ const rulesDir = path.join(process.cwd(), ".cursor", "rules");
1893
+ const filePath = path.join(rulesDir, "star-sdk.mdc");
1894
+ const content = `---
1895
+ description: Star SDK for browser game development with audio, canvas, leaderboards, and multiplayer
1896
+ globs: ["**/*.js", "**/*.ts", "**/*.jsx", "**/*.tsx", "**/*.html"]
1897
+ alwaysApply: false
1898
+ ---
1899
+
1900
+ ${getAllDocsContent()}`;
1901
+ fs.mkdirSync(rulesDir, { recursive: true });
1902
+ fs.writeFileSync(filePath, content);
1903
+ log("");
1904
+ success(`Star SDK installed to ${filePath}`);
1905
+ log("");
1906
+ log(`${colors.dim}Cursor will now have access to Star SDK documentation.${colors.reset}`);
1907
+ log(`${colors.dim}Use @star-sdk to reference it in Cursor chat.${colors.reset}`);
1908
+ log("");
1909
+ }
1910
+ function installWindsurf() {
1911
+ const rulesDir = path.join(process.cwd(), ".windsurf", "rules");
1912
+ const filePath = path.join(rulesDir, "star-sdk.md");
1913
+ const content = `# Star SDK - Browser Game Development
1914
+
1915
+ ${getAllDocsContent()}`;
1916
+ fs.mkdirSync(rulesDir, { recursive: true });
1917
+ fs.writeFileSync(filePath, content);
1918
+ log("");
1919
+ success(`Star SDK installed to ${filePath}`);
1920
+ log("");
1921
+ log(`${colors.dim}Windsurf will now have access to Star SDK documentation.${colors.reset}`);
1922
+ log("");
1923
+ }
1924
+ function installAider() {
1925
+ const filePath = path.join(process.cwd(), "CONVENTIONS.md");
1926
+ const content = `# Star SDK - Browser Game Development
1927
+
1928
+ ${getAllDocsContent()}`;
1929
+ if (fs.existsSync(filePath)) {
1930
+ const existing = fs.readFileSync(filePath, "utf-8");
1931
+ if (existing.includes("Star SDK")) {
1932
+ info(`Star SDK already present in ${filePath}`);
1933
+ return;
1934
+ }
1935
+ fs.writeFileSync(filePath, existing + "\n\n" + content);
1936
+ success(`Star SDK appended to ${filePath}`);
1937
+ } else {
1938
+ fs.writeFileSync(filePath, content);
1939
+ success(`Star SDK installed to ${filePath}`);
1940
+ }
1941
+ log("");
1942
+ log(`${colors.dim}Add to aider with: aider --read CONVENTIONS.md${colors.reset}`);
1943
+ log("");
1944
+ }
1945
+ function installCommand(agent = "claude", scope = "global") {
1799
1946
  try {
1800
- fs.mkdirSync(skillDir, { recursive: true });
1801
- fs.writeFileSync(path.join(skillDir, "SKILL.md"), SKILL_CONTENT);
1802
- fs.writeFileSync(path.join(skillDir, "audio.md"), AUDIO_DOCS);
1803
- fs.writeFileSync(path.join(skillDir, "canvas.md"), CANVAS_DOCS);
1804
- fs.writeFileSync(path.join(skillDir, "leaderboard.md"), LEADERBOARD_DOCS);
1805
- fs.writeFileSync(path.join(skillDir, "multiplayer.md"), MULTIPLAYER_DOCS);
1806
- log("");
1807
- success(`Star SDK skill installed to ${skillDir}`);
1808
- log("");
1809
- log(`${colors.dim}Claude Code will now auto-discover the Star SDK when you work on games.${colors.reset}`);
1810
- log("");
1811
- log(`${colors.dim}Installed files:${colors.reset}`);
1812
- log(` SKILL.md ${colors.dim}Main skill entry point${colors.reset}`);
1813
- log(` audio.md ${colors.dim}Star.audio API docs${colors.reset}`);
1814
- log(` canvas.md ${colors.dim}Star.game() API docs${colors.reset}`);
1815
- log(` leaderboard.md ${colors.dim}Star.leaderboard API docs${colors.reset}`);
1816
- log(` multiplayer.md ${colors.dim}Star.multiplayer API docs${colors.reset}`);
1817
- log("");
1947
+ switch (agent) {
1948
+ case "claude":
1949
+ installClaudeCode(scope);
1950
+ break;
1951
+ case "codex":
1952
+ installCodex(scope);
1953
+ break;
1954
+ case "cursor":
1955
+ installCursor();
1956
+ break;
1957
+ case "windsurf":
1958
+ installWindsurf();
1959
+ break;
1960
+ case "aider":
1961
+ installAider();
1962
+ break;
1963
+ default:
1964
+ error(`Unknown agent: ${agent}`);
1965
+ log("");
1966
+ log("Supported agents: claude, codex, cursor, windsurf, aider");
1967
+ process.exit(1);
1968
+ }
1818
1969
  } catch (err) {
1819
- error(`Failed to install skill: ${err.message}`);
1970
+ error(`Failed to install: ${err.message}`);
1820
1971
  process.exit(1);
1821
1972
  }
1822
1973
  }
1823
1974
  function docsCommand(topic) {
1824
1975
  const docs = {
1976
+ skill: SKILL_CONTENT,
1825
1977
  audio: AUDIO_DOCS,
1826
1978
  canvas: CANVAS_DOCS,
1827
1979
  leaderboard: LEADERBOARD_DOCS,
1828
1980
  multiplayer: MULTIPLAYER_DOCS
1829
1981
  };
1830
1982
  if (!topic) {
1831
- console.log(SKILL_CONTENT);
1983
+ console.log(transformForStdout(SKILL_CONTENT));
1832
1984
  } else if (docs[topic]) {
1833
1985
  console.log(docs[topic]);
1834
1986
  } else {
1835
1987
  error(`Unknown topic: ${topic}`);
1836
1988
  log("");
1837
- log("Available topics: audio, canvas, leaderboard, multiplayer");
1989
+ log("Available topics: skill, audio, canvas, leaderboard, multiplayer");
1838
1990
  process.exit(1);
1839
1991
  }
1840
1992
  }
@@ -1877,9 +2029,12 @@ async function main() {
1877
2029
  case "init":
1878
2030
  await initCommand(positional[0], email);
1879
2031
  break;
1880
- case "install":
1881
- installCommand(flags.project ? "project" : "personal");
2032
+ case "install": {
2033
+ const agent = positional[0] || "claude";
2034
+ const scope = flags.project ? "project" : "global";
2035
+ installCommand(agent, scope);
1882
2036
  break;
2037
+ }
1883
2038
  case "docs":
1884
2039
  case "skill":
1885
2040
  case "prompt":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "star-sdk-cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "CLI tool for Star SDK - register games and manage leaderboards",
5
5
  "type": "module",
6
6
  "bin": {