wp-typia 0.24.6 → 0.24.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +147 -54
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -21,7 +21,7 @@ var package_default;
|
|
|
21
21
|
var init_package = __esm(() => {
|
|
22
22
|
package_default = {
|
|
23
23
|
name: "wp-typia",
|
|
24
|
-
version: "0.24.
|
|
24
|
+
version: "0.24.7",
|
|
25
25
|
description: "Canonical CLI package for wp-typia scaffolding and project workflows",
|
|
26
26
|
packageManager: "bun@1.3.11",
|
|
27
27
|
type: "module",
|
|
@@ -1256,7 +1256,7 @@ function buildPatternCatalogDryRunSummaryLines(result, options) {
|
|
|
1256
1256
|
...normalizationNotes.map((note) => ` ${note}`)
|
|
1257
1257
|
];
|
|
1258
1258
|
}
|
|
1259
|
-
var PATTERN_MISSING_NAME_MESSAGE = "`wp-typia add pattern` requires <name>. Usage: wp-typia add pattern <name>.", patternAddKindEntry;
|
|
1259
|
+
var PATTERN_MISSING_NAME_MESSAGE = "`wp-typia add pattern` requires <name>. Usage: wp-typia add pattern <name>.", LEGACY_TAG_FLAG_WARNING = "--tag is deprecated; use repeatable --tags instead.", patternAddKindEntry;
|
|
1260
1260
|
var init_pattern = __esm(() => {
|
|
1261
1261
|
init_add_kind_registry_shared();
|
|
1262
1262
|
init_cli_string_flags();
|
|
@@ -1287,6 +1287,9 @@ var init_pattern = __esm(() => {
|
|
|
1287
1287
|
const catalogTitle = rawCatalogTitle;
|
|
1288
1288
|
const tags = normalizePatternTagFlags(context.flags.tags, context.flags.tag);
|
|
1289
1289
|
const thumbnailUrl = rawThumbnailUrl;
|
|
1290
|
+
if (context.flags.tag !== undefined && context.flags.format !== "json") {
|
|
1291
|
+
context.warnLine(LEGACY_TAG_FLAG_WARNING);
|
|
1292
|
+
}
|
|
1290
1293
|
return {
|
|
1291
1294
|
execute: (cwd) => context.addRuntime.runAddPatternCommand({
|
|
1292
1295
|
catalogTitle,
|
|
@@ -1708,6 +1711,17 @@ function buildAddKindCompletionDetails(kind, options) {
|
|
|
1708
1711
|
function supportsAddKindDryRun(kind) {
|
|
1709
1712
|
return ADD_KIND_REGISTRY[kind].supportsDryRun;
|
|
1710
1713
|
}
|
|
1714
|
+
function getAddKindOptions() {
|
|
1715
|
+
return ADD_KIND_IDS2.map((kind) => ({
|
|
1716
|
+
description: ADD_KIND_REGISTRY[kind].description,
|
|
1717
|
+
name: kind,
|
|
1718
|
+
value: kind
|
|
1719
|
+
}));
|
|
1720
|
+
}
|
|
1721
|
+
function getAddNameLabel(kind) {
|
|
1722
|
+
const resolvedKind = isAddKindId(kind) ? kind : "block";
|
|
1723
|
+
return ADD_KIND_REGISTRY[resolvedKind].nameLabel;
|
|
1724
|
+
}
|
|
1711
1725
|
var ADD_KIND_REGISTRY;
|
|
1712
1726
|
var init_add_kind_registry = __esm(() => {
|
|
1713
1727
|
init_add_kind_ids();
|
|
@@ -2233,9 +2247,6 @@ var init_runtime_bridge_sync = __esm(() => {
|
|
|
2233
2247
|
function formatMissingAddKindDetailLine() {
|
|
2234
2248
|
return `\`wp-typia add\` requires <kind>. Usage: wp-typia add ${formatAddKindUsagePlaceholder()} ...`;
|
|
2235
2249
|
}
|
|
2236
|
-
function buildMissingAddKindDetailLines() {
|
|
2237
|
-
return [formatMissingAddKindDetailLine()];
|
|
2238
|
-
}
|
|
2239
2250
|
function shouldPrintMissingAddKindHelp(options) {
|
|
2240
2251
|
if (typeof options.emitOutput === "boolean") {
|
|
2241
2252
|
return options.emitOutput;
|
|
@@ -2484,6 +2495,9 @@ async function executePlannedAddKind(kind, executionContext, context) {
|
|
|
2484
2495
|
const plan = await getAddKindExecutionPlan(kind, executionContext);
|
|
2485
2496
|
return executePreparedAddKind(kind, context, plan);
|
|
2486
2497
|
}
|
|
2498
|
+
function contextAllowsInteractivePrompts(flags) {
|
|
2499
|
+
return flags.format !== "json";
|
|
2500
|
+
}
|
|
2487
2501
|
async function executeAddCommand({
|
|
2488
2502
|
cwd,
|
|
2489
2503
|
emitOutput = true,
|
|
@@ -2501,36 +2515,53 @@ async function executeAddCommand({
|
|
|
2501
2515
|
try {
|
|
2502
2516
|
const addRuntime = await loadCliAddRuntime();
|
|
2503
2517
|
const isInteractiveSession = interactive ?? isInteractiveTerminal();
|
|
2504
|
-
|
|
2518
|
+
const getOrCreatePrompt = async () => {
|
|
2519
|
+
if (activePrompt) {
|
|
2520
|
+
return activePrompt;
|
|
2521
|
+
}
|
|
2522
|
+
const { createReadlinePrompt } = await loadCliPromptRuntime();
|
|
2523
|
+
activePrompt = prompt ?? createReadlinePrompt();
|
|
2524
|
+
return activePrompt;
|
|
2525
|
+
};
|
|
2526
|
+
let resolvedKind = kind;
|
|
2527
|
+
let resolvedName = name;
|
|
2528
|
+
let promptedForKind = false;
|
|
2529
|
+
if (!resolvedKind && isInteractiveSession && contextAllowsInteractivePrompts(flags)) {
|
|
2530
|
+
const kindPrompt = await getOrCreatePrompt();
|
|
2531
|
+
resolvedKind = await kindPrompt.select("Select what to add", getAddKindOptions().map((option) => ({
|
|
2532
|
+
hint: option.description,
|
|
2533
|
+
label: option.name,
|
|
2534
|
+
value: option.value
|
|
2535
|
+
})), 1);
|
|
2536
|
+
promptedForKind = true;
|
|
2537
|
+
}
|
|
2538
|
+
if (!resolvedKind) {
|
|
2505
2539
|
if (shouldPrintMissingAddKindHelp({ emitOutput })) {
|
|
2506
2540
|
printLine(addRuntime.formatAddHelpText());
|
|
2507
2541
|
}
|
|
2508
2542
|
throw createCliDiagnosticCodeError12(CLI_DIAGNOSTIC_CODES16.MISSING_ARGUMENT, formatMissingAddKindDetailLine());
|
|
2509
2543
|
}
|
|
2510
|
-
if (!isAddKindId(
|
|
2511
|
-
throw createCliDiagnosticCodeError12(CLI_DIAGNOSTIC_CODES16.INVALID_COMMAND, `Unknown add kind "${
|
|
2544
|
+
if (!isAddKindId(resolvedKind)) {
|
|
2545
|
+
throw createCliDiagnosticCodeError12(CLI_DIAGNOSTIC_CODES16.INVALID_COMMAND, `Unknown add kind "${resolvedKind}". Expected one of: ${formatAddKindList()}.`);
|
|
2512
2546
|
}
|
|
2513
|
-
if (
|
|
2514
|
-
|
|
2547
|
+
if (!resolvedName && promptedForKind) {
|
|
2548
|
+
const namePrompt = await getOrCreatePrompt();
|
|
2549
|
+
resolvedName = await namePrompt.text(getAddNameLabel(resolvedKind), "", (value) => value.trim().length > 0 ? true : `${getAddNameLabel(resolvedKind)} is required.`);
|
|
2550
|
+
}
|
|
2551
|
+
if (dryRun && !supportsAddKindDryRun(resolvedKind)) {
|
|
2552
|
+
throw createCliDiagnosticCodeError12(CLI_DIAGNOSTIC_CODES16.INVALID_ARGUMENT, `\`wp-typia add ${resolvedKind}\` does not support \`--dry-run\` yet.`);
|
|
2515
2553
|
}
|
|
2516
2554
|
const executionContext = {
|
|
2517
2555
|
addRuntime,
|
|
2518
2556
|
cwd,
|
|
2519
2557
|
flags,
|
|
2520
|
-
getOrCreatePrompt
|
|
2521
|
-
if (activePrompt) {
|
|
2522
|
-
return activePrompt;
|
|
2523
|
-
}
|
|
2524
|
-
const { createReadlinePrompt } = await loadCliPromptRuntime();
|
|
2525
|
-
activePrompt = prompt ?? createReadlinePrompt();
|
|
2526
|
-
return activePrompt;
|
|
2527
|
-
},
|
|
2558
|
+
getOrCreatePrompt,
|
|
2528
2559
|
isInteractiveSession,
|
|
2529
|
-
name,
|
|
2560
|
+
name: resolvedName,
|
|
2530
2561
|
positionalArgs,
|
|
2531
2562
|
warnLine
|
|
2532
2563
|
};
|
|
2533
|
-
return await executePlannedAddKind(
|
|
2564
|
+
return await executePlannedAddKind(resolvedKind, executionContext, {
|
|
2534
2565
|
cwd,
|
|
2535
2566
|
dryRun,
|
|
2536
2567
|
emitOutput,
|
|
@@ -2750,10 +2781,7 @@ var exports_add = {};
|
|
|
2750
2781
|
__export(exports_add, {
|
|
2751
2782
|
dispatchPortableCliAdd: () => dispatchPortableCliAdd
|
|
2752
2783
|
});
|
|
2753
|
-
import {
|
|
2754
|
-
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES18,
|
|
2755
|
-
createCliCommandError as createCliCommandError6
|
|
2756
|
-
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
2784
|
+
import { createCliCommandError as createCliCommandError6 } from "@wp-typia/project-tools/cli-diagnostics";
|
|
2757
2785
|
function resolvePortableCliAddName(positionals) {
|
|
2758
2786
|
if (positionals[1] === "core-variation" && positionals[3]) {
|
|
2759
2787
|
return positionals[3];
|
|
@@ -2767,17 +2795,6 @@ async function dispatchPortableCliAdd({
|
|
|
2767
2795
|
printLine,
|
|
2768
2796
|
warnLine
|
|
2769
2797
|
}) {
|
|
2770
|
-
if (!positionals[1]) {
|
|
2771
|
-
if (shouldPrintMissingAddKindHelp({ format: mergedFlags.format })) {
|
|
2772
|
-
const { formatAddHelpText } = await import("@wp-typia/project-tools/cli-add");
|
|
2773
|
-
printLine(formatAddHelpText());
|
|
2774
|
-
}
|
|
2775
|
-
throw createCliCommandError6({
|
|
2776
|
-
code: CLI_DIAGNOSTIC_CODES18.MISSING_ARGUMENT,
|
|
2777
|
-
command: "add",
|
|
2778
|
-
detailLines: buildMissingAddKindDetailLines()
|
|
2779
|
-
});
|
|
2780
|
-
}
|
|
2781
2798
|
const kind = positionals[1];
|
|
2782
2799
|
const name = resolvePortableCliAddName(positionals);
|
|
2783
2800
|
const positionalArgs = positionals.slice(1);
|
|
@@ -2821,7 +2838,6 @@ async function dispatchPortableCliAdd({
|
|
|
2821
2838
|
});
|
|
2822
2839
|
}
|
|
2823
2840
|
var init_add2 = __esm(() => {
|
|
2824
|
-
init_cli_error_messages();
|
|
2825
2841
|
init_runtime_bridge();
|
|
2826
2842
|
init_runtime_bridge_output();
|
|
2827
2843
|
});
|
|
@@ -2832,7 +2848,7 @@ __export(exports_create, {
|
|
|
2832
2848
|
dispatchPortableCliCreate: () => dispatchPortableCliCreate
|
|
2833
2849
|
});
|
|
2834
2850
|
import {
|
|
2835
|
-
CLI_DIAGNOSTIC_CODES as
|
|
2851
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES18,
|
|
2836
2852
|
createCliCommandError as createCliCommandError7
|
|
2837
2853
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
2838
2854
|
async function dispatchPortableCliCreate({
|
|
@@ -2845,7 +2861,7 @@ async function dispatchPortableCliCreate({
|
|
|
2845
2861
|
const projectDir = positionals[1];
|
|
2846
2862
|
if (!projectDir) {
|
|
2847
2863
|
throw createCliCommandError7({
|
|
2848
|
-
code:
|
|
2864
|
+
code: CLI_DIAGNOSTIC_CODES18.MISSING_ARGUMENT,
|
|
2849
2865
|
command: "create",
|
|
2850
2866
|
detailLines: buildMissingCreateProjectDirDetailLines()
|
|
2851
2867
|
});
|
|
@@ -2887,7 +2903,7 @@ __export(exports_doctor, {
|
|
|
2887
2903
|
dispatchPortableCliDoctor: () => dispatchPortableCliDoctor
|
|
2888
2904
|
});
|
|
2889
2905
|
import {
|
|
2890
|
-
CLI_DIAGNOSTIC_CODES as
|
|
2906
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES19,
|
|
2891
2907
|
createCliCommandError as createCliCommandError8
|
|
2892
2908
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
2893
2909
|
async function renderPortableCliDoctorJson(cwd, exitPolicy, printLine) {
|
|
@@ -2904,7 +2920,7 @@ async function renderPortableCliDoctorJson(cwd, exitPolicy, printLine) {
|
|
|
2904
2920
|
}, null, 2));
|
|
2905
2921
|
if (summary.exitCode === 1) {
|
|
2906
2922
|
throw createCliCommandError8({
|
|
2907
|
-
code:
|
|
2923
|
+
code: CLI_DIAGNOSTIC_CODES19.DOCTOR_CHECK_FAILED,
|
|
2908
2924
|
command: "doctor",
|
|
2909
2925
|
detailLines: getDoctorExitFailureDetailLines(checks, { exitPolicy }),
|
|
2910
2926
|
summary: "One or more doctor checks failed."
|
|
@@ -2933,7 +2949,7 @@ __export(exports_templates, {
|
|
|
2933
2949
|
dispatchPortableCliTemplates: () => dispatchPortableCliTemplates
|
|
2934
2950
|
});
|
|
2935
2951
|
import {
|
|
2936
|
-
CLI_DIAGNOSTIC_CODES as
|
|
2952
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES20,
|
|
2937
2953
|
createCliCommandError as createCliCommandError9
|
|
2938
2954
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
2939
2955
|
import {
|
|
@@ -2950,7 +2966,7 @@ function renderPortableCliTemplatesJson(printLine, flags, subcommand) {
|
|
|
2950
2966
|
const templateId = flags.id;
|
|
2951
2967
|
if (!templateId) {
|
|
2952
2968
|
throw createCliCommandError9({
|
|
2953
|
-
code:
|
|
2969
|
+
code: CLI_DIAGNOSTIC_CODES20.MISSING_ARGUMENT,
|
|
2954
2970
|
command: "templates",
|
|
2955
2971
|
detailLines: ["`wp-typia templates inspect` requires <template-id>."]
|
|
2956
2972
|
});
|
|
@@ -2958,7 +2974,7 @@ function renderPortableCliTemplatesJson(printLine, flags, subcommand) {
|
|
|
2958
2974
|
const template = getTemplateById(templateId);
|
|
2959
2975
|
if (!template) {
|
|
2960
2976
|
throw createCliCommandError9({
|
|
2961
|
-
code:
|
|
2977
|
+
code: CLI_DIAGNOSTIC_CODES20.INVALID_ARGUMENT,
|
|
2962
2978
|
command: "templates",
|
|
2963
2979
|
detailLines: [`Unknown template "${templateId}".`]
|
|
2964
2980
|
});
|
|
@@ -2977,7 +2993,7 @@ async function dispatchPortableCliTemplates({
|
|
|
2977
2993
|
const resolvedSubcommand = subcommand ?? (templateId ? "inspect" : "list");
|
|
2978
2994
|
if (resolvedSubcommand !== "list" && resolvedSubcommand !== "inspect") {
|
|
2979
2995
|
throw createCliCommandError9({
|
|
2980
|
-
code:
|
|
2996
|
+
code: CLI_DIAGNOSTIC_CODES20.INVALID_COMMAND,
|
|
2981
2997
|
command: "templates",
|
|
2982
2998
|
detailLines: [
|
|
2983
2999
|
`Unknown templates subcommand "${resolvedSubcommand}". Expected list or inspect.`
|
|
@@ -3428,7 +3444,7 @@ var ADD_OPTION_METADATA = {
|
|
|
3428
3444
|
type: "string"
|
|
3429
3445
|
},
|
|
3430
3446
|
template: {
|
|
3431
|
-
description: "
|
|
3447
|
+
description: "Built-in block family for add block; one of basic, interactivity, persistence, or compound. Defaults to basic in non-interactive runs; interactive runs prompt when omitted.",
|
|
3432
3448
|
short: "t",
|
|
3433
3449
|
type: "string"
|
|
3434
3450
|
},
|
|
@@ -3713,8 +3729,9 @@ function collectOptionNamesByType(metadata, type) {
|
|
|
3713
3729
|
}
|
|
3714
3730
|
function formatPortableCliOptionHelp(metadata) {
|
|
3715
3731
|
return Object.entries(metadata).filter(([, option]) => !option.hidden).map(([name, option]) => {
|
|
3716
|
-
const
|
|
3717
|
-
|
|
3732
|
+
const valueLabel = option.type === "string" ? " <value>" : "";
|
|
3733
|
+
const short = option.short ? `, -${option.short}${valueLabel}` : "";
|
|
3734
|
+
return `- --${name}${valueLabel}${short}: ${option.description}`;
|
|
3718
3735
|
});
|
|
3719
3736
|
}
|
|
3720
3737
|
function buildCommandOptionParser(...metadataMaps) {
|
|
@@ -3756,6 +3773,9 @@ function createMissingOptionValueError(optionLabel) {
|
|
|
3756
3773
|
function createUnknownOptionError(optionLabel) {
|
|
3757
3774
|
return createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, `Unknown option \`${optionLabel}\`.`);
|
|
3758
3775
|
}
|
|
3776
|
+
function createValueShortFlagClusterError(clusterLabel, optionLabel) {
|
|
3777
|
+
return createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, `Short flag cluster \`${clusterLabel}\` contains value-taking short flag \`${optionLabel}\`; spell value flags separately.`);
|
|
3778
|
+
}
|
|
3759
3779
|
function walkArgvOptions(argv, options) {
|
|
3760
3780
|
const flags = {};
|
|
3761
3781
|
const nextArgv = [];
|
|
@@ -3773,6 +3793,23 @@ function walkArgvOptions(argv, options) {
|
|
|
3773
3793
|
nextArgv.push(...argv.slice(index + (options.strict ? 1 : 0)));
|
|
3774
3794
|
break;
|
|
3775
3795
|
}
|
|
3796
|
+
if (arg.length > 2 && arg.startsWith("-") && !arg.startsWith("--")) {
|
|
3797
|
+
if (!options.strict) {
|
|
3798
|
+
nextArgv.push(arg);
|
|
3799
|
+
continue;
|
|
3800
|
+
}
|
|
3801
|
+
for (const shortName of arg.slice(1)) {
|
|
3802
|
+
const shortFlag = options.parser.shortFlagMap.get(shortName);
|
|
3803
|
+
if (!shortFlag) {
|
|
3804
|
+
throw createUnknownOptionError(`-${shortName}`);
|
|
3805
|
+
}
|
|
3806
|
+
if (shortFlag.type !== "boolean") {
|
|
3807
|
+
throw createValueShortFlagClusterError(arg, `-${shortName}`);
|
|
3808
|
+
}
|
|
3809
|
+
flags[shortFlag.name] = true;
|
|
3810
|
+
}
|
|
3811
|
+
continue;
|
|
3812
|
+
}
|
|
3776
3813
|
if (arg.length === 2 && arg.startsWith("-")) {
|
|
3777
3814
|
const shortFlag = options.parser.shortFlagMap.get(arg.slice(1));
|
|
3778
3815
|
if (!shortFlag || !options.strict && !optionNames.has(shortFlag.name)) {
|
|
@@ -4276,6 +4313,13 @@ function renderNoCommandHelp(printLine) {
|
|
|
4276
4313
|
printBlock(printLine, [PORTABLE_CLI_NO_COMMAND_REASON_LINE, ""]);
|
|
4277
4314
|
renderGeneralHelp(printLine);
|
|
4278
4315
|
}
|
|
4316
|
+
function renderUnknownHelpTarget(printLine, target) {
|
|
4317
|
+
printBlock(printLine, [
|
|
4318
|
+
`Unknown help target "${target}".`,
|
|
4319
|
+
`Supported commands: ${WP_TYPIA_PORTABLE_CLI_TOP_LEVEL_COMMAND_NAMES.join(", ")}.`,
|
|
4320
|
+
"Run wp-typia --help for general usage."
|
|
4321
|
+
]);
|
|
4322
|
+
}
|
|
4279
4323
|
function renderPortableCliCommandHelp(printLine, config) {
|
|
4280
4324
|
printBlock(printLine, [
|
|
4281
4325
|
config.heading,
|
|
@@ -4324,7 +4368,8 @@ var PORTABLE_CLI_COMMAND_HELP_CONFIG = {
|
|
|
4324
4368
|
},
|
|
4325
4369
|
skills: {
|
|
4326
4370
|
bodyLines: [
|
|
4327
|
-
"List detected coding agents or generate a compact wp-typia SKILL.md from command metadata."
|
|
4371
|
+
"List detected coding agents or generate a compact wp-typia SKILL.md from command metadata.",
|
|
4372
|
+
"Use --local to install project-local skills; generated universal skills under .agents/skills/wp-typia/ are added to .gitignore."
|
|
4328
4373
|
],
|
|
4329
4374
|
heading: "Usage: wp-typia skills <list|sync>",
|
|
4330
4375
|
optionMetadata: SKILLS_OPTION_METADATA
|
|
@@ -4403,7 +4448,7 @@ async function handlePortableCliEntrypointError(error, argv) {
|
|
|
4403
4448
|
|
|
4404
4449
|
// src/node-cli.ts
|
|
4405
4450
|
import {
|
|
4406
|
-
CLI_DIAGNOSTIC_CODES as
|
|
4451
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES21,
|
|
4407
4452
|
createCliCommandError as createCliCommandError10
|
|
4408
4453
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
4409
4454
|
|
|
@@ -5089,6 +5134,7 @@ var defaultSkillRuntime = {
|
|
|
5089
5134
|
homeDir: () => os2.homedir()
|
|
5090
5135
|
};
|
|
5091
5136
|
var GENERATED_SKILL_MARKER = ".wp-typia-skill.json";
|
|
5137
|
+
var LOCAL_SKILL_GITIGNORE_ENTRY = ".agents/skills/wp-typia/";
|
|
5092
5138
|
var SKILL_FILE = "SKILL.md";
|
|
5093
5139
|
function configHome(home) {
|
|
5094
5140
|
return process.env.XDG_CONFIG_HOME || path7.join(home, ".config");
|
|
@@ -5365,6 +5411,41 @@ function resolveParent(dir) {
|
|
|
5365
5411
|
}
|
|
5366
5412
|
}
|
|
5367
5413
|
}
|
|
5414
|
+
function detectLineEnding(content) {
|
|
5415
|
+
return content.includes(`\r
|
|
5416
|
+
`) ? `\r
|
|
5417
|
+
` : `
|
|
5418
|
+
`;
|
|
5419
|
+
}
|
|
5420
|
+
async function ensureLocalSkillsGitignore(cwd) {
|
|
5421
|
+
const gitignorePath = path7.join(cwd, ".gitignore");
|
|
5422
|
+
const entries = [LOCAL_SKILL_GITIGNORE_ENTRY];
|
|
5423
|
+
let content = "";
|
|
5424
|
+
let exists = true;
|
|
5425
|
+
try {
|
|
5426
|
+
content = await fsp.readFile(gitignorePath, "utf8");
|
|
5427
|
+
} catch (error) {
|
|
5428
|
+
if (error.code !== "ENOENT") {
|
|
5429
|
+
throw error;
|
|
5430
|
+
}
|
|
5431
|
+
exists = false;
|
|
5432
|
+
}
|
|
5433
|
+
const lines = content.split(/\r?\n/u).map((line) => line.trim());
|
|
5434
|
+
const missingEntries = entries.filter((entry) => !lines.includes(entry));
|
|
5435
|
+
if (missingEntries.length === 0) {
|
|
5436
|
+
return { entries, path: gitignorePath, updated: false };
|
|
5437
|
+
}
|
|
5438
|
+
const lineEnding = exists ? detectLineEnding(content) : `
|
|
5439
|
+
`;
|
|
5440
|
+
let nextContent = content;
|
|
5441
|
+
if (nextContent.length > 0 && !nextContent.endsWith(`
|
|
5442
|
+
`)) {
|
|
5443
|
+
nextContent += lineEnding;
|
|
5444
|
+
}
|
|
5445
|
+
nextContent += missingEntries.map((entry) => `${entry}${lineEnding}`).join("");
|
|
5446
|
+
await fsp.writeFile(gitignorePath, nextContent, "utf8");
|
|
5447
|
+
return { entries, path: gitignorePath, updated: true };
|
|
5448
|
+
}
|
|
5368
5449
|
async function syncSkills(options = {}) {
|
|
5369
5450
|
const runtime = options.runtime ?? defaultSkillRuntime;
|
|
5370
5451
|
const cwd = options.cwd ?? process.cwd();
|
|
@@ -5379,8 +5460,14 @@ async function syncSkills(options = {}) {
|
|
|
5379
5460
|
const hash = createHash("sha256").update(content).digest("hex").slice(0, 16);
|
|
5380
5461
|
const cacheKey = stalenessCacheKey(skillName, isGlobal, cwd, canonicalBase);
|
|
5381
5462
|
const previousState = readState(cacheKey, runtime);
|
|
5463
|
+
const gitignore = isGlobal ? undefined : await ensureLocalSkillsGitignore(cwd);
|
|
5382
5464
|
if (!options.force && previousState?.hash === hash && previousState.agentKey === agentKey && skillTargetsAreCurrent(canonicalDir, agentDirs, content)) {
|
|
5383
|
-
return {
|
|
5465
|
+
return {
|
|
5466
|
+
agents: [],
|
|
5467
|
+
gitignore,
|
|
5468
|
+
paths: [],
|
|
5469
|
+
updated: Boolean(gitignore?.updated)
|
|
5470
|
+
};
|
|
5384
5471
|
}
|
|
5385
5472
|
await fsp.mkdir(canonicalDir, { recursive: true });
|
|
5386
5473
|
await fsp.writeFile(path7.join(canonicalDir, SKILL_FILE), content, "utf8");
|
|
@@ -5415,6 +5502,7 @@ async function syncSkills(options = {}) {
|
|
|
5415
5502
|
writeState(cacheKey, { agentKey, hash }, runtime);
|
|
5416
5503
|
return {
|
|
5417
5504
|
agents: installs,
|
|
5505
|
+
gitignore,
|
|
5418
5506
|
paths: [canonicalDir],
|
|
5419
5507
|
updated: true
|
|
5420
5508
|
};
|
|
@@ -5570,15 +5658,20 @@ async function dispatchPortableCliSkills({
|
|
|
5570
5658
|
printLine2("Skills are up to date.");
|
|
5571
5659
|
return;
|
|
5572
5660
|
}
|
|
5573
|
-
|
|
5661
|
+
if (result.paths.length > 0) {
|
|
5662
|
+
printLine2(`Synced skills to ${result.paths.length} location(s).`);
|
|
5663
|
+
}
|
|
5574
5664
|
for (const install of result.agents) {
|
|
5575
5665
|
const reason = install.reason ? ` (${install.reason})` : "";
|
|
5576
5666
|
printLine2(` ${install.agent}: ${install.mode} -> ${install.path}${reason}`);
|
|
5577
5667
|
}
|
|
5668
|
+
if (result.gitignore?.updated) {
|
|
5669
|
+
printLine2(`Updated .gitignore for generated local skills: ${result.gitignore.entries.join(", ")}`);
|
|
5670
|
+
}
|
|
5578
5671
|
return;
|
|
5579
5672
|
}
|
|
5580
5673
|
throw createCliCommandError10({
|
|
5581
|
-
code:
|
|
5674
|
+
code: CLI_DIAGNOSTIC_CODES21.INVALID_COMMAND,
|
|
5582
5675
|
command: "skills",
|
|
5583
5676
|
detailLines: [
|
|
5584
5677
|
`Unknown skills subcommand "${subcommand}". Expected list or sync.`
|
|
@@ -5724,7 +5817,7 @@ async function runNodeCli(argv = process.argv.slice(2)) {
|
|
|
5724
5817
|
renderGeneralHelp(printLine);
|
|
5725
5818
|
return;
|
|
5726
5819
|
}
|
|
5727
|
-
|
|
5820
|
+
renderUnknownHelpTarget(printLine, helpTarget);
|
|
5728
5821
|
return;
|
|
5729
5822
|
}
|
|
5730
5823
|
if (versionRequested) {
|
|
@@ -5852,4 +5945,4 @@ export {
|
|
|
5852
5945
|
runGunshiCli
|
|
5853
5946
|
};
|
|
5854
5947
|
|
|
5855
|
-
//# debugId=
|
|
5948
|
+
//# debugId=23F1B8999F88E0E464756E2164756E21
|