@danceiny/gotry 0.0.1-rc.13 → 0.0.1-rc.14
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 +119 -140
- package/README.zh-CN.md +233 -0
- package/bin/gotry-bootstrap.js +126 -0
- package/bin/gotry-inner.js +10 -3
- package/dist/capabilities/hbcli.js +42 -15
- package/dist/scripts/bootstrap-tests.js +56 -0
- package/dist/scripts/flyai-tests.js +95 -0
- package/dist/scripts/hbcli-tests.js +28 -3
- package/dist/src/index.js +8 -3
- package/package.json +2 -1
- package/ts/capabilities/hbcli.ts +51 -19
- package/ts/src/index.ts +17 -5
package/ts/src/index.ts
CHANGED
|
@@ -516,11 +516,18 @@ export function apply(ctx: Context, config: Config): void {
|
|
|
516
516
|
},
|
|
517
517
|
presentCall: args => ({ card: 'generic', title: `酒店搜索:${String((args.query as { destination?: string })?.destination ?? '')}`, kind: 'search', rawInput: args.query }),
|
|
518
518
|
presentResult: (_args, value) => {
|
|
519
|
-
const r = value as { hotels?: unknown
|
|
520
|
-
const
|
|
519
|
+
const r = value as { hotels?: unknown; via?: string; destination?: string; summary?: string }
|
|
520
|
+
const h = r.hotels
|
|
521
|
+
const liveCount = Array.isArray(h) ? h.length : 0
|
|
522
|
+
// 静态包是 {meta, stays} 对象而非数组(issue #24:此前计数恒 0 → UI 显示「无结果」)
|
|
523
|
+
const stays = !Array.isArray(h) && h && typeof h === 'object' ? (h as { stays?: unknown[] }).stays : undefined
|
|
524
|
+
const staticCount = Array.isArray(stays) ? stays.length : 0
|
|
525
|
+
const tag = r.via === 'hbcli-realtime'
|
|
526
|
+
? (liveCount ? `实时 ${liveCount} 家` : '实时')
|
|
527
|
+
: staticCount ? `静态包 ${staticCount} 块` : (liveCount ? `${liveCount} 家` : '无结果')
|
|
521
528
|
return {
|
|
522
529
|
card: 'generic',
|
|
523
|
-
title: `酒店:${r.destination ?? ''} ${
|
|
530
|
+
title: `酒店:${r.destination ?? ''} ${tag}`,
|
|
524
531
|
content: [{ type: 'text', text: String(r.summary ?? '') }],
|
|
525
532
|
}
|
|
526
533
|
},
|
|
@@ -719,9 +726,14 @@ export function apply(ctx: Context, config: Config): void {
|
|
|
719
726
|
}
|
|
720
727
|
const r = await flyaiSearch({ kind, origin: q.from, destination: q.to, depDate: q.date })
|
|
721
728
|
const top = (r.options ?? []).slice(0, 8).map(o => `${o.no} ${o.name} ${o.depDateTime.slice(11, 16)}→${o.arrDateTime.slice(11, 16)} ¥${o.price}`)
|
|
729
|
+
// issue #24:miss(上游正常返回 0 条)与 error(限流/网络)分开陈述,不再混写「无结果或失败」
|
|
730
|
+
// (过去日期已被上方预校验拦下,此处不会出现过期查询)
|
|
731
|
+
const label = kind === 'flight' ? '机票' : '火车票'
|
|
722
732
|
const summary = r.verdict === 'hit'
|
|
723
|
-
? `${q.from}→${q.to} ${q.date} ${
|
|
724
|
-
:
|
|
733
|
+
? `${q.from}→${q.to} ${q.date} ${label}(飞猪官方只读)前 ${top.length} 条:\n${top.join('\n')}\n${r.evidence}`
|
|
734
|
+
: r.verdict === 'miss'
|
|
735
|
+
? `${q.from}→${q.to} ${q.date} ${label}官方通道正常返回 0 条(常见原因:航线未开放/当日售罄)。${r.evidence}`
|
|
736
|
+
: `${q.from}→${q.to} ${q.date} ${label}检索失败(可能限流/网络):${r.error ?? ''} ${r.evidence}`
|
|
725
737
|
return JSON.parse(JSON.stringify({ ...r, kind, summary })) as Record<string, never>
|
|
726
738
|
},
|
|
727
739
|
presentCall: args => ({ card: 'generic', title: `官方检索:${String((args.query as { kind?: string })?.kind ?? 'flight')}`, kind: 'fetch', rawInput: args.query }),
|