@yiyi_zhang/laoshi 0.0.0-stage → 0.1.1

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 (351) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/LICENSE +21 -0
  3. package/README.md +60 -2
  4. package/SCOPE.md +13 -0
  5. package/adapters/dsh/adapter.ts +75 -0
  6. package/adapters/dsh/dsh-runtime.ts +242 -0
  7. package/adapters/dsh/install.mjs +97 -0
  8. package/adapters/dsh/intranet/install.mjs +15 -0
  9. package/adapters/dsh/intranet/make-sample.mjs +52 -0
  10. package/adapters/dsh/plugin/channel.d.mts +2 -0
  11. package/adapters/dsh/plugin/channel.mjs +31 -0
  12. package/adapters/dsh/plugin/index.d.mts +3 -0
  13. package/adapters/dsh/plugin/index.mjs +292 -0
  14. package/adapters/dsh/plugin/package.json +18 -0
  15. package/adapters/paseo/adapter.ts +96 -0
  16. package/adapters/paseo/daemon-check.ts +80 -0
  17. package/adapters/paseo/daemon-version.ts +64 -0
  18. package/adapters/paseo/doctor.ts +161 -0
  19. package/adapters/paseo/install.mjs +30 -0
  20. package/adapters/paseo/paseo-json.ts +73 -0
  21. package/adapters/paseo/paseo-profiles.ts +127 -0
  22. package/adapters/paseo/paseo-runtime.ts +507 -0
  23. package/adapters/paseo/settings.ts +22 -0
  24. package/adapters/paseo/skill/setup.md +26 -0
  25. package/adapters/paseo/skill/templates/copy-local-files.mjs +32 -0
  26. package/adapters/paseo/skill/templates/with-port.mjs +36 -0
  27. package/adapters/paseo/smoke-test.ts +203 -0
  28. package/bin/bootstrap.mjs +170 -0
  29. package/bin/install.mjs +245 -0
  30. package/bin/locate.mjs +22 -0
  31. package/bin/req-docs.d.mts +5 -0
  32. package/bin/req-docs.mjs +167 -0
  33. package/bin/req-doctor.mjs +21 -0
  34. package/bin/req.mjs +236 -0
  35. package/bin/start-pipeline +21 -0
  36. package/bin/start-pipeline.mjs +22 -0
  37. package/config.example.json +134 -0
  38. package/contracts/README.md +21 -0
  39. package/contracts/agent-runtime.md +83 -0
  40. package/contracts/cli-json.md +76 -0
  41. package/contracts/feature-files.md +148 -0
  42. package/contracts/notifier-event.md +90 -0
  43. package/contracts/result-file.md +21 -0
  44. package/contracts/spec.md +37 -0
  45. package/contracts/state.md +69 -0
  46. package/contracts/usage-record.md +72 -0
  47. package/contracts/verify.md +41 -0
  48. package/docs/adr/0001-new-repo-core-and-adapters.md +20 -0
  49. package/docs/adr/0002-two-orchestration-modes.md +20 -0
  50. package/docs/adr/0003-generate-once-then-lock.md +20 -0
  51. package/docs/adr/0004-external-contracts-stay-stable.md +19 -0
  52. package/docs/adr/0005-skill-names.md +26 -0
  53. package/docs/adr/0006-deterministic-engine-platform-capabilities.md +42 -0
  54. package/docs/adr/0007-one-install-many-repos.md +63 -0
  55. package/docs/adr/0008-capability-sources-and-platform-plugin.md +81 -0
  56. package/docs/adr/README.md +14 -0
  57. package/docs/design/adapter-guide.md +90 -0
  58. package/docs/design/architecture.md +104 -0
  59. package/docs/design/builtin-capabilities.md +72 -0
  60. package/docs/design/compat-migration.md +65 -0
  61. package/docs/design/dsh-adapter.md +145 -0
  62. package/docs/design/in-chat-orchestration.md +67 -0
  63. package/docs/design/init-bootstrap.md +83 -0
  64. package/docs/design/internal-platform-adapter.md +76 -0
  65. package/docs/design/platform-discovery.md +117 -0
  66. package/docs/design/platform-vocabulary.md +44 -0
  67. package/docs/design/state-v2.md +71 -0
  68. package/docs/guide//344/275/277/347/224/250/350/200/205/346/214/207/345/215/227.md +130 -0
  69. package/docs/guide//345/256/211/350/243/205/344/270/216/345/215/207/347/272/247.md +211 -0
  70. package/docs/guide//347/273/264/346/212/244/350/200/205/346/214/207/345/215/227.md +86 -0
  71. 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 +595 -0
  72. package/docs/intranet/install-verify.md +278 -0
  73. package/engine/prompts/00-shared-context.md +107 -0
  74. package/engine/prompts/02-spec-review.md +46 -0
  75. package/engine/prompts/03-design.md +77 -0
  76. package/engine/prompts/03a-design-proposal.md +30 -0
  77. package/engine/prompts/04-design-review.md +73 -0
  78. package/engine/prompts/04b-design-revise.md +56 -0
  79. package/engine/prompts/05-implement.md +72 -0
  80. package/engine/prompts/06-code-review.md +81 -0
  81. package/engine/prompts/07-review-fix.md +41 -0
  82. package/engine/prompts/07b-handoff.md +45 -0
  83. package/engine/prompts/08-service-start.md +59 -0
  84. package/engine/prompts/09-verify.md +90 -0
  85. package/engine/prompts/10-defect-fix.md +41 -0
  86. package/engine/prompts/10b-reverify.md +43 -0
  87. package/engine/prompts/11-report.md +112 -0
  88. package/engine/prompts/browser-verify.md +14 -0
  89. package/engine/prompts/incremental.md +24 -0
  90. package/engine/prompts/joint.md +55 -0
  91. package/engine/prompts/managed-services.md +9 -0
  92. package/engine/prompts/panel-member.md +38 -0
  93. package/engine/prompts/related-repos.md +7 -0
  94. package/engine/prompts/review-axis-spec.md +10 -0
  95. package/engine/prompts/review-axis-standards.md +11 -0
  96. package/engine/prompts/types/assessment.md +41 -0
  97. package/engine/prompts/types/defect.md +55 -0
  98. package/engine/prompts/types/refactor.md +39 -0
  99. package/engine/prompts/ui-check.md +15 -0
  100. package/engine/prompts/verify-deployed.md +14 -0
  101. package/engine/skill-fragments/setup-builtin.md +24 -0
  102. package/engine/src/activity.ts +131 -0
  103. package/engine/src/api.ts +655 -0
  104. package/engine/src/builtin/index.ts +30 -0
  105. package/engine/src/builtin/project-services.ts +66 -0
  106. package/engine/src/builtin/service-runner.mjs +35 -0
  107. package/engine/src/builtin/services.ts +264 -0
  108. package/engine/src/builtin/setup-runner.mjs +26 -0
  109. package/engine/src/builtin/workspace.ts +139 -0
  110. package/engine/src/card-cmd.ts +505 -0
  111. package/engine/src/card.ts +541 -0
  112. package/engine/src/checklist-cmd.ts +37 -0
  113. package/engine/src/checklist.ts +254 -0
  114. package/engine/src/cli-args.ts +228 -0
  115. package/engine/src/code-review.ts +421 -0
  116. package/engine/src/codeowners.ts +87 -0
  117. package/engine/src/config-view.ts +310 -0
  118. package/engine/src/config.ts +862 -0
  119. package/engine/src/configure.ts +343 -0
  120. package/engine/src/control.ts +257 -0
  121. package/engine/src/danger-guard.ts +180 -0
  122. package/engine/src/digest.ts +141 -0
  123. package/engine/src/doctor.ts +410 -0
  124. package/engine/src/estimate.ts +95 -0
  125. package/engine/src/eval.ts +325 -0
  126. package/engine/src/factory.ts +545 -0
  127. package/engine/src/features.ts +311 -0
  128. package/engine/src/gate.ts +157 -0
  129. package/engine/src/git.ts +30 -0
  130. package/engine/src/identity.ts +72 -0
  131. package/engine/src/index-cmd.ts +34 -0
  132. package/engine/src/integration-cmd.ts +161 -0
  133. package/engine/src/integrations.ts +485 -0
  134. package/engine/src/joint.ts +173 -0
  135. package/engine/src/launch.ts +443 -0
  136. package/engine/src/lessons.ts +74 -0
  137. package/engine/src/locations.ts +83 -0
  138. package/engine/src/main.ts +390 -0
  139. package/engine/src/messages.ts +472 -0
  140. package/engine/src/notifiers.ts +114 -0
  141. package/engine/src/notify-test.ts +108 -0
  142. package/engine/src/outcomes.ts +145 -0
  143. package/engine/src/paths.ts +10 -0
  144. package/engine/src/pipeline.ts +2517 -0
  145. package/engine/src/platform.ts +121 -0
  146. package/engine/src/playbooks.ts +46 -0
  147. package/engine/src/preflight.ts +352 -0
  148. package/engine/src/prompts.ts +76 -0
  149. package/engine/src/queue.ts +61 -0
  150. package/engine/src/records.ts +403 -0
  151. package/engine/src/reply.ts +81 -0
  152. package/engine/src/review-assets/app.css +339 -0
  153. package/engine/src/review-assets/app.html +107 -0
  154. package/engine/src/review-assets/app.js +958 -0
  155. package/engine/src/review-assets/check.css +12 -0
  156. package/engine/src/review-assets/check.html +61 -0
  157. package/engine/src/review-assets/check.js +341 -0
  158. package/engine/src/review-assets/code.css +16 -0
  159. package/engine/src/review-assets/code.html +58 -0
  160. package/engine/src/review-assets/code.js +497 -0
  161. package/engine/src/review-assets/rk-icons.js +98 -0
  162. package/engine/src/review-assets/rk-tokens.css +252 -0
  163. package/engine/src/review-assets/rk.css +254 -0
  164. package/engine/src/review.ts +771 -0
  165. package/engine/src/runtime-loader.ts +110 -0
  166. package/engine/src/runtime.ts +186 -0
  167. package/engine/src/scan-guard.ts +132 -0
  168. package/engine/src/schedule-time.ts +51 -0
  169. package/engine/src/secret-scan.ts +177 -0
  170. package/engine/src/semver.ts +31 -0
  171. package/engine/src/skills-render.ts +104 -0
  172. package/engine/src/spec-review.ts +99 -0
  173. package/engine/src/state.ts +506 -0
  174. package/engine/src/stats.ts +810 -0
  175. package/engine/src/steps.ts +269 -0
  176. package/engine/src/try.ts +135 -0
  177. package/engine/src/ui-check-page.js +208 -0
  178. package/engine/src/ui-check.ts +366 -0
  179. package/engine/src/usage.ts +67 -0
  180. package/engine/src/watchdog.ts +139 -0
  181. package/engine/src/words.ts +95 -0
  182. package/engine/src/worktree.ts +227 -0
  183. package/notifiers/im-template.mjs +86 -0
  184. package/package.json +78 -4
  185. package/principles/INDEX.md +11 -0
  186. package/site-dist/404.html +27 -0
  187. package/site-dist/assets/app.Df99UgrJ.js +1 -0
  188. package/site-dist/assets/changelog.md.Df8vFhjK.js +1 -0
  189. package/site-dist/assets/changelog.md.Df8vFhjK.lean.js +1 -0
  190. package/site-dist/assets/chunks/@localSearchIndexroot.n-0kN-N0.js +1 -0
  191. package/site-dist/assets/chunks/VPLocalSearchBox.IEhP6Gw5.js +9 -0
  192. package/site-dist/assets/chunks/framework.BetZR81g.js +20 -0
  193. package/site-dist/assets/chunks/theme.DHubfO7g.js +2 -0
  194. package/site-dist/assets/guide_dsh.md.0X-eYB87.js +5 -0
  195. package/site-dist/assets/guide_dsh.md.0X-eYB87.lean.js +5 -0
  196. package/site-dist/assets/guide_getting-started.md.BZTWiHhH.js +1 -0
  197. package/site-dist/assets/guide_getting-started.md.BZTWiHhH.lean.js +1 -0
  198. package/site-dist/assets/guide_how-it-works.md.CkvlSgxO.js +25 -0
  199. package/site-dist/assets/guide_how-it-works.md.CkvlSgxO.lean.js +1 -0
  200. package/site-dist/assets/guide_index.md.D67QX_Vi.js +1 -0
  201. package/site-dist/assets/guide_index.md.D67QX_Vi.lean.js +1 -0
  202. package/site-dist/assets/guide_install.md.D7NiiOPu.js +19 -0
  203. package/site-dist/assets/guide_install.md.D7NiiOPu.lean.js +19 -0
  204. package/site-dist/assets/guide_intranet.md.Bz0sAHK0.js +9 -0
  205. package/site-dist/assets/guide_intranet.md.Bz0sAHK0.lean.js +9 -0
  206. package/site-dist/assets/guide_maintainer.md.C-Vt-DdK.js +1 -0
  207. package/site-dist/assets/guide_maintainer.md.C-Vt-DdK.lean.js +1 -0
  208. package/site-dist/assets/guide_phases.md.Cw0A9Vb1.js +1 -0
  209. package/site-dist/assets/guide_phases.md.Cw0A9Vb1.lean.js +1 -0
  210. package/site-dist/assets/guide_project.md.BIcaDhdS.js +77 -0
  211. package/site-dist/assets/guide_project.md.BIcaDhdS.lean.js +77 -0
  212. package/site-dist/assets/guide_user.md.B66TQvIA.js +1 -0
  213. package/site-dist/assets/guide_user.md.B66TQvIA.lean.js +1 -0
  214. package/site-dist/assets/index.md.CrBM3tiI.js +1 -0
  215. package/site-dist/assets/index.md.CrBM3tiI.lean.js +1 -0
  216. package/site-dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
  217. package/site-dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
  218. package/site-dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
  219. package/site-dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
  220. package/site-dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
  221. package/site-dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
  222. package/site-dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
  223. package/site-dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
  224. package/site-dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
  225. package/site-dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
  226. package/site-dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
  227. package/site-dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
  228. package/site-dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
  229. package/site-dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
  230. package/site-dist/assets/reference_adr_0001-new-repo-core-and-adapters.md.CjNHHmrf.js +1 -0
  231. package/site-dist/assets/reference_adr_0001-new-repo-core-and-adapters.md.CjNHHmrf.lean.js +1 -0
  232. package/site-dist/assets/reference_adr_0002-two-orchestration-modes.md.CHD05agO.js +1 -0
  233. package/site-dist/assets/reference_adr_0002-two-orchestration-modes.md.CHD05agO.lean.js +1 -0
  234. package/site-dist/assets/reference_adr_0003-generate-once-then-lock.md.BaRiZfXT.js +1 -0
  235. package/site-dist/assets/reference_adr_0003-generate-once-then-lock.md.BaRiZfXT.lean.js +1 -0
  236. package/site-dist/assets/reference_adr_0004-external-contracts-stay-stable.md.DUJ7CTV1.js +1 -0
  237. package/site-dist/assets/reference_adr_0004-external-contracts-stay-stable.md.DUJ7CTV1.lean.js +1 -0
  238. package/site-dist/assets/reference_adr_0005-skill-names.md.DuBVd1tl.js +1 -0
  239. package/site-dist/assets/reference_adr_0005-skill-names.md.DuBVd1tl.lean.js +1 -0
  240. package/site-dist/assets/reference_adr_0006-deterministic-engine-platform-capabilities.md.Dcrnx1-L.js +1 -0
  241. package/site-dist/assets/reference_adr_0006-deterministic-engine-platform-capabilities.md.Dcrnx1-L.lean.js +1 -0
  242. package/site-dist/assets/reference_adr_0007-one-install-many-repos.md.C78cd4_P.js +1 -0
  243. package/site-dist/assets/reference_adr_0007-one-install-many-repos.md.C78cd4_P.lean.js +1 -0
  244. package/site-dist/assets/reference_adr_0008-capability-sources-and-platform-plugin.md.B4vBkIDS.js +1 -0
  245. package/site-dist/assets/reference_adr_0008-capability-sources-and-platform-plugin.md.B4vBkIDS.lean.js +1 -0
  246. package/site-dist/assets/reference_adr_index.md.Dx8sPsjs.js +1 -0
  247. package/site-dist/assets/reference_adr_index.md.Dx8sPsjs.lean.js +1 -0
  248. package/site-dist/assets/reference_commands.md.BFJRjNju.js +1 -0
  249. package/site-dist/assets/reference_commands.md.BFJRjNju.lean.js +1 -0
  250. package/site-dist/assets/reference_config.md.Dt_TJ2y9.js +6 -0
  251. package/site-dist/assets/reference_config.md.Dt_TJ2y9.lean.js +1 -0
  252. package/site-dist/assets/reference_contracts_agent-runtime.md.Bu8q-uGl.js +1 -0
  253. package/site-dist/assets/reference_contracts_agent-runtime.md.Bu8q-uGl.lean.js +1 -0
  254. package/site-dist/assets/reference_contracts_cli-json.md.Bonk0m6-.js +1 -0
  255. package/site-dist/assets/reference_contracts_cli-json.md.Bonk0m6-.lean.js +1 -0
  256. package/site-dist/assets/reference_contracts_feature-files.md.9n332kF_.js +26 -0
  257. package/site-dist/assets/reference_contracts_feature-files.md.9n332kF_.lean.js +26 -0
  258. package/site-dist/assets/reference_contracts_index.md.dqNwNs6U.js +1 -0
  259. package/site-dist/assets/reference_contracts_index.md.dqNwNs6U.lean.js +1 -0
  260. package/site-dist/assets/reference_contracts_notifier-event.md.D6we9wWS.js +24 -0
  261. package/site-dist/assets/reference_contracts_notifier-event.md.D6we9wWS.lean.js +24 -0
  262. package/site-dist/assets/reference_contracts_result-file.md.BmCaSlEu.js +1 -0
  263. package/site-dist/assets/reference_contracts_result-file.md.BmCaSlEu.lean.js +1 -0
  264. package/site-dist/assets/reference_contracts_spec.md.CDQYgJz7.js +8 -0
  265. package/site-dist/assets/reference_contracts_spec.md.CDQYgJz7.lean.js +8 -0
  266. package/site-dist/assets/reference_contracts_state.md.DVHC4opX.js +1 -0
  267. package/site-dist/assets/reference_contracts_state.md.DVHC4opX.lean.js +1 -0
  268. package/site-dist/assets/reference_contracts_usage-record.md.CQI2chqh.js +10 -0
  269. package/site-dist/assets/reference_contracts_usage-record.md.CQI2chqh.lean.js +10 -0
  270. package/site-dist/assets/reference_contracts_verify.md.CkJy8LXk.js +29 -0
  271. package/site-dist/assets/reference_contracts_verify.md.CkJy8LXk.lean.js +29 -0
  272. package/site-dist/assets/reference_design_adapter-guide.md.BSziZJSM.js +16 -0
  273. package/site-dist/assets/reference_design_adapter-guide.md.BSziZJSM.lean.js +16 -0
  274. package/site-dist/assets/reference_design_architecture.md.Bfoc-F2B.js +23 -0
  275. package/site-dist/assets/reference_design_architecture.md.Bfoc-F2B.lean.js +23 -0
  276. package/site-dist/assets/reference_design_builtin-capabilities.md.CZYtjo_v.js +7 -0
  277. package/site-dist/assets/reference_design_builtin-capabilities.md.CZYtjo_v.lean.js +7 -0
  278. package/site-dist/assets/reference_design_platform-vocabulary.md.xWGv5QO8.js +3 -0
  279. package/site-dist/assets/reference_design_platform-vocabulary.md.xWGv5QO8.lean.js +3 -0
  280. package/site-dist/assets/reference_scope.md.aUo6vISB.js +1 -0
  281. package/site-dist/assets/reference_scope.md.aUo6vISB.lean.js +1 -0
  282. package/site-dist/assets/style.BX2ZxxqY.css +1 -0
  283. package/site-dist/changelog.html +30 -0
  284. package/site-dist/favicon.svg +10 -0
  285. package/site-dist/guide/dsh.html +34 -0
  286. package/site-dist/guide/getting-started.html +30 -0
  287. package/site-dist/guide/how-it-works.html +54 -0
  288. package/site-dist/guide/index.html +30 -0
  289. package/site-dist/guide/install.html +48 -0
  290. package/site-dist/guide/intranet.html +38 -0
  291. package/site-dist/guide/maintainer.html +30 -0
  292. package/site-dist/guide/phases.html +30 -0
  293. package/site-dist/guide/project.html +106 -0
  294. package/site-dist/guide/user.html +30 -0
  295. package/site-dist/hashmap.json +1 -0
  296. package/site-dist/index.html +30 -0
  297. package/site-dist/logo-light.svg +6 -0
  298. package/site-dist/logo.svg +6 -0
  299. package/site-dist/reference/adr/0001-new-repo-core-and-adapters.html +30 -0
  300. package/site-dist/reference/adr/0002-two-orchestration-modes.html +30 -0
  301. package/site-dist/reference/adr/0003-generate-once-then-lock.html +30 -0
  302. package/site-dist/reference/adr/0004-external-contracts-stay-stable.html +30 -0
  303. package/site-dist/reference/adr/0005-skill-names.html +30 -0
  304. package/site-dist/reference/adr/0006-deterministic-engine-platform-capabilities.html +30 -0
  305. package/site-dist/reference/adr/0007-one-install-many-repos.html +30 -0
  306. package/site-dist/reference/adr/0008-capability-sources-and-platform-plugin.html +30 -0
  307. package/site-dist/reference/adr/index.html +30 -0
  308. package/site-dist/reference/commands.html +30 -0
  309. package/site-dist/reference/config.html +35 -0
  310. package/site-dist/reference/contracts/agent-runtime.html +30 -0
  311. package/site-dist/reference/contracts/cli-json.html +30 -0
  312. package/site-dist/reference/contracts/feature-files.html +55 -0
  313. package/site-dist/reference/contracts/index.html +30 -0
  314. package/site-dist/reference/contracts/notifier-event.html +53 -0
  315. package/site-dist/reference/contracts/result-file.html +30 -0
  316. package/site-dist/reference/contracts/spec.html +37 -0
  317. package/site-dist/reference/contracts/state.html +30 -0
  318. package/site-dist/reference/contracts/usage-record.html +39 -0
  319. package/site-dist/reference/contracts/verify.html +58 -0
  320. package/site-dist/reference/design/adapter-guide.html +45 -0
  321. package/site-dist/reference/design/architecture.html +52 -0
  322. package/site-dist/reference/design/builtin-capabilities.html +36 -0
  323. package/site-dist/reference/design/platform-vocabulary.html +32 -0
  324. package/site-dist/reference/scope.html +30 -0
  325. package/site-dist/vp-icons.css +1 -0
  326. package/skills/acceptance-criteria/SKILL.md +61 -0
  327. package/skills/laoshi/SKILL.md +108 -0
  328. package/skills/laoshi/playbooks/accept.md +65 -0
  329. package/skills/laoshi/playbooks/change.md +51 -0
  330. package/skills/laoshi/playbooks/incident.md +55 -0
  331. package/skills/laoshi/playbooks/new.md +96 -0
  332. package/skills/laoshi/playbooks/small.md +48 -0
  333. package/skills/laoshi/playbooks/status.md +41 -0
  334. package/skills/laoshi/playbooks/takeover.md +51 -0
  335. package/skills/laoshi/playbooks/unattended.md +101 -0
  336. package/skills/laoshi/playbooks/verify.md +57 -0
  337. package/skills/laoshi-doctor/SKILL.md +36 -0
  338. package/skills/laoshi-retro/SKILL.md +81 -0
  339. package/skills/laoshi-setup/SKILL.md +107 -0
  340. package/skills/laoshi-setup/templates/copy-local-files.mjs +32 -0
  341. package/skills/principle-delete-before-add/SKILL.md +33 -0
  342. package/skills/principle-dont-block-on-humans/SKILL.md +35 -0
  343. package/skills/principle-fix-root-cause/SKILL.md +33 -0
  344. package/skills/principle-prove-it-works/SKILL.md +33 -0
  345. package/skills/principle-report-honestly/SKILL.md +33 -0
  346. package/skills/principle-speak-to-reader/SKILL.md +33 -0
  347. package/skills/principle-this-requirement-only/SKILL.md +33 -0
  348. package/skills/requirement-interview/SKILL.md +97 -0
  349. package/skills/result-report/SKILL.md +34 -0
  350. package/skills/spec-writing/SKILL.md +58 -0
  351. package/skills/spec-writing/spec-template.md +109 -0
@@ -0,0 +1,507 @@
1
+ import type { PaseoAgentHandle, PaseoClient } from "@getpaseo/client";
2
+ import { runningToolOf, toolCallsOf, summarizeActivity } from "../../engine/src/activity.js";
3
+ import { type AgentProfile, isResolved, type PipelineConfig } from "../../engine/src/config.js";
4
+ import { profilesFromDaemonConfig } from "./paseo-profiles.js";
5
+ import { cronAt, localTimeZone } from "../../engine/src/schedule-time.js";
6
+ import { samePath } from "../../engine/src/paths.js";
7
+ import type { AgentRuntime, ManagedService, ProviderQuota, RuntimeFactory, ServiceTarget, StepAgent, WaitOutcome } from "../../engine/src/runtime.js";
8
+ import { daemonOf } from "./settings.js";
9
+
10
+ // Checked against @getpaseo/client 0.11.2 (packages/client/src/index.ts) and the
11
+ // daemon (packages/server/src/server/session.ts, agent/create-agent/intent.ts):
12
+ // - agents.create({ config: { provider: "provider/model", modeId }, cwd, title, labels, prompt, parent })
13
+ // With `parent`, the daemon places the agent in the parent's workspace AND uses the
14
+ // parent's cwd; the requested cwd is ignored. The pipeline therefore requires the chat's
15
+ // cwd to be the repository (verifyOrigin), and verifies every created agent's cwd.
16
+ // SDK-created subagents do not post finish notifications to the parent.
17
+ // - handle.waitForFinish(timeoutMs) -> { status: idle|error|permission|timeout, final, error, lastMessage }
18
+ // The daemon answers immediately when the agent is already idle or has a pending permission.
19
+ // - handle.send(text, { activeTurnBehavior }) -> the daemon interrupts a running turn
20
+ // unless activeTurnBehavior is "steer".
21
+ // - config.get() -> { config: { agentProfiles?: AgentProfile[], mcp, browserTools, ... } }
22
+ // - providers.listUsage() -> { providers: [{ providerId, displayName, windows: [{ label, usedPct, resetsAt, tone }] }] }
23
+ // - agent.timeline.refetch({ direction: "tail", limit }) -> { entries: [{ timestamp, item }] }
24
+ // - Workspace scripts (paseo.json) are not on the public client in 0.11; they are reached
25
+ // through the exported internal DaemonClient (listWorkspaceScripts, startWorkspaceScriptWithStatus,
26
+ // stopWorkspaceScript). See WorkspaceScripts below; every use degrades to "not available".
27
+
28
+ export type SdkClient = Pick<PaseoClient, "agents" | "close"> &
29
+ Partial<Pick<PaseoClient, "config" | "providers" | "terminals" | "workspaces">>;
30
+
31
+ /** paseo.json scripts as the daemon reports them (protocol WorkspaceScriptPayloadSchema). */
32
+ export interface ScriptInfo {
33
+ scriptName: string;
34
+ type?: "script" | "service";
35
+ port: number | null;
36
+ proxyUrl?: string | null;
37
+ localProxyUrl?: string | null;
38
+ lifecycle: "running" | "stopped";
39
+ health: "healthy" | "unhealthy" | null;
40
+ exitCode?: number | null;
41
+ terminalId?: string | null;
42
+ }
43
+
44
+ export interface WorkspaceScripts {
45
+ list(workspaceId: string): Promise<ScriptInfo[]>;
46
+ start(workspaceId: string, name: string): Promise<void>;
47
+ stop(workspaceId: string, name: string): Promise<void>;
48
+ /** paseo.json setup of a new worktree; null when the daemon does not report one. */
49
+ setupStatus(workspaceId: string): Promise<{ status: "running" | "completed" | "failed" | "blocked"; error: string | null } | null>;
50
+ /** Paseo schedules (daemon-client scheduleCreate / scheduleDelete). Returns the schedule ID. */
51
+ createSchedule(options: Record<string, unknown>): Promise<string>;
52
+ deleteSchedule(id: string): Promise<void>;
53
+ close(): Promise<void>;
54
+ }
55
+
56
+ export { samePath };
57
+
58
+ function agentConfig(profile: AgentProfile) {
59
+ if (!isResolved(profile)) {
60
+ throw new Error(`agent 配置没有 provider${profile.platformProfile ? `(Paseo profile「${profile.platformProfile}」没有解析)` : ""}`);
61
+ }
62
+ return {
63
+ provider: profile.provider,
64
+ ...(profile.modeId ? { modeId: profile.modeId } : {}),
65
+ ...(profile.thinkingOptionId ? { thinkingOptionId: profile.thinkingOptionId } : {}),
66
+ ...(profile.featureValues ? { featureValues: profile.featureValues } : {}),
67
+ ...(profile.options ? { options: profile.options as Record<string, never> } : {}),
68
+ };
69
+ }
70
+
71
+ function wrap(handle: PaseoAgentHandle): StepAgent {
72
+ return {
73
+ id: handle.id,
74
+ async wait(timeoutMs: number): Promise<WaitOutcome> {
75
+ const result = await handle.waitForFinish(timeoutMs);
76
+ const pending = result.final?.pendingPermissions ?? [];
77
+ return {
78
+ status: result.status,
79
+ error: result.error,
80
+ lastMessage: result.lastMessage,
81
+ pendingPermissions: pending.map((p) => ({
82
+ id: p.id,
83
+ title: p.title ?? p.description ?? p.name,
84
+ })),
85
+ usage: result.final?.lastUsage ?? null,
86
+ };
87
+ },
88
+ async followUp(text: string): Promise<void> {
89
+ await handle.send(text);
90
+ },
91
+ async archive(): Promise<void> {
92
+ await handle.archive();
93
+ },
94
+ };
95
+ }
96
+
97
+ async function agentCwd(handle: PaseoAgentHandle): Promise<string | null> {
98
+ const fetched = await handle.refresh();
99
+ return fetched?.agent.cwd ?? null;
100
+ }
101
+
102
+ const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
103
+
104
+ export function createRuntimeWithClient(
105
+ client: SdkClient,
106
+ config: PipelineConfig,
107
+ log: (message: string) => void,
108
+ scriptsFactory: (() => Promise<WorkspaceScripts | null>) | null = null,
109
+ ): AgentRuntime {
110
+ let scripts: Promise<WorkspaceScripts | null> | null = null;
111
+ const getScripts = () => {
112
+ scripts ??= (scriptsFactory ? scriptsFactory() : Promise.resolve(null)).catch((error: Error) => {
113
+ log(`无法使用 Paseo 的工作区脚本:${error.message}`);
114
+ return null;
115
+ });
116
+ return scripts;
117
+ };
118
+ const workspaceOf = async (target: ServiceTarget): Promise<string | null> => {
119
+ if ("workspaceId" in target) return target.workspaceId;
120
+ const fetched = await client.agents.ref(target.agentId).refresh().catch(() => null);
121
+ return fetched?.agent.workspaceId ?? null;
122
+ };
123
+ const tail = async (terminalId: string | null | undefined): Promise<string | null> => {
124
+ if (!terminalId || !client.terminals) return null;
125
+ try {
126
+ const captured = await client.terminals.ref(terminalId).capture({ stripAnsi: true });
127
+ return captured.lines.slice(-60).join("\n").trim() || null;
128
+ } catch {
129
+ return null;
130
+ }
131
+ };
132
+ const toService = async (info: ScriptInfo): Promise<ManagedService> => ({
133
+ name: info.scriptName,
134
+ url: info.proxyUrl ?? info.localProxyUrl ?? (info.port ? `http://127.0.0.1:${info.port}` : null),
135
+ port: info.port,
136
+ running: info.lifecycle === "running",
137
+ health: info.health ?? null,
138
+ exitCode: info.exitCode ?? null,
139
+ output: await tail(info.terminalId),
140
+ });
141
+
142
+ return {
143
+ async verifyOrigin(agentId, cwd) {
144
+ let originCwd: string | null;
145
+ try {
146
+ originCwd = await agentCwd(client.agents.ref(agentId));
147
+ } catch (error) {
148
+ throw new Error(`无法读取发起对话的 agent ${agentId}:${(error as Error).message}`);
149
+ }
150
+ if (originCwd === null) {
151
+ throw new Error(`找不到发起对话的 agent ${agentId}(可能已被归档)。请在需求所在项目的对话中重新启动。`);
152
+ }
153
+ if (!samePath(originCwd, cwd)) {
154
+ throw new Error(
155
+ `发起对话的工作目录是 ${originCwd},与仓库目录 ${cwd} 不一致。` +
156
+ "步骤 agent 会挂在发起的对话下、使用对话的工作目录,所以流水线必须在该仓库对应的项目对话中启动。",
157
+ );
158
+ }
159
+ },
160
+ async startAgent(input) {
161
+ const base = {
162
+ config: agentConfig(input.profile ?? config.agents[input.role]),
163
+ cwd: input.cwd,
164
+ title: input.title,
165
+ labels: input.labels,
166
+ prompt: input.prompt,
167
+ };
168
+ let handle: PaseoAgentHandle;
169
+ if (input.workspaceId) {
170
+ // The requirement's own worktree: placed there, still a subagent of the chat.
171
+ if (!client.workspaces) throw new Error("这个 Paseo 版本不支持把 agent 放进指定的工作区");
172
+ const { cwd: _cwd, ...placed } = base;
173
+ handle = await client.workspaces.ref(input.workspaceId).agents.create({
174
+ ...placed,
175
+ ...(input.parentAgentId ? { parent: input.parentAgentId } : {}),
176
+ });
177
+ } else {
178
+ handle = input.parentAgentId
179
+ ? await client.agents.create({ ...base, parent: input.parentAgentId })
180
+ : await client.agents.create(base);
181
+ }
182
+
183
+ // Guard against the daemon placing the agent anywhere but the repository.
184
+ const actual = await agentCwd(handle).catch(() => null);
185
+ if (actual !== null && !samePath(actual, input.cwd)) {
186
+ await handle.archive().catch(() => undefined);
187
+ throw new Error(`新建的 agent 工作目录是 ${actual},不是仓库目录 ${input.cwd},已停止该 agent`);
188
+ }
189
+ return wrap(handle);
190
+ },
191
+ async startSessionAgent(input) {
192
+ const handle = await client.agents.create({ config: agentConfig(input.profile), cwd: input.cwd, title: input.title, labels: input.labels, prompt: input.prompt });
193
+ const actual = await agentCwd(handle).catch(() => null);
194
+ if (actual !== null && !samePath(actual, input.cwd)) {
195
+ await handle.archive().catch(() => undefined);
196
+ throw new Error(`新建的需求会话工作目录是 ${actual},不是仓库目录 ${input.cwd},已停止它`);
197
+ }
198
+ return handle.id;
199
+ },
200
+ async notifyAgent(agentId, text) {
201
+ await client.agents.ref(agentId).send(text, { activeTurnBehavior: "steer" });
202
+ },
203
+ attachAgent(agentId) {
204
+ return wrap(client.agents.ref(agentId));
205
+ },
206
+ async interruptAgent(agentId, text) {
207
+ await client.agents.ref(agentId).send(text, { activeTurnBehavior: "interrupt" });
208
+ },
209
+ async listProfiles() {
210
+ if (!client.config) return null;
211
+ try {
212
+ return profilesFromDaemonConfig((await client.config.get()).config);
213
+ } catch (error) {
214
+ log(`无法读取 Paseo 的 agent profiles:${(error as Error).message}`);
215
+ return null;
216
+ }
217
+ },
218
+ async listServices(target) {
219
+ const api = await getScripts();
220
+ const workspaceId = api ? await workspaceOf(target) : null;
221
+ if (!api || !workspaceId) return null;
222
+ try {
223
+ const services = (await api.list(workspaceId)).filter((s) => (s.type ?? "service") === "service").map((s) => s.scriptName);
224
+ return services.length ? services : null;
225
+ } catch (error) {
226
+ log(`无法列出工作区脚本:${(error as Error).message}`);
227
+ return null;
228
+ }
229
+ },
230
+ async startServices(target, names, readyTimeoutMs) {
231
+ const api = await getScripts();
232
+ const workspaceId = await workspaceOf(target);
233
+ if (!api || !workspaceId) throw new Error("无法使用 Paseo 的工作区脚本");
234
+ const current = await api.list(workspaceId);
235
+ for (const name of names) {
236
+ // Stop first so the service runs the code as it is now.
237
+ if (current.find((s) => s.scriptName === name)?.lifecycle === "running") await api.stop(workspaceId, name);
238
+ await api.start(workspaceId, name);
239
+ }
240
+ const deadline = Date.now() + readyTimeoutMs;
241
+ let latest = await api.list(workspaceId);
242
+ for (;;) {
243
+ const wanted = latest.filter((s) => names.includes(s.scriptName));
244
+ const settled = wanted.every((s) => s.lifecycle === "stopped" || s.health === "healthy");
245
+ if (settled || Date.now() >= deadline) break;
246
+ await sleep(2000);
247
+ latest = await api.list(workspaceId);
248
+ }
249
+ return Promise.all(latest.filter((s) => names.includes(s.scriptName)).map(toService));
250
+ },
251
+ async stopServices(target, names) {
252
+ const api = await getScripts();
253
+ const workspaceId = await workspaceOf(target);
254
+ if (!api || !workspaceId) return;
255
+ const current = await api.list(workspaceId).catch(() => []);
256
+ for (const name of names) {
257
+ if (current.find((s) => s.scriptName === name)?.lifecycle !== "running") continue;
258
+ await api.stop(workspaceId, name).catch((error: Error) => log(`停止服务 ${name} 失败:${error.message}`));
259
+ }
260
+ },
261
+ async providerQuota(providers) {
262
+ if (!client.providers) return null;
263
+ try {
264
+ const usage = await client.providers.listUsage();
265
+ const quotas: ProviderQuota[] = [];
266
+ for (const p of usage.providers) {
267
+ if (!providers.includes(p.providerId) || p.status !== "available") continue;
268
+ for (const w of p.windows) {
269
+ quotas.push({
270
+ provider: p.providerId,
271
+ displayName: p.displayName,
272
+ window: w.label,
273
+ usedPct: w.usedPct ?? (typeof w.remainingPct === "number" ? 100 - w.remainingPct : null),
274
+ resetsAt: w.resetsAt ?? null,
275
+ tone: w.tone ?? null,
276
+ });
277
+ }
278
+ }
279
+ return quotas.length ? quotas : null;
280
+ } catch {
281
+ return null;
282
+ }
283
+ },
284
+ async recentActivity(agentId, limit) {
285
+ try {
286
+ const page = await client.agents.ref(agentId).timeline.refetch({ direction: "tail", limit: Math.max(limit * 4, 20) });
287
+ return summarizeActivity(page.entries, limit);
288
+ } catch {
289
+ return null;
290
+ }
291
+ },
292
+ async runningTool(agentId) {
293
+ try {
294
+ const page = await client.agents.ref(agentId).timeline.refetch({ direction: "tail", limit: 40 });
295
+ return runningToolOf(page.entries);
296
+ } catch {
297
+ return null;
298
+ }
299
+ },
300
+ async toolCalls(agentId) {
301
+ try {
302
+ const page = await client.agents.ref(agentId).timeline.refetch({ direction: "tail", limit: 200 });
303
+ return toolCallsOf(page.entries);
304
+ } catch {
305
+ return null;
306
+ }
307
+ },
308
+ async createWorktree(request) {
309
+ if (!client.workspaces) throw new Error("这个 Paseo 版本不支持新建工作区");
310
+ const workspace = await client.workspaces.create({
311
+ source: { kind: "worktree", cwd: request.sourceRepo, action: "branch-off", refName: request.baseRef, branchName: request.branchName },
312
+ title: request.title,
313
+ ...(request.callerAgentId ? { callerAgentId: request.callerAgentId } : {}),
314
+ });
315
+ const directory = workspace.directory ?? (await workspace.refresh())?.workspaceDirectory ?? null;
316
+ if (!directory) throw new Error("Paseo 没有返回新工作区的目录");
317
+ return { workspaceId: workspace.id, directory };
318
+ },
319
+ async openWorkspace(directory) {
320
+ if (!client.workspaces) throw new Error("这个 Paseo 版本不支持接手已有的工作区目录");
321
+ const handle = await client.workspaces.open({ cwd: directory });
322
+ return { workspaceId: handle.id };
323
+ },
324
+ async waitForWorkspaceSetup(workspaceId, timeoutMs) {
325
+ const api = await getScripts();
326
+ if (!api) return { status: "none", error: null };
327
+ const deadline = Date.now() + timeoutMs;
328
+ for (;;) {
329
+ const snapshot = await api.setupStatus(workspaceId).catch(() => null);
330
+ if (!snapshot) return { status: "none", error: null };
331
+ if (snapshot.status === "completed") return { status: "completed", error: null };
332
+ if (snapshot.status === "failed" || snapshot.status === "blocked") return { status: "failed", error: snapshot.error ?? snapshot.status };
333
+ if (Date.now() >= deadline) return { status: "timeout", error: null };
334
+ await sleep(3000);
335
+ }
336
+ },
337
+ async scheduleMessage(input) {
338
+ const api = await getScripts();
339
+ if (!api) return null;
340
+ const oneShot = input.at !== undefined;
341
+ return api.createSchedule({
342
+ name: input.name,
343
+ prompt: input.prompt,
344
+ cadence: { type: "cron", expression: oneShot ? cronAt(input.at as Date) : (input.cron as string), timezone: localTimeZone() },
345
+ target: { type: "agent", agentId: input.agentId },
346
+ ...(oneShot ? { maxRuns: 1, expiresAt: new Date((input.at as Date).getTime() + 6 * 3600_000).toISOString() } : {}),
347
+ ...(input.expiresAt ? { expiresAt: input.expiresAt.toISOString() } : {}),
348
+ });
349
+ },
350
+ async scheduleNewAgent(input) {
351
+ const api = await getScripts();
352
+ if (!api) return null;
353
+ const settings = agentConfig(input.profile);
354
+ const slash = settings.provider.indexOf("/");
355
+ return api.createSchedule({
356
+ name: input.name,
357
+ prompt: input.prompt,
358
+ cadence: { type: "cron", expression: input.cron, timezone: localTimeZone() },
359
+ target: {
360
+ type: "new-agent",
361
+ config: {
362
+ provider: settings.provider.slice(0, slash),
363
+ model: settings.provider.slice(slash + 1),
364
+ cwd: input.cwd,
365
+ ...(settings.modeId ? { modeId: settings.modeId } : {}),
366
+ ...(settings.thinkingOptionId ? { thinkingOptionId: settings.thinkingOptionId } : {}),
367
+ archiveOnFinish: true,
368
+ title: input.name,
369
+ },
370
+ },
371
+ });
372
+ },
373
+ async cancelSchedule(id) {
374
+ const api = await getScripts();
375
+ if (api) await api.deleteSchedule(id);
376
+ },
377
+ async providerStatus() {
378
+ if (!client.providers) return null;
379
+ try {
380
+ const snapshot = await client.providers.waitForReady({ timeoutMs: 15_000 });
381
+ return snapshot.entries.map((e) => ({ provider: e.provider, status: e.status }));
382
+ } catch {
383
+ return null;
384
+ }
385
+ },
386
+ async capabilities() {
387
+ if (!client.config) return null;
388
+ try {
389
+ const daemonConfig = (await client.config.get()).config as { mcp?: { injectIntoAgents?: boolean }; browserTools?: { enabled?: boolean } };
390
+ const platformTools = daemonConfig.mcp?.injectIntoAgents === true;
391
+ return { platformTools, browser: platformTools && daemonConfig.browserTools?.enabled === true };
392
+ } catch {
393
+ return null;
394
+ }
395
+ },
396
+ async close() {
397
+ if (scripts) await (await scripts)?.close().catch(() => undefined);
398
+ await client.close();
399
+ },
400
+ };
401
+ }
402
+
403
+ export const createRuntime: RuntimeFactory = async ({ config, log }) => {
404
+ // Loaded lazily so the runtime logic can be tested without the SDK installed.
405
+ const { createPaseoClient } = await import("@getpaseo/client");
406
+ const settings = daemonOf(config);
407
+ const password = process.env[settings.daemonPasswordEnv];
408
+ const client = createPaseoClient({
409
+ url: settings.daemonUrl,
410
+ ...(password ? { password } : {}),
411
+ reconnect: { enabled: true },
412
+ });
413
+ await connectWithin(client, CONNECT_TIMEOUT_MS, settings.daemonUrl);
414
+ return createRuntimeWithClient(client, config, log, () => connectScripts(config));
415
+ };
416
+
417
+ /** How long to wait for the daemon before giving up (1.12.1). */
418
+ const CONNECT_TIMEOUT_MS = 30_000;
419
+
420
+ /**
421
+ * Connects, or gives up after `ms` and closes the client: with reconnect on, connect() can wait
422
+ * for a daemon that is not running for ever, and a client left behind keeps retrying in the
423
+ * background (a long-running process such as req factory would collect them).
424
+ */
425
+ export async function connectWithin(client: { connect(): Promise<unknown>; close(): Promise<unknown> }, ms: number, url: string): Promise<void> {
426
+ let timer: NodeJS.Timeout | undefined;
427
+ try {
428
+ await Promise.race([
429
+ client.connect(),
430
+ new Promise<never>((_, reject) => {
431
+ timer = setTimeout(() => reject(new Error(`${ms / 1000} 秒内没有连上 Paseo(${url})。确认 Paseo 正在运行`)), ms);
432
+ }),
433
+ ]);
434
+ } catch (error) {
435
+ await client.close().catch(() => undefined);
436
+ throw error;
437
+ } finally {
438
+ clearTimeout(timer);
439
+ }
440
+ }
441
+
442
+ /** Workspace scripts through the internal DaemonClient that @getpaseo/client 0.11 exports. */
443
+ async function connectScripts(config: PipelineConfig): Promise<WorkspaceScripts | null> {
444
+ const internal = (await import("@getpaseo/client/internal/daemon-client").catch(() => null)) as
445
+ | { DaemonClient?: new (options: Record<string, unknown>) => InternalDaemonClient }
446
+ | null;
447
+ if (!internal?.DaemonClient) return null;
448
+ const settings = daemonOf(config);
449
+ const password = process.env[settings.daemonPasswordEnv];
450
+ const daemon = new internal.DaemonClient({
451
+ url: settings.daemonUrl,
452
+ clientId: `req-kit-${process.pid}-${Date.now().toString(36)}`,
453
+ clientType: "cli",
454
+ ...(password ? { password } : {}),
455
+ reconnect: { enabled: true },
456
+ });
457
+ if (typeof daemon.listWorkspaceScripts !== "function") return null;
458
+ await connectWithin(daemon as unknown as { connect(): Promise<unknown>; close(): Promise<unknown> }, CONNECT_TIMEOUT_MS, settings.daemonUrl);
459
+ const check = (payload: { error: string | null }) => {
460
+ if (payload.error) throw new Error(payload.error);
461
+ };
462
+ return {
463
+ async list(workspaceId) {
464
+ const payload = await daemon.listWorkspaceScripts(workspaceId);
465
+ check(payload);
466
+ return (payload.scripts ?? []) as ScriptInfo[];
467
+ },
468
+ async start(workspaceId, name) {
469
+ check(await daemon.startWorkspaceScriptWithStatus(workspaceId, name));
470
+ },
471
+ async stop(workspaceId, name) {
472
+ check(await daemon.stopWorkspaceScript(workspaceId, name));
473
+ },
474
+ async createSchedule(options) {
475
+ if (typeof daemon.scheduleCreate !== "function") throw new Error("这个 Paseo 版本不支持定时任务");
476
+ const payload = await daemon.scheduleCreate(options);
477
+ if (payload.error || !payload.schedule) throw new Error(payload.error ?? "Paseo 没有返回定时任务");
478
+ return payload.schedule.id;
479
+ },
480
+ async deleteSchedule(id) {
481
+ if (typeof daemon.scheduleDelete !== "function") return;
482
+ const payload = await daemon.scheduleDelete({ id });
483
+ if (payload.error && !/not found/i.test(payload.error)) throw new Error(payload.error);
484
+ },
485
+ async setupStatus(workspaceId) {
486
+ if (typeof daemon.fetchWorkspaceSetupStatus !== "function") return null;
487
+ const payload = await daemon.fetchWorkspaceSetupStatus(workspaceId);
488
+ return payload.snapshot ? { status: payload.snapshot.status, error: payload.snapshot.error } : null;
489
+ },
490
+ async close() {
491
+ await daemon.close();
492
+ },
493
+ };
494
+ }
495
+
496
+ interface InternalDaemonClient {
497
+ connect(): Promise<void>;
498
+ close(): Promise<void>;
499
+ listWorkspaceScripts(workspaceId: string): Promise<{ scripts?: unknown[]; error: string | null }>;
500
+ startWorkspaceScriptWithStatus(workspaceId: string, name: string): Promise<{ error: string | null }>;
501
+ stopWorkspaceScript(workspaceId: string, name: string): Promise<{ error: string | null }>;
502
+ scheduleCreate?(options: Record<string, unknown>): Promise<{ schedule: { id: string } | null; error: string | null }>;
503
+ scheduleDelete?(options: { id: string }): Promise<{ error: string | null }>;
504
+ fetchWorkspaceSetupStatus?(
505
+ workspaceId: string,
506
+ ): Promise<{ snapshot: { status: "running" | "completed" | "failed" | "blocked"; error: string | null } | null }>;
507
+ }
@@ -0,0 +1,22 @@
1
+ // The Paseo adapter's own settings (laoshi M2c): platform.paseo in the install-level config,
2
+ // { "platform": { "adapter": "paseo", "paseo": { "daemonUrl": "ws://…", "daemonPasswordEnv": "…" } } }
3
+ // The top-level daemonUrl / daemonPasswordEnv of req-kit 1.x still work when platform.paseo does not set them.
4
+
5
+ import { DEFAULT_CONFIG } from "../../engine/src/config.js";
6
+
7
+ export interface DaemonSettings {
8
+ daemonUrl: string;
9
+ daemonPasswordEnv: string;
10
+ }
11
+
12
+ const text = (v: unknown) => (typeof v === "string" && v.trim() ? v : undefined);
13
+
14
+ /** Where the daemon is, from a loaded config or a raw config file's contents. */
15
+ export function daemonOf(config: unknown): DaemonSettings {
16
+ const c = (config ?? {}) as { daemonUrl?: unknown; daemonPasswordEnv?: unknown; platform?: { paseo?: { daemonUrl?: unknown; daemonPasswordEnv?: unknown } } };
17
+ const own = c.platform && typeof c.platform === "object" ? (c.platform.paseo ?? {}) : {};
18
+ return {
19
+ daemonUrl: text(own.daemonUrl) ?? text(c.daemonUrl) ?? DEFAULT_CONFIG.daemonUrl,
20
+ daemonPasswordEnv: text(own.daemonPasswordEnv) ?? text(c.daemonPasswordEnv) ?? DEFAULT_CONFIG.daemonPasswordEnv,
21
+ };
22
+ }
@@ -0,0 +1,26 @@
1
+ <!-- The Paseo adapter's /laoshi-setup sections (laoshi M2e): paseo.json and its helper scripts. -->
2
+ <!-- fragment: workspaceRow -->
3
+ | `paseo.json` | Paseo 的工作区设置(推荐):新建 worktree 时自动安装依赖、复制本地配置;把常驻服务定义为由 Paseo 管理的服务,每个 worktree 分到独立的端口 | Paseo;流水线在服务启动和验证前通过 Paseo 启动这些服务 |
4
+ <!-- fragment: workspaceCheck -->
5
+ - 生成了 `paseo.json` 的服务定义时,设置环境变量 `PASEO_PORT=<一个空闲端口>` 后手工跑一遍它的启动命令(`node scripts/paseo/with-port.mjs …`),确认服务确实监听这个端口,再关掉。准备命令也照样跑一遍(`copy-local-files.mjs` 需要设置 `PASEO_SOURCE_CHECKOUT_PATH`)。
6
+ <!-- fragment: workspaceWrite -->
7
+ - `paseo.json`(Paseo 读取,格式见 Paseo 文档的 Git worktrees 一节)。它会提交、整个团队共用,而团队成员的电脑可能是 macOS、Linux 或 Windows,Paseo 在各系统上用不同的 shell 执行其中的命令(macOS/Linux:bash 和 sh;Windows:准备命令用 PowerShell、脚本用 cmd.exe)。所以**命令一律写成各系统都一样的形式**:只调用程序本身(`npm`、`pnpm`、`node`、`python` 等),不用 shell 的语法——不写 `$变量`、`%变量%`、`$env:变量`,不用 `&&`、`||`、`cp`、`[ -f … ]`、`Copy-Item`。需要读环境变量或判断文件的逻辑交给下面两个脚本:
8
+ - 把 `{{REQ_KIT_ROOT}}/adapters/paseo/skill/templates/` 中的 `with-port.mjs` 和 `copy-local-files.mjs` 复制到项目的 `scripts/paseo/`(已有就比较,内容相同不动),和 `paseo.json` 一起提交。它们只依赖 Node.js(laoshi 本来就需要)。
9
+ - `worktree.setup`:写成数组,一行一条命令。通常是安装依赖(用锁文件对应的命令,例如 `npm ci`、`pnpm install --frozen-lockfile`),以及复制不提交的本地配置:`node scripts/paseo/copy-local-files.mjs .env config/local.json`(来源目录里没有的文件会跳过,不会报错)。
10
+ - `scripts`:常用的命令写成脚本(如 `test`、`lint`);常驻服务写成 `"type": "service"`,必须监听 Paseo 分配的端口,不要写死。写法:`node scripts/paseo/with-port.mjs npm run dev -- --port {PORT}`(`{PORT}` 换成 Paseo 分配的端口,同时设置环境变量 `PORT`);程序本来就读取 `PORT` 环境变量的,`node scripts/paseo/with-port.mjs npm start` 即可。服务之间互相调用的地址,让程序读取环境变量 `PASEO_SERVICE_<名称>_URL`。
11
+ - 例子:
12
+
13
+ ```json
14
+ {
15
+ "worktree": { "setup": ["npm ci", "node scripts/paseo/copy-local-files.mjs .env"] },
16
+ "scripts": {
17
+ "test": { "command": "npm test" },
18
+ "web": { "type": "service", "command": "node scripts/paseo/with-port.mjs npm run dev -- --port {PORT}" }
19
+ }
20
+ }
21
+ ```
22
+ - 团队确定只用一种系统、并且用户明确要求时,才可以用那种系统的 shell 写法;`/laoshi-doctor` 会提示它在其他系统上不能用。
23
+ - 已有 `paseo.json` 时只补充缺少的部分,不改别人写的内容。
24
+ - 在 `verify.md` 的启动服务一节注明:服务已定义在 `paseo.json`,由流水线通过 Paseo 启动;同时保留手工启动的命令,供没有 Paseo 时使用。
25
+ <!-- fragment: workspaceCommit -->
26
+ `paseo.json` 必须提交:Paseo 新建 worktree 时读取的是基准分支上已提交的版本。
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ // Written into the project by laoshi's /laoshi-setup. Copies local files that are not committed
3
+ // (for example .env) from the checkout a new Paseo worktree was created from, the same way on
4
+ // macOS, Linux and Windows. Files that do not exist there, or already exist here, are skipped.
5
+ //
6
+ // paseo.json: "worktree": { "setup": ["npm ci", "node scripts/paseo/copy-local-files.mjs .env"] }
7
+
8
+ import fs from "node:fs";
9
+ import path from "node:path";
10
+
11
+ const source = process.env.PASEO_SOURCE_CHECKOUT_PATH ?? process.env.LAOSHI_SOURCE_CHECKOUT_PATH;
12
+ const files = process.argv.slice(2);
13
+ if (!source) {
14
+ console.log("没有环境变量 PASEO_SOURCE_CHECKOUT_PATH(不是 Paseo 新建 worktree 时运行的),跳过。");
15
+ process.exit(0);
16
+ }
17
+ for (const file of files) {
18
+ const from = path.resolve(source, file);
19
+ const to = path.resolve(process.cwd(), file);
20
+ if (path.resolve(from) === path.resolve(to)) continue;
21
+ if (!fs.existsSync(from)) {
22
+ console.log(`跳过 ${file}:来源目录中没有`);
23
+ continue;
24
+ }
25
+ if (fs.existsSync(to)) {
26
+ console.log(`跳过 ${file}:这里已经有了`);
27
+ continue;
28
+ }
29
+ fs.mkdirSync(path.dirname(to), { recursive: true });
30
+ fs.cpSync(from, to, { recursive: true });
31
+ console.log(`已复制 ${file}`);
32
+ }
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ // Written into the project by laoshi's /laoshi-setup. Runs a command with {PORT} replaced by
3
+ // the port Paseo assigned (PASEO_PORT), the same way on macOS, Linux and Windows, whatever
4
+ // shell Paseo uses there (bash, sh, cmd.exe). Also sets PORT for programs that read it.
5
+ //
6
+ // paseo.json: "command": "node scripts/paseo/with-port.mjs npm run dev -- --port {PORT}"
7
+ // by hand: PASEO_PORT=4100 node scripts/paseo/with-port.mjs npm run dev -- --port {PORT}
8
+
9
+ import { spawn } from "node:child_process";
10
+
11
+ const args = process.argv.slice(2);
12
+ if (args.length === 0) {
13
+ console.error("用法:node scripts/paseo/with-port.mjs <命令> [参数…](参数中的 {PORT} 换成环境变量 PASEO_PORT)");
14
+ process.exit(2);
15
+ }
16
+ const port = process.env.PASEO_PORT ?? process.env.LAOSHI_PORT ?? process.env.PORT;
17
+ if (!port && args.some((a) => a.includes("{PORT}"))) {
18
+ console.error("没有环境变量 PASEO_PORT:它由 Paseo 提供,手工运行时请自己设置。");
19
+ process.exit(2);
20
+ }
21
+ const resolved = args.map((a) => (port ? a.replaceAll("{PORT}", port) : a));
22
+ // npm, npx and other .cmd shims need a shell on Windows.
23
+ const windows = process.platform === "win32";
24
+ const child = spawn(resolved[0], resolved.slice(1).map((a) => (windows && /[\s"]/.test(a) ? `"${a.replace(/"/g, '\\"')}"` : a)), {
25
+ stdio: "inherit",
26
+ shell: windows,
27
+ env: port ? { ...process.env, PORT: port } : process.env,
28
+ });
29
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
30
+ process.on(signal, () => child.kill(signal));
31
+ }
32
+ child.on("error", (error) => {
33
+ console.error(`无法启动 ${resolved[0]}:${error.message}`);
34
+ process.exit(127);
35
+ });
36
+ child.on("exit", (code, signal) => process.exit(code ?? (signal ? 1 : 0)));