[GH-ISSUE #5084] [GUI] 功能需求:加一个"全局规则"编辑框,写入 harness 已在读的 AGENTS.md 并每轮注入(桌面版 / 网页模式 / 命令行共用同一份) #2369

Open
opened 2026-11-04 01:58:45 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @xvcezrqpbxtpzblrt on GitHub (Nov 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5084

English TL;DR: Strata already ships a working global-instruction channel — the harness plugin @deepseek-ai/dsh-agent-instructions is enabled in the app's preset, and it loads AGENTS.md from two user-global roots plus the workspace. What is missing is any GUI entry point: the built-in system prompt is compiled in (apps/host/server/index.mjs:588), and the three in-app "instructions" surfaces (Settings → Tools → "Follow my instructions", Skills, Tasks) are all on-demand/trigger-matched, not always injected. This asks for a "global rules" editor that writes into that same AGENTS.md, shared by desktop, browser mode and CLI. The same request was filed as #738 and closed as not_planned by the automated "issues older than three days" sweep (two users +1'd it), so it is not a design rejection — it is simply unimplemented.

Area

[GUI] 桌面应用 + 网页模式(同一份 Web UI);顺带影响命令行启动的同一 host

想要什么(收窄成一句)

在设置里加一个全局规则编辑框(纯文本,支持"说人话"的约束/特殊要求/禁止事项),保存时写进 harness 已经在读的那份 AGENTS.md,让助手每一轮都带上这些规则;桌面版、--browser 网页模式、命令行启动的 host 共用同一份,不需要三处各写一遍。

现状(全部核到 tag v0.2.10 = ffa80d73,与你安装的产物时间 06:37:26 一致)

1. 我自己守的那套规则在代码里,不是文件

apps/host/server/index.mjs:588 逐字拼出系统提示:

'You are Strata, a helpful assistant. Answer clearly. Do not claim to have read files or performed actions unless their results are included in the conversation.'
+ skillInstructions(appliedSkills)

(代理路径用 SYSTEM_PROMPT,见 :655、:685)。用户改不了,也没有任何文件承载它。

2. 全局规则的文件通道已经存在,而且 app 已经启用

  • Strata 的 harness 预设里带着这个插件:apps/host/server/agent/preset.mjs:27(列表含 'agent-instructions'),:77 配置 { id: 'agent-instructions', name: '@deepseek-ai/dsh-agent-instructions', config: { maxBytes: 65536 } } → 上限 64 KB
  • 找哪些文件:已安装 harness/node_modules/@deepseek-ai/dsh-agent-instructions/lib/index.js:17
    const DEFAULT_INSTRUCTION_FILE_CANDIDATES = ["AGENTS.md", "CLAUDE.md"];
    :168 const USER_GLOBAL_FILE = "AGENTS.md";,:161 USER_GLOBAL_DIRECTORIES = [USER_GLOBAL_DIRECTORY, AGENTS_GLOBAL_DIRECTORY](顺序固定),项目级从 cwd 沿祖先目录往上找(:674)
  • 两个全局根的实际路径来自 @deepseek-ai/dsh-home-paths/lib/index.js:
    • :11 DSH_HOME_DIR_NAME = ".dsh",:15 可用环境变量 DSH_HOME 覆盖;Strata 在 apps/host/server/agent/harness-runtime.mjs:82 就设了 DSH_HOME: this.home → 本机实际是 C:\Users\123\.strata\data\agent\home\
    • :17 AGENTS_HOME_DIR_NAME = ".agents",:21 可用 DSH_AGENTS_HOME 覆盖 → C:\Users\123\.agents\
  • 于是可写的三个位置:
    1. C:\Users\123\.strata\data\agent\home\AGENTS.md(Strata 的 agent 全局档)
    2. C:\Users\123\.agents\AGENTS.md(各家 AI 工具共用的全局档)
    3. 工作区根,例如 C:\Users\123\Documents\Strata\Workspace\AGENTS.md(项目级)
  • 本机实测:以上路径目前全都不存在(Test-Path 四条全 False;…\data\agent\home\ 下只有 attachments / profiles / sessions / storages / .credentials.yaml)→ 现在没有任何用户规则被注入,用户想让助手守规矩只能在对话里临时说,换会话就没了

3. 界面里已有的三个"指令"入口,都不是"每轮注入"

入口 位置 上限 生效方式
设置 → 工具 → 添加工具 → "Follow my instructions" apps/host/src/components/SettingsTools.tsx:56;apps/host/server/agent/tools-settings.mjs:19,56-58 20,000 字 存成一个 MCP 工具 mcp__strata-instructions__<name>,必须助手主动调用才读得到(界面文案见 apps/host/server/agent/events.mjs:113,120:Reading your instructions)
技能 Skills apps/host/server/index.mjs:1637-1647(POST /api/skills,写 SKILL.md) 40,000 字 靠触发词 / 工作区匹配命中(apps/host/server/skill-selection.mjs)
任务 Tasks apps/host/server/tasks.mjs:13 1–12,000 字 定时任务自带 prompt,不影响日常聊天

第一行是最容易被误会的:名字写着 "Follow my instructions",用户写完以为它是全局规则,实际它躺在一个工具里,助手不点开门就永远看不见。触发词命中也不稳定。

4. 这条需求不是新提的

  • #738 "Configurable system prompt in the web GUI" —— state_reason = not_planned,2026-10-13 关闭,关闭理由是维护者的自动清扫("closing issues older than three days"),评论区有两位用户 +1(sinand99、avkwok)。不是设计否决,是没做
  • #909(closed,AGENTS.md 的文档补充)

为什么"按需读取"不能代替全局规则

写规则的人要的是"每次都算数"(称呼、语言、格式、禁止事项、安全约束)。走工具/触发词的通道有三个问题:①助手要主动调用,不调用就不生效;②触发词没命中就不生效;③界面上没有任何地方显示"这一轮到底注入了什么",用户无法验证。第三点最伤信任。

建议设计(5 条,尽量复用已有机制,不新造一套)

  1. 入口:设置 → 新增"全局规则"分区;一个多行文本框 + "保存"。保存动作 = 写入 C:\Users\<user>\.strata\data\agent\home\AGENTS.md(即 DSH_HOME 下那份),不新建第二条通道;顺带提供"打开所在文件夹"。
  2. 作用域与优先级:三层可选 —— 全局(上面那份)/ 当前工作区(工作区根 AGENTS.md)/ 仅本会话(临时,不落盘)。界面按 harness 已有的顺序讲清 user-global → agents-global → 项目级谁赢(代码里 USER_GLOBAL_DIRECTORIES 就是这个顺序,instructionCandidateGroup 还把前两者当同一候选组去重,index.js:161,197-199)。
  3. 可见性:聊天里显示"本轮注入了哪几份规则 / 各多少字",点开能看内容。用户能验证,规则才可信。
  4. 上限提示:maxBytes: 65536 目前会静默截断(truncateUtf8,index.js:131-134),编辑器要在保存时给出字数与剩余,别让人写完发现被切了。
  5. 把 GUI 的 "instructions 工具" 与全局规则的区别写进界面文案(现在零说明):前者=助手按需读,后者=每轮都带。顺手改掉 "Follow my instructions" 这个容易误会的名字。

验证状态(按 CONTRIBUTING 区分)

  • passed:插件与配置已核(preset.mjs:27,77);文件发现逻辑与两个全局根已核(dsh-agent-instructions/lib/index.js:17,161,168,175-176;dsh-home-paths/lib/index.js:11,15,17,21);Strata 设 DSH_HOME 已核(harness-runtime.mjs:82);本机四个候选路径不存在已实测;GUI 三个入口的上限与生效方式已核到源码与界面文案;#738 的关闭方式已核
  • not run:未做端到端注入验证(新建一份 AGENTS.md → 发一条消息 → 在请求日志里确认 system 段带上它)。这条是验收标准,应由实现者/维护者跑;我这边需要重启 agent 才能注入,会打断当前会话,所以没做
  • failed:无

影响面

桌面版(主窗口)、--browser / STRATA_UI=browser 的网页模式、命令行起的同一个 host —— 三者共用同一份文件,这条需求的价值主要就在这里:写一次,三处生效。

相关已有讨论(先查过仓库)

  • #738 [closed, not_planned] Configurable system prompt in the web GUI(同一诉求,自动清扫关闭,2 人 +1)
  • #909 [closed] Proposal (docs only): a short "contributing a change or report" section for AGENTS.md
  • 搜索关键词:AGENTS.md、global instructions、custom instructions、system prompt、全局规则、global rules user;除 #738 外没有覆盖"GUI 编辑全局规则 → 写入 AGENTS.md → 每轮注入"的开放 issue

本报告未包含

  • 未包含:端到端注入验证(见上"not run");macOS / Linux 下两个全局根的实际路径(本机只测 Windows);多语言(中文规则)在 64 KB 截断下的字节计数边界(truncateUtf8 只读了源码,未实测);把规则注入后对引擎提示缓存 / token 计量的影响(需要实测);与 #4981 那条里"编造路径"现象的关系(未验证,不作为本条依据)
Originally created by @xvcezrqpbxtpzblrt on GitHub (Nov 3, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5084 **English TL;DR**: Strata already ships a working global-instruction channel — the harness plugin `@deepseek-ai/dsh-agent-instructions` is enabled in the app's preset, and it loads `AGENTS.md` from two user-global roots plus the workspace. What is missing is any **GUI entry point**: the built-in system prompt is compiled in (`apps/host/server/index.mjs:588`), and the three in-app "instructions" surfaces (Settings → Tools → "Follow my instructions", Skills, Tasks) are all **on-demand/trigger-matched**, not always injected. This asks for a "global rules" editor that writes into that same `AGENTS.md`, shared by desktop, browser mode and CLI. The same request was filed as #738 and closed as `not_planned` by the automated "issues older than three days" sweep (two users `+1`'d it), so it is not a design rejection — it is simply unimplemented. ## Area [GUI] 桌面应用 + 网页模式(同一份 Web UI);顺带影响命令行启动的同一 host ## 想要什么(收窄成一句) 在设置里加一个**全局规则**编辑框(纯文本,支持"说人话"的约束/特殊要求/禁止事项),保存时**写进 harness 已经在读的那份 `AGENTS.md`**,让助手**每一轮都带上**这些规则;桌面版、`--browser` 网页模式、命令行启动的 host 共用同一份,不需要三处各写一遍。 ## 现状(全部核到 **tag v0.2.10 = ffa80d73**,与你安装的产物时间 06:37:26 一致) ### 1. 我自己守的那套规则在代码里,不是文件 `apps/host/server/index.mjs:588` 逐字拼出系统提示: ``` 'You are Strata, a helpful assistant. Answer clearly. Do not claim to have read files or performed actions unless their results are included in the conversation.' + skillInstructions(appliedSkills) ``` (代理路径用 `SYSTEM_PROMPT`,见 `:655`、`:685`)。用户改不了,也没有任何文件承载它。 ### 2. 全局规则的文件通道**已经存在**,而且 app 已经启用 - Strata 的 harness 预设里带着这个插件:`apps/host/server/agent/preset.mjs:27`(列表含 `'agent-instructions'`),`:77` 配置 `{ id: 'agent-instructions', name: '@deepseek-ai/dsh-agent-instructions', config: { maxBytes: 65536 } }` → **上限 64 KB** - 找哪些文件:已安装 `harness/node_modules/@deepseek-ai/dsh-agent-instructions/lib/index.js:17` `const DEFAULT_INSTRUCTION_FILE_CANDIDATES = ["AGENTS.md", "CLAUDE.md"];` `:168` `const USER_GLOBAL_FILE = "AGENTS.md";`,`:161` `USER_GLOBAL_DIRECTORIES = [USER_GLOBAL_DIRECTORY, AGENTS_GLOBAL_DIRECTORY]`(顺序固定),项目级从 cwd 沿祖先目录往上找(`:674`) - 两个全局根的实际路径来自 `@deepseek-ai/dsh-home-paths/lib/index.js`: - `:11` `DSH_HOME_DIR_NAME = ".dsh"`,`:15` 可用环境变量 `DSH_HOME` 覆盖;Strata 在 `apps/host/server/agent/harness-runtime.mjs:82` 就设了 `DSH_HOME: this.home` → 本机实际是 **`C:\Users\123\.strata\data\agent\home\`** - `:17` `AGENTS_HOME_DIR_NAME = ".agents"`,`:21` 可用 `DSH_AGENTS_HOME` 覆盖 → **`C:\Users\123\.agents\`** - 于是可写的三个位置: 1. `C:\Users\123\.strata\data\agent\home\AGENTS.md`(Strata 的 agent 全局档) 2. `C:\Users\123\.agents\AGENTS.md`(各家 AI 工具共用的全局档) 3. 工作区根,例如 `C:\Users\123\Documents\Strata\Workspace\AGENTS.md`(项目级) - **本机实测:以上路径目前全都不存在**(`Test-Path` 四条全 False;`…\data\agent\home\` 下只有 `attachments / profiles / sessions / storages / .credentials.yaml`)→ 现在没有任何用户规则被注入,用户想让助手守规矩只能在对话里临时说,换会话就没了 ### 3. 界面里已有的三个"指令"入口,都不是"每轮注入" | 入口 | 位置 | 上限 | 生效方式 | |---|---|---|---| | 设置 → 工具 → 添加工具 → **"Follow my instructions"** | `apps/host/src/components/SettingsTools.tsx:56`;`apps/host/server/agent/tools-settings.mjs:19,56-58` | 20,000 字 | 存成一个 MCP 工具 `mcp__strata-instructions__<name>`,**必须助手主动调用才读得到**(界面文案见 `apps/host/server/agent/events.mjs:113,120`:`Reading your instructions`) | | 技能 Skills | `apps/host/server/index.mjs:1637-1647`(`POST /api/skills`,写 `SKILL.md`) | 40,000 字 | 靠触发词 / 工作区匹配命中(`apps/host/server/skill-selection.mjs`) | | 任务 Tasks | `apps/host/server/tasks.mjs:13` | 1–12,000 字 | 定时任务自带 prompt,不影响日常聊天 | 第一行是最容易被误会的:名字写着 "Follow my instructions",用户写完以为它是全局规则,实际它躺在一个工具里,助手不点开门就永远看不见。触发词命中也不稳定。 ### 4. 这条需求不是新提的 - **#738 "Configurable system prompt in the web GUI"** —— `state_reason = not_planned`,2026-10-13 关闭,关闭理由是维护者的自动清扫("closing issues older than three days"),评论区有两位用户 `+1`(`sinand99`、`avkwok`)。**不是设计否决,是没做** - #909(closed,AGENTS.md 的文档补充) ## 为什么"按需读取"不能代替全局规则 写规则的人要的是"每次都算数"(称呼、语言、格式、禁止事项、安全约束)。走工具/触发词的通道有三个问题:①助手要主动调用,不调用就不生效;②触发词没命中就不生效;③界面上没有任何地方显示"这一轮到底注入了什么",用户无法验证。第三点最伤信任。 ## 建议设计(5 条,尽量复用已有机制,不新造一套) 1. **入口**:设置 → 新增"全局规则"分区;一个多行文本框 + "保存"。保存动作 = 写入 `C:\Users\<user>\.strata\data\agent\home\AGENTS.md`(即 `DSH_HOME` 下那份),**不新建第二条通道**;顺带提供"打开所在文件夹"。 2. **作用域与优先级**:三层可选 —— 全局(上面那份)/ 当前工作区(工作区根 `AGENTS.md`)/ 仅本会话(临时,不落盘)。界面按 harness 已有的顺序讲清 `user-global` → `agents-global` → 项目级谁赢(代码里 `USER_GLOBAL_DIRECTORIES` 就是这个顺序,`instructionCandidateGroup` 还把前两者当同一候选组去重,`index.js:161,197-199`)。 3. **可见性**:聊天里显示"本轮注入了哪几份规则 / 各多少字",点开能看内容。用户能验证,规则才可信。 4. **上限提示**:`maxBytes: 65536` 目前会**静默截断**(`truncateUtf8`,`index.js:131-134`),编辑器要在保存时给出字数与剩余,别让人写完发现被切了。 5. **把 GUI 的 "instructions 工具" 与全局规则的区别写进界面文案**(现在零说明):前者=助手按需读,后者=每轮都带。顺手改掉 "Follow my instructions" 这个容易误会的名字。 ## 验证状态(按 CONTRIBUTING 区分) - **passed**:插件与配置已核(`preset.mjs:27,77`);文件发现逻辑与两个全局根已核(`dsh-agent-instructions/lib/index.js:17,161,168,175-176`;`dsh-home-paths/lib/index.js:11,15,17,21`);Strata 设 `DSH_HOME` 已核(`harness-runtime.mjs:82`);本机四个候选路径不存在已实测;GUI 三个入口的上限与生效方式已核到源码与界面文案;#738 的关闭方式已核 - **not run**:未做端到端注入验证(新建一份 `AGENTS.md` → 发一条消息 → 在请求日志里确认 system 段带上它)。这条是验收标准,应由实现者/维护者跑;我这边需要重启 agent 才能注入,会打断当前会话,所以没做 - **failed**:无 ## 影响面 桌面版(主窗口)、`--browser` / `STRATA_UI=browser` 的网页模式、命令行起的同一个 host —— 三者共用同一份文件,这条需求的价值主要就在这里:写一次,三处生效。 ## 相关已有讨论(先查过仓库) - #738 [closed, not_planned] Configurable system prompt in the web GUI(同一诉求,自动清扫关闭,2 人 +1) - #909 [closed] Proposal (docs only): a short "contributing a change or report" section for AGENTS.md - 搜索关键词:`AGENTS.md`、`global instructions`、`custom instructions`、`system prompt`、`全局规则`、`global rules user`;除 #738 外没有覆盖"GUI 编辑全局规则 → 写入 AGENTS.md → 每轮注入"的开放 issue ## 本报告未包含 - 未包含:端到端注入验证(见上"not run");macOS / Linux 下两个全局根的实际路径(本机只测 Windows);多语言(中文规则)在 64 KB 截断下的字节计数边界(`truncateUtf8` 只读了源码,未实测);把规则注入后对**引擎**提示缓存 / token 计量的影响(需要实测);与 #4981 那条里"编造路径"现象的关系(未验证,不作为本条依据)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2369
No description provided.