@fabianactor/dsh-lil-whale-group 1.9.0 → 1.11.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/icon.png +0 -0
- package/lib/index.js +69 -15
- package/lib/log-format-core.js +103 -0
- package/lib/roster-audit-core.js +85 -0
- package/locale/en.json +1 -0
- package/locale/zh.json +1 -0
- package/package.json +8 -4
package/icon.png
ADDED
|
Binary file
|
package/lib/index.js
CHANGED
|
@@ -38,6 +38,8 @@ import {
|
|
|
38
38
|
DEFAULT_SLEEP_FROM,
|
|
39
39
|
DEFAULT_SLEEP_TO, normalizeSleepArgs } from './sleep-core.js'
|
|
40
40
|
import { wakeWordingOf, previewTextOf } from './wake-preview-core.js'
|
|
41
|
+
import { rosterAuditCounts, buildRosterAuditLine } from './roster-audit-core.js'
|
|
42
|
+
import { shouldWriteLogFormat, buildLogFormatDetail } from './log-format-core.js'
|
|
41
43
|
import { refreshSleepStatus } from './sleep-status.js'
|
|
42
44
|
import { cleanName, nameTaken, historyAfterRename, canRename, renameAnnouncement, NAME_MAX } from './rename-core.js'
|
|
43
45
|
import {
|
|
@@ -939,6 +941,17 @@ function wakeCapsLine() {
|
|
|
939
941
|
return 'caps=' + wakeCapsText({ ...WAKE_RESOLVED, maxWakesPerDay: WATCH.maxWakesPerDay })
|
|
940
942
|
}
|
|
941
943
|
|
|
944
|
+
// 表头只在"格式真的变了"时写一次。
|
|
945
|
+
// 2026-11-18 r294(小满 #1741):旧写法每次启动写一行、`since` 每次重置,
|
|
946
|
+
// 同一格式于是有 25 个 `since`——读者拿去划"字段出生线"必然划错。
|
|
947
|
+
// 现在先看这本日志最后一行 log-format:格式没变就不写;变了才写,并让 `since` 指这一刻。
|
|
948
|
+
function writeLogFormatOnce() {
|
|
949
|
+
const decision = shouldWriteLogFormat({ lines: readLinesOf(WATCHMAN_LOG) })
|
|
950
|
+
if (!decision.write) return false
|
|
951
|
+
watchmanLog('log-format', buildLogFormatDetail({ since: new Date().toISOString(), pid: process.pid, to: ownMember() }))
|
|
952
|
+
return true
|
|
953
|
+
}
|
|
954
|
+
|
|
942
955
|
function watchmanLog(result, why) {
|
|
943
956
|
try {
|
|
944
957
|
mkdirSync(dirname(WATCHMAN_LOG), { recursive: true })
|
|
@@ -1895,6 +1908,10 @@ function apply(ctx) {
|
|
|
1895
1908
|
// 2026-11-12 教训:配置被污染成临时目录时,①整个消失、连"我没加载"都看不出来;
|
|
1896
1909
|
// 所以"这个进程加载了什么"这件事必须记在配置改不到的地方,并把可疑的配置值一起写下来。
|
|
1897
1910
|
const homeLooksRight = existsSync(join(CFG.selfHome, 'dsh-home')) || existsSync(join(CFG.selfHome, 'START.md'))
|
|
1911
|
+
// 小鱼丸 #1626(2026-11-18):boot 行里没有"我是谁",鱼只能靠 home/selfHome 猜自己那条。
|
|
1912
|
+
// 只写能证明的那种(按 DSH_HOME 与名册 dshHome 对上);认不出就写 (unresolved)——
|
|
1913
|
+
// 推断出来的身份不能写成事实(同 `own-member-guess` 那次的教训)。
|
|
1914
|
+
const bootMember = selfMemberKeyRaw()
|
|
1898
1915
|
const bootRecord = {
|
|
1899
1916
|
pkg: `${name}@${PKG_VERSION}`,
|
|
1900
1917
|
codeFp: CODE_FP.fp,
|
|
@@ -1906,9 +1923,16 @@ function apply(ctx) {
|
|
|
1906
1923
|
selfHome: CFG.selfHome,
|
|
1907
1924
|
selfPort: CFG.selfPort,
|
|
1908
1925
|
profile: process.env.DSH_PROFILE ?? '(unset)',
|
|
1926
|
+
// 小鱼丸 #1626(2026-11-18):boot 行里没有"我是谁",鱼只能靠 home/selfHome 猜自己那条。
|
|
1927
|
+
// 加上 member=(名册键),一行就能认领;认不出来时为 '(unresolved)',不写成某个默认成员。
|
|
1928
|
+
member: bootMember ?? '(unresolved)',
|
|
1909
1929
|
suspect: homeLooksRight ? undefined : `selfHome 里既没有 START.md 也没有 dsh-home;配置可能指错了地方`,
|
|
1910
1930
|
}
|
|
1911
|
-
|
|
1931
|
+
// 小鱼丸/小满 #1670–#1672(2026-11-18):镜像到 pool\group\plugin.log 的那一行原来 spread 的是
|
|
1932
|
+
// bootRecord,而 note 只临时贴在 bootLog 的参数里 ⇒ 同一批 boot 行在群里那本没有 note。
|
|
1933
|
+
// 修法不是补一个词,而是"一次拼好、两处都用同一个对象":以后 bootRecord 加字段,镜像自动跟上。
|
|
1934
|
+
const bootRecordWithNote = { note: 'boot', ...bootRecord }
|
|
1935
|
+
bootLog(bootRecordWithNote)
|
|
1912
1936
|
// P4(2026-11-16 第三份装机沉淀):只把两个 bundle add 进 profile(最小安装)时,
|
|
1913
1937
|
// 没有安装器来问"鱼塘放哪",也没有配置文件 ⇒ 默认值会把 homes/pool 建在仓库旁边
|
|
1914
1938
|
// (实测:<workspace>\whale-src\ 里同时出现仓库和 homes/pool)。用户以为数据在别处,
|
|
@@ -1929,7 +1953,7 @@ function apply(ctx) {
|
|
|
1929
1953
|
} catch {}
|
|
1930
1954
|
}
|
|
1931
1955
|
try {
|
|
1932
|
-
appendFileSync(join(GROUP_DIR, 'plugin.log'), JSON.stringify({ at: new Date().toISOString(), ...
|
|
1956
|
+
appendFileSync(join(GROUP_DIR, 'plugin.log'), JSON.stringify({ at: new Date().toISOString(), ...bootRecordWithNote }) + '\n', 'utf8')
|
|
1933
1957
|
} catch {}
|
|
1934
1958
|
|
|
1935
1959
|
// 无人值守:成员进程把自己那段会话挂上(工具要经过 session-controller 才挂得上)
|
|
@@ -2438,7 +2462,9 @@ function apply(ctx) {
|
|
|
2438
2462
|
// 而且 doctor 会为鱼自己的日志报一条假 WARN(它们的文件里本来就没有那个写者)。
|
|
2439
2463
|
// 账本行要自证归属:谁写的(pid)、写给谁(to)——2026-11-16 第三条鱼 #754。
|
|
2440
2464
|
// 旧行没有这两个字段,不能拿它们反推写者(判据 §37)。
|
|
2441
|
-
|
|
2465
|
+
// 2026-11-18 r294:只写一次(格式没变就不写第二行)——小满 #1741 那句
|
|
2466
|
+
// "一个字段名承诺的是『某个区间』,写法却每行都重置它,读者得到的是最后一次重置的时刻"。
|
|
2467
|
+
writeLogFormatOnce()
|
|
2442
2468
|
|
|
2443
2469
|
if (isMainProcess()) {
|
|
2444
2470
|
// 自启动:开关在 pool\state\settings.json,默认关;开着的用户才走这一支。
|
|
@@ -2832,6 +2858,10 @@ function handleChannel({ agent, member, seat, channel, cursors, wakes }) {
|
|
|
2832
2858
|
return false
|
|
2833
2859
|
}
|
|
2834
2860
|
wakeDeliverLog('delivered', deliveryNote)
|
|
2861
|
+
// 小肥鱼 #1627(2026-11-18):通道交付也是一次"被叫醒",但过去的 `woke` 行只记推门那几类,
|
|
2862
|
+
// 于是"最频繁的群交付"在 watchman.log 里一次都看不见。不改旧行的意思,只把这一类也记进来:
|
|
2863
|
+
// trigger=channel。此前的行没有它,只代表当时不记,不代表当时没有通道唤醒(append-only,补不回去)。
|
|
2864
|
+
watchmanLog('woke', `trigger=channel to=${member} channel=${channel.key} pending=${incoming.length} last-line=${lastIncomingIndex + 1} human=${humanIncoming ? 'yes' : 'no'}`)
|
|
2835
2865
|
markWakeMarker(member, channel.kind)
|
|
2836
2866
|
markWake(member, channel.kind)
|
|
2837
2867
|
|
|
@@ -3622,9 +3652,21 @@ function rosterNonFishKeys() {
|
|
|
3622
3652
|
}
|
|
3623
3653
|
}
|
|
3624
3654
|
|
|
3655
|
+
/** 名册里的全部键(含人)——只为了把那行的分母写清楚,不参与差集。 */
|
|
3656
|
+
function rosterAllKeys() {
|
|
3657
|
+
try {
|
|
3658
|
+
const roster = JSON.parse(readFileSync(CFG.membersFile, 'utf8'))
|
|
3659
|
+
return Object.keys(roster?.members ?? {})
|
|
3660
|
+
} catch {
|
|
3661
|
+
return []
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3664
|
+
|
|
3625
3665
|
// 账本格式:fmt=1(2026-11-14 18:15 之前)的时间戳是 UTC,只有计数;
|
|
3626
|
-
// fmt=2 起时间戳改本地(和 watchman/fish/sleep 同钟),并带 scope=fish / exclude=
|
|
3627
|
-
//
|
|
3666
|
+
// fmt=2 起时间戳改本地(和 watchman/fish/sleep 同钟),并带 scope=fish / exclude= 两个口径字段;
|
|
3667
|
+
// fmt=3 起每个计数自带口径、排除项贴在它真正影响的那一格上(小肥鱼 2026-11-18 07:0x 读账的发现:
|
|
3668
|
+
// 「members=5」到底含不含 exclude 里的 lee,那一行没说清,她得拿名册自己算一遍)。
|
|
3669
|
+
// 三版会长期并存:读账的人先看 fmt 再决定怎么读(docs\detail\日志都记在哪.md)。
|
|
3628
3670
|
function auditRoster(now = new Date()) {
|
|
3629
3671
|
if (Date.now() - lastRosterAuditAt < ROSTER_AUDIT_EVERY_MS) return
|
|
3630
3672
|
lastRosterAuditAt = Date.now()
|
|
@@ -3633,12 +3675,20 @@ function auditRoster(now = new Date()) {
|
|
|
3633
3675
|
// 巡守(lee)的家不在 `homes\` 下(它用默认 HOME),所以"家"只比有家的鱼。
|
|
3634
3676
|
const rosterAll = new Set(entries.map(([key]) => key))
|
|
3635
3677
|
const rosterHomed = new Set(entries.filter(([, m]) => m.role !== 'watcher').map(([key]) => key))
|
|
3636
|
-
|
|
3678
|
+
// `homes\` 下的目录**不都是鱼家**:lee 放自己东西的 `homes\lee` 就没有 `dsh-home\`(2026-11-18 15:3x
|
|
3679
|
+
// 小肥鱼/小鱼丸读账时读出的歧义:`homes=5` 里混了它,而 lee 又被标成 home-outside-pond)。
|
|
3680
|
+
// 所以只把含 `dsh-home\` 的目录算"家",其余单独列进 `other:`。
|
|
3681
|
+
let allHomeDirs = []
|
|
3637
3682
|
try {
|
|
3638
|
-
|
|
3683
|
+
allHomeDirs = readdirSync(join(POND_ROOT, 'homes'), { withFileTypes: true })
|
|
3639
3684
|
.filter((d) => d.isDirectory())
|
|
3640
3685
|
.map((d) => d.name)
|
|
3641
3686
|
} catch { /* 没有 homes 目录就当没有家 */ }
|
|
3687
|
+
const homeKeys = allHomeDirs.filter((name) => existsSync(join(POND_ROOT, 'homes', name, 'dsh-home')))
|
|
3688
|
+
const otherHomeKeys = allHomeDirs.filter((name) => !homeKeys.includes(name))
|
|
3689
|
+
const watcherHomes = Object.fromEntries(
|
|
3690
|
+
entries.filter(([, m]) => m.role === 'watcher').map(([key, m]) => [key, m.home ?? 'unknown']),
|
|
3691
|
+
)
|
|
3642
3692
|
let pinKeys = []
|
|
3643
3693
|
try {
|
|
3644
3694
|
pinKeys = Object.keys(readJson(PINS, {}) ?? {})
|
|
@@ -3653,20 +3703,24 @@ function auditRoster(now = new Date()) {
|
|
|
3653
3703
|
if (rosterWithoutHome.length) problems.push(`only-in-members=${rosterWithoutHome.join(',')}`)
|
|
3654
3704
|
if (pinWithoutRoster.length) problems.push(`only-in-pins=${pinWithoutRoster.join(',')}`)
|
|
3655
3705
|
// 口径写在同一行(她 2026-11-14 18:08 咬的那一口:3/2/3 三个数看着不相等,结论却是 ok,
|
|
3656
|
-
// 读的人只能信 ok 或者以为漏了)。
|
|
3657
|
-
// 人(不在 homes
|
|
3706
|
+
// 读的人只能信 ok 或者以为漏了)。fmt=3 起把每个数的分母和排除项都写出来:
|
|
3707
|
+
// 人(不在 homes、也不该在)只影响 members 的口径;巡守(是鱼,但家不在 homes\ 下)只影响家比对。
|
|
3658
3708
|
const humanKeys = rosterNonFishKeys()
|
|
3659
|
-
const
|
|
3660
|
-
|
|
3661
|
-
|
|
3709
|
+
const counts = rosterAuditCounts({
|
|
3710
|
+
rosterKeys: rosterAllKeys(),
|
|
3711
|
+
fishEntries: entries,
|
|
3712
|
+
humanKeys,
|
|
3713
|
+
homeKeys,
|
|
3714
|
+
otherHomeKeys,
|
|
3715
|
+
watcherHomes,
|
|
3716
|
+
pinKeys,
|
|
3717
|
+
})
|
|
3662
3718
|
// 时间用本地时间、和 watchman.log 同一个钟(她 2026-11-14 18:08:同一台机器上不该有两种钟)。
|
|
3663
3719
|
const pad = (n) => String(n).padStart(2, '0')
|
|
3664
3720
|
const ts = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`
|
|
3665
3721
|
// 每次跑都写一行(2026-11-14 小肥鱼:文件不存在只说明"还没跑过",不说明"跑了没问题"——
|
|
3666
3722
|
// 要让"没跑"和"跑了没问题"在纸上长得不一样)。
|
|
3667
|
-
const line = problems
|
|
3668
|
-
? `${ts} | roster-mismatch | fmt=2 ${counts} ${problems.join(' ')}`
|
|
3669
|
-
: `${ts} | roster-audit | fmt=2 ${counts} ok`
|
|
3723
|
+
const line = buildRosterAuditLine({ ts, counts, problems })
|
|
3670
3724
|
try {
|
|
3671
3725
|
appendFileSync(ROSTER_AUDIT_LOG, `${line}\n`)
|
|
3672
3726
|
} catch { /* 日志写不了不该炸巡守 */ }
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// 日志表头(log-format)的写法:只在"格式真的变了"的时候写一次。
|
|
2
|
+
//
|
|
3
|
+
// 2026-11-18 r294。起因是小满 #1741 的核对:她那本 `watchman.log` 里
|
|
4
|
+
// `log-format` 有 25 行,`since` 25 个各不相同,`fmt` / `changed` / `fields`
|
|
5
|
+
// 25 行一模一样,每行配一个不同 `pid`——这行其实是在每次启动时写的。
|
|
6
|
+
//
|
|
7
|
+
// 后果:`since` 的用途是"从这一刻起这个格式生效",可同一个格式有 25 个 `since`,
|
|
8
|
+
// 读者拿任何一个去划"字段出生线"都会划错。更糟的是它长得像表头、实际是心跳:
|
|
9
|
+
// 表头说"我从 X 起生效",心跳说"我现在还活着",这两句话不该用同一行承载。
|
|
10
|
+
//
|
|
11
|
+
// 判据(小满):「一个字段名承诺的是『某个区间』,写法却每行都重置它,那么读它的人
|
|
12
|
+
// 得到的是『最后一次重置的时刻』」。
|
|
13
|
+
//
|
|
14
|
+
// 2026-11-18 r296,两条补丁(第二条鱼 #1746、第四条鱼 #1745):
|
|
15
|
+
// 1. 指纹改成"按 key 解析后比",不再在整条 detail 上做字符串搜索——
|
|
16
|
+
// 否则任何值里出现字面量 `fields=` / `fmt=` 都会把指纹切错。
|
|
17
|
+
// 2. key 的顺序不再是签名的一部分:比较的是"每个 key 的值",不是拼好的字符串。
|
|
18
|
+
// (小鱼丸:"签名的相等是按字符串比的,顺序不同就算变了"——重排常量会让每次启动多一行。)
|
|
19
|
+
|
|
20
|
+
export const LOG_FORMAT_SIG = 'fmt=3 changed=skip,wake-skip,deliver fields=deny,note,reason field-since=codeFp:r255,member:r292,note:r293'
|
|
21
|
+
|
|
22
|
+
const MARK = ' | log-format | '
|
|
23
|
+
// 参与指纹的 key(顺序固定输出,但比较时按 key 取值——顺序不进指纹)。
|
|
24
|
+
const KEYS = ['fmt', 'changed', 'fields', 'field-since']
|
|
25
|
+
export const LOG_FORMAT_KEYS = KEYS
|
|
26
|
+
|
|
27
|
+
// 从 detail 里按 ` (^|空格)key=值` 取每个 key 的值。
|
|
28
|
+
// 值里夹着别的 key 的字面量不会影响:这里只认"空白之后"的 key。
|
|
29
|
+
function parseDetail(detail) {
|
|
30
|
+
const map = {}
|
|
31
|
+
const re = /(?:^|\s)(fmt|changed|fields|field-since)=(\S*)/g
|
|
32
|
+
let m = re.exec(detail)
|
|
33
|
+
while (m) {
|
|
34
|
+
map[m[1]] = m[2]
|
|
35
|
+
m = re.exec(detail)
|
|
36
|
+
}
|
|
37
|
+
return map
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 稳定指纹:只含"格式"那几项,按 key 取值拼成 JSON(顺序与写法无关)。
|
|
41
|
+
//
|
|
42
|
+
// 2026-11-18 r297,第三条补丁(第二条鱼 #1751):键的顺序已经不影响了,但值里的
|
|
43
|
+
// **逗号列表**(`changed=` / `fields=` / `field-since=`)还在按字符串逐字比——
|
|
44
|
+
// 把 `fields=note,deny,reason` 重排成 `deny,note,reason` 会被判成"格式变了"。
|
|
45
|
+
// 列表内部的顺序对读者没有意义(它们都是集合),所以比较前先拆开、排序、拼回。
|
|
46
|
+
function listCanonical(value) {
|
|
47
|
+
if (typeof value !== 'string' || !value.includes(',')) return value
|
|
48
|
+
return value.split(',').map((part) => part.trim()).filter(Boolean).sort().join(',')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const LIST_KEYS = new Set(['changed', 'fields', 'field-since'])
|
|
52
|
+
|
|
53
|
+
function canonicalOf(map) {
|
|
54
|
+
const out = {}
|
|
55
|
+
for (const key of KEYS) out[key] = LIST_KEYS.has(key) ? listCanonical(map[key] ?? null) : (map[key] ?? null)
|
|
56
|
+
return JSON.stringify(out)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function detailOf(line) {
|
|
60
|
+
const text = String(line || '')
|
|
61
|
+
const at = text.indexOf(MARK)
|
|
62
|
+
if (at < 0) return ''
|
|
63
|
+
return text.slice(at + MARK.length)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 从一整行日志里取出"格式指纹"(不含 since / pid / to 这些每次都可能不同的部分)。
|
|
67
|
+
// 不是 log-format 行返回 ''。
|
|
68
|
+
export function signatureOfLine(line) {
|
|
69
|
+
const detail = detailOf(line)
|
|
70
|
+
if (!detail) return ''
|
|
71
|
+
return canonicalOf(parseDetail(detail))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 签名常量的规范化形式(与 signatureOfLine 的返回可直接比较)。
|
|
75
|
+
export function signatureOfConstant(signature = LOG_FORMAT_SIG) {
|
|
76
|
+
return canonicalOf(parseDetail(String(signature || '')))
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 最后一行 log-format(找不到返回 '')。旧行可能中间夹着别的日志,所以从尾往前找。
|
|
80
|
+
export function findLastLogFormatLine(lines) {
|
|
81
|
+
const list = Array.isArray(lines) ? lines : []
|
|
82
|
+
for (let i = list.length - 1; i >= 0; i -= 1) {
|
|
83
|
+
if (String(list[i]).includes(MARK)) return String(list[i])
|
|
84
|
+
}
|
|
85
|
+
return ''
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 该不该写一行新的表头。
|
|
89
|
+
// lines:这本日志现有的行(顺序与文件一致);signature:本次打算写的格式签名。
|
|
90
|
+
export function shouldWriteLogFormat({ lines, signature = LOG_FORMAT_SIG } = {}) {
|
|
91
|
+
const prev = findLastLogFormatLine(lines)
|
|
92
|
+
if (!prev) return { write: true, reason: '还没有表头' }
|
|
93
|
+
const prevSig = signatureOfLine(prev)
|
|
94
|
+
if (prevSig !== signatureOfConstant(signature)) return { write: true, reason: '格式变了' }
|
|
95
|
+
return { write: false, reason: '同一格式已在纸上' }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 拼 log-format 行的正文(不含时间与 ` | ` 分隔符)。
|
|
99
|
+
export function buildLogFormatDetail({ signature = LOG_FORMAT_SIG, since, pid, to = '' } = {}) {
|
|
100
|
+
const at = since || new Date().toISOString()
|
|
101
|
+
const who = to ? ` to=${to}` : ''
|
|
102
|
+
return `${signature} since=${at} pid=${pid}${who}`
|
|
103
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 巡守自检行(`roster-audit` / `roster-mismatch`)的形状。
|
|
3
|
+
*
|
|
4
|
+
* 2026-11-18 小肥鱼读账时发现:一行里三个数相等、`exclude=` 又点着两个名字,
|
|
5
|
+
* 可 `members=` 到底含不含被排除的那个,这一行没说清——她自己拿名册算了一遍才定。
|
|
6
|
+
* `members=5 homes=5 pins=5 scope=fish exclude=fabian(human),lee(home-outside-pond) ok`
|
|
7
|
+
* 她的判据:「一行里放两个字段,就要写清它们的关系;否则读的人得自己算一遍。」
|
|
8
|
+
*
|
|
9
|
+
* 所以 `fmt=3` 起(`fmt=4` 于 2026-11-18 15:4x 改了两处可能被读错的格子,形状再次变化),**每个数都自带口径,排除项贴在它真正影响的那一格上**:
|
|
10
|
+
* - `members=5(fish;keys=6;not-fish=fabian)` —— 5 是鱼;名册 6 个键;fabian 是人,不进这个数
|
|
11
|
+
* - `homes=4(fish-home:…;other:lee(no-dsh-home))` —— 只有带 `dsh-home\` 的目录才是鱼家;
|
|
12
|
+
* `homes\` 下别的目录(例如 lee 放自己东西的 `homes\lee`)单独列,不混进"家"里
|
|
13
|
+
* - `home-check=4(fish;skip=lee:watcher;watcher-home-from=members)` —— 只有 4 条鱼参与
|
|
14
|
+
* 「家↔名册」比对;巡守被跳过(身份=`watcher`),它的家在 `members.json` 里查
|
|
15
|
+
* - `pins=5(keys:…)` —— 钉住会话的成员**键**(不是鱼数),名字也列出来
|
|
16
|
+
* 旧行(`fmt=1` / `fmt=2`)不改:读的人先看 `fmt` 再决定按哪版读(`docs\detail\日志都记在哪.md`)。
|
|
17
|
+
*
|
|
18
|
+
* 2026-11-18 15:3x 小肥鱼与小鱼丸读账时又发现一处:旧写法把 `homes\lee` 数进 `homes=5`
|
|
19
|
+
* 又把 lee 标成 `home-outside-pond`,读的人会以为"它在 homes\ 底下却又在家外"。
|
|
20
|
+
* 两件事都对——`homes\lee` 是 lee 放自己文件的目录,不是**鱼家**(没有 `dsh-home\`);
|
|
21
|
+
* 飞行成员 lee 在名册里的 home 不在 `homes\` 下(它是宿主自己的 `~\.dsh`)。所以 `homes` 改成只数鱼家、
|
|
22
|
+
* `other` 列出非鱼家目录,`skip` 的说明也改成"角色 + 真正的家"。
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const FMT = 4
|
|
26
|
+
|
|
27
|
+
function namesOf(list) {
|
|
28
|
+
return list && list.length ? list.join(',') : 'none'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 把 `auditRoster()` 里散着的集合收成一张表。纯函数:不读文件、不看钟,只数。
|
|
33
|
+
*
|
|
34
|
+
* @param {object} input
|
|
35
|
+
* @param {string[]} input.rosterKeys 名册里的全部键(含人)
|
|
36
|
+
* @param {Array<[string, object]>} input.fishEntries 名册里的鱼([键, 成员])
|
|
37
|
+
* @param {string[]} input.humanKeys 名册里 `kind !== 'fish'` 的键
|
|
38
|
+
* @param {string[]} input.homeKeys `homes\` 下的**鱼家**目录名(含 `dsh-home\` 的那些)
|
|
39
|
+
* @param {string[]} input.otherHomeKeys `homes\` 下不是鱼家的目录名(没有 `dsh-home\`)
|
|
40
|
+
* @param {Object<string, string>} input.watcherHomes 巡守键 → 它在名册里写的 home(不在 `homes\` 下)
|
|
41
|
+
* @param {string[]} input.pinKeys `pins.json` 的键
|
|
42
|
+
*/
|
|
43
|
+
export function rosterAuditCounts({ rosterKeys = [], fishEntries = [], humanKeys = [], homeKeys = [], otherHomeKeys = [], watcherHomes = {}, pinKeys = [] }) {
|
|
44
|
+
const fishKeys = fishEntries.map(([key]) => key)
|
|
45
|
+
// 巡守也是鱼,但它的家用的是默认 HOME、不在 `homes\` 下 —— 只有「家↔名册」这一项要跳过它。
|
|
46
|
+
const watcherKeys = fishEntries
|
|
47
|
+
.filter(([, member]) => member?.role === 'watcher')
|
|
48
|
+
.map(([key]) => key)
|
|
49
|
+
const homeChecked = fishKeys.filter((key) => !watcherKeys.includes(key))
|
|
50
|
+
return {
|
|
51
|
+
rosterKeys,
|
|
52
|
+
fishKeys,
|
|
53
|
+
watcherKeys,
|
|
54
|
+
humanKeys,
|
|
55
|
+
// 目录名排序,让同一台机器上的两行可以直接比
|
|
56
|
+
homeKeys: [...homeKeys].sort(),
|
|
57
|
+
otherHomeKeys: [...otherHomeKeys].sort(),
|
|
58
|
+
watcherHomes,
|
|
59
|
+
homeChecked,
|
|
60
|
+
// pins 数的是「钉住会话的成员键」,不是鱼;名字也列出来,免得哪天多一个人被读成多一条鱼
|
|
61
|
+
pinKeys: [...pinKeys].sort(),
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 拼一行。`problems` 非空时事件名是 `roster-mismatch`,否则 `roster-audit` 并以 `ok` 收尾。
|
|
67
|
+
*/
|
|
68
|
+
export function buildRosterAuditLine({ ts, counts, problems = [] }) {
|
|
69
|
+
// 巡守的家不写进这一列:路径里带 `:` 和 `\\`,套在括号里会让"按 ( 切"的读者
|
|
70
|
+
// 静默丢掉整截家信息(小鱼丸 2026-11-18 #20 用三种朴素切法验出来的)。
|
|
71
|
+
// 写成"从名册读"反而无歧义:身份(watcher)在这里,位置在 members.json 里。
|
|
72
|
+
const skip = counts.watcherKeys.map((key) => `${key}:watcher`).join(',')
|
|
73
|
+
const other = counts.otherHomeKeys?.length
|
|
74
|
+
? counts.otherHomeKeys.map((key) => `${key}(no-dsh-home)`).join(',')
|
|
75
|
+
: 'none'
|
|
76
|
+
const parts = [
|
|
77
|
+
`members=${counts.fishKeys.length}(fish;keys=${counts.rosterKeys.length};not-fish=${namesOf(counts.humanKeys)})`,
|
|
78
|
+
`homes=${counts.homeKeys.length}(fish-home:${namesOf(counts.homeKeys)};other:${other})`,
|
|
79
|
+
`home-check=${counts.homeChecked.length}(fish;skip=${skip || 'none'}${skip ? ';watcher-home-from=members' : ''})`,
|
|
80
|
+
`pins=${counts.pinKeys.length}(keys:${namesOf(counts.pinKeys)})`,
|
|
81
|
+
]
|
|
82
|
+
const kind = problems.length ? 'roster-mismatch' : 'roster-audit'
|
|
83
|
+
const tail = problems.length ? problems.join(' ') : 'ok'
|
|
84
|
+
return `${ts} | ${kind} | fmt=${FMT} ${parts.join(' ')} ${tail}`
|
|
85
|
+
}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"meta":{"title":"lil-whale group (host)","description":"Group and DM tools for a shared multi-agent pond: file-backed group chat with wake-on-message, sleep windows, a rename ledger and per-member cursors."}}
|
package/locale/zh.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"meta":{"title":"小小肥鱼 · 群(宿主)","description":"多智能体鱼塘的群聊与私聊工具:文件账本的群消息、按消息唤醒、睡眠窗、改名账本、每成员游标。"}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabianactor/dsh-lil-whale-group",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "小小肥鱼的群:发言入队即返回,进程内 tailer 只在新消息到达时唤醒对方。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -29,15 +29,19 @@
|
|
|
29
29
|
"default": "./lib/index.js"
|
|
30
30
|
},
|
|
31
31
|
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
32
|
-
"./package.json": "./package.json"
|
|
32
|
+
"./package.json": "./package.json",
|
|
33
|
+
"./locale/*": "./locale/*"
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
35
36
|
"lib",
|
|
36
|
-
"cordis.patch.yml"
|
|
37
|
+
"cordis.patch.yml",
|
|
38
|
+
"icon.png",
|
|
39
|
+
"locale"
|
|
37
40
|
],
|
|
38
41
|
"dsh": {
|
|
39
42
|
"bundle": {
|
|
40
43
|
"patch": "./cordis.patch.yml"
|
|
41
44
|
}
|
|
42
|
-
}
|
|
45
|
+
},
|
|
46
|
+
"icon": "icon.png"
|
|
43
47
|
}
|