@clinebot/shared 0.0.20 → 0.0.21

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.
package/src/parse/json.ts DELETED
@@ -1,43 +0,0 @@
1
- import { jsonrepair } from "jsonrepair";
2
-
3
- function tryParseJson(text: string): unknown {
4
- return JSON.parse(text);
5
- }
6
-
7
- export function parseJsonStream(input: unknown): unknown {
8
- if (typeof input !== "string") return input;
9
-
10
- const text = input.trimStart();
11
- if (!(text.startsWith("{") || text.startsWith("["))) return input;
12
-
13
- try {
14
- return tryParseJson(text);
15
- } catch {
16
- try {
17
- return tryParseJson(jsonrepair(text));
18
- } catch {
19
- return input;
20
- }
21
- }
22
- }
23
-
24
- export function safeJsonStringify(input: unknown): string {
25
- const seen = new WeakSet<object>();
26
-
27
- try {
28
- const result = JSON.stringify(input, (_key, value) => {
29
- if (typeof value === "bigint") return value.toString();
30
-
31
- if (value && typeof value === "object") {
32
- if (seen.has(value as object)) return "[Circular]";
33
- seen.add(value as object);
34
- }
35
-
36
- return value;
37
- });
38
-
39
- return result ?? "null";
40
- } catch {
41
- return String(input);
42
- }
43
- }
package/src/parse/time.ts DELETED
@@ -1,21 +0,0 @@
1
- /**
2
- * Parses a date string and returns a human-readable format.
3
- * If the input is invalid, it returns the original string or a placeholder.
4
- *
5
- * @param dateStr - The date string to parse.
6
- * @returns A human-readable date string or the original input if invalid.
7
- */
8
- export function formatHumanReadableDate(dateStr?: string): string {
9
- if (!dateStr) return "(unknown-date)";
10
- const date = new Date(dateStr);
11
- if (Number.isNaN(date.getTime())) return dateStr;
12
- return date.toLocaleString("en-US", {
13
- year: "numeric",
14
- month: "numeric",
15
- day: "numeric",
16
- hour: "numeric",
17
- minute: "numeric",
18
- second: "numeric",
19
- hour12: true,
20
- });
21
- }
package/src/parse/zod.ts DELETED
@@ -1,23 +0,0 @@
1
- /**
2
- * Zod Utilities
3
- *
4
- * Helper functions for working with Zod schemas.
5
- */
6
-
7
- import { z } from "zod";
8
-
9
- /**
10
- * Validate input using a Zod schema
11
- * Throws a formatted error if validation fails
12
- */
13
- export function validateWithZod<T>(schema: z.ZodType<T>, input: unknown): T {
14
- const result = schema.safeParse(input);
15
- if (!result.success) {
16
- throw new Error(z.prettifyError(result.error));
17
- }
18
- return result.data;
19
- }
20
-
21
- export function zodToJsonSchema(schema: z.ZodTypeAny): Record<string, unknown> {
22
- return z.toJSONSchema(schema);
23
- }
@@ -1,22 +0,0 @@
1
- export function formatFileContentBlock(path: string, content: string): string {
2
- return `<file_content path="${path}">\n${content}\n</file_content>`;
3
- }
4
-
5
- export function formatUserInputBlock(
6
- input: string,
7
- mode: "act" | "plan" = "act",
8
- ): string {
9
- return `<user_input mode="${mode}">${input}</user_input>`;
10
- }
11
-
12
- export function normalizeUserInput(input?: string): string {
13
- if (!input?.trim()) return "";
14
- return xmlTagsRemoval(input, "user_input");
15
- }
16
-
17
- export function xmlTagsRemoval(input?: string, tag?: string): string {
18
- if (!input?.trim()) return "";
19
- if (!tag) return input;
20
- const regex = new RegExp(`<${tag}.*?>(.*?)</${tag}>`, "g");
21
- return input.replace(regex, "$1");
22
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * URI scheme for opening remote rules/workflows in the editor.
3
- * Used to construct URIs like: remote://rule/{name} or remote://workflow/{name}
4
- */
5
- export const REMOTE_URI_SCHEME = "remote://";