mirror of
https://github.com/documenso/documenso.git
synced 2026-06-22 04:12:06 +10:00
docs: add OpenCode AI-assisted development guide (#2384)
Adds OpenCode support for AI-assisted development, including custom commands and skills to help contributors maintain consistency and streamline common workflows. #### Changes - Added "AI-Assisted Development with OpenCode" section to CONTRIBUTING.md with: - Installation instructions and provider configuration - Documentation for 8 custom commands (/implement, /continue, /interview, /document, /commit, /create-plan, /create-scratch, /create-justification) - Typical workflow guide - Clear policy that AI-generated code must be reviewed before submission - Added .agents/ directory for plans, scratches, and justifications - Added .opencode/ commands and skills for the agent - Added helper scripts for creating agent files
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env node
|
||||
import { readFileSync } from 'fs';
|
||||
import { mkdirSync, writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { generateId } from './utils/generate-id';
|
||||
|
||||
const JUSTIFICATIONS_DIR = join(process.cwd(), '.agents', 'justifications');
|
||||
|
||||
const main = () => {
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
if (args.length === 0) {
|
||||
console.error('Usage: npx tsx scripts/create-justification.ts "file-slug" [content]');
|
||||
console.error(' or: npx tsx scripts/create-justification.ts "file-slug" << HEREDOC');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const slug = args[0];
|
||||
let content = '';
|
||||
|
||||
// Check if content is provided as second argument
|
||||
if (args.length > 1) {
|
||||
content = args.slice(1).join(' ');
|
||||
} else {
|
||||
// Read from stdin (heredoc)
|
||||
try {
|
||||
const stdin = readFileSync(0, 'utf-8');
|
||||
content = stdin.trim();
|
||||
} catch (error) {
|
||||
console.error('Error reading from stdin:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
console.error('Error: No content provided');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Generate unique ID
|
||||
const id = generateId();
|
||||
const filename = `${id}-${slug}.md`;
|
||||
const filepath = join(JUSTIFICATIONS_DIR, filename);
|
||||
|
||||
// Format title from slug (kebab-case to Title Case)
|
||||
const title = slug
|
||||
.split('-')
|
||||
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join(' ');
|
||||
|
||||
// Get current date in ISO format
|
||||
const date = new Date().toISOString().split('T')[0];
|
||||
|
||||
// Create frontmatter
|
||||
const frontmatter = `---
|
||||
date: ${date}
|
||||
title: ${title}
|
||||
---
|
||||
|
||||
`;
|
||||
|
||||
// Ensure directory exists
|
||||
mkdirSync(JUSTIFICATIONS_DIR, { recursive: true });
|
||||
|
||||
// Write file with frontmatter
|
||||
writeFileSync(filepath, frontmatter + content, 'utf-8');
|
||||
|
||||
console.log(`Created justification: ${filepath}`);
|
||||
console.log(`ID: ${id}`);
|
||||
console.log(`Filename: ${filename}`);
|
||||
};
|
||||
|
||||
main();
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env node
|
||||
import { readFileSync } from 'fs';
|
||||
import { mkdirSync, writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { generateId } from './utils/generate-id';
|
||||
|
||||
const PLANS_DIR = join(process.cwd(), '.agents', 'plans');
|
||||
|
||||
const main = () => {
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
if (args.length === 0) {
|
||||
console.error('Usage: npx tsx scripts/create-plan.ts "file-slug" [content]');
|
||||
console.error(' or: npx tsx scripts/create-plan.ts "file-slug" << HEREDOC');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const slug = args[0];
|
||||
let content = '';
|
||||
|
||||
// Check if content is provided as second argument
|
||||
if (args.length > 1) {
|
||||
content = args.slice(1).join(' ');
|
||||
} else {
|
||||
// Read from stdin (heredoc)
|
||||
try {
|
||||
const stdin = readFileSync(0, 'utf-8');
|
||||
content = stdin.trim();
|
||||
} catch (error) {
|
||||
console.error('Error reading from stdin:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
console.error('Error: No content provided');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Generate unique ID
|
||||
const id = generateId();
|
||||
const filename = `${id}-${slug}.md`;
|
||||
const filepath = join(PLANS_DIR, filename);
|
||||
|
||||
// Format title from slug (kebab-case to Title Case)
|
||||
const title = slug
|
||||
.split('-')
|
||||
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join(' ');
|
||||
|
||||
// Get current date in ISO format
|
||||
const date = new Date().toISOString().split('T')[0];
|
||||
|
||||
// Create frontmatter
|
||||
const frontmatter = `---
|
||||
date: ${date}
|
||||
title: ${title}
|
||||
---
|
||||
|
||||
`;
|
||||
|
||||
// Ensure directory exists
|
||||
mkdirSync(PLANS_DIR, { recursive: true });
|
||||
|
||||
// Write file with frontmatter
|
||||
writeFileSync(filepath, frontmatter + content, 'utf-8');
|
||||
|
||||
console.log(`Created plan: ${filepath}`);
|
||||
console.log(`ID: ${id}`);
|
||||
console.log(`Filename: ${filename}`);
|
||||
};
|
||||
|
||||
main();
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env node
|
||||
import { readFileSync } from 'fs';
|
||||
import { mkdirSync, writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { generateId } from './utils/generate-id';
|
||||
|
||||
const SCRATCHES_DIR = join(process.cwd(), '.agents', 'scratches');
|
||||
|
||||
const main = () => {
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
if (args.length === 0) {
|
||||
console.error('Usage: npx tsx scripts/create-scratch.ts "file-slug" [content]');
|
||||
console.error(' or: npx tsx scripts/create-scratch.ts "file-slug" << HEREDOC');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const slug = args[0];
|
||||
let content = '';
|
||||
|
||||
// Check if content is provided as second argument
|
||||
if (args.length > 1) {
|
||||
content = args.slice(1).join(' ');
|
||||
} else {
|
||||
// Read from stdin (heredoc)
|
||||
try {
|
||||
const stdin = readFileSync(0, 'utf-8');
|
||||
content = stdin.trim();
|
||||
} catch (error) {
|
||||
console.error('Error reading from stdin:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
console.error('Error: No content provided');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Generate unique ID
|
||||
const id = generateId();
|
||||
const filename = `${id}-${slug}.md`;
|
||||
const filepath = join(SCRATCHES_DIR, filename);
|
||||
|
||||
// Format title from slug (kebab-case to Title Case)
|
||||
const title = slug
|
||||
.split('-')
|
||||
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join(' ');
|
||||
|
||||
// Get current date in ISO format
|
||||
const date = new Date().toISOString().split('T')[0];
|
||||
|
||||
// Create frontmatter
|
||||
const frontmatter = `---
|
||||
date: ${date}
|
||||
title: ${title}
|
||||
---
|
||||
|
||||
`;
|
||||
|
||||
// Ensure directory exists
|
||||
mkdirSync(SCRATCHES_DIR, { recursive: true });
|
||||
|
||||
// Write file with frontmatter
|
||||
writeFileSync(filepath, frontmatter + content, 'utf-8');
|
||||
|
||||
console.log(`Created scratch: ${filepath}`);
|
||||
console.log(`ID: ${id}`);
|
||||
console.log(`Filename: ${filename}`);
|
||||
};
|
||||
|
||||
main();
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Generates a unique identifier using three simple words.
|
||||
* Falls back to unix timestamp if word generation fails.
|
||||
*/
|
||||
export const generateId = (): string => {
|
||||
const adjectives = [
|
||||
'happy',
|
||||
'bright',
|
||||
'swift',
|
||||
'calm',
|
||||
'bold',
|
||||
'clever',
|
||||
'gentle',
|
||||
'quick',
|
||||
'sharp',
|
||||
'warm',
|
||||
'cool',
|
||||
'fresh',
|
||||
'solid',
|
||||
'clear',
|
||||
'sweet',
|
||||
'wild',
|
||||
'quiet',
|
||||
'loud',
|
||||
'smooth',
|
||||
];
|
||||
|
||||
const nouns = [
|
||||
'moon',
|
||||
'star',
|
||||
'ocean',
|
||||
'river',
|
||||
'forest',
|
||||
'mountain',
|
||||
'cloud',
|
||||
'wave',
|
||||
'stone',
|
||||
'flower',
|
||||
'bird',
|
||||
'wind',
|
||||
'light',
|
||||
'shadow',
|
||||
'fire',
|
||||
'earth',
|
||||
'sky',
|
||||
'tree',
|
||||
'leaf',
|
||||
'rock',
|
||||
];
|
||||
|
||||
const colors = [
|
||||
'blue',
|
||||
'red',
|
||||
'green',
|
||||
'yellow',
|
||||
'purple',
|
||||
'orange',
|
||||
'pink',
|
||||
'cyan',
|
||||
'amber',
|
||||
'emerald',
|
||||
'violet',
|
||||
'indigo',
|
||||
'coral',
|
||||
'teal',
|
||||
'gold',
|
||||
'silver',
|
||||
'copper',
|
||||
'bronze',
|
||||
'ivory',
|
||||
'jade',
|
||||
];
|
||||
|
||||
try {
|
||||
const randomAdjective = adjectives[Math.floor(Math.random() * adjectives.length)];
|
||||
const randomColor = colors[Math.floor(Math.random() * colors.length)];
|
||||
const randomNoun = nouns[Math.floor(Math.random() * nouns.length)];
|
||||
|
||||
return `${randomAdjective}-${randomColor}-${randomNoun}`;
|
||||
} catch {
|
||||
// Fallback to unix timestamp if something goes wrong
|
||||
return Date.now().toString();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user