Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 82 additions & 88 deletions .github/workflows/typos-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,84 +56,113 @@ jobs:
ERRORS_B64=$(cat typos-output.json | base64 -w 0)
echo "typos_errors=$ERRORS_B64" >> $GITHUB_OUTPUT
echo "found_typos=true" >> $GITHUB_OUTPUT
exit 1
else
# No typos found or errors
echo "typos_errors=" >> $GITHUB_OUTPUT
echo "found_typos=false" >> $GITHUB_OUTPUT
fi

- name: Comment on PR with typos results
if: github.event_name == 'pull_request'
uses: actions/github-script@v8
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
console.log('Starting comment creation script...');
try {
const foundTypos = `${{ steps.typos_check.outputs.found_typos }}` === 'true';
const encodedErrors = `${{ steps.typos_check.outputs.typos_errors }}`;

console.log('foundTypos:', foundTypos);
console.log('encodedErrors length:', encodedErrors ? encodedErrors.length : 0);
console.log('Context Issue Number:', context.issue.number);
console.log('Context Payload Pull Request Number:', context.payload.pull_request ? context.payload.pull_request.number : 'None');

const prNumber = context.issue.number || (context.payload.pull_request ? context.payload.pull_request.number : null);

if (!prNumber) {
console.log('No PR number found, skipping comment');
return;
}

let commentBody;

if (!foundTypos) {
// No typos found - success message
commentBody = `## ✅ Typos Check Passed\n\nNo spelling errors found! The codebase is clean.\n\n*Automated comment from typos-check workflow* 🤖`;
} else {
// Typos found - error message
// Handle case when there are no errors
if (!encodedErrors || encodedErrors.trim() === '') {
throw new Error('Typos check failed but no error details were captured.');
}

const typosJson = Buffer.from(encodedErrors, 'base64').toString('utf8');

// Split the JSON Lines format into individual objects
const typosLines = typosJson.trim().split('\n').filter(line => line.trim() !== '');
const typos = typosLines.map(line => JSON.parse(line));
console.log('No encoded errors found but foundTypos is true');
commentBody = `## ❌ Typos Check Failed\n\nTypos were detected but error details could not be captured.\n\n*Automated comment from typos-check workflow* 🤖`;
} else {
try {
const typosJson = Buffer.from(encodedErrors, 'base64').toString('utf8');
// Split the JSON Lines format into individual objects
const typosLines = typosJson.trim().split('\n').filter(line => line.trim() !== '');
const typos = [];

for (const line of typosLines) {
try {
if (line.trim().startsWith('{')) {
typos.push(JSON.parse(line));
}
} catch (e) {
console.log('Failed to parse line as JSON:', line);
}
}

// Group typos by file for better organization
const typosByFile = {};
typos.forEach(typo => {
if (!typosByFile[typo.path]) {
typosByFile[typo.path] = [];
}
typosByFile[typo.path].push(typo);
});
console.log('Parsed typos count:', typos.length);

// Create formatted comment with links
commentBody = `## ❌ Typos Check Failed\n\n`;
commentBody += `Found ${typos.length} spelling error(s) that need to be corrected:\n\n`;

// Add each file's typos with GitHub links
for (const [filePath, fileTypos] of Object.entries(typosByFile)) {
fileTypos.forEach(typo => {
// Create GitHub permalink with ?plain=1 parameter for proper file display
const lineNum = typo.line_num || 'unknown';
const permalink = lineNum !== 'unknown'
? `https://github.com/${context.repo.owner}/${context.repo.repo}/blob/${context.sha}/${filePath}?plain=1#L${lineNum}`
: `https://github.com/${context.repo.owner}/${context.repo.repo}/blob/${context.sha}/${filePath}?plain=1`;

// Handle corrections - typos output may have different field names
const corrections = typo.corrections || typo.correction || [typo.replacement] || [];
if (corrections.length === 0) {
commentBody += `- [${filePath}:${lineNum}](${permalink}): \`${typo.typo}\`\n`;
if (typos.length === 0) {
commentBody = `## ❌ Typos Check Failed\n\nTypos were detected but the output format was unexpected.\n\n*Automated comment from typos-check workflow* 🤖`;
} else {
commentBody += `- [${filePath}:${lineNum}](${permalink}): \`${typo.typo}\` should be \`${corrections.join('\`, \`')}\`\n`;
// Group typos by file for better organization
const typosByFile = {};
typos.forEach(typo => {
if (!typosByFile[typo.path]) {
typosByFile[typo.path] = [];
}
typosByFile[typo.path].push(typo);
});

// Create formatted comment with links
commentBody = `## ❌ Typos Check Failed\n\n`;
commentBody += `Found ${typos.length} spelling error(s) that need to be corrected:\n\n`;

// Add each file's typos with GitHub links
for (const [filePath, fileTypos] of Object.entries(typosByFile)) {
fileTypos.forEach(typo => {
const lineNum = typo.line_num || 'unknown';
const permalink = lineNum !== 'unknown'
? `https://github.com/${context.repo.owner}/${context.repo.repo}/blob/${context.sha}/${filePath}?plain=1#L${lineNum}`
: `https://github.com/${context.repo.owner}/${context.repo.repo}/blob/${context.sha}/${filePath}?plain=1`;

const corrections = typo.corrections || typo.correction || [typo.replacement] || [];
if (corrections.length === 0 || !corrections[0]) {
commentBody += `- [${filePath}:${lineNum}](${permalink}): \`${typo.typo}\`\n`;
} else {
commentBody += `- [${filePath}:${lineNum}](${permalink}): \`${typo.typo}\` should be \`${corrections.join('\`, \`')}\`\n`;
}
});
commentBody += `\n`;
}

commentBody += `Please fix these typos before merging. For more information, see [typos documentation](https://github.com/crate-ci/typos).\n\n`;
commentBody += `*Automated comment from typos-check workflow* 🤖`;
}
});

commentBody += `\n`;
} catch (decodeError) {
console.error('Error decoding/parsing typos:', decodeError);
commentBody = `## ❌ Typos Check Failed\n\nFound spelling errors but failed to parse details. Check workflow logs for raw output.\n\n*Automated comment from typos-check workflow* 🤖`;
}
}

commentBody += `Please fix these typos before merging. For more information, see [typos documentation](https://github.com/crate-ci/typos).\n\n`;
commentBody += `*Automated comment from typos-check workflow* 🤖`;
}

// Check if a comment already exists
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
issue_number: prNumber,
});

const botComments = comments.filter(comment =>
Expand All @@ -155,52 +184,17 @@ jobs:
const newComment = await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
issue_number: prNumber,
body: commentBody
});
console.log('Created new comment:', newComment.data.id);
}
} catch (error) {
console.error('Error in comment creation:', error);
// If parsing fails, create a simple comment with raw output
try {
const foundTypos = `${{ steps.typos_check.outputs.found_typos }}` === 'true';
let simpleComment;

if (!foundTypos) {
simpleComment = `## ✅ Typos Check Passed\n\nNo spelling errors found! The codebase is clean.\n\n*Automated comment from typos-check workflow* 🤖`;
} else {
const rawOutput = `${{ steps.typos_check.outputs.typos_errors }}`;
simpleComment = `## ❌ Typos Check Failed\n\nFound spelling errors that need to be corrected:\n\n\`\`\`\n${rawOutput}\n\`\`\`\n\nPlease fix these typos before merging.\n\n*Automated comment from typos-check workflow* 🤖`;
}

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
console.error('Critical error in comment creation:', error);
}

const botComments = comments.filter(comment =>
comment.user.login === 'github-actions[bot]' &&
(comment.body.includes('Typos Check') || comment.body.includes('typos-check workflow'))
);

if (botComments.length > 0) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComments[0].id,
body: simpleComment
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: simpleComment
});
}
} catch (fallbackError) {
console.error('Fallback comment creation also failed:', fallbackError);
}
}
- name: Fail if typos found
if: steps.typos_check.outputs.found_typos == 'true'
run: |
echo "Typos were found. Please fix them to pass the check."
exit 1
68 changes: 34 additions & 34 deletions conf/claude-local-marketplace/skills/debugger/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,11 @@ description: Systematically trace bugs backward through call stack to find the o
- Bugs are vague and not easy to spot
- User says debug this or debug it something like that

# Tools, subagents, skills that might be helpful

- **Critical**: `fast-repo-context` claude skill for fast codebase search and analysis, this is highly recommended to use, load it with `Skill` tool; Can use it to search on current project or other projects.
- `kg` knowledge graph search
- load `git-jj` claude skill for vcs operations (logs, blame, diff etc), use `bash ~/.claude/skills/git-jj/scripts/repo_check.sh` to check repo is jj or git managed.
- **Debugging-specific commands:**
- `git blame <file>` / `jj file annotate <file>` - find who changed a line and when
- `git log -p <file>` / `jj log -p <file>` - see all changes to a specific file
- `git bisect` - binary search for the commit that introduced a bug
- `git diff <a>..<b>` / `jj diff -r <a>..<b>` - compare specific revisions
- `jj log -r "file('path')"` - find commits that touched a file
- `outbox` subagent for high level debugging ideas, strategies, and issue qualitative analysis; Invoke the `Task` tool with `outbox`.
- `oracle` subagent for advanced reasoning about complex issues, decision making; Invoke the `Task` tool with `oracle`.
- `exa` mcp tool: use it to search on the web for similar issues, error messages, stack traces, and solutions.
- `github` mcp tool: use it to search library related issues in github issues.
- Other command tools that you already know
- As a last resort, run `claude --model openrouter/anthropic/claude-opus-4.5 -p "<detailed prompt about the issue>" --tools "Read,Grep,Glob"` for help from the most advanced SWE LLM. This is expensive, so use it wisely and compose the prompt carefully.

## When to use git history for debugging

Use git history when:
- **Regression bugs**: User says "it worked before" or "it broke after update"
- **Unknown code changes**: You find suspicious code but don't understand why it was written that way
- **Recent breakage**: Bug appeared recently and might correlate with recent commits
- **Blame investigation**: Need to find the original author/context of problematic code

Skip git history when:
- Bug is clearly a logic error in current code
- Issue is configuration or environment related
- User confirms this is new code, not a regression

# Debugging process

1. **Understand** the issue/bug
2. **Fetch context with fast-repo-context skill** of the codebases. Use `kg` to search the knowledge graph in case we solved this before. Use `fast-repo-context` skill(recommended) or `rg` bash tool to search the codebases with possible keywords, and read comments or documents. Attach current project root path when applicable, this is needed for other tools to work properly, include the `outbox` agent.
3. **Review available tools** and subagents (fd, rg, kg, git, etc.)
2. **Fetch context** Use `kg` to search the knowledge graph in case we solved this before. Use `fast-repo-context` skill(recommended) or `rg` bash tool to search the codebases with possible keywords, and read comments or documents. Get a sense of recent changes that might relate to the issue/bug. Identify relevant files and code areas. You can ask general subagent to do this for you.
3. **Review available tools** Review what tools do you have that might help you debug issues.
4. **Start debugging iterations** - Each iteration MUST be explicitly labeled (e.g., "**Iteration 1**", "**Iteration 2**")
- 4.1 Get debugging ideas/strategy or issue qualitative analysis from `outbox` subagent with context from steps 2 and 3. Include the tools and subagents you have and what they do, so `outbox` can give advice based on your available tools.
- 4.2 **Check git history** (if applicable): Use `git-jj` skill to investigate version history when the bug might be a regression. Run blame on suspicious lines, check recent file changes, or use bisect to find the breaking commit. See "When to use git history" section above.
Expand All @@ -62,7 +31,7 @@ Skip git history when:

## Outbox prompt template

**Note**: `outbox` is a readonly/thinking agent. It cannot use tools (no Read, Write, Execute). It can only reason and advise. You must provide all relevant context in the prompt.
**Note**: `outbox` is a readonly/thinking agent. It cannot use tools (no Read, no Write, no Execute). It can only reason and advise. You must provide all relevant context in the prompt.

### First iteration:
```
Expand Down Expand Up @@ -104,6 +73,37 @@ Skip git history when:
**Ask**: Based on findings, what should I try next? At the end of your advice, include a "feedback request" like: "If this doesn't work, tell me [specific info] for next iteration."
```

# Tools, subagents, skills that might be helpful

- **Critical**: `fast-repo-context` claude skill for fast codebase search and analysis, this is highly recommended to use, load it with `Skill` tool; Can use it to search on current project or other projects.
- `kg` knowledge graph search, use it to find whether we have solved similar issues before.
- load `git-jj` claude skill for vcs operations (logs, blame, diff etc), use `bash ~/.claude/skills/git-jj/scripts/repo_check.sh` to check repo is jj or git managed.
- **Debugging-specific commands:**
- `git blame <file>` / `jj file annotate <file>` - find who changed a line and when
- `git log -p <file>` / `jj log -p <file>` - see all changes to a specific file
- `git bisect` - binary search for the commit that introduced a bug
- `git diff <a>..<b>` / `jj diff -r <a>..<b>` - compare specific revisions
- `jj log -r "file('path')"` - find commits that touched a file
- `outbox` subagent for high level debugging ideas, strategies, and issue qualitative analysis; Invoke the `Task` tool with `outbox`.
- `oracle` subagent for advanced reasoning about complex issues, decision making; Invoke the `Task` tool with `oracle`.
- `exa` mcp tool: use it to search on the web for similar issues, error messages, stack traces, and solutions.
- `github` mcp tool: use it to search library related issues in github issues.
- Other command tools that you already know

## When to use git history for debugging

Use git history when:

- **Regression bugs**: User says "it worked before", "it broke after update", recent we have a refactor or dependency upgrade etc.
- **Unknown code changes**: You find suspicious code but don't understand why it was written that way
- **Recent breakage**: Bug appeared recently and might correlate with recent commits
- **Blame investigation**: Need to find the original author/context of problematic code

Skip git history when:
- Bug is clearly a logic error in current code
- Issue is configuration or environment related
- User confirms this is new code, not a regression

## Notes

- `kg` should be used for finding key information related to the issues. Do not use it to save unverified debugging assumptions. After user confirms the fix, you can ask whether to save the fix to the knowledge graph.
Expand Down
Loading
Loading