@defai.digital/ax-cli 3.14.2 → 3.14.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
CHANGED
|
@@ -49,7 +49,7 @@ ax-cli
|
|
|
49
49
|
- [Security](#security)
|
|
50
50
|
- [Architecture](#architecture)
|
|
51
51
|
- [Changelog](#changelog)
|
|
52
|
-
- [Recent Changes (v3.14.
|
|
52
|
+
- [Recent Changes (v3.14.3)](#recent-changes-v3143)
|
|
53
53
|
- [Documentation](#documentation)
|
|
54
54
|
|
|
55
55
|
---
|
|
@@ -403,7 +403,11 @@ Email: **security@defai.digital** (private disclosure)
|
|
|
403
403
|
|
|
404
404
|
---
|
|
405
405
|
|
|
406
|
-
## Recent Changes (v3.14.
|
|
406
|
+
## Recent Changes (v3.14.3)
|
|
407
|
+
|
|
408
|
+
### New Features
|
|
409
|
+
|
|
410
|
+
- **Quoted Path Support**: Image paths with spaces now supported using quotes (`@"path with spaces/image.png"` or `'/path/file name.jpg'`)
|
|
407
411
|
|
|
408
412
|
### Bug Fixes
|
|
409
413
|
|
|
@@ -6,9 +6,17 @@ import * as path from 'path';
|
|
|
6
6
|
import { processImageFromPath, formatBytes, ImageProcessingError, SUPPORTED_IMAGE_FORMATS, MAX_IMAGE_SIZE_BYTES, TOKENS_PER_IMAGE, } from '../../utils/image-processor.js';
|
|
7
7
|
/** Regex patterns (compiled once at module load) */
|
|
8
8
|
// Exclude URLs (http://, https://, file://, ftp://, data:) from @ references
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
// Supports: @path/file.png, @"path with spaces/file.png", @'path with spaces/file.png'
|
|
10
|
+
const AT_REF_PATTERN = /@((?!https?:\/\/|ftp:\/\/|file:\/\/|data:)[^\s]+\.(png|jpg|jpeg|gif|webp)|"[^"]+\.(png|jpg|jpeg|gif|webp)"|'[^']+\.(png|jpg|jpeg|gif|webp)')/gi;
|
|
11
|
+
// Supports Unix (/path), relative (./path, ../path), Windows (C:\path), UNC (\\server\share), and quoted paths
|
|
12
|
+
const DIRECT_PATH_PATTERN = /^(\/[^\s]+\.(png|jpg|jpeg|gif|webp)|\.\.?\/[^\s]+\.(png|jpg|jpeg|gif|webp)|[a-zA-Z]:[\\/][^\s]+\.(png|jpg|jpeg|gif|webp)|\\\\[^\s]+\.(png|jpg|jpeg|gif|webp)|"[^"]+\.(png|jpg|jpeg|gif|webp)"|'[^']+\.(png|jpg|jpeg|gif|webp)')$/i;
|
|
13
|
+
/** Strip surrounding quotes from a path */
|
|
14
|
+
function stripQuotes(p) {
|
|
15
|
+
if ((p.startsWith('"') && p.endsWith('"')) || (p.startsWith("'") && p.endsWith("'"))) {
|
|
16
|
+
return p.slice(1, -1);
|
|
17
|
+
}
|
|
18
|
+
return p;
|
|
19
|
+
}
|
|
12
20
|
/** Parse user input for image references */
|
|
13
21
|
export async function parseImageInput(input, workingDir = process.cwd()) {
|
|
14
22
|
const images = [];
|
|
@@ -18,17 +26,18 @@ export async function parseImageInput(input, workingDir = process.cwd()) {
|
|
|
18
26
|
const pathToIndex = new Map(); // Map resolved path to image index
|
|
19
27
|
for (const [fullMatch, relativePath] of input.matchAll(AT_REF_PATTERN)) {
|
|
20
28
|
try {
|
|
21
|
-
const
|
|
29
|
+
const cleanPath = stripQuotes(relativePath);
|
|
30
|
+
const image = await processImageFromPath(cleanPath, workingDir);
|
|
22
31
|
const resolvedPath = image.originalPath;
|
|
23
32
|
if (seenPaths.has(resolvedPath)) {
|
|
24
33
|
// Same file referenced differently - reuse existing placeholder
|
|
25
34
|
const existingIndex = pathToIndex.get(resolvedPath);
|
|
26
|
-
const name = path.basename(
|
|
35
|
+
const name = path.basename(cleanPath);
|
|
27
36
|
textContent = textContent.split(fullMatch).join(`[Image #${existingIndex}: ${name}]`);
|
|
28
37
|
continue;
|
|
29
38
|
}
|
|
30
39
|
seenPaths.add(resolvedPath);
|
|
31
|
-
const name = path.basename(
|
|
40
|
+
const name = path.basename(cleanPath);
|
|
32
41
|
images.push({ image, preview: `[Image: ${name}]`, originalReference: fullMatch });
|
|
33
42
|
pathToIndex.set(resolvedPath, images.length);
|
|
34
43
|
textContent = textContent.split(fullMatch).join(`[Image #${images.length}: ${name}]`);
|
|
@@ -41,8 +50,9 @@ export async function parseImageInput(input, workingDir = process.cwd()) {
|
|
|
41
50
|
const trimmed = input.trim();
|
|
42
51
|
if (!images.length && DIRECT_PATH_PATTERN.test(trimmed)) {
|
|
43
52
|
try {
|
|
44
|
-
const
|
|
45
|
-
const
|
|
53
|
+
const cleanPath = stripQuotes(trimmed);
|
|
54
|
+
const image = await processImageFromPath(cleanPath, workingDir);
|
|
55
|
+
const name = path.basename(cleanPath);
|
|
46
56
|
images.push({ image, preview: `[Image: ${name}]`, originalReference: trimmed });
|
|
47
57
|
textContent = `Please analyze this image: ${name}`;
|
|
48
58
|
}
|
|
@@ -53,7 +63,8 @@ export async function parseImageInput(input, workingDir = process.cwd()) {
|
|
|
53
63
|
}
|
|
54
64
|
return { text: textContent.trim(), images, errors, hasImages: images.length > 0 };
|
|
55
65
|
}
|
|
56
|
-
|
|
66
|
+
// Quick check for @ references (unquoted or quoted)
|
|
67
|
+
const AT_REF_CHECK = /@(?:(?!https?:\/\/|ftp:\/\/|file:\/\/|data:)[^\s]+\.(png|jpg|jpeg|gif|webp)|"[^"]+\.(png|jpg|jpeg|gif|webp)"|'[^']+\.(png|jpg|jpeg|gif|webp)')/i;
|
|
57
68
|
/** Check if input contains image references (quick check) */
|
|
58
69
|
export function hasImageReferences(input) {
|
|
59
70
|
return AT_REF_CHECK.test(input) || DIRECT_PATH_PATTERN.test(input.trim());
|
|
@@ -71,9 +82,10 @@ export function buildMessageContent(parsed) {
|
|
|
71
82
|
}
|
|
72
83
|
/** Help text (static) */
|
|
73
84
|
const HELP_TEXT = `Image Input Methods:
|
|
74
|
-
@path/to/image.png
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
@path/to/image.png - Reference image with @ prefix
|
|
86
|
+
@"path with spaces.png" - Quoted path for names with spaces
|
|
87
|
+
/absolute/path.png - Direct absolute path
|
|
88
|
+
"./path with spaces.png" - Quoted direct path
|
|
77
89
|
|
|
78
90
|
Supported formats: ${SUPPORTED_IMAGE_FORMATS.join(', ')}
|
|
79
91
|
Maximum size: ${formatBytes(MAX_IMAGE_SIZE_BYTES)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-handler.js","sourceRoot":"","sources":["../../../src/ui/utils/image-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,WAAW,EAEX,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AAkBxC,oDAAoD;AACpD,6EAA6E;AAC7E,MAAM,cAAc,GAAG,
|
|
1
|
+
{"version":3,"file":"image-handler.js","sourceRoot":"","sources":["../../../src/ui/utils/image-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,WAAW,EAEX,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AAkBxC,oDAAoD;AACpD,6EAA6E;AAC7E,uFAAuF;AACvF,MAAM,cAAc,GAAG,gJAAgJ,CAAC;AACxK,+GAA+G;AAC/G,MAAM,mBAAmB,GAAG,mOAAmO,CAAC;AAEhQ,2CAA2C;AAC3C,SAAS,WAAW,CAAC,CAAS;IAC5B,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;Q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B,CAAC,IAAI,CAAC,IAAI,CAAC;gBACvC,WAAW,CAAC,oBAAoB,CAAC;;oDAEG,CAAC;AAErD,oCAAoC;AACpC,MAAM,UAAU,gBAAgB;IAC9B,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,0BAA0B,CAAC,UAA2B,EAAE,KAAa;IACnF,OAAO,KAAK,KAAK,KAAK,UAAU,CAAC,OAAO,KAAK,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,gBAAgB,UAAU,CAAC;AACvH,CAAC;AAED,kDAAkD;AAClD,MAAM,OAAO,iBAAiB;IAC5B,MAAM,CAAC,UAAU,GAAG,eAAe,CAAC;IACpC,MAAM,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,MAAM,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,MAAM,CAAC,WAAW,GAAG,gBAAgB,CAAC;IACtC,MAAM,CAAC,0BAA0B,GAAG,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defai.digital/ax-cli",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.3",
|
|
4
4
|
"sdkVersion": "1.3.0",
|
|
5
5
|
"description": "Enterprise-Class AI Command Line Interface - Primary support for GLM (General Language Model) with multi-provider AI orchestration powered by AutomatosX.",
|
|
6
6
|
"type": "module",
|