h3factory 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -7
- package/cli.py +72 -1
- package/package.json +1 -1
- package/scripts/postinstall.js +2 -0
- package/skills/h3factory/SKILL.md +3 -2
package/README.md
CHANGED
|
@@ -47,13 +47,13 @@ npm install -g git+https://<TOKEN>@github.com/xiangduo10146814/h3factory.git
|
|
|
47
47
|
### 从本地 tarball 安装
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
|
-
npm pack # 生成 h3factory-0.2.
|
|
51
|
-
npm install -g ./h3factory-0.2.
|
|
50
|
+
npm pack # 生成 h3factory-0.2.2.tgz
|
|
51
|
+
npm install -g ./h3factory-0.2.2.tgz
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
安装时 `postinstall` 会把 `skills/h3factory` 和 `skills/h3yun-dev-assistant` 复制到
|
|
55
|
-
Claude Code / Codex / Cursor / OpenCode / QwenWork / Qoder / QoderWork / Mulerun
|
|
56
|
-
的用户技能目录(不存在会创建)。技能更新由安装包管理,会覆盖本地修改。
|
|
55
|
+
Claude Code / Codex / Cursor / OpenCode / QwenWork / Qoder / QoderWork / Mulerun /
|
|
56
|
+
CodeBuddy / WorkBuddy 的用户技能目录(不存在会创建)。技能更新由安装包管理,会覆盖本地修改。
|
|
57
57
|
|
|
58
58
|
## 快速开始
|
|
59
59
|
|
|
@@ -61,7 +61,8 @@ Claude Code / Codex / Cursor / OpenCode / QwenWork / Qoder / QoderWork / Mulerun
|
|
|
61
61
|
mkdir D:\h3work && cd /d D:\h3work # 任意工作区目录,别用 System32
|
|
62
62
|
|
|
63
63
|
h3factory auth status --json # Agent 第一步:检查凭据,ok=false 就先录 token
|
|
64
|
-
h3factory init #
|
|
64
|
+
h3factory init # 交互录入 + 写入 AGENTS.md(任何 Agent 都能读到)
|
|
65
|
+
h3factory prompt # 打印通用提示语,直接贴给任意 Agent
|
|
65
66
|
h3factory doctor # 检查 Python / 配置 / JWT 是否过期 / 技能
|
|
66
67
|
h3factory demo # 复制内置示例项目到 ./projects/demo
|
|
67
68
|
h3factory check demo # 离线校验,不联网
|
|
@@ -105,7 +106,9 @@ JSON
|
|
|
105
106
|
| `h3factory auth status [--json]` | **凭据门禁**:检查配置与 JWT 是否可用 | 否 |
|
|
106
107
|
| `h3factory auth set --json` | 从 stdin 读 JSON 写入凭据(值不回显) | 否 |
|
|
107
108
|
| `h3factory auth set-token` | 从 stdin 读 token 写入 | 否 |
|
|
108
|
-
| `h3factory init [--no-input]` |
|
|
109
|
+
| `h3factory init [--no-input] [--no-agent-md]` | 生成 config.json 并写入 AGENTS.md | 否 |
|
|
110
|
+
| `h3factory agent init` | 只写 AGENTS.md 指令块 | 否 |
|
|
111
|
+
| `h3factory prompt [--short]` | 打印任意 Agent 可用的提示语 | 否 |
|
|
109
112
|
| `h3factory demo` | 复制内置示例项目 | 否 |
|
|
110
113
|
| `h3factory doctor` | 检查运行时、配置、JWT、技能 | 否 |
|
|
111
114
|
| `h3factory check <项目> [表..]` | 本地加载并校验表单定义 | 否 |
|
|
@@ -135,6 +138,8 @@ npm 安装后会把技能自动复制到以下用户级技能目录(目录不
|
|
|
135
138
|
| QwenWork | `~/.qwenworkcn/skills/` |
|
|
136
139
|
| Qoder / QoderWork | `~/.qoder/skills/`、`~/.qoderwork/skills/` |
|
|
137
140
|
| Mulerun | `~/.mulerun/skills/` |
|
|
141
|
+
| CodeBuddy | `~/.codebuddy/skills/` |
|
|
142
|
+
| WorkBuddy | `~/.workbuddy/skills/` |
|
|
138
143
|
|
|
139
144
|
随包安装两个技能:
|
|
140
145
|
|
|
@@ -163,6 +168,19 @@ CLI 自身也会在 `build/verify/group/import` 启动时做同样的检查,to
|
|
|
163
168
|
**首选方式**:让客户在自己的终端运行 `h3factory auth set-token`(输入隐藏,token 不进入对话记录);
|
|
164
169
|
还缺其他字段就运行 `h3factory init`。只有客户主动在对话里贴 token 时,才用上面的 `auth set --json`。
|
|
165
170
|
|
|
171
|
+
### 通用提示语(不依赖技能加载)
|
|
172
|
+
|
|
173
|
+
任何 Agent(包括 WorkBuddy / CodeBuddy,或不会自动加载技能的模型)都可以这样用:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
h3factory prompt # 打印通用提示语,复制给 Agent
|
|
177
|
+
h3factory prompt --short # 只要一句话版本
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
或者在项目目录运行一次 `h3factory init`:它会在工作区写入 `AGENTS.md`,
|
|
181
|
+
Codex 等会读取项目指令的 Agent 下次会话就能自动看到 h3factory 的流程和 token 门禁。
|
|
182
|
+
不读 `AGENTS.md` 的 Agent,直接把 `h3factory prompt` 的输出贴进去即可。
|
|
183
|
+
|
|
166
184
|
新需求直接对 Agent 说:
|
|
167
185
|
|
|
168
186
|
```
|
|
@@ -200,7 +218,7 @@ h3factory/
|
|
|
200
218
|
```bash
|
|
201
219
|
npm pack --dry-run # 检查包内容:不得出现 config.json / 业务 projects / logs
|
|
202
220
|
npm pack # 生成 tarball
|
|
203
|
-
npm install -g ./h3factory-0.2.
|
|
221
|
+
npm install -g ./h3factory-0.2.2.tgz
|
|
204
222
|
h3factory check demo # 冒烟
|
|
205
223
|
```
|
|
206
224
|
|
package/cli.py
CHANGED
|
@@ -59,6 +59,8 @@ TOOL_SKILL_DIRS = (
|
|
|
59
59
|
(".qoder", "qoder"),
|
|
60
60
|
(".qoderwork", "qoderwork"),
|
|
61
61
|
(".mulerun", "mulerun"),
|
|
62
|
+
(".codebuddy", "codebuddy"),
|
|
63
|
+
(".workbuddy", "workbuddy"),
|
|
62
64
|
)
|
|
63
65
|
|
|
64
66
|
|
|
@@ -133,7 +135,69 @@ def resolve_targets(proj, sheets, targets):
|
|
|
133
135
|
|
|
134
136
|
|
|
135
137
|
# ---------------------------------------------------------------- commands
|
|
138
|
+
AGENT_MD_BEGIN = "<!-- h3factory:begin -->"
|
|
139
|
+
AGENT_MD_END = "<!-- h3factory:end -->"
|
|
140
|
+
AGENT_MD_BLOCK = """<!-- h3factory:begin -->
|
|
141
|
+
## 氚云表单工厂(h3factory)
|
|
142
|
+
|
|
143
|
+
本工作区使用 `h3factory`。任何 Agent 会话开始必须先执行:
|
|
144
|
+
|
|
145
|
+
h3factory auth status --json
|
|
146
|
+
|
|
147
|
+
如果 `ok=false`,让用户在自己的终端运行 `h3factory auth set-token`(输入隐藏)
|
|
148
|
+
或 `h3factory init`;`ok=true` 后才允许执行 `build/verify/group/import`。
|
|
149
|
+
|
|
150
|
+
- 命令:`h3factory --help`
|
|
151
|
+
- 流程:`h3factory docs workflow`
|
|
152
|
+
- 需求澄清:`h3factory docs requirement_checklist`
|
|
153
|
+
- 通用提示语:`h3factory prompt`
|
|
154
|
+
<!-- h3factory:end -->"""
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def _ensure_agent_md(path):
|
|
158
|
+
"""幂等写入 AGENTS.md 的托管块,保留用户原有内容。"""
|
|
159
|
+
text = ""
|
|
160
|
+
if os.path.isfile(path):
|
|
161
|
+
with open(path, encoding="utf-8") as f:
|
|
162
|
+
text = f.read()
|
|
163
|
+
if AGENT_MD_BEGIN in text and AGENT_MD_END in text:
|
|
164
|
+
pre = text.split(AGENT_MD_BEGIN, 1)[0].rstrip()
|
|
165
|
+
post = text.split(AGENT_MD_END, 1)[1].lstrip("\n")
|
|
166
|
+
parts = [p for p in (pre, AGENT_MD_BLOCK, post) if p.strip()]
|
|
167
|
+
new = "\n\n".join(parts) + "\n"
|
|
168
|
+
else:
|
|
169
|
+
new = (text.rstrip() + "\n\n" if text.strip() else "") + AGENT_MD_BLOCK + "\n"
|
|
170
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
171
|
+
f.write(new)
|
|
172
|
+
return path
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def cmd_agent(args):
|
|
176
|
+
if args.action == "init":
|
|
177
|
+
path = _ensure_agent_md(os.path.join(settings.workspace_root(), "AGENTS.md"))
|
|
178
|
+
print("已写入 h3factory 指令块: %s" % path)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def cmd_prompt(args):
|
|
182
|
+
if args.short:
|
|
183
|
+
print("用 h3factory 帮我做这个需求:<需求>")
|
|
184
|
+
return
|
|
185
|
+
print("""请使用 h3factory 帮我完成以下需求:
|
|
186
|
+
<把需求贴在这里>
|
|
187
|
+
|
|
188
|
+
执行要求:
|
|
189
|
+
1. 先运行 h3factory auth status --json;若 ok=false,让我运行 h3factory auth set-token 录入 token。
|
|
190
|
+
2. 运行 h3factory docs workflow 和 h3factory docs requirement_checklist,按流程先澄清需求。
|
|
191
|
+
3. 产出 projects/<项目名>/ 设计后停下来让我过目,确认后再 build。""")
|
|
192
|
+
|
|
193
|
+
|
|
136
194
|
def cmd_init(args):
|
|
195
|
+
if not getattr(args, "no_agent_md", False):
|
|
196
|
+
try:
|
|
197
|
+
path = _ensure_agent_md(os.path.join(settings.workspace_root(), "AGENTS.md"))
|
|
198
|
+
print("已写入 Agent 指令: %s" % path)
|
|
199
|
+
except Exception as e:
|
|
200
|
+
print("警告: 写 AGENTS.md 失败: %s" % e)
|
|
137
201
|
existing = settings.resolve_config_path()
|
|
138
202
|
if existing:
|
|
139
203
|
print("config.json 已存在(%s),不覆盖。要重填请删除后重跑" % existing)
|
|
@@ -816,8 +880,14 @@ def main():
|
|
|
816
880
|
ap = argparse.ArgumentParser(prog="h3factory", description="h3factory —— 氚云表单工厂")
|
|
817
881
|
ap.add_argument("--version", action="version", version=VERSION)
|
|
818
882
|
sub = ap.add_subparsers(dest="cmd")
|
|
819
|
-
p = sub.add_parser("init", help="
|
|
883
|
+
p = sub.add_parser("init", help="生成配置文件并写入 AGENTS.md")
|
|
820
884
|
p.add_argument("--no-input", action="store_true", help="不交互,只复制模板")
|
|
885
|
+
p.add_argument("--no-agent-md", action="store_true",
|
|
886
|
+
help="不写入工作区 AGENTS.md")
|
|
887
|
+
p = sub.add_parser("agent", help="写入 AGENTS.md 指令(任意 Agent 通用)")
|
|
888
|
+
p.add_argument("action", choices=["init"])
|
|
889
|
+
p = sub.add_parser("prompt", help="打印通用提示语")
|
|
890
|
+
p.add_argument("--short", action="store_true", help="只输出一句话版本")
|
|
821
891
|
sub.add_parser("demo", help="把内置示例项目复制到工作区")
|
|
822
892
|
p = sub.add_parser("auth", help="凭据状态与录入(agent 第一步)")
|
|
823
893
|
p.add_argument("action", choices=["status", "set", "set-token"],
|
|
@@ -870,6 +940,7 @@ def main():
|
|
|
870
940
|
print("或: h3factory init(交互式录入全部凭据)")
|
|
871
941
|
sys.exit(2)
|
|
872
942
|
{"init": cmd_init, "demo": cmd_demo, "auth": cmd_auth,
|
|
943
|
+
"agent": cmd_agent, "prompt": cmd_prompt,
|
|
873
944
|
"doctor": cmd_doctor, "docs": cmd_docs,
|
|
874
945
|
"skill": cmd_skill, "check": cmd_check, "list": cmd_list,
|
|
875
946
|
"build": cmd_build, "verify": cmd_verify, "group": cmd_group,
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -40,11 +40,12 @@ description: 氚云(H3Yun)表单工厂总入口。用户提到氚云自动
|
|
|
40
40
|
|
|
41
41
|
## 工作区与安装
|
|
42
42
|
|
|
43
|
-
- 命令:`h3factory
|
|
43
|
+
- 命令:`h3factory`(npm 包名 `h3factory`;源码目录也可 `python -X utf8 cli.py`)。
|
|
44
44
|
- **当前目录 = 工作区**;项目在 `./projects/<项目名>/`。
|
|
45
45
|
- 配置查找顺序:`H3FACTORY_CONFIG` → `./config.json` → `~/.h3factory/config.json`;项目级 `projects/<项目名>/config.json` 优先于以上。
|
|
46
46
|
- 首次使用:`h3factory auth status --json` → 需要时 `auth set` 录入 token → `h3factory doctor`。
|
|
47
|
-
- 安装包会把技能自动装到 Claude Code / Codex / Cursor / OpenCode / QwenWork / Qoder / QoderWork / Mulerun 的用户技能目录;手动重装用 `h3factory skill install --tool all`。
|
|
47
|
+
- 安装包会把技能自动装到 Claude Code / Codex / Cursor / OpenCode / QwenWork / Qoder / QoderWork / Mulerun / CodeBuddy / WorkBuddy 的用户技能目录;手动重装用 `h3factory skill install --tool all`。
|
|
48
|
+
- 不自动加载技能的 Agent,用 `h3factory prompt` 打印通用提示语,或在项目里运行 `h3factory init` 写入 `AGENTS.md`。
|
|
48
49
|
- 查看内置文档:`h3factory docs` 列出,`h3factory docs schema_doc` 打印内容。
|
|
49
50
|
|
|
50
51
|
## 标准流程
|