MCPcopy
hub / github.com/Dimillian/CodexMonitor / cleanCommandText

Function cleanCommandText

src/utils/threadItems.explore.ts:84–98  ·  view source on GitHub ↗
(commandText: string)

Source from the content-addressed store, hash-verified

82}
83
84function cleanCommandText(commandText: string) {
85 if (!commandText) {
86 return "";
87 }
88 const trimmed = commandText.trim();
89 const shellMatch = trimmed.match(
90 /^(?:\/\S+\/)?(?:bash|zsh|sh|fish)(?:\.exe)?\s+-lc\s+(?:(['"])([\s\S]+)\1|([\s\S]+))$/,
91 );
92 const inner = shellMatch ? (shellMatch[2] ?? shellMatch[3] ?? "") : trimmed;
93 const cdMatch = inner.match(
94 /^\s*cd\s+[^&;]+(?:\s*&&\s*|\s*;\s*)([\s\S]+)$/i,
95 );
96 const stripped = cdMatch ? cdMatch[1] : inner;
97 return stripped.trim();
98}
99
100function tokenizeCommand(command: string) {
101 const tokens: string[] = [];

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected