Skip to content

Commit 69fb4d0

Browse files
author
SqlRush
committed
Accept worktree metadata aliases
1 parent 322e4f8 commit 69fb4d0

5 files changed

Lines changed: 12 additions & 1 deletion

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ M6 补充:tombstone metadata target/parent 现在接受 `targetId`/`deletedId`
4444

4545
M6 补充:transcript metadata 现在接受 summary `leafID`/message ID、content-replacement `agentID`/`toolUseID`/`blockID` 和 context-collapse `collapseID`/`summaryID`/archived ID 别名,metadata loader 与 full loader 保持同一兼容面。
4646

47+
M6 补充:worktree-state metadata 现在除 `worktreeSession`/`worktree_session` 外,也接受 `worktreeState`/`worktree_state`/`worktree`/`workspace` wrapper,full loader 和 lightweight metadata loader 都会保留旧 worktree payload。
48+
4749
M6 补充:remote history GraphQL/connection 分页现在接受 `hasPrevious`/`hasPreviousPage``hasOlder`/`more` 继续分页标记,以及 `previousCursor`/`prevCursor`/`beforeCursor`/`olderCursor` 等 before-id cursor 别名,避免只返回第一页历史。
4850

4951
M6 补充:remote history response parser 现在会递归解包 `data.session.events``data.projectSession.eventConnection``conversation``remoteHistory` 等 GraphQL/session wrapper,继续复用 `nodes`/`edges[].node``pageInfo` pagination 解析。

docs/claude-code-go-rewrite-plan.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ test/parity/ # golden tests against TS/official behavior
201201
- 本轮补充:基础 `SessionEntry` JSONL loader 接受 `role`/`entryType`/`messageType`、message ID/UUID、parent ID/UUID 和 `sessionID`/`session`/session UUID 别名,旧 entry 文件可通过 `session.Load` 保留类型、parent 和 session。
202202
- 本轮补充:tombstone metadata target/parent 加宽到 `targetId`/`deletedId`/`messageId``parentId`/`parentMessageId` ID/UUID 别名,delete/relink replay 可兼容旧字段拼写。
203203
- 本轮补充:transcript metadata 加宽 summary `leafID`/message ID、content-replacement `agentID`/`toolUseID`/`blockID` 和 context-collapse `collapseID`/`summaryID`/archived ID 别名,full loader 和 lightweight metadata loader 保持一致。
204+
- 本轮补充:worktree-state metadata 接受 `worktreeState`/`worktree_state`/`worktree`/`workspace` wrapper 别名,full loader 和 lightweight metadata loader 都能保留旧 worktree payload。
204205
- 本轮补充:remote history `SDKEvent` 解码接受顶层 `sessionID` 作为事件 session id 别名,materialize transcript 时会填充 record 与嵌套 message 的 session id(覆盖测试:`TestRemoteHistoryTranscriptMessagesAcceptsSessionIDUpperAlias`)。
205206
- 本轮补充:remote history `SDKEvent` 解码接受 `parentUUID``parentId`/`parentID`/`parent_id``parentMessageId`/`parentMessageID`/`parent_message_id` parent aliases,materialize transcript 时会保留 parent chain(覆盖测试:`TestRemoteHistoryTranscriptMessagesAcceptsParentIDAliases`)。
206207
- 本轮补充:memory 层补齐官方 `memoryAge`/freshness note 语义,`ReadDocumentsWithOptions` 可为超过 1 天的 memory 文档前缀 system-reminder,提示模型把 memory 当作 point-in-time observation 并核对当前代码。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ M6 progress now includes:
135135
- `internal/contracts`/`internal/session`: the base `SessionEntry` JSONL loader now accepts role/type, message ID/UUID, parent ID/UUID, and session ID/UUID aliases so older entry files keep type, parent, and session metadata when loaded through `session.Load`.
136136
- `internal/session`: tombstone metadata target/parent loading now accepts target/deleted/message ID aliases and parent ID/message ID aliases, preserving tombstone delete/relink replay across older field spellings.
137137
- `internal/session`: transcript metadata loading now accepts broader ID aliases for summary leaves, content-replacement agent/tool/block IDs, and context-collapse commit IDs across the full loader and lightweight metadata loader.
138+
- `internal/session`: worktree-state metadata now accepts additional wrapper aliases such as `worktreeState`, `worktree`, and `workspace` in both full and lightweight metadata loaders.
138139
- `internal/session`: remote-history parsing now also accepts connection-style `history`/`messages` wrappers with `nodes`/`edges[].node` event lists and `pageInfo`/`page_info` `hasNextPage`/`endCursor`/`startCursor` pagination aliases.
139140
- `internal/session`: remote-history connection edges now use `edges[].cursor` as the event cursor when the nested node lacks an event ID, preserving pagination even when pageInfo omits a cursor.
140141
- `internal/session`: remote-history parsing now also accepts `eventList`/`event_list`, `sessionEvents`/`session_events`, and connection aliases such as `connection`, `eventConnection`, and `sessionEventsConnection`.

internal/session/transcript_metadata_fields.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func parseWorktreeStateMetadata(line []byte) (WorktreeStateEntry, bool) {
151151
entry.SessionID = fields.sessionIDValue()
152152
}
153153
if len(entry.WorktreeSession) == 0 {
154-
entry.WorktreeSession = fields.rawValue("worktree_session")
154+
entry.WorktreeSession = fields.rawValue("worktree_session", "worktreeState", "worktree_state", "worktree", "workspace")
155155
}
156156
return entry, true
157157
}

internal/session/transcript_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ func TestLoadTranscriptCollectsMetadataEntries(t *testing.T) {
620620
`{"type":"mode","session_id":"s3","mode":"worker"}`,
621621
`{"type":"worktree-state","sessionId":"s1","worktreeSession":{"worktreePath":"/tmp/wt","sessionId":"s1"}}`,
622622
`{"type":"worktree_state","session_id":"s3","worktree_session":{"worktreePath":"/tmp/wt2","sessionId":"s3"}}`,
623+
`{"type":"worktree-state","sessionID":"s4","worktreeState":{"worktreePath":"/tmp/wt4","sessionId":"s4"}}`,
623624
`{"type":"file-history-snapshot","messageId":"a1","snapshot":{"files":[]},"isSnapshotUpdate":false}`,
624625
`{"type":"file_history_snapshot","message_id":"a2","snapshot":{"files":["alias"]},"is_snapshot_update":true}`,
625626
`{"type":"attribution-snapshot","messageId":"a1","surface":"cli","fileStates":{}}`,
@@ -664,6 +665,9 @@ func TestLoadTranscriptCollectsMetadataEntries(t *testing.T) {
664665
if transcript.PRLinks["s3"].PRNumber != 43 || transcript.Modes["s3"] != "worker" || len(transcript.WorktreeStates["s3"].WorktreeSession) == 0 {
665666
t.Fatalf("snake session metadata = %#v %#v %#v", transcript.PRLinks, transcript.Modes, transcript.WorktreeStates)
666667
}
668+
if !strings.Contains(string(transcript.WorktreeStates["s4"].WorktreeSession), "/tmp/wt4") {
669+
t.Fatalf("worktree state alias = %#v", transcript.WorktreeStates["s4"])
670+
}
667671
if len(transcript.FileHistorySnapshots) != 2 || len(transcript.AttributionSnapshots) != 2 || len(transcript.SpeculationAccepts) != 2 || transcript.SpeculationAccepts[1].TimeSavedMS != 3400 {
668672
t.Fatalf("raw metadata counts = %d %d %d", len(transcript.FileHistorySnapshots), len(transcript.AttributionSnapshots), len(transcript.SpeculationAccepts))
669673
}
@@ -719,6 +723,9 @@ func TestLoadTranscriptCollectsMetadataEntries(t *testing.T) {
719723
if metadata.PRLinks["s3"].PRNumber != 43 || metadata.Modes["s3"] != "worker" || len(metadata.WorktreeStates["s3"].WorktreeSession) == 0 {
720724
t.Fatalf("metadata snake session = %#v %#v %#v", metadata.PRLinks, metadata.Modes, metadata.WorktreeStates)
721725
}
726+
if !strings.Contains(string(metadata.WorktreeStates["s4"].WorktreeSession), "/tmp/wt4") {
727+
t.Fatalf("metadata worktree state alias = %#v", metadata.WorktreeStates["s4"])
728+
}
722729
if len(metadata.FileHistorySnapshots) != 2 || len(metadata.AttributionSnapshots) != 2 || len(metadata.SpeculationAccepts) != 2 || metadata.SpeculationAccepts[1].TimeSavedMS != 3400 {
723730
t.Fatalf("metadata raw counts = %d %d %d", len(metadata.FileHistorySnapshots), len(metadata.AttributionSnapshots), len(metadata.SpeculationAccepts))
724731
}

0 commit comments

Comments
 (0)