dsh-custom-mode 1.13.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/postures.mjs ADDED
@@ -0,0 +1,74 @@
1
+ /**
2
+ * 新建助手时的姿态。
3
+ *
4
+ * 姿态不是第五套基础模式。每一条的 `base` 必须是官方四套(或它们的并集 `all`)之一,
5
+ * 建完之后用户仍用设置页上的基础模式药丸改底子。`hands: 'shipped'` 表示开关一字不改,
6
+ * 和今天「只填名字就新建」相同。`hands: 'allow'` 是一张允许名单:出厂是开、又不在名单里的行
7
+ * 会被显式关掉。上游以后新增的行因此默认关闭,而不是悄悄出现在「聊天」里。
8
+ *
9
+ * 提示词草稿放在 `preset/postures/<id>.<zh|en>.md`,不写进代码,也从不复制进用户的预设目录。
10
+ * 只有用户点了新建,才会把对应草稿写进那一个新助手的 `prompt.md`。`develop` 不读这些文件,
11
+ * 它用的就是 `preset/prompt.md`,这样老的创建路径字节级不变。
12
+ *
13
+ * 能进这张表的姿态,提示词里要有一条可以指给人看的约定,开关要是这条约定的直接后果。
14
+ * 占位句(「把提示词写在这里」)不够格:它会占一个助手,也会占模型的上下文。
15
+ */
16
+ import { readFileSync } from 'node:fs'
17
+ import { dirname, join } from 'node:path'
18
+ import { fileURLToPath } from 'node:url'
19
+
20
+ const DIR = join(dirname(fileURLToPath(import.meta.url)), 'preset', 'postures')
21
+
22
+ /** 所有姿态都留下的行:身份(否则提示词不生效)和会话内改提示词的工具。 */
23
+ export const POSTURE_ALWAYS = ['persona', 'custom-prompt-tool']
24
+
25
+ export const POSTURES = [
26
+ { id: 'develop', base: 'standard', hands: 'shipped', allow: [] },
27
+ {
28
+ id: 'write',
29
+ base: 'standard',
30
+ hands: 'allow',
31
+ allow: ['persona', 'agent-instructions', 'tool-fs', 'tool-fs-search', 'tool-todo', 'time-context', 'custom-prompt-tool'],
32
+ },
33
+ {
34
+ id: 'chat',
35
+ base: 'standard',
36
+ hands: 'allow',
37
+ allow: ['persona', 'tool-ask-user', 'time-context', 'custom-prompt-tool'],
38
+ },
39
+ ]
40
+
41
+ /** @param {string} id */
42
+ export function postureById(id) {
43
+ return POSTURES.find((item) => item.id === id) ?? null
44
+ }
45
+
46
+ /** 列表接口交给页面的公开形状:没有允许名单,页面不必理解开关。 */
47
+ export function publicPostures() {
48
+ return POSTURES.map((item) => ({ id: item.id, base: item.base }))
49
+ }
50
+
51
+ /**
52
+ * @param {unknown} value - 请求里的 locale。只有明确的中文走中文草稿,其余走英文。
53
+ * @returns {'zh' | 'en'}
54
+ */
55
+ export function postureLocale(value) {
56
+ return typeof value === 'string' && value.toLowerCase().startsWith('zh') ? 'zh' : 'en'
57
+ }
58
+
59
+ /**
60
+ * 某个姿态的起步提示词。`develop` 返回 null,调用方继续用出厂 `prompt.md`。
61
+ *
62
+ * @param {string} id
63
+ * @param {'zh' | 'en'} locale
64
+ * @returns {string | null}
65
+ */
66
+ export function posturePrompt(id, locale) {
67
+ if (id === 'develop') return null
68
+ const lang = locale === 'zh' ? 'zh' : 'en'
69
+ try {
70
+ return readFileSync(join(DIR, id + '.' + lang + '.md'), 'utf8')
71
+ } catch {
72
+ return readFileSync(join(DIR, id + '.' + (lang === 'zh' ? 'en' : 'zh') + '.md'), 'utf8')
73
+ }
74
+ }
@@ -0,0 +1,7 @@
1
+ You are the user's conversation partner. The current model is {{model}}.
2
+
3
+ Match the user's length. If they wrote one sentence, do not answer with an essay.
4
+
5
+ Do not open by introducing yourself, do not list what you can do, and do not turn a remark into a plan. When you need to clarify, ask one question.
6
+
7
+ You cannot touch files, and you have no terminal. Do not claim that you edited a file or ran a command.
@@ -0,0 +1,7 @@
1
+ 你是用户的对话对象。当前模型是 {{model}}。
2
+
3
+ 回复长度跟着用户。用户写一句,就不要回一篇。
4
+
5
+ 不要开场自我介绍,不要列出你能做的事,不要把一句闲聊展开成方案。需要澄清时只问一个问题。
6
+
7
+ 你碰不到文件,也没有终端。不要声称你改过文件或跑过命令。
@@ -0,0 +1,7 @@
1
+ You help the user write. The current model is {{model}}. The working directory is {{cwd}}.
2
+
3
+ Change only files the user names. Before writing, read the voice, style and facts already established there. Do not add anything that conflicts with them.
4
+
5
+ Mark a missing fact as unknown. Do not invent it. Do not add a character the user did not ask for. Do not finish the ending. Do not rewrite a passage the user did not point at.
6
+
7
+ You have no terminal. Do not suggest finishing the writing with a command.
@@ -0,0 +1,7 @@
1
+ 你协助用户写作。当前模型是 {{model}}。工作目录是 {{cwd}}。
2
+
3
+ 只改用户点名的文件。动笔前先读其中已经成立的人称、文风和事实;与之冲突的内容不要写进去。
4
+
5
+ 缺的设定标成未知,不要补完。不要新增用户没要求的角色。不要替用户写完结局。不要改写用户没指出的段落。
6
+
7
+ 你没有终端。不要提议用命令来完成写作。