@tina_summer/codepocket 2.1.1 → 2.1.3

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 (2) hide show
  1. package/bin/codepocket.js +36 -1
  2. package/package.json +1 -1
package/bin/codepocket.js CHANGED
@@ -77,7 +77,8 @@ const CONNECT_ONLY = ['connect', 'c'].includes(args[0])
77
77
  const filteredArgs = CONNECT_ONLY ? args.slice(1) : args
78
78
 
79
79
  let hubUrl = process.env.CPKT_HUB_URL || process.env.HAPI_HUB_URL || 'http://127.0.0.1:3006'
80
- let relayUrl = process.env.RELAY_WS_URL || process.env.RELAY_URL || ''
80
+ const DEFAULT_RELAY_URL = 'wss://bkstory.cn/ws'
81
+ let relayUrl = process.env.RELAY_WS_URL || process.env.RELAY_URL || DEFAULT_RELAY_URL
81
82
  let relayKey = process.env.RELAY_KEY || ''
82
83
  let noHub = false
83
84
 
@@ -256,6 +257,14 @@ function connectRelay() {
256
257
  handleSpawnSession(msg.requestId, msg.directory)
257
258
  break
258
259
  }
260
+ case 'list-dir': {
261
+ handleListDir(msg.requestId, msg.path)
262
+ break
263
+ }
264
+ case 'list-dir': {
265
+ handleListDir(msg.requestId, msg.path)
266
+ break
267
+ }
259
268
  }
260
269
  })
261
270
 
@@ -366,9 +375,27 @@ async function handleSpawnSession(requestId, directory) {
366
375
  }
367
376
  }
368
377
 
378
+ function handleListDir(requestId, dirPath) {
379
+ try {
380
+ const resolved = (dirPath || '~').replace(/^~/, os.homedir())
381
+ const abs = path.resolve(resolved)
382
+ const entries = fs.readdirSync(abs, { withFileTypes: true })
383
+ .filter(d => d.isDirectory())
384
+ .map(d => ({ name: d.name, path: path.join(abs, d.name) }))
385
+ .sort((a, b) => a.name.localeCompare(b.name))
386
+ sendToRelay({ type: 'list-dir-result', requestId, path: abs, entries })
387
+ } catch (err) {
388
+ sendToRelay({ type: 'list-dir-result', requestId, error: err.message })
389
+ }
390
+ }
391
+
369
392
  // ── Background connect: auth + MCP + SSE + relay ──
370
393
 
371
394
  async function connectInBackground() {
395
+ if (!relayUrl) {
396
+ console.log('[codepocket] 未配置 Relay 地址,手机连接功能不可用')
397
+ return
398
+ }
372
399
  try {
373
400
  const token = await findHubToken()
374
401
  jwt = await authenticateHub(token)
@@ -403,6 +430,14 @@ async function run() {
403
430
  console.error('[codepocket] ✗ Key 不能为空')
404
431
  process.exit(1)
405
432
  }
433
+ }
434
+
435
+ // 1.5 Relay URL (default: wss://bkstory.cn/ws)
436
+ if (!relayUrl) {
437
+ relayUrl = DEFAULT_RELAY_URL
438
+ }
439
+
440
+ if (relayKey) {
406
441
  saveConfig({ ...loadConfig(), relayKey, relayUrl })
407
442
  console.log('[codepocket] ✓ 配置已保存')
408
443
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tina_summer/codepocket",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "CodePocket — 你的全能 AI 随身控制台",
5
5
  "bin": {
6
6
  "codepocket": "bin/codepocket.js",