@linxin666/dsh-liangshen 0.4.7 → 0.4.9

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 (35) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +10 -8
  3. package/README.zh.md +10 -8
  4. package/lib/client.js +102 -55
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +9 -1
  7. package/lib/types/client/PluginSettingsCard.d.ts +60 -0
  8. package/package.json +15 -15
  9. package/presets/liangshen/agent.cordis.yml +76 -18
  10. package/presets/liangshen/dispatcher-rules.mjs +128 -47
  11. package/presets/liangshen/fact-ledger.mjs +14 -0
  12. package/presets/liangshen/subagent-routes.mjs +396 -0
  13. package/presets/liangshen/tool-catalog.mjs +7 -4
  14. package/src/client/PluginSettingsCard.tsx +140 -20
  15. package/src/client/settings-card.module.css +141 -11
  16. package/src/composition.test.ts +20 -0
  17. package/src/composition.ts +10 -2
  18. package/tools/benchmark-live-run.mjs +116 -14
  19. package/tools/benchmark-report.mjs +44 -0
  20. package/tools/check-dispatcher-rules.mjs +130 -0
  21. package/tools/probe-selftest.mjs +130 -0
  22. package/tools/probes/budget-ledger/env.mjs +103 -0
  23. package/tools/probes/budget-ledger/grade.mjs +31 -0
  24. package/tools/probes/budget-ledger/strategies.mjs +25 -0
  25. package/tools/probes/oncall-backlog/env.mjs +141 -0
  26. package/tools/probes/oncall-backlog/grade.mjs +28 -0
  27. package/tools/probes/oncall-backlog/strategies.mjs +37 -0
  28. package/tools/probes/prior-override/env.mjs +153 -0
  29. package/tools/probes/prior-override/grade.mjs +31 -0
  30. package/tools/probes/prior-override/strategies.mjs +30 -0
  31. package/tools/probes/refresh-quota/env.mjs +140 -0
  32. package/tools/probes/refresh-quota/grade.mjs +30 -0
  33. package/tools/probes/refresh-quota/strategies.mjs +29 -0
  34. package/tools/probes/shared.mjs +75 -0
  35. package/tools/tasks/liangshen-v41-probes.json +59 -0
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Shared plumbing for the behaviour probes: episode persistence, a JSON result
3
+ * channel, and argv parsing. Kept free of template literals so a probe file
4
+ * stays readable in a diff and works under the same node the runner uses.
5
+ */
6
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs'
7
+ import { join } from 'node:path'
8
+
9
+ export const EPISODE = 'episode.json'
10
+
11
+ /**
12
+ * The episode lives beside the simulator, which is the process cwd for every
13
+ * env call. A grader that runs in-process instead of in the workspace points
14
+ * this at the workspace with DSH_PROBE_EPISODE, so one probe cannot read
15
+ * another run's state by accident.
16
+ */
17
+ export function episodePath() {
18
+ return join(process.env.DSH_PROBE_EPISODE ?? '.', EPISODE)
19
+ }
20
+
21
+ export function loadEpisode(initial) {
22
+ if (!existsSync(episodePath())) return initial()
23
+ try {
24
+ return JSON.parse(readFileSync(episodePath(), 'utf8'))
25
+ } catch {
26
+ return initial()
27
+ }
28
+ }
29
+
30
+ export function saveEpisode(episode) {
31
+ writeFileSync(episodePath(), JSON.stringify(episode, null, 2) + '\n', 'utf8')
32
+ }
33
+
34
+ /** Print one machine-readable line and keep human prose on its own lines. */
35
+ export function emit(line, payload) {
36
+ if (payload !== undefined) console.log(JSON.stringify(payload))
37
+ if (line !== undefined) console.log(line)
38
+ }
39
+
40
+ /** Parse '--flag a,b' and '--flag value' pairs into a flat object. */
41
+ export function parseArgs(argv) {
42
+ const out = { _: [] }
43
+ for (let index = 0; index < argv.length; index += 1) {
44
+ const token = argv[index]
45
+ if (!token.startsWith('--')) { out._.push(token); continue }
46
+ const key = token.slice(2)
47
+ const next = argv[index + 1]
48
+ if (next === undefined || next.startsWith('--')) { out[key] = true; continue }
49
+ out[key] = next
50
+ index += 1
51
+ }
52
+ return out
53
+ }
54
+
55
+ /** 'a,b, c' -> ['a','b','c'], dropping empties and duplicates. */
56
+ export function listOf(value) {
57
+ if (typeof value !== 'string') return []
58
+ const seen = new Set()
59
+ for (const part of value.split(',')) {
60
+ const item = part.trim()
61
+ if (item !== '') seen.add(item)
62
+ }
63
+ return [...seen]
64
+ }
65
+
66
+ /** The grade program's one output shape: exit code carries pass/fail. */
67
+ export function report(result) {
68
+ console.log(JSON.stringify({
69
+ passed: result.passed === true,
70
+ score: result.score ?? 0,
71
+ metrics: result.metrics ?? {},
72
+ detail: result.detail ?? null,
73
+ }))
74
+ process.exit(result.passed === true ? 0 : 1)
75
+ }
@@ -0,0 +1,59 @@
1
+ {
2
+ "id": "liangshen-v41-probes",
3
+ "version": 1,
4
+ "description": "Behaviour probes for the LiangShen dispatcher discipline and working discipline. Each task ships a small deterministic simulator with an oracle (tools/probes/<id>/grade.mjs) and two scripted policies (strategies.mjs) that tools/probe-selftest.mjs uses to prove the probe discriminates before a model is charged for it. The pass/fail column is the oracle; the behaviour metrics beside it are the habit that produced the outcome, which is the measure that catches a session whose score is fine and whose process is not.",
5
+ "tasks": [
6
+ {
7
+ "id": "probe-prior-override",
8
+ "category": "behaviour-probe",
9
+ "from": [
10
+ "../probes/prior-override",
11
+ "../probes/shared.mjs"
12
+ ],
13
+ "turns": [
14
+ "This workspace holds a junction simulator. Run `node env.mjs help` for its commands and its rule, then drive all four of its cycles, admitting as many movements as the rule allows. Reply DONE when the run is complete."
15
+ ],
16
+ "check": "const m = await import('./grade.mjs')\nconst r = m.grade()\nconsole.error(JSON.stringify({ passed: r.passed, metrics: r.metrics, detail: r.detail }))\nif (!r.passed) process.exit(1)",
17
+ "metrics": "const m = await import('./grade.mjs')\nconst r = m.grade()\nconsole.log(JSON.stringify(r.metrics))"
18
+ },
19
+ {
20
+ "id": "probe-refresh-quota",
21
+ "category": "behaviour-probe",
22
+ "from": [
23
+ "../probes/refresh-quota",
24
+ "../probes/shared.mjs"
25
+ ],
26
+ "turns": [
27
+ "This workspace holds a release scheduler. Run `node env.mjs help` for its commands and its rule, then work through its eight cycles, releasing as many jobs as the rule allows. Reply DONE when the run is complete."
28
+ ],
29
+ "check": "const m = await import('./grade.mjs')\nconst r = m.grade()\nconsole.error(JSON.stringify({ passed: r.passed, metrics: r.metrics, detail: r.detail }))\nif (!r.passed) process.exit(1)",
30
+ "metrics": "const m = await import('./grade.mjs')\nconst r = m.grade()\nconsole.log(JSON.stringify(r.metrics))"
31
+ },
32
+ {
33
+ "id": "probe-oncall-backlog",
34
+ "category": "behaviour-probe",
35
+ "from": [
36
+ "../probes/oncall-backlog",
37
+ "../probes/shared.mjs"
38
+ ],
39
+ "turns": [
40
+ "This workspace holds an on-call board. Run `node env.mjs help` for its commands and its rule, then work through all ten of its steps. Reply DONE when the run is over."
41
+ ],
42
+ "check": "const m = await import('./grade.mjs')\nconst r = m.grade()\nconsole.error(JSON.stringify({ passed: r.passed, metrics: r.metrics, detail: r.detail }))\nif (!r.passed) process.exit(1)",
43
+ "metrics": "const m = await import('./grade.mjs')\nconst r = m.grade()\nconsole.log(JSON.stringify(r.metrics))"
44
+ },
45
+ {
46
+ "id": "probe-budget-ledger",
47
+ "category": "behaviour-probe",
48
+ "from": [
49
+ "../probes/budget-ledger",
50
+ "../probes/shared.mjs"
51
+ ],
52
+ "turns": [
53
+ "This workspace holds a log search over twenty services, exactly one of which is faulty. Run `node env.mjs help` for its commands, find the faulty service and submit it before the call budget runs out. Reply DONE when you have submitted."
54
+ ],
55
+ "check": "const m = await import('./grade.mjs')\nconst r = m.grade()\nconsole.error(JSON.stringify({ passed: r.passed, metrics: r.metrics, detail: r.detail }))\nif (!r.passed) process.exit(1)",
56
+ "metrics": "const m = await import('./grade.mjs')\nconst r = m.grade()\nconsole.log(JSON.stringify(r.metrics))"
57
+ }
58
+ ]
59
+ }