@blod-nm/1kuan-act-01-cli 0.1.2 → 0.1.3
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/package.json +1 -1
- package/src/main.js +11 -5
- package/src/mcp.js +2 -1
- package/src/redpacket.js +5 -5
- package/src/skill.js +6 -4
- package/src/version.js +6 -0
package/package.json
CHANGED
package/src/main.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { parseArgs } from 'node:util'
|
|
6
|
+
import { VERSION } from './version.js'
|
|
6
7
|
import { join } from 'node:path'
|
|
7
8
|
import { configPath, expandPath, loadConfig, saveConfig, decodeConfigString, encryptConfig } from './store.js'
|
|
8
9
|
import { ACCOUNT_SQL, execPgsql, resolveApikey, gatewayBase } from './tcb.js'
|
|
@@ -10,7 +11,6 @@ import { buildCreateSql, confirmSummary, normalizeCreateRedpacket } from './redp
|
|
|
10
11
|
import { SKILL_MD, SKILL_NAME } from './skill.js'
|
|
11
12
|
import { startMcp } from './mcp.js'
|
|
12
13
|
|
|
13
|
-
const VERSION = '0.1.0'
|
|
14
14
|
|
|
15
15
|
const USAGE = `act-01 —— operations CLI(invoke preset database functions)
|
|
16
16
|
|
|
@@ -22,7 +22,7 @@ const USAGE = `act-01 —— operations CLI(invoke preset database functions)
|
|
|
22
22
|
config set apiKey 写入 API Key(值走 stdin;不放命令行)
|
|
23
23
|
config test 连接测试(SELECT 1,验证 envId/apiKey)
|
|
24
24
|
config export 导出加密配置串(口令交互输入或 ACT01_EXPORT_PASS)
|
|
25
|
-
config import <串|--stdin>
|
|
25
|
+
config import <串|--stdin> [--pass <口令>] 导入配置串(加密串需口令;自动识别 三种格式)
|
|
26
26
|
mcp 启动 MCP 服务(stdio;接入 Claude 等 AI 客户端)
|
|
27
27
|
skill 输出 agent 技能文档(--install <dir> 写入)
|
|
28
28
|
balance account balance
|
|
@@ -183,7 +183,13 @@ async function cmdConfig(argv) {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
if (sub === 'import') {
|
|
186
|
-
|
|
186
|
+
const { values: importValues, positionals: importPositionals } = parseArgs({
|
|
187
|
+
strict: false,
|
|
188
|
+
allowPositionals: true,
|
|
189
|
+
args: argv,
|
|
190
|
+
options: { pass: { type: 'string' }, json: { type: 'boolean', short: 'j' } },
|
|
191
|
+
})
|
|
192
|
+
let body = importPositionals[1]
|
|
187
193
|
if (!body && !process.stdin.isTTY) body = await readStdinText()
|
|
188
194
|
if (!body) {
|
|
189
195
|
const err = new Error('config import 需要 <配置串>(位置参数或 stdin)')
|
|
@@ -193,10 +199,10 @@ async function cmdConfig(argv) {
|
|
|
193
199
|
const decoded = decodeConfigString(body)
|
|
194
200
|
let cfg = decoded.config
|
|
195
201
|
if (decoded.encrypted) {
|
|
196
|
-
let passphrase = process.env.ACT01_EXPORT_PASS
|
|
202
|
+
let passphrase = str(importValues, 'pass') ?? process.env.ACT01_EXPORT_PASS
|
|
197
203
|
if (!passphrase) {
|
|
198
204
|
if (!process.stdin.isTTY) {
|
|
199
|
-
const err = new Error('
|
|
205
|
+
const err = new Error('加密串需要口令:用 --pass <口令> 或 ACT01_EXPORT_PASS 传入')
|
|
200
206
|
err.exitCode = 2
|
|
201
207
|
throw err
|
|
202
208
|
}
|
package/src/mcp.js
CHANGED
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
* 纪律: MCP 模式下 stdout 只输出 JSON-RPC 报文,任何日志走 stderr。
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
import { VERSION } from './version.js'
|
|
14
15
|
import { loadConfig } from './store.js'
|
|
15
16
|
import { resolveApikey, execPgsql, gatewayBase } from './tcb.js'
|
|
16
17
|
import { normalizeCreateRedpacket, buildCreateSql } from './redpacket.js'
|
|
17
18
|
|
|
18
|
-
const SERVER_INFO = { name: 'act-01', version:
|
|
19
|
+
const SERVER_INFO = { name: 'act-01', version: VERSION }
|
|
19
20
|
const SUPPORTED = ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05', '2024-10-07']
|
|
20
21
|
const LATEST = '2025-11-25'
|
|
21
22
|
|
package/src/redpacket.js
CHANGED
|
@@ -23,14 +23,14 @@ function optionalText(value, label, maxLen) {
|
|
|
23
23
|
export function normalizeCreateRedpacket(body) {
|
|
24
24
|
const mode = String(body.mode ?? '')
|
|
25
25
|
if (mode !== 'random' && mode !== 'equal')
|
|
26
|
-
throw new ValidationError('
|
|
26
|
+
throw new ValidationError('红包类型必须是 random 或 equal')
|
|
27
27
|
|
|
28
28
|
const totalPoints = positiveInteger(body.total_points, '总金额')
|
|
29
29
|
const count = positiveInteger(body.count, '份数')
|
|
30
30
|
const perUserLimit = positiveInteger(body.per_user_limit, '每人领取次数')
|
|
31
|
-
if (perUserLimit > count) throw new ValidationError('
|
|
31
|
+
if (perUserLimit > count) throw new ValidationError('每人领取次数不能超过份数')
|
|
32
32
|
if (mode === 'equal' && totalPoints < count)
|
|
33
|
-
throw new ValidationError('
|
|
33
|
+
throw new ValidationError('均分总额不能小于份数')
|
|
34
34
|
|
|
35
35
|
const shareTitle = optionalText(body.share_title, '分享标题', 60)
|
|
36
36
|
const shareCover = optionalText(body.share_cover, '分享封面', 500)
|
|
@@ -58,9 +58,9 @@ export function normalizeCreateRedpacket(body) {
|
|
|
58
58
|
const maxPoints = positiveInteger(body.max_points, '单份最大金额')
|
|
59
59
|
if (maxPoints < minPoints) throw new ValidationError('单份最大金额不能小于最小金额')
|
|
60
60
|
if (totalPoints < minPoints * count || totalPoints > maxPoints * count)
|
|
61
|
-
throw new ValidationError('
|
|
61
|
+
throw new ValidationError('总额不在可分配区间内(需介于 单份最小×份数 ~ 单份最大×份数)')
|
|
62
62
|
if (totalPoints % count !== 0)
|
|
63
|
-
throw new ValidationError('
|
|
63
|
+
throw new ValidationError('总额需能被份数整除(random 模式)')
|
|
64
64
|
|
|
65
65
|
return { mode, totalPoints, count, perUserLimit, minPoints, maxPoints, shareTitle, shareCover, note, requireGroup }
|
|
66
66
|
}
|
package/src/skill.js
CHANGED
|
@@ -61,12 +61,14 @@ const BODY = [
|
|
|
61
61
|
'',
|
|
62
62
|
'## 失败速查',
|
|
63
63
|
'',
|
|
64
|
-
'|
|
|
64
|
+
'| 错误里含 | 含义 | 修正 |',
|
|
65
65
|
'|---|---|---|',
|
|
66
|
-
'|
|
|
67
|
-
'| 整除 | total % count ≠ 0(random) | 调整 total 或 count |',
|
|
66
|
+
'| 必须是正整数 | 参数 ≤0 或非整数 | 传正整数(内部积分单位,不换算) |',
|
|
68
67
|
'| 不能超过份数 | per_user_limit > count | 降低 per_user_limit |',
|
|
69
|
-
'|
|
|
68
|
+
'| 不能小于份数 | equal 模式 total < count | 提高 total |',
|
|
69
|
+
'| 可分配区间 | total 不在 min×count ~ max×count | 调 min/max 或 total |',
|
|
70
|
+
'| 整除 | random 模式 total % count ≠ 0 | 调 total 或 count |',
|
|
71
|
+
'| 无法识别的配置串 | 配置串前缀/内容不对 | 用配套网页重新生成配置串 |',
|
|
70
72
|
'| 余额不足 / insufficient | 账户余额 < total | 先充值或调低 total |',
|
|
71
73
|
'',
|
|
72
74
|
'## 配置前置',
|