claudekit-cli 3.30.3 → 3.31.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2096 -428
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -7762,6 +7762,7 @@ var init_commands = __esm(() => {
|
|
|
7762
7762
|
release: exports_external.string().optional(),
|
|
7763
7763
|
check: exports_external.boolean().default(false),
|
|
7764
7764
|
yes: exports_external.boolean().default(false),
|
|
7765
|
+
dev: exports_external.boolean().default(false),
|
|
7765
7766
|
beta: exports_external.boolean().default(false),
|
|
7766
7767
|
registry: exports_external.string().url().optional()
|
|
7767
7768
|
}).merge(GlobalOutputOptionsSchema);
|
|
@@ -15652,8 +15653,1455 @@ var require_extract_zip = __commonJS((exports, module) => {
|
|
|
15652
15653
|
};
|
|
15653
15654
|
});
|
|
15654
15655
|
|
|
15655
|
-
// node_modules/
|
|
15656
|
+
// node_modules/picomatch/lib/constants.js
|
|
15656
15657
|
var require_constants = __commonJS((exports, module) => {
|
|
15658
|
+
var WIN_SLASH = "\\\\/";
|
|
15659
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
15660
|
+
var DOT_LITERAL = "\\.";
|
|
15661
|
+
var PLUS_LITERAL = "\\+";
|
|
15662
|
+
var QMARK_LITERAL = "\\?";
|
|
15663
|
+
var SLASH_LITERAL = "\\/";
|
|
15664
|
+
var ONE_CHAR = "(?=.)";
|
|
15665
|
+
var QMARK = "[^/]";
|
|
15666
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
15667
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
15668
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
15669
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
15670
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
15671
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
15672
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
15673
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
15674
|
+
var STAR = `${QMARK}*?`;
|
|
15675
|
+
var SEP = "/";
|
|
15676
|
+
var POSIX_CHARS = {
|
|
15677
|
+
DOT_LITERAL,
|
|
15678
|
+
PLUS_LITERAL,
|
|
15679
|
+
QMARK_LITERAL,
|
|
15680
|
+
SLASH_LITERAL,
|
|
15681
|
+
ONE_CHAR,
|
|
15682
|
+
QMARK,
|
|
15683
|
+
END_ANCHOR,
|
|
15684
|
+
DOTS_SLASH,
|
|
15685
|
+
NO_DOT,
|
|
15686
|
+
NO_DOTS,
|
|
15687
|
+
NO_DOT_SLASH,
|
|
15688
|
+
NO_DOTS_SLASH,
|
|
15689
|
+
QMARK_NO_DOT,
|
|
15690
|
+
STAR,
|
|
15691
|
+
START_ANCHOR,
|
|
15692
|
+
SEP
|
|
15693
|
+
};
|
|
15694
|
+
var WINDOWS_CHARS = {
|
|
15695
|
+
...POSIX_CHARS,
|
|
15696
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
15697
|
+
QMARK: WIN_NO_SLASH,
|
|
15698
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
15699
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
15700
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
15701
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
15702
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
15703
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
15704
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
15705
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
15706
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
15707
|
+
SEP: "\\"
|
|
15708
|
+
};
|
|
15709
|
+
var POSIX_REGEX_SOURCE = {
|
|
15710
|
+
alnum: "a-zA-Z0-9",
|
|
15711
|
+
alpha: "a-zA-Z",
|
|
15712
|
+
ascii: "\\x00-\\x7F",
|
|
15713
|
+
blank: " \\t",
|
|
15714
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
15715
|
+
digit: "0-9",
|
|
15716
|
+
graph: "\\x21-\\x7E",
|
|
15717
|
+
lower: "a-z",
|
|
15718
|
+
print: "\\x20-\\x7E ",
|
|
15719
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
15720
|
+
space: " \\t\\r\\n\\v\\f",
|
|
15721
|
+
upper: "A-Z",
|
|
15722
|
+
word: "A-Za-z0-9_",
|
|
15723
|
+
xdigit: "A-Fa-f0-9"
|
|
15724
|
+
};
|
|
15725
|
+
module.exports = {
|
|
15726
|
+
MAX_LENGTH: 1024 * 64,
|
|
15727
|
+
POSIX_REGEX_SOURCE,
|
|
15728
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
15729
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
15730
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
15731
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
15732
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
15733
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
15734
|
+
REPLACEMENTS: {
|
|
15735
|
+
__proto__: null,
|
|
15736
|
+
"***": "*",
|
|
15737
|
+
"**/**": "**",
|
|
15738
|
+
"**/**/**": "**"
|
|
15739
|
+
},
|
|
15740
|
+
CHAR_0: 48,
|
|
15741
|
+
CHAR_9: 57,
|
|
15742
|
+
CHAR_UPPERCASE_A: 65,
|
|
15743
|
+
CHAR_LOWERCASE_A: 97,
|
|
15744
|
+
CHAR_UPPERCASE_Z: 90,
|
|
15745
|
+
CHAR_LOWERCASE_Z: 122,
|
|
15746
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
15747
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
15748
|
+
CHAR_ASTERISK: 42,
|
|
15749
|
+
CHAR_AMPERSAND: 38,
|
|
15750
|
+
CHAR_AT: 64,
|
|
15751
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
15752
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
15753
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
15754
|
+
CHAR_COLON: 58,
|
|
15755
|
+
CHAR_COMMA: 44,
|
|
15756
|
+
CHAR_DOT: 46,
|
|
15757
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
15758
|
+
CHAR_EQUAL: 61,
|
|
15759
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
15760
|
+
CHAR_FORM_FEED: 12,
|
|
15761
|
+
CHAR_FORWARD_SLASH: 47,
|
|
15762
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
15763
|
+
CHAR_HASH: 35,
|
|
15764
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
15765
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
15766
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
15767
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
15768
|
+
CHAR_LINE_FEED: 10,
|
|
15769
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
15770
|
+
CHAR_PERCENT: 37,
|
|
15771
|
+
CHAR_PLUS: 43,
|
|
15772
|
+
CHAR_QUESTION_MARK: 63,
|
|
15773
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
15774
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
15775
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
15776
|
+
CHAR_SEMICOLON: 59,
|
|
15777
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
15778
|
+
CHAR_SPACE: 32,
|
|
15779
|
+
CHAR_TAB: 9,
|
|
15780
|
+
CHAR_UNDERSCORE: 95,
|
|
15781
|
+
CHAR_VERTICAL_LINE: 124,
|
|
15782
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
15783
|
+
extglobChars(chars) {
|
|
15784
|
+
return {
|
|
15785
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
15786
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
15787
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
15788
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
15789
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
15790
|
+
};
|
|
15791
|
+
},
|
|
15792
|
+
globChars(win322) {
|
|
15793
|
+
return win322 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
15794
|
+
}
|
|
15795
|
+
};
|
|
15796
|
+
});
|
|
15797
|
+
|
|
15798
|
+
// node_modules/picomatch/lib/utils.js
|
|
15799
|
+
var require_utils3 = __commonJS((exports) => {
|
|
15800
|
+
var {
|
|
15801
|
+
REGEX_BACKSLASH,
|
|
15802
|
+
REGEX_REMOVE_BACKSLASH,
|
|
15803
|
+
REGEX_SPECIAL_CHARS,
|
|
15804
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
15805
|
+
} = require_constants();
|
|
15806
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
15807
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
15808
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
15809
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
15810
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
15811
|
+
exports.isWindows = () => {
|
|
15812
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
15813
|
+
const platform10 = navigator.platform.toLowerCase();
|
|
15814
|
+
return platform10 === "win32" || platform10 === "windows";
|
|
15815
|
+
}
|
|
15816
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
15817
|
+
return process.platform === "win32";
|
|
15818
|
+
}
|
|
15819
|
+
return false;
|
|
15820
|
+
};
|
|
15821
|
+
exports.removeBackslashes = (str) => {
|
|
15822
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
15823
|
+
return match === "\\" ? "" : match;
|
|
15824
|
+
});
|
|
15825
|
+
};
|
|
15826
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
15827
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
15828
|
+
if (idx === -1)
|
|
15829
|
+
return input;
|
|
15830
|
+
if (input[idx - 1] === "\\")
|
|
15831
|
+
return exports.escapeLast(input, char, idx - 1);
|
|
15832
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
15833
|
+
};
|
|
15834
|
+
exports.removePrefix = (input, state = {}) => {
|
|
15835
|
+
let output2 = input;
|
|
15836
|
+
if (output2.startsWith("./")) {
|
|
15837
|
+
output2 = output2.slice(2);
|
|
15838
|
+
state.prefix = "./";
|
|
15839
|
+
}
|
|
15840
|
+
return output2;
|
|
15841
|
+
};
|
|
15842
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
15843
|
+
const prepend = options.contains ? "" : "^";
|
|
15844
|
+
const append = options.contains ? "" : "$";
|
|
15845
|
+
let output2 = `${prepend}(?:${input})${append}`;
|
|
15846
|
+
if (state.negated === true) {
|
|
15847
|
+
output2 = `(?:^(?!${output2}).*$)`;
|
|
15848
|
+
}
|
|
15849
|
+
return output2;
|
|
15850
|
+
};
|
|
15851
|
+
exports.basename = (path10, { windows } = {}) => {
|
|
15852
|
+
const segs = path10.split(windows ? /[\\/]/ : "/");
|
|
15853
|
+
const last = segs[segs.length - 1];
|
|
15854
|
+
if (last === "") {
|
|
15855
|
+
return segs[segs.length - 2];
|
|
15856
|
+
}
|
|
15857
|
+
return last;
|
|
15858
|
+
};
|
|
15859
|
+
});
|
|
15860
|
+
|
|
15861
|
+
// node_modules/picomatch/lib/scan.js
|
|
15862
|
+
var require_scan = __commonJS((exports, module) => {
|
|
15863
|
+
var utils = require_utils3();
|
|
15864
|
+
var {
|
|
15865
|
+
CHAR_ASTERISK,
|
|
15866
|
+
CHAR_AT,
|
|
15867
|
+
CHAR_BACKWARD_SLASH,
|
|
15868
|
+
CHAR_COMMA,
|
|
15869
|
+
CHAR_DOT,
|
|
15870
|
+
CHAR_EXCLAMATION_MARK,
|
|
15871
|
+
CHAR_FORWARD_SLASH,
|
|
15872
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
15873
|
+
CHAR_LEFT_PARENTHESES,
|
|
15874
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
15875
|
+
CHAR_PLUS,
|
|
15876
|
+
CHAR_QUESTION_MARK,
|
|
15877
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
15878
|
+
CHAR_RIGHT_PARENTHESES,
|
|
15879
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
15880
|
+
} = require_constants();
|
|
15881
|
+
var isPathSeparator = (code2) => {
|
|
15882
|
+
return code2 === CHAR_FORWARD_SLASH || code2 === CHAR_BACKWARD_SLASH;
|
|
15883
|
+
};
|
|
15884
|
+
var depth = (token) => {
|
|
15885
|
+
if (token.isPrefix !== true) {
|
|
15886
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
15887
|
+
}
|
|
15888
|
+
};
|
|
15889
|
+
var scan = (input, options) => {
|
|
15890
|
+
const opts = options || {};
|
|
15891
|
+
const length = input.length - 1;
|
|
15892
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
15893
|
+
const slashes = [];
|
|
15894
|
+
const tokens = [];
|
|
15895
|
+
const parts = [];
|
|
15896
|
+
let str = input;
|
|
15897
|
+
let index = -1;
|
|
15898
|
+
let start = 0;
|
|
15899
|
+
let lastIndex = 0;
|
|
15900
|
+
let isBrace = false;
|
|
15901
|
+
let isBracket = false;
|
|
15902
|
+
let isGlob = false;
|
|
15903
|
+
let isExtglob = false;
|
|
15904
|
+
let isGlobstar = false;
|
|
15905
|
+
let braceEscaped = false;
|
|
15906
|
+
let backslashes = false;
|
|
15907
|
+
let negated = false;
|
|
15908
|
+
let negatedExtglob = false;
|
|
15909
|
+
let finished = false;
|
|
15910
|
+
let braces = 0;
|
|
15911
|
+
let prev;
|
|
15912
|
+
let code2;
|
|
15913
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
15914
|
+
const eos = () => index >= length;
|
|
15915
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
15916
|
+
const advance = () => {
|
|
15917
|
+
prev = code2;
|
|
15918
|
+
return str.charCodeAt(++index);
|
|
15919
|
+
};
|
|
15920
|
+
while (index < length) {
|
|
15921
|
+
code2 = advance();
|
|
15922
|
+
let next;
|
|
15923
|
+
if (code2 === CHAR_BACKWARD_SLASH) {
|
|
15924
|
+
backslashes = token.backslashes = true;
|
|
15925
|
+
code2 = advance();
|
|
15926
|
+
if (code2 === CHAR_LEFT_CURLY_BRACE) {
|
|
15927
|
+
braceEscaped = true;
|
|
15928
|
+
}
|
|
15929
|
+
continue;
|
|
15930
|
+
}
|
|
15931
|
+
if (braceEscaped === true || code2 === CHAR_LEFT_CURLY_BRACE) {
|
|
15932
|
+
braces++;
|
|
15933
|
+
while (eos() !== true && (code2 = advance())) {
|
|
15934
|
+
if (code2 === CHAR_BACKWARD_SLASH) {
|
|
15935
|
+
backslashes = token.backslashes = true;
|
|
15936
|
+
advance();
|
|
15937
|
+
continue;
|
|
15938
|
+
}
|
|
15939
|
+
if (code2 === CHAR_LEFT_CURLY_BRACE) {
|
|
15940
|
+
braces++;
|
|
15941
|
+
continue;
|
|
15942
|
+
}
|
|
15943
|
+
if (braceEscaped !== true && code2 === CHAR_DOT && (code2 = advance()) === CHAR_DOT) {
|
|
15944
|
+
isBrace = token.isBrace = true;
|
|
15945
|
+
isGlob = token.isGlob = true;
|
|
15946
|
+
finished = true;
|
|
15947
|
+
if (scanToEnd === true) {
|
|
15948
|
+
continue;
|
|
15949
|
+
}
|
|
15950
|
+
break;
|
|
15951
|
+
}
|
|
15952
|
+
if (braceEscaped !== true && code2 === CHAR_COMMA) {
|
|
15953
|
+
isBrace = token.isBrace = true;
|
|
15954
|
+
isGlob = token.isGlob = true;
|
|
15955
|
+
finished = true;
|
|
15956
|
+
if (scanToEnd === true) {
|
|
15957
|
+
continue;
|
|
15958
|
+
}
|
|
15959
|
+
break;
|
|
15960
|
+
}
|
|
15961
|
+
if (code2 === CHAR_RIGHT_CURLY_BRACE) {
|
|
15962
|
+
braces--;
|
|
15963
|
+
if (braces === 0) {
|
|
15964
|
+
braceEscaped = false;
|
|
15965
|
+
isBrace = token.isBrace = true;
|
|
15966
|
+
finished = true;
|
|
15967
|
+
break;
|
|
15968
|
+
}
|
|
15969
|
+
}
|
|
15970
|
+
}
|
|
15971
|
+
if (scanToEnd === true) {
|
|
15972
|
+
continue;
|
|
15973
|
+
}
|
|
15974
|
+
break;
|
|
15975
|
+
}
|
|
15976
|
+
if (code2 === CHAR_FORWARD_SLASH) {
|
|
15977
|
+
slashes.push(index);
|
|
15978
|
+
tokens.push(token);
|
|
15979
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
15980
|
+
if (finished === true)
|
|
15981
|
+
continue;
|
|
15982
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
15983
|
+
start += 2;
|
|
15984
|
+
continue;
|
|
15985
|
+
}
|
|
15986
|
+
lastIndex = index + 1;
|
|
15987
|
+
continue;
|
|
15988
|
+
}
|
|
15989
|
+
if (opts.noext !== true) {
|
|
15990
|
+
const isExtglobChar = code2 === CHAR_PLUS || code2 === CHAR_AT || code2 === CHAR_ASTERISK || code2 === CHAR_QUESTION_MARK || code2 === CHAR_EXCLAMATION_MARK;
|
|
15991
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
15992
|
+
isGlob = token.isGlob = true;
|
|
15993
|
+
isExtglob = token.isExtglob = true;
|
|
15994
|
+
finished = true;
|
|
15995
|
+
if (code2 === CHAR_EXCLAMATION_MARK && index === start) {
|
|
15996
|
+
negatedExtglob = true;
|
|
15997
|
+
}
|
|
15998
|
+
if (scanToEnd === true) {
|
|
15999
|
+
while (eos() !== true && (code2 = advance())) {
|
|
16000
|
+
if (code2 === CHAR_BACKWARD_SLASH) {
|
|
16001
|
+
backslashes = token.backslashes = true;
|
|
16002
|
+
code2 = advance();
|
|
16003
|
+
continue;
|
|
16004
|
+
}
|
|
16005
|
+
if (code2 === CHAR_RIGHT_PARENTHESES) {
|
|
16006
|
+
isGlob = token.isGlob = true;
|
|
16007
|
+
finished = true;
|
|
16008
|
+
break;
|
|
16009
|
+
}
|
|
16010
|
+
}
|
|
16011
|
+
continue;
|
|
16012
|
+
}
|
|
16013
|
+
break;
|
|
16014
|
+
}
|
|
16015
|
+
}
|
|
16016
|
+
if (code2 === CHAR_ASTERISK) {
|
|
16017
|
+
if (prev === CHAR_ASTERISK)
|
|
16018
|
+
isGlobstar = token.isGlobstar = true;
|
|
16019
|
+
isGlob = token.isGlob = true;
|
|
16020
|
+
finished = true;
|
|
16021
|
+
if (scanToEnd === true) {
|
|
16022
|
+
continue;
|
|
16023
|
+
}
|
|
16024
|
+
break;
|
|
16025
|
+
}
|
|
16026
|
+
if (code2 === CHAR_QUESTION_MARK) {
|
|
16027
|
+
isGlob = token.isGlob = true;
|
|
16028
|
+
finished = true;
|
|
16029
|
+
if (scanToEnd === true) {
|
|
16030
|
+
continue;
|
|
16031
|
+
}
|
|
16032
|
+
break;
|
|
16033
|
+
}
|
|
16034
|
+
if (code2 === CHAR_LEFT_SQUARE_BRACKET) {
|
|
16035
|
+
while (eos() !== true && (next = advance())) {
|
|
16036
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
16037
|
+
backslashes = token.backslashes = true;
|
|
16038
|
+
advance();
|
|
16039
|
+
continue;
|
|
16040
|
+
}
|
|
16041
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
16042
|
+
isBracket = token.isBracket = true;
|
|
16043
|
+
isGlob = token.isGlob = true;
|
|
16044
|
+
finished = true;
|
|
16045
|
+
break;
|
|
16046
|
+
}
|
|
16047
|
+
}
|
|
16048
|
+
if (scanToEnd === true) {
|
|
16049
|
+
continue;
|
|
16050
|
+
}
|
|
16051
|
+
break;
|
|
16052
|
+
}
|
|
16053
|
+
if (opts.nonegate !== true && code2 === CHAR_EXCLAMATION_MARK && index === start) {
|
|
16054
|
+
negated = token.negated = true;
|
|
16055
|
+
start++;
|
|
16056
|
+
continue;
|
|
16057
|
+
}
|
|
16058
|
+
if (opts.noparen !== true && code2 === CHAR_LEFT_PARENTHESES) {
|
|
16059
|
+
isGlob = token.isGlob = true;
|
|
16060
|
+
if (scanToEnd === true) {
|
|
16061
|
+
while (eos() !== true && (code2 = advance())) {
|
|
16062
|
+
if (code2 === CHAR_LEFT_PARENTHESES) {
|
|
16063
|
+
backslashes = token.backslashes = true;
|
|
16064
|
+
code2 = advance();
|
|
16065
|
+
continue;
|
|
16066
|
+
}
|
|
16067
|
+
if (code2 === CHAR_RIGHT_PARENTHESES) {
|
|
16068
|
+
finished = true;
|
|
16069
|
+
break;
|
|
16070
|
+
}
|
|
16071
|
+
}
|
|
16072
|
+
continue;
|
|
16073
|
+
}
|
|
16074
|
+
break;
|
|
16075
|
+
}
|
|
16076
|
+
if (isGlob === true) {
|
|
16077
|
+
finished = true;
|
|
16078
|
+
if (scanToEnd === true) {
|
|
16079
|
+
continue;
|
|
16080
|
+
}
|
|
16081
|
+
break;
|
|
16082
|
+
}
|
|
16083
|
+
}
|
|
16084
|
+
if (opts.noext === true) {
|
|
16085
|
+
isExtglob = false;
|
|
16086
|
+
isGlob = false;
|
|
16087
|
+
}
|
|
16088
|
+
let base = str;
|
|
16089
|
+
let prefix = "";
|
|
16090
|
+
let glob = "";
|
|
16091
|
+
if (start > 0) {
|
|
16092
|
+
prefix = str.slice(0, start);
|
|
16093
|
+
str = str.slice(start);
|
|
16094
|
+
lastIndex -= start;
|
|
16095
|
+
}
|
|
16096
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
16097
|
+
base = str.slice(0, lastIndex);
|
|
16098
|
+
glob = str.slice(lastIndex);
|
|
16099
|
+
} else if (isGlob === true) {
|
|
16100
|
+
base = "";
|
|
16101
|
+
glob = str;
|
|
16102
|
+
} else {
|
|
16103
|
+
base = str;
|
|
16104
|
+
}
|
|
16105
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
16106
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
16107
|
+
base = base.slice(0, -1);
|
|
16108
|
+
}
|
|
16109
|
+
}
|
|
16110
|
+
if (opts.unescape === true) {
|
|
16111
|
+
if (glob)
|
|
16112
|
+
glob = utils.removeBackslashes(glob);
|
|
16113
|
+
if (base && backslashes === true) {
|
|
16114
|
+
base = utils.removeBackslashes(base);
|
|
16115
|
+
}
|
|
16116
|
+
}
|
|
16117
|
+
const state = {
|
|
16118
|
+
prefix,
|
|
16119
|
+
input,
|
|
16120
|
+
start,
|
|
16121
|
+
base,
|
|
16122
|
+
glob,
|
|
16123
|
+
isBrace,
|
|
16124
|
+
isBracket,
|
|
16125
|
+
isGlob,
|
|
16126
|
+
isExtglob,
|
|
16127
|
+
isGlobstar,
|
|
16128
|
+
negated,
|
|
16129
|
+
negatedExtglob
|
|
16130
|
+
};
|
|
16131
|
+
if (opts.tokens === true) {
|
|
16132
|
+
state.maxDepth = 0;
|
|
16133
|
+
if (!isPathSeparator(code2)) {
|
|
16134
|
+
tokens.push(token);
|
|
16135
|
+
}
|
|
16136
|
+
state.tokens = tokens;
|
|
16137
|
+
}
|
|
16138
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
16139
|
+
let prevIndex;
|
|
16140
|
+
for (let idx = 0;idx < slashes.length; idx++) {
|
|
16141
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
16142
|
+
const i = slashes[idx];
|
|
16143
|
+
const value = input.slice(n, i);
|
|
16144
|
+
if (opts.tokens) {
|
|
16145
|
+
if (idx === 0 && start !== 0) {
|
|
16146
|
+
tokens[idx].isPrefix = true;
|
|
16147
|
+
tokens[idx].value = prefix;
|
|
16148
|
+
} else {
|
|
16149
|
+
tokens[idx].value = value;
|
|
16150
|
+
}
|
|
16151
|
+
depth(tokens[idx]);
|
|
16152
|
+
state.maxDepth += tokens[idx].depth;
|
|
16153
|
+
}
|
|
16154
|
+
if (idx !== 0 || value !== "") {
|
|
16155
|
+
parts.push(value);
|
|
16156
|
+
}
|
|
16157
|
+
prevIndex = i;
|
|
16158
|
+
}
|
|
16159
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
16160
|
+
const value = input.slice(prevIndex + 1);
|
|
16161
|
+
parts.push(value);
|
|
16162
|
+
if (opts.tokens) {
|
|
16163
|
+
tokens[tokens.length - 1].value = value;
|
|
16164
|
+
depth(tokens[tokens.length - 1]);
|
|
16165
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
16166
|
+
}
|
|
16167
|
+
}
|
|
16168
|
+
state.slashes = slashes;
|
|
16169
|
+
state.parts = parts;
|
|
16170
|
+
}
|
|
16171
|
+
return state;
|
|
16172
|
+
};
|
|
16173
|
+
module.exports = scan;
|
|
16174
|
+
});
|
|
16175
|
+
|
|
16176
|
+
// node_modules/picomatch/lib/parse.js
|
|
16177
|
+
var require_parse = __commonJS((exports, module) => {
|
|
16178
|
+
var constants5 = require_constants();
|
|
16179
|
+
var utils = require_utils3();
|
|
16180
|
+
var {
|
|
16181
|
+
MAX_LENGTH,
|
|
16182
|
+
POSIX_REGEX_SOURCE,
|
|
16183
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
16184
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
16185
|
+
REPLACEMENTS
|
|
16186
|
+
} = constants5;
|
|
16187
|
+
var expandRange = (args, options) => {
|
|
16188
|
+
if (typeof options.expandRange === "function") {
|
|
16189
|
+
return options.expandRange(...args, options);
|
|
16190
|
+
}
|
|
16191
|
+
args.sort();
|
|
16192
|
+
const value = `[${args.join("-")}]`;
|
|
16193
|
+
try {
|
|
16194
|
+
new RegExp(value);
|
|
16195
|
+
} catch (ex) {
|
|
16196
|
+
return args.map((v2) => utils.escapeRegex(v2)).join("..");
|
|
16197
|
+
}
|
|
16198
|
+
return value;
|
|
16199
|
+
};
|
|
16200
|
+
var syntaxError = (type, char) => {
|
|
16201
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
16202
|
+
};
|
|
16203
|
+
var parse5 = (input, options) => {
|
|
16204
|
+
if (typeof input !== "string") {
|
|
16205
|
+
throw new TypeError("Expected a string");
|
|
16206
|
+
}
|
|
16207
|
+
input = REPLACEMENTS[input] || input;
|
|
16208
|
+
const opts = { ...options };
|
|
16209
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
16210
|
+
let len = input.length;
|
|
16211
|
+
if (len > max) {
|
|
16212
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
16213
|
+
}
|
|
16214
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
16215
|
+
const tokens = [bos];
|
|
16216
|
+
const capture = opts.capture ? "" : "?:";
|
|
16217
|
+
const PLATFORM_CHARS = constants5.globChars(opts.windows);
|
|
16218
|
+
const EXTGLOB_CHARS = constants5.extglobChars(PLATFORM_CHARS);
|
|
16219
|
+
const {
|
|
16220
|
+
DOT_LITERAL,
|
|
16221
|
+
PLUS_LITERAL,
|
|
16222
|
+
SLASH_LITERAL,
|
|
16223
|
+
ONE_CHAR,
|
|
16224
|
+
DOTS_SLASH,
|
|
16225
|
+
NO_DOT,
|
|
16226
|
+
NO_DOT_SLASH,
|
|
16227
|
+
NO_DOTS_SLASH,
|
|
16228
|
+
QMARK,
|
|
16229
|
+
QMARK_NO_DOT,
|
|
16230
|
+
STAR,
|
|
16231
|
+
START_ANCHOR
|
|
16232
|
+
} = PLATFORM_CHARS;
|
|
16233
|
+
const globstar = (opts2) => {
|
|
16234
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
16235
|
+
};
|
|
16236
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
16237
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
16238
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
16239
|
+
if (opts.capture) {
|
|
16240
|
+
star = `(${star})`;
|
|
16241
|
+
}
|
|
16242
|
+
if (typeof opts.noext === "boolean") {
|
|
16243
|
+
opts.noextglob = opts.noext;
|
|
16244
|
+
}
|
|
16245
|
+
const state = {
|
|
16246
|
+
input,
|
|
16247
|
+
index: -1,
|
|
16248
|
+
start: 0,
|
|
16249
|
+
dot: opts.dot === true,
|
|
16250
|
+
consumed: "",
|
|
16251
|
+
output: "",
|
|
16252
|
+
prefix: "",
|
|
16253
|
+
backtrack: false,
|
|
16254
|
+
negated: false,
|
|
16255
|
+
brackets: 0,
|
|
16256
|
+
braces: 0,
|
|
16257
|
+
parens: 0,
|
|
16258
|
+
quotes: 0,
|
|
16259
|
+
globstar: false,
|
|
16260
|
+
tokens
|
|
16261
|
+
};
|
|
16262
|
+
input = utils.removePrefix(input, state);
|
|
16263
|
+
len = input.length;
|
|
16264
|
+
const extglobs = [];
|
|
16265
|
+
const braces = [];
|
|
16266
|
+
const stack = [];
|
|
16267
|
+
let prev = bos;
|
|
16268
|
+
let value;
|
|
16269
|
+
const eos = () => state.index === len - 1;
|
|
16270
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
16271
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
16272
|
+
const remaining = () => input.slice(state.index + 1);
|
|
16273
|
+
const consume = (value2 = "", num = 0) => {
|
|
16274
|
+
state.consumed += value2;
|
|
16275
|
+
state.index += num;
|
|
16276
|
+
};
|
|
16277
|
+
const append = (token) => {
|
|
16278
|
+
state.output += token.output != null ? token.output : token.value;
|
|
16279
|
+
consume(token.value);
|
|
16280
|
+
};
|
|
16281
|
+
const negate = () => {
|
|
16282
|
+
let count = 1;
|
|
16283
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
16284
|
+
advance();
|
|
16285
|
+
state.start++;
|
|
16286
|
+
count++;
|
|
16287
|
+
}
|
|
16288
|
+
if (count % 2 === 0) {
|
|
16289
|
+
return false;
|
|
16290
|
+
}
|
|
16291
|
+
state.negated = true;
|
|
16292
|
+
state.start++;
|
|
16293
|
+
return true;
|
|
16294
|
+
};
|
|
16295
|
+
const increment = (type) => {
|
|
16296
|
+
state[type]++;
|
|
16297
|
+
stack.push(type);
|
|
16298
|
+
};
|
|
16299
|
+
const decrement = (type) => {
|
|
16300
|
+
state[type]--;
|
|
16301
|
+
stack.pop();
|
|
16302
|
+
};
|
|
16303
|
+
const push2 = (tok) => {
|
|
16304
|
+
if (prev.type === "globstar") {
|
|
16305
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
16306
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
16307
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
16308
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
16309
|
+
prev.type = "star";
|
|
16310
|
+
prev.value = "*";
|
|
16311
|
+
prev.output = star;
|
|
16312
|
+
state.output += prev.output;
|
|
16313
|
+
}
|
|
16314
|
+
}
|
|
16315
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
16316
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
16317
|
+
}
|
|
16318
|
+
if (tok.value || tok.output)
|
|
16319
|
+
append(tok);
|
|
16320
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
16321
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
16322
|
+
prev.value += tok.value;
|
|
16323
|
+
return;
|
|
16324
|
+
}
|
|
16325
|
+
tok.prev = prev;
|
|
16326
|
+
tokens.push(tok);
|
|
16327
|
+
prev = tok;
|
|
16328
|
+
};
|
|
16329
|
+
const extglobOpen = (type, value2) => {
|
|
16330
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
16331
|
+
token.prev = prev;
|
|
16332
|
+
token.parens = state.parens;
|
|
16333
|
+
token.output = state.output;
|
|
16334
|
+
const output2 = (opts.capture ? "(" : "") + token.open;
|
|
16335
|
+
increment("parens");
|
|
16336
|
+
push2({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
16337
|
+
push2({ type: "paren", extglob: true, value: advance(), output: output2 });
|
|
16338
|
+
extglobs.push(token);
|
|
16339
|
+
};
|
|
16340
|
+
const extglobClose = (token) => {
|
|
16341
|
+
let output2 = token.close + (opts.capture ? ")" : "");
|
|
16342
|
+
let rest;
|
|
16343
|
+
if (token.type === "negate") {
|
|
16344
|
+
let extglobStar = star;
|
|
16345
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
16346
|
+
extglobStar = globstar(opts);
|
|
16347
|
+
}
|
|
16348
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
16349
|
+
output2 = token.close = `)$))${extglobStar}`;
|
|
16350
|
+
}
|
|
16351
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
16352
|
+
const expression = parse5(rest, { ...options, fastpaths: false }).output;
|
|
16353
|
+
output2 = token.close = `)${expression})${extglobStar})`;
|
|
16354
|
+
}
|
|
16355
|
+
if (token.prev.type === "bos") {
|
|
16356
|
+
state.negatedExtglob = true;
|
|
16357
|
+
}
|
|
16358
|
+
}
|
|
16359
|
+
push2({ type: "paren", extglob: true, value, output: output2 });
|
|
16360
|
+
decrement("parens");
|
|
16361
|
+
};
|
|
16362
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
16363
|
+
let backslashes = false;
|
|
16364
|
+
let output2 = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m2, esc, chars, first, rest, index) => {
|
|
16365
|
+
if (first === "\\") {
|
|
16366
|
+
backslashes = true;
|
|
16367
|
+
return m2;
|
|
16368
|
+
}
|
|
16369
|
+
if (first === "?") {
|
|
16370
|
+
if (esc) {
|
|
16371
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
16372
|
+
}
|
|
16373
|
+
if (index === 0) {
|
|
16374
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
16375
|
+
}
|
|
16376
|
+
return QMARK.repeat(chars.length);
|
|
16377
|
+
}
|
|
16378
|
+
if (first === ".") {
|
|
16379
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
16380
|
+
}
|
|
16381
|
+
if (first === "*") {
|
|
16382
|
+
if (esc) {
|
|
16383
|
+
return esc + first + (rest ? star : "");
|
|
16384
|
+
}
|
|
16385
|
+
return star;
|
|
16386
|
+
}
|
|
16387
|
+
return esc ? m2 : `\\${m2}`;
|
|
16388
|
+
});
|
|
16389
|
+
if (backslashes === true) {
|
|
16390
|
+
if (opts.unescape === true) {
|
|
16391
|
+
output2 = output2.replace(/\\/g, "");
|
|
16392
|
+
} else {
|
|
16393
|
+
output2 = output2.replace(/\\+/g, (m2) => {
|
|
16394
|
+
return m2.length % 2 === 0 ? "\\\\" : m2 ? "\\" : "";
|
|
16395
|
+
});
|
|
16396
|
+
}
|
|
16397
|
+
}
|
|
16398
|
+
if (output2 === input && opts.contains === true) {
|
|
16399
|
+
state.output = input;
|
|
16400
|
+
return state;
|
|
16401
|
+
}
|
|
16402
|
+
state.output = utils.wrapOutput(output2, state, options);
|
|
16403
|
+
return state;
|
|
16404
|
+
}
|
|
16405
|
+
while (!eos()) {
|
|
16406
|
+
value = advance();
|
|
16407
|
+
if (value === "\x00") {
|
|
16408
|
+
continue;
|
|
16409
|
+
}
|
|
16410
|
+
if (value === "\\") {
|
|
16411
|
+
const next = peek();
|
|
16412
|
+
if (next === "/" && opts.bash !== true) {
|
|
16413
|
+
continue;
|
|
16414
|
+
}
|
|
16415
|
+
if (next === "." || next === ";") {
|
|
16416
|
+
continue;
|
|
16417
|
+
}
|
|
16418
|
+
if (!next) {
|
|
16419
|
+
value += "\\";
|
|
16420
|
+
push2({ type: "text", value });
|
|
16421
|
+
continue;
|
|
16422
|
+
}
|
|
16423
|
+
const match = /^\\+/.exec(remaining());
|
|
16424
|
+
let slashes = 0;
|
|
16425
|
+
if (match && match[0].length > 2) {
|
|
16426
|
+
slashes = match[0].length;
|
|
16427
|
+
state.index += slashes;
|
|
16428
|
+
if (slashes % 2 !== 0) {
|
|
16429
|
+
value += "\\";
|
|
16430
|
+
}
|
|
16431
|
+
}
|
|
16432
|
+
if (opts.unescape === true) {
|
|
16433
|
+
value = advance();
|
|
16434
|
+
} else {
|
|
16435
|
+
value += advance();
|
|
16436
|
+
}
|
|
16437
|
+
if (state.brackets === 0) {
|
|
16438
|
+
push2({ type: "text", value });
|
|
16439
|
+
continue;
|
|
16440
|
+
}
|
|
16441
|
+
}
|
|
16442
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
16443
|
+
if (opts.posix !== false && value === ":") {
|
|
16444
|
+
const inner = prev.value.slice(1);
|
|
16445
|
+
if (inner.includes("[")) {
|
|
16446
|
+
prev.posix = true;
|
|
16447
|
+
if (inner.includes(":")) {
|
|
16448
|
+
const idx = prev.value.lastIndexOf("[");
|
|
16449
|
+
const pre = prev.value.slice(0, idx);
|
|
16450
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
16451
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
16452
|
+
if (posix) {
|
|
16453
|
+
prev.value = pre + posix;
|
|
16454
|
+
state.backtrack = true;
|
|
16455
|
+
advance();
|
|
16456
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
16457
|
+
bos.output = ONE_CHAR;
|
|
16458
|
+
}
|
|
16459
|
+
continue;
|
|
16460
|
+
}
|
|
16461
|
+
}
|
|
16462
|
+
}
|
|
16463
|
+
}
|
|
16464
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
16465
|
+
value = `\\${value}`;
|
|
16466
|
+
}
|
|
16467
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
16468
|
+
value = `\\${value}`;
|
|
16469
|
+
}
|
|
16470
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
16471
|
+
value = "^";
|
|
16472
|
+
}
|
|
16473
|
+
prev.value += value;
|
|
16474
|
+
append({ value });
|
|
16475
|
+
continue;
|
|
16476
|
+
}
|
|
16477
|
+
if (state.quotes === 1 && value !== '"') {
|
|
16478
|
+
value = utils.escapeRegex(value);
|
|
16479
|
+
prev.value += value;
|
|
16480
|
+
append({ value });
|
|
16481
|
+
continue;
|
|
16482
|
+
}
|
|
16483
|
+
if (value === '"') {
|
|
16484
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
16485
|
+
if (opts.keepQuotes === true) {
|
|
16486
|
+
push2({ type: "text", value });
|
|
16487
|
+
}
|
|
16488
|
+
continue;
|
|
16489
|
+
}
|
|
16490
|
+
if (value === "(") {
|
|
16491
|
+
increment("parens");
|
|
16492
|
+
push2({ type: "paren", value });
|
|
16493
|
+
continue;
|
|
16494
|
+
}
|
|
16495
|
+
if (value === ")") {
|
|
16496
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
16497
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
16498
|
+
}
|
|
16499
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
16500
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
16501
|
+
extglobClose(extglobs.pop());
|
|
16502
|
+
continue;
|
|
16503
|
+
}
|
|
16504
|
+
push2({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
16505
|
+
decrement("parens");
|
|
16506
|
+
continue;
|
|
16507
|
+
}
|
|
16508
|
+
if (value === "[") {
|
|
16509
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
16510
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
16511
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
16512
|
+
}
|
|
16513
|
+
value = `\\${value}`;
|
|
16514
|
+
} else {
|
|
16515
|
+
increment("brackets");
|
|
16516
|
+
}
|
|
16517
|
+
push2({ type: "bracket", value });
|
|
16518
|
+
continue;
|
|
16519
|
+
}
|
|
16520
|
+
if (value === "]") {
|
|
16521
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
16522
|
+
push2({ type: "text", value, output: `\\${value}` });
|
|
16523
|
+
continue;
|
|
16524
|
+
}
|
|
16525
|
+
if (state.brackets === 0) {
|
|
16526
|
+
if (opts.strictBrackets === true) {
|
|
16527
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
16528
|
+
}
|
|
16529
|
+
push2({ type: "text", value, output: `\\${value}` });
|
|
16530
|
+
continue;
|
|
16531
|
+
}
|
|
16532
|
+
decrement("brackets");
|
|
16533
|
+
const prevValue = prev.value.slice(1);
|
|
16534
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
16535
|
+
value = `/${value}`;
|
|
16536
|
+
}
|
|
16537
|
+
prev.value += value;
|
|
16538
|
+
append({ value });
|
|
16539
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
16540
|
+
continue;
|
|
16541
|
+
}
|
|
16542
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
16543
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
16544
|
+
if (opts.literalBrackets === true) {
|
|
16545
|
+
state.output += escaped;
|
|
16546
|
+
prev.value = escaped;
|
|
16547
|
+
continue;
|
|
16548
|
+
}
|
|
16549
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
16550
|
+
state.output += prev.value;
|
|
16551
|
+
continue;
|
|
16552
|
+
}
|
|
16553
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
16554
|
+
increment("braces");
|
|
16555
|
+
const open = {
|
|
16556
|
+
type: "brace",
|
|
16557
|
+
value,
|
|
16558
|
+
output: "(",
|
|
16559
|
+
outputIndex: state.output.length,
|
|
16560
|
+
tokensIndex: state.tokens.length
|
|
16561
|
+
};
|
|
16562
|
+
braces.push(open);
|
|
16563
|
+
push2(open);
|
|
16564
|
+
continue;
|
|
16565
|
+
}
|
|
16566
|
+
if (value === "}") {
|
|
16567
|
+
const brace = braces[braces.length - 1];
|
|
16568
|
+
if (opts.nobrace === true || !brace) {
|
|
16569
|
+
push2({ type: "text", value, output: value });
|
|
16570
|
+
continue;
|
|
16571
|
+
}
|
|
16572
|
+
let output2 = ")";
|
|
16573
|
+
if (brace.dots === true) {
|
|
16574
|
+
const arr = tokens.slice();
|
|
16575
|
+
const range = [];
|
|
16576
|
+
for (let i = arr.length - 1;i >= 0; i--) {
|
|
16577
|
+
tokens.pop();
|
|
16578
|
+
if (arr[i].type === "brace") {
|
|
16579
|
+
break;
|
|
16580
|
+
}
|
|
16581
|
+
if (arr[i].type !== "dots") {
|
|
16582
|
+
range.unshift(arr[i].value);
|
|
16583
|
+
}
|
|
16584
|
+
}
|
|
16585
|
+
output2 = expandRange(range, opts);
|
|
16586
|
+
state.backtrack = true;
|
|
16587
|
+
}
|
|
16588
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
16589
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
16590
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
16591
|
+
brace.value = brace.output = "\\{";
|
|
16592
|
+
value = output2 = "\\}";
|
|
16593
|
+
state.output = out;
|
|
16594
|
+
for (const t of toks) {
|
|
16595
|
+
state.output += t.output || t.value;
|
|
16596
|
+
}
|
|
16597
|
+
}
|
|
16598
|
+
push2({ type: "brace", value, output: output2 });
|
|
16599
|
+
decrement("braces");
|
|
16600
|
+
braces.pop();
|
|
16601
|
+
continue;
|
|
16602
|
+
}
|
|
16603
|
+
if (value === "|") {
|
|
16604
|
+
if (extglobs.length > 0) {
|
|
16605
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
16606
|
+
}
|
|
16607
|
+
push2({ type: "text", value });
|
|
16608
|
+
continue;
|
|
16609
|
+
}
|
|
16610
|
+
if (value === ",") {
|
|
16611
|
+
let output2 = value;
|
|
16612
|
+
const brace = braces[braces.length - 1];
|
|
16613
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
16614
|
+
brace.comma = true;
|
|
16615
|
+
output2 = "|";
|
|
16616
|
+
}
|
|
16617
|
+
push2({ type: "comma", value, output: output2 });
|
|
16618
|
+
continue;
|
|
16619
|
+
}
|
|
16620
|
+
if (value === "/") {
|
|
16621
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
16622
|
+
state.start = state.index + 1;
|
|
16623
|
+
state.consumed = "";
|
|
16624
|
+
state.output = "";
|
|
16625
|
+
tokens.pop();
|
|
16626
|
+
prev = bos;
|
|
16627
|
+
continue;
|
|
16628
|
+
}
|
|
16629
|
+
push2({ type: "slash", value, output: SLASH_LITERAL });
|
|
16630
|
+
continue;
|
|
16631
|
+
}
|
|
16632
|
+
if (value === ".") {
|
|
16633
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
16634
|
+
if (prev.value === ".")
|
|
16635
|
+
prev.output = DOT_LITERAL;
|
|
16636
|
+
const brace = braces[braces.length - 1];
|
|
16637
|
+
prev.type = "dots";
|
|
16638
|
+
prev.output += value;
|
|
16639
|
+
prev.value += value;
|
|
16640
|
+
brace.dots = true;
|
|
16641
|
+
continue;
|
|
16642
|
+
}
|
|
16643
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
16644
|
+
push2({ type: "text", value, output: DOT_LITERAL });
|
|
16645
|
+
continue;
|
|
16646
|
+
}
|
|
16647
|
+
push2({ type: "dot", value, output: DOT_LITERAL });
|
|
16648
|
+
continue;
|
|
16649
|
+
}
|
|
16650
|
+
if (value === "?") {
|
|
16651
|
+
const isGroup = prev && prev.value === "(";
|
|
16652
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
16653
|
+
extglobOpen("qmark", value);
|
|
16654
|
+
continue;
|
|
16655
|
+
}
|
|
16656
|
+
if (prev && prev.type === "paren") {
|
|
16657
|
+
const next = peek();
|
|
16658
|
+
let output2 = value;
|
|
16659
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
16660
|
+
output2 = `\\${value}`;
|
|
16661
|
+
}
|
|
16662
|
+
push2({ type: "text", value, output: output2 });
|
|
16663
|
+
continue;
|
|
16664
|
+
}
|
|
16665
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
16666
|
+
push2({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
16667
|
+
continue;
|
|
16668
|
+
}
|
|
16669
|
+
push2({ type: "qmark", value, output: QMARK });
|
|
16670
|
+
continue;
|
|
16671
|
+
}
|
|
16672
|
+
if (value === "!") {
|
|
16673
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
16674
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
16675
|
+
extglobOpen("negate", value);
|
|
16676
|
+
continue;
|
|
16677
|
+
}
|
|
16678
|
+
}
|
|
16679
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
16680
|
+
negate();
|
|
16681
|
+
continue;
|
|
16682
|
+
}
|
|
16683
|
+
}
|
|
16684
|
+
if (value === "+") {
|
|
16685
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
16686
|
+
extglobOpen("plus", value);
|
|
16687
|
+
continue;
|
|
16688
|
+
}
|
|
16689
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
16690
|
+
push2({ type: "plus", value, output: PLUS_LITERAL });
|
|
16691
|
+
continue;
|
|
16692
|
+
}
|
|
16693
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
16694
|
+
push2({ type: "plus", value });
|
|
16695
|
+
continue;
|
|
16696
|
+
}
|
|
16697
|
+
push2({ type: "plus", value: PLUS_LITERAL });
|
|
16698
|
+
continue;
|
|
16699
|
+
}
|
|
16700
|
+
if (value === "@") {
|
|
16701
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
16702
|
+
push2({ type: "at", extglob: true, value, output: "" });
|
|
16703
|
+
continue;
|
|
16704
|
+
}
|
|
16705
|
+
push2({ type: "text", value });
|
|
16706
|
+
continue;
|
|
16707
|
+
}
|
|
16708
|
+
if (value !== "*") {
|
|
16709
|
+
if (value === "$" || value === "^") {
|
|
16710
|
+
value = `\\${value}`;
|
|
16711
|
+
}
|
|
16712
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
16713
|
+
if (match) {
|
|
16714
|
+
value += match[0];
|
|
16715
|
+
state.index += match[0].length;
|
|
16716
|
+
}
|
|
16717
|
+
push2({ type: "text", value });
|
|
16718
|
+
continue;
|
|
16719
|
+
}
|
|
16720
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
16721
|
+
prev.type = "star";
|
|
16722
|
+
prev.star = true;
|
|
16723
|
+
prev.value += value;
|
|
16724
|
+
prev.output = star;
|
|
16725
|
+
state.backtrack = true;
|
|
16726
|
+
state.globstar = true;
|
|
16727
|
+
consume(value);
|
|
16728
|
+
continue;
|
|
16729
|
+
}
|
|
16730
|
+
let rest = remaining();
|
|
16731
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
16732
|
+
extglobOpen("star", value);
|
|
16733
|
+
continue;
|
|
16734
|
+
}
|
|
16735
|
+
if (prev.type === "star") {
|
|
16736
|
+
if (opts.noglobstar === true) {
|
|
16737
|
+
consume(value);
|
|
16738
|
+
continue;
|
|
16739
|
+
}
|
|
16740
|
+
const prior = prev.prev;
|
|
16741
|
+
const before = prior.prev;
|
|
16742
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
16743
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
16744
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
16745
|
+
push2({ type: "star", value, output: "" });
|
|
16746
|
+
continue;
|
|
16747
|
+
}
|
|
16748
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
16749
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
16750
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
16751
|
+
push2({ type: "star", value, output: "" });
|
|
16752
|
+
continue;
|
|
16753
|
+
}
|
|
16754
|
+
while (rest.slice(0, 3) === "/**") {
|
|
16755
|
+
const after = input[state.index + 4];
|
|
16756
|
+
if (after && after !== "/") {
|
|
16757
|
+
break;
|
|
16758
|
+
}
|
|
16759
|
+
rest = rest.slice(3);
|
|
16760
|
+
consume("/**", 3);
|
|
16761
|
+
}
|
|
16762
|
+
if (prior.type === "bos" && eos()) {
|
|
16763
|
+
prev.type = "globstar";
|
|
16764
|
+
prev.value += value;
|
|
16765
|
+
prev.output = globstar(opts);
|
|
16766
|
+
state.output = prev.output;
|
|
16767
|
+
state.globstar = true;
|
|
16768
|
+
consume(value);
|
|
16769
|
+
continue;
|
|
16770
|
+
}
|
|
16771
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
16772
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
16773
|
+
prior.output = `(?:${prior.output}`;
|
|
16774
|
+
prev.type = "globstar";
|
|
16775
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
16776
|
+
prev.value += value;
|
|
16777
|
+
state.globstar = true;
|
|
16778
|
+
state.output += prior.output + prev.output;
|
|
16779
|
+
consume(value);
|
|
16780
|
+
continue;
|
|
16781
|
+
}
|
|
16782
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
16783
|
+
const end = rest[1] !== undefined ? "|$" : "";
|
|
16784
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
16785
|
+
prior.output = `(?:${prior.output}`;
|
|
16786
|
+
prev.type = "globstar";
|
|
16787
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
16788
|
+
prev.value += value;
|
|
16789
|
+
state.output += prior.output + prev.output;
|
|
16790
|
+
state.globstar = true;
|
|
16791
|
+
consume(value + advance());
|
|
16792
|
+
push2({ type: "slash", value: "/", output: "" });
|
|
16793
|
+
continue;
|
|
16794
|
+
}
|
|
16795
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
16796
|
+
prev.type = "globstar";
|
|
16797
|
+
prev.value += value;
|
|
16798
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
16799
|
+
state.output = prev.output;
|
|
16800
|
+
state.globstar = true;
|
|
16801
|
+
consume(value + advance());
|
|
16802
|
+
push2({ type: "slash", value: "/", output: "" });
|
|
16803
|
+
continue;
|
|
16804
|
+
}
|
|
16805
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
16806
|
+
prev.type = "globstar";
|
|
16807
|
+
prev.output = globstar(opts);
|
|
16808
|
+
prev.value += value;
|
|
16809
|
+
state.output += prev.output;
|
|
16810
|
+
state.globstar = true;
|
|
16811
|
+
consume(value);
|
|
16812
|
+
continue;
|
|
16813
|
+
}
|
|
16814
|
+
const token = { type: "star", value, output: star };
|
|
16815
|
+
if (opts.bash === true) {
|
|
16816
|
+
token.output = ".*?";
|
|
16817
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
16818
|
+
token.output = nodot + token.output;
|
|
16819
|
+
}
|
|
16820
|
+
push2(token);
|
|
16821
|
+
continue;
|
|
16822
|
+
}
|
|
16823
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
16824
|
+
token.output = value;
|
|
16825
|
+
push2(token);
|
|
16826
|
+
continue;
|
|
16827
|
+
}
|
|
16828
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
16829
|
+
if (prev.type === "dot") {
|
|
16830
|
+
state.output += NO_DOT_SLASH;
|
|
16831
|
+
prev.output += NO_DOT_SLASH;
|
|
16832
|
+
} else if (opts.dot === true) {
|
|
16833
|
+
state.output += NO_DOTS_SLASH;
|
|
16834
|
+
prev.output += NO_DOTS_SLASH;
|
|
16835
|
+
} else {
|
|
16836
|
+
state.output += nodot;
|
|
16837
|
+
prev.output += nodot;
|
|
16838
|
+
}
|
|
16839
|
+
if (peek() !== "*") {
|
|
16840
|
+
state.output += ONE_CHAR;
|
|
16841
|
+
prev.output += ONE_CHAR;
|
|
16842
|
+
}
|
|
16843
|
+
}
|
|
16844
|
+
push2(token);
|
|
16845
|
+
}
|
|
16846
|
+
while (state.brackets > 0) {
|
|
16847
|
+
if (opts.strictBrackets === true)
|
|
16848
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
16849
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
16850
|
+
decrement("brackets");
|
|
16851
|
+
}
|
|
16852
|
+
while (state.parens > 0) {
|
|
16853
|
+
if (opts.strictBrackets === true)
|
|
16854
|
+
throw new SyntaxError(syntaxError("closing", ")"));
|
|
16855
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
16856
|
+
decrement("parens");
|
|
16857
|
+
}
|
|
16858
|
+
while (state.braces > 0) {
|
|
16859
|
+
if (opts.strictBrackets === true)
|
|
16860
|
+
throw new SyntaxError(syntaxError("closing", "}"));
|
|
16861
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
16862
|
+
decrement("braces");
|
|
16863
|
+
}
|
|
16864
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
16865
|
+
push2({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
16866
|
+
}
|
|
16867
|
+
if (state.backtrack === true) {
|
|
16868
|
+
state.output = "";
|
|
16869
|
+
for (const token of state.tokens) {
|
|
16870
|
+
state.output += token.output != null ? token.output : token.value;
|
|
16871
|
+
if (token.suffix) {
|
|
16872
|
+
state.output += token.suffix;
|
|
16873
|
+
}
|
|
16874
|
+
}
|
|
16875
|
+
}
|
|
16876
|
+
return state;
|
|
16877
|
+
};
|
|
16878
|
+
parse5.fastpaths = (input, options) => {
|
|
16879
|
+
const opts = { ...options };
|
|
16880
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
16881
|
+
const len = input.length;
|
|
16882
|
+
if (len > max) {
|
|
16883
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
16884
|
+
}
|
|
16885
|
+
input = REPLACEMENTS[input] || input;
|
|
16886
|
+
const {
|
|
16887
|
+
DOT_LITERAL,
|
|
16888
|
+
SLASH_LITERAL,
|
|
16889
|
+
ONE_CHAR,
|
|
16890
|
+
DOTS_SLASH,
|
|
16891
|
+
NO_DOT,
|
|
16892
|
+
NO_DOTS,
|
|
16893
|
+
NO_DOTS_SLASH,
|
|
16894
|
+
STAR,
|
|
16895
|
+
START_ANCHOR
|
|
16896
|
+
} = constants5.globChars(opts.windows);
|
|
16897
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
16898
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
16899
|
+
const capture = opts.capture ? "" : "?:";
|
|
16900
|
+
const state = { negated: false, prefix: "" };
|
|
16901
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
16902
|
+
if (opts.capture) {
|
|
16903
|
+
star = `(${star})`;
|
|
16904
|
+
}
|
|
16905
|
+
const globstar = (opts2) => {
|
|
16906
|
+
if (opts2.noglobstar === true)
|
|
16907
|
+
return star;
|
|
16908
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
16909
|
+
};
|
|
16910
|
+
const create3 = (str) => {
|
|
16911
|
+
switch (str) {
|
|
16912
|
+
case "*":
|
|
16913
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
16914
|
+
case ".*":
|
|
16915
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
16916
|
+
case "*.*":
|
|
16917
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
16918
|
+
case "*/*":
|
|
16919
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
16920
|
+
case "**":
|
|
16921
|
+
return nodot + globstar(opts);
|
|
16922
|
+
case "**/*":
|
|
16923
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
16924
|
+
case "**/*.*":
|
|
16925
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
16926
|
+
case "**/.*":
|
|
16927
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
16928
|
+
default: {
|
|
16929
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
16930
|
+
if (!match)
|
|
16931
|
+
return;
|
|
16932
|
+
const source2 = create3(match[1]);
|
|
16933
|
+
if (!source2)
|
|
16934
|
+
return;
|
|
16935
|
+
return source2 + DOT_LITERAL + match[2];
|
|
16936
|
+
}
|
|
16937
|
+
}
|
|
16938
|
+
};
|
|
16939
|
+
const output2 = utils.removePrefix(input, state);
|
|
16940
|
+
let source = create3(output2);
|
|
16941
|
+
if (source && opts.strictSlashes !== true) {
|
|
16942
|
+
source += `${SLASH_LITERAL}?`;
|
|
16943
|
+
}
|
|
16944
|
+
return source;
|
|
16945
|
+
};
|
|
16946
|
+
module.exports = parse5;
|
|
16947
|
+
});
|
|
16948
|
+
|
|
16949
|
+
// node_modules/picomatch/lib/picomatch.js
|
|
16950
|
+
var require_picomatch = __commonJS((exports, module) => {
|
|
16951
|
+
var scan = require_scan();
|
|
16952
|
+
var parse5 = require_parse();
|
|
16953
|
+
var utils = require_utils3();
|
|
16954
|
+
var constants5 = require_constants();
|
|
16955
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
16956
|
+
var picomatch = (glob, options, returnState = false) => {
|
|
16957
|
+
if (Array.isArray(glob)) {
|
|
16958
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
16959
|
+
const arrayMatcher = (str) => {
|
|
16960
|
+
for (const isMatch of fns) {
|
|
16961
|
+
const state2 = isMatch(str);
|
|
16962
|
+
if (state2)
|
|
16963
|
+
return state2;
|
|
16964
|
+
}
|
|
16965
|
+
return false;
|
|
16966
|
+
};
|
|
16967
|
+
return arrayMatcher;
|
|
16968
|
+
}
|
|
16969
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
16970
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
16971
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
16972
|
+
}
|
|
16973
|
+
const opts = options || {};
|
|
16974
|
+
const posix = opts.windows;
|
|
16975
|
+
const regex2 = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
16976
|
+
const state = regex2.state;
|
|
16977
|
+
delete regex2.state;
|
|
16978
|
+
let isIgnored = () => false;
|
|
16979
|
+
if (opts.ignore) {
|
|
16980
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
16981
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
16982
|
+
}
|
|
16983
|
+
const matcher = (input, returnObject = false) => {
|
|
16984
|
+
const { isMatch, match, output: output2 } = picomatch.test(input, regex2, options, { glob, posix });
|
|
16985
|
+
const result = { glob, state, regex: regex2, posix, input, output: output2, match, isMatch };
|
|
16986
|
+
if (typeof opts.onResult === "function") {
|
|
16987
|
+
opts.onResult(result);
|
|
16988
|
+
}
|
|
16989
|
+
if (isMatch === false) {
|
|
16990
|
+
result.isMatch = false;
|
|
16991
|
+
return returnObject ? result : false;
|
|
16992
|
+
}
|
|
16993
|
+
if (isIgnored(input)) {
|
|
16994
|
+
if (typeof opts.onIgnore === "function") {
|
|
16995
|
+
opts.onIgnore(result);
|
|
16996
|
+
}
|
|
16997
|
+
result.isMatch = false;
|
|
16998
|
+
return returnObject ? result : false;
|
|
16999
|
+
}
|
|
17000
|
+
if (typeof opts.onMatch === "function") {
|
|
17001
|
+
opts.onMatch(result);
|
|
17002
|
+
}
|
|
17003
|
+
return returnObject ? result : true;
|
|
17004
|
+
};
|
|
17005
|
+
if (returnState) {
|
|
17006
|
+
matcher.state = state;
|
|
17007
|
+
}
|
|
17008
|
+
return matcher;
|
|
17009
|
+
};
|
|
17010
|
+
picomatch.test = (input, regex2, options, { glob, posix } = {}) => {
|
|
17011
|
+
if (typeof input !== "string") {
|
|
17012
|
+
throw new TypeError("Expected input to be a string");
|
|
17013
|
+
}
|
|
17014
|
+
if (input === "") {
|
|
17015
|
+
return { isMatch: false, output: "" };
|
|
17016
|
+
}
|
|
17017
|
+
const opts = options || {};
|
|
17018
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
17019
|
+
let match = input === glob;
|
|
17020
|
+
let output2 = match && format ? format(input) : input;
|
|
17021
|
+
if (match === false) {
|
|
17022
|
+
output2 = format ? format(input) : input;
|
|
17023
|
+
match = output2 === glob;
|
|
17024
|
+
}
|
|
17025
|
+
if (match === false || opts.capture === true) {
|
|
17026
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
17027
|
+
match = picomatch.matchBase(input, regex2, options, posix);
|
|
17028
|
+
} else {
|
|
17029
|
+
match = regex2.exec(output2);
|
|
17030
|
+
}
|
|
17031
|
+
}
|
|
17032
|
+
return { isMatch: Boolean(match), match, output: output2 };
|
|
17033
|
+
};
|
|
17034
|
+
picomatch.matchBase = (input, glob, options) => {
|
|
17035
|
+
const regex2 = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
17036
|
+
return regex2.test(utils.basename(input));
|
|
17037
|
+
};
|
|
17038
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
17039
|
+
picomatch.parse = (pattern, options) => {
|
|
17040
|
+
if (Array.isArray(pattern))
|
|
17041
|
+
return pattern.map((p) => picomatch.parse(p, options));
|
|
17042
|
+
return parse5(pattern, { ...options, fastpaths: false });
|
|
17043
|
+
};
|
|
17044
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
17045
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
17046
|
+
if (returnOutput === true) {
|
|
17047
|
+
return state.output;
|
|
17048
|
+
}
|
|
17049
|
+
const opts = options || {};
|
|
17050
|
+
const prepend = opts.contains ? "" : "^";
|
|
17051
|
+
const append = opts.contains ? "" : "$";
|
|
17052
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
17053
|
+
if (state && state.negated === true) {
|
|
17054
|
+
source = `^(?!${source}).*$`;
|
|
17055
|
+
}
|
|
17056
|
+
const regex2 = picomatch.toRegex(source, options);
|
|
17057
|
+
if (returnState === true) {
|
|
17058
|
+
regex2.state = state;
|
|
17059
|
+
}
|
|
17060
|
+
return regex2;
|
|
17061
|
+
};
|
|
17062
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
17063
|
+
if (!input || typeof input !== "string") {
|
|
17064
|
+
throw new TypeError("Expected a non-empty string");
|
|
17065
|
+
}
|
|
17066
|
+
let parsed = { negated: false, fastpaths: true };
|
|
17067
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
17068
|
+
parsed.output = parse5.fastpaths(input, options);
|
|
17069
|
+
}
|
|
17070
|
+
if (!parsed.output) {
|
|
17071
|
+
parsed = parse5(input, options);
|
|
17072
|
+
}
|
|
17073
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
17074
|
+
};
|
|
17075
|
+
picomatch.toRegex = (source, options) => {
|
|
17076
|
+
try {
|
|
17077
|
+
const opts = options || {};
|
|
17078
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
17079
|
+
} catch (err) {
|
|
17080
|
+
if (options && options.debug === true)
|
|
17081
|
+
throw err;
|
|
17082
|
+
return /$^/;
|
|
17083
|
+
}
|
|
17084
|
+
};
|
|
17085
|
+
picomatch.constants = constants5;
|
|
17086
|
+
module.exports = picomatch;
|
|
17087
|
+
});
|
|
17088
|
+
|
|
17089
|
+
// node_modules/picomatch/index.js
|
|
17090
|
+
var require_picomatch2 = __commonJS((exports, module) => {
|
|
17091
|
+
var pico = require_picomatch();
|
|
17092
|
+
var utils = require_utils3();
|
|
17093
|
+
function picomatch(glob, options, returnState = false) {
|
|
17094
|
+
if (options && (options.windows === null || options.windows === undefined)) {
|
|
17095
|
+
options = { ...options, windows: utils.isWindows() };
|
|
17096
|
+
}
|
|
17097
|
+
return pico(glob, options, returnState);
|
|
17098
|
+
}
|
|
17099
|
+
Object.assign(picomatch, pico);
|
|
17100
|
+
module.exports = picomatch;
|
|
17101
|
+
});
|
|
17102
|
+
|
|
17103
|
+
// node_modules/semver/internal/constants.js
|
|
17104
|
+
var require_constants2 = __commonJS((exports, module) => {
|
|
15657
17105
|
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
15658
17106
|
var MAX_LENGTH = 256;
|
|
15659
17107
|
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
@@ -15692,7 +17140,7 @@ var require_re = __commonJS((exports, module) => {
|
|
|
15692
17140
|
MAX_SAFE_COMPONENT_LENGTH,
|
|
15693
17141
|
MAX_SAFE_BUILD_LENGTH,
|
|
15694
17142
|
MAX_LENGTH
|
|
15695
|
-
} =
|
|
17143
|
+
} = require_constants2();
|
|
15696
17144
|
var debug = require_debug();
|
|
15697
17145
|
exports = module.exports = {};
|
|
15698
17146
|
var re2 = exports.re = [];
|
|
@@ -15812,7 +17260,7 @@ var require_identifiers = __commonJS((exports, module) => {
|
|
|
15812
17260
|
// node_modules/semver/classes/semver.js
|
|
15813
17261
|
var require_semver = __commonJS((exports, module) => {
|
|
15814
17262
|
var debug = require_debug();
|
|
15815
|
-
var { MAX_LENGTH, MAX_SAFE_INTEGER } =
|
|
17263
|
+
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants2();
|
|
15816
17264
|
var { safeRe: re2, t } = require_re();
|
|
15817
17265
|
var parseOptions = require_parse_options();
|
|
15818
17266
|
var { compareIdentifiers } = require_identifiers();
|
|
@@ -16079,7 +17527,7 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
16079
17527
|
});
|
|
16080
17528
|
|
|
16081
17529
|
// node_modules/semver/functions/parse.js
|
|
16082
|
-
var
|
|
17530
|
+
var require_parse2 = __commonJS((exports, module) => {
|
|
16083
17531
|
var SemVer = require_semver();
|
|
16084
17532
|
var parse5 = (version, options, throwErrors = false) => {
|
|
16085
17533
|
if (version instanceof SemVer) {
|
|
@@ -16099,7 +17547,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
16099
17547
|
|
|
16100
17548
|
// node_modules/semver/functions/valid.js
|
|
16101
17549
|
var require_valid = __commonJS((exports, module) => {
|
|
16102
|
-
var parse5 =
|
|
17550
|
+
var parse5 = require_parse2();
|
|
16103
17551
|
var valid = (version, options) => {
|
|
16104
17552
|
const v2 = parse5(version, options);
|
|
16105
17553
|
return v2 ? v2.version : null;
|
|
@@ -16109,7 +17557,7 @@ var require_valid = __commonJS((exports, module) => {
|
|
|
16109
17557
|
|
|
16110
17558
|
// node_modules/semver/functions/clean.js
|
|
16111
17559
|
var require_clean = __commonJS((exports, module) => {
|
|
16112
|
-
var parse5 =
|
|
17560
|
+
var parse5 = require_parse2();
|
|
16113
17561
|
var clean = (version, options) => {
|
|
16114
17562
|
const s = parse5(version.trim().replace(/^[=v]+/, ""), options);
|
|
16115
17563
|
return s ? s.version : null;
|
|
@@ -16137,7 +17585,7 @@ var require_inc = __commonJS((exports, module) => {
|
|
|
16137
17585
|
|
|
16138
17586
|
// node_modules/semver/functions/diff.js
|
|
16139
17587
|
var require_diff = __commonJS((exports, module) => {
|
|
16140
|
-
var parse5 =
|
|
17588
|
+
var parse5 = require_parse2();
|
|
16141
17589
|
var diff = (version1, version2) => {
|
|
16142
17590
|
const v1 = parse5(version1, null, true);
|
|
16143
17591
|
const v2 = parse5(version2, null, true);
|
|
@@ -16199,7 +17647,7 @@ var require_patch = __commonJS((exports, module) => {
|
|
|
16199
17647
|
|
|
16200
17648
|
// node_modules/semver/functions/prerelease.js
|
|
16201
17649
|
var require_prerelease = __commonJS((exports, module) => {
|
|
16202
|
-
var parse5 =
|
|
17650
|
+
var parse5 = require_parse2();
|
|
16203
17651
|
var prerelease = (version, options) => {
|
|
16204
17652
|
const parsed = parse5(version, options);
|
|
16205
17653
|
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
@@ -16345,7 +17793,7 @@ var require_cmp = __commonJS((exports, module) => {
|
|
|
16345
17793
|
// node_modules/semver/functions/coerce.js
|
|
16346
17794
|
var require_coerce = __commonJS((exports, module) => {
|
|
16347
17795
|
var SemVer = require_semver();
|
|
16348
|
-
var parse5 =
|
|
17796
|
+
var parse5 = require_parse2();
|
|
16349
17797
|
var { safeRe: re2, t } = require_re();
|
|
16350
17798
|
var coerce2 = (version, options) => {
|
|
16351
17799
|
if (version instanceof SemVer) {
|
|
@@ -16575,7 +18023,7 @@ var require_range = __commonJS((exports, module) => {
|
|
|
16575
18023
|
tildeTrimReplace,
|
|
16576
18024
|
caretTrimReplace
|
|
16577
18025
|
} = require_re();
|
|
16578
|
-
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } =
|
|
18026
|
+
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants2();
|
|
16579
18027
|
var isNullSet = (c2) => c2.value === "<0.0.0-0";
|
|
16580
18028
|
var isAny = (c2) => c2.value === "";
|
|
16581
18029
|
var isSatisfiable = (comparators, options) => {
|
|
@@ -17346,10 +18794,10 @@ var require_subset = __commonJS((exports, module) => {
|
|
|
17346
18794
|
// node_modules/semver/index.js
|
|
17347
18795
|
var require_semver2 = __commonJS((exports, module) => {
|
|
17348
18796
|
var internalRe = require_re();
|
|
17349
|
-
var constants5 =
|
|
18797
|
+
var constants5 = require_constants2();
|
|
17350
18798
|
var SemVer = require_semver();
|
|
17351
18799
|
var identifiers = require_identifiers();
|
|
17352
|
-
var parse5 =
|
|
18800
|
+
var parse5 = require_parse2();
|
|
17353
18801
|
var valid = require_valid();
|
|
17354
18802
|
var clean = require_clean();
|
|
17355
18803
|
var inc = require_inc();
|
|
@@ -18149,7 +19597,7 @@ function getPagerArgs(pagerCmd) {
|
|
|
18149
19597
|
return [];
|
|
18150
19598
|
}
|
|
18151
19599
|
async function trySystemPager(content) {
|
|
18152
|
-
return new Promise((
|
|
19600
|
+
return new Promise((resolve12) => {
|
|
18153
19601
|
const pagerCmd = process.env.PAGER || "less";
|
|
18154
19602
|
const pagerArgs = getPagerArgs(pagerCmd);
|
|
18155
19603
|
try {
|
|
@@ -18159,20 +19607,20 @@ async function trySystemPager(content) {
|
|
|
18159
19607
|
});
|
|
18160
19608
|
const timeout = setTimeout(() => {
|
|
18161
19609
|
pager.kill();
|
|
18162
|
-
|
|
19610
|
+
resolve12(false);
|
|
18163
19611
|
}, 30000);
|
|
18164
19612
|
pager.stdin.write(content);
|
|
18165
19613
|
pager.stdin.end();
|
|
18166
19614
|
pager.on("close", (code2) => {
|
|
18167
19615
|
clearTimeout(timeout);
|
|
18168
|
-
|
|
19616
|
+
resolve12(code2 === 0);
|
|
18169
19617
|
});
|
|
18170
19618
|
pager.on("error", () => {
|
|
18171
19619
|
clearTimeout(timeout);
|
|
18172
|
-
|
|
19620
|
+
resolve12(false);
|
|
18173
19621
|
});
|
|
18174
19622
|
} catch {
|
|
18175
|
-
|
|
19623
|
+
resolve12(false);
|
|
18176
19624
|
}
|
|
18177
19625
|
});
|
|
18178
19626
|
}
|
|
@@ -18199,16 +19647,16 @@ async function basicPager(content) {
|
|
|
18199
19647
|
break;
|
|
18200
19648
|
}
|
|
18201
19649
|
const remaining = lines.length - currentLine;
|
|
18202
|
-
await new Promise((
|
|
19650
|
+
await new Promise((resolve12) => {
|
|
18203
19651
|
rl.question(`-- More (${remaining} lines) [Enter/q] --`, (answer) => {
|
|
18204
19652
|
if (answer.toLowerCase() === "q") {
|
|
18205
19653
|
rl.close();
|
|
18206
19654
|
process.exitCode = 0;
|
|
18207
|
-
|
|
19655
|
+
resolve12();
|
|
18208
19656
|
return;
|
|
18209
19657
|
}
|
|
18210
19658
|
process.stdout.write("\x1B[1A\x1B[2K");
|
|
18211
|
-
|
|
19659
|
+
resolve12();
|
|
18212
19660
|
});
|
|
18213
19661
|
});
|
|
18214
19662
|
}
|
|
@@ -35225,22 +36673,11 @@ async function handleDownload(ctx) {
|
|
|
35225
36673
|
};
|
|
35226
36674
|
}
|
|
35227
36675
|
// src/commands/init/phases/merge-handler.ts
|
|
35228
|
-
import { join as
|
|
36676
|
+
import { join as join54 } from "node:path";
|
|
35229
36677
|
|
|
35230
|
-
// src/domains/installation/
|
|
35231
|
-
|
|
35232
|
-
|
|
35233
|
-
init_dist2();
|
|
35234
|
-
|
|
35235
|
-
// src/domains/installation/merger/copy-executor.ts
|
|
35236
|
-
init_logger();
|
|
35237
|
-
init_types2();
|
|
35238
|
-
var import_fs_extra10 = __toESM(require_lib(), 1);
|
|
35239
|
-
var import_ignore3 = __toESM(require_ignore(), 1);
|
|
35240
|
-
import { dirname as dirname8, join as join43, relative as relative6 } from "node:path";
|
|
35241
|
-
|
|
35242
|
-
// src/domains/installation/selective-merger.ts
|
|
35243
|
-
import { stat as stat6 } from "node:fs/promises";
|
|
36678
|
+
// src/domains/installation/deletion-handler.ts
|
|
36679
|
+
import { existsSync as existsSync17, lstatSync as lstatSync2, readdirSync, rmSync as rmSync2, rmdirSync, unlinkSync as unlinkSync3 } from "node:fs";
|
|
36680
|
+
import { dirname as dirname6, join as join40, relative as relative5, resolve as resolve6 } from "node:path";
|
|
35244
36681
|
|
|
35245
36682
|
// src/services/file-operations/manifest/manifest-reader.ts
|
|
35246
36683
|
import { join as join39 } from "node:path";
|
|
@@ -35389,7 +36826,212 @@ async function getUninstallManifest(claudeDir, kit) {
|
|
|
35389
36826
|
};
|
|
35390
36827
|
}
|
|
35391
36828
|
|
|
36829
|
+
// src/domains/installation/deletion-handler.ts
|
|
36830
|
+
init_logger();
|
|
36831
|
+
var import_fs_extra7 = __toESM(require_lib(), 1);
|
|
36832
|
+
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
36833
|
+
function findFileInMetadata(metadata, path10) {
|
|
36834
|
+
if (!metadata)
|
|
36835
|
+
return null;
|
|
36836
|
+
if (metadata.kits) {
|
|
36837
|
+
for (const kitMeta of Object.values(metadata.kits)) {
|
|
36838
|
+
if (kitMeta?.files) {
|
|
36839
|
+
const found = kitMeta.files.find((f3) => f3.path === path10);
|
|
36840
|
+
if (found)
|
|
36841
|
+
return found;
|
|
36842
|
+
}
|
|
36843
|
+
}
|
|
36844
|
+
}
|
|
36845
|
+
if (metadata.files) {
|
|
36846
|
+
const found = metadata.files.find((f3) => f3.path === path10);
|
|
36847
|
+
if (found)
|
|
36848
|
+
return found;
|
|
36849
|
+
}
|
|
36850
|
+
return null;
|
|
36851
|
+
}
|
|
36852
|
+
function shouldDeletePath(path10, metadata) {
|
|
36853
|
+
const tracked = findFileInMetadata(metadata, path10);
|
|
36854
|
+
if (!tracked)
|
|
36855
|
+
return true;
|
|
36856
|
+
return tracked.ownership !== "user";
|
|
36857
|
+
}
|
|
36858
|
+
function isGlobPattern(pattern) {
|
|
36859
|
+
return pattern.includes("*") || pattern.includes("?") || pattern.includes("{");
|
|
36860
|
+
}
|
|
36861
|
+
function collectFilesRecursively(dir, baseDir) {
|
|
36862
|
+
const results = [];
|
|
36863
|
+
if (!existsSync17(dir))
|
|
36864
|
+
return results;
|
|
36865
|
+
try {
|
|
36866
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
36867
|
+
for (const entry of entries) {
|
|
36868
|
+
const fullPath = join40(dir, entry.name);
|
|
36869
|
+
const relativePath = relative5(baseDir, fullPath);
|
|
36870
|
+
if (entry.isDirectory()) {
|
|
36871
|
+
results.push(...collectFilesRecursively(fullPath, baseDir));
|
|
36872
|
+
} else {
|
|
36873
|
+
results.push(relativePath);
|
|
36874
|
+
}
|
|
36875
|
+
}
|
|
36876
|
+
} catch {}
|
|
36877
|
+
return results;
|
|
36878
|
+
}
|
|
36879
|
+
function expandGlobPatterns(patterns, claudeDir) {
|
|
36880
|
+
const expanded = [];
|
|
36881
|
+
const allFiles = collectFilesRecursively(claudeDir, claudeDir);
|
|
36882
|
+
for (const pattern of patterns) {
|
|
36883
|
+
if (isGlobPattern(pattern)) {
|
|
36884
|
+
const matcher = import_picomatch.default(pattern);
|
|
36885
|
+
const matches = allFiles.filter((file) => matcher(file));
|
|
36886
|
+
expanded.push(...matches);
|
|
36887
|
+
if (matches.length > 0) {
|
|
36888
|
+
logger.debug(`Pattern "${pattern}" matched ${matches.length} files`);
|
|
36889
|
+
}
|
|
36890
|
+
} else {
|
|
36891
|
+
expanded.push(pattern);
|
|
36892
|
+
}
|
|
36893
|
+
}
|
|
36894
|
+
return [...new Set(expanded)];
|
|
36895
|
+
}
|
|
36896
|
+
var MAX_CLEANUP_ITERATIONS = 50;
|
|
36897
|
+
function cleanupEmptyDirectories(filePath, claudeDir) {
|
|
36898
|
+
const normalizedClaudeDir = resolve6(claudeDir);
|
|
36899
|
+
let currentDir = resolve6(dirname6(filePath));
|
|
36900
|
+
let iterations = 0;
|
|
36901
|
+
while (currentDir !== normalizedClaudeDir && currentDir.startsWith(normalizedClaudeDir) && iterations < MAX_CLEANUP_ITERATIONS) {
|
|
36902
|
+
iterations++;
|
|
36903
|
+
try {
|
|
36904
|
+
const entries = readdirSync(currentDir);
|
|
36905
|
+
if (entries.length === 0) {
|
|
36906
|
+
rmdirSync(currentDir);
|
|
36907
|
+
logger.debug(`Removed empty directory: ${currentDir}`);
|
|
36908
|
+
currentDir = resolve6(dirname6(currentDir));
|
|
36909
|
+
} else {
|
|
36910
|
+
break;
|
|
36911
|
+
}
|
|
36912
|
+
} catch {
|
|
36913
|
+
break;
|
|
36914
|
+
}
|
|
36915
|
+
}
|
|
36916
|
+
}
|
|
36917
|
+
function deletePath(fullPath, claudeDir) {
|
|
36918
|
+
const normalizedPath = resolve6(fullPath);
|
|
36919
|
+
const normalizedClaudeDir = resolve6(claudeDir);
|
|
36920
|
+
if (!normalizedPath.startsWith(`${normalizedClaudeDir}/`) && normalizedPath !== normalizedClaudeDir) {
|
|
36921
|
+
throw new Error(`Path traversal detected: ${fullPath}`);
|
|
36922
|
+
}
|
|
36923
|
+
try {
|
|
36924
|
+
const stat6 = lstatSync2(fullPath);
|
|
36925
|
+
if (stat6.isDirectory()) {
|
|
36926
|
+
rmSync2(fullPath, { recursive: true, force: true });
|
|
36927
|
+
} else {
|
|
36928
|
+
unlinkSync3(fullPath);
|
|
36929
|
+
cleanupEmptyDirectories(fullPath, claudeDir);
|
|
36930
|
+
}
|
|
36931
|
+
} catch (error) {
|
|
36932
|
+
throw new Error(`Failed to delete ${fullPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
36933
|
+
}
|
|
36934
|
+
}
|
|
36935
|
+
async function updateMetadataAfterDeletion(claudeDir, deletedPaths) {
|
|
36936
|
+
const metadataPath = join40(claudeDir, "metadata.json");
|
|
36937
|
+
if (!await import_fs_extra7.pathExists(metadataPath)) {
|
|
36938
|
+
return;
|
|
36939
|
+
}
|
|
36940
|
+
let content;
|
|
36941
|
+
try {
|
|
36942
|
+
content = await import_fs_extra7.readFile(metadataPath, "utf-8");
|
|
36943
|
+
} catch {
|
|
36944
|
+
logger.debug("Failed to read metadata.json for cleanup");
|
|
36945
|
+
return;
|
|
36946
|
+
}
|
|
36947
|
+
let metadata;
|
|
36948
|
+
try {
|
|
36949
|
+
metadata = JSON.parse(content);
|
|
36950
|
+
} catch {
|
|
36951
|
+
logger.debug("Failed to parse metadata.json for cleanup");
|
|
36952
|
+
return;
|
|
36953
|
+
}
|
|
36954
|
+
const deletedSet = new Set(deletedPaths);
|
|
36955
|
+
const isDeletedOrInDeletedDir = (path10) => {
|
|
36956
|
+
if (deletedSet.has(path10))
|
|
36957
|
+
return true;
|
|
36958
|
+
for (const deleted of deletedPaths) {
|
|
36959
|
+
if (path10.startsWith(`${deleted}/`))
|
|
36960
|
+
return true;
|
|
36961
|
+
}
|
|
36962
|
+
return false;
|
|
36963
|
+
};
|
|
36964
|
+
if (metadata.kits) {
|
|
36965
|
+
for (const kitName of Object.keys(metadata.kits)) {
|
|
36966
|
+
const kit = metadata.kits[kitName];
|
|
36967
|
+
if (kit?.files) {
|
|
36968
|
+
kit.files = kit.files.filter((f3) => !isDeletedOrInDeletedDir(f3.path));
|
|
36969
|
+
}
|
|
36970
|
+
}
|
|
36971
|
+
}
|
|
36972
|
+
if (metadata.files) {
|
|
36973
|
+
metadata.files = metadata.files.filter((f3) => !isDeletedOrInDeletedDir(f3.path));
|
|
36974
|
+
}
|
|
36975
|
+
try {
|
|
36976
|
+
await import_fs_extra7.writeFile(metadataPath, JSON.stringify(metadata, null, 2));
|
|
36977
|
+
logger.debug(`Updated metadata.json, removed ${deletedPaths.length} entries`);
|
|
36978
|
+
} catch {
|
|
36979
|
+
logger.debug("Failed to write updated metadata.json");
|
|
36980
|
+
}
|
|
36981
|
+
}
|
|
36982
|
+
async function handleDeletions(sourceMetadata, claudeDir) {
|
|
36983
|
+
const deletionPatterns = sourceMetadata.deletions || [];
|
|
36984
|
+
if (deletionPatterns.length === 0) {
|
|
36985
|
+
return { deletedPaths: [], preservedPaths: [], errors: [] };
|
|
36986
|
+
}
|
|
36987
|
+
const deletions = expandGlobPatterns(deletionPatterns, claudeDir);
|
|
36988
|
+
const userMetadata = await readManifest(claudeDir);
|
|
36989
|
+
const result = { deletedPaths: [], preservedPaths: [], errors: [] };
|
|
36990
|
+
for (const path10 of deletions) {
|
|
36991
|
+
const fullPath = join40(claudeDir, path10);
|
|
36992
|
+
const normalizedPath = resolve6(fullPath);
|
|
36993
|
+
const normalizedClaudeDir = resolve6(claudeDir);
|
|
36994
|
+
if (!normalizedPath.startsWith(`${normalizedClaudeDir}/`)) {
|
|
36995
|
+
logger.warning(`Skipping invalid path: ${path10}`);
|
|
36996
|
+
result.errors.push(path10);
|
|
36997
|
+
continue;
|
|
36998
|
+
}
|
|
36999
|
+
if (!shouldDeletePath(path10, userMetadata)) {
|
|
37000
|
+
result.preservedPaths.push(path10);
|
|
37001
|
+
logger.verbose(`Preserved user file: ${path10}`);
|
|
37002
|
+
continue;
|
|
37003
|
+
}
|
|
37004
|
+
if (existsSync17(fullPath)) {
|
|
37005
|
+
try {
|
|
37006
|
+
deletePath(fullPath, claudeDir);
|
|
37007
|
+
result.deletedPaths.push(path10);
|
|
37008
|
+
logger.verbose(`Deleted: ${path10}`);
|
|
37009
|
+
} catch (error) {
|
|
37010
|
+
result.errors.push(path10);
|
|
37011
|
+
logger.debug(`Failed to delete ${path10}: ${error}`);
|
|
37012
|
+
}
|
|
37013
|
+
}
|
|
37014
|
+
}
|
|
37015
|
+
if (result.deletedPaths.length > 0) {
|
|
37016
|
+
await updateMetadataAfterDeletion(claudeDir, result.deletedPaths);
|
|
37017
|
+
}
|
|
37018
|
+
return result;
|
|
37019
|
+
}
|
|
37020
|
+
|
|
37021
|
+
// src/domains/installation/file-merger.ts
|
|
37022
|
+
init_logger();
|
|
37023
|
+
init_types2();
|
|
37024
|
+
init_dist2();
|
|
37025
|
+
|
|
37026
|
+
// src/domains/installation/merger/copy-executor.ts
|
|
37027
|
+
init_logger();
|
|
37028
|
+
init_types2();
|
|
37029
|
+
var import_fs_extra11 = __toESM(require_lib(), 1);
|
|
37030
|
+
var import_ignore3 = __toESM(require_ignore(), 1);
|
|
37031
|
+
import { dirname as dirname9, join as join44, relative as relative7 } from "node:path";
|
|
37032
|
+
|
|
35392
37033
|
// src/domains/installation/selective-merger.ts
|
|
37034
|
+
import { stat as stat6 } from "node:fs/promises";
|
|
35393
37035
|
init_logger();
|
|
35394
37036
|
var import_semver = __toESM(require_semver2(), 1);
|
|
35395
37037
|
|
|
@@ -35562,10 +37204,10 @@ class SelectiveMerger {
|
|
|
35562
37204
|
|
|
35563
37205
|
// src/domains/installation/merger/file-scanner.ts
|
|
35564
37206
|
init_logger();
|
|
35565
|
-
var
|
|
37207
|
+
var import_fs_extra8 = __toESM(require_lib(), 1);
|
|
35566
37208
|
var import_ignore2 = __toESM(require_ignore(), 1);
|
|
35567
|
-
import { relative as
|
|
35568
|
-
import { join as
|
|
37209
|
+
import { relative as relative6 } from "node:path";
|
|
37210
|
+
import { join as join41 } from "node:path";
|
|
35569
37211
|
|
|
35570
37212
|
// node_modules/@isaacs/balanced-match/dist/esm/index.js
|
|
35571
37213
|
var balanced = (a3, b3, str) => {
|
|
@@ -37019,12 +38661,12 @@ class FileScanner {
|
|
|
37019
38661
|
}
|
|
37020
38662
|
async getFiles(dir, baseDir = dir) {
|
|
37021
38663
|
const files = [];
|
|
37022
|
-
const entries = await
|
|
38664
|
+
const entries = await import_fs_extra8.readdir(dir, { encoding: "utf8" });
|
|
37023
38665
|
for (const entry of entries) {
|
|
37024
|
-
const fullPath =
|
|
37025
|
-
const relativePath =
|
|
38666
|
+
const fullPath = join41(dir, entry);
|
|
38667
|
+
const relativePath = relative6(baseDir, fullPath);
|
|
37026
38668
|
const normalizedRelativePath = relativePath.replace(/\\/g, "/");
|
|
37027
|
-
const stats = await
|
|
38669
|
+
const stats = await import_fs_extra8.lstat(fullPath);
|
|
37028
38670
|
if (stats.isSymbolicLink()) {
|
|
37029
38671
|
logger.warning(`Skipping symbolic link: ${normalizedRelativePath}`);
|
|
37030
38672
|
continue;
|
|
@@ -37055,9 +38697,9 @@ class FileScanner {
|
|
|
37055
38697
|
}
|
|
37056
38698
|
|
|
37057
38699
|
// src/domains/config/installed-settings-tracker.ts
|
|
37058
|
-
import { existsSync as
|
|
37059
|
-
import { mkdir as mkdir15, readFile as
|
|
37060
|
-
import { dirname as
|
|
38700
|
+
import { existsSync as existsSync18 } from "node:fs";
|
|
38701
|
+
import { mkdir as mkdir15, readFile as readFile14, writeFile as writeFile11 } from "node:fs/promises";
|
|
38702
|
+
import { dirname as dirname7, join as join42 } from "node:path";
|
|
37061
38703
|
|
|
37062
38704
|
// src/shared/index.ts
|
|
37063
38705
|
init_logger();
|
|
@@ -37097,17 +38739,17 @@ class InstalledSettingsTracker {
|
|
|
37097
38739
|
}
|
|
37098
38740
|
getCkJsonPath() {
|
|
37099
38741
|
if (this.isGlobal) {
|
|
37100
|
-
return
|
|
38742
|
+
return join42(this.projectDir, CK_JSON_FILE);
|
|
37101
38743
|
}
|
|
37102
|
-
return
|
|
38744
|
+
return join42(this.projectDir, ".claude", CK_JSON_FILE);
|
|
37103
38745
|
}
|
|
37104
38746
|
async loadInstalledSettings() {
|
|
37105
38747
|
const ckJsonPath = this.getCkJsonPath();
|
|
37106
|
-
if (!
|
|
38748
|
+
if (!existsSync18(ckJsonPath)) {
|
|
37107
38749
|
return { hooks: [], mcpServers: [] };
|
|
37108
38750
|
}
|
|
37109
38751
|
try {
|
|
37110
|
-
const content = await
|
|
38752
|
+
const content = await readFile14(ckJsonPath, "utf-8");
|
|
37111
38753
|
const data = JSON.parse(content);
|
|
37112
38754
|
const installed = data.kits?.[this.kitName]?.installedSettings;
|
|
37113
38755
|
if (installed) {
|
|
@@ -37123,8 +38765,8 @@ class InstalledSettingsTracker {
|
|
|
37123
38765
|
const ckJsonPath = this.getCkJsonPath();
|
|
37124
38766
|
try {
|
|
37125
38767
|
let data = {};
|
|
37126
|
-
if (
|
|
37127
|
-
const content = await
|
|
38768
|
+
if (existsSync18(ckJsonPath)) {
|
|
38769
|
+
const content = await readFile14(ckJsonPath, "utf-8");
|
|
37128
38770
|
data = JSON.parse(content);
|
|
37129
38771
|
}
|
|
37130
38772
|
if (!data.kits) {
|
|
@@ -37134,8 +38776,8 @@ class InstalledSettingsTracker {
|
|
|
37134
38776
|
data.kits[this.kitName] = {};
|
|
37135
38777
|
}
|
|
37136
38778
|
data.kits[this.kitName].installedSettings = settings;
|
|
37137
|
-
await mkdir15(
|
|
37138
|
-
await
|
|
38779
|
+
await mkdir15(dirname7(ckJsonPath), { recursive: true });
|
|
38780
|
+
await writeFile11(ckJsonPath, JSON.stringify(data, null, 2), "utf-8");
|
|
37139
38781
|
logger.debug(`Saved installed settings to ${ckJsonPath}`);
|
|
37140
38782
|
} catch (error) {
|
|
37141
38783
|
logger.warning(`Failed to save installed settings: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
@@ -37556,18 +39198,18 @@ function mergeSettings(source, destination, options) {
|
|
|
37556
39198
|
}
|
|
37557
39199
|
// src/domains/config/merger/file-io.ts
|
|
37558
39200
|
init_logger();
|
|
37559
|
-
var
|
|
39201
|
+
var import_fs_extra9 = __toESM(require_lib(), 1);
|
|
37560
39202
|
import { randomUUID } from "node:crypto";
|
|
37561
|
-
import { dirname as
|
|
39203
|
+
import { dirname as dirname8, join as join43 } from "node:path";
|
|
37562
39204
|
function stripBOM(content) {
|
|
37563
39205
|
return content.charCodeAt(0) === 65279 ? content.slice(1) : content;
|
|
37564
39206
|
}
|
|
37565
39207
|
async function readSettingsFile(filePath) {
|
|
37566
39208
|
try {
|
|
37567
|
-
if (!await
|
|
39209
|
+
if (!await import_fs_extra9.pathExists(filePath)) {
|
|
37568
39210
|
return null;
|
|
37569
39211
|
}
|
|
37570
|
-
const rawContent = await
|
|
39212
|
+
const rawContent = await import_fs_extra9.readFile(filePath, "utf-8");
|
|
37571
39213
|
const content = stripBOM(rawContent);
|
|
37572
39214
|
const parsed = JSON.parse(content);
|
|
37573
39215
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
@@ -37581,15 +39223,15 @@ async function readSettingsFile(filePath) {
|
|
|
37581
39223
|
}
|
|
37582
39224
|
}
|
|
37583
39225
|
async function atomicWriteFile(filePath, content) {
|
|
37584
|
-
const dir =
|
|
37585
|
-
const tempPath =
|
|
39226
|
+
const dir = dirname8(filePath);
|
|
39227
|
+
const tempPath = join43(dir, `.settings-${randomUUID()}.tmp`);
|
|
37586
39228
|
try {
|
|
37587
|
-
await
|
|
37588
|
-
await
|
|
39229
|
+
await import_fs_extra9.writeFile(tempPath, content, "utf-8");
|
|
39230
|
+
await import_fs_extra9.rename(tempPath, filePath);
|
|
37589
39231
|
} catch (error) {
|
|
37590
39232
|
try {
|
|
37591
|
-
if (await
|
|
37592
|
-
await
|
|
39233
|
+
if (await import_fs_extra9.pathExists(tempPath)) {
|
|
39234
|
+
await import_fs_extra9.unlink(tempPath);
|
|
37593
39235
|
}
|
|
37594
39236
|
} catch {}
|
|
37595
39237
|
throw error;
|
|
@@ -37618,7 +39260,7 @@ class SettingsMerger {
|
|
|
37618
39260
|
// src/domains/installation/merger/settings-processor.ts
|
|
37619
39261
|
init_environment();
|
|
37620
39262
|
init_logger();
|
|
37621
|
-
var
|
|
39263
|
+
var import_fs_extra10 = __toESM(require_lib(), 1);
|
|
37622
39264
|
|
|
37623
39265
|
class SettingsProcessor {
|
|
37624
39266
|
isGlobal = false;
|
|
@@ -37651,7 +39293,7 @@ class SettingsProcessor {
|
|
|
37651
39293
|
}
|
|
37652
39294
|
async processSettingsJson(sourceFile, destFile) {
|
|
37653
39295
|
try {
|
|
37654
|
-
const sourceContent = await
|
|
39296
|
+
const sourceContent = await import_fs_extra10.readFile(sourceFile, "utf-8");
|
|
37655
39297
|
let transformedSource = sourceContent;
|
|
37656
39298
|
if (this.isGlobal) {
|
|
37657
39299
|
const homeVar = isWindows() ? '"%USERPROFILE%"' : '"$HOME"';
|
|
@@ -37666,12 +39308,12 @@ class SettingsProcessor {
|
|
|
37666
39308
|
logger.debug(`Transformed .claude/ paths to ${projectDirVar}/.claude/ in settings.json for local installation`);
|
|
37667
39309
|
}
|
|
37668
39310
|
}
|
|
37669
|
-
const destExists = await
|
|
39311
|
+
const destExists = await import_fs_extra10.pathExists(destFile);
|
|
37670
39312
|
if (destExists && !this.forceOverwriteSettings) {
|
|
37671
39313
|
await this.selectiveMergeSettings(transformedSource, destFile);
|
|
37672
39314
|
} else {
|
|
37673
39315
|
const formattedContent = this.formatJsonContent(transformedSource);
|
|
37674
|
-
await
|
|
39316
|
+
await import_fs_extra10.writeFile(destFile, formattedContent, "utf-8");
|
|
37675
39317
|
try {
|
|
37676
39318
|
const parsedSettings = JSON.parse(formattedContent);
|
|
37677
39319
|
if (this.forceOverwriteSettings && destExists) {
|
|
@@ -37685,7 +39327,7 @@ class SettingsProcessor {
|
|
|
37685
39327
|
}
|
|
37686
39328
|
} catch (error) {
|
|
37687
39329
|
logger.error(`Failed to process settings.json: ${error}`);
|
|
37688
|
-
await
|
|
39330
|
+
await import_fs_extra10.copy(sourceFile, destFile, { overwrite: true });
|
|
37689
39331
|
}
|
|
37690
39332
|
}
|
|
37691
39333
|
async selectiveMergeSettings(transformedSourceContent, destFile) {
|
|
@@ -37695,7 +39337,7 @@ class SettingsProcessor {
|
|
|
37695
39337
|
} catch {
|
|
37696
39338
|
logger.warning("Failed to parse source settings.json, falling back to overwrite");
|
|
37697
39339
|
const formattedContent = this.formatJsonContent(transformedSourceContent);
|
|
37698
|
-
await
|
|
39340
|
+
await import_fs_extra10.writeFile(destFile, formattedContent, "utf-8");
|
|
37699
39341
|
return;
|
|
37700
39342
|
}
|
|
37701
39343
|
let destSettings;
|
|
@@ -37781,7 +39423,7 @@ class SettingsProcessor {
|
|
|
37781
39423
|
}
|
|
37782
39424
|
async readAndNormalizeGlobalSettings(destFile) {
|
|
37783
39425
|
try {
|
|
37784
|
-
const content = await
|
|
39426
|
+
const content = await import_fs_extra10.readFile(destFile, "utf-8");
|
|
37785
39427
|
if (!content.trim())
|
|
37786
39428
|
return null;
|
|
37787
39429
|
const homeVar = isWindows() ? "%USERPROFILE%" : "$HOME";
|
|
@@ -37890,10 +39532,10 @@ class CopyExecutor {
|
|
|
37890
39532
|
const conflicts = [];
|
|
37891
39533
|
const files = await this.fileScanner.getFiles(sourceDir, sourceDir);
|
|
37892
39534
|
for (const file of files) {
|
|
37893
|
-
const relativePath =
|
|
39535
|
+
const relativePath = relative7(sourceDir, file);
|
|
37894
39536
|
const normalizedRelativePath = relativePath.replace(/\\/g, "/");
|
|
37895
|
-
const destPath =
|
|
37896
|
-
if (await
|
|
39537
|
+
const destPath = join44(destDir, relativePath);
|
|
39538
|
+
if (await import_fs_extra11.pathExists(destPath)) {
|
|
37897
39539
|
if (this.fileScanner.shouldNeverCopy(normalizedRelativePath)) {
|
|
37898
39540
|
logger.debug(`Security-sensitive file exists but won't be overwritten: ${normalizedRelativePath}`);
|
|
37899
39541
|
continue;
|
|
@@ -37912,16 +39554,16 @@ class CopyExecutor {
|
|
|
37912
39554
|
let copiedCount = 0;
|
|
37913
39555
|
let skippedCount = 0;
|
|
37914
39556
|
for (const file of files) {
|
|
37915
|
-
const relativePath =
|
|
39557
|
+
const relativePath = relative7(sourceDir, file);
|
|
37916
39558
|
const normalizedRelativePath = relativePath.replace(/\\/g, "/");
|
|
37917
|
-
const destPath =
|
|
39559
|
+
const destPath = join44(destDir, relativePath);
|
|
37918
39560
|
if (this.fileScanner.shouldNeverCopy(normalizedRelativePath)) {
|
|
37919
39561
|
logger.debug(`Skipping security-sensitive file: ${normalizedRelativePath}`);
|
|
37920
39562
|
skippedCount++;
|
|
37921
39563
|
continue;
|
|
37922
39564
|
}
|
|
37923
39565
|
if (this.userConfigChecker.ignores(normalizedRelativePath)) {
|
|
37924
|
-
const fileExists = await
|
|
39566
|
+
const fileExists = await import_fs_extra11.pathExists(destPath);
|
|
37925
39567
|
if (fileExists) {
|
|
37926
39568
|
logger.debug(`Preserving user config: ${normalizedRelativePath}`);
|
|
37927
39569
|
skippedCount++;
|
|
@@ -37952,7 +39594,7 @@ class CopyExecutor {
|
|
|
37952
39594
|
continue;
|
|
37953
39595
|
}
|
|
37954
39596
|
}
|
|
37955
|
-
await withRetry2(() =>
|
|
39597
|
+
await withRetry2(() => import_fs_extra11.copy(file, destPath, { overwrite: true }));
|
|
37956
39598
|
this.trackInstalledFile(normalizedRelativePath);
|
|
37957
39599
|
copiedCount++;
|
|
37958
39600
|
}
|
|
@@ -37991,10 +39633,10 @@ class CopyExecutor {
|
|
|
37991
39633
|
}
|
|
37992
39634
|
trackInstalledFile(relativePath) {
|
|
37993
39635
|
this.installedFiles.add(relativePath);
|
|
37994
|
-
let dir =
|
|
39636
|
+
let dir = dirname9(relativePath);
|
|
37995
39637
|
while (dir && dir !== "." && dir !== "/") {
|
|
37996
39638
|
this.installedDirectories.add(`${dir}/`);
|
|
37997
|
-
dir =
|
|
39639
|
+
dir = dirname9(dir);
|
|
37998
39640
|
}
|
|
37999
39641
|
}
|
|
38000
39642
|
}
|
|
@@ -38084,15 +39726,15 @@ class FileMerger {
|
|
|
38084
39726
|
|
|
38085
39727
|
// src/domains/migration/legacy-migration.ts
|
|
38086
39728
|
import { readdir as readdir9, stat as stat7 } from "node:fs/promises";
|
|
38087
|
-
import { join as
|
|
39729
|
+
import { join as join48, relative as relative8 } from "node:path";
|
|
38088
39730
|
// src/services/file-operations/manifest/manifest-tracker.ts
|
|
38089
|
-
import { join as
|
|
39731
|
+
import { join as join47 } from "node:path";
|
|
38090
39732
|
|
|
38091
39733
|
// src/domains/migration/release-manifest.ts
|
|
38092
39734
|
init_logger();
|
|
38093
39735
|
init_zod();
|
|
38094
|
-
var
|
|
38095
|
-
import { join as
|
|
39736
|
+
var import_fs_extra12 = __toESM(require_lib(), 1);
|
|
39737
|
+
import { join as join45 } from "node:path";
|
|
38096
39738
|
var ReleaseManifestFileSchema = exports_external.object({
|
|
38097
39739
|
path: exports_external.string(),
|
|
38098
39740
|
checksum: exports_external.string().regex(/^[a-f0-9]{64}$/),
|
|
@@ -38107,9 +39749,9 @@ var ReleaseManifestSchema = exports_external.object({
|
|
|
38107
39749
|
|
|
38108
39750
|
class ReleaseManifestLoader {
|
|
38109
39751
|
static async load(extractDir) {
|
|
38110
|
-
const manifestPath =
|
|
39752
|
+
const manifestPath = join45(extractDir, "release-manifest.json");
|
|
38111
39753
|
try {
|
|
38112
|
-
const content = await
|
|
39754
|
+
const content = await import_fs_extra12.readFile(manifestPath, "utf-8");
|
|
38113
39755
|
const parsed = JSON.parse(content);
|
|
38114
39756
|
return ReleaseManifestSchema.parse(parsed);
|
|
38115
39757
|
} catch (error) {
|
|
@@ -38127,15 +39769,15 @@ init_environment();
|
|
|
38127
39769
|
init_logger();
|
|
38128
39770
|
|
|
38129
39771
|
// src/services/file-operations/manifest/manifest-updater.ts
|
|
38130
|
-
import { join as
|
|
39772
|
+
import { join as join46 } from "node:path";
|
|
38131
39773
|
init_logger();
|
|
38132
39774
|
init_types2();
|
|
38133
|
-
var
|
|
39775
|
+
var import_fs_extra13 = __toESM(require_lib(), 1);
|
|
38134
39776
|
var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
|
|
38135
39777
|
async function writeManifest(claudeDir, kitName, version, scope, kitType, trackedFiles, userConfigFiles) {
|
|
38136
|
-
const metadataPath =
|
|
39778
|
+
const metadataPath = join46(claudeDir, "metadata.json");
|
|
38137
39779
|
const kit = kitType || (/\bmarketing\b/i.test(kitName) ? "marketing" : "engineer");
|
|
38138
|
-
await
|
|
39780
|
+
await import_fs_extra13.ensureFile(metadataPath);
|
|
38139
39781
|
let release = null;
|
|
38140
39782
|
try {
|
|
38141
39783
|
release = await import_proper_lockfile2.lock(metadataPath, {
|
|
@@ -38148,9 +39790,9 @@ async function writeManifest(claudeDir, kitName, version, scope, kitType, tracke
|
|
|
38148
39790
|
logger.warning(`Metadata migration warning: ${migrationResult.error}`);
|
|
38149
39791
|
}
|
|
38150
39792
|
let existingMetadata = { kits: {} };
|
|
38151
|
-
if (await
|
|
39793
|
+
if (await import_fs_extra13.pathExists(metadataPath)) {
|
|
38152
39794
|
try {
|
|
38153
|
-
const content = await
|
|
39795
|
+
const content = await import_fs_extra13.readFile(metadataPath, "utf-8");
|
|
38154
39796
|
const parsed = JSON.parse(content);
|
|
38155
39797
|
if (parsed && typeof parsed === "object" && Object.keys(parsed).length > 0) {
|
|
38156
39798
|
existingMetadata = parsed;
|
|
@@ -38179,7 +39821,7 @@ async function writeManifest(claudeDir, kitName, version, scope, kitType, tracke
|
|
|
38179
39821
|
userConfigFiles: [...USER_CONFIG_PATTERNS, ...userConfigFiles]
|
|
38180
39822
|
};
|
|
38181
39823
|
const validated = MetadataSchema.parse(metadata);
|
|
38182
|
-
await
|
|
39824
|
+
await import_fs_extra13.writeFile(metadataPath, JSON.stringify(validated, null, 2), "utf-8");
|
|
38183
39825
|
logger.debug(`Wrote manifest for kit "${kit}" with ${trackedFiles.length} tracked files`);
|
|
38184
39826
|
} finally {
|
|
38185
39827
|
if (release) {
|
|
@@ -38189,8 +39831,8 @@ async function writeManifest(claudeDir, kitName, version, scope, kitType, tracke
|
|
|
38189
39831
|
}
|
|
38190
39832
|
}
|
|
38191
39833
|
async function removeKitFromManifest(claudeDir, kit) {
|
|
38192
|
-
const metadataPath =
|
|
38193
|
-
if (!await
|
|
39834
|
+
const metadataPath = join46(claudeDir, "metadata.json");
|
|
39835
|
+
if (!await import_fs_extra13.pathExists(metadataPath))
|
|
38194
39836
|
return false;
|
|
38195
39837
|
let release = null;
|
|
38196
39838
|
try {
|
|
@@ -38211,7 +39853,7 @@ async function removeKitFromManifest(claudeDir, kit) {
|
|
|
38211
39853
|
...metadata,
|
|
38212
39854
|
kits: remainingKits
|
|
38213
39855
|
};
|
|
38214
|
-
await
|
|
39856
|
+
await import_fs_extra13.writeFile(metadataPath, JSON.stringify(updated, null, 2), "utf-8");
|
|
38215
39857
|
logger.debug(`Removed kit "${kit}" from metadata, ${Object.keys(remainingKits).length} kit(s) remaining`);
|
|
38216
39858
|
return true;
|
|
38217
39859
|
} finally {
|
|
@@ -38319,7 +39961,7 @@ function buildFileTrackingList(options) {
|
|
|
38319
39961
|
if (!isGlobal && !installedPath.startsWith(".claude/"))
|
|
38320
39962
|
continue;
|
|
38321
39963
|
const relativePath = isGlobal ? installedPath : installedPath.replace(/^\.claude\//, "");
|
|
38322
|
-
const filePath =
|
|
39964
|
+
const filePath = join47(claudeDir, relativePath);
|
|
38323
39965
|
const manifestEntry = releaseManifest ? ReleaseManifestLoader.findFile(releaseManifest, installedPath) : null;
|
|
38324
39966
|
const ownership = manifestEntry ? "ck" : "user";
|
|
38325
39967
|
filesToTrack.push({
|
|
@@ -38392,7 +40034,7 @@ class ManifestWriter {
|
|
|
38392
40034
|
|
|
38393
40035
|
// src/domains/migration/legacy-migration.ts
|
|
38394
40036
|
init_logger();
|
|
38395
|
-
var
|
|
40037
|
+
var import_fs_extra14 = __toESM(require_lib(), 1);
|
|
38396
40038
|
class LegacyMigration {
|
|
38397
40039
|
static async detectLegacy(claudeDir) {
|
|
38398
40040
|
const metadata = await ManifestWriter.readManifest(claudeDir);
|
|
@@ -38425,7 +40067,7 @@ class LegacyMigration {
|
|
|
38425
40067
|
continue;
|
|
38426
40068
|
if (SKIP_DIRS_ALL.includes(entry))
|
|
38427
40069
|
continue;
|
|
38428
|
-
const fullPath =
|
|
40070
|
+
const fullPath = join48(dir, entry);
|
|
38429
40071
|
let stats;
|
|
38430
40072
|
try {
|
|
38431
40073
|
stats = await stat7(fullPath);
|
|
@@ -38458,7 +40100,7 @@ class LegacyMigration {
|
|
|
38458
40100
|
};
|
|
38459
40101
|
const filesInManifest = [];
|
|
38460
40102
|
for (const file of files) {
|
|
38461
|
-
const relativePath =
|
|
40103
|
+
const relativePath = relative8(claudeDir, file).replace(/\\/g, "/");
|
|
38462
40104
|
const manifestEntry = ReleaseManifestLoader.findFile(manifest, relativePath);
|
|
38463
40105
|
if (!manifestEntry) {
|
|
38464
40106
|
preview.userCreated.push(relativePath);
|
|
@@ -38527,7 +40169,7 @@ User-created files (sample):`);
|
|
|
38527
40169
|
];
|
|
38528
40170
|
if (filesToChecksum.length > 0) {
|
|
38529
40171
|
const checksumResults = await mapWithLimit(filesToChecksum, async ({ relativePath, ownership }) => {
|
|
38530
|
-
const fullPath =
|
|
40172
|
+
const fullPath = join48(claudeDir, relativePath);
|
|
38531
40173
|
const checksum = await OwnershipChecker.calculateChecksum(fullPath);
|
|
38532
40174
|
return { relativePath, checksum, ownership };
|
|
38533
40175
|
});
|
|
@@ -38548,8 +40190,8 @@ User-created files (sample):`);
|
|
|
38548
40190
|
installedAt: new Date().toISOString(),
|
|
38549
40191
|
files: trackedFiles
|
|
38550
40192
|
};
|
|
38551
|
-
const metadataPath =
|
|
38552
|
-
await
|
|
40193
|
+
const metadataPath = join48(claudeDir, "metadata.json");
|
|
40194
|
+
await import_fs_extra14.writeFile(metadataPath, JSON.stringify(updatedMetadata, null, 2));
|
|
38553
40195
|
logger.success(`Migration complete: tracked ${trackedFiles.length} files`);
|
|
38554
40196
|
return true;
|
|
38555
40197
|
}
|
|
@@ -38651,32 +40293,32 @@ function buildConflictSummary(fileConflicts, hookConflicts, mcpConflicts) {
|
|
|
38651
40293
|
}
|
|
38652
40294
|
|
|
38653
40295
|
// src/services/file-operations/file-scanner.ts
|
|
38654
|
-
import { join as
|
|
40296
|
+
import { join as join49, relative as relative9, resolve as resolve7 } from "node:path";
|
|
38655
40297
|
init_logger();
|
|
38656
|
-
var
|
|
40298
|
+
var import_fs_extra15 = __toESM(require_lib(), 1);
|
|
38657
40299
|
|
|
38658
40300
|
class FileScanner2 {
|
|
38659
40301
|
static async getFiles(dirPath, relativeTo) {
|
|
38660
40302
|
const basePath = relativeTo || dirPath;
|
|
38661
40303
|
const files = [];
|
|
38662
|
-
if (!await
|
|
40304
|
+
if (!await import_fs_extra15.pathExists(dirPath)) {
|
|
38663
40305
|
return files;
|
|
38664
40306
|
}
|
|
38665
40307
|
try {
|
|
38666
|
-
const entries = await
|
|
40308
|
+
const entries = await import_fs_extra15.readdir(dirPath, { encoding: "utf8" });
|
|
38667
40309
|
for (const entry of entries) {
|
|
38668
40310
|
if (SKIP_DIRS_ALL.includes(entry)) {
|
|
38669
40311
|
logger.debug(`Skipping directory: ${entry}`);
|
|
38670
40312
|
continue;
|
|
38671
40313
|
}
|
|
38672
|
-
const fullPath =
|
|
40314
|
+
const fullPath = join49(dirPath, entry);
|
|
38673
40315
|
if (!FileScanner2.isSafePath(basePath, fullPath)) {
|
|
38674
40316
|
logger.warning(`Skipping potentially unsafe path: ${entry}`);
|
|
38675
40317
|
continue;
|
|
38676
40318
|
}
|
|
38677
40319
|
let stats;
|
|
38678
40320
|
try {
|
|
38679
|
-
stats = await
|
|
40321
|
+
stats = await import_fs_extra15.lstat(fullPath);
|
|
38680
40322
|
} catch (error) {
|
|
38681
40323
|
if (error instanceof Error && "code" in error && (error.code === "EACCES" || error.code === "EPERM")) {
|
|
38682
40324
|
logger.warning(`Skipping inaccessible path: ${entry}`);
|
|
@@ -38692,7 +40334,7 @@ class FileScanner2 {
|
|
|
38692
40334
|
const subFiles = await FileScanner2.getFiles(fullPath, basePath);
|
|
38693
40335
|
files.push(...subFiles);
|
|
38694
40336
|
} else if (stats.isFile()) {
|
|
38695
|
-
const relativePath =
|
|
40337
|
+
const relativePath = relative9(basePath, fullPath);
|
|
38696
40338
|
files.push(FileScanner2.toPosixPath(relativePath));
|
|
38697
40339
|
}
|
|
38698
40340
|
}
|
|
@@ -38704,8 +40346,8 @@ class FileScanner2 {
|
|
|
38704
40346
|
return files;
|
|
38705
40347
|
}
|
|
38706
40348
|
static async findCustomFiles(destDir, sourceDir, subPath) {
|
|
38707
|
-
const destSubDir =
|
|
38708
|
-
const sourceSubDir =
|
|
40349
|
+
const destSubDir = join49(destDir, subPath);
|
|
40350
|
+
const sourceSubDir = join49(sourceDir, subPath);
|
|
38709
40351
|
logger.debug(`findCustomFiles - destDir: ${destDir}`);
|
|
38710
40352
|
logger.debug(`findCustomFiles - sourceDir: ${sourceDir}`);
|
|
38711
40353
|
logger.debug(`findCustomFiles - subPath: "${subPath}"`);
|
|
@@ -38715,7 +40357,7 @@ class FileScanner2 {
|
|
|
38715
40357
|
const sourceFiles = await FileScanner2.getFiles(sourceSubDir, sourceDir);
|
|
38716
40358
|
logger.debug(`findCustomFiles - destFiles count: ${destFiles.length}`);
|
|
38717
40359
|
logger.debug(`findCustomFiles - sourceFiles count: ${sourceFiles.length}`);
|
|
38718
|
-
const sourceExists = await
|
|
40360
|
+
const sourceExists = await import_fs_extra15.pathExists(sourceSubDir);
|
|
38719
40361
|
if (sourceExists && sourceFiles.length === 0 && destFiles.length > 100) {
|
|
38720
40362
|
logger.warning(`Source directory exists but is empty while destination has ${destFiles.length} files. This may indicate an extraction issue. Skipping custom file detection.`);
|
|
38721
40363
|
return [];
|
|
@@ -38733,8 +40375,8 @@ class FileScanner2 {
|
|
|
38733
40375
|
return customFiles;
|
|
38734
40376
|
}
|
|
38735
40377
|
static isSafePath(basePath, targetPath) {
|
|
38736
|
-
const resolvedBase =
|
|
38737
|
-
const resolvedTarget =
|
|
40378
|
+
const resolvedBase = resolve7(basePath);
|
|
40379
|
+
const resolvedTarget = resolve7(targetPath);
|
|
38738
40380
|
return resolvedTarget.startsWith(resolvedBase);
|
|
38739
40381
|
}
|
|
38740
40382
|
static toPosixPath(path11) {
|
|
@@ -38744,14 +40386,14 @@ class FileScanner2 {
|
|
|
38744
40386
|
|
|
38745
40387
|
// src/services/transformers/commands-prefix/prefix-applier.ts
|
|
38746
40388
|
init_logger();
|
|
38747
|
-
var
|
|
40389
|
+
var import_fs_extra16 = __toESM(require_lib(), 1);
|
|
38748
40390
|
import { lstat as lstat5, mkdir as mkdir16, readdir as readdir12, stat as stat8 } from "node:fs/promises";
|
|
38749
|
-
import { join as
|
|
40391
|
+
import { join as join51 } from "node:path";
|
|
38750
40392
|
|
|
38751
40393
|
// src/services/transformers/commands-prefix/content-transformer.ts
|
|
38752
40394
|
init_logger();
|
|
38753
|
-
import { readFile as
|
|
38754
|
-
import { join as
|
|
40395
|
+
import { readFile as readFile19, readdir as readdir11, writeFile as writeFile16 } from "node:fs/promises";
|
|
40396
|
+
import { join as join50 } from "node:path";
|
|
38755
40397
|
var TRANSFORMABLE_EXTENSIONS = new Set([
|
|
38756
40398
|
".md",
|
|
38757
40399
|
".txt",
|
|
@@ -38819,7 +40461,7 @@ async function transformCommandReferences(directory, options = {}) {
|
|
|
38819
40461
|
async function processDirectory(dir) {
|
|
38820
40462
|
const entries = await readdir11(dir, { withFileTypes: true });
|
|
38821
40463
|
for (const entry of entries) {
|
|
38822
|
-
const fullPath =
|
|
40464
|
+
const fullPath = join50(dir, entry.name);
|
|
38823
40465
|
if (entry.isDirectory()) {
|
|
38824
40466
|
if (entry.name === "node_modules" || entry.name.startsWith(".") && entry.name !== ".claude") {
|
|
38825
40467
|
continue;
|
|
@@ -38827,13 +40469,13 @@ async function transformCommandReferences(directory, options = {}) {
|
|
|
38827
40469
|
await processDirectory(fullPath);
|
|
38828
40470
|
} else if (entry.isFile() && shouldTransformFile(entry.name)) {
|
|
38829
40471
|
try {
|
|
38830
|
-
const content = await
|
|
40472
|
+
const content = await readFile19(fullPath, "utf-8");
|
|
38831
40473
|
const { transformed, changes } = transformCommandContent(content);
|
|
38832
40474
|
if (changes > 0) {
|
|
38833
40475
|
if (options.dryRun) {
|
|
38834
40476
|
logger.debug(`[dry-run] Would transform ${changes} command ref(s) in ${fullPath}`);
|
|
38835
40477
|
} else {
|
|
38836
|
-
await
|
|
40478
|
+
await writeFile16(fullPath, transformed, "utf-8");
|
|
38837
40479
|
if (options.verbose) {
|
|
38838
40480
|
logger.verbose(`Transformed ${changes} command ref(s) in ${fullPath}`);
|
|
38839
40481
|
}
|
|
@@ -38894,14 +40536,14 @@ function shouldApplyPrefix(options) {
|
|
|
38894
40536
|
// src/services/transformers/commands-prefix/prefix-applier.ts
|
|
38895
40537
|
async function applyPrefix(extractDir) {
|
|
38896
40538
|
validatePath(extractDir, "extractDir");
|
|
38897
|
-
const commandsDir =
|
|
38898
|
-
if (!await
|
|
40539
|
+
const commandsDir = join51(extractDir, ".claude", "commands");
|
|
40540
|
+
if (!await import_fs_extra16.pathExists(commandsDir)) {
|
|
38899
40541
|
logger.verbose("No commands directory found, skipping prefix application");
|
|
38900
40542
|
return;
|
|
38901
40543
|
}
|
|
38902
40544
|
logger.info("Applying /ck: prefix to slash commands...");
|
|
38903
|
-
const backupDir =
|
|
38904
|
-
const tempDir =
|
|
40545
|
+
const backupDir = join51(extractDir, ".commands-backup");
|
|
40546
|
+
const tempDir = join51(extractDir, ".commands-prefix-temp");
|
|
38905
40547
|
try {
|
|
38906
40548
|
const entries = await readdir12(commandsDir);
|
|
38907
40549
|
if (entries.length === 0) {
|
|
@@ -38909,28 +40551,28 @@ async function applyPrefix(extractDir) {
|
|
|
38909
40551
|
return;
|
|
38910
40552
|
}
|
|
38911
40553
|
if (entries.length === 1 && entries[0] === "ck") {
|
|
38912
|
-
const ckDir2 =
|
|
40554
|
+
const ckDir2 = join51(commandsDir, "ck");
|
|
38913
40555
|
const ckStat = await stat8(ckDir2);
|
|
38914
40556
|
if (ckStat.isDirectory()) {
|
|
38915
40557
|
logger.verbose("Commands already have /ck: prefix, skipping");
|
|
38916
40558
|
return;
|
|
38917
40559
|
}
|
|
38918
40560
|
}
|
|
38919
|
-
await
|
|
40561
|
+
await import_fs_extra16.copy(commandsDir, backupDir);
|
|
38920
40562
|
logger.verbose("Created backup of commands directory");
|
|
38921
40563
|
await mkdir16(tempDir, { recursive: true });
|
|
38922
|
-
const ckDir =
|
|
40564
|
+
const ckDir = join51(tempDir, "ck");
|
|
38923
40565
|
await mkdir16(ckDir, { recursive: true });
|
|
38924
40566
|
let processedCount = 0;
|
|
38925
40567
|
for (const entry of entries) {
|
|
38926
|
-
const sourcePath =
|
|
40568
|
+
const sourcePath = join51(commandsDir, entry);
|
|
38927
40569
|
const stats = await lstat5(sourcePath);
|
|
38928
40570
|
if (stats.isSymbolicLink()) {
|
|
38929
40571
|
logger.warning(`Skipping symlink for security: ${entry}`);
|
|
38930
40572
|
continue;
|
|
38931
40573
|
}
|
|
38932
|
-
const destPath =
|
|
38933
|
-
await
|
|
40574
|
+
const destPath = join51(ckDir, entry);
|
|
40575
|
+
await import_fs_extra16.copy(sourcePath, destPath, {
|
|
38934
40576
|
overwrite: false,
|
|
38935
40577
|
errorOnExist: true
|
|
38936
40578
|
});
|
|
@@ -38939,15 +40581,15 @@ async function applyPrefix(extractDir) {
|
|
|
38939
40581
|
}
|
|
38940
40582
|
if (processedCount === 0) {
|
|
38941
40583
|
logger.warning("No files to move (all were symlinks or invalid)");
|
|
38942
|
-
await
|
|
38943
|
-
await
|
|
40584
|
+
await import_fs_extra16.remove(backupDir);
|
|
40585
|
+
await import_fs_extra16.remove(tempDir);
|
|
38944
40586
|
return;
|
|
38945
40587
|
}
|
|
38946
|
-
await
|
|
38947
|
-
await
|
|
38948
|
-
await
|
|
40588
|
+
await import_fs_extra16.remove(commandsDir);
|
|
40589
|
+
await import_fs_extra16.move(tempDir, commandsDir);
|
|
40590
|
+
await import_fs_extra16.remove(backupDir);
|
|
38949
40591
|
logger.success("Successfully reorganized commands to /ck: prefix");
|
|
38950
|
-
const claudeDir =
|
|
40592
|
+
const claudeDir = join51(extractDir, ".claude");
|
|
38951
40593
|
logger.info("Transforming command references in file contents...");
|
|
38952
40594
|
const transformResult = await transformCommandReferences(claudeDir, {
|
|
38953
40595
|
verbose: logger.isVerbose()
|
|
@@ -38958,46 +40600,46 @@ async function applyPrefix(extractDir) {
|
|
|
38958
40600
|
logger.verbose("No command references needed transformation");
|
|
38959
40601
|
}
|
|
38960
40602
|
} catch (error) {
|
|
38961
|
-
if (await
|
|
40603
|
+
if (await import_fs_extra16.pathExists(backupDir)) {
|
|
38962
40604
|
try {
|
|
38963
|
-
await
|
|
38964
|
-
await
|
|
40605
|
+
await import_fs_extra16.remove(commandsDir).catch(() => {});
|
|
40606
|
+
await import_fs_extra16.move(backupDir, commandsDir);
|
|
38965
40607
|
logger.info("Restored original commands directory from backup");
|
|
38966
40608
|
} catch (rollbackError) {
|
|
38967
40609
|
logger.error(`Rollback failed: ${rollbackError}`);
|
|
38968
40610
|
}
|
|
38969
40611
|
}
|
|
38970
|
-
if (await
|
|
38971
|
-
await
|
|
40612
|
+
if (await import_fs_extra16.pathExists(tempDir)) {
|
|
40613
|
+
await import_fs_extra16.remove(tempDir).catch(() => {});
|
|
38972
40614
|
}
|
|
38973
40615
|
logger.error("Failed to apply /ck: prefix to commands");
|
|
38974
40616
|
throw error;
|
|
38975
40617
|
} finally {
|
|
38976
|
-
if (await
|
|
38977
|
-
await
|
|
40618
|
+
if (await import_fs_extra16.pathExists(backupDir)) {
|
|
40619
|
+
await import_fs_extra16.remove(backupDir).catch(() => {});
|
|
38978
40620
|
}
|
|
38979
|
-
if (await
|
|
38980
|
-
await
|
|
40621
|
+
if (await import_fs_extra16.pathExists(tempDir)) {
|
|
40622
|
+
await import_fs_extra16.remove(tempDir).catch(() => {});
|
|
38981
40623
|
}
|
|
38982
40624
|
}
|
|
38983
40625
|
}
|
|
38984
40626
|
|
|
38985
40627
|
// src/services/transformers/commands-prefix/prefix-cleaner.ts
|
|
38986
40628
|
import { lstat as lstat7, readdir as readdir14 } from "node:fs/promises";
|
|
38987
|
-
import { join as
|
|
40629
|
+
import { join as join53 } from "node:path";
|
|
38988
40630
|
init_logger();
|
|
38989
|
-
var
|
|
40631
|
+
var import_fs_extra18 = __toESM(require_lib(), 1);
|
|
38990
40632
|
|
|
38991
40633
|
// src/services/transformers/commands-prefix/file-processor.ts
|
|
38992
40634
|
import { lstat as lstat6, readdir as readdir13 } from "node:fs/promises";
|
|
38993
|
-
import { join as
|
|
40635
|
+
import { join as join52 } from "node:path";
|
|
38994
40636
|
init_logger();
|
|
38995
|
-
var
|
|
40637
|
+
var import_fs_extra17 = __toESM(require_lib(), 1);
|
|
38996
40638
|
async function scanDirectoryFiles(dir) {
|
|
38997
40639
|
const files = [];
|
|
38998
40640
|
const entries = await readdir13(dir);
|
|
38999
40641
|
for (const entry of entries) {
|
|
39000
|
-
const fullPath =
|
|
40642
|
+
const fullPath = join52(dir, entry);
|
|
39001
40643
|
const stats = await lstat6(fullPath);
|
|
39002
40644
|
if (stats.isSymbolicLink()) {
|
|
39003
40645
|
continue;
|
|
@@ -39020,7 +40662,7 @@ async function processFileOwnership(file, relativePath, metadata, claudeDir, opt
|
|
|
39020
40662
|
action: "delete"
|
|
39021
40663
|
});
|
|
39022
40664
|
if (!dryRun) {
|
|
39023
|
-
await
|
|
40665
|
+
await import_fs_extra17.remove(file);
|
|
39024
40666
|
logger.verbose(`Deleted CK file: ${relativePath}`);
|
|
39025
40667
|
}
|
|
39026
40668
|
accumulator.deletedCount++;
|
|
@@ -39035,7 +40677,7 @@ async function processFileOwnership(file, relativePath, metadata, claudeDir, opt
|
|
|
39035
40677
|
reason: "force overwrite"
|
|
39036
40678
|
});
|
|
39037
40679
|
if (!dryRun) {
|
|
39038
|
-
await
|
|
40680
|
+
await import_fs_extra17.remove(file);
|
|
39039
40681
|
logger.verbose(`Force-deleted modified file: ${relativePath}`);
|
|
39040
40682
|
}
|
|
39041
40683
|
accumulator.deletedCount++;
|
|
@@ -39059,7 +40701,7 @@ async function processFileOwnership(file, relativePath, metadata, claudeDir, opt
|
|
|
39059
40701
|
reason: "force overwrite"
|
|
39060
40702
|
});
|
|
39061
40703
|
if (!dryRun) {
|
|
39062
|
-
await
|
|
40704
|
+
await import_fs_extra17.remove(file);
|
|
39063
40705
|
logger.verbose(`Force-deleted user file: ${relativePath}`);
|
|
39064
40706
|
}
|
|
39065
40707
|
accumulator.deletedCount++;
|
|
@@ -39105,8 +40747,8 @@ function logCleanupSummary(deletedCount, preservedCount, dryRun, results) {
|
|
|
39105
40747
|
async function cleanupCommandsDirectory(targetDir, isGlobal, options = {}) {
|
|
39106
40748
|
const { dryRun = false } = options;
|
|
39107
40749
|
validatePath(targetDir, "targetDir");
|
|
39108
|
-
const claudeDir = isGlobal ? targetDir :
|
|
39109
|
-
const commandsDir =
|
|
40750
|
+
const claudeDir = isGlobal ? targetDir : join53(targetDir, ".claude");
|
|
40751
|
+
const commandsDir = join53(claudeDir, "commands");
|
|
39110
40752
|
const accumulator = {
|
|
39111
40753
|
results: [],
|
|
39112
40754
|
deletedCount: 0,
|
|
@@ -39118,7 +40760,7 @@ async function cleanupCommandsDirectory(targetDir, isGlobal, options = {}) {
|
|
|
39118
40760
|
preservedCount: 0,
|
|
39119
40761
|
wasDryRun: dryRun
|
|
39120
40762
|
};
|
|
39121
|
-
if (!await
|
|
40763
|
+
if (!await import_fs_extra18.pathExists(commandsDir)) {
|
|
39122
40764
|
logger.verbose(`Commands directory does not exist: ${commandsDir}`);
|
|
39123
40765
|
return result;
|
|
39124
40766
|
}
|
|
@@ -39140,7 +40782,7 @@ async function cleanupCommandsDirectory(targetDir, isGlobal, options = {}) {
|
|
|
39140
40782
|
return result;
|
|
39141
40783
|
}
|
|
39142
40784
|
for (const entry of entries) {
|
|
39143
|
-
const entryPath =
|
|
40785
|
+
const entryPath = join53(commandsDir, entry);
|
|
39144
40786
|
const stats = await lstat7(entryPath);
|
|
39145
40787
|
if (stats.isSymbolicLink()) {
|
|
39146
40788
|
addSymlinkSkip(entry, accumulator);
|
|
@@ -39169,7 +40811,7 @@ async function processDirectory(entryPath, entry, claudeDir, metadata, options,
|
|
|
39169
40811
|
}
|
|
39170
40812
|
}
|
|
39171
40813
|
if (canDeleteDir && !dryRun) {
|
|
39172
|
-
await
|
|
40814
|
+
await import_fs_extra18.remove(entryPath);
|
|
39173
40815
|
logger.verbose(`Removed directory: ${entry}`);
|
|
39174
40816
|
}
|
|
39175
40817
|
}
|
|
@@ -39184,7 +40826,7 @@ class CommandsPrefix {
|
|
|
39184
40826
|
// src/commands/init/phases/merge-handler.ts
|
|
39185
40827
|
init_logger();
|
|
39186
40828
|
init_output_manager();
|
|
39187
|
-
var
|
|
40829
|
+
var import_fs_extra19 = __toESM(require_lib(), 1);
|
|
39188
40830
|
async function handleMerge(ctx) {
|
|
39189
40831
|
if (ctx.cancelled || !ctx.extractDir || !ctx.resolvedDir || !ctx.claudeDir || !ctx.kit || !ctx.kitType) {
|
|
39190
40832
|
return ctx;
|
|
@@ -39193,7 +40835,7 @@ async function handleMerge(ctx) {
|
|
|
39193
40835
|
let customClaudeFiles = [];
|
|
39194
40836
|
if (!ctx.options.fresh) {
|
|
39195
40837
|
logger.info("Scanning for custom .claude files...");
|
|
39196
|
-
const scanSourceDir = ctx.options.global ?
|
|
40838
|
+
const scanSourceDir = ctx.options.global ? join54(ctx.extractDir, ".claude") : ctx.extractDir;
|
|
39197
40839
|
const scanTargetSubdir = ctx.options.global ? "" : ".claude";
|
|
39198
40840
|
customClaudeFiles = await FileScanner2.findCustomFiles(ctx.resolvedDir, scanSourceDir, scanTargetSubdir);
|
|
39199
40841
|
} else {
|
|
@@ -39237,7 +40879,7 @@ async function handleMerge(ctx) {
|
|
|
39237
40879
|
if (releaseManifest) {
|
|
39238
40880
|
merger.setManifest(releaseManifest);
|
|
39239
40881
|
}
|
|
39240
|
-
if (!ctx.options.fresh && await
|
|
40882
|
+
if (!ctx.options.fresh && await import_fs_extra19.pathExists(ctx.claudeDir)) {
|
|
39241
40883
|
const legacyDetection = await LegacyMigration.detectLegacy(ctx.claudeDir);
|
|
39242
40884
|
if (legacyDetection.isLegacy && releaseManifest) {
|
|
39243
40885
|
logger.info("Legacy installation detected - migrating to ownership tracking...");
|
|
@@ -39257,13 +40899,34 @@ async function handleMerge(ctx) {
|
|
|
39257
40899
|
return { ...ctx, cancelled: true };
|
|
39258
40900
|
}
|
|
39259
40901
|
}
|
|
39260
|
-
const sourceDir = ctx.options.global ?
|
|
40902
|
+
const sourceDir = ctx.options.global ? join54(ctx.extractDir, ".claude") : ctx.extractDir;
|
|
39261
40903
|
await merger.merge(sourceDir, ctx.resolvedDir, ctx.isNonInteractive);
|
|
39262
40904
|
const fileConflicts = merger.getFileConflicts();
|
|
39263
40905
|
if (fileConflicts.length > 0 && !ctx.isNonInteractive) {
|
|
39264
40906
|
const summary = buildConflictSummary(fileConflicts, [], []);
|
|
39265
40907
|
displayConflictSummary(summary);
|
|
39266
40908
|
}
|
|
40909
|
+
try {
|
|
40910
|
+
const sourceMetadataPath = join54(sourceDir, "metadata.json");
|
|
40911
|
+
if (await import_fs_extra19.pathExists(sourceMetadataPath)) {
|
|
40912
|
+
const metadataContent = await import_fs_extra19.readFile(sourceMetadataPath, "utf-8");
|
|
40913
|
+
const sourceMetadata = JSON.parse(metadataContent);
|
|
40914
|
+
if (sourceMetadata.deletions && sourceMetadata.deletions.length > 0) {
|
|
40915
|
+
const deletionResult = await handleDeletions(sourceMetadata, ctx.claudeDir);
|
|
40916
|
+
if (deletionResult.deletedPaths.length > 0) {
|
|
40917
|
+
logger.info(`Removed ${deletionResult.deletedPaths.length} deprecated file(s)`);
|
|
40918
|
+
for (const path11 of deletionResult.deletedPaths) {
|
|
40919
|
+
logger.verbose(` - ${path11}`);
|
|
40920
|
+
}
|
|
40921
|
+
}
|
|
40922
|
+
if (deletionResult.preservedPaths.length > 0) {
|
|
40923
|
+
logger.verbose(`Preserved ${deletionResult.preservedPaths.length} user-owned file(s)`);
|
|
40924
|
+
}
|
|
40925
|
+
}
|
|
40926
|
+
}
|
|
40927
|
+
} catch (error) {
|
|
40928
|
+
logger.debug(`Cleanup of deprecated files failed: ${error}`);
|
|
40929
|
+
}
|
|
39267
40930
|
const installedFiles = merger.getAllInstalledFiles();
|
|
39268
40931
|
const filesToTrack = buildFileTrackingList({
|
|
39269
40932
|
installedFiles,
|
|
@@ -39286,11 +40949,11 @@ async function handleMerge(ctx) {
|
|
|
39286
40949
|
};
|
|
39287
40950
|
}
|
|
39288
40951
|
// src/commands/init/phases/migration-handler.ts
|
|
39289
|
-
import { join as
|
|
40952
|
+
import { join as join62 } from "node:path";
|
|
39290
40953
|
|
|
39291
40954
|
// src/domains/skills/skills-detector.ts
|
|
39292
40955
|
init_logger();
|
|
39293
|
-
var
|
|
40956
|
+
var import_fs_extra22 = __toESM(require_lib(), 1);
|
|
39294
40957
|
|
|
39295
40958
|
// src/domains/skills/detection/config-detector.ts
|
|
39296
40959
|
init_logger();
|
|
@@ -39298,17 +40961,17 @@ init_logger();
|
|
|
39298
40961
|
// src/domains/skills/skills-manifest.ts
|
|
39299
40962
|
init_logger();
|
|
39300
40963
|
import { createHash as createHash2 } from "node:crypto";
|
|
39301
|
-
import { readFile as
|
|
39302
|
-
import { join as
|
|
40964
|
+
import { readFile as readFile21, readdir as readdir15, writeFile as writeFile17 } from "node:fs/promises";
|
|
40965
|
+
import { join as join55, relative as relative10 } from "node:path";
|
|
39303
40966
|
init_types2();
|
|
39304
|
-
var
|
|
40967
|
+
var import_fs_extra20 = __toESM(require_lib(), 1);
|
|
39305
40968
|
|
|
39306
40969
|
class SkillsManifestManager {
|
|
39307
40970
|
static MANIFEST_FILENAME = ".skills-manifest.json";
|
|
39308
40971
|
static MANIFEST_VERSION = "1.0.0";
|
|
39309
40972
|
static async generateManifest(skillsDir) {
|
|
39310
40973
|
logger.debug(`Generating manifest for: ${skillsDir}`);
|
|
39311
|
-
if (!await
|
|
40974
|
+
if (!await import_fs_extra20.pathExists(skillsDir)) {
|
|
39312
40975
|
throw new SkillsMigrationError(`Skills directory does not exist: ${skillsDir}`);
|
|
39313
40976
|
}
|
|
39314
40977
|
const structure = await SkillsManifestManager.detectStructure(skillsDir);
|
|
@@ -39323,18 +40986,18 @@ class SkillsManifestManager {
|
|
|
39323
40986
|
return manifest;
|
|
39324
40987
|
}
|
|
39325
40988
|
static async writeManifest(skillsDir, manifest) {
|
|
39326
|
-
const manifestPath =
|
|
39327
|
-
await
|
|
40989
|
+
const manifestPath = join55(skillsDir, SkillsManifestManager.MANIFEST_FILENAME);
|
|
40990
|
+
await writeFile17(manifestPath, JSON.stringify(manifest, null, 2), "utf-8");
|
|
39328
40991
|
logger.debug(`Wrote manifest to: ${manifestPath}`);
|
|
39329
40992
|
}
|
|
39330
40993
|
static async readManifest(skillsDir) {
|
|
39331
|
-
const manifestPath =
|
|
39332
|
-
if (!await
|
|
40994
|
+
const manifestPath = join55(skillsDir, SkillsManifestManager.MANIFEST_FILENAME);
|
|
40995
|
+
if (!await import_fs_extra20.pathExists(manifestPath)) {
|
|
39333
40996
|
logger.debug(`No manifest found at: ${manifestPath}`);
|
|
39334
40997
|
return null;
|
|
39335
40998
|
}
|
|
39336
40999
|
try {
|
|
39337
|
-
const content = await
|
|
41000
|
+
const content = await readFile21(manifestPath, "utf-8");
|
|
39338
41001
|
const data = JSON.parse(content);
|
|
39339
41002
|
const manifest = SkillsManifestSchema.parse(data);
|
|
39340
41003
|
logger.debug(`Read manifest from: ${manifestPath}`);
|
|
@@ -39351,7 +41014,7 @@ class SkillsManifestManager {
|
|
|
39351
41014
|
return "flat";
|
|
39352
41015
|
}
|
|
39353
41016
|
for (const dir of dirs.slice(0, 3)) {
|
|
39354
|
-
const dirPath =
|
|
41017
|
+
const dirPath = join55(skillsDir, dir.name);
|
|
39355
41018
|
const subEntries = await readdir15(dirPath, { withFileTypes: true });
|
|
39356
41019
|
const hasSubdirs = subEntries.some((entry) => entry.isDirectory());
|
|
39357
41020
|
if (hasSubdirs) {
|
|
@@ -39370,7 +41033,7 @@ class SkillsManifestManager {
|
|
|
39370
41033
|
const entries = await readdir15(skillsDir, { withFileTypes: true });
|
|
39371
41034
|
for (const entry of entries) {
|
|
39372
41035
|
if (entry.isDirectory() && !BUILD_ARTIFACT_DIRS.includes(entry.name) && !entry.name.startsWith(".")) {
|
|
39373
|
-
const skillPath =
|
|
41036
|
+
const skillPath = join55(skillsDir, entry.name);
|
|
39374
41037
|
const hash = await SkillsManifestManager.hashDirectory(skillPath);
|
|
39375
41038
|
skills.push({
|
|
39376
41039
|
name: entry.name,
|
|
@@ -39382,11 +41045,11 @@ class SkillsManifestManager {
|
|
|
39382
41045
|
const categories = await readdir15(skillsDir, { withFileTypes: true });
|
|
39383
41046
|
for (const category of categories) {
|
|
39384
41047
|
if (category.isDirectory() && !BUILD_ARTIFACT_DIRS.includes(category.name) && !category.name.startsWith(".")) {
|
|
39385
|
-
const categoryPath =
|
|
41048
|
+
const categoryPath = join55(skillsDir, category.name);
|
|
39386
41049
|
const skillEntries = await readdir15(categoryPath, { withFileTypes: true });
|
|
39387
41050
|
for (const skillEntry of skillEntries) {
|
|
39388
41051
|
if (skillEntry.isDirectory() && !skillEntry.name.startsWith(".")) {
|
|
39389
|
-
const skillPath =
|
|
41052
|
+
const skillPath = join55(categoryPath, skillEntry.name);
|
|
39390
41053
|
const hash = await SkillsManifestManager.hashDirectory(skillPath);
|
|
39391
41054
|
skills.push({
|
|
39392
41055
|
name: skillEntry.name,
|
|
@@ -39405,8 +41068,8 @@ class SkillsManifestManager {
|
|
|
39405
41068
|
const files = await SkillsManifestManager.getAllFiles(dirPath);
|
|
39406
41069
|
files.sort();
|
|
39407
41070
|
for (const file of files) {
|
|
39408
|
-
const relativePath =
|
|
39409
|
-
const content = await
|
|
41071
|
+
const relativePath = relative10(dirPath, file);
|
|
41072
|
+
const content = await readFile21(file);
|
|
39410
41073
|
hash.update(relativePath);
|
|
39411
41074
|
hash.update(content);
|
|
39412
41075
|
}
|
|
@@ -39416,7 +41079,7 @@ class SkillsManifestManager {
|
|
|
39416
41079
|
const files = [];
|
|
39417
41080
|
const entries = await readdir15(dirPath, { withFileTypes: true });
|
|
39418
41081
|
for (const entry of entries) {
|
|
39419
|
-
const fullPath =
|
|
41082
|
+
const fullPath = join55(dirPath, entry.name);
|
|
39420
41083
|
if (entry.name.startsWith(".") || BUILD_ARTIFACT_DIRS.includes(entry.name)) {
|
|
39421
41084
|
continue;
|
|
39422
41085
|
}
|
|
@@ -39536,11 +41199,11 @@ function getPathMapping(skillName, oldBasePath, newBasePath) {
|
|
|
39536
41199
|
}
|
|
39537
41200
|
|
|
39538
41201
|
// src/domains/skills/detection/script-detector.ts
|
|
39539
|
-
var
|
|
41202
|
+
var import_fs_extra21 = __toESM(require_lib(), 1);
|
|
39540
41203
|
import { readdir as readdir16 } from "node:fs/promises";
|
|
39541
|
-
import { join as
|
|
41204
|
+
import { join as join56 } from "node:path";
|
|
39542
41205
|
async function scanDirectory(skillsDir) {
|
|
39543
|
-
if (!await
|
|
41206
|
+
if (!await import_fs_extra21.pathExists(skillsDir)) {
|
|
39544
41207
|
return ["flat", []];
|
|
39545
41208
|
}
|
|
39546
41209
|
const entries = await readdir16(skillsDir, { withFileTypes: true });
|
|
@@ -39551,12 +41214,12 @@ async function scanDirectory(skillsDir) {
|
|
|
39551
41214
|
let totalSkillLikeCount = 0;
|
|
39552
41215
|
const allSkills = [];
|
|
39553
41216
|
for (const dir of dirs) {
|
|
39554
|
-
const dirPath =
|
|
41217
|
+
const dirPath = join56(skillsDir, dir.name);
|
|
39555
41218
|
const subEntries = await readdir16(dirPath, { withFileTypes: true });
|
|
39556
41219
|
const subdirs = subEntries.filter((entry) => entry.isDirectory() && !entry.name.startsWith("."));
|
|
39557
41220
|
if (subdirs.length > 0) {
|
|
39558
41221
|
for (const subdir of subdirs.slice(0, 3)) {
|
|
39559
|
-
const subdirPath =
|
|
41222
|
+
const subdirPath = join56(dirPath, subdir.name);
|
|
39560
41223
|
const subdirFiles = await readdir16(subdirPath, { withFileTypes: true });
|
|
39561
41224
|
const hasSkillMarker = subdirFiles.some((file) => file.isFile() && (file.name === "skill.md" || file.name === "README.md" || file.name === "readme.md" || file.name === "config.json" || file.name === "package.json"));
|
|
39562
41225
|
if (hasSkillMarker) {
|
|
@@ -39678,8 +41341,8 @@ async function detectViaManifest(oldSkillsDir, currentSkillsDir) {
|
|
|
39678
41341
|
class SkillsMigrationDetector {
|
|
39679
41342
|
static async detectMigration(oldSkillsDir, currentSkillsDir) {
|
|
39680
41343
|
logger.debug("Detecting skills migration need...");
|
|
39681
|
-
const oldExists = await
|
|
39682
|
-
const currentExists = await
|
|
41344
|
+
const oldExists = await import_fs_extra22.pathExists(oldSkillsDir);
|
|
41345
|
+
const currentExists = await import_fs_extra22.pathExists(currentSkillsDir);
|
|
39683
41346
|
if (!oldExists && !currentExists) {
|
|
39684
41347
|
logger.debug("No skills directories found, migration not needed");
|
|
39685
41348
|
return {
|
|
@@ -39713,13 +41376,13 @@ class SkillsMigrationDetector {
|
|
|
39713
41376
|
// src/domains/skills/skills-migrator.ts
|
|
39714
41377
|
init_logger();
|
|
39715
41378
|
init_types2();
|
|
39716
|
-
import { join as
|
|
41379
|
+
import { join as join61 } from "node:path";
|
|
39717
41380
|
|
|
39718
41381
|
// src/domains/skills/migrator/migration-executor.ts
|
|
39719
41382
|
init_logger();
|
|
39720
41383
|
import { copyFile as copyFile4, mkdir as mkdir17, readdir as readdir17, rm as rm3 } from "node:fs/promises";
|
|
39721
|
-
import { join as
|
|
39722
|
-
var
|
|
41384
|
+
import { join as join57 } from "node:path";
|
|
41385
|
+
var import_fs_extra23 = __toESM(require_lib(), 1);
|
|
39723
41386
|
|
|
39724
41387
|
// src/domains/skills/skills-migration-prompts.ts
|
|
39725
41388
|
init_environment();
|
|
@@ -39883,8 +41546,8 @@ async function copySkillDirectory(sourceDir, destDir) {
|
|
|
39883
41546
|
await mkdir17(destDir, { recursive: true });
|
|
39884
41547
|
const entries = await readdir17(sourceDir, { withFileTypes: true });
|
|
39885
41548
|
for (const entry of entries) {
|
|
39886
|
-
const sourcePath =
|
|
39887
|
-
const destPath =
|
|
41549
|
+
const sourcePath = join57(sourceDir, entry.name);
|
|
41550
|
+
const destPath = join57(destDir, entry.name);
|
|
39888
41551
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.isSymbolicLink()) {
|
|
39889
41552
|
continue;
|
|
39890
41553
|
}
|
|
@@ -39899,14 +41562,14 @@ async function executeInternal(mappings, customizations, currentSkillsDir, inter
|
|
|
39899
41562
|
const migrated = [];
|
|
39900
41563
|
const preserved = [];
|
|
39901
41564
|
const errors2 = [];
|
|
39902
|
-
const tempDir =
|
|
41565
|
+
const tempDir = join57(currentSkillsDir, "..", ".skills-migration-temp");
|
|
39903
41566
|
await mkdir17(tempDir, { recursive: true });
|
|
39904
41567
|
try {
|
|
39905
41568
|
for (const mapping of mappings) {
|
|
39906
41569
|
try {
|
|
39907
41570
|
const skillName = mapping.skillName;
|
|
39908
41571
|
const currentSkillPath = mapping.oldPath;
|
|
39909
|
-
if (!await
|
|
41572
|
+
if (!await import_fs_extra23.pathExists(currentSkillPath)) {
|
|
39910
41573
|
logger.warning(`Skill not found, skipping: ${skillName}`);
|
|
39911
41574
|
continue;
|
|
39912
41575
|
}
|
|
@@ -39920,9 +41583,9 @@ async function executeInternal(mappings, customizations, currentSkillsDir, inter
|
|
|
39920
41583
|
}
|
|
39921
41584
|
}
|
|
39922
41585
|
const category = mapping.category;
|
|
39923
|
-
const targetPath = category ?
|
|
41586
|
+
const targetPath = category ? join57(tempDir, category, skillName) : join57(tempDir, skillName);
|
|
39924
41587
|
if (category) {
|
|
39925
|
-
await mkdir17(
|
|
41588
|
+
await mkdir17(join57(tempDir, category), { recursive: true });
|
|
39926
41589
|
}
|
|
39927
41590
|
await copySkillDirectory(currentSkillPath, targetPath);
|
|
39928
41591
|
migrated.push(skillName);
|
|
@@ -39987,9 +41650,9 @@ function validateMigrationPath(path11, paramName) {
|
|
|
39987
41650
|
// src/domains/skills/skills-backup-manager.ts
|
|
39988
41651
|
init_logger();
|
|
39989
41652
|
init_types2();
|
|
39990
|
-
var
|
|
41653
|
+
var import_fs_extra24 = __toESM(require_lib(), 1);
|
|
39991
41654
|
import { copyFile as copyFile5, mkdir as mkdir18, readdir as readdir18, rm as rm4, stat as stat9 } from "node:fs/promises";
|
|
39992
|
-
import { basename as basename2, join as
|
|
41655
|
+
import { basename as basename2, join as join58, normalize as normalize6 } from "node:path";
|
|
39993
41656
|
function validatePath2(path11, paramName) {
|
|
39994
41657
|
if (!path11 || typeof path11 !== "string") {
|
|
39995
41658
|
throw new SkillsMigrationError(`${paramName} must be a non-empty string`);
|
|
@@ -40009,13 +41672,13 @@ class SkillsBackupManager {
|
|
|
40009
41672
|
if (parentDir) {
|
|
40010
41673
|
validatePath2(parentDir, "parentDir");
|
|
40011
41674
|
}
|
|
40012
|
-
if (!await
|
|
41675
|
+
if (!await import_fs_extra24.pathExists(skillsDir)) {
|
|
40013
41676
|
throw new SkillsMigrationError(`Cannot create backup: Skills directory does not exist: ${skillsDir}`);
|
|
40014
41677
|
}
|
|
40015
41678
|
const timestamp = Date.now();
|
|
40016
41679
|
const randomSuffix = Math.random().toString(36).substring(2, 8);
|
|
40017
41680
|
const backupDirName = `${SkillsBackupManager.BACKUP_PREFIX}${timestamp}-${randomSuffix}`;
|
|
40018
|
-
const backupDir = parentDir ?
|
|
41681
|
+
const backupDir = parentDir ? join58(parentDir, backupDirName) : join58(skillsDir, "..", backupDirName);
|
|
40019
41682
|
logger.info(`Creating backup at: ${backupDir}`);
|
|
40020
41683
|
try {
|
|
40021
41684
|
await mkdir18(backupDir, { recursive: true });
|
|
@@ -40032,12 +41695,12 @@ class SkillsBackupManager {
|
|
|
40032
41695
|
static async restoreBackup(backupDir, targetDir) {
|
|
40033
41696
|
validatePath2(backupDir, "backupDir");
|
|
40034
41697
|
validatePath2(targetDir, "targetDir");
|
|
40035
|
-
if (!await
|
|
41698
|
+
if (!await import_fs_extra24.pathExists(backupDir)) {
|
|
40036
41699
|
throw new SkillsMigrationError(`Cannot restore: Backup directory does not exist: ${backupDir}`);
|
|
40037
41700
|
}
|
|
40038
41701
|
logger.info(`Restoring from backup: ${backupDir}`);
|
|
40039
41702
|
try {
|
|
40040
|
-
if (await
|
|
41703
|
+
if (await import_fs_extra24.pathExists(targetDir)) {
|
|
40041
41704
|
await rm4(targetDir, { recursive: true, force: true });
|
|
40042
41705
|
}
|
|
40043
41706
|
await mkdir18(targetDir, { recursive: true });
|
|
@@ -40048,7 +41711,7 @@ class SkillsBackupManager {
|
|
|
40048
41711
|
}
|
|
40049
41712
|
}
|
|
40050
41713
|
static async deleteBackup(backupDir) {
|
|
40051
|
-
if (!await
|
|
41714
|
+
if (!await import_fs_extra24.pathExists(backupDir)) {
|
|
40052
41715
|
logger.warning(`Backup directory does not exist: ${backupDir}`);
|
|
40053
41716
|
return;
|
|
40054
41717
|
}
|
|
@@ -40061,12 +41724,12 @@ class SkillsBackupManager {
|
|
|
40061
41724
|
}
|
|
40062
41725
|
}
|
|
40063
41726
|
static async listBackups(parentDir) {
|
|
40064
|
-
if (!await
|
|
41727
|
+
if (!await import_fs_extra24.pathExists(parentDir)) {
|
|
40065
41728
|
return [];
|
|
40066
41729
|
}
|
|
40067
41730
|
try {
|
|
40068
41731
|
const entries = await readdir18(parentDir, { withFileTypes: true });
|
|
40069
|
-
const backups = entries.filter((entry) => entry.isDirectory() && entry.name.startsWith(SkillsBackupManager.BACKUP_PREFIX)).map((entry) =>
|
|
41732
|
+
const backups = entries.filter((entry) => entry.isDirectory() && entry.name.startsWith(SkillsBackupManager.BACKUP_PREFIX)).map((entry) => join58(parentDir, entry.name));
|
|
40070
41733
|
backups.sort().reverse();
|
|
40071
41734
|
return backups;
|
|
40072
41735
|
} catch (error) {
|
|
@@ -40086,7 +41749,7 @@ class SkillsBackupManager {
|
|
|
40086
41749
|
}
|
|
40087
41750
|
}
|
|
40088
41751
|
static async getBackupSize(backupDir) {
|
|
40089
|
-
if (!await
|
|
41752
|
+
if (!await import_fs_extra24.pathExists(backupDir)) {
|
|
40090
41753
|
return 0;
|
|
40091
41754
|
}
|
|
40092
41755
|
return await SkillsBackupManager.getDirectorySize(backupDir);
|
|
@@ -40094,8 +41757,8 @@ class SkillsBackupManager {
|
|
|
40094
41757
|
static async copyDirectory(sourceDir, destDir) {
|
|
40095
41758
|
const entries = await readdir18(sourceDir, { withFileTypes: true });
|
|
40096
41759
|
for (const entry of entries) {
|
|
40097
|
-
const sourcePath =
|
|
40098
|
-
const destPath =
|
|
41760
|
+
const sourcePath = join58(sourceDir, entry.name);
|
|
41761
|
+
const destPath = join58(destDir, entry.name);
|
|
40099
41762
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.isSymbolicLink()) {
|
|
40100
41763
|
continue;
|
|
40101
41764
|
}
|
|
@@ -40111,7 +41774,7 @@ class SkillsBackupManager {
|
|
|
40111
41774
|
let size = 0;
|
|
40112
41775
|
const entries = await readdir18(dirPath, { withFileTypes: true });
|
|
40113
41776
|
for (const entry of entries) {
|
|
40114
|
-
const fullPath =
|
|
41777
|
+
const fullPath = join58(dirPath, entry.name);
|
|
40115
41778
|
if (entry.isSymbolicLink()) {
|
|
40116
41779
|
continue;
|
|
40117
41780
|
}
|
|
@@ -40139,19 +41802,19 @@ class SkillsBackupManager {
|
|
|
40139
41802
|
init_logger();
|
|
40140
41803
|
|
|
40141
41804
|
// src/domains/skills/customization/comparison-engine.ts
|
|
40142
|
-
var
|
|
40143
|
-
import { relative as
|
|
41805
|
+
var import_fs_extra25 = __toESM(require_lib(), 1);
|
|
41806
|
+
import { relative as relative12 } from "node:path";
|
|
40144
41807
|
|
|
40145
41808
|
// src/domains/skills/customization/hash-calculator.ts
|
|
40146
41809
|
import { createHash as createHash3 } from "node:crypto";
|
|
40147
41810
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
40148
|
-
import { readFile as
|
|
40149
|
-
import { join as
|
|
41811
|
+
import { readFile as readFile22, readdir as readdir19 } from "node:fs/promises";
|
|
41812
|
+
import { join as join59, relative as relative11 } from "node:path";
|
|
40150
41813
|
async function getAllFiles(dirPath) {
|
|
40151
41814
|
const files = [];
|
|
40152
41815
|
const entries = await readdir19(dirPath, { withFileTypes: true });
|
|
40153
41816
|
for (const entry of entries) {
|
|
40154
|
-
const fullPath =
|
|
41817
|
+
const fullPath = join59(dirPath, entry.name);
|
|
40155
41818
|
if (entry.name.startsWith(".") || BUILD_ARTIFACT_DIRS.includes(entry.name) || entry.isSymbolicLink()) {
|
|
40156
41819
|
continue;
|
|
40157
41820
|
}
|
|
@@ -40165,12 +41828,12 @@ async function getAllFiles(dirPath) {
|
|
|
40165
41828
|
return files;
|
|
40166
41829
|
}
|
|
40167
41830
|
async function hashFile(filePath) {
|
|
40168
|
-
return new Promise((
|
|
41831
|
+
return new Promise((resolve8, reject) => {
|
|
40169
41832
|
const hash = createHash3("sha256");
|
|
40170
41833
|
const stream = createReadStream2(filePath);
|
|
40171
41834
|
stream.on("data", (chunk) => hash.update(chunk));
|
|
40172
41835
|
stream.on("end", () => {
|
|
40173
|
-
|
|
41836
|
+
resolve8(hash.digest("hex"));
|
|
40174
41837
|
});
|
|
40175
41838
|
stream.on("error", (error) => {
|
|
40176
41839
|
stream.destroy();
|
|
@@ -40183,8 +41846,8 @@ async function hashDirectory(dirPath) {
|
|
|
40183
41846
|
const files = await getAllFiles(dirPath);
|
|
40184
41847
|
files.sort();
|
|
40185
41848
|
for (const file of files) {
|
|
40186
|
-
const relativePath =
|
|
40187
|
-
const content = await
|
|
41849
|
+
const relativePath = relative11(dirPath, file);
|
|
41850
|
+
const content = await readFile22(file);
|
|
40188
41851
|
hash.update(relativePath);
|
|
40189
41852
|
hash.update(content);
|
|
40190
41853
|
}
|
|
@@ -40217,8 +41880,8 @@ async function compareDirectories(dir1, dir2) {
|
|
|
40217
41880
|
if (files1.length !== files2.length) {
|
|
40218
41881
|
return true;
|
|
40219
41882
|
}
|
|
40220
|
-
const relFiles1 = files1.map((f3) =>
|
|
40221
|
-
const relFiles2 = files2.map((f3) =>
|
|
41883
|
+
const relFiles1 = files1.map((f3) => relative12(dir1, f3)).sort();
|
|
41884
|
+
const relFiles2 = files2.map((f3) => relative12(dir2, f3)).sort();
|
|
40222
41885
|
if (JSON.stringify(relFiles1) !== JSON.stringify(relFiles2)) {
|
|
40223
41886
|
return true;
|
|
40224
41887
|
}
|
|
@@ -40234,14 +41897,14 @@ async function compareDirectories(dir1, dir2) {
|
|
|
40234
41897
|
async function detectFileChanges(currentSkillPath, baselineSkillPath) {
|
|
40235
41898
|
const changes = [];
|
|
40236
41899
|
const currentFiles = await getAllFiles(currentSkillPath);
|
|
40237
|
-
const baselineFiles = await
|
|
41900
|
+
const baselineFiles = await import_fs_extra25.pathExists(baselineSkillPath) ? await getAllFiles(baselineSkillPath) : [];
|
|
40238
41901
|
const currentFileMap = new Map(await Promise.all(currentFiles.map(async (f3) => {
|
|
40239
|
-
const relPath =
|
|
41902
|
+
const relPath = relative12(currentSkillPath, f3);
|
|
40240
41903
|
const hash = await hashFile(f3);
|
|
40241
41904
|
return [relPath, hash];
|
|
40242
41905
|
})));
|
|
40243
41906
|
const baselineFileMap = new Map(await Promise.all(baselineFiles.map(async (f3) => {
|
|
40244
|
-
const relPath =
|
|
41907
|
+
const relPath = relative12(baselineSkillPath, f3);
|
|
40245
41908
|
const hash = await hashFile(f3);
|
|
40246
41909
|
return [relPath, hash];
|
|
40247
41910
|
})));
|
|
@@ -40276,9 +41939,9 @@ async function detectFileChanges(currentSkillPath, baselineSkillPath) {
|
|
|
40276
41939
|
|
|
40277
41940
|
// src/domains/skills/customization/scan-reporter.ts
|
|
40278
41941
|
init_types2();
|
|
40279
|
-
var
|
|
41942
|
+
var import_fs_extra26 = __toESM(require_lib(), 1);
|
|
40280
41943
|
import { readdir as readdir20 } from "node:fs/promises";
|
|
40281
|
-
import { join as
|
|
41944
|
+
import { join as join60, normalize as normalize7 } from "node:path";
|
|
40282
41945
|
function validatePath3(path11, paramName) {
|
|
40283
41946
|
if (!path11 || typeof path11 !== "string") {
|
|
40284
41947
|
throw new SkillsMigrationError(`${paramName} must be a non-empty string`);
|
|
@@ -40291,7 +41954,7 @@ function validatePath3(path11, paramName) {
|
|
|
40291
41954
|
}
|
|
40292
41955
|
}
|
|
40293
41956
|
async function scanSkillsDirectory(skillsDir) {
|
|
40294
|
-
if (!await
|
|
41957
|
+
if (!await import_fs_extra26.pathExists(skillsDir)) {
|
|
40295
41958
|
return ["flat", []];
|
|
40296
41959
|
}
|
|
40297
41960
|
const entries = await readdir20(skillsDir, { withFileTypes: true });
|
|
@@ -40299,13 +41962,13 @@ async function scanSkillsDirectory(skillsDir) {
|
|
|
40299
41962
|
if (dirs.length === 0) {
|
|
40300
41963
|
return ["flat", []];
|
|
40301
41964
|
}
|
|
40302
|
-
const firstDirPath =
|
|
41965
|
+
const firstDirPath = join60(skillsDir, dirs[0].name);
|
|
40303
41966
|
const subEntries = await readdir20(firstDirPath, { withFileTypes: true });
|
|
40304
41967
|
const subdirs = subEntries.filter((entry) => entry.isDirectory() && !entry.name.startsWith("."));
|
|
40305
41968
|
if (subdirs.length > 0) {
|
|
40306
41969
|
let skillLikeCount = 0;
|
|
40307
41970
|
for (const subdir of subdirs.slice(0, 3)) {
|
|
40308
|
-
const subdirPath =
|
|
41971
|
+
const subdirPath = join60(firstDirPath, subdir.name);
|
|
40309
41972
|
const subdirFiles = await readdir20(subdirPath, { withFileTypes: true });
|
|
40310
41973
|
const hasSkillMarker = subdirFiles.some((file) => file.isFile() && (file.name === "skill.md" || file.name === "README.md" || file.name === "readme.md" || file.name === "config.json" || file.name === "package.json"));
|
|
40311
41974
|
if (hasSkillMarker) {
|
|
@@ -40315,7 +41978,7 @@ async function scanSkillsDirectory(skillsDir) {
|
|
|
40315
41978
|
if (skillLikeCount > 0) {
|
|
40316
41979
|
const skills = [];
|
|
40317
41980
|
for (const dir of dirs) {
|
|
40318
|
-
const categoryPath =
|
|
41981
|
+
const categoryPath = join60(skillsDir, dir.name);
|
|
40319
41982
|
const skillDirs = await readdir20(categoryPath, { withFileTypes: true });
|
|
40320
41983
|
skills.push(...skillDirs.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name));
|
|
40321
41984
|
}
|
|
@@ -40325,8 +41988,8 @@ async function scanSkillsDirectory(skillsDir) {
|
|
|
40325
41988
|
return ["flat", dirs.map((dir) => dir.name)];
|
|
40326
41989
|
}
|
|
40327
41990
|
async function findSkillPath(skillsDir, skillName) {
|
|
40328
|
-
const flatPath =
|
|
40329
|
-
if (await
|
|
41991
|
+
const flatPath = join60(skillsDir, skillName);
|
|
41992
|
+
if (await import_fs_extra26.pathExists(flatPath)) {
|
|
40330
41993
|
return { path: flatPath, category: undefined };
|
|
40331
41994
|
}
|
|
40332
41995
|
const entries = await readdir20(skillsDir, { withFileTypes: true });
|
|
@@ -40334,9 +41997,9 @@ async function findSkillPath(skillsDir, skillName) {
|
|
|
40334
41997
|
if (!entry.isDirectory() || entry.name.startsWith(".") || entry.name === "node_modules") {
|
|
40335
41998
|
continue;
|
|
40336
41999
|
}
|
|
40337
|
-
const categoryPath =
|
|
40338
|
-
const skillPath =
|
|
40339
|
-
if (await
|
|
42000
|
+
const categoryPath = join60(skillsDir, entry.name);
|
|
42001
|
+
const skillPath = join60(categoryPath, skillName);
|
|
42002
|
+
if (await import_fs_extra26.pathExists(skillPath)) {
|
|
40340
42003
|
return { path: skillPath, category: entry.name };
|
|
40341
42004
|
}
|
|
40342
42005
|
}
|
|
@@ -40429,7 +42092,7 @@ class SkillsMigrator {
|
|
|
40429
42092
|
}
|
|
40430
42093
|
}
|
|
40431
42094
|
if (options.backup && !options.dryRun) {
|
|
40432
|
-
const claudeDir =
|
|
42095
|
+
const claudeDir = join61(currentSkillsDir, "..");
|
|
40433
42096
|
result.backupPath = await SkillsBackupManager.createBackup(currentSkillsDir, claudeDir);
|
|
40434
42097
|
logger.success(`Backup created at: ${result.backupPath}`);
|
|
40435
42098
|
}
|
|
@@ -40482,7 +42145,7 @@ class SkillsMigrator {
|
|
|
40482
42145
|
// src/commands/init/phases/migration-handler.ts
|
|
40483
42146
|
init_logger();
|
|
40484
42147
|
init_path_resolver();
|
|
40485
|
-
var
|
|
42148
|
+
var import_fs_extra27 = __toESM(require_lib(), 1);
|
|
40486
42149
|
async function handleMigration(ctx) {
|
|
40487
42150
|
if (ctx.cancelled || !ctx.extractDir || !ctx.resolvedDir)
|
|
40488
42151
|
return ctx;
|
|
@@ -40490,9 +42153,9 @@ async function handleMigration(ctx) {
|
|
|
40490
42153
|
logger.debug("Skipping skills migration (fresh installation)");
|
|
40491
42154
|
return ctx;
|
|
40492
42155
|
}
|
|
40493
|
-
const newSkillsDir =
|
|
42156
|
+
const newSkillsDir = join62(ctx.extractDir, ".claude", "skills");
|
|
40494
42157
|
const currentSkillsDir = PathResolver.buildSkillsPath(ctx.resolvedDir, ctx.options.global);
|
|
40495
|
-
if (!await
|
|
42158
|
+
if (!await import_fs_extra27.pathExists(newSkillsDir) || !await import_fs_extra27.pathExists(currentSkillsDir)) {
|
|
40496
42159
|
return ctx;
|
|
40497
42160
|
}
|
|
40498
42161
|
logger.info("Checking for skills directory migration...");
|
|
@@ -40514,13 +42177,13 @@ async function handleMigration(ctx) {
|
|
|
40514
42177
|
}
|
|
40515
42178
|
// src/commands/init/phases/opencode-handler.ts
|
|
40516
42179
|
import { cp, readdir as readdir22, rm as rm5 } from "node:fs/promises";
|
|
40517
|
-
import { join as
|
|
42180
|
+
import { join as join64 } from "node:path";
|
|
40518
42181
|
|
|
40519
42182
|
// src/services/transformers/opencode-path-transformer.ts
|
|
40520
42183
|
init_logger();
|
|
40521
|
-
import { readFile as
|
|
42184
|
+
import { readFile as readFile23, readdir as readdir21, writeFile as writeFile18 } from "node:fs/promises";
|
|
40522
42185
|
import { platform as platform10 } from "node:os";
|
|
40523
|
-
import { extname as extname2, join as
|
|
42186
|
+
import { extname as extname2, join as join63 } from "node:path";
|
|
40524
42187
|
var IS_WINDOWS3 = platform10() === "win32";
|
|
40525
42188
|
function getOpenCodeGlobalPath() {
|
|
40526
42189
|
return "$HOME/.config/opencode/";
|
|
@@ -40581,7 +42244,7 @@ async function transformPathsForGlobalOpenCode(directory, options = {}) {
|
|
|
40581
42244
|
async function processDirectory2(dir) {
|
|
40582
42245
|
const entries = await readdir21(dir, { withFileTypes: true });
|
|
40583
42246
|
for (const entry of entries) {
|
|
40584
|
-
const fullPath =
|
|
42247
|
+
const fullPath = join63(dir, entry.name);
|
|
40585
42248
|
if (entry.isDirectory()) {
|
|
40586
42249
|
if (entry.name === "node_modules" || entry.name.startsWith(".")) {
|
|
40587
42250
|
continue;
|
|
@@ -40589,10 +42252,10 @@ async function transformPathsForGlobalOpenCode(directory, options = {}) {
|
|
|
40589
42252
|
await processDirectory2(fullPath);
|
|
40590
42253
|
} else if (entry.isFile() && shouldTransformFile2(entry.name)) {
|
|
40591
42254
|
try {
|
|
40592
|
-
const content = await
|
|
42255
|
+
const content = await readFile23(fullPath, "utf-8");
|
|
40593
42256
|
const { transformed, changes } = transformOpenCodeContent(content);
|
|
40594
42257
|
if (changes > 0) {
|
|
40595
|
-
await
|
|
42258
|
+
await writeFile18(fullPath, transformed, "utf-8");
|
|
40596
42259
|
filesTransformed++;
|
|
40597
42260
|
totalChanges += changes;
|
|
40598
42261
|
if (options.verbose) {
|
|
@@ -40615,13 +42278,13 @@ async function transformPathsForGlobalOpenCode(directory, options = {}) {
|
|
|
40615
42278
|
// src/commands/init/phases/opencode-handler.ts
|
|
40616
42279
|
init_logger();
|
|
40617
42280
|
init_path_resolver();
|
|
40618
|
-
var
|
|
42281
|
+
var import_fs_extra28 = __toESM(require_lib(), 1);
|
|
40619
42282
|
async function handleOpenCode(ctx) {
|
|
40620
42283
|
if (ctx.cancelled || !ctx.extractDir || !ctx.resolvedDir) {
|
|
40621
42284
|
return ctx;
|
|
40622
42285
|
}
|
|
40623
|
-
const openCodeSource =
|
|
40624
|
-
if (!await
|
|
42286
|
+
const openCodeSource = join64(ctx.extractDir, ".opencode");
|
|
42287
|
+
if (!await import_fs_extra28.pathExists(openCodeSource)) {
|
|
40625
42288
|
logger.debug("No .opencode directory in archive, skipping");
|
|
40626
42289
|
return ctx;
|
|
40627
42290
|
}
|
|
@@ -40635,12 +42298,12 @@ async function handleOpenCode(ctx) {
|
|
|
40635
42298
|
if (transformResult.totalChanges > 0) {
|
|
40636
42299
|
logger.success(`Transformed ${transformResult.totalChanges} OpenCode path(s) in ${transformResult.filesTransformed} file(s)`);
|
|
40637
42300
|
}
|
|
40638
|
-
await
|
|
42301
|
+
await import_fs_extra28.ensureDir(targetDir);
|
|
40639
42302
|
const entries = await readdir22(openCodeSource, { withFileTypes: true });
|
|
40640
42303
|
for (const entry of entries) {
|
|
40641
|
-
const sourcePath =
|
|
40642
|
-
const targetPath =
|
|
40643
|
-
if (await
|
|
42304
|
+
const sourcePath = join64(openCodeSource, entry.name);
|
|
42305
|
+
const targetPath = join64(targetDir, entry.name);
|
|
42306
|
+
if (await import_fs_extra28.pathExists(targetPath)) {
|
|
40644
42307
|
if (!ctx.options.forceOverwrite) {
|
|
40645
42308
|
logger.verbose(`Skipping existing: ${entry.name}`);
|
|
40646
42309
|
continue;
|
|
@@ -40660,18 +42323,18 @@ async function handleOpenCode(ctx) {
|
|
|
40660
42323
|
init_logger();
|
|
40661
42324
|
init_path_resolver();
|
|
40662
42325
|
init_types2();
|
|
40663
|
-
import { existsSync as
|
|
40664
|
-
import { mkdir as mkdir19, readFile as
|
|
42326
|
+
import { existsSync as existsSync19 } from "node:fs";
|
|
42327
|
+
import { mkdir as mkdir19, readFile as readFile24, rename as rename2, rm as rm6, writeFile as writeFile19 } from "node:fs/promises";
|
|
40665
42328
|
import { chmod as chmod2 } from "node:fs/promises";
|
|
40666
42329
|
import { platform as platform11 } from "node:os";
|
|
40667
|
-
import { join as
|
|
42330
|
+
import { join as join65 } from "node:path";
|
|
40668
42331
|
var PROJECT_CONFIG_FILE = ".ck.json";
|
|
40669
42332
|
|
|
40670
42333
|
class ConfigManager {
|
|
40671
42334
|
static config = null;
|
|
40672
42335
|
static globalFlag = false;
|
|
40673
42336
|
static getProjectConfigDir(projectDir, global3) {
|
|
40674
|
-
return global3 ? projectDir :
|
|
42337
|
+
return global3 ? projectDir : join65(projectDir, ".claude");
|
|
40675
42338
|
}
|
|
40676
42339
|
static setGlobalFlag(global3) {
|
|
40677
42340
|
ConfigManager.globalFlag = global3;
|
|
@@ -40686,8 +42349,8 @@ class ConfigManager {
|
|
|
40686
42349
|
}
|
|
40687
42350
|
const configFile = PathResolver.getConfigFile(ConfigManager.globalFlag);
|
|
40688
42351
|
try {
|
|
40689
|
-
if (
|
|
40690
|
-
const content = await
|
|
42352
|
+
if (existsSync19(configFile)) {
|
|
42353
|
+
const content = await readFile24(configFile, "utf-8");
|
|
40691
42354
|
const data = JSON.parse(content);
|
|
40692
42355
|
ConfigManager.config = ConfigSchema.parse(data);
|
|
40693
42356
|
logger.debug(`Config loaded from ${configFile}`);
|
|
@@ -40704,13 +42367,13 @@ class ConfigManager {
|
|
|
40704
42367
|
const validConfig = ConfigSchema.parse(config);
|
|
40705
42368
|
const configDir = PathResolver.getConfigDir(ConfigManager.globalFlag);
|
|
40706
42369
|
const configFile = PathResolver.getConfigFile(ConfigManager.globalFlag);
|
|
40707
|
-
if (!
|
|
42370
|
+
if (!existsSync19(configDir)) {
|
|
40708
42371
|
await mkdir19(configDir, { recursive: true });
|
|
40709
42372
|
if (platform11() !== "win32") {
|
|
40710
42373
|
await chmod2(configDir, 448);
|
|
40711
42374
|
}
|
|
40712
42375
|
}
|
|
40713
|
-
await
|
|
42376
|
+
await writeFile19(configFile, JSON.stringify(validConfig, null, 2), "utf-8");
|
|
40714
42377
|
if (platform11() !== "win32") {
|
|
40715
42378
|
await chmod2(configFile, 384);
|
|
40716
42379
|
}
|
|
@@ -40738,10 +42401,10 @@ class ConfigManager {
|
|
|
40738
42401
|
}
|
|
40739
42402
|
static async loadProjectConfig(projectDir, global3 = false) {
|
|
40740
42403
|
const configDir = ConfigManager.getProjectConfigDir(projectDir, global3);
|
|
40741
|
-
const configPath =
|
|
42404
|
+
const configPath = join65(configDir, PROJECT_CONFIG_FILE);
|
|
40742
42405
|
try {
|
|
40743
|
-
if (
|
|
40744
|
-
const content = await
|
|
42406
|
+
if (existsSync19(configPath)) {
|
|
42407
|
+
const content = await readFile24(configPath, "utf-8");
|
|
40745
42408
|
const data = JSON.parse(content);
|
|
40746
42409
|
const folders = FoldersConfigSchema.parse(data.paths || data);
|
|
40747
42410
|
logger.debug(`Project config loaded from ${configPath}`);
|
|
@@ -40754,15 +42417,15 @@ class ConfigManager {
|
|
|
40754
42417
|
}
|
|
40755
42418
|
static async saveProjectConfig(projectDir, folders, global3 = false) {
|
|
40756
42419
|
const configDir = ConfigManager.getProjectConfigDir(projectDir, global3);
|
|
40757
|
-
const configPath =
|
|
42420
|
+
const configPath = join65(configDir, PROJECT_CONFIG_FILE);
|
|
40758
42421
|
try {
|
|
40759
|
-
if (!
|
|
42422
|
+
if (!existsSync19(configDir)) {
|
|
40760
42423
|
await mkdir19(configDir, { recursive: true });
|
|
40761
42424
|
}
|
|
40762
42425
|
let existingConfig = {};
|
|
40763
|
-
if (
|
|
42426
|
+
if (existsSync19(configPath)) {
|
|
40764
42427
|
try {
|
|
40765
|
-
const content = await
|
|
42428
|
+
const content = await readFile24(configPath, "utf-8");
|
|
40766
42429
|
existingConfig = JSON.parse(content);
|
|
40767
42430
|
} catch (error) {
|
|
40768
42431
|
logger.debug(`Could not parse existing config, starting fresh: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
@@ -40777,7 +42440,7 @@ class ConfigManager {
|
|
|
40777
42440
|
...validFolders
|
|
40778
42441
|
}
|
|
40779
42442
|
};
|
|
40780
|
-
await
|
|
42443
|
+
await writeFile19(configPath, JSON.stringify(mergedConfig, null, 2), "utf-8");
|
|
40781
42444
|
logger.debug(`Project config saved to ${configPath}`);
|
|
40782
42445
|
} catch (error) {
|
|
40783
42446
|
throw new Error(`Failed to save project config: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
@@ -40803,21 +42466,21 @@ class ConfigManager {
|
|
|
40803
42466
|
}
|
|
40804
42467
|
static projectConfigExists(projectDir, global3 = false) {
|
|
40805
42468
|
const configDir = ConfigManager.getProjectConfigDir(projectDir, global3);
|
|
40806
|
-
return
|
|
42469
|
+
return existsSync19(join65(configDir, PROJECT_CONFIG_FILE));
|
|
40807
42470
|
}
|
|
40808
42471
|
static async migrateNestedConfig(globalDir) {
|
|
40809
|
-
const correctPath =
|
|
40810
|
-
const incorrectPath =
|
|
40811
|
-
if (
|
|
42472
|
+
const correctPath = join65(globalDir, PROJECT_CONFIG_FILE);
|
|
42473
|
+
const incorrectPath = join65(globalDir, ".claude", PROJECT_CONFIG_FILE);
|
|
42474
|
+
if (existsSync19(correctPath)) {
|
|
40812
42475
|
logger.debug("Config already exists at correct location, skipping migration");
|
|
40813
42476
|
return false;
|
|
40814
42477
|
}
|
|
40815
|
-
if (
|
|
42478
|
+
if (existsSync19(incorrectPath)) {
|
|
40816
42479
|
try {
|
|
40817
42480
|
logger.info("Migrating .ck.json from nested location to correct location...");
|
|
40818
42481
|
await rename2(incorrectPath, correctPath);
|
|
40819
42482
|
logger.success(`Migrated ${PROJECT_CONFIG_FILE} to ${correctPath}`);
|
|
40820
|
-
const nestedClaudeDir =
|
|
42483
|
+
const nestedClaudeDir = join65(globalDir, ".claude");
|
|
40821
42484
|
try {
|
|
40822
42485
|
await rm6(nestedClaudeDir, { recursive: false });
|
|
40823
42486
|
logger.debug("Removed empty nested .claude directory");
|
|
@@ -40908,20 +42571,20 @@ Please use only one download method.`);
|
|
|
40908
42571
|
};
|
|
40909
42572
|
}
|
|
40910
42573
|
// src/commands/init/phases/post-install-handler.ts
|
|
40911
|
-
import { join as
|
|
42574
|
+
import { join as join66 } from "node:path";
|
|
40912
42575
|
init_logger();
|
|
40913
42576
|
init_path_resolver();
|
|
40914
|
-
var
|
|
42577
|
+
var import_fs_extra29 = __toESM(require_lib(), 1);
|
|
40915
42578
|
async function handlePostInstall(ctx) {
|
|
40916
42579
|
if (ctx.cancelled || !ctx.extractDir || !ctx.resolvedDir || !ctx.claudeDir) {
|
|
40917
42580
|
return ctx;
|
|
40918
42581
|
}
|
|
40919
42582
|
if (ctx.options.global) {
|
|
40920
|
-
const claudeMdSource =
|
|
40921
|
-
const claudeMdDest =
|
|
40922
|
-
if (await
|
|
40923
|
-
if (!await
|
|
40924
|
-
await
|
|
42583
|
+
const claudeMdSource = join66(ctx.extractDir, "CLAUDE.md");
|
|
42584
|
+
const claudeMdDest = join66(ctx.resolvedDir, "CLAUDE.md");
|
|
42585
|
+
if (await import_fs_extra29.pathExists(claudeMdSource)) {
|
|
42586
|
+
if (!await import_fs_extra29.pathExists(claudeMdDest)) {
|
|
42587
|
+
await import_fs_extra29.copy(claudeMdSource, claudeMdDest);
|
|
40925
42588
|
logger.success("Copied CLAUDE.md to global directory");
|
|
40926
42589
|
} else {
|
|
40927
42590
|
logger.debug("CLAUDE.md already exists in global directory (preserved)");
|
|
@@ -40966,7 +42629,7 @@ async function handlePostInstall(ctx) {
|
|
|
40966
42629
|
}
|
|
40967
42630
|
if (!ctx.options.skipSetup) {
|
|
40968
42631
|
await promptSetupWizardIfNeeded({
|
|
40969
|
-
envPath:
|
|
42632
|
+
envPath: join66(ctx.claudeDir, ".env"),
|
|
40970
42633
|
claudeDir: ctx.claudeDir,
|
|
40971
42634
|
isGlobal: ctx.options.global,
|
|
40972
42635
|
isNonInteractive: ctx.isNonInteractive,
|
|
@@ -40980,7 +42643,7 @@ async function handlePostInstall(ctx) {
|
|
|
40980
42643
|
}
|
|
40981
42644
|
// src/commands/init/phases/selection-handler.ts
|
|
40982
42645
|
import { mkdir as mkdir20 } from "node:fs/promises";
|
|
40983
|
-
import { join as
|
|
42646
|
+
import { join as join68, resolve as resolve9 } from "node:path";
|
|
40984
42647
|
init_github_client();
|
|
40985
42648
|
|
|
40986
42649
|
// src/domains/github/kit-access-checker.ts
|
|
@@ -41109,10 +42772,10 @@ async function runPreflightChecks() {
|
|
|
41109
42772
|
}
|
|
41110
42773
|
|
|
41111
42774
|
// src/domains/installation/fresh-installer.ts
|
|
41112
|
-
import { existsSync as
|
|
41113
|
-
import { dirname as
|
|
42775
|
+
import { existsSync as existsSync20, readdirSync as readdirSync2, rmSync as rmSync3, rmdirSync as rmdirSync2, unlinkSync as unlinkSync4 } from "node:fs";
|
|
42776
|
+
import { dirname as dirname10, join as join67, resolve as resolve8 } from "node:path";
|
|
41114
42777
|
init_logger();
|
|
41115
|
-
var
|
|
42778
|
+
var import_fs_extra30 = __toESM(require_lib(), 1);
|
|
41116
42779
|
var CLAUDEKIT_SUBDIRECTORIES = ["commands", "agents", "skills", "rules", "hooks"];
|
|
41117
42780
|
async function analyzeFreshInstallation(claudeDir) {
|
|
41118
42781
|
const metadata = await readManifest(claudeDir);
|
|
@@ -41156,16 +42819,16 @@ async function analyzeFreshInstallation(claudeDir) {
|
|
|
41156
42819
|
hasMetadata: true
|
|
41157
42820
|
};
|
|
41158
42821
|
}
|
|
41159
|
-
function
|
|
41160
|
-
const normalizedClaudeDir =
|
|
41161
|
-
let currentDir =
|
|
42822
|
+
function cleanupEmptyDirectories2(filePath, claudeDir) {
|
|
42823
|
+
const normalizedClaudeDir = resolve8(claudeDir);
|
|
42824
|
+
let currentDir = resolve8(dirname10(filePath));
|
|
41162
42825
|
while (currentDir !== normalizedClaudeDir && currentDir.startsWith(normalizedClaudeDir)) {
|
|
41163
42826
|
try {
|
|
41164
|
-
const entries =
|
|
42827
|
+
const entries = readdirSync2(currentDir);
|
|
41165
42828
|
if (entries.length === 0) {
|
|
41166
|
-
|
|
42829
|
+
rmdirSync2(currentDir);
|
|
41167
42830
|
logger.debug(`Removed empty directory: ${currentDir}`);
|
|
41168
|
-
currentDir =
|
|
42831
|
+
currentDir = resolve8(dirname10(currentDir));
|
|
41169
42832
|
} else {
|
|
41170
42833
|
break;
|
|
41171
42834
|
}
|
|
@@ -41182,13 +42845,13 @@ async function removeFilesByOwnership(claudeDir, analysis, includeModified) {
|
|
|
41182
42845
|
const filesToRemove = includeModified ? [...analysis.ckFiles, ...analysis.ckModifiedFiles] : analysis.ckFiles;
|
|
41183
42846
|
const filesToPreserve = includeModified ? analysis.userFiles : [...analysis.ckModifiedFiles, ...analysis.userFiles];
|
|
41184
42847
|
for (const file of filesToRemove) {
|
|
41185
|
-
const fullPath =
|
|
42848
|
+
const fullPath = join67(claudeDir, file.path);
|
|
41186
42849
|
try {
|
|
41187
|
-
if (
|
|
41188
|
-
|
|
42850
|
+
if (existsSync20(fullPath)) {
|
|
42851
|
+
unlinkSync4(fullPath);
|
|
41189
42852
|
removedFiles.push(file.path);
|
|
41190
42853
|
logger.debug(`Removed: ${file.path}`);
|
|
41191
|
-
|
|
42854
|
+
cleanupEmptyDirectories2(fullPath, claudeDir);
|
|
41192
42855
|
}
|
|
41193
42856
|
} catch (error) {
|
|
41194
42857
|
logger.debug(`Failed to remove ${file.path}: ${error}`);
|
|
@@ -41207,13 +42870,13 @@ async function removeFilesByOwnership(claudeDir, analysis, includeModified) {
|
|
|
41207
42870
|
};
|
|
41208
42871
|
}
|
|
41209
42872
|
async function updateMetadataAfterFresh(claudeDir, removedFiles) {
|
|
41210
|
-
const metadataPath =
|
|
41211
|
-
if (!await
|
|
42873
|
+
const metadataPath = join67(claudeDir, "metadata.json");
|
|
42874
|
+
if (!await import_fs_extra30.pathExists(metadataPath)) {
|
|
41212
42875
|
return;
|
|
41213
42876
|
}
|
|
41214
42877
|
let content;
|
|
41215
42878
|
try {
|
|
41216
|
-
content = await
|
|
42879
|
+
content = await import_fs_extra30.readFile(metadataPath, "utf-8");
|
|
41217
42880
|
} catch (readError) {
|
|
41218
42881
|
logger.warning(`Failed to read metadata.json: ${readError instanceof Error ? readError.message : String(readError)}`);
|
|
41219
42882
|
return;
|
|
@@ -41239,7 +42902,7 @@ async function updateMetadataAfterFresh(claudeDir, removedFiles) {
|
|
|
41239
42902
|
metadata.files = metadata.files.filter((f3) => !removedSet.has(f3.path));
|
|
41240
42903
|
}
|
|
41241
42904
|
try {
|
|
41242
|
-
await
|
|
42905
|
+
await import_fs_extra30.writeFile(metadataPath, JSON.stringify(metadata, null, 2));
|
|
41243
42906
|
logger.debug(`Updated metadata.json, removed ${removedFiles.length} file entries`);
|
|
41244
42907
|
} catch (writeError) {
|
|
41245
42908
|
logger.warning(`Failed to write metadata.json: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
|
|
@@ -41250,17 +42913,17 @@ async function removeSubdirectoriesFallback(claudeDir) {
|
|
|
41250
42913
|
const removedFiles = [];
|
|
41251
42914
|
let removedDirCount = 0;
|
|
41252
42915
|
for (const subdir of CLAUDEKIT_SUBDIRECTORIES) {
|
|
41253
|
-
const subdirPath =
|
|
41254
|
-
if (await
|
|
41255
|
-
|
|
42916
|
+
const subdirPath = join67(claudeDir, subdir);
|
|
42917
|
+
if (await import_fs_extra30.pathExists(subdirPath)) {
|
|
42918
|
+
rmSync3(subdirPath, { recursive: true, force: true });
|
|
41256
42919
|
removedDirCount++;
|
|
41257
42920
|
removedFiles.push(`${subdir}/ (entire directory)`);
|
|
41258
42921
|
logger.debug(`Removed subdirectory: ${subdir}/`);
|
|
41259
42922
|
}
|
|
41260
42923
|
}
|
|
41261
|
-
const metadataPath =
|
|
41262
|
-
if (await
|
|
41263
|
-
|
|
42924
|
+
const metadataPath = join67(claudeDir, "metadata.json");
|
|
42925
|
+
if (await import_fs_extra30.pathExists(metadataPath)) {
|
|
42926
|
+
unlinkSync4(metadataPath);
|
|
41264
42927
|
removedFiles.push("metadata.json");
|
|
41265
42928
|
}
|
|
41266
42929
|
return {
|
|
@@ -41272,7 +42935,7 @@ async function removeSubdirectoriesFallback(claudeDir) {
|
|
|
41272
42935
|
};
|
|
41273
42936
|
}
|
|
41274
42937
|
async function handleFreshInstallation(claudeDir, prompts) {
|
|
41275
|
-
if (!await
|
|
42938
|
+
if (!await import_fs_extra30.pathExists(claudeDir)) {
|
|
41276
42939
|
logger.info(".claude directory does not exist, proceeding with fresh installation");
|
|
41277
42940
|
return true;
|
|
41278
42941
|
}
|
|
@@ -41306,7 +42969,7 @@ async function handleFreshInstallation(claudeDir, prompts) {
|
|
|
41306
42969
|
init_logger();
|
|
41307
42970
|
init_path_resolver();
|
|
41308
42971
|
init_types2();
|
|
41309
|
-
var
|
|
42972
|
+
var import_fs_extra31 = __toESM(require_lib(), 1);
|
|
41310
42973
|
|
|
41311
42974
|
// src/commands/init/types.ts
|
|
41312
42975
|
function isSyncContext(ctx) {
|
|
@@ -41475,7 +43138,7 @@ async function handleSelection(ctx) {
|
|
|
41475
43138
|
}
|
|
41476
43139
|
}
|
|
41477
43140
|
}
|
|
41478
|
-
const resolvedDir =
|
|
43141
|
+
const resolvedDir = resolve9(targetDir);
|
|
41479
43142
|
logger.info(`Target directory: ${resolvedDir}`);
|
|
41480
43143
|
if (!ctx.options.global && PathResolver.isLocalSameAsGlobal(resolvedDir)) {
|
|
41481
43144
|
logger.warning("You're at HOME directory. Installing here modifies your GLOBAL ClaudeKit.");
|
|
@@ -41497,7 +43160,7 @@ async function handleSelection(ctx) {
|
|
|
41497
43160
|
return { ...ctx, cancelled: true };
|
|
41498
43161
|
}
|
|
41499
43162
|
}
|
|
41500
|
-
if (!await
|
|
43163
|
+
if (!await import_fs_extra31.pathExists(resolvedDir)) {
|
|
41501
43164
|
if (ctx.options.global) {
|
|
41502
43165
|
await mkdir20(resolvedDir, { recursive: true });
|
|
41503
43166
|
logger.info(`Created global directory: ${resolvedDir}`);
|
|
@@ -41509,7 +43172,7 @@ async function handleSelection(ctx) {
|
|
|
41509
43172
|
}
|
|
41510
43173
|
if (!ctx.options.fresh) {
|
|
41511
43174
|
const prefix = PathResolver.getPathPrefix(ctx.options.global);
|
|
41512
|
-
const claudeDir = prefix ?
|
|
43175
|
+
const claudeDir = prefix ? join68(resolvedDir, prefix) : resolvedDir;
|
|
41513
43176
|
try {
|
|
41514
43177
|
const existingMetadata = await readManifest(claudeDir);
|
|
41515
43178
|
if (existingMetadata?.kits) {
|
|
@@ -41541,7 +43204,7 @@ async function handleSelection(ctx) {
|
|
|
41541
43204
|
}
|
|
41542
43205
|
if (ctx.options.fresh) {
|
|
41543
43206
|
const prefix = PathResolver.getPathPrefix(ctx.options.global);
|
|
41544
|
-
const claudeDir = prefix ?
|
|
43207
|
+
const claudeDir = prefix ? join68(resolvedDir, prefix) : resolvedDir;
|
|
41545
43208
|
const canProceed = await handleFreshInstallation(claudeDir, ctx.prompts);
|
|
41546
43209
|
if (!canProceed) {
|
|
41547
43210
|
return { ...ctx, cancelled: true };
|
|
@@ -41560,7 +43223,7 @@ async function handleSelection(ctx) {
|
|
|
41560
43223
|
logger.info("Fetching available versions...");
|
|
41561
43224
|
let currentVersion = null;
|
|
41562
43225
|
try {
|
|
41563
|
-
const metadataPath = ctx.options.global ?
|
|
43226
|
+
const metadataPath = ctx.options.global ? join68(PathResolver.getGlobalKitDir(), "metadata.json") : join68(resolvedDir, ".claude", "metadata.json");
|
|
41564
43227
|
const metadata = await readClaudeKitMetadata(metadataPath);
|
|
41565
43228
|
currentVersion = metadata?.version || null;
|
|
41566
43229
|
if (currentVersion) {
|
|
@@ -41634,25 +43297,25 @@ async function handleSelection(ctx) {
|
|
|
41634
43297
|
};
|
|
41635
43298
|
}
|
|
41636
43299
|
// src/commands/init/phases/sync-handler.ts
|
|
41637
|
-
import { copyFile as copyFile6, mkdir as mkdir21, open, rename as rename3, stat as stat10, unlink as unlink7, writeFile as
|
|
41638
|
-
import { dirname as
|
|
43300
|
+
import { copyFile as copyFile6, mkdir as mkdir21, open, rename as rename3, stat as stat10, unlink as unlink7, writeFile as writeFile21 } from "node:fs/promises";
|
|
43301
|
+
import { dirname as dirname11, join as join69, resolve as resolve10 } from "node:path";
|
|
41639
43302
|
init_logger();
|
|
41640
43303
|
init_path_resolver();
|
|
41641
|
-
var
|
|
43304
|
+
var import_fs_extra32 = __toESM(require_lib(), 1);
|
|
41642
43305
|
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
41643
43306
|
async function handleSync(ctx) {
|
|
41644
43307
|
if (!ctx.options.sync) {
|
|
41645
43308
|
return ctx;
|
|
41646
43309
|
}
|
|
41647
|
-
const resolvedDir = ctx.options.global ? PathResolver.getGlobalKitDir() :
|
|
41648
|
-
const claudeDir = ctx.options.global ? resolvedDir :
|
|
41649
|
-
if (!await
|
|
43310
|
+
const resolvedDir = ctx.options.global ? PathResolver.getGlobalKitDir() : resolve10(ctx.options.dir || ".");
|
|
43311
|
+
const claudeDir = ctx.options.global ? resolvedDir : join69(resolvedDir, ".claude");
|
|
43312
|
+
if (!await import_fs_extra32.pathExists(claudeDir)) {
|
|
41650
43313
|
logger.error("Cannot sync: no .claude directory found");
|
|
41651
43314
|
ctx.prompts.note("Run 'ck init' without --sync to install first.", "No Installation Found");
|
|
41652
43315
|
return { ...ctx, cancelled: true };
|
|
41653
43316
|
}
|
|
41654
|
-
const metadataPath =
|
|
41655
|
-
if (!await
|
|
43317
|
+
const metadataPath = join69(claudeDir, "metadata.json");
|
|
43318
|
+
if (!await import_fs_extra32.pathExists(metadataPath)) {
|
|
41656
43319
|
logger.error("Cannot sync: no metadata.json found");
|
|
41657
43320
|
ctx.prompts.note(`Your installation may be from an older version.
|
|
41658
43321
|
Run 'ck init' to update.`, "Legacy Installation");
|
|
@@ -41751,10 +43414,10 @@ function getLockTimeout() {
|
|
|
41751
43414
|
var STALE_LOCK_THRESHOLD_MS = 5 * 60 * 1000;
|
|
41752
43415
|
async function acquireSyncLock(global3) {
|
|
41753
43416
|
const cacheDir = PathResolver.getCacheDir(global3);
|
|
41754
|
-
const lockPath =
|
|
43417
|
+
const lockPath = join69(cacheDir, ".sync-lock");
|
|
41755
43418
|
const startTime = Date.now();
|
|
41756
43419
|
const lockTimeout = getLockTimeout();
|
|
41757
|
-
await mkdir21(
|
|
43420
|
+
await mkdir21(dirname11(lockPath), { recursive: true });
|
|
41758
43421
|
while (Date.now() - startTime < lockTimeout) {
|
|
41759
43422
|
try {
|
|
41760
43423
|
const handle = await open(lockPath, "wx");
|
|
@@ -41778,7 +43441,7 @@ async function acquireSyncLock(global3) {
|
|
|
41778
43441
|
}
|
|
41779
43442
|
logger.debug(`Lock stat failed: ${statError}`);
|
|
41780
43443
|
}
|
|
41781
|
-
await new Promise((
|
|
43444
|
+
await new Promise((resolve11) => setTimeout(resolve11, 100));
|
|
41782
43445
|
continue;
|
|
41783
43446
|
}
|
|
41784
43447
|
throw err;
|
|
@@ -41797,7 +43460,7 @@ async function executeSyncMerge(ctx) {
|
|
|
41797
43460
|
const releaseLock = await acquireSyncLock(ctx.options.global);
|
|
41798
43461
|
try {
|
|
41799
43462
|
const trackedFiles = ctx.syncTrackedFiles;
|
|
41800
|
-
const upstreamDir = ctx.options.global ?
|
|
43463
|
+
const upstreamDir = ctx.options.global ? join69(ctx.extractDir, ".claude") : ctx.extractDir;
|
|
41801
43464
|
logger.info("Analyzing file changes...");
|
|
41802
43465
|
const plan = await SyncEngine.createSyncPlan(trackedFiles, ctx.claudeDir, upstreamDir);
|
|
41803
43466
|
displaySyncPlan(plan);
|
|
@@ -41816,7 +43479,7 @@ async function executeSyncMerge(ctx) {
|
|
|
41816
43479
|
try {
|
|
41817
43480
|
const sourcePath = await validateSyncPath(upstreamDir, file.path);
|
|
41818
43481
|
const targetPath = await validateSyncPath(ctx.claudeDir, file.path);
|
|
41819
|
-
const targetDir =
|
|
43482
|
+
const targetDir = join69(targetPath, "..");
|
|
41820
43483
|
try {
|
|
41821
43484
|
await mkdir21(targetDir, { recursive: true });
|
|
41822
43485
|
} catch (mkdirError) {
|
|
@@ -41897,7 +43560,7 @@ async function executeSyncMerge(ctx) {
|
|
|
41897
43560
|
try {
|
|
41898
43561
|
const tempPath = `${currentPath}.tmp.${Date.now()}`;
|
|
41899
43562
|
try {
|
|
41900
|
-
await
|
|
43563
|
+
await writeFile21(tempPath, result.result, "utf-8");
|
|
41901
43564
|
await rename3(tempPath, currentPath);
|
|
41902
43565
|
} catch (atomicError) {
|
|
41903
43566
|
await unlink7(tempPath).catch(() => {});
|
|
@@ -41985,9 +43648,9 @@ async function createBackup(claudeDir, files, backupDir) {
|
|
|
41985
43648
|
for (const file of files) {
|
|
41986
43649
|
try {
|
|
41987
43650
|
const sourcePath = await validateSyncPath(claudeDir, file.path);
|
|
41988
|
-
if (await
|
|
43651
|
+
if (await import_fs_extra32.pathExists(sourcePath)) {
|
|
41989
43652
|
const targetPath = await validateSyncPath(backupDir, file.path);
|
|
41990
|
-
const targetDir =
|
|
43653
|
+
const targetDir = join69(targetPath, "..");
|
|
41991
43654
|
await mkdir21(targetDir, { recursive: true });
|
|
41992
43655
|
await copyFile6(sourcePath, targetPath);
|
|
41993
43656
|
}
|
|
@@ -42001,7 +43664,7 @@ async function createBackup(claudeDir, files, backupDir) {
|
|
|
42001
43664
|
}
|
|
42002
43665
|
}
|
|
42003
43666
|
// src/commands/init/phases/transform-handler.ts
|
|
42004
|
-
import { join as
|
|
43667
|
+
import { join as join73 } from "node:path";
|
|
42005
43668
|
|
|
42006
43669
|
// src/services/transformers/folder-path-transformer.ts
|
|
42007
43670
|
init_logger();
|
|
@@ -42010,40 +43673,40 @@ init_types2();
|
|
|
42010
43673
|
// src/services/transformers/folder-transform/folder-renamer.ts
|
|
42011
43674
|
init_logger();
|
|
42012
43675
|
init_types2();
|
|
42013
|
-
var
|
|
43676
|
+
var import_fs_extra33 = __toESM(require_lib(), 1);
|
|
42014
43677
|
import { rename as rename4, rm as rm7 } from "node:fs/promises";
|
|
42015
|
-
import { join as
|
|
43678
|
+
import { join as join70, relative as relative13 } from "node:path";
|
|
42016
43679
|
async function collectDirsToRename(extractDir, folders) {
|
|
42017
43680
|
const dirsToRename = [];
|
|
42018
43681
|
if (folders.docs !== DEFAULT_FOLDERS.docs) {
|
|
42019
|
-
const docsPath =
|
|
42020
|
-
if (await
|
|
43682
|
+
const docsPath = join70(extractDir, DEFAULT_FOLDERS.docs);
|
|
43683
|
+
if (await import_fs_extra33.pathExists(docsPath)) {
|
|
42021
43684
|
dirsToRename.push({
|
|
42022
43685
|
from: docsPath,
|
|
42023
|
-
to:
|
|
43686
|
+
to: join70(extractDir, folders.docs)
|
|
42024
43687
|
});
|
|
42025
43688
|
}
|
|
42026
|
-
const claudeDocsPath =
|
|
42027
|
-
if (await
|
|
43689
|
+
const claudeDocsPath = join70(extractDir, ".claude", DEFAULT_FOLDERS.docs);
|
|
43690
|
+
if (await import_fs_extra33.pathExists(claudeDocsPath)) {
|
|
42028
43691
|
dirsToRename.push({
|
|
42029
43692
|
from: claudeDocsPath,
|
|
42030
|
-
to:
|
|
43693
|
+
to: join70(extractDir, ".claude", folders.docs)
|
|
42031
43694
|
});
|
|
42032
43695
|
}
|
|
42033
43696
|
}
|
|
42034
43697
|
if (folders.plans !== DEFAULT_FOLDERS.plans) {
|
|
42035
|
-
const plansPath =
|
|
42036
|
-
if (await
|
|
43698
|
+
const plansPath = join70(extractDir, DEFAULT_FOLDERS.plans);
|
|
43699
|
+
if (await import_fs_extra33.pathExists(plansPath)) {
|
|
42037
43700
|
dirsToRename.push({
|
|
42038
43701
|
from: plansPath,
|
|
42039
|
-
to:
|
|
43702
|
+
to: join70(extractDir, folders.plans)
|
|
42040
43703
|
});
|
|
42041
43704
|
}
|
|
42042
|
-
const claudePlansPath =
|
|
42043
|
-
if (await
|
|
43705
|
+
const claudePlansPath = join70(extractDir, ".claude", DEFAULT_FOLDERS.plans);
|
|
43706
|
+
if (await import_fs_extra33.pathExists(claudePlansPath)) {
|
|
42044
43707
|
dirsToRename.push({
|
|
42045
43708
|
from: claudePlansPath,
|
|
42046
|
-
to:
|
|
43709
|
+
to: join70(extractDir, ".claude", folders.plans)
|
|
42047
43710
|
});
|
|
42048
43711
|
}
|
|
42049
43712
|
}
|
|
@@ -42055,7 +43718,7 @@ async function moveAcrossDevices(src, dest) {
|
|
|
42055
43718
|
} catch (e2) {
|
|
42056
43719
|
if (e2.code === "EXDEV") {
|
|
42057
43720
|
logger.debug(`Cross-device move detected, using copy+delete: ${src} -> ${dest}`);
|
|
42058
|
-
await
|
|
43721
|
+
await import_fs_extra33.copy(src, dest, { overwrite: true });
|
|
42059
43722
|
await rm7(src, { recursive: true, force: true });
|
|
42060
43723
|
} else {
|
|
42061
43724
|
throw e2;
|
|
@@ -42066,11 +43729,11 @@ async function renameFolders(dirsToRename, extractDir, options) {
|
|
|
42066
43729
|
let foldersRenamed = 0;
|
|
42067
43730
|
for (const { from, to } of dirsToRename) {
|
|
42068
43731
|
if (options.dryRun) {
|
|
42069
|
-
logger.info(`[dry-run] Would rename: ${
|
|
43732
|
+
logger.info(`[dry-run] Would rename: ${relative13(extractDir, from)} -> ${relative13(extractDir, to)}`);
|
|
42070
43733
|
} else {
|
|
42071
43734
|
try {
|
|
42072
43735
|
await moveAcrossDevices(from, to);
|
|
42073
|
-
logger.debug(`Renamed: ${
|
|
43736
|
+
logger.debug(`Renamed: ${relative13(extractDir, from)} -> ${relative13(extractDir, to)}`);
|
|
42074
43737
|
foldersRenamed++;
|
|
42075
43738
|
} catch (error) {
|
|
42076
43739
|
logger.warning(`Failed to rename ${from}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
@@ -42083,8 +43746,8 @@ async function renameFolders(dirsToRename, extractDir, options) {
|
|
|
42083
43746
|
// src/services/transformers/folder-transform/path-replacer.ts
|
|
42084
43747
|
init_logger();
|
|
42085
43748
|
init_types2();
|
|
42086
|
-
import { readFile as
|
|
42087
|
-
import { join as
|
|
43749
|
+
import { readFile as readFile26, readdir as readdir23, writeFile as writeFile22 } from "node:fs/promises";
|
|
43750
|
+
import { join as join71, relative as relative14 } from "node:path";
|
|
42088
43751
|
var TRANSFORMABLE_FILE_PATTERNS = [
|
|
42089
43752
|
".md",
|
|
42090
43753
|
".txt",
|
|
@@ -42137,7 +43800,7 @@ async function transformFileContents(dir, compiledReplacements, options) {
|
|
|
42137
43800
|
let replacementsCount = 0;
|
|
42138
43801
|
const entries = await readdir23(dir, { withFileTypes: true });
|
|
42139
43802
|
for (const entry of entries) {
|
|
42140
|
-
const fullPath =
|
|
43803
|
+
const fullPath = join71(dir, entry.name);
|
|
42141
43804
|
if (entry.isDirectory()) {
|
|
42142
43805
|
if (entry.name === "node_modules" || entry.name === ".git") {
|
|
42143
43806
|
continue;
|
|
@@ -42150,7 +43813,7 @@ async function transformFileContents(dir, compiledReplacements, options) {
|
|
|
42150
43813
|
if (!shouldTransform)
|
|
42151
43814
|
continue;
|
|
42152
43815
|
try {
|
|
42153
|
-
const content = await
|
|
43816
|
+
const content = await readFile26(fullPath, "utf-8");
|
|
42154
43817
|
let newContent = content;
|
|
42155
43818
|
let changeCount = 0;
|
|
42156
43819
|
for (const { regex: regex2, replacement } of compiledReplacements) {
|
|
@@ -42164,10 +43827,10 @@ async function transformFileContents(dir, compiledReplacements, options) {
|
|
|
42164
43827
|
}
|
|
42165
43828
|
if (changeCount > 0) {
|
|
42166
43829
|
if (options.dryRun) {
|
|
42167
|
-
logger.debug(`[dry-run] Would update ${
|
|
43830
|
+
logger.debug(`[dry-run] Would update ${relative14(dir, fullPath)}: ${changeCount} replacement(s)`);
|
|
42168
43831
|
} else {
|
|
42169
|
-
await
|
|
42170
|
-
logger.debug(`Updated ${
|
|
43832
|
+
await writeFile22(fullPath, newContent, "utf-8");
|
|
43833
|
+
logger.debug(`Updated ${relative14(dir, fullPath)}: ${changeCount} replacement(s)`);
|
|
42171
43834
|
}
|
|
42172
43835
|
filesChanged++;
|
|
42173
43836
|
replacementsCount += changeCount;
|
|
@@ -42272,9 +43935,9 @@ async function transformFolderPaths(extractDir, folders, options = {}) {
|
|
|
42272
43935
|
|
|
42273
43936
|
// src/services/transformers/global-path-transformer.ts
|
|
42274
43937
|
init_logger();
|
|
42275
|
-
import { readFile as
|
|
43938
|
+
import { readFile as readFile27, readdir as readdir24, writeFile as writeFile23 } from "node:fs/promises";
|
|
42276
43939
|
import { platform as platform12 } from "node:os";
|
|
42277
|
-
import { extname as extname3, join as
|
|
43940
|
+
import { extname as extname3, join as join72 } from "node:path";
|
|
42278
43941
|
var IS_WINDOWS4 = platform12() === "win32";
|
|
42279
43942
|
var HOME_PREFIX = IS_WINDOWS4 ? "%USERPROFILE%" : "$HOME";
|
|
42280
43943
|
function getHomeDirPrefix() {
|
|
@@ -42384,7 +44047,7 @@ async function transformPathsForGlobalInstall(directory, options = {}) {
|
|
|
42384
44047
|
async function processDirectory2(dir) {
|
|
42385
44048
|
const entries = await readdir24(dir, { withFileTypes: true });
|
|
42386
44049
|
for (const entry of entries) {
|
|
42387
|
-
const fullPath =
|
|
44050
|
+
const fullPath = join72(dir, entry.name);
|
|
42388
44051
|
if (entry.isDirectory()) {
|
|
42389
44052
|
if (entry.name === "node_modules" || entry.name.startsWith(".") && entry.name !== ".claude") {
|
|
42390
44053
|
continue;
|
|
@@ -42392,10 +44055,10 @@ async function transformPathsForGlobalInstall(directory, options = {}) {
|
|
|
42392
44055
|
await processDirectory2(fullPath);
|
|
42393
44056
|
} else if (entry.isFile() && shouldTransformFile3(entry.name)) {
|
|
42394
44057
|
try {
|
|
42395
|
-
const content = await
|
|
44058
|
+
const content = await readFile27(fullPath, "utf-8");
|
|
42396
44059
|
const { transformed, changes } = transformContent(content);
|
|
42397
44060
|
if (changes > 0) {
|
|
42398
|
-
await
|
|
44061
|
+
await writeFile23(fullPath, transformed, "utf-8");
|
|
42399
44062
|
filesTransformed++;
|
|
42400
44063
|
totalChanges += changes;
|
|
42401
44064
|
if (options.verbose) {
|
|
@@ -42460,7 +44123,7 @@ async function handleTransforms(ctx) {
|
|
|
42460
44123
|
logger.debug(ctx.options.global ? "Saved folder configuration to ~/.claude/.ck.json" : "Saved folder configuration to .claude/.ck.json");
|
|
42461
44124
|
}
|
|
42462
44125
|
}
|
|
42463
|
-
const claudeDir = ctx.options.global ? ctx.resolvedDir :
|
|
44126
|
+
const claudeDir = ctx.options.global ? ctx.resolvedDir : join73(ctx.resolvedDir, ".claude");
|
|
42464
44127
|
return {
|
|
42465
44128
|
...ctx,
|
|
42466
44129
|
foldersConfig,
|
|
@@ -42650,11 +44313,11 @@ init_types2();
|
|
|
42650
44313
|
var import_picocolors20 = __toESM(require_picocolors(), 1);
|
|
42651
44314
|
|
|
42652
44315
|
// src/commands/new/phases/directory-setup.ts
|
|
42653
|
-
import { resolve as
|
|
44316
|
+
import { resolve as resolve11 } from "node:path";
|
|
42654
44317
|
init_logger();
|
|
42655
44318
|
init_path_resolver();
|
|
42656
44319
|
init_types2();
|
|
42657
|
-
var
|
|
44320
|
+
var import_fs_extra34 = __toESM(require_lib(), 1);
|
|
42658
44321
|
async function directorySetup(validOptions, prompts) {
|
|
42659
44322
|
const isNonInteractive2 = !process.stdin.isTTY || process.env.CI === "true" || process.env.NON_INTERACTIVE === "true";
|
|
42660
44323
|
const config = await ConfigManager.get();
|
|
@@ -42735,7 +44398,7 @@ async function directorySetup(validOptions, prompts) {
|
|
|
42735
44398
|
targetDir = await prompts.getDirectory(targetDir);
|
|
42736
44399
|
}
|
|
42737
44400
|
}
|
|
42738
|
-
const resolvedDir =
|
|
44401
|
+
const resolvedDir = resolve11(targetDir);
|
|
42739
44402
|
logger.info(`Target directory: ${resolvedDir}`);
|
|
42740
44403
|
if (PathResolver.isLocalSameAsGlobal(resolvedDir)) {
|
|
42741
44404
|
logger.warning("You're creating a project at HOME directory.");
|
|
@@ -42753,8 +44416,8 @@ async function directorySetup(validOptions, prompts) {
|
|
|
42753
44416
|
return null;
|
|
42754
44417
|
}
|
|
42755
44418
|
}
|
|
42756
|
-
if (await
|
|
42757
|
-
const files = await
|
|
44419
|
+
if (await import_fs_extra34.pathExists(resolvedDir)) {
|
|
44420
|
+
const files = await import_fs_extra34.readdir(resolvedDir);
|
|
42758
44421
|
const isEmpty = files.length === 0;
|
|
42759
44422
|
if (!isEmpty) {
|
|
42760
44423
|
if (isNonInteractive2) {
|
|
@@ -42790,7 +44453,7 @@ async function handleDirectorySetup(ctx) {
|
|
|
42790
44453
|
};
|
|
42791
44454
|
}
|
|
42792
44455
|
// src/commands/new/phases/project-creation.ts
|
|
42793
|
-
import { join as
|
|
44456
|
+
import { join as join74 } from "node:path";
|
|
42794
44457
|
init_github_client();
|
|
42795
44458
|
init_logger();
|
|
42796
44459
|
init_output_manager();
|
|
@@ -42917,7 +44580,7 @@ async function projectCreation(kit, resolvedDir, validOptions, isNonInteractive2
|
|
|
42917
44580
|
output.section("Installing");
|
|
42918
44581
|
logger.verbose("Installation target", { directory: resolvedDir });
|
|
42919
44582
|
const merger = new FileMerger;
|
|
42920
|
-
const claudeDir =
|
|
44583
|
+
const claudeDir = join74(resolvedDir, ".claude");
|
|
42921
44584
|
merger.setMultiKitContext(claudeDir, kit);
|
|
42922
44585
|
if (validOptions.exclude && validOptions.exclude.length > 0) {
|
|
42923
44586
|
merger.addIgnorePatterns(validOptions.exclude);
|
|
@@ -42963,7 +44626,7 @@ async function handleProjectCreation(ctx) {
|
|
|
42963
44626
|
};
|
|
42964
44627
|
}
|
|
42965
44628
|
// src/commands/new/phases/post-setup.ts
|
|
42966
|
-
import { join as
|
|
44629
|
+
import { join as join75 } from "node:path";
|
|
42967
44630
|
init_package_installer();
|
|
42968
44631
|
init_logger();
|
|
42969
44632
|
init_path_resolver();
|
|
@@ -42995,9 +44658,9 @@ async function postSetup(resolvedDir, validOptions, isNonInteractive2, prompts)
|
|
|
42995
44658
|
withSudo: validOptions.withSudo
|
|
42996
44659
|
});
|
|
42997
44660
|
}
|
|
42998
|
-
const claudeDir =
|
|
44661
|
+
const claudeDir = join75(resolvedDir, ".claude");
|
|
42999
44662
|
await promptSetupWizardIfNeeded({
|
|
43000
|
-
envPath:
|
|
44663
|
+
envPath: join75(claudeDir, ".env"),
|
|
43001
44664
|
claudeDir,
|
|
43002
44665
|
isGlobal: false,
|
|
43003
44666
|
isNonInteractive: isNonInteractive2,
|
|
@@ -43066,7 +44729,7 @@ var import_picocolors22 = __toESM(require_picocolors(), 1);
|
|
|
43066
44729
|
|
|
43067
44730
|
// src/commands/uninstall/installation-detector.ts
|
|
43068
44731
|
init_path_resolver();
|
|
43069
|
-
var
|
|
44732
|
+
var import_fs_extra35 = __toESM(require_lib(), 1);
|
|
43070
44733
|
async function detectInstallations() {
|
|
43071
44734
|
const installations = [];
|
|
43072
44735
|
const setup = await getClaudeKitSetup(process.cwd());
|
|
@@ -43075,28 +44738,28 @@ async function detectInstallations() {
|
|
|
43075
44738
|
installations.push({
|
|
43076
44739
|
type: "local",
|
|
43077
44740
|
path: setup.project.path,
|
|
43078
|
-
exists: await
|
|
44741
|
+
exists: await import_fs_extra35.pathExists(setup.project.path)
|
|
43079
44742
|
});
|
|
43080
44743
|
}
|
|
43081
44744
|
if (setup.global.path && setup.global.metadata) {
|
|
43082
44745
|
installations.push({
|
|
43083
44746
|
type: "global",
|
|
43084
44747
|
path: setup.global.path,
|
|
43085
|
-
exists: await
|
|
44748
|
+
exists: await import_fs_extra35.pathExists(setup.global.path)
|
|
43086
44749
|
});
|
|
43087
44750
|
}
|
|
43088
44751
|
return installations.filter((i) => i.exists);
|
|
43089
44752
|
}
|
|
43090
44753
|
|
|
43091
44754
|
// src/commands/uninstall/removal-handler.ts
|
|
43092
|
-
import { readdirSync as
|
|
43093
|
-
import { join as
|
|
44755
|
+
import { readdirSync as readdirSync4, rmSync as rmSync5 } from "node:fs";
|
|
44756
|
+
import { join as join77 } from "node:path";
|
|
43094
44757
|
init_logger();
|
|
43095
|
-
var
|
|
44758
|
+
var import_fs_extra36 = __toESM(require_lib(), 1);
|
|
43096
44759
|
|
|
43097
44760
|
// src/commands/uninstall/analysis-handler.ts
|
|
43098
|
-
import { readdirSync as
|
|
43099
|
-
import { dirname as
|
|
44761
|
+
import { readdirSync as readdirSync3, rmSync as rmSync4 } from "node:fs";
|
|
44762
|
+
import { dirname as dirname12, join as join76 } from "node:path";
|
|
43100
44763
|
init_logger();
|
|
43101
44764
|
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
43102
44765
|
function classifyFileByOwnership(ownership, forceOverwrite, deleteReason) {
|
|
@@ -43111,17 +44774,17 @@ function classifyFileByOwnership(ownership, forceOverwrite, deleteReason) {
|
|
|
43111
44774
|
}
|
|
43112
44775
|
return { action: "preserve", reason: "user-created" };
|
|
43113
44776
|
}
|
|
43114
|
-
async function
|
|
44777
|
+
async function cleanupEmptyDirectories3(filePath, installationRoot) {
|
|
43115
44778
|
let cleaned = 0;
|
|
43116
|
-
let currentDir =
|
|
44779
|
+
let currentDir = dirname12(filePath);
|
|
43117
44780
|
while (currentDir !== installationRoot && currentDir.startsWith(installationRoot)) {
|
|
43118
44781
|
try {
|
|
43119
|
-
const entries =
|
|
44782
|
+
const entries = readdirSync3(currentDir);
|
|
43120
44783
|
if (entries.length === 0) {
|
|
43121
|
-
|
|
44784
|
+
rmSync4(currentDir, { recursive: true });
|
|
43122
44785
|
cleaned++;
|
|
43123
44786
|
logger.debug(`Removed empty directory: ${currentDir}`);
|
|
43124
|
-
currentDir =
|
|
44787
|
+
currentDir = dirname12(currentDir);
|
|
43125
44788
|
} else {
|
|
43126
44789
|
break;
|
|
43127
44790
|
}
|
|
@@ -43143,7 +44806,7 @@ async function analyzeInstallation(installation, forceOverwrite, kit) {
|
|
|
43143
44806
|
if (uninstallManifest.isMultiKit && kit && metadata?.kits?.[kit]) {
|
|
43144
44807
|
const kitFiles = metadata.kits[kit].files || [];
|
|
43145
44808
|
for (const trackedFile of kitFiles) {
|
|
43146
|
-
const filePath =
|
|
44809
|
+
const filePath = join76(installation.path, trackedFile.path);
|
|
43147
44810
|
if (uninstallManifest.filesToPreserve.includes(trackedFile.path)) {
|
|
43148
44811
|
result.toPreserve.push({ path: trackedFile.path, reason: "shared with other kit" });
|
|
43149
44812
|
continue;
|
|
@@ -43173,7 +44836,7 @@ async function analyzeInstallation(installation, forceOverwrite, kit) {
|
|
|
43173
44836
|
return result;
|
|
43174
44837
|
}
|
|
43175
44838
|
for (const trackedFile of allTrackedFiles) {
|
|
43176
|
-
const filePath =
|
|
44839
|
+
const filePath = join76(installation.path, trackedFile.path);
|
|
43177
44840
|
const ownershipResult = await OwnershipChecker.checkOwnership(filePath, metadata, installation.path);
|
|
43178
44841
|
if (!ownershipResult.exists)
|
|
43179
44842
|
continue;
|
|
@@ -43233,21 +44896,21 @@ async function removeInstallations(installations, options) {
|
|
|
43233
44896
|
let removedCount = 0;
|
|
43234
44897
|
let cleanedDirs = 0;
|
|
43235
44898
|
for (const item of analysis.toDelete) {
|
|
43236
|
-
const filePath =
|
|
43237
|
-
if (await
|
|
43238
|
-
await
|
|
44899
|
+
const filePath = join77(installation.path, item.path);
|
|
44900
|
+
if (await import_fs_extra36.pathExists(filePath)) {
|
|
44901
|
+
await import_fs_extra36.remove(filePath);
|
|
43239
44902
|
removedCount++;
|
|
43240
44903
|
logger.debug(`Removed: ${item.path}`);
|
|
43241
|
-
cleanedDirs += await
|
|
44904
|
+
cleanedDirs += await cleanupEmptyDirectories3(filePath, installation.path);
|
|
43242
44905
|
}
|
|
43243
44906
|
}
|
|
43244
44907
|
if (options.kit && analysis.remainingKits.length > 0) {
|
|
43245
44908
|
await ManifestWriter.removeKitFromManifest(installation.path, options.kit);
|
|
43246
44909
|
}
|
|
43247
44910
|
try {
|
|
43248
|
-
const remaining =
|
|
44911
|
+
const remaining = readdirSync4(installation.path);
|
|
43249
44912
|
if (remaining.length === 0) {
|
|
43250
|
-
|
|
44913
|
+
rmSync5(installation.path, { recursive: true });
|
|
43251
44914
|
logger.debug(`Removed empty installation directory: ${installation.path}`);
|
|
43252
44915
|
}
|
|
43253
44916
|
} catch {}
|
|
@@ -43404,7 +45067,7 @@ ${import_picocolors22.default.yellow("User modifications will be permanently del
|
|
|
43404
45067
|
}
|
|
43405
45068
|
// src/commands/update-cli.ts
|
|
43406
45069
|
import { exec as exec8 } from "node:child_process";
|
|
43407
|
-
import { join as
|
|
45070
|
+
import { join as join78 } from "node:path";
|
|
43408
45071
|
import { promisify as promisify8 } from "node:util";
|
|
43409
45072
|
|
|
43410
45073
|
// src/domains/github/npm-registry.ts
|
|
@@ -43475,19 +45138,22 @@ class NpmRegistryClient {
|
|
|
43475
45138
|
}
|
|
43476
45139
|
}
|
|
43477
45140
|
static async getBetaVersion(packageName, registryUrl) {
|
|
45141
|
+
return NpmRegistryClient.getDevVersion(packageName, registryUrl);
|
|
45142
|
+
}
|
|
45143
|
+
static async getDevVersion(packageName, registryUrl) {
|
|
43478
45144
|
try {
|
|
43479
45145
|
const info = await NpmRegistryClient.getPackageInfo(packageName, registryUrl);
|
|
43480
45146
|
if (!info)
|
|
43481
45147
|
return null;
|
|
43482
|
-
const
|
|
43483
|
-
if (!
|
|
43484
|
-
logger.debug(`No
|
|
45148
|
+
const devVersion = info["dist-tags"]?.dev || info["dist-tags"]?.beta || info["dist-tags"]?.next;
|
|
45149
|
+
if (!devVersion) {
|
|
45150
|
+
logger.debug(`No dev version found for ${packageName}`);
|
|
43485
45151
|
return null;
|
|
43486
45152
|
}
|
|
43487
|
-
return
|
|
45153
|
+
return devVersion;
|
|
43488
45154
|
} catch (error) {
|
|
43489
45155
|
const message = error instanceof Error ? error.message : "Unknown error";
|
|
43490
|
-
logger.debug(`Failed to get
|
|
45156
|
+
logger.debug(`Failed to get dev version for ${packageName}: ${message}`);
|
|
43491
45157
|
return null;
|
|
43492
45158
|
}
|
|
43493
45159
|
}
|
|
@@ -43547,11 +45213,11 @@ init_logger();
|
|
|
43547
45213
|
init_types2();
|
|
43548
45214
|
init_types2();
|
|
43549
45215
|
var import_compare_versions3 = __toESM(require_umd(), 1);
|
|
43550
|
-
var
|
|
45216
|
+
var import_fs_extra37 = __toESM(require_lib(), 1);
|
|
43551
45217
|
// package.json
|
|
43552
45218
|
var package_default = {
|
|
43553
45219
|
name: "claudekit-cli",
|
|
43554
|
-
version: "3.
|
|
45220
|
+
version: "3.31.0-dev.2",
|
|
43555
45221
|
description: "CLI tool for bootstrapping and updating ClaudeKit projects",
|
|
43556
45222
|
type: "module",
|
|
43557
45223
|
repository: {
|
|
@@ -43617,6 +45283,7 @@ var package_default = {
|
|
|
43617
45283
|
ora: "^8.0.0",
|
|
43618
45284
|
"p-limit": "^7.2.0",
|
|
43619
45285
|
picocolors: "^1.1.1",
|
|
45286
|
+
picomatch: "^4.0.3",
|
|
43620
45287
|
"proper-lockfile": "^4.1.2",
|
|
43621
45288
|
semver: "^7.7.3",
|
|
43622
45289
|
tar: "^7.4.3",
|
|
@@ -43632,6 +45299,7 @@ var package_default = {
|
|
|
43632
45299
|
"@types/diff": "^8.0.0",
|
|
43633
45300
|
"@types/fs-extra": "^11.0.4",
|
|
43634
45301
|
"@types/node": "^22.10.1",
|
|
45302
|
+
"@types/picomatch": "^4.0.2",
|
|
43635
45303
|
"@types/proper-lockfile": "^4.1.4",
|
|
43636
45304
|
"@types/semver": "^7.7.1",
|
|
43637
45305
|
"@types/tar": "^6.1.13",
|
|
@@ -43665,7 +45333,7 @@ function buildInitCommand(isGlobal, kit, beta) {
|
|
|
43665
45333
|
function isBetaVersion(version) {
|
|
43666
45334
|
if (!version)
|
|
43667
45335
|
return false;
|
|
43668
|
-
return /-(beta|alpha|rc)[.\d]/i.test(version);
|
|
45336
|
+
return /-(beta|alpha|rc|dev)[.\d]/i.test(version);
|
|
43669
45337
|
}
|
|
43670
45338
|
function selectKitForUpdate(params) {
|
|
43671
45339
|
const { hasLocal, hasGlobal, localKits, globalKits } = params;
|
|
@@ -43698,12 +45366,12 @@ function selectKitForUpdate(params) {
|
|
|
43698
45366
|
};
|
|
43699
45367
|
}
|
|
43700
45368
|
async function readMetadataFile(claudeDir) {
|
|
43701
|
-
const metadataPath =
|
|
45369
|
+
const metadataPath = join78(claudeDir, "metadata.json");
|
|
43702
45370
|
try {
|
|
43703
|
-
if (!await
|
|
45371
|
+
if (!await import_fs_extra37.pathExists(metadataPath)) {
|
|
43704
45372
|
return null;
|
|
43705
45373
|
}
|
|
43706
|
-
const content = await
|
|
45374
|
+
const content = await import_fs_extra37.readFile(metadataPath, "utf-8");
|
|
43707
45375
|
const parsed = JSON.parse(content);
|
|
43708
45376
|
const validated = MetadataSchema.safeParse(parsed);
|
|
43709
45377
|
if (!validated.success) {
|
|
@@ -43786,14 +45454,14 @@ async function updateCliCommand(options) {
|
|
|
43786
45454
|
}
|
|
43787
45455
|
targetVersion = opts.release;
|
|
43788
45456
|
s.stop(`Target version: ${targetVersion}`);
|
|
43789
|
-
} else if (opts.beta) {
|
|
43790
|
-
targetVersion = await NpmRegistryClient.
|
|
45457
|
+
} else if (opts.dev || opts.beta) {
|
|
45458
|
+
targetVersion = await NpmRegistryClient.getDevVersion(PACKAGE_NAME, opts.registry);
|
|
43791
45459
|
if (!targetVersion) {
|
|
43792
|
-
s.stop("No
|
|
43793
|
-
logger.warning("No
|
|
45460
|
+
s.stop("No dev version available");
|
|
45461
|
+
logger.warning("No dev version found. Using latest stable version instead.");
|
|
43794
45462
|
targetVersion = await NpmRegistryClient.getLatestVersion(PACKAGE_NAME, opts.registry);
|
|
43795
45463
|
} else {
|
|
43796
|
-
s.stop(`Latest
|
|
45464
|
+
s.stop(`Latest dev version: ${targetVersion}`);
|
|
43797
45465
|
}
|
|
43798
45466
|
} else {
|
|
43799
45467
|
targetVersion = await NpmRegistryClient.getLatestVersion(PACKAGE_NAME, opts.registry);
|
|
@@ -43805,7 +45473,7 @@ async function updateCliCommand(options) {
|
|
|
43805
45473
|
const comparison = import_compare_versions3.compareVersions(currentVersion, targetVersion);
|
|
43806
45474
|
if (comparison === 0) {
|
|
43807
45475
|
outro(`[+] Already on the latest CLI version (${currentVersion})`);
|
|
43808
|
-
await promptKitUpdate(opts.beta);
|
|
45476
|
+
await promptKitUpdate(opts.dev || opts.beta);
|
|
43809
45477
|
return;
|
|
43810
45478
|
}
|
|
43811
45479
|
if (comparison > 0 && !opts.release) {
|
|
@@ -43819,7 +45487,7 @@ async function updateCliCommand(options) {
|
|
|
43819
45487
|
note(`CLI update available: ${currentVersion} -> ${targetVersion}
|
|
43820
45488
|
|
|
43821
45489
|
Run 'ck update' to install`, "Update Check");
|
|
43822
|
-
await promptKitUpdate(opts.beta);
|
|
45490
|
+
await promptKitUpdate(opts.dev || opts.beta);
|
|
43823
45491
|
outro("Check complete");
|
|
43824
45492
|
return;
|
|
43825
45493
|
}
|
|
@@ -43859,11 +45527,11 @@ Manual update: ${updateCmd}`);
|
|
|
43859
45527
|
const newVersion = newVersionMatch ? newVersionMatch[1] : targetVersion;
|
|
43860
45528
|
s.stop(`Installed version: ${newVersion}`);
|
|
43861
45529
|
outro(`[+] Successfully updated ClaudeKit CLI to ${newVersion}`);
|
|
43862
|
-
await promptKitUpdate(opts.beta);
|
|
45530
|
+
await promptKitUpdate(opts.dev || opts.beta);
|
|
43863
45531
|
} catch {
|
|
43864
45532
|
s.stop("Verification completed");
|
|
43865
45533
|
outro(`[+] Update completed. Please restart your terminal to use CLI ${targetVersion}`);
|
|
43866
|
-
await promptKitUpdate(opts.beta);
|
|
45534
|
+
await promptKitUpdate(opts.dev || opts.beta);
|
|
43867
45535
|
}
|
|
43868
45536
|
} catch (error) {
|
|
43869
45537
|
if (error instanceof CliUpdateError) {
|
|
@@ -43991,7 +45659,7 @@ function registerCommands(cli) {
|
|
|
43991
45659
|
}
|
|
43992
45660
|
await initCommand(options);
|
|
43993
45661
|
});
|
|
43994
|
-
cli.command("update", "Update ClaudeKit CLI to the latest version").option("-r, --release <version>", "Update to a specific version").option("--check", "Check for updates without installing").option("-y, --yes", "Non-interactive mode with sensible defaults (skip all prompts)").option("--
|
|
45662
|
+
cli.command("update", "Update ClaudeKit CLI to the latest version").option("-r, --release <version>", "Update to a specific version").option("--check", "Check for updates without installing").option("-y, --yes", "Non-interactive mode with sensible defaults (skip all prompts)").option("-d, --dev", "Update to the latest dev version").option("--beta", "Alias for --dev (deprecated)").option("--registry <url>", "Custom npm registry URL").option("--kit <kit>", "[DEPRECATED] Use 'ck init --kit <kit>' instead").option("-g, --global", "[DEPRECATED] Use 'ck init --global' instead").action(async (options) => {
|
|
43995
45663
|
if (options.kit || options.global) {
|
|
43996
45664
|
console.log();
|
|
43997
45665
|
const deprecatedFlags = [options.kit && "--kit", options.global && "--global"].filter(Boolean).join(" and ");
|
|
@@ -44030,8 +45698,8 @@ function registerCommands(cli) {
|
|
|
44030
45698
|
}
|
|
44031
45699
|
|
|
44032
45700
|
// src/cli/version-display.ts
|
|
44033
|
-
import { existsSync as
|
|
44034
|
-
import { join as
|
|
45701
|
+
import { existsSync as existsSync22, readFileSync as readFileSync7 } from "node:fs";
|
|
45702
|
+
import { join as join80 } from "node:path";
|
|
44035
45703
|
|
|
44036
45704
|
// src/domains/versioning/checking/version-utils.ts
|
|
44037
45705
|
var import_compare_versions4 = __toESM(require_umd(), 1);
|
|
@@ -44058,25 +45726,25 @@ init_types2();
|
|
|
44058
45726
|
// src/domains/versioning/version-cache.ts
|
|
44059
45727
|
init_logger();
|
|
44060
45728
|
init_path_resolver();
|
|
44061
|
-
import { existsSync as
|
|
44062
|
-
import { mkdir as mkdir22, readFile as
|
|
44063
|
-
import { join as
|
|
45729
|
+
import { existsSync as existsSync21 } from "node:fs";
|
|
45730
|
+
import { mkdir as mkdir22, readFile as readFile29, writeFile as writeFile24 } from "node:fs/promises";
|
|
45731
|
+
import { join as join79 } from "node:path";
|
|
44064
45732
|
|
|
44065
45733
|
class VersionCacheManager {
|
|
44066
45734
|
static CACHE_FILENAME = "version-check.json";
|
|
44067
45735
|
static CACHE_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
44068
45736
|
static getCacheFile() {
|
|
44069
45737
|
const cacheDir = PathResolver.getCacheDir(false);
|
|
44070
|
-
return
|
|
45738
|
+
return join79(cacheDir, VersionCacheManager.CACHE_FILENAME);
|
|
44071
45739
|
}
|
|
44072
45740
|
static async load() {
|
|
44073
45741
|
const cacheFile = VersionCacheManager.getCacheFile();
|
|
44074
45742
|
try {
|
|
44075
|
-
if (!
|
|
45743
|
+
if (!existsSync21(cacheFile)) {
|
|
44076
45744
|
logger.debug("Version check cache not found");
|
|
44077
45745
|
return null;
|
|
44078
45746
|
}
|
|
44079
|
-
const content = await
|
|
45747
|
+
const content = await readFile29(cacheFile, "utf-8");
|
|
44080
45748
|
const cache2 = JSON.parse(content);
|
|
44081
45749
|
if (!cache2.lastCheck || !cache2.currentVersion || !cache2.latestVersion) {
|
|
44082
45750
|
logger.debug("Invalid cache structure, ignoring");
|
|
@@ -44093,10 +45761,10 @@ class VersionCacheManager {
|
|
|
44093
45761
|
const cacheFile = VersionCacheManager.getCacheFile();
|
|
44094
45762
|
const cacheDir = PathResolver.getCacheDir(false);
|
|
44095
45763
|
try {
|
|
44096
|
-
if (!
|
|
45764
|
+
if (!existsSync21(cacheDir)) {
|
|
44097
45765
|
await mkdir22(cacheDir, { recursive: true, mode: 448 });
|
|
44098
45766
|
}
|
|
44099
|
-
await
|
|
45767
|
+
await writeFile24(cacheFile, JSON.stringify(cache2, null, 2), "utf-8");
|
|
44100
45768
|
logger.debug(`Version check cache saved to ${cacheFile}`);
|
|
44101
45769
|
} catch (error) {
|
|
44102
45770
|
logger.debug(`Failed to save version check cache: ${error}`);
|
|
@@ -44115,7 +45783,7 @@ class VersionCacheManager {
|
|
|
44115
45783
|
static async clear() {
|
|
44116
45784
|
const cacheFile = VersionCacheManager.getCacheFile();
|
|
44117
45785
|
try {
|
|
44118
|
-
if (
|
|
45786
|
+
if (existsSync21(cacheFile)) {
|
|
44119
45787
|
const fs14 = await import("node:fs/promises");
|
|
44120
45788
|
await fs14.unlink(cacheFile);
|
|
44121
45789
|
logger.debug("Version check cache cleared");
|
|
@@ -44335,11 +46003,11 @@ async function displayVersion() {
|
|
|
44335
46003
|
let localKitVersion = null;
|
|
44336
46004
|
let isGlobalOnlyKit = false;
|
|
44337
46005
|
const globalKitDir = PathResolver.getGlobalKitDir();
|
|
44338
|
-
const globalMetadataPath =
|
|
46006
|
+
const globalMetadataPath = join80(globalKitDir, "metadata.json");
|
|
44339
46007
|
const prefix = PathResolver.getPathPrefix(false);
|
|
44340
|
-
const localMetadataPath = prefix ?
|
|
46008
|
+
const localMetadataPath = prefix ? join80(process.cwd(), prefix, "metadata.json") : join80(process.cwd(), "metadata.json");
|
|
44341
46009
|
const isLocalSameAsGlobal = localMetadataPath === globalMetadataPath;
|
|
44342
|
-
if (!isLocalSameAsGlobal &&
|
|
46010
|
+
if (!isLocalSameAsGlobal && existsSync22(localMetadataPath)) {
|
|
44343
46011
|
try {
|
|
44344
46012
|
const rawMetadata = JSON.parse(readFileSync7(localMetadataPath, "utf-8"));
|
|
44345
46013
|
const metadata = MetadataSchema.parse(rawMetadata);
|
|
@@ -44353,7 +46021,7 @@ async function displayVersion() {
|
|
|
44353
46021
|
logger.verbose("Failed to parse local metadata.json", { error });
|
|
44354
46022
|
}
|
|
44355
46023
|
}
|
|
44356
|
-
if (
|
|
46024
|
+
if (existsSync22(globalMetadataPath)) {
|
|
44357
46025
|
try {
|
|
44358
46026
|
const rawMetadata = JSON.parse(readFileSync7(globalMetadataPath, "utf-8"));
|
|
44359
46027
|
const metadata = MetadataSchema.parse(rawMetadata);
|