arkgate 2.12.0 → 3.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/README.md +90 -51
  3. package/bin/ark-check.mjs +156 -39
  4. package/bin/ark-mcp.mjs +119 -6
  5. package/bin/ark-shared.mjs +216 -129
  6. package/bin/ark.mjs +134 -34
  7. package/bin/lib/adapter-contract.mjs +93 -0
  8. package/bin/lib/agent-gates.mjs +13 -0
  9. package/bin/lib/analysis-engine.mjs +1171 -0
  10. package/bin/lib/architecture-scan.mjs +84 -127
  11. package/bin/lib/ci-and-commands.mjs +40 -3
  12. package/bin/lib/codex-home.mjs +7 -0
  13. package/bin/lib/config-contract.mjs +331 -0
  14. package/bin/lib/config-warnings.mjs +7 -205
  15. package/bin/lib/doctor-plan.mjs +43 -16
  16. package/bin/lib/enforcement-profiles.mjs +97 -0
  17. package/bin/lib/field-install.mjs +67 -10
  18. package/bin/lib/gate-files.mjs +42 -3
  19. package/bin/lib/graph-cycles.mjs +4 -54
  20. package/bin/lib/hook-templates.mjs +33 -1
  21. package/bin/lib/host-support-matrix.mjs +83 -0
  22. package/bin/lib/install-migrate.mjs +99 -30
  23. package/bin/lib/mcp-adoption.mjs +35 -3
  24. package/bin/lib/open-html.mjs +75 -0
  25. package/bin/lib/presets.mjs +45 -4
  26. package/bin/lib/safety-diagnostics.mjs +36 -15
  27. package/bin/lib/scan-files.mjs +12 -1
  28. package/bin/lib/skill-install.mjs +72 -1
  29. package/bin/lib/source-policy.mjs +36 -0
  30. package/bin/lib/start-preview.mjs +271 -0
  31. package/bin/lib/ts-resolve.mjs +13 -3
  32. package/bin/lib/weakest-link.mjs +417 -0
  33. package/bin/lib/write-path-capabilities.mjs +186 -0
  34. package/bin/lib/write-path-detect.mjs +62 -99
  35. package/compat/nestjs.cjs +2 -0
  36. package/compat/nestjs.d.ts +2 -0
  37. package/compat/nestjs.js +1 -0
  38. package/compat/runtime.cjs +2 -0
  39. package/compat/runtime.d.ts +2 -0
  40. package/compat/runtime.js +1 -0
  41. package/dist/configContract-BxSIwVRo.d.cts +259 -0
  42. package/dist/configContract-BxSIwVRo.d.ts +259 -0
  43. package/dist/eslint/index.cjs +500 -61
  44. package/dist/eslint/index.d.cts +36 -20
  45. package/dist/eslint/index.d.ts +36 -20
  46. package/dist/eslint/index.js +500 -61
  47. package/dist/index.cjs +1349 -2741
  48. package/dist/index.d.cts +449 -483
  49. package/dist/index.d.ts +449 -483
  50. package/dist/index.js +1325 -2687
  51. package/docs/agent-guide.md +58 -34
  52. package/docs/ai-gates.md +79 -21
  53. package/docs/configuration.md +97 -0
  54. package/docs/enthusiast/README.md +3 -3
  55. package/docs/enthusiast/how-to-agent-gates.md +7 -3
  56. package/docs/migrate-from-ark-runtime-kernel.md +5 -3
  57. package/docs/package-surface.md +19 -19
  58. package/docs/production-hardening.md +31 -5
  59. package/docs/threat-model.md +65 -0
  60. package/docs/typescript-support.md +30 -3
  61. package/package.json +46 -11
  62. package/schemas/ark.analysis-result.schema.json +91 -0
  63. package/schemas/ark.config.schema.json +750 -0
  64. package/server.json +2 -2
  65. package/templates/hooks/pre-commit-ark +37 -0
  66. package/templates/skills/ark-architect.md +3 -2
  67. package/templates/skills/ark-coverage.md +2 -2
  68. package/templates/skills/ark-runtime.md +8 -5
  69. package/templates/skills/ark-upgrade.md +36 -16
  70. package/tests/fixtures/ts-consumer/ark.config.json +2 -0
  71. package/dist/eslint/index.cjs.map +0 -1
  72. package/dist/eslint/index.js.map +0 -1
  73. package/dist/index.cjs.map +0 -1
  74. package/dist/index.js.map +0 -1
  75. package/dist/nestjs/index.cjs +0 -2498
  76. package/dist/nestjs/index.cjs.map +0 -1
  77. package/dist/nestjs/index.d.cts +0 -22
  78. package/dist/nestjs/index.d.ts +0 -22
  79. package/dist/nestjs/index.js +0 -2474
  80. package/dist/nestjs/index.js.map +0 -1
  81. package/dist/runtime/index.cjs +0 -3352
  82. package/dist/runtime/index.cjs.map +0 -1
  83. package/dist/runtime/index.d.cts +0 -2
  84. package/dist/runtime/index.d.ts +0 -2
  85. package/dist/runtime/index.js +0 -3270
  86. package/dist/runtime/index.js.map +0 -1
  87. package/dist/types-BZ17b9i5.d.cts +0 -1068
  88. package/dist/types-BZ17b9i5.d.ts +0 -1068
@@ -1,3 +1,5 @@
1
+ import { A as ArkConfig } from '../configContract-BxSIwVRo.cjs';
2
+
1
3
  /**
2
4
  * Pure layer-glob matching for ark.config.json.
3
5
  *
@@ -6,7 +8,7 @@
6
8
  * (`npm run generate:layer-match` / `npm run check:layer-match`).
7
9
  * Behavioral parity tests remain a safety net.
8
10
  */
9
- type LayerConfig$1 = {
11
+ type LayerConfig = {
10
12
  name: string;
11
13
  patterns?: string[];
12
14
  exclude?: string[];
@@ -21,7 +23,7 @@ type LayerConfig$1 = {
21
23
  * (same **or** cross layer). Same-slice → allow. Needs fromPath/toPath; missing
22
24
  * paths/slices → fail-open.
23
25
  */
24
- type EdgeRule$1 = {
26
+ type EdgeRule = {
25
27
  from: string;
26
28
  to: string;
27
29
  allowed?: boolean;
@@ -47,12 +49,12 @@ type EdgeCheckOptions = {
47
49
  /** Repo-relative path of the imported module. */
48
50
  toPath?: string;
49
51
  /** Layer configs — used to infer sliceFolders when the rule omits them. */
50
- layers?: LayerConfig$1[];
52
+ layers?: LayerConfig[];
51
53
  };
52
54
  declare function globToRegExp(pattern: string): RegExp;
53
55
  declare function patternSpecificity(pattern: string): number;
54
- declare function layerForRelativePath(relPath: string, layers: LayerConfig$1[] | undefined): string | undefined;
55
- declare function isEdgeDenied(rules: EdgeRule$1[] | undefined, from: string, to: string, options?: EdgeCheckOptions): boolean;
56
+ declare function layerForRelativePath(relPath: string, layers: LayerConfig[] | undefined): string | undefined;
57
+ declare function isEdgeDenied(rules: EdgeRule[] | undefined, from: string, to: string, options?: EdgeCheckOptions): boolean;
56
58
 
57
59
  type RuleContext = {
58
60
  report(descriptor: Record<string, unknown>): void;
@@ -62,8 +64,28 @@ type RuleContext = {
62
64
  physicalFilename?: string;
63
65
  /** ESLint ≤8 API — still present on some hosts; removed in ESLint 10. */
64
66
  getFilename?: () => string;
67
+ /** ESLint 9+ source/scope API. */
68
+ sourceCode?: SourceCode;
69
+ /** ESLint ≤8 source/scope API. */
70
+ getSourceCode?: () => SourceCode;
65
71
  options?: unknown[];
66
72
  };
73
+ type ScopeVariable = {
74
+ defs?: unknown[];
75
+ };
76
+ type ScopeReference = {
77
+ identifier?: AstNode;
78
+ resolved?: ScopeVariable | null;
79
+ isValueReference?: boolean;
80
+ };
81
+ type Scope = {
82
+ set?: Map<string, ScopeVariable>;
83
+ references?: ScopeReference[];
84
+ upper?: Scope | null;
85
+ };
86
+ type SourceCode = {
87
+ getScope?: (node: AstNode) => Scope;
88
+ };
67
89
  type RuleListener = Record<string, (node: AstNode) => void>;
68
90
  type AstNode = {
69
91
  type?: string;
@@ -78,6 +100,15 @@ type AstNode = {
78
100
  properties?: AstNode[];
79
101
  importKind?: string;
80
102
  specifiers?: AstNode[];
103
+ parent?: AstNode;
104
+ init?: AstNode;
105
+ computed?: boolean;
106
+ loc?: {
107
+ start?: {
108
+ line?: number;
109
+ column?: number;
110
+ };
111
+ };
81
112
  };
82
113
  type ArkRule = {
83
114
  meta: {
@@ -94,21 +125,6 @@ type ArkEslintPlugin = {
94
125
  rules: Record<string, ArkRule>;
95
126
  configs?: Record<string, unknown>;
96
127
  };
97
- type LayerConfig = {
98
- name: string;
99
- patterns?: string[];
100
- exclude?: string[];
101
- forbiddenGlobals?: string[];
102
- };
103
- type EdgeRule = {
104
- from: string;
105
- to: string;
106
- allowed?: boolean;
107
- };
108
- type ArkConfig = {
109
- layers?: LayerConfig[];
110
- rules?: EdgeRule[];
111
- };
112
128
  declare function findConfigPath(startFile: string): string | null;
113
129
  declare function loadArkConfig(configPath: string): ArkConfig | null;
114
130
  /** Resolve relative import specifier to an absolute path candidate (TS-oriented). */
@@ -1,3 +1,5 @@
1
+ import { A as ArkConfig } from '../configContract-BxSIwVRo.js';
2
+
1
3
  /**
2
4
  * Pure layer-glob matching for ark.config.json.
3
5
  *
@@ -6,7 +8,7 @@
6
8
  * (`npm run generate:layer-match` / `npm run check:layer-match`).
7
9
  * Behavioral parity tests remain a safety net.
8
10
  */
9
- type LayerConfig$1 = {
11
+ type LayerConfig = {
10
12
  name: string;
11
13
  patterns?: string[];
12
14
  exclude?: string[];
@@ -21,7 +23,7 @@ type LayerConfig$1 = {
21
23
  * (same **or** cross layer). Same-slice → allow. Needs fromPath/toPath; missing
22
24
  * paths/slices → fail-open.
23
25
  */
24
- type EdgeRule$1 = {
26
+ type EdgeRule = {
25
27
  from: string;
26
28
  to: string;
27
29
  allowed?: boolean;
@@ -47,12 +49,12 @@ type EdgeCheckOptions = {
47
49
  /** Repo-relative path of the imported module. */
48
50
  toPath?: string;
49
51
  /** Layer configs — used to infer sliceFolders when the rule omits them. */
50
- layers?: LayerConfig$1[];
52
+ layers?: LayerConfig[];
51
53
  };
52
54
  declare function globToRegExp(pattern: string): RegExp;
53
55
  declare function patternSpecificity(pattern: string): number;
54
- declare function layerForRelativePath(relPath: string, layers: LayerConfig$1[] | undefined): string | undefined;
55
- declare function isEdgeDenied(rules: EdgeRule$1[] | undefined, from: string, to: string, options?: EdgeCheckOptions): boolean;
56
+ declare function layerForRelativePath(relPath: string, layers: LayerConfig[] | undefined): string | undefined;
57
+ declare function isEdgeDenied(rules: EdgeRule[] | undefined, from: string, to: string, options?: EdgeCheckOptions): boolean;
56
58
 
57
59
  type RuleContext = {
58
60
  report(descriptor: Record<string, unknown>): void;
@@ -62,8 +64,28 @@ type RuleContext = {
62
64
  physicalFilename?: string;
63
65
  /** ESLint ≤8 API — still present on some hosts; removed in ESLint 10. */
64
66
  getFilename?: () => string;
67
+ /** ESLint 9+ source/scope API. */
68
+ sourceCode?: SourceCode;
69
+ /** ESLint ≤8 source/scope API. */
70
+ getSourceCode?: () => SourceCode;
65
71
  options?: unknown[];
66
72
  };
73
+ type ScopeVariable = {
74
+ defs?: unknown[];
75
+ };
76
+ type ScopeReference = {
77
+ identifier?: AstNode;
78
+ resolved?: ScopeVariable | null;
79
+ isValueReference?: boolean;
80
+ };
81
+ type Scope = {
82
+ set?: Map<string, ScopeVariable>;
83
+ references?: ScopeReference[];
84
+ upper?: Scope | null;
85
+ };
86
+ type SourceCode = {
87
+ getScope?: (node: AstNode) => Scope;
88
+ };
67
89
  type RuleListener = Record<string, (node: AstNode) => void>;
68
90
  type AstNode = {
69
91
  type?: string;
@@ -78,6 +100,15 @@ type AstNode = {
78
100
  properties?: AstNode[];
79
101
  importKind?: string;
80
102
  specifiers?: AstNode[];
103
+ parent?: AstNode;
104
+ init?: AstNode;
105
+ computed?: boolean;
106
+ loc?: {
107
+ start?: {
108
+ line?: number;
109
+ column?: number;
110
+ };
111
+ };
81
112
  };
82
113
  type ArkRule = {
83
114
  meta: {
@@ -94,21 +125,6 @@ type ArkEslintPlugin = {
94
125
  rules: Record<string, ArkRule>;
95
126
  configs?: Record<string, unknown>;
96
127
  };
97
- type LayerConfig = {
98
- name: string;
99
- patterns?: string[];
100
- exclude?: string[];
101
- forbiddenGlobals?: string[];
102
- };
103
- type EdgeRule = {
104
- from: string;
105
- to: string;
106
- allowed?: boolean;
107
- };
108
- type ArkConfig = {
109
- layers?: LayerConfig[];
110
- rules?: EdgeRule[];
111
- };
112
128
  declare function findConfigPath(startFile: string): string | null;
113
129
  declare function loadArkConfig(configPath: string): ArkConfig | null;
114
130
  /** Resolve relative import specifier to an absolute path candidate (TS-oriented). */