@suifei/dsh-ai-team 0.3.53 → 0.3.56

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.
@@ -9,6 +9,7 @@
9
9
  const defineTool = (definition) => definition
10
10
  import { dirname, join } from 'node:path'
11
11
  import { fileURLToPath } from 'node:url'
12
+ import { existsSync, readFileSync, readdirSync } from 'node:fs'
12
13
 
13
14
  export const name = 'skillopt'
14
15
 
@@ -17,7 +18,7 @@ export const name = 'skillopt'
17
18
  const PLUGIN_DIR = dirname(fileURLToPath(import.meta.url)) + '/..'
18
19
 
19
20
  // Exported for the canary test (scripts/canary.mjs).
20
- export { buildArgv, quoteArgv, q, IS_WINDOWS }
21
+ export { buildArgv, quoteArgv, q, IS_WINDOWS, adoptGuardVerdict }
21
22
 
22
23
  // Wait for the tool registry and the shell executor before applying.
23
24
  export const inject = ['tools', 'shell']
@@ -147,8 +148,47 @@ function pick(obj, keys) {
147
148
  return out
148
149
  }
149
150
 
151
+ /**
152
+ * adopt 的 live-change 归因门(一手证据来自引擎 staging 布局:
153
+ * <project>/.skillopt-sleep/staging/<ts>/,.latest 指针 + manifest.json +
154
+ * diagnostics.json(cycle.py 每轮写入 `"backend": cfg.get("backend")`)。
155
+ * 返回 null 表示放行;返回字符串表示拒绝原因(fail-closed)。
156
+ */
157
+ function adoptGuardVerdict(project) {
158
+ const root = join(project, '.skillopt-sleep', 'staging')
159
+ let latest = null
160
+ try {
161
+ latest = readFileSync(join(root, '.latest'), 'utf8').trim() || null
162
+ } catch { /* 无指针:退化为扫描 ts 目录 */ }
163
+ if (!latest) {
164
+ try {
165
+ latest = readdirSync(root)
166
+ .filter((n) => /^\d{8}-\d{6}(-\d+)?$/.test(n) && existsSync(join(root, n, 'manifest.json')))
167
+ .sort()
168
+ .at(-1) ?? null
169
+ } catch {
170
+ return 'refusing to adopt: no staged proposal found (run skillopt_run first)'
171
+ }
172
+ }
173
+ if (!latest) return 'refusing to adopt: no staged proposal found (run skillopt_run first)'
174
+ const stagedDir = join(root, latest)
175
+ let backend = null
176
+ try {
177
+ const diag = JSON.parse(readFileSync(join(stagedDir, 'diagnostics.json'), 'utf8'))
178
+ backend = typeof diag.backend === 'string' ? diag.backend : null
179
+ } catch {
180
+ return `refusing to adopt: cannot attribute this proposal to a validating backend (no readable diagnostics.json in ${stagedDir}). Re-run skillopt_run to stage a fresh, attributable proposal.`
181
+ }
182
+ if (backend === 'mock') {
183
+ return `refusing to adopt: this staged proposal was validated by the MOCK backend — no real model ran and its scores are synthetic. Run skillopt_run with a real backend (config skilloptBackend, or per-call backend) to produce a genuine gate result. Staged dir: ${stagedDir}`
184
+ }
185
+ if (!backend) {
186
+ return `refusing to adopt: diagnostics.json in ${stagedDir} does not name the validating backend. Re-run skillopt_run to stage a fresh, attributable proposal.`
187
+ }
188
+ return null
189
+ }
190
+
150
191
  // Value-domain guard for model-supplied path-like strings.
151
- //
152
192
  // argv-level quoting (quoteArgv) protects the dsh `bash -c` boundary, but the
153
193
  // engine re-interpolates these values into its OWN shell/command strings:
154
194
  // scheduler.py builds `--project "{project}"` inside a crontab line and a
@@ -264,10 +304,12 @@ export function apply(ctx, config = {}) {
264
304
  {
265
305
  name: 'skillopt_adopt',
266
306
  description:
267
- 'Apply the latest staged proposal, backing up existing target files first. This is the live-change boundary.',
307
+ 'Apply the latest staged proposal, backing up existing target files first. This is the live-change boundary. Refuses proposals validated by the mock backend (scores are synthetic, no real model ran).',
268
308
  parameters: {
269
309
  project: { type: 'string', description: 'Project directory' },
270
310
  },
311
+ // live-change boundary 前的一手证据门:拒绝时不发起引擎调用。
312
+ guard: (project) => adoptGuardVerdict(project),
271
313
  build: (a) => buildArgv(config, 'adopt', pick(a, ['project']), [], ['project']),
272
314
  },
273
315
  {
@@ -339,6 +381,12 @@ export function apply(ctx, config = {}) {
339
381
  } catch (err) {
340
382
  return `[skillopt ${t.name}] ${err.message}`
341
383
  }
384
+ // 工具自带的前置门(如 adopt 的 mock 验证归因检查):拒绝时不发起
385
+ // 引擎调用,直接返回拒绝原因。
386
+ if (typeof t.guard === 'function') {
387
+ const verdict = t.guard(a.project ?? config.project ?? process.cwd())
388
+ if (verdict) return `[skillopt ${t.name}] ${verdict}`
389
+ }
342
390
  const argv = t.build(a)
343
391
  // `command` must be the shell-quoted form for the platform executor;
344
392
  // resolve() applies the executor's workdir/output-cap/sandbox defaults.
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "AI Team workbench",
4
+ "description": "Concurrent Projects with owned Tasks, Threads, an inbox and an append-only team ledger."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "文渊阁 AI Team 工作台",
4
+ "description": "并发项目、责任到人的任务、讨论串、收件箱与 append-only 团队账本。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.3.53",
3
+ "version": "0.3.56",
4
4
  "type": "module",
5
5
  "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
6
  "license": "MIT",
@@ -31,13 +31,18 @@
31
31
  ".": "./index.js",
32
32
  "./client": "./client.js",
33
33
  "./lib/*": "./lib/*",
34
+ "./locale/*.json": "./locale/*.json",
34
35
  "./icon": "./icon.svg"
35
36
  },
37
+ "dependencies": {
38
+ "@deepseek-ai/schemastery": "~3.19.0"
39
+ },
36
40
  "files": [
37
41
  "index.js",
38
42
  "client.js",
39
43
  "cordis.patch.yml",
40
44
  "icon.svg",
45
+ "locale/*.json",
41
46
  "lib/**/*.js",
42
47
  "lib/vendor/skillopt/scripts/**/*",
43
48
  "lib/vendor/skillopt/skillopt_sleep/**/*",