@yiyi_zhang/laoshi 0.2.0-beta.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +3 -2
  3. package/adapters/dsh/adapter.ts +22 -1
  4. package/adapters/dsh/dsh-runtime.ts +14 -3
  5. package/adapters/dsh/install.mjs +16 -4
  6. package/adapters/dsh/plugin/index.mjs +197 -18
  7. package/adapters/dsh/plugin/package.json +1 -1
  8. package/adapters/mogao/adapter.ts +10 -1
  9. package/adapters/mogao/mogao-runtime.ts +58 -23
  10. package/adapters/mogao/skill/setup.md +6 -0
  11. package/adapters/paseo/install.mjs +13 -4
  12. package/adapters/paseo/plugin/client/data.ts +13 -2
  13. package/adapters/paseo/plugin/client/detail.tsx +244 -4
  14. package/adapters/paseo/plugin/client/format.ts +25 -117
  15. package/adapters/paseo/plugin/client/overview.tsx +3 -3
  16. package/adapters/paseo/plugin/index.server.ts +2 -1
  17. package/adapters/paseo/plugin/package.json +1 -1
  18. package/adapters/paseo/plugin/paseo-plugin.json +1 -1
  19. package/adapters/paseo/plugin/server/handlers.ts +22 -4
  20. package/adapters/paseo/plugin/server/req.ts +17 -4
  21. package/adapters/paseo/plugin/shared/contracts.ts +28 -2
  22. package/adapters/paseo/plugin/shared/view-model.ts +425 -0
  23. package/bin/ensure-version.mjs +60 -0
  24. package/bin/req-doctor.mjs +5 -0
  25. package/bin/req.mjs +18 -0
  26. package/bin/start-pipeline.mjs +5 -0
  27. package/contracts/cli-json.md +3 -1
  28. package/docs/design/builtin-capabilities.md +2 -2
  29. package/docs/design/cli-adapter.md +1 -1
  30. package/docs/design/dsh-adapter.md +11 -11
  31. package/docs/design/shared-ui.md +43 -0
  32. package/docs/guide//345/234/250/346/221/270/351/253/230/344/270/212/344/275/277/347/224/250.md +2 -1
  33. package/docs/guide//345/256/211/350/243/205/344/270/216/345/215/207/347/272/247.md +13 -8
  34. package/docs/guide//347/234/237/345/256/236/347/216/257/345/242/203/350/265/260/346/237/245.md +78 -0
  35. package/docs/guide//347/273/264/346/212/244/350/200/205/346/214/207/345/215/227.md +36 -6
  36. package/engine/prompts/00-shared-context.md +7 -0
  37. package/engine/prompts/03-design.md +2 -0
  38. package/engine/prompts/04-design-review.md +5 -1
  39. package/engine/skill-fragments/defaults.md +5 -0
  40. package/engine/src/api.ts +11 -2
  41. package/engine/src/board.ts +435 -0
  42. package/engine/src/config.ts +23 -0
  43. package/engine/src/diagnose.ts +238 -0
  44. package/engine/src/doctor.ts +25 -0
  45. package/engine/src/estimate.ts +11 -0
  46. package/engine/src/extensions.ts +271 -0
  47. package/engine/src/handover-cmd.ts +47 -0
  48. package/engine/src/handover.ts +89 -0
  49. package/engine/src/history.ts +102 -0
  50. package/engine/src/joint.ts +49 -4
  51. package/engine/src/launch.ts +20 -5
  52. package/engine/src/main.ts +1 -1
  53. package/engine/src/messages.ts +58 -0
  54. package/engine/src/pipeline.ts +121 -5
  55. package/engine/src/platform.ts +6 -0
  56. package/engine/src/reply.ts +27 -6
  57. package/engine/src/semver.ts +21 -0
  58. package/engine/src/skills-render.ts +10 -1
  59. package/package.json +5 -2
  60. package/site-dist/404.html +2 -2
  61. package/site-dist/assets/{app.CXydUhZx.js → app.DZpVs0VH.js} +1 -1
  62. package/site-dist/assets/changelog.md.CdUYbro4.js +1 -0
  63. package/site-dist/assets/{changelog.md.BU-CvyJ1.lean.js → changelog.md.CdUYbro4.lean.js} +1 -1
  64. package/site-dist/assets/chunks/@localSearchIndexroot.CHr-ITwS.js +1 -0
  65. package/site-dist/assets/chunks/{VPLocalSearchBox.CIjDV0ax.js → VPLocalSearchBox.BHkmziy1.js} +1 -1
  66. package/site-dist/assets/chunks/{theme.CWtC1Kby.js → theme.BsPChbDE.js} +2 -2
  67. package/site-dist/assets/guide_dsh.md.D0XhcUHz.js +7 -0
  68. package/site-dist/assets/guide_dsh.md.D0XhcUHz.lean.js +7 -0
  69. package/site-dist/assets/{guide_getting-started.md.BxOxfic_.js → guide_getting-started.md.BDd3nU5n.js} +1 -1
  70. package/site-dist/assets/{guide_install.md.By4WxsJG.js → guide_install.md.SsIHMfUu.js} +7 -5
  71. package/site-dist/assets/{guide_install.md.By4WxsJG.lean.js → guide_install.md.SsIHMfUu.lean.js} +7 -5
  72. package/site-dist/assets/guide_maintainer.md.CvqvRle1.js +1 -0
  73. package/site-dist/assets/guide_maintainer.md.CvqvRle1.lean.js +1 -0
  74. package/site-dist/assets/{guide_mogao.md.S0eln1Pr.js → guide_mogao.md.TCu3lgE9.js} +2 -2
  75. package/site-dist/assets/{guide_mogao.md.S0eln1Pr.lean.js → guide_mogao.md.TCu3lgE9.lean.js} +2 -2
  76. package/site-dist/assets/guide_walkthrough.md.nj_PWP9Y.js +5 -0
  77. package/site-dist/assets/guide_walkthrough.md.nj_PWP9Y.lean.js +5 -0
  78. package/site-dist/assets/reference_contracts_cli-json.md.3iU9h4rw.js +1 -0
  79. package/site-dist/assets/reference_contracts_cli-json.md.3iU9h4rw.lean.js +1 -0
  80. package/site-dist/assets/{reference_design_builtin-capabilities.md.CZYtjo_v.js → reference_design_builtin-capabilities.md.k5NXkESv.js} +2 -2
  81. package/site-dist/assets/{reference_design_builtin-capabilities.md.CZYtjo_v.lean.js → reference_design_builtin-capabilities.md.k5NXkESv.lean.js} +2 -2
  82. package/site-dist/assets/{reference_design_cli-adapter.md.pJy3x6Un.js → reference_design_cli-adapter.md.C1lcDATP.js} +1 -1
  83. package/site-dist/assets/{reference_design_cli-adapter.md.pJy3x6Un.lean.js → reference_design_cli-adapter.md.C1lcDATP.lean.js} +1 -1
  84. package/site-dist/changelog.html +5 -5
  85. package/site-dist/guide/cli.html +4 -4
  86. package/site-dist/guide/dsh.html +8 -6
  87. package/site-dist/guide/getting-started.html +5 -5
  88. package/site-dist/guide/how-it-works.html +4 -4
  89. package/site-dist/guide/index.html +4 -4
  90. package/site-dist/guide/install.html +11 -9
  91. package/site-dist/guide/intranet.html +4 -4
  92. package/site-dist/guide/maintainer.html +5 -5
  93. package/site-dist/guide/mogao.html +7 -7
  94. package/site-dist/guide/phases.html +4 -4
  95. package/site-dist/guide/project.html +4 -4
  96. package/site-dist/guide/user.html +4 -4
  97. package/site-dist/guide/walkthrough.html +34 -0
  98. package/site-dist/hashmap.json +1 -1
  99. package/site-dist/index.html +4 -4
  100. package/site-dist/reference/adr/0001-new-repo-core-and-adapters.html +4 -4
  101. package/site-dist/reference/adr/0002-two-orchestration-modes.html +4 -4
  102. package/site-dist/reference/adr/0003-generate-once-then-lock.html +4 -4
  103. package/site-dist/reference/adr/0004-external-contracts-stay-stable.html +4 -4
  104. package/site-dist/reference/adr/0005-skill-names.html +4 -4
  105. package/site-dist/reference/adr/0006-deterministic-engine-platform-capabilities.html +4 -4
  106. package/site-dist/reference/adr/0007-one-install-many-repos.html +4 -4
  107. package/site-dist/reference/adr/0008-capability-sources-and-platform-plugin.html +4 -4
  108. package/site-dist/reference/adr/index.html +4 -4
  109. package/site-dist/reference/commands.html +4 -4
  110. package/site-dist/reference/config.html +4 -4
  111. package/site-dist/reference/contracts/agent-runtime.html +4 -4
  112. package/site-dist/reference/contracts/cli-json.html +5 -5
  113. package/site-dist/reference/contracts/feature-files.html +4 -4
  114. package/site-dist/reference/contracts/index.html +4 -4
  115. package/site-dist/reference/contracts/notifier-event.html +4 -4
  116. package/site-dist/reference/contracts/result-file.html +4 -4
  117. package/site-dist/reference/contracts/spec.html +4 -4
  118. package/site-dist/reference/contracts/state.html +4 -4
  119. package/site-dist/reference/contracts/usage-record.html +4 -4
  120. package/site-dist/reference/contracts/verify.html +4 -4
  121. package/site-dist/reference/design/adapter-guide.html +4 -4
  122. package/site-dist/reference/design/architecture.html +4 -4
  123. package/site-dist/reference/design/builtin-capabilities.html +6 -6
  124. package/site-dist/reference/design/cli-adapter.html +5 -5
  125. package/site-dist/reference/design/platform-vocabulary.html +4 -4
  126. package/site-dist/reference/scope.html +4 -4
  127. package/skills/laoshi/SKILL.md +1 -3
  128. package/skills/laoshi-setup/SKILL.md +1 -1
  129. package/ui/shared/view-model.ts +424 -0
  130. package/ui/web/board.ts +1126 -0
  131. package/site-dist/assets/changelog.md.BU-CvyJ1.js +0 -1
  132. package/site-dist/assets/chunks/@localSearchIndexroot.CfgJeQRO.js +0 -1
  133. package/site-dist/assets/guide_dsh.md.0X-eYB87.js +0 -5
  134. package/site-dist/assets/guide_dsh.md.0X-eYB87.lean.js +0 -5
  135. package/site-dist/assets/guide_maintainer.md.Da1ffqxm.js +0 -1
  136. package/site-dist/assets/guide_maintainer.md.Da1ffqxm.lean.js +0 -1
  137. package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.js +0 -1
  138. package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.lean.js +0 -1
  139. /package/site-dist/assets/{guide_getting-started.md.BxOxfic_.lean.js → guide_getting-started.md.BDd3nU5n.lean.js} +0 -0
@@ -1,18 +1,20 @@
1
- // Plain-language labels, shared by every screen.
2
- import type { Attention, Requirement } from "../shared/contracts";
3
-
4
- export const ATTENTION_LABELS: Record<Exclude<Attention, null>, string> = {
5
- approval: "等待确认方案",
6
- business: "等待需求方决定",
7
- permission: "等待批准权限",
8
- interrupted: "已中断,可以继续",
9
- not_completed: "结束但未完成",
10
- not_started: "已确认,未开始开发",
11
- };
12
-
13
- export const TYPE_LABELS: Record<string, string> = { defect: "缺陷", refactor: "重构", assessment: "评估" };
14
-
15
- export const PROFILE_LABELS: Record<string, string> = { quick: "快速档", standard: "标准档" };
1
+ // Plain-language labels, shared by every screen (re-exporting ui/shared/view-model).
2
+ import type { Requirement } from "../shared/contracts";
3
+ export {
4
+ ago,
5
+ ATTENTION_LABELS,
6
+ type Group,
7
+ GROUP_EYEBROWS,
8
+ GROUP_LABELS,
9
+ groupOf,
10
+ iconOf,
11
+ minutes,
12
+ PROFILE_LABELS,
13
+ tokens,
14
+ TRACK,
15
+ trackOf,
16
+ TYPE_LABELS,
17
+ } from "../shared/view-model";
16
18
 
17
19
  export const FILE_LABELS: Record<string, string> = {
18
20
  "spec.md": "需求说明",
@@ -37,51 +39,9 @@ export const FILE_LABELS: Record<string, string> = {
37
39
  "lessons.tsv": "可以变成规则的问题",
38
40
  };
39
41
 
40
- export type Group = "attention" | "running" | "verify" | "done" | "other";
41
-
42
- export const GROUP_LABELS: Record<Group, string> = {
43
- attention: "需要你处理",
44
- running: "进行中",
45
- verify: "研发完成,待测试验证",
46
- done: "最近完成",
47
- other: "其他",
48
- };
49
-
50
- const RECENT_MS = 14 * 24 * 3600_000;
51
-
52
- export function groupOf(r: Requirement, now = Date.now()): Group {
53
- if (r.attention) return "attention";
54
- if (r.running) return "running";
55
- if (r.status === "phase_done") return "verify";
56
- if (r.status === "completed" && now - Date.parse(r.updatedAt) < RECENT_MS) return "done";
57
- return "other";
58
- }
59
-
60
- export function minutes(m: number): string {
61
- if (m < 1) return "不到 1 分钟";
62
- if (m < 60) return `${Math.round(m)} 分钟`;
63
- const h = Math.floor(m / 60);
64
- const rest = Math.round(m % 60);
65
- return rest === 0 ? `${h} 小时` : `${h} 小时 ${rest} 分`;
66
- }
67
-
68
- export function ago(iso: string, now = Date.now()): string {
69
- const m = (now - Date.parse(iso)) / 60_000;
70
- if (!Number.isFinite(m)) return "";
71
- if (m < 1) return "刚刚";
72
- if (m < 60) return `${Math.round(m)} 分钟前`;
73
- if (m < 24 * 60) return `${Math.round(m / 60)} 小时前`;
74
- return `${Math.round(m / 60 / 24)} 天前`;
75
- }
76
-
77
- export function tokens(n: number | null): string {
78
- if (n === null) return "未报告";
79
- return n >= 10_000 ? `${Math.round(n / 1_000) / 10} 万` : String(n);
80
- }
81
-
82
42
  /** One line under a requirement's title: project, type, stage. */
83
43
  export function facts(r: Requirement): string {
84
- return [r.project, r.type ? TYPE_LABELS[r.type] ?? r.type : null, r.profile ? PROFILE_LABELS[r.profile] ?? r.profile : null]
44
+ return [r.project, r.type ? ({ defect: "缺陷", refactor: "重构", assessment: "评估" }[r.type] ?? r.type) : null, r.profile ? ({ quick: "快速档", standard: "标准档" }[r.profile] ?? r.profile) : null]
85
45
  .filter(Boolean)
86
46
  .join(" · ");
87
47
  }
@@ -98,9 +58,9 @@ export function actionsFor(
98
58
  ? ["resume"]
99
59
  : r.attention === "not_started"
100
60
  ? ["start"]
101
- : r.status === "phase_done"
102
- ? ["verify"]
103
- : [];
61
+ : r.status === "phase_done"
62
+ ? ["verify"]
63
+ : [];
104
64
  // A running pipeline sends what failed by itself at its next step change.
105
65
  if (!r.running && r.status && (r.external ?? []).some((e) => e.pending > 0 || !e.id)) base.push("sync");
106
66
  return base;
@@ -114,60 +74,8 @@ export const ACTION_TEXT = {
114
74
  verify: { label: "开始测试验证", confirm: "开始测试验证?选择在哪里验证。" },
115
75
  sync: { label: "同步到外部系统", confirm: "把这个需求同步到对接的外部系统:补发没有成功的调用、补建卡片、更新状态。" },
116
76
  reply: { label: "发送回复", confirm: "把回复转给这个需求的对话,由它更新需求说明并继续开发。" },
77
+ try: { label: "一键试用", confirm: "启动这个需求的服务,生成访问地址和测试数据供试用?" },
78
+ "try-stop": { label: "停止试用", confirm: "停止试用时启动的服务?" },
79
+ change: { label: "改需求", confirm: "把需求变更转给这个需求的对话:它会先停下流水线,和你确认变化并更新需求说明后继续。" },
80
+ handover: { label: "转交", confirm: "把当前需求的负责权转交给另一位同事。" },
117
81
  } as const;
118
-
119
- /** The six stops of the step track, and who does each (design/components/StepTrack.md). */
120
- export const TRACK = [
121
- { label: "对齐", who: "你" },
122
- { label: "方案", who: "AI · 你确认" },
123
- { label: "实现", who: "AI" },
124
- { label: "评审", who: "AI · 开发同事" },
125
- { label: "验证", who: "AI" },
126
- { label: "验收", who: "需求方" },
127
- ] as const;
128
-
129
- const STEP_STOP: Array<[RegExp, number]> = [
130
- [/^(design|design_review|design_revise|design_proposal|assessment|diagnosis|reproduce)/, 1],
131
- [/^(implement|acceptance_tests)/, 2],
132
- [/^(code_review|review_fix)/, 3],
133
- [/^(verify|defect_fix|reverify|service|handoff|report)/, 4],
134
- ];
135
-
136
- /**
137
- * Where the requirement is on the track, and whether that stop waits for a person.
138
- * `humanReview` (detail only) tells whether the code review is done.
139
- */
140
- export function trackOf(
141
- r: Pick<Requirement, "stage" | "status" | "attention" | "running" | "current">,
142
- humanReview?: { status: string; stale: boolean } | null,
143
- ): Array<{ label: string; who: string; state: "done" | "now" | "needs" | "todo" }> {
144
- let at = 0;
145
- let needs = false;
146
- const running = r.current[0]?.key;
147
- if (r.stage.startsWith("对齐")) at = 0;
148
- else if (r.attention === "approval" || r.attention === "business" || r.attention === "not_started") [at, needs] = [1, true];
149
- else if (running) at = STEP_STOP.find(([re]) => re.test(running))?.[1] ?? 2;
150
- else if (r.status === "phase_done") [at, needs] = [4, true];
151
- else if (r.status === "completed" || /待验收|已验收|验收/.test(r.stage)) {
152
- const reviewed = humanReview && humanReview.status === "approved" && !humanReview.stale;
153
- if (/已验收|验收通过/.test(r.stage)) at = TRACK.length;
154
- else if (humanReview !== undefined && !reviewed) [at, needs] = [3, true];
155
- else [at, needs] = [5, true];
156
- } else if (r.status) at = 2;
157
- return TRACK.map((t, i) => ({ ...t, state: i < at ? "done" : i === at ? (needs ? "needs" : "now") : "todo" }));
158
- }
159
-
160
- /** The icon of a requirement in a list, by what it needs (Lucide names). */
161
- export function iconOf(r: Pick<Requirement, "attention" | "running" | "status" | "stage">): { name: string; tone: "needs" | "running" | "success" | "warning" | "danger" | "muted" } {
162
- if (r.attention === "interrupted") return { name: "OctagonAlert", tone: "danger" };
163
- if (r.attention === "permission") return { name: "ShieldCheck", tone: "needs" };
164
- if (r.attention === "approval") return { name: "PenTool", tone: "needs" };
165
- if (r.attention === "business") return { name: "MessagesSquare", tone: "needs" };
166
- if (r.attention === "not_started") return { name: "Play", tone: "needs" };
167
- if (r.attention === "not_completed") return { name: "CircleDashed", tone: "warning" };
168
- if (r.running) return { name: "LoaderCircle", tone: "running" };
169
- if (r.stage.startsWith("对齐")) return { name: "MessagesSquare", tone: "muted" };
170
- if (r.status === "phase_done" || /待验收/.test(r.stage)) return { name: "ClipboardCheck", tone: "warning" };
171
- if (r.status === "completed") return { name: "CircleCheck", tone: "success" };
172
- return { name: "Circle", tone: "muted" };
173
- }
@@ -5,15 +5,15 @@ import { useMemo, useState } from "react";
5
5
  import { Text, View } from "react-native";
6
6
  import type { Requirement } from "../shared/contracts";
7
7
  import { useRequirements } from "./data";
8
- import { type Group, GROUP_LABELS, groupOf } from "./format";
8
+ import { type Group, GROUP_EYEBROWS, GROUP_LABELS, groupOf } from "./format";
9
9
  import { Inbox } from "./inbox";
10
10
  import { RequirementRow } from "./row";
11
11
  import { BrandHeader, Button, Chip, Eyebrow, Status, useStyles } from "./ui";
12
12
 
13
13
  export const ORDER: Group[] = ["attention", "running", "verify", "done", "other"];
14
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" };
15
+ /** Unified Chinese group headings (shared with dsh/Web board via ui/shared/view-model). */
16
+ const EYEBROW: Record<Group, string> = GROUP_EYEBROWS;
17
17
 
18
18
  /** Opens a requirement's detail screen. */
19
19
  export type OpenRequirement = (item: Pick<Requirement, "repo" | "featureDir" | "title">) => void;
@@ -1,5 +1,5 @@
1
1
  import type { PluginServerContext } from "@getpaseo/plugin/server";
2
- import { configRpc, fileRpc, listRpc, modelsRpc, preferences, reviewUrlRpc, runRpc, setAgentsRpc, statsRpc, statusRpc, versionRpc } from "./shared/contracts";
2
+ import { configRpc, fileRpc, historyRpc, listRpc, modelsRpc, preferences, reviewUrlRpc, runRpc, setAgentsRpc, statsRpc, statusRpc, versionRpc } from "./shared/contracts";
3
3
  import { createHandlers } from "./server/handlers";
4
4
  import { kitHomeOf, reqApi } from "./server/req";
5
5
 
@@ -32,6 +32,7 @@ export default function contribute(server: PluginServerContext) {
32
32
  server.handle(versionRpc, () => handlers.version());
33
33
  server.handle(listRpc, () => handlers.list());
34
34
  server.handle(statusRpc, (input) => handlers.status(input));
35
+ server.handle(historyRpc, (input) => handlers.history(input));
35
36
  server.handle(fileRpc, (input) => handlers.file(input));
36
37
  server.handle(statsRpc, (input) => handlers.stats(input));
37
38
  server.handle(runRpc, (input) => handlers.run(input));
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laoshi-paseo-plugin",
3
- "version": "0.2.0-beta.3",
3
+ "version": "0.3.0",
4
4
  "private": true,
5
5
  "description": "The laoshi plugin for Paseo. Ships inside the laoshi package (adapters/paseo/plugin); installed with laoshi plugin install.",
6
6
  "type": "module",
@@ -2,5 +2,5 @@
2
2
  "id": "laoshi",
3
3
  "name": "laoshi 需求",
4
4
  "description": "在 Paseo 中查看和管理 laoshi 的需求:总览、进度、文档、统计,确认方案、停止和继续",
5
- "requirements": { "paseo": ">=0.11.0 <0.12.0" }
5
+ "requirements": { "paseo": ">=0.11.0 <0.18.0" }
6
6
  }
@@ -1,13 +1,14 @@
1
1
  // The daemon side: each RPC is one `laoshi api` call. Management actions are refused here too
2
2
  // when the plugin is set to read-only, not only hidden in the app.
3
3
  import type { RpcInput } from "@getpaseo/plugin";
4
- import type { configRpc, ConfigViewData, fileRpc, KitInfo, ModelsData, Requirement, RequirementDetail, reviewUrlRpc, runRpc, setAgentsRpc, statsRpc, StatsSummary, statusRpc } from "../shared/contracts";
4
+ import type { configRpc, ConfigViewData, fileRpc, historyRpc, KitInfo, ModelsData, Requirement, RequirementDetail, RequirementHistory, reviewUrlRpc, runRpc, setAgentsRpc, statsRpc, StatsSummary, statusRpc } from "../shared/contracts";
5
5
  import { coalesce, type ReqRunner } from "./req";
6
6
 
7
7
  export interface Handlers {
8
8
  version(): Promise<KitInfo>;
9
9
  list(): Promise<Requirement[]>;
10
10
  status(input: RpcInput<typeof statusRpc>): Promise<RequirementDetail>;
11
+ history(input: RpcInput<typeof historyRpc>): Promise<RequirementHistory>;
11
12
  file(input: RpcInput<typeof fileRpc>): Promise<{ file: string; size: number; truncated: boolean; content: string }>;
12
13
  stats(input: RpcInput<typeof statsRpc>): Promise<StatsSummary>;
13
14
  run(input: RpcInput<typeof runRpc>): Promise<{ ok: boolean; message: string }>;
@@ -30,6 +31,9 @@ export function createHandlers(input: { req: ReqRunner; kitHome: () => string; r
30
31
  async status({ repo, featureDir }) {
31
32
  return (await req(["status", featureDir, "--repo", repo])) as RequirementDetail;
32
33
  },
34
+ async history({ repo, featureDir }) {
35
+ return (await req(["history", featureDir, "--repo", repo])) as RequirementHistory;
36
+ },
33
37
  async file({ repo, featureDir, file }) {
34
38
  return (await req(["file", featureDir, file, "--repo", repo])) as { file: string; size: number; truncated: boolean; content: string };
35
39
  },
@@ -39,11 +43,25 @@ export function createHandlers(input: { req: ReqRunner; kitHome: () => string; r
39
43
  else if (since) args.push("--since", since);
40
44
  return (await req(args)) as StatsSummary;
41
45
  },
42
- async run({ action, repo, featureDir, verifyEnv, text }) {
46
+ async run({ action, repo, featureDir, verifyEnv, text, to, note }) {
43
47
  if (await input.readOnly()) return { ok: false, message: "插件设置为只读:不能在这里操作需求。可以在插件设置中关闭只读,或在终端用 req 命令。" };
44
48
  if (action === "reply" && !text?.trim()) return { ok: false, message: "回复是空的" };
45
- const extra = action === "verify" && verifyEnv ? ["--verify-env", verifyEnv] : action === "reply" ? [text!.trim()] : [];
46
- const result = (await req(["run", action, featureDir, "--repo", repo, ...extra], { timeoutMs: 200_000 })) as { ok: boolean; message: string };
49
+ if (action === "change" && !text?.trim()) return { ok: false, message: "改动内容是空的" };
50
+ if (action === "handover" && !to?.trim()) return { ok: false, message: "接手人不能为空" };
51
+ const cmd = action === "try-stop" ? "try" : action === "change" ? "reply" : action;
52
+ const extra =
53
+ action === "verify" && verifyEnv
54
+ ? ["--verify-env", verifyEnv]
55
+ : action === "reply"
56
+ ? [text!.trim()]
57
+ : action === "change"
58
+ ? ["--change", text!.trim()]
59
+ : action === "handover"
60
+ ? [to!.trim(), ...(note?.trim() ? ["--note", note.trim()] : [])]
61
+ : action === "try-stop"
62
+ ? ["--stop"]
63
+ : [];
64
+ const result = (await req(["run", cmd, featureDir, "--repo", repo, ...extra], { timeoutMs: 200_000 })) as { ok: boolean; message: string };
47
65
  return { ok: result.ok, message: result.message };
48
66
  },
49
67
  async reviewUrl({ repo, featureDir, page }) {
@@ -15,16 +15,29 @@ export class ReqError extends Error {
15
15
  }
16
16
  }
17
17
 
18
+ function defaultHere(): string | undefined {
19
+ // Paseo bundles server code to CJS and runs it via eval(), where import.meta.url is undefined.
20
+ try {
21
+ if (typeof import.meta !== "undefined" && import.meta.url) return path.dirname(fileURLToPath(import.meta.url));
22
+ } catch {
23
+ // No module URL in bundled runtime; fall back to LAOSHI_HOME or ~/.laoshi.
24
+ }
25
+ return undefined;
26
+ }
27
+
18
28
  /**
19
29
  * laoshi's install root: the plugin setting, else LAOSHI_HOME, else the root the plugin is
20
30
  * installed in (`laoshi plugin install` copies it to <install root>/paseo-plugin), else ~/.laoshi.
21
31
  */
22
- export function kitHomeOf(configured: string, here: string = path.dirname(fileURLToPath(import.meta.url))): string {
23
- if (configured.trim()) return path.resolve(configured.trim().replace(/^~(?=$|[\\/])/, os.homedir()));
32
+ export function kitHomeOf(configured: string, here: string | undefined = defaultHere()): string {
33
+ const manual = (configured ?? "").trim();
34
+ if (manual) return path.resolve(manual.replace(/^~(?=$|[\\/])/, os.homedir()));
24
35
  const env = process.env.LAOSHI_HOME?.trim();
25
36
  if (env) return path.resolve(env);
26
- const root = path.resolve(here, "..", "..");
27
- if (path.basename(path.resolve(here, "..")) === "paseo-plugin" && fs.existsSync(path.join(root, "install.json"))) return root;
37
+ if (here) {
38
+ const root = path.resolve(here, "..", "..");
39
+ if (path.basename(path.resolve(here, "..")) === "paseo-plugin" && fs.existsSync(path.join(root, "install.json"))) return root;
40
+ }
28
41
  return path.join(os.homedir(), ".laoshi");
29
42
  }
30
43
 
@@ -34,6 +34,8 @@ export interface Requirement {
34
34
  updatedAt: string;
35
35
  usage: Usage | null;
36
36
  present: boolean;
37
+ startedBy?: string | null;
38
+ owner?: string | null;
37
39
  /** req-kit 1.13+: it has an interface prototype, which the review page shows. */
38
40
  hasPrototype?: boolean;
39
41
  /** req-kit 1.12+: what a requirement that needs a person is waiting for; absent before. */
@@ -182,17 +184,41 @@ export const statsRpc = defineRpc({
182
184
  output: z.custom<StatsSummary>(),
183
185
  });
184
186
 
185
- export const ACTIONS = ["approve", "stop", "resume", "verify", "sync", "reply", "start"] as const;
187
+ export const ACTIONS = ["approve", "stop", "resume", "verify", "sync", "reply", "start", "try", "try-stop", "change", "handover"] as const;
186
188
  export type Action = (typeof ACTIONS)[number];
187
189
 
190
+ export interface HandoverEvent {
191
+ from: string | null;
192
+ to: string;
193
+ at: string;
194
+ note: string | null;
195
+ }
196
+
197
+ export interface RequirementHistory {
198
+ specVersion: string | null;
199
+ changes: Array<{ title: string; body: string }>;
200
+ commits: Array<{ commit: string; date: string; author: string; subject: string; diff: string; truncated: boolean }>;
201
+ owner: { owner: string | null; history: HandoverEvent[] };
202
+ }
203
+
204
+ export const historyRpc = defineRpc({
205
+ name: "req.history",
206
+ input: target,
207
+ output: z.custom<RequirementHistory>(),
208
+ });
209
+
188
210
  export const runRpc = defineRpc({
189
211
  name: "req.run",
190
212
  input: target.extend({
191
213
  action: z.enum(ACTIONS),
192
214
  /** For verify: local | deployed. */
193
215
  verifyEnv: z.enum(["local", "deployed"]).optional(),
194
- /** For reply (1.12): the answer, passed to the requirement's chat. */
216
+ /** For reply / change: the answer or change request passed to the requirement's chat. */
195
217
  text: z.string().max(8000).optional(),
218
+ /** For handover: new owner name/account. */
219
+ to: z.string().max(64).optional(),
220
+ /** For handover: optional handover note. */
221
+ note: z.string().max(500).optional(),
196
222
  }),
197
223
  output: z.object({ ok: z.boolean(), message: z.string() }),
198
224
  });