@hardlydifficult/agent-tools 1.0.0
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/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/parsePath.d.ts +15 -0
- package/dist/parsePath.d.ts.map +1 -0
- package/dist/parsePath.js +22 -0
- package/dist/parsePath.js.map +1 -0
- package/dist/utils.d.ts +16 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +35 -0
- package/dist/utils.js.map +1 -0
- package/package.json +21 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Max bytes to return from read_file before truncating. */
|
|
2
|
+
export declare const MAX_READ_BYTES = 100000;
|
|
3
|
+
/** Max file size (bytes) to scan during content search — skip larger files. */
|
|
4
|
+
export declare const MAX_GREP_FILE_SIZE: number;
|
|
5
|
+
/** Max total matches returned by search_files. */
|
|
6
|
+
export declare const MAX_SEARCH_RESULTS = 100;
|
|
7
|
+
/** Lines of context to show around each edit in write_file output. */
|
|
8
|
+
export declare const MAX_CONTEXT_LINES = 3;
|
|
9
|
+
/** Timeout for verify tool commands (ms). */
|
|
10
|
+
export declare const VERIFY_TIMEOUT = 120000;
|
|
11
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,eAAO,MAAM,cAAc,SAAU,CAAC;AAEtC,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,QAAa,CAAC;AAE7C,kDAAkD;AAClD,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,6CAA6C;AAC7C,eAAO,MAAM,cAAc,SAAU,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VERIFY_TIMEOUT = exports.MAX_CONTEXT_LINES = exports.MAX_SEARCH_RESULTS = exports.MAX_GREP_FILE_SIZE = exports.MAX_READ_BYTES = void 0;
|
|
4
|
+
/** Max bytes to return from read_file before truncating. */
|
|
5
|
+
exports.MAX_READ_BYTES = 100_000;
|
|
6
|
+
/** Max file size (bytes) to scan during content search — skip larger files. */
|
|
7
|
+
exports.MAX_GREP_FILE_SIZE = 100 * 1024;
|
|
8
|
+
/** Max total matches returned by search_files. */
|
|
9
|
+
exports.MAX_SEARCH_RESULTS = 100;
|
|
10
|
+
/** Lines of context to show around each edit in write_file output. */
|
|
11
|
+
exports.MAX_CONTEXT_LINES = 3;
|
|
12
|
+
/** Timeout for verify tool commands (ms). */
|
|
13
|
+
exports.VERIFY_TIMEOUT = 120_000;
|
|
14
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC/C,QAAA,cAAc,GAAG,OAAO,CAAC;AAEtC,+EAA+E;AAClE,QAAA,kBAAkB,GAAG,GAAG,GAAG,IAAI,CAAC;AAE7C,kDAAkD;AACrC,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAEtC,sEAAsE;AACzD,QAAA,iBAAiB,GAAG,CAAC,CAAC;AAEnC,6CAA6C;AAChC,QAAA,cAAc,GAAG,OAAO,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { parsePath, type ParsedPath } from "./parsePath.js";
|
|
2
|
+
export { MAX_READ_BYTES, MAX_GREP_FILE_SIZE, MAX_SEARCH_RESULTS, MAX_CONTEXT_LINES, VERIFY_TIMEOUT, } from "./config.js";
|
|
3
|
+
export { toArray, executeWithErrorHandling, formatArrayResult, } from "./utils.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,OAAO,EACP,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatArrayResult = exports.executeWithErrorHandling = exports.toArray = exports.VERIFY_TIMEOUT = exports.MAX_CONTEXT_LINES = exports.MAX_SEARCH_RESULTS = exports.MAX_GREP_FILE_SIZE = exports.MAX_READ_BYTES = exports.parsePath = void 0;
|
|
4
|
+
var parsePath_js_1 = require("./parsePath.js");
|
|
5
|
+
Object.defineProperty(exports, "parsePath", { enumerable: true, get: function () { return parsePath_js_1.parsePath; } });
|
|
6
|
+
var config_js_1 = require("./config.js");
|
|
7
|
+
Object.defineProperty(exports, "MAX_READ_BYTES", { enumerable: true, get: function () { return config_js_1.MAX_READ_BYTES; } });
|
|
8
|
+
Object.defineProperty(exports, "MAX_GREP_FILE_SIZE", { enumerable: true, get: function () { return config_js_1.MAX_GREP_FILE_SIZE; } });
|
|
9
|
+
Object.defineProperty(exports, "MAX_SEARCH_RESULTS", { enumerable: true, get: function () { return config_js_1.MAX_SEARCH_RESULTS; } });
|
|
10
|
+
Object.defineProperty(exports, "MAX_CONTEXT_LINES", { enumerable: true, get: function () { return config_js_1.MAX_CONTEXT_LINES; } });
|
|
11
|
+
Object.defineProperty(exports, "VERIFY_TIMEOUT", { enumerable: true, get: function () { return config_js_1.VERIFY_TIMEOUT; } });
|
|
12
|
+
var utils_js_1 = require("./utils.js");
|
|
13
|
+
Object.defineProperty(exports, "toArray", { enumerable: true, get: function () { return utils_js_1.toArray; } });
|
|
14
|
+
Object.defineProperty(exports, "executeWithErrorHandling", { enumerable: true, get: function () { return utils_js_1.executeWithErrorHandling; } });
|
|
15
|
+
Object.defineProperty(exports, "formatArrayResult", { enumerable: true, get: function () { return utils_js_1.formatArrayResult; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAAnD,yGAAA,SAAS,OAAA;AAClB,yCAMqB;AALnB,2GAAA,cAAc,OAAA;AACd,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,8GAAA,iBAAiB,OAAA;AACjB,2GAAA,cAAc,OAAA;AAEhB,uCAIoB;AAHlB,mGAAA,OAAO,OAAA;AACP,oHAAA,wBAAwB,OAAA;AACxB,6GAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ParsedPath {
|
|
2
|
+
filePath: string;
|
|
3
|
+
startLine?: number;
|
|
4
|
+
endLine?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Parse a GitHub-style path with optional line range.
|
|
8
|
+
*
|
|
9
|
+
* Examples:
|
|
10
|
+
* 'src/index.ts' → { filePath: 'src/index.ts' }
|
|
11
|
+
* 'src/index.ts#L10' → { filePath: 'src/index.ts', startLine: 10, endLine: 10 }
|
|
12
|
+
* 'src/index.ts#L10-L20' → { filePath: 'src/index.ts', startLine: 10, endLine: 20 }
|
|
13
|
+
*/
|
|
14
|
+
export declare function parsePath(path: string): ParsedPath;
|
|
15
|
+
//# sourceMappingURL=parsePath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsePath.d.ts","sourceRoot":"","sources":["../src/parsePath.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAWlD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePath = parsePath;
|
|
4
|
+
/**
|
|
5
|
+
* Parse a GitHub-style path with optional line range.
|
|
6
|
+
*
|
|
7
|
+
* Examples:
|
|
8
|
+
* 'src/index.ts' → { filePath: 'src/index.ts' }
|
|
9
|
+
* 'src/index.ts#L10' → { filePath: 'src/index.ts', startLine: 10, endLine: 10 }
|
|
10
|
+
* 'src/index.ts#L10-L20' → { filePath: 'src/index.ts', startLine: 10, endLine: 20 }
|
|
11
|
+
*/
|
|
12
|
+
function parsePath(path) {
|
|
13
|
+
const match = /^(.+?)#L(\d+)(?:-L(\d+))?$/.exec(path);
|
|
14
|
+
if (!match) {
|
|
15
|
+
return { filePath: path };
|
|
16
|
+
}
|
|
17
|
+
const filePath = match[1];
|
|
18
|
+
const startLine = parseInt(match[2], 10);
|
|
19
|
+
const endLine = match[3] ? parseInt(match[3], 10) : startLine;
|
|
20
|
+
return { filePath, startLine, endLine };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=parsePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsePath.js","sourceRoot":"","sources":["../src/parsePath.ts"],"names":[],"mappings":";;AAcA,8BAWC;AAnBD;;;;;;;GAOG;AACH,SAAgB,SAAS,CAAC,IAAY;IACpC,MAAM,KAAK,GAAG,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAC1C,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a value that may be a single item or an array into an array.
|
|
3
|
+
* Used by batchable tools to accept both `string` and `string[]` inputs.
|
|
4
|
+
*/
|
|
5
|
+
export declare function toArray<T>(input: T | T[]): T[];
|
|
6
|
+
/**
|
|
7
|
+
* Wraps tool execution in try-catch and returns error message string.
|
|
8
|
+
* Eliminates duplicate try-catch blocks across tools.
|
|
9
|
+
*/
|
|
10
|
+
export declare function executeWithErrorHandling<T>(operation: () => Promise<T>, errorPrefix: string): Promise<T | string>;
|
|
11
|
+
/**
|
|
12
|
+
* Formats array results with empty handling.
|
|
13
|
+
* Returns a custom message if the array is empty, otherwise joins with newlines.
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatArrayResult(items: string[], emptyMessage: string): string;
|
|
16
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAE9C;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,CAAC,EAC9C,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,CAMrB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,EAAE,MAAM,GACnB,MAAM,CAKR"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toArray = toArray;
|
|
4
|
+
exports.executeWithErrorHandling = executeWithErrorHandling;
|
|
5
|
+
exports.formatArrayResult = formatArrayResult;
|
|
6
|
+
/**
|
|
7
|
+
* Normalize a value that may be a single item or an array into an array.
|
|
8
|
+
* Used by batchable tools to accept both `string` and `string[]` inputs.
|
|
9
|
+
*/
|
|
10
|
+
function toArray(input) {
|
|
11
|
+
return Array.isArray(input) ? input : [input];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Wraps tool execution in try-catch and returns error message string.
|
|
15
|
+
* Eliminates duplicate try-catch blocks across tools.
|
|
16
|
+
*/
|
|
17
|
+
async function executeWithErrorHandling(operation, errorPrefix) {
|
|
18
|
+
try {
|
|
19
|
+
return await operation();
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return `${errorPrefix}: ${error instanceof Error ? error.message : String(error)}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Formats array results with empty handling.
|
|
27
|
+
* Returns a custom message if the array is empty, otherwise joins with newlines.
|
|
28
|
+
*/
|
|
29
|
+
function formatArrayResult(items, emptyMessage) {
|
|
30
|
+
if (items.length === 0) {
|
|
31
|
+
return emptyMessage;
|
|
32
|
+
}
|
|
33
|
+
return items.join("\n");
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAIA,0BAEC;AAMD,4DASC;AAMD,8CAQC;AAnCD;;;GAGG;AACH,SAAgB,OAAO,CAAI,KAAc;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAC5C,SAA2B,EAC3B,WAAmB;IAEnB,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,EAAE,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,WAAW,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IACrF,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAC/B,KAAe,EACf,YAAoB;IAEpB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hardlydifficult/agent-tools",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"lint": "tsc --noEmit",
|
|
12
|
+
"clean": "rm -rf dist"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node": "25.2.3",
|
|
16
|
+
"typescript": "5.9.3"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18.0.0"
|
|
20
|
+
}
|
|
21
|
+
}
|