@hardlydifficult/agent-tools 1.0.5 → 1.0.7
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 +3 -1
- package/dist/parsePath.d.ts +1 -0
- package/dist/parsePath.d.ts.map +1 -1
- package/dist/parsePath.js +8 -4
- package/dist/parsePath.js.map +1 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Parses GitHub-style file paths with optional line ranges into structured objects
|
|
|
40
40
|
|
|
41
41
|
### `parsePath(path: string): ParsedPath`
|
|
42
42
|
|
|
43
|
-
Parses paths like `file.ts`, `file.ts#L10`, or `file.ts#L10-L20`.
|
|
43
|
+
Parses paths like `file.ts`, `file.ts#L10`, or `file.ts#L10-L20`. Line numbers must be positive integers, and reversed ranges are normalized.
|
|
44
44
|
|
|
45
45
|
**Parameters:**
|
|
46
46
|
|
|
@@ -62,6 +62,8 @@ import { parsePath } from "@hardlydifficult/agent-tools";
|
|
|
62
62
|
parsePath("src/index.ts"); // { filePath: "src/index.ts" }
|
|
63
63
|
parsePath("src/index.ts#L5"); // { filePath: "src/index.ts", startLine: 5, endLine: 5 }
|
|
64
64
|
parsePath("src/index.ts#L5-L15"); // { filePath: "src/index.ts", startLine: 5, endLine: 15 }
|
|
65
|
+
parsePath("src/index.ts#L15-L5"); // { filePath: "src/index.ts", startLine: 5, endLine: 15 }
|
|
66
|
+
parsePath("src/index.ts#L0"); // { filePath: "src/index.ts#L0" }
|
|
65
67
|
```
|
|
66
68
|
|
|
67
69
|
## Configuration Constants
|
package/dist/parsePath.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface ParsedPath {
|
|
|
10
10
|
* 'src/index.ts' → { filePath: 'src/index.ts' }
|
|
11
11
|
* 'src/index.ts#L10' → { filePath: 'src/index.ts', startLine: 10, endLine: 10 }
|
|
12
12
|
* 'src/index.ts#L10-L20' → { filePath: 'src/index.ts', startLine: 10, endLine: 20 }
|
|
13
|
+
* 'src/index.ts#L20-L10' → { filePath: 'src/index.ts', startLine: 10, endLine: 20 }
|
|
13
14
|
*/
|
|
14
15
|
export declare function parsePath(path: string): ParsedPath;
|
|
15
16
|
//# sourceMappingURL=parsePath.d.ts.map
|
package/dist/parsePath.d.ts.map
CHANGED
|
@@ -1 +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
|
|
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;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAelD"}
|
package/dist/parsePath.js
CHANGED
|
@@ -8,15 +8,19 @@ exports.parsePath = parsePath;
|
|
|
8
8
|
* 'src/index.ts' → { filePath: 'src/index.ts' }
|
|
9
9
|
* 'src/index.ts#L10' → { filePath: 'src/index.ts', startLine: 10, endLine: 10 }
|
|
10
10
|
* 'src/index.ts#L10-L20' → { filePath: 'src/index.ts', startLine: 10, endLine: 20 }
|
|
11
|
+
* 'src/index.ts#L20-L10' → { filePath: 'src/index.ts', startLine: 10, endLine: 20 }
|
|
11
12
|
*/
|
|
12
13
|
function parsePath(path) {
|
|
13
|
-
const match = /^(.+?)#L(\d
|
|
14
|
+
const match = /^(.+?)#L([1-9]\d*)(?:-L([1-9]\d*))?$/.exec(path);
|
|
14
15
|
if (!match) {
|
|
15
16
|
return { filePath: path };
|
|
16
17
|
}
|
|
17
18
|
const filePath = match[1];
|
|
18
|
-
const startLine = parseInt(match[2], 10);
|
|
19
|
-
const endLine = match[3] ? parseInt(match[3], 10) : startLine;
|
|
20
|
-
|
|
19
|
+
const startLine = Number.parseInt(match[2], 10);
|
|
20
|
+
const endLine = match[3] ? Number.parseInt(match[3], 10) : startLine;
|
|
21
|
+
if (startLine <= endLine) {
|
|
22
|
+
return { filePath, startLine, endLine };
|
|
23
|
+
}
|
|
24
|
+
return { filePath, startLine: endLine, endLine: startLine };
|
|
21
25
|
}
|
|
22
26
|
//# sourceMappingURL=parsePath.js.map
|
package/dist/parsePath.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsePath.js","sourceRoot":"","sources":["../src/parsePath.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"parsePath.js","sourceRoot":"","sources":["../src/parsePath.ts"],"names":[],"mappings":";;AAeA,8BAeC;AAxBD;;;;;;;;GAQG;AACH,SAAgB,SAAS,CAAC,IAAY;IACpC,MAAM,KAAK,GAAG,sCAAsC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChE,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,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAErE,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;QACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;IAC1C,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAC9D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardlydifficult/agent-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -9,11 +9,15 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"lint": "tsc --noEmit",
|
|
12
|
-
"clean": "
|
|
12
|
+
"clean": "node --eval \"fs.rmSync('dist', { recursive: true, force: true })\"",
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"test:watch": "vitest",
|
|
15
|
+
"test:coverage": "vitest run --coverage"
|
|
13
16
|
},
|
|
14
17
|
"devDependencies": {
|
|
15
18
|
"@types/node": "25.3.0",
|
|
16
|
-
"typescript": "5.9.3"
|
|
19
|
+
"typescript": "5.9.3",
|
|
20
|
+
"vitest": "4.0.18"
|
|
17
21
|
},
|
|
18
22
|
"engines": {
|
|
19
23
|
"node": ">=20.19.0"
|