Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/cli/src/acp/commandHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,14 @@ describe('CommandHandler', () => {

const init = parse('/init');
expect(init.commandToExecute?.name).toBe('init');
<<<<<<< HEAD
=======

const about = parse('/about');
expect(about.commandToExecute?.name).toBe('about');

const help = parse('/help');
expect(help.commandToExecute?.name).toBe('help');
>>>>>>> 06fcdc231 (feat(acp): add /help command (#24839))
Comment on lines +29 to +37

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This file contains unresolved merge conflict markers. This will cause the build to fail. Please resolve the conflicts before merging.

    const about = parse('/about');
    expect(about.commandToExecute?.name).toBe('about');

    const help = parse('/help');
    expect(help.commandToExecute?.name).toBe('help');

});
});
10 changes: 10 additions & 0 deletions packages/cli/src/acp/commandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import { MemoryCommand } from './commands/memory.js';
import { ExtensionsCommand } from './commands/extensions.js';
import { InitCommand } from './commands/init.js';
import { RestoreCommand } from './commands/restore.js';
<<<<<<< HEAD
=======
import { AboutCommand } from './commands/about.js';
import { HelpCommand } from './commands/help.js';
>>>>>>> 06fcdc231 (feat(acp): add /help command (#24839))
Comment on lines +13 to +17

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This file contains unresolved merge conflict markers. This will cause the build to fail. Please resolve the conflicts before merging.

import { AboutCommand } from './commands/about.js';
import { HelpCommand } from './commands/help.js';


export class CommandHandler {
private registry: CommandRegistry;
Expand All @@ -24,6 +29,11 @@ export class CommandHandler {
registry.register(new ExtensionsCommand());
registry.register(new InitCommand());
registry.register(new RestoreCommand());
<<<<<<< HEAD
=======
registry.register(new AboutCommand());
registry.register(new HelpCommand(registry));
>>>>>>> 06fcdc231 (feat(acp): add /help command (#24839))
Comment on lines +32 to +36

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This file contains unresolved merge conflict markers. This will cause the build to fail. Please resolve the conflicts before merging.

    registry.register(new AboutCommand());
    registry.register(new HelpCommand(registry));

return registry;
}

Expand Down
53 changes: 53 additions & 0 deletions packages/cli/src/acp/commands/help.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import { describe, it, expect } from 'vitest';
import { HelpCommand } from './help.js';
import { CommandRegistry } from './commandRegistry.js';
import type { Command, CommandContext } from './types.js';

describe('HelpCommand', () => {
it('returns formatted help text with sorted commands', async () => {
const registry = new CommandRegistry();

const cmdB: Command = {
name: 'bravo',
description: 'Bravo command',
execute: async () => ({ name: 'bravo', data: '' }),
};

const cmdA: Command = {
name: 'alpha',
description: 'Alpha command',
execute: async () => ({ name: 'alpha', data: '' }),
};

registry.register(cmdB);
registry.register(cmdA);

const helpCommand = new HelpCommand(registry);

const context = {} as CommandContext;

const response = await helpCommand.execute(context, []);

expect(response.name).toBe('help');

const data = response.data as string;

expect(data).toContain('Gemini CLI Help:');
expect(data).toContain('### Basics');
expect(data).toContain('### Commands');

const lines = data.split('\n');
const alphaIndex = lines.findIndex((l) => l.includes('/alpha'));
const bravoIndex = lines.findIndex((l) => l.includes('/bravo'));

expect(alphaIndex).toBeLessThan(bravoIndex);
expect(alphaIndex).not.toBe(-1);
expect(bravoIndex).not.toBe(-1);
});
});
50 changes: 50 additions & 0 deletions packages/cli/src/acp/commands/help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import type {
Command,
CommandContext,
CommandExecutionResponse,
} from './types.js';
import type { CommandRegistry } from './commandRegistry.js';

export class HelpCommand implements Command {
readonly name = 'help';
readonly description = 'Show available commands';

constructor(private registry: CommandRegistry) {}

async execute(
_context: CommandContext,
_args: string[] = [],
): Promise<CommandExecutionResponse> {
const commands = this.registry
.getAllCommands()
.sort((a, b) => a.name.localeCompare(b.name));

const lines: string[] = [];

lines.push('Gemini CLI Help:');
lines.push('');
lines.push('### Basics');
lines.push(
'- **Add context**: Use `@` to specify files for context (e.g., `@src/myFile.ts`) to target specific files or folders.',
);
lines.push('');

lines.push('### Commands');
for (const cmd of commands) {
if (cmd.description) {
lines.push(`- **/${cmd.name}** - ${cmd.description}`);
}
}

return {
name: this.name,
data: lines.join('\n'),
};
}
}
Loading