@xiangyixie/dsh-superagent 0.9.0 → 0.9.2

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/report.js CHANGED
@@ -1,79 +1,79 @@
1
- #!/usr/bin/env node
2
- /**
3
- * `dsh-superagent-report` — render existing runs into one self-contained HTML
4
- * file: inline CSS, inline SVG, no scripts, no network.
5
- */
6
- import fsp from 'node:fs/promises'
7
- import path from 'node:path'
8
- import { buildReport } from '../lib/report.js'
9
- import { createStore, resolveStateRoot } from '../lib/store.js'
10
-
11
- const USAGE = `Usage: dsh-superagent-report [options]
12
-
13
- Render recorded runs into one self-contained HTML file.
14
-
15
- Options:
16
- --state-dir <path> run state directory (default: $DSH_HOME/state/superagent)
17
- --out <file> output path (default: superagent-report.html)
18
- --limit <n> newest runs to include, 0 for all (default: 50)
19
- --title <text> report heading (default: Superagent run report)
20
- -h, --help show this message`
21
-
22
- function valueOf(argv, index, flag) {
23
- const value = argv[index]
24
- if (value === undefined || value.startsWith('--')) {
25
- console.error(`${flag} needs a value\n\n${USAGE}`)
26
- process.exit(2)
27
- }
28
- return value
29
- }
30
-
31
- function parse(argv) {
32
- const options = { out: 'superagent-report.html', limit: 50 }
33
- for (let index = 0; index < argv.length; index++) {
34
- const arg = argv[index]
35
- if (arg === '--state-dir') options.stateDir = valueOf(argv, ++index, '--state-dir')
36
- else if (arg.startsWith('--state-dir=')) options.stateDir = arg.slice('--state-dir='.length)
37
- else if (arg === '--out') options.out = valueOf(argv, ++index, '--out')
38
- else if (arg.startsWith('--out=')) options.out = arg.slice('--out='.length)
39
- else if (arg === '--limit') options.limit = Number(valueOf(argv, ++index, '--limit'))
40
- else if (arg.startsWith('--limit=')) options.limit = Number(arg.slice('--limit='.length))
41
- else if (arg === '--title') options.title = valueOf(argv, ++index, '--title')
42
- else if (arg.startsWith('--title=')) options.title = arg.slice('--title='.length)
43
- else if (arg === '-h' || arg === '--help') {
44
- console.log(USAGE)
45
- process.exit(0)
46
- } else {
47
- console.error(`unknown argument: ${arg}\n\n${USAGE}`)
48
- process.exit(2)
49
- }
50
- }
51
- if (!Number.isInteger(options.limit) || options.limit < 0) {
52
- console.error(`--limit must be a non-negative integer\n\n${USAGE}`)
53
- process.exit(2)
54
- }
55
- return options
56
- }
57
-
58
- const options = parse(process.argv.slice(2))
59
- const store = createStore(resolveStateRoot(options.stateDir))
60
- await store.init()
61
- const runs = await store.list()
62
- if (runs.length === 0) {
63
- console.error(`no runs in ${store.root}; start one with the superagent_start tool first`)
64
- process.exit(1)
65
- }
66
-
67
- const selected = options.limit === 0 ? runs : runs.slice(0, options.limit)
68
- const html = buildReport(selected, { title: options.title, generatedAt: Date.now() })
69
- const out = path.resolve(options.out)
70
- try {
71
- await fsp.mkdir(path.dirname(out), { recursive: true })
72
- await fsp.writeFile(out, html, 'utf8')
73
- } catch (error) {
74
- console.error(`cannot write ${out}: ${error?.message ?? error}`)
75
- process.exit(1)
76
- }
77
-
78
- const size = Buffer.byteLength(html, 'utf8')
79
- console.log(`wrote ${out} (${(size / 1024).toFixed(1)} kB, ${selected.length} run${selected.length === 1 ? '' : 's'})`)
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `dsh-superagent-report` — render existing runs into one self-contained HTML
4
+ * file: inline CSS, inline SVG, no scripts, no network.
5
+ */
6
+ import fsp from 'node:fs/promises'
7
+ import path from 'node:path'
8
+ import { buildReport } from '../lib/report.js'
9
+ import { createStore, resolveStateRoot } from '../lib/store.js'
10
+
11
+ const USAGE = `Usage: dsh-superagent-report [options]
12
+
13
+ Render recorded runs into one self-contained HTML file.
14
+
15
+ Options:
16
+ --state-dir <path> run state directory (default: $DSH_HOME/state/superagent)
17
+ --out <file> output path (default: superagent-report.html)
18
+ --limit <n> newest runs to include, 0 for all (default: 50)
19
+ --title <text> report heading (default: Superagent run report)
20
+ -h, --help show this message`
21
+
22
+ function valueOf(argv, index, flag) {
23
+ const value = argv[index]
24
+ if (value === undefined || value.startsWith('--')) {
25
+ console.error(`${flag} needs a value\n\n${USAGE}`)
26
+ process.exit(2)
27
+ }
28
+ return value
29
+ }
30
+
31
+ function parse(argv) {
32
+ const options = { out: 'superagent-report.html', limit: 50 }
33
+ for (let index = 0; index < argv.length; index++) {
34
+ const arg = argv[index]
35
+ if (arg === '--state-dir') options.stateDir = valueOf(argv, ++index, '--state-dir')
36
+ else if (arg.startsWith('--state-dir=')) options.stateDir = arg.slice('--state-dir='.length)
37
+ else if (arg === '--out') options.out = valueOf(argv, ++index, '--out')
38
+ else if (arg.startsWith('--out=')) options.out = arg.slice('--out='.length)
39
+ else if (arg === '--limit') options.limit = Number(valueOf(argv, ++index, '--limit'))
40
+ else if (arg.startsWith('--limit=')) options.limit = Number(arg.slice('--limit='.length))
41
+ else if (arg === '--title') options.title = valueOf(argv, ++index, '--title')
42
+ else if (arg.startsWith('--title=')) options.title = arg.slice('--title='.length)
43
+ else if (arg === '-h' || arg === '--help') {
44
+ console.log(USAGE)
45
+ process.exit(0)
46
+ } else {
47
+ console.error(`unknown argument: ${arg}\n\n${USAGE}`)
48
+ process.exit(2)
49
+ }
50
+ }
51
+ if (!Number.isInteger(options.limit) || options.limit < 0) {
52
+ console.error(`--limit must be a non-negative integer\n\n${USAGE}`)
53
+ process.exit(2)
54
+ }
55
+ return options
56
+ }
57
+
58
+ const options = parse(process.argv.slice(2))
59
+ const store = createStore(resolveStateRoot(options.stateDir))
60
+ await store.init()
61
+ const runs = await store.list()
62
+ if (runs.length === 0) {
63
+ console.error(`no runs in ${store.root}; start one with the superagent_start tool first`)
64
+ process.exit(1)
65
+ }
66
+
67
+ const selected = options.limit === 0 ? runs : runs.slice(0, options.limit)
68
+ const html = buildReport(selected, { title: options.title, generatedAt: Date.now() })
69
+ const out = path.resolve(options.out)
70
+ try {
71
+ await fsp.mkdir(path.dirname(out), { recursive: true })
72
+ await fsp.writeFile(out, html, 'utf8')
73
+ } catch (error) {
74
+ console.error(`cannot write ${out}: ${error?.message ?? error}`)
75
+ process.exit(1)
76
+ }
77
+
78
+ const size = Buffer.byteLength(html, 'utf8')
79
+ console.log(`wrote ${out} (${(size / 1024).toFixed(1)} kB, ${selected.length} run${selected.length === 1 ? '' : 's'})`)
package/bin/watch.js CHANGED
@@ -1,57 +1,57 @@
1
- #!/usr/bin/env node
2
- /**
3
- * `dsh-superagent-watch` — live terminal panel over the run store.
4
- *
5
- * The panel reads the same files the host writes, so it works from a separate
6
- * terminal, against a remote-mounted state directory, or after the host that
7
- * started the runs has gone.
8
- */
9
- import { DEFAULT_INTERVAL_MS, watch } from '../lib/watch.js'
10
-
11
- const USAGE = `Usage: dsh-superagent-watch [options]
12
-
13
- Draw one line per run, refreshed in place, until Ctrl-C.
14
-
15
- Options:
16
- --state-dir <path> run state directory (default: $DSH_HOME/state/superagent)
17
- --interval <ms> refresh interval (default: ${DEFAULT_INTERVAL_MS})
18
- --once print one frame and exit (for logs and pipes)
19
- --no-color never emit ANSI colour
20
- -h, --help show this message`
21
-
22
- /** Read one value that follows a flag, or fail with the usage text. */
23
- function valueOf(argv, index, flag) {
24
- const value = argv[index]
25
- if (value === undefined || value.startsWith('--')) {
26
- console.error(`${flag} needs a value\n\n${USAGE}`)
27
- process.exit(2)
28
- }
29
- return value
30
- }
31
-
32
- function parse(argv) {
33
- const options = { intervalMs: DEFAULT_INTERVAL_MS }
34
- for (let index = 0; index < argv.length; index++) {
35
- const arg = argv[index]
36
- if (arg === '--state-dir') options.stateDir = valueOf(argv, ++index, '--state-dir')
37
- else if (arg.startsWith('--state-dir=')) options.stateDir = arg.slice('--state-dir='.length)
38
- else if (arg === '--interval') options.intervalMs = Number(valueOf(argv, ++index, '--interval'))
39
- else if (arg.startsWith('--interval=')) options.intervalMs = Number(arg.slice('--interval='.length))
40
- else if (arg === '--once') options.once = true
41
- else if (arg === '--no-color') options.color = false
42
- else if (arg === '-h' || arg === '--help') {
43
- console.log(USAGE)
44
- process.exit(0)
45
- } else {
46
- console.error(`unknown argument: ${arg}\n\n${USAGE}`)
47
- process.exit(2)
48
- }
49
- }
50
- if (!Number.isFinite(options.intervalMs) || options.intervalMs <= 0) {
51
- console.error(`--interval must be a positive number of milliseconds\n\n${USAGE}`)
52
- process.exit(2)
53
- }
54
- return options
55
- }
56
-
57
- await watch(parse(process.argv.slice(2)))
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `dsh-superagent-watch` — live terminal panel over the run store.
4
+ *
5
+ * The panel reads the same files the host writes, so it works from a separate
6
+ * terminal, against a remote-mounted state directory, or after the host that
7
+ * started the runs has gone.
8
+ */
9
+ import { DEFAULT_INTERVAL_MS, watch } from '../lib/watch.js'
10
+
11
+ const USAGE = `Usage: dsh-superagent-watch [options]
12
+
13
+ Draw one line per run, refreshed in place, until Ctrl-C.
14
+
15
+ Options:
16
+ --state-dir <path> run state directory (default: $DSH_HOME/state/superagent)
17
+ --interval <ms> refresh interval (default: ${DEFAULT_INTERVAL_MS})
18
+ --once print one frame and exit (for logs and pipes)
19
+ --no-color never emit ANSI colour
20
+ -h, --help show this message`
21
+
22
+ /** Read one value that follows a flag, or fail with the usage text. */
23
+ function valueOf(argv, index, flag) {
24
+ const value = argv[index]
25
+ if (value === undefined || value.startsWith('--')) {
26
+ console.error(`${flag} needs a value\n\n${USAGE}`)
27
+ process.exit(2)
28
+ }
29
+ return value
30
+ }
31
+
32
+ function parse(argv) {
33
+ const options = { intervalMs: DEFAULT_INTERVAL_MS }
34
+ for (let index = 0; index < argv.length; index++) {
35
+ const arg = argv[index]
36
+ if (arg === '--state-dir') options.stateDir = valueOf(argv, ++index, '--state-dir')
37
+ else if (arg.startsWith('--state-dir=')) options.stateDir = arg.slice('--state-dir='.length)
38
+ else if (arg === '--interval') options.intervalMs = Number(valueOf(argv, ++index, '--interval'))
39
+ else if (arg.startsWith('--interval=')) options.intervalMs = Number(arg.slice('--interval='.length))
40
+ else if (arg === '--once') options.once = true
41
+ else if (arg === '--no-color') options.color = false
42
+ else if (arg === '-h' || arg === '--help') {
43
+ console.log(USAGE)
44
+ process.exit(0)
45
+ } else {
46
+ console.error(`unknown argument: ${arg}\n\n${USAGE}`)
47
+ process.exit(2)
48
+ }
49
+ }
50
+ if (!Number.isFinite(options.intervalMs) || options.intervalMs <= 0) {
51
+ console.error(`--interval must be a positive number of milliseconds\n\n${USAGE}`)
52
+ process.exit(2)
53
+ }
54
+ return options
55
+ }
56
+
57
+ await watch(parse(process.argv.slice(2)))
package/cordis.patch.yml CHANGED
@@ -1,9 +1,9 @@
1
- # dsh-superagent bundle layer.
2
- #
3
- # Inserts one tools-only plugin row at PROFILE scope, so every session in the
4
- # profile can start a run. The package never edits the profile's `bundles`
5
- # list — that entry is the operator's action (`dsh plugin --profile <name> add
6
- # @xiangyixie/dsh-superagent`).
7
- - insert:
8
- - id: superagent
9
- name: '@xiangyixie/dsh-superagent'
1
+ # dsh-superagent bundle layer.
2
+ #
3
+ # Inserts one tools-only plugin row at PROFILE scope, so every session in the
4
+ # profile can start a run. The package never edits the profile's `bundles`
5
+ # list — that entry is the operator's action (`dsh plugin --profile <name> add
6
+ # @xiangyixie/dsh-superagent`).
7
+ - insert:
8
+ - id: superagent
9
+ name: '@xiangyixie/dsh-superagent'