dsh-reference-anything 0.5.1 → 0.5.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 (73) hide show
  1. package/LICENSE +22 -22
  2. package/NOTICE.md +110 -110
  3. package/README.md +472 -459
  4. package/cordis.patch.yml +136 -136
  5. package/docs/release/0.4.4/README.md +75 -0
  6. package/{release-notes → docs/release}/0.4.4/features.json +36 -36
  7. package/docs/release/0.5.0/README.md +148 -0
  8. package/{release-notes → docs/release}/0.5.0/features.json +65 -65
  9. package/docs/release/0.5.1/README.md +33 -0
  10. package/docs/release/0.5.2/README.md +51 -0
  11. package/docs/release/0.5.2/features.json +29 -0
  12. package/{release-notes → docs/release}/README.md +42 -38
  13. package/images/agents/LICENSE +22 -22
  14. package/images/agents/README.md +7 -3
  15. package/images/agents/antigravity.svg +1 -1
  16. package/images/agents/cline.svg +1 -1
  17. package/images/agents/continue.svg +1 -1
  18. package/images/agents/copilot.svg +27 -0
  19. package/images/agents/crush.svg +1 -1
  20. package/images/agents/doubao.svg +1 -0
  21. package/images/agents/goose.svg +1 -1
  22. package/images/agents/omp.svg +1 -0
  23. package/images/agents/reasonix.svg +5 -5
  24. package/images/agents/teleagent.svg +1 -1
  25. package/images/agents/trae.svg +1 -1
  26. package/images/agents/vibe.svg +1 -1
  27. package/images/agents/workbuddy.svg +37 -37
  28. package/images/agents/zed.svg +1 -1
  29. package/lib/chat-import-compatibility.js +8 -5
  30. package/lib/client.js +36526 -4
  31. package/lib/contract.d.ts +4 -0
  32. package/lib/host.d.ts +2 -2
  33. package/lib/local-conversation-reader.js +16 -11
  34. package/lib/render.js +21 -21
  35. package/lib/store/spec.d.ts +9 -1
  36. package/lib/tool.js +3 -2
  37. package/lib/wire.d.ts +13 -1
  38. package/lib/wire.js +5 -4
  39. package/locale/en.json +6 -6
  40. package/locale/zh.json +6 -6
  41. package/opencli-plugin/chatgpt.js +128 -128
  42. package/opencli-plugin/claude.js +138 -138
  43. package/opencli-plugin/common.js +452 -452
  44. package/opencli-plugin/deepseek.js +155 -155
  45. package/opencli-plugin/gemini.js +169 -169
  46. package/opencli-plugin/grok.js +124 -124
  47. package/opencli-plugin/kimi.js +126 -126
  48. package/opencli-plugin/opencli-plugin.json +6 -6
  49. package/opencli-plugin/package.json +8 -8
  50. package/opencli-plugin/since-guard.js +45 -45
  51. package/package.json +263 -262
  52. package/vendor/chat-import-reader/LICENSE +22 -22
  53. package/vendor/chat-import-reader/LICENSE.fzstd +20 -20
  54. package/vendor/chat-import-reader/README.md +54 -48
  55. package/vendor/chat-import-reader/availability-worker.mjs +119 -114
  56. package/vendor/chat-import-reader/parsers.d.mts +6 -6
  57. package/vendor/chat-import-reader/parsers.mjs +13069 -11168
  58. package/vendor/chat-import-reader/scan-worker.mjs +7 -7
  59. package/vendor/chat-import-reader/scanners.mjs +5523 -4286
  60. package/vendor/chat-import-reader/upstream-sha256.json +114 -101
  61. package/release-notes/0.4.4/commands.png +0 -0
  62. package/release-notes/0.4.4/demos/agent-import.gif +0 -0
  63. package/release-notes/0.4.4/demos/chat-import-upgrade.gif +0 -0
  64. package/release-notes/0.4.4/demos/folders.gif +0 -0
  65. package/release-notes/0.4.4/demos/local-plugins.gif +0 -0
  66. package/release-notes/0.4.4/demos/shortcuts.gif +0 -0
  67. package/release-notes/0.4.4/files.png +0 -0
  68. package/release-notes/0.5.0/demos/agent-import.gif +0 -0
  69. package/release-notes/0.5.0/demos/chat-import-upgrade.gif +0 -0
  70. package/release-notes/0.5.0/demos/folders.gif +0 -0
  71. package/release-notes/0.5.0/demos/local-plugins.gif +0 -0
  72. package/release-notes/0.5.0/demos/local-references.gif +0 -0
  73. package/release-notes/0.5.0/demos/shortcuts.gif +0 -0
@@ -1,155 +1,155 @@
1
- import { domFallbackScript, registerProvider, sinceGuardSource } from './common.js'
2
- // OpenCLI discovery marker: registerProvider below performs the cli() calls.
3
-
4
- const historyScript = String.raw`async function (args) {
5
- const stopEarly = (${sinceGuardSource})(args && args.since)
6
- const normalize = value => Array.isArray(value) ? value : []
7
- const headers = (() => {
8
- try {
9
- const stored = JSON.parse(localStorage.getItem('userToken') || 'null')
10
- const token = typeof stored === 'string' ? stored : stored && (stored.value || stored.token)
11
- return token ? { Accept: 'application/json', Authorization: 'Bearer ' + token } : { Accept: 'application/json' }
12
- } catch { return { Accept: 'application/json' } }
13
- })()
14
- const toDate = value => {
15
- if (typeof value === 'number' && Number.isFinite(value)) return new Date(value < 1e12 ? value * 1000 : value).toISOString()
16
- return String(value || '')
17
- }
18
- const rows = []
19
- let cursorPinned = false
20
- let cursorUpdatedAt = ''
21
- let guard = 0
22
- try {
23
- do {
24
- const query = new URLSearchParams({ count: '100', 'lte_cursor.pinned': String(cursorPinned) })
25
- if (cursorUpdatedAt) query.set('lte_cursor.updated_at', cursorUpdatedAt)
26
- const response = await fetch('/api/v0/chat_session/fetch_page?' + query, { credentials: 'include', headers })
27
- if (response.status === 401 || response.status === 403) return JSON.stringify({ ok: false, code: 'AUTH' })
28
- if (response.status === 429) return JSON.stringify({ ok: false, code: 'RATE_LIMIT' })
29
- if (!response.ok) throw new Error('history HTTP ' + response.status)
30
- const payload = await response.json()
31
- if (payload && (payload.code === 40002 || /missing token|unauth/i.test(String(payload.msg || payload.message || '')))) {
32
- return JSON.stringify({ ok: false, code: 'AUTH' })
33
- }
34
- const data = payload.data && payload.data.biz_data || payload.biz_data || payload.data || payload
35
- const items = normalize(data.chat_sessions || data.sessions || data.items || data.conversations)
36
- const pageStart = rows.length
37
- for (const item of items) {
38
- const id = String(item.id || item.chat_session_id || item.uuid || '')
39
- if (!id) continue
40
- rows.push({
41
- provider: 'deepseek', accountScope: '', id,
42
- title: String(item.title || item.name || 'Untitled DeepSeek chat'),
43
- url: location.origin + '/a/chat/s/' + encodeURIComponent(id),
44
- createdAt: toDate(item.inserted_at || item.created_at || item.createdAt || ''),
45
- updatedAt: toDate(item.updated_at || item.updatedAt || item.inserted_at || item.created_at || ''),
46
- messageCount: Number(item.message_count || item.messageCount || 0),
47
- cursor: String(item.updated_at || item.updatedAt || ''), partial: false,
48
- })
49
- }
50
- const last = items[items.length - 1]
51
- const nextUpdatedAt = String(last && (last.updated_at || last.updatedAt) || '')
52
- const nextPinned = Boolean(last && last.pinned)
53
- if (!data.has_more || !nextUpdatedAt || (nextUpdatedAt === cursorUpdatedAt && nextPinned === cursorPinned)) break
54
- if (stopEarly(rows.slice(pageStart))) break
55
- cursorUpdatedAt = nextUpdatedAt
56
- cursorPinned = nextPinned
57
- } while (++guard < 500)
58
- return JSON.stringify({ ok: true, rows })
59
- } catch (error) {
60
- const links = Array.from(document.querySelectorAll('a[href*="/a/chat/s/"]'))
61
- const seen = new Set()
62
- for (const link of links) {
63
- const match = link.href.match(/\/a\/chat\/s\/([^/?#]+)/)
64
- if (!match || seen.has(match[1])) continue
65
- seen.add(match[1])
66
- rows.push({ provider: 'deepseek', accountScope: '', id: match[1],
67
- title: (link.textContent || '').trim() || 'Untitled DeepSeek chat', url: link.href,
68
- createdAt: '', updatedAt: '', messageCount: 0, cursor: '', partial: true })
69
- }
70
- return JSON.stringify({ ok: rows.length > 0, rows, message: String(error && error.message || error) })
71
- }
72
- }`
73
-
74
- const detailScript = String.raw`async function (args) {
75
- const headers = (() => {
76
- try {
77
- const stored = JSON.parse(localStorage.getItem('userToken') || 'null')
78
- const token = typeof stored === 'string' ? stored : stored && (stored.value || stored.token)
79
- return token ? { Accept: 'application/json', Authorization: 'Bearer ' + token } : { Accept: 'application/json' }
80
- } catch { return { Accept: 'application/json' } }
81
- })()
82
- const toText = value => typeof value === 'string' ? value
83
- : Array.isArray(value) ? value.map(toText).filter(Boolean).join('\n')
84
- : value && typeof value === 'object' ? toText(value.text || value.content || value.value || '') : ''
85
- try {
86
- const response = await fetch('/api/v0/chat/history_messages?chat_session_id=' + encodeURIComponent(args.id), { credentials: 'include', headers })
87
- if (response.status === 401 || response.status === 403) return JSON.stringify({ ok: false, code: 'AUTH' })
88
- if (response.status === 429) return JSON.stringify({ ok: false, code: 'RATE_LIMIT' })
89
- if (!response.ok) throw new Error('detail HTTP ' + response.status)
90
- const payload = await response.json()
91
- if (payload && (payload.code === 40002 || /missing token|unauth/i.test(String(payload.msg || payload.message || '')))) {
92
- return JSON.stringify({ ok: false, code: 'AUTH' })
93
- }
94
- const data = payload.data && payload.data.biz_data || payload.biz_data || payload.data || payload
95
- const messages = data.chat_messages || data.messages || data.items || []
96
- const rows = messages.map((message, ordinal) => {
97
- const roleRaw = String(message.role || message.message_role || message.sender || '').toLowerCase()
98
- const role = /assistant|bot|model/.test(roleRaw) ? 'assistant' : 'user'
99
- const files = message.attachments || message.files || message.file_infos || []
100
- const attachments = (Array.isArray(files) ? files : []).map((file, index) => {
101
- const candidate = String(file.download_url || file.url || file.path || '')
102
- let locator = ''
103
- try { if (candidate) { const url = new URL(candidate, location.origin); if (url.origin === location.origin && url.pathname !== '/') locator = url.pathname + url.search } } catch {}
104
- const name = String(file.name || file.file_name || 'attachment')
105
- const mimeType = String(file.mime_type || file.mimeType || '')
106
- return { attachmentId: String(file.id || file.file_id || index),
107
- kind: mimeType.startsWith('image/') || /\.(?:gif|jpe?g|png|webp)$/i.test(name) ? 'image' : 'file',
108
- name, mimeType,
109
- size: Number(file.size || file.file_size || 0), locator, status: locator ? 'available' : 'unavailable' }
110
- })
111
- return { conversationId: args.id, ordinal,
112
- messageId: String(message.id || message.message_id || ordinal),
113
- parentId: String(message.parent_id || message.parentId || ''), branchId: '', activeBranch: true,
114
- role, text: toText(message.content || message.text || message.fragments || ''),
115
- createdAt: String(message.created_at || message.createdAt || ''),
116
- attachmentsJson: JSON.stringify(attachments), partial: false }
117
- }).filter(row => row.text || row.attachmentsJson !== '[]')
118
- return JSON.stringify({ ok: rows.length > 0, rows })
119
- } catch (error) {
120
- return JSON.stringify({ ok: false, message: String(error && error.message || error) })
121
- }
122
- }`
123
-
124
- export const whoamiScript = String.raw`async function () {
125
- const headers = (() => {
126
- try {
127
- const stored = JSON.parse(localStorage.getItem('userToken') || 'null')
128
- const token = typeof stored === 'string' ? stored : stored && (stored.value || stored.token)
129
- return token ? { Accept: 'application/json', Authorization: 'Bearer ' + token } : { Accept: 'application/json' }
130
- } catch { return { Accept: 'application/json' } }
131
- })()
132
- for (const url of ['/api/v0/users/current', '/api/v0/user/profile']) {
133
- const response = await fetch(url, { credentials: 'include', headers })
134
- if (response.status === 401 || response.status === 403) return JSON.stringify({ ok: false, code: 'AUTH' })
135
- if (response.status === 429) return JSON.stringify({ ok: false, code: 'RATE_LIMIT' })
136
- if (!response.ok) continue
137
- const contentType = response.headers.get('content-type') || ''
138
- if (!contentType.includes('application/json')) continue
139
- const payload = await response.json()
140
- if (payload && (payload.code === 40002 || /missing token|unauth/i.test(String(payload.msg || payload.message || '')))) {
141
- return JSON.stringify({ ok: false, code: 'AUTH' })
142
- }
143
- const user = payload.data && payload.data.biz_data || payload.biz_data || payload.data || payload
144
- const identity = String(user.id || user.user_id || user.uuid || user.email || '')
145
- if (identity) return JSON.stringify({ ok: true, identity })
146
- }
147
- return JSON.stringify({ ok: false, code: 'AUTH' })
148
- }`
149
-
150
- registerProvider({
151
- site: 'dsh-deepseek', provider: 'DeepSeek', domain: 'chat.deepseek.com',
152
- home: 'https://chat.deepseek.com/', conversationUrl: id => `https://chat.deepseek.com/a/chat/s/${encodeURIComponent(id)}`,
153
- whoamiScript,
154
- historyScript, detailScript, fallbackScript: domFallbackScript,
155
- })
1
+ import { domFallbackScript, registerProvider, sinceGuardSource } from './common.js'
2
+ // OpenCLI discovery marker: registerProvider below performs the cli() calls.
3
+
4
+ const historyScript = String.raw`async function (args) {
5
+ const stopEarly = (${sinceGuardSource})(args && args.since)
6
+ const normalize = value => Array.isArray(value) ? value : []
7
+ const headers = (() => {
8
+ try {
9
+ const stored = JSON.parse(localStorage.getItem('userToken') || 'null')
10
+ const token = typeof stored === 'string' ? stored : stored && (stored.value || stored.token)
11
+ return token ? { Accept: 'application/json', Authorization: 'Bearer ' + token } : { Accept: 'application/json' }
12
+ } catch { return { Accept: 'application/json' } }
13
+ })()
14
+ const toDate = value => {
15
+ if (typeof value === 'number' && Number.isFinite(value)) return new Date(value < 1e12 ? value * 1000 : value).toISOString()
16
+ return String(value || '')
17
+ }
18
+ const rows = []
19
+ let cursorPinned = false
20
+ let cursorUpdatedAt = ''
21
+ let guard = 0
22
+ try {
23
+ do {
24
+ const query = new URLSearchParams({ count: '100', 'lte_cursor.pinned': String(cursorPinned) })
25
+ if (cursorUpdatedAt) query.set('lte_cursor.updated_at', cursorUpdatedAt)
26
+ const response = await fetch('/api/v0/chat_session/fetch_page?' + query, { credentials: 'include', headers })
27
+ if (response.status === 401 || response.status === 403) return JSON.stringify({ ok: false, code: 'AUTH' })
28
+ if (response.status === 429) return JSON.stringify({ ok: false, code: 'RATE_LIMIT' })
29
+ if (!response.ok) throw new Error('history HTTP ' + response.status)
30
+ const payload = await response.json()
31
+ if (payload && (payload.code === 40002 || /missing token|unauth/i.test(String(payload.msg || payload.message || '')))) {
32
+ return JSON.stringify({ ok: false, code: 'AUTH' })
33
+ }
34
+ const data = payload.data && payload.data.biz_data || payload.biz_data || payload.data || payload
35
+ const items = normalize(data.chat_sessions || data.sessions || data.items || data.conversations)
36
+ const pageStart = rows.length
37
+ for (const item of items) {
38
+ const id = String(item.id || item.chat_session_id || item.uuid || '')
39
+ if (!id) continue
40
+ rows.push({
41
+ provider: 'deepseek', accountScope: '', id,
42
+ title: String(item.title || item.name || 'Untitled DeepSeek chat'),
43
+ url: location.origin + '/a/chat/s/' + encodeURIComponent(id),
44
+ createdAt: toDate(item.inserted_at || item.created_at || item.createdAt || ''),
45
+ updatedAt: toDate(item.updated_at || item.updatedAt || item.inserted_at || item.created_at || ''),
46
+ messageCount: Number(item.message_count || item.messageCount || 0),
47
+ cursor: String(item.updated_at || item.updatedAt || ''), partial: false,
48
+ })
49
+ }
50
+ const last = items[items.length - 1]
51
+ const nextUpdatedAt = String(last && (last.updated_at || last.updatedAt) || '')
52
+ const nextPinned = Boolean(last && last.pinned)
53
+ if (!data.has_more || !nextUpdatedAt || (nextUpdatedAt === cursorUpdatedAt && nextPinned === cursorPinned)) break
54
+ if (stopEarly(rows.slice(pageStart))) break
55
+ cursorUpdatedAt = nextUpdatedAt
56
+ cursorPinned = nextPinned
57
+ } while (++guard < 500)
58
+ return JSON.stringify({ ok: true, rows })
59
+ } catch (error) {
60
+ const links = Array.from(document.querySelectorAll('a[href*="/a/chat/s/"]'))
61
+ const seen = new Set()
62
+ for (const link of links) {
63
+ const match = link.href.match(/\/a\/chat\/s\/([^/?#]+)/)
64
+ if (!match || seen.has(match[1])) continue
65
+ seen.add(match[1])
66
+ rows.push({ provider: 'deepseek', accountScope: '', id: match[1],
67
+ title: (link.textContent || '').trim() || 'Untitled DeepSeek chat', url: link.href,
68
+ createdAt: '', updatedAt: '', messageCount: 0, cursor: '', partial: true })
69
+ }
70
+ return JSON.stringify({ ok: rows.length > 0, rows, message: String(error && error.message || error) })
71
+ }
72
+ }`
73
+
74
+ const detailScript = String.raw`async function (args) {
75
+ const headers = (() => {
76
+ try {
77
+ const stored = JSON.parse(localStorage.getItem('userToken') || 'null')
78
+ const token = typeof stored === 'string' ? stored : stored && (stored.value || stored.token)
79
+ return token ? { Accept: 'application/json', Authorization: 'Bearer ' + token } : { Accept: 'application/json' }
80
+ } catch { return { Accept: 'application/json' } }
81
+ })()
82
+ const toText = value => typeof value === 'string' ? value
83
+ : Array.isArray(value) ? value.map(toText).filter(Boolean).join('\n')
84
+ : value && typeof value === 'object' ? toText(value.text || value.content || value.value || '') : ''
85
+ try {
86
+ const response = await fetch('/api/v0/chat/history_messages?chat_session_id=' + encodeURIComponent(args.id), { credentials: 'include', headers })
87
+ if (response.status === 401 || response.status === 403) return JSON.stringify({ ok: false, code: 'AUTH' })
88
+ if (response.status === 429) return JSON.stringify({ ok: false, code: 'RATE_LIMIT' })
89
+ if (!response.ok) throw new Error('detail HTTP ' + response.status)
90
+ const payload = await response.json()
91
+ if (payload && (payload.code === 40002 || /missing token|unauth/i.test(String(payload.msg || payload.message || '')))) {
92
+ return JSON.stringify({ ok: false, code: 'AUTH' })
93
+ }
94
+ const data = payload.data && payload.data.biz_data || payload.biz_data || payload.data || payload
95
+ const messages = data.chat_messages || data.messages || data.items || []
96
+ const rows = messages.map((message, ordinal) => {
97
+ const roleRaw = String(message.role || message.message_role || message.sender || '').toLowerCase()
98
+ const role = /assistant|bot|model/.test(roleRaw) ? 'assistant' : 'user'
99
+ const files = message.attachments || message.files || message.file_infos || []
100
+ const attachments = (Array.isArray(files) ? files : []).map((file, index) => {
101
+ const candidate = String(file.download_url || file.url || file.path || '')
102
+ let locator = ''
103
+ try { if (candidate) { const url = new URL(candidate, location.origin); if (url.origin === location.origin && url.pathname !== '/') locator = url.pathname + url.search } } catch {}
104
+ const name = String(file.name || file.file_name || 'attachment')
105
+ const mimeType = String(file.mime_type || file.mimeType || '')
106
+ return { attachmentId: String(file.id || file.file_id || index),
107
+ kind: mimeType.startsWith('image/') || /\.(?:gif|jpe?g|png|webp)$/i.test(name) ? 'image' : 'file',
108
+ name, mimeType,
109
+ size: Number(file.size || file.file_size || 0), locator, status: locator ? 'available' : 'unavailable' }
110
+ })
111
+ return { conversationId: args.id, ordinal,
112
+ messageId: String(message.id || message.message_id || ordinal),
113
+ parentId: String(message.parent_id || message.parentId || ''), branchId: '', activeBranch: true,
114
+ role, text: toText(message.content || message.text || message.fragments || ''),
115
+ createdAt: String(message.created_at || message.createdAt || ''),
116
+ attachmentsJson: JSON.stringify(attachments), partial: false }
117
+ }).filter(row => row.text || row.attachmentsJson !== '[]')
118
+ return JSON.stringify({ ok: rows.length > 0, rows })
119
+ } catch (error) {
120
+ return JSON.stringify({ ok: false, message: String(error && error.message || error) })
121
+ }
122
+ }`
123
+
124
+ export const whoamiScript = String.raw`async function () {
125
+ const headers = (() => {
126
+ try {
127
+ const stored = JSON.parse(localStorage.getItem('userToken') || 'null')
128
+ const token = typeof stored === 'string' ? stored : stored && (stored.value || stored.token)
129
+ return token ? { Accept: 'application/json', Authorization: 'Bearer ' + token } : { Accept: 'application/json' }
130
+ } catch { return { Accept: 'application/json' } }
131
+ })()
132
+ for (const url of ['/api/v0/users/current', '/api/v0/user/profile']) {
133
+ const response = await fetch(url, { credentials: 'include', headers })
134
+ if (response.status === 401 || response.status === 403) return JSON.stringify({ ok: false, code: 'AUTH' })
135
+ if (response.status === 429) return JSON.stringify({ ok: false, code: 'RATE_LIMIT' })
136
+ if (!response.ok) continue
137
+ const contentType = response.headers.get('content-type') || ''
138
+ if (!contentType.includes('application/json')) continue
139
+ const payload = await response.json()
140
+ if (payload && (payload.code === 40002 || /missing token|unauth/i.test(String(payload.msg || payload.message || '')))) {
141
+ return JSON.stringify({ ok: false, code: 'AUTH' })
142
+ }
143
+ const user = payload.data && payload.data.biz_data || payload.biz_data || payload.data || payload
144
+ const identity = String(user.id || user.user_id || user.uuid || user.email || '')
145
+ if (identity) return JSON.stringify({ ok: true, identity })
146
+ }
147
+ return JSON.stringify({ ok: false, code: 'AUTH' })
148
+ }`
149
+
150
+ registerProvider({
151
+ site: 'dsh-deepseek', provider: 'DeepSeek', domain: 'chat.deepseek.com',
152
+ home: 'https://chat.deepseek.com/', conversationUrl: id => `https://chat.deepseek.com/a/chat/s/${encodeURIComponent(id)}`,
153
+ whoamiScript,
154
+ historyScript, detailScript, fallbackScript: domFallbackScript,
155
+ })