dsh-dev-plan-presets 0.3.0 → 0.4.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/settings.js CHANGED
@@ -20,6 +20,13 @@
20
20
  /** 模型守门模式。off = 完全不管;audit = 只记录;pin = 钉住并可按设置打断。 */
21
21
  export const GUARD_MODES = Object.freeze(['off', 'audit', 'pin'])
22
22
 
23
+ /** 主窗工具权限档位。none = 纯规划派工;readonly = 定点只读核验;ask-edit = 经用户同意后允许局部微改(永不挂 Shell)。 */
24
+ export const MAIN_TOOL_MODES = Object.freeze(['none', 'readonly', 'ask-edit'])
25
+
26
+ /** 主窗连续实操步数软提醒阈值范围(仅在 mainToolMode !== 'none' 时生效)。 */
27
+ export const MIN_MAIN_STEP_WARN_THRESHOLD = 2
28
+ export const MAX_MAIN_STEP_WARN_THRESHOLD = 30
29
+
23
30
  /** 默认路由:与 0.2.0 及旧 dsh-subagent-model-pin 保持一致。 */
24
31
  export const DEFAULT_CHILD_PROVIDER = 'dsh-opencode-go'
25
32
  export const DEFAULT_CHILD_MODEL = 'deepseek-v4.1-flash'
@@ -50,6 +57,10 @@ export const DEFAULT_SETTINGS = Object.freeze({
50
57
  * 主会话始终不守门。
51
58
  */
52
59
  guardAllSubagents: false,
60
+ /** 主窗工具权限:ask-edit(默认,小范围只读+经同意局部微改,永不挂 Shell)/ readonly / none。 */
61
+ mainToolMode: 'ask-edit',
62
+ /** mainToolMode !== 'none' 时,主会话单轮连续步数超过该阈值后温和提醒转交子代理。 */
63
+ mainStepWarnThreshold: 6,
53
64
  })
54
65
 
55
66
  const isPlainObject = (value) =>
@@ -90,6 +101,15 @@ export function normalizeSettings(raw) {
90
101
  input.guardAllSubagents === undefined
91
102
  ? DEFAULT_SETTINGS.guardAllSubagents
92
103
  : input.guardAllSubagents === true,
104
+ mainToolMode: MAIN_TOOL_MODES.includes(input.mainToolMode)
105
+ ? input.mainToolMode
106
+ : DEFAULT_SETTINGS.mainToolMode,
107
+ mainStepWarnThreshold:
108
+ Number.isInteger(input.mainStepWarnThreshold) &&
109
+ input.mainStepWarnThreshold >= MIN_MAIN_STEP_WARN_THRESHOLD &&
110
+ input.mainStepWarnThreshold <= MAX_MAIN_STEP_WARN_THRESHOLD
111
+ ? input.mainStepWarnThreshold
112
+ : DEFAULT_SETTINGS.mainStepWarnThreshold,
93
113
  }
94
114
  }
95
115
 
@@ -127,6 +147,20 @@ export function validateSettings(raw) {
127
147
  issue(field, 'must be a boolean')
128
148
  }
129
149
  }
150
+ if (input.mainToolMode !== undefined && !MAIN_TOOL_MODES.includes(input.mainToolMode)) {
151
+ issue('mainToolMode', `must be one of ${MAIN_TOOL_MODES.join(', ')}`)
152
+ }
153
+ if (
154
+ input.mainStepWarnThreshold !== undefined &&
155
+ (!Number.isInteger(input.mainStepWarnThreshold) ||
156
+ input.mainStepWarnThreshold < MIN_MAIN_STEP_WARN_THRESHOLD ||
157
+ input.mainStepWarnThreshold > MAX_MAIN_STEP_WARN_THRESHOLD)
158
+ ) {
159
+ issue(
160
+ 'mainStepWarnThreshold',
161
+ `must be an integer between ${MIN_MAIN_STEP_WARN_THRESHOLD} and ${MAX_MAIN_STEP_WARN_THRESHOLD}`,
162
+ )
163
+ }
130
164
  if (issues.length > 0) return { issues }
131
165
  return { value: normalizeSettings(input) }
132
166
  }