@unikode/cli 1.0.20 → 1.0.22

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 (2) hide show
  1. package/dist/index.js +53 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2662,7 +2662,8 @@ function InputBar({ onSubmit, disabled = false }) {
2662
2662
  focused: !disabled && (isTopLayer("base") || isTopLayer("command") || isTopLayer("mention")),
2663
2663
  keyBindings: TEXTAREA_KEY_BINDINGS,
2664
2664
  onContentChange: handleTextareaContentChange,
2665
- placeholder: `Ask anything ... "Fix this bug for me!!"`
2665
+ placeholder: `Ask anything ... "Fix this bug for me!!"`,
2666
+ maxHeight: 3
2666
2667
  }, undefined, false, undefined, this),
2667
2668
  /* @__PURE__ */ jsxDEV17(StatusBar, {}, undefined, false, undefined, this)
2668
2669
  ]
@@ -3078,9 +3079,11 @@ function SessionShell({
3078
3079
  onSubmit,
3079
3080
  inputDisabled = false,
3080
3081
  loading = false,
3081
- interruptible = false
3082
+ interruptible = false,
3083
+ tokenCount
3082
3084
  }) {
3083
3085
  const { mode } = usePromptConfig();
3086
+ const { colors } = useTheme();
3084
3087
  return /* @__PURE__ */ jsxDEV21("box", {
3085
3088
  flexDirection: "column",
3086
3089
  flexGrow: 1,
@@ -3099,6 +3102,37 @@ function SessionShell({
3099
3102
  children
3100
3103
  }, undefined, false, undefined, this)
3101
3104
  }, undefined, false, undefined, this),
3105
+ tokenCount !== undefined && /* @__PURE__ */ jsxDEV21("box", {
3106
+ flexShrink: 0,
3107
+ flexDirection: "row",
3108
+ justifyContent: "flex-end",
3109
+ alignItems: "center",
3110
+ width: "100%",
3111
+ paddingX: 1,
3112
+ children: /* @__PURE__ */ jsxDEV21("box", {
3113
+ flexDirection: "row",
3114
+ alignItems: "center",
3115
+ gap: 1,
3116
+ paddingX: 1,
3117
+ backgroundColor: colors.surface,
3118
+ children: [
3119
+ /* @__PURE__ */ jsxDEV21("text", {
3120
+ fg: mode === Mode.PLAN ? colors.planMode : colors.primary,
3121
+ children: "\u26A1"
3122
+ }, undefined, false, undefined, this),
3123
+ /* @__PURE__ */ jsxDEV21("text", {
3124
+ attributes: TextAttributes8.DIM,
3125
+ fg: colors.info,
3126
+ children: "Tokens:"
3127
+ }, undefined, false, undefined, this),
3128
+ /* @__PURE__ */ jsxDEV21("text", {
3129
+ fg: mode === Mode.PLAN ? colors.planMode : colors.primary,
3130
+ attributes: TextAttributes8.BOLD,
3131
+ children: tokenCount.toLocaleString()
3132
+ }, undefined, false, undefined, this)
3133
+ ]
3134
+ }, undefined, true, undefined, this)
3135
+ }, undefined, false, undefined, this),
3102
3136
  /* @__PURE__ */ jsxDEV21("box", {
3103
3137
  flexShrink: 0,
3104
3138
  children: /* @__PURE__ */ jsxDEV21(InputBar, {
@@ -4406,7 +4440,24 @@ function SessionChat({ session, initialPrompt }) {
4406
4440
  model: initialPrompt.model
4407
4441
  });
4408
4442
  }, [initialPrompt, submit]);
4443
+ const totalTokenCount = useMemo6(() => {
4444
+ let initialUsageSum = 0;
4445
+ let currentUsageSum = 0;
4446
+ for (let i = 0;i < messages.length; i++) {
4447
+ const msg = messages[i];
4448
+ const metadata = msg?.metadata;
4449
+ const tokens = metadata?.usage?.totalTokens ?? 0;
4450
+ currentUsageSum += tokens;
4451
+ if (i < initialMessages.length) {
4452
+ initialUsageSum += tokens;
4453
+ }
4454
+ }
4455
+ const baseTokens = Math.max(session.tokenCount ?? 0, initialUsageSum);
4456
+ const newTokens = currentUsageSum - initialUsageSum;
4457
+ return baseTokens + newTokens;
4458
+ }, [messages, initialMessages.length, session.tokenCount]);
4409
4459
  return /* @__PURE__ */ jsxDEV28(SessionShell, {
4460
+ tokenCount: totalTokenCount,
4410
4461
  onSubmit: (text) => {
4411
4462
  deactivateQuestionPrompts();
4412
4463
  submit({ userText: text, mode, model });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unikode/cli",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {