@illuminis/comprism 0.1.3 → 0.1.5

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.
Files changed (142) hide show
  1. package/README.md +61 -2
  2. package/out/agent/command.d.ts +75 -4
  3. package/out/agent/command.js +221 -26
  4. package/out/agent/render.d.ts +56 -8
  5. package/out/agent/render.js +441 -39
  6. package/out/agent/session.d.ts +156 -2
  7. package/out/agent/session.js +795 -154
  8. package/out/commands/agents.d.ts +2 -0
  9. package/out/commands/agents.js +79 -0
  10. package/out/commands/ask.d.ts +1 -1
  11. package/out/commands/ask.js +88 -12
  12. package/out/commands/commands-thin.js +79 -17
  13. package/out/commands/config.d.ts +1 -0
  14. package/out/commands/config.js +138 -0
  15. package/out/commands/cost.d.ts +1 -0
  16. package/out/commands/cost.js +167 -0
  17. package/out/commands/hooks.d.ts +1 -0
  18. package/out/commands/hooks.js +83 -0
  19. package/out/commands/install.d.ts +44 -1
  20. package/out/commands/install.js +198 -4
  21. package/out/commands/instructions.d.ts +1 -0
  22. package/out/commands/instructions.js +113 -0
  23. package/out/commands/integrations.d.ts +3 -0
  24. package/out/commands/integrations.js +215 -0
  25. package/out/commands/jobs.d.ts +5 -0
  26. package/out/commands/jobs.js +157 -0
  27. package/out/commands/login.js +249 -43
  28. package/out/commands/memory.d.ts +3 -0
  29. package/out/commands/memory.js +113 -0
  30. package/out/commands/permissions.d.ts +1 -0
  31. package/out/commands/permissions.js +94 -0
  32. package/out/commands/plugins.d.ts +4 -0
  33. package/out/commands/plugins.js +192 -0
  34. package/out/commands/privacy.d.ts +1 -0
  35. package/out/commands/privacy.js +57 -0
  36. package/out/commands/providerKey.d.ts +32 -0
  37. package/out/commands/providerKey.js +108 -0
  38. package/out/commands/repl.d.ts +12 -1
  39. package/out/commands/repl.js +1649 -122
  40. package/out/commands/report.d.ts +39 -0
  41. package/out/commands/report.js +115 -0
  42. package/out/commands/review.d.ts +5 -0
  43. package/out/commands/review.js +223 -0
  44. package/out/commands/sessions.d.ts +23 -0
  45. package/out/commands/sessions.js +115 -0
  46. package/out/commands/settings.d.ts +3 -1
  47. package/out/commands/settings.js +18 -16
  48. package/out/commands/skills.d.ts +21 -0
  49. package/out/commands/skills.js +207 -0
  50. package/out/commands/unattended.d.ts +7 -0
  51. package/out/commands/unattended.js +351 -0
  52. package/out/commands/update.d.ts +1 -0
  53. package/out/commands/update.js +123 -0
  54. package/out/commands/welcome.d.ts +25 -1
  55. package/out/commands/welcome.js +71 -35
  56. package/out/commands/worktrees.d.ts +5 -0
  57. package/out/commands/worktrees.js +186 -0
  58. package/out/executor/browser.d.ts +14 -0
  59. package/out/executor/browser.js +270 -0
  60. package/out/executor/diagnostics.d.ts +2 -0
  61. package/out/executor/diagnostics.js +181 -0
  62. package/out/executor/files.js +270 -40
  63. package/out/executor/git.js +42 -29
  64. package/out/executor/hooks.d.ts +42 -58
  65. package/out/executor/hooks.js +89 -182
  66. package/out/executor/index.d.ts +21 -5
  67. package/out/executor/index.js +160 -14
  68. package/out/executor/paths.d.ts +6 -1
  69. package/out/executor/paths.js +34 -6
  70. package/out/executor/sandbox.d.ts +40 -0
  71. package/out/executor/sandbox.js +299 -0
  72. package/out/executor/shell.d.ts +49 -4
  73. package/out/executor/shell.js +302 -56
  74. package/out/executor/toolservers.d.ts +20 -0
  75. package/out/executor/toolservers.js +189 -0
  76. package/out/executor/worktree.d.ts +9 -0
  77. package/out/executor/worktree.js +119 -0
  78. package/out/graph/read-python.js +2 -1
  79. package/out/lib/attach.d.ts +56 -12
  80. package/out/lib/attach.js +230 -63
  81. package/out/lib/clipboard.d.ts +23 -0
  82. package/out/lib/clipboard.js +182 -0
  83. package/out/lib/commandlist.d.ts +20 -0
  84. package/out/lib/commandlist.js +58 -0
  85. package/out/lib/decision.d.ts +22 -0
  86. package/out/lib/decision.js +50 -0
  87. package/out/lib/fingerprint.d.ts +25 -0
  88. package/out/lib/fingerprint.js +58 -0
  89. package/out/lib/gateway.d.ts +190 -2
  90. package/out/lib/gateway.js +59 -4
  91. package/out/lib/history.d.ts +24 -0
  92. package/out/lib/history.js +137 -0
  93. package/out/lib/ide.d.ts +19 -0
  94. package/out/lib/ide.js +131 -0
  95. package/out/lib/keyboard.d.ts +98 -0
  96. package/out/lib/keyboard.js +390 -0
  97. package/out/lib/lastlogin.d.ts +14 -0
  98. package/out/lib/lastlogin.js +105 -0
  99. package/out/lib/machine.d.ts +21 -0
  100. package/out/lib/machine.js +91 -0
  101. package/out/lib/notify.d.ts +4 -0
  102. package/out/lib/notify.js +52 -0
  103. package/out/lib/output.d.ts +48 -0
  104. package/out/lib/output.js +108 -0
  105. package/out/lib/picker.d.ts +1 -0
  106. package/out/lib/picker.js +158 -0
  107. package/out/lib/project-ops.d.ts +19 -0
  108. package/out/lib/project-ops.js +146 -0
  109. package/out/lib/project.d.ts +28 -0
  110. package/out/lib/project.js +114 -0
  111. package/out/lib/prompt.d.ts +3 -0
  112. package/out/lib/prompt.js +36 -2
  113. package/out/lib/queue.d.ts +13 -0
  114. package/out/lib/queue.js +116 -0
  115. package/out/lib/readiness.d.ts +19 -0
  116. package/out/lib/readiness.js +170 -1
  117. package/out/lib/self.d.ts +23 -0
  118. package/out/lib/self.js +124 -0
  119. package/out/lib/sessions.d.ts +19 -0
  120. package/out/lib/sessions.js +221 -0
  121. package/out/lib/startcache.d.ts +13 -0
  122. package/out/lib/startcache.js +78 -0
  123. package/out/lib/stdin.d.ts +32 -0
  124. package/out/lib/stdin.js +117 -0
  125. package/out/lib/store.d.ts +40 -0
  126. package/out/lib/store.js +138 -0
  127. package/out/lib/sync.d.ts +18 -0
  128. package/out/lib/sync.js +81 -0
  129. package/out/lib/ui.d.ts +10 -4
  130. package/out/lib/ui.js +65 -25
  131. package/out/lib/voice.d.ts +36 -0
  132. package/out/lib/voice.js +160 -1
  133. package/out/native/dictate +0 -0
  134. package/out/postinstall.js +42 -17
  135. package/out/providers/anthropic.d.ts +22 -0
  136. package/out/providers/anthropic.js +80 -0
  137. package/out/providers/index.d.ts +8 -0
  138. package/out/providers/index.js +83 -0
  139. package/out/providers/openai.d.ts +11 -0
  140. package/out/providers/openai.js +57 -0
  141. package/out/thin.js +595 -33
  142. package/package.json +11 -50
@@ -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;
@@ -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,98 @@
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
+ /** The command list under the prompt (manual 6.4): Up, Down, Enter and Tab
51
+ * go to it while it is showing. Returns true when it used the key. */
52
+ onMenuKey: ((key: 'up' | 'down' | 'enter' | 'tab') => boolean) | null;
53
+ /** Ctrl+O, the short or full view (manual 6.9). */
54
+ onFullView: (() => void) | null;
55
+ /** Ctrl+G, the request in your own editor (manual 6.6). */
56
+ onEditor: (() => void) | null;
57
+ /** Ctrl+V, the clipboard's picture, where the terminal passes it (3.4). */
58
+ onPasteImage: (() => void) | null;
59
+ /** `keys vi` (manual 6.10): Esc at the prompt enters normal mode. */
60
+ vi: boolean;
61
+ private normal;
62
+ private pendingD;
63
+ /** `history` is the session's earlier requests, newest first, as shown. */
64
+ constructor(history: () => string[]);
65
+ /** The reader whose line a search edits. */
66
+ bind(reader: readline.Interface | null): void;
67
+ /**
68
+ * Start reading the keyboard. Raw, because the reader no longer holds the
69
+ * keyboard itself and so cannot switch it; bracketed, so the terminal marks
70
+ * where a paste begins and ends.
71
+ */
72
+ attach(): void;
73
+ /**
74
+ * Stop reading, and give the keyboard back exactly as it was found, for a
75
+ * command that asks its own question and for the shell afterwards. A shell
76
+ * left with bracketed paste on prints markers around everything pasted.
77
+ */
78
+ detach(): void;
79
+ /** True once after Alt+Enter, so the line just ended continues the request. */
80
+ takeContinued(): boolean;
81
+ /** The request as it will be sent: every paste label swapped for its text,
82
+ * and every shown line break made a real one again. */
83
+ expand(text: string): string;
84
+ /** Feed raw keyboard text. Public so a test can type without a terminal. */
85
+ take(s: string): void;
86
+ private forward;
87
+ /** Typing, outside a bracketed paste. */
88
+ private keys;
89
+ private paste;
90
+ private viKeys;
91
+ private editable;
92
+ private startSearch;
93
+ private match;
94
+ private drawSearch;
95
+ private setLine;
96
+ private endSearch;
97
+ private searchKeys;
98
+ }