declapract-typescript-ehmpathy 0.48.5 → 0.49.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.
@@ -90,6 +90,11 @@ jobs:
90
90
  key: ${{ needs.install.outputs.node-modules-cache-key }}
91
91
  fail-on-cache-miss: true
92
92
 
93
+ # .why = keyrack.yml can extend other manifests via symlinks (e.g., .agent/repo=ehmpathy/role=mechanic/keyrack.yml)
94
+ # prepare:rhachet creates these symlinks so keyrack.source() can hydrate extended keys
95
+ - name: prepare:rhachet
96
+ run: npm run prepare:rhachet --if-present
97
+
93
98
  - name: vpc:tunnel:open
94
99
  if: inputs.needs-vpn-for-acceptance
95
100
  run: ACCESS=${{ inputs.stage }} .agent/repo=.this/skills/use.vpc.tunnel.ts
@@ -0,0 +1,85 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
3
+ import { UnexpectedCodePathError } from 'helpful-errors';
4
+
5
+ /**
6
+ * known error classes exported by helpful-errors
7
+ *
8
+ * only these classes should be rewritten — custom error classes
9
+ * (e.g., UserInputError, HumanGuidanceError) must be left alone
10
+ */
11
+ const KNOWN_CLASSES = [
12
+ 'UnexpectedCodePathError',
13
+ 'BadRequestError',
14
+ 'HelpfulError',
15
+ 'MalfunctionError',
16
+ 'ConstraintError',
17
+ ];
18
+
19
+ /**
20
+ * pattern source for local imports that end with a known error class name
21
+ *
22
+ * anchored to line start via ^ with multiline flag (m)
23
+ * supports both `import { X }` and `import type { X }`
24
+ *
25
+ * examples that match:
26
+ * import { UnexpectedCodePathError } from '../../utils/errors/UnexpectedCodePathError'
27
+ * import type { BadRequestError } from '@src/domain.operations/BadRequestError'
28
+ *
29
+ * examples that do NOT match:
30
+ * from 'helpful-errors' (already correct)
31
+ * from '../../utils/errors/UserInputError' (custom class)
32
+ * const msg = "import { X } from 'local/UnexpectedCodePathError'" (mid-line)
33
+ * // import { X } from '../../errors/UnexpectedCodePathError' (comment)
34
+ */
35
+ const IMPORT_PREFIX = `(^\\s*import\\s+(?:type\\s+)?\\{[^}]+\\}\\s+)`;
36
+ const FROM_LOCAL_ERROR = `from ['"][^'"]*\\/(${KNOWN_CLASSES.join('|')})['"]`;
37
+ const LOCAL_ERROR_IMPORT_PATTERN_SOURCE = `${IMPORT_PREFIX}${FROM_LOCAL_ERROR}`;
38
+
39
+ /**
40
+ * regex for test: match once, multiline mode
41
+ */
42
+ const LOCAL_ERROR_IMPORT_PATTERN = new RegExp(
43
+ LOCAL_ERROR_IMPORT_PATTERN_SOURCE,
44
+ 'm',
45
+ );
46
+
47
+ /**
48
+ * regex for replace: match all occurrences, multiline mode
49
+ */
50
+ const LOCAL_ERROR_IMPORT_PATTERN_GLOBAL = new RegExp(
51
+ LOCAL_ERROR_IMPORT_PATTERN_SOURCE,
52
+ 'gm',
53
+ );
54
+
55
+ /**
56
+ * .what = detect local error imports that should use helpful-errors
57
+ * .why = flag files for fix by declapract
58
+ */
59
+ export const check: FileCheckFunction = (contents) => {
60
+ // matches bad practice if local error import found
61
+ if (contents && LOCAL_ERROR_IMPORT_PATTERN.test(contents)) return;
62
+
63
+ // no local error imports found — file does not need migration
64
+ UnexpectedCodePathError.throw(
65
+ 'no local error imports found; file uses helpful-errors or custom errors',
66
+ { hint: 'this file does not need migration to helpful-errors' },
67
+ );
68
+ };
69
+
70
+ /**
71
+ * .what = replace local error imports with helpful-errors
72
+ * .why = consolidate error class sources for easier maintenance
73
+ */
74
+ export const fix: FileFixFunction = (contents) => {
75
+ // skip if empty
76
+ if (!contents) return {};
77
+
78
+ // replace all local error imports, preserve import prefix via $1
79
+ return {
80
+ contents: contents.replace(
81
+ LOCAL_ERROR_IMPORT_PATTERN_GLOBAL,
82
+ "$1from 'helpful-errors'",
83
+ ),
84
+ };
85
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "declapract-typescript-ehmpathy",
3
3
  "author": "ehmpathy",
4
4
  "description": "declapract best practices declarations for typescript",
5
- "version": "0.48.5",
5
+ "version": "0.49.1",
6
6
  "license": "MIT",
7
7
  "main": "src/index.js",
8
8
  "repository": "ehmpathy/declapract-typescript-ehmpathy",
@@ -59,7 +59,6 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@biomejs/biome": "2.3.8",
62
- "declapract": "0.13.26",
63
62
  "@commitlint/cli": "19.5.0",
64
63
  "@commitlint/config-conventional": "19.5.0",
65
64
  "@swc/core": "1.15.3",
@@ -70,18 +69,19 @@
70
69
  "@types/jest": "30.0.0",
71
70
  "@types/node": "22.15.21",
72
71
  "cz-conventional-changelog": "3.3.0",
72
+ "declapract": "0.13.26",
73
73
  "declastruct": "1.9.1",
74
74
  "declastruct-github": "1.4.0",
75
75
  "depcheck": "1.4.3",
76
76
  "esbuild-register": "3.6.0",
77
77
  "husky": "8.0.3",
78
78
  "jest": "30.2.0",
79
- "rhachet": "1.41.17",
79
+ "rhachet": "1.41.21",
80
80
  "rhachet-brains-anthropic": "0.4.1",
81
81
  "rhachet-brains-xai": "0.3.3",
82
- "rhachet-roles-bhrain": "0.29.0",
83
- "rhachet-roles-bhuild": "0.21.15",
84
- "rhachet-roles-ehmpathy": "1.35.12",
82
+ "rhachet-roles-bhrain": "0.29.2",
83
+ "rhachet-roles-bhuild": "0.21.16",
84
+ "rhachet-roles-ehmpathy": "1.35.15",
85
85
  "tsc-alias": "1.8.10",
86
86
  "tsx": "4.20.6",
87
87
  "type-fns": "1.21.2",