@giovannijecha/jecode 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,8 @@ export function render(block, width, pal, context = {}) {
10
10
  return renderAnswer(block, width, pal);
11
11
  case "reasoning":
12
12
  return renderReasoning(block, width, pal, {
13
- continues: context.previous?.kind === "tool" || context.previous?.kind === "reasoning",
13
+ continues: context.previous?.kind === "reasoning",
14
+ followsTool: context.previous?.kind === "tool",
14
15
  });
15
16
  case "tool":
16
17
  return renderTool(block, width, pal, {
@@ -1,7 +1,7 @@
1
1
  import { trailingText } from "../../text-boundary.js";
2
2
  import { row } from "../../ui/render.js";
3
3
  import { markdown } from "../../ui/markdown.js";
4
- import { transcriptLead, transcriptWidth } from "../transcript-grammar.js";
4
+ import { transcriptLead, transcriptMark, transcriptWidth } from "../transcript-grammar.js";
5
5
  export const REASONING_PREVIEW_ROWS = 3;
6
6
  const MIN_REASONING_PREVIEW_CHARS = 4_096;
7
7
  const REASONING_PREVIEW_OVERSCAN = 12;
@@ -19,10 +19,9 @@ export function renderUser(block, width, pal) {
19
19
  ];
20
20
  }
21
21
  export function renderAnswer(block, width, pal) {
22
- const inner = transcriptWidth(width);
23
22
  return [
24
23
  "",
25
- ...markdown(block.text, inner, pal, inner).map((line) => row(width, [...transcriptLead(width), ...line.segs])),
24
+ ...markdown(block.text, width, pal, width).map((line) => row(width, line.segs)),
26
25
  ];
27
26
  }
28
27
  export function renderReasoning(block, width, pal, context = {}) {
@@ -36,7 +35,9 @@ export function renderReasoning(block, width, pal, context = {}) {
36
35
  const content = markdown(source.text, inner, pal, inner);
37
36
  const visible = expanded ? content : content.slice(-REASONING_PREVIEW_ROWS);
38
37
  return [
39
- ...(context.continues === true ? [] : [""]),
38
+ ...(context.followsTool === true
39
+ ? [row(width, transcriptMark(width, { text: "│", fg: pal.rule }))]
40
+ : context.continues === true ? [] : [""]),
40
41
  ...visible.map((line) => row(width, [
41
42
  ...transcriptLead(width, { text: "│", fg: pal.rule }),
42
43
  ...line.segs.map((seg) => ({ ...seg, fg: pal.ink.dim, italic: true })),
@@ -3,7 +3,7 @@
3
3
  import { fitSegs, hasColor, plainLen, row } from "../../ui/render.js";
4
4
  import { graphemeCeiling, graphemeFloor } from "../../text-boundary.js";
5
5
  import { toolDuration } from "../../duration.js";
6
- import { breathe, easeInOut, easeOut, interval, mix, TOOL_BIRTH_MS, TOOL_LEADER_MAX_MS, TOOL_ROW_ARRIVAL_MS, TOOL_SETTLE_MS, } from "../motion.js";
6
+ import { breathe, easeInOut, easeOut, interval, mix, TOOL_BIRTH_MS, TOOL_LEADER_MAX_MS, TOOL_ROW_ARRIVAL_MS, } from "../motion.js";
7
7
  import { transcriptLead, transcriptMark } from "../transcript-grammar.js";
8
8
  const OUTPUT_ROWS = 8;
9
9
  const LIVE_OUTPUT_ROWS = 6;
@@ -15,7 +15,7 @@ const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇",
15
15
  export function renderTool(block, width, pal, context = {}) {
16
16
  const now = context.now ?? Date.now();
17
17
  const shown = visibleDetails(block);
18
- const ink = statusInk(block, pal, context, now);
18
+ const ink = stateInk(block, pal, context, now);
19
19
  const nameInk = birthInk(pal.ink.bright, pal.ink.dim, context, now);
20
20
  const left = [
21
21
  ...transcriptLead(width, { text: stateGlyph(block, context, now), fg: ink, bold: true }),
@@ -138,7 +138,7 @@ function stateGlyph(block, context, now) {
138
138
  return SPINNER[Math.floor(now / SPINNER_MS) % SPINNER.length] ?? "○";
139
139
  }
140
140
  if (block.tone === "fail")
141
- return "×";
141
+ return hasColor() ? "●" : "×";
142
142
  if (block.tone === "deny")
143
143
  return "○";
144
144
  return hasColor() ? "●" : "✓";
@@ -148,7 +148,7 @@ function resultSegments(block, pal, context, now) {
148
148
  const duration = liveDuration(block, now);
149
149
  if (status === "" && duration === "")
150
150
  return [];
151
- const ink = statusInk(block, pal, context, now);
151
+ const ink = resultInk(block, pal, context, now);
152
152
  return [
153
153
  ...(status === "" ? [] : [{ text: status, fg: ink }]),
154
154
  ...(duration === "" ? [] : [{ text: `${status === "" ? "" : " · "}${duration}`, fg: pal.ink.dim }]),
@@ -160,7 +160,7 @@ function liveDuration(block, now) {
160
160
  }
161
161
  return block.durationMs === undefined ? "" : toolDuration(block.durationMs);
162
162
  }
163
- function statusInk(block, pal, context, now) {
163
+ function stateInk(block, pal, context, now) {
164
164
  if (block.tone === "fail")
165
165
  return pal.ink.removed;
166
166
  if (block.tone === "deny")
@@ -170,10 +170,10 @@ function statusInk(block, pal, context, now) {
170
170
  return pal.ink.attention;
171
171
  return mix(pal.ink.attention, pal.accent, breathe(now));
172
172
  }
173
- if (context.reducedMotion === true || context.motion?.settledAt === undefined)
174
- return pal.ink.muted;
175
- const cooled = easeOut(interval(now, context.motion.settledAt, TOOL_SETTLE_MS));
176
- return mix(pal.ink.added, pal.ink.muted, cooled);
173
+ return pal.ink.added;
174
+ }
175
+ function resultInk(block, pal, context, now) {
176
+ return block.tone === "ok" ? pal.ink.muted : stateInk(block, pal, context, now);
177
177
  }
178
178
  function birthInk(final, initial, context, now) {
179
179
  if (context.reducedMotion === true || context.motion === undefined)
@@ -1,9 +1,7 @@
1
1
  // One semantic margin shared by every transcript block.
2
- const FULL_GUTTER = 4;
3
- const COMPACT_GUTTER = 2;
4
- const COMPACT_BELOW = 64;
5
- export function transcriptGutter(width) {
6
- return width < COMPACT_BELOW ? COMPACT_GUTTER : FULL_GUTTER;
2
+ const GUTTER = 2;
3
+ export function transcriptGutter(_width) {
4
+ return GUTTER;
7
5
  }
8
6
  export function transcriptWidth(width) {
9
7
  return Math.max(8, width - transcriptGutter(width));
@@ -14,12 +12,10 @@ export function transcriptLead(width, mark) {
14
12
  return [{ text: " ".repeat(transcriptGutter(width)) }];
15
13
  return [
16
14
  ...transcriptMark(width, mark),
17
- { text: " ".repeat(width < COMPACT_BELOW ? 1 : 2) },
15
+ { text: " " },
18
16
  ];
19
17
  }
20
18
  /** Draw only the gutter mark, without trailing content-column whitespace. */
21
- export function transcriptMark(width, mark) {
22
- if (width < COMPACT_BELOW)
23
- return [{ ...mark }];
24
- return [{ text: " " }, { ...mark }];
19
+ export function transcriptMark(_width, mark) {
20
+ return [{ ...mark }];
25
21
  }
package/dist/ui/inline.js CHANGED
@@ -14,22 +14,22 @@ export function inline(text, base, pal, bold = false) {
14
14
  const { ink } = pal;
15
15
  const segs = [];
16
16
  let last = 0;
17
- INLINE.lastIndex = 0;
18
- for (let match = INLINE.exec(text); match !== null; match = INLINE.exec(text)) {
17
+ const matcher = new RegExp(INLINE.source, INLINE.flags);
18
+ for (let match = matcher.exec(text); match !== null; match = matcher.exec(text)) {
19
19
  if (match.index > last) {
20
20
  segs.push({ text: text.slice(last, match.index), fg: base, bold: bold || undefined });
21
21
  }
22
22
  const [, mono, strong, strongAlt, emphasis, label] = match;
23
23
  if (mono !== undefined)
24
- segs.push({ text: mono, fg: pal.technical });
24
+ segs.push({ text: mono, fg: pal.technical, bold: bold || undefined });
25
25
  else if (strong !== undefined)
26
- segs.push({ text: strong, fg: ink.bright, bold: true });
26
+ segs.push(...inline(strong, ink.bright, pal, true));
27
27
  else if (strongAlt !== undefined)
28
- segs.push({ text: strongAlt, fg: ink.bright, bold: true });
28
+ segs.push(...inline(strongAlt, ink.bright, pal, true));
29
29
  else if (emphasis !== undefined)
30
- segs.push({ text: emphasis, fg: ink.bright });
30
+ segs.push(...inline(emphasis, ink.bright, pal, bold));
31
31
  else if (label !== undefined)
32
- segs.push({ text: label, fg: pal.technical });
32
+ segs.push({ text: label, fg: pal.technical, bold: bold || undefined });
33
33
  last = match.index + match[0].length;
34
34
  }
35
35
  if (last < text.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giovannijecha/jecode",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "An owned coding agent with zero external runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "repository": {