feat(demo): anet demo science-team Phase 1 scaffold (refs #51)#53
Merged
Conversation
s2agi
pushed a commit
that referenced
this pull request
May 13, 2026
Follow-up polish for PR #53 per 通信demo马 review (task be6f9edf): L73 still pointed `RFC-008` at issue #51 (a stale placeholder from before the RFC file landed); L102 already had the correct relative path, this aligns L73. New commit (not amend) to preserve PR review chain since 通信牛 review is in flight. The intentional commit-body stale hash mention (`cherry-pick 542e5fa` in the cli scaffold commit message — actual cherry-pick became 9ab6092 after rebase) is left as archival noise; demo马 confirmed not worth amending. Refs #51 Author-Agent: 通信工程马 Helpers: 通信demo马 (review catch — L73 stale link)
Phase 1 scaffold per issue #51 + RFC-008. tmux-based only — Vincent 4303 correction: docker variant deferred to Phase 4+ backlog (not in this PR). cli.ts changes: - Add `demoScienceTeamCommand()` (~250 lines): - Wizard: Intern API key + 军团人数 (5-50, default 10) + 工作目录 (default ~/intern-s) + 综述方向 (7 presets including custom). - Auto register/login with default admin/anethub if no user token. - Per-node loop: process.chdir into <dir>/node<i>, build Profile manually, `ensureNodeToken` for ntok_, `saveProfile` writes config.json. Original cwd restored in finally clause. - Launch loop: tmux session `science-team-<alias>` per node. - Lifecycle: `--stop` kills tmux matching `science-team-*`; `--cleanup` adds `rm -rf <dir>/node*` + removes empty `<dir>`; `--restart` hints user to re-run create (full supervisor deferred to Phase 2). - Add dispatch case `"science-team"` and demoListCommand entry. - Profile interface widened with optional `systemPrompt` (used by all four demo commands but previously cast through), plus new RFC-008 fields `team` / `role` for Phase 2 leader fan-out logic to read. - saveProfile() toSave object now persists systemPrompt / team / role (per 通信牛 review catch — without these the placeholder systemPrompts and RFC-008 metadata are silently dropped from config.json, breaking the Phase 1 leader/researcher echo). Vendor preset (Vincent-verified per commit 1bc03c0 / issue #48 chain): runtime = claude-agent-sdk model = intern-s1-pro baseUrl = https://chat.intern-ai.org.cn (bare hostname, no /anthropic) token = $ANTHROPIC_AUTH_TOKEN (= user-supplied Intern API key) Phase 1 deliberately deferred (per issue #51 + RFC-008 spec): - Leader 智能 fan-out / sub-area assignment / aggregate (RFC-008 Phase 2). - Dashboard team 聚合视图 (issue #50). - Real academic systemPrompts (placeholders here). - In-place `--restart` supervisor. - Docker compose variant (Vincent 4303 — tmux-only this PR). Verified: - `npm run typecheck` passes after Profile widening + saveProfile() fix. - `bun bin/cli.ts demo` lists science-team alongside debate / socialmedia / pr-review. - `bun bin/cli.ts demo science-team --help` renders the full banner. Refs #51 (Vincent 4276+4279 GO; 4303 tmux-only correction) Author-Agent: 通信工程马 Helpers: 通信龙 (dispatch + runtime A confirm + Vincent 4303 scope correction + review), 通信SDK马 (RFC-008 spec author), 通信牛 (saveProfile() persistence bug catch), Vincent (issue raise 4237-4279 chain + Intern verify 4227 + tmux-only correction 4303)
8968421 to
5e2bb9c
Compare
s2agi
pushed a commit
that referenced
this pull request
May 13, 2026
Two related fixes for the Phase 1 team-scale demo:
1. **Rename science-team → sci-team** per Vincent 4319 ("换个名字吧 demo
叫 sci-team"). Affects all user-facing surfaces:
- `anet demo` dispatch case
- `anet demo ls` entry
- `anet demo sci-team --help` banner + flag descriptions
- tmux session prefix (`sci-team-<alias>`)
- lifecycle prompts ("kill sci-team-*", "清理完成", etc.)
- config.json `team` field default value
Internal identifiers (`demoSciTeamCommand`, `SCI_TEAM_DIRECTIONS`,
`sciTeamPlaceholderPrompt`, `sciTeamLifecycle`) renamed for consistency.
2. **Vincent 4317** reported `anet demo science-team` returning "Unknown
demo" after installing 2.1.8-preview.4. Source had the dispatch case
correctly (commit a3e6e3a from PR #53), so this was a publish-pipeline
issue, not a registration gap: the published preview.4 dist/bin/cli.js
was built from a stale tree before #53 merged (`strings dist/bin/cli.js
| grep science` returned zero matches; PR #46/#48 obfuscated identifiers
were present, confirming the dist was older than the merged source).
No source change required for the registration itself — the next
release (preview.5) just needs a fresh `npm run build` from current
main before publishing. SDK马 to bump + publish per the standard SOP.
Backward compat: no alias kept for `science-team` because preview.4 was
broken end-to-end (Vincent's report = it didn't work), so no real users
have config.json with `team: "science-team"`. Clean rename.
Verified locally:
- `npm run typecheck` passes (29 identifier touches, all updated).
- `bun bin/cli.ts demo` lists `sci-team` (not science-team).
- `bun bin/cli.ts demo sci-team --help` renders the full banner.
- `bun bin/cli.ts demo science-team` now responds "Unknown demo" (rename
is clean — old string is no longer registered).
Refs #51 (Vincent 4317 broken + 4319 rename)
Author-Agent: 通信工程马
Helpers: 通信龙 (dispatch + Vincent relay), Vincent (4317 broken report + 4319 rename + 4227 Intern verify chain)
s2agi
pushed a commit
that referenced
this pull request
May 13, 2026
…<verb> (refs #55) Issue #55 + Vincent 4335 lifted hold: add a generic `anet create --batch` wizard that batch-spawns N agents under a working directory, plus an `anet batch <verb> <prefix>` top-level lifecycle command set. The existing `anet demo sci-team` is refactored into a preset wrapper over the new primitive (PR #53's user-facing surface stays bit-identical). ## What's new ### `createBatch(options)` helper (~150 LOC) Generic N-node spawn primitive used by both `anet create --batch` and `anet demo sci-team`. Handles: - per-node mkdir (workdir-mode `separate` = `<workdir>/node{i}` / `shared` = single dir) - Profile build + `ensureNodeToken` (ntok_) + `saveProfile` - tmux session launch with `${team || prefix}-${alias}` naming - `process.chdir` restored in `finally` block so the caller's cwd is preserved - Two-pass loop (configs first, tmux launches second) so a partial-config failure doesn't leave half-started tmux sessions ### `batchLifecycle({ prefix, verb, workdir? })` helper (~80 LOC) Verbs: - `stop` — kill any tmux session matching `${prefix}-*` - `cleanup` — `stop` + `rm -rf <workdir>/node*` + remove empty `<workdir>` - `restart` / `start` — Phase 1 scaffold hint (re-run create wizard); in-place re-launch deferred to Phase 2 (would need to walk saved `.anet/nodes/<alias>/config.json` under each `<workdir>/node*` and re-spawn the tmux sessions) - `list` — group all tmux sessions by first `-` separator (Phase 1 known limitation: catches non-anet sessions whose names contain `-`; future improvement is a `~/.anet/batches.json` marker registry, deferred) ### CLI surfaces 1. `anet create --batch` wizard (5 prompts): - **Model preset** (Vincent-verified list, 1bc03c0 chain): intern-s1-pro / MiniMax-M2.7 / claude-sonnet-4-6 / claude-opus-4-6 / claude-haiku-4-5 / `__custom__`. Codex preset deliberately excluded — not yet verified, follow-up issue planned. - API key (ANTHROPIC_AUTH_TOKEN or runtime-equivalent) - Workdir + workdir-mode - Prefix + count (1-50, stderr warning when count > 20 per [[feedback_runtime_warning_count_high]]) - Description (systemPrompt) + optional `--leader-alias` (opt-in) 2. `anet batch <verb> <prefix>` top-level lifecycle (mirrors `anet hub`, `anet node`, `anet network` style — Decision A1 from scope review). 3. `anet demo sci-team` refactored to internally call `createBatch` with the sci-team preset (intern URL/model + sciTeamPrompt active fan-out template + `leaderAlias="研究Leader"` + `team="sci-team"`). User-facing wizard surface unchanged — backward compat for preview.5+ docs and demo videos. 4. Deprecation: `anet demo sci-team --stop|--restart|--cleanup` now prints a stderr deprecation warning pointing at the canonical `anet batch <verb> sci-team`. One-release-cycle grace per Decision D1. ## Verified locally (sandbox HOME, never touched 47.116.5.73) - `npm run typecheck` passes (504-line diff, no TS errors). - `bun bin/cli.ts create --batch --help` renders full banner with all flags. - `bun bin/cli.ts batch` renders verb list. - `bun bin/cli.ts batch list` enumerates host tmux session groups (limitation noted in help: catches non-anet groups). - `bun bin/cli.ts batch stop` without prefix → friendly usage error. - `bun bin/cli.ts demo sci-team --help` unchanged. - `bun bin/cli.ts demo sci-team --stop` → deprecation stderr + delegates to `batchLifecycle({ prefix: "sci-team", verb: "stop" })`. - End-to-end: spawned local commhub-server on :9897 + ran `create --batch --preset claude-haiku-4-5 --prefix 工程师 --count 3`: - 3 tmux sessions created (`工程师-工程师1号` .. `工程师-工程师3号`) - `<workdir>/node{1..3}/.anet/nodes/工程师{i}号/config.json` written with correct runtime / model / token / env / systemPrompt - `anet batch list` grouped them under `工程师 (3 node)` - `anet batch stop 工程师` killed all 3 tmux sessions cleanly ## Out of scope for this PR - Codex preset (model id + signup URL un-verified — follow-up issue) - In-place `anet batch restart` / `start` supervisor (Phase 2) - Cross-batch task routing (Phase 3+) - Multi-prefix protected lifecycle list filter (Phase 2) ## Scope creep defenses honored - Single file touched (`agent-network/bin/cli.ts`) - No new vendor / runtime / endpoint introduced - No new scaffold mode (tmux only, per Vincent 4303) - commhub-server / agent-node / demos untouched Refs #55 (Vincent 4335 lifted hold) Author-Agent: 通信工程马 Helpers: 通信龙 (Option C 分层 propose + dispatch + 7 decision A1/B1/C/D1/E/F3/G ack + 2 nit drop-codex + count>20 warning + review), Vincent (issue raise + 4335 lifted hold)
s2agi
pushed a commit
that referenced
this pull request
May 13, 2026
…<verb> (refs #55) Issue #55 + Vincent 4335 lifted hold: add a generic `anet create --batch` wizard that batch-spawns N agents under a working directory, plus an `anet batch <verb> <prefix>` top-level lifecycle command set. The existing `anet demo sci-team` is refactored into a preset wrapper over the new primitive (PR #53's user-facing surface stays bit-identical). ## What's new ### `createBatch(options)` helper (~150 LOC) Generic N-node spawn primitive used by both `anet create --batch` and `anet demo sci-team`. Handles: - per-node mkdir (workdir-mode `separate` = `<workdir>/node{i}` / `shared` = single dir) - Profile build + `ensureNodeToken` (ntok_) + `saveProfile` - tmux session launch with `${team || prefix}-${alias}` naming - `process.chdir` restored in `finally` block so the caller's cwd is preserved - Two-pass loop (configs first, tmux launches second) so a partial-config failure doesn't leave half-started tmux sessions ### `batchLifecycle({ prefix, verb, workdir? })` helper (~80 LOC) Verbs: - `stop` — kill any tmux session matching `${prefix}-*` - `cleanup` — `stop` + `rm -rf <workdir>/node*` + remove empty `<workdir>` - `restart` / `start` — Phase 1 scaffold hint (re-run create wizard); in-place re-launch deferred to Phase 2 (would need to walk saved `.anet/nodes/<alias>/config.json` under each `<workdir>/node*` and re-spawn the tmux sessions) - `list` — group all tmux sessions by first `-` separator (Phase 1 known limitation: catches non-anet sessions whose names contain `-`; future improvement is a `~/.anet/batches.json` marker registry, deferred) ### CLI surfaces 1. `anet create --batch` wizard (5 prompts): - **Model preset** (Vincent-verified list, 1bc03c0 chain): intern-s1-pro / MiniMax-M2.7 / claude-sonnet-4-6 / claude-opus-4-6 / claude-haiku-4-5 / `__custom__`. Codex preset deliberately excluded — not yet verified, follow-up issue planned. - API key (ANTHROPIC_AUTH_TOKEN or runtime-equivalent) - Workdir + workdir-mode - Prefix + count (1-50, stderr warning when count > 20 per [[feedback_runtime_warning_count_high]]) - Description (systemPrompt) + optional `--leader-alias` (opt-in) 2. `anet batch <verb> <prefix>` top-level lifecycle (mirrors `anet hub`, `anet node`, `anet network` style — Decision A1 from scope review). 3. `anet demo sci-team` refactored to internally call `createBatch` with the sci-team preset (intern URL/model + sciTeamPrompt active fan-out template + `leaderAlias="研究Leader"` + `team="sci-team"`). User-facing wizard surface unchanged — backward compat for preview.5+ docs and demo videos. 4. Deprecation: `anet demo sci-team --stop|--restart|--cleanup` now prints a stderr deprecation warning pointing at the canonical `anet batch <verb> sci-team`. One-release-cycle grace per Decision D1. ## Verified locally (sandbox HOME, never touched 47.116.5.73) - `npm run typecheck` passes (504-line diff, no TS errors). - `bun bin/cli.ts create --batch --help` renders full banner with all flags. - `bun bin/cli.ts batch` renders verb list. - `bun bin/cli.ts batch list` enumerates host tmux session groups (limitation noted in help: catches non-anet groups). - `bun bin/cli.ts batch stop` without prefix → friendly usage error. - `bun bin/cli.ts demo sci-team --help` unchanged. - `bun bin/cli.ts demo sci-team --stop` → deprecation stderr + delegates to `batchLifecycle({ prefix: "sci-team", verb: "stop" })`. - End-to-end: spawned local commhub-server on :9897 + ran `create --batch --preset claude-haiku-4-5 --prefix 工程师 --count 3`: - 3 tmux sessions created (`工程师-工程师1号` .. `工程师-工程师3号`) - `<workdir>/node{1..3}/.anet/nodes/工程师{i}号/config.json` written with correct runtime / model / token / env / systemPrompt - `anet batch list` grouped them under `工程师 (3 node)` - `anet batch stop 工程师` killed all 3 tmux sessions cleanly ## Out of scope for this PR - Codex preset (model id + signup URL un-verified — follow-up issue) - In-place `anet batch restart` / `start` supervisor (Phase 2) - Cross-batch task routing (Phase 3+) - Multi-prefix protected lifecycle list filter (Phase 2) ## Scope creep defenses honored - Single file touched (`agent-network/bin/cli.ts`) - No new vendor / runtime / endpoint introduced - No new scaffold mode (tmux only, per Vincent 4303) - commhub-server / agent-node / demos untouched Refs #55 (Vincent 4335 lifted hold) Author-Agent: 通信工程马 Helpers: 通信龙 (Option C 分层 propose + dispatch + 7 decision A1/B1/C/D1/E/F3/G ack + 2 nit drop-codex + count>20 warning + review), Vincent (issue raise + 4335 lifted hold)
s2agi
pushed a commit
that referenced
this pull request
May 13, 2026
…<verb> (refs #55) Issue #55 + Vincent 4335 lifted hold: add a generic `anet create --batch` wizard that batch-spawns N agents under a working directory, plus an `anet batch <verb> <prefix>` top-level lifecycle command set. The existing `anet demo sci-team` is refactored into a preset wrapper over the new primitive (PR #53's user-facing surface stays bit-identical). ## What's new ### `createBatch(options)` helper (~150 LOC) Generic N-node spawn primitive used by both `anet create --batch` and `anet demo sci-team`. Handles: - per-node mkdir (workdir-mode `separate` = `<workdir>/node{i}` / `shared` = single dir) - Profile build + `ensureNodeToken` (ntok_) + `saveProfile` - tmux session launch with `${team || prefix}-${alias}` naming - `process.chdir` restored in `finally` block so the caller's cwd is preserved - Two-pass loop (configs first, tmux launches second) so a partial-config failure doesn't leave half-started tmux sessions ### `batchLifecycle({ prefix, verb, workdir? })` helper (~80 LOC) Verbs: - `stop` — kill any tmux session matching `${prefix}-*` - `cleanup` — `stop` + `rm -rf <workdir>/node*` + remove empty `<workdir>` - `restart` / `start` — Phase 1 scaffold hint (re-run create wizard); in-place re-launch deferred to Phase 2 (would need to walk saved `.anet/nodes/<alias>/config.json` under each `<workdir>/node*` and re-spawn the tmux sessions) - `list` — group all tmux sessions by first `-` separator (Phase 1 known limitation: catches non-anet sessions whose names contain `-`; future improvement is a `~/.anet/batches.json` marker registry, deferred) ### CLI surfaces 1. `anet create --batch` wizard (5 prompts): - **Model preset** (Vincent-verified list, 1bc03c0 chain): intern-s1-pro / MiniMax-M2.7 / claude-sonnet-4-6 / claude-opus-4-6 / claude-haiku-4-5 / `__custom__`. Codex preset deliberately excluded — not yet verified, follow-up issue planned. - API key (ANTHROPIC_AUTH_TOKEN or runtime-equivalent) - Workdir + workdir-mode - Prefix + count (1-50, stderr warning when count > 20 per [[feedback_runtime_warning_count_high]]) - Description (systemPrompt) + optional `--leader-alias` (opt-in) 2. `anet batch <verb> <prefix>` top-level lifecycle (mirrors `anet hub`, `anet node`, `anet network` style — Decision A1 from scope review). 3. `anet demo sci-team` refactored to internally call `createBatch` with the sci-team preset (intern URL/model + sciTeamPrompt active fan-out template + `leaderAlias="研究Leader"` + `team="sci-team"`). User-facing wizard surface unchanged — backward compat for preview.5+ docs and demo videos. 4. Deprecation: `anet demo sci-team --stop|--restart|--cleanup` now prints a stderr deprecation warning pointing at the canonical `anet batch <verb> sci-team`. One-release-cycle grace per Decision D1. ## Verified locally (sandbox HOME, never touched 47.116.5.73) - `npm run typecheck` passes (504-line diff, no TS errors). - `bun bin/cli.ts create --batch --help` renders full banner with all flags. - `bun bin/cli.ts batch` renders verb list. - `bun bin/cli.ts batch list` enumerates host tmux session groups (limitation noted in help: catches non-anet groups). - `bun bin/cli.ts batch stop` without prefix → friendly usage error. - `bun bin/cli.ts demo sci-team --help` unchanged. - `bun bin/cli.ts demo sci-team --stop` → deprecation stderr + delegates to `batchLifecycle({ prefix: "sci-team", verb: "stop" })`. - End-to-end: spawned local commhub-server on :9897 + ran `create --batch --preset claude-haiku-4-5 --prefix 工程师 --count 3`: - 3 tmux sessions created (`工程师-工程师1号` .. `工程师-工程师3号`) - `<workdir>/node{1..3}/.anet/nodes/工程师{i}号/config.json` written with correct runtime / model / token / env / systemPrompt - `anet batch list` grouped them under `工程师 (3 node)` - `anet batch stop 工程师` killed all 3 tmux sessions cleanly ## Out of scope for this PR - Codex preset (model id + signup URL un-verified — follow-up issue) - In-place `anet batch restart` / `start` supervisor (Phase 2) - Cross-batch task routing (Phase 3+) - Multi-prefix protected lifecycle list filter (Phase 2) ## Scope creep defenses honored - Single file touched (`agent-network/bin/cli.ts`) - No new vendor / runtime / endpoint introduced - No new scaffold mode (tmux only, per Vincent 4303) - commhub-server / agent-node / demos untouched Refs #55 (Vincent 4335 lifted hold) Author-Agent: 通信工程马 Helpers: 通信龙 (Option C 分层 propose + dispatch + 7 decision A1/B1/C/D1/E/F3/G ack + 2 nit drop-codex + count>20 warning + review), Vincent (issue raise + 4335 lifted hold)
s2agi
pushed a commit
that referenced
this pull request
May 13, 2026
…<verb> (refs #55) Issue #55 + Vincent 4335 lifted hold: add a generic `anet create --batch` wizard that batch-spawns N agents under a working directory, plus an `anet batch <verb> <prefix>` top-level lifecycle command set. The existing `anet demo sci-team` is refactored into a preset wrapper over the new primitive (PR #53's user-facing surface stays bit-identical). ## What's new ### `createBatch(options)` helper (~150 LOC) Generic N-node spawn primitive used by both `anet create --batch` and `anet demo sci-team`. Handles: - per-node mkdir (workdir-mode `separate` = `<workdir>/node{i}` / `shared` = single dir) - Profile build + `ensureNodeToken` (ntok_) + `saveProfile` - tmux session launch with `${team || prefix}-${alias}` naming - `process.chdir` restored in `finally` block so the caller's cwd is preserved - Two-pass loop (configs first, tmux launches second) so a partial-config failure doesn't leave half-started tmux sessions ### `batchLifecycle({ prefix, verb, workdir? })` helper (~80 LOC) Verbs: - `stop` — kill any tmux session matching `${prefix}-*` - `cleanup` — `stop` + `rm -rf <workdir>/node*` + remove empty `<workdir>` - `restart` / `start` — Phase 1 scaffold hint (re-run create wizard); in-place re-launch deferred to Phase 2 (would need to walk saved `.anet/nodes/<alias>/config.json` under each `<workdir>/node*` and re-spawn the tmux sessions) - `list` — group all tmux sessions by first `-` separator (Phase 1 known limitation: catches non-anet sessions whose names contain `-`; future improvement is a `~/.anet/batches.json` marker registry, deferred) ### CLI surfaces 1. `anet create --batch` wizard (5 prompts): - **Model preset** (Vincent-verified list, 1bc03c0 chain): intern-s1-pro / MiniMax-M2.7 / claude-sonnet-4-6 / claude-opus-4-6 / claude-haiku-4-5 / `__custom__`. Codex preset deliberately excluded — not yet verified, follow-up issue planned. - API key (ANTHROPIC_AUTH_TOKEN or runtime-equivalent) - Workdir + workdir-mode - Prefix + count (1-50, stderr warning when count > 20 per [[feedback_runtime_warning_count_high]]) - Description (systemPrompt) + optional `--leader-alias` (opt-in) 2. `anet batch <verb> <prefix>` top-level lifecycle (mirrors `anet hub`, `anet node`, `anet network` style — Decision A1 from scope review). 3. `anet demo sci-team` refactored to internally call `createBatch` with the sci-team preset (intern URL/model + sciTeamPrompt active fan-out template + `leaderAlias="研究Leader"` + `team="sci-team"`). User-facing wizard surface unchanged — backward compat for preview.5+ docs and demo videos. 4. Deprecation: `anet demo sci-team --stop|--restart|--cleanup` now prints a stderr deprecation warning pointing at the canonical `anet batch <verb> sci-team`. One-release-cycle grace per Decision D1. ## Verified locally (sandbox HOME, never touched 47.116.5.73) - `npm run typecheck` passes (504-line diff, no TS errors). - `bun bin/cli.ts create --batch --help` renders full banner with all flags. - `bun bin/cli.ts batch` renders verb list. - `bun bin/cli.ts batch list` enumerates host tmux session groups (limitation noted in help: catches non-anet groups). - `bun bin/cli.ts batch stop` without prefix → friendly usage error. - `bun bin/cli.ts demo sci-team --help` unchanged. - `bun bin/cli.ts demo sci-team --stop` → deprecation stderr + delegates to `batchLifecycle({ prefix: "sci-team", verb: "stop" })`. - End-to-end: spawned local commhub-server on :9897 + ran `create --batch --preset claude-haiku-4-5 --prefix 工程师 --count 3`: - 3 tmux sessions created (`工程师-工程师1号` .. `工程师-工程师3号`) - `<workdir>/node{1..3}/.anet/nodes/工程师{i}号/config.json` written with correct runtime / model / token / env / systemPrompt - `anet batch list` grouped them under `工程师 (3 node)` - `anet batch stop 工程师` killed all 3 tmux sessions cleanly ## Out of scope for this PR - Codex preset (model id + signup URL un-verified — follow-up issue) - In-place `anet batch restart` / `start` supervisor (Phase 2) - Cross-batch task routing (Phase 3+) - Multi-prefix protected lifecycle list filter (Phase 2) ## Scope creep defenses honored - Single file touched (`agent-network/bin/cli.ts`) - No new vendor / runtime / endpoint introduced - No new scaffold mode (tmux only, per Vincent 4303) - commhub-server / agent-node / demos untouched Refs #55 (Vincent 4335 lifted hold) Author-Agent: 通信工程马 Helpers: 通信龙 (Option C 分层 propose + dispatch + 7 decision A1/B1/C/D1/E/F3/G ack + 2 nit drop-codex + count>20 warning + review), Vincent (issue raise + 4335 lifted hold)
s2agi
pushed a commit
that referenced
this pull request
May 13, 2026
…<verb> (refs #55) Issue #55 + Vincent 4335 lifted hold: add a generic `anet create --batch` wizard that batch-spawns N agents under a working directory, plus an `anet batch <verb> <prefix>` top-level lifecycle command set. The existing `anet demo sci-team` is refactored into a preset wrapper over the new primitive (PR #53's user-facing surface stays bit-identical). ## What's new ### `createBatch(options)` helper (~150 LOC) Generic N-node spawn primitive used by both `anet create --batch` and `anet demo sci-team`. Handles: - per-node mkdir (workdir-mode `separate` = `<workdir>/node{i}` / `shared` = single dir) - Profile build + `ensureNodeToken` (ntok_) + `saveProfile` - tmux session launch with `${team || prefix}-${alias}` naming - `process.chdir` restored in `finally` block so the caller's cwd is preserved - Two-pass loop (configs first, tmux launches second) so a partial-config failure doesn't leave half-started tmux sessions ### `batchLifecycle({ prefix, verb, workdir? })` helper (~80 LOC) Verbs: - `stop` — kill any tmux session matching `${prefix}-*` - `cleanup` — `stop` + `rm -rf <workdir>/node*` + remove empty `<workdir>` - `restart` / `start` — Phase 1 scaffold hint (re-run create wizard); in-place re-launch deferred to Phase 2 (would need to walk saved `.anet/nodes/<alias>/config.json` under each `<workdir>/node*` and re-spawn the tmux sessions) - `list` — group all tmux sessions by first `-` separator (Phase 1 known limitation: catches non-anet sessions whose names contain `-`; future improvement is a `~/.anet/batches.json` marker registry, deferred) ### CLI surfaces 1. `anet create --batch` wizard (5 prompts): - **Model preset** (Vincent-verified list, 1bc03c0 chain): intern-s1-pro / MiniMax-M2.7 / claude-sonnet-4-6 / claude-opus-4-6 / claude-haiku-4-5 / `__custom__`. Codex preset deliberately excluded — not yet verified, follow-up issue planned. - API key (ANTHROPIC_AUTH_TOKEN or runtime-equivalent) - Workdir + workdir-mode - Prefix + count (1-50, stderr warning when count > 20 per [[feedback_runtime_warning_count_high]]) - Description (systemPrompt) + optional `--leader-alias` (opt-in) 2. `anet batch <verb> <prefix>` top-level lifecycle (mirrors `anet hub`, `anet node`, `anet network` style — Decision A1 from scope review). 3. `anet demo sci-team` refactored to internally call `createBatch` with the sci-team preset (intern URL/model + sciTeamPrompt active fan-out template + `leaderAlias="研究Leader"` + `team="sci-team"`). User-facing wizard surface unchanged — backward compat for preview.5+ docs and demo videos. 4. Deprecation: `anet demo sci-team --stop|--restart|--cleanup` now prints a stderr deprecation warning pointing at the canonical `anet batch <verb> sci-team`. One-release-cycle grace per Decision D1. ## Verified locally (sandbox HOME, never touched 47.116.5.73) - `npm run typecheck` passes (504-line diff, no TS errors). - `bun bin/cli.ts create --batch --help` renders full banner with all flags. - `bun bin/cli.ts batch` renders verb list. - `bun bin/cli.ts batch list` enumerates host tmux session groups (limitation noted in help: catches non-anet groups). - `bun bin/cli.ts batch stop` without prefix → friendly usage error. - `bun bin/cli.ts demo sci-team --help` unchanged. - `bun bin/cli.ts demo sci-team --stop` → deprecation stderr + delegates to `batchLifecycle({ prefix: "sci-team", verb: "stop" })`. - End-to-end: spawned local commhub-server on :9897 + ran `create --batch --preset claude-haiku-4-5 --prefix 工程师 --count 3`: - 3 tmux sessions created (`工程师-工程师1号` .. `工程师-工程师3号`) - `<workdir>/node{1..3}/.anet/nodes/工程师{i}号/config.json` written with correct runtime / model / token / env / systemPrompt - `anet batch list` grouped them under `工程师 (3 node)` - `anet batch stop 工程师` killed all 3 tmux sessions cleanly ## Out of scope for this PR - Codex preset (model id + signup URL un-verified — follow-up issue) - In-place `anet batch restart` / `start` supervisor (Phase 2) - Cross-batch task routing (Phase 3+) - Multi-prefix protected lifecycle list filter (Phase 2) ## Scope creep defenses honored - Single file touched (`agent-network/bin/cli.ts`) - No new vendor / runtime / endpoint introduced - No new scaffold mode (tmux only, per Vincent 4303) - commhub-server / agent-node / demos untouched Refs #55 (Vincent 4335 lifted hold) Refs: #63 #64 #65 (test infra debt tracker — pre-existing rot exposed by lockfile fix, 测试马 triage) Author-Agent: 通信工程马 Helpers: 通信龙 (Option C 分层 propose + dispatch + 7 decision A1/B1/C/D1/E/F3/G ack + 2 nit drop-codex + count>20 warning + review), Vincent (issue raise + 4335 lifted hold)
s2agi
added a commit
that referenced
this pull request
May 13, 2026
…<verb> (closes #55) Issue #55 + Vincent 4335 lifted hold: add a generic `anet create --batch` wizard that batch-spawns N agents under a working directory, plus an `anet batch <verb> <prefix>` top-level lifecycle command set. The existing `anet demo sci-team` is refactored into a preset wrapper over the new primitive (PR #53's user-facing surface stays bit-identical). ## What's new ### `createBatch(options)` helper (~150 LOC) Generic N-node spawn primitive used by both `anet create --batch` and `anet demo sci-team`. Handles: - per-node mkdir (workdir-mode `separate` = `<workdir>/node{i}` / `shared` = single dir) - Profile build + `ensureNodeToken` (ntok_) + `saveProfile` - tmux session launch with `${team || prefix}-${alias}` naming - `process.chdir` restored in `finally` block so the caller's cwd is preserved - Two-pass loop (configs first, tmux launches second) so a partial-config failure doesn't leave half-started tmux sessions ### `batchLifecycle({ prefix, verb, workdir? })` helper (~80 LOC) Verbs: - `stop` — kill any tmux session matching `${prefix}-*` - `cleanup` — `stop` + `rm -rf <workdir>/node*` + remove empty `<workdir>` - `restart` / `start` — Phase 1 scaffold hint (re-run create wizard); in-place re-launch deferred to Phase 2 (would need to walk saved `.anet/nodes/<alias>/config.json` under each `<workdir>/node*` and re-spawn the tmux sessions) - `list` — group all tmux sessions by first `-` separator (Phase 1 known limitation: catches non-anet sessions whose names contain `-`; future improvement is a `~/.anet/batches.json` marker registry, deferred) ### CLI surfaces 1. `anet create --batch` wizard (5 prompts): - **Model preset** (Vincent-verified list, 1bc03c0 chain): intern-s1-pro / MiniMax-M2.7 / claude-sonnet-4-6 / claude-opus-4-6 / claude-haiku-4-5 / `__custom__`. Codex preset deliberately excluded — not yet verified, follow-up issue planned. - API key (ANTHROPIC_AUTH_TOKEN or runtime-equivalent) - Workdir + workdir-mode - Prefix + count (1-50, stderr warning when count > 20 per [[feedback_runtime_warning_count_high]]) - Description (systemPrompt) + optional `--leader-alias` (opt-in) 2. `anet batch <verb> <prefix>` top-level lifecycle (mirrors `anet hub`, `anet node`, `anet network` style — Decision A1 from scope review). 3. `anet demo sci-team` refactored to internally call `createBatch` with the sci-team preset (intern URL/model + sciTeamPrompt active fan-out template + `leaderAlias="研究Leader"` + `team="sci-team"`). User-facing wizard surface unchanged — backward compat for preview.5+ docs and demo videos. 4. Deprecation: `anet demo sci-team --stop|--restart|--cleanup` now prints a stderr deprecation warning pointing at the canonical `anet batch <verb> sci-team`. One-release-cycle grace per Decision D1. ## Verified locally (sandbox HOME, never touched 47.116.5.73) - `npm run typecheck` passes (504-line diff, no TS errors). - `bun bin/cli.ts create --batch --help` renders full banner with all flags. - `bun bin/cli.ts batch` renders verb list. - `bun bin/cli.ts batch list` enumerates host tmux session groups (limitation noted in help: catches non-anet groups). - `bun bin/cli.ts batch stop` without prefix → friendly usage error. - `bun bin/cli.ts demo sci-team --help` unchanged. - `bun bin/cli.ts demo sci-team --stop` → deprecation stderr + delegates to `batchLifecycle({ prefix: "sci-team", verb: "stop" })`. - End-to-end: spawned local commhub-server on :9897 + ran `create --batch --preset claude-haiku-4-5 --prefix 工程师 --count 3`: - 3 tmux sessions created (`工程师-工程师1号` .. `工程师-工程师3号`) - `<workdir>/node{1..3}/.anet/nodes/工程师{i}号/config.json` written with correct runtime / model / token / env / systemPrompt - `anet batch list` grouped them under `工程师 (3 node)` - `anet batch stop 工程师` killed all 3 tmux sessions cleanly ## Out of scope for this PR - Codex preset (model id + signup URL un-verified — follow-up issue) - In-place `anet batch restart` / `start` supervisor (Phase 2) - Cross-batch task routing (Phase 3+) - Multi-prefix protected lifecycle list filter (Phase 2) ## Scope creep defenses honored - Single file touched (`agent-network/bin/cli.ts`) - No new vendor / runtime / endpoint introduced - No new scaffold mode (tmux only, per Vincent 4303) - commhub-server / agent-node / demos untouched Refs #55 (Vincent 4335 lifted hold) Refs: #63 #64 #65 (test infra debt tracker — pre-existing rot exposed by lockfile fix, 测试马 triage) Author-Agent: 通信工程马 Helpers: 通信龙 (Option C 分层 propose + dispatch + 7 decision A1/B1/C/D1/E/F3/G ack + 2 nit drop-codex + count>20 warning + review), Vincent (issue raise + 4335 lifted hold) Co-authored-by: vansin <msnode@163.com>
This was referenced May 14, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Author & Helpers
Author (Primary): 通信工程马 (cli.ts scaffold)
Helpers:
saveProfile()was silently dropping new Profile fields (systemPrompt / team / role); fixed in this PRTier review gate: 通信龙 (Lead) + 通信牛 (cross-review)
Why
Refs #51 — Phase 1 of the 科研军团 demo. Vincent 4276+4279 GO + 4303 tmux-only correction.
This is anet's first team-scale demo, showcasing batch-create of N agents under a single coordinator. Phase 1 is scaffold only — wizard + creation + launch + lifecycle wired up; leader's intelligent fan-out + aggregation lands in Phase 2 alongside RFC-008.
What
Single deliverable, single commit, single file touched:
agent-network/bin/cli.ts(+288 lines).anet demo science-teamsubcommand:--intern-api/--count/--dir/--directionflags skip prompt):$INTERN_API_KEYenv)~/intern-s)process.chdirinto<dir>/node<i>, build Profile manually,ensureNodeTokenfor ntok_,saveProfilewrites<dir>/node<i>/.anet/nodes/<alias>/config.json. Original cwd restored infinally.science-team-<alias>per node.--stopkills tmux matchingscience-team-*;--cleanupaddsrm -rf <dir>/node*;--restarthints user to re-run create (full supervisor 留 Phase 2).systemPrompt+ new RFC-008team/rolefields.saveProfile()persistence fix (per 通信牛 review catch):toSavenow persistssystemPrompt/team/role. Without this the placeholder systemPrompts + RFC-008 metadata silently drop fromconfig.json, breaking the Phase 1 leader/researcher echo.Vendor preset (Vincent-verified per commit 1bc03c0 / issue #48 chain)
runtimeclaude-agent-sdkcodex-sdkbut Intern is Anthropic-compatiblemodelintern-s1-proANTHROPIC_BASE_URLhttps://chat.intern-ai.org.cn/anthropicsuffixANTHROPIC_AUTH_TOKEN$INTERN_API_KEYNo fabricated values added (per [[feedback_vendor_verify_before_hardcode]] SOP from preview.0-preview.2 incident).
Scope correction history
This PR was amended after the initial open per two review-time corrections:
demos/science-team/docker-compose template (+743 lines, 7 files, cherry-picked from 通信demo马's branch). Vincent corrected scope — cli scaffold already uses tmux per node, docker variant deferred to Phase 4+ backlog. (9ab6092+8968421removed via branch reset.)saveProfilegap): caught that the new Profile fields would silently drop. Fixed.Branch is now single-commit on top of latest origin/main (force-pushed with
--force-with-lease).How to verify
Phase 1 deliberately deferred
--restartsupervisorTest evidence
npm run typecheckpasses after Profile widening +saveProfilefixbun bin/cli.ts demolists science-team entrybun bin/cli.ts demo science-team --helprenders complete banner--force-with-leaseChecklist
docs-site/docs/changelog.mdupdated — n/a (frozen archive per RELEASE-SOP.md)--helpcovers user surface/home/<user>paths in the difffeat(cli):)Co-Authored-By: Claude*footer (OSS rule)Refs #51