Skip to content

Commit 88d9424

Browse files
committed
Remove plain agent context command and SessionStart hook
The .claude/rules/ files already provide all framework context natively, making the hook redundant. plain agent install now cleans up the old hook from settings.json instead of adding it.
1 parent 7155d36 commit 88d9424

File tree

3 files changed

+31
-70
lines changed

3 files changed

+31
-70
lines changed

.claude/settings.json

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

example/.claude/settings.json

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

plain/plain/cli/agent.py

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -140,40 +140,36 @@ def _cleanup_orphans(dest_dir: Path, agent_dirs: list[Path]) -> int:
140140
return removed_count
141141

142142

143-
def _setup_session_hook(dest_dir: Path) -> None:
144-
"""Create or update settings.json with SessionStart hook."""
143+
def _cleanup_session_hook(dest_dir: Path) -> None:
144+
"""Remove the old plain agent context SessionStart hook from settings.json."""
145145
settings_file = dest_dir / "settings.json"
146146

147-
# Load existing settings or start fresh
148-
if settings_file.exists():
149-
settings = json.loads(settings_file.read_text())
150-
else:
151-
settings = {}
152-
153-
# Ensure hooks structure exists
154-
if "hooks" not in settings:
155-
settings["hooks"] = {}
156-
157-
# Define the Plain hook - calls the agent context command directly
158-
plain_hook = {
159-
"matcher": "startup|resume",
160-
"hooks": [
161-
{
162-
"type": "command",
163-
"command": "uv run plain agent context 2>/dev/null || true",
164-
}
165-
],
166-
}
167-
168-
# Get existing SessionStart hooks, remove any existing plain hook
169-
session_hooks = settings["hooks"].get("SessionStart", [])
147+
if not settings_file.exists():
148+
return
149+
150+
settings = json.loads(settings_file.read_text())
151+
152+
hooks = settings.get("hooks", {})
153+
session_hooks = hooks.get("SessionStart", [])
154+
155+
# Remove any plain agent or plain-context.md hooks
170156
session_hooks = [h for h in session_hooks if "plain agent" not in str(h)]
171-
# Also remove old plain-context.md hooks for migration
172157
session_hooks = [h for h in session_hooks if "plain-context.md" not in str(h)]
173-
session_hooks.append(plain_hook)
174-
settings["hooks"]["SessionStart"] = session_hooks
175158

176-
settings_file.write_text(json.dumps(settings, indent=2) + "\n")
159+
if session_hooks:
160+
hooks["SessionStart"] = session_hooks
161+
else:
162+
hooks.pop("SessionStart", None)
163+
164+
if hooks:
165+
settings["hooks"] = hooks
166+
else:
167+
settings.pop("hooks", None)
168+
169+
if settings:
170+
settings_file.write_text(json.dumps(settings, indent=2) + "\n")
171+
else:
172+
settings_file.unlink()
177173

178174

179175
@click.group()
@@ -182,15 +178,9 @@ def agent() -> None:
182178
pass
183179

184180

185-
@agent.command()
186-
def context() -> None:
187-
"""Output Plain framework context for AI agents"""
188-
click.echo("This is a Plain project.")
189-
190-
191181
@agent.command()
192182
def install() -> None:
193-
"""Install skills, rules, and hooks to agent directories"""
183+
"""Install skills and rules to agent directories"""
194184
cwd = Path.cwd()
195185
claude_dir = cwd / ".claude"
196186

@@ -209,16 +199,17 @@ def install() -> None:
209199
installed, _ = _install_agent_dir(source_dir, claude_dir)
210200
total_installed += installed
211201

212-
# Setup session hook
213-
_setup_session_hook(claude_dir)
202+
# Clean up old session hook
203+
_cleanup_session_hook(claude_dir)
214204

215205
parts = []
216206
if total_installed > 0:
217207
parts.append(f"installed {total_installed}")
218208
if removed_count > 0:
219209
parts.append(f"removed {removed_count}")
220-
parts.append("updated hooks")
221-
click.echo(f"Agent: {', '.join(parts)} in .claude/")
210+
click.echo(f"Agent: {', '.join(parts)} in .claude/") if parts else click.echo(
211+
"Agent: up to date"
212+
)
222213

223214

224215
@agent.command()

0 commit comments

Comments
 (0)