mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-08-21 05:26:59 +08:00
update prompt
This commit is contained in:
@@ -506,10 +506,6 @@ func (store *ConversationFileStore) syncCursorTranscriptBestEffort(conversationI
|
||||
}
|
||||
|
||||
func (store *ConversationFileStore) syncCursorTranscript(conversationID string, conversation *ConversationFile, transcriptsFolder string) error {
|
||||
return store.syncCursorTranscriptWithLatestStatus(conversationID, conversation, transcriptsFolder, false)
|
||||
}
|
||||
|
||||
func (store *ConversationFileStore) syncCursorTranscriptWithLatestStatus(conversationID string, conversation *ConversationFile, transcriptsFolder string, includeLatestStatus bool) error {
|
||||
if store == nil || conversation == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -517,7 +513,7 @@ func (store *ConversationFileStore) syncCursorTranscriptWithLatestStatus(convers
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := projectCursorTranscriptJSONLWithLatestStatus(conversation, includeLatestStatus)
|
||||
data, err := projectCursorTranscriptJSONL(conversation)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -528,34 +524,6 @@ func (store *ConversationFileStore) syncCursorTranscriptWithLatestStatus(convers
|
||||
return writeCursorTranscriptAtomic(path, data)
|
||||
}
|
||||
|
||||
func (store *ConversationFileStore) SyncAllCursorTranscriptsBestEffort() {
|
||||
if store == nil {
|
||||
return
|
||||
}
|
||||
conversationIDs, err := store.ListConversationIDs()
|
||||
if err != nil {
|
||||
log.Printf("forwarder transcript backfill scan failed err=%v", err)
|
||||
return
|
||||
}
|
||||
for _, conversationID := range conversationIDs {
|
||||
conversation, err := store.LoadConversation(conversationID)
|
||||
if err != nil {
|
||||
log.Printf("forwarder transcript backfill load failed conversation_id=%s err=%v", conversationID, err)
|
||||
continue
|
||||
}
|
||||
if conversation == nil || conversation.AgentTranscriptsFolder == "" {
|
||||
continue
|
||||
}
|
||||
info, err := os.Stat(conversation.AgentTranscriptsFolder)
|
||||
if err != nil || !info.IsDir() {
|
||||
continue
|
||||
}
|
||||
if err := store.syncCursorTranscriptWithLatestStatus(conversationID, conversation, conversation.AgentTranscriptsFolder, true); err != nil {
|
||||
log.Printf("forwarder transcript backfill failed conversation_id=%s err=%v", conversationID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func contextVersionForEntries(entries []HistoryEntry) int64 {
|
||||
var version int64
|
||||
for _, entry := range entries {
|
||||
|
||||
@@ -307,7 +307,6 @@ func NewService(historyRoot string, resolver modeladapter.ChannelResolver) *Serv
|
||||
appendSeq: newAppendSequenceTracker(),
|
||||
}
|
||||
service.startHistoryMaintenance()
|
||||
store.SyncAllCursorTranscriptsBestEffort()
|
||||
return service
|
||||
}
|
||||
|
||||
|
||||
@@ -68,10 +68,6 @@ type cursorTranscriptContent struct {
|
||||
// projectCursorTranscriptJSONL projects the local semantic history into Cursor's
|
||||
// current agent transcript JSONL contract. context.json remains the source of truth.
|
||||
func projectCursorTranscriptJSONL(conversation *ConversationFile) ([]byte, error) {
|
||||
return projectCursorTranscriptJSONLWithLatestStatus(conversation, false)
|
||||
}
|
||||
|
||||
func projectCursorTranscriptJSONLWithLatestStatus(conversation *ConversationFile, includeLatestStatus bool) ([]byte, error) {
|
||||
if conversation == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -85,7 +81,7 @@ func projectCursorTranscriptJSONLWithLatestStatus(conversation *ConversationFile
|
||||
currentTurnSeq := int64(0)
|
||||
pendingTurnStatus := cursorTranscriptLine{}
|
||||
flushTurnStatus := func() {
|
||||
if currentTurnSeq > 0 && (includeLatestStatus || currentTurnSeq < maxTurnSeq) && pendingTurnStatus.Type != "" {
|
||||
if currentTurnSeq > 0 && currentTurnSeq < maxTurnSeq && pendingTurnStatus.Type != "" {
|
||||
lines = append(lines, pendingTurnStatus)
|
||||
}
|
||||
pendingTurnStatus = cursorTranscriptLine{}
|
||||
|
||||
@@ -97,42 +97,6 @@ func TestConversationFileStoreSyncsCursorTranscript(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConversationFileStoreBackfillsTranscriptOnStartup(t *testing.T) {
|
||||
historyRoot := filepath.Join(t.TempDir(), "history")
|
||||
transcriptsFolder := filepath.Join(t.TempDir(), "agent-transcripts")
|
||||
if err := os.MkdirAll(transcriptsFolder, 0o755); err != nil {
|
||||
t.Fatalf("create transcript root: %v", err)
|
||||
}
|
||||
store := NewConversationFileStore(historyRoot)
|
||||
conversation := transcriptTestConversation(nil)
|
||||
conversation.AgentTranscriptsFolder = transcriptsFolder
|
||||
_, err := store.SaveConversationWithEntries(conversation.ConversationID, conversation, []HistoryEntry{
|
||||
transcriptTestUserMessageEntry(t, 1, "request-1", "hello"),
|
||||
newAssistantTextEntry(1, "request-1", "hi", "", ""),
|
||||
newMetadataEntry(1, "request-1", "turn_completed", nil),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("SaveConversationWithEntries() error = %v", err)
|
||||
}
|
||||
path := filepath.Join(transcriptsFolder, conversation.ConversationID, conversation.ConversationID+".jsonl")
|
||||
if err := os.RemoveAll(filepath.Dir(path)); err != nil {
|
||||
t.Fatalf("remove generated transcript: %v", err)
|
||||
}
|
||||
if err := os.MkdirAll(transcriptsFolder, 0o755); err != nil {
|
||||
t.Fatalf("restore transcript root: %v", err)
|
||||
}
|
||||
|
||||
store.SyncAllCursorTranscriptsBestEffort()
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("read backfilled transcript: %v", err)
|
||||
}
|
||||
lines := decodeCursorTranscriptLines(t, data)
|
||||
if len(lines) != 3 || lines[2].Type != "turn_ended" || lines[2].Status != "success" {
|
||||
t.Fatalf("backfilled transcript = %s", data)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeAgentTranscriptsFolderRejectsUnexpectedPaths(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
if got := normalizeAgentTranscriptsFolder(filepath.Join(root, "agent-transcripts")); got == "" {
|
||||
|
||||
Reference in New Issue
Block a user