cli-calctool 1.0.0 → 1.0.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 +9 -161
- package/cli.mjs +238 -0
- package/package.json +12 -14
- package/{skills/calctool → skill}/SKILL.md +9 -5
- package/{skills/calctool → skill}/skill.json +2 -2
- package/LICENSE +0 -201
- package/install.mjs +0 -442
- package/skills/blueprint/SKILL.md +0 -47
- package/skills/blueprint/install-meta.json +0 -7
- package/skills/blueprint/skill.json +0 -10
- package/skills/calctool/install-meta.json +0 -7
- package/skills/calctool/platform-template/README.md +0 -74
- package/skills/calctool/platform-template/index.html +0 -12
- package/skills/calctool/platform-template/package.json +0 -26
- package/skills/calctool/platform-template/src/App.tsx +0 -233
- package/skills/calctool/platform-template/src/authz.ts +0 -103
- package/skills/calctool/platform-template/src/engine/evaluate.ts +0 -114
- package/skills/calctool/platform-template/src/engine-definition.json +0 -195
- package/skills/calctool/platform-template/src/main.tsx +0 -13
- package/skills/calctool/platform-template/src/pipeline.ts +0 -80
- package/skills/calctool/platform-template/src/store.ts +0 -53
- package/skills/calctool/platform-template/tsconfig.json +0 -15
- package/skills/calctool/platform-template/vite.config.ts +0 -7
- package/skills/calctool/references/declarative-pages.md +0 -69
- package/skills/calctool/references/engine-meta-model.md +0 -123
- package/skills/calctool/references/finance-example.md +0 -132
- package/skills/calctool/references/formula-dsl.md +0 -92
- package/skills/calctool/references/import-ocr.md +0 -72
- package/skills/calctool/templates/ecommerce-ops/README.md +0 -27
- package/skills/calctool/templates/ecommerce-ops/domain-reference.yaml +0 -172
- package/skills/swarm/SKILL.md +0 -120
- package/skills/swarm/install-meta.json +0 -7
- package/skills/swarm/references/ops-heartbeat.md +0 -45
- package/skills/swarm/references/org-chart.md +0 -50
- package/skills/swarm/references/security-guard.md +0 -56
- package/skills/swarm/references/task-lifecycle.md +0 -53
- package/skills/swarm/references/traffic-light.md +0 -52
- package/skills/swarm/skill.json +0 -10
- package/skills/swarm/swarm-runtime.mjs +0 -600
- package/sources.json +0 -25
package/README.md
CHANGED
|
@@ -1,166 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# calctool — 按需生成万能计算工具
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
从 CLI.Tax 安装并运行 calctool 技能:输入领域需求(如"我是财务,想要一个经营健康诊断工具"),
|
|
4
|
+
生成可执行、可验证、可发布的在线计算工具——支持自定义指标、自定义公式逻辑、上传内容自动识别。
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
npx cli-blueprint@latest install
|
|
7
|
-
```
|
|
6
|
+
## 命令
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
- `
|
|
11
|
-
- `calctool`(万能计算工具生成器,`https://cli.tax/KKyA6xljUX`)
|
|
8
|
+
- `npx <package-url> install [directory]` — 安装 skill 到当前 IDE
|
|
9
|
+
- `npx <package-url> run` — 技能握手:capabilities + intake 提问,保存 CALCTOOL-REQUIREMENTS.json
|
|
12
10
|
|
|
13
|
-
##
|
|
11
|
+
## 运行时
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
可分发、可扩展的本地插件包**,并打通了 cli.tax 生态:
|
|
18
|
-
|
|
19
|
-
- **自动拉取**:`sources.json` 里配置 cli.tax skill 源(如 `wvz6zmRWmX`),
|
|
20
|
-
`node install.mjs pull` 或 install 时自动从 cli.tax 拉取最新内容到 `skills/`(可提交进 git)
|
|
21
|
-
- **自动匹配分发**:每个 skill 是一个目录:`skills/<name>/SKILL.md`;安装器自动检测本机
|
|
22
|
-
真实安装的 IDE,把 skill 分发到各 IDE 自己的用户级根(如 Codex 扫 `~/.codex/skills`、
|
|
23
|
-
DSH 扫 `~/.dsh/skills`),各一份、互不干扰
|
|
24
|
-
- 共享兼容根 `~/.agents/skills` 默认跳过——它会被多个工具扫描,是"同一 skill 重复出现"的根源
|
|
25
|
-
|
|
26
|
-
**与 clitaxio 的区别**:clitaxio 只把 skill 装到**一个** IDE 目录;本包是"拉取 + 多 IDE 自动分发",
|
|
27
|
-
装一次,本机所有已装 IDE 都能用。
|
|
28
|
-
|
|
29
|
-
## 安装 / 更新 / 卸载
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
# 本地运行(无需发布)
|
|
33
|
-
node install.mjs pull # 从 cli.tax(sources.json)拉取最新 skill 到 skills/,可 git 提交
|
|
34
|
-
node install.mjs install # 自动匹配:skills/ 为空时自动先 pull,再分发到本机已装 IDE
|
|
35
|
-
node install.mjs install --all # 装到所有已知 IDE(不管是否安装)
|
|
36
|
-
node install.mjs install --ide codex --ide dsh # 只装指定 IDE(可重复)
|
|
37
|
-
node install.mjs install --skip cursor # 自动匹配但跳过指定 IDE(可重复)
|
|
38
|
-
node install.mjs install --pull # 强制重新从 cli.tax 拉取后再安装
|
|
39
|
-
node install.mjs install --project # 额外装到当前项目的项目级根
|
|
40
|
-
node install.mjs install --agents # 额外装到共享 ~/.agents/skills(警告:可能被多工具重复发现)
|
|
41
|
-
node install.mjs install --target /abs/path # 只装到自定义目录
|
|
42
|
-
node install.mjs update # 幂等覆盖,等同 install
|
|
43
|
-
node install.mjs list # 列出包内 skills
|
|
44
|
-
node install.mjs ides # 查看已知 IDE 及本机检测结果(✓ = 本机已装)
|
|
45
|
-
node install.mjs uninstall # 从相同目标卸载本包安装的 skills
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
**自动匹配说明**:默认安装会探测本机真实安装的 IDE(`which` 命令 / 应用路径 / 配置文件),
|
|
49
|
-
只装给已安装的 IDE,让每个 IDE 自己识别需要的 skill。用 `node install.mjs ides` 查看
|
|
50
|
-
本机检测结果(✓ = 已安装)。
|
|
51
|
-
|
|
52
|
-
## 支持的 IDE(全世界已知安装位置,官方文档核实)
|
|
53
|
-
|
|
54
|
-
| IDE | 用户级根 | 项目级根 | 说明 |
|
|
55
|
-
|---|---|---|---|
|
|
56
|
-
| Codex CLI | `~/.codex/skills` | `.codex/skills` | 新官方约定 `~/.agents/skills`;此处用专属根避免共享冲突 |
|
|
57
|
-
| DSH | `~/.dsh/skills` | `.dsh/skills` | skill-filesystem 自动扫描 |
|
|
58
|
-
| Claude Code | `~/.claude/skills` | `.claude/skills` | 父目录向上扫描至 repo root |
|
|
59
|
-
| Gemini CLI | `~/.gemini/skills` | `.gemini/skills` | 别名 `.agents/skills` 优先级更高 |
|
|
60
|
-
| Google Antigravity | `~/.gemini/antigravity/skills` | `.agents/skills`(随 --agents) | workspace 级固定用 agents 标准 |
|
|
61
|
-
| Cursor | `~/.cursor/skills` | `.cursor/skills` | 兼容加载 .claude/.codex/.agents/skills |
|
|
62
|
-
| Cline | `~/.cline/skills` | `.cline/skills` | 全局优先于项目 |
|
|
63
|
-
| Roo Code | `~/.roo/skills` | `.roo/skills` | 项目覆盖全局 |
|
|
64
|
-
| Kilo Code | `~/.kilo/skills` | `.kilo/skills` | kilo.jsonc 可配 |
|
|
65
|
-
| Windsurf | `~/.codeium/windsurf/skills` | `.windsurf/skills` | Cascade Skills |
|
|
66
|
-
| VS Code / Copilot | `~/.copilot/skills` | `.github/skills` | 另兼容 .claude/skills |
|
|
67
|
-
| Trae | `~/.trae-cn/skills`(国内版) | `.trae/skills` | 国际版用户级未确认 |
|
|
68
|
-
| Qwen Code | `~/.qwen/skills` | `.qwen/skills` | 模型自动调用 |
|
|
69
|
-
| OpenCode | `~/.config/opencode/skills` | `.opencode/skills` | 兼容 .claude/.agents |
|
|
70
|
-
| Zed | `~/.agents/skills`(仅 --agents) | `.agents/skills`(仅 --agents) | 官方即用 agents 标准根 |
|
|
71
|
-
| Amazon Q | 无 skills 机制 | 无 skills 机制 | 官方确认不支持 SKILL.md |
|
|
72
|
-
|
|
73
|
-
> 跨工具互操作标准根 `~/.agents/skills`(agentskills.io):Codex 新约定、Gemini、Zed、
|
|
74
|
-
> OpenCode、Cursor、Antigravity、Kilo 等都支持,但会被**多个工具同时扫描**——同一 skill
|
|
75
|
-
> 装进去会在各工具中重复出现。本安装器默认跳过它(`--agents` 显式开启并警告)。
|
|
76
|
-
>
|
|
77
|
-
> 新增 IDE:在 `install.mjs` 的 `IDES` 数组加一行即可,其余逻辑自动生效。
|
|
78
|
-
|
|
79
|
-
## 分发给别人
|
|
80
|
-
|
|
81
|
-
### 方式 A:npm 一条命令(推荐,最简单)
|
|
82
|
-
已发布到 npm(`cli-blueprint` / `cli-calctool` / `cli-swarm`),使用者只需:
|
|
83
|
-
```bash
|
|
84
|
-
npx cli-blueprint@latest install # 装 blueprint + calctool + swarm 三个 skill
|
|
85
|
-
npx cli-calctool@latest install # 同样内容(calctool 命名入口)
|
|
86
|
-
npx cli-swarm@latest install # 同样内容(swarm 命名入口)
|
|
87
|
-
```
|
|
88
|
-
自动完成:从 cli.tax 拉取 blueprint + calctool + swarm → 检测本机已装 IDE → 分发到每个 IDE。
|
|
89
|
-
更新:同一命令(`@latest` 自动拉新版),且每次 install 会对比 cli.tax 最新版本并提示 ⤴。
|
|
90
|
-
|
|
91
|
-
### 方式 B:Git 仓库
|
|
92
|
-
```bash
|
|
93
|
-
git clone https://github.com/88208555/Blueprint-clitax.git
|
|
94
|
-
cd Blueprint-clitax
|
|
95
|
-
node install.mjs install
|
|
96
|
-
```
|
|
97
|
-
更新:`git pull && node install.mjs update`(install/update 会对比已装版本与 cli.tax 最新版本并提示)。
|
|
98
|
-
|
|
99
|
-
### 更新感知(自动升级 + check)
|
|
100
|
-
|
|
101
|
-
**自动升级**:每次发布新版本到 npm / cli.tax 后,已安装用户只需重跑一次安装命令,
|
|
102
|
-
安装器会自动对比本地已装版本与远端最新版本,**有新版本直接覆盖升级到最新**(无需先卸载):
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
npx cli-blueprint@latest install # 自动拉取最新并覆盖升级(blueprint/calctool/swarm)
|
|
106
|
-
node install.mjs install # 源码方式同理
|
|
107
|
-
```
|
|
108
|
-
升级时输出 `⤴ 已更新 <skill> 旧版本 → 新版本`。
|
|
109
|
-
|
|
110
|
-
**静默自动更新(--silent / --yes)**:不想看到任何安装/升级输出,直接覆盖到最新:
|
|
111
|
-
```bash
|
|
112
|
-
npx cli-blueprint@latest install --silent # 静默升级,无任何提示
|
|
113
|
-
node install.mjs install --yes # 源码方式静默升级
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
**主动检查(check)**:不确定是否有新版本时,可随时主动检查(不写盘):
|
|
117
|
-
```bash
|
|
118
|
-
node install.mjs check # 遍历本机已装 IDE,对比 cli.tax 最新版本
|
|
119
|
-
npx cli-blueprint@latest check # 单包检查(calctool / swarm 同理)
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
安装器写入 `install-meta.json`(来源/版本/时间)到每个 skill 目录;SKILL.md 注入版本横幅,
|
|
123
|
-
IDE 每次读取即可见当前版本与更新命令。
|
|
124
|
-
|
|
125
|
-
### 方式 C:直接用 clitaxio(只装单个 IDE,作为对照)
|
|
126
|
-
```bash
|
|
127
|
-
npx clitaxio@latest install wvz6zmRWmX
|
|
128
|
-
```
|
|
129
|
-
> ⚠️ 注意:clitaxio **只把 skill 装到默认的 Codex 目录**(单一 IDE),不会自动检测/分发到
|
|
130
|
-
> 其他 IDE,也不处理 `~/.agents/skills` 共享根重复问题。需要多 IDE 分发请用方式 A/B。
|
|
131
|
-
|
|
132
|
-
## 目录结构
|
|
133
|
-
|
|
134
|
-
```
|
|
135
|
-
cli-blueprint/
|
|
136
|
-
├── install.mjs # 安装器(Node ≥18,零依赖):pull / install / uninstall / list / ides
|
|
137
|
-
├── sources.json # ★ cli.tax skill 源清单(code → 自动拉取),扩展就加一行
|
|
138
|
-
├── package.json # npm 包元数据(cli-blueprint)
|
|
139
|
-
├── README.md
|
|
140
|
-
└── skills/ # skill 内容(pull 生成,可提交 git 离线兜底)
|
|
141
|
-
└── blueprint/
|
|
142
|
-
├── SKILL.md
|
|
143
|
-
└── skill.json
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## 无限扩展(加新 skill 两种方式)
|
|
147
|
-
|
|
148
|
-
**方式 A:从 cli.tax 拉取**(推荐)——`sources.json` 加一行:
|
|
149
|
-
```json
|
|
150
|
-
{ "cliTax": [
|
|
151
|
-
{ "code": "wvz6zmRWmX", "slug": "blueprint", "endpoint": "https://cli.tax/api/public/skills/{code}" },
|
|
152
|
-
{ "code": "你的新code", "slug": "新skill名", "endpoint": "https://cli.tax/api/public/skills/{code}" }
|
|
153
|
-
] }
|
|
154
|
-
```
|
|
155
|
-
然后 `node install.mjs pull` → 自动下载到 skills/。
|
|
156
|
-
|
|
157
|
-
**方式 B:本地手工写**——直接建 `skills/my-new-skill/SKILL.md`(frontmatter: `name` kebab-case + `description`)。
|
|
158
|
-
|
|
159
|
-
两种方式后都只需 `node install.mjs update` 同步到本机所有已装 IDE。
|
|
160
|
-
|
|
161
|
-
## 常见问题
|
|
162
|
-
|
|
163
|
-
- **装完当前会话没立刻出现?** skill 目录在会话初始化时注入,新会话即可发现;文件系统 watcher 也会自动感知变更。
|
|
164
|
-
- **Codex 里出现了 2 个同一个 skill?** 常见原因是同时存在 `~/.codex/skills/<name>` 和 `~/.agents/skills/<name>`(或 config.toml 注册条目)。本安装器默认不会装到 `~/.agents/skills`,避免此问题;如已发生,删除 `~/.agents/skills/<name>` 并清理 config.toml 中的 `[[skills.config]]` 条目即可。
|
|
165
|
-
- **想改 skill 内容?** 直接改 `skills/<name>/SKILL.md` 再 `update`,幂等覆盖。
|
|
166
|
-
- **命名要求?** 目录名即 skill 名,必须 kebab-case(如 `my-new-skill`)。
|
|
13
|
+
`calctool.skill.request/1.0` 协议,端点 `https://cli.tax/KKyA6xljUX`,
|
|
14
|
+
操作:capabilities / help / intake / validate / compile-inline(确定性引擎定义生成)。
|
package/cli.mjs
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { copyFile, mkdir, writeFile } from 'node:fs/promises'
|
|
3
|
+
import { createInterface } from 'node:readline/promises'
|
|
4
|
+
import { stdin, stdout } from 'node:process'
|
|
5
|
+
import { dirname, join, resolve } from 'node:path'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
8
|
+
|
|
9
|
+
const ENDPOINT = 'https://cli.tax/KKyA6xljUX'
|
|
10
|
+
const SCHEMA_VERSION = 'calctool.skill.request/1.0'
|
|
11
|
+
const PACKAGE_SKILL_DIR = join(dirname(fileURLToPath(import.meta.url)), 'skill')
|
|
12
|
+
const INSTALL_META = 'install-meta.json'
|
|
13
|
+
const LATEST_ENDPOINT = 'https://cli.tax/api/public/skills/KKyA6xljUX'
|
|
14
|
+
|
|
15
|
+
const INTAKE_QUESTIONS = [
|
|
16
|
+
{
|
|
17
|
+
id: 'goal',
|
|
18
|
+
prompt: 'Describe what the tool must let users do: which domain, what inputs, what outputs. What must never happen?',
|
|
19
|
+
required: true,
|
|
20
|
+
example: '财务经营健康诊断:输入利润表 50 个字段,输出十大指标评分与健康报告;绝不虚构后端数据。',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'inputs',
|
|
24
|
+
prompt: 'List the user-entered fields (name, type, unit). Include any custom indicators the user wants to define.',
|
|
25
|
+
required: true,
|
|
26
|
+
example: '收入(money,CNY)、货品成本(money,CNY)、正式员工数(integer,人);用户可自定义指标。',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'formulas',
|
|
30
|
+
prompt: 'Describe the calculation logic: which derived metrics, formulas, scoring rules, or grading thresholds.',
|
|
31
|
+
required: true,
|
|
32
|
+
example: '运营毛利 = 收入 - 货品成本;健康分 = Σ(指标分×权重),权重 30%/17%/15%/…;除零回退 0。',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'input-method',
|
|
36
|
+
prompt: 'How do users get data in: manual entry, Excel upload, image/PDF OCR, or a combination?',
|
|
37
|
+
required: false,
|
|
38
|
+
example: 'Excel 上传 + 手工录入;Excel 原生解析,截图走 OCR 草稿确认。',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'output',
|
|
42
|
+
prompt: 'What output forms are needed: metric cards, tables, diagnostic report, history, export?',
|
|
43
|
+
required: false,
|
|
44
|
+
example: '指标卡 + 诊断报告(HTML) + 历史记录。',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'constraints',
|
|
48
|
+
prompt: 'State hard constraints: precision/rounding, language, offline/online, storage, forbidden behaviors.',
|
|
49
|
+
required: false,
|
|
50
|
+
example: '金额保留 2 位小数;中文界面;无账号也可用;禁止执行任意 JavaScript。',
|
|
51
|
+
},
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
function usage() {
|
|
55
|
+
return [
|
|
56
|
+
'clitax-KKyA6xljUX — install and run the calctool skill from CLI.Tax',
|
|
57
|
+
'',
|
|
58
|
+
'Usage:',
|
|
59
|
+
' npx <package-url> install [directory]',
|
|
60
|
+
' Install the calctool skill for the current IDE (Codex skills directory by default).',
|
|
61
|
+
' If an older version is already installed, it reports and upgrades it.',
|
|
62
|
+
' npx <package-url> check [directory]',
|
|
63
|
+
' Check whether the installed skill has a newer version on cli.tax.',
|
|
64
|
+
' npx <package-url> run',
|
|
65
|
+
' Run the skill handshake: discover capabilities, answer the intake questions,',
|
|
66
|
+
' and save CALCTOOL-REQUIREMENTS.json for the IDE agent.',
|
|
67
|
+
'',
|
|
68
|
+
`Endpoint: ${ENDPOINT}`,
|
|
69
|
+
].join('\n')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** 读取已安装目录的版本元数据 */
|
|
73
|
+
function readMeta(dir) {
|
|
74
|
+
const p = join(dir, INSTALL_META)
|
|
75
|
+
if (!existsSync(p)) return null
|
|
76
|
+
try { return JSON.parse(readFileSync(p, 'utf8')) } catch { return null }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** 查询 cli.tax 最新版本(GET /api/public/skills/{code}) */
|
|
80
|
+
async function fetchLatestVersion() {
|
|
81
|
+
try {
|
|
82
|
+
const resp = await fetch(LATEST_ENDPOINT)
|
|
83
|
+
if (!resp.ok) return null
|
|
84
|
+
const data = await resp.json()
|
|
85
|
+
return { version: data.version ?? '', displayName: data.displayName ?? 'calctool' }
|
|
86
|
+
} catch {
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function postRequest(operation, requestId) {
|
|
92
|
+
const response = await fetch(ENDPOINT, {
|
|
93
|
+
method: 'POST',
|
|
94
|
+
headers: { 'Content-Type': 'application/json' },
|
|
95
|
+
body: JSON.stringify({
|
|
96
|
+
input: {
|
|
97
|
+
schemaVersion: SCHEMA_VERSION,
|
|
98
|
+
requestId,
|
|
99
|
+
operation,
|
|
100
|
+
input: {},
|
|
101
|
+
},
|
|
102
|
+
}),
|
|
103
|
+
})
|
|
104
|
+
let payload
|
|
105
|
+
try {
|
|
106
|
+
payload = await response.json()
|
|
107
|
+
} catch {
|
|
108
|
+
throw new Error(`calctool ${operation} failed: the runtime host returned a non-JSON response (HTTP ${response.status}). Check that the CLI runtime is deployed on ${ENDPOINT}.`)
|
|
109
|
+
}
|
|
110
|
+
if (!response.ok || payload?.ok !== true) {
|
|
111
|
+
const message = payload?.error?.message ?? payload?.error ?? `HTTP ${response.status}`
|
|
112
|
+
throw new Error(`calctool ${operation} failed: ${message}`)
|
|
113
|
+
}
|
|
114
|
+
return payload
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function installTarget(explicit) {
|
|
118
|
+
if (explicit) return resolve(explicit)
|
|
119
|
+
const codexHome = process.env.CODEX_HOME?.trim()
|
|
120
|
+
if (codexHome) return join(codexHome, 'skills', 'calctool')
|
|
121
|
+
const projectCodex = join(process.cwd(), '.codex', 'skills', 'calctool')
|
|
122
|
+
return projectCodex
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function install(explicit) {
|
|
126
|
+
const target = installTarget(explicit)
|
|
127
|
+
await mkdir(target, { recursive: true })
|
|
128
|
+
const previous = readMeta(target)
|
|
129
|
+
await copyFile(join(PACKAGE_SKILL_DIR, 'SKILL.md'), join(target, 'SKILL.md'))
|
|
130
|
+
await copyFile(join(PACKAGE_SKILL_DIR, 'skill.json'), join(target, 'skill.json'))
|
|
131
|
+
const localVersion = process.env.npm_package_version ?? ''
|
|
132
|
+
const latest = await fetchLatestVersion()
|
|
133
|
+
await writeFile(join(target, INSTALL_META), `${JSON.stringify({
|
|
134
|
+
source: 'KKyA6xljUX',
|
|
135
|
+
slug: 'calctool',
|
|
136
|
+
version: latest?.version ?? '',
|
|
137
|
+
packageVersion: localVersion,
|
|
138
|
+
endpoint: ENDPOINT,
|
|
139
|
+
installedAt: new Date().toISOString(),
|
|
140
|
+
}, null, 2)}\n`)
|
|
141
|
+
if (previous?.version && latest?.version && previous.version !== latest.version) {
|
|
142
|
+
console.log(`calctool skill updated: ${target}`)
|
|
143
|
+
console.log(` ⤴ ${previous.version} → ${latest.version}`)
|
|
144
|
+
} else {
|
|
145
|
+
console.log(`calctool skill installed: ${target}${latest?.version ? ` (${latest.version})` : ''}`)
|
|
146
|
+
}
|
|
147
|
+
if (latest?.version) {
|
|
148
|
+
console.log(`Latest version on cli.tax: ${latest.version}`)
|
|
149
|
+
}
|
|
150
|
+
console.log('Next: return to your IDE conversation and describe the calculator tool you want.')
|
|
151
|
+
console.log('The IDE agent reads the installed SKILL.md, asks you the intake questions,')
|
|
152
|
+
console.log('and then calls the calctool protocol to generate and validate the engine definition.')
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function check(explicit) {
|
|
156
|
+
const target = installTarget(explicit)
|
|
157
|
+
const local = readMeta(target)
|
|
158
|
+
const latest = await fetchLatestVersion()
|
|
159
|
+
if (!latest) {
|
|
160
|
+
console.log('calctool: cannot reach cli.tax to check updates.')
|
|
161
|
+
process.exitCode = 1
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
if (!local?.version) {
|
|
165
|
+
console.log(`calctool: no version record in ${target} (installed before update tracking).`)
|
|
166
|
+
console.log(`Latest on cli.tax: ${latest.version}. Run install to record and refresh.`)
|
|
167
|
+
process.exitCode = 1
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
if (local.version === latest.version) {
|
|
171
|
+
console.log(`calctool is up to date (${latest.version}) at ${target}`)
|
|
172
|
+
} else {
|
|
173
|
+
console.log(`calctool update available: ${local.version} → ${latest.version} at ${target}`)
|
|
174
|
+
console.log('Run: npx cli-calctool@latest install')
|
|
175
|
+
process.exitCode = 1
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function askOne(question, readline) {
|
|
180
|
+
const requiredMark = question.required ? ' (required)' : ''
|
|
181
|
+
console.log(`\n${question.prompt}${requiredMark}`)
|
|
182
|
+
console.log(`Example: ${question.example}`)
|
|
183
|
+
for (;;) {
|
|
184
|
+
const answer = (await readline.question('> ')).trim()
|
|
185
|
+
if (answer || !question.required) return answer || ''
|
|
186
|
+
console.log('This question is required. Please answer before continuing.')
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async function run() {
|
|
191
|
+
const capabilities = await postRequest('capabilities', 'cli-1')
|
|
192
|
+
const skill = capabilities.output?.skill ?? {}
|
|
193
|
+
const nextStep = capabilities.output?.nextStep ?? {}
|
|
194
|
+
console.log(`calctool ${skill.version ?? ''} — ${skill.description ?? 'generate online calculator tools'}`)
|
|
195
|
+
if (nextStep.instruction) console.log(nextStep.instruction)
|
|
196
|
+
|
|
197
|
+
const readline = createInterface({ input: stdin, output: stdout })
|
|
198
|
+
const answers = []
|
|
199
|
+
try {
|
|
200
|
+
for (const question of INTAKE_QUESTIONS) {
|
|
201
|
+
answers.push({ id: question.id, prompt: question.prompt, answer: await askOne(question, readline) })
|
|
202
|
+
}
|
|
203
|
+
} finally {
|
|
204
|
+
readline.close()
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const requirements = {
|
|
208
|
+
schemaVersion: SCHEMA_VERSION,
|
|
209
|
+
endpoint: ENDPOINT,
|
|
210
|
+
createdAt: new Date().toISOString(),
|
|
211
|
+
answers,
|
|
212
|
+
}
|
|
213
|
+
const target = join(process.cwd(), 'CALCTOOL-REQUIREMENTS.json')
|
|
214
|
+
await writeFile(target, `${JSON.stringify(requirements, null, 2)}\n`)
|
|
215
|
+
console.log(`\nRequirements saved: ${target}`)
|
|
216
|
+
console.log('Next: continue in your IDE agent with this file.')
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const command = process.argv[2] ?? 'help'
|
|
220
|
+
const argument = process.argv[3] ?? ''
|
|
221
|
+
try {
|
|
222
|
+
if (command === 'install') {
|
|
223
|
+
await install(argument)
|
|
224
|
+
} else if (command === 'check') {
|
|
225
|
+
await check(argument)
|
|
226
|
+
} else if (command === 'run') {
|
|
227
|
+
await run()
|
|
228
|
+
} else if (command === '--help' || command === '-h' || command === 'help') {
|
|
229
|
+
console.log(usage())
|
|
230
|
+
} else {
|
|
231
|
+
console.error(`Unknown command: ${command}\n`)
|
|
232
|
+
console.log(usage())
|
|
233
|
+
process.exitCode = 1
|
|
234
|
+
}
|
|
235
|
+
} catch (error) {
|
|
236
|
+
console.error(error instanceof Error ? error.message : error)
|
|
237
|
+
process.exitCode = 1
|
|
238
|
+
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cli-calctool",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Calctool
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Calctool skill installer for CLI.Tax: generate a runnable online calculator from a domain need.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"cli-calctool": "
|
|
7
|
+
"cli-calctool": "./cli.mjs"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
10
|
+
"cli.mjs",
|
|
11
|
+
"README.md",
|
|
12
|
+
"skill/SKILL.md",
|
|
13
|
+
"skill/skill.json"
|
|
13
14
|
],
|
|
14
15
|
"engines": {
|
|
15
16
|
"node": ">=18"
|
|
16
17
|
},
|
|
17
|
-
"license": "
|
|
18
|
+
"license": "UNLICENSED",
|
|
18
19
|
"keywords": [
|
|
19
|
-
"blueprint",
|
|
20
|
-
"skill",
|
|
21
20
|
"cli.tax",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"agent"
|
|
25
|
-
"installer"
|
|
21
|
+
"skill",
|
|
22
|
+
"installer",
|
|
23
|
+
"agent"
|
|
26
24
|
]
|
|
27
|
-
}
|
|
25
|
+
}
|
|
@@ -51,6 +51,10 @@ description: '按需生成「万能计算工具」:用户输入一个领域需
|
|
|
51
51
|
|
|
52
52
|
不要用于:纯展示型页面(无计算)、与计算无关的 CRUD 后台。
|
|
53
53
|
|
|
54
|
+
## Official catalog hops
|
|
55
|
+
|
|
56
|
+
After `capabilities`, read `officialCatalog`. Default allowlist is official skills. Call another skill only when its capability matches this demand. User-named extras enter only when the user names them; then confirm that skill's capabilities before invoke. Do not call chain-unrelated or self-extended skills.
|
|
57
|
+
|
|
54
58
|
## 核心原则
|
|
55
59
|
|
|
56
60
|
1. **确定性计算**:正式数字由版本化确定性引擎(公式 AST + Decimal 运行时)产生;模型/OCR/AI 只产生候选、草稿与解释,绝不直接给出不可追溯的正式结果。
|
|
@@ -139,6 +143,11 @@ defaultLocale: zh-CN
|
|
|
139
143
|
- **用户控制**:每一步产物可查看、修改、重试(budget.maxAttempts);最终工具可测算、改公式、调阈值
|
|
140
144
|
- **编程能力**:蜂群产物是真实可编译的引擎定义(JSON AST + Decimal 运行时),不是伪代码
|
|
141
145
|
|
|
146
|
+
### Blueprint 协同(可选)
|
|
147
|
+
`brain-handshake` 时可选择 `blueprintEnabled`:生成引擎定义后,先交给 Blueprint 技能规划工具开发蓝图
|
|
148
|
+
(`blueprint-orchestrate` → `https://cli.tax/wvz6zmRWmX`,operation `compile-inline`),
|
|
149
|
+
再回到蜂群执行开发任务,验收标准全部可追溯。不开启时直接蜂群生成,全程框架一致。
|
|
150
|
+
|
|
142
151
|
## 输出产物
|
|
143
152
|
|
|
144
153
|
```
|
|
@@ -160,11 +169,6 @@ defaultLocale: zh-CN
|
|
|
160
169
|
- `references/import-ocr.md` —— 导入与 OCR(Excel 映射/图片识别/草稿确认)
|
|
161
170
|
- `references/finance-example.md` —— 经营健康诊断完整范例(50 字段 → 10 指标 → 报告)
|
|
162
171
|
|
|
163
|
-
### Blueprint 协同(可选)
|
|
164
|
-
`brain-handshake` 时可选择 `blueprintEnabled`:生成引擎定义后,先交给 Blueprint 技能规划工具开发蓝图
|
|
165
|
-
(`blueprint-orchestrate` → `https://cli.tax/wvz6zmRWmX`,operation `compile-inline`),
|
|
166
|
-
再回到蜂群执行开发任务,验收标准全部可追溯。不开启时直接蜂群生成,全程框架一致。
|
|
167
|
-
|
|
168
172
|
## 安全规则
|
|
169
173
|
|
|
170
174
|
- 不执行任意 JavaScript;公式只走受控 AST
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "calctool",
|
|
3
3
|
"displayName": "Calctool",
|
|
4
4
|
"description": "按需生成「万能计算工具」:输入领域需求(如财务经营健康诊断),通过提问明确指标/公式/输入方式,生成可执行、可验证、可发布的在线计算工具——支持自定义指标、自定义公式、上传内容自动识别(Excel/OCR)、报告输出。",
|
|
5
|
-
"schemaVersion": "
|
|
5
|
+
"schemaVersion": "calctool.skill.request/1.0",
|
|
6
6
|
"endpoint": "https://cli.tax/KKyA6xljUX",
|
|
7
7
|
"method": "POST",
|
|
8
|
-
"version": "
|
|
8
|
+
"version": "v1.0.2",
|
|
9
9
|
"type": "Skill"
|
|
10
10
|
}
|