aiblueprint-cli 1.4.59 → 1.4.61
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 +16 -36
- package/agents-config/agents/action.md +1 -1
- package/agents-config/agents/explore-codebase.md +53 -53
- package/agents-config/agents/explore-docs.md +50 -69
- package/agents-config/agents/websearch.md +36 -40
- package/agents-config/claude-config/scripts/.claude/skills/fix-on-my-computer/SKILL.md +81 -0
- package/agents-config/claude-config/scripts/CLAUDE.md +10 -4
- package/agents-config/claude-config/scripts/bun.lockb +0 -0
- package/agents-config/claude-config/scripts/package.json +22 -30
- package/agents-config/claude-config/scripts/statusline/CLAUDE.md +37 -155
- package/agents-config/claude-config/scripts/statusline/README.md +18 -94
- package/agents-config/claude-config/scripts/statusline/defaults.json +13 -10
- package/agents-config/claude-config/scripts/statusline/fixtures/mock-transcript.jsonl +4 -4
- package/agents-config/claude-config/scripts/statusline/fixtures/test-input.json +4 -4
- package/agents-config/claude-config/scripts/statusline/src/commands/interactive-config.ts +403 -0
- package/agents-config/claude-config/scripts/statusline/src/index.ts +33 -82
- package/agents-config/claude-config/scripts/statusline/src/lib/config-types.ts +7 -1
- package/agents-config/claude-config/scripts/statusline/src/lib/formatters.ts +40 -0
- package/agents-config/claude-config/scripts/statusline/src/lib/presets.ts +13 -13
- package/agents-config/claude-config/scripts/statusline/src/lib/render-pure.ts +24 -5
- package/agents-config/claude-config/scripts/statusline/statusline.config.free.json +79 -0
- package/agents-config/claude-config/scripts/statusline/statusline.config.json +77 -77
- package/agents-config/codex-config/config.toml +9 -0
- package/agents-config/codex-config/hooks/command-deny-list.ts +203 -0
- package/agents-config/commands/prompts/create-vitejs-app.md +272 -0
- package/agents-config/commands/prompts/nextjs-add-prisma-db.md +136 -0
- package/agents-config/commands/prompts/nextjs-setup-better-auth.md +173 -0
- package/agents-config/commands/prompts/nextjs-setup-project.md +200 -0
- package/agents-config/commands/prompts/prompt.md +55 -0
- package/agents-config/commands/prompts/saas-challenge-idea.md +135 -0
- package/agents-config/commands/prompts/saas-create-architecture.md +242 -0
- package/agents-config/commands/prompts/saas-create-headline.md +132 -0
- package/agents-config/commands/prompts/saas-create-landing-copywritting.md +267 -0
- package/agents-config/commands/prompts/saas-create-legals-docs.md +176 -0
- package/agents-config/commands/prompts/saas-create-logos.md +240 -0
- package/agents-config/commands/prompts/saas-create-prd.md +195 -0
- package/agents-config/commands/prompts/saas-create-tasks.md +240 -0
- package/agents-config/commands/prompts/saas-define-pricing.md +293 -0
- package/agents-config/commands/prompts/saas-find-domain-name.md +190 -0
- package/agents-config/commands/prompts/saas-implement-landing-page.md +257 -0
- package/agents-config/commands/prompts/setup-tmux.md +160 -0
- package/agents-config/commands/prompts/tools.md +148 -0
- package/agents-config/scripts/.claude/skills/fix-on-my-computer/SKILL.md +81 -0
- package/agents-config/scripts/CLAUDE.md +37 -0
- package/agents-config/scripts/biome.json +37 -0
- package/agents-config/scripts/bun.lockb +0 -0
- package/agents-config/scripts/package.json +24 -0
- package/agents-config/scripts/statusline/CLAUDE.md +87 -0
- package/agents-config/scripts/statusline/README.md +117 -0
- package/agents-config/scripts/statusline/__tests__/context.test.ts +229 -0
- package/agents-config/scripts/statusline/__tests__/formatters.test.ts +108 -0
- package/agents-config/scripts/statusline/__tests__/statusline.test.ts +309 -0
- package/agents-config/scripts/statusline/defaults.json +82 -0
- package/agents-config/scripts/statusline/fixtures/mock-transcript.jsonl +4 -0
- package/agents-config/scripts/statusline/fixtures/test-input.json +35 -0
- package/agents-config/scripts/statusline/src/commands/interactive-config.ts +403 -0
- package/agents-config/scripts/statusline/src/index.ts +141 -0
- package/agents-config/scripts/statusline/src/lib/config-types.ts +110 -0
- package/agents-config/scripts/statusline/src/lib/config.ts +21 -0
- package/agents-config/scripts/statusline/src/lib/context.ts +103 -0
- package/agents-config/scripts/statusline/src/lib/formatters.ts +426 -0
- package/agents-config/scripts/statusline/src/lib/git.ts +100 -0
- package/agents-config/scripts/statusline/src/lib/menu-factories.ts +224 -0
- package/agents-config/scripts/statusline/src/lib/presets.ts +177 -0
- package/agents-config/scripts/statusline/src/lib/render-pure.ts +516 -0
- package/agents-config/scripts/statusline/src/lib/types.ts +36 -0
- package/agents-config/scripts/statusline/src/lib/utils.ts +15 -0
- package/agents-config/scripts/statusline/statusline.config.free.json +79 -0
- package/agents-config/scripts/statusline/statusline.config.json +79 -0
- package/agents-config/scripts/statusline/test-with-fixtures.ts +37 -0
- package/agents-config/scripts/statusline/test.ts +20 -0
- package/agents-config/scripts/statusline/tsconfig.json +27 -0
- package/agents-config/scripts/tsconfig.json +27 -0
- package/agents-config/skills/{subagent-creator → agents-managers}/SKILL.md +47 -47
- package/agents-config/skills/{subagent-creator/references/subagents.md → agents-managers/references/agents.md} +45 -45
- package/agents-config/skills/{subagent-creator → agents-managers}/references/context-management.md +20 -20
- package/agents-config/skills/{subagent-creator → agents-managers}/references/debugging-agents.md +27 -27
- package/agents-config/skills/{subagent-creator → agents-managers}/references/error-handling-and-recovery.md +19 -19
- package/agents-config/skills/{subagent-creator → agents-managers}/references/evaluation-and-testing.md +29 -29
- package/agents-config/skills/{subagent-creator → agents-managers}/references/orchestration-patterns.md +5 -5
- package/agents-config/skills/{subagent-creator/references/writing-subagent-prompts.md → agents-managers/references/writing-agent-prompts.md} +23 -23
- package/agents-config/skills/codex-environment/SKILL.md +2 -0
- package/agents-config/skills/commit/SKILL.md +2 -0
- package/agents-config/skills/create-pr/SKILL.md +2 -0
- package/agents-config/skills/environments-manager/SKILL.md +271 -0
- package/agents-config/skills/environments-manager/examples/claude/.worktreeinclude +3 -0
- package/agents-config/skills/environments-manager/examples/claude/commands/dev.md +5 -0
- package/agents-config/skills/environments-manager/examples/claude/commands/lint.md +5 -0
- package/agents-config/skills/environments-manager/examples/claude/commands/test.md +5 -0
- package/agents-config/skills/environments-manager/examples/claude/commands/typecheck.md +5 -0
- package/agents-config/skills/environments-manager/examples/claude/settings.json +24 -0
- package/agents-config/skills/environments-manager/examples/codex/environments/environment.toml +29 -0
- package/agents-config/skills/environments-manager/examples/cursor/worktrees.json +3 -0
- package/agents-config/skills/environments-manager/examples/scripts/claude-worktree-create.sh +96 -0
- package/agents-config/skills/environments-manager/examples/scripts/claude-worktree-remove.sh +66 -0
- package/agents-config/skills/environments-manager/examples/scripts/dev.sh +15 -0
- package/agents-config/skills/environments-manager/examples/scripts/worktree-down.sh +22 -0
- package/agents-config/skills/environments-manager/examples/scripts/worktree-up.sh +50 -0
- package/agents-config/skills/environments-manager/references/claude.md +156 -0
- package/agents-config/skills/environments-manager/references/codex.md +97 -0
- package/agents-config/skills/environments-manager/references/cursor.md +88 -0
- package/agents-config/skills/fix-pr-comments/SKILL.md +2 -0
- package/agents-config/skills/grill-me/SKILL.md +10 -0
- package/agents-config/skills/merge/SKILL.md +2 -0
- package/agents-config/skills/rules-manager/SKILL.md +191 -0
- package/agents-config/skills/rules-manager/references/agents-vs-claude.md +66 -0
- package/agents-config/skills/rules-manager/references/examples.md +117 -0
- package/agents-config/skills/skill-manager/SKILL.md +101 -0
- package/agents-config/skills/skill-manager/references/claude-code.md +81 -0
- package/agents-config/skills/skill-manager/references/codex.md +288 -0
- package/agents-config/skills/skill-manager/references/cursor.md +125 -0
- package/agents-config/skills/skill-manager/references/description-recommandation.md +97 -0
- package/agents-config/skills/skill-manager/scripts/inspect-description.ts +743 -0
- package/agents-config/skills/ultrathink/SKILL.md +2 -0
- package/dist/cli.js +581 -299
- package/package.json +1 -1
- package/agents-config/claude-config/scripts/statusline/data/.gitignore +0 -8
- package/agents-config/claude-config/scripts/statusline/data/.gitkeep +0 -0
- package/agents-config/claude-config/scripts/statusline/docs/ARCHITECTURE.md +0 -166
- package/agents-config/claude-config/scripts/statusline/src/tests/spend-v2.test.ts +0 -306
- package/agents-config/skills/apex/SKILL.md +0 -261
- package/agents-config/skills/apex/scripts/setup-templates.sh +0 -100
- package/agents-config/skills/apex/scripts/update-progress.sh +0 -80
- package/agents-config/skills/apex/steps/step-00-init.md +0 -267
- package/agents-config/skills/apex/steps/step-00b-branch.md +0 -126
- package/agents-config/skills/apex/steps/step-00b-economy.md +0 -244
- package/agents-config/skills/apex/steps/step-00b-interactive.md +0 -153
- package/agents-config/skills/apex/steps/step-01-analyze.md +0 -361
- package/agents-config/skills/apex/steps/step-02-plan.md +0 -264
- package/agents-config/skills/apex/steps/step-03-execute.md +0 -239
- package/agents-config/skills/apex/steps/step-04-validate.md +0 -251
- package/agents-config/skills/apex/templates/00-context.md +0 -43
- package/agents-config/skills/apex/templates/01-analyze.md +0 -10
- package/agents-config/skills/apex/templates/02-plan.md +0 -10
- package/agents-config/skills/apex/templates/03-execute.md +0 -10
- package/agents-config/skills/apex/templates/04-validate.md +0 -10
- package/agents-config/skills/apex/templates/README.md +0 -176
- package/agents-config/skills/apex/templates/step-complete.md +0 -7
- package/agents-config/skills/claude-memory/SKILL.md +0 -293
- package/agents-config/skills/claude-memory/references/comprehensive-example.md +0 -175
- package/agents-config/skills/claude-memory/references/optimize-guide.md +0 -300
- package/agents-config/skills/claude-memory/references/project-patterns.md +0 -334
- package/agents-config/skills/claude-memory/references/prompting-techniques.md +0 -411
- package/agents-config/skills/claude-memory/references/rules-directory-guide.md +0 -298
- package/agents-config/skills/claude-memory/references/section-templates.md +0 -347
- package/agents-config/skills/fix-errors/SKILL.md +0 -61
- package/agents-config/skills/fix-grammar/SKILL.md +0 -59
- package/agents-config/skills/ralph-loop/SKILL.md +0 -117
- package/agents-config/skills/ralph-loop/scripts/setup.sh +0 -278
- package/agents-config/skills/ralph-loop/steps/step-00-init.md +0 -215
- package/agents-config/skills/ralph-loop/steps/step-01-interactive-prd.md +0 -366
- package/agents-config/skills/ralph-loop/steps/step-02-create-stories.md +0 -273
- package/agents-config/skills/ralph-loop/steps/step-03-finish.md +0 -245
- package/agents-config/skills/skill-creator/LICENSE.txt +0 -202
- package/agents-config/skills/skill-creator/SKILL.md +0 -421
- package/agents-config/skills/skill-creator/package.json +0 -5
- package/agents-config/skills/skill-creator/references/output-patterns.md +0 -82
- package/agents-config/skills/skill-creator/references/progressive-disclosure-patterns.md +0 -374
- package/agents-config/skills/skill-creator/references/prompting-integration.md +0 -363
- package/agents-config/skills/skill-creator/references/real-world-examples.md +0 -513
- package/agents-config/skills/skill-creator/references/script-patterns.md +0 -385
- package/agents-config/skills/skill-creator/references/workflows.md +0 -28
- package/agents-config/skills/skill-creator/references/xml-tag-guide.md +0 -606
- package/agents-config/skills/skill-creator/scripts/init-skill.ts +0 -214
- package/agents-config/skills/skill-creator/scripts/package-skill.ts +0 -146
- package/agents-config/skills/skill-creator/scripts/validate.ts +0 -138
- package/agents-config/skills/workflow-apex-free/SKILL.md +0 -261
- package/agents-config/skills/workflow-apex-free/scripts/setup-templates.sh +0 -100
- package/agents-config/skills/workflow-apex-free/scripts/update-progress.sh +0 -80
- package/agents-config/skills/workflow-apex-free/steps/step-00-init.md +0 -267
- package/agents-config/skills/workflow-apex-free/steps/step-00b-branch.md +0 -126
- package/agents-config/skills/workflow-apex-free/steps/step-00b-economy.md +0 -244
- package/agents-config/skills/workflow-apex-free/steps/step-00b-interactive.md +0 -153
- package/agents-config/skills/workflow-apex-free/steps/step-01-analyze.md +0 -361
- package/agents-config/skills/workflow-apex-free/steps/step-02-plan.md +0 -264
- package/agents-config/skills/workflow-apex-free/steps/step-03-execute.md +0 -239
- package/agents-config/skills/workflow-apex-free/steps/step-04-validate.md +0 -251
- package/agents-config/skills/workflow-apex-free/templates/00-context.md +0 -43
- package/agents-config/skills/workflow-apex-free/templates/01-analyze.md +0 -10
- package/agents-config/skills/workflow-apex-free/templates/02-plan.md +0 -10
- package/agents-config/skills/workflow-apex-free/templates/03-execute.md +0 -10
- package/agents-config/skills/workflow-apex-free/templates/04-validate.md +0 -10
- package/agents-config/skills/workflow-apex-free/templates/README.md +0 -176
- package/agents-config/skills/workflow-apex-free/templates/step-complete.md +0 -7
package/dist/cli.js
CHANGED
|
@@ -32263,8 +32263,8 @@ var inquirer = {
|
|
|
32263
32263
|
var lib_default = inquirer;
|
|
32264
32264
|
|
|
32265
32265
|
// src/commands/setup.ts
|
|
32266
|
-
var
|
|
32267
|
-
import
|
|
32266
|
+
var import_fs_extra9 = __toESM(require_lib4(), 1);
|
|
32267
|
+
import path13 from "path";
|
|
32268
32268
|
import os10 from "os";
|
|
32269
32269
|
|
|
32270
32270
|
// node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
@@ -33481,6 +33481,7 @@ var TUI_STATUS_LINE_BLOCK = `status_line = [
|
|
|
33481
33481
|
status_line_use_colors = true`;
|
|
33482
33482
|
var TUI_SECTION = `[tui]
|
|
33483
33483
|
${TUI_STATUS_LINE_BLOCK}`;
|
|
33484
|
+
var COMMAND_DENY_HOOK_MARKER = "command-deny-list.ts";
|
|
33484
33485
|
function hasTopLevelKey(content, key) {
|
|
33485
33486
|
let inSection = false;
|
|
33486
33487
|
for (const line of content.split(/\r?\n/)) {
|
|
@@ -33503,7 +33504,7 @@ function getTopLevelAssignments(defaultConfig) {
|
|
|
33503
33504
|
const trimmed = line.trim();
|
|
33504
33505
|
if (!trimmed || trimmed.startsWith("#"))
|
|
33505
33506
|
continue;
|
|
33506
|
-
if (
|
|
33507
|
+
if (trimmed.startsWith("["))
|
|
33507
33508
|
break;
|
|
33508
33509
|
if (/^[A-Za-z0-9_-]+\s*=/.test(trimmed)) {
|
|
33509
33510
|
assignments.push(line);
|
|
@@ -33553,6 +33554,45 @@ function appendBlock(content, block) {
|
|
|
33553
33554
|
${block}
|
|
33554
33555
|
`;
|
|
33555
33556
|
}
|
|
33557
|
+
function getDefaultHookBlocks(defaultConfig) {
|
|
33558
|
+
const lines = defaultConfig.split(/\r?\n/);
|
|
33559
|
+
const blocks = [];
|
|
33560
|
+
let current = null;
|
|
33561
|
+
for (const line of lines) {
|
|
33562
|
+
const trimmed = line.trim();
|
|
33563
|
+
const tableName = trimmed.startsWith("[[") && trimmed.endsWith("]]") ? trimmed.slice(2, -2) : trimmed.startsWith("[") && trimmed.endsWith("]") ? trimmed.slice(1, -1) : null;
|
|
33564
|
+
if (tableName) {
|
|
33565
|
+
const isHookTable = tableName.startsWith("hooks.");
|
|
33566
|
+
if (!isHookTable) {
|
|
33567
|
+
if (current) {
|
|
33568
|
+
blocks.push(current.join(`
|
|
33569
|
+
`).trimEnd());
|
|
33570
|
+
current = null;
|
|
33571
|
+
}
|
|
33572
|
+
continue;
|
|
33573
|
+
}
|
|
33574
|
+
current ??= [];
|
|
33575
|
+
}
|
|
33576
|
+
if (current) {
|
|
33577
|
+
current.push(line);
|
|
33578
|
+
}
|
|
33579
|
+
}
|
|
33580
|
+
if (current) {
|
|
33581
|
+
blocks.push(current.join(`
|
|
33582
|
+
`).trimEnd());
|
|
33583
|
+
}
|
|
33584
|
+
return blocks.filter(Boolean);
|
|
33585
|
+
}
|
|
33586
|
+
function mergeDefaultHooks(existingConfig, defaultConfig) {
|
|
33587
|
+
let merged = existingConfig;
|
|
33588
|
+
for (const hookBlock of getDefaultHookBlocks(defaultConfig)) {
|
|
33589
|
+
if (hookBlock.includes(COMMAND_DENY_HOOK_MARKER) && merged.includes(COMMAND_DENY_HOOK_MARKER)) {
|
|
33590
|
+
continue;
|
|
33591
|
+
}
|
|
33592
|
+
merged = appendBlock(merged, hookBlock);
|
|
33593
|
+
}
|
|
33594
|
+
return merged;
|
|
33595
|
+
}
|
|
33556
33596
|
function mergeCodexConfig(existingConfig, defaultConfig) {
|
|
33557
33597
|
let merged = existingConfig.trimEnd();
|
|
33558
33598
|
for (const assignment of getTopLevelAssignments(defaultConfig)) {
|
|
@@ -33561,6 +33601,7 @@ function mergeCodexConfig(existingConfig, defaultConfig) {
|
|
|
33561
33601
|
merged = appendBlock(merged, assignment);
|
|
33562
33602
|
}
|
|
33563
33603
|
}
|
|
33604
|
+
merged = mergeDefaultHooks(merged, defaultConfig).trimEnd();
|
|
33564
33605
|
if (sectionHasKey(merged, "tui", "status_line")) {
|
|
33565
33606
|
return `${merged}
|
|
33566
33607
|
`;
|
|
@@ -33893,16 +33934,218 @@ async function listConfigBackups(options = {}) {
|
|
|
33893
33934
|
return listSnapshots(paths.backupsDir, "backup");
|
|
33894
33935
|
}
|
|
33895
33936
|
|
|
33937
|
+
// src/lib/codex-agents-renderer.ts
|
|
33938
|
+
var import_fs_extra8 = __toESM(require_lib4(), 1);
|
|
33939
|
+
import path12 from "path";
|
|
33940
|
+
var GENERATED_MARKER = "# Generated by aiblueprint-cli from Markdown agents.";
|
|
33941
|
+
var IGNORED_ENTRY_NAMES = new Set([".DS_Store", "node_modules"]);
|
|
33942
|
+
function parseFrontmatterValue(rawValue) {
|
|
33943
|
+
const value = rawValue.trim();
|
|
33944
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
33945
|
+
return value.slice(1, -1);
|
|
33946
|
+
}
|
|
33947
|
+
return value;
|
|
33948
|
+
}
|
|
33949
|
+
function parseMarkdownAgent(sourcePath, content) {
|
|
33950
|
+
if (!content.startsWith(`---
|
|
33951
|
+
`))
|
|
33952
|
+
return null;
|
|
33953
|
+
const end = content.indexOf(`
|
|
33954
|
+
---`, 4);
|
|
33955
|
+
if (end === -1)
|
|
33956
|
+
return null;
|
|
33957
|
+
const frontmatterText = content.slice(4, end);
|
|
33958
|
+
const bodyStart = content.indexOf(`
|
|
33959
|
+
`, end + 4);
|
|
33960
|
+
const body = bodyStart === -1 ? "" : content.slice(bodyStart + 1).trim();
|
|
33961
|
+
const frontmatter = {};
|
|
33962
|
+
const lines = frontmatterText.split(`
|
|
33963
|
+
`);
|
|
33964
|
+
for (let index = 0;index < lines.length; index++) {
|
|
33965
|
+
const line = lines[index];
|
|
33966
|
+
const match = line.match(/^([A-Za-z0-9_-]+):\s*(.*)$/);
|
|
33967
|
+
if (!match)
|
|
33968
|
+
continue;
|
|
33969
|
+
const key = match[1];
|
|
33970
|
+
const rawValue = match[2];
|
|
33971
|
+
if (rawValue === ">-" || rawValue === ">") {
|
|
33972
|
+
const foldedLines = [];
|
|
33973
|
+
while (index + 1 < lines.length && /^\s+/.test(lines[index + 1])) {
|
|
33974
|
+
index++;
|
|
33975
|
+
foldedLines.push(lines[index].trim());
|
|
33976
|
+
}
|
|
33977
|
+
frontmatter[key] = foldedLines.join(" ");
|
|
33978
|
+
continue;
|
|
33979
|
+
}
|
|
33980
|
+
if (rawValue === "|-" || rawValue === "|") {
|
|
33981
|
+
const literalLines = [];
|
|
33982
|
+
while (index + 1 < lines.length && /^\s+/.test(lines[index + 1])) {
|
|
33983
|
+
index++;
|
|
33984
|
+
literalLines.push(lines[index].replace(/^\s{2}/, ""));
|
|
33985
|
+
}
|
|
33986
|
+
frontmatter[key] = literalLines.join(`
|
|
33987
|
+
`);
|
|
33988
|
+
continue;
|
|
33989
|
+
}
|
|
33990
|
+
frontmatter[key] = parseFrontmatterValue(rawValue);
|
|
33991
|
+
}
|
|
33992
|
+
return { sourcePath, frontmatter, body };
|
|
33993
|
+
}
|
|
33994
|
+
function normalizeCodexAgentName(value) {
|
|
33995
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").replace(/_+/g, "_");
|
|
33996
|
+
if (!normalized)
|
|
33997
|
+
return "agent";
|
|
33998
|
+
if (/^[0-9]/.test(normalized))
|
|
33999
|
+
return `agent_${normalized}`;
|
|
34000
|
+
return normalized;
|
|
34001
|
+
}
|
|
34002
|
+
function mapModel(model) {
|
|
34003
|
+
switch (model?.trim().toLowerCase()) {
|
|
34004
|
+
case "haiku":
|
|
34005
|
+
return "gpt-5.4-mini";
|
|
34006
|
+
case "sonnet":
|
|
34007
|
+
return "gpt-5.4";
|
|
34008
|
+
case "opus":
|
|
34009
|
+
return "gpt-5.5";
|
|
34010
|
+
case "inherit":
|
|
34011
|
+
case "":
|
|
34012
|
+
case undefined:
|
|
34013
|
+
return null;
|
|
34014
|
+
default:
|
|
34015
|
+
return model ?? null;
|
|
34016
|
+
}
|
|
34017
|
+
}
|
|
34018
|
+
function tomlString(value) {
|
|
34019
|
+
return JSON.stringify(value);
|
|
34020
|
+
}
|
|
34021
|
+
function tomlMultilineLiteral(value) {
|
|
34022
|
+
if (value.includes("'''")) {
|
|
34023
|
+
return tomlString(value);
|
|
34024
|
+
}
|
|
34025
|
+
return `'''
|
|
34026
|
+
${value}
|
|
34027
|
+
'''`;
|
|
34028
|
+
}
|
|
34029
|
+
function buildDeveloperInstructions(agent) {
|
|
34030
|
+
const toolHints = agent.frontmatter.tools?.trim();
|
|
34031
|
+
const color = agent.frontmatter.color?.trim();
|
|
34032
|
+
const notes = [];
|
|
34033
|
+
if (toolHints) {
|
|
34034
|
+
notes.push(`Original tool hints from the Markdown agent: ${toolHints}.`);
|
|
34035
|
+
}
|
|
34036
|
+
if (color) {
|
|
34037
|
+
notes.push(`Original display color metadata: ${color}.`);
|
|
34038
|
+
}
|
|
34039
|
+
const prefix = [
|
|
34040
|
+
`Source Markdown agent: ${path12.basename(agent.sourcePath)}.`,
|
|
34041
|
+
...notes
|
|
34042
|
+
].join(`
|
|
34043
|
+
`);
|
|
34044
|
+
return `${prefix}
|
|
34045
|
+
|
|
34046
|
+
${agent.body}`.trim();
|
|
34047
|
+
}
|
|
34048
|
+
function renderToml(agent) {
|
|
34049
|
+
const rawName = agent.frontmatter.name?.trim();
|
|
34050
|
+
const description = agent.frontmatter.description?.trim();
|
|
34051
|
+
if (!rawName || !description || !agent.body) {
|
|
34052
|
+
return null;
|
|
34053
|
+
}
|
|
34054
|
+
const name = normalizeCodexAgentName(rawName);
|
|
34055
|
+
const model = mapModel(agent.frontmatter.model);
|
|
34056
|
+
const lines = [
|
|
34057
|
+
GENERATED_MARKER,
|
|
34058
|
+
`# Source: ${agent.sourcePath}`,
|
|
34059
|
+
`name = ${tomlString(name)}`,
|
|
34060
|
+
`description = ${tomlString(description)}`
|
|
34061
|
+
];
|
|
34062
|
+
if (model) {
|
|
34063
|
+
lines.push(`model = ${tomlString(model)}`);
|
|
34064
|
+
}
|
|
34065
|
+
lines.push(`developer_instructions = ${tomlMultilineLiteral(buildDeveloperInstructions(agent))}`);
|
|
34066
|
+
lines.push("");
|
|
34067
|
+
return {
|
|
34068
|
+
name,
|
|
34069
|
+
content: lines.join(`
|
|
34070
|
+
`)
|
|
34071
|
+
};
|
|
34072
|
+
}
|
|
34073
|
+
async function canOverwriteTarget(targetPath, overwrite) {
|
|
34074
|
+
if (overwrite)
|
|
34075
|
+
return true;
|
|
34076
|
+
const existing = await import_fs_extra8.default.readFile(targetPath, "utf-8").catch(() => null);
|
|
34077
|
+
return existing?.startsWith(GENERATED_MARKER) ?? false;
|
|
34078
|
+
}
|
|
34079
|
+
async function ensureRealTargetDir(targetDir) {
|
|
34080
|
+
const stat = await import_fs_extra8.default.lstat(targetDir).catch(() => null);
|
|
34081
|
+
if (stat?.isSymbolicLink()) {
|
|
34082
|
+
await import_fs_extra8.default.remove(targetDir);
|
|
34083
|
+
}
|
|
34084
|
+
await import_fs_extra8.default.ensureDir(targetDir);
|
|
34085
|
+
}
|
|
34086
|
+
async function renderCodexAgentsFromMarkdown(options = {}) {
|
|
34087
|
+
const folders = resolveFolders(options);
|
|
34088
|
+
const sourceDir = path12.join(folders.agentsDir, "agents");
|
|
34089
|
+
const targetDir = path12.join(folders.codexDir, "agents");
|
|
34090
|
+
const result = {
|
|
34091
|
+
sourceDir,
|
|
34092
|
+
targetDir,
|
|
34093
|
+
rendered: [],
|
|
34094
|
+
skipped: []
|
|
34095
|
+
};
|
|
34096
|
+
if (!await import_fs_extra8.default.pathExists(sourceDir)) {
|
|
34097
|
+
return result;
|
|
34098
|
+
}
|
|
34099
|
+
await import_fs_extra8.default.ensureDir(folders.codexDir);
|
|
34100
|
+
await ensureRealTargetDir(targetDir);
|
|
34101
|
+
const entries = await import_fs_extra8.default.readdir(sourceDir, { withFileTypes: true });
|
|
34102
|
+
for (const entry of entries) {
|
|
34103
|
+
if (IGNORED_ENTRY_NAMES.has(entry.name))
|
|
34104
|
+
continue;
|
|
34105
|
+
if (!entry.isFile() || path12.extname(entry.name) !== ".md")
|
|
34106
|
+
continue;
|
|
34107
|
+
const sourcePath = path12.join(sourceDir, entry.name);
|
|
34108
|
+
const parsed = parseMarkdownAgent(sourcePath, await import_fs_extra8.default.readFile(sourcePath, "utf-8"));
|
|
34109
|
+
if (!parsed) {
|
|
34110
|
+
result.skipped.push({ source: sourcePath, reason: "Missing YAML frontmatter" });
|
|
34111
|
+
continue;
|
|
34112
|
+
}
|
|
34113
|
+
const rendered = renderToml(parsed);
|
|
34114
|
+
if (!rendered) {
|
|
34115
|
+
result.skipped.push({
|
|
34116
|
+
source: sourcePath,
|
|
34117
|
+
reason: "Missing name, description, or instruction body"
|
|
34118
|
+
});
|
|
34119
|
+
continue;
|
|
34120
|
+
}
|
|
34121
|
+
const targetPath = path12.join(targetDir, `${rendered.name}.toml`);
|
|
34122
|
+
if (await import_fs_extra8.default.pathExists(targetPath) && !await canOverwriteTarget(targetPath, Boolean(options.overwrite))) {
|
|
34123
|
+
result.skipped.push({
|
|
34124
|
+
source: sourcePath,
|
|
34125
|
+
reason: `Codex agent already exists at ${targetPath}`
|
|
34126
|
+
});
|
|
34127
|
+
continue;
|
|
34128
|
+
}
|
|
34129
|
+
await import_fs_extra8.default.writeFile(targetPath, rendered.content, "utf-8");
|
|
34130
|
+
result.rendered.push({
|
|
34131
|
+
source: sourcePath,
|
|
34132
|
+
target: targetPath,
|
|
34133
|
+
name: rendered.name
|
|
34134
|
+
});
|
|
34135
|
+
}
|
|
34136
|
+
return result;
|
|
34137
|
+
}
|
|
34138
|
+
|
|
33896
34139
|
// src/commands/setup.ts
|
|
33897
34140
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
33898
34141
|
var __dirname2 = dirname2(__filename2);
|
|
33899
34142
|
async function resolveClaudeAssetPath(sourceDir, name) {
|
|
33900
34143
|
const candidates = [
|
|
33901
|
-
|
|
33902
|
-
|
|
34144
|
+
path13.join(sourceDir, "claude-config", name),
|
|
34145
|
+
path13.join(sourceDir, name)
|
|
33903
34146
|
];
|
|
33904
34147
|
for (const candidate of candidates) {
|
|
33905
|
-
if (await
|
|
34148
|
+
if (await import_fs_extra9.default.pathExists(candidate))
|
|
33906
34149
|
return candidate;
|
|
33907
34150
|
}
|
|
33908
34151
|
return null;
|
|
@@ -33990,8 +34233,8 @@ async function setupCommand(params = {}) {
|
|
|
33990
34233
|
console.log(source_default.gray(`Claude: ${claudeDir}`));
|
|
33991
34234
|
console.log(source_default.gray(`Codex: ${codexDir}`));
|
|
33992
34235
|
console.log(source_default.gray(`Agents: ${agentsDir}`));
|
|
33993
|
-
await
|
|
33994
|
-
await
|
|
34236
|
+
await import_fs_extra9.default.ensureDir(claudeDir);
|
|
34237
|
+
await import_fs_extra9.default.ensureDir(agentsDir);
|
|
33995
34238
|
s.start("Creating backup of existing configuration");
|
|
33996
34239
|
const backupPath = await createConfigBackup({ folder, claudeCodeFolder, codexFolder, agentsFolder }, "Before running aiblueprint setup", "setup", "aiblueprint-setup");
|
|
33997
34240
|
if (backupPath) {
|
|
@@ -34019,11 +34262,11 @@ async function setupCommand(params = {}) {
|
|
|
34019
34262
|
s.start("Setting up scripts");
|
|
34020
34263
|
const scriptsSource = await resolveClaudeAssetPath(sourceDir, "scripts");
|
|
34021
34264
|
if (scriptsSource) {
|
|
34022
|
-
await
|
|
34265
|
+
await import_fs_extra9.default.copy(scriptsSource, path13.join(claudeDir, "scripts"), {
|
|
34023
34266
|
overwrite: true
|
|
34024
34267
|
});
|
|
34025
|
-
await replacePathPlaceholdersInDir(
|
|
34026
|
-
await
|
|
34268
|
+
await replacePathPlaceholdersInDir(path13.join(claudeDir, "scripts"), claudeDir);
|
|
34269
|
+
await import_fs_extra9.default.ensureDir(path13.join(claudeDir, "scripts/statusline/data"));
|
|
34027
34270
|
s.stop("Scripts installed");
|
|
34028
34271
|
} else {
|
|
34029
34272
|
s.stop("Scripts not available in repository");
|
|
@@ -34031,8 +34274,8 @@ async function setupCommand(params = {}) {
|
|
|
34031
34274
|
}
|
|
34032
34275
|
if (options.aiblueprintAgents) {
|
|
34033
34276
|
s.start("Setting up AIBlueprint agents");
|
|
34034
|
-
const agentsSource =
|
|
34035
|
-
if (await
|
|
34277
|
+
const agentsSource = path13.join(sourceDir, "agents");
|
|
34278
|
+
if (await import_fs_extra9.default.pathExists(agentsSource)) {
|
|
34036
34279
|
const installResult = await installCategoryToAgents(agentsSource, "agents", agentsDir, claudeDir, { migrateClaudeDirs: true, silent: true });
|
|
34037
34280
|
const summary = [
|
|
34038
34281
|
installResult.copied.length && `${installResult.copied.length} copied`,
|
|
@@ -34047,8 +34290,8 @@ async function setupCommand(params = {}) {
|
|
|
34047
34290
|
}
|
|
34048
34291
|
if (options.aiblueprintSkills) {
|
|
34049
34292
|
s.start("Setting up AIBlueprint Skills");
|
|
34050
|
-
const skillsSourcePath =
|
|
34051
|
-
if (await
|
|
34293
|
+
const skillsSourcePath = path13.join(sourceDir, "skills");
|
|
34294
|
+
if (await import_fs_extra9.default.pathExists(skillsSourcePath)) {
|
|
34052
34295
|
const installResult = await installCategoryToAgents(skillsSourcePath, "skills", agentsDir, claudeDir, { migrateClaudeDirs: true, silent: true });
|
|
34053
34296
|
const summary = [
|
|
34054
34297
|
installResult.copied.length && `${installResult.copied.length} copied`,
|
|
@@ -34068,18 +34311,18 @@ async function setupCommand(params = {}) {
|
|
|
34068
34311
|
}
|
|
34069
34312
|
if (options.installCodex) {
|
|
34070
34313
|
s.start("Setting up Codex");
|
|
34071
|
-
await
|
|
34072
|
-
const codexConfigSource =
|
|
34073
|
-
if (await
|
|
34074
|
-
const codexConfigPath =
|
|
34075
|
-
if (await
|
|
34314
|
+
await import_fs_extra9.default.ensureDir(codexDir);
|
|
34315
|
+
const codexConfigSource = path13.join(sourceDir, "codex-config");
|
|
34316
|
+
if (await import_fs_extra9.default.pathExists(codexConfigSource)) {
|
|
34317
|
+
const codexConfigPath = path13.join(codexConfigSource, "config.toml");
|
|
34318
|
+
if (await import_fs_extra9.default.pathExists(codexConfigPath)) {
|
|
34076
34319
|
await mergeCodexConfigFile(codexConfigPath, codexDir);
|
|
34077
34320
|
}
|
|
34078
|
-
const entries = await
|
|
34321
|
+
const entries = await import_fs_extra9.default.readdir(codexConfigSource);
|
|
34079
34322
|
for (const entry of entries) {
|
|
34080
34323
|
if (entry === "config.toml")
|
|
34081
34324
|
continue;
|
|
34082
|
-
await
|
|
34325
|
+
await import_fs_extra9.default.copy(path13.join(codexConfigSource, entry), path13.join(codexDir, entry), {
|
|
34083
34326
|
overwrite: false
|
|
34084
34327
|
});
|
|
34085
34328
|
}
|
|
@@ -34088,7 +34331,12 @@ async function setupCommand(params = {}) {
|
|
|
34088
34331
|
await syncCategorySymlinks("skills", agentsDir, codexDir, undefined, true);
|
|
34089
34332
|
}
|
|
34090
34333
|
if (options.aiblueprintAgents) {
|
|
34091
|
-
await
|
|
34334
|
+
await renderCodexAgentsFromMarkdown({
|
|
34335
|
+
folder,
|
|
34336
|
+
claudeCodeFolder,
|
|
34337
|
+
codexFolder,
|
|
34338
|
+
agentsFolder
|
|
34339
|
+
});
|
|
34092
34340
|
}
|
|
34093
34341
|
s.stop("Codex configured");
|
|
34094
34342
|
}
|
|
@@ -34154,8 +34402,8 @@ Next steps:`));
|
|
|
34154
34402
|
}
|
|
34155
34403
|
|
|
34156
34404
|
// src/commands/setup-terminal.ts
|
|
34157
|
-
var
|
|
34158
|
-
import
|
|
34405
|
+
var import_fs_extra10 = __toESM(require_lib4(), 1);
|
|
34406
|
+
import path14 from "path";
|
|
34159
34407
|
import os11 from "os";
|
|
34160
34408
|
import { execSync as execSync3, exec as exec2 } from "child_process";
|
|
34161
34409
|
var OHMYZSH_INSTALL_URL = "https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh";
|
|
@@ -34190,16 +34438,16 @@ function commandExists(cmd) {
|
|
|
34190
34438
|
}
|
|
34191
34439
|
}
|
|
34192
34440
|
function isOhMyZshInstalled(homeDir) {
|
|
34193
|
-
const ohMyZshDir =
|
|
34194
|
-
return
|
|
34441
|
+
const ohMyZshDir = path14.join(homeDir, ".oh-my-zsh");
|
|
34442
|
+
return import_fs_extra10.default.existsSync(ohMyZshDir);
|
|
34195
34443
|
}
|
|
34196
34444
|
function backupFile(filePath) {
|
|
34197
|
-
if (!
|
|
34445
|
+
if (!import_fs_extra10.default.existsSync(filePath))
|
|
34198
34446
|
return null;
|
|
34199
34447
|
const timestamp2 = new Date().toISOString().replace(/[:.]/g, "-");
|
|
34200
34448
|
const backupPath = `${filePath}.backup-${timestamp2}`;
|
|
34201
34449
|
try {
|
|
34202
|
-
|
|
34450
|
+
import_fs_extra10.default.copyFileSync(filePath, backupPath);
|
|
34203
34451
|
return backupPath;
|
|
34204
34452
|
} catch (error) {
|
|
34205
34453
|
throw new Error(`Failed to create backup: ${error.message}`);
|
|
@@ -34238,7 +34486,7 @@ function installPrerequisiteSync(packageName, installCmd) {
|
|
|
34238
34486
|
async function installOhMyZsh(homeDir) {
|
|
34239
34487
|
return new Promise((resolve, reject) => {
|
|
34240
34488
|
const installCmd = `sh -c "$(curl -fsSL ${OHMYZSH_INSTALL_URL})" "" --unattended`;
|
|
34241
|
-
const env2 = { ...process.env, HOME: homeDir, ZSH:
|
|
34489
|
+
const env2 = { ...process.env, HOME: homeDir, ZSH: path14.join(homeDir, ".oh-my-zsh") };
|
|
34242
34490
|
exec2(installCmd, { timeout: INSTALL_TIMEOUT, env: env2 }, (error, stdout, stderr) => {
|
|
34243
34491
|
if (error) {
|
|
34244
34492
|
if ("killed" in error && error.killed) {
|
|
@@ -34259,8 +34507,8 @@ async function installPlugin(pluginName, repoUrl, homeDir) {
|
|
|
34259
34507
|
if (!/^https:\/\/github\.com\/[\w-]+\/[\w-]+$/.test(repoUrl)) {
|
|
34260
34508
|
throw new Error(`Invalid repository URL: ${repoUrl}`);
|
|
34261
34509
|
}
|
|
34262
|
-
const customPluginsDir =
|
|
34263
|
-
if (
|
|
34510
|
+
const customPluginsDir = path14.join(homeDir, ".oh-my-zsh/custom/plugins", pluginName);
|
|
34511
|
+
if (import_fs_extra10.default.existsSync(customPluginsDir)) {
|
|
34264
34512
|
return;
|
|
34265
34513
|
}
|
|
34266
34514
|
return new Promise((resolve, reject) => {
|
|
@@ -34278,20 +34526,20 @@ async function installPlugin(pluginName, repoUrl, homeDir) {
|
|
|
34278
34526
|
});
|
|
34279
34527
|
}
|
|
34280
34528
|
function updateZshrcTheme(theme, homeDir) {
|
|
34281
|
-
const zshrcPath =
|
|
34529
|
+
const zshrcPath = path14.join(homeDir, ".zshrc");
|
|
34282
34530
|
const sanitizedTheme = sanitizeThemeName(theme);
|
|
34283
|
-
if (!
|
|
34531
|
+
if (!import_fs_extra10.default.existsSync(zshrcPath)) {
|
|
34284
34532
|
throw new Error(".zshrc file not found. Please ensure Oh My ZSH is installed correctly.");
|
|
34285
34533
|
}
|
|
34286
34534
|
try {
|
|
34287
|
-
let content =
|
|
34535
|
+
let content = import_fs_extra10.default.readFileSync(zshrcPath, "utf-8");
|
|
34288
34536
|
if (content.match(/^ZSH_THEME=/m)) {
|
|
34289
34537
|
content = content.replace(/^ZSH_THEME=.*/m, `ZSH_THEME="${sanitizedTheme}"`);
|
|
34290
34538
|
} else {
|
|
34291
34539
|
content = `ZSH_THEME="${sanitizedTheme}"
|
|
34292
34540
|
${content}`;
|
|
34293
34541
|
}
|
|
34294
|
-
|
|
34542
|
+
import_fs_extra10.default.writeFileSync(zshrcPath, content);
|
|
34295
34543
|
} catch (error) {
|
|
34296
34544
|
if (error.message.includes(".zshrc file not found")) {
|
|
34297
34545
|
throw error;
|
|
@@ -34300,12 +34548,12 @@ ${content}`;
|
|
|
34300
34548
|
}
|
|
34301
34549
|
}
|
|
34302
34550
|
function updateZshrcPlugins(plugins, homeDir) {
|
|
34303
|
-
const zshrcPath =
|
|
34304
|
-
if (!
|
|
34551
|
+
const zshrcPath = path14.join(homeDir, ".zshrc");
|
|
34552
|
+
if (!import_fs_extra10.default.existsSync(zshrcPath)) {
|
|
34305
34553
|
throw new Error(".zshrc file not found. Please ensure Oh My ZSH is installed correctly.");
|
|
34306
34554
|
}
|
|
34307
34555
|
try {
|
|
34308
|
-
let content =
|
|
34556
|
+
let content = import_fs_extra10.default.readFileSync(zshrcPath, "utf-8");
|
|
34309
34557
|
const pluginsString = plugins.join(" ");
|
|
34310
34558
|
if (content.match(/^plugins=\(/m)) {
|
|
34311
34559
|
content = content.replace(/^plugins=\([^)]*\)/m, `plugins=(${pluginsString})`);
|
|
@@ -34313,7 +34561,7 @@ function updateZshrcPlugins(plugins, homeDir) {
|
|
|
34313
34561
|
content = `${content}
|
|
34314
34562
|
plugins=(${pluginsString})`;
|
|
34315
34563
|
}
|
|
34316
|
-
|
|
34564
|
+
import_fs_extra10.default.writeFileSync(zshrcPath, content);
|
|
34317
34565
|
} catch (error) {
|
|
34318
34566
|
if (error.message.includes(".zshrc file not found")) {
|
|
34319
34567
|
throw error;
|
|
@@ -34420,8 +34668,8 @@ Installing missing prerequisites: ${missingPrereqs.join(", ")}`));
|
|
|
34420
34668
|
selectedTheme = themeAnswer.theme;
|
|
34421
34669
|
}
|
|
34422
34670
|
}
|
|
34423
|
-
const zshrcPath =
|
|
34424
|
-
if (
|
|
34671
|
+
const zshrcPath = path14.join(homeDir, ".zshrc");
|
|
34672
|
+
if (import_fs_extra10.default.existsSync(zshrcPath)) {
|
|
34425
34673
|
s.start("Backing up .zshrc");
|
|
34426
34674
|
const backupPath = backupFile(zshrcPath);
|
|
34427
34675
|
if (backupPath) {
|
|
@@ -34471,37 +34719,37 @@ Next steps:`));
|
|
|
34471
34719
|
}
|
|
34472
34720
|
|
|
34473
34721
|
// src/commands/setup/symlinks.ts
|
|
34474
|
-
var
|
|
34475
|
-
import
|
|
34722
|
+
var import_fs_extra11 = __toESM(require_lib4(), 1);
|
|
34723
|
+
import path15 from "path";
|
|
34476
34724
|
import os12 from "os";
|
|
34477
34725
|
async function getToolPaths(tool, customFolder) {
|
|
34478
34726
|
let baseDir;
|
|
34479
34727
|
switch (tool) {
|
|
34480
34728
|
case "claude-code":
|
|
34481
|
-
baseDir = customFolder ?
|
|
34729
|
+
baseDir = customFolder ? path15.resolve(customFolder) : path15.join(os12.homedir(), ".claude");
|
|
34482
34730
|
return {
|
|
34483
34731
|
baseDir,
|
|
34484
|
-
commandsPath:
|
|
34485
|
-
agentsPath:
|
|
34732
|
+
commandsPath: path15.join(baseDir, "commands"),
|
|
34733
|
+
agentsPath: path15.join(baseDir, "agents")
|
|
34486
34734
|
};
|
|
34487
34735
|
case "codex":
|
|
34488
|
-
baseDir = customFolder ?
|
|
34736
|
+
baseDir = customFolder ? path15.resolve(customFolder) : path15.join(os12.homedir(), ".codex");
|
|
34489
34737
|
return {
|
|
34490
34738
|
baseDir,
|
|
34491
|
-
agentsPath:
|
|
34739
|
+
agentsPath: path15.join(baseDir, "agents")
|
|
34492
34740
|
};
|
|
34493
34741
|
case "opencode":
|
|
34494
|
-
baseDir = customFolder ?
|
|
34742
|
+
baseDir = customFolder ? path15.resolve(customFolder) : path15.join(os12.homedir(), ".config", "opencode");
|
|
34495
34743
|
return {
|
|
34496
34744
|
baseDir,
|
|
34497
|
-
commandsPath:
|
|
34745
|
+
commandsPath: path15.join(baseDir, "command")
|
|
34498
34746
|
};
|
|
34499
34747
|
case "factoryai":
|
|
34500
|
-
baseDir = customFolder ?
|
|
34748
|
+
baseDir = customFolder ? path15.resolve(customFolder) : path15.join(os12.homedir(), ".factory");
|
|
34501
34749
|
return {
|
|
34502
34750
|
baseDir,
|
|
34503
|
-
commandsPath:
|
|
34504
|
-
agentsPath:
|
|
34751
|
+
commandsPath: path15.join(baseDir, "commands"),
|
|
34752
|
+
agentsPath: path15.join(baseDir, "droids")
|
|
34505
34753
|
};
|
|
34506
34754
|
default:
|
|
34507
34755
|
throw new Error(`Unknown tool type: ${tool}`);
|
|
@@ -34509,18 +34757,18 @@ async function getToolPaths(tool, customFolder) {
|
|
|
34509
34757
|
}
|
|
34510
34758
|
async function createSymlink(sourcePath, targetPath, options = {}) {
|
|
34511
34759
|
try {
|
|
34512
|
-
const sourceExists = await
|
|
34760
|
+
const sourceExists = await import_fs_extra11.default.pathExists(sourcePath);
|
|
34513
34761
|
if (!sourceExists) {
|
|
34514
34762
|
console.log(source_default.yellow(` Source path ${sourcePath} does not exist. Skipping symlink creation...`));
|
|
34515
34763
|
return false;
|
|
34516
34764
|
}
|
|
34517
|
-
const targetDir =
|
|
34518
|
-
await
|
|
34519
|
-
const targetExists = await
|
|
34765
|
+
const targetDir = path15.dirname(targetPath);
|
|
34766
|
+
await import_fs_extra11.default.ensureDir(targetDir);
|
|
34767
|
+
const targetExists = await import_fs_extra11.default.pathExists(targetPath);
|
|
34520
34768
|
if (targetExists) {
|
|
34521
|
-
const stat = await
|
|
34769
|
+
const stat = await import_fs_extra11.default.lstat(targetPath);
|
|
34522
34770
|
if (stat.isSymbolicLink()) {
|
|
34523
|
-
await
|
|
34771
|
+
await import_fs_extra11.default.remove(targetPath);
|
|
34524
34772
|
} else {
|
|
34525
34773
|
console.log(source_default.yellow(options.skipMessage || ` ${targetPath} already exists and is not a symlink. Skipping...`));
|
|
34526
34774
|
return false;
|
|
@@ -34528,9 +34776,9 @@ async function createSymlink(sourcePath, targetPath, options = {}) {
|
|
|
34528
34776
|
}
|
|
34529
34777
|
const isWindows2 = os12.platform() === "win32";
|
|
34530
34778
|
if (isWindows2) {
|
|
34531
|
-
await
|
|
34779
|
+
await import_fs_extra11.default.symlink(sourcePath, targetPath, "junction");
|
|
34532
34780
|
} else {
|
|
34533
|
-
await
|
|
34781
|
+
await import_fs_extra11.default.symlink(sourcePath, targetPath);
|
|
34534
34782
|
}
|
|
34535
34783
|
return true;
|
|
34536
34784
|
} catch (error) {
|
|
@@ -34711,11 +34959,11 @@ async function symlinkCommand(params = {}) {
|
|
|
34711
34959
|
}
|
|
34712
34960
|
|
|
34713
34961
|
// src/lib/agents-unifier.ts
|
|
34714
|
-
var
|
|
34962
|
+
var import_fs_extra12 = __toESM(require_lib4(), 1);
|
|
34715
34963
|
import crypto from "crypto";
|
|
34716
34964
|
import os13 from "os";
|
|
34717
|
-
import
|
|
34718
|
-
var
|
|
34965
|
+
import path16 from "path";
|
|
34966
|
+
var IGNORED_ENTRY_NAMES2 = new Set([
|
|
34719
34967
|
".DS_Store",
|
|
34720
34968
|
".git",
|
|
34721
34969
|
"node_modules"
|
|
@@ -34724,7 +34972,7 @@ function uniqueByPath(candidates) {
|
|
|
34724
34972
|
const seen = new Set;
|
|
34725
34973
|
const unique = [];
|
|
34726
34974
|
for (const candidate of candidates) {
|
|
34727
|
-
const resolved =
|
|
34975
|
+
const resolved = path16.resolve(candidate.path);
|
|
34728
34976
|
if (seen.has(resolved))
|
|
34729
34977
|
continue;
|
|
34730
34978
|
seen.add(resolved);
|
|
@@ -34734,109 +34982,103 @@ function uniqueByPath(candidates) {
|
|
|
34734
34982
|
}
|
|
34735
34983
|
function getContainerCandidates(options) {
|
|
34736
34984
|
const folders = resolveFolders(options);
|
|
34737
|
-
const cursorDir =
|
|
34738
|
-
const factoryDir =
|
|
34739
|
-
const opencodeDir =
|
|
34985
|
+
const cursorDir = path16.join(folders.rootDir, ".cursor");
|
|
34986
|
+
const factoryDir = path16.join(folders.rootDir, ".factory");
|
|
34987
|
+
const opencodeDir = path16.join(folders.rootDir, ".config", "opencode");
|
|
34740
34988
|
return uniqueByPath([
|
|
34741
34989
|
{
|
|
34742
34990
|
category: "skills",
|
|
34743
34991
|
label: "agents-skills",
|
|
34744
|
-
path:
|
|
34992
|
+
path: path16.join(folders.agentsDir, "skills"),
|
|
34745
34993
|
isDestination: true
|
|
34746
34994
|
},
|
|
34747
34995
|
{
|
|
34748
34996
|
category: "skills",
|
|
34749
34997
|
label: "claude-skills",
|
|
34750
|
-
path:
|
|
34998
|
+
path: path16.join(folders.claudeDir, "skills"),
|
|
34751
34999
|
linkWhenMissing: true
|
|
34752
35000
|
},
|
|
34753
35001
|
{
|
|
34754
35002
|
category: "skills",
|
|
34755
35003
|
label: "codex-skills",
|
|
34756
|
-
path:
|
|
35004
|
+
path: path16.join(folders.codexDir, "skills"),
|
|
34757
35005
|
linkWhenMissing: true
|
|
34758
35006
|
},
|
|
34759
35007
|
{
|
|
34760
35008
|
category: "skills",
|
|
34761
35009
|
label: "cursor-skills",
|
|
34762
|
-
path:
|
|
35010
|
+
path: path16.join(cursorDir, "skills"),
|
|
34763
35011
|
linkWhenParentExists: true
|
|
34764
35012
|
},
|
|
34765
35013
|
{
|
|
34766
35014
|
category: "skills",
|
|
34767
35015
|
label: "cursor-skills-cursor",
|
|
34768
|
-
path:
|
|
35016
|
+
path: path16.join(cursorDir, "skills-cursor"),
|
|
34769
35017
|
linkWhenParentExists: true
|
|
34770
35018
|
},
|
|
34771
35019
|
{
|
|
34772
35020
|
category: "skills",
|
|
34773
35021
|
label: "factory-skills",
|
|
34774
|
-
path:
|
|
35022
|
+
path: path16.join(factoryDir, "skills"),
|
|
34775
35023
|
linkWhenParentExists: true
|
|
34776
35024
|
},
|
|
34777
35025
|
{
|
|
34778
35026
|
category: "skills",
|
|
34779
35027
|
label: "opencode-skill",
|
|
34780
|
-
path:
|
|
35028
|
+
path: path16.join(opencodeDir, "skill"),
|
|
34781
35029
|
linkWhenParentExists: true
|
|
34782
35030
|
},
|
|
34783
35031
|
{
|
|
34784
35032
|
category: "skills",
|
|
34785
35033
|
label: "opencode-skills",
|
|
34786
|
-
path:
|
|
35034
|
+
path: path16.join(opencodeDir, "skills"),
|
|
34787
35035
|
linkWhenParentExists: true
|
|
34788
35036
|
},
|
|
34789
35037
|
{
|
|
34790
35038
|
category: "agents",
|
|
34791
35039
|
label: "agents-agents",
|
|
34792
|
-
path:
|
|
35040
|
+
path: path16.join(folders.agentsDir, "agents"),
|
|
34793
35041
|
isDestination: true
|
|
34794
35042
|
},
|
|
34795
35043
|
{
|
|
34796
35044
|
category: "agents",
|
|
34797
35045
|
label: "claude-agents",
|
|
34798
|
-
path:
|
|
35046
|
+
path: path16.join(folders.claudeDir, "agents"),
|
|
34799
35047
|
linkWhenMissing: true
|
|
34800
35048
|
},
|
|
34801
35049
|
{
|
|
34802
35050
|
category: "agents",
|
|
34803
35051
|
label: "claude-agnets",
|
|
34804
|
-
path:
|
|
34805
|
-
},
|
|
34806
|
-
{
|
|
34807
|
-
category: "agents",
|
|
34808
|
-
label: "codex-agents",
|
|
34809
|
-
path: path15.join(folders.codexDir, "agents"),
|
|
34810
|
-
linkWhenMissing: true
|
|
35052
|
+
path: path16.join(folders.claudeDir, "agnets")
|
|
34811
35053
|
},
|
|
34812
35054
|
{
|
|
34813
35055
|
category: "agents",
|
|
34814
35056
|
label: "cursor-agents",
|
|
34815
|
-
path:
|
|
35057
|
+
path: path16.join(cursorDir, "agents"),
|
|
34816
35058
|
linkWhenParentExists: true
|
|
34817
35059
|
},
|
|
34818
35060
|
{
|
|
34819
35061
|
category: "agents",
|
|
34820
35062
|
label: "factory-droids",
|
|
34821
|
-
path:
|
|
35063
|
+
path: path16.join(factoryDir, "droids"),
|
|
34822
35064
|
linkWhenParentExists: true
|
|
34823
35065
|
},
|
|
34824
35066
|
{
|
|
34825
35067
|
category: "agents",
|
|
34826
35068
|
label: "opencode-agent",
|
|
34827
|
-
path:
|
|
35069
|
+
path: path16.join(opencodeDir, "agent"),
|
|
34828
35070
|
linkWhenParentExists: true
|
|
34829
35071
|
},
|
|
34830
35072
|
{
|
|
34831
35073
|
category: "agents",
|
|
34832
35074
|
label: "opencode-agents",
|
|
34833
|
-
path:
|
|
35075
|
+
path: path16.join(opencodeDir, "agents"),
|
|
34834
35076
|
linkWhenParentExists: true
|
|
34835
35077
|
}
|
|
34836
35078
|
]);
|
|
34837
35079
|
}
|
|
34838
35080
|
function shouldCollectEntry(category, entry) {
|
|
34839
|
-
if (
|
|
35081
|
+
if (IGNORED_ENTRY_NAMES2.has(entry.name))
|
|
34840
35082
|
return false;
|
|
34841
35083
|
if (category === "skills" && entry.name === ".cursor-managed-skills-manifest.json") {
|
|
34842
35084
|
return true;
|
|
@@ -34844,42 +35086,42 @@ function shouldCollectEntry(category, entry) {
|
|
|
34844
35086
|
return entry.isFile() || entry.isDirectory() || entry.isSymbolicLink();
|
|
34845
35087
|
}
|
|
34846
35088
|
async function pathExistsOrSymlink(targetPath) {
|
|
34847
|
-
const stat = await
|
|
35089
|
+
const stat = await import_fs_extra12.default.lstat(targetPath).catch(() => null);
|
|
34848
35090
|
return Boolean(stat);
|
|
34849
35091
|
}
|
|
34850
35092
|
async function realPathIfPossible(targetPath) {
|
|
34851
35093
|
try {
|
|
34852
|
-
return await
|
|
35094
|
+
return await import_fs_extra12.default.realpath(targetPath);
|
|
34853
35095
|
} catch {
|
|
34854
35096
|
return null;
|
|
34855
35097
|
}
|
|
34856
35098
|
}
|
|
34857
35099
|
function samePath(a, b) {
|
|
34858
|
-
return
|
|
35100
|
+
return path16.resolve(a) === path16.resolve(b);
|
|
34859
35101
|
}
|
|
34860
35102
|
function hashString(value) {
|
|
34861
35103
|
return crypto.createHash("sha256").update(value).digest("hex");
|
|
34862
35104
|
}
|
|
34863
35105
|
async function hashPath(targetPath) {
|
|
34864
|
-
const stat = await
|
|
35106
|
+
const stat = await import_fs_extra12.default.lstat(targetPath);
|
|
34865
35107
|
if (stat.isSymbolicLink()) {
|
|
34866
|
-
const linkTarget = await
|
|
35108
|
+
const linkTarget = await import_fs_extra12.default.readlink(targetPath);
|
|
34867
35109
|
return hashString(`symlink:${linkTarget}`);
|
|
34868
35110
|
}
|
|
34869
35111
|
if (stat.isFile()) {
|
|
34870
35112
|
const fileHash = crypto.createHash("sha256");
|
|
34871
35113
|
fileHash.update("file:");
|
|
34872
|
-
fileHash.update(await
|
|
35114
|
+
fileHash.update(await import_fs_extra12.default.readFile(targetPath));
|
|
34873
35115
|
return fileHash.digest("hex");
|
|
34874
35116
|
}
|
|
34875
35117
|
if (stat.isDirectory()) {
|
|
34876
|
-
const entries = (await
|
|
35118
|
+
const entries = (await import_fs_extra12.default.readdir(targetPath, { withFileTypes: true })).filter((entry) => !IGNORED_ENTRY_NAMES2.has(entry.name)).sort((a, b) => a.name.localeCompare(b.name));
|
|
34877
35119
|
const dirHash = crypto.createHash("sha256");
|
|
34878
35120
|
dirHash.update("dir:");
|
|
34879
35121
|
for (const entry of entries) {
|
|
34880
35122
|
dirHash.update(entry.name);
|
|
34881
35123
|
dirHash.update("\x00");
|
|
34882
|
-
dirHash.update(await hashPath(
|
|
35124
|
+
dirHash.update(await hashPath(path16.join(targetPath, entry.name)));
|
|
34883
35125
|
dirHash.update("\x00");
|
|
34884
35126
|
}
|
|
34885
35127
|
return dirHash.digest("hex");
|
|
@@ -34890,7 +35132,7 @@ function suffixFromLabel(label) {
|
|
|
34890
35132
|
return label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "source";
|
|
34891
35133
|
}
|
|
34892
35134
|
function nameWithSuffix(name, suffix, index) {
|
|
34893
|
-
const parsed =
|
|
35135
|
+
const parsed = path16.parse(name);
|
|
34894
35136
|
const numberedSuffix = index === 1 ? suffix : `${suffix}-${index}`;
|
|
34895
35137
|
if (parsed.ext && parsed.name) {
|
|
34896
35138
|
return `${parsed.name}--${numberedSuffix}${parsed.ext}`;
|
|
@@ -34902,39 +35144,39 @@ async function findTargetName(destinationDir, originalName, label) {
|
|
|
34902
35144
|
let index = 1;
|
|
34903
35145
|
while (true) {
|
|
34904
35146
|
const candidate = nameWithSuffix(originalName, suffix, index);
|
|
34905
|
-
if (!await pathExistsOrSymlink(
|
|
35147
|
+
if (!await pathExistsOrSymlink(path16.join(destinationDir, candidate))) {
|
|
34906
35148
|
return candidate;
|
|
34907
35149
|
}
|
|
34908
35150
|
index++;
|
|
34909
35151
|
}
|
|
34910
35152
|
}
|
|
34911
35153
|
async function addExistingDestinationHashes(destinationDir, knownHashes) {
|
|
34912
|
-
if (!await
|
|
35154
|
+
if (!await import_fs_extra12.default.pathExists(destinationDir))
|
|
34913
35155
|
return;
|
|
34914
|
-
const entries = await
|
|
35156
|
+
const entries = await import_fs_extra12.default.readdir(destinationDir, { withFileTypes: true });
|
|
34915
35157
|
for (const entry of entries) {
|
|
34916
|
-
if (
|
|
35158
|
+
if (IGNORED_ENTRY_NAMES2.has(entry.name))
|
|
34917
35159
|
continue;
|
|
34918
|
-
const entryPath =
|
|
35160
|
+
const entryPath = path16.join(destinationDir, entry.name);
|
|
34919
35161
|
knownHashes.set(await hashPath(entryPath), entry.name);
|
|
34920
35162
|
}
|
|
34921
35163
|
}
|
|
34922
35164
|
async function importCategoryEntries(category, candidates, destinationDir, result) {
|
|
34923
|
-
await
|
|
35165
|
+
await import_fs_extra12.default.ensureDir(destinationDir);
|
|
34924
35166
|
const destinationRealPath = await realPathIfPossible(destinationDir);
|
|
34925
35167
|
const knownHashes = new Map;
|
|
34926
35168
|
await addExistingDestinationHashes(destinationDir, knownHashes);
|
|
34927
35169
|
for (const candidate of candidates) {
|
|
34928
35170
|
if (candidate.category !== category || candidate.isDestination)
|
|
34929
35171
|
continue;
|
|
34930
|
-
const candidateStat = await
|
|
35172
|
+
const candidateStat = await import_fs_extra12.default.lstat(candidate.path).catch(() => null);
|
|
34931
35173
|
if (!candidateStat)
|
|
34932
35174
|
continue;
|
|
34933
35175
|
const candidateRealPath = await realPathIfPossible(candidate.path);
|
|
34934
35176
|
if (destinationRealPath && candidateRealPath && samePath(destinationRealPath, candidateRealPath)) {
|
|
34935
35177
|
continue;
|
|
34936
35178
|
}
|
|
34937
|
-
const entries = await
|
|
35179
|
+
const entries = await import_fs_extra12.default.readdir(candidate.path, { withFileTypes: true }).catch(() => null);
|
|
34938
35180
|
if (!entries) {
|
|
34939
35181
|
result.skipped.push({
|
|
34940
35182
|
category,
|
|
@@ -34946,7 +35188,7 @@ async function importCategoryEntries(category, candidates, destinationDir, resul
|
|
|
34946
35188
|
for (const entry of entries) {
|
|
34947
35189
|
if (!shouldCollectEntry(category, entry))
|
|
34948
35190
|
continue;
|
|
34949
|
-
const sourcePath =
|
|
35191
|
+
const sourcePath = path16.join(candidate.path, entry.name);
|
|
34950
35192
|
const sourceHash = await hashPath(sourcePath);
|
|
34951
35193
|
const existingName = knownHashes.get(sourceHash);
|
|
34952
35194
|
if (existingName) {
|
|
@@ -34954,15 +35196,15 @@ async function importCategoryEntries(category, candidates, destinationDir, resul
|
|
|
34954
35196
|
category,
|
|
34955
35197
|
name: entry.name,
|
|
34956
35198
|
from: sourcePath,
|
|
34957
|
-
keptAs:
|
|
35199
|
+
keptAs: path16.join(destinationDir, existingName)
|
|
34958
35200
|
});
|
|
34959
35201
|
continue;
|
|
34960
35202
|
}
|
|
34961
35203
|
let targetName = entry.name;
|
|
34962
|
-
let targetPath =
|
|
35204
|
+
let targetPath = path16.join(destinationDir, targetName);
|
|
34963
35205
|
if (await pathExistsOrSymlink(targetPath)) {
|
|
34964
35206
|
targetName = await findTargetName(destinationDir, entry.name, candidate.label);
|
|
34965
|
-
targetPath =
|
|
35207
|
+
targetPath = path16.join(destinationDir, targetName);
|
|
34966
35208
|
result.renamed.push({
|
|
34967
35209
|
category,
|
|
34968
35210
|
name: entry.name,
|
|
@@ -34971,7 +35213,7 @@ async function importCategoryEntries(category, candidates, destinationDir, resul
|
|
|
34971
35213
|
reason: "Same name with different content"
|
|
34972
35214
|
});
|
|
34973
35215
|
}
|
|
34974
|
-
await
|
|
35216
|
+
await import_fs_extra12.default.copy(sourcePath, targetPath, {
|
|
34975
35217
|
dereference: false,
|
|
34976
35218
|
overwrite: false
|
|
34977
35219
|
});
|
|
@@ -34989,43 +35231,43 @@ function timestamp2(date = new Date) {
|
|
|
34989
35231
|
return date.toISOString().replace(/\.\d{3}Z$/, "").replace(/[:T]/g, "-");
|
|
34990
35232
|
}
|
|
34991
35233
|
function safeRelativePath(rootDir, targetPath) {
|
|
34992
|
-
const relativePath =
|
|
34993
|
-
if (!relativePath || relativePath.startsWith("..") ||
|
|
34994
|
-
return
|
|
35234
|
+
const relativePath = path16.relative(rootDir, targetPath);
|
|
35235
|
+
if (!relativePath || relativePath.startsWith("..") || path16.isAbsolute(relativePath)) {
|
|
35236
|
+
return path16.join("external", targetPath.replace(/[^a-zA-Z0-9._-]+/g, "-"));
|
|
34995
35237
|
}
|
|
34996
35238
|
return relativePath;
|
|
34997
35239
|
}
|
|
34998
35240
|
function createBackupPath(rootDir) {
|
|
34999
|
-
return
|
|
35241
|
+
return path16.join(rootDir, ".aiblueprint", "backups", "agents-unify-sources", timestamp2());
|
|
35000
35242
|
}
|
|
35001
35243
|
async function ensureBackupPath(result) {
|
|
35002
35244
|
if (!result.backupPath) {
|
|
35003
35245
|
result.backupPath = createBackupPath(result.rootDir);
|
|
35004
|
-
await
|
|
35246
|
+
await import_fs_extra12.default.ensureDir(result.backupPath);
|
|
35005
35247
|
}
|
|
35006
35248
|
return result.backupPath;
|
|
35007
35249
|
}
|
|
35008
35250
|
async function createDirectorySymlink(source, target) {
|
|
35009
|
-
await
|
|
35251
|
+
await import_fs_extra12.default.ensureDir(path16.dirname(target));
|
|
35010
35252
|
if (os13.platform() === "win32") {
|
|
35011
|
-
await
|
|
35253
|
+
await import_fs_extra12.default.symlink(source, target, "junction");
|
|
35012
35254
|
return;
|
|
35013
35255
|
}
|
|
35014
|
-
await
|
|
35256
|
+
await import_fs_extra12.default.symlink(source, target, "dir");
|
|
35015
35257
|
}
|
|
35016
35258
|
async function shouldLinkMissingContainer(candidate) {
|
|
35017
35259
|
if (candidate.linkWhenMissing)
|
|
35018
35260
|
return true;
|
|
35019
35261
|
if (!candidate.linkWhenParentExists)
|
|
35020
35262
|
return false;
|
|
35021
|
-
return
|
|
35263
|
+
return import_fs_extra12.default.pathExists(path16.dirname(candidate.path));
|
|
35022
35264
|
}
|
|
35023
35265
|
async function linkContainer(candidate, destinationDir, result) {
|
|
35024
35266
|
if (candidate.isDestination || samePath(candidate.path, destinationDir)) {
|
|
35025
35267
|
return;
|
|
35026
35268
|
}
|
|
35027
35269
|
const destinationRealPath = await realPathIfPossible(destinationDir);
|
|
35028
|
-
const stat = await
|
|
35270
|
+
const stat = await import_fs_extra12.default.lstat(candidate.path).catch(() => null);
|
|
35029
35271
|
if (!stat) {
|
|
35030
35272
|
if (!await shouldLinkMissingContainer(candidate))
|
|
35031
35273
|
return;
|
|
@@ -35047,7 +35289,7 @@ async function linkContainer(candidate, destinationDir, result) {
|
|
|
35047
35289
|
});
|
|
35048
35290
|
return;
|
|
35049
35291
|
}
|
|
35050
|
-
await
|
|
35292
|
+
await import_fs_extra12.default.remove(candidate.path);
|
|
35051
35293
|
await createDirectorySymlink(destinationDir, candidate.path);
|
|
35052
35294
|
result.linked.push({
|
|
35053
35295
|
category: candidate.category,
|
|
@@ -35057,9 +35299,9 @@ async function linkContainer(candidate, destinationDir, result) {
|
|
|
35057
35299
|
return;
|
|
35058
35300
|
}
|
|
35059
35301
|
const backupRoot = await ensureBackupPath(result);
|
|
35060
|
-
const backupTarget =
|
|
35061
|
-
await
|
|
35062
|
-
await
|
|
35302
|
+
const backupTarget = path16.join(backupRoot, safeRelativePath(result.rootDir, candidate.path));
|
|
35303
|
+
await import_fs_extra12.default.ensureDir(path16.dirname(backupTarget));
|
|
35304
|
+
await import_fs_extra12.default.move(candidate.path, backupTarget, { overwrite: false });
|
|
35063
35305
|
await createDirectorySymlink(destinationDir, candidate.path);
|
|
35064
35306
|
result.linked.push({
|
|
35065
35307
|
category: candidate.category,
|
|
@@ -35083,10 +35325,10 @@ async function unifyAgentsConfiguration(options = {}) {
|
|
|
35083
35325
|
skipped: []
|
|
35084
35326
|
};
|
|
35085
35327
|
const destinationByCategory = {
|
|
35086
|
-
skills:
|
|
35087
|
-
agents:
|
|
35328
|
+
skills: path16.join(folders.agentsDir, "skills"),
|
|
35329
|
+
agents: path16.join(folders.agentsDir, "agents")
|
|
35088
35330
|
};
|
|
35089
|
-
await
|
|
35331
|
+
await import_fs_extra12.default.ensureDir(folders.agentsDir);
|
|
35090
35332
|
for (const category of ["skills", "agents"]) {
|
|
35091
35333
|
await importCategoryEntries(category, candidates, destinationByCategory[category], result);
|
|
35092
35334
|
}
|
|
@@ -35113,13 +35355,15 @@ async function agentsUnifyCommand(params = {}) {
|
|
|
35113
35355
|
console.log(source_default.blue.bold(`
|
|
35114
35356
|
AIBlueprint agents unify ${source_default.gray(`v${getVersion()}`)}
|
|
35115
35357
|
`));
|
|
35116
|
-
console.log(source_default.gray("Centralizing reusable skills and agents into .agents"));
|
|
35358
|
+
console.log(source_default.gray("Centralizing reusable skills and agents into .agents, then rendering Codex agents"));
|
|
35117
35359
|
const result = await unifyAgentsConfiguration(params);
|
|
35360
|
+
const codexResult = await renderCodexAgentsFromMarkdown(params);
|
|
35118
35361
|
console.log(source_default.green(`
|
|
35119
35362
|
Unify complete`));
|
|
35120
35363
|
console.log(source_default.gray(` Shared folder: ${result.agentsDir}`));
|
|
35121
35364
|
printCategorySummary(result, "skills");
|
|
35122
35365
|
printCategorySummary(result, "agents");
|
|
35366
|
+
console.log(source_default.gray(` codex agents: ${codexResult.rendered.length} rendered, ${codexResult.skipped.length} skipped`));
|
|
35123
35367
|
if (result.backupPath) {
|
|
35124
35368
|
console.log(source_default.gray(` Source backups: ${result.backupPath}`));
|
|
35125
35369
|
}
|
|
@@ -35137,6 +35381,34 @@ Agents unify failed:`), error);
|
|
|
35137
35381
|
}
|
|
35138
35382
|
}
|
|
35139
35383
|
|
|
35384
|
+
// src/commands/codex-agents.ts
|
|
35385
|
+
async function codexAgentsCommand(options = {}) {
|
|
35386
|
+
try {
|
|
35387
|
+
console.log(source_default.blue.bold(`
|
|
35388
|
+
AIBlueprint Codex agents ${source_default.gray(`v${getVersion()}`)}
|
|
35389
|
+
`));
|
|
35390
|
+
console.log(source_default.gray("Rendering shared Markdown agents into Codex TOML custom agents"));
|
|
35391
|
+
const result = await renderCodexAgentsFromMarkdown(options);
|
|
35392
|
+
console.log(source_default.green(`
|
|
35393
|
+
Codex agents rendered`));
|
|
35394
|
+
console.log(source_default.gray(` Source: ${result.sourceDir}`));
|
|
35395
|
+
console.log(source_default.gray(` Target: ${result.targetDir}`));
|
|
35396
|
+
console.log(source_default.gray(` Rendered: ${result.rendered.length}`));
|
|
35397
|
+
console.log(source_default.gray(` Skipped: ${result.skipped.length}`));
|
|
35398
|
+
if (result.skipped.length > 0) {
|
|
35399
|
+
console.log(source_default.yellow(`
|
|
35400
|
+
Skipped agents:`));
|
|
35401
|
+
for (const skipped of result.skipped) {
|
|
35402
|
+
console.log(source_default.yellow(` ${skipped.source}: ${skipped.reason}`));
|
|
35403
|
+
}
|
|
35404
|
+
}
|
|
35405
|
+
} catch (error) {
|
|
35406
|
+
console.error(source_default.red(`
|
|
35407
|
+
Codex agents render failed:`), error);
|
|
35408
|
+
process.exit(1);
|
|
35409
|
+
}
|
|
35410
|
+
}
|
|
35411
|
+
|
|
35140
35412
|
// node_modules/@clack/core/dist/index.mjs
|
|
35141
35413
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
35142
35414
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
@@ -35853,12 +36125,12 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
35853
36125
|
};
|
|
35854
36126
|
|
|
35855
36127
|
// src/commands/pro.ts
|
|
35856
|
-
import
|
|
36128
|
+
import path19 from "path";
|
|
35857
36129
|
|
|
35858
36130
|
// src/lib/pro-installer.ts
|
|
35859
|
-
var
|
|
36131
|
+
var import_fs_extra13 = __toESM(require_lib4(), 1);
|
|
35860
36132
|
import os14 from "os";
|
|
35861
|
-
import
|
|
36133
|
+
import path17 from "path";
|
|
35862
36134
|
import { exec as exec3 } from "child_process";
|
|
35863
36135
|
import { promisify as promisify2 } from "util";
|
|
35864
36136
|
var execAsync2 = promisify2(exec3);
|
|
@@ -35866,9 +36138,9 @@ var PREMIUM_REPO = "Melvynx/aiblueprint-cli-premium";
|
|
|
35866
36138
|
var PREMIUM_BRANCH = "main";
|
|
35867
36139
|
var CONFIG_FOLDER_CANDIDATES2 = ["agents-config", "ai-coding", "claude-code-config", "ai-config"];
|
|
35868
36140
|
function routePath(relativePath) {
|
|
35869
|
-
const segments = relativePath.split(
|
|
36141
|
+
const segments = relativePath.split(path17.sep);
|
|
35870
36142
|
const first = segments[0];
|
|
35871
|
-
const rest = segments.slice(1).join(
|
|
36143
|
+
const rest = segments.slice(1).join(path17.sep);
|
|
35872
36144
|
if (first === "claude-config") {
|
|
35873
36145
|
return { kind: "claude", relativePath: rest };
|
|
35874
36146
|
}
|
|
@@ -35884,7 +36156,7 @@ function routePath(relativePath) {
|
|
|
35884
36156
|
return { kind: "claude", relativePath };
|
|
35885
36157
|
}
|
|
35886
36158
|
function getCacheRepoDir() {
|
|
35887
|
-
return
|
|
36159
|
+
return path17.join(os14.homedir(), ".config", "aiblueprint", "pro-repos", "aiblueprint-cli-premium");
|
|
35888
36160
|
}
|
|
35889
36161
|
async function execGitWithAuth(command, token, repoUrl, cwd) {
|
|
35890
36162
|
const authenticatedUrl = `https://x-access-token:${token}@${repoUrl.replace(/^https?:\/\//, "")}`;
|
|
@@ -35898,21 +36170,21 @@ async function execGitWithAuth(command, token, repoUrl, cwd) {
|
|
|
35898
36170
|
async function cloneOrUpdateRepo(token) {
|
|
35899
36171
|
const cacheDir = getCacheRepoDir();
|
|
35900
36172
|
const repoUrl = `https://github.com/${PREMIUM_REPO}.git`;
|
|
35901
|
-
if (await
|
|
36173
|
+
if (await import_fs_extra13.default.pathExists(path17.join(cacheDir, ".git"))) {
|
|
35902
36174
|
try {
|
|
35903
36175
|
await execGitWithAuth("pull", token, repoUrl, cacheDir);
|
|
35904
36176
|
} catch (error) {
|
|
35905
|
-
await
|
|
35906
|
-
await
|
|
36177
|
+
await import_fs_extra13.default.remove(cacheDir);
|
|
36178
|
+
await import_fs_extra13.default.ensureDir(path17.dirname(cacheDir));
|
|
35907
36179
|
await execGitWithAuth(`clone ${repoUrl} ${cacheDir}`, token, repoUrl);
|
|
35908
36180
|
}
|
|
35909
36181
|
} else {
|
|
35910
|
-
await
|
|
36182
|
+
await import_fs_extra13.default.ensureDir(path17.dirname(cacheDir));
|
|
35911
36183
|
await execGitWithAuth(`clone ${repoUrl} ${cacheDir}`, token, repoUrl);
|
|
35912
36184
|
}
|
|
35913
36185
|
for (const candidate of CONFIG_FOLDER_CANDIDATES2) {
|
|
35914
|
-
const candidatePath =
|
|
35915
|
-
if (await
|
|
36186
|
+
const candidatePath = path17.join(cacheDir, candidate);
|
|
36187
|
+
if (await import_fs_extra13.default.pathExists(candidatePath)) {
|
|
35916
36188
|
return candidatePath;
|
|
35917
36189
|
}
|
|
35918
36190
|
}
|
|
@@ -35920,38 +36192,38 @@ async function cloneOrUpdateRepo(token) {
|
|
|
35920
36192
|
}
|
|
35921
36193
|
async function copyConfigFromCache(cacheConfigDir, dest, onProgress) {
|
|
35922
36194
|
const walk = async (dir, baseDir = dir) => {
|
|
35923
|
-
const entries = await
|
|
36195
|
+
const entries = await import_fs_extra13.default.readdir(dir, { withFileTypes: true });
|
|
35924
36196
|
for (const entry of entries) {
|
|
35925
36197
|
if (entry.name === ".DS_Store" || entry.name === "node_modules")
|
|
35926
36198
|
continue;
|
|
35927
|
-
const sourcePath =
|
|
35928
|
-
const relativePath =
|
|
36199
|
+
const sourcePath = path17.join(dir, entry.name);
|
|
36200
|
+
const relativePath = path17.relative(baseDir, sourcePath);
|
|
35929
36201
|
const route = routePath(relativePath);
|
|
35930
36202
|
if (route.kind === "skip")
|
|
35931
36203
|
continue;
|
|
35932
36204
|
if (route.kind === "agents-category") {
|
|
35933
|
-
if (relativePath.split(
|
|
36205
|
+
if (relativePath.split(path17.sep).length === 1) {
|
|
35934
36206
|
await copyAgentCategory(sourcePath, route.category, dest.agentsDir, dest.claudeDir, onProgress);
|
|
35935
36207
|
}
|
|
35936
36208
|
continue;
|
|
35937
36209
|
}
|
|
35938
36210
|
const targetBase = route.kind === "claude" ? dest.claudeDir : dest.codexDir;
|
|
35939
|
-
const targetPath =
|
|
36211
|
+
const targetPath = path17.join(targetBase, route.relativePath);
|
|
35940
36212
|
if (entry.isDirectory()) {
|
|
35941
|
-
await
|
|
36213
|
+
await import_fs_extra13.default.ensureDir(targetPath);
|
|
35942
36214
|
onProgress?.(relativePath, "directory");
|
|
35943
36215
|
await walk(sourcePath, baseDir);
|
|
35944
36216
|
} else if (route.kind === "codex" && route.relativePath === "config.toml") {
|
|
35945
36217
|
await mergeCodexConfigFile(sourcePath, dest.codexDir);
|
|
35946
36218
|
onProgress?.(relativePath, "file");
|
|
35947
36219
|
} else if (isTextFile(entry.name)) {
|
|
35948
|
-
const content = await
|
|
36220
|
+
const content = await import_fs_extra13.default.readFile(sourcePath, "utf-8");
|
|
35949
36221
|
const replaced = replaceClaudePathPlaceholder(content, dest.claudeDir);
|
|
35950
|
-
await
|
|
35951
|
-
await
|
|
36222
|
+
await import_fs_extra13.default.ensureDir(path17.dirname(targetPath));
|
|
36223
|
+
await import_fs_extra13.default.writeFile(targetPath, replaced, "utf-8");
|
|
35952
36224
|
onProgress?.(relativePath, "file");
|
|
35953
36225
|
} else {
|
|
35954
|
-
await
|
|
36226
|
+
await import_fs_extra13.default.copy(sourcePath, targetPath, { overwrite: true });
|
|
35955
36227
|
onProgress?.(relativePath, "file");
|
|
35956
36228
|
}
|
|
35957
36229
|
}
|
|
@@ -35959,21 +36231,21 @@ async function copyConfigFromCache(cacheConfigDir, dest, onProgress) {
|
|
|
35959
36231
|
await walk(cacheConfigDir);
|
|
35960
36232
|
}
|
|
35961
36233
|
async function copyAgentCategory(sourceCategoryDir, category, agentsDir, claudeDir, onProgress) {
|
|
35962
|
-
const agentsCategoryDir =
|
|
35963
|
-
await
|
|
35964
|
-
const entries = await
|
|
36234
|
+
const agentsCategoryDir = path17.join(agentsDir, category);
|
|
36235
|
+
await import_fs_extra13.default.ensureDir(agentsCategoryDir);
|
|
36236
|
+
const entries = await import_fs_extra13.default.readdir(sourceCategoryDir, { withFileTypes: true });
|
|
35965
36237
|
for (const entry of entries) {
|
|
35966
36238
|
if (entry.name === ".DS_Store")
|
|
35967
36239
|
continue;
|
|
35968
|
-
const src =
|
|
35969
|
-
const dst =
|
|
35970
|
-
const claudeTop =
|
|
35971
|
-
const claudeStat = await
|
|
36240
|
+
const src = path17.join(sourceCategoryDir, entry.name);
|
|
36241
|
+
const dst = path17.join(agentsCategoryDir, entry.name);
|
|
36242
|
+
const claudeTop = path17.join(claudeDir, category, entry.name);
|
|
36243
|
+
const claudeStat = await import_fs_extra13.default.lstat(claudeTop).catch(() => null);
|
|
35972
36244
|
if (claudeStat && !claudeStat.isSymbolicLink()) {
|
|
35973
36245
|
onProgress?.(`${category}/${entry.name} (skipped - real dir in claude)`, "file");
|
|
35974
36246
|
continue;
|
|
35975
36247
|
}
|
|
35976
|
-
await
|
|
36248
|
+
await import_fs_extra13.default.copy(src, dst, { overwrite: true });
|
|
35977
36249
|
await applyPathPlaceholders(dst, claudeDir);
|
|
35978
36250
|
onProgress?.(`${category}/${entry.name}`, entry.isDirectory() ? "directory" : "file");
|
|
35979
36251
|
}
|
|
@@ -35992,8 +36264,8 @@ async function downloadFromPrivateGitHub(repo, branch, relativePath, targetPath,
|
|
|
35992
36264
|
return false;
|
|
35993
36265
|
}
|
|
35994
36266
|
const content = await response.arrayBuffer();
|
|
35995
|
-
await
|
|
35996
|
-
await
|
|
36267
|
+
await import_fs_extra13.default.ensureDir(path17.dirname(targetPath));
|
|
36268
|
+
await import_fs_extra13.default.writeFile(targetPath, Buffer.from(content));
|
|
35997
36269
|
return true;
|
|
35998
36270
|
} catch (error) {
|
|
35999
36271
|
console.error(`Error downloading ${relativePath}:`, error);
|
|
@@ -36018,10 +36290,10 @@ async function downloadDirectoryFromPrivateGitHub(repo, branch, dirPath, targetD
|
|
|
36018
36290
|
console.error(`Unexpected response for directory ${dirPath}`);
|
|
36019
36291
|
return false;
|
|
36020
36292
|
}
|
|
36021
|
-
await
|
|
36293
|
+
await import_fs_extra13.default.ensureDir(targetDir);
|
|
36022
36294
|
for (const file of files) {
|
|
36023
36295
|
const relativePath = dirPath ? `${dirPath}/${file.name}` : file.name;
|
|
36024
|
-
const targetPath =
|
|
36296
|
+
const targetPath = path17.join(targetDir, file.name);
|
|
36025
36297
|
const displayPath = relativePath.replace(/^(agents-config|ai-coding|claude-code-config|ai-config)\//, "");
|
|
36026
36298
|
if (file.type === "file") {
|
|
36027
36299
|
onProgress?.(displayPath, "file");
|
|
@@ -36044,8 +36316,8 @@ async function installProConfigs(options) {
|
|
|
36044
36316
|
codexFolder,
|
|
36045
36317
|
agentsFolder
|
|
36046
36318
|
});
|
|
36047
|
-
await
|
|
36048
|
-
await
|
|
36319
|
+
await import_fs_extra13.default.ensureDir(claudeDir);
|
|
36320
|
+
await import_fs_extra13.default.ensureDir(agentsDir);
|
|
36049
36321
|
const dest = { claudeDir, codexDir, agentsDir };
|
|
36050
36322
|
try {
|
|
36051
36323
|
const cacheConfigDir = await cloneOrUpdateRepo(githubToken);
|
|
@@ -36055,7 +36327,7 @@ async function installProConfigs(options) {
|
|
|
36055
36327
|
} catch (error) {
|
|
36056
36328
|
console.warn("Git caching failed, falling back to API download");
|
|
36057
36329
|
}
|
|
36058
|
-
const tempDir =
|
|
36330
|
+
const tempDir = path17.join(os14.tmpdir(), `aiblueprint-premium-${Date.now()}`);
|
|
36059
36331
|
try {
|
|
36060
36332
|
let success = false;
|
|
36061
36333
|
for (const candidate of CONFIG_FOLDER_CANDIDATES2) {
|
|
@@ -36069,8 +36341,8 @@ async function installProConfigs(options) {
|
|
|
36069
36341
|
await copyConfigFromCache(tempDir, dest, onProgress);
|
|
36070
36342
|
await replacePathPlaceholdersInDir(claudeDir, claudeDir);
|
|
36071
36343
|
for (const category of AGENT_CATEGORIES) {
|
|
36072
|
-
const agentsCategoryDir =
|
|
36073
|
-
if (await
|
|
36344
|
+
const agentsCategoryDir = path17.join(agentsDir, category);
|
|
36345
|
+
if (await import_fs_extra13.default.pathExists(agentsCategoryDir)) {
|
|
36074
36346
|
await replacePathPlaceholdersInDir(agentsCategoryDir, claudeDir);
|
|
36075
36347
|
}
|
|
36076
36348
|
}
|
|
@@ -36079,7 +36351,7 @@ async function installProConfigs(options) {
|
|
|
36079
36351
|
throw new Error(`Failed to install premium configs: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
36080
36352
|
} finally {
|
|
36081
36353
|
try {
|
|
36082
|
-
await
|
|
36354
|
+
await import_fs_extra13.default.remove(tempDir);
|
|
36083
36355
|
} catch {}
|
|
36084
36356
|
}
|
|
36085
36357
|
}
|
|
@@ -36090,27 +36362,27 @@ async function syncAllAgentSymlinks(agentsDir, claudeDir) {
|
|
|
36090
36362
|
}
|
|
36091
36363
|
|
|
36092
36364
|
// src/lib/token-storage.ts
|
|
36093
|
-
var
|
|
36365
|
+
var import_fs_extra14 = __toESM(require_lib4(), 1);
|
|
36094
36366
|
import os15 from "os";
|
|
36095
|
-
import
|
|
36367
|
+
import path18 from "path";
|
|
36096
36368
|
function getConfigDir() {
|
|
36097
36369
|
const platform = os15.platform();
|
|
36098
36370
|
if (platform === "win32") {
|
|
36099
|
-
const appData = process.env.APPDATA ||
|
|
36100
|
-
return
|
|
36371
|
+
const appData = process.env.APPDATA || path18.join(os15.homedir(), "AppData", "Roaming");
|
|
36372
|
+
return path18.join(appData, "aiblueprint");
|
|
36101
36373
|
} else {
|
|
36102
|
-
const configHome = process.env.XDG_CONFIG_HOME ||
|
|
36103
|
-
return
|
|
36374
|
+
const configHome = process.env.XDG_CONFIG_HOME || path18.join(os15.homedir(), ".config");
|
|
36375
|
+
return path18.join(configHome, "aiblueprint");
|
|
36104
36376
|
}
|
|
36105
36377
|
}
|
|
36106
36378
|
function getTokenFilePath2() {
|
|
36107
|
-
return
|
|
36379
|
+
return path18.join(getConfigDir(), "token.txt");
|
|
36108
36380
|
}
|
|
36109
36381
|
async function saveToken(githubToken) {
|
|
36110
36382
|
const tokenFile = getTokenFilePath2();
|
|
36111
|
-
const configDir =
|
|
36383
|
+
const configDir = path18.dirname(tokenFile);
|
|
36112
36384
|
try {
|
|
36113
|
-
await
|
|
36385
|
+
await import_fs_extra14.default.ensureDir(configDir);
|
|
36114
36386
|
} catch (error) {
|
|
36115
36387
|
if (error.code === "EACCES") {
|
|
36116
36388
|
throw new Error(`Permission denied creating config directory: ${configDir}
|
|
@@ -36118,15 +36390,15 @@ async function saveToken(githubToken) {
|
|
|
36118
36390
|
}
|
|
36119
36391
|
throw error;
|
|
36120
36392
|
}
|
|
36121
|
-
await
|
|
36393
|
+
await import_fs_extra14.default.writeFile(tokenFile, githubToken, { mode: 384 });
|
|
36122
36394
|
}
|
|
36123
36395
|
async function getToken() {
|
|
36124
36396
|
const tokenFile = getTokenFilePath2();
|
|
36125
|
-
if (!await
|
|
36397
|
+
if (!await import_fs_extra14.default.pathExists(tokenFile)) {
|
|
36126
36398
|
return null;
|
|
36127
36399
|
}
|
|
36128
36400
|
try {
|
|
36129
|
-
const token = await
|
|
36401
|
+
const token = await import_fs_extra14.default.readFile(tokenFile, "utf-8");
|
|
36130
36402
|
return token.trim();
|
|
36131
36403
|
} catch (error) {
|
|
36132
36404
|
return null;
|
|
@@ -36140,7 +36412,7 @@ function getTokenInfo() {
|
|
|
36140
36412
|
}
|
|
36141
36413
|
|
|
36142
36414
|
// src/commands/pro.ts
|
|
36143
|
-
var
|
|
36415
|
+
var import_fs_extra15 = __toESM(require_lib4(), 1);
|
|
36144
36416
|
var API_URL = "https://codeline.app/api/products";
|
|
36145
36417
|
var PRODUCT_IDS = ["prd_XJVgxVPbGG", "prd_NKabAkdOkw"];
|
|
36146
36418
|
async function countInstalledItems(claudeDir) {
|
|
@@ -36149,20 +36421,20 @@ async function countInstalledItems(claudeDir) {
|
|
|
36149
36421
|
skills: 0
|
|
36150
36422
|
};
|
|
36151
36423
|
try {
|
|
36152
|
-
const agentsDir =
|
|
36153
|
-
if (await
|
|
36154
|
-
const files = await
|
|
36424
|
+
const agentsDir = path19.join(claudeDir, "agents");
|
|
36425
|
+
if (await import_fs_extra15.default.pathExists(agentsDir)) {
|
|
36426
|
+
const files = await import_fs_extra15.default.readdir(agentsDir);
|
|
36155
36427
|
counts.agents = files.filter((f) => f.endsWith(".md")).length;
|
|
36156
36428
|
}
|
|
36157
36429
|
} catch (error) {
|
|
36158
36430
|
console.error("Failed to count agents:", error instanceof Error ? error.message : error);
|
|
36159
36431
|
}
|
|
36160
36432
|
try {
|
|
36161
|
-
const skillsDir =
|
|
36162
|
-
if (await
|
|
36163
|
-
const items = await
|
|
36433
|
+
const skillsDir = path19.join(claudeDir, "skills");
|
|
36434
|
+
if (await import_fs_extra15.default.pathExists(skillsDir)) {
|
|
36435
|
+
const items = await import_fs_extra15.default.readdir(skillsDir);
|
|
36164
36436
|
const dirs = await Promise.all(items.map(async (item) => {
|
|
36165
|
-
const stat = await
|
|
36437
|
+
const stat = await import_fs_extra15.default.stat(path19.join(skillsDir, item));
|
|
36166
36438
|
return stat.isDirectory();
|
|
36167
36439
|
}));
|
|
36168
36440
|
counts.skills = dirs.filter(Boolean).length;
|
|
@@ -36370,8 +36642,8 @@ async function proUpdateCommand(options = {}) {
|
|
|
36370
36642
|
}
|
|
36371
36643
|
|
|
36372
36644
|
// src/lib/sync-utils.ts
|
|
36373
|
-
var
|
|
36374
|
-
import
|
|
36645
|
+
var import_fs_extra16 = __toESM(require_lib4(), 1);
|
|
36646
|
+
import path20 from "path";
|
|
36375
36647
|
import crypto2 from "crypto";
|
|
36376
36648
|
var PREMIUM_REPO2 = "Melvynx/aiblueprint-cli-premium";
|
|
36377
36649
|
var PREMIUM_BRANCH2 = "main";
|
|
@@ -36442,7 +36714,7 @@ async function listRemoteFilesRecursive(dirPath, githubToken, basePath = "") {
|
|
|
36442
36714
|
}
|
|
36443
36715
|
async function computeLocalFileSha(filePath) {
|
|
36444
36716
|
try {
|
|
36445
|
-
const content = await
|
|
36717
|
+
const content = await import_fs_extra16.default.readFile(filePath);
|
|
36446
36718
|
return computeFileSha(content);
|
|
36447
36719
|
} catch {
|
|
36448
36720
|
return null;
|
|
@@ -36450,15 +36722,15 @@ async function computeLocalFileSha(filePath) {
|
|
|
36450
36722
|
}
|
|
36451
36723
|
async function listLocalFiles(dir) {
|
|
36452
36724
|
const files = [];
|
|
36453
|
-
if (!await
|
|
36725
|
+
if (!await import_fs_extra16.default.pathExists(dir)) {
|
|
36454
36726
|
return files;
|
|
36455
36727
|
}
|
|
36456
|
-
const items = await
|
|
36728
|
+
const items = await import_fs_extra16.default.readdir(dir);
|
|
36457
36729
|
for (const item of items) {
|
|
36458
36730
|
if (item === "node_modules" || item === ".DS_Store")
|
|
36459
36731
|
continue;
|
|
36460
|
-
const fullPath =
|
|
36461
|
-
const stat = await
|
|
36732
|
+
const fullPath = path20.join(dir, item);
|
|
36733
|
+
const stat = await import_fs_extra16.default.stat(fullPath).catch(() => null);
|
|
36462
36734
|
if (!stat)
|
|
36463
36735
|
continue;
|
|
36464
36736
|
if (stat.isDirectory()) {
|
|
@@ -36473,13 +36745,13 @@ async function listLocalFiles(dir) {
|
|
|
36473
36745
|
}
|
|
36474
36746
|
async function listLocalFilesRecursive(dir, basePath) {
|
|
36475
36747
|
const files = [];
|
|
36476
|
-
const items = await
|
|
36748
|
+
const items = await import_fs_extra16.default.readdir(dir).catch(() => []);
|
|
36477
36749
|
for (const item of items) {
|
|
36478
36750
|
if (item === "node_modules" || item === ".DS_Store")
|
|
36479
36751
|
continue;
|
|
36480
|
-
const fullPath =
|
|
36752
|
+
const fullPath = path20.join(dir, item);
|
|
36481
36753
|
const relativePath = `${basePath}/${item}`;
|
|
36482
|
-
const stat = await
|
|
36754
|
+
const stat = await import_fs_extra16.default.stat(fullPath).catch(() => null);
|
|
36483
36755
|
if (!stat)
|
|
36484
36756
|
continue;
|
|
36485
36757
|
if (stat.isDirectory()) {
|
|
@@ -36493,14 +36765,14 @@ async function listLocalFilesRecursive(dir, basePath) {
|
|
|
36493
36765
|
return files;
|
|
36494
36766
|
}
|
|
36495
36767
|
async function listClaudeRealTopLevel(claudeCategoryDir) {
|
|
36496
|
-
if (!await
|
|
36768
|
+
if (!await import_fs_extra16.default.pathExists(claudeCategoryDir))
|
|
36497
36769
|
return [];
|
|
36498
|
-
const entries = await
|
|
36770
|
+
const entries = await import_fs_extra16.default.readdir(claudeCategoryDir).catch(() => []);
|
|
36499
36771
|
const real = [];
|
|
36500
36772
|
for (const name of entries) {
|
|
36501
36773
|
if (name === "node_modules" || name === ".DS_Store")
|
|
36502
36774
|
continue;
|
|
36503
|
-
const stat = await
|
|
36775
|
+
const stat = await import_fs_extra16.default.lstat(path20.join(claudeCategoryDir, name)).catch(() => null);
|
|
36504
36776
|
if (!stat)
|
|
36505
36777
|
continue;
|
|
36506
36778
|
if (stat.isDirectory())
|
|
@@ -36517,7 +36789,7 @@ async function analyzeCategory(category, claudeDir, agentsDir, githubToken) {
|
|
|
36517
36789
|
const items = [];
|
|
36518
36790
|
const useAgents = isAgentCategory(category);
|
|
36519
36791
|
const localBase = useAgents ? agentsDir : claudeDir;
|
|
36520
|
-
const localDir =
|
|
36792
|
+
const localDir = path20.join(localBase, category);
|
|
36521
36793
|
const remoteCategoryPath = getRemoteCategoryPath(category);
|
|
36522
36794
|
const remoteFiles = await listRemoteFilesRecursive(remoteCategoryPath, githubToken);
|
|
36523
36795
|
const localFiles = await listLocalFiles(localDir);
|
|
@@ -36531,7 +36803,7 @@ async function analyzeCategory(category, claudeDir, agentsDir, githubToken) {
|
|
|
36531
36803
|
}
|
|
36532
36804
|
const localSet = new Set(localFiles);
|
|
36533
36805
|
for (const [remotePath, { sha, isFolder }] of remoteSet) {
|
|
36534
|
-
const localPath =
|
|
36806
|
+
const localPath = path20.join(localDir, remotePath);
|
|
36535
36807
|
if (isFolder) {
|
|
36536
36808
|
continue;
|
|
36537
36809
|
}
|
|
@@ -36566,7 +36838,7 @@ async function analyzeCategory(category, claudeDir, agentsDir, githubToken) {
|
|
|
36566
36838
|
for (const localPath of localSet) {
|
|
36567
36839
|
agentsTopLevels.add(localPath.split("/")[0]);
|
|
36568
36840
|
}
|
|
36569
|
-
const claudeCategoryDir =
|
|
36841
|
+
const claudeCategoryDir = path20.join(claudeDir, category);
|
|
36570
36842
|
const claudeRealEntries = await listClaudeRealTopLevel(claudeCategoryDir);
|
|
36571
36843
|
for (const top of claudeRealEntries) {
|
|
36572
36844
|
if (!remoteTopLevels.has(top))
|
|
@@ -36625,13 +36897,13 @@ async function downloadFromPrivateGitHub2(relativePath, targetPath, githubToken,
|
|
|
36625
36897
|
return false;
|
|
36626
36898
|
}
|
|
36627
36899
|
const content = await response.arrayBuffer();
|
|
36628
|
-
await
|
|
36900
|
+
await import_fs_extra16.default.ensureDir(path20.dirname(targetPath));
|
|
36629
36901
|
if (isTextFile(relativePath)) {
|
|
36630
36902
|
const textContent = Buffer.from(content).toString("utf-8");
|
|
36631
36903
|
const transformedContent = transformFileContent(textContent, claudeDir);
|
|
36632
|
-
await
|
|
36904
|
+
await import_fs_extra16.default.writeFile(targetPath, transformedContent, "utf-8");
|
|
36633
36905
|
} else {
|
|
36634
|
-
await
|
|
36906
|
+
await import_fs_extra16.default.writeFile(targetPath, Buffer.from(content));
|
|
36635
36907
|
}
|
|
36636
36908
|
return true;
|
|
36637
36909
|
} catch {
|
|
@@ -36647,27 +36919,27 @@ async function syncSelectedItems(claudeDir, items, githubToken, agentsDir, onPro
|
|
|
36647
36919
|
for (const item of items) {
|
|
36648
36920
|
const useAgents = isAgentCategory(item.category);
|
|
36649
36921
|
const baseDir = useAgents ? agentsDir : claudeDir;
|
|
36650
|
-
const targetPath =
|
|
36922
|
+
const targetPath = path20.join(baseDir, item.relativePath);
|
|
36651
36923
|
if (item.status === "migration" && useAgents) {
|
|
36652
36924
|
const topName = item.name.split("/")[0];
|
|
36653
|
-
const agentsTop =
|
|
36654
|
-
const claudeTop =
|
|
36925
|
+
const agentsTop = path20.join(agentsDir, item.category, topName);
|
|
36926
|
+
const claudeTop = path20.join(claudeDir, item.category, topName);
|
|
36655
36927
|
try {
|
|
36656
|
-
const claudeStat = await
|
|
36928
|
+
const claudeStat = await import_fs_extra16.default.lstat(claudeTop).catch(() => null);
|
|
36657
36929
|
if (!claudeStat || claudeStat.isSymbolicLink()) {
|
|
36658
36930
|
onProgress?.(item.relativePath, "skipping (no real dir to migrate)");
|
|
36659
36931
|
failed++;
|
|
36660
36932
|
continue;
|
|
36661
36933
|
}
|
|
36662
|
-
const agentsExists = await
|
|
36934
|
+
const agentsExists = await import_fs_extra16.default.pathExists(agentsTop);
|
|
36663
36935
|
if (agentsExists) {
|
|
36664
36936
|
onProgress?.(item.relativePath, "skipping (already in .agents)");
|
|
36665
36937
|
failed++;
|
|
36666
36938
|
continue;
|
|
36667
36939
|
}
|
|
36668
36940
|
onProgress?.(item.relativePath, "moving to .agents");
|
|
36669
|
-
await
|
|
36670
|
-
await
|
|
36941
|
+
await import_fs_extra16.default.ensureDir(path20.dirname(agentsTop));
|
|
36942
|
+
await import_fs_extra16.default.move(claudeTop, agentsTop);
|
|
36671
36943
|
migrated++;
|
|
36672
36944
|
touchedAgentCategories.add(item.category);
|
|
36673
36945
|
} catch {
|
|
@@ -36677,8 +36949,8 @@ async function syncSelectedItems(claudeDir, items, githubToken, agentsDir, onPro
|
|
|
36677
36949
|
}
|
|
36678
36950
|
if (useAgents) {
|
|
36679
36951
|
const topName = item.name.split("/")[0];
|
|
36680
|
-
const claudeTop =
|
|
36681
|
-
const claudeTopStat = await
|
|
36952
|
+
const claudeTop = path20.join(claudeDir, item.category, topName);
|
|
36953
|
+
const claudeTopStat = await import_fs_extra16.default.lstat(claudeTop).catch(() => null);
|
|
36682
36954
|
if (claudeTopStat && !claudeTopStat.isSymbolicLink()) {
|
|
36683
36955
|
onProgress?.(item.relativePath, "skipping (real dir in .claude)");
|
|
36684
36956
|
failed++;
|
|
@@ -36688,7 +36960,7 @@ async function syncSelectedItems(claudeDir, items, githubToken, agentsDir, onPro
|
|
|
36688
36960
|
if (item.status === "deleted") {
|
|
36689
36961
|
onProgress?.(item.relativePath, "deleting");
|
|
36690
36962
|
try {
|
|
36691
|
-
await
|
|
36963
|
+
await import_fs_extra16.default.remove(targetPath);
|
|
36692
36964
|
deleted++;
|
|
36693
36965
|
if (useAgents)
|
|
36694
36966
|
touchedAgentCategories.add(item.category);
|
|
@@ -37026,20 +37298,20 @@ async function proSyncCommand(options = {}) {
|
|
|
37026
37298
|
}
|
|
37027
37299
|
|
|
37028
37300
|
// src/lib/backup-utils.ts
|
|
37029
|
-
var
|
|
37030
|
-
import
|
|
37301
|
+
var import_fs_extra17 = __toESM(require_lib4(), 1);
|
|
37302
|
+
import path21 from "path";
|
|
37031
37303
|
import os16 from "os";
|
|
37032
|
-
var BACKUP_BASE_DIR =
|
|
37304
|
+
var BACKUP_BASE_DIR = path21.join(os16.homedir(), ".config", "aiblueprint", "backup");
|
|
37033
37305
|
function formatDate(date) {
|
|
37034
37306
|
const pad = (n) => n.toString().padStart(2, "0");
|
|
37035
37307
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}-${pad(date.getHours())}-${pad(date.getMinutes())}-${pad(date.getSeconds())}`;
|
|
37036
37308
|
}
|
|
37037
37309
|
async function listBackups() {
|
|
37038
|
-
const exists = await
|
|
37310
|
+
const exists = await import_fs_extra17.default.pathExists(BACKUP_BASE_DIR);
|
|
37039
37311
|
if (!exists) {
|
|
37040
37312
|
return [];
|
|
37041
37313
|
}
|
|
37042
|
-
const entries = await
|
|
37314
|
+
const entries = await import_fs_extra17.default.readdir(BACKUP_BASE_DIR, { withFileTypes: true });
|
|
37043
37315
|
const backups = [];
|
|
37044
37316
|
for (const entry of entries) {
|
|
37045
37317
|
if (!entry.isDirectory())
|
|
@@ -37051,7 +37323,7 @@ async function listBackups() {
|
|
|
37051
37323
|
const date = new Date(parseInt(year), parseInt(month) - 1, parseInt(day), parseInt(hour), parseInt(minute), parseInt(second));
|
|
37052
37324
|
backups.push({
|
|
37053
37325
|
name: entry.name,
|
|
37054
|
-
path:
|
|
37326
|
+
path: path21.join(BACKUP_BASE_DIR, entry.name),
|
|
37055
37327
|
date
|
|
37056
37328
|
});
|
|
37057
37329
|
}
|
|
@@ -37060,12 +37332,12 @@ async function listBackups() {
|
|
|
37060
37332
|
var AGENTS_BACKUP_SUBDIR = ".agents";
|
|
37061
37333
|
var CLAUDE_ITEMS = ["commands", "agents", "skills", "scripts", "settings.json"];
|
|
37062
37334
|
async function copyForBackup(sourcePath, destPath) {
|
|
37063
|
-
await
|
|
37335
|
+
await import_fs_extra17.default.copy(sourcePath, destPath, {
|
|
37064
37336
|
overwrite: true,
|
|
37065
37337
|
dereference: false,
|
|
37066
37338
|
filter: async (src) => {
|
|
37067
37339
|
try {
|
|
37068
|
-
const stat = await
|
|
37340
|
+
const stat = await import_fs_extra17.default.lstat(src);
|
|
37069
37341
|
return !stat.isSymbolicLink();
|
|
37070
37342
|
} catch {
|
|
37071
37343
|
return true;
|
|
@@ -37074,28 +37346,28 @@ async function copyForBackup(sourcePath, destPath) {
|
|
|
37074
37346
|
});
|
|
37075
37347
|
}
|
|
37076
37348
|
async function hasMeaningfulContent(dir) {
|
|
37077
|
-
if (!await
|
|
37349
|
+
if (!await import_fs_extra17.default.pathExists(dir))
|
|
37078
37350
|
return false;
|
|
37079
|
-
const files = await
|
|
37351
|
+
const files = await import_fs_extra17.default.readdir(dir);
|
|
37080
37352
|
return files.some((f) => f !== ".DS_Store");
|
|
37081
37353
|
}
|
|
37082
37354
|
async function loadBackup(backupPath, claudeDir, agentsDir) {
|
|
37083
|
-
const exists = await
|
|
37355
|
+
const exists = await import_fs_extra17.default.pathExists(backupPath);
|
|
37084
37356
|
if (!exists) {
|
|
37085
37357
|
throw new Error(`Backup not found: ${backupPath}`);
|
|
37086
37358
|
}
|
|
37087
|
-
await
|
|
37359
|
+
await import_fs_extra17.default.ensureDir(claudeDir);
|
|
37088
37360
|
for (const item of CLAUDE_ITEMS) {
|
|
37089
|
-
const sourcePath =
|
|
37090
|
-
const destPath =
|
|
37091
|
-
if (await
|
|
37361
|
+
const sourcePath = path21.join(backupPath, item);
|
|
37362
|
+
const destPath = path21.join(claudeDir, item);
|
|
37363
|
+
if (await import_fs_extra17.default.pathExists(sourcePath)) {
|
|
37092
37364
|
await copyForBackup(sourcePath, destPath);
|
|
37093
37365
|
}
|
|
37094
37366
|
}
|
|
37095
37367
|
if (agentsDir) {
|
|
37096
|
-
const agentsBackupPath =
|
|
37097
|
-
if (await
|
|
37098
|
-
await
|
|
37368
|
+
const agentsBackupPath = path21.join(backupPath, AGENTS_BACKUP_SUBDIR);
|
|
37369
|
+
if (await import_fs_extra17.default.pathExists(agentsBackupPath)) {
|
|
37370
|
+
await import_fs_extra17.default.ensureDir(agentsDir);
|
|
37099
37371
|
await copyForBackup(agentsBackupPath, agentsDir);
|
|
37100
37372
|
}
|
|
37101
37373
|
}
|
|
@@ -37107,19 +37379,19 @@ async function createBackup(claudeDir, agentsDir) {
|
|
|
37107
37379
|
return null;
|
|
37108
37380
|
}
|
|
37109
37381
|
const timestamp3 = formatDate(new Date);
|
|
37110
|
-
const backupPath =
|
|
37111
|
-
await
|
|
37382
|
+
const backupPath = path21.join(BACKUP_BASE_DIR, timestamp3);
|
|
37383
|
+
await import_fs_extra17.default.ensureDir(backupPath);
|
|
37112
37384
|
if (claudeHasContent) {
|
|
37113
37385
|
for (const item of CLAUDE_ITEMS) {
|
|
37114
|
-
const sourcePath =
|
|
37115
|
-
const destPath =
|
|
37116
|
-
if (await
|
|
37386
|
+
const sourcePath = path21.join(claudeDir, item);
|
|
37387
|
+
const destPath = path21.join(backupPath, item);
|
|
37388
|
+
if (await import_fs_extra17.default.pathExists(sourcePath)) {
|
|
37117
37389
|
await copyForBackup(sourcePath, destPath);
|
|
37118
37390
|
}
|
|
37119
37391
|
}
|
|
37120
37392
|
}
|
|
37121
37393
|
if (agentsHasContent && agentsDir) {
|
|
37122
|
-
const destPath =
|
|
37394
|
+
const destPath = path21.join(backupPath, AGENTS_BACKUP_SUBDIR);
|
|
37123
37395
|
await copyForBackup(agentsDir, destPath);
|
|
37124
37396
|
}
|
|
37125
37397
|
return backupPath;
|
|
@@ -37303,18 +37575,18 @@ async function configsBackupsCreateCommand(reason, options = {}) {
|
|
|
37303
37575
|
|
|
37304
37576
|
// src/commands/openclaw-pro.ts
|
|
37305
37577
|
import os19 from "os";
|
|
37306
|
-
import
|
|
37578
|
+
import path24 from "path";
|
|
37307
37579
|
|
|
37308
37580
|
// src/lib/openclaw-installer.ts
|
|
37309
|
-
var
|
|
37581
|
+
var import_fs_extra18 = __toESM(require_lib4(), 1);
|
|
37310
37582
|
import os17 from "os";
|
|
37311
|
-
import
|
|
37583
|
+
import path22 from "path";
|
|
37312
37584
|
import { exec as exec4 } from "child_process";
|
|
37313
37585
|
import { promisify as promisify3 } from "util";
|
|
37314
37586
|
var execAsync3 = promisify3(exec4);
|
|
37315
37587
|
var OPENCLAW_PRO_REPO = "Melvynx/openclawpro";
|
|
37316
37588
|
function getCacheRepoDir2() {
|
|
37317
|
-
return
|
|
37589
|
+
return path22.join(os17.homedir(), ".config", "openclaw", "pro-repos", "openclawpro");
|
|
37318
37590
|
}
|
|
37319
37591
|
async function execGitWithAuth2(command, token, repoUrl, cwd) {
|
|
37320
37592
|
const authenticatedUrl = `https://x-access-token:${token}@${repoUrl.replace(/^https?:\/\//, "")}`;
|
|
@@ -37328,33 +37600,33 @@ async function execGitWithAuth2(command, token, repoUrl, cwd) {
|
|
|
37328
37600
|
async function cloneOrUpdateRepo2(token) {
|
|
37329
37601
|
const cacheDir = getCacheRepoDir2();
|
|
37330
37602
|
const repoUrl = `https://github.com/${OPENCLAW_PRO_REPO}.git`;
|
|
37331
|
-
if (await
|
|
37603
|
+
if (await import_fs_extra18.default.pathExists(path22.join(cacheDir, ".git"))) {
|
|
37332
37604
|
try {
|
|
37333
37605
|
await execGitWithAuth2("pull", token, repoUrl, cacheDir);
|
|
37334
37606
|
} catch (error) {
|
|
37335
|
-
await
|
|
37336
|
-
await
|
|
37607
|
+
await import_fs_extra18.default.remove(cacheDir);
|
|
37608
|
+
await import_fs_extra18.default.ensureDir(path22.dirname(cacheDir));
|
|
37337
37609
|
await execGitWithAuth2(`clone ${repoUrl} ${cacheDir}`, token, repoUrl);
|
|
37338
37610
|
}
|
|
37339
37611
|
} else {
|
|
37340
|
-
await
|
|
37612
|
+
await import_fs_extra18.default.ensureDir(path22.dirname(cacheDir));
|
|
37341
37613
|
await execGitWithAuth2(`clone ${repoUrl} ${cacheDir}`, token, repoUrl);
|
|
37342
37614
|
}
|
|
37343
|
-
return
|
|
37615
|
+
return path22.join(cacheDir, "openclaw-config");
|
|
37344
37616
|
}
|
|
37345
37617
|
async function copyConfigFromCache2(cacheConfigDir, targetDir, onProgress) {
|
|
37346
37618
|
const walk = async (dir, baseDir = dir) => {
|
|
37347
|
-
const entries = await
|
|
37619
|
+
const entries = await import_fs_extra18.default.readdir(dir, { withFileTypes: true });
|
|
37348
37620
|
for (const entry of entries) {
|
|
37349
|
-
const sourcePath =
|
|
37350
|
-
const relativePath =
|
|
37351
|
-
const targetPath =
|
|
37621
|
+
const sourcePath = path22.join(dir, entry.name);
|
|
37622
|
+
const relativePath = path22.relative(baseDir, sourcePath);
|
|
37623
|
+
const targetPath = path22.join(targetDir, relativePath);
|
|
37352
37624
|
if (entry.isDirectory()) {
|
|
37353
|
-
await
|
|
37625
|
+
await import_fs_extra18.default.ensureDir(targetPath);
|
|
37354
37626
|
onProgress?.(relativePath, "directory");
|
|
37355
37627
|
await walk(sourcePath, baseDir);
|
|
37356
37628
|
} else {
|
|
37357
|
-
await
|
|
37629
|
+
await import_fs_extra18.default.copy(sourcePath, targetPath, { overwrite: true });
|
|
37358
37630
|
onProgress?.(relativePath, "file");
|
|
37359
37631
|
}
|
|
37360
37632
|
}
|
|
@@ -37363,7 +37635,7 @@ async function copyConfigFromCache2(cacheConfigDir, targetDir, onProgress) {
|
|
|
37363
37635
|
}
|
|
37364
37636
|
async function installOpenclawProConfigs(options) {
|
|
37365
37637
|
const { githubToken, openclawFolder, onProgress } = options;
|
|
37366
|
-
const targetFolder = openclawFolder ||
|
|
37638
|
+
const targetFolder = openclawFolder || path22.join(os17.homedir(), ".openclaw");
|
|
37367
37639
|
try {
|
|
37368
37640
|
const cacheConfigDir = await cloneOrUpdateRepo2(githubToken);
|
|
37369
37641
|
await copyConfigFromCache2(cacheConfigDir, targetFolder, onProgress);
|
|
@@ -37374,28 +37646,28 @@ async function installOpenclawProConfigs(options) {
|
|
|
37374
37646
|
}
|
|
37375
37647
|
|
|
37376
37648
|
// src/lib/openclaw-token-storage.ts
|
|
37377
|
-
var
|
|
37649
|
+
var import_fs_extra19 = __toESM(require_lib4(), 1);
|
|
37378
37650
|
import os18 from "os";
|
|
37379
|
-
import
|
|
37651
|
+
import path23 from "path";
|
|
37380
37652
|
function getConfigDir2() {
|
|
37381
37653
|
const platform = os18.platform();
|
|
37382
37654
|
if (platform === "win32") {
|
|
37383
|
-
return
|
|
37655
|
+
return path23.join(process.env.APPDATA || os18.homedir(), "openclaw");
|
|
37384
37656
|
}
|
|
37385
|
-
return
|
|
37657
|
+
return path23.join(os18.homedir(), ".config", "openclaw");
|
|
37386
37658
|
}
|
|
37387
37659
|
function getTokenPath() {
|
|
37388
|
-
return
|
|
37660
|
+
return path23.join(getConfigDir2(), "token.txt");
|
|
37389
37661
|
}
|
|
37390
37662
|
async function saveOpenclawToken(githubToken) {
|
|
37391
37663
|
const configDir = getConfigDir2();
|
|
37392
|
-
await
|
|
37393
|
-
await
|
|
37664
|
+
await import_fs_extra19.default.ensureDir(configDir);
|
|
37665
|
+
await import_fs_extra19.default.writeFile(getTokenPath(), githubToken, { mode: 384 });
|
|
37394
37666
|
}
|
|
37395
37667
|
async function getOpenclawToken() {
|
|
37396
37668
|
const tokenPath = getTokenPath();
|
|
37397
|
-
if (await
|
|
37398
|
-
const token = await
|
|
37669
|
+
if (await import_fs_extra19.default.pathExists(tokenPath)) {
|
|
37670
|
+
const token = await import_fs_extra19.default.readFile(tokenPath, "utf8");
|
|
37399
37671
|
return token.trim();
|
|
37400
37672
|
}
|
|
37401
37673
|
return null;
|
|
@@ -37408,7 +37680,7 @@ function getOpenclawTokenInfo() {
|
|
|
37408
37680
|
}
|
|
37409
37681
|
|
|
37410
37682
|
// src/commands/openclaw-pro.ts
|
|
37411
|
-
var
|
|
37683
|
+
var import_fs_extra20 = __toESM(require_lib4(), 1);
|
|
37412
37684
|
var API_URL2 = "https://codeline.app/api/products";
|
|
37413
37685
|
var OPENCLAW_PRODUCT_ID = "prd_t2GRwX3aH1";
|
|
37414
37686
|
var CLAUDE_CODE_TOOLS_INSTRUCTIONS = `
|
|
@@ -37515,7 +37787,7 @@ async function openclawProSetupCommand(options = {}) {
|
|
|
37515
37787
|
Se(source_default.red("❌ Not activated"));
|
|
37516
37788
|
process.exit(1);
|
|
37517
37789
|
}
|
|
37518
|
-
const openclawDir = options.folder ?
|
|
37790
|
+
const openclawDir = options.folder ? path24.resolve(options.folder) : path24.join(os19.homedir(), ".openclaw");
|
|
37519
37791
|
const spinner = Y2();
|
|
37520
37792
|
const onProgress = (file, type) => {
|
|
37521
37793
|
spinner.message(`Installing: ${source_default.cyan(file)} ${source_default.gray(`(${type})`)}`);
|
|
@@ -37528,23 +37800,23 @@ async function openclawProSetupCommand(options = {}) {
|
|
|
37528
37800
|
});
|
|
37529
37801
|
spinner.stop("OpenClaw Pro configurations installed");
|
|
37530
37802
|
let skillCount = 0;
|
|
37531
|
-
const skillsDir =
|
|
37532
|
-
if (await
|
|
37533
|
-
const items = await
|
|
37803
|
+
const skillsDir = path24.join(openclawDir, "skills");
|
|
37804
|
+
if (await import_fs_extra20.default.pathExists(skillsDir)) {
|
|
37805
|
+
const items = await import_fs_extra20.default.readdir(skillsDir);
|
|
37534
37806
|
const dirs = await Promise.all(items.map(async (item) => {
|
|
37535
|
-
const stat = await
|
|
37807
|
+
const stat = await import_fs_extra20.default.stat(path24.join(skillsDir, item));
|
|
37536
37808
|
return stat.isDirectory();
|
|
37537
37809
|
}));
|
|
37538
37810
|
skillCount = dirs.filter(Boolean).length;
|
|
37539
37811
|
}
|
|
37540
37812
|
spinner.start("Setting up workspace TOOLS.md...");
|
|
37541
|
-
const workspaceDir =
|
|
37542
|
-
const toolsPath =
|
|
37543
|
-
await
|
|
37544
|
-
if (await
|
|
37545
|
-
const existingContent = await
|
|
37813
|
+
const workspaceDir = path24.join(openclawDir, "workspace");
|
|
37814
|
+
const toolsPath = path24.join(workspaceDir, "TOOLS.md");
|
|
37815
|
+
await import_fs_extra20.default.ensureDir(workspaceDir);
|
|
37816
|
+
if (await import_fs_extra20.default.pathExists(toolsPath)) {
|
|
37817
|
+
const existingContent = await import_fs_extra20.default.readFile(toolsPath, "utf-8");
|
|
37546
37818
|
if (!existingContent.includes("Claude Code CLI")) {
|
|
37547
|
-
await
|
|
37819
|
+
await import_fs_extra20.default.appendFile(toolsPath, `
|
|
37548
37820
|
|
|
37549
37821
|
` + CLAUDE_CODE_TOOLS_INSTRUCTIONS);
|
|
37550
37822
|
spinner.stop("TOOLS.md updated with Claude Code instructions");
|
|
@@ -37558,7 +37830,7 @@ Skills define _how_ tools work. This file is for _your_ specifics — the stuff
|
|
|
37558
37830
|
|
|
37559
37831
|
${CLAUDE_CODE_TOOLS_INSTRUCTIONS}
|
|
37560
37832
|
`;
|
|
37561
|
-
await
|
|
37833
|
+
await import_fs_extra20.default.writeFile(toolsPath, defaultToolsMd);
|
|
37562
37834
|
spinner.stop("TOOLS.md created with Claude Code instructions");
|
|
37563
37835
|
}
|
|
37564
37836
|
spinner.start("Creating claude-run wrapper...");
|
|
@@ -37569,9 +37841,9 @@ ${CLAUDE_CODE_TOOLS_INSTRUCTIONS}
|
|
|
37569
37841
|
script -q -c "claude $*" /dev/null
|
|
37570
37842
|
`;
|
|
37571
37843
|
const binDir = "/usr/local/bin";
|
|
37572
|
-
const wrapperPath =
|
|
37844
|
+
const wrapperPath = path24.join(binDir, "claude-run");
|
|
37573
37845
|
try {
|
|
37574
|
-
await
|
|
37846
|
+
await import_fs_extra20.default.writeFile(wrapperPath, claudeRunWrapper, { mode: 493 });
|
|
37575
37847
|
spinner.stop("claude-run wrapper created");
|
|
37576
37848
|
} catch {
|
|
37577
37849
|
spinner.stop("claude-run wrapper skipped (no write access to /usr/local/bin)");
|
|
@@ -37620,12 +37892,12 @@ async function openclawProUpdateCommand(options = {}) {
|
|
|
37620
37892
|
}
|
|
37621
37893
|
|
|
37622
37894
|
// src/commands/dynamic-scripts.ts
|
|
37623
|
-
import
|
|
37895
|
+
import path27 from "path";
|
|
37624
37896
|
import { homedir } from "os";
|
|
37625
37897
|
|
|
37626
37898
|
// src/lib/script-parser.ts
|
|
37627
|
-
var
|
|
37628
|
-
import
|
|
37899
|
+
var import_fs_extra21 = __toESM(require_lib4(), 1);
|
|
37900
|
+
import path25 from "path";
|
|
37629
37901
|
var EXCLUDED_SCRIPTS = ["test", "lint", "format", "start"];
|
|
37630
37902
|
var EXCLUDED_SUFFIXES = [":test", ":lint", ":test-fixtures", ":start"];
|
|
37631
37903
|
function shouldIncludeScript(scriptName) {
|
|
@@ -37636,12 +37908,12 @@ function shouldIncludeScript(scriptName) {
|
|
|
37636
37908
|
return true;
|
|
37637
37909
|
}
|
|
37638
37910
|
async function readScriptsPackageJson(claudeDir) {
|
|
37639
|
-
const packageJsonPath =
|
|
37911
|
+
const packageJsonPath = path25.join(claudeDir, "scripts", "package.json");
|
|
37640
37912
|
try {
|
|
37641
|
-
if (!await
|
|
37913
|
+
if (!await import_fs_extra21.default.pathExists(packageJsonPath)) {
|
|
37642
37914
|
return null;
|
|
37643
37915
|
}
|
|
37644
|
-
const content = await
|
|
37916
|
+
const content = await import_fs_extra21.default.readFile(packageJsonPath, "utf-8");
|
|
37645
37917
|
const parsed = JSON.parse(content);
|
|
37646
37918
|
return parsed.scripts || null;
|
|
37647
37919
|
} catch (error) {
|
|
@@ -37685,10 +37957,10 @@ function groupScriptsByPrefix(commands) {
|
|
|
37685
37957
|
}
|
|
37686
37958
|
|
|
37687
37959
|
// src/commands/script-runner.ts
|
|
37688
|
-
var
|
|
37960
|
+
var import_fs_extra22 = __toESM(require_lib4(), 1);
|
|
37689
37961
|
import { spawn as spawn2 } from "child_process";
|
|
37690
37962
|
import { execSync as execSync4 } from "child_process";
|
|
37691
|
-
import
|
|
37963
|
+
import path26 from "path";
|
|
37692
37964
|
import os20 from "os";
|
|
37693
37965
|
function checkCommand2(cmd) {
|
|
37694
37966
|
try {
|
|
@@ -37718,18 +37990,18 @@ async function executeScript(scriptName, claudeDir) {
|
|
|
37718
37990
|
console.error(source_default.red("Bun is not installed. Install with: npm install -g bun"));
|
|
37719
37991
|
return 1;
|
|
37720
37992
|
}
|
|
37721
|
-
const scriptsDir =
|
|
37722
|
-
if (!await
|
|
37993
|
+
const scriptsDir = path26.join(claudeDir, "scripts");
|
|
37994
|
+
if (!await import_fs_extra22.default.pathExists(scriptsDir)) {
|
|
37723
37995
|
console.error(source_default.red(`Scripts directory not found at ${scriptsDir}`));
|
|
37724
37996
|
console.log(source_default.gray("Run: aiblueprint agents setup"));
|
|
37725
37997
|
return 1;
|
|
37726
37998
|
}
|
|
37727
|
-
const packageJsonPath =
|
|
37728
|
-
if (!await
|
|
37999
|
+
const packageJsonPath = path26.join(scriptsDir, "package.json");
|
|
38000
|
+
if (!await import_fs_extra22.default.pathExists(packageJsonPath)) {
|
|
37729
38001
|
console.error(source_default.red(`package.json not found in ${scriptsDir}`));
|
|
37730
38002
|
return 1;
|
|
37731
38003
|
}
|
|
37732
|
-
const packageJson = await
|
|
38004
|
+
const packageJson = await import_fs_extra22.default.readJson(packageJsonPath);
|
|
37733
38005
|
if (!packageJson.scripts || !packageJson.scripts[scriptName]) {
|
|
37734
38006
|
console.error(source_default.red(`Script "${scriptName}" not found in package.json`));
|
|
37735
38007
|
return 1;
|
|
@@ -37752,7 +38024,7 @@ async function executeScript(scriptName, claudeDir) {
|
|
|
37752
38024
|
|
|
37753
38025
|
// src/commands/dynamic-scripts.ts
|
|
37754
38026
|
function getClaudeDir(parentOptions) {
|
|
37755
|
-
return parentOptions.claudeCodeFolder || parentOptions.folder ?
|
|
38027
|
+
return parentOptions.claudeCodeFolder || parentOptions.folder ? path27.resolve(parentOptions.claudeCodeFolder || parentOptions.folder) : path27.join(homedir(), ".claude");
|
|
37756
38028
|
}
|
|
37757
38029
|
async function registerDynamicScriptCommands(claudeCodeCmd, claudeDir) {
|
|
37758
38030
|
const scripts = await readScriptsPackageJson(claudeDir);
|
|
@@ -37814,7 +38086,7 @@ function registerAgentsCommands(cmd) {
|
|
|
37814
38086
|
codexFolder: parentOptions.codexFolder
|
|
37815
38087
|
});
|
|
37816
38088
|
});
|
|
37817
|
-
cmd.command("unify").description("Unify skills and agents into .agents
|
|
38089
|
+
cmd.command("unify").description("Unify skills and agents into .agents, then render Codex TOML agents").action((options, command) => {
|
|
37818
38090
|
const parentOptions = command.parent.opts();
|
|
37819
38091
|
return agentsUnifyCommand({
|
|
37820
38092
|
folder: parentOptions.folder,
|
|
@@ -37823,6 +38095,16 @@ function registerAgentsCommands(cmd) {
|
|
|
37823
38095
|
agentsFolder: parentOptions.agentsFolder
|
|
37824
38096
|
});
|
|
37825
38097
|
});
|
|
38098
|
+
cmd.command("codex-agents").description("Render shared Markdown agents from .agents/agents into Codex TOML custom agents").option("--overwrite", "Overwrite existing non-generated Codex agent files").action((options, command) => {
|
|
38099
|
+
const parentOptions = command.parent.opts();
|
|
38100
|
+
return codexAgentsCommand({
|
|
38101
|
+
folder: parentOptions.folder,
|
|
38102
|
+
claudeCodeFolder: parentOptions.claudeCodeFolder,
|
|
38103
|
+
codexFolder: parentOptions.codexFolder,
|
|
38104
|
+
agentsFolder: parentOptions.agentsFolder,
|
|
38105
|
+
overwrite: options.overwrite
|
|
38106
|
+
});
|
|
38107
|
+
});
|
|
37826
38108
|
const proCmd = cmd.command("pro").description("Manage AIBlueprint CLI Premium features");
|
|
37827
38109
|
proCmd.command("activate [token]").description("Activate AIBlueprint CLI Premium with your access token").action((token) => {
|
|
37828
38110
|
proActivateCommand(token);
|