aiblueprint-cli 1.4.29 → 1.4.30

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.js +304 -16
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -36046,13 +36046,283 @@ async function backupLoadCommand(options = {}) {
36046
36046
  }
36047
36047
  }
36048
36048
 
36049
- // src/commands/dynamic-scripts.ts
36049
+ // src/commands/openclaw-pro.ts
36050
+ import os18 from "os";
36050
36051
  import path18 from "path";
36051
- import { homedir } from "os";
36052
36052
 
36053
- // src/lib/script-parser.ts
36053
+ // src/lib/openclaw-installer.ts
36054
36054
  var import_fs_extra12 = __toESM(require_lib4(), 1);
36055
+ import os16 from "os";
36055
36056
  import path16 from "path";
36057
+ import { exec as exec4 } from "child_process";
36058
+ import { promisify as promisify3 } from "util";
36059
+ var execAsync3 = promisify3(exec4);
36060
+ var OPENCLAW_PRO_REPO = "Melvynx/openclawpro";
36061
+ function getCacheRepoDir2() {
36062
+ return path16.join(os16.homedir(), ".config", "openclaw", "pro-repos", "openclawpro");
36063
+ }
36064
+ async function execGitWithAuth2(command, token, repoUrl, cwd) {
36065
+ const authenticatedUrl = `https://x-access-token:${token}@${repoUrl.replace(/^https?:\/\//, "")}`;
36066
+ const fullCommand = `git ${command.replace(repoUrl, authenticatedUrl)}`;
36067
+ try {
36068
+ await execAsync3(fullCommand, { cwd, timeout: 120000 });
36069
+ } catch (error) {
36070
+ throw new Error(`Git command failed: ${error instanceof Error ? error.message : "Unknown error"}`);
36071
+ }
36072
+ }
36073
+ async function cloneOrUpdateRepo2(token) {
36074
+ const cacheDir = getCacheRepoDir2();
36075
+ const repoUrl = `https://github.com/${OPENCLAW_PRO_REPO}.git`;
36076
+ if (await import_fs_extra12.default.pathExists(path16.join(cacheDir, ".git"))) {
36077
+ try {
36078
+ await execGitWithAuth2("pull", token, repoUrl, cacheDir);
36079
+ } catch (error) {
36080
+ await import_fs_extra12.default.remove(cacheDir);
36081
+ await import_fs_extra12.default.ensureDir(path16.dirname(cacheDir));
36082
+ await execGitWithAuth2(`clone ${repoUrl} ${cacheDir}`, token, repoUrl);
36083
+ }
36084
+ } else {
36085
+ await import_fs_extra12.default.ensureDir(path16.dirname(cacheDir));
36086
+ await execGitWithAuth2(`clone ${repoUrl} ${cacheDir}`, token, repoUrl);
36087
+ }
36088
+ return path16.join(cacheDir, "openclaw-config");
36089
+ }
36090
+ async function copyConfigFromCache2(cacheConfigDir, targetDir, onProgress) {
36091
+ const walk = async (dir, baseDir = dir) => {
36092
+ const entries = await import_fs_extra12.default.readdir(dir, { withFileTypes: true });
36093
+ for (const entry of entries) {
36094
+ const sourcePath = path16.join(dir, entry.name);
36095
+ const relativePath = path16.relative(baseDir, sourcePath);
36096
+ const targetPath = path16.join(targetDir, relativePath);
36097
+ if (entry.isDirectory()) {
36098
+ await import_fs_extra12.default.ensureDir(targetPath);
36099
+ onProgress?.(relativePath, "directory");
36100
+ await walk(sourcePath, baseDir);
36101
+ } else {
36102
+ await import_fs_extra12.default.copy(sourcePath, targetPath, { overwrite: true });
36103
+ onProgress?.(relativePath, "file");
36104
+ }
36105
+ }
36106
+ };
36107
+ await walk(cacheConfigDir);
36108
+ }
36109
+ async function installOpenclawProConfigs(options) {
36110
+ const { githubToken, openclawFolder, onProgress } = options;
36111
+ const targetFolder = openclawFolder || path16.join(os16.homedir(), ".openclaw");
36112
+ try {
36113
+ const cacheConfigDir = await cloneOrUpdateRepo2(githubToken);
36114
+ await copyConfigFromCache2(cacheConfigDir, targetFolder, onProgress);
36115
+ return;
36116
+ } catch (error) {
36117
+ throw new Error(`Failed to install OpenClaw Pro configs: ${error instanceof Error ? error.message : "Unknown error"}`);
36118
+ }
36119
+ }
36120
+
36121
+ // src/lib/openclaw-token-storage.ts
36122
+ var import_fs_extra13 = __toESM(require_lib4(), 1);
36123
+ import os17 from "os";
36124
+ import path17 from "path";
36125
+ function getConfigDir2() {
36126
+ const platform = os17.platform();
36127
+ if (platform === "win32") {
36128
+ return path17.join(process.env.APPDATA || os17.homedir(), "openclaw");
36129
+ }
36130
+ return path17.join(os17.homedir(), ".config", "openclaw");
36131
+ }
36132
+ function getTokenPath() {
36133
+ return path17.join(getConfigDir2(), "token.txt");
36134
+ }
36135
+ async function saveOpenclawToken(githubToken) {
36136
+ const configDir = getConfigDir2();
36137
+ await import_fs_extra13.default.ensureDir(configDir);
36138
+ await import_fs_extra13.default.writeFile(getTokenPath(), githubToken, { mode: 384 });
36139
+ }
36140
+ async function getOpenclawToken() {
36141
+ const tokenPath = getTokenPath();
36142
+ if (await import_fs_extra13.default.pathExists(tokenPath)) {
36143
+ const token = await import_fs_extra13.default.readFile(tokenPath, "utf8");
36144
+ return token.trim();
36145
+ }
36146
+ return null;
36147
+ }
36148
+ function getOpenclawTokenInfo() {
36149
+ return {
36150
+ path: getTokenPath(),
36151
+ platform: os17.platform()
36152
+ };
36153
+ }
36154
+
36155
+ // src/commands/openclaw-pro.ts
36156
+ var import_fs_extra14 = __toESM(require_lib4(), 1);
36157
+ var API_URL2 = "https://codeline.app/api/products";
36158
+ var OPENCLAW_PRODUCT_ID = "prd_t2GRwX3aH1";
36159
+ async function openclawProActivateCommand(userToken) {
36160
+ Ie(source_default.blue(`\uD83D\uDD11 Activate OpenClaw Pro ${source_default.gray(`v${getVersion()}`)}`));
36161
+ try {
36162
+ if (!userToken) {
36163
+ const result = await he({
36164
+ message: "Enter your OpenClaw Pro access token:",
36165
+ placeholder: "Your ProductsOnUsers ID from codeline.app",
36166
+ validate: (value) => {
36167
+ if (!value)
36168
+ return "Token is required";
36169
+ if (value.length < 5)
36170
+ return "Token seems invalid";
36171
+ return;
36172
+ }
36173
+ });
36174
+ if (pD(result)) {
36175
+ xe("Activation cancelled");
36176
+ process.exit(0);
36177
+ }
36178
+ userToken = result;
36179
+ }
36180
+ const spinner = Y2();
36181
+ spinner.start("Validating token...");
36182
+ const response = await fetch(`${API_URL2}/${OPENCLAW_PRODUCT_ID}/have-access?token=${userToken}`);
36183
+ if (!response.ok) {
36184
+ spinner.stop("Token validation failed");
36185
+ M2.error("Invalid token or no access");
36186
+ M2.info("Get OpenClaw Pro at: https://codeline.app");
36187
+ Se(source_default.red("❌ Activation failed"));
36188
+ process.exit(1);
36189
+ }
36190
+ const data = await response.json();
36191
+ if (!data.hasAccess) {
36192
+ spinner.stop("Token validation failed");
36193
+ M2.error("No access to OpenClaw Pro");
36194
+ Se(source_default.red("❌ Activation failed"));
36195
+ process.exit(1);
36196
+ }
36197
+ spinner.stop("Token validated");
36198
+ const githubToken = data.product.metadata?.["cli-github-token"];
36199
+ if (!githubToken) {
36200
+ M2.error("No GitHub token found in product metadata. Contact support.");
36201
+ Se(source_default.red("❌ Activation failed"));
36202
+ process.exit(1);
36203
+ }
36204
+ spinner.start("Saving token...");
36205
+ await saveOpenclawToken(githubToken);
36206
+ spinner.stop("Token saved");
36207
+ const tokenInfo = getOpenclawTokenInfo();
36208
+ M2.success("✅ Token activated!");
36209
+ M2.info(`User: ${data.user.name} (${data.user.email})`);
36210
+ M2.info(`Product: ${data.product.title}`);
36211
+ M2.info(`Token saved to: ${tokenInfo.path}`);
36212
+ M2.info(source_default.cyan(`
36213
+ \uD83D\uDCA1 Next step: Run 'npx aiblueprint-cli@latest openclaw pro setup'`));
36214
+ Se(source_default.green("✅ Activation complete!"));
36215
+ } catch (error) {
36216
+ if (error instanceof Error) {
36217
+ M2.error(error.message);
36218
+ }
36219
+ Se(source_default.red("❌ Activation failed"));
36220
+ process.exit(1);
36221
+ }
36222
+ }
36223
+ async function openclawProStatusCommand() {
36224
+ Ie(source_default.blue(`\uD83D\uDCCA OpenClaw Pro Status ${source_default.gray(`v${getVersion()}`)}`));
36225
+ try {
36226
+ const token = await getOpenclawToken();
36227
+ if (!token) {
36228
+ M2.warn("No token found");
36229
+ M2.info("Run: npx aiblueprint-cli@latest openclaw pro activate <token>");
36230
+ Se(source_default.yellow("⚠️ Not activated"));
36231
+ process.exit(0);
36232
+ }
36233
+ const tokenInfo = getOpenclawTokenInfo();
36234
+ M2.success("✅ Token active");
36235
+ M2.info(`Token file: ${tokenInfo.path}`);
36236
+ Se(source_default.green("Token is saved"));
36237
+ } catch (error) {
36238
+ if (error instanceof Error) {
36239
+ M2.error(error.message);
36240
+ }
36241
+ Se(source_default.red("❌ Failed to check status"));
36242
+ process.exit(1);
36243
+ }
36244
+ }
36245
+ async function openclawProSetupCommand(options = {}) {
36246
+ Ie(source_default.blue(`⚙️ Setup OpenClaw Pro ${source_default.gray(`v${getVersion()}`)}`));
36247
+ try {
36248
+ const githubToken = await getOpenclawToken();
36249
+ if (!githubToken) {
36250
+ M2.error("No token found");
36251
+ M2.info("Run: npx aiblueprint-cli@latest openclaw pro activate <token>");
36252
+ Se(source_default.red("❌ Not activated"));
36253
+ process.exit(1);
36254
+ }
36255
+ const openclawDir = options.folder ? path18.resolve(options.folder) : path18.join(os18.homedir(), ".openclaw");
36256
+ const spinner = Y2();
36257
+ const onProgress = (file, type) => {
36258
+ spinner.message(`Installing: ${source_default.cyan(file)} ${source_default.gray(`(${type})`)}`);
36259
+ };
36260
+ spinner.start("Installing OpenClaw Pro configurations...");
36261
+ await installOpenclawProConfigs({
36262
+ githubToken,
36263
+ openclawFolder: openclawDir,
36264
+ onProgress
36265
+ });
36266
+ spinner.stop("OpenClaw Pro configurations installed");
36267
+ let skillCount = 0;
36268
+ const skillsDir = path18.join(openclawDir, "skills");
36269
+ if (await import_fs_extra14.default.pathExists(skillsDir)) {
36270
+ const items = await import_fs_extra14.default.readdir(skillsDir);
36271
+ const dirs = await Promise.all(items.map(async (item) => {
36272
+ const stat = await import_fs_extra14.default.stat(path18.join(skillsDir, item));
36273
+ return stat.isDirectory();
36274
+ }));
36275
+ skillCount = dirs.filter(Boolean).length;
36276
+ }
36277
+ M2.success("✅ Setup complete!");
36278
+ M2.info("Installed:");
36279
+ M2.info(` • Skills (${skillCount})`);
36280
+ M2.info(` • IDENTITY.md`);
36281
+ M2.info(source_default.cyan(`
36282
+ \uD83D\uDCA1 Skills installed to: ` + skillsDir));
36283
+ Se(source_default.green("\uD83D\uDE80 OpenClaw Pro ready!"));
36284
+ } catch (error) {
36285
+ if (error instanceof Error) {
36286
+ M2.error(error.message);
36287
+ }
36288
+ Se(source_default.red("❌ Setup failed"));
36289
+ process.exit(1);
36290
+ }
36291
+ }
36292
+ async function openclawProUpdateCommand(options = {}) {
36293
+ Ie(source_default.blue(`\uD83D\uDD04 Update OpenClaw Pro ${source_default.gray(`v${getVersion()}`)}`));
36294
+ try {
36295
+ const githubToken = await getOpenclawToken();
36296
+ if (!githubToken) {
36297
+ M2.error("No token found");
36298
+ M2.info("Run: npx aiblueprint-cli@latest openclaw pro activate <token>");
36299
+ Se(source_default.red("❌ Not activated"));
36300
+ process.exit(1);
36301
+ }
36302
+ const spinner = Y2();
36303
+ spinner.start("Updating OpenClaw Pro configurations...");
36304
+ await installOpenclawProConfigs({
36305
+ githubToken,
36306
+ openclawFolder: options.folder
36307
+ });
36308
+ spinner.stop("OpenClaw Pro configurations updated");
36309
+ Se(source_default.green("✅ Update completed"));
36310
+ } catch (error) {
36311
+ if (error instanceof Error) {
36312
+ M2.error(error.message);
36313
+ }
36314
+ Se(source_default.red("❌ Update failed"));
36315
+ process.exit(1);
36316
+ }
36317
+ }
36318
+
36319
+ // src/commands/dynamic-scripts.ts
36320
+ import path21 from "path";
36321
+ import { homedir } from "os";
36322
+
36323
+ // src/lib/script-parser.ts
36324
+ var import_fs_extra15 = __toESM(require_lib4(), 1);
36325
+ import path19 from "path";
36056
36326
  var EXCLUDED_SCRIPTS = ["test", "lint", "format", "start"];
36057
36327
  var EXCLUDED_SUFFIXES = [":test", ":lint", ":test-fixtures", ":start"];
36058
36328
  function shouldIncludeScript(scriptName) {
@@ -36063,12 +36333,12 @@ function shouldIncludeScript(scriptName) {
36063
36333
  return true;
36064
36334
  }
36065
36335
  async function readScriptsPackageJson(claudeDir) {
36066
- const packageJsonPath = path16.join(claudeDir, "scripts", "package.json");
36336
+ const packageJsonPath = path19.join(claudeDir, "scripts", "package.json");
36067
36337
  try {
36068
- if (!await import_fs_extra12.default.pathExists(packageJsonPath)) {
36338
+ if (!await import_fs_extra15.default.pathExists(packageJsonPath)) {
36069
36339
  return null;
36070
36340
  }
36071
- const content = await import_fs_extra12.default.readFile(packageJsonPath, "utf-8");
36341
+ const content = await import_fs_extra15.default.readFile(packageJsonPath, "utf-8");
36072
36342
  const parsed = JSON.parse(content);
36073
36343
  return parsed.scripts || null;
36074
36344
  } catch (error) {
@@ -36112,14 +36382,14 @@ function groupScriptsByPrefix(commands) {
36112
36382
  }
36113
36383
 
36114
36384
  // src/commands/script-runner.ts
36115
- var import_fs_extra13 = __toESM(require_lib4(), 1);
36385
+ var import_fs_extra16 = __toESM(require_lib4(), 1);
36116
36386
  import { spawn as spawn2 } from "child_process";
36117
36387
  import { execSync as execSync4 } from "child_process";
36118
- import path17 from "path";
36119
- import os16 from "os";
36388
+ import path20 from "path";
36389
+ import os19 from "os";
36120
36390
  function checkCommand(cmd) {
36121
36391
  try {
36122
- const isWindows = os16.platform() === "win32";
36392
+ const isWindows = os19.platform() === "win32";
36123
36393
  const whichCmd = isWindows ? `where ${cmd}` : `which ${cmd}`;
36124
36394
  execSync4(whichCmd, { stdio: "ignore" });
36125
36395
  return true;
@@ -36145,18 +36415,18 @@ async function executeScript(scriptName, claudeDir) {
36145
36415
  console.error(source_default.red("Bun is not installed. Install with: npm install -g bun"));
36146
36416
  return 1;
36147
36417
  }
36148
- const scriptsDir = path17.join(claudeDir, "scripts");
36149
- if (!await import_fs_extra13.default.pathExists(scriptsDir)) {
36418
+ const scriptsDir = path20.join(claudeDir, "scripts");
36419
+ if (!await import_fs_extra16.default.pathExists(scriptsDir)) {
36150
36420
  console.error(source_default.red(`Scripts directory not found at ${scriptsDir}`));
36151
36421
  console.log(source_default.gray("Run: aiblueprint claude-code setup"));
36152
36422
  return 1;
36153
36423
  }
36154
- const packageJsonPath = path17.join(scriptsDir, "package.json");
36155
- if (!await import_fs_extra13.default.pathExists(packageJsonPath)) {
36424
+ const packageJsonPath = path20.join(scriptsDir, "package.json");
36425
+ if (!await import_fs_extra16.default.pathExists(packageJsonPath)) {
36156
36426
  console.error(source_default.red(`package.json not found in ${scriptsDir}`));
36157
36427
  return 1;
36158
36428
  }
36159
- const packageJson = await import_fs_extra13.default.readJson(packageJsonPath);
36429
+ const packageJson = await import_fs_extra16.default.readJson(packageJsonPath);
36160
36430
  if (!packageJson.scripts || !packageJson.scripts[scriptName]) {
36161
36431
  console.error(source_default.red(`Script "${scriptName}" not found in package.json`));
36162
36432
  return 1;
@@ -36179,7 +36449,7 @@ async function executeScript(scriptName, claudeDir) {
36179
36449
 
36180
36450
  // src/commands/dynamic-scripts.ts
36181
36451
  function getClaudeDir(parentOptions) {
36182
- return parentOptions.claudeCodeFolder || parentOptions.folder ? path18.resolve(parentOptions.claudeCodeFolder || parentOptions.folder) : path18.join(homedir(), ".claude");
36452
+ return parentOptions.claudeCodeFolder || parentOptions.folder ? path21.resolve(parentOptions.claudeCodeFolder || parentOptions.folder) : path21.join(homedir(), ".claude");
36183
36453
  }
36184
36454
  async function registerDynamicScriptCommands(claudeCodeCmd, claudeDir) {
36185
36455
  const scripts = await readScriptsPackageJson(claudeDir);
@@ -36268,6 +36538,24 @@ backupCmd.command("load").description("Load a previous backup interactively").ac
36268
36538
  const claudeCodeFolder = parentOptions.claudeCodeFolder || parentOptions.folder;
36269
36539
  backupLoadCommand({ folder: claudeCodeFolder });
36270
36540
  });
36541
+ var openclawCmd = program2.command("openclaw").description("OpenClaw configuration commands").option("-f, --folder <path>", "Specify custom OpenClaw folder path (default: ~/.openclaw)");
36542
+ var openclawProCmd = openclawCmd.command("pro").description("Manage OpenClaw Pro features");
36543
+ openclawProCmd.command("activate [token]").description("Activate OpenClaw Pro with your access token").action((token) => {
36544
+ openclawProActivateCommand(token);
36545
+ });
36546
+ openclawProCmd.command("status").description("Check your OpenClaw Pro token status").action(() => {
36547
+ openclawProStatusCommand();
36548
+ });
36549
+ openclawProCmd.command("setup").description("Install OpenClaw Pro configurations (requires activation)").action((options, command) => {
36550
+ const parentOptions = command.parent.parent.opts();
36551
+ const folder = parentOptions.folder;
36552
+ openclawProSetupCommand({ folder });
36553
+ });
36554
+ openclawProCmd.command("update").description("Update OpenClaw Pro configurations").action((options, command) => {
36555
+ const parentOptions = command.parent.parent.opts();
36556
+ const folder = parentOptions.folder;
36557
+ openclawProUpdateCommand({ folder });
36558
+ });
36271
36559
  try {
36272
36560
  const claudeDir = join2(homedir2(), ".claude");
36273
36561
  await registerDynamicScriptCommands(claudeCodeCmd, claudeDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiblueprint-cli",
3
- "version": "1.4.29",
3
+ "version": "1.4.30",
4
4
  "description": "AIBlueprint CLI for setting up Claude Code configurations",
5
5
  "author": "AIBlueprint",
6
6
  "license": "MIT",