Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the coding-context tool to simplify its architecture by changing from a multi-file output approach (persona.md, rules.md, task.md) to a single stdout-based output. The command-line interface now requires both an agent name and task name as arguments, and the tool generates agent-specific rule mappings.
- Removed embedded bootstrap script and persona/task file generation
- Changed CLI from
[task-name] [persona-name]to<agent-name> <task-name>(both now required) - Introduced agent-specific rule path mappings for various AI coding assistants (ClaudeCode, Cursor, Windsurf, etc.)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| main.go | Complete refactoring of the main logic: removed persona/task file generation, added agent-specific rule path lookups, changed output from files to stdout, and modified argument validation to require exactly 2 arguments |
| bootstrap | Removed the embedded bootstrap script file entirely |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return fmt.Errorf("failed to stat persona path %s: %w", path, err) | ||
| for source, target := range map[string]string{ | ||
|
|
||
| // --- USER RULES (GLOBAL PERSUASION, HOME DIRECTORY) --- |
There was a problem hiding this comment.
Corrected spelling of 'PERSUASION' to 'PERSONA'. The comment appears to be describing user-level persona configuration.
| // --- USER RULES (GLOBAL PERSUASION, HOME DIRECTORY) --- | |
| // --- USER RULES (GLOBAL PERSONA, HOME DIRECTORY) --- |
| // --- USER RULES (GLOBAL PERSUASION, HOME DIRECTORY) --- | ||
| // These files define the agent's persona and rules across all projects. | ||
| // Standardized value format: ~/.agents/rules/<purpose>.md | ||
| homeDir + "/.claude/CLAUDE.md": homeDir + ".agents/rules/CLAUDE.md", // Claude Code global persona [1] |
There was a problem hiding this comment.
Missing path separator in the target path. Should be homeDir + \"/.agents/rules/CLAUDE.md\" to avoid creating a malformed path like /home/user.agents/rules/CLAUDE.md.
| homeDir + "/.claude/CLAUDE.md": homeDir + ".agents/rules/CLAUDE.md", // Claude Code global persona [1] | |
| homeDir + "/.claude/CLAUDE.md": homeDir + "/.agents/rules/CLAUDE.md", // Claude Code global persona [1] |
| // Standardized value format: ~/.agents/rules/<purpose>.md | ||
| homeDir + "/.claude/CLAUDE.md": homeDir + ".agents/rules/CLAUDE.md", // Claude Code global persona [1] | ||
| homeDir + "/.gemini/GEMINI.md": homeDir + "/.agents/rules/GEMINI.md", // Gemini CLI global context [2] | ||
| homeDir + "/.codex/AGENTS.md": homeDir + ".agents/rules/CODEX.md", // Codex CLI global guidance [3] |
There was a problem hiding this comment.
Missing path separator in the target path. Should be homeDir + \"/.agents/rules/CODEX.md\" to avoid creating a malformed path like /home/user.agents/rules/CODEX.md.
| homeDir + "/.codex/AGENTS.md": homeDir + ".agents/rules/CODEX.md", // Codex CLI global guidance [3] | |
| homeDir + "/.codex/AGENTS.md": homeDir + "/.agents/rules/CODEX.md", // Codex CLI global guidance [3] |
| homeDir + "/.gemini/GEMINI.md": homeDir + "/.agents/rules/GEMINI.md", // Gemini CLI global context [2] | ||
| homeDir + "/.codex/AGENTS.md": homeDir + ".agents/rules/CODEX.md", // Codex CLI global guidance [3] | ||
|
|
||
| // --- PROJECT RULES (ANCSTOR & PWD-SPECIFIC GUIDANCE) --- |
There was a problem hiding this comment.
Corrected spelling of 'ANCSTOR' to 'ANCESTOR'.
| // --- PROJECT RULES (ANCSTOR & PWD-SPECIFIC GUIDANCE) --- | |
| // --- PROJECT RULES (ANCESTOR & PWD-SPECIFIC GUIDANCE) --- |
| // Check for a bootstrap file named <markdown-file-without-md/mdc-suffix>-bootstrap | ||
| // For example, setup.md -> setup-bootstrap, setup.mdc -> setup-bootstrap | ||
| baseNameWithoutExt := strings.TrimSuffix(path, ext) | ||
| bootstrapSoucePath := baseNameWithoutExt + "-bootstrap" |
There was a problem hiding this comment.
Corrected spelling of 'bootstrapSoucePath' to 'bootstrapSourcePath'.
| if os.IsExist(err) { | ||
| continue | ||
| } else if err != nil { |
There was a problem hiding this comment.
Logic error: os.IsExist(err) returns true when a path already exists (when creating), but this is checking the error from os.RemoveAll. Should use os.IsNotExist(err) to skip if the file doesn't exist, or remove this check entirely since os.RemoveAll doesn't error if the path doesn't exist.
| if os.IsExist(err) { | |
| continue | |
| } else if err != nil { | |
| if err != nil { |
| for _, rulePath := range []string{ | ||
| ".agents/rules", | ||
| filepath.Join(userConfigDir, "agents", "rules"), | ||
| "/etc/agents/tasks", |
There was a problem hiding this comment.
Wrong path in rules iteration. This array is iterating over rule paths but includes /etc/agents/tasks which should be /etc/agents/rules to match the pattern established in the agentRulesPathLookup map.
| "/etc/agents/tasks", | |
| "/etc/agents/rules", |
|
|
||
| // Only process .md and .mdc files as rule files | ||
| // Only process .md files as rule files | ||
| ext := filepath.Ext(path) | ||
| if ext != ".md" && ext != ".mdc" { | ||
| if ext != ".md" { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
Missing directory check. Unlike the first loop (lines 117-119), this code doesn't skip directories before checking file extensions, which could cause issues if filepath.Walk encounters a directory with no extension.
| if err := os.WriteFile(bootstrapPath, bootstrapContent, 0700); err != nil { | ||
| return fmt.Errorf("failed to write bootstrap file: %w", err) | ||
| } | ||
| bootstrapSoucePath := baseNameWithoutExt + "-bootstrap" |
There was a problem hiding this comment.
Corrected spelling of 'bootstrapSoucePath' to 'bootstrapSourcePath'.
| } { | ||
|
|
||
| err := filepath.Walk(rule, func(path string, info os.FileInfo, err error) error { | ||
| err = filepath.Walk(rulePath, func(path string, info os.FileInfo, err error) error { |
There was a problem hiding this comment.
This definition of err is never used.
|
@copilot Think deeply about this change. Write a test suite. |
No description provided.