yyx-agent-kit 0.0.0-stage → 0.1.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 +152 -3
- package/agents/chief.md +64 -0
- package/agents/qa.md +30 -0
- package/cli/bin/yyx-new.mjs +155 -0
- package/package.json +33 -4
- package/skills/flows/archive/SKILL.md +56 -0
- package/skills/flows/prd/SKILL.md +71 -0
- package/skills/flows/product-pipeline/SKILL.md +73 -0
- package/skills/flows/qa-regression/SKILL.md +58 -0
- package/skills/flows/tech-design/SKILL.md +75 -0
- package/skills/standards/nestjs/SKILL.md +29 -0
- package/skills/standards/next/SKILL.md +39 -0
- package/skills/standards/react/SKILL.md +25 -0
- package/skills/standards/workspace/SKILL.md +127 -0
- package/skills/tools/tooling/SKILL.md +39 -0
- package/templates/base/.opencode/agents/.synced.json +4 -0
- package/templates/base/.opencode/agents/chief.md +64 -0
- package/templates/base/.opencode/agents/qa.md +30 -0
- package/templates/base/.opencode/opencode.json +5 -0
- package/templates/base/AGENTS.md +51 -0
- package/templates/base/README.md +85 -0
- package/templates/base/apps/admin/index.html +12 -0
- package/templates/base/apps/admin/package.json +27 -0
- package/templates/base/apps/admin/src/App.tsx +10 -0
- package/templates/base/apps/admin/src/index.css +1 -0
- package/templates/base/apps/admin/src/main.tsx +10 -0
- package/templates/base/apps/admin/tsconfig.json +9 -0
- package/templates/base/apps/admin/vite.config.ts +15 -0
- package/templates/base/apps/client/index.html +12 -0
- package/templates/base/apps/client/package.json +27 -0
- package/templates/base/apps/client/src/App.tsx +41 -0
- package/templates/base/apps/client/src/index.css +1 -0
- package/templates/base/apps/client/src/main.tsx +10 -0
- package/templates/base/apps/client/tsconfig.json +9 -0
- package/templates/base/apps/client/vite.config.ts +15 -0
- package/templates/base/apps/portal/README.md +27 -0
- package/templates/base/apps/portal/next-env.d.ts +6 -0
- package/templates/base/apps/portal/next.config.ts +19 -0
- package/templates/base/apps/portal/package.json +26 -0
- package/templates/base/apps/portal/postcss.config.mjs +5 -0
- package/templates/base/apps/portal/src/app/README.md +19 -0
- package/templates/base/apps/portal/src/app/globals.css +1 -0
- package/templates/base/apps/portal/src/app/layout.tsx +17 -0
- package/templates/base/apps/portal/src/app/page.tsx +12 -0
- package/templates/base/apps/portal/tsconfig.json +33 -0
- package/templates/base/apps/server/package.json +22 -0
- package/templates/base/apps/server/src/app.controller.ts +15 -0
- package/templates/base/apps/server/src/app.module.ts +11 -0
- package/templates/base/apps/server/src/app.service.ts +8 -0
- package/templates/base/apps/server/src/main.ts +15 -0
- package/templates/base/apps/server/src/todos.controller.ts +15 -0
- package/templates/base/apps/server/src/todos.service.ts +18 -0
- package/templates/base/apps/server/tsconfig.json +16 -0
- package/templates/base/docs/.gitkeep +0 -0
- package/templates/base/mise.toml +2 -0
- package/templates/base/package.json +17 -0
- package/templates/base/packages/README.md +18 -0
- package/templates/base/packages/api/config.ts +26 -0
- package/templates/base/packages/api/package.json +19 -0
- package/templates/base/packages/api/src/README.md +26 -0
- package/templates/base/packages/api/src/client.ts +51 -0
- package/templates/base/packages/api/src/index.ts +2 -0
- package/templates/base/packages/api/src/types.ts +10 -0
- package/templates/base/packages/api/tsconfig.json +7 -0
- package/templates/base/packages/shared/package.json +15 -0
- package/templates/base/packages/shared/src/README.md +21 -0
- package/templates/base/packages/shared/src/index.ts +37 -0
- package/templates/base/packages/shared/tsconfig.json +4 -0
- package/templates/base/pnpm-lock.yaml +3144 -0
- package/templates/base/pnpm-workspace.yaml +6 -0
- package/templates/base/tsconfig.base.json +19 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { API_ROUTES, type Todo } from "@starter/shared";
|
|
2
|
+
import type { HealthResponse } from "./types";
|
|
3
|
+
|
|
4
|
+
export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
5
|
+
|
|
6
|
+
export interface ApiClientOptions {
|
|
7
|
+
/** 默认 `/api`,走 Vite 代理;不要填后端域名 */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
/** 取当前 access token,返回 null 表示未登录 */
|
|
10
|
+
getToken?: () => string | null;
|
|
11
|
+
/** 收到 401 时回调:清会话并跳登录,由调用方实现 */
|
|
12
|
+
onUnauthorized?: () => void;
|
|
13
|
+
/** 自定义请求实现。小程序 / RN 端注入自己的请求器,不传则用全局 fetch */
|
|
14
|
+
fetcher?: FetchLike;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ApiClient {
|
|
18
|
+
health: () => Promise<HealthResponse>;
|
|
19
|
+
todos: () => Promise<Todo[]>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const createApiClient = (options: ApiClientOptions = {}): ApiClient => {
|
|
23
|
+
const baseUrl = options.baseUrl ?? "/api";
|
|
24
|
+
const fetcher: FetchLike = options.fetcher ?? ((input, init) => fetch(input, init));
|
|
25
|
+
|
|
26
|
+
const request = async <T>(path: string, init?: RequestInit): Promise<T> => {
|
|
27
|
+
const headers = new Headers(init?.headers);
|
|
28
|
+
const token = options.getToken?.();
|
|
29
|
+
if (token) {
|
|
30
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const response = await fetcher(`${baseUrl}${path}`, { ...init, headers });
|
|
34
|
+
|
|
35
|
+
if (response.status === 401) {
|
|
36
|
+
options.onUnauthorized?.();
|
|
37
|
+
throw new Error("未登录或登录已过期");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
throw new Error(`请求失败:${response.status}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (await response.json()) as T;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
health: () => request<HealthResponse>(API_ROUTES.health),
|
|
49
|
+
todos: () => request<Todo[]>(API_ROUTES.todos),
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# shared
|
|
2
|
+
|
|
3
|
+
## 职责
|
|
4
|
+
|
|
5
|
+
跨应用共享的**纯逻辑**:常量、路由表、业务枚举、类型。这里是唯一来源,前后端和各个端都从这里取。
|
|
6
|
+
|
|
7
|
+
以 TS 源码被消费,没有构建产物。`package.json` 的 `exports` 是白名单,新增子路径必须同时改 `exports`。
|
|
8
|
+
|
|
9
|
+
## 文件索引
|
|
10
|
+
|
|
11
|
+
| 文件 | 作用 |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `src/index.ts` | 包入口:`API_PREFIX`、`API_ROUTES`、业务枚举、类型、工具函数 |
|
|
14
|
+
| `src/README.md` | 本文件 |
|
|
15
|
+
|
|
16
|
+
## 注意事项
|
|
17
|
+
|
|
18
|
+
- 不依赖 `react`、`fetch`、`window` 或 `process`,否则小程序 / App / 服务端无法复用。
|
|
19
|
+
- 新增接口时先加 `API_ROUTES` 常量,再让 controller 与 api 层引用,不要两边各写一个字符串。
|
|
20
|
+
- 业务枚举(状态、类型、错误码)放这里,不要在前端写字符串字面量、服务端再写一遍。
|
|
21
|
+
- 服务端通过相对路径引用本包源码(`../../../packages/shared/src/index`),因为 NestJS 是 CommonJS,无法直接 `require` TS 源码包。
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const APP_NAME = "starter";
|
|
2
|
+
|
|
3
|
+
/** API 路径前缀。server 的 setGlobalPrefix、前端的 baseUrl、路由常量都以此为准 */
|
|
4
|
+
export const API_PREFIX = "/api";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 业务路由表。新增接口先在这里加常量,再由 controller 和 api 层引用,
|
|
8
|
+
* 避免前后端各写一份字符串。
|
|
9
|
+
*
|
|
10
|
+
* 注意:`health` 是运维探活,不属于业务接口。
|
|
11
|
+
*/
|
|
12
|
+
export const API_ROUTES = {
|
|
13
|
+
health: "/health",
|
|
14
|
+
todos: "/todos",
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
/** 业务状态枚举,前后端共用 */
|
|
18
|
+
export const TODO_STATUS = {
|
|
19
|
+
pending: "pending",
|
|
20
|
+
done: "done",
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
export type TodoStatus = (typeof TODO_STATUS)[keyof typeof TODO_STATUS];
|
|
24
|
+
|
|
25
|
+
export interface Todo {
|
|
26
|
+
id: string;
|
|
27
|
+
title: string;
|
|
28
|
+
status: TodoStatus;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** 统一日期展示格式,避免各端各自拼字符串 */
|
|
33
|
+
export const formatDateTime = (input: Date | string | number): string => {
|
|
34
|
+
const date = input instanceof Date ? input : new Date(input);
|
|
35
|
+
const pad = (value: number): string => String(value).padStart(2, "0");
|
|
36
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
37
|
+
};
|