@wenaixi/dsh-ponytail 5.0.0 → 5.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/CHANGELOG.md +140 -226
- package/README.md +102 -98
- package/lib/client.js +303 -140
- package/lib/ponytail-config.d.ts +47 -21
- package/lib/ponytail-config.d.ts.map +1 -1
- package/lib/ponytail-config.js +42 -36
- package/lib/ponytail-config.js.map +1 -1
- package/lib/ponytail-instructions.d.ts.map +1 -1
- package/lib/ponytail-instructions.js +31 -31
- package/lib/ponytail-instructions.js.map +1 -1
- package/lib/ponytail-priority.d.ts +10 -8
- package/lib/ponytail-priority.d.ts.map +1 -1
- package/lib/ponytail-priority.js +12 -11
- package/lib/ponytail-priority.js.map +1 -1
- package/lib/ponytail-remote.d.ts +65 -0
- package/lib/ponytail-remote.d.ts.map +1 -0
- package/lib/ponytail-remote.js +141 -0
- package/lib/ponytail-remote.js.map +1 -0
- package/lib/ponytail-settings.d.ts +96 -0
- package/lib/ponytail-settings.d.ts.map +1 -0
- package/lib/ponytail-settings.js +165 -0
- package/lib/ponytail-settings.js.map +1 -0
- package/lib/ponytail-skills.d.ts +10 -0
- package/lib/ponytail-skills.d.ts.map +1 -1
- package/lib/ponytail-skills.js +23 -5
- package/lib/ponytail-skills.js.map +1 -1
- package/lib/ponytail-state.d.ts +8 -4
- package/lib/ponytail-state.d.ts.map +1 -1
- package/lib/ponytail-state.js +40 -39
- package/lib/ponytail-state.js.map +1 -1
- package/lib/ponytail.d.ts +28 -4
- package/lib/ponytail.d.ts.map +1 -1
- package/lib/ponytail.js +181 -83
- package/lib/ponytail.js.map +1 -1
- package/locale/en.json +37 -27
- package/locale/zh.json +37 -27
- package/package.json +3 -1
- package/skills/descriptions.en.json +8 -0
- package/skills/descriptions.zh.json +8 -0
- package/skills/ponytail/SKILL.md +89 -46
- package/skills/ponytail-audit/SKILL.md +27 -17
- package/skills/ponytail-debt/SKILL.md +27 -14
- package/skills/ponytail-gain/SKILL.md +32 -19
- package/skills/ponytail-help/SKILL.md +53 -32
- package/skills/ponytail-review/SKILL.md +36 -24
- package/lib/ponytail-http.d.ts +0 -45
- package/lib/ponytail-http.d.ts.map +0 -1
- package/lib/ponytail-http.js +0 -162
- package/lib/ponytail-http.js.map +0 -1
|
@@ -1,58 +1,79 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ponytail-help
|
|
3
3
|
description: >
|
|
4
|
-
|
|
4
|
+
Quick-reference card for all ponytail modes, skills, and commands.
|
|
5
|
+
One-shot display, not a persistent mode. Trigger: /ponytail-help,
|
|
6
|
+
"ponytail help", "what ponytail commands", "how do I use ponytail".
|
|
5
7
|
---
|
|
6
8
|
|
|
7
|
-
# Ponytail Help
|
|
9
|
+
# Ponytail Help
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
Display this reference card when invoked. One-shot, do NOT change mode,
|
|
12
|
+
write flag files, or persist anything.
|
|
10
13
|
|
|
11
|
-
##
|
|
14
|
+
## Levels
|
|
12
15
|
|
|
13
|
-
|
|
|
14
|
-
|
|
15
|
-
| **Lite** | `/ponytail lite` |
|
|
16
|
-
| **Full** | `/ponytail` |
|
|
17
|
-
| **Ultra** | `/ponytail ultra` | YAGNI
|
|
16
|
+
| Level | Trigger | What change |
|
|
17
|
+
|-------|---------|-------------|
|
|
18
|
+
| **Lite** | `/ponytail lite` | Build what's asked, name the lazier alternative in one line. |
|
|
19
|
+
| **Full** | `/ponytail` | The ladder enforced: YAGNI → stdlib → native → one line → minimum. Default. |
|
|
20
|
+
| **Ultra** | `/ponytail ultra` | YAGNI extremist. Deletion before addition. Challenges requirements before building. |
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
Level sticks until changed or session end.
|
|
20
23
|
|
|
21
|
-
##
|
|
24
|
+
## Skills
|
|
22
25
|
|
|
23
|
-
|
|
|
24
|
-
|
|
25
|
-
| **ponytail** | `/ponytail` |
|
|
26
|
-
| **ponytail-review** | `/ponytail-review` |
|
|
27
|
-
| **ponytail-audit** | `/ponytail-audit` |
|
|
28
|
-
| **ponytail-debt** | `/ponytail-debt` |
|
|
29
|
-
| **ponytail-gain** | `/ponytail-gain` |
|
|
30
|
-
| **ponytail-help** | `/ponytail-help` |
|
|
26
|
+
| Skill | Trigger | What it does |
|
|
27
|
+
|-------|---------|--------------|
|
|
28
|
+
| **ponytail** | `/ponytail` | Lazy mode itself. Simplest solution that works. |
|
|
29
|
+
| **ponytail-review** | `/ponytail-review` | Over-engineering review: `L42: yagni: factory, one product. Inline.` |
|
|
30
|
+
| **ponytail-audit** | `/ponytail-audit` | Whole-repo over-engineering audit: ranked list of what to delete. |
|
|
31
|
+
| **ponytail-debt** | `/ponytail-debt` | Harvest `ponytail:` shortcut comments into a tracked ledger. |
|
|
32
|
+
| **ponytail-gain** | `/ponytail-gain` | Measured-impact scoreboard: less code, less cost, more speed. |
|
|
33
|
+
| **ponytail-help** | `/ponytail-help` | This card. |
|
|
31
34
|
|
|
35
|
+
Codex uses `@ponytail`, `@ponytail-review`, and `@ponytail-help`; Claude Code
|
|
36
|
+
and OpenCode use the slash-command forms above (OpenCode ships all six as
|
|
37
|
+
slash commands).
|
|
32
38
|
|
|
33
|
-
##
|
|
39
|
+
## Deactivate
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
`/ponytail off`
|
|
41
|
+
Say "stop ponytail" or "normal mode". Resume anytime with `/ponytail`.
|
|
42
|
+
`/ponytail off` also works.
|
|
37
43
|
|
|
38
|
-
##
|
|
44
|
+
## Configure Default Mode
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
Default mode = `full`, auto-active every session. Change it:
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
**Environment variable** (highest priority):
|
|
43
49
|
```bash
|
|
44
50
|
export PONYTAIL_DEFAULT_MODE=ultra
|
|
45
51
|
```
|
|
46
52
|
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
|
|
53
|
+
**Profile patch** (`profiles/<name>/cordis.patch.yml`, entry `- id: ponytail`):
|
|
54
|
+
```yaml
|
|
55
|
+
config:
|
|
56
|
+
defaultMode: lite
|
|
50
57
|
```
|
|
51
58
|
|
|
52
|
-
|
|
59
|
+
The plugin config card writes the patch for you; `/ponytail default <mode>`
|
|
60
|
+
does the same from a prompt. Set `"off"` to disable auto-activation on session
|
|
61
|
+
start, activate manually with `/ponytail` when wanted.
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
Resolution: env var > profile patch > built-in `full`. The card shows all three
|
|
64
|
+
sources and which one wins, so a level that "looks" set but is shadowed is
|
|
65
|
+
visible instead of silently ignored.
|
|
55
66
|
|
|
56
|
-
##
|
|
67
|
+
## Update
|
|
57
68
|
|
|
58
|
-
|
|
69
|
+
```bash
|
|
70
|
+
dsh plugin --profile <name> add @wenaixi/dsh-ponytail
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Restart the host after updating: a plugin entry's artifact fingerprint is
|
|
74
|
+
computed at process start and frozen, so a page refresh alone keeps serving
|
|
75
|
+
the previous build. A fresh install only needs a refresh.
|
|
76
|
+
|
|
77
|
+
## More
|
|
78
|
+
|
|
79
|
+
Full docs + examples: https://github.com/DietrichGebert/ponytail
|
|
@@ -1,45 +1,57 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ponytail-review
|
|
3
3
|
description: >
|
|
4
|
-
|
|
4
|
+
Code review focused exclusively on over-engineering. Finds what to delete:
|
|
5
|
+
reinvented standard library, unneeded dependencies, speculative abstractions,
|
|
6
|
+
dead flexibility. One line per finding: location, what to cut, what replaces
|
|
7
|
+
it. Use when the user says "review for over-engineering", "what can we
|
|
8
|
+
delete", "is this over-engineered", "simplify review", or invokes
|
|
9
|
+
/ponytail-review. Complements correctness-focused review, this one only
|
|
10
|
+
hunts complexity.
|
|
5
11
|
---
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
Review diffs for unnecessary complexity. One line per finding: location, what
|
|
14
|
+
to cut, what replaces it. The diff's best outcome is getting shorter.
|
|
8
15
|
|
|
9
|
-
##
|
|
16
|
+
## Format
|
|
10
17
|
|
|
11
|
-
`L
|
|
18
|
+
`L<line>: <tag> <what>. <replacement>.`, or `<file>:L<line>: ...` for
|
|
19
|
+
multi-file diffs.
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
Tags:
|
|
14
22
|
|
|
15
|
-
- `delete:`
|
|
16
|
-
- `stdlib:`
|
|
17
|
-
- `native:`
|
|
18
|
-
- `yagni:`
|
|
19
|
-
- `shrink:`
|
|
23
|
+
- `delete:` dead code, unused flexibility, speculative feature. Replacement: nothing.
|
|
24
|
+
- `stdlib:` hand-rolled thing the standard library ships. Name the function.
|
|
25
|
+
- `native:` dependency or code doing what the platform already does. Name the feature.
|
|
26
|
+
- `yagni:` abstraction with one implementation, config nobody sets, layer with one caller.
|
|
27
|
+
- `shrink:` same logic, fewer lines. Show the shorter form.
|
|
20
28
|
|
|
21
|
-
##
|
|
29
|
+
## Examples
|
|
22
30
|
|
|
23
|
-
❌
|
|
31
|
+
❌ "This EmailValidator class might be more complex than necessary, have you
|
|
32
|
+
considered whether all these validation rules are needed at this stage?"
|
|
24
33
|
|
|
25
|
-
✅ `L12-38: stdlib: 27
|
|
34
|
+
✅ `L12-38: stdlib: 27-line validator class. "@" in email, 1 line, real validation is the confirmation mail.`
|
|
26
35
|
|
|
27
|
-
✅ `L4: native:
|
|
36
|
+
✅ `L4: native: moment.js imported for one format call. Intl.DateTimeFormat, 0 deps.`
|
|
28
37
|
|
|
29
|
-
✅ `repo.py:L88: yagni:
|
|
38
|
+
✅ `repo.py:L88: yagni: AbstractRepository with one implementation. Inline it until a second one exists.`
|
|
30
39
|
|
|
31
|
-
✅ `L52-71: delete:
|
|
40
|
+
✅ `L52-71: delete: retry wrapper around an idempotent local call. Nothing replaces it.`
|
|
32
41
|
|
|
33
|
-
✅ `L30-44: shrink:
|
|
42
|
+
✅ `L30-44: shrink: manual loop builds dict. dict(zip(keys, values)), 1 line.`
|
|
34
43
|
|
|
35
|
-
##
|
|
44
|
+
## Scoring
|
|
36
45
|
|
|
37
|
-
|
|
46
|
+
End with the only metric that matters: `net: -<N> lines possible.`
|
|
38
47
|
|
|
39
|
-
|
|
48
|
+
If there is nothing to cut, say `Lean already. Ship.` and stop.
|
|
40
49
|
|
|
41
|
-
##
|
|
50
|
+
## Boundaries
|
|
42
51
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
Scope: over-engineering and complexity only. Correctness bugs, security holes,
|
|
53
|
+
and performance are explicitly out of scope. Route them to a normal review
|
|
54
|
+
pass, not this one. A single smoke test or `assert`-based
|
|
55
|
+
self-check is the ponytail minimum, not bloat, never flag it for deletion.
|
|
56
|
+
Does not apply the fixes, only lists them.
|
|
57
|
+
"stop ponytail-review" or "normal mode": revert to verbose review style.
|
package/lib/ponytail-http.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ponytail-http — HTTP 配置端点深模块(纯 Node 工厂,零 ctx)
|
|
3
|
-
*
|
|
4
|
-
* 从 apply() 剥离出的 /api/plugins/ponytail/config 处理器:
|
|
5
|
-
* GET/POST 全部业务分支、请求体解析、响应组装、405 兜底内聚于此,
|
|
6
|
-
* apply() 只保留 webServer.register 一行接线。
|
|
7
|
-
* 依赖全部经 deps 注入(state / 解析函数 / 失效回调 / patch/env 原值),
|
|
8
|
-
* 因此不经 Cordis ctx 即可用 node:test + 假 req/res 单测。
|
|
9
|
-
*/
|
|
10
|
-
import type { PonytailState } from './ponytail-state.js';
|
|
11
|
-
export interface ConfigHttpDeps {
|
|
12
|
-
/** 等级与技能开关状态机 */
|
|
13
|
-
state: PonytailState;
|
|
14
|
-
/** 读取 config.json 的 defaultMode 原始值(undefined=缺失/损坏) */
|
|
15
|
-
readRawConfigMode: () => string | undefined;
|
|
16
|
-
/** 变更后让宿主技能目录失效(UI 改禁用后模型侧即时收敛) */
|
|
17
|
-
invalidateSkills: () => void;
|
|
18
|
-
/** 每次快照读取 cordis.patch.yml 与运行时用户意图的当前值 */
|
|
19
|
-
readPatchMode: () => string | undefined;
|
|
20
|
-
/** 日志(沿用 ctx.logger 形状) */
|
|
21
|
-
logger: {
|
|
22
|
-
info: (msg: string) => void;
|
|
23
|
-
};
|
|
24
|
-
/** 每次快照读取 PONYTAIL_DEFAULT_MODE 当前值 */
|
|
25
|
-
readEnvRaw: () => string | undefined;
|
|
26
|
-
/** 技能目录(读取 SKILL.md frontmatter 作为元数据真源) */
|
|
27
|
-
skillDir: string;
|
|
28
|
-
}
|
|
29
|
-
export interface SkillMeta {
|
|
30
|
-
id: string;
|
|
31
|
-
name: string;
|
|
32
|
-
description: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 从 skills/ 目录读取全部技能元数据(SKILL.md frontmatter 为唯一真源)。
|
|
36
|
-
* 不按禁用状态过滤——面板需要展示全部 6 项(enabled 由 state.isSkillEnabled 标记)。
|
|
37
|
-
* 目录/文件不可读时回退 FALLBACK_SKILL_META(不抛错)。
|
|
38
|
-
*/
|
|
39
|
-
export declare function readSkillMeta(skillDirPath: string): SkillMeta[];
|
|
40
|
-
/**
|
|
41
|
-
* 创建 /api/plugins/ponytail/config 处理器。
|
|
42
|
-
* @returns 纯 Node http handler(req/res),可被 webServer.register 直接消费
|
|
43
|
-
*/
|
|
44
|
-
export declare function createConfigHttpEndpoint(deps: ConfigHttpDeps): (req: import('node:http').IncomingMessage, res: import('node:http').ServerResponse) => Promise<void>;
|
|
45
|
-
//# sourceMappingURL=ponytail-http.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ponytail-http.d.ts","sourceRoot":"","sources":["../src/ponytail-http.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAKxD,MAAM,WAAW,cAAc;IAC7B,iBAAiB;IACjB,KAAK,EAAE,aAAa,CAAA;IACpB,wDAAwD;IACxD,iBAAiB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IAC3C,mCAAmC;IACnC,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,2CAA2C;IAC3C,aAAa,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IACvC,2BAA2B;IAC3B,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAA;IACvC,uCAAuC;IACvC,UAAU,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IACpC,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAA;CACjB;AAyCD,MAAM,WAAW,SAAS;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE;AAiB5E;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,CAgB/D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,cAAc,GAC3D,CAAC,GAAG,EAAE,OAAO,WAAW,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,WAAW,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAwErG"}
|
package/lib/ponytail-http.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ponytail-http — HTTP 配置端点深模块(纯 Node 工厂,零 ctx)
|
|
3
|
-
*
|
|
4
|
-
* 从 apply() 剥离出的 /api/plugins/ponytail/config 处理器:
|
|
5
|
-
* GET/POST 全部业务分支、请求体解析、响应组装、405 兜底内聚于此,
|
|
6
|
-
* apply() 只保留 webServer.register 一行接线。
|
|
7
|
-
* 依赖全部经 deps 注入(state / 解析函数 / 失效回调 / patch/env 原值),
|
|
8
|
-
* 因此不经 Cordis ctx 即可用 node:test + 假 req/res 单测。
|
|
9
|
-
*/
|
|
10
|
-
import { readFileSync, readdirSync } from 'node:fs';
|
|
11
|
-
import { join } from 'node:path';
|
|
12
|
-
import { parse as parseYaml } from 'yaml';
|
|
13
|
-
import { resolvePriority } from './ponytail-priority.js';
|
|
14
|
-
import { isMainSkillDisabled } from './ponytail-state.js';
|
|
15
|
-
/** GET/POST 响应共用的快照:等级、默认档(与 priority 同源)、禁用技能、技能列表、诊断链 */
|
|
16
|
-
function snapshot(state, deps) {
|
|
17
|
-
const currentMode = state.get() ?? 'off';
|
|
18
|
-
// C3 合并:同快照内只求值一次(读盘一次、resolvePriority 一次),
|
|
19
|
-
// defaultMode 与 priority.effective 由同一 report 保证同源同值。
|
|
20
|
-
const report = resolvePriority({
|
|
21
|
-
envRaw: deps.readEnvRaw(),
|
|
22
|
-
patchMode: deps.readPatchMode(),
|
|
23
|
-
configMode: deps.readRawConfigMode(),
|
|
24
|
-
});
|
|
25
|
-
const disabledSkills = state.getDisabledSkills();
|
|
26
|
-
const skillsList = readSkillMeta(deps.skillDir).map((s) => ({
|
|
27
|
-
...s,
|
|
28
|
-
enabled: state.isSkillEnabled(s.id),
|
|
29
|
-
}));
|
|
30
|
-
return {
|
|
31
|
-
currentMode,
|
|
32
|
-
defaultMode: report.effective,
|
|
33
|
-
disabledSkills,
|
|
34
|
-
skills: skillsList,
|
|
35
|
-
priority: report,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
// 兜底元数据:仅当 frontmatter 目录不可读时使用(正常路径以 SKILL.md 为唯一真源,
|
|
39
|
-
// 见 readSkillMeta)。与面板构建期快照同源,防 API 离线时面板空白。
|
|
40
|
-
const FALLBACK_SKILL_META = [
|
|
41
|
-
{ id: 'ponytail', name: 'ponytail', description: '懒人模式本体:3 档强度,梯子七阶注入' },
|
|
42
|
-
{ id: 'ponytail-review', name: 'ponytail-review', description: '过度设计评审:只挑能删的代码,一行一条' },
|
|
43
|
-
{ id: 'ponytail-audit', name: 'ponytail-audit', description: '全仓过度设计审计:按可删行数降序猎取臃肿' },
|
|
44
|
-
{ id: 'ponytail-debt', name: 'ponytail-debt', description: '债务台账收割:收割所有 ponytail: 注释,建立债务台账' },
|
|
45
|
-
{ id: 'ponytail-gain', name: 'ponytail-gain', description: '收益看板:展示 benchmark 中位数收益' },
|
|
46
|
-
{ id: 'ponytail-help', name: 'ponytail-help', description: '速查卡:模式、技能、命令与配置速查' },
|
|
47
|
-
];
|
|
48
|
-
function parseSkillFrontmatter(filePath) {
|
|
49
|
-
try {
|
|
50
|
-
const raw = readFileSync(filePath, 'utf8').replace(/^\uFEFF/, '').replace(/\r\n/g, '\n');
|
|
51
|
-
if (!raw.startsWith('---\n'))
|
|
52
|
-
return null;
|
|
53
|
-
const end = raw.indexOf('\n---\n');
|
|
54
|
-
if (end < 0)
|
|
55
|
-
return null;
|
|
56
|
-
const fm = parseYaml(raw.slice(4, end));
|
|
57
|
-
if (typeof fm !== 'object' || fm === null || Array.isArray(fm))
|
|
58
|
-
return null;
|
|
59
|
-
const desc = fm['description'];
|
|
60
|
-
return { description: typeof desc === 'string' ? desc : undefined };
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* 从 skills/ 目录读取全部技能元数据(SKILL.md frontmatter 为唯一真源)。
|
|
68
|
-
* 不按禁用状态过滤——面板需要展示全部 6 项(enabled 由 state.isSkillEnabled 标记)。
|
|
69
|
-
* 目录/文件不可读时回退 FALLBACK_SKILL_META(不抛错)。
|
|
70
|
-
*/
|
|
71
|
-
export function readSkillMeta(skillDirPath) {
|
|
72
|
-
let names = [];
|
|
73
|
-
try {
|
|
74
|
-
names = readdirSync(skillDirPath, { withFileTypes: true })
|
|
75
|
-
.filter((d) => d.isDirectory() && !d.name.startsWith('.'))
|
|
76
|
-
.map((d) => d.name)
|
|
77
|
-
.sort();
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
return FALLBACK_SKILL_META.map((m) => ({ ...m }));
|
|
81
|
-
}
|
|
82
|
-
const metas = [];
|
|
83
|
-
for (const name of names) {
|
|
84
|
-
const fm = parseSkillFrontmatter(join(skillDirPath, name, 'SKILL.md'));
|
|
85
|
-
metas.push({ id: name, name, description: fm?.description ?? name });
|
|
86
|
-
}
|
|
87
|
-
return metas.length > 0 ? metas : FALLBACK_SKILL_META.map((m) => ({ ...m }));
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* 创建 /api/plugins/ponytail/config 处理器。
|
|
91
|
-
* @returns 纯 Node http handler(req/res),可被 webServer.register 直接消费
|
|
92
|
-
*/
|
|
93
|
-
export function createConfigHttpEndpoint(deps) {
|
|
94
|
-
return async (req, res) => {
|
|
95
|
-
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
96
|
-
res.setHeader('Cache-Control', 'no-store');
|
|
97
|
-
if (req.method === 'GET') {
|
|
98
|
-
res.writeHead(200);
|
|
99
|
-
res.end(JSON.stringify(snapshot(deps.state, deps)));
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (req.method === 'POST') {
|
|
103
|
-
let bodyStr = '';
|
|
104
|
-
for await (const chunk of req) {
|
|
105
|
-
bodyStr += chunk;
|
|
106
|
-
}
|
|
107
|
-
let payload = {};
|
|
108
|
-
try {
|
|
109
|
-
if (bodyStr)
|
|
110
|
-
payload = JSON.parse(bodyStr);
|
|
111
|
-
}
|
|
112
|
-
catch {
|
|
113
|
-
res.writeHead(400);
|
|
114
|
-
res.end(JSON.stringify({ error: 'Invalid JSON body' }));
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
// 一键恢复默认配置
|
|
118
|
-
if (payload.action === 'reset') {
|
|
119
|
-
deps.state.resetToDefaults();
|
|
120
|
-
deps.invalidateSkills();
|
|
121
|
-
deps.logger.info('[ponytail] UI 一键重置为默认配置(full 等级,开启所有技能)');
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
// 修改等级(全局持久化与即时生效)
|
|
125
|
-
if (typeof payload.mode === 'string') {
|
|
126
|
-
const targetMode = payload.mode.toLowerCase();
|
|
127
|
-
deps.state.setDefaultMode(targetMode);
|
|
128
|
-
deps.state.set(targetMode === 'off' ? null : targetMode);
|
|
129
|
-
deps.logger.info(`[ponytail] UI 切换运行等级:${targetMode}(已持久化为默认等级)`);
|
|
130
|
-
}
|
|
131
|
-
// 修改禁用的技能列表(物理隐藏)
|
|
132
|
-
if (Array.isArray(payload.disabledSkills)) {
|
|
133
|
-
const newDisabled = payload.disabledSkills.filter((s) => typeof s === 'string');
|
|
134
|
-
deps.state.setDisabledSkills(newDisabled);
|
|
135
|
-
if (isMainSkillDisabled(newDisabled)) {
|
|
136
|
-
deps.state.set(null);
|
|
137
|
-
}
|
|
138
|
-
deps.invalidateSkills();
|
|
139
|
-
deps.logger.info(`[ponytail] UI 更新禁用技能列表:${JSON.stringify(newDisabled)}`);
|
|
140
|
-
}
|
|
141
|
-
// 切换单个技能
|
|
142
|
-
if (typeof payload.toggleSkill === 'object' && payload.toggleSkill !== null) {
|
|
143
|
-
const tg = payload.toggleSkill;
|
|
144
|
-
if (typeof tg.name === 'string') {
|
|
145
|
-
deps.state.toggleSkill(tg.name, tg.enabled);
|
|
146
|
-
if (isMainSkillDisabled([tg.name]) && tg.enabled === false) {
|
|
147
|
-
deps.state.set(null);
|
|
148
|
-
}
|
|
149
|
-
deps.invalidateSkills();
|
|
150
|
-
deps.logger.info(`[ponytail] UI 切换技能 ${tg.name} 状态:${tg.enabled}`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
res.writeHead(200);
|
|
155
|
-
res.end(JSON.stringify({ success: true, ...snapshot(deps.state, deps) }));
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
res.writeHead(405);
|
|
159
|
-
res.end(JSON.stringify({ error: 'Method Not Allowed' }));
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
//# sourceMappingURL=ponytail-http.js.map
|
package/lib/ponytail-http.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version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