yepanywhere 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled/@yep-anywhere/shared/dist/app-types.d.ts +229 -0
- package/bundled/@yep-anywhere/shared/dist/app-types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/app-types.js +46 -0
- package/bundled/@yep-anywhere/shared/dist/app-types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/DocumentContentSchema.d.ts +16 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/DocumentContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/DocumentContentSchema.js +17 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/DocumentContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ImageContentSchema.d.ts +15 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ImageContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ImageContentSchema.js +10 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ImageContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/TextContentSchema.d.ts +6 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/TextContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/TextContentSchema.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/TextContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ThinkingContentSchema.d.ts +7 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ThinkingContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ThinkingContentSchema.js +7 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ThinkingContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolResultContentSchema.d.ts +24 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolResultContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolResultContentSchema.js +13 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolResultContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolUseContentSchema.d.ts +8 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolUseContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolUseContentSchema.js +8 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolUseContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AssistantEntrySchema.d.ts +78 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AssistantEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AssistantEntrySchema.js +13 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AssistantEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/BaseEntrySchema.d.ts +18 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/BaseEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/BaseEntrySchema.js +19 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/BaseEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/FileHistorySnapshotEntrySchema.d.ts +13 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/FileHistorySnapshotEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/FileHistorySnapshotEntrySchema.js +14 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/FileHistorySnapshotEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.d.ts +68 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.js +37 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SummaryEntrySchema.d.ts +8 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SummaryEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SummaryEntrySchema.js +7 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SummaryEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.d.ts +52 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.js +29 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/UserEntrySchema.d.ts +72 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/UserEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/UserEntrySchema.js +10 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/UserEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/normalizeQueueOperationContent.d.ts +14 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/normalizeQueueOperationContent.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/normalizeQueueOperationContent.js +39 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/normalizeQueueOperationContent.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/guards.d.ts +15 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/guards.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/guards.js +26 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/guards.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.d.ts +566 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.js +39 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.d.ts +93 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.js +40 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/UserMessageSchema.d.ts +105 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/UserMessageSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/UserMessageSchema.js +20 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/UserMessageSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/CommonToolSchema.d.ts +53 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/CommonToolSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/CommonToolSchema.js +54 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/CommonToolSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/StructuredPatchSchema.d.ts +9 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/StructuredPatchSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/StructuredPatchSchema.js +9 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/StructuredPatchSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/TodoSchema.d.ts +32 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/TodoSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/TodoSchema.js +12 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/TodoSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/ToolResultSchemas.d.ts +288 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/ToolResultSchemas.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/ToolResultSchemas.js +293 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/ToolResultSchemas.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/index.d.ts +83 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/index.js +10 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/types.d.ts +42 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/types.js +11 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/content.d.ts +99 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/content.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/content.js +64 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/content.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/index.d.ts +17 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/index.js +17 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.d.ts +600 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.js +282 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/types.d.ts +7 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/types.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/dag.d.ts +35 -0
- package/bundled/@yep-anywhere/shared/dist/dag.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/dag.js +75 -0
- package/bundled/@yep-anywhere/shared/dist/dag.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/filePathDetection.d.ts +72 -0
- package/bundled/@yep-anywhere/shared/dist/filePathDetection.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/filePathDetection.js +376 -0
- package/bundled/@yep-anywhere/shared/dist/filePathDetection.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/content.d.ts +95 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/content.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/content.js +57 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/content.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/events.d.ts +174 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/events.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/events.js +117 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/events.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/index.d.ts +18 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/index.js +18 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/session.d.ts +267 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/session.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/session.js +147 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/session.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/types.d.ts +7 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/types.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/ideMetadata.d.ts +30 -0
- package/bundled/@yep-anywhere/shared/dist/ideMetadata.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/ideMetadata.js +58 -0
- package/bundled/@yep-anywhere/shared/dist/ideMetadata.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/index.d.ts +24 -0
- package/bundled/@yep-anywhere/shared/dist/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/index.js +17 -0
- package/bundled/@yep-anywhere/shared/dist/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/events.d.ts +457 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/events.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/events.js +217 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/events.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/index.d.ts +23 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/index.js +23 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/session.d.ts +149 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/session.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/session.js +158 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/session.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/types.d.ts +7 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/types.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/projectId.d.ts +48 -0
- package/bundled/@yep-anywhere/shared/dist/projectId.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/projectId.js +74 -0
- package/bundled/@yep-anywhere/shared/dist/projectId.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/SessionView.d.ts +171 -0
- package/bundled/@yep-anywhere/shared/dist/session/SessionView.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/SessionView.js +189 -0
- package/bundled/@yep-anywhere/shared/dist/session/SessionView.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/UnifiedSession.d.ts +31 -0
- package/bundled/@yep-anywhere/shared/dist/session/UnifiedSession.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/UnifiedSession.js +2 -0
- package/bundled/@yep-anywhere/shared/dist/session/UnifiedSession.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/index.d.ts +3 -0
- package/bundled/@yep-anywhere/shared/dist/session/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/index.js +2 -0
- package/bundled/@yep-anywhere/shared/dist/session/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/types.d.ts +172 -0
- package/bundled/@yep-anywhere/shared/dist/types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/types.js +33 -0
- package/bundled/@yep-anywhere/shared/dist/types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/upload.d.ts +58 -0
- package/bundled/@yep-anywhere/shared/dist/upload.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/upload.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/upload.js.map +1 -0
- package/bundled/@yep-anywhere/shared/package.json +7 -0
- package/client-dist/assets/index-C7DeAWG4.css +1 -0
- package/client-dist/assets/index-yX0HPwrz.js +147 -0
- package/client-dist/badge-96.png +0 -0
- package/client-dist/badge.svg +20 -0
- package/client-dist/debug-streaming.html +746 -0
- package/client-dist/favicon.ico +0 -0
- package/client-dist/icon-192.png +0 -0
- package/client-dist/icon-512.png +0 -0
- package/client-dist/icon.svg +27 -0
- package/client-dist/index.html +35 -0
- package/client-dist/manifest.json +23 -0
- package/client-dist/sw.js +482 -0
- package/dist/app.d.ts +67 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +236 -0
- package/dist/app.js.map +1 -0
- package/dist/augments/augment-generator.d.ts +30 -0
- package/dist/augments/augment-generator.d.ts.map +1 -0
- package/dist/augments/augment-generator.js +171 -0
- package/dist/augments/augment-generator.js.map +1 -0
- package/dist/augments/block-detector.d.ts +81 -0
- package/dist/augments/block-detector.d.ts.map +1 -0
- package/dist/augments/block-detector.js +615 -0
- package/dist/augments/block-detector.js.map +1 -0
- package/dist/augments/edit-augments.d.ts +138 -0
- package/dist/augments/edit-augments.d.ts.map +1 -0
- package/dist/augments/edit-augments.js +665 -0
- package/dist/augments/edit-augments.js.map +1 -0
- package/dist/augments/index.d.ts +14 -0
- package/dist/augments/index.d.ts.map +1 -0
- package/dist/augments/index.js +20 -0
- package/dist/augments/index.js.map +1 -0
- package/dist/augments/markdown-augments.d.ts +33 -0
- package/dist/augments/markdown-augments.d.ts.map +1 -0
- package/dist/augments/markdown-augments.js +128 -0
- package/dist/augments/markdown-augments.js.map +1 -0
- package/dist/augments/read-augments.d.ts +40 -0
- package/dist/augments/read-augments.d.ts.map +1 -0
- package/dist/augments/read-augments.js +64 -0
- package/dist/augments/read-augments.js.map +1 -0
- package/dist/augments/stream-coordinator.d.ts +32 -0
- package/dist/augments/stream-coordinator.d.ts.map +1 -0
- package/dist/augments/stream-coordinator.js +115 -0
- package/dist/augments/stream-coordinator.js.map +1 -0
- package/dist/augments/write-augments.d.ts +32 -0
- package/dist/augments/write-augments.d.ts.map +1 -0
- package/dist/augments/write-augments.js +27 -0
- package/dist/augments/write-augments.js.map +1 -0
- package/dist/auth/AuthService.d.ts +98 -0
- package/dist/auth/AuthService.d.ts.map +1 -0
- package/dist/auth/AuthService.js +217 -0
- package/dist/auth/AuthService.js.map +1 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +3 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/routes.d.ts +13 -0
- package/dist/auth/routes.d.ts.map +1 -0
- package/dist/auth/routes.js +149 -0
- package/dist/auth/routes.js.map +1 -0
- package/dist/cli.d.ts +19 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +152 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +76 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +124 -0
- package/dist/config.js.map +1 -0
- package/dist/dev-mock.d.ts +18 -0
- package/dist/dev-mock.d.ts.map +1 -0
- package/dist/dev-mock.js +260 -0
- package/dist/dev-mock.js.map +1 -0
- package/dist/frontend/index.d.ts +10 -0
- package/dist/frontend/index.d.ts.map +1 -0
- package/dist/frontend/index.js +10 -0
- package/dist/frontend/index.js.map +1 -0
- package/dist/frontend/proxy.d.ts +70 -0
- package/dist/frontend/proxy.d.ts.map +1 -0
- package/dist/frontend/proxy.js +329 -0
- package/dist/frontend/proxy.js.map +1 -0
- package/dist/frontend/static.d.ts +16 -0
- package/dist/frontend/static.d.ts.map +1 -0
- package/dist/frontend/static.js +106 -0
- package/dist/frontend/static.js.map +1 -0
- package/dist/highlighting/index.d.ts +43 -0
- package/dist/highlighting/index.d.ts.map +1 -0
- package/dist/highlighting/index.js +224 -0
- package/dist/highlighting/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +259 -0
- package/dist/index.js.map +1 -0
- package/dist/indexes/SessionIndexService.d.ts +106 -0
- package/dist/indexes/SessionIndexService.d.ts.map +1 -0
- package/dist/indexes/SessionIndexService.js +356 -0
- package/dist/indexes/SessionIndexService.js.map +1 -0
- package/dist/indexes/index.d.ts +3 -0
- package/dist/indexes/index.d.ts.map +1 -0
- package/dist/indexes/index.js +2 -0
- package/dist/indexes/index.js.map +1 -0
- package/dist/indexes/types.d.ts +55 -0
- package/dist/indexes/types.d.ts.map +1 -0
- package/dist/indexes/types.js +8 -0
- package/dist/indexes/types.js.map +1 -0
- package/dist/logging/index.d.ts +2 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +2 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.d.ts +81 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +257 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/maintenance/debug-routes.d.ts +39 -0
- package/dist/maintenance/debug-routes.d.ts.map +1 -0
- package/dist/maintenance/debug-routes.js +561 -0
- package/dist/maintenance/debug-routes.js.map +1 -0
- package/dist/maintenance/index.d.ts +3 -0
- package/dist/maintenance/index.d.ts.map +1 -0
- package/dist/maintenance/index.js +3 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/maintenance/server.d.ts +53 -0
- package/dist/maintenance/server.d.ts.map +1 -0
- package/dist/maintenance/server.js +419 -0
- package/dist/maintenance/server.js.map +1 -0
- package/dist/metadata/SessionMetadataService.d.ts +96 -0
- package/dist/metadata/SessionMetadataService.d.ts.map +1 -0
- package/dist/metadata/SessionMetadataService.js +209 -0
- package/dist/metadata/SessionMetadataService.js.map +1 -0
- package/dist/metadata/index.d.ts +2 -0
- package/dist/metadata/index.d.ts.map +1 -0
- package/dist/metadata/index.js +2 -0
- package/dist/metadata/index.js.map +1 -0
- package/dist/middleware/auth.d.ts +18 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +53 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/security.d.ts +4 -0
- package/dist/middleware/security.d.ts.map +1 -0
- package/dist/middleware/security.js +28 -0
- package/dist/middleware/security.js.map +1 -0
- package/dist/notifications/NotificationService.d.ts +76 -0
- package/dist/notifications/NotificationService.d.ts.map +1 -0
- package/dist/notifications/NotificationService.js +155 -0
- package/dist/notifications/NotificationService.js.map +1 -0
- package/dist/notifications/index.d.ts +2 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +2 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/projects/codex-scanner.d.ts +52 -0
- package/dist/projects/codex-scanner.d.ts.map +1 -0
- package/dist/projects/codex-scanner.js +167 -0
- package/dist/projects/codex-scanner.js.map +1 -0
- package/dist/projects/gemini-project-map.d.ts +54 -0
- package/dist/projects/gemini-project-map.d.ts.map +1 -0
- package/dist/projects/gemini-project-map.js +116 -0
- package/dist/projects/gemini-project-map.js.map +1 -0
- package/dist/projects/gemini-scanner.d.ts +58 -0
- package/dist/projects/gemini-scanner.d.ts.map +1 -0
- package/dist/projects/gemini-scanner.js +210 -0
- package/dist/projects/gemini-scanner.js.map +1 -0
- package/dist/projects/index.d.ts +16 -0
- package/dist/projects/index.d.ts.map +1 -0
- package/dist/projects/index.js +17 -0
- package/dist/projects/index.js.map +1 -0
- package/dist/projects/paths.d.ts +127 -0
- package/dist/projects/paths.d.ts.map +1 -0
- package/dist/projects/paths.js +185 -0
- package/dist/projects/paths.js.map +1 -0
- package/dist/projects/scanner.d.ts +45 -0
- package/dist/projects/scanner.d.ts.map +1 -0
- package/dist/projects/scanner.js +287 -0
- package/dist/projects/scanner.js.map +1 -0
- package/dist/push/PushNotifier.d.ts +48 -0
- package/dist/push/PushNotifier.d.ts.map +1 -0
- package/dist/push/PushNotifier.js +145 -0
- package/dist/push/PushNotifier.js.map +1 -0
- package/dist/push/PushService.d.ts +95 -0
- package/dist/push/PushService.d.ts.map +1 -0
- package/dist/push/PushService.js +245 -0
- package/dist/push/PushService.js.map +1 -0
- package/dist/push/index.d.ts +9 -0
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +8 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/routes.d.ts +10 -0
- package/dist/push/routes.d.ts.map +1 -0
- package/dist/push/routes.js +111 -0
- package/dist/push/routes.js.map +1 -0
- package/dist/push/types.d.ts +80 -0
- package/dist/push/types.d.ts.map +1 -0
- package/dist/push/types.js +5 -0
- package/dist/push/types.js.map +1 -0
- package/dist/push/vapid.d.ts +42 -0
- package/dist/push/vapid.d.ts.map +1 -0
- package/dist/push/vapid.js +132 -0
- package/dist/push/vapid.js.map +1 -0
- package/dist/recents/RecentsService.d.ts +77 -0
- package/dist/recents/RecentsService.d.ts.map +1 -0
- package/dist/recents/RecentsService.js +155 -0
- package/dist/recents/RecentsService.js.map +1 -0
- package/dist/recents/index.d.ts +2 -0
- package/dist/recents/index.d.ts.map +1 -0
- package/dist/recents/index.js +2 -0
- package/dist/recents/index.js.map +1 -0
- package/dist/routes/activity.d.ts +7 -0
- package/dist/routes/activity.d.ts.map +1 -0
- package/dist/routes/activity.js +80 -0
- package/dist/routes/activity.js.map +1 -0
- package/dist/routes/beads.d.ts +42 -0
- package/dist/routes/beads.d.ts.map +1 -0
- package/dist/routes/beads.js +101 -0
- package/dist/routes/beads.js.map +1 -0
- package/dist/routes/debug-streaming.d.ts +7 -0
- package/dist/routes/debug-streaming.d.ts.map +1 -0
- package/dist/routes/debug-streaming.js +88 -0
- package/dist/routes/debug-streaming.js.map +1 -0
- package/dist/routes/dev.d.ts +11 -0
- package/dist/routes/dev.d.ts.map +1 -0
- package/dist/routes/dev.js +55 -0
- package/dist/routes/dev.js.map +1 -0
- package/dist/routes/files.d.ts +7 -0
- package/dist/routes/files.d.ts.map +1 -0
- package/dist/routes/files.js +429 -0
- package/dist/routes/files.js.map +1 -0
- package/dist/routes/global-sessions.d.ts +76 -0
- package/dist/routes/global-sessions.d.ts.map +1 -0
- package/dist/routes/global-sessions.js +207 -0
- package/dist/routes/global-sessions.js.map +1 -0
- package/dist/routes/health.d.ts +3 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +6 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/inbox.d.ts +45 -0
- package/dist/routes/inbox.d.ts.map +1 -0
- package/dist/routes/inbox.js +174 -0
- package/dist/routes/inbox.js.map +1 -0
- package/dist/routes/processes.d.ts +16 -0
- package/dist/routes/processes.d.ts.map +1 -0
- package/dist/routes/processes.js +82 -0
- package/dist/routes/processes.js.map +1 -0
- package/dist/routes/projects.d.ts +30 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +316 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/providers.d.ts +9 -0
- package/dist/routes/providers.d.ts.map +1 -0
- package/dist/routes/providers.js +63 -0
- package/dist/routes/providers.js.map +1 -0
- package/dist/routes/recents.d.ts +14 -0
- package/dist/routes/recents.d.ts.map +1 -0
- package/dist/routes/recents.js +82 -0
- package/dist/routes/recents.js.map +1 -0
- package/dist/routes/sessions.d.ts +26 -0
- package/dist/routes/sessions.d.ts.map +1 -0
- package/dist/routes/sessions.js +962 -0
- package/dist/routes/sessions.js.map +1 -0
- package/dist/routes/stream.d.ts +7 -0
- package/dist/routes/stream.d.ts.map +1 -0
- package/dist/routes/stream.js +561 -0
- package/dist/routes/stream.js.map +1 -0
- package/dist/routes/upload.d.ts +14 -0
- package/dist/routes/upload.d.ts.map +1 -0
- package/dist/routes/upload.js +278 -0
- package/dist/routes/upload.js.map +1 -0
- package/dist/sdk/cli-detection.d.ts +47 -0
- package/dist/sdk/cli-detection.d.ts.map +1 -0
- package/dist/sdk/cli-detection.js +122 -0
- package/dist/sdk/cli-detection.js.map +1 -0
- package/dist/sdk/messageLogger.d.ts +15 -0
- package/dist/sdk/messageLogger.d.ts.map +1 -0
- package/dist/sdk/messageLogger.js +68 -0
- package/dist/sdk/messageLogger.js.map +1 -0
- package/dist/sdk/messageQueue.d.ts +49 -0
- package/dist/sdk/messageQueue.d.ts.map +1 -0
- package/dist/sdk/messageQueue.js +186 -0
- package/dist/sdk/messageQueue.js.map +1 -0
- package/dist/sdk/mock.d.ts +16 -0
- package/dist/sdk/mock.d.ts.map +1 -0
- package/dist/sdk/mock.js +81 -0
- package/dist/sdk/mock.js.map +1 -0
- package/dist/sdk/providers/__mocks__/base.d.ts +78 -0
- package/dist/sdk/providers/__mocks__/base.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/base.js +185 -0
- package/dist/sdk/providers/__mocks__/base.js.map +1 -0
- package/dist/sdk/providers/__mocks__/claude.d.ts +33 -0
- package/dist/sdk/providers/__mocks__/claude.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/claude.js +146 -0
- package/dist/sdk/providers/__mocks__/claude.js.map +1 -0
- package/dist/sdk/providers/__mocks__/codex.d.ts +45 -0
- package/dist/sdk/providers/__mocks__/codex.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/codex.js +160 -0
- package/dist/sdk/providers/__mocks__/codex.js.map +1 -0
- package/dist/sdk/providers/__mocks__/factory.d.ts +40 -0
- package/dist/sdk/providers/__mocks__/factory.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/factory.js +183 -0
- package/dist/sdk/providers/__mocks__/factory.js.map +1 -0
- package/dist/sdk/providers/__mocks__/gemini.d.ts +43 -0
- package/dist/sdk/providers/__mocks__/gemini.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/gemini.js +198 -0
- package/dist/sdk/providers/__mocks__/gemini.js.map +1 -0
- package/dist/sdk/providers/__mocks__/index.d.ts +23 -0
- package/dist/sdk/providers/__mocks__/index.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/index.js +25 -0
- package/dist/sdk/providers/__mocks__/index.js.map +1 -0
- package/dist/sdk/providers/__mocks__/opencode.d.ts +33 -0
- package/dist/sdk/providers/__mocks__/opencode.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/opencode.js +136 -0
- package/dist/sdk/providers/__mocks__/opencode.js.map +1 -0
- package/dist/sdk/providers/__mocks__/types.d.ts +50 -0
- package/dist/sdk/providers/__mocks__/types.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/types.js +8 -0
- package/dist/sdk/providers/__mocks__/types.js.map +1 -0
- package/dist/sdk/providers/claude.d.ts +63 -0
- package/dist/sdk/providers/claude.d.ts.map +1 -0
- package/dist/sdk/providers/claude.js +252 -0
- package/dist/sdk/providers/claude.js.map +1 -0
- package/dist/sdk/providers/codex-oss.d.ts +108 -0
- package/dist/sdk/providers/codex-oss.d.ts.map +1 -0
- package/dist/sdk/providers/codex-oss.js +744 -0
- package/dist/sdk/providers/codex-oss.js.map +1 -0
- package/dist/sdk/providers/codex.d.ts +82 -0
- package/dist/sdk/providers/codex.d.ts.map +1 -0
- package/dist/sdk/providers/codex.js +597 -0
- package/dist/sdk/providers/codex.js.map +1 -0
- package/dist/sdk/providers/gemini.d.ts +78 -0
- package/dist/sdk/providers/gemini.d.ts.map +1 -0
- package/dist/sdk/providers/gemini.js +536 -0
- package/dist/sdk/providers/gemini.js.map +1 -0
- package/dist/sdk/providers/index.d.ts +22 -0
- package/dist/sdk/providers/index.d.ts.map +1 -0
- package/dist/sdk/providers/index.js +53 -0
- package/dist/sdk/providers/index.js.map +1 -0
- package/dist/sdk/providers/opencode.d.ts +95 -0
- package/dist/sdk/providers/opencode.d.ts.map +1 -0
- package/dist/sdk/providers/opencode.js +586 -0
- package/dist/sdk/providers/opencode.js.map +1 -0
- package/dist/sdk/providers/types.d.ts +99 -0
- package/dist/sdk/providers/types.d.ts.map +1 -0
- package/dist/sdk/providers/types.js +2 -0
- package/dist/sdk/providers/types.js.map +1 -0
- package/dist/sdk/real.d.ts +20 -0
- package/dist/sdk/real.d.ts.map +1 -0
- package/dist/sdk/real.js +22 -0
- package/dist/sdk/real.js.map +1 -0
- package/dist/sdk/types.d.ts +113 -0
- package/dist/sdk/types.d.ts.map +1 -0
- package/dist/sdk/types.js +3 -0
- package/dist/sdk/types.js.map +1 -0
- package/dist/sessions/Session.d.ts +80 -0
- package/dist/sessions/Session.d.ts.map +1 -0
- package/dist/sessions/Session.js +119 -0
- package/dist/sessions/Session.js.map +1 -0
- package/dist/sessions/codex-reader.d.ts +166 -0
- package/dist/sessions/codex-reader.d.ts.map +1 -0
- package/dist/sessions/codex-reader.js +664 -0
- package/dist/sessions/codex-reader.js.map +1 -0
- package/dist/sessions/dag.d.ts +62 -0
- package/dist/sessions/dag.d.ts.map +1 -0
- package/dist/sessions/dag.js +175 -0
- package/dist/sessions/dag.js.map +1 -0
- package/dist/sessions/fork.d.ts +34 -0
- package/dist/sessions/fork.d.ts.map +1 -0
- package/dist/sessions/fork.js +58 -0
- package/dist/sessions/fork.js.map +1 -0
- package/dist/sessions/gemini-reader.d.ts +103 -0
- package/dist/sessions/gemini-reader.d.ts.map +1 -0
- package/dist/sessions/gemini-reader.js +332 -0
- package/dist/sessions/gemini-reader.js.map +1 -0
- package/dist/sessions/normalization.d.ts +7 -0
- package/dist/sessions/normalization.d.ts.map +1 -0
- package/dist/sessions/normalization.js +429 -0
- package/dist/sessions/normalization.js.map +1 -0
- package/dist/sessions/opencode-reader.d.ts +99 -0
- package/dist/sessions/opencode-reader.d.ts.map +1 -0
- package/dist/sessions/opencode-reader.js +370 -0
- package/dist/sessions/opencode-reader.js.map +1 -0
- package/dist/sessions/reader.d.ts +118 -0
- package/dist/sessions/reader.d.ts.map +1 -0
- package/dist/sessions/reader.js +444 -0
- package/dist/sessions/reader.js.map +1 -0
- package/dist/sessions/types.d.ts +77 -0
- package/dist/sessions/types.d.ts.map +1 -0
- package/dist/sessions/types.js +8 -0
- package/dist/sessions/types.js.map +1 -0
- package/dist/supervisor/ExternalSessionTracker.d.ts +94 -0
- package/dist/supervisor/ExternalSessionTracker.d.ts.map +1 -0
- package/dist/supervisor/ExternalSessionTracker.js +507 -0
- package/dist/supervisor/ExternalSessionTracker.js.map +1 -0
- package/dist/supervisor/Process.d.ts +230 -0
- package/dist/supervisor/Process.d.ts.map +1 -0
- package/dist/supervisor/Process.js +878 -0
- package/dist/supervisor/Process.js.map +1 -0
- package/dist/supervisor/Supervisor.d.ts +191 -0
- package/dist/supervisor/Supervisor.d.ts.map +1 -0
- package/dist/supervisor/Supervisor.js +933 -0
- package/dist/supervisor/Supervisor.js.map +1 -0
- package/dist/supervisor/WorkerQueue.d.ts +113 -0
- package/dist/supervisor/WorkerQueue.d.ts.map +1 -0
- package/dist/supervisor/WorkerQueue.js +148 -0
- package/dist/supervisor/WorkerQueue.js.map +1 -0
- package/dist/supervisor/types.d.ts +176 -0
- package/dist/supervisor/types.d.ts.map +1 -0
- package/dist/supervisor/types.js +7 -0
- package/dist/supervisor/types.js.map +1 -0
- package/dist/testing/mockProjectData.d.ts +5 -0
- package/dist/testing/mockProjectData.d.ts.map +1 -0
- package/dist/testing/mockProjectData.js +27 -0
- package/dist/testing/mockProjectData.js.map +1 -0
- package/dist/uploads/index.d.ts +3 -0
- package/dist/uploads/index.d.ts.map +1 -0
- package/dist/uploads/index.js +2 -0
- package/dist/uploads/index.js.map +1 -0
- package/dist/uploads/manager.d.ts +84 -0
- package/dist/uploads/manager.d.ts.map +1 -0
- package/dist/uploads/manager.js +215 -0
- package/dist/uploads/manager.js.map +1 -0
- package/dist/utils/fileLock.d.ts +57 -0
- package/dist/utils/fileLock.d.ts.map +1 -0
- package/dist/utils/fileLock.js +91 -0
- package/dist/utils/fileLock.js.map +1 -0
- package/dist/watcher/BatchProcessor.d.ts +58 -0
- package/dist/watcher/BatchProcessor.d.ts.map +1 -0
- package/dist/watcher/BatchProcessor.js +105 -0
- package/dist/watcher/BatchProcessor.js.map +1 -0
- package/dist/watcher/EventBus.d.ts +157 -0
- package/dist/watcher/EventBus.d.ts.map +1 -0
- package/dist/watcher/EventBus.js +36 -0
- package/dist/watcher/EventBus.js.map +1 -0
- package/dist/watcher/FileWatcher.d.ts +42 -0
- package/dist/watcher/FileWatcher.d.ts.map +1 -0
- package/dist/watcher/FileWatcher.js +165 -0
- package/dist/watcher/FileWatcher.js.map +1 -0
- package/dist/watcher/SourceWatcher.d.ts +36 -0
- package/dist/watcher/SourceWatcher.d.ts.map +1 -0
- package/dist/watcher/SourceWatcher.js +97 -0
- package/dist/watcher/SourceWatcher.js.map +1 -0
- package/dist/watcher/index.d.ts +9 -0
- package/dist/watcher/index.d.ts.map +1 -0
- package/dist/watcher/index.js +5 -0
- package/dist/watcher/index.js.map +1 -0
- package/package.json +54 -0
- package/scripts/postinstall.js +48 -0
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit augment service - computes structuredPatch and highlighted diff HTML
|
|
3
|
+
* for Edit tool_use blocks.
|
|
4
|
+
*
|
|
5
|
+
* This enables consistent unified diff display for both pending (tool_use)
|
|
6
|
+
* and completed (tool_result) edits.
|
|
7
|
+
*/
|
|
8
|
+
import { diffWordsWithSpace, structuredPatch } from "diff";
|
|
9
|
+
import { getLanguageForPath, highlightCode } from "../highlighting/index.js";
|
|
10
|
+
/** Number of context lines to include in the diff */
|
|
11
|
+
const CONTEXT_LINES = 3;
|
|
12
|
+
/**
|
|
13
|
+
* Convert jsdiff patch hunks to our PatchHunk format.
|
|
14
|
+
* jsdiff hunks have the same structure but we need to add line prefixes.
|
|
15
|
+
*/
|
|
16
|
+
function convertHunks(hunks) {
|
|
17
|
+
return hunks.map((hunk) => ({
|
|
18
|
+
oldStart: hunk.oldStart,
|
|
19
|
+
oldLines: hunk.oldLines,
|
|
20
|
+
newStart: hunk.newStart,
|
|
21
|
+
newLines: hunk.newLines,
|
|
22
|
+
// Filter out "" - not useful for UI display
|
|
23
|
+
lines: hunk.lines.filter((line) => line !== "\"),
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert structured patch hunks to unified diff text for highlighting.
|
|
28
|
+
*/
|
|
29
|
+
function patchToUnifiedText(hunks) {
|
|
30
|
+
const lines = [];
|
|
31
|
+
for (const hunk of hunks) {
|
|
32
|
+
// Add hunk header
|
|
33
|
+
lines.push(`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`);
|
|
34
|
+
// Add diff lines (already prefixed with ' ', '-', or '+')
|
|
35
|
+
lines.push(...hunk.lines);
|
|
36
|
+
}
|
|
37
|
+
return lines.join("\n");
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Extract the inner content of each <span class="line">...</span> from Shiki HTML.
|
|
41
|
+
* Handles nested spans by counting depth.
|
|
42
|
+
*/
|
|
43
|
+
function extractShikiLines(html) {
|
|
44
|
+
const lines = [];
|
|
45
|
+
const lineStartRegex = /<span class="line">/g;
|
|
46
|
+
let match = lineStartRegex.exec(html);
|
|
47
|
+
while (match !== null) {
|
|
48
|
+
const startPos = match.index + match[0].length;
|
|
49
|
+
let depth = 1;
|
|
50
|
+
let pos = startPos;
|
|
51
|
+
// Find the matching closing </span> by tracking nesting depth
|
|
52
|
+
while (depth > 0 && pos < html.length) {
|
|
53
|
+
const nextOpen = html.indexOf("<span", pos);
|
|
54
|
+
const nextClose = html.indexOf("</span>", pos);
|
|
55
|
+
if (nextClose === -1)
|
|
56
|
+
break;
|
|
57
|
+
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
58
|
+
depth++;
|
|
59
|
+
pos = nextOpen + 5; // Move past "<span"
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
depth--;
|
|
63
|
+
if (depth === 0) {
|
|
64
|
+
lines.push(html.slice(startPos, nextClose));
|
|
65
|
+
}
|
|
66
|
+
pos = nextClose + 7; // Move past "</span>"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
match = lineStartRegex.exec(html);
|
|
70
|
+
}
|
|
71
|
+
return lines;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Pre-compute word diffs for replacement pairs in a hunk.
|
|
75
|
+
* Returns maps from line indices to word diffs.
|
|
76
|
+
*/
|
|
77
|
+
function computeHunkWordDiffs(hunk, hunkOldStartIdx, // Starting index in oldLines for this hunk
|
|
78
|
+
hunkNewStartIdx) {
|
|
79
|
+
const oldLineDiffs = new Map();
|
|
80
|
+
const newLineDiffs = new Map();
|
|
81
|
+
// Find replacement pairs in this hunk
|
|
82
|
+
const { pairs } = findReplacePairs(hunk.lines);
|
|
83
|
+
// For each pair, compute word diff and store by absolute line index
|
|
84
|
+
// We need to map the pair's relative indices back to the oldLines/newLines arrays
|
|
85
|
+
// Track how many - and + lines we've seen to compute absolute indices
|
|
86
|
+
let oldOffset = 0;
|
|
87
|
+
let newOffset = 0;
|
|
88
|
+
let currentRemovals = [];
|
|
89
|
+
let currentAdditions = [];
|
|
90
|
+
const flushPairs = () => {
|
|
91
|
+
const pairCount = Math.min(currentRemovals.length, currentAdditions.length);
|
|
92
|
+
for (let i = 0; i < pairCount; i++) {
|
|
93
|
+
const removal = currentRemovals[i];
|
|
94
|
+
const addition = currentAdditions[i];
|
|
95
|
+
if (removal && addition) {
|
|
96
|
+
const wordDiff = computeWordDiff(removal.text, addition.text);
|
|
97
|
+
// Only add if there are actual changes (not all unchanged)
|
|
98
|
+
const hasChanges = wordDiff.some((seg) => seg.type === "removed" || seg.type === "added");
|
|
99
|
+
if (hasChanges) {
|
|
100
|
+
oldLineDiffs.set(removal.absIdx, wordDiff);
|
|
101
|
+
newLineDiffs.set(addition.absIdx, wordDiff);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
currentRemovals = [];
|
|
106
|
+
currentAdditions = [];
|
|
107
|
+
};
|
|
108
|
+
for (const line of hunk.lines) {
|
|
109
|
+
const prefix = line[0];
|
|
110
|
+
const text = line.slice(1);
|
|
111
|
+
if (prefix === "-") {
|
|
112
|
+
// If we were collecting additions, flush first
|
|
113
|
+
if (currentAdditions.length > 0) {
|
|
114
|
+
flushPairs();
|
|
115
|
+
}
|
|
116
|
+
currentRemovals.push({
|
|
117
|
+
absIdx: hunkOldStartIdx + oldOffset,
|
|
118
|
+
text,
|
|
119
|
+
});
|
|
120
|
+
oldOffset++;
|
|
121
|
+
}
|
|
122
|
+
else if (prefix === "+") {
|
|
123
|
+
currentAdditions.push({
|
|
124
|
+
absIdx: hunkNewStartIdx + newOffset,
|
|
125
|
+
text,
|
|
126
|
+
});
|
|
127
|
+
newOffset++;
|
|
128
|
+
}
|
|
129
|
+
else if (prefix === " ") {
|
|
130
|
+
flushPairs();
|
|
131
|
+
oldOffset++;
|
|
132
|
+
newOffset++;
|
|
133
|
+
}
|
|
134
|
+
else if (line.startsWith("@@")) {
|
|
135
|
+
flushPairs();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Flush any remaining pairs
|
|
139
|
+
flushPairs();
|
|
140
|
+
return { oldLineDiffs, newLineDiffs };
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Build syntax-highlighted diff HTML by highlighting old_string and new_string
|
|
144
|
+
* separately with the file's language, then reconstructing the diff.
|
|
145
|
+
*
|
|
146
|
+
* @returns Highlighted HTML or null if language is unknown/unsupported
|
|
147
|
+
*/
|
|
148
|
+
async function highlightDiffWithSyntax(oldString, newString, hunks, filePath) {
|
|
149
|
+
// Detect language from file extension
|
|
150
|
+
const lang = getLanguageForPath(filePath);
|
|
151
|
+
if (!lang)
|
|
152
|
+
return null;
|
|
153
|
+
// Highlight both strings with the file's language
|
|
154
|
+
// Handle empty strings - highlightCode returns null for empty input
|
|
155
|
+
const oldResult = oldString.length > 0 ? await highlightCode(oldString, lang) : null;
|
|
156
|
+
const newResult = newString.length > 0 ? await highlightCode(newString, lang) : null;
|
|
157
|
+
// If both fail (not just empty), fall back
|
|
158
|
+
if (!oldResult && oldString.length > 0)
|
|
159
|
+
return null;
|
|
160
|
+
if (!newResult && newString.length > 0)
|
|
161
|
+
return null;
|
|
162
|
+
// Extract lines from Shiki HTML
|
|
163
|
+
const oldLines = oldResult ? extractShikiLines(oldResult.html) : [];
|
|
164
|
+
const newLines = newResult ? extractShikiLines(newResult.html) : [];
|
|
165
|
+
// Pre-compute word diffs for all hunks
|
|
166
|
+
const allOldLineDiffs = new Map();
|
|
167
|
+
const allNewLineDiffs = new Map();
|
|
168
|
+
for (const hunk of hunks) {
|
|
169
|
+
const hunkOldStartIdx = hunk.oldStart - 1; // Convert to 0-indexed
|
|
170
|
+
const hunkNewStartIdx = hunk.newStart - 1;
|
|
171
|
+
const { oldLineDiffs, newLineDiffs } = computeHunkWordDiffs(hunk, hunkOldStartIdx, hunkNewStartIdx);
|
|
172
|
+
// Merge into global maps
|
|
173
|
+
for (const [idx, diff] of oldLineDiffs) {
|
|
174
|
+
allOldLineDiffs.set(idx, diff);
|
|
175
|
+
}
|
|
176
|
+
for (const [idx, diff] of newLineDiffs) {
|
|
177
|
+
allNewLineDiffs.set(idx, diff);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// Build diff HTML by mapping hunk lines to highlighted source lines
|
|
181
|
+
const resultLines = [];
|
|
182
|
+
for (const hunk of hunks) {
|
|
183
|
+
// Add hunk header (hidden by CSS but needed for tests)
|
|
184
|
+
resultLines.push(`<span class="line line-hunk">@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@</span>`);
|
|
185
|
+
let oldIdx = hunk.oldStart - 1; // 0-indexed
|
|
186
|
+
let newIdx = hunk.newStart - 1;
|
|
187
|
+
for (const line of hunk.lines) {
|
|
188
|
+
const prefix = line[0];
|
|
189
|
+
let lineClass;
|
|
190
|
+
let content;
|
|
191
|
+
if (prefix === " ") {
|
|
192
|
+
// Context line - use old (identical in both)
|
|
193
|
+
lineClass = "line line-context";
|
|
194
|
+
content = oldLines[oldIdx++] ?? "";
|
|
195
|
+
newIdx++;
|
|
196
|
+
}
|
|
197
|
+
else if (prefix === "-") {
|
|
198
|
+
// Deleted line - use old
|
|
199
|
+
lineClass = "line line-deleted";
|
|
200
|
+
content = oldLines[oldIdx] ?? "";
|
|
201
|
+
// Apply word diff if available
|
|
202
|
+
const wordDiff = allOldLineDiffs.get(oldIdx);
|
|
203
|
+
if (wordDiff) {
|
|
204
|
+
content = injectWordDiffMarkers(content, wordDiff, "old");
|
|
205
|
+
}
|
|
206
|
+
oldIdx++;
|
|
207
|
+
}
|
|
208
|
+
else if (prefix === "+") {
|
|
209
|
+
// Inserted line - use new
|
|
210
|
+
lineClass = "line line-inserted";
|
|
211
|
+
content = newLines[newIdx] ?? "";
|
|
212
|
+
// Apply word diff if available
|
|
213
|
+
const wordDiff = allNewLineDiffs.get(newIdx);
|
|
214
|
+
if (wordDiff) {
|
|
215
|
+
content = injectWordDiffMarkers(content, wordDiff, "new");
|
|
216
|
+
}
|
|
217
|
+
newIdx++;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
continue; // Skip unexpected
|
|
221
|
+
}
|
|
222
|
+
resultLines.push(`<span class="${lineClass}"><span class="diff-prefix">${escapeHtml(prefix)}</span>${content}</span>`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return `<pre class="shiki"><code class="language-${lang}">${resultLines.join("\n")}</code></pre>`;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Compute an edit augment for an Edit tool_use.
|
|
229
|
+
*
|
|
230
|
+
* @param toolUseId - The tool_use ID to associate with this augment
|
|
231
|
+
* @param input - The Edit tool input containing file_path, old_string, new_string
|
|
232
|
+
* @returns EditAugment with structuredPatch and highlighted diff HTML
|
|
233
|
+
*/
|
|
234
|
+
export async function computeEditAugment(toolUseId, input) {
|
|
235
|
+
const { file_path, old_string, new_string } = input;
|
|
236
|
+
// Compute structured patch using jsdiff
|
|
237
|
+
const patch = structuredPatch(file_path, file_path, old_string, new_string, "", // oldHeader
|
|
238
|
+
"", // newHeader
|
|
239
|
+
{ context: CONTEXT_LINES });
|
|
240
|
+
// Convert hunks to our format
|
|
241
|
+
const structuredPatchResult = convertHunks(patch.hunks);
|
|
242
|
+
// Try syntax-highlighted diff first (highlights code with file's language)
|
|
243
|
+
let diffHtml = await highlightDiffWithSyntax(old_string, new_string, structuredPatchResult, file_path);
|
|
244
|
+
// Fall back to diff-only highlighting if syntax highlighting fails
|
|
245
|
+
if (!diffHtml) {
|
|
246
|
+
const diffText = patchToUnifiedText(structuredPatchResult);
|
|
247
|
+
const highlightResult = await highlightCode(diffText, "diff");
|
|
248
|
+
if (highlightResult) {
|
|
249
|
+
// Post-process to add line type classes for background colors
|
|
250
|
+
diffHtml = addDiffLineClasses(highlightResult.html);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
// Fallback to plain text wrapped in pre/code
|
|
254
|
+
diffHtml = `<pre class="shiki"><code class="language-diff">${escapeHtml(diffText)}</code></pre>`;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
toolUseId,
|
|
259
|
+
type: "edit",
|
|
260
|
+
structuredPatch: structuredPatchResult,
|
|
261
|
+
diffHtml,
|
|
262
|
+
filePath: file_path,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Add diff line type classes to shiki HTML output.
|
|
267
|
+
* Detects line content and adds classes like "line-deleted", "line-inserted", "line-context", "line-hunk".
|
|
268
|
+
* This enables CSS background colors for traditional diff styling.
|
|
269
|
+
*/
|
|
270
|
+
function addDiffLineClasses(html) {
|
|
271
|
+
// Match each <span class="line">...</span> and inspect content
|
|
272
|
+
return html.replace(/<span class="line">([\s\S]*?)<\/span>/g, (_match, content) => {
|
|
273
|
+
// Decode HTML entities to check the actual first character
|
|
274
|
+
const decoded = content
|
|
275
|
+
.replace(/</g, "<")
|
|
276
|
+
.replace(/>/g, ">")
|
|
277
|
+
.replace(/&/g, "&");
|
|
278
|
+
// Get the visible text (strip HTML tags)
|
|
279
|
+
const textContent = decoded.replace(/<[^>]*>/g, "");
|
|
280
|
+
const firstChar = textContent[0];
|
|
281
|
+
let lineClass = "line";
|
|
282
|
+
if (firstChar === "-") {
|
|
283
|
+
lineClass = "line line-deleted";
|
|
284
|
+
}
|
|
285
|
+
else if (firstChar === "+") {
|
|
286
|
+
lineClass = "line line-inserted";
|
|
287
|
+
}
|
|
288
|
+
else if (firstChar === "@") {
|
|
289
|
+
lineClass = "line line-hunk";
|
|
290
|
+
}
|
|
291
|
+
else if (firstChar === " ") {
|
|
292
|
+
lineClass = "line line-context";
|
|
293
|
+
}
|
|
294
|
+
return `<span class="${lineClass}">${content}</span>`;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Escape HTML special characters for fallback rendering.
|
|
299
|
+
*/
|
|
300
|
+
function escapeHtml(text) {
|
|
301
|
+
return text
|
|
302
|
+
.replace(/&/g, "&")
|
|
303
|
+
.replace(/</g, "<")
|
|
304
|
+
.replace(/>/g, ">")
|
|
305
|
+
.replace(/"/g, """)
|
|
306
|
+
.replace(/'/g, "'");
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Find consecutive -/+ line pairs in diff hunk lines that represent "replacements".
|
|
310
|
+
* These pairs are candidates for word-level diffing.
|
|
311
|
+
*
|
|
312
|
+
* Pairing strategy:
|
|
313
|
+
* - Match removed lines with added lines in order (first - with first +, etc.)
|
|
314
|
+
* - If there are more - than +, extra removed lines have no pair
|
|
315
|
+
* - If there are more + than -, extra added lines have no pair
|
|
316
|
+
* - Context lines (space prefix) or hunk headers (@@) reset the grouping
|
|
317
|
+
*
|
|
318
|
+
* @param hunkLines - Array of diff lines with prefixes: ' ', '-', '+', or starting with '@@'
|
|
319
|
+
* @returns Object containing pairs and unpaired lines
|
|
320
|
+
*/
|
|
321
|
+
function findReplacePairs(hunkLines) {
|
|
322
|
+
const result = {
|
|
323
|
+
pairs: [],
|
|
324
|
+
unpairedRemovals: [],
|
|
325
|
+
unpairedAdditions: [],
|
|
326
|
+
};
|
|
327
|
+
// Collect removals and additions in the current contiguous group
|
|
328
|
+
let currentRemovals = [];
|
|
329
|
+
let currentAdditions = [];
|
|
330
|
+
/**
|
|
331
|
+
* Process the current group of removals and additions, creating pairs
|
|
332
|
+
* and tracking unpaired lines.
|
|
333
|
+
*/
|
|
334
|
+
function flushGroup() {
|
|
335
|
+
// Pair up removals and additions in order
|
|
336
|
+
const pairCount = Math.min(currentRemovals.length, currentAdditions.length);
|
|
337
|
+
for (let i = 0; i < pairCount; i++) {
|
|
338
|
+
const removal = currentRemovals[i];
|
|
339
|
+
const addition = currentAdditions[i];
|
|
340
|
+
if (removal && addition) {
|
|
341
|
+
result.pairs.push({
|
|
342
|
+
oldLineIndex: i,
|
|
343
|
+
newLineIndex: i,
|
|
344
|
+
oldText: removal.text,
|
|
345
|
+
newText: addition.text,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// Track unpaired removals (when more - than +)
|
|
350
|
+
for (let i = pairCount; i < currentRemovals.length; i++) {
|
|
351
|
+
const removal = currentRemovals[i];
|
|
352
|
+
if (removal) {
|
|
353
|
+
result.unpairedRemovals.push(removal);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// Track unpaired additions (when more + than -)
|
|
357
|
+
for (let i = pairCount; i < currentAdditions.length; i++) {
|
|
358
|
+
const addition = currentAdditions[i];
|
|
359
|
+
if (addition) {
|
|
360
|
+
result.unpairedAdditions.push(addition);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
// Reset for next group
|
|
364
|
+
currentRemovals = [];
|
|
365
|
+
currentAdditions = [];
|
|
366
|
+
}
|
|
367
|
+
for (const line of hunkLines) {
|
|
368
|
+
const prefix = line[0];
|
|
369
|
+
if (prefix === "-") {
|
|
370
|
+
// If we were collecting additions, flush the group first
|
|
371
|
+
// (additions after removals is normal, but - after + means new group)
|
|
372
|
+
if (currentAdditions.length > 0) {
|
|
373
|
+
flushGroup();
|
|
374
|
+
}
|
|
375
|
+
currentRemovals.push({
|
|
376
|
+
index: currentRemovals.length,
|
|
377
|
+
text: line.slice(1),
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
else if (prefix === "+") {
|
|
381
|
+
// Additions are added to current group
|
|
382
|
+
currentAdditions.push({
|
|
383
|
+
index: currentAdditions.length,
|
|
384
|
+
text: line.slice(1),
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
else if (prefix === " " || line.startsWith("@@")) {
|
|
388
|
+
// Context line or hunk header - flush current group and reset
|
|
389
|
+
flushGroup();
|
|
390
|
+
}
|
|
391
|
+
// Skip other lines (like "")
|
|
392
|
+
}
|
|
393
|
+
// Flush any remaining group
|
|
394
|
+
flushGroup();
|
|
395
|
+
return result;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Compute word-level diff between two strings.
|
|
399
|
+
* Uses jsdiff's diffWordsWithSpace to find word-by-word changes.
|
|
400
|
+
* Unlike diffWords, this treats whitespace as significant, so leading
|
|
401
|
+
* indentation is preserved as unchanged when only words change.
|
|
402
|
+
*
|
|
403
|
+
* @param oldLine - The original string
|
|
404
|
+
* @param newLine - The modified string
|
|
405
|
+
* @returns Array of diff segments with their types
|
|
406
|
+
*/
|
|
407
|
+
function computeWordDiff(oldLine, newLine) {
|
|
408
|
+
const changes = diffWordsWithSpace(oldLine, newLine);
|
|
409
|
+
return changes.map((change) => ({
|
|
410
|
+
text: change.value,
|
|
411
|
+
type: change.added ? "added" : change.removed ? "removed" : "unchanged",
|
|
412
|
+
}));
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Maps HTML entity names to their decoded characters.
|
|
416
|
+
*/
|
|
417
|
+
const HTML_ENTITY_MAP = {
|
|
418
|
+
"<": "<",
|
|
419
|
+
">": ">",
|
|
420
|
+
"&": "&",
|
|
421
|
+
""": '"',
|
|
422
|
+
"'": "'",
|
|
423
|
+
"'": "'",
|
|
424
|
+
};
|
|
425
|
+
/**
|
|
426
|
+
* Parse HTML into segments of text content and tags.
|
|
427
|
+
* Text content has HTML entities decoded for matching against plain text.
|
|
428
|
+
*/
|
|
429
|
+
function parseHtmlSegments(html) {
|
|
430
|
+
const segments = [];
|
|
431
|
+
const tagRegex = /<[^>]*>/g;
|
|
432
|
+
let lastIndex = 0;
|
|
433
|
+
for (const match of html.matchAll(tagRegex)) {
|
|
434
|
+
// Add text content before this tag
|
|
435
|
+
if (match.index > lastIndex) {
|
|
436
|
+
const content = html.slice(lastIndex, match.index);
|
|
437
|
+
segments.push({
|
|
438
|
+
type: "text",
|
|
439
|
+
content,
|
|
440
|
+
plainText: decodeHtmlEntities(content),
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
// Add the tag itself
|
|
444
|
+
segments.push({
|
|
445
|
+
type: "tag",
|
|
446
|
+
content: match[0],
|
|
447
|
+
});
|
|
448
|
+
lastIndex = match.index + match[0].length;
|
|
449
|
+
}
|
|
450
|
+
// Add any remaining text after the last tag
|
|
451
|
+
if (lastIndex < html.length) {
|
|
452
|
+
const content = html.slice(lastIndex);
|
|
453
|
+
segments.push({
|
|
454
|
+
type: "text",
|
|
455
|
+
content,
|
|
456
|
+
plainText: decodeHtmlEntities(content),
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
return segments;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Decode HTML entities in a string to their plain text equivalents.
|
|
463
|
+
* Handles named entities (<), decimal entities (<), and hex entities (<).
|
|
464
|
+
*/
|
|
465
|
+
function decodeHtmlEntities(html) {
|
|
466
|
+
return html.replace(/&[^;]+;/g, (entity) => {
|
|
467
|
+
// Check named entity map first
|
|
468
|
+
if (HTML_ENTITY_MAP[entity]) {
|
|
469
|
+
return HTML_ENTITY_MAP[entity];
|
|
470
|
+
}
|
|
471
|
+
// Handle numeric entities: < (decimal) or < (hex)
|
|
472
|
+
if (entity.startsWith("&#")) {
|
|
473
|
+
const isHex = entity[2] === "x" || entity[2] === "X";
|
|
474
|
+
const numStr = isHex ? entity.slice(3, -1) : entity.slice(2, -1);
|
|
475
|
+
const codePoint = Number.parseInt(numStr, isHex ? 16 : 10);
|
|
476
|
+
if (!Number.isNaN(codePoint)) {
|
|
477
|
+
return String.fromCodePoint(codePoint);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return entity;
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Inject word-level diff markers into syntax-highlighted HTML.
|
|
485
|
+
*
|
|
486
|
+
* This function takes syntax-highlighted HTML (from Shiki) and a word diff,
|
|
487
|
+
* then wraps changed portions in <span class="diff-word-removed"> or
|
|
488
|
+
* <span class="diff-word-added"> tags without breaking the HTML structure.
|
|
489
|
+
*
|
|
490
|
+
* @param html - Syntax-highlighted HTML for a single line (inner content of <span class="line">)
|
|
491
|
+
* @param wordDiff - Word diff segments from computeWordDiff()
|
|
492
|
+
* @param mode - Whether this is the 'old' (removed) or 'new' (added) line
|
|
493
|
+
* @returns HTML with word diff markers injected
|
|
494
|
+
*/
|
|
495
|
+
function injectWordDiffMarkers(html, wordDiff, mode) {
|
|
496
|
+
// Determine which segment type to highlight based on mode
|
|
497
|
+
const targetType = mode === "old" ? "removed" : "added";
|
|
498
|
+
const cssClass = mode === "old" ? "diff-word-removed" : "diff-word-added";
|
|
499
|
+
// Build the plain text that should appear in this version
|
|
500
|
+
// In 'old' mode: unchanged + removed
|
|
501
|
+
// In 'new' mode: unchanged + added
|
|
502
|
+
const relevantSegments = wordDiff.filter((seg) => seg.type === "unchanged" || seg.type === targetType);
|
|
503
|
+
// Parse HTML into text and tag segments
|
|
504
|
+
const htmlSegments = parseHtmlSegments(html);
|
|
505
|
+
// Build result by walking through word diff segments and HTML segments together
|
|
506
|
+
const result = [];
|
|
507
|
+
let htmlSegmentIndex = 0;
|
|
508
|
+
let htmlTextOffset = 0; // Offset within current text segment's plainText
|
|
509
|
+
for (const segment of relevantSegments) {
|
|
510
|
+
const segmentText = segment.text;
|
|
511
|
+
let remaining = segmentText.length;
|
|
512
|
+
const needsHighlight = segment.type === targetType;
|
|
513
|
+
// Track if we're in the middle of a highlight span
|
|
514
|
+
let highlightParts = [];
|
|
515
|
+
while (remaining > 0) {
|
|
516
|
+
const htmlSeg = htmlSegments[htmlSegmentIndex];
|
|
517
|
+
if (!htmlSeg)
|
|
518
|
+
break;
|
|
519
|
+
if (htmlSeg.type === "tag") {
|
|
520
|
+
// Tags pass through unchanged
|
|
521
|
+
// If we're collecting highlight parts, we need to close/reopen the highlight
|
|
522
|
+
if (needsHighlight && highlightParts.length > 0) {
|
|
523
|
+
// Flush accumulated highlight parts before the tag
|
|
524
|
+
result.push(`<span class="${cssClass}">${highlightParts.join("")}</span>`);
|
|
525
|
+
highlightParts = [];
|
|
526
|
+
}
|
|
527
|
+
result.push(htmlSeg.content);
|
|
528
|
+
htmlSegmentIndex++;
|
|
529
|
+
continue;
|
|
530
|
+
}
|
|
531
|
+
// Text segment
|
|
532
|
+
const plainText = htmlSeg.plainText ?? "";
|
|
533
|
+
const availableText = plainText.slice(htmlTextOffset);
|
|
534
|
+
const availableLen = availableText.length;
|
|
535
|
+
if (availableLen === 0) {
|
|
536
|
+
// Move to next segment
|
|
537
|
+
htmlSegmentIndex++;
|
|
538
|
+
htmlTextOffset = 0;
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
// How much of this text segment do we need?
|
|
542
|
+
const takeLen = Math.min(remaining, availableLen);
|
|
543
|
+
const takenPlainText = availableText.slice(0, takeLen);
|
|
544
|
+
// Convert taken plain text back to HTML (re-encode entities)
|
|
545
|
+
const takenHtml = convertPlainTextToHtml(htmlSeg.content, htmlTextOffset, takenPlainText);
|
|
546
|
+
if (needsHighlight) {
|
|
547
|
+
highlightParts.push(takenHtml);
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
result.push(takenHtml);
|
|
551
|
+
}
|
|
552
|
+
remaining -= takeLen;
|
|
553
|
+
htmlTextOffset += takeLen;
|
|
554
|
+
// If we've consumed this segment, move to next
|
|
555
|
+
if (htmlTextOffset >= plainText.length) {
|
|
556
|
+
htmlSegmentIndex++;
|
|
557
|
+
htmlTextOffset = 0;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
// Flush any remaining highlight parts
|
|
561
|
+
if (needsHighlight && highlightParts.length > 0) {
|
|
562
|
+
result.push(`<span class="${cssClass}">${highlightParts.join("")}</span>`);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
// Append any remaining HTML segments (tags after all text is consumed)
|
|
566
|
+
for (let i = htmlSegmentIndex; i < htmlSegments.length; i++) {
|
|
567
|
+
const htmlSeg = htmlSegments[i];
|
|
568
|
+
if (!htmlSeg)
|
|
569
|
+
continue;
|
|
570
|
+
if (htmlSeg.type === "tag") {
|
|
571
|
+
result.push(htmlSeg.content);
|
|
572
|
+
}
|
|
573
|
+
else if (i === htmlSegmentIndex && htmlTextOffset > 0) {
|
|
574
|
+
// First remaining segment may have a partial offset
|
|
575
|
+
const remainingText = (htmlSeg.plainText ?? "").slice(htmlTextOffset);
|
|
576
|
+
if (remainingText.length > 0) {
|
|
577
|
+
result.push(htmlSeg.content.slice(findHtmlOffsetForPlainTextOffset(htmlSeg.content, htmlTextOffset)));
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
// Full text segment
|
|
582
|
+
result.push(htmlSeg.content);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return result.join("");
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Convert a portion of plain text back to its HTML representation,
|
|
589
|
+
* using the original HTML as a reference for entity encoding.
|
|
590
|
+
*
|
|
591
|
+
* @param originalHtml - The original HTML text segment (with entities)
|
|
592
|
+
* @param startPlainOffset - Starting offset in the decoded plain text
|
|
593
|
+
* @param plainText - The plain text portion we want to convert
|
|
594
|
+
* @returns The HTML representation of the plain text
|
|
595
|
+
*/
|
|
596
|
+
function convertPlainTextToHtml(originalHtml, startPlainOffset, plainText) {
|
|
597
|
+
// Find the starting position in the original HTML
|
|
598
|
+
const htmlStart = findHtmlOffsetForPlainTextOffset(originalHtml, startPlainOffset);
|
|
599
|
+
// Find the ending position
|
|
600
|
+
const htmlEnd = findHtmlOffsetForPlainTextOffset(originalHtml, startPlainOffset + plainText.length);
|
|
601
|
+
return originalHtml.slice(htmlStart, htmlEnd);
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Check if an HTML entity decodes to a single character.
|
|
605
|
+
* Handles named entities, decimal entities (<), and hex entities (<).
|
|
606
|
+
*/
|
|
607
|
+
function isValidHtmlEntity(entity) {
|
|
608
|
+
if (HTML_ENTITY_MAP[entity]) {
|
|
609
|
+
return true;
|
|
610
|
+
}
|
|
611
|
+
// Check numeric entities: < or <
|
|
612
|
+
if (entity.startsWith("&#")) {
|
|
613
|
+
const isHex = entity[2] === "x" || entity[2] === "X";
|
|
614
|
+
const numStr = isHex ? entity.slice(3, -1) : entity.slice(2, -1);
|
|
615
|
+
const codePoint = Number.parseInt(numStr, isHex ? 16 : 10);
|
|
616
|
+
return !Number.isNaN(codePoint);
|
|
617
|
+
}
|
|
618
|
+
return false;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Find the position in HTML string that corresponds to a position in decoded plain text.
|
|
622
|
+
*
|
|
623
|
+
* @param html - HTML string (may contain entities)
|
|
624
|
+
* @param plainOffset - Offset in the decoded plain text
|
|
625
|
+
* @returns Offset in the HTML string
|
|
626
|
+
*/
|
|
627
|
+
function findHtmlOffsetForPlainTextOffset(html, plainOffset) {
|
|
628
|
+
let htmlPos = 0;
|
|
629
|
+
let plainPos = 0;
|
|
630
|
+
while (plainPos < plainOffset && htmlPos < html.length) {
|
|
631
|
+
// Check for HTML entity
|
|
632
|
+
if (html[htmlPos] === "&") {
|
|
633
|
+
// Find the end of the entity
|
|
634
|
+
const semiPos = html.indexOf(";", htmlPos);
|
|
635
|
+
if (semiPos !== -1) {
|
|
636
|
+
const entity = html.slice(htmlPos, semiPos + 1);
|
|
637
|
+
if (isValidHtmlEntity(entity)) {
|
|
638
|
+
// This entity decodes to one character
|
|
639
|
+
htmlPos = semiPos + 1;
|
|
640
|
+
plainPos++;
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
// Regular character
|
|
646
|
+
htmlPos++;
|
|
647
|
+
plainPos++;
|
|
648
|
+
}
|
|
649
|
+
return htmlPos;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* @internal
|
|
653
|
+
* Exported for testing purposes only. Do not use in production code.
|
|
654
|
+
*/
|
|
655
|
+
export const __test__ = {
|
|
656
|
+
extractShikiLines,
|
|
657
|
+
addDiffLineClasses,
|
|
658
|
+
convertHunks,
|
|
659
|
+
patchToUnifiedText,
|
|
660
|
+
escapeHtml,
|
|
661
|
+
computeWordDiff,
|
|
662
|
+
findReplacePairs,
|
|
663
|
+
injectWordDiffMarkers,
|
|
664
|
+
};
|
|
665
|
+
//# sourceMappingURL=edit-augments.js.map
|