npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lz-ui/cli-code

v1.0.0

Published

基于多智能体协作的智能需求文档生成 CLI 工具

Downloads

13

Readme

@lz-ui/cli-code


📖 项目简介

@lz-ui/cli-code 是一个运行在命令行中的 AI 智能体编排工具。它模拟了真实软件开发团队的工作流程,通过 "产品经理""评审专家" 两个智能体角色的博弈与协作,自动生成高质量的需求文档。

核心理念:

  • 角色扮演:模拟 PM 写文档、Reviewer 挑毛病的真实场景。
  • 博弈闭环:通过批评与自我批评,确保逻辑闭环,减少 AI 幻觉。
  • 人机协同:在关键决策点引入人工干预,确保结果符合预期。
  • 视觉友好:内置 Markdown 终端渲染与文档 Diff 差异对比功能。

✨ 核心功能

  • 🤝 双智能体协作:PM Agent 负责生成,Reviewer Agent 负责逻辑校验。
  • 💻 交互式控制台:支持 REPL 模式,内置闪烁光标,提供沉浸式终端体验。
  • ⚙️ 可视化配置:支持 /config 命令交互式配置模型,自动管理 API Key,无需手动编辑环境变量。
  • 🛑 人工干预机制:当智能体间存在争议或生成结果不满意时,支持人工介入指导。
  • 🎨 终端 Markdown 渲染:在命令行中优雅地展示格式化文档。
  • 📝 智能 Diff 对比:文档修改时,仅显示新增与删除部分,告别刷屏。
  • 📦 零配置发布:开箱即用,一键发布至 NPM。

项目架构设计

@lz-ui/cli-code/
├── bin/                  # CLI 入口
│   └── index.js
├── src/
│   ├── commands/         # CLI 命令层
│   │   └── generate.ts   # 核心生成命令
│   ├── agents/           # 智能体定义
│   │   ├── base.ts       # 基类
│   │   ├── pm.ts         # 产品经理 Agent
│   │   └── reviewer.ts   # 评审专家 Agent
│   ├── core/
│   │   ├── orchestrator.ts # 编排器(博弈闭环核心)
│   │   └── context.ts      # 上下文管理
│   ├── services/
│   │   ├── llm.ts        # AI 模型服务(支持流式输出)
│   │   └── diff.ts       # Diff 算法封装
│   ├── utils/
│   │   ├── ui.ts         # 终端渲染
│   │   └── config.ts     # 配置文件加载器
│   └── index.ts
├── prompts/              # 提示词模板(配置化)
│   ├── pm.yaml
│   └── reviewer.yaml
├── package.json
└── tsconfig.json

 关键设计思想解析

  1. 配置化与解耦
    • 我们没有把 PM 和 Reviewer 的提示词写死在代码里,而是通过 loadPrompt 从 prompts/*.yaml 加载。这样用户可以通过修改配置文件微调 Agent 行为。
    • AI 接口通过 dotenv 配置,兼容 OpenAI 格式的接口(如智谱 AI GLM-4),方便切换模型。
  2. 博弈闭环机制
    • Orchestrator 是核心。它不只是简单的调用,而是维护了一个 state (currentDoc)。
    • PM -> Doc -> Reviewer -> Feedback -> PM (修改) 的循环构成了"自我反思"机制,这比单次生成效果好很多,能有效减少 AI 幻觉。
  3. 人机协同
    • 在每一轮 Reviewer 提出建议后,代码插入了 inquirer 交互。
    • 用户可以选择"让 AI 改"、“自己改"或者"忽略”。这保证了人在回路中的决策权,避免了 AI 跑偏。
  4. 视觉体验
    • 使用 marked-terminal 直接在终端渲染 Markdown 表格、标题,体验接近 Notion。
    • 使用 diff 库进行增量对比,避免了刷屏,让用户一眼看到修改重点。

🚀 快速开始

1. 安装

全局安装 CLI 工具:

npm install -g @lz-ui/cli-code

2. 初始化配置

首次运行时,CLI 会检测环境变量。最简单的方式是运行配置命令:

lz-cli /config

3. 开始使用

交互式模式 (推荐):

直接运行命令进入交互式控制台:

lz-cli

启动后,你会看到欢迎界面:

 |     |__  /         | | | | |_ _|    / ___| | |     |_ _|
 | |       / /   _____  | | | |  | |    | |     | |      | |
 | |___   / /_  |_____| | |_| |  | |    | |___  | |___   | |
 |_____| /____|          \___/  |___|    \____| |_____| |___|

 > Multi-Agent Document Generator
 > 输入 /help 查看命令,或直接输入需求开始...

⚠️ 检测到尚未配置 AI 模型,请先运行 /config 进行初始化。