跳至内容
把 AI 工具链当成产品来做,而不是一堆脚本

把 AI 工具链当成产品来做,而不是一堆脚本

July 11, 2026

很多人的 AI 工具链是长出来的:一个 Chat 窗口、一段脚本、一个插件、一个本地模型——点都能用,合起来很累。缺的不是工具,是产品边界

1. 四层架构(先画清再填工具)

交互层   Web / 桌面 / IDE 插件
编排层   模板 · Agent 步骤 · 人工确认点
接入层   Gateway(鉴权/路由/日志/预算)
能力层   云模型 · 本地模型 · 检索 · 文件

层间用稳定接口:换 UI 不改路由;换模型不改桌面。

2. 把高频工作沉淀成模板

{
  "id": "release-checklist",
  "title": "发版前检查",
  "inputs": ["repo_path", "version"],
  "steps": [
    {
      "type": "shell",
      "run": "git -C {{repo_path}} status --porcelain"
    },
    {
      "type": "llm",
      "model": "auto",
      "prompt": "根据以下 git status,列出发版风险(中文要点):\n{{shell_0}}"
    },
    {
      "type": "human_confirm",
      "message": "确认风险可接受后再继续打 tag?"
    }
  ]
}

最小执行器示例:

# run_template.py
from __future__ import annotations
import json, subprocess, sys
from pathlib import Path
from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:4000/v1", api_key="sk-local")

def render(s: str, ctx: dict) -> str:
    for k, v in ctx.items():
        s = s.replace("{{" + k + "}}", str(v))
    return s

def run(path: str, inputs: dict) -> None:
    tpl = json.loads(Path(path).read_text())
    ctx = dict(inputs)
    for i, step in enumerate(tpl["steps"]):
        if step["type"] == "shell":
            cmd = render(step["run"], ctx)
            out = subprocess.check_output(cmd, shell=True, text=True)
            ctx[f"shell_{i}"] = out
            print(out)
        elif step["type"] == "llm":
            prompt = render(step["prompt"], ctx)
            r = client.chat.completions.create(
                model=step.get("model", "auto"),
                messages=[{"role": "user", "content": prompt}],
            )
            text = r.choices[0].message.content or ""
            ctx[f"llm_{i}"] = text
            print(text)
        elif step["type"] == "human_confirm":
            ans = input(step["message"] + " [y/N] ").strip().lower()
            if ans != "y":
                sys.exit("aborted by human")
        else:
            raise ValueError(step["type"])

if __name__ == "__main__":
    run(sys.argv[1], {"repo_path": sys.argv[2], "version": sys.argv[3]})

用法:

python run_template.py release-checklist.json /srv/tiancheng-notes v1.2.0

关键点:human_confirm——涉及发版、删数据、改生产时,自动化到「建议」为止。

3. 统一调用入口(再谈多 Agent)

# 所有客户端同一套
from openai import OpenAI
client = OpenAI(base_url="https://api.outsider-studio.cloud/v1", api_key="sk-xxx")

没有统一入口时,桌面存一份 Key、插件一份、脚本一份——工具链会在密钥轮换日集体死亡。

4. 案例:文档迁移助手从「聊天」变成「产品」

原来:每次打开 Chat,粘贴目录树,口述「帮我分类」。
现在:

  1. 桌面选目录 → command 列出文件(见 Tauri 文)
  2. 套用 docs-classify 模板
  3. 模型给出分类草案(JSON)
  4. 人在 UI 勾选确认
  5. 脚本只移动被勾选文件

成功率上升的原因不是更强模型,而是输入结构化 + 人工确认 + 可重复模板

5. 最小可运行版本(本周就能做完)

  1. 网关统一入口
  2. 只保留一个主交互端(Web 或桌面)
  3. 沉淀 3 个模板(发版检查 / 周报草稿 / 日志摘要)
  4. 调用打日志:template_id, model, tokens, cost
  5. 先别上复杂多 Agent

工具链的目标不是看起来智能,而是让你下周还愿意继续用。