Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.
Merged
203 changes: 203 additions & 0 deletions .github/workflows/bot-docs-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
name: Bot - Documentation Update

on:
push:
branches: [main, master]
paths:
- 'src/**'
- 'lib/**'
- '*.md'
schedule:
- cron: '0 0 * * 1' # Weekly on Monday

permissions:
contents: write
pull-requests: write

jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check README exists
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');

if (!fs.existsSync('README.md')) {
const template = `# ${context.repo.repo}

## Overview
[Add project description]

## Installation
\`\`\`bash
npm install
\`\`\`

## Usage
[Add usage instructions]

## Contributing
See CONTRIBUTING.md

## License
[Add license]

---
πŸ€– Generated by BlackRoad Bot System
`;

fs.writeFileSync('README.md', template);

await github.request('PUT /repos/{owner}/{repo}/contents/{path}', {
owner: context.repo.owner,
repo: context.repo.repo,
path: 'README.md',
message: 'πŸ€– docs: Add README template',
content: Buffer.from(template, 'utf8').toString('base64')
});
}

- name: Generate API docs
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');

// Simple JSDoc extraction
function extractDocs(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
const docRegex = /\/\*\*([\s\S]*?)\*\/\s*(?:export\s+)?(?:async\s+)?function\s+(\w+)/g;
const docs = [];

let match;
while ((match = docRegex.exec(content)) !== null) {
docs.push({
name: match[2],
doc: match[1].trim()
});
}

return docs;
}

function scanForFunctions(dir) {
const docs = [];
const entries = fs.readdirSync(dir, { withFileTypes: true });

for (const entry of entries) {
const fullPath = path.join(dir, entry.name);

if (entry.name.startsWith('.') || entry.name === 'node_modules') {
continue;
}

if (entry.isDirectory()) {
docs.push(...scanForFunctions(fullPath));
} else if (entry.name.endsWith('.js') || entry.name.endsWith('.ts')) {
docs.push(...extractDocs(fullPath));
}
}

return docs;
}

if (fs.existsSync('src')) {
const docs = scanForFunctions('src');

if (docs.length > 0) {
let apiDoc = '# API Documentation\n\n';
apiDoc += '> Auto-generated from source code\n\n';

for (const doc of docs) {
apiDoc += `## ${doc.name}\n\n`;
const cleanedDoc = doc.doc
.split('\n')
.map(line => line.replace(/^\s*\*\s?/, ''))
.join('\n');
apiDoc += cleanedDoc + '\n\n';
}

apiDoc += '\n---\nπŸ€– Generated by BlackRoad Bot System\n';

fs.writeFileSync('API.md', apiDoc);

console.log(`Generated API documentation with ${docs.length} functions`);
}
}

- name: Update documentation links
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');

if (fs.existsSync('README.md')) {
let readme = fs.readFileSync('README.md', 'utf8');

// Add links section if missing
if (!readme.includes('## Links') && !readme.includes('## Resources')) {
const links = `

## Links

- [Documentation](https://docs.blackroad.io)
- [API Reference](./API.md)
- [Contributing](./CONTRIBUTING.md)
- [BlackRoad OS](https://github.com/BlackRoad-OS)
`;
readme += links;
fs.writeFileSync('README.md', readme);
}
}

- name: Create PR for doc updates
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');

// Check if we made changes
const { execSync } = require('child_process');
const status = execSync('git status --porcelain').toString();

if (status.trim()) {
const branchName = `bot/docs-update-${Date.now()}`;

execSync(`git config user.name "github-actions[bot]"`);
execSync(`git config user.email "41898282+github-actions[bot]@users.noreply.github.com"`);
execSync(`git checkout -b ${branchName}`);
execSync(`git add .`);
execSync(`git commit -m "πŸ€– docs: Auto-update documentation"`);
execSync(`git push origin ${branchName}`);

await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'πŸ€– docs: Auto-update documentation',
body: `## Documentation Updates

This PR includes automated documentation updates:
- README improvements
- API documentation generation
- Link updates

**Generated by:** BlackRoad Bot System
**Review:** Please verify changes before merging

cc: @${context.repo.owner}`,
head: branchName,
base: 'main'
});
}

- name: Log to memory
run: |
if [ -f ~/memory-system.sh ]; then
~/memory-system.sh log bot-action "docs-update" "Documentation updated for ${{ github.repository }}"
fi
122 changes: 122 additions & 0 deletions .github/workflows/bot-issue-triage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Bot - Issue Triage

on:
issues:
types: [opened, edited, reopened]

permissions:
issues: write
contents: read

jobs:
triage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Auto-label issue
uses: actions/github-script@v7
with:
script: |
const issue = context.payload.issue;
const title = issue.title.toLowerCase();
const body = issue.body ? issue.body.toLowerCase() : '';
const labels = [];

// Auto-detect issue type
if (title.includes('bug') || body.includes('error') || body.includes('broken')) {
labels.push('bug');
}
if (title.includes('feature') || title.includes('enhancement')) {
labels.push('enhancement');
}
if (title.includes('docs') || title.includes('documentation')) {
labels.push('documentation');
}
if (title.includes('security') || body.includes('vulnerability')) {
labels.push('security');
}
if (title.includes('performance') || body.includes('slow')) {
labels.push('performance');
}
if (title.includes('test')) {
labels.push('testing');
}

// Priority detection
if (title.includes('urgent') || title.includes('critical') || body.includes('production down')) {
labels.push('priority:high');
} else if (title.includes('minor') || title.includes('trivial')) {
labels.push('priority:low');
} else {
labels.push('priority:medium');
}

// Add labels
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: labels
});
}

// Add triage comment
const comment = `πŸ‘‹ Thanks for opening this issue!

πŸ€– **Bot Triage:**
- Auto-labeled as: ${labels.join(', ')}
- Assigned priority based on content
- A team member will review soon

This is an automated message from the BlackRoad bot system.`;

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: comment
});

- name: Check for duplicates
uses: actions/github-script@v7
with:
script: |
const issue = context.payload.issue;
const title = issue.title.toLowerCase();

// Search for similar issues
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'all',
per_page: 100
});

const similar = issues.filter(i =>
i.number !== issue.number &&
i.title.toLowerCase().includes(title.split(' ')[0])
);
Comment on lines +98 to +101

Copilot AI Dec 23, 2025

Copy link

Choose a reason for hiding this comment

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

The duplicate detection logic only checks if the first word of the title appears in other issue titles. This is overly simplistic and will produce many false positives. For example, issues starting with "Add", "Fix", or "Update" would all be flagged as potential duplicates of each other. Consider using a more sophisticated similarity algorithm or checking for more significant overlap between titles.

Copilot uses AI. Check for mistakes.

if (similar.length > 0) {
const duplicateList = similar.slice(0, 5).map(i => `- #${i.number}: ${i.title}`).join('\n');

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `πŸ€– **Possible Duplicates Detected:**

${duplicateList}

Please check if any of these issues match your report.`
});
}

- name: Log to memory
run: |
if [ -f ~/memory-system.sh ]; then
~/memory-system.sh log bot-action "issue-triage" "Triaged issue #${{ github.event.issue.number }} in ${{ github.repository }}"
fi
Loading
Loading