@ariestools/toolchain 10.1.1 → 10.1.3

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.
Files changed (75) hide show
  1. package/dist/actions/agent/document.d.ts +15 -0
  2. package/dist/actions/agent/document.d.ts.map +1 -1
  3. package/dist/actions/agent/index.d.ts +1 -1
  4. package/dist/actions/agent/index.d.ts.map +1 -1
  5. package/dist/actions/agent/lint.d.ts +5 -0
  6. package/dist/actions/agent/lint.d.ts.map +1 -1
  7. package/dist/actions/agent/mutate.d.ts.map +1 -1
  8. package/dist/actions/agent/rules.d.ts.map +1 -1
  9. package/dist/actions/agent/walk.d.ts.map +1 -1
  10. package/dist/actions/package/compile/XyConfig.d.ts +25 -2
  11. package/dist/actions/package/compile/XyConfig.d.ts.map +1 -1
  12. package/dist/actions/plan/markdown.d.ts.map +1 -1
  13. package/dist/actions/repo-init/scaffold.d.ts.map +1 -1
  14. package/dist/actions/repo-init/skillsInstall.d.ts.map +1 -1
  15. package/dist/actions/repo-init/templateVars.d.ts.map +1 -1
  16. package/dist/actions/secure/dependabot.d.ts.map +1 -1
  17. package/dist/actions/skills/defaults.d.ts +3 -3
  18. package/dist/actions/skills/defaults.d.ts.map +1 -1
  19. package/dist/actions/skills/detectProfile.d.ts.map +1 -1
  20. package/dist/actions/skills/editXyConfigSkillPresence.d.ts +13 -0
  21. package/dist/actions/skills/editXyConfigSkillPresence.d.ts.map +1 -0
  22. package/dist/actions/skills/installed.d.ts +7 -0
  23. package/dist/actions/skills/installed.d.ts.map +1 -1
  24. package/dist/actions/skills/legacyGenerated.d.ts +7 -0
  25. package/dist/actions/skills/legacyGenerated.d.ts.map +1 -0
  26. package/dist/actions/skills/lint.d.ts +3 -0
  27. package/dist/actions/skills/lint.d.ts.map +1 -1
  28. package/dist/actions/skills/lock.d.ts +5 -1
  29. package/dist/actions/skills/lock.d.ts.map +1 -1
  30. package/dist/actions/skills/pick.d.ts.map +1 -1
  31. package/dist/actions/skills/skillRules.d.ts +2 -1
  32. package/dist/actions/skills/skillRules.d.ts.map +1 -1
  33. package/dist/actions/work/github.d.ts +9 -0
  34. package/dist/actions/work/github.d.ts.map +1 -1
  35. package/dist/actions/work/lifecycle.d.ts +3 -0
  36. package/dist/actions/work/lifecycle.d.ts.map +1 -1
  37. package/dist/actions/work/lint.d.ts.map +1 -1
  38. package/dist/actions/work/priority.d.ts +5 -1
  39. package/dist/actions/work/priority.d.ts.map +1 -1
  40. package/dist/actions/work/sync.d.ts +5 -1
  41. package/dist/actions/work/sync.d.ts.map +1 -1
  42. package/dist/bin/package/build.mjs +1494 -1494
  43. package/dist/bin/package/build.mjs.map +1 -1
  44. package/dist/bin/package/clean.mjs +1813 -1813
  45. package/dist/bin/package/clean.mjs.map +1 -1
  46. package/dist/bin/package/compile.mjs +1494 -1494
  47. package/dist/bin/package/compile.mjs.map +1 -1
  48. package/dist/bin/package/copy-assets-cjs.mjs +1 -1
  49. package/dist/bin/package/copy-assets-esm.mjs +1 -1
  50. package/dist/bin/package/publint.mjs +1 -1
  51. package/dist/bin/package/publint.mjs.map +1 -1
  52. package/dist/bin/package/recompile.mjs +1494 -1494
  53. package/dist/bin/package/recompile.mjs.map +1 -1
  54. package/dist/bin/package/sync-layout.mjs.map +1 -1
  55. package/dist/bin/xy.mjs +1400 -701
  56. package/dist/bin/xy.mjs.map +1 -1
  57. package/dist/bin/xyex.mjs +1400 -701
  58. package/dist/bin/xyex.mjs.map +1 -1
  59. package/dist/lib/loadConfig.d.ts +5 -0
  60. package/dist/lib/loadConfig.d.ts.map +1 -1
  61. package/dist/xy/common/checkCommand.d.ts.map +1 -1
  62. package/dist/xy/common/skills/index.d.ts.map +1 -1
  63. package/dist/xy/common/work/updateCommand.d.ts.map +1 -1
  64. package/dist/xy/xy.d.ts +2 -0
  65. package/dist/xy/xy.d.ts.map +1 -1
  66. package/package.json +4 -4
  67. package/templates/repo/cli/root/AGENTS.md.tmpl +26 -17
  68. package/templates/repo/cli/root/docs/README.md.tmpl +4 -0
  69. package/templates/repo/cli/root/github/workflows/build-bun.yml.tmpl +8 -0
  70. package/templates/repo/cli/root/github/workflows/build-npm.yml.tmpl +9 -1
  71. package/templates/repo/cli/root/github/workflows/build-pnpm.yml.tmpl +10 -2
  72. package/templates/repo/cli/root/github/workflows/build-yarn.yml.tmpl +9 -1
  73. package/templates/repo/cli/root/package.json.tmpl +3 -3
  74. package/templates/repo/cli/root/papers/README.md.tmpl +10 -0
  75. package/templates/repo/cli/root/pnpm-workspace.yaml +4 -0
package/dist/bin/xyex.mjs CHANGED
@@ -6,15 +6,15 @@ import tty from "node:tty";
6
6
  import * as xi from "node:fs";
7
7
  import fs, { closeSync, copyFileSync, existsSync, lstatSync, mkdirSync, openSync, promises, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
8
8
  import path, { basename, delimiter, dirname, normalize, posix, resolve, win32 } from "node:path";
9
+ import { basename as basename$1, dirname as dirname$1, extname, join, normalize as normalize$1, relative, resolve as resolve$1 } from "path";
10
+ import { lstatSync as lstatSync$1, readFileSync as readFileSync$1, readdir, readdirSync as readdirSync$1, readlinkSync as readlinkSync$1, realpathSync as realpathSync$1, statSync as statSync$1, writeFile } from "fs";
9
11
  import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
10
12
  import posixPath from "node:path/posix";
11
13
  import { fileURLToPath, pathToFileURL } from "node:url";
12
- import { lstatSync as lstatSync$1, readFileSync as readFileSync$1, readdir, readdirSync as readdirSync$1, readlinkSync as readlinkSync$1, realpathSync as realpathSync$1, statSync as statSync$1, writeFile } from "fs";
13
14
  import fs$1, { lstat, readdir as readdir$1, readlink, realpath } from "node:fs/promises";
14
15
  import { EventEmitter } from "node:events";
15
16
  import Pe, { PassThrough } from "node:stream";
16
17
  import { StringDecoder } from "node:string_decoder";
17
- import { basename as basename$1, dirname as dirname$1, extname, join, normalize as normalize$1, relative, resolve as resolve$1 } from "path";
18
18
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
19
19
  import * as readline$2 from "node:readline";
20
20
  import readline, { createInterface } from "node:readline";
@@ -626,9 +626,441 @@ const ADAPTER_PATHS = [
626
626
  ".github/copilot-instructions.md",
627
627
  "GEMINI.md"
628
628
  ];
629
- function isThinAgentsImport(text) {
630
- const lines = text.replaceAll(/<!--[\s\S]*?-->/g, "").split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
631
- return lines.length === 1 && /^@(\.\/)?AGENTS\.md$/.test(lines[0] ?? "");
629
+ const CLAUDE_AGENTS_IMPORT = /^@(\.\/)?AGENTS\.md$/;
630
+ const COPILOT_AGENTS_IMPORT = /^@(\.\/|\.\.\/)?AGENTS\.md$/;
631
+ /**
632
+ * Markdown with fenced blocks, inline code, and HTML comments removed, matching
633
+ * the plan linter's visible text so an import inside those does not count.
634
+ */
635
+ function visibleInstructionMarkdown(markdown) {
636
+ return markdown.replaceAll(/^ {0,3}([`~]{3,})[^\n]*\n[\s\S]*?^ {0,3}\1[^\n]*$/gmu, "\n").replaceAll(/`[^`\n]+`/g, " ").replaceAll(/<!--[\s\S]*?-->/g, " ");
637
+ }
638
+ function visibleInstructionLines(markdown) {
639
+ return visibleInstructionMarkdown(markdown).split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
640
+ }
641
+ /**
642
+ * Where a Claude or Gemini `@AGENTS.md` import sits. Tool-specific sections
643
+ * may follow a leading import. An import that is not the first visible line
644
+ * does not count.
645
+ */
646
+ function claudeAgentsImportPlacement(text) {
647
+ const index = visibleInstructionLines(text).findIndex((line) => CLAUDE_AGENTS_IMPORT.test(line));
648
+ if (index === -1) return "absent";
649
+ return index === 0 ? "first" : "later";
650
+ }
651
+ function hasCopilotAgentsReference(text) {
652
+ return visibleInstructionLines(text).some((line) => COPILOT_AGENTS_IMPORT.test(line));
653
+ }
654
+ function markdownLinkTargets(text) {
655
+ return visibleInstructionMarkdown(text).matchAll(/\[[^\]]*]\(([^)]+)\)/g).map((match) => match[1]?.trim() ?? "").filter((target) => target.length > 0).toArray();
656
+ }
657
+ //#endregion
658
+ //#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
659
+ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
660
+ module.exports = isexe;
661
+ isexe.sync = sync;
662
+ var fs$5 = __require("fs");
663
+ function checkPathExt(path, options) {
664
+ var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
665
+ if (!pathext) return true;
666
+ pathext = pathext.split(";");
667
+ if (pathext.indexOf("") !== -1) return true;
668
+ for (var i = 0; i < pathext.length; i++) {
669
+ var p = pathext[i].toLowerCase();
670
+ if (p && path.substr(-p.length).toLowerCase() === p) return true;
671
+ }
672
+ return false;
673
+ }
674
+ function checkStat(stat, path, options) {
675
+ if (!stat.isSymbolicLink() && !stat.isFile()) return false;
676
+ return checkPathExt(path, options);
677
+ }
678
+ function isexe(path, options, cb) {
679
+ fs$5.stat(path, function(er, stat) {
680
+ cb(er, er ? false : checkStat(stat, path, options));
681
+ });
682
+ }
683
+ function sync(path, options) {
684
+ return checkStat(fs$5.statSync(path), path, options);
685
+ }
686
+ }));
687
+ //#endregion
688
+ //#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
689
+ var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
690
+ module.exports = isexe;
691
+ isexe.sync = sync;
692
+ var fs$4 = __require("fs");
693
+ function isexe(path, options, cb) {
694
+ fs$4.stat(path, function(er, stat) {
695
+ cb(er, er ? false : checkStat(stat, options));
696
+ });
697
+ }
698
+ function sync(path, options) {
699
+ return checkStat(fs$4.statSync(path), options);
700
+ }
701
+ function checkStat(stat, options) {
702
+ return stat.isFile() && checkMode(stat, options);
703
+ }
704
+ function checkMode(stat, options) {
705
+ var mod = stat.mode;
706
+ var uid = stat.uid;
707
+ var gid = stat.gid;
708
+ var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
709
+ var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
710
+ var u = parseInt("100", 8);
711
+ var g = parseInt("010", 8);
712
+ var o = parseInt("001", 8);
713
+ var ug = u | g;
714
+ return mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
715
+ }
716
+ }));
717
+ //#endregion
718
+ //#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
719
+ var require_isexe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
720
+ __require("fs");
721
+ var core;
722
+ if (process.platform === "win32" || global.TESTING_WINDOWS) core = require_windows();
723
+ else core = require_mode();
724
+ module.exports = isexe;
725
+ isexe.sync = sync;
726
+ function isexe(path, options, cb) {
727
+ if (typeof options === "function") {
728
+ cb = options;
729
+ options = {};
730
+ }
731
+ if (!cb) {
732
+ if (typeof Promise !== "function") throw new TypeError("callback not provided");
733
+ return new Promise(function(resolve, reject) {
734
+ isexe(path, options || {}, function(er, is) {
735
+ if (er) reject(er);
736
+ else resolve(is);
737
+ });
738
+ });
739
+ }
740
+ core(path, options || {}, function(er, is) {
741
+ if (er) {
742
+ if (er.code === "EACCES" || options && options.ignoreErrors) {
743
+ er = null;
744
+ is = false;
745
+ }
746
+ }
747
+ cb(er, is);
748
+ });
749
+ }
750
+ function sync(path, options) {
751
+ try {
752
+ return core.sync(path, options || {});
753
+ } catch (er) {
754
+ if (options && options.ignoreErrors || er.code === "EACCES") return false;
755
+ else throw er;
756
+ }
757
+ }
758
+ }));
759
+ //#endregion
760
+ //#region ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
761
+ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
762
+ const isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
763
+ const path$5 = __require("path");
764
+ const COLON = isWindows ? ";" : ":";
765
+ const isexe = require_isexe();
766
+ const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
767
+ const getPathInfo = (cmd, opt) => {
768
+ const colon = opt.colon || COLON;
769
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH ||
770
+ /* istanbul ignore next: very unusual */ "").split(colon)];
771
+ const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
772
+ const pathExt = isWindows ? pathExtExe.split(colon) : [""];
773
+ if (isWindows) {
774
+ if (cmd.indexOf(".") !== -1 && pathExt[0] !== "") pathExt.unshift("");
775
+ }
776
+ return {
777
+ pathEnv,
778
+ pathExt,
779
+ pathExtExe
780
+ };
781
+ };
782
+ const which = (cmd, opt, cb) => {
783
+ if (typeof opt === "function") {
784
+ cb = opt;
785
+ opt = {};
786
+ }
787
+ if (!opt) opt = {};
788
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
789
+ const found = [];
790
+ const step = (i) => new Promise((resolve, reject) => {
791
+ if (i === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
792
+ const ppRaw = pathEnv[i];
793
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
794
+ const pCmd = path$5.join(pathPart, cmd);
795
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
796
+ resolve(subStep(p, i, 0));
797
+ });
798
+ const subStep = (p, i, ii) => new Promise((resolve, reject) => {
799
+ if (ii === pathExt.length) return resolve(step(i + 1));
800
+ const ext = pathExt[ii];
801
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
802
+ if (!er && is) {
803
+ if (opt.all) found.push(p + ext);
804
+ else return resolve(p + ext);
805
+ }
806
+ return resolve(subStep(p, i, ii + 1));
807
+ });
808
+ });
809
+ return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
810
+ };
811
+ const whichSync = (cmd, opt) => {
812
+ opt = opt || {};
813
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
814
+ const found = [];
815
+ for (let i = 0; i < pathEnv.length; i++) {
816
+ const ppRaw = pathEnv[i];
817
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
818
+ const pCmd = path$5.join(pathPart, cmd);
819
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
820
+ for (let j = 0; j < pathExt.length; j++) {
821
+ const cur = p + pathExt[j];
822
+ try {
823
+ if (isexe.sync(cur, { pathExt: pathExtExe })) {
824
+ if (opt.all) found.push(cur);
825
+ else return cur;
826
+ }
827
+ } catch (ex) {}
828
+ }
829
+ }
830
+ if (opt.all && found.length) return found;
831
+ if (opt.nothrow) return null;
832
+ throw getNotFoundError(cmd);
833
+ };
834
+ module.exports = which;
835
+ which.sync = whichSync;
836
+ }));
837
+ //#endregion
838
+ //#region ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
839
+ var require_path_key = /* @__PURE__ */ __commonJSMin(((exports, module) => {
840
+ const pathKey = (options = {}) => {
841
+ const environment = options.env || process.env;
842
+ if ((options.platform || process.platform) !== "win32") return "PATH";
843
+ return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
844
+ };
845
+ module.exports = pathKey;
846
+ module.exports.default = pathKey;
847
+ }));
848
+ //#endregion
849
+ //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
850
+ var require_resolveCommand = /* @__PURE__ */ __commonJSMin(((exports, module) => {
851
+ const path$4 = __require("path");
852
+ const which = require_which();
853
+ const getPathKey = require_path_key();
854
+ function resolveCommandAttempt(parsed, withoutPathExt) {
855
+ const env = parsed.options.env || process.env;
856
+ const cwd = process.cwd();
857
+ const hasCustomCwd = parsed.options.cwd != null;
858
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
859
+ if (shouldSwitchCwd) try {
860
+ process.chdir(parsed.options.cwd);
861
+ } catch (err) {}
862
+ let resolved;
863
+ try {
864
+ resolved = which.sync(parsed.command, {
865
+ path: env[getPathKey({ env })],
866
+ pathExt: withoutPathExt ? path$4.delimiter : void 0
867
+ });
868
+ } catch (e) {} finally {
869
+ if (shouldSwitchCwd) process.chdir(cwd);
870
+ }
871
+ if (resolved) resolved = path$4.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
872
+ return resolved;
873
+ }
874
+ function resolveCommand(parsed) {
875
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
876
+ }
877
+ module.exports = resolveCommand;
878
+ }));
879
+ //#endregion
880
+ //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
881
+ var require_escape = /* @__PURE__ */ __commonJSMin(((exports, module) => {
882
+ const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
883
+ function escapeCommand(arg) {
884
+ arg = arg.replace(metaCharsRegExp, "^$1");
885
+ return arg;
886
+ }
887
+ function escapeArgument(arg, doubleEscapeMetaChars) {
888
+ arg = `${arg}`;
889
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
890
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
891
+ arg = `"${arg}"`;
892
+ arg = arg.replace(metaCharsRegExp, "^$1");
893
+ if (doubleEscapeMetaChars) arg = arg.replace(metaCharsRegExp, "^$1");
894
+ return arg;
895
+ }
896
+ module.exports.command = escapeCommand;
897
+ module.exports.argument = escapeArgument;
898
+ }));
899
+ //#endregion
900
+ //#region ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
901
+ var require_shebang_regex = /* @__PURE__ */ __commonJSMin(((exports, module) => {
902
+ module.exports = /^#!(.*)/;
903
+ }));
904
+ //#endregion
905
+ //#region ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
906
+ var require_shebang_command = /* @__PURE__ */ __commonJSMin(((exports, module) => {
907
+ const shebangRegex = require_shebang_regex();
908
+ module.exports = (string = "") => {
909
+ const match = string.match(shebangRegex);
910
+ if (!match) return null;
911
+ const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
912
+ const binary = path.split("/").pop();
913
+ if (binary === "env") return argument;
914
+ return argument ? `${binary} ${argument}` : binary;
915
+ };
916
+ }));
917
+ //#endregion
918
+ //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
919
+ var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
920
+ const fs$3 = __require("fs");
921
+ const shebangCommand = require_shebang_command();
922
+ function readShebang(command) {
923
+ const size = 150;
924
+ const buffer = Buffer.alloc(size);
925
+ let fd;
926
+ try {
927
+ fd = fs$3.openSync(command, "r");
928
+ fs$3.readSync(fd, buffer, 0, size, 0);
929
+ fs$3.closeSync(fd);
930
+ } catch (e) {}
931
+ return shebangCommand(buffer.toString());
932
+ }
933
+ module.exports = readShebang;
934
+ }));
935
+ //#endregion
936
+ //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
937
+ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
938
+ const path$3 = __require("path");
939
+ const resolveCommand = require_resolveCommand();
940
+ const escape = require_escape();
941
+ const readShebang = require_readShebang();
942
+ const isWin = process.platform === "win32";
943
+ const isExecutableRegExp = /\.(?:com|exe)$/i;
944
+ const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
945
+ function detectShebang(parsed) {
946
+ parsed.file = resolveCommand(parsed);
947
+ const shebang = parsed.file && readShebang(parsed.file);
948
+ if (shebang) {
949
+ parsed.args.unshift(parsed.file);
950
+ parsed.command = shebang;
951
+ return resolveCommand(parsed);
952
+ }
953
+ return parsed.file;
954
+ }
955
+ function parseNonShell(parsed) {
956
+ if (!isWin) return parsed;
957
+ const commandFile = detectShebang(parsed);
958
+ const needsShell = !isExecutableRegExp.test(commandFile);
959
+ if (parsed.options.forceShell || needsShell) {
960
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
961
+ parsed.command = path$3.normalize(parsed.command);
962
+ parsed.command = escape.command(parsed.command);
963
+ parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
964
+ parsed.args = [
965
+ "/d",
966
+ "/s",
967
+ "/c",
968
+ `"${[parsed.command].concat(parsed.args).join(" ")}"`
969
+ ];
970
+ parsed.command = process.env.comspec || "cmd.exe";
971
+ parsed.options.windowsVerbatimArguments = true;
972
+ }
973
+ return parsed;
974
+ }
975
+ function parse(command, args, options) {
976
+ if (args && !Array.isArray(args)) {
977
+ options = args;
978
+ args = null;
979
+ }
980
+ args = args ? args.slice(0) : [];
981
+ options = Object.assign({}, options);
982
+ const parsed = {
983
+ command,
984
+ args,
985
+ options,
986
+ file: void 0,
987
+ original: {
988
+ command,
989
+ args
990
+ }
991
+ };
992
+ return options.shell ? parsed : parseNonShell(parsed);
993
+ }
994
+ module.exports = parse;
995
+ }));
996
+ //#endregion
997
+ //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
998
+ var require_enoent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
999
+ const isWin = process.platform === "win32";
1000
+ function notFoundError(original, syscall) {
1001
+ return Object.assign(/* @__PURE__ */ new Error(`${syscall} ${original.command} ENOENT`), {
1002
+ code: "ENOENT",
1003
+ errno: "ENOENT",
1004
+ syscall: `${syscall} ${original.command}`,
1005
+ path: original.command,
1006
+ spawnargs: original.args
1007
+ });
1008
+ }
1009
+ function hookChildProcess(cp, parsed) {
1010
+ if (!isWin) return;
1011
+ const originalEmit = cp.emit;
1012
+ cp.emit = function(name, arg1) {
1013
+ if (name === "exit") {
1014
+ const err = verifyENOENT(arg1, parsed);
1015
+ if (err) return originalEmit.call(cp, "error", err);
1016
+ }
1017
+ return originalEmit.apply(cp, arguments);
1018
+ };
1019
+ }
1020
+ function verifyENOENT(status, parsed) {
1021
+ if (isWin && status === 1 && !parsed.file) return notFoundError(parsed.original, "spawn");
1022
+ return null;
1023
+ }
1024
+ function verifyENOENTSync(status, parsed) {
1025
+ if (isWin && status === 1 && !parsed.file) return notFoundError(parsed.original, "spawnSync");
1026
+ return null;
1027
+ }
1028
+ module.exports = {
1029
+ hookChildProcess,
1030
+ verifyENOENT,
1031
+ verifyENOENTSync,
1032
+ notFoundError
1033
+ };
1034
+ }));
1035
+ //#endregion
1036
+ //#region src/lib/crossSpawn.ts
1037
+ var import_cross_spawn = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
1038
+ const cp = __require("child_process");
1039
+ const parse = require_parse$1();
1040
+ const enoent = require_enoent();
1041
+ function spawn(command, args, options) {
1042
+ const parsed = parse(command, args, options);
1043
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
1044
+ enoent.hookChildProcess(spawned, parsed);
1045
+ return spawned;
1046
+ }
1047
+ function spawnSync(command, args, options) {
1048
+ const parsed = parse(command, args, options);
1049
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
1050
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
1051
+ return result;
1052
+ }
1053
+ module.exports = spawn;
1054
+ module.exports.spawn = spawn;
1055
+ module.exports.sync = spawnSync;
1056
+ module.exports._parse = parse;
1057
+ module.exports._enoent = enoent;
1058
+ })))(), 1);
1059
+ function spawn$1(command, args, options) {
1060
+ return (0, import_cross_spawn.default)(command, args, options);
1061
+ }
1062
+ function spawnSync$1(command, args, options) {
1063
+ return import_cross_spawn.default.sync(command, args, options);
632
1064
  }
633
1065
  //#endregion
634
1066
  //#region src/lib/gitCheckoutRoot.ts
@@ -687,7 +1119,18 @@ function walkRepoFiles(root, include) {
687
1119
  }
688
1120
  };
689
1121
  visit(root, true);
690
- return found.toSorted();
1122
+ return dropGitignored(root, found.toSorted());
1123
+ }
1124
+ function dropGitignored(root, relativePaths) {
1125
+ if (relativePaths.length === 0 || !fs.existsSync(path.join(root, ".git"))) return relativePaths;
1126
+ const result = spawnSync$1("git", ["check-ignore", "--stdin"], {
1127
+ cwd: root,
1128
+ encoding: "utf8",
1129
+ input: `${relativePaths.join("\n")}\n`
1130
+ });
1131
+ if (result.error !== void 0 || result.status !== 0 && result.status !== 1) return relativePaths;
1132
+ const ignored = new Set((result.stdout ?? "").split("\n").map((line) => line.trim()).filter((line) => line.length > 0));
1133
+ return relativePaths.filter((relativePath) => !ignored.has(relativePath));
691
1134
  }
692
1135
  //#endregion
693
1136
  //#region src/actions/agent/context.ts
@@ -768,7 +1211,7 @@ Use the repository package scripts from the root.
768
1211
 
769
1212
  ## Failures
770
1213
 
771
- Re-run the failing command after the fix. Do not record in-flight tasks here.
1214
+ Re-run the failing command after the fix. Keep task assignments out of this file.
772
1215
  `;
773
1216
  const CLAUDE_ADAPTER = "@AGENTS.md\n";
774
1217
  function writeIfMissing(cwd, relativePath, contents, result) {
@@ -918,7 +1361,7 @@ function Ht(n) {
918
1361
  return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
919
1362
  }
920
1363
  function ps(n) {
921
- return n.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs$5, de).replace(us, pe);
1364
+ return n.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs$2, de).replace(us, pe);
922
1365
  }
923
1366
  function ms(n) {
924
1367
  return n.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os$2, ",").replace(hs, ".");
@@ -1010,7 +1453,7 @@ function Ut(n, t = {}) {
1010
1453
  function es(n, t = {}) {
1011
1454
  return new I(n, t).iterate();
1012
1455
  }
1013
- var Gt, ce, ss, fe, ue, qt, de, pe, is, rs, ns, os$2, hs, as, ls, cs, fs$5, us, ds, at, Ss, lt, Es, we, ye, W, xs, be, vs, Ct, Cs, Ts, As, ks, Kt, Se, Ee, Q, tt, O, Rs, Os, Fs, Ds, Ms, Ns, _s, Ls, Ws, Ps, js, Is, zs, Bs, Us, $s, Gs, Hs, Ce, Te, Ae, xe, A, Vs, Ys, Xs, Js, N, Zs, ke, Qs, ti, ve, ei, D, si, Oe, Vt, Fe, At, Re, ii, q, De, Tt, ri, ft, Ne, oi, hi, ai, G, H, K, kt, ut, Rt, _e, Ot, Le, P, et, v, dt, st, C, F, T, Yt, Ft, k, x$1, Xt, Jt, We, Zt, B, Qt, Dt, pt, Y, M, mt, li, ci, fi, ui$1, Mt, te, di, pi, V, vi, wt, Ue, $e, Ri, Oi, L, Ge, He, U, qe, Ke, X, Ve, _, gt, se, je, yt, j, Nt, Lt, Ie, Fi, ie, ze, bt, Be, _t, Wt, ne, Ye, R, Pt, jt, It, it, rt, St, Xe, Di, Mi, Ni, nt, _i, ot, oe, he, ae, Et, Li, zt, xt, vt, Pi, I, le, ji, Ii, zi, Bi, Ui, Ze;
1456
+ var Gt, ce, ss, fe, ue, qt, de, pe, is, rs, ns, os$2, hs, as, ls, cs, fs$2, us, ds, at, Ss, lt, Es, we, ye, W, xs, be, vs, Ct, Cs, Ts, As, ks, Kt, Se, Ee, Q, tt, O, Rs, Os, Fs, Ds, Ms, Ns, _s, Ls, Ws, Ps, js, Is, zs, Bs, Us, $s, Gs, Hs, Ce, Te, Ae, xe, A, Vs, Ys, Xs, Js, N, Zs, ke, Qs, ti, ve, ei, D, si, Oe, Vt, Fe, At, Re, ii, q, De, Tt, ri, ft, Ne, oi, hi, ai, G, H, K, kt, ut, Rt, _e, Ot, Le, P, et, v, dt, st, C, F, T, Yt, Ft, k, x$1, Xt, Jt, We, Zt, B, Qt, Dt, pt, Y, M, mt, li, ci, fi, ui$1, Mt, te, di, pi, V, vi, wt, Ue, $e, Ri, Oi, L, Ge, He, U, qe, Ke, X, Ve, _, gt, se, je, yt, j, Nt, Lt, Ie, Fi, ie, ze, bt, Be, _t, Wt, ne, Ye, R, Pt, jt, It, it, rt, St, Xe, Di, Mi, Ni, nt, _i, ot, oe, he, ae, Et, Li, zt, xt, vt, Pi, I, le, ji, Ii, zi, Bi, Ui, Ze;
1014
1457
  var init_index_min = __esmMin((() => {
1015
1458
  Gt = (n, t, e) => {
1016
1459
  let s = n instanceof RegExp ? ce(n, e) : n, i = t instanceof RegExp ? ce(t, e) : t, r = s !== null && i != null && ss(s, i, e);
@@ -1055,7 +1498,7 @@ var init_index_min = __esmMin((() => {
1055
1498
  as = /\\\\/g;
1056
1499
  ls = /\\{/g;
1057
1500
  cs = /\\}/g;
1058
- fs$5 = /\\,/g;
1501
+ fs$2 = /\\,/g;
1059
1502
  us = /\\./g;
1060
1503
  ds = 1e5;
1061
1504
  at = (n) => {
@@ -4254,414 +4697,6 @@ function copyAssetFiles(srcDir, destDir) {
4254
4697
  return copied;
4255
4698
  }
4256
4699
  //#endregion
4257
- //#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
4258
- var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4259
- module.exports = isexe;
4260
- isexe.sync = sync;
4261
- var fs$4 = __require("fs");
4262
- function checkPathExt(path, options) {
4263
- var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
4264
- if (!pathext) return true;
4265
- pathext = pathext.split(";");
4266
- if (pathext.indexOf("") !== -1) return true;
4267
- for (var i = 0; i < pathext.length; i++) {
4268
- var p = pathext[i].toLowerCase();
4269
- if (p && path.substr(-p.length).toLowerCase() === p) return true;
4270
- }
4271
- return false;
4272
- }
4273
- function checkStat(stat, path, options) {
4274
- if (!stat.isSymbolicLink() && !stat.isFile()) return false;
4275
- return checkPathExt(path, options);
4276
- }
4277
- function isexe(path, options, cb) {
4278
- fs$4.stat(path, function(er, stat) {
4279
- cb(er, er ? false : checkStat(stat, path, options));
4280
- });
4281
- }
4282
- function sync(path, options) {
4283
- return checkStat(fs$4.statSync(path), path, options);
4284
- }
4285
- }));
4286
- //#endregion
4287
- //#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
4288
- var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4289
- module.exports = isexe;
4290
- isexe.sync = sync;
4291
- var fs$3 = __require("fs");
4292
- function isexe(path, options, cb) {
4293
- fs$3.stat(path, function(er, stat) {
4294
- cb(er, er ? false : checkStat(stat, options));
4295
- });
4296
- }
4297
- function sync(path, options) {
4298
- return checkStat(fs$3.statSync(path), options);
4299
- }
4300
- function checkStat(stat, options) {
4301
- return stat.isFile() && checkMode(stat, options);
4302
- }
4303
- function checkMode(stat, options) {
4304
- var mod = stat.mode;
4305
- var uid = stat.uid;
4306
- var gid = stat.gid;
4307
- var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
4308
- var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
4309
- var u = parseInt("100", 8);
4310
- var g = parseInt("010", 8);
4311
- var o = parseInt("001", 8);
4312
- var ug = u | g;
4313
- return mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
4314
- }
4315
- }));
4316
- //#endregion
4317
- //#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
4318
- var require_isexe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4319
- __require("fs");
4320
- var core;
4321
- if (process.platform === "win32" || global.TESTING_WINDOWS) core = require_windows();
4322
- else core = require_mode();
4323
- module.exports = isexe;
4324
- isexe.sync = sync;
4325
- function isexe(path, options, cb) {
4326
- if (typeof options === "function") {
4327
- cb = options;
4328
- options = {};
4329
- }
4330
- if (!cb) {
4331
- if (typeof Promise !== "function") throw new TypeError("callback not provided");
4332
- return new Promise(function(resolve, reject) {
4333
- isexe(path, options || {}, function(er, is) {
4334
- if (er) reject(er);
4335
- else resolve(is);
4336
- });
4337
- });
4338
- }
4339
- core(path, options || {}, function(er, is) {
4340
- if (er) {
4341
- if (er.code === "EACCES" || options && options.ignoreErrors) {
4342
- er = null;
4343
- is = false;
4344
- }
4345
- }
4346
- cb(er, is);
4347
- });
4348
- }
4349
- function sync(path, options) {
4350
- try {
4351
- return core.sync(path, options || {});
4352
- } catch (er) {
4353
- if (options && options.ignoreErrors || er.code === "EACCES") return false;
4354
- else throw er;
4355
- }
4356
- }
4357
- }));
4358
- //#endregion
4359
- //#region ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
4360
- var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4361
- const isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
4362
- const path$5 = __require("path");
4363
- const COLON = isWindows ? ";" : ":";
4364
- const isexe = require_isexe();
4365
- const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
4366
- const getPathInfo = (cmd, opt) => {
4367
- const colon = opt.colon || COLON;
4368
- const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH ||
4369
- /* istanbul ignore next: very unusual */ "").split(colon)];
4370
- const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
4371
- const pathExt = isWindows ? pathExtExe.split(colon) : [""];
4372
- if (isWindows) {
4373
- if (cmd.indexOf(".") !== -1 && pathExt[0] !== "") pathExt.unshift("");
4374
- }
4375
- return {
4376
- pathEnv,
4377
- pathExt,
4378
- pathExtExe
4379
- };
4380
- };
4381
- const which = (cmd, opt, cb) => {
4382
- if (typeof opt === "function") {
4383
- cb = opt;
4384
- opt = {};
4385
- }
4386
- if (!opt) opt = {};
4387
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
4388
- const found = [];
4389
- const step = (i) => new Promise((resolve, reject) => {
4390
- if (i === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
4391
- const ppRaw = pathEnv[i];
4392
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
4393
- const pCmd = path$5.join(pathPart, cmd);
4394
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
4395
- resolve(subStep(p, i, 0));
4396
- });
4397
- const subStep = (p, i, ii) => new Promise((resolve, reject) => {
4398
- if (ii === pathExt.length) return resolve(step(i + 1));
4399
- const ext = pathExt[ii];
4400
- isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
4401
- if (!er && is) {
4402
- if (opt.all) found.push(p + ext);
4403
- else return resolve(p + ext);
4404
- }
4405
- return resolve(subStep(p, i, ii + 1));
4406
- });
4407
- });
4408
- return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
4409
- };
4410
- const whichSync = (cmd, opt) => {
4411
- opt = opt || {};
4412
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
4413
- const found = [];
4414
- for (let i = 0; i < pathEnv.length; i++) {
4415
- const ppRaw = pathEnv[i];
4416
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
4417
- const pCmd = path$5.join(pathPart, cmd);
4418
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
4419
- for (let j = 0; j < pathExt.length; j++) {
4420
- const cur = p + pathExt[j];
4421
- try {
4422
- if (isexe.sync(cur, { pathExt: pathExtExe })) {
4423
- if (opt.all) found.push(cur);
4424
- else return cur;
4425
- }
4426
- } catch (ex) {}
4427
- }
4428
- }
4429
- if (opt.all && found.length) return found;
4430
- if (opt.nothrow) return null;
4431
- throw getNotFoundError(cmd);
4432
- };
4433
- module.exports = which;
4434
- which.sync = whichSync;
4435
- }));
4436
- //#endregion
4437
- //#region ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
4438
- var require_path_key = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4439
- const pathKey = (options = {}) => {
4440
- const environment = options.env || process.env;
4441
- if ((options.platform || process.platform) !== "win32") return "PATH";
4442
- return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
4443
- };
4444
- module.exports = pathKey;
4445
- module.exports.default = pathKey;
4446
- }));
4447
- //#endregion
4448
- //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
4449
- var require_resolveCommand = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4450
- const path$4 = __require("path");
4451
- const which = require_which();
4452
- const getPathKey = require_path_key();
4453
- function resolveCommandAttempt(parsed, withoutPathExt) {
4454
- const env = parsed.options.env || process.env;
4455
- const cwd = process.cwd();
4456
- const hasCustomCwd = parsed.options.cwd != null;
4457
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
4458
- if (shouldSwitchCwd) try {
4459
- process.chdir(parsed.options.cwd);
4460
- } catch (err) {}
4461
- let resolved;
4462
- try {
4463
- resolved = which.sync(parsed.command, {
4464
- path: env[getPathKey({ env })],
4465
- pathExt: withoutPathExt ? path$4.delimiter : void 0
4466
- });
4467
- } catch (e) {} finally {
4468
- if (shouldSwitchCwd) process.chdir(cwd);
4469
- }
4470
- if (resolved) resolved = path$4.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
4471
- return resolved;
4472
- }
4473
- function resolveCommand(parsed) {
4474
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
4475
- }
4476
- module.exports = resolveCommand;
4477
- }));
4478
- //#endregion
4479
- //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
4480
- var require_escape = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4481
- const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
4482
- function escapeCommand(arg) {
4483
- arg = arg.replace(metaCharsRegExp, "^$1");
4484
- return arg;
4485
- }
4486
- function escapeArgument(arg, doubleEscapeMetaChars) {
4487
- arg = `${arg}`;
4488
- arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
4489
- arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
4490
- arg = `"${arg}"`;
4491
- arg = arg.replace(metaCharsRegExp, "^$1");
4492
- if (doubleEscapeMetaChars) arg = arg.replace(metaCharsRegExp, "^$1");
4493
- return arg;
4494
- }
4495
- module.exports.command = escapeCommand;
4496
- module.exports.argument = escapeArgument;
4497
- }));
4498
- //#endregion
4499
- //#region ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
4500
- var require_shebang_regex = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4501
- module.exports = /^#!(.*)/;
4502
- }));
4503
- //#endregion
4504
- //#region ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
4505
- var require_shebang_command = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4506
- const shebangRegex = require_shebang_regex();
4507
- module.exports = (string = "") => {
4508
- const match = string.match(shebangRegex);
4509
- if (!match) return null;
4510
- const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
4511
- const binary = path.split("/").pop();
4512
- if (binary === "env") return argument;
4513
- return argument ? `${binary} ${argument}` : binary;
4514
- };
4515
- }));
4516
- //#endregion
4517
- //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
4518
- var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4519
- const fs$2 = __require("fs");
4520
- const shebangCommand = require_shebang_command();
4521
- function readShebang(command) {
4522
- const size = 150;
4523
- const buffer = Buffer.alloc(size);
4524
- let fd;
4525
- try {
4526
- fd = fs$2.openSync(command, "r");
4527
- fs$2.readSync(fd, buffer, 0, size, 0);
4528
- fs$2.closeSync(fd);
4529
- } catch (e) {}
4530
- return shebangCommand(buffer.toString());
4531
- }
4532
- module.exports = readShebang;
4533
- }));
4534
- //#endregion
4535
- //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
4536
- var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4537
- const path$3 = __require("path");
4538
- const resolveCommand = require_resolveCommand();
4539
- const escape = require_escape();
4540
- const readShebang = require_readShebang();
4541
- const isWin = process.platform === "win32";
4542
- const isExecutableRegExp = /\.(?:com|exe)$/i;
4543
- const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
4544
- function detectShebang(parsed) {
4545
- parsed.file = resolveCommand(parsed);
4546
- const shebang = parsed.file && readShebang(parsed.file);
4547
- if (shebang) {
4548
- parsed.args.unshift(parsed.file);
4549
- parsed.command = shebang;
4550
- return resolveCommand(parsed);
4551
- }
4552
- return parsed.file;
4553
- }
4554
- function parseNonShell(parsed) {
4555
- if (!isWin) return parsed;
4556
- const commandFile = detectShebang(parsed);
4557
- const needsShell = !isExecutableRegExp.test(commandFile);
4558
- if (parsed.options.forceShell || needsShell) {
4559
- const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
4560
- parsed.command = path$3.normalize(parsed.command);
4561
- parsed.command = escape.command(parsed.command);
4562
- parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
4563
- parsed.args = [
4564
- "/d",
4565
- "/s",
4566
- "/c",
4567
- `"${[parsed.command].concat(parsed.args).join(" ")}"`
4568
- ];
4569
- parsed.command = process.env.comspec || "cmd.exe";
4570
- parsed.options.windowsVerbatimArguments = true;
4571
- }
4572
- return parsed;
4573
- }
4574
- function parse(command, args, options) {
4575
- if (args && !Array.isArray(args)) {
4576
- options = args;
4577
- args = null;
4578
- }
4579
- args = args ? args.slice(0) : [];
4580
- options = Object.assign({}, options);
4581
- const parsed = {
4582
- command,
4583
- args,
4584
- options,
4585
- file: void 0,
4586
- original: {
4587
- command,
4588
- args
4589
- }
4590
- };
4591
- return options.shell ? parsed : parseNonShell(parsed);
4592
- }
4593
- module.exports = parse;
4594
- }));
4595
- //#endregion
4596
- //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
4597
- var require_enoent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4598
- const isWin = process.platform === "win32";
4599
- function notFoundError(original, syscall) {
4600
- return Object.assign(/* @__PURE__ */ new Error(`${syscall} ${original.command} ENOENT`), {
4601
- code: "ENOENT",
4602
- errno: "ENOENT",
4603
- syscall: `${syscall} ${original.command}`,
4604
- path: original.command,
4605
- spawnargs: original.args
4606
- });
4607
- }
4608
- function hookChildProcess(cp, parsed) {
4609
- if (!isWin) return;
4610
- const originalEmit = cp.emit;
4611
- cp.emit = function(name, arg1) {
4612
- if (name === "exit") {
4613
- const err = verifyENOENT(arg1, parsed);
4614
- if (err) return originalEmit.call(cp, "error", err);
4615
- }
4616
- return originalEmit.apply(cp, arguments);
4617
- };
4618
- }
4619
- function verifyENOENT(status, parsed) {
4620
- if (isWin && status === 1 && !parsed.file) return notFoundError(parsed.original, "spawn");
4621
- return null;
4622
- }
4623
- function verifyENOENTSync(status, parsed) {
4624
- if (isWin && status === 1 && !parsed.file) return notFoundError(parsed.original, "spawnSync");
4625
- return null;
4626
- }
4627
- module.exports = {
4628
- hookChildProcess,
4629
- verifyENOENT,
4630
- verifyENOENTSync,
4631
- notFoundError
4632
- };
4633
- }));
4634
- //#endregion
4635
- //#region src/lib/crossSpawn.ts
4636
- var import_cross_spawn = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
4637
- const cp = __require("child_process");
4638
- const parse = require_parse$1();
4639
- const enoent = require_enoent();
4640
- function spawn(command, args, options) {
4641
- const parsed = parse(command, args, options);
4642
- const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
4643
- enoent.hookChildProcess(spawned, parsed);
4644
- return spawned;
4645
- }
4646
- function spawnSync(command, args, options) {
4647
- const parsed = parse(command, args, options);
4648
- const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
4649
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
4650
- return result;
4651
- }
4652
- module.exports = spawn;
4653
- module.exports.spawn = spawn;
4654
- module.exports.sync = spawnSync;
4655
- module.exports._parse = parse;
4656
- module.exports._enoent = enoent;
4657
- })))(), 1);
4658
- function spawn$1(command, args, options) {
4659
- return (0, import_cross_spawn.default)(command, args, options);
4660
- }
4661
- function spawnSync$1(command, args, options) {
4662
- return import_cross_spawn.default.sync(command, args, options);
4663
- }
4664
- //#endregion
4665
4700
  //#region src/lib/deepMerge.ts
4666
4701
  const UNSAFE_KEYS = /* @__PURE__ */ new Set([
4667
4702
  "__proto__",
@@ -7114,7 +7149,7 @@ var require_semver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7114
7149
  //#region src/lib/toolchainVersion.ts
7115
7150
  createRequire(import.meta.url);
7116
7151
  function bundledToolchainVersion() {
7117
- return "10.1.1";
7152
+ return "10.1.3";
7118
7153
  }
7119
7154
  function bundledToolchainRange() {
7120
7155
  return `^${bundledToolchainVersion()}`;
@@ -12234,7 +12269,7 @@ In-flight workspace loads — concurrent jobs for the same dir share one search.
12234
12269
  */
12235
12270
  const workspaceConfigLoadPromises = /* @__PURE__ */ new Map();
12236
12271
  const deprecationWarned = /* @__PURE__ */ new Set();
12237
- function isRecord$13(value) {
12272
+ function isRecord$14(value) {
12238
12273
  return typeof value === "object" && value !== null && !Array.isArray(value);
12239
12274
  }
12240
12275
  const explorerState = {};
@@ -12315,12 +12350,12 @@ function warnOnce(key, message) {
12315
12350
  */
12316
12351
  function resolveCommandField(cfg, commandName, configPath) {
12317
12352
  const configKey = canonicalRuleConfigKey(commandName);
12318
- const commands = isRecord$13(cfg.commands) ? cfg.commands : void 0;
12353
+ const commands = isRecord$14(cfg.commands) ? cfg.commands : void 0;
12319
12354
  const fromCommands = commands?.[configKey];
12320
- if (isRecord$13(fromCommands)) return fromCommands;
12355
+ if (isRecord$14(fromCommands)) return fromCommands;
12321
12356
  for (const alias of deprecatedRuleConfigAliases(configKey)) {
12322
12357
  const fromAlias = commands?.[alias];
12323
- if (!isRecord$13(fromAlias)) continue;
12358
+ if (!isRecord$14(fromAlias)) continue;
12324
12359
  warnOnce(`${configPath ?? "unknown"}:commands.${alias}`, `[xy] Deprecated: "commands.${alias}" in ${configPath ?? "xy.config"} — use "commands.${configKey}"`);
12325
12360
  return fromAlias;
12326
12361
  }
@@ -12332,7 +12367,7 @@ function resolveCommandField(cfg, commandName, configPath) {
12332
12367
  return {};
12333
12368
  }
12334
12369
  function mergeRuleConfigs(target, source) {
12335
- return isRecord$13(target) && isRecord$13(source) ? {
12370
+ return isRecord$14(target) && isRecord$14(source) ? {
12336
12371
  ...target,
12337
12372
  ...source
12338
12373
  } : source;
@@ -12361,6 +12396,21 @@ function isWorkspaceUnderRootConfig(workspaceDir) {
12361
12396
  const relative = path.relative(rootDir, path.resolve(workspaceDir));
12362
12397
  return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
12363
12398
  }
12399
+ function commandKeyIsPresent(cfg, commandName) {
12400
+ const configKey = canonicalRuleConfigKey(commandName);
12401
+ const commands = isRecord$14(cfg.commands) ? cfg.commands : void 0;
12402
+ return commands !== void 0 && Object.hasOwn(commands, configKey);
12403
+ }
12404
+ /**
12405
+ * True when root or workspace xy config declares `commands.<key>`.
12406
+ * An empty merged command object is not a declaration.
12407
+ */
12408
+ async function isCommandConfigDeclared(workspaceDir, commandName) {
12409
+ await ensureRootConfigLoaded();
12410
+ const root = configState.config ?? {};
12411
+ if (isWorkspaceUnderRootConfig(workspaceDir) && commandKeyIsPresent(root, commandName)) return true;
12412
+ return commandKeyIsPresent(await loadWorkspaceConfig(workspaceDir), commandName);
12413
+ }
12364
12414
  async function loadWorkspaceCommandConfig(workspaceDir, commandName) {
12365
12415
  const configKey = canonicalRuleConfigKey(commandName);
12366
12416
  const root = await loadConfig();
@@ -21117,7 +21167,7 @@ const SEVERITIES = /* @__PURE__ */ new Set([
21117
21167
  ]);
21118
21168
  const SCOPES = /* @__PURE__ */ new Set(["development", "runtime"]);
21119
21169
  const RELATIONSHIPS = /* @__PURE__ */ new Set(["direct", "transitive"]);
21120
- function isRecord$12(value) {
21170
+ function isRecord$13(value) {
21121
21171
  return typeof value === "object" && value !== null && !Array.isArray(value);
21122
21172
  }
21123
21173
  function readString(value) {
@@ -21136,13 +21186,13 @@ function readRelationship(value) {
21136
21186
  return RELATIONSHIPS.has(raw) ? raw : "unknown";
21137
21187
  }
21138
21188
  function parseDependabotAlert(raw) {
21139
- if (!isRecord$12(raw)) return void 0;
21140
- const dependency = isRecord$12(raw.dependency) ? raw.dependency : {};
21141
- const dependencyPackage = isRecord$12(dependency.package) ? dependency.package : {};
21142
- const advisory = isRecord$12(raw.security_advisory) ? raw.security_advisory : {};
21143
- const vulnerability = isRecord$12(raw.security_vulnerability) ? raw.security_vulnerability : {};
21144
- const patched = isRecord$12(vulnerability.first_patched_version) ? vulnerability.first_patched_version : {};
21145
- const repository = isRecord$12(raw.repository) ? raw.repository : {};
21189
+ if (!isRecord$13(raw)) return void 0;
21190
+ const dependency = isRecord$13(raw.dependency) ? raw.dependency : {};
21191
+ const dependencyPackage = isRecord$13(dependency.package) ? dependency.package : {};
21192
+ const advisory = isRecord$13(raw.security_advisory) ? raw.security_advisory : {};
21193
+ const vulnerability = isRecord$13(raw.security_vulnerability) ? raw.security_vulnerability : {};
21194
+ const patched = isRecord$13(vulnerability.first_patched_version) ? vulnerability.first_patched_version : {};
21195
+ const repository = isRecord$13(raw.repository) ? raw.repository : {};
21146
21196
  const packageName = readString(dependencyPackage.name);
21147
21197
  if (packageName.length === 0) return void 0;
21148
21198
  const patchedVersion = readString(patched.identifier);
@@ -24345,7 +24395,7 @@ const REQUIRED_SECTIONS = [
24345
24395
  },
24346
24396
  {
24347
24397
  label: "authority",
24348
- pattern: /authority/i
24398
+ pattern: /authorit/i
24349
24399
  },
24350
24400
  {
24351
24401
  label: "repository map",
@@ -24357,7 +24407,33 @@ const REQUIRED_SECTIONS = [
24357
24407
  },
24358
24408
  {
24359
24409
  label: "failures",
24360
- pattern: /fail|troubleshoot/i
24410
+ pattern: /fail|troubleshoot|what not to do|pitfall/i
24411
+ }
24412
+ ];
24413
+ const FRONT_MATTER_KINDS = [
24414
+ {
24415
+ kind: "decision",
24416
+ pattern: /^docs\/decisions\//
24417
+ },
24418
+ {
24419
+ kind: "evidence",
24420
+ pattern: /^docs\/evidence\//
24421
+ },
24422
+ {
24423
+ kind: "runbook",
24424
+ pattern: /^docs\/runbooks\//
24425
+ },
24426
+ {
24427
+ kind: "plan",
24428
+ pattern: /^docs\/plans\//
24429
+ },
24430
+ {
24431
+ kind: "paper",
24432
+ pattern: /^papers\//
24433
+ },
24434
+ {
24435
+ kind: "spec",
24436
+ pattern: /^specs\//
24361
24437
  }
24362
24438
  ];
24363
24439
  function finding(message) {
@@ -24378,6 +24454,34 @@ function linkExists(cwd, from, target) {
24378
24454
  const resolved = path.resolve(cwd, path.dirname(from), bare);
24379
24455
  return fs.existsSync(resolved);
24380
24456
  }
24457
+ function docLinkExists(cwd, from, target) {
24458
+ const bare = target.split("#", 1)[0]?.split("?", 1)[0] ?? "";
24459
+ return bare.length === 0 || fs.existsSync(path.resolve(cwd, bare)) || linkExists(cwd, from, target);
24460
+ }
24461
+ function cellPath(cell) {
24462
+ return (/\[[^\]]*]\(([^)]+)\)/.exec(cell)?.[1] ?? cell).replaceAll(/[`[\]()]/g, " ").trim().split(/\s+/).find((part) => part.includes("/") || part.endsWith(".md"));
24463
+ }
24464
+ function authorityRows(section) {
24465
+ const rows = section.matchAll(/^\|(.+)\|$/gm).map((match) => (match[1] ?? "").split("|").map((cell) => cell.trim())).filter((cells) => cells.some((cell) => cell.length > 0) && cells.some((cell) => !/^:?-+:?$/.test(cell))).toArray();
24466
+ if (rows.length === 0) return [];
24467
+ const header = rows[0] ?? [];
24468
+ const headerIsLabels = header.some((cell) => /authority|document|^path$|^kind$/i.test(cell));
24469
+ const data = headerIsLabels ? rows.slice(1) : rows;
24470
+ const labeledPath = header.findIndex((cell) => /authority|document|^path$/i.test(cell));
24471
+ const pathIndex = headerIsLabels ? Math.max(labeledPath, 0) : 0;
24472
+ const kindIndex = headerIsLabels ? header.findIndex((cell) => /^kind$/i.test(cell)) : 1;
24473
+ const found = [];
24474
+ for (const cells of data) {
24475
+ const target = cellPath(cells[pathIndex] ?? "") ?? cells.map((cell) => cellPath(cell)).find((value) => value !== void 0);
24476
+ if (target === void 0) continue;
24477
+ const kind = kindIndex >= 0 ? cells[kindIndex]?.trim().toLowerCase() : void 0;
24478
+ found.push({
24479
+ kind,
24480
+ target
24481
+ });
24482
+ }
24483
+ return found;
24484
+ }
24381
24485
  function daysSince(isoDate, now) {
24382
24486
  const parsed = Date.parse(isoDate);
24383
24487
  return Number.isNaN(parsed) ? void 0 : (now - parsed) / 864e5;
@@ -24400,14 +24504,41 @@ function contentCommitCount(cwd, relativePath) {
24400
24504
  const count = Number(result.stdout.trim());
24401
24505
  return Number.isFinite(count) ? count : void 0;
24402
24506
  }
24507
+ function inferredFrontMatterKind(relativePath) {
24508
+ return FRONT_MATTER_KINDS.find((entry) => entry.pattern.test(relativePath))?.kind;
24509
+ }
24510
+ function resolvesToAgentsMd(cwd, from, target) {
24511
+ const bare = target.split("#", 1)[0]?.split("?", 1)[0] ?? "";
24512
+ return bare.length > 0 && !/^(?:https?:|mailto:)/.test(bare) && path.resolve(cwd, path.dirname(from), bare) === path.resolve(cwd, "AGENTS.md");
24513
+ }
24514
+ function restatesAgents(adapterText, agentsText) {
24515
+ const agentsBody = agentsText.trim();
24516
+ if (agentsBody.length < 40) return false;
24517
+ const lines = adapterText.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
24518
+ const importAt = lines.findIndex((line) => line.includes("AGENTS.md"));
24519
+ const rest = lines.slice(importAt + 1).join("\n");
24520
+ if (rest.includes(agentsBody)) return true;
24521
+ const h1 = firstHeading(agentsText);
24522
+ const h2s = agentsText.matchAll(/^##\s+(.+)$/gm).map((match) => match[1]?.trim() ?? "").filter((heading) => heading.length > 0).toArray();
24523
+ if (h1 === void 0 || h2s.length < 2) return false;
24524
+ const restHeadings = new Set(headings(rest).map((heading) => heading.toLowerCase()));
24525
+ if (!restHeadings.has(h1.toLowerCase())) return false;
24526
+ return h2s.filter((heading) => restHeadings.has(heading.toLowerCase())).length * 2 >= h2s.length;
24527
+ }
24403
24528
  function adapterFinding(cwd, relativePath, agentsText) {
24404
24529
  const fullPath = path.join(cwd, relativePath);
24405
24530
  if (!fs.existsSync(fullPath)) return void 0;
24406
24531
  if (fs.lstatSync(fullPath).isSymbolicLink()) return path.basename(fs.readlinkSync(fullPath)) === "AGENTS.md" ? void 0 : `${relativePath} symlink does not point at AGENTS.md (inverted-symlink)`;
24407
24532
  const text = fs.readFileSync(fullPath, "utf8");
24408
- if (isThinAgentsImport(text)) return void 0;
24409
24533
  if (agentsText !== void 0 && text === agentsText) return `${relativePath} duplicates AGENTS.md (duplicate)`;
24410
- return /@(\.\/)?AGENTS\.md/.test(text) ? `${relativePath} mentions @AGENTS.md but is not only that import (pointer-not-import)` : `${relativePath} is a copy or a divergent adapter; use an @AGENTS.md import or a symlink`;
24534
+ if (relativePath.endsWith("copilot-instructions.md")) {
24535
+ if (!(hasCopilotAgentsReference(text) || markdownLinkTargets(text).some((target) => resolvesToAgentsMd(cwd, relativePath, target)))) return `${relativePath} does not link to AGENTS.md; use a Markdown link to ../AGENTS.md or a symlink`;
24536
+ } else {
24537
+ const placement = claudeAgentsImportPlacement(text);
24538
+ if (placement === "later") return `${relativePath} mentions @AGENTS.md but the import is not the first line (pointer-not-import)`;
24539
+ if (placement === "absent") return `${relativePath} is a divergent adapter; start with an @AGENTS.md import or use a symlink`;
24540
+ }
24541
+ return agentsText !== void 0 && restatesAgents(text, agentsText) ? `${relativePath} duplicates AGENTS.md (duplicate)` : void 0;
24411
24542
  }
24412
24543
  const AGENT_LINT_RULES = [
24413
24544
  {
@@ -24429,8 +24560,8 @@ const AGENT_LINT_RULES = [
24429
24560
  }
24430
24561
  return findings(messages);
24431
24562
  },
24432
- defaultLevel: "error",
24433
- description: "Tool adapters import AGENTS.md, symlink to it, or are absent",
24563
+ defaultLevel: "warn",
24564
+ description: "Tool adapters lead with an AGENTS.md import or link, then tool-specific notes",
24434
24565
  id: "agents.adapter-thin"
24435
24566
  },
24436
24567
  {
@@ -24450,7 +24581,7 @@ const AGENT_LINT_RULES = [
24450
24581
  const missing = REQUIRED_SECTIONS.filter((section) => present.every((heading) => !section.pattern.test(heading)));
24451
24582
  return missing.length === 0 ? {} : finding(`AGENTS.md is missing sections: ${missing.map((section) => section.label).join(", ")}`);
24452
24583
  },
24453
- defaultLevel: "error",
24584
+ defaultLevel: "warn",
24454
24585
  description: "AGENTS.md has orient, authority, repository map, commands, and failures sections",
24455
24586
  id: "agents.required-sections"
24456
24587
  },
@@ -24479,7 +24610,7 @@ const AGENT_LINT_RULES = [
24479
24610
  for (const document of context.documents) if (/\/(?:Users|home)\//.test(document.text)) messages.push(`${document.relativePath} contains an absolute home-directory path`);
24480
24611
  return findings(messages);
24481
24612
  },
24482
- defaultLevel: "error",
24613
+ defaultLevel: "warn",
24483
24614
  description: "Committed instruction files do not contain /Users or /home paths",
24484
24615
  id: "agents.no-absolute-paths"
24485
24616
  },
@@ -24507,20 +24638,16 @@ const AGENT_LINT_RULES = [
24507
24638
  {
24508
24639
  check: (context) => {
24509
24640
  if (context.agents === void 0) return {};
24510
- const section = context.agents.text.split(/^##\s+/m).find((part) => /^authority\b/i.test(part));
24641
+ const section = context.agents.text.split(/^##\s+/m).find((part) => /authorit/i.test(part.split("\n", 1)[0] ?? ""));
24511
24642
  if (section === void 0) return {};
24512
24643
  const messages = [];
24513
- for (const row of section.matchAll(/^\|([^|\n]+)\|([^|\n]+)\|/gm)) {
24514
- const target = row[1]?.replaceAll(/[[\]]/g, " ").trim().split(/\s+/).at(-1);
24515
- if (target === void 0) continue;
24516
- if (!(target.includes("/") || target.endsWith(".md"))) continue;
24517
- if (!linkExists(context.cwd, "AGENTS.md", target)) {
24518
- messages.push(`Authority row ${target} does not exist`);
24644
+ for (const row of authorityRows(section)) {
24645
+ if (!linkExists(context.cwd, "AGENTS.md", row.target)) {
24646
+ messages.push(`Authority row ${row.target} does not exist`);
24519
24647
  continue;
24520
24648
  }
24521
- const kind = row[2]?.trim().toLowerCase();
24522
- const actual = readLinkedDocument(context, target)?.frontMatter.kind?.toLowerCase();
24523
- if (mismatchedAuthorityKind(kind, actual)) messages.push(`Authority row ${target} claims kind ${kind ?? ""} but front matter says ${actual ?? ""}`);
24649
+ const actual = readLinkedDocument(context, row.target)?.frontMatter.kind?.toLowerCase();
24650
+ if (mismatchedAuthorityKind(row.kind, actual)) messages.push(`Authority row ${row.target} claims kind ${row.kind ?? ""} but front matter says ${actual ?? ""}`);
24524
24651
  }
24525
24652
  return findings(messages);
24526
24653
  },
@@ -24536,14 +24663,22 @@ const AGENT_LINT_RULES = [
24536
24663
  if (!/^(?:docs|papers|specs)\//.test(document.relativePath) || document.relativePath.endsWith("/README.md")) continue;
24537
24664
  const hasMatter = Object.keys(document.frontMatter).length > 0;
24538
24665
  if (hasMatter && document.frontMatter.kind !== void 0) continue;
24539
- if (!hasMatter && rule.fix) {
24540
- fs.writeFileSync(path.join(context.cwd, document.relativePath), `---\nkind: doc\n---\n\n${document.text}`);
24666
+ const kind = inferredFrontMatterKind(document.relativePath);
24667
+ if (kind !== void 0 && !hasMatter && rule.fix) {
24668
+ const next = `---\nkind: ${kind}\n---\n\n${document.text}`;
24669
+ fs.writeFileSync(path.join(context.cwd, document.relativePath), next);
24670
+ document.text = next;
24671
+ document.frontMatter = { kind };
24672
+ document.body = document.text;
24541
24673
  fixedCount += 1;
24542
24674
  continue;
24543
24675
  }
24544
24676
  messages.push(`${document.relativePath} is missing front matter${hasMatter ? " kind" : ""}`);
24545
24677
  }
24546
- return fixedCount > 0 ? { fixedCount } : findings(messages);
24678
+ return fixedCount > 0 ? {
24679
+ ...findings(messages),
24680
+ fixedCount
24681
+ } : findings(messages);
24547
24682
  },
24548
24683
  defaultLevel: "warn",
24549
24684
  description: "Markdown under docs/, papers/, and specs/ has front matter",
@@ -24561,7 +24696,7 @@ const AGENT_LINT_RULES = [
24561
24696
  }
24562
24697
  return finding("docs/README.md does not match the index generated from front matter");
24563
24698
  },
24564
- defaultLevel: "error",
24699
+ defaultLevel: "warn",
24565
24700
  description: "docs/README.md matches the index generated from front matter",
24566
24701
  fixable: true,
24567
24702
  id: "docs.index-current"
@@ -24570,19 +24705,17 @@ const AGENT_LINT_RULES = [
24570
24705
  check: (context) => {
24571
24706
  const messages = [];
24572
24707
  for (const document of context.documents) {
24573
- if (document.frontMatter.state !== "superseded") continue;
24708
+ const state = document.frontMatter.state;
24709
+ if (state !== "superseded" && state !== "retired") continue;
24710
+ if (!document.relativePath.startsWith("docs/archive/")) messages.push(`${document.relativePath} has state ${state} but is not under docs/archive/`);
24711
+ if (state !== "superseded") continue;
24574
24712
  const successor = document.frontMatter.supersededBy;
24575
- if (successor === void 0 || !linkExists(context.cwd, document.relativePath, successor)) {
24576
- messages.push(`${document.relativePath} is superseded without a resolvable supersededBy`);
24577
- continue;
24578
- }
24579
- const resolved = path.posix.normalize(path.posix.join(path.posix.dirname(document.relativePath), successor));
24580
- if (!(resolved.includes("/archive/") || resolved.startsWith("archive/"))) messages.push(`${document.relativePath} is superseded but ${successor} is not under archive/`);
24713
+ if (successor === void 0 || !docLinkExists(context.cwd, document.relativePath, successor)) messages.push(`${document.relativePath} is superseded without a resolvable supersededBy`);
24581
24714
  }
24582
24715
  return findings(messages);
24583
24716
  },
24584
24717
  defaultLevel: "warn",
24585
- description: "Superseded documents point at a successor under archive/",
24718
+ description: "Superseded and retired documents live under docs/archive/ and name a successor",
24586
24719
  id: "docs.superseded-archived"
24587
24720
  },
24588
24721
  {
@@ -24604,6 +24737,9 @@ const AGENT_LINT_RULES = [
24604
24737
  const now = Date.now();
24605
24738
  const messages = [];
24606
24739
  for (const document of context.documents) {
24740
+ if (document.relativePath.startsWith("docs/evidence/") || document.relativePath.startsWith("docs/decisions/") || document.relativePath.startsWith("docs/archive/")) continue;
24741
+ const state = document.frontMatter.state;
24742
+ if (state === "superseded" || state === "retired") continue;
24607
24743
  const stamp = document.frontMatter.reviewed ?? document.frontMatter.date;
24608
24744
  if (stamp === void 0) continue;
24609
24745
  const age = daysSince(stamp, now);
@@ -24619,18 +24755,16 @@ const AGENT_LINT_RULES = [
24619
24755
  },
24620
24756
  {
24621
24757
  check: (context) => {
24622
- const corpus = context.documents.filter((document) => document.relativePath !== "docs/README.md").map((document) => document.text).join("\n");
24623
- const index = documentAt(context, "docs/README.md")?.text ?? "";
24624
24758
  const messages = [];
24625
24759
  for (const document of context.documents) {
24626
24760
  if (!document.relativePath.startsWith("docs/") || document.relativePath === "docs/README.md") continue;
24627
24761
  const name = path.posix.basename(document.relativePath);
24628
- if (!(corpus.includes(document.relativePath) || corpus.includes(name) || index.includes(name) || (context.agents?.text.includes(name) ?? false))) messages.push(`${document.relativePath} is not linked from AGENTS.md, the index, or another document`);
24762
+ if (!(context.documents.some((other) => other.relativePath !== document.relativePath && other.relativePath !== "docs/README.md" && (other.text.includes(document.relativePath) || other.text.includes(name))) || (context.agents?.text.includes(document.relativePath) ?? false) || (context.agents?.text.includes(name) ?? false))) messages.push(`${document.relativePath} is not linked from AGENTS.md or another document`);
24629
24763
  }
24630
24764
  return findings(messages);
24631
24765
  },
24632
24766
  defaultLevel: "warn",
24633
- description: "docs/ files are linked from AGENTS.md, the index, or another document",
24767
+ description: "docs/ files are linked from AGENTS.md or another document",
24634
24768
  id: "docs.orphan"
24635
24769
  },
24636
24770
  {
@@ -24642,17 +24776,22 @@ const AGENT_LINT_RULES = [
24642
24776
  const messages = [];
24643
24777
  for (const document of decisions) {
24644
24778
  const base = path.posix.basename(document.relativePath);
24645
- const numbered = /^(\d+)-/.exec(base);
24646
- const adr = /^ADR-(\d+)/i.exec(base);
24647
24779
  const dated = /^(\d{8})-/.exec(base);
24648
- if (numbered?.[1] !== void 0) {
24649
- schemes.add("numbered");
24650
- ids.push(Number(numbered[1]));
24780
+ const prefixed = /^[A-Za-z][\w]*-D(\d+)/.exec(base);
24781
+ const adr = /^ADR-(\d+)/i.exec(base);
24782
+ const numbered = /^(\d+)-/.exec(base);
24783
+ if (dated !== null) schemes.add("dated");
24784
+ else if (prefixed?.[1] !== void 0) {
24785
+ schemes.add("prefixed");
24786
+ ids.push(Number(prefixed[1]));
24651
24787
  } else if (adr?.[1] !== void 0) {
24652
24788
  schemes.add("adr");
24653
24789
  ids.push(Number(adr[1]));
24654
- } else if (dated === null) schemes.add("other");
24655
- else schemes.add("dated");
24790
+ } else if (numbered?.[1] === void 0) schemes.add("other");
24791
+ else {
24792
+ schemes.add("numbered");
24793
+ ids.push(Number(numbered[1]));
24794
+ }
24656
24795
  if (document.frontMatter.state === void 0) messages.push(`${document.relativePath} has no state`);
24657
24796
  }
24658
24797
  if (schemes.size > 1) messages.push(`docs/decisions uses more than one naming scheme: ${[...schemes].toSorted().join(", ")}`);
@@ -24695,6 +24834,20 @@ function readLinkedDocument(context, target) {
24695
24834
  }
24696
24835
  //#endregion
24697
24836
  //#region src/actions/agent/lint.ts
24837
+ /**
24838
+ * `xy check` runs agent lint when the repo has adopted the convention or
24839
+ * opted in. A direct `xy agent lint` still reports a missing AGENTS.md.
24840
+ */
24841
+ async function isAgentLintEnabled(cwd) {
24842
+ if (await isCommandConfigDeclared(cwd, "agentLint")) return true;
24843
+ try {
24844
+ fs.lstatSync(path.join(cwd, "AGENTS.md"));
24845
+ return true;
24846
+ } catch (error) {
24847
+ if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) === "ENOENT") return false;
24848
+ throw error;
24849
+ }
24850
+ }
24698
24851
  async function agentLint(options = {}) {
24699
24852
  const cwd = options.cwd ?? INIT_CWD();
24700
24853
  return runRuleChecks({
@@ -24703,8 +24856,9 @@ async function agentLint(options = {}) {
24703
24856
  configKey: "agentLint",
24704
24857
  context: loadAgentLintContext(cwd),
24705
24858
  fix: options.fix === true,
24859
+ reporter: defaultRuleReporter(),
24706
24860
  rules: AGENT_LINT_RULES,
24707
- strict: options.strict === true
24861
+ strict: options.strict === true || isStrictMode()
24708
24862
  });
24709
24863
  }
24710
24864
  const AUDIT_RULES = /* @__PURE__ */ new Set([
@@ -24721,8 +24875,9 @@ async function agentAudit(options = {}) {
24721
24875
  config: await loadWorkspaceCommandConfig(cwd, "agentLint"),
24722
24876
  configKey: "agentLint",
24723
24877
  context: loadAgentLintContext(cwd),
24878
+ reporter: defaultRuleReporter(),
24724
24879
  rules: AGENT_LINT_RULES.filter((rule) => AUDIT_RULES.has(rule.id)),
24725
- strict: options.strict === true
24880
+ strict: options.strict === true || isStrictMode()
24726
24881
  });
24727
24882
  }
24728
24883
  //#endregion
@@ -24731,28 +24886,41 @@ function agentIndex(cwd) {
24731
24886
  writeDocsIndex(cwd, loadAgentLintContext(cwd).documents);
24732
24887
  return "docs/README.md";
24733
24888
  }
24889
+ function archiveDestination(relativeSource) {
24890
+ const underDocs = relativeSource.startsWith("docs/") ? relativeSource.slice(5) : path.posix.basename(relativeSource);
24891
+ return path.posix.join("docs/archive", underDocs);
24892
+ }
24893
+ function withArchivedState(text) {
24894
+ const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
24895
+ if (match?.[1] === void 0) return `---\nstate: retired\n---\n\n${text}`;
24896
+ let replaced = false;
24897
+ const lines = match[1].split("\n").map((line) => {
24898
+ const field = /^state\s*:\s*(.*)$/.exec(line.trim());
24899
+ if (field === null) return line;
24900
+ replaced = true;
24901
+ return field[1]?.trim().replaceAll(/^['"]|['"]$/g, "") === "superseded" ? line : "state: retired";
24902
+ });
24903
+ if (!replaced) lines.push("state: retired");
24904
+ const body = text.slice(match[0].length);
24905
+ return `---\n${lines.join("\n")}\n---\n${body.startsWith("\n") ? "" : "\n"}${body}`;
24906
+ }
24734
24907
  function agentArchive(cwd, source) {
24735
24908
  const relativeSource = source.split(path.sep).join("/");
24736
24909
  const fullSource = path.resolve(cwd, relativeSource);
24737
24910
  const root = path.resolve(cwd);
24738
24911
  if (fullSource !== root && !fullSource.startsWith(`${root}${path.sep}`)) throw new Error(`Refusing to archive a path outside the repository: ${source}`);
24739
24912
  if (!fs.existsSync(fullSource) || !fs.statSync(fullSource).isFile()) throw new Error(`Nothing to archive at ${relativeSource}`);
24740
- const parsed = parseFrontMatter(fs.readFileSync(fullSource, "utf8"));
24741
- const frontMatter = {
24742
- ...parsed.frontMatter,
24743
- state: "archived"
24744
- };
24745
- const archived = [
24746
- "---",
24747
- Object.entries(frontMatter).map(([key, value]) => `${key}: ${value}`).join("\n"),
24748
- "---",
24749
- "",
24750
- "> Archived. This document is historical and is not a current instruction.",
24751
- "",
24752
- parsed.body.trimStart()
24753
- ].join("\n");
24754
- const destination = path.posix.join("docs/archive", path.posix.basename(relativeSource));
24913
+ const text = fs.readFileSync(fullSource, "utf8");
24914
+ const parsed = parseFrontMatter(text);
24915
+ const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
24916
+ const successor = parsed.frontMatter.supersededBy;
24917
+ const banner = `> ${parsed.frontMatter.state === "superseded" ? `Superseded${successor === void 0 ? "" : ` by ${successor}`}` : "Retired"} on ${date}. Original path: ${relativeSource}. This document is historical and is not a current instruction.`;
24918
+ const withState = withArchivedState(text);
24919
+ const front = /^(---\r?\n[\s\S]*?\r?\n---\r?\n)/.exec(withState);
24920
+ const archived = front?.[1] === void 0 || withState.includes(banner) ? withState : `${front[1]}\n${banner}\n\n${withState.slice(front[1].length)}`;
24921
+ const destination = archiveDestination(relativeSource);
24755
24922
  const fullDestination = path.join(cwd, destination);
24923
+ if (path.resolve(fullDestination) === fullSource) throw new Error(`Archive destination is the source file: ${destination}`);
24756
24924
  if (fs.existsSync(fullDestination)) throw new Error(`Archive destination already exists: ${destination}`);
24757
24925
  fs.mkdirSync(path.dirname(fullDestination), { recursive: true });
24758
24926
  fs.writeFileSync(fullDestination, archived.endsWith("\n") ? archived : `${archived}\n`);
@@ -25683,7 +25851,7 @@ const RULE_LEVELS = /* @__PURE__ */ new Set([
25683
25851
  "off",
25684
25852
  "warn"
25685
25853
  ]);
25686
- function isRecord$11(value) {
25854
+ function isRecord$12(value) {
25687
25855
  return typeof value === "object" && value !== null && !Array.isArray(value);
25688
25856
  }
25689
25857
  function isValidWeight(value) {
@@ -25700,7 +25868,7 @@ function parseTupleRuleSetting(location, setting) {
25700
25868
  if (setting.length !== 2) throw new TypeError(`${location} tuple must be [level, options]`);
25701
25869
  const [level, options] = setting;
25702
25870
  if (!isRuleLevel$3(level)) throw new TypeError(`${location} level must be "error", "warn", or "off"`);
25703
- if (!isRecord$11(options)) throw new TypeError(`${location} options must be an object`);
25871
+ if (!isRecord$12(options)) throw new TypeError(`${location} options must be an object`);
25704
25872
  return {
25705
25873
  enabled: level !== "off",
25706
25874
  level,
@@ -25733,7 +25901,7 @@ function parseRuleSetting(location, setting) {
25733
25901
  weight: parseWeight(location, setting)
25734
25902
  };
25735
25903
  if (Array.isArray(setting)) return parseTupleRuleSetting(location, setting);
25736
- if (isRecord$11(setting)) return parseObjectRuleSetting(location, setting);
25904
+ if (isRecord$12(setting)) return parseObjectRuleSetting(location, setting);
25737
25905
  throw new TypeError(`${location} must be a boolean, rule level, number, "infinite", [level, options], or { enabled?, level?, weight? } object`);
25738
25906
  }
25739
25907
  function validateRuleIds(location, rules) {
@@ -28832,7 +29000,7 @@ function isJsonConfigPath$1(configPath) {
28832
29000
  const base = path.basename(configPath);
28833
29001
  return base === ".xyrc.json" || base.endsWith(".json");
28834
29002
  }
28835
- function getPropertyName$3(prop) {
29003
+ function getPropertyName$4(prop) {
28836
29004
  if (ts.isPropertyAssignment(prop)) {
28837
29005
  const { name } = prop;
28838
29006
  if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNoSubstitutionTemplateLiteral(name)) return name.text;
@@ -28850,9 +29018,9 @@ function findDeplintPackagesAssignment(sourceFile) {
28850
29018
  let found;
28851
29019
  function visit(node) {
28852
29020
  if (found !== void 0) return;
28853
- if (ts.isPropertyAssignment(node) && getPropertyName$3(node) === "packages" && ts.isObjectLiteralExpression(node.initializer)) {
29021
+ if (ts.isPropertyAssignment(node) && getPropertyName$4(node) === "packages" && ts.isObjectLiteralExpression(node.initializer)) {
28854
29022
  const parentObject = node.parent;
28855
- if (ts.isObjectLiteralExpression(parentObject) && ts.isPropertyAssignment(parentObject.parent) && getPropertyName$3(parentObject.parent) === "deplint") {
29023
+ if (ts.isObjectLiteralExpression(parentObject) && ts.isPropertyAssignment(parentObject.parent) && getPropertyName$4(parentObject.parent) === "deplint") {
28856
29024
  found = node;
28857
29025
  return;
28858
29026
  }
@@ -28866,7 +29034,7 @@ function findDeplintObjectAssignment(sourceFile) {
28866
29034
  let found;
28867
29035
  function visit(node) {
28868
29036
  if (found !== void 0) return;
28869
- if (ts.isPropertyAssignment(node) && getPropertyName$3(node) === "deplint" && ts.isObjectLiteralExpression(node.initializer)) {
29037
+ if (ts.isPropertyAssignment(node) && getPropertyName$4(node) === "deplint" && ts.isObjectLiteralExpression(node.initializer)) {
28870
29038
  found = node;
28871
29039
  return;
28872
29040
  }
@@ -28879,7 +29047,7 @@ function findCommandsObjectAssignment(sourceFile) {
28879
29047
  let found;
28880
29048
  function visit(node) {
28881
29049
  if (found !== void 0) return;
28882
- if (ts.isPropertyAssignment(node) && getPropertyName$3(node) === "commands" && ts.isObjectLiteralExpression(node.initializer)) {
29050
+ if (ts.isPropertyAssignment(node) && getPropertyName$4(node) === "commands" && ts.isObjectLiteralExpression(node.initializer)) {
28883
29051
  found = node;
28884
29052
  return;
28885
29053
  }
@@ -28912,7 +29080,7 @@ function formatPackageConfigValue(config) {
28912
29080
  if (legacyRefType !== void 0) parts.push(`refType: '${legacyRefType}'`);
28913
29081
  return `{ ${parts.join(", ")} }`;
28914
29082
  }
28915
- function detectIndent$2(text, packagesObject, sourceFile) {
29083
+ function detectIndent$3(text, packagesObject, sourceFile) {
28916
29084
  if (packagesObject.properties.length > 0) {
28917
29085
  const start = packagesObject.properties[0].getStart(sourceFile);
28918
29086
  let lineStart = start;
@@ -28928,7 +29096,7 @@ function detectIndent$2(text, packagesObject, sourceFile) {
28928
29096
  function findPackageProperty(packagesObject, dependency) {
28929
29097
  for (const prop of packagesObject.properties) {
28930
29098
  if (!ts.isPropertyAssignment(prop)) continue;
28931
- if (getPropertyName$3(prop) === dependency) return prop;
29099
+ if (getPropertyName$4(prop) === dependency) return prop;
28932
29100
  }
28933
29101
  }
28934
29102
  function removePropertyFromObject$1(text, prop, sourceFile) {
@@ -28957,7 +29125,7 @@ function upsertPackagePropertyInObject(text, packagesAssignment, sourceFile, dep
28957
29125
  }
28958
29126
  const valueText = formatPackageConfigValue(config);
28959
29127
  const keyText = quotePackageKey(dependency);
28960
- const indent = detectIndent$2(text, packagesObject, sourceFile);
29128
+ const indent = detectIndent$3(text, packagesObject, sourceFile);
28961
29129
  const entry = `${keyText}: ${valueText}`;
28962
29130
  const openBraceEnd = packagesObject.getStart(sourceFile) + 1;
28963
29131
  const insertion = `\n${indent}${entry},`;
@@ -28966,7 +29134,7 @@ function upsertPackagePropertyInObject(text, packagesAssignment, sourceFile, dep
28966
29134
  function insertPackagesIntoDeplint(text, deplintAssignment, sourceFile, dependency, config) {
28967
29135
  if (!ts.isObjectLiteralExpression(deplintAssignment.initializer)) throw new TypeError("deplint must be an object literal");
28968
29136
  const deplintObject = deplintAssignment.initializer;
28969
- const indent = detectIndent$2(text, deplintObject, sourceFile);
29137
+ const indent = detectIndent$3(text, deplintObject, sourceFile);
28970
29138
  const packagesBlock = `packages: {\n${indent} ${quotePackageKey(dependency)}: ${formatPackageConfigValue(config)},\n${indent}}`;
28971
29139
  const openBraceEnd = deplintObject.getStart(sourceFile) + 1;
28972
29140
  const insertion = `\n${indent}${packagesBlock},`;
@@ -28975,7 +29143,7 @@ function insertPackagesIntoDeplint(text, deplintAssignment, sourceFile, dependen
28975
29143
  function insertDeplintIntoCommands(text, commandsAssignment, sourceFile, dependency, config) {
28976
29144
  if (!ts.isObjectLiteralExpression(commandsAssignment.initializer)) throw new TypeError("commands must be an object literal");
28977
29145
  const commandsObject = commandsAssignment.initializer;
28978
- const indent = detectIndent$2(text, commandsObject, sourceFile);
29146
+ const indent = detectIndent$3(text, commandsObject, sourceFile);
28979
29147
  const block = [
28980
29148
  "deplint: {",
28981
29149
  `${indent} packages: {`,
@@ -28988,7 +29156,7 @@ function insertDeplintIntoCommands(text, commandsAssignment, sourceFile, depende
28988
29156
  return `${text.slice(0, openBraceEnd)}${insertion}${text.slice(openBraceEnd)}`;
28989
29157
  }
28990
29158
  function insertCommandsIntoConfigObject(text, configObject, sourceFile, dependency, config) {
28991
- const indent = detectIndent$2(text, configObject, sourceFile);
29159
+ const indent = detectIndent$3(text, configObject, sourceFile);
28992
29160
  const block = [
28993
29161
  "commands: {",
28994
29162
  `${indent} deplint: {`,
@@ -29036,11 +29204,11 @@ function applyPackageEditsToTsSource(text, edits) {
29036
29204
  }
29037
29205
  return result;
29038
29206
  }
29039
- function isRecord$10(value) {
29207
+ function isRecord$11(value) {
29040
29208
  return typeof value === "object" && value !== null && !Array.isArray(value);
29041
29209
  }
29042
29210
  function readJsonPackageConfig(value) {
29043
- if (!isRecord$10(value)) return void 0;
29211
+ if (!isRecord$11(value)) return void 0;
29044
29212
  const config = {};
29045
29213
  if (typeof value.placement === "string") config.placement = value.placement;
29046
29214
  if (typeof value.presence === "string") config.presence = value.presence;
@@ -29049,10 +29217,10 @@ function readJsonPackageConfig(value) {
29049
29217
  return config;
29050
29218
  }
29051
29219
  function resolveJsonDeplintObject(root) {
29052
- const commands = isRecord$10(root.commands) ? root.commands : void 0;
29053
- if (commands !== void 0 && isRecord$10(commands.deplint)) return commands.deplint;
29054
- if (isRecord$10(root.deplint)) return root.deplint;
29055
- if (!isRecord$10(root.commands)) root.commands = {};
29220
+ const commands = isRecord$11(root.commands) ? root.commands : void 0;
29221
+ if (commands !== void 0 && isRecord$11(commands.deplint)) return commands.deplint;
29222
+ if (isRecord$11(root.deplint)) return root.deplint;
29223
+ if (!isRecord$11(root.commands)) root.commands = {};
29056
29224
  const cmds = root.commands;
29057
29225
  const deplint = {};
29058
29226
  cmds.deplint = deplint;
@@ -29065,7 +29233,7 @@ function applyPackageEditsToJsonSource(text, edits) {
29065
29233
  if (edits.length === 0) return text;
29066
29234
  const root = JSON.parse(text);
29067
29235
  const deplint = resolveJsonDeplintObject(root);
29068
- const packages = isRecord$10(deplint.packages) ? deplint.packages : deplint.packages = {};
29236
+ const packages = isRecord$11(deplint.packages) ? deplint.packages : deplint.packages = {};
29069
29237
  for (const edit of edits) if (edit.config === void 0) delete packages[edit.dependency];
29070
29238
  else packages[edit.dependency] = edit.config;
29071
29239
  if (Object.keys(packages).length === 0) delete deplint.packages;
@@ -29075,7 +29243,7 @@ function readPackageConfigFromObjectLiteral(objectLiteral) {
29075
29243
  const config = {};
29076
29244
  for (const prop of objectLiteral.properties) {
29077
29245
  if (!ts.isPropertyAssignment(prop)) continue;
29078
- const key = getPropertyName$3(prop);
29246
+ const key = getPropertyName$4(prop);
29079
29247
  if (key === void 0) continue;
29080
29248
  const { initializer } = prop;
29081
29249
  if ([
@@ -29100,9 +29268,9 @@ function readPackagesFromConfigFile(configPath) {
29100
29268
  const result = /* @__PURE__ */ new Map();
29101
29269
  if (isJsonConfigPath$1(configPath)) try {
29102
29270
  const root = JSON.parse(text);
29103
- const commands = isRecord$10(root.commands) ? root.commands : void 0;
29104
- const deplint = commands !== void 0 && isRecord$10(commands.deplint) ? commands.deplint : isRecord$10(root.deplint) ? root.deplint : void 0;
29105
- const packages = deplint !== void 0 && isRecord$10(deplint.packages) ? deplint.packages : void 0;
29271
+ const commands = isRecord$11(root.commands) ? root.commands : void 0;
29272
+ const deplint = commands !== void 0 && isRecord$11(commands.deplint) ? commands.deplint : isRecord$11(root.deplint) ? root.deplint : void 0;
29273
+ const packages = deplint !== void 0 && isRecord$11(deplint.packages) ? deplint.packages : void 0;
29106
29274
  if (packages === void 0) return result;
29107
29275
  for (const [name, value] of Object.entries(packages)) {
29108
29276
  const config = readJsonPackageConfig(value);
@@ -29116,7 +29284,7 @@ function readPackagesFromConfigFile(configPath) {
29116
29284
  if (packagesAssignment === void 0 || !ts.isObjectLiteralExpression(packagesAssignment.initializer)) return result;
29117
29285
  for (const prop of packagesAssignment.initializer.properties) {
29118
29286
  if (!ts.isPropertyAssignment(prop)) continue;
29119
- const name = getPropertyName$3(prop);
29287
+ const name = getPropertyName$4(prop);
29120
29288
  if (name === void 0 || !ts.isObjectLiteralExpression(prop.initializer)) continue;
29121
29289
  result.set(name, readPackageConfigFromObjectLiteral(prop.initializer));
29122
29290
  }
@@ -29446,7 +29614,7 @@ const BUILT_IN_RULE_OPTION_KEYS = {
29446
29614
  ]),
29447
29615
  "dep.workspace.protocol": /* @__PURE__ */ new Set(["ignore", "protocol"])
29448
29616
  };
29449
- function isRecord$9(value) {
29617
+ function isRecord$10(value) {
29450
29618
  return typeof value === "object" && value !== null && !Array.isArray(value);
29451
29619
  }
29452
29620
  function isRuleLevel$2(value) {
@@ -29487,7 +29655,7 @@ function parseRuleConfig$1(ruleId, value) {
29487
29655
  const level = value[0];
29488
29656
  if (!isRuleLevel$2(level)) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} level must be one of "off", "warn", or "error"`);
29489
29657
  const options = value[1];
29490
- if (!isRecord$9(options)) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} options must be an object`);
29658
+ if (!isRecord$10(options)) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} options must be an object`);
29491
29659
  return {
29492
29660
  level,
29493
29661
  options: { ...options }
@@ -29942,7 +30110,7 @@ const npmPackageNamePattern = /^@?[a-z0-9][\w./-]*$/i;
29942
30110
  function isStorybookMainFile(filePath) {
29943
30111
  return storybookMainPattern.test(filePath);
29944
30112
  }
29945
- function getPropertyName$2(prop) {
30113
+ function getPropertyName$3(prop) {
29946
30114
  if (ts.isIdentifier(prop.name)) return prop.name.text;
29947
30115
  return ts.isStringLiteral(prop.name) || ts.isNoSubstitutionTemplateLiteral(prop.name) ? prop.name.text : void 0;
29948
30116
  }
@@ -29957,7 +30125,7 @@ function extractFromEntry(node, collected) {
29957
30125
  return;
29958
30126
  }
29959
30127
  if (ts.isObjectLiteralExpression(node)) {
29960
- for (const prop of node.properties) if (ts.isPropertyAssignment(prop) && getPropertyName$2(prop) === "name") extractFromEntry(prop.initializer, collected);
30128
+ for (const prop of node.properties) if (ts.isPropertyAssignment(prop) && getPropertyName$3(prop) === "name") extractFromEntry(prop.initializer, collected);
29961
30129
  return;
29962
30130
  }
29963
30131
  if (ts.isCallExpression(node)) {
@@ -29974,7 +30142,7 @@ function getStorybookConfigImports(filePath, importPaths) {
29974
30142
  const collected = [];
29975
30143
  function visit(node) {
29976
30144
  if (ts.isPropertyAssignment(node)) {
29977
- const name = getPropertyName$2(node);
30145
+ const name = getPropertyName$3(node);
29978
30146
  if (name === "addons") {
29979
30147
  if (ts.isArrayLiteralExpression(node.initializer)) for (const element of node.initializer.elements) extractFromEntry(element, collected);
29980
30148
  } else if (name === "framework" || name === "builder") extractFromEntry(node.initializer, collected);
@@ -30212,7 +30380,7 @@ function getMostUsedKey(indents) {
30212
30380
  function makeIndentString(type, amount) {
30213
30381
  return (type === INDENT_TYPE_SPACE ? " " : " ").repeat(amount);
30214
30382
  }
30215
- function detectIndent$1(string) {
30383
+ function detectIndent$2(string) {
30216
30384
  if (typeof string !== "string") throw new TypeError("Expected a string");
30217
30385
  let indents = makeIndentsMap(string, true);
30218
30386
  if (indents.size === 0) indents = makeIndentsMap(string, false);
@@ -30848,7 +31016,7 @@ const defaultSortOrder = fields.map(({ key }) => key);
30848
31016
  const overFields = pipe(fields.map(({ key, over }) => over ? overProperty(key, over) : void 0).filter(Boolean));
30849
31017
  function editStringJSON(json, over) {
30850
31018
  if (typeof json === "string") {
30851
- const { indent, type } = detectIndent$1(json);
31019
+ const { indent, type } = detectIndent$2(json);
30852
31020
  const endCharacters = json.slice(-1) === "\n" ? "\n" : "";
30853
31021
  const newline = detectNewlineGraceful(json);
30854
31022
  json = JSON.parse(json);
@@ -36549,7 +36717,7 @@ const alwaysActiveConditions = /* @__PURE__ */ new Set(["default", "neutral"]);
36549
36717
  const typeOnlyConditions = /* @__PURE__ */ new Set(["types"]);
36550
36718
  const sourceFileRe = /\.(?:[cm]?tsx?)$/;
36551
36719
  const declarationFileRe = /\.d\.[cm]?ts$/;
36552
- function isRecord$8(value) {
36720
+ function isRecord$9(value) {
36553
36721
  return typeof value === "object" && value !== null && !Array.isArray(value);
36554
36722
  }
36555
36723
  function resolveOrExclude(target, conditions) {
@@ -36562,7 +36730,7 @@ function resolveOrExclude(target, conditions) {
36562
36730
  }
36563
36731
  return;
36564
36732
  }
36565
- if (!isRecord$8(target)) return void 0;
36733
+ if (!isRecord$9(target)) return void 0;
36566
36734
  for (const [condition, nested] of Object.entries(target)) {
36567
36735
  if (typeOnlyConditions.has(condition)) continue;
36568
36736
  if (!alwaysActiveConditions.has(condition) && !conditions.has(condition)) continue;
@@ -36583,7 +36751,7 @@ Condition keys a target branches on, excluding always-active and type-only keys.
36583
36751
  */
36584
36752
  function runtimeConditionKeys(target) {
36585
36753
  if (Array.isArray(target)) return target.flatMap((entry) => runtimeConditionKeys(entry));
36586
- if (!isRecord$8(target)) return [];
36754
+ if (!isRecord$9(target)) return [];
36587
36755
  return Object.entries(target).flatMap(([condition, nested]) => [...alwaysActiveConditions.has(condition) || typeOnlyConditions.has(condition) ? [] : [condition], ...runtimeConditionKeys(nested)]);
36588
36756
  }
36589
36757
  /**
@@ -36597,7 +36765,7 @@ function conditionCombinations(keys) {
36597
36765
  function leafTargets(target) {
36598
36766
  if (typeof target === "string") return [target];
36599
36767
  if (Array.isArray(target)) return target.flatMap((entry) => leafTargets(entry));
36600
- return isRecord$8(target) ? Object.entries(target).filter(([condition]) => !typeOnlyConditions.has(condition)).flatMap(([, nested]) => leafTargets(nested)) : [];
36768
+ return isRecord$9(target) ? Object.entries(target).filter(([condition]) => !typeOnlyConditions.has(condition)).flatMap(([, nested]) => leafTargets(nested)) : [];
36601
36769
  }
36602
36770
  function isSourceTarget(target) {
36603
36771
  return sourceFileRe.test(target) && !declarationFileRe.test(target);
@@ -36616,7 +36784,7 @@ function normalizeTarget$1(target) {
36616
36784
  return target === void 0 || target.startsWith("./") ? target : `./${target}`;
36617
36785
  }
36618
36786
  function exportSubpaths(exports) {
36619
- const entries = isRecord$8(exports) ? Object.entries(exports) : [];
36787
+ const entries = isRecord$9(exports) ? Object.entries(exports) : [];
36620
36788
  return Object.fromEntries(entries.filter(([key]) => key === "." || key.startsWith("./")));
36621
36789
  }
36622
36790
  /**
@@ -36626,7 +36794,7 @@ function exportSubpaths(exports) {
36626
36794
  * not also select.
36627
36795
  */
36628
36796
  function importAliasTarget(imports, subpath, conditions) {
36629
- if (!isRecord$8(imports) || !subpath.startsWith("./")) return void 0;
36797
+ if (!isRecord$9(imports) || !subpath.startsWith("./")) return void 0;
36630
36798
  const alias = `#${subpath.slice(2)}`;
36631
36799
  const importTarget = imports[alias];
36632
36800
  return isRuntimeImportTarget(importTarget) ? {
@@ -36652,7 +36820,7 @@ function aliasMismatches(importTarget, exportTarget) {
36652
36820
  * the conditions either map branches on.
36653
36821
  */
36654
36822
  function findImportAliasDivergences(imports, exports) {
36655
- if (!isRecord$8(imports)) return [];
36823
+ if (!isRecord$9(imports)) return [];
36656
36824
  const subpaths = exportSubpaths(exports);
36657
36825
  return Object.entries(imports).flatMap(([alias, importTarget]) => {
36658
36826
  if (!alias.startsWith("#") || alias.includes("*")) return [];
@@ -36911,7 +37079,7 @@ function findConfigFile(pkgDir) {
36911
37079
  if (fs.existsSync(candidate)) return candidate;
36912
37080
  }
36913
37081
  }
36914
- function getPropertyName$1(prop) {
37082
+ function getPropertyName$2(prop) {
36915
37083
  if (!ts.isPropertyAssignment(prop)) return void 0;
36916
37084
  const { name } = prop;
36917
37085
  return ts.isIdentifier(name) || ts.isStringLiteral(name) ? name.text : void 0;
@@ -36924,8 +37092,8 @@ function getPropertyName$1(prop) {
36924
37092
  function collectEmptyTargetProps(sourceFile) {
36925
37093
  const found = [];
36926
37094
  function visit(node) {
36927
- if (ts.isPropertyAssignment(node) && getPropertyName$1(node) === "compile" && ts.isObjectLiteralExpression(node.initializer)) {
36928
- for (const prop of node.initializer.properties) if (ts.isPropertyAssignment(prop) && COMPILE_TARGET_NAMES.has(getPropertyName$1(prop) ?? "") && ts.isObjectLiteralExpression(prop.initializer) && prop.initializer.properties.length === 0) found.push(prop);
37095
+ if (ts.isPropertyAssignment(node) && getPropertyName$2(node) === "compile" && ts.isObjectLiteralExpression(node.initializer)) {
37096
+ for (const prop of node.initializer.properties) if (ts.isPropertyAssignment(prop) && COMPILE_TARGET_NAMES.has(getPropertyName$2(prop) ?? "") && ts.isObjectLiteralExpression(prop.initializer) && prop.initializer.properties.length === 0) found.push(prop);
36929
37097
  }
36930
37098
  ts.forEachChild(node, visit);
36931
37099
  }
@@ -36976,9 +37144,9 @@ function checkCompileTargets(pkgDir, shouldFix) {
36976
37144
  const configName = path.basename(configPath);
36977
37145
  if (shouldFix) {
36978
37146
  fs.writeFileSync(configPath, removeProperties(text, emptyProps, sourceFile));
36979
- for (const prop of emptyProps) console.warn(chalk.yellow(`Publint [compileTargets]: removed deprecated empty "compile.${getPropertyName$1(prop)}" target from ${configName}`));
37147
+ for (const prop of emptyProps) console.warn(chalk.yellow(`Publint [compileTargets]: removed deprecated empty "compile.${getPropertyName$2(prop)}" target from ${configName}`));
36980
37148
  result.modified = true;
36981
- } else for (const prop of emptyProps) console.warn(chalk.yellow(`Publint [compileTargets]: "compile.${getPropertyName$1(prop)} = {}" is treated as "do not build" — set it to \`false\` or remove it (use --fix to remove) in ${configName}`));
37149
+ } else for (const prop of emptyProps) console.warn(chalk.yellow(`Publint [compileTargets]: "compile.${getPropertyName$2(prop)} = {}" is treated as "do not build" — set it to \`false\` or remove it (use --fix to remove) in ${configName}`));
36982
37150
  result.warnings += emptyProps.length;
36983
37151
  return result;
36984
37152
  }
@@ -37308,7 +37476,7 @@ function formatExportPath$1(pathParts) {
37308
37476
  function ensureExportsPath$1(value) {
37309
37477
  return value.startsWith("./") ? value : `./${value}`;
37310
37478
  }
37311
- function isRecord$7(value) {
37479
+ function isRecord$8(value) {
37312
37480
  return typeof value === "object" && value !== null && !Array.isArray(value);
37313
37481
  }
37314
37482
  function normalizeTarget(target) {
@@ -37345,7 +37513,7 @@ function collectExportLeaves(value, subpath = ".", pathParts = ["exports"], cond
37345
37513
  }];
37346
37514
  }
37347
37515
  if (Array.isArray(value)) return value.flatMap((entry, index) => collectExportLeaves(entry, subpath, [...pathParts, `[${index}]`], conditionPath));
37348
- if (!isRecord$7(value)) return [];
37516
+ if (!isRecord$8(value)) return [];
37349
37517
  return Object.entries(value).flatMap(([key, nested]) => {
37350
37518
  return isSubpathExportKey$1(key) ? collectExportLeaves(nested, key, [...pathParts, key], conditionPath) : collectExportLeaves(nested, subpath, [...pathParts, key], [...conditionPath, key]);
37351
37519
  });
@@ -37467,14 +37635,14 @@ function shouldNormalizeExportsForFix(pkg) {
37467
37635
  pkg.exports = { ".": pkg.exports };
37468
37636
  return true;
37469
37637
  }
37470
- if (isRecord$7(pkg.exports) && !hasSubpathKeys(pkg.exports)) {
37638
+ if (isRecord$8(pkg.exports) && !hasSubpathKeys(pkg.exports)) {
37471
37639
  pkg.exports = { ".": pkg.exports };
37472
37640
  return true;
37473
37641
  }
37474
37642
  return false;
37475
37643
  }
37476
37644
  function isRecordObject(value) {
37477
- return isRecord$7(value);
37645
+ return isRecord$8(value);
37478
37646
  }
37479
37647
  function ensureSubpath(exports, subpath) {
37480
37648
  const existing = exports[subpath];
@@ -43014,7 +43182,7 @@ const VALID_RULE_LEVELS = /* @__PURE__ */ new Set([
43014
43182
  "warn",
43015
43183
  "error"
43016
43184
  ]);
43017
- function isRecord$6(value) {
43185
+ function isRecord$7(value) {
43018
43186
  return typeof value === "object" && value !== null && !Array.isArray(value);
43019
43187
  }
43020
43188
  function isRuleLevel(value) {
@@ -43039,13 +43207,13 @@ function parseRuleConfig(ruleId, value) {
43039
43207
  const level = value[0];
43040
43208
  if (!isRuleLevel(level)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} level must be one of "off", "warn", or "error"`);
43041
43209
  const options = value[1];
43042
- if (!isRecord$6(options)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} options must be an object`);
43210
+ if (!isRecord$7(options)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} options must be an object`);
43043
43211
  return {
43044
43212
  level,
43045
43213
  options: { ...options }
43046
43214
  };
43047
43215
  }
43048
- if (isRecord$6(value)) return {
43216
+ if (isRecord$7(value)) return {
43049
43217
  level: "warn",
43050
43218
  options: { ...value }
43051
43219
  };
@@ -44124,7 +44292,7 @@ function isJsonConfigPath(configPath) {
44124
44292
  const base = path.basename(configPath);
44125
44293
  return base === ".xyrc.json" || base.endsWith(".json");
44126
44294
  }
44127
- function getPropertyName(prop) {
44295
+ function getPropertyName$1(prop) {
44128
44296
  if (ts.isPropertyAssignment(prop)) {
44129
44297
  const { name } = prop;
44130
44298
  if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNoSubstitutionTemplateLiteral(name)) return name.text;
@@ -44148,10 +44316,10 @@ function findDefaultExportObject(sourceFile) {
44148
44316
  function findObjectProperty(object, key) {
44149
44317
  for (const prop of object.properties) {
44150
44318
  if (!ts.isPropertyAssignment(prop)) continue;
44151
- if (getPropertyName(prop) === key) return prop;
44319
+ if (getPropertyName$1(prop) === key) return prop;
44152
44320
  }
44153
44321
  }
44154
- function detectIndent(text, object, sourceFile) {
44322
+ function detectIndent$1(text, object, sourceFile) {
44155
44323
  if (object.properties.length > 0) {
44156
44324
  const start = object.properties[0].getStart(sourceFile);
44157
44325
  let lineStart = start;
@@ -44178,7 +44346,7 @@ function removePropertyFromObject(text, prop, sourceFile) {
44178
44346
  return `${text.slice(0, start)}${text.slice(end)}`;
44179
44347
  }
44180
44348
  function insertPropertyIntoObject(text, object, sourceFile, entry) {
44181
- const indent = detectIndent(text, object, sourceFile);
44349
+ const indent = detectIndent$1(text, object, sourceFile);
44182
44350
  const openBraceEnd = object.getStart(sourceFile) + 1;
44183
44351
  const insertion = `\n${indent}${entry},`;
44184
44352
  return `${text.slice(0, openBraceEnd)}${insertion}${text.slice(openBraceEnd)}`;
@@ -44217,7 +44385,7 @@ function applyCompileCompilerToTsSource(text, compiler) {
44217
44385
  if ((ts.isStringLiteral(validator.initializer) || ts.isNoSubstitutionTemplateLiteral(validator.initializer)) && validator.initializer.text === "shared") result = removePropertyFromObject(result, validator, afterCompiler);
44218
44386
  return result;
44219
44387
  }
44220
- function isRecord$5(value) {
44388
+ function isRecord$6(value) {
44221
44389
  return typeof value === "object" && value !== null && !Array.isArray(value);
44222
44390
  }
44223
44391
  /**
@@ -44225,7 +44393,7 @@ function isRecord$5(value) {
44225
44393
  */
44226
44394
  function applyCompileCompilerToJsonSource(text, compiler) {
44227
44395
  const root = JSON.parse(text);
44228
- const compile = isRecord$5(root.compile) ? { ...root.compile } : {};
44396
+ const compile = isRecord$6(root.compile) ? { ...root.compile } : {};
44229
44397
  compile.compiler = compiler;
44230
44398
  if (compiler === "native" && compile.validator === "shared") delete compile.validator;
44231
44399
  root.compile = compile;
@@ -46459,12 +46627,12 @@ function checkPnpmReleaseAgeExcludes(cwd, pm, workspaces = []) {
46459
46627
  for (const pattern of unnecessary) result.fixable.push(`pnpm-workspace.yaml minimumReleaseAgeExclude includes '${pattern}' but the repo does not use that scope`);
46460
46628
  return result;
46461
46629
  }
46462
- function isRecord$4(value) {
46630
+ function isRecord$5(value) {
46463
46631
  return typeof value === "object" && value !== null && !Array.isArray(value);
46464
46632
  }
46465
46633
  function isConfiguredValue(value) {
46466
46634
  if (value === void 0 || value === null) return false;
46467
- if (isRecord$4(value)) return Object.keys(value).length > 0;
46635
+ if (isRecord$5(value)) return Object.keys(value).length > 0;
46468
46636
  return Array.isArray(value) ? value.length > 0 : value !== "";
46469
46637
  }
46470
46638
  function configuredYamlKeys(node) {
@@ -46489,8 +46657,8 @@ function formatOverrideWarning(location, keys) {
46489
46657
  function checkPnpmDependencyOverrides(cwd, pm, rootPkg) {
46490
46658
  const result = emptyResult$2();
46491
46659
  if (pm !== "pnpm") return result;
46492
- const packageJsonOverrides = (isRecord$4(rootPkg.pnpm) ? rootPkg.pnpm : void 0)?.overrides;
46493
- if (isConfiguredValue(packageJsonOverrides)) result.warnings.push(formatOverrideWarning("Root package.json pnpm.overrides field", isRecord$4(packageJsonOverrides) ? Object.keys(packageJsonOverrides) : []));
46660
+ const packageJsonOverrides = (isRecord$5(rootPkg.pnpm) ? rootPkg.pnpm : void 0)?.overrides;
46661
+ if (isConfiguredValue(packageJsonOverrides)) result.warnings.push(formatOverrideWarning("Root package.json pnpm.overrides field", isRecord$5(packageJsonOverrides) ? Object.keys(packageJsonOverrides) : []));
46494
46662
  const workspaceOverrides = readPnpmWorkspaceDocument(cwd)?.get("overrides");
46495
46663
  if (isConfiguredYamlNode(workspaceOverrides)) result.warnings.push(formatOverrideWarning("pnpm-workspace.yaml overrides field", configuredYamlKeys(workspaceOverrides)));
46496
46664
  return result;
@@ -48037,7 +48205,7 @@ function visibleMarkdown(markdown) {
48037
48205
  return markdown.replaceAll(/^ {0,3}([`~]{3,})[^\n]*\n[\s\S]*?^ {0,3}\1[^\n]*$/gmu, "\n").replaceAll(/`[^`\n]+`/gu, " ").replaceAll(/<!--[\s\S]*?-->/gu, " ");
48038
48206
  }
48039
48207
  function hasClaudeAgentsImport(markdown) {
48040
- return /(?:^|[\s(])@(?:\.\/)?AGENTS\.md(?=$|[\s).,;:])/u.test(visibleMarkdown(markdown));
48208
+ return claudeAgentsImportPlacement(markdown) === "first";
48041
48209
  }
48042
48210
  function claudeFileImports(markdown) {
48043
48211
  const imports = [];
@@ -48265,7 +48433,7 @@ const claudeImportsOutcome = (root, hasClaude, fix) => {
48265
48433
  if (contents === void 0 || hasClaudeAgentsImport(contents)) return { diagnostics: [] };
48266
48434
  if (fix) {
48267
48435
  const template = PLAN_REQUIRED_FILE_TEMPLATES["CLAUDE.md"];
48268
- const next = contents.trim().length === 0 ? template : `${template}${contents.trimStart()}`;
48436
+ const next = contents.trim().length === 0 ? template : `${template.trimEnd()}\n\n${contents.trimStart()}`;
48269
48437
  if (writeRootMarkdown(root, "CLAUDE.md", next)) return {
48270
48438
  diagnostics: [],
48271
48439
  fixedCount: 1
@@ -49493,7 +49661,7 @@ async function resolveRepoInitPlan(params) {
49493
49661
  //#region src/actions/repo-init/templateVars.ts
49494
49662
  function packageManagerField(pm) {
49495
49663
  switch (pm) {
49496
- case "pnpm": return "pnpm@11.13.1";
49664
+ case "pnpm": return "pnpm@12.10.1";
49497
49665
  case "yarn": return "yarn@4.13.0";
49498
49666
  case "npm": return "npm@10.9.4";
49499
49667
  case "bun": return "bun@1.3.3";
@@ -49545,7 +49713,8 @@ function buildTemplateVariables(plan) {
49545
49713
  const layoutLabel = monorepo ? "monorepo (pnpm/yarn/npm workspaces)" : "single package";
49546
49714
  const layoutDescription = monorepo ? `Monorepo for ${projectName} (\`${scopedPackageName}\`). Package sources live under \`packages/${packageName}\`.` : `Single-package repo for ${projectName} (\`${scopedPackageName}\`). Sources live under \`src/\`.`;
49547
49715
  const packageDirNote = monorepo ? ", never from inside a package directory" : "";
49548
- const copyrightYear = String((/* @__PURE__ */ new Date()).getFullYear());
49716
+ const now = /* @__PURE__ */ new Date();
49717
+ const copyrightYear = String(now.getFullYear());
49549
49718
  return {
49550
49719
  authorEmail,
49551
49720
  authorName,
@@ -49555,12 +49724,14 @@ function buildTemplateVariables(plan) {
49555
49724
  description,
49556
49725
  eslintConfigPackage,
49557
49726
  githubOrg,
49727
+ githubRef: "${{ github.ref }}",
49558
49728
  homepage,
49559
49729
  identifierName,
49560
49730
  keywordPrimary: npmScope.replace(/^@/, "") || "typescript",
49561
49731
  layoutDescription,
49562
49732
  layoutLabel,
49563
49733
  license,
49734
+ nodeVersion: latestVersions.nodeCurrent,
49564
49735
  licenseFile: licenseFileContents(license, Number(copyrightYear), authorName),
49565
49736
  npmScope,
49566
49737
  packageDirNote,
@@ -49574,6 +49745,9 @@ function buildTemplateVariables(plan) {
49574
49745
  scopedPackageName,
49575
49746
  srcPrefix,
49576
49747
  testInclude,
49748
+ today: now.toISOString().slice(0, 10),
49749
+ vitestCoverageRange: "~5.0.3",
49750
+ vitestRange: "~5.0.3",
49577
49751
  toolchainRange: bundledToolchainRange(),
49578
49752
  toolchainVersion: bundledToolchainVersion(),
49579
49753
  tsconfigPackage,
@@ -49667,11 +49841,14 @@ function mergePackageJsonRecords(rootPkg, packagePkg) {
49667
49841
  ...rootDev,
49668
49842
  ...pkgDev
49669
49843
  },
49844
+ engineStrict: rootPkg.engineStrict ?? packagePkg.engineStrict,
49845
+ packageManager: rootPkg.packageManager ?? packagePkg.packageManager,
49670
49846
  private: false,
49671
49847
  scripts: {
49672
49848
  ...rootScripts,
49673
49849
  ...pkgScripts
49674
- }
49850
+ },
49851
+ volta: rootPkg.volta ?? packagePkg.volta
49675
49852
  };
49676
49853
  }
49677
49854
  function normalizeRootPackageJson(projectDir, plan, packagePkg) {
@@ -49856,7 +50033,7 @@ const argvAfterCommand = (command) => {
49856
50033
  //#endregion
49857
50034
  //#region src/actions/skills/defaults.ts
49858
50035
  /**
49859
- Source of truth for xy-development, xy-toolchain, and ariestools-sdk.
50036
+ Source of truth for xy-development, xy-toolchain, xy-agent, and ariestools-sdk.
49860
50037
  */
49861
50038
  const ARIESTOOLS_SKILLS_SOURCE = "ariestools/ariestools-skills";
49862
50039
  /**
@@ -49865,6 +50042,7 @@ Source of truth for xyo-knowledge and xl1-* skills.
49865
50042
  const XYO_SKILLS_SOURCE = "XYOracleNetwork/xyo-skills";
49866
50043
  const ARIESTOOLS_SKILLS = [
49867
50044
  "ariestools-sdk",
50045
+ "xy-agent",
49868
50046
  "xy-development",
49869
50047
  "xy-toolchain"
49870
50048
  ];
@@ -49913,8 +50091,14 @@ const skillsDefaultsInstallPlans = (args) => {
49913
50091
  source: XYO_SKILLS_SOURCE
49914
50092
  }];
49915
50093
  };
50094
+ const SKILL_SOURCES = {
50095
+ ...Object.fromEntries(ARIESTOOLS_SKILLS.map((name) => [name, ARIESTOOLS_SKILLS_SOURCE])),
50096
+ ...Object.fromEntries(XYO_STACK_SKILLS.map((name) => [name, XYO_SKILLS_SOURCE]))
50097
+ };
49916
50098
  const skillSourceForName = (skillName) => {
49917
- return ARIESTOOLS_SKILLS.includes(skillName) ? ARIESTOOLS_SKILLS_SOURCE : XYO_SKILLS_SOURCE;
50099
+ const source = SKILL_SOURCES[skillName];
50100
+ if (source === void 0) throw new TypeError(`Unknown skill "${skillName}". Known skills: ${Object.keys(SKILL_SOURCES).join(", ")}`);
50101
+ return source;
49918
50102
  };
49919
50103
  const skillsDefaults = async (args) => {
49920
50104
  for (const plan of skillsDefaultsInstallPlans(args)) {
@@ -49934,6 +50118,7 @@ const XYO_SKILL_NAMES = [...XYO_DEFAULT_SKILLS];
49934
50118
  const SKILL_ORDER = [
49935
50119
  "xy-development",
49936
50120
  "xy-toolchain",
50121
+ "xy-agent",
49937
50122
  "ariestools-sdk",
49938
50123
  "xyo-knowledge",
49939
50124
  "xl1-knowledge",
@@ -49960,6 +50145,7 @@ const XL1_SKILLS = [
49960
50145
  "xl1-patterns",
49961
50146
  "xl1-testing"
49962
50147
  ];
50148
+ const XY_OPTIONAL_SKILLS = ["xy-agent"];
49963
50149
  const XL1_OPTIONAL_SKILLS = [
49964
50150
  "xl1-dapp-kit",
49965
50151
  "xl1-scaffold",
@@ -49992,7 +50178,7 @@ const normalizeAdditionalSkills = (value) => {
49992
50178
  if (unknown.length > 0) throw new TypeError(`Unknown skills in commands.skillsLint.additionalSkills: ${unknown.join(", ")}. Known skills: ${XYO_SKILL_NAMES.join(", ")}`);
49993
50179
  return sortSkills([...new Set(names.filter((entry) => isXyoSkillName(entry)))]);
49994
50180
  };
49995
- const PRESENCE_VALUES = /* @__PURE__ */ new Set([
50181
+ const PRESENCE_VALUES$1 = /* @__PURE__ */ new Set([
49996
50182
  "allowed",
49997
50183
  "off",
49998
50184
  "required"
@@ -50008,7 +50194,7 @@ const normalizeSkillPresence = (value) => {
50008
50194
  for (const [name, entry] of Object.entries(value)) {
50009
50195
  if (!isXyoSkillName(name)) throw new TypeError(`Unknown skill in commands.skillsLint.skills: ${name}. Known skills: ${XYO_SKILL_NAMES.join(", ")}`);
50010
50196
  const setting = (typeof entry === "object" && entry !== null ? entry : void 0)?.presence;
50011
- if (typeof setting !== "string" || !PRESENCE_VALUES.has(setting)) throw new TypeError(`commands.skillsLint.skills.${name}.presence must be "required", "allowed", or "off"`);
50197
+ if (typeof setting !== "string" || !PRESENCE_VALUES$1.has(setting)) throw new TypeError(`commands.skillsLint.skills.${name}.presence must be "required", "allowed", or "off"`);
50012
50198
  presence[name] = setting;
50013
50199
  }
50014
50200
  return presence;
@@ -50045,7 +50231,8 @@ const requiredSkillsForProfile = (profile) => {
50045
50231
  return applySkillPresence(additional.length === 0 ? withDappKit : sortSkills([.../* @__PURE__ */ new Set([...withDappKit, ...additional])]), profile.skillPresence);
50046
50232
  };
50047
50233
  const optionalSkillsForTier = (tier) => {
50048
- return tier === "xl1" ? XL1_OPTIONAL_SKILLS : [];
50234
+ if (tier === "none") return [];
50235
+ return tier === "xl1" ? sortSkills([...XY_OPTIONAL_SKILLS, ...XL1_OPTIONAL_SKILLS]) : XY_OPTIONAL_SKILLS;
50049
50236
  };
50050
50237
  const isXyoSkillName = (name) => {
50051
50238
  return XYO_SKILL_NAMES.includes(name);
@@ -50067,11 +50254,7 @@ function skillsInstallPlansForTier(tier, includeOptional) {
50067
50254
  const required = [...requiredSkillsForTier(tier)];
50068
50255
  const optional = includeOptional ? [...optionalSkillsForTier(tier)] : [];
50069
50256
  const names = [.../* @__PURE__ */ new Set([...required, ...optional])];
50070
- const ariestoolsNames = /* @__PURE__ */ new Set([
50071
- "xy-development",
50072
- "xy-toolchain",
50073
- "ariestools-sdk"
50074
- ]);
50257
+ const ariestoolsNames = new Set(ARIESTOOLS_SKILLS);
50075
50258
  const ariestools = names.filter((name) => ariestoolsNames.has(name));
50076
50259
  const xyo = names.filter((name) => !ariestoolsNames.has(name));
50077
50260
  const plans = [];
@@ -56337,8 +56520,7 @@ const ARIESTOOLS_SDK_JS_PACKAGES = /* @__PURE__ */ new Set([
56337
56520
  "@ariestools/storage-adapters",
56338
56521
  "@ariestools/telemetry",
56339
56522
  "@ariestools/testing",
56340
- "@ariestools/threads",
56341
- "@ariestools/threads-test"
56523
+ "@ariestools/threads"
56342
56524
  ]);
56343
56525
  const XY_ECOSYSTEM_SCOPES = [
56344
56526
  XYLABS_SCOPE,
@@ -56475,31 +56657,39 @@ const detectRepoProfile = (cwd) => {
56475
56657
  //#endregion
56476
56658
  //#region src/actions/skills/installed.ts
56477
56659
  const PROJECT_SKILL_DIRS = [".claude/skills", ".agents/skills"];
56478
- const VERSION_PATTERN$1 = /metadata:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+version:\s*([^\s#]+)/;
56660
+ const metadataField = (field) => new RegExp(String.raw`metadata:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+${field}:\s*['"]?([^\s#'"]+)`);
56479
56661
  const listSkillDirs = (root) => {
56480
56662
  return existsSync(root) ? readdirSync(root).filter((f) => statSync(path.resolve(root, f)).isDirectory()) : [];
56481
56663
  };
56482
- const recordInstalledSkill = (installed, relativeDir, name, version) => {
56664
+ const recordInstalledSkill = (installed, relativeDir, name, details) => {
56483
56665
  const existing = installed.get(name);
56484
56666
  if (existing == null) {
56485
56667
  installed.set(name, {
56668
+ file: details.file,
56486
56669
  locations: [relativeDir],
56487
56670
  name,
56488
- version
56671
+ status: details.status,
56672
+ version: details.version
56489
56673
  });
56490
56674
  return;
56491
56675
  }
56492
56676
  existing.locations.push(relativeDir);
56493
- if (version != null && existing.version == null) existing.version = version;
56677
+ if (details.version != null && existing.version == null) existing.version = details.version;
56678
+ if (details.status != null && existing.status == null) existing.status = details.status;
56679
+ if (details.file != null && existing.file == null) existing.file = details.file;
56494
56680
  };
56495
- const readSkillVersion = (skillDir) => {
56681
+ const readSkillMetadata = (skillDir) => {
56496
56682
  const skillMdPath = path.resolve(skillDir, "SKILL.md");
56497
- if (!existsSync(skillMdPath)) return void 0;
56683
+ if (!existsSync(skillMdPath)) return {};
56498
56684
  try {
56499
56685
  const content = readFileSync(skillMdPath, "utf8");
56500
- return VERSION_PATTERN$1.exec(content)?.[1]?.trim();
56686
+ return {
56687
+ file: skillMdPath,
56688
+ status: metadataField("status").exec(content)?.[1]?.trim(),
56689
+ version: metadataField("version").exec(content)?.[1]?.trim()
56690
+ };
56501
56691
  } catch {
56502
- return;
56692
+ return {};
56503
56693
  }
56504
56694
  };
56505
56695
  const scanInstalledSkills = (cwd, projectDirs = PROJECT_SKILL_DIRS) => {
@@ -56507,8 +56697,8 @@ const scanInstalledSkills = (cwd, projectDirs = PROJECT_SKILL_DIRS) => {
56507
56697
  for (const relativeDir of projectDirs) {
56508
56698
  const root = path.resolve(cwd, relativeDir);
56509
56699
  for (const name of listSkillDirs(root)) {
56510
- const version = readSkillVersion(path.resolve(root, name));
56511
- recordInstalledSkill(installed, relativeDir, name, version);
56700
+ const details = readSkillMetadata(path.resolve(root, name));
56701
+ recordInstalledSkill(installed, relativeDir, name, details);
56512
56702
  }
56513
56703
  }
56514
56704
  return installed;
@@ -56517,16 +56707,131 @@ const listSkillDirsAt = (root) => {
56517
56707
  return listSkillDirs(root);
56518
56708
  };
56519
56709
  //#endregion
56710
+ //#region src/actions/skills/legacyGenerated.ts
56711
+ const LEGACY_SKILL_NAMES = [
56712
+ "xylabs-e2e-setup",
56713
+ "xylabs-refactor-cohesion",
56714
+ "xylabs-xy-cli",
56715
+ "xylabs-xy-deplint-fix"
56716
+ ];
56717
+ const LEGACY_RULES = [
56718
+ "xylabs-architecture.md",
56719
+ "xylabs-build.md",
56720
+ "xylabs-dependencies.md",
56721
+ "xylabs-error-handling.md",
56722
+ "xylabs-frameworks.md",
56723
+ "xylabs-git-workflow.md",
56724
+ "xylabs-linting.md",
56725
+ "xylabs-naming.md",
56726
+ "xylabs-style.md",
56727
+ "xylabs-typescript.md"
56728
+ ];
56729
+ const LEGACY_XY_COMMANDS = [
56730
+ "xy-build.md",
56731
+ "xy-clean.md",
56732
+ "xy-compile.md",
56733
+ "xy-cycle.md",
56734
+ "xy-dead.md",
56735
+ "xy-deplint.md",
56736
+ "xy-deps.md",
56737
+ "xy-dupdeps.md",
56738
+ "xy-fix.md",
56739
+ "xy-gen-docs.md",
56740
+ "xy-gitignore.md",
56741
+ "xy-gitlint.md",
56742
+ "xy-knip.md",
56743
+ "xy-license.md",
56744
+ "xy-lint-rules.md",
56745
+ "xy-lint.md",
56746
+ "xy-publint.md",
56747
+ "xy-rebuild.md",
56748
+ "xy-recompile.md",
56749
+ "xy-reinstall.md",
56750
+ "xy-relint.md",
56751
+ "xy-retest.md",
56752
+ "xy-sonar.md",
56753
+ "xy-test.md",
56754
+ "xy-up.md"
56755
+ ];
56756
+ const LEGACY_XYLABS_COMMANDS = [
56757
+ "xylabs-build.md",
56758
+ "xylabs-clean.md",
56759
+ "xylabs-compile.md",
56760
+ "xylabs-cycle.md",
56761
+ "xylabs-deplint.md",
56762
+ "xylabs-deploy.md",
56763
+ "xylabs-deploy-major.md",
56764
+ "xylabs-deploy-minor.md",
56765
+ "xylabs-fix.md",
56766
+ "xylabs-knip.md",
56767
+ "xylabs-lint.md",
56768
+ "xylabs-publint.md",
56769
+ "xylabs-rebuild.md",
56770
+ "xylabs-test.md"
56771
+ ];
56772
+ const AUTO_MANAGED = "Auto-managed by `";
56773
+ function pushFile(found, filePath, skillName) {
56774
+ if (!existsSync(filePath)) return;
56775
+ found.push({
56776
+ file: filePath,
56777
+ skillName
56778
+ });
56779
+ }
56780
+ function scanRoot(cwd, found) {
56781
+ for (const dir of [".agents/skills", ".claude/skills"]) for (const name of LEGACY_SKILL_NAMES) pushFile(found, path.join(cwd, dir, name), name);
56782
+ const rulesDir = path.join(cwd, ".claude", "rules");
56783
+ for (const name of LEGACY_RULES) pushFile(found, path.join(rulesDir, name));
56784
+ if (existsSync(rulesDir)) for (const name of readdirSync(rulesDir)) {
56785
+ if (!name.startsWith("xylabs-") || !name.endsWith(".md") || LEGACY_RULES.includes(name)) continue;
56786
+ const filePath = path.join(rulesDir, name);
56787
+ try {
56788
+ if (readFileSync(filePath, "utf8").includes(AUTO_MANAGED)) pushFile(found, filePath);
56789
+ } catch {}
56790
+ }
56791
+ const commandsDir = path.join(cwd, ".claude", "commands");
56792
+ const commandNames = [...LEGACY_XY_COMMANDS, ...LEGACY_XYLABS_COMMANDS];
56793
+ for (const name of commandNames) pushFile(found, path.join(commandsDir, name));
56794
+ }
56795
+ function workspaceRoots(cwd) {
56796
+ const roots = [cwd];
56797
+ const packagesDir = path.join(cwd, "packages");
56798
+ if (!existsSync(packagesDir)) return roots;
56799
+ const entries = readdirSync(packagesDir, { withFileTypes: true });
56800
+ for (const entry of entries) {
56801
+ if (!entry.isDirectory()) continue;
56802
+ const root = path.join(packagesDir, entry.name);
56803
+ if (statSync(root).isDirectory()) roots.push(root);
56804
+ }
56805
+ return roots;
56806
+ }
56807
+ function findLegacyGeneratedFiles(cwd) {
56808
+ const found = [];
56809
+ const roots = workspaceRoots(cwd);
56810
+ for (const root of roots) scanRoot(root, found);
56811
+ return found;
56812
+ }
56813
+ async function removeLegacyGeneratedFile(item, removeSkill) {
56814
+ if (removeSkill !== void 0 && item.skillName !== void 0) {
56815
+ if (await removeSkill(item.skillName, path.dirname(path.dirname(path.dirname(item.file)))) === 0 && !existsSync(item.file)) return;
56816
+ }
56817
+ if (!existsSync(item.file)) return;
56818
+ if (statSync(item.file).isDirectory()) rmSync(item.file, {
56819
+ force: true,
56820
+ recursive: true
56821
+ });
56822
+ else unlinkSync(item.file);
56823
+ }
56824
+ //#endregion
56520
56825
  //#region src/actions/skills/lock.ts
56521
56826
  const SKILLS_LOCK_FILE = "skills-lock.json";
56522
56827
  const normalizeSkillSource = (source) => {
56523
56828
  return source.trim().replace(/^https?:\/\/github\.com\//i, "").replace(/^github:/i, "").replace(/\.git$/i, "").replace(/\/+$/, "").toLowerCase();
56524
56829
  };
56525
- const isRecord$3 = (value) => {
56830
+ const isRecord$4 = (value) => {
56526
56831
  return typeof value === "object" && value !== null && !Array.isArray(value);
56527
56832
  };
56528
56833
  const parseLockEntry = (value) => {
56529
- if (!isRecord$3(value) || typeof value.source !== "string" || value.source.length === 0) return void 0;
56834
+ if (!isRecord$4(value) || typeof value.source !== "string" || value.source.length === 0) return void 0;
56530
56835
  return {
56531
56836
  computedHash: typeof value.computedHash === "string" ? value.computedHash : void 0,
56532
56837
  skillPath: typeof value.skillPath === "string" ? value.skillPath : void 0,
@@ -56535,7 +56840,7 @@ const parseLockEntry = (value) => {
56535
56840
  };
56536
56841
  };
56537
56842
  const parseSkillsLock = (value) => {
56538
- if (!isRecord$3(value) || !isRecord$3(value.skills)) return void 0;
56843
+ if (!isRecord$4(value) || !isRecord$4(value.skills)) return void 0;
56539
56844
  const skills = {};
56540
56845
  for (const [name, entry] of Object.entries(value.skills)) {
56541
56846
  const parsed = parseLockEntry(entry);
@@ -56570,14 +56875,47 @@ const unmigratedSkillsFromLock = (lock) => {
56570
56875
  }
56571
56876
  return unmigrated;
56572
56877
  };
56573
- const findUnmigratedSkills = (cwd) => {
56574
- return unmigratedSkillsFromLock(readSkillsLock(cwd));
56878
+ const unmigratedSkillsFromInstalled = (installed, latestVersions) => {
56879
+ const found = [];
56880
+ for (const skill of MIGRATED_SKILLS) {
56881
+ const copy = installed.get(skill.name);
56882
+ if (copy == null) continue;
56883
+ const latest = latestVersions.get(skill.name);
56884
+ if (!(copy.version !== void 0 && latest !== void 0 && import_semver.default.valid(copy.version) !== null && import_semver.default.valid(latest) !== null && import_semver.default.gt(copy.version, latest)) && copy.status !== "redirect") continue;
56885
+ found.push({
56886
+ currentSource: copy.status === "redirect" ? "redirect stub" : copy.version ?? "unknown",
56887
+ expectedSource: skill.to,
56888
+ file: copy.file,
56889
+ name: skill.name
56890
+ });
56891
+ }
56892
+ return found;
56893
+ };
56894
+ const mergeUnmigratedSkills = (...groups) => {
56895
+ const byName = /* @__PURE__ */ new Map();
56896
+ for (const skill of groups.flat()) {
56897
+ const existing = byName.get(skill.name);
56898
+ if (existing === void 0) {
56899
+ byName.set(skill.name, skill);
56900
+ continue;
56901
+ }
56902
+ if (existing.file === void 0 && skill.file !== void 0) byName.set(skill.name, {
56903
+ ...existing,
56904
+ file: skill.file
56905
+ });
56906
+ }
56907
+ return byName.values().toArray();
56908
+ };
56909
+ const findUnmigratedSkills = (cwd, installed, latestVersions) => {
56910
+ const fromLock = unmigratedSkillsFromLock(readSkillsLock(cwd));
56911
+ const fromFiles = installed === void 0 ? [] : unmigratedSkillsFromInstalled(installed, latestVersions ?? /* @__PURE__ */ new Map());
56912
+ return mergeUnmigratedSkills(fromLock, fromFiles);
56575
56913
  };
56576
56914
  //#endregion
56577
56915
  //#region src/actions/skills/packageSkills.ts
56578
56916
  const SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
56579
56917
  const MAX_SKILL_NAME_LENGTH = 64;
56580
- const isRecord$2 = (value) => {
56918
+ const isRecord$3 = (value) => {
56581
56919
  return typeof value === "object" && value !== null && !Array.isArray(value);
56582
56920
  };
56583
56921
  const isSkillName = (name) => {
@@ -56591,7 +56929,7 @@ const readManifest = (filePath) => {
56591
56929
  if (!existsSync(filePath)) return void 0;
56592
56930
  try {
56593
56931
  const value = JSON.parse(readFileSync(filePath, "utf8"));
56594
- return isRecord$2(value) ? value : void 0;
56932
+ return isRecord$3(value) ? value : void 0;
56595
56933
  } catch {
56596
56934
  return;
56597
56935
  }
@@ -56610,7 +56948,7 @@ const findInstalledPackageJson = (fromDir, depName) => {
56610
56948
  }
56611
56949
  };
56612
56950
  const parseSkillEntry = (packageName, file, index, value) => {
56613
- if (!isRecord$2(value) || typeof value.name !== "string" || !isSkillName(value.name)) return { problem: {
56951
+ if (!isRecord$3(value) || typeof value.name !== "string" || !isSkillName(value.name)) return { problem: {
56614
56952
  file,
56615
56953
  message: `${packageName} — xy.skills[${index}] must be an object with a skill name`
56616
56954
  } };
@@ -56651,7 +56989,7 @@ const parsePackageSkills = (packageName, file, manifest) => {
56651
56989
  problems: []
56652
56990
  };
56653
56991
  const xy = manifest.xy;
56654
- if (!isRecord$2(xy) || !Object.hasOwn(xy, "skills")) return {
56992
+ if (!isRecord$3(xy) || !Object.hasOwn(xy, "skills")) return {
56655
56993
  entries: [],
56656
56994
  problems: []
56657
56995
  };
@@ -56837,7 +57175,7 @@ const missingSkillReason = (profile, skillName) => {
56837
57175
  if (skillName === "xy-toolchain" && profile.isUsingToolchain) return "repo uses @ariestools/toolchain";
56838
57176
  return profile.additionalSkills?.includes(skillName) === true ? "listed in commands.skillsLint.additionalSkills" : "required for repo profile";
56839
57177
  };
56840
- const checkRequiredSkills = (required, installed, latestVersions) => {
57178
+ const checkRequiredSkills = (required, installed, latestVersions, unmigratedNames = /* @__PURE__ */ new Set()) => {
56841
57179
  const current = [];
56842
57180
  const missing = [];
56843
57181
  const outdated = [];
@@ -56857,6 +57195,7 @@ const checkRequiredSkills = (required, installed, latestVersions) => {
56857
57195
  });
56858
57196
  continue;
56859
57197
  }
57198
+ if (unmigratedNames.has(skillName)) continue;
56860
57199
  current.push({
56861
57200
  name: skillName,
56862
57201
  version: installedVersion
@@ -56993,7 +57332,7 @@ const SKILLS_LINT_RULES = [
56993
57332
  if (await installSkills(unmigrated.map((skill) => ({ name: skill.name })), installSkill, "Migrating skills to canonical sources...", "Migrated skills reinstalled from ariestools/ariestools-skills. Re-run `xy skills lint` to verify versions.") === 0) return { fixedCount: unmigrated.length };
56994
57333
  }
56995
57334
  return { diagnostics: unmigrated.map((skill) => ({
56996
- file: SKILLS_LOCK_FILE,
57335
+ file: skill.file ?? "skills-lock.json",
56997
57336
  message: `${skill.name} — installed from ${skill.currentSource}; migrate to ${skill.expectedSource}`,
56998
57337
  rule: "skills.migrated-source"
56999
57338
  })) };
@@ -57006,7 +57345,7 @@ const SKILLS_LINT_RULES = [
57006
57345
  {
57007
57346
  check: ({ unnecessary }) => ({ diagnostics: skillDiagnostics("skills.unnecessary", unnecessary.map((skillName) => `${skillName} — installed but not required for this repo profile`)) }),
57008
57347
  defaultLevel: "warn",
57009
- description: "Installed skills are required or optional for the detected repo profile (extend via commands.skillsLint.additionalSkills)",
57348
+ description: "Installed skills are required, optional, or allowed (commands.skillsLint.skills presence, or commands.skillsLint.additionalSkills)",
57010
57349
  id: "skills.unnecessary"
57011
57350
  },
57012
57351
  {
@@ -57014,6 +57353,25 @@ const SKILLS_LINT_RULES = [
57014
57353
  defaultLevel: "warn",
57015
57354
  description: "Project-local skills are not duplicated globally",
57016
57355
  id: "skills.duplicate-install"
57356
+ },
57357
+ {
57358
+ check: async ({ cwd, removeSkill }, { fix }) => {
57359
+ const found = findLegacyGeneratedFiles(cwd);
57360
+ if (found.length === 0) return {};
57361
+ if (fix) {
57362
+ for (const item of found) await removeLegacyGeneratedFile(item, removeSkill);
57363
+ return { fixedCount: found.length };
57364
+ }
57365
+ return { diagnostics: found.map((item) => ({
57366
+ file: item.file,
57367
+ message: `${path.basename(item.file)} — retired output of \`xy claude\` (removed in 8.2.8); delete it`,
57368
+ rule: "skills.legacy-generated"
57369
+ })) };
57370
+ },
57371
+ defaultLevel: "warn",
57372
+ description: "Retired xy claude skills, rules, and commands are absent",
57373
+ fixable: true,
57374
+ id: "skills.legacy-generated"
57017
57375
  }
57018
57376
  ];
57019
57377
  function logSkillsDiagnostic(diagnostic) {
@@ -57056,7 +57414,7 @@ const skillsLint = async (options = {}) => {
57056
57414
  const cwd = options.cwd ?? INIT_CWD();
57057
57415
  const projectDirs = options.projectDirs ?? [...PROJECT_SKILL_DIRS];
57058
57416
  const globalDir = options.globalDir ?? DEFAULT_GLOBAL_DIR;
57059
- const isStrict = options.isStrict === true || options.strict === true;
57417
+ const isStrict = options.isStrict === true || options.strict === true || isStrictMode();
57060
57418
  const config = await loadWorkspaceCommandConfig(cwd, "skillsLint");
57061
57419
  const profile = {
57062
57420
  ...detectRepoProfile(cwd),
@@ -57070,18 +57428,17 @@ const skillsLint = async (options = {}) => {
57070
57428
  const installed = scanInstalledSkills(cwd, projectDirs);
57071
57429
  logProfileHeader(profile);
57072
57430
  const latestVersions = await resolveLatestSkillVersions(collectSkillNamesToCheck(required, installed), options);
57073
- const requiredCheck = checkRequiredSkills(required, installed, latestVersions);
57431
+ const unmigrated = findUnmigratedSkills(cwd, installed, latestVersions);
57432
+ const requiredCheck = checkRequiredSkills(required, installed, latestVersions, new Set(unmigrated.map((skill) => skill.name)));
57074
57433
  logCurrentRequiredSkills(requiredCheck);
57075
57434
  const unnecessary = collectUnnecessarySkills(profile, installed).filter((name) => !recommendedNames.has(name));
57076
- const duplicates = findDuplicateSkills(cwd, globalDir);
57077
- const unmigrated = findUnmigratedSkills(cwd);
57078
57435
  return reportSkillsLintResult(await runRuleChecks({
57079
57436
  commandName: "skills lint",
57080
57437
  configKey: "skillsLint",
57081
57438
  config,
57082
57439
  context: {
57083
57440
  cwd,
57084
- duplicates,
57441
+ duplicates: findDuplicateSkills(cwd, globalDir),
57085
57442
  globalDir,
57086
57443
  installSkill: installSkillOnce(options.installSkill ?? createSkillInstaller(cwd)),
57087
57444
  installed,
@@ -57089,6 +57446,7 @@ const skillsLint = async (options = {}) => {
57089
57446
  outdated: requiredCheck.outdated,
57090
57447
  packageSkills,
57091
57448
  profile,
57449
+ removeSkill: options.removeSkill,
57092
57450
  unmigrated,
57093
57451
  unnecessary
57094
57452
  },
@@ -57159,7 +57517,7 @@ const defaultWorkConfig = () => ({
57159
57517
  },
57160
57518
  version: 1
57161
57519
  });
57162
- const isRecord$1 = (value) => {
57520
+ const isRecord$2 = (value) => {
57163
57521
  return typeof value === "object" && value !== null && !Array.isArray(value);
57164
57522
  };
57165
57523
  const isStringArray = (value) => {
@@ -57185,7 +57543,7 @@ const parseStringArray = (value, label) => {
57185
57543
  return value;
57186
57544
  };
57187
57545
  const parseRecord = (value, label) => {
57188
- if (!isRecord$1(value)) throw new TypeError(`${label} must be an object`);
57546
+ if (!isRecord$2(value)) throw new TypeError(`${label} must be an object`);
57189
57547
  return value;
57190
57548
  };
57191
57549
  const isWorkType = (value) => {
@@ -57411,7 +57769,7 @@ HTML comment marker embedded in issue bodies so we can recognize our issues.
57411
57769
  */
57412
57770
  const XY_WORK_GITHUB_BODY_MARKER_PREFIX = "<!-- xy-work:";
57413
57771
  const defaultGithubWorkRunner = defaultGithubRunner;
57414
- const isRecord = (value) => {
57772
+ const isRecord$1 = (value) => {
57415
57773
  return typeof value === "object" && value !== null && !Array.isArray(value);
57416
57774
  };
57417
57775
  const runOrThrow = githubRunOrThrow;
@@ -57443,12 +57801,12 @@ const githubIssueIsOpen = (issue) => {
57443
57801
  };
57444
57802
  const readGithubStoreNumber = (stores) => {
57445
57803
  const value = stores.github;
57446
- if (!isRecord(value)) return void 0;
57804
+ if (!isRecord$1(value)) return void 0;
57447
57805
  return typeof value.number !== "number" || !Number.isSafeInteger(value.number) || value.number < 1 ? void 0 : value.number;
57448
57806
  };
57449
57807
  const readGithubStoreUrl = (stores) => {
57450
57808
  const value = stores.github;
57451
- return !isRecord(value) || typeof value.url !== "string" || value.url.length === 0 ? void 0 : value.url;
57809
+ return !isRecord$1(value) || typeof value.url !== "string" || value.url.length === 0 ? void 0 : value.url;
57452
57810
  };
57453
57811
  const formatGithubWorkIssueBody = (item) => {
57454
57812
  const sections = [];
@@ -57469,6 +57827,22 @@ const formatGithubWorkIssueBody = (item) => {
57469
57827
  ].join("\n"));
57470
57828
  return sections.join("\n\n");
57471
57829
  };
57830
+ const normalizeGithubIssueBody = (body) => body.replaceAll("\r\n", "\n").trim();
57831
+ /**
57832
+ Compare issue bodies, ignoring the CRLF line endings and surrounding whitespace GitHub can add.
57833
+ */
57834
+ const githubIssueBodiesMatch = (a, b) => {
57835
+ return normalizeGithubIssueBody(a) === normalizeGithubIssueBody(b);
57836
+ };
57837
+ const XY_WORK_GENERATED_SECTION_PATTERN = /(?:^|\n)(?:## xy work metadata\b|(?:---[ \t]*\r?\n)?[ \t]*<!--\s*xy-work:)/i;
57838
+ /**
57839
+ Drop the sections `formatGithubWorkIssueBody` generates (metadata, marker, footer) so an imported
57840
+ xy-work issue body can be rendered again without repeating them.
57841
+ */
57842
+ const stripXyWorkGeneratedBody = (body) => {
57843
+ const match = XY_WORK_GENERATED_SECTION_PATTERN.exec(body);
57844
+ return (match === null ? body : body.slice(0, match.index)).trim();
57845
+ };
57472
57846
  const TYPE_LABEL_MAP = [
57473
57847
  ["bug", "bug"],
57474
57848
  ["type:bug", "bug"],
@@ -57533,7 +57907,7 @@ const ensureXyWorkLabel = (runner, cwd) => {
57533
57907
  ], { cwd });
57534
57908
  if (list.status === 0) try {
57535
57909
  const labels = JSON.parse(list.stdout);
57536
- if (Array.isArray(labels) && labels.some((entry) => isRecord(entry) && entry.name === "xy-work")) return;
57910
+ if (Array.isArray(labels) && labels.some((entry) => isRecord$1(entry) && entry.name === "xy-work")) return;
57537
57911
  } catch {}
57538
57912
  runner([
57539
57913
  "label",
@@ -57550,11 +57924,11 @@ const parseIssueList = (stdout) => {
57550
57924
  const parsed = JSON.parse(stdout);
57551
57925
  if (!Array.isArray(parsed)) throw new TypeError("gh issue list returned non-array JSON");
57552
57926
  return parsed.map((entry) => {
57553
- if (!isRecord(entry)) throw new TypeError("gh issue list entry must be an object");
57927
+ if (!isRecord$1(entry)) throw new TypeError("gh issue list entry must be an object");
57554
57928
  const labelsRaw = entry.labels;
57555
57929
  const labels = Array.isArray(labelsRaw) ? labelsRaw.map((label) => {
57556
57930
  if (typeof label === "string") return label;
57557
- return isRecord(label) && typeof label.name === "string" ? label.name : "";
57931
+ return isRecord$1(label) && typeof label.name === "string" ? label.name : "";
57558
57932
  }).filter((label) => label.length > 0) : [];
57559
57933
  return {
57560
57934
  body: typeof entry.body === "string" ? entry.body : "",
@@ -57659,6 +58033,20 @@ const isTerminalWorkStatus = (status) => {
57659
58033
  return status === "done" || status === "wontfix";
57660
58034
  };
57661
58035
  /**
58036
+ Sync may edit a linked issue only when its body marker names this item and the stored URL matches.
58037
+ */
58038
+ const githubIssueBelongsToItem = (item, issue) => {
58039
+ const storedUrl = readGithubStoreUrl(item.stores);
58040
+ return parseXyWorkIdFromGithubBody(issue.body) === item.id && (storedUrl === void 0 || storedUrl === issue.url);
58041
+ };
58042
+ /**
58043
+ The body of an issue xy work owns is rendered from the local item and cannot be imported back,
58044
+ so any difference counts as drift and sync pushes the local rendering.
58045
+ */
58046
+ const githubBodyDrifted = (item, issue) => {
58047
+ return githubIssueBelongsToItem(item, issue) && !githubIssueBodiesMatch(formatGithubWorkIssueBody(item), issue.body);
58048
+ };
58049
+ /**
57662
58050
  * Normalize open GitHub issues that were not created by `xy work` into WorkItem shape.
57663
58051
  * Issues already linked from local items (or marked with the xy-work label/marker) are skipped.
57664
58052
  */
@@ -57696,6 +58084,7 @@ const importGithubIssueLocally = (cwd, issue, now, preferredId) => {
57696
58084
  const item = {
57697
58085
  ...base,
57698
58086
  completedAt: open ? void 0 : base.updatedAt || nowIso(now),
58087
+ description: createdByXyWork ? stripXyWorkGeneratedBody(base.description) : base.description,
57699
58088
  id,
57700
58089
  status: open ? "open" : "done",
57701
58090
  stores: { github: {
@@ -57772,26 +58161,33 @@ const attachOrImportGithubIssues = (cwd, issuesByNumber, summary, now) => {
57772
58161
  }
57773
58162
  }
57774
58163
  };
57775
- const reconcileTitleDrift = (cwd, github, item, issue, number, summary, canMutateGithub = true, now) => {
57776
- if (item.title === issue.title) return {
58164
+ /**
58165
+ Title: newer side wins. Body: the local rendering always wins on issues the item owns.
58166
+ */
58167
+ const reconcileContentDrift = (cwd, github, item, issue, number, summary, canMutateGithub = true, now) => {
58168
+ const titleDrifted = item.title !== issue.title;
58169
+ const bodyDrifted = githubBodyDrifted(item, issue);
58170
+ if (!titleDrifted && !bodyDrifted) return {
58171
+ localChanged: false,
58172
+ next: item
58173
+ };
58174
+ const localIsNewer = item.updatedAt.localeCompare(issue.updatedAt) >= 0;
58175
+ const pushTitle = titleDrifted && localIsNewer && canMutateGithub;
58176
+ if (pushTitle || bodyDrifted) {
58177
+ const body = formatGithubWorkIssueBody(item);
58178
+ github.updateIssue(cwd, number, pushTitle ? {
58179
+ body,
58180
+ title: item.title
58181
+ } : { body });
58182
+ summary.updatedGithub.push(`${item.id}→#${String(number)}`);
58183
+ issue.body = body;
58184
+ if (pushTitle) issue.title = item.title;
58185
+ issue.updatedAt = nowIso(now);
58186
+ }
58187
+ if (!titleDrifted || localIsNewer) return {
57777
58188
  localChanged: false,
57778
58189
  next: item
57779
58190
  };
57780
- if (item.updatedAt.localeCompare(issue.updatedAt) >= 0) {
57781
- if (canMutateGithub) {
57782
- github.updateIssue(cwd, number, {
57783
- body: formatGithubWorkIssueBody(item),
57784
- title: item.title
57785
- });
57786
- summary.updatedGithub.push(`${item.id}→#${String(number)}`);
57787
- issue.title = item.title;
57788
- issue.updatedAt = nowIso(now);
57789
- }
57790
- return {
57791
- localChanged: false,
57792
- next: item
57793
- };
57794
- }
57795
58191
  return {
57796
58192
  localChanged: true,
57797
58193
  next: {
@@ -57819,15 +58215,16 @@ const reconcileLinkedItem = (cwd, github, item, issue, number, summary, now) =>
57819
58215
  let localChanged = false;
57820
58216
  const issueOpen = githubIssueIsOpen(issue);
57821
58217
  const localTerminal = isTerminalWorkStatus(item.status);
57822
- const markerId = parseXyWorkIdFromGithubBody(issue.body);
57823
- const storedUrl = readGithubStoreUrl(item.stores);
57824
- const canMutateGithub = markerId === item.id && (storedUrl === void 0 || storedUrl === issue.url);
58218
+ const canMutateGithub = githubIssueBelongsToItem(item, issue);
57825
58219
  if (localTerminal && issueOpen) {
57826
58220
  if (canMutateGithub) {
57827
58221
  github.updateIssue(cwd, number, { state: "closed" });
57828
58222
  summary.closedGithub.push(`${item.id}→#${String(number)}`);
57829
58223
  issue.state = "CLOSED";
57830
- } else xyLog(`Sync reconcile skipped closing GitHub #${String(number)}: body marker (${markerId ?? "none"}) does not match ${item.id} or URL mismatch`);
58224
+ } else {
58225
+ const markerId = parseXyWorkIdFromGithubBody(issue.body);
58226
+ xyLog(`Sync reconcile skipped closing GitHub #${String(number)}: body marker (${markerId ?? "none"}) does not match ${item.id} or URL mismatch`);
58227
+ }
57831
58228
  } else if (!localTerminal && !issueOpen) {
57832
58229
  next = {
57833
58230
  ...next,
@@ -57838,9 +58235,9 @@ const reconcileLinkedItem = (cwd, github, item, issue, number, summary, now) =>
57838
58235
  };
57839
58236
  localChanged = true;
57840
58237
  } else if (!localTerminal && issueOpen) {
57841
- const titleResult = reconcileTitleDrift(cwd, github, next, issue, number, summary, canMutateGithub, now);
57842
- next = titleResult.next;
57843
- localChanged ||= titleResult.localChanged;
58238
+ const contentResult = reconcileContentDrift(cwd, github, next, issue, number, summary, canMutateGithub, now);
58239
+ next = contentResult.next;
58240
+ localChanged ||= contentResult.localChanged;
57844
58241
  }
57845
58242
  const urlResult = ensureGithubStoreUrl(next, issue, number);
57846
58243
  next = urlResult.next;
@@ -57878,13 +58275,14 @@ const logSyncSummary = (summary) => {
57878
58275
  ].join("\n"));
57879
58276
  };
57880
58277
  const emptyWorkSyncDrift = () => ({
58278
+ bodyMismatch: [],
57881
58279
  githubMissingLocal: [],
57882
58280
  localMissingGithub: [],
57883
58281
  statusMismatch: [],
57884
58282
  titleMismatch: []
57885
58283
  });
57886
58284
  const workSyncDriftIsClean = (drift) => {
57887
- return drift.githubMissingLocal.length === 0 && drift.localMissingGithub.length === 0 && drift.statusMismatch.length === 0 && drift.titleMismatch.length === 0;
58285
+ return drift.bodyMismatch.length === 0 && drift.githubMissingLocal.length === 0 && drift.localMissingGithub.length === 0 && drift.statusMismatch.length === 0 && drift.titleMismatch.length === 0;
57888
58286
  };
57889
58287
  const recordLocalMissingGithub = (localItems, drift) => {
57890
58288
  for (const item of localItems) {
@@ -57900,7 +58298,11 @@ const recordLinkedPairDrift = (issue, linked, drift) => {
57900
58298
  drift.statusMismatch.push(`${linked.id} done/wontfix but GitHub #${String(issue.number)} open`);
57901
58299
  return;
57902
58300
  }
57903
- if (!localTerminal && !issueOpen) drift.statusMismatch.push(`${linked.id} open locally but GitHub #${String(issue.number)} closed`);
58301
+ if (!localTerminal && !issueOpen) {
58302
+ drift.statusMismatch.push(`${linked.id} open locally but GitHub #${String(issue.number)} closed`);
58303
+ return;
58304
+ }
58305
+ if (!localTerminal && githubBodyDrifted(linked, issue)) drift.bodyMismatch.push(`${linked.id}/#${String(issue.number)}`);
57904
58306
  };
57905
58307
  const recordUnlinkedXyWorkDrift = (issue, localById, drift) => {
57906
58308
  if (!isXyWorkGithubIssue(issue)) return;
@@ -57945,7 +58347,7 @@ const computeWorkSyncDrift = (cwd, options = {}) => {
57945
58347
  *
57946
58348
  * - Local active items without a GitHub link → create a marked GitHub issue
57947
58349
  * - Open/closed GitHub issues not present locally → import as local items
57948
- * - Linked pairs: reconcile title (newer wins) and status (done/wontfix ↔ closed)
58350
+ * - Linked pairs: reconcile title (newer wins), body of xy-work issues (local wins), and status (done/wontfix ↔ closed)
57949
58351
  */
57950
58352
  const workSync = (options = {}) => {
57951
58353
  const cwd = options.cwd ?? process.cwd();
@@ -57992,14 +58394,18 @@ const compareWorkItemsByPriority = (a, b, formula = DEFAULT_PRIORITY_FORMULA) =>
57992
58394
  if (aScore !== void 0 && bScore === void 0) return -1;
57993
58395
  return aScore === void 0 && bScore !== void 0 ? 1 : a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id);
57994
58396
  };
57995
- const priorityFromPartial = (partial) => {
58397
+ /**
58398
+ Build a priority from the fields given. Fields left out keep their value from `base` (the stored
58399
+ priority on update), or default to 3 when there is no base.
58400
+ */
58401
+ const priorityFromPartial = (partial, base) => {
57996
58402
  if (Object.values(partial).every((value) => value === void 0)) return void 0;
57997
58403
  return {
57998
- confidence: partial.confidence ?? 3,
57999
- effort: partial.effort ?? 3,
58000
- impact: partial.impact ?? 3,
58001
- risk: partial.risk ?? 3,
58002
- urgency: partial.urgency ?? 3
58404
+ confidence: partial.confidence ?? base?.confidence ?? 3,
58405
+ effort: partial.effort ?? base?.effort ?? 3,
58406
+ impact: partial.impact ?? base?.impact ?? 3,
58407
+ risk: partial.risk ?? base?.risk ?? 3,
58408
+ urgency: partial.urgency ?? base?.urgency ?? 3
58003
58409
  };
58004
58410
  };
58005
58411
  //#endregion
@@ -58216,6 +58622,7 @@ const buildRepoContext = (repo, github) => {
58216
58622
  for (const id of drift.localMissingGithub) driftMessages.push(`${id} — active local item missing GitHub link`);
58217
58623
  for (const entry of drift.githubMissingLocal) driftMessages.push(`${entry} — GitHub issue missing local item`);
58218
58624
  for (const entry of drift.titleMismatch) driftMessages.push(`${entry} — title mismatch`);
58625
+ for (const entry of drift.bodyMismatch) driftMessages.push(`${entry} — body mismatch`);
58219
58626
  for (const entry of drift.statusMismatch) driftMessages.push(entry);
58220
58627
  }
58221
58628
  } catch (error) {
@@ -58723,6 +59130,263 @@ const sitemap = () => {
58723
59130
  return runSteps("Sitemap", [["ts-node-script", "./scripts/sitemap.ts"]]);
58724
59131
  };
58725
59132
  //#endregion
59133
+ //#region src/actions/skills/editXyConfigSkillPresence.ts
59134
+ function isJsonConfig(filePath) {
59135
+ const base = path.basename(filePath);
59136
+ return base === ".xyrc" || base.endsWith(".json");
59137
+ }
59138
+ const PRESENCE_VALUES = /* @__PURE__ */ new Set([
59139
+ "allowed",
59140
+ "off",
59141
+ "required"
59142
+ ]);
59143
+ function isSkillPresence(value) {
59144
+ return PRESENCE_VALUES.has(value);
59145
+ }
59146
+ function isRecord(value) {
59147
+ return typeof value === "object" && value !== null && !Array.isArray(value);
59148
+ }
59149
+ function getPropertyName(prop) {
59150
+ if (ts.isPropertyAssignment(prop)) {
59151
+ const { name } = prop;
59152
+ if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNoSubstitutionTemplateLiteral(name)) return name.text;
59153
+ }
59154
+ return ts.isShorthandPropertyAssignment(prop) ? prop.name.text : void 0;
59155
+ }
59156
+ function findConfigObject(sourceFile) {
59157
+ for (const statement of sourceFile.statements) {
59158
+ if (ts.isExportAssignment(statement) && statement.isExportEquals !== true && ts.isObjectLiteralExpression(statement.expression)) return statement.expression;
59159
+ if (!ts.isVariableStatement(statement)) continue;
59160
+ for (const decl of statement.declarationList.declarations) if (decl.initializer && ts.isObjectLiteralExpression(decl.initializer) && ts.isIdentifier(decl.name) && decl.name.text === "config") return decl.initializer;
59161
+ }
59162
+ for (const statement of sourceFile.statements) {
59163
+ if (!ts.isVariableStatement(statement)) continue;
59164
+ for (const decl of statement.declarationList.declarations) if (decl.initializer && ts.isObjectLiteralExpression(decl.initializer)) return decl.initializer;
59165
+ }
59166
+ }
59167
+ function objectProperty(object, name) {
59168
+ for (const prop of object.properties) if (ts.isPropertyAssignment(prop) && getPropertyName(prop) === name) return prop;
59169
+ }
59170
+ function objectLiteral(prop) {
59171
+ return prop !== void 0 && ts.isObjectLiteralExpression(prop.initializer) ? prop.initializer : void 0;
59172
+ }
59173
+ function quoteKey(name) {
59174
+ return /^[A-Za-z_$][\w$]*$/.test(name) ? name : `'${name.replaceAll("\\", "\\\\").replaceAll("'", String.raw`\'`)}'`;
59175
+ }
59176
+ function detectIndent(text, object, sourceFile) {
59177
+ if (object.properties.length > 0) {
59178
+ const start = object.properties[0].getStart(sourceFile);
59179
+ let lineStart = start;
59180
+ while (lineStart > 0 && text[lineStart - 1] !== "\n" && text[lineStart - 1] !== "\r") lineStart -= 1;
59181
+ const indent = /^[ \t]*/.exec(text.slice(lineStart, start))?.[0];
59182
+ if (indent !== void 0 && indent.length > 0) return indent;
59183
+ }
59184
+ const braceStart = object.getStart(sourceFile);
59185
+ let lineStart = braceStart;
59186
+ while (lineStart > 0 && text[lineStart - 1] !== "\n" && text[lineStart - 1] !== "\r") lineStart -= 1;
59187
+ return `${/^[ \t]*/.exec(text.slice(lineStart, braceStart))?.[0] ?? ""} `;
59188
+ }
59189
+ function upsertSkillKey(text, skillsObject, sourceFile, name, presence) {
59190
+ const existing = objectProperty(skillsObject, name);
59191
+ const valueText = `{ presence: '${presence}' }`;
59192
+ if (existing !== void 0) {
59193
+ const valueStart = existing.initializer.getStart(sourceFile);
59194
+ const valueEnd = existing.initializer.getEnd();
59195
+ return `${text.slice(0, valueStart)}${valueText}${text.slice(valueEnd)}`;
59196
+ }
59197
+ const indent = detectIndent(text, skillsObject, sourceFile);
59198
+ const open = skillsObject.getStart(sourceFile) + 1;
59199
+ return `${text.slice(0, open)}\n${indent}${quoteKey(name)}: ${valueText},${text.slice(open)}`;
59200
+ }
59201
+ function insertBlock(text, object, sourceFile, block) {
59202
+ const indent = detectIndent(text, object, sourceFile);
59203
+ const open = object.getStart(sourceFile) + 1;
59204
+ return `${text.slice(0, open)}\n${indent}${block},${text.slice(open)}`;
59205
+ }
59206
+ function nestedSkillsObject(configObject) {
59207
+ const commands = objectLiteral(objectProperty(configObject, "commands"));
59208
+ if (commands === void 0) return void 0;
59209
+ const skillsLint = objectLiteral(objectProperty(commands, "skillsLint"));
59210
+ return skillsLint === void 0 ? void 0 : objectLiteral(objectProperty(skillsLint, "skills"));
59211
+ }
59212
+ function applyPresenceToSource(text, presence, scriptKind) {
59213
+ let result = text;
59214
+ for (const [name, setting] of Object.entries(presence)) {
59215
+ const sourceFile = ts.createSourceFile("xy.config.ts", result, ts.ScriptTarget.Latest, true, scriptKind);
59216
+ const configObject = findConfigObject(sourceFile);
59217
+ if (configObject === void 0) return void 0;
59218
+ const skills = nestedSkillsObject(configObject);
59219
+ if (skills !== void 0) {
59220
+ result = upsertSkillKey(result, skills, sourceFile, name, setting);
59221
+ continue;
59222
+ }
59223
+ const commands = objectLiteral(objectProperty(configObject, "commands"));
59224
+ const skillsLint = commands === void 0 ? void 0 : objectLiteral(objectProperty(commands, "skillsLint"));
59225
+ const indent = detectIndent(result, skillsLint ?? commands ?? configObject, sourceFile);
59226
+ if (skillsLint !== void 0) {
59227
+ result = insertBlock(result, skillsLint, sourceFile, `skills: {\n${indent} ${quoteKey(name)}: { presence: '${setting}' },\n${indent}}`);
59228
+ continue;
59229
+ }
59230
+ if (commands !== void 0) {
59231
+ const block = [
59232
+ "skillsLint: {",
59233
+ `${indent} skills: {`,
59234
+ `${indent} ${quoteKey(name)}: { presence: '${setting}' },`,
59235
+ `${indent} },`,
59236
+ `${indent}}`
59237
+ ].join("\n");
59238
+ result = insertBlock(result, commands, sourceFile, block);
59239
+ continue;
59240
+ }
59241
+ const block = [
59242
+ "commands: {",
59243
+ `${indent} skillsLint: {`,
59244
+ `${indent} skills: {`,
59245
+ `${indent} ${quoteKey(name)}: { presence: '${setting}' },`,
59246
+ `${indent} },`,
59247
+ `${indent} },`,
59248
+ `${indent}}`
59249
+ ].join("\n");
59250
+ result = insertBlock(result, configObject, sourceFile, block);
59251
+ }
59252
+ return result;
59253
+ }
59254
+ function readPresenceFromSource(text, scriptKind) {
59255
+ const sourceFile = ts.createSourceFile("xy.config.ts", text, ts.ScriptTarget.Latest, true, scriptKind);
59256
+ const skills = (() => {
59257
+ const configObject = findConfigObject(sourceFile);
59258
+ return configObject === void 0 ? void 0 : nestedSkillsObject(configObject);
59259
+ })();
59260
+ if (skills === void 0) return {};
59261
+ const presence = {};
59262
+ for (const prop of skills.properties) {
59263
+ if (!ts.isPropertyAssignment(prop) || !ts.isObjectLiteralExpression(prop.initializer)) continue;
59264
+ const name = getPropertyName(prop);
59265
+ const setting = objectProperty(prop.initializer, "presence");
59266
+ if (name === void 0 || setting === void 0) continue;
59267
+ if (!ts.isStringLiteral(setting.initializer) && !ts.isNoSubstitutionTemplateLiteral(setting.initializer)) continue;
59268
+ const value = setting.initializer.text;
59269
+ if (isSkillPresence(value)) presence[name] = value;
59270
+ }
59271
+ return presence;
59272
+ }
59273
+ function skillsObjectFromJson(root, create) {
59274
+ if (!isRecord(root.commands)) {
59275
+ if (!create) return void 0;
59276
+ root.commands = {};
59277
+ }
59278
+ const commands = root.commands;
59279
+ if (!isRecord(commands.skillsLint)) {
59280
+ if (!create) return void 0;
59281
+ commands.skillsLint = {};
59282
+ }
59283
+ const skillsLint = commands.skillsLint;
59284
+ if (!isRecord(skillsLint.skills)) {
59285
+ if (!create) return void 0;
59286
+ skillsLint.skills = {};
59287
+ }
59288
+ return skillsLint.skills;
59289
+ }
59290
+ function readPresenceFromJson(text) {
59291
+ const skills = skillsObjectFromJson(JSON.parse(text), false);
59292
+ if (skills === void 0) return {};
59293
+ const presence = {};
59294
+ for (const [name, value] of Object.entries(skills)) {
59295
+ if (!isRecord(value) || typeof value.presence !== "string") continue;
59296
+ if (typeof value.presence === "string" && isSkillPresence(value.presence)) presence[name] = value.presence;
59297
+ }
59298
+ return presence;
59299
+ }
59300
+ function applyPresenceToJson(text, presence) {
59301
+ const root = JSON.parse(text);
59302
+ const skills = skillsObjectFromJson(root, true);
59303
+ if (skills === void 0) return text;
59304
+ for (const [name, setting] of Object.entries(presence)) {
59305
+ const existing = skills[name];
59306
+ if (isRecord(existing)) existing.presence = setting;
59307
+ else skills[name] = { presence: setting };
59308
+ }
59309
+ return `${JSON.stringify(root, null, 2)}\n`;
59310
+ }
59311
+ function skillPresenceSnippet(presence) {
59312
+ return [
59313
+ "commands: {",
59314
+ " skillsLint: {",
59315
+ " skills: {",
59316
+ ...Object.entries(presence).map(([name, setting]) => ` '${name}': { presence: '${setting}' },`),
59317
+ " },",
59318
+ " },",
59319
+ "},"
59320
+ ].join("\n");
59321
+ }
59322
+ function readSkillPresenceFile(cwd) {
59323
+ const filePath = findXyConfigFile(cwd);
59324
+ if (filePath === void 0) return {};
59325
+ const text = fs.readFileSync(filePath, "utf8");
59326
+ if (isJsonConfig(filePath)) try {
59327
+ return readPresenceFromJson(text);
59328
+ } catch {
59329
+ return {};
59330
+ }
59331
+ return readPresenceFromSource(text, ts.ScriptKind.TS);
59332
+ }
59333
+ function minimalConfig(presence) {
59334
+ return [
59335
+ "import type { XyConfig } from '@ariestools/toolchain'",
59336
+ "",
59337
+ "const config: XyConfig = {",
59338
+ " commands: {",
59339
+ " skillsLint: {",
59340
+ " skills: {",
59341
+ ...Object.entries(presence).map(([name, setting]) => ` '${name}': { presence: '${setting}' },`),
59342
+ " },",
59343
+ " },",
59344
+ " },",
59345
+ "}",
59346
+ "",
59347
+ "export default config",
59348
+ ""
59349
+ ].join("\n");
59350
+ }
59351
+ /**
59352
+ * Merge skill presence into the workspace xy config.
59353
+ * An existing file that has no config object is left unchanged.
59354
+ */
59355
+ function writeSkillPresenceFile(cwd, presence) {
59356
+ const snippet = skillPresenceSnippet(presence);
59357
+ const filePath = findXyConfigFile(cwd) ?? path.join(cwd, XY_CONFIG_FILE_NAMES[0]);
59358
+ if (!fs.existsSync(filePath)) {
59359
+ fs.writeFileSync(filePath, minimalConfig(presence));
59360
+ return {
59361
+ ok: true,
59362
+ snippet
59363
+ };
59364
+ }
59365
+ const current = fs.readFileSync(filePath, "utf8");
59366
+ if (isJsonConfig(filePath)) try {
59367
+ fs.writeFileSync(filePath, applyPresenceToJson(current, presence));
59368
+ return {
59369
+ ok: true,
59370
+ snippet
59371
+ };
59372
+ } catch {
59373
+ return {
59374
+ ok: false,
59375
+ snippet
59376
+ };
59377
+ }
59378
+ const next = applyPresenceToSource(current, presence, ts.ScriptKind.TS);
59379
+ if (next === void 0) return {
59380
+ ok: false,
59381
+ snippet
59382
+ };
59383
+ fs.writeFileSync(filePath, next);
59384
+ return {
59385
+ ok: true,
59386
+ snippet
59387
+ };
59388
+ }
59389
+ //#endregion
58726
59390
  //#region src/actions/skills/pick.ts
58727
59391
  function skillPickRows(cwd, presence = {}) {
58728
59392
  const profile = {
@@ -58752,47 +59416,6 @@ function formatSkillPickTable(rows) {
58752
59416
  for (const row of rows) lines.push(`${row.name} ${row.source} ${row.installed ? "installed" : "missing"} ${row.state}`);
58753
59417
  return lines.join("\n");
58754
59418
  }
58755
- function writeSkillPresence(cwd, presence) {
58756
- const filePath = path.join(cwd, "xy.config.ts");
58757
- const body = [
58758
- "import type { XyConfig } from '@ariestools/toolchain'",
58759
- "",
58760
- "const config: XyConfig = {",
58761
- " commands: {",
58762
- " skillsLint: {",
58763
- " skills: {",
58764
- ...Object.entries(presence).map(([name, setting]) => ` '${name}': { presence: '${setting}' },`),
58765
- " },",
58766
- " },",
58767
- " },",
58768
- "}",
58769
- "",
58770
- "export default config",
58771
- ""
58772
- ].join("\n");
58773
- if (!fs.existsSync(filePath)) {
58774
- fs.writeFileSync(filePath, body);
58775
- return;
58776
- }
58777
- const replaced = spliceObject(fs.readFileSync(filePath, "utf8"), "skills:", [
58778
- "skills: {",
58779
- ...Object.entries(presence).map(([name, setting]) => ` '${name}': { presence: '${setting}' },`),
58780
- " }"
58781
- ].join("\n"));
58782
- fs.writeFileSync(filePath, replaced ?? body);
58783
- }
58784
- function spliceObject(current, label, block) {
58785
- const at = current.indexOf(label);
58786
- if (at === -1) return void 0;
58787
- const open = current.indexOf("{", at);
58788
- if (open === -1) return void 0;
58789
- let depth = 0;
58790
- for (let index = open; index < current.length; index += 1) {
58791
- if (current[index] === "{") depth += 1;
58792
- if (current[index] === "}") depth -= 1;
58793
- if (depth === 0) return `${current.slice(0, at)}${block}${current.slice(index + 1)}`;
58794
- }
58795
- }
58796
59419
  async function skillsPick(options = {}) {
58797
59420
  const cwd = options.cwd ?? INIT_CWD();
58798
59421
  const selected = options.skills === void 0 ? await promptForSkills(cwd) : [...options.skills];
@@ -58810,14 +59433,19 @@ async function skillsPick(options = {}) {
58810
59433
  const code = await install(name, skillSourceForName(name));
58811
59434
  if (code !== 0) return code;
58812
59435
  }
58813
- const presence = {};
59436
+ const presence = { ...readSkillPresenceFile(cwd) };
58814
59437
  for (const name of selected) presence[name] = "required";
58815
- writeSkillPresence(cwd, normalizeSkillPresence(Object.fromEntries(Object.entries(presence).map(([name, setting]) => [name, { presence: setting }]))));
59438
+ const written = writeSkillPresenceFile(cwd, normalizeSkillPresence(Object.fromEntries(Object.entries(presence).map(([name, setting]) => [name, { presence: setting }]))));
59439
+ if (!written.ok) {
59440
+ console.error("xy skills pick could not find a config object. Paste this into xy config and re-run:");
59441
+ console.error(written.snippet);
59442
+ return 1;
59443
+ }
58816
59444
  return 0;
58817
59445
  }
58818
59446
  async function promptForSkills(cwd) {
58819
59447
  if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error("xy skills pick needs a TTY. Pass --skill <name> to choose without a prompt.");
58820
- console.log(formatSkillPickTable(skillPickRows(cwd)));
59448
+ console.log(formatSkillPickTable(skillPickRows(cwd, readSkillPresenceFile(cwd))));
58821
59449
  const rl = readline$1.createInterface({
58822
59450
  input: process.stdin,
58823
59451
  output: process.stdout
@@ -59001,6 +59629,10 @@ const workDone = (options) => {
59001
59629
  repo: scoped.repo
59002
59630
  });
59003
59631
  };
59632
+ const updatedBlockedReason = (next, current) => {
59633
+ if (next === void 0) return current;
59634
+ return next.trim().length === 0 ? void 0 : next;
59635
+ };
59004
59636
  const workUpdate = (options) => {
59005
59637
  const scoped = resolveScopedWorkItem(options.id, scopeFrom(options));
59006
59638
  const item = stripScope(scoped);
@@ -59010,13 +59642,13 @@ const workUpdate = (options) => {
59010
59642
  impact: options.impact,
59011
59643
  risk: options.risk,
59012
59644
  urgency: options.urgency
59013
- });
59645
+ }, item.priority);
59014
59646
  const updatedAt = nowIso(options.now);
59015
59647
  const updated = {
59016
59648
  ...item,
59017
59649
  acceptanceCriteria: options.acceptanceCriteria === void 0 ? item.acceptanceCriteria : normalizeTextList(options.acceptanceCriteria),
59018
59650
  area: options.area ?? item.area,
59019
- blockedReason: options.blockedReason ?? item.blockedReason,
59651
+ blockedReason: updatedBlockedReason(options.blockedReason, item.blockedReason),
59020
59652
  description: options.description ?? item.description,
59021
59653
  priority: priority === void 0 ? item.priority : validateWorkPriority(priority),
59022
59654
  status: options.status ?? item.status,
@@ -59847,7 +60479,7 @@ const lintCommand$6 = {
59847
60479
  type: "boolean"
59848
60480
  }).option("strict", {
59849
60481
  default: false,
59850
- describe: "Treat warnings as errors",
60482
+ describe: "Treat warnings as errors (also XY_STRICT=1)",
59851
60483
  type: "boolean"
59852
60484
  }),
59853
60485
  command: "lint",
@@ -59883,7 +60515,7 @@ const initCommand$4 = {
59883
60515
  const auditCommand = {
59884
60516
  builder: (yargs) => yargs.option("strict", {
59885
60517
  default: false,
59886
- describe: "Treat warnings as errors",
60518
+ describe: "Treat warnings as errors (also XY_STRICT=1)",
59887
60519
  type: "boolean"
59888
60520
  }),
59889
60521
  command: "audit",
@@ -59967,16 +60599,22 @@ const checkCommand = {
59967
60599
  let errors = 0;
59968
60600
  let exitCode = 0;
59969
60601
  let warnings = 0;
60602
+ const errorDiagnostics = [];
60603
+ const warningDiagnostics = [];
59970
60604
  const addResult = (result) => {
59971
60605
  errors += resultErrorCount(result);
59972
60606
  warnings += resultWarningCount(result);
59973
60607
  exitCode += resultExitCode(result);
60608
+ if (typeof result === "number") return;
60609
+ errorDiagnostics.push(...result.envelope?.errors ?? []);
60610
+ warningDiagnostics.push(...result.envelope?.warnings ?? []);
59974
60611
  };
59975
60612
  console.log(chalk.blue("\n— agent lint —"));
59976
- addResult(await agentLint({
60613
+ if (await isAgentLintEnabled(process.cwd())) addResult(await agentLint({
59977
60614
  cwd: process.cwd(),
59978
60615
  fix: isFix
59979
60616
  }));
60617
+ else console.log(chalk.gray("No AGENTS.md — skipping agent lint"));
59980
60618
  console.log(chalk.blue("\n— git lint —"));
59981
60619
  if (isFix) addResult(await gitlintFix());
59982
60620
  else addResult(await gitlint());
@@ -60008,7 +60646,9 @@ const checkCommand = {
60008
60646
  return {
60009
60647
  envelope: {
60010
60648
  errorCount: errors,
60011
- warningCount: warnings
60649
+ errors: errorDiagnostics,
60650
+ warningCount: warnings,
60651
+ warnings: warningDiagnostics
60012
60652
  },
60013
60653
  exitCode
60014
60654
  };
@@ -60124,7 +60764,7 @@ const gitLintCommand = {
60124
60764
  //#endregion
60125
60765
  //#region src/xy/common/gitCommand.ts
60126
60766
  const gitCommand = {
60127
- builder: (yargs) => yargs.command(gitLintCommand).demandCommand(1),
60767
+ builder: (yargs) => yargs.command(gitLintCommand).demandCommand(1).strictCommands(),
60128
60768
  command: "git",
60129
60769
  describe: "Git utilities",
60130
60770
  handler: () => {
@@ -60665,11 +61305,28 @@ const CUSTOM_SKILLS_COMMANDS = /* @__PURE__ */ new Set([
60665
61305
  ]);
60666
61306
  const HELP_FLAGS = /* @__PURE__ */ new Set(["--help", "-h"]);
60667
61307
  const hasHelpFlag = (args) => args.some((arg) => HELP_FLAGS.has(arg));
61308
+ const printPickHelp = () => {
61309
+ console.log(`xy skills pick
61310
+
61311
+ Install catalog skills and record them as required.
61312
+
61313
+ Usage:
61314
+ xy skills pick [--skill <name>]...
61315
+
61316
+ Pick is catalog-only. A TTY is required when --skill is omitted.
61317
+ It writes commands.skillsLint.skills.<name>.presence: 'required'
61318
+ and keeps other presence entries.
61319
+
61320
+ Options:
61321
+ --skill <name> Skill to require. Repeat for more than one.
61322
+ -h, --help Show this help
61323
+ `);
61324
+ };
60668
61325
  const printDefaultsHelp = () => {
60669
61326
  console.log(`xy skills defaults
60670
61327
 
60671
61328
  Install the default skill stacks:
60672
- - ariestools/ariestools-skills (xy-development, xy-toolchain, ariestools-sdk)
61329
+ - ariestools/ariestools-skills (xy-development, xy-toolchain, xy-agent, ariestools-sdk)
60673
61330
  - XYOracleNetwork/xyo-skills (xyo-knowledge, xl1-*)
60674
61331
 
60675
61332
  Usage:
@@ -60720,12 +61377,16 @@ Config (xy.config.ts):
60720
61377
  - commands.skillsLint.additionalSkills
60721
61378
  Treat extra skills as required even when the detected
60722
61379
  profile does not require them
61380
+ - commands.skillsLint.skills.<name>.presence
61381
+ required | allowed | off. required forces a skill on,
61382
+ off forces it off, allowed keeps an install from
61383
+ counting as unnecessary
60723
61384
 
60724
61385
  Options:
60725
- --fix Install missing, migrate relocated, and update outdated skills (project scope)
61386
+ --fix Install missing and update outdated required and package-declared skills; migrate relocated ones (project scope)
60726
61387
  --offline Skip upstream version checks
60727
61388
  --rules List supported skills lint rules and their effective levels
60728
- --strict Fail on warnings (duplicates, unnecessary skills)
61389
+ --strict Fail on warnings (duplicates, unnecessary skills). XY_STRICT=1 does the same.
60729
61390
  -h, --help Show this help
60730
61391
  `);
60731
61392
  };
@@ -60739,6 +61400,10 @@ const runSkillsTail = async (tail) => {
60739
61400
  printLintHelp();
60740
61401
  return 0;
60741
61402
  }
61403
+ if (subcommand === "pick" && hasHelpFlag(args)) {
61404
+ printPickHelp();
61405
+ return 0;
61406
+ }
60742
61407
  if (subcommand === "defaults") return skillsDefaults(args);
60743
61408
  if (subcommand === "lint") {
60744
61409
  if (args.includes("--rules")) return ruleCatalogResult(await getSkillsLintRuleCatalog(), RULE_COMMANDS.skillsLint.title);
@@ -61175,7 +61840,7 @@ const updateCommand = {
61175
61840
  describe: "Replace status",
61176
61841
  type: "string"
61177
61842
  }).option("blocked-reason", {
61178
- describe: "Blocked status explanation",
61843
+ describe: "Blocked status explanation; pass an empty value (--blocked-reason \"\") to remove it",
61179
61844
  type: "string"
61180
61845
  }).option("tag", {
61181
61846
  array: true,
@@ -61189,17 +61854,32 @@ const updateCommand = {
61189
61854
  array: true,
61190
61855
  describe: "Replace verification entries; repeatable",
61191
61856
  type: "string"
61192
- }).option("impact", { type: "number" }).option("urgency", { type: "number" }).option("effort", { type: "number" }).option("risk", { type: "number" }).option("confidence", { type: "number" }));
61857
+ }).option("impact", {
61858
+ describe: "Set priority impact (1-5)",
61859
+ type: "number"
61860
+ }).option("urgency", {
61861
+ describe: "Set priority urgency (1-5)",
61862
+ type: "number"
61863
+ }).option("effort", {
61864
+ describe: "Set priority effort (1-5)",
61865
+ type: "number"
61866
+ }).option("risk", {
61867
+ describe: "Set priority risk (1-5)",
61868
+ type: "number"
61869
+ }).option("confidence", {
61870
+ describe: "Set priority confidence (1-5)",
61871
+ type: "number"
61872
+ }).epilogue(["Only the fields you pass change. Priority fields you leave out keep their stored values (or default to 3 when the item has no priority yet).", "Updates are written to the local store only. Run `xy work sync` afterwards to push the title and issue body to a linked GitHub issue; `xy work lint` reports linked issues whose body has drifted (work.github-synced)."].join("\n\n")));
61193
61873
  },
61194
61874
  command: "update <id>",
61195
- describe: "Update triage fields on a work item",
61875
+ describe: "Update fields on a work item (local only; run `xy work sync` to push to GitHub)",
61196
61876
  handler: async (argv) => {
61197
61877
  const scope = scopeFromArgv(argv);
61198
61878
  await withEnvelope("work update", () => workUpdate({
61199
61879
  ...scope,
61200
61880
  acceptanceCriteria: optionalStringArray(argv.acceptance),
61201
61881
  area: optionalString(argv.area),
61202
- blockedReason: optionalString(argv["blocked-reason"]),
61882
+ blockedReason: typeof argv["blocked-reason"] === "string" ? argv["blocked-reason"] : void 0,
61203
61883
  confidence: optionalNumber(argv.confidence),
61204
61884
  description: optionalString(argv.description),
61205
61885
  effort: optionalNumber(argv.effort),
@@ -67707,6 +68387,25 @@ function isRootRulesRequest(raw = process.argv.slice(2)) {
67707
68387
  function isRootStabilityRequest(raw = process.argv.slice(2)) {
67708
68388
  return isRootLongFlagRequest("--stability", raw);
67709
68389
  }
68390
+ const RETIRED_COMMANDS = {
68391
+ "claude-rules": "skills",
68392
+ "compile-only": "compile",
68393
+ "deploy-minor": "deploy minor",
68394
+ "gitlint": "git lint",
68395
+ "lintlint": "lint lint"
68396
+ };
68397
+ function retiredCommandReplacement(commandName, cliLabel) {
68398
+ if (commandName.startsWith("claude-")) return `${cliLabel} skills`;
68399
+ const replacement = RETIRED_COMMANDS[commandName];
68400
+ return replacement === void 0 ? void 0 : `${cliLabel} ${replacement}`;
68401
+ }
68402
+ function reportUnknownCommand(commandName, cliLabel) {
68403
+ const replacement = retiredCommandReplacement(commandName, cliLabel);
68404
+ const message = replacement === void 0 ? `Command not found [${commandName}]` : `Command not found [${commandName}]. Use ${replacement}`;
68405
+ console.error(chalk.yellow(message));
68406
+ console.error(chalk.gray(`Try '${cliLabel} --help' for list of commands`));
68407
+ process.exitCode = 1;
68408
+ }
67710
68409
  function registerCoreCommands(args, channel) {
67711
68410
  let next = xyLintStableCommands(args);
67712
68411
  next = xyLintExperimentalCommands(next, channel);
@@ -67736,15 +68435,15 @@ const xyBase = async (options = {}) => {
67736
68435
  }), channel);
67737
68436
  if (options.plugins) args = options.plugins(args, channel);
67738
68437
  const cliLabel = channel === "experimental" ? "xyex" : "xy";
67739
- return await args.demandCommand(1).command("*", "", () => {
67740
- const cmd = process.argv[2];
67741
- if (cmd === void 0 || process.argv.some((a) => [
68438
+ return await args.demandCommand(1).command("*", "", () => {}, (argv) => {
68439
+ const raw = argv._[0];
68440
+ const cmd = typeof raw === "string" || typeof raw === "number" ? String(raw) : "";
68441
+ if (cmd.length === 0 || process.argv.some((arg) => [
67742
68442
  "--help",
67743
68443
  "-h",
67744
68444
  "--version"
67745
- ].includes(a))) return;
67746
- console.error(chalk.yellow(`Command not found [${chalk.magenta(cmd)}]`));
67747
- console.log(chalk.gray(`Try '${cliLabel} --help' for list of commands`));
68445
+ ].includes(arg))) return;
68446
+ reportUnknownCommand(cmd, cliLabel);
67748
68447
  }).version(bundledToolchainVersion()).help().argv;
67749
68448
  };
67750
68449
  function registerLifecyclePlugins(args, channel) {