@intentset/cli 0.1.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 (116) hide show
  1. package/dist/commands/architecture.d.ts +6 -0
  2. package/dist/commands/architecture.d.ts.map +1 -0
  3. package/dist/commands/architecture.js +65 -0
  4. package/dist/commands/architecture.js.map +1 -0
  5. package/dist/commands/context.d.ts +4 -0
  6. package/dist/commands/context.d.ts.map +1 -0
  7. package/dist/commands/context.js +124 -0
  8. package/dist/commands/context.js.map +1 -0
  9. package/dist/commands/evidence.d.ts +29 -0
  10. package/dist/commands/evidence.d.ts.map +1 -0
  11. package/dist/commands/evidence.js +157 -0
  12. package/dist/commands/evidence.js.map +1 -0
  13. package/dist/commands/graph.d.ts +18 -0
  14. package/dist/commands/graph.d.ts.map +1 -0
  15. package/dist/commands/graph.js +77 -0
  16. package/dist/commands/graph.js.map +1 -0
  17. package/dist/commands/impact.d.ts +20 -0
  18. package/dist/commands/impact.d.ts.map +1 -0
  19. package/dist/commands/impact.js +92 -0
  20. package/dist/commands/impact.js.map +1 -0
  21. package/dist/commands/init.d.ts +18 -0
  22. package/dist/commands/init.d.ts.map +1 -0
  23. package/dist/commands/init.js +122 -0
  24. package/dist/commands/init.js.map +1 -0
  25. package/dist/commands/mcp.d.ts +24 -0
  26. package/dist/commands/mcp.d.ts.map +1 -0
  27. package/dist/commands/mcp.js +122 -0
  28. package/dist/commands/mcp.js.map +1 -0
  29. package/dist/commands/publish.d.ts +19 -0
  30. package/dist/commands/publish.d.ts.map +1 -0
  31. package/dist/commands/publish.js +98 -0
  32. package/dist/commands/publish.js.map +1 -0
  33. package/dist/commands/review.d.ts +29 -0
  34. package/dist/commands/review.d.ts.map +1 -0
  35. package/dist/commands/review.js +147 -0
  36. package/dist/commands/review.js.map +1 -0
  37. package/dist/commands/serve.d.ts +14 -0
  38. package/dist/commands/serve.d.ts.map +1 -0
  39. package/dist/commands/serve.js +246 -0
  40. package/dist/commands/serve.js.map +1 -0
  41. package/dist/commands/shared.d.ts +19 -0
  42. package/dist/commands/shared.d.ts.map +1 -0
  43. package/dist/commands/shared.js +43 -0
  44. package/dist/commands/shared.js.map +1 -0
  45. package/dist/commands/validate.d.ts +11 -0
  46. package/dist/commands/validate.d.ts.map +1 -0
  47. package/dist/commands/validate.js +38 -0
  48. package/dist/commands/validate.js.map +1 -0
  49. package/dist/git.d.ts +25 -0
  50. package/dist/git.d.ts.map +1 -0
  51. package/dist/git.js +63 -0
  52. package/dist/git.js.map +1 -0
  53. package/dist/glob.d.ts +16 -0
  54. package/dist/glob.d.ts.map +1 -0
  55. package/dist/glob.js +60 -0
  56. package/dist/glob.js.map +1 -0
  57. package/dist/index.d.ts +9 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +8 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/intentset.d.ts +3 -0
  62. package/dist/intentset.d.ts.map +1 -0
  63. package/dist/intentset.js +15 -0
  64. package/dist/intentset.js.map +1 -0
  65. package/dist/main.d.ts +5 -0
  66. package/dist/main.d.ts.map +1 -0
  67. package/dist/main.js +406 -0
  68. package/dist/main.js.map +1 -0
  69. package/dist/output.d.ts +38 -0
  70. package/dist/output.d.ts.map +1 -0
  71. package/dist/output.js +53 -0
  72. package/dist/output.js.map +1 -0
  73. package/dist/outputs.d.ts +17 -0
  74. package/dist/outputs.d.ts.map +1 -0
  75. package/dist/outputs.js +70 -0
  76. package/dist/outputs.js.map +1 -0
  77. package/dist/reports.d.ts +16 -0
  78. package/dist/reports.d.ts.map +1 -0
  79. package/dist/reports.js +89 -0
  80. package/dist/reports.js.map +1 -0
  81. package/dist/repository.d.ts +56 -0
  82. package/dist/repository.d.ts.map +1 -0
  83. package/dist/repository.js +191 -0
  84. package/dist/repository.js.map +1 -0
  85. package/dist/session.d.ts +61 -0
  86. package/dist/session.d.ts.map +1 -0
  87. package/dist/session.js +202 -0
  88. package/dist/session.js.map +1 -0
  89. package/dist/tree.d.ts +15 -0
  90. package/dist/tree.d.ts.map +1 -0
  91. package/dist/tree.js +56 -0
  92. package/dist/tree.js.map +1 -0
  93. package/package.json +46 -0
  94. package/src/commands/architecture.ts +77 -0
  95. package/src/commands/context.ts +142 -0
  96. package/src/commands/evidence.ts +180 -0
  97. package/src/commands/graph.ts +89 -0
  98. package/src/commands/impact.ts +97 -0
  99. package/src/commands/init.ts +138 -0
  100. package/src/commands/mcp.ts +143 -0
  101. package/src/commands/publish.ts +119 -0
  102. package/src/commands/review.ts +155 -0
  103. package/src/commands/serve.ts +261 -0
  104. package/src/commands/shared.ts +46 -0
  105. package/src/commands/validate.ts +39 -0
  106. package/src/git.ts +81 -0
  107. package/src/glob.ts +58 -0
  108. package/src/index.ts +8 -0
  109. package/src/intentset.ts +15 -0
  110. package/src/main.ts +408 -0
  111. package/src/output.ts +78 -0
  112. package/src/outputs.ts +65 -0
  113. package/src/reports.ts +103 -0
  114. package/src/repository.ts +220 -0
  115. package/src/session.ts +276 -0
  116. package/src/tree.ts +64 -0
package/src/tree.ts ADDED
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The repository as the architecture and evidence checks see it: every file
3
+ * `listFiles` returns that neither `.intentset/config.yaml` nor
4
+ * `.intentset/architecture.yaml` ignores. Code and configuration carry their
5
+ * text; every other file (a stylesheet, an image, a font) is present with an
6
+ * empty text, so an import of it resolves to a file rather than to nothing.
7
+ * A text file over 1 MiB is present but not read, and the report lists it,
8
+ * rather than a check quietly seeing less than the tree holds.
9
+ */
10
+ import { readFileSync, statSync } from "node:fs";
11
+ import { join } from "node:path";
12
+ import { ARCHITECTURE_CONFIG_PATH, readArchitectureConfig, resolveConfig } from "@intentset/architecture";
13
+ import type { Config } from "@intentset/core";
14
+ import { listFiles } from "./repository.ts";
15
+
16
+ /** Extensions read as text: code the import graph needs, and the JSON, Markdown and YAML it and the claims name. */
17
+ export const TEXT_EXTENSIONS = [
18
+ ".ts",
19
+ ".tsx",
20
+ ".mts",
21
+ ".cts",
22
+ ".js",
23
+ ".jsx",
24
+ ".mjs",
25
+ ".cjs",
26
+ ".json",
27
+ ".md",
28
+ ".yaml",
29
+ ".yml",
30
+ ];
31
+
32
+ /** The largest file read into the tree; Core §3 bounds what a tool reads, and a record has the same limit. */
33
+ export const TREE_MAX_BYTES = 1024 * 1024;
34
+
35
+ export interface Tree {
36
+ /** Every path in the tree, with its text for code and configuration and "" for anything else. */
37
+ files: Map<string, string>;
38
+ /** Every path in the tree, for checks that only ask whether a file exists. */
39
+ paths: Set<string>;
40
+ /** Files with a text extension that were over the limit and not read, sorted. */
41
+ skipped: string[];
42
+ }
43
+
44
+ export function readTree(root: string, config: Pick<Config, "ignore">): Tree {
45
+ let ignore = resolveConfig().ignore;
46
+ try {
47
+ const text = readFileSync(join(root, ARCHITECTURE_CONFIG_PATH), "utf8");
48
+ ignore = resolveConfig(readArchitectureConfig(text).config).ignore;
49
+ } catch {
50
+ // No architecture configuration: its default ignore list stands.
51
+ }
52
+ const files = new Map<string, string>();
53
+ const skipped: string[] = [];
54
+ const paths = listFiles(root, [...config.ignore, ...ignore]);
55
+ for (const path of paths) {
56
+ const file = join(root, path);
57
+ if (!TEXT_EXTENSIONS.some((extension) => path.endsWith(extension))) files.set(path, "");
58
+ else if (statSync(file).size > TREE_MAX_BYTES) {
59
+ skipped.push(path);
60
+ files.set(path, "");
61
+ } else files.set(path, readFileSync(file, "utf8"));
62
+ }
63
+ return { files, paths: new Set(paths), skipped };
64
+ }