clairo 1.0.0 → 1.0.2

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/cli.js +83 -26
  2. package/package.json +2 -1
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import meow from "meow";
5
5
 
6
6
  // src/app.tsx
7
- import { useCallback as useCallback4, useState as useState9 } from "react";
7
+ import { useCallback as useCallback4, useState as useState10 } from "react";
8
8
  import { Box as Box16, useApp, useInput as useInput13 } from "ink";
9
9
 
10
10
  // src/components/github/GitHubView.tsx
@@ -484,9 +484,12 @@ function getTodayDate() {
484
484
  }
485
485
  function formatTimestamp() {
486
486
  const now = /* @__PURE__ */ new Date();
487
+ const year = now.getFullYear();
488
+ const month = String(now.getMonth() + 1).padStart(2, "0");
489
+ const day = String(now.getDate()).padStart(2, "0");
487
490
  const hours = String(now.getHours()).padStart(2, "0");
488
491
  const minutes = String(now.getMinutes()).padStart(2, "0");
489
- return `${hours}:${minutes}`;
492
+ return `${year}-${month}-${day} ${hours}:${minutes}`;
490
493
  }
491
494
  function listLogFiles() {
492
495
  ensureLogsDirectory();
@@ -549,6 +552,11 @@ function openLogInEditor(date) {
549
552
  if (!existsSync2(filePath)) {
550
553
  return false;
551
554
  }
555
+ const timestamp = formatTimestamp();
556
+ appendFileSync(filePath, `
557
+ ## ${timestamp}
558
+
559
+ `);
552
560
  const editor = process.env.VISUAL || process.env.EDITOR || "vi";
553
561
  const result = spawnSync(editor, [filePath], {
554
562
  stdio: "inherit"
@@ -1819,7 +1827,7 @@ function JiraView({ isFocused, onModalChange, onKeybindingsChange, onLogUpdated
1819
1827
  }
1820
1828
 
1821
1829
  // src/components/logs/LogsView.tsx
1822
- import { useCallback as useCallback3, useEffect as useEffect6, useState as useState8 } from "react";
1830
+ import { useCallback as useCallback3, useEffect as useEffect6, useState as useState9 } from "react";
1823
1831
  import { Box as Box14, useInput as useInput12 } from "ink";
1824
1832
 
1825
1833
  // src/components/logs/LogsHistoryBox.tsx
@@ -1882,19 +1890,30 @@ function LogsHistoryBox({
1882
1890
  }
1883
1891
 
1884
1892
  // src/components/logs/LogViewerBox.tsx
1885
- import { useRef as useRef3 } from "react";
1893
+ import { useRef as useRef3, useState as useState8 } from "react";
1886
1894
  import { TitledBox as TitledBox6 } from "@mishieck/ink-titled-box";
1887
1895
  import { Box as Box13, Text as Text13, useInput as useInput11 } from "ink";
1888
1896
  import { ScrollView as ScrollView2 } from "ink-scroll-view";
1897
+ import TextInput2 from "ink-text-input";
1889
1898
  import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
1890
1899
  function LogViewerBox({ date, content, isFocused, onRefresh, onLogCreated }) {
1891
1900
  const scrollRef = useRef3(null);
1901
+ const [isInputMode, setIsInputMode] = useState8(false);
1902
+ const [inputValue, setInputValue] = useState8("");
1892
1903
  const title = "[6] Log Content";
1893
1904
  const borderColor = isFocused ? "yellow" : void 0;
1894
1905
  const displayTitle = date ? `${title} - ${date}.md` : title;
1895
1906
  useInput11(
1896
1907
  (input, key) => {
1897
1908
  var _a, _b;
1909
+ if (key.escape && isInputMode) {
1910
+ setIsInputMode(false);
1911
+ setInputValue("");
1912
+ return;
1913
+ }
1914
+ if (isInputMode) {
1915
+ return;
1916
+ }
1898
1917
  if (key.upArrow || input === "k") {
1899
1918
  (_a = scrollRef.current) == null ? void 0 : _a.scrollBy(-1);
1900
1919
  }
@@ -1905,6 +1924,9 @@ function LogViewerBox({ date, content, isFocused, onRefresh, onLogCreated }) {
1905
1924
  openLogInEditor(date);
1906
1925
  onRefresh();
1907
1926
  }
1927
+ if (input === "i" && date) {
1928
+ setIsInputMode(true);
1929
+ }
1908
1930
  if (input === "n") {
1909
1931
  const today = getTodayDate();
1910
1932
  if (!logExists(today)) {
@@ -1918,22 +1940,48 @@ function LogViewerBox({ date, content, isFocused, onRefresh, onLogCreated }) {
1918
1940
  },
1919
1941
  { isActive: isFocused }
1920
1942
  );
1921
- return /* @__PURE__ */ jsx13(TitledBox6, { borderStyle: "round", titles: [displayTitle], borderColor, flexGrow: 1, children: /* @__PURE__ */ jsx13(Box13, { flexDirection: "column", flexGrow: 1, children: /* @__PURE__ */ jsx13(ScrollView2, { ref: scrollRef, children: /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", paddingX: 1, children: [
1922
- !date && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Select a log file to view" }),
1923
- date && content === null && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Log file not found" }),
1924
- date && content !== null && content.trim() === "" && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Empty log file" }),
1925
- date && content && content.trim() !== "" && /* @__PURE__ */ jsx13(Markdown, { children: content })
1926
- ] }) }) }) });
1943
+ const handleInputSubmit = (value) => {
1944
+ if (!date || !value.trim()) {
1945
+ setIsInputMode(false);
1946
+ setInputValue("");
1947
+ return;
1948
+ }
1949
+ const timestamp = formatTimestamp();
1950
+ const entry = `
1951
+ ## ${timestamp}
1952
+
1953
+ ${value.trim()}
1954
+ `;
1955
+ appendToLog(date, entry);
1956
+ setInputValue("");
1957
+ setIsInputMode(false);
1958
+ onRefresh();
1959
+ };
1960
+ return /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", flexGrow: 1, children: [
1961
+ /* @__PURE__ */ jsx13(TitledBox6, { borderStyle: "round", titles: [displayTitle], borderColor, flexGrow: 1, children: /* @__PURE__ */ jsx13(Box13, { flexDirection: "column", flexGrow: 1, children: /* @__PURE__ */ jsx13(ScrollView2, { ref: scrollRef, children: /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", paddingX: 1, children: [
1962
+ !date && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Select a log file to view" }),
1963
+ date && content === null && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Log file not found" }),
1964
+ date && content !== null && content.trim() === "" && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Empty log file" }),
1965
+ date && content && content.trim() !== "" && /* @__PURE__ */ jsx13(Markdown, { children: content })
1966
+ ] }) }) }) }),
1967
+ isInputMode && /* @__PURE__ */ jsx13(TitledBox6, { borderStyle: "round", titles: ["Add Entry"], borderColor: "yellow", children: /* @__PURE__ */ jsx13(Box13, { paddingX: 1, children: /* @__PURE__ */ jsx13(
1968
+ TextInput2,
1969
+ {
1970
+ value: inputValue,
1971
+ onChange: (val) => setInputValue(val.replace(/[\r\n]/g, "")),
1972
+ onSubmit: handleInputSubmit
1973
+ }
1974
+ ) }) })
1975
+ ] });
1927
1976
  }
1928
1977
 
1929
1978
  // src/components/logs/LogsView.tsx
1930
1979
  import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
1931
- function LogsView({ isFocused, onKeybindingsChange, refreshKey }) {
1932
- const [logFiles, setLogFiles] = useState8([]);
1933
- const [selectedDate, setSelectedDate] = useState8(null);
1934
- const [logContent, setLogContent] = useState8(null);
1935
- const [highlightedIndex, setHighlightedIndex] = useState8(0);
1936
- const [focusedBox, setFocusedBox] = useState8("history");
1980
+ function LogsView({ isFocused, onKeybindingsChange, refreshKey, focusedBox, onFocusedBoxChange }) {
1981
+ const [logFiles, setLogFiles] = useState9([]);
1982
+ const [selectedDate, setSelectedDate] = useState9(null);
1983
+ const [logContent, setLogContent] = useState9(null);
1984
+ const [highlightedIndex, setHighlightedIndex] = useState9(0);
1937
1985
  useEffect6(() => {
1938
1986
  if (!isFocused) {
1939
1987
  onKeybindingsChange == null ? void 0 : onKeybindingsChange([]);
@@ -1943,6 +1991,7 @@ function LogsView({ isFocused, onKeybindingsChange, refreshKey }) {
1943
1991
  if (focusedBox === "history") {
1944
1992
  bindings.push({ key: "Enter", label: "Select" });
1945
1993
  } else if (focusedBox === "viewer") {
1994
+ bindings.push({ key: "i", label: "Add Entry" });
1946
1995
  bindings.push({ key: "e", label: "Edit" });
1947
1996
  bindings.push({ key: "n", label: "New Log", color: "green" });
1948
1997
  bindings.push({ key: "r", label: "Refresh" });
@@ -2016,8 +2065,8 @@ function LogsView({ isFocused, onKeybindingsChange, refreshKey }) {
2016
2065
  }, []);
2017
2066
  useInput12(
2018
2067
  (input) => {
2019
- if (input === "5") setFocusedBox("history");
2020
- if (input === "6") setFocusedBox("viewer");
2068
+ if (input === "5") onFocusedBoxChange("history");
2069
+ if (input === "6") onFocusedBoxChange("viewer");
2021
2070
  },
2022
2071
  { isActive: isFocused }
2023
2072
  );
@@ -2069,10 +2118,11 @@ function KeybindingsBar({ contextBindings = [], modalOpen = false }) {
2069
2118
  import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
2070
2119
  function App() {
2071
2120
  const { exit } = useApp();
2072
- const [focusedView, setFocusedView] = useState9("github");
2073
- const [modalOpen, setModalOpen] = useState9(false);
2074
- const [contextBindings, setContextBindings] = useState9([]);
2075
- const [logRefreshKey, setLogRefreshKey] = useState9(0);
2121
+ const [focusedView, setFocusedView] = useState10("github");
2122
+ const [modalOpen, setModalOpen] = useState10(false);
2123
+ const [contextBindings, setContextBindings] = useState10([]);
2124
+ const [logRefreshKey, setLogRefreshKey] = useState10(0);
2125
+ const [logsFocusedBox, setLogsFocusedBox] = useState10("history");
2076
2126
  const handleLogUpdated = useCallback4(() => {
2077
2127
  setLogRefreshKey((prev) => prev + 1);
2078
2128
  }, []);
@@ -2087,8 +2137,13 @@ function App() {
2087
2137
  if (input === "4") {
2088
2138
  setFocusedView("jira");
2089
2139
  }
2090
- if (input === "5" || input === "6") {
2140
+ if (input === "5") {
2141
+ setFocusedView("logs");
2142
+ setLogsFocusedBox("history");
2143
+ }
2144
+ if (input === "6") {
2091
2145
  setFocusedView("logs");
2146
+ setLogsFocusedBox("viewer");
2092
2147
  }
2093
2148
  },
2094
2149
  { isActive: !modalOpen }
@@ -2119,7 +2174,9 @@ function App() {
2119
2174
  {
2120
2175
  isFocused: focusedView === "logs",
2121
2176
  onKeybindingsChange: focusedView === "logs" ? setContextBindings : void 0,
2122
- refreshKey: logRefreshKey
2177
+ refreshKey: logRefreshKey,
2178
+ focusedBox: logsFocusedBox,
2179
+ onFocusedBoxChange: setLogsFocusedBox
2123
2180
  }
2124
2181
  ) })
2125
2182
  ] }),
@@ -2132,7 +2189,7 @@ import { render as inkRender } from "ink";
2132
2189
 
2133
2190
  // src/lib/Screen.tsx
2134
2191
  import { Box as Box17, useStdout as useStdout2 } from "ink";
2135
- import { useCallback as useCallback5, useEffect as useEffect7, useState as useState10 } from "react";
2192
+ import { useCallback as useCallback5, useEffect as useEffect7, useState as useState11 } from "react";
2136
2193
  import { jsx as jsx17 } from "react/jsx-runtime";
2137
2194
  function Screen({ children }) {
2138
2195
  const { stdout } = useStdout2();
@@ -2140,7 +2197,7 @@ function Screen({ children }) {
2140
2197
  () => ({ height: stdout.rows, width: stdout.columns }),
2141
2198
  [stdout]
2142
2199
  );
2143
- const [size, setSize] = useState10(getSize);
2200
+ const [size, setSize] = useState11(getSize);
2144
2201
  useEffect7(() => {
2145
2202
  const onResize = () => setSize(getSize());
2146
2203
  stdout.on("resize", onResize);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clairo",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,6 +27,7 @@
27
27
  "ink-link": "^5.0.0",
28
28
  "ink-scroll-view": "^0.3.5",
29
29
  "ink-select-input": "^6.2.0",
30
+ "ink-text-input": "^6.0.0",
30
31
  "marked": "^17.0.1",
31
32
  "meow": "^11.0.0",
32
33
  "open": "^11.0.0",