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

Function loadMessageHistory

cli/src/utils/message-history.ts:65–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63 * @returns Array of previous messages, most recent last
64 */
65export const loadMessageHistory = (): string[] => {
66 const historyPath = getMessageHistoryPath()
67
68 if (!fs.existsSync(historyPath)) {
69 return []
70 }
71
72 try {
73 const historyFile = fs.readFileSync(historyPath, 'utf8')
74 const history = JSON.parse(historyFile)
75
76 if (!Array.isArray(history)) {
77 logger.warn('Message history file has invalid format, resetting')
78 return []
79 }
80
81 return history.filter((item) => typeof item === 'string')
82 } catch (error) {
83 logger.error(
84 {
85 error: error instanceof Error ? error.message : String(error),
86 },
87 'Error reading message history',
88 )
89 return []
90 }
91}
92
93/**
94 * Save message history to file system

Callers 1

useInputHistoryFunction · 0.90

Calls 2

getMessageHistoryPathFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected