aiblueprint-cli 1.4.19 → 1.4.21
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/README.md +97 -506
- package/dist/cli.js +303 -271
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -32251,7 +32251,7 @@ var lib_default = inquirer;
|
|
|
32251
32251
|
// src/commands/setup.ts
|
|
32252
32252
|
var import_fs_extra6 = __toESM(require_lib4(), 1);
|
|
32253
32253
|
import path8 from "path";
|
|
32254
|
-
import
|
|
32254
|
+
import os9 from "os";
|
|
32255
32255
|
|
|
32256
32256
|
// node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
32257
32257
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
@@ -33201,6 +33201,10 @@ async function updateSettings(options, claudeDir) {
|
|
|
33201
33201
|
// src/commands/setup/utils.ts
|
|
33202
33202
|
var import_fs_extra4 = __toESM(require_lib4(), 1);
|
|
33203
33203
|
import path6 from "path";
|
|
33204
|
+
import os7 from "os";
|
|
33205
|
+
import { exec } from "child_process";
|
|
33206
|
+
import { promisify } from "util";
|
|
33207
|
+
var execAsync = promisify(exec);
|
|
33204
33208
|
|
|
33205
33209
|
class SimpleSpinner {
|
|
33206
33210
|
message = "";
|
|
@@ -33212,57 +33216,24 @@ class SimpleSpinner {
|
|
|
33212
33216
|
console.log(source_default.green(`✓ ${message}`));
|
|
33213
33217
|
}
|
|
33214
33218
|
}
|
|
33215
|
-
var
|
|
33216
|
-
async function
|
|
33219
|
+
var GITHUB_REPO = "https://github.com/Melvynx/aiblueprint.git";
|
|
33220
|
+
async function cloneRepository() {
|
|
33221
|
+
const tmpDir = path6.join(os7.tmpdir(), `aiblueprint-${Date.now()}`);
|
|
33217
33222
|
try {
|
|
33218
|
-
|
|
33219
|
-
|
|
33220
|
-
|
|
33221
|
-
return false;
|
|
33222
|
-
}
|
|
33223
|
-
const content = await response.arrayBuffer();
|
|
33224
|
-
await import_fs_extra4.default.ensureDir(path6.dirname(targetPath));
|
|
33225
|
-
await import_fs_extra4.default.writeFile(targetPath, Buffer.from(content));
|
|
33226
|
-
return true;
|
|
33223
|
+
await import_fs_extra4.default.ensureDir(tmpDir);
|
|
33224
|
+
await execAsync(`git clone --depth 1 --quiet ${GITHUB_REPO} "${tmpDir}"`);
|
|
33225
|
+
return tmpDir;
|
|
33227
33226
|
} catch (error) {
|
|
33228
|
-
|
|
33227
|
+
console.error(source_default.yellow(` Warning: Failed to clone repository: ${error instanceof Error ? error.message : String(error)}`));
|
|
33228
|
+
await import_fs_extra4.default.remove(tmpDir).catch(() => {});
|
|
33229
|
+
return null;
|
|
33229
33230
|
}
|
|
33230
33231
|
}
|
|
33231
|
-
async function
|
|
33232
|
+
async function cleanupRepository(repoPath) {
|
|
33232
33233
|
try {
|
|
33233
|
-
|
|
33234
|
-
const response = await fetch(apiUrl);
|
|
33235
|
-
if (!response.ok) {
|
|
33236
|
-
console.error(source_default.yellow(` Warning: Failed to fetch directory from GitHub: ${dirPath} (HTTP ${response.status})`));
|
|
33237
|
-
return false;
|
|
33238
|
-
}
|
|
33239
|
-
const files = await response.json();
|
|
33240
|
-
if (!Array.isArray(files)) {
|
|
33241
|
-
console.error(source_default.yellow(` Warning: Invalid response from GitHub API for: ${dirPath}`));
|
|
33242
|
-
return false;
|
|
33243
|
-
}
|
|
33244
|
-
await import_fs_extra4.default.ensureDir(targetDir);
|
|
33245
|
-
let allSuccess = true;
|
|
33246
|
-
for (const file of files) {
|
|
33247
|
-
const relativePath = `${dirPath}/${file.name}`;
|
|
33248
|
-
const targetPath = path6.join(targetDir, file.name);
|
|
33249
|
-
if (file.type === "file") {
|
|
33250
|
-
const success = await downloadFromGitHub(relativePath, targetPath);
|
|
33251
|
-
if (!success) {
|
|
33252
|
-
console.error(source_default.yellow(` Warning: Failed to download file: ${relativePath}`));
|
|
33253
|
-
allSuccess = false;
|
|
33254
|
-
}
|
|
33255
|
-
} else if (file.type === "dir") {
|
|
33256
|
-
const success = await downloadDirectoryFromGitHub(relativePath, targetPath);
|
|
33257
|
-
if (!success) {
|
|
33258
|
-
allSuccess = false;
|
|
33259
|
-
}
|
|
33260
|
-
}
|
|
33261
|
-
}
|
|
33262
|
-
return allSuccess;
|
|
33234
|
+
await import_fs_extra4.default.remove(repoPath);
|
|
33263
33235
|
} catch (error) {
|
|
33264
|
-
console.error(source_default.yellow(` Warning:
|
|
33265
|
-
return false;
|
|
33236
|
+
console.error(source_default.yellow(` Warning: Failed to cleanup temporary directory: ${error instanceof Error ? error.message : String(error)}`));
|
|
33266
33237
|
}
|
|
33267
33238
|
}
|
|
33268
33239
|
|
|
@@ -33287,8 +33258,8 @@ function getVersion() {
|
|
|
33287
33258
|
// src/lib/backup-utils.ts
|
|
33288
33259
|
var import_fs_extra5 = __toESM(require_lib4(), 1);
|
|
33289
33260
|
import path7 from "path";
|
|
33290
|
-
import
|
|
33291
|
-
var BACKUP_BASE_DIR = path7.join(
|
|
33261
|
+
import os8 from "os";
|
|
33262
|
+
var BACKUP_BASE_DIR = path7.join(os8.homedir(), ".config", "aiblueprint", "backup");
|
|
33292
33263
|
function formatDate(date) {
|
|
33293
33264
|
const pad = (n) => n.toString().padStart(2, "0");
|
|
33294
33265
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}-${pad(date.getHours())}-${pad(date.getMinutes())}-${pad(date.getSeconds())}`;
|
|
@@ -33320,7 +33291,6 @@ async function createBackup(claudeDir) {
|
|
|
33320
33291
|
// src/commands/setup.ts
|
|
33321
33292
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
33322
33293
|
var __dirname2 = dirname2(__filename2);
|
|
33323
|
-
var GITHUB_RAW_BASE2 = "https://raw.githubusercontent.com/Melvynx/aiblueprint-cli/main/claude-code-config";
|
|
33324
33294
|
async function setupCommand(params = {}) {
|
|
33325
33295
|
const {
|
|
33326
33296
|
claudeCodeFolder: customClaudeCodeFolder,
|
|
@@ -33328,6 +33298,7 @@ async function setupCommand(params = {}) {
|
|
|
33328
33298
|
openCodeFolder: customOpenCodeFolder,
|
|
33329
33299
|
skipInteractive
|
|
33330
33300
|
} = params;
|
|
33301
|
+
let repoPath = null;
|
|
33331
33302
|
try {
|
|
33332
33303
|
console.log(source_default.blue.bold(`
|
|
33333
33304
|
\uD83D\uDE80 AIBlueprint Claude Code Setup ${source_default.gray(`v${getVersion()}`)}
|
|
@@ -33415,7 +33386,7 @@ async function setupCommand(params = {}) {
|
|
|
33415
33386
|
skipInteractive
|
|
33416
33387
|
};
|
|
33417
33388
|
const s = new SimpleSpinner;
|
|
33418
|
-
const claudeDir = customClaudeCodeFolder ? path8.resolve(customClaudeCodeFolder) : path8.join(
|
|
33389
|
+
const claudeDir = customClaudeCodeFolder ? path8.resolve(customClaudeCodeFolder) : path8.join(os9.homedir(), ".claude");
|
|
33419
33390
|
console.log(source_default.gray(`Installing to: ${claudeDir}`));
|
|
33420
33391
|
await import_fs_extra6.default.ensureDir(claudeDir);
|
|
33421
33392
|
s.start("Creating backup of existing configuration");
|
|
@@ -33425,37 +33396,17 @@ async function setupCommand(params = {}) {
|
|
|
33425
33396
|
} else {
|
|
33426
33397
|
s.stop("No existing config to backup");
|
|
33427
33398
|
}
|
|
33428
|
-
|
|
33429
|
-
|
|
33430
|
-
|
|
33431
|
-
|
|
33432
|
-
const testResponse = await fetch(testUrl);
|
|
33433
|
-
useGitHub = testResponse.ok;
|
|
33434
|
-
} catch {
|
|
33435
|
-
useGitHub = false;
|
|
33436
|
-
}
|
|
33437
|
-
if (!useGitHub) {
|
|
33438
|
-
const currentDir = process.cwd();
|
|
33439
|
-
const possiblePaths = [
|
|
33440
|
-
path8.join(currentDir, "claude-code-config"),
|
|
33441
|
-
path8.join(__dirname2, "../../claude-code-config"),
|
|
33442
|
-
path8.join(__dirname2, "../claude-code-config"),
|
|
33443
|
-
path8.join(path8.dirname(process.argv[1]), "../claude-code-config")
|
|
33444
|
-
];
|
|
33445
|
-
sourceDir = possiblePaths.find((p) => {
|
|
33446
|
-
try {
|
|
33447
|
-
return import_fs_extra6.default.existsSync(p);
|
|
33448
|
-
} catch {
|
|
33449
|
-
return false;
|
|
33450
|
-
}
|
|
33451
|
-
});
|
|
33452
|
-
if (!sourceDir) {
|
|
33453
|
-
throw new Error("Could not find claude-code-config directory locally and GitHub is not accessible");
|
|
33454
|
-
}
|
|
33455
|
-
console.log(source_default.yellow(" Using local configuration files (GitHub not accessible)"));
|
|
33456
|
-
} else {
|
|
33457
|
-
console.log(source_default.green(" Downloading latest configuration from GitHub"));
|
|
33399
|
+
s.start("Cloning configuration repository");
|
|
33400
|
+
repoPath = await cloneRepository();
|
|
33401
|
+
if (!repoPath) {
|
|
33402
|
+
throw new Error("Failed to clone repository. Please check your internet connection and try again.");
|
|
33458
33403
|
}
|
|
33404
|
+
const sourceDir = path8.join(repoPath, "claude-code-config");
|
|
33405
|
+
if (!await import_fs_extra6.default.pathExists(sourceDir)) {
|
|
33406
|
+
await cleanupRepository(repoPath);
|
|
33407
|
+
throw new Error("Configuration directory not found in cloned repository");
|
|
33408
|
+
}
|
|
33409
|
+
s.stop("Repository cloned successfully");
|
|
33459
33410
|
if (options.shellShortcuts) {
|
|
33460
33411
|
s.start("Setting up shell shortcuts");
|
|
33461
33412
|
await setupShellShortcuts();
|
|
@@ -33463,31 +33414,15 @@ async function setupCommand(params = {}) {
|
|
|
33463
33414
|
}
|
|
33464
33415
|
if (options.commandValidation || options.customStatusline || options.notificationSounds) {
|
|
33465
33416
|
s.start("Setting up scripts");
|
|
33466
|
-
|
|
33467
|
-
|
|
33468
|
-
await import_fs_extra6.default.ensureDir(
|
|
33469
|
-
if (options.commandValidation) {
|
|
33470
|
-
await downloadDirectoryFromGitHub("scripts/command-validator", path8.join(scriptsDir, "command-validator"));
|
|
33471
|
-
}
|
|
33472
|
-
if (options.customStatusline) {
|
|
33473
|
-
await downloadDirectoryFromGitHub("scripts/statusline", path8.join(scriptsDir, "statusline"));
|
|
33474
|
-
await import_fs_extra6.default.ensureDir(path8.join(scriptsDir, "statusline/data"));
|
|
33475
|
-
}
|
|
33476
|
-
} else {
|
|
33477
|
-
await import_fs_extra6.default.copy(path8.join(sourceDir, "scripts"), path8.join(claudeDir, "scripts"), { overwrite: true });
|
|
33478
|
-
if (options.customStatusline) {
|
|
33479
|
-
await import_fs_extra6.default.ensureDir(path8.join(claudeDir, "scripts/statusline/data"));
|
|
33480
|
-
}
|
|
33417
|
+
await import_fs_extra6.default.copy(path8.join(sourceDir, "scripts"), path8.join(claudeDir, "scripts"), { overwrite: true });
|
|
33418
|
+
if (options.customStatusline) {
|
|
33419
|
+
await import_fs_extra6.default.ensureDir(path8.join(claudeDir, "scripts/statusline/data"));
|
|
33481
33420
|
}
|
|
33482
33421
|
s.stop("Scripts installed");
|
|
33483
33422
|
}
|
|
33484
33423
|
if (options.aiblueprintCommands) {
|
|
33485
33424
|
s.start("Setting up AIBlueprint commands");
|
|
33486
|
-
|
|
33487
|
-
await downloadDirectoryFromGitHub("commands", path8.join(claudeDir, "commands"));
|
|
33488
|
-
} else {
|
|
33489
|
-
await import_fs_extra6.default.copy(path8.join(sourceDir, "commands"), path8.join(claudeDir, "commands"), { overwrite: true });
|
|
33490
|
-
}
|
|
33425
|
+
await import_fs_extra6.default.copy(path8.join(sourceDir, "commands"), path8.join(claudeDir, "commands"), { overwrite: true });
|
|
33491
33426
|
s.stop("Commands installed");
|
|
33492
33427
|
}
|
|
33493
33428
|
if (options.codexSymlink && options.aiblueprintCommands) {
|
|
@@ -33502,48 +33437,22 @@ async function setupCommand(params = {}) {
|
|
|
33502
33437
|
}
|
|
33503
33438
|
if (options.aiblueprintAgents) {
|
|
33504
33439
|
s.start("Setting up AIBlueprint agents");
|
|
33505
|
-
|
|
33506
|
-
await downloadDirectoryFromGitHub("agents", path8.join(claudeDir, "agents"));
|
|
33507
|
-
} else {
|
|
33508
|
-
await import_fs_extra6.default.copy(path8.join(sourceDir, "agents"), path8.join(claudeDir, "agents"), { overwrite: true });
|
|
33509
|
-
}
|
|
33440
|
+
await import_fs_extra6.default.copy(path8.join(sourceDir, "agents"), path8.join(claudeDir, "agents"), { overwrite: true });
|
|
33510
33441
|
s.stop("Agents installed");
|
|
33511
33442
|
}
|
|
33512
33443
|
if (options.aiblueprintSkills) {
|
|
33513
33444
|
s.start("Setting up AIBlueprint Skills");
|
|
33514
|
-
|
|
33515
|
-
|
|
33516
|
-
|
|
33517
|
-
|
|
33518
|
-
if (testResponse.ok) {
|
|
33519
|
-
await downloadDirectoryFromGitHub("skills", path8.join(claudeDir, "skills"));
|
|
33520
|
-
s.stop("Skills installed");
|
|
33521
|
-
} else {
|
|
33522
|
-
s.stop("Skills not available in repository");
|
|
33523
|
-
}
|
|
33524
|
-
} catch {
|
|
33525
|
-
s.stop("Skills not available in repository");
|
|
33526
|
-
}
|
|
33445
|
+
const skillsSourcePath = path8.join(sourceDir, "skills");
|
|
33446
|
+
if (await import_fs_extra6.default.pathExists(skillsSourcePath)) {
|
|
33447
|
+
await import_fs_extra6.default.copy(skillsSourcePath, path8.join(claudeDir, "skills"), { overwrite: true });
|
|
33448
|
+
s.stop("Skills installed");
|
|
33527
33449
|
} else {
|
|
33528
|
-
|
|
33529
|
-
if (await import_fs_extra6.default.pathExists(skillsSourcePath)) {
|
|
33530
|
-
await import_fs_extra6.default.copy(skillsSourcePath, path8.join(claudeDir, "skills"), { overwrite: true });
|
|
33531
|
-
s.stop("Skills installed");
|
|
33532
|
-
} else {
|
|
33533
|
-
s.stop("Skills not available in local repository");
|
|
33534
|
-
}
|
|
33450
|
+
s.stop("Skills not available in repository");
|
|
33535
33451
|
}
|
|
33536
33452
|
}
|
|
33537
33453
|
if (options.notificationSounds) {
|
|
33538
33454
|
s.start("Setting up notification sounds");
|
|
33539
|
-
|
|
33540
|
-
const songDir = path8.join(claudeDir, "song");
|
|
33541
|
-
await import_fs_extra6.default.ensureDir(songDir);
|
|
33542
|
-
await downloadFromGitHub("song/finish.mp3", path8.join(songDir, "finish.mp3"));
|
|
33543
|
-
await downloadFromGitHub("song/need-human.mp3", path8.join(songDir, "need-human.mp3"));
|
|
33544
|
-
} else {
|
|
33545
|
-
await import_fs_extra6.default.copy(path8.join(sourceDir, "song"), path8.join(claudeDir, "song"), { overwrite: true });
|
|
33546
|
-
}
|
|
33455
|
+
await import_fs_extra6.default.copy(path8.join(sourceDir, "song"), path8.join(claudeDir, "song"), { overwrite: true });
|
|
33547
33456
|
s.stop("Notification sounds installed");
|
|
33548
33457
|
}
|
|
33549
33458
|
if (options.customStatusline) {
|
|
@@ -33574,11 +33483,14 @@ async function setupCommand(params = {}) {
|
|
|
33574
33483
|
s.start("Updating settings.json");
|
|
33575
33484
|
await updateSettings(options, claudeDir);
|
|
33576
33485
|
s.stop("Settings updated");
|
|
33486
|
+
s.start("Cleaning up temporary files");
|
|
33487
|
+
await cleanupRepository(repoPath);
|
|
33488
|
+
s.stop("Cleanup complete");
|
|
33577
33489
|
console.log(source_default.green("✨ Setup complete!"));
|
|
33578
33490
|
console.log(source_default.gray(`
|
|
33579
33491
|
Next steps:`));
|
|
33580
33492
|
if (options.shellShortcuts) {
|
|
33581
|
-
const platform =
|
|
33493
|
+
const platform = os9.platform();
|
|
33582
33494
|
if (platform === "win32") {
|
|
33583
33495
|
console.log(source_default.gray(" • Restart PowerShell to load the new functions"));
|
|
33584
33496
|
} else {
|
|
@@ -33594,6 +33506,9 @@ Next steps:`));
|
|
|
33594
33506
|
console.error(source_default.red(`
|
|
33595
33507
|
❌ Setup failed:`), error);
|
|
33596
33508
|
console.log(source_default.red("Setup failed!"));
|
|
33509
|
+
if (repoPath) {
|
|
33510
|
+
await cleanupRepository(repoPath);
|
|
33511
|
+
}
|
|
33597
33512
|
process.exit(1);
|
|
33598
33513
|
}
|
|
33599
33514
|
}
|
|
@@ -33601,8 +33516,8 @@ Next steps:`));
|
|
|
33601
33516
|
// src/commands/setup-terminal.ts
|
|
33602
33517
|
var import_fs_extra7 = __toESM(require_lib4(), 1);
|
|
33603
33518
|
import path9 from "path";
|
|
33604
|
-
import
|
|
33605
|
-
import { execSync as execSync3, exec } from "child_process";
|
|
33519
|
+
import os10 from "os";
|
|
33520
|
+
import { execSync as execSync3, exec as exec2 } from "child_process";
|
|
33606
33521
|
var OHMYZSH_INSTALL_URL = "https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh";
|
|
33607
33522
|
var INSTALL_TIMEOUT = 120000;
|
|
33608
33523
|
var PLUGIN_TIMEOUT = 60000;
|
|
@@ -33684,7 +33599,7 @@ async function installOhMyZsh(homeDir) {
|
|
|
33684
33599
|
return new Promise((resolve, reject) => {
|
|
33685
33600
|
const installCmd = `sh -c "$(curl -fsSL ${OHMYZSH_INSTALL_URL})" "" --unattended`;
|
|
33686
33601
|
const env2 = { ...process.env, HOME: homeDir, ZSH: path9.join(homeDir, ".oh-my-zsh") };
|
|
33687
|
-
|
|
33602
|
+
exec2(installCmd, { timeout: INSTALL_TIMEOUT, env: env2 }, (error, stdout, stderr) => {
|
|
33688
33603
|
if (error) {
|
|
33689
33604
|
if ("killed" in error && error.killed) {
|
|
33690
33605
|
reject(new Error("Oh My ZSH installation timed out. Please check your network connection."));
|
|
@@ -33709,7 +33624,7 @@ async function installPlugin(pluginName, repoUrl, homeDir) {
|
|
|
33709
33624
|
return;
|
|
33710
33625
|
}
|
|
33711
33626
|
return new Promise((resolve, reject) => {
|
|
33712
|
-
|
|
33627
|
+
exec2(`git clone ${repoUrl} "${customPluginsDir}"`, { timeout: PLUGIN_TIMEOUT }, (error, stdout, stderr) => {
|
|
33713
33628
|
if (error) {
|
|
33714
33629
|
if ("killed" in error && error.killed) {
|
|
33715
33630
|
reject(new Error(`Plugin ${pluginName} installation timed out. Please check your network connection.`));
|
|
@@ -33768,7 +33683,7 @@ plugins=(${pluginsString})`;
|
|
|
33768
33683
|
}
|
|
33769
33684
|
async function setupTerminalCommand(options = {}) {
|
|
33770
33685
|
const { skipInteractive, homeDir: customHomeDir } = options;
|
|
33771
|
-
const homeDir = customHomeDir ||
|
|
33686
|
+
const homeDir = customHomeDir || os10.homedir();
|
|
33772
33687
|
try {
|
|
33773
33688
|
console.log(source_default.blue.bold(`
|
|
33774
33689
|
\uD83D\uDDA5️ AIBlueprint Terminal Setup ${source_default.gray(`v${getVersion()}`)}
|
|
@@ -34081,52 +33996,6 @@ async function symlinkCommand(params = {}) {
|
|
|
34081
33996
|
}
|
|
34082
33997
|
}
|
|
34083
33998
|
|
|
34084
|
-
// src/commands/statusline.ts
|
|
34085
|
-
var import_fs_extra8 = __toESM(require_lib4(), 1);
|
|
34086
|
-
import path10 from "path";
|
|
34087
|
-
import { homedir } from "os";
|
|
34088
|
-
async function statuslineCommand(options) {
|
|
34089
|
-
const claudeDir = options.folder ? path10.resolve(options.folder) : path10.join(homedir(), ".claude");
|
|
34090
|
-
console.log(source_default.blue(`\uD83D\uDE80 Setting up AIBlueprint Statusline ${source_default.gray(`v${getVersion()}`)}...`));
|
|
34091
|
-
console.log(source_default.gray(` Target: ${claudeDir}
|
|
34092
|
-
`));
|
|
34093
|
-
await import_fs_extra8.default.ensureDir(claudeDir);
|
|
34094
|
-
console.log(source_default.cyan("\uD83D\uDCE6 Checking dependencies..."));
|
|
34095
|
-
await checkAndInstallDependencies();
|
|
34096
|
-
console.log(source_default.cyan(`
|
|
34097
|
-
\uD83D\uDCE5 Downloading statusline files...`));
|
|
34098
|
-
const scriptsDir = path10.join(claudeDir, "scripts");
|
|
34099
|
-
await import_fs_extra8.default.ensureDir(scriptsDir);
|
|
34100
|
-
const success = await downloadDirectoryFromGitHub("scripts/statusline", path10.join(scriptsDir, "statusline"));
|
|
34101
|
-
if (!success) {
|
|
34102
|
-
console.log(source_default.red(" Failed to download statusline files from GitHub"));
|
|
34103
|
-
return;
|
|
34104
|
-
}
|
|
34105
|
-
console.log(source_default.cyan(`
|
|
34106
|
-
\uD83D\uDCE6 Installing statusline dependencies...`));
|
|
34107
|
-
await installStatuslineDependencies(claudeDir);
|
|
34108
|
-
console.log(source_default.cyan(`
|
|
34109
|
-
⚙️ Configuring settings.json...`));
|
|
34110
|
-
const settingsPath = path10.join(claudeDir, "settings.json");
|
|
34111
|
-
let settings = {};
|
|
34112
|
-
try {
|
|
34113
|
-
const existingSettings = await import_fs_extra8.default.readFile(settingsPath, "utf-8");
|
|
34114
|
-
settings = JSON.parse(existingSettings);
|
|
34115
|
-
} catch {}
|
|
34116
|
-
settings.statusLine = {
|
|
34117
|
-
type: "command",
|
|
34118
|
-
command: `bun ${path10.join(claudeDir, "scripts/statusline/src/index.ts")}`,
|
|
34119
|
-
padding: 0
|
|
34120
|
-
};
|
|
34121
|
-
await import_fs_extra8.default.writeJson(settingsPath, settings, { spaces: 2 });
|
|
34122
|
-
console.log(source_default.green(`
|
|
34123
|
-
✅ Statusline setup complete!`));
|
|
34124
|
-
console.log(source_default.gray(`
|
|
34125
|
-
Your Claude Code statusline is now configured.`));
|
|
34126
|
-
console.log(source_default.gray(`Restart Claude Code to see the changes.
|
|
34127
|
-
`));
|
|
34128
|
-
}
|
|
34129
|
-
|
|
34130
33999
|
// node_modules/@clack/core/dist/index.mjs
|
|
34131
34000
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
34132
34001
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
@@ -34843,26 +34712,26 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
34843
34712
|
};
|
|
34844
34713
|
|
|
34845
34714
|
// src/commands/pro.ts
|
|
34846
|
-
import
|
|
34847
|
-
import
|
|
34715
|
+
import os13 from "os";
|
|
34716
|
+
import path12 from "path";
|
|
34848
34717
|
|
|
34849
34718
|
// src/lib/pro-installer.ts
|
|
34850
|
-
var
|
|
34851
|
-
import
|
|
34852
|
-
import
|
|
34853
|
-
import { exec as
|
|
34854
|
-
import { promisify } from "util";
|
|
34855
|
-
var
|
|
34719
|
+
var import_fs_extra8 = __toESM(require_lib4(), 1);
|
|
34720
|
+
import os11 from "os";
|
|
34721
|
+
import path10 from "path";
|
|
34722
|
+
import { exec as exec3 } from "child_process";
|
|
34723
|
+
import { promisify as promisify2 } from "util";
|
|
34724
|
+
var execAsync2 = promisify2(exec3);
|
|
34856
34725
|
var PREMIUM_REPO = "Melvynx/aiblueprint-cli-premium";
|
|
34857
34726
|
var PREMIUM_BRANCH = "main";
|
|
34858
34727
|
function getCacheRepoDir() {
|
|
34859
|
-
return
|
|
34728
|
+
return path10.join(os11.homedir(), ".config", "aiblueprint", "pro-repos", "aiblueprint-cli-premium");
|
|
34860
34729
|
}
|
|
34861
34730
|
async function execGitWithAuth(command, token, repoUrl, cwd) {
|
|
34862
34731
|
const authenticatedUrl = `https://x-access-token:${token}@${repoUrl.replace(/^https?:\/\//, "")}`;
|
|
34863
34732
|
const fullCommand = `git ${command.replace(repoUrl, authenticatedUrl)}`;
|
|
34864
34733
|
try {
|
|
34865
|
-
await
|
|
34734
|
+
await execAsync2(fullCommand, { cwd, timeout: 120000 });
|
|
34866
34735
|
} catch (error) {
|
|
34867
34736
|
throw new Error(`Git command failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
34868
34737
|
}
|
|
@@ -34870,33 +34739,33 @@ async function execGitWithAuth(command, token, repoUrl, cwd) {
|
|
|
34870
34739
|
async function cloneOrUpdateRepo(token) {
|
|
34871
34740
|
const cacheDir = getCacheRepoDir();
|
|
34872
34741
|
const repoUrl = `https://github.com/${PREMIUM_REPO}.git`;
|
|
34873
|
-
if (await
|
|
34742
|
+
if (await import_fs_extra8.default.pathExists(path10.join(cacheDir, ".git"))) {
|
|
34874
34743
|
try {
|
|
34875
34744
|
await execGitWithAuth("pull", token, repoUrl, cacheDir);
|
|
34876
34745
|
} catch (error) {
|
|
34877
|
-
await
|
|
34878
|
-
await
|
|
34746
|
+
await import_fs_extra8.default.remove(cacheDir);
|
|
34747
|
+
await import_fs_extra8.default.ensureDir(path10.dirname(cacheDir));
|
|
34879
34748
|
await execGitWithAuth(`clone ${repoUrl} ${cacheDir}`, token, repoUrl);
|
|
34880
34749
|
}
|
|
34881
34750
|
} else {
|
|
34882
|
-
await
|
|
34751
|
+
await import_fs_extra8.default.ensureDir(path10.dirname(cacheDir));
|
|
34883
34752
|
await execGitWithAuth(`clone ${repoUrl} ${cacheDir}`, token, repoUrl);
|
|
34884
34753
|
}
|
|
34885
|
-
return
|
|
34754
|
+
return path10.join(cacheDir, "claude-code-config");
|
|
34886
34755
|
}
|
|
34887
34756
|
async function copyConfigFromCache(cacheConfigDir, targetDir, onProgress) {
|
|
34888
34757
|
const walk = async (dir, baseDir = dir) => {
|
|
34889
|
-
const entries = await
|
|
34758
|
+
const entries = await import_fs_extra8.default.readdir(dir, { withFileTypes: true });
|
|
34890
34759
|
for (const entry of entries) {
|
|
34891
|
-
const sourcePath =
|
|
34892
|
-
const relativePath =
|
|
34893
|
-
const targetPath =
|
|
34760
|
+
const sourcePath = path10.join(dir, entry.name);
|
|
34761
|
+
const relativePath = path10.relative(baseDir, sourcePath);
|
|
34762
|
+
const targetPath = path10.join(targetDir, relativePath);
|
|
34894
34763
|
if (entry.isDirectory()) {
|
|
34895
|
-
await
|
|
34764
|
+
await import_fs_extra8.default.ensureDir(targetPath);
|
|
34896
34765
|
onProgress?.(relativePath, "directory");
|
|
34897
34766
|
await walk(sourcePath, baseDir);
|
|
34898
34767
|
} else {
|
|
34899
|
-
await
|
|
34768
|
+
await import_fs_extra8.default.copy(sourcePath, targetPath, { overwrite: true });
|
|
34900
34769
|
onProgress?.(relativePath, "file");
|
|
34901
34770
|
}
|
|
34902
34771
|
}
|
|
@@ -34917,8 +34786,8 @@ async function downloadFromPrivateGitHub(repo, branch, relativePath, targetPath,
|
|
|
34917
34786
|
return false;
|
|
34918
34787
|
}
|
|
34919
34788
|
const content = await response.arrayBuffer();
|
|
34920
|
-
await
|
|
34921
|
-
await
|
|
34789
|
+
await import_fs_extra8.default.ensureDir(path10.dirname(targetPath));
|
|
34790
|
+
await import_fs_extra8.default.writeFile(targetPath, Buffer.from(content));
|
|
34922
34791
|
return true;
|
|
34923
34792
|
} catch (error) {
|
|
34924
34793
|
console.error(`Error downloading ${relativePath}:`, error);
|
|
@@ -34943,10 +34812,10 @@ async function downloadDirectoryFromPrivateGitHub(repo, branch, dirPath, targetD
|
|
|
34943
34812
|
console.error(`Unexpected response for directory ${dirPath}`);
|
|
34944
34813
|
return false;
|
|
34945
34814
|
}
|
|
34946
|
-
await
|
|
34815
|
+
await import_fs_extra8.default.ensureDir(targetDir);
|
|
34947
34816
|
for (const file of files) {
|
|
34948
34817
|
const relativePath = dirPath ? `${dirPath}/${file.name}` : file.name;
|
|
34949
|
-
const targetPath =
|
|
34818
|
+
const targetPath = path10.join(targetDir, file.name);
|
|
34950
34819
|
const displayPath = relativePath.replace("claude-code-config/", "");
|
|
34951
34820
|
if (file.type === "file") {
|
|
34952
34821
|
onProgress?.(displayPath, "file");
|
|
@@ -34963,7 +34832,7 @@ async function downloadDirectoryFromPrivateGitHub(repo, branch, dirPath, targetD
|
|
|
34963
34832
|
}
|
|
34964
34833
|
async function installProConfigs(options) {
|
|
34965
34834
|
const { githubToken, claudeCodeFolder, onProgress } = options;
|
|
34966
|
-
const claudeFolder = claudeCodeFolder ||
|
|
34835
|
+
const claudeFolder = claudeCodeFolder || path10.join(os11.homedir(), ".claude");
|
|
34967
34836
|
try {
|
|
34968
34837
|
const cacheConfigDir = await cloneOrUpdateRepo(githubToken);
|
|
34969
34838
|
await copyConfigFromCache(cacheConfigDir, claudeFolder, onProgress);
|
|
@@ -34971,53 +34840,53 @@ async function installProConfigs(options) {
|
|
|
34971
34840
|
} catch (error) {
|
|
34972
34841
|
console.warn("Git caching failed, falling back to API download");
|
|
34973
34842
|
}
|
|
34974
|
-
const tempDir =
|
|
34843
|
+
const tempDir = path10.join(os11.tmpdir(), `aiblueprint-premium-${Date.now()}`);
|
|
34975
34844
|
try {
|
|
34976
34845
|
const success = await downloadDirectoryFromPrivateGitHub(PREMIUM_REPO, PREMIUM_BRANCH, "claude-code-config", tempDir, githubToken, onProgress);
|
|
34977
34846
|
if (!success) {
|
|
34978
34847
|
throw new Error("Failed to download premium configurations");
|
|
34979
34848
|
}
|
|
34980
|
-
await
|
|
34849
|
+
await import_fs_extra8.default.copy(tempDir, claudeFolder, {
|
|
34981
34850
|
overwrite: true
|
|
34982
34851
|
});
|
|
34983
34852
|
} catch (error) {
|
|
34984
34853
|
throw new Error(`Failed to install premium configs: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
34985
34854
|
} finally {
|
|
34986
34855
|
try {
|
|
34987
|
-
await
|
|
34856
|
+
await import_fs_extra8.default.remove(tempDir);
|
|
34988
34857
|
} catch {}
|
|
34989
34858
|
}
|
|
34990
34859
|
}
|
|
34991
34860
|
|
|
34992
34861
|
// src/lib/token-storage.ts
|
|
34993
|
-
var
|
|
34994
|
-
import
|
|
34995
|
-
import
|
|
34862
|
+
var import_fs_extra9 = __toESM(require_lib4(), 1);
|
|
34863
|
+
import os12 from "os";
|
|
34864
|
+
import path11 from "path";
|
|
34996
34865
|
function getConfigDir() {
|
|
34997
|
-
const platform =
|
|
34866
|
+
const platform = os12.platform();
|
|
34998
34867
|
if (platform === "win32") {
|
|
34999
|
-
const appData = process.env.APPDATA ||
|
|
35000
|
-
return
|
|
34868
|
+
const appData = process.env.APPDATA || path11.join(os12.homedir(), "AppData", "Roaming");
|
|
34869
|
+
return path11.join(appData, "aiblueprint");
|
|
35001
34870
|
} else {
|
|
35002
|
-
const configHome = process.env.XDG_CONFIG_HOME ||
|
|
35003
|
-
return
|
|
34871
|
+
const configHome = process.env.XDG_CONFIG_HOME || path11.join(os12.homedir(), ".config");
|
|
34872
|
+
return path11.join(configHome, "aiblueprint");
|
|
35004
34873
|
}
|
|
35005
34874
|
}
|
|
35006
34875
|
function getTokenFilePath() {
|
|
35007
|
-
return
|
|
34876
|
+
return path11.join(getConfigDir(), "token.txt");
|
|
35008
34877
|
}
|
|
35009
34878
|
async function saveToken(githubToken) {
|
|
35010
34879
|
const tokenFile = getTokenFilePath();
|
|
35011
|
-
await
|
|
35012
|
-
await
|
|
34880
|
+
await import_fs_extra9.default.ensureDir(path11.dirname(tokenFile));
|
|
34881
|
+
await import_fs_extra9.default.writeFile(tokenFile, githubToken, { mode: 384 });
|
|
35013
34882
|
}
|
|
35014
34883
|
async function getToken() {
|
|
35015
34884
|
const tokenFile = getTokenFilePath();
|
|
35016
|
-
if (!await
|
|
34885
|
+
if (!await import_fs_extra9.default.pathExists(tokenFile)) {
|
|
35017
34886
|
return null;
|
|
35018
34887
|
}
|
|
35019
34888
|
try {
|
|
35020
|
-
const token = await
|
|
34889
|
+
const token = await import_fs_extra9.default.readFile(tokenFile, "utf-8");
|
|
35021
34890
|
return token.trim();
|
|
35022
34891
|
} catch (error) {
|
|
35023
34892
|
return null;
|
|
@@ -35026,12 +34895,12 @@ async function getToken() {
|
|
|
35026
34895
|
function getTokenInfo() {
|
|
35027
34896
|
return {
|
|
35028
34897
|
path: getTokenFilePath(),
|
|
35029
|
-
platform:
|
|
34898
|
+
platform: os12.platform()
|
|
35030
34899
|
};
|
|
35031
34900
|
}
|
|
35032
34901
|
|
|
35033
34902
|
// src/commands/pro.ts
|
|
35034
|
-
var
|
|
34903
|
+
var import_fs_extra10 = __toESM(require_lib4(), 1);
|
|
35035
34904
|
var API_URL = "https://codeline.app/api/products";
|
|
35036
34905
|
var PRODUCT_IDS = ["prd_XJVgxVPbGG", "prd_NKabAkdOkw"];
|
|
35037
34906
|
async function countInstalledItems(claudeDir) {
|
|
@@ -35041,29 +34910,29 @@ async function countInstalledItems(claudeDir) {
|
|
|
35041
34910
|
skills: 0
|
|
35042
34911
|
};
|
|
35043
34912
|
try {
|
|
35044
|
-
const commandsDir =
|
|
35045
|
-
if (await
|
|
35046
|
-
const files = await
|
|
34913
|
+
const commandsDir = path12.join(claudeDir, "commands");
|
|
34914
|
+
if (await import_fs_extra10.default.pathExists(commandsDir)) {
|
|
34915
|
+
const files = await import_fs_extra10.default.readdir(commandsDir);
|
|
35047
34916
|
counts.commands = files.filter((f) => f.endsWith(".md")).length;
|
|
35048
34917
|
}
|
|
35049
34918
|
} catch (error) {
|
|
35050
34919
|
console.error("Failed to count commands:", error instanceof Error ? error.message : error);
|
|
35051
34920
|
}
|
|
35052
34921
|
try {
|
|
35053
|
-
const agentsDir =
|
|
35054
|
-
if (await
|
|
35055
|
-
const files = await
|
|
34922
|
+
const agentsDir = path12.join(claudeDir, "agents");
|
|
34923
|
+
if (await import_fs_extra10.default.pathExists(agentsDir)) {
|
|
34924
|
+
const files = await import_fs_extra10.default.readdir(agentsDir);
|
|
35056
34925
|
counts.agents = files.filter((f) => f.endsWith(".md")).length;
|
|
35057
34926
|
}
|
|
35058
34927
|
} catch (error) {
|
|
35059
34928
|
console.error("Failed to count agents:", error instanceof Error ? error.message : error);
|
|
35060
34929
|
}
|
|
35061
34930
|
try {
|
|
35062
|
-
const skillsDir =
|
|
35063
|
-
if (await
|
|
35064
|
-
const items = await
|
|
34931
|
+
const skillsDir = path12.join(claudeDir, "skills");
|
|
34932
|
+
if (await import_fs_extra10.default.pathExists(skillsDir)) {
|
|
34933
|
+
const items = await import_fs_extra10.default.readdir(skillsDir);
|
|
35065
34934
|
const dirs = await Promise.all(items.map(async (item) => {
|
|
35066
|
-
const stat = await
|
|
34935
|
+
const stat = await import_fs_extra10.default.stat(path12.join(skillsDir, item));
|
|
35067
34936
|
return stat.isDirectory();
|
|
35068
34937
|
}));
|
|
35069
34938
|
counts.skills = dirs.filter(Boolean).length;
|
|
@@ -35176,7 +35045,7 @@ async function proSetupCommand(options = {}) {
|
|
|
35176
35045
|
Se(source_default.red("❌ Not activated"));
|
|
35177
35046
|
process.exit(1);
|
|
35178
35047
|
}
|
|
35179
|
-
const claudeDir = options.folder ?
|
|
35048
|
+
const claudeDir = options.folder ? path12.resolve(options.folder) : path12.join(os13.homedir(), ".claude");
|
|
35180
35049
|
const spinner = Y2();
|
|
35181
35050
|
const onProgress = (file, type) => {
|
|
35182
35051
|
spinner.message(`Installing: ${source_default.cyan(file)} ${source_default.gray(`(${type})`)}`);
|
|
@@ -35258,12 +35127,12 @@ async function proUpdateCommand(options = {}) {
|
|
|
35258
35127
|
}
|
|
35259
35128
|
|
|
35260
35129
|
// src/commands/sync.ts
|
|
35261
|
-
import
|
|
35262
|
-
import
|
|
35130
|
+
import os14 from "os";
|
|
35131
|
+
import path14 from "path";
|
|
35263
35132
|
|
|
35264
35133
|
// src/lib/sync-utils.ts
|
|
35265
|
-
var
|
|
35266
|
-
import
|
|
35134
|
+
var import_fs_extra11 = __toESM(require_lib4(), 1);
|
|
35135
|
+
import path13 from "path";
|
|
35267
35136
|
import crypto from "crypto";
|
|
35268
35137
|
var PREMIUM_REPO2 = "Melvynx/aiblueprint-cli-premium";
|
|
35269
35138
|
var PREMIUM_BRANCH2 = "main";
|
|
@@ -35312,7 +35181,7 @@ async function listRemoteFilesRecursive(dirPath, githubToken, basePath = "") {
|
|
|
35312
35181
|
}
|
|
35313
35182
|
async function computeLocalFileSha(filePath) {
|
|
35314
35183
|
try {
|
|
35315
|
-
const content = await
|
|
35184
|
+
const content = await import_fs_extra11.default.readFile(filePath);
|
|
35316
35185
|
return computeFileSha(content);
|
|
35317
35186
|
} catch {
|
|
35318
35187
|
return null;
|
|
@@ -35320,15 +35189,15 @@ async function computeLocalFileSha(filePath) {
|
|
|
35320
35189
|
}
|
|
35321
35190
|
async function listLocalFiles(dir) {
|
|
35322
35191
|
const files = [];
|
|
35323
|
-
if (!await
|
|
35192
|
+
if (!await import_fs_extra11.default.pathExists(dir)) {
|
|
35324
35193
|
return files;
|
|
35325
35194
|
}
|
|
35326
|
-
const items = await
|
|
35195
|
+
const items = await import_fs_extra11.default.readdir(dir);
|
|
35327
35196
|
for (const item of items) {
|
|
35328
35197
|
if (item === "node_modules" || item === ".DS_Store")
|
|
35329
35198
|
continue;
|
|
35330
|
-
const fullPath =
|
|
35331
|
-
const stat = await
|
|
35199
|
+
const fullPath = path13.join(dir, item);
|
|
35200
|
+
const stat = await import_fs_extra11.default.stat(fullPath);
|
|
35332
35201
|
if (stat.isDirectory()) {
|
|
35333
35202
|
files.push(item);
|
|
35334
35203
|
const subFiles = await listLocalFilesRecursive(fullPath, item);
|
|
@@ -35341,13 +35210,13 @@ async function listLocalFiles(dir) {
|
|
|
35341
35210
|
}
|
|
35342
35211
|
async function listLocalFilesRecursive(dir, basePath) {
|
|
35343
35212
|
const files = [];
|
|
35344
|
-
const items = await
|
|
35213
|
+
const items = await import_fs_extra11.default.readdir(dir);
|
|
35345
35214
|
for (const item of items) {
|
|
35346
35215
|
if (item === "node_modules" || item === ".DS_Store")
|
|
35347
35216
|
continue;
|
|
35348
|
-
const fullPath =
|
|
35217
|
+
const fullPath = path13.join(dir, item);
|
|
35349
35218
|
const relativePath = `${basePath}/${item}`;
|
|
35350
|
-
const stat = await
|
|
35219
|
+
const stat = await import_fs_extra11.default.stat(fullPath);
|
|
35351
35220
|
if (stat.isDirectory()) {
|
|
35352
35221
|
files.push(relativePath);
|
|
35353
35222
|
const subFiles = await listLocalFilesRecursive(fullPath, relativePath);
|
|
@@ -35360,7 +35229,7 @@ async function listLocalFilesRecursive(dir, basePath) {
|
|
|
35360
35229
|
}
|
|
35361
35230
|
async function analyzeCategory(category, claudeDir, githubToken) {
|
|
35362
35231
|
const items = [];
|
|
35363
|
-
const localDir =
|
|
35232
|
+
const localDir = path13.join(claudeDir, category);
|
|
35364
35233
|
const remoteFiles = await listRemoteFilesRecursive(category, githubToken);
|
|
35365
35234
|
const localFiles = await listLocalFiles(localDir);
|
|
35366
35235
|
const remoteSet = new Map;
|
|
@@ -35369,7 +35238,7 @@ async function analyzeCategory(category, claudeDir, githubToken) {
|
|
|
35369
35238
|
}
|
|
35370
35239
|
const localSet = new Set(localFiles);
|
|
35371
35240
|
for (const [remotePath, { sha, isFolder }] of remoteSet) {
|
|
35372
|
-
const localPath =
|
|
35241
|
+
const localPath = path13.join(localDir, remotePath);
|
|
35373
35242
|
if (isFolder) {
|
|
35374
35243
|
continue;
|
|
35375
35244
|
}
|
|
@@ -35412,8 +35281,8 @@ async function analyzeCategory(category, claudeDir, githubToken) {
|
|
|
35412
35281
|
if (parentAlreadyDeleted) {
|
|
35413
35282
|
continue;
|
|
35414
35283
|
}
|
|
35415
|
-
const fullPath =
|
|
35416
|
-
const stat = await
|
|
35284
|
+
const fullPath = path13.join(localDir, localPath);
|
|
35285
|
+
const stat = await import_fs_extra11.default.stat(fullPath).catch(() => null);
|
|
35417
35286
|
if (stat) {
|
|
35418
35287
|
const isFolder = stat.isDirectory();
|
|
35419
35288
|
items.push({
|
|
@@ -35449,9 +35318,9 @@ async function fetchRemoteSettings(githubToken) {
|
|
|
35449
35318
|
}
|
|
35450
35319
|
}
|
|
35451
35320
|
async function getLocalSettings(claudeDir) {
|
|
35452
|
-
const settingsPath =
|
|
35321
|
+
const settingsPath = path13.join(claudeDir, "settings.json");
|
|
35453
35322
|
try {
|
|
35454
|
-
const content = await
|
|
35323
|
+
const content = await import_fs_extra11.default.readFile(settingsPath, "utf-8");
|
|
35455
35324
|
return JSON.parse(content);
|
|
35456
35325
|
} catch {
|
|
35457
35326
|
return {};
|
|
@@ -35533,8 +35402,8 @@ async function downloadFromPrivateGitHub2(relativePath, targetPath, githubToken)
|
|
|
35533
35402
|
return false;
|
|
35534
35403
|
}
|
|
35535
35404
|
const content = await response.arrayBuffer();
|
|
35536
|
-
await
|
|
35537
|
-
await
|
|
35405
|
+
await import_fs_extra11.default.ensureDir(path13.dirname(targetPath));
|
|
35406
|
+
await import_fs_extra11.default.writeFile(targetPath, Buffer.from(content));
|
|
35538
35407
|
return true;
|
|
35539
35408
|
} catch {
|
|
35540
35409
|
return false;
|
|
@@ -35544,10 +35413,10 @@ async function syncSelectedHooks(claudeDir, hooks, onProgress) {
|
|
|
35544
35413
|
if (hooks.length === 0) {
|
|
35545
35414
|
return { success: 0, failed: 0 };
|
|
35546
35415
|
}
|
|
35547
|
-
const settingsPath =
|
|
35416
|
+
const settingsPath = path13.join(claudeDir, "settings.json");
|
|
35548
35417
|
let settings = {};
|
|
35549
35418
|
try {
|
|
35550
|
-
const content = await
|
|
35419
|
+
const content = await import_fs_extra11.default.readFile(settingsPath, "utf-8");
|
|
35551
35420
|
settings = JSON.parse(content);
|
|
35552
35421
|
} catch {
|
|
35553
35422
|
settings = {};
|
|
@@ -35575,7 +35444,7 @@ async function syncSelectedHooks(claudeDir, hooks, onProgress) {
|
|
|
35575
35444
|
failed++;
|
|
35576
35445
|
}
|
|
35577
35446
|
}
|
|
35578
|
-
await
|
|
35447
|
+
await import_fs_extra11.default.writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
35579
35448
|
return { success, failed };
|
|
35580
35449
|
}
|
|
35581
35450
|
async function syncSelectedItems(claudeDir, items, githubToken, onProgress) {
|
|
@@ -35583,11 +35452,11 @@ async function syncSelectedItems(claudeDir, items, githubToken, onProgress) {
|
|
|
35583
35452
|
let failed = 0;
|
|
35584
35453
|
let deleted = 0;
|
|
35585
35454
|
for (const item of items) {
|
|
35586
|
-
const targetPath =
|
|
35455
|
+
const targetPath = path13.join(claudeDir, item.relativePath);
|
|
35587
35456
|
if (item.status === "deleted") {
|
|
35588
35457
|
onProgress?.(item.relativePath, "deleting");
|
|
35589
35458
|
try {
|
|
35590
|
-
await
|
|
35459
|
+
await import_fs_extra11.default.remove(targetPath);
|
|
35591
35460
|
deleted++;
|
|
35592
35461
|
} catch {
|
|
35593
35462
|
failed++;
|
|
@@ -35739,7 +35608,7 @@ async function proSyncCommand(options = {}) {
|
|
|
35739
35608
|
Se(source_default.red("❌ Not activated"));
|
|
35740
35609
|
process.exit(1);
|
|
35741
35610
|
}
|
|
35742
|
-
const claudeDir = options.folder ?
|
|
35611
|
+
const claudeDir = options.folder ? path14.resolve(options.folder) : path14.join(os14.homedir(), ".claude");
|
|
35743
35612
|
const spinner = Y2();
|
|
35744
35613
|
spinner.start("Analyzing changes...");
|
|
35745
35614
|
const result = await analyzeSyncChanges(claudeDir, githubToken);
|
|
@@ -35967,10 +35836,170 @@ async function proSyncCommand(options = {}) {
|
|
|
35967
35836
|
}
|
|
35968
35837
|
}
|
|
35969
35838
|
|
|
35839
|
+
// src/commands/dynamic-scripts.ts
|
|
35840
|
+
import path17 from "path";
|
|
35841
|
+
import { homedir } from "os";
|
|
35842
|
+
|
|
35843
|
+
// src/lib/script-parser.ts
|
|
35844
|
+
var import_fs_extra12 = __toESM(require_lib4(), 1);
|
|
35845
|
+
import path15 from "path";
|
|
35846
|
+
var EXCLUDED_SCRIPTS = ["test", "lint", "format", "start"];
|
|
35847
|
+
var EXCLUDED_SUFFIXES = [":test", ":lint", ":test-fixtures", ":start"];
|
|
35848
|
+
function shouldIncludeScript(scriptName) {
|
|
35849
|
+
if (EXCLUDED_SCRIPTS.includes(scriptName))
|
|
35850
|
+
return false;
|
|
35851
|
+
if (EXCLUDED_SUFFIXES.some((suffix) => scriptName.endsWith(suffix)))
|
|
35852
|
+
return false;
|
|
35853
|
+
return true;
|
|
35854
|
+
}
|
|
35855
|
+
async function readScriptsPackageJson(claudeDir) {
|
|
35856
|
+
const packageJsonPath = path15.join(claudeDir, "scripts", "package.json");
|
|
35857
|
+
try {
|
|
35858
|
+
if (!await import_fs_extra12.default.pathExists(packageJsonPath)) {
|
|
35859
|
+
return null;
|
|
35860
|
+
}
|
|
35861
|
+
const content = await import_fs_extra12.default.readFile(packageJsonPath, "utf-8");
|
|
35862
|
+
const parsed = JSON.parse(content);
|
|
35863
|
+
return parsed.scripts || null;
|
|
35864
|
+
} catch (error) {
|
|
35865
|
+
if (process.env.DEBUG) {
|
|
35866
|
+
console.error("Failed to read scripts package.json:", error);
|
|
35867
|
+
}
|
|
35868
|
+
return null;
|
|
35869
|
+
}
|
|
35870
|
+
}
|
|
35871
|
+
function parseScriptCommands(scripts) {
|
|
35872
|
+
const commands = [];
|
|
35873
|
+
for (const scriptName of Object.keys(scripts)) {
|
|
35874
|
+
if (!shouldIncludeScript(scriptName)) {
|
|
35875
|
+
continue;
|
|
35876
|
+
}
|
|
35877
|
+
if (!scriptName.includes(":")) {
|
|
35878
|
+
continue;
|
|
35879
|
+
}
|
|
35880
|
+
const [prefix, ...actionParts] = scriptName.split(":");
|
|
35881
|
+
const action = actionParts.join(":");
|
|
35882
|
+
if (!action) {
|
|
35883
|
+
continue;
|
|
35884
|
+
}
|
|
35885
|
+
commands.push({
|
|
35886
|
+
prefix,
|
|
35887
|
+
action,
|
|
35888
|
+
fullScriptName: scriptName
|
|
35889
|
+
});
|
|
35890
|
+
}
|
|
35891
|
+
return commands;
|
|
35892
|
+
}
|
|
35893
|
+
function groupScriptsByPrefix(commands) {
|
|
35894
|
+
const groups = {};
|
|
35895
|
+
for (const command of commands) {
|
|
35896
|
+
if (!groups[command.prefix]) {
|
|
35897
|
+
groups[command.prefix] = [];
|
|
35898
|
+
}
|
|
35899
|
+
groups[command.prefix].push(command.action);
|
|
35900
|
+
}
|
|
35901
|
+
return groups;
|
|
35902
|
+
}
|
|
35903
|
+
|
|
35904
|
+
// src/commands/script-runner.ts
|
|
35905
|
+
var import_fs_extra13 = __toESM(require_lib4(), 1);
|
|
35906
|
+
import { spawn as spawn2 } from "child_process";
|
|
35907
|
+
import { execSync as execSync4 } from "child_process";
|
|
35908
|
+
import path16 from "path";
|
|
35909
|
+
import os15 from "os";
|
|
35910
|
+
function checkCommand(cmd) {
|
|
35911
|
+
try {
|
|
35912
|
+
const isWindows = os15.platform() === "win32";
|
|
35913
|
+
const whichCmd = isWindows ? `where ${cmd}` : `which ${cmd}`;
|
|
35914
|
+
execSync4(whichCmd, { stdio: "ignore" });
|
|
35915
|
+
return true;
|
|
35916
|
+
} catch {
|
|
35917
|
+
return false;
|
|
35918
|
+
}
|
|
35919
|
+
}
|
|
35920
|
+
function showAvailableActions(prefix, actions) {
|
|
35921
|
+
console.log(source_default.blue(`
|
|
35922
|
+
${prefix.charAt(0).toUpperCase() + prefix.slice(1)} Scripts:`));
|
|
35923
|
+
console.log(source_default.gray(`Run scripts from ~/.claude/scripts
|
|
35924
|
+
`));
|
|
35925
|
+
for (const action of actions) {
|
|
35926
|
+
console.log(source_default.white(` ${prefix} ${action}`));
|
|
35927
|
+
}
|
|
35928
|
+
console.log(source_default.gray(`
|
|
35929
|
+
Usage: aiblueprint ${prefix} <action>`));
|
|
35930
|
+
console.log(source_default.gray(`Example: aiblueprint ${prefix} ${actions[0] || "start"}
|
|
35931
|
+
`));
|
|
35932
|
+
}
|
|
35933
|
+
async function executeScript(scriptName, claudeDir) {
|
|
35934
|
+
if (!checkCommand("bun")) {
|
|
35935
|
+
console.error(source_default.red("Bun is not installed. Install with: npm install -g bun"));
|
|
35936
|
+
return 1;
|
|
35937
|
+
}
|
|
35938
|
+
const scriptsDir = path16.join(claudeDir, "scripts");
|
|
35939
|
+
if (!await import_fs_extra13.default.pathExists(scriptsDir)) {
|
|
35940
|
+
console.error(source_default.red(`Scripts directory not found at ${scriptsDir}`));
|
|
35941
|
+
console.log(source_default.gray("Run: aiblueprint claude-code setup"));
|
|
35942
|
+
return 1;
|
|
35943
|
+
}
|
|
35944
|
+
const packageJsonPath = path16.join(scriptsDir, "package.json");
|
|
35945
|
+
if (!await import_fs_extra13.default.pathExists(packageJsonPath)) {
|
|
35946
|
+
console.error(source_default.red(`package.json not found in ${scriptsDir}`));
|
|
35947
|
+
return 1;
|
|
35948
|
+
}
|
|
35949
|
+
const packageJson = await import_fs_extra13.default.readJson(packageJsonPath);
|
|
35950
|
+
if (!packageJson.scripts || !packageJson.scripts[scriptName]) {
|
|
35951
|
+
console.error(source_default.red(`Script "${scriptName}" not found in package.json`));
|
|
35952
|
+
return 1;
|
|
35953
|
+
}
|
|
35954
|
+
return new Promise((resolve) => {
|
|
35955
|
+
const child = spawn2("bun", ["run", scriptName], {
|
|
35956
|
+
cwd: scriptsDir,
|
|
35957
|
+
stdio: "inherit",
|
|
35958
|
+
env: process.env
|
|
35959
|
+
});
|
|
35960
|
+
child.on("close", (code) => {
|
|
35961
|
+
resolve(code || 0);
|
|
35962
|
+
});
|
|
35963
|
+
child.on("error", (error) => {
|
|
35964
|
+
console.error(source_default.red(`Failed to execute script: ${error.message}`));
|
|
35965
|
+
resolve(1);
|
|
35966
|
+
});
|
|
35967
|
+
});
|
|
35968
|
+
}
|
|
35969
|
+
|
|
35970
|
+
// src/commands/dynamic-scripts.ts
|
|
35971
|
+
function getClaudeDir(parentOptions) {
|
|
35972
|
+
return parentOptions.claudeCodeFolder || parentOptions.folder ? path17.resolve(parentOptions.claudeCodeFolder || parentOptions.folder) : path17.join(homedir(), ".claude");
|
|
35973
|
+
}
|
|
35974
|
+
async function registerDynamicScriptCommands(claudeCodeCmd, claudeDir) {
|
|
35975
|
+
const scripts = await readScriptsPackageJson(claudeDir);
|
|
35976
|
+
if (!scripts) {
|
|
35977
|
+
return;
|
|
35978
|
+
}
|
|
35979
|
+
const commands = parseScriptCommands(scripts);
|
|
35980
|
+
if (commands.length === 0) {
|
|
35981
|
+
return;
|
|
35982
|
+
}
|
|
35983
|
+
const scriptGroups = groupScriptsByPrefix(commands);
|
|
35984
|
+
for (const [prefix, actions] of Object.entries(scriptGroups)) {
|
|
35985
|
+
const command = claudeCodeCmd.command(`${prefix} [action]`).description(`Run ${prefix} scripts from ~/.claude/scripts`).option("-l, --list", "List available actions").action(async (action, options) => {
|
|
35986
|
+
const parentOptions = command.parent?.opts() || {};
|
|
35987
|
+
const resolvedClaudeDir = getClaudeDir(parentOptions);
|
|
35988
|
+
if (options.list || !action) {
|
|
35989
|
+
showAvailableActions(prefix, actions);
|
|
35990
|
+
return;
|
|
35991
|
+
}
|
|
35992
|
+
const exitCode = await executeScript(`${prefix}:${action}`, resolvedClaudeDir);
|
|
35993
|
+
process.exit(exitCode);
|
|
35994
|
+
});
|
|
35995
|
+
}
|
|
35996
|
+
}
|
|
35997
|
+
|
|
35970
35998
|
// src/cli.ts
|
|
35971
35999
|
import { readFileSync as readFileSync3 } from "fs";
|
|
35972
36000
|
import { dirname as dirname3, join as join2 } from "path";
|
|
35973
36001
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
36002
|
+
import { homedir as homedir2 } from "os";
|
|
35974
36003
|
var __dirname3 = dirname3(fileURLToPath3(import.meta.url));
|
|
35975
36004
|
var packageJson = JSON.parse(readFileSync3(join2(__dirname3, "../package.json"), "utf8"));
|
|
35976
36005
|
var program2 = new Command;
|
|
@@ -36001,11 +36030,6 @@ claudeCodeCmd.command("symlink").description("Create symlinks between different
|
|
|
36001
36030
|
factoryAiFolder: parentOptions.factoryAiFolder
|
|
36002
36031
|
});
|
|
36003
36032
|
});
|
|
36004
|
-
claudeCodeCmd.command("statusline").description("Setup custom statusline with git status, costs, and token usage").action((options, command) => {
|
|
36005
|
-
const parentOptions = command.parent.opts();
|
|
36006
|
-
const claudeCodeFolder = parentOptions.claudeCodeFolder || parentOptions.folder;
|
|
36007
|
-
statuslineCommand({ folder: claudeCodeFolder });
|
|
36008
|
-
});
|
|
36009
36033
|
var proCmd = claudeCodeCmd.command("pro").description("Manage AIBlueprint CLI Premium features");
|
|
36010
36034
|
proCmd.command("activate [token]").description("Activate AIBlueprint CLI Premium with your access token").action((token) => {
|
|
36011
36035
|
proActivateCommand(token);
|
|
@@ -36028,6 +36052,14 @@ proCmd.command("sync").description("Sync premium configurations with selective u
|
|
|
36028
36052
|
const claudeCodeFolder = parentOptions.claudeCodeFolder || parentOptions.folder;
|
|
36029
36053
|
proSyncCommand({ folder: claudeCodeFolder });
|
|
36030
36054
|
});
|
|
36055
|
+
try {
|
|
36056
|
+
const claudeDir = join2(homedir2(), ".claude");
|
|
36057
|
+
await registerDynamicScriptCommands(claudeCodeCmd, claudeDir);
|
|
36058
|
+
} catch (error) {
|
|
36059
|
+
if (process.env.DEBUG) {
|
|
36060
|
+
console.error("Failed to register dynamic commands:", error);
|
|
36061
|
+
}
|
|
36062
|
+
}
|
|
36031
36063
|
program2.parse(process.argv);
|
|
36032
36064
|
if (!process.argv.slice(2).length) {
|
|
36033
36065
|
console.log(source_default.blue("\uD83D\uDE80 AIBlueprint CLI"));
|