@sweny-ai/core 0.1.95 → 0.1.96

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.
@@ -1,19 +1,19 @@
1
1
  import type { Observer } from "../types.js";
2
2
  /**
3
- * Create an observer that prints each tool call's input and output to stderr
4
- * in a human-readable form. Useful when debugging a node that fails or routes
5
- * unexpectedly — the default human output only shows step transitions,
6
- * leaving "why" invisible.
3
+ * Create an observer that prints, on `node:exit`:
4
+ * 1. Every tool call's input and output (truncated).
5
+ * 2. The node's structured output (`result.data`) — the payload that
6
+ * conditional edges route on. Without this, "validate → notify_halt"
7
+ * with no failing checks looks like a paradox; with it, you can see
8
+ * that the node emitted `{ status: "fail" }` and root-cause the wrong
9
+ * decision.
7
10
  *
8
- * Emission strategy: print the full call list on `node:exit` rather than per
9
- * `tool:call`/`tool:result` event. The reason: the executor's tool:call and
10
- * tool:result events fire only for skill-registered tools, not for the
11
- * Claude Code subprocess's built-in tools (Bash, Read, Edit, etc.). Those
12
- * built-in tools — the ones agents actually use most — land in
13
- * `result.toolCalls` only after the node completes. Walking result.toolCalls
14
- * on node:exit covers both kinds and avoids partial visibility.
11
+ * Both kinds of tools are covered (skill-registered AND Claude Code's
12
+ * built-in Bash/Read/Edit/Write), because `result.toolCalls` is populated
13
+ * after the node completes regardless of how the call was dispatched.
15
14
  *
16
- * Inputs and outputs are truncated; use `--stream` for full untruncated
17
- * NDJSON.
15
+ * Truncation defaults to 4000 chars per side. Override with the
16
+ * `SWENY_VERBOSE_TRUNCATE` env var for ad-hoc debugging. Use `--stream` for
17
+ * the full untruncated NDJSON.
18
18
  */
19
19
  export declare function createVerboseToolObserver(): Observer;
@@ -1,5 +1,8 @@
1
1
  import chalk from "chalk";
2
- const TRUNCATE = 1200;
2
+ // Default truncation, large enough to fit a 14-item validation checklist JSON
3
+ // without losing the bottom (passed/failed totals). Overridable via env var
4
+ // for ad-hoc debugging when even this isn't enough.
5
+ const TRUNCATE = Number.parseInt(process.env.SWENY_VERBOSE_TRUNCATE ?? "4000", 10) || 4000;
3
6
  function truncate(s) {
4
7
  return s.length > TRUNCATE
5
8
  ? `${s.slice(0, TRUNCATE)}\n ${chalk.dim(`… [${s.length - TRUNCATE} more chars]`)}`
@@ -29,33 +32,39 @@ function printCall(call) {
29
32
  process.stderr.write(` ${chalk.dim("←")} ${chalk.cyan(call.tool)} ${status}\n`);
30
33
  process.stderr.write(` ${chalk.dim(indent(truncate(fmt(call.output))))}\n`);
31
34
  }
35
+ function printData(node, data) {
36
+ if (!data || Object.keys(data).length === 0)
37
+ return;
38
+ process.stderr.write(` ${chalk.bold.dim(`${node}: output`)}\n`);
39
+ process.stderr.write(` ${chalk.dim(indent(truncate(fmt(data))))}\n`);
40
+ }
32
41
  /**
33
- * Create an observer that prints each tool call's input and output to stderr
34
- * in a human-readable form. Useful when debugging a node that fails or routes
35
- * unexpectedly — the default human output only shows step transitions,
36
- * leaving "why" invisible.
42
+ * Create an observer that prints, on `node:exit`:
43
+ * 1. Every tool call's input and output (truncated).
44
+ * 2. The node's structured output (`result.data`) — the payload that
45
+ * conditional edges route on. Without this, "validate → notify_halt"
46
+ * with no failing checks looks like a paradox; with it, you can see
47
+ * that the node emitted `{ status: "fail" }` and root-cause the wrong
48
+ * decision.
37
49
  *
38
- * Emission strategy: print the full call list on `node:exit` rather than per
39
- * `tool:call`/`tool:result` event. The reason: the executor's tool:call and
40
- * tool:result events fire only for skill-registered tools, not for the
41
- * Claude Code subprocess's built-in tools (Bash, Read, Edit, etc.). Those
42
- * built-in tools — the ones agents actually use most — land in
43
- * `result.toolCalls` only after the node completes. Walking result.toolCalls
44
- * on node:exit covers both kinds and avoids partial visibility.
50
+ * Both kinds of tools are covered (skill-registered AND Claude Code's
51
+ * built-in Bash/Read/Edit/Write), because `result.toolCalls` is populated
52
+ * after the node completes regardless of how the call was dispatched.
45
53
  *
46
- * Inputs and outputs are truncated; use `--stream` for full untruncated
47
- * NDJSON.
54
+ * Truncation defaults to 4000 chars per side. Override with the
55
+ * `SWENY_VERBOSE_TRUNCATE` env var for ad-hoc debugging. Use `--stream` for
56
+ * the full untruncated NDJSON.
48
57
  */
49
58
  export function createVerboseToolObserver() {
50
59
  return (event) => {
51
60
  if (event.type !== "node:exit")
52
61
  return;
53
62
  const calls = event.result.toolCalls;
54
- if (calls.length === 0)
55
- return;
56
- process.stderr.write(` ${chalk.bold.dim(`${event.node}: ${calls.length} tool call${calls.length === 1 ? "" : "s"}`)}\n`);
57
- for (const call of calls) {
58
- printCall(call);
63
+ if (calls.length > 0) {
64
+ process.stderr.write(` ${chalk.bold.dim(`${event.node}: ${calls.length} tool call${calls.length === 1 ? "" : "s"}`)}\n`);
65
+ for (const call of calls)
66
+ printCall(call);
59
67
  }
68
+ printData(event.node, event.result.data);
60
69
  };
61
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sweny-ai/core",
3
- "version": "0.1.95",
3
+ "version": "0.1.96",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "sweny": "./dist/cli/main.js"