@monotykamary/localterm-server 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/parse-osc-pr-created.d.ts +2 -0
- package/dist/utils/parse-osc-pr-created.d.ts.map +1 -0
- package/dist/utils/parse-osc-pr-created.js +37 -0
- package/dist/utils/parse-osc-pr-created.js.map +1 -0
- package/dist/utils/scan-pr-url.d.ts +2 -0
- package/dist/utils/scan-pr-url.d.ts.map +1 -0
- package/dist/utils/scan-pr-url.js +33 -0
- package/dist/utils/scan-pr-url.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-osc-pr-created.d.ts","sourceRoot":"","sources":["../../src/utils/parse-osc-pr-created.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,0BAA0B,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAyBlE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// OSC 7777 (localterm pr-created signal) format:
|
|
2
|
+
// ESC ] 7777 ; pr-created ; <pr url> ST
|
|
3
|
+
// where ST is either BEL (0x07) or ESC \ (0x1b 0x5c).
|
|
4
|
+
//
|
|
5
|
+
// Emitted by the injected shell `gh` wrapper when `gh pr create` exits 0,
|
|
6
|
+
// carrying the URL the CLI printed. The ambient PR overlay refreshes inline off
|
|
7
|
+
// it — no separate `gh pr list` round-trip — so a freshly-created PR surfaces
|
|
8
|
+
// the moment the CLI returns, before the toolbar lease would have re-polled.
|
|
9
|
+
import { MAX_PR_CREATED_URL_LENGTH } from "../constants.js";
|
|
10
|
+
const OSC_PR_CREATED_PREFIX = "\x1b]7777;pr-created;";
|
|
11
|
+
const BEL = "\x07";
|
|
12
|
+
const ST = "\x1b\\";
|
|
13
|
+
export const parseOscPrCreatedFromChunk = (data) => {
|
|
14
|
+
let searchFrom = 0;
|
|
15
|
+
while (searchFrom < data.length) {
|
|
16
|
+
const start = data.indexOf(OSC_PR_CREATED_PREFIX, searchFrom);
|
|
17
|
+
if (start === -1)
|
|
18
|
+
return null;
|
|
19
|
+
const payloadStart = start + OSC_PR_CREATED_PREFIX.length;
|
|
20
|
+
const belIndex = data.indexOf(BEL, payloadStart);
|
|
21
|
+
const stIndex = data.indexOf(ST, payloadStart);
|
|
22
|
+
let terminatorIndex = -1;
|
|
23
|
+
if (belIndex !== -1 && (stIndex === -1 || belIndex < stIndex))
|
|
24
|
+
terminatorIndex = belIndex;
|
|
25
|
+
else if (stIndex !== -1)
|
|
26
|
+
terminatorIndex = stIndex;
|
|
27
|
+
if (terminatorIndex === -1)
|
|
28
|
+
return null;
|
|
29
|
+
const payload = data.slice(payloadStart, terminatorIndex);
|
|
30
|
+
if (payload.length >= 1 && payload.length <= MAX_PR_CREATED_URL_LENGTH) {
|
|
31
|
+
return payload;
|
|
32
|
+
}
|
|
33
|
+
searchFrom = terminatorIndex + 1;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=parse-osc-pr-created.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-osc-pr-created.js","sourceRoot":"","sources":["../../src/utils/parse-osc-pr-created.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,0CAA0C;AAC1C,sDAAsD;AACtD,EAAE;AACF,0EAA0E;AAC1E,gFAAgF;AAChF,8EAA8E;AAC9E,6EAA6E;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AACtD,MAAM,GAAG,GAAG,MAAM,CAAC;AACnB,MAAM,EAAE,GAAG,QAAQ,CAAC;AAEpB,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,IAAY,EAAiB,EAAE;IACxE,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,OAAO,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC;QAC9D,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QAE9B,MAAM,YAAY,GAAG,KAAK,GAAG,qBAAqB,CAAC,MAAM,CAAC;QAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;QAE/C,IAAI,eAAe,GAAG,CAAC,CAAC,CAAC;QACzB,IAAI,QAAQ,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC,CAAC,IAAI,QAAQ,GAAG,OAAO,CAAC;YAAE,eAAe,GAAG,QAAQ,CAAC;aACrF,IAAI,OAAO,KAAK,CAAC,CAAC;YAAE,eAAe,GAAG,OAAO,CAAC;QACnD,IAAI,eAAe,KAAK,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QAExC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QAC1D,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,OAAO,CAAC,MAAM,IAAI,yBAAyB,EAAE,CAAC;YACvE,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,UAAU,GAAG,eAAe,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-pr-url.d.ts","sourceRoot":"","sources":["../../src/utils/scan-pr-url.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,MAAM,EAW/C,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Best-effort scan of recent PTY output for a freshly-printed GitHub PR URL, so
|
|
2
|
+
// the ambient overlay can warm when an agent (e.g. pi) creates a PR and echoes
|
|
3
|
+
// the URL without going through the interactive `gh` wrapper. Strips ANSI first
|
|
4
|
+
// so a URL colored or boxed by a TUI still matches.
|
|
5
|
+
//
|
|
6
|
+
// Returns every DISTINCT PR URL found in the chunk, in first-appearance order.
|
|
7
|
+
// The caller keeps a sliding window and only treats a window containing exactly
|
|
8
|
+
// one distinct URL as a creation signal — that suppresses `gh pr list`-style
|
|
9
|
+
// output (many URLs at once) while accepting a TUI that redraws one URL across
|
|
10
|
+
// several frames.
|
|
11
|
+
// Control chars as runtime values so the regex sources carry no literal control
|
|
12
|
+
// escapes (which would trip the no-control-regex lint rule).
|
|
13
|
+
const ESC = String.fromCodePoint(0x1b);
|
|
14
|
+
const BEL = String.fromCodePoint(7);
|
|
15
|
+
const ANSI_CSI_RE = new RegExp(`${ESC}\\[[0-9;?]*[A-Za-z]`, "g");
|
|
16
|
+
const ANSI_OSC_RE = new RegExp(`${ESC}\\][^${BEL}${ESC}]*(?:${BEL}|${ESC}\\\\)`, "g");
|
|
17
|
+
const PR_URL_RE = /https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+/g;
|
|
18
|
+
const stripAnsi = (data) => data.replace(ANSI_OSC_RE, "").replace(ANSI_CSI_RE, "");
|
|
19
|
+
export const scanPrUrls = (data) => {
|
|
20
|
+
const matches = stripAnsi(data).match(PR_URL_RE);
|
|
21
|
+
if (!matches)
|
|
22
|
+
return [];
|
|
23
|
+
const seen = new Set();
|
|
24
|
+
const distinct = [];
|
|
25
|
+
for (const url of matches) {
|
|
26
|
+
if (seen.has(url))
|
|
27
|
+
continue;
|
|
28
|
+
seen.add(url);
|
|
29
|
+
distinct.push(url);
|
|
30
|
+
}
|
|
31
|
+
return distinct;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=scan-pr-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-pr-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