@cortexkit/aft-opencode 0.59.0 → 0.60.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 (45) hide show
  1. package/dist/bg-notifications.d.ts +5 -0
  2. package/dist/bg-notifications.d.ts.map +1 -1
  3. package/dist/bridge-bootstrap.d.ts +3 -3
  4. package/dist/bridge-bootstrap.d.ts.map +1 -1
  5. package/dist/config-live-reload.d.ts.map +1 -1
  6. package/dist/config.d.ts +0 -4
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/entry/server.js +1402 -536
  9. package/dist/index.js +1288 -376
  10. package/dist/lsp-github-install.d.ts +7 -1
  11. package/dist/lsp-github-install.d.ts.map +1 -1
  12. package/dist/shared/status.d.ts +9 -4
  13. package/dist/shared/status.d.ts.map +1 -1
  14. package/dist/tool-registration.d.ts +3 -0
  15. package/dist/tool-registration.d.ts.map +1 -1
  16. package/dist/tools/_shared.d.ts +2 -5
  17. package/dist/tools/_shared.d.ts.map +1 -1
  18. package/dist/tools/bash.d.ts.map +1 -1
  19. package/dist/tools/bash_watch.d.ts.map +1 -1
  20. package/dist/tools/definitions/v2.d.ts +9 -1
  21. package/dist/tools/definitions/v2.d.ts.map +1 -1
  22. package/dist/tools/hoisted.d.ts.map +1 -1
  23. package/dist/tools/inspect.d.ts.map +1 -1
  24. package/dist/tui/v2-status.d.ts.map +1 -1
  25. package/dist/types.d.ts +7 -1
  26. package/dist/types.d.ts.map +1 -1
  27. package/dist/v2-host-tool-names.d.ts +43 -0
  28. package/dist/v2-host-tool-names.d.ts.map +1 -0
  29. package/dist/v2-session-lifecycle.d.ts +22 -0
  30. package/dist/v2-session-lifecycle.d.ts.map +1 -0
  31. package/dist/v2-tool-hooks.d.ts +14 -2
  32. package/dist/v2-tool-hooks.d.ts.map +1 -1
  33. package/dist/wakes/runtime-consumer.d.ts +6 -1
  34. package/dist/wakes/runtime-consumer.d.ts.map +1 -1
  35. package/dist/wakes/session-delivery.d.ts +12 -7
  36. package/dist/wakes/session-delivery.d.ts.map +1 -1
  37. package/package.json +8 -8
  38. package/src/entry/server-runtime.mjs +26 -14
  39. package/src/shared/status.ts +25 -4
  40. package/src/tui/v2-status.ts +1 -0
  41. package/src/tui/v2.tsx +7 -4
  42. package/src/tui-compiled/v2-status.ts +1 -0
  43. package/src/tui-compiled/v2.tsx +7 -4
  44. package/dist/v2-host-tool-overlap.d.ts +0 -66
  45. package/dist/v2-host-tool-overlap.d.ts.map +0 -1
@@ -64,11 +64,12 @@ export interface StatusBar {
64
64
  todos?: number;
65
65
  tier2_stale?: boolean;
66
66
  /**
67
- * `"no_language_server"` when no language server is running, so errors and
68
- * warnings will not arrive until one starts. Absent while the counts are
69
- * present or a running server has not reported yet.
67
+ * `no_language_server` means no server is running. `producer_missing`
68
+ * masks both counts when an expected project producer has failed, even if
69
+ * another server supplied counts; diagnostics_gaps identifies the failures.
70
70
  */
71
- diagnostics?: "no_language_server";
71
+ diagnostics?: "no_language_server" | "producer_missing";
72
+ diagnostics_gaps?: Array<{ language: string; producer: string; root: string }>;
72
73
  }
73
74
 
74
75
  export interface AftStatusSnapshot {
@@ -225,6 +226,22 @@ function readStatusBar(value: unknown): StatusBar | undefined {
225
226
  const duplicates = readOptionalNumber(bar.duplicates);
226
227
  const todos = readOptionalNumber(bar.todos);
227
228
  const noLanguageServer = bar.diagnostics === "no_language_server";
229
+ const producerMissing = bar.diagnostics === "producer_missing";
230
+ const diagnosticsGaps = Array.isArray(bar.diagnostics_gaps)
231
+ ? bar.diagnostics_gaps
232
+ .map(asRecord)
233
+ .filter(
234
+ (gap) =>
235
+ typeof gap.language === "string" &&
236
+ typeof gap.producer === "string" &&
237
+ typeof gap.root === "string",
238
+ )
239
+ .map((gap) => ({
240
+ language: gap.language as string,
241
+ producer: gap.producer as string,
242
+ root: gap.root as string,
243
+ }))
244
+ : [];
228
245
  if (
229
246
  errors === null &&
230
247
  warnings === null &&
@@ -233,6 +250,7 @@ function readStatusBar(value: unknown): StatusBar | undefined {
233
250
  duplicates === null &&
234
251
  todos === null &&
235
252
  !noLanguageServer &&
253
+ !producerMissing &&
236
254
  disabled.length === 0
237
255
  ) {
238
256
  return undefined;
@@ -247,6 +265,9 @@ function readStatusBar(value: unknown): StatusBar | undefined {
247
265
  ...(todos !== null ? { todos } : {}),
248
266
  ...(bar.tier2_stale === true ? { tier2_stale: true } : {}),
249
267
  ...(noLanguageServer ? { diagnostics: "no_language_server" as const } : {}),
268
+ ...(producerMissing
269
+ ? { diagnostics: "producer_missing" as const, diagnostics_gaps: diagnosticsGaps }
270
+ : {}),
250
271
  };
251
272
  }
252
273
 
@@ -12,6 +12,7 @@ function count(value: number | undefined, off = false): string {
12
12
  */
13
13
  function diagnosticsPart(bar: StatusBar): string {
14
14
  if (bar.disabled_categories?.includes("diagnostics")) return "E○ W○";
15
+ if (bar.diagnostics === "producer_missing") return "E? W?";
15
16
  if (
16
17
  bar.errors === undefined &&
17
18
  bar.warnings === undefined &&
package/src/tui/v2.tsx CHANGED
@@ -333,10 +333,13 @@ function AftStatusCommands(props: { context: V2TuiContext; rpc: AftRpcClient })
333
333
  const HOST_TOOL_OVERLAP_TOAST_MS = 15_000;
334
334
 
335
335
  /**
336
- * Show the server's one-off built-in tool overlap notice as a toast. A toast
337
- * reaches the person at the terminal and nothing else; the server sends this
338
- * at most once per host process, so every TUI subscribed at that moment shows
339
- * it once. A host without a toast surface shows nothing.
336
+ * Show a server's one-off built-in tool overlap notice as a toast. A toast
337
+ * reaches the person at the terminal and nothing else. The current server no
338
+ * longer sends this notice: on OpenCode 2 AFT registers its command and patch
339
+ * tools as `shell` and `patch`, replacing the host's built-ins instead of
340
+ * sitting beside them. The subscription stays so a TUI still shows the notice
341
+ * from an older AFT server running in the same host during an upgrade. A host
342
+ * without a toast surface shows nothing.
340
343
  */
341
344
  export function subscribeV2HostToolOverlapToast(
342
345
  context: Pick<V2TuiContext, "ui">,
@@ -12,6 +12,7 @@ function count(value: number | undefined, off = false): string {
12
12
  */
13
13
  function diagnosticsPart(bar: StatusBar): string {
14
14
  if (bar.disabled_categories?.includes("diagnostics")) return "E○ W○";
15
+ if (bar.diagnostics === "producer_missing") return "E? W?";
15
16
  if (
16
17
  bar.errors === undefined &&
17
18
  bar.warnings === undefined &&
@@ -251,10 +251,13 @@ function AftStatusCommands(props) {
251
251
  const HOST_TOOL_OVERLAP_TOAST_MS = 15_000;
252
252
 
253
253
  /**
254
- * Show the server's one-off built-in tool overlap notice as a toast. A toast
255
- * reaches the person at the terminal and nothing else; the server sends this
256
- * at most once per host process, so every TUI subscribed at that moment shows
257
- * it once. A host without a toast surface shows nothing.
254
+ * Show a server's one-off built-in tool overlap notice as a toast. A toast
255
+ * reaches the person at the terminal and nothing else. The current server no
256
+ * longer sends this notice: on OpenCode 2 AFT registers its command and patch
257
+ * tools as `shell` and `patch`, replacing the host's built-ins instead of
258
+ * sitting beside them. The subscription stays so a TUI still shows the notice
259
+ * from an older AFT server running in the same host during an upgrade. A host
260
+ * without a toast surface shows nothing.
258
261
  */
259
262
  export function subscribeV2HostToolOverlapToast(context, rpc, options) {
260
263
  return rpc.events.on("hostToolOverlap", event => {
@@ -1,66 +0,0 @@
1
- /**
2
- * On OpenCode 2, AFT's `apply_patch` and `bash` sit beside the host's own
3
- * `patch` and `shell` tools unless the user's opencode config turns the host
4
- * plugins off (`-opencode.tool.patch` / `-opencode.tool.shell` under
5
- * `plugins`, which `aft setup` and `aft doctor --fix` write). Someone who
6
- * installed AFT without setup, or turned the host tools back on, gets two
7
- * editing tools and two shells with nothing saying why. This module tells the
8
- * user once per host process and points at `doctor --fix`.
9
- *
10
- * What counts is what the host actually registered: `context.tool.list()`
11
- * returns the host's tools after every plugin's transform, keyed by the name
12
- * the model sees. The check waits for the first user prompt rather than
13
- * running at plugin start, because at start other plugins (the host's own
14
- * patch and shell plugins included) may not have registered yet, and because
15
- * the notice is an RPC event the host does not replay: a TUI that has not
16
- * subscribed yet would miss it, while a prompt typed into the TUI proves its
17
- * subscription is live. A host without `tool.list()`
18
- * (OpenCode 2.0.3 has none) or a list call that fails gets no notice: the
19
- * reason is logged once at debug level and nothing is guessed.
20
- *
21
- * The notice must reach the user and never the model. Nothing is written into
22
- * the session: OpenCode 2 sends a synthetic session record to the model as a
23
- * user message on every later turn, where a notice would read as an
24
- * instruction. A server plugin has no toast or dialog of its own, so the
25
- * notice goes out as an AFT RPC event and AFT's OpenCode 2 TUI plugin shows
26
- * it as a toast. The desktop and web apps run no TUI plugin and show nothing;
27
- * `aft doctor` reports the same problem there.
28
- */
29
- import { Effect } from "effect";
30
- /** An AFT tool and the OpenCode 2 built-in that does the same job. */
31
- export interface HostToolOverlap {
32
- readonly aft: "apply_patch" | "bash";
33
- readonly host: "patch" | "shell";
34
- }
35
- /**
36
- * The pairs where AFT registered its tool (it is not in `disabled_tools`) and
37
- * the host also has its built-in, in a fixed order. `hostToolNames` is the
38
- * host's whole registry after every transform, AFT's own tools included, so a
39
- * name AFT registered itself is never taken for the host's built-in.
40
- */
41
- export declare function findHostToolOverlaps(hostToolNames: ReadonlySet<string>, registeredAftTools: ReadonlySet<string>): HostToolOverlap[];
42
- /** One notice for every overlapping pair, or null when there is none. */
43
- export declare function hostToolOverlapNotice(overlaps: readonly HostToolOverlap[]): string | null;
44
- /** Reset the once-per-process state. Tests only. */
45
- export declare function __resetHostToolOverlapNoticeForTests(): void;
46
- interface PromptEvent {
47
- readonly sessionID: string;
48
- readonly metadata?: Record<string, unknown>;
49
- }
50
- /** Hands the notice text to the user-only channel (the TUI toast event). */
51
- export type HostToolOverlapDelivery = (message: string) => Promise<void>;
52
- /**
53
- * The session `prompt` hook for one Location. It never fails and never waits:
54
- * the host holds the prompt until the hook returns, so the check runs in the
55
- * background after it.
56
- */
57
- export declare function createHostToolOverlapPromptHook(context: unknown, registeredAftTools: ReadonlySet<string>, deliver: HostToolOverlapDelivery, onChecked?: (done: Promise<void>) => void): (event: PromptEvent) => Effect.Effect<void>;
58
- /**
59
- * Register the overlap check on an OpenCode 2 host's session `prompt` hook.
60
- * `registeredAftTools` is AFT's final tool surface, so a tool listed in
61
- * `disabled_tools` never counts as an overlap. `deliver` must reach the user
62
- * only, never the session.
63
- */
64
- export declare function registerV2HostToolOverlapNotice(context: unknown, registeredAftTools: ReadonlySet<string>, deliver: HostToolOverlapDelivery, onChecked?: (done: Promise<void>) => void): Effect.Effect<boolean, never, unknown>;
65
- export {};
66
- //# sourceMappingURL=v2-host-tool-overlap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v2-host-tool-overlap.d.ts","sourceRoot":"","sources":["../src/v2-host-tool-overlap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,sEAAsE;AACtE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;CAClC;AASD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,EAClC,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,GACtC,eAAe,EAAE,CAOnB;AAED,yEAAyE;AACzE,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,GAAG,IAAI,CAazF;AAQD,oDAAoD;AACpD,wBAAgB,oCAAoC,IAAI,IAAI,CAG3D;AAwDD,UAAU,WAAW;IACnB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED,4EAA4E;AAC5E,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAgCzE;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,OAAO,EAChB,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,EACvC,OAAO,EAAE,uBAAuB,EAChC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,GACxC,CAAC,KAAK,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAe7C;AAOD;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,OAAO,EAChB,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,EACvC,OAAO,EAAE,uBAAuB,EAChC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,GACxC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAkBxC"}