teamsmith 0.4.3 → 0.4.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teamsmith",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Turn one agent session into a project owner: self-contained task briefs dispatched to worker agents in their own git worktrees, independent verification on a separate checkout, and an auditable ledger (BOARD / reviews / threads / DECISIONS). Runs on Pi today.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -5,6 +5,26 @@
5
5
  > `SKILL.md`/`references/**`/`templates/**`/`extension/**` 在 Pi 里输入 `/reload`(或 `/pi-team-reload`)即生效;
6
6
  > 判断自己是不是旧的:`team mark-loaded`(开局记一次)→ `team version --check`。
7
7
 
8
+ ## v0.4.5(2026-11-05)
9
+
10
+ 修复编号回复页始终不增长。
11
+
12
+ - 捕获在发布前要确认"这条落盘的消息就是我刚写的那条"。原按消息逐字节比较;装了会在回复开头加 `§N§` 标签的扩展(例如 magic-context)时,落盘消息必然与捕获时不同,判定失败,待发布条目被静默丢弃。
13
+ - 现在只比较回复正文,忽略行首标签与结尾空白;消息 id 本身已经指明是哪条。
14
+ - 判定被跳过时不再无声:原因写入 `.pi/team/state/reply-capture/diagnostics.log`。
15
+ - 已被卡住的待发布回复会在下一个回合结束时补发。
16
+
17
+ 升级方式:`npm i -g teamsmith@0.4.5`,重启 PM。
18
+
19
+ ## v0.4.4(2026-11-05)
20
+
21
+ 修复编号回复页始终不增长:捕获认不出自己那条消息,于是永远停在“待发布”。
22
+
23
+ - 判定一条回复是否就是刚产出的那条时,原先要求消息逐字节相同。装了第二个会改写回复的扩展(例如在回复开头加时间标签的 magic-context)时,落盘的消息与捕获时的消息必然差一点点,判定失败,待发布条目被静默丢弃。
24
+ - 现在按回复正文比较,忽略行首那种 `§N§` 标签;条目本身已由消息 id 指定,逐字节相等并不会带来额外保护。
25
+
26
+ 升级方式:`npm i -g teamsmith@0.4.4`,重启 PM。已被卡住的待发布回复会在下一个回合结束时补发。
27
+
8
28
  ## v0.4.3(2026-11-05)
9
29
 
10
30
  让"回复没进编号回复页"这件事留下可查的原因。
@@ -3,7 +3,7 @@ name: teamsmith
3
3
  description: teamsmith gives one agent real ownership of a project — it plans, writes self-contained task briefs, dispatches worker agents into their own tmux windows and git worktrees, verifies their work on an independent checkout, merges, and keeps an auditable ledger (BOARD/reviews/threads/DECISIONS). A pulse window (the periodic patrol) wakes the owner only when there is pending work, and the owner can deliberately stand down. Works with Pi; the launch/notify seam is an internal seam (frozen) reserved for a possible future non-Pi adapter, with no compatibility promise. Use when the user wants an agent to own a project end to end, dispatch tasks to worker agents, run agents in parallel in tmux with git worktree isolation, act as a PM/orchestrator over other agents, review an agent's work independently, run the patrol (`pulse`) as a tmux window, wake the PM only when there is pending work, or resume and coordinate a multi-agent project. To start a new project, use the teamsmith-init skill.
4
4
  license: MIT
5
5
  metadata:
6
- version: "0.4.3"
6
+ version: "0.4.5"
7
7
  ---
8
8
 
9
9
  # teamsmith · one agent that actually owns the project
@@ -3,7 +3,7 @@
3
3
  # 由 scripts/team 与各 cmd-*.sh source;不要直接执行。
4
4
  # 约定:所有函数名以 team_ 前缀;不依赖 jq / python / node。
5
5
 
6
- TEAM_VERSION="0.4.3"
6
+ TEAM_VERSION="0.4.5"
7
7
 
8
8
  # ---------------------------------------------------------------- 输出
9
9
  if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
@@ -114,6 +114,11 @@ function derivedTitle(body) {
114
114
  }
115
115
 
116
116
  /** No mutation outside exact original control ranges; character offsets are NOT UTF-8 byte offsets. */
117
+ const TAG_PREFIX = /^\u00a7\d+\u00a7\s*/
118
+ /** What a host may legitimately change about a reply we just produced: the leading tag it asked for,
119
+ * and trailing whitespace left behind by removing the control line. Nothing else is compared. */
120
+ const normalizeReplyText = text => String(text).replace(TAG_PREFIX, '').replace(/\s+$/, '')
121
+
117
122
  export function parseReply(message) {
118
123
  const blocks = Array.isArray(message.content) ? message.content : []
119
124
  const original = blocks.filter(b => b.type === 'text').map(b => b.text).join('')
@@ -328,6 +333,23 @@ function writerOutcome(result, record) {
328
333
  return { status: 'uncertain', reason: 'inconsistent-outcome' }
329
334
  }
330
335
 
336
+ /**
337
+ * Another extension may rewrite the finalized message after ours returns -- magic-context, for one,
338
+ * removes the leading `§N§` tag it asked for. Compare the reply text with that tag normalized away,
339
+ * because the entry id already names the message; requiring byte equality bound nothing and dropped
340
+ * every reply on a machine that runs a second message_end transform.
341
+ */
342
+ function sameReplyMessage(a, b) {
343
+ if (!a || !b || a.role !== b.role || !Array.isArray(a.content) || !Array.isArray(b.content)) return false
344
+ if (a.content.length !== b.content.length) return false
345
+ return a.content.every((item, i) => {
346
+ const other = b.content[i]
347
+ if (!item || !other || item.type !== other.type) return false
348
+ if (item.type !== 'text') return isDeepStrictEqual(item, other)
349
+ return normalizeReplyText(item.text) === normalizeReplyText(other.text)
350
+ })
351
+ }
352
+
331
353
  /** Pi event state, deliberately independent of the host. Only view.entry/branch of the actual current session bind a source. */
332
354
  export class ReplyCapture {
333
355
  constructor({ identity, journal = new CaptureJournal(identity), current, verify, writer, owner, diagnostic }) {
@@ -336,7 +358,17 @@ export class ReplyCapture {
336
358
  this.running = new Set()
337
359
  }
338
360
  memoryHost(view) { return this.current() && sameIdentity(this.identity, view.identity) }
339
- eligibleHost(view) { return this.memoryHost(view) && this.verify() }
361
+ // Re-proving identity costs a git/tmux/getconf round trip; doing it on every event made a transient
362
+ // shell failure look like a refused host, which dropped the reply. Prove once per turn and reuse it.
363
+ eligibleHost(view) {
364
+ if (!this.memoryHost(view)) return false
365
+ const a = this.activity
366
+ if (a && typeof a.verified === 'boolean') return a.verified
367
+ let ok = false
368
+ try { ok = !!this.verify() } catch { ok = false }
369
+ if (a) a.verified = ok
370
+ return ok
371
+ }
340
372
  report(reason, entryId = '') {
341
373
  try { this.diagnostic({ reason, entryId, path: this.journal.path }) }
342
374
  catch { /* An unavailable diagnostic sink must not block final message cleanup. */ }
@@ -377,8 +409,8 @@ export class ReplyCapture {
377
409
  // that never grew. Name it, with the same diagnostic sink that records a mismatched binding.
378
410
  if (!this.eligibleHost(view)) { this.report('ineligible-at-turn'); return }
379
411
  const entry = view.entry(event.messageEntryId)
380
- if (!event.messageEntryId || entry?.type !== 'message' || !isDeepStrictEqual(entry.message, latest.message) ||
381
- !isDeepStrictEqual(event.message, latest.message) || !branchWitness(view, a.startLeaf, event.messageEntryId)) {
412
+ if (!event.messageEntryId || entry?.type !== 'message' || !sameReplyMessage(entry.message, latest.message) ||
413
+ !sameReplyMessage(event.message, latest.message) || !branchWitness(view, a.startLeaf, event.messageEntryId)) {
382
414
  latest.intent = null // A bad binding cannot be repaired by another event or current-leaf inference.
383
415
  this.report('binding-mismatch', event.messageEntryId)
384
416
  return
@@ -413,7 +445,8 @@ export class ReplyCapture {
413
445
  }
414
446
  reset() { this.activity = null }
415
447
  recover(view) {
416
- if (this.activity || !this.eligibleHost(view)) return
448
+ if (this.activity) { this.report('recover-skip:busy'); return }
449
+ if (!this.eligibleHost(view)) { this.report('recover-skip:ineligible'); return }
417
450
  let records
418
451
  try {
419
452
  records = this.journal.transact(snapshot => {
@@ -425,9 +458,17 @@ export class ReplyCapture {
425
458
  record.reason = 'attempt-owner-exited'
426
459
  }
427
460
  }
428
- return Object.values(snapshot.sources).filter(record => record.status === 'eligible' &&
461
+ const all = Object.values(snapshot.sources)
462
+ const keep = all.filter(record => record.status === 'eligible' &&
429
463
  branchWitness(view, record.startLeaf, record.entryId, record.settledLeaf) &&
430
- isDeepStrictEqual(view.entry(record.entryId)?.message, record.message))
464
+ sameReplyMessage(view.entry(record.entryId)?.message, record.message))
465
+ for (const record of all) {
466
+ if (record.status !== 'eligible' || keep.includes(record)) continue
467
+ const why = !branchWitness(view, record.startLeaf, record.entryId, record.settledLeaf) ? 'not-on-branch'
468
+ : 'text-differs'
469
+ this.report(`recover-skipped:${why}`, record.entryId)
470
+ }
471
+ return keep
431
472
  })
432
473
  } catch (e) {
433
474
  if (e.code !== 'ENOENT') this.report(`recovery:${e.code ?? e.name}`)
@@ -436,7 +477,10 @@ export class ReplyCapture {
436
477
  for (const record of records) this.attempt(record, view)
437
478
  }
438
479
  attempt(record, view) {
439
- if (this.activity || !this.eligibleHost(view)) return
480
+ if (this.activity || !this.eligibleHost(view)) {
481
+ this.report(this.activity ? 'attempt-busy' : 'attempt-ineligible', record.entryId)
482
+ return
483
+ }
440
484
  const token = randomUUID()
441
485
  const key = sourceKey(this.identity, record.entryId)
442
486
  try {
@@ -447,7 +491,8 @@ export class ReplyCapture {
447
491
  stored.attempt = { token, ...this.owner, at: new Date().toISOString() }
448
492
  return true
449
493
  })
450
- if (!acquired || !this.eligibleHost(view)) return
494
+ if (!acquired) { this.report('attempt-cas-lost', record.entryId); return }
495
+ if (!this.eligibleHost(view)) { this.report('attempt-ineligible', record.entryId); return }
451
496
  } catch (e) { this.report(`attempting:${e.code ?? e.name}`, record.entryId); return }
452
497
  // Durable CAS above is the barrier, including a crash right before this invocation.
453
498
  const work = Promise.resolve().then(() => {
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env bash
2
+ # Live probe for marker capture, run against THIS working tree (not an installed release).
3
+ #
4
+ # Cost: it starts one real PM session and asks the model for one reply, so it is not part of any
5
+ # gate. Use it before cutting a release that touches scripts/reply-capture.mjs or extension/team-reply.ts.
6
+ #
7
+ # bash skills/teamsmith/tests/live-capture-probe.sh [scratch-dir]
8
+ #
9
+ # Success is three facts, printed at the end: the marker is gone from the persisted reply, the
10
+ # journal's newest source is `saved` with a number, and the reply store grew.
11
+ set -euo pipefail
12
+
13
+ repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)
14
+ probe=${1:-/var/tmp/teamsmith-live-probe}
15
+ model=${PROBE_PM_MODEL:-deepseek/deepseek-flash}
16
+ team="$repo_root/skills/teamsmith/scripts/team"
17
+ unset TEAM_ROOT TEAM_MAIN_ROOT TEAM_PROJECT TEAM_SESSION TEAM_STATE_DIR TEAM_CONFIG_FILE TEAM_PM_WINDOW
18
+
19
+ rm -rf "$probe"; mkdir -p "$probe"
20
+ git -C "$probe" init -q .
21
+ git -C "$probe" -c user.email=probe@local -c user.name=probe commit -q --allow-empty -m init
22
+
23
+ cd "$probe"
24
+ bash "$team" init --no-skills --session probe --agents dev --pm-model "$model" \
25
+ --task-models "code=$model verify=$model analysis=$model" >/dev/null
26
+ bash "$team" up >/dev/null
27
+ sleep 35
28
+
29
+ session=probe
30
+ tmux send-keys -t "$session:pm" '正文一句。最后一行单独写 [[team-reply]]' Enter
31
+ sleep 55
32
+
33
+ journal=$(ls .pi/team/state/reply-capture/*.json | grep -v runtime | head -1)
34
+ store=.pi/team/state/key-replies/index.v1
35
+
36
+ python3 - "$journal" "$store" <<'PY'
37
+ import json, sys
38
+ journal, store, os = sys.argv[1], sys.argv[2], __import__('os')
39
+ data = json.load(open(journal))
40
+ records = list(data['sources'].values())
41
+ saved = [r for r in records if r.get('status') == 'saved' and isinstance(r.get('no'), int)]
42
+ bodies = [json.dumps(r.get('message', {}), ensure_ascii=False) for r in saved]
43
+ marker_left = any('[[team-reply' in b for b in bodies)
44
+ size = os.path.getsize(store) if os.path.exists(store) else 0
45
+ print(f'journal sources: {len(records)} | saved: {len(saved)}')
46
+ print(f'marker in published body: {marker_left}')
47
+ print(f'store bytes: {size}')
48
+ sys.exit(0 if saved and not marker_left and size > 0 else 1)
49
+ PY
50
+
51
+ status=$?
52
+ tmux kill-session -t probe 2>/dev/null || true
53
+ exit $status
@@ -3,7 +3,7 @@ name: teamsmith-init
3
3
  description: teamsmith-init is the new-project entry point of the teamsmith toolkit — organize multiple agents into a team, set up an agent collaboration protocol, and bootstrap this skill into a new project. It walks the questions to settle with the user first (dependencies, session and roster, the task-category mapping and the independent PM model, gates, VCS mode, install command, and the project's ROADMAP/OWNERSHIP/AGENTS.md red lines), then runs the one command that writes `.pi/team/config.sh` + the `docs/team/` skeleton + the `AGENTS.md` protocol section and starts the pulse, and finally hands day-to-day operation to the `teamsmith` skill. Use when the user wants to bootstrap teamsmith into a new repository, set up a brand-new team, organize multiple agents into a team, or set up an agent collaboration protocol where none exists yet.
4
4
  license: MIT
5
5
  metadata:
6
- version: "0.4.3"
6
+ version: "0.4.5"
7
7
  ---
8
8
 
9
9
  # teamsmith-init · bring a new project to "ready to dispatch"