@researai/deepscientist 1.5.14 → 1.5.16

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 (225) hide show
  1. package/README.md +336 -90
  2. package/assets/branding/logo-raster.png +0 -0
  3. package/bin/ds.js +816 -131
  4. package/docs/en/00_QUICK_START.md +36 -15
  5. package/docs/en/01_SETTINGS_REFERENCE.md +53 -4
  6. package/docs/en/02_START_RESEARCH_GUIDE.md +7 -0
  7. package/docs/en/03_QQ_CONNECTOR_GUIDE.md +19 -0
  8. package/docs/en/05_TUI_GUIDE.md +6 -0
  9. package/docs/en/06_RUNTIME_AND_CANVAS.md +4 -3
  10. package/docs/en/09_DOCTOR.md +11 -5
  11. package/docs/en/10_WEIXIN_CONNECTOR_GUIDE.md +20 -0
  12. package/docs/en/14_PROMPT_SKILLS_AND_MCP_GUIDE.md +65 -13
  13. package/docs/en/15_CODEX_PROVIDER_SETUP.md +25 -8
  14. package/docs/en/16_TELEGRAM_CONNECTOR_GUIDE.md +134 -0
  15. package/docs/en/17_WHATSAPP_CONNECTOR_GUIDE.md +126 -0
  16. package/docs/en/18_FEISHU_CONNECTOR_GUIDE.md +136 -0
  17. package/docs/en/19_EXTERNAL_CONTROLLER_GUIDE.md +226 -0
  18. package/docs/en/19_LOCAL_BROWSER_AUTH.md +70 -0
  19. package/docs/en/20_WORKSPACE_MODES_GUIDE.md +250 -0
  20. package/docs/en/README.md +24 -0
  21. package/docs/zh/00_QUICK_START.md +36 -15
  22. package/docs/zh/01_SETTINGS_REFERENCE.md +53 -4
  23. package/docs/zh/02_START_RESEARCH_GUIDE.md +7 -0
  24. package/docs/zh/03_QQ_CONNECTOR_GUIDE.md +19 -0
  25. package/docs/zh/05_TUI_GUIDE.md +6 -0
  26. package/docs/zh/09_DOCTOR.md +11 -5
  27. package/docs/zh/10_WEIXIN_CONNECTOR_GUIDE.md +20 -0
  28. package/docs/zh/14_PROMPT_SKILLS_AND_MCP_GUIDE.md +65 -13
  29. package/docs/zh/15_CODEX_PROVIDER_SETUP.md +25 -8
  30. package/docs/zh/16_TELEGRAM_CONNECTOR_GUIDE.md +134 -0
  31. package/docs/zh/17_WHATSAPP_CONNECTOR_GUIDE.md +126 -0
  32. package/docs/zh/18_FEISHU_CONNECTOR_GUIDE.md +136 -0
  33. package/docs/zh/19_EXTERNAL_CONTROLLER_GUIDE.md +226 -0
  34. package/docs/zh/19_LOCAL_BROWSER_AUTH.md +68 -0
  35. package/docs/zh/20_WORKSPACE_MODES_GUIDE.md +251 -0
  36. package/docs/zh/README.md +24 -0
  37. package/install.sh +2 -0
  38. package/package.json +1 -1
  39. package/pyproject.toml +1 -1
  40. package/src/deepscientist/__init__.py +1 -1
  41. package/src/deepscientist/acp/envelope.py +6 -0
  42. package/src/deepscientist/artifact/charts.py +567 -0
  43. package/src/deepscientist/artifact/guidance.py +50 -10
  44. package/src/deepscientist/artifact/metrics.py +228 -5
  45. package/src/deepscientist/artifact/schemas.py +3 -0
  46. package/src/deepscientist/artifact/service.py +4276 -308
  47. package/src/deepscientist/bash_exec/models.py +23 -0
  48. package/src/deepscientist/bash_exec/monitor.py +147 -67
  49. package/src/deepscientist/bash_exec/runtime.py +218 -156
  50. package/src/deepscientist/bash_exec/service.py +309 -69
  51. package/src/deepscientist/bash_exec/shells.py +87 -0
  52. package/src/deepscientist/bridges/connectors.py +51 -2
  53. package/src/deepscientist/cli.py +115 -19
  54. package/src/deepscientist/codex_cli_compat.py +232 -0
  55. package/src/deepscientist/config/models.py +8 -4
  56. package/src/deepscientist/config/service.py +38 -11
  57. package/src/deepscientist/connector/weixin_support.py +122 -1
  58. package/src/deepscientist/daemon/api/handlers.py +199 -9
  59. package/src/deepscientist/daemon/api/router.py +5 -0
  60. package/src/deepscientist/daemon/app.py +1458 -289
  61. package/src/deepscientist/doctor.py +51 -0
  62. package/src/deepscientist/file_lock.py +48 -0
  63. package/src/deepscientist/gitops/__init__.py +10 -1
  64. package/src/deepscientist/gitops/diff.py +296 -1
  65. package/src/deepscientist/gitops/service.py +4 -1
  66. package/src/deepscientist/mcp/server.py +212 -5
  67. package/src/deepscientist/process_control.py +161 -0
  68. package/src/deepscientist/prompts/builder.py +501 -453
  69. package/src/deepscientist/quest/layout.py +15 -2
  70. package/src/deepscientist/quest/service.py +2539 -195
  71. package/src/deepscientist/quest/stage_views.py +177 -1
  72. package/src/deepscientist/runners/base.py +2 -0
  73. package/src/deepscientist/runners/codex.py +169 -31
  74. package/src/deepscientist/runners/runtime_overrides.py +17 -1
  75. package/src/deepscientist/skills/__init__.py +2 -2
  76. package/src/deepscientist/skills/installer.py +196 -5
  77. package/src/deepscientist/skills/registry.py +66 -0
  78. package/src/prompts/connectors/qq.md +18 -8
  79. package/src/prompts/connectors/weixin.md +16 -6
  80. package/src/prompts/contracts/shared_interaction.md +24 -4
  81. package/src/prompts/system.md +921 -72
  82. package/src/prompts/system_copilot.md +43 -0
  83. package/src/skills/analysis-campaign/SKILL.md +32 -2
  84. package/src/skills/analysis-campaign/references/artifact-orchestration.md +1 -1
  85. package/src/skills/analysis-campaign/references/writing-facing-slice-examples.md +65 -0
  86. package/src/skills/baseline/SKILL.md +10 -0
  87. package/src/skills/decision/SKILL.md +27 -2
  88. package/src/skills/experiment/SKILL.md +16 -2
  89. package/src/skills/figure-polish/SKILL.md +1 -0
  90. package/src/skills/finalize/SKILL.md +19 -0
  91. package/src/skills/idea/SKILL.md +79 -0
  92. package/src/skills/idea/references/idea-generation-playbook.md +100 -0
  93. package/src/skills/idea/references/outline-seeding-example.md +60 -0
  94. package/src/skills/intake-audit/SKILL.md +9 -1
  95. package/src/skills/mentor/SKILL.md +217 -0
  96. package/src/skills/mentor/references/correction-rules.md +210 -0
  97. package/src/skills/mentor/references/knowledge-profile.md +91 -0
  98. package/src/skills/mentor/references/persona-profile.md +138 -0
  99. package/src/skills/mentor/references/taste-profile.md +128 -0
  100. package/src/skills/mentor/references/thought-style-profile.md +138 -0
  101. package/src/skills/mentor/references/work-profile.md +289 -0
  102. package/src/skills/mentor/references/workflow-profile.md +240 -0
  103. package/src/skills/optimize/SKILL.md +1645 -0
  104. package/src/skills/rebuttal/SKILL.md +3 -1
  105. package/src/skills/review/SKILL.md +3 -1
  106. package/src/skills/scout/SKILL.md +8 -0
  107. package/src/skills/write/SKILL.md +81 -12
  108. package/src/skills/write/references/outline-evidence-contract-example.md +107 -0
  109. package/src/tui/dist/app/AppContainer.js +22 -11
  110. package/src/tui/dist/index.js +4 -1
  111. package/src/tui/dist/lib/api.js +33 -3
  112. package/src/tui/package.json +1 -1
  113. package/src/ui/dist/assets/AiManusChatView-COFACy7V.js +204 -0
  114. package/src/ui/dist/assets/AnalysisPlugin-DnSm0GZn.js +1 -0
  115. package/src/ui/dist/assets/CliPlugin-CvwCmDQ5.js +109 -0
  116. package/src/ui/dist/assets/CodeEditorPlugin-cOqSa0xq.js +2 -0
  117. package/src/ui/dist/assets/CodeViewerPlugin-itb0tltR.js +270 -0
  118. package/src/ui/dist/assets/DocViewerPlugin-DqKkiCI6.js +7 -0
  119. package/src/ui/dist/assets/GitCommitViewerPlugin-DVgNHBCS.js +1 -0
  120. package/src/ui/dist/assets/GitDiffViewerPlugin-DxL2ezFG.js +6 -0
  121. package/src/ui/dist/assets/GitSnapshotViewer-B_RQm1YZ.js +30 -0
  122. package/src/ui/dist/assets/ImageViewerPlugin-tHqlXY3n.js +26 -0
  123. package/src/ui/dist/assets/LabCopilotPanel-ClMbq5Yu.js +14 -0
  124. package/src/ui/dist/assets/LabPlugin-L_SuE8ow.js +22 -0
  125. package/src/ui/dist/assets/LatexPlugin-B495DTXC.js +25 -0
  126. package/src/ui/dist/assets/MarkdownViewerPlugin-DG28-61B.js +128 -0
  127. package/src/ui/dist/assets/MarketplacePlugin-BiOGT-Kj.js +13 -0
  128. package/src/ui/dist/assets/{NotebookEditor-CccQYZjX.css → NotebookEditor-BHH8rdGj.css} +1 -1
  129. package/src/ui/dist/assets/NotebookEditor-BOr3x3Ej.css +1 -0
  130. package/src/ui/dist/assets/NotebookEditor-C-4Kt1p9.js +81 -0
  131. package/src/ui/dist/assets/NotebookEditor-CVsj8h_T.js +361 -0
  132. package/src/ui/dist/assets/PdfLoader-CASDQmxJ.js +16 -0
  133. package/src/ui/dist/assets/PdfLoader-Cy5jtWrr.css +1 -0
  134. package/src/ui/dist/assets/PdfMarkdownPlugin-BFhwoKsY.js +1 -0
  135. package/src/ui/dist/assets/PdfViewerPlugin-DcOzU9vd.js +17 -0
  136. package/src/ui/dist/assets/PdfViewerPlugin-nwwE-fjJ.css +1 -0
  137. package/src/ui/dist/assets/SearchPlugin-CHj7M58O.js +16 -0
  138. package/src/ui/dist/assets/SearchPlugin-DA4en4hK.css +1 -0
  139. package/src/ui/dist/assets/TextViewerPlugin-CB4DYfWO.js +54 -0
  140. package/src/ui/dist/assets/VNCViewer-CjlbyCB3.js +11 -0
  141. package/src/ui/dist/assets/bot-CFkZY-JP.js +6 -0
  142. package/src/ui/dist/assets/browser-CTB2jwNe.js +8 -0
  143. package/src/ui/dist/assets/chevron-up-Dq5ofbht.js +6 -0
  144. package/src/ui/dist/assets/code-DLC6G24T.js +6 -0
  145. package/src/ui/dist/assets/file-content-Dv4LoZec.js +1 -0
  146. package/src/ui/dist/assets/file-diff-panel-Denq-lC3.js +1 -0
  147. package/src/ui/dist/assets/file-jump-queue-DA-SdG__.js +1 -0
  148. package/src/ui/dist/assets/file-socket-Cu4Qln7Y.js +1 -0
  149. package/src/ui/dist/assets/git-commit-horizontal-BUh6G52n.js +6 -0
  150. package/src/ui/dist/assets/image-B9HUUddG.js +6 -0
  151. package/src/ui/dist/assets/index-B2B1sg-M.js +1 -0
  152. package/src/ui/dist/assets/index-Cgla8biy.css +33 -0
  153. package/src/ui/dist/assets/index-DRyx7vAc.js +1 -0
  154. package/src/ui/dist/assets/index-Gbl53BNp.js +2496 -0
  155. package/src/ui/dist/assets/index-wQ7RIIRd.js +11 -0
  156. package/src/ui/dist/assets/monaco-CiHMMNH_.js +1 -0
  157. package/src/ui/dist/assets/pdf-effect-queue-ZtnHFCAi.js +6 -0
  158. package/src/ui/dist/assets/plugin-monaco-C8UgLomw.js +19 -0
  159. package/src/ui/dist/assets/plugin-notebook-HbW2K-1c.js +169 -0
  160. package/src/ui/dist/assets/plugin-pdf-CR8hgQBV.js +357 -0
  161. package/src/ui/dist/assets/plugin-terminal-MXFIPun8.js +227 -0
  162. package/src/ui/dist/assets/popover-DL6h35vr.js +1 -0
  163. package/src/ui/dist/assets/project-sync-CsX08Qno.js +1 -0
  164. package/src/ui/dist/assets/select-DvmXt1yY.js +11 -0
  165. package/src/ui/dist/assets/sigma-7jpXazui.js +6 -0
  166. package/src/ui/dist/assets/trash-xA7kFt8i.js +11 -0
  167. package/src/ui/dist/assets/useCliAccess-DsMwDjOp.js +1 -0
  168. package/src/ui/dist/assets/useFileDiffOverlay-FuhcnKiw.js +1 -0
  169. package/src/ui/dist/assets/wrap-text-CwMn-iqb.js +11 -0
  170. package/src/ui/dist/assets/zoom-out-R-GWEhzS.js +11 -0
  171. package/src/ui/dist/index.html +5 -2
  172. package/src/ui/dist/assets/AiManusChatView-DaF9Nge_.js +0 -26597
  173. package/src/ui/dist/assets/AnalysisPlugin-BSVx6dXE.js +0 -123
  174. package/src/ui/dist/assets/CliPlugin-C9gzJX41.js +0 -5905
  175. package/src/ui/dist/assets/CodeEditorPlugin-DU9G0Tox.js +0 -427
  176. package/src/ui/dist/assets/CodeViewerPlugin-DoX_fI9l.js +0 -905
  177. package/src/ui/dist/assets/DocViewerPlugin-C4FWIXuU.js +0 -278
  178. package/src/ui/dist/assets/GitDiffViewerPlugin-BgfFMgtf.js +0 -2661
  179. package/src/ui/dist/assets/ImageViewerPlugin-tcPkfY_x.js +0 -500
  180. package/src/ui/dist/assets/LabCopilotPanel-_dKV60Bf.js +0 -4104
  181. package/src/ui/dist/assets/LabPlugin-Bje0ayoC.js +0 -2677
  182. package/src/ui/dist/assets/LatexPlugin-CVsBzAln.js +0 -1792
  183. package/src/ui/dist/assets/MarkdownViewerPlugin-xjmrqv_8.js +0 -308
  184. package/src/ui/dist/assets/MarketplacePlugin-mMM2A8wP.js +0 -413
  185. package/src/ui/dist/assets/NotebookEditor-3kVDSOBo.js +0 -4214
  186. package/src/ui/dist/assets/NotebookEditor-C3VQ7ylN.css +0 -1405
  187. package/src/ui/dist/assets/NotebookEditor-SoJ8X-MO.js +0 -84873
  188. package/src/ui/dist/assets/PdfLoader-C-Y707R3.css +0 -49
  189. package/src/ui/dist/assets/PdfLoader-DElVuHl9.js +0 -25468
  190. package/src/ui/dist/assets/PdfMarkdownPlugin-Bq88XT4G.js +0 -409
  191. package/src/ui/dist/assets/PdfViewerPlugin-CsCXMo9S.js +0 -3095
  192. package/src/ui/dist/assets/PdfViewerPlugin-DQ11QcSf.css +0 -3627
  193. package/src/ui/dist/assets/SearchPlugin-DDMrGDkh.css +0 -379
  194. package/src/ui/dist/assets/SearchPlugin-oUPvy19k.js +0 -741
  195. package/src/ui/dist/assets/TextViewerPlugin-CRkT9yNy.js +0 -472
  196. package/src/ui/dist/assets/VNCViewer-BgbuvWhR.js +0 -18821
  197. package/src/ui/dist/assets/awareness-C0NPR2Dj.js +0 -292
  198. package/src/ui/dist/assets/bot-v_RASACv.js +0 -21
  199. package/src/ui/dist/assets/browser-BAcuE0Xj.js +0 -2895
  200. package/src/ui/dist/assets/code-5hC9d0VH.js +0 -17
  201. package/src/ui/dist/assets/file-content-D1PxfOrp.js +0 -377
  202. package/src/ui/dist/assets/file-diff-panel-DG1oT_Hj.js +0 -92
  203. package/src/ui/dist/assets/file-jump-queue-r5XKgJEV.js +0 -16
  204. package/src/ui/dist/assets/file-socket-BmdFYQlk.js +0 -58
  205. package/src/ui/dist/assets/function-B5QZkkHC.js +0 -1895
  206. package/src/ui/dist/assets/image-Dqe2X2tW.js +0 -18
  207. package/src/ui/dist/assets/index-BQG-1s2o.css +0 -12553
  208. package/src/ui/dist/assets/index-DVsMKK_y.js +0 -25
  209. package/src/ui/dist/assets/index-Duvz8Ip0.js +0 -159
  210. package/src/ui/dist/assets/index-Nt9hS4ck.js +0 -244829
  211. package/src/ui/dist/assets/index-RDlNXXx1.js +0 -120
  212. package/src/ui/dist/assets/monaco-DIXge1CP.js +0 -623
  213. package/src/ui/dist/assets/pdf-effect-queue-BBTTQaO-.js +0 -47
  214. package/src/ui/dist/assets/pdf_viewer-e0g1is2C.js +0 -8206
  215. package/src/ui/dist/assets/popover-BWlolyxo.js +0 -476
  216. package/src/ui/dist/assets/project-sync-BM5PkFH4.js +0 -297
  217. package/src/ui/dist/assets/select-D4dAtrA8.js +0 -1690
  218. package/src/ui/dist/assets/sigma-CKbE5jJT.js +0 -22
  219. package/src/ui/dist/assets/square-check-big-CZNGMgiB.js +0 -17
  220. package/src/ui/dist/assets/trash-DaB37xAz.js +0 -32
  221. package/src/ui/dist/assets/useCliAccess-C2OmAcWe.js +0 -957
  222. package/src/ui/dist/assets/useFileDiffOverlay-Dowd1Ij4.js +0 -53
  223. package/src/ui/dist/assets/wrap-text-BGjAhAUq.js +0 -35
  224. package/src/ui/dist/assets/yjs-DncrqiZ8.js +0 -11243
  225. package/src/ui/dist/assets/zoom-out-dMZQMXzc.js +0 -34
@@ -1,905 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Nt9hS4ck.js","assets/index-BQG-1s2o.css"])))=>i.map(i=>d[i]);
2
- import { u as useI18n, a as useWorkspaceSurfaceStore, r as reactExports, c as copyToClipboard, j as jsxRuntimeExports, L as LoaderCircle, C as CircleAlert, F as FileCode, E as Eye, b as cn, d as Check, e as Copy, _ as __vitePreload } from './index-Nt9hS4ck.js';
3
- import { c as consumeFileJumpEffects } from './file-jump-queue-r5XKgJEV.js';
4
- import { C as Code } from './code-5hC9d0VH.js';
5
- import { H as Hash, W as WrapText } from './wrap-text-BGjAhAUq.js';
6
-
7
- const EXTENSION_TO_LANGUAGE = {
8
- // JavaScript/TypeScript
9
- ".js": "javascript",
10
- ".jsx": "javascript",
11
- ".mjs": "javascript",
12
- ".ts": "typescript",
13
- ".tsx": "typescript",
14
- ".mts": "typescript",
15
- // Python
16
- ".py": "python",
17
- ".pyw": "python",
18
- ".pyi": "python",
19
- // JSON
20
- ".json": "json",
21
- ".jsonc": "json",
22
- ".json5": "json",
23
- // Web
24
- ".html": "html",
25
- ".htm": "html",
26
- ".css": "css",
27
- ".scss": "scss",
28
- ".sass": "sass",
29
- ".less": "less",
30
- // Config
31
- ".yaml": "yaml",
32
- ".yml": "yaml",
33
- ".toml": "toml",
34
- ".ini": "ini",
35
- ".cfg": "ini",
36
- ".conf": "ini",
37
- // Shell
38
- ".sh": "bash",
39
- ".bash": "bash",
40
- ".zsh": "zsh",
41
- ".fish": "fish",
42
- // SQL
43
- ".sql": "sql",
44
- // XML
45
- ".xml": "xml",
46
- ".xsl": "xml",
47
- ".xslt": "xml",
48
- ".svg": "xml",
49
- // Go
50
- ".go": "go",
51
- // Rust
52
- ".rs": "rust",
53
- // C/C++
54
- ".c": "c",
55
- ".h": "c",
56
- ".cpp": "cpp",
57
- ".cc": "cpp",
58
- ".cxx": "cpp",
59
- ".hpp": "cpp",
60
- ".hxx": "cpp",
61
- // Java
62
- ".java": "java",
63
- // C#
64
- ".cs": "csharp",
65
- // PHP
66
- ".php": "php",
67
- // Ruby
68
- ".rb": "ruby",
69
- // Swift
70
- ".swift": "swift",
71
- // Kotlin
72
- ".kt": "kotlin",
73
- ".kts": "kotlin",
74
- // Markdown
75
- ".md": "markdown",
76
- ".markdown": "markdown"
77
- };
78
- function getLanguageFromPath(path) {
79
- const ext = path.substring(path.lastIndexOf(".")).toLowerCase();
80
- return EXTENSION_TO_LANGUAGE[ext] || "plaintext";
81
- }
82
- function isHtmlLanguage(language) {
83
- return language === "html";
84
- }
85
- const KEYWORDS = {
86
- javascript: [
87
- "const",
88
- "let",
89
- "var",
90
- "function",
91
- "return",
92
- "if",
93
- "else",
94
- "for",
95
- "while",
96
- "do",
97
- "switch",
98
- "case",
99
- "break",
100
- "continue",
101
- "default",
102
- "class",
103
- "extends",
104
- "new",
105
- "this",
106
- "super",
107
- "import",
108
- "export",
109
- "from",
110
- "as",
111
- "async",
112
- "await",
113
- "try",
114
- "catch",
115
- "finally",
116
- "throw",
117
- "typeof",
118
- "instanceof",
119
- "in",
120
- "of",
121
- "true",
122
- "false",
123
- "null",
124
- "undefined",
125
- "void"
126
- ],
127
- typescript: [
128
- "const",
129
- "let",
130
- "var",
131
- "function",
132
- "return",
133
- "if",
134
- "else",
135
- "for",
136
- "while",
137
- "do",
138
- "switch",
139
- "case",
140
- "break",
141
- "continue",
142
- "default",
143
- "class",
144
- "extends",
145
- "new",
146
- "this",
147
- "super",
148
- "import",
149
- "export",
150
- "from",
151
- "as",
152
- "async",
153
- "await",
154
- "try",
155
- "catch",
156
- "finally",
157
- "throw",
158
- "typeof",
159
- "instanceof",
160
- "in",
161
- "of",
162
- "true",
163
- "false",
164
- "null",
165
- "undefined",
166
- "void",
167
- "type",
168
- "interface",
169
- "enum",
170
- "namespace",
171
- "module",
172
- "declare",
173
- "abstract",
174
- "implements",
175
- "private",
176
- "protected",
177
- "public",
178
- "readonly",
179
- "static"
180
- ],
181
- python: [
182
- "def",
183
- "class",
184
- "if",
185
- "elif",
186
- "else",
187
- "for",
188
- "while",
189
- "try",
190
- "except",
191
- "finally",
192
- "with",
193
- "as",
194
- "import",
195
- "from",
196
- "return",
197
- "yield",
198
- "raise",
199
- "pass",
200
- "break",
201
- "continue",
202
- "and",
203
- "or",
204
- "not",
205
- "in",
206
- "is",
207
- "lambda",
208
- "True",
209
- "False",
210
- "None",
211
- "global",
212
- "nonlocal",
213
- "assert",
214
- "del"
215
- ],
216
- go: [
217
- "package",
218
- "import",
219
- "func",
220
- "return",
221
- "var",
222
- "const",
223
- "type",
224
- "struct",
225
- "interface",
226
- "map",
227
- "chan",
228
- "go",
229
- "defer",
230
- "if",
231
- "else",
232
- "for",
233
- "range",
234
- "switch",
235
- "case",
236
- "default",
237
- "break",
238
- "continue",
239
- "fallthrough",
240
- "select",
241
- "true",
242
- "false",
243
- "nil"
244
- ],
245
- rust: [
246
- "fn",
247
- "let",
248
- "mut",
249
- "const",
250
- "static",
251
- "if",
252
- "else",
253
- "match",
254
- "for",
255
- "while",
256
- "loop",
257
- "break",
258
- "continue",
259
- "return",
260
- "struct",
261
- "enum",
262
- "impl",
263
- "trait",
264
- "pub",
265
- "mod",
266
- "use",
267
- "as",
268
- "self",
269
- "super",
270
- "crate",
271
- "async",
272
- "await",
273
- "move",
274
- "ref",
275
- "true",
276
- "false",
277
- "where"
278
- ]
279
- // Add more as needed...
280
- };
281
- function tokenize(code, language) {
282
- const lines = code.split("\n");
283
- const keywords = KEYWORDS[language] || KEYWORDS.javascript || [];
284
- const keywordSet = new Set(keywords);
285
- return lines.map((line) => {
286
- const tokens = [];
287
- let remaining = line;
288
- while (remaining.length > 0) {
289
- const doubleStringMatch = remaining.match(/^"(?:[^"\\]|\\.)*"/);
290
- if (doubleStringMatch) {
291
- tokens.push({ type: "string", value: doubleStringMatch[0] });
292
- remaining = remaining.slice(doubleStringMatch[0].length);
293
- continue;
294
- }
295
- const singleStringMatch = remaining.match(/^'(?:[^'\\]|\\.)*'/);
296
- if (singleStringMatch) {
297
- tokens.push({ type: "string", value: singleStringMatch[0] });
298
- remaining = remaining.slice(singleStringMatch[0].length);
299
- continue;
300
- }
301
- const templateStringMatch = remaining.match(/^`(?:[^`\\]|\\.)*`/);
302
- if (templateStringMatch) {
303
- tokens.push({ type: "string", value: templateStringMatch[0] });
304
- remaining = remaining.slice(templateStringMatch[0].length);
305
- continue;
306
- }
307
- const commentMatch = remaining.match(/^(\/\/.*|#.*)$/);
308
- if (commentMatch) {
309
- tokens.push({ type: "comment", value: commentMatch[0] });
310
- remaining = "";
311
- continue;
312
- }
313
- const multiCommentMatch = remaining.match(/^\/\*.*?\*\//);
314
- if (multiCommentMatch) {
315
- tokens.push({ type: "comment", value: multiCommentMatch[0] });
316
- remaining = remaining.slice(multiCommentMatch[0].length);
317
- continue;
318
- }
319
- const numberMatch = remaining.match(/^-?\d+\.?\d*([eE][+-]?\d+)?/);
320
- if (numberMatch) {
321
- tokens.push({ type: "number", value: numberMatch[0] });
322
- remaining = remaining.slice(numberMatch[0].length);
323
- continue;
324
- }
325
- const wordMatch = remaining.match(/^[a-zA-Z_$][a-zA-Z0-9_$]*/);
326
- if (wordMatch) {
327
- const word = wordMatch[0];
328
- const nextChar = remaining[word.length];
329
- if (keywordSet.has(word)) {
330
- tokens.push({ type: "keyword", value: word });
331
- } else if (nextChar === "(") {
332
- tokens.push({ type: "function", value: word });
333
- } else {
334
- tokens.push({ type: "default", value: word });
335
- }
336
- remaining = remaining.slice(word.length);
337
- continue;
338
- }
339
- const operatorMatch = remaining.match(/^[+\-*/%=<>!&|^~?:]+/);
340
- if (operatorMatch) {
341
- tokens.push({ type: "operator", value: operatorMatch[0] });
342
- remaining = remaining.slice(operatorMatch[0].length);
343
- continue;
344
- }
345
- const punctMatch = remaining.match(/^[{}[\]();,.]/);
346
- if (punctMatch) {
347
- tokens.push({ type: "punctuation", value: punctMatch[0] });
348
- remaining = remaining.slice(punctMatch[0].length);
349
- continue;
350
- }
351
- tokens.push({ type: "default", value: remaining[0] });
352
- remaining = remaining.slice(1);
353
- }
354
- return tokens;
355
- });
356
- }
357
- const TOKEN_COLORS = {
358
- keyword: "text-purple-400",
359
- string: "text-green-400",
360
- comment: "text-gray-500 italic",
361
- number: "text-slate-200",
362
- function: "text-blue-400",
363
- operator: "text-pink-400",
364
- punctuation: "text-gray-400",
365
- default: "text-gray-100"
366
- };
367
- function CodeViewerPlugin({
368
- context,
369
- tabId,
370
- setDirty,
371
- setTitle
372
- }) {
373
- const { t } = useI18n("code_viewer");
374
- const updateWorkspaceTabState = useWorkspaceSurfaceStore((state) => state.updateTabState);
375
- const [content, setContent] = reactExports.useState("");
376
- const [loading, setLoading] = reactExports.useState(true);
377
- const [error, setError] = reactExports.useState(null);
378
- const [copied, setCopied] = reactExports.useState(false);
379
- const [showLineNumbers, setShowLineNumbers] = reactExports.useState(true);
380
- const [wordWrap, setWordWrap] = reactExports.useState(false);
381
- const [viewMode, setViewMode] = reactExports.useState("source");
382
- const [highlightRange, setHighlightRange] = reactExports.useState(
383
- null
384
- );
385
- const highlightTimerRef = reactExports.useRef(null);
386
- const fileId = context.resourceId;
387
- const fileName = context.resourceName || context.resourcePath || "Untitled";
388
- const language = reactExports.useMemo(
389
- () => getLanguageFromPath(context.resourcePath || ""),
390
- [context.resourcePath]
391
- );
392
- const isHtmlDocument = reactExports.useMemo(
393
- () => isHtmlLanguage(language) || String(context.mimeType || "").toLowerCase().includes("html"),
394
- [context.mimeType, language]
395
- );
396
- reactExports.useEffect(() => {
397
- setViewMode(isHtmlDocument ? "rendered" : "source");
398
- }, [fileId, isHtmlDocument]);
399
- reactExports.useEffect(() => {
400
- setTitle(fileName);
401
- }, [fileName, setTitle]);
402
- reactExports.useEffect(() => {
403
- updateWorkspaceTabState(tabId, {
404
- contentKind: isHtmlDocument ? "html" : "code",
405
- documentMode: isHtmlDocument ? viewMode : "source",
406
- isReadOnly: true
407
- });
408
- }, [isHtmlDocument, tabId, updateWorkspaceTabState, viewMode]);
409
- reactExports.useEffect(() => {
410
- const loadContent = async () => {
411
- setLoading(true);
412
- setError(null);
413
- try {
414
- if (!context.resourceId) {
415
- setContent(DEMO_CODE[language] || DEMO_CODE.javascript);
416
- setLoading(false);
417
- return;
418
- }
419
- const { getFileContent } = await __vitePreload(async () => { const { getFileContent } = await import('./index-Nt9hS4ck.js').then(n => n.el);return { getFileContent }},true?__vite__mapDeps([0,1]):void 0);
420
- const text = await getFileContent(context.resourceId);
421
- setContent(text);
422
- } catch (err) {
423
- setError(err instanceof Error ? err.message : t("load_failed"));
424
- } finally {
425
- setLoading(false);
426
- }
427
- };
428
- loadContent();
429
- }, [context.resourceId, language, t]);
430
- const tokenizedLines = reactExports.useMemo(() => tokenize(content, language), [content, language]);
431
- const handleCopy = reactExports.useCallback(async () => {
432
- const ok = await copyToClipboard(content);
433
- if (ok) {
434
- setCopied(true);
435
- setTimeout(() => setCopied(false), 2e3);
436
- }
437
- }, [content]);
438
- const lineCount = tokenizedLines.length;
439
- const applyJump = reactExports.useCallback(
440
- (detail) => {
441
- if (!fileId || detail.fileId !== fileId) return;
442
- const startValue = detail.lineStart ?? detail.line ?? detail.lineEnd;
443
- if (!startValue) return;
444
- const endValue = detail.lineEnd ?? detail.line ?? detail.lineStart ?? startValue;
445
- const maxLine = Math.max(1, lineCount);
446
- const start = Math.min(Math.max(startValue, 1), maxLine);
447
- const end = Math.min(Math.max(endValue, start), maxLine);
448
- setHighlightRange({ start, end });
449
- const lineElement = document.getElementById(`code-line-${start - 1}`);
450
- if (lineElement) {
451
- lineElement.scrollIntoView({ behavior: "smooth", block: "center" });
452
- }
453
- if (highlightTimerRef.current) {
454
- window.clearTimeout(highlightTimerRef.current);
455
- }
456
- highlightTimerRef.current = window.setTimeout(() => {
457
- setHighlightRange(null);
458
- }, 2500);
459
- },
460
- [fileId, lineCount]
461
- );
462
- reactExports.useEffect(() => {
463
- if (!fileId) return;
464
- const processQueue = () => {
465
- const queued = consumeFileJumpEffects(fileId);
466
- queued.forEach((entry) => applyJump(entry.data));
467
- };
468
- processQueue();
469
- const handleJump = (event) => {
470
- const detail = event.detail;
471
- applyJump(detail);
472
- };
473
- const handleQueue = (event) => {
474
- const detail = event.detail;
475
- if (!detail || detail.fileId !== fileId) return;
476
- processQueue();
477
- };
478
- window.addEventListener("ds:file:jump", handleJump);
479
- window.addEventListener("ds:file:queue", handleQueue);
480
- return () => {
481
- window.removeEventListener("ds:file:jump", handleJump);
482
- window.removeEventListener("ds:file:queue", handleQueue);
483
- if (highlightTimerRef.current) {
484
- window.clearTimeout(highlightTimerRef.current);
485
- highlightTimerRef.current = null;
486
- }
487
- };
488
- }, [applyJump, fileId]);
489
- if (loading) {
490
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-3 text-muted-foreground", children: [
491
- /* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "w-8 h-8 animate-spin" }),
492
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: t("loading") })
493
- ] }) });
494
- }
495
- if (error) {
496
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-3 text-destructive", children: [
497
- /* @__PURE__ */ jsxRuntimeExports.jsx(CircleAlert, { className: "w-8 h-8" }),
498
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: error }),
499
- /* @__PURE__ */ jsxRuntimeExports.jsx(
500
- "button",
501
- {
502
- className: "px-4 py-2 text-sm bg-destructive/10 hover:bg-destructive/20 rounded-lg transition-colors",
503
- onClick: () => window.location.reload(),
504
- children: t("retry")
505
- }
506
- )
507
- ] }) });
508
- }
509
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col h-full bg-[#1e1e1e] text-gray-100", children: [
510
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between px-4 py-2 border-b border-[#333] bg-[#252526]", children: [
511
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
512
- /* @__PURE__ */ jsxRuntimeExports.jsx(FileCode, { className: "w-4 h-4 text-gray-400" }),
513
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-gray-300", children: fileName }),
514
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs px-2 py-0.5 rounded bg-[#333] text-gray-400 uppercase", children: isHtmlDocument ? "HTML" : language }),
515
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-500", children: t("line_count", { count: lineCount }) })
516
- ] }),
517
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [
518
- isHtmlDocument ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mr-2 flex items-center rounded-md border border-[#3a3a3a] bg-[#202021] p-0.5", children: [
519
- /* @__PURE__ */ jsxRuntimeExports.jsx(
520
- "button",
521
- {
522
- onClick: () => setViewMode("rendered"),
523
- className: cn(
524
- "rounded px-2 py-1 text-xs transition-colors",
525
- viewMode === "rendered" ? "bg-[#3A4653] text-white" : "text-gray-400 hover:text-gray-200"
526
- ),
527
- title: t("rendered_view"),
528
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1", children: [
529
- /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-3.5 w-3.5" }),
530
- t("rendered_view_short")
531
- ] })
532
- }
533
- ),
534
- /* @__PURE__ */ jsxRuntimeExports.jsx(
535
- "button",
536
- {
537
- onClick: () => setViewMode("source"),
538
- className: cn(
539
- "rounded px-2 py-1 text-xs transition-colors",
540
- viewMode === "source" ? "bg-[#3A4653] text-white" : "text-gray-400 hover:text-gray-200"
541
- ),
542
- title: t("source_view"),
543
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1", children: [
544
- /* @__PURE__ */ jsxRuntimeExports.jsx(Code, { className: "h-3.5 w-3.5" }),
545
- t("source_view_short")
546
- ] })
547
- }
548
- )
549
- ] }) : null,
550
- !isHtmlDocument || viewMode === "source" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
551
- "button",
552
- {
553
- onClick: () => setShowLineNumbers(!showLineNumbers),
554
- className: cn(
555
- "p-2 rounded hover:bg-[#333] transition-colors",
556
- showLineNumbers ? "text-blue-400" : "text-gray-500"
557
- ),
558
- title: t("toggle_line_numbers"),
559
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Hash, { className: "w-4 h-4" })
560
- }
561
- ) : null,
562
- !isHtmlDocument || viewMode === "source" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
563
- "button",
564
- {
565
- onClick: () => setWordWrap(!wordWrap),
566
- className: cn(
567
- "p-2 rounded hover:bg-[#333] transition-colors",
568
- wordWrap ? "text-blue-400" : "text-gray-500"
569
- ),
570
- title: t("toggle_word_wrap"),
571
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(WrapText, { className: "w-4 h-4" })
572
- }
573
- ) : null,
574
- /* @__PURE__ */ jsxRuntimeExports.jsx(
575
- "button",
576
- {
577
- onClick: handleCopy,
578
- className: "p-2 rounded hover:bg-[#333] transition-colors text-gray-400 hover:text-gray-200",
579
- title: t("copy_source"),
580
- children: copied ? /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "w-4 h-4 text-green-400" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Copy, { className: "w-4 h-4" })
581
- }
582
- )
583
- ] })
584
- ] }),
585
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: isHtmlDocument && viewMode === "rendered" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full flex-col bg-[#1c1c1d]", children: [
586
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "border-b border-[#2f2f30] px-4 py-2 text-xs text-gray-400", children: t("html_render_hint") }),
587
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full overflow-hidden rounded-xl border border-white/10 bg-white shadow-[0_24px_60px_-36px_rgba(0,0,0,0.55)]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
588
- "iframe",
589
- {
590
- title: t("html_render_frame_title", { name: fileName }),
591
- srcDoc: content,
592
- sandbox: "",
593
- className: "h-full w-full bg-white"
594
- }
595
- ) }) })
596
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex min-h-full", children: [
597
- showLineNumbers && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 py-4 pr-4 text-right bg-[#1e1e1e] border-r border-[#333] select-none sticky left-0", children: tokenizedLines.map((_, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(
598
- "div",
599
- {
600
- className: "px-4 text-xs leading-6 text-gray-500 font-mono",
601
- children: index + 1
602
- },
603
- index
604
- )) }),
605
- /* @__PURE__ */ jsxRuntimeExports.jsx(
606
- "pre",
607
- {
608
- className: cn(
609
- "flex-1 py-4 px-4 font-mono text-sm leading-6 overflow-x-auto",
610
- wordWrap && "whitespace-pre-wrap break-all"
611
- ),
612
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("code", { children: tokenizedLines.map((tokens, lineIndex) => {
613
- const isCitationLine = highlightRange && lineIndex + 1 >= highlightRange.start && lineIndex + 1 <= highlightRange.end;
614
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
615
- "div",
616
- {
617
- id: `code-line-${lineIndex}`,
618
- className: cn("min-h-[1.5rem]", isCitationLine && "ds-citation-line-highlight"),
619
- children: tokens.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: " " }) : tokens.map((token, tokenIndex) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: TOKEN_COLORS[token.type], children: token.value }, tokenIndex))
620
- },
621
- lineIndex
622
- );
623
- }) })
624
- }
625
- )
626
- ] }) })
627
- ] });
628
- }
629
- const DEMO_CODE = {
630
- javascript: `// DeepScientist - Example JavaScript Code
631
- import { useState, useEffect } from 'react';
632
-
633
- /**
634
- * Custom hook for fetching data
635
- * @param {string} url - The URL to fetch from
636
- * @returns {Object} - The data, loading state, and error
637
- */
638
- export function useFetch(url) {
639
- const [data, setData] = useState(null);
640
- const [loading, setLoading] = useState(true);
641
- const [error, setError] = useState(null);
642
-
643
- useEffect(() => {
644
- const fetchData = async () => {
645
- try {
646
- const response = await fetch(url);
647
- if (!response.ok) {
648
- throw new Error('Network response was not ok');
649
- }
650
- const json = await response.json();
651
- setData(json);
652
- } catch (err) {
653
- setError(err.message);
654
- } finally {
655
- setLoading(false);
656
- }
657
- };
658
-
659
- fetchData();
660
- }, [url]);
661
-
662
- return { data, loading, error };
663
- }
664
-
665
- // Example usage
666
- const API_URL = "https://api.example.com/data";
667
- const { data, loading } = useFetch(API_URL);
668
-
669
- console.log("Data loaded:", data);
670
- `,
671
- typescript: `// DeepScientist - Example TypeScript Code
672
- interface User {
673
- id: string;
674
- name: string;
675
- email: string;
676
- role: 'admin' | 'user' | 'guest';
677
- }
678
-
679
- type AsyncResult<T> = {
680
- data: T | null;
681
- loading: boolean;
682
- error: string | null;
683
- };
684
-
685
- async function fetchUser(userId: string): Promise<User> {
686
- const response = await fetch(\`/api/users/\${userId}\`);
687
- if (!response.ok) {
688
- throw new Error('Failed to fetch user');
689
- }
690
- return response.json();
691
- }
692
-
693
- class UserService {
694
- private cache: Map<string, User> = new Map();
695
-
696
- async getUser(id: string): Promise<User | undefined> {
697
- if (this.cache.has(id)) {
698
- return this.cache.get(id);
699
- }
700
-
701
- const user = await fetchUser(id);
702
- this.cache.set(id, user);
703
- return user;
704
- }
705
- }
706
-
707
- export const userService = new UserService();
708
- `,
709
- python: `# DeepScientist - Example Python Code
710
- from typing import List, Optional, Dict
711
- from dataclasses import dataclass
712
- import asyncio
713
-
714
- @dataclass
715
- class Document:
716
- """Represents a research document."""
717
- id: str
718
- title: str
719
- content: str
720
- tags: List[str]
721
- metadata: Dict[str, any]
722
-
723
- class DocumentProcessor:
724
- """Processes and analyzes documents."""
725
-
726
- def __init__(self, model_name: str = "gpt-4"):
727
- self.model_name = model_name
728
- self._cache: Dict[str, Document] = {}
729
-
730
- async def process(self, doc: Document) -> Dict[str, any]:
731
- """Process a document and extract insights."""
732
- # Simulate async processing
733
- await asyncio.sleep(0.1)
734
-
735
- return {
736
- "word_count": len(doc.content.split()),
737
- "tag_count": len(doc.tags),
738
- "has_metadata": bool(doc.metadata)
739
- }
740
-
741
- def summarize(self, doc: Document) -> str:
742
- """Generate a summary of the document."""
743
- words = doc.content.split()[:100]
744
- return " ".join(words) + "..."
745
-
746
- # Example usage
747
- if __name__ == "__main__":
748
- doc = Document(
749
- id="doc-001",
750
- title="Research Paper",
751
- content="This is the content of the research paper...",
752
- tags=["AI", "Machine Learning"],
753
- metadata={"author": "Dr. Smith"}
754
- )
755
-
756
- processor = DocumentProcessor()
757
- print(f"Processing: {doc.title}")
758
- `,
759
- go: `// DeepScientist - Example Go Code
760
- package main
761
-
762
- import (
763
- "context"
764
- "encoding/json"
765
- "fmt"
766
- "net/http"
767
- "time"
768
- )
769
-
770
- // Document represents a research document
771
- type Document struct {
772
- ID string \`json:"id"\`
773
- Title string \`json:"title"\`
774
- Content string \`json:"content"\`
775
- Tags []string \`json:"tags"\`
776
- Metadata map[string]string \`json:"metadata"\`
777
- }
778
-
779
- // DocumentService handles document operations
780
- type DocumentService struct {
781
- cache map[string]*Document
782
- }
783
-
784
- // NewDocumentService creates a new DocumentService
785
- func NewDocumentService() *DocumentService {
786
- return &DocumentService{
787
- cache: make(map[string]*Document),
788
- }
789
- }
790
-
791
- // GetDocument retrieves a document by ID
792
- func (s *DocumentService) GetDocument(ctx context.Context, id string) (*Document, error) {
793
- if doc, ok := s.cache[id]; ok {
794
- return doc, nil
795
- }
796
- return nil, fmt.Errorf("document not found: %s", id)
797
- }
798
-
799
- func main() {
800
- service := NewDocumentService()
801
-
802
- http.HandleFunc("/documents", func(w http.ResponseWriter, r *http.Request) {
803
- w.Header().Set("Content-Type", "application/json")
804
- json.NewEncoder(w).Encode(map[string]string{
805
- "status": "ok",
806
- "time": time.Now().Format(time.RFC3339),
807
- })
808
- })
809
-
810
- fmt.Println("Server starting on :8080")
811
- http.ListenAndServe(":8080", nil)
812
- }
813
- `,
814
- rust: `// DeepScientist - Example Rust Code
815
- use std::collections::HashMap;
816
- use serde::{Deserialize, Serialize};
817
-
818
- #[derive(Debug, Clone, Serialize, Deserialize)]
819
- pub struct Document {
820
- pub id: String,
821
- pub title: String,
822
- pub content: String,
823
- pub tags: Vec<String>,
824
- pub metadata: HashMap<String, String>,
825
- }
826
-
827
- impl Document {
828
- pub fn new(id: &str, title: &str, content: &str) -> Self {
829
- Document {
830
- id: id.to_string(),
831
- title: title.to_string(),
832
- content: content.to_string(),
833
- tags: Vec::new(),
834
- metadata: HashMap::new(),
835
- }
836
- }
837
-
838
- pub fn word_count(&self) -> usize {
839
- self.content.split_whitespace().count()
840
- }
841
-
842
- pub fn add_tag(&mut self, tag: &str) {
843
- self.tags.push(tag.to_string());
844
- }
845
- }
846
-
847
- pub struct DocumentService {
848
- cache: HashMap<String, Document>,
849
- }
850
-
851
- impl DocumentService {
852
- pub fn new() -> Self {
853
- DocumentService {
854
- cache: HashMap::new(),
855
- }
856
- }
857
-
858
- pub fn get(&self, id: &str) -> Option<&Document> {
859
- self.cache.get(id)
860
- }
861
-
862
- pub fn insert(&mut self, doc: Document) {
863
- self.cache.insert(doc.id.clone(), doc);
864
- }
865
- }
866
-
867
- fn main() {
868
- let mut service = DocumentService::new();
869
- let mut doc = Document::new("doc-001", "Research Paper", "Content here...");
870
- doc.add_tag("AI");
871
-
872
- service.insert(doc);
873
- println!("Document service initialized");
874
- }
875
- `,
876
- json: `{
877
- "name": "@ds/plugin-code-viewer",
878
- "version": "1.0.0",
879
- "description": "Code viewer plugin for DeepScientist",
880
- "author": "DeepScientist Team",
881
- "license": "MIT",
882
- "keywords": ["code", "viewer", "syntax", "highlight"],
883
- "main": "dist/index.js",
884
- "types": "dist/index.d.ts",
885
- "dependencies": {
886
- "react": "^18.0.0",
887
- "lucide-react": "^0.263.0"
888
- },
889
- "devDependencies": {
890
- "typescript": "^5.0.0",
891
- "@types/react": "^18.0.0"
892
- },
893
- "scripts": {
894
- "build": "tsc",
895
- "dev": "tsc --watch",
896
- "test": "jest"
897
- },
898
- "peerDependencies": {
899
- "react": ">=18.0.0"
900
- }
901
- }
902
- `
903
- };
904
-
905
- export { CodeViewerPlugin as default };