MCPcopy
hub / github.com/slopus/happy / stringifyToolCommand

Function stringifyToolCommand

packages/happy-app/sources/utils/toolCommand.ts:10–35  ·  view source on GitHub ↗
(command: unknown)

Source from the content-addressed store, hash-verified

8]);
9
10export function stringifyToolCommand(command: unknown): string | null {
11 if (typeof command === 'string') {
12 const trimmed = command.trim();
13 return trimmed.length > 0 ? trimmed : null;
14 }
15
16 if (!Array.isArray(command)) {
17 return null;
18 }
19
20 const parts = command
21 .filter((part): part is string => typeof part === 'string')
22 .map((part) => part.trim())
23 .filter((part) => part.length > 0);
24
25 if (parts.length === 0) {
26 return null;
27 }
28
29 if (parts.length >= 3 && SHELL_WRAPPERS.has(parts[0]) && (parts[1] === '-c' || parts[1] === '-lc')) {
30 const wrappedCommand = parts.slice(2).join(' ').trim();
31 return wrappedCommand.length > 0 ? wrappedCommand : null;
32 }
33
34 return parts.join(' ');
35}

Callers 5

knownTools.tsxFile · 0.90
CodexBashView.tsxFile · 0.90
getTerminalToolCommandFunction · 0.90
getToolSummaryFunction · 0.90

Calls 1

hasMethod · 0.45

Tested by

no test coverage detected