@ariestools/toolchain 8.7.23 → 8.7.24
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/actions/fix.d.ts.map +1 -1
- package/dist/actions/ruleCatalog.d.ts +1 -0
- package/dist/actions/ruleCatalog.d.ts.map +1 -1
- package/dist/actions/work/helpers.d.ts +21 -0
- package/dist/actions/work/helpers.d.ts.map +1 -0
- package/dist/actions/work/index.d.ts +29 -86
- package/dist/actions/work/index.d.ts.map +1 -1
- package/dist/actions/work/lifecycle.d.ts +41 -0
- package/dist/actions/work/lifecycle.d.ts.map +1 -0
- package/dist/actions/work/lint.d.ts +21 -0
- package/dist/actions/work/lint.d.ts.map +1 -0
- package/dist/actions/work/list.d.ts +30 -0
- package/dist/actions/work/list.d.ts.map +1 -0
- package/dist/actions/work/move.d.ts +21 -0
- package/dist/actions/work/move.d.ts.map +1 -0
- package/dist/actions/work/queue.d.ts +26 -0
- package/dist/actions/work/queue.d.ts.map +1 -0
- package/dist/actions/work/render.d.ts +10 -3
- package/dist/actions/work/render.d.ts.map +1 -1
- package/dist/actions/work/store.d.ts +5 -0
- package/dist/actions/work/store.d.ts.map +1 -1
- package/dist/actions/work/sync.d.ts +20 -0
- package/dist/actions/work/sync.d.ts.map +1 -1
- package/dist/actions/work/workspace.d.ts +46 -0
- package/dist/actions/work/workspace.d.ts.map +1 -0
- package/dist/bin/package/build.mjs +6 -0
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/clean.mjs +6 -0
- package/dist/bin/package/clean.mjs.map +1 -1
- package/dist/bin/package/publint.mjs +6 -0
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +6 -0
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/skills.mjs +220 -76
- package/dist/bin/skills.mjs.map +1 -1
- package/dist/bin/xy.mjs +2004 -1031
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/lib/ruleCommandRegistry.d.ts +6 -0
- package/dist/lib/ruleCommandRegistry.d.ts.map +1 -1
- package/dist/xy/common/work/addCommand.d.ts.map +1 -1
- package/dist/xy/common/work/claimCommand.d.ts.map +1 -1
- package/dist/xy/common/work/doneCommand.d.ts.map +1 -1
- package/dist/xy/common/work/index.d.ts.map +1 -1
- package/dist/xy/common/work/initCommand.d.ts.map +1 -1
- package/dist/xy/common/work/lintCommand.d.ts +3 -0
- package/dist/xy/common/work/lintCommand.d.ts.map +1 -0
- package/dist/xy/common/work/listCommand.d.ts.map +1 -1
- package/dist/xy/common/work/moveCommand.d.ts +3 -0
- package/dist/xy/common/work/moveCommand.d.ts.map +1 -0
- package/dist/xy/common/work/nextCommand.d.ts.map +1 -1
- package/dist/xy/common/work/options.d.ts +8 -0
- package/dist/xy/common/work/options.d.ts.map +1 -1
- package/dist/xy/common/work/queueCommand.d.ts.map +1 -1
- package/dist/xy/common/work/showCommand.d.ts.map +1 -1
- package/dist/xy/common/work/syncCommand.d.ts.map +1 -1
- package/dist/xy/common/work/triageCommand.d.ts.map +1 -1
- package/dist/xy/common/work/updateCommand.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/bin/xy.mjs
CHANGED
|
@@ -12137,6 +12137,12 @@ const RULE_COMMANDS = {
|
|
|
12137
12137
|
configKey: "skillsLint",
|
|
12138
12138
|
includeInRoot: true,
|
|
12139
12139
|
title: "Skills Lint Rules"
|
|
12140
|
+
},
|
|
12141
|
+
workLint: {
|
|
12142
|
+
command: "work lint",
|
|
12143
|
+
configKey: "workLint",
|
|
12144
|
+
includeInRoot: true,
|
|
12145
|
+
title: "Work Lint Rules"
|
|
12140
12146
|
}
|
|
12141
12147
|
};
|
|
12142
12148
|
const DEPRECATED_CONFIG_KEY_ALIASES = {
|
|
@@ -41760,6 +41766,12 @@ const fix = async ({ jobs, pkg, verbose }) => {
|
|
|
41760
41766
|
...pkgOpts,
|
|
41761
41767
|
"--fix",
|
|
41762
41768
|
...verboseOpts
|
|
41769
|
+
]),
|
|
41770
|
+
pm.runXy([
|
|
41771
|
+
"lint",
|
|
41772
|
+
"lint",
|
|
41773
|
+
"--fix",
|
|
41774
|
+
...verboseOpts
|
|
41763
41775
|
])
|
|
41764
41776
|
], false);
|
|
41765
41777
|
};
|
|
@@ -51573,437 +51585,6 @@ const skillsLint = async (options = {}) => {
|
|
|
51573
51585
|
return result;
|
|
51574
51586
|
};
|
|
51575
51587
|
//#endregion
|
|
51576
|
-
//#region src/actions/ruleCatalog.ts
|
|
51577
|
-
const REPO_LINT_RULES = [
|
|
51578
|
-
[
|
|
51579
|
-
"repo.root-private",
|
|
51580
|
-
"Root package is private",
|
|
51581
|
-
"error",
|
|
51582
|
-
true
|
|
51583
|
-
],
|
|
51584
|
-
[
|
|
51585
|
-
"repo.no-private-publish-config",
|
|
51586
|
-
"Private root has no publishConfig",
|
|
51587
|
-
"error",
|
|
51588
|
-
true
|
|
51589
|
-
],
|
|
51590
|
-
[
|
|
51591
|
-
"repo.packages-folder",
|
|
51592
|
-
"Workspace packages live under packages/",
|
|
51593
|
-
"error",
|
|
51594
|
-
false
|
|
51595
|
-
],
|
|
51596
|
-
[
|
|
51597
|
-
"repo.spec-layout",
|
|
51598
|
-
"Spec files live in spec/ folders",
|
|
51599
|
-
"error",
|
|
51600
|
-
false
|
|
51601
|
-
],
|
|
51602
|
-
[
|
|
51603
|
-
"repo.workspaces-field-placement",
|
|
51604
|
-
"Workspace fields are declared in the package-manager-specific location",
|
|
51605
|
-
"error",
|
|
51606
|
-
true
|
|
51607
|
-
],
|
|
51608
|
-
[
|
|
51609
|
-
"repo.workspace-glob-coverage",
|
|
51610
|
-
"Workspace globs cover every package",
|
|
51611
|
-
"error",
|
|
51612
|
-
false
|
|
51613
|
-
],
|
|
51614
|
-
[
|
|
51615
|
-
"repo.no-package-manager-in-workspaces",
|
|
51616
|
-
"Only the root package declares packageManager",
|
|
51617
|
-
"error",
|
|
51618
|
-
true
|
|
51619
|
-
],
|
|
51620
|
-
[
|
|
51621
|
-
"repo.volta-only-root",
|
|
51622
|
-
"Only the root package declares volta",
|
|
51623
|
-
"error",
|
|
51624
|
-
true
|
|
51625
|
-
],
|
|
51626
|
-
[
|
|
51627
|
-
"repo.engines-non-terminal",
|
|
51628
|
-
"Only non-terminal packages declare engines",
|
|
51629
|
-
"error",
|
|
51630
|
-
true
|
|
51631
|
-
],
|
|
51632
|
-
[
|
|
51633
|
-
"repo.engines-lts",
|
|
51634
|
-
"Engine and volta versions include latest LTS",
|
|
51635
|
-
"error",
|
|
51636
|
-
false
|
|
51637
|
-
],
|
|
51638
|
-
[
|
|
51639
|
-
"repo.version-consistency",
|
|
51640
|
-
"Workspace versions are consistent",
|
|
51641
|
-
"error",
|
|
51642
|
-
true
|
|
51643
|
-
],
|
|
51644
|
-
[
|
|
51645
|
-
"repo.internal-dependency-ranges",
|
|
51646
|
-
"Internal dependencies use the expected workspace/version protocol",
|
|
51647
|
-
"error",
|
|
51648
|
-
true
|
|
51649
|
-
],
|
|
51650
|
-
[
|
|
51651
|
-
"repo.internal-peer-ranges",
|
|
51652
|
-
"Internal peerDependencies use publishable ranges",
|
|
51653
|
-
"error",
|
|
51654
|
-
true
|
|
51655
|
-
],
|
|
51656
|
-
[
|
|
51657
|
-
"repo.pnpm-release-age-excludes",
|
|
51658
|
-
"pnpm minimumReleaseAgeExclude matches imported scopes",
|
|
51659
|
-
"error",
|
|
51660
|
-
true
|
|
51661
|
-
],
|
|
51662
|
-
[
|
|
51663
|
-
"repo.pnpm-minimum-release-age",
|
|
51664
|
-
"pnpm minimumReleaseAge is configured",
|
|
51665
|
-
"error",
|
|
51666
|
-
true
|
|
51667
|
-
],
|
|
51668
|
-
[
|
|
51669
|
-
"repo.pnpm-no-overrides",
|
|
51670
|
-
"pnpm dependency overrides are not configured",
|
|
51671
|
-
"warn",
|
|
51672
|
-
false
|
|
51673
|
-
]
|
|
51674
|
-
].map(([id, description, defaultLevel, fixable]) => ({
|
|
51675
|
-
defaultLevel,
|
|
51676
|
-
description,
|
|
51677
|
-
fixable,
|
|
51678
|
-
id
|
|
51679
|
-
}));
|
|
51680
|
-
const NON_FIXABLE_DEAD_RULES = /* @__PURE__ */ new Set([
|
|
51681
|
-
"dead.repo.deprecated-export",
|
|
51682
|
-
"dead.workspace.deprecated-export",
|
|
51683
|
-
"dead.workspace.deprecated-unused-export"
|
|
51684
|
-
]);
|
|
51685
|
-
function isDeadRuleFixable(ruleId) {
|
|
51686
|
-
return !NON_FIXABLE_DEAD_RULES.has(ruleId);
|
|
51687
|
-
}
|
|
51688
|
-
function severityToLevel(severity, enabled = true) {
|
|
51689
|
-
if (!enabled) return "off";
|
|
51690
|
-
return severity === "error" ? "error" : "warn";
|
|
51691
|
-
}
|
|
51692
|
-
async function loadCommandConfig(commandName, pkg) {
|
|
51693
|
-
if (pkg !== void 0 && pkg.length > 0) {
|
|
51694
|
-
const workspace = getPackageManager().findWorkspace(pkg);
|
|
51695
|
-
if (workspace === void 0) throw new Error(`Workspace not found: ${pkg}`);
|
|
51696
|
-
return loadWorkspaceCommandConfig(workspace.location, commandName);
|
|
51697
|
-
}
|
|
51698
|
-
return loadWorkspaceCommandConfig(process.cwd(), commandName);
|
|
51699
|
-
}
|
|
51700
|
-
function staticCatalog(command, configKey, definitions, config) {
|
|
51701
|
-
const ruleSettings = config?.rules ?? {};
|
|
51702
|
-
const known = new Set(definitions.flatMap((rule) => [rule.id, ...rule.aliases ?? []]));
|
|
51703
|
-
const unknown = Object.keys(ruleSettings).filter((id) => !known.has(id));
|
|
51704
|
-
if (unknown.length > 0) throw new TypeError(`Unknown ${command} rule ${unknown.map((id) => `"${id}"`).join(", ")} in commands.${configKey}.rules`);
|
|
51705
|
-
const resolveSetting = (rule) => {
|
|
51706
|
-
if (ruleSettings[rule.id] !== void 0) return ruleSettings[rule.id];
|
|
51707
|
-
const aliases = rule.aliases ?? [];
|
|
51708
|
-
for (const alias of aliases) if (ruleSettings[alias] !== void 0) return ruleSettings[alias];
|
|
51709
|
-
};
|
|
51710
|
-
return definitions.map((rule) => ({
|
|
51711
|
-
command,
|
|
51712
|
-
defaultLevel: rule.defaultLevel,
|
|
51713
|
-
description: rule.description,
|
|
51714
|
-
fixable: rule.fixable === true,
|
|
51715
|
-
id: rule.id,
|
|
51716
|
-
level: parseRuleLevelSetting(ruleConfigPath(configKey, rule.id), resolveSetting(rule), rule.defaultLevel)
|
|
51717
|
-
}));
|
|
51718
|
-
}
|
|
51719
|
-
function runtimeRuleCatalog(command, configKey, definitions, config) {
|
|
51720
|
-
return staticCatalog(command, configKey, definitions, config);
|
|
51721
|
-
}
|
|
51722
|
-
function commandPrefix(prefix, rules) {
|
|
51723
|
-
return rules.map((rule) => ({
|
|
51724
|
-
...rule,
|
|
51725
|
-
command: `${prefix} ${rule.command}`
|
|
51726
|
-
}));
|
|
51727
|
-
}
|
|
51728
|
-
async function getDeplintRuleCatalog(pkg) {
|
|
51729
|
-
const config = await loadCommandConfig("deplint", pkg);
|
|
51730
|
-
const rules = await loadDeplintRules(config);
|
|
51731
|
-
const defaultRules = await loadDeplintRules(config === void 0 ? void 0 : {
|
|
51732
|
-
...config,
|
|
51733
|
-
rules: void 0
|
|
51734
|
-
});
|
|
51735
|
-
const defaults = new Map(defaultRules.map((rule) => [rule.id, severityToLevel(rule.meta.severity, rule.enabled !== false)]));
|
|
51736
|
-
return sortRules(rules.map((rule) => ({
|
|
51737
|
-
command: RULE_COMMANDS.deplint.command,
|
|
51738
|
-
defaultLevel: defaults.get(rule.id) ?? "warn",
|
|
51739
|
-
description: rule.meta.description,
|
|
51740
|
-
fixable: isRuleFixable(rule),
|
|
51741
|
-
id: rule.id,
|
|
51742
|
-
level: severityToLevel(rule.meta.severity, rule.enabled !== false)
|
|
51743
|
-
})));
|
|
51744
|
-
}
|
|
51745
|
-
async function getDeadRuleCatalog(pkg, options) {
|
|
51746
|
-
const config = await loadCommandConfig("dead", pkg);
|
|
51747
|
-
const rules = loadDeadRules(config, { deprecated: options?.deprecated === true });
|
|
51748
|
-
const defaultConfig = config === void 0 ? void 0 : {
|
|
51749
|
-
...config,
|
|
51750
|
-
rules: void 0
|
|
51751
|
-
};
|
|
51752
|
-
const defaults = new Map(loadDeadRules(defaultConfig, { deprecated: options?.deprecated === true }).map((rule) => [rule.id, severityToLevel(rule.meta.severity, rule.enabled)]));
|
|
51753
|
-
return sortRules(rules.map((rule) => ({
|
|
51754
|
-
command: RULE_COMMANDS.dead.command,
|
|
51755
|
-
defaultLevel: defaults.get(rule.id) ?? "warn",
|
|
51756
|
-
description: rule.meta.description,
|
|
51757
|
-
fixable: isDeadRuleFixable(rule.id),
|
|
51758
|
-
id: rule.id,
|
|
51759
|
-
level: severityToLevel(rule.meta.severity, rule.enabled)
|
|
51760
|
-
})));
|
|
51761
|
-
}
|
|
51762
|
-
async function getPublintRuleCatalog(command = RULE_COMMANDS.publint.command, pkg) {
|
|
51763
|
-
const levels = resolvePublintRuleLevels(await loadCommandConfig("publint", pkg));
|
|
51764
|
-
return ALL_PUBLINT_CHECKS.map((check) => ({
|
|
51765
|
-
command,
|
|
51766
|
-
defaultLevel: defaultPublintLevel(check),
|
|
51767
|
-
description: publintRuleDescription(check),
|
|
51768
|
-
fixable: publintRuleFixable(check),
|
|
51769
|
-
id: publintRuleId(check),
|
|
51770
|
-
level: levels.get(check) ?? "warn"
|
|
51771
|
-
}));
|
|
51772
|
-
}
|
|
51773
|
-
async function getApiExposureRuleCatalog(pkg) {
|
|
51774
|
-
const config = normalizeApiExposureConfig(await loadCommandConfig("apiExposure", pkg));
|
|
51775
|
-
const byId = new Map(config.rules.map((rule) => [rule.id, rule]));
|
|
51776
|
-
return AEI_RULES.map((rule) => {
|
|
51777
|
-
const resolved = byId.get(rule.id);
|
|
51778
|
-
return {
|
|
51779
|
-
command: RULE_COMMANDS.apiExposure.command,
|
|
51780
|
-
defaultLevel: rule.defaultEnabled === false ? "off" : "warn",
|
|
51781
|
-
description: rule.description,
|
|
51782
|
-
fixable: false,
|
|
51783
|
-
id: rule.id,
|
|
51784
|
-
level: resolved?.level ?? "warn",
|
|
51785
|
-
weight: resolved?.weight ?? rule.defaultWeight
|
|
51786
|
-
};
|
|
51787
|
-
});
|
|
51788
|
-
}
|
|
51789
|
-
async function getGitlintRuleCatalog() {
|
|
51790
|
-
return runtimeRuleCatalog(RULE_COMMANDS.gitLint.command, RULE_COMMANDS.gitLint.configKey, GITLINT_RULES, await loadCommandConfig("gitLint"));
|
|
51791
|
-
}
|
|
51792
|
-
async function getPackmanRuleCatalog() {
|
|
51793
|
-
return runtimeRuleCatalog(RULE_COMMANDS.packman.command, RULE_COMMANDS.packman.configKey, PACKMAN_RULES, await loadCommandConfig("packman"));
|
|
51794
|
-
}
|
|
51795
|
-
async function getRepoLintRuleCatalog() {
|
|
51796
|
-
return staticCatalog(RULE_COMMANDS.repoLint.command, RULE_COMMANDS.repoLint.configKey, REPO_LINT_RULES, await loadCommandConfig("repoLint"));
|
|
51797
|
-
}
|
|
51798
|
-
async function getNodeLintRuleCatalog() {
|
|
51799
|
-
return runtimeRuleCatalog(RULE_COMMANDS.nodeLint.command, RULE_COMMANDS.nodeLint.configKey, NODE_LINT_RULES, await loadCommandConfig("nodeLint"));
|
|
51800
|
-
}
|
|
51801
|
-
async function getLintlintRuleCatalog() {
|
|
51802
|
-
return runtimeRuleCatalog(RULE_COMMANDS.lintLint.command, RULE_COMMANDS.lintLint.configKey, LINTLINT_RULES, await loadCommandConfig("lintLint"));
|
|
51803
|
-
}
|
|
51804
|
-
async function getSkillsLintRuleCatalog() {
|
|
51805
|
-
return runtimeRuleCatalog(RULE_COMMANDS.skillsLint.command, RULE_COMMANDS.skillsLint.configKey, SKILLS_LINT_RULES, await loadCommandConfig("skillsLint"));
|
|
51806
|
-
}
|
|
51807
|
-
function parseEslintRuleLevel(setting) {
|
|
51808
|
-
let current = setting;
|
|
51809
|
-
while (Array.isArray(current) && current.length > 0) current = current[0];
|
|
51810
|
-
if (current === "error" || current === 2) return "error";
|
|
51811
|
-
if (current === "warn" || current === 1) return "warn";
|
|
51812
|
-
return "off";
|
|
51813
|
-
}
|
|
51814
|
-
function mergeEslintRules(configs) {
|
|
51815
|
-
const rules = /* @__PURE__ */ new Map();
|
|
51816
|
-
for (const config of configs) {
|
|
51817
|
-
if (config.rules === void 0) continue;
|
|
51818
|
-
for (const [id, setting] of Object.entries(config.rules)) rules.set(id, setting);
|
|
51819
|
-
}
|
|
51820
|
-
return rules;
|
|
51821
|
-
}
|
|
51822
|
-
function eslintRuleDescription(rule) {
|
|
51823
|
-
const description = rule?.meta?.docs?.description;
|
|
51824
|
-
return typeof description === "string" && description.length > 0 ? description : void 0;
|
|
51825
|
-
}
|
|
51826
|
-
function eslintRuleFixable(rule) {
|
|
51827
|
-
return rule?.meta?.fixable !== void 0;
|
|
51828
|
-
}
|
|
51829
|
-
function collectEslintRuleDescriptions(configs) {
|
|
51830
|
-
const descriptions = /* @__PURE__ */ new Map();
|
|
51831
|
-
for (const [id, rule] of builtinRules) {
|
|
51832
|
-
const description = eslintRuleDescription(rule);
|
|
51833
|
-
if (description !== void 0) descriptions.set(id, description);
|
|
51834
|
-
}
|
|
51835
|
-
for (const config of configs) {
|
|
51836
|
-
const plugins = Object.entries(config.plugins ?? {});
|
|
51837
|
-
for (const [pluginName, plugin] of plugins) {
|
|
51838
|
-
const rules = Object.entries(plugin?.rules ?? {});
|
|
51839
|
-
for (const [ruleName, rule] of rules) {
|
|
51840
|
-
const description = eslintRuleDescription(rule);
|
|
51841
|
-
if (description !== void 0) descriptions.set(`${pluginName}/${ruleName}`, description);
|
|
51842
|
-
}
|
|
51843
|
-
}
|
|
51844
|
-
}
|
|
51845
|
-
return descriptions;
|
|
51846
|
-
}
|
|
51847
|
-
function collectEslintRuleFixability(configs) {
|
|
51848
|
-
const fixability = /* @__PURE__ */ new Map();
|
|
51849
|
-
for (const [id, rule] of builtinRules) fixability.set(id, eslintRuleFixable(rule));
|
|
51850
|
-
for (const config of configs) {
|
|
51851
|
-
const plugins = Object.entries(config.plugins ?? {});
|
|
51852
|
-
for (const [pluginName, plugin] of plugins) {
|
|
51853
|
-
const rules = Object.entries(plugin?.rules ?? {});
|
|
51854
|
-
for (const [ruleName, rule] of rules) fixability.set(`${pluginName}/${ruleName}`, eslintRuleFixable(rule));
|
|
51855
|
-
}
|
|
51856
|
-
}
|
|
51857
|
-
return fixability;
|
|
51858
|
-
}
|
|
51859
|
-
async function getEslintRuleCatalog(command = RULE_COMMANDS.lint.command) {
|
|
51860
|
-
const configPath = await findUp(["eslint.config.ts", "eslint.config.mjs"]);
|
|
51861
|
-
if (configPath === void 0) return [];
|
|
51862
|
-
const module = await import(pathToFileURL(configPath).href);
|
|
51863
|
-
const configs = Array.isArray(module.default) ? module.default : [];
|
|
51864
|
-
const rules = mergeEslintRules(configs);
|
|
51865
|
-
const descriptions = collectEslintRuleDescriptions(configs);
|
|
51866
|
-
const fixability = collectEslintRuleFixability(configs);
|
|
51867
|
-
return rules.entries().map(([id, setting]) => ({
|
|
51868
|
-
command,
|
|
51869
|
-
defaultLevel: parseEslintRuleLevel(setting),
|
|
51870
|
-
description: descriptions.get(id),
|
|
51871
|
-
fixable: fixability.get(id) ?? false,
|
|
51872
|
-
id,
|
|
51873
|
-
level: parseEslintRuleLevel(setting),
|
|
51874
|
-
source: configPath
|
|
51875
|
-
})).toArray().toSorted((left, right) => left.id.localeCompare(right.id));
|
|
51876
|
-
}
|
|
51877
|
-
function getCycleRuleCatalog(depth = 25) {
|
|
51878
|
-
return [{
|
|
51879
|
-
command: RULE_COMMANDS.cycle.command,
|
|
51880
|
-
defaultLevel: "warn",
|
|
51881
|
-
description: `ESLint import cycle rule with maxDepth ${depth}`,
|
|
51882
|
-
fixable: false,
|
|
51883
|
-
id: "import-x/no-cycle",
|
|
51884
|
-
level: "warn"
|
|
51885
|
-
}];
|
|
51886
|
-
}
|
|
51887
|
-
async function loadDirectRuleCatalog() {
|
|
51888
|
-
return sortRules([...(await Promise.all([
|
|
51889
|
-
getApiExposureRuleCatalog(),
|
|
51890
|
-
getCleanRuleCatalog(),
|
|
51891
|
-
getDeadRuleCatalog(),
|
|
51892
|
-
getDeplintRuleCatalog(),
|
|
51893
|
-
getGitlintRuleCatalog(),
|
|
51894
|
-
getPackmanRuleCatalog(),
|
|
51895
|
-
getPublintRuleCatalog(),
|
|
51896
|
-
getRepoLintRuleCatalog(),
|
|
51897
|
-
getNodeLintRuleCatalog(),
|
|
51898
|
-
getLintlintRuleCatalog(),
|
|
51899
|
-
getSkillsLintRuleCatalog()
|
|
51900
|
-
])).flat(), ...getCycleRuleCatalog()]);
|
|
51901
|
-
}
|
|
51902
|
-
async function getCheckRuleCatalog() {
|
|
51903
|
-
return sortRules(commandPrefix("check", (await Promise.all([
|
|
51904
|
-
getGitlintRuleCatalog(),
|
|
51905
|
-
getPackmanRuleCatalog(),
|
|
51906
|
-
getPublintRuleCatalog(),
|
|
51907
|
-
getRepoLintRuleCatalog(),
|
|
51908
|
-
getLintlintRuleCatalog(),
|
|
51909
|
-
getSkillsLintRuleCatalog()
|
|
51910
|
-
])).flat()));
|
|
51911
|
-
}
|
|
51912
|
-
async function getFixRuleCatalog() {
|
|
51913
|
-
return sortRules(commandPrefix("fix", (await Promise.all([
|
|
51914
|
-
getGitlintRuleCatalog(),
|
|
51915
|
-
getDeplintRuleCatalog(),
|
|
51916
|
-
getRepoLintRuleCatalog(),
|
|
51917
|
-
getPublintRuleCatalog(),
|
|
51918
|
-
getEslintRuleCatalog("lint")
|
|
51919
|
-
])).flat()));
|
|
51920
|
-
}
|
|
51921
|
-
async function getMasterRuleCatalog() {
|
|
51922
|
-
return sortRules(await loadDirectRuleCatalog());
|
|
51923
|
-
}
|
|
51924
|
-
//#endregion
|
|
51925
|
-
//#region src/actions/secure.ts
|
|
51926
|
-
const secure = async ({ jobs = 16, pkg, verbose = false } = {}) => {
|
|
51927
|
-
return await runSecurityAudit(getPackageManager(), {
|
|
51928
|
-
concurrency: jobs,
|
|
51929
|
-
pkg,
|
|
51930
|
-
verbose
|
|
51931
|
-
});
|
|
51932
|
-
};
|
|
51933
|
-
//#endregion
|
|
51934
|
-
//#region src/actions/sitemap.ts
|
|
51935
|
-
const sitemap = () => {
|
|
51936
|
-
return runSteps("Sitemap", [["ts-node-script", "./scripts/sitemap.ts"]]);
|
|
51937
|
-
};
|
|
51938
|
-
//#endregion
|
|
51939
|
-
//#region src/actions/skills/updo.ts
|
|
51940
|
-
const SCOPE_FLAGS = /* @__PURE__ */ new Set([
|
|
51941
|
-
"-g",
|
|
51942
|
-
"--global",
|
|
51943
|
-
"-p",
|
|
51944
|
-
"--project"
|
|
51945
|
-
]);
|
|
51946
|
-
const hasSkillsScopeFlag = (args) => args.some((a) => SCOPE_FLAGS.has(a));
|
|
51947
|
-
const skillsUpdoArgs = (args) => {
|
|
51948
|
-
return ["update", ...hasSkillsScopeFlag(args) ? args : ["-p", ...args]];
|
|
51949
|
-
};
|
|
51950
|
-
const skillsUpdo = (args) => {
|
|
51951
|
-
return runSkills(skillsUpdoArgs(args));
|
|
51952
|
-
};
|
|
51953
|
-
//#endregion
|
|
51954
|
-
//#region src/actions/sonar.ts
|
|
51955
|
-
const sonar = () => {
|
|
51956
|
-
return runSteps("Sonar", [["eslint", [
|
|
51957
|
-
"-c",
|
|
51958
|
-
"sonar.eslintrc",
|
|
51959
|
-
"."
|
|
51960
|
-
]]]);
|
|
51961
|
-
};
|
|
51962
|
-
//#endregion
|
|
51963
|
-
//#region src/actions/start.ts
|
|
51964
|
-
const start = () => {
|
|
51965
|
-
return runSteps("Start", [[getPackageManager().command, "react-scripts start"]]);
|
|
51966
|
-
};
|
|
51967
|
-
//#endregion
|
|
51968
|
-
//#region src/actions/statics.ts
|
|
51969
|
-
const DefaultDependencies = [
|
|
51970
|
-
"axios",
|
|
51971
|
-
"@xylabs/pixel",
|
|
51972
|
-
"react",
|
|
51973
|
-
"graphql",
|
|
51974
|
-
"react-router",
|
|
51975
|
-
"@mui/material",
|
|
51976
|
-
"@mui/system"
|
|
51977
|
-
];
|
|
51978
|
-
const statics = () => {
|
|
51979
|
-
console.log(chalk.green("Check Required Static Dependencies"));
|
|
51980
|
-
const staticsValue = ((parsedPackageJSON()?.xy)?.deps)?.statics;
|
|
51981
|
-
const result = detectDuplicateDependencies(staticsValue, DefaultDependencies, false);
|
|
51982
|
-
return isStrictMode() ? result : 0;
|
|
51983
|
-
};
|
|
51984
|
-
//#endregion
|
|
51985
|
-
//#region src/actions/test.ts
|
|
51986
|
-
const test = ({ target } = {}) => {
|
|
51987
|
-
const pm = getPackageManager();
|
|
51988
|
-
if (target != null && target.length > 0 && pm.findWorkspace(target)) return runSteps(`Test [${target}]`, [pm.runInWorkspace(target, "vitest", ["."])]);
|
|
51989
|
-
return runSteps("Test", [["vitest", [target ?? "."]]]);
|
|
51990
|
-
};
|
|
51991
|
-
//#endregion
|
|
51992
|
-
//#region src/actions/up.ts
|
|
51993
|
-
const up = () => {
|
|
51994
|
-
return runSteps("Up", [getPackageManager().outdated()]);
|
|
51995
|
-
};
|
|
51996
|
-
//#endregion
|
|
51997
|
-
//#region src/actions/updo.ts
|
|
51998
|
-
const updo = async ({ jobs, latest = false, next = false, risk = "green" } = {}) => {
|
|
51999
|
-
return await runUpdo(getPackageManager(), {
|
|
52000
|
-
jobs,
|
|
52001
|
-
latest,
|
|
52002
|
-
next,
|
|
52003
|
-
risk
|
|
52004
|
-
});
|
|
52005
|
-
};
|
|
52006
|
-
//#endregion
|
|
52007
51588
|
//#region src/actions/work/id.ts
|
|
52008
51589
|
const formatWorkDate = (date) => {
|
|
52009
51590
|
return date.toISOString().slice(0, 10).replaceAll("-", "");
|
|
@@ -52247,6 +51828,12 @@ const readWorkConfig = (cwd = process.cwd()) => {
|
|
|
52247
51828
|
const paths = ensureWorkStore(cwd);
|
|
52248
51829
|
return validateWorkConfig(readJson(paths.configPath));
|
|
52249
51830
|
};
|
|
51831
|
+
/** Read config when the store already exists; does not create it. */
|
|
51832
|
+
const tryReadWorkConfig = (cwd = process.cwd()) => {
|
|
51833
|
+
const fixed = fixedWorkRootPaths(cwd);
|
|
51834
|
+
if (!existsSync(fixed.configPath)) return void 0;
|
|
51835
|
+
return validateWorkConfig(readJson(fixed.configPath));
|
|
51836
|
+
};
|
|
52250
51837
|
const workItemPath = (cwd, id) => {
|
|
52251
51838
|
assertSafeWorkId(id);
|
|
52252
51839
|
return PATH.resolve(workStorePaths(cwd, readWorkConfig(cwd)).itemsDir, `${id}.json`);
|
|
@@ -52264,6 +51851,17 @@ const readWorkItem = (cwd, id) => {
|
|
|
52264
51851
|
if (!existsSync(filePath)) throw new Error(`Work item not found: ${id}`);
|
|
52265
51852
|
return validateWorkItem(readJson(filePath));
|
|
52266
51853
|
};
|
|
51854
|
+
const workItemExists = (cwd, id) => {
|
|
51855
|
+
assertSafeWorkId(id);
|
|
51856
|
+
const config = tryReadWorkConfig(cwd);
|
|
51857
|
+
if (config === void 0) return false;
|
|
51858
|
+
return existsSync(PATH.resolve(workStorePaths(cwd, config).itemsDir, `${id}.json`));
|
|
51859
|
+
};
|
|
51860
|
+
const deleteWorkItem = (cwd, id) => {
|
|
51861
|
+
const filePath = workItemPath(cwd, id);
|
|
51862
|
+
if (!existsSync(filePath)) throw new Error(`Work item not found: ${id}`);
|
|
51863
|
+
unlinkSync(filePath);
|
|
51864
|
+
};
|
|
52267
51865
|
const listWorkItems = (cwd = process.cwd()) => {
|
|
52268
51866
|
const paths = workStorePaths(cwd, readWorkConfig(cwd));
|
|
52269
51867
|
return readdirSync(paths.itemsDir).filter((file) => file.endsWith(".json")).toSorted().map((file) => validateWorkItem(readJson(PATH.resolve(paths.itemsDir, file))));
|
|
@@ -52286,182 +51884,9 @@ const pathInsideRepo = (cwd, filePath) => {
|
|
|
52286
51884
|
relativePath: relativePath.split(PATH.sep).join("/")
|
|
52287
51885
|
};
|
|
52288
51886
|
};
|
|
52289
|
-
|
|
52290
|
-
|
|
52291
|
-
const markdownLikeExtensions = /* @__PURE__ */ new Set([
|
|
52292
|
-
".htm",
|
|
52293
|
-
".html",
|
|
52294
|
-
".md",
|
|
52295
|
-
".mdx"
|
|
52296
|
-
]);
|
|
52297
|
-
const markerForFile = (filePath, marker, id) => {
|
|
52298
|
-
const ext = PATH.extname(filePath).toLowerCase();
|
|
52299
|
-
if (markdownLikeExtensions.has(ext)) return `<!-- ${marker}: ${id} -->`;
|
|
52300
|
-
return `// ${marker}: ${id}`;
|
|
52301
|
-
};
|
|
52302
|
-
const insertInlineWorkMarker = ({ cwd, filePath, id, line, marker }) => {
|
|
52303
|
-
const { absolutePath, relativePath } = pathInsideRepo(cwd, filePath);
|
|
52304
|
-
if (!existsSync(absolutePath)) throw new Error(`Inline anchor file not found: ${relativePath}`);
|
|
52305
|
-
const markerText = markerForFile(absolutePath, marker, id);
|
|
52306
|
-
const original = readFileSync(absolutePath, "utf8");
|
|
52307
|
-
if (original.includes(markerText)) return relativePath;
|
|
52308
|
-
if (line === void 0) {
|
|
52309
|
-
writeFileSync(absolutePath, `${original}${original.endsWith("\n") || original.length === 0 ? "" : "\n"}${markerText}\n`, "utf8");
|
|
52310
|
-
return relativePath;
|
|
52311
|
-
}
|
|
52312
|
-
const lines = original.split("\n");
|
|
52313
|
-
const index = Math.max(0, Math.min(line - 1, lines.length));
|
|
52314
|
-
lines.splice(index, 0, markerText);
|
|
52315
|
-
writeFileSync(absolutePath, lines.join("\n"), "utf8");
|
|
52316
|
-
return relativePath;
|
|
52317
|
-
};
|
|
52318
|
-
//#endregion
|
|
52319
|
-
//#region src/actions/work/priority.ts
|
|
52320
|
-
const FIELD_SET = new Set(WORK_PRIORITY_FIELDS);
|
|
52321
|
-
const TERM_PATTERN = /([+-]?)\s*(impact|urgency|effort|risk|confidence)/g;
|
|
52322
|
-
const calculatePriorityScore = (priority, formula = DEFAULT_PRIORITY_FORMULA) => {
|
|
52323
|
-
if (priority === void 0) return void 0;
|
|
52324
|
-
let score = 0;
|
|
52325
|
-
let cursor = 0;
|
|
52326
|
-
for (const match of formula.matchAll(TERM_PATTERN)) {
|
|
52327
|
-
const index = match.index ?? 0;
|
|
52328
|
-
const skipped = formula.slice(cursor, index);
|
|
52329
|
-
if (!/^[\s+]*$/.test(skipped)) throw new Error(`Unsupported priority formula: ${formula}`);
|
|
52330
|
-
const operator = match[1] === "-" ? -1 : 1;
|
|
52331
|
-
const field = match[2];
|
|
52332
|
-
if (!FIELD_SET.has(field)) throw new Error(`Unknown priority field in formula: ${field}`);
|
|
52333
|
-
score += operator * priority[field];
|
|
52334
|
-
cursor = index + match[0].length;
|
|
52335
|
-
}
|
|
52336
|
-
if (!/^[\s+]*$/.test(formula.slice(cursor))) throw new Error(`Unsupported priority formula: ${formula}`);
|
|
52337
|
-
return score;
|
|
52338
|
-
};
|
|
52339
|
-
const compareWorkItemsByPriority = (a, b, formula = DEFAULT_PRIORITY_FORMULA) => {
|
|
52340
|
-
const aScore = calculatePriorityScore(a.priority, formula);
|
|
52341
|
-
const bScore = calculatePriorityScore(b.priority, formula);
|
|
52342
|
-
if (aScore !== void 0 && bScore !== void 0 && aScore !== bScore) return bScore - aScore;
|
|
52343
|
-
if (aScore !== void 0 && bScore === void 0) return -1;
|
|
52344
|
-
if (aScore === void 0 && bScore !== void 0) return 1;
|
|
52345
|
-
return a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id);
|
|
52346
|
-
};
|
|
52347
|
-
const priorityFromPartial = (partial) => {
|
|
52348
|
-
if (Object.values(partial).every((value) => value === void 0)) return void 0;
|
|
52349
|
-
return {
|
|
52350
|
-
confidence: partial.confidence ?? 3,
|
|
52351
|
-
effort: partial.effort ?? 3,
|
|
52352
|
-
impact: partial.impact ?? 3,
|
|
52353
|
-
risk: partial.risk ?? 3,
|
|
52354
|
-
urgency: partial.urgency ?? 3
|
|
52355
|
-
};
|
|
52356
|
-
};
|
|
52357
|
-
//#endregion
|
|
52358
|
-
//#region src/actions/work/render.ts
|
|
52359
|
-
const maxWidth = (headerLabel, values, max = Infinity) => {
|
|
52360
|
-
return Math.min(max, Math.max(headerLabel.length, ...values.map((value) => value.length)));
|
|
52361
|
-
};
|
|
52362
|
-
const resolveTableWidth = () => {
|
|
52363
|
-
const columns = process.stdout.isTTY ? process.stdout.columns : void 0;
|
|
52364
|
-
return Math.max(72, Math.min(columns ?? 120, 160) - 2);
|
|
52365
|
-
};
|
|
52366
|
-
const resolveWorkTableWidths = (rows) => {
|
|
52367
|
-
const tableChromeWidth = 19;
|
|
52368
|
-
const id = maxWidth("ID", rows.map((row) => row.id), 28);
|
|
52369
|
-
const status = maxWidth("Status", rows.map((row) => row.status), 12);
|
|
52370
|
-
const type = maxWidth("Type", rows.map((row) => row.type), 12);
|
|
52371
|
-
const score = maxWidth("Score", rows.map((row) => row.score), 8);
|
|
52372
|
-
const area = maxWidth("Area", rows.map((row) => row.area), 20);
|
|
52373
|
-
const fixedWidth = tableChromeWidth + id + status + type + score + area;
|
|
52374
|
-
const availableTitle = Math.max(20, resolveTableWidth() - fixedWidth);
|
|
52375
|
-
const naturalTitle = maxWidth("Title", rows.map((row) => row.title), 72);
|
|
52376
|
-
return {
|
|
52377
|
-
area,
|
|
52378
|
-
id,
|
|
52379
|
-
score,
|
|
52380
|
-
status,
|
|
52381
|
-
title: Math.min(naturalTitle, availableTitle),
|
|
52382
|
-
type
|
|
52383
|
-
};
|
|
52384
|
-
};
|
|
52385
|
-
const workTableConfig = (widths) => ({
|
|
52386
|
-
border: (0, import_src.getBorderCharacters)("norc"),
|
|
52387
|
-
columnDefault: {
|
|
52388
|
-
paddingLeft: 1,
|
|
52389
|
-
paddingRight: 1,
|
|
52390
|
-
wrapWord: true
|
|
52391
|
-
},
|
|
52392
|
-
columns: {
|
|
52393
|
-
0: { width: widths.id },
|
|
52394
|
-
1: { width: widths.status },
|
|
52395
|
-
2: { width: widths.type },
|
|
52396
|
-
3: {
|
|
52397
|
-
alignment: "right",
|
|
52398
|
-
width: widths.score
|
|
52399
|
-
},
|
|
52400
|
-
4: { width: widths.area },
|
|
52401
|
-
5: { width: widths.title }
|
|
52402
|
-
},
|
|
52403
|
-
drawHorizontalLine: (index, size) => [
|
|
52404
|
-
0,
|
|
52405
|
-
1,
|
|
52406
|
-
size
|
|
52407
|
-
].includes(index)
|
|
52408
|
-
});
|
|
52409
|
-
const toRow = (item, formula) => {
|
|
52410
|
-
const score = calculatePriorityScore(item.priority, formula);
|
|
52411
|
-
return {
|
|
52412
|
-
area: item.area ?? "-",
|
|
52413
|
-
id: item.id,
|
|
52414
|
-
score: score === void 0 ? "-" : String(score),
|
|
52415
|
-
status: item.status,
|
|
52416
|
-
title: item.title,
|
|
52417
|
-
type: item.type
|
|
52418
|
-
};
|
|
52419
|
-
};
|
|
52420
|
-
const formatWorkTable = (items, formula) => {
|
|
52421
|
-
const rows = items.map((item) => toRow(item, formula));
|
|
52422
|
-
const widths = resolveWorkTableWidths(rows);
|
|
52423
|
-
return (0, import_src.table)([[
|
|
52424
|
-
chalk.gray.bold("ID"),
|
|
52425
|
-
chalk.gray.bold("Status"),
|
|
52426
|
-
chalk.gray.bold("Type"),
|
|
52427
|
-
chalk.gray.bold("Score"),
|
|
52428
|
-
chalk.gray.bold("Area"),
|
|
52429
|
-
chalk.gray.bold("Title")
|
|
52430
|
-
], ...rows.map((row) => [
|
|
52431
|
-
chalk.cyan(row.id),
|
|
52432
|
-
chalk.white(row.status),
|
|
52433
|
-
chalk.white(row.type),
|
|
52434
|
-
chalk.gray(row.score),
|
|
52435
|
-
chalk.gray(row.area),
|
|
52436
|
-
chalk.white(row.title)
|
|
52437
|
-
])], workTableConfig(widths)).trimEnd();
|
|
52438
|
-
};
|
|
52439
|
-
const printWorkItemsTable = (items, formula) => {
|
|
52440
|
-
if (isJsonMode()) return;
|
|
52441
|
-
if (items.length === 0) {
|
|
52442
|
-
xyLog("No work items");
|
|
52443
|
-
return;
|
|
52444
|
-
}
|
|
52445
|
-
xyLog(formatWorkTable(items, formula));
|
|
52446
|
-
};
|
|
52447
|
-
const printWorkItemSummary = (item, score) => {
|
|
52448
|
-
const scoreText = score === void 0 ? "-" : String(score);
|
|
52449
|
-
xyLog(`${item.id}\t${item.status}\t${item.type}\t${scoreText}\t${item.title}`);
|
|
52450
|
-
};
|
|
52451
|
-
//#endregion
|
|
52452
|
-
//#region src/actions/work/result.ts
|
|
52453
|
-
const cleanResult = (data) => {
|
|
52454
|
-
return {
|
|
52455
|
-
envelope: {
|
|
52456
|
-
data,
|
|
52457
|
-
errorCount: 0,
|
|
52458
|
-
warningCount: 0
|
|
52459
|
-
},
|
|
52460
|
-
exitCode: 0,
|
|
52461
|
-
data
|
|
52462
|
-
};
|
|
51887
|
+
const workStoreExists = (cwd = process.cwd()) => {
|
|
51888
|
+
return existsSync(fixedWorkRootPaths(cwd).configPath);
|
|
52463
51889
|
};
|
|
52464
|
-
const nowIso = (now = /* @__PURE__ */ new Date()) => now.toISOString();
|
|
52465
51890
|
//#endregion
|
|
52466
51891
|
//#region src/actions/work/github.ts
|
|
52467
51892
|
/** Label applied to every GitHub issue created by `xy work`. */
|
|
@@ -52722,6 +52147,20 @@ const createGithubWorkBridge = (runner = defaultGithubWorkRunner) => {
|
|
|
52722
52147
|
};
|
|
52723
52148
|
const defaultGithubWorkBridge = createGithubWorkBridge();
|
|
52724
52149
|
//#endregion
|
|
52150
|
+
//#region src/actions/work/result.ts
|
|
52151
|
+
const cleanResult = (data) => {
|
|
52152
|
+
return {
|
|
52153
|
+
envelope: {
|
|
52154
|
+
data,
|
|
52155
|
+
errorCount: 0,
|
|
52156
|
+
warningCount: 0
|
|
52157
|
+
},
|
|
52158
|
+
exitCode: 0,
|
|
52159
|
+
data
|
|
52160
|
+
};
|
|
52161
|
+
};
|
|
52162
|
+
const nowIso = (now = /* @__PURE__ */ new Date()) => now.toISOString();
|
|
52163
|
+
//#endregion
|
|
52725
52164
|
//#region src/actions/work/sync.ts
|
|
52726
52165
|
const resolveGithubBridge = (config, cwd, bridge = defaultGithubWorkBridge) => {
|
|
52727
52166
|
if (!config.stores.github.enabled) return void 0;
|
|
@@ -52754,261 +52193,1808 @@ const emptySyncSummary = () => ({
|
|
|
52754
52193
|
updatedGithub: [],
|
|
52755
52194
|
updatedLocal: []
|
|
52756
52195
|
});
|
|
52757
|
-
const withGithubLink = (item, number, url, createdByXyWork) => {
|
|
52196
|
+
const withGithubLink$1 = (item, number, url, createdByXyWork) => {
|
|
52197
|
+
return {
|
|
52198
|
+
...item,
|
|
52199
|
+
stores: {
|
|
52200
|
+
...item.stores,
|
|
52201
|
+
github: {
|
|
52202
|
+
createdByXyWork,
|
|
52203
|
+
number,
|
|
52204
|
+
...!createdByXyWork && { source: "github" },
|
|
52205
|
+
url
|
|
52206
|
+
}
|
|
52207
|
+
}
|
|
52208
|
+
};
|
|
52209
|
+
};
|
|
52210
|
+
const importGithubIssueLocally = (cwd, issue, now, preferredId) => {
|
|
52211
|
+
const base = normalizeGithubIssueToWorkItem(issue);
|
|
52212
|
+
const id = preferredId ?? base.id;
|
|
52213
|
+
const createdByXyWork = isXyWorkGithubIssue(issue);
|
|
52214
|
+
const open = githubIssueIsOpen(issue);
|
|
52215
|
+
const item = {
|
|
52216
|
+
...base,
|
|
52217
|
+
completedAt: open ? void 0 : base.updatedAt || nowIso(now),
|
|
52218
|
+
id,
|
|
52219
|
+
status: open ? "open" : "done",
|
|
52220
|
+
stores: { github: {
|
|
52221
|
+
createdByXyWork,
|
|
52222
|
+
number: issue.number,
|
|
52223
|
+
...!createdByXyWork && { source: "github" },
|
|
52224
|
+
url: issue.url
|
|
52225
|
+
} },
|
|
52226
|
+
updatedAt: nowIso(now)
|
|
52227
|
+
};
|
|
52228
|
+
writeWorkItem(cwd, item);
|
|
52229
|
+
return item;
|
|
52230
|
+
};
|
|
52231
|
+
const createMissingGithubIssues = (cwd, localItems, github, issuesByNumber, summary, now) => {
|
|
52232
|
+
for (const item of localItems) {
|
|
52233
|
+
if (readGithubStoreNumber(item.stores) !== void 0) continue;
|
|
52234
|
+
if (isTerminalWorkStatus(item.status)) continue;
|
|
52235
|
+
try {
|
|
52236
|
+
const ref = github.createIssue(cwd, item);
|
|
52237
|
+
const linked = {
|
|
52238
|
+
...withGithubLink$1(item, ref.number, ref.url, true),
|
|
52239
|
+
updatedAt: nowIso(now)
|
|
52240
|
+
};
|
|
52241
|
+
writeWorkItem(cwd, linked);
|
|
52242
|
+
summary.createdGithub.push(`${item.id}→#${String(ref.number)}`);
|
|
52243
|
+
issuesByNumber.set(ref.number, {
|
|
52244
|
+
body: formatGithubWorkIssueBody(linked),
|
|
52245
|
+
createdAt: linked.createdAt,
|
|
52246
|
+
labels: ["xy-work"],
|
|
52247
|
+
number: ref.number,
|
|
52248
|
+
state: "OPEN",
|
|
52249
|
+
title: linked.title,
|
|
52250
|
+
updatedAt: linked.updatedAt,
|
|
52251
|
+
url: ref.url
|
|
52252
|
+
});
|
|
52253
|
+
} catch (error) {
|
|
52254
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
52255
|
+
xyLog(`Sync create failed for ${item.id}: ${message}`);
|
|
52256
|
+
}
|
|
52257
|
+
}
|
|
52258
|
+
};
|
|
52259
|
+
const attachOrImportGithubIssues = (cwd, issuesByNumber, summary, now) => {
|
|
52260
|
+
const localItems = listWorkItems(cwd);
|
|
52261
|
+
const localById = new Map(localItems.map((item) => [item.id, item]));
|
|
52262
|
+
const linkedNumbers = linkedGithubNumbers(localItems);
|
|
52263
|
+
for (const issue of issuesByNumber.values()) {
|
|
52264
|
+
if (linkedNumbers.has(issue.number)) continue;
|
|
52265
|
+
const xyWorkId = isXyWorkGithubIssue(issue) ? parseXyWorkIdFromGithubBody(issue.body) : void 0;
|
|
52266
|
+
if (xyWorkId !== void 0 && localById.has(xyWorkId)) {
|
|
52267
|
+
const existing = localById.get(xyWorkId);
|
|
52268
|
+
if (existing === void 0) continue;
|
|
52269
|
+
if (readGithubStoreNumber(existing.stores) === void 0) {
|
|
52270
|
+
const linked = {
|
|
52271
|
+
...withGithubLink$1(existing, issue.number, issue.url, true),
|
|
52272
|
+
updatedAt: nowIso(now)
|
|
52273
|
+
};
|
|
52274
|
+
writeWorkItem(cwd, linked);
|
|
52275
|
+
localById.set(xyWorkId, linked);
|
|
52276
|
+
linkedNumbers.add(issue.number);
|
|
52277
|
+
summary.updatedLocal.push(`${xyWorkId}↔#${String(issue.number)}`);
|
|
52278
|
+
}
|
|
52279
|
+
continue;
|
|
52280
|
+
}
|
|
52281
|
+
if (!githubIssueIsOpen(issue) && !isXyWorkGithubIssue(issue)) continue;
|
|
52282
|
+
const preferredId = xyWorkId;
|
|
52283
|
+
if (preferredId !== void 0 && localById.has(preferredId)) continue;
|
|
52284
|
+
try {
|
|
52285
|
+
const imported = importGithubIssueLocally(cwd, issue, now ?? /* @__PURE__ */ new Date(), preferredId);
|
|
52286
|
+
localById.set(imported.id, imported);
|
|
52287
|
+
linkedNumbers.add(issue.number);
|
|
52288
|
+
summary.importedLocal.push(`${imported.id}←#${String(issue.number)}`);
|
|
52289
|
+
} catch (error) {
|
|
52290
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
52291
|
+
xyLog(`Sync import failed for GitHub #${String(issue.number)}: ${message}`);
|
|
52292
|
+
}
|
|
52293
|
+
}
|
|
52294
|
+
};
|
|
52295
|
+
const reconcileTitleDrift = (cwd, github, item, issue, number, summary, now) => {
|
|
52296
|
+
if (item.title === issue.title) return {
|
|
52297
|
+
localChanged: false,
|
|
52298
|
+
next: item
|
|
52299
|
+
};
|
|
52300
|
+
if (item.updatedAt.localeCompare(issue.updatedAt) >= 0) {
|
|
52301
|
+
github.updateIssue(cwd, number, {
|
|
52302
|
+
body: formatGithubWorkIssueBody(item),
|
|
52303
|
+
title: item.title
|
|
52304
|
+
});
|
|
52305
|
+
summary.updatedGithub.push(`${item.id}→#${String(number)}`);
|
|
52306
|
+
issue.title = item.title;
|
|
52307
|
+
issue.updatedAt = nowIso(now);
|
|
52308
|
+
return {
|
|
52309
|
+
localChanged: false,
|
|
52310
|
+
next: item
|
|
52311
|
+
};
|
|
52312
|
+
}
|
|
52313
|
+
return {
|
|
52314
|
+
localChanged: true,
|
|
52315
|
+
next: {
|
|
52316
|
+
...item,
|
|
52317
|
+
title: issue.title,
|
|
52318
|
+
updatedAt: nowIso(now)
|
|
52319
|
+
}
|
|
52320
|
+
};
|
|
52321
|
+
};
|
|
52322
|
+
const ensureGithubStoreUrl = (item, issue, number) => {
|
|
52323
|
+
const url = readGithubStoreUrl(item.stores) ?? issue.url;
|
|
52324
|
+
if (readGithubStoreUrl(item.stores) === url) return {
|
|
52325
|
+
localChanged: false,
|
|
52326
|
+
next: item
|
|
52327
|
+
};
|
|
52328
|
+
const store = item.stores.github;
|
|
52329
|
+
const createdByXyWork = isXyWorkGithubIssue(issue) || typeof store === "object" && store !== null && store.createdByXyWork === true;
|
|
52330
|
+
return {
|
|
52331
|
+
localChanged: true,
|
|
52332
|
+
next: withGithubLink$1(item, number, url, createdByXyWork)
|
|
52333
|
+
};
|
|
52334
|
+
};
|
|
52335
|
+
const reconcileLinkedItem = (cwd, github, item, issue, number, summary, now) => {
|
|
52336
|
+
let next = item;
|
|
52337
|
+
let localChanged = false;
|
|
52338
|
+
const issueOpen = githubIssueIsOpen(issue);
|
|
52339
|
+
const localTerminal = isTerminalWorkStatus(item.status);
|
|
52340
|
+
if (localTerminal && issueOpen) {
|
|
52341
|
+
github.updateIssue(cwd, number, { state: "closed" });
|
|
52342
|
+
summary.closedGithub.push(`${item.id}→#${String(number)}`);
|
|
52343
|
+
issue.state = "CLOSED";
|
|
52344
|
+
} else if (!localTerminal && !issueOpen) {
|
|
52345
|
+
next = {
|
|
52346
|
+
...next,
|
|
52347
|
+
completedAt: next.completedAt ?? issue.updatedAt,
|
|
52348
|
+
status: "done",
|
|
52349
|
+
updatedAt: nowIso(now),
|
|
52350
|
+
verification: [.../* @__PURE__ */ new Set([...next.verification, `synced closed from GitHub #${String(number)}`])]
|
|
52351
|
+
};
|
|
52352
|
+
localChanged = true;
|
|
52353
|
+
} else if (!localTerminal && issueOpen) {
|
|
52354
|
+
const titleResult = reconcileTitleDrift(cwd, github, next, issue, number, summary, now);
|
|
52355
|
+
next = titleResult.next;
|
|
52356
|
+
localChanged ||= titleResult.localChanged;
|
|
52357
|
+
}
|
|
52358
|
+
const urlResult = ensureGithubStoreUrl(next, issue, number);
|
|
52359
|
+
next = urlResult.next;
|
|
52360
|
+
localChanged ||= urlResult.localChanged;
|
|
52361
|
+
if (localChanged) {
|
|
52362
|
+
writeWorkItem(cwd, next);
|
|
52363
|
+
summary.updatedLocal.push(`${next.id}←#${String(number)}`);
|
|
52364
|
+
}
|
|
52365
|
+
};
|
|
52366
|
+
const reconcileLinkedPairs = (cwd, github, issuesByNumber, summary, now) => {
|
|
52367
|
+
for (const item of listWorkItems(cwd)) {
|
|
52368
|
+
const number = readGithubStoreNumber(item.stores);
|
|
52369
|
+
if (number === void 0) continue;
|
|
52370
|
+
const issue = issuesByNumber.get(number);
|
|
52371
|
+
if (issue === void 0) continue;
|
|
52372
|
+
try {
|
|
52373
|
+
reconcileLinkedItem(cwd, github, item, issue, number, summary, now);
|
|
52374
|
+
} catch (error) {
|
|
52375
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
52376
|
+
xyLog(`Sync reconcile failed for ${item.id}/#${String(number)}: ${message}`);
|
|
52377
|
+
}
|
|
52378
|
+
}
|
|
52379
|
+
};
|
|
52380
|
+
const logSyncSummary = (summary) => {
|
|
52381
|
+
if (summary.createdGithub.length + summary.importedLocal.length + summary.updatedLocal.length + summary.updatedGithub.length + summary.closedGithub.length + summary.reopenedGithub.length === 0) {
|
|
52382
|
+
xyLog("GitHub sync: already in sync");
|
|
52383
|
+
return;
|
|
52384
|
+
}
|
|
52385
|
+
xyLog([
|
|
52386
|
+
"GitHub sync complete:",
|
|
52387
|
+
` created GitHub: ${String(summary.createdGithub.length)}`,
|
|
52388
|
+
` imported local: ${String(summary.importedLocal.length)}`,
|
|
52389
|
+
` updated local: ${String(summary.updatedLocal.length)}`,
|
|
52390
|
+
` updated GitHub: ${String(summary.updatedGithub.length)}`,
|
|
52391
|
+
` closed GitHub: ${String(summary.closedGithub.length)}`
|
|
52392
|
+
].join("\n"));
|
|
52393
|
+
};
|
|
52394
|
+
const emptyWorkSyncDrift = () => ({
|
|
52395
|
+
githubMissingLocal: [],
|
|
52396
|
+
localMissingGithub: [],
|
|
52397
|
+
statusMismatch: [],
|
|
52398
|
+
titleMismatch: []
|
|
52399
|
+
});
|
|
52400
|
+
const workSyncDriftIsClean = (drift) => {
|
|
52401
|
+
return drift.githubMissingLocal.length === 0 && drift.localMissingGithub.length === 0 && drift.statusMismatch.length === 0 && drift.titleMismatch.length === 0;
|
|
52402
|
+
};
|
|
52403
|
+
const recordLocalMissingGithub = (localItems, drift) => {
|
|
52404
|
+
for (const item of localItems) {
|
|
52405
|
+
if (isTerminalWorkStatus(item.status)) continue;
|
|
52406
|
+
if (readGithubStoreNumber(item.stores) === void 0) drift.localMissingGithub.push(item.id);
|
|
52407
|
+
}
|
|
52408
|
+
};
|
|
52409
|
+
const recordLinkedPairDrift = (issue, linked, drift) => {
|
|
52410
|
+
if (linked.title !== issue.title) drift.titleMismatch.push(`${linked.id}/#${String(issue.number)}`);
|
|
52411
|
+
const issueOpen = githubIssueIsOpen(issue);
|
|
52412
|
+
const localTerminal = isTerminalWorkStatus(linked.status);
|
|
52413
|
+
if (localTerminal && issueOpen) {
|
|
52414
|
+
drift.statusMismatch.push(`${linked.id} done/wontfix but GitHub #${String(issue.number)} open`);
|
|
52415
|
+
return;
|
|
52416
|
+
}
|
|
52417
|
+
if (!localTerminal && !issueOpen) drift.statusMismatch.push(`${linked.id} open locally but GitHub #${String(issue.number)} closed`);
|
|
52418
|
+
};
|
|
52419
|
+
const recordUnlinkedXyWorkDrift = (issue, localById, drift) => {
|
|
52420
|
+
if (!isXyWorkGithubIssue(issue)) return;
|
|
52421
|
+
const preferredId = parseXyWorkIdFromGithubBody(issue.body);
|
|
52422
|
+
if (preferredId !== void 0 && localById.has(preferredId)) {
|
|
52423
|
+
drift.githubMissingLocal.push(`#${String(issue.number)}↔${preferredId} (unlinked)`);
|
|
52424
|
+
return;
|
|
52425
|
+
}
|
|
52426
|
+
drift.githubMissingLocal.push(preferredId === void 0 ? `#${String(issue.number)} (${issue.title})` : `#${String(issue.number)}→${preferredId}`);
|
|
52427
|
+
};
|
|
52428
|
+
/**
|
|
52429
|
+
* Compute local ↔ GitHub drift without mutating either side.
|
|
52430
|
+
* Returns empty drift when GitHub is unavailable or disabled.
|
|
52431
|
+
*/
|
|
52432
|
+
const computeWorkSyncDrift = (cwd, options = {}) => {
|
|
52433
|
+
const config = options.config ?? readWorkConfig(cwd);
|
|
52434
|
+
const drift = emptyWorkSyncDrift();
|
|
52435
|
+
const github = resolveGithubBridge(config, cwd, options.github);
|
|
52436
|
+
if (github === void 0) return drift;
|
|
52437
|
+
const localItems = listWorkItems(cwd);
|
|
52438
|
+
const localById = new Map(localItems.map((item) => [item.id, item]));
|
|
52439
|
+
const linkedNumbers = linkedGithubNumbers(localItems);
|
|
52440
|
+
recordLocalMissingGithub(localItems, drift);
|
|
52441
|
+
let issues;
|
|
52442
|
+
try {
|
|
52443
|
+
issues = github.listIssues(cwd, "all");
|
|
52444
|
+
} catch {
|
|
52445
|
+
return drift;
|
|
52446
|
+
}
|
|
52447
|
+
for (const issue of issues) {
|
|
52448
|
+
if (linkedNumbers.has(issue.number)) {
|
|
52449
|
+
const linked = localItems.find((item) => readGithubStoreNumber(item.stores) === issue.number);
|
|
52450
|
+
if (linked !== void 0) recordLinkedPairDrift(issue, linked, drift);
|
|
52451
|
+
continue;
|
|
52452
|
+
}
|
|
52453
|
+
recordUnlinkedXyWorkDrift(issue, localById, drift);
|
|
52454
|
+
}
|
|
52455
|
+
return drift;
|
|
52456
|
+
};
|
|
52457
|
+
/**
|
|
52458
|
+
* Bidirectional sync between repo-local work items and GitHub Issues when available.
|
|
52459
|
+
*
|
|
52460
|
+
* - Local active items without a GitHub link → create a marked GitHub issue
|
|
52461
|
+
* - Open/closed GitHub issues not present locally → import as local items
|
|
52462
|
+
* - Linked pairs: reconcile title (newer wins) and status (done/wontfix ↔ closed)
|
|
52463
|
+
*/
|
|
52464
|
+
const workSync = (options = {}) => {
|
|
52465
|
+
const cwd = options.cwd ?? process.cwd();
|
|
52466
|
+
const config = readWorkConfig(cwd);
|
|
52467
|
+
const summary = emptySyncSummary();
|
|
52468
|
+
const github = resolveGithubBridge(config, cwd, options.github);
|
|
52469
|
+
if (github === void 0) {
|
|
52470
|
+
xyLog("GitHub sync skipped: GitHub Issues unavailable or disabled");
|
|
52471
|
+
return cleanResult({ summary });
|
|
52472
|
+
}
|
|
52473
|
+
const issuesByNumber = /* @__PURE__ */ new Map();
|
|
52474
|
+
for (const issue of github.listIssues(cwd, "all")) issuesByNumber.set(issue.number, issue);
|
|
52475
|
+
createMissingGithubIssues(cwd, listWorkItems(cwd), github, issuesByNumber, summary, options.now);
|
|
52476
|
+
attachOrImportGithubIssues(cwd, issuesByNumber, summary, options.now);
|
|
52477
|
+
reconcileLinkedPairs(cwd, github, issuesByNumber, summary, options.now);
|
|
52478
|
+
logSyncSummary(summary);
|
|
52479
|
+
return cleanResult({ summary });
|
|
52480
|
+
};
|
|
52481
|
+
//#endregion
|
|
52482
|
+
//#region src/actions/work/priority.ts
|
|
52483
|
+
const FIELD_SET = new Set(WORK_PRIORITY_FIELDS);
|
|
52484
|
+
const TERM_PATTERN = /([+-]?)\s*(impact|urgency|effort|risk|confidence)/g;
|
|
52485
|
+
const calculatePriorityScore = (priority, formula = DEFAULT_PRIORITY_FORMULA) => {
|
|
52486
|
+
if (priority === void 0) return void 0;
|
|
52487
|
+
let score = 0;
|
|
52488
|
+
let cursor = 0;
|
|
52489
|
+
for (const match of formula.matchAll(TERM_PATTERN)) {
|
|
52490
|
+
const index = match.index ?? 0;
|
|
52491
|
+
const skipped = formula.slice(cursor, index);
|
|
52492
|
+
if (!/^[\s+]*$/.test(skipped)) throw new Error(`Unsupported priority formula: ${formula}`);
|
|
52493
|
+
const operator = match[1] === "-" ? -1 : 1;
|
|
52494
|
+
const field = match[2];
|
|
52495
|
+
if (!FIELD_SET.has(field)) throw new Error(`Unknown priority field in formula: ${field}`);
|
|
52496
|
+
score += operator * priority[field];
|
|
52497
|
+
cursor = index + match[0].length;
|
|
52498
|
+
}
|
|
52499
|
+
if (!/^[\s+]*$/.test(formula.slice(cursor))) throw new Error(`Unsupported priority formula: ${formula}`);
|
|
52500
|
+
return score;
|
|
52501
|
+
};
|
|
52502
|
+
const compareWorkItemsByPriority = (a, b, formula = DEFAULT_PRIORITY_FORMULA) => {
|
|
52503
|
+
const aScore = calculatePriorityScore(a.priority, formula);
|
|
52504
|
+
const bScore = calculatePriorityScore(b.priority, formula);
|
|
52505
|
+
if (aScore !== void 0 && bScore !== void 0 && aScore !== bScore) return bScore - aScore;
|
|
52506
|
+
if (aScore !== void 0 && bScore === void 0) return -1;
|
|
52507
|
+
if (aScore === void 0 && bScore !== void 0) return 1;
|
|
52508
|
+
return a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id);
|
|
52509
|
+
};
|
|
52510
|
+
const priorityFromPartial = (partial) => {
|
|
52511
|
+
if (Object.values(partial).every((value) => value === void 0)) return void 0;
|
|
52512
|
+
return {
|
|
52513
|
+
confidence: partial.confidence ?? 3,
|
|
52514
|
+
effort: partial.effort ?? 3,
|
|
52515
|
+
impact: partial.impact ?? 3,
|
|
52516
|
+
risk: partial.risk ?? 3,
|
|
52517
|
+
urgency: partial.urgency ?? 3
|
|
52518
|
+
};
|
|
52519
|
+
};
|
|
52520
|
+
//#endregion
|
|
52521
|
+
//#region src/actions/work/workspace.ts
|
|
52522
|
+
const isWorkspaceScope = (options) => {
|
|
52523
|
+
return options.workspace === true || options.workspaceFile !== void 0 && options.workspaceFile.length > 0;
|
|
52524
|
+
};
|
|
52525
|
+
const singleRepo = (cwd) => {
|
|
52526
|
+
return {
|
|
52527
|
+
cwd: PATH.resolve(cwd),
|
|
52528
|
+
hasStore: workStoreExists(cwd),
|
|
52529
|
+
name: PATH.basename(PATH.resolve(cwd))
|
|
52530
|
+
};
|
|
52531
|
+
};
|
|
52532
|
+
const preferredFolderName = (absolutePath, explicitName) => {
|
|
52533
|
+
if (explicitName !== void 0 && explicitName.length > 0) return explicitName;
|
|
52534
|
+
return PATH.basename(absolutePath);
|
|
52535
|
+
};
|
|
52536
|
+
const disambiguateRepoNames = (folders) => {
|
|
52537
|
+
const nameCounts = /* @__PURE__ */ new Map();
|
|
52538
|
+
for (const folder of folders) nameCounts.set(folder.preferredName, (nameCounts.get(folder.preferredName) ?? 0) + 1);
|
|
52539
|
+
return folders.map((folder) => {
|
|
52540
|
+
const base = folder.preferredName;
|
|
52541
|
+
const name = (nameCounts.get(base) ?? 0) > 1 ? `${base}@${PATH.basename(PATH.dirname(folder.absolutePath))}` : base;
|
|
52542
|
+
return {
|
|
52543
|
+
cwd: folder.absolutePath,
|
|
52544
|
+
hasStore: workStoreExists(folder.absolutePath),
|
|
52545
|
+
name
|
|
52546
|
+
};
|
|
52547
|
+
});
|
|
52548
|
+
};
|
|
52549
|
+
const resolveWorkRepos = (options = {}) => {
|
|
52550
|
+
const cwd = PATH.resolve(options.cwd ?? process.cwd());
|
|
52551
|
+
if (!isWorkspaceScope(options)) {
|
|
52552
|
+
const repo = singleRepo(cwd);
|
|
52553
|
+
if (options.repo !== void 0 && options.repo.length > 0 && options.repo !== repo.name) throw new Error(`Repo filter "${options.repo}" does not match current directory repo "${repo.name}"`);
|
|
52554
|
+
return [repo];
|
|
52555
|
+
}
|
|
52556
|
+
const lookup = resolveCodeWorkspaceFile(options.workspaceFile, cwd);
|
|
52557
|
+
if (lookup === void 0) throw new Error("Could not resolve a *.code-workspace file. Pass --workspace-file <path> or open a multi-root workspace.");
|
|
52558
|
+
const folders = parseCodeWorkspace(lookup.path).map((folder) => ({
|
|
52559
|
+
absolutePath: PATH.resolve(folder.absolutePath),
|
|
52560
|
+
preferredName: preferredFolderName(folder.absolutePath, folder.name)
|
|
52561
|
+
})).filter((folder) => existsSync(folder.absolutePath));
|
|
52562
|
+
const seen = /* @__PURE__ */ new Set();
|
|
52563
|
+
const unique = folders.filter((folder) => {
|
|
52564
|
+
if (seen.has(folder.absolutePath)) return false;
|
|
52565
|
+
seen.add(folder.absolutePath);
|
|
52566
|
+
return true;
|
|
52567
|
+
});
|
|
52568
|
+
let repos = disambiguateRepoNames(unique);
|
|
52569
|
+
if (options.repo !== void 0 && options.repo.length > 0) {
|
|
52570
|
+
repos = repos.filter((repo) => repo.name === options.repo);
|
|
52571
|
+
if (repos.length === 0) {
|
|
52572
|
+
const available = disambiguateRepoNames(unique).map((repo) => repo.name).toSorted();
|
|
52573
|
+
throw new Error(`Workspace folder not found: ${options.repo}. Available: ${available.join(", ") || "(none)"}`);
|
|
52574
|
+
}
|
|
52575
|
+
}
|
|
52576
|
+
return repos;
|
|
52577
|
+
};
|
|
52578
|
+
const resolveWorkReposWithStore = (options = {}) => {
|
|
52579
|
+
return resolveWorkRepos(options).filter((repo) => repo.hasStore);
|
|
52580
|
+
};
|
|
52581
|
+
const toScopedWorkItem = (item, repo, formula = DEFAULT_PRIORITY_FORMULA) => {
|
|
52582
|
+
return {
|
|
52583
|
+
...item,
|
|
52584
|
+
formula,
|
|
52585
|
+
repo: repo.name,
|
|
52586
|
+
repoCwd: repo.cwd
|
|
52587
|
+
};
|
|
52588
|
+
};
|
|
52589
|
+
/** Load work items for the current scope (auto-inits only in single-repo mode). */
|
|
52590
|
+
const listScopedWorkItems = (options = {}) => {
|
|
52591
|
+
if (!isWorkspaceScope(options)) {
|
|
52592
|
+
const cwd = PATH.resolve(options.cwd ?? process.cwd());
|
|
52593
|
+
const config = readWorkConfig(cwd);
|
|
52594
|
+
const repo = singleRepo(cwd);
|
|
52595
|
+
return listWorkItems(cwd).map((item) => toScopedWorkItem(item, repo, config.priority.formula));
|
|
52596
|
+
}
|
|
52597
|
+
const repos = resolveWorkReposWithStore(options);
|
|
52598
|
+
const items = [];
|
|
52599
|
+
for (const repo of repos) {
|
|
52600
|
+
const config = readWorkConfig(repo.cwd);
|
|
52601
|
+
for (const item of listWorkItems(repo.cwd)) items.push(toScopedWorkItem(item, repo, config.priority.formula));
|
|
52602
|
+
}
|
|
52603
|
+
return items;
|
|
52604
|
+
};
|
|
52605
|
+
const compareScopedWorkItemsByPriority = (a, b) => {
|
|
52606
|
+
const aScore = calculatePriorityScore(a.priority, a.formula);
|
|
52607
|
+
const bScore = calculatePriorityScore(b.priority, b.formula);
|
|
52608
|
+
if (aScore !== void 0 && bScore !== void 0 && aScore !== bScore) return bScore - aScore;
|
|
52609
|
+
if (aScore !== void 0 && bScore === void 0) return -1;
|
|
52610
|
+
if (aScore === void 0 && bScore !== void 0) return 1;
|
|
52611
|
+
return a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id) || a.repo.localeCompare(b.repo);
|
|
52612
|
+
};
|
|
52613
|
+
const selectScopedWorkItems = (items, options) => {
|
|
52614
|
+
const filtered = items.filter((item) => (options.status === void 0 || item.status === options.status) && (options.type === void 0 || item.type === options.type));
|
|
52615
|
+
if (options.sort === "priority") return filtered.toSorted(compareScopedWorkItemsByPriority);
|
|
52616
|
+
return filtered.toSorted((a, b) => a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id) || a.repo.localeCompare(b.repo));
|
|
52617
|
+
};
|
|
52618
|
+
/**
|
|
52619
|
+
* Resolve a work item by id within the current scope.
|
|
52620
|
+
* In single-repo mode, uses cwd directly (same error as readWorkItem).
|
|
52621
|
+
*/
|
|
52622
|
+
const resolveScopedWorkItem = (id, options = {}) => {
|
|
52623
|
+
if (!isWorkspaceScope(options)) {
|
|
52624
|
+
const cwd = PATH.resolve(options.cwd ?? process.cwd());
|
|
52625
|
+
const config = readWorkConfig(cwd);
|
|
52626
|
+
const item = readWorkItem(cwd, id);
|
|
52627
|
+
return toScopedWorkItem(item, singleRepo(cwd), config.priority.formula);
|
|
52628
|
+
}
|
|
52629
|
+
const repos = resolveWorkReposWithStore(options);
|
|
52630
|
+
const matches = [];
|
|
52631
|
+
for (const repo of repos) try {
|
|
52632
|
+
const item = readWorkItem(repo.cwd, id);
|
|
52633
|
+
const config = readWorkConfig(repo.cwd);
|
|
52634
|
+
matches.push(toScopedWorkItem(item, repo, config.priority.formula));
|
|
52635
|
+
} catch {}
|
|
52636
|
+
if (matches.length === 0) throw new Error(`Work item not found: ${id}`);
|
|
52637
|
+
if (matches.length > 1) {
|
|
52638
|
+
const reposList = matches.map((item) => item.repo).toSorted().join(", ");
|
|
52639
|
+
throw new Error(`Work item id ${id} is ambiguous across repos: ${reposList}. Pass --repo <name>.`);
|
|
52640
|
+
}
|
|
52641
|
+
const [match] = matches;
|
|
52642
|
+
if (match === void 0) throw new Error(`Work item not found: ${id}`);
|
|
52643
|
+
return match;
|
|
52644
|
+
};
|
|
52645
|
+
/**
|
|
52646
|
+
* Target repo for create operations (`add`).
|
|
52647
|
+
* Workspace mode: --repo, else deepest workspace folder containing cwd, else error.
|
|
52648
|
+
*/
|
|
52649
|
+
const resolveAddTargetRepo = (options = {}) => {
|
|
52650
|
+
if (!isWorkspaceScope(options)) return singleRepo(PATH.resolve(options.cwd ?? process.cwd()));
|
|
52651
|
+
const repos = resolveWorkRepos({ ...options });
|
|
52652
|
+
if (options.repo !== void 0 && options.repo.length > 0) {
|
|
52653
|
+
const [target] = repos;
|
|
52654
|
+
if (target === void 0) throw new Error(`Workspace folder not found: ${options.repo}`);
|
|
52655
|
+
return target;
|
|
52656
|
+
}
|
|
52657
|
+
const cwd = PATH.resolve(options.cwd ?? process.cwd());
|
|
52658
|
+
const target = repos.filter((repo) => cwd === repo.cwd || cwd.startsWith(`${repo.cwd}${PATH.sep}`)).toSorted((a, b) => b.cwd.length - a.cwd.length)[0];
|
|
52659
|
+
if (target === void 0) {
|
|
52660
|
+
const available = resolveWorkRepos({
|
|
52661
|
+
cwd: options.cwd,
|
|
52662
|
+
workspace: options.workspace,
|
|
52663
|
+
workspaceFile: options.workspaceFile
|
|
52664
|
+
}).map((repo) => repo.name).toSorted();
|
|
52665
|
+
throw new Error(`xy work add --workspace requires --repo <name> when cwd is not inside a workspace folder. Available: ${available.join(", ") || "(none)"}`);
|
|
52666
|
+
}
|
|
52667
|
+
return target;
|
|
52668
|
+
};
|
|
52669
|
+
const findWorkRepoByName = (name, options = {}) => {
|
|
52670
|
+
const repos = resolveWorkRepos({
|
|
52671
|
+
...options,
|
|
52672
|
+
repo: void 0,
|
|
52673
|
+
workspace: options.workspace ?? true,
|
|
52674
|
+
workspaceFile: options.workspaceFile
|
|
52675
|
+
});
|
|
52676
|
+
const match = repos.find((repo) => repo.name === name);
|
|
52677
|
+
if (match === void 0) throw new Error(`Workspace folder not found: ${name}. Available: ${repos.map((repo) => repo.name).toSorted().join(", ") || "(none)"}`);
|
|
52678
|
+
return match;
|
|
52679
|
+
};
|
|
52680
|
+
//#endregion
|
|
52681
|
+
//#region src/actions/work/lint.ts
|
|
52682
|
+
const pathLabel = (repo, absolutePath) => {
|
|
52683
|
+
const rel = PATH.relative(repo.cwd, absolutePath).split(PATH.sep).join("/");
|
|
52684
|
+
return rel.length === 0 ? "." : rel;
|
|
52685
|
+
};
|
|
52686
|
+
const collectGitignoredWorkPaths = (repo) => {
|
|
52687
|
+
if (!gitCleanGitignoreBackend.isGitRepo(repo.cwd)) return {
|
|
52688
|
+
gitignoredPaths: [],
|
|
52689
|
+
notGitRepo: true
|
|
52690
|
+
};
|
|
52691
|
+
const config = tryReadWorkConfig(repo.cwd);
|
|
52692
|
+
if (config === void 0) return {
|
|
52693
|
+
gitignoredPaths: [],
|
|
52694
|
+
notGitRepo: false
|
|
52695
|
+
};
|
|
52696
|
+
const paths = workStorePaths(repo.cwd, config);
|
|
52697
|
+
const candidates = [
|
|
52698
|
+
paths.rootDir,
|
|
52699
|
+
paths.configPath,
|
|
52700
|
+
paths.itemsDir
|
|
52701
|
+
];
|
|
52702
|
+
const gitignoredPaths = [];
|
|
52703
|
+
for (const candidate of candidates) if (gitCleanGitignoreBackend.isIgnored(repo.cwd, candidate)) gitignoredPaths.push(pathLabel(repo, candidate));
|
|
52704
|
+
return {
|
|
52705
|
+
gitignoredPaths: [...new Set(gitignoredPaths)].toSorted(),
|
|
52706
|
+
notGitRepo: false
|
|
52707
|
+
};
|
|
52708
|
+
};
|
|
52709
|
+
const buildRepoContext = (repo, github) => {
|
|
52710
|
+
const config = tryReadWorkConfig(repo.cwd);
|
|
52711
|
+
const { gitignoredPaths, notGitRepo } = collectGitignoredWorkPaths(repo);
|
|
52712
|
+
if (config === void 0) return {
|
|
52713
|
+
driftMessages: [],
|
|
52714
|
+
githubEnabled: false,
|
|
52715
|
+
githubUnavailable: false,
|
|
52716
|
+
gitignoredPaths,
|
|
52717
|
+
notGitRepo,
|
|
52718
|
+
repo
|
|
52719
|
+
};
|
|
52720
|
+
const githubEnabled = config.stores.github.enabled;
|
|
52721
|
+
let githubUnavailable = false;
|
|
52722
|
+
const driftMessages = [];
|
|
52723
|
+
if (githubEnabled) {
|
|
52724
|
+
const bridge = resolveGithubBridge(config, repo.cwd, github);
|
|
52725
|
+
if (bridge === void 0) githubUnavailable = true;
|
|
52726
|
+
else try {
|
|
52727
|
+
const drift = computeWorkSyncDrift(repo.cwd, {
|
|
52728
|
+
config,
|
|
52729
|
+
github: bridge
|
|
52730
|
+
});
|
|
52731
|
+
if (!workSyncDriftIsClean(drift)) {
|
|
52732
|
+
for (const id of drift.localMissingGithub) driftMessages.push(`${id} — active local item missing GitHub link`);
|
|
52733
|
+
for (const entry of drift.githubMissingLocal) driftMessages.push(`${entry} — GitHub issue missing local item`);
|
|
52734
|
+
for (const entry of drift.titleMismatch) driftMessages.push(`${entry} — title mismatch`);
|
|
52735
|
+
for (const entry of drift.statusMismatch) driftMessages.push(entry);
|
|
52736
|
+
}
|
|
52737
|
+
} catch (error) {
|
|
52738
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
52739
|
+
driftMessages.push(`failed to compute sync drift: ${message}`);
|
|
52740
|
+
}
|
|
52741
|
+
}
|
|
52742
|
+
return {
|
|
52743
|
+
driftMessages,
|
|
52744
|
+
githubEnabled,
|
|
52745
|
+
githubUnavailable,
|
|
52746
|
+
gitignoredPaths,
|
|
52747
|
+
notGitRepo,
|
|
52748
|
+
repo
|
|
52749
|
+
};
|
|
52750
|
+
};
|
|
52751
|
+
const withRepoPrefix = (repo, multi, message) => {
|
|
52752
|
+
return multi ? `${repo.name}: ${message}` : message;
|
|
52753
|
+
};
|
|
52754
|
+
const diagnosticsForMessages = (rule, messages) => {
|
|
52755
|
+
return messages.map((message) => ({
|
|
52756
|
+
message,
|
|
52757
|
+
rule
|
|
52758
|
+
}));
|
|
52759
|
+
};
|
|
52760
|
+
const WORK_LINT_RULES = [
|
|
52761
|
+
{
|
|
52762
|
+
check: ({ repos }) => {
|
|
52763
|
+
const multi = repos.length > 1;
|
|
52764
|
+
const messages = [];
|
|
52765
|
+
for (const ctx of repos) {
|
|
52766
|
+
if (ctx.notGitRepo) continue;
|
|
52767
|
+
for (const ignored of ctx.gitignoredPaths) messages.push(withRepoPrefix(ctx.repo, multi, `${ignored} is gitignored — work items must be committed; remove .xy/work from .gitignore`));
|
|
52768
|
+
}
|
|
52769
|
+
return { diagnostics: diagnosticsForMessages("work.store-not-gitignored", messages) };
|
|
52770
|
+
},
|
|
52771
|
+
defaultLevel: "error",
|
|
52772
|
+
description: "The .xy/work store is not gitignored",
|
|
52773
|
+
id: "work.store-not-gitignored"
|
|
52774
|
+
},
|
|
52775
|
+
{
|
|
52776
|
+
check: ({ repos }) => {
|
|
52777
|
+
const multi = repos.length > 1;
|
|
52778
|
+
const messages = [];
|
|
52779
|
+
for (const ctx of repos) {
|
|
52780
|
+
if (!ctx.githubEnabled) continue;
|
|
52781
|
+
if (ctx.githubUnavailable) messages.push(withRepoPrefix(ctx.repo, multi, "stores.github.enabled but gh is unavailable/unauthenticated for this repo"));
|
|
52782
|
+
}
|
|
52783
|
+
return { diagnostics: diagnosticsForMessages("work.github-available", messages) };
|
|
52784
|
+
},
|
|
52785
|
+
defaultLevel: "warn",
|
|
52786
|
+
description: "GitHub Issues are available when dual-write is enabled",
|
|
52787
|
+
id: "work.github-available"
|
|
52788
|
+
},
|
|
52789
|
+
{
|
|
52790
|
+
check: ({ repos }) => {
|
|
52791
|
+
const multi = repos.length > 1;
|
|
52792
|
+
const messages = [];
|
|
52793
|
+
for (const ctx of repos) {
|
|
52794
|
+
if (!ctx.githubEnabled || ctx.githubUnavailable) continue;
|
|
52795
|
+
for (const message of ctx.driftMessages) messages.push(withRepoPrefix(ctx.repo, multi, message));
|
|
52796
|
+
}
|
|
52797
|
+
return { diagnostics: diagnosticsForMessages("work.github-synced", messages) };
|
|
52798
|
+
},
|
|
52799
|
+
defaultLevel: "warn",
|
|
52800
|
+
description: "Local work items and GitHub Issues are in sync",
|
|
52801
|
+
id: "work.github-synced"
|
|
52802
|
+
}
|
|
52803
|
+
];
|
|
52804
|
+
function logWorkDiagnostic(diagnostic) {
|
|
52805
|
+
if (diagnostic.level === "error") console.log(chalk.red(` ✗ ${diagnostic.message}`));
|
|
52806
|
+
else console.log(chalk.yellow(` ⚠ ${diagnostic.message}`));
|
|
52807
|
+
}
|
|
52808
|
+
const resolveLintRepos = (options) => {
|
|
52809
|
+
if (isWorkspaceScope(options)) return resolveWorkRepos(options).filter((repo) => repo.hasStore);
|
|
52810
|
+
return resolveWorkRepos({ cwd: PATH.resolve(options.cwd ?? process.cwd()) }).filter((repo) => repo.hasStore);
|
|
52811
|
+
};
|
|
52812
|
+
const workLint = async (options = {}) => {
|
|
52813
|
+
const repos = resolveLintRepos(options);
|
|
52814
|
+
if (repos.length === 0) {
|
|
52815
|
+
console.log(chalk.gray("No work stores found to lint"));
|
|
52816
|
+
return {
|
|
52817
|
+
envelope: {
|
|
52818
|
+
data: {
|
|
52819
|
+
diagnostics: [],
|
|
52820
|
+
errorCount: 0,
|
|
52821
|
+
fixedCount: 0,
|
|
52822
|
+
warningCount: 0
|
|
52823
|
+
},
|
|
52824
|
+
errorCount: 0,
|
|
52825
|
+
warningCount: 0
|
|
52826
|
+
},
|
|
52827
|
+
exitCode: 0
|
|
52828
|
+
};
|
|
52829
|
+
}
|
|
52830
|
+
const cwd = options.cwd ?? process.cwd();
|
|
52831
|
+
const context = { repos: repos.map((repo) => buildRepoContext(repo, options.github)) };
|
|
52832
|
+
return runRuleChecks({
|
|
52833
|
+
commandName: "work lint",
|
|
52834
|
+
config: await loadWorkspaceCommandConfig(cwd, "workLint"),
|
|
52835
|
+
configKey: "workLint",
|
|
52836
|
+
context,
|
|
52837
|
+
reporter: {
|
|
52838
|
+
diagnostic: logWorkDiagnostic,
|
|
52839
|
+
passed: (rule) => {
|
|
52840
|
+
console.log(chalk.green(` ✓ ${rule.id}`));
|
|
52841
|
+
}
|
|
52842
|
+
},
|
|
52843
|
+
rules: WORK_LINT_RULES,
|
|
52844
|
+
strict: options.strict === true
|
|
52845
|
+
});
|
|
52846
|
+
};
|
|
52847
|
+
//#endregion
|
|
52848
|
+
//#region src/actions/ruleCatalog.ts
|
|
52849
|
+
const REPO_LINT_RULES = [
|
|
52850
|
+
[
|
|
52851
|
+
"repo.root-private",
|
|
52852
|
+
"Root package is private",
|
|
52853
|
+
"error",
|
|
52854
|
+
true
|
|
52855
|
+
],
|
|
52856
|
+
[
|
|
52857
|
+
"repo.no-private-publish-config",
|
|
52858
|
+
"Private root has no publishConfig",
|
|
52859
|
+
"error",
|
|
52860
|
+
true
|
|
52861
|
+
],
|
|
52862
|
+
[
|
|
52863
|
+
"repo.packages-folder",
|
|
52864
|
+
"Workspace packages live under packages/",
|
|
52865
|
+
"error",
|
|
52866
|
+
false
|
|
52867
|
+
],
|
|
52868
|
+
[
|
|
52869
|
+
"repo.spec-layout",
|
|
52870
|
+
"Spec files live in spec/ folders",
|
|
52871
|
+
"error",
|
|
52872
|
+
false
|
|
52873
|
+
],
|
|
52874
|
+
[
|
|
52875
|
+
"repo.workspaces-field-placement",
|
|
52876
|
+
"Workspace fields are declared in the package-manager-specific location",
|
|
52877
|
+
"error",
|
|
52878
|
+
true
|
|
52879
|
+
],
|
|
52880
|
+
[
|
|
52881
|
+
"repo.workspace-glob-coverage",
|
|
52882
|
+
"Workspace globs cover every package",
|
|
52883
|
+
"error",
|
|
52884
|
+
false
|
|
52885
|
+
],
|
|
52886
|
+
[
|
|
52887
|
+
"repo.no-package-manager-in-workspaces",
|
|
52888
|
+
"Only the root package declares packageManager",
|
|
52889
|
+
"error",
|
|
52890
|
+
true
|
|
52891
|
+
],
|
|
52892
|
+
[
|
|
52893
|
+
"repo.volta-only-root",
|
|
52894
|
+
"Only the root package declares volta",
|
|
52895
|
+
"error",
|
|
52896
|
+
true
|
|
52897
|
+
],
|
|
52898
|
+
[
|
|
52899
|
+
"repo.engines-non-terminal",
|
|
52900
|
+
"Only non-terminal packages declare engines",
|
|
52901
|
+
"error",
|
|
52902
|
+
true
|
|
52903
|
+
],
|
|
52904
|
+
[
|
|
52905
|
+
"repo.engines-lts",
|
|
52906
|
+
"Engine and volta versions include latest LTS",
|
|
52907
|
+
"error",
|
|
52908
|
+
false
|
|
52909
|
+
],
|
|
52910
|
+
[
|
|
52911
|
+
"repo.version-consistency",
|
|
52912
|
+
"Workspace versions are consistent",
|
|
52913
|
+
"error",
|
|
52914
|
+
true
|
|
52915
|
+
],
|
|
52916
|
+
[
|
|
52917
|
+
"repo.internal-dependency-ranges",
|
|
52918
|
+
"Internal dependencies use the expected workspace/version protocol",
|
|
52919
|
+
"error",
|
|
52920
|
+
true
|
|
52921
|
+
],
|
|
52922
|
+
[
|
|
52923
|
+
"repo.internal-peer-ranges",
|
|
52924
|
+
"Internal peerDependencies use publishable ranges",
|
|
52925
|
+
"error",
|
|
52926
|
+
true
|
|
52927
|
+
],
|
|
52928
|
+
[
|
|
52929
|
+
"repo.pnpm-release-age-excludes",
|
|
52930
|
+
"pnpm minimumReleaseAgeExclude matches imported scopes",
|
|
52931
|
+
"error",
|
|
52932
|
+
true
|
|
52933
|
+
],
|
|
52934
|
+
[
|
|
52935
|
+
"repo.pnpm-minimum-release-age",
|
|
52936
|
+
"pnpm minimumReleaseAge is configured",
|
|
52937
|
+
"error",
|
|
52938
|
+
true
|
|
52939
|
+
],
|
|
52940
|
+
[
|
|
52941
|
+
"repo.pnpm-no-overrides",
|
|
52942
|
+
"pnpm dependency overrides are not configured",
|
|
52943
|
+
"warn",
|
|
52944
|
+
false
|
|
52945
|
+
]
|
|
52946
|
+
].map(([id, description, defaultLevel, fixable]) => ({
|
|
52947
|
+
defaultLevel,
|
|
52948
|
+
description,
|
|
52949
|
+
fixable,
|
|
52950
|
+
id
|
|
52951
|
+
}));
|
|
52952
|
+
const NON_FIXABLE_DEAD_RULES = /* @__PURE__ */ new Set([
|
|
52953
|
+
"dead.repo.deprecated-export",
|
|
52954
|
+
"dead.workspace.deprecated-export",
|
|
52955
|
+
"dead.workspace.deprecated-unused-export"
|
|
52956
|
+
]);
|
|
52957
|
+
function isDeadRuleFixable(ruleId) {
|
|
52958
|
+
return !NON_FIXABLE_DEAD_RULES.has(ruleId);
|
|
52959
|
+
}
|
|
52960
|
+
function severityToLevel(severity, enabled = true) {
|
|
52961
|
+
if (!enabled) return "off";
|
|
52962
|
+
return severity === "error" ? "error" : "warn";
|
|
52963
|
+
}
|
|
52964
|
+
async function loadCommandConfig(commandName, pkg) {
|
|
52965
|
+
if (pkg !== void 0 && pkg.length > 0) {
|
|
52966
|
+
const workspace = getPackageManager().findWorkspace(pkg);
|
|
52967
|
+
if (workspace === void 0) throw new Error(`Workspace not found: ${pkg}`);
|
|
52968
|
+
return loadWorkspaceCommandConfig(workspace.location, commandName);
|
|
52969
|
+
}
|
|
52970
|
+
return loadWorkspaceCommandConfig(process.cwd(), commandName);
|
|
52971
|
+
}
|
|
52972
|
+
function staticCatalog(command, configKey, definitions, config) {
|
|
52973
|
+
const ruleSettings = config?.rules ?? {};
|
|
52974
|
+
const known = new Set(definitions.flatMap((rule) => [rule.id, ...rule.aliases ?? []]));
|
|
52975
|
+
const unknown = Object.keys(ruleSettings).filter((id) => !known.has(id));
|
|
52976
|
+
if (unknown.length > 0) throw new TypeError(`Unknown ${command} rule ${unknown.map((id) => `"${id}"`).join(", ")} in commands.${configKey}.rules`);
|
|
52977
|
+
const resolveSetting = (rule) => {
|
|
52978
|
+
if (ruleSettings[rule.id] !== void 0) return ruleSettings[rule.id];
|
|
52979
|
+
const aliases = rule.aliases ?? [];
|
|
52980
|
+
for (const alias of aliases) if (ruleSettings[alias] !== void 0) return ruleSettings[alias];
|
|
52981
|
+
};
|
|
52982
|
+
return definitions.map((rule) => ({
|
|
52983
|
+
command,
|
|
52984
|
+
defaultLevel: rule.defaultLevel,
|
|
52985
|
+
description: rule.description,
|
|
52986
|
+
fixable: rule.fixable === true,
|
|
52987
|
+
id: rule.id,
|
|
52988
|
+
level: parseRuleLevelSetting(ruleConfigPath(configKey, rule.id), resolveSetting(rule), rule.defaultLevel)
|
|
52989
|
+
}));
|
|
52990
|
+
}
|
|
52991
|
+
function runtimeRuleCatalog(command, configKey, definitions, config) {
|
|
52992
|
+
return staticCatalog(command, configKey, definitions, config);
|
|
52993
|
+
}
|
|
52994
|
+
function commandPrefix(prefix, rules) {
|
|
52995
|
+
return rules.map((rule) => ({
|
|
52996
|
+
...rule,
|
|
52997
|
+
command: `${prefix} ${rule.command}`
|
|
52998
|
+
}));
|
|
52999
|
+
}
|
|
53000
|
+
async function getDeplintRuleCatalog(pkg) {
|
|
53001
|
+
const config = await loadCommandConfig("deplint", pkg);
|
|
53002
|
+
const rules = await loadDeplintRules(config);
|
|
53003
|
+
const defaultRules = await loadDeplintRules(config === void 0 ? void 0 : {
|
|
53004
|
+
...config,
|
|
53005
|
+
rules: void 0
|
|
53006
|
+
});
|
|
53007
|
+
const defaults = new Map(defaultRules.map((rule) => [rule.id, severityToLevel(rule.meta.severity, rule.enabled !== false)]));
|
|
53008
|
+
return sortRules(rules.map((rule) => ({
|
|
53009
|
+
command: RULE_COMMANDS.deplint.command,
|
|
53010
|
+
defaultLevel: defaults.get(rule.id) ?? "warn",
|
|
53011
|
+
description: rule.meta.description,
|
|
53012
|
+
fixable: isRuleFixable(rule),
|
|
53013
|
+
id: rule.id,
|
|
53014
|
+
level: severityToLevel(rule.meta.severity, rule.enabled !== false)
|
|
53015
|
+
})));
|
|
53016
|
+
}
|
|
53017
|
+
async function getDeadRuleCatalog(pkg, options) {
|
|
53018
|
+
const config = await loadCommandConfig("dead", pkg);
|
|
53019
|
+
const rules = loadDeadRules(config, { deprecated: options?.deprecated === true });
|
|
53020
|
+
const defaultConfig = config === void 0 ? void 0 : {
|
|
53021
|
+
...config,
|
|
53022
|
+
rules: void 0
|
|
53023
|
+
};
|
|
53024
|
+
const defaults = new Map(loadDeadRules(defaultConfig, { deprecated: options?.deprecated === true }).map((rule) => [rule.id, severityToLevel(rule.meta.severity, rule.enabled)]));
|
|
53025
|
+
return sortRules(rules.map((rule) => ({
|
|
53026
|
+
command: RULE_COMMANDS.dead.command,
|
|
53027
|
+
defaultLevel: defaults.get(rule.id) ?? "warn",
|
|
53028
|
+
description: rule.meta.description,
|
|
53029
|
+
fixable: isDeadRuleFixable(rule.id),
|
|
53030
|
+
id: rule.id,
|
|
53031
|
+
level: severityToLevel(rule.meta.severity, rule.enabled)
|
|
53032
|
+
})));
|
|
53033
|
+
}
|
|
53034
|
+
async function getPublintRuleCatalog(command = RULE_COMMANDS.publint.command, pkg) {
|
|
53035
|
+
const levels = resolvePublintRuleLevels(await loadCommandConfig("publint", pkg));
|
|
53036
|
+
return ALL_PUBLINT_CHECKS.map((check) => ({
|
|
53037
|
+
command,
|
|
53038
|
+
defaultLevel: defaultPublintLevel(check),
|
|
53039
|
+
description: publintRuleDescription(check),
|
|
53040
|
+
fixable: publintRuleFixable(check),
|
|
53041
|
+
id: publintRuleId(check),
|
|
53042
|
+
level: levels.get(check) ?? "warn"
|
|
53043
|
+
}));
|
|
53044
|
+
}
|
|
53045
|
+
async function getApiExposureRuleCatalog(pkg) {
|
|
53046
|
+
const config = normalizeApiExposureConfig(await loadCommandConfig("apiExposure", pkg));
|
|
53047
|
+
const byId = new Map(config.rules.map((rule) => [rule.id, rule]));
|
|
53048
|
+
return AEI_RULES.map((rule) => {
|
|
53049
|
+
const resolved = byId.get(rule.id);
|
|
53050
|
+
return {
|
|
53051
|
+
command: RULE_COMMANDS.apiExposure.command,
|
|
53052
|
+
defaultLevel: rule.defaultEnabled === false ? "off" : "warn",
|
|
53053
|
+
description: rule.description,
|
|
53054
|
+
fixable: false,
|
|
53055
|
+
id: rule.id,
|
|
53056
|
+
level: resolved?.level ?? "warn",
|
|
53057
|
+
weight: resolved?.weight ?? rule.defaultWeight
|
|
53058
|
+
};
|
|
53059
|
+
});
|
|
53060
|
+
}
|
|
53061
|
+
async function getGitlintRuleCatalog() {
|
|
53062
|
+
return runtimeRuleCatalog(RULE_COMMANDS.gitLint.command, RULE_COMMANDS.gitLint.configKey, GITLINT_RULES, await loadCommandConfig("gitLint"));
|
|
53063
|
+
}
|
|
53064
|
+
async function getPackmanRuleCatalog() {
|
|
53065
|
+
return runtimeRuleCatalog(RULE_COMMANDS.packman.command, RULE_COMMANDS.packman.configKey, PACKMAN_RULES, await loadCommandConfig("packman"));
|
|
53066
|
+
}
|
|
53067
|
+
async function getRepoLintRuleCatalog() {
|
|
53068
|
+
return staticCatalog(RULE_COMMANDS.repoLint.command, RULE_COMMANDS.repoLint.configKey, REPO_LINT_RULES, await loadCommandConfig("repoLint"));
|
|
53069
|
+
}
|
|
53070
|
+
async function getNodeLintRuleCatalog() {
|
|
53071
|
+
return runtimeRuleCatalog(RULE_COMMANDS.nodeLint.command, RULE_COMMANDS.nodeLint.configKey, NODE_LINT_RULES, await loadCommandConfig("nodeLint"));
|
|
53072
|
+
}
|
|
53073
|
+
async function getLintlintRuleCatalog() {
|
|
53074
|
+
return runtimeRuleCatalog(RULE_COMMANDS.lintLint.command, RULE_COMMANDS.lintLint.configKey, LINTLINT_RULES, await loadCommandConfig("lintLint"));
|
|
53075
|
+
}
|
|
53076
|
+
async function getSkillsLintRuleCatalog() {
|
|
53077
|
+
return runtimeRuleCatalog(RULE_COMMANDS.skillsLint.command, RULE_COMMANDS.skillsLint.configKey, SKILLS_LINT_RULES, await loadCommandConfig("skillsLint"));
|
|
53078
|
+
}
|
|
53079
|
+
async function getWorkLintRuleCatalog() {
|
|
53080
|
+
return runtimeRuleCatalog(RULE_COMMANDS.workLint.command, RULE_COMMANDS.workLint.configKey, WORK_LINT_RULES, await loadCommandConfig("workLint"));
|
|
53081
|
+
}
|
|
53082
|
+
function parseEslintRuleLevel(setting) {
|
|
53083
|
+
let current = setting;
|
|
53084
|
+
while (Array.isArray(current) && current.length > 0) current = current[0];
|
|
53085
|
+
if (current === "error" || current === 2) return "error";
|
|
53086
|
+
if (current === "warn" || current === 1) return "warn";
|
|
53087
|
+
return "off";
|
|
53088
|
+
}
|
|
53089
|
+
function mergeEslintRules(configs) {
|
|
53090
|
+
const rules = /* @__PURE__ */ new Map();
|
|
53091
|
+
for (const config of configs) {
|
|
53092
|
+
if (config.rules === void 0) continue;
|
|
53093
|
+
for (const [id, setting] of Object.entries(config.rules)) rules.set(id, setting);
|
|
53094
|
+
}
|
|
53095
|
+
return rules;
|
|
53096
|
+
}
|
|
53097
|
+
function eslintRuleDescription(rule) {
|
|
53098
|
+
const description = rule?.meta?.docs?.description;
|
|
53099
|
+
return typeof description === "string" && description.length > 0 ? description : void 0;
|
|
53100
|
+
}
|
|
53101
|
+
function eslintRuleFixable(rule) {
|
|
53102
|
+
return rule?.meta?.fixable !== void 0;
|
|
53103
|
+
}
|
|
53104
|
+
function collectEslintRuleDescriptions(configs) {
|
|
53105
|
+
const descriptions = /* @__PURE__ */ new Map();
|
|
53106
|
+
for (const [id, rule] of builtinRules) {
|
|
53107
|
+
const description = eslintRuleDescription(rule);
|
|
53108
|
+
if (description !== void 0) descriptions.set(id, description);
|
|
53109
|
+
}
|
|
53110
|
+
for (const config of configs) {
|
|
53111
|
+
const plugins = Object.entries(config.plugins ?? {});
|
|
53112
|
+
for (const [pluginName, plugin] of plugins) {
|
|
53113
|
+
const rules = Object.entries(plugin?.rules ?? {});
|
|
53114
|
+
for (const [ruleName, rule] of rules) {
|
|
53115
|
+
const description = eslintRuleDescription(rule);
|
|
53116
|
+
if (description !== void 0) descriptions.set(`${pluginName}/${ruleName}`, description);
|
|
53117
|
+
}
|
|
53118
|
+
}
|
|
53119
|
+
}
|
|
53120
|
+
return descriptions;
|
|
53121
|
+
}
|
|
53122
|
+
function collectEslintRuleFixability(configs) {
|
|
53123
|
+
const fixability = /* @__PURE__ */ new Map();
|
|
53124
|
+
for (const [id, rule] of builtinRules) fixability.set(id, eslintRuleFixable(rule));
|
|
53125
|
+
for (const config of configs) {
|
|
53126
|
+
const plugins = Object.entries(config.plugins ?? {});
|
|
53127
|
+
for (const [pluginName, plugin] of plugins) {
|
|
53128
|
+
const rules = Object.entries(plugin?.rules ?? {});
|
|
53129
|
+
for (const [ruleName, rule] of rules) fixability.set(`${pluginName}/${ruleName}`, eslintRuleFixable(rule));
|
|
53130
|
+
}
|
|
53131
|
+
}
|
|
53132
|
+
return fixability;
|
|
53133
|
+
}
|
|
53134
|
+
async function getEslintRuleCatalog(command = RULE_COMMANDS.lint.command) {
|
|
53135
|
+
const configPath = await findUp(["eslint.config.ts", "eslint.config.mjs"]);
|
|
53136
|
+
if (configPath === void 0) return [];
|
|
53137
|
+
const module = await import(pathToFileURL(configPath).href);
|
|
53138
|
+
const configs = Array.isArray(module.default) ? module.default : [];
|
|
53139
|
+
const rules = mergeEslintRules(configs);
|
|
53140
|
+
const descriptions = collectEslintRuleDescriptions(configs);
|
|
53141
|
+
const fixability = collectEslintRuleFixability(configs);
|
|
53142
|
+
return rules.entries().map(([id, setting]) => ({
|
|
53143
|
+
command,
|
|
53144
|
+
defaultLevel: parseEslintRuleLevel(setting),
|
|
53145
|
+
description: descriptions.get(id),
|
|
53146
|
+
fixable: fixability.get(id) ?? false,
|
|
53147
|
+
id,
|
|
53148
|
+
level: parseEslintRuleLevel(setting),
|
|
53149
|
+
source: configPath
|
|
53150
|
+
})).toArray().toSorted((left, right) => left.id.localeCompare(right.id));
|
|
53151
|
+
}
|
|
53152
|
+
function getCycleRuleCatalog(depth = 25) {
|
|
53153
|
+
return [{
|
|
53154
|
+
command: RULE_COMMANDS.cycle.command,
|
|
53155
|
+
defaultLevel: "warn",
|
|
53156
|
+
description: `ESLint import cycle rule with maxDepth ${depth}`,
|
|
53157
|
+
fixable: false,
|
|
53158
|
+
id: "import-x/no-cycle",
|
|
53159
|
+
level: "warn"
|
|
53160
|
+
}];
|
|
53161
|
+
}
|
|
53162
|
+
async function loadDirectRuleCatalog() {
|
|
53163
|
+
return sortRules([...(await Promise.all([
|
|
53164
|
+
getApiExposureRuleCatalog(),
|
|
53165
|
+
getCleanRuleCatalog(),
|
|
53166
|
+
getDeadRuleCatalog(),
|
|
53167
|
+
getDeplintRuleCatalog(),
|
|
53168
|
+
getGitlintRuleCatalog(),
|
|
53169
|
+
getPackmanRuleCatalog(),
|
|
53170
|
+
getPublintRuleCatalog(),
|
|
53171
|
+
getRepoLintRuleCatalog(),
|
|
53172
|
+
getNodeLintRuleCatalog(),
|
|
53173
|
+
getLintlintRuleCatalog(),
|
|
53174
|
+
getSkillsLintRuleCatalog(),
|
|
53175
|
+
getWorkLintRuleCatalog()
|
|
53176
|
+
])).flat(), ...getCycleRuleCatalog()]);
|
|
53177
|
+
}
|
|
53178
|
+
async function getCheckRuleCatalog() {
|
|
53179
|
+
return sortRules(commandPrefix("check", (await Promise.all([
|
|
53180
|
+
getGitlintRuleCatalog(),
|
|
53181
|
+
getPackmanRuleCatalog(),
|
|
53182
|
+
getPublintRuleCatalog(),
|
|
53183
|
+
getRepoLintRuleCatalog(),
|
|
53184
|
+
getLintlintRuleCatalog(),
|
|
53185
|
+
getSkillsLintRuleCatalog()
|
|
53186
|
+
])).flat()));
|
|
53187
|
+
}
|
|
53188
|
+
async function getFixRuleCatalog() {
|
|
53189
|
+
return sortRules(commandPrefix("fix", (await Promise.all([
|
|
53190
|
+
getGitlintRuleCatalog(),
|
|
53191
|
+
getDeplintRuleCatalog(),
|
|
53192
|
+
getRepoLintRuleCatalog(),
|
|
53193
|
+
getPublintRuleCatalog(),
|
|
53194
|
+
getEslintRuleCatalog("lint"),
|
|
53195
|
+
getLintlintRuleCatalog()
|
|
53196
|
+
])).flat()));
|
|
53197
|
+
}
|
|
53198
|
+
async function getMasterRuleCatalog() {
|
|
53199
|
+
return sortRules(await loadDirectRuleCatalog());
|
|
53200
|
+
}
|
|
53201
|
+
//#endregion
|
|
53202
|
+
//#region src/actions/secure.ts
|
|
53203
|
+
const secure = async ({ jobs = 16, pkg, verbose = false } = {}) => {
|
|
53204
|
+
return await runSecurityAudit(getPackageManager(), {
|
|
53205
|
+
concurrency: jobs,
|
|
53206
|
+
pkg,
|
|
53207
|
+
verbose
|
|
53208
|
+
});
|
|
53209
|
+
};
|
|
53210
|
+
//#endregion
|
|
53211
|
+
//#region src/actions/sitemap.ts
|
|
53212
|
+
const sitemap = () => {
|
|
53213
|
+
return runSteps("Sitemap", [["ts-node-script", "./scripts/sitemap.ts"]]);
|
|
53214
|
+
};
|
|
53215
|
+
//#endregion
|
|
53216
|
+
//#region src/actions/skills/updo.ts
|
|
53217
|
+
const SCOPE_FLAGS = /* @__PURE__ */ new Set([
|
|
53218
|
+
"-g",
|
|
53219
|
+
"--global",
|
|
53220
|
+
"-p",
|
|
53221
|
+
"--project"
|
|
53222
|
+
]);
|
|
53223
|
+
const hasSkillsScopeFlag = (args) => args.some((a) => SCOPE_FLAGS.has(a));
|
|
53224
|
+
const skillsUpdoArgs = (args) => {
|
|
53225
|
+
return ["update", ...hasSkillsScopeFlag(args) ? args : ["-p", ...args]];
|
|
53226
|
+
};
|
|
53227
|
+
const skillsUpdo = (args) => {
|
|
53228
|
+
return runSkills(skillsUpdoArgs(args));
|
|
53229
|
+
};
|
|
53230
|
+
//#endregion
|
|
53231
|
+
//#region src/actions/sonar.ts
|
|
53232
|
+
const sonar = () => {
|
|
53233
|
+
return runSteps("Sonar", [["eslint", [
|
|
53234
|
+
"-c",
|
|
53235
|
+
"sonar.eslintrc",
|
|
53236
|
+
"."
|
|
53237
|
+
]]]);
|
|
53238
|
+
};
|
|
53239
|
+
//#endregion
|
|
53240
|
+
//#region src/actions/start.ts
|
|
53241
|
+
const start = () => {
|
|
53242
|
+
return runSteps("Start", [[getPackageManager().command, "react-scripts start"]]);
|
|
53243
|
+
};
|
|
53244
|
+
//#endregion
|
|
53245
|
+
//#region src/actions/statics.ts
|
|
53246
|
+
const DefaultDependencies = [
|
|
53247
|
+
"axios",
|
|
53248
|
+
"@xylabs/pixel",
|
|
53249
|
+
"react",
|
|
53250
|
+
"graphql",
|
|
53251
|
+
"react-router",
|
|
53252
|
+
"@mui/material",
|
|
53253
|
+
"@mui/system"
|
|
53254
|
+
];
|
|
53255
|
+
const statics = () => {
|
|
53256
|
+
console.log(chalk.green("Check Required Static Dependencies"));
|
|
53257
|
+
const staticsValue = ((parsedPackageJSON()?.xy)?.deps)?.statics;
|
|
53258
|
+
const result = detectDuplicateDependencies(staticsValue, DefaultDependencies, false);
|
|
53259
|
+
return isStrictMode() ? result : 0;
|
|
53260
|
+
};
|
|
53261
|
+
//#endregion
|
|
53262
|
+
//#region src/actions/test.ts
|
|
53263
|
+
const test = ({ target } = {}) => {
|
|
53264
|
+
const pm = getPackageManager();
|
|
53265
|
+
if (target != null && target.length > 0 && pm.findWorkspace(target)) return runSteps(`Test [${target}]`, [pm.runInWorkspace(target, "vitest", ["."])]);
|
|
53266
|
+
return runSteps("Test", [["vitest", [target ?? "."]]]);
|
|
53267
|
+
};
|
|
53268
|
+
//#endregion
|
|
53269
|
+
//#region src/actions/up.ts
|
|
53270
|
+
const up = () => {
|
|
53271
|
+
return runSteps("Up", [getPackageManager().outdated()]);
|
|
53272
|
+
};
|
|
53273
|
+
//#endregion
|
|
53274
|
+
//#region src/actions/updo.ts
|
|
53275
|
+
const updo = async ({ jobs, latest = false, next = false, risk = "green" } = {}) => {
|
|
53276
|
+
return await runUpdo(getPackageManager(), {
|
|
53277
|
+
jobs,
|
|
53278
|
+
latest,
|
|
53279
|
+
next,
|
|
53280
|
+
risk
|
|
53281
|
+
});
|
|
53282
|
+
};
|
|
53283
|
+
//#endregion
|
|
53284
|
+
//#region src/actions/work/helpers.ts
|
|
53285
|
+
const normalizeTags = (tags) => {
|
|
53286
|
+
return [...new Set((tags ?? []).map((tag) => tag.trim()).filter((tag) => tag.length > 0))].toSorted();
|
|
53287
|
+
};
|
|
53288
|
+
const normalizeTextList = (items) => {
|
|
53289
|
+
return (items ?? []).map((item) => item.trim()).filter((item) => item.length > 0);
|
|
53290
|
+
};
|
|
53291
|
+
const normalizeAnchor = (cwd, filePath, line) => {
|
|
53292
|
+
const { relativePath } = pathInsideRepo(cwd, filePath);
|
|
53293
|
+
return {
|
|
53294
|
+
kind: "file",
|
|
53295
|
+
line,
|
|
53296
|
+
path: relativePath
|
|
53297
|
+
};
|
|
53298
|
+
};
|
|
53299
|
+
const scopeFrom = (options) => ({
|
|
53300
|
+
cwd: options.cwd,
|
|
53301
|
+
repo: options.repo,
|
|
53302
|
+
workspace: options.workspace,
|
|
53303
|
+
workspaceFile: options.workspaceFile
|
|
53304
|
+
});
|
|
53305
|
+
const stripScope = (item) => {
|
|
53306
|
+
const { formula: _formula, repo: _repo, repoCwd: _repoCwd, ...rest } = item;
|
|
53307
|
+
return rest;
|
|
53308
|
+
};
|
|
53309
|
+
const toListedItem = (item, keepRepo) => {
|
|
53310
|
+
if (!keepRepo) return stripScope(item);
|
|
53311
|
+
return {
|
|
53312
|
+
...stripScope(item),
|
|
53313
|
+
repo: item.repo
|
|
53314
|
+
};
|
|
53315
|
+
};
|
|
53316
|
+
const claimItem = (cwd, item, now) => {
|
|
53317
|
+
if (item.status === "done" || item.status === "wontfix") throw new Error(`Cannot claim ${item.status} item: ${item.id}`);
|
|
53318
|
+
const claimedAt = nowIso(now);
|
|
53319
|
+
const claimed = {
|
|
53320
|
+
...item,
|
|
53321
|
+
claimedAt,
|
|
53322
|
+
status: "claimed",
|
|
53323
|
+
updatedAt: claimedAt
|
|
53324
|
+
};
|
|
53325
|
+
writeWorkItem(cwd, claimed);
|
|
53326
|
+
return claimed;
|
|
53327
|
+
};
|
|
53328
|
+
const repoBasename = (cwd) => PATH.basename(PATH.resolve(cwd));
|
|
53329
|
+
//#endregion
|
|
53330
|
+
//#region src/actions/work/inline.ts
|
|
53331
|
+
const markdownLikeExtensions = /* @__PURE__ */ new Set([
|
|
53332
|
+
".htm",
|
|
53333
|
+
".html",
|
|
53334
|
+
".md",
|
|
53335
|
+
".mdx"
|
|
53336
|
+
]);
|
|
53337
|
+
const markerForFile = (filePath, marker, id) => {
|
|
53338
|
+
const ext = PATH.extname(filePath).toLowerCase();
|
|
53339
|
+
if (markdownLikeExtensions.has(ext)) return `<!-- ${marker}: ${id} -->`;
|
|
53340
|
+
return `// ${marker}: ${id}`;
|
|
53341
|
+
};
|
|
53342
|
+
const insertInlineWorkMarker = ({ cwd, filePath, id, line, marker }) => {
|
|
53343
|
+
const { absolutePath, relativePath } = pathInsideRepo(cwd, filePath);
|
|
53344
|
+
if (!existsSync(absolutePath)) throw new Error(`Inline anchor file not found: ${relativePath}`);
|
|
53345
|
+
const markerText = markerForFile(absolutePath, marker, id);
|
|
53346
|
+
const original = readFileSync(absolutePath, "utf8");
|
|
53347
|
+
if (original.includes(markerText)) return relativePath;
|
|
53348
|
+
if (line === void 0) {
|
|
53349
|
+
writeFileSync(absolutePath, `${original}${original.endsWith("\n") || original.length === 0 ? "" : "\n"}${markerText}\n`, "utf8");
|
|
53350
|
+
return relativePath;
|
|
53351
|
+
}
|
|
53352
|
+
const lines = original.split("\n");
|
|
53353
|
+
const index = Math.max(0, Math.min(line - 1, lines.length));
|
|
53354
|
+
lines.splice(index, 0, markerText);
|
|
53355
|
+
writeFileSync(absolutePath, lines.join("\n"), "utf8");
|
|
53356
|
+
return relativePath;
|
|
53357
|
+
};
|
|
53358
|
+
//#endregion
|
|
53359
|
+
//#region src/actions/work/lifecycle.ts
|
|
53360
|
+
const workClaim = (options) => {
|
|
53361
|
+
const scoped = resolveScopedWorkItem(options.id, scopeFrom(options));
|
|
53362
|
+
const item = claimItem(scoped.repoCwd, stripScope(scoped), options.now);
|
|
53363
|
+
const label = isWorkspaceScope(options) ? ` [${scoped.repo}]` : "";
|
|
53364
|
+
xyLog(`Claimed ${item.id}${label}`);
|
|
53365
|
+
return cleanResult({
|
|
53366
|
+
item,
|
|
53367
|
+
repo: scoped.repo
|
|
53368
|
+
});
|
|
53369
|
+
};
|
|
53370
|
+
const workDone = (options) => {
|
|
53371
|
+
if (options.evidence.trim().length === 0) throw new Error("done requires non-empty verification evidence");
|
|
53372
|
+
const scoped = resolveScopedWorkItem(options.id, scopeFrom(options));
|
|
53373
|
+
const item = stripScope(scoped);
|
|
53374
|
+
const completedAt = nowIso(options.now);
|
|
53375
|
+
const verification = [...item.verification, options.evidence.trim()];
|
|
53376
|
+
const done = {
|
|
53377
|
+
...item,
|
|
53378
|
+
completedAt,
|
|
53379
|
+
status: "done",
|
|
53380
|
+
updatedAt: completedAt,
|
|
53381
|
+
verification: [...new Set(verification)]
|
|
53382
|
+
};
|
|
53383
|
+
writeWorkItem(scoped.repoCwd, done);
|
|
53384
|
+
const label = isWorkspaceScope(options) ? ` [${scoped.repo}]` : "";
|
|
53385
|
+
xyLog(`Done ${done.id}${label}`);
|
|
53386
|
+
return cleanResult({
|
|
53387
|
+
item: done,
|
|
53388
|
+
repo: scoped.repo
|
|
53389
|
+
});
|
|
53390
|
+
};
|
|
53391
|
+
const workUpdate = (options) => {
|
|
53392
|
+
const scoped = resolveScopedWorkItem(options.id, scopeFrom(options));
|
|
53393
|
+
const item = stripScope(scoped);
|
|
53394
|
+
const priority = priorityFromPartial({
|
|
53395
|
+
confidence: options.confidence,
|
|
53396
|
+
effort: options.effort,
|
|
53397
|
+
impact: options.impact,
|
|
53398
|
+
risk: options.risk,
|
|
53399
|
+
urgency: options.urgency
|
|
53400
|
+
});
|
|
53401
|
+
const updatedAt = nowIso(options.now);
|
|
53402
|
+
const updated = {
|
|
53403
|
+
...item,
|
|
53404
|
+
acceptanceCriteria: options.acceptanceCriteria === void 0 ? item.acceptanceCriteria : normalizeTextList(options.acceptanceCriteria),
|
|
53405
|
+
area: options.area ?? item.area,
|
|
53406
|
+
blockedReason: options.blockedReason ?? item.blockedReason,
|
|
53407
|
+
description: options.description ?? item.description,
|
|
53408
|
+
priority: priority === void 0 ? item.priority : validateWorkPriority(priority),
|
|
53409
|
+
status: options.status ?? item.status,
|
|
53410
|
+
tags: options.tags === void 0 ? item.tags : normalizeTags(options.tags),
|
|
53411
|
+
title: options.title ?? item.title,
|
|
53412
|
+
updatedAt,
|
|
53413
|
+
verification: options.verification === void 0 ? item.verification : normalizeTextList(options.verification)
|
|
53414
|
+
};
|
|
53415
|
+
writeWorkItem(scoped.repoCwd, updated);
|
|
53416
|
+
const label = isWorkspaceScope(options) ? ` [${scoped.repo}]` : "";
|
|
53417
|
+
xyLog(`Updated ${updated.id}${label}`);
|
|
53418
|
+
return cleanResult({
|
|
53419
|
+
item: updated,
|
|
53420
|
+
repo: scoped.repo
|
|
53421
|
+
});
|
|
53422
|
+
};
|
|
53423
|
+
//#endregion
|
|
53424
|
+
//#region src/actions/work/render.ts
|
|
53425
|
+
const maxWidth = (headerLabel, values, max = Infinity) => {
|
|
53426
|
+
return Math.min(max, Math.max(headerLabel.length, ...values.map((value) => value.length)));
|
|
53427
|
+
};
|
|
53428
|
+
const resolveTableWidth = () => {
|
|
53429
|
+
const columns = process.stdout.isTTY ? process.stdout.columns : void 0;
|
|
53430
|
+
return Math.max(72, Math.min(columns ?? 120, 160) - 2);
|
|
53431
|
+
};
|
|
53432
|
+
const resolveWorkTableWidths = (rows, showRepo) => {
|
|
53433
|
+
const columnCount = showRepo ? 7 : 6;
|
|
53434
|
+
const tableChromeWidth = columnCount + 1 + columnCount * 2;
|
|
53435
|
+
const id = maxWidth("ID", rows.map((row) => row.id), 28);
|
|
53436
|
+
const status = maxWidth("Status", rows.map((row) => row.status), 12);
|
|
53437
|
+
const type = maxWidth("Type", rows.map((row) => row.type), 12);
|
|
53438
|
+
const score = maxWidth("Score", rows.map((row) => row.score), 8);
|
|
53439
|
+
const area = maxWidth("Area", rows.map((row) => row.area), 20);
|
|
53440
|
+
const repo = showRepo ? maxWidth("Repo", rows.map((row) => row.repo), 24) : 0;
|
|
53441
|
+
const fixedWidth = tableChromeWidth + id + status + type + score + area + repo;
|
|
53442
|
+
const availableTitle = Math.max(20, resolveTableWidth() - fixedWidth);
|
|
53443
|
+
const naturalTitle = maxWidth("Title", rows.map((row) => row.title), 72);
|
|
53444
|
+
return {
|
|
53445
|
+
area,
|
|
53446
|
+
id,
|
|
53447
|
+
repo,
|
|
53448
|
+
score,
|
|
53449
|
+
status,
|
|
53450
|
+
title: Math.min(naturalTitle, availableTitle),
|
|
53451
|
+
type
|
|
53452
|
+
};
|
|
53453
|
+
};
|
|
53454
|
+
const workTableConfig = (widths, showRepo) => {
|
|
53455
|
+
const columns = showRepo ? {
|
|
53456
|
+
0: { width: widths.id },
|
|
53457
|
+
1: { width: widths.repo },
|
|
53458
|
+
2: { width: widths.status },
|
|
53459
|
+
3: { width: widths.type },
|
|
53460
|
+
4: {
|
|
53461
|
+
alignment: "right",
|
|
53462
|
+
width: widths.score
|
|
53463
|
+
},
|
|
53464
|
+
5: { width: widths.area },
|
|
53465
|
+
6: { width: widths.title }
|
|
53466
|
+
} : {
|
|
53467
|
+
0: { width: widths.id },
|
|
53468
|
+
1: { width: widths.status },
|
|
53469
|
+
2: { width: widths.type },
|
|
53470
|
+
3: {
|
|
53471
|
+
alignment: "right",
|
|
53472
|
+
width: widths.score
|
|
53473
|
+
},
|
|
53474
|
+
4: { width: widths.area },
|
|
53475
|
+
5: { width: widths.title }
|
|
53476
|
+
};
|
|
53477
|
+
return {
|
|
53478
|
+
border: (0, import_src.getBorderCharacters)("norc"),
|
|
53479
|
+
columnDefault: {
|
|
53480
|
+
paddingLeft: 1,
|
|
53481
|
+
paddingRight: 1,
|
|
53482
|
+
wrapWord: true
|
|
53483
|
+
},
|
|
53484
|
+
columns,
|
|
53485
|
+
drawHorizontalLine: (index, size) => [
|
|
53486
|
+
0,
|
|
53487
|
+
1,
|
|
53488
|
+
size
|
|
53489
|
+
].includes(index)
|
|
53490
|
+
};
|
|
53491
|
+
};
|
|
53492
|
+
const toRow = (item, formula) => {
|
|
53493
|
+
const score = calculatePriorityScore(item.priority, item.formula ?? formula);
|
|
53494
|
+
return {
|
|
53495
|
+
area: item.area ?? "-",
|
|
53496
|
+
id: item.id,
|
|
53497
|
+
repo: item.repo ?? "-",
|
|
53498
|
+
score: score === void 0 ? "-" : String(score),
|
|
53499
|
+
status: item.status,
|
|
53500
|
+
title: item.title,
|
|
53501
|
+
type: item.type
|
|
53502
|
+
};
|
|
53503
|
+
};
|
|
53504
|
+
const formatWorkTable = (items, formula, options = {}) => {
|
|
53505
|
+
const showRepo = options.showRepo === true;
|
|
53506
|
+
const rows = items.map((item) => toRow(item, formula));
|
|
53507
|
+
const widths = resolveWorkTableWidths(rows, showRepo);
|
|
53508
|
+
return (0, import_src.table)([showRepo ? [
|
|
53509
|
+
chalk.gray.bold("ID"),
|
|
53510
|
+
chalk.gray.bold("Repo"),
|
|
53511
|
+
chalk.gray.bold("Status"),
|
|
53512
|
+
chalk.gray.bold("Type"),
|
|
53513
|
+
chalk.gray.bold("Score"),
|
|
53514
|
+
chalk.gray.bold("Area"),
|
|
53515
|
+
chalk.gray.bold("Title")
|
|
53516
|
+
] : [
|
|
53517
|
+
chalk.gray.bold("ID"),
|
|
53518
|
+
chalk.gray.bold("Status"),
|
|
53519
|
+
chalk.gray.bold("Type"),
|
|
53520
|
+
chalk.gray.bold("Score"),
|
|
53521
|
+
chalk.gray.bold("Area"),
|
|
53522
|
+
chalk.gray.bold("Title")
|
|
53523
|
+
], ...rows.map((row) => showRepo ? [
|
|
53524
|
+
chalk.cyan(row.id),
|
|
53525
|
+
chalk.magenta(row.repo),
|
|
53526
|
+
chalk.white(row.status),
|
|
53527
|
+
chalk.white(row.type),
|
|
53528
|
+
chalk.gray(row.score),
|
|
53529
|
+
chalk.gray(row.area),
|
|
53530
|
+
chalk.white(row.title)
|
|
53531
|
+
] : [
|
|
53532
|
+
chalk.cyan(row.id),
|
|
53533
|
+
chalk.white(row.status),
|
|
53534
|
+
chalk.white(row.type),
|
|
53535
|
+
chalk.gray(row.score),
|
|
53536
|
+
chalk.gray(row.area),
|
|
53537
|
+
chalk.white(row.title)
|
|
53538
|
+
])], workTableConfig(widths, showRepo)).trimEnd();
|
|
53539
|
+
};
|
|
53540
|
+
const printWorkItemsTable = (items, formula, options = {}) => {
|
|
53541
|
+
if (isJsonMode()) return;
|
|
53542
|
+
if (items.length === 0) {
|
|
53543
|
+
xyLog("No work items");
|
|
53544
|
+
return;
|
|
53545
|
+
}
|
|
53546
|
+
xyLog(formatWorkTable(items, formula, options));
|
|
53547
|
+
};
|
|
53548
|
+
const printWorkItemSummary = (item, score) => {
|
|
53549
|
+
const scoreText = score === void 0 ? "-" : String(score);
|
|
53550
|
+
xyLog(`${item.repo === void 0 ? "" : `${item.repo}\t`}${item.id}\t${item.status}\t${item.type}\t${scoreText}\t${item.title}`);
|
|
53551
|
+
};
|
|
53552
|
+
//#endregion
|
|
53553
|
+
//#region src/actions/work/list.ts
|
|
53554
|
+
const selectWorkItems = (items, options, formula) => {
|
|
53555
|
+
const filtered = items.filter((item) => (options.status === void 0 || item.status === options.status) && (options.type === void 0 || item.type === options.type));
|
|
53556
|
+
if (options.sort === "priority") return filtered.toSorted((a, b) => compareWorkItemsByPriority(a, b, formula));
|
|
53557
|
+
return filtered.toSorted((a, b) => a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id));
|
|
53558
|
+
};
|
|
53559
|
+
const appendExternalGithubItems = (cwd, scoped, github, localItems, formula, repoName) => {
|
|
53560
|
+
const external = listExternalGithubWorkItems(cwd, localItems, github);
|
|
53561
|
+
return [...scoped, ...external.map((item) => ({
|
|
53562
|
+
...item,
|
|
53563
|
+
formula,
|
|
53564
|
+
repo: repoName,
|
|
53565
|
+
repoCwd: PATH.resolve(cwd)
|
|
53566
|
+
}))];
|
|
53567
|
+
};
|
|
53568
|
+
const loadSingleRepoWithGithub = (options, scoped) => {
|
|
53569
|
+
const cwd = options.cwd ?? process.cwd();
|
|
53570
|
+
const config = readWorkConfig(cwd);
|
|
53571
|
+
const github = resolveGithubBridge(config, cwd, options.github);
|
|
53572
|
+
if (github === void 0) return scoped;
|
|
53573
|
+
try {
|
|
53574
|
+
return appendExternalGithubItems(cwd, scoped, github, listWorkItems(cwd), config.priority.formula, scoped[0]?.repo ?? PATH.basename(PATH.resolve(cwd)));
|
|
53575
|
+
} catch (error) {
|
|
53576
|
+
xyLog(`GitHub issues skipped: ${error instanceof Error ? error.message : String(error)}`);
|
|
53577
|
+
return scoped;
|
|
53578
|
+
}
|
|
53579
|
+
};
|
|
53580
|
+
const loadWorkspaceWithGithub = (options, scoped) => {
|
|
53581
|
+
const byRepo = /* @__PURE__ */ new Map();
|
|
53582
|
+
for (const item of scoped) {
|
|
53583
|
+
const list = byRepo.get(item.repoCwd) ?? [];
|
|
53584
|
+
list.push(item);
|
|
53585
|
+
byRepo.set(item.repoCwd, list);
|
|
53586
|
+
}
|
|
53587
|
+
const combined = [...scoped];
|
|
53588
|
+
for (const [repoCwd, localScoped] of byRepo) {
|
|
53589
|
+
const config = readWorkConfig(repoCwd);
|
|
53590
|
+
const github = resolveGithubBridge(config, repoCwd, options.github);
|
|
53591
|
+
if (github === void 0) continue;
|
|
53592
|
+
try {
|
|
53593
|
+
const external = listExternalGithubWorkItems(repoCwd, localScoped.map(stripScope), github);
|
|
53594
|
+
const repoName = localScoped[0]?.repo ?? PATH.basename(repoCwd);
|
|
53595
|
+
for (const item of external) combined.push({
|
|
53596
|
+
...item,
|
|
53597
|
+
formula: config.priority.formula,
|
|
53598
|
+
repo: repoName,
|
|
53599
|
+
repoCwd
|
|
53600
|
+
});
|
|
53601
|
+
} catch (error) {
|
|
53602
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
53603
|
+
xyLog(`GitHub issues skipped for ${PATH.basename(repoCwd)}: ${message}`);
|
|
53604
|
+
}
|
|
53605
|
+
}
|
|
53606
|
+
return combined;
|
|
53607
|
+
};
|
|
53608
|
+
const loadScopedItemsWithOptionalGithub = (options) => {
|
|
53609
|
+
const scoped = listScopedWorkItems(scopeFrom(options));
|
|
53610
|
+
if (options.all !== true) return scoped;
|
|
53611
|
+
if (!isWorkspaceScope(options)) return loadSingleRepoWithGithub(options, scoped);
|
|
53612
|
+
return loadWorkspaceWithGithub(options, scoped);
|
|
53613
|
+
};
|
|
53614
|
+
const workList = (options = {}) => {
|
|
53615
|
+
const items = selectScopedWorkItems(loadScopedItemsWithOptionalGithub(options), {
|
|
53616
|
+
sort: options.sort,
|
|
53617
|
+
status: options.status,
|
|
53618
|
+
type: options.type
|
|
53619
|
+
});
|
|
53620
|
+
const showRepo = isWorkspaceScope(options);
|
|
53621
|
+
printWorkItemsTable(items, items[0]?.formula ?? "impact + urgency + risk + confidence - effort", { showRepo });
|
|
53622
|
+
return cleanResult({ items: items.map((item) => toListedItem(item, showRepo)) });
|
|
53623
|
+
};
|
|
53624
|
+
const workShow = (options) => {
|
|
53625
|
+
const payload = toListedItem(resolveScopedWorkItem(options.id, scopeFrom(options)), isWorkspaceScope(options));
|
|
53626
|
+
xyLog(JSON.stringify(payload, null, 2));
|
|
53627
|
+
return cleanResult({ item: payload });
|
|
53628
|
+
};
|
|
53629
|
+
const needsTriage = (item) => {
|
|
53630
|
+
return item.status === "open" && (item.priority === void 0 || item.area === void 0 || item.acceptanceCriteria.length === 0 || item.verification.length === 0);
|
|
53631
|
+
};
|
|
53632
|
+
const workTriage = (options = {}) => {
|
|
53633
|
+
const items = listScopedWorkItems(scopeFrom(options)).filter(needsTriage);
|
|
53634
|
+
const showRepo = isWorkspaceScope(options);
|
|
53635
|
+
printWorkItemsTable(items, items[0]?.formula ?? "impact + urgency + risk + confidence - effort", { showRepo });
|
|
53636
|
+
return cleanResult({ items: items.map((item) => toListedItem(item, showRepo)) });
|
|
53637
|
+
};
|
|
53638
|
+
//#endregion
|
|
53639
|
+
//#region src/actions/work/move.ts
|
|
53640
|
+
const stripGithubStore = (item) => {
|
|
53641
|
+
const { github: _github, ...restStores } = item.stores;
|
|
53642
|
+
return {
|
|
53643
|
+
...item,
|
|
53644
|
+
stores: restStores
|
|
53645
|
+
};
|
|
53646
|
+
};
|
|
53647
|
+
const withGithubLink = (item, number, url) => {
|
|
52758
53648
|
return {
|
|
52759
53649
|
...item,
|
|
52760
53650
|
stores: {
|
|
52761
53651
|
...item.stores,
|
|
52762
53652
|
github: {
|
|
52763
|
-
createdByXyWork,
|
|
53653
|
+
createdByXyWork: true,
|
|
52764
53654
|
number,
|
|
52765
|
-
...!createdByXyWork && { source: "github" },
|
|
52766
53655
|
url
|
|
52767
53656
|
}
|
|
52768
53657
|
}
|
|
52769
53658
|
};
|
|
52770
53659
|
};
|
|
52771
|
-
const
|
|
52772
|
-
const
|
|
52773
|
-
|
|
52774
|
-
|
|
52775
|
-
|
|
52776
|
-
|
|
52777
|
-
|
|
52778
|
-
|
|
52779
|
-
|
|
52780
|
-
|
|
52781
|
-
|
|
52782
|
-
|
|
52783
|
-
|
|
52784
|
-
|
|
52785
|
-
|
|
52786
|
-
|
|
52787
|
-
|
|
52788
|
-
|
|
52789
|
-
|
|
52790
|
-
|
|
52791
|
-
|
|
52792
|
-
|
|
52793
|
-
|
|
52794
|
-
|
|
52795
|
-
|
|
52796
|
-
|
|
52797
|
-
|
|
52798
|
-
|
|
52799
|
-
|
|
52800
|
-
|
|
52801
|
-
}
|
|
52802
|
-
|
|
52803
|
-
|
|
52804
|
-
|
|
52805
|
-
|
|
52806
|
-
|
|
52807
|
-
|
|
52808
|
-
|
|
52809
|
-
|
|
52810
|
-
title: linked.title,
|
|
52811
|
-
updatedAt: linked.updatedAt,
|
|
52812
|
-
url: ref.url
|
|
52813
|
-
});
|
|
52814
|
-
} catch (error) {
|
|
52815
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
52816
|
-
xyLog(`Sync create failed for ${item.id}: ${message}`);
|
|
52817
|
-
}
|
|
53660
|
+
const warnMissingAnchors = (item, destCwd) => {
|
|
53661
|
+
for (const anchor of item.anchors) {
|
|
53662
|
+
if (anchor.kind !== "file") continue;
|
|
53663
|
+
if (!existsSync(PATH.resolve(destCwd, anchor.path))) xyLog(`Warning: anchor path missing in destination: ${anchor.path}`);
|
|
53664
|
+
}
|
|
53665
|
+
};
|
|
53666
|
+
const cloneItemForMove = (source, updatedAt) => ({
|
|
53667
|
+
acceptanceCriteria: source.acceptanceCriteria,
|
|
53668
|
+
anchors: source.anchors,
|
|
53669
|
+
area: source.area,
|
|
53670
|
+
blockedReason: source.blockedReason,
|
|
53671
|
+
claimedAt: source.claimedAt,
|
|
53672
|
+
completedAt: source.completedAt,
|
|
53673
|
+
createdAt: source.createdAt,
|
|
53674
|
+
description: source.description,
|
|
53675
|
+
id: source.id,
|
|
53676
|
+
priority: source.priority,
|
|
53677
|
+
status: source.status,
|
|
53678
|
+
stores: { ...source.stores },
|
|
53679
|
+
tags: source.tags,
|
|
53680
|
+
title: source.title,
|
|
53681
|
+
type: source.type,
|
|
53682
|
+
updatedAt,
|
|
53683
|
+
verification: source.verification
|
|
53684
|
+
});
|
|
53685
|
+
const closeSourceGithubIssue = (source, sourceGithub, sourceNumber, sourceUrl, dest, moved, newIssueUrl) => {
|
|
53686
|
+
try {
|
|
53687
|
+
const note = [
|
|
53688
|
+
`Moved to workspace repo \`${dest.name}\` as \`${moved.id}\`.`,
|
|
53689
|
+
sourceUrl === void 0 ? void 0 : `Previous issue: ${sourceUrl}`,
|
|
53690
|
+
`New issue: ${newIssueUrl}`
|
|
53691
|
+
].filter((line) => line !== void 0).join("\n");
|
|
53692
|
+
sourceGithub.updateIssue(source.repoCwd, sourceNumber, {
|
|
53693
|
+
body: note,
|
|
53694
|
+
state: "closed"
|
|
53695
|
+
});
|
|
53696
|
+
} catch (error) {
|
|
53697
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
53698
|
+
xyLog(`Warning: could not close source GitHub issue #${String(sourceNumber)}: ${message}`);
|
|
52818
53699
|
}
|
|
52819
53700
|
};
|
|
52820
|
-
const
|
|
52821
|
-
const
|
|
52822
|
-
|
|
52823
|
-
|
|
52824
|
-
|
|
52825
|
-
if (linkedNumbers.has(issue.number)) continue;
|
|
52826
|
-
const xyWorkId = isXyWorkGithubIssue(issue) ? parseXyWorkIdFromGithubBody(issue.body) : void 0;
|
|
52827
|
-
if (xyWorkId !== void 0 && localById.has(xyWorkId)) {
|
|
52828
|
-
const existing = localById.get(xyWorkId);
|
|
52829
|
-
if (existing === void 0) continue;
|
|
52830
|
-
if (readGithubStoreNumber(existing.stores) === void 0) {
|
|
52831
|
-
const linked = {
|
|
52832
|
-
...withGithubLink(existing, issue.number, issue.url, true),
|
|
52833
|
-
updatedAt: nowIso(now)
|
|
52834
|
-
};
|
|
52835
|
-
writeWorkItem(cwd, linked);
|
|
52836
|
-
localById.set(xyWorkId, linked);
|
|
52837
|
-
linkedNumbers.add(issue.number);
|
|
52838
|
-
summary.updatedLocal.push(`${xyWorkId}↔#${String(issue.number)}`);
|
|
52839
|
-
}
|
|
52840
|
-
continue;
|
|
52841
|
-
}
|
|
52842
|
-
if (!githubIssueIsOpen(issue) && !isXyWorkGithubIssue(issue)) continue;
|
|
52843
|
-
const preferredId = xyWorkId;
|
|
52844
|
-
if (preferredId !== void 0 && localById.has(preferredId)) continue;
|
|
52845
|
-
try {
|
|
52846
|
-
const imported = importGithubIssueLocally(cwd, issue, now ?? /* @__PURE__ */ new Date(), preferredId);
|
|
52847
|
-
localById.set(imported.id, imported);
|
|
52848
|
-
linkedNumbers.add(issue.number);
|
|
52849
|
-
summary.importedLocal.push(`${imported.id}←#${String(issue.number)}`);
|
|
52850
|
-
} catch (error) {
|
|
52851
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
52852
|
-
xyLog(`Sync import failed for GitHub #${String(issue.number)}: ${message}`);
|
|
52853
|
-
}
|
|
53701
|
+
const recreateGithubOnMove = (source, dest, moved, options, sourceNumber) => {
|
|
53702
|
+
const destGithub = resolveGithubBridge(readWorkConfig(dest.cwd), dest.cwd, options.github);
|
|
53703
|
+
if (destGithub === void 0) {
|
|
53704
|
+
xyLog("Warning: destination GitHub unavailable; stripped GitHub link (run xy work sync later)");
|
|
53705
|
+
return stripGithubStore(moved);
|
|
52854
53706
|
}
|
|
52855
|
-
|
|
52856
|
-
const
|
|
52857
|
-
|
|
52858
|
-
|
|
52859
|
-
|
|
52860
|
-
|
|
52861
|
-
|
|
52862
|
-
|
|
52863
|
-
|
|
52864
|
-
|
|
52865
|
-
|
|
52866
|
-
summary.updatedGithub.push(`${item.id}→#${String(number)}`);
|
|
52867
|
-
issue.title = item.title;
|
|
52868
|
-
issue.updatedAt = nowIso(now);
|
|
52869
|
-
return {
|
|
52870
|
-
localChanged: false,
|
|
52871
|
-
next: item
|
|
52872
|
-
};
|
|
53707
|
+
const sourceGithub = resolveGithubBridge(readWorkConfig(source.repoCwd), source.repoCwd, options.github);
|
|
53708
|
+
const sourceUrl = readGithubStoreUrl(source.stores);
|
|
53709
|
+
try {
|
|
53710
|
+
const ref = destGithub.createIssue(dest.cwd, stripGithubStore(moved));
|
|
53711
|
+
const linked = withGithubLink(moved, ref.number, ref.url);
|
|
53712
|
+
if (sourceGithub !== void 0) closeSourceGithubIssue(source, sourceGithub, sourceNumber, sourceUrl, dest, linked, ref.url);
|
|
53713
|
+
xyLog(`GitHub: created #${String(ref.number)} in ${dest.name}; closed #${String(sourceNumber)} in ${source.repo}`);
|
|
53714
|
+
return linked;
|
|
53715
|
+
} catch (error) {
|
|
53716
|
+
xyLog(`Warning: GitHub recreate failed (${error instanceof Error ? error.message : String(error)}); moved local item without GitHub link`);
|
|
53717
|
+
return stripGithubStore(moved);
|
|
52873
53718
|
}
|
|
52874
|
-
return {
|
|
52875
|
-
localChanged: true,
|
|
52876
|
-
next: {
|
|
52877
|
-
...item,
|
|
52878
|
-
title: issue.title,
|
|
52879
|
-
updatedAt: nowIso(now)
|
|
52880
|
-
}
|
|
52881
|
-
};
|
|
52882
53719
|
};
|
|
52883
|
-
const
|
|
52884
|
-
|
|
52885
|
-
if (
|
|
52886
|
-
|
|
52887
|
-
|
|
53720
|
+
const resolveMoveEndpoints = (options) => {
|
|
53721
|
+
if (!isWorkspaceScope(options)) throw new Error("xy work move requires --workspace (or --workspace-file)");
|
|
53722
|
+
if (options.to.trim().length === 0) throw new Error("--to <repo> is required");
|
|
53723
|
+
const scope = {
|
|
53724
|
+
cwd: options.cwd,
|
|
53725
|
+
repo: options.from,
|
|
53726
|
+
workspace: options.workspace ?? true,
|
|
53727
|
+
workspaceFile: options.workspaceFile
|
|
52888
53728
|
};
|
|
52889
|
-
const
|
|
52890
|
-
|
|
53729
|
+
const source = resolveScopedWorkItem(options.id, scope);
|
|
53730
|
+
if (options.from !== void 0 && options.from.length > 0 && source.repo !== options.from) throw new Error(`Work item ${options.id} is in repo "${source.repo}", not "${options.from}"`);
|
|
53731
|
+
const dest = findWorkRepoByName(options.to, {
|
|
53732
|
+
cwd: options.cwd,
|
|
53733
|
+
workspace: options.workspace ?? true,
|
|
53734
|
+
workspaceFile: options.workspaceFile
|
|
53735
|
+
});
|
|
53736
|
+
if (!dest.hasStore) throw new Error(`Destination repo "${dest.name}" has no work store. Run: xy work init --workspace --repo ${dest.name}`);
|
|
53737
|
+
if (PATH.resolve(dest.cwd) === PATH.resolve(source.repoCwd)) throw new Error(`Source and destination repo are the same: ${dest.name}`);
|
|
53738
|
+
if (workItemExists(dest.cwd, source.id)) throw new Error(`Destination already has work item ${source.id}`);
|
|
52891
53739
|
return {
|
|
52892
|
-
|
|
52893
|
-
|
|
53740
|
+
dest,
|
|
53741
|
+
source
|
|
52894
53742
|
};
|
|
52895
53743
|
};
|
|
52896
|
-
|
|
52897
|
-
|
|
52898
|
-
|
|
52899
|
-
|
|
52900
|
-
|
|
52901
|
-
|
|
52902
|
-
|
|
52903
|
-
|
|
52904
|
-
|
|
52905
|
-
|
|
52906
|
-
|
|
52907
|
-
|
|
52908
|
-
|
|
52909
|
-
|
|
52910
|
-
|
|
52911
|
-
|
|
52912
|
-
|
|
52913
|
-
|
|
52914
|
-
|
|
52915
|
-
|
|
52916
|
-
|
|
52917
|
-
|
|
52918
|
-
|
|
52919
|
-
|
|
52920
|
-
|
|
52921
|
-
|
|
52922
|
-
|
|
52923
|
-
|
|
52924
|
-
|
|
53744
|
+
/**
|
|
53745
|
+
* Move a work item from one workspace folder repo to another.
|
|
53746
|
+
* Requires workspace scope (or an explicit workspace file).
|
|
53747
|
+
*/
|
|
53748
|
+
const workMove = (options) => {
|
|
53749
|
+
const { dest, source } = resolveMoveEndpoints(options);
|
|
53750
|
+
let moved = cloneItemForMove(source, nowIso(options.now));
|
|
53751
|
+
const sourceNumber = readGithubStoreNumber(source.stores);
|
|
53752
|
+
if (sourceNumber !== void 0) moved = recreateGithubOnMove(source, dest, moved, options, sourceNumber);
|
|
53753
|
+
warnMissingAnchors(moved, dest.cwd);
|
|
53754
|
+
writeWorkItem(dest.cwd, moved);
|
|
53755
|
+
deleteWorkItem(source.repoCwd, source.id);
|
|
53756
|
+
xyLog(`Moved ${moved.id}: ${source.repo} → ${dest.name}`);
|
|
53757
|
+
return cleanResult({
|
|
53758
|
+
from: source.repo,
|
|
53759
|
+
item: moved,
|
|
53760
|
+
to: dest.name
|
|
53761
|
+
});
|
|
53762
|
+
};
|
|
53763
|
+
//#endregion
|
|
53764
|
+
//#region src/actions/work/queue.ts
|
|
53765
|
+
const ELIGIBLE_QUEUE_STATUSES = /* @__PURE__ */ new Set([
|
|
53766
|
+
"open",
|
|
53767
|
+
"triaged",
|
|
53768
|
+
"queued"
|
|
53769
|
+
]);
|
|
53770
|
+
const INACTIVE_QUEUE_STATUSES = /* @__PURE__ */ new Set([
|
|
53771
|
+
"done",
|
|
53772
|
+
"wontfix",
|
|
53773
|
+
"claimed",
|
|
53774
|
+
"blocked"
|
|
53775
|
+
]);
|
|
53776
|
+
const NEXT_FALLBACK_STATUSES = /* @__PURE__ */ new Set([
|
|
53777
|
+
"open",
|
|
53778
|
+
"triaged",
|
|
53779
|
+
"queued"
|
|
53780
|
+
]);
|
|
53781
|
+
const eligibleStatuses = (status) => {
|
|
53782
|
+
return status === void 0 ? ELIGIBLE_QUEUE_STATUSES : /* @__PURE__ */ new Set([status]);
|
|
53783
|
+
};
|
|
53784
|
+
const markItemsQueued = (cwd, items, queuedAt) => {
|
|
53785
|
+
for (const item of items) if (item.status === "open" || item.status === "triaged") writeWorkItem(cwd, {
|
|
53786
|
+
...item,
|
|
53787
|
+
status: "queued",
|
|
53788
|
+
updatedAt: queuedAt
|
|
53789
|
+
});
|
|
53790
|
+
};
|
|
53791
|
+
const buildQueue = (name, selected, formula, queuedAt) => ({
|
|
53792
|
+
generatedAt: queuedAt,
|
|
53793
|
+
items: selected.map((item) => ({
|
|
53794
|
+
id: item.id,
|
|
53795
|
+
score: calculatePriorityScore(item.priority, formula)
|
|
53796
|
+
})),
|
|
53797
|
+
name,
|
|
53798
|
+
version: 1
|
|
53799
|
+
});
|
|
53800
|
+
const queueSingleRepo = (options) => {
|
|
53801
|
+
const cwd = options.cwd ?? process.cwd();
|
|
53802
|
+
const config = readWorkConfig(cwd);
|
|
53803
|
+
const name = options.name ?? config.defaultQueue;
|
|
53804
|
+
const selected = selectWorkItems(listWorkItems(cwd), { sort: "priority" }, config.priority.formula).filter((item) => eligibleStatuses(options.status).has(item.status)).slice(0, options.limit);
|
|
53805
|
+
const queuedAt = nowIso(options.now);
|
|
53806
|
+
const queue = buildQueue(name, selected, config.priority.formula, queuedAt);
|
|
53807
|
+
markItemsQueued(cwd, selected, queuedAt);
|
|
53808
|
+
writeWorkQueue(cwd, queue);
|
|
53809
|
+
xyLog(`Queued ${queue.items.length} item(s) in ${name}`);
|
|
53810
|
+
return cleanResult({
|
|
53811
|
+
items: selected,
|
|
53812
|
+
queue,
|
|
53813
|
+
queues: [{
|
|
53814
|
+
name,
|
|
53815
|
+
queue,
|
|
53816
|
+
repo: repoBasename(cwd)
|
|
53817
|
+
}]
|
|
53818
|
+
});
|
|
53819
|
+
};
|
|
53820
|
+
const queueWorkspace = (options) => {
|
|
53821
|
+
const selected = selectScopedWorkItems(listScopedWorkItems(scopeFrom(options)), { sort: "priority" }).filter((item) => eligibleStatuses(options.status).has(item.status)).slice(0, options.limit);
|
|
53822
|
+
const queuedAt = nowIso(options.now);
|
|
53823
|
+
const byRepo = /* @__PURE__ */ new Map();
|
|
53824
|
+
for (const item of selected) {
|
|
53825
|
+
const list = byRepo.get(item.repoCwd) ?? [];
|
|
53826
|
+
list.push(item);
|
|
53827
|
+
byRepo.set(item.repoCwd, list);
|
|
53828
|
+
}
|
|
53829
|
+
const queues = [];
|
|
53830
|
+
for (const [repoCwd, items] of byRepo) {
|
|
53831
|
+
const config = readWorkConfig(repoCwd);
|
|
53832
|
+
const name = options.name ?? config.defaultQueue;
|
|
53833
|
+
const queue = buildQueue(name, items.map(stripScope), items[0]?.formula ?? config.priority.formula, queuedAt);
|
|
53834
|
+
markItemsQueued(repoCwd, items.map(stripScope), queuedAt);
|
|
53835
|
+
writeWorkQueue(repoCwd, queue);
|
|
53836
|
+
queues.push({
|
|
53837
|
+
name,
|
|
53838
|
+
queue,
|
|
53839
|
+
repo: items[0]?.repo ?? PATH.basename(repoCwd)
|
|
53840
|
+
});
|
|
52925
53841
|
}
|
|
53842
|
+
xyLog(`Queued ${selected.length} item(s) across ${queues.length} repo(s)`);
|
|
53843
|
+
return cleanResult({
|
|
53844
|
+
items: selected,
|
|
53845
|
+
queue: queues[0]?.queue ?? {
|
|
53846
|
+
generatedAt: queuedAt,
|
|
53847
|
+
items: [],
|
|
53848
|
+
name: options.name ?? "default",
|
|
53849
|
+
version: 1
|
|
53850
|
+
},
|
|
53851
|
+
queues
|
|
53852
|
+
});
|
|
52926
53853
|
};
|
|
52927
|
-
const
|
|
52928
|
-
|
|
52929
|
-
|
|
52930
|
-
|
|
52931
|
-
|
|
52932
|
-
|
|
52933
|
-
|
|
52934
|
-
|
|
52935
|
-
} catch (error) {
|
|
52936
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
52937
|
-
xyLog(`Sync reconcile failed for ${item.id}/#${String(number)}: ${message}`);
|
|
52938
|
-
}
|
|
53854
|
+
const workQueue = (options = {}) => {
|
|
53855
|
+
if (!isWorkspaceScope(options)) return queueSingleRepo(options);
|
|
53856
|
+
return queueWorkspace(options);
|
|
53857
|
+
};
|
|
53858
|
+
const activeQueueItem = (cwd, queue) => {
|
|
53859
|
+
for (const entry of queue.items) {
|
|
53860
|
+
const item = readWorkItem(cwd, entry.id);
|
|
53861
|
+
if (!INACTIVE_QUEUE_STATUSES.has(item.status)) return item;
|
|
52939
53862
|
}
|
|
52940
53863
|
};
|
|
52941
|
-
const
|
|
52942
|
-
|
|
52943
|
-
|
|
53864
|
+
const tryReadQueue = (cwd, name) => {
|
|
53865
|
+
try {
|
|
53866
|
+
return readWorkQueue(cwd, name);
|
|
53867
|
+
} catch {
|
|
52944
53868
|
return;
|
|
52945
53869
|
}
|
|
52946
|
-
xyLog([
|
|
52947
|
-
"GitHub sync complete:",
|
|
52948
|
-
` created GitHub: ${String(summary.createdGithub.length)}`,
|
|
52949
|
-
` imported local: ${String(summary.importedLocal.length)}`,
|
|
52950
|
-
` updated local: ${String(summary.updatedLocal.length)}`,
|
|
52951
|
-
` updated GitHub: ${String(summary.updatedGithub.length)}`,
|
|
52952
|
-
` closed GitHub: ${String(summary.closedGithub.length)}`
|
|
52953
|
-
].join("\n"));
|
|
52954
53870
|
};
|
|
52955
|
-
|
|
52956
|
-
* Bidirectional sync between repo-local work items and GitHub Issues when available.
|
|
52957
|
-
*
|
|
52958
|
-
* - Local active items without a GitHub link → create a marked GitHub issue
|
|
52959
|
-
* - Open/closed GitHub issues not present locally → import as local items
|
|
52960
|
-
* - Linked pairs: reconcile title (newer wins) and status (done/wontfix ↔ closed)
|
|
52961
|
-
*/
|
|
52962
|
-
const workSync = (options = {}) => {
|
|
53871
|
+
const nextSingleRepo = (options) => {
|
|
52963
53872
|
const cwd = options.cwd ?? process.cwd();
|
|
52964
53873
|
const config = readWorkConfig(cwd);
|
|
52965
|
-
const
|
|
52966
|
-
const
|
|
52967
|
-
if (
|
|
52968
|
-
xyLog("
|
|
52969
|
-
return cleanResult({
|
|
53874
|
+
const queue = readWorkQueue(cwd, options.name ?? config.defaultQueue);
|
|
53875
|
+
const item = activeQueueItem(cwd, queue);
|
|
53876
|
+
if (item === void 0) {
|
|
53877
|
+
xyLog("No available queued work item");
|
|
53878
|
+
return cleanResult({ item: void 0 });
|
|
52970
53879
|
}
|
|
52971
|
-
const
|
|
52972
|
-
|
|
52973
|
-
|
|
52974
|
-
attachOrImportGithubIssues(cwd, issuesByNumber, summary, options.now);
|
|
52975
|
-
reconcileLinkedPairs(cwd, github, issuesByNumber, summary, options.now);
|
|
52976
|
-
logSyncSummary(summary);
|
|
52977
|
-
return cleanResult({ summary });
|
|
53880
|
+
const next = options.claim === true ? claimItem(cwd, item, options.now) : item;
|
|
53881
|
+
printWorkItemSummary(next, calculatePriorityScore(next.priority, config.priority.formula));
|
|
53882
|
+
return cleanResult({ item: next });
|
|
52978
53883
|
};
|
|
52979
|
-
|
|
52980
|
-
|
|
52981
|
-
const
|
|
52982
|
-
|
|
53884
|
+
const collectQueuedCandidates = (options) => {
|
|
53885
|
+
const repos = resolveWorkReposWithStore(scopeFrom(options));
|
|
53886
|
+
const candidates = [];
|
|
53887
|
+
for (const repo of repos) {
|
|
53888
|
+
const config = readWorkConfig(repo.cwd);
|
|
53889
|
+
const queueName = options.name ?? config.defaultQueue;
|
|
53890
|
+
const queue = tryReadQueue(repo.cwd, queueName);
|
|
53891
|
+
if (queue === void 0) continue;
|
|
53892
|
+
const item = activeQueueItem(repo.cwd, queue);
|
|
53893
|
+
if (item === void 0) continue;
|
|
53894
|
+
candidates.push({
|
|
53895
|
+
...item,
|
|
53896
|
+
formula: config.priority.formula,
|
|
53897
|
+
repo: repo.name,
|
|
53898
|
+
repoCwd: repo.cwd
|
|
53899
|
+
});
|
|
53900
|
+
}
|
|
53901
|
+
return candidates;
|
|
52983
53902
|
};
|
|
52984
|
-
const
|
|
52985
|
-
|
|
53903
|
+
const pickNextScoped = (options) => {
|
|
53904
|
+
const fromQueues = selectScopedWorkItems(collectQueuedCandidates(options), { sort: "priority" })[0];
|
|
53905
|
+
if (fromQueues !== void 0) return fromQueues;
|
|
53906
|
+
return selectScopedWorkItems(listScopedWorkItems(scopeFrom(options)).filter((item) => NEXT_FALLBACK_STATUSES.has(item.status)), { sort: "priority" })[0];
|
|
52986
53907
|
};
|
|
52987
|
-
const
|
|
52988
|
-
const
|
|
53908
|
+
const nextWorkspace = (options) => {
|
|
53909
|
+
const nextScoped = pickNextScoped(options);
|
|
53910
|
+
if (nextScoped === void 0) {
|
|
53911
|
+
xyLog("No available queued work item");
|
|
53912
|
+
return cleanResult({ item: void 0 });
|
|
53913
|
+
}
|
|
53914
|
+
const next = options.claim === true ? {
|
|
53915
|
+
...claimItem(nextScoped.repoCwd, stripScope(nextScoped), options.now),
|
|
53916
|
+
formula: nextScoped.formula,
|
|
53917
|
+
repo: nextScoped.repo,
|
|
53918
|
+
repoCwd: nextScoped.repoCwd
|
|
53919
|
+
} : nextScoped;
|
|
53920
|
+
printWorkItemSummary(next, calculatePriorityScore(next.priority, next.formula));
|
|
53921
|
+
return cleanResult({ item: next });
|
|
53922
|
+
};
|
|
53923
|
+
const workNext = (options = {}) => {
|
|
53924
|
+
if (!isWorkspaceScope(options)) return nextSingleRepo(options);
|
|
53925
|
+
return nextWorkspace(options);
|
|
53926
|
+
};
|
|
53927
|
+
//#endregion
|
|
53928
|
+
//#region src/actions/work/index.ts
|
|
53929
|
+
const initRepoResult = (cwd, name) => {
|
|
53930
|
+
const paths = ensureWorkStore(cwd);
|
|
52989
53931
|
return {
|
|
52990
|
-
|
|
52991
|
-
|
|
52992
|
-
|
|
53932
|
+
config: readWorkConfig(cwd),
|
|
53933
|
+
paths: {
|
|
53934
|
+
config: paths.configPath,
|
|
53935
|
+
items: paths.itemsDir,
|
|
53936
|
+
queues: paths.queuesDir
|
|
53937
|
+
},
|
|
53938
|
+
repo: name
|
|
52993
53939
|
};
|
|
52994
53940
|
};
|
|
52995
53941
|
const workInit = (options = {}) => {
|
|
53942
|
+
if (isWorkspaceScope(options)) {
|
|
53943
|
+
const results = resolveWorkRepos(options).map((repo) => {
|
|
53944
|
+
const result = initRepoResult(repo.cwd, repo.name);
|
|
53945
|
+
xyLog(`Initialized work store for ${repo.name} at ${workStorePaths(repo.cwd).rootDir}`);
|
|
53946
|
+
return result;
|
|
53947
|
+
});
|
|
53948
|
+
return cleanResult({
|
|
53949
|
+
config: results[0]?.config,
|
|
53950
|
+
paths: results[0]?.paths,
|
|
53951
|
+
repos: results
|
|
53952
|
+
});
|
|
53953
|
+
}
|
|
52996
53954
|
const cwd = options.cwd ?? process.cwd();
|
|
52997
|
-
const
|
|
52998
|
-
|
|
52999
|
-
const queuePath = workStorePaths(cwd).queuesDir;
|
|
53000
|
-
xyLog(`Initialized work store at ${paths.rootDir}`);
|
|
53955
|
+
const result = initRepoResult(cwd, repoBasename(cwd));
|
|
53956
|
+
xyLog(`Initialized work store at ${workStorePaths(cwd).rootDir}`);
|
|
53001
53957
|
return cleanResult({
|
|
53002
|
-
config,
|
|
53003
|
-
paths:
|
|
53004
|
-
|
|
53005
|
-
|
|
53006
|
-
|
|
53007
|
-
|
|
53958
|
+
config: result.config,
|
|
53959
|
+
paths: result.paths,
|
|
53960
|
+
repos: [result]
|
|
53961
|
+
});
|
|
53962
|
+
};
|
|
53963
|
+
const maybeInsertInline = (options, cwd, id, config) => {
|
|
53964
|
+
if (options.inline !== true) return;
|
|
53965
|
+
if (options.file === void 0) throw new Error("--inline requires --file");
|
|
53966
|
+
if (!config.stores.inline.enabled) throw new Error("Inline work store is disabled");
|
|
53967
|
+
insertInlineWorkMarker({
|
|
53968
|
+
cwd,
|
|
53969
|
+
filePath: options.file,
|
|
53970
|
+
id,
|
|
53971
|
+
line: options.line,
|
|
53972
|
+
marker: config.stores.inline.marker
|
|
53008
53973
|
});
|
|
53009
53974
|
};
|
|
53975
|
+
const linkGithubOnAdd = (cwd, item, github, now) => {
|
|
53976
|
+
const ref = github.createIssue(cwd, item);
|
|
53977
|
+
const linked = {
|
|
53978
|
+
...item,
|
|
53979
|
+
stores: {
|
|
53980
|
+
...item.stores,
|
|
53981
|
+
github: {
|
|
53982
|
+
createdByXyWork: true,
|
|
53983
|
+
number: ref.number,
|
|
53984
|
+
url: ref.url
|
|
53985
|
+
}
|
|
53986
|
+
},
|
|
53987
|
+
updatedAt: nowIso(now)
|
|
53988
|
+
};
|
|
53989
|
+
writeWorkItem(cwd, linked);
|
|
53990
|
+
return {
|
|
53991
|
+
item: linked,
|
|
53992
|
+
number: ref.number
|
|
53993
|
+
};
|
|
53994
|
+
};
|
|
53010
53995
|
const workAdd = (options) => {
|
|
53011
|
-
const
|
|
53996
|
+
const target = resolveAddTargetRepo(scopeFrom(options));
|
|
53997
|
+
const cwd = target.cwd;
|
|
53012
53998
|
const config = readWorkConfig(cwd);
|
|
53013
53999
|
const createdAt = nowIso(options.now);
|
|
53014
54000
|
const priority = priorityFromPartial({
|
|
@@ -53040,196 +54026,74 @@ const workAdd = (options) => {
|
|
|
53040
54026
|
verification: normalizeTextList(options.verification)
|
|
53041
54027
|
};
|
|
53042
54028
|
writeWorkItem(cwd, item);
|
|
53043
|
-
|
|
53044
|
-
if (options.file === void 0) throw new Error("--inline requires --file");
|
|
53045
|
-
if (!config.stores.inline.enabled) throw new Error("Inline work store is disabled");
|
|
53046
|
-
insertInlineWorkMarker({
|
|
53047
|
-
cwd,
|
|
53048
|
-
filePath: options.file,
|
|
53049
|
-
id,
|
|
53050
|
-
line: options.line,
|
|
53051
|
-
marker: config.stores.inline.marker
|
|
53052
|
-
});
|
|
53053
|
-
}
|
|
54029
|
+
maybeInsertInline(options, cwd, id, config);
|
|
53054
54030
|
const github = resolveGithubBridge(config, cwd, options.github);
|
|
54031
|
+
const repoLabel = isWorkspaceScope(options) ? ` [${target.name}]` : "";
|
|
53055
54032
|
if (github !== void 0) try {
|
|
53056
|
-
const
|
|
53057
|
-
item =
|
|
53058
|
-
|
|
53059
|
-
|
|
53060
|
-
|
|
53061
|
-
|
|
53062
|
-
|
|
53063
|
-
number: ref.number,
|
|
53064
|
-
url: ref.url
|
|
53065
|
-
}
|
|
53066
|
-
},
|
|
53067
|
-
updatedAt: nowIso(options.now)
|
|
53068
|
-
};
|
|
53069
|
-
writeWorkItem(cwd, item);
|
|
53070
|
-
xyLog(`Added ${item.id}: ${item.title} (GitHub #${String(ref.number)})`);
|
|
53071
|
-
return cleanResult({ item });
|
|
54033
|
+
const linked = linkGithubOnAdd(cwd, item, github, options.now);
|
|
54034
|
+
item = linked.item;
|
|
54035
|
+
xyLog(`Added ${item.id}: ${item.title}${repoLabel} (GitHub #${String(linked.number)})`);
|
|
54036
|
+
return cleanResult({
|
|
54037
|
+
item,
|
|
54038
|
+
repo: target.name
|
|
54039
|
+
});
|
|
53072
54040
|
} catch (error) {
|
|
53073
54041
|
const message = error instanceof Error ? error.message : String(error);
|
|
53074
|
-
xyLog(`Added ${item.id}: ${item.title} (GitHub issue skipped: ${message})`);
|
|
53075
|
-
return cleanResult({
|
|
54042
|
+
xyLog(`Added ${item.id}: ${item.title}${repoLabel} (GitHub issue skipped: ${message})`);
|
|
54043
|
+
return cleanResult({
|
|
54044
|
+
item,
|
|
54045
|
+
repo: target.name
|
|
54046
|
+
});
|
|
53076
54047
|
}
|
|
53077
|
-
xyLog(`Added ${item.id}: ${item.title}`);
|
|
53078
|
-
return cleanResult({
|
|
53079
|
-
|
|
53080
|
-
|
|
53081
|
-
|
|
53082
|
-
|
|
53083
|
-
|
|
53084
|
-
}
|
|
53085
|
-
|
|
53086
|
-
|
|
53087
|
-
|
|
53088
|
-
|
|
53089
|
-
|
|
53090
|
-
|
|
53091
|
-
|
|
53092
|
-
|
|
53093
|
-
|
|
53094
|
-
|
|
54048
|
+
xyLog(`Added ${item.id}: ${item.title}${repoLabel}`);
|
|
54049
|
+
return cleanResult({
|
|
54050
|
+
item,
|
|
54051
|
+
repo: target.name
|
|
54052
|
+
});
|
|
54053
|
+
};
|
|
54054
|
+
/** Sync one repo, or each store in a code-workspace when --workspace is set. */
|
|
54055
|
+
const workSyncScoped = (options = {}) => {
|
|
54056
|
+
if (!isWorkspaceScope(options)) {
|
|
54057
|
+
const result = workSync({
|
|
54058
|
+
cwd: options.cwd,
|
|
54059
|
+
github: options.github,
|
|
54060
|
+
now: options.now
|
|
54061
|
+
});
|
|
54062
|
+
return cleanResult({
|
|
54063
|
+
results: [{
|
|
54064
|
+
repo: PATH.basename(PATH.resolve(options.cwd ?? process.cwd())),
|
|
54065
|
+
summary: result.data.summary
|
|
54066
|
+
}],
|
|
54067
|
+
summary: result.data.summary
|
|
54068
|
+
});
|
|
54069
|
+
}
|
|
54070
|
+
const repos = resolveWorkReposWithStore(scopeFrom(options));
|
|
54071
|
+
const results = [];
|
|
54072
|
+
for (const repo of repos) {
|
|
54073
|
+
xyLog(`Syncing ${repo.name}...`);
|
|
54074
|
+
try {
|
|
54075
|
+
const result = workSync({
|
|
54076
|
+
cwd: repo.cwd,
|
|
54077
|
+
github: options.github,
|
|
54078
|
+
now: options.now
|
|
54079
|
+
});
|
|
54080
|
+
results.push({
|
|
54081
|
+
repo: repo.name,
|
|
54082
|
+
summary: result.data.summary
|
|
54083
|
+
});
|
|
53095
54084
|
} catch (error) {
|
|
53096
|
-
|
|
54085
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
54086
|
+
xyLog(`Sync failed for ${repo.name}: ${message}`);
|
|
54087
|
+
results.push({
|
|
54088
|
+
repo: repo.name,
|
|
54089
|
+
summary: { error: message }
|
|
54090
|
+
});
|
|
53097
54091
|
}
|
|
53098
54092
|
}
|
|
53099
|
-
|
|
53100
|
-
|
|
53101
|
-
|
|
53102
|
-
};
|
|
53103
|
-
const workShow = (options) => {
|
|
53104
|
-
const item = readWorkItem(options.cwd ?? process.cwd(), options.id);
|
|
53105
|
-
xyLog(JSON.stringify(item, null, 2));
|
|
53106
|
-
return cleanResult({ item });
|
|
53107
|
-
};
|
|
53108
|
-
const needsTriage = (item) => {
|
|
53109
|
-
return item.status === "open" && (item.priority === void 0 || item.area === void 0 || item.acceptanceCriteria.length === 0 || item.verification.length === 0);
|
|
53110
|
-
};
|
|
53111
|
-
const workTriage = (options = {}) => {
|
|
53112
|
-
const cwd = options.cwd ?? process.cwd();
|
|
53113
|
-
const config = readWorkConfig(cwd);
|
|
53114
|
-
const items = listWorkItems(cwd).filter(needsTriage);
|
|
53115
|
-
printWorkItemsTable(items, config.priority.formula);
|
|
53116
|
-
return cleanResult({ items });
|
|
53117
|
-
};
|
|
53118
|
-
const workQueue = (options = {}) => {
|
|
53119
|
-
const cwd = options.cwd ?? process.cwd();
|
|
53120
|
-
const config = readWorkConfig(cwd);
|
|
53121
|
-
const name = options.name ?? config.defaultQueue;
|
|
53122
|
-
const eligibleStatuses = options.status === void 0 ? /* @__PURE__ */ new Set([
|
|
53123
|
-
"open",
|
|
53124
|
-
"triaged",
|
|
53125
|
-
"queued"
|
|
53126
|
-
]) : /* @__PURE__ */ new Set([options.status]);
|
|
53127
|
-
const selected = selectWorkItems(listWorkItems(cwd), { sort: "priority" }, config.priority.formula).filter((item) => eligibleStatuses.has(item.status)).slice(0, options.limit);
|
|
53128
|
-
const queuedAt = nowIso(options.now);
|
|
53129
|
-
const queue = {
|
|
53130
|
-
generatedAt: queuedAt,
|
|
53131
|
-
items: selected.map((item) => ({
|
|
53132
|
-
id: item.id,
|
|
53133
|
-
score: calculatePriorityScore(item.priority, config.priority.formula)
|
|
53134
|
-
})),
|
|
53135
|
-
name,
|
|
53136
|
-
version: 1
|
|
53137
|
-
};
|
|
53138
|
-
for (const item of selected) if (item.status === "open" || item.status === "triaged") writeWorkItem(cwd, {
|
|
53139
|
-
...item,
|
|
53140
|
-
status: "queued",
|
|
53141
|
-
updatedAt: queuedAt
|
|
53142
|
-
});
|
|
53143
|
-
writeWorkQueue(cwd, queue);
|
|
53144
|
-
xyLog(`Queued ${queue.items.length} item(s) in ${name}`);
|
|
53145
|
-
return cleanResult({ queue });
|
|
53146
|
-
};
|
|
53147
|
-
const activeQueueItem = (cwd, queue) => {
|
|
53148
|
-
for (const entry of queue.items) {
|
|
53149
|
-
const item = readWorkItem(cwd, entry.id);
|
|
53150
|
-
if (![
|
|
53151
|
-
"done",
|
|
53152
|
-
"wontfix",
|
|
53153
|
-
"claimed",
|
|
53154
|
-
"blocked"
|
|
53155
|
-
].includes(item.status)) return item;
|
|
53156
|
-
}
|
|
53157
|
-
};
|
|
53158
|
-
const workNext = (options = {}) => {
|
|
53159
|
-
const cwd = options.cwd ?? process.cwd();
|
|
53160
|
-
const config = readWorkConfig(cwd);
|
|
53161
|
-
const queue = readWorkQueue(cwd, options.name ?? config.defaultQueue);
|
|
53162
|
-
const item = activeQueueItem(cwd, queue);
|
|
53163
|
-
if (item === void 0) {
|
|
53164
|
-
xyLog("No available queued work item");
|
|
53165
|
-
return cleanResult({ item: void 0 });
|
|
53166
|
-
}
|
|
53167
|
-
const next = options.claim === true ? claimItem(cwd, item, options.now) : item;
|
|
53168
|
-
printWorkItemSummary(next, calculatePriorityScore(next.priority, config.priority.formula));
|
|
53169
|
-
return cleanResult({ item: next });
|
|
53170
|
-
};
|
|
53171
|
-
const claimItem = (cwd, item, now) => {
|
|
53172
|
-
if (item.status === "done" || item.status === "wontfix") throw new Error(`Cannot claim ${item.status} item: ${item.id}`);
|
|
53173
|
-
const claimedAt = nowIso(now);
|
|
53174
|
-
const claimed = {
|
|
53175
|
-
...item,
|
|
53176
|
-
claimedAt,
|
|
53177
|
-
status: "claimed",
|
|
53178
|
-
updatedAt: claimedAt
|
|
53179
|
-
};
|
|
53180
|
-
writeWorkItem(cwd, claimed);
|
|
53181
|
-
return claimed;
|
|
53182
|
-
};
|
|
53183
|
-
const workClaim = (options) => {
|
|
53184
|
-
const cwd = options.cwd ?? process.cwd();
|
|
53185
|
-
const item = claimItem(cwd, readWorkItem(cwd, options.id), options.now);
|
|
53186
|
-
xyLog(`Claimed ${item.id}`);
|
|
53187
|
-
return cleanResult({ item });
|
|
53188
|
-
};
|
|
53189
|
-
const workDone = (options) => {
|
|
53190
|
-
if (options.evidence.trim().length === 0) throw new Error("done requires non-empty verification evidence");
|
|
53191
|
-
const cwd = options.cwd ?? process.cwd();
|
|
53192
|
-
const item = readWorkItem(cwd, options.id);
|
|
53193
|
-
const completedAt = nowIso(options.now);
|
|
53194
|
-
const verification = [...item.verification, options.evidence.trim()];
|
|
53195
|
-
const done = {
|
|
53196
|
-
...item,
|
|
53197
|
-
completedAt,
|
|
53198
|
-
status: "done",
|
|
53199
|
-
updatedAt: completedAt,
|
|
53200
|
-
verification: [...new Set(verification)]
|
|
53201
|
-
};
|
|
53202
|
-
writeWorkItem(cwd, done);
|
|
53203
|
-
xyLog(`Done ${done.id}`);
|
|
53204
|
-
return cleanResult({ item: done });
|
|
53205
|
-
};
|
|
53206
|
-
const workUpdate = (options) => {
|
|
53207
|
-
const cwd = options.cwd ?? process.cwd();
|
|
53208
|
-
const item = readWorkItem(cwd, options.id);
|
|
53209
|
-
const priority = priorityFromPartial({
|
|
53210
|
-
confidence: options.confidence,
|
|
53211
|
-
effort: options.effort,
|
|
53212
|
-
impact: options.impact,
|
|
53213
|
-
risk: options.risk,
|
|
53214
|
-
urgency: options.urgency
|
|
54093
|
+
return cleanResult({
|
|
54094
|
+
results,
|
|
54095
|
+
summary: results[0]?.summary
|
|
53215
54096
|
});
|
|
53216
|
-
const updatedAt = nowIso(options.now);
|
|
53217
|
-
const updated = {
|
|
53218
|
-
...item,
|
|
53219
|
-
acceptanceCriteria: options.acceptanceCriteria === void 0 ? item.acceptanceCriteria : normalizeTextList(options.acceptanceCriteria),
|
|
53220
|
-
area: options.area ?? item.area,
|
|
53221
|
-
blockedReason: options.blockedReason ?? item.blockedReason,
|
|
53222
|
-
description: options.description ?? item.description,
|
|
53223
|
-
priority: priority === void 0 ? item.priority : validateWorkPriority(priority),
|
|
53224
|
-
status: options.status ?? item.status,
|
|
53225
|
-
tags: options.tags === void 0 ? item.tags : normalizeTags(options.tags),
|
|
53226
|
-
title: options.title ?? item.title,
|
|
53227
|
-
updatedAt,
|
|
53228
|
-
verification: options.verification === void 0 ? item.verification : normalizeTextList(options.verification)
|
|
53229
|
-
};
|
|
53230
|
-
writeWorkItem(cwd, updated);
|
|
53231
|
-
xyLog(`Updated ${updated.id}`);
|
|
53232
|
-
return cleanResult({ item: updated });
|
|
53233
54097
|
};
|
|
53234
54098
|
//#endregion
|
|
53235
54099
|
//#region src/xy/build/buildCommand.ts
|
|
@@ -53625,7 +54489,7 @@ const cleanCommand$1 = {
|
|
|
53625
54489
|
await withEnvelope("packman clean", () => packmanClean({ isVerbose: !!Boolean(argv.verbose) }));
|
|
53626
54490
|
}
|
|
53627
54491
|
};
|
|
53628
|
-
const lintCommand$
|
|
54492
|
+
const lintCommand$3 = {
|
|
53629
54493
|
command: "lint",
|
|
53630
54494
|
describe: "Check package manager configuration settings",
|
|
53631
54495
|
builder: (yargs) => {
|
|
@@ -53653,7 +54517,7 @@ const lintCommand$2 = {
|
|
|
53653
54517
|
};
|
|
53654
54518
|
const packmanCommand = {
|
|
53655
54519
|
builder: (yargs) => {
|
|
53656
|
-
return yargs.command(cleanCommand$1).command(convertCommand).command(lintCommand$
|
|
54520
|
+
return yargs.command(cleanCommand$1).command(convertCommand).command(lintCommand$3).demandCommand(1, "Please specify a packman subcommand").strictCommands();
|
|
53657
54521
|
},
|
|
53658
54522
|
command: "packman",
|
|
53659
54523
|
describe: "Package Manager - Configuration and conversion utilities",
|
|
@@ -53724,7 +54588,7 @@ const initCommand$2 = {
|
|
|
53724
54588
|
};
|
|
53725
54589
|
//#endregion
|
|
53726
54590
|
//#region src/xy/common/repo/lintCommand.ts
|
|
53727
|
-
const lintCommand$
|
|
54591
|
+
const lintCommand$2 = {
|
|
53728
54592
|
command: "lint",
|
|
53729
54593
|
describe: "Check monorepo package structure",
|
|
53730
54594
|
builder: (yargs) => {
|
|
@@ -53751,7 +54615,7 @@ const lintCommand$1 = {
|
|
|
53751
54615
|
//#region src/xy/common/repo/index.ts
|
|
53752
54616
|
const repoCommand = {
|
|
53753
54617
|
builder: (yargs) => {
|
|
53754
|
-
return yargs.command(initCommand$2).command(lintCommand$
|
|
54618
|
+
return yargs.command(initCommand$2).command(lintCommand$2).demandCommand(1, "Please specify a repo subcommand").strictCommands();
|
|
53755
54619
|
},
|
|
53756
54620
|
command: "repo",
|
|
53757
54621
|
describe: "Repo - Repository structure utilities",
|
|
@@ -53934,11 +54798,37 @@ const optionalNumber = (value) => {
|
|
|
53934
54798
|
const optionalString = (value) => {
|
|
53935
54799
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
53936
54800
|
};
|
|
54801
|
+
/** Shared --workspace / --workspace-file / --repo flags for work subcommands. */
|
|
54802
|
+
const withWorkScopeOptions = (yargs) => {
|
|
54803
|
+
const y = yargs;
|
|
54804
|
+
y.option("workspace", {
|
|
54805
|
+
default: false,
|
|
54806
|
+
describe: "Operate across folders in the active/local *.code-workspace",
|
|
54807
|
+
type: "boolean"
|
|
54808
|
+
});
|
|
54809
|
+
y.option("workspace-file", {
|
|
54810
|
+
describe: "Explicit *.code-workspace path (implies --workspace)",
|
|
54811
|
+
type: "string"
|
|
54812
|
+
});
|
|
54813
|
+
y.option("repo", {
|
|
54814
|
+
describe: "Limit or target a single workspace folder by name",
|
|
54815
|
+
type: "string"
|
|
54816
|
+
});
|
|
54817
|
+
return yargs;
|
|
54818
|
+
};
|
|
54819
|
+
const scopeFromArgv = (argv) => {
|
|
54820
|
+
const workspaceFile = optionalString(argv["workspace-file"]);
|
|
54821
|
+
return {
|
|
54822
|
+
repo: optionalString(argv.repo),
|
|
54823
|
+
workspace: Boolean(argv.workspace) || workspaceFile !== void 0,
|
|
54824
|
+
workspaceFile
|
|
54825
|
+
};
|
|
54826
|
+
};
|
|
53937
54827
|
//#endregion
|
|
53938
54828
|
//#region src/xy/common/work/addCommand.ts
|
|
53939
54829
|
const addCommand = {
|
|
53940
54830
|
builder: (yargs) => {
|
|
53941
|
-
return yargs.positional("type", {
|
|
54831
|
+
return withWorkScopeOptions(yargs.positional("type", {
|
|
53942
54832
|
choices: WORK_TYPES,
|
|
53943
54833
|
describe: "Work item type",
|
|
53944
54834
|
type: "string"
|
|
@@ -53988,12 +54878,14 @@ const addCommand = {
|
|
|
53988
54878
|
}).option("confidence", {
|
|
53989
54879
|
describe: "Priority confidence from 1 to 5",
|
|
53990
54880
|
type: "number"
|
|
53991
|
-
});
|
|
54881
|
+
}));
|
|
53992
54882
|
},
|
|
53993
54883
|
command: "add <type> <title>",
|
|
53994
54884
|
describe: "Create a work item (also creates a GitHub issue when available)",
|
|
53995
54885
|
handler: async (argv) => {
|
|
54886
|
+
const scope = scopeFromArgv(argv);
|
|
53996
54887
|
await withEnvelope("work add", () => workAdd({
|
|
54888
|
+
...scope,
|
|
53997
54889
|
acceptanceCriteria: stringArray(argv.acceptance),
|
|
53998
54890
|
area: optionalString(argv.area),
|
|
53999
54891
|
confidence: optionalNumber(argv.confidence),
|
|
@@ -54016,34 +54908,40 @@ const addCommand = {
|
|
|
54016
54908
|
//#region src/xy/common/work/claimCommand.ts
|
|
54017
54909
|
const claimCommand = {
|
|
54018
54910
|
builder: (yargs) => {
|
|
54019
|
-
return yargs.positional("id", {
|
|
54911
|
+
return withWorkScopeOptions(yargs.positional("id", {
|
|
54020
54912
|
describe: "Work item id",
|
|
54021
54913
|
type: "string"
|
|
54022
|
-
});
|
|
54914
|
+
}));
|
|
54023
54915
|
},
|
|
54024
54916
|
command: "claim <id>",
|
|
54025
54917
|
describe: "Claim a work item",
|
|
54026
54918
|
handler: async (argv) => {
|
|
54027
|
-
|
|
54919
|
+
const scope = scopeFromArgv(argv);
|
|
54920
|
+
await withEnvelope("work claim", () => workClaim({
|
|
54921
|
+
...scope,
|
|
54922
|
+
id: String(argv.id)
|
|
54923
|
+
}));
|
|
54028
54924
|
}
|
|
54029
54925
|
};
|
|
54030
54926
|
//#endregion
|
|
54031
54927
|
//#region src/xy/common/work/doneCommand.ts
|
|
54032
54928
|
const doneCommand = {
|
|
54033
54929
|
builder: (yargs) => {
|
|
54034
|
-
return yargs.positional("id", {
|
|
54930
|
+
return withWorkScopeOptions(yargs.positional("id", {
|
|
54035
54931
|
describe: "Work item id",
|
|
54036
54932
|
type: "string"
|
|
54037
54933
|
}).option("evidence", {
|
|
54038
54934
|
demandOption: true,
|
|
54039
54935
|
describe: "Verification evidence proving the work is complete",
|
|
54040
54936
|
type: "string"
|
|
54041
|
-
});
|
|
54937
|
+
}));
|
|
54042
54938
|
},
|
|
54043
54939
|
command: "done <id>",
|
|
54044
54940
|
describe: "Mark a work item done with verification evidence",
|
|
54045
54941
|
handler: async (argv) => {
|
|
54942
|
+
const scope = scopeFromArgv(argv);
|
|
54046
54943
|
await withEnvelope("work done", () => workDone({
|
|
54944
|
+
...scope,
|
|
54047
54945
|
evidence: String(argv.evidence),
|
|
54048
54946
|
id: String(argv.id)
|
|
54049
54947
|
}));
|
|
@@ -54052,17 +54950,47 @@ const doneCommand = {
|
|
|
54052
54950
|
//#endregion
|
|
54053
54951
|
//#region src/xy/common/work/initCommand.ts
|
|
54054
54952
|
const initCommand$1 = {
|
|
54953
|
+
builder: (yargs) => withWorkScopeOptions(yargs),
|
|
54055
54954
|
command: "init",
|
|
54056
54955
|
describe: "Initialize the repo-local work item store",
|
|
54057
|
-
handler: async () => {
|
|
54058
|
-
|
|
54956
|
+
handler: async (argv) => {
|
|
54957
|
+
const scope = scopeFromArgv(argv);
|
|
54958
|
+
await withEnvelope("work init", () => workInit(scope));
|
|
54959
|
+
}
|
|
54960
|
+
};
|
|
54961
|
+
//#endregion
|
|
54962
|
+
//#region src/xy/common/work/lintCommand.ts
|
|
54963
|
+
const lintCommand$1 = {
|
|
54964
|
+
builder: (yargs) => {
|
|
54965
|
+
return withWorkScopeOptions(yargs.option("strict", {
|
|
54966
|
+
default: false,
|
|
54967
|
+
describe: "Fail on warnings",
|
|
54968
|
+
type: "boolean"
|
|
54969
|
+
}).option("rules", {
|
|
54970
|
+
default: false,
|
|
54971
|
+
describe: "List supported work lint rules and their effective levels",
|
|
54972
|
+
type: "boolean"
|
|
54973
|
+
}));
|
|
54974
|
+
},
|
|
54975
|
+
command: "lint",
|
|
54976
|
+
describe: "Lint work store health (gitignore, GitHub availability, sync drift)",
|
|
54977
|
+
handler: async (argv) => {
|
|
54978
|
+
if (argv.rules === true) {
|
|
54979
|
+
await withEnvelope("work lint rules", async () => ruleCatalogResult(await getWorkLintRuleCatalog(), RULE_COMMANDS.workLint.title));
|
|
54980
|
+
return;
|
|
54981
|
+
}
|
|
54982
|
+
const scope = scopeFromArgv(argv);
|
|
54983
|
+
await withEnvelope("work lint", () => workLint({
|
|
54984
|
+
...scope,
|
|
54985
|
+
strict: Boolean(argv.strict)
|
|
54986
|
+
}));
|
|
54059
54987
|
}
|
|
54060
54988
|
};
|
|
54061
54989
|
//#endregion
|
|
54062
54990
|
//#region src/xy/common/work/listCommand.ts
|
|
54063
54991
|
const listCommand = {
|
|
54064
54992
|
builder: (yargs) => {
|
|
54065
|
-
return yargs.option("all", {
|
|
54993
|
+
return withWorkScopeOptions(yargs.option("all", {
|
|
54066
54994
|
default: false,
|
|
54067
54995
|
describe: "Also list/normalize open GitHub issues not created by xy work",
|
|
54068
54996
|
type: "boolean"
|
|
@@ -54079,12 +55007,14 @@ const listCommand = {
|
|
|
54079
55007
|
default: "created",
|
|
54080
55008
|
describe: "Sort order",
|
|
54081
55009
|
type: "string"
|
|
54082
|
-
});
|
|
55010
|
+
}));
|
|
54083
55011
|
},
|
|
54084
55012
|
command: "list",
|
|
54085
55013
|
describe: "List work items",
|
|
54086
55014
|
handler: async (argv) => {
|
|
55015
|
+
const scope = scopeFromArgv(argv);
|
|
54087
55016
|
await withEnvelope("work list", () => workList({
|
|
55017
|
+
...scope,
|
|
54088
55018
|
all: Boolean(argv.all),
|
|
54089
55019
|
sort: argv.sort,
|
|
54090
55020
|
status: argv.status,
|
|
@@ -54093,22 +55023,53 @@ const listCommand = {
|
|
|
54093
55023
|
}
|
|
54094
55024
|
};
|
|
54095
55025
|
//#endregion
|
|
55026
|
+
//#region src/xy/common/work/moveCommand.ts
|
|
55027
|
+
const moveCommand = {
|
|
55028
|
+
builder: (yargs) => {
|
|
55029
|
+
return withWorkScopeOptions(yargs.positional("id", {
|
|
55030
|
+
describe: "Work item id",
|
|
55031
|
+
type: "string"
|
|
55032
|
+
}).option("to", {
|
|
55033
|
+
demandOption: true,
|
|
55034
|
+
describe: "Destination workspace folder name",
|
|
55035
|
+
type: "string"
|
|
55036
|
+
}).option("from", {
|
|
55037
|
+
describe: "Source workspace folder name (disambiguates id)",
|
|
55038
|
+
type: "string"
|
|
55039
|
+
}));
|
|
55040
|
+
},
|
|
55041
|
+
command: "move <id>",
|
|
55042
|
+
describe: "Move a work item between workspace folder repos",
|
|
55043
|
+
handler: async (argv) => {
|
|
55044
|
+
const scope = scopeFromArgv(argv);
|
|
55045
|
+
await withEnvelope("work move", () => workMove({
|
|
55046
|
+
...scope,
|
|
55047
|
+
from: optionalString(argv.from),
|
|
55048
|
+
id: String(argv.id),
|
|
55049
|
+
to: String(argv.to),
|
|
55050
|
+
workspace: true
|
|
55051
|
+
}));
|
|
55052
|
+
}
|
|
55053
|
+
};
|
|
55054
|
+
//#endregion
|
|
54096
55055
|
//#region src/xy/common/work/nextCommand.ts
|
|
54097
55056
|
const nextCommand = {
|
|
54098
55057
|
builder: (yargs) => {
|
|
54099
|
-
return yargs.option("name", {
|
|
55058
|
+
return withWorkScopeOptions(yargs.option("name", {
|
|
54100
55059
|
describe: "Queue name",
|
|
54101
55060
|
type: "string"
|
|
54102
55061
|
}).option("claim", {
|
|
54103
55062
|
default: false,
|
|
54104
55063
|
describe: "Claim the returned item",
|
|
54105
55064
|
type: "boolean"
|
|
54106
|
-
});
|
|
55065
|
+
}));
|
|
54107
55066
|
},
|
|
54108
55067
|
command: "next",
|
|
54109
55068
|
describe: "Show the next available queued work item",
|
|
54110
55069
|
handler: async (argv) => {
|
|
55070
|
+
const scope = scopeFromArgv(argv);
|
|
54111
55071
|
await withEnvelope("work next", () => workNext({
|
|
55072
|
+
...scope,
|
|
54112
55073
|
claim: Boolean(argv.claim),
|
|
54113
55074
|
name: optionalString(argv.name)
|
|
54114
55075
|
}));
|
|
@@ -54118,7 +55079,7 @@ const nextCommand = {
|
|
|
54118
55079
|
//#region src/xy/common/work/queueCommand.ts
|
|
54119
55080
|
const queueCommand = {
|
|
54120
55081
|
builder: (yargs) => {
|
|
54121
|
-
return yargs.option("name", {
|
|
55082
|
+
return withWorkScopeOptions(yargs.option("name", {
|
|
54122
55083
|
describe: "Queue name",
|
|
54123
55084
|
type: "string"
|
|
54124
55085
|
}).option("limit", {
|
|
@@ -54128,12 +55089,14 @@ const queueCommand = {
|
|
|
54128
55089
|
choices: WORK_STATUSES,
|
|
54129
55090
|
describe: "Only queue items with this status",
|
|
54130
55091
|
type: "string"
|
|
54131
|
-
});
|
|
55092
|
+
}));
|
|
54132
55093
|
},
|
|
54133
55094
|
command: "queue",
|
|
54134
55095
|
describe: "Materialize a priority-sorted work queue",
|
|
54135
55096
|
handler: async (argv) => {
|
|
55097
|
+
const scope = scopeFromArgv(argv);
|
|
54136
55098
|
await withEnvelope("work queue", () => workQueue({
|
|
55099
|
+
...scope,
|
|
54137
55100
|
limit: optionalNumber(argv.limit),
|
|
54138
55101
|
name: optionalString(argv.name),
|
|
54139
55102
|
status: argv.status
|
|
@@ -54143,41 +55106,49 @@ const queueCommand = {
|
|
|
54143
55106
|
//#endregion
|
|
54144
55107
|
//#region src/xy/common/work/showCommand.ts
|
|
54145
55108
|
const showCommand = {
|
|
54146
|
-
command: "show <id>",
|
|
54147
|
-
describe: "Show a work item as JSON",
|
|
54148
55109
|
builder: (yargs) => {
|
|
54149
|
-
return yargs.positional("id", {
|
|
55110
|
+
return withWorkScopeOptions(yargs.positional("id", {
|
|
54150
55111
|
describe: "Work item id",
|
|
54151
55112
|
type: "string"
|
|
54152
|
-
});
|
|
55113
|
+
}));
|
|
54153
55114
|
},
|
|
55115
|
+
command: "show <id>",
|
|
55116
|
+
describe: "Show a work item as JSON",
|
|
54154
55117
|
handler: async (argv) => {
|
|
54155
|
-
|
|
55118
|
+
const scope = scopeFromArgv(argv);
|
|
55119
|
+
await withEnvelope("work show", () => workShow({
|
|
55120
|
+
...scope,
|
|
55121
|
+
id: String(argv.id)
|
|
55122
|
+
}));
|
|
54156
55123
|
}
|
|
54157
55124
|
};
|
|
54158
55125
|
//#endregion
|
|
54159
55126
|
//#region src/xy/common/work/syncCommand.ts
|
|
54160
55127
|
const syncCommand = {
|
|
55128
|
+
builder: (yargs) => withWorkScopeOptions(yargs),
|
|
54161
55129
|
command: "sync",
|
|
54162
55130
|
describe: "Sync repo-local work items with GitHub Issues when available",
|
|
54163
|
-
handler: async () => {
|
|
54164
|
-
|
|
55131
|
+
handler: async (argv) => {
|
|
55132
|
+
const scope = scopeFromArgv(argv);
|
|
55133
|
+
await withEnvelope("work sync", () => workSyncScoped(scope));
|
|
54165
55134
|
}
|
|
54166
55135
|
};
|
|
54167
55136
|
//#endregion
|
|
54168
55137
|
//#region src/xy/common/work/triageCommand.ts
|
|
54169
55138
|
const triageCommand = {
|
|
55139
|
+
builder: (yargs) => withWorkScopeOptions(yargs),
|
|
54170
55140
|
command: "triage",
|
|
54171
55141
|
describe: "List open work items missing triage fields",
|
|
54172
|
-
handler: async () => {
|
|
54173
|
-
|
|
55142
|
+
handler: async (argv) => {
|
|
55143
|
+
const scope = scopeFromArgv(argv);
|
|
55144
|
+
await withEnvelope("work triage", () => workTriage(scope));
|
|
54174
55145
|
}
|
|
54175
55146
|
};
|
|
54176
55147
|
//#endregion
|
|
54177
55148
|
//#region src/xy/common/work/updateCommand.ts
|
|
54178
55149
|
const updateCommand = {
|
|
54179
55150
|
builder: (yargs) => {
|
|
54180
|
-
return yargs.positional("id", {
|
|
55151
|
+
return withWorkScopeOptions(yargs.positional("id", {
|
|
54181
55152
|
describe: "Work item id",
|
|
54182
55153
|
type: "string"
|
|
54183
55154
|
}).option("title", {
|
|
@@ -54208,12 +55179,14 @@ const updateCommand = {
|
|
|
54208
55179
|
array: true,
|
|
54209
55180
|
describe: "Replace verification entries; repeatable",
|
|
54210
55181
|
type: "string"
|
|
54211
|
-
}).option("impact", { type: "number" }).option("urgency", { type: "number" }).option("effort", { type: "number" }).option("risk", { type: "number" }).option("confidence", { type: "number" });
|
|
55182
|
+
}).option("impact", { type: "number" }).option("urgency", { type: "number" }).option("effort", { type: "number" }).option("risk", { type: "number" }).option("confidence", { type: "number" }));
|
|
54212
55183
|
},
|
|
54213
55184
|
command: "update <id>",
|
|
54214
55185
|
describe: "Update triage fields on a work item",
|
|
54215
55186
|
handler: async (argv) => {
|
|
55187
|
+
const scope = scopeFromArgv(argv);
|
|
54216
55188
|
await withEnvelope("work update", () => workUpdate({
|
|
55189
|
+
...scope,
|
|
54217
55190
|
acceptanceCriteria: optionalStringArray(argv.acceptance),
|
|
54218
55191
|
area: optionalString(argv.area),
|
|
54219
55192
|
blockedReason: optionalString(argv["blocked-reason"]),
|
|
@@ -54235,7 +55208,7 @@ const updateCommand = {
|
|
|
54235
55208
|
//#region src/xy/common/work/index.ts
|
|
54236
55209
|
const workCommand = {
|
|
54237
55210
|
builder: (yargs) => {
|
|
54238
|
-
return yargs.command(initCommand$1).command(addCommand).command(listCommand).command(showCommand).command(syncCommand).command(triageCommand).command(queueCommand).command(nextCommand).command(claimCommand).command(doneCommand).command(updateCommand).demandCommand(1, "Please specify a work subcommand").strictCommands();
|
|
55211
|
+
return yargs.command(initCommand$1).command(addCommand).command(listCommand).command(showCommand).command(syncCommand).command(triageCommand).command(queueCommand).command(nextCommand).command(claimCommand).command(doneCommand).command(updateCommand).command(moveCommand).command(lintCommand$1).demandCommand(1, "Please specify a work subcommand").strictCommands();
|
|
54239
55212
|
},
|
|
54240
55213
|
command: "work",
|
|
54241
55214
|
describe: "Work - AI-friendly work tracking (repo-local, with optional GitHub Issues)",
|