@yiyi_zhang/laoshi 0.2.0-beta.1 → 0.2.0-beta.3
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 +1 -0
- package/adapters/mogao/install.mjs +1 -1
- package/adapters/mogao/make-expert.mjs +1 -0
- package/adapters/mogao/mogao-runtime.ts +98 -17
- 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 +8 -7
- package/bin/req.mjs +10 -2
- package/contracts/README.md +1 -1
- package/contracts/agent-runtime.md +2 -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 +3 -1
- 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 +4 -0
- package/engine/src/doctor.ts +3 -2
- package/engine/src/identity.ts +16 -1
- package/engine/src/main.ts +3 -1
- package/engine/src/messages.ts +1 -1
- package/engine/src/platform.ts +2 -0
- package/engine/src/runtime-loader.ts +14 -0
- package/engine/src/state.ts +2 -0
- package/engine/src/words.ts +1 -1
- package/package.json +2 -1
- package/site-dist/404.html +2 -2
- package/site-dist/assets/{app.DMAHANCl.js → app.CXydUhZx.js} +1 -1
- package/site-dist/assets/changelog.md.BU-CvyJ1.js +1 -0
- package/site-dist/assets/changelog.md.BU-CvyJ1.lean.js +1 -0
- package/site-dist/assets/chunks/@localSearchIndexroot.CfgJeQRO.js +1 -0
- package/site-dist/assets/chunks/{VPLocalSearchBox.COsLwqWS.js → VPLocalSearchBox.CIjDV0ax.js} +1 -1
- package/site-dist/assets/chunks/{theme.CeR3HD86.js → theme.CWtC1Kby.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.Bytaz3L8.js → guide_getting-started.md.BxOxfic_.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.TK7Lhwdf.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/site-dist/assets/changelog.md.Q8QGpuBY.js +0 -1
- package/site-dist/assets/changelog.md.Q8QGpuBY.lean.js +0 -1
- package/site-dist/assets/chunks/@localSearchIndexroot.CQdjFK3w.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.TK7Lhwdf.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/{guide_getting-started.md.Bytaz3L8.lean.js → guide_getting-started.md.BxOxfic_.lean.js} +0 -0
- /package/site-dist/assets/{reference_contracts_state.md.DVHC4opX.lean.js → reference_contracts_state.md.DLygjkfs.lean.js} +0 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// "laoshi 配置" (1.12): every setting that applies, in plain words, with where each one comes
|
|
2
|
+
// from (default, this machine, the team, the project) and how to change it. Read-only: changes
|
|
3
|
+
// go through the files, laoshi configure, /laoshi-setup, or the model settings page.
|
|
4
|
+
import type { PluginHostProps, PluginScreenProps } from "@getpaseo/plugin/client";
|
|
5
|
+
import { ScrollView, TextInput } from "@getpaseo/plugin/client/react-native";
|
|
6
|
+
import { useMemo, useState } from "react";
|
|
7
|
+
import { Pressable, Text, View } from "react-native";
|
|
8
|
+
import type { ConfigItemData, ConfigLayer, ConfigViewData } from "../shared/contracts";
|
|
9
|
+
import { useConfigView, useRequirements } from "./data";
|
|
10
|
+
import { Badge, Chip, Status, useStyles } from "./ui";
|
|
11
|
+
|
|
12
|
+
type Theme = PluginHostProps["theme"];
|
|
13
|
+
type Layout = PluginHostProps["layout"];
|
|
14
|
+
|
|
15
|
+
const LAYER: Record<ConfigLayer, { label: string; tone: "accent" | "success" | "warning"; hint: string }> = {
|
|
16
|
+
machine: { label: "本机", tone: "accent", hint: "这台机器自己的设置" },
|
|
17
|
+
team: { label: "团队", tone: "warning", hint: "团队共用的配置,覆盖本机的同名设置" },
|
|
18
|
+
project: { label: "项目", tone: "success", hint: "项目仓库中的设置,覆盖本机和团队的" },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const SCOPE_NOTE: Record<ConfigItemData["scope"], string | null> = {
|
|
22
|
+
any: null,
|
|
23
|
+
machine: "只能在本机配置中设置",
|
|
24
|
+
machine_team: "只能在本机或团队配置中设置(会运行命令或发消息)",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** Where an item's value comes from: the last file that set it to something other than the default. */
|
|
28
|
+
function originOf(item: ConfigItemData): ConfigLayer | null {
|
|
29
|
+
return item.changed ? (item.setBy.at(-1) ?? null) : null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function ItemRow({ theme, layout, item }: { theme: Theme; layout: Layout; item: ConfigItemData }) {
|
|
33
|
+
const s = useStyles(theme, layout.compact);
|
|
34
|
+
const [open, setOpen] = useState(false);
|
|
35
|
+
const origin = originOf(item);
|
|
36
|
+
const scope = SCOPE_NOTE[item.scope];
|
|
37
|
+
return (
|
|
38
|
+
<Pressable
|
|
39
|
+
accessibilityRole="button"
|
|
40
|
+
accessibilityLabel={`${item.label}:${item.display}`}
|
|
41
|
+
accessibilityState={{ selected: open }}
|
|
42
|
+
onPress={() => setOpen((v) => !v)}
|
|
43
|
+
style={{ paddingVertical: 10, gap: 4 }}
|
|
44
|
+
>
|
|
45
|
+
<View style={[s.row, { justifyContent: "space-between", flexWrap: "nowrap" }]}>
|
|
46
|
+
<Text style={[s.text, { fontWeight: "600", flexShrink: 1 }]}>{item.label}</Text>
|
|
47
|
+
{origin ? (
|
|
48
|
+
<Badge theme={theme} tone={LAYER[origin].tone}>
|
|
49
|
+
{LAYER[origin].label}
|
|
50
|
+
</Badge>
|
|
51
|
+
) : (
|
|
52
|
+
<Badge theme={theme} tone="muted">
|
|
53
|
+
默认
|
|
54
|
+
</Badge>
|
|
55
|
+
)}
|
|
56
|
+
</View>
|
|
57
|
+
<Text style={s.text}>{item.display}</Text>
|
|
58
|
+
{item.description ? <Text style={s.muted}>{item.description}</Text> : null}
|
|
59
|
+
{open ? (
|
|
60
|
+
<View style={{ gap: 6, marginTop: 4 }}>
|
|
61
|
+
<Text style={s.muted}>
|
|
62
|
+
配置项 <Text style={{ fontFamily: "monospace", color: theme.colors.foreground }}>{item.key}</Text>
|
|
63
|
+
{item.setBy.length > 0 ? ` · 写在${item.setBy.map((l) => LAYER[l].label).join("、")}配置中` : " · 没有在任何配置文件中写,用的是默认值"}
|
|
64
|
+
{scope ? ` · ${scope}` : ""}
|
|
65
|
+
</Text>
|
|
66
|
+
<View style={{ backgroundColor: theme.colors.surface0, borderRadius: 8, borderWidth: 1, borderColor: theme.colors.border, padding: 10 }}>
|
|
67
|
+
<Text selectable style={{ fontFamily: "monospace", fontSize: 12, color: theme.colors.foreground }}>
|
|
68
|
+
{JSON.stringify(item.value, null, 2) ?? "null"}
|
|
69
|
+
</Text>
|
|
70
|
+
</View>
|
|
71
|
+
</View>
|
|
72
|
+
) : null}
|
|
73
|
+
</Pressable>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function Sources({ theme, layout, view }: { theme: Theme; layout: Layout; view: ConfigViewData }) {
|
|
78
|
+
const s = useStyles(theme, layout.compact);
|
|
79
|
+
return (
|
|
80
|
+
<View style={[s.card, { gap: 8 }]}>
|
|
81
|
+
<Text style={s.heading}>配置从哪里来</Text>
|
|
82
|
+
<Text style={s.muted}>按下面的顺序叠加,后面的覆盖前面的;没有写的用 laoshi 的默认值。</Text>
|
|
83
|
+
{view.sources.length === 0 ? <Text style={s.text}>还没有本机配置文件。在终端运行 laoshi install 生成。</Text> : null}
|
|
84
|
+
{view.sources.map((src, i) => (
|
|
85
|
+
<View key={src.path} style={[s.row, { flexWrap: "nowrap", alignItems: "flex-start" }]}>
|
|
86
|
+
<Text style={[s.muted, { width: 18 }]}>{i + 1}.</Text>
|
|
87
|
+
<Badge theme={theme} tone={LAYER[src.layer].tone}>
|
|
88
|
+
{LAYER[src.layer].label}
|
|
89
|
+
</Badge>
|
|
90
|
+
<View style={{ flexShrink: 1, gap: 2 }}>
|
|
91
|
+
<Text selectable style={[s.text, { fontFamily: "monospace", fontSize: 12 }]}>
|
|
92
|
+
{src.path}
|
|
93
|
+
</Text>
|
|
94
|
+
<Text style={s.muted}>{LAYER[src.layer].hint}</Text>
|
|
95
|
+
</View>
|
|
96
|
+
</View>
|
|
97
|
+
))}
|
|
98
|
+
{view.ignored.length > 0 ? <Text style={{ color: theme.colors.statusWarning, fontSize: 13 }}>没有生效:{view.ignored.join("、")}(这些设置不能写在团队或项目配置中)</Text> : null}
|
|
99
|
+
</View>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function ConfigScreen({ theme, layout }: PluginScreenProps) {
|
|
104
|
+
const s = useStyles(theme, layout.compact);
|
|
105
|
+
const requirements = useRequirements();
|
|
106
|
+
// A project is any checkout requirements were started from.
|
|
107
|
+
const projects = useMemo(() => {
|
|
108
|
+
const map = new Map<string, string>();
|
|
109
|
+
for (const r of requirements.data ?? []) if (r.present) map.set(r.sourceRepo ?? r.repo, r.project);
|
|
110
|
+
return [...map.entries()].sort((a, b) => a[1].localeCompare(b[1]));
|
|
111
|
+
}, [requirements.data]);
|
|
112
|
+
const [repo, setRepo] = useState<string | null>(null);
|
|
113
|
+
const [query, setQuery] = useState("");
|
|
114
|
+
const [changedOnly, setChangedOnly] = useState(false);
|
|
115
|
+
const config = useConfigView(repo);
|
|
116
|
+
const view = config.data;
|
|
117
|
+
|
|
118
|
+
const groups = useMemo(() => {
|
|
119
|
+
if (!view) return [];
|
|
120
|
+
const q = query.trim().toLowerCase();
|
|
121
|
+
return view.groups
|
|
122
|
+
.map((g) => ({
|
|
123
|
+
...g,
|
|
124
|
+
items: g.items.filter(
|
|
125
|
+
(i) => (!changedOnly || i.changed) && (!q || `${i.label} ${i.key} ${i.display} ${i.description}`.toLowerCase().includes(q)),
|
|
126
|
+
),
|
|
127
|
+
}))
|
|
128
|
+
.filter((g) => g.items.length > 0);
|
|
129
|
+
}, [view, query, changedOnly]);
|
|
130
|
+
const changedCount = view ? view.groups.reduce((n, g) => n + g.items.filter((i) => i.changed).length, 0) : 0;
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<View style={s.screen}>
|
|
134
|
+
<ScrollView contentContainerStyle={s.body}>
|
|
135
|
+
<View style={{ gap: 4 }}>
|
|
136
|
+
<Text style={s.title}>laoshi 配置</Text>
|
|
137
|
+
<Text style={s.muted}>这台机器上生效的全部设置,用大白话写出每一项是什么、现在是什么、来自哪个文件。这一页只看不改,修改方法在最下面。</Text>
|
|
138
|
+
</View>
|
|
139
|
+
|
|
140
|
+
<View style={{ gap: 6 }}>
|
|
141
|
+
<Text style={s.heading}>看哪里的配置</Text>
|
|
142
|
+
<View style={s.row}>
|
|
143
|
+
<Chip theme={theme} label="本机(不含项目)" active={repo === null} onPress={() => setRepo(null)} />
|
|
144
|
+
{projects.map(([dir, name]) => (
|
|
145
|
+
<Chip key={dir} theme={theme} label={name} active={repo === dir} onPress={() => setRepo(dir)} />
|
|
146
|
+
))}
|
|
147
|
+
</View>
|
|
148
|
+
{projects.length === 0 ? <Text style={s.muted}>开始过需求的项目会出现在这里,可以看到项目配置叠加后的结果。</Text> : null}
|
|
149
|
+
</View>
|
|
150
|
+
|
|
151
|
+
<Status theme={theme} loading={config.isPending} error={config.error} />
|
|
152
|
+
{view ? (
|
|
153
|
+
<>
|
|
154
|
+
{view.error ? (
|
|
155
|
+
<View style={[s.card, { borderColor: theme.colors.statusDanger }]}>
|
|
156
|
+
<Text style={[s.text, { color: theme.colors.statusDanger, fontWeight: "600" }]}>配置有错误,流水线现在无法启动</Text>
|
|
157
|
+
<Text style={s.text}>{view.error}</Text>
|
|
158
|
+
<Text style={s.muted}>下面显示的是各文件中写的值。修好后在终端运行 laoshi doctor 检查。</Text>
|
|
159
|
+
</View>
|
|
160
|
+
) : null}
|
|
161
|
+
<Sources theme={theme} layout={layout} view={view} />
|
|
162
|
+
|
|
163
|
+
<View style={{ gap: 8 }}>
|
|
164
|
+
<TextInput
|
|
165
|
+
value={query}
|
|
166
|
+
onChangeText={setQuery}
|
|
167
|
+
placeholder="搜索设置,例如:超时、备用模型、推送"
|
|
168
|
+
placeholderTextColor={theme.colors.foregroundMuted}
|
|
169
|
+
style={{
|
|
170
|
+
paddingHorizontal: 12,
|
|
171
|
+
paddingVertical: 8,
|
|
172
|
+
borderRadius: 8,
|
|
173
|
+
borderWidth: 1,
|
|
174
|
+
borderColor: theme.colors.border,
|
|
175
|
+
backgroundColor: theme.colors.surface1,
|
|
176
|
+
color: theme.colors.foreground,
|
|
177
|
+
fontSize: 14,
|
|
178
|
+
}}
|
|
179
|
+
/>
|
|
180
|
+
<View style={s.row}>
|
|
181
|
+
<Chip theme={theme} label="全部" active={!changedOnly} onPress={() => setChangedOnly(false)} />
|
|
182
|
+
<Chip theme={theme} label={`只看改过的(${changedCount})`} active={changedOnly} onPress={() => setChangedOnly(true)} />
|
|
183
|
+
</View>
|
|
184
|
+
</View>
|
|
185
|
+
|
|
186
|
+
{groups.length === 0 ? <Text style={s.muted}>{changedOnly && !query ? "所有设置都是默认值。" : "没有符合的设置。"}</Text> : null}
|
|
187
|
+
{groups.map((g) => (
|
|
188
|
+
<View key={g.id} style={{ gap: 6 }}>
|
|
189
|
+
<View style={{ gap: 2 }}>
|
|
190
|
+
<Text style={[s.text, { fontSize: 15, fontWeight: "600" }]}>{g.title}</Text>
|
|
191
|
+
<Text style={s.muted}>{g.description}</Text>
|
|
192
|
+
</View>
|
|
193
|
+
<View style={[s.card, { paddingVertical: 2 }]}>
|
|
194
|
+
{g.items.map((item, i) => (
|
|
195
|
+
<View key={item.key}>
|
|
196
|
+
{i > 0 ? <View style={s.divider} /> : null}
|
|
197
|
+
<ItemRow theme={theme} layout={layout} item={item} />
|
|
198
|
+
</View>
|
|
199
|
+
))}
|
|
200
|
+
</View>
|
|
201
|
+
</View>
|
|
202
|
+
))}
|
|
203
|
+
|
|
204
|
+
<View style={[s.card, { gap: 6 }]}>
|
|
205
|
+
<Text style={s.heading}>怎么修改</Text>
|
|
206
|
+
<Text style={s.text}>· 模型(builder、reviewer、备用模型):设置 → 插件 → laoshi → 模型,或在终端运行 laoshi configure。</Text>
|
|
207
|
+
<Text style={s.text}>· 项目的检查命令、服务启动方式、接哪些卡片:在项目的对话中运行 /laoshi-setup。</Text>
|
|
208
|
+
<Text style={s.text}>· 其他设置:编辑上面"配置从哪里来"中的文件,写法见 laoshi 文档的《项目定制与运行规则》。改完运行 laoshi doctor 检查。</Text>
|
|
209
|
+
<Text style={s.muted}>密码、令牌等看起来像密钥的值和个人账号不会在这里显示。</Text>
|
|
210
|
+
</View>
|
|
211
|
+
</>
|
|
212
|
+
) : null}
|
|
213
|
+
</ScrollView>
|
|
214
|
+
</View>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Data hooks: every read is an RPC to the daemon side (laoshi api), cached by React Query.
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { useRpc, useSettings } from "@getpaseo/plugin/client";
|
|
4
|
+
import { configRpc, fileRpc, listRpc, modelsRpc, preferences, reviewUrlRpc, runRpc, setAgentsRpc, statsRpc, statusRpc, versionRpc, type Action, type AgentProfileData } from "../shared/contracts";
|
|
5
|
+
|
|
6
|
+
export function usePreferences(): { readOnly: boolean; refreshMs: number } {
|
|
7
|
+
const settings = useSettings(preferences);
|
|
8
|
+
if (settings.status !== "ready") return { readOnly: true, refreshMs: 10_000 };
|
|
9
|
+
return { readOnly: settings.values.readOnly, refreshMs: settings.values.refreshSeconds * 1000 };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useRequirements() {
|
|
13
|
+
const list = useRpc(listRpc);
|
|
14
|
+
const { refreshMs } = usePreferences();
|
|
15
|
+
return useQuery({ queryKey: ["req", "list"], queryFn: () => list({}), refetchInterval: refreshMs });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useRequirement(repo: string, featureDir: string) {
|
|
19
|
+
const status = useRpc(statusRpc);
|
|
20
|
+
const { refreshMs } = usePreferences();
|
|
21
|
+
return useQuery({
|
|
22
|
+
queryKey: ["req", "status", repo, featureDir],
|
|
23
|
+
queryFn: () => status({ repo, featureDir }),
|
|
24
|
+
refetchInterval: refreshMs,
|
|
25
|
+
enabled: Boolean(repo && featureDir),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function useDocument(repo: string, featureDir: string, file: string | null) {
|
|
30
|
+
const read = useRpc(fileRpc);
|
|
31
|
+
return useQuery({
|
|
32
|
+
queryKey: ["req", "file", repo, featureDir, file],
|
|
33
|
+
queryFn: () => read({ repo, featureDir, file: file ?? "" }),
|
|
34
|
+
enabled: Boolean(file),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function useStats(period: { since?: string; month?: string }) {
|
|
39
|
+
const stats = useRpc(statsRpc);
|
|
40
|
+
return useQuery({ queryKey: ["req", "stats", period.since ?? "", period.month ?? ""], queryFn: () => stats(period) });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function useKitInfo() {
|
|
44
|
+
const version = useRpc(versionRpc);
|
|
45
|
+
return useQuery({ queryKey: ["req", "version"], queryFn: () => version({}), retry: false });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function useAction() {
|
|
49
|
+
const run = useRpc(runRpc);
|
|
50
|
+
const queries = useQueryClient();
|
|
51
|
+
return useMutation({
|
|
52
|
+
mutationFn: (input: { action: Action; repo: string; featureDir: string; verifyEnv?: "local" | "deployed"; text?: string }) => run(input),
|
|
53
|
+
onSettled: () => queries.invalidateQueries({ queryKey: ["req"] }),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function useModels() {
|
|
58
|
+
const models = useRpc(modelsRpc);
|
|
59
|
+
return useQuery({ queryKey: ["req", "models"], queryFn: () => models({}), retry: false });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function useSetAgents() {
|
|
63
|
+
const set = useRpc(setAgentsRpc);
|
|
64
|
+
const queries = useQueryClient();
|
|
65
|
+
return useMutation({
|
|
66
|
+
mutationFn: (input: { builder: AgentProfileData; reviewer: AgentProfileData; fallback: AgentProfileData | null }) => set(input),
|
|
67
|
+
onSettled: () => queries.invalidateQueries({ queryKey: ["req", "models"] }),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function useConfigView(repo: string | null) {
|
|
72
|
+
const config = useRpc(configRpc);
|
|
73
|
+
return useQuery({ queryKey: ["req", "config", repo ?? ""], queryFn: () => config(repo ? { repo } : {}), retry: false });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The prototype review page's address (1.13); it stays valid while its server runs. */
|
|
77
|
+
export function useReviewUrl(repo: string, featureDir: string, enabled: boolean, page: "prototype" | "check" | "code" = "prototype") {
|
|
78
|
+
const reviewUrl = useRpc(reviewUrlRpc);
|
|
79
|
+
return useQuery({
|
|
80
|
+
queryKey: ["req", "review-url", repo, featureDir, page],
|
|
81
|
+
queryFn: () => reviewUrl({ repo, featureDir, ...(page !== "prototype" ? { page } : {}) }),
|
|
82
|
+
enabled: enabled && Boolean(repo && featureDir),
|
|
83
|
+
retry: false,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
// One requirement: where it stands, its steps, the quality gate, its documents, and the
|
|
2
|
+
// management actions (each one is `req <command>` on the daemon machine, after confirming).
|
|
3
|
+
import type { PluginHostProps, PluginScreenProps, PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
4
|
+
import { Modal, ScrollView, useToast } from "@getpaseo/plugin/client/react-native";
|
|
5
|
+
import { ExternalLink } from "@getpaseo/plugin/client/ui";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { Pressable, Text, View } from "react-native";
|
|
8
|
+
import type { Action, RequirementDetail, Step } from "../shared/contracts";
|
|
9
|
+
import { useAction, useDocument, usePreferences, useRequirement, useRequirements } from "./data";
|
|
10
|
+
import { ACTION_TEXT, actionsFor, ago, ATTENTION_LABELS, facts, FILE_LABELS, minutes, tokens, trackOf } from "./format";
|
|
11
|
+
import { Markdown, tsvToMarkdown } from "./markdown";
|
|
12
|
+
import { ChecklistButton, CodeReviewButton, ReviewButton } from "./review";
|
|
13
|
+
import { Badge, Button, Chip, Eyebrow, rk, Status, StepTrack, useStyles } from "./ui";
|
|
14
|
+
|
|
15
|
+
type Theme = PluginHostProps["theme"];
|
|
16
|
+
type Layout = PluginHostProps["layout"];
|
|
17
|
+
type Navigation = PluginSurfaceProps["navigation"];
|
|
18
|
+
|
|
19
|
+
const OUTCOME_LABELS: Record<Step["outcome"], string> = { running: "运行中", completed: "完成", failed: "失败" };
|
|
20
|
+
|
|
21
|
+
function StepRow({ theme, layout, step, navigation }: { theme: Theme; layout: Layout; step: Step; navigation: Navigation }) {
|
|
22
|
+
const s = useStyles(theme, layout.compact);
|
|
23
|
+
const tone = step.outcome === "failed" ? "danger" : step.outcome === "running" ? "running" : "muted";
|
|
24
|
+
const body = (
|
|
25
|
+
<View style={{ gap: 2, paddingVertical: 6 }}>
|
|
26
|
+
<View style={s.row}>
|
|
27
|
+
<Text style={[s.text, { flexShrink: 1 }]}>{step.title}</Text>
|
|
28
|
+
<Badge theme={theme} tone={tone}>
|
|
29
|
+
{step.outcome === "completed" && step.result ? step.result : OUTCOME_LABELS[step.outcome]}
|
|
30
|
+
</Badge>
|
|
31
|
+
</View>
|
|
32
|
+
<Text style={s.muted}>
|
|
33
|
+
第 {step.attempt} 次尝试 · {minutes(step.minutes)} · {ago(step.startedAt)}开始
|
|
34
|
+
</Text>
|
|
35
|
+
{step.error ? <Text style={s.danger}>{step.error}</Text> : null}
|
|
36
|
+
</View>
|
|
37
|
+
);
|
|
38
|
+
// A step agent opens in Paseo, where its whole conversation is.
|
|
39
|
+
if (!navigation || !step.agentId) return body;
|
|
40
|
+
return (
|
|
41
|
+
<Pressable accessibilityRole="button" accessibilityLabel={`打开 ${step.title} 的 agent`} onPress={() => navigation.openAgent({ agentId: step.agentId })}>
|
|
42
|
+
{body}
|
|
43
|
+
</Pressable>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function DocumentModal({
|
|
48
|
+
theme,
|
|
49
|
+
layout,
|
|
50
|
+
repo,
|
|
51
|
+
featureDir,
|
|
52
|
+
file,
|
|
53
|
+
onClose,
|
|
54
|
+
}: {
|
|
55
|
+
theme: Theme;
|
|
56
|
+
layout: Layout;
|
|
57
|
+
repo: string;
|
|
58
|
+
featureDir: string;
|
|
59
|
+
file: string | null;
|
|
60
|
+
onClose(): void;
|
|
61
|
+
}) {
|
|
62
|
+
const s = useStyles(theme, layout.compact);
|
|
63
|
+
const doc = useDocument(repo, featureDir, file);
|
|
64
|
+
return (
|
|
65
|
+
<Modal title={file ? `${FILE_LABELS[file] ?? file}(${file})` : ""} open={file !== null} onOpenChange={(open) => (open ? undefined : onClose())}>
|
|
66
|
+
<Modal.Content>
|
|
67
|
+
<Status theme={theme} loading={doc.isPending} error={doc.error} />
|
|
68
|
+
{doc.data ? (
|
|
69
|
+
<>
|
|
70
|
+
<Markdown theme={theme} source={doc.data.file.endsWith(".tsv") ? tsvToMarkdown(doc.data.content) : doc.data.content} />
|
|
71
|
+
{doc.data.truncated ? <Text style={s.muted}>文件较大,只显示了开头的 512 KB。</Text> : null}
|
|
72
|
+
</>
|
|
73
|
+
) : null}
|
|
74
|
+
</Modal.Content>
|
|
75
|
+
</Modal>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function ActionModal({
|
|
80
|
+
theme,
|
|
81
|
+
layout,
|
|
82
|
+
detail,
|
|
83
|
+
action,
|
|
84
|
+
onClose,
|
|
85
|
+
}: {
|
|
86
|
+
theme: Theme;
|
|
87
|
+
layout: Layout;
|
|
88
|
+
detail: RequirementDetail;
|
|
89
|
+
action: Action | null;
|
|
90
|
+
onClose(): void;
|
|
91
|
+
}) {
|
|
92
|
+
const s = useStyles(theme, layout.compact);
|
|
93
|
+
const run = useAction();
|
|
94
|
+
const toast = useToast();
|
|
95
|
+
const go = async (verifyEnv?: "local" | "deployed") => {
|
|
96
|
+
if (!action) return;
|
|
97
|
+
try {
|
|
98
|
+
const result = await run.mutateAsync({ action, repo: detail.sourceRepo ?? detail.repo, featureDir: detail.featureDir, verifyEnv });
|
|
99
|
+
const first = result.message.split("\n").find((l) => l.trim()) ?? "";
|
|
100
|
+
if (result.ok) toast.show(first || "已完成", { variant: "success", durationMs: 4000 });
|
|
101
|
+
else toast.error(first || "没有完成");
|
|
102
|
+
onClose();
|
|
103
|
+
} catch (error) {
|
|
104
|
+
toast.error((error as Error).message);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const text = action ? ACTION_TEXT[action] : null;
|
|
108
|
+
return (
|
|
109
|
+
<Modal title={text ? `${text.label}:${detail.title}` : ""} open={action !== null} onOpenChange={(open) => (open ? undefined : onClose())}>
|
|
110
|
+
<Modal.Content>
|
|
111
|
+
<Text style={s.text}>{text?.confirm}</Text>
|
|
112
|
+
{action === "approve" && detail.files.includes("preview.md") ? <Text style={s.muted}>确认预览在本页的"文档"中:确认预览(preview.md)。</Text> : null}
|
|
113
|
+
<View style={s.row}>
|
|
114
|
+
{action === "verify" ? (
|
|
115
|
+
<>
|
|
116
|
+
<Button theme={theme} primary label="在本地验证" disabled={run.isPending} onPress={() => void go("local")} />
|
|
117
|
+
<Button theme={theme} label="在已部署的测试环境验证" disabled={run.isPending} onPress={() => void go("deployed")} />
|
|
118
|
+
</>
|
|
119
|
+
) : (
|
|
120
|
+
<Button theme={theme} primary label={run.isPending ? "正在执行…" : (text?.label ?? "")} disabled={run.isPending} onPress={() => void go()} />
|
|
121
|
+
)}
|
|
122
|
+
<Button theme={theme} label="取消" disabled={run.isPending} onPress={onClose} />
|
|
123
|
+
</View>
|
|
124
|
+
</Modal.Content>
|
|
125
|
+
</Modal>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function GateSummary({ theme, layout, detail }: { theme: Theme; layout: Layout; detail: RequirementDetail }) {
|
|
130
|
+
const s = useStyles(theme, layout.compact);
|
|
131
|
+
const runs = [...(detail.gate?.runs ?? []), ...detail.joint.flatMap((j) => j.gate?.runs ?? [])];
|
|
132
|
+
if (runs.length === 0) return null;
|
|
133
|
+
const last = runs.at(-1)!;
|
|
134
|
+
const failed = runs.filter((r) => !r.passed).length;
|
|
135
|
+
return (
|
|
136
|
+
<View style={s.card}>
|
|
137
|
+
<Text style={s.heading}>质量门</Text>
|
|
138
|
+
<Text style={s.text}>
|
|
139
|
+
运行 {runs.length} 次{failed > 0 ? `,其中 ${failed} 次发现改动带来的新失败` : ",都没有新失败"}
|
|
140
|
+
</Text>
|
|
141
|
+
<Text style={s.muted}>
|
|
142
|
+
最近一次({last.key}):{last.passed ? "通过" : `新失败:${last.newFailures.join("、")}`}
|
|
143
|
+
</Text>
|
|
144
|
+
</View>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function RequirementView({
|
|
149
|
+
theme,
|
|
150
|
+
layout,
|
|
151
|
+
navigation,
|
|
152
|
+
repo,
|
|
153
|
+
featureDir,
|
|
154
|
+
}: {
|
|
155
|
+
theme: Theme;
|
|
156
|
+
layout: Layout;
|
|
157
|
+
navigation: Navigation;
|
|
158
|
+
repo: string;
|
|
159
|
+
featureDir: string;
|
|
160
|
+
}) {
|
|
161
|
+
const s = useStyles(theme, layout.compact);
|
|
162
|
+
const query = useRequirement(repo, featureDir);
|
|
163
|
+
const { readOnly } = usePreferences();
|
|
164
|
+
const [doc, setDoc] = useState<string | null>(null);
|
|
165
|
+
const [action, setAction] = useState<Action | null>(null);
|
|
166
|
+
const [allSteps, setAllSteps] = useState(false);
|
|
167
|
+
const d = query.data;
|
|
168
|
+
if (!d) return <Status theme={theme} loading={query.isPending} error={query.error} />;
|
|
169
|
+
const steps = allSteps ? d.steps : d.steps.slice(-12);
|
|
170
|
+
const actions = readOnly ? [] : actionsFor(d);
|
|
171
|
+
// 1.14: finished (it has a report) and not running: the requester can try it and accept it.
|
|
172
|
+
const canAccept = d.files.includes("report.md") && !d.running;
|
|
173
|
+
// 1.14: code written and reviewed by the AI: a person can review it too.
|
|
174
|
+
const canReviewCode = (d.files.includes("code-review.md") || d.files.includes("implementation.md")) && !d.running;
|
|
175
|
+
const hr = d.humanReview ?? null;
|
|
176
|
+
const reviewLabel = !hr ? "代码审查" : hr.status === "approved" ? (hr.stale ? "代码审查(有新改动,需重新评审)" : "代码审查(已通过)") : "代码审查(已退回修改)";
|
|
177
|
+
// 1.15: one lime button, the decision this requirement waits for now.
|
|
178
|
+
const waitingAcceptance = d.stage.startsWith("待验收") || d.stage === "验收未通过";
|
|
179
|
+
const codeNeedsReview = canReviewCode && (!hr || hr.stale) && (d.status === "completed" || d.status === "phase_done");
|
|
180
|
+
const primary: "review" | "code" | "check" | Action | null =
|
|
181
|
+
d.attention === "approval" && d.hasPrototype
|
|
182
|
+
? "review"
|
|
183
|
+
: codeNeedsReview
|
|
184
|
+
? "code"
|
|
185
|
+
: canAccept && waitingAcceptance
|
|
186
|
+
? "check"
|
|
187
|
+
: (actions.find((a) => a !== "stop" && !(a === "approve" && d.hasPrototype)) ?? null);
|
|
188
|
+
const c = rk(theme);
|
|
189
|
+
return (
|
|
190
|
+
<View style={{ gap: 16 }}>
|
|
191
|
+
<View style={[s.card, { gap: 12 }]}>
|
|
192
|
+
<Eyebrow theme={theme} accent right={<Text style={s.mono} numberOfLines={1}>{d.branch ?? d.name}</Text>}>
|
|
193
|
+
REQUIREMENT
|
|
194
|
+
</Eyebrow>
|
|
195
|
+
<View style={s.row}>
|
|
196
|
+
<Text style={s.title}>{d.title}</Text>
|
|
197
|
+
{d.attention ? (
|
|
198
|
+
<Badge theme={theme} tone={d.attention === "interrupted" ? "danger" : d.attention === "not_completed" ? "warning" : "needs"}>
|
|
199
|
+
{ATTENTION_LABELS[d.attention]}
|
|
200
|
+
</Badge>
|
|
201
|
+
) : d.running ? (
|
|
202
|
+
<Badge theme={theme} tone="running" icon="LoaderCircle">
|
|
203
|
+
进行中
|
|
204
|
+
</Badge>
|
|
205
|
+
) : null}
|
|
206
|
+
</View>
|
|
207
|
+
<StepTrack theme={theme} steps={trackOf(d, hr)} />
|
|
208
|
+
<Text style={s.muted}>{facts(d)}</Text>
|
|
209
|
+
<Text style={[s.text, { color: d.attention ? c.brandText : theme.colors.foreground }]}>{d.stage}</Text>
|
|
210
|
+
{d.estimate && d.attention !== "approval" ? (
|
|
211
|
+
<Text style={s.muted}>
|
|
212
|
+
{d.estimate.over
|
|
213
|
+
? `已超过同档位需求通常的用时(已用 ${minutes(d.estimate.usedAgentMinutes)},通常 ${minutes(d.estimate.typicalAgentMinutes)})`
|
|
214
|
+
: `预计还要约 ${minutes(Math.max(5, d.estimate.leftMinutes))}`}
|
|
215
|
+
{d.estimate.usedTokens !== null ? ` · 已用 ${tokens(d.estimate.usedTokens)} tokens${d.estimate.typicalTokens !== null ? `(通常 ${tokens(d.estimate.typicalTokens)})` : ""}` : ""}
|
|
216
|
+
{` · 按本机最近 ${d.estimate.basis} 个同档位需求,不含等人的时间`}
|
|
217
|
+
</Text>
|
|
218
|
+
) : null}
|
|
219
|
+
{d.run?.stopReason && !d.running ? <Text style={s.danger}>{d.run.stopReason}</Text> : null}
|
|
220
|
+
{d.attention === "business" ? <Text style={s.muted}>需求方的决定请在发起需求的对话中回答,回答后再继续。</Text> : null}
|
|
221
|
+
</View>
|
|
222
|
+
|
|
223
|
+
{actions.length > 0 || d.hasPrototype || canAccept || canReviewCode ? (
|
|
224
|
+
<View style={s.row}>
|
|
225
|
+
{canReviewCode ? <CodeReviewButton theme={theme} repo={d.sourceRepo ?? d.repo} featureDir={d.featureDir} title={d.title} label={reviewLabel} primary={primary === "code"} /> : null}
|
|
226
|
+
{canAccept ? <ChecklistButton theme={theme} repo={d.sourceRepo ?? d.repo} featureDir={d.featureDir} title={d.title} primary={primary === "check"} /> : null}
|
|
227
|
+
{d.hasPrototype ? <ReviewButton theme={theme} repo={d.sourceRepo ?? d.repo} featureDir={d.featureDir} title={d.title} waiting={primary === "review"} /> : null}
|
|
228
|
+
{actions.map((a) => (
|
|
229
|
+
<Button key={a} theme={theme} primary={primary === a} label={ACTION_TEXT[a].label} onPress={() => setAction(a)} />
|
|
230
|
+
))}
|
|
231
|
+
</View>
|
|
232
|
+
) : null}
|
|
233
|
+
|
|
234
|
+
{d.files.length > 0 ? (
|
|
235
|
+
<View style={{ gap: 6 }}>
|
|
236
|
+
<Text style={s.heading}>文档</Text>
|
|
237
|
+
<View style={s.row}>
|
|
238
|
+
{d.files.map((f) => (
|
|
239
|
+
<Chip key={f} theme={theme} label={FILE_LABELS[f] ?? f} active={false} onPress={() => setDoc(f)} />
|
|
240
|
+
))}
|
|
241
|
+
</View>
|
|
242
|
+
</View>
|
|
243
|
+
) : null}
|
|
244
|
+
|
|
245
|
+
<View style={s.card}>
|
|
246
|
+
<Text style={s.heading}>位置</Text>
|
|
247
|
+
<Text selectable style={s.text}>
|
|
248
|
+
{d.repo}/{d.featureDir}
|
|
249
|
+
</Text>
|
|
250
|
+
{d.branch ? <Text style={s.muted}>分支 {d.branch}</Text> : null}
|
|
251
|
+
{d.workspaceId && navigation ? (
|
|
252
|
+
<Pressable accessibilityRole="button" onPress={() => navigation.openWorkspace({ workspaceId: d.workspaceId! })}>
|
|
253
|
+
<Text style={{ color: rk(theme).brandText, fontSize: 13, fontWeight: "600" }}>打开这个需求的工作区</Text>
|
|
254
|
+
</Pressable>
|
|
255
|
+
) : null}
|
|
256
|
+
{d.joint.map((j) => (
|
|
257
|
+
<Text key={j.name} style={s.muted}>
|
|
258
|
+
联合开发「{j.name}」:{j.repo}(分支 {j.branch})
|
|
259
|
+
</Text>
|
|
260
|
+
))}
|
|
261
|
+
</View>
|
|
262
|
+
|
|
263
|
+
{(d.external ?? []).length > 0 ? (
|
|
264
|
+
<View style={s.card}>
|
|
265
|
+
<Text style={s.heading}>外部系统</Text>
|
|
266
|
+
{(d.external ?? []).map((e) => (
|
|
267
|
+
<View key={e.name} style={{ gap: 2 }}>
|
|
268
|
+
<View style={s.row}>
|
|
269
|
+
<Text style={s.text}>
|
|
270
|
+
{e.name}:{e.id ?? "还没有建卡"}
|
|
271
|
+
</Text>
|
|
272
|
+
{e.status ? (
|
|
273
|
+
<Badge theme={theme} tone="muted">
|
|
274
|
+
{e.status}
|
|
275
|
+
</Badge>
|
|
276
|
+
) : null}
|
|
277
|
+
</View>
|
|
278
|
+
{e.url ? <ExternalLink href={e.url}>打开卡片</ExternalLink> : null}
|
|
279
|
+
{e.pending > 0 ? (
|
|
280
|
+
<Text style={s.danger}>
|
|
281
|
+
有 {e.pending} 次调用没有成功:{e.lastError}
|
|
282
|
+
</Text>
|
|
283
|
+
) : null}
|
|
284
|
+
</View>
|
|
285
|
+
))}
|
|
286
|
+
</View>
|
|
287
|
+
) : null}
|
|
288
|
+
|
|
289
|
+
{d.usage ? (
|
|
290
|
+
<View style={s.card}>
|
|
291
|
+
<Text style={s.heading}>用时与用量</Text>
|
|
292
|
+
<Text style={s.text}>
|
|
293
|
+
{d.usage.steps} 个步骤,agent 合计 {minutes(d.usage.agentMinutes)}
|
|
294
|
+
</Text>
|
|
295
|
+
<Text style={s.muted}>
|
|
296
|
+
输入 {tokens(d.usage.inputTokens)} tokens,输出 {tokens(d.usage.outputTokens)} tokens
|
|
297
|
+
{d.usage.costUsd !== null ? `,约 $${d.usage.costUsd.toFixed(2)}` : ""}
|
|
298
|
+
</Text>
|
|
299
|
+
</View>
|
|
300
|
+
) : null}
|
|
301
|
+
|
|
302
|
+
<GateSummary theme={theme} layout={layout} detail={d} />
|
|
303
|
+
|
|
304
|
+
{d.steps.length > 0 ? (
|
|
305
|
+
<View style={s.card}>
|
|
306
|
+
<View style={s.row}>
|
|
307
|
+
<Text style={s.heading}>步骤({d.steps.length})</Text>
|
|
308
|
+
{d.steps.length > 12 ? <Button theme={theme} label={allSteps ? "只看最近的" : "显示全部"} onPress={() => setAllSteps((v) => !v)} /> : null}
|
|
309
|
+
</View>
|
|
310
|
+
{steps.map((step) => (
|
|
311
|
+
<StepRow key={`${step.key}-${step.attempt}-${step.startedAt}`} theme={theme} layout={layout} step={step} navigation={navigation} />
|
|
312
|
+
))}
|
|
313
|
+
</View>
|
|
314
|
+
) : null}
|
|
315
|
+
|
|
316
|
+
<DocumentModal theme={theme} layout={layout} repo={d.repo} featureDir={d.featureDir} file={doc} onClose={() => setDoc(null)} />
|
|
317
|
+
<ActionModal theme={theme} layout={layout} detail={d} action={action} onClose={() => setAction(null)} />
|
|
318
|
+
</View>
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export function RequirementScreen({ theme, layout, navigation, params }: PluginScreenProps) {
|
|
323
|
+
const s = useStyles(theme, layout.compact);
|
|
324
|
+
// Opened from a step agent's pill: only the requirement's name is known; find it in the list.
|
|
325
|
+
const list = useRequirements();
|
|
326
|
+
const byName = !params.repo && params.name ? (list.data ?? []).find((r) => r.name === params.name) : null;
|
|
327
|
+
const repo = params.repo ?? byName?.repo;
|
|
328
|
+
const featureDir = params.featureDir ?? byName?.featureDir;
|
|
329
|
+
return (
|
|
330
|
+
<View style={s.screen}>
|
|
331
|
+
<ScrollView contentContainerStyle={s.body}>
|
|
332
|
+
{repo && featureDir ? (
|
|
333
|
+
<RequirementView theme={theme} layout={layout} navigation={navigation} repo={repo} featureDir={featureDir} />
|
|
334
|
+
) : params.name ? (
|
|
335
|
+
<Status theme={theme} loading={list.isPending} error={list.error} empty={list.data ? `本机记录中没有需求 ${params.name}。` : null} />
|
|
336
|
+
) : (
|
|
337
|
+
<Text style={s.muted}>没有指定需求。</Text>
|
|
338
|
+
)}
|
|
339
|
+
</ScrollView>
|
|
340
|
+
</View>
|
|
341
|
+
);
|
|
342
|
+
}
|