aiblueprint-cli 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +110 -107
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -33220,8 +33220,8 @@ async function updateSettings(options, claudeDir) {
|
|
|
33220
33220
|
}
|
|
33221
33221
|
|
|
33222
33222
|
// src/commands/addHook.ts
|
|
33223
|
-
var
|
|
33224
|
-
import
|
|
33223
|
+
var import_fs_extra5 = __toESM(require_lib4(), 1);
|
|
33224
|
+
import path6 from "path";
|
|
33225
33225
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
33226
33226
|
import { dirname as dirname3 } from "path";
|
|
33227
33227
|
|
|
@@ -33285,6 +33285,101 @@ async function getTargetDirectory(options) {
|
|
|
33285
33285
|
return path3.join(process.env.HOME || process.env.USERPROFILE || "~", ".claude");
|
|
33286
33286
|
}
|
|
33287
33287
|
|
|
33288
|
+
// src/utils/file-installer.ts
|
|
33289
|
+
var import_fs_extra4 = __toESM(require_lib4(), 1);
|
|
33290
|
+
import path5 from "path";
|
|
33291
|
+
|
|
33292
|
+
// src/utils/github.ts
|
|
33293
|
+
var import_fs_extra3 = __toESM(require_lib4(), 1);
|
|
33294
|
+
import path4 from "path";
|
|
33295
|
+
var GITHUB_RAW_BASE2 = "https://raw.githubusercontent.com/Melvynx/aiblueprint-cli/main/claude-code-config";
|
|
33296
|
+
async function downloadFromGitHub2(relativePath) {
|
|
33297
|
+
try {
|
|
33298
|
+
const url = `${GITHUB_RAW_BASE2}/${relativePath}`;
|
|
33299
|
+
const response = await fetch(url);
|
|
33300
|
+
if (!response.ok) {
|
|
33301
|
+
return null;
|
|
33302
|
+
}
|
|
33303
|
+
return await response.text();
|
|
33304
|
+
} catch (error) {
|
|
33305
|
+
return null;
|
|
33306
|
+
}
|
|
33307
|
+
}
|
|
33308
|
+
async function listFilesFromGitHub(dirPath) {
|
|
33309
|
+
try {
|
|
33310
|
+
const apiUrl = `https://api.github.com/repos/Melvynx/aiblueprint-cli/contents/claude-code-config/${dirPath}`;
|
|
33311
|
+
const response = await fetch(apiUrl);
|
|
33312
|
+
if (!response.ok) {
|
|
33313
|
+
return [];
|
|
33314
|
+
}
|
|
33315
|
+
const files = await response.json();
|
|
33316
|
+
return files.filter((file) => file.type === "file").map((file) => file.name);
|
|
33317
|
+
} catch (error) {
|
|
33318
|
+
return [];
|
|
33319
|
+
}
|
|
33320
|
+
}
|
|
33321
|
+
async function isGitHubAvailable() {
|
|
33322
|
+
try {
|
|
33323
|
+
const testUrl = `${GITHUB_RAW_BASE2}/commands/commit.md`;
|
|
33324
|
+
const testResponse = await fetch(testUrl);
|
|
33325
|
+
return testResponse.ok;
|
|
33326
|
+
} catch {
|
|
33327
|
+
return false;
|
|
33328
|
+
}
|
|
33329
|
+
}
|
|
33330
|
+
async function downloadAndWriteFile(relativePath, targetPath) {
|
|
33331
|
+
const content = await downloadFromGitHub2(relativePath);
|
|
33332
|
+
if (content) {
|
|
33333
|
+
await import_fs_extra3.default.ensureDir(path4.dirname(targetPath));
|
|
33334
|
+
await import_fs_extra3.default.writeFile(targetPath, content);
|
|
33335
|
+
return true;
|
|
33336
|
+
}
|
|
33337
|
+
return false;
|
|
33338
|
+
}
|
|
33339
|
+
|
|
33340
|
+
// src/utils/file-installer.ts
|
|
33341
|
+
async function installFileWithGitHubFallback(options) {
|
|
33342
|
+
const { sourceDir, targetPath, fileName } = options;
|
|
33343
|
+
await import_fs_extra4.default.ensureDir(path5.dirname(targetPath));
|
|
33344
|
+
const useGitHub = options.useGitHub ?? await isGitHubAvailable();
|
|
33345
|
+
if (useGitHub) {
|
|
33346
|
+
const relativePath = `${sourceDir}/${fileName}`;
|
|
33347
|
+
const success = await downloadAndWriteFile(relativePath, targetPath);
|
|
33348
|
+
if (success) {
|
|
33349
|
+
return;
|
|
33350
|
+
}
|
|
33351
|
+
console.log(source_default.yellow(`⚠️ GitHub download failed for ${fileName}, falling back to local files`));
|
|
33352
|
+
}
|
|
33353
|
+
const localConfigDir = await findLocalConfigDir(sourceDir);
|
|
33354
|
+
if (!localConfigDir) {
|
|
33355
|
+
throw new Error(`Neither GitHub nor local ${sourceDir} directory found`);
|
|
33356
|
+
}
|
|
33357
|
+
const localFilePath = path5.join(localConfigDir, fileName);
|
|
33358
|
+
if (!await import_fs_extra4.default.pathExists(localFilePath)) {
|
|
33359
|
+
throw new Error(`File not found: ${fileName}`);
|
|
33360
|
+
}
|
|
33361
|
+
await import_fs_extra4.default.copy(localFilePath, targetPath);
|
|
33362
|
+
}
|
|
33363
|
+
async function getFileContentWithGitHubFallback(sourceDir, fileName) {
|
|
33364
|
+
const useGitHub = await isGitHubAvailable();
|
|
33365
|
+
if (useGitHub) {
|
|
33366
|
+
const content = await downloadFromGitHub2(`${sourceDir}/${fileName}`);
|
|
33367
|
+
if (content) {
|
|
33368
|
+
return content;
|
|
33369
|
+
}
|
|
33370
|
+
console.log(source_default.yellow(`⚠️ GitHub download failed for ${fileName}, falling back to local files`));
|
|
33371
|
+
}
|
|
33372
|
+
const localConfigDir = await findLocalConfigDir(sourceDir);
|
|
33373
|
+
if (!localConfigDir) {
|
|
33374
|
+
throw new Error(`Neither GitHub nor local ${sourceDir} directory found`);
|
|
33375
|
+
}
|
|
33376
|
+
const localFilePath = path5.join(localConfigDir, fileName);
|
|
33377
|
+
if (!await import_fs_extra4.default.pathExists(localFilePath)) {
|
|
33378
|
+
throw new Error(`File not found: ${fileName}`);
|
|
33379
|
+
}
|
|
33380
|
+
return await import_fs_extra4.default.readFile(localFilePath, "utf-8");
|
|
33381
|
+
}
|
|
33382
|
+
|
|
33288
33383
|
// src/commands/addHook.ts
|
|
33289
33384
|
var __filename4 = fileURLToPath3(import.meta.url);
|
|
33290
33385
|
var __dirname4 = dirname3(__filename4);
|
|
@@ -33322,10 +33417,10 @@ async function addHookCommand(hookType, options) {
|
|
|
33322
33417
|
const s = new SimpleSpinner2;
|
|
33323
33418
|
const targetDir = await getTargetDirectory(options);
|
|
33324
33419
|
const claudeDir = targetDir;
|
|
33325
|
-
const hooksDir =
|
|
33326
|
-
const hookFilePath =
|
|
33327
|
-
const settingsPath =
|
|
33328
|
-
if (await
|
|
33420
|
+
const hooksDir = path6.join(claudeDir, "hooks");
|
|
33421
|
+
const hookFilePath = path6.join(hooksDir, hook.hookFile);
|
|
33422
|
+
const settingsPath = path6.join(claudeDir, "settings.json");
|
|
33423
|
+
if (await import_fs_extra5.default.pathExists(hookFilePath)) {
|
|
33329
33424
|
const overwriteAnswer = await lib_default.prompt([{
|
|
33330
33425
|
type: "confirm",
|
|
33331
33426
|
name: "overwrite",
|
|
@@ -33338,15 +33433,18 @@ async function addHookCommand(hookType, options) {
|
|
|
33338
33433
|
}
|
|
33339
33434
|
try {
|
|
33340
33435
|
s.start("Installing hook...");
|
|
33341
|
-
await
|
|
33342
|
-
|
|
33343
|
-
|
|
33344
|
-
|
|
33436
|
+
await import_fs_extra5.default.ensureDir(hooksDir);
|
|
33437
|
+
await installFileWithGitHubFallback({
|
|
33438
|
+
sourceDir: "hooks",
|
|
33439
|
+
targetPath: hookFilePath,
|
|
33440
|
+
fileName: hook.hookFile
|
|
33441
|
+
});
|
|
33442
|
+
await import_fs_extra5.default.chmod(hookFilePath, 493);
|
|
33345
33443
|
s.stop("Hook file installed");
|
|
33346
33444
|
s.start("Updating settings.json...");
|
|
33347
33445
|
let settings = {};
|
|
33348
33446
|
try {
|
|
33349
|
-
const existingSettings = await
|
|
33447
|
+
const existingSettings = await import_fs_extra5.default.readFile(settingsPath, "utf-8");
|
|
33350
33448
|
settings = JSON.parse(existingSettings);
|
|
33351
33449
|
} catch {
|
|
33352
33450
|
settings = {};
|
|
@@ -33383,7 +33481,7 @@ async function addHookCommand(hookType, options) {
|
|
|
33383
33481
|
} else {
|
|
33384
33482
|
settings.hooks[hook.event].push(newHook);
|
|
33385
33483
|
}
|
|
33386
|
-
await
|
|
33484
|
+
await import_fs_extra5.default.writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
33387
33485
|
s.stop("Settings updated");
|
|
33388
33486
|
console.log(source_default.green("✨ Hook installed successfully!"));
|
|
33389
33487
|
console.log(source_default.gray(`
|
|
@@ -33404,101 +33502,6 @@ The hook will run automatically when you edit TypeScript files with Claude Code.
|
|
|
33404
33502
|
// src/commands/addCommand.ts
|
|
33405
33503
|
var import_fs_extra6 = __toESM(require_lib4(), 1);
|
|
33406
33504
|
import path7 from "path";
|
|
33407
|
-
|
|
33408
|
-
// src/utils/github.ts
|
|
33409
|
-
var import_fs_extra4 = __toESM(require_lib4(), 1);
|
|
33410
|
-
import path5 from "path";
|
|
33411
|
-
var GITHUB_RAW_BASE2 = "https://raw.githubusercontent.com/Melvynx/aiblueprint-cli/main/claude-code-config";
|
|
33412
|
-
async function downloadFromGitHub2(relativePath) {
|
|
33413
|
-
try {
|
|
33414
|
-
const url = `${GITHUB_RAW_BASE2}/${relativePath}`;
|
|
33415
|
-
const response = await fetch(url);
|
|
33416
|
-
if (!response.ok) {
|
|
33417
|
-
return null;
|
|
33418
|
-
}
|
|
33419
|
-
return await response.text();
|
|
33420
|
-
} catch (error) {
|
|
33421
|
-
return null;
|
|
33422
|
-
}
|
|
33423
|
-
}
|
|
33424
|
-
async function listFilesFromGitHub(dirPath) {
|
|
33425
|
-
try {
|
|
33426
|
-
const apiUrl = `https://api.github.com/repos/Melvynx/aiblueprint-cli/contents/claude-code-config/${dirPath}`;
|
|
33427
|
-
const response = await fetch(apiUrl);
|
|
33428
|
-
if (!response.ok) {
|
|
33429
|
-
return [];
|
|
33430
|
-
}
|
|
33431
|
-
const files = await response.json();
|
|
33432
|
-
return files.filter((file) => file.type === "file").map((file) => file.name);
|
|
33433
|
-
} catch (error) {
|
|
33434
|
-
return [];
|
|
33435
|
-
}
|
|
33436
|
-
}
|
|
33437
|
-
async function isGitHubAvailable() {
|
|
33438
|
-
try {
|
|
33439
|
-
const testUrl = `${GITHUB_RAW_BASE2}/commands/commit.md`;
|
|
33440
|
-
const testResponse = await fetch(testUrl);
|
|
33441
|
-
return testResponse.ok;
|
|
33442
|
-
} catch {
|
|
33443
|
-
return false;
|
|
33444
|
-
}
|
|
33445
|
-
}
|
|
33446
|
-
async function downloadAndWriteFile(relativePath, targetPath) {
|
|
33447
|
-
const content = await downloadFromGitHub2(relativePath);
|
|
33448
|
-
if (content) {
|
|
33449
|
-
await import_fs_extra4.default.ensureDir(path5.dirname(targetPath));
|
|
33450
|
-
await import_fs_extra4.default.writeFile(targetPath, content);
|
|
33451
|
-
return true;
|
|
33452
|
-
}
|
|
33453
|
-
return false;
|
|
33454
|
-
}
|
|
33455
|
-
|
|
33456
|
-
// src/utils/file-installer.ts
|
|
33457
|
-
var import_fs_extra5 = __toESM(require_lib4(), 1);
|
|
33458
|
-
import path6 from "path";
|
|
33459
|
-
async function installFileWithGitHubFallback(options) {
|
|
33460
|
-
const { sourceDir, targetPath, fileName } = options;
|
|
33461
|
-
await import_fs_extra5.default.ensureDir(path6.dirname(targetPath));
|
|
33462
|
-
const useGitHub = options.useGitHub ?? await isGitHubAvailable();
|
|
33463
|
-
if (useGitHub) {
|
|
33464
|
-
const relativePath = `${sourceDir}/${fileName}`;
|
|
33465
|
-
const success = await downloadAndWriteFile(relativePath, targetPath);
|
|
33466
|
-
if (success) {
|
|
33467
|
-
return;
|
|
33468
|
-
}
|
|
33469
|
-
console.log(source_default.yellow(`⚠️ GitHub download failed for ${fileName}, falling back to local files`));
|
|
33470
|
-
}
|
|
33471
|
-
const localConfigDir = await findLocalConfigDir(sourceDir);
|
|
33472
|
-
if (!localConfigDir) {
|
|
33473
|
-
throw new Error(`Neither GitHub nor local ${sourceDir} directory found`);
|
|
33474
|
-
}
|
|
33475
|
-
const localFilePath = path6.join(localConfigDir, fileName);
|
|
33476
|
-
if (!await import_fs_extra5.default.pathExists(localFilePath)) {
|
|
33477
|
-
throw new Error(`File not found: ${fileName}`);
|
|
33478
|
-
}
|
|
33479
|
-
await import_fs_extra5.default.copy(localFilePath, targetPath);
|
|
33480
|
-
}
|
|
33481
|
-
async function getFileContentWithGitHubFallback(sourceDir, fileName) {
|
|
33482
|
-
const useGitHub = await isGitHubAvailable();
|
|
33483
|
-
if (useGitHub) {
|
|
33484
|
-
const content = await downloadFromGitHub2(`${sourceDir}/${fileName}`);
|
|
33485
|
-
if (content) {
|
|
33486
|
-
return content;
|
|
33487
|
-
}
|
|
33488
|
-
console.log(source_default.yellow(`⚠️ GitHub download failed for ${fileName}, falling back to local files`));
|
|
33489
|
-
}
|
|
33490
|
-
const localConfigDir = await findLocalConfigDir(sourceDir);
|
|
33491
|
-
if (!localConfigDir) {
|
|
33492
|
-
throw new Error(`Neither GitHub nor local ${sourceDir} directory found`);
|
|
33493
|
-
}
|
|
33494
|
-
const localFilePath = path6.join(localConfigDir, fileName);
|
|
33495
|
-
if (!await import_fs_extra5.default.pathExists(localFilePath)) {
|
|
33496
|
-
throw new Error(`File not found: ${fileName}`);
|
|
33497
|
-
}
|
|
33498
|
-
return await import_fs_extra5.default.readFile(localFilePath, "utf-8");
|
|
33499
|
-
}
|
|
33500
|
-
|
|
33501
|
-
// src/commands/addCommand.ts
|
|
33502
33505
|
class SimpleSpinner3 {
|
|
33503
33506
|
message = "";
|
|
33504
33507
|
start(message) {
|