Skip to content

feat: 데모 템플릿 수정#24

Merged
sehwan505 merged 13 commits intomainfrom
feat/enhance-policy-editor
Nov 18, 2025
Merged

feat: 데모 템플릿 수정#24
sehwan505 merged 13 commits intomainfrom
feat/enhance-policy-editor

Conversation

@baeyc0510
Copy link
Contributor

@baeyc0510 baeyc0510 commented Nov 18, 2025

feat: Enhance policy editor and add AI coding tool instructions

Overview

This PR enhances the policy editor with improved UX and adds automatic instructions file generation for AI coding tools during sym init.

Changes

1. AI Coding Tool Instructions Auto-Generation

When users register MCP servers during sym init, Symphony now automatically creates instructions files for AI coding tools to ensure they properly use Symphony conventions.

Supported Tools:

  • Claude Code: Appends to claude.md
  • Cursor: Creates .cursor/rules/symphony.mdc with MDC frontmatter
  • VS Code Copilot: Creates .github/instructions/symphony.instructions.md with proper frontmatter

Instructions Content:

All instructions files include concise, essential guidelines:

  1. Before Writing Code

    • Verify Symphony MCP server is active
    • Query conventions using symphony/query_conventions tool
    • Available categories: security, style, documentation, error_handling, architecture, performance, testing
  2. After Writing Code

    • Validate all changes using symphony/validate_code tool
    • Fix violations before committing

2. Improved sym init Completion Message

Before:

  • Verbose "Next steps" with git commands
  • Dashboard info shown mid-process
  • Interrupts setup flow

After:

  • Concise dashboard usage guide
  • Shows features: Manage roles, Edit policies, Test validation
  • Displayed only after all initialization is complete (MCP + API key setup)

3. Policy Editor Enhancements

  • Added demo template management
  • Enhanced RBAC change detection
  • Fixed file handling issues
  • Removed auto-save feature for better control
  • Improved policy editor UI stability

Technical Details

Files Modified

  • internal/cmd/mcp_register.go - Added instructions generation logic (+187 lines)
  • internal/cmd/init.go - Improved completion message and reordered output
  • Policy editor UI enhancements (previous commits)

Implementation

Instructions Generation Flow:

MCP Registration
    ↓
Check if project-specific (not global)
    ↓
Create instructions file based on app type
    ↓
Check if file exists
    ↓
Append (Claude Code) or Create/Backup (others)

File Formats:

  • Claude Code: Plain Markdown, appends if exists
  • Cursor: MDC format with YAML frontmatter (globs, alwaysApply)
  • VS Code: Instructions format with YAML frontmatter (applyTo pattern)

Testing

  • Built successfully with make build
  • All existing tests pass (failures are pre-existing Windows issues)
  • Manual testing of sym init flow
  • Instructions files generated correctly for each tool

Breaking Changes

None. All changes are backward compatible.

Documentation

Instructions files are auto-generated with inline documentation. Users can customize them after generation.

Screenshots/Examples

New sym init completion message:

🎯 What's Next: Use Symphony Dashboard

Start the web dashboard:
  sym dashboard

Dashboard features:
  📋 Manage roles - Add/remove team members, configure permissions
  📝 Edit policies - Create and modify coding conventions
  ✅ Test validation - Check rules against your code in real-time

After setup, commit and push .sym/ folder to share with your team.

Generated .cursor/rules/symphony.mdc:

---
description: Symphony code convention validation
globs:
  - "**/*"
alwaysApply: true
---

# Symphony Code Conventions

**This project uses Symphony MCP for code convention management.**

## Required Steps

### Before Code Generation
1. **Verify Symphony MCP is active** - If not available, stop and warn user
2. **Query conventions** - Use `symphony/query_conventions` with appropriate category and language

### After Code Generation
1. **Validate all changes** - Use `symphony/validate_code`
2. **Fix violations** - Address issues before committing
...

baeyc0510 and others added 13 commits November 15, 2025 20:26
- Remove policy change history feature
  * Delete internal/policy/history.go
  * Remove /api/policy/history endpoint from server
  * Remove history UI components (button, modal, event handlers)
  * Remove 'policy history' CLI command

- Set default language for new rules from global settings
  * New rules now inherit languages from policy.defaults.languages
  * Improves consistency across policy rules

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove auto-save-checkbox references (element was deleted from HTML)
  * Remove event listener
  * Remove from saveSettings() and loadSettings()

- Remove defaults-autofix references (element was deleted from HTML)
  * Remove from renderAll()
  * Remove from saveSettings()
  * Remove from applyPermissions()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove auto-save timer and startAutoSave() function
- Remove autoSave from appState.settings
- Remove autoSave from localStorage loading/saving
- Clean up all autoSave references

This prevents the 30-second auto-save timer from triggering
and attempting to save incomplete/invalid policy data.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ements

Major Changes:

1. **Environment Variable Management (envutil package)**
   - Created internal/envutil package to centralize .env operations
   - Removed duplicate env-related functions across multiple files
   - Unified API key and policy path retrieval from .env files
   - Functions: GetAPIKey(), GetPolicyPath(), LoadKeyFromEnvFile(), SaveKeyToEnvFile()

2. **Policy Editor Improvements**
   - Add automatic policy path save on editor save
   - Implement file migration when policy path changes
   - Add convert prompt when rules are modified
   - Integrate convert API endpoint for linter config generation
   - Store original rules to detect changes

3. **Convert Command Enhancement**
   - Use POLICY_PATH from .env as default input
   - Output to same directory as input policy by default
   - Remove hardcoded paths

4. **Init Command Enhancement**
   - Create .sym/.env with default POLICY_PATH during init
   - Preserve existing API keys when adding POLICY_PATH

5. **MCP Server Enhancement**
   - Load policy path from .env instead of hardcoded path
   - Support both ANTHROPIC_API_KEY and OPENAI_API_KEY from .env

Files Modified:
- internal/envutil/env.go (new)
- internal/cmd/api_key.go
- internal/cmd/convert.go
- internal/cmd/init.go
- internal/engine/llm/engine.go
- internal/llm/client.go
- internal/mcp/server.go
- internal/server/server.go
- internal/server/static/policy-editor.js

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fix errcheck linter error by explicitly handling the file.Close() error
in deferred function. This resolves CI lint test failure.
Changes:
- Add originalRBAC to appState for tracking RBAC changes
- Implement createStableJSON helper for consistent object comparison
- Extend change detection to include both rules and RBAC
- Update conversion prompt to show what changed (rules/RBAC)
- Add .mcp.json to .gitignore

This enables the policy editor to detect RBAC changes and prompt
for linter config generation when either rules or RBAC are modified.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Add demo-template with description and language info
- Add code-policy.json existence check in policy editor
- Prompt conversion if code-policy.json is missing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…at/enhance-policy-editor

# Conflicts:
#	internal/server/static/policy-editor.js
Add automatic instructions file generation during MCP registration:

1. **Claude Code**: Appends to claude.md
2. **Cursor**: Creates .cursor/rules/symphony.mdc with frontmatter
3. **VS Code Copilot**: Creates .github/instructions/symphony.instructions.md

Instructions include:
- Check Symphony MCP server status before coding
- Query conventions using symphony/query_conventions
- Validate all changes using symphony/validate_code
- Convention categories: security, style, documentation, error_handling, architecture, performance, testing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Replace verbose "Next steps" with concise dashboard usage guide.

Changes:
- Remove file review and git commit instructions
- Focus on dashboard functionality:
  * Manage roles (team members, permissions)
  * Edit policies (coding conventions)
  * Test validation (real-time rule checking)
- Brief reminder to commit .sym/ folder

More actionable and user-friendly guidance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move dashboard usage message after MCP registration and API key setup,
so users see it only after all initialization steps are complete.

Improves UX by showing next steps at the end rather than interrupting
the setup flow.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sehwan505 sehwan505 merged commit 4fb27c8 into main Nov 18, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants