dravoice 0.1.0 → 0.1.1
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/LICENSE +21 -21
- package/README.md +28 -26
- package/package.json +2 -2
- package/src/index.js +78 -56
- package/src/v2/analyzers/evidence.js +9 -5
- package/src/v2/benchmark.js +67 -136
- package/src/v2/brief.js +146 -146
- package/src/v2/profile.js +73 -25
- package/src/v2/revise-plan.js +340 -0
- package/src/v2/stylometry.js +236 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Dravoice contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dravoice contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
# Dravoice
|
|
2
|
-
|
|
3
|
-
Dravoice is a local-first CLI for compiling Markdown, MDX, and plain-text
|
|
4
|
-
writing corpora into reusable voice guidance and deterministic draft review
|
|
5
|
-
notes.
|
|
6
|
-
|
|
7
|
-
It is not an AI-authorship detector, grammar checker, prose linter, or
|
|
8
|
-
third-party author imitation tool. It helps a writer inspect and reuse their
|
|
9
|
-
own measurable rhythm, register, evidence habits, discourse shape, and
|
|
10
|
-
structure.
|
|
11
|
-
|
|
12
|
-
## Quick Start
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
npx --package dravoice drav learn --examples ./articles --out ./dravoice-voice
|
|
16
|
-
npx --package dravoice drav inspect --voice ./dravoice-voice
|
|
1
|
+
# Dravoice
|
|
2
|
+
|
|
3
|
+
Dravoice is a local-first CLI for compiling Markdown, MDX, and plain-text
|
|
4
|
+
writing corpora into reusable voice guidance and deterministic draft review
|
|
5
|
+
notes.
|
|
6
|
+
|
|
7
|
+
It is not an AI-authorship detector, grammar checker, prose linter, or
|
|
8
|
+
third-party author imitation tool. It helps a writer inspect and reuse their
|
|
9
|
+
own measurable rhythm, register, evidence habits, discourse shape, and
|
|
10
|
+
structure.
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx --package dravoice drav learn --examples ./articles --out ./dravoice-voice
|
|
16
|
+
npx --package dravoice drav inspect --voice ./dravoice-voice
|
|
17
17
|
npx --package dravoice drav prompt --voice ./dravoice-voice --format agents --out AGENTS.md
|
|
18
18
|
npx --package dravoice drav brief --voice ./dravoice-voice --topic "A new article topic" --evidence notes.md --out brief.md
|
|
19
|
+
npx --package dravoice drav revise-plan draft.md --voice ./dravoice-voice
|
|
19
20
|
npx --package dravoice drav review draft.md --voice ./dravoice-voice
|
|
20
21
|
npx --package dravoice drav review draft.md --voice ./dravoice-voice --mode strict --format json
|
|
21
22
|
```
|
|
@@ -23,13 +24,14 @@ npx --package dravoice drav review draft.md --voice ./dravoice-voice --mode stri
|
|
|
23
24
|
`learn` writes a schemaVersion 2 `profile.json` plus local metadata. `inspect`
|
|
24
25
|
makes the learned feature families visible, `prompt` turns high-confidence
|
|
25
26
|
observations into drafting guidance, `brief` creates an evidence-first article
|
|
26
|
-
plan, and `review`
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
npm
|
|
35
|
-
|
|
27
|
+
plan, `revise-plan` ranks calibrated stylometric revision actions, and `review`
|
|
28
|
+
reports family-level drift.
|
|
29
|
+
|
|
30
|
+
## Fresh Install Smoke Test
|
|
31
|
+
|
|
32
|
+
From a packed tarball:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm pack
|
|
36
|
+
npm exec --package ./dravoice-0.1.1.tgz -- drav --help
|
|
37
|
+
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dravoice",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Compile article voice profiles into reusable LLM writing context, evidence-first briefs, and deterministic draft review notes.",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Compile article voice profiles into reusable LLM writing context, evidence-first briefs, and deterministic draft review notes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"drav": "bin/dravoice.js"
|
package/src/index.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
prepareVoiceBenchmark,
|
|
5
|
-
renderBenchmarkReport,
|
|
6
|
-
scoreVoiceBenchmark,
|
|
7
|
-
} from "./v2/benchmark.js";
|
|
8
|
-
import { renderVoiceBriefV2, voiceArticleBriefV2 } from "./v2/brief.js";
|
|
9
|
-
import { renderInspectV2 } from "./v2/inspect.js";
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
prepareVoiceBenchmark,
|
|
5
|
+
renderBenchmarkReport,
|
|
6
|
+
scoreVoiceBenchmark,
|
|
7
|
+
} from "./v2/benchmark.js";
|
|
8
|
+
import { renderVoiceBriefV2, voiceArticleBriefV2 } from "./v2/brief.js";
|
|
9
|
+
import { renderInspectV2 } from "./v2/inspect.js";
|
|
10
10
|
import { learnVoicePackV2, loadVoicePackV2 } from "./v2/profile.js";
|
|
11
11
|
import { voicePromptPackV2 } from "./v2/prompt.js";
|
|
12
12
|
import { renderVoiceReviewV2, reviewVoiceDraftV2 } from "./v2/review.js";
|
|
13
|
+
import { renderRevisePlanV2, revisePlanDraftV2 } from "./v2/revise-plan.js";
|
|
13
14
|
|
|
14
15
|
export {
|
|
15
16
|
learnVoicePackV2 as learnVoicePack,
|
|
16
|
-
loadVoicePackV2 as loadVoicePack,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
17
|
+
loadVoicePackV2 as loadVoicePack,
|
|
18
|
+
revisePlanDraftV2 as revisePlanDraft,
|
|
19
|
+
reviewVoiceDraftV2 as reviewVoiceDraft,
|
|
20
|
+
voicePromptPackV2 as voicePromptPack,
|
|
21
|
+
};
|
|
22
|
+
export { renderInspectV2, renderRevisePlanV2 as renderRevisePlan, renderVoiceReviewV2 as renderVoiceReview };
|
|
23
|
+
export { renderVoiceBriefV2 as renderVoiceBrief, voiceArticleBriefV2 as voiceArticleBrief };
|
|
24
|
+
export { prepareVoiceBenchmark, renderBenchmarkReport, scoreVoiceBenchmark };
|
|
23
25
|
|
|
24
26
|
export async function runCli(args, io) {
|
|
25
27
|
try {
|
|
@@ -39,7 +41,7 @@ export async function runCli(args, io) {
|
|
|
39
41
|
return 0;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
if (command === "review") {
|
|
44
|
+
if (command === "review") {
|
|
43
45
|
const { options, positional } = parseArgs(rest, ["voice", "mode", "format"]);
|
|
44
46
|
const file = positional[0];
|
|
45
47
|
if (!file) {
|
|
@@ -56,46 +58,65 @@ export async function runCli(args, io) {
|
|
|
56
58
|
} else {
|
|
57
59
|
io.stdout.write(renderVoiceReviewV2(result));
|
|
58
60
|
}
|
|
59
|
-
return result.exitCode;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (command === "prompt") {
|
|
63
|
-
const { options } = parseArgs(rest, ["voice", "format", "out"]);
|
|
64
|
-
const rendered = voicePromptPackV2({
|
|
65
|
-
voice: loadVoicePackV2(resolvePath(io.cwd, options.voice ?? ".")),
|
|
66
|
-
format: options.format ?? "agents",
|
|
67
|
-
outPath: options.out ? resolvePath(io.cwd, options.out) : undefined,
|
|
68
|
-
});
|
|
69
|
-
if (!options.out) {
|
|
70
|
-
io.stdout.write(rendered);
|
|
71
|
-
}
|
|
72
|
-
return 0;
|
|
61
|
+
return result.exitCode;
|
|
73
62
|
}
|
|
74
63
|
|
|
75
|
-
if (command === "
|
|
76
|
-
const { options } = parseArgs(rest, ["voice", "
|
|
77
|
-
const
|
|
64
|
+
if (command === "revise-plan") {
|
|
65
|
+
const { options, positional } = parseArgs(rest, ["voice", "format"]);
|
|
66
|
+
const file = positional[0];
|
|
67
|
+
if (!file) {
|
|
68
|
+
throw new Error("Missing draft file path for revise-plan");
|
|
69
|
+
}
|
|
70
|
+
const result = revisePlanDraftV2({
|
|
71
|
+
file: resolvePath(io.cwd, file),
|
|
78
72
|
voice: loadVoicePackV2(resolvePath(io.cwd, options.voice ?? ".")),
|
|
79
|
-
topic: requiredOption(options, "topic"),
|
|
80
|
-
evidence: options.evidence ? resolvePath(io.cwd, options.evidence) : undefined,
|
|
81
73
|
cwd: io.cwd,
|
|
82
74
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const outPath = resolvePath(io.cwd, options.out);
|
|
86
|
-
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
87
|
-
fs.writeFileSync(outPath, rendered, "utf8");
|
|
75
|
+
if (options.format === "json") {
|
|
76
|
+
io.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
88
77
|
} else {
|
|
89
|
-
io.stdout.write(
|
|
78
|
+
io.stdout.write(renderRevisePlanV2(result));
|
|
90
79
|
}
|
|
91
80
|
return 0;
|
|
92
81
|
}
|
|
93
82
|
|
|
94
|
-
if (command === "
|
|
95
|
-
const { options } = parseArgs(rest, ["voice"]);
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
if (command === "prompt") {
|
|
84
|
+
const { options } = parseArgs(rest, ["voice", "format", "out"]);
|
|
85
|
+
const rendered = voicePromptPackV2({
|
|
86
|
+
voice: loadVoicePackV2(resolvePath(io.cwd, options.voice ?? ".")),
|
|
87
|
+
format: options.format ?? "agents",
|
|
88
|
+
outPath: options.out ? resolvePath(io.cwd, options.out) : undefined,
|
|
89
|
+
});
|
|
90
|
+
if (!options.out) {
|
|
91
|
+
io.stdout.write(rendered);
|
|
92
|
+
}
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (command === "brief") {
|
|
97
|
+
const { options } = parseArgs(rest, ["voice", "topic", "evidence", "format", "out"]);
|
|
98
|
+
const result = voiceArticleBriefV2({
|
|
99
|
+
voice: loadVoicePackV2(resolvePath(io.cwd, options.voice ?? ".")),
|
|
100
|
+
topic: requiredOption(options, "topic"),
|
|
101
|
+
evidence: options.evidence ? resolvePath(io.cwd, options.evidence) : undefined,
|
|
102
|
+
cwd: io.cwd,
|
|
103
|
+
});
|
|
104
|
+
const rendered = options.format === "json" ? `${JSON.stringify(result, null, 2)}\n` : renderVoiceBriefV2(result);
|
|
105
|
+
if (options.out) {
|
|
106
|
+
const outPath = resolvePath(io.cwd, options.out);
|
|
107
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
108
|
+
fs.writeFileSync(outPath, rendered, "utf8");
|
|
109
|
+
} else {
|
|
110
|
+
io.stdout.write(rendered);
|
|
111
|
+
}
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (command === "inspect") {
|
|
116
|
+
const { options } = parseArgs(rest, ["voice"]);
|
|
117
|
+
const profile = loadVoicePackV2(resolvePath(io.cwd, options.voice ?? "."));
|
|
118
|
+
io.stdout.write(renderInspectV2(profile));
|
|
119
|
+
return 0;
|
|
99
120
|
}
|
|
100
121
|
|
|
101
122
|
if (command === "benchmark") {
|
|
@@ -190,15 +211,16 @@ function resolvePath(cwd, value) {
|
|
|
190
211
|
return path.isAbsolute(value) ? value : path.join(cwd, value);
|
|
191
212
|
}
|
|
192
213
|
|
|
193
|
-
function helpText() {
|
|
194
|
-
return [
|
|
195
|
-
"drav learn --examples ./articles --out ./dravoice-voice",
|
|
196
|
-
"drav inspect --voice ./dravoice-voice",
|
|
197
|
-
"drav prompt --voice ./dravoice-voice --format agents --out AGENTS.md",
|
|
214
|
+
function helpText() {
|
|
215
|
+
return [
|
|
216
|
+
"drav learn --examples ./articles --out ./dravoice-voice",
|
|
217
|
+
"drav inspect --voice ./dravoice-voice",
|
|
218
|
+
"drav prompt --voice ./dravoice-voice --format agents --out AGENTS.md",
|
|
198
219
|
"drav brief --voice ./dravoice-voice --topic \"New topic\" --evidence notes.md --out brief.md",
|
|
199
220
|
"drav review draft.md --voice ./dravoice-voice --mode balanced --format text",
|
|
221
|
+
"drav revise-plan draft.md --voice ./dravoice-voice --format text",
|
|
200
222
|
"drav benchmark prepare --examples ./articles --topic \"New topic\" --out ./bench-run --seed 42",
|
|
201
|
-
"drav benchmark score --run ./bench-run --judge ./bench-run/judge/judgment.json",
|
|
202
|
-
"",
|
|
203
|
-
].join("\n");
|
|
204
|
-
}
|
|
223
|
+
"drav benchmark score --run ./bench-run --judge ./bench-run/judge/judgment.json",
|
|
224
|
+
"",
|
|
225
|
+
].join("\n");
|
|
226
|
+
}
|
|
@@ -36,8 +36,12 @@ export function analyzeEvidence(documents) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export function evidenceTypes(text) {
|
|
40
|
-
return Object.entries(EVIDENCE_PATTERNS)
|
|
41
|
-
.filter(([, pattern]) => pattern.test(text))
|
|
42
|
-
.map(([type]) => type);
|
|
43
|
-
}
|
|
39
|
+
export function evidenceTypes(text) {
|
|
40
|
+
return Object.entries(EVIDENCE_PATTERNS)
|
|
41
|
+
.filter(([, pattern]) => pattern.test(text))
|
|
42
|
+
.map(([type]) => type);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function isAbstractClaim(text) {
|
|
46
|
+
return ABSTRACT_CLAIM_RE.test(text);
|
|
47
|
+
}
|
package/src/v2/benchmark.js
CHANGED
|
@@ -5,30 +5,22 @@ import { voicePromptPackV2 } from "./prompt.js";
|
|
|
5
5
|
import { reviewVoiceDraftV2 } from "./review.js";
|
|
6
6
|
import { clampScore } from "./text-utils.js";
|
|
7
7
|
|
|
8
|
-
const BENCHMARK_SCHEMA_VERSION = 2;
|
|
9
|
-
const GENERATED_BY = "dravoice-v2-benchmark";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const voicePackDir = path.join(outputRoot, "voice-pack");
|
|
25
|
-
const promptsDir = path.join(outputRoot, "prompts");
|
|
26
|
-
const draftsDir = path.join(outputRoot, "drafts");
|
|
27
|
-
fs.mkdirSync(promptsDir, { recursive: true });
|
|
28
|
-
fs.mkdirSync(draftsDir, { recursive: true });
|
|
29
|
-
|
|
30
|
-
const profile = learnVoicePackV2({ examplesDir: examplesRoot, outDir: voicePackDir });
|
|
31
|
-
const sources = sourceFiles.map((filePath, index) => sourceArticle(filePath, examplesRoot, index));
|
|
8
|
+
const BENCHMARK_SCHEMA_VERSION = 2;
|
|
9
|
+
const GENERATED_BY = "dravoice-v2-benchmark";
|
|
10
|
+
|
|
11
|
+
export function prepareVoiceBenchmark({ examplesDir, topic, outDir, seed = 1, cwd = process.cwd() }) {
|
|
12
|
+
const examplesRoot = path.resolve(resolvePath(cwd, examplesDir));
|
|
13
|
+
const outputRoot = path.resolve(resolvePath(cwd, outDir));
|
|
14
|
+
const normalizedSeed = normalizeSeed(seed);
|
|
15
|
+
|
|
16
|
+
const voicePackDir = path.join(outputRoot, "voice-pack");
|
|
17
|
+
const promptsDir = path.join(outputRoot, "prompts");
|
|
18
|
+
const draftsDir = path.join(outputRoot, "drafts");
|
|
19
|
+
fs.mkdirSync(promptsDir, { recursive: true });
|
|
20
|
+
fs.mkdirSync(draftsDir, { recursive: true });
|
|
21
|
+
|
|
22
|
+
const profile = learnVoicePackV2({ examplesDir: examplesRoot, outDir: voicePackDir });
|
|
23
|
+
const sources = benchmarkSourcesFromProfile(profile);
|
|
32
24
|
const blind = blindMapping(normalizedSeed);
|
|
33
25
|
const benchmark = {
|
|
34
26
|
schemaVersion: BENCHMARK_SCHEMA_VERSION,
|
|
@@ -538,58 +530,56 @@ function assertObject(value, field) {
|
|
|
538
530
|
}
|
|
539
531
|
}
|
|
540
532
|
|
|
541
|
-
function
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
};
|
|
592
|
-
}
|
|
533
|
+
function benchmarkSourcesFromProfile(profile) {
|
|
534
|
+
return profile.source.files.map((file, index) => ({
|
|
535
|
+
id: file.id ?? `source-${index + 1}`,
|
|
536
|
+
path: `source-${index + 1}${file.extension || ".txt"}`,
|
|
537
|
+
title: `Source ${index + 1}`,
|
|
538
|
+
words: file.wordCount,
|
|
539
|
+
}));
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function benchmarkSources(benchmark, resolved) {
|
|
543
|
+
return resolved.corpus.files.map((file, index) => ({
|
|
544
|
+
id: file.id ?? `source-${index + 1}`,
|
|
545
|
+
path: file.path,
|
|
546
|
+
title: file.title ?? `Source ${index + 1}`,
|
|
547
|
+
words: file.words,
|
|
548
|
+
}));
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function benchmarkDrafts(benchmark, resolved) {
|
|
552
|
+
return ["A", "B"].map((label) => {
|
|
553
|
+
const draftPath = benchmark.blind.draftFiles[label];
|
|
554
|
+
const resolvedDraftPath = resolved.blind.draftFiles[label];
|
|
555
|
+
return {
|
|
556
|
+
label,
|
|
557
|
+
path: draftPath,
|
|
558
|
+
words: fs.existsSync(resolvedDraftPath)
|
|
559
|
+
? (fs.readFileSync(resolvedDraftPath, "utf8").match(/[a-z][a-z0-9'-]*/gi) ?? []).length
|
|
560
|
+
: 0,
|
|
561
|
+
};
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function blindMapping(seed) {
|
|
566
|
+
const baselineIsA = seededRandom(seed) < 0.5;
|
|
567
|
+
const labels = {
|
|
568
|
+
baseline: baselineIsA ? "A" : "B",
|
|
569
|
+
voiceAssisted: baselineIsA ? "B" : "A",
|
|
570
|
+
};
|
|
571
|
+
return {
|
|
572
|
+
labels,
|
|
573
|
+
drafts: {
|
|
574
|
+
A: baselineIsA ? "baseline" : "voice-assisted",
|
|
575
|
+
B: baselineIsA ? "voice-assisted" : "baseline",
|
|
576
|
+
},
|
|
577
|
+
draftFiles: {
|
|
578
|
+
A: baselineIsA ? "drafts/baseline.md" : "drafts/voice-assisted.md",
|
|
579
|
+
B: baselineIsA ? "drafts/voice-assisted.md" : "drafts/baseline.md",
|
|
580
|
+
},
|
|
581
|
+
};
|
|
582
|
+
}
|
|
593
583
|
|
|
594
584
|
function seededRandom(seed) {
|
|
595
585
|
const next = (normalizeSeed(seed) * 1664525 + 1013904223) >>> 0;
|
|
@@ -608,66 +598,7 @@ function normalizeSeed(seed) {
|
|
|
608
598
|
return Number(parsed);
|
|
609
599
|
}
|
|
610
600
|
|
|
611
|
-
function
|
|
612
|
-
if (!fs.existsSync(rootDir)) {
|
|
613
|
-
return [];
|
|
614
|
-
}
|
|
615
|
-
const result = [];
|
|
616
|
-
for (const entry of fs.readdirSync(rootDir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
617
|
-
const fullPath = path.join(rootDir, entry.name);
|
|
618
|
-
if (entry.isDirectory()) {
|
|
619
|
-
if (!isSkippedVoiceDir(fullPath, entry.name)) {
|
|
620
|
-
result.push(...walkVoiceFiles(fullPath));
|
|
621
|
-
}
|
|
622
|
-
} else if (VOICE_EXTENSIONS.has(path.extname(entry.name).toLowerCase()) && !isGeneratedBenchmarkMarkdown(fullPath)) {
|
|
623
|
-
result.push(fullPath);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
return result.sort((a, b) => toPosix(path.relative(rootDir, a)).localeCompare(toPosix(path.relative(rootDir, b))));
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
function isSkippedVoiceDir(dirPath, name) {
|
|
630
|
-
if (SKIP_DIRS.has(name)) {
|
|
631
|
-
return true;
|
|
632
|
-
}
|
|
633
|
-
if (name === "voice-pack" || name === "dravoice-voice" || name === ".dravoice") {
|
|
634
|
-
return true;
|
|
635
|
-
}
|
|
636
|
-
if (fs.existsSync(path.join(dirPath, SOURCE_SNAPSHOT_MARKER))) {
|
|
637
|
-
return true;
|
|
638
|
-
}
|
|
639
|
-
if (isBenchmarkRunDir(dirPath)) {
|
|
640
|
-
return true;
|
|
641
|
-
}
|
|
642
|
-
if (BENCHMARK_ARTIFACT_DIRS.has(name) && isBenchmarkRunDir(path.dirname(dirPath))) {
|
|
643
|
-
return true;
|
|
644
|
-
}
|
|
645
|
-
return fs.existsSync(path.join(dirPath, "profile.json"));
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
function isBenchmarkRunDir(dirPath) {
|
|
649
|
-
const benchmarkPath = path.join(dirPath, "benchmark.json");
|
|
650
|
-
if (!fs.existsSync(benchmarkPath)) {
|
|
651
|
-
return false;
|
|
652
|
-
}
|
|
653
|
-
try {
|
|
654
|
-
const benchmark = JSON.parse(fs.readFileSync(benchmarkPath, "utf8"));
|
|
655
|
-
return benchmark?.generatedBy === GENERATED_BY;
|
|
656
|
-
} catch {
|
|
657
|
-
return false;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
function isGeneratedBenchmarkMarkdown(filePath) {
|
|
662
|
-
const basename = path.basename(filePath).toLowerCase();
|
|
663
|
-
if (!["baseline-writer.md", "voice-writer.md", "judge.md", "report.md"].includes(basename)) {
|
|
664
|
-
return false;
|
|
665
|
-
}
|
|
666
|
-
const contents = fs.readFileSync(filePath, "utf8");
|
|
667
|
-
return /^# (?:Baseline Writer Prompt|Voice-Assisted Writer Prompt|Blind V2 Voice Benchmark Judge Prompt|Dravoice V2 Voice Benchmark Report)/m.test(contents);
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
function writeIfMissing(filePath, contents) {
|
|
601
|
+
function writeIfMissing(filePath, contents) {
|
|
671
602
|
if (!fs.existsSync(filePath)) {
|
|
672
603
|
fs.writeFileSync(filePath, contents, "utf8");
|
|
673
604
|
}
|