@tbox.cn/app-build 1.0.0-alpha.1 → 1.0.0-alpha.11

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,14 +1,22 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-build",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.11",
4
4
  "type": "module",
5
- "description": "tbox-app 1.0 build-time leaf: scan apps/ modules/ and generate manifest, registries, documents; Vite plugin, checks and AGENTS composition.",
5
+ "description": "tbox-app 1.0 build-time leaf: scan apps/ modules/ and generate manifest, registries, documents; Vite plugin and checks.",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./dist/index.d.ts",
9
9
  "import": "./dist/index.js"
10
10
  },
11
- "./package.json": "./package.json"
11
+ "./package.json": "./package.json",
12
+ "./tailwind-sources": {
13
+ "types": "./tailwind-sources.d.mts",
14
+ "import": "./tailwind-sources.mjs"
15
+ },
16
+ "./compat": {
17
+ "types": "./compat.d.mts",
18
+ "import": "./compat.mjs"
19
+ }
12
20
  },
13
21
  "publishConfig": {
14
22
  "access": "public"
@@ -35,9 +43,12 @@
35
43
  },
36
44
  "files": [
37
45
  "dist",
38
- "agents",
46
+ "tailwind-sources.mjs",
47
+ "tailwind-sources.d.mts",
39
48
  "README.md",
40
- "LICENSE"
49
+ "LICENSE",
50
+ "compat.mjs",
51
+ "compat.d.mts"
41
52
  ],
42
53
  "license": "MIT",
43
54
  "scripts": {
@@ -0,0 +1,2 @@
1
+ export function collectModuleSourceDirs(appRoot: string): string[];
2
+ export function renderModuleSources(dirs: string[]): string;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Tailwind 模块源码发现:dev/build 的 Vite 插件与证据包 surface-css 共用。
3
+ *
4
+ * 只登记有 src/client/index.ts 的客户端模块,扫描其 src/client/;显式绝对路径——
5
+ * Tailwind 的 @source 不跟随通配符路径(对 pnpm 软链不生效)。
6
+ */
7
+ import { existsSync, readdirSync, realpathSync, statSync } from 'node:fs';
8
+ import path from 'node:path';
9
+
10
+ const MODULE_ROOTS = [
11
+ { dir: 'modules', prefixes: ['module-'] },
12
+ { dir: 'apps/client/node_modules/@tbox.cn', prefixes: ['app-module-', 'module-'] },
13
+ ];
14
+
15
+ /**
16
+ * @param {string} appRoot
17
+ * @returns {string[]} 模块源码目录(绝对路径,已排序/去重)
18
+ */
19
+ export function collectModuleSourceDirs(appRoot) {
20
+ const root = path.resolve(appRoot);
21
+ const seen = new Set();
22
+ const out = [];
23
+
24
+ for (const { dir, prefixes } of MODULE_ROOTS) {
25
+ const base = path.join(root, dir);
26
+ if (!existsSync(base)) continue;
27
+ for (const name of readdirSync(base).sort()) {
28
+ if (!prefixes.some((prefix) => name.startsWith(prefix))) continue;
29
+ const moduleDir = path.join(base, name);
30
+ const clientDir = path.join(moduleDir, 'src/client');
31
+ let real;
32
+ try {
33
+ if (!statSync(moduleDir).isDirectory()) continue;
34
+ if (!existsSync(path.join(clientDir, 'index.ts'))) continue;
35
+ real = realpathSync(clientDir);
36
+ } catch {
37
+ continue;
38
+ }
39
+ if (seen.has(real)) continue;
40
+ seen.add(real);
41
+ out.push(clientDir);
42
+ }
43
+ }
44
+ return out.sort();
45
+ }
46
+
47
+ /**
48
+ * @param {string[]} dirs
49
+ * @returns {string} 可拼进任意 Tailwind 入口 CSS 的 @source 行
50
+ */
51
+ export function renderModuleSources(dirs) {
52
+ return dirs
53
+ .map((dir) => `@source ${JSON.stringify(dir.split(path.sep).join('/'))};`)
54
+ .join('\n');
55
+ }
@@ -1,5 +0,0 @@
1
- ## agent 面
2
-
3
- - 工具单文件:`apps/server/src/tools/*.tool.ts`。
4
- - 卡片双文件:`apps/server/src/cards/*.card.ts` + `apps/client/src/cards/*.card.tsx`。
5
- - 卡片预览页由构建生成,不要手写。
@@ -1,8 +0,0 @@
1
- # 应用代码
2
-
3
- - 页面:`apps/client/src/pages/**/page.tsx`。
4
- - 函数:`apps/server/src/functions/*.server.ts`,直接 import 使用。
5
- - HTTP:`request`;不要新增第二套 HTTP 客户端。
6
- - 共享 DTO:`packages/shared/`,导入 `@app/shared`。
7
- - 构建产物:`apps/client/dist`(部署静态根)、`apps/server/dist`。
8
- - 不要手写路由表;页面目录就是路由。
package/agents/app-web.md DELETED
@@ -1,4 +0,0 @@
1
- ## web 面
2
-
3
- - 不创建 agent 目录。
4
- - 页面只依赖 `@tbox.cn/app-sdk-client` 与共享 DTO。
package/agents/base.md DELETED
@@ -1,12 +0,0 @@
1
- # tbox-app
2
-
3
- 这是一个 tbox-app 1.0 应用。应用代码根是 `apps/`(`apps/client` + `apps/server`)。
4
-
5
- - `apps/client/src/pages/**/page.tsx`:页面;目录即 URL;页面元数据用 inline `export const page`。
6
- - `apps/server/src/functions/*.server.ts`:函数;文件名即 `/api/fn/<id>`。
7
- - `apps/server/src/tools/*.tool.ts`、`skills/*.skill.ts`、`cards/*.card.ts`:应用级原语(仅 agent)。
8
- - `packages/shared/`:跨端 DTO(`@app/shared`),只放纯类型与常量。
9
- - `modules/<id>/`:可复用/可分发模块;必须有 `tbox.module.json`。
10
- - 不要创建 `app/`、`apps/client/src/modules.ts`、`routes.json`、`page.config.jsonc`。
11
-
12
- 修改后先运行 `pnpm check`,再按需运行 `pnpm typecheck`。
@@ -1,5 +0,0 @@
1
- ## 应用类型:agent
2
-
3
- 本应用可以包含页面、函数、工具、技能、卡片与卡片预览。卡片必须双端成对;工具/技能/卡片使用 app 级原语,只有需要复用或分发时才放入 `modules/<id>`。
4
-
5
- `agent-ui-kit` 是普通 npm 依赖,不要把它当模块。
@@ -1,3 +0,0 @@
1
- ## 应用类型:web
2
-
3
- 本应用只有页面、函数与共享 DTO。不要创建 `tools/`、`skills/`、`cards/`,不要引入 agent SDK 或卡片预览。
package/agents/modules.md DELETED
@@ -1,9 +0,0 @@
1
- # 模块
2
-
3
- 模块只在需要复用、分发或自定义安装后源码时创建。
4
-
5
- - 本地模块:`modules/<id>/`,无 `package.json`。
6
- - Vendored 模块:`modules/<id>/`,有 `package.json` 与 `tbox.upstream`。
7
- - 两种模块都必须有 `tbox.module.json`。
8
- - 模块入口:`src/server/index.ts` 导出 `serverModule`;`src/client/index.ts` 导出 `clientModule`。
9
- - 模块只注册,不解析;跨模块经 `ctx`。