@jojonadam/dsh-mriter 0.1.0 → 0.2.0
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 +4 -1
- package/bin/darwin-arm64/mriter +0 -0
- package/index.js +47 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
## 安装
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
#
|
|
17
|
+
# 已发布到 npm(0.1.0,内置 darwin-arm64 二进制)
|
|
18
|
+
dsh plugin --profile desktop add @jojonadam/dsh-mriter
|
|
19
|
+
|
|
20
|
+
# 或装本地 checkout
|
|
18
21
|
dsh plugin --profile desktop add ./packaging/dsh-plugin
|
|
19
22
|
|
|
20
23
|
# 桌面版没有暴露 dsh CLI 时(本机实测路径)
|
package/bin/darwin-arm64/mriter
CHANGED
|
Binary file
|
package/index.js
CHANGED
|
@@ -123,12 +123,58 @@ const tool = {
|
|
|
123
123
|
},
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
+
const progressionTool = {
|
|
127
|
+
name: "mriter_progression",
|
|
128
|
+
description:
|
|
129
|
+
"查一条和弦走向在 1029 首中文流行语料里的稀有度。支持罗马级数(vi IV V I)、数字简谱(6451)、" +
|
|
130
|
+
"和弦符号(C Am F G,需 key)。返回每千窗频次与分位;不足 4 个和弦时返回 measurable=false," +
|
|
131
|
+
"**0‰ 要读成「测不了」,不是「罕见」**。",
|
|
132
|
+
parameters: {
|
|
133
|
+
type: "object",
|
|
134
|
+
properties: {
|
|
135
|
+
chords: { type: "string", description: "和弦或级数序列,如 'vi IV V I'、'6451'、'C Am F G'" },
|
|
136
|
+
key: { type: "string", description: "调式主音,和弦符号写法时需要,默认 C" },
|
|
137
|
+
},
|
|
138
|
+
required: ["chords"],
|
|
139
|
+
},
|
|
140
|
+
output: {
|
|
141
|
+
schema: { type: "object", additionalProperties: true,
|
|
142
|
+
properties: { text: { type: "string" } }, required: ["text"] },
|
|
143
|
+
render: (_args, value) => [{ type: "text", text: String((value && value.text) || "") }],
|
|
144
|
+
},
|
|
145
|
+
async execute(args) {
|
|
146
|
+
const engine = resolveEngine();
|
|
147
|
+
if (!engine) return { text: "找不到 Mriter 引擎(设 MRITER_BIN 或 MRITER_HOME)" };
|
|
148
|
+
const argv = [...engine.base, "--progression", String(args.chords || ""), "--key", args.key || "C"];
|
|
149
|
+
const r = await run(engine.cmd, argv, engine.cwd ? { cwd: engine.cwd } : {});
|
|
150
|
+
const raw = (r.stdout || "").trim();
|
|
151
|
+
if (!raw) return { text: `查询失败(退出码 ${r.code}):${r.stderr || ""}`.trim(), exitCode: r.code };
|
|
152
|
+
try {
|
|
153
|
+
const j = JSON.parse(raw.split("\n").pop());
|
|
154
|
+
if (j.ok === false) return { text: `解析不出:${j.why || ""}`, exitCode: 2 };
|
|
155
|
+
if (j.measurable === false) {
|
|
156
|
+
return { text: `${j.readable}:${j.why}`, exitCode: 0, measurable: false };
|
|
157
|
+
}
|
|
158
|
+
const pct = j.rank_pct === null ? "" : `,分位 ${j.rank_pct}%`;
|
|
159
|
+
return {
|
|
160
|
+
text: `${j.readable}\n每千窗 ${j.per_1000}‰${pct}\n命中 ${j.hits} 次 / ${j.windows} 个窗口`,
|
|
161
|
+
exitCode: 0, measurable: true, per_1000: j.per_1000,
|
|
162
|
+
};
|
|
163
|
+
} catch {
|
|
164
|
+
return { text: raw, exitCode: 0 };
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
126
169
|
function apply(ctx) {
|
|
127
170
|
const tools = ctx.get("tools");
|
|
128
171
|
if (tools === undefined) throw new Error("dsh-mriter 需要 tools 服务");
|
|
129
172
|
if (tools.get(tool.name) === undefined) {
|
|
130
173
|
ctx.effect(() => tools.register(tool));
|
|
131
174
|
}
|
|
175
|
+
if (tools.get(progressionTool.name) === undefined) {
|
|
176
|
+
ctx.effect(() => tools.register(progressionTool));
|
|
177
|
+
}
|
|
132
178
|
}
|
|
133
179
|
|
|
134
|
-
export { apply, inject, name, tool, advice, resolveEngine };
|
|
180
|
+
export { apply, inject, name, tool, progressionTool, advice, resolveEngine };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jojonadam/dsh-mriter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"patch": "./cordis.patch.yml"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"description": "Mriter for DSH
|
|
17
|
+
"description": "Mriter for DSH:歌词诊断 + 和弦走向稀有度(1029 首中文流行语料)。本地引擎,零网络请求。",
|
|
18
18
|
"keywords": [
|
|
19
19
|
"dsh",
|
|
20
20
|
"dsh-plugin",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
"homepage": "https://mriter.com",
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "git+https://github.com/JOJO-Adam/
|
|
33
|
+
"url": "git+https://github.com/JOJO-Adam/dsh-mriter.git"
|
|
34
34
|
}
|
|
35
35
|
}
|