teamsmith 0.4.2 → 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 +1 -1
- package/skills/teamsmith/CHANGELOG.md +29 -0
- package/skills/teamsmith/SKILL.md +1 -1
- package/skills/teamsmith/extension/team-reply.ts +16 -2
- package/skills/teamsmith/scripts/lib/common.sh +1 -1
- package/skills/teamsmith/scripts/reply-capture.mjs +57 -9
- package/skills/teamsmith/tests/live-capture-probe.sh +53 -0
- package/skills/teamsmith-init/SKILL.md +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teamsmith",
|
|
3
|
-
"version": "0.4.
|
|
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,35 @@
|
|
|
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
|
+
|
|
28
|
+
## v0.4.3(2026-11-05)
|
|
29
|
+
|
|
30
|
+
让"回复没进编号回复页"这件事留下可查的原因。
|
|
31
|
+
|
|
32
|
+
- 扩展的诊断行不再只写 stderr(TUI 里看不见):同时追加到 `.pi/team/state/reply-capture/diagnostics.log`,超过 256 KB 保留最近 400 行。
|
|
33
|
+
- 收束时若判定当前会话不合格,会记一条 `ineligible-at-turn`,不再无声丢弃待发布的条目。
|
|
34
|
+
|
|
35
|
+
行为未变,只是把失败原因写下来。
|
|
36
|
+
|
|
8
37
|
## v0.4.2(2026-11-05)
|
|
9
38
|
|
|
10
39
|
修复续用旧会话的 PM 无法捕获关键回复:会话文件被过度严格的权限判据拒绝注册。
|
|
@@ -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.
|
|
6
|
+
version: "0.4.5"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# teamsmith · one agent that actually owns the project
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** PM-only, explicit live-message capture. No tools, provider hooks, history import, or automatic selection. */
|
|
2
2
|
import type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent'
|
|
3
3
|
import { createHash, randomUUID } from 'node:crypto'
|
|
4
|
-
import { readFileSync, realpathSync } from 'node:fs'
|
|
4
|
+
import { appendFileSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs'
|
|
5
5
|
import { dirname, join } from 'node:path'
|
|
6
6
|
import { fileURLToPath } from 'node:url'
|
|
7
7
|
import { isDeepStrictEqual } from 'node:util'
|
|
@@ -39,7 +39,21 @@ export default async function (pi: ExtensionAPI) {
|
|
|
39
39
|
})
|
|
40
40
|
const diagnostic = (d: { reason: string; entryId: string; path: string }) => {
|
|
41
41
|
// Never title/body/model text. Diagnostics are separate from the ordinary answer, including print/JSON modes.
|
|
42
|
-
|
|
42
|
+
const line = `[team-reply] ${d.reason}; source=${d.entryId || 'unbound'}; evidence=${d.path}\n`
|
|
43
|
+
process.stderr.write(line)
|
|
44
|
+
// A TUI swallows stderr, so the same line also lands beside the journal: without it a refused
|
|
45
|
+
// publication leaves no trace at all and the only symptom is a reply page that never grows.
|
|
46
|
+
try {
|
|
47
|
+
const state = registration?.state
|
|
48
|
+
if (!state) return
|
|
49
|
+
const file = join(state, 'reply-capture', 'diagnostics.log')
|
|
50
|
+
appendFileSync(file, `${new Date().toISOString()} ${line}`)
|
|
51
|
+
const stat = statSync(file)
|
|
52
|
+
if (stat.size > 256 * 1024) {
|
|
53
|
+
const kept = readFileSync(file, 'utf8').split('\n').slice(-400).join('\n')
|
|
54
|
+
writeFileSync(file, kept)
|
|
55
|
+
}
|
|
56
|
+
} catch { /* A diagnostic sink that cannot be written must not block cleanup. */ }
|
|
43
57
|
}
|
|
44
58
|
const runtime = (status: string, reason?: string) => {
|
|
45
59
|
if (!current()) return
|
|
@@ -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
|
-
|
|
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. */ }
|
|
@@ -372,10 +404,13 @@ export class ReplyCapture {
|
|
|
372
404
|
}
|
|
373
405
|
turn(event, view) {
|
|
374
406
|
const a = this.activity, latest = a?.latest
|
|
375
|
-
if (!latest?.intent || latest.entryId
|
|
407
|
+
if (!latest?.intent || latest.entryId) return
|
|
408
|
+
// A refused host used to drop the pending intent without a word; the only symptom was a reply page
|
|
409
|
+
// that never grew. Name it, with the same diagnostic sink that records a mismatched binding.
|
|
410
|
+
if (!this.eligibleHost(view)) { this.report('ineligible-at-turn'); return }
|
|
376
411
|
const entry = view.entry(event.messageEntryId)
|
|
377
|
-
if (!event.messageEntryId || entry?.type !== 'message' || !
|
|
378
|
-
!
|
|
412
|
+
if (!event.messageEntryId || entry?.type !== 'message' || !sameReplyMessage(entry.message, latest.message) ||
|
|
413
|
+
!sameReplyMessage(event.message, latest.message) || !branchWitness(view, a.startLeaf, event.messageEntryId)) {
|
|
379
414
|
latest.intent = null // A bad binding cannot be repaired by another event or current-leaf inference.
|
|
380
415
|
this.report('binding-mismatch', event.messageEntryId)
|
|
381
416
|
return
|
|
@@ -410,7 +445,8 @@ export class ReplyCapture {
|
|
|
410
445
|
}
|
|
411
446
|
reset() { this.activity = null }
|
|
412
447
|
recover(view) {
|
|
413
|
-
if (this.activity
|
|
448
|
+
if (this.activity) { this.report('recover-skip:busy'); return }
|
|
449
|
+
if (!this.eligibleHost(view)) { this.report('recover-skip:ineligible'); return }
|
|
414
450
|
let records
|
|
415
451
|
try {
|
|
416
452
|
records = this.journal.transact(snapshot => {
|
|
@@ -422,9 +458,17 @@ export class ReplyCapture {
|
|
|
422
458
|
record.reason = 'attempt-owner-exited'
|
|
423
459
|
}
|
|
424
460
|
}
|
|
425
|
-
|
|
461
|
+
const all = Object.values(snapshot.sources)
|
|
462
|
+
const keep = all.filter(record => record.status === 'eligible' &&
|
|
426
463
|
branchWitness(view, record.startLeaf, record.entryId, record.settledLeaf) &&
|
|
427
|
-
|
|
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
|
|
428
472
|
})
|
|
429
473
|
} catch (e) {
|
|
430
474
|
if (e.code !== 'ENOENT') this.report(`recovery:${e.code ?? e.name}`)
|
|
@@ -433,7 +477,10 @@ export class ReplyCapture {
|
|
|
433
477
|
for (const record of records) this.attempt(record, view)
|
|
434
478
|
}
|
|
435
479
|
attempt(record, view) {
|
|
436
|
-
if (this.activity || !this.eligibleHost(view))
|
|
480
|
+
if (this.activity || !this.eligibleHost(view)) {
|
|
481
|
+
this.report(this.activity ? 'attempt-busy' : 'attempt-ineligible', record.entryId)
|
|
482
|
+
return
|
|
483
|
+
}
|
|
437
484
|
const token = randomUUID()
|
|
438
485
|
const key = sourceKey(this.identity, record.entryId)
|
|
439
486
|
try {
|
|
@@ -444,7 +491,8 @@ export class ReplyCapture {
|
|
|
444
491
|
stored.attempt = { token, ...this.owner, at: new Date().toISOString() }
|
|
445
492
|
return true
|
|
446
493
|
})
|
|
447
|
-
if (!acquired
|
|
494
|
+
if (!acquired) { this.report('attempt-cas-lost', record.entryId); return }
|
|
495
|
+
if (!this.eligibleHost(view)) { this.report('attempt-ineligible', record.entryId); return }
|
|
448
496
|
} catch (e) { this.report(`attempting:${e.code ?? e.name}`, record.entryId); return }
|
|
449
497
|
// Durable CAS above is the barrier, including a crash right before this invocation.
|
|
450
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.
|
|
6
|
+
version: "0.4.5"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# teamsmith-init · bring a new project to "ready to dispatch"
|