ds-bot 0.1.1 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ds-bot",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "DS Bot: a team of long-lived Bots for DeepSeek Harness, with Main Bots, Bot-to-Bot messages and group chats",
5
5
  "keywords": [
6
6
  "dsh-plugin",
@@ -58,9 +58,6 @@
58
58
  "patch": "./cordis.patch.yml"
59
59
  }
60
60
  },
61
- "dsBot": {
62
- "verifiedDsh": "0.2.1-alpha.1"
63
- },
64
61
  "devDependencies": {
65
62
  "esbuild": "0.28.2"
66
63
  }
@@ -71,7 +71,7 @@ export function install(rt) {
71
71
  const live = () => ({ activity: rt.activityView(), memoryNews: rt.memoryNews(), memoryReviews: rt.memoryReviews(), connectors: rt.connectorsView() })
72
72
  // What a host that only reads the team may still answer.
73
73
  // Updates change the dsh profile, not the team, so a reading host may run them too.
74
- const READS = new Set(['state', 'models', 'efforts', 'earlier', 'room-progress', 'exchange', 'usage', 'schedules', 'memory-view', 'browser-wait', 'browser-result', 'diagnostics', 'diagnostics-log', 'diagnostics-clear', 'update-check', 'update-install', 'dsh-update-install'])
74
+ const READS = new Set(['state', 'models', 'efforts', 'earlier', 'room-progress', 'exchange', 'usage', 'schedules', 'memory-view', 'browser-wait', 'browser-result', 'diagnostics', 'diagnostics-log', 'diagnostics-clear', 'update-check', 'update-install', 'dsh-update-install', 'repo-stars'])
75
75
 
76
76
  function setPrefs(body) {
77
77
  if (body.theme !== undefined) {
@@ -270,6 +270,8 @@ export function install(rt) {
270
270
  return ok(rt.updateStart())
271
271
  case 'dsh-update-install':
272
272
  return ok(rt.dshUpdateStart?.())
273
+ case 'repo-stars':
274
+ return ok(await rt.repoStars())
273
275
  // The Desktop window's long poll for read_browser, and its answers.
274
276
  case 'browser-wait': {
275
277
  if (rt.browserChannel === undefined) return fail('Bot browsers are off on this host', 'bot/browser-off')
@@ -1,9 +1,11 @@
1
- // DSH updates: every released DS Bot names the DSH release it was verified
2
- // against (`dsBot.verifiedDsh` in package.json). The newest released bot wins:
3
- // offering that version and nothing newer keeps the update path away from DSH
4
- // releases we have not checked. A DSH installed from npm swaps with
5
- // `npm i -g`; a packaged app's runtime lives inside its bundle, so the card
6
- // there only reports current and verified — its own updater chooses versions.
1
+ // DSH updates: a released DS Bot may name the DSH release it was verified
2
+ // against (`dsBot.verifiedDsh` in package.json); a release that names none
3
+ // offers nothing. The newest released bot wins: offering that version and
4
+ // nothing newer keeps the update path away from DSH releases we have not
5
+ // checked. A DSH installed from npm swaps with `npm i -g`; a packaged app's
6
+ // runtime lives inside its bundle and only its own updater moves it, to the
7
+ // newest release it finds, so the client offers it only when that release is
8
+ // the verified one.
7
9
  import { spawn } from 'node:child_process'
8
10
  import { readFileSync } from 'node:fs'
9
11
  import { dirname, join } from 'node:path'
@@ -99,11 +99,17 @@ export async function installSpecOf(ctx) {
99
99
  export const repoSlug = () =>
100
100
  /github\.com[/:]([\w.-]+\/[\w.-]+?)(?:\.git)?$/i.exec(String(PKG.repository?.url ?? PKG.repository ?? ''))?.[1] ?? null
101
101
 
102
- const releasesUrl = () => {
102
+ const repoUrl = () => {
103
103
  const repo = repoSlug()
104
- return repo ? `https://github.com/${repo}/releases` : (PKG.homepage ?? null)
104
+ return repo ? `https://github.com/${repo}` : null
105
+ }
106
+ const releasesUrl = () => {
107
+ const repo = repoUrl()
108
+ return repo ? `${repo}/releases` : (PKG.homepage ?? null)
105
109
  }
106
110
 
111
+ export const STARS_TTL_MS = 60 * 60_000
112
+
107
113
  export function install(rt) {
108
114
  const { ctx, config } = rt
109
115
  const enabled = config.updateCheck !== false
@@ -119,10 +125,27 @@ export function install(rt) {
119
125
 
120
126
  const view = () => ({
121
127
  name: status.name, current: status.current, latest: status.latest, source: status.source, notesUrl: status.notesUrl,
128
+ repoUrl: repoUrl(), enabled,
122
129
  checkedAt: status.checkedAt, phase: status.phase, installed: status.installed, error: status.error,
123
130
  available: status.phase !== 'installed' && target !== null && status.latest !== null && newer(status.latest, status.current),
124
131
  })
125
132
 
133
+ // Asked only while the About page is open, so a closed page never calls GitHub.
134
+ // A failed answer keeps the last count and is asked again next time.
135
+ let stars = { count: null, at: 0 }
136
+ let starring = null
137
+ async function repoStars() {
138
+ const repo = repoSlug()
139
+ if (repo === null) return null
140
+ if (Date.now() - stars.at < STARS_TTL_MS) return stars.count
141
+ starring ??= fetchJson(`https://api.github.com/repos/${repo}`, { 'user-agent': `${PKG.name}/${PKG.version}` })
142
+ .then((info) => { if (Number.isInteger(info?.stargazers_count)) stars = { count: info.stargazers_count, at: Date.now() } })
143
+ .catch(error => rt.warn('ds-bot: star count failed: %s', error?.message ?? error))
144
+ .finally(() => { starring = null })
145
+ await starring
146
+ return stars.count
147
+ }
148
+
126
149
  async function newestFromRegistry() {
127
150
  for (const registry of await registryPlan(config, manager())) {
128
151
  try {
@@ -206,5 +229,5 @@ export function install(rt) {
206
229
  }, 'ds-bot: update check')
207
230
  }
208
231
 
209
- Object.assign(rt, { updateCheck: check, updateStart: start, updateView: view })
232
+ Object.assign(rt, { updateCheck: check, updateStart: start, updateView: view, repoStars })
210
233
  }