MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / readQueueFile

Function readQueueFile

apps/kimi-code/src/tui/goal-queue-store.ts:141–168  ·  view source on GitHub ↗
(session: GoalQueueSession)

Source from the content-addressed store, hash-verified

139}
140
141async function readQueueFile(session: GoalQueueSession): Promise<GoalQueueFile> {
142 const filePath = goalQueuePath(session);
143 let raw: string;
144 try {
145 raw = await readFile(filePath, 'utf-8');
146 } catch (error) {
147 if (isErrno(error, 'ENOENT')) return emptyQueueFile();
148 throw error;
149 }
150
151 let parsed: unknown;
152 try {
153 parsed = JSON.parse(raw);
154 } catch (error) {
155 throw new KimiError(
156 ErrorCodes.CONFIG_INVALID,
157 `Invalid JSON in goal queue: ${describeError(error)}`,
158 );
159 }
160
161 if (!isGoalQueueFile(parsed)) {
162 const empty = emptyQueueFile();
163 await writeQueueFile(session, empty);
164 return empty;
165 }
166
167 return parsed;
168}
169
170async function writeQueueFile(session: GoalQueueSession, file: GoalQueueFile): Promise<void> {
171 const filePath = goalQueuePath(session);

Callers 6

readGoalQueueFunction · 0.70
appendGoalQueueItemFunction · 0.70
updateGoalQueueItemFunction · 0.70
removeGoalQueueItemFunction · 0.70
restoreGoalQueueItemFunction · 0.70
moveGoalQueueItemFunction · 0.70

Calls 7

goalQueuePathFunction · 0.85
isErrnoFunction · 0.85
emptyQueueFileFunction · 0.85
isGoalQueueFileFunction · 0.85
writeQueueFileFunction · 0.85
describeErrorFunction · 0.70
readFileFunction · 0.50

Tested by

no test coverage detected