@oyasmi/pipiclaw 0.9.5-beta.2 → 0.9.5-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/README.en.md +9 -11
  2. package/README.md +9 -11
  3. package/dist/agent/channel-runner.d.ts +12 -24
  4. package/dist/agent/channel-runner.js +74 -30
  5. package/dist/agent/maintenance-context.d.ts +2 -0
  6. package/dist/agent/maintenance-context.js +15 -0
  7. package/dist/agent/prompt/sections.js +8 -6
  8. package/dist/agent/prompt/types.d.ts +1 -1
  9. package/dist/agent/runner-factory.js +1 -1
  10. package/dist/agent/session/command-extension.js +11 -0
  11. package/dist/agent/session/compaction-summary.js +6 -2
  12. package/dist/agent/session/execution-trace.d.ts +14 -0
  13. package/dist/agent/session/execution-trace.js +57 -0
  14. package/dist/agent/session/session-events.d.ts +2 -7
  15. package/dist/agent/session/session-events.js +35 -12
  16. package/dist/agent/session/session-host.d.ts +12 -22
  17. package/dist/agent/session/session-host.js +46 -65
  18. package/dist/agent/turn/task-digest.d.ts +1 -2
  19. package/dist/agent/turn/task-digest.js +33 -33
  20. package/dist/agent/turn/turn-context.d.ts +1 -1
  21. package/dist/agent/turn/turn-context.js +1 -1
  22. package/dist/agent/turn/turn-finish.d.ts +2 -2
  23. package/dist/agent/turn/turn-finish.js +3 -2
  24. package/dist/agent/turn/turn-pipeline.d.ts +4 -2
  25. package/dist/agent/turn/turn-pipeline.js +33 -5
  26. package/dist/agent/types.d.ts +64 -14
  27. package/dist/agent/types.js +3 -0
  28. package/dist/app/home.js +3 -4
  29. package/dist/channel/channel-event.d.ts +4 -12
  30. package/dist/channel/ingress.d.ts +1 -9
  31. package/dist/channel/store.d.ts +1 -1
  32. package/dist/commands/catalog.js +25 -19
  33. package/dist/commands/router.d.ts +5 -2
  34. package/dist/commands/router.js +9 -4
  35. package/dist/config/settings.d.ts +5 -12
  36. package/dist/config/settings.js +0 -7
  37. package/dist/config/tools.d.ts +2 -2
  38. package/dist/config/tools.js +2 -2
  39. package/dist/dingtalk/bot.d.ts +2 -0
  40. package/dist/dingtalk/bot.js +4 -0
  41. package/dist/dingtalk/cards.d.ts +7 -0
  42. package/dist/dingtalk/cards.js +32 -2
  43. package/dist/dingtalk/delivery.d.ts +5 -1
  44. package/dist/dingtalk/delivery.js +157 -142
  45. package/dist/dingtalk/progress.d.ts +55 -6
  46. package/dist/dingtalk/progress.js +195 -16
  47. package/dist/file-store.d.ts +4 -0
  48. package/dist/file-store.js +6 -1
  49. package/dist/jobs/completion-observer.d.ts +20 -0
  50. package/dist/jobs/completion-observer.js +107 -0
  51. package/dist/jobs/completion-signal.d.ts +9 -0
  52. package/dist/jobs/completion-signal.js +32 -0
  53. package/dist/jobs/completion-wake.d.ts +1 -1
  54. package/dist/jobs/completion-wake.js +2 -13
  55. package/dist/jobs/manager.d.ts +11 -29
  56. package/dist/jobs/manager.js +103 -176
  57. package/dist/jobs/probe.d.ts +3 -0
  58. package/dist/jobs/probe.js +42 -0
  59. package/dist/jobs/record.d.ts +3 -6
  60. package/dist/jobs/runtime.d.ts +28 -0
  61. package/dist/jobs/runtime.js +69 -0
  62. package/dist/memory/boundary-work.d.ts +2 -0
  63. package/dist/memory/boundary-work.js +79 -37
  64. package/dist/memory/commands.js +4 -1
  65. package/dist/memory/index-budget.js +18 -15
  66. package/dist/memory/journal.js +2 -1
  67. package/dist/memory/lifecycle.d.ts +4 -8
  68. package/dist/memory/lifecycle.js +21 -51
  69. package/dist/memory/reflect-job.d.ts +0 -6
  70. package/dist/memory/reflect-job.js +13 -34
  71. package/dist/memory/reflect.d.ts +4 -0
  72. package/dist/memory/reflect.js +32 -5
  73. package/dist/memory/review-log.d.ts +13 -0
  74. package/dist/memory/review-log.js +49 -0
  75. package/dist/memory/search.js +7 -4
  76. package/dist/memory/source-window.d.ts +18 -1
  77. package/dist/memory/source-window.js +59 -9
  78. package/dist/memory/store.d.ts +2 -0
  79. package/dist/memory/store.js +45 -13
  80. package/dist/playbooks/agent-delegation.md +10 -4
  81. package/dist/playbooks/background-jobs.md +4 -4
  82. package/dist/playbooks/event-scheduling.md +2 -2
  83. package/dist/playbooks/memory-and-learning.md +3 -3
  84. package/dist/playbooks/outbound-media.md +2 -2
  85. package/dist/playbooks/runtime-orientation.md +10 -6
  86. package/dist/playbooks/task-lead.md +54 -33
  87. package/dist/runtime/bootstrap.d.ts +11 -24
  88. package/dist/runtime/bootstrap.js +92 -59
  89. package/dist/runtime/channel-queue.d.ts +2 -0
  90. package/dist/runtime/channel-queue.js +5 -1
  91. package/dist/runtime/durable-dispatch.d.ts +7 -0
  92. package/dist/runtime/durable-dispatch.js +66 -7
  93. package/dist/runtime/ingress-busy.d.ts +1 -2
  94. package/dist/runtime/ingress-busy.js +2 -35
  95. package/dist/runtime/ingress-commands.d.ts +1 -1
  96. package/dist/runtime/ingress-commands.js +28 -20
  97. package/dist/runtime/ingress-deps.d.ts +4 -7
  98. package/dist/runtime/ingress.js +23 -13
  99. package/dist/runtime/shutdown.d.ts +1 -1
  100. package/dist/runtime/shutdown.js +2 -2
  101. package/dist/runtime/task-close.d.ts +4 -0
  102. package/dist/runtime/task-close.js +102 -0
  103. package/dist/runtime/task-control.d.ts +34 -0
  104. package/dist/runtime/task-control.js +225 -0
  105. package/dist/runtime/task-input.d.ts +13 -0
  106. package/dist/runtime/task-input.js +129 -0
  107. package/dist/runtime/task-lane-types.d.ts +123 -0
  108. package/dist/runtime/task-lane-types.js +14 -0
  109. package/dist/runtime/task-lane.d.ts +99 -0
  110. package/dist/runtime/task-lane.js +703 -0
  111. package/dist/runtime/task-pending.d.ts +8 -0
  112. package/dist/runtime/task-pending.js +40 -0
  113. package/dist/runtime/task-spawn.d.ts +4 -4
  114. package/dist/runtime/task-spawn.js +4 -4
  115. package/dist/runtime/task-step.d.ts +32 -0
  116. package/dist/runtime/task-step.js +276 -0
  117. package/dist/runtime/turn-run.d.ts +4 -16
  118. package/dist/runtime/turn-run.js +17 -155
  119. package/dist/runtime/wake-coalescing.d.ts +1 -3
  120. package/dist/runtime/wake-coalescing.js +2 -4
  121. package/dist/shared/format.d.ts +0 -6
  122. package/dist/shared/format.js +0 -17
  123. package/dist/shared/host-process.d.ts +2 -0
  124. package/dist/shared/host-process.js +16 -1
  125. package/dist/shared/jsonl-appender.d.ts +5 -0
  126. package/dist/shared/jsonl-appender.js +25 -2
  127. package/dist/skills/catalog.d.ts +9 -0
  128. package/dist/skills/catalog.js +34 -0
  129. package/dist/skills/commands.d.ts +3 -12
  130. package/dist/skills/commands.js +36 -22
  131. package/dist/skills/loader.d.ts +2 -31
  132. package/dist/skills/loader.js +101 -68
  133. package/dist/skills/roots.d.ts +12 -0
  134. package/dist/skills/roots.js +18 -0
  135. package/dist/skills/types.d.ts +24 -0
  136. package/dist/skills/types.js +1 -0
  137. package/dist/subagents/completion-wake.js +0 -10
  138. package/dist/subagents/discovery.d.ts +1 -1
  139. package/dist/subagents/discovery.js +10 -16
  140. package/dist/subagents/dispatch.js +8 -16
  141. package/dist/subagents/external/cursor-cli.d.ts +2 -0
  142. package/dist/subagents/external/cursor-cli.js +256 -0
  143. package/dist/subagents/external/harness.d.ts +5 -5
  144. package/dist/subagents/external/reconciliation.d.ts +7 -0
  145. package/dist/subagents/external/reconciliation.js +105 -0
  146. package/dist/subagents/external/recovery.d.ts +20 -0
  147. package/dist/subagents/external/recovery.js +71 -0
  148. package/dist/subagents/external/registry.js +2 -0
  149. package/dist/subagents/external/role-warnings.d.ts +17 -0
  150. package/dist/subagents/external/role-warnings.js +42 -0
  151. package/dist/subagents/external/run.js +18 -22
  152. package/dist/subagents/format.d.ts +1 -1
  153. package/dist/subagents/format.js +1 -1
  154. package/dist/subagents/grace.d.ts +2 -2
  155. package/dist/subagents/grace.js +3 -3
  156. package/dist/subagents/internal/run.js +7 -5
  157. package/dist/subagents/internal/worker.js +31 -2
  158. package/dist/subagents/result.js +2 -3
  159. package/dist/subagents/run-record.d.ts +4 -7
  160. package/dist/subagents/run-record.js +2 -2
  161. package/dist/subagents/runs.d.ts +33 -46
  162. package/dist/subagents/runs.js +126 -245
  163. package/dist/subagents/task-settlement.d.ts +3 -0
  164. package/dist/subagents/task-settlement.js +20 -0
  165. package/dist/subagents/types.d.ts +1 -2
  166. package/dist/subagents/workspace-summary.js +5 -1
  167. package/dist/tasks/archive.d.ts +11 -0
  168. package/dist/tasks/archive.js +141 -0
  169. package/dist/tasks/board.d.ts +5 -12
  170. package/dist/tasks/board.js +4 -30
  171. package/dist/tasks/bound-work.d.ts +12 -6
  172. package/dist/tasks/bound-work.js +37 -24
  173. package/dist/tasks/brief.d.ts +38 -14
  174. package/dist/tasks/brief.js +128 -70
  175. package/dist/tasks/budget.d.ts +3 -3
  176. package/dist/tasks/budget.js +9 -4
  177. package/dist/tasks/commands.d.ts +14 -9
  178. package/dist/tasks/commands.js +190 -121
  179. package/dist/tasks/completion.d.ts +12 -0
  180. package/dist/tasks/completion.js +35 -0
  181. package/dist/tasks/contract.d.ts +8 -17
  182. package/dist/tasks/contract.js +41 -43
  183. package/dist/tasks/control.d.ts +138 -0
  184. package/dist/tasks/control.js +1 -0
  185. package/dist/tasks/create.d.ts +1 -1
  186. package/dist/tasks/create.js +3 -3
  187. package/dist/tasks/delivery.d.ts +24 -0
  188. package/dist/tasks/delivery.js +221 -0
  189. package/dist/tasks/file-mutation.d.ts +5 -0
  190. package/dist/tasks/file-mutation.js +38 -0
  191. package/dist/tasks/frontmatter.d.ts +43 -28
  192. package/dist/tasks/frontmatter.js +83 -40
  193. package/dist/tasks/input-receipts.d.ts +7 -0
  194. package/dist/tasks/input-receipts.js +60 -0
  195. package/dist/tasks/loop-log.d.ts +147 -28
  196. package/dist/tasks/loop-log.js +239 -28
  197. package/dist/tasks/receipts.d.ts +19 -0
  198. package/dist/tasks/receipts.js +48 -0
  199. package/dist/tasks/state.d.ts +93 -0
  200. package/dist/tasks/state.js +156 -0
  201. package/dist/tasks/store.d.ts +81 -49
  202. package/dist/tasks/store.js +244 -147
  203. package/dist/tools/bash.d.ts +3 -5
  204. package/dist/tools/bash.js +8 -22
  205. package/dist/tools/contract/details.d.ts +6 -6
  206. package/dist/tools/contract/details.js +6 -6
  207. package/dist/tools/contract/execution-trace.d.ts +4 -0
  208. package/dist/tools/contract/execution-trace.js +23 -0
  209. package/dist/tools/contract/presentation.js +6 -2
  210. package/dist/tools/edit.d.ts +1 -0
  211. package/dist/tools/edit.js +45 -42
  212. package/dist/tools/index.d.ts +8 -12
  213. package/dist/tools/index.js +16 -6
  214. package/dist/tools/memory-manage.js +8 -1
  215. package/dist/tools/registry.d.ts +7 -11
  216. package/dist/tools/registry.js +52 -25
  217. package/dist/tools/skill.d.ts +2 -2
  218. package/dist/tools/skill.js +24 -10
  219. package/dist/tools/subagent-manage.js +7 -4
  220. package/dist/tools/subagent.d.ts +0 -2
  221. package/dist/tools/subagent.js +2 -7
  222. package/dist/tools/task-manage/control-tools.d.ts +4 -0
  223. package/dist/tools/task-manage/control-tools.js +65 -0
  224. package/dist/tools/task-manage/create.js +2 -1
  225. package/dist/tools/task-manage/factory.d.ts +12 -6
  226. package/dist/tools/task-manage/factory.js +72 -57
  227. package/dist/tools/task-manage/lifecycle.d.ts +7 -12
  228. package/dist/tools/task-manage/lifecycle.js +118 -66
  229. package/dist/tools/task-manage/log-view.js +8 -5
  230. package/dist/tools/task-manage/schema.d.ts +21 -26
  231. package/dist/tools/task-manage/schema.js +29 -35
  232. package/dist/tools/task-manage/shared.d.ts +8 -39
  233. package/dist/tools/task-manage/shared.js +19 -68
  234. package/dist/tools/task-manage/step-tools.d.ts +5 -0
  235. package/dist/tools/task-manage/step-tools.js +103 -0
  236. package/dist/tools/task-manage/types.d.ts +25 -18
  237. package/dist/tools/write-content.d.ts +1 -0
  238. package/dist/tools/write-content.js +6 -1
  239. package/dist/tools/write.d.ts +1 -0
  240. package/dist/tools/write.js +1 -0
  241. package/dist/usage/ledger.d.ts +4 -4
  242. package/dist/usage/render.js +2 -2
  243. package/dist/web/search-providers.js +0 -33
  244. package/dist/webapi/request-policy.js +1 -1
  245. package/examples/sub-agents/README.md +23 -16
  246. package/examples/sub-agents/agents/claude-high.md +1 -1
  247. package/examples/sub-agents/agents/claude-main.md +1 -1
  248. package/examples/sub-agents/agents/codex-flash.md +1 -1
  249. package/examples/sub-agents/agents/codex-high.md +1 -1
  250. package/examples/sub-agents/agents/codex-main.md +4 -4
  251. package/examples/sub-agents/agents/cursor-high.md +22 -0
  252. package/examples/sub-agents/agents/cursor-main.md +22 -0
  253. package/examples/sub-agents/agents/glm-flash.md +1 -1
  254. package/examples/sub-agents/agents/glm-high.md +2 -2
  255. package/examples/sub-agents/agents/scout.md +30 -0
  256. package/package.json +6 -6
  257. package/dist/runtime/task-driver.d.ts +0 -116
  258. package/dist/runtime/task-driver.js +0 -443
  259. package/dist/runtime/task-wake.d.ts +0 -48
  260. package/dist/runtime/task-wake.js +0 -32
  261. package/dist/shared/wake-claim.d.ts +0 -23
  262. package/dist/shared/wake-claim.js +0 -26
  263. package/dist/skills/validation.d.ts +0 -8
  264. package/dist/skills/validation.js +0 -91
  265. package/dist/skills/workspace.d.ts +0 -33
  266. package/dist/skills/workspace.js +0 -116
  267. package/dist/tasks/steer.d.ts +0 -8
  268. package/dist/tasks/steer.js +0 -81
  269. package/dist/tasks/ticket.d.ts +0 -71
  270. package/dist/tasks/ticket.js +0 -138
  271. package/dist/tools/task-manage/step-end.d.ts +0 -11
  272. package/dist/tools/task-manage/step-end.js +0 -117
@@ -1,16 +1,12 @@
1
1
  import { senderOf } from "../channel/channel-event.js";
2
2
  import { BUILT_IN_COMMANDS, formatUnknownCommandMessage, isRunnerBuiltInCommand, parseBuiltInCommand, renderBuiltInHelp, slashCommandName, } from "../commands/catalog.js";
3
3
  import { formatNoDeskReply } from "../desk/commands.js";
4
- import { getDeskDir } from "../desk/paths.js";
5
4
  import * as log from "../log.js";
6
5
  import { errorMessage } from "../shared/text-utils.js";
7
- import { buildTaskStepBrief } from "../tasks/brief.js";
8
- import { consumeTaskNotice } from "../tasks/steer.js";
6
+ import { renderStopTaskHint } from "../tasks/commands.js";
9
7
  import { createEmptyUsageTotals } from "../usage/totals.js";
10
8
  import { admitsSyntheticEvent, resolvedDesk } from "./desk-runtime.js";
11
9
  import { relativeImagePaths } from "./inbound-images.js";
12
- import { parseDriverTaskId } from "./task-driver.js";
13
- import { claimVerifiedWake } from "./task-wake.js";
14
10
  import { canAbsorbWake, isCoalescableWake, MAX_COALESCED_WAKES, mergeCompletionWakes } from "./wake-coalescing.js";
15
11
  /**
16
12
  * The `runRuntimeCommand` names usable on the idle-turn path — every `BUILT_IN_COMMANDS` entry
@@ -41,10 +37,6 @@ function trackOutput(ctx) {
41
37
  };
42
38
  return tracked;
43
39
  }
44
- /** A task step is silent: its output never reaches the channel (only `task_step_end`'s report does, through `push`). */
45
- function silenceAnswers(ctx) {
46
- return { emit: () => undefined, finish: (outcome) => ctx.finish(outcome) };
47
- }
48
40
  function turnInfoOf(event) {
49
41
  return {
50
42
  channelId: event.channelId,
@@ -61,73 +53,7 @@ function turnInfoOf(event) {
61
53
  * step when the wake is one), and always settle the dispatch and release the turn.
62
54
  */
63
55
  export function createEventTurnRunner(deps) {
64
- const { options, transports, store, activeTasks, archiveIncomingMessage, getRunner, isShuttingDown, getDurableDispatch, getJobs, getRuns, getTaskDriver, } = deps;
65
- /**
66
- * Turn a `[TASK_DRIVER:<id>]` dispatch into a task loop step: bind the runner to the task
67
- * cycle's own session and replace the wake text with the step brief. Returns `undefined` for
68
- * every other event, which then follows the unchanged chat path.
69
- *
70
- * Binding failures fall back to the chat path rather than dropping the wake — a task that
71
- * cannot open its session should still be visible, not silently skipped.
72
- */
73
- const prepareTaskStep = async (event, runner) => {
74
- if (event.source !== "wake")
75
- return undefined;
76
- const taskId = parseDriverTaskId(event.text) ?? event.internalWake?.taskId;
77
- if (!taskId)
78
- return undefined;
79
- const { desk, deskDir } = runner.conversation;
80
- // Admission already refused a wake for another desk (spec 058, D7); a task step bound to the
81
- // wrong desk's session would run a task this runner does not own, so check once more.
82
- if (event.desk !== desk) {
83
- log.logWarn("taskdriver.step.desk_mismatch", "Task step refused: wake is not for this runner's desk", {
84
- channelId: event.channelId,
85
- fields: { taskId, eventDesk: event.desk, runnerDesk: desk },
86
- });
87
- return undefined;
88
- }
89
- try {
90
- const brief = await buildTaskStepBrief({ deskDir, taskId });
91
- if (!brief)
92
- return undefined;
93
- await runner.bindTaskSession(taskId);
94
- return { taskId, brief };
95
- }
96
- catch (error) {
97
- log.logWarn("taskdriver.step.start_failed", "Task step start failed", {
98
- channelId: event.channelId,
99
- reason: errorMessage(error),
100
- fields: { taskId },
101
- });
102
- return undefined;
103
- }
104
- };
105
- /** Deliver whatever the step asked to say, then hand the runner back to the chat session. */
106
- const finishTaskStep = async (runner, channelId, taskId, transport) => {
107
- try {
108
- const notice = await consumeTaskNotice(runner.conversation.deskDir, taskId);
109
- if (notice) {
110
- // runner.run finishes its per-turn output before returning. Sending through that
111
- // finished output silently dropped successful task_step_end notifications (T-run-01).
112
- const delivered = await transport.push(channelId, { text: notice });
113
- if (delivered)
114
- await store.logBotResponse(channelId, notice, Date.now().toString());
115
- else
116
- log.logWarn("taskdriver.notice.delivery_failed", "Task notice delivery failed", {
117
- channelId: channelId,
118
- fields: { taskId },
119
- });
120
- }
121
- }
122
- catch (error) {
123
- log.logWarn("taskdriver.notice.delivery_failed", "Task notice delivery failed", {
124
- channelId: channelId,
125
- reason: errorMessage(error),
126
- fields: { taskId },
127
- });
128
- }
129
- await runner.bindChatSession();
130
- };
56
+ const { transports, store, activeTasks, archiveIncomingMessage, getRunner, isShuttingDown, getDurableDispatch } = deps;
131
57
  /**
132
58
  * Dispatch admission: refuse a stale redelivery of a wake an earlier turn already handled (the
133
59
  * turn is released), and fold other pending completion wakes into this one. `undefined` = skip.
@@ -143,7 +69,6 @@ export function createEventTurnRunner(deps) {
143
69
  runner.endTurn();
144
70
  return undefined;
145
71
  }
146
- const structuredWakeFinalized = event.source !== "wake" || event.internalWake === undefined;
147
72
  let absorbedDispatchIds = [];
148
73
  if (durable && event.source === "wake" && event.dispatchId && isCoalescableWake(event)) {
149
74
  const primary = event;
@@ -168,7 +93,6 @@ export function createEventTurnRunner(deps) {
168
93
  return {
169
94
  event,
170
95
  output: undefined,
171
- structuredWakeFinalized,
172
96
  absorbedDispatchIds,
173
97
  mergedWakesHandled: false,
174
98
  threw: false,
@@ -196,6 +120,17 @@ export function createEventTurnRunner(deps) {
196
120
  }
197
121
  else if (isRunnerBuiltInCommand(builtInCommand)) {
198
122
  response = await runner.handleBuiltinCommand(builtInCommand);
123
+ // `/stop` only reaches an idle channel's chat turn. Say so, and where a task can be
124
+ // stopped: tasks run apart from the chat (spec 064, D27).
125
+ if (builtInCommand.name === "stop") {
126
+ const snapshots = await deps
127
+ .getTaskControl()
128
+ ?.snapshot(runner.conversation.desk)
129
+ .catch(() => []);
130
+ const hint = renderStopTaskHint(snapshots ?? []);
131
+ if (hint)
132
+ response = `${response}\n${hint}`;
133
+ }
199
134
  }
200
135
  if (response !== undefined) {
201
136
  // Command echoes are control-plane traffic, not conversation: sent, never archived.
@@ -227,33 +162,7 @@ export function createEventTurnRunner(deps) {
227
162
  throw err;
228
163
  }
229
164
  };
230
- /**
231
- * A completion wake for a task's job or delegation: verified against the resource's own record
232
- * before it may reopen the task (see `claimVerifiedWake`). Plain "belongs to task" text in a
233
- * message never counts — only the producer-created `internalWake` envelope. Returns whether the
234
- * turn should still run.
235
- */
236
- const verifyInternalWake = async (turn, runner, internalWake) => {
237
- const event = turn.event;
238
- const { kind, resourceId, taskId: wakeTaskId } = internalWake;
239
- const { desk, deskDir } = runner.conversation;
240
- const claimed = await claimVerifiedWake(event, deskDir, kind === "job" ? getJobs().get(desk) : getRuns().get(desk), options.wakeTransitionHooks?.[kind]);
241
- if (!claimed) {
242
- log.logWarn("dispatch.wake.unverified", "Unverifiable wake ignored", {
243
- channelId: event.channelId,
244
- fields: { kind, resourceId, taskId: wakeTaskId },
245
- });
246
- turn.structuredWakeFinalized = true;
247
- return false;
248
- }
249
- await claimed.finish();
250
- turn.structuredWakeFinalized = true;
251
- // Drop without a turn only when something else is still driving this task (a sibling
252
- // wake in the same fan-out already reopened it); in every other case nobody else will
253
- // look at this result, so it still reaches a normal turn.
254
- return claimed.activated || !claimed.taskStillDriven;
255
- };
256
- /** The turn proper: archive, route commands, verify wakes, then run the agent (as a task step if one). */
165
+ /** The turn proper: archive, route commands, then run the agent. */
257
166
  const executeTurn = async (turn, runner, transport, backgroundOnly) => {
258
167
  const { event } = turn;
259
168
  const sender = senderOf(event);
@@ -290,37 +199,20 @@ export function createEventTurnRunner(deps) {
290
199
  ctx: { channelId: event.channelId, userName: sender.userName },
291
200
  fields: { messageLength: event.text.length, source: backgroundOnly ? "event" : "message" },
292
201
  });
293
- if (event.source === "wake" &&
294
- event.internalWake &&
295
- !(await verifyInternalWake(turn, runner, event.internalWake)))
296
- return;
297
- // Verified job/run wakes that activate a task are task steps too. Verification must happen
298
- // first: routing directly from user-controlled wake text would grant task-only tools.
299
- const taskStep = await prepareTaskStep(turn.event, runner);
300
- if (taskStep) {
301
- turn.event = { ...turn.event, text: taskStep.brief };
302
- }
303
202
  // Background wakes deliver their result, not their process: no progress card, no
304
203
  // thinking stream, nothing to clean up when a check-in ends `[SILENT]`. Awaited completions
305
204
  // deliver their result too, without opening another progress card.
306
- // Spec 051, D3: a task-driver dispatch runs as a *task step* — in the task cycle's own
307
- // session, with a brief instead of the wake text, and silent unless the step asked for a
308
- // notify. Everything below (busy state, /stop, delivery) is unchanged; only which session
309
- // the turn is bound to, and what reaches the channel, differ.
310
205
  const info = turnInfoOf(turn.event);
311
- const opened = transport.openTurn(info, { quiet: backgroundOnly || taskStep !== undefined });
312
- turn.output = trackOutput(taskStep ? silenceAnswers(opened) : opened);
206
+ turn.output = trackOutput(transport.openTurn(info, { quiet: backgroundOnly }));
313
207
  const result = await runner.run(info, turn.output.ctx, store);
314
208
  if (!deps.isCurrentRunner(runner))
315
209
  return;
316
210
  turn.mergedWakesHandled = result.stopReason !== "aborted" && result.stopReason !== "error";
317
- if (taskStep)
318
- await finishTaskStep(runner, turn.event.channelId, taskStep.taskId, transport);
319
211
  if (result.stopReason === "aborted" && runner.getTurnStatus().stopRequested) {
320
212
  log.logInfoEvent("agent.turn.stopped", "Turn stopped", { channelId: turn.event.channelId });
321
213
  }
322
214
  };
323
- /** Always runs: finish the output, settle the dispatch records, release the turn, nudge the task driver. */
215
+ /** Always runs: finish the output, settle the dispatch records, release the turn. */
324
216
  const finishTurn = async (turn, runner) => {
325
217
  const { event } = turn;
326
218
  // The runner finishes the output when it runs; a command, or a turn that failed before the
@@ -351,10 +243,7 @@ export function createEventTurnRunner(deps) {
351
243
  runner.endTurn();
352
244
  return;
353
245
  }
354
- if (turn.structuredWakeFinalized)
355
- await getDurableDispatch()?.markCompleted(event.dispatchId);
356
- else
357
- await getDurableDispatch()?.markRetryable(event.dispatchId);
246
+ await getDurableDispatch()?.markCompleted(event.dispatchId);
358
247
  // A stopped turn has not finished handling its merged notifications. Release their
359
248
  // claims even if /stop's asynchronous cancelChannel reset raced admission or failed.
360
249
  const stopped = !turn.mergedWakesHandled || runner.getTurnStatus().stopRequested;
@@ -365,32 +254,6 @@ export function createEventTurnRunner(deps) {
365
254
  await getDurableDispatch()?.markCompleted(absorbedId);
366
255
  }
367
256
  runner.endTurn();
368
- // A finished turn may have written task files; rescan now so `outcome: continue`
369
- // queues the next step immediately instead of waiting out the current sleep.
370
- getTaskDriver().nudge?.();
371
- };
372
- /**
373
- * A task-bound wake dropped at admission because its channel left the wake's desk while it was
374
- * queued. No turn runs, but the business side settles exactly as when the producer suppresses
375
- * the wake itself: the owner verifies and claims it and the task's `work` ticket is redeemed, so
376
- * the task resumes as soon as its channel is bound back instead of waiting out the backstop.
377
- */
378
- const settleDroppedTaskWake = async (event) => {
379
- const wake = event.internalWake;
380
- if (!wake)
381
- return;
382
- try {
383
- const owner = wake.kind === "job" ? getJobs().get(event.desk) : getRuns().get(event.desk);
384
- const claimed = await claimVerifiedWake(event, getDeskDir(options.paths.workspaceDir, event.desk), owner);
385
- await claimed?.finish();
386
- }
387
- catch (error) {
388
- log.logWarn("dispatch.wake.redeem_failed", "Work ticket redeem for a dropped wake failed", {
389
- channelId: event.channelId,
390
- reason: errorMessage(error),
391
- fields: { dispatchId: event.dispatchId, taskId: wake.taskId },
392
- });
393
- }
394
257
  };
395
258
  /** Release a turn `reserveEvent` began for an event that admission then refused. */
396
259
  const releaseReservation = (event) => {
@@ -481,7 +344,6 @@ export function createEventTurnRunner(deps) {
481
344
  },
482
345
  });
483
346
  releaseReservation(inboundEvent);
484
- await settleDroppedTaskWake(inboundEvent);
485
347
  await getDurableDispatch()?.markCompleted(inboundEvent.dispatchId);
486
348
  return;
487
349
  }
@@ -7,9 +7,7 @@ import type { WakeEvent } from "../channel/channel-event.js";
7
7
  * channel, so results that arrive while the channel is busy are handled together in the next turn.
8
8
  * Nothing is delayed to make that happen: the first result still wakes the channel immediately.
9
9
  *
10
- * Only chat-level wakes merge. A task-bound wake carries `internalWake` and goes through its own
11
- * claim (`task-wake.ts`), which already lets sibling wakes of one fan-out drop out once the task
12
- * is reopened.
10
+ * Only completion wakes merge; a task-bound result never wakes a channel at all (spec 064, D19).
13
11
  */
14
12
  /** The merged turn's prompt grows with every result's tail; past this many it is better split. */
15
13
  export declare const MAX_COALESCED_WAKES = 6;
@@ -6,15 +6,13 @@
6
6
  * channel, so results that arrive while the channel is busy are handled together in the next turn.
7
7
  * Nothing is delayed to make that happen: the first result still wakes the channel immediately.
8
8
  *
9
- * Only chat-level wakes merge. A task-bound wake carries `internalWake` and goes through its own
10
- * claim (`task-wake.ts`), which already lets sibling wakes of one fan-out drop out once the task
11
- * is reopened.
9
+ * Only completion wakes merge; a task-bound result never wakes a channel at all (spec 064, D19).
12
10
  */
13
11
  /** The merged turn's prompt grows with every result's tail; past this many it is better split. */
14
12
  export const MAX_COALESCED_WAKES = 6;
15
13
  const COMPLETION_WAKE_ID = /^(subagent|job):.+:done$/;
16
14
  export function isCoalescableWake(event) {
17
- return !event.internalWake && typeof event.dispatchId === "string" && COMPLETION_WAKE_ID.test(event.dispatchId);
15
+ return typeof event.dispatchId === "string" && COMPLETION_WAKE_ID.test(event.dispatchId);
18
16
  }
19
17
  /**
20
18
  * Whether `candidate` may ride along in `primary`'s turn. The primary already passed
@@ -6,12 +6,6 @@ export declare function formatDuration(ms: number): string;
6
6
  * D4). Model-facing text keeps `formatDuration` above.
7
7
  */
8
8
  export declare function formatElapsedZh(ms: number): string;
9
- /**
10
- * A coarse, single-unit span in Chinese (`30 秒`, `12 分钟`, `3 小时`, `2 天`) — for "how far away is
11
- * this deadline", where a second unit is noise. Rounds within a unit and promotes to the next unit
12
- * when rounding reaches it, so the output never reads `60 分钟` or `24 小时`.
13
- */
14
- export declare function formatSpanZh(ms: number): string;
15
9
  /**
16
10
  * Coerce an untrusted numeric config/request value into an integer within `[minimum, maximum]`,
17
11
  * falling back to `fallback` for anything not a finite number or out of range. Shared by the
@@ -26,23 +26,6 @@ export function formatElapsedZh(ms) {
26
26
  const hours = totalHours % 24;
27
27
  return hours > 0 ? `${Math.floor(totalHours / 24)}天${hours}小时` : `${Math.floor(totalHours / 24)}天`;
28
28
  }
29
- /**
30
- * A coarse, single-unit span in Chinese (`30 秒`, `12 分钟`, `3 小时`, `2 天`) — for "how far away is
31
- * this deadline", where a second unit is noise. Rounds within a unit and promotes to the next unit
32
- * when rounding reaches it, so the output never reads `60 分钟` or `24 小时`.
33
- */
34
- export function formatSpanZh(ms) {
35
- const seconds = Math.max(0, Math.round(ms / 1000));
36
- if (seconds < 60)
37
- return `${seconds} 秒`;
38
- const minutes = Math.round(ms / 60_000);
39
- if (minutes < 60)
40
- return `${minutes} 分钟`;
41
- const hours = Math.round(ms / 3_600_000);
42
- if (hours < 24)
43
- return `${hours} 小时`;
44
- return `${Math.round(ms / 86_400_000)} 天`;
45
- }
46
29
  /**
47
30
  * Coerce an untrusted numeric config/request value into an integer within `[minimum, maximum]`,
48
31
  * falling back to `fallback` for anything not a finite number or out of range. Shared by the
@@ -18,6 +18,8 @@ export declare function isProcessAlive(pid: number): boolean;
18
18
  * just the leader, so a leader that already exited while a lingering descendant (e.g. a shell
19
19
  * that forked and returned) is still running is correctly reported as "still something there". */
20
20
  export declare function isProcessGroupAlive(pid: number): boolean;
21
+ /** A zombie cannot write. A failed host probe remains unknown, never evidence of a safe group. */
22
+ export declare function processGroupQuiescent(pid: number): Promise<boolean>;
21
23
  /**
22
24
  * SIGTERM the process group, then unconditionally SIGKILL it after `graceMs`. `detached: true` at
23
25
  * spawn time makes the child its own process-group leader, so `-pid` reaches it and everything it
@@ -16,7 +16,7 @@ const execFileAsync = promisify(execFile);
16
16
  */
17
17
  export async function readProcessStartTime(pid) {
18
18
  try {
19
- const { stdout } = await execFileAsync("ps", ["-p", String(pid), "-o", "lstart="]);
19
+ const { stdout } = await execFileAsync("ps", ["-p", String(pid), "-o", "lstart="], { timeout: 1_000 });
20
20
  const value = stdout.trim();
21
21
  return value || undefined;
22
22
  }
@@ -77,6 +77,21 @@ export function isProcessGroupAlive(pid) {
77
77
  return error.code === "EPERM";
78
78
  }
79
79
  }
80
+ /** A zombie cannot write. A failed host probe remains unknown, never evidence of a safe group. */
81
+ export async function processGroupQuiescent(pid) {
82
+ if (!isProcessGroupAlive(pid))
83
+ return true;
84
+ try {
85
+ const { stdout } = await execFileAsync("ps", ["-eo", "pgid=,stat="], { timeout: 1_000 });
86
+ return !stdout.split("\n").some((line) => {
87
+ const [group, state] = line.trim().split(/\s+/);
88
+ return Number(group) === pid && !state?.startsWith("Z");
89
+ });
90
+ }
91
+ catch {
92
+ return false;
93
+ }
94
+ }
80
95
  /**
81
96
  * Spec 042 D8: cancel/timeout grace before SIGKILL — long enough for a coding agent CLI to flush
82
97
  * its protocol terminal event and buffered output before being force-killed (300ms was rarely
@@ -22,6 +22,11 @@ export interface JsonlAppenderOptions {
22
22
  reservedCriticalBytes?: number;
23
23
  /** Optional work that must follow a successful rotation in the same file queue. */
24
24
  onRotate?: (filePath: string) => Promise<void>;
25
+ /** Defer rotation while the oldest shard still holds required recovery records. */
26
+ canRotate?: () => Promise<boolean>;
27
+ /** Isolate an interrupted last line before appending. Caller serializes cross-process writes. */
28
+ repairTail?: boolean;
29
+ onRepairTail?: (filePath: string, offset: number) => void;
25
30
  }
26
31
  export interface JsonlAppender {
27
32
  /** Queue and await one record. Never throws; a full or closed writer drops it. */
@@ -1,4 +1,4 @@
1
- import { appendFile, mkdir, rename, rm, stat } from "node:fs/promises";
1
+ import { appendFile, mkdir, open, rename, rm, stat } from "node:fs/promises";
2
2
  import { dirname } from "node:path";
3
3
  const DEFAULT_MAX_PENDING_RECORDS = 2_000;
4
4
  const DEFAULT_MAX_PENDING_BYTES = 8 * 1024 * 1024;
@@ -86,8 +86,31 @@ export function createJsonlAppender(options) {
86
86
  };
87
87
  const write = async (filePath, line, lineBytes) => {
88
88
  await ensureDir(filePath);
89
+ if (options.repairTail) {
90
+ const handle = await open(filePath, "a+", mode);
91
+ try {
92
+ let size = (await handle.stat()).size;
93
+ if (size > 0) {
94
+ const tail = Buffer.alloc(1);
95
+ await handle.read(tail, 0, 1, size - 1);
96
+ if (tail[0] !== 10) {
97
+ await handle.writeFile("\n");
98
+ options.onRepairTail?.(filePath, size);
99
+ size++;
100
+ }
101
+ }
102
+ sizes.set(filePath, size);
103
+ }
104
+ finally {
105
+ await handle.close();
106
+ }
107
+ }
89
108
  const size = await currentSize(filePath);
90
- if (options.maxSizeBytes && options.maxSizeBytes > 0 && size + lineBytes > options.maxSizeBytes && size > 0) {
109
+ if (options.maxSizeBytes &&
110
+ options.maxSizeBytes > 0 &&
111
+ size + lineBytes > options.maxSizeBytes &&
112
+ size > 0 &&
113
+ ((await options.canRotate?.()) ?? true)) {
91
114
  await rotate(filePath);
92
115
  }
93
116
  await appendFile(filePath, line, { encoding: "utf-8", mode });
@@ -0,0 +1,9 @@
1
+ import type { SkillOptions, SkillSource } from "./types.js";
2
+ export declare function loadSkillFile(options: SkillOptions, name: string, inspectRejected?: boolean): Promise<{
3
+ name: string;
4
+ path: string;
5
+ source: SkillSource;
6
+ content: string;
7
+ loaded: boolean;
8
+ }>;
9
+ export declare function skillSourceLabel(source: SkillSource): string;
@@ -0,0 +1,34 @@
1
+ /** On-demand catalog reads, shared by the skill tool and /skills. */
2
+ import { readFile } from "node:fs/promises";
3
+ import { checkPathGuard } from "../security/path-guard-check.js";
4
+ import { RecoverableToolError } from "../shared/recoverable-error.js";
5
+ import { errorMessage } from "../shared/text-utils.js";
6
+ import { loadPipiclawSkills } from "./loader.js";
7
+ import { skillSecurity } from "./roots.js";
8
+ export async function loadSkillFile(options, name, inspectRejected = false) {
9
+ const catalog = loadPipiclawSkills(options);
10
+ const skill = catalog.skills.find((item) => item.name === name);
11
+ const rejected = inspectRejected
12
+ ? catalog.diagnostics.find((item) => item.rejected && item.name === name && item.path)
13
+ : undefined;
14
+ const path = skill?.filePath ?? rejected?.path;
15
+ if (!path) {
16
+ throw new RecoverableToolError(`Skill "${name}" does not exist or could not be loaded. Use action "list" to inspect skills and diagnostics.`);
17
+ }
18
+ const { securityConfig, securityContext } = skillSecurity(options);
19
+ const target = await checkPathGuard(path, "read", securityConfig, securityContext, {
20
+ tool: "skill",
21
+ channelId: options.channelId,
22
+ });
23
+ let content;
24
+ try {
25
+ content = await readFile(target, "utf-8");
26
+ }
27
+ catch (error) {
28
+ throw new RecoverableToolError(`Skill "${name}" could not be read: ${errorMessage(error)}. Use action "list" to refresh the catalog before retrying.`);
29
+ }
30
+ return { name, path: target, source: (skill ?? rejected).source, content, loaded: !!skill };
31
+ }
32
+ export function skillSourceLabel(source) {
33
+ return source === "workspace" ? "工作区" : "用户共享";
34
+ }
@@ -1,15 +1,6 @@
1
- /**
2
- * `/skills` — the human control path for a workspace's skill catalog (spec 045's read-only
3
- * `skill` tool has no channel-command counterpart until now). Mirrors `channel/commands.ts`'s
4
- * shape: pure-ish functions returning markdown, no bot/event coupling.
5
- *
6
- * Deliberately a disk scan via `listWorkspaceSkills`, not the live `ChannelRunner`'s already-
7
- * loaded catalog: that keeps `/skills` usable while a turn is streaming and for a channel with no
8
- * active runner, and — the whole reason this exists rather than reusing `/help`'s discovery tail
9
- * — it is the only place that shows a skill that failed the content scan and was silently dropped
10
- * from the prompt's skill list (`src/skills/loader.ts`).
11
- */
12
- export interface HandleSkillsCommandOptions {
1
+ import type { SkillOptions } from "./types.js";
2
+ /** Stateless disk inspection remains usable without an active session. */
3
+ export interface HandleSkillsCommandOptions extends Pick<SkillOptions, "sharedSkillsDir"> {
13
4
  args: string;
14
5
  workspaceDir: string;
15
6
  appHomeDir: string;
@@ -4,7 +4,8 @@ import { GuardBlockedError, renderGuardBlockForUser } from "../security/block-me
4
4
  import { loadSecurityConfigWithDiagnostics } from "../security/config.js";
5
5
  import { RecoverableToolError } from "../shared/recoverable-error.js";
6
6
  import { errorMessage } from "../shared/text-utils.js";
7
- import { listWorkspaceSkills, loadWorkspaceSkillFile } from "./workspace.js";
7
+ import { loadSkillFile, skillSourceLabel } from "./catalog.js";
8
+ import { loadPipiclawSkills } from "./loader.js";
8
9
  function usage() {
9
10
  return renderSubcommandUsage("skills");
10
11
  }
@@ -21,36 +22,45 @@ export function parseSkillsCommand(args) {
21
22
  }
22
23
  throw new Error(`未知子命令 \`${parts[0]}\`。`);
23
24
  }
24
- async function listSkills(workspaceDir) {
25
- const skills = await listWorkspaceSkills({ workspaceDir });
26
- if (skills.length === 0) {
27
- return ("暂无工作区 skill。\n" +
28
- `让我帮你创建,或手动放到 \`${workspaceDir}/skills/<name>/SKILL.md\`(文件头需要非空的 \`name\`,与目录名一致,以及 \`description\`)。`);
25
+ function diagnosticForUser(diagnostic, skills) {
26
+ const label = diagnostic.name ? `\`${diagnostic.name}\`` : "技能目录";
27
+ const source = skillSourceLabel(diagnostic.source);
28
+ if (diagnostic.type === "collision") {
29
+ return `- ${label}(${source}):同名版本已被覆盖;使用${skillSourceLabel(skills.find((skill) => skill.name === diagnostic.name).source)}版本。`;
29
30
  }
30
- const loaded = skills.filter((skill) => !skill.warning);
31
- const rejected = skills.filter((skill) => skill.warning);
32
- const lines = [`**工作区 skills**(${loaded.length} 个)· 用 \`/skill:<名称>\` 调用`, ""];
33
- if (loaded.length > 0) {
34
- lines.push(...loaded.map((skill) => `- \`${skill.name}\` — ${skill.description || "(无 description)"}`));
31
+ const active = skills.find((skill) => skill.name === diagnostic.name);
32
+ const status = diagnostic.rejected
33
+ ? `该版本未加载${active ? `;当前使用${skillSourceLabel(active.source)}版本` : ""}`
34
+ : "格式提醒,仍可使用";
35
+ return `- ${label}(${source}):${status}。请检查${diagnostic.path ? ` \`${diagnostic.path}\`` : "目录权限或文件内容"},修改后发送 \`/reload\`。`;
36
+ }
37
+ function listSkills(options) {
38
+ const { skills, diagnostics } = loadPipiclawSkills(options);
39
+ if (skills.length === 0 && diagnostics.length === 0) {
40
+ return ("暂无技能。\n" +
41
+ `让我帮你创建,或放到 \`${options.workspaceDir}/skills/<name>/SKILL.md\`;也支持 \`~/.agents/skills/\`。`);
35
42
  }
36
- else {
37
- lines.push("(全部未通过加载,见下)");
43
+ const lines = [`**技能**(${skills.length} 个)· 用 \`/skill:<名称>\` 调用`, ""];
44
+ for (const skill of skills) {
45
+ lines.push(`- \`${skill.name}\`(${skillSourceLabel(skill.source)}${skill.disableModelInvocation ? ",仅显式调用" : ""})— ${skill.description.replace(/\s+/g, " ")}`);
38
46
  }
39
- if (rejected.length > 0) {
40
- lines.push("", "⚠️ 未加载(助手看不到,也无法用 `/skill:名称` 调用)", "");
41
- lines.push(...rejected.map((skill) => `- \`${skill.name}\` — ${skill.warning}`));
47
+ if (diagnostics.length > 0) {
48
+ lines.push("", "加载提醒", "", ...diagnostics.map((item) => diagnosticForUser(item, skills)));
42
49
  }
43
- return capReply(lines.join("\n"), { nextStepHint: "用 `/skills show <name>` 查看单个 skill 的完整正文" }).text;
50
+ return capReply(lines.join("\n"), {
51
+ nextStepHint: "用 `/skills show <name>` 查看单个技能;外部修改后发送 `/reload` 更新当前会话",
52
+ }).text;
44
53
  }
45
54
  async function showSkill(options, name) {
46
55
  try {
47
56
  const securityConfig = loadSecurityConfigWithDiagnostics(options.appHomeDir).config;
48
- const file = await loadWorkspaceSkillFile({
57
+ const file = await loadSkillFile({
49
58
  workspaceDir: options.workspaceDir,
59
+ sharedSkillsDir: options.sharedSkillsDir,
50
60
  securityConfig,
51
61
  channelId: options.channelId,
52
- }, name);
53
- const body = `**Skill \`${file.name}\`**\n\n路径:\`${file.path}\`\n\n${flattenMarkdownForChat(file.content)}`;
62
+ }, name, true);
63
+ const body = `**Skill \`${file.name}\`**\n\n来源:${skillSourceLabel(file.source)}${file.loaded ? "" : "(未加载,仅供排错)"}\n\n路径:\`${file.path}\`\n\n${flattenMarkdownForChat(file.content)}`;
54
64
  return capReply(body, { nextStepHint: `完整内容在 \`${file.path}\`` }).text;
55
65
  }
56
66
  catch (error) {
@@ -59,7 +69,7 @@ async function showSkill(options, name) {
59
69
  return `未找到 skill \`${name}\`。用 \`/skills\` 查看可用的 skill。`;
60
70
  if (error instanceof GuardBlockedError)
61
71
  return renderGuardBlockForUser(error.blocked);
62
- return `无法读取 skill \`${name}\`:${errorMessage(error)}`;
72
+ return `无法读取 skill \`${name}\`。请检查文件权限和内容后重试。`;
63
73
  }
64
74
  }
65
75
  export async function handleSkillsCommand(options) {
@@ -72,7 +82,11 @@ export async function handleSkillsCommand(options) {
72
82
  }
73
83
  switch (command.action) {
74
84
  case "list":
75
- return listSkills(options.workspaceDir);
85
+ return listSkills({
86
+ workspaceDir: options.workspaceDir,
87
+ sharedSkillsDir: options.sharedSkillsDir,
88
+ securityConfig: loadSecurityConfigWithDiagnostics(options.appHomeDir).config,
89
+ });
76
90
  case "show":
77
91
  return showSkill(options, command.name);
78
92
  }
@@ -1,31 +1,2 @@
1
- /**
2
- * Workspace skills.
3
- *
4
- * SOUL.md and AGENTS.md are loaded by the prompt pipeline itself
5
- * (`agent/prompt/resources.ts`), which owns their budgets and framing.
6
- */
7
- import { type ResourceDiagnostic, type Skill } from "@earendil-works/pi-coding-agent";
8
- export interface PipiclawSkillsResult {
9
- skills: Skill[];
10
- diagnostics: ResourceDiagnostic[];
11
- }
12
- /**
13
- * Load skills from the workspace-level skill directory.
14
- *
15
- * Diagnostics (an unreadable SKILL.md, bad frontmatter, a duplicate name, content that failed the
16
- * scan above) were previously dropped on the floor, so a broken workspace skill silently vanished
17
- * from the prompt. They are returned now and surfaced by the runner.
18
- */
19
- export declare function loadPipiclawSkills(workspaceDir: string): PipiclawSkillsResult;
20
- /**
21
- * Merge pi's auto-discovered skills with the workspace ones. Workspace wins on a
22
- * name collision (it is the layer the user actually edits), and the collision is
23
- * reported rather than resolved in silence.
24
- */
25
- export declare function resolvePipiclawSkills(base: {
26
- skills: Skill[];
27
- diagnostics: ResourceDiagnostic[];
28
- }, workspace: PipiclawSkillsResult): {
29
- skills: Skill[];
30
- diagnostics: ResourceDiagnostic[];
31
- };
1
+ import type { PipiclawSkillsResult, SkillOptions } from "./types.js";
2
+ export declare function loadPipiclawSkills(options: SkillOptions): PipiclawSkillsResult;