Hacker News 中文摘要

RSS订阅

显示HN:Runprompt——从命令行运行.prompt文件 -- Show HN: Runprompt – run .prompt files from the command line

文章摘要

该项目是一个名为"runprompt"的小型脚本工具,用于运行.prompt文件。该工具由GitHub用户chr15m开发,主要功能是处理提示文件,可能用于AI代码生成或自动化工作流程。

文章总结

GitHub项目:runprompt - 运行.prompt文件的轻量脚本

项目概述 runprompt是一个由开发者chr15m创建的开源项目,它是一个单文件Python脚本,专门用于运行.prompt文件(遵循Google的dotprompt规范)。该项目已获得137颗星和6个分支。

核心功能 1. 快速启动 - 通过curl获取脚本并添加执行权限 - 创建包含模型定义和模板的.prompt文件 - 通过环境变量设置API密钥后运行脚本

  1. 主要特性
  • 支持标准输入(STDIN)作为变量
  • 可生成结构化JSON输出
  • 支持提示链式调用(前一个提示的输出作为后一个的输入)
  • 提供命令行参数覆盖配置选项
  1. 配置方式
  • 环境变量设置API密钥
  • 通过RUNPROMPT_前缀的环境变量覆盖配置
  • 支持详细模式(-v)查看请求/响应详情
  1. 支持的AI提供商
  • Anthropic (Claude系列)
  • OpenAI (GPT系列)
  • Google AI (Gemini系列)
  • OpenRouter (多提供商聚合服务)

使用示例 1. 基础提示

```html

model: anthropic/claude-sonnet-4-20250514

Say hello to {{name}}! ```

  1. 结构化输出 html output: format: json schema: name?: string, the person's name age?: number, the person's age

  2. 链式调用 shell echo "文本" | ./runprompt extract.prompt | ./runprompt generate-bio.prompt

项目结构 - 主脚本文件:runprompt - 测试用例:/tests目录 - CI工作流:/.github/workflows

技术栈 - Python (96.6%) - Shell (3.4%)

备注:该项目不包含已发布的版本或软件包,文档和更多示例可在项目README和tests目录中找到。

评论总结

以下是评论内容的总结:

  1. 功能需求与改进建议

    • 希望支持自定义基础URL以兼容本地LLM(如Ollama),提升速度和隐私性
      "Can the base URL be overridden so I can point it at eg Ollama..." (dymk)
    • 建议增加缓存功能以保持结果一致性
      "It would be cool if there were some cache..." (MatrixMan)
    • 提议支持直接通过shebang执行
      "Can it be made to be directly executable with a shebang line?" (cedws)
  2. 工具设计认可

    • 赞赏其轻量级、管道友好的设计,适合简单工作流
      "Dotprompt as a thin, pipe-friendly layer around LLMs feels way more ergonomic..." (Barathkanna)
      "Everything seems to be about agents. Glad to see a post about enabling simple workflows!" (tomComb)
    • 认为.prompt格式实用,适合构建提示库
      "I'd actually rather have a small library of prompts..." (cootsnuck)
  3. 与其他工具的比较

    • 对比现有方案(如.md文件、Microsoft的.prompty格式)
      "Why this over md files I already make..." (orliesaurus)
      "Seems there is a very similar format by Microsoft called .prompty" (oddrationale)
    • 用户自发开发类似工具(如pmp项目)
      "I created something similar recently..." (meander_water)
  4. 社区反应

    • 积极反馈创意并提交改进建议
      "Seeing lots of good ideas in this thread..." (stephenlf)
      "I’m so happy that you made this!" (gessha)
    • 幽默调侃开发方式
      "Ooof, I guess vibecoding is only as good as the vibecoder." (ltbarcly3)

关键争议点:
- 是否需要支持更多文件格式(如.prompty)
- 与现有工作流(如手动脚本/Alfred)的替代价值