MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / parseSlashContext

Function parseSlashContext

cli/src/hooks/use-suggestion-engine.ts:45–66  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

43}
44
45const parseSlashContext = (input: string): TriggerContext => {
46 if (!input) {
47 return { active: false, query: '', startIndex: -1 }
48 }
49
50 const { lineStart, line } = getCurrentLineInfo(input)
51
52 const match = line.match(/^(\s*)\/([^\s]*)$/)
53 if (!match) {
54 return { active: false, query: '', startIndex: -1 }
55 }
56
57 const [, leadingWhitespace, commandSegment] = match
58 const startIndex = lineStart + leadingWhitespace.length
59
60 // Slash commands only activate on the first line (startIndex must be 0)
61 if (startIndex !== 0) {
62 return { active: false, query: '', startIndex: -1 }
63 }
64
65 return { active: true, query: commandSegment, startIndex }
66}
67
68interface MentionParseResult {
69 active: boolean

Callers 1

useSuggestionEngineFunction · 0.85

Calls 1

getCurrentLineInfoFunction · 0.85

Tested by

no test coverage detected