openprototype 1.1.0 → 1.3.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 +106 -49
- package/README.zh-CN.md +107 -48
- package/bin/cli.js +72 -4
- package/image/README/core-loop.gif +0 -0
- package/package.json +8 -3
- package/product/demo/pc/index.html +6 -0
- package/runtime/shell/onboarding.css +184 -0
- package/runtime/shell/onboarding.js +422 -0
- package/scripts/check/smoke-test.js +10 -2
- package/templates/product-shell/index.html +6 -0
package/bin/cli.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* openprototype CLI
|
|
6
6
|
*
|
|
7
7
|
* openprototype create <dir> 从零创建一个新项目(场景①)
|
|
8
|
-
* openprototype init
|
|
8
|
+
* openprototype init 把框架植入当前已有项目(保留已有模板,可能安装常驻服务)
|
|
9
9
|
* openprototype add-product <id> 新增一个产品壳(默认 pc)
|
|
10
10
|
* openprototype serve 启动本地服务器
|
|
11
11
|
* openprototype service <action> 管理本地常驻服务
|
|
@@ -97,6 +97,69 @@ function scaffoldProductShell(projectRoot, productId, productTitle) {
|
|
|
97
97
|
writeFileSafe(path.join(dir, 'nav-tree.json'), '[]\n');
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
// 新手引导的两行引用标签。壳 HTML 是脚手架时复制的、不会随 npm update 升级,
|
|
101
|
+
// 所以老项目的壳里没有这两行;这里在 init 时补进去(真正的逻辑在 /_kit/shell/onboarding.*,会随包升级)。
|
|
102
|
+
const ONBOARDING_MARK = 'onboarding:start';
|
|
103
|
+
const ONBOARDING_HEAD = [
|
|
104
|
+
'<!-- onboarding:start (本地开发专用;发布时可由 openprototype publish 自动剥离) -->',
|
|
105
|
+
'<link rel="stylesheet" href="/_kit/shell/onboarding.css">',
|
|
106
|
+
'<!-- onboarding:end -->'
|
|
107
|
+
].join('\n');
|
|
108
|
+
const ONBOARDING_BODY = [
|
|
109
|
+
'<!-- onboarding:start (本地开发专用;发布时可由 openprototype publish 自动剥离) -->',
|
|
110
|
+
'<script src="/_kit/shell/onboarding.js"></script>',
|
|
111
|
+
'<!-- onboarding:end -->'
|
|
112
|
+
].join('\n');
|
|
113
|
+
|
|
114
|
+
/** 列出 product/<id>/<root>/index.html —— 已生成的产品壳 */
|
|
115
|
+
function listProductShells(projectRoot) {
|
|
116
|
+
const shells = [];
|
|
117
|
+
const productDir = path.join(projectRoot, 'product');
|
|
118
|
+
if (!fs.existsSync(productDir)) return shells;
|
|
119
|
+
for (const productId of fs.readdirSync(productDir)) {
|
|
120
|
+
const dir = path.join(productDir, productId);
|
|
121
|
+
if (!fs.statSync(dir).isDirectory()) continue;
|
|
122
|
+
for (const rootName of fs.readdirSync(dir)) {
|
|
123
|
+
const shell = path.join(dir, rootName, 'index.html');
|
|
124
|
+
if (fs.existsSync(shell)) shells.push(shell);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return shells;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 给已有的产品壳补上新手引导的引用标签。
|
|
132
|
+
* 幂等:见到 onboarding:start 就跳过;壳里没有 agent-panel 标记的一律不动(不是本框架的壳)。
|
|
133
|
+
* 引导的 <script> 必须排在 agent-panel.js 之后,那里才定义了 window.PROTO_KIT。
|
|
134
|
+
*/
|
|
135
|
+
function patchShellOnboarding(projectRoot) {
|
|
136
|
+
let patched = 0;
|
|
137
|
+
for (const shell of listProductShells(projectRoot)) {
|
|
138
|
+
const rel = path.relative(projectRoot, shell);
|
|
139
|
+
let html = fs.readFileSync(shell, 'utf8');
|
|
140
|
+
if (html.includes(ONBOARDING_MARK)) { info(C.dim(' 跳过(已有引导入口): ') + rel); continue; }
|
|
141
|
+
if (!html.includes('/_kit/shell/agent-panel.js')) { info(C.dim(' 跳过(非本框架的壳): ') + rel); continue; }
|
|
142
|
+
|
|
143
|
+
const headAnchor = '<!-- agent-panel:end -->';
|
|
144
|
+
const bodyAnchor = '<script src="/_kit/shell/agent-panel.js"></script>';
|
|
145
|
+
const headAt = html.indexOf(headAnchor);
|
|
146
|
+
const bodyAt = html.indexOf(bodyAnchor);
|
|
147
|
+
if (headAt === -1 || bodyAt === -1) { info(C.dim(' 跳过(壳结构不认识): ') + rel); continue; }
|
|
148
|
+
|
|
149
|
+
// 先补后面的、再补前面的,免得插入把后一个位置的下标顶偏
|
|
150
|
+
const bodyEnd = html.indexOf(headAnchor, bodyAt);
|
|
151
|
+
const bodyInsertAt = bodyEnd === -1 ? bodyAt + bodyAnchor.length : bodyEnd + headAnchor.length;
|
|
152
|
+
html = html.slice(0, bodyInsertAt) + '\n' + ONBOARDING_BODY + html.slice(bodyInsertAt);
|
|
153
|
+
const headInsertAt = headAt + headAnchor.length;
|
|
154
|
+
html = html.slice(0, headInsertAt) + '\n' + ONBOARDING_HEAD + html.slice(headInsertAt);
|
|
155
|
+
|
|
156
|
+
fs.writeFileSync(shell, html);
|
|
157
|
+
ok('已补上新手引导入口 ' + rel);
|
|
158
|
+
patched++;
|
|
159
|
+
}
|
|
160
|
+
return patched;
|
|
161
|
+
}
|
|
162
|
+
|
|
100
163
|
/** 新项目 package.json 里本框架的依赖版本(已发布 npm,语义化版本管理) */
|
|
101
164
|
function kitDependencySpec() {
|
|
102
165
|
const pkg = readJson(path.join(PKG_ROOT, 'package.json'), {});
|
|
@@ -168,7 +231,7 @@ function cmdCreate(argv) {
|
|
|
168
231
|
async function cmdInit() {
|
|
169
232
|
const root = process.cwd();
|
|
170
233
|
let serviceInstallDenied = false;
|
|
171
|
-
info(C.b('\n把 openprototype
|
|
234
|
+
info(C.b('\n把 openprototype 植入当前项目(保留已有模板,按配置安装常驻服务)…\n'));
|
|
172
235
|
|
|
173
236
|
copyIfAbsent(path.join(TPL, 'skills'), path.join(root, 'skills'));
|
|
174
237
|
copyIfAbsent(path.join(TPL, 'AGENTS.md'), path.join(root, 'AGENTS.md'));
|
|
@@ -178,6 +241,8 @@ async function cmdInit() {
|
|
|
178
241
|
ok('写入 ' + CONFIG_FILENAME);
|
|
179
242
|
} else info(C.dim(' 跳过(已存在): ') + CONFIG_FILENAME);
|
|
180
243
|
|
|
244
|
+
patchShellOnboarding(root);
|
|
245
|
+
|
|
181
246
|
// 合并 package.json 脚本(不覆盖用户已有脚本)
|
|
182
247
|
const pkgPath = path.join(root, 'package.json');
|
|
183
248
|
if (fs.existsSync(pkgPath)) {
|
|
@@ -396,6 +461,9 @@ function cmdUpdate() {
|
|
|
396
461
|
info(C.b('\n更新 openprototype\n'));
|
|
397
462
|
info('运行时(服务器 / shared 引擎 / Agent 面板 / 检查脚本)随包升级:');
|
|
398
463
|
info(C.g(' npm update openprototype\n'));
|
|
464
|
+
info('产品壳(product/*/*/index.html)是脚手架时复制的,不随包升级。');
|
|
465
|
+
info('升级后跑一次下面这条,可给已有的壳补上新功能入口(幂等,已有的会跳过):');
|
|
466
|
+
info(C.g(' npx openprototype init\n'));
|
|
399
467
|
info('可编辑资产(rules / prompts / workflow / AGENTS.md)由你拥有,不会被自动覆盖。');
|
|
400
468
|
info('想同步最新模板时,对比这些目录后按需合并:');
|
|
401
469
|
info(C.dim(' node_modules/openprototype/templates/ → 你项目里的 AGENTS.md / CONVENTIONS.md / skills/'));
|
|
@@ -409,11 +477,11 @@ ${C.b('openprototype')} — 本地原型工作台脚手架
|
|
|
409
477
|
|
|
410
478
|
用法:
|
|
411
479
|
${C.g('openprototype create <dir>')} 从零创建新项目
|
|
412
|
-
${C.g('openprototype init')}
|
|
480
|
+
${C.g('openprototype init')} 补充缺失资产、合并脚本,并按配置安装常驻服务
|
|
413
481
|
${C.g('openprototype add-product <id>')} 新增一个产品壳(默认 pc)
|
|
414
482
|
${C.g('openprototype serve')} 启动本地服务器
|
|
415
483
|
${C.g('openprototype service <action>')} 管理常驻服务(install/start/stop/restart/status/logs/uninstall/prune)
|
|
416
|
-
${C.g('openprototype check [--changed]')}
|
|
484
|
+
${C.g('openprototype check [--changed]')} 自动化检查(静态红线;安装 Playwright 后增加冒烟)
|
|
417
485
|
${C.g('openprototype nav:sync')} 重建各产品 nav-tree.json
|
|
418
486
|
${C.g('openprototype doctor')} 体检(Node / OpenCode / 配置 / Playwright)
|
|
419
487
|
${C.g('openprototype update')} 如何更新框架
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openprototype",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "本地原型工作台:左侧树形导航 + 中间原型预览 + 右侧 AI Agent(OpenCode)。PRD 与 HTML/JS 原型协作,含自动化检查。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prototype",
|
|
7
|
+
"ai-prototyping",
|
|
7
8
|
"prd",
|
|
9
|
+
"product-management",
|
|
10
|
+
"html-prototype",
|
|
11
|
+
"local-first",
|
|
8
12
|
"opencode",
|
|
9
13
|
"agent",
|
|
10
14
|
"scaffold",
|
|
@@ -16,7 +20,7 @@
|
|
|
16
20
|
"type": "git",
|
|
17
21
|
"url": "git+https://github.com/lightdoodleh/openprototype.git"
|
|
18
22
|
},
|
|
19
|
-
"homepage": "https://github.
|
|
23
|
+
"homepage": "https://lightdoodleh.github.io/OpenPrototype/",
|
|
20
24
|
"bugs": "https://github.com/lightdoodleh/openprototype/issues",
|
|
21
25
|
"engines": {
|
|
22
26
|
"node": ">=16"
|
|
@@ -48,7 +52,8 @@
|
|
|
48
52
|
"proto-kit.config.json",
|
|
49
53
|
"AGENTS.md",
|
|
50
54
|
"CONVENTIONS.md",
|
|
51
|
-
"README.md"
|
|
55
|
+
"README.md",
|
|
56
|
+
"image/README/core-loop.gif"
|
|
52
57
|
],
|
|
53
58
|
"devDependencies": {
|
|
54
59
|
"playwright": "^1.49.0"
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
<!-- agent-panel:start (本地开发专用;发布时可由 openprototype publish 自动剥离) -->
|
|
8
8
|
<link rel="stylesheet" href="/_kit/shell/agent-panel.css">
|
|
9
9
|
<!-- agent-panel:end -->
|
|
10
|
+
<!-- onboarding:start (本地开发专用;发布时可由 openprototype publish 自动剥离) -->
|
|
11
|
+
<link rel="stylesheet" href="/_kit/shell/onboarding.css">
|
|
12
|
+
<!-- onboarding:end -->
|
|
10
13
|
<style>
|
|
11
14
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
12
15
|
|
|
@@ -1519,5 +1522,8 @@ window.addEventListener('DOMContentLoaded', async () => {
|
|
|
1519
1522
|
<script>window.PROTO_KIT = { productId: 'demo', productTitle: 'Demo' };</script>
|
|
1520
1523
|
<script src="/_kit/shell/agent-panel.js"></script>
|
|
1521
1524
|
<!-- agent-panel:end -->
|
|
1525
|
+
<!-- onboarding:start (本地开发专用;发布时可由 openprototype publish 自动剥离) -->
|
|
1526
|
+
<script src="/_kit/shell/onboarding.js"></script>
|
|
1527
|
+
<!-- onboarding:end -->
|
|
1522
1528
|
</body>
|
|
1523
1529
|
</html>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/* 新手引导 — 首次打开工作台时的分步气泡提示。
|
|
2
|
+
层级说明:blocker(10040) < spotlight(10050) < bubble(10060)。
|
|
3
|
+
外壳内现有最高层级是新建弹窗遮罩 10000、toast 9999,故整体压在它们之上。 */
|
|
4
|
+
|
|
5
|
+
/* 吃掉引导期间的所有点击;spotlight 自身不接收事件,靠这一层拦截 */
|
|
6
|
+
.tour-blocker {
|
|
7
|
+
position: fixed;
|
|
8
|
+
inset: 0;
|
|
9
|
+
z-index: 10040;
|
|
10
|
+
cursor: default;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* 高亮框:用一个超大扩散的 box-shadow 直接在遮罩上"挖洞",
|
|
14
|
+
省掉切四块遮罩的麻烦,且天生跟随目标矩形 */
|
|
15
|
+
.tour-spotlight {
|
|
16
|
+
position: fixed;
|
|
17
|
+
z-index: 10050;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
border-radius: 8px;
|
|
20
|
+
outline: 2px solid #1677ff;
|
|
21
|
+
outline-offset: 0;
|
|
22
|
+
box-shadow: 0 0 0 9999px rgba(16, 22, 32, 0.45);
|
|
23
|
+
transition: top 0.18s ease, left 0.18s ease, width 0.18s ease, height 0.18s ease;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tour-bubble {
|
|
27
|
+
position: fixed;
|
|
28
|
+
z-index: 10060;
|
|
29
|
+
width: 320px;
|
|
30
|
+
max-width: calc(100vw - 24px);
|
|
31
|
+
padding: 14px 16px 12px;
|
|
32
|
+
border-radius: 10px;
|
|
33
|
+
background: #fff;
|
|
34
|
+
color: #20242d;
|
|
35
|
+
font-size: 13px;
|
|
36
|
+
line-height: 1.6;
|
|
37
|
+
box-shadow: 0 8px 24px rgba(16, 22, 32, 0.18);
|
|
38
|
+
transition: top 0.18s ease, left 0.18s ease;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* 箭头:8px 实心三角,四个方向各自贴边 */
|
|
42
|
+
.tour-bubble-arrow {
|
|
43
|
+
position: absolute;
|
|
44
|
+
width: 0;
|
|
45
|
+
height: 0;
|
|
46
|
+
border: 8px solid transparent;
|
|
47
|
+
}
|
|
48
|
+
.tour-bubble-arrow.is-top {
|
|
49
|
+
bottom: -16px;
|
|
50
|
+
border-top-color: #fff;
|
|
51
|
+
}
|
|
52
|
+
.tour-bubble-arrow.is-bottom {
|
|
53
|
+
top: -16px;
|
|
54
|
+
border-bottom-color: #fff;
|
|
55
|
+
}
|
|
56
|
+
.tour-bubble-arrow.is-left {
|
|
57
|
+
right: -16px;
|
|
58
|
+
border-left-color: #fff;
|
|
59
|
+
}
|
|
60
|
+
.tour-bubble-arrow.is-right {
|
|
61
|
+
left: -16px;
|
|
62
|
+
border-right-color: #fff;
|
|
63
|
+
}
|
|
64
|
+
/* 气泡被 clamp 回视口后箭头可能指偏,此时干脆藏掉,别指错地方 */
|
|
65
|
+
.tour-bubble-arrow.is-hidden {
|
|
66
|
+
display: none;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.tour-step-index {
|
|
70
|
+
font-size: 11px;
|
|
71
|
+
color: #7b8495;
|
|
72
|
+
letter-spacing: 0.02em;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.tour-title {
|
|
76
|
+
margin: 2px 0 6px;
|
|
77
|
+
font-size: 14px;
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
color: #20242d;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.tour-body {
|
|
83
|
+
color: #4a5262;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.tour-body b {
|
|
87
|
+
color: #20242d;
|
|
88
|
+
font-weight: 600;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.tour-actions {
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
gap: 6px;
|
|
95
|
+
margin-top: 12px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.tour-actions-spacer {
|
|
99
|
+
flex: 1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.tour-btn {
|
|
103
|
+
padding: 4px 12px;
|
|
104
|
+
border: 1px solid #dfe5ee;
|
|
105
|
+
border-radius: 4px;
|
|
106
|
+
background: #fff;
|
|
107
|
+
color: #4a5262;
|
|
108
|
+
font-family: inherit;
|
|
109
|
+
font-size: 12px;
|
|
110
|
+
line-height: 1.5;
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
transition: background 0.12s, color 0.12s, border-color 0.12s;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.tour-btn:hover {
|
|
116
|
+
background: #f0f5ff;
|
|
117
|
+
border-color: #bfdbff;
|
|
118
|
+
color: #1677ff;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.tour-btn-primary {
|
|
122
|
+
border-color: #1677ff;
|
|
123
|
+
background: #1677ff;
|
|
124
|
+
color: #fff;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.tour-btn-primary:hover {
|
|
128
|
+
background: #0d5edb;
|
|
129
|
+
border-color: #0d5edb;
|
|
130
|
+
color: #fff;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.tour-skip {
|
|
134
|
+
padding: 4px 2px;
|
|
135
|
+
border: 0;
|
|
136
|
+
background: transparent;
|
|
137
|
+
color: #7b8495;
|
|
138
|
+
font-family: inherit;
|
|
139
|
+
font-size: 12px;
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.tour-skip:hover {
|
|
144
|
+
color: #1677ff;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.tour-btn:focus-visible,
|
|
148
|
+
.tour-skip:focus-visible,
|
|
149
|
+
.tour-replay-btn:focus-visible {
|
|
150
|
+
outline: 2px solid #1677ff;
|
|
151
|
+
outline-offset: 2px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* 侧栏标题行里的「?」重放入口,由 onboarding.js 运行时注入。
|
|
155
|
+
尺寸与 .copy-address-btn 对齐,保证同一行视觉齐平 */
|
|
156
|
+
.tour-replay-btn {
|
|
157
|
+
flex-shrink: 0;
|
|
158
|
+
width: 24px;
|
|
159
|
+
height: 24px;
|
|
160
|
+
padding: 0;
|
|
161
|
+
border: 1px solid #dfe5ee;
|
|
162
|
+
border-radius: 50%;
|
|
163
|
+
background: #fff;
|
|
164
|
+
color: #7b8495;
|
|
165
|
+
font-family: inherit;
|
|
166
|
+
font-size: 12px;
|
|
167
|
+
line-height: 1;
|
|
168
|
+
cursor: pointer;
|
|
169
|
+
transition: background 0.12s, color 0.12s, border-color 0.12s;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.tour-replay-btn:hover {
|
|
173
|
+
background: #edf6ff;
|
|
174
|
+
border-color: #1677ff;
|
|
175
|
+
color: #1677ff;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* 低动效偏好下去掉位移过渡,避免引导跳来跳去引起不适 */
|
|
179
|
+
@media (prefers-reduced-motion: reduce) {
|
|
180
|
+
.tour-spotlight,
|
|
181
|
+
.tour-bubble {
|
|
182
|
+
transition: none;
|
|
183
|
+
}
|
|
184
|
+
}
|