CodePoet:将你的 Git 历史转化为史诗诗歌,使用 GitHub Copilot CLI 🎭
Source: Dev.to
我构建的
CodePoet 🎭 – 一个令人愉快的创意 CLI 工具,使用 GitHub Copilot CLI 将你的代码转换成诗歌、史诗故事和传奇叙事。
有没有在查看 git 历史时想过,“这可以更戏剧化一点”?CodePoet 将枯燥的提交日志变成史诗奇幻传奇,将代码文件化作优美的俳句,并生成团队真的会记住的诗意提交信息。
这不仅是一个有趣的实验——它是一个能为回顾会议带来乐趣、为团队创建可分享内容、让项目里程碑庆祝真正变得有趣的工具。
关键特性
- 📜 史诗传奇 – 您的 git 历史将变成英雄、战斗和辉煌胜利的传奇故事。
- 🌸 代码俳句 – 任意代码文件都可以变成优雅的 5‑7‑5 音节诗。
- 🎭 诗意提交 – 生成俳句、打油诗或莎士比亚体的提交信息。
- ⚔️ 开发者统计 – 将您的编码旅程呈现为 RPG 角色卡,包含成就和等级。
Tech Stack
- TypeScript – 强大的、类型安全的代码。
- Commander.js – CLI 解析。
- Simple‑git – 仓库分析。
- Chalk & Ora – 美观的终端输出。
- GitHub Copilot CLI – AI 驱动的创意生成。
演示
安装
git clone https://github.com/pealmasa/codepoet.git
cd codepoet
npm install
npm run build
npm link
史诗传奇指令
将你的 git 历史转化为史诗叙事:
codepoet saga
示例输出
🎭 THE SAGA OF CODEPOET 📜
═══════════════════════════════════════════════════════
In the ancient realm of TypeScript, a brave developer
embarked upon a legendary quest...
Chapter I: The Initialization
The hero forged the sacred package.json, binding the
project's fate to the Node.js kingdom...
Chapter II: The Battle of Dependencies
Armed with Commander, Chalk, and the mystical Simple‑git,
our champion assembled a fellowship of libraries...
Chapter III: The Refactoring Trials
Through treacherous bugs and tortuous logic, the hero
persevered, transforming chaos into elegant beauty...
代码俳句
将任意文件转化为诗歌:
codepoet haiku src/index.ts
示例输出
指令在此等待,
通过类型化路径指引方向,
诗歌腾空而起。
诗意提交
git add .
codepoet commit --style limerick
示例输出
There once was a bug in the code,
That caused the whole system to load,
Fixed it with grace,
In just one place,
Now smoothly the data has flowed!
开发者统计
codepoet stats
示例输出
╔════════════════════════════════════╗
║ DEVELOPER CHARACTER SHEET ║
╚════════════════════════════════════╝
Name: Pedro Marques Santos
Class: TypeScript Wizard
Level: 42
Stats:
⚔️ STR (Code Quality): 85/100
🛡️ DEF (Bug Fixes): 92/100
✨ INT (Features): 88/100
🏃 AGI (Commits): 156 commits
Achievements Unlocked:
🏆 First Commit
🔥 Bug Slayer (10+ fixes)
⭐ Feature Forger
📜 Documentation Hero
Source: …
我在 GitHub Copilot CLI 的使用体验
构建 CodePoet 是一次奇妙的创意 AI 应用之旅,而 GitHub Copilot CLI 则是让它得以实现的关键工具。
我是如何使用 Copilot CLI 的
(此处省略细节 – 你可以自行补充个人见解和使用的提示示例)
1. 核心创意引擎
CodePoet 的核心是 CopilotService 类,它封装了 GitHub Copilot CLI 的 gh copilot suggest 命令。与其把 Copilot 用作代码补全,我更把它当作 创意文本生成引擎:
async ask(prompt: string, options: CopilotOptions = {}): Promise {
const command = `gh copilot suggest "${fullPrompt}"`;
const { stdout } = await execAsync(command);
return this.cleanCopilotOutput(stdout);
}
2. 具备上下文感知的诗歌生成
我编写了特定的提示,让 Copilot CLI 获得丰富的创作上下文。
对于 史诗传奇 – 我提供 git 历史并让它:
- 将提交转化为英雄事迹
- 把 bug 修复写成对抗黑暗的战斗
- 把新特性描绘为传奇神器
- 把合并视作王国之间的联盟
对于 代码俳句 – 我提供实际代码并要求:
- 严格遵循 5‑7‑5 音节的传统结构
- 捕捉代码功能的本质
- 在保持技术准确性的同时展现诗意之美
3. 多种创意风格
风格指令引导 Copilot 的创作方向:
getStyleInstructions(style: string): string {
const styles = {
epic: 'Write in dramatic, fantasy‑epic style with grand language',
haiku: 'Create traditional Japanese haiku with exactly 5‑7‑5 syllables',
limerick: 'Write a funny limerick with AABBA rhyme scheme',
shakespearean: 'Write in Shakespearean style with iambic pentameter'
};
return styles[style];
}
对开发的影响
| 方面 | 好处 |
|---|---|
| 速度 | 无需集成完整的 LLM API(OpenAI、Anthropic 等);Copilot CLI 提供即时、具上下文感知的 AI,零配置。 |
| 质量 | 输出始终优秀,因为 Copilot 同时理解代码上下文 和 自然语言生成。 |
| 迭代 | 快速原型化提示风格并立即看到结果;紧密的反馈回路便于调优。 |
| 开发者体验 | gh copilot suggest 已为 Copilot 用户所熟悉,CodePoet 因此成为自然的工作流扩展。 |
为什么这很重要
CodePoet 表明 GitHub Copilot CLI 不仅仅用于建议 shell 命令——它是一个强大的创意 AI 工具,能够:
- 在丰富上下文下生成自然语言内容
- 理解技术概念并进行创意转化
- 以最小的设置提供一致、高质量的输出
- 无缝融入开发者的工作流
这为众多创意 CLI 工具打开了可能性:提交信息生成器、代码文档诗人、PR 描述写手等等!
使用 Copilot CLI 的未来设想
- 把代码评审写成电影评论 – “一次重构的杰作! ⭐⭐⭐⭐⭐”
- 把 PR 描述写成史诗故事 – 将 diff 变成冒险传奇
- 把发布说明写成歌曲歌词 – “🎵 版本 2.0,出发吧! 🎵”
- 把架构文档写成奇幻地图 – “在微服务的王国 …”
试一试!
克隆并安装
git clone https://github.com/pealmasa/codepoet.git
cd codepoet
npm install
npm run build
npm link
在任意 git 仓库中生成史诗般的 saga:
cd your-project
codepoet saga
在社交媒体上使用 #CodePoet 分享你最喜欢的输出!
仓库
🔗 GitHub:
📖 快速入门指南:
“最好的代码会讲述一个故事。CodePoet 以史诗般的方式讲述它!” 🎭📜✨




