mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
feat: add multi-run fusion and session change walkthroughs
Fuse two to five completed multi-run entries into one synthesized session, and explain a session's diff as ordered walkthrough stops cached by diff hash. - Multi-run fusion service, persistence, routes and FuseRunDialog - Change walkthrough service, persistence, routes and ChangesWalkthroughDialog - Shared unified-diff parser plus bounded text generation, json-extract, text-truncate and service-error helpers
This commit is contained in:
1 parent
90c6ccf236
commit
b36d412ca2
66 files changed
+6228
-468
No files matched your search
@@ -0,0 +1,41 @@
|
||||
export function extractFirstJsonObject(text: string): string | null {
|
||||
const start = text.indexOf('{')
|
||||
if (start === -1) {
|
||||
return null
|
||||
}
|
||||
|
||||
let depth = 0
|
||||
let inString = false
|
||||
let escaped = false
|
||||
|
||||
for (let index = start; index < text.length; index += 1) {
|
||||
const char = text[index]
|
||||
|
||||
if (inString) {
|
||||
if (escaped) {
|
||||
escaped = false
|
||||
} else if (char === '\\') {
|
||||
escaped = true
|
||||
} else if (char === '"') {
|
||||
inString = false
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if (char === '"') {
|
||||
inString = true
|
||||
continue
|
||||
}
|
||||
|
||||
if (char === '{') {
|
||||
depth += 1
|
||||
} else if (char === '}') {
|
||||
depth -= 1
|
||||
if (depth === 0) {
|
||||
return text.slice(start, index + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
export class ServiceError extends Error {
|
||||
status: number
|
||||
code?: string
|
||||
details?: unknown
|
||||
|
||||
constructor(message: string, status: number, options?: { code?: string; details?: unknown }) {
|
||||
super(message)
|
||||
this.name = 'ServiceError'
|
||||
this.status = status
|
||||
this.code = options?.code
|
||||
this.details = options?.details
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export interface TruncateTextResult {
|
||||
text: string
|
||||
truncated: boolean
|
||||
}
|
||||
|
||||
export function truncateText(text: string, maxLength: number, marker: string): TruncateTextResult {
|
||||
if (text.length <= maxLength) {
|
||||
return { text, truncated: false }
|
||||
}
|
||||
return { text: `${text.slice(0, maxLength)}${marker}`, truncated: true }
|
||||
}
|
||||
Reference in new issue
Block a user