Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import { openCodeGoFacts, parseGoTraining } from './opencode-go-facts.ts'
4
5describe('openCodeGoFacts', () => {
6 it('requires the session header and User-Agent on every Go row', () => {
7 const facts = openCodeGoFacts('opencode-go', 'glm-5.2')
8 expect(facts.requiredRequestHeaders?.map((header) => header.name)).toEqual([
9 'x-opencode-session',
10 'User-Agent',
11 ])
12 expect(facts.trainsOnRequestData).toBeNull()
13 expect(facts.factSources.requiredRequestHeaders).toMatchObject({
14 derivation: 'docs-derived',
15 sourceUrl: 'https://opencode.ai/docs/console/go/',
16 })
17 expect(facts.factSources.trainsOnRequestData).toBeUndefined()
18 })
19
20 it('sets training only on the id whose probe stated it', () => {
21 const argon = openCodeGoFacts('opencode-go', 'gemini-4-argon-contributor')
22 expect(argon.trainsOnRequestData).toBe(true)
23 expect(argon.factSources.trainsOnRequestData).toMatchObject({
24 derivation: 'probe-verified',
25 verifiedAt: '2026-10-23',
26 })
27 expect(
28 openCodeGoFacts('opencode-go', 'muse-spark-1.3-contributor')
29 .trainsOnRequestData,
30 ).toBeNull()
31 expect(openCodeGoFacts('opencode', 'gemini-4-argon-contributor')).toEqual({
32 requiredRequestHeaders: null,
33 trainsOnRequestData: null,
34 factSources: {},
35 })
36 })
37})
38
39const PRIVACY = `
40## Endpoints
41
42| Model | Model ID | Endpoint |
43| ----- | -------- | -------- |
44| Muse Spark 1.3 Contributor | muse-spark-1.3-contributor | \`https://opencode.ai/inference/go/openai/v1/responses\` |
45| Muse Spark 1.2 Contributor | muse-spark-1.2-contributor | \`https://opencode.ai/inference/go/openai/v1/responses\` |
46| Gemini 4 Argon | gemini-4-argon | \`https://opencode.ai/inference/go/google/v1beta/models/gemini-4-argon\` |
47| Other Contributor | other-contributor | \`https://opencode.ai/inference/go/openai/v1/responses\` |
48
49## Privacy
50
51| Model | Model training | Data retention |
52| ----- | -------------- | -------------- |
53| Muse Spark 1.3 Contributor | Yes | Not ZDR |
54| Muse Spark 1.2 Contributor | Yes | Not ZDR |
55| Gemini 4 Argon | Not used | 0 days |
56| Other Contributor | Not used | 0 days |
57`
58
59describe('parseGoTraining', () => {
60 it('binds Yes to that row’s model id and does not read the suffix', () => {
61 const training = parseGoTraining(PRIVACY)
62 expect(training.get('muse-spark-1.3-contributor')).toBe(true)
63 expect(training.get('muse-spark-1.2-contributor')).toBe(true)
64 expect(training.get('gemini-4-argon')).toBe(false)
65 expect(training.get('other-contributor')).toBe(false)
66 expect(training.has('gemini-4-argon-contributor')).toBe(false)
67 })
68
69 it('throws when a privacy training cell is empty', () => {
70 expect(() =>
71 parseGoTraining(`
72## Endpoints
73
74| Model | Model ID |
75| ----- | -------- |
76| Mini | mini |
77
78## Privacy
79
80| Model | Model training |
81| ----- | -------------- |
82| Mini | |
83`),
84 ).toThrow(/Mini/)
85 })
86
87 it('throws when a privacy name has no endpoint id', () => {
88 expect(() =>
89 parseGoTraining(`
90## Endpoints
91
92| Model | Model ID |
93| ----- | -------- |
94| Mini | mini |
95
96## Privacy
97
98| Model | Model training |
99| ----- | -------------- |
100| Missing | Yes |
101`),
102 ).toThrow(/Missing/)
103 })
104})