coauthored 0.0.0-stage → 1.0.0
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 -0
- package/PRIVACY.md +107 -0
- package/README.md +113 -3
- package/THIRD_PARTY_LICENSES.md +105 -0
- package/dist/cli/analytics/anchors.js +39 -0
- package/dist/cli/analytics/archetypes.js +193 -0
- package/dist/cli/analytics/content/analyzer.js +945 -0
- package/dist/cli/analytics/content/classify.js +115 -0
- package/dist/cli/analytics/content/demo-corpus.js +301 -0
- package/dist/cli/analytics/content/sketch.js +54 -0
- package/dist/cli/analytics/dataset.js +321 -0
- package/dist/cli/analytics/demo-fixtures.js +531 -0
- package/dist/cli/analytics/fdr.js +183 -0
- package/dist/cli/analytics/helicorder.js +66 -0
- package/dist/cli/analytics/insights.js +589 -0
- package/dist/cli/analytics/models.js +75 -0
- package/dist/cli/analytics/pricing.js +121 -0
- package/dist/cli/analytics/probable-cause.js +115 -0
- package/dist/cli/analytics/report-builder.js +162 -0
- package/dist/cli/analytics/statistics.js +91 -0
- package/dist/cli/analytics/time.js +252 -0
- package/dist/cli/cli/args.js +105 -0
- package/dist/cli/cli/browser.js +71 -0
- package/dist/cli/cli/index.js +20 -0
- package/dist/cli/cli/main.js +520 -0
- package/dist/cli/cli/phrase-review.js +78 -0
- package/dist/cli/cli/server.js +481 -0
- package/dist/cli/cli/terminal.js +363 -0
- package/dist/cli/ingest/adapters/aider.js +116 -0
- package/dist/cli/ingest/adapters/claude-code.js +139 -0
- package/dist/cli/ingest/adapters/cline-roo.js +89 -0
- package/dist/cli/ingest/adapters/codex-cli.js +240 -0
- package/dist/cli/ingest/adapters/content.js +99 -0
- package/dist/cli/ingest/adapters/cursor-ide.js +149 -0
- package/dist/cli/ingest/adapters/gemini-cli.js +208 -0
- package/dist/cli/ingest/adapters/index.js +18 -0
- package/dist/cli/ingest/adapters/opencode.js +203 -0
- package/dist/cli/ingest/adapters/pi-agent.js +85 -0
- package/dist/cli/ingest/adapters/shared.js +484 -0
- package/dist/cli/ingest/content-sink.js +31 -0
- package/dist/cli/ingest/discovery.js +50 -0
- package/dist/cli/ingest/message-digests.js +61 -0
- package/dist/cli/ingest/pipeline.js +155 -0
- package/dist/cli/ingest/safe-fs.js +284 -0
- package/dist/cli/ingest/sqlite-stage.js +139 -0
- package/dist/cli/ingest/time-window.js +34 -0
- package/dist/cli/ingest/tool-map.js +24 -0
- package/dist/cli/ingest/types.js +1 -0
- package/dist/cli/ingest/worker.js +97 -0
- package/dist/cli/report/content/emoji-names.js +3956 -0
- package/dist/cli/report/content/insights.js +41 -0
- package/dist/cli/report/content/lexicons.js +112 -0
- package/dist/cli/report/content/policy.js +77 -0
- package/dist/cli/report/content/redact.js +164 -0
- package/dist/cli/report/content/stopwords.js +8848 -0
- package/dist/cli/report/content/suppression.js +2617 -0
- package/dist/cli/report/content/validate.js +152 -0
- package/dist/cli/report/copy-lint.js +105 -0
- package/dist/cli/report/share.js +132 -0
- package/dist/cli/report/types.js +1 -0
- package/dist/cli/report/validators.js +334 -0
- package/dist/web/assets/Archivo-VF-BohoA-Sn.woff2 +0 -0
- package/dist/web/assets/DelaGothicOne-subset-CpoJGhTq.woff2 +0 -0
- package/dist/web/assets/Film-Dq8Xxn7U.css +1 -0
- package/dist/web/assets/MartianMono-VF-CmJ1nXx9.woff2 +0 -0
- package/dist/web/assets/app-DEQgytaq.js +38 -0
- package/dist/web/assets/bricolage-grotesque-latin-700-normal-gtcctNPv.woff2 +0 -0
- package/dist/web/assets/bricolage-grotesque-latin-800-normal-J50vIsBe.woff2 +0 -0
- package/dist/web/assets/chorus-D7bfON5Z.ogg +0 -0
- package/dist/web/assets/chorus-bass-CBTKpMv_.ogg +0 -0
- package/dist/web/assets/chorus-drums-BOzgLSoq.ogg +0 -0
- package/dist/web/assets/chorus-harmony-DnJYs_tp.ogg +0 -0
- package/dist/web/assets/chorus-lead-CFpg5DC1.ogg +0 -0
- package/dist/web/assets/chunk-BNfsY4o8.js +1 -0
- package/dist/web/assets/chunk-BSm8IhPY.js +1 -0
- package/dist/web/assets/chunk-Bi6EQAkf.js +1 -0
- package/dist/web/assets/chunk-BmDwUWlX.js +1 -0
- package/dist/web/assets/chunk-Ds4joAI5.js +46 -0
- package/dist/web/assets/chunk-V3YGpFIw.js +1 -0
- package/dist/web/assets/chunk-XGhNFWse.js +1 -0
- package/dist/web/assets/dialogue-card-A5zmbNhu.ogg +0 -0
- package/dist/web/assets/groove-bass-BFNelLKi.ogg +0 -0
- package/dist/web/assets/groove-drums-BY1SBntR.ogg +0 -0
- package/dist/web/assets/groove-harmony-C0CrBzu3.ogg +0 -0
- package/dist/web/assets/groove-lead-CEYPzm5U.ogg +0 -0
- package/dist/web/assets/groove-ln-zQmTb.ogg +0 -0
- package/dist/web/assets/guess-high-CL6mF18x.ogg +0 -0
- package/dist/web/assets/guess-low-C3UnKayZ.ogg +0 -0
- package/dist/web/assets/higher-BevsMIWl.ogg +0 -0
- package/dist/web/assets/identity-0EPS3msD.ogg +0 -0
- package/dist/web/assets/index-DpT0dtHc.css +1 -0
- package/dist/web/assets/intro-DeRh6kUx.ogg +0 -0
- package/dist/web/assets/intro-bass-D63IPU0H.ogg +0 -0
- package/dist/web/assets/intro-drums-Dt9QO534.ogg +0 -0
- package/dist/web/assets/intro-harmony-DBsMG9jJ.ogg +0 -0
- package/dist/web/assets/intro-lead-DWcWS1ia.ogg +0 -0
- package/dist/web/assets/jar-coin-rtCvspuq.ogg +0 -0
- package/dist/web/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/web/assets/ledger-tick-C1rQgQGX.ogg +0 -0
- package/dist/web/assets/night-B_bMOZcf.ogg +0 -0
- package/dist/web/assets/night-bass-B-7Ay9ME.ogg +0 -0
- package/dist/web/assets/night-drums-zEtqWXX3.ogg +0 -0
- package/dist/web/assets/night-harmony-C5Ix2yce.ogg +0 -0
- package/dist/web/assets/night-lead-B7KMlRyj.ogg +0 -0
- package/dist/web/assets/ourturn-DX78hTEz.ogg +0 -0
- package/dist/web/assets/plus-jakarta-sans-latin-400-normal-Dhut76fR.woff2 +0 -0
- package/dist/web/assets/plus-jakarta-sans-latin-500-normal-Bf-nb4oT.woff2 +0 -0
- package/dist/web/assets/plus-jakarta-sans-latin-600-normal-DLTa1BUW.woff2 +0 -0
- package/dist/web/assets/plus-jakarta-sans-latin-700-normal-CfpNZvy6.woff2 +0 -0
- package/dist/web/assets/reveal-BmWAGHih.ogg +0 -0
- package/dist/web/assets/review-split-Dac4zagw.ogg +0 -0
- package/dist/web/assets/shutter-uhz2Y9S9.ogg +0 -0
- package/dist/web/assets/soclose-CiUFR5St.ogg +0 -0
- package/dist/web/assets/stinger-TnnzHAMN.ogg +0 -0
- package/dist/web/assets/stomp-mzIk4cGm.ogg +0 -0
- package/dist/web/assets/syne-latin-700-normal-AF3Rs61n.woff2 +0 -0
- package/dist/web/assets/syne-latin-800-normal-EehdNYzx.woff2 +0 -0
- package/dist/web/assets/tension-BHvWG5ru.ogg +0 -0
- package/dist/web/assets/tension-bass-4G-2qA9W.ogg +0 -0
- package/dist/web/assets/tension-drums-D7sdehJr.ogg +0 -0
- package/dist/web/assets/tension-harmony-FyPldmLb.ogg +0 -0
- package/dist/web/assets/tension-lead-C5uoFMR8.ogg +0 -0
- package/dist/web/assets/why-clock-Dzs1A_ym.ogg +0 -0
- package/dist/web/favicon.svg +1 -0
- package/dist/web/index.html +16 -0
- package/dist/web/licenses/OFL-Archivo.txt +93 -0
- package/dist/web/licenses/OFL-DelaGothic.txt +93 -0
- package/dist/web/licenses/OFL-MartianMono.txt +93 -0
- package/package.json +63 -6
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { EMOJI_NAMES } from './emoji-names.js';
|
|
2
|
+
import { displayLexiconTerm, HEADLINE_TERMS } from './lexicons.js';
|
|
3
|
+
import { CONTENT_EXCLUDED, CONTENT_FIELDS, CONTENT_GATES, CONTENT_VETO_ONLY, LEXICONS, LEXICON_HASHES, SCRIPTS, validEmoji, validOpenTerm } from './policy.js';
|
|
4
|
+
function requireContent(ok) {
|
|
5
|
+
if (!ok)
|
|
6
|
+
throw new Error('INVALID_CONTENT_CHAPTER');
|
|
7
|
+
}
|
|
8
|
+
const count = v => requireContent(typeof v === 'number' && Number.isSafeInteger(v) && v >= 0);
|
|
9
|
+
const amount = v => requireContent(typeof v === 'number' && Number.isFinite(v) && v >= 0);
|
|
10
|
+
const fraction = v => requireContent(typeof v === 'number' && v >= 0 && v <= 1);
|
|
11
|
+
const literal = (value) => v => requireContent(v === value);
|
|
12
|
+
const oneOf = (values) => v => requireContent(values.includes(v));
|
|
13
|
+
const nullable = (check) => v => { if (v !== null)
|
|
14
|
+
check(v); };
|
|
15
|
+
const object = v => requireContent(v && typeof v === 'object' &&
|
|
16
|
+
[Object.prototype, null].includes(Object.getPrototypeOf(v)));
|
|
17
|
+
const empty = () => { };
|
|
18
|
+
const integer = (min, max) => v => {
|
|
19
|
+
count(v);
|
|
20
|
+
requireContent(v >= min && v <= max);
|
|
21
|
+
};
|
|
22
|
+
const array = (check, max, min = 0) => v => {
|
|
23
|
+
requireContent(Array.isArray(v) && v.length >= min && v.length <= max && Object.keys(v).length === v.length);
|
|
24
|
+
for (const item of v)
|
|
25
|
+
check(item);
|
|
26
|
+
};
|
|
27
|
+
const fixed = (check, length) => array(check, length, length);
|
|
28
|
+
const record = (keys, check) => shape({}, Object.fromEntries(keys.map(key => [key, check])));
|
|
29
|
+
function shape(required, optional = {}) {
|
|
30
|
+
return value => {
|
|
31
|
+
object(value);
|
|
32
|
+
const v = value;
|
|
33
|
+
for (const key of Object.keys(v))
|
|
34
|
+
requireContent(Object.hasOwn(required, key) || Object.hasOwn(optional, key));
|
|
35
|
+
for (const [key, check] of Object.entries(required)) {
|
|
36
|
+
requireContent(Object.hasOwn(v, key));
|
|
37
|
+
check(v[key]);
|
|
38
|
+
}
|
|
39
|
+
for (const [key, check] of Object.entries(optional))
|
|
40
|
+
if (Object.hasOwn(v, key))
|
|
41
|
+
check(v[key]);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const redactions = shape({ secret: count, pii: count, identifier: count });
|
|
45
|
+
const byRole = (check) => shape({ user: check, agent: check });
|
|
46
|
+
const sketch = shape({ capacity: count, evictions: count, errorFloor: count });
|
|
47
|
+
const equalArray = (expected) => v => requireContent(Array.isArray(v) &&
|
|
48
|
+
v.length === expected.length && expected.every((value, index) => value === v[index]));
|
|
49
|
+
export function validateContentReceipt(raw, chapter) {
|
|
50
|
+
shape({
|
|
51
|
+
mode: literal('content-opt-in'), fieldsRead: equalArray(CONTENT_FIELDS), fieldsNeverRead: equalArray(CONTENT_EXCLUDED),
|
|
52
|
+
categoriesDerived: equalArray(chapter.lexicon.map(c => c.id)), lexiconHash: literal(LEXICON_HASHES[chapter.lexiconVersion]),
|
|
53
|
+
rawBytesPersisted: literal(0), recordsSeen: byRole(count), charsSeen: count, oversizedMessagesSkipped: count,
|
|
54
|
+
duplicateMessagesSkipped: count, proseShare: fraction,
|
|
55
|
+
droppedLinesByKind: record(['fence', 'indent', 'stack', 'diff', 'log', 'shell', 'symbol', 'markup'], count),
|
|
56
|
+
harnessWrapperBlocksDropped: count, redactions: byRole(redactions),
|
|
57
|
+
sketches: shape({ userWords: sketch, agentWords: sketch, phrases: sketch, openers: sketch, userEmoji: sketch, agentEmoji: sketch }),
|
|
58
|
+
gates: shape(Object.fromEntries(Object.entries(CONTENT_GATES).map(([key, value]) => [key, literal(value)]))),
|
|
59
|
+
}, { timeBudgetMessagesSkipped: count, tokenLimitMessagesSkipped: count, injectedMessagesSkipped: count,
|
|
60
|
+
phraseCandidatesSuppressed: literal(true), vetoOnlyFields: equalArray(CONTENT_VETO_ONLY) })(raw);
|
|
61
|
+
return raw;
|
|
62
|
+
}
|
|
63
|
+
const checkVersion = oneOf(Object.keys(LEXICONS));
|
|
64
|
+
const emoji = v => {
|
|
65
|
+
object(v);
|
|
66
|
+
const row = v;
|
|
67
|
+
requireContent(typeof row.emoji === 'string' && validEmoji(row.emoji));
|
|
68
|
+
shape({ emoji: literal(row.emoji), count: integer(3, Number.MAX_SAFE_INTEGER) }, { name: literal(EMOJI_NAMES[row.emoji]) })(v);
|
|
69
|
+
};
|
|
70
|
+
const harnesses = ['claude-code', 'codex-cli', 'gemini-cli', 'opencode', 'cursor-ide', 'cline', 'roo-code', 'pi-agent', 'aider'];
|
|
71
|
+
export function validateContentChapter(raw) {
|
|
72
|
+
object(raw);
|
|
73
|
+
const chapter = raw;
|
|
74
|
+
checkVersion(chapter.lexiconVersion);
|
|
75
|
+
const lexicon = LEXICONS[chapter.lexiconVersion];
|
|
76
|
+
const seen = new Set();
|
|
77
|
+
const termFrom = (terms) => v => requireContent(typeof v === 'string' && terms.has(v));
|
|
78
|
+
const oneWord = new Set([...lexicon.values()].filter(c => c.role === 'user' && !c.censor)
|
|
79
|
+
.flatMap(c => c.phrases.filter(term => !term.includes(' '))));
|
|
80
|
+
const termWithLabel = (allowed, numeric) => v => {
|
|
81
|
+
object(v);
|
|
82
|
+
const row = v;
|
|
83
|
+
termFrom(allowed)(row.term);
|
|
84
|
+
shape({ term: literal(row.term), ...numeric }, { display: literal(displayLexiconTerm(row.term)) })(v);
|
|
85
|
+
};
|
|
86
|
+
const goOnTerms = new Set(lexicon.get('go-on').phrases.filter(term => !term.includes(' ')));
|
|
87
|
+
const agentTerms = new Set([...lexicon.values()].filter(c => c.role === 'agent').flatMap(c => c.phrases));
|
|
88
|
+
const openTerm = (min, max) => v => {
|
|
89
|
+
requireContent(typeof v === 'string' && validOpenTerm(v, chapter.lexiconVersion.endsWith('preview')));
|
|
90
|
+
integer(min, max)(v.split(' ').length);
|
|
91
|
+
};
|
|
92
|
+
const open = (term) => ({
|
|
93
|
+
term, count: integer(8, Number.MAX_SAFE_INTEGER), sessions: integer(3, 32), days: integer(2, 32),
|
|
94
|
+
});
|
|
95
|
+
const category = v => {
|
|
96
|
+
object(v);
|
|
97
|
+
const row = v;
|
|
98
|
+
const allowed = lexicon.get(row.id);
|
|
99
|
+
requireContent(allowed && !seen.has(row.id));
|
|
100
|
+
seen.add(row.id);
|
|
101
|
+
shape({
|
|
102
|
+
id: literal(allowed.id), role: literal(allowed.role), shareEligible: literal(allowed.shareEligible),
|
|
103
|
+
total: count, messages: count, sessions: integer(1, 5), byHour: fixed(count, 24), byMonth: fixed(count, 12),
|
|
104
|
+
topTerms: array(termWithLabel(allowed.shown, { count, sessions: integer(1, 5) }), 5),
|
|
105
|
+
}, HEADLINE_TERMS[row.id] ? { headline: shape(Object.fromEntries(HEADLINE_TERMS[row.id].map(term => [term, count]))) } : {})(row);
|
|
106
|
+
if (row.headline) {
|
|
107
|
+
requireContent(Object.values(row.headline).reduce((sum, n) => sum + n, 0) <= row.total);
|
|
108
|
+
for (const entry of row.topTerms) {
|
|
109
|
+
if (Object.hasOwn(row.headline, entry.term))
|
|
110
|
+
requireContent(row.headline[entry.term] === entry.count);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
requireContent(row.total > 0 && row.messages > 0 && row.messages <= row.total &&
|
|
114
|
+
row.byHour.reduce((a, b) => a + b, 0) === row.total && row.byMonth.reduce((a, b) => a + b, 0) === row.total);
|
|
115
|
+
};
|
|
116
|
+
shape({
|
|
117
|
+
lexiconVersion: checkVersion, lexicon: array(category, lexicon.size),
|
|
118
|
+
style: shape({
|
|
119
|
+
prompts: count, words: count, promptsWithLetters: count, oneWord: count,
|
|
120
|
+
oneWordTop: nullable(termWithLabel(oneWord, { count })), lengthBuckets: fixed(count, 7),
|
|
121
|
+
longestWords: count, longestMonth: nullable(integer(1, 12)), lowercaseShare: fraction, questionShare: fraction,
|
|
122
|
+
capsPrompts: count, userExclaimPrompts: count, agentExclaimReplies: count, codeShareEstimate: fraction,
|
|
123
|
+
stackLines: count, scripts: record(Object.keys(SCRIPTS), count),
|
|
124
|
+
}),
|
|
125
|
+
emoji: shape({ user: array(emoji, 10), agent: array(emoji, 10), total: count }),
|
|
126
|
+
combos: shape({
|
|
127
|
+
swearPeakHour: nullable(integer(0, 23)), swearSessions: integer(0, 5), whyPeakHour: nullable(integer(0, 23)),
|
|
128
|
+
pleasePer100ByMonth: fixed(nullable(amount), 12), thanksLastPromptLong: nullable(fraction),
|
|
129
|
+
thanksLastPromptShort: nullable(fraction), apologies: byRole(count),
|
|
130
|
+
agentOpener: nullable(termWithLabel(agentTerms, { count: integer(20, Number.MAX_SAFE_INTEGER), sessions: literal(5) })),
|
|
131
|
+
goOnStreak: count, thanksByLanguage: record(chapter.lexiconVersion.endsWith('preview') ?
|
|
132
|
+
['en', 'de', 'fr', 'es', 'it', 'pt', 'ru', 'zh', 'ja', 'ko', 'tr', 'pl', 'nl'] : ['en'], count),
|
|
133
|
+
swearAtRhythmPeak: nullable(count), whyDuringLongestNight: nullable(count),
|
|
134
|
+
apologiesAfterError: nullable(shape({ errorsWithReply: count, apologies: count })),
|
|
135
|
+
mainEventLastPromptThanks: nullable(oneOf([true, false])), oneWordLeashMaxToolCalls: nullable(count),
|
|
136
|
+
catchphrasesByHarness: record(harnesses, count),
|
|
137
|
+
}, { goOnStreakTerm: nullable(termFrom(goOnTerms)) }),
|
|
138
|
+
safety: redactions, receipt: empty,
|
|
139
|
+
}, {
|
|
140
|
+
private: shape({
|
|
141
|
+
localOnly: literal(true), reviewRequired: literal(true),
|
|
142
|
+
phrases: array(shape(open(openTerm(2, 4))), 20),
|
|
143
|
+
words: array(shape({ ...open(openTerm(1, 1)), agentCountAtMost: count,
|
|
144
|
+
g2: v => { amount(v); requireContent(v >= 10.83); } }), 15),
|
|
145
|
+
openers: array(shape(open(openTerm(1, 2))), 10),
|
|
146
|
+
}),
|
|
147
|
+
})(raw);
|
|
148
|
+
validateContentReceipt(chapter.receipt, chapter);
|
|
149
|
+
requireContent(!chapter.combos.goOnStreakTerm || chapter.combos.goOnStreak > 0);
|
|
150
|
+
requireContent(!chapter.private?.openers.length || chapter.style.prompts >= 50);
|
|
151
|
+
return chapter;
|
|
152
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Banned generic AI-slop, population claims, outcome claims, mental-state claims
|
|
2
|
+
const BANNED_PATTERNS = [
|
|
3
|
+
{ rule: 'slop-vocab', regex: /\b(journey|unlock|unleash|supercharge|elevate|seamless|delve|tapestry|testament|game[- ]changer|dive in|ai[- ]powered)\b/i },
|
|
4
|
+
{ rule: 'population-claim', regex: /\b(?:top\s+\d+%|(?:percentile|more than most|average developer|unlike others|faster than most)\b)/i },
|
|
5
|
+
{ rule: 'outcome-claim', regex: /\b(lines of code|bugs fixed|time saved|productivity score|shipped\s+\d+)\b/i },
|
|
6
|
+
{ rule: 'mental-state-claim', regex: /\b(you were frustrated|you were exhausted|you were stuck|while you slept|you were asleep)\b/i },
|
|
7
|
+
{ rule: 'emoji-in-copy', regex: /[\u{1F300}-\u{1FAFF}\u{2600}-\u{26FF}]/u },
|
|
8
|
+
];
|
|
9
|
+
export function lintText(text, path) {
|
|
10
|
+
const violations = [];
|
|
11
|
+
for (const { rule, regex } of BANNED_PATTERNS) {
|
|
12
|
+
const match = regex.exec(text);
|
|
13
|
+
if (match) {
|
|
14
|
+
violations.push({
|
|
15
|
+
path,
|
|
16
|
+
rule,
|
|
17
|
+
snippet: text.slice(Math.max(0, match.index - 20), Math.min(text.length, match.index + 40)),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return violations;
|
|
22
|
+
}
|
|
23
|
+
const CONTENT_COPY_RULES = [
|
|
24
|
+
{ rule: 'content-mental-state', regex: /\b(?:frustrat\w*|angry|anger|rage|upset|annoyed|stressed|mad at|losing it|meltdown|you snapped)\b/i },
|
|
25
|
+
{ rule: 'content-counted', regex: /\bwe didn['’]t look\b/i },
|
|
26
|
+
];
|
|
27
|
+
export function lintContentCopy(text, path) {
|
|
28
|
+
return [...lintText(text, path), ...CONTENT_COPY_RULES.flatMap(({ rule, regex }) => regex.test(text) ? [{ path, rule, snippet: text.slice(0, 80) }] : [])];
|
|
29
|
+
}
|
|
30
|
+
export function lintReportCopy(report) {
|
|
31
|
+
const violations = [];
|
|
32
|
+
const check = (value, path) => {
|
|
33
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
34
|
+
violations.push(...(report.content ? lintContentCopy(value, path) : lintText(value, path)));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
check(report.capturedWindow.titleLabel, 'capturedWindow.titleLabel');
|
|
38
|
+
check(report.capturedWindow.disclosure, 'capturedWindow.disclosure');
|
|
39
|
+
check(report.rhythm.solarNoon.copy, 'rhythm.solarNoon.copy');
|
|
40
|
+
check(report.rhythm.witchingHour.copy, 'rhythm.witchingHour.copy');
|
|
41
|
+
check(report.rhythm.longestNight.copy, 'rhythm.longestNight.copy');
|
|
42
|
+
check(report.rhythm.streaks.copy, 'rhythm.streaks.copy');
|
|
43
|
+
check(report.rhythm.weekendContrast.copy, 'rhythm.weekendContrast.copy');
|
|
44
|
+
check(report.craft.readEditCopy, 'craft.readEditCopy');
|
|
45
|
+
check(report.craft.bounceBack.copy, 'craft.bounceBack.copy');
|
|
46
|
+
check(report.craft.leashLength.copy, 'craft.leashLength.copy');
|
|
47
|
+
check(report.craft.pilotSplit.copy, 'craft.pilotSplit.copy');
|
|
48
|
+
check(report.delegation.orchestra.copy, 'delegation.orchestra.copy');
|
|
49
|
+
check(report.delegation.cliffDiving.copy, 'delegation.cliffDiving.copy');
|
|
50
|
+
check(report.delegation.parallelism.copy, 'delegation.parallelism.copy');
|
|
51
|
+
check(report.delegation.unattended.copy, 'delegation.unattended.copy');
|
|
52
|
+
check(report.mainEvent.punchline, 'mainEvent.punchline');
|
|
53
|
+
if (report.content) {
|
|
54
|
+
for (const [i, row] of report.mainEvent.cvrTranscript.entries())
|
|
55
|
+
check(row.entry, `mainEvent.cvrTranscript.${i}.entry`);
|
|
56
|
+
}
|
|
57
|
+
check(report.evolution.modelRiver.migration.copy, 'evolution.modelRiver.migration.copy');
|
|
58
|
+
check(report.evolution.harnessPolyglot.copy, 'evolution.harnessPolyglot.copy');
|
|
59
|
+
check(report.evolution.turningPoint.copy, 'evolution.turningPoint.copy');
|
|
60
|
+
check(report.scale.writtenAnchor?.metaphorCopy, 'scale.writtenAnchor.metaphorCopy');
|
|
61
|
+
check(report.scale.cacheMastery.copy, 'scale.cacheMastery.copy');
|
|
62
|
+
check(report.scale.apiEquivalent.disclaimer, 'scale.apiEquivalent.disclaimer');
|
|
63
|
+
check(report.probableCause.headline, 'probableCause.headline');
|
|
64
|
+
check(report.probableCause.evidence, 'probableCause.evidence');
|
|
65
|
+
check(report.archetype.tagline, 'archetype.tagline');
|
|
66
|
+
check(report.archetype.body, 'archetype.body');
|
|
67
|
+
check(report.archetype.whatWouldChangeIt, 'archetype.whatWouldChangeIt');
|
|
68
|
+
for (const f of report.findings) {
|
|
69
|
+
check(f.statement, `findings.${f.id}.statement`);
|
|
70
|
+
}
|
|
71
|
+
for (const r of report.safetyRecommendations) {
|
|
72
|
+
check(r.text, `safetyRecommendations.${r.id}.text`);
|
|
73
|
+
}
|
|
74
|
+
for (const w of report.winks) {
|
|
75
|
+
check(w.text, `winks.${w.id}.text`);
|
|
76
|
+
}
|
|
77
|
+
for (const stat of report.shareableStats) {
|
|
78
|
+
check(stat.label, `shareableStats.${stat.id}.label`);
|
|
79
|
+
if (stat.epistemic === 'estimated' && !stat.value.includes('≈')) {
|
|
80
|
+
violations.push({
|
|
81
|
+
path: `shareableStats.${stat.id}.value`,
|
|
82
|
+
rule: 'estimated-missing-tilde',
|
|
83
|
+
snippet: stat.value,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return violations;
|
|
88
|
+
}
|
|
89
|
+
export function lintShareCard(card) {
|
|
90
|
+
const violations = [];
|
|
91
|
+
violations.push(...lintText(card.probableCause, 'shareCard.probableCause'));
|
|
92
|
+
violations.push(...lintText(card.archetypeTagline, 'shareCard.archetypeTagline'));
|
|
93
|
+
violations.push(...lintText(card.suggestedCaption, 'shareCard.suggestedCaption'));
|
|
94
|
+
violations.push(...lintText(card.altText, 'shareCard.altText'));
|
|
95
|
+
for (const s of card.stats) {
|
|
96
|
+
if (s.epistemic === 'estimated' && !s.value.includes('≈')) {
|
|
97
|
+
violations.push({
|
|
98
|
+
path: `shareCard.stats.${s.label}`,
|
|
99
|
+
rule: 'estimated-missing-tilde',
|
|
100
|
+
snippet: s.value,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return violations;
|
|
105
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { LEXICONS, SWEARS } from './content/policy.js';
|
|
2
|
+
import { sanitizeShortLabel } from './validators.js';
|
|
3
|
+
export const SHARE_DIMENSIONS = {
|
|
4
|
+
'4:5': { width: 1080, height: 1350 },
|
|
5
|
+
'16:9': { width: 1200, height: 630 },
|
|
6
|
+
'1:1': { width: 1080, height: 1080 },
|
|
7
|
+
'9:16': { width: 1080, height: 1920 },
|
|
8
|
+
};
|
|
9
|
+
const CONTENT_LABELS = {
|
|
10
|
+
please: 'Please', thanks: 'Thanks', 'sorry-user': 'User apologies', 'swear-mild': 'Mild swear jar',
|
|
11
|
+
'swear-strong': 'Strong swear jar', why: 'Why', 'again-still': 'Repeat requests', 'not-working': 'Failure phrases',
|
|
12
|
+
praise: 'User praise', instruction: 'Instructions', 'go-on': 'Go-on words', undo: 'Undo',
|
|
13
|
+
'agent-agree': 'Agent agreement', 'agent-sorry': 'Agent apologies', 'agent-confident': 'Agent confidence',
|
|
14
|
+
'agent-praise': 'Agent praise',
|
|
15
|
+
};
|
|
16
|
+
export function shareableContentStats(chapter, includeCensoredSwears = false) {
|
|
17
|
+
if (!chapter)
|
|
18
|
+
return [];
|
|
19
|
+
return chapter.lexicon.flatMap(row => {
|
|
20
|
+
const category = LEXICONS[chapter.lexiconVersion]?.get(row.id);
|
|
21
|
+
const label = CONTENT_LABELS[row.id];
|
|
22
|
+
const swear = SWEARS.has(row.id);
|
|
23
|
+
if (!label || !category?.shareEligible || !row.shareEligible || !Number.isSafeInteger(row.total) || row.total <= 0 ||
|
|
24
|
+
(swear && (!includeCensoredSwears || row.total < 10 || row.sessions < 3)))
|
|
25
|
+
return [];
|
|
26
|
+
const top = swear && row.topTerms.find(term => category.shown.has(term.term));
|
|
27
|
+
return [{
|
|
28
|
+
id: `content-${row.id}`, label: top ? `${label} (${top.term})` : label, value: row.total.toLocaleString('en-US'),
|
|
29
|
+
epistemic: 'observed', defaultSelected: false, sensitiveByDefault: swear,
|
|
30
|
+
}];
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function defaultShareOptions(report) {
|
|
34
|
+
const defaultSelected = report.shareableStats
|
|
35
|
+
.filter((s) => s.defaultSelected && !s.sensitiveByDefault)
|
|
36
|
+
.slice(0, 3)
|
|
37
|
+
.map((s) => s.id);
|
|
38
|
+
return {
|
|
39
|
+
format: '4:5',
|
|
40
|
+
selectedStatIds: defaultSelected,
|
|
41
|
+
includeWindowLabel: false,
|
|
42
|
+
includeHandle: false,
|
|
43
|
+
handleText: report.investigatorLabel !== 'the crew' ? report.investigatorLabel : '',
|
|
44
|
+
includeToolAttribution: true,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Strictly allowlisted ShareCardData projection.
|
|
49
|
+
* Raw paths, project HMACs, receipt rows, and unapproved sensitive fields can never enter here.
|
|
50
|
+
*/
|
|
51
|
+
export function buildShareCardData(report, options) {
|
|
52
|
+
const dims = SHARE_DIMENSIONS[options.format] ?? SHARE_DIMENSIONS['4:5'];
|
|
53
|
+
const statLookup = new Map(report.shareableStats.filter(s => !s.id.startsWith('content-')).map(s => [s.id, s]));
|
|
54
|
+
const contentStats = shareableContentStats(report.content, options.includeCensoredSwears);
|
|
55
|
+
const contentIds = new Set(options.selectedContentStatIds?.filter(id => id.startsWith('content-')));
|
|
56
|
+
for (const stat of contentStats)
|
|
57
|
+
if (contentIds.has(stat.id))
|
|
58
|
+
statLookup.set(stat.id, stat);
|
|
59
|
+
const ids = [...new Set([...options.selectedStatIds.filter(id => !id.startsWith('content-')), ...contentIds])];
|
|
60
|
+
const chosenStats = [];
|
|
61
|
+
for (const id of ids) {
|
|
62
|
+
if (chosenStats.length >= 3)
|
|
63
|
+
break;
|
|
64
|
+
const stat = statLookup.get(id);
|
|
65
|
+
if (!stat)
|
|
66
|
+
continue;
|
|
67
|
+
const value = stat.epistemic === 'estimated' && !stat.value.includes('≈')
|
|
68
|
+
? `≈ ${stat.value}`
|
|
69
|
+
: stat.value;
|
|
70
|
+
chosenStats.push({
|
|
71
|
+
label: stat.label,
|
|
72
|
+
value,
|
|
73
|
+
epistemic: stat.epistemic,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const windowLabel = options.includeWindowLabel
|
|
77
|
+
? report.capturedWindow.titleLabel.toUpperCase()
|
|
78
|
+
: null;
|
|
79
|
+
const handleLabel = options.includeHandle && options.handleText.trim().length > 0
|
|
80
|
+
? sanitizeShortLabel(options.handleText, '', 24)
|
|
81
|
+
: null;
|
|
82
|
+
const reportTitle = report.format === 'preliminary'
|
|
83
|
+
? `COAUTHORED · ${report.year} ROOKIE`
|
|
84
|
+
: `COAUTHORED · ${report.year}`;
|
|
85
|
+
const legendSentence = 'Activity waves from your coding rhythm across the year.';
|
|
86
|
+
const activitySummary = options.includeWindowLabel
|
|
87
|
+
? report.helicorder.textEquivalent
|
|
88
|
+
: `Coding activity waves for ${report.year} across ${report.capturedWindow.activeDays} active day${report.capturedWindow.activeDays === 1 ? '' : 's'} (${report.totals.sessions} session${report.totals.sessions === 1 ? '' : 's'}).`;
|
|
89
|
+
const statsSummary = chosenStats.map((s) => `${s.label}: ${s.value}`).join(', ');
|
|
90
|
+
const altText = `${reportTitle}. ` +
|
|
91
|
+
`${activitySummary} ` +
|
|
92
|
+
`Persona: ${report.archetype.title}. ` +
|
|
93
|
+
`${report.archetype.tagline}` +
|
|
94
|
+
(statsSummary ? ` Stats: ${statsSummary}.` : '');
|
|
95
|
+
const attributionSuffix = options.includeToolAttribution
|
|
96
|
+
? ' — made with npx coauthored'
|
|
97
|
+
: '';
|
|
98
|
+
const suggestedCaption = `My ${report.year} Coding Wrapped: ${report.archetype.title}. ` +
|
|
99
|
+
`${report.archetype.tagline}${attributionSuffix}`;
|
|
100
|
+
return {
|
|
101
|
+
format: options.format,
|
|
102
|
+
width: dims.width,
|
|
103
|
+
height: dims.height,
|
|
104
|
+
year: report.year,
|
|
105
|
+
registration: report.registration,
|
|
106
|
+
docketNumber: report.docketNumber,
|
|
107
|
+
statsSeedHex: report.statsSeedHex,
|
|
108
|
+
reportTitle,
|
|
109
|
+
windowLabel,
|
|
110
|
+
archetypeTitle: report.archetype.title,
|
|
111
|
+
archetypeTagline: report.archetype.tagline,
|
|
112
|
+
probableCause: report.probableCause.headline,
|
|
113
|
+
deadWaxInscription: report.deadWaxInscription,
|
|
114
|
+
handleLabel: handleLabel && handleLabel.length > 0 ? handleLabel : null,
|
|
115
|
+
toolAttribution: options.includeToolAttribution ? 'coauthored · local-only' : null,
|
|
116
|
+
stats: chosenStats,
|
|
117
|
+
helicorder: {
|
|
118
|
+
days: report.helicorder.days.map((d) => ({
|
|
119
|
+
date: d.date,
|
|
120
|
+
buckets: d.buckets.slice(),
|
|
121
|
+
})),
|
|
122
|
+
events: report.helicorder.events.map((e) => ({
|
|
123
|
+
date: e.date,
|
|
124
|
+
minuteOfDay: e.minuteOfDay,
|
|
125
|
+
code: e.code,
|
|
126
|
+
})),
|
|
127
|
+
},
|
|
128
|
+
legendSentence,
|
|
129
|
+
altText,
|
|
130
|
+
suggestedCaption,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|