dsh-cabinet-mode 0.2.0 → 0.2.2

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.
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cabinet-mode",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Cabinet Mode (内阁模式) for DeepSeek Harness: a declarative DSH bundle that adds a dual-identity Lead/teammate agent preset for the Great Ming Research Bureau cabinet team.",
5
5
  "license": "MIT",
6
6
  "icon": "./icon.svg",
@@ -72,5 +72,8 @@
72
72
  "market:check": "node scripts/market-index.mjs --check",
73
73
  "market:publish": "bash scripts/publish-market-index.sh",
74
74
  "pack:dry-run": "npm pack --dry-run"
75
+ },
76
+ "devDependencies": {
77
+ "@deepseek-ai/dsh-plugin-market-index": "0.2.1-rc.5"
75
78
  }
76
79
  }
@@ -284,8 +284,8 @@ const index = {
284
284
  name: MANIFEST.name,
285
285
  title: { en: 'Cabinet Mode', zh: '内阁模式' },
286
286
  description: {
287
- en: 'Adds the “内阁模式” preset: one persona shared by the Lead and the bureau members (翰林院 / 工部 / 大理寺 / 都察院), research-first rules, and evidence-anchored reporting. Pure YAML bundle, no runtime dependencies.',
288
- zh: '新增「内阁模式」preset:首辅与阁臣(翰林院 / 工部 / 大理寺 / 都察院)共享同一段 persona,默认只调研不改码、结论必须锚定证据。纯 YAML bundle,无运行时依赖。',
287
+ en: 'Adds the “内阁模式” preset: one persona shared by the Lead and the bureau members (翰林院 / 工部 / 大理寺 / 都察院), research-first rules, and evidence-anchored reporting. Includes the Cabinet sidebar and member avatars, with no third-party runtime dependencies.',
288
+ zh: '新增「内阁模式」preset:首辅与阁臣(翰林院 / 工部 / 大理寺 / 都察院)共享同一段 persona,默认只调研不改码、结论必须锚定证据。包含内阁侧边栏与成员头像,无第三方运行时依赖。',
289
289
  },
290
290
  icon: './icon.svg',
291
291
  author: MANIFEST.author,
@@ -31,12 +31,38 @@ version=$(node -p "require('./package.json').version")
31
31
  staging=$(mktemp -d)
32
32
  cp marketplace.json icon.svg "$staging/"
33
33
 
34
+ cat > "$staging/README.md" <<'EOF'
35
+ # Plugin market index
36
+
37
+ ## Add this source in DSH
38
+
39
+ Enable **Custom plugin market** under Plugins > Experimental plugins, then open
40
+ **Discover > Index sources** and paste this exact raw JSON URL:
41
+
42
+ ```text
43
+ https://raw.githubusercontent.com/luodaoyi/dsh-cabinet-mode/market-index/marketplace.json
44
+ ```
45
+
46
+ Do not paste a GitHub `tree` or `blob` page URL. Those return a web page rather
47
+ than the format-1 index and DSH reports `$.format must be 1`. Remove that invalid
48
+ source and add the raw URL above. The same rule applies to other markets.
49
+
50
+ 请复制上面的 raw JSON 地址到「发现 → 索引源」。不要填写本页的 GitHub
51
+ 网页地址;遇到 `$.format must be 1` 时,移除错误源并重新添加上述地址。
52
+
53
+ Generated from the npm registry by `scripts/market-index.mjs` for `dsh-cabinet-mode`.
54
+ Do not edit this branch by hand: the release workflow force-pushes it after every
55
+ tagged publish, and maintainers can refresh it with the `Market index` workflow.
56
+ EOF
57
+
34
58
  git config user.name 'github-actions[bot]'
35
59
  git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
36
60
 
37
61
  # Skip the push when the published copy already matches the regenerated one.
38
62
  if git fetch --no-tags origin market-index 2>/dev/null \
39
- && git show origin/market-index:marketplace.json 2>/dev/null | cmp -s - marketplace.json; then
63
+ && git show origin/market-index:marketplace.json 2>/dev/null | cmp -s - marketplace.json \
64
+ && git show origin/market-index:icon.svg 2>/dev/null | cmp -s - icon.svg \
65
+ && git show origin/market-index:README.md 2>/dev/null | cmp -s - "$staging/README.md"; then
40
66
  echo "index already current for ${version}"
41
67
  exit 0
42
68
  fi
@@ -44,13 +70,8 @@ fi
44
70
  git checkout --orphan market-index-publish
45
71
  git rm -rf .
46
72
  cp "$staging/marketplace.json" "$staging/icon.svg" .
47
- cat > README.md <<'EOF'
48
- # Plugin market index
73
+ cp "$staging/README.md" .
49
74
 
50
- Generated from the npm registry by `scripts/market-index.mjs` for `dsh-cabinet-mode`.
51
- Do not edit this branch by hand: the release workflow force-pushes it after every
52
- tagged publish, and maintainers can refresh it with the `Market index` workflow.
53
- EOF
54
75
  git add marketplace.json icon.svg README.md
55
76
  git commit -m "chore: refresh plugin market index for ${version}"
56
77
 
@@ -14,7 +14,7 @@ const React = {
14
14
  useLayoutEffect: () => {}, useEffect: () => {},
15
15
  };
16
16
  runInNewContext(source.replace(exportPoint,
17
- 'return { inject, apply, avatarFor, CabinetPanel, zh, en };'), {
17
+ 'return { inject, apply, avatarFor, displayName, CabinetPanel, MemberCard, TaskLine, zh, en };'), {
18
18
  window: { __ModuleLoader__: { load: ({ factory }) => {
19
19
  client = factory((name) => { assert.equal(name, 'react'); return React; });
20
20
  } } },
@@ -25,6 +25,17 @@ for (const [english, chinese] of [
25
25
  ]) assert.equal(client.avatarFor(english), client.avatarFor(' ' + chinese + '-一 '));
26
26
  assert.match(client.avatarFor('unknown'), /^data:image\/svg\+xml/);
27
27
  assert.match(client.avatarFor(null), /^data:image\/svg\+xml/);
28
+ for (const [name, expected] of [
29
+ ['gongbu2', '工部主事2 · gongbu2'],
30
+ ['works-ui', '工部主事(ui) · works-ui'],
31
+ ['works_ui', '工部主事(ui) · works_ui'],
32
+ ['works.ui', '工部主事(ui) · works.ui'],
33
+ ['翰林院编修-一', '翰林院编修(一) · 翰林院编修-一'],
34
+ ['工部主事', '工部主事'],
35
+ ['hanlinx', 'hanlinx'], ['works-', 'works-'], ['gongbu2x', 'gongbu2x'],
36
+ ]) assert.equal(client.displayName(name), expected);
37
+ for (const name of ['hanlinx', 'works-', 'gongbu2x']) assert.match(client.avatarFor(name), /^data:image\/svg\+xml/);
38
+ assert.equal(client.avatarFor('gongbu2'), client.avatarFor('works'));
28
39
 
29
40
  const render = (team, language) => client.CabinetPanel({
30
41
  sessionId: 'lead-session',
@@ -43,4 +54,37 @@ for (const language of [client.zh, client.en]) {
43
54
  assert.ok(!JSON.stringify(render({ members: [], tasks: [] }, language)).includes(language['team.stale']));
44
55
  assert.ok(!JSON.stringify(render(undefined, language)).includes(language['team.stale']));
45
56
  }
46
- console.log('PASS: avatar role aliases and stale-team warning rendering (zh/en); mocked React, not browser E2E');
57
+ // Inspect rendered host elements, including the member and owner leaf components.
58
+ function elements(tree) {
59
+ if (Array.isArray(tree)) return tree.flatMap(elements);
60
+ if (!tree || typeof tree !== 'object') return [];
61
+ if (typeof tree.type === 'function') {
62
+ const props = { ...tree.props };
63
+ if (tree.children.length) props.children = tree.children.flat();
64
+ return elements(tree.type(props));
65
+ }
66
+ return [tree, ...tree.children.flatMap(elements)];
67
+ }
68
+ const names = ['works', 'gongbu', 'zhushi', 'works-ui', 'works_ui', 'works.ui'];
69
+ const labels = [];
70
+ const tasks = names.map((name, i) => ({ id: String(i), subject: 'Task ' + i, ownerName: name, status: 'pending' }));
71
+ for (const name of names) {
72
+ const card = client.MemberCard({ member: { name, phase: 'active' }, statusLabel: (status) => status });
73
+ const label = elements(card).find((node) => node.props?.key === 'n');
74
+ assert.ok(label.children[0].includes(name), 'member label must retain raw name: ' + name);
75
+ assert.equal(label.props.title, label.children[0], 'truncated member label needs full tooltip');
76
+ labels.push(label.children[0]);
77
+ const task = tasks.find((task) => task.ownerName === name);
78
+ const line = client.TaskLine({ task, t: (key) => key, taskLabel: (status) => status });
79
+ const owner = elements(line).find((node) => node.type === 'span' && node.children.flat().some((text) => typeof text === 'string' && text.startsWith('Owner: ')));
80
+ assert.ok(owner.children.flat().includes('Owner: ' + label.children[0]));
81
+ assert.equal(owner.props.title, label.children[0]);
82
+ }
83
+ assert.equal(new Set(labels).size, names.length, 'aliases and separators must remain distinguishable');
84
+ const groups = elements(render({ members: [], tasks }, client.zh)).filter((node) => node.props?.key === 'title');
85
+ assert.equal(groups.length, names.length);
86
+ for (const [i, group] of groups.entries()) {
87
+ assert.equal(group.children[0], labels[i]);
88
+ assert.equal(group.props.title, labels[i]);
89
+ }
90
+ console.log('PASS: avatars, stale-team warnings, and distinct member/owner/group identities; mocked React, not browser E2E');
@@ -0,0 +1,46 @@
1
+ import assert from 'node:assert/strict';
2
+ import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
3
+ import { tmpdir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { spawnSync } from 'node:child_process';
6
+ import { parseMarketIndex, marketInstallTarget } from '@deepseek-ai/dsh-plugin-market-index';
7
+
8
+ const dir = mkdtempSync(join(tmpdir(), 'cabinet-market-contract-'));
9
+ const registry = join(dir, 'registry.json');
10
+ const baseline = join(dir, 'baseline.json');
11
+ const output = join(dir, 'marketplace.json');
12
+ const url = 'https://raw.githubusercontent.com/luodaoyi/dsh-cabinet-mode/market-index/marketplace.json';
13
+ writeFileSync(registry, JSON.stringify({
14
+ versions: { '0.2.0': {}, '0.2.1': {}, '0.2.2-rc.1': {}, '0.1.0': { deprecated: 'old' } },
15
+ time: Object.fromEntries(['0.2.0', '0.2.1', '0.2.2-rc.1', '0.1.0'].map(v => [v, '2026-11-05T00:00:00Z'])),
16
+ }));
17
+ function generate(extra = {}) {
18
+ return spawnSync(process.execPath, ['scripts/market-index.mjs'], {
19
+ encoding: 'utf8', timeout: 10000,
20
+ env: { ...process.env, MARKET_REGISTRY_MANIFEST: registry, MARKET_INDEX_URL: baseline,
21
+ MARKET_INDEX_OUT: output, MARKET_EXPECT_VERSION: '', MARKET_ALLOW_SHRINK: '0', ...extra },
22
+ });
23
+ }
24
+ let result = generate();
25
+ assert.equal(result.status, 0, result.stderr);
26
+ const raw = JSON.parse(readFileSync(output, 'utf8'));
27
+ const parsed = parseMarketIndex(raw, url);
28
+ const plugin = parsed.plugins[0];
29
+ assert.deepEqual(plugin.versions.map(v => v.version), ['0.2.1', '0.2.0']);
30
+ assert.equal(plugin.icon, new URL('./icon.svg', url).href);
31
+ assert.deepEqual(marketInstallTarget(plugin.name, plugin.versions[0]), {
32
+ spec: 'dsh-cabinet-mode@0.2.1', registry: 'https://registry.npmjs.org/',
33
+ });
34
+ assert.deepEqual(plugin.versions[0].engines, {});
35
+ assert.throws(() => parseMarketIndex({ payload: {} }, url), /\$\.format must be 1/);
36
+ // A lagging registry must never silently remove an already published version.
37
+ raw.plugins[0].versions.push({ ...raw.plugins[0].versions[0], version: '0.2.3' });
38
+ writeFileSync(baseline, JSON.stringify(raw));
39
+ result = generate();
40
+ assert.notEqual(result.status, 0, 'version-loss guard must reject a shrinking index');
41
+ assert.match(result.stderr, /0\.2\.3/);
42
+ // A release must wait for the registry instead of advertising an absent version.
43
+ result = generate({ MARKET_EXPECT_VERSION: '0.2.4', MARKET_EXPECT_TIMEOUT_MS: '30', MARKET_EXPECT_INTERVAL_MS: '10' });
44
+ assert.notEqual(result.status, 0);
45
+ assert.match(result.stderr, /registry did not list/);
46
+ console.log('PASS: official DSH parser, install target, version filtering, format rejection, version-loss and publication guards');
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env bash
2
+ # Exercise the real publisher only in disposable local repositories, never GitHub.
3
+ set -euo pipefail
4
+ publisher=$(cd "$(dirname "$0")" && pwd)/publish-market-index.sh
5
+ fixture=$(mktemp -d)
6
+ git init --bare "$fixture/remote.git" >/dev/null
7
+ git init -b main "$fixture/source" >/dev/null
8
+ cd "$fixture/source"
9
+ git config user.name Test
10
+ git config user.email test@example.invalid
11
+ git config core.autocrlf false
12
+ printf '{"version":"0.2.1"}\n' > package.json
13
+ printf '<svg>first</svg>\n' > icon.svg
14
+ git add .
15
+ git commit -qm fixture
16
+ git remote add origin "$fixture/remote.git"
17
+ git push -q origin main
18
+ publish() {
19
+ git -c core.autocrlf=false clone -q --branch main "$fixture/remote.git" "$fixture/run-$1"
20
+ (
21
+ cd "$fixture/run-$1"
22
+ printf '{"format":1}\n' > marketplace.json
23
+ bash "$publisher" > "$fixture/result-$1.log" 2>&1
24
+ )
25
+ }
26
+ head() { git --git-dir="$fixture/remote.git" rev-parse market-index; }
27
+ publish initial
28
+ initial=$(head)
29
+ publish unchanged
30
+ test "$(head)" = "$initial"
31
+ grep -q 'index already current' "$fixture/result-unchanged.log"
32
+ printf '<svg>second</svg>\n' > icon.svg
33
+ git add icon.svg
34
+ git commit -qm 'change icon only'
35
+ git push -q origin main
36
+ publish icon
37
+ test "$(head)" != "$initial"
38
+ git --git-dir="$fixture/remote.git" show market-index:icon.svg | grep -q second
39
+ git --git-dir="$fixture/remote.git" show market-index:README.md | grep -q 'raw.githubusercontent.com/luodaoyi/dsh-cabinet-mode/market-index/marketplace.json'
40
+ # Simulate an older generated README while keeping the current JSON and icon.
41
+ git -c core.autocrlf=false clone -q --branch market-index "$fixture/remote.git" "$fixture/old-readme"
42
+ (
43
+ cd "$fixture/old-readme"
44
+ git config user.name Test
45
+ git config user.email test@example.invalid
46
+ printf 'old instructions\n' > README.md
47
+ git add README.md
48
+ git commit -qm 'old readme'
49
+ git push -q origin market-index
50
+ )
51
+ old=$(head)
52
+ publish readme
53
+ test "$(head)" != "$old"
54
+ git --git-dir="$fixture/remote.git" show market-index:README.md | grep -q '\$.format must be 1'
55
+ echo 'PASS: initial publish, unchanged no-op, icon-only update, README-only update'
Binary file
Binary file
Binary file
Binary file
Binary file