gsd-pi 2.70.1-dev.3e19108 → 2.70.1-dev.ec24142
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/resources/extensions/claude-code-cli/stream-adapter.js +127 -30
- package/dist/resources/extensions/get-secrets-from-user.js +17 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/required-server-files.json +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +12 -12
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/server.js +1 -1
- package/package.json +1 -1
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +54 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +27 -7
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.js.map +1 -1
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +68 -0
- package/packages/pi-coding-agent/src/core/extensions/types.ts +2 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/extension-input.ts +2 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +32 -13
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +1 -1
- package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +1 -1
- package/packages/pi-coding-agent/src/modes/rpc/rpc-types.ts +1 -0
- package/packages/pi-tui/dist/components/__tests__/input.test.js +9 -0
- package/packages/pi-tui/dist/components/__tests__/input.test.js.map +1 -1
- package/packages/pi-tui/dist/components/input.d.ts +2 -0
- package/packages/pi-tui/dist/components/input.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/input.js +7 -4
- package/packages/pi-tui/dist/components/input.js.map +1 -1
- package/packages/pi-tui/src/components/__tests__/input.test.ts +11 -0
- package/packages/pi-tui/src/components/input.ts +7 -4
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +164 -31
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +112 -0
- package/src/resources/extensions/get-secrets-from-user.ts +24 -1
- package/src/resources/extensions/gsd/tests/secure-env-collect.test.ts +45 -0
- /package/dist/web/standalone/.next/static/{cHCEWiRJM5bXJa9HkP1QU → 20e8bFnNjxQJflHNodEve}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{cHCEWiRJM5bXJa9HkP1QU → 20e8bFnNjxQJflHNodEve}/_ssgManifest.js +0 -0
|
@@ -25,5 +25,14 @@ describe("Input", () => {
|
|
|
25
25
|
input.focused = false;
|
|
26
26
|
assert.equal(input.focused, false);
|
|
27
27
|
});
|
|
28
|
+
it("secure mode obscures typed characters in render output", () => {
|
|
29
|
+
const input = new Input();
|
|
30
|
+
input.secure = true;
|
|
31
|
+
input.focused = true;
|
|
32
|
+
input.handleInput("secret123");
|
|
33
|
+
const line = input.render(40)[0] ?? "";
|
|
34
|
+
assert.ok(!line.includes("secret123"), "rendered line must not expose raw secret text");
|
|
35
|
+
assert.ok(line.includes("*********"), "rendered line should include masked characters");
|
|
36
|
+
});
|
|
28
37
|
});
|
|
29
38
|
//# sourceMappingURL=input.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.test.js","sourceRoot":"","sources":["../../../src/components/__tests__/input.test.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,4DAA4D;AAE5D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACrD,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;QAC1B,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QAErB,yDAAyD;QACzD,KAAK,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;QAEtC,2BAA2B;QAC3B,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;QAEtB,mDAAmD;QACnD,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QAErB,iEAAiE;QACjE,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC3B,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAChD,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACnC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAClC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;QACtB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["// pi-tui Input component regression tests\n// Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>\n\nimport { describe, it } from \"node:test\";\nimport assert from \"node:assert/strict\";\nimport { Input } from \"../input.js\";\n\ndescribe(\"Input\", () => {\n\tit(\"paste buffer is cleared when focus is lost\", () => {\n\t\tconst input = new Input();\n\t\tinput.focused = true;\n\n\t\t// Simulate starting a paste (bracket paste start marker)\n\t\tinput.handleInput(\"\\x1b[200~partial\");\n\n\t\t// Now lose focus mid-paste\n\t\tinput.focused = false;\n\n\t\t// Regain focus — should not have stale paste state\n\t\tinput.focused = true;\n\n\t\t// Typing normal text should work without paste buffer corruption\n\t\tinput.handleInput(\"hello\");\n\t\tassert.equal(input.getValue(), \"hello\");\n\t});\n\n\tit(\"focused getter/setter works correctly\", () => {\n\t\tconst input = new Input();\n\t\tassert.equal(input.focused, false);\n\t\tinput.focused = true;\n\t\tassert.equal(input.focused, true);\n\t\tinput.focused = false;\n\t\tassert.equal(input.focused, false);\n\t});\n});\n"]}
|
|
1
|
+
{"version":3,"file":"input.test.js","sourceRoot":"","sources":["../../../src/components/__tests__/input.test.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,4DAA4D;AAE5D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE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AAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACvC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,+CAA+C,CAAC,CAAC;QACxF,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,gDAAgD,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["// pi-tui Input component regression tests\n// Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>\n\nimport { describe, it } from \"node:test\";\nimport assert from \"node:assert/strict\";\nimport { Input } from \"../input.js\";\n\ndescribe(\"Input\", () => {\n\tit(\"paste buffer is cleared when focus is lost\", () => {\n\t\tconst input = new Input();\n\t\tinput.focused = true;\n\n\t\t// Simulate starting a paste (bracket paste start marker)\n\t\tinput.handleInput(\"\\x1b[200~partial\");\n\n\t\t// Now lose focus mid-paste\n\t\tinput.focused = false;\n\n\t\t// Regain focus — should not have stale paste state\n\t\tinput.focused = true;\n\n\t\t// Typing normal text should work without paste buffer corruption\n\t\tinput.handleInput(\"hello\");\n\t\tassert.equal(input.getValue(), \"hello\");\n\t});\n\n\tit(\"focused getter/setter works correctly\", () => {\n\t\tconst input = new Input();\n\t\tassert.equal(input.focused, false);\n\t\tinput.focused = true;\n\t\tassert.equal(input.focused, true);\n\t\tinput.focused = false;\n\t\tassert.equal(input.focused, false);\n\t});\n\n\tit(\"secure mode obscures typed characters in render output\", () => {\n\t\tconst input = new Input();\n\t\tinput.secure = true;\n\t\tinput.focused = true;\n\t\tinput.handleInput(\"secret123\");\n\n\t\tconst line = input.render(40)[0] ?? \"\";\n\t\tassert.ok(!line.includes(\"secret123\"), \"rendered line must not expose raw secret text\");\n\t\tassert.ok(line.includes(\"*********\"), \"rendered line should include masked characters\");\n\t});\n});\n"]}
|
|
@@ -8,6 +8,8 @@ export declare class Input implements Component, Focusable {
|
|
|
8
8
|
onSubmit?: (value: string) => void;
|
|
9
9
|
onEscape?: () => void;
|
|
10
10
|
placeholder: string;
|
|
11
|
+
/** When true, render obscured characters instead of the actual value. */
|
|
12
|
+
secure: boolean;
|
|
11
13
|
/** Focusable interface - set by TUI when focus changes */
|
|
12
14
|
private _focused;
|
|
13
15
|
get focused(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/components/input.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAiB,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAW1E;;GAEG;AACH,qBAAa,KAAM,YAAW,SAAS,EAAE,SAAS;IACjD,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAAa;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,CAAM;
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/components/input.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAiB,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAW1E;;GAEG;AACH,qBAAa,KAAM,YAAW,SAAS,EAAE,SAAS;IACjD,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAAa;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,CAAM;IAChC,yEAAyE;IAClE,MAAM,EAAE,OAAO,CAAS;IAE/B,0DAA0D;IAC1D,OAAO,CAAC,QAAQ,CAAkB;IAClC,IAAI,OAAO,IAAI,OAAO,CAErB;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAMzB;IAGD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAkB;IAGnC,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,UAAU,CAA8C;IAGhE,OAAO,CAAC,SAAS,CAA+B;IAEhD,QAAQ,IAAI,MAAM;IAIlB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAqK/B,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,IAAI;IAWZ,OAAO,CAAC,OAAO;IAkBf,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,iBAAiB;IAkCzB,OAAO,CAAC,gBAAgB;IAmCxB,OAAO,CAAC,WAAW;IAYnB,UAAU,IAAI,IAAI;IAIlB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAkG/B"}
|
|
@@ -13,6 +13,8 @@ export class Input {
|
|
|
13
13
|
this.value = "";
|
|
14
14
|
this.cursor = 0; // Cursor position in the value
|
|
15
15
|
this.placeholder = "";
|
|
16
|
+
/** When true, render obscured characters instead of the actual value. */
|
|
17
|
+
this.secure = false;
|
|
16
18
|
/** Focusable interface - set by TUI when focus changes */
|
|
17
19
|
this._focused = false;
|
|
18
20
|
// Bracketed paste mode buffering
|
|
@@ -376,6 +378,7 @@ export class Input {
|
|
|
376
378
|
// Calculate visible window
|
|
377
379
|
const prompt = "> ";
|
|
378
380
|
const availableWidth = width - prompt.length;
|
|
381
|
+
const renderValue = this.secure ? "*".repeat(this.value.length) : this.value;
|
|
379
382
|
if (availableWidth <= 0) {
|
|
380
383
|
return [prompt];
|
|
381
384
|
}
|
|
@@ -392,7 +395,7 @@ export class Input {
|
|
|
392
395
|
let cursorDisplay = this.cursor;
|
|
393
396
|
if (this.value.length < availableWidth) {
|
|
394
397
|
// Everything fits (leave room for cursor at end)
|
|
395
|
-
visibleText =
|
|
398
|
+
visibleText = renderValue;
|
|
396
399
|
}
|
|
397
400
|
else {
|
|
398
401
|
// Need horizontal scrolling
|
|
@@ -425,19 +428,19 @@ export class Input {
|
|
|
425
428
|
};
|
|
426
429
|
if (this.cursor < halfWidth) {
|
|
427
430
|
// Cursor near start
|
|
428
|
-
visibleText =
|
|
431
|
+
visibleText = renderValue.slice(0, findValidEnd(scrollWidth));
|
|
429
432
|
cursorDisplay = this.cursor;
|
|
430
433
|
}
|
|
431
434
|
else if (this.cursor > this.value.length - halfWidth) {
|
|
432
435
|
// Cursor near end
|
|
433
436
|
const start = findValidStart(this.value.length - scrollWidth);
|
|
434
|
-
visibleText =
|
|
437
|
+
visibleText = renderValue.slice(start);
|
|
435
438
|
cursorDisplay = this.cursor - start;
|
|
436
439
|
}
|
|
437
440
|
else {
|
|
438
441
|
// Cursor in middle
|
|
439
442
|
const start = findValidStart(this.cursor - halfWidth);
|
|
440
|
-
visibleText =
|
|
443
|
+
visibleText = renderValue.slice(start, findValidEnd(start + scrollWidth));
|
|
441
444
|
cursorDisplay = halfWidth;
|
|
442
445
|
}
|
|
443
446
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/components/input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAkB,aAAa,EAAkB,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO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C,CAAC;QAC3E,MAAM,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAEpC,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;QACzD,MAAM,QAAQ,GAAG,cAAc,EAAE,OAAO,IAAI,GAAG,CAAC,CAAC,0CAA0C;QAC3F,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEvE,sFAAsF;QACtF,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QAEjD,mCAAmC;QACnC,MAAM,UAAU,GAAG,UAAU,QAAQ,UAAU,CAAC,CAAC,2CAA2C;QAC5F,MAAM,cAAc,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;QAExE,yBAAyB;QACzB,MAAM,YAAY,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC;QACvE,MAAM,IAAI,GAAG,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC;QAE/C,OAAO,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACD","sourcesContent":["import { getEditorKeybindings } from \"../keybindings.js\";\nimport { decodeKittyPrintable } from \"../keys.js\";\nimport { KillRing } from \"../kill-ring.js\";\nimport { type Component, CURSOR_MARKER, type Focusable } from \"../tui.js\";\nimport { UndoStack } from \"../undo-stack.js\";\nimport { getSegmenter, isPunctuationChar, isWhitespaceChar, visibleWidth } from \"../utils.js\";\n\nconst segmenter = getSegmenter();\n\ninterface InputState {\n\tvalue: string;\n\tcursor: number;\n}\n\n/**\n * Input component - single-line text input with horizontal scrolling\n */\nexport class Input implements Component, Focusable {\n\tprivate value: string = \"\";\n\tprivate cursor: number = 0; // Cursor position in the value\n\tpublic onSubmit?: (value: string) => void;\n\tpublic onEscape?: () => void;\n\tpublic placeholder: string = \"\";\n\n\t/** Focusable interface - set by TUI when focus changes */\n\tprivate _focused: boolean = false;\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tif (!value) {\n\t\t\tthis.isInPaste = false;\n\t\t\tthis.pasteBuffer = \"\";\n\t\t}\n\t}\n\n\t// Bracketed paste mode buffering\n\tprivate pasteBuffer: string = \"\";\n\tprivate isInPaste: boolean = false;\n\n\t// Kill ring for Emacs-style kill/yank operations\n\tprivate killRing = new KillRing();\n\tprivate lastAction: \"kill\" | \"yank\" | \"type-word\" | null = null;\n\n\t// Undo support\n\tprivate undoStack = new UndoStack<InputState>();\n\n\tgetValue(): string {\n\t\treturn this.value;\n\t}\n\n\tsetValue(value: string): void {\n\t\tthis.value = value;\n\t\tthis.cursor = Math.min(this.cursor, value.length);\n\t}\n\n\thandleInput(data: string): void {\n\t\t// Handle bracketed paste mode\n\t\t// Start of paste: \\x1b[200~\n\t\t// End of paste: \\x1b[201~\n\n\t\t// Check if we're starting a bracketed paste\n\t\tif (data.includes(\"\\x1b[200~\")) {\n\t\t\tthis.isInPaste = true;\n\t\t\tthis.pasteBuffer = \"\";\n\t\t\tdata = data.replace(\"\\x1b[200~\", \"\");\n\t\t}\n\n\t\t// If we're in a paste, buffer the data\n\t\tif (this.isInPaste) {\n\t\t\t// Check if this chunk contains the end marker\n\t\t\tthis.pasteBuffer += data;\n\n\t\t\tconst endIndex = this.pasteBuffer.indexOf(\"\\x1b[201~\");\n\t\t\tif (endIndex !== -1) {\n\t\t\t\t// Extract the pasted content\n\t\t\t\tconst pasteContent = this.pasteBuffer.substring(0, endIndex);\n\n\t\t\t\t// Process the complete paste\n\t\t\t\tthis.handlePaste(pasteContent);\n\n\t\t\t\t// Reset paste state\n\t\t\t\tthis.isInPaste = false;\n\n\t\t\t\t// Handle any remaining input after the paste marker\n\t\t\t\tconst remaining = this.pasteBuffer.substring(endIndex + 6); // 6 = length of \\x1b[201~\n\t\t\t\tthis.pasteBuffer = \"\";\n\t\t\t\tif (remaining) {\n\t\t\t\t\tthis.handleInput(remaining);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst kb = getEditorKeybindings();\n\n\t\t// Escape/Cancel\n\t\tif (kb.matches(data, \"selectCancel\")) {\n\t\t\tif (this.onEscape) this.onEscape();\n\t\t\treturn;\n\t\t}\n\n\t\t// Undo\n\t\tif (kb.matches(data, \"undo\")) {\n\t\t\tthis.undo();\n\t\t\treturn;\n\t\t}\n\n\t\t// Submit\n\t\tif (kb.matches(data, \"submit\") || data === \"\\n\") {\n\t\t\tif (this.onSubmit) this.onSubmit(this.value);\n\t\t\treturn;\n\t\t}\n\n\t\t// Deletion\n\t\tif (kb.matches(data, \"deleteCharBackward\")) {\n\t\t\tthis.handleBackspace();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"deleteCharForward\")) {\n\t\t\tthis.handleForwardDelete();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"deleteWordBackward\")) {\n\t\t\tthis.deleteWordBackwards();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"deleteWordForward\")) {\n\t\t\tthis.deleteWordForward();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"deleteToLineStart\")) {\n\t\t\tthis.deleteToLineStart();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"deleteToLineEnd\")) {\n\t\t\tthis.deleteToLineEnd();\n\t\t\treturn;\n\t\t}\n\n\t\t// Kill ring actions\n\t\tif (kb.matches(data, \"yank\")) {\n\t\t\tthis.yank();\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"yankPop\")) {\n\t\t\tthis.yankPop();\n\t\t\treturn;\n\t\t}\n\n\t\t// Cursor movement\n\t\tif (kb.matches(data, \"cursorLeft\")) {\n\t\t\tthis.lastAction = null;\n\t\t\tif (this.cursor > 0) {\n\t\t\t\tconst beforeCursor = this.value.slice(0, this.cursor);\n\t\t\t\tconst graphemes = [...segmenter.segment(beforeCursor)];\n\t\t\t\tconst lastGrapheme = graphemes[graphemes.length - 1];\n\t\t\t\tthis.cursor -= lastGrapheme ? lastGrapheme.segment.length : 1;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"cursorRight\")) {\n\t\t\tthis.lastAction = null;\n\t\t\tif (this.cursor < this.value.length) {\n\t\t\t\tconst afterCursor = this.value.slice(this.cursor);\n\t\t\t\tconst graphemes = [...segmenter.segment(afterCursor)];\n\t\t\t\tconst firstGrapheme = graphemes[0];\n\t\t\t\tthis.cursor += firstGrapheme ? firstGrapheme.segment.length : 1;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"cursorLineStart\")) {\n\t\t\tthis.lastAction = null;\n\t\t\tthis.cursor = 0;\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"cursorLineEnd\")) {\n\t\t\tthis.lastAction = null;\n\t\t\tthis.cursor = this.value.length;\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"cursorWordLeft\")) {\n\t\t\tthis.moveWordBackwards();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"cursorWordRight\")) {\n\t\t\tthis.moveWordForwards();\n\t\t\treturn;\n\t\t}\n\n\t\t// Kitty CSI-u printable character (e.g. \\x1b[97u for 'a').\n\t\t// Terminals with Kitty protocol flag 1 (disambiguate) send CSI-u for all keys,\n\t\t// including plain printable characters. Decode before the control-char check\n\t\t// since CSI-u sequences contain \\x1b which would be rejected.\n\t\tconst kittyPrintable = decodeKittyPrintable(data);\n\t\tif (kittyPrintable !== undefined) {\n\t\t\tthis.insertCharacter(kittyPrintable);\n\t\t\treturn;\n\t\t}\n\n\t\t// Regular character input - accept printable characters including Unicode,\n\t\t// but reject control characters (C0: 0x00-0x1F, DEL: 0x7F, C1: 0x80-0x9F)\n\t\tconst hasControlChars = [...data].some((ch) => {\n\t\t\tconst code = ch.charCodeAt(0);\n\t\t\treturn code < 32 || code === 0x7f || (code >= 0x80 && code <= 0x9f);\n\t\t});\n\t\tif (!hasControlChars) {\n\t\t\tthis.insertCharacter(data);\n\t\t}\n\t}\n\n\tprivate insertCharacter(char: string): void {\n\t\t// Undo coalescing: consecutive word chars coalesce into one undo unit\n\t\tif (isWhitespaceChar(char) || this.lastAction !== \"type-word\") {\n\t\t\tthis.pushUndo();\n\t\t}\n\t\tthis.lastAction = \"type-word\";\n\n\t\tthis.value = this.value.slice(0, this.cursor) + char + this.value.slice(this.cursor);\n\t\tthis.cursor += char.length;\n\t}\n\n\tprivate handleBackspace(): void {\n\t\tthis.lastAction = null;\n\t\tif (this.cursor > 0) {\n\t\t\tthis.pushUndo();\n\t\t\tconst beforeCursor = this.value.slice(0, this.cursor);\n\t\t\tconst graphemes = [...segmenter.segment(beforeCursor)];\n\t\t\tconst lastGrapheme = graphemes[graphemes.length - 1];\n\t\t\tconst graphemeLength = lastGrapheme ? lastGrapheme.segment.length : 1;\n\t\t\tthis.value = this.value.slice(0, this.cursor - graphemeLength) + this.value.slice(this.cursor);\n\t\t\tthis.cursor -= graphemeLength;\n\t\t}\n\t}\n\n\tprivate handleForwardDelete(): void {\n\t\tthis.lastAction = null;\n\t\tif (this.cursor < this.value.length) {\n\t\t\tthis.pushUndo();\n\t\t\tconst afterCursor = this.value.slice(this.cursor);\n\t\t\tconst graphemes = [...segmenter.segment(afterCursor)];\n\t\t\tconst firstGrapheme = graphemes[0];\n\t\t\tconst graphemeLength = firstGrapheme ? firstGrapheme.segment.length : 1;\n\t\t\tthis.value = this.value.slice(0, this.cursor) + this.value.slice(this.cursor + graphemeLength);\n\t\t}\n\t}\n\n\tprivate deleteToLineStart(): void {\n\t\tif (this.cursor === 0) return;\n\t\tthis.pushUndo();\n\t\tconst deletedText = this.value.slice(0, this.cursor);\n\t\tthis.killRing.push(deletedText, { prepend: true, accumulate: this.lastAction === \"kill\" });\n\t\tthis.lastAction = \"kill\";\n\t\tthis.value = this.value.slice(this.cursor);\n\t\tthis.cursor = 0;\n\t}\n\n\tprivate deleteToLineEnd(): void {\n\t\tif (this.cursor >= this.value.length) return;\n\t\tthis.pushUndo();\n\t\tconst deletedText = this.value.slice(this.cursor);\n\t\tthis.killRing.push(deletedText, { prepend: false, accumulate: this.lastAction === \"kill\" });\n\t\tthis.lastAction = \"kill\";\n\t\tthis.value = this.value.slice(0, this.cursor);\n\t}\n\n\tprivate deleteWordBackwards(): void {\n\t\tif (this.cursor === 0) return;\n\n\t\t// Save lastAction before cursor movement (moveWordBackwards resets it)\n\t\tconst wasKill = this.lastAction === \"kill\";\n\n\t\tthis.pushUndo();\n\n\t\tconst oldCursor = this.cursor;\n\t\tthis.moveWordBackwards();\n\t\tconst deleteFrom = this.cursor;\n\t\tthis.cursor = oldCursor;\n\n\t\tconst deletedText = this.value.slice(deleteFrom, this.cursor);\n\t\tthis.killRing.push(deletedText, { prepend: true, accumulate: wasKill });\n\t\tthis.lastAction = \"kill\";\n\n\t\tthis.value = this.value.slice(0, deleteFrom) + this.value.slice(this.cursor);\n\t\tthis.cursor = deleteFrom;\n\t}\n\n\tprivate deleteWordForward(): void {\n\t\tif (this.cursor >= this.value.length) return;\n\n\t\t// Save lastAction before cursor movement (moveWordForwards resets it)\n\t\tconst wasKill = this.lastAction === \"kill\";\n\n\t\tthis.pushUndo();\n\n\t\tconst oldCursor = this.cursor;\n\t\tthis.moveWordForwards();\n\t\tconst deleteTo = this.cursor;\n\t\tthis.cursor = oldCursor;\n\n\t\tconst deletedText = this.value.slice(this.cursor, deleteTo);\n\t\tthis.killRing.push(deletedText, { prepend: false, accumulate: wasKill });\n\t\tthis.lastAction = \"kill\";\n\n\t\tthis.value = this.value.slice(0, this.cursor) + this.value.slice(deleteTo);\n\t}\n\n\tprivate yank(): void {\n\t\tconst text = this.killRing.peek();\n\t\tif (!text) return;\n\n\t\tthis.pushUndo();\n\n\t\tthis.value = this.value.slice(0, this.cursor) + text + this.value.slice(this.cursor);\n\t\tthis.cursor += text.length;\n\t\tthis.lastAction = \"yank\";\n\t}\n\n\tprivate yankPop(): void {\n\t\tif (this.lastAction !== \"yank\" || this.killRing.length <= 1) return;\n\n\t\tthis.pushUndo();\n\n\t\t// Delete the previously yanked text (still at end of ring before rotation)\n\t\tconst prevText = this.killRing.peek() || \"\";\n\t\tthis.value = this.value.slice(0, this.cursor - prevText.length) + this.value.slice(this.cursor);\n\t\tthis.cursor -= prevText.length;\n\n\t\t// Rotate and insert new entry\n\t\tthis.killRing.rotate();\n\t\tconst text = this.killRing.peek() || \"\";\n\t\tthis.value = this.value.slice(0, this.cursor) + text + this.value.slice(this.cursor);\n\t\tthis.cursor += text.length;\n\t\tthis.lastAction = \"yank\";\n\t}\n\n\tprivate pushUndo(): void {\n\t\tthis.undoStack.push({ value: this.value, cursor: this.cursor });\n\t}\n\n\tprivate undo(): void {\n\t\tconst snapshot = this.undoStack.pop();\n\t\tif (!snapshot) return;\n\t\tthis.value = snapshot.value;\n\t\tthis.cursor = snapshot.cursor;\n\t\tthis.lastAction = null;\n\t}\n\n\tprivate moveWordBackwards(): void {\n\t\tif (this.cursor === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lastAction = null;\n\t\tconst textBeforeCursor = this.value.slice(0, this.cursor);\n\t\tconst graphemes = [...segmenter.segment(textBeforeCursor)];\n\n\t\t// Skip trailing whitespace\n\t\twhile (graphemes.length > 0 && isWhitespaceChar(graphemes[graphemes.length - 1]?.segment || \"\")) {\n\t\t\tthis.cursor -= graphemes.pop()?.segment.length || 0;\n\t\t}\n\n\t\tif (graphemes.length > 0) {\n\t\t\tconst lastGrapheme = graphemes[graphemes.length - 1]?.segment || \"\";\n\t\t\tif (isPunctuationChar(lastGrapheme)) {\n\t\t\t\t// Skip punctuation run\n\t\t\t\twhile (graphemes.length > 0 && isPunctuationChar(graphemes[graphemes.length - 1]?.segment || \"\")) {\n\t\t\t\t\tthis.cursor -= graphemes.pop()?.segment.length || 0;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Skip word run\n\t\t\t\twhile (\n\t\t\t\t\tgraphemes.length > 0 &&\n\t\t\t\t\t!isWhitespaceChar(graphemes[graphemes.length - 1]?.segment || \"\") &&\n\t\t\t\t\t!isPunctuationChar(graphemes[graphemes.length - 1]?.segment || \"\")\n\t\t\t\t) {\n\t\t\t\t\tthis.cursor -= graphemes.pop()?.segment.length || 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate moveWordForwards(): void {\n\t\tif (this.cursor >= this.value.length) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lastAction = null;\n\t\tconst textAfterCursor = this.value.slice(this.cursor);\n\t\tconst segments = segmenter.segment(textAfterCursor);\n\t\tconst iterator = segments[Symbol.iterator]();\n\t\tlet next = iterator.next();\n\n\t\t// Skip leading whitespace\n\t\twhile (!next.done && isWhitespaceChar(next.value.segment)) {\n\t\t\tthis.cursor += next.value.segment.length;\n\t\t\tnext = iterator.next();\n\t\t}\n\n\t\tif (!next.done) {\n\t\t\tconst firstGrapheme = next.value.segment;\n\t\t\tif (isPunctuationChar(firstGrapheme)) {\n\t\t\t\t// Skip punctuation run\n\t\t\t\twhile (!next.done && isPunctuationChar(next.value.segment)) {\n\t\t\t\t\tthis.cursor += next.value.segment.length;\n\t\t\t\t\tnext = iterator.next();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Skip word run\n\t\t\t\twhile (!next.done && !isWhitespaceChar(next.value.segment) && !isPunctuationChar(next.value.segment)) {\n\t\t\t\t\tthis.cursor += next.value.segment.length;\n\t\t\t\t\tnext = iterator.next();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handlePaste(pastedText: string): void {\n\t\tthis.lastAction = null;\n\t\tthis.pushUndo();\n\n\t\t// Clean the pasted text - remove newlines and carriage returns\n\t\tconst cleanText = pastedText.replace(/\\r\\n/g, \"\").replace(/\\r/g, \"\").replace(/\\n/g, \"\");\n\n\t\t// Insert at cursor position\n\t\tthis.value = this.value.slice(0, this.cursor) + cleanText + this.value.slice(this.cursor);\n\t\tthis.cursor += cleanText.length;\n\t}\n\n\tinvalidate(): void {\n\t\t// No cached state to invalidate currently\n\t}\n\n\trender(width: number): string[] {\n\t\t// Calculate visible window\n\t\tconst prompt = \"> \";\n\t\tconst availableWidth = width - prompt.length;\n\n\t\tif (availableWidth <= 0) {\n\t\t\treturn [prompt];\n\t\t}\n\n\t\t// Show placeholder when value is empty\n\t\tif (this.value === \"\" && this.placeholder) {\n\t\t\tconst placeholderText = this.placeholder.slice(0, availableWidth - 1);\n\t\t\tconst marker = this.focused ? CURSOR_MARKER : \"\";\n\t\t\tconst cursorChar = \"\\x1b[7m \\x1b[27m\"; // inverse space for cursor\n\t\t\tconst dimPlaceholder = `\\x1b[2m${placeholderText}\\x1b[22m`; // dim text\n\t\t\tconst padding = \" \".repeat(Math.max(0, availableWidth - visibleWidth(placeholderText) - 1));\n\t\t\treturn [prompt + marker + cursorChar + dimPlaceholder + padding];\n\t\t}\n\n\t\tlet visibleText = \"\";\n\t\tlet cursorDisplay = this.cursor;\n\n\t\tif (this.value.length < availableWidth) {\n\t\t\t// Everything fits (leave room for cursor at end)\n\t\t\tvisibleText = this.value;\n\t\t} else {\n\t\t\t// Need horizontal scrolling\n\t\t\t// Reserve one character for cursor if it's at the end\n\t\t\tconst scrollWidth = this.cursor === this.value.length ? availableWidth - 1 : availableWidth;\n\t\t\tconst halfWidth = Math.floor(scrollWidth / 2);\n\n\t\t\tconst findValidStart = (start: number) => {\n\t\t\t\twhile (start < this.value.length) {\n\t\t\t\t\tconst charCode = this.value.charCodeAt(start);\n\t\t\t\t\t// this is low surrogate, not a valid start\n\t\t\t\t\tif (charCode >= 0xdc00 && charCode < 0xe000) {\n\t\t\t\t\t\tstart++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treturn start;\n\t\t\t};\n\n\t\t\tconst findValidEnd = (end: number) => {\n\t\t\t\twhile (end > 0) {\n\t\t\t\t\tconst charCode = this.value.charCodeAt(end - 1);\n\t\t\t\t\t// this is high surrogate, might be split.\n\t\t\t\t\tif (charCode >= 0xd800 && charCode < 0xdc00) {\n\t\t\t\t\t\tend--;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treturn end;\n\t\t\t};\n\n\t\t\tif (this.cursor < halfWidth) {\n\t\t\t\t// Cursor near start\n\t\t\t\tvisibleText = this.value.slice(0, findValidEnd(scrollWidth));\n\t\t\t\tcursorDisplay = this.cursor;\n\t\t\t} else if (this.cursor > this.value.length - halfWidth) {\n\t\t\t\t// Cursor near end\n\t\t\t\tconst start = findValidStart(this.value.length - scrollWidth);\n\t\t\t\tvisibleText = this.value.slice(start);\n\t\t\t\tcursorDisplay = this.cursor - start;\n\t\t\t} else {\n\t\t\t\t// Cursor in middle\n\t\t\t\tconst start = findValidStart(this.cursor - halfWidth);\n\t\t\t\tvisibleText = this.value.slice(start, findValidEnd(start + scrollWidth));\n\t\t\t\tcursorDisplay = halfWidth;\n\t\t\t}\n\t\t}\n\n\t\t// Build line with fake cursor\n\t\t// Insert cursor character at cursor position\n\t\tconst graphemes = [...segmenter.segment(visibleText.slice(cursorDisplay))];\n\t\tconst cursorGrapheme = graphemes[0];\n\n\t\tconst beforeCursor = visibleText.slice(0, cursorDisplay);\n\t\tconst atCursor = cursorGrapheme?.segment ?? \" \"; // Character at cursor, or space if at end\n\t\tconst afterCursor = visibleText.slice(cursorDisplay + atCursor.length);\n\n\t\t// Hardware cursor marker (zero-width, emitted before fake cursor for IME positioning)\n\t\tconst marker = this.focused ? CURSOR_MARKER : \"\";\n\n\t\t// Use inverse video to show cursor\n\t\tconst cursorChar = `\\x1b[7m${atCursor}\\x1b[27m`; // ESC[7m = reverse video, ESC[27m = normal\n\t\tconst textWithCursor = beforeCursor + marker + cursorChar + afterCursor;\n\n\t\t// Calculate visual width\n\t\tconst visualLength = visibleWidth(textWithCursor);\n\t\tconst padding = \" \".repeat(Math.max(0, availableWidth - visualLength));\n\t\tconst line = prompt + textWithCursor + padding;\n\n\t\treturn [line];\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/components/input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAkB,aAAa,EAAkB,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9F,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;AAOjC;;GAEG;AACH,MAAM,OAAO,KAAK;IAAlB;QACS,UAAK,GAAW,EAAE,CAAC;QACnB,WAAM,GAAW,CAAC,CAAC,CAAC,+BAA+B;QAGpD,gBAAW,GAAW,EAAE,CAAC;QAChC,yEAAyE;QAClE,WAAM,GAAY,KAAK,CAAC;QAE/B,0DAA0D;QAClD,aAAQ,GAAY,KAAK,CAAC;QAYlC,iCAAiC;QACzB,gBAAW,GAAW,EAAE,CAAC;QACzB,cAAS,GAAY,KAAK,CAAC;QAEnC,iDAAiD;QACzC,aAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC1B,eAAU,GAAyC,IAAI,CAAC;QAEhE,eAAe;QACP,cAAS,GAAG,IAAI,SAAS,EAAc,CAAC;IAgfjD,CAAC;IApgBA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AAM,UAAU,GAAG,UAAU,QAAQ,UAAU,CAAC,CAAC,2CAA2C;QAC5F,MAAM,cAAc,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;QAExE,yBAAyB;QACzB,MAAM,YAAY,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC;QACvE,MAAM,IAAI,GAAG,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC;QAE/C,OAAO,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACD","sourcesContent":["import { getEditorKeybindings } from \"../keybindings.js\";\nimport { decodeKittyPrintable } from \"../keys.js\";\nimport { KillRing } from \"../kill-ring.js\";\nimport { type Component, CURSOR_MARKER, type Focusable } from \"../tui.js\";\nimport { UndoStack } from \"../undo-stack.js\";\nimport { getSegmenter, isPunctuationChar, isWhitespaceChar, visibleWidth } from \"../utils.js\";\n\nconst segmenter = getSegmenter();\n\ninterface InputState {\n\tvalue: string;\n\tcursor: number;\n}\n\n/**\n * Input component - single-line text input with horizontal scrolling\n */\nexport class Input implements Component, Focusable {\n\tprivate value: string = \"\";\n\tprivate cursor: number = 0; // Cursor position in the value\n\tpublic onSubmit?: (value: string) => void;\n\tpublic onEscape?: () => void;\n\tpublic placeholder: string = \"\";\n\t/** When true, render obscured characters instead of the actual value. */\n\tpublic secure: boolean = false;\n\n\t/** Focusable interface - set by TUI when focus changes */\n\tprivate _focused: boolean = false;\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tif (!value) {\n\t\t\tthis.isInPaste = false;\n\t\t\tthis.pasteBuffer = \"\";\n\t\t}\n\t}\n\n\t// Bracketed paste mode buffering\n\tprivate pasteBuffer: string = \"\";\n\tprivate isInPaste: boolean = false;\n\n\t// Kill ring for Emacs-style kill/yank operations\n\tprivate killRing = new KillRing();\n\tprivate lastAction: \"kill\" | \"yank\" | \"type-word\" | null = null;\n\n\t// Undo support\n\tprivate undoStack = new UndoStack<InputState>();\n\n\tgetValue(): string {\n\t\treturn this.value;\n\t}\n\n\tsetValue(value: string): void {\n\t\tthis.value = value;\n\t\tthis.cursor = Math.min(this.cursor, value.length);\n\t}\n\n\thandleInput(data: string): void {\n\t\t// Handle bracketed paste mode\n\t\t// Start of paste: \\x1b[200~\n\t\t// End of paste: \\x1b[201~\n\n\t\t// Check if we're starting a bracketed paste\n\t\tif (data.includes(\"\\x1b[200~\")) {\n\t\t\tthis.isInPaste = true;\n\t\t\tthis.pasteBuffer = \"\";\n\t\t\tdata = data.replace(\"\\x1b[200~\", \"\");\n\t\t}\n\n\t\t// If we're in a paste, buffer the data\n\t\tif (this.isInPaste) {\n\t\t\t// Check if this chunk contains the end marker\n\t\t\tthis.pasteBuffer += data;\n\n\t\t\tconst endIndex = this.pasteBuffer.indexOf(\"\\x1b[201~\");\n\t\t\tif (endIndex !== -1) {\n\t\t\t\t// Extract the pasted content\n\t\t\t\tconst pasteContent = this.pasteBuffer.substring(0, endIndex);\n\n\t\t\t\t// Process the complete paste\n\t\t\t\tthis.handlePaste(pasteContent);\n\n\t\t\t\t// Reset paste state\n\t\t\t\tthis.isInPaste = false;\n\n\t\t\t\t// Handle any remaining input after the paste marker\n\t\t\t\tconst remaining = this.pasteBuffer.substring(endIndex + 6); // 6 = length of \\x1b[201~\n\t\t\t\tthis.pasteBuffer = \"\";\n\t\t\t\tif (remaining) {\n\t\t\t\t\tthis.handleInput(remaining);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst kb = getEditorKeybindings();\n\n\t\t// Escape/Cancel\n\t\tif (kb.matches(data, \"selectCancel\")) {\n\t\t\tif (this.onEscape) this.onEscape();\n\t\t\treturn;\n\t\t}\n\n\t\t// Undo\n\t\tif (kb.matches(data, \"undo\")) {\n\t\t\tthis.undo();\n\t\t\treturn;\n\t\t}\n\n\t\t// Submit\n\t\tif (kb.matches(data, \"submit\") || data === \"\\n\") {\n\t\t\tif (this.onSubmit) this.onSubmit(this.value);\n\t\t\treturn;\n\t\t}\n\n\t\t// Deletion\n\t\tif (kb.matches(data, \"deleteCharBackward\")) {\n\t\t\tthis.handleBackspace();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"deleteCharForward\")) {\n\t\t\tthis.handleForwardDelete();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"deleteWordBackward\")) {\n\t\t\tthis.deleteWordBackwards();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"deleteWordForward\")) {\n\t\t\tthis.deleteWordForward();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"deleteToLineStart\")) {\n\t\t\tthis.deleteToLineStart();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"deleteToLineEnd\")) {\n\t\t\tthis.deleteToLineEnd();\n\t\t\treturn;\n\t\t}\n\n\t\t// Kill ring actions\n\t\tif (kb.matches(data, \"yank\")) {\n\t\t\tthis.yank();\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"yankPop\")) {\n\t\t\tthis.yankPop();\n\t\t\treturn;\n\t\t}\n\n\t\t// Cursor movement\n\t\tif (kb.matches(data, \"cursorLeft\")) {\n\t\t\tthis.lastAction = null;\n\t\t\tif (this.cursor > 0) {\n\t\t\t\tconst beforeCursor = this.value.slice(0, this.cursor);\n\t\t\t\tconst graphemes = [...segmenter.segment(beforeCursor)];\n\t\t\t\tconst lastGrapheme = graphemes[graphemes.length - 1];\n\t\t\t\tthis.cursor -= lastGrapheme ? lastGrapheme.segment.length : 1;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"cursorRight\")) {\n\t\t\tthis.lastAction = null;\n\t\t\tif (this.cursor < this.value.length) {\n\t\t\t\tconst afterCursor = this.value.slice(this.cursor);\n\t\t\t\tconst graphemes = [...segmenter.segment(afterCursor)];\n\t\t\t\tconst firstGrapheme = graphemes[0];\n\t\t\t\tthis.cursor += firstGrapheme ? firstGrapheme.segment.length : 1;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"cursorLineStart\")) {\n\t\t\tthis.lastAction = null;\n\t\t\tthis.cursor = 0;\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"cursorLineEnd\")) {\n\t\t\tthis.lastAction = null;\n\t\t\tthis.cursor = this.value.length;\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"cursorWordLeft\")) {\n\t\t\tthis.moveWordBackwards();\n\t\t\treturn;\n\t\t}\n\n\t\tif (kb.matches(data, \"cursorWordRight\")) {\n\t\t\tthis.moveWordForwards();\n\t\t\treturn;\n\t\t}\n\n\t\t// Kitty CSI-u printable character (e.g. \\x1b[97u for 'a').\n\t\t// Terminals with Kitty protocol flag 1 (disambiguate) send CSI-u for all keys,\n\t\t// including plain printable characters. Decode before the control-char check\n\t\t// since CSI-u sequences contain \\x1b which would be rejected.\n\t\tconst kittyPrintable = decodeKittyPrintable(data);\n\t\tif (kittyPrintable !== undefined) {\n\t\t\tthis.insertCharacter(kittyPrintable);\n\t\t\treturn;\n\t\t}\n\n\t\t// Regular character input - accept printable characters including Unicode,\n\t\t// but reject control characters (C0: 0x00-0x1F, DEL: 0x7F, C1: 0x80-0x9F)\n\t\tconst hasControlChars = [...data].some((ch) => {\n\t\t\tconst code = ch.charCodeAt(0);\n\t\t\treturn code < 32 || code === 0x7f || (code >= 0x80 && code <= 0x9f);\n\t\t});\n\t\tif (!hasControlChars) {\n\t\t\tthis.insertCharacter(data);\n\t\t}\n\t}\n\n\tprivate insertCharacter(char: string): void {\n\t\t// Undo coalescing: consecutive word chars coalesce into one undo unit\n\t\tif (isWhitespaceChar(char) || this.lastAction !== \"type-word\") {\n\t\t\tthis.pushUndo();\n\t\t}\n\t\tthis.lastAction = \"type-word\";\n\n\t\tthis.value = this.value.slice(0, this.cursor) + char + this.value.slice(this.cursor);\n\t\tthis.cursor += char.length;\n\t}\n\n\tprivate handleBackspace(): void {\n\t\tthis.lastAction = null;\n\t\tif (this.cursor > 0) {\n\t\t\tthis.pushUndo();\n\t\t\tconst beforeCursor = this.value.slice(0, this.cursor);\n\t\t\tconst graphemes = [...segmenter.segment(beforeCursor)];\n\t\t\tconst lastGrapheme = graphemes[graphemes.length - 1];\n\t\t\tconst graphemeLength = lastGrapheme ? lastGrapheme.segment.length : 1;\n\t\t\tthis.value = this.value.slice(0, this.cursor - graphemeLength) + this.value.slice(this.cursor);\n\t\t\tthis.cursor -= graphemeLength;\n\t\t}\n\t}\n\n\tprivate handleForwardDelete(): void {\n\t\tthis.lastAction = null;\n\t\tif (this.cursor < this.value.length) {\n\t\t\tthis.pushUndo();\n\t\t\tconst afterCursor = this.value.slice(this.cursor);\n\t\t\tconst graphemes = [...segmenter.segment(afterCursor)];\n\t\t\tconst firstGrapheme = graphemes[0];\n\t\t\tconst graphemeLength = firstGrapheme ? firstGrapheme.segment.length : 1;\n\t\t\tthis.value = this.value.slice(0, this.cursor) + this.value.slice(this.cursor + graphemeLength);\n\t\t}\n\t}\n\n\tprivate deleteToLineStart(): void {\n\t\tif (this.cursor === 0) return;\n\t\tthis.pushUndo();\n\t\tconst deletedText = this.value.slice(0, this.cursor);\n\t\tthis.killRing.push(deletedText, { prepend: true, accumulate: this.lastAction === \"kill\" });\n\t\tthis.lastAction = \"kill\";\n\t\tthis.value = this.value.slice(this.cursor);\n\t\tthis.cursor = 0;\n\t}\n\n\tprivate deleteToLineEnd(): void {\n\t\tif (this.cursor >= this.value.length) return;\n\t\tthis.pushUndo();\n\t\tconst deletedText = this.value.slice(this.cursor);\n\t\tthis.killRing.push(deletedText, { prepend: false, accumulate: this.lastAction === \"kill\" });\n\t\tthis.lastAction = \"kill\";\n\t\tthis.value = this.value.slice(0, this.cursor);\n\t}\n\n\tprivate deleteWordBackwards(): void {\n\t\tif (this.cursor === 0) return;\n\n\t\t// Save lastAction before cursor movement (moveWordBackwards resets it)\n\t\tconst wasKill = this.lastAction === \"kill\";\n\n\t\tthis.pushUndo();\n\n\t\tconst oldCursor = this.cursor;\n\t\tthis.moveWordBackwards();\n\t\tconst deleteFrom = this.cursor;\n\t\tthis.cursor = oldCursor;\n\n\t\tconst deletedText = this.value.slice(deleteFrom, this.cursor);\n\t\tthis.killRing.push(deletedText, { prepend: true, accumulate: wasKill });\n\t\tthis.lastAction = \"kill\";\n\n\t\tthis.value = this.value.slice(0, deleteFrom) + this.value.slice(this.cursor);\n\t\tthis.cursor = deleteFrom;\n\t}\n\n\tprivate deleteWordForward(): void {\n\t\tif (this.cursor >= this.value.length) return;\n\n\t\t// Save lastAction before cursor movement (moveWordForwards resets it)\n\t\tconst wasKill = this.lastAction === \"kill\";\n\n\t\tthis.pushUndo();\n\n\t\tconst oldCursor = this.cursor;\n\t\tthis.moveWordForwards();\n\t\tconst deleteTo = this.cursor;\n\t\tthis.cursor = oldCursor;\n\n\t\tconst deletedText = this.value.slice(this.cursor, deleteTo);\n\t\tthis.killRing.push(deletedText, { prepend: false, accumulate: wasKill });\n\t\tthis.lastAction = \"kill\";\n\n\t\tthis.value = this.value.slice(0, this.cursor) + this.value.slice(deleteTo);\n\t}\n\n\tprivate yank(): void {\n\t\tconst text = this.killRing.peek();\n\t\tif (!text) return;\n\n\t\tthis.pushUndo();\n\n\t\tthis.value = this.value.slice(0, this.cursor) + text + this.value.slice(this.cursor);\n\t\tthis.cursor += text.length;\n\t\tthis.lastAction = \"yank\";\n\t}\n\n\tprivate yankPop(): void {\n\t\tif (this.lastAction !== \"yank\" || this.killRing.length <= 1) return;\n\n\t\tthis.pushUndo();\n\n\t\t// Delete the previously yanked text (still at end of ring before rotation)\n\t\tconst prevText = this.killRing.peek() || \"\";\n\t\tthis.value = this.value.slice(0, this.cursor - prevText.length) + this.value.slice(this.cursor);\n\t\tthis.cursor -= prevText.length;\n\n\t\t// Rotate and insert new entry\n\t\tthis.killRing.rotate();\n\t\tconst text = this.killRing.peek() || \"\";\n\t\tthis.value = this.value.slice(0, this.cursor) + text + this.value.slice(this.cursor);\n\t\tthis.cursor += text.length;\n\t\tthis.lastAction = \"yank\";\n\t}\n\n\tprivate pushUndo(): void {\n\t\tthis.undoStack.push({ value: this.value, cursor: this.cursor });\n\t}\n\n\tprivate undo(): void {\n\t\tconst snapshot = this.undoStack.pop();\n\t\tif (!snapshot) return;\n\t\tthis.value = snapshot.value;\n\t\tthis.cursor = snapshot.cursor;\n\t\tthis.lastAction = null;\n\t}\n\n\tprivate moveWordBackwards(): void {\n\t\tif (this.cursor === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lastAction = null;\n\t\tconst textBeforeCursor = this.value.slice(0, this.cursor);\n\t\tconst graphemes = [...segmenter.segment(textBeforeCursor)];\n\n\t\t// Skip trailing whitespace\n\t\twhile (graphemes.length > 0 && isWhitespaceChar(graphemes[graphemes.length - 1]?.segment || \"\")) {\n\t\t\tthis.cursor -= graphemes.pop()?.segment.length || 0;\n\t\t}\n\n\t\tif (graphemes.length > 0) {\n\t\t\tconst lastGrapheme = graphemes[graphemes.length - 1]?.segment || \"\";\n\t\t\tif (isPunctuationChar(lastGrapheme)) {\n\t\t\t\t// Skip punctuation run\n\t\t\t\twhile (graphemes.length > 0 && isPunctuationChar(graphemes[graphemes.length - 1]?.segment || \"\")) {\n\t\t\t\t\tthis.cursor -= graphemes.pop()?.segment.length || 0;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Skip word run\n\t\t\t\twhile (\n\t\t\t\t\tgraphemes.length > 0 &&\n\t\t\t\t\t!isWhitespaceChar(graphemes[graphemes.length - 1]?.segment || \"\") &&\n\t\t\t\t\t!isPunctuationChar(graphemes[graphemes.length - 1]?.segment || \"\")\n\t\t\t\t) {\n\t\t\t\t\tthis.cursor -= graphemes.pop()?.segment.length || 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate moveWordForwards(): void {\n\t\tif (this.cursor >= this.value.length) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lastAction = null;\n\t\tconst textAfterCursor = this.value.slice(this.cursor);\n\t\tconst segments = segmenter.segment(textAfterCursor);\n\t\tconst iterator = segments[Symbol.iterator]();\n\t\tlet next = iterator.next();\n\n\t\t// Skip leading whitespace\n\t\twhile (!next.done && isWhitespaceChar(next.value.segment)) {\n\t\t\tthis.cursor += next.value.segment.length;\n\t\t\tnext = iterator.next();\n\t\t}\n\n\t\tif (!next.done) {\n\t\t\tconst firstGrapheme = next.value.segment;\n\t\t\tif (isPunctuationChar(firstGrapheme)) {\n\t\t\t\t// Skip punctuation run\n\t\t\t\twhile (!next.done && isPunctuationChar(next.value.segment)) {\n\t\t\t\t\tthis.cursor += next.value.segment.length;\n\t\t\t\t\tnext = iterator.next();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Skip word run\n\t\t\t\twhile (!next.done && !isWhitespaceChar(next.value.segment) && !isPunctuationChar(next.value.segment)) {\n\t\t\t\t\tthis.cursor += next.value.segment.length;\n\t\t\t\t\tnext = iterator.next();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handlePaste(pastedText: string): void {\n\t\tthis.lastAction = null;\n\t\tthis.pushUndo();\n\n\t\t// Clean the pasted text - remove newlines and carriage returns\n\t\tconst cleanText = pastedText.replace(/\\r\\n/g, \"\").replace(/\\r/g, \"\").replace(/\\n/g, \"\");\n\n\t\t// Insert at cursor position\n\t\tthis.value = this.value.slice(0, this.cursor) + cleanText + this.value.slice(this.cursor);\n\t\tthis.cursor += cleanText.length;\n\t}\n\n\tinvalidate(): void {\n\t\t// No cached state to invalidate currently\n\t}\n\n\trender(width: number): string[] {\n\t\t// Calculate visible window\n\t\tconst prompt = \"> \";\n\t\tconst availableWidth = width - prompt.length;\n\t\tconst renderValue = this.secure ? \"*\".repeat(this.value.length) : this.value;\n\n\t\tif (availableWidth <= 0) {\n\t\t\treturn [prompt];\n\t\t}\n\n\t\t// Show placeholder when value is empty\n\t\tif (this.value === \"\" && this.placeholder) {\n\t\t\tconst placeholderText = this.placeholder.slice(0, availableWidth - 1);\n\t\t\tconst marker = this.focused ? CURSOR_MARKER : \"\";\n\t\t\tconst cursorChar = \"\\x1b[7m \\x1b[27m\"; // inverse space for cursor\n\t\t\tconst dimPlaceholder = `\\x1b[2m${placeholderText}\\x1b[22m`; // dim text\n\t\t\tconst padding = \" \".repeat(Math.max(0, availableWidth - visibleWidth(placeholderText) - 1));\n\t\t\treturn [prompt + marker + cursorChar + dimPlaceholder + padding];\n\t\t}\n\n\t\tlet visibleText = \"\";\n\t\tlet cursorDisplay = this.cursor;\n\n\t\tif (this.value.length < availableWidth) {\n\t\t\t// Everything fits (leave room for cursor at end)\n\t\t\tvisibleText = renderValue;\n\t\t} else {\n\t\t\t// Need horizontal scrolling\n\t\t\t// Reserve one character for cursor if it's at the end\n\t\t\tconst scrollWidth = this.cursor === this.value.length ? availableWidth - 1 : availableWidth;\n\t\t\tconst halfWidth = Math.floor(scrollWidth / 2);\n\n\t\t\tconst findValidStart = (start: number) => {\n\t\t\t\twhile (start < this.value.length) {\n\t\t\t\t\tconst charCode = this.value.charCodeAt(start);\n\t\t\t\t\t// this is low surrogate, not a valid start\n\t\t\t\t\tif (charCode >= 0xdc00 && charCode < 0xe000) {\n\t\t\t\t\t\tstart++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treturn start;\n\t\t\t};\n\n\t\t\tconst findValidEnd = (end: number) => {\n\t\t\t\twhile (end > 0) {\n\t\t\t\t\tconst charCode = this.value.charCodeAt(end - 1);\n\t\t\t\t\t// this is high surrogate, might be split.\n\t\t\t\t\tif (charCode >= 0xd800 && charCode < 0xdc00) {\n\t\t\t\t\t\tend--;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treturn end;\n\t\t\t};\n\n\t\t\tif (this.cursor < halfWidth) {\n\t\t\t\t// Cursor near start\n\t\t\t\tvisibleText = renderValue.slice(0, findValidEnd(scrollWidth));\n\t\t\t\tcursorDisplay = this.cursor;\n\t\t\t} else if (this.cursor > this.value.length - halfWidth) {\n\t\t\t\t// Cursor near end\n\t\t\t\tconst start = findValidStart(this.value.length - scrollWidth);\n\t\t\t\tvisibleText = renderValue.slice(start);\n\t\t\t\tcursorDisplay = this.cursor - start;\n\t\t\t} else {\n\t\t\t\t// Cursor in middle\n\t\t\t\tconst start = findValidStart(this.cursor - halfWidth);\n\t\t\t\tvisibleText = renderValue.slice(start, findValidEnd(start + scrollWidth));\n\t\t\t\tcursorDisplay = halfWidth;\n\t\t\t}\n\t\t}\n\n\t\t// Build line with fake cursor\n\t\t// Insert cursor character at cursor position\n\t\tconst graphemes = [...segmenter.segment(visibleText.slice(cursorDisplay))];\n\t\tconst cursorGrapheme = graphemes[0];\n\n\t\tconst beforeCursor = visibleText.slice(0, cursorDisplay);\n\t\tconst atCursor = cursorGrapheme?.segment ?? \" \"; // Character at cursor, or space if at end\n\t\tconst afterCursor = visibleText.slice(cursorDisplay + atCursor.length);\n\n\t\t// Hardware cursor marker (zero-width, emitted before fake cursor for IME positioning)\n\t\tconst marker = this.focused ? CURSOR_MARKER : \"\";\n\n\t\t// Use inverse video to show cursor\n\t\tconst cursorChar = `\\x1b[7m${atCursor}\\x1b[27m`; // ESC[7m = reverse video, ESC[27m = normal\n\t\tconst textWithCursor = beforeCursor + marker + cursorChar + afterCursor;\n\n\t\t// Calculate visual width\n\t\tconst visualLength = visibleWidth(textWithCursor);\n\t\tconst padding = \" \".repeat(Math.max(0, availableWidth - visualLength));\n\t\tconst line = prompt + textWithCursor + padding;\n\n\t\treturn [line];\n\t}\n}\n"]}
|
|
@@ -32,4 +32,15 @@ describe("Input", () => {
|
|
|
32
32
|
input.focused = false;
|
|
33
33
|
assert.equal(input.focused, false);
|
|
34
34
|
});
|
|
35
|
+
|
|
36
|
+
it("secure mode obscures typed characters in render output", () => {
|
|
37
|
+
const input = new Input();
|
|
38
|
+
input.secure = true;
|
|
39
|
+
input.focused = true;
|
|
40
|
+
input.handleInput("secret123");
|
|
41
|
+
|
|
42
|
+
const line = input.render(40)[0] ?? "";
|
|
43
|
+
assert.ok(!line.includes("secret123"), "rendered line must not expose raw secret text");
|
|
44
|
+
assert.ok(line.includes("*********"), "rendered line should include masked characters");
|
|
45
|
+
});
|
|
35
46
|
});
|
|
@@ -21,6 +21,8 @@ export class Input implements Component, Focusable {
|
|
|
21
21
|
public onSubmit?: (value: string) => void;
|
|
22
22
|
public onEscape?: () => void;
|
|
23
23
|
public placeholder: string = "";
|
|
24
|
+
/** When true, render obscured characters instead of the actual value. */
|
|
25
|
+
public secure: boolean = false;
|
|
24
26
|
|
|
25
27
|
/** Focusable interface - set by TUI when focus changes */
|
|
26
28
|
private _focused: boolean = false;
|
|
@@ -446,6 +448,7 @@ export class Input implements Component, Focusable {
|
|
|
446
448
|
// Calculate visible window
|
|
447
449
|
const prompt = "> ";
|
|
448
450
|
const availableWidth = width - prompt.length;
|
|
451
|
+
const renderValue = this.secure ? "*".repeat(this.value.length) : this.value;
|
|
449
452
|
|
|
450
453
|
if (availableWidth <= 0) {
|
|
451
454
|
return [prompt];
|
|
@@ -466,7 +469,7 @@ export class Input implements Component, Focusable {
|
|
|
466
469
|
|
|
467
470
|
if (this.value.length < availableWidth) {
|
|
468
471
|
// Everything fits (leave room for cursor at end)
|
|
469
|
-
visibleText =
|
|
472
|
+
visibleText = renderValue;
|
|
470
473
|
} else {
|
|
471
474
|
// Need horizontal scrolling
|
|
472
475
|
// Reserve one character for cursor if it's at the end
|
|
@@ -501,17 +504,17 @@ export class Input implements Component, Focusable {
|
|
|
501
504
|
|
|
502
505
|
if (this.cursor < halfWidth) {
|
|
503
506
|
// Cursor near start
|
|
504
|
-
visibleText =
|
|
507
|
+
visibleText = renderValue.slice(0, findValidEnd(scrollWidth));
|
|
505
508
|
cursorDisplay = this.cursor;
|
|
506
509
|
} else if (this.cursor > this.value.length - halfWidth) {
|
|
507
510
|
// Cursor near end
|
|
508
511
|
const start = findValidStart(this.value.length - scrollWidth);
|
|
509
|
-
visibleText =
|
|
512
|
+
visibleText = renderValue.slice(start);
|
|
510
513
|
cursorDisplay = this.cursor - start;
|
|
511
514
|
} else {
|
|
512
515
|
// Cursor in middle
|
|
513
516
|
const start = findValidStart(this.cursor - halfWidth);
|
|
514
|
-
visibleText =
|
|
517
|
+
visibleText = renderValue.slice(start, findValidEnd(start + scrollWidth));
|
|
515
518
|
cursorDisplay = halfWidth;
|
|
516
519
|
}
|
|
517
520
|
}
|
|
@@ -60,6 +60,8 @@ interface SdkElicitationFieldSchema {
|
|
|
60
60
|
type?: string;
|
|
61
61
|
title?: string;
|
|
62
62
|
description?: string;
|
|
63
|
+
format?: string;
|
|
64
|
+
writeOnly?: boolean;
|
|
63
65
|
oneOf?: SdkElicitationRequestOption[];
|
|
64
66
|
items?: {
|
|
65
67
|
anyOf?: SdkElicitationRequestOption[];
|
|
@@ -73,6 +75,7 @@ interface SdkElicitationRequest {
|
|
|
73
75
|
requestedSchema?: {
|
|
74
76
|
type?: string;
|
|
75
77
|
properties?: Record<string, SdkElicitationFieldSchema>;
|
|
78
|
+
required?: string[];
|
|
76
79
|
};
|
|
77
80
|
}
|
|
78
81
|
|
|
@@ -85,7 +88,16 @@ interface ParsedElicitationQuestion extends Question {
|
|
|
85
88
|
noteFieldId?: string;
|
|
86
89
|
}
|
|
87
90
|
|
|
91
|
+
interface ParsedTextInputField {
|
|
92
|
+
id: string;
|
|
93
|
+
title: string;
|
|
94
|
+
description: string;
|
|
95
|
+
required: boolean;
|
|
96
|
+
secure: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
88
99
|
const OTHER_OPTION_LABEL = "None of the above";
|
|
100
|
+
const SENSITIVE_FIELD_PATTERN = /(password|passphrase|secret|token|api[_\s-]*key|private[_\s-]*key|credential)/i;
|
|
89
101
|
|
|
90
102
|
// ---------------------------------------------------------------------------
|
|
91
103
|
// Stream factory
|
|
@@ -274,6 +286,67 @@ export function parseAskUserQuestionsElicitation(
|
|
|
274
286
|
return questions.length > 0 ? questions : null;
|
|
275
287
|
}
|
|
276
288
|
|
|
289
|
+
function isSecureElicitationField(
|
|
290
|
+
requestMessage: string,
|
|
291
|
+
fieldId: string,
|
|
292
|
+
field: SdkElicitationFieldSchema,
|
|
293
|
+
): boolean {
|
|
294
|
+
if (field.format === "password") return true;
|
|
295
|
+
if (field.writeOnly === true) return true;
|
|
296
|
+
|
|
297
|
+
const rawField = field as Record<string, unknown>;
|
|
298
|
+
if (rawField.sensitive === true || rawField["x-sensitive"] === true) return true;
|
|
299
|
+
|
|
300
|
+
const haystack = [
|
|
301
|
+
requestMessage,
|
|
302
|
+
fieldId.replace(/[_-]+/g, " "),
|
|
303
|
+
typeof field.title === "string" ? field.title : "",
|
|
304
|
+
typeof field.description === "string" ? field.description : "",
|
|
305
|
+
]
|
|
306
|
+
.join(" ")
|
|
307
|
+
.toLowerCase();
|
|
308
|
+
|
|
309
|
+
return SENSITIVE_FIELD_PATTERN.test(haystack);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export function parseTextInputElicitation(
|
|
313
|
+
request: Pick<SdkElicitationRequest, "message" | "mode" | "requestedSchema">,
|
|
314
|
+
): ParsedTextInputField[] | null {
|
|
315
|
+
if (request.mode && request.mode !== "form") return null;
|
|
316
|
+
const schema = request.requestedSchema as
|
|
317
|
+
| ({ properties?: Record<string, SdkElicitationFieldSchema>; keys?: Record<string, SdkElicitationFieldSchema> } & Record<string, unknown>)
|
|
318
|
+
| undefined;
|
|
319
|
+
const fieldsSource = schema?.properties && typeof schema.properties === "object"
|
|
320
|
+
? schema.properties
|
|
321
|
+
: schema?.keys && typeof schema.keys === "object"
|
|
322
|
+
? schema.keys
|
|
323
|
+
: undefined;
|
|
324
|
+
if (!fieldsSource) return null;
|
|
325
|
+
|
|
326
|
+
const requiredSet = new Set(
|
|
327
|
+
Array.isArray(request.requestedSchema?.required)
|
|
328
|
+
? request.requestedSchema.required.filter((value): value is string => typeof value === "string")
|
|
329
|
+
: [],
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
const fields: ParsedTextInputField[] = [];
|
|
333
|
+
for (const [fieldId, field] of Object.entries(fieldsSource)) {
|
|
334
|
+
if (!field || typeof field !== "object") continue;
|
|
335
|
+
if (field.type !== "string") continue;
|
|
336
|
+
if (Array.isArray(field.oneOf) && field.oneOf.length > 0) continue;
|
|
337
|
+
|
|
338
|
+
fields.push({
|
|
339
|
+
id: fieldId,
|
|
340
|
+
title: typeof field.title === "string" && field.title.length > 0 ? field.title : fieldId,
|
|
341
|
+
description: typeof field.description === "string" ? field.description : "",
|
|
342
|
+
required: requiredSet.has(fieldId),
|
|
343
|
+
secure: isSecureElicitationField(request.message, fieldId, field),
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
return fields.length > 0 ? fields : null;
|
|
348
|
+
}
|
|
349
|
+
|
|
277
350
|
export function roundResultToElicitationContent(
|
|
278
351
|
questions: ParsedElicitationQuestion[],
|
|
279
352
|
result: RoundResult,
|
|
@@ -355,6 +428,52 @@ async function promptElicitationWithDialogs(
|
|
|
355
428
|
return { action: "accept", content };
|
|
356
429
|
}
|
|
357
430
|
|
|
431
|
+
function buildTextInputPromptTitle(request: SdkElicitationRequest, field: ParsedTextInputField): string {
|
|
432
|
+
const parts = [
|
|
433
|
+
request.serverName ? `[${request.serverName}]` : "",
|
|
434
|
+
field.title,
|
|
435
|
+
field.description,
|
|
436
|
+
].filter((part) => typeof part === "string" && part.trim().length > 0);
|
|
437
|
+
return parts.join("\n\n");
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function buildTextInputPlaceholder(field: ParsedTextInputField): string | undefined {
|
|
441
|
+
const desc = field.description.trim();
|
|
442
|
+
if (!desc) return field.required ? "Required" : "Leave empty to skip";
|
|
443
|
+
|
|
444
|
+
const formatLine = desc
|
|
445
|
+
.split(/\r?\n/)
|
|
446
|
+
.map((line) => line.trim())
|
|
447
|
+
.find((line) => /^format:/i.test(line));
|
|
448
|
+
|
|
449
|
+
if (!formatLine) return field.required ? "Required" : "Leave empty to skip";
|
|
450
|
+
const hint = formatLine.replace(/^format:\s*/i, "").trim();
|
|
451
|
+
return hint.length > 0 ? hint : field.required ? "Required" : "Leave empty to skip";
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
async function promptTextInputElicitation(
|
|
455
|
+
request: SdkElicitationRequest,
|
|
456
|
+
fields: ParsedTextInputField[],
|
|
457
|
+
ui: ExtensionUIContext,
|
|
458
|
+
signal: AbortSignal,
|
|
459
|
+
): Promise<SdkElicitationResult> {
|
|
460
|
+
const content: Record<string, string | string[]> = {};
|
|
461
|
+
|
|
462
|
+
for (const field of fields) {
|
|
463
|
+
const value = await ui.input(
|
|
464
|
+
buildTextInputPromptTitle(request, field),
|
|
465
|
+
buildTextInputPlaceholder(field),
|
|
466
|
+
{ signal, ...(field.secure ? { secure: true } : {}) },
|
|
467
|
+
);
|
|
468
|
+
if (value === undefined) {
|
|
469
|
+
return { action: "cancel" };
|
|
470
|
+
}
|
|
471
|
+
content[field.id] = value;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
return { action: "accept", content };
|
|
475
|
+
}
|
|
476
|
+
|
|
358
477
|
export function createClaudeCodeElicitationHandler(
|
|
359
478
|
ui: ExtensionUIContext | undefined,
|
|
360
479
|
): ((request: SdkElicitationRequest, options: { signal: AbortSignal }) => Promise<SdkElicitationResult>) | undefined {
|
|
@@ -366,19 +485,24 @@ export function createClaudeCodeElicitationHandler(
|
|
|
366
485
|
}
|
|
367
486
|
|
|
368
487
|
const questions = parseAskUserQuestionsElicitation(request);
|
|
369
|
-
if (
|
|
370
|
-
|
|
488
|
+
if (questions) {
|
|
489
|
+
const interviewResult = await showInterviewRound(questions, { signal }, { ui } as any).catch(() => undefined);
|
|
490
|
+
if (interviewResult && Object.keys(interviewResult.answers).length > 0) {
|
|
491
|
+
return {
|
|
492
|
+
action: "accept",
|
|
493
|
+
content: roundResultToElicitationContent(questions, interviewResult),
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
return promptElicitationWithDialogs(request, questions, ui, signal);
|
|
371
498
|
}
|
|
372
499
|
|
|
373
|
-
const
|
|
374
|
-
if (
|
|
375
|
-
return
|
|
376
|
-
action: "accept",
|
|
377
|
-
content: roundResultToElicitationContent(questions, interviewResult),
|
|
378
|
-
};
|
|
500
|
+
const textFields = parseTextInputElicitation(request);
|
|
501
|
+
if (textFields) {
|
|
502
|
+
return promptTextInputElicitation(request, textFields, ui, signal);
|
|
379
503
|
}
|
|
380
504
|
|
|
381
|
-
return
|
|
505
|
+
return { action: "decline" };
|
|
382
506
|
};
|
|
383
507
|
}
|
|
384
508
|
|
|
@@ -508,15 +632,15 @@ export function extractToolResultsFromSdkUserMessage(message: SDKUserMessage): A
|
|
|
508
632
|
return extracted;
|
|
509
633
|
}
|
|
510
634
|
|
|
511
|
-
function
|
|
512
|
-
|
|
635
|
+
function attachExternalResultsToToolBlocks(
|
|
636
|
+
toolBlocks: AssistantMessage["content"],
|
|
513
637
|
toolResultsById: ReadonlyMap<string, ExternalToolResultPayload>,
|
|
514
638
|
): void {
|
|
515
|
-
for (const block of
|
|
516
|
-
if (block.type !== "toolCall") continue;
|
|
639
|
+
for (const block of toolBlocks) {
|
|
640
|
+
if (block.type !== "toolCall" && block.type !== "serverToolUse") continue;
|
|
517
641
|
const externalResult = toolResultsById.get(block.id);
|
|
518
642
|
if (!externalResult) continue;
|
|
519
|
-
(block as ToolCallWithExternalResult).externalResult = externalResult;
|
|
643
|
+
(block as ToolCallWithExternalResult & { id: string }).externalResult = externalResult;
|
|
520
644
|
}
|
|
521
645
|
}
|
|
522
646
|
|
|
@@ -554,8 +678,8 @@ async function pumpSdkMessages(
|
|
|
554
678
|
/** Track the last text content seen across all assistant turns for the final message. */
|
|
555
679
|
let lastTextContent = "";
|
|
556
680
|
let lastThinkingContent = "";
|
|
557
|
-
/** Collect tool
|
|
558
|
-
const
|
|
681
|
+
/** Collect tool blocks from intermediate SDK turns for tool execution rendering. */
|
|
682
|
+
const intermediateToolBlocks: AssistantMessage["content"] = [];
|
|
559
683
|
/** Preserve real external tool results from Claude Code's synthetic user messages. */
|
|
560
684
|
const toolResultsById = new Map<string, ExternalToolResultPayload>();
|
|
561
685
|
|
|
@@ -666,9 +790,9 @@ async function pumpSdkMessages(
|
|
|
666
790
|
lastTextContent = block.text;
|
|
667
791
|
} else if (block.type === "thinking" && block.thinking) {
|
|
668
792
|
lastThinkingContent = block.thinking;
|
|
669
|
-
} else if (block.type === "toolCall") {
|
|
670
|
-
// Collect tool
|
|
671
|
-
|
|
793
|
+
} else if (block.type === "toolCall" || block.type === "serverToolUse") {
|
|
794
|
+
// Collect tool blocks for externalToolExecution rendering
|
|
795
|
+
intermediateToolBlocks.push(block);
|
|
672
796
|
}
|
|
673
797
|
}
|
|
674
798
|
}
|
|
@@ -678,24 +802,33 @@ async function pumpSdkMessages(
|
|
|
678
802
|
for (const { toolUseId, result } of extractToolResultsFromSdkUserMessage(msg as SDKUserMessage)) {
|
|
679
803
|
toolResultsById.set(toolUseId, result);
|
|
680
804
|
}
|
|
681
|
-
|
|
805
|
+
attachExternalResultsToToolBlocks(intermediateToolBlocks, toolResultsById);
|
|
682
806
|
|
|
683
807
|
// Push a synthetic toolcall_end for each tool call from this turn
|
|
684
808
|
// so the TUI can render tool results in real-time during the SDK
|
|
685
809
|
// session instead of waiting until the entire session completes.
|
|
686
810
|
if (builder) {
|
|
687
811
|
for (const block of builder.message.content) {
|
|
688
|
-
if (block.type !== "toolCall") continue;
|
|
689
812
|
const extResult = (block as ToolCallWithExternalResult).externalResult;
|
|
690
813
|
if (!extResult) continue;
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
814
|
+
const contentIndex = builder.message.content.indexOf(block);
|
|
815
|
+
if (contentIndex < 0) continue;
|
|
816
|
+
// Push synthetic completion events with result attached so the
|
|
817
|
+
// chat-controller can update pending ToolExecutionComponents.
|
|
818
|
+
if (block.type === "toolCall") {
|
|
819
|
+
stream.push({
|
|
820
|
+
type: "toolcall_end",
|
|
821
|
+
contentIndex,
|
|
822
|
+
toolCall: block,
|
|
823
|
+
partial: builder.message,
|
|
824
|
+
});
|
|
825
|
+
} else if (block.type === "serverToolUse") {
|
|
826
|
+
stream.push({
|
|
827
|
+
type: "server_tool_use",
|
|
828
|
+
contentIndex,
|
|
829
|
+
partial: builder.message,
|
|
830
|
+
});
|
|
831
|
+
}
|
|
699
832
|
}
|
|
700
833
|
}
|
|
701
834
|
|
|
@@ -713,8 +846,8 @@ async function pumpSdkMessages(
|
|
|
713
846
|
const finalContent: AssistantMessage["content"] = [];
|
|
714
847
|
|
|
715
848
|
// Add tool calls from intermediate turns first (renders above text)
|
|
716
|
-
|
|
717
|
-
finalContent.push(...
|
|
849
|
+
attachExternalResultsToToolBlocks(intermediateToolBlocks, toolResultsById);
|
|
850
|
+
finalContent.push(...intermediateToolBlocks);
|
|
718
851
|
|
|
719
852
|
// Add text/thinking from the last turn
|
|
720
853
|
if (builder && builder.message.content.length > 0) {
|