cc-haha/src/commands/headless.test.ts
程序员阿江(Relakkes) 8ecc757729 Hide unfinished goal command entrypoints
The goal implementation is being kept in the tree for later redesign, but the CLI and desktop slash-command surfaces should not advertise or route new users into it while the long-running goal experience is incomplete. Existing transcript parsing and goal event rendering remain intact so historical sessions still load.

Constraint: Keep the implementation code available for future iteration while removing discoverable entrypoints.
Confidence: high
Scope-risk: narrow
Directive: Do not re-expose /goal until the persistent goal/runtime design is revisited.
Tested: bun test src/commands/headless.test.ts
Tested: cd desktop && bun run test -- composerUtils.test.ts pages.test.tsx
Tested: NODE_ENV=test ANTHROPIC_API_KEY=dummy bun -e getCommands assertion for hidden goal command
2026-05-17 00:05:50 +08:00

48 lines
1.3 KiB
TypeScript

import { describe, expect, test } from 'bun:test'
import type { Command } from '../types/command.js'
import { filterCommandsForHeadlessMode } from './headless.js'
describe('filterCommandsForHeadlessMode', () => {
test('keeps non-interactive commands without exposing local-jsx UI commands', () => {
const commands = [
{
type: 'local-jsx',
supportsNonInteractive: true,
name: 'cost',
description: 'Show cost',
load: async () => ({ call: async () => null }),
},
{
type: 'local-jsx',
name: 'config',
description: 'Open config UI',
load: async () => ({ call: async () => null }),
},
{
type: 'prompt',
name: 'review',
description: 'Review code',
progressMessage: 'reviewing',
contentLength: 0,
source: 'builtin',
getPromptForCommand: async () => [],
},
{
type: 'prompt',
name: 'statusline',
description: 'Hidden from print mode',
progressMessage: 'checking',
contentLength: 0,
source: 'builtin',
disableNonInteractive: true,
getPromptForCommand: async () => [],
},
] satisfies Command[]
expect(filterCommandsForHeadlessMode(commands).map(command => command.name)).toEqual([
'cost',
'review',
])
})
})