@ariestools/toolchain 8.7.28 → 8.7.29
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 +27 -0
- package/dist/actions/repo-init/index.d.ts +7 -0
- package/dist/actions/repo-init/index.d.ts.map +1 -0
- package/dist/actions/repo-init/prompts.d.ts +4 -0
- package/dist/actions/repo-init/prompts.d.ts.map +1 -0
- package/dist/actions/repo-init/resolvePlan.d.ts +7 -0
- package/dist/actions/repo-init/resolvePlan.d.ts.map +1 -0
- package/dist/actions/repo-init/scaffold.d.ts +10 -0
- package/dist/actions/repo-init/scaffold.d.ts.map +1 -0
- package/dist/actions/repo-init/skillsInstall.d.ts +12 -0
- package/dist/actions/repo-init/skillsInstall.d.ts.map +1 -0
- package/dist/actions/repo-init/templateVars.d.ts +5 -0
- package/dist/actions/repo-init/templateVars.d.ts.map +1 -0
- package/dist/actions/repo-init/types.d.ts +40 -0
- package/dist/actions/repo-init/types.d.ts.map +1 -0
- package/dist/actions/repo-init.d.ts +1 -13
- package/dist/actions/repo-init.d.ts.map +1 -1
- package/dist/actions/skills/passthrough.d.ts +4 -0
- package/dist/actions/skills/passthrough.d.ts.map +1 -1
- package/dist/bin/xy.mjs +719 -343
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/xy/common/repo/initCommand.d.ts.map +1 -1
- package/package.json +8 -8
- package/templates/repo/cli/package/package.json.tmpl +5 -5
- package/templates/repo/cli/package/tsconfig.json.tmpl +4 -0
- package/templates/repo/cli/root/AGENTS.md.tmpl +34 -0
- package/templates/repo/cli/root/CLAUDE.md.tmpl +15 -15
- package/templates/repo/cli/root/eslint.config.ts.tmpl +16 -0
- package/templates/repo/cli/root/gitignore.tmpl +6 -9
- package/templates/repo/cli/root/package.json.tmpl +16 -14
- package/templates/repo/cli/root/tsconfig.json.tmpl +4 -0
- package/templates/repo/cli/root/{vitest.config.ts → vitest.config.ts.tmpl} +2 -2
- package/templates/repo/cli/package/tsconfig.json +0 -4
- package/templates/repo/cli/root/eslint.config.ts +0 -20
- package/templates/repo/cli/root/tsconfig.json +0 -4
package/dist/bin/xy.mjs
CHANGED
|
@@ -19106,6 +19106,9 @@ function collectFiles$1(dir, prefix) {
|
|
|
19106
19106
|
function loadRepoTemplateFiles(template, section) {
|
|
19107
19107
|
return collectFiles$1(PATH.resolve(repoTemplatesDir, template, section), "");
|
|
19108
19108
|
}
|
|
19109
|
+
function listRepoTemplates() {
|
|
19110
|
+
return readdirSync(repoTemplatesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
19111
|
+
}
|
|
19109
19112
|
//#endregion
|
|
19110
19113
|
//#region src/lib/runSteps.ts
|
|
19111
19114
|
const packageManagers$1 = /* @__PURE__ */ new Set([
|
|
@@ -20077,13 +20080,13 @@ async function fetchAllRegistryInfo(packageNames, options = {}) {
|
|
|
20077
20080
|
return await fetchAllRegistryInfoDirect(packageNames, options);
|
|
20078
20081
|
}
|
|
20079
20082
|
//#endregion
|
|
20080
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20083
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/key.js
|
|
20081
20084
|
const isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
|
|
20082
20085
|
const isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
|
|
20083
20086
|
const isSpaceKey = (key) => key.name === "space";
|
|
20084
20087
|
const isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
20085
20088
|
//#endregion
|
|
20086
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20089
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/errors.js
|
|
20087
20090
|
var AbortPromptError = class extends Error {
|
|
20088
20091
|
name = "AbortPromptError";
|
|
20089
20092
|
message = "Prompt was aborted";
|
|
@@ -20106,7 +20109,7 @@ var ValidationError = class extends Error {
|
|
|
20106
20109
|
name = "ValidationError";
|
|
20107
20110
|
};
|
|
20108
20111
|
//#endregion
|
|
20109
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20112
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/hook-engine.js
|
|
20110
20113
|
const hookStorage = new AsyncLocalStorage();
|
|
20111
20114
|
function createStore(rl) {
|
|
20112
20115
|
return {
|
|
@@ -20202,7 +20205,7 @@ const effectScheduler = {
|
|
|
20202
20205
|
}
|
|
20203
20206
|
};
|
|
20204
20207
|
//#endregion
|
|
20205
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20208
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
20206
20209
|
function isFactory(value) {
|
|
20207
20210
|
return typeof value === "function";
|
|
20208
20211
|
}
|
|
@@ -20221,7 +20224,7 @@ function useState(defaultValue) {
|
|
|
20221
20224
|
});
|
|
20222
20225
|
}
|
|
20223
20226
|
//#endregion
|
|
20224
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20227
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-effect.js
|
|
20225
20228
|
function useEffect(cb, depArray) {
|
|
20226
20229
|
withPointer((pointer) => {
|
|
20227
20230
|
const oldDeps = pointer.get();
|
|
@@ -20230,12 +20233,12 @@ function useEffect(cb, depArray) {
|
|
|
20230
20233
|
});
|
|
20231
20234
|
}
|
|
20232
20235
|
//#endregion
|
|
20233
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20236
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-ref.js
|
|
20234
20237
|
function useRef(val) {
|
|
20235
20238
|
return useState({ current: val })[0];
|
|
20236
20239
|
}
|
|
20237
20240
|
//#endregion
|
|
20238
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20241
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-keypress.js
|
|
20239
20242
|
function useKeypress(userHandler) {
|
|
20240
20243
|
const signal = useRef(userHandler);
|
|
20241
20244
|
signal.current = userHandler;
|
|
@@ -20563,7 +20566,7 @@ function wrapAnsi$1(string, columns, options) {
|
|
|
20563
20566
|
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec$1(line, columns, options)).join("\n");
|
|
20564
20567
|
}
|
|
20565
20568
|
//#endregion
|
|
20566
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20569
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/utils.js
|
|
20567
20570
|
var import_cli_width = /* @__PURE__ */ __toESM(require_cli_width(), 1);
|
|
20568
20571
|
/**
|
|
20569
20572
|
* Force line returns at specific width. This function is ANSI code friendly and it'll
|
|
@@ -20903,7 +20906,7 @@ const eraseLine = "\x1B[2K";
|
|
|
20903
20906
|
/** Erase the specified number of lines above the cursor */
|
|
20904
20907
|
const eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + "\x1B[2K\x1B[G" : "";
|
|
20905
20908
|
//#endregion
|
|
20906
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20909
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
20907
20910
|
const height = (content) => content.split("\n").length;
|
|
20908
20911
|
const lastLine = (content) => content.split("\n").pop() ?? "";
|
|
20909
20912
|
var ScreenManager = class {
|
|
@@ -20960,7 +20963,7 @@ var ScreenManager = class {
|
|
|
20960
20963
|
}
|
|
20961
20964
|
};
|
|
20962
20965
|
//#endregion
|
|
20963
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20966
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
20964
20967
|
var PromisePolyfill = class extends Promise {
|
|
20965
20968
|
static withResolver() {
|
|
20966
20969
|
let resolve;
|
|
@@ -20976,7 +20979,7 @@ var PromisePolyfill = class extends Promise {
|
|
|
20976
20979
|
}
|
|
20977
20980
|
};
|
|
20978
20981
|
//#endregion
|
|
20979
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20982
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
20980
20983
|
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
20981
20984
|
const nativeSetImmediate = globalThis.setImmediate;
|
|
20982
20985
|
function getCallSites() {
|
|
@@ -40712,7 +40715,7 @@ function addGitignoreConfig(source) {
|
|
|
40712
40715
|
}
|
|
40713
40716
|
//#endregion
|
|
40714
40717
|
//#region src/actions/lint-init.ts
|
|
40715
|
-
function askConfirmation(question) {
|
|
40718
|
+
function askConfirmation$1(question) {
|
|
40716
40719
|
const rl = createInterface({
|
|
40717
40720
|
input: process.stdin,
|
|
40718
40721
|
output: process.stdout
|
|
@@ -40858,7 +40861,7 @@ async function lintInit({ isVerbose } = {}) {
|
|
|
40858
40861
|
const existingPath = findExistingConfig(configPath, legacyConfigPath);
|
|
40859
40862
|
if (existingPath !== void 0) {
|
|
40860
40863
|
const filename = PATH.basename(existingPath);
|
|
40861
|
-
if (!await askConfirmation(chalk.yellow(`${filename} already exists. Replace it with eslint.config.ts? (y/N) `))) {
|
|
40864
|
+
if (!await askConfirmation$1(chalk.yellow(`${filename} already exists. Replace it with eslint.config.ts? (y/N) `))) {
|
|
40862
40865
|
console.log(chalk.gray(`Skipped — existing ${filename} preserved`));
|
|
40863
40866
|
return 0;
|
|
40864
40867
|
}
|
|
@@ -40867,7 +40870,7 @@ async function lintInit({ isVerbose } = {}) {
|
|
|
40867
40870
|
if (isReact) console.log(chalk.cyan("Detected React packages — using @ariestools/eslint-config-react-flat"));
|
|
40868
40871
|
else if (isVerbose === true) console.log(chalk.gray(" No React packages detected — using @ariestools/eslint-config-flat"));
|
|
40869
40872
|
const enabledBarrels = [];
|
|
40870
|
-
for (const descriptor of getBarrelDescriptorsForRepo(isReact)) if (await askConfirmation(chalk.cyan(`Disallow ${descriptor.pkg} barrel imports? (y/N) `))) enabledBarrels.push(descriptor);
|
|
40873
|
+
for (const descriptor of getBarrelDescriptorsForRepo(isReact)) if (await askConfirmation$1(chalk.cyan(`Disallow ${descriptor.pkg} barrel imports? (y/N) `))) enabledBarrels.push(descriptor);
|
|
40871
40874
|
const config = generateEslintConfig({
|
|
40872
40875
|
barrels: resolveEnabledBarrels(cwd, enabledBarrels, isVerbose),
|
|
40873
40876
|
hasGitignore: existsSync(PATH.resolve(cwd, ".gitignore")),
|
|
@@ -43398,7 +43401,7 @@ const relintAllPackages = ({ fix = false } = {}) => {
|
|
|
43398
43401
|
return runSteps(`${fix ? "Fix" : "Lint"} [All-Packages]`, [["eslint", fix ? ["--fix"] : []]]);
|
|
43399
43402
|
};
|
|
43400
43403
|
//#endregion
|
|
43401
|
-
//#region src/actions/repo-init.ts
|
|
43404
|
+
//#region src/actions/repo-init/prompts.ts
|
|
43402
43405
|
function askQuestion(question) {
|
|
43403
43406
|
const rl = createInterface({
|
|
43404
43407
|
input: process.stdin,
|
|
@@ -43411,6 +43414,262 @@ function askQuestion(question) {
|
|
|
43411
43414
|
});
|
|
43412
43415
|
});
|
|
43413
43416
|
}
|
|
43417
|
+
async function askConfirmation(question, defaultYes = false) {
|
|
43418
|
+
const hint = defaultYes ? "Y/n" : "y/N";
|
|
43419
|
+
const answer = await askQuestion(chalk.cyan(`${question} (${hint}) `));
|
|
43420
|
+
if (answer.length === 0) return defaultYes;
|
|
43421
|
+
return answer.toLowerCase() === "y" || answer.toLowerCase() === "yes";
|
|
43422
|
+
}
|
|
43423
|
+
async function askChoice(question, choices, defaultChoice) {
|
|
43424
|
+
const labels = choices.map((choice) => {
|
|
43425
|
+
return choice === defaultChoice ? chalk.bold(choice) : choice;
|
|
43426
|
+
}).join("/");
|
|
43427
|
+
const answer = await askQuestion(chalk.cyan(`${question} [${labels}]: `));
|
|
43428
|
+
if (answer.length === 0) return defaultChoice;
|
|
43429
|
+
const match = choices.find((choice) => choice.toLowerCase() === answer.toLowerCase());
|
|
43430
|
+
if (match === void 0) {
|
|
43431
|
+
console.warn(chalk.yellow(`Unknown choice "${answer}", using ${defaultChoice}`));
|
|
43432
|
+
return defaultChoice;
|
|
43433
|
+
}
|
|
43434
|
+
return match;
|
|
43435
|
+
}
|
|
43436
|
+
//#endregion
|
|
43437
|
+
//#region src/actions/repo-init/resolvePlan.ts
|
|
43438
|
+
const PMS = [
|
|
43439
|
+
"pnpm",
|
|
43440
|
+
"yarn",
|
|
43441
|
+
"npm",
|
|
43442
|
+
"bun"
|
|
43443
|
+
];
|
|
43444
|
+
const TIERS = [
|
|
43445
|
+
"none",
|
|
43446
|
+
"xy",
|
|
43447
|
+
"xyo",
|
|
43448
|
+
"xl1"
|
|
43449
|
+
];
|
|
43450
|
+
function isPackageManagerName(value) {
|
|
43451
|
+
return PMS.includes(value);
|
|
43452
|
+
}
|
|
43453
|
+
function isSkillTier(value) {
|
|
43454
|
+
return TIERS.includes(value);
|
|
43455
|
+
}
|
|
43456
|
+
function printSummary(plan) {
|
|
43457
|
+
console.log("");
|
|
43458
|
+
console.log(chalk.bold("Scaffold plan"));
|
|
43459
|
+
console.log(chalk.gray(` name: ${plan.name}`));
|
|
43460
|
+
console.log(chalk.gray(` template: ${plan.template}`));
|
|
43461
|
+
console.log(chalk.gray(` package: ${plan.packageName}`));
|
|
43462
|
+
console.log(chalk.gray(` scope: ${plan.scope || "(none)"}`));
|
|
43463
|
+
console.log(chalk.gray(` pm: ${plan.pm}`));
|
|
43464
|
+
console.log(chalk.gray(` monorepo: ${String(plan.monorepo)}`));
|
|
43465
|
+
console.log(chalk.gray(` react: ${String(plan.react)}`));
|
|
43466
|
+
console.log(chalk.gray(` skills: ${plan.skillsTier}${plan.skillsOptional ? " (+optional)" : ""}`));
|
|
43467
|
+
console.log("");
|
|
43468
|
+
}
|
|
43469
|
+
function reassignUnknownTemplateAsName(templates, template, name) {
|
|
43470
|
+
if (template != null && template.length > 0 && !templates.includes(template) && (name == null || name.length === 0)) return {
|
|
43471
|
+
name: template,
|
|
43472
|
+
template: void 0
|
|
43473
|
+
};
|
|
43474
|
+
return {
|
|
43475
|
+
name,
|
|
43476
|
+
template
|
|
43477
|
+
};
|
|
43478
|
+
}
|
|
43479
|
+
async function resolveTemplateName(templates, template, wizard, useDefaults) {
|
|
43480
|
+
if (template != null && template.length > 0) return template;
|
|
43481
|
+
if (useDefaults) return templates.includes("cli") ? "cli" : templates[0];
|
|
43482
|
+
if (wizard) return askChoice("Template", templates, templates.includes("cli") ? "cli" : templates[0]);
|
|
43483
|
+
return "cli";
|
|
43484
|
+
}
|
|
43485
|
+
async function resolveProjectName(name, useDefaults) {
|
|
43486
|
+
if (name != null && name.length > 0) return name;
|
|
43487
|
+
if (useDefaults) {
|
|
43488
|
+
console.error(chalk.red("Project name is required (pass a name or omit --yes)"));
|
|
43489
|
+
return;
|
|
43490
|
+
}
|
|
43491
|
+
const answer = await askQuestion(chalk.cyan("Project name: "));
|
|
43492
|
+
if (!answer) {
|
|
43493
|
+
console.error(chalk.red("Project name is required"));
|
|
43494
|
+
return;
|
|
43495
|
+
}
|
|
43496
|
+
return answer;
|
|
43497
|
+
}
|
|
43498
|
+
async function resolveWizardBoolean(provided, question, defaultYes, wizard, useDefaults) {
|
|
43499
|
+
if (provided !== void 0) return provided;
|
|
43500
|
+
if (!wizard || useDefaults) return defaultYes;
|
|
43501
|
+
return askConfirmation(question, defaultYes);
|
|
43502
|
+
}
|
|
43503
|
+
async function resolvePackageManager(provided, wizard, useDefaults) {
|
|
43504
|
+
if (provided !== void 0) return provided;
|
|
43505
|
+
if (!wizard || useDefaults) return "pnpm";
|
|
43506
|
+
return askChoice("Package manager", PMS, "pnpm");
|
|
43507
|
+
}
|
|
43508
|
+
async function resolveScope(provided, wizard, useDefaults) {
|
|
43509
|
+
const fallback = provided ?? "@xylabs";
|
|
43510
|
+
if (provided !== void 0 || !wizard || useDefaults) return fallback;
|
|
43511
|
+
const answer = await askQuestion(chalk.cyan(`npm scope [${fallback}]: `));
|
|
43512
|
+
return answer.length > 0 ? answer : fallback;
|
|
43513
|
+
}
|
|
43514
|
+
async function resolveDescription(provided, wizard, useDefaults) {
|
|
43515
|
+
if (useDefaults || !wizard || provided != null && provided.length > 0) return provided ?? "";
|
|
43516
|
+
return askQuestion(chalk.cyan("Description (optional): "));
|
|
43517
|
+
}
|
|
43518
|
+
async function resolveSkillsTier(provided, wizard, useDefaults) {
|
|
43519
|
+
if (provided !== void 0) {
|
|
43520
|
+
if (!isSkillTier(provided)) {
|
|
43521
|
+
console.error(chalk.red(`Invalid skills tier "${provided}"`));
|
|
43522
|
+
return;
|
|
43523
|
+
}
|
|
43524
|
+
return provided;
|
|
43525
|
+
}
|
|
43526
|
+
if (!wizard || useDefaults) return wizard ? "xy" : "none";
|
|
43527
|
+
return askChoice("Skills tier (agent skills to install)", TIERS, "xy");
|
|
43528
|
+
}
|
|
43529
|
+
async function resolveSkillsOptional(provided, skillsTier, wizard, useDefaults) {
|
|
43530
|
+
if (provided !== void 0) return provided;
|
|
43531
|
+
if (skillsTier !== "xl1" || !wizard || useDefaults) return false;
|
|
43532
|
+
return askConfirmation("Install optional XL1 skills (xl1-scaffold, xl1-build)?", true);
|
|
43533
|
+
}
|
|
43534
|
+
async function resolveCore(params, templates, useDefaults) {
|
|
43535
|
+
const reassigned = reassignUnknownTemplateAsName(templates, params.template, params.name);
|
|
43536
|
+
const wizard = reassigned.template == null || reassigned.template.length === 0;
|
|
43537
|
+
const template = await resolveTemplateName(templates, reassigned.template, wizard, useDefaults);
|
|
43538
|
+
if (template === void 0 || !templates.includes(template)) {
|
|
43539
|
+
console.error(chalk.red(`Unknown template "${template ?? ""}". Available: ${templates.join(", ")}`));
|
|
43540
|
+
return;
|
|
43541
|
+
}
|
|
43542
|
+
const name = await resolveProjectName(reassigned.name, useDefaults);
|
|
43543
|
+
if (name === void 0) return void 0;
|
|
43544
|
+
return {
|
|
43545
|
+
name,
|
|
43546
|
+
template,
|
|
43547
|
+
wizard
|
|
43548
|
+
};
|
|
43549
|
+
}
|
|
43550
|
+
async function resolvePlanOptions(params, wizard, useDefaults) {
|
|
43551
|
+
const pm = await resolvePackageManager(params.pm, wizard, useDefaults);
|
|
43552
|
+
if (!isPackageManagerName(pm)) {
|
|
43553
|
+
console.error(chalk.red(`Invalid package manager "${pm}"`));
|
|
43554
|
+
return;
|
|
43555
|
+
}
|
|
43556
|
+
const monorepo = await resolveWizardBoolean(params.monorepo, "Monorepo (packages/* workspaces)?", true, wizard, useDefaults);
|
|
43557
|
+
const react = await resolveWizardBoolean(params.react, "React project (eslint-config-react-flat + tsconfig-react)?", false, wizard, useDefaults);
|
|
43558
|
+
const scope = await resolveScope(params.scope, wizard, useDefaults);
|
|
43559
|
+
const description = await resolveDescription(params.description, wizard, useDefaults);
|
|
43560
|
+
const skillsTier = await resolveSkillsTier(params.skillsTier, wizard, useDefaults);
|
|
43561
|
+
if (skillsTier === void 0) return void 0;
|
|
43562
|
+
return {
|
|
43563
|
+
description,
|
|
43564
|
+
monorepo,
|
|
43565
|
+
pm,
|
|
43566
|
+
react,
|
|
43567
|
+
scope,
|
|
43568
|
+
skillsOptional: await resolveSkillsOptional(params.skillsOptional, skillsTier, wizard, useDefaults),
|
|
43569
|
+
skillsTier
|
|
43570
|
+
};
|
|
43571
|
+
}
|
|
43572
|
+
function buildPlan(params, core, options) {
|
|
43573
|
+
const projectName = PATH.basename(core.name);
|
|
43574
|
+
return {
|
|
43575
|
+
description: options.description,
|
|
43576
|
+
githubOrg: params.githubOrg ?? (options.scope.replace(/^@/, "") || projectName),
|
|
43577
|
+
isVerbose: params.isVerbose ?? false,
|
|
43578
|
+
monorepo: options.monorepo,
|
|
43579
|
+
name: core.name,
|
|
43580
|
+
packageName: params.packageName ?? projectName,
|
|
43581
|
+
pm: options.pm,
|
|
43582
|
+
projectName,
|
|
43583
|
+
react: options.react,
|
|
43584
|
+
scope: options.scope,
|
|
43585
|
+
skillsOptional: options.skillsOptional,
|
|
43586
|
+
skillsTier: options.skillsTier,
|
|
43587
|
+
skipGit: params.skipGit ?? false,
|
|
43588
|
+
skipInstall: params.skipInstall ?? false,
|
|
43589
|
+
template: core.template
|
|
43590
|
+
};
|
|
43591
|
+
}
|
|
43592
|
+
/**
|
|
43593
|
+
* When template is provided, fill only missing fields (legacy non-wizard path).
|
|
43594
|
+
* When template is omitted, run the interactive wizard (unless --yes supplies defaults).
|
|
43595
|
+
*/
|
|
43596
|
+
async function resolveRepoInitPlan(params) {
|
|
43597
|
+
const templates = listRepoTemplates();
|
|
43598
|
+
if (templates.length === 0) {
|
|
43599
|
+
console.error(chalk.red("No repo templates found under templates/repo"));
|
|
43600
|
+
return;
|
|
43601
|
+
}
|
|
43602
|
+
const useDefaults = params.yes === true;
|
|
43603
|
+
const core = await resolveCore(params, templates, useDefaults);
|
|
43604
|
+
if (core === void 0) return void 0;
|
|
43605
|
+
const options = await resolvePlanOptions(params, core.wizard, useDefaults);
|
|
43606
|
+
if (options === void 0) return void 0;
|
|
43607
|
+
const plan = buildPlan(params, core, options);
|
|
43608
|
+
if (!useDefaults && core.wizard) {
|
|
43609
|
+
printSummary(plan);
|
|
43610
|
+
if (!await askConfirmation("Proceed?", true)) {
|
|
43611
|
+
console.log(chalk.yellow("Cancelled"));
|
|
43612
|
+
return;
|
|
43613
|
+
}
|
|
43614
|
+
}
|
|
43615
|
+
return plan;
|
|
43616
|
+
}
|
|
43617
|
+
//#endregion
|
|
43618
|
+
//#region src/actions/repo-init/templateVars.ts
|
|
43619
|
+
function packageManagerField(pm) {
|
|
43620
|
+
switch (pm) {
|
|
43621
|
+
case "pnpm": return "pnpm@11.13.1";
|
|
43622
|
+
case "yarn": return "yarn@4.13.0";
|
|
43623
|
+
case "npm": return "npm@10.9.4";
|
|
43624
|
+
case "bun": return "bun@1.3.3";
|
|
43625
|
+
}
|
|
43626
|
+
}
|
|
43627
|
+
function xyCommandForPm(pm) {
|
|
43628
|
+
switch (pm) {
|
|
43629
|
+
case "bun": return "bun run xy";
|
|
43630
|
+
case "npm": return "npm exec -- xy";
|
|
43631
|
+
default: return `${pm} xy`;
|
|
43632
|
+
}
|
|
43633
|
+
}
|
|
43634
|
+
function buildTemplateVariables(plan) {
|
|
43635
|
+
const { description, githubOrg, monorepo, packageName, pm, projectName, react, scope } = plan;
|
|
43636
|
+
const identifierName = packageName.replaceAll(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
43637
|
+
const npmScope = scope.startsWith("@") || scope.length === 0 ? scope : `@${scope}`;
|
|
43638
|
+
const scopedPackageName = npmScope.length > 0 ? `${npmScope}/${packageName}` : packageName;
|
|
43639
|
+
const rootPackageName = monorepo ? npmScope.length > 0 ? `${npmScope}/${projectName}-build` : `${projectName}-build` : scopedPackageName;
|
|
43640
|
+
const eslintConfigPackage = react ? "@ariestools/eslint-config-react-flat" : "@ariestools/eslint-config-flat";
|
|
43641
|
+
const tsconfigPackage = react ? "@ariestools/tsconfig-react" : "@ariestools/tsconfig";
|
|
43642
|
+
const coverageInclude = monorepo ? "packages/*/src/**/*.{ts,tsx,mts,cts}" : "src/**/*.{ts,tsx,mts,cts}";
|
|
43643
|
+
const testInclude = monorepo ? "packages/*/src/spec/**/*.spec.{ts,tsx,mts,cts}" : "src/spec/**/*.spec.{ts,tsx,mts,cts}";
|
|
43644
|
+
const srcPrefix = monorepo ? `packages/${packageName}/src/` : "src/";
|
|
43645
|
+
const layoutLabel = monorepo ? "monorepo (pnpm/yarn/npm workspaces)" : "single package";
|
|
43646
|
+
return {
|
|
43647
|
+
coverageInclude,
|
|
43648
|
+
description,
|
|
43649
|
+
eslintConfigPackage,
|
|
43650
|
+
githubOrg,
|
|
43651
|
+
identifierName,
|
|
43652
|
+
layoutDescription: monorepo ? `Monorepo for ${projectName} (\`${scopedPackageName}\`). Package sources live under \`packages/${packageName}\`.` : `Single-package repo for ${projectName} (\`${scopedPackageName}\`). Sources live under \`src/\`.`,
|
|
43653
|
+
layoutLabel,
|
|
43654
|
+
npmScope,
|
|
43655
|
+
packageDirNote: monorepo ? ", never from inside a package directory" : "",
|
|
43656
|
+
packageManager: packageManagerField(pm),
|
|
43657
|
+
packageName,
|
|
43658
|
+
pmName: pm,
|
|
43659
|
+
projectName,
|
|
43660
|
+
rootPackageName,
|
|
43661
|
+
rootPrivate: monorepo ? "true" : "false",
|
|
43662
|
+
scopedPackageName,
|
|
43663
|
+
srcPrefix,
|
|
43664
|
+
testInclude,
|
|
43665
|
+
toolchainRange: bundledToolchainRange(),
|
|
43666
|
+
toolchainVersion: bundledToolchainVersion(),
|
|
43667
|
+
tsconfigPackage,
|
|
43668
|
+
xyCommand: xyCommandForPm(pm)
|
|
43669
|
+
};
|
|
43670
|
+
}
|
|
43671
|
+
//#endregion
|
|
43672
|
+
//#region src/actions/repo-init/scaffold.ts
|
|
43414
43673
|
function mapOutputPath(relativePath, variables) {
|
|
43415
43674
|
let result = relativePath;
|
|
43416
43675
|
if (result.endsWith(".tmpl")) result = result.slice(0, -5);
|
|
@@ -43419,8 +43678,8 @@ function mapOutputPath(relativePath, variables) {
|
|
|
43419
43678
|
result = result.replaceAll("__packageName__", () => variables.packageName);
|
|
43420
43679
|
return result;
|
|
43421
43680
|
}
|
|
43422
|
-
function isPmSpecificFile(relativePath, pm) {
|
|
43423
|
-
if (relativePath === "pnpm-workspace.yaml" && pm !== "pnpm") return true;
|
|
43681
|
+
function isPmSpecificFile(relativePath, pm, monorepo) {
|
|
43682
|
+
if (relativePath === "pnpm-workspace.yaml" && (pm !== "pnpm" || !monorepo)) return true;
|
|
43424
43683
|
if (pm !== "pnpm" && relativePath.includes("build-pnpm")) return true;
|
|
43425
43684
|
if (pm !== "npm" && relativePath.includes("build-npm")) return true;
|
|
43426
43685
|
if (pm !== "bun" && relativePath.includes("build-bun")) return true;
|
|
@@ -43429,25 +43688,6 @@ function isPmSpecificFile(relativePath, pm) {
|
|
|
43429
43688
|
function mapBuildWorkflowName(outputPath) {
|
|
43430
43689
|
return outputPath.replace(/build-(bun|npm|pnpm|yarn)\.yml/, "build.yml");
|
|
43431
43690
|
}
|
|
43432
|
-
function buildVariables(params) {
|
|
43433
|
-
const { description, githubOrg, packageName, pm, projectName, scope } = params;
|
|
43434
|
-
const identifierName = packageName.replaceAll(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
43435
|
-
const packageManager = pm === "pnpm" ? "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319" : pm === "yarn" ? "yarn@4.13.0" : pm === "npm" ? "npm@10.9.4" : "bun@1.3.3";
|
|
43436
|
-
const xyCommand = pm === "npm" ? "npm exec -- xy" : pm === "bun" ? "bun run xy" : `${pm} xy`;
|
|
43437
|
-
return {
|
|
43438
|
-
description,
|
|
43439
|
-
githubOrg,
|
|
43440
|
-
identifierName,
|
|
43441
|
-
npmScope: scope,
|
|
43442
|
-
packageName,
|
|
43443
|
-
packageManager,
|
|
43444
|
-
pmName: pm,
|
|
43445
|
-
projectName,
|
|
43446
|
-
toolchainRange: bundledToolchainRange(),
|
|
43447
|
-
toolchainVersion: bundledToolchainVersion(),
|
|
43448
|
-
xyCommand
|
|
43449
|
-
};
|
|
43450
|
-
}
|
|
43451
43691
|
function didEnsureEmptyDir(projectDir, name) {
|
|
43452
43692
|
if (existsSync(projectDir)) {
|
|
43453
43693
|
if (readdirSync(projectDir).length > 0) {
|
|
@@ -43458,11 +43698,12 @@ function didEnsureEmptyDir(projectDir, name) {
|
|
|
43458
43698
|
mkdirSync(projectDir, { recursive: true });
|
|
43459
43699
|
return true;
|
|
43460
43700
|
}
|
|
43461
|
-
function scaffoldFiles(templateName, layer, outputDir, pm, variables, isVerbose) {
|
|
43701
|
+
function scaffoldFiles(templateName, layer, outputDir, pm, monorepo, variables, isVerbose, skipRelativePaths = /* @__PURE__ */ new Set()) {
|
|
43462
43702
|
const files = loadRepoTemplateFiles(templateName, layer);
|
|
43463
43703
|
let count = 0;
|
|
43464
43704
|
for (const file of files) {
|
|
43465
|
-
if (
|
|
43705
|
+
if (skipRelativePaths.has(file.relativePath)) continue;
|
|
43706
|
+
if (isPmSpecificFile(file.relativePath, pm, monorepo)) continue;
|
|
43466
43707
|
const content = fillTemplate(file.content, variables);
|
|
43467
43708
|
let outputPath = mapOutputPath(file.relativePath, variables);
|
|
43468
43709
|
if (outputPath == null || outputPath.length === 0) continue;
|
|
@@ -43471,7 +43712,10 @@ function scaffoldFiles(templateName, layer, outputDir, pm, variables, isVerbose)
|
|
|
43471
43712
|
mkdirSync(PATH.dirname(fullPath), { recursive: true });
|
|
43472
43713
|
writeFileSync(fullPath, content);
|
|
43473
43714
|
count++;
|
|
43474
|
-
if (isVerbose ?? false)
|
|
43715
|
+
if (isVerbose ?? false) {
|
|
43716
|
+
const label = layer === "root" || !monorepo ? outputPath : `packages/${variables.packageName}/${outputPath}`;
|
|
43717
|
+
console.log(chalk.gray(` ${label}`));
|
|
43718
|
+
}
|
|
43475
43719
|
}
|
|
43476
43720
|
return count;
|
|
43477
43721
|
}
|
|
@@ -43504,60 +43748,412 @@ function didInstallDependencies(projectDir, pm) {
|
|
|
43504
43748
|
console.log(chalk.green("Dependencies installed"));
|
|
43505
43749
|
return true;
|
|
43506
43750
|
}
|
|
43507
|
-
function
|
|
43751
|
+
function mergePackageJsonRecords(rootPkg, packagePkg) {
|
|
43752
|
+
const rootDev = rootPkg.devDependencies ?? {};
|
|
43753
|
+
const pkgDev = packagePkg.devDependencies ?? {};
|
|
43754
|
+
const pkgDeps = packagePkg.dependencies ?? {};
|
|
43755
|
+
const rootScripts = rootPkg.scripts ?? {};
|
|
43756
|
+
const pkgScripts = packagePkg.scripts ?? {};
|
|
43757
|
+
return {
|
|
43758
|
+
...packagePkg,
|
|
43759
|
+
dependencies: pkgDeps,
|
|
43760
|
+
devDependencies: {
|
|
43761
|
+
...rootDev,
|
|
43762
|
+
...pkgDev
|
|
43763
|
+
},
|
|
43764
|
+
private: false,
|
|
43765
|
+
scripts: {
|
|
43766
|
+
...rootScripts,
|
|
43767
|
+
...pkgScripts
|
|
43768
|
+
}
|
|
43769
|
+
};
|
|
43770
|
+
}
|
|
43771
|
+
function normalizeRootPackageJson(projectDir, plan, packagePkg) {
|
|
43508
43772
|
const pkgPath = PATH.resolve(projectDir, "package.json");
|
|
43509
43773
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
43510
|
-
if (
|
|
43774
|
+
if (!plan.monorepo) {
|
|
43775
|
+
if (packagePkg !== void 0) {
|
|
43776
|
+
const merged = mergePackageJsonRecords(pkg, packagePkg);
|
|
43777
|
+
writeFileSync(pkgPath, `${JSON.stringify(merged, null, 2)}\n`, "utf8");
|
|
43778
|
+
return;
|
|
43779
|
+
}
|
|
43780
|
+
delete pkg.workspaces;
|
|
43781
|
+
pkg.private = false;
|
|
43782
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
|
|
43783
|
+
return;
|
|
43784
|
+
}
|
|
43785
|
+
if (plan.pm === "pnpm") delete pkg.workspaces;
|
|
43511
43786
|
else pkg.workspaces ??= ["packages/*"];
|
|
43512
43787
|
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
|
|
43513
43788
|
}
|
|
43514
|
-
function
|
|
43515
|
-
const
|
|
43516
|
-
|
|
43517
|
-
|
|
43518
|
-
|
|
43519
|
-
|
|
43789
|
+
function renderNextSteps(plan) {
|
|
43790
|
+
const lines = [`cd ${plan.name}`];
|
|
43791
|
+
if (plan.skipInstall) lines.push(`${plan.pm} install`);
|
|
43792
|
+
lines.push(`${xyCommandForPm(plan.pm)} build`);
|
|
43793
|
+
if (plan.skillsTier !== "none" && plan.skipInstall) lines.push(`${xyCommandForPm(plan.pm)} skills lint --fix`);
|
|
43794
|
+
return lines;
|
|
43795
|
+
}
|
|
43796
|
+
function scaffoldProject(plan) {
|
|
43797
|
+
const variables = buildTemplateVariables(plan);
|
|
43798
|
+
if (plan.isVerbose) {
|
|
43799
|
+
console.log(chalk.gray("Template variables:"));
|
|
43800
|
+
for (const [key, value] of Object.entries(variables)) console.log(chalk.gray(` ${key}: ${value}`));
|
|
43520
43801
|
}
|
|
43802
|
+
const projectDir = PATH.resolve(process.cwd(), plan.name);
|
|
43803
|
+
if (!didEnsureEmptyDir(projectDir, plan.name)) return void 0;
|
|
43804
|
+
let count = 0;
|
|
43805
|
+
if (plan.monorepo) {
|
|
43806
|
+
count += scaffoldFiles(plan.template, "root", projectDir, plan.pm, true, variables, plan.isVerbose);
|
|
43807
|
+
const pkgDir = PATH.resolve(projectDir, "packages", plan.packageName);
|
|
43808
|
+
count += scaffoldFiles(plan.template, "package", pkgDir, plan.pm, true, variables, plan.isVerbose);
|
|
43809
|
+
normalizeRootPackageJson(projectDir, plan);
|
|
43810
|
+
} else {
|
|
43811
|
+
count += scaffoldFiles(plan.template, "package", projectDir, plan.pm, false, variables, plan.isVerbose);
|
|
43812
|
+
const packagePkgPath = PATH.resolve(projectDir, "package.json");
|
|
43813
|
+
const packagePkg = JSON.parse(readFileSync(packagePkgPath, "utf8"));
|
|
43814
|
+
count += scaffoldFiles(plan.template, "root", projectDir, plan.pm, false, variables, plan.isVerbose);
|
|
43815
|
+
normalizeRootPackageJson(projectDir, plan, packagePkg);
|
|
43816
|
+
const mergeTmp = PATH.resolve(projectDir, ".package.json.merge");
|
|
43817
|
+
if (existsSync(mergeTmp)) unlinkSync(mergeTmp);
|
|
43818
|
+
}
|
|
43819
|
+
console.log(chalk.green(`Scaffolded ${count} files into ${plan.name}/`));
|
|
43820
|
+
return {
|
|
43821
|
+
count,
|
|
43822
|
+
projectDir
|
|
43823
|
+
};
|
|
43521
43824
|
}
|
|
43522
|
-
|
|
43523
|
-
|
|
43524
|
-
|
|
43525
|
-
|
|
43526
|
-
|
|
43527
|
-
|
|
43528
|
-
|
|
43529
|
-
|
|
43825
|
+
function runPostScaffold(plan, projectDir) {
|
|
43826
|
+
if (!plan.skipGit) initGitRepo(projectDir, plan.isVerbose);
|
|
43827
|
+
if (!plan.skipInstall) return { installOk: didInstallDependencies(projectDir, plan.pm) };
|
|
43828
|
+
return { installOk: true };
|
|
43829
|
+
}
|
|
43830
|
+
//#endregion
|
|
43831
|
+
//#region src/actions/skills/passthrough.ts
|
|
43832
|
+
const ANSI_PREFIX = String.raw`\x1B\[[\d;]*m`;
|
|
43833
|
+
const COMMAND_PREFIX = String.raw`(^|[\s$()\x60>]|${ANSI_PREFIX})`;
|
|
43834
|
+
const SKILLS_COMMANDS = [
|
|
43835
|
+
"<command>",
|
|
43836
|
+
"add",
|
|
43837
|
+
"a",
|
|
43838
|
+
"use",
|
|
43839
|
+
"remove",
|
|
43840
|
+
"rm",
|
|
43841
|
+
"list",
|
|
43842
|
+
"ls",
|
|
43843
|
+
"find",
|
|
43844
|
+
"update",
|
|
43845
|
+
"upgrade",
|
|
43846
|
+
"experimental_install",
|
|
43847
|
+
"init",
|
|
43848
|
+
"experimental_sync",
|
|
43849
|
+
"defaults",
|
|
43850
|
+
"lint",
|
|
43851
|
+
"updo"
|
|
43852
|
+
].join("|");
|
|
43853
|
+
const NPX_SKILLS_PATTERN = new RegExp(String.raw`${COMMAND_PREFIX}npx(?:\s+-y)?\s+skills(?:@latest)?(?=\W|$)`, "g");
|
|
43854
|
+
const BARE_USAGE_SKILLS_PATTERN = new RegExp(String.raw`^(\s*(?:${ANSI_PREFIX})*Usage:(?:${ANSI_PREFIX})*\s*)skills(?=\s+<command>)`, "gm");
|
|
43855
|
+
const BARE_PROMPT_SKILLS_PATTERN = new RegExp(String.raw`^(\s*(?:${ANSI_PREFIX})*\$(?:${ANSI_PREFIX})*\s*)skills(?=\s+(?:${SKILLS_COMMANDS})(?:\W|$))`, "gm");
|
|
43856
|
+
const require$3 = createRequire(import.meta.url);
|
|
43857
|
+
const YES_FLAGS = /* @__PURE__ */ new Set(["-y", "--yes"]);
|
|
43858
|
+
const SCOPE_FLAGS$1 = /* @__PURE__ */ new Set([
|
|
43859
|
+
"-g",
|
|
43860
|
+
"--global",
|
|
43861
|
+
"-p",
|
|
43862
|
+
"--project"
|
|
43863
|
+
]);
|
|
43864
|
+
const INTERACTIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
43865
|
+
"add",
|
|
43866
|
+
"a",
|
|
43867
|
+
"experimental_sync",
|
|
43868
|
+
"find",
|
|
43869
|
+
"remove",
|
|
43870
|
+
"rm",
|
|
43871
|
+
"update",
|
|
43872
|
+
"upgrade"
|
|
43873
|
+
]);
|
|
43874
|
+
const skillsPositionalArgs = (args) => {
|
|
43875
|
+
return args.filter((arg) => !arg.startsWith("-"));
|
|
43876
|
+
};
|
|
43877
|
+
const hasSkillsFlag = (args, flags) => {
|
|
43878
|
+
return args.some((arg) => flags.has(arg));
|
|
43879
|
+
};
|
|
43880
|
+
const needsSkillsInteractive = (args) => {
|
|
43881
|
+
const [command, ...tail] = args;
|
|
43882
|
+
if (command === void 0 || !INTERACTIVE_COMMANDS.has(command)) return false;
|
|
43883
|
+
switch (command) {
|
|
43884
|
+
case "update":
|
|
43885
|
+
case "upgrade": return !hasSkillsFlag(tail, SCOPE_FLAGS$1) && !hasSkillsFlag(tail, YES_FLAGS) && skillsPositionalArgs(tail).length === 0;
|
|
43886
|
+
case "add":
|
|
43887
|
+
case "a":
|
|
43888
|
+
case "experimental_sync": return !hasSkillsFlag(tail, YES_FLAGS);
|
|
43889
|
+
case "remove":
|
|
43890
|
+
case "rm": return !hasSkillsFlag(tail, YES_FLAGS) && skillsPositionalArgs(tail).length === 0;
|
|
43891
|
+
case "find": return skillsPositionalArgs(tail).length === 0;
|
|
43892
|
+
default: return false;
|
|
43893
|
+
}
|
|
43894
|
+
};
|
|
43895
|
+
const rewriteSkillsRefs = (text) => {
|
|
43896
|
+
return text.replaceAll(NPX_SKILLS_PATTERN, (_match, prefix) => `${prefix}xy skills`).replaceAll(BARE_USAGE_SKILLS_PATTERN, "$1xy skills").replaceAll(BARE_PROMPT_SKILLS_PATTERN, "$1xy skills");
|
|
43897
|
+
};
|
|
43898
|
+
const resolveBundledSkillsCli = () => {
|
|
43899
|
+
return resolvePublishedOrDevCli("skills.mjs", () => require$3.resolve("skills/bin/cli.mjs"));
|
|
43900
|
+
};
|
|
43901
|
+
const resolveSkillsInvocation = async (args, options = {}) => {
|
|
43902
|
+
const resolveCli = options.resolveBundledCli ?? resolveBundledSkillsCli;
|
|
43903
|
+
const writeNotice = options.writeNotice ?? ((message) => console.error(message));
|
|
43904
|
+
try {
|
|
43905
|
+
return {
|
|
43906
|
+
args: [resolveCli(), ...args],
|
|
43907
|
+
command: process.execPath,
|
|
43908
|
+
fallback: false
|
|
43909
|
+
};
|
|
43910
|
+
} catch {
|
|
43911
|
+
writeNotice(chalk.red("skills package not found. Reinstall @ariestools/toolchain dependencies."));
|
|
43912
|
+
return;
|
|
43913
|
+
}
|
|
43914
|
+
};
|
|
43915
|
+
const runSkills = async (args, options = {}) => {
|
|
43916
|
+
const invocation = await resolveSkillsInvocation(args, options);
|
|
43917
|
+
if (invocation === void 0) return 1;
|
|
43918
|
+
const isInteractive = options.interactive ?? (process.stdin.isTTY && needsSkillsInteractive(args));
|
|
43919
|
+
const stdio = isInteractive ? "inherit" : [
|
|
43920
|
+
"inherit",
|
|
43921
|
+
"pipe",
|
|
43922
|
+
"pipe"
|
|
43923
|
+
];
|
|
43924
|
+
return new Promise((resolve) => {
|
|
43925
|
+
const child = spawn$1(invocation.command, invocation.args, {
|
|
43926
|
+
cwd: options.cwd,
|
|
43927
|
+
env: {
|
|
43928
|
+
FORCE_COLOR: "3",
|
|
43929
|
+
...process.env
|
|
43930
|
+
},
|
|
43931
|
+
stdio
|
|
43932
|
+
});
|
|
43933
|
+
if (!isInteractive) {
|
|
43934
|
+
child.stdout?.setEncoding("utf8");
|
|
43935
|
+
child.stderr?.setEncoding("utf8");
|
|
43936
|
+
child.stdout?.on("data", (chunk) => {
|
|
43937
|
+
process.stdout.write(rewriteSkillsRefs(chunk));
|
|
43938
|
+
});
|
|
43939
|
+
child.stderr?.on("data", (chunk) => {
|
|
43940
|
+
process.stderr.write(rewriteSkillsRefs(chunk));
|
|
43941
|
+
});
|
|
43530
43942
|
}
|
|
43943
|
+
child.on("error", () => resolve(1));
|
|
43944
|
+
child.on("close", (code) => resolve(code ?? 1));
|
|
43945
|
+
});
|
|
43946
|
+
};
|
|
43947
|
+
const argvAfterCommand = (command) => {
|
|
43948
|
+
const argv = process.argv;
|
|
43949
|
+
const commandIdx = argv.indexOf(command);
|
|
43950
|
+
if (commandIdx === -1) return [];
|
|
43951
|
+
return argv.slice(commandIdx + 1);
|
|
43952
|
+
};
|
|
43953
|
+
//#endregion
|
|
43954
|
+
//#region src/actions/skills/defaults.ts
|
|
43955
|
+
/**
|
|
43956
|
+
Source of truth for xy-development, xy-toolchain, and ariestools-sdk.
|
|
43957
|
+
*/
|
|
43958
|
+
const ARIESTOOLS_SKILLS_SOURCE = "ariestools/ariestools-skills";
|
|
43959
|
+
/**
|
|
43960
|
+
Source of truth for xyo-knowledge and xl1-* skills.
|
|
43961
|
+
*/
|
|
43962
|
+
const XYO_SKILLS_SOURCE = "XYOracleNetwork/xyo-skills";
|
|
43963
|
+
const ARIESTOOLS_SKILLS = [
|
|
43964
|
+
"ariestools-sdk",
|
|
43965
|
+
"xy-development",
|
|
43966
|
+
"xy-toolchain"
|
|
43967
|
+
];
|
|
43968
|
+
const XYO_STACK_SKILLS = [
|
|
43969
|
+
"xl1-build",
|
|
43970
|
+
"xl1-knowledge",
|
|
43971
|
+
"xl1-patterns",
|
|
43972
|
+
"xl1-scaffold",
|
|
43973
|
+
"xl1-testing",
|
|
43974
|
+
"xyo-knowledge"
|
|
43975
|
+
];
|
|
43976
|
+
/**
|
|
43977
|
+
All skills managed by `xy skills` conveniences (both sources).
|
|
43978
|
+
*/
|
|
43979
|
+
const XYO_DEFAULT_SKILLS = [...ARIESTOOLS_SKILLS, ...XYO_STACK_SKILLS];
|
|
43980
|
+
const AGENT_FLAGS = /* @__PURE__ */ new Set(["-a", "--agent"]);
|
|
43981
|
+
const hasSkillsAgentFlag = (args) => {
|
|
43982
|
+
return args.some((arg) => AGENT_FLAGS.has(arg) || arg.startsWith("--agent="));
|
|
43983
|
+
};
|
|
43984
|
+
/**
|
|
43985
|
+
* Returns install argument plans for `xy skills defaults`.
|
|
43986
|
+
* Aries Tools base skills install from ariestools-skills; XYO/XL1 skills from xyo-skills.
|
|
43987
|
+
*/
|
|
43988
|
+
const skillsDefaultsInstallPlans = (args) => {
|
|
43989
|
+
const installSelector = hasSkillsAgentFlag(args) ? ["--skill", "*"] : ["--all"];
|
|
43990
|
+
const xyoSelector = XYO_STACK_SKILLS.flatMap((skill) => ["--skill", skill]);
|
|
43991
|
+
return [{
|
|
43992
|
+
selector: installSelector,
|
|
43993
|
+
source: ARIESTOOLS_SKILLS_SOURCE
|
|
43994
|
+
}, {
|
|
43995
|
+
selector: xyoSelector,
|
|
43996
|
+
source: XYO_SKILLS_SOURCE
|
|
43997
|
+
}];
|
|
43998
|
+
};
|
|
43999
|
+
const skillSourceForName = (skillName) => {
|
|
44000
|
+
if (ARIESTOOLS_SKILLS.includes(skillName)) return ARIESTOOLS_SKILLS_SOURCE;
|
|
44001
|
+
return XYO_SKILLS_SOURCE;
|
|
44002
|
+
};
|
|
44003
|
+
const skillsDefaults = async (args) => {
|
|
44004
|
+
for (const plan of skillsDefaultsInstallPlans(args)) {
|
|
44005
|
+
const code = await runSkills([
|
|
44006
|
+
"add",
|
|
44007
|
+
plan.source,
|
|
44008
|
+
...plan.selector,
|
|
44009
|
+
...args
|
|
44010
|
+
]);
|
|
44011
|
+
if (code !== 0) return code;
|
|
43531
44012
|
}
|
|
43532
|
-
|
|
43533
|
-
|
|
43534
|
-
|
|
43535
|
-
|
|
43536
|
-
|
|
43537
|
-
|
|
43538
|
-
|
|
43539
|
-
|
|
43540
|
-
|
|
44013
|
+
return 0;
|
|
44014
|
+
};
|
|
44015
|
+
//#endregion
|
|
44016
|
+
//#region src/actions/skills/skillRules.ts
|
|
44017
|
+
const XYO_SKILL_NAMES = [...XYO_DEFAULT_SKILLS];
|
|
44018
|
+
const SKILL_ORDER = [
|
|
44019
|
+
"xy-development",
|
|
44020
|
+
"xy-toolchain",
|
|
44021
|
+
"ariestools-sdk",
|
|
44022
|
+
"xyo-knowledge",
|
|
44023
|
+
"xl1-knowledge",
|
|
44024
|
+
"xl1-patterns",
|
|
44025
|
+
"xl1-testing",
|
|
44026
|
+
"xl1-scaffold",
|
|
44027
|
+
"xl1-build"
|
|
44028
|
+
];
|
|
44029
|
+
const skillOrderIndex = (name) => {
|
|
44030
|
+
const index = SKILL_ORDER.indexOf(name);
|
|
44031
|
+
return index === -1 ? SKILL_ORDER.length : index;
|
|
44032
|
+
};
|
|
44033
|
+
const sortSkills = (skills) => {
|
|
44034
|
+
return [...skills].toSorted((a, b) => skillOrderIndex(a) - skillOrderIndex(b) || a.localeCompare(b));
|
|
44035
|
+
};
|
|
44036
|
+
const XY_SKILLS = ["xy-development", "xy-toolchain"];
|
|
44037
|
+
const XYO_SKILLS = ["xyo-knowledge"];
|
|
44038
|
+
const XL1_SKILLS = [
|
|
44039
|
+
"xl1-knowledge",
|
|
44040
|
+
"xl1-patterns",
|
|
44041
|
+
"xl1-testing"
|
|
44042
|
+
];
|
|
44043
|
+
const XL1_OPTIONAL_SKILLS = ["xl1-scaffold", "xl1-build"];
|
|
44044
|
+
const TIER_REQUIRED_SKILLS = {
|
|
44045
|
+
xy: XY_SKILLS,
|
|
44046
|
+
xyo: [...XY_SKILLS, ...XYO_SKILLS],
|
|
44047
|
+
xl1: [
|
|
44048
|
+
...XY_SKILLS,
|
|
44049
|
+
...XYO_SKILLS,
|
|
44050
|
+
...XL1_SKILLS
|
|
44051
|
+
]
|
|
44052
|
+
};
|
|
44053
|
+
const requiredSkillsForTier = (tier) => {
|
|
44054
|
+
if (tier === "none") return [];
|
|
44055
|
+
return TIER_REQUIRED_SKILLS[tier];
|
|
44056
|
+
};
|
|
44057
|
+
/**
|
|
44058
|
+
* Required skills for a detected repo profile.
|
|
44059
|
+
* Adds `ariestools-sdk` when the repo depends on or produces packages from ariestools/sdk-js.
|
|
44060
|
+
*/
|
|
44061
|
+
const requiredSkillsForProfile = (profile) => {
|
|
44062
|
+
const base = requiredSkillsForTier(profile.tier);
|
|
44063
|
+
if (!profile.isUsingAriestoolsSdk) return base;
|
|
44064
|
+
if (base.length === 0) return sortSkills([
|
|
44065
|
+
"xy-development",
|
|
44066
|
+
"xy-toolchain",
|
|
44067
|
+
"ariestools-sdk"
|
|
44068
|
+
]);
|
|
44069
|
+
if (base.includes("ariestools-sdk")) return base;
|
|
44070
|
+
return sortSkills([...base, "ariestools-sdk"]);
|
|
44071
|
+
};
|
|
44072
|
+
const optionalSkillsForTier = (tier) => {
|
|
44073
|
+
if (tier !== "xl1") return [];
|
|
44074
|
+
return XL1_OPTIONAL_SKILLS;
|
|
44075
|
+
};
|
|
44076
|
+
const isXyoSkillName = (name) => {
|
|
44077
|
+
return XYO_SKILL_NAMES.includes(name);
|
|
44078
|
+
};
|
|
44079
|
+
const unnecessarySkillsForProfile = (profile, installed) => {
|
|
44080
|
+
const required = new Set(requiredSkillsForProfile(profile));
|
|
44081
|
+
const optional = new Set(optionalSkillsForTier(profile.tier));
|
|
44082
|
+
return installed.filter(isXyoSkillName).filter((name) => !required.has(name) && !optional.has(name)).toSorted((a, b) => a.localeCompare(b));
|
|
44083
|
+
};
|
|
44084
|
+
//#endregion
|
|
44085
|
+
//#region src/actions/repo-init/skillsInstall.ts
|
|
44086
|
+
/**
|
|
44087
|
+
* Tier-scoped skills install plans for `xy repo init` (project-local).
|
|
44088
|
+
* Unlike `skills defaults`, this only installs skills needed for the chosen tier.
|
|
44089
|
+
*/
|
|
44090
|
+
function skillsInstallPlansForTier(tier, includeOptional) {
|
|
44091
|
+
if (tier === "none") return [];
|
|
44092
|
+
const required = [...requiredSkillsForTier(tier)];
|
|
44093
|
+
const optional = includeOptional ? [...optionalSkillsForTier(tier)] : [];
|
|
44094
|
+
const names = [.../* @__PURE__ */ new Set([...required, ...optional])];
|
|
44095
|
+
const ariestoolsNames = /* @__PURE__ */ new Set([
|
|
44096
|
+
"xy-development",
|
|
44097
|
+
"xy-toolchain",
|
|
44098
|
+
"ariestools-sdk"
|
|
44099
|
+
]);
|
|
44100
|
+
const ariestools = names.filter((name) => ariestoolsNames.has(name));
|
|
44101
|
+
const xyo = names.filter((name) => !ariestoolsNames.has(name));
|
|
44102
|
+
const plans = [];
|
|
44103
|
+
if (ariestools.length > 0) plans.push({
|
|
44104
|
+
selector: ariestools.flatMap((skill) => ["--skill", skill]),
|
|
44105
|
+
source: ARIESTOOLS_SKILLS_SOURCE
|
|
43541
44106
|
});
|
|
43542
|
-
if (
|
|
43543
|
-
|
|
43544
|
-
|
|
44107
|
+
if (xyo.length > 0) plans.push({
|
|
44108
|
+
selector: xyo.flatMap((skill) => ["--skill", skill]),
|
|
44109
|
+
source: XYO_SKILLS_SOURCE
|
|
44110
|
+
});
|
|
44111
|
+
return plans;
|
|
44112
|
+
}
|
|
44113
|
+
async function installSkillsForTier(projectDir, tier, includeOptional, isVerbose) {
|
|
44114
|
+
const plans = skillsInstallPlansForTier(tier, includeOptional);
|
|
44115
|
+
if (plans.length === 0) return 0;
|
|
44116
|
+
console.log(chalk.gray(`Installing skills for tier "${tier}"...`));
|
|
44117
|
+
for (const plan of plans) {
|
|
44118
|
+
if (isVerbose ?? false) console.log(chalk.gray(` skills add ${plan.source} ${plan.selector.join(" ")}`));
|
|
44119
|
+
const code = await runSkills([
|
|
44120
|
+
"add",
|
|
44121
|
+
plan.source,
|
|
44122
|
+
...plan.selector,
|
|
44123
|
+
"-y"
|
|
44124
|
+
], {
|
|
44125
|
+
cwd: projectDir,
|
|
44126
|
+
interactive: false
|
|
44127
|
+
});
|
|
44128
|
+
if (code !== 0) {
|
|
44129
|
+
console.warn(chalk.yellow(`Skills install failed for ${plan.source} (exit ${code})`));
|
|
44130
|
+
return code;
|
|
44131
|
+
}
|
|
44132
|
+
}
|
|
44133
|
+
console.log(chalk.green("Skills installed"));
|
|
44134
|
+
return 0;
|
|
44135
|
+
}
|
|
44136
|
+
//#endregion
|
|
44137
|
+
//#region src/actions/repo-init/index.ts
|
|
44138
|
+
async function repoInit(params) {
|
|
44139
|
+
const plan = await resolveRepoInitPlan(params);
|
|
44140
|
+
if (plan === void 0) return 1;
|
|
44141
|
+
const scaffolded = scaffoldProject(plan);
|
|
44142
|
+
if (scaffolded === void 0) return 1;
|
|
44143
|
+
const { projectDir } = scaffolded;
|
|
44144
|
+
const { installOk } = runPostScaffold(plan, projectDir);
|
|
44145
|
+
if (!installOk) return 1;
|
|
44146
|
+
if (plan.skillsTier !== "none") {
|
|
44147
|
+
if (plan.skipInstall) {
|
|
44148
|
+
console.log(chalk.yellow("Skipping skills install because --skip-install was set"));
|
|
44149
|
+
console.log(chalk.gray(" After install, run: xy skills lint --fix"));
|
|
44150
|
+
} else if (await installSkillsForTier(projectDir, plan.skillsTier, plan.skillsOptional, plan.isVerbose) !== 0) console.warn(chalk.yellow("Project was created but skills install failed"));
|
|
43545
44151
|
}
|
|
43546
|
-
const projectDir = PATH.resolve(process.cwd(), name);
|
|
43547
|
-
if (!didEnsureEmptyDir(projectDir, name)) return 1;
|
|
43548
|
-
const rootCount = scaffoldFiles(template, "root", projectDir, pm, variables, isVerbose);
|
|
43549
|
-
const pkgCount = scaffoldFiles(template, "package", PATH.resolve(projectDir, "packages", packageName), pm, variables, isVerbose);
|
|
43550
|
-
normalizeRootPackageJson(projectDir, pm);
|
|
43551
|
-
console.log(chalk.green(`Scaffolded ${rootCount + pkgCount} files into ${name}/`));
|
|
43552
|
-
if (!(skipGit ?? false)) initGitRepo(projectDir, isVerbose);
|
|
43553
|
-
if (!(skipInstall ?? false) && !didInstallDependencies(projectDir, pm)) return 1;
|
|
43554
44152
|
console.log("");
|
|
43555
|
-
console.log(chalk.cyan(`Project ${name} created successfully!`));
|
|
44153
|
+
console.log(chalk.cyan(`Project ${plan.name} created successfully!`));
|
|
43556
44154
|
console.log("");
|
|
43557
44155
|
console.log(chalk.gray("Next steps:"));
|
|
43558
|
-
console.log(chalk.gray(`
|
|
43559
|
-
if (skipInstall ?? false) console.log(chalk.gray(` ${pm} install`));
|
|
43560
|
-
console.log(chalk.gray(` ${renderXyCommand(pm, ["build"])}`));
|
|
44156
|
+
for (const line of renderNextSteps(plan)) console.log(chalk.gray(` ${line}`));
|
|
43561
44157
|
return 0;
|
|
43562
44158
|
}
|
|
43563
44159
|
//#endregion
|
|
@@ -49687,190 +50283,6 @@ function ruleCatalogResult(rules, title) {
|
|
|
49687
50283
|
};
|
|
49688
50284
|
}
|
|
49689
50285
|
//#endregion
|
|
49690
|
-
//#region src/actions/skills/passthrough.ts
|
|
49691
|
-
const ANSI_PREFIX = String.raw`\x1B\[[\d;]*m`;
|
|
49692
|
-
const COMMAND_PREFIX = String.raw`(^|[\s$()\x60>]|${ANSI_PREFIX})`;
|
|
49693
|
-
const SKILLS_COMMANDS = [
|
|
49694
|
-
"<command>",
|
|
49695
|
-
"add",
|
|
49696
|
-
"a",
|
|
49697
|
-
"use",
|
|
49698
|
-
"remove",
|
|
49699
|
-
"rm",
|
|
49700
|
-
"list",
|
|
49701
|
-
"ls",
|
|
49702
|
-
"find",
|
|
49703
|
-
"update",
|
|
49704
|
-
"upgrade",
|
|
49705
|
-
"experimental_install",
|
|
49706
|
-
"init",
|
|
49707
|
-
"experimental_sync",
|
|
49708
|
-
"defaults",
|
|
49709
|
-
"lint",
|
|
49710
|
-
"updo"
|
|
49711
|
-
].join("|");
|
|
49712
|
-
const NPX_SKILLS_PATTERN = new RegExp(String.raw`${COMMAND_PREFIX}npx(?:\s+-y)?\s+skills(?:@latest)?(?=\W|$)`, "g");
|
|
49713
|
-
const BARE_USAGE_SKILLS_PATTERN = new RegExp(String.raw`^(\s*(?:${ANSI_PREFIX})*Usage:(?:${ANSI_PREFIX})*\s*)skills(?=\s+<command>)`, "gm");
|
|
49714
|
-
const BARE_PROMPT_SKILLS_PATTERN = new RegExp(String.raw`^(\s*(?:${ANSI_PREFIX})*\$(?:${ANSI_PREFIX})*\s*)skills(?=\s+(?:${SKILLS_COMMANDS})(?:\W|$))`, "gm");
|
|
49715
|
-
const require$3 = createRequire(import.meta.url);
|
|
49716
|
-
const YES_FLAGS = /* @__PURE__ */ new Set(["-y", "--yes"]);
|
|
49717
|
-
const SCOPE_FLAGS$1 = /* @__PURE__ */ new Set([
|
|
49718
|
-
"-g",
|
|
49719
|
-
"--global",
|
|
49720
|
-
"-p",
|
|
49721
|
-
"--project"
|
|
49722
|
-
]);
|
|
49723
|
-
const INTERACTIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
49724
|
-
"add",
|
|
49725
|
-
"a",
|
|
49726
|
-
"experimental_sync",
|
|
49727
|
-
"find",
|
|
49728
|
-
"remove",
|
|
49729
|
-
"rm",
|
|
49730
|
-
"update",
|
|
49731
|
-
"upgrade"
|
|
49732
|
-
]);
|
|
49733
|
-
const skillsPositionalArgs = (args) => {
|
|
49734
|
-
return args.filter((arg) => !arg.startsWith("-"));
|
|
49735
|
-
};
|
|
49736
|
-
const hasSkillsFlag = (args, flags) => {
|
|
49737
|
-
return args.some((arg) => flags.has(arg));
|
|
49738
|
-
};
|
|
49739
|
-
const needsSkillsInteractive = (args) => {
|
|
49740
|
-
const [command, ...tail] = args;
|
|
49741
|
-
if (command === void 0 || !INTERACTIVE_COMMANDS.has(command)) return false;
|
|
49742
|
-
switch (command) {
|
|
49743
|
-
case "update":
|
|
49744
|
-
case "upgrade": return !hasSkillsFlag(tail, SCOPE_FLAGS$1) && !hasSkillsFlag(tail, YES_FLAGS) && skillsPositionalArgs(tail).length === 0;
|
|
49745
|
-
case "add":
|
|
49746
|
-
case "a":
|
|
49747
|
-
case "experimental_sync": return !hasSkillsFlag(tail, YES_FLAGS);
|
|
49748
|
-
case "remove":
|
|
49749
|
-
case "rm": return !hasSkillsFlag(tail, YES_FLAGS) && skillsPositionalArgs(tail).length === 0;
|
|
49750
|
-
case "find": return skillsPositionalArgs(tail).length === 0;
|
|
49751
|
-
default: return false;
|
|
49752
|
-
}
|
|
49753
|
-
};
|
|
49754
|
-
const rewriteSkillsRefs = (text) => {
|
|
49755
|
-
return text.replaceAll(NPX_SKILLS_PATTERN, (_match, prefix) => `${prefix}xy skills`).replaceAll(BARE_USAGE_SKILLS_PATTERN, "$1xy skills").replaceAll(BARE_PROMPT_SKILLS_PATTERN, "$1xy skills");
|
|
49756
|
-
};
|
|
49757
|
-
const resolveBundledSkillsCli = () => {
|
|
49758
|
-
return resolvePublishedOrDevCli("skills.mjs", () => require$3.resolve("skills/bin/cli.mjs"));
|
|
49759
|
-
};
|
|
49760
|
-
const resolveSkillsInvocation = async (args, options = {}) => {
|
|
49761
|
-
const resolveCli = options.resolveBundledCli ?? resolveBundledSkillsCli;
|
|
49762
|
-
const writeNotice = options.writeNotice ?? ((message) => console.error(message));
|
|
49763
|
-
try {
|
|
49764
|
-
return {
|
|
49765
|
-
args: [resolveCli(), ...args],
|
|
49766
|
-
command: process.execPath,
|
|
49767
|
-
fallback: false
|
|
49768
|
-
};
|
|
49769
|
-
} catch {
|
|
49770
|
-
writeNotice(chalk.red("skills package not found. Reinstall @ariestools/toolchain dependencies."));
|
|
49771
|
-
return;
|
|
49772
|
-
}
|
|
49773
|
-
};
|
|
49774
|
-
const runSkills = async (args, options = {}) => {
|
|
49775
|
-
const invocation = await resolveSkillsInvocation(args, options);
|
|
49776
|
-
if (invocation === void 0) return 1;
|
|
49777
|
-
const isInteractive = options.interactive ?? (process.stdin.isTTY && needsSkillsInteractive(args));
|
|
49778
|
-
const stdio = isInteractive ? "inherit" : [
|
|
49779
|
-
"inherit",
|
|
49780
|
-
"pipe",
|
|
49781
|
-
"pipe"
|
|
49782
|
-
];
|
|
49783
|
-
return new Promise((resolve) => {
|
|
49784
|
-
const child = spawn$1(invocation.command, invocation.args, {
|
|
49785
|
-
env: {
|
|
49786
|
-
FORCE_COLOR: "3",
|
|
49787
|
-
...process.env
|
|
49788
|
-
},
|
|
49789
|
-
stdio
|
|
49790
|
-
});
|
|
49791
|
-
if (!isInteractive) {
|
|
49792
|
-
child.stdout?.setEncoding("utf8");
|
|
49793
|
-
child.stderr?.setEncoding("utf8");
|
|
49794
|
-
child.stdout?.on("data", (chunk) => {
|
|
49795
|
-
process.stdout.write(rewriteSkillsRefs(chunk));
|
|
49796
|
-
});
|
|
49797
|
-
child.stderr?.on("data", (chunk) => {
|
|
49798
|
-
process.stderr.write(rewriteSkillsRefs(chunk));
|
|
49799
|
-
});
|
|
49800
|
-
}
|
|
49801
|
-
child.on("error", () => resolve(1));
|
|
49802
|
-
child.on("close", (code) => resolve(code ?? 1));
|
|
49803
|
-
});
|
|
49804
|
-
};
|
|
49805
|
-
const argvAfterCommand = (command) => {
|
|
49806
|
-
const argv = process.argv;
|
|
49807
|
-
const commandIdx = argv.indexOf(command);
|
|
49808
|
-
if (commandIdx === -1) return [];
|
|
49809
|
-
return argv.slice(commandIdx + 1);
|
|
49810
|
-
};
|
|
49811
|
-
//#endregion
|
|
49812
|
-
//#region src/actions/skills/defaults.ts
|
|
49813
|
-
/**
|
|
49814
|
-
Source of truth for xy-development, xy-toolchain, and ariestools-sdk.
|
|
49815
|
-
*/
|
|
49816
|
-
const ARIESTOOLS_SKILLS_SOURCE = "ariestools/ariestools-skills";
|
|
49817
|
-
/**
|
|
49818
|
-
Source of truth for xyo-knowledge and xl1-* skills.
|
|
49819
|
-
*/
|
|
49820
|
-
const XYO_SKILLS_SOURCE = "XYOracleNetwork/xyo-skills";
|
|
49821
|
-
const ARIESTOOLS_SKILLS = [
|
|
49822
|
-
"ariestools-sdk",
|
|
49823
|
-
"xy-development",
|
|
49824
|
-
"xy-toolchain"
|
|
49825
|
-
];
|
|
49826
|
-
const XYO_STACK_SKILLS = [
|
|
49827
|
-
"xl1-build",
|
|
49828
|
-
"xl1-knowledge",
|
|
49829
|
-
"xl1-patterns",
|
|
49830
|
-
"xl1-scaffold",
|
|
49831
|
-
"xl1-testing",
|
|
49832
|
-
"xyo-knowledge"
|
|
49833
|
-
];
|
|
49834
|
-
/**
|
|
49835
|
-
All skills managed by `xy skills` conveniences (both sources).
|
|
49836
|
-
*/
|
|
49837
|
-
const XYO_DEFAULT_SKILLS = [...ARIESTOOLS_SKILLS, ...XYO_STACK_SKILLS];
|
|
49838
|
-
const AGENT_FLAGS = /* @__PURE__ */ new Set(["-a", "--agent"]);
|
|
49839
|
-
const hasSkillsAgentFlag = (args) => {
|
|
49840
|
-
return args.some((arg) => AGENT_FLAGS.has(arg) || arg.startsWith("--agent="));
|
|
49841
|
-
};
|
|
49842
|
-
/**
|
|
49843
|
-
* Returns install argument plans for `xy skills defaults`.
|
|
49844
|
-
* Aries Tools base skills install from ariestools-skills; XYO/XL1 skills from xyo-skills.
|
|
49845
|
-
*/
|
|
49846
|
-
const skillsDefaultsInstallPlans = (args) => {
|
|
49847
|
-
const installSelector = hasSkillsAgentFlag(args) ? ["--skill", "*"] : ["--all"];
|
|
49848
|
-
const xyoSelector = XYO_STACK_SKILLS.flatMap((skill) => ["--skill", skill]);
|
|
49849
|
-
return [{
|
|
49850
|
-
selector: installSelector,
|
|
49851
|
-
source: ARIESTOOLS_SKILLS_SOURCE
|
|
49852
|
-
}, {
|
|
49853
|
-
selector: xyoSelector,
|
|
49854
|
-
source: XYO_SKILLS_SOURCE
|
|
49855
|
-
}];
|
|
49856
|
-
};
|
|
49857
|
-
const skillSourceForName = (skillName) => {
|
|
49858
|
-
if (ARIESTOOLS_SKILLS.includes(skillName)) return ARIESTOOLS_SKILLS_SOURCE;
|
|
49859
|
-
return XYO_SKILLS_SOURCE;
|
|
49860
|
-
};
|
|
49861
|
-
const skillsDefaults = async (args) => {
|
|
49862
|
-
for (const plan of skillsDefaultsInstallPlans(args)) {
|
|
49863
|
-
const code = await runSkills([
|
|
49864
|
-
"add",
|
|
49865
|
-
plan.source,
|
|
49866
|
-
...plan.selector,
|
|
49867
|
-
...args
|
|
49868
|
-
]);
|
|
49869
|
-
if (code !== 0) return code;
|
|
49870
|
-
}
|
|
49871
|
-
return 0;
|
|
49872
|
-
};
|
|
49873
|
-
//#endregion
|
|
49874
50286
|
//#region src/actions/skills/detectProfile.ts
|
|
49875
50287
|
const XYLABS_SCOPE = "@xylabs/";
|
|
49876
50288
|
const ARIESTOOLS_SCOPE = "@ariestools/";
|
|
@@ -50071,75 +50483,6 @@ const listSkillDirsAt = (root) => {
|
|
|
50071
50483
|
return listSkillDirs(root);
|
|
50072
50484
|
};
|
|
50073
50485
|
//#endregion
|
|
50074
|
-
//#region src/actions/skills/skillRules.ts
|
|
50075
|
-
const XYO_SKILL_NAMES = [...XYO_DEFAULT_SKILLS];
|
|
50076
|
-
const SKILL_ORDER = [
|
|
50077
|
-
"xy-development",
|
|
50078
|
-
"xy-toolchain",
|
|
50079
|
-
"ariestools-sdk",
|
|
50080
|
-
"xyo-knowledge",
|
|
50081
|
-
"xl1-knowledge",
|
|
50082
|
-
"xl1-patterns",
|
|
50083
|
-
"xl1-testing",
|
|
50084
|
-
"xl1-scaffold",
|
|
50085
|
-
"xl1-build"
|
|
50086
|
-
];
|
|
50087
|
-
const skillOrderIndex = (name) => {
|
|
50088
|
-
const index = SKILL_ORDER.indexOf(name);
|
|
50089
|
-
return index === -1 ? SKILL_ORDER.length : index;
|
|
50090
|
-
};
|
|
50091
|
-
const sortSkills = (skills) => {
|
|
50092
|
-
return [...skills].toSorted((a, b) => skillOrderIndex(a) - skillOrderIndex(b) || a.localeCompare(b));
|
|
50093
|
-
};
|
|
50094
|
-
const XY_SKILLS = ["xy-development", "xy-toolchain"];
|
|
50095
|
-
const XYO_SKILLS = ["xyo-knowledge"];
|
|
50096
|
-
const XL1_SKILLS = [
|
|
50097
|
-
"xl1-knowledge",
|
|
50098
|
-
"xl1-patterns",
|
|
50099
|
-
"xl1-testing"
|
|
50100
|
-
];
|
|
50101
|
-
const XL1_OPTIONAL_SKILLS = ["xl1-scaffold", "xl1-build"];
|
|
50102
|
-
const TIER_REQUIRED_SKILLS = {
|
|
50103
|
-
xy: XY_SKILLS,
|
|
50104
|
-
xyo: [...XY_SKILLS, ...XYO_SKILLS],
|
|
50105
|
-
xl1: [
|
|
50106
|
-
...XY_SKILLS,
|
|
50107
|
-
...XYO_SKILLS,
|
|
50108
|
-
...XL1_SKILLS
|
|
50109
|
-
]
|
|
50110
|
-
};
|
|
50111
|
-
const requiredSkillsForTier = (tier) => {
|
|
50112
|
-
if (tier === "none") return [];
|
|
50113
|
-
return TIER_REQUIRED_SKILLS[tier];
|
|
50114
|
-
};
|
|
50115
|
-
/**
|
|
50116
|
-
* Required skills for a detected repo profile.
|
|
50117
|
-
* Adds `ariestools-sdk` when the repo depends on or produces packages from ariestools/sdk-js.
|
|
50118
|
-
*/
|
|
50119
|
-
const requiredSkillsForProfile = (profile) => {
|
|
50120
|
-
const base = requiredSkillsForTier(profile.tier);
|
|
50121
|
-
if (!profile.isUsingAriestoolsSdk) return base;
|
|
50122
|
-
if (base.length === 0) return sortSkills([
|
|
50123
|
-
"xy-development",
|
|
50124
|
-
"xy-toolchain",
|
|
50125
|
-
"ariestools-sdk"
|
|
50126
|
-
]);
|
|
50127
|
-
if (base.includes("ariestools-sdk")) return base;
|
|
50128
|
-
return sortSkills([...base, "ariestools-sdk"]);
|
|
50129
|
-
};
|
|
50130
|
-
const optionalSkillsForTier = (tier) => {
|
|
50131
|
-
if (tier !== "xl1") return [];
|
|
50132
|
-
return XL1_OPTIONAL_SKILLS;
|
|
50133
|
-
};
|
|
50134
|
-
const isXyoSkillName = (name) => {
|
|
50135
|
-
return XYO_SKILL_NAMES.includes(name);
|
|
50136
|
-
};
|
|
50137
|
-
const unnecessarySkillsForProfile = (profile, installed) => {
|
|
50138
|
-
const required = new Set(requiredSkillsForProfile(profile));
|
|
50139
|
-
const optional = new Set(optionalSkillsForTier(profile.tier));
|
|
50140
|
-
return installed.filter(isXyoSkillName).filter((name) => !required.has(name) && !optional.has(name)).toSorted((a, b) => a.localeCompare(b));
|
|
50141
|
-
};
|
|
50142
|
-
//#endregion
|
|
50143
50486
|
//#region src/actions/skills/versions.ts
|
|
50144
50487
|
const VERSION_PATTERN = /metadata:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+version:\s*([^\s#]+)/;
|
|
50145
50488
|
const upstreamSkillUrl = (skillName) => {
|
|
@@ -53345,20 +53688,26 @@ const packmanCommand = {
|
|
|
53345
53688
|
};
|
|
53346
53689
|
//#endregion
|
|
53347
53690
|
//#region src/xy/common/repo/initCommand.ts
|
|
53691
|
+
const templates = (() => {
|
|
53692
|
+
try {
|
|
53693
|
+
return listRepoTemplates();
|
|
53694
|
+
} catch {
|
|
53695
|
+
return ["cli"];
|
|
53696
|
+
}
|
|
53697
|
+
})();
|
|
53348
53698
|
const initCommand$2 = {
|
|
53349
|
-
command: "init
|
|
53350
|
-
describe: "Scaffold a new
|
|
53699
|
+
command: "init [template] [name]",
|
|
53700
|
+
describe: "Scaffold a new repo from a template (interactive when template is omitted)",
|
|
53351
53701
|
builder: (yargs) => {
|
|
53352
53702
|
return yargs.positional("template", {
|
|
53353
|
-
choices:
|
|
53354
|
-
describe: "Template to use",
|
|
53703
|
+
choices: templates.length > 0 ? templates : void 0,
|
|
53704
|
+
describe: "Template to use (omit to answer setup questions)",
|
|
53355
53705
|
type: "string"
|
|
53356
53706
|
}).positional("name", {
|
|
53357
53707
|
describe: "Project name (also used as directory name)",
|
|
53358
53708
|
type: "string"
|
|
53359
53709
|
}).option("scope", {
|
|
53360
|
-
default:
|
|
53361
|
-
describe: "npm scope for packages",
|
|
53710
|
+
describe: "npm scope for packages (default: @xylabs; wizard may prompt)",
|
|
53362
53711
|
type: "string"
|
|
53363
53712
|
}).option("package", {
|
|
53364
53713
|
describe: "Package name within the monorepo (defaults to project name)",
|
|
@@ -53377,9 +53726,31 @@ const initCommand$2 = {
|
|
|
53377
53726
|
"pnpm",
|
|
53378
53727
|
"yarn"
|
|
53379
53728
|
],
|
|
53380
|
-
default:
|
|
53381
|
-
|
|
53729
|
+
describe: "Package manager to configure (default: pnpm)",
|
|
53730
|
+
type: "string"
|
|
53731
|
+
}).option("monorepo", {
|
|
53732
|
+
describe: "Scaffold as a monorepo with packages/* (default: true)",
|
|
53733
|
+
type: "boolean"
|
|
53734
|
+
}).option("react", {
|
|
53735
|
+
describe: "Use React ESLint/tsconfig packages (default: false)",
|
|
53736
|
+
type: "boolean"
|
|
53737
|
+
}).option("skills-tier", {
|
|
53738
|
+
choices: [
|
|
53739
|
+
"none",
|
|
53740
|
+
"xy",
|
|
53741
|
+
"xyo",
|
|
53742
|
+
"xl1"
|
|
53743
|
+
],
|
|
53744
|
+
describe: "Agent skills to install after scaffold (wizard default: xy)",
|
|
53382
53745
|
type: "string"
|
|
53746
|
+
}).option("skills-optional", {
|
|
53747
|
+
describe: "Include optional XL1 skills (scaffold/build) when skills-tier is xl1",
|
|
53748
|
+
type: "boolean"
|
|
53749
|
+
}).option("yes", {
|
|
53750
|
+
alias: "y",
|
|
53751
|
+
default: false,
|
|
53752
|
+
describe: "Accept defaults for omitted wizard questions (name still required)",
|
|
53753
|
+
type: "boolean"
|
|
53383
53754
|
}).option("skip-install", {
|
|
53384
53755
|
default: false,
|
|
53385
53756
|
describe: "Skip dependency installation after scaffolding",
|
|
@@ -53395,14 +53766,19 @@ const initCommand$2 = {
|
|
|
53395
53766
|
await withEnvelope("repo init", () => repoInit({
|
|
53396
53767
|
description: argv.description,
|
|
53397
53768
|
githubOrg: argv["github-org"],
|
|
53769
|
+
isVerbose: Boolean(argv.verbose),
|
|
53770
|
+
monorepo: argv.monorepo,
|
|
53398
53771
|
name: argv.name,
|
|
53399
53772
|
packageName: argv.package,
|
|
53400
53773
|
pm: argv.pm,
|
|
53774
|
+
react: argv.react,
|
|
53401
53775
|
scope: argv.scope,
|
|
53402
|
-
skipGit:
|
|
53403
|
-
skipInstall:
|
|
53776
|
+
skipGit: Boolean(argv.skipGit),
|
|
53777
|
+
skipInstall: Boolean(argv.skipInstall),
|
|
53778
|
+
skillsOptional: argv["skills-optional"],
|
|
53779
|
+
skillsTier: argv["skills-tier"],
|
|
53404
53780
|
template: argv.template,
|
|
53405
|
-
|
|
53781
|
+
yes: Boolean(argv.yes)
|
|
53406
53782
|
}));
|
|
53407
53783
|
}
|
|
53408
53784
|
};
|