micode 0.8.5 → 0.9.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 (43) hide show
  1. package/INSTALL_CLAUDE.md +53 -4
  2. package/LICENSE +21 -0
  3. package/README.md +66 -0
  4. package/dist/index.js +11141 -1891
  5. package/package.json +3 -2
  6. package/src/agents/brainstormer.ts +1 -1
  7. package/src/agents/commander.ts +18 -2
  8. package/src/agents/executor.ts +116 -76
  9. package/src/agents/implementer.ts +63 -39
  10. package/src/agents/index.ts +27 -2
  11. package/src/agents/mindmodel/anti-pattern-detector.ts +95 -0
  12. package/src/agents/mindmodel/code-clusterer.ts +108 -0
  13. package/src/agents/mindmodel/constraint-reviewer.ts +84 -0
  14. package/src/agents/mindmodel/constraint-writer.ts +136 -0
  15. package/src/agents/mindmodel/convention-extractor.ts +102 -0
  16. package/src/agents/mindmodel/dependency-mapper.ts +85 -0
  17. package/src/agents/mindmodel/domain-extractor.ts +77 -0
  18. package/src/agents/mindmodel/example-extractor.ts +87 -0
  19. package/src/agents/mindmodel/index.ts +11 -0
  20. package/src/agents/mindmodel/orchestrator.ts +103 -0
  21. package/src/agents/mindmodel/pattern-discoverer.ts +77 -0
  22. package/src/agents/mindmodel/stack-detector.ts +62 -0
  23. package/src/agents/planner.ts +108 -64
  24. package/src/agents/reviewer.ts +45 -29
  25. package/src/config-loader.ts +158 -39
  26. package/src/hooks/auto-compact.ts +34 -5
  27. package/src/hooks/constraint-reviewer.ts +177 -0
  28. package/src/hooks/context-injector.ts +4 -2
  29. package/src/hooks/context-window-monitor.ts +10 -2
  30. package/src/hooks/fragment-injector.ts +181 -0
  31. package/src/hooks/mindmodel-injector.ts +170 -0
  32. package/src/index.ts +131 -8
  33. package/src/mindmodel/classifier.ts +36 -0
  34. package/src/mindmodel/formatter.ts +18 -0
  35. package/src/mindmodel/index.ts +18 -0
  36. package/src/mindmodel/loader.ts +66 -0
  37. package/src/mindmodel/review.ts +68 -0
  38. package/src/mindmodel/types.ts +87 -0
  39. package/src/tools/batch-read.ts +75 -0
  40. package/src/tools/mindmodel-lookup.ts +87 -0
  41. package/src/tools/spawn-agent.ts +134 -59
  42. package/src/utils/config.ts +23 -3
  43. package/src/utils/model-limits.ts +20 -4
@@ -1,6 +1,7 @@
1
1
  // Shared model context limits (tokens)
2
- // Used by context-window-monitor and auto-clear-ledger hooks
2
+ // Used by context-window-monitor and auto-compact hooks
3
3
 
4
+ // Fallback patterns for models not in opencode.json
4
5
  export const MODEL_CONTEXT_LIMITS: Record<string, number> = {
5
6
  // Claude models
6
7
  "claude-opus": 200_000,
@@ -22,15 +23,30 @@ export const MODEL_CONTEXT_LIMITS: Record<string, number> = {
22
23
  export const DEFAULT_CONTEXT_LIMIT = 200_000;
23
24
 
24
25
  /**
25
- * Get the context window limit for a given model ID.
26
- * Matches against known patterns and falls back to default.
26
+ * Get the context window limit for a given model.
27
+ * Priority: loaded limits (exact match) > pattern match > default
28
+ *
29
+ * @param modelID - The model ID (e.g., "gpt-4o", "claude-opus")
30
+ * @param providerID - Optional provider ID (e.g., "openai", "anthropic")
31
+ * @param loadedLimits - Optional map of "provider/model" -> limit from opencode.json
27
32
  */
28
- export function getContextLimit(modelID: string): number {
33
+ export function getContextLimit(modelID: string, providerID?: string, loadedLimits?: Map<string, number>): number {
34
+ // Check loaded limits first (exact match with provider/model)
35
+ if (loadedLimits && providerID) {
36
+ const exactKey = `${providerID}/${modelID}`;
37
+ const exactLimit = loadedLimits.get(exactKey);
38
+ if (exactLimit !== undefined) {
39
+ return exactLimit;
40
+ }
41
+ }
42
+
43
+ // Fall back to pattern matching on model ID
29
44
  const modelLower = modelID.toLowerCase();
30
45
  for (const [pattern, limit] of Object.entries(MODEL_CONTEXT_LIMITS)) {
31
46
  if (modelLower.includes(pattern)) {
32
47
  return limit;
33
48
  }
34
49
  }
50
+
35
51
  return DEFAULT_CONTEXT_LIMIT;
36
52
  }