codehere 0.2.1 → 0.3.0-rc.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.
Files changed (235) hide show
  1. package/README.md +88 -68
  2. package/dist/domain/entities/task.js +4 -4
  3. package/dist/error-handler.js +4 -9
  4. package/dist/index.js +253 -1219
  5. package/dist/infrastructure/config/product-context.js +7 -6
  6. package/dist/infrastructure/hooks/claude-sdk-hook.js +335 -63
  7. package/dist/infrastructure/observability/execution-tracer.js +11 -6
  8. package/dist/infrastructure/orchestration/agent-adapter.js +13 -0
  9. package/dist/infrastructure/orchestration/agent-installer.js +101 -0
  10. package/dist/infrastructure/orchestration/agents-config-seed.js +56 -0
  11. package/dist/infrastructure/orchestration/aider-adapter.js +319 -0
  12. package/dist/infrastructure/orchestration/artifacts-extractor.js +175 -0
  13. package/dist/infrastructure/orchestration/claude-code-adapter.js +352 -0
  14. package/dist/infrastructure/orchestration/codex-adapter.js +310 -0
  15. package/dist/infrastructure/orchestration/generic-cli-adapter.js +553 -0
  16. package/dist/infrastructure/orchestration/opencode-adapter.js +275 -0
  17. package/dist/infrastructure/orchestration/progress-aggregator.js +189 -0
  18. package/dist/infrastructure/orchestration/readiness.js +106 -0
  19. package/dist/infrastructure/orchestration/session-manager.js +272 -0
  20. package/dist/infrastructure/orchestration/session-persistence.js +109 -0
  21. package/dist/infrastructure/protocols/mcp-helpers.js +10 -30
  22. package/dist/infrastructure/protocols/mcp-server-impl.js +359 -21
  23. package/dist/infrastructure/protocols/ui-page.js +1827 -0
  24. package/dist/infrastructure/security/file-collection.js +115 -0
  25. package/dist/infrastructure/security/trust-scorer.js +301 -56
  26. package/dist/infrastructure/storage/task-repository.js +8 -7
  27. package/dist/monitoring.js +10 -49
  28. package/dist/presentation/cli/commands/help-command.js +96 -139
  29. package/dist/presentation/cli/commands/hook-command.js +17 -24
  30. package/dist/presentation/cli/commands/report-command.js +59 -72
  31. package/dist/presentation/cli/commands/setup-command.js +4 -4
  32. package/dist/presentation/cli/commands/status-command.js +334 -43
  33. package/dist/presentation/cli/commands/trust-command.js +115 -99
  34. package/dist/presentation/cli/error-display.js +17 -21
  35. package/dist/ui.js +17 -12
  36. package/package.json +35 -67
  37. package/dist/agents/base.js +0 -101
  38. package/dist/agents/orchestrator-model-driven.js +0 -141
  39. package/dist/agents/react-orchestrator-agent.js +0 -54
  40. package/dist/application/agents/execution-agent.js +0 -508
  41. package/dist/application/agents/multi-agent-orchestrator.js +0 -295
  42. package/dist/application/agents/planning-agent.js +0 -433
  43. package/dist/application/agents/validation-agent.js +0 -317
  44. package/dist/application/architectures/plan-and-act.js +0 -242
  45. package/dist/application/index.js +0 -12
  46. package/dist/application/services/agent-factory.js +0 -28
  47. package/dist/application/services/dependency-container.js +0 -596
  48. package/dist/application/services/git-context-service.js +0 -83
  49. package/dist/application/services/intelligent-router.js +0 -934
  50. package/dist/application/services/tool-executor-service.js +0 -94
  51. package/dist/application/use-cases/ask-question-use-case.js +0 -338
  52. package/dist/application/use-cases/edit-file-use-case.js +0 -830
  53. package/dist/application/use-cases/explain-file-use-case.js +0 -50
  54. package/dist/application/use-cases/index-codebase-use-case.js +0 -113
  55. package/dist/application/use-cases/planning-use-case.js +0 -276
  56. package/dist/application/use-cases/react-orchestration-use-case.js +0 -329
  57. package/dist/application/use-cases/reflexion-use-case.js +0 -30
  58. package/dist/application/workflows/deterministic-workflows.js +0 -189
  59. package/dist/ast-parser.js +0 -331
  60. package/dist/cache.js +0 -180
  61. package/dist/chat.js +0 -251
  62. package/dist/code-analysis.js +0 -327
  63. package/dist/context.js +0 -187
  64. package/dist/docs.js +0 -146
  65. package/dist/domain/entities/code-chunk.js +0 -6
  66. package/dist/domain/entities/decision.js +0 -9
  67. package/dist/domain/entities/edit.js +0 -6
  68. package/dist/domain/entities/knowledge-node.js +0 -9
  69. package/dist/domain/entities/knowledge-preservation.js +0 -10
  70. package/dist/domain/entities/memory.js +0 -6
  71. package/dist/domain/entities/pattern.js +0 -7
  72. package/dist/domain/entities/plan.js +0 -6
  73. package/dist/domain/entities/query.js +0 -6
  74. package/dist/domain/errors/embeddings-not-found-error.js +0 -13
  75. package/dist/domain/index.js +0 -19
  76. package/dist/domain/interfaces/ai-service.interface.js +0 -6
  77. package/dist/domain/interfaces/code-analyzer.interface.js +0 -6
  78. package/dist/domain/interfaces/decision-repository.interface.js +0 -9
  79. package/dist/domain/interfaces/embedding-repository.interface.js +0 -6
  80. package/dist/domain/interfaces/knowledge-graph-repository.interface.js +0 -9
  81. package/dist/domain/interfaces/knowledge-preservation-repository.interface.js +0 -8
  82. package/dist/domain/interfaces/memory-repository.interface.js +0 -6
  83. package/dist/domain/interfaces/pattern-repository.interface.js +0 -6
  84. package/dist/domain/interfaces/verification-service.interface.js +0 -6
  85. package/dist/domain/services/cross-team-pattern-sharing.js +0 -125
  86. package/dist/domain/services/decision-recorder.js +0 -223
  87. package/dist/domain/services/decision-retriever.js +0 -133
  88. package/dist/domain/services/environment-mode-manager.js +0 -22
  89. package/dist/domain/services/graded-memory-activation.js +0 -69
  90. package/dist/domain/services/knowledge-access.js +0 -132
  91. package/dist/domain/services/knowledge-extractor.js +0 -247
  92. package/dist/domain/services/knowledge-graph-builder.js +0 -268
  93. package/dist/domain/services/knowledge-graph-query.js +0 -187
  94. package/dist/domain/services/memory-retriever.js +0 -82
  95. package/dist/domain/services/memory-synthesizer.js +0 -91
  96. package/dist/domain/services/pattern-extractor.js +0 -442
  97. package/dist/domain/services/query-intent-classifier.js +0 -140
  98. package/dist/domain/services/react-loop.js +0 -186
  99. package/dist/domain/services/risk-tier-detector.js +0 -78
  100. package/dist/edit.js +0 -319
  101. package/dist/embed.js +0 -459
  102. package/dist/formatter.js +0 -168
  103. package/dist/git.js +0 -198
  104. package/dist/infrastructure/ai/cohere-ai-service.js +0 -607
  105. package/dist/infrastructure/ai/command-r-evaluation.js +0 -206
  106. package/dist/infrastructure/ai/model-config.js +0 -84
  107. package/dist/infrastructure/ai/provider-ai-service.js +0 -477
  108. package/dist/infrastructure/cache/embedding-cache.js +0 -175
  109. package/dist/infrastructure/cache/query-result-cache.js +0 -66
  110. package/dist/infrastructure/cache/response-cache.js +0 -48
  111. package/dist/infrastructure/cache/security-scan-cache.js +0 -47
  112. package/dist/infrastructure/chunking/ast-code-chunker.js +0 -19
  113. package/dist/infrastructure/chunking/code-aware-chunker.js +0 -397
  114. package/dist/infrastructure/context/context-compressor.js +0 -329
  115. package/dist/infrastructure/context/conversation-context.js +0 -128
  116. package/dist/infrastructure/context/session-manager.js +0 -94
  117. package/dist/infrastructure/cost/cost-tracker.js +0 -360
  118. package/dist/infrastructure/file-scanner/file-scanner.js +0 -106
  119. package/dist/infrastructure/governance/nist-ai-rmf.js +0 -292
  120. package/dist/infrastructure/governance/policy-as-code.js +0 -258
  121. package/dist/infrastructure/governance/prompt-to-code-lineage.js +0 -239
  122. package/dist/infrastructure/index.js +0 -7
  123. package/dist/infrastructure/observability/prompt-versioner.js +0 -145
  124. package/dist/infrastructure/protocols/a2a-metadata.js +0 -137
  125. package/dist/infrastructure/protocols/a2a-protocol.js +0 -314
  126. package/dist/infrastructure/protocols/mcp-oauth.js +0 -184
  127. package/dist/infrastructure/protocols/mcp-server.js +0 -333
  128. package/dist/infrastructure/protocols/streaming-handler.js +0 -103
  129. package/dist/infrastructure/providers/cohere-provider.js +0 -444
  130. package/dist/infrastructure/providers/fake-provider.js +0 -130
  131. package/dist/infrastructure/providers/local-llm-provider.js +0 -330
  132. package/dist/infrastructure/providers/model-config.types.js +0 -9
  133. package/dist/infrastructure/providers/model-provider.interface.js +0 -8
  134. package/dist/infrastructure/providers/openai-provider.js +0 -413
  135. package/dist/infrastructure/providers/openrouter-provider.js +0 -399
  136. package/dist/infrastructure/providers/operation-provider-resolver.js +0 -105
  137. package/dist/infrastructure/providers/provider-config-loader.js +0 -120
  138. package/dist/infrastructure/providers/provider-registry.js +0 -88
  139. package/dist/infrastructure/safety/pattern-detector.js +0 -133
  140. package/dist/infrastructure/security/ai-sast-scanner.js +0 -290
  141. package/dist/infrastructure/security/docker-sandbox.js +0 -178
  142. package/dist/infrastructure/security/enhanced-security-gate.js +0 -151
  143. package/dist/infrastructure/security/license-scanner.js +0 -167
  144. package/dist/infrastructure/security/provider-bias-detector.js +0 -164
  145. package/dist/infrastructure/security/sandbox-executor.js +0 -64
  146. package/dist/infrastructure/serialization/toon-serializer.js +0 -119
  147. package/dist/infrastructure/storage/memory-stream-service.js +0 -204
  148. package/dist/infrastructure/storage/plan-repository.js +0 -96
  149. package/dist/infrastructure/storage/sqlite-decision-repository.js +0 -232
  150. package/dist/infrastructure/storage/sqlite-embedding-repository.js +0 -311
  151. package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js +0 -417
  152. package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js +0 -230
  153. package/dist/infrastructure/storage/sqlite-memory-repository.js +0 -229
  154. package/dist/infrastructure/storage/sqlite-pattern-repository.js +0 -249
  155. package/dist/infrastructure/storage/task-helpers.js +0 -197
  156. package/dist/infrastructure/telemetry/telemetry-service.js +0 -167
  157. package/dist/infrastructure/ux/appropriate-friction.js +0 -213
  158. package/dist/infrastructure/ux/bi-directional-learning.js +0 -337
  159. package/dist/infrastructure/ux/capability-boundaries.js +0 -42
  160. package/dist/infrastructure/ux/comprehensive-formatter.js +0 -117
  161. package/dist/infrastructure/ux/contextual-feature-discovery.js +0 -10
  162. package/dist/infrastructure/ux/expectation-management.js +0 -327
  163. package/dist/infrastructure/ux/feature-discovery.js +0 -14
  164. package/dist/infrastructure/ux/feedback-prompt.js +0 -45
  165. package/dist/infrastructure/ux/hitl-validation.js +0 -297
  166. package/dist/infrastructure/ux/progress-indicator.js +0 -116
  167. package/dist/infrastructure/ux/progressive-disclosure.js +0 -236
  168. package/dist/infrastructure/ux/review-checkpoint.js +0 -72
  169. package/dist/infrastructure/ux/staged-feature-intro.js +0 -24
  170. package/dist/infrastructure/ux/stream-markdown.js +0 -151
  171. package/dist/infrastructure/ux/syntax-highlighter.js +0 -91
  172. package/dist/infrastructure/ux/team-standards.js +0 -196
  173. package/dist/infrastructure/ux/transparency.js +0 -71
  174. package/dist/infrastructure/validation/agent-feedback.js +0 -55
  175. package/dist/infrastructure/validation/agent-validation-helper.js +0 -137
  176. package/dist/infrastructure/validation/review-handler.js +0 -40
  177. package/dist/infrastructure/validation/summary-aggregator.js +0 -70
  178. package/dist/infrastructure/validation/summary-extractor.js +0 -45
  179. package/dist/infrastructure/validation/trace-summary.js +0 -52
  180. package/dist/infrastructure/verification/verification-service.js +0 -47
  181. package/dist/infrastructure/xai/attention-visualizer.js +0 -172
  182. package/dist/infrastructure/xai/cot-visualizer.js +0 -283
  183. package/dist/infrastructure/xai/decision-tree-log.js +0 -212
  184. package/dist/infrastructure/xai/interactive-xai.js +0 -260
  185. package/dist/infrastructure/xai/uncertainty-quantifier.js +0 -198
  186. package/dist/intelligent-retrieval.js +0 -272
  187. package/dist/intent/classifier.js +0 -2
  188. package/dist/intent/context.js +0 -2
  189. package/dist/iterative-refinement.js +0 -189
  190. package/dist/learning.js +0 -232
  191. package/dist/log.js +0 -31
  192. package/dist/migrate.js +0 -133
  193. package/dist/parallel-processor.js +0 -530
  194. package/dist/planner.js +0 -198
  195. package/dist/policy.js +0 -26
  196. package/dist/presentation/cli/commands/ask-command.js +0 -314
  197. package/dist/presentation/cli/commands/cost-command.js +0 -191
  198. package/dist/presentation/cli/commands/decision-command.js +0 -207
  199. package/dist/presentation/cli/commands/docs-command.js +0 -25
  200. package/dist/presentation/cli/commands/fix-command.js +0 -53
  201. package/dist/presentation/cli/commands/knowledge-command.js +0 -129
  202. package/dist/presentation/cli/commands/learning-dashboard-command.js +0 -183
  203. package/dist/presentation/cli/commands/models-command.js +0 -194
  204. package/dist/presentation/cli/commands/orchestrate-command.js +0 -207
  205. package/dist/presentation/cli/commands/plan-command.js +0 -246
  206. package/dist/presentation/cli/commands/product-command.js +0 -199
  207. package/dist/presentation/cli/commands/react-command.js +0 -181
  208. package/dist/presentation/cli/commands/review-command.js +0 -154
  209. package/dist/presentation/cli/commands/run-command.js +0 -188
  210. package/dist/presentation/cli/commands/smart-command.js +0 -395
  211. package/dist/presentation/cli/commands/suggest-command.js +0 -138
  212. package/dist/presentation/cli/commands/trace-command.js +0 -129
  213. package/dist/presentation/cli/commands/undo-command.js +0 -150
  214. package/dist/query-optimizer.js +0 -205
  215. package/dist/refactor.js +0 -116
  216. package/dist/review.js +0 -206
  217. package/dist/search.js +0 -163
  218. package/dist/session.js +0 -652
  219. package/dist/task-verification.js +0 -336
  220. package/dist/testgen.js +0 -166
  221. package/dist/token-optimizer.js +0 -277
  222. package/dist/tools/bash.js +0 -213
  223. package/dist/tools/edit.js +0 -235
  224. package/dist/tools/executor.js +0 -153
  225. package/dist/tools/git-tool.js +0 -292
  226. package/dist/tools/parser.js +0 -158
  227. package/dist/tools/registry.js +0 -302
  228. package/dist/tools/search.js +0 -100
  229. package/dist/types.js +0 -2
  230. package/dist/utils/check-api-status.js +0 -100
  231. package/dist/utils/diff-parser.js +0 -162
  232. package/dist/verification/backup.js +0 -259
  233. package/dist/verification/compiler.js +0 -264
  234. package/dist/verification/index.js +0 -273
  235. package/dist/verification/test-runner.js +0 -379
@@ -1,327 +0,0 @@
1
- /**
2
- * Infrastructure: Expectation Management System
3
- *
4
- * Clearly communicates AI limitations to prevent user frustration
5
- * Research: Expectation management - clear limitations, "can make mistakes" warnings
6
- *
7
- * Features:
8
- * - Clear capability communication
9
- * - Limitation warnings
10
- * - Contextual disclaimers
11
- * - Error prevention messaging
12
- * - First-time AI operation disclaimers
13
- * - Uncertainty indicators
14
- */
15
- import { readFileSync, existsSync, writeFileSync, mkdirSync } from 'fs';
16
- import { join } from 'path';
17
- export class ExpectationManagement {
18
- messages = new Map();
19
- shownMessages = new Set(); // Track shown messages
20
- disclaimerShown = false;
21
- constructor() {
22
- this.initializeDefaultMessages();
23
- this.loadDisclaimerState();
24
- }
25
- /**
26
- * Assess capability for an operation
27
- */
28
- assessCapability(operation, context) {
29
- const { complexity = 'moderate', domain, uncertainty = 0.5, riskLevel = 'medium' } = context;
30
- let capability = 'moderate';
31
- let confidence = 0.7;
32
- const limitations = [];
33
- const warnings = [];
34
- // Adjust based on complexity
35
- if (complexity === 'simple') {
36
- capability = 'confident';
37
- confidence = 0.9;
38
- }
39
- else if (complexity === 'complex') {
40
- capability = 'uncertain';
41
- confidence = 0.5;
42
- limitations.push('Complex operations may require multiple iterations');
43
- }
44
- // Adjust based on uncertainty
45
- if (uncertainty > 0.7) {
46
- capability = 'risky';
47
- confidence = 0.3;
48
- warnings.push('High uncertainty detected - verify output carefully');
49
- warnings.push('This may indicate hallucination risk');
50
- }
51
- // Adjust based on risk level
52
- if (riskLevel === 'critical') {
53
- warnings.push('Critical operation - human review recommended');
54
- capability = 'risky';
55
- confidence = Math.min(confidence, 0.4);
56
- }
57
- else if (riskLevel === 'high') {
58
- warnings.push('High-risk operation - please review before applying');
59
- }
60
- // Domain-specific limitations
61
- if (domain === 'security') {
62
- limitations.push('Security-sensitive code requires careful review');
63
- warnings.push('Always verify security implications manually');
64
- }
65
- else if (domain === 'financial') {
66
- limitations.push('Financial code requires compliance verification');
67
- warnings.push('Ensure regulatory compliance before deployment');
68
- }
69
- const canProceed = capability !== 'risky' || riskLevel !== 'critical';
70
- return {
71
- operation,
72
- capability,
73
- confidence,
74
- limitations,
75
- warnings,
76
- canProceed,
77
- recommendedApproach: this.generateRecommendedApproach(capability, complexity, riskLevel),
78
- };
79
- }
80
- /**
81
- * Get expectation message for operation
82
- */
83
- getExpectationMessage(operation, context) {
84
- // Check for contextual messages first
85
- if (context) {
86
- for (const message of this.messages.values()) {
87
- if (message.contextual && this.matchesContext(message, context)) {
88
- return message;
89
- }
90
- }
91
- }
92
- // Check for operation-specific message
93
- const operationMessage = this.messages.get(operation);
94
- if (operationMessage) {
95
- if (operationMessage.showOnce && this.shownMessages.has(operation)) {
96
- return null; // Already shown
97
- }
98
- this.shownMessages.add(operation);
99
- return operationMessage;
100
- }
101
- return null;
102
- }
103
- /**
104
- * Register custom expectation message
105
- */
106
- registerMessage(message) {
107
- this.messages.set(message.operation, message);
108
- }
109
- /**
110
- * Format capability assessment for display
111
- */
112
- formatAssessment(assessment) {
113
- let output = '';
114
- // Capability level indicator
115
- const capabilityIcons = {
116
- confident: '✓',
117
- moderate: '◐',
118
- uncertain: '⚠',
119
- risky: '⚠⚠',
120
- };
121
- output += `${capabilityIcons[assessment.capability]} ${assessment.operation}\n`;
122
- output += `Confidence: ${(assessment.confidence * 100).toFixed(0)}%\n\n`;
123
- if (assessment.limitations.length > 0) {
124
- output += `Limitations:\n`;
125
- for (const limitation of assessment.limitations) {
126
- output += ` • ${limitation}\n`;
127
- }
128
- output += '\n';
129
- }
130
- if (assessment.warnings.length > 0) {
131
- output += `Warnings:\n`;
132
- for (const warning of assessment.warnings) {
133
- output += ` ⚠ ${warning}\n`;
134
- }
135
- output += '\n';
136
- }
137
- if (assessment.recommendedApproach) {
138
- output += `Recommended: ${assessment.recommendedApproach}\n`;
139
- }
140
- if (!assessment.canProceed) {
141
- output += `\n⚠️ This operation requires human review before proceeding.\n`;
142
- }
143
- return output;
144
- }
145
- // Private helpers
146
- initializeDefaultMessages() {
147
- // General disclaimer
148
- this.registerMessage({
149
- type: 'disclaimer',
150
- operation: 'general',
151
- message: 'AI-generated code may contain errors. Please review and test before deploying.',
152
- severity: 'info',
153
- showOnce: true,
154
- });
155
- // Security operations
156
- this.registerMessage({
157
- type: 'warning',
158
- operation: 'security-sensitive',
159
- message: 'Security-sensitive operations require careful manual review. The AI may not catch all vulnerabilities.',
160
- severity: 'warning',
161
- contextual: true,
162
- });
163
- // Critical operations
164
- this.registerMessage({
165
- type: 'warning',
166
- operation: 'critical',
167
- message: 'This is a high-risk operation. Human review is mandatory before proceeding.',
168
- severity: 'error',
169
- contextual: true,
170
- });
171
- }
172
- matchesContext(message, context) {
173
- // Simple context matching logic
174
- if (message.operation === 'security-sensitive' && context.domain === 'security') {
175
- return true;
176
- }
177
- if (message.operation === 'critical' && context.riskLevel === 'critical') {
178
- return true;
179
- }
180
- return false;
181
- }
182
- generateRecommendedApproach(capability, complexity, riskLevel) {
183
- if (capability === 'risky' || riskLevel === 'critical') {
184
- return 'Review generated code carefully, test thoroughly, and get human approval before deployment';
185
- }
186
- else if (capability === 'uncertain' || complexity === 'complex') {
187
- return 'Review the generated code and test incrementally';
188
- }
189
- else if (capability === 'moderate') {
190
- return 'Review the code before committing';
191
- }
192
- return undefined;
193
- }
194
- /**
195
- * Check if first-time AI operation disclaimer should be shown
196
- */
197
- shouldShowFirstTimeDisclaimer() {
198
- return !this.disclaimerShown;
199
- }
200
- /**
201
- * Get first-time AI operation disclaimer notice
202
- */
203
- getFirstTimeDisclaimer() {
204
- return `┌────────────────────────────────────────────────────┐
205
- │ ⚠️ AI Assistant Notice │
206
- │ │
207
- │ This AI can make mistakes. Please verify: │
208
- │ • Generated code correctness │
209
- │ • Security implications │
210
- │ • License compliance │
211
- │ • Output accuracy and completeness │
212
- │ │
213
- │ Capabilities: │
214
- │ • Can generate, explain, and modify code │
215
- │ • May not catch all edge cases │
216
- │ • May not be aware of latest APIs │
217
- │ • Processing patterns, not "thinking" │
218
- │ │
219
- │ Always review generated code before deploying. │
220
- └────────────────────────────────────────────────────┘`;
221
- }
222
- /**
223
- * Mark first-time disclaimer as shown
224
- */
225
- markDisclaimerShown() {
226
- this.disclaimerShown = true;
227
- this.saveDisclaimerState();
228
- }
229
- /**
230
- * Get uncertainty indicator message
231
- */
232
- getUncertaintyIndicator(confidence) {
233
- if (confidence < 0.65) {
234
- const percent = (confidence * 100).toFixed(0);
235
- return `┌────────────────────────────────────────────────────┐
236
- │ ⚠️ Uncertainty Detected │
237
- │ │
238
- │ I'm less confident about this answer (${percent}%). │
239
- │ Please verify the information carefully. │
240
- │ │
241
- │ This may indicate: │
242
- │ • Limited context for the query │
243
- │ • Ambiguous or complex requirements │
244
- │ • Potential hallucination risk │
245
- │ │
246
- │ Recommendation: Review output thoroughly. │
247
- └────────────────────────────────────────────────────┘`;
248
- }
249
- return null;
250
- }
251
- /**
252
- * Get capability boundaries notice
253
- */
254
- getCapabilityBoundaries() {
255
- return `Capability Boundaries:
256
-
257
- What I CAN do:
258
- ✓ Answer questions about your codebase
259
- ✓ Generate and modify code
260
- ✓ Explain code structure and logic
261
- ✓ Suggest improvements and refactorings
262
- ✓ Identify potential issues
263
-
264
- What I CANNOT do:
265
- ✗ Guarantee code correctness
266
- ✗ Always detect all security vulnerabilities
267
- ✗ Know your specific business requirements
268
- ✗ Replace thorough testing
269
- ✗ Ensure compliance with all regulations
270
-
271
- Important:
272
- • Always review generated code
273
- • Test thoroughly before deploying
274
- • Verify security and compliance requirements
275
- • Use as an assistant, not a replacement for expertise`;
276
- }
277
- /**
278
- * Format disclaimer for console display (honest tone, no anthropomorphization)
279
- */
280
- formatDisclaimerForConsole() {
281
- return `⚠️ AI Assistant Notice
282
-
283
- This AI assistant processes code patterns and generates suggestions based on training data.
284
- It can make mistakes and may not understand all context.
285
-
286
- Please verify:
287
- • Generated code correctness and logic
288
- • Security implications (vulnerabilities, data exposure)
289
- • License compliance (license conflicts, attribution)
290
- • Output accuracy (may miss edge cases or latest APIs)
291
-
292
- Remember: The AI is processing patterns, not "thinking" or "understanding"
293
- in the human sense. Always review and test before deploying.`;
294
- }
295
- // Private helpers for disclaimer state management
296
- loadDisclaimerState() {
297
- try {
298
- const configDir = join(process.cwd(), 'data');
299
- const disclaimerPath = join(configDir, 'ai-disclaimer.json');
300
- if (existsSync(disclaimerPath)) {
301
- const state = JSON.parse(readFileSync(disclaimerPath, 'utf-8'));
302
- this.disclaimerShown = state.shown || false;
303
- }
304
- }
305
- catch {
306
- // Ignore errors - will default to not shown
307
- }
308
- }
309
- saveDisclaimerState() {
310
- try {
311
- const configDir = join(process.cwd(), 'data');
312
- if (!existsSync(configDir)) {
313
- mkdirSync(configDir, { recursive: true });
314
- }
315
- const disclaimerPath = join(configDir, 'ai-disclaimer.json');
316
- const state = {
317
- shown: true,
318
- shownDate: new Date().toISOString(),
319
- };
320
- writeFileSync(disclaimerPath, JSON.stringify(state, null, 2));
321
- }
322
- catch {
323
- // Ignore errors - non-critical
324
- }
325
- }
326
- }
327
- //# sourceMappingURL=expectation-management.js.map
@@ -1,14 +0,0 @@
1
- /**
2
- * Feature Discovery (v0.5.0-alpha.0 - Stub)
3
- * TODO: Implement feature discovery system
4
- */
5
- export function trackCommand(command) {
6
- // Stub implementation
7
- }
8
- export function shouldShowFeatureDiscovery(command) {
9
- return null;
10
- }
11
- export function markFeatureDiscoveryShown(id) {
12
- // Stub implementation
13
- }
14
- //# sourceMappingURL=feature-discovery.js.map
@@ -1,45 +0,0 @@
1
- /**
2
- * Feedback Prompt
3
- * Collect and store user feedback for bidirectional learning
4
- *
5
- * Phase 1: v0.5.0-alpha.0
6
- */
7
- /**
8
- * Prompt user for feedback (non-blocking, returns null if user skips)
9
- */
10
- export async function promptForFeedback(operation, context) {
11
- // In alpha, we skip interactive prompts to avoid blocking
12
- // This can be enhanced later with readline-based prompts
13
- return null;
14
- }
15
- /**
16
- * Store feedback in the learning system
17
- */
18
- export function storeFeedback(learningSystem, userId, feedback, metadata) {
19
- if (!learningSystem || !feedback) {
20
- return;
21
- }
22
- try {
23
- // Store feedback if learning system supports it
24
- if (typeof learningSystem.storeFeedback === 'function') {
25
- learningSystem.storeFeedback({
26
- userId,
27
- feedback,
28
- metadata,
29
- timestamp: new Date().toISOString(),
30
- });
31
- }
32
- }
33
- catch (error) {
34
- // Silent failure - feedback collection should not break the workflow
35
- console.error('Failed to store feedback:', error);
36
- }
37
- }
38
- /**
39
- * Display feedback confirmation message
40
- */
41
- export function displayFeedbackConfirmation(feedback) {
42
- // In alpha, skip confirmation display to keep CLI clean
43
- // This can be enhanced later
44
- }
45
- //# sourceMappingURL=feedback-prompt.js.map
@@ -1,297 +0,0 @@
1
- /**
2
- * Infrastructure: Human-in-the-Loop (HITL) Validation System
3
- *
4
- * Architecturally embedded human intervention points for supervision and decision-making
5
- * Research: Human-in-the-Loop (HITL) validation mandatory, prevents automation bias
6
- *
7
- * Features:
8
- * - Mandatory validation checkpoints
9
- * - Centralized review hub
10
- * - Review queue management
11
- * - Approval workflow
12
- */
13
- /**
14
- * Human-in-the-Loop Validation System
15
- * Manages mandatory validation checkpoints for critical operations
16
- * Task 4.2: Adaptive HITL - Supports mandatory vs optional checkpoints based on risk
17
- */
18
- export class HITLValidation {
19
- checkpoints = new Map();
20
- reviewQueue = []; // Checkpoint IDs in review order
21
- config;
22
- constructor(config) {
23
- this.config = config || {
24
- strictness: 'balanced',
25
- allowAutoProceed: true,
26
- mandatoryRiskLevels: ['critical', 'high'],
27
- };
28
- }
29
- /**
30
- * Set HITL configuration (user preferences)
31
- */
32
- setConfiguration(config) {
33
- this.config = config;
34
- }
35
- /**
36
- * Get current HITL configuration
37
- */
38
- getConfiguration() {
39
- return { ...this.config };
40
- }
41
- /**
42
- * Create review checkpoint
43
- * Task 4.2: Determines if checkpoint is mandatory or optional based on risk and user preferences
44
- */
45
- createCheckpoint(operation, changes, context, metadata) {
46
- const checkpointId = `checkpoint-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
47
- // Determine priority based on risk level
48
- const priority = context.riskLevel === 'critical' ? 'critical' :
49
- context.riskLevel === 'high' ? 'high' :
50
- context.riskLevel === 'medium' ? 'normal' :
51
- 'low';
52
- // Task 4.2: Determine if checkpoint is mandatory or optional
53
- const isMandatory = this.isMandatoryCheckpoint(context);
54
- const checkpoint = {
55
- checkpointId,
56
- operation,
57
- description: this.generateDescription(operation, changes, context),
58
- priority,
59
- status: 'pending',
60
- createdAt: Date.now(),
61
- isMandatory,
62
- changes,
63
- context,
64
- metadata: metadata || {},
65
- };
66
- this.checkpoints.set(checkpointId, checkpoint);
67
- this.addToReviewQueue(checkpointId, priority);
68
- return checkpoint;
69
- }
70
- /**
71
- * Task 4.2: Determine if checkpoint requires mandatory approval
72
- * Low-risk operations can be optional (auto-proceed if user preference allows)
73
- * High-risk operations are always mandatory
74
- */
75
- isMandatoryCheckpoint(context) {
76
- const { riskLevel, isDestructive = false, modifiesSecuritySensitiveCode = false, affectsMultipleFiles = false, uncertainty = 0.5, } = context;
77
- // Always mandatory for critical operations
78
- if (riskLevel === 'critical') {
79
- return true;
80
- }
81
- // Always mandatory for destructive operations
82
- if (isDestructive) {
83
- return true;
84
- }
85
- // Always mandatory for security-sensitive modifications
86
- if (modifiesSecuritySensitiveCode) {
87
- return true;
88
- }
89
- // Check user-configured mandatory risk levels
90
- if (this.config.mandatoryRiskLevels?.includes(riskLevel)) {
91
- return true;
92
- }
93
- // Apply strictness-based rules
94
- // Note: 'critical' is already handled above, so riskLevel here is 'low' | 'medium' | 'high'
95
- const strictness = this.config.strictness;
96
- if (strictness === 'strict') {
97
- // Strict: All medium+ risk operations are mandatory
98
- return riskLevel !== 'low';
99
- }
100
- else if (strictness === 'balanced') {
101
- // Balanced: High+ risk operations are mandatory, medium is optional
102
- return riskLevel === 'high' || (affectsMultipleFiles && riskLevel === 'medium') || uncertainty > 0.8;
103
- }
104
- else if (strictness === 'minimal') {
105
- // Minimal: Only high-risk operations are mandatory (critical already handled above)
106
- return riskLevel === 'high' || (isDestructive && riskLevel === 'medium');
107
- }
108
- else {
109
- // Default: High+ risk operations are mandatory
110
- return riskLevel === 'high';
111
- }
112
- }
113
- /**
114
- * Task 4.2: Check if checkpoint can auto-proceed (optional checkpoint with user preference)
115
- */
116
- canAutoProceed(checkpoint) {
117
- // Never auto-proceed mandatory checkpoints
118
- if (checkpoint.isMandatory) {
119
- return false;
120
- }
121
- // Check if user allows auto-proceed
122
- if (!this.config.allowAutoProceed) {
123
- return false;
124
- }
125
- // Optional checkpoints can auto-proceed if:
126
- // 1. Not mandatory
127
- // 2. User preference allows auto-proceed
128
- // 3. Risk level is low or medium (not high/critical)
129
- return checkpoint.context.riskLevel === 'low' || checkpoint.context.riskLevel === 'medium';
130
- }
131
- /**
132
- * Check if operation requires HITL validation
133
- */
134
- requiresValidation(context) {
135
- const { riskLevel, isDestructive = false, modifiesSecuritySensitiveCode = false, affectsMultipleFiles = false, uncertainty = 0.5, } = context;
136
- // Always require validation for critical operations
137
- if (riskLevel === 'critical') {
138
- return true;
139
- }
140
- // Require validation for destructive operations
141
- if (isDestructive) {
142
- return true;
143
- }
144
- // Require validation for security-sensitive modifications
145
- if (modifiesSecuritySensitiveCode) {
146
- return true;
147
- }
148
- // Require validation for high-risk multi-file operations
149
- if (affectsMultipleFiles && riskLevel === 'high') {
150
- return true;
151
- }
152
- // Require validation if uncertainty is very high
153
- if (uncertainty > 0.8) {
154
- return true;
155
- }
156
- // Require validation for high-risk operations
157
- if (riskLevel === 'high') {
158
- return true;
159
- }
160
- return false;
161
- }
162
- /**
163
- * Get next checkpoint in review queue
164
- */
165
- getNextCheckpoint() {
166
- if (this.reviewQueue.length === 0) {
167
- return null;
168
- }
169
- const checkpointId = this.reviewQueue[0];
170
- return this.checkpoints.get(checkpointId) || null;
171
- }
172
- /**
173
- * Submit review decision
174
- */
175
- submitDecision(decision) {
176
- const checkpoint = this.checkpoints.get(decision.checkpointId);
177
- if (!checkpoint) {
178
- throw new Error(`Checkpoint ${decision.checkpointId} not found`);
179
- }
180
- checkpoint.status =
181
- decision.decision === 'approve' ? 'approved' :
182
- decision.decision === 'reject' ? 'rejected' :
183
- 'needs_changes';
184
- checkpoint.reviewedAt = decision.timestamp;
185
- checkpoint.reviewedBy = decision.reviewer;
186
- // Remove from review queue
187
- const index = this.reviewQueue.indexOf(decision.checkpointId);
188
- if (index !== -1) {
189
- this.reviewQueue.splice(index, 1);
190
- }
191
- }
192
- /**
193
- * Get checkpoint by ID
194
- */
195
- getCheckpoint(checkpointId) {
196
- return this.checkpoints.get(checkpointId) || null;
197
- }
198
- /**
199
- * Get all pending checkpoints
200
- */
201
- getPendingCheckpoints(priority) {
202
- const pending = [];
203
- for (const checkpointId of this.reviewQueue) {
204
- const checkpoint = this.checkpoints.get(checkpointId);
205
- if (checkpoint && checkpoint.status === 'pending') {
206
- if (!priority || checkpoint.priority === priority) {
207
- pending.push(checkpoint);
208
- }
209
- }
210
- }
211
- return pending;
212
- }
213
- /**
214
- * Get review queue status
215
- */
216
- getReviewQueueStatus() {
217
- const byPriority = {
218
- low: 0,
219
- normal: 0,
220
- high: 0,
221
- critical: 0,
222
- };
223
- let pending = 0;
224
- for (const checkpointId of this.reviewQueue) {
225
- const checkpoint = this.checkpoints.get(checkpointId);
226
- if (checkpoint && checkpoint.status === 'pending') {
227
- pending++;
228
- byPriority[checkpoint.priority]++;
229
- }
230
- }
231
- return {
232
- total: this.checkpoints.size,
233
- pending,
234
- byPriority,
235
- };
236
- }
237
- /**
238
- * Format checkpoint for review
239
- */
240
- formatCheckpoint(checkpoint) {
241
- let output = '';
242
- output += `\n${'═'.repeat(80)}\n`;
243
- output += `Review Checkpoint: ${checkpoint.checkpointId}\n`;
244
- output += `${'═'.repeat(80)}\n\n`;
245
- output += `Operation: ${checkpoint.operation}\n`;
246
- output += `Priority: ${checkpoint.priority.toUpperCase()}\n`;
247
- output += `Status: ${checkpoint.status}\n`;
248
- output += `Created: ${new Date(checkpoint.createdAt).toISOString()}\n\n`;
249
- output += `Description:\n${checkpoint.description}\n\n`;
250
- output += `Changes (${checkpoint.changes.length}):\n`;
251
- for (const change of checkpoint.changes) {
252
- output += ` • ${change.type}: ${change.summary}\n`;
253
- if (change.filepath) {
254
- output += ` File: ${change.filepath}\n`;
255
- }
256
- }
257
- output += '\n';
258
- output += `Context:\n`;
259
- output += ` Query: ${checkpoint.context.query}\n`;
260
- output += ` Risk Level: ${checkpoint.context.riskLevel}\n`;
261
- if (checkpoint.context.uncertainty) {
262
- output += ` Uncertainty: ${(checkpoint.context.uncertainty * 100).toFixed(1)}%\n`;
263
- }
264
- if (checkpoint.context.securityFindings && checkpoint.context.securityFindings.length > 0) {
265
- output += ` ⚠️ Security Findings: ${checkpoint.context.securityFindings.length}\n`;
266
- }
267
- if (checkpoint.context.licenseFindings && checkpoint.context.licenseFindings.length > 0) {
268
- output += ` ⚠️ License Findings: ${checkpoint.context.licenseFindings.length}\n`;
269
- }
270
- output += `\n${'═'.repeat(80)}\n`;
271
- return output;
272
- }
273
- // Private helpers
274
- addToReviewQueue(checkpointId, priority) {
275
- // Insert based on priority (critical first)
276
- const priorityOrder = ['critical', 'high', 'normal', 'low'];
277
- const priorityIndex = priorityOrder.indexOf(priority);
278
- let insertIndex = 0;
279
- for (let i = 0; i < this.reviewQueue.length; i++) {
280
- const existingCheckpoint = this.checkpoints.get(this.reviewQueue[i]);
281
- if (existingCheckpoint) {
282
- const existingPriorityIndex = priorityOrder.indexOf(existingCheckpoint.priority);
283
- if (priorityIndex <= existingPriorityIndex) {
284
- insertIndex = i;
285
- break;
286
- }
287
- }
288
- insertIndex = i + 1;
289
- }
290
- this.reviewQueue.splice(insertIndex, 0, checkpointId);
291
- }
292
- generateDescription(operation, changes, context) {
293
- const changeSummary = changes.map(c => `${c.type} ${c.filepath || ''}`).join(', ');
294
- return `${operation}: ${changeSummary}. Risk level: ${context.riskLevel}.`;
295
- }
296
- }
297
- //# sourceMappingURL=hitl-validation.js.map