teamsmith 0.4.0 → 0.4.1
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 +10 -0
- package/skills/teamsmith/SKILL.md +1 -1
- package/skills/teamsmith/scripts/lib/common.sh +1 -1
- package/skills/teamsmith/scripts/reply-capture.mjs +18 -2
- package/skills/teamsmith/tests/lib/pm-window.sh +25 -9
- package/skills/teamsmith/tests/reply-capture.mjs +139 -5
- 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.1",
|
|
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,16 @@
|
|
|
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.1(2026-11-05)
|
|
9
|
+
|
|
10
|
+
修复 0.4.0 的一处功能失效:关键回复在组可写的项目目录下从不注册。
|
|
11
|
+
|
|
12
|
+
- 目录安全检查原先拒绝任何“组可写且无 sticky 位”的祖先目录。个人项目常见的 775 布局(组就是本人)因此被判不安全,`[[team-reply]]` 标记不会被剥离、也不会进编号回复。
|
|
13
|
+
- 现在只拒绝“他人可写”,以及“组可写但该组不在本进程的有效组内”;sticky 位仍然放行。
|
|
14
|
+
- `team doctor` 的“关键回复运行”在未注册时给出目录与原因,不再只显示 `unknown`。
|
|
15
|
+
|
|
16
|
+
升级方式:在 Pi 中执行 `/reload`,或运行 `npm i -g teamsmith@0.4.1`。无需修改目录权限。
|
|
17
|
+
|
|
8
18
|
## v0.4.0(2026-11-04)
|
|
9
19
|
|
|
10
20
|
升级方式:在 Pi 中执行 `/reload`,或运行 `npm i -g teamsmith@0.4.0`。无配置迁移。
|
|
@@ -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.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# teamsmith · one agent that actually owns the project
|
|
@@ -172,9 +172,19 @@ export function processIdentity(pid) {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
/**
|
|
175
|
+
/** Groups this process can write as; a directory owned by one of them is not a foreign trust domain. */
|
|
176
|
+
const writableGroups = () => new Set([process.getgid(), process.getegid(), ...process.getgroups()])
|
|
177
|
+
/** Why a writable ancestor is unsafe: someone outside this process's groups can replace its entries. */
|
|
178
|
+
function foreignWriter(mode, gid, groups) {
|
|
179
|
+
if (mode & 0o1000) return '' // Sticky directories (system temp) protect entries the caller does not own.
|
|
180
|
+
if (mode & 0o002) return 'is other-writable'
|
|
181
|
+
if ((mode & 0o020) && !groups.has(gid)) return 'is group-writable outside the effective groups'
|
|
182
|
+
return ''
|
|
183
|
+
}
|
|
184
|
+
/** Canonical, nonsymlink ancestry. Sticky system temp parents are allowed; so are own-group 775 layouts. */
|
|
176
185
|
export function safeDirectory(path, create = false) {
|
|
177
186
|
if (!isAbsolute(path) || resolve(path) !== path) throw new Error('noncanonical directory')
|
|
187
|
+
const groups = writableGroups()
|
|
178
188
|
let at = sep
|
|
179
189
|
for (const part of path.split(sep).filter(Boolean)) {
|
|
180
190
|
at = join(at, part)
|
|
@@ -184,7 +194,9 @@ export function safeDirectory(path, create = false) {
|
|
|
184
194
|
mkdirSync(at, { mode: 0o700 })
|
|
185
195
|
st = lstatSync(at)
|
|
186
196
|
}
|
|
187
|
-
if (!st.isDirectory() || st.isSymbolicLink()
|
|
197
|
+
if (!st.isDirectory() || st.isSymbolicLink()) throw new Error(`unsafe directory ancestry: ${at} is not a plain directory`)
|
|
198
|
+
const unsafe = foreignWriter(st.mode, st.gid, groups)
|
|
199
|
+
if (unsafe) throw new Error(`unsafe directory ancestry: ${at} ${unsafe}`)
|
|
188
200
|
}
|
|
189
201
|
if (realpathSync(path) !== path) throw new Error('directory identity changed')
|
|
190
202
|
return path
|
|
@@ -578,6 +590,10 @@ export function captureDiskFingerprint(skill) {
|
|
|
578
590
|
export function inspectRuntime({ root, state, config, session, window, skill }) {
|
|
579
591
|
let disk
|
|
580
592
|
try { disk = captureDiskFingerprint(skill) } catch (e) { return { state: 'unknown', reason: `disk:${e.code ?? e.name}` } }
|
|
593
|
+
// A refused ancestry is the reason registration never happened, so name the directory and the rule.
|
|
594
|
+
try { safeDirectory(root); safeDirectory(state) } catch (e) {
|
|
595
|
+
if (e.code !== 'ENOENT') return { disk, state: 'unknown', reason: `not registered: ${e.message}` }
|
|
596
|
+
}
|
|
581
597
|
let runtime
|
|
582
598
|
try { runtime = JSON.parse(readRegular(join(state, 'reply-capture/runtime.json'))) }
|
|
583
599
|
catch (e) { return { disk, state: 'unknown', reason: `registration:${e.code ?? e.name}` } }
|
|
@@ -13,6 +13,22 @@
|
|
|
13
13
|
#
|
|
14
14
|
# 这里只放**读状态 / 等条件 / 造空窗**这类现场助手:它们不写账本、不碰真实项目,调用方必须已经把
|
|
15
15
|
# 身份钉在夹具仓库($REPO / $SESSION)里。段自己的夹具数据(假 pi 的 argv 日志、config 改写)留在段内。
|
|
16
|
+
#
|
|
17
|
+
# 为什么不裸调 tmux(P414):本文件会被 `--select` 单独裁进段副本,而静态 lint 不认「运行时套件装了
|
|
18
|
+
# tmux() 壳」这种背书(P173:通用名 `tmux` 不给同目录别的文件背书)——裸调用就是 RED。所以这里的每次
|
|
19
|
+
# tmux 调用都经**专用名** `pmw_tmux`:隔离写成文本里读得出的构造(`env -u TMUX` + 本轮私有
|
|
20
|
+
# `TMUX_TMPDIR`),变更类先过 P162 的三条件前置;缺私有目录就响失败,绝不回落调用者的默认 server。
|
|
21
|
+
pmw_tmux() { # <tmux argv…>:读写都打本轮私有 server(见上一段「为什么不裸调」)
|
|
22
|
+
[ -n "${TMUX_TMPDIR:-}" ] || { printf '✗ pm-window 夹具:TMUX_TMPDIR 未设 —— 拒绝回落调用者的默认 server\n' >&2; return 1; }
|
|
23
|
+
tmux_iso_argv_parse "$@"
|
|
24
|
+
if [ "${TMUX_ISO_ARGV_DESTRUCTIVE:-0}" = 1 ]; then pmw_tmux_require "$@" || return 1; fi
|
|
25
|
+
env -u TMUX -u TMUX_PANE TMUX_TMPDIR="${TMUX_TMPDIR}" tmux "$@"
|
|
26
|
+
}
|
|
27
|
+
pmw_tmux_require() { # <tmux argv…>:变更类的 P162 前置(与套件 tmux() 壳同一份判定;不成立 → 硬停)
|
|
28
|
+
tmux_iso_require "${SMOKE_SEC_OPEN_ID:-pm-window}" "PM 窗口现场:${1:-?}" \
|
|
29
|
+
--tmpdir "$TMUX_TMPDIR" --own-root "${TMP:-}" --own-root "${SMOKE_TMUX_OWN_ROOT:-}" \
|
|
30
|
+
--caller-tmpdir "${SMOKE_CALLER_TMUX_TMPDIR:-}"
|
|
31
|
+
}
|
|
16
32
|
|
|
17
33
|
# PM 窗口名:以项目配置为准(`team paths` 的 pm_window),解析不出才退回约定值 pm。
|
|
18
34
|
# 结果写进全局 PMW —— §11b / §11b2 / §11b3 一直按这个名字引用窗口。幂等:算过一次就复用,
|
|
@@ -63,7 +79,7 @@ wait_session_gone() { # <session> [最多等秒]
|
|
|
63
79
|
local s="${1:-}" secs="${2:-300}" i=0 ticks
|
|
64
80
|
ticks=$(( secs * 20 ))
|
|
65
81
|
while [ "$i" -lt "$ticks" ]; do
|
|
66
|
-
|
|
82
|
+
pmw_tmux has-session -t "$s" 2>/dev/null || return 0
|
|
67
83
|
sleep 0.05
|
|
68
84
|
i=$((i + 1))
|
|
69
85
|
done
|
|
@@ -73,7 +89,7 @@ wait_window_gone() { # <窗口名> [最多等秒](沿用夹具的 $SESSION)
|
|
|
73
89
|
local n="${1:-}" secs="${2:-300}" i=0 ticks
|
|
74
90
|
ticks=$(( secs * 20 ))
|
|
75
91
|
while [ "$i" -lt "$ticks" ]; do
|
|
76
|
-
|
|
92
|
+
pmw_tmux list-windows -t "$SESSION" -F '#{window_name}' 2>/dev/null | grep -qx "$n" || return 0
|
|
77
93
|
sleep 0.05
|
|
78
94
|
i=$((i + 1))
|
|
79
95
|
done
|
|
@@ -86,21 +102,21 @@ make_pm_idle() { # 让 PM 窗口回到**确定性**的空 shell(等 team_pm_
|
|
|
86
102
|
# session 本身可能还不存在:单独裁出来的段前面没有 §11b2「先 kill 再 new」那一步,而 tmux new-window
|
|
87
103
|
# 对不存在的 session 是直接失败 —— 于是窗口永远建不出来、状态停在 missing,这里白等 300s
|
|
88
104
|
# (P413 实测:`--select 11b4` 唯一的一条红就是这个)。场景助手要把场景备齐,判据不变。
|
|
89
|
-
if
|
|
90
|
-
|
|
105
|
+
if pmw_tmux has-session -t "$SESSION" 2>/dev/null; then
|
|
106
|
+
pmw_tmux new-window -t "$SESSION" -n keep -d -c "$REPO" >/dev/null 2>&1 || true
|
|
91
107
|
else
|
|
92
|
-
|
|
108
|
+
pmw_tmux new-session -d -s "$SESSION" -n keep -c "$REPO" >/dev/null 2>&1 || true
|
|
93
109
|
fi
|
|
94
|
-
|
|
110
|
+
pmw_tmux list-windows -t "$SESSION" -F '#{window_id} #{window_name}' 2>/dev/null \
|
|
95
111
|
| awk -v n="$PMW" '$2==n {print $1}' \
|
|
96
|
-
| while read -r wid; do [ -n "$wid" ] &&
|
|
112
|
+
| while read -r wid; do [ -n "$wid" ] && pmw_tmux kill-window -t "$wid" 2>/dev/null || true; done
|
|
97
113
|
# 窗口里跑**不带 rc 的 bash**(M35)——不是任何 profile 跑完后的登录 zsh。
|
|
98
114
|
# 实测(M35 注入实验):登录 zsh 的 profile(/etc/zsh/zprofile → distrobox 的 host-spawn)
|
|
99
115
|
# 在“提示符已出现”之后仍会间歇性起前台子进程;make_pm_idle 的两次采样可以落在空档里,而紧接着的
|
|
100
116
|
# 那一拍(§11b3 ⑤ 的 watch)撞上子进程,于是 attempts 行如实记成 state=unknown、断言 state=idle
|
|
101
117
|
# 假红(P18 B2、M34 复验两条实测)。`bash --noprofile --norc` 让“空提示符”变成**构造性**的:
|
|
102
118
|
# 没有 rc、没有异步子进程、cwd 由 tmux 的 -c 钉在 $REPO。
|
|
103
|
-
|
|
119
|
+
pmw_tmux new-window -t "$SESSION" -n "$PMW" -d -c "$REPO" bash --noprofile --norc >/dev/null 2>&1 || true
|
|
104
120
|
# 旧实现轮询 pane_current_command + sleep 0.5;只采样一次 team_pm_state 也不够:
|
|
105
121
|
# 窗口刚建好的一瞬间 pane 还没 exec 出前台命令,team_pm_state 会**假**报 idle(空 cmd),
|
|
106
122
|
# 紧接着启动命令就把它变成 unknown:*(§11b3 ⑤ 的 attempts 行正是这么记错的;注入 1.2s 的
|
|
@@ -109,7 +125,7 @@ make_pm_idle() { # 让 PM 窗口回到**确定性**的空 shell(等 team_pm_
|
|
|
109
125
|
local i=0 st="" cmd="" n=0
|
|
110
126
|
while [ "$i" -lt 600 ]; do
|
|
111
127
|
st="$(pm_state_now 2>/dev/null || true)"
|
|
112
|
-
cmd="$(
|
|
128
|
+
cmd="$(pmw_tmux display-message -p -t "$SESSION:$PMW" '#{pane_current_command}' 2>/dev/null || true)"
|
|
113
129
|
case "$st" in idle:*)
|
|
114
130
|
case "$cmd" in
|
|
115
131
|
zsh|bash|sh|dash|ash|ksh|fish)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/** Product parser/source evidence. All fixtures and mutations stay here, never in product code. */
|
|
3
3
|
import assert from 'node:assert/strict'
|
|
4
|
-
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync, rmSync, copyFileSync, existsSync, symlinkSync, openSync, closeSync, appendFileSync, constants as C } from 'node:fs'
|
|
4
|
+
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync, rmSync, copyFileSync, existsSync, symlinkSync, openSync, closeSync, appendFileSync, chmodSync, lstatSync, realpathSync, constants as C } from 'node:fs'
|
|
5
5
|
import { dirname, join, resolve } from 'node:path'
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
7
7
|
import { spawn, spawnSync } from 'node:child_process'
|
|
@@ -9,7 +9,7 @@ import { spawn, spawnSync } from 'node:child_process'
|
|
|
9
9
|
const here = dirname(fileURLToPath(import.meta.url))
|
|
10
10
|
const modulePath = process.env.TEST_CAPTURE_MODULE ?? resolve(here, '../scripts/reply-capture.mjs')
|
|
11
11
|
const product = await import(pathToFileURL(modulePath).href)
|
|
12
|
-
const { parseReply, CaptureJournal, ReplyCapture, runReplyWriter, processIdentity, sourceKey } = product
|
|
12
|
+
const { parseReply, CaptureJournal, ReplyCapture, runReplyWriter, processIdentity, sourceKey, safeDirectory, inspectRuntime, resolvePMIdentity } = product
|
|
13
13
|
const tests = []
|
|
14
14
|
const test = (name, run) => tests.push({ name, run })
|
|
15
15
|
const message = (text, extra = {}) => ({ role: 'assistant', content: [{ type: 'text', text }], stopReason: 'stop', timestamp: 1, ...extra })
|
|
@@ -522,6 +522,129 @@ for (const fault of ['kill:body-staged', 'kill:index-written', 'kill:index-durab
|
|
|
522
522
|
}))
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
+
// P415 · The ancestry refusal must name what it refuses, and an own-group 775 layout is not a foreign trust
|
|
526
|
+
// domain. Both sides run: the acceptance would go red under the stricter pre-P415 rule (see ancestryFlip).
|
|
527
|
+
const ancestryTests = []
|
|
528
|
+
const ancestry = (name, run) => ancestryTests.push({ name, run })
|
|
529
|
+
const ancestryTemp = () => realpathSync(mkdtempSync('/var/tmp/p415-ancestry.'))
|
|
530
|
+
const foreignGroups = () => {
|
|
531
|
+
const saved = [process.getgid, process.getegid, process.getgroups]
|
|
532
|
+
process.getgid = () => 0
|
|
533
|
+
process.getegid = () => 0
|
|
534
|
+
process.getgroups = () => [0]
|
|
535
|
+
return () => { [process.getgid, process.getegid, process.getgroups] = saved }
|
|
536
|
+
}
|
|
537
|
+
const refusal = (run, ...fragments) => {
|
|
538
|
+
try { run() } catch (e) {
|
|
539
|
+
assert.ok(e.message.startsWith('unsafe directory ancestry'), `expected an ancestry refusal, got: ${e.message}`)
|
|
540
|
+
for (const fragment of fragments) assert.ok(e.message.includes(fragment), `${fragment} missing from: ${e.message}`)
|
|
541
|
+
return e
|
|
542
|
+
}
|
|
543
|
+
return assert.fail('expected an ancestry refusal, the directory was accepted')
|
|
544
|
+
}
|
|
545
|
+
ancestry('0755 ancestry is accepted (baseline)', () => {
|
|
546
|
+
const root = ancestryTemp()
|
|
547
|
+
try { assert.equal(safeDirectory(root), root) } finally { rmSync(root, { recursive: true, force: true }) }
|
|
548
|
+
})
|
|
549
|
+
ancestry('0775 owned by this process group is accepted (this machine layout)', () => {
|
|
550
|
+
const root = ancestryTemp()
|
|
551
|
+
const dir = join(root, 'own-group')
|
|
552
|
+
try {
|
|
553
|
+
mkdirSync(dir); chmodSync(dir, 0o775)
|
|
554
|
+
assert.equal(lstatSync(dir).gid, process.getgid(), 'fixture premise: the directory belongs to this process group')
|
|
555
|
+
assert.equal(safeDirectory(dir), dir)
|
|
556
|
+
} finally { rmSync(root, { recursive: true, force: true }) }
|
|
557
|
+
})
|
|
558
|
+
ancestry('1777 sticky temp parent stays accepted', () => {
|
|
559
|
+
const root = ancestryTemp()
|
|
560
|
+
const dir = join(root, 'sticky')
|
|
561
|
+
try {
|
|
562
|
+
mkdirSync(dir); chmodSync(dir, 0o1777)
|
|
563
|
+
assert.equal(safeDirectory(dir), dir)
|
|
564
|
+
} finally { rmSync(root, { recursive: true, force: true }) }
|
|
565
|
+
})
|
|
566
|
+
ancestry('0777 other-writable ancestor is refused by path', () => {
|
|
567
|
+
const root = ancestryTemp()
|
|
568
|
+
const dir = join(root, 'open')
|
|
569
|
+
try {
|
|
570
|
+
mkdirSync(dir); chmodSync(dir, 0o777)
|
|
571
|
+
refusal(() => safeDirectory(dir), dir, 'is other-writable')
|
|
572
|
+
} finally { rmSync(root, { recursive: true, force: true }) }
|
|
573
|
+
})
|
|
574
|
+
ancestry('0775 owned by a group outside the process groups is refused by path', () => {
|
|
575
|
+
const root = ancestryTemp()
|
|
576
|
+
const dir = join(root, 'foreign-group')
|
|
577
|
+
try {
|
|
578
|
+
mkdirSync(dir); chmodSync(dir, 0o775)
|
|
579
|
+
const restore = foreignGroups()
|
|
580
|
+
try { refusal(() => safeDirectory(dir), dir, 'is group-writable outside the effective groups') } finally { restore() }
|
|
581
|
+
} finally { rmSync(root, { recursive: true, force: true }) }
|
|
582
|
+
})
|
|
583
|
+
ancestry('real git project: own-group 0775 resolves, 0777 root and 0777 state are refused', () => {
|
|
584
|
+
const root = ancestryTemp()
|
|
585
|
+
const state = join(root, '.pi/team/state'), config = join(root, '.pi/team/config.sh'), cwd = process.cwd()
|
|
586
|
+
const context = { cwd: root, sessionId: 'p415-fixture', sessionFile: join(root, 'session.jsonl') }
|
|
587
|
+
try {
|
|
588
|
+
assert.equal(spawnSync('git', ['init', '-q', '-b', 'main', root]).status, 0)
|
|
589
|
+
mkdirSync(state, { recursive: true })
|
|
590
|
+
writeFileSync(config, '# fixture\n')
|
|
591
|
+
writeFileSync(join(root, 'session.jsonl'), '')
|
|
592
|
+
chmodSync(root, 0o775)
|
|
593
|
+
process.chdir(root)
|
|
594
|
+
try {
|
|
595
|
+
// Own group: the ancestry passes and the same entry stops at the next fact it actually needs.
|
|
596
|
+
assert.throws(() => resolvePMIdentity(context, {}), e => e.message === 'missing directed PM launch environment')
|
|
597
|
+
chmodSync(root, 0o777)
|
|
598
|
+
refusal(() => resolvePMIdentity(context, {}), root)
|
|
599
|
+
chmodSync(root, 0o775); chmodSync(state, 0o777)
|
|
600
|
+
refusal(() => resolvePMIdentity(context, { TEAM_STATE_DIR: state, TEAM_CONFIG_FILE: config, TEAM_PM_WINDOW: 'pm', TEAM_SESSION: 'p415' }), state)
|
|
601
|
+
} finally { process.chdir(cwd) }
|
|
602
|
+
} finally { rmSync(root, { recursive: true, force: true }) }
|
|
603
|
+
})
|
|
604
|
+
ancestry('doctor reason names the directory and the rule, not an errno class', () => {
|
|
605
|
+
const root = ancestryTemp()
|
|
606
|
+
const state = join(root, '.pi/team/state'), config = join(root, '.pi/team/config.sh')
|
|
607
|
+
try {
|
|
608
|
+
mkdirSync(state, { recursive: true })
|
|
609
|
+
writeFileSync(config, '# fixture\n')
|
|
610
|
+
chmodSync(root, 0o775)
|
|
611
|
+
const args = { root, state, config, session: 'p415', window: 'pm', skill: resolve(here, '..') }
|
|
612
|
+
assert.equal(inspectRuntime(args).reason, 'registration:ENOENT', 'a missing registration is not a refusal')
|
|
613
|
+
const restore = foreignGroups()
|
|
614
|
+
try {
|
|
615
|
+
const refused = inspectRuntime(args)
|
|
616
|
+
assert.equal(refused.state, 'unknown')
|
|
617
|
+
assert.ok(refused.reason.startsWith('not registered: unsafe directory ancestry: '), `unexpected reason: ${refused.reason}`)
|
|
618
|
+
assert.ok(refused.reason.includes(root), `the refused directory is missing: ${refused.reason}`)
|
|
619
|
+
assert.ok(refused.reason.includes('is group-writable outside the effective groups'), `the rule is missing: ${refused.reason}`)
|
|
620
|
+
} finally { restore() }
|
|
621
|
+
} finally { rmSync(root, { recursive: true, force: true }) }
|
|
622
|
+
})
|
|
623
|
+
async function ancestryFlip() {
|
|
624
|
+
const root = mkdtempSync('/var/tmp/p415-flip.')
|
|
625
|
+
try {
|
|
626
|
+
const scripts = join(root, 'scripts'); mkdirSync(scripts)
|
|
627
|
+
copyFileSync(resolve(here, '../scripts/replies.mjs'), join(scripts, 'replies.mjs'))
|
|
628
|
+
const source = readFileSync(modulePath, 'utf8')
|
|
629
|
+
const anchor = " if (mode & 0o1000) return '' // Sticky directories (system temp) protect entries the caller does not own.\n" +
|
|
630
|
+
" if (mode & 0o002) return 'is other-writable'\n" +
|
|
631
|
+
" if ((mode & 0o020) && !groups.has(gid)) return 'is group-writable outside the effective groups'\n return ''"
|
|
632
|
+
assert.equal(source.split(anchor).length, 2, 'flip: unique target for the pre-P415 rule')
|
|
633
|
+
const target = join(scripts, 'reply-capture.mjs')
|
|
634
|
+
writeFileSync(target, source.replace(anchor, " return (mode & 0o022) && !(mode & 0o1000) ? 'is other-writable or group-writable' : ''"))
|
|
635
|
+
const red = spawnSync(process.execPath, [fileURLToPath(import.meta.url), '--select', 'ancestry'],
|
|
636
|
+
{ env: { ...process.env, TEST_CAPTURE_MODULE: target }, encoding: 'utf8' })
|
|
637
|
+
const lines = `${red.stdout}${red.stderr}`.split('\n')
|
|
638
|
+
assert.equal(red.status, 1, `pre-P415 rule must fail the acceptance: ${lines.join(' | ')}`)
|
|
639
|
+
const flipped = lines.find(line => line.startsWith('FAIL ') && line.includes('0775 owned by this process group'))
|
|
640
|
+
assert.ok(flipped, 'the own-group acceptance must be the assertion that goes red')
|
|
641
|
+
for (const kept of ['0777 other-writable ancestor is refused by path', '1777 sticky temp parent stays accepted']) {
|
|
642
|
+
assert.ok(lines.includes(`PASS ${kept}`), `the flip must not change the ${kept} verdict`)
|
|
643
|
+
assert.ok(!lines.some(line => line.startsWith('FAIL ') && line.includes(kept)), `the flip changed the ${kept} verdict`)
|
|
644
|
+
}
|
|
645
|
+
console.log(`PASS flip pre-P415 rule: own-group acceptance red (${flipped})`)
|
|
646
|
+
} finally { rmSync(root, { recursive: true, force: true }) }
|
|
647
|
+
}
|
|
525
648
|
// The shipped instruction surfaces print a concrete marker example. This group runs that printed text
|
|
526
649
|
// through the product parser and the real writer, so the promise "printed example works" is exercised
|
|
527
650
|
// rather than asserted about prose. A broken example must fail here (no vacuous pass).
|
|
@@ -593,10 +716,10 @@ if (args[0] === '--recover-child') { await recoverChild(args[1]); process.exit(0
|
|
|
593
716
|
if (args[0] === '--crash-child') crashChild(args[1], args[2])
|
|
594
717
|
let groups = ['parser']
|
|
595
718
|
if (args.length && args[0] !== '--all') {
|
|
596
|
-
if (args[0] !== '--select' || args.length !== 2) throw new Error('usage: reply-capture.mjs --all | --select parser,state,mutations,state-mutations (or --select example with TEST_EXAMPLE_FILE)')
|
|
719
|
+
if (args[0] !== '--select' || args.length !== 2) throw new Error('usage: reply-capture.mjs --all | --select parser,state,mutations,state-mutations,ancestry (or --select example with TEST_EXAMPLE_FILE)')
|
|
597
720
|
groups = args[1].split(',')
|
|
598
|
-
} else if (args[0] === '--all') groups = ['parser', 'state', 'mutations', 'state-mutations']
|
|
599
|
-
if (groups.some(g => !['parser', 'state', 'mutations', 'state-mutations', 'example'].includes(g))) throw new Error('unknown test group')
|
|
721
|
+
} else if (args[0] === '--all') groups = ['parser', 'state', 'mutations', 'state-mutations', 'ancestry']
|
|
722
|
+
if (groups.some(g => !['parser', 'state', 'mutations', 'state-mutations', 'ancestry', 'example'].includes(g))) throw new Error('unknown test group')
|
|
600
723
|
let passed = 0, failed = 0
|
|
601
724
|
if (groups.includes('parser')) for (const { name, run } of tests) {
|
|
602
725
|
try { await run(); passed++; console.log(`PASS ${name}`) }
|
|
@@ -614,6 +737,17 @@ if (groups.includes('state-mutations')) {
|
|
|
614
737
|
try { await stateMutations(); passed += 4 }
|
|
615
738
|
catch (e) { failed++; console.log(`FAIL state mutations: ${e.stack}`) }
|
|
616
739
|
}
|
|
740
|
+
if (groups.includes('ancestry')) {
|
|
741
|
+
for (const { name, run } of ancestryTests) {
|
|
742
|
+
try { await run(); passed++; console.log(`PASS ${name}`) }
|
|
743
|
+
catch (e) { failed++; console.log(`FAIL ${name}: ${e.stack}`) }
|
|
744
|
+
}
|
|
745
|
+
// The flip mutates the module under test, so it is meaningless again inside its own child run.
|
|
746
|
+
if (!process.env.TEST_CAPTURE_MODULE) {
|
|
747
|
+
try { await ancestryFlip(); passed++ }
|
|
748
|
+
catch (e) { failed++; console.log(`FAIL ancestry flip: ${e.stack}`) }
|
|
749
|
+
}
|
|
750
|
+
}
|
|
617
751
|
if (groups.includes('example')) {
|
|
618
752
|
try { await shippedExample(); passed += 1 }
|
|
619
753
|
catch (e) { failed++; console.log(`FAIL example: ${e.stack}`) }
|
|
@@ -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.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# teamsmith-init · bring a new project to "ready to dispatch"
|