govon 1.3.0 → 1.4.1
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/bin/govon.js +2 -41
- package/dist/App.d.ts +22 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +307 -0
- package/dist/App.js.map +1 -0
- package/dist/client.d.ts +102 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +332 -0
- package/dist/client.js.map +1 -0
- package/dist/components/ApprovalPrompt.d.ts +15 -0
- package/dist/components/ApprovalPrompt.d.ts.map +1 -0
- package/dist/components/ApprovalPrompt.js +35 -0
- package/dist/components/ApprovalPrompt.js.map +1 -0
- package/dist/components/Banner.d.ts +6 -0
- package/dist/components/Banner.d.ts.map +1 -0
- package/dist/components/Banner.js +27 -0
- package/dist/components/Banner.js.map +1 -0
- package/dist/components/InputBar.d.ts +8 -0
- package/dist/components/InputBar.d.ts.map +1 -0
- package/dist/components/InputBar.js +26 -0
- package/dist/components/InputBar.js.map +1 -0
- package/dist/components/MarkdownView.d.ts +9 -0
- package/dist/components/MarkdownView.d.ts.map +1 -0
- package/dist/components/MarkdownView.js +38 -0
- package/dist/components/MarkdownView.js.map +1 -0
- package/dist/components/MessageBubble.d.ts +14 -0
- package/dist/components/MessageBubble.d.ts.map +1 -0
- package/dist/components/MessageBubble.js +15 -0
- package/dist/components/MessageBubble.js.map +1 -0
- package/dist/components/MetadataBar.d.ts +7 -0
- package/dist/components/MetadataBar.d.ts.map +1 -0
- package/dist/components/MetadataBar.js +19 -0
- package/dist/components/MetadataBar.js.map +1 -0
- package/dist/components/Spinner.d.ts +7 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +51 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/ThinkingBlock.d.ts +9 -0
- package/dist/components/ThinkingBlock.d.ts.map +1 -0
- package/dist/components/ThinkingBlock.js +9 -0
- package/dist/components/ThinkingBlock.js.map +1 -0
- package/dist/components/ToolPanel.d.ts +7 -0
- package/dist/components/ToolPanel.d.ts.map +1 -0
- package/dist/components/ToolPanel.js +19 -0
- package/dist/components/ToolPanel.js.map +1 -0
- package/dist/config.d.ts +32 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +64 -0
- package/dist/config.js.map +1 -0
- package/dist/data/spinnerVerbs.d.ts +7 -0
- package/dist/data/spinnerVerbs.d.ts.map +1 -0
- package/dist/data/spinnerVerbs.js +58 -0
- package/dist/data/spinnerVerbs.js.map +1 -0
- package/dist/hooks/useDaemon.d.ts +16 -0
- package/dist/hooks/useDaemon.d.ts.map +1 -0
- package/dist/hooks/useDaemon.js +55 -0
- package/dist/hooks/useDaemon.js.map +1 -0
- package/dist/hooks/useHistory.d.ts +13 -0
- package/dist/hooks/useHistory.d.ts.map +1 -0
- package/dist/hooks/useHistory.js +170 -0
- package/dist/hooks/useHistory.js.map +1 -0
- package/dist/hooks/useSSE.d.ts +29 -0
- package/dist/hooks/useSSE.d.ts.map +1 -0
- package/dist/hooks/useSSE.js +341 -0
- package/dist/hooks/useSSE.js.map +1 -0
- package/dist/hooks/useTheme.d.ts +39 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/hooks/useTheme.js +36 -0
- package/dist/hooks/useTheme.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1496 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +356 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +67 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -19
- package/README.md +0 -45
- package/lib/python-check.js +0 -223
package/lib/python-check.js
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { execSync, spawnSync } = require('child_process');
|
|
4
|
-
const { realpathSync } = require('fs');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
|
|
7
|
-
const MIN_PYTHON_MAJOR = 3;
|
|
8
|
-
const MIN_PYTHON_MINOR = 10;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* List of Python executable candidates in priority order
|
|
12
|
-
*/
|
|
13
|
-
const PYTHON_CANDIDATES = ['python3', 'python'];
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Returns the version of the given Python executable.
|
|
17
|
-
* Returns null if the executable cannot be run or version parsing fails.
|
|
18
|
-
* @param {string} cmd - Python command to execute
|
|
19
|
-
* @returns {{ major: number, minor: number } | null}
|
|
20
|
-
*/
|
|
21
|
-
function getPythonVersion(cmd) {
|
|
22
|
-
try {
|
|
23
|
-
const result = spawnSync(cmd, ['--version'], { encoding: 'utf8', timeout: 5000 });
|
|
24
|
-
if (result.status !== 0 || result.error) return null;
|
|
25
|
-
|
|
26
|
-
// Output may appear as "Python 3.11.4" or on stderr (Python 2)
|
|
27
|
-
const output = (result.stdout || result.stderr || '').trim();
|
|
28
|
-
const match = output.match(/Python\s+(\d+)\.(\d+)/i);
|
|
29
|
-
if (!match) return null;
|
|
30
|
-
|
|
31
|
-
return { major: parseInt(match[1], 10), minor: parseInt(match[2], 10) };
|
|
32
|
-
} catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Finds a Python 3.10+ executable available on the system.
|
|
39
|
-
* @returns {{ cmd: string, major: number, minor: number } | null}
|
|
40
|
-
*/
|
|
41
|
-
function findPython() {
|
|
42
|
-
for (const candidate of PYTHON_CANDIDATES) {
|
|
43
|
-
const version = getPythonVersion(candidate);
|
|
44
|
-
if (
|
|
45
|
-
version &&
|
|
46
|
-
(version.major > MIN_PYTHON_MAJOR ||
|
|
47
|
-
(version.major === MIN_PYTHON_MAJOR && version.minor >= MIN_PYTHON_MINOR))
|
|
48
|
-
) {
|
|
49
|
-
return { cmd: candidate, ...version };
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Checks whether the `govon` CLI is installed in PATH.
|
|
57
|
-
* Looks for the Python govon binary, not the npm govon.js wrapper.
|
|
58
|
-
* @returns {boolean}
|
|
59
|
-
*/
|
|
60
|
-
function isGovonInstalled() {
|
|
61
|
-
try {
|
|
62
|
-
// Verify govon path via which/where to confirm it is a Python binary
|
|
63
|
-
const whichCmd = process.platform === 'win32' ? 'where' : 'which';
|
|
64
|
-
const which = spawnSync(whichCmd, ['govon'], { encoding: 'utf8', timeout: 5000 });
|
|
65
|
-
if (which.error || which.status !== 0) return false;
|
|
66
|
-
|
|
67
|
-
const govonPath = (which.stdout || '').trim().split('\n')[0];
|
|
68
|
-
// Resolve symlinks to detect npm wrapper even behind /usr/local/bin symlinks
|
|
69
|
-
let resolvedPath;
|
|
70
|
-
try {
|
|
71
|
-
resolvedPath = realpathSync(govonPath);
|
|
72
|
-
} catch {
|
|
73
|
-
resolvedPath = govonPath;
|
|
74
|
-
}
|
|
75
|
-
// If the resolved path is under node_modules/.bin it is the npm wrapper — ignore it
|
|
76
|
-
if (resolvedPath.includes('node_modules')) return false;
|
|
77
|
-
|
|
78
|
-
// Confirm directly via Python module
|
|
79
|
-
const python = findPython();
|
|
80
|
-
if (!python) return false;
|
|
81
|
-
|
|
82
|
-
const result = spawnSync(python.cmd, ['-m', 'govon', '--version'], {
|
|
83
|
-
encoding: 'utf8',
|
|
84
|
-
timeout: 5000,
|
|
85
|
-
});
|
|
86
|
-
return !result.error && result.status === 0;
|
|
87
|
-
} catch {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Reads the npm package version from package.json for version pinning.
|
|
94
|
-
* @returns {string} - version string (e.g. "1.0.6"), or empty string on failure
|
|
95
|
-
*/
|
|
96
|
-
function getNpmPackageVersion() {
|
|
97
|
-
try {
|
|
98
|
-
const pkgPath = path.join(__dirname, '..', 'package.json');
|
|
99
|
-
const pkg = require(pkgPath);
|
|
100
|
-
return pkg.version || '';
|
|
101
|
-
} catch {
|
|
102
|
-
return '';
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Inspects the entire Python environment and returns the result.
|
|
108
|
-
* @returns {{
|
|
109
|
-
* pythonFound: boolean,
|
|
110
|
-
* pythonCmd: string | null,
|
|
111
|
-
* pythonVersion: string | null,
|
|
112
|
-
* govonInstalled: boolean
|
|
113
|
-
* }}
|
|
114
|
-
*/
|
|
115
|
-
function checkEnvironment() {
|
|
116
|
-
const python = findPython();
|
|
117
|
-
const govonInstalled = python ? isGovonInstalled() : false;
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
pythonFound: python !== null,
|
|
121
|
-
pythonCmd: python ? python.cmd : null,
|
|
122
|
-
pythonVersion: python ? `${python.major}.${python.minor}` : null,
|
|
123
|
-
govonInstalled,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Automatically installs the Python govon package via pip.
|
|
129
|
-
* Pins to the same version as the npm package to prevent version drift.
|
|
130
|
-
* @param {string} pythonCmd - path to the python executable
|
|
131
|
-
* @returns {boolean} - true if installation succeeded
|
|
132
|
-
*/
|
|
133
|
-
function autoInstallGovon(pythonCmd) {
|
|
134
|
-
const version = getNpmPackageVersion();
|
|
135
|
-
const spec = version ? `govon==${version}` : 'govon';
|
|
136
|
-
|
|
137
|
-
console.log('\n [govon] Auto-installing the Python govon package…');
|
|
138
|
-
console.log(` → ${pythonCmd} -m pip install ${spec}\n`);
|
|
139
|
-
|
|
140
|
-
const result = spawnSync(pythonCmd, ['-m', 'pip', 'install', spec], {
|
|
141
|
-
stdio: 'inherit',
|
|
142
|
-
timeout: 120000,
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
if (result.error || result.status !== 0) {
|
|
146
|
-
console.error(
|
|
147
|
-
[
|
|
148
|
-
'',
|
|
149
|
-
' [govon] Auto-installation failed.',
|
|
150
|
-
'',
|
|
151
|
-
' Please install manually with:',
|
|
152
|
-
` ${pythonCmd} -m pip install ${spec}`,
|
|
153
|
-
'',
|
|
154
|
-
' If you encounter a permission error:',
|
|
155
|
-
` ${pythonCmd} -m pip install --user ${spec}`,
|
|
156
|
-
'',
|
|
157
|
-
].join('\n')
|
|
158
|
-
);
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
console.log('\n [govon] ✓ Python govon package installed successfully.\n');
|
|
163
|
-
return true;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Prints the environment check result to stdout and displays guidance if issues are found.
|
|
168
|
-
* Attempts auto-installation if Python govon is not found.
|
|
169
|
-
* @returns {boolean} - true if all conditions are met
|
|
170
|
-
*/
|
|
171
|
-
function printEnvironmentStatus() {
|
|
172
|
-
const { pythonFound, pythonCmd, pythonVersion, govonInstalled } = checkEnvironment();
|
|
173
|
-
|
|
174
|
-
if (!pythonFound) {
|
|
175
|
-
console.error(
|
|
176
|
-
[
|
|
177
|
-
'',
|
|
178
|
-
' [govon] Python 3.10 or later is required.',
|
|
179
|
-
'',
|
|
180
|
-
' Please install Python and try again:',
|
|
181
|
-
' https://www.python.org/downloads/',
|
|
182
|
-
'',
|
|
183
|
-
' Or install via a package manager:',
|
|
184
|
-
' macOS: brew install python@3.12',
|
|
185
|
-
' Ubuntu: sudo apt install python3.12',
|
|
186
|
-
' Windows: winget install Python.Python.3.12',
|
|
187
|
-
'',
|
|
188
|
-
].join('\n')
|
|
189
|
-
);
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (!govonInstalled) {
|
|
194
|
-
// Attempt auto-installation
|
|
195
|
-
if (!autoInstallGovon(pythonCmd)) {
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
// Re-verify after installation (resolve symlinks for accurate detection)
|
|
199
|
-
if (!isGovonInstalled()) {
|
|
200
|
-
console.error(
|
|
201
|
-
[
|
|
202
|
-
'',
|
|
203
|
-
' [govon] govon CLI could not be found even after installation.',
|
|
204
|
-
'',
|
|
205
|
-
' Please ensure the pip install path is included in your PATH.',
|
|
206
|
-
` Or run directly: ${pythonCmd} -m govon`,
|
|
207
|
-
'',
|
|
208
|
-
].join('\n')
|
|
209
|
-
);
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return true;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
module.exports = {
|
|
218
|
-
findPython,
|
|
219
|
-
isGovonInstalled,
|
|
220
|
-
autoInstallGovon,
|
|
221
|
-
checkEnvironment,
|
|
222
|
-
printEnvironmentStatus,
|
|
223
|
-
};
|