🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(cli): add --tag to lh agent create (#23012)
Rdmclin2ab883dde0663
diff --git a/apps/cli/src/commands/agent.create.test.ts b/apps/cli/src/commands/agent.create.test.tsindex 3eb4a594593..1540378eeb7 100644--- a/apps/cli/src/commands/agent.create.test.ts+++ b/apps/cli/src/commands/agent.create.test.ts@@ -96,6 +96,43 @@ describe('agent create', () => {expect(consoleSpy).toHaveBeenCalledWith(` Visibility: ${v}`);});+ it('passes repeated --tag flags as config.tags, trimmed and without duplicates', async () => {+ mockTrpcClient.agent.createAgent.mutate.mockResolvedValue({ agentId: 'a-new' });++ const program = createProgram();+ await program.parseAsync([+ 'node',+ 'test',+ 'agent',+ 'create',+ '-t',+ 'x',+ '--tag',+ 'lobe-pet',+ '--tag',+ ' pet:dafeiyu ',+ '--tag',+ 'lobe-pet',+ '--tag',+ ' ',+ ]);++ expect(mockTrpcClient.agent.createAgent.mutate).toHaveBeenCalledWith({+ config: { tags: ['lobe-pet', 'pet:dafeiyu'], title: 'x' },+ });+ });++ it('sends no tags without --tag', async () => {+ mockTrpcClient.agent.createAgent.mutate.mockResolvedValue({ agentId: 'a-new' });++ const program = createProgram();+ await program.parseAsync(['node', 'test', 'agent', 'create', '-t', 'x']);++ expect(mockTrpcClient.agent.createAgent.mutate.mock.calls[0][0].config).not.toHaveProperty(+ 'tags',+ );+ });+it('rejects an unknown --visibility value before calling the server', async () => {const program = createProgram();program.exitOverride();diff --git a/apps/cli/src/commands/agent.ts b/apps/cli/src/commands/agent.tsindex 4e5a3a59d58..5b59a3b382d 100644--- a/apps/cli/src/commands/agent.ts+++ b/apps/cli/src/commands/agent.ts@@ -182,6 +182,11 @@ export function registerAgentCommand(program: Command) {.option('-p, --provider <provider>', 'Provider ID').option('-s, --system-role <role>', 'System role prompt').option('--group <groupId>', 'Group ID')+ .option(+ '--tag <tag>',+ 'Tag the agent (repeatable), e.g. so an app can find the agents it created',+ (tag: string, tags: string[] = []) => [...tags, tag],+ ).addOption(new Option('--visibility <visibility>',@@ -197,6 +202,7 @@ export function registerAgentCommand(program: Command) {model?: string;provider?: string;systemRole?: string;+ tag?: string[];title?: string;visibility?: AgentVisibility;}) => {@@ -209,6 +215,8 @@ export function registerAgentCommand(program: Command) {if (options.model) config.model = options.model;if (options.provider) config.provider = options.provider;if (options.systemRole) config.systemRole = options.systemRole;+ const tags = [...new Set((options.tag ?? []).map((t) => t.trim()).filter(Boolean))];+ if (tags.length > 0) config.tags = tags;const input: Record<string, any> = { config };if (options.group) input.groupId = options.group;