@hunterzhu/pulse-cli 0.1.1 → 0.1.3
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 +6 -2
- package/dist/config.d.ts +1 -0
- package/dist/config.js +6 -3
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createInterface } from 'node:readline';
|
|
3
3
|
import { access, chmod, mkdir, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
4
5
|
import { dirname } from 'node:path';
|
|
5
6
|
import { createLocalHost } from '@hunterzhu/pulse-server';
|
|
6
7
|
import { defaultPulseConfig, defaultPulseConfigPath, ensurePulseUserConfig, expandHome, loadPulseConfig } from './config.js';
|
|
7
|
-
const
|
|
8
|
+
const packageManifest = createRequire(import.meta.url)('../package.json');
|
|
9
|
+
const version = packageManifest.version;
|
|
8
10
|
const help = `Pulse ${version}
|
|
9
11
|
|
|
10
12
|
Usage:
|
|
@@ -127,8 +129,10 @@ async function consume(run, format, approvalInput) { let streamedText = false; l
|
|
|
127
129
|
}
|
|
128
130
|
const outcome = await run.outcome();
|
|
129
131
|
if (format === 'jsonl') {
|
|
130
|
-
process.stdout.write(`${JSON.stringify({ schemaVersion: 1, type: 'result', runId: run.id, status: outcome.status, text: outcome.text ?? null })}\n`);
|
|
132
|
+
process.stdout.write(`${JSON.stringify({ schemaVersion: 1, type: 'result', runId: run.id, status: outcome.status, text: outcome.text ?? null, error: outcome.error ?? null })}\n`);
|
|
131
133
|
}
|
|
134
|
+
else if (outcome.status === 'failed' && outcome.error)
|
|
135
|
+
process.stderr.write(`\n[错误] ${outcome.error.code}: ${outcome.error.message}\n`);
|
|
132
136
|
else if (!streamedText && outcome.text)
|
|
133
137
|
process.stdout.write(`${outcome.text}\n`);
|
|
134
138
|
else
|
package/dist/config.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface PulseCliConfig {
|
|
|
12
12
|
}
|
|
13
13
|
export declare const defaultPulseConfig: PulseCliConfig;
|
|
14
14
|
export declare function defaultPulseConfigPath(): string;
|
|
15
|
+
export declare function defaultPulseHomePath(): string;
|
|
15
16
|
/** Create the user config on first run without replacing an existing file. */
|
|
16
17
|
export declare function ensurePulseUserConfig(path?: string): Promise<void>;
|
|
17
18
|
export declare function expandHome(path: string | undefined): string | undefined;
|
package/dist/config.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { access, chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
4
|
export const defaultPulseConfig = {
|
|
5
5
|
provider: { provider: 'mock', model: 'mock', apiKeyEnv: 'OPENAI_API_KEY' },
|
|
6
6
|
approvalMode: 'ask',
|
|
7
7
|
allowNetwork: false,
|
|
8
8
|
};
|
|
9
9
|
export function defaultPulseConfigPath() {
|
|
10
|
-
return join(
|
|
10
|
+
return join(defaultPulseHomePath(), 'config.json');
|
|
11
|
+
}
|
|
12
|
+
export function defaultPulseHomePath() {
|
|
13
|
+
return resolve(process.env.PULSE_HOME ?? join(homedir(), '.pulse'));
|
|
11
14
|
}
|
|
12
15
|
/** Create the user config on first run without replacing an existing file. */
|
|
13
16
|
export async function ensurePulseUserConfig(path = defaultPulseConfigPath()) {
|
|
@@ -66,7 +69,7 @@ export function mergePulseConfigs(layers) {
|
|
|
66
69
|
}
|
|
67
70
|
export async function loadPulseConfig(cwd, explicitPath, trustWorkspace = false) {
|
|
68
71
|
const workspacePath = join(cwd, '.pulse', 'config.json');
|
|
69
|
-
const homePath =
|
|
72
|
+
const homePath = defaultPulseConfigPath();
|
|
70
73
|
const envPath = expandHome(process.env.PULSE_CONFIG);
|
|
71
74
|
const layers = [];
|
|
72
75
|
for (const [path, trust] of [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hunterzhu/pulse-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/zhuhengtan/Pulse"
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
"build": "tsc -p tsconfig.json"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@hunterzhu/pulse-server": "0.1.
|
|
22
|
+
"@hunterzhu/pulse-server": "0.1.3"
|
|
23
23
|
}
|
|
24
24
|
}
|