MCPcopy Create free account
hub / github.com/electric-sql/electric / parseGoalCommand

Function parseGoalCommand

packages/agents-runtime/src/goal-command.ts:44–72  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

42}
43
44export function parseGoalCommand(text: string): GoalCommand {
45 const trimmed = text.trim()
46 const afterPrefix = trimmed.slice(GOAL_PREFIX.length).trim()
47 if (afterPrefix.length === 0) {
48 return {
49 kind: `error`,
50 message: `Usage: /goal set <objective> [--tokens N|unlimited] | /goal clear | /goal show | /goal complete`,
51 }
52 }
53 const tokens = tokenize(afterPrefix)
54 const [subcommand, ...rest] = tokens
55 switch (subcommand) {
56 case `set`:
57 return parseSet(rest)
58 case `clear`:
59 return { kind: `clear` }
60 case `show`:
61 case `status`:
62 return { kind: `show` }
63 case `complete`:
64 case `done`:
65 return { kind: `complete` }
66 default:
67 return {
68 kind: `error`,
69 message: `Unknown subcommand "${subcommand}". Use /goal set, /goal clear, /goal show, or /goal complete.`,
70 }
71 }
72}
73
74function parseSet(rest: Array<string>): GoalCommand {
75 if (rest.length === 0) {

Callers 3

tryHandleSlashCommandFunction · 0.90
isAbortingGoalCommandFunction · 0.85

Calls 3

parseSetFunction · 0.85
tokenizeFunction · 0.70
sliceMethod · 0.45

Tested by

no test coverage detected