stow-cli 2.2.0 → 2.2.3
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 +10 -10
- package/dist/app-ZIHTOHXL.js +255 -0
- package/dist/backfill-BG65X4TP.js +65 -0
- package/dist/backfill-JCNPLFJU.js +67 -0
- package/dist/backfill-KW46AEAL.js +67 -0
- package/dist/backfill-VAORMLMY.js +67 -0
- package/dist/buckets-AFNX7FV3.js +137 -0
- package/dist/buckets-FPMMPRR2.js +130 -0
- package/dist/buckets-JJBWUVKF.js +137 -0
- package/dist/buckets-VYI2QVLO.js +137 -0
- package/dist/chunk-533UGNLM.js +42 -0
- package/dist/chunk-5BVMPHKH.js +147 -0
- package/dist/chunk-5IX3ASXH.js +153 -0
- package/dist/chunk-AHBVZRDR.js +29 -0
- package/dist/chunk-KPIQZBTO.js +151 -0
- package/dist/chunk-MYFLRBWC.js +312 -0
- package/dist/chunk-NBHBVKP5.js +54 -0
- package/dist/chunk-PE6V3MVP.js +46 -0
- package/dist/chunk-RH4BOSYB.js +153 -0
- package/dist/chunk-XVKIRHTX.js +29 -0
- package/dist/cli.js +184 -200
- package/dist/delete-3UDS4RMH.js +34 -0
- package/dist/delete-CQJEGLP3.js +34 -0
- package/dist/describe-CU5FBHZS.js +79 -0
- package/dist/describe-HSEHMJVD.js +79 -0
- package/dist/describe-NH3K3LLW.js +79 -0
- package/dist/describe-W3ED4VW3.js +79 -0
- package/dist/drops-XO4CZ4BH.js +39 -0
- package/dist/files-BIMA5L2G.js +206 -0
- package/dist/files-CFOTEASC.js +206 -0
- package/dist/files-SQURZ7VO.js +194 -0
- package/dist/files-XU6MDPP4.js +206 -0
- package/dist/health-3U3RHXFS.js +56 -0
- package/dist/health-SH6T6DZS.js +61 -0
- package/dist/health-TIJU6U2D.js +61 -0
- package/dist/health-YLNNKAFP.js +61 -0
- package/dist/jobs-HUW6Z6A7.js +87 -0
- package/dist/jobs-KK5IZYO5.js +99 -0
- package/dist/jobs-RMRGXLAA.js +90 -0
- package/dist/jobs-ROJFRPMR.js +90 -0
- package/dist/jobs-SX7DIN6T.js +90 -0
- package/dist/jobs-TND5AHCL.js +102 -0
- package/dist/jobs-TOLVGN6K.js +102 -0
- package/dist/jobs-XUAXWUAK.js +102 -0
- package/dist/maintenance-6XNJ56LL.js +79 -0
- package/dist/maintenance-7UBKZOR3.js +79 -0
- package/dist/maintenance-US3PUKFF.js +79 -0
- package/dist/maintenance-V2TXPXQE.js +79 -0
- package/dist/mcp-TUZZB2C7.js +189 -0
- package/dist/profiles-FOLKZZRU.js +53 -0
- package/dist/profiles-MB3TZQE4.js +53 -0
- package/dist/profiles-NVCJCYXR.js +53 -0
- package/dist/profiles-XXVM3UKI.js +53 -0
- package/dist/queues-AUGTAFBT.js +61 -0
- package/dist/queues-MTA2RWUP.js +56 -0
- package/dist/queues-NR25TGT7.js +61 -0
- package/dist/queues-X6IU3KBZ.js +61 -0
- package/dist/search-ETC2EXKM.js +135 -0
- package/dist/search-ICJO264J.js +135 -0
- package/dist/search-ULMFDWHE.js +135 -0
- package/dist/search-UWLK4OL2.js +119 -0
- package/dist/tags-75SSHS26.js +90 -0
- package/dist/tags-OFZQ2XCX.js +90 -0
- package/dist/tags-TBFPDHIQ.js +90 -0
- package/dist/tags-V43DCLPQ.js +90 -0
- package/dist/upload-F5I2SJRB.js +126 -0
- package/dist/upload-N7NAVN3Q.js +126 -0
- package/dist/whoami-WUQDFC5P.js +28 -0
- package/package.json +20 -20
- package/LICENSE +0 -21
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/lib/format.ts
|
|
2
|
+
function padCell(str, width) {
|
|
3
|
+
return str.padEnd(width);
|
|
4
|
+
}
|
|
5
|
+
function formatBytes(bytes) {
|
|
6
|
+
if (bytes === 0) {
|
|
7
|
+
return "0 B";
|
|
8
|
+
}
|
|
9
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
10
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
11
|
+
return `${(bytes / 1024 ** i).toFixed(i > 0 ? 1 : 0)} ${units[i]}`;
|
|
12
|
+
}
|
|
13
|
+
function formatTable(headers, rows) {
|
|
14
|
+
if (rows.length === 0) {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
const widths = headers.map((h, i) => {
|
|
18
|
+
let dataMax = 0;
|
|
19
|
+
for (const row of rows) {
|
|
20
|
+
const cellLength = (row[i] || "").length;
|
|
21
|
+
if (cellLength > dataMax) {
|
|
22
|
+
dataMax = cellLength;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return Math.max(h.length, dataMax);
|
|
26
|
+
});
|
|
27
|
+
const sep = widths.map((w) => "\u2500".repeat(w)).join("\u2500\u2500");
|
|
28
|
+
const lines = [headers.map((h, i) => padCell(h, widths[i] ?? 0)).join(" "), sep];
|
|
29
|
+
for (const row of rows) {
|
|
30
|
+
lines.push(row.map((cell, i) => padCell(cell || "", widths[i] ?? 0)).join(" "));
|
|
31
|
+
}
|
|
32
|
+
return lines.join("\n");
|
|
33
|
+
}
|
|
34
|
+
function usageBar(used, total, width = 20) {
|
|
35
|
+
const ratio = Math.min(used / total, 1);
|
|
36
|
+
const filled = Math.round(ratio * width);
|
|
37
|
+
const empty = width - filled;
|
|
38
|
+
const pct = Math.round(ratio * 100);
|
|
39
|
+
return `[${"\u2588".repeat(filled)}${"\u2591".repeat(empty)}] ${pct}%`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
formatBytes,
|
|
44
|
+
formatTable,
|
|
45
|
+
usageBar
|
|
46
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// src/lib/sanitize-response.ts
|
|
2
|
+
var INJECTION_PATTERNS = [
|
|
3
|
+
// Direct instruction injection
|
|
4
|
+
/\b(?:ignore|disregard|forget)\b.*\b(?:previous|above|prior)\b.*\b(?:instructions?|rules?|context)\b/i,
|
|
5
|
+
// System prompt extraction attempts
|
|
6
|
+
/\b(?:reveal|show|print|output|display)\b.*\b(?:system\s*prompt|instructions?|rules?)\b/i,
|
|
7
|
+
// Role hijacking
|
|
8
|
+
/\byou\s+are\s+(?:now|a)\b/i,
|
|
9
|
+
// Tool/action injection
|
|
10
|
+
/\b(?:execute|run|call)\b.*\b(?:command|tool|function|bash|shell)\b/i,
|
|
11
|
+
// Markdown/XML injection that could affect agent parsing
|
|
12
|
+
/<\/?(?:system|user|assistant|tool_use|tool_result)\b/i
|
|
13
|
+
];
|
|
14
|
+
var USER_CONTENT_FIELDS = /* @__PURE__ */ new Set([
|
|
15
|
+
"originalFilename",
|
|
16
|
+
"filename",
|
|
17
|
+
"name",
|
|
18
|
+
"description",
|
|
19
|
+
"label",
|
|
20
|
+
"text",
|
|
21
|
+
"slug",
|
|
22
|
+
"webhookUrl"
|
|
23
|
+
]);
|
|
24
|
+
function detectInjection(value) {
|
|
25
|
+
return INJECTION_PATTERNS.some((pattern) => pattern.test(value));
|
|
26
|
+
}
|
|
27
|
+
function sanitizeValue(value) {
|
|
28
|
+
if (detectInjection(value)) {
|
|
29
|
+
return `[FLAGGED: potential prompt injection] ${value}`;
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function sanitizeResponse(data) {
|
|
34
|
+
if (data === null || data === void 0) {
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
if (typeof data === "string") {
|
|
38
|
+
return sanitizeValue(data);
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(data)) {
|
|
41
|
+
return data.map((item) => sanitizeResponse(item));
|
|
42
|
+
}
|
|
43
|
+
if (typeof data === "object") {
|
|
44
|
+
const result = {};
|
|
45
|
+
for (const [key, value] of Object.entries(data)) {
|
|
46
|
+
if (USER_CONTENT_FIELDS.has(key) && typeof value === "string") {
|
|
47
|
+
result[key] = sanitizeValue(value);
|
|
48
|
+
} else if (typeof value === "object" && value !== null) {
|
|
49
|
+
result[key] = sanitizeResponse(value);
|
|
50
|
+
} else {
|
|
51
|
+
result[key] = value;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/lib/output.ts
|
|
60
|
+
var _forceHuman = false;
|
|
61
|
+
var _globalFields;
|
|
62
|
+
var _globalNdjson = false;
|
|
63
|
+
function setForceHuman(value) {
|
|
64
|
+
_forceHuman = value;
|
|
65
|
+
}
|
|
66
|
+
function setGlobalFields(fields) {
|
|
67
|
+
_globalFields = fields;
|
|
68
|
+
}
|
|
69
|
+
function setGlobalNdjson(value) {
|
|
70
|
+
_globalNdjson = value;
|
|
71
|
+
}
|
|
72
|
+
function isJsonOutput() {
|
|
73
|
+
if (_forceHuman) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return !process.stdout.isTTY;
|
|
77
|
+
}
|
|
78
|
+
function output(data, humanFormatter, options) {
|
|
79
|
+
const sanitized = sanitizeResponse(data);
|
|
80
|
+
const unwrapped = _globalFields || _globalNdjson ? unwrapArray(sanitized) : sanitized;
|
|
81
|
+
const masked = applyFieldMask(unwrapped, _globalFields);
|
|
82
|
+
if (_globalNdjson && Array.isArray(masked)) {
|
|
83
|
+
outputNdjson(masked);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (options?.json || isJsonOutput()) {
|
|
87
|
+
console.log(JSON.stringify(masked, null, 2));
|
|
88
|
+
} else if (humanFormatter && !_globalFields) {
|
|
89
|
+
console.log(humanFormatter());
|
|
90
|
+
} else {
|
|
91
|
+
console.log(JSON.stringify(masked, null, 2));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function outputError(error, code, details) {
|
|
95
|
+
if (isJsonOutput()) {
|
|
96
|
+
console.error(
|
|
97
|
+
JSON.stringify({ error, ...code ? { code } : {}, ...details })
|
|
98
|
+
);
|
|
99
|
+
} else {
|
|
100
|
+
console.error(`Error: ${error}`);
|
|
101
|
+
}
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
function outputNdjson(items) {
|
|
105
|
+
for (const item of items) {
|
|
106
|
+
const sanitized = sanitizeResponse(item);
|
|
107
|
+
console.log(JSON.stringify(sanitized));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function applyFieldMask(data, fields) {
|
|
111
|
+
if (!fields) {
|
|
112
|
+
return data;
|
|
113
|
+
}
|
|
114
|
+
const fieldSet = new Set(fields.split(",").map((f) => f.trim()));
|
|
115
|
+
if (Array.isArray(data)) {
|
|
116
|
+
return data.map((item) => pickFields(item, fieldSet));
|
|
117
|
+
}
|
|
118
|
+
if (typeof data === "object" && data !== null) {
|
|
119
|
+
return pickFields(data, fieldSet);
|
|
120
|
+
}
|
|
121
|
+
return data;
|
|
122
|
+
}
|
|
123
|
+
function unwrapArray(data) {
|
|
124
|
+
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
125
|
+
return data;
|
|
126
|
+
}
|
|
127
|
+
const entries = Object.entries(data);
|
|
128
|
+
if (entries.length === 1 && Array.isArray(entries[0][1])) {
|
|
129
|
+
return entries[0][1];
|
|
130
|
+
}
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
133
|
+
function pickFields(obj, fieldSet) {
|
|
134
|
+
if (typeof obj !== "object" || obj === null) {
|
|
135
|
+
return {};
|
|
136
|
+
}
|
|
137
|
+
const result = {};
|
|
138
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
139
|
+
if (fieldSet.has(key)) {
|
|
140
|
+
result[key] = value;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
setForceHuman,
|
|
148
|
+
setGlobalFields,
|
|
149
|
+
setGlobalNdjson,
|
|
150
|
+
isJsonOutput,
|
|
151
|
+
output,
|
|
152
|
+
outputError
|
|
153
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/lib/parse-json-input.ts
|
|
2
|
+
function stripUndefined(obj) {
|
|
3
|
+
const result = {};
|
|
4
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
5
|
+
if (value !== void 0) {
|
|
6
|
+
result[key] = value;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
function parseJsonInput(jsonStr, flagValues) {
|
|
12
|
+
if (!jsonStr) {
|
|
13
|
+
return flagValues;
|
|
14
|
+
}
|
|
15
|
+
let parsed;
|
|
16
|
+
try {
|
|
17
|
+
parsed = JSON.parse(jsonStr);
|
|
18
|
+
} catch {
|
|
19
|
+
throw new Error(`Invalid JSON in --input-json: ${jsonStr.slice(0, 100)}`);
|
|
20
|
+
}
|
|
21
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
22
|
+
throw new Error("--input-json must be a JSON object");
|
|
23
|
+
}
|
|
24
|
+
return { ...parsed, ...stripUndefined(flagValues) };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
parseJsonInput
|
|
29
|
+
};
|