MCPcopy Create free account
hub / github.com/astercloud/aster / loadJSON

Method loadJSON

pkg/store/json.go:93–107  ·  view source on GitHub ↗

loadJSON 加载JSON文件

(path string, dest any)

Source from the content-addressed store, hash-verified

91
92// loadJSON 加载JSON文件
93func (js *JSONStore) loadJSON(path string, dest any) error {
94 data, err := os.ReadFile(path)
95 if err != nil {
96 if os.IsNotExist(err) {
97 return nil // 文件不存在返回nil
98 }
99 return fmt.Errorf("read file: %w", err)
100 }
101
102 if err := json.Unmarshal(data, dest); err != nil {
103 return fmt.Errorf("unmarshal json: %w", err)
104 }
105
106 return nil
107}
108
109// SaveMessages 保存消息列表
110func (js *JSONStore) SaveMessages(ctx context.Context, agentID string, messages []types.Message) error {

Callers 7

LoadMessagesMethod · 0.95
TrimMessagesMethod · 0.95
LoadToolCallRecordsMethod · 0.95
LoadSnapshotMethod · 0.95
ListSnapshotsMethod · 0.95
LoadInfoMethod · 0.95
LoadTodosMethod · 0.95

Calls 1

ReadFileMethod · 0.45

Tested by

no test coverage detected