@steerable/agent-shell-web 0.6.16 → 0.6.17

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": "@steerable/agent-shell-web",
3
- "version": "0.6.16",
3
+ "version": "0.6.17",
4
4
  "type": "module",
5
5
  "description": "Steerable framework — product-neutral renderer SPA source for @steerable/agent-shell (React + Vite). Consumed by product web entry points via the `@/` alias (anchored at this package's src/) and the createProductViteConfig factory. Published as a source package (src/ + vite.base.ts), not a build artifact.",
6
6
  "license": "Apache-2.0",
@@ -14,7 +14,10 @@
14
14
  "url": "https://github.com/pathlyapp/steerable-framework/issues"
15
15
  },
16
16
  "exports": {
17
- "./vite.base": "./vite.base.ts",
17
+ "./vite.base": {
18
+ "types": "./vite.base.d.ts",
19
+ "default": "./vite.base.js"
20
+ },
18
21
  "./package.json": "./package.json"
19
22
  },
20
23
  "files": [
@@ -22,7 +25,8 @@
22
25
  "!src/**/*.test.ts",
23
26
  "!src/**/*.test.tsx",
24
27
  "public",
25
- "vite.base.ts",
28
+ "vite.base.js",
29
+ "vite.base.d.ts",
26
30
  "README.md"
27
31
  ],
28
32
  "publishConfig": {
@@ -45,9 +49,9 @@
45
49
  "remark-gfm": "^4.0.1",
46
50
  "tailwindcss": "^4.3.0",
47
51
  "vite": "^5.4.21",
48
- "@steerable/agent-protocol": "0.6.16",
49
- "@steerable/pack-sdk": "0.6.16",
50
- "@steerable/agent-ui": "0.6.16"
52
+ "@steerable/agent-protocol": "0.6.17",
53
+ "@steerable/agent-ui": "0.6.17",
54
+ "@steerable/pack-sdk": "0.6.17"
51
55
  },
52
56
  "devDependencies": {
53
57
  "@testing-library/react": "^16.1.0",
@@ -59,7 +63,8 @@
59
63
  },
60
64
  "scripts": {
61
65
  "gen": "echo agent-shell-web",
62
- "build": "tsc --noEmit",
66
+ "build": "tsc --noEmit && npm run build:vite-base",
67
+ "build:vite-base": "tsc vite.base.ts --module esnext --target es2022 --moduleResolution bundler --declaration --skipLibCheck --outDir .",
63
68
  "typecheck": "tsc --noEmit",
64
69
  "test": "vitest run",
65
70
  "lint": "tsc --noEmit",
package/vite.base.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export interface ProductViteConfigOptions {
2
+ /** 产品目录(products/<id>/web 的上一级…即 products/<id>)。 */
3
+ productDir: string;
4
+ /** 产品 flavor(决定品牌 define 与激活包集合)。 */
5
+ flavor: string;
6
+ }
7
+ export declare function createProductViteConfig(options: ProductViteConfigOptions): import("vite").UserConfig;
package/vite.base.js ADDED
@@ -0,0 +1,83 @@
1
+ /**
2
+ * 产品 web 构建的共享 vite 配置工厂(2.3)。
3
+ *
4
+ * 每个产品(products/<id>/web/)有自己的 vite 入口:index.html +
5
+ * main.tsx(静态注册本产品的包渲染层贡献)+ vite.config.ts(调本工厂)。
6
+ * 产品的编译单元只含自己的包——未激活包代码不进 bundle,不依赖树摇
7
+ * 正确性(物理隔离与 node 侧对称)。
8
+ *
9
+ * Electron 加载产物时走 file:// 协议,必须用相对路径,否则资源 404。
10
+ * dev server 跑在固定端口,主进程的 IS_DEV 分支 loadURL('http://localhost:5173')。
11
+ */
12
+ import { defineConfig } from 'vite';
13
+ import react from '@vitejs/plugin-react';
14
+ import tailwindcss from '@tailwindcss/vite';
15
+ import path from 'node:path';
16
+ import { fileURLToPath } from 'node:url';
17
+ import { existsSync, readFileSync } from 'node:fs';
18
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
19
+ export function createProductViteConfig(options) {
20
+ const { productDir, flavor } = options;
21
+ const repoRoot = path.resolve(productDir, '../..');
22
+ // shell 渲染层源码锚到本包自身(3.2 起住在框架仓库
23
+ // packages/agent-shell/web/src),产品经 `@/` 别名引用。
24
+ const webSrcDir = path.resolve(HERE, 'src');
25
+ const readJson = (p) => JSON.parse(readFileSync(p, 'utf8'));
26
+ // 产品品牌(3.1):product.json 的 brand 字段优先(无包产品的品牌
27
+ // 来源);否则取激活包 pack.json 的 brand(0.3g 机制,读
28
+ // products/manifest.json 的 flavor→包映射,第一个带 brand 的包)。
29
+ // 都没有则用 shell 中性默认(Agent Shell)。
30
+ const productJsonPath = path.join(productDir, 'product.json');
31
+ const product = existsSync(productJsonPath) ? readJson(productJsonPath) : {};
32
+ const manifest = readJson(path.join(repoRoot, 'products/manifest.json'));
33
+ let packBrand = null;
34
+ for (const packId of manifest.flavors?.[flavor] ?? []) {
35
+ const pack = readJson(path.join(repoRoot, 'packages', `pack-${packId}`, 'pack.json'));
36
+ if (pack.brand) {
37
+ packBrand = pack.brand;
38
+ break;
39
+ }
40
+ }
41
+ const brand = product.brand ?? packBrand;
42
+ return defineConfig({
43
+ // root 默认取 config 文件所在目录(products/<id>/web)。
44
+ base: './',
45
+ plugins: [react(), tailwindcss()],
46
+ define: {
47
+ // 显式 define 让 flavor 条件在构建期可静态折叠。
48
+ 'import.meta.env.VITE_APP_FLAVOR': JSON.stringify(flavor),
49
+ // 品牌 define:产品/包声明覆盖 shell 中性默认(Agent Shell)。
50
+ // logo 不走 define——资产必须静态 import 才进 bundle,由包 web 模块
51
+ // 在注册时经 setBrandLogoUrl 注入(本包 src/brand.ts)。
52
+ 'import.meta.env.VITE_BRAND_NAME': JSON.stringify(brand?.displayName ?? 'Steerable Shell'),
53
+ 'import.meta.env.VITE_BRAND_TAGLINE': JSON.stringify(brand?.tagline ?? '一款本地桌面 AI 伙伴'),
54
+ 'import.meta.env.VITE_DEFAULT_AGENT_ID': JSON.stringify(brand?.defaultAgentId ?? 'local-assistant'),
55
+ },
56
+ resolve: {
57
+ alias: {
58
+ // shell 渲染层源码(产品入口与包 web 模块都以 `@/` 引用它)。
59
+ '@': webSrcDir,
60
+ },
61
+ },
62
+ // 静态资产(favicon 等中性默认)随 shell web 包分发;产品可在自己的
63
+ // web root 放 public/ 覆盖(vite 不合并双 publicDir——需要产品级资产
64
+ // 时在产品 vite.config 里显式覆盖本字段)。
65
+ publicDir: path.resolve(HERE, 'public'),
66
+ server: {
67
+ port: 5173,
68
+ strictPort: true,
69
+ host: '127.0.0.1',
70
+ // 产品 root 在 products/<id>/web;shell 渲染层源码在框架仓库
71
+ // (3.2 起经 file: 依赖符号链接)——两个根都放行。
72
+ fs: { allow: [repoRoot, path.resolve(webSrcDir, '..')] },
73
+ },
74
+ build: {
75
+ // 产物落在产品目录:products/<id>/web/dist(打包期被 electron-builder
76
+ // 映射为包内 web-dist/)。
77
+ outDir: 'dist',
78
+ emptyOutDir: true,
79
+ sourcemap: true,
80
+ target: 'chrome120',
81
+ },
82
+ });
83
+ }
package/vite.base.ts DELETED
@@ -1,94 +0,0 @@
1
- /**
2
- * 产品 web 构建的共享 vite 配置工厂(2.3)。
3
- *
4
- * 每个产品(products/<id>/web/)有自己的 vite 入口:index.html +
5
- * main.tsx(静态注册本产品的包渲染层贡献)+ vite.config.ts(调本工厂)。
6
- * 产品的编译单元只含自己的包——未激活包代码不进 bundle,不依赖树摇
7
- * 正确性(物理隔离与 node 侧对称)。
8
- *
9
- * Electron 加载产物时走 file:// 协议,必须用相对路径,否则资源 404。
10
- * dev server 跑在固定端口,主进程的 IS_DEV 分支 loadURL('http://localhost:5173')。
11
- */
12
- import { defineConfig } from 'vite';
13
- import react from '@vitejs/plugin-react';
14
- import tailwindcss from '@tailwindcss/vite';
15
- import path from 'node:path';
16
- import { fileURLToPath } from 'node:url';
17
- import { existsSync, readFileSync } from 'node:fs';
18
-
19
- const HERE = path.dirname(fileURLToPath(import.meta.url));
20
-
21
- export interface ProductViteConfigOptions {
22
- /** 产品目录(products/<id>/web 的上一级…即 products/<id>)。 */
23
- productDir: string;
24
- /** 产品 flavor(决定品牌 define 与激活包集合)。 */
25
- flavor: string;
26
- }
27
-
28
- export function createProductViteConfig(options: ProductViteConfigOptions) {
29
- const { productDir, flavor } = options;
30
- const repoRoot = path.resolve(productDir, '../..');
31
- // shell 渲染层源码锚到本包自身(3.2 起住在框架仓库
32
- // packages/agent-shell/web/src),产品经 `@/` 别名引用。
33
- const webSrcDir = path.resolve(HERE, 'src');
34
- const readJson = (p: string) => JSON.parse(readFileSync(p, 'utf8'));
35
-
36
- // 产品品牌(3.1):product.json 的 brand 字段优先(无包产品的品牌
37
- // 来源);否则取激活包 pack.json 的 brand(0.3g 机制,读
38
- // products/manifest.json 的 flavor→包映射,第一个带 brand 的包)。
39
- // 都没有则用 shell 中性默认(Agent Shell)。
40
- const productJsonPath = path.join(productDir, 'product.json');
41
- const product = existsSync(productJsonPath) ? readJson(productJsonPath) : {};
42
- const manifest = readJson(path.join(repoRoot, 'products/manifest.json'));
43
- let packBrand: Record<string, string> | null = null;
44
- for (const packId of manifest.flavors?.[flavor] ?? []) {
45
- const pack = readJson(path.join(repoRoot, 'packages', `pack-${packId}`, 'pack.json'));
46
- if (pack.brand) {
47
- packBrand = pack.brand;
48
- break;
49
- }
50
- }
51
- const brand = product.brand ?? packBrand;
52
-
53
- return defineConfig({
54
- // root 默认取 config 文件所在目录(products/<id>/web)。
55
- base: './',
56
- plugins: [react(), tailwindcss()],
57
- define: {
58
- // 显式 define 让 flavor 条件在构建期可静态折叠。
59
- 'import.meta.env.VITE_APP_FLAVOR': JSON.stringify(flavor),
60
- // 品牌 define:产品/包声明覆盖 shell 中性默认(Agent Shell)。
61
- // logo 不走 define——资产必须静态 import 才进 bundle,由包 web 模块
62
- // 在注册时经 setBrandLogoUrl 注入(本包 src/brand.ts)。
63
- 'import.meta.env.VITE_BRAND_NAME': JSON.stringify(brand?.displayName ?? 'Steerable Shell'),
64
- 'import.meta.env.VITE_BRAND_TAGLINE': JSON.stringify(brand?.tagline ?? '一款本地桌面 AI 伙伴'),
65
- 'import.meta.env.VITE_DEFAULT_AGENT_ID': JSON.stringify(brand?.defaultAgentId ?? 'local-assistant'),
66
- },
67
- resolve: {
68
- alias: {
69
- // shell 渲染层源码(产品入口与包 web 模块都以 `@/` 引用它)。
70
- '@': webSrcDir,
71
- },
72
- },
73
- // 静态资产(favicon 等中性默认)随 shell web 包分发;产品可在自己的
74
- // web root 放 public/ 覆盖(vite 不合并双 publicDir——需要产品级资产
75
- // 时在产品 vite.config 里显式覆盖本字段)。
76
- publicDir: path.resolve(HERE, 'public'),
77
- server: {
78
- port: 5173,
79
- strictPort: true,
80
- host: '127.0.0.1',
81
- // 产品 root 在 products/<id>/web;shell 渲染层源码在框架仓库
82
- // (3.2 起经 file: 依赖符号链接)——两个根都放行。
83
- fs: { allow: [repoRoot, path.resolve(webSrcDir, '..')] },
84
- },
85
- build: {
86
- // 产物落在产品目录:products/<id>/web/dist(打包期被 electron-builder
87
- // 映射为包内 web-dist/)。
88
- outDir: 'dist',
89
- emptyOutDir: true,
90
- sourcemap: true,
91
- target: 'chrome120',
92
- },
93
- });
94
- }