@illuminis/comprism 0.1.3 → 0.1.4
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/README.md +61 -2
- package/out/agent/command.d.ts +75 -4
- package/out/agent/command.js +220 -25
- package/out/agent/render.d.ts +17 -2
- package/out/agent/render.js +157 -14
- package/out/agent/session.d.ts +141 -2
- package/out/agent/session.js +735 -149
- package/out/commands/agents.d.ts +2 -0
- package/out/commands/agents.js +79 -0
- package/out/commands/ask.d.ts +1 -1
- package/out/commands/ask.js +78 -11
- package/out/commands/commands-thin.js +79 -17
- package/out/commands/config.d.ts +1 -0
- package/out/commands/config.js +138 -0
- package/out/commands/cost.d.ts +1 -0
- package/out/commands/cost.js +167 -0
- package/out/commands/hooks.d.ts +1 -0
- package/out/commands/hooks.js +83 -0
- package/out/commands/install.d.ts +44 -1
- package/out/commands/install.js +198 -4
- package/out/commands/instructions.d.ts +1 -0
- package/out/commands/instructions.js +113 -0
- package/out/commands/integrations.d.ts +3 -0
- package/out/commands/integrations.js +215 -0
- package/out/commands/jobs.d.ts +5 -0
- package/out/commands/jobs.js +157 -0
- package/out/commands/login.js +188 -36
- package/out/commands/memory.d.ts +3 -0
- package/out/commands/memory.js +113 -0
- package/out/commands/permissions.d.ts +1 -0
- package/out/commands/permissions.js +94 -0
- package/out/commands/plugins.d.ts +4 -0
- package/out/commands/plugins.js +192 -0
- package/out/commands/privacy.d.ts +1 -0
- package/out/commands/privacy.js +57 -0
- package/out/commands/providerKey.d.ts +32 -0
- package/out/commands/providerKey.js +108 -0
- package/out/commands/repl.d.ts +8 -1
- package/out/commands/repl.js +1207 -118
- package/out/commands/report.d.ts +39 -0
- package/out/commands/report.js +115 -0
- package/out/commands/review.d.ts +5 -0
- package/out/commands/review.js +223 -0
- package/out/commands/sessions.d.ts +23 -0
- package/out/commands/sessions.js +115 -0
- package/out/commands/settings.d.ts +3 -1
- package/out/commands/settings.js +18 -16
- package/out/commands/skills.d.ts +21 -0
- package/out/commands/skills.js +207 -0
- package/out/commands/unattended.d.ts +7 -0
- package/out/commands/unattended.js +351 -0
- package/out/commands/update.d.ts +1 -0
- package/out/commands/update.js +123 -0
- package/out/commands/worktrees.d.ts +5 -0
- package/out/commands/worktrees.js +186 -0
- package/out/executor/browser.d.ts +14 -0
- package/out/executor/browser.js +270 -0
- package/out/executor/diagnostics.d.ts +2 -0
- package/out/executor/diagnostics.js +181 -0
- package/out/executor/files.js +270 -40
- package/out/executor/git.js +42 -29
- package/out/executor/hooks.d.ts +42 -58
- package/out/executor/hooks.js +89 -182
- package/out/executor/index.d.ts +21 -5
- package/out/executor/index.js +160 -14
- package/out/executor/paths.d.ts +6 -1
- package/out/executor/paths.js +34 -6
- package/out/executor/sandbox.d.ts +40 -0
- package/out/executor/sandbox.js +299 -0
- package/out/executor/shell.d.ts +49 -4
- package/out/executor/shell.js +302 -56
- package/out/executor/toolservers.d.ts +20 -0
- package/out/executor/toolservers.js +189 -0
- package/out/executor/worktree.d.ts +9 -0
- package/out/executor/worktree.js +119 -0
- package/out/graph/read-python.js +2 -1
- package/out/lib/attach.d.ts +56 -12
- package/out/lib/attach.js +230 -63
- package/out/lib/clipboard.d.ts +23 -0
- package/out/lib/clipboard.js +182 -0
- package/out/lib/commandlist.d.ts +20 -0
- package/out/lib/commandlist.js +58 -0
- package/out/lib/decision.d.ts +22 -0
- package/out/lib/decision.js +50 -0
- package/out/lib/fingerprint.d.ts +25 -0
- package/out/lib/fingerprint.js +58 -0
- package/out/lib/gateway.d.ts +186 -2
- package/out/lib/gateway.js +59 -4
- package/out/lib/history.d.ts +24 -0
- package/out/lib/history.js +137 -0
- package/out/lib/ide.d.ts +19 -0
- package/out/lib/ide.js +131 -0
- package/out/lib/keyboard.d.ts +95 -0
- package/out/lib/keyboard.js +383 -0
- package/out/lib/machine.d.ts +21 -0
- package/out/lib/machine.js +91 -0
- package/out/lib/notify.d.ts +4 -0
- package/out/lib/notify.js +52 -0
- package/out/lib/output.d.ts +48 -0
- package/out/lib/output.js +108 -0
- package/out/lib/project-ops.d.ts +19 -0
- package/out/lib/project-ops.js +146 -0
- package/out/lib/project.d.ts +28 -0
- package/out/lib/project.js +114 -0
- package/out/lib/prompt.js +15 -2
- package/out/lib/queue.d.ts +13 -0
- package/out/lib/queue.js +116 -0
- package/out/lib/readiness.d.ts +19 -0
- package/out/lib/readiness.js +170 -1
- package/out/lib/self.d.ts +23 -0
- package/out/lib/self.js +124 -0
- package/out/lib/sessions.d.ts +19 -0
- package/out/lib/sessions.js +221 -0
- package/out/lib/stdin.d.ts +32 -0
- package/out/lib/stdin.js +117 -0
- package/out/lib/store.d.ts +40 -0
- package/out/lib/store.js +138 -0
- package/out/lib/sync.d.ts +18 -0
- package/out/lib/sync.js +81 -0
- package/out/lib/ui.d.ts +2 -4
- package/out/lib/ui.js +31 -25
- package/out/lib/voice.js +24 -0
- package/out/postinstall.js +42 -17
- package/out/providers/anthropic.d.ts +22 -0
- package/out/providers/anthropic.js +80 -0
- package/out/providers/index.d.ts +8 -0
- package/out/providers/index.js +83 -0
- package/out/providers/openai.d.ts +11 -0
- package/out/providers/openai.js +57 -0
- package/out/thin.js +594 -32
- package/package.json +9 -49
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.History = void 0;
|
|
37
|
+
exports.historyFile = historyFile;
|
|
38
|
+
/**
|
|
39
|
+
* Earlier requests, for Up, Down and Ctrl+R (manual 6.5).
|
|
40
|
+
*
|
|
41
|
+
* Always kept in memory for the session. Kept on this machine between sessions
|
|
42
|
+
* only when the service says the company lets prompt text be kept, and then in
|
|
43
|
+
* one file, `history` in the tool's own folder, readable by this account only.
|
|
44
|
+
* When the company does not, the file is removed at the start and at the end of
|
|
45
|
+
* the session, so a rule changed by an administrator is honored by the next
|
|
46
|
+
* session without anybody deleting anything by hand.
|
|
47
|
+
*
|
|
48
|
+
* The decision is the service's (`commands` intent, `keep_history`). This file
|
|
49
|
+
* only does what it was told.
|
|
50
|
+
*/
|
|
51
|
+
const fs = __importStar(require("node:fs"));
|
|
52
|
+
const path = __importStar(require("node:path"));
|
|
53
|
+
const config_1 = require("./config");
|
|
54
|
+
const keyboard_1 = require("./keyboard");
|
|
55
|
+
/** How many requests are remembered. */
|
|
56
|
+
const MAX_ENTRIES = 500;
|
|
57
|
+
/** A request longer than this is remembered for the session only. A 1,000
|
|
58
|
+
* line paste is not something to replay from a file next week. */
|
|
59
|
+
const MAX_SAVED_CHARS = 4000;
|
|
60
|
+
function historyFile() {
|
|
61
|
+
return path.join((0, config_1.homeDir)(), 'history');
|
|
62
|
+
}
|
|
63
|
+
class History {
|
|
64
|
+
/** Newest first, as shown on the prompt line. Shared with the reader, which
|
|
65
|
+
* walks it with Up and Down. */
|
|
66
|
+
entries = [];
|
|
67
|
+
/** Newest first, as sent. What the file holds. */
|
|
68
|
+
saved = [];
|
|
69
|
+
/** The company's rule: true keeps, false removes, null (the service could
|
|
70
|
+
* not be asked) keeps this session's requests in memory and leaves any
|
|
71
|
+
* file exactly as it is. */
|
|
72
|
+
keep = null;
|
|
73
|
+
/** Begin a session under the company's rule. */
|
|
74
|
+
start(keep) {
|
|
75
|
+
this.keep = keep;
|
|
76
|
+
if (keep === false)
|
|
77
|
+
this.remove();
|
|
78
|
+
if (keep !== true)
|
|
79
|
+
return;
|
|
80
|
+
try {
|
|
81
|
+
const lines = fs.readFileSync(historyFile(), 'utf8').split('\n').filter(Boolean);
|
|
82
|
+
for (const line of lines) {
|
|
83
|
+
try {
|
|
84
|
+
const text = JSON.parse(line);
|
|
85
|
+
if (typeof text === 'string')
|
|
86
|
+
this.saved.push(text);
|
|
87
|
+
}
|
|
88
|
+
catch { /* a damaged line is skipped, not fatal */ }
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch { /* no file yet */ }
|
|
92
|
+
this.saved = this.saved.slice(0, MAX_ENTRIES);
|
|
93
|
+
this.entries.splice(0, this.entries.length, ...this.saved.map(keyboard_1.asOneLine));
|
|
94
|
+
}
|
|
95
|
+
off = false;
|
|
96
|
+
/** `history off`: nothing is remembered, in memory or on disk. */
|
|
97
|
+
disable() {
|
|
98
|
+
this.off = true;
|
|
99
|
+
this.entries.splice(0);
|
|
100
|
+
}
|
|
101
|
+
/** Remember one request. `shown` is how it looked at the prompt, paste
|
|
102
|
+
* labels included; `sent` is what was sent. */
|
|
103
|
+
add(shown, sent) {
|
|
104
|
+
const line = (0, keyboard_1.asOneLine)(shown).trim();
|
|
105
|
+
if (!line || this.off)
|
|
106
|
+
return;
|
|
107
|
+
const at = this.entries.indexOf(line);
|
|
108
|
+
if (at !== -1)
|
|
109
|
+
this.entries.splice(at, 1);
|
|
110
|
+
this.entries.unshift(line);
|
|
111
|
+
this.entries.splice(MAX_ENTRIES);
|
|
112
|
+
if (this.keep !== true || sent.length > MAX_SAVED_CHARS)
|
|
113
|
+
return;
|
|
114
|
+
this.saved = [sent, ...this.saved.filter((s) => s !== sent)].slice(0, MAX_ENTRIES);
|
|
115
|
+
this.write();
|
|
116
|
+
}
|
|
117
|
+
/** End the session. Without permission to keep, nothing is left behind. */
|
|
118
|
+
finish() {
|
|
119
|
+
if (this.keep === false)
|
|
120
|
+
this.remove();
|
|
121
|
+
}
|
|
122
|
+
write() {
|
|
123
|
+
try {
|
|
124
|
+
fs.mkdirSync((0, config_1.homeDir)(), { recursive: true, mode: 0o700 });
|
|
125
|
+
const body = this.saved.map((s) => JSON.stringify(s)).join('\n') + '\n';
|
|
126
|
+
fs.writeFileSync(historyFile(), body, { mode: 0o600 });
|
|
127
|
+
}
|
|
128
|
+
catch { /* a history that could not be written costs typing, nothing more */ }
|
|
129
|
+
}
|
|
130
|
+
remove() {
|
|
131
|
+
try {
|
|
132
|
+
fs.rmSync(historyFile(), { force: true });
|
|
133
|
+
}
|
|
134
|
+
catch { /* already gone */ }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.History = History;
|
package/out/lib/ide.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface EditorLink {
|
|
2
|
+
folder: string;
|
|
3
|
+
context(): Promise<{
|
|
4
|
+
file?: string;
|
|
5
|
+
selection?: {
|
|
6
|
+
text: string;
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
9
|
+
};
|
|
10
|
+
problems?: string[];
|
|
11
|
+
} | null>;
|
|
12
|
+
diff(name: string, input: Record<string, unknown>): Promise<void>;
|
|
13
|
+
open(file: string, line?: number): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare function lockFolder(): string;
|
|
16
|
+
/** The VS Code window whose folder holds `root`, if one is running. */
|
|
17
|
+
export declare function findEditor(root: string): EditorLink | null;
|
|
18
|
+
/** The selected lines, as the panel sends them (VS Code manual 3.3). */
|
|
19
|
+
export declare function selectionText(ctx: Awaited<ReturnType<EditorLink["context"]>>): string;
|
package/out/lib/ide.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.lockFolder = lockFolder;
|
|
37
|
+
exports.findEditor = findEditor;
|
|
38
|
+
exports.selectionText = selectionText;
|
|
39
|
+
/**
|
|
40
|
+
* The terminal tool, joined to a VS Code window (VS Code manual 9.12).
|
|
41
|
+
*
|
|
42
|
+
* When the CompletionPrism extension is running it leaves a small file in
|
|
43
|
+
* `~/.completionprism/ide/` naming a port on this machine and a secret. This
|
|
44
|
+
* finds the file for the folder the job is in, and asks that window three
|
|
45
|
+
* things: what is open and selected, to show a proposed change in its diff
|
|
46
|
+
* view, and to open a file at a line.
|
|
47
|
+
*
|
|
48
|
+
* It is CompletionPrism's own connection: its own folder, its own secret, only
|
|
49
|
+
* this user's files. It never looks for, or speaks to, another tool's editor
|
|
50
|
+
* connection.
|
|
51
|
+
*/
|
|
52
|
+
const fs = __importStar(require("fs"));
|
|
53
|
+
const os = __importStar(require("os"));
|
|
54
|
+
const path = __importStar(require("path"));
|
|
55
|
+
function alive(pid) {
|
|
56
|
+
try {
|
|
57
|
+
process.kill(pid, 0);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function lockFolder() {
|
|
65
|
+
return path.join(os.homedir(), ".completionprism", "ide");
|
|
66
|
+
}
|
|
67
|
+
/** The VS Code window whose folder holds `root`, if one is running. */
|
|
68
|
+
function findEditor(root) {
|
|
69
|
+
let names = [];
|
|
70
|
+
try {
|
|
71
|
+
names = fs.readdirSync(lockFolder()).filter((n) => n.endsWith(".json"));
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const here = path.resolve(root);
|
|
77
|
+
for (const name of names) {
|
|
78
|
+
let lock;
|
|
79
|
+
try {
|
|
80
|
+
lock = JSON.parse(fs.readFileSync(path.join(lockFolder(), name), "utf8"));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (!lock.port || !lock.token || !alive(lock.pid))
|
|
86
|
+
continue;
|
|
87
|
+
const folder = lock.folders.find((f) => here === f || here.startsWith(f + path.sep));
|
|
88
|
+
if (!folder)
|
|
89
|
+
continue;
|
|
90
|
+
const call = async (what, body) => {
|
|
91
|
+
const res = await fetch(`http://127.0.0.1:${lock.port}/${what}`, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers: { "content-type": "application/json", "x-completionprism-token": lock.token },
|
|
94
|
+
body: JSON.stringify(body),
|
|
95
|
+
signal: AbortSignal.timeout(2000),
|
|
96
|
+
});
|
|
97
|
+
return res.ok ? res.json() : null;
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
folder,
|
|
101
|
+
context: async () => {
|
|
102
|
+
try {
|
|
103
|
+
return (await call("context", {}));
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
diff: async (tool, input) => {
|
|
110
|
+
try {
|
|
111
|
+
await call("diff", { name: tool, input, root: here });
|
|
112
|
+
}
|
|
113
|
+
catch { /* the terminal still shows it */ }
|
|
114
|
+
},
|
|
115
|
+
open: async (file, line) => {
|
|
116
|
+
try {
|
|
117
|
+
await call("open", { path: file, line, root: here });
|
|
118
|
+
}
|
|
119
|
+
catch { /* nothing to open it in */ }
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
/** The selected lines, as the panel sends them (VS Code manual 3.3). */
|
|
126
|
+
function selectionText(ctx) {
|
|
127
|
+
if (!ctx?.selection?.text || !ctx.file)
|
|
128
|
+
return "";
|
|
129
|
+
const { from, to, text } = ctx.selection;
|
|
130
|
+
return `\n\nSelected lines ${from} to ${to} of ${ctx.file}:\n\`\`\`\n${text}\n\`\`\``;
|
|
131
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The keystrokes a session's reader never sees on their own (manual 6.2, 6.3,
|
|
3
|
+
* 6.5).
|
|
4
|
+
*
|
|
5
|
+
* Node's line reader edits one line well and knows nothing about a paste: every
|
|
6
|
+
* line break inside a pasted stack trace reached it as Enter, so a 240 line
|
|
7
|
+
* paste was sent as 240 requests, each billed. It also has no Alt+Enter and no
|
|
8
|
+
* search of earlier requests.
|
|
9
|
+
*
|
|
10
|
+
* So the session's reader reads from this filter instead of from the keyboard.
|
|
11
|
+
* The filter passes ordinary typing straight through and handles four things
|
|
12
|
+
* itself:
|
|
13
|
+
*
|
|
14
|
+
* * A paste, bracketed by the terminal, becomes one piece of the request. The
|
|
15
|
+
* reader is given a short label, `[pasted 240 lines]`, that can be edited
|
|
16
|
+
* around like any word, and the label is swapped back for the exact text,
|
|
17
|
+
* tabs and trailing spaces included, when the request is sent.
|
|
18
|
+
* * A terminal that does not bracket pastes still delivers a paste in one read,
|
|
19
|
+
* so several lines arriving in one read are treated the same way. A person
|
|
20
|
+
* typing never produces a line break followed by more text in one read.
|
|
21
|
+
* * Alt+Enter continues the request on a new line, exactly as `\` then Enter.
|
|
22
|
+
* * Ctrl+R searches earlier requests; Enter puts the match at the prompt to be
|
|
23
|
+
* edited or sent, and Esc or Ctrl+C puts back what was there.
|
|
24
|
+
*
|
|
25
|
+
* Nothing here is written anywhere. Pieces live in memory for the session.
|
|
26
|
+
*/
|
|
27
|
+
import { PassThrough } from 'node:stream';
|
|
28
|
+
import type readline from 'node:readline';
|
|
29
|
+
/** Stands for a line break inside a request shown on one line, such as a
|
|
30
|
+
* recalled request. Turned back into a line break when it is sent. */
|
|
31
|
+
export declare const LINE_BREAK = "\u2424";
|
|
32
|
+
/** A request as it is shown on one editable line. */
|
|
33
|
+
export declare function asOneLine(text: string): string;
|
|
34
|
+
export declare class Keyboard {
|
|
35
|
+
private readonly history;
|
|
36
|
+
/** What the session's reader reads. */
|
|
37
|
+
readonly input: PassThrough;
|
|
38
|
+
private readonly decoder;
|
|
39
|
+
private pieces;
|
|
40
|
+
private pasting;
|
|
41
|
+
private carry;
|
|
42
|
+
private continued;
|
|
43
|
+
private search;
|
|
44
|
+
private reader;
|
|
45
|
+
private listening;
|
|
46
|
+
private readonly onData;
|
|
47
|
+
/** Esc on its own (manual 6.7). Returns true when it was used, so the key
|
|
48
|
+
* goes no further; false passes it to the reader as before. */
|
|
49
|
+
onEscape: (() => boolean) | null;
|
|
50
|
+
/** Ctrl+O, the short or full view (manual 6.9). */
|
|
51
|
+
onFullView: (() => void) | null;
|
|
52
|
+
/** Ctrl+G, the request in your own editor (manual 6.6). */
|
|
53
|
+
onEditor: (() => void) | null;
|
|
54
|
+
/** Ctrl+V, the clipboard's picture, where the terminal passes it (3.4). */
|
|
55
|
+
onPasteImage: (() => void) | null;
|
|
56
|
+
/** `keys vi` (manual 6.10): Esc at the prompt enters normal mode. */
|
|
57
|
+
vi: boolean;
|
|
58
|
+
private normal;
|
|
59
|
+
private pendingD;
|
|
60
|
+
/** `history` is the session's earlier requests, newest first, as shown. */
|
|
61
|
+
constructor(history: () => string[]);
|
|
62
|
+
/** The reader whose line a search edits. */
|
|
63
|
+
bind(reader: readline.Interface | null): void;
|
|
64
|
+
/**
|
|
65
|
+
* Start reading the keyboard. Raw, because the reader no longer holds the
|
|
66
|
+
* keyboard itself and so cannot switch it; bracketed, so the terminal marks
|
|
67
|
+
* where a paste begins and ends.
|
|
68
|
+
*/
|
|
69
|
+
attach(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Stop reading, and give the keyboard back exactly as it was found, for a
|
|
72
|
+
* command that asks its own question and for the shell afterwards. A shell
|
|
73
|
+
* left with bracketed paste on prints markers around everything pasted.
|
|
74
|
+
*/
|
|
75
|
+
detach(): void;
|
|
76
|
+
/** True once after Alt+Enter, so the line just ended continues the request. */
|
|
77
|
+
takeContinued(): boolean;
|
|
78
|
+
/** The request as it will be sent: every paste label swapped for its text,
|
|
79
|
+
* and every shown line break made a real one again. */
|
|
80
|
+
expand(text: string): string;
|
|
81
|
+
/** Feed raw keyboard text. Public so a test can type without a terminal. */
|
|
82
|
+
take(s: string): void;
|
|
83
|
+
private forward;
|
|
84
|
+
/** Typing, outside a bracketed paste. */
|
|
85
|
+
private keys;
|
|
86
|
+
private paste;
|
|
87
|
+
private viKeys;
|
|
88
|
+
private editable;
|
|
89
|
+
private startSearch;
|
|
90
|
+
private match;
|
|
91
|
+
private drawSearch;
|
|
92
|
+
private setLine;
|
|
93
|
+
private endSearch;
|
|
94
|
+
private searchKeys;
|
|
95
|
+
}
|