star-sdk-cli 0.1.2 → 0.1.3
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/dist/cli.mjs +188 -41
- 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:
|
|
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
|
-
###
|
|
75
|
+
### Audio (It Just Works)
|
|
76
76
|
|
|
77
|
-
|
|
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}
|
|
1659
|
-
${colors.cyan}install${colors.reset}
|
|
1660
|
-
${colors.cyan}docs [topic]${colors.reset}
|
|
1661
|
-
${colors.cyan}whoami${colors.reset}
|
|
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 to stdout
|
|
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
|
-
--
|
|
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,18 @@ ${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
|
|
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
|
|
1693
|
+
${colors.dim}# Print API docs (works with any LLM)${colors.reset}
|
|
1677
1694
|
npx star-sdk docs
|
|
1678
1695
|
npx star-sdk docs audio
|
|
1679
1696
|
|
|
1680
|
-
${colors.dim}Learn more:${colors.reset} https://buildwithstar.com/docs
|
|
1697
|
+
${colors.dim}Learn more:${colors.reset} https://buildwithstar.com/docs
|
|
1681
1698
|
`);
|
|
1682
1699
|
}
|
|
1683
1700
|
function showVersion() {
|
|
@@ -1756,13 +1773,11 @@ async function initCommand(name, email) {
|
|
|
1756
1773
|
log(` ${colors.cyan}import Star from 'star-sdk';${colors.reset}`);
|
|
1757
1774
|
log(` ${colors.cyan}Star.leaderboard.submit(1500);${colors.reset}`);
|
|
1758
1775
|
log("");
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
}
|
|
1776
|
+
log(`${colors.dim}Using an AI coding agent?${colors.reset}`);
|
|
1777
|
+
log(` ${colors.cyan}npx star-sdk install${colors.reset} ${colors.dim}Claude Code, Codex, Cursor, Windsurf, Aider${colors.reset}`);
|
|
1778
|
+
log("");
|
|
1763
1779
|
log(`${colors.dim}Documentation:${colors.reset}`);
|
|
1764
|
-
log(` ${colors.
|
|
1765
|
-
log(` ${colors.dim}CLI docs:${colors.reset} ${colors.cyan}npx star-sdk docs${colors.reset}`);
|
|
1780
|
+
log(` ${colors.cyan}https://buildwithstar.com/docs${colors.reset}`);
|
|
1766
1781
|
log("");
|
|
1767
1782
|
} catch (err) {
|
|
1768
1783
|
if (err.code === "ECONNREFUSED" || err.code === "ENOTFOUND") {
|
|
@@ -1794,29 +1809,158 @@ function whoamiCommand() {
|
|
|
1794
1809
|
}
|
|
1795
1810
|
log("");
|
|
1796
1811
|
}
|
|
1797
|
-
function
|
|
1798
|
-
|
|
1812
|
+
function getAllDocsContent() {
|
|
1813
|
+
return `${SKILL_CONTENT}
|
|
1814
|
+
|
|
1815
|
+
---
|
|
1816
|
+
|
|
1817
|
+
# Audio API
|
|
1818
|
+
|
|
1819
|
+
${AUDIO_DOCS}
|
|
1820
|
+
|
|
1821
|
+
---
|
|
1822
|
+
|
|
1823
|
+
# Canvas API
|
|
1824
|
+
|
|
1825
|
+
${CANVAS_DOCS}
|
|
1826
|
+
|
|
1827
|
+
---
|
|
1828
|
+
|
|
1829
|
+
# Leaderboard API
|
|
1830
|
+
|
|
1831
|
+
${LEADERBOARD_DOCS}
|
|
1832
|
+
|
|
1833
|
+
---
|
|
1834
|
+
|
|
1835
|
+
# Multiplayer API
|
|
1836
|
+
|
|
1837
|
+
${MULTIPLAYER_DOCS}`;
|
|
1838
|
+
}
|
|
1839
|
+
function installClaudeCode(scope) {
|
|
1840
|
+
const skillDir = scope === "global" ? path.join(os.homedir(), ".claude", "skills", "star-sdk") : path.join(process.cwd(), ".claude", "skills", "star-sdk");
|
|
1841
|
+
fs.mkdirSync(skillDir, { recursive: true });
|
|
1842
|
+
fs.writeFileSync(path.join(skillDir, "SKILL.md"), SKILL_CONTENT);
|
|
1843
|
+
fs.writeFileSync(path.join(skillDir, "audio.md"), AUDIO_DOCS);
|
|
1844
|
+
fs.writeFileSync(path.join(skillDir, "canvas.md"), CANVAS_DOCS);
|
|
1845
|
+
fs.writeFileSync(path.join(skillDir, "leaderboard.md"), LEADERBOARD_DOCS);
|
|
1846
|
+
fs.writeFileSync(path.join(skillDir, "multiplayer.md"), MULTIPLAYER_DOCS);
|
|
1847
|
+
log("");
|
|
1848
|
+
success(`Star SDK skill installed to ${skillDir}`);
|
|
1849
|
+
log("");
|
|
1850
|
+
log(`${colors.dim}Claude Code will now auto-discover the Star SDK when you work on games.${colors.reset}`);
|
|
1851
|
+
log("");
|
|
1852
|
+
log(`${colors.dim}Installed files:${colors.reset}`);
|
|
1853
|
+
log(` SKILL.md ${colors.dim}Main skill entry point${colors.reset}`);
|
|
1854
|
+
log(` audio.md ${colors.dim}Star.audio API docs${colors.reset}`);
|
|
1855
|
+
log(` canvas.md ${colors.dim}Star.game() API docs${colors.reset}`);
|
|
1856
|
+
log(` leaderboard.md ${colors.dim}Star.leaderboard API docs${colors.reset}`);
|
|
1857
|
+
log(` multiplayer.md ${colors.dim}Star.multiplayer API docs${colors.reset}`);
|
|
1858
|
+
log("");
|
|
1859
|
+
}
|
|
1860
|
+
function installCodex(scope) {
|
|
1861
|
+
const content = `# Star SDK - Browser Game Development
|
|
1862
|
+
|
|
1863
|
+
${getAllDocsContent()}`;
|
|
1864
|
+
const filePath = scope === "global" ? path.join(os.homedir(), ".codex", "AGENTS.md") : path.join(process.cwd(), "AGENTS.md");
|
|
1865
|
+
if (scope === "global") {
|
|
1866
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
1867
|
+
}
|
|
1868
|
+
if (fs.existsSync(filePath)) {
|
|
1869
|
+
const existing = fs.readFileSync(filePath, "utf-8");
|
|
1870
|
+
if (existing.includes("Star SDK")) {
|
|
1871
|
+
info(`Star SDK already present in ${filePath}`);
|
|
1872
|
+
return;
|
|
1873
|
+
}
|
|
1874
|
+
fs.writeFileSync(filePath, existing + "\n\n" + content);
|
|
1875
|
+
success(`Star SDK appended to ${filePath}`);
|
|
1876
|
+
} else {
|
|
1877
|
+
fs.writeFileSync(filePath, content);
|
|
1878
|
+
success(`Star SDK installed to ${filePath}`);
|
|
1879
|
+
}
|
|
1880
|
+
log("");
|
|
1881
|
+
log(`${colors.dim}Codex will now have access to Star SDK documentation.${colors.reset}`);
|
|
1882
|
+
log("");
|
|
1883
|
+
}
|
|
1884
|
+
function installCursor() {
|
|
1885
|
+
const rulesDir = path.join(process.cwd(), ".cursor", "rules");
|
|
1886
|
+
const filePath = path.join(rulesDir, "star-sdk.mdc");
|
|
1887
|
+
const content = `---
|
|
1888
|
+
description: Star SDK for browser game development with audio, canvas, leaderboards, and multiplayer
|
|
1889
|
+
globs: ["**/*.js", "**/*.ts", "**/*.jsx", "**/*.tsx", "**/*.html"]
|
|
1890
|
+
alwaysApply: false
|
|
1891
|
+
---
|
|
1892
|
+
|
|
1893
|
+
${getAllDocsContent()}`;
|
|
1894
|
+
fs.mkdirSync(rulesDir, { recursive: true });
|
|
1895
|
+
fs.writeFileSync(filePath, content);
|
|
1896
|
+
log("");
|
|
1897
|
+
success(`Star SDK installed to ${filePath}`);
|
|
1898
|
+
log("");
|
|
1899
|
+
log(`${colors.dim}Cursor will now have access to Star SDK documentation.${colors.reset}`);
|
|
1900
|
+
log(`${colors.dim}Use @star-sdk to reference it in Cursor chat.${colors.reset}`);
|
|
1901
|
+
log("");
|
|
1902
|
+
}
|
|
1903
|
+
function installWindsurf() {
|
|
1904
|
+
const rulesDir = path.join(process.cwd(), ".windsurf", "rules");
|
|
1905
|
+
const filePath = path.join(rulesDir, "star-sdk.md");
|
|
1906
|
+
const content = `# Star SDK - Browser Game Development
|
|
1907
|
+
|
|
1908
|
+
${getAllDocsContent()}`;
|
|
1909
|
+
fs.mkdirSync(rulesDir, { recursive: true });
|
|
1910
|
+
fs.writeFileSync(filePath, content);
|
|
1911
|
+
log("");
|
|
1912
|
+
success(`Star SDK installed to ${filePath}`);
|
|
1913
|
+
log("");
|
|
1914
|
+
log(`${colors.dim}Windsurf will now have access to Star SDK documentation.${colors.reset}`);
|
|
1915
|
+
log("");
|
|
1916
|
+
}
|
|
1917
|
+
function installAider() {
|
|
1918
|
+
const filePath = path.join(process.cwd(), "CONVENTIONS.md");
|
|
1919
|
+
const content = `# Star SDK - Browser Game Development
|
|
1920
|
+
|
|
1921
|
+
${getAllDocsContent()}`;
|
|
1922
|
+
if (fs.existsSync(filePath)) {
|
|
1923
|
+
const existing = fs.readFileSync(filePath, "utf-8");
|
|
1924
|
+
if (existing.includes("Star SDK")) {
|
|
1925
|
+
info(`Star SDK already present in ${filePath}`);
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
fs.writeFileSync(filePath, existing + "\n\n" + content);
|
|
1929
|
+
success(`Star SDK appended to ${filePath}`);
|
|
1930
|
+
} else {
|
|
1931
|
+
fs.writeFileSync(filePath, content);
|
|
1932
|
+
success(`Star SDK installed to ${filePath}`);
|
|
1933
|
+
}
|
|
1934
|
+
log("");
|
|
1935
|
+
log(`${colors.dim}Add to aider with: aider --read CONVENTIONS.md${colors.reset}`);
|
|
1936
|
+
log("");
|
|
1937
|
+
}
|
|
1938
|
+
function installCommand(agent = "claude", scope = "global") {
|
|
1799
1939
|
try {
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1940
|
+
switch (agent) {
|
|
1941
|
+
case "claude":
|
|
1942
|
+
installClaudeCode(scope);
|
|
1943
|
+
break;
|
|
1944
|
+
case "codex":
|
|
1945
|
+
installCodex(scope);
|
|
1946
|
+
break;
|
|
1947
|
+
case "cursor":
|
|
1948
|
+
installCursor();
|
|
1949
|
+
break;
|
|
1950
|
+
case "windsurf":
|
|
1951
|
+
installWindsurf();
|
|
1952
|
+
break;
|
|
1953
|
+
case "aider":
|
|
1954
|
+
installAider();
|
|
1955
|
+
break;
|
|
1956
|
+
default:
|
|
1957
|
+
error(`Unknown agent: ${agent}`);
|
|
1958
|
+
log("");
|
|
1959
|
+
log("Supported agents: claude, codex, cursor, windsurf, aider");
|
|
1960
|
+
process.exit(1);
|
|
1961
|
+
}
|
|
1818
1962
|
} catch (err) {
|
|
1819
|
-
error(`Failed to install
|
|
1963
|
+
error(`Failed to install: ${err.message}`);
|
|
1820
1964
|
process.exit(1);
|
|
1821
1965
|
}
|
|
1822
1966
|
}
|
|
@@ -1877,9 +2021,12 @@ async function main() {
|
|
|
1877
2021
|
case "init":
|
|
1878
2022
|
await initCommand(positional[0], email);
|
|
1879
2023
|
break;
|
|
1880
|
-
case "install":
|
|
1881
|
-
|
|
2024
|
+
case "install": {
|
|
2025
|
+
const agent = positional[0] || "claude";
|
|
2026
|
+
const scope = flags.project ? "project" : "global";
|
|
2027
|
+
installCommand(agent, scope);
|
|
1882
2028
|
break;
|
|
2029
|
+
}
|
|
1883
2030
|
case "docs":
|
|
1884
2031
|
case "skill":
|
|
1885
2032
|
case "prompt":
|