@@ -53,6 +53,7 @@ import * as EffectAcpErrors from "effect-acp/errors";
5353import type * as EffectAcpProtocol from "effect-acp/protocol" ;
5454import type * as EffectAcpSchema from "effect-acp/compat" ;
5555
56+ import { writeFakeCli } from "@t3tools/provider-testing/fakeCli" ;
5657import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost" ;
5758import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions" ;
5859import * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime" ;
@@ -3169,6 +3170,89 @@ describe("AcpAdapterV2", () => {
31693170 } ) . pipe ( Effect . provide ( layerTest ) , Effect . scoped ) ,
31703171 ) ;
31713172
3173+ // Oracle: #13457. Grok expands only a leading `/name`, so a picked leading `$name`
3174+ // must reach it in that form; anything else keeps the user's text.
3175+ it . live . each ( [
3176+ { text : "$deploy ship it" , sent : "/deploy ship it" , native : true } ,
3177+ { text : "ship $deploy" , sent : "ship $deploy" , native : false } ,
3178+ { text : "$other ship it" , sent : "$other ship it" , native : false } ,
3179+ ] ) ( "Grok sends $text with a picked skill as $sent" , ( { text, sent, native } ) =>
3180+ Effect . gen ( function * ( ) {
3181+ const childProcessSpawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
3182+ const fileSystem = yield * FileSystem . FileSystem ;
3183+ const path = yield * Path . Path ;
3184+ const mockAgentPath = yield * path . fromFileUrl (
3185+ new URL ( "../../../scripts/acp-mock-agent.ts" , import . meta. url ) ,
3186+ ) ;
3187+ const hostPlatform = yield * HostProcess . Platform ;
3188+ // Stands in for `grok inspect --json`, the catalog behind the `$` picker.
3189+ const catalog = { skills : [ { name : "deploy" , source : { path : "/s/deploy/SKILL.md" } } ] } ;
3190+ const grokPath = writeFakeCli ( {
3191+ directory : yield * fileSystem . makeTempDirectoryScoped ( ) ,
3192+ name : "grok" ,
3193+ source : `process.stdout.write(${ JSON . stringify ( `${ JSON . stringify ( catalog ) } \n` ) } );\n` ,
3194+ platform : hostPlatform ,
3195+ } ) ;
3196+ const protocolEvents = yield * Queue . unbounded < EffectAcpProtocol . AcpProtocolLogEvent > ( ) ;
3197+ const instanceId = ProviderInstanceId . make ( "grok-skill-mention" ) ;
3198+ const adapter = yield * makeGrokAdapterV2 ( {
3199+ instanceId,
3200+ settings : { ...DEFAULT_GROK_SETTINGS , binaryPath : grokPath } ,
3201+ // The fake CLI needs `node` on its PATH.
3202+ environment : { ...process . env } ,
3203+ hostPlatform,
3204+ selfInvocation : yield * resolveSelfInvocation ( ) ,
3205+ makeRuntime : ( input ) =>
3206+ makeMockRuntime ( { childProcessSpawner, mockAgentPath, protocolEvents } ) ( input ) . pipe (
3207+ Effect . flatMap ( makeXAiPromptCompletionRuntime ) ,
3208+ ) ,
3209+ } ) ;
3210+ const threadId = ThreadId . make ( "grok-skill-mention" ) ;
3211+ const modelSelection = { instanceId, model : "default" } as const ;
3212+ const runtimePolicy = ProviderAdapter . ProviderAdapterV2RuntimePolicy . make ( {
3213+ runtimeMode : "full-access" ,
3214+ interactionMode : "default" ,
3215+ cwd : process . cwd ( ) ,
3216+ } ) ;
3217+ const runtime = yield * adapter . openSession ( {
3218+ threadId,
3219+ providerSessionId : ProviderSessionId . make ( "grok-skill-mention" ) ,
3220+ modelSelection,
3221+ runtimePolicy,
3222+ } ) ;
3223+ const providerThread = yield * runtime . ensureThread ( {
3224+ threadId,
3225+ modelSelection,
3226+ runtimePolicy,
3227+ } ) ;
3228+ yield * runtime . startTurn (
3229+ makeTurnInput ( {
3230+ threadId,
3231+ providerThread,
3232+ instanceId,
3233+ runtimePolicy,
3234+ now : yield * DateTime . now ,
3235+ messageText : text ,
3236+ } ) ,
3237+ ) ;
3238+ const prompt = yield * Stream . fromQueue ( protocolEvents ) . pipe (
3239+ Stream . filter (
3240+ ( event ) =>
3241+ event . direction === "outgoing" && rawProtocolMethod ( event ) === "session/prompt" ,
3242+ ) ,
3243+ Stream . runHead ,
3244+ ) ;
3245+ const blocks = rawProtocolPromptTextBlocks ( Option . getOrThrow ( prompt ) ) ;
3246+ if ( native ) {
3247+ // Same shape as a typed native command: one bare text block, no T3 instructions.
3248+ assert . deepEqual ( blocks , [ { type : "text" , text : sent } ] ) ;
3249+ } else {
3250+ assert . isTrue ( blocks . some ( ( block ) => block . text . includes ( sent ) ) ) ;
3251+ assert . isFalse ( blocks . some ( ( block ) => block . text . trimStart ( ) . startsWith ( "/" ) ) ) ;
3252+ }
3253+ } ) . pipe ( Effect . provide ( layerTest ) , Effect . scoped ) ,
3254+ ) ;
3255+
31723256 // Oracle: #15888 KillTask reports. Command completion must release the turn even
31733257 // when the CLI keeps the prompt RPC and process alive. Kill calls stay visible.
31743258 it . live . each ( [
0 commit comments