@eddacraft/anvil-runtime 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 (170) hide show
  1. package/LICENSE +14 -0
  2. package/dist/cache/cache-key.d.ts +45 -0
  3. package/dist/cache/cache-key.d.ts.map +1 -0
  4. package/dist/cache/cache-key.js +135 -0
  5. package/dist/cache/index.d.ts +27 -0
  6. package/dist/cache/index.d.ts.map +1 -0
  7. package/dist/cache/index.js +38 -0
  8. package/dist/cache/providers/file-cache.d.ts +63 -0
  9. package/dist/cache/providers/file-cache.d.ts.map +1 -0
  10. package/dist/cache/providers/file-cache.js +369 -0
  11. package/dist/cache/providers/memory-cache.d.ts +52 -0
  12. package/dist/cache/providers/memory-cache.d.ts.map +1 -0
  13. package/dist/cache/providers/memory-cache.js +197 -0
  14. package/dist/cache/providers/null-cache.d.ts +26 -0
  15. package/dist/cache/providers/null-cache.d.ts.map +1 -0
  16. package/dist/cache/providers/null-cache.js +50 -0
  17. package/dist/cache/types.d.ts +114 -0
  18. package/dist/cache/types.d.ts.map +1 -0
  19. package/dist/cache/types.js +4 -0
  20. package/dist/concurrency/agent.d.ts +137 -0
  21. package/dist/concurrency/agent.d.ts.map +1 -0
  22. package/dist/concurrency/agent.js +440 -0
  23. package/dist/concurrency/atomic.d.ts +93 -0
  24. package/dist/concurrency/atomic.d.ts.map +1 -0
  25. package/dist/concurrency/atomic.js +281 -0
  26. package/dist/concurrency/git-agent.d.ts +114 -0
  27. package/dist/concurrency/git-agent.d.ts.map +1 -0
  28. package/dist/concurrency/git-agent.js +313 -0
  29. package/dist/concurrency/index.d.ts +95 -0
  30. package/dist/concurrency/index.d.ts.map +1 -0
  31. package/dist/concurrency/index.js +127 -0
  32. package/dist/concurrency/lock-manager.d.ts +170 -0
  33. package/dist/concurrency/lock-manager.d.ts.map +1 -0
  34. package/dist/concurrency/lock-manager.js +525 -0
  35. package/dist/concurrency/queue-manager.d.ts +166 -0
  36. package/dist/concurrency/queue-manager.d.ts.map +1 -0
  37. package/dist/concurrency/queue-manager.js +442 -0
  38. package/dist/concurrency/types.d.ts +382 -0
  39. package/dist/concurrency/types.d.ts.map +1 -0
  40. package/dist/concurrency/types.js +204 -0
  41. package/dist/export/constraint-collector.d.ts +175 -0
  42. package/dist/export/constraint-collector.d.ts.map +1 -0
  43. package/dist/export/constraint-collector.js +203 -0
  44. package/dist/export/formatters/llms-txt-formatter.d.ts +89 -0
  45. package/dist/export/formatters/llms-txt-formatter.d.ts.map +1 -0
  46. package/dist/export/formatters/llms-txt-formatter.js +249 -0
  47. package/dist/export/formatters/mcp-resource-formatter.d.ts +186 -0
  48. package/dist/export/formatters/mcp-resource-formatter.d.ts.map +1 -0
  49. package/dist/export/formatters/mcp-resource-formatter.js +139 -0
  50. package/dist/export/formatters/prompt-formatter.d.ts +83 -0
  51. package/dist/export/formatters/prompt-formatter.d.ts.map +1 -0
  52. package/dist/export/formatters/prompt-formatter.js +256 -0
  53. package/dist/export/index.d.ts +10 -0
  54. package/dist/export/index.d.ts.map +1 -0
  55. package/dist/export/index.js +9 -0
  56. package/dist/gate/check.interface.d.ts +15 -0
  57. package/dist/gate/check.interface.d.ts.map +1 -0
  58. package/dist/gate/check.interface.js +18 -0
  59. package/dist/gate/checks/antipattern.check.d.ts +27 -0
  60. package/dist/gate/checks/antipattern.check.d.ts.map +1 -0
  61. package/dist/gate/checks/antipattern.check.js +140 -0
  62. package/dist/gate/checks/architecture/circular-detector.d.ts +33 -0
  63. package/dist/gate/checks/architecture/circular-detector.d.ts.map +1 -0
  64. package/dist/gate/checks/architecture/circular-detector.js +71 -0
  65. package/dist/gate/checks/architecture/dependency-analyzer.d.ts +81 -0
  66. package/dist/gate/checks/architecture/dependency-analyzer.d.ts.map +1 -0
  67. package/dist/gate/checks/architecture/dependency-analyzer.js +136 -0
  68. package/dist/gate/checks/architecture/layer-validator.d.ts +75 -0
  69. package/dist/gate/checks/architecture/layer-validator.d.ts.map +1 -0
  70. package/dist/gate/checks/architecture/layer-validator.js +193 -0
  71. package/dist/gate/checks/architecture.check.d.ts +56 -0
  72. package/dist/gate/checks/architecture.check.d.ts.map +1 -0
  73. package/dist/gate/checks/architecture.check.js +394 -0
  74. package/dist/gate/checks/command-safety.check.d.ts +12 -0
  75. package/dist/gate/checks/command-safety.check.d.ts.map +1 -0
  76. package/dist/gate/checks/command-safety.check.js +230 -0
  77. package/dist/gate/checks/coverage.check.d.ts +9 -0
  78. package/dist/gate/checks/coverage.check.d.ts.map +1 -0
  79. package/dist/gate/checks/coverage.check.js +81 -0
  80. package/dist/gate/checks/dependency.check.d.ts +17 -0
  81. package/dist/gate/checks/dependency.check.d.ts.map +1 -0
  82. package/dist/gate/checks/dependency.check.js +342 -0
  83. package/dist/gate/checks/eslint.check.d.ts +14 -0
  84. package/dist/gate/checks/eslint.check.d.ts.map +1 -0
  85. package/dist/gate/checks/eslint.check.js +79 -0
  86. package/dist/gate/checks/policy.check.d.ts +78 -0
  87. package/dist/gate/checks/policy.check.d.ts.map +1 -0
  88. package/dist/gate/checks/policy.check.js +457 -0
  89. package/dist/gate/checks/secret/entropy-detector.d.ts +44 -0
  90. package/dist/gate/checks/secret/entropy-detector.d.ts.map +1 -0
  91. package/dist/gate/checks/secret/entropy-detector.js +76 -0
  92. package/dist/gate/checks/secret/git-scanner.d.ts +36 -0
  93. package/dist/gate/checks/secret/git-scanner.d.ts.map +1 -0
  94. package/dist/gate/checks/secret/git-scanner.js +90 -0
  95. package/dist/gate/checks/secret/secret-patterns.d.ts +42 -0
  96. package/dist/gate/checks/secret/secret-patterns.d.ts.map +1 -0
  97. package/dist/gate/checks/secret/secret-patterns.js +137 -0
  98. package/dist/gate/checks/secret.check.d.ts +56 -0
  99. package/dist/gate/checks/secret.check.d.ts.map +1 -0
  100. package/dist/gate/checks/secret.check.js +245 -0
  101. package/dist/gate/config/command-safety-config.d.ts +5 -0
  102. package/dist/gate/config/command-safety-config.d.ts.map +1 -0
  103. package/dist/gate/config/command-safety-config.js +69 -0
  104. package/dist/gate/config/index.d.ts +2 -0
  105. package/dist/gate/config/index.d.ts.map +1 -0
  106. package/dist/gate/config/index.js +1 -0
  107. package/dist/gate/formatters/command-safety-formatter.d.ts +10 -0
  108. package/dist/gate/formatters/command-safety-formatter.d.ts.map +1 -0
  109. package/dist/gate/formatters/command-safety-formatter.js +64 -0
  110. package/dist/gate/formatters/index.d.ts +2 -0
  111. package/dist/gate/formatters/index.d.ts.map +1 -0
  112. package/dist/gate/formatters/index.js +1 -0
  113. package/dist/gate/gate-config.d.ts +44 -0
  114. package/dist/gate/gate-config.d.ts.map +1 -0
  115. package/dist/gate/gate-config.js +334 -0
  116. package/dist/gate/gate-runner.d.ts +160 -0
  117. package/dist/gate/gate-runner.d.ts.map +1 -0
  118. package/dist/gate/gate-runner.js +531 -0
  119. package/dist/gate/index.d.ts +20 -0
  120. package/dist/gate/index.d.ts.map +1 -0
  121. package/dist/gate/index.js +14 -0
  122. package/dist/gate/parsers/command-parser.d.ts +18 -0
  123. package/dist/gate/parsers/command-parser.d.ts.map +1 -0
  124. package/dist/gate/parsers/command-parser.js +363 -0
  125. package/dist/gate/parsers/index.d.ts +2 -0
  126. package/dist/gate/parsers/index.d.ts.map +1 -0
  127. package/dist/gate/parsers/index.js +1 -0
  128. package/dist/gate/policy/index.d.ts +12 -0
  129. package/dist/gate/policy/index.d.ts.map +1 -0
  130. package/dist/gate/policy/index.js +10 -0
  131. package/dist/gate/rules/default-filesystem-rules.d.ts +3 -0
  132. package/dist/gate/rules/default-filesystem-rules.d.ts.map +1 -0
  133. package/dist/gate/rules/default-filesystem-rules.js +201 -0
  134. package/dist/gate/rules/default-git-rules.d.ts +3 -0
  135. package/dist/gate/rules/default-git-rules.d.ts.map +1 -0
  136. package/dist/gate/rules/default-git-rules.js +192 -0
  137. package/dist/gate/rules/index.d.ts +5 -0
  138. package/dist/gate/rules/index.d.ts.map +1 -0
  139. package/dist/gate/rules/index.js +3 -0
  140. package/dist/gate/rules/rule-matcher.d.ts +27 -0
  141. package/dist/gate/rules/rule-matcher.d.ts.map +1 -0
  142. package/dist/gate/rules/rule-matcher.js +228 -0
  143. package/dist/gate/rules/types.d.ts +250 -0
  144. package/dist/gate/rules/types.d.ts.map +1 -0
  145. package/dist/gate/rules/types.js +1 -0
  146. package/dist/index.d.ts +19 -0
  147. package/dist/index.d.ts.map +1 -0
  148. package/dist/index.js +35 -0
  149. package/dist/types/gate.types.d.ts +42 -0
  150. package/dist/types/gate.types.d.ts.map +1 -0
  151. package/dist/types/gate.types.js +94 -0
  152. package/dist/watch/debouncer.d.ts +90 -0
  153. package/dist/watch/debouncer.d.ts.map +1 -0
  154. package/dist/watch/debouncer.js +135 -0
  155. package/dist/watch/file-watcher.d.ts +73 -0
  156. package/dist/watch/file-watcher.d.ts.map +1 -0
  157. package/dist/watch/file-watcher.js +121 -0
  158. package/dist/watch/git-status.d.ts +98 -0
  159. package/dist/watch/git-status.d.ts.map +1 -0
  160. package/dist/watch/git-status.js +266 -0
  161. package/dist/watch/index.d.ts +16 -0
  162. package/dist/watch/index.d.ts.map +1 -0
  163. package/dist/watch/index.js +15 -0
  164. package/dist/watch/orchestrator.d.ts +113 -0
  165. package/dist/watch/orchestrator.d.ts.map +1 -0
  166. package/dist/watch/orchestrator.js +409 -0
  167. package/dist/watch/types.d.ts +190 -0
  168. package/dist/watch/types.d.ts.map +1 -0
  169. package/dist/watch/types.js +76 -0
  170. package/package.json +60 -0
@@ -0,0 +1,250 @@
1
+ /**
2
+ * Category of command rule
3
+ */
4
+ export type CommandCategory = 'git' | 'filesystem' | 'shell' | 'custom';
5
+ /**
6
+ * Action to take when a rule matches
7
+ */
8
+ export type CommandAction = 'block' | 'warn' | 'allow';
9
+ /**
10
+ * Severity level for rule violations
11
+ */
12
+ export type CommandSeverity = 'error' | 'warning' | 'info';
13
+ /**
14
+ * Flag matching configuration for a rule
15
+ */
16
+ export interface CommandFlagConfig {
17
+ /** Flags where ANY ONE must be present for the rule to match (OR logic) */
18
+ required?: string[];
19
+ /** Flags where ALL must be present for the rule to match (AND logic) */
20
+ requiredAll?: string[];
21
+ /** Flags that must NOT be present for the rule to match */
22
+ forbidden?: string[];
23
+ /** Flags that make the command dangerous when present */
24
+ dangerous?: string[];
25
+ }
26
+ /**
27
+ * Argument matching configuration for a rule
28
+ */
29
+ export interface CommandArgConfig {
30
+ /** Regex pattern to match against arguments */
31
+ pattern?: RegExp;
32
+ /** Specific argument position to check (0-indexed) */
33
+ position?: number;
34
+ }
35
+ /**
36
+ * Conditions for when a rule applies
37
+ */
38
+ export interface CommandConditions {
39
+ /** Only apply in strict mode */
40
+ strictModeOnly?: boolean;
41
+ /** Working directory restrictions */
42
+ workingDirectory?: 'home' | 'root' | 'any';
43
+ }
44
+ /**
45
+ * A command safety rule definition.
46
+ *
47
+ * Rules are matched by specificity: command + subcommand + flags + args.
48
+ * More specific rules take precedence over less specific ones.
49
+ */
50
+ export interface CommandRule {
51
+ /** Unique identifier for the rule (e.g., 'git-reset-hard') */
52
+ id: string;
53
+ /** Category of the rule */
54
+ category: CommandCategory;
55
+ /** Base command to match (e.g., 'git', 'rm') */
56
+ command: string;
57
+ /** Optional subcommand to match (e.g., 'reset', 'push') */
58
+ subcommand?: string;
59
+ /** Flag matching configuration */
60
+ flags?: CommandFlagConfig;
61
+ /** Argument matching configuration */
62
+ args?: CommandArgConfig;
63
+ /** Action to take when the rule matches */
64
+ action: CommandAction;
65
+ /** Severity level for reporting */
66
+ severity: CommandSeverity;
67
+ /** Human-readable explanation of why this is blocked/warned */
68
+ reason: string;
69
+ /** Suggested safe alternative */
70
+ suggestion?: string;
71
+ /** Reference links for more information */
72
+ references?: string[];
73
+ /** Conditions for when the rule applies */
74
+ conditions?: CommandConditions;
75
+ }
76
+ /**
77
+ * A collection of command rules
78
+ */
79
+ export interface CommandRuleset {
80
+ /** Ruleset version */
81
+ version: string;
82
+ /** Array of rules */
83
+ rules: CommandRule[];
84
+ }
85
+ /**
86
+ * A parsed shell command with extracted components.
87
+ *
88
+ * This is the output of the CommandParser.
89
+ */
90
+ export interface ParsedCommand {
91
+ /** Original raw command string */
92
+ raw: string;
93
+ /** Base command (e.g., 'git', 'rm', 'bash') */
94
+ command: string;
95
+ /** Subcommand if applicable (e.g., 'reset', 'push') */
96
+ subcommand?: string;
97
+ /** Extracted flags (e.g., ['--hard', '-f', '-r']) */
98
+ flags: string[];
99
+ /** Extracted arguments (non-flag tokens) */
100
+ args: string[];
101
+ /** The unwrapped command after stripping wrappers */
102
+ unwrapped: string;
103
+ /** Chain of wrappers that were stripped (e.g., ['sudo', 'bash']) */
104
+ wrapperChain: string[];
105
+ }
106
+ /**
107
+ * Result of analysing a single command against the ruleset.
108
+ */
109
+ export interface CommandAnalysisResult {
110
+ /** Original command string */
111
+ command: string;
112
+ /** Parsed command structure */
113
+ parsedCommand: ParsedCommand;
114
+ /** The rule that matched, if any */
115
+ matchedRule?: CommandRule;
116
+ /** Resolved action to take */
117
+ action: CommandAction;
118
+ /** Resolved severity level */
119
+ severity: CommandSeverity;
120
+ /** Reason for the action (from matched rule) */
121
+ reason?: string;
122
+ /** Suggested alternative (from matched rule) */
123
+ suggestion?: string;
124
+ /** Reference links (from matched rule) */
125
+ references?: string[];
126
+ }
127
+ /**
128
+ * Summary of command analysis results.
129
+ */
130
+ export interface CommandAnalysisSummary {
131
+ /** Total commands analysed */
132
+ total: number;
133
+ /** Number of blocked commands */
134
+ blocked: number;
135
+ /** Number of warned commands */
136
+ warned: number;
137
+ /** Number of allowed commands */
138
+ allowed: number;
139
+ }
140
+ /**
141
+ * Override configuration for a specific rule.
142
+ */
143
+ export interface CommandRuleOverride {
144
+ /** Rule ID to override */
145
+ id: string;
146
+ /** Override action (or 'disable' to completely disable) */
147
+ action?: CommandAction | 'disable';
148
+ /** Override severity */
149
+ severity?: CommandSeverity;
150
+ }
151
+ /**
152
+ * Rules configuration section.
153
+ */
154
+ export interface CommandRulesConfig {
155
+ /** Override existing rules */
156
+ overrides?: CommandRuleOverride[];
157
+ /** Add custom rules */
158
+ custom?: CommandRule[];
159
+ /** Disable specific rules by ID */
160
+ disabled?: string[];
161
+ }
162
+ /**
163
+ * Working directory configuration.
164
+ */
165
+ export interface WorkingDirectoryConfig {
166
+ /** Allow rm -rf in current working directory */
167
+ allowDeleteInCwd?: boolean;
168
+ /** Additional patterns to treat as temp directories */
169
+ tempDirPatterns?: string[];
170
+ }
171
+ /**
172
+ * Output configuration.
173
+ */
174
+ export interface CommandSafetyOutputConfig {
175
+ /** Include full command in error messages */
176
+ verbose?: boolean;
177
+ /** Show safe alternative suggestions */
178
+ showSuggestions?: boolean;
179
+ /** Show reference links */
180
+ showReferences?: boolean;
181
+ }
182
+ /**
183
+ * Command safety check configuration.
184
+ *
185
+ * This is loaded from `.anvilrc` under the `commandSafety` key.
186
+ */
187
+ export interface CommandSafetyConfig {
188
+ /** Enable/disable the check (default: true) */
189
+ enabled?: boolean;
190
+ /** Strict mode - block unparseable commands (default: false) */
191
+ strict?: boolean;
192
+ /** Rule customisation */
193
+ rules?: CommandRulesConfig;
194
+ /** Working directory restrictions */
195
+ workingDirectory?: WorkingDirectoryConfig;
196
+ /** Output customisation */
197
+ output?: CommandSafetyOutputConfig;
198
+ }
199
+ /**
200
+ * Resolved configuration with all defaults applied.
201
+ */
202
+ export interface ResolvedCommandSafetyConfig {
203
+ enabled: boolean;
204
+ strict: boolean;
205
+ rules: CommandRule[];
206
+ workingDirectory: Required<WorkingDirectoryConfig>;
207
+ output: Required<CommandSafetyOutputConfig>;
208
+ }
209
+ /**
210
+ * Detailed information about a blocked or warned command.
211
+ */
212
+ export interface CommandSafetyFinding {
213
+ /** The command that was flagged */
214
+ command: string;
215
+ /** The rule ID that matched */
216
+ ruleId: string;
217
+ /** Category of the rule */
218
+ category: CommandCategory;
219
+ /** Action taken (block or warn) */
220
+ action: Exclude<CommandAction, 'allow'>;
221
+ /** Severity level */
222
+ severity: CommandSeverity;
223
+ /** Human-readable reason */
224
+ reason: string;
225
+ /** Suggested safe alternative */
226
+ suggestion?: string;
227
+ /** Reference links */
228
+ references?: string[];
229
+ /** Source location if available (e.g., plan file path) */
230
+ source?: string;
231
+ }
232
+ /**
233
+ * Result details from the command safety check.
234
+ */
235
+ export interface CommandSafetyDetails {
236
+ /** Commands that were blocked */
237
+ blocked: CommandSafetyFinding[];
238
+ /** Commands that triggered warnings */
239
+ warnings: CommandSafetyFinding[];
240
+ /** Summary statistics */
241
+ summary: CommandAnalysisSummary;
242
+ /** Configuration that was used */
243
+ config?: {
244
+ strict: boolean;
245
+ rulesCount: number;
246
+ customRulesCount: number;
247
+ disabledRulesCount: number;
248
+ };
249
+ }
250
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/gate/rules/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC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E,MAAM,CAAC;IAEpB,sBAAsB;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,iCAAiC;IACjC,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAEhC,uCAAuC;IACvC,QAAQ,EAAE,oBAAoB,EAAE,CAAC;IAEjC,yBAAyB;IACzB,OAAO,EAAE,sBAAsB,CAAC;IAEhC,kCAAkC;IAClC,MAAM,CAAC,EAAE;QACP,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB,EAAE,MAAM,CAAC;QACzB,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @eddacraft/anvil-runtime
3
+ *
4
+ * Orchestration and I/O for the Anvil system.
5
+ * Contains gate runner, cache providers, file watcher, export utilities,
6
+ * and multi-agent concurrency coordination.
7
+ *
8
+ * This package handles all I/O operations that @eddacraft/anvil-core does not.
9
+ *
10
+ * @module @eddacraft/anvil-runtime
11
+ */
12
+ export * from './gate/index.js';
13
+ export * from './cache/index.js';
14
+ export { WatchConfigSchema, WatchGitConfigSchema, parseWatchConfig, getDefaultWatchConfig, DEFAULT_WATCH_PATTERNS, DEFAULT_EXCLUDE_PATTERNS, GitStatusChecker, createGitStatusChecker, getChangedFiles, ChangeDebouncer, createDebouncer, FileWatcher, createFileWatcher, WatchOrchestrator, createWatchOrchestrator, } from './watch/index.js';
15
+ export type { WatchConfig as DetailedWatchConfig, WatchGitConfig, GitFileStatus, WatchChangeEvent, DebouncedChanges, WatchStatusEvent, WatchStatusEventType, WatchActionResult, WatchOrchestratorOptions, GetChangedFilesOptions, DebouncerFlushCallback, FileWatcherOptions, FileWatcherEvents, ActionHandler, MultiAgentConfig, } from './watch/index.js';
16
+ export * from './export/index.js';
17
+ export { AgentTypeSchema, AgentInfoSchema, AgentRegistrationSchema, AgentRegistrySchema, LockTypeSchema, LockRecordSchema, LockFileSchema, QueueEntrySchema, QueueFileSchema, ConcurrencyConfigSchema, getDefaultConcurrencyConfig, AgentManager, createAgentManager, initializeGlobalAgent, getGlobalAgent, detectAgentType, getAgentId, getSessionId, getAgentName, createAgentInfo, LockManager, createLockManager, withLock, tryWithLock, QueueManager, createQueueManager, coordinatedExecution, withConcurrencyLimit, GIT_TRAILERS, parseCommitTrailers, extractAgentInfo, getCommitAgentInfo, getRecentCommitsAgentInfo, formatCommitWithAgent, prepareCommitMsgHook, getHookSetupCommand, getAgentContributions, getAiCommitPercentage, atomicWriteJson, atomicWriteText, readJsonSafe, readJsonWithRetry, acquireFileLock, tryAcquireFileLock, isLocked, forceReleaseLock, unlinkSafe, fileExists, getFileMtime, sleepWithJitter, createConcurrencyContext, createSimpleLockContext, } from './concurrency/index.js';
18
+ export type { AgentType, AgentInfo, AgentRegistration, AgentRegistry, LockType, LockRecord, LockFile, LockAcquisitionResult, LockReleaseResult, QueueEntry, QueueFile, QueueJoinResult, QueueStatusResult, CoordinationEvent, CoordinationEventType, ConcurrencyConfig, AgentManagerOptions, LockManagerOptions, AcquireLockOptions, QueueManagerOptions, QueueJoinOptions, QueueWaitOptions, ConcurrencyContextOptions, ConcurrencyContext, ConcurrentGroupResult, CommitAgentInfo, FormatCommitOptions, AgentContributionSummary, AtomicWriteOptions, FileLockOptions, FileLockHandle, } from './concurrency/index.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,cAAc,iBAAiB,CAAC;AAGhC,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,w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ACV,QAAQ,EACR,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EAEjB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EAErB,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EAExB,kBAAkB,EAClB,eAAe,EACf,cAAc,GACf,MAAM,wBAAwB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @eddacraft/anvil-runtime
3
+ *
4
+ * Orchestration and I/O for the Anvil system.
5
+ * Contains gate runner, cache providers, file watcher, export utilities,
6
+ * and multi-agent concurrency coordination.
7
+ *
8
+ * This package handles all I/O operations that @eddacraft/anvil-core does not.
9
+ *
10
+ * @module @eddacraft/anvil-runtime
11
+ */
12
+ // Gate runner and checks (includes types from @eddacraft/anvil-contracts)
13
+ export * from './gate/index.js';
14
+ // Cache providers
15
+ export * from './cache/index.js';
16
+ // File watching - export specific items to avoid WatchConfig conflict
17
+ export { WatchConfigSchema, WatchGitConfigSchema, parseWatchConfig, getDefaultWatchConfig, DEFAULT_WATCH_PATTERNS, DEFAULT_EXCLUDE_PATTERNS, GitStatusChecker, createGitStatusChecker, getChangedFiles, ChangeDebouncer, createDebouncer, FileWatcher, createFileWatcher, WatchOrchestrator, createWatchOrchestrator, } from './watch/index.js';
18
+ // Export utilities (llms.txt, MCP, etc.)
19
+ export * from './export/index.js';
20
+ // Multi-agent concurrency coordination
21
+ export {
22
+ // Types and schemas
23
+ AgentTypeSchema, AgentInfoSchema, AgentRegistrationSchema, AgentRegistrySchema, LockTypeSchema, LockRecordSchema, LockFileSchema, QueueEntrySchema, QueueFileSchema, ConcurrencyConfigSchema, getDefaultConcurrencyConfig,
24
+ // Agent management
25
+ AgentManager, createAgentManager, initializeGlobalAgent, getGlobalAgent, detectAgentType, getAgentId, getSessionId, getAgentName, createAgentInfo,
26
+ // Lock management
27
+ LockManager, createLockManager, withLock, tryWithLock,
28
+ // Queue management
29
+ QueueManager, createQueueManager, coordinatedExecution, withConcurrencyLimit,
30
+ // Git agent identification
31
+ GIT_TRAILERS, parseCommitTrailers, extractAgentInfo, getCommitAgentInfo, getRecentCommitsAgentInfo, formatCommitWithAgent, prepareCommitMsgHook, getHookSetupCommand, getAgentContributions, getAiCommitPercentage,
32
+ // Atomic operations
33
+ atomicWriteJson, atomicWriteText, readJsonSafe, readJsonWithRetry, acquireFileLock, tryAcquireFileLock, isLocked, forceReleaseLock, unlinkSafe, fileExists, getFileMtime, sleepWithJitter,
34
+ // High-level context
35
+ createConcurrencyContext, createSimpleLockContext, } from './concurrency/index.js';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Gate Types for @eddacraft/anvil-runtime
3
+ *
4
+ * Re-exports types from @eddacraft/anvil-contracts and provides runtime utility functions.
5
+ */
6
+ import type { CheckContext, NormaliseFilesOptions } from '@eddacraft/anvil-core';
7
+ export type { APSPlan, Change, ChangeType, Provenance, Validation, EvidenceEntry, Evidence, Approval, ExecutionResult, SchemaValidationResult, GateConfig, GateCheck, GateResult, GateResultDetails, GateRunResult, CheckContext, PlanData, WatchConfig, PolicyConfig, PolicyBundleConfig, PolicyVerificationConfig, SignatureAlgorithm, StackConfig, StackLayerConfig, StackValidationConfig, ArchitectureContextBase, NormaliseFilesOptions, } from '@eddacraft/anvil-core';
8
+ export { APSPlanSchema, APS_SCHEMA_VERSION, ChangeTypeSchema, ChangeSchema, ProvenanceSchema, ValidationSchema, EvidenceEntrySchema, EvidenceSchema, ApprovalSchema, ExecutionResultSchema, validatePlan, createPlan, generateJSONSchema, getWarningsFromResult, hasBlockingWarnings, } from '@eddacraft/anvil-core';
9
+ /**
10
+ * Normalise target files to absolute paths and filter non-existent files.
11
+ *
12
+ * This ensures consistent behaviour between plan-based and planless modes:
13
+ * - Converts workspace-relative paths to absolute paths
14
+ * - Filters out non-existent files (unless checkExists is false)
15
+ * - Applies optional filter function
16
+ *
17
+ * @param targetFiles - Array of file paths (relative or absolute)
18
+ * @param workspaceRoot - Workspace root directory
19
+ * @param options - Normalisation options
20
+ * @returns Array of absolute paths to existing files
21
+ */
22
+ export declare function normaliseTargetFiles(targetFiles: string[], workspaceRoot: string, options?: NormaliseFilesOptions): string[];
23
+ /**
24
+ * Get files from CheckContext, handling both plan-based and planless modes consistently.
25
+ *
26
+ * For planless mode (targetFiles provided):
27
+ * - Normalises paths to absolute
28
+ * - Filters non-existent files
29
+ * - Applies optional filter function
30
+ *
31
+ * For plan-based mode:
32
+ * - Extracts file paths from proposed_changes
33
+ * - Joins with workspace_root
34
+ * - Filters non-existent files (except for file_delete)
35
+ * - Applies optional filter function
36
+ *
37
+ * @param context - Check context
38
+ * @param options - Options including filter function
39
+ * @returns Array of absolute paths to files
40
+ */
41
+ export declare function getFilesFromContext(context: CheckContext, options?: NormaliseFilesOptions): string[];
42
+ //# sourceMappingURL=gate.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate.types.d.ts","sourceRoot":"","sources":["../../src/types/gate.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAGjF,YAAY,EACV,OAAO,EACP,MAAM,EACN,UAAU,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAM/B;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EAAE,EACrB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,qBAA0B,GAClC,MAAM,EAAE,CAsBV;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE,qBAA0B,GAClC,MAAM,EAAE,CAsCV"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Gate Types for @eddacraft/anvil-runtime
3
+ *
4
+ * Re-exports types from @eddacraft/anvil-contracts and provides runtime utility functions.
5
+ */
6
+ import { existsSync } from 'node:fs';
7
+ import { join, isAbsolute } from 'node:path';
8
+ export { APSPlanSchema, APS_SCHEMA_VERSION, ChangeTypeSchema, ChangeSchema, ProvenanceSchema, ValidationSchema, EvidenceEntrySchema, EvidenceSchema, ApprovalSchema, ExecutionResultSchema, validatePlan, createPlan, generateJSONSchema, getWarningsFromResult, hasBlockingWarnings, } from '@eddacraft/anvil-core';
9
+ // =============================================================================
10
+ // Path Normalisation Helpers (runtime-specific with fs operations)
11
+ // =============================================================================
12
+ /**
13
+ * Normalise target files to absolute paths and filter non-existent files.
14
+ *
15
+ * This ensures consistent behaviour between plan-based and planless modes:
16
+ * - Converts workspace-relative paths to absolute paths
17
+ * - Filters out non-existent files (unless checkExists is false)
18
+ * - Applies optional filter function
19
+ *
20
+ * @param targetFiles - Array of file paths (relative or absolute)
21
+ * @param workspaceRoot - Workspace root directory
22
+ * @param options - Normalisation options
23
+ * @returns Array of absolute paths to existing files
24
+ */
25
+ export function normaliseTargetFiles(targetFiles, workspaceRoot, options = {}) {
26
+ const { filter, checkExists = true } = options;
27
+ return targetFiles
28
+ .map((filePath) => {
29
+ // Convert to absolute path if relative
30
+ if (isAbsolute(filePath)) {
31
+ return filePath;
32
+ }
33
+ return join(workspaceRoot, filePath);
34
+ })
35
+ .filter((absolutePath) => {
36
+ // Check existence if required
37
+ if (checkExists && !existsSync(absolutePath)) {
38
+ return false;
39
+ }
40
+ // Apply custom filter if provided
41
+ if (filter && !filter(absolutePath)) {
42
+ return false;
43
+ }
44
+ return true;
45
+ });
46
+ }
47
+ /**
48
+ * Get files from CheckContext, handling both plan-based and planless modes consistently.
49
+ *
50
+ * For planless mode (targetFiles provided):
51
+ * - Normalises paths to absolute
52
+ * - Filters non-existent files
53
+ * - Applies optional filter function
54
+ *
55
+ * For plan-based mode:
56
+ * - Extracts file paths from proposed_changes
57
+ * - Joins with workspace_root
58
+ * - Filters non-existent files (except for file_delete)
59
+ * - Applies optional filter function
60
+ *
61
+ * @param context - Check context
62
+ * @param options - Options including filter function
63
+ * @returns Array of absolute paths to files
64
+ */
65
+ export function getFilesFromContext(context, options = {}) {
66
+ const { filter, checkExists = true } = options;
67
+ // Planless mode: use targetFiles
68
+ if (context.targetFiles && context.targetFiles.length > 0) {
69
+ return normaliseTargetFiles(context.targetFiles, context.workspace_root, options);
70
+ }
71
+ // Plan-based mode: extract from proposed_changes
72
+ const files = [];
73
+ if (context.plan) {
74
+ for (const change of context.plan.proposed_changes) {
75
+ const isFileChange = change.type === 'file_create' ||
76
+ change.type === 'file_update' ||
77
+ change.type === 'file_delete';
78
+ if (!isFileChange || !change.path) {
79
+ continue;
80
+ }
81
+ // Apply filter if provided
82
+ if (filter && !filter(change.path)) {
83
+ continue;
84
+ }
85
+ const fullPath = join(context.workspace_root, change.path);
86
+ // For file_delete, don't check existence
87
+ // For other changes, check existence if required
88
+ if (change.type === 'file_delete' || !checkExists || existsSync(fullPath)) {
89
+ files.push(fullPath);
90
+ }
91
+ }
92
+ }
93
+ return files;
94
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Change Debouncer
3
+ *
4
+ * Coalesces rapid file changes into batches to prevent
5
+ * excessive action triggers during editor auto-save or
6
+ * multi-file operations.
7
+ */
8
+ import type { DebouncedChanges } from './types.js';
9
+ /**
10
+ * Callback type for debounced flush
11
+ */
12
+ export type DebouncerFlushCallback = (changes: DebouncedChanges) => void;
13
+ /**
14
+ * Debouncer for file changes
15
+ *
16
+ * Accumulates file paths and flushes them as a batch
17
+ * after a configurable delay.
18
+ */
19
+ export declare class ChangeDebouncer {
20
+ private delayMs;
21
+ private onFlush;
22
+ private pendingFiles;
23
+ private timer;
24
+ /**
25
+ * Create a new debouncer
26
+ *
27
+ * @param delayMs - Debounce delay in milliseconds
28
+ * @param onFlush - Callback when changes are flushed
29
+ */
30
+ constructor(delayMs: number, onFlush: DebouncerFlushCallback);
31
+ /**
32
+ * Add a file to the pending changes
33
+ *
34
+ * Resets the debounce timer each time a file is added.
35
+ *
36
+ * @param filePath - Absolute file path
37
+ */
38
+ add(filePath: string): void;
39
+ /**
40
+ * Add multiple files to pending changes
41
+ *
42
+ * @param filePaths - Array of absolute file paths
43
+ */
44
+ addMany(filePaths: string[]): void;
45
+ /**
46
+ * Immediately flush pending changes
47
+ *
48
+ * Clears the timer and invokes the callback with all
49
+ * accumulated files.
50
+ */
51
+ flush(): void;
52
+ /**
53
+ * Cancel pending flush and clear accumulated files
54
+ */
55
+ cancel(): void;
56
+ /**
57
+ * Get count of pending files
58
+ */
59
+ get pendingCount(): number;
60
+ /**
61
+ * Check if there are pending changes
62
+ */
63
+ get hasPending(): boolean;
64
+ /**
65
+ * Get the current delay setting
66
+ */
67
+ get delay(): number;
68
+ /**
69
+ * Update the debounce delay
70
+ *
71
+ * Takes effect on next add() call.
72
+ */
73
+ setDelay(delayMs: number): void;
74
+ /**
75
+ * Reset the debounce timer
76
+ */
77
+ private resetTimer;
78
+ /**
79
+ * Clear the debounce timer
80
+ */
81
+ private clearTimer;
82
+ }
83
+ /**
84
+ * Create a change debouncer
85
+ *
86
+ * @param delayMs - Debounce delay in milliseconds (default: 300)
87
+ * @param onFlush - Callback when changes are flushed
88
+ */
89
+ export declare function createDebouncer(delayMs: number, onFlush: DebouncerFlushCallback): ChangeDebouncer;
90
+ //# sourceMappingURL=debouncer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debouncer.d.ts","sourceRoot":"","sources":["../../src/watch/debouncer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAKnD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAEzE;;;;;GAKG;AACH,qBAAa,eAAe;IAWxB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;IAXjB,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,KAAK,CAA8C;IAE3D;;;;;OAKG;gBAEO,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,sBAAsB;IAGzC;;;;;;OAMG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAM3B;;;;OAIG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAOlC;;;;;OAKG;IACH,KAAK,IAAI,IAAI;IAkBb;;OAEG;IACH,MAAM,IAAI,IAAI;IAMd;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,OAAO,CAAC,UAAU;IAOlB;;OAEG;IACH,OAAO,CAAC,UAAU;CAMnB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,eAAe,CAEjG"}