@towles/tool 0.0.20 → 0.0.48

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/{LICENSE.md → LICENSE} +1 -1
  2. package/README.md +86 -85
  3. package/bin/run.ts +5 -0
  4. package/package.json +84 -64
  5. package/patches/prompts.patch +34 -0
  6. package/src/commands/base.ts +27 -0
  7. package/src/commands/config.test.ts +15 -0
  8. package/src/commands/config.ts +44 -0
  9. package/src/commands/doctor.ts +136 -0
  10. package/src/commands/gh/branch-clean.ts +116 -0
  11. package/src/commands/gh/branch.test.ts +124 -0
  12. package/src/commands/gh/branch.ts +135 -0
  13. package/src/commands/gh/pr.ts +175 -0
  14. package/src/commands/graph-template.html +1214 -0
  15. package/src/commands/graph.test.ts +176 -0
  16. package/src/commands/graph.ts +970 -0
  17. package/src/commands/install.ts +154 -0
  18. package/src/commands/journal/daily-notes.ts +70 -0
  19. package/src/commands/journal/meeting.ts +89 -0
  20. package/src/commands/journal/note.ts +89 -0
  21. package/src/commands/ralph/plan/add.ts +75 -0
  22. package/src/commands/ralph/plan/done.ts +82 -0
  23. package/src/commands/ralph/plan/list.test.ts +48 -0
  24. package/src/commands/ralph/plan/list.ts +99 -0
  25. package/src/commands/ralph/plan/remove.ts +71 -0
  26. package/src/commands/ralph/run.test.ts +521 -0
  27. package/src/commands/ralph/run.ts +345 -0
  28. package/src/commands/ralph/show.ts +88 -0
  29. package/src/config/settings.ts +136 -0
  30. package/src/lib/journal/utils.ts +399 -0
  31. package/src/lib/ralph/execution.ts +292 -0
  32. package/src/lib/ralph/formatter.ts +238 -0
  33. package/src/lib/ralph/index.ts +4 -0
  34. package/src/lib/ralph/state.ts +166 -0
  35. package/src/types/journal.ts +16 -0
  36. package/src/utils/date-utils.test.ts +97 -0
  37. package/src/utils/date-utils.ts +54 -0
  38. package/src/utils/git/gh-cli-wrapper.test.ts +14 -0
  39. package/src/utils/git/gh-cli-wrapper.ts +54 -0
  40. package/src/utils/git/git-wrapper.test.ts +26 -0
  41. package/src/utils/git/git-wrapper.ts +15 -0
  42. package/src/utils/render.test.ts +71 -0
  43. package/src/utils/render.ts +34 -0
  44. package/dist/index.d.mts +0 -1
  45. package/dist/index.mjs +0 -805
@@ -0,0 +1,71 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { printWithHexColor } from "./render";
3
+
4
+ describe("printWithHexColor", () => {
5
+ it("should handle hex colors with # prefix", () => {
6
+ const result = printWithHexColor({ msg: "test", hex: "#ff0000" });
7
+ expect(result).toBe("\x1B[38;2;255;0;0mtest\x1B[0m");
8
+ });
9
+
10
+ it("should handle hex colors without # prefix", () => {
11
+ const result = printWithHexColor({ msg: "test", hex: "ff0000" });
12
+ expect(result).toBe("\x1B[38;2;255;0;0mtest\x1B[0m");
13
+ });
14
+
15
+ it("should handle green color correctly", () => {
16
+ const result = printWithHexColor({ msg: "green", hex: "#00ff00" });
17
+ expect(result).toBe("\x1B[38;2;0;255;0mgreen\x1B[0m");
18
+ });
19
+
20
+ it("should handle blue color correctly", () => {
21
+ const result = printWithHexColor({ msg: "blue", hex: "0000ff" });
22
+ expect(result).toBe("\x1B[38;2;0;0;255mblue\x1B[0m");
23
+ });
24
+
25
+ it("should handle mixed RGB values", () => {
26
+ const result = printWithHexColor({ msg: "purple", hex: "#800080" });
27
+ expect(result).toBe("\x1B[38;2;128;0;128mpurple\x1B[0m");
28
+ });
29
+
30
+ it("should handle GitHub-style label colors", () => {
31
+ // GitHub red label color
32
+ const result = printWithHexColor({ msg: "bug", hex: "d73a49" });
33
+ expect(result).toBe("\x1B[38;2;215;58;73mbug\x1B[0m");
34
+ });
35
+
36
+ it("should handle lowercase hex values", () => {
37
+ const result = printWithHexColor({ msg: "test", hex: "abc123" });
38
+ expect(result).toBe("\x1B[38;2;171;193;35mtest\x1B[0m");
39
+ });
40
+
41
+ it("should handle uppercase hex values", () => {
42
+ const result = printWithHexColor({ msg: "test", hex: "ABC123" });
43
+ expect(result).toBe("\x1B[38;2;171;193;35mtest\x1B[0m");
44
+ });
45
+
46
+ it("should handle empty message", () => {
47
+ const result = printWithHexColor({ msg: "", hex: "#ff0000" });
48
+ expect(result).toBe("\x1B[38;2;255;0;0m\x1B[0m");
49
+ });
50
+
51
+ it("should handle message with spaces", () => {
52
+ const result = printWithHexColor({ msg: "hello world", hex: "#ffffff" });
53
+ expect(result).toBe("\x1B[38;2;255;255;255mhello world\x1B[0m");
54
+ });
55
+
56
+ it("should handle black color (000000)", () => {
57
+ const result = printWithHexColor({ msg: "black", hex: "000000" });
58
+ expect(result).toBe("\x1B[38;2;0;0;0mblack\x1B[0m");
59
+ });
60
+
61
+ it("should handle white color (ffffff)", () => {
62
+ const result = printWithHexColor({ msg: "white", hex: "ffffff" });
63
+ expect(result).toBe("\x1B[38;2;255;255;255mwhite\x1B[0m");
64
+ });
65
+
66
+ it("should preserve message content exactly", () => {
67
+ const specialMessage = "special-chars_123!@#";
68
+ const result = printWithHexColor({ msg: specialMessage, hex: "#123456" });
69
+ expect(result).toBe(`\x1B[38;2;18;52;86m${specialMessage}\x1B[0m`);
70
+ });
71
+ });
@@ -0,0 +1,34 @@
1
+ import { colors } from "consola/utils";
2
+
3
+ export const getTerminalColumns = () => process.stdout?.columns || 80;
4
+
5
+ export const limitText = (text: string, maxWidth: number): string => {
6
+ if (text.length <= maxWidth) return text;
7
+ // subtract 1 so room for the ellipsis
8
+ return `${text.slice(0, maxWidth - 1)}${colors.dim("…")}`;
9
+ };
10
+
11
+ /**
12
+ * Convert hex color to RGB values
13
+ */
14
+ function hexToRgb(hex: string): { r: number; g: number; b: number } {
15
+ const cleanHex = hex.replace("#", "");
16
+ const r = Number.parseInt(cleanHex.slice(0, 2), 16);
17
+ const g = Number.parseInt(cleanHex.slice(2, 4), 16);
18
+ const b = Number.parseInt(cleanHex.slice(4, 6), 16);
19
+ return { r, g, b };
20
+ }
21
+
22
+ /**
23
+ * Apply hex color to text using ANSI 24-bit color codes
24
+ */
25
+ export function printWithHexColor({ msg, hex }: { msg: string; hex: string }): string {
26
+ const colorWithHex = hex.startsWith("#") ? hex : `#${hex}`;
27
+ const { r, g, b } = hexToRgb(colorWithHex);
28
+
29
+ // Use ANSI 24-bit color: \x1B[38;2;r;g;bm for foreground color
30
+ const colorStart = `\x1B[38;2;${r};${g};${b}m`;
31
+ const colorEnd = "\x1B[0m"; // Reset color
32
+
33
+ return `${colorStart}${msg}${colorEnd}`;
34
+ }
package/dist/index.d.mts DELETED
@@ -1 +0,0 @@
1
-