langwatch 0.3.0 → 0.3.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.
- package/README.md +5 -2
- package/dist/add-LBBS4I3H.js +114 -0
- package/dist/add-LBBS4I3H.js.map +1 -0
- package/dist/add-RD3ZKFAT.mjs +114 -0
- package/dist/add-RD3ZKFAT.mjs.map +1 -0
- package/dist/chunk-2JU376G7.js +242 -0
- package/dist/chunk-2JU376G7.js.map +1 -0
- package/dist/chunk-2ODBGSBI.js +4 -0
- package/dist/{chunk-G3AUABT7.js.map → chunk-2ODBGSBI.js.map} +1 -1
- package/dist/chunk-3GKPQB4R.mjs +242 -0
- package/dist/chunk-3GKPQB4R.mjs.map +1 -0
- package/dist/chunk-4NRLVT2U.mjs +35 -0
- package/dist/chunk-4NRLVT2U.mjs.map +1 -0
- package/dist/{chunk-SVJ7SCGB.js → chunk-52GXX3MA.js} +33 -31
- package/dist/chunk-52GXX3MA.js.map +1 -0
- package/dist/chunk-5NC5ILKA.js +94 -0
- package/dist/chunk-5NC5ILKA.js.map +1 -0
- package/dist/chunk-AAROJADR.mjs +49 -0
- package/dist/chunk-AAROJADR.mjs.map +1 -0
- package/dist/chunk-DHJKJVY7.mjs +20 -0
- package/dist/chunk-DHJKJVY7.mjs.map +1 -0
- package/dist/{chunk-VJSOCNPA.js → chunk-DTEKFQ4U.js} +6 -28
- package/dist/chunk-DTEKFQ4U.js.map +1 -0
- package/dist/chunk-E7UE2MPD.mjs +93 -0
- package/dist/chunk-E7UE2MPD.mjs.map +1 -0
- package/dist/chunk-F6E4XQQU.js +20 -0
- package/dist/chunk-F6E4XQQU.js.map +1 -0
- package/dist/chunk-FJLK5CFL.js +37 -0
- package/dist/chunk-FJLK5CFL.js.map +1 -0
- package/dist/{chunk-Z5J5UI5E.mjs → chunk-GJSEBQXF.mjs} +139 -107
- package/dist/chunk-GJSEBQXF.mjs.map +1 -0
- package/dist/chunk-HA3LI5IK.js +35 -0
- package/dist/chunk-HA3LI5IK.js.map +1 -0
- package/dist/chunk-HJU67C7H.js +93 -0
- package/dist/chunk-HJU67C7H.js.map +1 -0
- package/dist/chunk-IGHXIIIK.js +49 -0
- package/dist/chunk-IGHXIIIK.js.map +1 -0
- package/dist/{chunk-PMBEK6YE.mjs → chunk-J7ICRUU4.mjs} +5 -3
- package/dist/{chunk-PMBEK6YE.mjs.map → chunk-J7ICRUU4.mjs.map} +1 -1
- package/dist/{chunk-HPC6Z7J4.js → chunk-PWZBLTHR.js} +3 -3
- package/dist/{chunk-HPC6Z7J4.js.map → chunk-PWZBLTHR.js.map} +1 -1
- package/dist/chunk-SMXXAVMB.js +100 -0
- package/dist/chunk-SMXXAVMB.js.map +1 -0
- package/dist/{chunk-CSC3CMIT.mjs → chunk-STV4ZVNA.mjs} +2 -2
- package/dist/chunk-T5AZMMVS.mjs +94 -0
- package/dist/chunk-T5AZMMVS.mjs.map +1 -0
- package/dist/{chunk-4BZATFKJ.mjs → chunk-UU33HCCZ.mjs} +4 -26
- package/dist/{chunk-4BZATFKJ.mjs.map → chunk-UU33HCCZ.mjs.map} +1 -1
- package/dist/{chunk-PTJ6AAI7.js → chunk-VGHLQXKB.js} +138 -106
- package/dist/chunk-VGHLQXKB.js.map +1 -0
- package/dist/chunk-W5ZEP3CI.mjs +100 -0
- package/dist/chunk-W5ZEP3CI.mjs.map +1 -0
- package/dist/chunk-Y666BJA5.mjs +4 -0
- package/dist/chunk-YN4436PK.mjs +37 -0
- package/dist/chunk-YN4436PK.mjs.map +1 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +106 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.mjs +106 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/client-browser.js +15 -10
- package/dist/client-browser.js.map +1 -1
- package/dist/client-browser.mjs +9 -4
- package/dist/client-browser.mjs.map +1 -1
- package/dist/client-node.js +14 -9
- package/dist/client-node.js.map +1 -1
- package/dist/client-node.mjs +11 -6
- package/dist/client-node.mjs.map +1 -1
- package/dist/create-G5MTGOOH.js +70 -0
- package/dist/create-G5MTGOOH.js.map +1 -0
- package/dist/create-QUZYBMQB.mjs +70 -0
- package/dist/create-QUZYBMQB.mjs.map +1 -0
- package/dist/evaluation/index.js +5 -4
- package/dist/evaluation/index.js.map +1 -1
- package/dist/evaluation/index.mjs +4 -3
- package/dist/index.d.mts +21 -14
- package/dist/index.d.ts +21 -14
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -6
- package/dist/init-H67RW22E.mjs +16 -0
- package/dist/init-H67RW22E.mjs.map +1 -0
- package/dist/init-XU2JFY6N.js +16 -0
- package/dist/init-XU2JFY6N.js.map +1 -0
- package/dist/list-7NPSX2E4.mjs +136 -0
- package/dist/list-7NPSX2E4.mjs.map +1 -0
- package/dist/list-ZXFLAF52.js +136 -0
- package/dist/list-ZXFLAF52.js.map +1 -0
- package/dist/login-76NQIHKR.js +110 -0
- package/dist/login-76NQIHKR.js.map +1 -0
- package/dist/login-EK4WVOI2.mjs +110 -0
- package/dist/login-EK4WVOI2.mjs.map +1 -0
- package/dist/observability/index.d.mts +3 -3
- package/dist/observability/index.d.ts +3 -3
- package/dist/observability/index.js +5 -4
- package/dist/observability/index.js.map +1 -1
- package/dist/observability/index.mjs +4 -3
- package/dist/observability/instrumentation/langchain/index.d.mts +2 -2
- package/dist/observability/instrumentation/langchain/index.d.ts +2 -2
- package/dist/observability/instrumentation/langchain/index.js +29 -27
- package/dist/observability/instrumentation/langchain/index.js.map +1 -1
- package/dist/observability/instrumentation/langchain/index.mjs +5 -3
- package/dist/observability/instrumentation/langchain/index.mjs.map +1 -1
- package/dist/prompt/index.d.mts +2 -2
- package/dist/prompt/index.d.ts +2 -2
- package/dist/prompt/index.js +8 -4
- package/dist/prompt/index.js.map +1 -1
- package/dist/prompt/index.mjs +10 -6
- package/dist/{prompt-BXJWdbQp.d.mts → prompt-D-jpMrLS.d.mts} +245 -0
- package/dist/{prompt-BXJWdbQp.d.ts → prompt-D-jpMrLS.d.ts} +245 -0
- package/dist/remove-SDJYEPAY.mjs +106 -0
- package/dist/remove-SDJYEPAY.mjs.map +1 -0
- package/dist/remove-XBNGIVMR.js +106 -0
- package/dist/remove-XBNGIVMR.js.map +1 -0
- package/dist/sync-EISKGPTL.js +403 -0
- package/dist/sync-EISKGPTL.js.map +1 -0
- package/dist/sync-ST2IWXSB.mjs +403 -0
- package/dist/sync-ST2IWXSB.mjs.map +1 -0
- package/dist/{trace-G2312klE.d.ts → trace-CqaKo0kZ.d.ts} +1 -1
- package/dist/{trace-D-bZOuqb.d.mts → trace-DtVc5GhF.d.mts} +1 -1
- package/package.json +23 -12
- package/dist/chunk-76KNOWLS.js +0 -39
- package/dist/chunk-76KNOWLS.js.map +0 -1
- package/dist/chunk-G3AUABT7.js +0 -4
- package/dist/chunk-OM7VY3XT.mjs +0 -4
- package/dist/chunk-PTJ6AAI7.js.map +0 -1
- package/dist/chunk-SVJ7SCGB.js.map +0 -1
- package/dist/chunk-VJSOCNPA.js.map +0 -1
- package/dist/chunk-X62YT4WB.mjs +0 -39
- package/dist/chunk-X62YT4WB.mjs.map +0 -1
- package/dist/chunk-Z5J5UI5E.mjs.map +0 -1
- /package/dist/{chunk-CSC3CMIT.mjs.map → chunk-STV4ZVNA.mjs.map} +0 -0
- /package/dist/{chunk-OM7VY3XT.mjs.map → chunk-Y666BJA5.mjs.map} +0 -0
|
@@ -724,6 +724,23 @@ interface paths {
|
|
|
724
724
|
patch?: never;
|
|
725
725
|
trace?: never;
|
|
726
726
|
};
|
|
727
|
+
"/api/prompts/{id}/sync": {
|
|
728
|
+
parameters: {
|
|
729
|
+
query?: never;
|
|
730
|
+
header?: never;
|
|
731
|
+
path?: never;
|
|
732
|
+
cookie?: never;
|
|
733
|
+
};
|
|
734
|
+
get?: never;
|
|
735
|
+
put?: never;
|
|
736
|
+
/** @description Sync/upsert a prompt with local content */
|
|
737
|
+
post: operations["postApiPromptsByIdSync"];
|
|
738
|
+
delete?: never;
|
|
739
|
+
options?: never;
|
|
740
|
+
head?: never;
|
|
741
|
+
patch?: never;
|
|
742
|
+
trace?: never;
|
|
743
|
+
};
|
|
727
744
|
}
|
|
728
745
|
interface components {
|
|
729
746
|
schemas: {
|
|
@@ -903,6 +920,9 @@ interface operations {
|
|
|
903
920
|
schema: Record<string, never>;
|
|
904
921
|
};
|
|
905
922
|
} | null;
|
|
923
|
+
handle: string | null;
|
|
924
|
+
/** @enum {string} */
|
|
925
|
+
scope: "ORGANIZATION" | "PROJECT";
|
|
906
926
|
}[];
|
|
907
927
|
};
|
|
908
928
|
};
|
|
@@ -954,6 +974,12 @@ interface operations {
|
|
|
954
974
|
content: {
|
|
955
975
|
"application/json": {
|
|
956
976
|
name: string;
|
|
977
|
+
handle?: string;
|
|
978
|
+
/**
|
|
979
|
+
* @default PROJECT
|
|
980
|
+
* @enum {string}
|
|
981
|
+
*/
|
|
982
|
+
scope?: "ORGANIZATION" | "PROJECT";
|
|
957
983
|
};
|
|
958
984
|
};
|
|
959
985
|
};
|
|
@@ -988,6 +1014,9 @@ interface operations {
|
|
|
988
1014
|
schema: Record<string, never>;
|
|
989
1015
|
};
|
|
990
1016
|
} | null;
|
|
1017
|
+
handle: string | null;
|
|
1018
|
+
/** @enum {string} */
|
|
1019
|
+
scope: "ORGANIZATION" | "PROJECT";
|
|
991
1020
|
};
|
|
992
1021
|
};
|
|
993
1022
|
};
|
|
@@ -1069,6 +1098,9 @@ interface operations {
|
|
|
1069
1098
|
schema: Record<string, never>;
|
|
1070
1099
|
};
|
|
1071
1100
|
} | null;
|
|
1101
|
+
handle: string | null;
|
|
1102
|
+
/** @enum {string} */
|
|
1103
|
+
scope: "ORGANIZATION" | "PROJECT";
|
|
1072
1104
|
};
|
|
1073
1105
|
};
|
|
1074
1106
|
};
|
|
@@ -1133,6 +1165,9 @@ interface operations {
|
|
|
1133
1165
|
content: {
|
|
1134
1166
|
"application/json": {
|
|
1135
1167
|
name: string;
|
|
1168
|
+
handle?: string;
|
|
1169
|
+
/** @enum {string} */
|
|
1170
|
+
scope?: "ORGANIZATION" | "PROJECT";
|
|
1136
1171
|
};
|
|
1137
1172
|
};
|
|
1138
1173
|
};
|
|
@@ -1147,6 +1182,9 @@ interface operations {
|
|
|
1147
1182
|
id: string;
|
|
1148
1183
|
name: string;
|
|
1149
1184
|
updatedAt: string;
|
|
1185
|
+
handle: string | null;
|
|
1186
|
+
/** @enum {string} */
|
|
1187
|
+
scope: "ORGANIZATION" | "PROJECT";
|
|
1150
1188
|
};
|
|
1151
1189
|
};
|
|
1152
1190
|
};
|
|
@@ -1353,6 +1391,12 @@ interface operations {
|
|
|
1353
1391
|
ref?: string;
|
|
1354
1392
|
};
|
|
1355
1393
|
};
|
|
1394
|
+
author?: {
|
|
1395
|
+
name: string;
|
|
1396
|
+
} | null;
|
|
1397
|
+
handle: string | null;
|
|
1398
|
+
/** @enum {string} */
|
|
1399
|
+
scope: "ORGANIZATION" | "PROJECT";
|
|
1356
1400
|
};
|
|
1357
1401
|
};
|
|
1358
1402
|
};
|
|
@@ -1483,6 +1527,9 @@ interface operations {
|
|
|
1483
1527
|
ref?: string;
|
|
1484
1528
|
};
|
|
1485
1529
|
};
|
|
1530
|
+
author?: {
|
|
1531
|
+
name: string;
|
|
1532
|
+
} | null;
|
|
1486
1533
|
};
|
|
1487
1534
|
};
|
|
1488
1535
|
};
|
|
@@ -1561,6 +1608,12 @@ interface operations {
|
|
|
1561
1608
|
ref?: string;
|
|
1562
1609
|
};
|
|
1563
1610
|
};
|
|
1611
|
+
author?: {
|
|
1612
|
+
name: string;
|
|
1613
|
+
} | null;
|
|
1614
|
+
handle: string | null;
|
|
1615
|
+
/** @enum {string} */
|
|
1616
|
+
scope: "ORGANIZATION" | "PROJECT";
|
|
1564
1617
|
};
|
|
1565
1618
|
};
|
|
1566
1619
|
};
|
|
@@ -1914,6 +1967,196 @@ interface operations {
|
|
|
1914
1967
|
};
|
|
1915
1968
|
};
|
|
1916
1969
|
};
|
|
1970
|
+
postApiPromptsByIdSync: {
|
|
1971
|
+
parameters: {
|
|
1972
|
+
query?: never;
|
|
1973
|
+
header?: never;
|
|
1974
|
+
path: {
|
|
1975
|
+
id: string;
|
|
1976
|
+
};
|
|
1977
|
+
cookie?: never;
|
|
1978
|
+
};
|
|
1979
|
+
requestBody?: {
|
|
1980
|
+
content: {
|
|
1981
|
+
"application/json": {
|
|
1982
|
+
configData: {
|
|
1983
|
+
version?: number;
|
|
1984
|
+
prompt: string;
|
|
1985
|
+
/** @default [] */
|
|
1986
|
+
messages?: ({
|
|
1987
|
+
/** @enum {string} */
|
|
1988
|
+
role: "user" | "assistant" | "system";
|
|
1989
|
+
content: string;
|
|
1990
|
+
} & {
|
|
1991
|
+
[key: string]: unknown;
|
|
1992
|
+
})[];
|
|
1993
|
+
inputs: {
|
|
1994
|
+
identifier: string;
|
|
1995
|
+
/** @enum {string} */
|
|
1996
|
+
type: "str" | "float" | "bool" | "image" | "list[str]" | "list[float]" | "list[int]" | "list[bool]" | "dict";
|
|
1997
|
+
}[];
|
|
1998
|
+
outputs: {
|
|
1999
|
+
identifier: string;
|
|
2000
|
+
/** @enum {string} */
|
|
2001
|
+
type: "str" | "float" | "bool" | "json_schema";
|
|
2002
|
+
json_schema?: {
|
|
2003
|
+
type: string;
|
|
2004
|
+
} & {
|
|
2005
|
+
[key: string]: unknown;
|
|
2006
|
+
};
|
|
2007
|
+
}[];
|
|
2008
|
+
model: string;
|
|
2009
|
+
temperature?: number;
|
|
2010
|
+
max_tokens?: number;
|
|
2011
|
+
demonstrations?: {
|
|
2012
|
+
id?: string;
|
|
2013
|
+
name?: string;
|
|
2014
|
+
inline?: {
|
|
2015
|
+
records: {
|
|
2016
|
+
[key: string]: string[];
|
|
2017
|
+
};
|
|
2018
|
+
columnTypes: {
|
|
2019
|
+
name: string;
|
|
2020
|
+
type: "string" | "boolean" | "number" | "date" | "list" | "json" | "spans" | "rag_contexts" | "chat_messages" | "annotations" | "evaluations";
|
|
2021
|
+
}[];
|
|
2022
|
+
};
|
|
2023
|
+
};
|
|
2024
|
+
prompting_technique?: {
|
|
2025
|
+
ref?: string;
|
|
2026
|
+
};
|
|
2027
|
+
};
|
|
2028
|
+
localVersion?: number;
|
|
2029
|
+
commitMessage?: string;
|
|
2030
|
+
};
|
|
2031
|
+
};
|
|
2032
|
+
};
|
|
2033
|
+
responses: {
|
|
2034
|
+
/** @description Sync result */
|
|
2035
|
+
200: {
|
|
2036
|
+
headers: {
|
|
2037
|
+
[name: string]: unknown;
|
|
2038
|
+
};
|
|
2039
|
+
content: {
|
|
2040
|
+
"application/json": {
|
|
2041
|
+
/** @enum {string} */
|
|
2042
|
+
action: "created" | "updated" | "conflict" | "up_to_date";
|
|
2043
|
+
prompt?: {
|
|
2044
|
+
id: string;
|
|
2045
|
+
handle: string | null;
|
|
2046
|
+
/** @enum {string} */
|
|
2047
|
+
scope: "ORGANIZATION" | "PROJECT";
|
|
2048
|
+
name: string;
|
|
2049
|
+
updatedAt: string;
|
|
2050
|
+
version: number;
|
|
2051
|
+
versionId: string;
|
|
2052
|
+
versionCreatedAt: string;
|
|
2053
|
+
model: string;
|
|
2054
|
+
prompt: string;
|
|
2055
|
+
messages: ({
|
|
2056
|
+
/** @enum {string} */
|
|
2057
|
+
role: "user" | "assistant" | "system";
|
|
2058
|
+
content: string;
|
|
2059
|
+
} & {
|
|
2060
|
+
[key: string]: unknown;
|
|
2061
|
+
})[];
|
|
2062
|
+
response_format: {
|
|
2063
|
+
/** @enum {string} */
|
|
2064
|
+
type: "json_schema";
|
|
2065
|
+
json_schema: {
|
|
2066
|
+
name: string;
|
|
2067
|
+
schema: Record<string, never>;
|
|
2068
|
+
};
|
|
2069
|
+
} | null;
|
|
2070
|
+
};
|
|
2071
|
+
conflictInfo?: {
|
|
2072
|
+
localVersion: number;
|
|
2073
|
+
remoteVersion: number;
|
|
2074
|
+
differences: string[];
|
|
2075
|
+
remoteConfigData: {
|
|
2076
|
+
version?: number;
|
|
2077
|
+
prompt: string;
|
|
2078
|
+
/** @default [] */
|
|
2079
|
+
messages: ({
|
|
2080
|
+
/** @enum {string} */
|
|
2081
|
+
role: "user" | "assistant" | "system";
|
|
2082
|
+
content: string;
|
|
2083
|
+
} & {
|
|
2084
|
+
[key: string]: unknown;
|
|
2085
|
+
})[];
|
|
2086
|
+
inputs: {
|
|
2087
|
+
identifier: string;
|
|
2088
|
+
/** @enum {string} */
|
|
2089
|
+
type: "str" | "float" | "bool" | "image" | "list[str]" | "list[float]" | "list[int]" | "list[bool]" | "dict";
|
|
2090
|
+
}[];
|
|
2091
|
+
outputs: {
|
|
2092
|
+
identifier: string;
|
|
2093
|
+
/** @enum {string} */
|
|
2094
|
+
type: "str" | "float" | "bool" | "json_schema";
|
|
2095
|
+
json_schema?: {
|
|
2096
|
+
type: string;
|
|
2097
|
+
} & {
|
|
2098
|
+
[key: string]: unknown;
|
|
2099
|
+
};
|
|
2100
|
+
}[];
|
|
2101
|
+
model: string;
|
|
2102
|
+
temperature?: number;
|
|
2103
|
+
max_tokens?: number;
|
|
2104
|
+
demonstrations?: {
|
|
2105
|
+
id?: string;
|
|
2106
|
+
name?: string;
|
|
2107
|
+
inline?: {
|
|
2108
|
+
records: {
|
|
2109
|
+
[key: string]: string[];
|
|
2110
|
+
};
|
|
2111
|
+
columnTypes: {
|
|
2112
|
+
name: string;
|
|
2113
|
+
type: "string" | "boolean" | "number" | "date" | "list" | "json" | "spans" | "rag_contexts" | "chat_messages" | "annotations" | "evaluations";
|
|
2114
|
+
}[];
|
|
2115
|
+
};
|
|
2116
|
+
};
|
|
2117
|
+
prompting_technique?: {
|
|
2118
|
+
ref?: string;
|
|
2119
|
+
};
|
|
2120
|
+
};
|
|
2121
|
+
};
|
|
2122
|
+
};
|
|
2123
|
+
};
|
|
2124
|
+
};
|
|
2125
|
+
/** @description Bad Request */
|
|
2126
|
+
400: {
|
|
2127
|
+
headers: {
|
|
2128
|
+
[name: string]: unknown;
|
|
2129
|
+
};
|
|
2130
|
+
content: {
|
|
2131
|
+
"application/json": {
|
|
2132
|
+
error: string;
|
|
2133
|
+
};
|
|
2134
|
+
};
|
|
2135
|
+
};
|
|
2136
|
+
/** @description Unauthorized */
|
|
2137
|
+
401: {
|
|
2138
|
+
headers: {
|
|
2139
|
+
[name: string]: unknown;
|
|
2140
|
+
};
|
|
2141
|
+
content: {
|
|
2142
|
+
"application/json": {
|
|
2143
|
+
error: string;
|
|
2144
|
+
};
|
|
2145
|
+
};
|
|
2146
|
+
};
|
|
2147
|
+
/** @description Internal Server Error */
|
|
2148
|
+
500: {
|
|
2149
|
+
headers: {
|
|
2150
|
+
[name: string]: unknown;
|
|
2151
|
+
};
|
|
2152
|
+
content: {
|
|
2153
|
+
"application/json": {
|
|
2154
|
+
error: string;
|
|
2155
|
+
};
|
|
2156
|
+
};
|
|
2157
|
+
};
|
|
2158
|
+
};
|
|
2159
|
+
};
|
|
1917
2160
|
}
|
|
1918
2161
|
|
|
1919
2162
|
type PromptResponse = NonNullable<paths["/api/prompts/{id}"]["get"]["responses"]["200"]["content"]["application/json"]>;
|
|
@@ -1928,6 +2171,8 @@ declare class PromptCompilationError extends Error {
|
|
|
1928
2171
|
}
|
|
1929
2172
|
declare class Prompt implements PromptResponse {
|
|
1930
2173
|
readonly id: string;
|
|
2174
|
+
readonly handle: string | null;
|
|
2175
|
+
readonly scope: "ORGANIZATION" | "PROJECT";
|
|
1931
2176
|
readonly name: string;
|
|
1932
2177
|
readonly updatedAt: string;
|
|
1933
2178
|
readonly version: number;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FileManager
|
|
3
|
+
} from "./chunk-3GKPQB4R.mjs";
|
|
4
|
+
import "./chunk-4NRLVT2U.mjs";
|
|
5
|
+
import {
|
|
6
|
+
PromptsError
|
|
7
|
+
} from "./chunk-GJSEBQXF.mjs";
|
|
8
|
+
import "./chunk-W5ZEP3CI.mjs";
|
|
9
|
+
import "./chunk-QEWDG5QE.mjs";
|
|
10
|
+
import "./chunk-YN4436PK.mjs";
|
|
11
|
+
|
|
12
|
+
// src/cli/commands/remove.ts
|
|
13
|
+
import * as fs from "fs";
|
|
14
|
+
import * as path from "path";
|
|
15
|
+
import chalk from "chalk";
|
|
16
|
+
import ora from "ora";
|
|
17
|
+
var removeCommand = async (name) => {
|
|
18
|
+
try {
|
|
19
|
+
if (!name || name.trim() === "") {
|
|
20
|
+
console.error(chalk.red("Error: Prompt name cannot be empty"));
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const config = FileManager.loadPromptsConfig();
|
|
24
|
+
const lock = FileManager.loadPromptsLock();
|
|
25
|
+
if (!config.prompts[name]) {
|
|
26
|
+
console.error(chalk.red(`Error: Prompt "${name}" not found in dependencies`));
|
|
27
|
+
console.log(chalk.gray(`Available prompts: ${Object.keys(config.prompts).join(", ") || "none"}`));
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
const dependency = config.prompts[name];
|
|
31
|
+
const isLocalPrompt = typeof dependency === "string" && dependency.startsWith("file:") || typeof dependency === "object" && dependency.file;
|
|
32
|
+
const spinner = ora(`Removing ${chalk.cyan(name)}...`).start();
|
|
33
|
+
try {
|
|
34
|
+
if (isLocalPrompt) {
|
|
35
|
+
let localFilePath;
|
|
36
|
+
if (typeof dependency === "string" && dependency.startsWith("file:")) {
|
|
37
|
+
localFilePath = path.resolve(dependency.slice(5));
|
|
38
|
+
} else if (typeof dependency === "object" && dependency.file) {
|
|
39
|
+
localFilePath = path.resolve(dependency.file);
|
|
40
|
+
} else {
|
|
41
|
+
localFilePath = path.join(FileManager.getPromptsDir(), `${name}.prompt.yaml`);
|
|
42
|
+
}
|
|
43
|
+
if (fs.existsSync(localFilePath)) {
|
|
44
|
+
fs.unlinkSync(localFilePath);
|
|
45
|
+
const relativePath = path.relative(process.cwd(), localFilePath);
|
|
46
|
+
spinner.succeed();
|
|
47
|
+
console.log(chalk.green(`\u2713 Removed local file ${chalk.gray(relativePath)}`));
|
|
48
|
+
} else {
|
|
49
|
+
spinner.succeed();
|
|
50
|
+
console.log(chalk.yellow(`\u26A0 Local file not found (already deleted?)`));
|
|
51
|
+
}
|
|
52
|
+
console.log(chalk.yellow(`\u26A0 Note: This prompt may still exist on the server. Visit LangWatch to fully delete it.`));
|
|
53
|
+
}
|
|
54
|
+
const lockEntry = lock.prompts[name];
|
|
55
|
+
if (lockEntry == null ? void 0 : lockEntry.materialized) {
|
|
56
|
+
const materializedPath = path.resolve(lockEntry.materialized);
|
|
57
|
+
if (fs.existsSync(materializedPath)) {
|
|
58
|
+
fs.unlinkSync(materializedPath);
|
|
59
|
+
const materializedDir = path.dirname(materializedPath);
|
|
60
|
+
const rootMaterializedDir = FileManager.getMaterializedDir();
|
|
61
|
+
let currentDir = materializedDir;
|
|
62
|
+
while (currentDir !== rootMaterializedDir && currentDir !== path.dirname(currentDir)) {
|
|
63
|
+
try {
|
|
64
|
+
const entries = fs.readdirSync(currentDir);
|
|
65
|
+
if (entries.length === 0) {
|
|
66
|
+
fs.rmdirSync(currentDir);
|
|
67
|
+
currentDir = path.dirname(currentDir);
|
|
68
|
+
} else {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
} catch (e) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
delete config.prompts[name];
|
|
78
|
+
delete lock.prompts[name];
|
|
79
|
+
FileManager.savePromptsConfig(config);
|
|
80
|
+
FileManager.savePromptsLock(lock);
|
|
81
|
+
if (!isLocalPrompt) {
|
|
82
|
+
spinner.succeed();
|
|
83
|
+
console.log(chalk.green(`\u2713 Removed ${chalk.cyan(name)} from dependencies`));
|
|
84
|
+
}
|
|
85
|
+
} catch (error) {
|
|
86
|
+
spinner.fail();
|
|
87
|
+
if (error instanceof PromptsError) {
|
|
88
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
89
|
+
} else {
|
|
90
|
+
console.error(chalk.red(`Error removing prompt: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
91
|
+
}
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error instanceof PromptsError) {
|
|
96
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
97
|
+
} else {
|
|
98
|
+
console.error(chalk.red(`Unexpected error: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
99
|
+
}
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
export {
|
|
104
|
+
removeCommand
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=remove-SDJYEPAY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/remove.ts"],"sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { PromptService, PromptsError } from \"../../prompt/service\";\n\nexport const removeCommand = async (name: string): Promise<void> => {\n try {\n // Validate prompt name\n if (!name || name.trim() === \"\") {\n console.error(chalk.red(\"Error: Prompt name cannot be empty\"));\n process.exit(1);\n }\n\n // Load existing config and lock\n const config = FileManager.loadPromptsConfig();\n const lock = FileManager.loadPromptsLock();\n\n // Check if prompt exists in dependencies\n if (!config.prompts[name]) {\n console.error(chalk.red(`Error: Prompt \"${name}\" not found in dependencies`));\n console.log(chalk.gray(`Available prompts: ${Object.keys(config.prompts).join(', ') || 'none'}`));\n process.exit(1);\n }\n\n const dependency = config.prompts[name];\n const isLocalPrompt = (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) ||\n (typeof dependency === \"object\" && dependency.file);\n\n const spinner = ora(`Removing ${chalk.cyan(name)}...`).start();\n\n try {\n // Handle local prompts\n if (isLocalPrompt) {\n let localFilePath: string;\n\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n localFilePath = path.resolve(dependency.slice(5)); // Remove \"file:\" prefix\n } else if (typeof dependency === \"object\" && dependency.file) {\n localFilePath = path.resolve(dependency.file);\n } else {\n // Fallback: assume it's in the prompts directory\n localFilePath = path.join(FileManager.getPromptsDir(), `${name}.prompt.yaml`);\n }\n\n // Delete the local file if it exists\n if (fs.existsSync(localFilePath)) {\n fs.unlinkSync(localFilePath);\n const relativePath = path.relative(process.cwd(), localFilePath);\n spinner.succeed();\n console.log(chalk.green(`✓ Removed local file ${chalk.gray(relativePath)}`));\n } else {\n spinner.succeed();\n console.log(chalk.yellow(`⚠ Local file not found (already deleted?)`));\n }\n\n console.log(chalk.yellow(`⚠ Note: This prompt may still exist on the server. Visit LangWatch to fully delete it.`));\n }\n\n // Remove materialized file if it exists\n const lockEntry = lock.prompts[name];\n if (lockEntry?.materialized) {\n const materializedPath = path.resolve(lockEntry.materialized);\n if (fs.existsSync(materializedPath)) {\n fs.unlinkSync(materializedPath);\n\n // Clean up empty directories\n const materializedDir = path.dirname(materializedPath);\n const rootMaterializedDir = FileManager.getMaterializedDir();\n\n let currentDir = materializedDir;\n while (currentDir !== rootMaterializedDir && currentDir !== path.dirname(currentDir)) {\n try {\n const entries = fs.readdirSync(currentDir);\n if (entries.length === 0) {\n fs.rmdirSync(currentDir);\n currentDir = path.dirname(currentDir);\n } else {\n break;\n }\n } catch {\n break;\n }\n }\n }\n }\n\n // Remove from config and lock\n delete config.prompts[name];\n delete lock.prompts[name];\n\n // Save updated files\n FileManager.savePromptsConfig(config);\n FileManager.savePromptsLock(lock);\n\n if (!isLocalPrompt) {\n spinner.succeed();\n console.log(chalk.green(`✓ Removed ${chalk.cyan(name)} from dependencies`));\n }\n\n } catch (error) {\n spinner.fail();\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(chalk.red(`Error removing prompt: ${error instanceof Error ? error.message : \"Unknown error\"}`));\n }\n process.exit(1);\n }\n\n } catch (error) {\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(chalk.red(`Unexpected error: ${error instanceof Error ? error.message : \"Unknown error\"}`));\n }\n process.exit(1);\n }\n};"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunk2JU376G7js = require('./chunk-2JU376G7.js');
|
|
4
|
+
require('./chunk-HA3LI5IK.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkVGHLQXKBjs = require('./chunk-VGHLQXKB.js');
|
|
8
|
+
require('./chunk-SMXXAVMB.js');
|
|
9
|
+
require('./chunk-PCQVQ7SB.js');
|
|
10
|
+
require('./chunk-FJLK5CFL.js');
|
|
11
|
+
|
|
12
|
+
// src/cli/commands/remove.ts
|
|
13
|
+
var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
|
|
14
|
+
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
15
|
+
var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
|
|
16
|
+
var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);
|
|
17
|
+
var removeCommand = async (name) => {
|
|
18
|
+
try {
|
|
19
|
+
if (!name || name.trim() === "") {
|
|
20
|
+
console.error(_chalk2.default.red("Error: Prompt name cannot be empty"));
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const config = _chunk2JU376G7js.FileManager.loadPromptsConfig();
|
|
24
|
+
const lock = _chunk2JU376G7js.FileManager.loadPromptsLock();
|
|
25
|
+
if (!config.prompts[name]) {
|
|
26
|
+
console.error(_chalk2.default.red(`Error: Prompt "${name}" not found in dependencies`));
|
|
27
|
+
console.log(_chalk2.default.gray(`Available prompts: ${Object.keys(config.prompts).join(", ") || "none"}`));
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
const dependency = config.prompts[name];
|
|
31
|
+
const isLocalPrompt = typeof dependency === "string" && dependency.startsWith("file:") || typeof dependency === "object" && dependency.file;
|
|
32
|
+
const spinner = _ora2.default.call(void 0, `Removing ${_chalk2.default.cyan(name)}...`).start();
|
|
33
|
+
try {
|
|
34
|
+
if (isLocalPrompt) {
|
|
35
|
+
let localFilePath;
|
|
36
|
+
if (typeof dependency === "string" && dependency.startsWith("file:")) {
|
|
37
|
+
localFilePath = path.resolve(dependency.slice(5));
|
|
38
|
+
} else if (typeof dependency === "object" && dependency.file) {
|
|
39
|
+
localFilePath = path.resolve(dependency.file);
|
|
40
|
+
} else {
|
|
41
|
+
localFilePath = path.join(_chunk2JU376G7js.FileManager.getPromptsDir(), `${name}.prompt.yaml`);
|
|
42
|
+
}
|
|
43
|
+
if (fs.existsSync(localFilePath)) {
|
|
44
|
+
fs.unlinkSync(localFilePath);
|
|
45
|
+
const relativePath = path.relative(process.cwd(), localFilePath);
|
|
46
|
+
spinner.succeed();
|
|
47
|
+
console.log(_chalk2.default.green(`\u2713 Removed local file ${_chalk2.default.gray(relativePath)}`));
|
|
48
|
+
} else {
|
|
49
|
+
spinner.succeed();
|
|
50
|
+
console.log(_chalk2.default.yellow(`\u26A0 Local file not found (already deleted?)`));
|
|
51
|
+
}
|
|
52
|
+
console.log(_chalk2.default.yellow(`\u26A0 Note: This prompt may still exist on the server. Visit LangWatch to fully delete it.`));
|
|
53
|
+
}
|
|
54
|
+
const lockEntry = lock.prompts[name];
|
|
55
|
+
if (lockEntry == null ? void 0 : lockEntry.materialized) {
|
|
56
|
+
const materializedPath = path.resolve(lockEntry.materialized);
|
|
57
|
+
if (fs.existsSync(materializedPath)) {
|
|
58
|
+
fs.unlinkSync(materializedPath);
|
|
59
|
+
const materializedDir = path.dirname(materializedPath);
|
|
60
|
+
const rootMaterializedDir = _chunk2JU376G7js.FileManager.getMaterializedDir();
|
|
61
|
+
let currentDir = materializedDir;
|
|
62
|
+
while (currentDir !== rootMaterializedDir && currentDir !== path.dirname(currentDir)) {
|
|
63
|
+
try {
|
|
64
|
+
const entries = fs.readdirSync(currentDir);
|
|
65
|
+
if (entries.length === 0) {
|
|
66
|
+
fs.rmdirSync(currentDir);
|
|
67
|
+
currentDir = path.dirname(currentDir);
|
|
68
|
+
} else {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
} catch (e) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
delete config.prompts[name];
|
|
78
|
+
delete lock.prompts[name];
|
|
79
|
+
_chunk2JU376G7js.FileManager.savePromptsConfig(config);
|
|
80
|
+
_chunk2JU376G7js.FileManager.savePromptsLock(lock);
|
|
81
|
+
if (!isLocalPrompt) {
|
|
82
|
+
spinner.succeed();
|
|
83
|
+
console.log(_chalk2.default.green(`\u2713 Removed ${_chalk2.default.cyan(name)} from dependencies`));
|
|
84
|
+
}
|
|
85
|
+
} catch (error) {
|
|
86
|
+
spinner.fail();
|
|
87
|
+
if (error instanceof _chunkVGHLQXKBjs.PromptsError) {
|
|
88
|
+
console.error(_chalk2.default.red(`Error: ${error.message}`));
|
|
89
|
+
} else {
|
|
90
|
+
console.error(_chalk2.default.red(`Error removing prompt: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
91
|
+
}
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error instanceof _chunkVGHLQXKBjs.PromptsError) {
|
|
96
|
+
console.error(_chalk2.default.red(`Error: ${error.message}`));
|
|
97
|
+
} else {
|
|
98
|
+
console.error(_chalk2.default.red(`Unexpected error: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
99
|
+
}
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
exports.removeCommand = removeCommand;
|
|
106
|
+
//# sourceMappingURL=remove-XBNGIVMR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/remove-XBNGIVMR.js","../src/cli/commands/remove.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACA;ACXA,+DAAoB;AACpB,uEAAsB;AACtB,4EAAkB;AAClB,oEAAgB;AAIT,IAAM,cAAA,EAAgB,MAAA,CAAO,IAAA,EAAA,GAAgC;AAClE,EAAA,IAAI;AAEF,IAAA,GAAA,CAAI,CAAC,KAAA,GAAQ,IAAA,CAAK,IAAA,CAAK,EAAA,IAAM,EAAA,EAAI;AAC/B,MAAA,OAAA,CAAQ,KAAA,CAAM,eAAA,CAAM,GAAA,CAAI,oCAAoC,CAAC,CAAA;AAC7D,MAAA,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA;AAAA,IAChB;AAGA,IAAA,MAAM,OAAA,EAAS,4BAAA,CAAY,iBAAA,CAAkB,CAAA;AAC7C,IAAA,MAAM,KAAA,EAAO,4BAAA,CAAY,eAAA,CAAgB,CAAA;AAGzC,IAAA,GAAA,CAAI,CAAC,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,EAAG;AACzB,MAAA,OAAA,CAAQ,KAAA,CAAM,eAAA,CAAM,GAAA,CAAI,CAAA,eAAA,EAAkB,IAAI,CAAA,2BAAA,CAA6B,CAAC,CAAA;AAC5E,MAAA,OAAA,CAAQ,GAAA,CAAI,eAAA,CAAM,IAAA,CAAK,CAAA,mBAAA,EAAsB,MAAA,CAAO,IAAA,CAAK,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,CAAK,IAAI,EAAA,GAAK,MAAM,CAAA,CAAA;AAC/E,MAAA;AAChB,IAAA;AAEsC,IAAA;AAEhB,IAAA;AAEuC,IAAA;AAEzD,IAAA;AAEiB,MAAA;AACb,QAAA;AAEkE,QAAA;AACpB,UAAA;AACY,QAAA;AAChB,UAAA;AACvC,QAAA;AAEuE,UAAA;AAC9E,QAAA;AAGkC,QAAA;AACL,UAAA;AACoC,UAAA;AAC/C,UAAA;AAC2D,UAAA;AACtE,QAAA;AACW,UAAA;AACqD,UAAA;AACvE,QAAA;AAEyB,QAAA;AAC3B,MAAA;AAGmC,MAAA;AACN,MAAA;AACiC,QAAA;AACvB,QAAA;AACL,UAAA;AAGuB,UAAA;AACM,UAAA;AAE1C,UAAA;AACqE,UAAA;AAChF,YAAA;AACuC,cAAA;AACf,cAAA;AACD,gBAAA;AACa,gBAAA;AAC/B,cAAA;AACL,gBAAA;AACF,cAAA;AACM,YAAA;AACN,cAAA;AACF,YAAA;AACF,UAAA;AACF,QAAA;AACF,MAAA;AAG0B,MAAA;AACF,MAAA;AAGY,MAAA;AACJ,MAAA;AAEZ,MAAA;AACF,QAAA;AAC0D,QAAA;AAC5E,MAAA;AAEc,IAAA;AACD,MAAA;AACsB,MAAA;AACiB,QAAA;AAC7C,MAAA;AACsF,QAAA;AAC7F,MAAA;AACc,MAAA;AAChB,IAAA;AAEc,EAAA;AACqB,IAAA;AACiB,MAAA;AAC7C,IAAA;AACiF,MAAA;AACxF,IAAA;AACc,IAAA;AAChB,EAAA;AACF;ADjBoG;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/remove-XBNGIVMR.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { PromptService, PromptsError } from \"../../prompt/service\";\n\nexport const removeCommand = async (name: string): Promise<void> => {\n try {\n // Validate prompt name\n if (!name || name.trim() === \"\") {\n console.error(chalk.red(\"Error: Prompt name cannot be empty\"));\n process.exit(1);\n }\n\n // Load existing config and lock\n const config = FileManager.loadPromptsConfig();\n const lock = FileManager.loadPromptsLock();\n\n // Check if prompt exists in dependencies\n if (!config.prompts[name]) {\n console.error(chalk.red(`Error: Prompt \"${name}\" not found in dependencies`));\n console.log(chalk.gray(`Available prompts: ${Object.keys(config.prompts).join(', ') || 'none'}`));\n process.exit(1);\n }\n\n const dependency = config.prompts[name];\n const isLocalPrompt = (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) ||\n (typeof dependency === \"object\" && dependency.file);\n\n const spinner = ora(`Removing ${chalk.cyan(name)}...`).start();\n\n try {\n // Handle local prompts\n if (isLocalPrompt) {\n let localFilePath: string;\n\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n localFilePath = path.resolve(dependency.slice(5)); // Remove \"file:\" prefix\n } else if (typeof dependency === \"object\" && dependency.file) {\n localFilePath = path.resolve(dependency.file);\n } else {\n // Fallback: assume it's in the prompts directory\n localFilePath = path.join(FileManager.getPromptsDir(), `${name}.prompt.yaml`);\n }\n\n // Delete the local file if it exists\n if (fs.existsSync(localFilePath)) {\n fs.unlinkSync(localFilePath);\n const relativePath = path.relative(process.cwd(), localFilePath);\n spinner.succeed();\n console.log(chalk.green(`✓ Removed local file ${chalk.gray(relativePath)}`));\n } else {\n spinner.succeed();\n console.log(chalk.yellow(`⚠ Local file not found (already deleted?)`));\n }\n\n console.log(chalk.yellow(`⚠ Note: This prompt may still exist on the server. Visit LangWatch to fully delete it.`));\n }\n\n // Remove materialized file if it exists\n const lockEntry = lock.prompts[name];\n if (lockEntry?.materialized) {\n const materializedPath = path.resolve(lockEntry.materialized);\n if (fs.existsSync(materializedPath)) {\n fs.unlinkSync(materializedPath);\n\n // Clean up empty directories\n const materializedDir = path.dirname(materializedPath);\n const rootMaterializedDir = FileManager.getMaterializedDir();\n\n let currentDir = materializedDir;\n while (currentDir !== rootMaterializedDir && currentDir !== path.dirname(currentDir)) {\n try {\n const entries = fs.readdirSync(currentDir);\n if (entries.length === 0) {\n fs.rmdirSync(currentDir);\n currentDir = path.dirname(currentDir);\n } else {\n break;\n }\n } catch {\n break;\n }\n }\n }\n }\n\n // Remove from config and lock\n delete config.prompts[name];\n delete lock.prompts[name];\n\n // Save updated files\n FileManager.savePromptsConfig(config);\n FileManager.savePromptsLock(lock);\n\n if (!isLocalPrompt) {\n spinner.succeed();\n console.log(chalk.green(`✓ Removed ${chalk.cyan(name)} from dependencies`));\n }\n\n } catch (error) {\n spinner.fail();\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(chalk.red(`Error removing prompt: ${error instanceof Error ? error.message : \"Unknown error\"}`));\n }\n process.exit(1);\n }\n\n } catch (error) {\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(chalk.red(`Unexpected error: ${error instanceof Error ? error.message : \"Unknown error\"}`));\n }\n process.exit(1);\n }\n};"]}
|