@lucasacoutinho/archer 0.2.0 → 0.3.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 (214) hide show
  1. package/README.md +145 -387
  2. package/dist/analyzer/Analyzer.d.ts +17 -0
  3. package/dist/analyzer/Analyzer.d.ts.map +1 -0
  4. package/dist/analyzer/Analyzer.js +15 -0
  5. package/dist/analyzer/Analyzer.js.map +1 -0
  6. package/dist/analyzer/bindings.d.ts +26 -0
  7. package/dist/analyzer/bindings.d.ts.map +1 -0
  8. package/dist/analyzer/bindings.js +61 -0
  9. package/dist/analyzer/bindings.js.map +1 -0
  10. package/dist/analyzer/errors.d.ts +34 -0
  11. package/dist/analyzer/errors.d.ts.map +1 -0
  12. package/dist/analyzer/errors.js +20 -0
  13. package/dist/analyzer/errors.js.map +1 -0
  14. package/dist/analyzer/graph-file.d.ts +13 -0
  15. package/dist/analyzer/graph-file.d.ts.map +1 -0
  16. package/dist/analyzer/graph-file.js +22 -0
  17. package/dist/analyzer/graph-file.js.map +1 -0
  18. package/dist/analyzer/paths.d.ts +12 -0
  19. package/dist/analyzer/paths.d.ts.map +1 -0
  20. package/dist/analyzer/paths.js +26 -0
  21. package/dist/analyzer/paths.js.map +1 -0
  22. package/dist/analyzer/server-exit.d.ts +19 -0
  23. package/dist/analyzer/server-exit.d.ts.map +1 -0
  24. package/dist/analyzer/server-exit.js +70 -0
  25. package/dist/analyzer/server-exit.js.map +1 -0
  26. package/dist/analyzer/source.d.ts +29 -0
  27. package/dist/analyzer/source.d.ts.map +1 -0
  28. package/dist/analyzer/source.js +58 -0
  29. package/dist/analyzer/source.js.map +1 -0
  30. package/dist/analyzer/syntax.d.ts +29 -0
  31. package/dist/analyzer/syntax.d.ts.map +1 -0
  32. package/dist/analyzer/syntax.js +226 -0
  33. package/dist/analyzer/syntax.js.map +1 -0
  34. package/dist/analyzer/targets.d.ts +26 -0
  35. package/dist/analyzer/targets.d.ts.map +1 -0
  36. package/dist/analyzer/targets.js +84 -0
  37. package/dist/analyzer/targets.js.map +1 -0
  38. package/dist/analyzer/typescript.d.ts +5 -0
  39. package/dist/analyzer/typescript.d.ts.map +1 -0
  40. package/dist/analyzer/typescript.js +221 -0
  41. package/dist/analyzer/typescript.js.map +1 -0
  42. package/dist/analyzer/workspace.d.ts +24 -0
  43. package/dist/analyzer/workspace.d.ts.map +1 -0
  44. package/dist/analyzer/workspace.js +9 -0
  45. package/dist/analyzer/workspace.js.map +1 -0
  46. package/dist/cli/explain.d.ts +3 -0
  47. package/dist/cli/explain.d.ts.map +1 -0
  48. package/dist/cli/explain.js +21 -0
  49. package/dist/cli/explain.js.map +1 -0
  50. package/dist/cli/main.d.ts +3 -0
  51. package/dist/cli/main.d.ts.map +1 -0
  52. package/dist/cli/main.js +159 -0
  53. package/dist/cli/main.js.map +1 -0
  54. package/dist/config/input.d.ts +59 -0
  55. package/dist/config/input.d.ts.map +1 -0
  56. package/dist/config/input.js +115 -0
  57. package/dist/config/input.js.map +1 -0
  58. package/dist/config/rules.d.ts +94 -0
  59. package/dist/config/rules.d.ts.map +1 -0
  60. package/dist/config/rules.js +130 -0
  61. package/dist/config/rules.js.map +1 -0
  62. package/dist/core/baseline.d.ts +16 -0
  63. package/dist/core/baseline.d.ts.map +1 -0
  64. package/dist/core/baseline.js +25 -0
  65. package/dist/core/baseline.js.map +1 -0
  66. package/dist/core/check.d.ts +16 -0
  67. package/dist/core/check.d.ts.map +1 -0
  68. package/dist/core/check.js +271 -0
  69. package/dist/core/check.js.map +1 -0
  70. package/dist/core/config.d.ts +72 -0
  71. package/dist/core/config.d.ts.map +1 -0
  72. package/dist/core/config.js +78 -0
  73. package/dist/core/config.js.map +1 -0
  74. package/dist/core/fingerprint.d.ts +54 -0
  75. package/dist/core/fingerprint.d.ts.map +1 -0
  76. package/dist/core/fingerprint.js +182 -0
  77. package/dist/core/fingerprint.js.map +1 -0
  78. package/dist/core/keys.d.ts +10 -0
  79. package/dist/core/keys.d.ts.map +1 -0
  80. package/dist/core/keys.js +16 -0
  81. package/dist/core/keys.js.map +1 -0
  82. package/dist/core/lower.d.ts +13 -0
  83. package/dist/core/lower.d.ts.map +1 -0
  84. package/dist/core/lower.js +82 -0
  85. package/dist/core/lower.js.map +1 -0
  86. package/dist/core/model.d.ts +155 -0
  87. package/dist/core/model.d.ts.map +1 -0
  88. package/dist/core/model.js +116 -0
  89. package/dist/core/model.js.map +1 -0
  90. package/dist/core/pattern.d.ts +13 -0
  91. package/dist/core/pattern.d.ts.map +1 -0
  92. package/dist/core/pattern.js +29 -0
  93. package/dist/core/pattern.js.map +1 -0
  94. package/dist/core/reach.d.ts +10 -0
  95. package/dist/core/reach.d.ts.map +1 -0
  96. package/dist/core/reach.js +81 -0
  97. package/dist/core/reach.js.map +1 -0
  98. package/dist/core/rule.d.ts +200 -0
  99. package/dist/core/rule.d.ts.map +1 -0
  100. package/dist/core/rule.js +162 -0
  101. package/dist/core/rule.js.map +1 -0
  102. package/dist/core/selector.d.ts +7 -0
  103. package/dist/core/selector.d.ts.map +1 -0
  104. package/dist/core/selector.js +27 -0
  105. package/dist/core/selector.js.map +1 -0
  106. package/dist/core/structural.d.ts +10 -0
  107. package/dist/core/structural.d.ts.map +1 -0
  108. package/dist/core/structural.js +24 -0
  109. package/dist/core/structural.js.map +1 -0
  110. package/dist/core/text.d.ts +26 -0
  111. package/dist/core/text.d.ts.map +1 -0
  112. package/dist/core/text.js +144 -0
  113. package/dist/core/text.js.map +1 -0
  114. package/dist/effect.d.ts +19 -0
  115. package/dist/effect.d.ts.map +1 -0
  116. package/dist/effect.js +21 -0
  117. package/dist/effect.js.map +1 -0
  118. package/dist/index.d.ts +24 -44
  119. package/dist/index.d.ts.map +1 -0
  120. package/dist/index.js +59 -52
  121. package/dist/index.js.map +1 -0
  122. package/dist/report/agent.d.ts +3 -0
  123. package/dist/report/agent.d.ts.map +1 -0
  124. package/dist/report/agent.js +35 -0
  125. package/dist/report/agent.js.map +1 -0
  126. package/dist/report/dot.d.ts +4 -0
  127. package/dist/report/dot.d.ts.map +1 -0
  128. package/dist/report/dot.js +15 -0
  129. package/dist/report/dot.js.map +1 -0
  130. package/dist/report/github.d.ts +3 -0
  131. package/dist/report/github.d.ts.map +1 -0
  132. package/dist/report/github.js +18 -0
  133. package/dist/report/github.js.map +1 -0
  134. package/dist/report/json.d.ts +3 -0
  135. package/dist/report/json.d.ts.map +1 -0
  136. package/dist/report/json.js +4 -0
  137. package/dist/report/json.js.map +1 -0
  138. package/dist/report/message.d.ts +20 -0
  139. package/dist/report/message.d.ts.map +1 -0
  140. package/dist/report/message.js +73 -0
  141. package/dist/report/message.js.map +1 -0
  142. package/dist/report/pretty.d.ts +8 -0
  143. package/dist/report/pretty.d.ts.map +1 -0
  144. package/dist/report/pretty.js +89 -0
  145. package/dist/report/pretty.js.map +1 -0
  146. package/dist/report/render.d.ts +9 -0
  147. package/dist/report/render.d.ts.map +1 -0
  148. package/dist/report/render.js +10 -0
  149. package/dist/report/render.js.map +1 -0
  150. package/dist/report/report.d.ts +44 -0
  151. package/dist/report/report.d.ts.map +1 -0
  152. package/dist/report/report.js +49 -0
  153. package/dist/report/report.js.map +1 -0
  154. package/dist/report/sarif.d.ts +3 -0
  155. package/dist/report/sarif.d.ts.map +1 -0
  156. package/dist/report/sarif.js +68 -0
  157. package/dist/report/sarif.js.map +1 -0
  158. package/dist/run.d.ts +49 -0
  159. package/dist/run.d.ts.map +1 -0
  160. package/dist/run.js +87 -0
  161. package/dist/run.js.map +1 -0
  162. package/dist/shell/baseline-file.d.ts +20 -0
  163. package/dist/shell/baseline-file.d.ts.map +1 -0
  164. package/dist/shell/baseline-file.js +46 -0
  165. package/dist/shell/baseline-file.js.map +1 -0
  166. package/dist/shell/load-config.d.ts +19 -0
  167. package/dist/shell/load-config.d.ts.map +1 -0
  168. package/dist/shell/load-config.js +39 -0
  169. package/dist/shell/load-config.js.map +1 -0
  170. package/package.json +29 -177
  171. package/skills/archer/SKILL.md +127 -45
  172. package/skills/archer/agents/openai.yaml +2 -2
  173. package/skills/archer/references/rules.md +267 -54
  174. package/dist/bun/plugin.cjs +0 -85
  175. package/dist/bun/plugin.d.cts +0 -7
  176. package/dist/bun/plugin.d.ts +0 -7
  177. package/dist/bun/plugin.js +0 -11
  178. package/dist/bun.cjs +0 -2238
  179. package/dist/bun.d.cts +0 -13
  180. package/dist/bun.d.ts +0 -13
  181. package/dist/bun.js +0 -28
  182. package/dist/chunk-2AKMBLHG.js +0 -2165
  183. package/dist/chunk-67YEOTXP.js +0 -25
  184. package/dist/chunk-IDVLHNL2.js +0 -46
  185. package/dist/chunk-ZZ6TR4PO.js +0 -201
  186. package/dist/cli.js +0 -2643
  187. package/dist/index.cjs +0 -2484
  188. package/dist/index.d.cts +0 -45
  189. package/dist/jest/plugin.cjs +0 -85
  190. package/dist/jest/plugin.d.cts +0 -7
  191. package/dist/jest/plugin.d.ts +0 -7
  192. package/dist/jest/plugin.js +0 -11
  193. package/dist/jest.cjs +0 -2237
  194. package/dist/jest.d.cts +0 -13
  195. package/dist/jest.d.ts +0 -13
  196. package/dist/jest.js +0 -27
  197. package/dist/matchers-Cqnbsyxe.d.cts +0 -11
  198. package/dist/matchers-Cqnbsyxe.d.ts +0 -11
  199. package/dist/node.cjs +0 -2237
  200. package/dist/node.d.cts +0 -13
  201. package/dist/node.d.ts +0 -13
  202. package/dist/node.js +0 -27
  203. package/dist/reporters-BbAXMpuW.d.cts +0 -6
  204. package/dist/reporters-xh-HQneS.d.ts +0 -6
  205. package/dist/suite-BwnPDCvU.d.cts +0 -337
  206. package/dist/suite-BwnPDCvU.d.ts +0 -337
  207. package/dist/vitest/plugin.cjs +0 -85
  208. package/dist/vitest/plugin.d.cts +0 -7
  209. package/dist/vitest/plugin.d.ts +0 -7
  210. package/dist/vitest/plugin.js +0 -11
  211. package/dist/vitest.cjs +0 -2531
  212. package/dist/vitest.d.cts +0 -37
  213. package/dist/vitest.d.ts +0 -37
  214. package/dist/vitest.js +0 -139
package/dist/vitest.d.cts DELETED
@@ -1,37 +0,0 @@
1
- import { TestOptions } from 'vitest';
2
- import { R as ReporterName } from './reporters-BbAXMpuW.cjs';
3
- import { A as ArcherOptions, a as ArchitectureSuite } from './suite-BwnPDCvU.cjs';
4
- export { S as Selector } from './suite-BwnPDCvU.cjs';
5
-
6
- interface ArchitectureCheckOptions {
7
- readonly baseline?: string;
8
- readonly config?: string;
9
- readonly cwd?: string;
10
- readonly failOnWarnings?: boolean;
11
- readonly output?: string;
12
- readonly reporter?: ReporterName;
13
- readonly updateBaseline?: boolean;
14
- }
15
-
16
- interface ArchTestOptions extends ArcherOptions {
17
- readonly test?: TestOptions;
18
- }
19
- interface ArcherVitestOptions extends Omit<ArchitectureCheckOptions, 'cwd' | 'updateBaseline'> {
20
- }
21
- interface ArcherVitestPlugin {
22
- readonly enforce: 'pre';
23
- readonly name: 'archer:architecture-check';
24
- readonly configResolved: (config: {
25
- readonly root: string;
26
- }) => Promise<void>;
27
- }
28
- /**
29
- * Runs Archer once while Vitest resolves its Vite configuration.
30
- */
31
- declare function archer(options?: ArcherVitestOptions): ArcherVitestPlugin;
32
- /**
33
- * Registers an architecture test in Vitest and returns its rule builder.
34
- */
35
- declare function arch(name: string, options?: ArchTestOptions): ArchitectureSuite;
36
-
37
- export { type ArchTestOptions, ArcherOptions, type ArcherVitestOptions, type ArcherVitestPlugin, arch, archer };
package/dist/vitest.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import { TestOptions } from 'vitest';
2
- import { R as ReporterName } from './reporters-xh-HQneS.js';
3
- import { A as ArcherOptions, a as ArchitectureSuite } from './suite-BwnPDCvU.js';
4
- export { S as Selector } from './suite-BwnPDCvU.js';
5
-
6
- interface ArchitectureCheckOptions {
7
- readonly baseline?: string;
8
- readonly config?: string;
9
- readonly cwd?: string;
10
- readonly failOnWarnings?: boolean;
11
- readonly output?: string;
12
- readonly reporter?: ReporterName;
13
- readonly updateBaseline?: boolean;
14
- }
15
-
16
- interface ArchTestOptions extends ArcherOptions {
17
- readonly test?: TestOptions;
18
- }
19
- interface ArcherVitestOptions extends Omit<ArchitectureCheckOptions, 'cwd' | 'updateBaseline'> {
20
- }
21
- interface ArcherVitestPlugin {
22
- readonly enforce: 'pre';
23
- readonly name: 'archer:architecture-check';
24
- readonly configResolved: (config: {
25
- readonly root: string;
26
- }) => Promise<void>;
27
- }
28
- /**
29
- * Runs Archer once while Vitest resolves its Vite configuration.
30
- */
31
- declare function archer(options?: ArcherVitestOptions): ArcherVitestPlugin;
32
- /**
33
- * Registers an architecture test in Vitest and returns its rule builder.
34
- */
35
- declare function arch(name: string, options?: ArchTestOptions): ArchitectureSuite;
36
-
37
- export { type ArchTestOptions, ArcherOptions, type ArcherVitestOptions, type ArcherVitestPlugin, arch, archer };
package/dist/vitest.js DELETED
@@ -1,139 +0,0 @@
1
- import {
2
- applyBaseline,
3
- createBaseline,
4
- readBaseline,
5
- report,
6
- writeBaseline
7
- } from "./chunk-ZZ6TR4PO.js";
8
- import {
9
- ArchitectureSuite,
10
- analyze
11
- } from "./chunk-2AKMBLHG.js";
12
- import {
13
- ArchitectureError
14
- } from "./chunk-IDVLHNL2.js";
15
-
16
- // src/adapters/vitest/index.ts
17
- import { test } from "vitest";
18
-
19
- // src/application/check.ts
20
- import { existsSync } from "fs";
21
- import { mkdir, writeFile } from "fs/promises";
22
- import path from "path";
23
- import { createJiti } from "jiti";
24
- var CONFIG_NAMES = [
25
- "archer.config.ts",
26
- "archer.config.mts",
27
- "archer.config.cts",
28
- "archer.config.js",
29
- "archer.config.mjs",
30
- "archer.config.cjs"
31
- ];
32
- var REPORTERS = /* @__PURE__ */ new Set([
33
- "agent",
34
- "dot",
35
- "github",
36
- "json",
37
- "llm",
38
- "pretty",
39
- "sarif"
40
- ]);
41
- function findConfig(cwd, explicit) {
42
- if (explicit !== void 0) {
43
- const resolved = path.resolve(cwd, explicit);
44
- if (!existsSync(resolved)) throw new Error(`Archer config not found: ${resolved}`);
45
- return resolved;
46
- }
47
- for (const name of CONFIG_NAMES) {
48
- const candidate = path.join(cwd, name);
49
- if (existsSync(candidate)) return candidate;
50
- }
51
- throw new Error(`No Archer config found in ${cwd}. Run 'archer init' to create one.`);
52
- }
53
- async function loadConfig(fileName) {
54
- const jiti = createJiti(fileName, { moduleCache: false });
55
- const config = await jiti.import(fileName, { default: true });
56
- if (typeof config !== "object" || config === null || !("rules" in config) || typeof config.rules !== "function") {
57
- throw new TypeError(`Archer config '${fileName}' must export defineConfig({ rules() {} }).`);
58
- }
59
- return config;
60
- }
61
- async function writeReport(fileName, content) {
62
- await mkdir(path.dirname(fileName), { recursive: true });
63
- await writeFile(fileName, `${content}
64
- `, "utf8");
65
- }
66
- async function checkArchitecture(options = {}) {
67
- const cwd = path.resolve(options.cwd ?? process.cwd());
68
- const configPath = findConfig(cwd, options.config);
69
- const config = await loadConfig(configPath);
70
- if (config.reporter !== void 0 && !REPORTERS.has(config.reporter)) {
71
- throw new TypeError(`Unknown reporter '${config.reporter}' in ${configPath}.`);
72
- }
73
- const configDirectory = path.dirname(configPath);
74
- const root = path.resolve(configDirectory, config.root ?? ".");
75
- const suite = new ArchitectureSuite({ ...config, root });
76
- await config.rules(suite);
77
- const graph = await analyze({ ...config, root });
78
- const originalResult = await suite.check(graph);
79
- const configuredBaseline = options.baseline ?? config.baseline;
80
- const baselinePath = path.resolve(configDirectory, configuredBaseline ?? ".archer-baseline.json");
81
- const updateBaseline = options.updateBaseline ?? false;
82
- if (updateBaseline) await writeBaseline(baselinePath, createBaseline(originalResult));
83
- if (!updateBaseline && configuredBaseline !== void 0 && !existsSync(baselinePath)) {
84
- throw new Error(`Archer baseline not found: ${baselinePath}`);
85
- }
86
- const result = !updateBaseline && existsSync(baselinePath) ? applyBaseline(originalResult, await readBaseline(baselinePath)) : originalResult;
87
- const reporter = options.reporter ?? config.reporter ?? "pretty";
88
- const content = report(reporter, result, graph);
89
- const configuredOutput = options.output ?? config.output;
90
- const outputPath = configuredOutput === void 0 ? void 0 : path.resolve(configDirectory, configuredOutput);
91
- if (outputPath !== void 0) await writeReport(outputPath, content);
92
- return {
93
- baselinePath,
94
- code: result.ok && (!(options.failOnWarnings ?? false) || result.warnings === 0) ? 0 : 1,
95
- content,
96
- graph,
97
- ...outputPath === void 0 ? {} : { outputPath },
98
- result,
99
- updatedBaseline: updateBaseline
100
- };
101
- }
102
-
103
- // src/adapters/vitest/index.ts
104
- var ArcherVitestError = class extends Error {
105
- constructor(message) {
106
- super(message);
107
- this.name = "ArcherVitestError";
108
- }
109
- };
110
- function archer(options = {}) {
111
- let execution;
112
- return {
113
- enforce: "pre",
114
- name: "archer:architecture-check",
115
- configResolved(config) {
116
- execution ??= checkArchitecture({ ...options, cwd: config.root }).then((result) => {
117
- if (result.code !== 0) throw new ArcherVitestError(result.content);
118
- if (result.outputPath === void 0) process.stdout.write(`${result.content}
119
- `);
120
- });
121
- return execution;
122
- }
123
- };
124
- }
125
- function arch(name, options = {}) {
126
- const { test: testOptions, ...archerOptions } = options;
127
- const suite = new ArchitectureSuite(archerOptions);
128
- test(name, testOptions ?? {}, async () => {
129
- const result = await suite.check();
130
- if (!result.ok) {
131
- throw new ArchitectureError(result);
132
- }
133
- });
134
- return suite;
135
- }
136
- export {
137
- arch,
138
- archer
139
- };