mino-connector-webwatch 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wuyangji
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,8 @@
1
- # Temporary Holding Version
1
+ # mino-connector-webwatch
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 被动观察 v0:反爬死域(12306/滴滴/淘宝订单)的入口=用户浏览器历史。
4
+
5
+ - `watch_scan`:扫浏览器历史里访问过的订单/行程页,每个命中给导入通道
6
+ - `watch_suggest`:单站点的可用导入通道(复制文本→orders/travel、截图→ocr、官方导出→bills)
7
+
8
+ 只读本机历史库快照,不监听不驻留不上传;导入动作由用户发起。
@@ -0,0 +1,5 @@
1
+ # mino-connector-webwatch — bundle patch
2
+ - insert:
3
+ - id: webwatch
4
+ name: 'mino-connector-webwatch'
5
+ config: {}
package/hostdeps.mjs ADDED
@@ -0,0 +1,74 @@
1
+ /**
2
+ * hostdeps.mjs —— 从宿主那棵树里取 `defineTool`(拿不到就退到自己的依赖,再不行用本地等价实现)。
3
+ * 与 fish-memory/lib/hostdeps.mjs 同一策略:桌面版 profile `autoInstallPeers: false`
4
+ * 时裸 import `@deepseek-ai/dsh-tools` 会让整条插件不激活,所以优先从宿主树解析。
5
+ * 本包只需要 defineTool 一个件。
6
+ */
7
+ import { existsSync, readFileSync, readdirSync } from 'node:fs'
8
+ import { join, dirname } from 'node:path'
9
+ import { homedir } from 'node:os'
10
+ import { fileURLToPath, pathToFileURL } from 'node:url'
11
+
12
+ const SELF_MODULES = join(dirname(fileURLToPath(import.meta.url)), 'node_modules', '@deepseek-ai')
13
+
14
+ function candidateRoots() {
15
+ const out = []
16
+ const push = (p) => { if (p && !out.includes(p)) out.push(p) }
17
+ push(process.env.DSH_HOST_MODULES)
18
+ const appdata = process.env.APPDATA
19
+ if (appdata) {
20
+ const npm = join(appdata, 'npm', 'node_modules')
21
+ push(join(npm, '@deepseek-ai'))
22
+ try {
23
+ for (const n of readdirSync(join(npm, '@deepseek-ai'))) {
24
+ push(join(npm, '@deepseek-ai', n, 'node_modules', '@deepseek-ai'))
25
+ }
26
+ } catch { /* 没有就算了 */ }
27
+ }
28
+ try {
29
+ const dshHome = process.env.DSH_HOME || join(homedir(), '.dsh')
30
+ for (const p of readdirSync(join(dshHome, 'profiles'))) {
31
+ push(join(dshHome, 'profiles', p, 'node_modules', '@deepseek-ai'))
32
+ }
33
+ } catch { /* 没有就算了 */ }
34
+ push(SELF_MODULES)
35
+ return out
36
+ }
37
+
38
+ function entryUrlFor(root, name) {
39
+ try {
40
+ const dir = join(root, name)
41
+ const pkgFile = join(dir, 'package.json')
42
+ if (!existsSync(pkgFile)) return null
43
+ const pkg = JSON.parse(readFileSync(pkgFile, 'utf8'))
44
+ const dot = pkg.exports?.['.']
45
+ const rel = typeof dot === 'string' ? dot : (dot?.import || dot?.default || pkg.module || pkg.main)
46
+ if (!rel) return null
47
+ const file = join(dir, String(rel).replace(/^\.\//, ''))
48
+ return existsSync(file) ? pathToFileURL(file).href : null
49
+ } catch { return null }
50
+ }
51
+
52
+ function localDefineTool(options) {
53
+ return options
54
+ }
55
+
56
+ export async function loadHostDeps() {
57
+ const notes = []
58
+ const log = (m) => notes.push(m)
59
+ let defineTool = null
60
+ let dtMod = null
61
+ for (const root of candidateRoots()) {
62
+ if (root === SELF_MODULES) continue
63
+ const url = entryUrlFor(root, 'dsh-tools')
64
+ if (!url) continue
65
+ try { dtMod = await import(url); log(`dsh-tools:宿主树取到(${url})`); break }
66
+ catch { /* try next root */ }
67
+ }
68
+ if (!dtMod) {
69
+ try { dtMod = await import('@deepseek-ai/dsh-tools'); log('dsh-tools:用自己依赖里那份') }
70
+ catch (e) { log(`dsh-tools 拿不到(${e?.code || ''})—— 用本地等价实现顶上`); dtMod = null }
71
+ }
72
+ defineTool = dtMod?.defineTool || ((options) => localDefineTool(options))
73
+ return { defineTool, notes }
74
+ }
package/index.js ADDED
@@ -0,0 +1,155 @@
1
+ /**
2
+ * mino-connector-webwatch —— 被动观察 v0。
3
+ * 抓不到的域(12306/滴滴/淘宝订单等反爬死域)的活通道:用户在浏览器里已经
4
+ * 打开过这些页面——扫浏览器历史命中订单/行程域 → 提示对应的导入通道
5
+ * (复制文本给 orders/travel、截图给 connector-ocr、官方导出给 bills)。
6
+ * 只读本机浏览器历史库(复制后只读打开),不监听不上传。
7
+ */
8
+ import { existsSync, readFileSync, readdirSync, mkdirSync, copyFileSync } from 'node:fs'
9
+ import { join, dirname } from 'node:path'
10
+ import { homedir, tmpdir } from 'node:os'
11
+ import { fileURLToPath } from 'node:url'
12
+ import { loadHostDeps } from './hostdeps.mjs'
13
+ import { createSkillProvider } from './skill-provider.mjs'
14
+
15
+ const PKG_DIR = dirname(fileURLToPath(import.meta.url))
16
+ const PKG = JSON.parse(readFileSync(join(PKG_DIR, 'package.json'), 'utf8'))
17
+ const STORE = join(process.env.DSH_HOME || join(homedir(), '.dsh'), 'connector-webwatch')
18
+
19
+ export const name = PKG.name
20
+ export const inject = ['skills', 'tools']
21
+ const defineTool = (await loadHostDeps()).defineTool
22
+ let DatabaseSync = null
23
+ try { ({ DatabaseSync } = await import('node:sqlite')) } catch { }
24
+
25
+ // ── 订单/行程站点(命中这些域=用户在浏览器打开过订单页)────────────────────────
26
+ const SITES = [
27
+ { site: '12306', re: /kyfw\.12306\.cn|www\.12306\.cn/i, hint: '12306 无导出——订单页全选复制文字喂 connector-travel,或截图喂 connector-ocr' },
28
+ { site: '滴滴', re: /didiglobal\.com|didi\.cn|xiaojukeji/i, hint: '滴滴行程单在 App 里可生成 PDF 行程报销单→connector-travel' },
29
+ { site: '淘宝订单', re: /buyertrade\.taobao\.com|trade\.taobao\.com|order.*taobao/i, hint: '淘宝订单页全选复制→connector-orders;账单侧用 connector-bills(支付宝官方导出)' },
30
+ { site: '京东订单', re: /order\.jd\.com|jd\.com.*order/i, hint: '京东订单页复制→connector-orders;账单侧 connector-bills 支持京东账单' },
31
+ { site: '拼多多', re: /yangkeduo|pinduoduo/i, hint: '拼多多订单页复制→connector-orders' },
32
+ { site: '美团', re: /meituan\.com|i\.meituan|dianping/i, hint: '美团/点评订单复制→connector-orders;账单侧 connector-bills 支持美团' },
33
+ { site: '携程', re: /ctrip\.com|trip\.com|fliggy|feizhu/i, hint: '携程/飞猪行程单导出或复制→connector-travel' },
34
+ { site: '高德', re: /amap\.com|ditu\.amap/i, hint: '高德足迹无 API——手动点亮图喂 connector-footprints' },
35
+ { site: '闲鱼', re: /goofish|2\.taobao|xianyu/i, hint: '闲鱼订单复制→connector-orders' },
36
+ ]
37
+
38
+ // ── 浏览器历史库定位(与 connector-browser-history 同一探测面)─────────────────
39
+ const L = process.env.LOCALAPPDATA || ''
40
+ const R = process.env.APPDATA || ''
41
+
42
+ function profilesOf(root) {
43
+ try {
44
+ return readdirSync(root, { withFileTypes: true })
45
+ .filter(e => e.isDirectory() && (e.name === 'Default' || e.name.startsWith('Profile') || e.name.includes('.')))
46
+ .map(e => join(root, e.name))
47
+ } catch { return [] }
48
+ }
49
+
50
+ function candidates() {
51
+ const out = []
52
+ for (const [browser, root] of [['chrome', join(L, 'Google', 'Chrome', 'User Data')],
53
+ ['edge', join(L, 'Microsoft', 'Edge', 'User Data')],
54
+ ['brave', join(L, 'BraveSoftware', 'Brave-Browser', 'User Data')]]) {
55
+ for (const prof of profilesOf(root)) {
56
+ const db = join(prof, 'History')
57
+ if (existsSync(db)) out.push({ browser, engine: 'chromium', db })
58
+ }
59
+ }
60
+ for (const prof of profilesOf(join(R, 'Mozilla', 'Firefox', 'Profiles'))) {
61
+ const db = join(prof, 'places.sqlite')
62
+ if (existsSync(db)) out.push({ browser: 'firefox', engine: 'firefox', db })
63
+ }
64
+ return out
65
+ }
66
+
67
+ const CHROME_EPOCH = 11644473600 // 1601→1970 秒差
68
+
69
+ async function readChromium(dbPath, days) {
70
+ const tmp = join(STORE, `snap-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.db`)
71
+ mkdirSync(STORE, { recursive: true })
72
+ copyFileSync(dbPath, tmp)
73
+ try {
74
+ const db = new DatabaseSync(tmp, { readOnly: true })
75
+ const cutoff = (Date.now() / 1000 - days * 86400 + CHROME_EPOCH) * 1e6
76
+ const rows = db.prepare(
77
+ `SELECT url, title, last_visit_time t FROM urls WHERE last_visit_time > ? ORDER BY last_visit_time DESC LIMIT 200000`).all(cutoff)
78
+ db.close()
79
+ return rows.map(r => ({ url: r.url, title: r.title || '', ts: (r.t / 1e6 - CHROME_EPOCH) * 1000 }))
80
+ } finally { try { const { unlinkSync } = await import('node:fs'); unlinkSync(tmp) } catch { } }
81
+ }
82
+
83
+ async function readFirefox(dbPath, days) {
84
+ const tmp = join(STORE, `snap-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.db`)
85
+ mkdirSync(STORE, { recursive: true })
86
+ copyFileSync(dbPath, tmp)
87
+ try {
88
+ const db = new DatabaseSync(tmp, { readOnly: true })
89
+ const cutoff = (Date.now() / 1000 - days * 86400) * 1e6 // moz visit_date 微秒 unix
90
+ const rows = db.prepare(
91
+ `SELECT p.url, p.title, v.visit_date t FROM moz_places p JOIN moz_historyvisits v ON p.id=v.place_id
92
+ WHERE v.visit_date > ? ORDER BY v.visit_date DESC LIMIT 200000`).all(cutoff)
93
+ db.close()
94
+ return rows.map(r => ({ url: r.url, title: r.title || '', ts: r.t / 1000 }))
95
+ } finally { try { const { unlinkSync } = await import('node:fs'); unlinkSync(tmp) } catch { } }
96
+ }
97
+
98
+ export function apply(ctx) {
99
+ ctx.tools.register(defineTool({
100
+ name: 'watch_scan',
101
+ description: '被动观察:扫浏览器历史(近 N 天)里访问过的订单/行程页(12306/滴滴/淘宝/京东/拼多多/美团/携程/高德/闲鱼),每个命中给出可用的导入通道。',
102
+ parameters: {
103
+ days: { type: 'integer', description: '回看天数(默认 30)' },
104
+ browser: { type: 'string', description: 'chrome|edge|firefox|brave|auto(默认 auto 全扫)' },
105
+ },
106
+ output: { schema: { type: 'object', additionalProperties: false, properties: {
107
+ hits: { type: 'array', items: { type: 'object', additionalProperties: false, properties: {
108
+ site: { type: 'string' }, browser: { type: 'string' }, when: { type: 'string' },
109
+ title: { type: 'string' }, url: { type: 'string' }, hint: { type: 'string' } } } },
110
+ browsers: { type: 'integer' } } },
111
+ render: (_a, v) => [{ type: 'text', text: v.hits.length
112
+ ? `命中 ${v.hits.length} 条:\n` + v.hits.slice(0, 15).map(h => `[${h.site}] ${h.when} ${h.title || h.url}`).join('\n')
113
+ : '近 N 天没访问过订单/行程页' }] },
114
+ isConcurrencySafe: () => true,
115
+ async execute(args) {
116
+ if (!DatabaseSync) throw new Error('watch_scan: 运行时缺 node:sqlite')
117
+ const days = Math.min(Math.max(Number(args.days) || 30, 1), 365)
118
+ const want = String(args.browser || 'auto').toLowerCase()
119
+ const cands = candidates().filter(c => want === 'auto' || c.browser === want)
120
+ if (!cands.length) throw new Error('watch_scan: 没找到浏览器历史库(Chrome/Edge/Firefox/Brave)')
121
+ const hits = []
122
+ for (const c of cands) {
123
+ let rows = []
124
+ try { rows = c.engine === 'chromium' ? await readChromium(c.db, days) : await readFirefox(c.db, days) } catch { continue }
125
+ for (const r of rows) {
126
+ const site = SITES.find(s => s.re.test(r.url))
127
+ if (site) hits.push({ site: site.site, browser: c.browser, when: new Date(r.ts).toISOString().slice(0, 16).replace('T', ' '), title: (r.title || '').slice(0, 60), url: r.url.slice(0, 140), hint: site.hint })
128
+ }
129
+ }
130
+ hits.sort((a, b) => b.when.localeCompare(a.when))
131
+ const seen = new Set()
132
+ const dedup = hits.filter(h => { const k = h.site + h.url; if (seen.has(k)) return false; seen.add(k); return true }).slice(0, 60)
133
+ return { hits: dedup, browsers: cands.length }
134
+ },
135
+ presentCall: (a) => ({ card: 'generic', title: '扫订单页足迹', kind: 'other', rawInput: a }),
136
+ }))
137
+
138
+ ctx.tools.register(defineTool({
139
+ name: 'watch_suggest',
140
+ description: '给一个域的「抓不到数据」建议:返回该站点的可用导入通道(复制文本/截图 OCR/官方导出/手动录入)。watch_scan 命中后的下一步指引。',
141
+ parameters: { site: { type: 'string', description: '站点名(12306/滴滴/淘宝订单/京东订单/拼多多/美团/携程/高德/闲鱼),空则全列' } },
142
+ output: { schema: { type: 'object', additionalProperties: false, properties: { report: { type: 'string' } } },
143
+ render: (_a, v) => [{ type: 'text', text: v.report }] },
144
+ isConcurrencySafe: () => true,
145
+ async execute(args) {
146
+ const want = String(args.site || '').trim()
147
+ const list = want ? SITES.filter(s => s.site.includes(want) || want.includes(s.site)) : SITES
148
+ if (!list.length) throw new Error(`watch_suggest: 不认识 "${want}",支持:${SITES.map(s => s.site).join('/')}`)
149
+ return { report: list.map(s => `${s.site}:${s.hint}`).join('\n') }
150
+ },
151
+ presentCall: (a) => ({ card: 'generic', title: '导入通道建议', kind: 'other', rawInput: a }),
152
+ }))
153
+
154
+ ctx.effect(() => ctx.skills.registerProvider(() => createSkillProvider(ctx)))
155
+ }
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "mino-connector-webwatch",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "被动观察 v0:扫浏览器历史里的订单/行程页访问,提示可用的导入通道(复制/OCR/导出)。",
5
+ "keywords": [
6
+ "dsh",
7
+ "dsh-plugin",
8
+ "mino-connector",
9
+ "watch",
10
+ "orders",
11
+ "browser"
12
+ ],
13
+ "type": "module",
14
+ "main": "index.js",
15
+ "exports": {
16
+ ".": "./index.js",
17
+ "./cordis.patch.yml": "./cordis.patch.yml",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": [
21
+ "index.js",
22
+ "hostdeps.mjs",
23
+ "skill-provider.mjs",
24
+ "skills",
25
+ "cordis.patch.yml",
26
+ "README.md",
27
+ "LICENSE"
28
+ ],
29
+ "dsh": {
30
+ "bundle": {
31
+ "patch": "./cordis.patch.yml"
32
+ }
33
+ },
34
+ "engines": {
35
+ "dsh": ">=0.2.2-alpha.1 <0.3.0"
36
+ }
6
37
  }
@@ -0,0 +1,131 @@
1
+ /**
2
+ * skill-provider.mjs —— ctx.skills.registerProvider 的标准实现。
3
+ * 与 templates/skill-pack/index.js 的 provider 逻辑一致(D42 纪律:逐字用,勿手写变形)。
4
+ * 用法:import { createSkillProvider } from './skill-provider.mjs'
5
+ * ctx.effect(() => ctx.skills.registerProvider(() => createSkillProvider(ctx)))
6
+ * 约定:包根有 package.json(取 name)和 skills/ 目录。
7
+ */
8
+ import { readFileSync } from 'node:fs'
9
+ import { readdir, readFile } from 'node:fs/promises'
10
+ import { fileURLToPath } from 'node:url'
11
+ import { dirname, join } from 'node:path'
12
+
13
+ const PKG_DIR = dirname(fileURLToPath(import.meta.url))
14
+ const PKG = JSON.parse(readFileSync(join(PKG_DIR, 'package.json'), 'utf8'))
15
+ const SKILLS_DIR = join(PKG_DIR, 'skills')
16
+ const RANK = 650
17
+ const NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/
18
+
19
+ export function createSkillProvider(ctx) {
20
+ const warn = (msg) => ctx.logger?.warn(msg)
21
+ return {
22
+ name: PKG.name,
23
+ async list(options = {}) {
24
+ let entries
25
+ try { entries = await readdir(SKILLS_DIR, { withFileTypes: true }) }
26
+ catch (e) { if (e?.code === 'ENOENT') return []; throw e }
27
+ const candidates = []
28
+ for (const entry of entries) {
29
+ options.signal?.throwIfAborted?.()
30
+ const file = entry.isDirectory() ? join(SKILLS_DIR, entry.name, 'SKILL.md')
31
+ : entry.isFile() && entry.name.endsWith('.md') ? join(SKILLS_DIR, entry.name) : undefined
32
+ if (!file) continue
33
+ const parsed = await parseSkillFile(file, options.signal, warn)
34
+ if (parsed) candidates.push(toCandidate(parsed, file))
35
+ }
36
+ return candidates
37
+ },
38
+ async get(candidate, options = {}) {
39
+ const parsed = await parseSkillFile(candidate.locator, options.signal, warn)
40
+ if (!parsed || parsed.name !== candidate.name) return undefined
41
+ return {
42
+ name: parsed.name,
43
+ description: parsed.description,
44
+ ...(parsed.whenToUse !== undefined ? { whenToUse: parsed.whenToUse } : {}),
45
+ invocation: parsed.invocation,
46
+ source: 'market',
47
+ provider: PKG.name,
48
+ resourceBase: { kind: 'directory', path: dirname(candidate.locator) },
49
+ ...(parsed.metadata !== undefined ? { metadata: parsed.metadata } : {}),
50
+ content: parsed.content,
51
+ }
52
+ },
53
+ }
54
+ }
55
+
56
+ function toCandidate(parsed, file) {
57
+ return {
58
+ name: parsed.name,
59
+ description: parsed.description,
60
+ ...(parsed.whenToUse !== undefined ? { whenToUse: parsed.whenToUse } : {}),
61
+ invocation: parsed.invocation,
62
+ source: 'market',
63
+ provider: PKG.name,
64
+ resourceBase: { kind: 'directory', path: dirname(file) },
65
+ ...(parsed.metadata !== undefined ? { metadata: parsed.metadata } : {}),
66
+ rank: RANK,
67
+ locator: file,
68
+ }
69
+ }
70
+
71
+ async function parseSkillFile(file, signal, warn) {
72
+ let raw
73
+ try { raw = await readFile(file, 'utf8') } catch { return undefined }
74
+ signal?.throwIfAborted?.()
75
+ const parsed = parseFrontmatter(raw)
76
+ if (!parsed) { warn(`skill file ${file} ignored: missing frontmatter`); return undefined }
77
+ const { data, body } = parsed
78
+ const name = str(data.name)
79
+ const description = str(data.description)
80
+ if (!name || !description) { warn(`skill file ${file} ignored: frontmatter requires name and description`); return undefined }
81
+ if (!NAME_RE.test(name)) { warn(`skill file ${file} ignored: invalid skill name "${name}"`); return undefined }
82
+ return {
83
+ name,
84
+ description,
85
+ ...(str(data.whenToUse) !== undefined ? { whenToUse: str(data.whenToUse) } : {}),
86
+ invocation: { modelInvocable: !(data['disable-model-invocation'] === true), userInvocable: data['user-invocable'] !== false },
87
+ ...(data.metadata && typeof data.metadata === 'object' ? { metadata: data.metadata } : {}),
88
+ content: body.trim(),
89
+ }
90
+ }
91
+
92
+ const str = (v) => typeof v === 'string' && v.trim() ? v : undefined
93
+
94
+ function parseFrontmatter(text) {
95
+ const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text)
96
+ if (!match) return undefined
97
+ return { data: parseFlatYaml(match[1]), body: text.slice(match[0].length) }
98
+ }
99
+
100
+ function parseFlatYaml(src) {
101
+ const data = {}
102
+ let section
103
+ for (const line of src.split(/\r?\n/)) {
104
+ if (!line.trim() || line.trimStart().startsWith('#')) continue
105
+ const indent = line.length - line.trimStart().length
106
+ const match = /^([A-Za-z0-9_-]+)\s*:\s*(.*)$/.exec(line.trim())
107
+ if (!match) continue
108
+ const [, key, raw] = match
109
+ const value = parseScalar(raw)
110
+ if (indent > 0 && section) {
111
+ if (typeof data[section] !== 'object' || data[section] === null) data[section] = {}
112
+ data[section][key] = value
113
+ continue
114
+ }
115
+ if (value === undefined) { section = key; data[key] = {} }
116
+ else { data[key] = value; section = undefined }
117
+ }
118
+ return data
119
+ }
120
+
121
+ function parseScalar(raw) {
122
+ const value = raw.trim()
123
+ if (value === '') return undefined
124
+ if (value.startsWith('"') && value.endsWith('"') && value.length >= 2) return value.slice(1, -1)
125
+ if (value.startsWith("'") && value.endsWith("'") && value.length >= 2) return value.slice(1, -1)
126
+ const bare = value.replace(/\s+#.*$/, '')
127
+ if (bare === 'true') return true
128
+ if (bare === 'false') return false
129
+ if (bare === 'null' || bare === '~') return null
130
+ return bare
131
+ }
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: order-watch
3
+ description: 被动观察用法:抓不到的域(12306/滴滴/淘宝订单等反爬死域)别硬爬——watch_scan 看用户在浏览器打开过哪些订单页,命中后按 watch_suggest 指引走复制/OCR/导出通道导入。
4
+ ---
5
+
6
+ # 被动观察
7
+
8
+ 有的域没有官方导出也爬不动(12306/滴滴/拼多多订单)。但用户自己在浏览器里
9
+ 打开过这些页面——**历史记录就是入口**。
10
+
11
+ ## 流程
12
+
13
+ 1. 用户说「帮我整理订单/行程」「查我最近买了啥」而对应域没有活通道时:
14
+ `watch_scan` 扫浏览器历史命中订单/行程页
15
+ 2. 命中后按每条的 `hint` 走导入通道:
16
+ - 页面内可全选复制 → 喂 `connector-orders` / `connector-travel`
17
+ - 只有截图 → 喂 `connector-ocr`
18
+ - 有官方导出 → `connector-bills`(支付宝/微信/京东/美团账单官方导)
19
+ 3. `watch_suggest` 给单个站点的完整通道说明
20
+
21
+ ## 口径
22
+
23
+ - 只读用户本机浏览器历史库(快照复制后只读打开),不监听、不驻留、不上传
24
+ - v0 是「检测到访问过 → 给导入通道」,不做实时页面监听
25
+ - 导入动作始终由用户发起/确认,不替用户抓取页面内容