@yiyi_zhang/laoshi 0.1.1 → 0.2.0-beta.2
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/CHANGELOG.md +32 -0
- package/adapters/cli/adapter.ts +53 -0
- package/adapters/cli/cli-runtime.ts +402 -0
- package/adapters/cli/drivers.ts +146 -0
- package/adapters/cli/install.mjs +28 -0
- package/adapters/cli/skill/setup.md +8 -0
- package/adapters/dsh/plugin/index.mjs +1 -1
- package/adapters/dsh/plugin/package.json +1 -1
- package/adapters/mogao/adapter.ts +47 -0
- package/adapters/mogao/install.mjs +31 -0
- package/adapters/mogao/make-expert.mjs +64 -0
- package/adapters/mogao/mogao-runtime.ts +506 -0
- package/adapters/mogao/skill/setup.md +21 -0
- package/adapters/paseo/adapter.ts +1 -1
- package/adapters/paseo/install.mjs +17 -5
- package/adapters/paseo/migrate.ts +267 -0
- package/adapters/paseo/plugin/OVERVIEW.md +9 -0
- package/adapters/paseo/plugin/client/config.tsx +216 -0
- package/adapters/paseo/plugin/client/data.ts +85 -0
- package/adapters/paseo/plugin/client/detail.tsx +342 -0
- package/adapters/paseo/plugin/client/format.ts +173 -0
- package/adapters/paseo/plugin/client/inbox.tsx +190 -0
- package/adapters/paseo/plugin/client/live.ts +161 -0
- package/adapters/paseo/plugin/client/markdown.tsx +220 -0
- package/adapters/paseo/plugin/client/models.tsx +117 -0
- package/adapters/paseo/plugin/client/nav.ts +22 -0
- package/adapters/paseo/plugin/client/overview.tsx +103 -0
- package/adapters/paseo/plugin/client/panel.tsx +56 -0
- package/adapters/paseo/plugin/client/review.tsx +80 -0
- package/adapters/paseo/plugin/client/row.tsx +63 -0
- package/adapters/paseo/plugin/client/settings.tsx +92 -0
- package/adapters/paseo/plugin/client/sidebar.tsx +27 -0
- package/adapters/paseo/plugin/client/stats.tsx +138 -0
- package/adapters/paseo/plugin/client/ui.tsx +278 -0
- package/adapters/paseo/plugin/client/web.ts +34 -0
- package/adapters/paseo/plugin/index.client.tsx +66 -0
- package/adapters/paseo/plugin/index.server.ts +61 -0
- package/adapters/paseo/plugin/package.json +22 -0
- package/adapters/paseo/plugin/paseo-plugin.json +6 -0
- package/adapters/paseo/plugin/server/handlers.ts +69 -0
- package/adapters/paseo/plugin/server/req.ts +105 -0
- package/adapters/paseo/plugin/shared/contracts.ts +286 -0
- package/adapters/paseo/plugin/shared/rk-colors.ts +35 -0
- package/adapters/paseo/plugin/tsconfig.json +16 -0
- package/adapters/paseo/plugin-cmd.mjs +233 -0
- package/bin/install.mjs +12 -5
- package/bin/req.mjs +18 -2
- package/contracts/README.md +1 -1
- package/contracts/agent-runtime.md +5 -2
- package/contracts/cli-json.md +4 -3
- package/contracts/notifier-event.md +2 -2
- package/contracts/state.md +2 -0
- package/contracts/usage-record.md +3 -3
- package/docs/design/adapter-guide.md +2 -1
- package/docs/design/cli-adapter.md +75 -0
- package/docs/design/compat-migration.md +2 -0
- package/docs/design/mogao-expert.md +103 -0
- package/docs/guide//345/234/250/346/221/270/351/253/230/344/270/212/344/275/277/347/224/250.md +132 -0
- package/docs/guide//345/256/211/350/243/205/344/270/216/345/215/207/347/272/247.md +32 -3
- package/docs/guide//347/273/264/346/212/244/350/200/205/346/214/207/345/215/227.md +4 -2
- package/docs/guide//351/241/271/347/233/256/345/256/232/345/210/266/344/270/216/350/277/220/350/241/214/350/247/204/345/210/231.md +1 -1
- package/engine/src/api.ts +9 -5
- package/engine/src/code-review.ts +2 -2
- package/engine/src/control.ts +6 -6
- package/engine/src/danger-guard.ts +7 -0
- package/engine/src/doctor.ts +4 -3
- package/engine/src/features.ts +2 -2
- package/engine/src/identity.ts +16 -1
- package/engine/src/integration-cmd.ts +2 -2
- package/engine/src/launch.ts +44 -6
- package/engine/src/locations.ts +15 -1
- package/engine/src/main.ts +6 -1
- package/engine/src/messages.ts +1 -1
- package/engine/src/permission-cmd.ts +56 -0
- package/engine/src/platform.ts +7 -0
- package/engine/src/preflight.ts +2 -2
- package/engine/src/runtime-loader.ts +16 -0
- package/engine/src/runtime.ts +5 -0
- package/engine/src/skills-render.ts +10 -6
- package/engine/src/state.ts +25 -1
- package/engine/src/words.ts +1 -1
- package/package.json +2 -1
- package/site-dist/404.html +2 -2
- package/site-dist/assets/{app.Df99UgrJ.js → app.D2ywvSfZ.js} +1 -1
- package/site-dist/assets/changelog.md.EDul9PkX.js +1 -0
- package/site-dist/assets/changelog.md.EDul9PkX.lean.js +1 -0
- package/site-dist/assets/chunks/@localSearchIndexroot.Dr_jsw66.js +1 -0
- package/site-dist/assets/chunks/{VPLocalSearchBox.IEhP6Gw5.js → VPLocalSearchBox.ClWffKqN.js} +1 -1
- package/site-dist/assets/chunks/{theme.DHubfO7g.js → theme.tbt16E5a.js} +2 -2
- package/site-dist/assets/guide_cli.md.BrXllHw9.js +2 -0
- package/site-dist/assets/guide_cli.md.BrXllHw9.lean.js +2 -0
- package/site-dist/assets/{guide_getting-started.md.BZTWiHhH.js → guide_getting-started.md.qAp5hWCl.js} +1 -1
- package/site-dist/assets/{guide_getting-started.md.BZTWiHhH.lean.js → guide_getting-started.md.qAp5hWCl.lean.js} +1 -1
- package/site-dist/assets/guide_install.md.By4WxsJG.js +24 -0
- package/site-dist/assets/guide_install.md.By4WxsJG.lean.js +24 -0
- package/site-dist/assets/guide_maintainer.md.Da1ffqxm.js +1 -0
- package/site-dist/assets/guide_maintainer.md.Da1ffqxm.lean.js +1 -0
- package/site-dist/assets/guide_mogao.md.S0eln1Pr.js +10 -0
- package/site-dist/assets/guide_mogao.md.S0eln1Pr.lean.js +10 -0
- package/site-dist/assets/{guide_project.md.BIcaDhdS.js → guide_project.md.B2cmf8YF.js} +1 -1
- package/site-dist/assets/{guide_project.md.BIcaDhdS.lean.js → guide_project.md.B2cmf8YF.lean.js} +1 -1
- package/site-dist/assets/reference_contracts_agent-runtime.md.DPE2FJFc.js +1 -0
- package/site-dist/assets/{reference_contracts_agent-runtime.md.Bu8q-uGl.lean.js → reference_contracts_agent-runtime.md.DPE2FJFc.lean.js} +1 -1
- package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.js +1 -0
- package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.lean.js +1 -0
- package/site-dist/assets/{reference_contracts_index.md.dqNwNs6U.js → reference_contracts_index.md.B5P4FjRk.js} +1 -1
- package/site-dist/assets/{reference_contracts_index.md.dqNwNs6U.lean.js → reference_contracts_index.md.B5P4FjRk.lean.js} +1 -1
- package/site-dist/assets/{reference_contracts_notifier-event.md.D6we9wWS.js → reference_contracts_notifier-event.md.BeR8iODP.js} +1 -1
- package/site-dist/assets/{reference_contracts_notifier-event.md.D6we9wWS.lean.js → reference_contracts_notifier-event.md.BeR8iODP.lean.js} +1 -1
- package/site-dist/assets/reference_contracts_state.md.DLygjkfs.js +1 -0
- package/site-dist/assets/reference_contracts_usage-record.md.CgfMoYp0.js +10 -0
- package/site-dist/assets/reference_contracts_usage-record.md.CgfMoYp0.lean.js +10 -0
- package/site-dist/assets/{reference_design_adapter-guide.md.BSziZJSM.js → reference_design_adapter-guide.md.B_P-spS5.js} +2 -2
- package/site-dist/assets/{reference_design_adapter-guide.md.BSziZJSM.lean.js → reference_design_adapter-guide.md.B_P-spS5.lean.js} +2 -2
- package/site-dist/assets/reference_design_cli-adapter.md.pJy3x6Un.js +13 -0
- package/site-dist/assets/reference_design_cli-adapter.md.pJy3x6Un.lean.js +13 -0
- package/site-dist/changelog.html +5 -5
- package/site-dist/guide/cli.html +31 -0
- package/site-dist/guide/dsh.html +5 -5
- package/site-dist/guide/getting-started.html +5 -5
- package/site-dist/guide/how-it-works.html +4 -4
- package/site-dist/guide/index.html +4 -4
- package/site-dist/guide/install.html +13 -8
- package/site-dist/guide/intranet.html +5 -5
- package/site-dist/guide/maintainer.html +5 -5
- package/site-dist/guide/mogao.html +39 -0
- package/site-dist/guide/phases.html +4 -4
- package/site-dist/guide/project.html +6 -6
- package/site-dist/guide/user.html +4 -4
- package/site-dist/hashmap.json +1 -1
- package/site-dist/index.html +4 -4
- package/site-dist/reference/adr/0001-new-repo-core-and-adapters.html +4 -4
- package/site-dist/reference/adr/0002-two-orchestration-modes.html +4 -4
- package/site-dist/reference/adr/0003-generate-once-then-lock.html +4 -4
- package/site-dist/reference/adr/0004-external-contracts-stay-stable.html +4 -4
- package/site-dist/reference/adr/0005-skill-names.html +4 -4
- package/site-dist/reference/adr/0006-deterministic-engine-platform-capabilities.html +4 -4
- package/site-dist/reference/adr/0007-one-install-many-repos.html +4 -4
- package/site-dist/reference/adr/0008-capability-sources-and-platform-plugin.html +4 -4
- package/site-dist/reference/adr/index.html +4 -4
- package/site-dist/reference/commands.html +4 -4
- package/site-dist/reference/config.html +4 -4
- package/site-dist/reference/contracts/agent-runtime.html +5 -5
- package/site-dist/reference/contracts/cli-json.html +5 -5
- package/site-dist/reference/contracts/feature-files.html +4 -4
- package/site-dist/reference/contracts/index.html +5 -5
- package/site-dist/reference/contracts/notifier-event.html +6 -6
- package/site-dist/reference/contracts/result-file.html +4 -4
- package/site-dist/reference/contracts/spec.html +4 -4
- package/site-dist/reference/contracts/state.html +5 -5
- package/site-dist/reference/contracts/usage-record.html +6 -6
- package/site-dist/reference/contracts/verify.html +4 -4
- package/site-dist/reference/design/adapter-guide.html +6 -6
- package/site-dist/reference/design/architecture.html +4 -4
- package/site-dist/reference/design/builtin-capabilities.html +4 -4
- package/site-dist/reference/design/cli-adapter.html +42 -0
- package/site-dist/reference/design/platform-vocabulary.html +4 -4
- package/site-dist/reference/scope.html +4 -4
- package/skills/laoshi/SKILL.md +3 -0
- package/skills/laoshi-doctor/SKILL.md +2 -0
- package/skills/laoshi-retro/SKILL.md +2 -0
- package/skills/laoshi-setup/SKILL.md +3 -0
- package/site-dist/assets/changelog.md.Df8vFhjK.js +0 -1
- package/site-dist/assets/changelog.md.Df8vFhjK.lean.js +0 -1
- package/site-dist/assets/chunks/@localSearchIndexroot.n-0kN-N0.js +0 -1
- package/site-dist/assets/guide_install.md.D7NiiOPu.js +0 -19
- package/site-dist/assets/guide_install.md.D7NiiOPu.lean.js +0 -19
- package/site-dist/assets/guide_maintainer.md.C-Vt-DdK.js +0 -1
- package/site-dist/assets/guide_maintainer.md.C-Vt-DdK.lean.js +0 -1
- package/site-dist/assets/reference_contracts_agent-runtime.md.Bu8q-uGl.js +0 -1
- package/site-dist/assets/reference_contracts_cli-json.md.Bonk0m6-.js +0 -1
- package/site-dist/assets/reference_contracts_cli-json.md.Bonk0m6-.lean.js +0 -1
- package/site-dist/assets/reference_contracts_state.md.DVHC4opX.js +0 -1
- package/site-dist/assets/reference_contracts_usage-record.md.CQI2chqh.js +0 -10
- package/site-dist/assets/reference_contracts_usage-record.md.CQI2chqh.lean.js +0 -10
- /package/site-dist/assets/{reference_contracts_state.md.DVHC4opX.lean.js → reference_contracts_state.md.DLygjkfs.lean.js} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Settings → Plugins → laoshi → 模型 (1.12): pick builder, reviewer and the fallback model from what
|
|
2
|
+
// this daemon offers, and write them to laoshi's machine config — the same as `laoshi configure`.
|
|
3
|
+
import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
4
|
+
import { SettingsAction, SettingsCard, SettingsRow, SettingsSection, SettingsSelect } from "@getpaseo/plugin/client/ui";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { Text } from "react-native";
|
|
7
|
+
import type { AgentChoiceData, AgentProfileData } from "../shared/contracts";
|
|
8
|
+
import { useModels, useSetAgents } from "./data";
|
|
9
|
+
|
|
10
|
+
const NONE = "none";
|
|
11
|
+
|
|
12
|
+
/** The choice a saved profile corresponds to; a profile Paseo no longer offers keeps its own entry. */
|
|
13
|
+
function idOf(profile: AgentProfileData | null | undefined, choices: AgentChoiceData[]): string {
|
|
14
|
+
if (!profile) return NONE;
|
|
15
|
+
if (profile.paseoProfile) return `paseo:${profile.paseoProfile}`;
|
|
16
|
+
const found = choices.find((c) => !c.profile.paseoProfile && c.profile.provider === profile.provider);
|
|
17
|
+
return found ? found.id : `saved:${profile.provider ?? ""}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type Role = "builder" | "reviewer" | "fallback";
|
|
21
|
+
|
|
22
|
+
const ROLES: Array<{ role: Role; label: string; hint: string }> = [
|
|
23
|
+
{ role: "builder", label: "builder", hint: "方案设计、写代码、修复、写报告" },
|
|
24
|
+
{ role: "reviewer", label: "reviewer", hint: "方案审核、代码评审、功能验证。和 builder 用不同厂商的模型,更容易发现问题" },
|
|
25
|
+
{ role: "fallback", label: "备用模型", hint: "主模型一直限流、额度用完或报错时,换它把这一步做完,而不是停下等人" },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export function ModelSettings({ theme, readOnly }: { theme: PluginSurfaceProps["theme"]; readOnly: boolean }) {
|
|
29
|
+
const models = useModels();
|
|
30
|
+
const save = useSetAgents();
|
|
31
|
+
const data = models.data;
|
|
32
|
+
const choices = data?.choices ?? [];
|
|
33
|
+
const [picked, setPicked] = useState<Record<Role, string>>({ builder: NONE, reviewer: NONE, fallback: NONE });
|
|
34
|
+
const [message, setMessage] = useState<string | null>(null);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!data) return;
|
|
38
|
+
setPicked({
|
|
39
|
+
builder: idOf(data.current?.builder, choices),
|
|
40
|
+
reviewer: idOf(data.current?.reviewer, choices),
|
|
41
|
+
fallback: idOf(data.current?.fallback ?? null, choices),
|
|
42
|
+
});
|
|
43
|
+
}, [data]);
|
|
44
|
+
|
|
45
|
+
if (!data) {
|
|
46
|
+
return (
|
|
47
|
+
<SettingsSection title="模型">
|
|
48
|
+
<SettingsCard>
|
|
49
|
+
<SettingsRow label="可用的 agent" error={models.error?.message ?? undefined} hint={models.isPending ? "正在向 Paseo 读取已登录的 agent 和模型…" : undefined} />
|
|
50
|
+
</SettingsCard>
|
|
51
|
+
</SettingsSection>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const saved = (role: Role): AgentProfileData | null => (role === "fallback" ? (data.current?.fallback ?? null) : (data.current?.[role] ?? null));
|
|
56
|
+
const profileOf = (role: Role, id: string): AgentProfileData | null => {
|
|
57
|
+
if (id === NONE) return null;
|
|
58
|
+
if (id.startsWith("saved:")) return saved(role);
|
|
59
|
+
return choices.find((c) => c.id === id)?.profile ?? null;
|
|
60
|
+
};
|
|
61
|
+
const optionsFor = (role: Role) => {
|
|
62
|
+
const list = choices.map((c) => ({ label: c.label, value: c.id }));
|
|
63
|
+
const current = picked[role];
|
|
64
|
+
if (current.startsWith("saved:")) list.unshift({ label: `现在的设置:${current.slice(6)}(Paseo 中没有找到)`, value: current });
|
|
65
|
+
if (role === "fallback" || current === NONE) list.unshift({ label: role === "fallback" ? "不用备用模型" : "(未设置)", value: NONE });
|
|
66
|
+
return list;
|
|
67
|
+
};
|
|
68
|
+
const builder = profileOf("builder", picked.builder);
|
|
69
|
+
const reviewer = profileOf("reviewer", picked.reviewer);
|
|
70
|
+
const changed = ROLES.some(({ role }) => picked[role] !== idOf(role === "fallback" ? (data.current?.fallback ?? null) : data.current?.[role], choices));
|
|
71
|
+
|
|
72
|
+
const useRecommended = () => {
|
|
73
|
+
const r = data.recommended;
|
|
74
|
+
if (!r) return;
|
|
75
|
+
setPicked({ builder: idOf(r.builder, choices), reviewer: idOf(r.reviewer, choices), fallback: idOf(r.fallback ?? null, choices) });
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<SettingsSection title="模型">
|
|
80
|
+
<SettingsCard>
|
|
81
|
+
{choices.length === 0 ? (
|
|
82
|
+
<SettingsRow label="可用的 agent" hint="Paseo 中还没有登录任何能无人值守运行的 agent。在 Paseo 中登录 Claude Code、Codex 等之后再打开这一页。" />
|
|
83
|
+
) : null}
|
|
84
|
+
{ROLES.map(({ role, label, hint }) => (
|
|
85
|
+
<SettingsSelect
|
|
86
|
+
key={role}
|
|
87
|
+
label={label}
|
|
88
|
+
hint={hint}
|
|
89
|
+
value={picked[role]}
|
|
90
|
+
options={optionsFor(role)}
|
|
91
|
+
disabled={readOnly || save.isPending}
|
|
92
|
+
onValueChange={(v) => {
|
|
93
|
+
setMessage(null);
|
|
94
|
+
setPicked({ ...picked, [role]: v });
|
|
95
|
+
}}
|
|
96
|
+
/>
|
|
97
|
+
))}
|
|
98
|
+
{data.recommended ? (
|
|
99
|
+
<SettingsAction label="按推荐选择" hint="不同厂商的模型分别做 builder 和 reviewer,再选一个做备用" actionLabel="填入推荐" disabled={readOnly || save.isPending} onPress={useRecommended} />
|
|
100
|
+
) : null}
|
|
101
|
+
<SettingsAction
|
|
102
|
+
label="保存到本机配置"
|
|
103
|
+
hint={readOnly ? "插件设置为只读,不能在这里修改" : "写入 laoshi 的安装级配置(原文件会备份);之后开始的需求使用新的设置,进行中的不变"}
|
|
104
|
+
actionLabel={save.isPending ? "保存中…" : "保存"}
|
|
105
|
+
disabled={readOnly || save.isPending || !changed || !builder || !reviewer}
|
|
106
|
+
onPress={() =>
|
|
107
|
+
void save.mutateAsync({ builder: builder!, reviewer: reviewer!, fallback: profileOf("fallback", picked.fallback) }).then(
|
|
108
|
+
(r) => setMessage(r.message),
|
|
109
|
+
(e: Error) => setMessage(e.message),
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
/>
|
|
113
|
+
{message ? <Text style={{ color: theme.colors.foregroundMuted }}>{message}</Text> : null}
|
|
114
|
+
</SettingsCard>
|
|
115
|
+
</SettingsSection>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Opening the plugin's screens from anywhere in it (screens themselves are not handed an opener).
|
|
2
|
+
type Opener = (input: { screenId: string; params?: Record<string, string> }) => void;
|
|
3
|
+
|
|
4
|
+
let opener: Opener | null = null;
|
|
5
|
+
|
|
6
|
+
export function setScreenOpener(open: Opener): void {
|
|
7
|
+
opener = open;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function openReview(input: { repo: string; featureDir: string; title: string }): void {
|
|
11
|
+
opener?.({ screenId: "review", params: { repo: input.repo, featureDir: input.featureDir, title: input.title } });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** 1.14: the acceptance checklist of a requirement (the same screen, another page). */
|
|
15
|
+
export function openChecklist(input: { repo: string; featureDir: string; title: string }): void {
|
|
16
|
+
opener?.({ screenId: "review", params: { repo: input.repo, featureDir: input.featureDir, title: input.title, page: "check" } });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** 1.14: the code review page of a requirement (the same screen, another page). */
|
|
20
|
+
export function openCodeReview(input: { repo: string; featureDir: string; title: string }): void {
|
|
21
|
+
opener?.({ screenId: "review", params: { repo: input.repo, featureDir: input.featureDir, title: input.title, page: "code" } });
|
|
22
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// The overview: every requirement on this machine, grouped by what it needs.
|
|
2
|
+
import type { PluginOpenScreenInput, PluginScreenProps } from "@getpaseo/plugin/client";
|
|
3
|
+
import { ScrollView } from "@getpaseo/plugin/client/react-native";
|
|
4
|
+
import { useMemo, useState } from "react";
|
|
5
|
+
import { Text, View } from "react-native";
|
|
6
|
+
import type { Requirement } from "../shared/contracts";
|
|
7
|
+
import { useRequirements } from "./data";
|
|
8
|
+
import { type Group, GROUP_LABELS, groupOf } from "./format";
|
|
9
|
+
import { Inbox } from "./inbox";
|
|
10
|
+
import { RequirementRow } from "./row";
|
|
11
|
+
import { BrandHeader, Button, Chip, Eyebrow, Status, useStyles } from "./ui";
|
|
12
|
+
|
|
13
|
+
export const ORDER: Group[] = ["attention", "running", "verify", "done", "other"];
|
|
14
|
+
|
|
15
|
+
/** Uppercase mono group names (design/guidelines/plugin.md); the Chinese label follows. */
|
|
16
|
+
const EYEBROW: Record<Group, string> = { attention: "NEEDS YOU", running: "IN PROGRESS", verify: "READY TO TEST", done: "DONE", other: "OTHERS" };
|
|
17
|
+
|
|
18
|
+
/** Opens a requirement's detail screen. */
|
|
19
|
+
export type OpenRequirement = (item: Pick<Requirement, "repo" | "featureDir" | "title">) => void;
|
|
20
|
+
|
|
21
|
+
export function RequirementGroups({
|
|
22
|
+
theme,
|
|
23
|
+
layout,
|
|
24
|
+
items,
|
|
25
|
+
open,
|
|
26
|
+
skip = [],
|
|
27
|
+
}: Pick<PluginScreenProps, "theme" | "layout"> & { items: Requirement[]; open: OpenRequirement; skip?: Group[] }) {
|
|
28
|
+
const s = useStyles(theme, layout.compact);
|
|
29
|
+
const [showOther, setShowOther] = useState(false);
|
|
30
|
+
const groups = useMemo(() => {
|
|
31
|
+
const map = new Map<Group, Requirement[]>();
|
|
32
|
+
for (const item of items) map.set(groupOf(item), [...(map.get(groupOf(item)) ?? []), item]);
|
|
33
|
+
return map;
|
|
34
|
+
}, [items]);
|
|
35
|
+
return (
|
|
36
|
+
<View style={{ gap: 20 }}>
|
|
37
|
+
{ORDER.filter((g) => groups.has(g) && !skip.includes(g)).map((g) => (
|
|
38
|
+
<View key={g} style={{ gap: 8 }}>
|
|
39
|
+
<Eyebrow
|
|
40
|
+
theme={theme}
|
|
41
|
+
accent={g === "attention"}
|
|
42
|
+
right={g === "other" ? <Button theme={theme} label={showOther ? "收起" : "展开"} onPress={() => setShowOther((v) => !v)} /> : <Text style={s.muted}>{GROUP_LABELS[g]}</Text>}
|
|
43
|
+
>
|
|
44
|
+
{EYEBROW[g]} · {groups.get(g)!.length}
|
|
45
|
+
</Eyebrow>
|
|
46
|
+
{g === "other" && !showOther
|
|
47
|
+
? null
|
|
48
|
+
: groups.get(g)!.map((item) => <RequirementRow key={item.key} theme={theme} layout={layout} item={item} onPress={() => open(item)} />)}
|
|
49
|
+
</View>
|
|
50
|
+
))}
|
|
51
|
+
</View>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Screens open other screens through the client context; index.client.tsx passes it in. */
|
|
56
|
+
export type ScreenOpener = (input: PluginOpenScreenInput) => void;
|
|
57
|
+
|
|
58
|
+
export function requirementOpener(openScreen: ScreenOpener): OpenRequirement {
|
|
59
|
+
return (item) => openScreen({ screenId: "requirement", params: { repo: item.repo, featureDir: item.featureDir, title: item.title } });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function OverviewScreen(props: PluginScreenProps & { openScreen: ScreenOpener }) {
|
|
63
|
+
const { theme, layout } = props;
|
|
64
|
+
const s = useStyles(theme, layout.compact);
|
|
65
|
+
const query = useRequirements();
|
|
66
|
+
const [project, setProject] = useState<string | null>(null);
|
|
67
|
+
const items = query.data ?? [];
|
|
68
|
+
const projects = useMemo(() => [...new Set(items.map((i) => i.project))].sort(), [items]);
|
|
69
|
+
const shown = project ? items.filter((i) => i.project === project) : items;
|
|
70
|
+
const open = requirementOpener(props.openScreen);
|
|
71
|
+
return (
|
|
72
|
+
<View style={s.screen}>
|
|
73
|
+
<ScrollView contentContainerStyle={s.body}>
|
|
74
|
+
<BrandHeader
|
|
75
|
+
theme={theme}
|
|
76
|
+
page="需求"
|
|
77
|
+
right={
|
|
78
|
+
<View style={s.row}>
|
|
79
|
+
<Button theme={theme} icon="ChartColumn" label="使用统计" onPress={() => props.openScreen({ screenId: "stats" })} />
|
|
80
|
+
<Button theme={theme} icon="Settings2" label="配置" onPress={() => props.openScreen({ screenId: "config" })} />
|
|
81
|
+
</View>
|
|
82
|
+
}
|
|
83
|
+
/>
|
|
84
|
+
{projects.length > 1 ? (
|
|
85
|
+
<View style={s.row}>
|
|
86
|
+
<Chip theme={theme} label="全部项目" active={project === null} onPress={() => setProject(null)} />
|
|
87
|
+
{projects.map((p) => (
|
|
88
|
+
<Chip key={p} theme={theme} label={p} active={project === p} onPress={() => setProject(p)} />
|
|
89
|
+
))}
|
|
90
|
+
</View>
|
|
91
|
+
) : null}
|
|
92
|
+
<Status
|
|
93
|
+
theme={theme}
|
|
94
|
+
loading={query.isPending}
|
|
95
|
+
error={query.error}
|
|
96
|
+
empty={query.data && items.length === 0 ? "这台机器上还没有记录任何需求。在 Paseo 对话中用 /laoshi 开始一个;1.9 之前运行过的需求,在项目目录运行 laoshi index --rebuild。" : null}
|
|
97
|
+
/>
|
|
98
|
+
{query.data && items.length > 0 ? <Inbox theme={theme} layout={layout} items={shown} open={open} openAgent={props.navigation ? (agentId) => props.navigation!.openAgent({ agentId }) : undefined} /> : null}
|
|
99
|
+
<RequirementGroups theme={theme} layout={layout} items={shown} open={open} skip={["attention"]} />
|
|
100
|
+
</ScrollView>
|
|
101
|
+
</View>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// The panel beside a workspace: the requirements developed in it or started from it.
|
|
2
|
+
import { type PluginWorkspacePanelProps, useWorkspace } from "@getpaseo/plugin/client";
|
|
3
|
+
import { ScrollView } from "@getpaseo/plugin/client/react-native";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Text, View } from "react-native";
|
|
6
|
+
import type { Requirement } from "../shared/contracts";
|
|
7
|
+
import { useRequirements } from "./data";
|
|
8
|
+
import { RequirementView } from "./detail";
|
|
9
|
+
import { RequirementGroups } from "./overview";
|
|
10
|
+
import { Button, Status, useStyles } from "./ui";
|
|
11
|
+
|
|
12
|
+
/** Same directory, ignoring a trailing separator and (on Windows) case. */
|
|
13
|
+
export function sameDir(a: string | null | undefined, b: string | null | undefined): boolean {
|
|
14
|
+
if (!a || !b) return false;
|
|
15
|
+
const norm = (p: string) => p.replace(/[\\/]+$/, "").replace(/\\/g, "/");
|
|
16
|
+
const x = norm(a);
|
|
17
|
+
const y = norm(b);
|
|
18
|
+
return /^[a-z]:\//i.test(x) ? x.toLowerCase() === y.toLowerCase() : x === y;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function inWorkspace(items: Requirement[], directory: string | null | undefined, workspaceId?: string | null): Requirement[] {
|
|
22
|
+
return items.filter((r) => (workspaceId && r.workspaceId === workspaceId) || sameDir(r.repo, directory) || sameDir(r.sourceRepo, directory));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function WorkspacePanel({ theme, layout, navigation, workspaceId }: PluginWorkspacePanelProps) {
|
|
26
|
+
const s = useStyles(theme, layout.compact);
|
|
27
|
+
const workspace = useWorkspace(workspaceId, (w) => ({ directory: w.directory, name: w.name }));
|
|
28
|
+
const query = useRequirements();
|
|
29
|
+
const [picked, setPicked] = useState<Pick<Requirement, "repo" | "featureDir"> | null>(null);
|
|
30
|
+
const items = inWorkspace(query.data ?? [], workspace?.directory, workspaceId);
|
|
31
|
+
const only = items.length === 1 ? items[0] : null;
|
|
32
|
+
const shown = picked ?? only;
|
|
33
|
+
return (
|
|
34
|
+
<View style={s.screen}>
|
|
35
|
+
<ScrollView contentContainerStyle={s.body}>
|
|
36
|
+
<Status
|
|
37
|
+
theme={theme}
|
|
38
|
+
loading={query.isPending}
|
|
39
|
+
error={query.error}
|
|
40
|
+
empty={query.data && items.length === 0 ? `${workspace?.name ?? "这个工作区"}还没有需求。在对话中用 /laoshi 开始一个。` : null}
|
|
41
|
+
/>
|
|
42
|
+
{shown ? (
|
|
43
|
+
<>
|
|
44
|
+
{picked && !only ? <Button theme={theme} label="返回列表" onPress={() => setPicked(null)} /> : null}
|
|
45
|
+
<RequirementView theme={theme} layout={layout} navigation={navigation} repo={shown.repo} featureDir={shown.featureDir} />
|
|
46
|
+
</>
|
|
47
|
+
) : items.length > 1 ? (
|
|
48
|
+
<>
|
|
49
|
+
<Text style={s.muted}>这个工作区有 {items.length} 个需求</Text>
|
|
50
|
+
<RequirementGroups theme={theme} layout={layout} items={items} open={(item) => setPicked(item)} />
|
|
51
|
+
</>
|
|
52
|
+
) : null}
|
|
53
|
+
</ScrollView>
|
|
54
|
+
</View>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// "审查原型" (1.13): the prototype review page inside Paseo. On the web and desktop apps it is
|
|
2
|
+
// embedded in this screen; on phones (and as a fallback) it opens in the browser.
|
|
3
|
+
import type { PluginHostProps, PluginScreenProps } from "@getpaseo/plugin/client";
|
|
4
|
+
import { ExternalLink } from "@getpaseo/plugin/client/ui";
|
|
5
|
+
import { Text, View } from "react-native";
|
|
6
|
+
import { useReviewUrl } from "./data";
|
|
7
|
+
import { openChecklist, openCodeReview, openReview } from "./nav";
|
|
8
|
+
import { Button, Status, useStyles } from "./ui";
|
|
9
|
+
import { canEmbedPages, embeddedPage, reviewUnreachable } from "./web";
|
|
10
|
+
|
|
11
|
+
type Theme = PluginHostProps["theme"];
|
|
12
|
+
|
|
13
|
+
/** 1.14: the acceptance checklist, primary while the requirement waits for acceptance. */
|
|
14
|
+
export function ChecklistButton({ theme, repo, featureDir, title, primary }: { theme: Theme; repo: string; featureDir: string; title: string; primary: boolean }) {
|
|
15
|
+
return <Button theme={theme} primary={primary} icon="ClipboardCheck" label="验收清单(可一键试用)" onPress={() => openChecklist({ repo, featureDir, title })} />;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** 1.14: the code review page: AI findings next to the code, the person's comments, pass or send back. */
|
|
19
|
+
export function CodeReviewButton({ theme, repo, featureDir, title, primary, label }: { theme: Theme; repo: string; featureDir: string; title: string; primary: boolean; label: string }) {
|
|
20
|
+
return <Button theme={theme} primary={primary} icon="GitPullRequest" label={label} onPress={() => openCodeReview({ repo, featureDir, title })} />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The button on a requirement with a prototype: primary while the design waits for confirmation. */
|
|
24
|
+
export function ReviewButton({ theme, repo, featureDir, title, waiting }: { theme: Theme; repo: string; featureDir: string; title: string; waiting: boolean }) {
|
|
25
|
+
return <Button theme={theme} primary={waiting} icon="PenTool" label={waiting ? "审查原型并确认方案" : "审查原型"} onPress={() => openReview({ repo, featureDir, title })} />;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function ReviewScreen({ theme, layout, params }: PluginScreenProps) {
|
|
29
|
+
const s = useStyles(theme, layout.compact);
|
|
30
|
+
const repo = params.repo ?? "";
|
|
31
|
+
const featureDir = params.featureDir ?? "";
|
|
32
|
+
const page = params.page === "check" ? "check" : params.page === "code" ? "code" : "prototype";
|
|
33
|
+
const review = useReviewUrl(repo, featureDir, true, page);
|
|
34
|
+
if (!review.data) {
|
|
35
|
+
return (
|
|
36
|
+
<View style={[s.screen, { padding: 16 }]}>
|
|
37
|
+
<Status theme={theme} loading={review.isPending} error={review.error} />
|
|
38
|
+
</View>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
const { url, readOnly } = review.data;
|
|
42
|
+
if (reviewUnreachable(url)) {
|
|
43
|
+
return (
|
|
44
|
+
<View style={[s.screen, { padding: 12 }]}>
|
|
45
|
+
<View style={[s.card, { gap: 8 }]}>
|
|
46
|
+
<Text style={s.text}>原型审查页只在运行 Paseo 的那台电脑上能打开(地址是 {new URL(url).host}),你现在是从另一台电脑打开的 Paseo 网页,所以看不到。</Text>
|
|
47
|
+
<Text style={s.muted}>{`办法:到运行 Paseo 的那台电脑上打开 Paseo 网页再点"审查原型";或者请管理员在那台电脑上设置环境变量 REQ_KIT_REVIEW_HOST=0.0.0.0 和 REQ_KIT_REVIEW_PUBLIC_URL=http://<那台电脑的地址>:6781,再重启 Paseo daemon,审查页就能从别的电脑打开(能连上那台电脑的人都能看到审查页,提交意见要用页面地址里的口令)。也可以直接看功能目录里的 preview.md 和 prototype/。`}</Text>
|
|
48
|
+
</View>
|
|
49
|
+
</View>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
const name = page === "check" ? "验收清单" : page === "code" ? "代码审查" : "原型审查";
|
|
53
|
+
const frame = canEmbedPages ? embeddedPage(url, `${name}:${params.title ?? featureDir}`) : null;
|
|
54
|
+
return (
|
|
55
|
+
<View style={[s.screen, { gap: 6 }]}>
|
|
56
|
+
<View style={[s.row, { paddingHorizontal: 12, paddingTop: 8, justifyContent: "space-between" }]}>
|
|
57
|
+
<Text style={s.muted}>
|
|
58
|
+
{page === "code"
|
|
59
|
+
? readOnly
|
|
60
|
+
? "插件设为只读:可以看改动和 AI 意见,不能提交评审。"
|
|
61
|
+
: "点代码行写意见,AI 的意见标要改或不用改;看完在底部退回修改或评审通过。"
|
|
62
|
+
: page === "check"
|
|
63
|
+
? readOnly
|
|
64
|
+
? "插件设为只读:可以看清单,不能提交。"
|
|
65
|
+
: "逐条核对:通过、不对(写下看到了什么)、先不验;需要时点右上角把它跑起来。"
|
|
66
|
+
: readOnly
|
|
67
|
+
? "插件设为只读:可以看原型,不能提交意见或确认。"
|
|
68
|
+
: "点原型上要改的地方提意见,双击文字直接改字;看完在右下角提交或确认方案。"}
|
|
69
|
+
</Text>
|
|
70
|
+
<ExternalLink href={url}>在新窗口打开</ExternalLink>
|
|
71
|
+
</View>
|
|
72
|
+
{frame ?? (
|
|
73
|
+
<View style={[s.card, { margin: 12, gap: 8 }]}>
|
|
74
|
+
<Text style={s.text}>{page === "prototype" ? "原型审查页" : name}在浏览器中打开效果最好(手机上屏幕较小,建议用电脑)。</Text>
|
|
75
|
+
<ExternalLink href={url}>{page === "prototype" ? "打开原型审查页" : `打开${name}`}</ExternalLink>
|
|
76
|
+
</View>
|
|
77
|
+
)}
|
|
78
|
+
</View>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// One requirement in a list: icon, title, project and feature directory, stage, what is running.
|
|
2
|
+
import type { PluginHostProps } from "@getpaseo/plugin/client";
|
|
3
|
+
import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
4
|
+
import { Pressable, Text, View } from "react-native";
|
|
5
|
+
import type { Requirement } from "../shared/contracts";
|
|
6
|
+
import { ago, ATTENTION_LABELS, iconOf } from "./format";
|
|
7
|
+
import { Badge, rk, useStyles } from "./ui";
|
|
8
|
+
|
|
9
|
+
export function RequirementRow({
|
|
10
|
+
theme,
|
|
11
|
+
layout,
|
|
12
|
+
item,
|
|
13
|
+
onPress,
|
|
14
|
+
}: Pick<PluginHostProps, "theme" | "layout"> & { item: Requirement; onPress(): void }) {
|
|
15
|
+
const s = useStyles(theme, layout.compact);
|
|
16
|
+
const c = rk(theme);
|
|
17
|
+
const ic = iconOf(item);
|
|
18
|
+
const iconColor =
|
|
19
|
+
ic.tone === "needs" ? c.brandText : ic.tone === "running" ? c.data : ic.tone === "success" ? theme.colors.statusSuccess : ic.tone === "warning" ? theme.colors.statusWarning : ic.tone === "danger" ? theme.colors.statusDanger : theme.colors.foregroundMuted;
|
|
20
|
+
return (
|
|
21
|
+
<Pressable
|
|
22
|
+
accessibilityRole="button"
|
|
23
|
+
accessibilityLabel={item.title}
|
|
24
|
+
onPress={onPress}
|
|
25
|
+
style={({ pressed }: { pressed: boolean }) => [s.card, { flexDirection: "row", alignItems: "center", gap: 12, backgroundColor: pressed ? theme.colors.surface2 : theme.colors.surface1 }]}
|
|
26
|
+
>
|
|
27
|
+
<Icon name={ic.name} size={18} color={iconColor} />
|
|
28
|
+
<View style={{ flex: 1, minWidth: 0, gap: 2 }}>
|
|
29
|
+
<Text style={[s.text, { fontWeight: "600" }]} numberOfLines={1}>
|
|
30
|
+
{item.title}
|
|
31
|
+
</Text>
|
|
32
|
+
<Text style={s.mono} numberOfLines={1}>
|
|
33
|
+
{item.project} · {item.name}
|
|
34
|
+
</Text>
|
|
35
|
+
{item.current.length > 0 ? (
|
|
36
|
+
<Text style={s.muted} numberOfLines={1}>
|
|
37
|
+
正在:{item.current.map((x) => x.title).join("、")}
|
|
38
|
+
</Text>
|
|
39
|
+
) : (
|
|
40
|
+
<Text style={s.muted} numberOfLines={1}>
|
|
41
|
+
{item.stage}
|
|
42
|
+
</Text>
|
|
43
|
+
)}
|
|
44
|
+
</View>
|
|
45
|
+
<View style={{ alignItems: "flex-end", gap: 4 }}>
|
|
46
|
+
{item.attention ? (
|
|
47
|
+
<Badge theme={theme} tone={item.attention === "interrupted" ? "danger" : item.attention === "not_completed" ? "warning" : "needs"}>
|
|
48
|
+
{ATTENTION_LABELS[item.attention]}
|
|
49
|
+
</Badge>
|
|
50
|
+
) : item.running ? (
|
|
51
|
+
<Badge theme={theme} tone="running" icon="LoaderCircle">
|
|
52
|
+
进行中
|
|
53
|
+
</Badge>
|
|
54
|
+
) : !item.present ? (
|
|
55
|
+
<Badge theme={theme} tone="muted">
|
|
56
|
+
目录已不在
|
|
57
|
+
</Badge>
|
|
58
|
+
) : null}
|
|
59
|
+
<Text style={s.mono}>{ago(item.updatedAt)}</Text>
|
|
60
|
+
</View>
|
|
61
|
+
</Pressable>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Settings → Plugins → laoshi: what the plugin found, the models (1.12), read-only mode, refresh interval.
|
|
2
|
+
import { type PluginSurfaceProps, type SettingsState, useSettings } from "@getpaseo/plugin/client";
|
|
3
|
+
import { SettingsAction, SettingsCard, SettingsInput, SettingsRow, SettingsSection, SettingsSelect, SettingsSwitch } from "@getpaseo/plugin/client/ui";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Text } from "react-native";
|
|
6
|
+
import { preferences } from "../shared/contracts";
|
|
7
|
+
import { useKitInfo } from "./data";
|
|
8
|
+
import { ModelSettings } from "./models";
|
|
9
|
+
|
|
10
|
+
type Ready = Extract<SettingsState<typeof preferences.schema>, { status: "ready" }>;
|
|
11
|
+
|
|
12
|
+
const REFRESH = [
|
|
13
|
+
{ label: "5 秒", value: "5" },
|
|
14
|
+
{ label: "10 秒", value: "10" },
|
|
15
|
+
{ label: "30 秒", value: "30" },
|
|
16
|
+
{ label: "1 分钟", value: "60" },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
function Controls({ settings, theme }: { settings: Ready; theme: PluginSurfaceProps["theme"] }) {
|
|
20
|
+
const [kitHome, setKitHome] = useState(settings.values.kitHome);
|
|
21
|
+
const info = useKitInfo();
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<SettingsSection title="laoshi">
|
|
25
|
+
<SettingsCard>
|
|
26
|
+
{info.data ? (
|
|
27
|
+
<>
|
|
28
|
+
<SettingsRow label="版本" hint={info.data.kitRoot}>
|
|
29
|
+
<Text style={{ color: theme.colors.foreground }}>{info.data.kitVersion}</Text>
|
|
30
|
+
</SettingsRow>
|
|
31
|
+
<SettingsRow label="支持的 Paseo" hint={`本机配置目录:${info.data.kitHome}`}>
|
|
32
|
+
<Text style={{ color: theme.colors.foreground }}>{info.data.paseo ?? "-"}</Text>
|
|
33
|
+
</SettingsRow>
|
|
34
|
+
</>
|
|
35
|
+
) : (
|
|
36
|
+
<SettingsRow label="状态" error={info.error?.message ?? undefined} hint={info.isPending ? "正在读取…" : undefined} />
|
|
37
|
+
)}
|
|
38
|
+
<SettingsInput
|
|
39
|
+
label="laoshi 的安装根"
|
|
40
|
+
hint="通常不用填:插件就装在安装根下,会自己找到。安装根换过位置(LAOSHI_HOME)又找不到时填那个目录。"
|
|
41
|
+
initialValue={settings.values.kitHome}
|
|
42
|
+
placeholder="~/.laoshi"
|
|
43
|
+
onChangeText={setKitHome}
|
|
44
|
+
disabled={settings.saving}
|
|
45
|
+
error={settings.saveError ?? undefined}
|
|
46
|
+
/>
|
|
47
|
+
<SettingsAction
|
|
48
|
+
label="保存配置目录"
|
|
49
|
+
actionLabel="保存"
|
|
50
|
+
disabled={settings.saving || kitHome === settings.values.kitHome}
|
|
51
|
+
onPress={() => void settings.save({ ...settings.values, kitHome: kitHome.trim() }, settings.revision).then(() => info.refetch())}
|
|
52
|
+
/>
|
|
53
|
+
</SettingsCard>
|
|
54
|
+
</SettingsSection>
|
|
55
|
+
<ModelSettings theme={theme} readOnly={settings.values.readOnly} />
|
|
56
|
+
<SettingsSection title="显示与操作">
|
|
57
|
+
<SettingsCard>
|
|
58
|
+
<SettingsSwitch
|
|
59
|
+
label="只读"
|
|
60
|
+
hint="只显示需求和文档,不提供确认方案、停止、继续、开始测试验证。能连上这台 daemon 的人都能看到这个插件。"
|
|
61
|
+
value={settings.values.readOnly}
|
|
62
|
+
disabled={settings.saving}
|
|
63
|
+
onValueChange={(readOnly) => void settings.save({ ...settings.values, readOnly }, settings.revision)}
|
|
64
|
+
/>
|
|
65
|
+
<SettingsSelect
|
|
66
|
+
label="刷新间隔"
|
|
67
|
+
value={String(settings.values.refreshSeconds)}
|
|
68
|
+
options={REFRESH}
|
|
69
|
+
disabled={settings.saving}
|
|
70
|
+
onValueChange={(v) => void settings.save({ ...settings.values, refreshSeconds: Number(v) }, settings.revision)}
|
|
71
|
+
/>
|
|
72
|
+
</SettingsCard>
|
|
73
|
+
</SettingsSection>
|
|
74
|
+
</>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function SettingsScreen({ theme }: PluginSurfaceProps) {
|
|
79
|
+
const settings = useSettings(preferences);
|
|
80
|
+
if (settings.status === "loading") return <Text style={{ color: theme.colors.foregroundMuted }}>正在读取…</Text>;
|
|
81
|
+
if (settings.status !== "ready") {
|
|
82
|
+
return (
|
|
83
|
+
<SettingsSection title="设置">
|
|
84
|
+
<SettingsCard>
|
|
85
|
+
<SettingsRow label="设置读取失败" error={settings.error} />
|
|
86
|
+
<SettingsAction label="恢复默认设置" actionLabel="恢复" onPress={() => void settings.reset()} />
|
|
87
|
+
</SettingsCard>
|
|
88
|
+
</SettingsSection>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
return <Controls settings={settings} theme={theme} />;
|
|
92
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// The "需求" row in the sidebar, with how many requirements need a person.
|
|
2
|
+
import type { PluginSidebarItemProps } from "@getpaseo/plugin/client";
|
|
3
|
+
import { SidebarRow } from "@getpaseo/plugin/client/ui";
|
|
4
|
+
import { Text, View } from "react-native";
|
|
5
|
+
import { useRequirements } from "./data";
|
|
6
|
+
|
|
7
|
+
export function RequirementsItem({ theme, currentScreen, openScreen }: PluginSidebarItemProps) {
|
|
8
|
+
const query = useRequirements();
|
|
9
|
+
const waiting = (query.data ?? []).filter((r) => r.attention).length;
|
|
10
|
+
return (
|
|
11
|
+
<SidebarRow
|
|
12
|
+
icon="ClipboardList"
|
|
13
|
+
label="需求"
|
|
14
|
+
active={currentScreen !== null}
|
|
15
|
+
onPress={() => openScreen({ screenId: "overview" })}
|
|
16
|
+
trailing={
|
|
17
|
+
waiting > 0 ? (
|
|
18
|
+
<View style={{ backgroundColor: theme.colors.statusWarning, borderRadius: 999, minWidth: 18, paddingHorizontal: 5, alignItems: "center" }}>
|
|
19
|
+
<Text accessibilityLabel={`${waiting} 个需求需要处理`} style={{ color: theme.colors.surface0, fontSize: 11, fontWeight: "600" }}>
|
|
20
|
+
{waiting}
|
|
21
|
+
</Text>
|
|
22
|
+
</View>
|
|
23
|
+
) : undefined
|
|
24
|
+
}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|