dsh-reference-anything 0.3.0 → 0.3.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 (109) hide show
  1. package/LICENSE +22 -22
  2. package/NOTICE.md +52 -25
  3. package/README.md +339 -286
  4. package/cordis.patch.yml +89 -18
  5. package/lib/client.js +13538 -591
  6. package/lib/contract.d.ts +155 -16
  7. package/lib/contract.js +68 -7
  8. package/lib/download-directory.d.ts +18 -0
  9. package/lib/download-directory.js +55 -0
  10. package/lib/errors.d.ts +4 -0
  11. package/lib/host.d.ts +96 -8
  12. package/lib/host.js +88 -19
  13. package/lib/index.d.ts +22 -2
  14. package/lib/index.js +57 -7
  15. package/lib/opencli.d.ts +5 -3
  16. package/lib/opencli.js +13 -6
  17. package/lib/openlist/host.d.ts +157 -0
  18. package/lib/openlist/host.js +873 -0
  19. package/lib/openlist/index.d.ts +84 -0
  20. package/lib/openlist/index.js +507 -0
  21. package/lib/render.d.ts +12 -7
  22. package/lib/render.js +27 -21
  23. package/lib/sources/cloud-drive/cache.d.ts +60 -0
  24. package/lib/sources/cloud-drive/cache.js +107 -0
  25. package/lib/sources/cloud-drive/index.d.ts +190 -0
  26. package/lib/sources/cloud-drive/index.js +526 -0
  27. package/lib/sources/cloud-drive/providers/http.d.ts +27 -0
  28. package/lib/sources/cloud-drive/providers/http.js +73 -0
  29. package/lib/sources/cloud-drive/providers/openlist.d.ts +59 -0
  30. package/lib/sources/cloud-drive/providers/openlist.js +535 -0
  31. package/lib/sources/cloud-drive/registry.d.ts +53 -0
  32. package/lib/sources/cloud-drive/registry.js +101 -0
  33. package/lib/sources/cloud-drive/types.d.ts +169 -0
  34. package/lib/sources/cloud-drive/types.js +17 -0
  35. package/lib/sources/file.d.ts +2 -0
  36. package/lib/sources/file.js +2 -0
  37. package/lib/sources/local-agent/adapters/claude-code.d.ts +16 -0
  38. package/lib/sources/local-agent/adapters/claude-code.js +171 -0
  39. package/lib/sources/local-agent/adapters/codex.d.ts +20 -0
  40. package/lib/sources/local-agent/adapters/codex.js +204 -0
  41. package/lib/sources/local-agent/adapters/cursor.d.ts +23 -0
  42. package/lib/sources/local-agent/adapters/cursor.js +121 -0
  43. package/lib/sources/local-agent/adapters/gemini-cli.d.ts +20 -0
  44. package/lib/sources/local-agent/adapters/gemini-cli.js +141 -0
  45. package/lib/sources/local-agent/adapters/grokbuild.d.ts +22 -0
  46. package/lib/sources/local-agent/adapters/grokbuild.js +76 -0
  47. package/lib/sources/local-agent/adapters/hermes.d.ts +19 -0
  48. package/lib/sources/local-agent/adapters/hermes.js +85 -0
  49. package/lib/sources/local-agent/adapters/kimi.d.ts +28 -0
  50. package/lib/sources/local-agent/adapters/kimi.js +261 -0
  51. package/lib/sources/local-agent/adapters/openclaw.d.ts +21 -0
  52. package/lib/sources/local-agent/adapters/openclaw.js +120 -0
  53. package/lib/sources/local-agent/adapters/opencode.d.ts +44 -0
  54. package/lib/sources/local-agent/adapters/opencode.js +236 -0
  55. package/lib/sources/local-agent/adapters/pi.d.ts +26 -0
  56. package/lib/sources/local-agent/adapters/pi.js +242 -0
  57. package/lib/sources/local-agent/adapters/qoder.d.ts +19 -0
  58. package/lib/sources/local-agent/adapters/qoder.js +93 -0
  59. package/lib/sources/local-agent/adapters/reasonix.d.ts +23 -0
  60. package/lib/sources/local-agent/adapters/reasonix.js +90 -0
  61. package/lib/sources/local-agent/adapters/shared.d.ts +163 -0
  62. package/lib/sources/local-agent/adapters/shared.js +415 -0
  63. package/lib/sources/local-agent/adapters/sqlite-shared.d.ts +92 -0
  64. package/lib/sources/local-agent/adapters/sqlite-shared.js +215 -0
  65. package/lib/sources/local-agent/adapters/zcode.d.ts +41 -0
  66. package/lib/sources/local-agent/adapters/zcode.js +159 -0
  67. package/lib/sources/local-agent/index.d.ts +222 -0
  68. package/lib/sources/local-agent/index.js +656 -0
  69. package/lib/sources/local-agent/page.d.ts +55 -0
  70. package/lib/sources/local-agent/page.js +83 -0
  71. package/lib/sources/local-agent/path.d.ts +8 -0
  72. package/lib/sources/local-agent/path.js +43 -0
  73. package/lib/sources/local-agent/registry.d.ts +68 -0
  74. package/lib/sources/local-agent/registry.js +116 -0
  75. package/lib/sources/local-agent/scan.d.ts +175 -0
  76. package/lib/sources/local-agent/scan.js +472 -0
  77. package/lib/sources/local-agent/sqlite.d.ts +45 -0
  78. package/lib/sources/local-agent/sqlite.js +113 -0
  79. package/lib/sources/local-agent/store.d.ts +93 -0
  80. package/lib/sources/local-agent/store.js +113 -0
  81. package/lib/sources/local-agent/types.d.ts +338 -0
  82. package/lib/sources/local-agent/types.js +20 -0
  83. package/lib/sources/web-chat/index.d.ts +5 -1
  84. package/lib/sources/web-chat/index.js +47 -8
  85. package/lib/store/spec.d.ts +50 -4
  86. package/lib/store/spec.js +2 -2
  87. package/lib/sync/index.d.ts +1 -0
  88. package/lib/sync/index.js +28 -8
  89. package/lib/tool.d.ts +5 -0
  90. package/lib/tool.js +418 -45
  91. package/lib/typert.js +13 -2
  92. package/lib/types.d.ts +28 -2
  93. package/lib/update.d.ts +6 -0
  94. package/lib/update.js +29 -1
  95. package/lib/web.js +5 -1
  96. package/lib/wire.d.ts +80 -9
  97. package/lib/wire.js +30 -4
  98. package/opencli-plugin/chatgpt.js +30 -27
  99. package/opencli-plugin/claude.js +12 -8
  100. package/opencli-plugin/common.js +266 -187
  101. package/opencli-plugin/deepseek.js +8 -5
  102. package/opencli-plugin/gemini.js +42 -38
  103. package/opencli-plugin/grok.js +22 -21
  104. package/opencli-plugin/kimi.js +34 -31
  105. package/opencli-plugin/opencli-plugin.json +6 -6
  106. package/opencli-plugin/package.json +8 -8
  107. package/package.json +182 -167
  108. package/lib/profile-mode.d.ts +0 -30
  109. package/lib/profile-mode.js +0 -90
package/package.json CHANGED
@@ -1,92 +1,104 @@
1
- {
2
- "name": "dsh-reference-anything",
3
- "version": "0.3.0",
4
- "description": "Reference locally mirrored ChatGPT, Claude, Gemini, DeepSeek, Grok, and Kimi conversations from DeepSeek Harness",
5
- "license": "MIT",
6
- "publishConfig": {
7
- "access": "public"
8
- },
9
- "type": "module",
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/Chael-Chael/dsh-reference-anything.git"
13
- },
14
- "main": "lib/index.js",
15
- "types": "lib/index.d.ts",
16
- "exports": {
17
- ".": {
18
- "types": "./lib/index.d.ts",
19
- "default": "./lib/index.js"
20
- },
21
- "./reference": {
22
- "types": "./lib/reference.d.ts",
23
- "default": "./lib/reference.js"
24
- },
25
- "./tool": {
26
- "types": "./lib/tool.d.ts",
27
- "default": "./lib/tool.js"
28
- },
29
- "./file": {
30
- "types": "./lib/sources/file.d.ts",
31
- "default": "./lib/sources/file.js"
32
- },
33
- "./web-chat": {
34
- "types": "./lib/sources/web-chat/index.d.ts",
35
- "default": "./lib/sources/web-chat/index.js"
36
- },
37
- "./web": {
38
- "types": "./lib/web.d.ts",
39
- "default": "./lib/web.js"
40
- },
41
- "./sync": {
42
- "types": "./lib/sync/index.d.ts",
43
- "default": "./lib/sync/index.js"
44
- },
45
- "./client": {
46
- "types": "./lib/client/index.d.ts",
47
- "default": "./lib/client.js"
48
- },
49
- "./package.json": "./package.json"
50
- },
51
- "files": [
52
- "lib",
53
- "opencli-plugin/*.js",
54
- "opencli-plugin/opencli-plugin.json",
55
- "opencli-plugin/package.json",
56
- "cordis.patch.yml",
57
- "images/logo.png",
58
- "NOTICE.md",
59
- "README.md"
60
- ],
61
- "dsh": {
62
- "bundle": {
63
- "patch": "./cordis.patch.yml"
64
- },
65
- "client": {
66
- "platform": "web",
67
- "inject": [
68
- "@deepseek-ai/dsh-client-runtime",
69
- "@deepseek-ai/dsh-api-remotes",
70
- "@deepseek-ai/dsh-client-ui-input-trigger",
71
- "@deepseek-ai/dsh-client-ui-conversation",
72
- "@deepseek-ai/dsh-client-ui-settings",
73
- "@deepseek-ai/dsh-client-locale"
74
- ]
75
- }
76
- },
77
- "scripts": {
78
- "build": "node build.mjs",
79
- "typecheck": "tsc -p tsconfig.json --noEmit",
80
- "test": "vitest run",
81
- "check": "pnpm run typecheck && pnpm run test && pnpm run build",
82
- "prepublishOnly": "pnpm run check",
83
- "prepare": "node build.mjs"
84
- },
85
- "peerDependencies": {
86
- "@deepseek-ai/cordis": ">=4.0.1",
87
- "@deepseek-ai/dsh-agent": ">=0.1.0-rc.6",
1
+ {
2
+ "name": "dsh-reference-anything",
3
+ "version": "0.3.2",
4
+ "description": "Reference commands, skills, workspace files, DSH sessions, local agent transcripts, cloud-drive files, and mirrored web-chat conversations from one DeepSeek Harness @ menu",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "type": "module",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/Chael-Chael/dsh-reference-anything.git"
13
+ },
14
+ "main": "lib/index.js",
15
+ "types": "lib/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./reference": {
22
+ "types": "./lib/reference.d.ts",
23
+ "default": "./lib/reference.js"
24
+ },
25
+ "./tool": {
26
+ "types": "./lib/tool.d.ts",
27
+ "default": "./lib/tool.js"
28
+ },
29
+ "./file": {
30
+ "types": "./lib/sources/file.d.ts",
31
+ "default": "./lib/sources/file.js"
32
+ },
33
+ "./local-agent": {
34
+ "types": "./lib/sources/local-agent/index.d.ts",
35
+ "default": "./lib/sources/local-agent/index.js"
36
+ },
37
+ "./cloud-drive": {
38
+ "types": "./lib/sources/cloud-drive/index.d.ts",
39
+ "default": "./lib/sources/cloud-drive/index.js"
40
+ },
41
+ "./openlist": {
42
+ "types": "./lib/openlist/index.d.ts",
43
+ "default": "./lib/openlist/index.js"
44
+ },
45
+ "./web-chat": {
46
+ "types": "./lib/sources/web-chat/index.d.ts",
47
+ "default": "./lib/sources/web-chat/index.js"
48
+ },
49
+ "./web": {
50
+ "types": "./lib/web.d.ts",
51
+ "default": "./lib/web.js"
52
+ },
53
+ "./sync": {
54
+ "types": "./lib/sync/index.d.ts",
55
+ "default": "./lib/sync/index.js"
56
+ },
57
+ "./client": {
58
+ "types": "./lib/client/index.d.ts",
59
+ "default": "./lib/client.js"
60
+ },
61
+ "./package.json": "./package.json"
62
+ },
63
+ "files": [
64
+ "lib",
65
+ "opencli-plugin/*.js",
66
+ "opencli-plugin/opencli-plugin.json",
67
+ "opencli-plugin/package.json",
68
+ "cordis.patch.yml",
69
+ "images/logo.png",
70
+ "NOTICE.md",
71
+ "README.md"
72
+ ],
73
+ "dsh": {
74
+ "bundle": {
75
+ "patch": "./cordis.patch.yml"
76
+ },
77
+ "client": {
78
+ "platform": "web",
79
+ "inject": [
80
+ "@deepseek-ai/dsh-client-runtime",
81
+ "@deepseek-ai/dsh-api-remotes",
82
+ "@deepseek-ai/dsh-client-ui-input-trigger",
83
+ "@deepseek-ai/dsh-client-ui-conversation",
84
+ "@deepseek-ai/dsh-client-ui-settings",
85
+ "@deepseek-ai/dsh-client-locale"
86
+ ]
87
+ }
88
+ },
89
+ "scripts": {
90
+ "build": "node build.mjs",
91
+ "typecheck": "tsc -p tsconfig.json --noEmit",
92
+ "test": "vitest run",
93
+ "check": "pnpm run typecheck && pnpm run test && pnpm run build",
94
+ "prepublishOnly": "pnpm run check",
95
+ "prepare": "node build.mjs"
96
+ },
97
+ "peerDependencies": {
98
+ "@deepseek-ai/cordis": ">=4.0.1",
99
+ "@deepseek-ai/dsh-agent": ">=0.1.0-rc.6",
88
100
  "@deepseek-ai/dsh-api-remotes": ">=0.1.0-rc.8",
89
- "@deepseek-ai/dsh-attachment": ">=0.1.0-rc.6",
101
+ "@deepseek-ai/dsh-attachment": ">=0.1.0-rc.6",
90
102
  "@deepseek-ai/dsh-client-connection": ">=0.1.0-rc.8",
91
103
  "@deepseek-ai/dsh-client-locale": ">=0.1.0-rc.8",
92
104
  "@deepseek-ai/dsh-client-runtime": ">=0.1.0-rc.8",
@@ -95,91 +107,94 @@
95
107
  "@deepseek-ai/dsh-client-ui-settings": ">=0.1.0-rc.8",
96
108
  "@deepseek-ai/dsh-client-ui-slots": ">=0.1.0-rc.8",
97
109
  "@deepseek-ai/dsh-file-reference": ">=0.1.0-rc.8",
98
- "@deepseek-ai/dsh-llm": ">=0.1.0-rc.6",
99
- "@deepseek-ai/dsh-output-retention": ">=0.1.0-rc.6",
100
- "@deepseek-ai/dsh-session": ">=0.1.0-rc.6",
101
- "@deepseek-ai/dsh-session-reference": ">=0.1.0-rc.6",
110
+ "@deepseek-ai/dsh-llm": ">=0.1.0-rc.6",
111
+ "@deepseek-ai/dsh-output-retention": ">=0.1.0-rc.6",
112
+ "@deepseek-ai/dsh-session": ">=0.1.0-rc.6",
113
+ "@deepseek-ai/dsh-session-reference": ">=0.1.0-rc.6",
102
114
  "@deepseek-ai/dsh-settings": ">=0.1.0-rc.8",
103
115
  "@deepseek-ai/dsh-storage-domain": ">=0.1.0-rc.8",
104
- "@deepseek-ai/dsh-tools": ">=0.1.0-rc.6",
105
- "@deepseek-ai/dsh-typert-protocol": ">=0.1.0-rc.6",
116
+ "@deepseek-ai/dsh-tools": ">=0.1.0-rc.6",
117
+ "@deepseek-ai/dsh-typert-protocol": ">=0.1.0-rc.6",
106
118
  "@deepseek-ai/dsh-typert-registry": ">=0.1.0-rc.8",
107
- "react": "^18.2.0"
108
- },
109
- "peerDependenciesMeta": {
119
+ "react": "^18.2.0"
120
+ },
121
+ "peerDependenciesMeta": {
110
122
  "@deepseek-ai/dsh-session-reference": {
111
123
  "optional": true
112
124
  },
113
125
  "@deepseek-ai/dsh-file-reference": {
114
126
  "optional": true
115
127
  },
116
- "@deepseek-ai/dsh-client-runtime": {
117
- "optional": true
118
- },
119
- "@deepseek-ai/dsh-api-remotes": {
120
- "optional": true
121
- },
122
- "@deepseek-ai/dsh-client-ui-input-trigger": {
123
- "optional": true
124
- },
125
- "@deepseek-ai/dsh-client-ui-slots": {
126
- "optional": true
127
- },
128
- "@deepseek-ai/dsh-client-ui-conversation": {
129
- "optional": true
130
- },
131
- "@deepseek-ai/dsh-client-locale": {
132
- "optional": true
133
- },
134
- "@deepseek-ai/dsh-client-connection": {
135
- "optional": true
136
- },
137
- "@deepseek-ai/dsh-client-ui-settings": {
138
- "optional": true
139
- },
140
- "@deepseek-ai/dsh-settings": {
141
- "optional": true
142
- },
143
- "react": {
144
- "optional": true
145
- }
146
- },
147
- "dependencies": {
148
- "@deepseek-ai/schemastery": "^3.18.1",
149
- "@lobehub/icons": "^5.16.0",
150
- "zod": "^4.4.3"
151
- },
152
- "devDependencies": {
153
- "@deepseek-ai/cordis": "link:../deepseek-harness/vendor/cordis",
154
- "@deepseek-ai/dsh-agent": "link:../deepseek-harness/packages/core/agent",
155
- "@deepseek-ai/dsh-api-remotes": "link:../deepseek-harness/packages/api/remotes",
156
- "@deepseek-ai/dsh-attachment": "link:../deepseek-harness/packages/attachment/attachment",
157
- "@deepseek-ai/dsh-client-connection": "link:../deepseek-harness/packages/client/connection",
158
- "@deepseek-ai/dsh-client-locale": "link:../deepseek-harness/packages/client/locale",
159
- "@deepseek-ai/dsh-client-runtime": "link:../deepseek-harness/packages/client/runtime",
160
- "@deepseek-ai/dsh-client-ui-conversation": "link:../deepseek-harness/packages/client/ui-conversation",
161
- "@deepseek-ai/dsh-client-ui-input-trigger": "link:../deepseek-harness/packages/client/ui-input-trigger",
162
- "@deepseek-ai/dsh-client-ui-settings": "link:../deepseek-harness/packages/client/ui-settings",
163
- "@deepseek-ai/dsh-client-ui-slots": "link:../deepseek-harness/packages/client/ui-slots",
164
- "@deepseek-ai/dsh-file-reference": "link:../deepseek-harness/packages/context/file-reference",
165
- "@deepseek-ai/dsh-llm": "link:../deepseek-harness/packages/llm/llm",
166
- "@deepseek-ai/dsh-output-retention": "link:../deepseek-harness/packages/util/output-retention",
167
- "@deepseek-ai/dsh-session": "link:../deepseek-harness/packages/core/session",
168
- "@deepseek-ai/dsh-session-reference": "link:../deepseek-harness/packages/context/session-reference",
169
- "@deepseek-ai/dsh-settings": "link:../deepseek-harness/packages/settings/settings",
170
- "@deepseek-ai/dsh-storage-domain": "link:../deepseek-harness/packages/storage/storage-domain",
171
- "@deepseek-ai/dsh-system-prompt": "link:../deepseek-harness/packages/core/system-prompt",
172
- "@deepseek-ai/dsh-tools": "link:../deepseek-harness/packages/core/tools",
173
- "@deepseek-ai/dsh-typert-protocol": "link:../deepseek-harness/packages/typert/protocol",
174
- "@deepseek-ai/dsh-typert-registry": "link:../deepseek-harness/packages/typert/registry",
175
- "@types/node": "^22.20.1",
176
- "@types/react": "^18.2.0",
177
- "@types/react-dom": "^18.3.7",
178
- "esbuild": "^0.25.0",
179
- "jsdom": "^26.1.0",
180
- "react": "^18.2.0",
181
- "react-dom": "^18.2.0",
182
- "typescript": "^5.7.0",
183
- "vitest": "^3.0.0"
184
- }
185
- }
128
+ "@deepseek-ai/dsh-client-runtime": {
129
+ "optional": true
130
+ },
131
+ "@deepseek-ai/dsh-api-remotes": {
132
+ "optional": true
133
+ },
134
+ "@deepseek-ai/dsh-client-ui-input-trigger": {
135
+ "optional": true
136
+ },
137
+ "@deepseek-ai/dsh-client-ui-slots": {
138
+ "optional": true
139
+ },
140
+ "@deepseek-ai/dsh-client-ui-conversation": {
141
+ "optional": true
142
+ },
143
+ "@deepseek-ai/dsh-client-locale": {
144
+ "optional": true
145
+ },
146
+ "@deepseek-ai/dsh-client-connection": {
147
+ "optional": true
148
+ },
149
+ "@deepseek-ai/dsh-client-ui-settings": {
150
+ "optional": true
151
+ },
152
+ "@deepseek-ai/dsh-settings": {
153
+ "optional": true
154
+ },
155
+ "react": {
156
+ "optional": true
157
+ }
158
+ },
159
+ "dependencies": {
160
+ "@deepseek-ai/schemastery": "^3.18.1",
161
+ "@lobehub/icons": "^5.16.0",
162
+ "react-markdown": "^10.1.0",
163
+ "zod": "^4.4.3"
164
+ },
165
+ "devDependencies": {
166
+ "@deepseek-ai/cordis": "^4.0.1",
167
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.8",
168
+ "@deepseek-ai/dsh-api-remotes": "^0.1.0-rc.8",
169
+ "@deepseek-ai/dsh-attachment": "^0.1.0-rc.8",
170
+ "@deepseek-ai/dsh-client-connection": "^0.1.0-rc.8",
171
+ "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.8",
172
+ "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.8",
173
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.1.0-rc.8",
174
+ "@deepseek-ai/dsh-client-ui-input-trigger": "^0.1.0-rc.8",
175
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.8",
176
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.8",
177
+ "@deepseek-ai/dsh-file-reference": "^0.1.0-rc.8",
178
+ "@deepseek-ai/dsh-llm": "^0.1.0-rc.8",
179
+ "@deepseek-ai/dsh-output-retention": "^0.1.0-rc.8",
180
+ "@deepseek-ai/dsh-session": "^0.1.0-rc.8",
181
+ "@deepseek-ai/dsh-session-reference": "^0.1.0-rc.8",
182
+ "@deepseek-ai/dsh-settings": "^0.1.0-rc.8",
183
+ "@deepseek-ai/dsh-storage": "^0.1.0-rc.8",
184
+ "@deepseek-ai/dsh-storage-domain": "^0.1.0-rc.8",
185
+ "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.8",
186
+ "@deepseek-ai/dsh-tools": "^0.1.0-rc.8",
187
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.8",
188
+ "@deepseek-ai/dsh-typert-registry": "^0.1.0-rc.8",
189
+ "@jackwener/opencli": "1.8.6",
190
+ "@types/node": "^22.20.1",
191
+ "@types/react": "^18.2.0",
192
+ "@types/react-dom": "^18.3.7",
193
+ "esbuild": "^0.25.0",
194
+ "jsdom": "^26.1.0",
195
+ "react": "^18.2.0",
196
+ "react-dom": "^18.2.0",
197
+ "typescript": "^5.7.0",
198
+ "vitest": "^3.0.0"
199
+ }
200
+ }
@@ -1,30 +0,0 @@
1
- import type { ReferenceUiMode } from './wire.ts';
2
- export declare const OFFICIAL_REFERENCE_PATCH_BEGIN = "# BEGIN dsh-reference-anything managed official-reference override";
3
- export declare const OFFICIAL_REFERENCE_PATCH_END = "# END dsh-reference-anything managed official-reference override";
4
- export interface ReferenceUiSwitchResult {
5
- mode: ReferenceUiMode;
6
- restartRequired: false;
7
- }
8
- interface SwitchReferenceUiModeOptions {
9
- mode: ReferenceUiMode;
10
- packageRoot?: string;
11
- dshHome?: string;
12
- signal?: AbortSignal;
13
- }
14
- /**
15
- * Switch only the visible @ implementation while keeping this package alive.
16
- *
17
- * The bundle patch remains untouched so updating or reinstalling the package
18
- * cannot erase the user's choice. The plugin Host and settings entry remain
19
- * active in both modes; the client separately registers or disposes its own
20
- * picker sources.
21
- */
22
- export declare function switchReferenceUiMode(options: SwitchReferenceUiModeOptions): Promise<ReferenceUiSwitchResult>;
23
- /** Write the managed override without exposing a partially-written YAML file. */
24
- export declare function writeReferenceUiModeOverride(path: string, mode: ReferenceUiMode, signal?: AbortSignal): Promise<void>;
25
- /**
26
- * Preserve every user-owned row and append one idempotent block at the end,
27
- * where Cordis' ordered patch semantics make it the effective override.
28
- */
29
- export declare function withReferenceUiModeOverride(source: string, mode: ReferenceUiMode): string;
30
- export {};
@@ -1,90 +0,0 @@
1
- import { readFile, rename, rm, writeFile } from 'node:fs/promises';
2
- import { dirname, join } from 'node:path';
3
- import { findOwningProfileDir } from "./update.js";
4
- export const OFFICIAL_REFERENCE_PATCH_BEGIN = '# BEGIN dsh-reference-anything managed official-reference override';
5
- export const OFFICIAL_REFERENCE_PATCH_END = '# END dsh-reference-anything managed official-reference override';
6
- /**
7
- * Switch only the visible @ implementation while keeping this package alive.
8
- *
9
- * The bundle patch remains untouched so updating or reinstalling the package
10
- * cannot erase the user's choice. The plugin Host and settings entry remain
11
- * active in both modes; the client separately registers or disposes its own
12
- * picker sources.
13
- */
14
- export async function switchReferenceUiMode(options) {
15
- options.signal?.throwIfAborted();
16
- const profileDir = await findOwningProfileDir(options.packageRoot, options.dshHome);
17
- await writeReferenceUiModeOverride(join(profileDir, 'cordis.patch.yml'), options.mode, options.signal);
18
- return { mode: options.mode, restartRequired: false };
19
- }
20
- /** Write the managed override without exposing a partially-written YAML file. */
21
- export async function writeReferenceUiModeOverride(path, mode, signal) {
22
- signal?.throwIfAborted();
23
- let source = '';
24
- try {
25
- source = await readFile(path, { encoding: 'utf8', signal });
26
- }
27
- catch (error) {
28
- const code = error.code;
29
- if (code !== 'ENOENT')
30
- throw error;
31
- }
32
- const next = withReferenceUiModeOverride(source, mode);
33
- if (next === source)
34
- return;
35
- const temporary = join(dirname(path), `.cordis.patch.yml.dsh-reference-anything-${String(process.pid)}-${String(Date.now())}.tmp`);
36
- try {
37
- await writeFile(temporary, next, { encoding: 'utf8', signal });
38
- signal?.throwIfAborted();
39
- await rename(temporary, path);
40
- }
41
- catch (error) {
42
- await rm(temporary, { force: true }).catch(() => undefined);
43
- throw error;
44
- }
45
- }
46
- /**
47
- * Preserve every user-owned row and append one idempotent block at the end,
48
- * where Cordis' ordered patch semantics make it the effective override.
49
- */
50
- export function withReferenceUiModeOverride(source, mode) {
51
- const eol = source.includes('\r\n') ? '\r\n' : '\n';
52
- const lines = source.split(/\r?\n/);
53
- const beginRows = markerRows(lines, OFFICIAL_REFERENCE_PATCH_BEGIN);
54
- const endRows = markerRows(lines, OFFICIAL_REFERENCE_PATCH_END);
55
- if (beginRows.length > 1 || endRows.length > 1 || beginRows.length !== endRows.length) {
56
- throw new Error('the managed official-reference block in cordis.patch.yml is malformed');
57
- }
58
- if (beginRows.length === 1) {
59
- const begin = beginRows[0];
60
- const end = endRows[0];
61
- if (end < begin)
62
- throw new Error('the managed official-reference block in cordis.patch.yml is malformed');
63
- lines.splice(begin, end - begin + 1);
64
- }
65
- removeEmptyArrayDocument(lines);
66
- while (lines.length > 0 && lines.at(-1)?.trim() === '')
67
- lines.pop();
68
- const block = [
69
- OFFICIAL_REFERENCE_PATCH_BEGIN,
70
- '# Switch only the visible @ implementation; Reference Anything stays loaded.',
71
- '- id: ui-reference',
72
- ` disabled: ${mode === 'official' ? 'false' : 'true'}`,
73
- OFFICIAL_REFERENCE_PATCH_END,
74
- ];
75
- return [...lines, ...(lines.length > 0 ? [''] : []), ...block, ''].join(eol);
76
- }
77
- function markerRows(lines, marker) {
78
- const rows = [];
79
- lines.forEach((line, index) => { if (line.trim() === marker)
80
- rows.push(index); });
81
- return rows;
82
- }
83
- /** `[]` is the valid empty profile document, but cannot precede list rows. */
84
- function removeEmptyArrayDocument(lines) {
85
- const meaningful = lines
86
- .map((line, index) => ({ index, text: line.trim() }))
87
- .filter(row => row.text !== '' && !row.text.startsWith('#'));
88
- if (meaningful.length === 1 && meaningful[0]?.text === '[]')
89
- lines.splice(meaningful[0].index, 1);
90
- }