@onexapis/cli 1.1.45 → 1.1.46
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.js +220 -12
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +220 -12
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/templates/default/.cursorrules +126 -0
- package/templates/default/AGENTS.md +126 -0
- package/templates/default/CLAUDE.md +88 -1726
- package/templates/default/THEME_REFERENCE.md +1764 -0
package/dist/cli.mjs
CHANGED
|
@@ -2673,12 +2673,12 @@ async function validateCommand(options) {
|
|
|
2673
2673
|
}
|
|
2674
2674
|
themeToValidate = options.theme;
|
|
2675
2675
|
} else {
|
|
2676
|
-
const
|
|
2676
|
+
const isThemeDir2 = [
|
|
2677
2677
|
"theme.config.ts",
|
|
2678
2678
|
"bundle-entry.ts",
|
|
2679
2679
|
"manifest.ts"
|
|
2680
2680
|
].some((f) => fs.existsSync(path9.join(process.cwd(), f)));
|
|
2681
|
-
if (
|
|
2681
|
+
if (isThemeDir2) {
|
|
2682
2682
|
themeToValidate = path9.basename(process.cwd());
|
|
2683
2683
|
logger.info(`Validating current theme: ${themeToValidate}`);
|
|
2684
2684
|
} else {
|
|
@@ -3070,12 +3070,12 @@ async function buildCommand(options) {
|
|
|
3070
3070
|
process.exit(1);
|
|
3071
3071
|
}
|
|
3072
3072
|
} else {
|
|
3073
|
-
const
|
|
3073
|
+
const isThemeDir2 = [
|
|
3074
3074
|
"theme.config.ts",
|
|
3075
3075
|
"bundle-entry.ts",
|
|
3076
3076
|
"manifest.ts"
|
|
3077
3077
|
].some((f) => fs.existsSync(path9.join(process.cwd(), f)));
|
|
3078
|
-
if (
|
|
3078
|
+
if (isThemeDir2) {
|
|
3079
3079
|
themePath = process.cwd();
|
|
3080
3080
|
themeName = path9.basename(themePath);
|
|
3081
3081
|
logger.info(`Building current theme: ${themeName}`);
|
|
@@ -3206,12 +3206,12 @@ async function packageCommand(options) {
|
|
|
3206
3206
|
process.exit(1);
|
|
3207
3207
|
}
|
|
3208
3208
|
} else {
|
|
3209
|
-
const
|
|
3209
|
+
const isThemeDir2 = [
|
|
3210
3210
|
"theme.config.ts",
|
|
3211
3211
|
"bundle-entry.ts",
|
|
3212
3212
|
"manifest.ts"
|
|
3213
3213
|
].some((f) => fs.existsSync(path9.join(process.cwd(), f)));
|
|
3214
|
-
if (
|
|
3214
|
+
if (isThemeDir2) {
|
|
3215
3215
|
themePath = process.cwd();
|
|
3216
3216
|
themeName = path9.basename(themePath);
|
|
3217
3217
|
logger.info(`Packaging current theme: ${themeName}`);
|
|
@@ -3747,8 +3747,8 @@ function runInstall(cwd) {
|
|
|
3747
3747
|
});
|
|
3748
3748
|
}
|
|
3749
3749
|
async function promptThemeName(originalName) {
|
|
3750
|
-
const { default:
|
|
3751
|
-
const { themeName } = await
|
|
3750
|
+
const { default: inquirer8 } = await import('inquirer');
|
|
3751
|
+
const { themeName } = await inquirer8.prompt([
|
|
3752
3752
|
{
|
|
3753
3753
|
type: "input",
|
|
3754
3754
|
name: "themeName",
|
|
@@ -4225,12 +4225,12 @@ async function devCommand(options) {
|
|
|
4225
4225
|
process.exit(1);
|
|
4226
4226
|
}
|
|
4227
4227
|
} else {
|
|
4228
|
-
const
|
|
4228
|
+
const isThemeDir2 = [
|
|
4229
4229
|
"theme.config.ts",
|
|
4230
4230
|
"bundle-entry.ts",
|
|
4231
4231
|
"manifest.ts"
|
|
4232
4232
|
].some((f) => fs.existsSync(path9.join(process.cwd(), f)));
|
|
4233
|
-
if (
|
|
4233
|
+
if (isThemeDir2) {
|
|
4234
4234
|
themePath = process.cwd();
|
|
4235
4235
|
themeName = path9.basename(themePath);
|
|
4236
4236
|
} else {
|
|
@@ -4658,12 +4658,12 @@ async function publishCommand(options) {
|
|
|
4658
4658
|
if (options.theme) {
|
|
4659
4659
|
themePath = path9.resolve(options.theme);
|
|
4660
4660
|
} else {
|
|
4661
|
-
const
|
|
4661
|
+
const isThemeDir2 = [
|
|
4662
4662
|
"theme.config.ts",
|
|
4663
4663
|
"bundle-entry.ts",
|
|
4664
4664
|
"manifest.ts"
|
|
4665
4665
|
].some((f) => fs.existsSync(path9.join(process.cwd(), f)));
|
|
4666
|
-
if (
|
|
4666
|
+
if (isThemeDir2) {
|
|
4667
4667
|
themePath = process.cwd();
|
|
4668
4668
|
} else {
|
|
4669
4669
|
logger.error(
|
|
@@ -5013,6 +5013,210 @@ async function createZip(sourceDir, outputPath, exclude) {
|
|
|
5013
5013
|
});
|
|
5014
5014
|
}
|
|
5015
5015
|
|
|
5016
|
+
// src/commands/mcp.ts
|
|
5017
|
+
init_logger();
|
|
5018
|
+
var AI_CONTEXT_FILES = [
|
|
5019
|
+
"CLAUDE.md",
|
|
5020
|
+
"AGENTS.md",
|
|
5021
|
+
".cursorrules",
|
|
5022
|
+
"THEME_REFERENCE.md",
|
|
5023
|
+
".mcp.json"
|
|
5024
|
+
];
|
|
5025
|
+
function resolveTargetDir(opts) {
|
|
5026
|
+
return path9.resolve(opts.cwd ?? process.cwd());
|
|
5027
|
+
}
|
|
5028
|
+
function resolveDefaultTemplateDir() {
|
|
5029
|
+
return path9.join(getTemplatesDir(), "default");
|
|
5030
|
+
}
|
|
5031
|
+
function isThemeDir(dir) {
|
|
5032
|
+
return fs.existsSync(path9.join(dir, "theme.config.ts")) || fs.existsSync(path9.join(dir, "theme.config.js"));
|
|
5033
|
+
}
|
|
5034
|
+
function inspectFiles(templateDir, targetDir) {
|
|
5035
|
+
return AI_CONTEXT_FILES.map((name) => {
|
|
5036
|
+
const templatePath = path9.join(templateDir, name);
|
|
5037
|
+
const targetPath = path9.join(targetDir, name);
|
|
5038
|
+
const exists = fs.existsSync(targetPath);
|
|
5039
|
+
let identical = false;
|
|
5040
|
+
if (exists && fs.existsSync(templatePath)) {
|
|
5041
|
+
try {
|
|
5042
|
+
const a = fs.readFileSync(templatePath, "utf-8");
|
|
5043
|
+
const b = fs.readFileSync(targetPath, "utf-8");
|
|
5044
|
+
identical = a.replace(/\r\n/g, "\n") === b.replace(/\r\n/g, "\n");
|
|
5045
|
+
} catch {
|
|
5046
|
+
identical = false;
|
|
5047
|
+
}
|
|
5048
|
+
}
|
|
5049
|
+
return { name, templatePath, targetPath, exists, identical };
|
|
5050
|
+
});
|
|
5051
|
+
}
|
|
5052
|
+
async function mcpSetupCommand(options = {}) {
|
|
5053
|
+
const targetDir = resolveTargetDir(options);
|
|
5054
|
+
const templateDir = resolveDefaultTemplateDir();
|
|
5055
|
+
logger.header("Install OneX MCP context files");
|
|
5056
|
+
logger.log(`Target: ${targetDir}`);
|
|
5057
|
+
logger.log("");
|
|
5058
|
+
if (!isThemeDir(targetDir)) {
|
|
5059
|
+
logger.error(
|
|
5060
|
+
`${targetDir} does not look like an OneX theme (no theme.config.ts found).`
|
|
5061
|
+
);
|
|
5062
|
+
logger.log("Run this command from the root of your theme project.");
|
|
5063
|
+
process.exitCode = 1;
|
|
5064
|
+
return;
|
|
5065
|
+
}
|
|
5066
|
+
const statuses = inspectFiles(templateDir, targetDir);
|
|
5067
|
+
const missing = statuses.filter((s) => !s.exists);
|
|
5068
|
+
if (missing.length === 0) {
|
|
5069
|
+
logger.success("All AI context files are already present.");
|
|
5070
|
+
logger.log("Run `onexthm mcp upgrade` to refresh them to the latest version.");
|
|
5071
|
+
return;
|
|
5072
|
+
}
|
|
5073
|
+
logger.log(`Will install ${missing.length} file(s):`);
|
|
5074
|
+
for (const s of missing) logger.log(` + ${s.name}`);
|
|
5075
|
+
logger.log("");
|
|
5076
|
+
if (!options.yes) {
|
|
5077
|
+
const { confirm } = await inquirer.prompt([
|
|
5078
|
+
{
|
|
5079
|
+
type: "confirm",
|
|
5080
|
+
name: "confirm",
|
|
5081
|
+
message: "Proceed?",
|
|
5082
|
+
default: true
|
|
5083
|
+
}
|
|
5084
|
+
]);
|
|
5085
|
+
if (!confirm) {
|
|
5086
|
+
logger.log("Cancelled.");
|
|
5087
|
+
return;
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
5090
|
+
for (const s of missing) {
|
|
5091
|
+
if (!fs.existsSync(s.templatePath)) {
|
|
5092
|
+
logger.warning(` ! ${s.name} not in template \u2014 skipped`);
|
|
5093
|
+
continue;
|
|
5094
|
+
}
|
|
5095
|
+
await fs.copy(s.templatePath, s.targetPath);
|
|
5096
|
+
logger.success(` \u2713 ${s.name}`);
|
|
5097
|
+
}
|
|
5098
|
+
logger.log("");
|
|
5099
|
+
logger.success("Done. Restart your AI client to pick up the new MCP server.");
|
|
5100
|
+
logger.log("");
|
|
5101
|
+
logger.log("Tip: if your theme uses the Figma MCP, edit .mcp.json and");
|
|
5102
|
+
logger.log("replace __FIGMA_API_KEY__ with your Figma personal access token.");
|
|
5103
|
+
}
|
|
5104
|
+
async function mcpUpgradeCommand(options = {}) {
|
|
5105
|
+
const targetDir = resolveTargetDir(options);
|
|
5106
|
+
const templateDir = resolveDefaultTemplateDir();
|
|
5107
|
+
logger.header("Upgrade OneX MCP context files");
|
|
5108
|
+
logger.log(`Target: ${targetDir}`);
|
|
5109
|
+
logger.log("");
|
|
5110
|
+
if (!isThemeDir(targetDir)) {
|
|
5111
|
+
logger.error(
|
|
5112
|
+
`${targetDir} does not look like an OneX theme (no theme.config.ts found).`
|
|
5113
|
+
);
|
|
5114
|
+
process.exitCode = 1;
|
|
5115
|
+
return;
|
|
5116
|
+
}
|
|
5117
|
+
const statuses = inspectFiles(templateDir, targetDir);
|
|
5118
|
+
const toUpgrade = statuses.filter(
|
|
5119
|
+
(s) => !s.identical && s.name !== ".mcp.json"
|
|
5120
|
+
);
|
|
5121
|
+
const mcpJsonStatus = statuses.find((s) => s.name === ".mcp.json");
|
|
5122
|
+
if (mcpJsonStatus && !mcpJsonStatus.exists) {
|
|
5123
|
+
logger.warning(
|
|
5124
|
+
".mcp.json is missing. Run `onexthm mcp setup` to install it."
|
|
5125
|
+
);
|
|
5126
|
+
}
|
|
5127
|
+
if (toUpgrade.length === 0) {
|
|
5128
|
+
logger.success("All AI context files are already up to date.");
|
|
5129
|
+
return;
|
|
5130
|
+
}
|
|
5131
|
+
logger.log("Files to update:");
|
|
5132
|
+
for (const s of toUpgrade) {
|
|
5133
|
+
const tag = !s.exists ? "+ new" : "~ changed";
|
|
5134
|
+
logger.log(` ${tag} ${s.name}`);
|
|
5135
|
+
}
|
|
5136
|
+
logger.log("");
|
|
5137
|
+
logger.log("(.mcp.json is never auto-upgraded \u2014 edit by hand if needed.)");
|
|
5138
|
+
logger.log("");
|
|
5139
|
+
if (!options.yes) {
|
|
5140
|
+
const { confirm } = await inquirer.prompt([
|
|
5141
|
+
{
|
|
5142
|
+
type: "confirm",
|
|
5143
|
+
name: "confirm",
|
|
5144
|
+
message: "Overwrite the file(s) above?",
|
|
5145
|
+
default: true
|
|
5146
|
+
}
|
|
5147
|
+
]);
|
|
5148
|
+
if (!confirm) {
|
|
5149
|
+
logger.log("Cancelled.");
|
|
5150
|
+
return;
|
|
5151
|
+
}
|
|
5152
|
+
}
|
|
5153
|
+
for (const s of toUpgrade) {
|
|
5154
|
+
if (!fs.existsSync(s.templatePath)) {
|
|
5155
|
+
logger.warning(` ! ${s.name} not in template \u2014 skipped`);
|
|
5156
|
+
continue;
|
|
5157
|
+
}
|
|
5158
|
+
await fs.copy(s.templatePath, s.targetPath, { overwrite: true });
|
|
5159
|
+
logger.success(` \u2713 ${s.name}`);
|
|
5160
|
+
}
|
|
5161
|
+
logger.log("");
|
|
5162
|
+
logger.success("Done. Restart your AI client to pick up the new context.");
|
|
5163
|
+
}
|
|
5164
|
+
async function mcpDoctorCommand(options = {}) {
|
|
5165
|
+
const targetDir = resolveTargetDir(options);
|
|
5166
|
+
const templateDir = resolveDefaultTemplateDir();
|
|
5167
|
+
logger.header("OneX MCP doctor");
|
|
5168
|
+
logger.log(`Target: ${targetDir}`);
|
|
5169
|
+
logger.log("");
|
|
5170
|
+
if (!isThemeDir(targetDir)) {
|
|
5171
|
+
logger.error("Not an OneX theme directory (no theme.config.ts).");
|
|
5172
|
+
process.exitCode = 1;
|
|
5173
|
+
return;
|
|
5174
|
+
}
|
|
5175
|
+
logger.success("theme.config.ts present");
|
|
5176
|
+
const mcpJsonPath = path9.join(targetDir, ".mcp.json");
|
|
5177
|
+
if (!fs.existsSync(mcpJsonPath)) {
|
|
5178
|
+
logger.error(".mcp.json missing \u2014 run `onexthm mcp setup`");
|
|
5179
|
+
} else {
|
|
5180
|
+
try {
|
|
5181
|
+
const mcpJson = JSON.parse(fs.readFileSync(mcpJsonPath, "utf-8"));
|
|
5182
|
+
const servers = mcpJson?.mcpServers ?? {};
|
|
5183
|
+
if (servers.onexthm) {
|
|
5184
|
+
logger.success(".mcp.json registers `onexthm`");
|
|
5185
|
+
} else {
|
|
5186
|
+
logger.error(".mcp.json does not register `onexthm`");
|
|
5187
|
+
}
|
|
5188
|
+
if (servers.figma) {
|
|
5189
|
+
const arg = (servers.figma.args ?? []).join(" ");
|
|
5190
|
+
if (arg.includes("__FIGMA_API_KEY__")) {
|
|
5191
|
+
logger.warning("figma server uses placeholder API key \u2014 replace __FIGMA_API_KEY__");
|
|
5192
|
+
} else {
|
|
5193
|
+
logger.success(".mcp.json registers `figma`");
|
|
5194
|
+
}
|
|
5195
|
+
}
|
|
5196
|
+
} catch (err) {
|
|
5197
|
+
logger.error(`.mcp.json could not be parsed: ${err.message}`);
|
|
5198
|
+
}
|
|
5199
|
+
}
|
|
5200
|
+
const statuses = inspectFiles(templateDir, targetDir).filter(
|
|
5201
|
+
(s) => s.name !== ".mcp.json"
|
|
5202
|
+
);
|
|
5203
|
+
for (const s of statuses) {
|
|
5204
|
+
if (!s.exists) {
|
|
5205
|
+
logger.warning(`${s.name} missing`);
|
|
5206
|
+
} else if (!s.identical) {
|
|
5207
|
+
logger.warning(`${s.name} is out of date \u2014 run \`onexthm mcp upgrade\``);
|
|
5208
|
+
} else {
|
|
5209
|
+
logger.success(`${s.name} up to date`);
|
|
5210
|
+
}
|
|
5211
|
+
}
|
|
5212
|
+
const registryPath = path9.join(targetDir, "sections-registry.ts");
|
|
5213
|
+
if (fs.existsSync(registryPath)) {
|
|
5214
|
+
logger.success("sections-registry.ts present");
|
|
5215
|
+
} else {
|
|
5216
|
+
logger.warning("sections-registry.ts missing \u2014 section tools won't auto-register");
|
|
5217
|
+
}
|
|
5218
|
+
}
|
|
5219
|
+
|
|
5016
5220
|
// src/cli.ts
|
|
5017
5221
|
dotenv.config({
|
|
5018
5222
|
path: path9.join(process.cwd(), ".env.local"),
|
|
@@ -5078,6 +5282,10 @@ program.command("config").description("Configure OneX CLI credentials (AWS, API
|
|
|
5078
5282
|
program.command("login").description("Login to OneX platform").action(loginCommand);
|
|
5079
5283
|
program.command("logout").description("Logout from OneX platform").action(logoutCommand);
|
|
5080
5284
|
program.command("whoami").description("Show current logged-in developer").action(whoamiCommand);
|
|
5285
|
+
var mcpCmd = program.command("mcp").description("Manage MCP server registration and AI-context files");
|
|
5286
|
+
mcpCmd.command("setup").description("Install .mcp.json + CLAUDE.md + AGENTS.md + .cursorrules into the current theme").option("-y, --yes", "Skip confirmation prompts").action(mcpSetupCommand);
|
|
5287
|
+
mcpCmd.command("upgrade").description("Refresh AI-context files to the latest version from the bundled template").option("-y, --yes", "Skip confirmation prompts").action(mcpUpgradeCommand);
|
|
5288
|
+
mcpCmd.command("doctor").description("Diagnose MCP setup in the current theme directory").action(mcpDoctorCommand);
|
|
5081
5289
|
program.command("publish").description("Build, scan, and publish theme to marketplace (requires login)").option("-t, --theme <path>", "Theme directory path").option(
|
|
5082
5290
|
"--bump <type>",
|
|
5083
5291
|
"Auto-bump version before publish (patch|minor|major)"
|