Skip to content

/init corrupts the project path when the directory name contains dollar sequences #760

Closed

Description

What happened?

/init splices the project directory into its prompt with a string
replacement, so a directory whose name contains the sequences a replacement
string treats as patterns produces a corrupted prompt. The prompt is the only
thing that tells the agent which directory it is working in.

On current main (3e94875c) the template begins
Create or update the project's AGENTS.md at ${path}: the file every …, and:

project directory what the prompt says
…/openscience-init-prices$$ …at …/openscience-init-prices$: the file …
…/openscience-init-a$&b …at …/openscience-init-a${path}b: the file …
…/openscience-init-x$'y the whole remainder of the prompt is pasted into the path and the sentence is repeated

$$ collapses to $, $& pastes the matched ${path} placeholder, and $'
pastes everything after the match — so the last row duplicates the rest of the
prompt and leaves the agent pointing at a directory that does not exist.

This is the same defect class as #753, fixed for {file:…} config references
in ba152a6, and the $ARGUMENTS case in #755. A function replacement inserts
the path literally.

Steps to reproduce

  1. Create a project directory whose name contains $$, $& or $' (legal on
    Windows, macOS and Linux), e.g. mkdir 'a$&b'.
  2. Run /init in that project.
  3. Read the command text passed to the model; the directory it names no longer
    matches the one you are in.

The focused regression in test/session/command-init-template.test.ts fails on
3e94875c and passes with the fix. It stops before any model call.

How did you install OpenScience?

From source (bun dev).

OpenScience version

Source commit 3e94875c.

Provider and model

Not applicable; the reproduction captures the command before a model call.

Operating system

Not OS-specific; reproduced in the Bun test harness. Project paths containing
$ are legal on all three desktop platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions