Skip to content

feat: add --agent-role to CLI session create - #1286

Merged
Leeeon233 merged 3 commits into
LodyAI:mainfrom
kipyin:feat/cli-session-create-agent-role
Oct 11, 2026
Merged

Leeeon233 merged 3 commits into
LodyAI:mainfrom
kipyin:feat/cli-session-create-agent-role

Conversation

@kipyin

@kipyin kipyin commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Related issue

Closes #1282

Problem / pressure

lody session create had no way to select a workspace Agent Role. CLI operators and automation had to hand-assemble machine, agent config, and run configuration from lody agent-role get, which loses Role version provenance, drops the prompt prefix, and drifts when the Role changes — while the MCP create tools already resolve all of this from agentRoleId.

Summary

  • lody session create gains --agent-role <idOrName>, resolved from the workspace Role catalog by fixed id or unique name.
  • Role resolution moved verbatim from the MCP server into shared apps/cli/src/lib/agent-role-create.ts; both surfaces use it. The Role's machine, agent config, run config, and prompt prefix are authoritative; manual --machine/--agent/--agent-config/--mode/--model/--config-option are cleared with a stderr warning, and Role id/revision/snapshot freeze as creation provenance via the existing session-meta/input-config path.
  • --repo/--branch/--local-project/--worktree/--parent still apply as work context. A missing Role fails fast with the candidate list; unavailable targets keep failing in the existing create validation, matching MCP semantics.
  • Docs (en/zh CLI reference, CLI README), the session-orchestration Spec (en/zh), the commands AGENTS.md boundary, and an Agent Note (en/zh) updated.

Visual explanation

 lody session create --agent-role reviewer "…"
   withWorkspaceManager
+    resolveAgentRoleCreateFromCatalog      (lib/agent-role-create.ts, shared with MCP)
+      loadWorkspaceAgentRoleCatalog        workspace Flock agentRole rows
+      selectUniqueAgentRoleByIdOrName      fixed id → unique name → candidates
+    warn: ignored --machine/--agent/--mode/--model/--config-option
+    applyAgentRoleCreateTarget             Role machine + agentConfig + runConfig win
+    composeAgentRolePrompt                 promptPrefix + user prompt
   createSessionResult                      unchanged; freezes agentRoleId/revision/snapshot

Before / after

Before After
lody session create --help lists no Role option; Role config hand-copied from lody agent-role get --agent-role <idOrName> resolves the catalog Role; its machine, agent config, run configuration, and prompt prefix win, with a warning for ignored flags

Test plan

  • New apps/cli/src/lib/agent-role-create.test.ts (12 tests): selector id/unique-name/ambiguous/not-found, dispatch config and prompt derivation, ignored-override listing, catalog load via mocked LoroDocumentManager, provenance binding, work-context coexistence, and a parity test running the same Role fixture through the CLI resolver and MCP's resolveMcpSessionCreate + buildMcpCreateOptions (equal machine, agent config, prompt, dispatch config, provenance).
  • Affected suites (agent-role-create, lody-mcp-server, session): 145/145 pass. Full apps/cli suite: 3493 passed, 1 failure in github-git-transport.test.ts that only occurs under this session's injected git credential shim (passes 6/6 in a clean environment; unrelated code).
  • tsgo --noEmit, oxlint (0 errors), check:public-boundary, check:platform-boundaries, check-code-collab-imports, lint:i18n, and oxfmt all pass.
  • Not run: live end-to-end lody session create --agent-role against a real workspace (no commander-level harness exists for this command, consistent with existing coverage of the other create flags).

Context handoff

Original user prompt

Show original prompt
如果要用 gh cli,用本机的 gh (/opt/homebrew/bin/gh),不要用 lody managed gh

Implement the assigned ticket or task.

Follow /implement ([Skill Path](/Users/kip/Code/kstack/global/implement/SKILL.md)).

## Completion
- Orchestrated mode (assigned a worktree branch): Commit to that branch and stop. Do not push or create a pull request.
- Standalone mode:
  1. If UI changes, capture screenshots using /ego-browser ([Skill Path](/Users/kip/Code/kstack/global/ego-browser/SKILL.md)).
  2. Request the PR body from `Writer` (id: `5fcdaafc-e42a-41ae-a9f3-f869fa7633fc`).
  3. Push the branch.
  4. Create the pull request with `/opt/homebrew/bin/gh` (or `/opt/homebrew/bin/gitee` if specified). Do not run bare `gh`.

https://github.com/LodyAI/Lody/issues/1282

[Harness-level system-instruction block redacted: not user-authored content.]

Shared conversation

Status: shared
Link: https://share.lody.ai/s/r1730r4h2j6yyhss06ahqrhkg18fvmqr#access=v1.5779813d5136883df772f3281853b19d544d65c44b6ba847339df3e09f935a00

Resolve a workspace Agent Role by fixed id or unique name in
`lody session create`, reusing the MCP resolution extracted into
lib/agent-role-create.ts. The Role's machine, agent config, run
configuration, and prompt prefix override --machine/--agent/
--agent-config/--mode/--model/--config-option with a stderr warning,
and Role id/revision/snapshot freeze as creation provenance.
Work-context flags and --parent still apply.

Closes LodyAI#1282.

Model: kimi-code (runtime model ID not exposed)
kipyin and others added 2 commits October 9, 2026 16:36
…eate-agent-role

# Conflicts:
#	apps/cli/src/commands/session.ts
Resolve MCP imports and relocated CLI reference conflicts. Preserve Role creation behavior and record integration verification.

Model: gpt-6
@Leeeon233
Leeeon233 merged commit 25d4b32 into LodyAI:main Oct 11, 2026
12 checks passed
@kipyin
kipyin deleted the feat/cli-session-create-agent-role branch October 11, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] CLI session create:支持 --agent-role

2 participants