@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,138 @@
|
|
|
1
|
+
// Usage statistics (laoshi stats): for whoever reports on how requirements went.
|
|
2
|
+
import type { PluginScreenProps } 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 { useStats } from "./data";
|
|
7
|
+
import { minutes, tokens, TYPE_LABELS } from "./format";
|
|
8
|
+
import { BrandHeader, Chip, Eyebrow, rk, Status, useStyles } from "./ui";
|
|
9
|
+
|
|
10
|
+
type Tokens = NonNullable<import("../shared/contracts").StatsSummary["tokens"]>;
|
|
11
|
+
|
|
12
|
+
const pct = (x: number) => `${Math.round(x * 100)}%`;
|
|
13
|
+
|
|
14
|
+
/** Where the tokens went (1.13): a bar per step and per model, and the share spent on rework. */
|
|
15
|
+
function TokenShare({ theme, compact, t }: { theme: import("@getpaseo/plugin/client").PluginHostProps["theme"]; compact: boolean; t: Tokens }) {
|
|
16
|
+
const s = useStyles(theme, compact);
|
|
17
|
+
const bar = (key: string, label: string, value: number, share: number, note: string) => (
|
|
18
|
+
<View key={key} style={{ gap: 2 }}>
|
|
19
|
+
<View style={[s.row, { justifyContent: "space-between", flexWrap: "nowrap" }]}>
|
|
20
|
+
<Text style={[s.text, { flexShrink: 1 }]}>{label}</Text>
|
|
21
|
+
<Text style={s.muted}>
|
|
22
|
+
{tokens(value)} · {pct(share)}
|
|
23
|
+
{note}
|
|
24
|
+
</Text>
|
|
25
|
+
</View>
|
|
26
|
+
<View style={{ height: 6, borderRadius: 3, backgroundColor: theme.colors.surface2, overflow: "hidden" }}>
|
|
27
|
+
<View style={{ width: `${Math.max(1, Math.round(share * 100))}%`, height: 6, backgroundColor: rk(theme).data }} />
|
|
28
|
+
</View>
|
|
29
|
+
</View>
|
|
30
|
+
);
|
|
31
|
+
return (
|
|
32
|
+
<View style={[s.card, { gap: 10 }]}>
|
|
33
|
+
<Eyebrow theme={theme} right={<Text style={s.muted}>token 花在哪</Text>}>TOKENS</Eyebrow>
|
|
34
|
+
<Text style={s.text}>
|
|
35
|
+
合计 {tokens(t.total)} tokens
|
|
36
|
+
{t.rework ? `,其中返工(修订、修复、复验和第 2 轮起的评审)占 ${pct(t.rework.share)}` : ""}
|
|
37
|
+
{t.cachedShare !== null ? `;输入中 ${pct(t.cachedShare)} 来自提示缓存` : ""}
|
|
38
|
+
</Text>
|
|
39
|
+
{t.perRequirement.median !== null ? <Text style={s.muted}>每个完成的需求中位数 {tokens(t.perRequirement.median)}</Text> : null}
|
|
40
|
+
<View style={{ gap: 8 }}>{t.byStep.slice(0, 12).map((r) => bar(r.stepId, r.title, r.tokens, r.share, `(${r.steps} 次)`))}</View>
|
|
41
|
+
{t.byAgent.some((a) => a.agent !== "(未记录)") ? (
|
|
42
|
+
<>
|
|
43
|
+
<Text style={[s.text, { fontWeight: "600" }]}>按模型</Text>
|
|
44
|
+
<View style={{ gap: 8 }}>{t.byAgent.map((r) => bar(r.agent, r.agent, r.tokens, r.share, `(${r.steps} 步)`))}</View>
|
|
45
|
+
</>
|
|
46
|
+
) : null}
|
|
47
|
+
</View>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function month(offset: number, now = new Date()): string {
|
|
52
|
+
const d = new Date(now.getFullYear(), now.getMonth() + offset, 1);
|
|
53
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const OUTCOME: Record<string, string> = { completed: "已完成", completed_with_issues: "有遗留问题", not_completed: "未完成", unknown: "结论未记录" };
|
|
57
|
+
|
|
58
|
+
export function StatsScreen({ theme, layout }: PluginScreenProps) {
|
|
59
|
+
const s = useStyles(theme, layout.compact);
|
|
60
|
+
const periods = [
|
|
61
|
+
{ label: "最近 30 天", value: { since: "30d" } },
|
|
62
|
+
{ label: "本月", value: { month: month(0) } },
|
|
63
|
+
{ label: "上月", value: { month: month(-1) } },
|
|
64
|
+
];
|
|
65
|
+
const [pick, setPick] = useState(0);
|
|
66
|
+
const query = useStats(periods[pick].value);
|
|
67
|
+
const d = query.data;
|
|
68
|
+
const card = (label: string, value: string, note?: string) => (
|
|
69
|
+
<View key={label} style={[s.card, { minWidth: layout.compact ? "45%" : 160, flexGrow: 1 }]}>
|
|
70
|
+
<Text style={s.muted}>{label}</Text>
|
|
71
|
+
<Text style={[s.text, { fontSize: 22, fontWeight: "600" }]}>{value}</Text>
|
|
72
|
+
{note ? <Text style={s.muted}>{note}</Text> : null}
|
|
73
|
+
</View>
|
|
74
|
+
);
|
|
75
|
+
return (
|
|
76
|
+
<View style={s.screen}>
|
|
77
|
+
<ScrollView contentContainerStyle={s.body}>
|
|
78
|
+
<BrandHeader theme={theme} page="使用统计" />
|
|
79
|
+
<View style={s.row}>
|
|
80
|
+
{periods.map((p, i) => (
|
|
81
|
+
<Chip key={p.label} theme={theme} label={p.label} active={i === pick} onPress={() => setPick(i)} />
|
|
82
|
+
))}
|
|
83
|
+
</View>
|
|
84
|
+
<Status theme={theme} loading={query.isPending} error={query.error} empty={d && d.active === 0 ? "这段时间没有流水线运行记录。" : null} />
|
|
85
|
+
{d && d.active > 0 ? (
|
|
86
|
+
<>
|
|
87
|
+
<View style={[s.row, { alignItems: "stretch" }]}>
|
|
88
|
+
{card("有进展的需求", String(d.active), Object.entries(d.byType).map(([k, v]) => `${TYPE_LABELS[k] ?? "普通"} ${v}`).join(","))}
|
|
89
|
+
{card("完成", String(d.completed.total), Object.entries(d.completed.byOutcome).map(([k, v]) => `${OUTCOME[k] ?? k} ${v}`).join(","))}
|
|
90
|
+
{card("交付周期中位数", d.cycleHours.median === null ? "-" : `${d.cycleHours.median} 小时`, "首次开始到完成")}
|
|
91
|
+
{card("平均评审轮数", d.rework.averageReviewRounds === null ? "-" : String(d.rework.averageReviewRounds), d.rework.withDefectRounds === null ? undefined : `${Math.round(d.rework.withDefectRounds * 100)}% 需要缺陷修复`)}
|
|
92
|
+
{card("agent 合计用时", minutes(d.usage.agentMinutes), `输入 ${tokens(d.usage.inputTokens)},输出 ${tokens(d.usage.outputTokens)} tokens`)}
|
|
93
|
+
{d.usage.costUsd !== null ? card("费用", `$${d.usage.costUsd.toFixed(2)}`) : null}
|
|
94
|
+
</View>
|
|
95
|
+
{d.oversight && d.oversight.reviews.total + d.oversight.acceptance.total + d.oversight.merged.requirements + d.oversight.issues.total > 0 ? (
|
|
96
|
+
<View style={s.card}>
|
|
97
|
+
<Eyebrow theme={theme} right={<Text style={s.muted}>人工把关和合并后</Text>}>OVERSIGHT</Eyebrow>
|
|
98
|
+
<Text style={s.text}>
|
|
99
|
+
人工代码评审 {d.oversight.reviews.total} 次({d.oversight.reviews.requirements} 个需求),退回修改 {d.oversight.reviews.sentBack} 次;第一次就通过 {d.oversight.reviews.passedFirstTime} 个
|
|
100
|
+
</Text>
|
|
101
|
+
<Text style={s.text}>
|
|
102
|
+
需求方验收 {d.oversight.acceptance.total} 次,不通过 {d.oversight.acceptance.failed} 次;第一次就通过 {d.oversight.acceptance.passedFirstTime} 个
|
|
103
|
+
</Text>
|
|
104
|
+
<Text style={s.text}>
|
|
105
|
+
合并进主干 {d.oversight.merged.requirements} 个需求
|
|
106
|
+
{d.oversight.merged.medianHoursAfterCompletion === null ? "" : `,完成到合并中位数 ${d.oversight.merged.medianHoursAfterCompletion} 小时`};合并后发现问题 {d.oversight.issues.total} 个
|
|
107
|
+
</Text>
|
|
108
|
+
</View>
|
|
109
|
+
) : null}
|
|
110
|
+
{d.tokens?.total ? <TokenShare theme={theme} compact={layout.compact} t={d.tokens} /> : null}
|
|
111
|
+
{d.waits.length > 0 ? (
|
|
112
|
+
<View style={s.card}>
|
|
113
|
+
<Text style={s.heading}>等待</Text>
|
|
114
|
+
{d.waits.map((w) => (
|
|
115
|
+
<Text key={w.kind} style={s.text}>
|
|
116
|
+
{w.label}:{w.requirements} 个需求,平均 {minutes(w.averageMinutes)}
|
|
117
|
+
</Text>
|
|
118
|
+
))}
|
|
119
|
+
</View>
|
|
120
|
+
) : null}
|
|
121
|
+
<View style={s.card}>
|
|
122
|
+
<Text style={s.heading}>各步骤用时</Text>
|
|
123
|
+
{d.steps.map((st) => (
|
|
124
|
+
<Text key={st.stepId} style={s.text}>
|
|
125
|
+
{st.title}:{st.count} 次,平均 {minutes(st.averageMinutes)},合计 {minutes(st.totalMinutes)}
|
|
126
|
+
</Text>
|
|
127
|
+
))}
|
|
128
|
+
<Text style={s.muted}>
|
|
129
|
+
质量门运行 {d.rework.gateRuns} 次,发现新失败 {d.rework.gateFailed} 次。机器:{d.machines.join("、")}
|
|
130
|
+
</Text>
|
|
131
|
+
</View>
|
|
132
|
+
<Text style={s.muted}>给管理方的汇报文件:在终端运行 laoshi stats --report --month {month(0)};几台机器一起汇报见 laoshi stats --export 和 --merge。</Text>
|
|
133
|
+
</>
|
|
134
|
+
) : null}
|
|
135
|
+
</ScrollView>
|
|
136
|
+
</View>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
// Small building blocks. Surfaces, text, borders and status colors come from Paseo's theme
|
|
2
|
+
// (theme.colors), so the plugin sits well in Paseo's light, dark and phone layouts; laoshi's own
|
|
3
|
+
// accents (lime for "you decide", indigo for AI, cyan for running) come from design/ through
|
|
4
|
+
// shared/rk-colors.ts. See design/guidelines/plugin.md.
|
|
5
|
+
import type { PluginHostProps } from "@getpaseo/plugin/client";
|
|
6
|
+
import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
7
|
+
import { type ReactNode, useMemo } from "react";
|
|
8
|
+
import { Pressable, Text, View } from "react-native";
|
|
9
|
+
import { RK_COLORS, type RkColors } from "../shared/rk-colors";
|
|
10
|
+
|
|
11
|
+
type Theme = PluginHostProps["theme"];
|
|
12
|
+
|
|
13
|
+
const MONO = "ui-monospace, Menlo, Consolas, monospace";
|
|
14
|
+
|
|
15
|
+
/** Whether Paseo is in a dark theme: from the brightness of its page background. */
|
|
16
|
+
export function isDark(theme: Theme): boolean {
|
|
17
|
+
const m = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(theme.colors.surface0.trim());
|
|
18
|
+
if (!m) return true;
|
|
19
|
+
const [r, g, b] = [m[1], m[2], m[3]].map((h) => parseInt(h, 16) / 255);
|
|
20
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b < 0.45;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** laoshi's accent colors for the current Paseo theme. */
|
|
24
|
+
export function rk(theme: Theme): RkColors {
|
|
25
|
+
return isDark(theme) ? RK_COLORS.dark : (RK_COLORS.light as unknown as RkColors);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function useStyles(theme: Theme, compact: boolean) {
|
|
29
|
+
return useMemo(
|
|
30
|
+
() => ({
|
|
31
|
+
screen: { flex: 1, backgroundColor: theme.colors.surface0 },
|
|
32
|
+
body: { padding: compact ? 16 : 24, gap: compact ? 16 : 20 },
|
|
33
|
+
title: { color: theme.colors.foreground, fontSize: compact ? 18 : 20, fontWeight: "600" as const },
|
|
34
|
+
heading: { color: theme.colors.foregroundMuted, fontSize: 13, fontWeight: "600" as const, marginBottom: 6 },
|
|
35
|
+
text: { color: theme.colors.foreground, fontSize: 14, lineHeight: 22 },
|
|
36
|
+
muted: { color: theme.colors.foregroundMuted, fontSize: 13, lineHeight: 20 },
|
|
37
|
+
mono: { color: theme.colors.foregroundMuted, fontSize: 12, fontFamily: MONO },
|
|
38
|
+
danger: { color: theme.colors.statusDanger, fontSize: 13 },
|
|
39
|
+
eyebrow: { color: theme.colors.foregroundMuted, fontSize: 12, fontFamily: MONO, letterSpacing: 1.9, fontWeight: "500" as const },
|
|
40
|
+
card: {
|
|
41
|
+
backgroundColor: theme.colors.surface1,
|
|
42
|
+
borderColor: theme.colors.border,
|
|
43
|
+
borderWidth: 1,
|
|
44
|
+
borderRadius: 14,
|
|
45
|
+
padding: compact ? 12 : 16,
|
|
46
|
+
gap: 6,
|
|
47
|
+
},
|
|
48
|
+
row: { flexDirection: "row" as const, alignItems: "center" as const, gap: 8, flexWrap: "wrap" as const },
|
|
49
|
+
divider: { height: 1, backgroundColor: theme.colors.border },
|
|
50
|
+
}),
|
|
51
|
+
[theme, compact],
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type Tone = "warning" | "danger" | "success" | "accent" | "running" | "needs" | "ai" | "muted";
|
|
56
|
+
|
|
57
|
+
/** A status badge: color + (optional) Lucide icon + words. "accent" is an older name for "running". */
|
|
58
|
+
export function Badge({ theme, tone, icon, children }: { theme: Theme; tone: Tone; icon?: string; children: ReactNode }) {
|
|
59
|
+
const c = rk(theme);
|
|
60
|
+
const [fg, bg] =
|
|
61
|
+
tone === "warning"
|
|
62
|
+
? [theme.colors.statusWarning, c.warningTint]
|
|
63
|
+
: tone === "danger"
|
|
64
|
+
? [theme.colors.statusDanger, c.failedTint]
|
|
65
|
+
: tone === "success"
|
|
66
|
+
? [theme.colors.statusSuccess, c.successTint]
|
|
67
|
+
: tone === "running" || tone === "accent"
|
|
68
|
+
? [c.data, c.dataTint]
|
|
69
|
+
: tone === "needs"
|
|
70
|
+
? [c.brandText, c.brandTint]
|
|
71
|
+
: tone === "ai"
|
|
72
|
+
? [c.ai, c.aiTint]
|
|
73
|
+
: [theme.colors.foregroundMuted, theme.colors.surface2];
|
|
74
|
+
return (
|
|
75
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 4, borderRadius: 6, paddingHorizontal: 8, paddingVertical: 2, backgroundColor: bg }}>
|
|
76
|
+
{icon ? <Icon name={icon} size={13} color={fg} /> : null}
|
|
77
|
+
<Text style={{ color: fg, fontSize: 12, fontWeight: "600" }}>{children}</Text>
|
|
78
|
+
</View>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A button. `primary` is laoshi's lime: the one decision this view is asking for (one per card or
|
|
84
|
+
* screen). Others take Paseo's surfaces.
|
|
85
|
+
*/
|
|
86
|
+
export function Button({
|
|
87
|
+
theme,
|
|
88
|
+
label,
|
|
89
|
+
onPress,
|
|
90
|
+
primary,
|
|
91
|
+
disabled,
|
|
92
|
+
icon,
|
|
93
|
+
}: {
|
|
94
|
+
theme: Theme;
|
|
95
|
+
label: string;
|
|
96
|
+
onPress(): void;
|
|
97
|
+
primary?: boolean;
|
|
98
|
+
disabled?: boolean;
|
|
99
|
+
icon?: string;
|
|
100
|
+
}) {
|
|
101
|
+
const c = rk(theme);
|
|
102
|
+
const fg = primary ? c.onBrand : theme.colors.foreground;
|
|
103
|
+
return (
|
|
104
|
+
<Pressable
|
|
105
|
+
accessibilityRole="button"
|
|
106
|
+
accessibilityLabel={label}
|
|
107
|
+
accessibilityState={{ disabled: !!disabled }}
|
|
108
|
+
disabled={disabled}
|
|
109
|
+
onPress={onPress}
|
|
110
|
+
style={({ pressed }: { pressed: boolean }) => ({
|
|
111
|
+
flexDirection: "row",
|
|
112
|
+
alignItems: "center",
|
|
113
|
+
gap: 6,
|
|
114
|
+
paddingHorizontal: 14,
|
|
115
|
+
paddingVertical: 8,
|
|
116
|
+
borderRadius: 10,
|
|
117
|
+
opacity: disabled ? 0.5 : 1,
|
|
118
|
+
backgroundColor: primary ? (pressed ? c.brand400 : c.brand500) : pressed ? theme.colors.surface1 : theme.colors.surface2,
|
|
119
|
+
borderColor: primary ? c.brandEdge : theme.colors.border,
|
|
120
|
+
borderWidth: 1,
|
|
121
|
+
})}
|
|
122
|
+
>
|
|
123
|
+
{icon ? <Icon name={icon} size={16} color={fg} /> : null}
|
|
124
|
+
<Text style={{ color: fg, fontSize: 14, fontWeight: "600" }}>{label}</Text>
|
|
125
|
+
</Pressable>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** A filter chip; the selected one carries laoshi's lime. */
|
|
130
|
+
export function Chip({ theme, label, active, onPress }: { theme: Theme; label: string; active: boolean; onPress(): void }) {
|
|
131
|
+
const c = rk(theme);
|
|
132
|
+
return (
|
|
133
|
+
<Pressable
|
|
134
|
+
accessibilityRole="button"
|
|
135
|
+
accessibilityState={{ selected: active }}
|
|
136
|
+
onPress={onPress}
|
|
137
|
+
style={{
|
|
138
|
+
paddingHorizontal: 12,
|
|
139
|
+
paddingVertical: 5,
|
|
140
|
+
borderRadius: 999,
|
|
141
|
+
backgroundColor: active ? c.brandTint : theme.colors.surface1,
|
|
142
|
+
borderColor: active ? c.brandEdge : theme.colors.border,
|
|
143
|
+
borderWidth: 1,
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
<Text style={{ color: active ? c.brandText : theme.colors.foreground, fontSize: 13, fontWeight: active ? "600" : "400" }}>{label}</Text>
|
|
147
|
+
</Pressable>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** An uppercase mono label above a group, e.g. NEEDS YOU · 2. */
|
|
152
|
+
export function Eyebrow({ theme, children, accent, right }: { theme: Theme; children: ReactNode; accent?: boolean; right?: ReactNode }) {
|
|
153
|
+
const c = rk(theme);
|
|
154
|
+
return (
|
|
155
|
+
<View style={{ flexDirection: "row", alignItems: "center", justifyContent: "space-between", gap: 8 }}>
|
|
156
|
+
<Text style={{ color: accent ? c.brandText : theme.colors.foregroundMuted, fontSize: 12, fontFamily: MONO, letterSpacing: 1.9, fontWeight: "500" }}>{children}</Text>
|
|
157
|
+
{right ?? null}
|
|
158
|
+
</View>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** The laoshi mark (a check-shaped pipeline ending in a lit node), drawn with views. */
|
|
163
|
+
export function Mark({ theme, size = 20 }: { theme: Theme; size?: number }) {
|
|
164
|
+
const c = rk(theme);
|
|
165
|
+
const k = size / 100;
|
|
166
|
+
const bar = (x1: number, y1: number, x2: number, y2: number) => {
|
|
167
|
+
const len = Math.hypot(x2 - x1, y2 - y1);
|
|
168
|
+
const angle = (Math.atan2(y2 - y1, x2 - x1) * 180) / Math.PI;
|
|
169
|
+
return (
|
|
170
|
+
<View
|
|
171
|
+
style={{
|
|
172
|
+
position: "absolute",
|
|
173
|
+
left: ((x1 + x2) / 2 - len / 2) * k,
|
|
174
|
+
top: ((y1 + y2) / 2) * k - 5 * k,
|
|
175
|
+
width: len * k,
|
|
176
|
+
height: 10 * k,
|
|
177
|
+
borderRadius: 5 * k,
|
|
178
|
+
backgroundColor: c.brandEdge,
|
|
179
|
+
transform: [{ rotate: `${angle}deg` }],
|
|
180
|
+
}}
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
const node = (x: number, y: number, r: number, filled: boolean) => (
|
|
185
|
+
<View
|
|
186
|
+
style={{
|
|
187
|
+
position: "absolute",
|
|
188
|
+
left: (x - r) * k,
|
|
189
|
+
top: (y - r) * k,
|
|
190
|
+
width: 2 * r * k,
|
|
191
|
+
height: 2 * r * k,
|
|
192
|
+
borderRadius: r * k,
|
|
193
|
+
backgroundColor: filled ? c.brandEdge : theme.colors.surface0,
|
|
194
|
+
borderColor: c.brandEdge,
|
|
195
|
+
borderWidth: filled ? 0 : Math.max(1, 6 * k),
|
|
196
|
+
}}
|
|
197
|
+
/>
|
|
198
|
+
);
|
|
199
|
+
return (
|
|
200
|
+
<View style={{ width: size, height: size }}>
|
|
201
|
+
{bar(16, 54, 40, 77)}
|
|
202
|
+
{bar(40, 77, 82, 30)}
|
|
203
|
+
{node(16, 54, 9, false)}
|
|
204
|
+
{node(40, 77, 9, false)}
|
|
205
|
+
{node(82, 30, 13, true)}
|
|
206
|
+
</View>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** The mark and the wordmark "laoshi" ("shi" lime), and an optional page name. */
|
|
211
|
+
export function BrandHeader({ theme, page, right }: { theme: Theme; page?: string; right?: ReactNode }) {
|
|
212
|
+
const c = rk(theme);
|
|
213
|
+
return (
|
|
214
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 10, flexWrap: "wrap" }}>
|
|
215
|
+
<Mark theme={theme} size={20} />
|
|
216
|
+
<Text style={{ color: theme.colors.foreground, fontSize: 16, fontWeight: "800", letterSpacing: -0.3 }}>
|
|
217
|
+
lao<Text style={{ color: c.brandEdge }}>shi</Text>
|
|
218
|
+
</Text>
|
|
219
|
+
{page ? <Text style={{ color: theme.colors.foregroundMuted, fontSize: 15, fontWeight: "600" }}>{page}</Text> : null}
|
|
220
|
+
<View style={{ flex: 1 }} />
|
|
221
|
+
{right ?? null}
|
|
222
|
+
</View>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export type TrackState = "done" | "now" | "needs" | "todo";
|
|
227
|
+
|
|
228
|
+
/** The step track: where a requirement is (design/components/StepTrack.md). */
|
|
229
|
+
export function StepTrack({ theme, steps }: { theme: Theme; steps: Array<{ label: string; who: string; state: TrackState }> }) {
|
|
230
|
+
const c = rk(theme);
|
|
231
|
+
return (
|
|
232
|
+
<View style={{ flexDirection: "row", alignItems: "flex-start" }} accessibilityLabel={`进度:${steps.map((s) => `${s.label}${s.state === "done" ? "已完成" : s.state === "now" ? "进行中" : s.state === "needs" ? "等你" : ""}`).join(",")}`}>
|
|
233
|
+
{steps.map((st, i) => {
|
|
234
|
+
const reached = st.state !== "todo";
|
|
235
|
+
const dot =
|
|
236
|
+
st.state === "done"
|
|
237
|
+
? { bg: c.successTint, border: theme.colors.statusSuccess, fg: theme.colors.statusSuccess }
|
|
238
|
+
: st.state === "now"
|
|
239
|
+
? { bg: c.dataTint, border: c.data, fg: c.data }
|
|
240
|
+
: st.state === "needs"
|
|
241
|
+
? { bg: c.brand500, border: c.brandEdge, fg: c.onBrand }
|
|
242
|
+
: { bg: theme.colors.surface1, border: theme.colors.border, fg: theme.colors.foregroundMuted };
|
|
243
|
+
return (
|
|
244
|
+
<View key={st.label} style={{ flex: 1, alignItems: "center", gap: 4, minWidth: 48 }}>
|
|
245
|
+
<View style={{ flexDirection: "row", alignItems: "center", alignSelf: "stretch" }}>
|
|
246
|
+
<View style={{ flex: 1, height: 2, backgroundColor: i === 0 ? "transparent" : reached ? theme.colors.statusSuccess : theme.colors.border }} />
|
|
247
|
+
<View style={{ width: 24, height: 24, borderRadius: 12, alignItems: "center", justifyContent: "center", backgroundColor: dot.bg, borderColor: dot.border, borderWidth: 1.5 }}>
|
|
248
|
+
{st.state === "done" ? <Icon name="Check" size={13} color={dot.fg} /> : <Text style={{ color: dot.fg, fontSize: 11, fontWeight: "700", fontFamily: MONO }}>{i + 1}</Text>}
|
|
249
|
+
</View>
|
|
250
|
+
<View style={{ flex: 1, height: 2, backgroundColor: i === steps.length - 1 ? "transparent" : steps[i + 1].state !== "todo" ? theme.colors.statusSuccess : theme.colors.border }} />
|
|
251
|
+
</View>
|
|
252
|
+
<Text style={{ color: st.state === "needs" ? c.brandText : theme.colors.foreground, fontSize: 12, fontWeight: "600" }}>{st.label}</Text>
|
|
253
|
+
<Text style={{ color: theme.colors.foregroundMuted, fontSize: 11 }}>{st.who}</Text>
|
|
254
|
+
</View>
|
|
255
|
+
);
|
|
256
|
+
})}
|
|
257
|
+
</View>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** The square icon block at the start of an "等你处理" card. */
|
|
262
|
+
export function AttentionIcon({ theme, icon, tone = "needs" }: { theme: Theme; icon: string; tone?: "needs" | "danger" | "muted" }) {
|
|
263
|
+
const c = rk(theme);
|
|
264
|
+
const [fg, bg] = tone === "danger" ? [theme.colors.statusDanger, c.failedTint] : tone === "muted" ? [theme.colors.foregroundMuted, theme.colors.surface2] : [c.brandText, c.brandTint];
|
|
265
|
+
return (
|
|
266
|
+
<View style={{ width: 36, height: 36, borderRadius: 10, alignItems: "center", justifyContent: "center", backgroundColor: bg }}>
|
|
267
|
+
<Icon name={icon} size={18} color={fg} />
|
|
268
|
+
</View>
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Loading, error and empty states in one place. */
|
|
273
|
+
export function Status({ theme, loading, error, empty }: { theme: Theme; loading?: boolean; error?: Error | null; empty?: string | null }) {
|
|
274
|
+
if (error) return <Text style={{ color: theme.colors.statusDanger, fontSize: 14 }}>{error.message}</Text>;
|
|
275
|
+
if (loading) return <Text style={{ color: theme.colors.foregroundMuted, fontSize: 14 }}>正在读取…</Text>;
|
|
276
|
+
if (empty) return <Text style={{ color: theme.colors.foregroundMuted, fontSize: 14 }}>{empty}</Text>;
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// The only file that uses web-only things (Paseo's rule for plugins): the prototype review page
|
|
2
|
+
// shown inside Paseo, in an iframe, on the web app and the desktop app. Phones get null and
|
|
3
|
+
// the screen offers a link instead.
|
|
4
|
+
import { createElement, type ReactElement } from "react";
|
|
5
|
+
import { Platform } from "react-native";
|
|
6
|
+
|
|
7
|
+
export const canEmbedPages = Platform.OS === "web";
|
|
8
|
+
|
|
9
|
+
export function embeddedPage(url: string, title: string): ReactElement | null {
|
|
10
|
+
if (Platform.OS !== "web") return null;
|
|
11
|
+
return createElement("iframe" as string, {
|
|
12
|
+
src: url,
|
|
13
|
+
title,
|
|
14
|
+
allow: "clipboard-read; clipboard-write",
|
|
15
|
+
style: { border: 0, width: "100%", height: "calc(100vh - 120px)", minHeight: 560, display: "block", background: "transparent" },
|
|
16
|
+
} as Record<string, unknown>);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const LOOPBACK = /^(127\.\d+\.\d+\.\d+|localhost|\[::1\]|::1)$/i;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Whether the review page cannot load in this browser: the review server listens only on the
|
|
23
|
+
* daemon's machine (127.0.0.1) and this Paseo web page was opened from another computer.
|
|
24
|
+
*/
|
|
25
|
+
export function reviewUnreachable(url: string): boolean {
|
|
26
|
+
if (Platform.OS !== "web") return false;
|
|
27
|
+
try {
|
|
28
|
+
const page = (globalThis as { location?: { hostname?: string } }).location?.hostname ?? "";
|
|
29
|
+
const target = new URL(url).hostname;
|
|
30
|
+
return LOOPBACK.test(target) && !!page && !LOOPBACK.test(page);
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { PluginClientContext, PluginScreenProps } from "@getpaseo/plugin/client";
|
|
2
|
+
import { ConfigScreen } from "./client/config";
|
|
3
|
+
import { RequirementScreen } from "./client/detail";
|
|
4
|
+
import { contributeLive } from "./client/live";
|
|
5
|
+
import { setScreenOpener } from "./client/nav";
|
|
6
|
+
import { OverviewScreen } from "./client/overview";
|
|
7
|
+
import { ReviewScreen } from "./client/review";
|
|
8
|
+
import { WorkspacePanel } from "./client/panel";
|
|
9
|
+
import { SettingsScreen } from "./client/settings";
|
|
10
|
+
import { RequirementsItem } from "./client/sidebar";
|
|
11
|
+
import { StatsScreen } from "./client/stats";
|
|
12
|
+
|
|
13
|
+
export default function contribute(client: PluginClientContext) {
|
|
14
|
+
const openScreen = (input: { screenId: string; params?: Record<string, string> }) => client.openScreen(input);
|
|
15
|
+
setScreenOpener(openScreen);
|
|
16
|
+
const Overview = (props: PluginScreenProps) => <OverviewScreen {...props} openScreen={openScreen} />;
|
|
17
|
+
|
|
18
|
+
client.addScreen({ id: "overview", title: "需求", Component: Overview });
|
|
19
|
+
client.addScreen({ id: "requirement", title: (params) => params.title || params.name || "需求", Component: RequirementScreen });
|
|
20
|
+
client.addScreen({ id: "stats", title: "需求统计", Component: StatsScreen });
|
|
21
|
+
client.addScreen({ id: "review", title: (params) => `审查原型:${params.title || params.featureDir?.split("/").pop() || ""}`, Component: ReviewScreen });
|
|
22
|
+
client.addScreen({ id: "config", title: "laoshi 配置", Component: ConfigScreen });
|
|
23
|
+
client.addSidebarHeaderItem({ id: "requirements", title: "需求(laoshi)", Component: RequirementsItem });
|
|
24
|
+
client.addWorkspacePanel({
|
|
25
|
+
id: "requirements",
|
|
26
|
+
title: "需求",
|
|
27
|
+
icon: "ClipboardList",
|
|
28
|
+
context: "workspace",
|
|
29
|
+
locations: ["workspace", "explorer"],
|
|
30
|
+
Component: WorkspacePanel,
|
|
31
|
+
});
|
|
32
|
+
client.addSettingsScreen({ id: "preferences", title: "laoshi", icon: "ClipboardList", Component: SettingsScreen });
|
|
33
|
+
client.addCommandCenterItem({
|
|
34
|
+
id: "open-overview",
|
|
35
|
+
title: "需求总览(laoshi)",
|
|
36
|
+
icon: "ClipboardList",
|
|
37
|
+
keywords: ["req", "requirement", "需求", "流水线"],
|
|
38
|
+
context: "global",
|
|
39
|
+
onSelect: ({ openScreen: open }) => open({ screenId: "overview" }),
|
|
40
|
+
});
|
|
41
|
+
client.addCommandCenterItem({
|
|
42
|
+
id: "open-stats",
|
|
43
|
+
title: "需求统计(laoshi)",
|
|
44
|
+
icon: "ChartColumn",
|
|
45
|
+
keywords: ["req", "stats", "统计", "用量"],
|
|
46
|
+
context: "global",
|
|
47
|
+
onSelect: ({ openScreen: open }) => open({ screenId: "stats" }),
|
|
48
|
+
});
|
|
49
|
+
client.addCommandCenterItem({
|
|
50
|
+
id: "open-config",
|
|
51
|
+
title: "laoshi 配置",
|
|
52
|
+
icon: "Settings",
|
|
53
|
+
keywords: ["req", "config", "配置", "设置"],
|
|
54
|
+
context: "global",
|
|
55
|
+
onSelect: ({ openScreen: open }) => open({ screenId: "config" }),
|
|
56
|
+
});
|
|
57
|
+
client.addCommandCenterItem({
|
|
58
|
+
id: "open-panel",
|
|
59
|
+
title: "这个工作区的需求(laoshi)",
|
|
60
|
+
icon: "ClipboardList",
|
|
61
|
+
keywords: ["req", "需求"],
|
|
62
|
+
context: "workspace",
|
|
63
|
+
onSelect: ({ openPanel }) => openPanel("requirements"),
|
|
64
|
+
});
|
|
65
|
+
return contributeLive(client);
|
|
66
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { PluginServerContext } from "@getpaseo/plugin/server";
|
|
2
|
+
import { configRpc, fileRpc, listRpc, modelsRpc, preferences, reviewUrlRpc, runRpc, setAgentsRpc, statsRpc, statusRpc, versionRpc } from "./shared/contracts";
|
|
3
|
+
import { createHandlers } from "./server/handlers";
|
|
4
|
+
import { kitHomeOf, reqApi } from "./server/req";
|
|
5
|
+
|
|
6
|
+
export default function contribute(server: PluginServerContext) {
|
|
7
|
+
const settings = server.registerSettings(preferences);
|
|
8
|
+
let kitHomeSetting = "";
|
|
9
|
+
let readOnly = false;
|
|
10
|
+
const load = async () => {
|
|
11
|
+
const state = await settings.read();
|
|
12
|
+
if (state.status === "ready") {
|
|
13
|
+
kitHomeSetting = state.values.kitHome;
|
|
14
|
+
readOnly = state.values.readOnly;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
void load();
|
|
18
|
+
const unsubscribe = settings.subscribe((state) => {
|
|
19
|
+
if (state.status !== "ready") return;
|
|
20
|
+
kitHomeSetting = state.values.kitHome;
|
|
21
|
+
readOnly = state.values.readOnly;
|
|
22
|
+
});
|
|
23
|
+
const kitHome = () => kitHomeOf(kitHomeSetting);
|
|
24
|
+
const handlers = createHandlers({
|
|
25
|
+
req: reqApi(kitHome),
|
|
26
|
+
kitHome,
|
|
27
|
+
readOnly: async () => {
|
|
28
|
+
await load();
|
|
29
|
+
return readOnly;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
server.handle(versionRpc, () => handlers.version());
|
|
33
|
+
server.handle(listRpc, () => handlers.list());
|
|
34
|
+
server.handle(statusRpc, (input) => handlers.status(input));
|
|
35
|
+
server.handle(fileRpc, (input) => handlers.file(input));
|
|
36
|
+
server.handle(statsRpc, (input) => handlers.stats(input));
|
|
37
|
+
server.handle(runRpc, (input) => handlers.run(input));
|
|
38
|
+
server.handle(modelsRpc, () => handlers.models());
|
|
39
|
+
server.handle(configRpc, (input) => handlers.config(input));
|
|
40
|
+
server.handle(setAgentsRpc, (input) => handlers.setAgents(input));
|
|
41
|
+
server.handle(reviewUrlRpc, (input) => handlers.reviewUrl(input));
|
|
42
|
+
// 1.13: every few minutes, continue this machine's pipelines whose background process died
|
|
43
|
+
// (laoshi api watchdog). Deterministic, no model involved; while it runs, pipelines do not ask
|
|
44
|
+
// their chats to check on them. Off when the plugin is read-only.
|
|
45
|
+
const check = async () => {
|
|
46
|
+
try {
|
|
47
|
+
await load();
|
|
48
|
+
if (readOnly) return;
|
|
49
|
+
await reqApi(kitHome)(["watchdog", "--by", "plugin"], { timeoutMs: 240_000 });
|
|
50
|
+
} catch {
|
|
51
|
+
// laoshi missing or a check failing: the next one tries again.
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const first = setTimeout(() => void check(), 60_000);
|
|
55
|
+
const timer = setInterval(() => void check(), 5 * 60_000);
|
|
56
|
+
return () => {
|
|
57
|
+
clearTimeout(first);
|
|
58
|
+
clearInterval(timer);
|
|
59
|
+
unsubscribe();
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "laoshi-paseo-plugin",
|
|
3
|
+
"version": "0.2.0-beta.2",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "The laoshi plugin for Paseo. Ships inside the laoshi package (adapters/paseo/plugin); installed with laoshi plugin install.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@getpaseo/client": "0.11.2",
|
|
12
|
+
"@getpaseo/plugin": "0.11.2",
|
|
13
|
+
"@getpaseo/protocol": "0.11.2",
|
|
14
|
+
"@tanstack/react-query": "^5.90.0",
|
|
15
|
+
"@types/node": "^22.0.0",
|
|
16
|
+
"@types/react": "~19.2.0",
|
|
17
|
+
"react": "19.1.0",
|
|
18
|
+
"react-native": "0.81.5",
|
|
19
|
+
"typescript": "^5.9.3",
|
|
20
|
+
"zod": "^4.4.3"
|
|
21
|
+
}
|
|
22
|
+
}
|