@lark-apaas/coding-steering 0.1.0-alpha.1

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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Lark Technologies Pte. Ltd. and/or its affiliates
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,provided that the above copyright notice and this permission notice appear in all copies.
6
+
7
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8
+ IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
9
+ INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
10
+ EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
11
+ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
12
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
13
+ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @lark-apaas/coding-steering
2
+
3
+ Stack-specific steering content for [miaoda coding](https://code.byted.org/apaas/miaoda-coding) templates.
4
+
5
+ Consumed by [miaoda-cli](https://code.byted.org/apaas/miaoda-cli) at `app init` time and synced into the user project's `.agent/steering/`. **Not a runtime dependency** — no entry in user `package.json`.
6
+
7
+ ## Layout
8
+
9
+ ```
10
+ steering/
11
+ ├── _common/
12
+ │ └── skills/ # cross-stack shared skills
13
+ ├── <stack>/
14
+ │ ├── tech.md # always-loaded, injected into agent system prompt
15
+ │ └── skills/<id>/SKILL.md # progressive disclosure, triggered by description match
16
+ └── ...
17
+ ```
18
+
19
+ Top-level directory names (other than `_common`) ARE the stackId — discovery is by directory convention, no central manifest.
20
+
21
+ ## Sync mapping (executed by miaoda-cli)
22
+
23
+ | Source in this package | Destination in user project |
24
+ |---|---|
25
+ | `steering/<stack>/tech.md` | `.agent/steering/tech.md` |
26
+ | `steering/<stack>/skills/<id>/**` | `.agent/steering/skills/<id>/**` |
27
+ | `steering/_common/skills/<id>/**` | `.agent/steering/skills/<id>/**` |
28
+
29
+ When a `_common` skill and a stack-specific skill share the same `<id>`, the stack-specific one wins.
30
+
31
+ ## Writing rules
32
+
33
+ See [steering-authoring-rules.md](https://code.byted.org/apaas/miaoda-coding/blob/main/docs/steering-authoring-rules.md). Core principles:
34
+
35
+ - **Forward-compatible always:** never break old usage, only `@deprecated` it
36
+ - **Latest is safe:** existing user projects can always pull the latest version
37
+ - **Describe by current structure:** when introducing version-dependent guidance, write for the stack's current layout
38
+
39
+ ## License
40
+
41
+ MIT — see [LICENSE](./LICENSE).
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@lark-apaas/coding-steering",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "Stack-specific steering content for miaoda-coding templates",
5
+ "type": "module",
6
+ "files": ["steering"],
7
+ "scripts": {
8
+ "lint:md": "markdownlint 'steering/**/*.md'"
9
+ },
10
+ "devDependencies": {
11
+ "markdownlint-cli": "^0.47.0"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public",
15
+ "registry": "https://registry.npmjs.org/"
16
+ },
17
+ "keywords": ["miaoda", "coding-steering"],
18
+ "license": "MIT"
19
+ }
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: react-hook-best-practices
3
+ description: "Use when writing or reviewing React hooks: useEffect dependencies, useMemo/useCallback, custom hooks. 触发词:useEffect, useMemo, useCallback, 自定义 hook, React hook 规范"
4
+ steering: true
5
+ steering-topic: react_hook_best_practices
6
+ ---
7
+
8
+ # React Hook 最佳实践
9
+
10
+ ## 一、useEffect 依赖
11
+
12
+ ```tsx
13
+ // ❌ 错:缺依赖
14
+ useEffect(() => {
15
+ fetchUser(userId);
16
+ }, []);
17
+
18
+ // ✅ 对:完整依赖
19
+ useEffect(() => {
20
+ fetchUser(userId);
21
+ }, [userId]);
22
+ ```
23
+
24
+ - 始终用 `eslint-plugin-react-hooks` 自动检查依赖
25
+ - 不要为了"避免重复执行"省略依赖——用 cleanup function 或 ref 处理
26
+
27
+ ## 二、useMemo / useCallback
28
+
29
+ 只在以下场景使用:
30
+
31
+ - 计算昂贵(实测 >5ms)
32
+ - 引用稳定性影响下游(passed as prop to memoized child)
33
+
34
+ 默认**不预先优化**——大多数计算不需要 memo。
35
+
36
+ ## 三、自定义 hook
37
+
38
+ - 命名以 `use` 开头:`useDebounce` / `useLocalStorage`
39
+ - 单一职责,<50 行
40
+ - 内部不直接操作 DOM(用 ref + useEffect)
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: tailwind-conventions
3
+ description: "Use when styling components with Tailwind CSS: class organization, custom utilities, dark mode, responsive design. 触发词:Tailwind, className 顺序, 暗色模式, 响应式设计"
4
+ steering: true
5
+ steering-topic: tailwind_conventions
6
+ ---
7
+
8
+ # Tailwind 约定
9
+
10
+ ## 一、className 顺序
11
+
12
+ 按下列顺序写 class:
13
+
14
+ 1. layout(display / position / flex / grid)
15
+ 2. spacing(margin / padding / gap)
16
+ 3. sizing(width / height)
17
+ 4. typography(text-* / font-*)
18
+ 5. color(bg-* / text-* / border-*)
19
+ 6. interactive(hover: / focus: / active:)
20
+ 7. responsive(md: / lg:)
21
+
22
+ ```tsx
23
+ <div className="flex items-center gap-2 px-4 py-2 text-sm text-gray-900 bg-white hover:bg-gray-50 md:px-6">
24
+ ```
25
+
26
+ ## 二、暗色模式
27
+
28
+ - 用 `next-themes` 提供 `dark` class 切换
29
+ - 颜色用 `bg-white dark:bg-gray-900` 双写
30
+
31
+ ## 三、避免硬编码颜色
32
+
33
+ ❌ `text-[#3b82f6]`
34
+ ✅ `text-blue-500`
35
+
36
+ 如确需自定义色,加到 `tailwind.config.js` 的 theme.colors。
@@ -0,0 +1,3 @@
1
+ # html stack
2
+
3
+ Placeholder for v0.1. Stack technical overview will be written in v0.3.
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: client-coding-guide
3
+ description: "Use when implementing client-side features in vite-react stack: components, hooks, routing, state management. 触发词:客户端开发, React 组件, 页面路由, hooks, vite, vite-react"
4
+ steering: true
5
+ steering-topic: client_coding_guide
6
+ ---
7
+
8
+ # Client Coding Guide (vite-react)
9
+
10
+ ## 一、组件分层
11
+
12
+ ```
13
+ ui/ ← shadcn-ui 基础组件,源码自动生成,禁止直接编辑
14
+ components/ ← 业务组件,组合 ui/ 实现具体场景
15
+ pages/ ← 路由页面,组合多个 components/ 构建完整界面
16
+ ```
17
+
18
+ ## 二、State 管理
19
+
20
+ - 局部 state 用 `useState`
21
+ - 共享 state 优先用 React Context
22
+ - 避免引入 Redux/Zustand 等全局 store(v0.1 不依赖)
23
+
24
+ ## 三、表单实现模板
25
+
26
+ ```tsx
27
+ import { useForm } from 'react-hook-form';
28
+ import { zodResolver } from '@hookform/resolvers/zod';
29
+ import { z } from 'zod';
30
+
31
+ const schema = z.object({
32
+ name: z.string().min(1, '必填'),
33
+ email: z.string().email(),
34
+ });
35
+
36
+ type FormValues = z.infer<typeof schema>;
37
+
38
+ export function MyForm() {
39
+ const form = useForm<FormValues>({ resolver: zodResolver(schema) });
40
+ const onSubmit = (values: FormValues) => { /* ... */ };
41
+ return (
42
+ <form onSubmit={form.handleSubmit(onSubmit)}>
43
+ <input {...form.register('name')} />
44
+ {/* ... */}
45
+ </form>
46
+ );
47
+ }
48
+ ```
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: component-conventions
3
+ description: "Use when creating or refactoring React components: naming, file structure, props typing, default values. 触发词:组件命名, props 类型, 组件文件结构, React 最佳实践"
4
+ steering: true
5
+ steering-topic: component_conventions
6
+ ---
7
+
8
+ # Component Conventions (vite-react)
9
+
10
+ ## 一、文件结构
11
+
12
+ 每个组件一个目录:
13
+
14
+ ```
15
+ components/
16
+ └── UserCard/
17
+ ├── index.tsx # 组件主文件
18
+ ├── UserCard.test.tsx # 测试(可选)
19
+ └── types.ts # 局部类型(可选)
20
+ ```
21
+
22
+ ## 二、命名
23
+
24
+ - 组件名 PascalCase:`UserCard`、`StatusBadge`
25
+ - 文件名跟组件名一致:`UserCard.tsx`
26
+ - props 接口:`UserCardProps`
27
+
28
+ ## 三、props 类型
29
+
30
+ ```tsx
31
+ interface UserCardProps {
32
+ user: User;
33
+ onSelect?: (id: string) => void;
34
+ className?: string;
35
+ }
36
+
37
+ export function UserCard({ user, onSelect, className }: UserCardProps) {
38
+ // ...
39
+ }
40
+ ```
41
+
42
+ - **强制带 `className?: string`**——所有业务组件都应允许外部传 className
43
+ - **回调用 `onXxx` 命名**——`onSelect` / `onChange` / `onSubmit`
44
+
45
+ ## 四、默认导出 vs 命名导出
46
+
47
+ - 业务组件**命名导出**:`export function UserCard ...`
48
+ - 入口/页面组件可以默认导出
@@ -0,0 +1,35 @@
1
+ # Vite React Stack
2
+
3
+ ## 技术栈
4
+
5
+ - 构建:Vite 8 + TypeScript
6
+ - UI:React 19 + shadcn-ui + Radix Primitives + Tailwind CSS v4
7
+ - 路由:react-router-dom v7
8
+ - 表单:react-hook-form + zod
9
+ - 图表:echarts-for-react / recharts
10
+ - 动画:framer-motion / gsap
11
+
12
+ ## 目录结构
13
+
14
+ ```
15
+ my-app/
16
+ ├── client/
17
+ │ ├── src/
18
+ │ │ ├── components/ # 业务组件
19
+ │ │ ├── ui/ # shadcn-ui 基础组件(不要直接改)
20
+ │ │ ├── pages/ # 路由页面
21
+ │ │ ├── hooks/ # 自定义 hooks
22
+ │ │ └── lib/ # 工具函数
23
+ │ ├── index.html
24
+ │ └── public/
25
+ ├── vite.config.ts
26
+ ├── tsconfig.json
27
+ └── package.json
28
+ ```
29
+
30
+ ## 核心约定
31
+
32
+ 1. **shadcn-ui 组件不直接改源码**——需要变化时通过 className / variant props 控制
33
+ 2. **样式优先用 Tailwind utility**,避免写 CSS module
34
+ 3. **表单始终用 react-hook-form + zod**——不要直接操作 input value
35
+ 4. **图表 ECharts 优先 echarts-for-react**——React 18 严格模式下要小心 echarts instance 的初始化