@tbox.cn/app-template-h5 1.0.0-alpha.1 → 1.0.0-alpha.6

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.
Files changed (63) hide show
  1. package/._.gitignore +0 -0
  2. package/._.npmignore +0 -0
  3. package/._.nvmrc +0 -0
  4. package/._AGENTS.md +0 -0
  5. package/._LEGAL.md +0 -0
  6. package/._LICENSE +0 -0
  7. package/._README.md +0 -0
  8. package/._eslint.config.mjs +0 -0
  9. package/._package.json +0 -0
  10. package/._pnpm-lock.template.yaml +0 -0
  11. package/._pnpm-workspace.template.yaml +0 -0
  12. package/._tsconfig.base.json +0 -0
  13. package/.gitignore +2 -1
  14. package/.tbox/._app.json +0 -0
  15. package/.tbox/app.json +1 -1
  16. package/AGENTS.md +16 -10
  17. package/README.md +0 -1
  18. package/apps/._AGENTS.md +0 -0
  19. package/apps/AGENTS.md +2 -6
  20. package/apps/client/._index.html +0 -0
  21. package/apps/client/._package.json +0 -0
  22. package/apps/client/._tsconfig.json +0 -0
  23. package/apps/client/._vite.config.ts +0 -0
  24. package/apps/client/._vitest.config.ts +0 -0
  25. package/apps/client/package.json +3 -1
  26. package/apps/client/src/._app.config.ts +0 -0
  27. package/apps/client/src/._vite-env.d.ts +0 -0
  28. package/apps/client/src/app.config.ts +10 -0
  29. package/apps/client/src/pages/._page.tsx +0 -0
  30. package/apps/client/src/pages/page.tsx +9 -5
  31. package/apps/client/src/styles/._tailwind.css +0 -0
  32. package/apps/client/src/styles/tailwind.css +101 -0
  33. package/apps/client/vite.config.ts +2 -1
  34. package/apps/server/._package.json +0 -0
  35. package/apps/server/._tsconfig.json +0 -0
  36. package/apps/server/._tsup.config.ts +0 -0
  37. package/apps/server/._vitest.config.ts +0 -0
  38. package/apps/server/src/._app.ts +0 -0
  39. package/apps/server/src/._dev.ts +0 -0
  40. package/apps/server/src/._index.ts +0 -0
  41. package/apps/server/src/dev.ts +2 -2
  42. package/apps/server/src/functions/._greet.server.ts +0 -0
  43. package/apps/server/src/index.ts +2 -2
  44. package/apps/server/tests/._app.test.ts +0 -0
  45. package/modules/._.gitkeep +0 -0
  46. package/package.json +5 -7
  47. package/packages/shared/._AGENTS.md +0 -0
  48. package/packages/shared/._package.json +0 -0
  49. package/packages/shared/._tsconfig.json +0 -0
  50. package/packages/shared/src/._index.ts +0 -0
  51. package/pnpm-lock.template.yaml +529 -171
  52. package/pnpm-workspace.template.yaml +10 -8
  53. package/scripts/._build.sh +0 -0
  54. package/scripts/._check.mjs +0 -0
  55. package/scripts/._dev.sh +0 -0
  56. package/scripts/._generate.mjs +0 -0
  57. package/scripts/._start.sh +0 -0
  58. package/scripts/._stop.sh +0 -0
  59. package/apps/client/src/platform/bootstrap.ts +0 -11
  60. package/apps/client/src/platform/mount-page.tsx +0 -26
  61. package/apps/client/src/styles/base.css +0 -21
  62. package/scripts/agents-check.mjs +0 -23
  63. package/scripts/agents-sync.mjs +0 -9
package/._.gitignore ADDED
Binary file
package/._.npmignore ADDED
Binary file
package/._.nvmrc ADDED
Binary file
package/._AGENTS.md ADDED
Binary file
package/._LEGAL.md ADDED
Binary file
package/._LICENSE ADDED
Binary file
package/._README.md ADDED
Binary file
Binary file
package/._package.json ADDED
Binary file
Binary file
Binary file
Binary file
package/.gitignore CHANGED
@@ -8,7 +8,8 @@ dist-ssr
8
8
  *.log
9
9
  .pnpm-store
10
10
 
11
- apps/client/.tbox-gen
11
+ # 客户端生成 IR(构建期 disposable——可删除重建;勿手写、勿提交)
12
+ apps/client/.tbox-gen/
12
13
  .tbox-dist-staging-*
13
14
  .tbox-dist-backup-*
14
15
 
Binary file
package/.tbox/app.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "appKind": "web",
4
- "templateVersion": "1.0.0-alpha.1"
4
+ "templateVersion": "1.0.0-alpha.6"
5
5
  }
package/AGENTS.md CHANGED
@@ -1,25 +1,31 @@
1
1
  # tbox-app 1.0 Web 应用
2
2
 
3
- 这是一个 `appKind: web` 应用。应用代码根是 `apps/`(`apps/client` + `apps/server`)。
4
-
5
- <!-- tbox:agents:begin -->
6
- # tbox-app
7
-
8
- 这是一个 tbox-app 1.0 应用。应用代码根是 `apps/`(`apps/client` + `apps/server`)。
3
+ 这是一个 tbox-app 1.0 Web 全栈应用(`app.json` 的 `appKind` 为 `web`)。应用代码根是 `apps/`(`apps/client` + `apps/server`)。
9
4
 
10
5
  - `apps/client/src/pages/**/page.tsx`:页面;目录即 URL;页面元数据用 inline `export const page`。
6
+ - `apps/client/src/app.config.ts`:客户端装配真源(样式入口/apiBaseUrl);生成 entry 第一个 import 它。
7
+ - 样式只写 Tailwind 工具类(入口 `apps/client/src/styles/tailwind.css`:语义色 + 4px 标度 + px 圆角/字号;不引 preflight,不新建样式文件)。
8
+ - `.tbox-gen` 是生成 IR:不要手写、不要 import;默认不要创建 `apps/client/src/entry.tsx`。
11
9
  - `apps/server/src/functions/*.server.ts`:函数;文件名即 `/api/fn/<id>`。
12
- - `apps/server/src/tools/*.tool.ts`、`skills/*.skill.ts`、`cards/*.card.ts`:应用级原语(仅 agent)。
13
10
  - `packages/shared/`:跨端 DTO(`@app/shared`),只放纯类型与常量。
14
11
  - `modules/<id>/`:可复用/可分发模块;必须有 `tbox.module.json`。
15
12
  - 不要创建 `app/`、`apps/client/src/modules.ts`、`routes.json`、`page.config.jsonc`。
16
13
 
17
- 修改后先运行 `pnpm check`,再按需运行 `pnpm typecheck`。
14
+ 修改后先运行 `pnpm check`,再按需运行 `pnpm typecheck`。沙箱/无端口环境不要跑 `pnpm dev`/`pnpm build`(长驻进程 + Vite + 端口)。
18
15
 
19
16
  ## 应用类型:web
20
17
 
21
- 本应用只有页面、函数与共享 DTO。不要创建 `tools/`、`skills/`、`cards/`,不要引入 agent SDK 或卡片预览。
22
- <!-- tbox:agents:end -->
18
+ 本应用只有页面、函数与共享 DTO。不要创建 `tools/`、`skills/`、`cards/`,不要引入 agent-sdk 系列包或卡片预览——本应用不是对话式 agent 应用。
19
+
20
+ ## 模块
21
+
22
+ 模块只在需要复用、分发或自定义安装后源码时创建。
23
+
24
+ - 本地模块:`modules/<id>/`,无 `package.json`。
25
+ - Vendored 模块:`modules/<id>/`,有 `package.json` 与 `tbox.upstream`。
26
+ - 两种模块都必须有 `tbox.module.json`。
27
+ - 模块入口:`src/server/index.ts` 导出 `serverModule`;`src/client/index.ts` 导出 `clientModule`。
28
+ - 模块只注册,不解析;跨模块经 `ctx`。
23
29
 
24
30
  ## 端形态决策
25
31
 
package/README.md CHANGED
@@ -31,7 +31,6 @@ modules/<id>/ # A-lite 模块
31
31
  pnpm check
32
32
  pnpm typecheck
33
33
  pnpm build
34
- pnpm agents:check
35
34
  ```
36
35
 
37
36
  `pnpm build` 生成 `apps/client/.tbox-gen`,再构建 `apps/client/dist` 与 `apps/server/dist`。生产启动 `pnpm start`。
Binary file
package/apps/AGENTS.md CHANGED
@@ -1,9 +1,6 @@
1
1
  # 应用代码
2
2
 
3
- <!-- tbox:agents:begin -->
4
- # 应用代码
5
-
6
- - 页面:`apps/client/src/pages/**/page.tsx`。
3
+ - 页面:`apps/client/src/pages/**/page.tsx`;客户端装配真源是 `apps/client/src/app.config.ts`。
7
4
  - 函数:`apps/server/src/functions/*.server.ts`,直接 import 使用。
8
5
  - HTTP:`request`;不要新增第二套 HTTP 客户端。
9
6
  - 共享 DTO:`packages/shared/`,导入 `@app/shared`。
@@ -12,6 +9,5 @@
12
9
 
13
10
  ## web 面
14
11
 
15
- - 不创建 agent 目录。
12
+ - 不创建 agent 应用专属目录(`tools/`、`skills/`、`cards/`)。
16
13
  - 页面只依赖 `@tbox.cn/app-sdk-client` 与共享 DTO。
17
- <!-- tbox:agents:end -->
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -21,6 +21,8 @@
21
21
  "happy-dom": "catalog:",
22
22
  "typescript": "catalog:",
23
23
  "vite": "catalog:",
24
- "vitest": "catalog:"
24
+ "vitest": "catalog:",
25
+ "tailwindcss": "catalog:",
26
+ "@tailwindcss/vite": "catalog:"
25
27
  }
26
28
  }
Binary file
Binary file
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 客户端装配真源:样式入口(tailwind.css:投影 + 文档级重置)+ 环境值。
3
+ * 页面由生成 entry 经 startApp 挂载;错误边界/启动兜底由 SDK 统一提供。
4
+ */
5
+ import type { AppConfig } from '@tbox.cn/app-sdk-client/app';
6
+ import './styles/tailwind.css';
7
+
8
+ export default {
9
+ apiBaseUrl: import.meta.env.VITE_API_URL as string | undefined,
10
+ } satisfies AppConfig;
Binary file
@@ -21,13 +21,17 @@ export default function HomePage() {
21
21
  }
22
22
 
23
23
  return (
24
- <main style={{ padding: 32, maxWidth: 720, margin: '0 auto' }}>
25
- <h1>tbox-app</h1>
26
- <p>页面即路由,函数即接口。</p>
27
- <button type="button" onClick={() => void callGreet()}>
24
+ <main className="mx-auto max-w-content px-8 py-8">
25
+ <h1 className="text-2xl font-semibold">tbox-app</h1>
26
+ <p className="mt-2 text-sm text-muted-foreground">页面即路由,函数即接口。</p>
27
+ <button
28
+ type="button"
29
+ className="mt-4 cursor-pointer rounded-md border-0 bg-primary px-4 py-2 text-sm font-medium text-primary-foreground [font-family:inherit] hover:bg-primary-dark"
30
+ onClick={() => void callGreet()}
31
+ >
28
32
  调用 greet
29
33
  </button>
30
- {message ? <p role="status">{message}</p> : null}
34
+ {message ? <p role="status" className="mt-4 rounded-md border border-border bg-card px-3 py-2 text-sm">{message}</p> : null}
31
35
  </main>
32
36
  );
33
37
  }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Tailwind 入口(与 agent 两个模板同一形态):只引 theme 与 utilities,不引 preflight。
3
+ *
4
+ * - 本模板是 Web 全栈(无设计契约),故在此定义一套最小语义色板;工具类是唯一写法;
5
+ * - 圆角/字号命名空间先清空再用 px 补齐(默认档位是 rem);
6
+ * - `@layer base` 只保留文档级重置(原 styles/base.css),组件样式一律写工具类。
7
+ */
8
+ /* 显式层序:base 层(基座重置)必须在 utilities 之前,工具类才能覆写它 */
9
+ @layer theme, base, components, utilities;
10
+
11
+ @import "tailwindcss/theme.css" layer(theme) theme(reference);
12
+ @import "tailwindcss/utilities.css" layer(utilities) source(none);
13
+
14
+ @source "../../src";
15
+
16
+ @theme inline {
17
+ /* 颜色:清空默认调色板,只留语义名(改品牌只改这里或覆写 --color-*) */
18
+ --color-*: initial;
19
+ --color-background: #f7f8fa;
20
+ --color-foreground: #1f2329;
21
+ --color-card: #ffffff;
22
+ --color-muted: #f2f3f5;
23
+ --color-muted-foreground: #646a73;
24
+ --color-border: #e5e6eb;
25
+ --color-primary: #1677ff;
26
+ --color-primary-dark: #0958d9;
27
+ --color-primary-foreground: #ffffff;
28
+ --color-destructive: #d4380d;
29
+ --color-success: #14804a;
30
+ --color-warning: #a65f00;
31
+
32
+ /* 圆角:物理 px 阶梯(禁 rem) */
33
+ --radius-*: initial;
34
+ --radius-xs: 4px;
35
+ --radius-sm: 6px;
36
+ --radius-md: 8px;
37
+ --radius-lg: 12px;
38
+ --radius-xl: 16px;
39
+ --radius-2xl: 20px;
40
+ --radius-3xl: 24px;
41
+
42
+ /* 间距:1 单位 = 4px */
43
+ /* 断点用 px:默认档位是 rem,会被宿主入口的动态根字号放大(40rem 会变成 2000px) */
44
+ --breakpoint-sm: 640px;
45
+ --breakpoint-md: 768px;
46
+ --breakpoint-lg: 1024px;
47
+ --breakpoint-xl: 1280px;
48
+ --breakpoint-2xl: 1536px;
49
+
50
+ --spacing: 4px;
51
+
52
+ /* 字号:清空命名空间后用 px 补齐,档位 12/14/16/18/20/24/30/36 */
53
+ --text-*: initial;
54
+ --text-xs: 12px;
55
+ --text-xs--line-height: 1.5;
56
+ --text-sm: 14px;
57
+ --text-sm--line-height: 1.5;
58
+ --text-base: 16px;
59
+ --text-base--line-height: 1.5;
60
+ --text-lg: 18px;
61
+ --text-lg--line-height: 1.5;
62
+ --text-xl: 20px;
63
+ --text-xl--line-height: 1.4;
64
+ --text-2xl: 24px;
65
+ --text-2xl--line-height: 1.35;
66
+ --text-3xl: 30px;
67
+ --text-3xl--line-height: 1.2;
68
+ --text-4xl: 36px;
69
+ --text-4xl--line-height: 1.2;
70
+
71
+ --container-content: 720px;
72
+ }
73
+
74
+ /* 文档级重置(原 styles/base.css):只放 html/body/#root,不放组件样式 */
75
+ @layer base {
76
+ :root {
77
+ color-scheme: light;
78
+ }
79
+
80
+ * {
81
+ box-sizing: border-box;
82
+ }
83
+
84
+ html,
85
+ body,
86
+ #root {
87
+ min-height: 100%;
88
+ margin: 0;
89
+ }
90
+
91
+ body {
92
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
93
+ color: var(--color-foreground);
94
+ background: var(--color-background);
95
+ }
96
+
97
+ /* preflight 未引入:标题与段落统一归零,间距交给工具类 */
98
+ h1, h2, h3, h4, h5, h6, p, dl, dd, dt, ul, ol {
99
+ margin: 0;
100
+ }
101
+ }
@@ -2,6 +2,7 @@ import { existsSync } from 'node:fs';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import { defineConfig } from 'vite';
4
4
  import react from '@vitejs/plugin-react';
5
+ import tailwindcss from '@tailwindcss/vite';
5
6
  import { tboxAppPlugin } from '@tbox.cn/app-build';
6
7
 
7
8
  const clientRoot = fileURLToPath(new URL('.', import.meta.url));
@@ -10,7 +11,7 @@ const repoModules = fileURLToPath(new URL('../../../../node_modules', import.met
10
11
 
11
12
  export default defineConfig({
12
13
  root: clientRoot,
13
- plugins: [react(), tboxAppPlugin({ root: fileURLToPath(new URL('../..', import.meta.url)) })],
14
+ plugins: [tboxAppPlugin({ root: fileURLToPath(new URL('../..', import.meta.url)) }), tailwindcss(), react()],
14
15
  resolve: {
15
16
  alias: {
16
17
  react: fileURLToPath(new URL('./node_modules/react', import.meta.url)),
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -10,10 +10,10 @@ const root = path.resolve(here, '../../..');
10
10
  const clientDir = path.join(root, 'apps', 'client');
11
11
 
12
12
  const generated = await generateApp({ root, watch: true });
13
- const [{ registry }, { appKind }] = await Promise.all([
13
+ const [{ registry }] = await Promise.all([
14
14
  import('../../client/.tbox-gen/registry.server.ts'),
15
- import('../../client/.tbox-gen/app-kind.ts'),
16
15
  ]);
16
+ const { appKind } = generated;
17
17
 
18
18
  const httpServer = createServer();
19
19
  const vite = await createViteServer({
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import { createApp, start, type AppManifest } from '@tbox.cn/app-sdk-server';
4
4
  import manifest from '../../client/.tbox-gen/manifest.json';
5
- import { appKind } from '../../client/.tbox-gen/app-kind';
5
+ import appMeta from '../../../.tbox/app.json';
6
6
  import { registry } from '../../client/.tbox-gen/registry.server';
7
7
 
8
8
  const here = path.dirname(fileURLToPath(import.meta.url));
@@ -10,7 +10,7 @@ const clientDir = path.resolve(here, '../../client/dist');
10
10
 
11
11
  const app = await createApp({
12
12
  manifest: manifest as AppManifest,
13
- appKind,
13
+ appKind: appMeta.appKind as 'web',
14
14
  registry,
15
15
  mode: 'prod',
16
16
  clientDir,
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-template-h5",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.6",
4
4
  "type": "module",
5
5
  "description": "tbox-app 1.0 Web 全栈模板:apps/client + apps/server 唯一应用代码根 + modules/ 源码根;appKind=web。",
6
6
  "engines": {
@@ -39,9 +39,9 @@
39
39
  "express": "4.22.2"
40
40
  },
41
41
  "devDependencies": {
42
- "@tbox.cn/app-build": "1.0.0-alpha.1",
43
- "@tbox.cn/app-sdk-client": "1.0.0-alpha.1",
44
- "@tbox.cn/app-sdk-server": "1.0.0-alpha.1",
42
+ "@tbox.cn/app-build": "1.0.0-alpha.6",
43
+ "@tbox.cn/app-sdk-client": "1.0.0-alpha.6",
44
+ "@tbox.cn/app-sdk-server": "1.0.0-alpha.6",
45
45
  "@types/node": "24.13.3",
46
46
  "@vitejs/plugin-react": "4.7.0",
47
47
  "eslint": "9.39.5",
@@ -59,9 +59,7 @@
59
59
  "test": "pnpm -r --filter \"./apps/*\" test",
60
60
  "lint": "eslint apps packages scripts",
61
61
  "check": "node scripts/check.mjs",
62
- "agents:sync": "node scripts/agents-sync.mjs",
63
- "agents:check": "node scripts/agents-check.mjs",
64
- "verify:fast": "pnpm typecheck && pnpm test && pnpm check && pnpm agents:check",
62
+ "verify:fast": "pnpm typecheck && pnpm test && pnpm check",
65
63
  "verify": "pnpm verify:fast && pnpm build"
66
64
  }
67
65
  }
Binary file
Binary file
Binary file
Binary file