Skip to content

Commit b542bdc

Browse files
committed
fix(core): build /init prompt with the session directory
The command plugin substituted ${path} with location.project.directory, the git worktree root. In a monorepo that made /init write AGENTS.md at the repository root instead of the directory the session was opened in. Use location.directory so ${path} points at the session location directory, and pin the test to a session opened in a subdirectory of the project instead of the project root. /review is unchanged: review.txt has no ${path} placeholder. Fixes anomalyco#52833
1 parent 69269e4 commit b542bdc

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎packages/core/src/plugin/command.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const Plugin = define({
3434
.prompt({
3535
...input.prompt,
3636
sessionID: input.sessionID,
37-
text: append(PROMPT_INITIALIZE.replace("${path}", location.project.directory), input.prompt.text),
37+
text: append(PROMPT_INITIALIZE.replace("${path}", location.directory), input.prompt.text),
3838
delivery: input.delivery,
3939
})
4040
.pipe(Effect.asVoid),

‎packages/core/test/plugin/command.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe("CommandPlugin.Plugin", () => {
112112
})
113113
expect(prompts).toEqual([
114114
{
115-
text: PROMPT_INITIALIZE.replace("${path}", project).replaceAll("$ARGUMENTS", "extra context"),
115+
text: PROMPT_INITIALIZE.replace("${path}", directory).replaceAll("$ARGUMENTS", "extra context"),
116116
files: [{ uri: "file:///tmp/context.md" }],
117117
delivery: "queue",
118118
},
@@ -122,7 +122,7 @@ describe("CommandPlugin.Plugin", () => {
122122
delivery: "steer",
123123
},
124124
{
125-
text: PROMPT_INITIALIZE.replace("${path}", project).replaceAll("$ARGUMENTS", ""),
125+
text: PROMPT_INITIALIZE.replace("${path}", directory).replaceAll("$ARGUMENTS", ""),
126126
files: undefined,
127127
delivery: "steer",
128128
},

0 commit comments

Comments
 (0)