aiblueprint-cli 1.1.2 → 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 +171 -177
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -33220,12 +33220,169 @@ async function updateSettings(options, claudeDir) {
|
|
|
33220
33220
|
}
|
|
33221
33221
|
|
|
33222
33222
|
// src/commands/addHook.ts
|
|
33223
|
+
var import_fs_extra5 = __toESM(require_lib4(), 1);
|
|
33224
|
+
import path6 from "path";
|
|
33225
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
33226
|
+
import { dirname as dirname3 } from "path";
|
|
33227
|
+
|
|
33228
|
+
// src/utils/claude-config.ts
|
|
33223
33229
|
var import_fs_extra2 = __toESM(require_lib4(), 1);
|
|
33224
33230
|
import path3 from "path";
|
|
33225
33231
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
33226
33232
|
import { dirname as dirname2 } from "path";
|
|
33227
33233
|
var __filename3 = fileURLToPath2(import.meta.url);
|
|
33228
33234
|
var __dirname3 = dirname2(__filename3);
|
|
33235
|
+
function parseYamlFrontmatter(content) {
|
|
33236
|
+
const lines = content.split(`
|
|
33237
|
+
`);
|
|
33238
|
+
if (lines[0] !== "---") {
|
|
33239
|
+
return { metadata: {}, body: content };
|
|
33240
|
+
}
|
|
33241
|
+
const endIndex = lines.findIndex((line, index) => index > 0 && line === "---");
|
|
33242
|
+
if (endIndex === -1) {
|
|
33243
|
+
return { metadata: {}, body: content };
|
|
33244
|
+
}
|
|
33245
|
+
const frontmatterLines = lines.slice(1, endIndex);
|
|
33246
|
+
const body = lines.slice(endIndex + 1).join(`
|
|
33247
|
+
`);
|
|
33248
|
+
const metadata = {};
|
|
33249
|
+
frontmatterLines.forEach((line) => {
|
|
33250
|
+
const colonIndex = line.indexOf(":");
|
|
33251
|
+
if (colonIndex > -1) {
|
|
33252
|
+
const key = line.substring(0, colonIndex).trim();
|
|
33253
|
+
const value = line.substring(colonIndex + 1).trim();
|
|
33254
|
+
metadata[key] = value;
|
|
33255
|
+
}
|
|
33256
|
+
});
|
|
33257
|
+
return { metadata, body };
|
|
33258
|
+
}
|
|
33259
|
+
function getLocalConfigPaths(subDir) {
|
|
33260
|
+
return [
|
|
33261
|
+
path3.join(__dirname3, `../claude-code-config/${subDir}`),
|
|
33262
|
+
path3.join(__dirname3, `../../claude-code-config/${subDir}`)
|
|
33263
|
+
];
|
|
33264
|
+
}
|
|
33265
|
+
async function findLocalConfigDir(subDir) {
|
|
33266
|
+
const possiblePaths = getLocalConfigPaths(subDir);
|
|
33267
|
+
for (const testPath of possiblePaths) {
|
|
33268
|
+
if (await import_fs_extra2.default.pathExists(testPath)) {
|
|
33269
|
+
return testPath;
|
|
33270
|
+
}
|
|
33271
|
+
}
|
|
33272
|
+
return null;
|
|
33273
|
+
}
|
|
33274
|
+
async function getTargetDirectory(options) {
|
|
33275
|
+
if (options.folder) {
|
|
33276
|
+
return options.folder;
|
|
33277
|
+
}
|
|
33278
|
+
const cwd = process.cwd();
|
|
33279
|
+
const localClaudeDir = path3.join(cwd, ".claude");
|
|
33280
|
+
const isGitRepo = await import_fs_extra2.default.pathExists(path3.join(cwd, ".git"));
|
|
33281
|
+
const hasClaudeConfig = await import_fs_extra2.default.pathExists(localClaudeDir);
|
|
33282
|
+
if (isGitRepo || hasClaudeConfig) {
|
|
33283
|
+
return localClaudeDir;
|
|
33284
|
+
}
|
|
33285
|
+
return path3.join(process.env.HOME || process.env.USERPROFILE || "~", ".claude");
|
|
33286
|
+
}
|
|
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
|
+
|
|
33383
|
+
// src/commands/addHook.ts
|
|
33384
|
+
var __filename4 = fileURLToPath3(import.meta.url);
|
|
33385
|
+
var __dirname4 = dirname3(__filename4);
|
|
33229
33386
|
|
|
33230
33387
|
class SimpleSpinner2 {
|
|
33231
33388
|
message = "";
|
|
@@ -33258,24 +33415,12 @@ async function addHookCommand(hookType, options) {
|
|
|
33258
33415
|
}
|
|
33259
33416
|
const hook = supportedHooks[hookType];
|
|
33260
33417
|
const s = new SimpleSpinner2;
|
|
33261
|
-
const targetDir =
|
|
33262
|
-
if (!options.folder) {
|
|
33263
|
-
const cwd = process.cwd();
|
|
33264
|
-
const isGitRepo = await import_fs_extra2.default.pathExists(path3.join(cwd, ".git"));
|
|
33265
|
-
const hasClaudeConfig = await import_fs_extra2.default.pathExists(path3.join(cwd, ".claude"));
|
|
33266
|
-
if (!isGitRepo && !hasClaudeConfig) {
|
|
33267
|
-
console.log(source_default.red("❌ Not in a project directory. Please run this command in a Git repository or a directory with .claude/ configuration."));
|
|
33268
|
-
process.exit(1);
|
|
33269
|
-
}
|
|
33270
|
-
const claudeDir2 = path3.join(cwd, ".claude");
|
|
33271
|
-
} else {
|
|
33272
|
-
console.log(source_default.gray(`Using custom folder: ${targetDir}`));
|
|
33273
|
-
}
|
|
33418
|
+
const targetDir = await getTargetDirectory(options);
|
|
33274
33419
|
const claudeDir = targetDir;
|
|
33275
|
-
const hooksDir =
|
|
33276
|
-
const hookFilePath =
|
|
33277
|
-
const settingsPath =
|
|
33278
|
-
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)) {
|
|
33279
33424
|
const overwriteAnswer = await lib_default.prompt([{
|
|
33280
33425
|
type: "confirm",
|
|
33281
33426
|
name: "overwrite",
|
|
@@ -33288,15 +33433,18 @@ async function addHookCommand(hookType, options) {
|
|
|
33288
33433
|
}
|
|
33289
33434
|
try {
|
|
33290
33435
|
s.start("Installing hook...");
|
|
33291
|
-
await
|
|
33292
|
-
|
|
33293
|
-
|
|
33294
|
-
|
|
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);
|
|
33295
33443
|
s.stop("Hook file installed");
|
|
33296
33444
|
s.start("Updating settings.json...");
|
|
33297
33445
|
let settings = {};
|
|
33298
33446
|
try {
|
|
33299
|
-
const existingSettings = await
|
|
33447
|
+
const existingSettings = await import_fs_extra5.default.readFile(settingsPath, "utf-8");
|
|
33300
33448
|
settings = JSON.parse(existingSettings);
|
|
33301
33449
|
} catch {
|
|
33302
33450
|
settings = {};
|
|
@@ -33333,7 +33481,7 @@ async function addHookCommand(hookType, options) {
|
|
|
33333
33481
|
} else {
|
|
33334
33482
|
settings.hooks[hook.event].push(newHook);
|
|
33335
33483
|
}
|
|
33336
|
-
await
|
|
33484
|
+
await import_fs_extra5.default.writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
33337
33485
|
s.stop("Settings updated");
|
|
33338
33486
|
console.log(source_default.green("✨ Hook installed successfully!"));
|
|
33339
33487
|
console.log(source_default.gray(`
|
|
@@ -33354,160 +33502,6 @@ The hook will run automatically when you edit TypeScript files with Claude Code.
|
|
|
33354
33502
|
// src/commands/addCommand.ts
|
|
33355
33503
|
var import_fs_extra6 = __toESM(require_lib4(), 1);
|
|
33356
33504
|
import path7 from "path";
|
|
33357
|
-
|
|
33358
|
-
// src/utils/github.ts
|
|
33359
|
-
var import_fs_extra3 = __toESM(require_lib4(), 1);
|
|
33360
|
-
import path4 from "path";
|
|
33361
|
-
var GITHUB_RAW_BASE2 = "https://raw.githubusercontent.com/Melvynx/aiblueprint-cli/main/claude-code-config";
|
|
33362
|
-
async function downloadFromGitHub2(relativePath) {
|
|
33363
|
-
try {
|
|
33364
|
-
const url = `${GITHUB_RAW_BASE2}/${relativePath}`;
|
|
33365
|
-
const response = await fetch(url);
|
|
33366
|
-
if (!response.ok) {
|
|
33367
|
-
return null;
|
|
33368
|
-
}
|
|
33369
|
-
return await response.text();
|
|
33370
|
-
} catch (error) {
|
|
33371
|
-
return null;
|
|
33372
|
-
}
|
|
33373
|
-
}
|
|
33374
|
-
async function listFilesFromGitHub(dirPath) {
|
|
33375
|
-
try {
|
|
33376
|
-
const apiUrl = `https://api.github.com/repos/Melvynx/aiblueprint-cli/contents/claude-code-config/${dirPath}`;
|
|
33377
|
-
const response = await fetch(apiUrl);
|
|
33378
|
-
if (!response.ok) {
|
|
33379
|
-
return [];
|
|
33380
|
-
}
|
|
33381
|
-
const files = await response.json();
|
|
33382
|
-
return files.filter((file) => file.type === "file").map((file) => file.name);
|
|
33383
|
-
} catch (error) {
|
|
33384
|
-
return [];
|
|
33385
|
-
}
|
|
33386
|
-
}
|
|
33387
|
-
async function isGitHubAvailable() {
|
|
33388
|
-
try {
|
|
33389
|
-
const testUrl = `${GITHUB_RAW_BASE2}/commands/commit.md`;
|
|
33390
|
-
const testResponse = await fetch(testUrl);
|
|
33391
|
-
return testResponse.ok;
|
|
33392
|
-
} catch {
|
|
33393
|
-
return false;
|
|
33394
|
-
}
|
|
33395
|
-
}
|
|
33396
|
-
async function downloadAndWriteFile(relativePath, targetPath) {
|
|
33397
|
-
const content = await downloadFromGitHub2(relativePath);
|
|
33398
|
-
if (content) {
|
|
33399
|
-
await import_fs_extra3.default.ensureDir(path4.dirname(targetPath));
|
|
33400
|
-
await import_fs_extra3.default.writeFile(targetPath, content);
|
|
33401
|
-
return true;
|
|
33402
|
-
}
|
|
33403
|
-
return false;
|
|
33404
|
-
}
|
|
33405
|
-
|
|
33406
|
-
// src/utils/claude-config.ts
|
|
33407
|
-
var import_fs_extra4 = __toESM(require_lib4(), 1);
|
|
33408
|
-
import path5 from "path";
|
|
33409
|
-
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
33410
|
-
import { dirname as dirname3 } from "path";
|
|
33411
|
-
var __filename4 = fileURLToPath3(import.meta.url);
|
|
33412
|
-
var __dirname4 = dirname3(__filename4);
|
|
33413
|
-
function parseYamlFrontmatter(content) {
|
|
33414
|
-
const lines = content.split(`
|
|
33415
|
-
`);
|
|
33416
|
-
if (lines[0] !== "---") {
|
|
33417
|
-
return { metadata: {}, body: content };
|
|
33418
|
-
}
|
|
33419
|
-
const endIndex = lines.findIndex((line, index) => index > 0 && line === "---");
|
|
33420
|
-
if (endIndex === -1) {
|
|
33421
|
-
return { metadata: {}, body: content };
|
|
33422
|
-
}
|
|
33423
|
-
const frontmatterLines = lines.slice(1, endIndex);
|
|
33424
|
-
const body = lines.slice(endIndex + 1).join(`
|
|
33425
|
-
`);
|
|
33426
|
-
const metadata = {};
|
|
33427
|
-
frontmatterLines.forEach((line) => {
|
|
33428
|
-
const colonIndex = line.indexOf(":");
|
|
33429
|
-
if (colonIndex > -1) {
|
|
33430
|
-
const key = line.substring(0, colonIndex).trim();
|
|
33431
|
-
const value = line.substring(colonIndex + 1).trim();
|
|
33432
|
-
metadata[key] = value;
|
|
33433
|
-
}
|
|
33434
|
-
});
|
|
33435
|
-
return { metadata, body };
|
|
33436
|
-
}
|
|
33437
|
-
function getLocalConfigPaths(subDir) {
|
|
33438
|
-
return [
|
|
33439
|
-
path5.join(__dirname4, `../claude-code-config/${subDir}`),
|
|
33440
|
-
path5.join(__dirname4, `../../claude-code-config/${subDir}`)
|
|
33441
|
-
];
|
|
33442
|
-
}
|
|
33443
|
-
async function findLocalConfigDir(subDir) {
|
|
33444
|
-
const possiblePaths = getLocalConfigPaths(subDir);
|
|
33445
|
-
for (const testPath of possiblePaths) {
|
|
33446
|
-
if (await import_fs_extra4.default.pathExists(testPath)) {
|
|
33447
|
-
return testPath;
|
|
33448
|
-
}
|
|
33449
|
-
}
|
|
33450
|
-
return null;
|
|
33451
|
-
}
|
|
33452
|
-
async function getTargetDirectory(options) {
|
|
33453
|
-
let targetDir = options.folder || path5.join(process.env.HOME || process.env.USERPROFILE || "~", ".claude");
|
|
33454
|
-
if (!options.folder) {
|
|
33455
|
-
const cwd = process.cwd();
|
|
33456
|
-
const isGitRepo = await import_fs_extra4.default.pathExists(path5.join(cwd, ".git"));
|
|
33457
|
-
const hasClaudeConfig = await import_fs_extra4.default.pathExists(path5.join(cwd, ".claude"));
|
|
33458
|
-
if (isGitRepo || hasClaudeConfig) {
|
|
33459
|
-
targetDir = path5.join(cwd, ".claude");
|
|
33460
|
-
}
|
|
33461
|
-
}
|
|
33462
|
-
return targetDir;
|
|
33463
|
-
}
|
|
33464
|
-
|
|
33465
|
-
// src/utils/file-installer.ts
|
|
33466
|
-
var import_fs_extra5 = __toESM(require_lib4(), 1);
|
|
33467
|
-
import path6 from "path";
|
|
33468
|
-
async function installFileWithGitHubFallback(options) {
|
|
33469
|
-
const { sourceDir, targetPath, fileName } = options;
|
|
33470
|
-
await import_fs_extra5.default.ensureDir(path6.dirname(targetPath));
|
|
33471
|
-
const useGitHub = options.useGitHub ?? await isGitHubAvailable();
|
|
33472
|
-
if (useGitHub) {
|
|
33473
|
-
const relativePath = `${sourceDir}/${fileName}`;
|
|
33474
|
-
const success = await downloadAndWriteFile(relativePath, targetPath);
|
|
33475
|
-
if (success) {
|
|
33476
|
-
return;
|
|
33477
|
-
}
|
|
33478
|
-
console.log(source_default.yellow(`⚠️ GitHub download failed for ${fileName}, falling back to local files`));
|
|
33479
|
-
}
|
|
33480
|
-
const localConfigDir = await findLocalConfigDir(sourceDir);
|
|
33481
|
-
if (!localConfigDir) {
|
|
33482
|
-
throw new Error(`Neither GitHub nor local ${sourceDir} directory found`);
|
|
33483
|
-
}
|
|
33484
|
-
const localFilePath = path6.join(localConfigDir, fileName);
|
|
33485
|
-
if (!await import_fs_extra5.default.pathExists(localFilePath)) {
|
|
33486
|
-
throw new Error(`File not found: ${fileName}`);
|
|
33487
|
-
}
|
|
33488
|
-
await import_fs_extra5.default.copy(localFilePath, targetPath);
|
|
33489
|
-
}
|
|
33490
|
-
async function getFileContentWithGitHubFallback(sourceDir, fileName) {
|
|
33491
|
-
const useGitHub = await isGitHubAvailable();
|
|
33492
|
-
if (useGitHub) {
|
|
33493
|
-
const content = await downloadFromGitHub2(`${sourceDir}/${fileName}`);
|
|
33494
|
-
if (content) {
|
|
33495
|
-
return content;
|
|
33496
|
-
}
|
|
33497
|
-
console.log(source_default.yellow(`⚠️ GitHub download failed for ${fileName}, falling back to local files`));
|
|
33498
|
-
}
|
|
33499
|
-
const localConfigDir = await findLocalConfigDir(sourceDir);
|
|
33500
|
-
if (!localConfigDir) {
|
|
33501
|
-
throw new Error(`Neither GitHub nor local ${sourceDir} directory found`);
|
|
33502
|
-
}
|
|
33503
|
-
const localFilePath = path6.join(localConfigDir, fileName);
|
|
33504
|
-
if (!await import_fs_extra5.default.pathExists(localFilePath)) {
|
|
33505
|
-
throw new Error(`File not found: ${fileName}`);
|
|
33506
|
-
}
|
|
33507
|
-
return await import_fs_extra5.default.readFile(localFilePath, "utf-8");
|
|
33508
|
-
}
|
|
33509
|
-
|
|
33510
|
-
// src/commands/addCommand.ts
|
|
33511
33505
|
class SimpleSpinner3 {
|
|
33512
33506
|
message = "";
|
|
33513
33507
|
start(message) {
|