@niracler/encore 0.2.0 → 0.3.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/README.md +104 -75
- package/README.zh-CN.md +105 -69
- package/bin/encore.mjs +53 -22
- package/package.json +4 -2
- package/player/encore-player.css +83 -1
- package/player/encore-player.js +422 -90
- package/schema/session.schema.json +63 -1
- package/skills/encore/SKILL.md +39 -35
- package/src/attachment-previews.mjs +169 -0
- package/src/attachment-reader.mjs +169 -0
- package/src/claude-ai.mjs +3 -1
- package/src/claude-code.mjs +11 -7
- package/src/codex.mjs +10 -3
- package/src/common.mjs +25 -5
- package/src/external-files.mjs +176 -0
- package/src/i18n.mjs +107 -25
- package/src/index.d.ts +18 -2
- package/src/index.mjs +59 -41
- package/src/markdown.mjs +14 -11
- package/src/player-assets.mjs +4 -1
- package/src/player-runtime.mjs +53 -11
- package/src/render.mjs +48 -13
- package/src/server.mjs +2 -0
- package/src/timeline.mjs +32 -30
- package/src/workbuddy.mjs +6 -5
package/src/timeline.mjs
CHANGED
|
@@ -162,7 +162,7 @@ function extractStepDocs(toolItems, stepIndex) {
|
|
|
162
162
|
return [...byPath.values()]
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
function extractStepSubagents(toolItems, stepIndex) {
|
|
165
|
+
function extractStepSubagents(toolItems, stepIndex, t) {
|
|
166
166
|
const list = []
|
|
167
167
|
toolItems.forEach((item, idx) => {
|
|
168
168
|
const rawSum = String(item.summary || '')
|
|
@@ -188,17 +188,17 @@ function extractStepSubagents(toolItems, stepIndex) {
|
|
|
188
188
|
const combined = `${rawSum}\n${item.output || ''}`
|
|
189
189
|
const isAsyncSpawn = /^(?:spawn_agent|collaboration__spawn_agent|followup_task|collaboration__followup_task)$/.test(item.name || '')
|
|
190
190
|
let state = 'sent'
|
|
191
|
-
let badge = '
|
|
191
|
+
let badge = t('agentSent')
|
|
192
192
|
let report = ''
|
|
193
193
|
if (/was stopped|中途打断|已取消/i.test(combined)) {
|
|
194
194
|
state = 'stopped'
|
|
195
|
-
badge = '
|
|
195
|
+
badge = t('agentStopped')
|
|
196
196
|
} else if (/failed:|terminated early|rate_limit|hit your session limit|^Error:\s*Failed/im.test(combined)) {
|
|
197
197
|
state = 'failed'
|
|
198
|
-
badge = /limit|429/i.test(combined) ? '
|
|
198
|
+
badge = /limit|429/i.test(combined) ? t('agentRateLimited') : t('agentFailed')
|
|
199
199
|
} else if (item.kind === 'reply' || item.stats?.reply || (!isAsyncSpawn && item.output && item.output.length > 80 && !item.output.trim().startsWith('{'))) {
|
|
200
200
|
state = 'done'
|
|
201
|
-
badge = '
|
|
201
|
+
badge = t('agentDone')
|
|
202
202
|
if (item.output && item.output.length > 40 && !item.output.trim().startsWith('{')) {
|
|
203
203
|
report = String(item.output).trim()
|
|
204
204
|
}
|
|
@@ -462,7 +462,9 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
462
462
|
}
|
|
463
463
|
for (const item of items) {
|
|
464
464
|
if (item.type === 'tool' || item.type === 'reasoning') {
|
|
465
|
+
if (item.deliverables?.length) flushWork()
|
|
465
466
|
work.push(item)
|
|
467
|
+
if (item.deliverables?.length) flushWork()
|
|
466
468
|
continue
|
|
467
469
|
}
|
|
468
470
|
flushWork()
|
|
@@ -572,7 +574,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
572
574
|
name,
|
|
573
575
|
color,
|
|
574
576
|
itemCount: records.length,
|
|
575
|
-
count:
|
|
577
|
+
count: t('itemCount', { n: records.length }),
|
|
576
578
|
tok: `≈${(curTok / 1000).toFixed(1)}k`,
|
|
577
579
|
pct: `${kindPct(curTok)}%`,
|
|
578
580
|
delta: stepIdx >= 0 ? fmtCountDelta(records.length, prevCount) : '',
|
|
@@ -682,8 +684,8 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
682
684
|
id: `user-${userSeq}`,
|
|
683
685
|
stepIndex: index,
|
|
684
686
|
tokEst: userTok,
|
|
685
|
-
tag:
|
|
686
|
-
title: cleanPromptText.slice(0, 56) || '
|
|
687
|
+
tag: t('turnTag', { n: turnCount }),
|
|
688
|
+
title: cleanPromptText.slice(0, 56) || t('userMessage'),
|
|
687
689
|
meta: `≈${(userTok / 1000).toFixed(1)}k · ${stepTime}s`,
|
|
688
690
|
payload: String(first.text || ''),
|
|
689
691
|
...(first.images?.length ? { images: first.images } : {}),
|
|
@@ -700,7 +702,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
700
702
|
tokEst: skTok,
|
|
701
703
|
tag: 'SKILL.md',
|
|
702
704
|
title: `${skill}/SKILL.md`,
|
|
703
|
-
meta: `≈${(skTok / 1000).toFixed(1)}k ·
|
|
705
|
+
meta: `≈${(skTok / 1000).toFixed(1)}k · ${t('turnTag', { n: turnCount })}`,
|
|
704
706
|
payload: `# ${skill} (SKILL.md)\nLoaded into active context.`,
|
|
705
707
|
}))
|
|
706
708
|
}
|
|
@@ -709,10 +711,10 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
709
711
|
primaryCat = 'user'
|
|
710
712
|
speedLabel = '1.0×'
|
|
711
713
|
dwellMs = 1500
|
|
712
|
-
detailTitle =
|
|
714
|
+
detailTitle = t('promptTitle', { n: turnCount })
|
|
713
715
|
detailSnippet = (first.text || '').slice(0, 260)
|
|
714
|
-
inBrief = '
|
|
715
|
-
responseBrief = '
|
|
716
|
+
inBrief = t('appendedPrompt')
|
|
717
|
+
responseBrief = t('waitingForTools')
|
|
716
718
|
} else if (group.groupType === 'compact') {
|
|
717
719
|
compactSeq++
|
|
718
720
|
const cItem = first
|
|
@@ -765,10 +767,10 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
765
767
|
speedLabel = '0.8×'
|
|
766
768
|
dwellMs = 2100
|
|
767
769
|
spotlight = 'context-compact'
|
|
768
|
-
detailTitle =
|
|
770
|
+
detailTitle = t('compactTitle', { seq: compactInfo.seq })
|
|
769
771
|
detailSnippet = summaryText.slice(0, 260)
|
|
770
772
|
inBrief = `${(preTokens / 1000).toFixed(1)}k → ${(postTokens / 1000).toFixed(1)}k`
|
|
771
|
-
responseBrief =
|
|
773
|
+
responseBrief = t('archivedTools', { n: archivedTools, tokens: (droppedTokens / 1000).toFixed(1) })
|
|
772
774
|
} else if (group.groupType === 'assistant') {
|
|
773
775
|
msgSeq++
|
|
774
776
|
const cleanReply = (first.text || '').replace(/\s+/g, ' ').trim()
|
|
@@ -779,8 +781,8 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
779
781
|
id: `msg-${msgSeq}`,
|
|
780
782
|
stepIndex: index,
|
|
781
783
|
tokEst: msgTok,
|
|
782
|
-
tag:
|
|
783
|
-
title: cleanReply.slice(0, 56) || '
|
|
784
|
+
tag: t('replyTag', { n: msgSeq }),
|
|
785
|
+
title: cleanReply.slice(0, 56) || t('assistantReply'),
|
|
784
786
|
meta: `≈${(msgTok / 1000).toFixed(1)}k · ${stepTime}s`,
|
|
785
787
|
payload: String(first.text || ''),
|
|
786
788
|
}))
|
|
@@ -794,17 +796,17 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
794
796
|
primaryCat = 'msg'
|
|
795
797
|
speedLabel = '1.0×'
|
|
796
798
|
dwellMs = 1750
|
|
797
|
-
detailTitle = '
|
|
799
|
+
detailTitle = t('assistantReply')
|
|
798
800
|
detailSnippet = (first.text || '').slice(0, 260)
|
|
799
|
-
inBrief = allTools.length ?
|
|
800
|
-
responseBrief = cleanReply.slice(0, 96) || '
|
|
801
|
+
inBrief = allTools.length ? t('synthesizing', { tools: allTools.slice(-2).join(', ') }) : t('directResponse')
|
|
802
|
+
responseBrief = cleanReply.slice(0, 96) || t('completedResponse')
|
|
801
803
|
} else {
|
|
802
804
|
const toolItems = group.items.filter(item => item.type === 'tool')
|
|
803
805
|
const reasoningItems = group.items.filter(item => item.type === 'reasoning')
|
|
804
806
|
const stats = sumStats(toolItems)
|
|
805
807
|
const extracted = extractFileChips(toolItems)
|
|
806
808
|
stepDocs = extractStepDocs(toolItems, index)
|
|
807
|
-
stepSubagents = extractStepSubagents(toolItems, index)
|
|
809
|
+
stepSubagents = extractStepSubagents(toolItems, index, t)
|
|
808
810
|
stepAudios = extractStepAudios(toolItems, t)
|
|
809
811
|
allTools.push(...extracted.tools)
|
|
810
812
|
allChanges.push(...extracted.changes)
|
|
@@ -819,9 +821,9 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
819
821
|
id: `mem-dyn-${memRecords.length + 1}`,
|
|
820
822
|
stepIndex: index,
|
|
821
823
|
tokEst: memTok,
|
|
822
|
-
tag: '
|
|
824
|
+
tag: t('rule'),
|
|
823
825
|
title: `${memName}`,
|
|
824
|
-
meta: `≈${(memTok / 1000).toFixed(1)}k ·
|
|
826
|
+
meta: `≈${(memTok / 1000).toFixed(1)}k · ${t('stepTag', { n: index + 1 })}`,
|
|
825
827
|
payload: `# ${memName}\nLoaded into context during step ${index + 1}.`,
|
|
826
828
|
}))
|
|
827
829
|
}
|
|
@@ -837,9 +839,9 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
837
839
|
id: `think-${msgSeq}`,
|
|
838
840
|
stepIndex: index,
|
|
839
841
|
tokEst: rTok,
|
|
840
|
-
tag: '
|
|
842
|
+
tag: t('thinking'),
|
|
841
843
|
title: rItem.text.replace(/\s+/g, ' ').trim().slice(0, 54),
|
|
842
|
-
meta: `≈${(rTok / 1000).toFixed(1)}k ·
|
|
844
|
+
meta: `≈${(rTok / 1000).toFixed(1)}k · ${t('reasoning')}`,
|
|
843
845
|
payload: String(rItem.text),
|
|
844
846
|
}))
|
|
845
847
|
}
|
|
@@ -865,7 +867,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
865
867
|
tokEst: skTok,
|
|
866
868
|
tag: 'SKILL.md',
|
|
867
869
|
title: `${skill}/SKILL.md`,
|
|
868
|
-
meta: `≈${(skTok / 1000).toFixed(1)}k ·
|
|
870
|
+
meta: `≈${(skTok / 1000).toFixed(1)}k · ${t('stepTag', { n: index + 1 })}`,
|
|
869
871
|
payload: String(item.output || item.input || `# ${skill} (SKILL.md)`),
|
|
870
872
|
}))
|
|
871
873
|
}
|
|
@@ -905,7 +907,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
905
907
|
toolRecords.push(registerRecord({
|
|
906
908
|
id: `frame-${++toolSeq}`,
|
|
907
909
|
stepIndex: index,
|
|
908
|
-
tag: '
|
|
910
|
+
tag: t('preview'),
|
|
909
911
|
title: `${fr.label}`,
|
|
910
912
|
meta: '≈1.2k tok',
|
|
911
913
|
payload: `Preview frame: ${fr.label}`,
|
|
@@ -913,7 +915,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
913
915
|
}))
|
|
914
916
|
}
|
|
915
917
|
rawMontage.push({
|
|
916
|
-
tag: '
|
|
918
|
+
tag: t('preview'),
|
|
917
919
|
title: `${fr.label}`,
|
|
918
920
|
isSpot: true,
|
|
919
921
|
speed: '🖼',
|
|
@@ -921,7 +923,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
921
923
|
}
|
|
922
924
|
for (const doc of stepDocs) {
|
|
923
925
|
rawMontage.push({
|
|
924
|
-
tag: '
|
|
926
|
+
tag: t('draft'),
|
|
925
927
|
title: `${doc.title}`,
|
|
926
928
|
isSpot: true,
|
|
927
929
|
speed: '📄',
|
|
@@ -968,7 +970,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
968
970
|
dwellMs = 1100
|
|
969
971
|
}
|
|
970
972
|
if (toolItems.length) {
|
|
971
|
-
detailTitle =
|
|
973
|
+
detailTitle = t('toolCalls', { n: toolItems.length })
|
|
972
974
|
detailSnippet = toolItems.slice(0, 3).map(item => item.summary).join('\n')
|
|
973
975
|
const primaryTool = toolItems[0]?.name || 'tool'
|
|
974
976
|
inBrief = `${primaryTool} · ${toolItems.slice(0, 2).map(i => i.summary).join(';')}`
|
|
@@ -1059,7 +1061,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1059
1061
|
snippet: detailSnippet,
|
|
1060
1062
|
},
|
|
1061
1063
|
brief: {
|
|
1062
|
-
user: latestUserPrompt || '
|
|
1064
|
+
user: latestUserPrompt || t('sessionStart'),
|
|
1063
1065
|
in: inBrief,
|
|
1064
1066
|
response: responseBrief,
|
|
1065
1067
|
},
|
package/src/workbuddy.mjs
CHANGED
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
} from './common.mjs'
|
|
11
11
|
|
|
12
12
|
// WorkBuddy sessions: ~/.workbuddy/projects/<workspace>/<id>.jsonl, records in OpenAI Responses shape.
|
|
13
|
-
export function workBuddyUserText(content) {
|
|
13
|
+
export function workBuddyUserText(content, references) {
|
|
14
14
|
const text = textOf(content)
|
|
15
15
|
const queries = [...text.matchAll(/<user_query>([\s\S]*?)<\/user_query>/g)].map(match => match[1].trim())
|
|
16
|
-
return mentions(queries.length ? queries.join('\n\n') : stripInjected(text))
|
|
16
|
+
return mentions(queries.length ? queries.join('\n\n') : stripInjected(text), references)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function readWorkBuddy(records) {
|
|
@@ -31,15 +31,16 @@ export function readWorkBuddy(records) {
|
|
|
31
31
|
if (record.type === 'ai-title') {
|
|
32
32
|
title = record.aiTitle
|
|
33
33
|
} else if (record.type === 'message' && record.role === 'user') {
|
|
34
|
-
|
|
34
|
+
const references = []
|
|
35
|
+
transcript.user(workBuddyUserText(record.content, references), time, { images: imagesOf(record.content), references, cwd: record.cwd })
|
|
35
36
|
} else if (record.type === 'message' && record.role === 'assistant') {
|
|
36
|
-
transcript.assistant(textOf(record.content), time)
|
|
37
|
+
transcript.assistant(textOf(record.content), time, { cwd: record.cwd })
|
|
37
38
|
} else if (record.type === 'reasoning') {
|
|
38
39
|
transcript.reasoning(textOf(record.rawContent?.length ? record.rawContent : record.content), time)
|
|
39
40
|
} else if (record.type === 'function_call') {
|
|
40
41
|
transcript.tool(record.callId, describeTool(record.name, parseArguments(record.arguments)), time)
|
|
41
42
|
} else if (record.type === 'function_call_result') {
|
|
42
|
-
transcript.result(record.callId, stripInjected(textOf(record.output)), time, imagesOf(record.output))
|
|
43
|
+
transcript.result(record.callId, stripInjected(textOf(record.output)), time, imagesOf(record.output), record.cwd)
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
const tokens = [...usage.values()].reduce((sum, value) => sum + value, 0) || undefined
|