π€― 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
π fix(cli): restore the node glyph `lh goal show` lost when the kind was renamed (#18912)
Arvin Xu439b0cadad6a
diff --git a/apps/cli/src/commands/goal.test.ts b/apps/cli/src/commands/goal.test.tsindex 4b44163c58a..fc7427ed716 100644--- a/apps/cli/src/commands/goal.test.ts+++ b/apps/cli/src/commands/goal.test.ts@@ -6,6 +6,7 @@ import { registerGoalCommand } from './goal';const { mockClient } = vi.hoisted(() => ({mockClient: {goal: {+ graph: { query: vi.fn() },tick: { mutate: vi.fn() },},},@@ -77,3 +78,78 @@ describe('goal run command', () => {expect(result[1]).toMatchObject({ outcome: 'achieved' });});});++describe('goal show command', () => {+ const node = (kind: string, title: string) => ({+ createdAt: new Date(0),+ id: `${kind}-node-id`,+ kind,+ priority: 0,+ status: 'waiting',+ taskId: kind === 'task' ? 'task_8A1DyvjIc7PL' : null,+ title,+ updatedAt: new Date(0),+ });++ beforeEach(() => {+ vi.clearAllMocks();+ vi.spyOn(console, 'log').mockImplementation(() => {});+ });++ const render = async () => {+ await createProgram().parseAsync(['node', 'test', 'goal', 'show', 'goal-1']);+ return (+ vi+ .mocked(console.log)+ .mock.calls // `printGraph` calls `console.log()` bare for a blank line; stringifying that+ // would manufacture the very word the assertion below is looking for.+ .map(([value]) => (value === undefined ? '' : String(value)))+ .join('\n')+ );+ };++ it('renders a glyph for every node kind, including task', async () => {+ // The glyph map was keyed on the old `work` kind after the rename, so every+ // task row printed `undefined task` against a real goal. Typing the map+ // proves each kind maps to *a* string; only rendering proves it maps to the+ // right one.+ mockClient.goal.graph.query.mockResolvedValue({+ data: {+ decisions: [],+ edges: [],+ events: [],+ goal: { id: 'goal-1', requirement: null, status: 'review', title: 'Three quotes' },+ nodes: [+ node('problem', 'Collect three quotes'),+ node('task', 'Ask vendor A'),+ node('finding', 'Vendor A quoted 1200'),+ node('decision', 'Retry or retire?'),+ ],+ workVersions: [],+ },+ });++ const output = await render();++ expect(output).toContain('β£ task');+ expect(output).toContain('β problem');+ expect(output).toContain('β finding');+ expect(output).toContain('β decision');+ expect(output).not.toContain('undefined');+ });++ it('still shows the responsible task id next to its node', async () => {+ mockClient.goal.graph.query.mockResolvedValue({+ data: {+ decisions: [],+ edges: [],+ events: [],+ goal: { id: 'goal-1', requirement: null, status: 'review', title: 'Three quotes' },+ nodes: [node('task', 'Ask vendor A')],+ workVersions: [],+ },+ });++ expect(await render()).toContain('task_8A1DyvjIc7PL');+ });+});diff --git a/apps/cli/src/commands/goal.ts b/apps/cli/src/commands/goal.tsindex 555c7404183..8689e0b63a9 100644--- a/apps/cli/src/commands/goal.ts+++ b/apps/cli/src/commands/goal.ts@@ -1,4 +1,9 @@-import type { GoalGraphDecision, GoalGraphSnapshot, GoalTickResult } from '@lobechat/types';+import type {+ GoalGraphDecision,+ GoalGraphSnapshot,+ GoalNodeKind,+ GoalTickResult,+} from '@lobechat/types';import type { Command } from 'commander';import pc from 'picocolors';@@ -7,7 +12,15 @@ import { outputJson, printTable, truncate } from '../utils/format';import { log } from '../utils/logger';import { resolveAppUrlBuilder } from './task/url';-const nodeIcon = { decision: 'β', finding: 'β', problem: 'β', work: 'β£' } as const;+// Typed rather than inferred: an `as const` map is indexable by a widened+// `any` node kind, which is how a renamed kind silently printed `undefined`+// here after the type checker had signed off everywhere else.+const nodeIcon: Record<GoalNodeKind, string> = {+ decision: 'β',+ finding: 'β',+ problem: 'β',+ task: 'β£',+};const terminalOutcomes = new Set(['achieved', 'waiting_human', 'no_progress', 'failed']);interface GoalRunTickResult extends GoalTickResult {