@kurvball/ashlar 1.7.0 → 1.7.1
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/CHANGELOG.md +8 -0
- package/dist/cli.js +2 -2
- package/dist/errors.d.ts +6 -1
- package/dist/errors.js +40 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ changesets merged since the release before it, under its version and release dat
|
|
|
6
6
|
and patch changes; see [RELEASING.md](RELEASING.md). Versions up to 1.0.1 follow
|
|
7
7
|
[Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/).
|
|
8
8
|
|
|
9
|
+
## 1.7.1
|
|
10
|
+
|
|
11
|
+
_Released 2026-12-04._
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- What Ashlar says when it refuses carries no home folder, on stderr and in the error object's `says` and `file` alike: a path in the folder it runs in shows from there (the folder itself as "this folder"), a path in the home folder shows from `~`, and any other path stays whole.
|
|
16
|
+
|
|
9
17
|
## 1.7.0
|
|
10
18
|
|
|
11
19
|
_Released 2026-12-04._
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import { relative } from 'node:path';
|
|
|
4
4
|
import { affectedAnswer, briefAnswer, checkAnswer, mapAnswer, onboardAnswer } from './answers.js';
|
|
5
5
|
import { AshlarError, loadConfig } from './config.js';
|
|
6
6
|
import { init, initText } from './init.js';
|
|
7
|
-
import { errorJson } from './errors.js';
|
|
7
|
+
import { errorJson, scrubbed } from './errors.js';
|
|
8
8
|
import { serve } from './mcp.js';
|
|
9
9
|
import { featuresOf, unreadText } from './features.js';
|
|
10
10
|
import { ledgerOf, ledgerText } from './ledger.js';
|
|
@@ -229,7 +229,7 @@ catch (error) {
|
|
|
229
229
|
if (json)
|
|
230
230
|
process.stdout.write(`${JSON.stringify(errorJson(error), null, 2)}\n`);
|
|
231
231
|
else
|
|
232
|
-
process.stderr.write(`${error.message}\n`);
|
|
232
|
+
process.stderr.write(`${scrubbed(error.message)}\n`);
|
|
233
233
|
process.exitCode = 2;
|
|
234
234
|
}
|
|
235
235
|
}
|
package/dist/errors.d.ts
CHANGED
|
@@ -9,4 +9,9 @@ export interface ErrorJson {
|
|
|
9
9
|
line?: number;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export interface Places {
|
|
13
|
+
cwd: string;
|
|
14
|
+
home: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function scrubbed(text: string, places?: Places): string;
|
|
17
|
+
export declare function errorJson(error: unknown, places?: Places): ErrorJson;
|
package/dist/errors.js
CHANGED
|
@@ -1,17 +1,53 @@
|
|
|
1
|
+
import { realpathSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
1
3
|
import { isAbsolute, relative } from 'node:path';
|
|
2
4
|
import { AshlarError } from './config.js';
|
|
3
|
-
|
|
5
|
+
const here = () => ({ cwd: process.cwd(), home: homedir() });
|
|
6
|
+
function spellings(folder) {
|
|
7
|
+
let real = folder;
|
|
8
|
+
try {
|
|
9
|
+
real = realpathSync(folder);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
real = folder;
|
|
13
|
+
}
|
|
14
|
+
return [...new Set([folder, real])]
|
|
15
|
+
.filter((path) => path !== '' && path !== '/')
|
|
16
|
+
.sort((a, b) => b.length - a.length);
|
|
17
|
+
}
|
|
18
|
+
const escaped = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
19
|
+
function replaced(text, folder, inside, whole) {
|
|
20
|
+
const name = escaped(folder);
|
|
21
|
+
return text
|
|
22
|
+
.replace(new RegExp(`${name}/`, 'g'), inside)
|
|
23
|
+
.replace(new RegExp(`${name}(?![\\w./-])`, 'g'), whole);
|
|
24
|
+
}
|
|
25
|
+
export function scrubbed(text, places = here()) {
|
|
26
|
+
let out = text;
|
|
27
|
+
for (const folder of spellings(places.cwd))
|
|
28
|
+
out = replaced(out, folder, '', 'this folder');
|
|
29
|
+
for (const folder of spellings(places.home))
|
|
30
|
+
out = replaced(out, folder, '~/', '~');
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
function shownFile(file, places) {
|
|
34
|
+
if (!isAbsolute(file))
|
|
35
|
+
return file;
|
|
36
|
+
const inside = relative(places.cwd, file);
|
|
37
|
+
return inside && !inside.startsWith('..') && !isAbsolute(inside) ? inside : scrubbed(file, places);
|
|
38
|
+
}
|
|
39
|
+
export function errorJson(error, places = here()) {
|
|
4
40
|
if (!(error instanceof AshlarError)) {
|
|
5
41
|
const said = error instanceof Error ? error.message.split('\n')[0] || error.name : String(error);
|
|
6
|
-
return { v: 1, ok: false, error: { code: 'crashed', says: `Ashlar stopped: ${said}
|
|
42
|
+
return { v: 1, ok: false, error: { code: 'crashed', says: scrubbed(`Ashlar stopped: ${said}`, places) } };
|
|
7
43
|
}
|
|
8
|
-
const file = error.file === undefined ? undefined :
|
|
44
|
+
const file = error.file === undefined ? undefined : shownFile(error.file, places);
|
|
9
45
|
return {
|
|
10
46
|
v: 1,
|
|
11
47
|
ok: false,
|
|
12
48
|
error: {
|
|
13
49
|
code: error.code,
|
|
14
|
-
says: error.message,
|
|
50
|
+
says: scrubbed(error.message, places),
|
|
15
51
|
...(file !== undefined && { file }),
|
|
16
52
|
...(error.line !== undefined && { line: error.line }),
|
|
17
53
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kurvball/ashlar",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "The rules for building software with agents: lint rules, an import graph with a shrink-only ratchet, a feature map and onboarding for TypeScript projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|