Skip to content

feat: sync agent directories#54

Closed
alexec wants to merge 1 commit intomainfrom
sync
Closed

feat: sync agent directories#54
alexec wants to merge 1 commit intomainfrom
sync

Conversation

@alexec
Copy link
Contributor

@alexec alexec commented Nov 2, 2025

No description provided.

@alexec alexec requested a review from Copilot November 2, 2025 22:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) ---
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'PERSUASION' to 'PERSONA'. The comment appears to be describing user-level persona configuration.

Suggested change
// --- USER RULES (GLOBAL PERSUASION, HOME DIRECTORY) ---
// --- USER RULES (GLOBAL PERSONA, HOME DIRECTORY) ---

Copilot uses AI. Check for mistakes.
// --- 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]
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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]

Copilot uses AI. Check for mistakes.
// 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]
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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]

Copilot uses AI. Check for mistakes.
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) ---
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'ANCSTOR' to 'ANCESTOR'.

Suggested change
// --- PROJECT RULES (ANCSTOR & PWD-SPECIFIC GUIDANCE) ---
// --- PROJECT RULES (ANCESTOR & PWD-SPECIFIC GUIDANCE) ---

Copilot uses AI. Check for mistakes.
// 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"
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'bootstrapSoucePath' to 'bootstrapSourcePath'.

Copilot uses AI. Check for mistakes.
Comment on lines +230 to +232
if os.IsExist(err) {
continue
} else if err != nil {
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if os.IsExist(err) {
continue
} else if err != nil {
if err != nil {

Copilot uses AI. Check for mistakes.
for _, rulePath := range []string{
".agents/rules",
filepath.Join(userConfigDir, "agents", "rules"),
"/etc/agents/tasks",
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"/etc/agents/tasks",
"/etc/agents/rules",

Copilot uses AI. Check for mistakes.
Comment on lines 247 to 252

// 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
}
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
if err := os.WriteFile(bootstrapPath, bootstrapContent, 0700); err != nil {
return fmt.Errorf("failed to write bootstrap file: %w", err)
}
bootstrapSoucePath := baseNameWithoutExt + "-bootstrap"
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'bootstrapSoucePath' to 'bootstrapSourcePath'.

Copilot uses AI. Check for mistakes.
} {

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 {
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definition of err is never used.

Copilot uses AI. Check for mistakes.
@alexec
Copy link
Contributor Author

alexec commented Nov 2, 2025

@copilot Think deeply about this change. Write a test suite.

Copy link
Contributor

Copilot AI commented Nov 2, 2025

@alexec I've opened a new pull request, #55, to work on those changes. Once the pull request is ready, I'll request review from you.

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.

3 participants