claude-warden 2.0.1 → 2.3.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/.claude-plugin/plugin.json +1 -1
- package/README.md +78 -19
- package/config/warden.default.yaml +83 -31
- package/dist/codex-export.cjs +794 -298
- package/dist/index.cjs +799 -298
- package/package.json +2 -2
package/dist/codex-export.cjs
CHANGED
|
@@ -166,9 +166,9 @@ var require_compose_function = __commonJS({
|
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
-
// node_modules/.pnpm
|
|
169
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/shell-lexer.js
|
|
170
170
|
var require_shell_lexer = __commonJS({
|
|
171
|
-
"node_modules/.pnpm
|
|
171
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/shell-lexer.js"(exports2, module2) {
|
|
172
172
|
"use strict";
|
|
173
173
|
var compose = require_compose_function();
|
|
174
174
|
var posixShellLexer = (mode, options) => ({
|
|
@@ -220,9 +220,9 @@ var require_shell_lexer = __commonJS({
|
|
|
220
220
|
}
|
|
221
221
|
});
|
|
222
222
|
|
|
223
|
-
// node_modules/.pnpm
|
|
223
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/logger-phase.js
|
|
224
224
|
var require_logger_phase = __commonJS({
|
|
225
|
-
"node_modules/.pnpm
|
|
225
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/logger-phase.js"(exports2, module2) {
|
|
226
226
|
"use strict";
|
|
227
227
|
var logger = (name) => () => function* (tokens) {
|
|
228
228
|
for (const tk of tokens) {
|
|
@@ -273,9 +273,9 @@ var require_filter_obj = __commonJS({
|
|
|
273
273
|
}
|
|
274
274
|
});
|
|
275
275
|
|
|
276
|
-
// node_modules/.pnpm
|
|
276
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/enums/operators.js
|
|
277
277
|
var require_operators = __commonJS({
|
|
278
|
-
"node_modules/.pnpm
|
|
278
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/enums/operators.js"(exports2, module2) {
|
|
279
279
|
"use strict";
|
|
280
280
|
var operators = {
|
|
281
281
|
"&": "AND",
|
|
@@ -300,9 +300,9 @@ var require_operators = __commonJS({
|
|
|
300
300
|
}
|
|
301
301
|
});
|
|
302
302
|
|
|
303
|
-
// node_modules/.pnpm
|
|
303
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/tokens.js
|
|
304
304
|
var require_tokens = __commonJS({
|
|
305
|
-
"node_modules/.pnpm
|
|
305
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/tokens.js"(exports2) {
|
|
306
306
|
"use strict";
|
|
307
307
|
var hasOwnProperty = require_has_own_property();
|
|
308
308
|
var filter = require_filter_obj();
|
|
@@ -340,7 +340,7 @@ var require_tokens = __commonJS({
|
|
|
340
340
|
exports2.token = (args2) => new Token(args2);
|
|
341
341
|
function mkToken(type, value, loc, expansion) {
|
|
342
342
|
const tk = new Token({ type, value, loc });
|
|
343
|
-
if (expansion && expansion.length) {
|
|
343
|
+
if (expansion && expansion.length > 0) {
|
|
344
344
|
tk.expansion = expansion;
|
|
345
345
|
}
|
|
346
346
|
return tk;
|
|
@@ -366,12 +366,15 @@ var require_tokens = __commonJS({
|
|
|
366
366
|
exports2.setExpansions = (tk, expansion) => tk.setExpansions(expansion);
|
|
367
367
|
exports2.tokenOrEmpty = function tokenOrEmpty(state) {
|
|
368
368
|
if (state.current !== "" && state.current !== "\n") {
|
|
369
|
-
const expansion = (state.expansion || []).map(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
369
|
+
const expansion = (state.expansion || []).map(
|
|
370
|
+
(xp) => (
|
|
371
|
+
// console.log('aaa', {token: state.loc, xp: xp.loc});
|
|
372
|
+
Object.assign({}, xp, { loc: {
|
|
373
|
+
start: xp.loc.start.char - state.loc.start.char,
|
|
374
|
+
end: xp.loc.end.char - state.loc.start.char
|
|
375
|
+
} })
|
|
376
|
+
)
|
|
377
|
+
);
|
|
375
378
|
const token = mkToken("TOKEN", state.current, {
|
|
376
379
|
start: Object.assign({}, state.loc.start),
|
|
377
380
|
end: Object.assign({}, state.loc.previous)
|
|
@@ -420,12 +423,12 @@ var require_tokens = __commonJS({
|
|
|
420
423
|
}
|
|
421
424
|
});
|
|
422
425
|
|
|
423
|
-
// node_modules/.pnpm
|
|
426
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/is-valid-name.js
|
|
424
427
|
var require_is_valid_name = __commonJS({
|
|
425
|
-
"node_modules/.pnpm
|
|
428
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/is-valid-name.js"(exports2, module2) {
|
|
426
429
|
"use strict";
|
|
427
430
|
module2.exports = function isValidName(text) {
|
|
428
|
-
return /^[a-zA-Z_]
|
|
431
|
+
return /^[a-zA-Z_]\w*$/.test(text);
|
|
429
432
|
};
|
|
430
433
|
}
|
|
431
434
|
});
|
|
@@ -554,9 +557,9 @@ var require_iterable_transform_replace = __commonJS({
|
|
|
554
557
|
}
|
|
555
558
|
});
|
|
556
559
|
|
|
557
|
-
// node_modules/.pnpm
|
|
560
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/index.js
|
|
558
561
|
var require_utils = __commonJS({
|
|
559
|
-
"node_modules/.pnpm
|
|
562
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/index.js"(exports2) {
|
|
560
563
|
"use strict";
|
|
561
564
|
exports2.loggerPhase = require_logger_phase();
|
|
562
565
|
exports2.tokens = require_tokens();
|
|
@@ -655,9 +658,9 @@ var require_transform_spread_iterable = __commonJS({
|
|
|
655
658
|
}
|
|
656
659
|
});
|
|
657
660
|
|
|
658
|
-
// node_modules/.pnpm
|
|
661
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/bash/rules/alias-substitution.js
|
|
659
662
|
var require_alias_substitution = __commonJS({
|
|
660
|
-
"node_modules/.pnpm
|
|
663
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/bash/rules/alias-substitution.js"(exports2, module2) {
|
|
661
664
|
"use strict";
|
|
662
665
|
var compose = require_compose_function();
|
|
663
666
|
var identity = require_identity_function();
|
|
@@ -667,7 +670,7 @@ var require_alias_substitution = __commonJS({
|
|
|
667
670
|
var tokens = require_tokens();
|
|
668
671
|
var expandAlias = (preAliasLexer, resolveAlias, reservedWords) => {
|
|
669
672
|
function* tryExpandToken(token, expandingAliases) {
|
|
670
|
-
if (expandingAliases.
|
|
673
|
+
if (expandingAliases.includes(token.value)) {
|
|
671
674
|
yield token;
|
|
672
675
|
return;
|
|
673
676
|
}
|
|
@@ -693,9 +696,9 @@ var require_alias_substitution = __commonJS({
|
|
|
693
696
|
const visitor = {
|
|
694
697
|
WORD: expandToken
|
|
695
698
|
};
|
|
696
|
-
|
|
699
|
+
for (const w of reservedWords) {
|
|
697
700
|
visitor[w] = expandToken;
|
|
698
|
-
}
|
|
701
|
+
}
|
|
699
702
|
return visitor;
|
|
700
703
|
};
|
|
701
704
|
module2.exports = (options, mode, previousPhases) => {
|
|
@@ -714,9 +717,9 @@ var require_alias_substitution = __commonJS({
|
|
|
714
717
|
}
|
|
715
718
|
});
|
|
716
719
|
|
|
717
|
-
// node_modules/.pnpm
|
|
720
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/bash/index.js
|
|
718
721
|
var require_bash = __commonJS({
|
|
719
|
-
"node_modules/.pnpm
|
|
722
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/bash/index.js"(exports2, module2) {
|
|
720
723
|
"use strict";
|
|
721
724
|
var bashAliasSubstitution = require_alias_substitution();
|
|
722
725
|
var name = "[a-zA-Z_][a-zA-Z0-9_]*";
|
|
@@ -727,8 +730,8 @@ var require_bash = __commonJS({
|
|
|
727
730
|
[`^(${name}):([^:]*):?([^:]*)$`]: {
|
|
728
731
|
op: "substring",
|
|
729
732
|
parameter: (m) => m[1],
|
|
730
|
-
offset: (m) => parseInt(m[2], 10),
|
|
731
|
-
length: (m) => parseInt(m[3], 10) || void 0
|
|
733
|
+
offset: (m) => Number.parseInt(m[2], 10),
|
|
734
|
+
length: (m) => Number.parseInt(m[3], 10) || void 0
|
|
732
735
|
},
|
|
733
736
|
// Expands to the names of variables whose names begin with prefix,
|
|
734
737
|
// separated by the first character of the IFS special variable.
|
|
@@ -806,18 +809,24 @@ var require_bash = __commonJS({
|
|
|
806
809
|
parameter: (m) => m[1],
|
|
807
810
|
kind: (m) => {
|
|
808
811
|
switch (m[2]) {
|
|
809
|
-
case "Q":
|
|
812
|
+
case "Q": {
|
|
810
813
|
return "quoted";
|
|
811
|
-
|
|
814
|
+
}
|
|
815
|
+
case "E": {
|
|
812
816
|
return "escape";
|
|
813
|
-
|
|
817
|
+
}
|
|
818
|
+
case "P": {
|
|
814
819
|
return "prompt";
|
|
815
|
-
|
|
820
|
+
}
|
|
821
|
+
case "A": {
|
|
816
822
|
return "assignment";
|
|
817
|
-
|
|
823
|
+
}
|
|
824
|
+
case "a": {
|
|
818
825
|
return "flags";
|
|
819
|
-
|
|
826
|
+
}
|
|
827
|
+
default: {
|
|
820
828
|
return "unknown";
|
|
829
|
+
}
|
|
821
830
|
}
|
|
822
831
|
}
|
|
823
832
|
},
|
|
@@ -830,7 +839,7 @@ var require_bash = __commonJS({
|
|
|
830
839
|
// performing the complete indirect expansion. The exceptions to this are the expansions
|
|
831
840
|
// of ${!prefix*} and ${!name[@]} described below. The exclamation point must immediately
|
|
832
841
|
// follow the left brace in order to introduce indirection.
|
|
833
|
-
|
|
842
|
+
"^!(.+)$": {
|
|
834
843
|
op: "indirection",
|
|
835
844
|
word: (m) => m[1],
|
|
836
845
|
parameter: () => void 0
|
|
@@ -910,9 +919,9 @@ var require_array_last = __commonJS({
|
|
|
910
919
|
}
|
|
911
920
|
});
|
|
912
921
|
|
|
913
|
-
// node_modules/.pnpm
|
|
922
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/ast-builder.js
|
|
914
923
|
var require_ast_builder = __commonJS({
|
|
915
|
-
"node_modules/.pnpm
|
|
924
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/ast-builder.js"(exports2, module2) {
|
|
916
925
|
"use strict";
|
|
917
926
|
module2.exports = (options) => {
|
|
918
927
|
const builder = {};
|
|
@@ -959,7 +968,7 @@ var require_ast_builder = __commonJS({
|
|
|
959
968
|
return node;
|
|
960
969
|
};
|
|
961
970
|
function isAsyncSeparator(separator) {
|
|
962
|
-
return separator.text.
|
|
971
|
+
return separator.text.includes("&");
|
|
963
972
|
}
|
|
964
973
|
const last = require_array_last();
|
|
965
974
|
builder.checkAsync = (list, separator) => {
|
|
@@ -981,7 +990,7 @@ var require_ast_builder = __commonJS({
|
|
|
981
990
|
builder.addRedirections = (compoundCommand, redirectList) => {
|
|
982
991
|
compoundCommand.redirections = redirectList;
|
|
983
992
|
if (options.insertLOC) {
|
|
984
|
-
const lastRedirect = redirectList
|
|
993
|
+
const lastRedirect = redirectList.at(-1);
|
|
985
994
|
setLocEnd(compoundCommand.loc, lastRedirect.loc);
|
|
986
995
|
}
|
|
987
996
|
return compoundCommand;
|
|
@@ -1123,12 +1132,12 @@ var require_ast_builder = __commonJS({
|
|
|
1123
1132
|
node.loc.start = command.loc.start;
|
|
1124
1133
|
}
|
|
1125
1134
|
if (suffix) {
|
|
1126
|
-
const lastSuffix = suffix
|
|
1135
|
+
const lastSuffix = suffix.at(-1);
|
|
1127
1136
|
node.loc.end = lastSuffix.loc.end;
|
|
1128
1137
|
} else if (command) {
|
|
1129
1138
|
node.loc.end = command.loc.end;
|
|
1130
1139
|
} else {
|
|
1131
|
-
const lastPrefix = prefix
|
|
1140
|
+
const lastPrefix = prefix.at(-1);
|
|
1132
1141
|
node.loc.end = lastPrefix.loc.end;
|
|
1133
1142
|
}
|
|
1134
1143
|
}
|
|
@@ -1169,9 +1178,7 @@ var require_ast_builder = __commonJS({
|
|
|
1169
1178
|
return target;
|
|
1170
1179
|
}
|
|
1171
1180
|
function mkListHelper(builder, listName) {
|
|
1172
|
-
builder[listName] = (item) =>
|
|
1173
|
-
return [item];
|
|
1174
|
-
};
|
|
1181
|
+
builder[listName] = (item) => [item];
|
|
1175
1182
|
builder[`${listName}Append`] = (list, item) => {
|
|
1176
1183
|
list.push(item);
|
|
1177
1184
|
return list;
|
|
@@ -1196,9 +1203,9 @@ var require_deep_freeze = __commonJS({
|
|
|
1196
1203
|
}
|
|
1197
1204
|
});
|
|
1198
1205
|
|
|
1199
|
-
// node_modules/.pnpm
|
|
1206
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/end.js
|
|
1200
1207
|
var require_end = __commonJS({
|
|
1201
|
-
"node_modules/.pnpm
|
|
1208
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/end.js"(exports2, module2) {
|
|
1202
1209
|
"use strict";
|
|
1203
1210
|
var eof = require_tokens().eof;
|
|
1204
1211
|
module2.exports = function end() {
|
|
@@ -1210,9 +1217,9 @@ var require_end = __commonJS({
|
|
|
1210
1217
|
}
|
|
1211
1218
|
});
|
|
1212
1219
|
|
|
1213
|
-
// node_modules/.pnpm
|
|
1220
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/operator.js
|
|
1214
1221
|
var require_operator = __commonJS({
|
|
1215
|
-
"node_modules/.pnpm
|
|
1222
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/operator.js"(exports2, module2) {
|
|
1216
1223
|
"use strict";
|
|
1217
1224
|
var t = require_tokens();
|
|
1218
1225
|
var isPartOfOperator = t.isPartOfOperator;
|
|
@@ -1257,9 +1264,9 @@ var require_operator = __commonJS({
|
|
|
1257
1264
|
}
|
|
1258
1265
|
});
|
|
1259
1266
|
|
|
1260
|
-
// node_modules/.pnpm
|
|
1267
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/comment.js
|
|
1261
1268
|
var require_comment = __commonJS({
|
|
1262
|
-
"node_modules/.pnpm
|
|
1269
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/comment.js"(exports2, module2) {
|
|
1263
1270
|
"use strict";
|
|
1264
1271
|
var newLine = require_tokens().newLine;
|
|
1265
1272
|
module2.exports = function comment(state, source, reducers) {
|
|
@@ -1285,9 +1292,9 @@ var require_comment = __commonJS({
|
|
|
1285
1292
|
}
|
|
1286
1293
|
});
|
|
1287
1294
|
|
|
1288
|
-
// node_modules/.pnpm
|
|
1295
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/single-quoting.js
|
|
1289
1296
|
var require_single_quoting = __commonJS({
|
|
1290
|
-
"node_modules/.pnpm
|
|
1297
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/single-quoting.js"(exports2, module2) {
|
|
1291
1298
|
"use strict";
|
|
1292
1299
|
var t = require_tokens();
|
|
1293
1300
|
var tokenOrEmpty = t.tokenOrEmpty;
|
|
@@ -1315,9 +1322,9 @@ var require_single_quoting = __commonJS({
|
|
|
1315
1322
|
}
|
|
1316
1323
|
});
|
|
1317
1324
|
|
|
1318
|
-
// node_modules/.pnpm
|
|
1325
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/double-quoting.js
|
|
1319
1326
|
var require_double_quoting = __commonJS({
|
|
1320
|
-
"node_modules/.pnpm
|
|
1327
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/double-quoting.js"(exports2, module2) {
|
|
1321
1328
|
"use strict";
|
|
1322
1329
|
var t = require_tokens();
|
|
1323
1330
|
var tokenOrEmpty = t.tokenOrEmpty;
|
|
@@ -1364,12 +1371,12 @@ var require_double_quoting = __commonJS({
|
|
|
1364
1371
|
}
|
|
1365
1372
|
});
|
|
1366
1373
|
|
|
1367
|
-
// node_modules/.pnpm
|
|
1374
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-start.js
|
|
1368
1375
|
var require_expansion_start = __commonJS({
|
|
1369
|
-
"node_modules/.pnpm
|
|
1376
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-start.js"(exports2, module2) {
|
|
1370
1377
|
"use strict";
|
|
1371
1378
|
function isSpecialParameter(char) {
|
|
1372
|
-
return char.match(/^[
|
|
1379
|
+
return char.match(/^[\d\-!@#?*$]$/);
|
|
1373
1380
|
}
|
|
1374
1381
|
module2.exports = function expansionStart(state, source, reducers) {
|
|
1375
1382
|
const char = source && source.shift();
|
|
@@ -1385,7 +1392,7 @@ var require_expansion_start = __commonJS({
|
|
|
1385
1392
|
nextState: state.appendChar(char)
|
|
1386
1393
|
};
|
|
1387
1394
|
}
|
|
1388
|
-
if (
|
|
1395
|
+
if (/[a-zA-Z_]/.test(char)) {
|
|
1389
1396
|
return {
|
|
1390
1397
|
nextReduction: reducers.expansionParameter,
|
|
1391
1398
|
nextState: state.appendChar(char).replaceLastExpansion({
|
|
@@ -1395,16 +1402,17 @@ var require_expansion_start = __commonJS({
|
|
|
1395
1402
|
};
|
|
1396
1403
|
}
|
|
1397
1404
|
if (isSpecialParameter(char)) {
|
|
1398
|
-
return reducers.expansionSpecialParameter(state, [char].concat(source));
|
|
1405
|
+
return reducers.expansionSpecialParameter(state, [char].concat(source), reducers);
|
|
1399
1406
|
}
|
|
1400
|
-
|
|
1407
|
+
const cleanState = state.removeLastExpansion();
|
|
1408
|
+
return cleanState.previousReducer(cleanState, [char].concat(source), reducers);
|
|
1401
1409
|
};
|
|
1402
1410
|
}
|
|
1403
1411
|
});
|
|
1404
1412
|
|
|
1405
|
-
// node_modules/.pnpm
|
|
1413
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-command-tick.js
|
|
1406
1414
|
var require_expansion_command_tick = __commonJS({
|
|
1407
|
-
"node_modules/.pnpm
|
|
1415
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-command-tick.js"(exports2, module2) {
|
|
1408
1416
|
"use strict";
|
|
1409
1417
|
var last = require_array_last();
|
|
1410
1418
|
var t = require_tokens();
|
|
@@ -1444,9 +1452,9 @@ var require_expansion_command_tick = __commonJS({
|
|
|
1444
1452
|
}
|
|
1445
1453
|
});
|
|
1446
1454
|
|
|
1447
|
-
// node_modules/.pnpm
|
|
1455
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/start.js
|
|
1448
1456
|
var require_start = __commonJS({
|
|
1449
|
-
"node_modules/.pnpm
|
|
1457
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/start.js"(exports2, module2) {
|
|
1450
1458
|
"use strict";
|
|
1451
1459
|
var t = require_tokens();
|
|
1452
1460
|
var tokenOrEmpty = t.tokenOrEmpty;
|
|
@@ -1504,7 +1512,7 @@ var require_start = __commonJS({
|
|
|
1504
1512
|
nextState: state.appendChar(char)
|
|
1505
1513
|
};
|
|
1506
1514
|
}
|
|
1507
|
-
if (!state.escaping &&
|
|
1515
|
+
if (!state.escaping && /\s/.test(char)) {
|
|
1508
1516
|
return {
|
|
1509
1517
|
nextReduction: reducers.start,
|
|
1510
1518
|
tokensToEmit: tokenOrEmpty(state),
|
|
@@ -1531,9 +1539,9 @@ var require_start = __commonJS({
|
|
|
1531
1539
|
}
|
|
1532
1540
|
});
|
|
1533
1541
|
|
|
1534
|
-
// node_modules/.pnpm
|
|
1542
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-arithmetic.js
|
|
1535
1543
|
var require_expansion_arithmetic = __commonJS({
|
|
1536
|
-
"node_modules/.pnpm
|
|
1544
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-arithmetic.js"(exports2, module2) {
|
|
1537
1545
|
"use strict";
|
|
1538
1546
|
var last = require_array_last();
|
|
1539
1547
|
var t = require_tokens();
|
|
@@ -1541,7 +1549,7 @@ var require_expansion_arithmetic = __commonJS({
|
|
|
1541
1549
|
module2.exports = function expansionArithmetic(state, source) {
|
|
1542
1550
|
const char = source && source.shift();
|
|
1543
1551
|
const xp = last(state.expansion);
|
|
1544
|
-
if (char === ")" && state.current.
|
|
1552
|
+
if (char === ")" && state.current.at(-1) === ")") {
|
|
1545
1553
|
return {
|
|
1546
1554
|
nextReduction: state.previousReducer,
|
|
1547
1555
|
nextState: state.appendChar(char).replaceLastExpansion({
|
|
@@ -1568,12 +1576,12 @@ var require_expansion_arithmetic = __commonJS({
|
|
|
1568
1576
|
}
|
|
1569
1577
|
});
|
|
1570
1578
|
|
|
1571
|
-
// node_modules/.pnpm
|
|
1579
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-special-parameter.js
|
|
1572
1580
|
var require_expansion_special_parameter = __commonJS({
|
|
1573
|
-
"node_modules/.pnpm
|
|
1581
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-special-parameter.js"(exports2, module2) {
|
|
1574
1582
|
"use strict";
|
|
1575
1583
|
var last = require_array_last();
|
|
1576
|
-
module2.exports = function expansionSpecialParameter(state, source) {
|
|
1584
|
+
module2.exports = function expansionSpecialParameter(state, source, _reducers) {
|
|
1577
1585
|
const char = source && source.shift();
|
|
1578
1586
|
const xp = last(state.expansion);
|
|
1579
1587
|
return {
|
|
@@ -1588,9 +1596,9 @@ var require_expansion_special_parameter = __commonJS({
|
|
|
1588
1596
|
}
|
|
1589
1597
|
});
|
|
1590
1598
|
|
|
1591
|
-
// node_modules/.pnpm
|
|
1599
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-parameter.js
|
|
1592
1600
|
var require_expansion_parameter = __commonJS({
|
|
1593
|
-
"node_modules/.pnpm
|
|
1601
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-parameter.js"(exports2, module2) {
|
|
1594
1602
|
"use strict";
|
|
1595
1603
|
var last = require_array_last();
|
|
1596
1604
|
module2.exports = function expansionParameter(state, source, reducers) {
|
|
@@ -1604,7 +1612,7 @@ var require_expansion_parameter = __commonJS({
|
|
|
1604
1612
|
})
|
|
1605
1613
|
};
|
|
1606
1614
|
}
|
|
1607
|
-
if (char
|
|
1615
|
+
if (/\w/.test(char)) {
|
|
1608
1616
|
return {
|
|
1609
1617
|
nextReduction: reducers.expansionParameter,
|
|
1610
1618
|
nextState: state.appendChar(char).replaceLastExpansion({
|
|
@@ -1621,9 +1629,9 @@ var require_expansion_parameter = __commonJS({
|
|
|
1621
1629
|
}
|
|
1622
1630
|
});
|
|
1623
1631
|
|
|
1624
|
-
// node_modules/.pnpm
|
|
1632
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-command-or-arithmetic.js
|
|
1625
1633
|
var require_expansion_command_or_arithmetic = __commonJS({
|
|
1626
|
-
"node_modules/.pnpm
|
|
1634
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-command-or-arithmetic.js"(exports2, module2) {
|
|
1627
1635
|
"use strict";
|
|
1628
1636
|
var last = require_array_last();
|
|
1629
1637
|
var t = require_tokens();
|
|
@@ -1665,9 +1673,9 @@ var require_expansion_command_or_arithmetic = __commonJS({
|
|
|
1665
1673
|
}
|
|
1666
1674
|
});
|
|
1667
1675
|
|
|
1668
|
-
// node_modules/.pnpm
|
|
1676
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-parameter-extended.js
|
|
1669
1677
|
var require_expansion_parameter_extended = __commonJS({
|
|
1670
|
-
"node_modules/.pnpm
|
|
1678
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/expansion-parameter-extended.js"(exports2, module2) {
|
|
1671
1679
|
"use strict";
|
|
1672
1680
|
var last = require_array_last();
|
|
1673
1681
|
var t = require_tokens();
|
|
@@ -1701,9 +1709,9 @@ var require_expansion_parameter_extended = __commonJS({
|
|
|
1701
1709
|
}
|
|
1702
1710
|
});
|
|
1703
1711
|
|
|
1704
|
-
// node_modules/.pnpm
|
|
1712
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/index.js
|
|
1705
1713
|
var require_reducers = __commonJS({
|
|
1706
|
-
"node_modules/.pnpm
|
|
1714
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/reducers/index.js"(exports2, module2) {
|
|
1707
1715
|
"use strict";
|
|
1708
1716
|
var end = require_end();
|
|
1709
1717
|
var operator = require_operator();
|
|
@@ -1736,9 +1744,9 @@ var require_reducers = __commonJS({
|
|
|
1736
1744
|
}
|
|
1737
1745
|
});
|
|
1738
1746
|
|
|
1739
|
-
// node_modules/.pnpm
|
|
1747
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/index.js
|
|
1740
1748
|
var require_tokenizer = __commonJS({
|
|
1741
|
-
"node_modules/.pnpm
|
|
1749
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/tokenizer/index.js"(exports2, module2) {
|
|
1742
1750
|
"use strict";
|
|
1743
1751
|
var deepFreeze = require_deep_freeze();
|
|
1744
1752
|
var last = require_array_last();
|
|
@@ -1778,6 +1786,9 @@ var require_tokenizer = __commonJS({
|
|
|
1778
1786
|
});
|
|
1779
1787
|
return this.setExpansion(expansion);
|
|
1780
1788
|
}
|
|
1789
|
+
removeLastExpansion() {
|
|
1790
|
+
return this.setExpansion((this.expansion || []).slice(0, -1));
|
|
1791
|
+
}
|
|
1781
1792
|
appendChar(char) {
|
|
1782
1793
|
return new ImmutableState(Object.assign({}, this, { current: this.current + char }));
|
|
1783
1794
|
}
|
|
@@ -1806,7 +1817,7 @@ var require_tokenizer = __commonJS({
|
|
|
1806
1817
|
loc.current.col++;
|
|
1807
1818
|
}
|
|
1808
1819
|
loc.current.char++;
|
|
1809
|
-
if (char &&
|
|
1820
|
+
if (char && /\s/.test(char) && this.current === "") {
|
|
1810
1821
|
loc.start = Object.assign({}, loc.current);
|
|
1811
1822
|
}
|
|
1812
1823
|
return this.setLoc(loc);
|
|
@@ -1843,8 +1854,12 @@ var require_tokenizer = __commonJS({
|
|
|
1843
1854
|
});
|
|
1844
1855
|
return this;
|
|
1845
1856
|
}
|
|
1857
|
+
removeLastExpansion() {
|
|
1858
|
+
this.expansion = (this.expansion || []).slice(0, -1);
|
|
1859
|
+
return this;
|
|
1860
|
+
}
|
|
1846
1861
|
appendChar(char) {
|
|
1847
|
-
this.current
|
|
1862
|
+
this.current += char;
|
|
1848
1863
|
return this;
|
|
1849
1864
|
}
|
|
1850
1865
|
removeLastChar() {
|
|
@@ -1879,7 +1894,7 @@ var require_tokenizer = __commonJS({
|
|
|
1879
1894
|
loc.current.col++;
|
|
1880
1895
|
}
|
|
1881
1896
|
loc.current.char++;
|
|
1882
|
-
if (char &&
|
|
1897
|
+
if (char && /\s/.test(char) && this.current === "") {
|
|
1883
1898
|
loc.start = Object.assign({}, loc.current);
|
|
1884
1899
|
}
|
|
1885
1900
|
return this.setLoc(loc);
|
|
@@ -1900,11 +1915,7 @@ var require_tokenizer = __commonJS({
|
|
|
1900
1915
|
if (tokensToEmit) {
|
|
1901
1916
|
yield* tokensToEmit;
|
|
1902
1917
|
}
|
|
1903
|
-
|
|
1904
|
-
state = nextState.advanceLoc(char);
|
|
1905
|
-
} else {
|
|
1906
|
-
state = state.advanceLoc(char);
|
|
1907
|
-
}
|
|
1918
|
+
state = nextState ? nextState.advanceLoc(char) : state.advanceLoc(char);
|
|
1908
1919
|
reduction = nextReduction;
|
|
1909
1920
|
}
|
|
1910
1921
|
};
|
|
@@ -2899,9 +2910,9 @@ var init_magic_string_es6 = __esm({
|
|
|
2899
2910
|
}
|
|
2900
2911
|
});
|
|
2901
2912
|
|
|
2902
|
-
// node_modules/.pnpm
|
|
2913
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/field-splitting.js
|
|
2903
2914
|
var require_field_splitting = __commonJS({
|
|
2904
|
-
"node_modules/.pnpm
|
|
2915
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/field-splitting.js"(exports2) {
|
|
2905
2916
|
"use strict";
|
|
2906
2917
|
var map = require_map_iterable();
|
|
2907
2918
|
var merge = require_transform_spread_iterable();
|
|
@@ -2911,7 +2922,7 @@ var require_field_splitting = __commonJS({
|
|
|
2911
2922
|
if (typeof options.resolveEnv === "function" && text[0] !== "'" && text[0] !== '"') {
|
|
2912
2923
|
const ifs = options.resolveEnv("IFS");
|
|
2913
2924
|
if (ifs !== null) {
|
|
2914
|
-
return result.
|
|
2925
|
+
return result.replaceAll(new RegExp(`[${ifs}]+`, "g"), "\0");
|
|
2915
2926
|
}
|
|
2916
2927
|
}
|
|
2917
2928
|
return result;
|
|
@@ -2934,9 +2945,9 @@ var require_field_splitting = __commonJS({
|
|
|
2934
2945
|
}
|
|
2935
2946
|
});
|
|
2936
2947
|
|
|
2937
|
-
// node_modules/.pnpm
|
|
2948
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/parameter-expansion.js
|
|
2938
2949
|
var require_parameter_expansion = __commonJS({
|
|
2939
|
-
"node_modules/.pnpm
|
|
2950
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/parameter-expansion.js"(exports2, module2) {
|
|
2940
2951
|
"use strict";
|
|
2941
2952
|
var mapObj = require_map_obj();
|
|
2942
2953
|
var filter = require_filter_obj();
|
|
@@ -2967,7 +2978,7 @@ var require_parameter_expansion = __commonJS({
|
|
|
2967
2978
|
return ret;
|
|
2968
2979
|
};
|
|
2969
2980
|
function expandParameter(xp, enums) {
|
|
2970
|
-
|
|
2981
|
+
const parameter = xp.parameter;
|
|
2971
2982
|
for (const pair of pairs(enums.parameterOperators)) {
|
|
2972
2983
|
const re = new RegExp(pair[0]);
|
|
2973
2984
|
const match = parameter.match(re);
|
|
@@ -3021,9 +3032,9 @@ var require_parameter_expansion = __commonJS({
|
|
|
3021
3032
|
}
|
|
3022
3033
|
});
|
|
3023
3034
|
|
|
3024
|
-
// node_modules/.pnpm
|
|
3035
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/command-expansion.js
|
|
3025
3036
|
var require_command_expansion = __commonJS({
|
|
3026
|
-
"node_modules/.pnpm
|
|
3037
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/command-expansion.js"(exports2, module2) {
|
|
3027
3038
|
"use strict";
|
|
3028
3039
|
var map = require_map_iterable();
|
|
3029
3040
|
var MagicString2 = (init_magic_string_es6(), __toCommonJS(magic_string_es6_exports));
|
|
@@ -3032,7 +3043,7 @@ var require_command_expansion = __commonJS({
|
|
|
3032
3043
|
function setCommandExpansion(xp, token) {
|
|
3033
3044
|
let command = xp.command;
|
|
3034
3045
|
if (token.value[xp.loc.start - 1] === "`") {
|
|
3035
|
-
command = command.
|
|
3046
|
+
command = command.replaceAll("\\`", "`");
|
|
3036
3047
|
}
|
|
3037
3048
|
const bashParser = require_src();
|
|
3038
3049
|
const commandAST = bashParser(command);
|
|
@@ -8656,9 +8667,9 @@ var require_lib = __commonJS({
|
|
|
8656
8667
|
}
|
|
8657
8668
|
});
|
|
8658
8669
|
|
|
8659
|
-
// node_modules/.pnpm
|
|
8670
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/arithmetic-expansion.js
|
|
8660
8671
|
var require_arithmetic_expansion = __commonJS({
|
|
8661
|
-
"node_modules/.pnpm
|
|
8672
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/arithmetic-expansion.js"(exports2, module2) {
|
|
8662
8673
|
"use strict";
|
|
8663
8674
|
var map = require_map_iterable();
|
|
8664
8675
|
var babylon = require_lib();
|
|
@@ -8669,8 +8680,8 @@ var require_arithmetic_expansion = __commonJS({
|
|
|
8669
8680
|
let AST;
|
|
8670
8681
|
try {
|
|
8671
8682
|
AST = babylon.parse(xp.expression);
|
|
8672
|
-
} catch (
|
|
8673
|
-
throw new SyntaxError(`Cannot parse arithmetic expression "${xp.expression}": ${
|
|
8683
|
+
} catch (error) {
|
|
8684
|
+
throw new SyntaxError(`Cannot parse arithmetic expression "${xp.expression}": ${error.message}`);
|
|
8674
8685
|
}
|
|
8675
8686
|
const expression = AST.program.body[0].expression;
|
|
8676
8687
|
if (expression === void 0) {
|
|
@@ -8715,9 +8726,9 @@ var require_arithmetic_expansion = __commonJS({
|
|
|
8715
8726
|
}
|
|
8716
8727
|
});
|
|
8717
8728
|
|
|
8718
|
-
// node_modules/.pnpm
|
|
8729
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/alias-substitution.js
|
|
8719
8730
|
var require_alias_substitution2 = __commonJS({
|
|
8720
|
-
"node_modules/.pnpm
|
|
8731
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/alias-substitution.js"(exports2, module2) {
|
|
8721
8732
|
"use strict";
|
|
8722
8733
|
var compose = require_compose_function();
|
|
8723
8734
|
var identity = require_identity_function();
|
|
@@ -8726,7 +8737,7 @@ var require_alias_substitution2 = __commonJS({
|
|
|
8726
8737
|
var tokens = require_tokens();
|
|
8727
8738
|
var expandAlias = (preAliasLexer, resolveAlias) => {
|
|
8728
8739
|
function* tryExpandToken(token, expandingAliases) {
|
|
8729
|
-
if (expandingAliases.
|
|
8740
|
+
if (expandingAliases.includes(token.value) || !token._.maybeSimpleCommandName) {
|
|
8730
8741
|
yield token;
|
|
8731
8742
|
return;
|
|
8732
8743
|
}
|
|
@@ -8747,9 +8758,7 @@ var require_alias_substitution2 = __commonJS({
|
|
|
8747
8758
|
}
|
|
8748
8759
|
}
|
|
8749
8760
|
return {
|
|
8750
|
-
WORD: (tk) =>
|
|
8751
|
-
return Array.from(tryExpandToken(tk, []));
|
|
8752
|
-
}
|
|
8761
|
+
WORD: (tk) => Array.from(tryExpandToken(tk, []))
|
|
8753
8762
|
};
|
|
8754
8763
|
};
|
|
8755
8764
|
module2.exports = (options, mode, previousPhases) => {
|
|
@@ -8825,9 +8834,9 @@ var require_to_pascal_case = __commonJS({
|
|
|
8825
8834
|
}
|
|
8826
8835
|
});
|
|
8827
8836
|
|
|
8828
|
-
// node_modules/.pnpm
|
|
8837
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/default-node-type.js
|
|
8829
8838
|
var require_default_node_type = __commonJS({
|
|
8830
|
-
"node_modules/.pnpm
|
|
8839
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/default-node-type.js"(exports2, module2) {
|
|
8831
8840
|
"use strict";
|
|
8832
8841
|
var toPascal = require_to_pascal_case();
|
|
8833
8842
|
var map = require_map_iterable();
|
|
@@ -8835,11 +8844,7 @@ var require_default_node_type = __commonJS({
|
|
|
8835
8844
|
const tk = Object.assign({}, token);
|
|
8836
8845
|
if (tk.type) {
|
|
8837
8846
|
tk.originalType = token.type;
|
|
8838
|
-
|
|
8839
|
-
tk.type = toPascal(tk.type);
|
|
8840
|
-
} else {
|
|
8841
|
-
tk.type = token.type.toLowerCase();
|
|
8842
|
-
}
|
|
8847
|
+
tk.type = token.is("WORD") || token.is("NAME") || token.is("ASSIGNMENT_WORD") ? toPascal(tk.type) : token.type.toLowerCase();
|
|
8843
8848
|
for (const xp of tk.expansion || []) {
|
|
8844
8849
|
xp.type = toPascal(xp.type);
|
|
8845
8850
|
}
|
|
@@ -8850,22 +8855,20 @@ var require_default_node_type = __commonJS({
|
|
|
8850
8855
|
}
|
|
8851
8856
|
});
|
|
8852
8857
|
|
|
8853
|
-
// node_modules/.pnpm
|
|
8858
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/tilde-expanding.js
|
|
8854
8859
|
var require_tilde_expanding = __commonJS({
|
|
8855
|
-
"node_modules/.pnpm
|
|
8860
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/tilde-expanding.js"(exports2, module2) {
|
|
8856
8861
|
"use strict";
|
|
8857
8862
|
var map = require_map_iterable();
|
|
8858
8863
|
var tokens = require_tokens();
|
|
8859
8864
|
var replace = (text, resolveHomeUser) => {
|
|
8860
8865
|
let replaced = false;
|
|
8861
|
-
let result = text.replace(/^~([
|
|
8866
|
+
let result = text.replace(/^~([^/]*)\//, (match, p1) => {
|
|
8862
8867
|
replaced = true;
|
|
8863
8868
|
return resolveHomeUser(p1 || null) + "/";
|
|
8864
8869
|
});
|
|
8865
8870
|
if (!replaced) {
|
|
8866
|
-
result = text.replace(/^~(.*)$/, (match, p1) =>
|
|
8867
|
-
return resolveHomeUser(p1 || null);
|
|
8868
|
-
});
|
|
8871
|
+
result = text.replace(/^~(.*)$/, (match, p1) => resolveHomeUser(p1 || null));
|
|
8869
8872
|
}
|
|
8870
8873
|
return result;
|
|
8871
8874
|
};
|
|
@@ -8885,9 +8888,9 @@ var require_tilde_expanding = __commonJS({
|
|
|
8885
8888
|
}
|
|
8886
8889
|
});
|
|
8887
8890
|
|
|
8888
|
-
// node_modules/.pnpm
|
|
8891
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/path-expansion.js
|
|
8889
8892
|
var require_path_expansion = __commonJS({
|
|
8890
|
-
"node_modules/.pnpm
|
|
8893
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/path-expansion.js"(exports2, module2) {
|
|
8891
8894
|
"use strict";
|
|
8892
8895
|
var map = require_map_iterable();
|
|
8893
8896
|
var tokens = require_tokens();
|
|
@@ -9097,9 +9100,9 @@ var require_dist = __commonJS({
|
|
|
9097
9100
|
}
|
|
9098
9101
|
});
|
|
9099
9102
|
|
|
9100
|
-
// node_modules/.pnpm
|
|
9103
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/quote-removal.js
|
|
9101
9104
|
var require_quote_removal = __commonJS({
|
|
9102
|
-
"node_modules/.pnpm
|
|
9105
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/quote-removal.js"(exports2, module2) {
|
|
9103
9106
|
"use strict";
|
|
9104
9107
|
var parse2 = require_shell_quote_word();
|
|
9105
9108
|
var unescape = require_dist();
|
|
@@ -9123,10 +9126,8 @@ var require_quote_removal = __commonJS({
|
|
|
9123
9126
|
return unresolved.length > 0;
|
|
9124
9127
|
}
|
|
9125
9128
|
module2.exports = () => map((token) => {
|
|
9126
|
-
if (token.is("WORD") || token.is("ASSIGNMENT_WORD")) {
|
|
9127
|
-
|
|
9128
|
-
return tokens.setValue(token, unquote(token.value));
|
|
9129
|
-
}
|
|
9129
|
+
if ((token.is("WORD") || token.is("ASSIGNMENT_WORD")) && !unresolvedExpansions(token)) {
|
|
9130
|
+
return tokens.setValue(token, unquote(token.value));
|
|
9130
9131
|
}
|
|
9131
9132
|
return token;
|
|
9132
9133
|
});
|
|
@@ -9208,9 +9209,9 @@ var require_iterable_lookahead = __commonJS({
|
|
|
9208
9209
|
}
|
|
9209
9210
|
});
|
|
9210
9211
|
|
|
9211
|
-
// node_modules/.pnpm
|
|
9212
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/identify-simplecommand-names.js
|
|
9212
9213
|
var require_identify_simplecommand_names = __commonJS({
|
|
9213
|
-
"node_modules/.pnpm
|
|
9214
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/identify-simplecommand-names.js"(exports2, module2) {
|
|
9214
9215
|
"use strict";
|
|
9215
9216
|
var lookahead = require_iterable_lookahead();
|
|
9216
9217
|
var compose = require_compose_function();
|
|
@@ -9253,9 +9254,9 @@ var require_identify_simplecommand_names = __commonJS({
|
|
|
9253
9254
|
}
|
|
9254
9255
|
});
|
|
9255
9256
|
|
|
9256
|
-
// node_modules/.pnpm
|
|
9257
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/identify-maybe-simple-commands.js
|
|
9257
9258
|
var require_identify_maybe_simple_commands = __commonJS({
|
|
9258
|
-
"node_modules/.pnpm
|
|
9259
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/identify-maybe-simple-commands.js"(exports2, module2) {
|
|
9259
9260
|
"use strict";
|
|
9260
9261
|
var values = require_object_values();
|
|
9261
9262
|
var compose = require_compose_function();
|
|
@@ -9273,9 +9274,9 @@ var require_identify_maybe_simple_commands = __commonJS({
|
|
|
9273
9274
|
}
|
|
9274
9275
|
});
|
|
9275
9276
|
|
|
9276
|
-
// node_modules/.pnpm
|
|
9277
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/operator-tokens.js
|
|
9277
9278
|
var require_operator_tokens = __commonJS({
|
|
9278
|
-
"node_modules/.pnpm
|
|
9279
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/operator-tokens.js"(exports2, module2) {
|
|
9279
9280
|
"use strict";
|
|
9280
9281
|
var hasOwnProperty = require_has_own_property();
|
|
9281
9282
|
var map = require_map_iterable();
|
|
@@ -9298,9 +9299,9 @@ var require_operator_tokens = __commonJS({
|
|
|
9298
9299
|
}
|
|
9299
9300
|
});
|
|
9300
9301
|
|
|
9301
|
-
// node_modules/.pnpm
|
|
9302
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/reserved-words.js
|
|
9302
9303
|
var require_reserved_words = __commonJS({
|
|
9303
|
-
"node_modules/.pnpm
|
|
9304
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/reserved-words.js"(exports2, module2) {
|
|
9304
9305
|
"use strict";
|
|
9305
9306
|
var hasOwnProperty = require_has_own_property();
|
|
9306
9307
|
var values = require_object_values();
|
|
@@ -9356,9 +9357,9 @@ var require_reverse_arguments = __commonJS({
|
|
|
9356
9357
|
}
|
|
9357
9358
|
});
|
|
9358
9359
|
|
|
9359
|
-
// node_modules/.pnpm
|
|
9360
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/filter.js
|
|
9360
9361
|
var require_filter = __commonJS({
|
|
9361
|
-
"node_modules/.pnpm
|
|
9362
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/filter.js"(exports2, module2) {
|
|
9362
9363
|
"use strict";
|
|
9363
9364
|
var filterIterator = require_filter_iterator();
|
|
9364
9365
|
var reverse = require_reverse_arguments();
|
|
@@ -9368,22 +9369,20 @@ var require_filter = __commonJS({
|
|
|
9368
9369
|
}
|
|
9369
9370
|
});
|
|
9370
9371
|
|
|
9371
|
-
// node_modules/.pnpm
|
|
9372
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/non-null.js
|
|
9372
9373
|
var require_non_null = __commonJS({
|
|
9373
|
-
"node_modules/.pnpm
|
|
9374
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/utils/non-null.js"(exports2, module2) {
|
|
9374
9375
|
"use strict";
|
|
9375
9376
|
var filter = require_filter();
|
|
9376
|
-
var nonNull = (tk) =>
|
|
9377
|
-
return tk !== null;
|
|
9378
|
-
};
|
|
9377
|
+
var nonNull = (tk) => tk !== null;
|
|
9379
9378
|
module2.exports = filter(nonNull);
|
|
9380
9379
|
filter.predicate = nonNull;
|
|
9381
9380
|
}
|
|
9382
9381
|
});
|
|
9383
9382
|
|
|
9384
|
-
// node_modules/.pnpm
|
|
9383
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/separator.js
|
|
9385
9384
|
var require_separator = __commonJS({
|
|
9386
|
-
"node_modules/.pnpm
|
|
9385
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/separator.js"(exports2, module2) {
|
|
9387
9386
|
"use strict";
|
|
9388
9387
|
var compose = require_compose_function();
|
|
9389
9388
|
var map = require_map_iterable();
|
|
@@ -9433,9 +9432,9 @@ var require_separator = __commonJS({
|
|
|
9433
9432
|
}
|
|
9434
9433
|
});
|
|
9435
9434
|
|
|
9436
|
-
// node_modules/.pnpm
|
|
9435
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/linebreak-in.js
|
|
9437
9436
|
var require_linebreak_in = __commonJS({
|
|
9438
|
-
"node_modules/.pnpm
|
|
9437
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/linebreak-in.js"(exports2, module2) {
|
|
9439
9438
|
"use strict";
|
|
9440
9439
|
var compose = require_compose_function();
|
|
9441
9440
|
var map = require_map_iterable();
|
|
@@ -9472,9 +9471,9 @@ var require_linebreak_in = __commonJS({
|
|
|
9472
9471
|
}
|
|
9473
9472
|
});
|
|
9474
9473
|
|
|
9475
|
-
// node_modules/.pnpm
|
|
9474
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/for-name-variable.js
|
|
9476
9475
|
var require_for_name_variable = __commonJS({
|
|
9477
|
-
"node_modules/.pnpm
|
|
9476
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/for-name-variable.js"(exports2, module2) {
|
|
9478
9477
|
"use strict";
|
|
9479
9478
|
var compose = require_compose_function();
|
|
9480
9479
|
var map = require_map_iterable();
|
|
@@ -9482,7 +9481,7 @@ var require_for_name_variable = __commonJS({
|
|
|
9482
9481
|
var isValidName = require_is_valid_name();
|
|
9483
9482
|
module2.exports = function forNameVariable() {
|
|
9484
9483
|
return compose(map((tk, idx, iterable) => {
|
|
9485
|
-
|
|
9484
|
+
const lastToken = iterable.behind(1) || { is: () => false };
|
|
9486
9485
|
if (lastToken.is("For") && tk.is("WORD") && isValidName(tk.value)) {
|
|
9487
9486
|
return tk.changeTokenType("NAME", tk.value);
|
|
9488
9487
|
}
|
|
@@ -9492,9 +9491,9 @@ var require_for_name_variable = __commonJS({
|
|
|
9492
9491
|
}
|
|
9493
9492
|
});
|
|
9494
9493
|
|
|
9495
|
-
// node_modules/.pnpm
|
|
9494
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/function-name.js
|
|
9496
9495
|
var require_function_name = __commonJS({
|
|
9497
|
-
"node_modules/.pnpm
|
|
9496
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/function-name.js"(exports2, module2) {
|
|
9498
9497
|
"use strict";
|
|
9499
9498
|
var compose = require_compose_function();
|
|
9500
9499
|
var map = require_map_iterable();
|
|
@@ -9510,9 +9509,9 @@ var require_function_name = __commonJS({
|
|
|
9510
9509
|
}
|
|
9511
9510
|
});
|
|
9512
9511
|
|
|
9513
|
-
// node_modules/.pnpm
|
|
9512
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/io-number.js
|
|
9514
9513
|
var require_io_number = __commonJS({
|
|
9515
|
-
"node_modules/.pnpm
|
|
9514
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/io-number.js"(exports2, module2) {
|
|
9516
9515
|
"use strict";
|
|
9517
9516
|
var compose = require_compose_function();
|
|
9518
9517
|
var map = require_map_iterable();
|
|
@@ -9520,7 +9519,7 @@ var require_io_number = __commonJS({
|
|
|
9520
9519
|
module2.exports = function ioNumber(options, mode) {
|
|
9521
9520
|
return compose(map((tk, idx, iterable) => {
|
|
9522
9521
|
const next = iterable.ahead(1);
|
|
9523
|
-
if (tk && tk.is("WORD") && tk.value
|
|
9522
|
+
if (tk && tk.is("WORD") && /^\d+$/.test(tk.value) && mode.enums.IOFileOperators.isOperator(next)) {
|
|
9524
9523
|
return tk.changeTokenType("IO_NUMBER", tk.value);
|
|
9525
9524
|
}
|
|
9526
9525
|
return tk;
|
|
@@ -9529,9 +9528,9 @@ var require_io_number = __commonJS({
|
|
|
9529
9528
|
}
|
|
9530
9529
|
});
|
|
9531
9530
|
|
|
9532
|
-
// node_modules/.pnpm
|
|
9531
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/new-line-list.js
|
|
9533
9532
|
var require_new_line_list = __commonJS({
|
|
9534
|
-
"node_modules/.pnpm
|
|
9533
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/new-line-list.js"(exports2, module2) {
|
|
9535
9534
|
"use strict";
|
|
9536
9535
|
var compose = require_compose_function();
|
|
9537
9536
|
var map = require_map_iterable();
|
|
@@ -9557,9 +9556,9 @@ var require_new_line_list = __commonJS({
|
|
|
9557
9556
|
}
|
|
9558
9557
|
});
|
|
9559
9558
|
|
|
9560
|
-
// node_modules/.pnpm
|
|
9559
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/assignment-word.js
|
|
9561
9560
|
var require_assignment_word = __commonJS({
|
|
9562
|
-
"node_modules/.pnpm
|
|
9561
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/assignment-word.js"(exports2, module2) {
|
|
9563
9562
|
"use strict";
|
|
9564
9563
|
var map = require_map_iterable();
|
|
9565
9564
|
var isValidName = require_is_valid_name();
|
|
@@ -9579,9 +9578,9 @@ var require_assignment_word = __commonJS({
|
|
|
9579
9578
|
}
|
|
9580
9579
|
});
|
|
9581
9580
|
|
|
9582
|
-
// node_modules/.pnpm
|
|
9581
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/syntaxerror-oncontinue.js
|
|
9583
9582
|
var require_syntaxerror_oncontinue = __commonJS({
|
|
9584
|
-
"node_modules/.pnpm
|
|
9583
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/syntaxerror-oncontinue.js"(exports2, module2) {
|
|
9585
9584
|
"use strict";
|
|
9586
9585
|
var map = require_map_iterable();
|
|
9587
9586
|
module2.exports = function syntaxerrorOnContinue() {
|
|
@@ -9595,9 +9594,9 @@ var require_syntaxerror_oncontinue = __commonJS({
|
|
|
9595
9594
|
}
|
|
9596
9595
|
});
|
|
9597
9596
|
|
|
9598
|
-
// node_modules/.pnpm
|
|
9597
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/index.js
|
|
9599
9598
|
var require_rules = __commonJS({
|
|
9600
|
-
"node_modules/.pnpm
|
|
9599
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/rules/index.js"(exports2) {
|
|
9601
9600
|
"use strict";
|
|
9602
9601
|
exports2.parameterExpansion = require_parameter_expansion();
|
|
9603
9602
|
exports2.commandExpansion = require_command_expansion();
|
|
@@ -9623,9 +9622,9 @@ var require_rules = __commonJS({
|
|
|
9623
9622
|
}
|
|
9624
9623
|
});
|
|
9625
9624
|
|
|
9626
|
-
// node_modules/.pnpm
|
|
9625
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/grammar.js
|
|
9627
9626
|
var require_grammar = __commonJS({
|
|
9628
|
-
"node_modules/.pnpm
|
|
9627
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/grammar.js"(exports2, module2) {
|
|
9629
9628
|
"use strict";
|
|
9630
9629
|
module2.exports = {
|
|
9631
9630
|
start: "complete_command",
|
|
@@ -10074,9 +10073,9 @@ var require_grammar = __commonJS({
|
|
|
10074
10073
|
}
|
|
10075
10074
|
});
|
|
10076
10075
|
|
|
10077
|
-
// node_modules/.pnpm
|
|
10076
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/enums/io-file-operators.js
|
|
10078
10077
|
var require_io_file_operators = __commonJS({
|
|
10079
|
-
"node_modules/.pnpm
|
|
10078
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/enums/io-file-operators.js"(exports2, module2) {
|
|
10080
10079
|
"use strict";
|
|
10081
10080
|
var ioFileOperators = module2.exports = [
|
|
10082
10081
|
"LESS",
|
|
@@ -10099,9 +10098,9 @@ var require_io_file_operators = __commonJS({
|
|
|
10099
10098
|
}
|
|
10100
10099
|
});
|
|
10101
10100
|
|
|
10102
|
-
// node_modules/.pnpm
|
|
10101
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/enums/parameter-operators.js
|
|
10103
10102
|
var require_parameter_operators = __commonJS({
|
|
10104
|
-
"node_modules/.pnpm
|
|
10103
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/enums/parameter-operators.js"(exports2, module2) {
|
|
10105
10104
|
"use strict";
|
|
10106
10105
|
var name = "[a-zA-Z_][a-zA-Z0-9_]*";
|
|
10107
10106
|
var parameterOps = {
|
|
@@ -10181,7 +10180,7 @@ var require_parameter_operators = __commonJS({
|
|
|
10181
10180
|
op: "stringLength",
|
|
10182
10181
|
parameter: (m) => m[1]
|
|
10183
10182
|
},
|
|
10184
|
-
|
|
10183
|
+
"^([1-9][0-9]*)$": {
|
|
10185
10184
|
kind: "positional",
|
|
10186
10185
|
parameter: (m) => Number(m[1])
|
|
10187
10186
|
},
|
|
@@ -10214,9 +10213,9 @@ var require_parameter_operators = __commonJS({
|
|
|
10214
10213
|
}
|
|
10215
10214
|
});
|
|
10216
10215
|
|
|
10217
|
-
// node_modules/.pnpm
|
|
10216
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/enums/reserved-words.js
|
|
10218
10217
|
var require_reserved_words2 = __commonJS({
|
|
10219
|
-
"node_modules/.pnpm
|
|
10218
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/enums/reserved-words.js"(exports2, module2) {
|
|
10220
10219
|
"use strict";
|
|
10221
10220
|
module2.exports = {
|
|
10222
10221
|
"if": "If",
|
|
@@ -10239,9 +10238,9 @@ var require_reserved_words2 = __commonJS({
|
|
|
10239
10238
|
}
|
|
10240
10239
|
});
|
|
10241
10240
|
|
|
10242
|
-
// node_modules/.pnpm
|
|
10241
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/enums/index.js
|
|
10243
10242
|
var require_enums = __commonJS({
|
|
10244
|
-
"node_modules/.pnpm
|
|
10243
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/enums/index.js"(exports2) {
|
|
10245
10244
|
"use strict";
|
|
10246
10245
|
exports2.IOFileOperators = require_io_file_operators();
|
|
10247
10246
|
exports2.operators = require_operators();
|
|
@@ -10250,9 +10249,9 @@ var require_enums = __commonJS({
|
|
|
10250
10249
|
}
|
|
10251
10250
|
});
|
|
10252
10251
|
|
|
10253
|
-
// node_modules/.pnpm
|
|
10252
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/built-grammar.js
|
|
10254
10253
|
var require_built_grammar = __commonJS({
|
|
10255
|
-
"node_modules/.pnpm
|
|
10254
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/built-grammar.js"(exports2, module2) {
|
|
10256
10255
|
"use strict";
|
|
10257
10256
|
var parser = (function() {
|
|
10258
10257
|
var o = function(k, v, o2, l) {
|
|
@@ -10483,13 +10482,9 @@ var require_built_grammar = __commonJS({
|
|
|
10483
10482
|
if (hash.recoverable) {
|
|
10484
10483
|
this.trace(str);
|
|
10485
10484
|
} else {
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
};
|
|
10490
|
-
var _parseError = _parseError2;
|
|
10491
|
-
_parseError2.prototype = Error;
|
|
10492
|
-
throw new _parseError2(str, hash);
|
|
10485
|
+
var error = new Error(str);
|
|
10486
|
+
error.hash = hash;
|
|
10487
|
+
throw error;
|
|
10493
10488
|
}
|
|
10494
10489
|
},
|
|
10495
10490
|
parse: function parse2(input) {
|
|
@@ -10658,9 +10653,9 @@ var require_built_grammar = __commonJS({
|
|
|
10658
10653
|
}
|
|
10659
10654
|
});
|
|
10660
10655
|
|
|
10661
|
-
// node_modules/.pnpm
|
|
10656
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/index.js
|
|
10662
10657
|
var require_posix = __commonJS({
|
|
10663
|
-
"node_modules/.pnpm
|
|
10658
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/posix/index.js"(exports2, module2) {
|
|
10664
10659
|
"use strict";
|
|
10665
10660
|
var astBuilder = require_ast_builder();
|
|
10666
10661
|
var tokenizer = require_tokenizer();
|
|
@@ -10702,7 +10697,7 @@ var require_posix = __commonJS({
|
|
|
10702
10697
|
let grammar = null;
|
|
10703
10698
|
try {
|
|
10704
10699
|
grammar = require_built_grammar();
|
|
10705
|
-
} catch
|
|
10700
|
+
} catch {
|
|
10706
10701
|
}
|
|
10707
10702
|
return {
|
|
10708
10703
|
enums,
|
|
@@ -10718,9 +10713,9 @@ var require_posix = __commonJS({
|
|
|
10718
10713
|
}
|
|
10719
10714
|
});
|
|
10720
10715
|
|
|
10721
|
-
// node_modules/.pnpm
|
|
10716
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/word-expansion/index.js
|
|
10722
10717
|
var require_word_expansion = __commonJS({
|
|
10723
|
-
"node_modules/.pnpm
|
|
10718
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/modes/word-expansion/index.js"(exports2, module2) {
|
|
10724
10719
|
"use strict";
|
|
10725
10720
|
var map = require_map_iterable();
|
|
10726
10721
|
var tokenOrEmpty = require_tokens().tokenOrEmpty;
|
|
@@ -10806,9 +10801,9 @@ var require_word_expansion = __commonJS({
|
|
|
10806
10801
|
}
|
|
10807
10802
|
});
|
|
10808
10803
|
|
|
10809
|
-
// node_modules/.pnpm
|
|
10804
|
+
// node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/index.js
|
|
10810
10805
|
var require_src = __commonJS({
|
|
10811
|
-
"node_modules/.pnpm
|
|
10806
|
+
"node_modules/.pnpm/@banyudu+bash-parser@0.5.2/node_modules/@banyudu/bash-parser/src/index.js"(exports2, module2) {
|
|
10812
10807
|
"use strict";
|
|
10813
10808
|
var shellLexer = require_shell_lexer();
|
|
10814
10809
|
var utils = require_utils();
|
|
@@ -10836,11 +10831,11 @@ var require_src = __commonJS({
|
|
|
10836
10831
|
parser.yy = astBuilder(options);
|
|
10837
10832
|
const ast = parser.parse(sourceCode);
|
|
10838
10833
|
return ast;
|
|
10839
|
-
} catch (
|
|
10840
|
-
if (
|
|
10841
|
-
throw
|
|
10834
|
+
} catch (error) {
|
|
10835
|
+
if (error instanceof SyntaxError) {
|
|
10836
|
+
throw error;
|
|
10842
10837
|
}
|
|
10843
|
-
throw new Error(
|
|
10838
|
+
throw new Error(error.stack || error.message);
|
|
10844
10839
|
}
|
|
10845
10840
|
};
|
|
10846
10841
|
}
|
|
@@ -18137,7 +18132,7 @@ var require_dist2 = __commonJS({
|
|
|
18137
18132
|
|
|
18138
18133
|
// src/codex-export.ts
|
|
18139
18134
|
var import_fs2 = require("fs");
|
|
18140
|
-
var
|
|
18135
|
+
var import_path4 = require("path");
|
|
18141
18136
|
|
|
18142
18137
|
// src/evaluator.ts
|
|
18143
18138
|
var import_os = require("os");
|
|
@@ -18359,7 +18354,7 @@ function parseCommand(input) {
|
|
|
18359
18354
|
for (const cmd of cmdAst.commands) {
|
|
18360
18355
|
walkNode(cmd, result);
|
|
18361
18356
|
}
|
|
18362
|
-
return { commands: result.commands, hasSubshell:
|
|
18357
|
+
return { commands: result.commands, hasSubshell: result.hasSubshell, subshellCommands: result.subshellCommands, parseError: false };
|
|
18363
18358
|
} catch {
|
|
18364
18359
|
return { commands: [], hasSubshell: true, subshellCommands: [], parseError: true };
|
|
18365
18360
|
}
|
|
@@ -18381,9 +18376,9 @@ function parseCommand(input) {
|
|
|
18381
18376
|
for (const cmd of ast.commands) {
|
|
18382
18377
|
walkNode(cmd, result);
|
|
18383
18378
|
}
|
|
18384
|
-
return { commands: result.commands, hasSubshell:
|
|
18379
|
+
return { commands: result.commands, hasSubshell: result.hasSubshell, subshellCommands: result.subshellCommands, parseError: false };
|
|
18385
18380
|
} catch {
|
|
18386
|
-
return { commands: [], hasSubshell:
|
|
18381
|
+
return { commands: [], hasSubshell: false, subshellCommands: [], parseError: true };
|
|
18387
18382
|
}
|
|
18388
18383
|
}
|
|
18389
18384
|
const fallback = regexFallbackParse(input);
|
|
@@ -18461,6 +18456,282 @@ function regexFallbackParse(input) {
|
|
|
18461
18456
|
return { command, originalCommand, args: args2, envPrefixes, raw: trimmed };
|
|
18462
18457
|
}
|
|
18463
18458
|
|
|
18459
|
+
// src/targets.ts
|
|
18460
|
+
var import_path2 = require("path");
|
|
18461
|
+
|
|
18462
|
+
// src/glob.ts
|
|
18463
|
+
function globToRegex(pattern) {
|
|
18464
|
+
let regex = "";
|
|
18465
|
+
let i = 0;
|
|
18466
|
+
while (i < pattern.length) {
|
|
18467
|
+
const ch = pattern[i];
|
|
18468
|
+
if (ch === "*") {
|
|
18469
|
+
regex += ".*";
|
|
18470
|
+
} else if (ch === "?") {
|
|
18471
|
+
regex += ".";
|
|
18472
|
+
} else if (ch === "[") {
|
|
18473
|
+
i++;
|
|
18474
|
+
if (i < pattern.length && pattern[i] === "!") {
|
|
18475
|
+
regex += "[^";
|
|
18476
|
+
i++;
|
|
18477
|
+
} else {
|
|
18478
|
+
regex += "[";
|
|
18479
|
+
}
|
|
18480
|
+
while (i < pattern.length && pattern[i] !== "]") {
|
|
18481
|
+
regex += pattern[i];
|
|
18482
|
+
i++;
|
|
18483
|
+
}
|
|
18484
|
+
if (i < pattern.length) regex += "]";
|
|
18485
|
+
} else if (ch === "{") {
|
|
18486
|
+
const end = pattern.indexOf("}", i);
|
|
18487
|
+
if (end !== -1) {
|
|
18488
|
+
const alternatives = pattern.slice(i + 1, end).split(",").map((s) => s.replace(/[.+^$|\\()]/g, "\\$&"));
|
|
18489
|
+
regex += `(${alternatives.join("|")})`;
|
|
18490
|
+
i = end;
|
|
18491
|
+
} else {
|
|
18492
|
+
regex += "\\{";
|
|
18493
|
+
}
|
|
18494
|
+
} else if (".+^$|\\()".includes(ch)) {
|
|
18495
|
+
regex += "\\" + ch;
|
|
18496
|
+
} else {
|
|
18497
|
+
regex += ch;
|
|
18498
|
+
}
|
|
18499
|
+
i++;
|
|
18500
|
+
}
|
|
18501
|
+
return new RegExp(`^${regex}$`);
|
|
18502
|
+
}
|
|
18503
|
+
|
|
18504
|
+
// src/targets.ts
|
|
18505
|
+
var PATH_COMMANDS = /* @__PURE__ */ new Set([
|
|
18506
|
+
"rm",
|
|
18507
|
+
"chmod",
|
|
18508
|
+
"chown",
|
|
18509
|
+
"cp",
|
|
18510
|
+
"mv",
|
|
18511
|
+
"tee",
|
|
18512
|
+
"mkdir",
|
|
18513
|
+
"rmdir",
|
|
18514
|
+
"touch",
|
|
18515
|
+
"ln"
|
|
18516
|
+
]);
|
|
18517
|
+
function evaluatePathTarget(cmd, cwd, targets) {
|
|
18518
|
+
if (targets.length === 0) return null;
|
|
18519
|
+
const positionalArgs = cmd.args.filter((a) => !a.startsWith("-"));
|
|
18520
|
+
if (positionalArgs.length === 0) return null;
|
|
18521
|
+
let bestMatch = null;
|
|
18522
|
+
for (const target of targets) {
|
|
18523
|
+
if (target.allowAll) {
|
|
18524
|
+
} else {
|
|
18525
|
+
if (target.commands && target.commands.length > 0 && !target.commands.includes(cmd.command)) {
|
|
18526
|
+
continue;
|
|
18527
|
+
}
|
|
18528
|
+
if (!target.commands && !PATH_COMMANDS.has(cmd.command)) {
|
|
18529
|
+
continue;
|
|
18530
|
+
}
|
|
18531
|
+
}
|
|
18532
|
+
const targetPath = (0, import_path2.normalize)(target.path.replace(/\{\{cwd\}\}/g, cwd));
|
|
18533
|
+
const recursive = target.recursive !== false;
|
|
18534
|
+
for (const arg of positionalArgs) {
|
|
18535
|
+
const resolvedArg = (0, import_path2.normalize)((0, import_path2.resolve)(cwd, arg));
|
|
18536
|
+
const matches = recursive ? resolvedArg === targetPath || resolvedArg.startsWith(targetPath + "/") : resolvedArg === targetPath;
|
|
18537
|
+
if (matches) {
|
|
18538
|
+
const decision = target.allowAll ? "allow" : target.decision;
|
|
18539
|
+
const detail = {
|
|
18540
|
+
command: cmd.command,
|
|
18541
|
+
args: cmd.args,
|
|
18542
|
+
decision,
|
|
18543
|
+
reason: target.reason || `Path "${resolvedArg}" matches trusted path "${target.path}" (${decision})`,
|
|
18544
|
+
matchedRule: "trustedPaths"
|
|
18545
|
+
};
|
|
18546
|
+
if (decision === "deny") return detail;
|
|
18547
|
+
if (!bestMatch || bestMatch.decision !== "deny") {
|
|
18548
|
+
bestMatch = detail;
|
|
18549
|
+
}
|
|
18550
|
+
}
|
|
18551
|
+
}
|
|
18552
|
+
}
|
|
18553
|
+
return bestMatch;
|
|
18554
|
+
}
|
|
18555
|
+
var DB_HOST_FLAGS = {
|
|
18556
|
+
psql: ["-h", "--host"],
|
|
18557
|
+
mysql: ["-h", "--host"],
|
|
18558
|
+
mariadb: ["-h", "--host"],
|
|
18559
|
+
"redis-cli": ["-h"],
|
|
18560
|
+
mongosh: ["--host"]
|
|
18561
|
+
};
|
|
18562
|
+
var DB_DATABASE_FLAGS = {
|
|
18563
|
+
psql: ["-d", "--dbname"],
|
|
18564
|
+
mysql: ["-D", "--database"],
|
|
18565
|
+
mariadb: ["-D", "--database"]
|
|
18566
|
+
};
|
|
18567
|
+
var DB_PORT_FLAGS = {
|
|
18568
|
+
psql: ["-p", "--port"],
|
|
18569
|
+
mysql: ["-P", "--port"],
|
|
18570
|
+
mariadb: ["-P", "--port"],
|
|
18571
|
+
"redis-cli": ["-p"],
|
|
18572
|
+
mongosh: ["--port"]
|
|
18573
|
+
};
|
|
18574
|
+
function extractFlagValue(args2, flags) {
|
|
18575
|
+
for (let i = 0; i < args2.length; i++) {
|
|
18576
|
+
const arg = args2[i];
|
|
18577
|
+
for (const f of flags) {
|
|
18578
|
+
if (arg.startsWith(f + "=")) {
|
|
18579
|
+
return arg.slice(f.length + 1);
|
|
18580
|
+
}
|
|
18581
|
+
}
|
|
18582
|
+
if (flags.includes(arg) && i + 1 < args2.length) {
|
|
18583
|
+
return args2[i + 1];
|
|
18584
|
+
}
|
|
18585
|
+
}
|
|
18586
|
+
return void 0;
|
|
18587
|
+
}
|
|
18588
|
+
function parseDBConnection(cmd) {
|
|
18589
|
+
const command = cmd.command;
|
|
18590
|
+
const info = {};
|
|
18591
|
+
for (const arg of cmd.args) {
|
|
18592
|
+
if (arg.startsWith("postgresql://") || arg.startsWith("postgres://")) {
|
|
18593
|
+
try {
|
|
18594
|
+
const url = new URL(arg);
|
|
18595
|
+
info.host = url.hostname;
|
|
18596
|
+
if (url.port) info.port = parseInt(url.port, 10);
|
|
18597
|
+
if (url.pathname.length > 1) info.database = url.pathname.slice(1);
|
|
18598
|
+
return info;
|
|
18599
|
+
} catch {
|
|
18600
|
+
}
|
|
18601
|
+
}
|
|
18602
|
+
if (arg.startsWith("mongodb://") || arg.startsWith("mongodb+srv://")) {
|
|
18603
|
+
try {
|
|
18604
|
+
const url = new URL(arg);
|
|
18605
|
+
info.host = url.hostname;
|
|
18606
|
+
if (url.port) info.port = parseInt(url.port, 10);
|
|
18607
|
+
if (url.pathname.length > 1) info.database = url.pathname.slice(1);
|
|
18608
|
+
return info;
|
|
18609
|
+
} catch {
|
|
18610
|
+
}
|
|
18611
|
+
}
|
|
18612
|
+
}
|
|
18613
|
+
const hostFlags = DB_HOST_FLAGS[command];
|
|
18614
|
+
if (hostFlags) {
|
|
18615
|
+
const h = extractFlagValue(cmd.args, hostFlags);
|
|
18616
|
+
if (h) info.host = h;
|
|
18617
|
+
}
|
|
18618
|
+
const dbFlags = DB_DATABASE_FLAGS[command];
|
|
18619
|
+
if (dbFlags) {
|
|
18620
|
+
const d = extractFlagValue(cmd.args, dbFlags);
|
|
18621
|
+
if (d) info.database = d;
|
|
18622
|
+
}
|
|
18623
|
+
const portFlags = DB_PORT_FLAGS[command];
|
|
18624
|
+
if (portFlags) {
|
|
18625
|
+
const p = extractFlagValue(cmd.args, portFlags);
|
|
18626
|
+
if (p) info.port = parseInt(p, 10);
|
|
18627
|
+
}
|
|
18628
|
+
return info;
|
|
18629
|
+
}
|
|
18630
|
+
var DB_COMMANDS = new Set(Object.keys(DB_HOST_FLAGS));
|
|
18631
|
+
function evaluateDatabaseTarget(cmd, targets) {
|
|
18632
|
+
if (targets.length === 0) return null;
|
|
18633
|
+
const hasAllowAll = targets.some((t) => t.allowAll);
|
|
18634
|
+
if (!hasAllowAll && !DB_COMMANDS.has(cmd.command)) return null;
|
|
18635
|
+
const applicableTargets = targets.filter((t) => t.allowAll || DB_COMMANDS.has(cmd.command));
|
|
18636
|
+
if (applicableTargets.length === 0) return null;
|
|
18637
|
+
const conn = parseDBConnection(cmd);
|
|
18638
|
+
if (!conn.host) return null;
|
|
18639
|
+
let bestMatch = null;
|
|
18640
|
+
for (const target of applicableTargets) {
|
|
18641
|
+
if (!target.allowAll && target.commands && target.commands.length > 0 && !target.commands.includes(cmd.command)) {
|
|
18642
|
+
continue;
|
|
18643
|
+
}
|
|
18644
|
+
const hostMatch = globToRegex(target.host).test(conn.host);
|
|
18645
|
+
if (!hostMatch) continue;
|
|
18646
|
+
if (target.port !== void 0 && conn.port !== void 0 && target.port !== conn.port) {
|
|
18647
|
+
continue;
|
|
18648
|
+
}
|
|
18649
|
+
if (target.database) {
|
|
18650
|
+
if (!conn.database || !globToRegex(target.database).test(conn.database)) continue;
|
|
18651
|
+
}
|
|
18652
|
+
const decision = target.allowAll ? "allow" : target.decision;
|
|
18653
|
+
const detail = {
|
|
18654
|
+
command: cmd.command,
|
|
18655
|
+
args: cmd.args,
|
|
18656
|
+
decision,
|
|
18657
|
+
reason: target.reason || `Database "${conn.host}${conn.database ? "/" + conn.database : ""}" matches trusted database (${decision})`,
|
|
18658
|
+
matchedRule: "trustedDatabases"
|
|
18659
|
+
};
|
|
18660
|
+
if (decision === "deny") return detail;
|
|
18661
|
+
if (!bestMatch) bestMatch = detail;
|
|
18662
|
+
}
|
|
18663
|
+
return bestMatch;
|
|
18664
|
+
}
|
|
18665
|
+
var ENDPOINT_COMMANDS = /* @__PURE__ */ new Set(["curl", "wget", "http", "httpie"]);
|
|
18666
|
+
function extractURLs(cmd) {
|
|
18667
|
+
const urls = [];
|
|
18668
|
+
const args2 = cmd.args;
|
|
18669
|
+
for (let i = 0; i < args2.length; i++) {
|
|
18670
|
+
const arg = args2[i];
|
|
18671
|
+
if (arg === "--url" && i + 1 < args2.length) {
|
|
18672
|
+
urls.push(args2[i + 1]);
|
|
18673
|
+
i++;
|
|
18674
|
+
continue;
|
|
18675
|
+
}
|
|
18676
|
+
if (arg.startsWith("http://") || arg.startsWith("https://")) {
|
|
18677
|
+
urls.push(arg);
|
|
18678
|
+
}
|
|
18679
|
+
}
|
|
18680
|
+
return urls;
|
|
18681
|
+
}
|
|
18682
|
+
function evaluateEndpointTarget(cmd, targets) {
|
|
18683
|
+
if (targets.length === 0) return null;
|
|
18684
|
+
const hasAllowAll = targets.some((t) => t.allowAll);
|
|
18685
|
+
if (!hasAllowAll && !ENDPOINT_COMMANDS.has(cmd.command)) return null;
|
|
18686
|
+
const urls = extractURLs(cmd);
|
|
18687
|
+
if (urls.length === 0) return null;
|
|
18688
|
+
let bestMatch = null;
|
|
18689
|
+
for (const target of targets) {
|
|
18690
|
+
if (!target.allowAll && target.commands && target.commands.length > 0 && !target.commands.includes(cmd.command)) {
|
|
18691
|
+
continue;
|
|
18692
|
+
}
|
|
18693
|
+
for (const url of urls) {
|
|
18694
|
+
if (globToRegex(target.pattern).test(url)) {
|
|
18695
|
+
const decision = target.allowAll ? "allow" : target.decision;
|
|
18696
|
+
const detail = {
|
|
18697
|
+
command: cmd.command,
|
|
18698
|
+
args: cmd.args,
|
|
18699
|
+
decision,
|
|
18700
|
+
reason: target.reason || `URL "${url}" matches trusted endpoint "${target.pattern}" (${decision})`,
|
|
18701
|
+
matchedRule: "trustedEndpoints"
|
|
18702
|
+
};
|
|
18703
|
+
if (decision === "deny") return detail;
|
|
18704
|
+
if (!bestMatch) bestMatch = detail;
|
|
18705
|
+
}
|
|
18706
|
+
}
|
|
18707
|
+
}
|
|
18708
|
+
return bestMatch;
|
|
18709
|
+
}
|
|
18710
|
+
function evaluateTargetPolicies(cmd, cwd, config) {
|
|
18711
|
+
const policies = config.targetPolicies;
|
|
18712
|
+
if (!policies?.length) return null;
|
|
18713
|
+
const results = [];
|
|
18714
|
+
const pathPolicies = policies.filter((p) => p.type === "path");
|
|
18715
|
+
if (pathPolicies.length) {
|
|
18716
|
+
const r = evaluatePathTarget(cmd, cwd, pathPolicies);
|
|
18717
|
+
if (r) results.push(r);
|
|
18718
|
+
}
|
|
18719
|
+
const dbPolicies = policies.filter((p) => p.type === "database");
|
|
18720
|
+
if (dbPolicies.length) {
|
|
18721
|
+
const r = evaluateDatabaseTarget(cmd, dbPolicies);
|
|
18722
|
+
if (r) results.push(r);
|
|
18723
|
+
}
|
|
18724
|
+
const endpointPolicies = policies.filter((p) => p.type === "endpoint");
|
|
18725
|
+
if (endpointPolicies.length) {
|
|
18726
|
+
const r = evaluateEndpointTarget(cmd, endpointPolicies);
|
|
18727
|
+
if (r) results.push(r);
|
|
18728
|
+
}
|
|
18729
|
+
if (results.length === 0) return null;
|
|
18730
|
+
const deny = results.find((r) => r.decision === "deny");
|
|
18731
|
+
if (deny) return deny;
|
|
18732
|
+
return results[0];
|
|
18733
|
+
}
|
|
18734
|
+
|
|
18464
18735
|
// src/evaluator.ts
|
|
18465
18736
|
function safeRegexTest(pattern, input) {
|
|
18466
18737
|
try {
|
|
@@ -18481,7 +18752,9 @@ function commandMatchesName(cmd, name) {
|
|
|
18481
18752
|
return cmd.command === name;
|
|
18482
18753
|
}
|
|
18483
18754
|
var MAX_RECURSION_DEPTH = 10;
|
|
18484
|
-
function evaluate(parsed, config,
|
|
18755
|
+
function evaluate(parsed, config, cwdOrDepth, maybeDepth) {
|
|
18756
|
+
const cwd = typeof cwdOrDepth === "string" ? cwdOrDepth : void 0;
|
|
18757
|
+
const depth = typeof cwdOrDepth === "number" ? cwdOrDepth : maybeDepth ?? 0;
|
|
18485
18758
|
if (depth > MAX_RECURSION_DEPTH) {
|
|
18486
18759
|
return { decision: "ask", reason: "Maximum recursion depth exceeded", details: [] };
|
|
18487
18760
|
}
|
|
@@ -18494,7 +18767,7 @@ function evaluate(parsed, config, depth = 0) {
|
|
|
18494
18767
|
if (parsed.hasSubshell && parsed.subshellCommands.length > 0) {
|
|
18495
18768
|
for (const subCmd of parsed.subshellCommands) {
|
|
18496
18769
|
const subParsed = parseCommand(subCmd);
|
|
18497
|
-
const subResult = evaluate(subParsed, config, depth + 1);
|
|
18770
|
+
const subResult = evaluate(subParsed, config, cwd, depth + 1);
|
|
18498
18771
|
if (subResult.decision === "deny") {
|
|
18499
18772
|
return { decision: "deny", reason: `Subshell command: ${subResult.reason}`, details: subResult.details };
|
|
18500
18773
|
}
|
|
@@ -18507,7 +18780,7 @@ function evaluate(parsed, config, depth = 0) {
|
|
|
18507
18780
|
}
|
|
18508
18781
|
const details = [];
|
|
18509
18782
|
for (const cmd of parsed.commands) {
|
|
18510
|
-
details.push(evaluateCommand(cmd, config, depth));
|
|
18783
|
+
details.push(evaluateCommand(cmd, config, cwd, depth));
|
|
18511
18784
|
}
|
|
18512
18785
|
const decisions = details.map((d) => d.decision);
|
|
18513
18786
|
if (decisions.includes("deny")) {
|
|
@@ -18528,7 +18801,7 @@ function evaluate(parsed, config, depth = 0) {
|
|
|
18528
18801
|
}
|
|
18529
18802
|
return { decision: "allow", reason: "All commands are safe", details };
|
|
18530
18803
|
}
|
|
18531
|
-
function evaluateCommand(cmd, config, depth = 0) {
|
|
18804
|
+
function evaluateCommand(cmd, config, cwd, depth = 0) {
|
|
18532
18805
|
const { command, args: args2 } = cmd;
|
|
18533
18806
|
for (const layer of config.layers) {
|
|
18534
18807
|
if (layer.alwaysDeny.some((name) => commandMatchesName(cmd, name))) {
|
|
@@ -18538,27 +18811,51 @@ function evaluateCommand(cmd, config, depth = 0) {
|
|
|
18538
18811
|
return { command, args: args2, decision: "allow", reason: `"${command}" is safe`, matchedRule: "alwaysAllow" };
|
|
18539
18812
|
}
|
|
18540
18813
|
}
|
|
18541
|
-
if (
|
|
18542
|
-
const
|
|
18543
|
-
if (
|
|
18814
|
+
if (cwd) {
|
|
18815
|
+
const targetResult = evaluateTargetPolicies(cmd, cwd, config);
|
|
18816
|
+
if (targetResult) return targetResult;
|
|
18544
18817
|
}
|
|
18545
|
-
|
|
18546
|
-
|
|
18547
|
-
|
|
18818
|
+
const remotes = config.trustedRemotes || [];
|
|
18819
|
+
if (command === "ssh" || command === "scp" || command === "rsync") {
|
|
18820
|
+
const sshTargets = remotes.filter((r) => r.context === "ssh");
|
|
18821
|
+
if (sshTargets.length) {
|
|
18822
|
+
const sshResult = evaluateSSHCommand(cmd, config, sshTargets, depth);
|
|
18823
|
+
if (sshResult) return sshResult;
|
|
18824
|
+
}
|
|
18548
18825
|
}
|
|
18549
|
-
if (command === "
|
|
18550
|
-
const
|
|
18551
|
-
if (
|
|
18826
|
+
if (command === "docker") {
|
|
18827
|
+
const dockerTargets = remotes.filter((r) => r.context === "docker");
|
|
18828
|
+
if (dockerTargets.length) {
|
|
18829
|
+
const dockerResult = evaluateDockerExec(cmd, config, dockerTargets, depth);
|
|
18830
|
+
if (dockerResult) return dockerResult;
|
|
18831
|
+
}
|
|
18552
18832
|
}
|
|
18553
|
-
if (command === "
|
|
18554
|
-
const
|
|
18555
|
-
if (
|
|
18833
|
+
if (command === "kubectl") {
|
|
18834
|
+
const kubectlTargets = remotes.filter((r) => r.context === "kubectl");
|
|
18835
|
+
if (kubectlTargets.length) {
|
|
18836
|
+
const kubectlResult = evaluateKubectlExec(cmd, config, kubectlTargets, depth);
|
|
18837
|
+
if (kubectlResult) return kubectlResult;
|
|
18838
|
+
}
|
|
18839
|
+
}
|
|
18840
|
+
if (command === "sprite") {
|
|
18841
|
+
const spriteTargets = remotes.filter((r) => r.context === "sprite");
|
|
18842
|
+
if (spriteTargets.length) {
|
|
18843
|
+
const spriteResult = evaluateSpriteExec(cmd, config, spriteTargets, depth);
|
|
18844
|
+
if (spriteResult) return spriteResult;
|
|
18845
|
+
}
|
|
18846
|
+
}
|
|
18847
|
+
if (command === "fly" || command === "flyctl") {
|
|
18848
|
+
const flyTargets = remotes.filter((r) => r.context === "fly");
|
|
18849
|
+
if (flyTargets.length) {
|
|
18850
|
+
const flyResult = evaluateFlyCommand(cmd, config, flyTargets, depth);
|
|
18851
|
+
if (flyResult) return flyResult;
|
|
18852
|
+
}
|
|
18556
18853
|
}
|
|
18557
18854
|
if (command === "xargs") {
|
|
18558
|
-
return evaluateXargsCommand(cmd, config, depth);
|
|
18855
|
+
return evaluateXargsCommand(cmd, config, cwd, depth);
|
|
18559
18856
|
}
|
|
18560
18857
|
if (command === "find") {
|
|
18561
|
-
return evaluateFindCommand(cmd, config, depth);
|
|
18858
|
+
return evaluateFindCommand(cmd, config, cwd, depth);
|
|
18562
18859
|
}
|
|
18563
18860
|
const mergedRule = collectMergedRule(cmd, config);
|
|
18564
18861
|
if (mergedRule) {
|
|
@@ -18720,7 +19017,7 @@ function parseXargsSubcommand(args2) {
|
|
|
18720
19017
|
}
|
|
18721
19018
|
};
|
|
18722
19019
|
}
|
|
18723
|
-
function evaluateXargsCommand(cmd, config, depth = 0) {
|
|
19020
|
+
function evaluateXargsCommand(cmd, config, cwd, depth = 0) {
|
|
18724
19021
|
const { command, args: args2 } = cmd;
|
|
18725
19022
|
const { subcommand, unresolved } = parseXargsSubcommand(args2);
|
|
18726
19023
|
if (unresolved || !subcommand) {
|
|
@@ -18744,7 +19041,7 @@ function evaluateXargsCommand(cmd, config, depth = 0) {
|
|
|
18744
19041
|
} else {
|
|
18745
19042
|
parsed = { commands: [subcommand], hasSubshell: false, subshellCommands: [], parseError: false };
|
|
18746
19043
|
}
|
|
18747
|
-
const result = evaluate(parsed, config, depth + 1);
|
|
19044
|
+
const result = evaluate(parsed, config, cwd, depth + 1);
|
|
18748
19045
|
return {
|
|
18749
19046
|
command,
|
|
18750
19047
|
args: args2,
|
|
@@ -18782,7 +19079,7 @@ function parseFindExecCommands(args2) {
|
|
|
18782
19079
|
}
|
|
18783
19080
|
return commands;
|
|
18784
19081
|
}
|
|
18785
|
-
function evaluateFindCommand(cmd, config, depth = 0) {
|
|
19082
|
+
function evaluateFindCommand(cmd, config, cwd, depth = 0) {
|
|
18786
19083
|
const { command, args: args2 } = cmd;
|
|
18787
19084
|
if (args2.some((a) => a === "-delete")) {
|
|
18788
19085
|
return { command, args: args2, decision: "ask", reason: "find -delete can remove files", matchedRule: "find:delete" };
|
|
@@ -18801,7 +19098,7 @@ function evaluateFindCommand(cmd, config, depth = 0) {
|
|
|
18801
19098
|
subshellCommands: [],
|
|
18802
19099
|
parseError: false
|
|
18803
19100
|
};
|
|
18804
|
-
const result = evaluate(parsed, config, depth + 1);
|
|
19101
|
+
const result = evaluate(parsed, config, cwd, depth + 1);
|
|
18805
19102
|
if (result.decision === "deny") {
|
|
18806
19103
|
return { command, args: args2, decision: "deny", reason: `find -exec: ${result.reason}`, matchedRule: "find:exec" };
|
|
18807
19104
|
}
|
|
@@ -18833,48 +19130,6 @@ var SSH_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set([
|
|
|
18833
19130
|
"-W",
|
|
18834
19131
|
"-w"
|
|
18835
19132
|
]);
|
|
18836
|
-
function globToRegex(pattern) {
|
|
18837
|
-
let regex = "";
|
|
18838
|
-
let i = 0;
|
|
18839
|
-
while (i < pattern.length) {
|
|
18840
|
-
const ch = pattern[i];
|
|
18841
|
-
if (ch === "*") {
|
|
18842
|
-
regex += ".*";
|
|
18843
|
-
} else if (ch === "?") {
|
|
18844
|
-
regex += ".";
|
|
18845
|
-
} else if (ch === "[") {
|
|
18846
|
-
i++;
|
|
18847
|
-
if (i < pattern.length && pattern[i] === "!") {
|
|
18848
|
-
regex += "[^";
|
|
18849
|
-
i++;
|
|
18850
|
-
} else {
|
|
18851
|
-
regex += "[";
|
|
18852
|
-
}
|
|
18853
|
-
while (i < pattern.length && pattern[i] !== "]") {
|
|
18854
|
-
regex += pattern[i];
|
|
18855
|
-
i++;
|
|
18856
|
-
}
|
|
18857
|
-
if (i < pattern.length) {
|
|
18858
|
-
regex += "]";
|
|
18859
|
-
}
|
|
18860
|
-
} else if (ch === "{") {
|
|
18861
|
-
const end = pattern.indexOf("}", i);
|
|
18862
|
-
if (end !== -1) {
|
|
18863
|
-
const alternatives = pattern.slice(i + 1, end).split(",").map((s) => s.replace(/[.+^$|\\()]/g, "\\$&"));
|
|
18864
|
-
regex += `(${alternatives.join("|")})`;
|
|
18865
|
-
i = end;
|
|
18866
|
-
} else {
|
|
18867
|
-
regex += "\\{";
|
|
18868
|
-
}
|
|
18869
|
-
} else if (".+^$|\\()".includes(ch)) {
|
|
18870
|
-
regex += "\\" + ch;
|
|
18871
|
-
} else {
|
|
18872
|
-
regex += ch;
|
|
18873
|
-
}
|
|
18874
|
-
i++;
|
|
18875
|
-
}
|
|
18876
|
-
return new RegExp(`^${regex}$`);
|
|
18877
|
-
}
|
|
18878
19133
|
function findMatchingTarget(value, targets) {
|
|
18879
19134
|
return targets.find((t) => globToRegex(t.name).test(value)) || null;
|
|
18880
19135
|
}
|
|
@@ -18915,13 +19170,12 @@ function extractHostFromRemotePath(args2) {
|
|
|
18915
19170
|
}
|
|
18916
19171
|
return null;
|
|
18917
19172
|
}
|
|
18918
|
-
function evaluateSSHCommand(cmd, config, depth = 0) {
|
|
19173
|
+
function evaluateSSHCommand(cmd, config, targets, depth = 0) {
|
|
18919
19174
|
const { command, args: args2 } = cmd;
|
|
18920
|
-
const trustedHosts = config.trustedSSHHosts || [];
|
|
18921
19175
|
if (command === "scp" || command === "rsync") {
|
|
18922
19176
|
const host2 = extractHostFromRemotePath(args2);
|
|
18923
19177
|
if (!host2) return null;
|
|
18924
|
-
const target2 = findMatchingTarget(host2,
|
|
19178
|
+
const target2 = findMatchingTarget(host2, targets);
|
|
18925
19179
|
if (!target2) return null;
|
|
18926
19180
|
if (target2.allowAll || !target2.overrides) {
|
|
18927
19181
|
return {
|
|
@@ -18951,7 +19205,7 @@ function evaluateSSHCommand(cmd, config, depth = 0) {
|
|
|
18951
19205
|
}
|
|
18952
19206
|
const { host, remoteCommand } = parseSSHArgs(args2);
|
|
18953
19207
|
if (!host) return null;
|
|
18954
|
-
const target = findMatchingTarget(host,
|
|
19208
|
+
const target = findMatchingTarget(host, targets);
|
|
18955
19209
|
if (!target) return null;
|
|
18956
19210
|
if (!remoteCommand) {
|
|
18957
19211
|
return {
|
|
@@ -19060,12 +19314,12 @@ function parseDockerExecArgs(args2) {
|
|
|
19060
19314
|
}
|
|
19061
19315
|
return { target, remoteArgs };
|
|
19062
19316
|
}
|
|
19063
|
-
function evaluateDockerExec(cmd, config, depth = 0) {
|
|
19317
|
+
function evaluateDockerExec(cmd, config, targets, depth = 0) {
|
|
19064
19318
|
const { command, args: args2 } = cmd;
|
|
19065
19319
|
if (args2[0] !== "exec") return null;
|
|
19066
19320
|
const { target: containerName, remoteArgs } = parseDockerExecArgs(args2.slice(1));
|
|
19067
19321
|
if (!containerName) return null;
|
|
19068
|
-
const matched = findMatchingTarget(containerName,
|
|
19322
|
+
const matched = findMatchingTarget(containerName, targets);
|
|
19069
19323
|
if (!matched) return null;
|
|
19070
19324
|
const result = evaluateRemoteCommand(remoteArgs, config, matched, depth);
|
|
19071
19325
|
return {
|
|
@@ -19140,12 +19394,12 @@ function parseKubectlExecArgs(args2) {
|
|
|
19140
19394
|
}
|
|
19141
19395
|
return { context, pod, remoteArgs };
|
|
19142
19396
|
}
|
|
19143
|
-
function evaluateKubectlExec(cmd, config, depth = 0) {
|
|
19397
|
+
function evaluateKubectlExec(cmd, config, targets, depth = 0) {
|
|
19144
19398
|
const { command, args: args2 } = cmd;
|
|
19145
19399
|
if (args2[0] !== "exec") return null;
|
|
19146
19400
|
const { context, pod, remoteArgs } = parseKubectlExecArgs(args2.slice(1));
|
|
19147
19401
|
if (!context) return null;
|
|
19148
|
-
const matched = findMatchingTarget(context,
|
|
19402
|
+
const matched = findMatchingTarget(context, targets);
|
|
19149
19403
|
if (!matched) return null;
|
|
19150
19404
|
const result = evaluateRemoteCommand(remoteArgs, config, matched, depth);
|
|
19151
19405
|
return {
|
|
@@ -19207,11 +19461,11 @@ function parseSpriteExecArgs(args2) {
|
|
|
19207
19461
|
}
|
|
19208
19462
|
return { spriteName, remoteArgs };
|
|
19209
19463
|
}
|
|
19210
|
-
function evaluateSpriteExec(cmd, config, depth = 0) {
|
|
19464
|
+
function evaluateSpriteExec(cmd, config, targets, depth = 0) {
|
|
19211
19465
|
const { command, args: args2 } = cmd;
|
|
19212
19466
|
const { spriteName, remoteArgs } = parseSpriteExecArgs(args2);
|
|
19213
19467
|
if (!spriteName) return null;
|
|
19214
|
-
const matched = findMatchingTarget(spriteName,
|
|
19468
|
+
const matched = findMatchingTarget(spriteName, targets);
|
|
19215
19469
|
if (!matched) return null;
|
|
19216
19470
|
const result = evaluateRemoteCommand(remoteArgs, config, matched, depth);
|
|
19217
19471
|
return {
|
|
@@ -19222,6 +19476,93 @@ function evaluateSpriteExec(cmd, config, depth = 0) {
|
|
|
19222
19476
|
matchedRule: "trustedSprites"
|
|
19223
19477
|
};
|
|
19224
19478
|
}
|
|
19479
|
+
var FLY_SSH_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set([
|
|
19480
|
+
"-a",
|
|
19481
|
+
"--app",
|
|
19482
|
+
"-C",
|
|
19483
|
+
"--command",
|
|
19484
|
+
"-o",
|
|
19485
|
+
"--org",
|
|
19486
|
+
"-r",
|
|
19487
|
+
"--region",
|
|
19488
|
+
"-u",
|
|
19489
|
+
"--user",
|
|
19490
|
+
"--address"
|
|
19491
|
+
]);
|
|
19492
|
+
function parseFlySSHArgs(args2) {
|
|
19493
|
+
let app = null;
|
|
19494
|
+
const remoteArgs = [];
|
|
19495
|
+
let isSSH = false;
|
|
19496
|
+
let foundConsole = false;
|
|
19497
|
+
let i = 0;
|
|
19498
|
+
while (i < args2.length) {
|
|
19499
|
+
const arg = args2[i];
|
|
19500
|
+
if (arg.startsWith("--app=")) {
|
|
19501
|
+
app = arg.slice(6);
|
|
19502
|
+
i++;
|
|
19503
|
+
continue;
|
|
19504
|
+
}
|
|
19505
|
+
if (FLY_SSH_FLAGS_WITH_VALUE.has(arg)) {
|
|
19506
|
+
if (arg === "-a" || arg === "--app") {
|
|
19507
|
+
app = args2[i + 1] || null;
|
|
19508
|
+
}
|
|
19509
|
+
if ((arg === "-C" || arg === "--command") && foundConsole) {
|
|
19510
|
+
const cmdValue = args2[i + 1];
|
|
19511
|
+
if (cmdValue) {
|
|
19512
|
+
const parsed = parseCommand(cmdValue);
|
|
19513
|
+
if (!parsed.parseError && parsed.commands.length > 0) {
|
|
19514
|
+
const cmd = parsed.commands[0];
|
|
19515
|
+
remoteArgs.push(cmd.command, ...cmd.args);
|
|
19516
|
+
}
|
|
19517
|
+
}
|
|
19518
|
+
i += 2;
|
|
19519
|
+
continue;
|
|
19520
|
+
}
|
|
19521
|
+
i += 2;
|
|
19522
|
+
continue;
|
|
19523
|
+
}
|
|
19524
|
+
if (arg === "--") {
|
|
19525
|
+
i++;
|
|
19526
|
+
while (i < args2.length) {
|
|
19527
|
+
remoteArgs.push(args2[i]);
|
|
19528
|
+
i++;
|
|
19529
|
+
}
|
|
19530
|
+
break;
|
|
19531
|
+
}
|
|
19532
|
+
if (arg.startsWith("-")) {
|
|
19533
|
+
i++;
|
|
19534
|
+
continue;
|
|
19535
|
+
}
|
|
19536
|
+
if (!isSSH && arg === "ssh") {
|
|
19537
|
+
isSSH = true;
|
|
19538
|
+
i++;
|
|
19539
|
+
continue;
|
|
19540
|
+
}
|
|
19541
|
+
if (isSSH && !foundConsole && (arg === "console" || arg === "sftp")) {
|
|
19542
|
+
foundConsole = true;
|
|
19543
|
+
i++;
|
|
19544
|
+
continue;
|
|
19545
|
+
}
|
|
19546
|
+
i++;
|
|
19547
|
+
}
|
|
19548
|
+
return { app, remoteArgs, isSSH: isSSH && foundConsole };
|
|
19549
|
+
}
|
|
19550
|
+
function evaluateFlyCommand(cmd, config, targets, depth = 0) {
|
|
19551
|
+
const { command, args: args2 } = cmd;
|
|
19552
|
+
const { app, remoteArgs, isSSH } = parseFlySSHArgs(args2);
|
|
19553
|
+
if (!isSSH) return null;
|
|
19554
|
+
if (!app) return null;
|
|
19555
|
+
const matched = findMatchingTarget(app, targets);
|
|
19556
|
+
if (!matched) return null;
|
|
19557
|
+
const result = evaluateRemoteCommand(remoteArgs, config, matched, depth);
|
|
19558
|
+
return {
|
|
19559
|
+
command,
|
|
19560
|
+
args: args2,
|
|
19561
|
+
decision: result.decision,
|
|
19562
|
+
reason: `Trusted Fly app "${app}" (${result.reason})`,
|
|
19563
|
+
matchedRule: "trustedFlyApps"
|
|
19564
|
+
};
|
|
19565
|
+
}
|
|
19225
19566
|
|
|
19226
19567
|
// src/codex.ts
|
|
19227
19568
|
function toCodexDecision(decision) {
|
|
@@ -19272,7 +19613,7 @@ function generateCodexRules(config) {
|
|
|
19272
19613
|
var import_fs = require("fs");
|
|
19273
19614
|
var import_yaml = __toESM(require_dist2(), 1);
|
|
19274
19615
|
var import_os2 = require("os");
|
|
19275
|
-
var
|
|
19616
|
+
var import_path3 = require("path");
|
|
19276
19617
|
|
|
19277
19618
|
// src/defaults.ts
|
|
19278
19619
|
var SAFE_DEV_TOOLS = [
|
|
@@ -19420,10 +19761,8 @@ var DEFAULT_CONFIG = {
|
|
|
19420
19761
|
askOnSubshell: true,
|
|
19421
19762
|
notifyOnAsk: true,
|
|
19422
19763
|
notifyOnDeny: true,
|
|
19423
|
-
|
|
19424
|
-
|
|
19425
|
-
trustedKubectlContexts: [],
|
|
19426
|
-
trustedSprites: [],
|
|
19764
|
+
trustedRemotes: [],
|
|
19765
|
+
targetPolicies: [],
|
|
19427
19766
|
layers: [{
|
|
19428
19767
|
alwaysAllow: [
|
|
19429
19768
|
// Read-only file operations
|
|
@@ -19593,6 +19932,16 @@ var DEFAULT_CONFIG = {
|
|
|
19593
19932
|
"ldd",
|
|
19594
19933
|
"otool",
|
|
19595
19934
|
"size",
|
|
19935
|
+
// ImageMagick
|
|
19936
|
+
"magick",
|
|
19937
|
+
"convert",
|
|
19938
|
+
"identify",
|
|
19939
|
+
"mogrify",
|
|
19940
|
+
"composite",
|
|
19941
|
+
"montage",
|
|
19942
|
+
"compare",
|
|
19943
|
+
"conjure",
|
|
19944
|
+
"stream",
|
|
19596
19945
|
// macOS utilities (read-only)
|
|
19597
19946
|
"mdfind",
|
|
19598
19947
|
"mdls",
|
|
@@ -19665,7 +20014,8 @@ var DEFAULT_CONFIG = {
|
|
|
19665
20014
|
command: "claude",
|
|
19666
20015
|
default: "ask",
|
|
19667
20016
|
argPatterns: [
|
|
19668
|
-
{ match: { anyArgMatches: ["^--(version|help)$", "^-[vh]$"] }, decision: "allow", description: "Version/help flags" }
|
|
20017
|
+
{ match: { anyArgMatches: ["^--(version|help)$", "^-[vh]$"] }, decision: "allow", description: "Version/help flags" },
|
|
20018
|
+
{ match: { argsMatch: ["^plugin(s)?\\s+(list|help|validate|marketplace\\s+(list|help))\\b"] }, decision: "allow", description: "Read-only plugin commands" }
|
|
19669
20019
|
]
|
|
19670
20020
|
},
|
|
19671
20021
|
// --- Shell sourcing ---
|
|
@@ -19846,8 +20196,8 @@ var DEFAULT_CONFIG = {
|
|
|
19846
20196
|
command: "rm",
|
|
19847
20197
|
default: "ask",
|
|
19848
20198
|
argPatterns: [
|
|
19849
|
-
{ match: {
|
|
19850
|
-
{ match: {
|
|
20199
|
+
{ match: { anyArgMatches: ["^-[^\\s]*r[^\\s]*f$|^-[^\\s]*f[^\\s]*r$"] }, decision: "ask", reason: "Recursive force delete (rm -rf)" },
|
|
20200
|
+
{ match: { anyArgMatches: ["^-[^\\s]*r"] }, decision: "ask", reason: "Recursive delete" },
|
|
19851
20201
|
{ match: { argCount: { max: 3 }, not: false }, decision: "allow", description: "Deleting a small number of non-recursive files" }
|
|
19852
20202
|
]
|
|
19853
20203
|
},
|
|
@@ -19935,6 +20285,17 @@ var DEFAULT_CONFIG = {
|
|
|
19935
20285
|
{ match: { anyArgMatches: ["^(list|search|show|status|get|template|version|env|history)$"] }, decision: "allow", description: "Read-only helm commands" },
|
|
19936
20286
|
VERSION_HELP_FLAGS
|
|
19937
20287
|
] },
|
|
20288
|
+
// --- Fly.io ---
|
|
20289
|
+
...["fly", "flyctl"].map((cmd) => ({
|
|
20290
|
+
command: cmd,
|
|
20291
|
+
default: "ask",
|
|
20292
|
+
argPatterns: [
|
|
20293
|
+
{ match: { anyArgMatches: ["^(status|logs|info|version|platform|doctor|dig)$"] }, decision: "allow", description: "Read-only fly commands" },
|
|
20294
|
+
{ match: { argsMatch: ["^apps\\s+list"] }, decision: "allow", description: "List fly apps" },
|
|
20295
|
+
{ match: { anyArgMatches: ["^(deploy|destroy|scale|secrets)$"] }, decision: "ask", reason: "Destructive fly operation" },
|
|
20296
|
+
VERSION_HELP_FLAGS
|
|
20297
|
+
]
|
|
20298
|
+
})),
|
|
19938
20299
|
// --- Screen/tmux ---
|
|
19939
20300
|
...["screen", "tmux"].map((cmd) => ({
|
|
19940
20301
|
command: cmd,
|
|
@@ -19982,8 +20343,8 @@ function isValidDecision(value) {
|
|
|
19982
20343
|
return VALID_DECISIONS.has(value);
|
|
19983
20344
|
}
|
|
19984
20345
|
var USER_CONFIG_PATHS = [
|
|
19985
|
-
(0,
|
|
19986
|
-
(0,
|
|
20346
|
+
(0, import_path3.join)((0, import_os2.homedir)(), ".claude", "warden.yaml"),
|
|
20347
|
+
(0, import_path3.join)((0, import_os2.homedir)(), ".claude", "warden.json")
|
|
19987
20348
|
];
|
|
19988
20349
|
var PROJECT_CONFIG_NAMES = [
|
|
19989
20350
|
".claude/warden.yaml",
|
|
@@ -20006,7 +20367,7 @@ function loadConfig(cwd) {
|
|
|
20006
20367
|
let workspaceRaw = null;
|
|
20007
20368
|
if (cwd) {
|
|
20008
20369
|
for (const name of PROJECT_CONFIG_NAMES) {
|
|
20009
|
-
const result = tryLoadFile((0,
|
|
20370
|
+
const result = tryLoadFile((0, import_path3.join)(cwd, name));
|
|
20010
20371
|
if (result) {
|
|
20011
20372
|
workspaceLayer = extractLayer(result);
|
|
20012
20373
|
workspaceRaw = result;
|
|
@@ -20108,18 +20469,153 @@ function parseTrustedList(raw) {
|
|
|
20108
20469
|
return null;
|
|
20109
20470
|
}).filter((t) => t !== null);
|
|
20110
20471
|
}
|
|
20472
|
+
var VALID_REMOTE_CONTEXTS = /* @__PURE__ */ new Set(["ssh", "docker", "kubectl", "sprite", "fly"]);
|
|
20473
|
+
function parseTrustedRemotes(raw) {
|
|
20474
|
+
const results = [];
|
|
20475
|
+
for (const entry of raw) {
|
|
20476
|
+
if (!entry || typeof entry !== "object") continue;
|
|
20477
|
+
const obj = entry;
|
|
20478
|
+
const context = String(obj.context || "");
|
|
20479
|
+
if (!VALID_REMOTE_CONTEXTS.has(context)) {
|
|
20480
|
+
process.stderr.write(`[warden] Warning: unknown remote context "${context}", skipping
|
|
20481
|
+
`);
|
|
20482
|
+
continue;
|
|
20483
|
+
}
|
|
20484
|
+
const name = String(obj.name || "");
|
|
20485
|
+
if (!name) continue;
|
|
20486
|
+
const remote = { name, context };
|
|
20487
|
+
if (obj.allowAll === true) remote.allowAll = true;
|
|
20488
|
+
if (obj.overrides && typeof obj.overrides === "object") {
|
|
20489
|
+
remote.overrides = extractLayer(obj.overrides);
|
|
20490
|
+
}
|
|
20491
|
+
results.push(remote);
|
|
20492
|
+
}
|
|
20493
|
+
return results;
|
|
20494
|
+
}
|
|
20495
|
+
function parseTargetPolicies(raw) {
|
|
20496
|
+
const results = [];
|
|
20497
|
+
for (const entry of raw) {
|
|
20498
|
+
if (!entry || typeof entry !== "object") continue;
|
|
20499
|
+
const obj = entry;
|
|
20500
|
+
const type = String(obj.type || "");
|
|
20501
|
+
const rawDecision = String(obj.decision || "allow");
|
|
20502
|
+
const decision = isValidDecision(rawDecision) ? rawDecision : "allow";
|
|
20503
|
+
const base = {
|
|
20504
|
+
commands: Array.isArray(obj.commands) ? obj.commands.map(String) : void 0,
|
|
20505
|
+
decision,
|
|
20506
|
+
reason: obj.reason ? String(obj.reason) : void 0,
|
|
20507
|
+
allowAll: obj.allowAll === true ? true : void 0
|
|
20508
|
+
};
|
|
20509
|
+
switch (type) {
|
|
20510
|
+
case "path": {
|
|
20511
|
+
const path = String(obj.path || "");
|
|
20512
|
+
if (!path) continue;
|
|
20513
|
+
const policy = { ...base, type: "path", path };
|
|
20514
|
+
if (obj.recursive === false) policy.recursive = false;
|
|
20515
|
+
results.push(policy);
|
|
20516
|
+
break;
|
|
20517
|
+
}
|
|
20518
|
+
case "database": {
|
|
20519
|
+
const host = String(obj.host || "");
|
|
20520
|
+
if (!host) continue;
|
|
20521
|
+
const policy = { ...base, type: "database", host };
|
|
20522
|
+
if (typeof obj.port === "number") policy.port = obj.port;
|
|
20523
|
+
if (obj.database) policy.database = String(obj.database);
|
|
20524
|
+
results.push(policy);
|
|
20525
|
+
break;
|
|
20526
|
+
}
|
|
20527
|
+
case "endpoint": {
|
|
20528
|
+
const pattern = String(obj.pattern || "");
|
|
20529
|
+
if (!pattern) continue;
|
|
20530
|
+
results.push({ ...base, type: "endpoint", pattern });
|
|
20531
|
+
break;
|
|
20532
|
+
}
|
|
20533
|
+
default:
|
|
20534
|
+
process.stderr.write(`[warden] Warning: unknown target policy type "${type}", skipping
|
|
20535
|
+
`);
|
|
20536
|
+
}
|
|
20537
|
+
}
|
|
20538
|
+
return results;
|
|
20539
|
+
}
|
|
20540
|
+
function parseLegacyPaths(raw) {
|
|
20541
|
+
const results = [];
|
|
20542
|
+
for (const e of raw) {
|
|
20543
|
+
if (!e || typeof e !== "object") continue;
|
|
20544
|
+
const obj = e;
|
|
20545
|
+
const decision = String(obj.decision || "allow");
|
|
20546
|
+
if (!isValidDecision(decision)) continue;
|
|
20547
|
+
const path = String(obj.path || "");
|
|
20548
|
+
if (!path) continue;
|
|
20549
|
+
const tp = { type: "path", path, decision };
|
|
20550
|
+
if (obj.recursive === false) tp.recursive = false;
|
|
20551
|
+
if (Array.isArray(obj.commands)) tp.commands = obj.commands.map(String);
|
|
20552
|
+
if (obj.reason) tp.reason = String(obj.reason);
|
|
20553
|
+
results.push(tp);
|
|
20554
|
+
}
|
|
20555
|
+
return results;
|
|
20556
|
+
}
|
|
20557
|
+
function parseLegacyDatabases(raw) {
|
|
20558
|
+
const results = [];
|
|
20559
|
+
for (const e of raw) {
|
|
20560
|
+
if (!e || typeof e !== "object") continue;
|
|
20561
|
+
const obj = e;
|
|
20562
|
+
const decision = String(obj.decision || "allow");
|
|
20563
|
+
if (!isValidDecision(decision)) continue;
|
|
20564
|
+
const host = String(obj.host || "");
|
|
20565
|
+
if (!host) continue;
|
|
20566
|
+
const td = { type: "database", host, decision };
|
|
20567
|
+
if (typeof obj.port === "number") td.port = obj.port;
|
|
20568
|
+
if (obj.database) td.database = String(obj.database);
|
|
20569
|
+
if (Array.isArray(obj.commands)) td.commands = obj.commands.map(String);
|
|
20570
|
+
if (obj.reason) td.reason = String(obj.reason);
|
|
20571
|
+
results.push(td);
|
|
20572
|
+
}
|
|
20573
|
+
return results;
|
|
20574
|
+
}
|
|
20575
|
+
function parseLegacyEndpoints(raw) {
|
|
20576
|
+
const results = [];
|
|
20577
|
+
for (const e of raw) {
|
|
20578
|
+
if (!e || typeof e !== "object") continue;
|
|
20579
|
+
const obj = e;
|
|
20580
|
+
const decision = String(obj.decision || "allow");
|
|
20581
|
+
if (!isValidDecision(decision)) continue;
|
|
20582
|
+
const pattern = String(obj.pattern || "");
|
|
20583
|
+
if (!pattern) continue;
|
|
20584
|
+
const te = { type: "endpoint", pattern, decision };
|
|
20585
|
+
if (Array.isArray(obj.commands)) te.commands = obj.commands.map(String);
|
|
20586
|
+
if (obj.reason) te.reason = String(obj.reason);
|
|
20587
|
+
results.push(te);
|
|
20588
|
+
}
|
|
20589
|
+
return results;
|
|
20590
|
+
}
|
|
20591
|
+
var LEGACY_REMOTE_MAP = {
|
|
20592
|
+
trustedSSHHosts: "ssh",
|
|
20593
|
+
trustedDockerContainers: "docker",
|
|
20594
|
+
trustedKubectlContexts: "kubectl",
|
|
20595
|
+
trustedSprites: "sprite",
|
|
20596
|
+
trustedFlyApps: "fly"
|
|
20597
|
+
};
|
|
20111
20598
|
function mergeNonLayerFields(config, raw) {
|
|
20112
|
-
if (Array.isArray(raw.
|
|
20113
|
-
config.
|
|
20599
|
+
if (Array.isArray(raw.trustedRemotes)) {
|
|
20600
|
+
config.trustedRemotes = [...config.trustedRemotes || [], ...parseTrustedRemotes(raw.trustedRemotes)];
|
|
20601
|
+
}
|
|
20602
|
+
if (Array.isArray(raw.targetPolicies)) {
|
|
20603
|
+
config.targetPolicies = [...config.targetPolicies || [], ...parseTargetPolicies(raw.targetPolicies)];
|
|
20604
|
+
}
|
|
20605
|
+
for (const [key, context] of Object.entries(LEGACY_REMOTE_MAP)) {
|
|
20606
|
+
if (Array.isArray(raw[key])) {
|
|
20607
|
+
const remotes = parseTrustedList(raw[key]).map((t) => ({ ...t, context }));
|
|
20608
|
+
config.trustedRemotes = [...config.trustedRemotes || [], ...remotes];
|
|
20609
|
+
}
|
|
20114
20610
|
}
|
|
20115
|
-
if (Array.isArray(raw.
|
|
20116
|
-
config.
|
|
20611
|
+
if (Array.isArray(raw.trustedPaths)) {
|
|
20612
|
+
config.targetPolicies = [...config.targetPolicies || [], ...parseLegacyPaths(raw.trustedPaths)];
|
|
20117
20613
|
}
|
|
20118
|
-
if (Array.isArray(raw.
|
|
20119
|
-
config.
|
|
20614
|
+
if (Array.isArray(raw.trustedDatabases)) {
|
|
20615
|
+
config.targetPolicies = [...config.targetPolicies || [], ...parseLegacyDatabases(raw.trustedDatabases)];
|
|
20120
20616
|
}
|
|
20121
|
-
if (Array.isArray(raw.
|
|
20122
|
-
config.
|
|
20617
|
+
if (Array.isArray(raw.trustedEndpoints)) {
|
|
20618
|
+
config.targetPolicies = [...config.targetPolicies || [], ...parseLegacyEndpoints(raw.trustedEndpoints)];
|
|
20123
20619
|
}
|
|
20124
20620
|
if (typeof raw.defaultDecision === "string") {
|
|
20125
20621
|
if (isValidDecision(raw.defaultDecision)) {
|
|
@@ -20160,7 +20656,7 @@ function parseArgs(argv) {
|
|
|
20160
20656
|
for (let i = 0; i < argv.length; i += 1) {
|
|
20161
20657
|
const arg = argv[i];
|
|
20162
20658
|
if (arg === "--cwd" && argv[i + 1]) {
|
|
20163
|
-
cwd = (0,
|
|
20659
|
+
cwd = (0, import_path4.resolve)(argv[i + 1]);
|
|
20164
20660
|
i += 1;
|
|
20165
20661
|
continue;
|
|
20166
20662
|
}
|
|
@@ -20196,13 +20692,13 @@ function main() {
|
|
|
20196
20692
|
const options = parseArgs(process.argv.slice(2));
|
|
20197
20693
|
const config = loadConfig(options.cwd);
|
|
20198
20694
|
const rules = generateCodexRules(config);
|
|
20199
|
-
const target = options.outPath ?? (0,
|
|
20695
|
+
const target = options.outPath ?? (0, import_path4.join)(options.cwd, ".codex", "rules", "warden.rules");
|
|
20200
20696
|
if (target === "-") {
|
|
20201
20697
|
process.stdout.write(rules);
|
|
20202
20698
|
return;
|
|
20203
20699
|
}
|
|
20204
|
-
const resolvedTarget = (0,
|
|
20205
|
-
(0, import_fs2.mkdirSync)((0,
|
|
20700
|
+
const resolvedTarget = (0, import_path4.isAbsolute)(target) ? target : (0, import_path4.resolve)(options.cwd, target);
|
|
20701
|
+
(0, import_fs2.mkdirSync)((0, import_path4.dirname)(resolvedTarget), { recursive: true });
|
|
20206
20702
|
(0, import_fs2.writeFileSync)(resolvedTarget, rules, "utf-8");
|
|
20207
20703
|
process.stderr.write(`[warden] Wrote Codex rules to ${resolvedTarget}
|
|
20208
20704
|
`);
|