@cloud411716/fancy-webnovel 1.0.15 → 1.0.16
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/commands/scan/index.js +1 -37
- package/infra.js +42 -2
- package/package.json +1 -1
package/commands/scan/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { existsSync } from 'fs';
|
|
9
9
|
import { join } from 'path';
|
|
10
|
-
import { notify, llmFollowup } from '../../infra.js';
|
|
10
|
+
import { notify, llmFollowup, StatusLine } from '../../infra.js';
|
|
11
11
|
import { runScans } from './scraper.js';
|
|
12
12
|
import * as qidian from './platforms/qidian.js';
|
|
13
13
|
import * as fanqie from './platforms/fanqie.js';
|
|
@@ -16,42 +16,6 @@ import * as qimao from './platforms/qimao.js';
|
|
|
16
16
|
|
|
17
17
|
// inject is declared in the root index.js; only apply() is imported by index.js
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* StatusLine — appends a single session event and updates it in-place on
|
|
21
|
-
* subsequent calls using session's surfaceOp replace mechanism.
|
|
22
|
-
*
|
|
23
|
-
* The event always stays at the same log position; only its content changes.
|
|
24
|
-
* This gives the appearance of a terminal "status bar" that doesn't scroll
|
|
25
|
-
* away or get buried under other messages.
|
|
26
|
-
*/
|
|
27
|
-
class StatusLine {
|
|
28
|
-
#session;
|
|
29
|
-
#seq; // event sequence of the status line (set after first append)
|
|
30
|
-
#text = '';
|
|
31
|
-
|
|
32
|
-
constructor(session) { this.#session = session; }
|
|
33
|
-
|
|
34
|
-
/** Update the status line content. First call creates the event; subsequent
|
|
35
|
-
* calls replace it in-place. */
|
|
36
|
-
update(text) {
|
|
37
|
-
const event = this.#seq
|
|
38
|
-
? this.#session.append(
|
|
39
|
-
'fancy/status',
|
|
40
|
-
{ content: [{ type: 'text', text }], source: { kind: 'user' } },
|
|
41
|
-
{ surfaceOp: { op: 'replace', start: this.#seq, end: this.#seq } }
|
|
42
|
-
)
|
|
43
|
-
: this.#session.append(
|
|
44
|
-
'fancy/status',
|
|
45
|
-
{ content: [{ type: 'text', text }], source: { kind: 'user' } },
|
|
46
|
-
{ surfaceOp: 'append' }
|
|
47
|
-
);
|
|
48
|
-
this.#seq ??= event.seq;
|
|
49
|
-
this.#text = text;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
clear() { this.update(''); }
|
|
53
|
-
}
|
|
54
|
-
|
|
55
19
|
const PLATFORM_TABLE = [
|
|
56
20
|
['1', 'qidian', '起点'],
|
|
57
21
|
['2', 'fanqie', '番茄'],
|
package/infra.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* infra.js — DSH Plugin Core Infrastructure
|
|
3
3
|
*
|
|
4
4
|
* Provides:
|
|
5
|
-
* notify(session, text)
|
|
5
|
+
* notify(session, text) — append a user-facing message to the session log
|
|
6
6
|
* llmFollowup(invocation,prompt)— hand a prompt to the LLM as a user message
|
|
7
|
+
* StatusLine(session) — in-place updatable status bar via surfaceOp replace
|
|
7
8
|
* scanProgress(ctx, phase, data)— emit structured scan progress events
|
|
8
|
-
* sleep(ctx, ms)
|
|
9
|
+
* sleep(ctx, ms) — DSH-native promise delay via ctx.timeout()
|
|
9
10
|
*
|
|
10
11
|
* All fancy-* plugins import from this file.
|
|
11
12
|
*/
|
|
@@ -31,6 +32,45 @@ export function notify(session, text) {
|
|
|
31
32
|
);
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
// --------------------------------------------------------------------------
|
|
36
|
+
// StatusLine — in-place updatable status bar using session surfaceOp replace
|
|
37
|
+
// --------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Appends a single session event and updates it in-place on subsequent calls
|
|
41
|
+
* using session's surfaceOp replace mechanism. The event always stays at the
|
|
42
|
+
* same log position; only its content changes — visually a terminal status bar.
|
|
43
|
+
*
|
|
44
|
+
* Usage:
|
|
45
|
+
* const status = new StatusLine(session);
|
|
46
|
+
* status.update('Working…');
|
|
47
|
+
* status.update('Done ✓');
|
|
48
|
+
* status.clear();
|
|
49
|
+
*/
|
|
50
|
+
export class StatusLine {
|
|
51
|
+
#session;
|
|
52
|
+
#seq;
|
|
53
|
+
|
|
54
|
+
constructor(session) { this.#session = session; }
|
|
55
|
+
|
|
56
|
+
update(text) {
|
|
57
|
+
const event = this.#seq
|
|
58
|
+
? this.#session.append(
|
|
59
|
+
'fancy/status',
|
|
60
|
+
{ content: [{ type: 'text', text }], source: { kind: 'user' } },
|
|
61
|
+
{ surfaceOp: { op: 'replace', start: this.#seq, end: this.#seq } }
|
|
62
|
+
)
|
|
63
|
+
: this.#session.append(
|
|
64
|
+
'fancy/status',
|
|
65
|
+
{ content: [{ type: 'text', text }], source: { kind: 'user' } },
|
|
66
|
+
{ surfaceOp: 'append' }
|
|
67
|
+
);
|
|
68
|
+
this.#seq ??= event.seq;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
clear() { this.update(''); }
|
|
72
|
+
}
|
|
73
|
+
|
|
34
74
|
// --------------------------------------------------------------------------
|
|
35
75
|
// llmFollowup — hand a prompt to the LLM as a user message
|
|
36
76
|
// --------------------------------------------------------------------------
|