MCPcopy
hub / github.com/openai/codex-plugin-cc / loadState

Function loadState

plugins/codex/scripts/lib/state.mjs:58–78  ·  view source on GitHub ↗
(cwd)

Source from the content-addressed store, hash-verified

56}
57
58export function loadState(cwd) {
59 const stateFile = resolveStateFile(cwd);
60 if (!fs.existsSync(stateFile)) {
61 return defaultState();
62 }
63
64 try {
65 const parsed = JSON.parse(fs.readFileSync(stateFile, "utf8"));
66 return {
67 ...defaultState(),
68 ...parsed,
69 config: {
70 ...defaultState().config,
71 ...(parsed.config ?? {})
72 },
73 jobs: Array.isArray(parsed.jobs) ? parsed.jobs : []
74 };
75 } catch {
76 return defaultState();
77 }
78}
79
80function pruneJobs(jobs) {
81 return [...jobs]

Callers 5

cleanupSessionJobsFunction · 0.90
saveStateFunction · 0.85
updateStateFunction · 0.85
listJobsFunction · 0.85
getConfigFunction · 0.85

Calls 2

resolveStateFileFunction · 0.85
defaultStateFunction · 0.85

Tested by

no test coverage detected