@@ -1605,66 +1605,73 @@ describe("ClaudeAdapterV2 attachments", () => {
16051605} ) ;
16061606
16071607describe ( "ClaudeAdapterV2 skill dispatch" , ( ) => {
1608+ const makeSkillDispatchHarness = Effect . gen ( function * ( ) {
1609+ const fileSystem = yield * FileSystem . FileSystem ;
1610+ const path = yield * Path . Path ;
1611+ const claudeHome = yield * fileSystem . makeTempDirectoryScoped ( {
1612+ prefix : "t3-claude-v2-skills-home-" ,
1613+ } ) ;
1614+ yield * fileSystem . makeDirectory ( path . join ( claudeHome , "skills" , "implement" ) , {
1615+ recursive : true ,
1616+ } ) ;
1617+ yield * fileSystem . writeFileString (
1618+ path . join ( claudeHome , "skills" , "implement" , "SKILL.md" ) ,
1619+ "---\ndescription: Implement the requested change\n---\nImplement it.\n" ,
1620+ ) ;
1621+ const attachmentsDir = yield * fileSystem . makeTempDirectoryScoped ( {
1622+ prefix : "t3-claude-v2-skills-attachments-" ,
1623+ } ) ;
1624+ const offeredMessages : Array < SDKUserMessage > = [ ] ;
1625+ const adapter = ClaudeAdapterV2 . makeClaudeAdapterV2 ( {
1626+ instanceId : ClaudeAdapterV2 . CLAUDE_DEFAULT_INSTANCE_ID ,
1627+ settings : { ...DEFAULT_CLAUDE_SETTINGS , homePath : claudeHome } ,
1628+ environment : { } ,
1629+ attachmentsDir,
1630+ fileSystem,
1631+ path,
1632+ idAllocator : yield * IdAllocator . IdAllocatorV2 ,
1633+ queryRunner : {
1634+ allocateSessionId : Effect . succeed ( "native-thread-claude-skills" ) ,
1635+ open : ( ) =>
1636+ Effect . succeed ( {
1637+ messages : Stream . never ,
1638+ offer : ( message ) =>
1639+ Effect . sync ( ( ) => {
1640+ offeredMessages . push ( message ) ;
1641+ } ) ,
1642+ setModel : ( ) => Effect . void ,
1643+ setPermissionMode : ( ) => Effect . void ,
1644+ interrupt : Effect . void ,
1645+ close : Effect . void ,
1646+ } ) ,
1647+ forkSession : ( ) => Effect . die ( "unused forkSession" ) ,
1648+ subagentLaunchToolUseId : ( ) => Effect . succeed ( null ) ,
1649+ assertComplete : Effect . void ,
1650+ } ,
1651+ } ) ;
1652+ const threadId = ThreadId . make ( "thread-claude-skills" ) ;
1653+ const runtime = yield * adapter . openSession ( {
1654+ threadId,
1655+ providerSessionId : ProviderSessionId . make ( "provider-session-claude-skills" ) ,
1656+ modelSelection : CLAUDE_TEST_MODEL_SELECTION ,
1657+ runtimePolicy : CLAUDE_TEST_RUNTIME_POLICY ,
1658+ } ) ;
1659+ const providerThread = yield * runtime . ensureThread ( {
1660+ threadId,
1661+ modelSelection : CLAUDE_TEST_MODEL_SELECTION ,
1662+ runtimePolicy : CLAUDE_TEST_RUNTIME_POLICY ,
1663+ } ) ;
1664+ return { attachmentsDir, offeredMessages, providerThread, runtime, threadId } ;
1665+ } ) ;
1666+
16081667 // Claude Code moves the expanded command ahead of earlier text blocks, so a
16091668 // leading block holding only the words before the chip reaches the model as
16101669 // a cut-off sentence (#13256).
16111670 it . effect ( "keeps the full request ahead of a mid-sentence skill command" , ( ) =>
16121671 Effect . scoped (
16131672 Effect . gen ( function * ( ) {
1614- const fileSystem = yield * FileSystem . FileSystem ;
1615- const idAllocator = yield * IdAllocator . IdAllocatorV2 ;
1616- const path = yield * Path . Path ;
1617- const claudeHome = yield * fileSystem . makeTempDirectoryScoped ( {
1618- prefix : "t3-claude-v2-skills-home-" ,
1619- } ) ;
1620- yield * fileSystem . makeDirectory ( path . join ( claudeHome , "skills" , "implement" ) , {
1621- recursive : true ,
1622- } ) ;
1623- yield * fileSystem . writeFileString (
1624- path . join ( claudeHome , "skills" , "implement" , "SKILL.md" ) ,
1625- "---\ndescription: Implement the requested change\n---\nImplement it.\n" ,
1626- ) ;
1627- const offeredMessages : Array < SDKUserMessage > = [ ] ;
1628- const adapter = ClaudeAdapterV2 . makeClaudeAdapterV2 ( {
1629- instanceId : ClaudeAdapterV2 . CLAUDE_DEFAULT_INSTANCE_ID ,
1630- settings : { ...DEFAULT_CLAUDE_SETTINGS , homePath : claudeHome } ,
1631- environment : { } ,
1632- attachmentsDir : yield * fileSystem . makeTempDirectoryScoped ( {
1633- prefix : "t3-claude-v2-skills-attachments-" ,
1634- } ) ,
1635- fileSystem,
1636- path,
1637- idAllocator,
1638- queryRunner : {
1639- allocateSessionId : Effect . succeed ( "native-thread-claude-skills" ) ,
1640- open : ( ) =>
1641- Effect . succeed ( {
1642- messages : Stream . never ,
1643- offer : ( message ) =>
1644- Effect . sync ( ( ) => {
1645- offeredMessages . push ( message ) ;
1646- } ) ,
1647- setModel : ( ) => Effect . void ,
1648- interrupt : Effect . void ,
1649- close : Effect . void ,
1650- } ) ,
1651- forkSession : ( ) => Effect . die ( "unused forkSession" ) ,
1652- subagentLaunchToolUseId : ( ) => Effect . succeed ( null ) ,
1653- assertComplete : Effect . void ,
1654- } ,
1655- } ) ;
1656- const threadId = ThreadId . make ( "thread-claude-skills" ) ;
1657- const runtime = yield * adapter . openSession ( {
1658- threadId,
1659- providerSessionId : ProviderSessionId . make ( "provider-session-claude-skills" ) ,
1660- modelSelection : CLAUDE_TEST_MODEL_SELECTION ,
1661- runtimePolicy : CLAUDE_TEST_RUNTIME_POLICY ,
1662- } ) ;
1663- const providerThread = yield * runtime . ensureThread ( {
1664- threadId,
1665- modelSelection : CLAUDE_TEST_MODEL_SELECTION ,
1666- runtimePolicy : CLAUDE_TEST_RUNTIME_POLICY ,
1667- } ) ;
1673+ const { offeredMessages, providerThread, runtime, threadId } =
1674+ yield * makeSkillDispatchHarness ;
16681675
16691676 yield * runtime . startTurn (
16701677 makeClaudeTestTurnInput ( {
@@ -1684,6 +1691,91 @@ describe("ClaudeAdapterV2 skill dispatch", () => {
16841691 } ) . pipe ( Effect . provide ( Layer . merge ( IdAllocator . layer , NodeServices . layer ) ) ) ,
16851692 ) ,
16861693 ) ;
1694+
1695+ it . effect ( "keeps the full request ahead of images and the skill command" , ( ) =>
1696+ Effect . scoped (
1697+ Effect . gen ( function * ( ) {
1698+ const fileSystem = yield * FileSystem . FileSystem ;
1699+ const path = yield * Path . Path ;
1700+ const { attachmentsDir, offeredMessages, providerThread, runtime, threadId } =
1701+ yield * makeSkillDispatchHarness ;
1702+ const attachment = ChatImageAttachment . make ( {
1703+ type : "image" ,
1704+ id : ChatAttachmentId . make ( "thread-claude-skills-12345678-1234-1234-1234-123456789abc" ) ,
1705+ name : "screen.png" ,
1706+ mimeType : "image/png" ,
1707+ sizeBytes : 4 ,
1708+ } ) ;
1709+ const attachmentPath = path . join ( attachmentsDir , attachmentRelativePath ( attachment ) ! ) ;
1710+ yield * fileSystem . writeFile ( attachmentPath , Uint8Array . from ( [ 1 , 2 , 3 , 4 ] ) ) ;
1711+
1712+ yield * runtime . startTurn (
1713+ makeClaudeTestTurnInput ( {
1714+ threadId,
1715+ providerThread,
1716+ now : yield * DateTime . now ,
1717+ attemptId : RunAttemptId . make ( "attempt-claude-skills-image" ) ,
1718+ text : "please $implement this screenshot" ,
1719+ attachments : [ attachment ] ,
1720+ } ) ,
1721+ ) ;
1722+
1723+ const attachmentNote = `[Attached image "screen.png" is saved at: ${ attachmentPath } ]` ;
1724+ assert . deepEqual ( offeredMessages [ 0 ] ?. message . content , [
1725+ {
1726+ type : "text" ,
1727+ text : `Ultrathink:\nplease /implement this screenshot\n\n${ attachmentNote } ` ,
1728+ } ,
1729+ { type : "image" , source : { type : "base64" , media_type : "image/png" , data : "AQIDBA==" } } ,
1730+ { type : "text" , text : `/implement this screenshot\n\n${ attachmentNote } ` } ,
1731+ ] ) ;
1732+ } ) . pipe ( Effect . provide ( Layer . merge ( IdAllocator . layer , NodeServices . layer ) ) ) ,
1733+ ) ,
1734+ ) ;
1735+
1736+ it . effect ( "keeps the full request ahead of a skill command sent as steering" , ( ) =>
1737+ Effect . scoped (
1738+ Effect . gen ( function * ( ) {
1739+ const idAllocator = yield * IdAllocator . IdAllocatorV2 ;
1740+ const { offeredMessages, providerThread, runtime, threadId } =
1741+ yield * makeSkillDispatchHarness ;
1742+ const attemptId = RunAttemptId . make ( "attempt-claude-skills-steer" ) ;
1743+ yield * runtime . startTurn (
1744+ makeClaudeTestTurnInput ( {
1745+ threadId,
1746+ providerThread,
1747+ now : yield * DateTime . now ,
1748+ attemptId,
1749+ text : "look at the failing tests" ,
1750+ attachments : [ ] ,
1751+ } ) ,
1752+ ) ;
1753+
1754+ yield * runtime . steerTurn ( {
1755+ threadId,
1756+ runId : RunId . make ( `run-${ attemptId } ` ) ,
1757+ providerThread,
1758+ providerTurnId : idAllocator . derive . providerTurn ( {
1759+ driver : ClaudeAdapterV2 . CLAUDE_PROVIDER ,
1760+ nativeTurnId : `turn:${ attemptId } ` ,
1761+ } ) ,
1762+ message : {
1763+ createdBy : "user" ,
1764+ creationSource : "web" ,
1765+ messageId : MessageId . make ( "message-claude-skills-steer" ) ,
1766+ text : "then $implement the fixes" ,
1767+ attachments : [ ] ,
1768+ } ,
1769+ } ) ;
1770+
1771+ assert . equal ( offeredMessages [ 1 ] ?. priority , "now" ) ;
1772+ assert . deepEqual ( offeredMessages [ 1 ] ?. message . content , [
1773+ { type : "text" , text : "Ultrathink:\nthen /implement the fixes" } ,
1774+ { type : "text" , text : "/implement the fixes" } ,
1775+ ] ) ;
1776+ } ) . pipe ( Effect . provide ( Layer . merge ( IdAllocator . layer , NodeServices . layer ) ) ) ,
1777+ ) ,
1778+ ) ;
16871779} ) ;
16881780
16891781describe ( "ClaudeAdapterV2 native fork" , ( ) => {
0 commit comments