pair-mode 0.3.0 → 0.4.0
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/.codex-plugin/plugin.json +2 -8
- package/README.md +71 -12
- package/assets/duck-appalled-banner-sprite.png +0 -0
- package/assets/duck-appalled-banner-v2-sprite.png +0 -0
- package/assets/duck-appalled-banner-v2.gif +0 -0
- package/assets/duck-appalled-sprite.png +0 -0
- package/assets/duck-appalled.gif +0 -0
- package/assets/duck-before-main.png +0 -0
- package/assets/duck.png +0 -0
- package/assets/favicon.png +0 -0
- package/assets/syntax/clojure.yaml +36 -0
- package/assets/syntax/cmake.yaml +41 -0
- package/assets/syntax/crystal.yaml +71 -0
- package/assets/syntax/csharp.yaml +51 -0
- package/assets/syntax/dart.yaml +45 -0
- package/assets/syntax/elm.yaml +38 -0
- package/assets/syntax/erb.yaml +42 -0
- package/assets/syntax/erlang.yaml +45 -0
- package/assets/syntax/fsharp.yaml +48 -0
- package/assets/syntax/graphql.yaml +47 -0
- package/assets/syntax/groovy.yaml +111 -0
- package/assets/syntax/haml.yaml +16 -0
- package/assets/syntax/haskell.yaml +52 -0
- package/assets/syntax/ini.yaml +23 -0
- package/assets/syntax/java.yaml +36 -0
- package/assets/syntax/julia.yaml +56 -0
- package/assets/syntax/kotlin.yaml +65 -0
- package/assets/syntax/makefile.yaml +37 -0
- package/assets/syntax/nginx.yaml +22 -0
- package/assets/syntax/nim.yaml +27 -0
- package/assets/syntax/nix.yaml +32 -0
- package/assets/syntax/objc.yaml +60 -0
- package/assets/syntax/ocaml.yaml +43 -0
- package/assets/syntax/perl.yaml +58 -0
- package/assets/syntax/php.yaml +60 -0
- package/assets/syntax/r.yaml +30 -0
- package/assets/syntax/scala.yaml +32 -0
- package/assets/syntax/svelte.yaml +27 -0
- package/assets/syntax/swift.yaml +102 -0
- package/assets/syntax/vue.yaml +63 -0
- package/assets/syntax/xml.yaml +37 -0
- package/assets/syntax/zig.yaml +52 -0
- package/dist/claude-code.js +463 -150
- package/dist/cli.js +1534 -459
- package/dist/codex.js +811 -394
- package/dist/opencode.js +455 -143
- package/dist/pair-tui.js +177 -27
- package/dist/pi.js +510 -156
- package/package.json +16 -17
- package/skills/toggle/SKILL.md +24 -0
- package/commands/pair.md +0 -18
- package/skills/pair/SKILL.md +0 -20
package/dist/codex.js
CHANGED
|
@@ -94,13 +94,13 @@ var require_identity = __commonJS({
|
|
|
94
94
|
var require_visit = __commonJS({
|
|
95
95
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/visit.js"(exports) {
|
|
96
96
|
"use strict";
|
|
97
|
-
var
|
|
97
|
+
var identity2 = require_identity();
|
|
98
98
|
var BREAK = Symbol("break visit");
|
|
99
99
|
var SKIP = Symbol("skip children");
|
|
100
100
|
var REMOVE = Symbol("remove node");
|
|
101
101
|
function visit(node, visitor) {
|
|
102
102
|
const visitor_ = initVisitor(visitor);
|
|
103
|
-
if (
|
|
103
|
+
if (identity2.isDocument(node)) {
|
|
104
104
|
const cd = visit_(null, node.contents, visitor_, Object.freeze([node]));
|
|
105
105
|
if (cd === REMOVE)
|
|
106
106
|
node.contents = null;
|
|
@@ -112,12 +112,12 @@ var require_visit = __commonJS({
|
|
|
112
112
|
visit.REMOVE = REMOVE;
|
|
113
113
|
function visit_(key, node, visitor, path) {
|
|
114
114
|
const ctrl = callVisitor(key, node, visitor, path);
|
|
115
|
-
if (
|
|
115
|
+
if (identity2.isNode(ctrl) || identity2.isPair(ctrl)) {
|
|
116
116
|
replaceNode(key, path, ctrl);
|
|
117
117
|
return visit_(key, ctrl, visitor, path);
|
|
118
118
|
}
|
|
119
119
|
if (typeof ctrl !== "symbol") {
|
|
120
|
-
if (
|
|
120
|
+
if (identity2.isCollection(node)) {
|
|
121
121
|
path = Object.freeze(path.concat(node));
|
|
122
122
|
for (let i = 0; i < node.items.length; ++i) {
|
|
123
123
|
const ci = visit_(i, node.items[i], visitor, path);
|
|
@@ -130,7 +130,7 @@ var require_visit = __commonJS({
|
|
|
130
130
|
i -= 1;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
} else if (
|
|
133
|
+
} else if (identity2.isPair(node)) {
|
|
134
134
|
path = Object.freeze(path.concat(node));
|
|
135
135
|
const ck = visit_("key", node.key, visitor, path);
|
|
136
136
|
if (ck === BREAK)
|
|
@@ -148,7 +148,7 @@ var require_visit = __commonJS({
|
|
|
148
148
|
}
|
|
149
149
|
async function visitAsync(node, visitor) {
|
|
150
150
|
const visitor_ = initVisitor(visitor);
|
|
151
|
-
if (
|
|
151
|
+
if (identity2.isDocument(node)) {
|
|
152
152
|
const cd = await visitAsync_(null, node.contents, visitor_, Object.freeze([node]));
|
|
153
153
|
if (cd === REMOVE)
|
|
154
154
|
node.contents = null;
|
|
@@ -160,12 +160,12 @@ var require_visit = __commonJS({
|
|
|
160
160
|
visitAsync.REMOVE = REMOVE;
|
|
161
161
|
async function visitAsync_(key, node, visitor, path) {
|
|
162
162
|
const ctrl = await callVisitor(key, node, visitor, path);
|
|
163
|
-
if (
|
|
163
|
+
if (identity2.isNode(ctrl) || identity2.isPair(ctrl)) {
|
|
164
164
|
replaceNode(key, path, ctrl);
|
|
165
165
|
return visitAsync_(key, ctrl, visitor, path);
|
|
166
166
|
}
|
|
167
167
|
if (typeof ctrl !== "symbol") {
|
|
168
|
-
if (
|
|
168
|
+
if (identity2.isCollection(node)) {
|
|
169
169
|
path = Object.freeze(path.concat(node));
|
|
170
170
|
for (let i = 0; i < node.items.length; ++i) {
|
|
171
171
|
const ci = await visitAsync_(i, node.items[i], visitor, path);
|
|
@@ -178,7 +178,7 @@ var require_visit = __commonJS({
|
|
|
178
178
|
i -= 1;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
} else if (
|
|
181
|
+
} else if (identity2.isPair(node)) {
|
|
182
182
|
path = Object.freeze(path.concat(node));
|
|
183
183
|
const ck = await visitAsync_("key", node.key, visitor, path);
|
|
184
184
|
if (ck === BREAK)
|
|
@@ -215,31 +215,31 @@ var require_visit = __commonJS({
|
|
|
215
215
|
function callVisitor(key, node, visitor, path) {
|
|
216
216
|
if (typeof visitor === "function")
|
|
217
217
|
return visitor(key, node, path);
|
|
218
|
-
if (
|
|
218
|
+
if (identity2.isMap(node))
|
|
219
219
|
return visitor.Map?.(key, node, path);
|
|
220
|
-
if (
|
|
220
|
+
if (identity2.isSeq(node))
|
|
221
221
|
return visitor.Seq?.(key, node, path);
|
|
222
|
-
if (
|
|
222
|
+
if (identity2.isPair(node))
|
|
223
223
|
return visitor.Pair?.(key, node, path);
|
|
224
|
-
if (
|
|
224
|
+
if (identity2.isScalar(node))
|
|
225
225
|
return visitor.Scalar?.(key, node, path);
|
|
226
|
-
if (
|
|
226
|
+
if (identity2.isAlias(node))
|
|
227
227
|
return visitor.Alias?.(key, node, path);
|
|
228
228
|
return void 0;
|
|
229
229
|
}
|
|
230
230
|
function replaceNode(key, path, node) {
|
|
231
231
|
const parent = path[path.length - 1];
|
|
232
|
-
if (
|
|
232
|
+
if (identity2.isCollection(parent)) {
|
|
233
233
|
parent.items[key] = node;
|
|
234
|
-
} else if (
|
|
234
|
+
} else if (identity2.isPair(parent)) {
|
|
235
235
|
if (key === "key")
|
|
236
236
|
parent.key = node;
|
|
237
237
|
else
|
|
238
238
|
parent.value = node;
|
|
239
|
-
} else if (
|
|
239
|
+
} else if (identity2.isDocument(parent)) {
|
|
240
240
|
parent.contents = node;
|
|
241
241
|
} else {
|
|
242
|
-
const pt =
|
|
242
|
+
const pt = identity2.isAlias(parent) ? "alias" : "scalar";
|
|
243
243
|
throw new Error(`Cannot replace node with ${pt} parent`);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
@@ -252,7 +252,7 @@ var require_visit = __commonJS({
|
|
|
252
252
|
var require_directives = __commonJS({
|
|
253
253
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/doc/directives.js"(exports) {
|
|
254
254
|
"use strict";
|
|
255
|
-
var
|
|
255
|
+
var identity2 = require_identity();
|
|
256
256
|
var visit = require_visit();
|
|
257
257
|
var escapeChars = {
|
|
258
258
|
"!": "%21",
|
|
@@ -395,10 +395,10 @@ var require_directives = __commonJS({
|
|
|
395
395
|
const lines = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : [];
|
|
396
396
|
const tagEntries = Object.entries(this.tags);
|
|
397
397
|
let tagNames;
|
|
398
|
-
if (doc && tagEntries.length > 0 &&
|
|
398
|
+
if (doc && tagEntries.length > 0 && identity2.isNode(doc.contents)) {
|
|
399
399
|
const tags = {};
|
|
400
400
|
visit.visit(doc.contents, (_key, node) => {
|
|
401
|
-
if (
|
|
401
|
+
if (identity2.isNode(node) && node.tag)
|
|
402
402
|
tags[node.tag] = true;
|
|
403
403
|
});
|
|
404
404
|
tagNames = Object.keys(tags);
|
|
@@ -423,7 +423,7 @@ var require_directives = __commonJS({
|
|
|
423
423
|
var require_anchors = __commonJS({
|
|
424
424
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/doc/anchors.js"(exports) {
|
|
425
425
|
"use strict";
|
|
426
|
-
var
|
|
426
|
+
var identity2 = require_identity();
|
|
427
427
|
var visit = require_visit();
|
|
428
428
|
function anchorIsValid(anchor2) {
|
|
429
429
|
if (/[\x00-\x19\s,[\]{}]/.test(anchor2)) {
|
|
@@ -470,7 +470,7 @@ var require_anchors = __commonJS({
|
|
|
470
470
|
setAnchors: () => {
|
|
471
471
|
for (const source of aliasObjects) {
|
|
472
472
|
const ref = sourceObjects.get(source);
|
|
473
|
-
if (typeof ref === "object" && ref.anchor && (
|
|
473
|
+
if (typeof ref === "object" && ref.anchor && (identity2.isScalar(ref.node) || identity2.isCollection(ref.node))) {
|
|
474
474
|
ref.node.anchor = ref.anchor;
|
|
475
475
|
} else {
|
|
476
476
|
const error = new Error("Failed to resolve repeated object (this should not happen)");
|
|
@@ -543,12 +543,12 @@ var require_applyReviver = __commonJS({
|
|
|
543
543
|
var require_toJS = __commonJS({
|
|
544
544
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/toJS.js"(exports) {
|
|
545
545
|
"use strict";
|
|
546
|
-
var
|
|
546
|
+
var identity2 = require_identity();
|
|
547
547
|
function toJS(value, arg, ctx) {
|
|
548
548
|
if (Array.isArray(value))
|
|
549
549
|
return value.map((v, i) => toJS(v, String(i), ctx));
|
|
550
550
|
if (value && typeof value.toJSON === "function") {
|
|
551
|
-
if (!ctx || !
|
|
551
|
+
if (!ctx || !identity2.hasAnchor(value))
|
|
552
552
|
return value.toJSON(arg, ctx);
|
|
553
553
|
const data = { aliasCount: 0, count: 1, res: void 0 };
|
|
554
554
|
ctx.anchors.set(value, data);
|
|
@@ -574,11 +574,11 @@ var require_Node = __commonJS({
|
|
|
574
574
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/Node.js"(exports) {
|
|
575
575
|
"use strict";
|
|
576
576
|
var applyReviver = require_applyReviver();
|
|
577
|
-
var
|
|
577
|
+
var identity2 = require_identity();
|
|
578
578
|
var toJS = require_toJS();
|
|
579
579
|
var NodeBase = class {
|
|
580
580
|
constructor(type) {
|
|
581
|
-
Object.defineProperty(this,
|
|
581
|
+
Object.defineProperty(this, identity2.NODE_TYPE, { value: type });
|
|
582
582
|
}
|
|
583
583
|
/** Create a copy of this node. */
|
|
584
584
|
clone() {
|
|
@@ -589,7 +589,7 @@ var require_Node = __commonJS({
|
|
|
589
589
|
}
|
|
590
590
|
/** A plain JavaScript representation of this node. */
|
|
591
591
|
toJS(doc, { mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
|
|
592
|
-
if (!
|
|
592
|
+
if (!identity2.isDocument(doc))
|
|
593
593
|
throw new TypeError("A document argument is required");
|
|
594
594
|
const ctx = {
|
|
595
595
|
anchors: /* @__PURE__ */ new Map(),
|
|
@@ -616,12 +616,12 @@ var require_Alias = __commonJS({
|
|
|
616
616
|
"use strict";
|
|
617
617
|
var anchors = require_anchors();
|
|
618
618
|
var visit = require_visit();
|
|
619
|
-
var
|
|
619
|
+
var identity2 = require_identity();
|
|
620
620
|
var Node = require_Node();
|
|
621
621
|
var toJS = require_toJS();
|
|
622
622
|
var Alias = class extends Node.NodeBase {
|
|
623
623
|
constructor(source) {
|
|
624
|
-
super(
|
|
624
|
+
super(identity2.ALIAS);
|
|
625
625
|
this.source = source;
|
|
626
626
|
Object.defineProperty(this, "tag", {
|
|
627
627
|
set() {
|
|
@@ -643,7 +643,7 @@ var require_Alias = __commonJS({
|
|
|
643
643
|
nodes = [];
|
|
644
644
|
visit.visit(doc, {
|
|
645
645
|
Node: (_key, node) => {
|
|
646
|
-
if (
|
|
646
|
+
if (identity2.isAlias(node) || identity2.hasAnchor(node))
|
|
647
647
|
nodes.push(node);
|
|
648
648
|
}
|
|
649
649
|
});
|
|
@@ -703,11 +703,11 @@ var require_Alias = __commonJS({
|
|
|
703
703
|
}
|
|
704
704
|
};
|
|
705
705
|
function getAliasCount(doc, node, anchors2) {
|
|
706
|
-
if (
|
|
706
|
+
if (identity2.isAlias(node)) {
|
|
707
707
|
const source = node.resolve(doc);
|
|
708
708
|
const anchor2 = anchors2 && source && anchors2.get(source);
|
|
709
709
|
return anchor2 ? anchor2.count * anchor2.aliasCount : 0;
|
|
710
|
-
} else if (
|
|
710
|
+
} else if (identity2.isCollection(node)) {
|
|
711
711
|
let count = 0;
|
|
712
712
|
for (const item of node.items) {
|
|
713
713
|
const c = getAliasCount(doc, item, anchors2);
|
|
@@ -715,7 +715,7 @@ var require_Alias = __commonJS({
|
|
|
715
715
|
count = c;
|
|
716
716
|
}
|
|
717
717
|
return count;
|
|
718
|
-
} else if (
|
|
718
|
+
} else if (identity2.isPair(node)) {
|
|
719
719
|
const kc = getAliasCount(doc, node.key, anchors2);
|
|
720
720
|
const vc = getAliasCount(doc, node.value, anchors2);
|
|
721
721
|
return Math.max(kc, vc);
|
|
@@ -730,13 +730,13 @@ var require_Alias = __commonJS({
|
|
|
730
730
|
var require_Scalar = __commonJS({
|
|
731
731
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/Scalar.js"(exports) {
|
|
732
732
|
"use strict";
|
|
733
|
-
var
|
|
733
|
+
var identity2 = require_identity();
|
|
734
734
|
var Node = require_Node();
|
|
735
735
|
var toJS = require_toJS();
|
|
736
736
|
var isScalarValue = (value) => !value || typeof value !== "function" && typeof value !== "object";
|
|
737
737
|
var Scalar = class extends Node.NodeBase {
|
|
738
738
|
constructor(value) {
|
|
739
|
-
super(
|
|
739
|
+
super(identity2.SCALAR);
|
|
740
740
|
this.value = value;
|
|
741
741
|
}
|
|
742
742
|
toJSON(arg, ctx) {
|
|
@@ -761,7 +761,7 @@ var require_createNode = __commonJS({
|
|
|
761
761
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/doc/createNode.js"(exports) {
|
|
762
762
|
"use strict";
|
|
763
763
|
var Alias = require_Alias();
|
|
764
|
-
var
|
|
764
|
+
var identity2 = require_identity();
|
|
765
765
|
var Scalar = require_Scalar();
|
|
766
766
|
var defaultTagPrefix = "tag:yaml.org,2002:";
|
|
767
767
|
function findTagObject(value, tagName, tags) {
|
|
@@ -775,12 +775,12 @@ var require_createNode = __commonJS({
|
|
|
775
775
|
return tags.find((t) => t.identify?.(value) && !t.format);
|
|
776
776
|
}
|
|
777
777
|
function createNode(value, tagName, ctx) {
|
|
778
|
-
if (
|
|
778
|
+
if (identity2.isDocument(value))
|
|
779
779
|
value = value.contents;
|
|
780
|
-
if (
|
|
780
|
+
if (identity2.isNode(value))
|
|
781
781
|
return value;
|
|
782
|
-
if (
|
|
783
|
-
const map = ctx.schema[
|
|
782
|
+
if (identity2.isPair(value)) {
|
|
783
|
+
const map = ctx.schema[identity2.MAP].createNode?.(ctx.schema, null, ctx);
|
|
784
784
|
map.items.push(value);
|
|
785
785
|
return map;
|
|
786
786
|
}
|
|
@@ -812,7 +812,7 @@ var require_createNode = __commonJS({
|
|
|
812
812
|
ref.node = node2;
|
|
813
813
|
return node2;
|
|
814
814
|
}
|
|
815
|
-
tagObj = value instanceof Map ? schema[
|
|
815
|
+
tagObj = value instanceof Map ? schema[identity2.MAP] : Symbol.iterator in Object(value) ? schema[identity2.SEQ] : schema[identity2.MAP];
|
|
816
816
|
}
|
|
817
817
|
if (onTagObj) {
|
|
818
818
|
onTagObj(tagObj);
|
|
@@ -836,7 +836,7 @@ var require_Collection = __commonJS({
|
|
|
836
836
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/Collection.js"(exports) {
|
|
837
837
|
"use strict";
|
|
838
838
|
var createNode = require_createNode();
|
|
839
|
-
var
|
|
839
|
+
var identity2 = require_identity();
|
|
840
840
|
var Node = require_Node();
|
|
841
841
|
function collectionFromPath(schema, path, value) {
|
|
842
842
|
let v = value;
|
|
@@ -880,7 +880,7 @@ var require_Collection = __commonJS({
|
|
|
880
880
|
const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
881
881
|
if (schema)
|
|
882
882
|
copy.schema = schema;
|
|
883
|
-
copy.items = copy.items.map((it) =>
|
|
883
|
+
copy.items = copy.items.map((it) => identity2.isNode(it) || identity2.isPair(it) ? it.clone(schema) : it);
|
|
884
884
|
if (this.range)
|
|
885
885
|
copy.range = this.range.slice();
|
|
886
886
|
return copy;
|
|
@@ -896,7 +896,7 @@ var require_Collection = __commonJS({
|
|
|
896
896
|
else {
|
|
897
897
|
const [key, ...rest] = path;
|
|
898
898
|
const node = this.get(key, true);
|
|
899
|
-
if (
|
|
899
|
+
if (identity2.isCollection(node))
|
|
900
900
|
node.addIn(rest, value);
|
|
901
901
|
else if (node === void 0 && this.schema)
|
|
902
902
|
this.set(key, collectionFromPath(this.schema, rest, value));
|
|
@@ -913,7 +913,7 @@ var require_Collection = __commonJS({
|
|
|
913
913
|
if (rest.length === 0)
|
|
914
914
|
return this.delete(key);
|
|
915
915
|
const node = this.get(key, true);
|
|
916
|
-
if (
|
|
916
|
+
if (identity2.isCollection(node))
|
|
917
917
|
return node.deleteIn(rest);
|
|
918
918
|
else
|
|
919
919
|
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
|
@@ -927,16 +927,16 @@ var require_Collection = __commonJS({
|
|
|
927
927
|
const [key, ...rest] = path;
|
|
928
928
|
const node = this.get(key, true);
|
|
929
929
|
if (rest.length === 0)
|
|
930
|
-
return !keepScalar &&
|
|
930
|
+
return !keepScalar && identity2.isScalar(node) ? node.value : node;
|
|
931
931
|
else
|
|
932
|
-
return
|
|
932
|
+
return identity2.isCollection(node) ? node.getIn(rest, keepScalar) : void 0;
|
|
933
933
|
}
|
|
934
934
|
hasAllNullValues(allowScalar) {
|
|
935
935
|
return this.items.every((node) => {
|
|
936
|
-
if (!
|
|
936
|
+
if (!identity2.isPair(node))
|
|
937
937
|
return false;
|
|
938
938
|
const n = node.value;
|
|
939
|
-
return n == null || allowScalar &&
|
|
939
|
+
return n == null || allowScalar && identity2.isScalar(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag;
|
|
940
940
|
});
|
|
941
941
|
}
|
|
942
942
|
/**
|
|
@@ -947,7 +947,7 @@ var require_Collection = __commonJS({
|
|
|
947
947
|
if (rest.length === 0)
|
|
948
948
|
return this.has(key);
|
|
949
949
|
const node = this.get(key, true);
|
|
950
|
-
return
|
|
950
|
+
return identity2.isCollection(node) ? node.hasIn(rest) : false;
|
|
951
951
|
}
|
|
952
952
|
/**
|
|
953
953
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
@@ -959,7 +959,7 @@ var require_Collection = __commonJS({
|
|
|
959
959
|
this.set(key, value);
|
|
960
960
|
} else {
|
|
961
961
|
const node = this.get(key, true);
|
|
962
|
-
if (
|
|
962
|
+
if (identity2.isCollection(node))
|
|
963
963
|
node.setIn(rest, value);
|
|
964
964
|
else if (node === void 0 && this.schema)
|
|
965
965
|
this.set(key, collectionFromPath(this.schema, rest, value));
|
|
@@ -1415,7 +1415,7 @@ var require_stringify = __commonJS({
|
|
|
1415
1415
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/stringify/stringify.js"(exports) {
|
|
1416
1416
|
"use strict";
|
|
1417
1417
|
var anchors = require_anchors();
|
|
1418
|
-
var
|
|
1418
|
+
var identity2 = require_identity();
|
|
1419
1419
|
var stringifyComment = require_stringifyComment();
|
|
1420
1420
|
var stringifyString = require_stringifyString();
|
|
1421
1421
|
function createStringifyContext(doc, options) {
|
|
@@ -1468,7 +1468,7 @@ var require_stringify = __commonJS({
|
|
|
1468
1468
|
}
|
|
1469
1469
|
let tagObj = void 0;
|
|
1470
1470
|
let obj;
|
|
1471
|
-
if (
|
|
1471
|
+
if (identity2.isScalar(item)) {
|
|
1472
1472
|
obj = item.value;
|
|
1473
1473
|
let match = tags.filter((t) => t.identify?.(obj));
|
|
1474
1474
|
if (match.length > 1) {
|
|
@@ -1491,7 +1491,7 @@ var require_stringify = __commonJS({
|
|
|
1491
1491
|
if (!doc.directives)
|
|
1492
1492
|
return "";
|
|
1493
1493
|
const props = [];
|
|
1494
|
-
const anchor2 = (
|
|
1494
|
+
const anchor2 = (identity2.isScalar(node) || identity2.isCollection(node)) && node.anchor;
|
|
1495
1495
|
if (anchor2 && anchors.anchorIsValid(anchor2)) {
|
|
1496
1496
|
anchors$1.add(anchor2);
|
|
1497
1497
|
props.push(`&${anchor2}`);
|
|
@@ -1502,9 +1502,9 @@ var require_stringify = __commonJS({
|
|
|
1502
1502
|
return props.join(" ");
|
|
1503
1503
|
}
|
|
1504
1504
|
function stringify2(item, ctx, onComment, onChompKeep) {
|
|
1505
|
-
if (
|
|
1505
|
+
if (identity2.isPair(item))
|
|
1506
1506
|
return item.toString(ctx, onComment, onChompKeep);
|
|
1507
|
-
if (
|
|
1507
|
+
if (identity2.isAlias(item)) {
|
|
1508
1508
|
if (ctx.doc.directives)
|
|
1509
1509
|
return item.toString(ctx);
|
|
1510
1510
|
if (ctx.resolvedAliases?.has(item)) {
|
|
@@ -1518,15 +1518,15 @@ var require_stringify = __commonJS({
|
|
|
1518
1518
|
}
|
|
1519
1519
|
}
|
|
1520
1520
|
let tagObj = void 0;
|
|
1521
|
-
const node =
|
|
1521
|
+
const node = identity2.isNode(item) ? item : ctx.doc.createNode(item, { onTagObj: (o) => tagObj = o });
|
|
1522
1522
|
tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
|
|
1523
1523
|
const props = stringifyProps(node, tagObj, ctx);
|
|
1524
1524
|
if (props.length > 0)
|
|
1525
1525
|
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
|
|
1526
|
-
const str = typeof tagObj.stringify === "function" ? tagObj.stringify(node, ctx, onComment, onChompKeep) :
|
|
1526
|
+
const str = typeof tagObj.stringify === "function" ? tagObj.stringify(node, ctx, onComment, onChompKeep) : identity2.isScalar(node) ? stringifyString.stringifyString(node, ctx, onComment, onChompKeep) : node.toString(ctx, onComment, onChompKeep);
|
|
1527
1527
|
if (!props)
|
|
1528
1528
|
return str;
|
|
1529
|
-
return
|
|
1529
|
+
return identity2.isScalar(node) || str[0] === "{" || str[0] === "[" ? `${props} ${str}` : `${props}
|
|
1530
1530
|
${ctx.indent}${str}`;
|
|
1531
1531
|
}
|
|
1532
1532
|
exports.createStringifyContext = createStringifyContext;
|
|
@@ -1538,23 +1538,23 @@ ${ctx.indent}${str}`;
|
|
|
1538
1538
|
var require_stringifyPair = __commonJS({
|
|
1539
1539
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/stringify/stringifyPair.js"(exports) {
|
|
1540
1540
|
"use strict";
|
|
1541
|
-
var
|
|
1541
|
+
var identity2 = require_identity();
|
|
1542
1542
|
var Scalar = require_Scalar();
|
|
1543
1543
|
var stringify2 = require_stringify();
|
|
1544
1544
|
var stringifyComment = require_stringifyComment();
|
|
1545
1545
|
function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
1546
1546
|
const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
|
|
1547
|
-
let keyComment =
|
|
1547
|
+
let keyComment = identity2.isNode(key) && key.comment || null;
|
|
1548
1548
|
if (simpleKeys) {
|
|
1549
1549
|
if (keyComment) {
|
|
1550
1550
|
throw new Error("With simple keys, key nodes cannot have comments");
|
|
1551
1551
|
}
|
|
1552
|
-
if (
|
|
1552
|
+
if (identity2.isCollection(key) || !identity2.isNode(key) && typeof key === "object") {
|
|
1553
1553
|
const msg = "With simple keys, collection cannot be used as a key value";
|
|
1554
1554
|
throw new Error(msg);
|
|
1555
1555
|
}
|
|
1556
1556
|
}
|
|
1557
|
-
let explicitKey = !simpleKeys && (!key || keyComment && value == null && !ctx.inFlow ||
|
|
1557
|
+
let explicitKey = !simpleKeys && (!key || keyComment && value == null && !ctx.inFlow || identity2.isCollection(key) || (identity2.isScalar(key) ? key.type === Scalar.Scalar.BLOCK_FOLDED || key.type === Scalar.Scalar.BLOCK_LITERAL : typeof key === "object"));
|
|
1558
1558
|
ctx = Object.assign({}, ctx, {
|
|
1559
1559
|
allNullValues: false,
|
|
1560
1560
|
implicitKey: !explicitKey && (simpleKeys || !allNullValues),
|
|
@@ -1595,7 +1595,7 @@ ${indent}:`;
|
|
|
1595
1595
|
str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment));
|
|
1596
1596
|
}
|
|
1597
1597
|
let vsb, vcb, valueComment;
|
|
1598
|
-
if (
|
|
1598
|
+
if (identity2.isNode(value)) {
|
|
1599
1599
|
vsb = !!value.spaceBefore;
|
|
1600
1600
|
vcb = value.commentBefore;
|
|
1601
1601
|
valueComment = value.comment;
|
|
@@ -1607,10 +1607,10 @@ ${indent}:`;
|
|
|
1607
1607
|
value = doc.createNode(value);
|
|
1608
1608
|
}
|
|
1609
1609
|
ctx.implicitKey = false;
|
|
1610
|
-
if (!explicitKey && !keyComment &&
|
|
1610
|
+
if (!explicitKey && !keyComment && identity2.isScalar(value))
|
|
1611
1611
|
ctx.indentAtStart = str.length + 1;
|
|
1612
1612
|
chompKeep = false;
|
|
1613
|
-
if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey &&
|
|
1613
|
+
if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey && identity2.isSeq(value) && !value.flow && !value.tag && !value.anchor) {
|
|
1614
1614
|
ctx.indent = ctx.indent.substring(2);
|
|
1615
1615
|
}
|
|
1616
1616
|
let valueCommentDone = false;
|
|
@@ -1630,7 +1630,7 @@ ${stringifyComment.indentComment(cs, ctx.indent)}`;
|
|
|
1630
1630
|
ws += `
|
|
1631
1631
|
${ctx.indent}`;
|
|
1632
1632
|
}
|
|
1633
|
-
} else if (!explicitKey &&
|
|
1633
|
+
} else if (!explicitKey && identity2.isCollection(value)) {
|
|
1634
1634
|
const vs0 = valueStr[0];
|
|
1635
1635
|
const nl0 = valueStr.indexOf("\n");
|
|
1636
1636
|
const hasNewline = nl0 !== -1;
|
|
@@ -1693,7 +1693,7 @@ var require_log = __commonJS({
|
|
|
1693
1693
|
var require_merge = __commonJS({
|
|
1694
1694
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/yaml-1.1/merge.js"(exports) {
|
|
1695
1695
|
"use strict";
|
|
1696
|
-
var
|
|
1696
|
+
var identity2 = require_identity();
|
|
1697
1697
|
var Scalar = require_Scalar();
|
|
1698
1698
|
var MERGE_KEY = "<<";
|
|
1699
1699
|
var merge = {
|
|
@@ -1706,10 +1706,10 @@ var require_merge = __commonJS({
|
|
|
1706
1706
|
}),
|
|
1707
1707
|
stringify: () => MERGE_KEY
|
|
1708
1708
|
};
|
|
1709
|
-
var isMergeKey = (ctx, key) => (merge.identify(key) ||
|
|
1709
|
+
var isMergeKey = (ctx, key) => (merge.identify(key) || identity2.isScalar(key) && (!key.type || key.type === Scalar.Scalar.PLAIN) && merge.identify(key.value)) && ctx?.doc.schema.tags.some((tag) => tag.tag === merge.tag && tag.default);
|
|
1710
1710
|
function addMergeToJSMap(ctx, map, value) {
|
|
1711
1711
|
const source = resolveAliasValue(ctx, value);
|
|
1712
|
-
if (
|
|
1712
|
+
if (identity2.isSeq(source))
|
|
1713
1713
|
for (const it of source.items)
|
|
1714
1714
|
mergeValue(ctx, map, it);
|
|
1715
1715
|
else if (Array.isArray(source))
|
|
@@ -1720,7 +1720,7 @@ var require_merge = __commonJS({
|
|
|
1720
1720
|
}
|
|
1721
1721
|
function mergeValue(ctx, map, value) {
|
|
1722
1722
|
const source = resolveAliasValue(ctx, value);
|
|
1723
|
-
if (!
|
|
1723
|
+
if (!identity2.isMap(source))
|
|
1724
1724
|
throw new Error("Merge sources must be maps or map aliases");
|
|
1725
1725
|
const srcMap = source.toJSON(null, ctx, Map);
|
|
1726
1726
|
for (const [key, value2] of srcMap) {
|
|
@@ -1741,7 +1741,7 @@ var require_merge = __commonJS({
|
|
|
1741
1741
|
return map;
|
|
1742
1742
|
}
|
|
1743
1743
|
function resolveAliasValue(ctx, value) {
|
|
1744
|
-
return ctx &&
|
|
1744
|
+
return ctx && identity2.isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
|
|
1745
1745
|
}
|
|
1746
1746
|
exports.addMergeToJSMap = addMergeToJSMap;
|
|
1747
1747
|
exports.isMergeKey = isMergeKey;
|
|
@@ -1756,10 +1756,10 @@ var require_addPairToJSMap = __commonJS({
|
|
|
1756
1756
|
var log = require_log();
|
|
1757
1757
|
var merge = require_merge();
|
|
1758
1758
|
var stringify2 = require_stringify();
|
|
1759
|
-
var
|
|
1759
|
+
var identity2 = require_identity();
|
|
1760
1760
|
var toJS = require_toJS();
|
|
1761
1761
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
1762
|
-
if (
|
|
1762
|
+
if (identity2.isNode(key) && key.addToJSMap)
|
|
1763
1763
|
key.addToJSMap(ctx, map, value);
|
|
1764
1764
|
else if (merge.isMergeKey(ctx, key))
|
|
1765
1765
|
merge.addMergeToJSMap(ctx, map, value);
|
|
@@ -1790,7 +1790,7 @@ var require_addPairToJSMap = __commonJS({
|
|
|
1790
1790
|
return "";
|
|
1791
1791
|
if (typeof jsKey !== "object")
|
|
1792
1792
|
return String(jsKey);
|
|
1793
|
-
if (
|
|
1793
|
+
if (identity2.isNode(key) && ctx?.doc) {
|
|
1794
1794
|
const strCtx = stringify2.createStringifyContext(ctx.doc, {});
|
|
1795
1795
|
strCtx.anchors = /* @__PURE__ */ new Set();
|
|
1796
1796
|
for (const node of ctx.anchors.keys())
|
|
@@ -1820,7 +1820,7 @@ var require_Pair = __commonJS({
|
|
|
1820
1820
|
var createNode = require_createNode();
|
|
1821
1821
|
var stringifyPair = require_stringifyPair();
|
|
1822
1822
|
var addPairToJSMap = require_addPairToJSMap();
|
|
1823
|
-
var
|
|
1823
|
+
var identity2 = require_identity();
|
|
1824
1824
|
function createPair(key, value, ctx) {
|
|
1825
1825
|
const k = createNode.createNode(key, void 0, ctx);
|
|
1826
1826
|
const v = createNode.createNode(value, void 0, ctx);
|
|
@@ -1828,15 +1828,15 @@ var require_Pair = __commonJS({
|
|
|
1828
1828
|
}
|
|
1829
1829
|
var Pair = class _Pair {
|
|
1830
1830
|
constructor(key, value = null) {
|
|
1831
|
-
Object.defineProperty(this,
|
|
1831
|
+
Object.defineProperty(this, identity2.NODE_TYPE, { value: identity2.PAIR });
|
|
1832
1832
|
this.key = key;
|
|
1833
1833
|
this.value = value;
|
|
1834
1834
|
}
|
|
1835
1835
|
clone(schema) {
|
|
1836
1836
|
let { key, value } = this;
|
|
1837
|
-
if (
|
|
1837
|
+
if (identity2.isNode(key))
|
|
1838
1838
|
key = key.clone(schema);
|
|
1839
|
-
if (
|
|
1839
|
+
if (identity2.isNode(value))
|
|
1840
1840
|
value = value.clone(schema);
|
|
1841
1841
|
return new _Pair(key, value);
|
|
1842
1842
|
}
|
|
@@ -1857,7 +1857,7 @@ var require_Pair = __commonJS({
|
|
|
1857
1857
|
var require_stringifyCollection = __commonJS({
|
|
1858
1858
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/stringify/stringifyCollection.js"(exports) {
|
|
1859
1859
|
"use strict";
|
|
1860
|
-
var
|
|
1860
|
+
var identity2 = require_identity();
|
|
1861
1861
|
var stringify2 = require_stringify();
|
|
1862
1862
|
var stringifyComment = require_stringifyComment();
|
|
1863
1863
|
function stringifyCollection(collection, ctx, options) {
|
|
@@ -1873,14 +1873,14 @@ var require_stringifyCollection = __commonJS({
|
|
|
1873
1873
|
for (let i = 0; i < items.length; ++i) {
|
|
1874
1874
|
const item = items[i];
|
|
1875
1875
|
let comment2 = null;
|
|
1876
|
-
if (
|
|
1876
|
+
if (identity2.isNode(item)) {
|
|
1877
1877
|
if (!chompKeep && item.spaceBefore)
|
|
1878
1878
|
lines.push("");
|
|
1879
1879
|
addCommentBefore(ctx, lines, item.commentBefore, chompKeep);
|
|
1880
1880
|
if (item.comment)
|
|
1881
1881
|
comment2 = item.comment;
|
|
1882
|
-
} else if (
|
|
1883
|
-
const ik =
|
|
1882
|
+
} else if (identity2.isPair(item)) {
|
|
1883
|
+
const ik = identity2.isNode(item.key) ? item.key : null;
|
|
1884
1884
|
if (ik) {
|
|
1885
1885
|
if (!chompKeep && ik.spaceBefore)
|
|
1886
1886
|
lines.push("");
|
|
@@ -1928,14 +1928,14 @@ ${indent}${line}` : "\n";
|
|
|
1928
1928
|
for (let i = 0; i < items.length; ++i) {
|
|
1929
1929
|
const item = items[i];
|
|
1930
1930
|
let comment = null;
|
|
1931
|
-
if (
|
|
1931
|
+
if (identity2.isNode(item)) {
|
|
1932
1932
|
if (item.spaceBefore)
|
|
1933
1933
|
lines.push("");
|
|
1934
1934
|
addCommentBefore(ctx, lines, item.commentBefore, false);
|
|
1935
1935
|
if (item.comment)
|
|
1936
1936
|
comment = item.comment;
|
|
1937
|
-
} else if (
|
|
1938
|
-
const ik =
|
|
1937
|
+
} else if (identity2.isPair(item)) {
|
|
1938
|
+
const ik = identity2.isNode(item.key) ? item.key : null;
|
|
1939
1939
|
if (ik) {
|
|
1940
1940
|
if (ik.spaceBefore)
|
|
1941
1941
|
lines.push("");
|
|
@@ -1943,7 +1943,7 @@ ${indent}${line}` : "\n";
|
|
|
1943
1943
|
if (ik.comment)
|
|
1944
1944
|
reqNewline = true;
|
|
1945
1945
|
}
|
|
1946
|
-
const iv =
|
|
1946
|
+
const iv = identity2.isNode(item.value) ? item.value : null;
|
|
1947
1947
|
if (iv) {
|
|
1948
1948
|
if (iv.comment)
|
|
1949
1949
|
comment = iv.comment;
|
|
@@ -2011,16 +2011,16 @@ var require_YAMLMap = __commonJS({
|
|
|
2011
2011
|
var stringifyCollection = require_stringifyCollection();
|
|
2012
2012
|
var addPairToJSMap = require_addPairToJSMap();
|
|
2013
2013
|
var Collection = require_Collection();
|
|
2014
|
-
var
|
|
2014
|
+
var identity2 = require_identity();
|
|
2015
2015
|
var Pair = require_Pair();
|
|
2016
2016
|
var Scalar = require_Scalar();
|
|
2017
2017
|
function findPair(items, key) {
|
|
2018
|
-
const k =
|
|
2018
|
+
const k = identity2.isScalar(key) ? key.value : key;
|
|
2019
2019
|
for (const it of items) {
|
|
2020
|
-
if (
|
|
2020
|
+
if (identity2.isPair(it)) {
|
|
2021
2021
|
if (it.key === key || it.key === k)
|
|
2022
2022
|
return it;
|
|
2023
|
-
if (
|
|
2023
|
+
if (identity2.isScalar(it.key) && it.key.value === k)
|
|
2024
2024
|
return it;
|
|
2025
2025
|
}
|
|
2026
2026
|
}
|
|
@@ -2031,7 +2031,7 @@ var require_YAMLMap = __commonJS({
|
|
|
2031
2031
|
return "tag:yaml.org,2002:map";
|
|
2032
2032
|
}
|
|
2033
2033
|
constructor(schema) {
|
|
2034
|
-
super(
|
|
2034
|
+
super(identity2.MAP, schema);
|
|
2035
2035
|
this.items = [];
|
|
2036
2036
|
}
|
|
2037
2037
|
/**
|
|
@@ -2069,7 +2069,7 @@ var require_YAMLMap = __commonJS({
|
|
|
2069
2069
|
*/
|
|
2070
2070
|
add(pair, overwrite) {
|
|
2071
2071
|
let _pair;
|
|
2072
|
-
if (
|
|
2072
|
+
if (identity2.isPair(pair))
|
|
2073
2073
|
_pair = pair;
|
|
2074
2074
|
else if (!pair || typeof pair !== "object" || !("key" in pair)) {
|
|
2075
2075
|
_pair = new Pair.Pair(pair, pair?.value);
|
|
@@ -2080,7 +2080,7 @@ var require_YAMLMap = __commonJS({
|
|
|
2080
2080
|
if (prev) {
|
|
2081
2081
|
if (!overwrite)
|
|
2082
2082
|
throw new Error(`Key ${_pair.key} already set`);
|
|
2083
|
-
if (
|
|
2083
|
+
if (identity2.isScalar(prev.value) && Scalar.isScalarValue(_pair.value))
|
|
2084
2084
|
prev.value.value = _pair.value;
|
|
2085
2085
|
else
|
|
2086
2086
|
prev.value = _pair.value;
|
|
@@ -2104,7 +2104,7 @@ var require_YAMLMap = __commonJS({
|
|
|
2104
2104
|
get(key, keepScalar) {
|
|
2105
2105
|
const it = findPair(this.items, key);
|
|
2106
2106
|
const node = it?.value;
|
|
2107
|
-
return (!keepScalar &&
|
|
2107
|
+
return (!keepScalar && identity2.isScalar(node) ? node.value : node) ?? void 0;
|
|
2108
2108
|
}
|
|
2109
2109
|
has(key) {
|
|
2110
2110
|
return !!findPair(this.items, key);
|
|
@@ -2129,7 +2129,7 @@ var require_YAMLMap = __commonJS({
|
|
|
2129
2129
|
if (!ctx)
|
|
2130
2130
|
return JSON.stringify(this);
|
|
2131
2131
|
for (const item of this.items) {
|
|
2132
|
-
if (!
|
|
2132
|
+
if (!identity2.isPair(item))
|
|
2133
2133
|
throw new Error(`Map items must all be pairs; found ${JSON.stringify(item)} instead`);
|
|
2134
2134
|
}
|
|
2135
2135
|
if (!ctx.allNullValues && this.hasAllNullValues(false))
|
|
@@ -2152,7 +2152,7 @@ var require_YAMLMap = __commonJS({
|
|
|
2152
2152
|
var require_map = __commonJS({
|
|
2153
2153
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/common/map.js"(exports) {
|
|
2154
2154
|
"use strict";
|
|
2155
|
-
var
|
|
2155
|
+
var identity2 = require_identity();
|
|
2156
2156
|
var YAMLMap = require_YAMLMap();
|
|
2157
2157
|
var map = {
|
|
2158
2158
|
collection: "map",
|
|
@@ -2160,7 +2160,7 @@ var require_map = __commonJS({
|
|
|
2160
2160
|
nodeClass: YAMLMap.YAMLMap,
|
|
2161
2161
|
tag: "tag:yaml.org,2002:map",
|
|
2162
2162
|
resolve(map2, onError) {
|
|
2163
|
-
if (!
|
|
2163
|
+
if (!identity2.isMap(map2))
|
|
2164
2164
|
onError("Expected a mapping for this tag");
|
|
2165
2165
|
return map2;
|
|
2166
2166
|
},
|
|
@@ -2177,7 +2177,7 @@ var require_YAMLSeq = __commonJS({
|
|
|
2177
2177
|
var createNode = require_createNode();
|
|
2178
2178
|
var stringifyCollection = require_stringifyCollection();
|
|
2179
2179
|
var Collection = require_Collection();
|
|
2180
|
-
var
|
|
2180
|
+
var identity2 = require_identity();
|
|
2181
2181
|
var Scalar = require_Scalar();
|
|
2182
2182
|
var toJS = require_toJS();
|
|
2183
2183
|
var YAMLSeq = class extends Collection.Collection {
|
|
@@ -2185,7 +2185,7 @@ var require_YAMLSeq = __commonJS({
|
|
|
2185
2185
|
return "tag:yaml.org,2002:seq";
|
|
2186
2186
|
}
|
|
2187
2187
|
constructor(schema) {
|
|
2188
|
-
super(
|
|
2188
|
+
super(identity2.SEQ, schema);
|
|
2189
2189
|
this.items = [];
|
|
2190
2190
|
}
|
|
2191
2191
|
add(value) {
|
|
@@ -2211,7 +2211,7 @@ var require_YAMLSeq = __commonJS({
|
|
|
2211
2211
|
if (typeof idx !== "number")
|
|
2212
2212
|
return void 0;
|
|
2213
2213
|
const it = this.items[idx];
|
|
2214
|
-
return !keepScalar &&
|
|
2214
|
+
return !keepScalar && identity2.isScalar(it) ? it.value : it;
|
|
2215
2215
|
}
|
|
2216
2216
|
/**
|
|
2217
2217
|
* Checks if the collection includes a value with the key `key`.
|
|
@@ -2235,7 +2235,7 @@ var require_YAMLSeq = __commonJS({
|
|
|
2235
2235
|
if (typeof idx !== "number")
|
|
2236
2236
|
throw new Error(`Expected a valid index, not ${key}.`);
|
|
2237
2237
|
const prev = this.items[idx];
|
|
2238
|
-
if (
|
|
2238
|
+
if (identity2.isScalar(prev) && Scalar.isScalarValue(value))
|
|
2239
2239
|
prev.value = value;
|
|
2240
2240
|
else
|
|
2241
2241
|
this.items[idx] = value;
|
|
@@ -2277,7 +2277,7 @@ var require_YAMLSeq = __commonJS({
|
|
|
2277
2277
|
}
|
|
2278
2278
|
};
|
|
2279
2279
|
function asItemIndex(key) {
|
|
2280
|
-
let idx =
|
|
2280
|
+
let idx = identity2.isScalar(key) ? key.value : key;
|
|
2281
2281
|
if (idx && typeof idx === "string")
|
|
2282
2282
|
idx = Number(idx);
|
|
2283
2283
|
return typeof idx === "number" && Number.isInteger(idx) && idx >= 0 ? idx : null;
|
|
@@ -2290,7 +2290,7 @@ var require_YAMLSeq = __commonJS({
|
|
|
2290
2290
|
var require_seq = __commonJS({
|
|
2291
2291
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/common/seq.js"(exports) {
|
|
2292
2292
|
"use strict";
|
|
2293
|
-
var
|
|
2293
|
+
var identity2 = require_identity();
|
|
2294
2294
|
var YAMLSeq = require_YAMLSeq();
|
|
2295
2295
|
var seq = {
|
|
2296
2296
|
collection: "seq",
|
|
@@ -2298,7 +2298,7 @@ var require_seq = __commonJS({
|
|
|
2298
2298
|
nodeClass: YAMLSeq.YAMLSeq,
|
|
2299
2299
|
tag: "tag:yaml.org,2002:seq",
|
|
2300
2300
|
resolve(seq2, onError) {
|
|
2301
|
-
if (!
|
|
2301
|
+
if (!identity2.isSeq(seq2))
|
|
2302
2302
|
onError("Expected a sequence for this tag");
|
|
2303
2303
|
return seq2;
|
|
2304
2304
|
},
|
|
@@ -2652,17 +2652,17 @@ var require_binary = __commonJS({
|
|
|
2652
2652
|
var require_pairs = __commonJS({
|
|
2653
2653
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/yaml-1.1/pairs.js"(exports) {
|
|
2654
2654
|
"use strict";
|
|
2655
|
-
var
|
|
2655
|
+
var identity2 = require_identity();
|
|
2656
2656
|
var Pair = require_Pair();
|
|
2657
2657
|
var Scalar = require_Scalar();
|
|
2658
2658
|
var YAMLSeq = require_YAMLSeq();
|
|
2659
2659
|
function resolvePairs(seq, onError) {
|
|
2660
|
-
if (
|
|
2660
|
+
if (identity2.isSeq(seq)) {
|
|
2661
2661
|
for (let i = 0; i < seq.items.length; ++i) {
|
|
2662
2662
|
let item = seq.items[i];
|
|
2663
|
-
if (
|
|
2663
|
+
if (identity2.isPair(item))
|
|
2664
2664
|
continue;
|
|
2665
|
-
else if (
|
|
2665
|
+
else if (identity2.isMap(item)) {
|
|
2666
2666
|
if (item.items.length > 1)
|
|
2667
2667
|
onError("Each pair must have its own sequence indicator");
|
|
2668
2668
|
const pair = item.items[0] || new Pair.Pair(new Scalar.Scalar(null));
|
|
@@ -2676,7 +2676,7 @@ ${cn.comment}` : item.comment;
|
|
|
2676
2676
|
}
|
|
2677
2677
|
item = pair;
|
|
2678
2678
|
}
|
|
2679
|
-
seq.items[i] =
|
|
2679
|
+
seq.items[i] = identity2.isPair(item) ? item : new Pair.Pair(item);
|
|
2680
2680
|
}
|
|
2681
2681
|
} else
|
|
2682
2682
|
onError("Expected a sequence for this tag");
|
|
@@ -2730,7 +2730,7 @@ ${cn.comment}` : item.comment;
|
|
|
2730
2730
|
var require_omap = __commonJS({
|
|
2731
2731
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/yaml-1.1/omap.js"(exports) {
|
|
2732
2732
|
"use strict";
|
|
2733
|
-
var
|
|
2733
|
+
var identity2 = require_identity();
|
|
2734
2734
|
var toJS = require_toJS();
|
|
2735
2735
|
var YAMLMap = require_YAMLMap();
|
|
2736
2736
|
var YAMLSeq = require_YAMLSeq();
|
|
@@ -2757,7 +2757,7 @@ var require_omap = __commonJS({
|
|
|
2757
2757
|
ctx.onCreate(map);
|
|
2758
2758
|
for (const pair of this.items) {
|
|
2759
2759
|
let key, value;
|
|
2760
|
-
if (
|
|
2760
|
+
if (identity2.isPair(pair)) {
|
|
2761
2761
|
key = toJS.toJS(pair.key, "", ctx);
|
|
2762
2762
|
value = toJS.toJS(pair.value, key, ctx);
|
|
2763
2763
|
} else {
|
|
@@ -2787,7 +2787,7 @@ var require_omap = __commonJS({
|
|
|
2787
2787
|
const pairs$1 = pairs.resolvePairs(seq, onError);
|
|
2788
2788
|
const seenKeys = [];
|
|
2789
2789
|
for (const { key } of pairs$1.items) {
|
|
2790
|
-
if (
|
|
2790
|
+
if (identity2.isScalar(key)) {
|
|
2791
2791
|
if (seenKeys.includes(key.value)) {
|
|
2792
2792
|
onError(`Ordered maps must not include duplicate keys: ${key.value}`);
|
|
2793
2793
|
} else {
|
|
@@ -2968,7 +2968,7 @@ var require_int2 = __commonJS({
|
|
|
2968
2968
|
var require_set = __commonJS({
|
|
2969
2969
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/yaml-1.1/set.js"(exports) {
|
|
2970
2970
|
"use strict";
|
|
2971
|
-
var
|
|
2971
|
+
var identity2 = require_identity();
|
|
2972
2972
|
var Pair = require_Pair();
|
|
2973
2973
|
var YAMLMap = require_YAMLMap();
|
|
2974
2974
|
var YAMLSet = class _YAMLSet extends YAMLMap.YAMLMap {
|
|
@@ -2978,7 +2978,7 @@ var require_set = __commonJS({
|
|
|
2978
2978
|
}
|
|
2979
2979
|
add(key) {
|
|
2980
2980
|
let pair;
|
|
2981
|
-
if (
|
|
2981
|
+
if (identity2.isPair(key))
|
|
2982
2982
|
pair = key;
|
|
2983
2983
|
else if (key && typeof key === "object" && "key" in key && "value" in key && key.value === null)
|
|
2984
2984
|
pair = new Pair.Pair(key.key, null);
|
|
@@ -2994,7 +2994,7 @@ var require_set = __commonJS({
|
|
|
2994
2994
|
*/
|
|
2995
2995
|
get(key, keepPair) {
|
|
2996
2996
|
const pair = YAMLMap.findPair(this.items, key);
|
|
2997
|
-
return !keepPair &&
|
|
2997
|
+
return !keepPair && identity2.isPair(pair) ? identity2.isScalar(pair.key) ? pair.key.value : pair.key : pair;
|
|
2998
2998
|
}
|
|
2999
2999
|
set(key, value) {
|
|
3000
3000
|
if (typeof value !== "boolean")
|
|
@@ -3038,7 +3038,7 @@ var require_set = __commonJS({
|
|
|
3038
3038
|
tag: "tag:yaml.org,2002:set",
|
|
3039
3039
|
createNode: (schema, iterable, ctx) => YAMLSet.from(schema, iterable, ctx),
|
|
3040
3040
|
resolve(map, onError) {
|
|
3041
|
-
if (
|
|
3041
|
+
if (identity2.isMap(map)) {
|
|
3042
3042
|
if (map.hasAllNullValues(true))
|
|
3043
3043
|
return Object.assign(new YAMLSet(), map);
|
|
3044
3044
|
else
|
|
@@ -3283,7 +3283,7 @@ var require_tags = __commonJS({
|
|
|
3283
3283
|
var require_Schema = __commonJS({
|
|
3284
3284
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/Schema.js"(exports) {
|
|
3285
3285
|
"use strict";
|
|
3286
|
-
var
|
|
3286
|
+
var identity2 = require_identity();
|
|
3287
3287
|
var map = require_map();
|
|
3288
3288
|
var seq = require_seq();
|
|
3289
3289
|
var string = require_string();
|
|
@@ -3296,9 +3296,9 @@ var require_Schema = __commonJS({
|
|
|
3296
3296
|
this.knownTags = resolveKnownTags ? tags.coreKnownTags : {};
|
|
3297
3297
|
this.tags = tags.getTags(customTags, this.name, merge);
|
|
3298
3298
|
this.toStringOptions = toStringDefaults ?? null;
|
|
3299
|
-
Object.defineProperty(this,
|
|
3300
|
-
Object.defineProperty(this,
|
|
3301
|
-
Object.defineProperty(this,
|
|
3299
|
+
Object.defineProperty(this, identity2.MAP, { value: map.map });
|
|
3300
|
+
Object.defineProperty(this, identity2.SCALAR, { value: string.string });
|
|
3301
|
+
Object.defineProperty(this, identity2.SEQ, { value: seq.seq });
|
|
3302
3302
|
this.sortMapEntries = typeof sortMapEntries === "function" ? sortMapEntries : sortMapEntries === true ? sortMapEntriesByKey : null;
|
|
3303
3303
|
}
|
|
3304
3304
|
clone() {
|
|
@@ -3315,7 +3315,7 @@ var require_Schema = __commonJS({
|
|
|
3315
3315
|
var require_stringifyDocument = __commonJS({
|
|
3316
3316
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/stringify/stringifyDocument.js"(exports) {
|
|
3317
3317
|
"use strict";
|
|
3318
|
-
var
|
|
3318
|
+
var identity2 = require_identity();
|
|
3319
3319
|
var stringify2 = require_stringify();
|
|
3320
3320
|
var stringifyComment = require_stringifyComment();
|
|
3321
3321
|
function stringifyDocument(doc, options) {
|
|
@@ -3342,7 +3342,7 @@ var require_stringifyDocument = __commonJS({
|
|
|
3342
3342
|
let chompKeep = false;
|
|
3343
3343
|
let contentComment = null;
|
|
3344
3344
|
if (doc.contents) {
|
|
3345
|
-
if (
|
|
3345
|
+
if (identity2.isNode(doc.contents)) {
|
|
3346
3346
|
if (doc.contents.spaceBefore && hasDirectives)
|
|
3347
3347
|
lines.push("");
|
|
3348
3348
|
if (doc.contents.commentBefore) {
|
|
@@ -3397,7 +3397,7 @@ var require_Document = __commonJS({
|
|
|
3397
3397
|
"use strict";
|
|
3398
3398
|
var Alias = require_Alias();
|
|
3399
3399
|
var Collection = require_Collection();
|
|
3400
|
-
var
|
|
3400
|
+
var identity2 = require_identity();
|
|
3401
3401
|
var Pair = require_Pair();
|
|
3402
3402
|
var toJS = require_toJS();
|
|
3403
3403
|
var Schema = require_Schema();
|
|
@@ -3412,7 +3412,7 @@ var require_Document = __commonJS({
|
|
|
3412
3412
|
this.comment = null;
|
|
3413
3413
|
this.errors = [];
|
|
3414
3414
|
this.warnings = [];
|
|
3415
|
-
Object.defineProperty(this,
|
|
3415
|
+
Object.defineProperty(this, identity2.NODE_TYPE, { value: identity2.DOC });
|
|
3416
3416
|
let _replacer = null;
|
|
3417
3417
|
if (typeof replacer === "function" || Array.isArray(replacer)) {
|
|
3418
3418
|
_replacer = replacer;
|
|
@@ -3448,7 +3448,7 @@ var require_Document = __commonJS({
|
|
|
3448
3448
|
*/
|
|
3449
3449
|
clone() {
|
|
3450
3450
|
const copy = Object.create(_Document.prototype, {
|
|
3451
|
-
[
|
|
3451
|
+
[identity2.NODE_TYPE]: { value: identity2.DOC }
|
|
3452
3452
|
});
|
|
3453
3453
|
copy.commentBefore = this.commentBefore;
|
|
3454
3454
|
copy.comment = this.comment;
|
|
@@ -3458,7 +3458,7 @@ var require_Document = __commonJS({
|
|
|
3458
3458
|
if (this.directives)
|
|
3459
3459
|
copy.directives = this.directives.clone();
|
|
3460
3460
|
copy.schema = this.schema.clone();
|
|
3461
|
-
copy.contents =
|
|
3461
|
+
copy.contents = identity2.isNode(this.contents) ? this.contents.clone(copy.schema) : this.contents;
|
|
3462
3462
|
if (this.range)
|
|
3463
3463
|
copy.range = this.range.slice();
|
|
3464
3464
|
return copy;
|
|
@@ -3521,7 +3521,7 @@ var require_Document = __commonJS({
|
|
|
3521
3521
|
sourceObjects
|
|
3522
3522
|
};
|
|
3523
3523
|
const node = createNode.createNode(value, tag, ctx);
|
|
3524
|
-
if (flow &&
|
|
3524
|
+
if (flow && identity2.isCollection(node))
|
|
3525
3525
|
node.flow = true;
|
|
3526
3526
|
setAnchors();
|
|
3527
3527
|
return node;
|
|
@@ -3561,7 +3561,7 @@ var require_Document = __commonJS({
|
|
|
3561
3561
|
* `true` (collections are always returned intact).
|
|
3562
3562
|
*/
|
|
3563
3563
|
get(key, keepScalar) {
|
|
3564
|
-
return
|
|
3564
|
+
return identity2.isCollection(this.contents) ? this.contents.get(key, keepScalar) : void 0;
|
|
3565
3565
|
}
|
|
3566
3566
|
/**
|
|
3567
3567
|
* Returns item at `path`, or `undefined` if not found. By default unwraps
|
|
@@ -3570,14 +3570,14 @@ var require_Document = __commonJS({
|
|
|
3570
3570
|
*/
|
|
3571
3571
|
getIn(path, keepScalar) {
|
|
3572
3572
|
if (Collection.isEmptyPath(path))
|
|
3573
|
-
return !keepScalar &&
|
|
3574
|
-
return
|
|
3573
|
+
return !keepScalar && identity2.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3574
|
+
return identity2.isCollection(this.contents) ? this.contents.getIn(path, keepScalar) : void 0;
|
|
3575
3575
|
}
|
|
3576
3576
|
/**
|
|
3577
3577
|
* Checks if the document includes a value with the key `key`.
|
|
3578
3578
|
*/
|
|
3579
3579
|
has(key) {
|
|
3580
|
-
return
|
|
3580
|
+
return identity2.isCollection(this.contents) ? this.contents.has(key) : false;
|
|
3581
3581
|
}
|
|
3582
3582
|
/**
|
|
3583
3583
|
* Checks if the document includes a value at `path`.
|
|
@@ -3585,7 +3585,7 @@ var require_Document = __commonJS({
|
|
|
3585
3585
|
hasIn(path) {
|
|
3586
3586
|
if (Collection.isEmptyPath(path))
|
|
3587
3587
|
return this.contents !== void 0;
|
|
3588
|
-
return
|
|
3588
|
+
return identity2.isCollection(this.contents) ? this.contents.hasIn(path) : false;
|
|
3589
3589
|
}
|
|
3590
3590
|
/**
|
|
3591
3591
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -3692,7 +3692,7 @@ var require_Document = __commonJS({
|
|
|
3692
3692
|
}
|
|
3693
3693
|
};
|
|
3694
3694
|
function assertCollection(contents) {
|
|
3695
|
-
if (
|
|
3695
|
+
if (identity2.isCollection(contents))
|
|
3696
3696
|
return true;
|
|
3697
3697
|
throw new Error("Expected a YAML collection as document contents");
|
|
3698
3698
|
}
|
|
@@ -3963,12 +3963,12 @@ var require_util_flow_indent_check = __commonJS({
|
|
|
3963
3963
|
var require_util_map_includes = __commonJS({
|
|
3964
3964
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/compose/util-map-includes.js"(exports) {
|
|
3965
3965
|
"use strict";
|
|
3966
|
-
var
|
|
3966
|
+
var identity2 = require_identity();
|
|
3967
3967
|
function mapIncludes(ctx, items, search) {
|
|
3968
3968
|
const { uniqueKeys } = ctx.options;
|
|
3969
3969
|
if (uniqueKeys === false)
|
|
3970
3970
|
return false;
|
|
3971
|
-
const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a, b) => a === b ||
|
|
3971
|
+
const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a, b) => a === b || identity2.isScalar(a) && identity2.isScalar(b) && a.value === b.value;
|
|
3972
3972
|
return items.some((pair) => isEqual(pair.key, search));
|
|
3973
3973
|
}
|
|
3974
3974
|
exports.mapIncludes = mapIncludes;
|
|
@@ -4181,7 +4181,7 @@ var require_resolve_end = __commonJS({
|
|
|
4181
4181
|
var require_resolve_flow_collection = __commonJS({
|
|
4182
4182
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/compose/resolve-flow-collection.js"(exports) {
|
|
4183
4183
|
"use strict";
|
|
4184
|
-
var
|
|
4184
|
+
var identity2 = require_identity();
|
|
4185
4185
|
var Pair = require_Pair();
|
|
4186
4186
|
var YAMLMap = require_YAMLMap();
|
|
4187
4187
|
var YAMLSeq = require_YAMLSeq();
|
|
@@ -4260,7 +4260,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4260
4260
|
}
|
|
4261
4261
|
if (prevItemComment) {
|
|
4262
4262
|
let prev = coll.items[coll.items.length - 1];
|
|
4263
|
-
if (
|
|
4263
|
+
if (identity2.isPair(prev))
|
|
4264
4264
|
prev = prev.value ?? prev.key;
|
|
4265
4265
|
if (prev.comment)
|
|
4266
4266
|
prev.comment += "\n" + prevItemComment;
|
|
@@ -4375,7 +4375,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4375
4375
|
var require_compose_collection = __commonJS({
|
|
4376
4376
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/compose/compose-collection.js"(exports) {
|
|
4377
4377
|
"use strict";
|
|
4378
|
-
var
|
|
4378
|
+
var identity2 = require_identity();
|
|
4379
4379
|
var Scalar = require_Scalar();
|
|
4380
4380
|
var YAMLMap = require_YAMLMap();
|
|
4381
4381
|
var YAMLSeq = require_YAMLSeq();
|
|
@@ -4425,7 +4425,7 @@ var require_compose_collection = __commonJS({
|
|
|
4425
4425
|
}
|
|
4426
4426
|
const coll = resolveCollection(CN, ctx, token, onError, tagName, tag);
|
|
4427
4427
|
const res = tag.resolve?.(coll, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg), ctx.options) ?? coll;
|
|
4428
|
-
const node =
|
|
4428
|
+
const node = identity2.isNode(res) ? res : new Scalar.Scalar(res);
|
|
4429
4429
|
node.range = coll.range;
|
|
4430
4430
|
node.tag = tagName;
|
|
4431
4431
|
if (tag?.format)
|
|
@@ -4843,7 +4843,7 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
4843
4843
|
var require_compose_scalar = __commonJS({
|
|
4844
4844
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/compose/compose-scalar.js"(exports) {
|
|
4845
4845
|
"use strict";
|
|
4846
|
-
var
|
|
4846
|
+
var identity2 = require_identity();
|
|
4847
4847
|
var Scalar = require_Scalar();
|
|
4848
4848
|
var resolveBlockScalar = require_resolve_block_scalar();
|
|
4849
4849
|
var resolveFlowScalar = require_resolve_flow_scalar();
|
|
@@ -4852,17 +4852,17 @@ var require_compose_scalar = __commonJS({
|
|
|
4852
4852
|
const tagName = tagToken ? ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)) : null;
|
|
4853
4853
|
let tag;
|
|
4854
4854
|
if (ctx.options.stringKeys && ctx.atKey) {
|
|
4855
|
-
tag = ctx.schema[
|
|
4855
|
+
tag = ctx.schema[identity2.SCALAR];
|
|
4856
4856
|
} else if (tagName)
|
|
4857
4857
|
tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError);
|
|
4858
4858
|
else if (token.type === "scalar")
|
|
4859
4859
|
tag = findScalarTagByTest(ctx, value, token, onError);
|
|
4860
4860
|
else
|
|
4861
|
-
tag = ctx.schema[
|
|
4861
|
+
tag = ctx.schema[identity2.SCALAR];
|
|
4862
4862
|
let scalar;
|
|
4863
4863
|
try {
|
|
4864
4864
|
const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
|
|
4865
|
-
scalar =
|
|
4865
|
+
scalar = identity2.isScalar(res) ? res : new Scalar.Scalar(res);
|
|
4866
4866
|
} catch (error) {
|
|
4867
4867
|
const msg = error instanceof Error ? error.message : String(error);
|
|
4868
4868
|
onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg);
|
|
@@ -4882,7 +4882,7 @@ var require_compose_scalar = __commonJS({
|
|
|
4882
4882
|
}
|
|
4883
4883
|
function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
4884
4884
|
if (tagName === "!")
|
|
4885
|
-
return schema[
|
|
4885
|
+
return schema[identity2.SCALAR];
|
|
4886
4886
|
const matchWithTest = [];
|
|
4887
4887
|
for (const tag of schema.tags) {
|
|
4888
4888
|
if (!tag.collection && tag.tag === tagName) {
|
|
@@ -4901,12 +4901,12 @@ var require_compose_scalar = __commonJS({
|
|
|
4901
4901
|
return kt;
|
|
4902
4902
|
}
|
|
4903
4903
|
onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, tagName !== "tag:yaml.org,2002:str");
|
|
4904
|
-
return schema[
|
|
4904
|
+
return schema[identity2.SCALAR];
|
|
4905
4905
|
}
|
|
4906
4906
|
function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
|
|
4907
|
-
const tag = schema.tags.find((tag2) => (tag2.default === true || atKey && tag2.default === "key") && tag2.test?.test(value)) || schema[
|
|
4907
|
+
const tag = schema.tags.find((tag2) => (tag2.default === true || atKey && tag2.default === "key") && tag2.test?.test(value)) || schema[identity2.SCALAR];
|
|
4908
4908
|
if (schema.compat) {
|
|
4909
|
-
const compat = schema.compat.find((tag2) => tag2.default && tag2.test?.test(value)) ?? schema[
|
|
4909
|
+
const compat = schema.compat.find((tag2) => tag2.default && tag2.test?.test(value)) ?? schema[identity2.SCALAR];
|
|
4910
4910
|
if (tag.tag !== compat.tag) {
|
|
4911
4911
|
const ts = directives.tagString(tag.tag);
|
|
4912
4912
|
const cs = directives.tagString(compat.tag);
|
|
@@ -4955,7 +4955,7 @@ var require_compose_node = __commonJS({
|
|
|
4955
4955
|
"node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/compose/compose-node.js"(exports) {
|
|
4956
4956
|
"use strict";
|
|
4957
4957
|
var Alias = require_Alias();
|
|
4958
|
-
var
|
|
4958
|
+
var identity2 = require_identity();
|
|
4959
4959
|
var composeCollection = require_compose_collection();
|
|
4960
4960
|
var composeScalar = require_compose_scalar();
|
|
4961
4961
|
var resolveEnd = require_resolve_end();
|
|
@@ -5001,7 +5001,7 @@ var require_compose_node = __commonJS({
|
|
|
5001
5001
|
node ?? (node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError));
|
|
5002
5002
|
if (anchor2 && node.anchor === "")
|
|
5003
5003
|
onError(anchor2, "BAD_ALIAS", "Anchor cannot be an empty string");
|
|
5004
|
-
if (atKey && ctx.options.stringKeys && (!
|
|
5004
|
+
if (atKey && ctx.options.stringKeys && (!identity2.isScalar(node) || typeof node.value !== "string" || node.tag && node.tag !== "tag:yaml.org,2002:str")) {
|
|
5005
5005
|
const msg = "With stringKeys, all keys must be strings";
|
|
5006
5006
|
onError(tag ?? token, "NON_STRING_KEY", msg);
|
|
5007
5007
|
}
|
|
@@ -5107,7 +5107,7 @@ var require_composer = __commonJS({
|
|
|
5107
5107
|
var directives = require_directives();
|
|
5108
5108
|
var Document = require_Document();
|
|
5109
5109
|
var errors = require_errors();
|
|
5110
|
-
var
|
|
5110
|
+
var identity2 = require_identity();
|
|
5111
5111
|
var composeDoc = require_compose_doc();
|
|
5112
5112
|
var resolveEnd = require_resolve_end();
|
|
5113
5113
|
function getErrorPos(src) {
|
|
@@ -5169,9 +5169,9 @@ var require_composer = __commonJS({
|
|
|
5169
5169
|
${comment}` : comment;
|
|
5170
5170
|
} else if (afterEmptyLine || doc.directives.docStart || !dc) {
|
|
5171
5171
|
doc.commentBefore = comment;
|
|
5172
|
-
} else if (
|
|
5172
|
+
} else if (identity2.isCollection(dc) && !dc.flow && dc.items.length > 0) {
|
|
5173
5173
|
let it = dc.items[0];
|
|
5174
|
-
if (
|
|
5174
|
+
if (identity2.isPair(it))
|
|
5175
5175
|
it = it.key;
|
|
5176
5176
|
const cb = it.commentBefore;
|
|
5177
5177
|
it.commentBefore = cb ? `${comment}
|
|
@@ -7219,7 +7219,7 @@ var require_public_api = __commonJS({
|
|
|
7219
7219
|
var Document = require_Document();
|
|
7220
7220
|
var errors = require_errors();
|
|
7221
7221
|
var log = require_log();
|
|
7222
|
-
var
|
|
7222
|
+
var identity2 = require_identity();
|
|
7223
7223
|
var lineCounter = require_line_counter();
|
|
7224
7224
|
var parser = require_parser();
|
|
7225
7225
|
function parseOptions(options) {
|
|
@@ -7297,7 +7297,7 @@ var require_public_api = __commonJS({
|
|
|
7297
7297
|
if (!keepUndefined)
|
|
7298
7298
|
return void 0;
|
|
7299
7299
|
}
|
|
7300
|
-
if (
|
|
7300
|
+
if (identity2.isDocument(value) && !_replacer)
|
|
7301
7301
|
return value.toString(options);
|
|
7302
7302
|
return new Document.Document(value, _replacer, options).toString(options);
|
|
7303
7303
|
}
|
|
@@ -7317,7 +7317,7 @@ var require_dist = __commonJS({
|
|
|
7317
7317
|
var Schema = require_Schema();
|
|
7318
7318
|
var errors = require_errors();
|
|
7319
7319
|
var Alias = require_Alias();
|
|
7320
|
-
var
|
|
7320
|
+
var identity2 = require_identity();
|
|
7321
7321
|
var Pair = require_Pair();
|
|
7322
7322
|
var Scalar = require_Scalar();
|
|
7323
7323
|
var YAMLMap = require_YAMLMap();
|
|
@@ -7335,14 +7335,14 @@ var require_dist = __commonJS({
|
|
|
7335
7335
|
exports.YAMLParseError = errors.YAMLParseError;
|
|
7336
7336
|
exports.YAMLWarning = errors.YAMLWarning;
|
|
7337
7337
|
exports.Alias = Alias.Alias;
|
|
7338
|
-
exports.isAlias =
|
|
7339
|
-
exports.isCollection =
|
|
7340
|
-
exports.isDocument =
|
|
7341
|
-
exports.isMap =
|
|
7342
|
-
exports.isNode =
|
|
7343
|
-
exports.isPair =
|
|
7344
|
-
exports.isScalar =
|
|
7345
|
-
exports.isSeq =
|
|
7338
|
+
exports.isAlias = identity2.isAlias;
|
|
7339
|
+
exports.isCollection = identity2.isCollection;
|
|
7340
|
+
exports.isDocument = identity2.isDocument;
|
|
7341
|
+
exports.isMap = identity2.isMap;
|
|
7342
|
+
exports.isNode = identity2.isNode;
|
|
7343
|
+
exports.isPair = identity2.isPair;
|
|
7344
|
+
exports.isScalar = identity2.isScalar;
|
|
7345
|
+
exports.isSeq = identity2.isSeq;
|
|
7346
7346
|
exports.Pair = Pair.Pair;
|
|
7347
7347
|
exports.Scalar = Scalar.Scalar;
|
|
7348
7348
|
exports.YAMLMap = YAMLMap.YAMLMap;
|
|
@@ -7363,11 +7363,79 @@ var require_dist = __commonJS({
|
|
|
7363
7363
|
// src/core/state/state.ts
|
|
7364
7364
|
import { createHash } from "node:crypto";
|
|
7365
7365
|
import { homedir } from "node:os";
|
|
7366
|
-
import { join, dirname, basename } from "node:path";
|
|
7367
|
-
import { existsSync, realpathSync, mkdirSync, writeFileSync, unlinkSync } from "node:fs";
|
|
7366
|
+
import { join as join2, dirname, basename } from "node:path";
|
|
7367
|
+
import { existsSync, realpathSync, mkdirSync, writeFileSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
7368
|
+
|
|
7369
|
+
// src/helpers/isRecord.ts
|
|
7370
|
+
function isRecord(value) {
|
|
7371
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7372
|
+
}
|
|
7373
|
+
|
|
7374
|
+
// src/helpers/readFileOrEmpty.ts
|
|
7375
|
+
import { readFileSync } from "node:fs";
|
|
7376
|
+
function readFileOrEmpty(path) {
|
|
7377
|
+
try {
|
|
7378
|
+
return readFileSync(path, "utf-8");
|
|
7379
|
+
} catch {
|
|
7380
|
+
return "";
|
|
7381
|
+
}
|
|
7382
|
+
}
|
|
7383
|
+
|
|
7384
|
+
// src/helpers/readPayload.ts
|
|
7385
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
7386
|
+
function readPayload() {
|
|
7387
|
+
const text = readFileSync2(0, "utf-8");
|
|
7388
|
+
return JSON.parse(text);
|
|
7389
|
+
}
|
|
7390
|
+
|
|
7391
|
+
// src/helpers/removeQuietly.ts
|
|
7392
|
+
import { unlinkSync } from "node:fs";
|
|
7393
|
+
function removeQuietly(path) {
|
|
7394
|
+
try {
|
|
7395
|
+
unlinkSync(path);
|
|
7396
|
+
} catch {
|
|
7397
|
+
}
|
|
7398
|
+
}
|
|
7399
|
+
|
|
7400
|
+
// src/helpers/resolvesOnPath.ts
|
|
7401
|
+
import { spawnSync } from "node:child_process";
|
|
7402
|
+
var defaultResolvesOnPath = (command) => {
|
|
7403
|
+
const result = spawnSync("which", [command], { stdio: "ignore" });
|
|
7404
|
+
return result.status === 0;
|
|
7405
|
+
};
|
|
7406
|
+
|
|
7407
|
+
// src/helpers/resultFilePath.ts
|
|
7408
|
+
import { randomBytes } from "node:crypto";
|
|
7409
|
+
import { tmpdir } from "node:os";
|
|
7410
|
+
import { join } from "node:path";
|
|
7411
|
+
var NAME_BYTES = 6;
|
|
7412
|
+
function resultFilePath() {
|
|
7413
|
+
const name = `pair-result-${randomBytes(NAME_BYTES).toString("hex")}.json`;
|
|
7414
|
+
return join(tmpdir(), name);
|
|
7415
|
+
}
|
|
7416
|
+
|
|
7417
|
+
// src/helpers/spawn.ts
|
|
7418
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
7419
|
+
var defaultSpawn = (command, args) => {
|
|
7420
|
+
const result = spawnSync2(command, args, { stdio: ["ignore", "ignore", "pipe"] });
|
|
7421
|
+
const stderr = result.stderr ? result.stderr.toString("utf-8") : result.error?.message ?? "";
|
|
7422
|
+
return { status: result.status, stderr };
|
|
7423
|
+
};
|
|
7424
|
+
|
|
7425
|
+
// src/helpers/splitLines.ts
|
|
7426
|
+
function splitLines(text) {
|
|
7427
|
+
const lines = text.split("\n");
|
|
7428
|
+
const last = lines.at(-1);
|
|
7429
|
+
if (last === "") {
|
|
7430
|
+
lines.pop();
|
|
7431
|
+
}
|
|
7432
|
+
return lines;
|
|
7433
|
+
}
|
|
7434
|
+
|
|
7435
|
+
// src/core/state/state.ts
|
|
7368
7436
|
function stateDir() {
|
|
7369
|
-
const base = process.env["XDG_STATE_HOME"] ||
|
|
7370
|
-
return
|
|
7437
|
+
const base = process.env["XDG_STATE_HOME"] || join2(homedir(), ".local", "state");
|
|
7438
|
+
return join2(base, "pair-mode");
|
|
7371
7439
|
}
|
|
7372
7440
|
function realpathLenient(path) {
|
|
7373
7441
|
try {
|
|
@@ -7377,7 +7445,7 @@ function realpathLenient(path) {
|
|
|
7377
7445
|
if (parent === path) {
|
|
7378
7446
|
return path;
|
|
7379
7447
|
}
|
|
7380
|
-
return
|
|
7448
|
+
return join2(realpathLenient(parent), basename(path));
|
|
7381
7449
|
}
|
|
7382
7450
|
}
|
|
7383
7451
|
var DIGEST_LENGTH = 16;
|
|
@@ -7386,13 +7454,13 @@ function digestFor(directory) {
|
|
|
7386
7454
|
return createHash("sha1").update(real).digest("hex").slice(0, DIGEST_LENGTH);
|
|
7387
7455
|
}
|
|
7388
7456
|
function flagPath(directory) {
|
|
7389
|
-
return
|
|
7457
|
+
return join2(stateDir(), `${digestFor(directory)}.on`);
|
|
7390
7458
|
}
|
|
7391
7459
|
function sessionsDir() {
|
|
7392
|
-
return
|
|
7460
|
+
return join2(stateDir(), "sessions");
|
|
7393
7461
|
}
|
|
7394
7462
|
function sessionSocketPath(directory) {
|
|
7395
|
-
return
|
|
7463
|
+
return join2(sessionsDir(), `${digestFor(directory)}.sock`);
|
|
7396
7464
|
}
|
|
7397
7465
|
function findSessionSocket(filePath) {
|
|
7398
7466
|
let current = dirname(realpathLenient(filePath));
|
|
@@ -7408,7 +7476,13 @@ function findSessionSocket(filePath) {
|
|
|
7408
7476
|
current = parent;
|
|
7409
7477
|
}
|
|
7410
7478
|
}
|
|
7411
|
-
function
|
|
7479
|
+
function sessionFlagState(key) {
|
|
7480
|
+
if (existsSync(sessionKeyOptOutPath(key))) {
|
|
7481
|
+
return "off";
|
|
7482
|
+
}
|
|
7483
|
+
return existsSync(sessionKeyFlagPath(key)) ? "on" : "unset";
|
|
7484
|
+
}
|
|
7485
|
+
function directoryEnabled(filePath) {
|
|
7412
7486
|
let current = dirname(realpathLenient(filePath));
|
|
7413
7487
|
while (true) {
|
|
7414
7488
|
if (existsSync(flagPath(current))) {
|
|
@@ -7421,10 +7495,34 @@ function isEnabled(filePath) {
|
|
|
7421
7495
|
current = parent;
|
|
7422
7496
|
}
|
|
7423
7497
|
}
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7498
|
+
function isEnabled(filePath, key) {
|
|
7499
|
+
if (key !== void 0) {
|
|
7500
|
+
const state = sessionFlagState(key);
|
|
7501
|
+
if (state !== "unset") {
|
|
7502
|
+
return state === "on";
|
|
7503
|
+
}
|
|
7504
|
+
}
|
|
7505
|
+
return directoryEnabled(filePath);
|
|
7506
|
+
}
|
|
7507
|
+
var SESSION_KEY_LENGTH = 8;
|
|
7508
|
+
function sessionKey(agentSessionId) {
|
|
7509
|
+
const digest = createHash("sha1").update(agentSessionId).digest("hex");
|
|
7510
|
+
return `s-${digest.slice(0, SESSION_KEY_LENGTH)}`;
|
|
7511
|
+
}
|
|
7512
|
+
function keyFor(agentSessionId) {
|
|
7513
|
+
return agentSessionId === void 0 || agentSessionId === "" ? void 0 : sessionKey(agentSessionId);
|
|
7514
|
+
}
|
|
7515
|
+
function sessionKeyPath(key, extension) {
|
|
7516
|
+
return join2(sessionsDir(), `${key}${extension}`);
|
|
7517
|
+
}
|
|
7518
|
+
function sessionKeySocketPath(key) {
|
|
7519
|
+
return sessionKeyPath(key, ".sock");
|
|
7520
|
+
}
|
|
7521
|
+
function sessionKeyFlagPath(key) {
|
|
7522
|
+
return sessionKeyPath(key, ".on");
|
|
7523
|
+
}
|
|
7524
|
+
function sessionKeyOptOutPath(key) {
|
|
7525
|
+
return sessionKeyPath(key, ".off");
|
|
7428
7526
|
}
|
|
7429
7527
|
|
|
7430
7528
|
// src/core/simulate/simulate.ts
|
|
@@ -7471,7 +7569,7 @@ function applyEdit(text, edit) {
|
|
|
7471
7569
|
}
|
|
7472
7570
|
return replaceFirst(text, old, next);
|
|
7473
7571
|
}
|
|
7474
|
-
function simulate(tool, input, readFile) {
|
|
7572
|
+
function simulate(tool, input, readFile, sessionId) {
|
|
7475
7573
|
if (!isRecord(input)) {
|
|
7476
7574
|
return null;
|
|
7477
7575
|
}
|
|
@@ -7483,7 +7581,7 @@ function simulate(tool, input, readFile) {
|
|
|
7483
7581
|
const content = input["content"];
|
|
7484
7582
|
const after = typeof content === "string" ? content : "";
|
|
7485
7583
|
const before = readFile(filePath);
|
|
7486
|
-
return { tool, filePath, before, after };
|
|
7584
|
+
return { tool, filePath, before, after, sessionId };
|
|
7487
7585
|
}
|
|
7488
7586
|
if (tool === "Edit" || tool === "MultiEdit") {
|
|
7489
7587
|
const editsRaw = input["edits"];
|
|
@@ -7498,7 +7596,7 @@ function simulate(tool, input, readFile) {
|
|
|
7498
7596
|
if (after === null) {
|
|
7499
7597
|
return null;
|
|
7500
7598
|
}
|
|
7501
|
-
return { tool, filePath, before, after };
|
|
7599
|
+
return { tool, filePath, before, after, sessionId };
|
|
7502
7600
|
}
|
|
7503
7601
|
return null;
|
|
7504
7602
|
}
|
|
@@ -7929,16 +8027,6 @@ import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, rmSync
|
|
|
7929
8027
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
7930
8028
|
import { join as join8 } from "node:path";
|
|
7931
8029
|
|
|
7932
|
-
// src/helpers/splitLines.ts
|
|
7933
|
-
function splitLines(text) {
|
|
7934
|
-
const lines = text.split("\n");
|
|
7935
|
-
const last = lines.at(-1);
|
|
7936
|
-
if (last === "") {
|
|
7937
|
-
lines.pop();
|
|
7938
|
-
}
|
|
7939
|
-
return lines;
|
|
7940
|
-
}
|
|
7941
|
-
|
|
7942
8030
|
// src/core/render/render.ts
|
|
7943
8031
|
var HEADER_LEAD = [
|
|
7944
8032
|
"# PAIR MODE. Left pane is the current file. Right pane is the proposal.",
|
|
@@ -7977,56 +8065,299 @@ function renderInline(input) {
|
|
|
7977
8065
|
// src/editors/micro.ts
|
|
7978
8066
|
var import_yaml = __toESM(require_dist(), 1);
|
|
7979
8067
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
7980
|
-
import { join as
|
|
8068
|
+
import { join as join4 } from "node:path";
|
|
7981
8069
|
|
|
7982
8070
|
// src/editors/languages.ts
|
|
7983
|
-
import {
|
|
7984
|
-
|
|
8071
|
+
import { openSync, readSync, closeSync } from "node:fs";
|
|
8072
|
+
import { basename as basename2, extname } from "node:path";
|
|
8073
|
+
var EXTENSIONS = {
|
|
7985
8074
|
".go": "go",
|
|
7986
8075
|
".rb": "ruby",
|
|
7987
8076
|
".rake": "ruby",
|
|
8077
|
+
".gemspec": "ruby",
|
|
8078
|
+
".ru": "ruby",
|
|
8079
|
+
".erb": "erb",
|
|
8080
|
+
".haml": "haml",
|
|
7988
8081
|
".ts": "typescript",
|
|
7989
|
-
".
|
|
8082
|
+
".mts": "typescript",
|
|
8083
|
+
".cts": "typescript",
|
|
8084
|
+
".tsx": "tsx",
|
|
7990
8085
|
".js": "javascript",
|
|
7991
|
-
".jsx": "javascript",
|
|
7992
8086
|
".mjs": "javascript",
|
|
7993
|
-
".
|
|
8087
|
+
".cjs": "javascript",
|
|
8088
|
+
".jsx": "jsx",
|
|
8089
|
+
".vue": "vue",
|
|
8090
|
+
".svelte": "svelte",
|
|
8091
|
+
".astro": "astro",
|
|
8092
|
+
".py": "python",
|
|
8093
|
+
".pyi": "python",
|
|
7994
8094
|
".ex": "elixir",
|
|
7995
8095
|
".exs": "elixir",
|
|
8096
|
+
".heex": "elixir",
|
|
8097
|
+
".erl": "erlang",
|
|
8098
|
+
".hrl": "erlang",
|
|
7996
8099
|
".rs": "rust",
|
|
7997
|
-
".sh": "
|
|
7998
|
-
".bash": "
|
|
7999
|
-
".
|
|
8100
|
+
".sh": "shellscript",
|
|
8101
|
+
".bash": "shellscript",
|
|
8102
|
+
".ksh": "shellscript",
|
|
8000
8103
|
".zsh": "zsh",
|
|
8104
|
+
".fish": "fish",
|
|
8105
|
+
".ps1": "powershell",
|
|
8106
|
+
".psm1": "powershell",
|
|
8107
|
+
".bat": "bat",
|
|
8108
|
+
".cmd": "bat",
|
|
8001
8109
|
".sql": "sql",
|
|
8002
8110
|
".json": "json",
|
|
8111
|
+
".jsonc": "jsonc",
|
|
8112
|
+
".json5": "json5",
|
|
8003
8113
|
".tf": "terraform",
|
|
8114
|
+
".tfvars": "terraform",
|
|
8115
|
+
".hcl": "hcl",
|
|
8004
8116
|
".proto": "proto",
|
|
8005
|
-
".dockerfile": "
|
|
8117
|
+
".dockerfile": "docker",
|
|
8006
8118
|
".toml": "toml",
|
|
8007
8119
|
".yaml": "yaml",
|
|
8008
8120
|
".yml": "yaml",
|
|
8121
|
+
".ini": "ini",
|
|
8122
|
+
".cfg": "ini",
|
|
8123
|
+
".properties": "properties",
|
|
8124
|
+
".env": "dotenv",
|
|
8009
8125
|
".md": "markdown",
|
|
8126
|
+
".markdown": "markdown",
|
|
8127
|
+
".mdx": "mdx",
|
|
8010
8128
|
".css": "css",
|
|
8129
|
+
".scss": "scss",
|
|
8130
|
+
".sass": "sass",
|
|
8131
|
+
".less": "less",
|
|
8132
|
+
".styl": "stylus",
|
|
8011
8133
|
".html": "html",
|
|
8012
|
-
".
|
|
8134
|
+
".htm": "html",
|
|
8135
|
+
".xml": "xml",
|
|
8136
|
+
".xsl": "xml",
|
|
8137
|
+
".svg": "xml",
|
|
8013
8138
|
".lua": "lua",
|
|
8014
8139
|
".c": "c",
|
|
8015
|
-
".h": "c"
|
|
8140
|
+
".h": "c",
|
|
8141
|
+
".cc": "cpp",
|
|
8142
|
+
".cpp": "cpp",
|
|
8143
|
+
".cxx": "cpp",
|
|
8144
|
+
".hpp": "cpp",
|
|
8145
|
+
".hh": "cpp",
|
|
8146
|
+
".cs": "csharp",
|
|
8147
|
+
".java": "java",
|
|
8148
|
+
".kt": "kotlin",
|
|
8149
|
+
".kts": "kotlin",
|
|
8150
|
+
".swift": "swift",
|
|
8151
|
+
".m": "objective-c",
|
|
8152
|
+
".mm": "objective-c",
|
|
8153
|
+
".php": "php",
|
|
8154
|
+
".pl": "perl",
|
|
8155
|
+
".pm": "perl",
|
|
8156
|
+
".scala": "scala",
|
|
8157
|
+
".sc": "scala",
|
|
8158
|
+
".clj": "clojure",
|
|
8159
|
+
".cljs": "clojure",
|
|
8160
|
+
".cljc": "clojure",
|
|
8161
|
+
".hs": "haskell",
|
|
8162
|
+
".nix": "nix",
|
|
8163
|
+
".r": "r",
|
|
8164
|
+
".jl": "julia",
|
|
8165
|
+
".zig": "zig",
|
|
8166
|
+
".nim": "nim",
|
|
8167
|
+
".dart": "dart",
|
|
8168
|
+
".groovy": "groovy",
|
|
8169
|
+
".gradle": "groovy",
|
|
8170
|
+
".cr": "crystal",
|
|
8171
|
+
".ml": "ocaml",
|
|
8172
|
+
".mli": "ocaml",
|
|
8173
|
+
".fs": "fsharp",
|
|
8174
|
+
".fsx": "fsharp",
|
|
8175
|
+
".elm": "elm",
|
|
8176
|
+
".graphql": "graphql",
|
|
8177
|
+
".gql": "graphql",
|
|
8178
|
+
".prisma": "prisma",
|
|
8179
|
+
".sol": "solidity",
|
|
8180
|
+
".vim": "viml",
|
|
8181
|
+
".diff": "diff",
|
|
8182
|
+
".patch": "diff",
|
|
8183
|
+
".tex": "latex",
|
|
8184
|
+
".wgsl": "wgsl",
|
|
8185
|
+
".glsl": "glsl",
|
|
8186
|
+
".cue": "cue"
|
|
8187
|
+
};
|
|
8188
|
+
var FILENAMES = {
|
|
8189
|
+
gemfile: "ruby",
|
|
8190
|
+
rakefile: "ruby",
|
|
8191
|
+
capfile: "ruby",
|
|
8192
|
+
vagrantfile: "ruby",
|
|
8193
|
+
guardfile: "ruby",
|
|
8194
|
+
podfile: "ruby",
|
|
8195
|
+
fastfile: "ruby",
|
|
8196
|
+
appfile: "ruby",
|
|
8197
|
+
brewfile: "ruby",
|
|
8198
|
+
"config.ru": "ruby",
|
|
8199
|
+
dockerfile: "docker",
|
|
8200
|
+
containerfile: "docker",
|
|
8201
|
+
makefile: "make",
|
|
8202
|
+
gnumakefile: "make",
|
|
8203
|
+
"cmakelists.txt": "cmake",
|
|
8204
|
+
"cargo.lock": "toml",
|
|
8205
|
+
"gemfile.lock": "toml",
|
|
8206
|
+
".babelrc": "json",
|
|
8207
|
+
".eslintrc": "json",
|
|
8208
|
+
".prettierrc": "json",
|
|
8209
|
+
".env": "dotenv",
|
|
8210
|
+
".gitconfig": "ini",
|
|
8211
|
+
".editorconfig": "ini",
|
|
8212
|
+
"nginx.conf": "nginx",
|
|
8213
|
+
"pnpm-workspace.yaml": "yaml"
|
|
8214
|
+
};
|
|
8215
|
+
var SHEBANGS = [
|
|
8216
|
+
{ pattern: /^#!.*\/(env\s+)?ruby(\s|$)/, id: "ruby" },
|
|
8217
|
+
{ pattern: /^#!.*\/(env\s+)?python[\d.]*(\s|$)/, id: "python" },
|
|
8218
|
+
{ pattern: /^#!.*\/(env\s+)?(node|bun|deno)(\s|$)/, id: "javascript" },
|
|
8219
|
+
{ pattern: /^#!.*\/(env\s+)?(bash|sh|ksh|dash)(\s|$)/, id: "shellscript" },
|
|
8220
|
+
{ pattern: /^#!.*\/(env\s+)?zsh(\s|$)/, id: "zsh" },
|
|
8221
|
+
{ pattern: /^#!.*\/(env\s+)?fish(\s|$)/, id: "fish" },
|
|
8222
|
+
{ pattern: /^#!.*\/(env\s+)?perl(\s|$)/, id: "perl" },
|
|
8223
|
+
{ pattern: /^#!.*\/(env\s+)?php(\s|$)/, id: "php" },
|
|
8224
|
+
{ pattern: /^#!.*\/(env\s+)?(elixir|iex)(\s|$)/, id: "elixir" },
|
|
8225
|
+
{ pattern: /^#!.*\/(env\s+)?lua(\s|$)/, id: "lua" },
|
|
8226
|
+
{ pattern: /^#!.*\/(env\s+)?Rscript(\s|$)/, id: "r" },
|
|
8227
|
+
{ pattern: /^#!.*\/(env\s+)?pwsh(\s|$)/, id: "powershell" }
|
|
8228
|
+
];
|
|
8229
|
+
var FIRST_LINE_BYTES = 256;
|
|
8230
|
+
function firstLine(sourcePath) {
|
|
8231
|
+
let handle = null;
|
|
8232
|
+
try {
|
|
8233
|
+
handle = openSync(sourcePath, "r");
|
|
8234
|
+
const buffer = Buffer.alloc(FIRST_LINE_BYTES);
|
|
8235
|
+
const read = readSync(handle, buffer, 0, FIRST_LINE_BYTES, 0);
|
|
8236
|
+
const text = buffer.toString("utf-8", 0, read);
|
|
8237
|
+
const newline = text.indexOf("\n");
|
|
8238
|
+
return newline === -1 ? text : text.slice(0, newline);
|
|
8239
|
+
} catch {
|
|
8240
|
+
return null;
|
|
8241
|
+
} finally {
|
|
8242
|
+
if (handle !== null) {
|
|
8243
|
+
try {
|
|
8244
|
+
closeSync(handle);
|
|
8245
|
+
} catch {
|
|
8246
|
+
}
|
|
8247
|
+
}
|
|
8248
|
+
}
|
|
8249
|
+
}
|
|
8250
|
+
function shebangLanguage(sourcePath) {
|
|
8251
|
+
const line = firstLine(sourcePath);
|
|
8252
|
+
if (line === null || !line.startsWith("#!")) {
|
|
8253
|
+
return null;
|
|
8254
|
+
}
|
|
8255
|
+
return SHEBANGS.find((rule) => rule.pattern.test(line))?.id ?? null;
|
|
8256
|
+
}
|
|
8257
|
+
function detectLanguage(sourcePath) {
|
|
8258
|
+
const name = basename2(sourcePath).toLowerCase();
|
|
8259
|
+
const ext = extname(name);
|
|
8260
|
+
if (ext !== "" && EXTENSIONS[ext] !== void 0) {
|
|
8261
|
+
return EXTENSIONS[ext];
|
|
8262
|
+
}
|
|
8263
|
+
if (FILENAMES[name] !== void 0) {
|
|
8264
|
+
return FILENAMES[name];
|
|
8265
|
+
}
|
|
8266
|
+
return shebangLanguage(sourcePath);
|
|
8267
|
+
}
|
|
8268
|
+
var MICRO_SYNTAX = {
|
|
8269
|
+
c: "c",
|
|
8270
|
+
clojure: "clojure",
|
|
8271
|
+
cmake: "cmake",
|
|
8272
|
+
crystal: "crystal",
|
|
8273
|
+
csharp: "csharp",
|
|
8274
|
+
css: "css",
|
|
8275
|
+
dart: "dart",
|
|
8276
|
+
docker: "dockerfile",
|
|
8277
|
+
elixir: "elixir",
|
|
8278
|
+
elm: "elm",
|
|
8279
|
+
erb: "erb",
|
|
8280
|
+
erlang: "erlang",
|
|
8281
|
+
fish: "fish",
|
|
8282
|
+
fsharp: "fsharp",
|
|
8283
|
+
go: "go",
|
|
8284
|
+
graphql: "graphql",
|
|
8285
|
+
groovy: "groovy",
|
|
8286
|
+
haml: "haml",
|
|
8287
|
+
haskell: "haskell",
|
|
8288
|
+
html: "html",
|
|
8289
|
+
ini: "ini",
|
|
8290
|
+
java: "java",
|
|
8291
|
+
javascript: "javascript",
|
|
8292
|
+
json: "json",
|
|
8293
|
+
julia: "julia",
|
|
8294
|
+
kotlin: "kotlin",
|
|
8295
|
+
lua: "lua",
|
|
8296
|
+
make: "makefile",
|
|
8297
|
+
markdown: "markdown",
|
|
8298
|
+
nginx: "nginx",
|
|
8299
|
+
nim: "nim",
|
|
8300
|
+
nix: "nix",
|
|
8301
|
+
"objective-c": "objc",
|
|
8302
|
+
ocaml: "ocaml",
|
|
8303
|
+
perl: "perl",
|
|
8304
|
+
php: "php",
|
|
8305
|
+
proto: "proto",
|
|
8306
|
+
python: "python3",
|
|
8307
|
+
r: "r",
|
|
8308
|
+
ruby: "ruby",
|
|
8309
|
+
rust: "rust",
|
|
8310
|
+
scala: "scala",
|
|
8311
|
+
shellscript: "sh",
|
|
8312
|
+
sql: "sql",
|
|
8313
|
+
svelte: "svelte",
|
|
8314
|
+
swift: "swift",
|
|
8315
|
+
terraform: "terraform",
|
|
8316
|
+
toml: "toml",
|
|
8317
|
+
typescript: "typescript",
|
|
8318
|
+
vue: "vue",
|
|
8319
|
+
xml: "xml",
|
|
8320
|
+
yaml: "yaml",
|
|
8321
|
+
zig: "zig",
|
|
8322
|
+
zsh: "zsh"
|
|
8323
|
+
};
|
|
8324
|
+
var VIM_FILETYPES = {
|
|
8325
|
+
shellscript: "sh",
|
|
8326
|
+
docker: "dockerfile",
|
|
8327
|
+
csharp: "cs",
|
|
8328
|
+
"objective-c": "objc",
|
|
8329
|
+
bat: "dosbatch",
|
|
8330
|
+
viml: "vim",
|
|
8331
|
+
mdx: "markdown",
|
|
8332
|
+
jsx: "javascriptreact",
|
|
8333
|
+
tsx: "typescriptreact",
|
|
8334
|
+
dotenv: "sh",
|
|
8335
|
+
properties: "jproperties",
|
|
8336
|
+
stylus: "stylus"
|
|
8016
8337
|
};
|
|
8017
|
-
function
|
|
8018
|
-
const
|
|
8019
|
-
|
|
8338
|
+
function microSyntaxName(sourcePath) {
|
|
8339
|
+
const id = detectLanguage(sourcePath);
|
|
8340
|
+
if (id === null) {
|
|
8341
|
+
return null;
|
|
8342
|
+
}
|
|
8343
|
+
return MICRO_SYNTAX[id] ?? null;
|
|
8344
|
+
}
|
|
8345
|
+
function vimFiletype(sourcePath) {
|
|
8346
|
+
const id = detectLanguage(sourcePath);
|
|
8347
|
+
if (id === null) {
|
|
8348
|
+
return null;
|
|
8349
|
+
}
|
|
8350
|
+
return VIM_FILETYPES[id] ?? id;
|
|
8020
8351
|
}
|
|
8021
8352
|
|
|
8022
8353
|
// src/editors/syntax-cache.ts
|
|
8023
|
-
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
8024
|
-
import { dirname as dirname2, join as
|
|
8354
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
8355
|
+
import { dirname as dirname2, join as join3 } from "node:path";
|
|
8025
8356
|
import { fileURLToPath } from "node:url";
|
|
8026
8357
|
function defaultAssetsDir() {
|
|
8027
8358
|
let dir = dirname2(fileURLToPath(import.meta.url));
|
|
8028
8359
|
while (true) {
|
|
8029
|
-
const candidate =
|
|
8360
|
+
const candidate = join3(dir, "assets", "syntax");
|
|
8030
8361
|
if (existsSync2(candidate)) {
|
|
8031
8362
|
return candidate;
|
|
8032
8363
|
}
|
|
@@ -8041,20 +8372,13 @@ function syntaxSource(lang, assetsDir = defaultAssetsDir()) {
|
|
|
8041
8372
|
if (assetsDir === null) {
|
|
8042
8373
|
return null;
|
|
8043
8374
|
}
|
|
8044
|
-
const path =
|
|
8375
|
+
const path = join3(assetsDir, `${lang}.yaml`);
|
|
8045
8376
|
if (!existsSync2(path)) {
|
|
8046
8377
|
return null;
|
|
8047
8378
|
}
|
|
8048
|
-
return
|
|
8379
|
+
return readFileSync3(path, "utf-8");
|
|
8049
8380
|
}
|
|
8050
8381
|
|
|
8051
|
-
// src/helpers/resolvesOnPath.ts
|
|
8052
|
-
import { spawnSync } from "node:child_process";
|
|
8053
|
-
var defaultResolvesOnPath = (command) => {
|
|
8054
|
-
const result = spawnSync("which", [command], { stdio: "ignore" });
|
|
8055
|
-
return result.status === 0;
|
|
8056
|
-
};
|
|
8057
|
-
|
|
8058
8382
|
// src/editors/micro.ts
|
|
8059
8383
|
var MICRO_BINDINGS = {
|
|
8060
8384
|
F2: "QuitAll",
|
|
@@ -8085,7 +8409,7 @@ function bandRules() {
|
|
|
8085
8409
|
];
|
|
8086
8410
|
}
|
|
8087
8411
|
function writeColorScheme(configDir, theme) {
|
|
8088
|
-
const dir =
|
|
8412
|
+
const dir = join4(configDir, "colorschemes");
|
|
8089
8413
|
mkdirSync2(dir, { recursive: true });
|
|
8090
8414
|
const text = `include "monokai"
|
|
8091
8415
|
|
|
@@ -8093,7 +8417,7 @@ color-link pairadd "#d7ffd7,${theme.add}"
|
|
|
8093
8417
|
color-link pairdel "#ffd7d7,${theme.del}"
|
|
8094
8418
|
color-link pairskip "#6a6a6a,${theme.fold}"
|
|
8095
8419
|
`;
|
|
8096
|
-
writeFileSync2(
|
|
8420
|
+
writeFileSync2(join4(dir, "pair.micro"), text, "utf-8");
|
|
8097
8421
|
}
|
|
8098
8422
|
function syntaxText(lang, source) {
|
|
8099
8423
|
const parsed = (0, import_yaml.parse)(source);
|
|
@@ -8109,7 +8433,7 @@ function syntaxText(lang, source) {
|
|
|
8109
8433
|
return (0, import_yaml.stringify)(file, { lineWidth: 0 });
|
|
8110
8434
|
}
|
|
8111
8435
|
function writeSyntax(configDir, sourcePath) {
|
|
8112
|
-
const lang =
|
|
8436
|
+
const lang = microSyntaxName(sourcePath);
|
|
8113
8437
|
if (lang === null) {
|
|
8114
8438
|
return;
|
|
8115
8439
|
}
|
|
@@ -8121,9 +8445,9 @@ function writeSyntax(configDir, sourcePath) {
|
|
|
8121
8445
|
if (text === null) {
|
|
8122
8446
|
return;
|
|
8123
8447
|
}
|
|
8124
|
-
const dir =
|
|
8448
|
+
const dir = join4(configDir, "syntax");
|
|
8125
8449
|
mkdirSync2(dir, { recursive: true });
|
|
8126
|
-
writeFileSync2(
|
|
8450
|
+
writeFileSync2(join4(dir, `pair-${lang}.yaml`), text, "utf-8");
|
|
8127
8451
|
}
|
|
8128
8452
|
function createMicroEditor(resolvesOnPath = defaultResolvesOnPath) {
|
|
8129
8453
|
return {
|
|
@@ -8136,7 +8460,7 @@ function createMicroEditor(resolvesOnPath = defaultResolvesOnPath) {
|
|
|
8136
8460
|
return ["# F3 moves between panes. Ctrl+W or F2 sends and closes."];
|
|
8137
8461
|
},
|
|
8138
8462
|
bufferSuffix(sourcePath) {
|
|
8139
|
-
const lang =
|
|
8463
|
+
const lang = microSyntaxName(sourcePath);
|
|
8140
8464
|
if (lang === null) {
|
|
8141
8465
|
return ".diff";
|
|
8142
8466
|
}
|
|
@@ -8145,12 +8469,12 @@ function createMicroEditor(resolvesOnPath = defaultResolvesOnPath) {
|
|
|
8145
8469
|
prepare(context) {
|
|
8146
8470
|
mkdirSync2(context.configDir, { recursive: true });
|
|
8147
8471
|
writeFileSync2(
|
|
8148
|
-
|
|
8472
|
+
join4(context.configDir, "bindings.json"),
|
|
8149
8473
|
JSON.stringify(MICRO_BINDINGS, null, 2),
|
|
8150
8474
|
"utf-8"
|
|
8151
8475
|
);
|
|
8152
8476
|
writeFileSync2(
|
|
8153
|
-
|
|
8477
|
+
join4(context.configDir, "settings.json"),
|
|
8154
8478
|
JSON.stringify(MICRO_SETTINGS, null, 2),
|
|
8155
8479
|
"utf-8"
|
|
8156
8480
|
);
|
|
@@ -8174,16 +8498,6 @@ function isHexColor(value) {
|
|
|
8174
8498
|
}
|
|
8175
8499
|
|
|
8176
8500
|
// src/editors/vim.ts
|
|
8177
|
-
var VIM_FILETYPE_OVERRIDES = {
|
|
8178
|
-
python3: "python"
|
|
8179
|
-
};
|
|
8180
|
-
function vimFiletype(sourcePath) {
|
|
8181
|
-
const lang = syntaxName(sourcePath);
|
|
8182
|
-
if (lang === null) {
|
|
8183
|
-
return null;
|
|
8184
|
-
}
|
|
8185
|
-
return VIM_FILETYPE_OVERRIDES[lang] ?? lang;
|
|
8186
|
-
}
|
|
8187
8501
|
function safeThemeColor(value) {
|
|
8188
8502
|
if (!isHexColor(value)) {
|
|
8189
8503
|
throw new Error(`invalid theme colour for vim highlight: ${value}`);
|
|
@@ -8238,7 +8552,7 @@ function vimEditor(name, resolvesOnPath = defaultResolvesOnPath) {
|
|
|
8238
8552
|
|
|
8239
8553
|
// src/editors/nano.ts
|
|
8240
8554
|
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
8241
|
-
import { join as
|
|
8555
|
+
import { join as join5 } from "node:path";
|
|
8242
8556
|
function safeThemeColor2(value) {
|
|
8243
8557
|
if (!isHexColor(value)) {
|
|
8244
8558
|
throw new Error(`invalid theme colour for nano rcfile: ${value}`);
|
|
@@ -8250,7 +8564,7 @@ function writeNanorc(configDir, theme) {
|
|
|
8250
8564
|
color ,${safeThemeColor2(theme.del)} "^\u258C\u258C-"
|
|
8251
8565
|
color ,${safeThemeColor2(theme.fold)} "^\u22EF"
|
|
8252
8566
|
`;
|
|
8253
|
-
const path =
|
|
8567
|
+
const path = join5(configDir, "pair.nanorc");
|
|
8254
8568
|
writeFileSync3(path, text, "utf-8");
|
|
8255
8569
|
return path;
|
|
8256
8570
|
}
|
|
@@ -8280,13 +8594,13 @@ function createNanoEditor(resolvesOnPath = defaultResolvesOnPath) {
|
|
|
8280
8594
|
|
|
8281
8595
|
// src/editors/pair.ts
|
|
8282
8596
|
import { existsSync as existsSync4 } from "node:fs";
|
|
8283
|
-
import { dirname as dirname4, extname as extname3, join as
|
|
8597
|
+
import { dirname as dirname4, extname as extname3, join as join7 } from "node:path";
|
|
8284
8598
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8285
8599
|
|
|
8286
8600
|
// src/core/config/config.ts
|
|
8287
8601
|
import { homedir as homedir2 } from "node:os";
|
|
8288
|
-
import { join as
|
|
8289
|
-
import { existsSync as existsSync3, readFileSync as
|
|
8602
|
+
import { join as join6, dirname as dirname3 } from "node:path";
|
|
8603
|
+
import { existsSync as existsSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync4, mkdirSync as mkdirSync4 } from "node:fs";
|
|
8290
8604
|
var EDITOR_NAMES = ["auto", "pair", "micro", "nvim", "vim", "nano"];
|
|
8291
8605
|
var MULTIPLEXER_NAMES = ["auto", "zellij", "tmux", "none"];
|
|
8292
8606
|
var TRANSPORT_NAMES = ["pane", "session"];
|
|
@@ -8312,8 +8626,8 @@ var DEFAULT_CONFIG = {
|
|
|
8312
8626
|
syntax: true
|
|
8313
8627
|
};
|
|
8314
8628
|
function configPath(homeDir) {
|
|
8315
|
-
const base = process.env["XDG_CONFIG_HOME"] ||
|
|
8316
|
-
return
|
|
8629
|
+
const base = process.env["XDG_CONFIG_HOME"] || join6(homeDir ?? homedir2(), ".config");
|
|
8630
|
+
return join6(base, "pair-mode", "config.json");
|
|
8317
8631
|
}
|
|
8318
8632
|
function isEditorName(value) {
|
|
8319
8633
|
return typeof value === "string" && EDITOR_NAMES.includes(value);
|
|
@@ -8585,7 +8899,7 @@ function loadConfig(path) {
|
|
|
8585
8899
|
}
|
|
8586
8900
|
let text;
|
|
8587
8901
|
try {
|
|
8588
|
-
text =
|
|
8902
|
+
text = readFileSync4(target, "utf-8");
|
|
8589
8903
|
} catch (error) {
|
|
8590
8904
|
const message = error instanceof Error ? error.message : String(error);
|
|
8591
8905
|
return {
|
|
@@ -8620,7 +8934,7 @@ function paintLayout(layout) {
|
|
|
8620
8934
|
// src/editors/pair.ts
|
|
8621
8935
|
var defaultResolveTuiEntry = () => {
|
|
8622
8936
|
const here = dirname4(fileURLToPath2(import.meta.url));
|
|
8623
|
-
return
|
|
8937
|
+
return join7(here, "pair-tui.js");
|
|
8624
8938
|
};
|
|
8625
8939
|
var defaultCheckBundleExists = existsSync4;
|
|
8626
8940
|
function createPairEditor(resolveTuiEntry = defaultResolveTuiEntry, checkBundleExists = defaultCheckBundleExists) {
|
|
@@ -8719,14 +9033,6 @@ function resolve(preference, resolvesOnPath = defaultResolvesOnPath, checkPairBu
|
|
|
8719
9033
|
return available ?? vimEditor("vim", resolvesOnPath);
|
|
8720
9034
|
}
|
|
8721
9035
|
|
|
8722
|
-
// src/helpers/spawn.ts
|
|
8723
|
-
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
8724
|
-
var defaultSpawn = (command, args) => {
|
|
8725
|
-
const result = spawnSync2(command, args, { stdio: ["ignore", "ignore", "pipe"] });
|
|
8726
|
-
const stderr = result.stderr ? result.stderr.toString("utf-8") : result.error?.message ?? "";
|
|
8727
|
-
return { status: result.status, stderr };
|
|
8728
|
-
};
|
|
8729
|
-
|
|
8730
9036
|
// src/multiplexers/zellij.ts
|
|
8731
9037
|
function createZellijMultiplexer(spawn = defaultSpawn, resolvesOnPath = defaultResolvesOnPath) {
|
|
8732
9038
|
return {
|
|
@@ -8756,7 +9062,7 @@ function createZellijMultiplexer(spawn = defaultSpawn, resolvesOnPath = defaultR
|
|
|
8756
9062
|
}
|
|
8757
9063
|
|
|
8758
9064
|
// src/multiplexers/tmux.ts
|
|
8759
|
-
import { randomBytes } from "node:crypto";
|
|
9065
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
8760
9066
|
var CHANNEL_BYTES = 8;
|
|
8761
9067
|
var SAFE_UNQUOTED = /^[A-Za-z0-9_\-./]+$/;
|
|
8762
9068
|
function shellQuote(value) {
|
|
@@ -8772,7 +9078,7 @@ function createTmuxMultiplexer(spawn = defaultSpawn, resolvesOnPath = defaultRes
|
|
|
8772
9078
|
return Boolean(process.env["TMUX"]) && resolvesOnPath("tmux");
|
|
8773
9079
|
},
|
|
8774
9080
|
run(argv, size) {
|
|
8775
|
-
const channel = `pair-${
|
|
9081
|
+
const channel = `pair-${randomBytes2(CHANNEL_BYTES).toString("hex")}`;
|
|
8776
9082
|
const inner = argv.map(shellQuote).join(" ");
|
|
8777
9083
|
const script = `stty -ixon 2>/dev/null; ${inner}; tmux wait-for -S ${channel}`;
|
|
8778
9084
|
const popup = spawn("tmux", [
|
|
@@ -8794,9 +9100,9 @@ function createTmuxMultiplexer(spawn = defaultSpawn, resolvesOnPath = defaultRes
|
|
|
8794
9100
|
}
|
|
8795
9101
|
|
|
8796
9102
|
// src/multiplexers/tty.ts
|
|
8797
|
-
import { openSync, closeSync } from "node:fs";
|
|
9103
|
+
import { openSync as openSync2, closeSync as closeSync2 } from "node:fs";
|
|
8798
9104
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
8799
|
-
var defaultOpen = () =>
|
|
9105
|
+
var defaultOpen = () => openSync2("/dev/tty", "r+");
|
|
8800
9106
|
var defaultRunner = (command, args, fd) => {
|
|
8801
9107
|
const result = spawnSync3(command, args, { stdio: [fd, fd, fd] });
|
|
8802
9108
|
const detail = result.status === 0 ? "" : String(result.error?.message ?? result.stderr ?? "");
|
|
@@ -8804,7 +9110,7 @@ var defaultRunner = (command, args, fd) => {
|
|
|
8804
9110
|
};
|
|
8805
9111
|
function closeQuietly(fd) {
|
|
8806
9112
|
try {
|
|
8807
|
-
|
|
9113
|
+
closeSync2(fd);
|
|
8808
9114
|
} catch {
|
|
8809
9115
|
}
|
|
8810
9116
|
}
|
|
@@ -8861,51 +9167,16 @@ function detect(preference, adapters = {}) {
|
|
|
8861
9167
|
return tty;
|
|
8862
9168
|
}
|
|
8863
9169
|
|
|
8864
|
-
// src/helpers/readFileOrEmpty.ts
|
|
8865
|
-
import { readFileSync as readFileSync3 } from "node:fs";
|
|
8866
|
-
function readFileOrEmpty(path) {
|
|
8867
|
-
try {
|
|
8868
|
-
return readFileSync3(path, "utf-8");
|
|
8869
|
-
} catch {
|
|
8870
|
-
return "";
|
|
8871
|
-
}
|
|
8872
|
-
}
|
|
8873
|
-
|
|
8874
|
-
// src/helpers/readPayload.ts
|
|
8875
|
-
import { readFileSync as readFileSync4 } from "node:fs";
|
|
8876
|
-
function readPayload() {
|
|
8877
|
-
const text = readFileSync4(0, "utf-8");
|
|
8878
|
-
return JSON.parse(text);
|
|
8879
|
-
}
|
|
8880
|
-
|
|
8881
|
-
// src/helpers/removeQuietly.ts
|
|
8882
|
-
import { unlinkSync as unlinkSync2 } from "node:fs";
|
|
8883
|
-
function removeQuietly(path) {
|
|
8884
|
-
try {
|
|
8885
|
-
unlinkSync2(path);
|
|
8886
|
-
} catch {
|
|
8887
|
-
}
|
|
8888
|
-
}
|
|
8889
|
-
|
|
8890
|
-
// src/helpers/resultFilePath.ts
|
|
8891
|
-
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
8892
|
-
import { tmpdir } from "node:os";
|
|
8893
|
-
import { join as join7 } from "node:path";
|
|
8894
|
-
var NAME_BYTES = 6;
|
|
8895
|
-
function resultFilePath() {
|
|
8896
|
-
const name = `pair-result-${randomBytes2(NAME_BYTES).toString("hex")}.json`;
|
|
8897
|
-
return join7(tmpdir(), name);
|
|
8898
|
-
}
|
|
8899
|
-
|
|
8900
9170
|
// src/transports/pane/pane.ts
|
|
8901
9171
|
var NAME_BYTES2 = 6;
|
|
9172
|
+
var OWNER_ONLY_FILE = 384;
|
|
8902
9173
|
function splitCommand(value) {
|
|
8903
9174
|
return value.trim().split(/\s+/).filter((part) => part !== "");
|
|
8904
9175
|
}
|
|
8905
9176
|
function tempFile(prefix, suffix, content) {
|
|
8906
9177
|
const name = `${prefix}${randomBytes3(NAME_BYTES2).toString("hex")}${suffix}`;
|
|
8907
9178
|
const path = join8(tmpdir2(), name);
|
|
8908
|
-
writeFileSync5(path, content, "utf-8");
|
|
9179
|
+
writeFileSync5(path, content, { encoding: "utf-8", mode: OWNER_ONLY_FILE, flag: "wx" });
|
|
8909
9180
|
return path;
|
|
8910
9181
|
}
|
|
8911
9182
|
function removeTreeQuietly(path) {
|
|
@@ -8995,6 +9266,7 @@ function createPaneTransport(deps = {}) {
|
|
|
8995
9266
|
|
|
8996
9267
|
// src/transports/session/client.ts
|
|
8997
9268
|
import { createConnection } from "node:net";
|
|
9269
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
8998
9270
|
|
|
8999
9271
|
// src/transports/session/wire.ts
|
|
9000
9272
|
var CLIENT_KINDS = ["tui", "web"];
|
|
@@ -9009,11 +9281,11 @@ function createLineReader() {
|
|
|
9009
9281
|
return parts.filter((line) => line.trim() !== "");
|
|
9010
9282
|
};
|
|
9011
9283
|
}
|
|
9012
|
-
function
|
|
9284
|
+
function isString2(value) {
|
|
9013
9285
|
return typeof value === "string";
|
|
9014
9286
|
}
|
|
9015
9287
|
function isClientKind(value) {
|
|
9016
|
-
return
|
|
9288
|
+
return isString2(value) && CLIENT_KINDS.includes(value);
|
|
9017
9289
|
}
|
|
9018
9290
|
function isQuestion(value) {
|
|
9019
9291
|
if (!isRecord(value)) {
|
|
@@ -9021,16 +9293,16 @@ function isQuestion(value) {
|
|
|
9021
9293
|
}
|
|
9022
9294
|
const line = value["line"];
|
|
9023
9295
|
const lineOk = line === null || typeof line === "number";
|
|
9024
|
-
return lineOk &&
|
|
9296
|
+
return lineOk && isString2(value["code"]) && isString2(value["text"]);
|
|
9025
9297
|
}
|
|
9026
9298
|
function isQuestionList(value) {
|
|
9027
9299
|
return Array.isArray(value) && value.every(isQuestion);
|
|
9028
9300
|
}
|
|
9029
9301
|
function toSubmit(raw) {
|
|
9030
|
-
if (!
|
|
9302
|
+
if (!isString2(raw["tool"]) || !isString2(raw["path"])) {
|
|
9031
9303
|
return null;
|
|
9032
9304
|
}
|
|
9033
|
-
if (!
|
|
9305
|
+
if (!isString2(raw["before"]) || !isString2(raw["after"])) {
|
|
9034
9306
|
return null;
|
|
9035
9307
|
}
|
|
9036
9308
|
return {
|
|
@@ -9046,7 +9318,7 @@ function toAttach(raw) {
|
|
|
9046
9318
|
}
|
|
9047
9319
|
function toReview(raw) {
|
|
9048
9320
|
const submit = toSubmit({ ...raw, type: "submit" });
|
|
9049
|
-
if (submit === null || !
|
|
9321
|
+
if (submit === null || !isString2(raw["id"])) {
|
|
9050
9322
|
return null;
|
|
9051
9323
|
}
|
|
9052
9324
|
return {
|
|
@@ -9059,13 +9331,31 @@ function toReview(raw) {
|
|
|
9059
9331
|
};
|
|
9060
9332
|
}
|
|
9061
9333
|
function toVerdict(raw) {
|
|
9062
|
-
if (!
|
|
9334
|
+
if (!isString2(raw["id"]) || !isQuestionList(raw["questions"])) {
|
|
9063
9335
|
return null;
|
|
9064
9336
|
}
|
|
9065
9337
|
return { type: "verdict", id: raw["id"], questions: raw["questions"] };
|
|
9066
9338
|
}
|
|
9067
9339
|
function toCancel(raw) {
|
|
9068
|
-
return
|
|
9340
|
+
return isString2(raw["id"]) ? { type: "cancel", id: raw["id"] } : null;
|
|
9341
|
+
}
|
|
9342
|
+
function isNumber(value) {
|
|
9343
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
9344
|
+
}
|
|
9345
|
+
function toState(raw) {
|
|
9346
|
+
const lastAttachAt = raw["lastAttachAt"];
|
|
9347
|
+
if (lastAttachAt !== null && !isString2(lastAttachAt)) {
|
|
9348
|
+
return null;
|
|
9349
|
+
}
|
|
9350
|
+
if (!isNumber(raw["clientCount"]) || !isNumber(raw["waitingDepth"])) {
|
|
9351
|
+
return null;
|
|
9352
|
+
}
|
|
9353
|
+
return {
|
|
9354
|
+
type: "state",
|
|
9355
|
+
clientCount: raw["clientCount"],
|
|
9356
|
+
waitingDepth: raw["waitingDepth"],
|
|
9357
|
+
lastAttachAt
|
|
9358
|
+
};
|
|
9069
9359
|
}
|
|
9070
9360
|
function decodeLine(line) {
|
|
9071
9361
|
let parsed;
|
|
@@ -9093,11 +9383,18 @@ function decodeLine(line) {
|
|
|
9093
9383
|
if (type === "cancel") {
|
|
9094
9384
|
return toCancel(parsed);
|
|
9095
9385
|
}
|
|
9386
|
+
if (type === "status") {
|
|
9387
|
+
return { type: "status" };
|
|
9388
|
+
}
|
|
9389
|
+
if (type === "state") {
|
|
9390
|
+
return toState(parsed);
|
|
9391
|
+
}
|
|
9096
9392
|
return null;
|
|
9097
9393
|
}
|
|
9098
9394
|
|
|
9099
9395
|
// src/transports/session/client.ts
|
|
9100
9396
|
var MS_PER_SECOND = 1e3;
|
|
9397
|
+
var NO_WATCHER = "no pair-mode watcher attached";
|
|
9101
9398
|
function failOpen(detail) {
|
|
9102
9399
|
return { reviewed: false, detail };
|
|
9103
9400
|
}
|
|
@@ -9130,7 +9427,7 @@ function requestReview(request, options) {
|
|
|
9130
9427
|
let lastError = "";
|
|
9131
9428
|
socket.on("error", (error) => {
|
|
9132
9429
|
if (isConnectionRefused(error)) {
|
|
9133
|
-
settle(failOpen(
|
|
9430
|
+
settle(failOpen(NO_WATCHER));
|
|
9134
9431
|
return;
|
|
9135
9432
|
}
|
|
9136
9433
|
lastError = error instanceof Error ? error.message : String(error);
|
|
@@ -9160,15 +9457,27 @@ function requestReview(request, options) {
|
|
|
9160
9457
|
});
|
|
9161
9458
|
});
|
|
9162
9459
|
}
|
|
9163
|
-
function reviewInSession(request, config, socketPath) {
|
|
9164
|
-
const
|
|
9165
|
-
if (
|
|
9166
|
-
return
|
|
9460
|
+
async function reviewInSession(request, config, socketPath) {
|
|
9461
|
+
const timeoutMs = config.session.timeout * MS_PER_SECOND;
|
|
9462
|
+
if (socketPath !== void 0) {
|
|
9463
|
+
return await requestReview(request, { socketPath, timeoutMs });
|
|
9167
9464
|
}
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
|
|
9465
|
+
const key = keyFor(request.sessionId);
|
|
9466
|
+
const sessionPath = key === void 0 ? null : sessionKeySocketPath(key);
|
|
9467
|
+
if (sessionPath !== null && existsSync5(sessionPath)) {
|
|
9468
|
+
const outcome = await requestReview(request, { socketPath: sessionPath, timeoutMs });
|
|
9469
|
+
if (outcome.reviewed) {
|
|
9470
|
+
return outcome;
|
|
9471
|
+
}
|
|
9472
|
+
if (outcome.detail !== NO_WATCHER) {
|
|
9473
|
+
return outcome;
|
|
9474
|
+
}
|
|
9475
|
+
}
|
|
9476
|
+
const directoryPath = findSessionSocket(request.filePath);
|
|
9477
|
+
if (directoryPath === null) {
|
|
9478
|
+
return failOpen(NO_WATCHER);
|
|
9479
|
+
}
|
|
9480
|
+
return await requestReview(request, { socketPath: directoryPath, timeoutMs });
|
|
9172
9481
|
}
|
|
9173
9482
|
function createSessionTransport(socketPath) {
|
|
9174
9483
|
return {
|
|
@@ -9189,7 +9498,8 @@ async function runPair(request, config, deps = {}) {
|
|
|
9189
9498
|
if (request.before === request.after) {
|
|
9190
9499
|
return { decision: "allow", reviewed: false };
|
|
9191
9500
|
}
|
|
9192
|
-
|
|
9501
|
+
const key = keyFor(request.sessionId);
|
|
9502
|
+
if (!isEnabled(request.filePath, key)) {
|
|
9193
9503
|
return { decision: "allow", reviewed: false };
|
|
9194
9504
|
}
|
|
9195
9505
|
const transport = deps.transport ?? resolveTransport(config, deps);
|
|
@@ -9218,6 +9528,71 @@ function trace(message, config) {
|
|
|
9218
9528
|
}
|
|
9219
9529
|
}
|
|
9220
9530
|
|
|
9531
|
+
// src/adapters/codex/apply.ts
|
|
9532
|
+
var identity = (line) => line;
|
|
9533
|
+
var trimTrailing = (line) => line.replace(/\s+$/, "");
|
|
9534
|
+
var trimBoth = (line) => line.trim();
|
|
9535
|
+
function findRun(lines, target, from, normalize) {
|
|
9536
|
+
const wanted = target.map(normalize);
|
|
9537
|
+
for (let i = from; i + target.length <= lines.length; i++) {
|
|
9538
|
+
let matches = true;
|
|
9539
|
+
for (let offset = 0; offset < wanted.length; offset++) {
|
|
9540
|
+
if (normalize(lines[i + offset] ?? "") !== wanted[offset]) {
|
|
9541
|
+
matches = false;
|
|
9542
|
+
break;
|
|
9543
|
+
}
|
|
9544
|
+
}
|
|
9545
|
+
if (matches) {
|
|
9546
|
+
return i;
|
|
9547
|
+
}
|
|
9548
|
+
}
|
|
9549
|
+
return -1;
|
|
9550
|
+
}
|
|
9551
|
+
function findOldRun(lines, oldLines, from) {
|
|
9552
|
+
const exact = findRun(lines, oldLines, from, identity);
|
|
9553
|
+
if (exact !== -1) return exact;
|
|
9554
|
+
const trailingTrimmed = findRun(lines, oldLines, from, trimTrailing);
|
|
9555
|
+
if (trailingTrimmed !== -1) return trailingTrimmed;
|
|
9556
|
+
return findRun(lines, oldLines, from, trimBoth);
|
|
9557
|
+
}
|
|
9558
|
+
function findContext(lines, ctx, cursor) {
|
|
9559
|
+
for (let i = cursor; i < lines.length; i++) {
|
|
9560
|
+
if (lines[i] === ctx) {
|
|
9561
|
+
return i;
|
|
9562
|
+
}
|
|
9563
|
+
}
|
|
9564
|
+
return -1;
|
|
9565
|
+
}
|
|
9566
|
+
function applyHunks(text, hunks) {
|
|
9567
|
+
let lines = text.split("\n");
|
|
9568
|
+
let cursor = 0;
|
|
9569
|
+
for (const hunk of hunks) {
|
|
9570
|
+
if (hunk.context !== null) {
|
|
9571
|
+
const contextIndex = findContext(lines, hunk.context, cursor);
|
|
9572
|
+
if (contextIndex === -1) {
|
|
9573
|
+
return null;
|
|
9574
|
+
}
|
|
9575
|
+
cursor = contextIndex + 1;
|
|
9576
|
+
}
|
|
9577
|
+
const oldLines = hunk.lines.flatMap((line) => line.old !== null ? [line.old] : []);
|
|
9578
|
+
const newLines = hunk.lines.flatMap((line) => line.new !== null ? [line.new] : []);
|
|
9579
|
+
if (oldLines.length === 0) {
|
|
9580
|
+
return null;
|
|
9581
|
+
}
|
|
9582
|
+
const matchIndex = findOldRun(lines, oldLines, cursor);
|
|
9583
|
+
if (matchIndex === -1) {
|
|
9584
|
+
return null;
|
|
9585
|
+
}
|
|
9586
|
+
lines = [
|
|
9587
|
+
...lines.slice(0, matchIndex),
|
|
9588
|
+
...newLines,
|
|
9589
|
+
...lines.slice(matchIndex + oldLines.length)
|
|
9590
|
+
];
|
|
9591
|
+
cursor = matchIndex + newLines.length;
|
|
9592
|
+
}
|
|
9593
|
+
return lines.join("\n");
|
|
9594
|
+
}
|
|
9595
|
+
|
|
9221
9596
|
// src/adapters/entry-point.ts
|
|
9222
9597
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
9223
9598
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -9235,13 +9610,18 @@ function isEntryPoint(moduleUrl) {
|
|
|
9235
9610
|
|
|
9236
9611
|
// src/adapters/codex/codex.ts
|
|
9237
9612
|
var BEGIN_PATCH = "*** Begin Patch";
|
|
9613
|
+
var END_PATCH = "*** End Patch";
|
|
9238
9614
|
var END_OF_FILE = "*** End of File";
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
|
|
9615
|
+
var MOVE_TO_PREFIX = "*** Move to:";
|
|
9616
|
+
function isSectionHeader(line) {
|
|
9617
|
+
return line.startsWith("*** ") && !line.startsWith(MOVE_TO_PREFIX) && line.trim() !== END_OF_FILE;
|
|
9618
|
+
}
|
|
9619
|
+
function stripEndOfFile(body) {
|
|
9620
|
+
const lastIndex = body.findLastIndex((line) => line.trim() !== "");
|
|
9621
|
+
if (lastIndex === -1 || body[lastIndex]?.trim() !== END_OF_FILE) {
|
|
9622
|
+
return body;
|
|
9243
9623
|
}
|
|
9244
|
-
return [...
|
|
9624
|
+
return [...body.slice(0, lastIndex), ...body.slice(lastIndex + 1)];
|
|
9245
9625
|
}
|
|
9246
9626
|
var hasPatchMarker = (value) => typeof value === "string" && value.includes(BEGIN_PATCH);
|
|
9247
9627
|
function extractPatchText(toolInput) {
|
|
@@ -9250,28 +9630,29 @@ function extractPatchText(toolInput) {
|
|
|
9250
9630
|
if (!Array.isArray(command)) return null;
|
|
9251
9631
|
return command.find(hasPatchMarker) ?? null;
|
|
9252
9632
|
}
|
|
9253
|
-
function
|
|
9633
|
+
function parseSections(patchText) {
|
|
9254
9634
|
const lines = patchText.split("\n");
|
|
9255
9635
|
const beginIndex = lines.findIndex((line) => line.trim() === BEGIN_PATCH);
|
|
9256
|
-
const endIndex = lines.findIndex((line) => line.trim() ===
|
|
9636
|
+
const endIndex = lines.findIndex((line) => line.trim() === END_PATCH);
|
|
9257
9637
|
if (beginIndex === -1 || endIndex === -1 || endIndex <= beginIndex) {
|
|
9258
9638
|
return null;
|
|
9259
9639
|
}
|
|
9260
|
-
const inner =
|
|
9261
|
-
const
|
|
9262
|
-
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
const rest = inner.slice(headerIndex + 1);
|
|
9267
|
-
const nextHeaderIndex = rest.findIndex((line) => line.startsWith("*** "));
|
|
9268
|
-
if (header === void 0) {
|
|
9269
|
-
return null;
|
|
9270
|
-
}
|
|
9271
|
-
if (nextHeaderIndex !== -1) {
|
|
9640
|
+
const inner = lines.slice(beginIndex + 1, endIndex);
|
|
9641
|
+
const headerIndices = inner.reduce(
|
|
9642
|
+
(acc, line, index) => isSectionHeader(line) ? [...acc, index] : acc,
|
|
9643
|
+
[]
|
|
9644
|
+
);
|
|
9645
|
+
if (headerIndices.length === 0) {
|
|
9272
9646
|
return null;
|
|
9273
9647
|
}
|
|
9274
|
-
return
|
|
9648
|
+
return headerIndices.map((headerIndex, order) => {
|
|
9649
|
+
const header = inner[headerIndex] ?? "";
|
|
9650
|
+
const end = headerIndices[order + 1] ?? inner.length;
|
|
9651
|
+
const rawBody = inner.slice(headerIndex + 1, end);
|
|
9652
|
+
const bodyNoEof = stripEndOfFile(rawBody);
|
|
9653
|
+
const body = bodyNoEof.filter((line) => !line.startsWith(MOVE_TO_PREFIX));
|
|
9654
|
+
return { header, body };
|
|
9655
|
+
});
|
|
9275
9656
|
}
|
|
9276
9657
|
function pathFromHeader(header, marker) {
|
|
9277
9658
|
if (!header.startsWith(marker)) {
|
|
@@ -9302,47 +9683,43 @@ function classifyHunkLine(line) {
|
|
|
9302
9683
|
}
|
|
9303
9684
|
return null;
|
|
9304
9685
|
}
|
|
9305
|
-
function
|
|
9306
|
-
|
|
9307
|
-
if (!classified.every((entry) => entry !== null)) {
|
|
9686
|
+
function contextFor(line) {
|
|
9687
|
+
if (line === "@@") {
|
|
9308
9688
|
return null;
|
|
9309
9689
|
}
|
|
9310
|
-
|
|
9311
|
-
const newLines = classified.flatMap((entry) => entry.new !== null ? [entry.new] : []);
|
|
9312
|
-
if (oldLines.length === 0) {
|
|
9313
|
-
return null;
|
|
9314
|
-
}
|
|
9315
|
-
return { old_string: oldLines.join("\n"), new_string: newLines.join("\n") };
|
|
9690
|
+
return line.startsWith("@@ ") ? line.slice(3) : line.slice(2);
|
|
9316
9691
|
}
|
|
9317
9692
|
function parseUpdateFile(body) {
|
|
9318
|
-
const
|
|
9693
|
+
const groups = [];
|
|
9319
9694
|
let current = null;
|
|
9320
9695
|
for (const line of body) {
|
|
9321
9696
|
if (line.startsWith("@@")) {
|
|
9322
|
-
current = [];
|
|
9323
|
-
|
|
9697
|
+
current = { context: contextFor(line), raw: [] };
|
|
9698
|
+
groups.push(current);
|
|
9324
9699
|
continue;
|
|
9325
9700
|
}
|
|
9326
9701
|
if (current === null) {
|
|
9327
|
-
current = [];
|
|
9328
|
-
|
|
9702
|
+
current = { context: null, raw: [] };
|
|
9703
|
+
groups.push(current);
|
|
9329
9704
|
}
|
|
9330
|
-
current.push(line);
|
|
9705
|
+
current.raw.push(line);
|
|
9331
9706
|
}
|
|
9332
|
-
if (
|
|
9707
|
+
if (groups.length === 0) {
|
|
9333
9708
|
return null;
|
|
9334
9709
|
}
|
|
9335
|
-
const
|
|
9336
|
-
|
|
9710
|
+
const hunks = groups.map((group) => {
|
|
9711
|
+
const classified = group.raw.map(classifyHunkLine);
|
|
9712
|
+
if (!classified.every((entry) => entry !== null)) {
|
|
9713
|
+
return null;
|
|
9714
|
+
}
|
|
9715
|
+
return { context: group.context, lines: classified };
|
|
9716
|
+
});
|
|
9717
|
+
if (!hunks.every((hunk) => hunk !== null)) {
|
|
9337
9718
|
return null;
|
|
9338
9719
|
}
|
|
9339
|
-
return
|
|
9720
|
+
return hunks;
|
|
9340
9721
|
}
|
|
9341
|
-
function
|
|
9342
|
-
const section = extractSection(patchText);
|
|
9343
|
-
if (section === null) {
|
|
9344
|
-
return null;
|
|
9345
|
-
}
|
|
9722
|
+
function parseSection(section) {
|
|
9346
9723
|
const addPath = pathFromHeader(section.header, "*** Add File:");
|
|
9347
9724
|
if (addPath !== null) {
|
|
9348
9725
|
const content = parseAddFile(section.body);
|
|
@@ -9357,18 +9734,84 @@ function parsePatch(patchText) {
|
|
|
9357
9734
|
}
|
|
9358
9735
|
const updatePath = pathFromHeader(section.header, "*** Update File:");
|
|
9359
9736
|
if (updatePath !== null) {
|
|
9360
|
-
const
|
|
9361
|
-
if (
|
|
9737
|
+
const hunks = parseUpdateFile(section.body);
|
|
9738
|
+
if (hunks === null) {
|
|
9362
9739
|
return null;
|
|
9363
9740
|
}
|
|
9364
|
-
return { filePath: updatePath, tool: "MultiEdit",
|
|
9741
|
+
return { filePath: updatePath, tool: "MultiEdit", hunks };
|
|
9365
9742
|
}
|
|
9366
9743
|
return null;
|
|
9367
9744
|
}
|
|
9745
|
+
function parsePatch(patchText) {
|
|
9746
|
+
const sections = parseSections(patchText);
|
|
9747
|
+
if (sections === null) {
|
|
9748
|
+
return null;
|
|
9749
|
+
}
|
|
9750
|
+
const parsed = sections.map(parseSection);
|
|
9751
|
+
if (!parsed.every((entry) => entry !== null)) {
|
|
9752
|
+
return null;
|
|
9753
|
+
}
|
|
9754
|
+
return parsed;
|
|
9755
|
+
}
|
|
9368
9756
|
function toolNameFor(payload) {
|
|
9369
9757
|
const value = payload["tool_name"];
|
|
9370
9758
|
return typeof value === "string" ? value : "";
|
|
9371
9759
|
}
|
|
9760
|
+
function emitDeny(reason) {
|
|
9761
|
+
const denyJson = JSON.stringify({
|
|
9762
|
+
hookSpecificOutput: {
|
|
9763
|
+
hookEventName: "PreToolUse",
|
|
9764
|
+
permissionDecision: "deny",
|
|
9765
|
+
permissionDecisionReason: reason
|
|
9766
|
+
}
|
|
9767
|
+
});
|
|
9768
|
+
try {
|
|
9769
|
+
process.stdout.write(denyJson + "\n");
|
|
9770
|
+
return 0;
|
|
9771
|
+
} catch {
|
|
9772
|
+
process.stderr.write(reason + "\n");
|
|
9773
|
+
return 2;
|
|
9774
|
+
}
|
|
9775
|
+
}
|
|
9776
|
+
function buildRequest(section, sessionId, config) {
|
|
9777
|
+
if (section.tool === "Write") {
|
|
9778
|
+
const input = { file_path: section.filePath, content: section.content ?? "" };
|
|
9779
|
+
return simulate("Write", input, readFileOrEmpty, sessionId);
|
|
9780
|
+
}
|
|
9781
|
+
const before = readFileOrEmpty(section.filePath);
|
|
9782
|
+
const after = applyHunks(before, section.hunks ?? []);
|
|
9783
|
+
if (after === null) {
|
|
9784
|
+
trace("exit: apply_patch hunk defeated the applier", config);
|
|
9785
|
+
return null;
|
|
9786
|
+
}
|
|
9787
|
+
return { tool: "MultiEdit", filePath: section.filePath, before, after, sessionId };
|
|
9788
|
+
}
|
|
9789
|
+
async function reviewPatch(toolInput, sessionId, key, config) {
|
|
9790
|
+
const patchText = extractPatchText(toolInput);
|
|
9791
|
+
if (patchText === null) {
|
|
9792
|
+
trace("exit: apply_patch payload had no patch text", config);
|
|
9793
|
+
return 0;
|
|
9794
|
+
}
|
|
9795
|
+
const sections = parsePatch(patchText);
|
|
9796
|
+
if (sections === null) {
|
|
9797
|
+
trace("exit: apply_patch body defeated the parser", config);
|
|
9798
|
+
return 0;
|
|
9799
|
+
}
|
|
9800
|
+
for (const section of sections) {
|
|
9801
|
+
if (!isEnabled(section.filePath, key)) {
|
|
9802
|
+
continue;
|
|
9803
|
+
}
|
|
9804
|
+
const request = buildRequest(section, sessionId, config);
|
|
9805
|
+
if (request === null) {
|
|
9806
|
+
continue;
|
|
9807
|
+
}
|
|
9808
|
+
const verdict = await runPair(request, config);
|
|
9809
|
+
if (verdict.decision === "deny") {
|
|
9810
|
+
return emitDeny(verdict.reason);
|
|
9811
|
+
}
|
|
9812
|
+
}
|
|
9813
|
+
return 0;
|
|
9814
|
+
}
|
|
9372
9815
|
async function main(config) {
|
|
9373
9816
|
const payload = readPayload();
|
|
9374
9817
|
if (!isRecord(payload)) {
|
|
@@ -9379,31 +9822,18 @@ async function main(config) {
|
|
|
9379
9822
|
if (!isRecord(toolInput)) {
|
|
9380
9823
|
return 0;
|
|
9381
9824
|
}
|
|
9382
|
-
|
|
9383
|
-
|
|
9825
|
+
const rawSessionId = payload["session_id"];
|
|
9826
|
+
const sessionId = typeof rawSessionId === "string" ? rawSessionId : void 0;
|
|
9827
|
+
const key = keyFor(sessionId);
|
|
9384
9828
|
if (tool === "apply_patch") {
|
|
9385
|
-
|
|
9386
|
-
if (patchText === null) {
|
|
9387
|
-
trace("exit: apply_patch payload had no patch text", config);
|
|
9388
|
-
return 0;
|
|
9389
|
-
}
|
|
9390
|
-
const parsed = parsePatch(patchText);
|
|
9391
|
-
if (parsed === null) {
|
|
9392
|
-
trace("exit: apply_patch body defeated the parser", config);
|
|
9393
|
-
return 0;
|
|
9394
|
-
}
|
|
9395
|
-
simTool = parsed.tool;
|
|
9396
|
-
simInput = parsed.tool === "Write" ? { file_path: parsed.filePath, content: parsed.content ?? "" } : { file_path: parsed.filePath, edits: parsed.edits ?? [] };
|
|
9829
|
+
return reviewPatch(toolInput, sessionId, key, config);
|
|
9397
9830
|
}
|
|
9398
|
-
const filePathValue =
|
|
9831
|
+
const filePathValue = toolInput["file_path"];
|
|
9399
9832
|
const filePath = typeof filePathValue === "string" ? filePathValue : "";
|
|
9400
|
-
if (filePath === "") {
|
|
9401
|
-
return 0;
|
|
9402
|
-
}
|
|
9403
|
-
if (!isEnabled(filePath)) {
|
|
9833
|
+
if (filePath === "" || !isEnabled(filePath, key)) {
|
|
9404
9834
|
return 0;
|
|
9405
9835
|
}
|
|
9406
|
-
const request = simulate(
|
|
9836
|
+
const request = simulate(tool, toolInput, readFileOrEmpty, sessionId);
|
|
9407
9837
|
if (request === null) {
|
|
9408
9838
|
trace("exit: could not simulate", config);
|
|
9409
9839
|
return 0;
|
|
@@ -9412,20 +9842,7 @@ async function main(config) {
|
|
|
9412
9842
|
if (verdict.decision === "allow") {
|
|
9413
9843
|
return 0;
|
|
9414
9844
|
}
|
|
9415
|
-
|
|
9416
|
-
hookSpecificOutput: {
|
|
9417
|
-
hookEventName: "PreToolUse",
|
|
9418
|
-
permissionDecision: "deny",
|
|
9419
|
-
permissionDecisionReason: verdict.reason
|
|
9420
|
-
}
|
|
9421
|
-
});
|
|
9422
|
-
try {
|
|
9423
|
-
process.stdout.write(denyJson + "\n");
|
|
9424
|
-
return 0;
|
|
9425
|
-
} catch {
|
|
9426
|
-
process.stderr.write(verdict.reason + "\n");
|
|
9427
|
-
return 2;
|
|
9428
|
-
}
|
|
9845
|
+
return emitDeny(verdict.reason);
|
|
9429
9846
|
}
|
|
9430
9847
|
async function run() {
|
|
9431
9848
|
let config = DEFAULT_CONFIG;
|