Skip to content

feat(demo): anet demo science-team Phase 1 scaffold (refs #51)#53

Merged
s2agi merged 1 commit into
mainfrom
feat/issue-51-science-team-scaffold
May 13, 2026
Merged

feat(demo): anet demo science-team Phase 1 scaffold (refs #51)#53
s2agi merged 1 commit into
mainfrom
feat/issue-51-science-team-scaffold

Conversation

@s2agi
Copy link
Copy Markdown
Contributor

@s2agi s2agi commented May 13, 2026

Author & Helpers

Author (Primary): 通信工程马 (cli.ts scaffold)

Helpers:

  • 通信龙: dispatch + Option A (claude-agent-sdk) runtime confirm + Vincent 4303 scope correction (tmux-only) + review
  • 通信SDK马: RFC-008 multi-agent team convention spec author (already on main: 2f10bc3 v1 + d765b9e v1.1 amend)
  • 通信牛: review catch — saveProfile() was silently dropping new Profile fields (systemPrompt / team / role); fixed in this PR
  • 通信demo马: original docker compose draft (dropped from this PR per Vincent 4303 — deferred to Phase 4+ backlog)
  • Vincent: issue [feat] 科研军团 demo — anet demo science-team 批量创建 N 节点协作 #51 raise + 4276+4279 GO + 4303 tmux-only scope + 4227 Intern endpoint verify (refs commit 1bc03c0)

Tier 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-team subcommand:

  • Wizard prompts (--intern-api / --count / --dir / --direction flags skip prompt):
    • 书生 Intern API key (or $INTERN_API_KEY env)
    • 军团人数 5-50 (default 10)
    • 工作目录 (default ~/intern-s)
    • 综述方向 7 presets (comprehensive / infra / llm-arch / unified-gen / rlhf / ai-safety / 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 <dir>/node<i>/.anet/nodes/<alias>/config.json. Original cwd restored in finally.
  • Launch loop: tmux session science-team-<alias> per node.
  • Lifecycle: --stop kills tmux matching science-team-*; --cleanup adds rm -rf <dir>/node*; --restart hints user to re-run create (full supervisor 留 Phase 2).
  • Profile interface widening: optional systemPrompt + new RFC-008 team / role fields.
  • saveProfile() persistence fix (per 通信牛 review catch): toSave now persists systemPrompt / team / role. Without this the placeholder systemPrompts + RFC-008 metadata silently drop from config.json, breaking the Phase 1 leader/researcher echo.

Vendor preset (Vincent-verified per commit 1bc03c0 / issue #48 chain)

Field Value Source
runtime claude-agent-sdk RFC-008 v1.1 amend (d765b9e) — original spec said codex-sdk but Intern is Anthropic-compatible
model intern-s1-pro Vincent 4227 verified (lowercase)
ANTHROPIC_BASE_URL https://chat.intern-ai.org.cn Vincent 4227 — bare hostname, no /anthropic suffix
ANTHROPIC_AUTH_TOKEN $INTERN_API_KEY User-supplied via wizard / env

No 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:

  1. Vincent 4303 (tmux-only): initial PR included 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 + 8968421 removed via branch reset.)
  2. 通信牛 review (saveProfile gap): 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

# 1. typecheck
cd agent-network && bun install && npm run typecheck    # no errors

# 2. demo list shows science-team
bun bin/cli.ts demo
# expect: science-team listed after debate / socialmedia / pr-review

# 3. help banner renders
bun bin/cli.ts demo science-team --help

# 4. happy path (needs running hub + Intern API key)
anet hub start &
bun bin/cli.ts demo science-team --count 5 --dir /tmp/sci-test --intern-api $INTERN_API_KEY --direction llm-arch
# expect: /tmp/sci-test/node1..node5 each with .anet/nodes/<alias>/config.json
# expect: tmux sessions science-team-研究Leader, science-team-研究员1号..研究员4号

# 5. verify saveProfile fix — config.json includes systemPrompt + team + role
cat /tmp/sci-test/node1/.anet/nodes/研究Leader/config.json | jq '.systemPrompt, .team, .role'
# expect: placeholder string + "science-team" + "leader"

# 6. cleanup
bun bin/cli.ts demo science-team --cleanup --dir /tmp/sci-test
# expect: "killed 5 tmux session(s)" + "清理完成"

Phase 1 deliberately deferred

Test evidence

  • npm run typecheck passes after Profile widening + saveProfile fix
  • bun bin/cli.ts demo lists science-team entry
  • bun bin/cli.ts demo science-team --help renders complete banner
  • ✅ Single commit on top of latest origin/main (incl. RFC-008 v1.1 amend d765b9e)
  • ✅ Force-push used --force-with-lease

Checklist

  • Relevant tests pass locally (typecheck + help + dispatch list)
  • docs-site/docs/changelog.md updated — n/a (frozen archive per RELEASE-SOP.md)
  • Docs synced — CLI --help covers user surface
  • No secrets / tokens / private IPs / /home/<user> paths in the diff
  • Conventional Commits message (feat(cli):)
  • No Co-Authored-By: Claude* footer (OSS rule)
  • Attribution trailer in commit footer per [[feedback_attribution_traceability_sop]]
  • Issue linked via Refs #51

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)
@s2agi s2agi force-pushed the feat/issue-51-science-team-scaffold branch from 8968421 to 5e2bb9c Compare May 13, 2026 09:13
@s2agi s2agi merged commit a3e6e3a into main May 13, 2026
1 of 3 checks passed
@s2agi s2agi deleted the feat/issue-51-science-team-scaffold branch May 13, 2026 09:20
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants