@2cmddev/2cmd 0.0.0-stage → 0.1.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.
Files changed (93) hide show
  1. package/.opencode/command/2cmd-audit.md +5 -0
  2. package/.opencode/command/2cmd-debt.md +5 -0
  3. package/.opencode/command/2cmd-gain.md +5 -0
  4. package/.opencode/command/2cmd-help.md +5 -0
  5. package/.opencode/command/2cmd-review.md +5 -0
  6. package/.opencode/command/2cmd.md +5 -0
  7. package/.opencode/plugins/2cmd-frontmatter.cjs +63 -0
  8. package/.opencode/plugins/2cmd.mjs +206 -0
  9. package/.opencode/plugins/index.js +4 -0
  10. package/.qoder/rules/2cmd.md +31 -0
  11. package/.qoder-plugin/plugin.json +16 -0
  12. package/.zcode-plugin/plugin.json +13 -0
  13. package/AGENTS.md +33 -0
  14. package/LICENSE +22 -0
  15. package/README.md +133 -2
  16. package/codex/answer.mjs +164 -0
  17. package/codex/data.mjs +31 -0
  18. package/codex/pty.py +80 -0
  19. package/codex/stats.mjs +105 -0
  20. package/codex/terminal.mjs +388 -0
  21. package/dsh/LICENSE +22 -0
  22. package/dsh/board.js +782 -0
  23. package/dsh/build.mjs +47 -0
  24. package/dsh/bundle.json +2104 -0
  25. package/dsh/client.js +877 -0
  26. package/dsh/cordis.patch.yml +3 -0
  27. package/dsh/index.js +185 -0
  28. package/dsh/ledger.js +50 -0
  29. package/dsh/market.js +152 -0
  30. package/dsh/package.json +24 -0
  31. package/dsh/prices.json +1812 -0
  32. package/dsh/settings-text.mjs +520 -0
  33. package/dsh/settings.js +42 -0
  34. package/dsh/stats.js +106 -0
  35. package/dsh/store.js +32 -0
  36. package/dsh/update-prices.mjs +9 -0
  37. package/dsh/update.js +27 -0
  38. package/dsh/voice-helper/Info.plist +13 -0
  39. package/dsh/voice-helper/Transcript.swift +21 -0
  40. package/dsh/voice-helper/build.sh +10 -0
  41. package/dsh/voice-helper/main.swift +70 -0
  42. package/dsh/voice-helper/test.swift +17 -0
  43. package/dsh/voice.js +63 -0
  44. package/hooks/2cmd-activate.js +219 -0
  45. package/hooks/2cmd-antigravity.js +64 -0
  46. package/hooks/2cmd-band-import.js +305 -0
  47. package/hooks/2cmd-config.js +186 -0
  48. package/hooks/2cmd-instructions.js +104 -0
  49. package/hooks/2cmd-map.js +200 -0
  50. package/hooks/2cmd-mode-tracker.js +248 -0
  51. package/hooks/2cmd-runtime.js +245 -0
  52. package/hooks/2cmd-statusline.ps1 +24 -0
  53. package/hooks/2cmd-statusline.sh +18 -0
  54. package/hooks/2cmd-subagent.js +100 -0
  55. package/hooks/band/board.ts +720 -0
  56. package/hooks/band/buttons.ts +60 -0
  57. package/hooks/band/i18n/de.ts +149 -0
  58. package/hooks/band/i18n/en.ts +150 -0
  59. package/hooks/band/i18n/es.ts +149 -0
  60. package/hooks/band/i18n/fr.ts +149 -0
  61. package/hooks/band/i18n/index.ts +42 -0
  62. package/hooks/band/i18n/ja.ts +149 -0
  63. package/hooks/band/i18n/ko.ts +149 -0
  64. package/hooks/band/i18n/pt.ts +149 -0
  65. package/hooks/band/i18n/ru.ts +149 -0
  66. package/hooks/band/i18n/vi.ts +149 -0
  67. package/hooks/band/i18n/zh-Hans.ts +149 -0
  68. package/hooks/band/i18n/zh-Hant.ts +149 -0
  69. package/hooks/band/logo.ts +3 -0
  70. package/hooks/band/metrics.ts +373 -0
  71. package/hooks/band/register.tsx +681 -0
  72. package/hooks/band/types.d.ts +45 -0
  73. package/hooks/band/windows-board.mjs +20 -0
  74. package/hooks/claude-band.json +6 -0
  75. package/hooks/claude-codex-hooks.json +41 -0
  76. package/hooks/codebuddy-hooks.json +20 -0
  77. package/hooks/copilot-hooks.json +21 -0
  78. package/hooks/cursor-hooks.json +17 -0
  79. package/hooks/qoder-hooks.json +26 -0
  80. package/hooks/zcode-hooks.json +26 -0
  81. package/package.json +56 -4
  82. package/pi-extension/index.js +258 -0
  83. package/pi-extension/names.js +19 -0
  84. package/pi-extension/package.json +8 -0
  85. package/scripts/cursor-hooks.js +145 -0
  86. package/scripts/uninstall.js +92 -0
  87. package/skills/2cmd/SKILL.md +55 -0
  88. package/skills/2cmd-audit/SKILL.md +105 -0
  89. package/skills/2cmd-debt/SKILL.md +46 -0
  90. package/skills/2cmd-gain/SKILL.md +53 -0
  91. package/skills/2cmd-help/SKILL.md +87 -0
  92. package/skills/2cmd-review/SKILL.md +143 -0
  93. package/skills/plugin.json +5 -0
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: 2cmd
3
+ name: 2cmd-dsh
package/dsh/index.js ADDED
@@ -0,0 +1,185 @@
1
+ // DeepSeek Harness host half: adds the rules to the next message, computes the stats and answers the panel.
2
+ import { randomUUID } from 'node:crypto'
3
+ import { readFileSync } from 'node:fs'
4
+ import { boardHtml, buttonText, normalizeButtons } from './board.js'
5
+ import { readTasks, saveTask } from './ledger.js'
6
+ import { money, refreshWhenDue } from './market.js'
7
+ import { changeSettings, chosenLanguage, settingsFor } from './settings.js'
8
+ import { statsOf } from './stats.js'
9
+ import { readSettings } from './store.js'
10
+ import { checkUpdate, siteUrl } from './update.js'
11
+ import { addSystemVoice } from './voice.js'
12
+
13
+ const { strings: STRINGS, rules: RULES, skills: SKILLS } = JSON.parse(readFileSync(new URL('./bundle.json', import.meta.url), 'utf8'))
14
+ const { version: VERSION } = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'))
15
+
16
+ export const name = '2cmd'
17
+ export const inject = ['agents', 'connection']
18
+ export const MODES = ['off', 'hindsight', 'reuse', 'pushback', 'scout']
19
+ const KIND = 'plugin:2cmd'
20
+ const OFF = 'TWOCMD MODE OFF\n\nFrom this message on, do not use any 2Cmd rules loaded earlier in this session.'
21
+
22
+ const COMMAND = `The 2Cmd plugin handles /2cmd. The only levels are ${MODES.join(', ')}.
23
+ If the user's message is just /2cmd, with or without a level, reply with one short line in the user's language: the level now in use, or the valid levels if theirs is not one of them. Do nothing else. Otherwise, ignore this note and answer the message.`
24
+ // The whole message must be the command, so a sentence that mentions it changes nothing.
25
+ const typedMode = ({ content }) => MODES.find(mode => new RegExp(`^\\s*/2cmd\\s+${mode}\\s*$`, 'i').test(content.map(block => block.text ?? '').join('')))
26
+
27
+ // A mode saved before the rename (lite, full, ultra) counts as none, so the session gets the default rules again.
28
+ const modeIn = event => (event?.type === 'user/message' && event.data.source.kind === KIND && MODES.includes(event.data.source.mode) ? event.data.source.mode : undefined)
29
+
30
+ /** The mode last sent to the model. It is saved in the session itself, so it survives restarts and forks. */
31
+ export const sentMode = session => modeIn(session.snapshotEvents().findLast(event => modeIn(event) !== undefined))
32
+
33
+ // Compaction can drop the rules from what the model sees.
34
+ const visibleMode = session => session.surface.nodes.map(seq => modeIn(session.eventAt(seq))).findLast(mode => mode !== undefined)
35
+
36
+ const message = (text, source) => ({ id: randomUUID(), role: 'user', content: [{ type: 'text', text }], source })
37
+ const rules = mode => message(mode === 'off' ? OFF : RULES[mode], { kind: KIND, form: 'instructions', mode })
38
+
39
+ const json = (body, status = 200) => Response.json(body, { status, headers: { 'cache-control': 'no-store' } })
40
+
41
+ // Browsers will not let another site send JSON unless this server allows it.
42
+ const isJson = request => request.headers.get('content-type')?.split(';', 1)[0].trim() === 'application/json'
43
+
44
+ export function apply(ctx) {
45
+ const pending = new Map() // session id -> mode picked but not sent yet
46
+
47
+ const currentMode = (session) => {
48
+ const sent = sentMode(session)
49
+ if (sent !== undefined) return sent
50
+ // A new subagent starts in its parent's mode.
51
+ const parent = session.header.origin === 'subagent' ? ctx.agents.get(session.header.parentSession)?.session : undefined
52
+ return parent ? currentMode(parent) : 'reuse'
53
+ }
54
+
55
+ const pick = (session, mode) => {
56
+ if (mode === currentMode(session)) pending.delete(session.id)
57
+ else pending.set(session.id, mode)
58
+ }
59
+
60
+ // A failed save must not break the chat.
61
+ const record = (session) => {
62
+ if (session.header.origin === 'subagent') return
63
+ try {
64
+ saveTask(session, statsOf(session.ownEvents()), currentMode(session))
65
+ } catch (error) {
66
+ console.warn(`2cmd: could not save the board: ${error.message}`)
67
+ }
68
+ }
69
+
70
+ ctx.on('agent/pre-step', async ({ agent, messages, step, signal }, next) => {
71
+ const decision = await next()
72
+ if (decision.kind !== 'enter' || signal.aborted) return decision
73
+ if (decision.messages.length === 0 && (step === 1 || messages.length > 0)) return decision
74
+ const { session } = agent
75
+ const current = currentMode(session)
76
+ const prompts = messages.filter(entry => entry.source.kind === 'user')
77
+ const typed = prompts.map(typedMode).findLast(Boolean)
78
+ if (typed) pick(session, typed)
79
+ const mode = prompts.length > 0 ? pending.get(session.id) ?? current : current
80
+ const added = []
81
+ if (mode !== current || (mode !== 'off' && visibleMode(session) !== mode)) added.push(rules(mode))
82
+ return added.length > 0 ? { ...decision, messages: [...decision.messages, ...added] } : decision
83
+ })
84
+
85
+ // Cleared only once saved, so a cancelled send keeps the choice and a newer choice is not lost.
86
+ ctx.on('session/event', (session, event) => {
87
+ if (event.type === 'turn/end' || event.type === 'session/title') record(session)
88
+ if (event.type !== 'user/message') return
89
+ if (modeIn(event) !== undefined && pending.get(session.id) === modeIn(event)) pending.delete(session.id)
90
+ })
91
+
92
+ const snapshot = (session) => {
93
+ refreshWhenDue()
94
+ const mode = currentMode(session)
95
+ return {
96
+ mode,
97
+ pending: pending.get(session.id) ?? null,
98
+ // What 启用 goes back to.
99
+ resume: modeIn(session.snapshotEvents().findLast(event => ![undefined, 'off'].includes(modeIn(event)))) ?? (mode === 'off' ? 'reuse' : mode),
100
+ stats: statsOf(session.ownEvents()),
101
+ // The text each button puts in the message box.
102
+ buttons: normalizeButtons(readSettings().buttons, 'dsh').map(button => ({ ...button, text: buttonText(button, 'dsh') })),
103
+ money: money(),
104
+ }
105
+ }
106
+
107
+ // DSH's voice plugin is optional, so this waits for it.
108
+ ctx.inject(['speechToText'], addSystemVoice)
109
+
110
+ // DSH command names cannot start with a digit but skill names can, so /2cmd is a skill. DSH loads its text with the
111
+ // message, and only when the user types its name.
112
+ ctx.inject(['skills'], ({ skills }) => {
113
+ const add = (name, description, content) => skills.register({ name, description, content, source: 'bundled', invocation: { modelInvocable: false, userInvocable: true } })
114
+ add('2cmd', `2Cmd mode: ${MODES.join(', ')}`, COMMAND)
115
+ add('2cmd-review', '2Cmd review of this change', SKILLS.review)
116
+ add('2cmd-audit', '2Cmd review of the whole project', SKILLS.audit)
117
+ })
118
+
119
+ // Use connection.fetch, not webServer: DSH 0.2.2-rc.5 lets webServer routes run without a login and ignores
120
+ // `auth`. connection.fetch checks the request's origin and login, and only lets the owner through.
121
+ ctx.connection.fetch.register({
122
+ path: '/api/2cmd.strings',
123
+ methods: ['GET'],
124
+ requestBody: 'buffered',
125
+ fetch: async () => json({ ...STRINGS, chosen: chosenLanguage() }), // chosen: the language set in 2Cmd's settings
126
+ })
127
+
128
+ ctx.connection.fetch.register({
129
+ path: '/api/2cmd.board',
130
+ methods: ['GET'],
131
+ requestBody: 'buffered',
132
+ fetch: async (request) => {
133
+ const query = new URL(request.url).searchParams
134
+ // Sessions from before the plugin was installed are added when their board is opened.
135
+ const agent = ctx.agents.get(query.get('session'))
136
+ if (agent) record(agent.session)
137
+ const lang = Object.hasOwn(STRINGS, query.get('lang')) ? query.get('lang') : 'en'
138
+ const { currency, rate } = money()
139
+ const tasks = readTasks().map(task => ({ ...task, cost: typeof task.cost === 'number' ? task.cost * rate : null }))
140
+ return json({ html: boardHtml(tasks, Date.now(), { lang, t: STRINGS[lang] }, currency === 'USD' ? undefined : currency) })
141
+ },
142
+ })
143
+
144
+ // Check for updates, when the person asks; the page opens 2Cmd's site (url) for a newer version.
145
+ ctx.connection.fetch.register({
146
+ path: '/api/2cmd.update',
147
+ methods: ['GET'],
148
+ requestBody: 'buffered',
149
+ fetch: async (request) => {
150
+ const lang = new URL(request.url).searchParams.get('lang')
151
+ return json({ ...(await checkUpdate(VERSION)), url: siteUrl(Object.hasOwn(STRINGS, lang) ? lang : 'en') })
152
+ },
153
+ })
154
+
155
+ ctx.connection.fetch.register({
156
+ path: '/api/2cmd.settings',
157
+ methods: ['GET', 'POST'],
158
+ requestBody: 'buffered',
159
+ fetch: async (request) => {
160
+ if (request.method !== 'POST') return json(settingsFor('dsh'))
161
+ if (!isJson(request)) return json({}, 415)
162
+ const changed = await changeSettings(await request.json().catch(() => undefined), 'dsh')
163
+ return changed ? json(changed) : json({}, 400)
164
+ },
165
+ })
166
+
167
+ ctx.connection.fetch.register({
168
+ path: '/api/2cmd.session',
169
+ methods: ['GET', 'POST'],
170
+ requestBody: 'buffered',
171
+ fetch: async (request) => {
172
+ const write = request.method === 'POST'
173
+ if (write && !isJson(request)) return json({}, 415)
174
+ const body = write ? await request.json().catch(() => undefined) : { session: new URL(request.url).searchParams.get('session') }
175
+ const agent = typeof body?.session === 'string' ? ctx.agents.get(body.session) : undefined
176
+ if (!agent) return json({}, 404)
177
+ const { session } = agent
178
+ if (write) {
179
+ if (MODES.includes(body.mode)) pick(session, body.mode)
180
+ else return json({}, 400)
181
+ }
182
+ return json(snapshot(session))
183
+ },
184
+ })
185
+ }
package/dsh/ledger.js ADDED
@@ -0,0 +1,50 @@
1
+ // The board's data: one small file per session in DSH's own folder, so two DSH windows never overwrite each other.
2
+ import { readdirSync } from 'node:fs'
3
+ import { basename, join } from 'node:path'
4
+ import { pathOf, readJson, writeJson } from './store.js'
5
+
6
+ const stamp = (ms) => {
7
+ const d = new Date(ms)
8
+ const two = n => String(n).padStart(2, '0')
9
+ return `${d.getFullYear()}-${two(d.getMonth() + 1)}-${two(d.getDate())} ${two(d.getHours())}:${two(d.getMinutes())}`
10
+ }
11
+
12
+ /** Projects a session's current totals, without any chat content except its title. */
13
+ export function taskOf(session, stats, mode) {
14
+ if (stats.turns === 0 || stats.started === null) return
15
+ const title = session.snapshotEvents().findLast(event => event.type === 'session/title')?.data.title
16
+ return {
17
+ started: stamp(stats.started),
18
+ project: basename(session.header.cwd ?? '') || '–',
19
+ name: title ?? '',
20
+ cost: stats.cost?.total ?? null,
21
+ turns: stats.turns,
22
+ agentMinutes: stats.ms / 60000,
23
+ tokens: stats.tokens,
24
+ reuse: null,
25
+ // DSH test runs are not tracked. The board shows – for "import", and "not run" for anything else.
26
+ tests: '',
27
+ level: 'import',
28
+ mode,
29
+ model: stats.model,
30
+ }
31
+ }
32
+
33
+ export function saveTask(session, stats, mode) {
34
+ const task = taskOf(session, stats, mode)
35
+ if (task) writeJson(pathOf('sessions', `${encodeURIComponent(session.id)}.json`), task)
36
+ }
37
+
38
+ export function readTasks() {
39
+ let files
40
+ try {
41
+ files = readdirSync(pathOf('sessions'))
42
+ } catch (error) {
43
+ if (error.code === 'ENOENT') return []
44
+ throw error
45
+ }
46
+ return files.filter(file => file.endsWith('.json')).flatMap((file) => {
47
+ const task = readJson(join(pathOf('sessions'), file))
48
+ return typeof task?.started === 'string' && typeof task.project === 'string' ? [task] : []
49
+ })
50
+ }
package/dsh/market.js ADDED
@@ -0,0 +1,152 @@
1
+ // Public data: model prices from models.dev and exchange rates from open.er-api.com.
2
+ // Both are plain downloads that send nothing about the user. A failed or broken one keeps the data already here.
3
+ import { readFileSync } from 'node:fs'
4
+ import { pathOf, readJson, readSettings, saveSettings, writeJson } from './store.js'
5
+
6
+ export const CURRENCIES = ['USD', 'CNY', 'TWD', 'HKD', 'JPY', 'KRW', 'EUR', 'GBP', 'BRL', 'RUB', 'VND']
7
+ const HOUR = 60 * 60 * 1000
8
+ const MAX_BYTES = 32 * 1024 * 1024
9
+ const BUNDLED = JSON.parse(readFileSync(new URL('./prices.json', import.meta.url), 'utf8'))
10
+
11
+ // Model makers only: when two list the same model, the earlier one's price wins.
12
+ const PROVIDERS = [
13
+ 'anthropic', 'openai', 'google', 'xai', 'deepseek', 'mistral',
14
+ 'moonshotai', 'moonshotai-cn', 'zhipuai', 'zai', 'alibaba', 'alibaba-cn',
15
+ 'minimax', 'xiaomi', 'stepfun', 'volcengine',
16
+ ]
17
+
18
+ const amount = value => (typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 1e6 ? value : undefined)
19
+
20
+ function price(cost) {
21
+ const out = {}
22
+ for (const key of ['input', 'output', 'cache_read', 'cache_write']) {
23
+ const value = amount(cost?.[key])
24
+ if (value !== undefined) out[key] = value
25
+ }
26
+ return out.input === undefined || out.output === undefined ? undefined : out
27
+ }
28
+
29
+ /** Keeps only the prices the plugin needs, in USD per million tokens. */
30
+ export function trimPrices(catalogue) {
31
+ const models = {}
32
+ for (const provider of PROVIDERS) {
33
+ for (const [id, model] of Object.entries(catalogue?.[provider]?.models ?? {})) {
34
+ const key = id.toLowerCase()
35
+ const base = price(model?.cost)
36
+ if (Object.hasOwn(models, key) || !base) continue
37
+ const tiers = (Array.isArray(model.cost.tiers) ? model.cost.tiers : [])
38
+ .flatMap((tier) => {
39
+ const size = amount(tier?.tier?.size)
40
+ const rate = price(tier)
41
+ return size && rate ? [{ size, ...rate }] : []
42
+ })
43
+ .sort((a, b) => a.size - b.size)
44
+ models[key] = tiers.length > 0 ? { ...base, tiers } : base
45
+ }
46
+ }
47
+ const ids = Object.keys(models).sort()
48
+ // If the main makers are gone, the download is broken. Prices did not really change that much.
49
+ if (ids.length < 50 || !['claude-', 'deepseek-'].every(prefix => ids.some(id => id.startsWith(prefix)))) {
50
+ throw new Error(`only ${ids.length} models`)
51
+ }
52
+ return Object.fromEntries(ids.map(id => [id, models[id]]))
53
+ }
54
+
55
+ export function trimRates(data) {
56
+ if (data?.result !== 'success' || data.base_code !== 'USD') throw new Error('no USD rates')
57
+ return Object.fromEntries(CURRENCIES.map((code) => {
58
+ const rate = code === 'USD' ? 1 : data.rates?.[code]
59
+ if (typeof rate !== 'number' || !Number.isFinite(rate) || rate <= 0) throw new Error(`no ${code} rate`)
60
+ return [code, rate]
61
+ }))
62
+ }
63
+
64
+ async function download(url) {
65
+ const response = await fetch(url, { signal: AbortSignal.timeout(20_000) })
66
+ if (!response.ok) throw new Error(`${response.status} from ${new URL(url).host}`)
67
+ const parts = []
68
+ let size = 0
69
+ for await (const part of response.body) {
70
+ size += part.length
71
+ if (size > MAX_BYTES) throw new Error(`too much data from ${new URL(url).host}`)
72
+ parts.push(part)
73
+ }
74
+ return JSON.parse(Buffer.concat(parts).toString('utf8'))
75
+ }
76
+
77
+ /** One downloaded table, cached on disk. */
78
+ function table({ file, url, trim, maxAge, bundled }) {
79
+ let saved
80
+ let loaded
81
+ let busy
82
+ let failedAt = -Infinity
83
+ const current = () => {
84
+ const path = pathOf(file)
85
+ if (loaded !== path) {
86
+ loaded = path
87
+ const cached = readJson(path)
88
+ const usable = typeof cached?.updated === 'number' && cached.data && typeof cached.data === 'object'
89
+ saved = usable && cached.updated > (bundled?.updated ?? 0) ? cached : bundled
90
+ }
91
+ return saved
92
+ }
93
+ /** Resolves to whether the data is up to date. After a failure it waits an hour, unless the user asks. */
94
+ const refresh = async (force = false) => {
95
+ const now = Date.now()
96
+ const age = now - (current()?.updated ?? -Infinity)
97
+ if (!force && age >= 0 && age < maxAge) return true
98
+ if (!force && now - failedAt < HOUR) return false
99
+ busy ??= (async () => {
100
+ try {
101
+ const next = { updated: Date.now(), data: trim(await download(url)) }
102
+ saved = next
103
+ failedAt = -Infinity
104
+ try {
105
+ writeJson(pathOf(file), next)
106
+ } catch (error) {
107
+ console.warn(`2cmd: could not save ${file}: ${error.message}`)
108
+ }
109
+ return true
110
+ } catch (error) {
111
+ failedAt = Date.now()
112
+ console.warn(`2cmd: could not update ${file}: ${error.message}`)
113
+ return false
114
+ }
115
+ })().finally(() => { busy = undefined })
116
+ return busy
117
+ }
118
+ return { current, refresh }
119
+ }
120
+
121
+ export const prices = table({
122
+ file: 'prices.json', url: 'https://models.dev/api.json', trim: trimPrices, maxAge: 72 * HOUR,
123
+ bundled: { updated: Date.parse(BUNDLED.updated), data: BUNDLED.models },
124
+ })
125
+ export const rates = table({ file: 'rates.json', url: 'https://open.er-api.com/v6/latest/USD', trim: trimRates, maxAge: 24 * HOUR })
126
+
127
+ /** A model models.dev has dropped keeps its bundled price, so older chats can still be priced. */
128
+ export function findPrice(id) {
129
+ const { data } = prices.current()
130
+ if (Object.hasOwn(data, id)) return data[id]
131
+ return Object.hasOwn(BUNDLED.models, id) ? BUNDLED.models[id] : undefined
132
+ }
133
+
134
+ export function chosenCurrency() {
135
+ const { currency } = readSettings()
136
+ return CURRENCIES.includes(currency) ? currency : 'USD'
137
+ }
138
+
139
+ export const chooseCurrency = currency => saveSettings({ currency })
140
+
141
+ /** How to show USD costs. Stays in USD until there is a rate, so an amount never gets the wrong currency sign. */
142
+ export function money() {
143
+ const currency = chosenCurrency()
144
+ const rate = currency === 'USD' ? 1 : rates.current()?.data[currency]
145
+ return rate > 0 ? { currency, rate } : { currency: 'USD', rate: 1 }
146
+ }
147
+
148
+ /** Starts any update that is due, without making the panel wait. */
149
+ export function refreshWhenDue() {
150
+ void prices.refresh()
151
+ if (chosenCurrency() !== 'USD') void rates.refresh()
152
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "2cmd-dsh",
3
+ "version": "0.1.2",
4
+ "description": "2Cmd panel for DeepSeek Harness: modes, stats, a one-line composer and optional voice input.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./index.js",
8
+ "exports": {
9
+ ".": "./index.js",
10
+ "./client": "./client.js",
11
+ "./package.json": "./package.json"
12
+ },
13
+ "files": ["*.js", "bundle.json", "prices.json", "cordis.patch.yml", "LICENSE"],
14
+ "keywords": ["dsh-plugin", "2cmd"],
15
+ "repository": { "type": "git", "url": "git+https://github.com/2cmddev/2Cmd.git", "directory": "dsh" },
16
+ "engines": { "node": ">=24.9", "dsh": ">=0.2.2-rc.5 <0.3.0" },
17
+ "dsh": {
18
+ "bundle": { "patch": "./cordis.patch.yml" },
19
+ "client": {
20
+ "platform": "web",
21
+ "inject": ["@deepseek-ai/dsh-client-locale", "@deepseek-ai/dsh-client-ui-conversation", "@deepseek-ai/dsh-client-ui-settings"]
22
+ }
23
+ }
24
+ }