added prompt context library (#27)

This commit is contained in:
Arwid Thornström
2025-06-17 10:00:25 +02:00
committed by GitHub
parent 8950a83e12
commit 90b9ccc454
5 changed files with 1098 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
import { GluegunMenuToolbox } from '@lenne.tech/gluegun-menu';
import { defaultMenuSettings } from '../../globals';
module.exports = {
name: 'ai',
alias: ['ai'],
description: 'AI (ai)',
hidden: false,
run: async (toolbox: GluegunMenuToolbox) => {
await toolbox.menu.showMenu('ai', defaultMenuSettings);
},
};
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,51 @@
import { GluegunMenuToolbox } from '@lenne.tech/gluegun-menu';
import * as path from 'path';
import * as fs from 'fs';
import chalk = require('chalk');
const { AutoComplete } = require('enquirer');
const clipboard = require('clipboardy');
module.exports = {
name: 'promptcontextlibrary',
alias: ['pcl'],
description: 'Prompt Context Library (pcl)',
hidden: false,
run: async (toolbox: GluegunMenuToolbox) => {
const currentDir = path.dirname(__filename);
const files = fs
.readdirSync(currentDir)
.filter((file) => file.endsWith('.txt'))
.map((file) => ({
name: file.replace(/-/g, ' ').replace(/\b\w/g, (l) => l.toUpperCase()),
value: file,
}));
console.log(chalk.cyan('📚 Welcome to the Prompt Context Library! 📚'));
const prompt = new AutoComplete({
name: 'context',
message: chalk.yellow('✨ Select a context file:'),
limit: 10,
initial: 0,
choices: files,
});
try {
const answer = await prompt.run();
const filePath = path.join(currentDir, answer);
const fileContent = fs.readFileSync(filePath, 'utf8');
// Copy content to clipboard
await clipboard.write(fileContent);
console.log(chalk.green(`🎯 Selected: ${chalk.bold(answer)}`));
console.log(
chalk.magenta(
'📋 Context has been copied to clipboard and is ready to paste! 🚀'
)
);
} catch (error) {
console.error(chalk.red('❌ Operation cancelled'));
}
},
};