t3code
t3code copied to clipboard
Shell commands without -c are read as inline scripts when finding the agent's working folders
What happens
When a reply cites a file, T3 Code looks for it in the folders earlier commands cd'd into (agentWorkingDirectories, #35337). A shell call that doesn't use -c, like sh "cd /work/x" or bash -x 'cd /work/y', is still read as an inline script. /work/x and /work/y then become search roots, even though those shells run a script file with that name and never change directory.
Cause
In cdOperands (packages/client-runtime/src/workspaceBasenameLookup.ts):
const inner = rest[rest.findIndex((word) => /^-[a-z]*c$/.test(word)) + 1];
If there's no -c flag, findIndex returns -1, so this reads rest[0], the first argument, as if it were the -c body.
Steps to reproduce
Call agentWorkingDirectories on a timeline with sh "cd /work/l" above the reply. It returns /work/l.