@hunterzhu/pulse-cli 0.1.7 → 0.1.9
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/bin.js +2 -1
- package/dist/config.js +20 -2
- package/dist/utils/is-main-module.d.ts +2 -0
- package/dist/utils/is-main-module.js +20 -0
- package/package.json +10 -5
- package/scripts/postinstall.mjs +11 -0
package/dist/bin.js
CHANGED
|
@@ -10,6 +10,7 @@ import { runDoctor } from './commands/doctor.js';
|
|
|
10
10
|
import { runSessions } from './commands/sessions.js';
|
|
11
11
|
import { runResume } from './commands/resume.js';
|
|
12
12
|
import { runSetup } from './commands/setup.js';
|
|
13
|
+
import { isSameModulePath } from './utils/is-main-module.js';
|
|
13
14
|
const packageManifest = createRequire(import.meta.url)('../package.json');
|
|
14
15
|
export const version = packageManifest.version;
|
|
15
16
|
process.stdout.on('error', (error) => {
|
|
@@ -262,7 +263,7 @@ export async function main() {
|
|
|
262
263
|
// 默认启动交互式 Ink 界面
|
|
263
264
|
return runInteractive(options, undefined, undefined, version, parsed.options.resume === true);
|
|
264
265
|
}
|
|
265
|
-
if (process.argv[1] &&
|
|
266
|
+
if (process.argv[1] && isSameModulePath(process.argv[1], fileURLToPath(import.meta.url))) {
|
|
266
267
|
main()
|
|
267
268
|
.then((code) => {
|
|
268
269
|
process.exitCode = code;
|
package/dist/config.js
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { access, chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
|
-
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { dirname, join, resolve, sep } from 'node:path';
|
|
4
4
|
export const defaultPulseConfig = {
|
|
5
5
|
providers: {
|
|
6
6
|
mock: { provider: 'mock', name: 'Mock' },
|
|
7
|
+
openai: {
|
|
8
|
+
provider: 'openai-compatible',
|
|
9
|
+
name: 'OpenAI',
|
|
10
|
+
baseURL: 'https://api.openai.com/v1',
|
|
11
|
+
apiKeyEnv: 'OPENAI_API_KEY',
|
|
12
|
+
},
|
|
13
|
+
deepseek: {
|
|
14
|
+
provider: 'deepseek',
|
|
15
|
+
name: 'DeepSeek',
|
|
16
|
+
baseURL: 'https://api.deepseek.com',
|
|
17
|
+
apiKeyEnv: 'DEEPSEEK_API_KEY',
|
|
18
|
+
},
|
|
7
19
|
},
|
|
8
20
|
models: {
|
|
9
21
|
mock: { displayName: 'mock', provider: 'mock', modelCode: 'mock', maxContextTokens: 32_000, maxOutputTokens: 4_096, reasoningEffort: 'medium' },
|
|
22
|
+
'gpt5.6-a': { displayName: 'gpt5.6-a', provider: 'openai', modelCode: 'gpt-5.6' },
|
|
23
|
+
'deepseek-chat': { displayName: 'deepseek-chat', provider: 'deepseek', modelCode: 'deepseek-chat' },
|
|
10
24
|
},
|
|
11
25
|
activeModel: 'mock',
|
|
12
26
|
approvalMode: 'ask',
|
|
@@ -44,7 +58,11 @@ export async function ensurePulseUserConfig(path = defaultPulseConfigPath()) {
|
|
|
44
58
|
export function expandHome(path) {
|
|
45
59
|
if (path === undefined)
|
|
46
60
|
return undefined;
|
|
47
|
-
return path === '~'
|
|
61
|
+
return path === '~' || path === `~${sep}`
|
|
62
|
+
? homedir()
|
|
63
|
+
: path.startsWith('~/') || (sep === '\\' && path.startsWith('~\\'))
|
|
64
|
+
? join(homedir(), path.slice(2))
|
|
65
|
+
: path;
|
|
48
66
|
}
|
|
49
67
|
function asConfig(value) {
|
|
50
68
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { realpathSync } from 'node:fs';
|
|
2
|
+
import { resolve, win32 } from 'node:path';
|
|
3
|
+
/** Compare resolved entrypoints, following package-manager shims and filesystem symlinks. */
|
|
4
|
+
export function isSameModulePath(executablePath, modulePath, platform = process.platform) {
|
|
5
|
+
const resolvePath = platform === 'win32' ? win32.resolve : resolve;
|
|
6
|
+
const canonicalize = (path) => {
|
|
7
|
+
const resolved = resolvePath(path);
|
|
8
|
+
try {
|
|
9
|
+
return realpathSync.native(resolved);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return resolved;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const executable = canonicalize(executablePath);
|
|
16
|
+
const module = canonicalize(modulePath);
|
|
17
|
+
return platform === 'win32'
|
|
18
|
+
? executable.toLowerCase() === module.toLowerCase()
|
|
19
|
+
: executable === module;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hunterzhu/pulse-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/zhuhengtan/Pulse"
|
|
@@ -11,15 +11,20 @@
|
|
|
11
11
|
},
|
|
12
12
|
"main": "dist/bin.js",
|
|
13
13
|
"types": "dist/bin.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"scripts"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"postinstall": "node ./scripts/postinstall.mjs"
|
|
21
|
+
},
|
|
14
22
|
"publishConfig": {
|
|
15
23
|
"access": "public",
|
|
16
24
|
"registry": "https://registry.npmjs.org"
|
|
17
25
|
},
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "tsc -p tsconfig.json"
|
|
20
|
-
},
|
|
21
26
|
"dependencies": {
|
|
22
|
-
"@hunterzhu/pulse-server": "0.1.
|
|
27
|
+
"@hunterzhu/pulse-server": "0.1.9",
|
|
23
28
|
"ink": "^7.1.1",
|
|
24
29
|
"react": "^19.0.0",
|
|
25
30
|
"ink-spinner": "^5.0.0",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ensurePulseUserConfig, defaultPulseConfigPath } from '../dist/config.js'
|
|
2
|
+
|
|
3
|
+
try {
|
|
4
|
+
const configPath = defaultPulseConfigPath()
|
|
5
|
+
await ensurePulseUserConfig(configPath)
|
|
6
|
+
console.log(`Pulse config is ready at ${configPath}`)
|
|
7
|
+
} catch (error) {
|
|
8
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
9
|
+
console.warn(`Pulse could not create its default config: ${message}`)
|
|
10
|
+
console.warn('Run "pulse setup" later to create it.')
|
|
11
|
+
}
|