@miphamai/cli 0.48.0 → 0.49.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miphamai/cli",
3
- "version": "0.48.0",
3
+ "version": "0.49.0",
4
4
  "description": "Mipham Code — Multi-model open-core intelligent coding terminal by MiphamAI",
5
5
  "keywords": [
6
6
  "ai",
@@ -0,0 +1,198 @@
1
+ ---
2
+ name: doc-sync
3
+ description: Keep engineering truth docs aligned with code — map changed code to docs, update stale docs after functional changes, keep git-reviewable
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # Doc Sync
8
+
9
+ Keep engineering "truth docs" aligned with code. After a functional code change, run this skill to find the docs that map to the changed code, check them against the code + tests, and update anything that drifted. Docs travel with the branch in git and are reviewed alongside the code diff.
10
+
11
+ ## Where truth docs live
12
+
13
+ Engineering truth docs live under `docs/truth/engineering/`. Routing from code → docs lives in `docs/truth/ROUTES.md`.
14
+
15
+ ```
16
+ docs/truth/
17
+ ├── ROUTES.md # code area → canonical doc mapping
18
+ └── engineering/
19
+ ├── behaviors/ # implementation behavior
20
+ ├── contracts/ # API / interface contracts
21
+ ├── architecture/ # component structure and boundaries
22
+ ├── workflows/ # multi-step flows and orchestration
23
+ └── operations/ # runbooks, config, deployment
24
+ ```
25
+
26
+ ## Invariants (never break)
27
+
28
+ - **Doc-only**: touch `docs/truth/**` and `ROUTES.md` only. Never modify functional code, tests, or config outside `docs/truth/`.
29
+ - **Evidence-backed**: every claim cites `file:line` (or `file` for a whole file). No invented behavior.
30
+ - **Branch-scoped**: docs change in the same branch as the code, so they review together.
31
+
32
+ ## Workflow
33
+
34
+ ### 1. Map — find the docs that cover the change
35
+
36
+ Determine the changed code. Prefer an explicit path argument; otherwise use the working-tree or branch diff:
37
+
38
+ ```bash
39
+ git diff --name-only # uncommitted working-tree changes
40
+ git diff --name-only HEAD~1 # last commit
41
+ ```
42
+
43
+ Read `docs/truth/ROUTES.md` and match the changed paths to their canonical doc. A route is a glob → doc path pair. A changed path with no route is a signal to create one (Step 3).
44
+
45
+ ### 2. Check — is the doc now stale?
46
+
47
+ For each mapped doc, read the doc, the changed code, and the relevant tests. Compare:
48
+
49
+ - Does the doc describe behavior the code no longer has?
50
+ - Does the code add or remove behavior the doc doesn't mention?
51
+ - Do contract shapes (signatures, types, errors) still match?
52
+ - Are the `file:line` evidence pointers still valid?
53
+
54
+ A doc is stale when any claim no longer matches the code + tests.
55
+
56
+ ### 3. Update — fix the drift
57
+
58
+ - **Existing doc, stale**: edit the doc in place. Update claims, refresh `file:line` pointers, remove dead behavior, add new behavior. Keep the section structure unless the change demands otherwise.
59
+ - **Existing doc, orphaned**: if the mapped code is gone, remove the doc and its route entry.
60
+ - **Changed path has no route**: create one bounded doc under the right `docs/truth/engineering/<type>/` folder and add a route entry to `ROUTES.md`. Scope the doc to the changed area — do not document the whole codebase.
61
+
62
+ Keep the diff minimal and reviewable: one doc per functional change, no unrelated rewrites.
63
+
64
+ ### 4. Verify — reviewable and true
65
+
66
+ Confirm before reporting done:
67
+
68
+ - `git diff --stat` shows only `docs/truth/**` and `ROUTES.md`.
69
+ - Every claim in the updated doc has a `file:line` pointer that exists in the working tree.
70
+ - The doc matches the code + tests, not the other way around.
71
+
72
+ Report: "Updated <doc> for <change>. Review the truth diff alongside the code diff."
73
+
74
+ ## Document templates
75
+
76
+ ### Behavior (`behaviors/`)
77
+
78
+ ```markdown
79
+ # <Behavior Name>
80
+
81
+ **Area**: <route / component>
82
+ **Evidence**: `src/<file>:<line>`
83
+
84
+ ## What it does
85
+
86
+ <one-paragraph summary, from code + tests>
87
+
88
+ ## Behavior
89
+
90
+ - <observable behavior> — `src/<file>:<line>`
91
+
92
+ ## Edge cases
93
+
94
+ - <case> — `src/<file>:<line>`
95
+
96
+ ## Tests
97
+
98
+ - `tests/<file>.test.ts` — covers <behavior>
99
+ ```
100
+
101
+ ### Contract (`contracts/`)
102
+
103
+ ```markdown
104
+ # <API / Interface>
105
+
106
+ **Evidence**: `src/<file>:<line>`
107
+
108
+ ## Signature
109
+
110
+ \`\`\`ts
111
+ // the actual exported signature
112
+ \`\`\`
113
+
114
+ ## Parameters
115
+
116
+ | Param | Type | Description |
117
+ | ----- | ---- | ----------- |
118
+
119
+ ## Returns / Errors
120
+
121
+ - ...
122
+
123
+ ## Consumers
124
+
125
+ - <caller> — `src/<file>:<line>`
126
+ ```
127
+
128
+ ### Architecture (`architecture/`)
129
+
130
+ ```markdown
131
+ # <Component / Module>
132
+
133
+ **Evidence**: `src/<file>`
134
+
135
+ ## Responsibility
136
+
137
+ <one paragraph — what it owns, what it doesn't>
138
+
139
+ ## Dependencies
140
+
141
+ - depends on: <...>
142
+ - depended on by: <...>
143
+
144
+ ## Boundaries
145
+
146
+ - <seam / interface> — `src/<file>:<line>`
147
+ ```
148
+
149
+ ### Workflow (`workflows/`)
150
+
151
+ ```markdown
152
+ # <Workflow Name>
153
+
154
+ **Evidence**: `src/<file>:<line>`
155
+
156
+ ## Steps
157
+
158
+ 1. <step> — `src/<file>:<line>`
159
+
160
+ ## Trigger / Exit
161
+
162
+ - trigger: <...>
163
+ - success: <...> / failure: <...>
164
+ ```
165
+
166
+ ### Operations (`operations/`)
167
+
168
+ ```markdown
169
+ # <Runbook / Config>
170
+
171
+ **Evidence**: `src/<file>`
172
+
173
+ ## Config / Env
174
+
175
+ | Key | Default | Meaning |
176
+ | --- | ------- | ------- |
177
+
178
+ ## Runbook
179
+
180
+ - <action> — <command or step>
181
+
182
+ ## Failure modes
183
+
184
+ - <symptom> → <cause> → <fix>
185
+ ```
186
+
187
+ ## Routing file (`ROUTES.md`)
188
+
189
+ ```markdown
190
+ # Truth Routes
191
+
192
+ | Code pattern | Doc |
193
+ | ----------------- | ---------------------------------------- |
194
+ | src/auth/session* | engineering/behaviors/session-timeout.md |
195
+ | src/api/* | engineering/contracts/api.md |
196
+ ```
197
+
198
+ Patterns are globs relative to the repo root. One doc may be routed by several patterns; one pattern maps to one doc. Keep patterns as specific as needed to avoid one giant doc.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: self-audit
3
- description: CRSI Phase 2: Mipham Code systematic self-audit — identifies code quality, architecture, performance, and security issues; integrates with CRSI pipeline for auto-rule generation
3
+ description: 'CRSI Phase 2: Mipham Code systematic self-audit — identifies code quality, architecture, performance, and security issues; integrates with CRSI pipeline for auto-rule generation'
4
4
  version: 1.0.0
5
5
  ---
6
6
 
@@ -0,0 +1,132 @@
1
+ # CDP Proxy API 参考
2
+
3
+ ## 基础信息
4
+
5
+ - 地址:`http://localhost:3456`
6
+ - 启动:`node ~/.claude/skills/web-access/scripts/cdp-proxy.mjs &`
7
+ - 启动后持续运行,不建议主动停止(重启需 Chrome 重新授权)
8
+ - 强制停止:`pkill -f cdp-proxy.mjs`
9
+
10
+ ## API 端点
11
+
12
+ ### GET /health
13
+
14
+ 健康检查,返回连接状态。
15
+
16
+ ```bash
17
+ curl -s http://localhost:3456/health
18
+ ```
19
+
20
+ ### GET /targets
21
+
22
+ 列出所有已打开的页面 tab。返回数组,每项含 `targetId`、`title`、`url`。
23
+
24
+ ```bash
25
+ curl -s http://localhost:3456/targets
26
+ ```
27
+
28
+ ### GET /new?url=URL
29
+
30
+ 创建新后台 tab,自动等待页面加载完成。返回 `{ targetId }`.
31
+
32
+ ```bash
33
+ curl -s "http://localhost:3456/new?url=https://example.com"
34
+ ```
35
+
36
+ ### GET /close?target=ID
37
+
38
+ 关闭指定 tab。
39
+
40
+ ```bash
41
+ curl -s "http://localhost:3456/close?target=TARGET_ID"
42
+ ```
43
+
44
+ ### GET /navigate?target=ID&url=URL
45
+
46
+ 在已有 tab 中导航到新 URL,自动等待加载。
47
+
48
+ ```bash
49
+ curl -s "http://localhost:3456/navigate?target=ID&url=https://example.com"
50
+ ```
51
+
52
+ ### GET /back?target=ID
53
+
54
+ 后退一页。
55
+
56
+ ```bash
57
+ curl -s "http://localhost:3456/back?target=ID"
58
+ ```
59
+
60
+ ### GET /info?target=ID
61
+
62
+ 获取页面基础信息(title、url、readyState)。
63
+
64
+ ```bash
65
+ curl -s "http://localhost:3456/info?target=ID"
66
+ ```
67
+
68
+ ### POST /eval?target=ID
69
+
70
+ 执行 JavaScript 表达式,POST body 为 JS 代码。
71
+
72
+ ```bash
73
+ curl -s -X POST "http://localhost:3456/eval?target=ID" -d 'document.title'
74
+ ```
75
+
76
+ ### POST /click?target=ID
77
+
78
+ JS 层面点击(`el.click()`),POST body 为 CSS 选择器。自动 scrollIntoView 后点击。简单快速,覆盖大多数场景。
79
+
80
+ ```bash
81
+ curl -s -X POST "http://localhost:3456/click?target=ID" -d 'button.submit'
82
+ ```
83
+
84
+ ### POST /clickAt?target=ID
85
+
86
+ CDP 浏览器级真实鼠标点击(`Input.dispatchMouseEvent`),POST body 为 CSS 选择器。先获取元素坐标,再模拟鼠标按下/释放。算真实用户手势,能触发文件对话框、绕过部分反自动化检测。
87
+
88
+ ```bash
89
+ curl -s -X POST "http://localhost:3456/clickAt?target=ID" -d 'button.upload'
90
+ ```
91
+
92
+ ### POST /setFiles?target=ID
93
+
94
+ 给 file input 设置本地文件路径(`DOM.setFileInputFiles`),完全绕过文件对话框。POST body 为 JSON。
95
+
96
+ ```bash
97
+ curl -s -X POST "http://localhost:3456/setFiles?target=ID" -d '{"selector":"input[type=file]","files":["/path/to/file1.png","/path/to/file2.png"]}'
98
+ ```
99
+
100
+ ### GET /scroll?target=ID&y=3000&direction=down
101
+
102
+ 滚动页面。`direction` 可选 `down`(默认)、`up`、`top`、`bottom`。滚动后自动等待 800ms 供懒加载触发。
103
+
104
+ ```bash
105
+ curl -s "http://localhost:3456/scroll?target=ID&y=3000"
106
+ curl -s "http://localhost:3456/scroll?target=ID&direction=bottom"
107
+ ```
108
+
109
+ ### GET /screenshot?target=ID&file=/tmp/shot.png
110
+
111
+ 截图。指定 `file` 参数保存到本地文件;不指定则返回图片二进制。可选 `format=jpeg`。
112
+
113
+ ```bash
114
+ curl -s "http://localhost:3456/screenshot?target=ID&file=/tmp/shot.png"
115
+ ```
116
+
117
+ ## /eval 使用提示
118
+
119
+ - POST body 为任意 JS 表达式,返回 `{ value }` 或 `{ error }`
120
+ - 支持 `awaitPromise`:可以写 async 表达式
121
+ - 返回值必须是可序列化的(字符串、数字、对象),DOM 节点不能直接返回,需要提取属性
122
+ - 提取大量数据时用 `JSON.stringify()` 包裹,确保返回字符串
123
+ - 根据页面实际 DOM 结构编写选择器,不要套用固定模板
124
+
125
+ ## 错误处理
126
+
127
+ | 错误 | 原因 | 解决 |
128
+ | --------------------------- | -------------------------- | -------------------------------------------------------------- |
129
+ | `Chrome 未开启远程调试端口` | Chrome 未开启远程调试 | 提示用户打开 `chrome://inspect/#remote-debugging` 并勾选 Allow |
130
+ | `attach 失败` | targetId 无效或 tab 已关闭 | 用 `/targets` 获取最新列表 |
131
+ | `CDP 命令超时` | 页面长时间未响应 | 重试或检查 tab 状态 |
132
+ | `端口已被占用` | 另一个 proxy 已在运行 | 已有实例可直接复用 |