@trenchwork/erosolar 1.1.32 → 1.1.34

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.
@@ -1,113 +0,0 @@
1
- /**
2
- * Adapter — Phase 5 of the Ink migration. Bridges the Ink App tree to
3
- * the rest of the codebase that imports PromptController.
4
- *
5
- * Goal: zero changes to interactiveShell.ts. When EROSOLAR_INK=1, the
6
- * factory returns an Ink-backed instance that satisfies the same
7
- * surface; otherwise it returns the existing PromptController. This is
8
- * the migration's safety valve — production keeps the old path until
9
- * we've grown enough Ink coverage to flip the default.
10
- *
11
- * The adapter is intentionally narrow today: it covers prompt input
12
- * + status + history + suggestions. Methods on PromptController that
13
- * we haven't ported yet (pinned prompt, secret-mode panels, the chrome
14
- * banner, etc.) are no-ops or fall through to a tiny event emitter so
15
- * existing callers don't crash. Each phase of the migration replaces
16
- * one of those no-ops with a real Ink-backed implementation.
17
- */
18
- import { EventEmitter } from 'node:events';
19
- /**
20
- * Returns true when the harness should mount the Ink-backed adapter.
21
- * Three signals — explicit env opt-in, never in plain mode, never under
22
- * a non-TTY pipe (Ink would refuse raw mode and crash).
23
- */
24
- export function shouldUseInkAdapter(opts) {
25
- if (opts.plainMode)
26
- return false;
27
- if (!opts.isTty)
28
- return false;
29
- const flag = (process.env['EROSOLAR_INK'] || '').toLowerCase();
30
- return flag === '1' || flag === 'true' || flag === 'on' || flag === 'yes';
31
- }
32
- /**
33
- * Construct a live adapter. The implementation lazy-imports the React +
34
- * Ink bundle so requiring this module from a non-Ink path doesn't pay
35
- * the parse cost — the production CLI only loads Ink when actually
36
- * mounting it.
37
- */
38
- export async function createInkPromptAdapter(callbacks) {
39
- // Lazy load — keeps Ink + React out of the cold-start path of every
40
- // process that imports the adapter type but doesn't mount it.
41
- const [{ render }, React, { App }] = await Promise.all([
42
- import('ink'),
43
- import('react'),
44
- import('./App.js'),
45
- ]);
46
- const events = new EventEmitter();
47
- let status = {};
48
- let history = [];
49
- let suggestions = [];
50
- let initialBuffer = '';
51
- let inst = null;
52
- let enabled = true;
53
- const buildTree = () => React.createElement(App, {
54
- history,
55
- status: { message: status.message ?? null, modeMessage: status.modeMessage ?? null },
56
- suggestions,
57
- prompt: {
58
- initial: initialBuffer,
59
- onSubmit: (text) => callbacks.onSubmit(text),
60
- onCancel: () => {
61
- callbacks.onCtrlC?.({ hadBuffer: false });
62
- callbacks.onCancel?.();
63
- },
64
- },
65
- });
66
- const rerender = () => {
67
- if (!inst)
68
- return;
69
- inst.rerender(buildTree());
70
- };
71
- const adapter = Object.assign(events, {
72
- enabled,
73
- start() {
74
- if (inst)
75
- return;
76
- inst = render(buildTree(), {
77
- // exitOnCtrlC=false so the host gets Ctrl+C through onCancel.
78
- exitOnCtrlC: false,
79
- });
80
- },
81
- stop() {
82
- if (!inst)
83
- return;
84
- try {
85
- inst.unmount();
86
- }
87
- catch { /* ignore */ }
88
- inst = null;
89
- },
90
- setStatusMessage(message) {
91
- status = { ...status, message };
92
- rerender();
93
- },
94
- setModeMessage(message) {
95
- status = { ...status, modeMessage: message };
96
- rerender();
97
- },
98
- appendHistory(item) {
99
- history = [...history, item];
100
- rerender();
101
- },
102
- setSuggestions(next) {
103
- suggestions = next;
104
- rerender();
105
- },
106
- setBuffer(text) {
107
- initialBuffer = text;
108
- rerender();
109
- },
110
- });
111
- return adapter;
112
- }
113
- //# sourceMappingURL=adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/ui/ink/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAsB3C;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAA4C;IAC9E,IAAI,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IACjC,IAAI,CAAC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAC9B,MAAM,IAA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