@uncarved/jade 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/README.md +64 -2
  2. package/assets/logo.svg +1 -0
  3. package/bin/jade.js +4 -0
  4. package/dist/api.d.ts +5 -250
  5. package/dist/api.js +5 -7
  6. package/dist/api.js.map +1 -1
  7. package/dist/fetch.d.ts +8 -0
  8. package/dist/fetch.js +19 -17
  9. package/dist/fetch.js.map +1 -1
  10. package/dist/host.d.ts +12 -1
  11. package/dist/host.js +49 -1
  12. package/dist/host.js.map +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/main.js +26 -4
  17. package/dist/main.js.map +1 -1
  18. package/dist/remote.js +4 -0
  19. package/dist/remote.js.map +1 -1
  20. package/dist/session.d.ts +2 -0
  21. package/dist/session.js +133 -13
  22. package/dist/session.js.map +1 -1
  23. package/dist/source.d.ts +2 -10
  24. package/dist/source.js.map +1 -1
  25. package/dist/update.d.ts +8 -20
  26. package/dist/update.js +12 -1
  27. package/dist/update.js.map +1 -1
  28. package/package.json +4 -2
  29. package/plugins/approval/index.ts +233 -85
  30. package/plugins/approval/plugin.json +1 -1
  31. package/plugins/approval/policy.ts +2 -1
  32. package/plugins/approval/review.ts +1 -1
  33. package/plugins/ask/index.ts +2 -2
  34. package/plugins/budget/index.ts +1 -1
  35. package/plugins/checks/checks.ts +3 -2
  36. package/plugins/checks/index.ts +2 -5
  37. package/plugins/commands/index.ts +2 -44
  38. package/plugins/compact/compact.ts +8 -3
  39. package/plugins/compact/index.ts +13 -16
  40. package/plugins/continue/index.ts +1 -1
  41. package/plugins/cost/index.ts +143 -0
  42. package/plugins/cost/plugin.json +13 -0
  43. package/plugins/custom-commands/index.ts +85 -0
  44. package/plugins/custom-commands/plugin.json +8 -0
  45. package/plugins/editor/index.ts +88 -0
  46. package/plugins/editor/plugin.json +17 -0
  47. package/plugins/fs/fs.ts +33 -6
  48. package/plugins/fs/grep.ts +6 -4
  49. package/plugins/fs/index.ts +2 -3
  50. package/plugins/fs/renderers.ts +1 -1
  51. package/plugins/hooks/index.ts +152 -0
  52. package/plugins/hooks/plugin.json +14 -0
  53. package/plugins/keys/index.ts +2 -18
  54. package/plugins/mcp/index.ts +40 -12
  55. package/plugins/mcp/install.ts +139 -0
  56. package/plugins/mcp/mcp.ts +2 -1
  57. package/plugins/mcp/plugin.json +1 -1
  58. package/plugins/mcp/project.ts +37 -1
  59. package/plugins/memory/index.ts +4 -9
  60. package/plugins/memory/plugin.json +1 -1
  61. package/plugins/mentions/index.ts +2 -2
  62. package/plugins/models/configure.ts +258 -150
  63. package/plugins/models/context.ts +2 -2
  64. package/plugins/models/index.ts +35 -42
  65. package/plugins/models/plugin.json +1 -1
  66. package/plugins/models/provider.ts +22 -4
  67. package/plugins/models/saved.ts +8 -4
  68. package/plugins/modes/index.ts +2 -17
  69. package/plugins/plugins/index.ts +2 -2
  70. package/plugins/print/index.ts +36 -6
  71. package/plugins/print/plugin.json +1 -0
  72. package/plugins/prompts/index.ts +22 -14
  73. package/plugins/{memory → prompts}/notes.ts +21 -9
  74. package/plugins/prompts/plugin.json +8 -2
  75. package/plugins/prompts/prompts.ts +5 -4
  76. package/plugins/renderers/index.ts +2 -43
  77. package/plugins/repeats/index.ts +1 -1
  78. package/plugins/schedule/index.ts +2 -2
  79. package/plugins/scratch/index.ts +2 -3
  80. package/plugins/screenshot/index.ts +26 -13
  81. package/plugins/screenshot/plugin.json +1 -1
  82. package/plugins/sessions/index.ts +2 -17
  83. package/plugins/shell/index.ts +56 -6
  84. package/plugins/shell/plugin.json +3 -1
  85. package/plugins/shell/renderers.ts +1 -1
  86. package/plugins/shell/service.ts +2 -13
  87. package/plugins/shell/shell.ts +31 -16
  88. package/plugins/skills/index.ts +172 -37
  89. package/plugins/skills/install.ts +212 -0
  90. package/plugins/skills/plugin.json +3 -2
  91. package/plugins/skills/project.ts +38 -1
  92. package/plugins/skills/skills.ts +28 -9
  93. package/plugins/steer/index.ts +142 -0
  94. package/plugins/steer/plugin.json +8 -0
  95. package/plugins/suggest/index.ts +16 -11
  96. package/plugins/suggest/plugin.json +1 -1
  97. package/plugins/task/index.ts +7 -16
  98. package/plugins/task/plugin.json +9 -2
  99. package/plugins/task/subagent.ts +23 -5
  100. package/plugins/todo/index.ts +2 -2
  101. package/plugins/tui/editor.ts +10 -2
  102. package/plugins/tui/frontend.ts +103 -21
  103. package/plugins/tui/index.ts +3 -8
  104. package/plugins/tui/markdown.ts +51 -6
  105. package/plugins/tui/mascot.ts +505 -0
  106. package/plugins/tui/plugin.json +2 -2
  107. package/plugins/tui/screen.ts +6 -0
  108. package/plugins/tui/transcript.ts +17 -2
  109. package/plugins/tui/tui.ts +321 -90
  110. package/plugins/undo/checkpoint.ts +2 -2
  111. package/plugins/undo/index.ts +84 -26
  112. package/plugins/undo/plugin.json +8 -2
  113. package/plugins/undo/snapshot.ts +129 -0
  114. package/plugins/update/index.ts +11 -15
  115. package/plugins/update/plugin.json +2 -1
  116. package/plugins/web/index.ts +2 -5
  117. package/plugins/web/renderers.ts +1 -1
  118. package/plugins-dist/approval/index.js +217 -51
  119. package/plugins-dist/approval/plugin.json +1 -1
  120. package/plugins-dist/ask/index.js +1 -1
  121. package/plugins-dist/budget/index.js +1 -1
  122. package/plugins-dist/checks/checks.js +2 -1
  123. package/plugins-dist/checks/index.js +1 -1
  124. package/plugins-dist/commands/index.js +1 -1
  125. package/plugins-dist/compact/compact.js +6 -1
  126. package/plugins-dist/compact/index.js +12 -8
  127. package/plugins-dist/continue/index.js +1 -1
  128. package/plugins-dist/cost/index.js +135 -0
  129. package/plugins-dist/cost/plugin.json +16 -0
  130. package/plugins-dist/custom-commands/index.js +86 -0
  131. package/plugins-dist/custom-commands/plugin.json +12 -0
  132. package/plugins-dist/editor/index.js +89 -0
  133. package/plugins-dist/editor/plugin.json +21 -0
  134. package/plugins-dist/fs/fs.js +34 -6
  135. package/plugins-dist/fs/grep.js +5 -3
  136. package/plugins-dist/fs/index.js +1 -1
  137. package/plugins-dist/hooks/index.js +145 -0
  138. package/plugins-dist/hooks/plugin.json +19 -0
  139. package/plugins-dist/keys/index.js +1 -1
  140. package/plugins-dist/mcp/index.js +41 -9
  141. package/plugins-dist/mcp/install.js +160 -0
  142. package/plugins-dist/mcp/mcp.js +2 -1
  143. package/plugins-dist/mcp/plugin.json +2 -1
  144. package/plugins-dist/mcp/project.js +42 -1
  145. package/plugins-dist/memory/index.js +3 -5
  146. package/plugins-dist/memory/plugin.json +1 -1
  147. package/plugins-dist/mentions/index.js +1 -1
  148. package/plugins-dist/models/configure.js +252 -151
  149. package/plugins-dist/models/context.js +2 -2
  150. package/plugins-dist/models/index.js +37 -14
  151. package/plugins-dist/models/plugin.json +1 -1
  152. package/plugins-dist/models/provider.js +4 -2
  153. package/plugins-dist/models/saved.js +9 -4
  154. package/plugins-dist/modes/index.js +1 -1
  155. package/plugins-dist/plugins/index.js +1 -1
  156. package/plugins-dist/print/index.js +37 -3
  157. package/plugins-dist/print/plugin.json +3 -0
  158. package/plugins-dist/prompts/index.js +22 -3
  159. package/plugins-dist/{memory → prompts}/notes.js +10 -7
  160. package/plugins-dist/prompts/plugin.json +8 -2
  161. package/plugins-dist/prompts/prompts.js +5 -4
  162. package/plugins-dist/renderers/index.js +1 -1
  163. package/plugins-dist/repeats/index.js +1 -1
  164. package/plugins-dist/schedule/index.js +1 -1
  165. package/plugins-dist/scratch/index.js +1 -1
  166. package/plugins-dist/screenshot/index.js +25 -11
  167. package/plugins-dist/screenshot/plugin.json +1 -1
  168. package/plugins-dist/sessions/index.js +1 -1
  169. package/plugins-dist/shell/index.js +55 -3
  170. package/plugins-dist/shell/plugin.json +3 -1
  171. package/plugins-dist/shell/shell.js +26 -8
  172. package/plugins-dist/skills/index.js +184 -35
  173. package/plugins-dist/skills/install.js +178 -0
  174. package/plugins-dist/skills/plugin.json +6 -2
  175. package/plugins-dist/skills/project.js +43 -1
  176. package/plugins-dist/skills/skills.js +27 -10
  177. package/plugins-dist/steer/index.js +135 -0
  178. package/plugins-dist/steer/plugin.json +12 -0
  179. package/plugins-dist/suggest/index.js +15 -9
  180. package/plugins-dist/suggest/plugin.json +1 -1
  181. package/plugins-dist/task/index.js +6 -4
  182. package/plugins-dist/task/plugin.json +10 -2
  183. package/plugins-dist/task/subagent.js +20 -5
  184. package/plugins-dist/todo/index.js +1 -1
  185. package/plugins-dist/tui/editor.js +7 -2
  186. package/plugins-dist/tui/frontend.js +107 -13
  187. package/plugins-dist/tui/index.js +2 -1
  188. package/plugins-dist/tui/markdown.js +48 -6
  189. package/plugins-dist/tui/mascot.js +439 -0
  190. package/plugins-dist/tui/plugin.json +3 -2
  191. package/plugins-dist/tui/screen.js +2 -0
  192. package/plugins-dist/tui/transcript.js +16 -1
  193. package/plugins-dist/tui/tui.js +302 -81
  194. package/plugins-dist/undo/checkpoint.js +1 -1
  195. package/plugins-dist/undo/index.js +91 -24
  196. package/plugins-dist/undo/plugin.json +10 -3
  197. package/plugins-dist/undo/snapshot.js +111 -0
  198. package/plugins-dist/update/index.js +9 -10
  199. package/plugins-dist/update/plugin.json +4 -1
  200. package/plugins-dist/web/index.js +1 -1
  201. package/sdk/python/__pycache__/jade_plugin.cpython-312.pyc +0 -0
  202. package/sdk/python/jade_plugin.py +8 -0
  203. package/src/api.ts +7 -262
  204. package/src/fetch.ts +18 -16
  205. package/src/host.ts +49 -1
  206. package/src/index.ts +1 -1
  207. package/src/main.ts +23 -5
  208. package/src/remote.ts +2 -0
  209. package/src/session.ts +134 -15
  210. package/src/source.ts +2 -11
  211. package/src/update.ts +16 -10
  212. package/plugins/undo/notes.ts +0 -43
  213. package/plugins-dist/undo/notes.js +0 -36
@@ -6,40 +6,13 @@
6
6
 
7
7
  import path from "node:path";
8
8
  import type { ModelRequest, ModelResponse, Provider } from "uncarved";
9
- import { definePlugin, type UI } from "../../src/api.ts";
10
- import type { Commands } from "../commands/index.ts";
9
+ import { definePlugin, type UI } from "@uncarved/jade-api";
10
+ import type { Commands, Models } from "@uncarved/jade-api/services";
11
11
  import { contextWindow } from "./context.ts";
12
12
  import { envWithFile, hasProvider, parseTokens } from "./config.ts";
13
13
  import { configurator } from "./configure.ts";
14
- import { isBuiltinKind, listModels, MODEL_KEY, providerFromEnv, providerInfo, providerKind, RateGate, rpmFromEnv, visionFromEnv, withRetry } from "./provider.ts";
15
- import { readSavedServices, type Env } from "./saved.ts";
16
-
17
- /** models@1 */
18
- export interface Models {
19
- /** 当前配置的服务和模型;没有配置时 undefined。via 是给人看的服务说明,例如 "the Anthropic API" */
20
- current(): {
21
- kind: string;
22
- model: string;
23
- via: string;
24
- /** 上下文窗口(token) */
25
- contextWindow: number;
26
- /** 模型能不能看图片(JADE_VISION;不设时按服务推断) */
27
- vision: boolean;
28
- /** 每次回复的输出上限(JADE_MAX_TOKENS,含 .env 里的);不设或写错时没有,用服务的默认值 */
29
- maxTokens?: number;
30
- } | undefined;
31
- /**
32
- * 完成一次请求,带重试和限速。默认用当前配置的模型(限速和会话共用);
33
- * model 是 /model 保存过的模型名($JADE_HOME/models.json),用它和它自己的设置,找不到时报错
34
- */
35
- complete(request: ModelRequest, options: { signal: AbortSignal; onDelta?: (delta: import("uncarved").Delta) => void; model?: string }): Promise<ModelResponse>;
36
- /** 服务提供的模型列表;不支持或出错时为空 */
37
- list(): Promise<string[]>;
38
- /** /model 保存过的模型名(complete 的 model 能用的那些),最近用过的在前 */
39
- saved?(): Promise<string[]>;
40
- /** 配置换了(/model)时调用,返回取消订阅。前端用它更新状态栏 */
41
- subscribe?(fn: () => void): () => void;
42
- }
14
+ import { isBuiltinKind, listModels, MODEL_KEY, providerFromEnv, providerInfo, providerKind, RateGate, rpmFromEnv, visionFromEnv, withRetry, type RetriedResponse } from "./provider.ts";
15
+ import { MODEL_SETTINGS, readSavedServices, type Env } from "./saved.ts";
43
16
 
44
17
  export default definePlugin({
45
18
  async process(ctx) {
@@ -95,24 +68,32 @@ export default definePlugin({
95
68
 
96
69
  /** 保存过的模型的 provider,按配置缓存:models.json 里的密钥或设置改了就另建一份 */
97
70
  const savedProviders = new Map<string, Promise<Provider>>();
71
+ const cachedBuild = (snapshot: Env): Promise<Provider> => {
72
+ const key = JSON.stringify(snapshot);
73
+ const cached = savedProviders.get(key);
74
+ if (cached) return cached;
75
+ const p = build(snapshot);
76
+ savedProviders.set(key, p);
77
+ // 创建失败时下次重试
78
+ p.catch(() => savedProviders.delete(key));
79
+ return p;
80
+ };
98
81
  const saved = async (name: string): Promise<Provider> => {
99
82
  for (const s of await readSavedServices(modelsFile)) {
100
83
  const m = s.models.find((x) => x.name === name);
101
84
  const kind = providerKind(s.env);
102
85
  if (!m || !isBuiltinKind(kind)) continue;
103
- const snapshot: Env = { ...s.env, ...m.settings, JADE_PROVIDER: kind, [MODEL_KEY[kind]]: m.name };
104
- const key = JSON.stringify(snapshot);
105
- const cached = savedProviders.get(key);
106
- if (cached) return cached;
107
- const p = build(snapshot);
108
- savedProviders.set(key, p);
109
- // 创建失败时下次重试
110
- p.catch(() => savedProviders.delete(key));
111
- return p;
86
+ return cachedBuild({ ...s.env, ...m.settings, JADE_PROVIDER: kind, [MODEL_KEY[kind]]: m.name });
112
87
  }
88
+ if (!hasProvider(env)) throw notConfigured();
113
89
  // 只写在 .env 里、没保存过的当前模型
114
- if (hasProvider(env) && providerInfo(env).model === name) return provider();
115
- throw new Error(`model ${JSON.stringify(name)} is not one of the models saved by /model (${modelsFile})`);
90
+ if (providerInfo(env).model === name) return provider();
91
+ // 当前服务上的另一个模型(没保存过):用这个服务的地址和密钥,不带当前模型自己的设置,用服务的默认值
92
+ const kind = providerKind(env);
93
+ if (!isBuiltinKind(kind)) throw new Error(`model ${JSON.stringify(name)} is not one of the models saved by /model (${modelsFile})`);
94
+ const snapshot: Env = { ...env, JADE_PROVIDER: kind, [MODEL_KEY[kind]]: name };
95
+ for (const k of MODEL_SETTINGS) delete snapshot[k];
96
+ return cachedBuild(snapshot);
116
97
  };
117
98
 
118
99
  const current: Provider["complete"] = (request, options) => provider().then((p) => p.complete(request, options));
@@ -195,6 +176,18 @@ export default definePlugin({
195
176
  },
196
177
  });
197
178
  },
179
+
180
+ session(ctx) {
181
+ // 重试过的请求:把每次失败写进会话日志,事后能查到为什么慢、为什么重新输出(插件事件,不进上下文)
182
+ ctx.kernel.hook({
183
+ kind: "observe",
184
+ point: "model.after",
185
+ fn: async (res, hook) => {
186
+ const retries = (res as RetriedResponse).retries;
187
+ if (retries?.length) await hook.emit("retried", { retries });
188
+ },
189
+ });
190
+ },
198
191
  });
199
192
 
200
193
  function via(kind: string, baseURL: string | undefined): string {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "jade/models",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "api": "^1",
5
5
  "entry": "./index.ts",
6
6
  "provides": ["provider@1", "models@1"],
@@ -1,6 +1,6 @@
1
1
  // Provider:按环境变量选择,外面包一层重试(4.7:重试是包装 Provider 的事)。
2
2
 
3
- import { ProviderError, type Provider } from "uncarved";
3
+ import { ProviderError, type ModelResponse, type Provider } from "uncarved";
4
4
  import { parseTokens } from "./config.ts";
5
5
 
6
6
  /** 默认的重试等待:一次比一次久,最长 3 分钟 */
@@ -33,6 +33,22 @@ export const isRateLimit = (err: ProviderError) => err.status === 429 || /\b429\
33
33
  */
34
34
  export const isConcurrencyLimit = (err: ProviderError) => /concurren/i.test(err.message);
35
35
 
36
+ /** 重试过的请求里每次失败的记录 */
37
+ export interface RetryRecord {
38
+ attempt: number;
39
+ delayMs: number;
40
+ error: string;
41
+ status?: number;
42
+ /** 失败前已经输出了一部分(界面上标了作废) */
43
+ discarded?: true;
44
+ }
45
+
46
+ /**
47
+ * withRetry 的回复:重试过时带上失败的记录。核心写日志时只取回复的 content、stopReason、usage,
48
+ * 这一项进不了上下文;jade/models 在 model.after 里把它写成插件事件
49
+ */
50
+ export type RetriedResponse = ModelResponse & { retries?: RetryRecord[] };
51
+
36
52
  export function withRetry(inner: Provider, opts: RetryOptions = {}): Provider {
37
53
  const delays = opts.delaysMs ?? RETRY_DELAYS_MS;
38
54
  const retries = opts.retries ?? delays.length;
@@ -40,7 +56,8 @@ export function withRetry(inner: Provider, opts: RetryOptions = {}): Provider {
40
56
  const random = opts.random ?? Math.random;
41
57
  return {
42
58
  id: `retry(${inner.id})`,
43
- async complete(request, options) {
59
+ async complete(request, options): Promise<RetriedResponse> {
60
+ const failures: RetryRecord[] = [];
44
61
  for (let attempt = 1; ; attempt++) {
45
62
  let streamed = false;
46
63
  await opts.gate?.acquire(options.signal);
@@ -54,7 +71,7 @@ export function withRetry(inner: Provider, opts: RetryOptions = {}): Provider {
54
71
  },
55
72
  });
56
73
  // 实际回复的是被包装者(4.7 第 3 款)
57
- return { ...res, provider: res.provider ?? inner.id };
74
+ return { ...res, provider: res.provider ?? inner.id, ...(failures.length > 0 ? { retries: failures } : {}) };
58
75
  } catch (err) {
59
76
  if (!(err instanceof ProviderError) || !err.retryable || attempt > retries || options.signal.aborted) throw err;
60
77
  // 在计划的时间上随机缩短最多 20%,并行的子 Agent 同时遇到 429 时不会同时重试。
@@ -66,6 +83,7 @@ export function withRetry(inner: Provider, opts: RetryOptions = {}): Provider {
66
83
  if (isRateLimit(err)) opts.gate?.limited(delayMs, { learn: !isConcurrencyLimit(err) });
67
84
  // 失败的这次已经推送过增量的,先让订阅者作废它们(4.7)
68
85
  if (streamed) options.onDelta?.({ kind: "reset" });
86
+ failures.push({ attempt, delayMs, error: err.message, ...(err.status !== undefined ? { status: err.status } : {}), ...(streamed ? { discarded: true as const } : {}) });
69
87
  opts.onRetry?.({ attempt, retries, delayMs, error: err });
70
88
  await sleep(delayMs, options.signal);
71
89
  }
@@ -351,7 +369,7 @@ export async function listModels(env: Env = process.env, fetchImpl: typeof fetch
351
369
  }
352
370
  }
353
371
 
354
- function jsonObject(name: string, text: string): Record<string, unknown> {
372
+ export function jsonObject(name: string, text: string): Record<string, unknown> {
355
373
  let value: unknown;
356
374
  try {
357
375
  value = JSON.parse(text);
@@ -1,5 +1,5 @@
1
1
  // 保存过的模型:$JADE_HOME/models.json。同一个服务(类型、地址、密钥都相同)只存一份,下面是在它上面用过的模型,
2
- // 每个模型带自己的设置(输出上限、思考力度、上下文窗口)。.env 里始终是当前用的那一个,这里记着用过的全部,
2
+ // 每个模型带自己的设置(输出上限、思考力度、上下文窗口、openai-compat 的额外请求参数等)。.env 里始终是当前用的那一个,这里记着用过的全部,
3
3
  // /model 可以切回去。
4
4
 
5
5
  import { mkdir, readFile, writeFile } from "node:fs/promises";
@@ -8,7 +8,7 @@ import path from "node:path";
8
8
  export type Env = Record<string, string | undefined>;
9
9
 
10
10
  /** 每个模型自己的设置:切换模型时一起换掉 */
11
- export const MODEL_SETTINGS = ["JADE_MAX_TOKENS", "JADE_EFFORT", "JADE_CONTEXT_WINDOW", "JADE_RPM", "JADE_VISION"];
11
+ export const MODEL_SETTINGS = ["JADE_MAX_TOKENS", "JADE_EFFORT", "JADE_CONTEXT_WINDOW", "JADE_RPM", "JADE_VISION", "OPENAI_COMPAT_EXTRA_BODY"];
12
12
 
13
13
  export interface SavedModel {
14
14
  name: string;
@@ -34,11 +34,15 @@ export async function readSavedServices(file: string): Promise<SavedService[]> {
34
34
  return data.services.flatMap((raw: unknown) => {
35
35
  const s = raw as { env?: unknown; models?: unknown } | null;
36
36
  if (!s || !Array.isArray(s.models)) return [];
37
+ // 以前额外请求参数存在服务上:分给它下面没有自己那份的模型
38
+ const { OPENAI_COMPAT_EXTRA_BODY: extraBody, ...env } = strings(s.env);
37
39
  const models = s.models.flatMap((m: unknown) => {
38
40
  const name = (m as { name?: unknown } | null)?.name;
39
- return typeof name === "string" && name ? [{ name, settings: strings((m as { settings?: unknown }).settings) }] : [];
41
+ const settings = strings((m as { settings?: unknown }).settings);
42
+ if (extraBody && settings.OPENAI_COMPAT_EXTRA_BODY === undefined) settings.OPENAI_COMPAT_EXTRA_BODY = extraBody;
43
+ return typeof name === "string" && name ? [{ name, settings }] : [];
40
44
  });
41
- return models.length ? [{ env: strings(s.env), models }] : [];
45
+ return models.length ? [{ env, models }] : [];
42
46
  });
43
47
  } catch {
44
48
  return [];
@@ -10,23 +10,8 @@
10
10
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
11
11
  import path from "node:path";
12
12
  import type { Tool } from "uncarved";
13
- import { definePlugin, type UI } from "../../src/api.ts";
14
- import type { Approval } from "../approval/index.ts";
15
- import type { Commands } from "../commands/index.ts";
16
- import type { Keys } from "../keys/index.ts";
17
- import type { Prompts } from "../prompts/index.ts";
18
-
19
- /** modes@1 */
20
- export interface Modes {
21
- current(): string;
22
- list(): { name: string; description: string }[];
23
- /** 换模式,从下一个工具调用起生效 */
24
- set(mode: string): void;
25
- /** 换到轮换顺序里的下一个 */
26
- cycle(): string;
27
- /** 模式变化时调用,返回取消订阅的函数;调用方关闭时自动取消 */
28
- subscribe(fn: (mode: string) => void): () => void;
29
- }
13
+ import { definePlugin, type UI } from "@uncarved/jade-api";
14
+ import type { Approval, Commands, Keys, Modes, Prompts } from "@uncarved/jade-api/services";
30
15
 
31
16
  export const DESCRIPTIONS: Record<string, string> = {
32
17
  ask: "ask before edits and commands",
@@ -1,8 +1,8 @@
1
1
  // jade/plugins:/plugins 命令。列出这次启动里每个插件的状态和原因(failed、skipped、conflicted……),
2
2
  // 以及每个服务由谁提供。数据来自核心自己的 jade@1 服务,和救援 CLI `jade plugins list` 是同一份状态。
3
3
 
4
- import { definePlugin, type Jade } from "../../src/api.ts";
5
- import type { Commands } from "../commands/index.ts";
4
+ import { definePlugin, type Jade } from "@uncarved/jade-api";
5
+ import type { Commands } from "@uncarved/jade-api/services";
6
6
 
7
7
  export default definePlugin({
8
8
  process(ctx) {
@@ -1,16 +1,20 @@
1
1
  // jade/print:jade -p "<prompt>" 跑一轮就退出。模型的回复写到 stdout,工具调用和提示写到 stderr。
2
2
  // 不能向用户提问:ui@1 的 select 总是返回 undefined,要审批的调用由审批插件拒绝。
3
3
 
4
- import type { Block, LogEvent, RuntimeNotice } from "uncarved";
5
- import { definePlugin, type Frontend, type UI } from "../../src/api.ts";
4
+ import type { Block, LogEvent, RuntimeNotice, Usage } from "uncarved";
5
+ import { definePlugin, type Frontend, type UI } from "@uncarved/jade-api";
6
+ import type { SessionIndex } from "@uncarved/jade-api/services";
6
7
 
7
- const USAGE = `usage: jade -p <prompt> [--resume <session id>]
8
+ const USAGE = `usage: jade -p <prompt> [--resume <session id> | --continue] [--json]
8
9
  echo <prompt> | jade -p
9
10
  cat <file> | jade -p - <prompt>
10
11
 
11
12
  With "-", what comes in on stdin is added after the prompt (without a prompt, stdin is the prompt).
12
13
 
13
14
  Runs one prompt and exits. The reply goes to stdout; tool calls and notices go to stderr.
15
+ -c, --continue continues the most recent session in this directory.
16
+ --json prints one JSON object on stdout instead of the reply as it is written:
17
+ {"session", "result" (the final reply), "reason" (why the turn ended), "error"?, "usage"}
14
18
  Exit code: 0 when the turn ends normally, 1 on an error, 130 when interrupted.
15
19
  jade's own commands (plugins, update, --safe): jade help`;
16
20
 
@@ -23,6 +27,9 @@ const ui: UI = {
23
27
  input: async () => undefined,
24
28
  };
25
29
 
30
+ /** --continue 用:process() 里记下的工作目录和会话索引(jade/sessions 的 sessions@1,用到的时候取) */
31
+ let here: { cwd: string; index(): SessionIndex | undefined } | undefined;
32
+
26
33
  const frontend: Frontend = {
27
34
  async run({ argv, sessions }) {
28
35
  const args = parse(argv);
@@ -42,6 +49,14 @@ const frontend: Frontend = {
42
49
  return 2;
43
50
  }
44
51
 
52
+ if (args.cont) {
53
+ const latest = (await here?.index()?.list(here.cwd))?.[0]?.id;
54
+ if (!latest) {
55
+ process.stderr.write("jade: there is no earlier session in this directory to continue\n");
56
+ return 2;
57
+ }
58
+ args.resume = latest;
59
+ }
45
60
  let session: Awaited<ReturnType<typeof sessions.open>>;
46
61
  try {
47
62
  session = await sessions.open(args.resume ? { resume: args.resume } : {});
@@ -52,7 +67,11 @@ const frontend: Frontend = {
52
67
  }
53
68
  let ended: { reason: string; error?: string } | undefined;
54
69
  let midLine = false;
70
+ /** --json:回复不边写边打印,最后一次回复的正文和用量合计在结束时一起输出 */
71
+ let result = "";
72
+ const used: Required<Usage> = { inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 };
55
73
  const out = (text: string) => {
74
+ if (args.json) return;
56
75
  process.stdout.write(text);
57
76
  midLine = !text.endsWith("\n");
58
77
  };
@@ -66,7 +85,10 @@ const frontend: Frontend = {
66
85
  if (n.type !== "event") return;
67
86
  const e = n.event as LogEvent;
68
87
  if (e.type === "model.responded") {
69
- const content = (e.data as { content: Block[] }).content;
88
+ const { content, usage } = e.data as { content: Block[]; usage?: Usage };
89
+ const text = content.flatMap((b) => (b.kind === "text" ? [b.text] : [])).join("\n");
90
+ if (text) result = text;
91
+ for (const k of Object.keys(used) as (keyof Usage)[]) used[k] += usage?.[k] ?? 0;
70
92
  if (!streamed) for (const b of content) if (b.kind === "text") out(b.text);
71
93
  streamed = false;
72
94
  if (midLine) out("\n");
@@ -99,6 +121,10 @@ const frontend: Frontend = {
99
121
  if (midLine) out("\n");
100
122
  process.stderr.write(`session ${session.id}\n`);
101
123
  const end = ended as { reason: string; error?: string } | undefined;
124
+ if (args.json) {
125
+ const error = failure !== undefined ? errorText(failure) : end?.error;
126
+ process.stdout.write(`${JSON.stringify({ session: session.id, result, reason: end?.reason ?? "error", ...(error ? { error } : {}), usage: used })}\n`);
127
+ }
102
128
  if (end?.reason === "aborted") return 130;
103
129
  if (failure !== undefined || end?.reason === "error") {
104
130
  process.stderr.write(`error: ${failure !== undefined ? errorText(failure) : (end?.error ?? "the turn failed")}\n`);
@@ -110,19 +136,22 @@ const frontend: Frontend = {
110
136
 
111
137
  export default definePlugin({
112
138
  process(ctx) {
139
+ here = { cwd: ctx.cwd, index: () => ctx.service<SessionIndex>("sessions@1") };
113
140
  ctx.provide("ui@1", ui);
114
141
  ctx.provide("frontend@1", frontend);
115
142
  },
116
143
  });
117
144
 
118
- function parse(argv: readonly string[]): { prompt?: string; resume?: string; help?: boolean; stdin?: boolean } | string {
119
- const out: { prompt?: string; resume?: string; help?: boolean; stdin?: boolean } = {};
145
+ function parse(argv: readonly string[]): { prompt?: string; resume?: string; cont?: boolean; json?: boolean; help?: boolean; stdin?: boolean } | string {
146
+ const out: { prompt?: string; resume?: string; cont?: boolean; json?: boolean; help?: boolean; stdin?: boolean } = {};
120
147
  const words: string[] = [];
121
148
  for (let i = 0; i < argv.length; i++) {
122
149
  const a = argv[i]!;
123
150
  if (a === "-p" || a === "--print") continue;
124
151
  if (a === "-h" || a === "--help") out.help = true;
125
152
  else if (a === "-") out.stdin = true;
153
+ else if (a === "-c" || a === "--continue") out.cont = true;
154
+ else if (a === "--json") out.json = true;
126
155
  else if (a === "--resume") {
127
156
  const id = argv[++i];
128
157
  if (!id) return "--resume needs a session id";
@@ -130,6 +159,7 @@ function parse(argv: readonly string[]): { prompt?: string; resume?: string; hel
130
159
  } else if (a.startsWith("-")) return `unknown option ${a}`;
131
160
  else words.push(a);
132
161
  }
162
+ if (out.cont && out.resume) return "--continue and --resume both pick the session; use one of them";
133
163
  if (words.length > 0) out.prompt = words.join(" ");
134
164
  return out;
135
165
  }
@@ -4,5 +4,6 @@
4
4
  "api": "^1",
5
5
  "entry": "./index.ts",
6
6
  "provides": ["frontend@1", "ui@1"],
7
+ "optional": ["sessions@1"],
7
8
  "frontend": { "name": "print", "flag": "-p" }
8
9
  }
@@ -1,23 +1,16 @@
1
1
  // jade/prompts:在 context.build 里生成系统提示词。其他插件经 prompts@1 往里加段落。
2
- // 也负责内核不写的、给模型看的说明:内容为空的错误工具结果在投影里补一句原因(results.ts)。
2
+ // 也负责内核不写的、给模型看的说明:内容为空的错误工具结果在投影里补一句原因(results.ts);
3
+ // 其他插件经 prompts@1 的 note 给模型留一句说明(notes.ts)。
3
4
 
5
+ import os from "node:os";
4
6
  import path from "node:path";
5
7
  import type { ContentSource, LogEvent, SystemSegment } from "uncarved";
6
- import { definePlugin, type UI } from "../../src/api.ts";
7
- import type { Models } from "../models/index.ts";
8
+ import { definePlugin, type UI } from "@uncarved/jade-api";
9
+ import type { Models, PromptInstructions, Prompts } from "@uncarved/jade-api/services";
10
+ import { Notes } from "./notes.ts";
8
11
  import { allInstructions, environment, mainPrompt, realPath } from "./prompts.ts";
9
12
  import { explainEmptyResults, whyEmpty, type Reasons, type Why } from "./results.ts";
10
13
 
11
- /** prompts@1 */
12
- export interface Prompts {
13
- /**
14
- * 往系统提示词里加一段,排在主体、环境信息和指令文件之后,返回撤销函数;调用方的作用域关闭时自动撤销。
15
- * stable(默认 true)的段落排在 volatile 的前面:会变的段落放在后面,前面的才能命中提示缓存。
16
- * 项目层插件加的段落标为不可信;untrusted 为 true 时也标为不可信(内容来自外部,例如 MCP 服务的说明、仓库里的 skill)
17
- */
18
- add(section: { text: string; stable?: boolean; untrusted?: boolean }): () => void;
19
- }
20
-
21
14
  interface Section {
22
15
  plugin: string;
23
16
  text: string;
@@ -29,6 +22,10 @@ const ID = "jade/prompts";
29
22
 
30
23
  /** 其他插件加的段落。模块每个进程只加载一次,进程级和会话级共用 */
31
24
  const sections: Section[] = [];
25
+ /** 打开着的会话 → 它读到的指令文件(prompts@1.instructions) */
26
+ const loaded = new Map<string, PromptInstructions[]>();
27
+ /** 其他插件留给模型的说明 */
28
+ const notes = new Notes();
32
29
 
33
30
  function segment(text: string, trust: SystemSegment["trust"] = "trusted", stability: SystemSegment["stability"] = "stable", by = ID, source?: ContentSource): SystemSegment {
34
31
  return { text, stability, origin: { by: "plugin", id: by, ...(source ? { source } : {}) }, trust };
@@ -55,12 +52,20 @@ export default definePlugin({
55
52
  caller.onDispose(remove);
56
53
  return remove;
57
54
  },
55
+ note(session, text) {
56
+ if (typeof session !== "string" || !session) throw new Error("prompts.note: session must be a session id");
57
+ if (typeof text !== "string" || !text) throw new Error("prompts.note: text must be a non-empty string");
58
+ notes.add(session, { plugin: caller.plugin, text, trusted: caller.layer !== "project" });
59
+ },
60
+ instructions: (session) => (loaded.get(session) ?? []).map((i) => ({ ...i, source: { ...i.source } })),
58
61
  }));
59
62
  },
60
63
 
61
64
  async session(ctx) {
62
65
  const models = ctx.service<Models>("models@1");
63
- const [env, instructions] = await Promise.all([environment(ctx.cwd), allInstructions(ctx.home, ctx.cwd)]);
66
+ const [env, instructions] = await Promise.all([environment(ctx.cwd), allInstructions(ctx.home, ctx.cwd, ctx.config.claudeInstructions === false ? null : os.homedir())]);
67
+ loaded.set(ctx.session.id, instructions.map(({ text, trust, source }) => ({ text, trust, source })));
68
+ await ctx.effect(() => () => void loaded.delete(ctx.session.id));
64
69
  const fixed = [segment(env), ...instructions.map((i) => segment(i.text, i.trust, "stable", ID, i.source))];
65
70
  // 告诉用户读了哪些指令文件,否则看不出它们生效了
66
71
  if (instructions.length > 0) ctx.service<UI>("ui@1")?.notify(`loaded instructions: ${instructions.map((i) => display(realPath(ctx.cwd), i.file)).join(", ")}`);
@@ -91,6 +96,9 @@ export default definePlugin({
91
96
  fn: (messages, hook) => explainEmptyResults(messages, { ...(hook.derived[reasonsKey] as Reasons | undefined), ...reasons }, ID),
92
97
  });
93
98
 
99
+ ctx.kernel.hook(notes.hook(ctx.session.id, `${ID}/notes`));
100
+ await ctx.effect(() => () => notes.drop(ctx.session.id));
101
+
94
102
  ctx.kernel.hook({
95
103
  kind: "transform",
96
104
  point: "context.build",
@@ -1,23 +1,35 @@
1
- // 给模型的说明([Note from jade]):命令里做的事(例如用户删掉了一条记忆)要让模型知道,
2
- // 但命令拿不到会话日志,也不该替用户发一条消息。所以先记下来,下一次请求模型时在 context.project 里
1
+ // 给模型的说明([Note from jade],prompts@1 的 note):命令里做的事(例如用户删掉了一条记忆、撤销了模型改的文件)
2
+ // 要让模型知道,但命令拿不到会话日志,也不该替用户发一条消息。所以先记下来,下一次请求模型时在 context.project 里
3
3
  // 附在最后一条消息后面,并用 ctx.record 写进日志(derived):之后的投影、恢复的会话里它都在同一个位置。
4
- // 插件之间不共享代码,jade/undo 里也有一份。
5
4
 
6
5
  import type { Block, LocalHookSpec, Message } from "uncarved";
7
6
 
7
+ export interface Note {
8
+ /** 留下这条说明的插件 */
9
+ plugin: string;
10
+ text: string;
11
+ /** 项目层插件留的说明不可信 */
12
+ trusted: boolean;
13
+ }
14
+
8
15
  /** derived 里:消息的下标 → 附在它后面的说明 */
9
- type NotesState = Record<string, string[]>;
16
+ type NotesState = Record<string, Note[]>;
10
17
 
11
18
  export class Notes {
12
19
  /** 会话 → 还没交给模型的说明 */
13
- readonly #pending = new Map<string, string[]>();
20
+ readonly #pending = new Map<string, Note[]>();
21
+
22
+ add(sessionId: string, note: Note): void {
23
+ this.#pending.set(sessionId, [...(this.#pending.get(sessionId) ?? []), note]);
24
+ }
14
25
 
15
- add(sessionId: string, text: string): void {
16
- this.#pending.set(sessionId, [...(this.#pending.get(sessionId) ?? []), text]);
26
+ /** 会话关闭:还没交给模型的说明不再留着 */
27
+ drop(sessionId: string): void {
28
+ this.#pending.delete(sessionId);
17
29
  }
18
30
 
19
31
  /** 会话里的 context.project hook;key 是 derived 里的键 */
20
- hook(sessionId: string, plugin: string, key: string): LocalHookSpec {
32
+ hook(sessionId: string, key: string): LocalHookSpec {
21
33
  return {
22
34
  kind: "transform",
23
35
  point: "context.project",
@@ -34,7 +46,7 @@ export class Notes {
34
46
  return messages.map((m, i): Message => {
35
47
  const notes = state[i];
36
48
  if (!notes?.length || m.role !== "user") return m;
37
- const blocks: Block[] = notes.map((text) => ({ kind: "text", text: `[Note from jade] ${text}`, origin: { by: "plugin", id: plugin }, trust: "trusted" }));
49
+ const blocks: Block[] = notes.map((n) => ({ kind: "text", text: `[Note from jade] ${n.text}`, origin: { by: "plugin", id: n.plugin }, trust: n.trusted ? "trusted" : "untrusted" }));
38
50
  return { ...m, content: [...m.content, ...blocks] };
39
51
  });
40
52
  },
@@ -1,8 +1,14 @@
1
1
  {
2
2
  "id": "jade/prompts",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "api": "^1",
5
5
  "entry": "./index.ts",
6
6
  "provides": ["prompts@1"],
7
- "optional": ["models@1", "ui@1"]
7
+ "optional": ["models@1", "ui@1"],
8
+ "config": {
9
+ "claudeInstructions": {
10
+ "default": true,
11
+ "description": "when $JADE_HOME has no AGENTS.md or CLAUDE.md, use ~/.claude/CLAUDE.md as the user instructions; false turns this off"
12
+ }
13
+ }
8
14
  }
@@ -3,7 +3,8 @@
3
3
  // 主体和环境信息都是 stable:环境信息在会话开始时取一次,不在每次请求时更新,
4
4
  // 否则它一变,排在后面的整段历史都无法命中提示缓存。
5
5
  // 指令文件兼容 AGENTS.md 和 CLAUDE.md,同一目录两者都有时只读 AGENTS.md。
6
- // 用户层($JADE_HOME 里)的是 trusted;项目层(随仓库分发)的是 untrusted,并记下出处(宪法 7.2)。
6
+ // 用户层的先找 $JADE_HOME,没有时用 ~/.claude 里的(和 jade/skills 读 ~/.claude/skills 一样,已有的全局指令不用再抄一份)。
7
+ // 用户层的是 trusted;项目层(随仓库分发)的是 untrusted,并记下出处(宪法 7.2)。
7
8
  // 项目层从仓库根目录到工作目录逐级查找,上级的在前,离工作目录近的在后。
8
9
 
9
10
  import { createHash } from "node:crypto";
@@ -110,10 +111,10 @@ export interface Instructions {
110
111
  file: string;
111
112
  }
112
113
 
113
- /** 用户层(home 里)和项目层(仓库根目录到 cwd 逐级)的指令文件,按顺序 */
114
- export async function allInstructions(home: string, cwd: string): Promise<Instructions[]> {
114
+ /** 用户层(home 里,没有时 userHome/.claude 里;userHome 给 null 时不找)和项目层(仓库根目录到 cwd 逐级)的指令文件,按顺序 */
115
+ export async function allInstructions(home: string, cwd: string, userHome: string | null = os.homedir()): Promise<Instructions[]> {
115
116
  const out: Instructions[] = [];
116
- const user = await instructions(home, home, "user");
117
+ const user = (await instructions(home, home, "user")) ?? (userHome === null ? undefined : await instructions(userHome, path.join(userHome, ".claude"), "user"));
117
118
  if (user) out.push({ text: `# User instructions (${user.source.path})\n\n${user.text}`, trust: "trusted", source: user.source, file: user.file });
118
119
  const root = realPath(await repoRoot(cwd));
119
120
  for (const dir of ancestry(root, realPath(cwd))) {
@@ -1,49 +1,8 @@
1
1
  // jade/renderers:工具调用和插件事件在对话里怎么显示的注册表。前端查这里;没有登记的用前端的默认显示。
2
2
  // 显示的文字可以带 ANSI 颜色,前端负责过滤掉颜色之外的控制序列。
3
3
 
4
- import { definePlugin } from "../../src/api.ts";
5
-
6
- export interface ToolRenderer {
7
- tool: string;
8
- /** 调用行 "● 工具名(…)" 括号里的摘要,只显示第一行;默认是 path 参数或参数的 JSON */
9
- summary?(input: unknown): string | undefined;
10
- /** 摘要省略了的参数(例如很长的命令),展开调用行后显示在最前面,可以多行 */
11
- details?(input: unknown): string | undefined;
12
- /** 执行时显示的内容,代替默认的 "工具名(摘要)":第一行跟在 "● " 后面,其余的行原样显示在下面,不折叠 */
13
- call?(input: unknown): string | undefined;
14
- /**
15
- * 运行中的进度:工具用 ToolContext.progress 推送的一项换成一行,显示在对话的最后,工具结束时去掉;返回 undefined 不显示。
16
- * 没有这个函数时,{ text } 形式的进度按输出逐行显示,其他的不显示
17
- */
18
- progress?(update: unknown, call: { toolUseId: string; summary(tool: string, input: unknown): string }): string | undefined;
19
- /** 请用户批准时显示的预览,可以多行;默认是参数的 JSON */
20
- preview?(input: unknown): string | undefined | Promise<string | undefined>;
21
- /** 工具执行之前同步调用(例如记下修改前的文件,好在结果里显示 diff),返回值交给 result 的 before */
22
- before?(input: unknown): unknown;
23
- /**
24
- * 结果:line 接在调用行的 "⎿ " 后面(一行),details 是展开后的内容(可以多行);
25
- * 返回 null 时不显示结果;默认显示结果文字的第一行,多出的行折叠起来
26
- */
27
- result?(r: { toolUseId: string; input: unknown; text: string; isError: boolean; before?: unknown }): { line: string; details?: string } | null | undefined;
28
- }
29
-
30
- /** 插件自己的事件(hook 的 ctx.emit 写入的)怎么显示。只能为自己的事件注册:event 不带 "<插件 id>/" 前缀 */
31
- export interface EventRenderer {
32
- event: string;
33
- /** line 显示成一行,details 是展开后的内容;返回 undefined 时不显示 */
34
- render(data: unknown): { line: string; details?: string } | undefined;
35
- }
36
-
37
- export interface Renderers {
38
- /** 为一个工具登记显示方式,返回撤销函数。同一个工具已有登记时抛错 */
39
- tool(renderer: ToolRenderer): () => void;
40
- /** 为自己的一种事件登记显示方式,返回撤销函数 */
41
- event(renderer: EventRenderer): () => void;
42
- /** 前端查找 */
43
- forTool(tool: string): { renderer: ToolRenderer; plugin: string } | undefined;
44
- /** 前端按完整的事件类型("<插件 id>/<event>")查找 */
45
- forEvent(type: string): { renderer: EventRenderer; plugin: string } | undefined;
46
- }
4
+ import { definePlugin } from "@uncarved/jade-api";
5
+ import type { EventRenderer, Renderers, ToolRenderer } from "@uncarved/jade-api/services";
47
6
 
48
7
  const tools = new Map<string, { renderer: ToolRenderer; plugin: string }>();
49
8
  const events = new Map<string, { renderer: EventRenderer; plugin: string }>();
@@ -15,7 +15,7 @@
15
15
  import { createHash } from "node:crypto";
16
16
  import path from "node:path";
17
17
  import type { Block, GateResult, LocalHookSpec, LogEvent } from "uncarved";
18
- import { definePlugin } from "../../src/api.ts";
18
+ import { definePlugin } from "@uncarved/jade-api";
19
19
 
20
20
  const ID = "jade/repeats";
21
21
  /** jade/compact 记录压缩结果用的派生数据键(旧 jade 的约定):记一次就说明历史被压缩过 */
@@ -5,8 +5,8 @@
5
5
 
6
6
  import path from "node:path";
7
7
  import type { Tool, UserInput } from "uncarved";
8
- import { definePlugin, type UI } from "../../src/api.ts";
9
- import type { Commands } from "../commands/index.ts";
8
+ import { definePlugin, type UI } from "@uncarved/jade-api";
9
+ import type { Commands } from "@uncarved/jade-api/services";
10
10
  import { parseCron } from "./cron.ts";
11
11
  import { claimDue, nextAt, sameDir, ScheduleStore, type Task } from "./store.ts";
12
12
 
@@ -5,9 +5,8 @@ import { realpathSync } from "node:fs";
5
5
  import { mkdir } from "node:fs/promises";
6
6
  import os from "node:os";
7
7
  import path from "node:path";
8
- import { definePlugin } from "../../src/api.ts";
9
- import type { Approval } from "../approval/index.ts";
10
- import type { Prompts } from "../prompts/index.ts";
8
+ import { definePlugin } from "@uncarved/jade-api";
9
+ import type { Approval, Prompts } from "@uncarved/jade-api/services";
11
10
 
12
11
  /** 会话 id 对应的临时目录 */
13
12
  export const scratchDir = (session: string): string => path.join(os.tmpdir(), "jade-scratch", session);