Skip to content

Commit 0e9d243

Browse files
committed
refactor(config): auto-update agent instructions, never create new files (#1027)
## Summary - `vp config` no longer creates new agent files or prompts for agent selection - Silently updates existing files that contain Vite+ markers (`<!--VITE PLUS START-->`) when content is outdated - Same behavior for `prepare` lifecycle, interactive, and non-interactive modes - Skipped with `--hooks-only` - Delete `config/agent.ts` and its tests (superseded by shared `utils/agent.ts`) ## Behavior | Scenario | Action | |----------|--------| | No agent files | No writes | | Agent files exist, no Vite+ markers | No writes | | Vite+ markers, content up to date | No writes | | Vite+ markers, content outdated | Update marked section silently | | `--hooks-only` | Skip agent update | ## Test plan - [x] `pnpm -F vite-plus snap-test-global command-config` — all 9 tests pass - [x] `pnpm -F vite-plus snap-test` — all tests pass - [x] New snap test: `command-config-update-agents` — verifies outdated markers are updated, user content preserved - [x] New snap test: `command-config-no-agent-writes` — verifies no writes when no markers, no new files created
1 parent fb7cc34 commit 0e9d243

14 files changed

Lines changed: 108 additions & 340 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# My Custom Claude Instructions
2+
3+
Do not modify this file.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "command-config-no-agent-writes"
3+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
> git init
2+
> vp config
3+
> cat CLAUDE.md # should be unchanged
4+
# My Custom Claude Instructions
5+
6+
Do not modify this file.
7+
8+
> test -f AGENTS.md && echo 'AGENTS.md exists' || echo 'AGENTS.md not created' # should not exist
9+
AGENTS.md not created
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"commands": [
3+
{ "command": "git init", "ignoreOutput": true },
4+
"vp config",
5+
"cat CLAUDE.md # should be unchanged",
6+
"test -f AGENTS.md && echo 'AGENTS.md exists' || echo 'AGENTS.md not created' # should not exist"
7+
]
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# My Project
2+
3+
Custom instructions here.
4+
5+
<!--VITE PLUS START-->
6+
7+
OUTDATED CONTENT THAT SHOULD BE REPLACED
8+
9+
<!--VITE PLUS END-->
10+
11+
More custom content below.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "command-config-update-agents"
3+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
> git init
2+
> vp config # should auto-update agent instructions
3+
> head -5 AGENTS.md # verify user content preserved
4+
# My Project
5+
6+
Custom instructions here.
7+
8+
<!--VITE PLUS START-->
9+
10+
> tail -3 AGENTS.md # verify user content preserved
11+
<!--VITE PLUS END-->
12+
13+
More custom content below.
14+
15+
> grep -q 'OUTDATED CONTENT' AGENTS.md && echo 'ERROR: outdated content still present' || echo 'outdated content replaced' # verify old content gone
16+
outdated content replaced
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"commands": [
3+
{ "command": "git init", "ignoreOutput": true },
4+
"vp config # should auto-update agent instructions",
5+
"head -5 AGENTS.md # verify user content preserved",
6+
"tail -3 AGENTS.md # verify user content preserved",
7+
"grep -q 'OUTDATED CONTENT' AGENTS.md && echo 'ERROR: outdated content still present' || echo 'outdated content replaced' # verify old content gone"
8+
]
9+
}

packages/cli/snap-tests/command-run-with-vp-config/snap.txt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@
22
$ vp config ⊘ cache disabled
33
.git can't be found
44

5-
Created AGENTS.md with Vite+ instructions
6-
◇ Add this MCP server config to your agent ─╮
7-
8-
{
9-
"vite-plus": {
10-
"command": "npx",
11-
"args": [
12-
"vp",
13-
"mcp"
14-
]
15-
}
16-
}
17-
18-
╰────────────────────────────────────────────╯
19-
205

216
[2]> vp run bar # should throw error
227
$ vp not-exist-command ⊘ cache disabled

packages/cli/src/config/__tests__/agent.spec.ts

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)