@cloud411716/fancy-webnovel 0.1.61 → 0.1.63
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/infra.js +1 -5
- package/package.json +1 -1
- package/plugins/fancy-scan/index.js +14 -27
package/infra.js
CHANGED
|
@@ -14,14 +14,10 @@
|
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
|
|
16
16
|
export function notify(session, text) {
|
|
17
|
-
const isHtml = String(text).startsWith('<');
|
|
18
17
|
queueMicrotask(() => {
|
|
19
18
|
session.append(
|
|
20
19
|
'user/message',
|
|
21
|
-
{
|
|
22
|
-
content: [{ type: isHtml ? 'html' : 'text', text: String(text) }],
|
|
23
|
-
source: { kind: 'user' }
|
|
24
|
-
},
|
|
20
|
+
{ content: [{ type: 'text', text: String(text) }], source: { kind: 'user' } },
|
|
25
21
|
{ surfaceOp: 'append' }
|
|
26
22
|
);
|
|
27
23
|
});
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import { dirname, join } from 'path';
|
|
6
6
|
import { existsSync } from 'fs';
|
|
7
|
-
import { notify, llmFollowup } from '../../infra.js';
|
|
7
|
+
import { notify, llmFollowup, spawnScript } from '../../infra.js';
|
|
8
8
|
import { scan, PLATFORM_TABLE, platformLabel } from './templates.js';
|
|
9
9
|
|
|
10
10
|
export const inject = ['commands', 'userQuestions'];
|
|
@@ -92,37 +92,24 @@ export async function apply(ctx) {
|
|
|
92
92
|
|
|
93
93
|
notify(session, scan.notify({ type: 'collecting', platform, length }));
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
'--project-root', projectRoot, '--platform', platform, '--length', length], {
|
|
107
|
-
timeout: 120000,
|
|
108
|
-
stdio: ['ignore', 'pipe', 'inherit'],
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const [code, out] = await new Promise(resolve => {
|
|
112
|
-
const chunks = [];
|
|
113
|
-
proc.stdout.on('data', d => chunks.push(d.toString()));
|
|
114
|
-
proc.on('close', (c) => resolve([c, chunks.join('')]));
|
|
115
|
-
});
|
|
116
|
-
clearInterval(ticker);
|
|
117
|
-
|
|
118
|
-
if (code !== 0) {
|
|
119
|
-
const err = out.slice(-300) || `exit ${code}`;
|
|
95
|
+
const scriptResult = await spawnScript(
|
|
96
|
+
'node',
|
|
97
|
+
[join(SCAN_SCRIPTS_DIR, 'run-scan.js'),
|
|
98
|
+
'--project-root', projectRoot, '--platform', platform, '--length', length],
|
|
99
|
+
{ timeout: 120000 }
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (!scriptResult.ok) {
|
|
103
|
+
const err = (typeof scriptResult.error === 'object' && scriptResult.error !== null)
|
|
104
|
+
? (scriptResult.error.message || JSON.stringify(scriptResult.error))
|
|
105
|
+
: String(scriptResult.error || '未知错误');
|
|
120
106
|
notify(session, scan.notify({ type: 'failed', err }));
|
|
121
107
|
return { kind: 'success', text: '' };
|
|
122
108
|
}
|
|
123
109
|
|
|
110
|
+
// 解析 receipt
|
|
124
111
|
let receipt;
|
|
125
|
-
try { receipt = JSON.parse(
|
|
112
|
+
try { receipt = JSON.parse(scriptResult.output); } catch (_) {
|
|
126
113
|
notify(session, scan.notify({ type: 'parse_error' }));
|
|
127
114
|
return { kind: 'success', text: '' };
|
|
128
115
|
}
|