micode 0.7.0 → 0.7.2

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 (92) hide show
  1. package/package.json +7 -13
  2. package/src/agents/artifact-searcher.ts +46 -0
  3. package/src/agents/brainstormer.ts +145 -0
  4. package/src/agents/codebase-analyzer.ts +75 -0
  5. package/src/agents/codebase-locator.ts +71 -0
  6. package/src/agents/commander.ts +138 -0
  7. package/src/agents/executor.ts +215 -0
  8. package/src/agents/implementer.ts +99 -0
  9. package/src/agents/index.ts +44 -0
  10. package/src/agents/ledger-creator.ts +113 -0
  11. package/src/agents/pattern-finder.ts +70 -0
  12. package/src/agents/planner.ts +230 -0
  13. package/src/agents/project-initializer.ts +264 -0
  14. package/src/agents/reviewer.ts +102 -0
  15. package/src/config-loader.ts +89 -0
  16. package/src/hooks/artifact-auto-index.ts +111 -0
  17. package/src/hooks/auto-clear-ledger.ts +230 -0
  18. package/src/hooks/auto-compact.ts +241 -0
  19. package/src/hooks/comment-checker.ts +120 -0
  20. package/src/hooks/context-injector.ts +163 -0
  21. package/src/hooks/context-window-monitor.ts +106 -0
  22. package/src/hooks/file-ops-tracker.ts +96 -0
  23. package/src/hooks/ledger-loader.ts +78 -0
  24. package/src/hooks/preemptive-compaction.ts +183 -0
  25. package/src/hooks/session-recovery.ts +258 -0
  26. package/src/hooks/token-aware-truncation.ts +189 -0
  27. package/src/index.ts +258 -0
  28. package/src/tools/artifact-index/index.ts +269 -0
  29. package/src/tools/artifact-index/schema.sql +44 -0
  30. package/src/tools/artifact-search.ts +49 -0
  31. package/src/tools/ast-grep/index.ts +189 -0
  32. package/src/tools/background-task/manager.ts +397 -0
  33. package/src/tools/background-task/tools.ts +145 -0
  34. package/src/tools/background-task/types.ts +68 -0
  35. package/src/tools/btca/index.ts +82 -0
  36. package/src/tools/look-at.ts +210 -0
  37. package/src/tools/pty/buffer.ts +49 -0
  38. package/src/tools/pty/index.ts +34 -0
  39. package/src/tools/pty/manager.ts +159 -0
  40. package/src/tools/pty/tools/kill.ts +68 -0
  41. package/src/tools/pty/tools/list.ts +55 -0
  42. package/src/tools/pty/tools/read.ts +152 -0
  43. package/src/tools/pty/tools/spawn.ts +78 -0
  44. package/src/tools/pty/tools/write.ts +97 -0
  45. package/src/tools/pty/types.ts +62 -0
  46. package/src/utils/model-limits.ts +36 -0
  47. package/dist/agents/artifact-searcher.d.ts +0 -2
  48. package/dist/agents/brainstormer.d.ts +0 -2
  49. package/dist/agents/codebase-analyzer.d.ts +0 -2
  50. package/dist/agents/codebase-locator.d.ts +0 -2
  51. package/dist/agents/commander.d.ts +0 -3
  52. package/dist/agents/executor.d.ts +0 -2
  53. package/dist/agents/implementer.d.ts +0 -2
  54. package/dist/agents/index.d.ts +0 -15
  55. package/dist/agents/ledger-creator.d.ts +0 -2
  56. package/dist/agents/pattern-finder.d.ts +0 -2
  57. package/dist/agents/planner.d.ts +0 -2
  58. package/dist/agents/project-initializer.d.ts +0 -2
  59. package/dist/agents/reviewer.d.ts +0 -2
  60. package/dist/config-loader.d.ts +0 -20
  61. package/dist/hooks/artifact-auto-index.d.ts +0 -19
  62. package/dist/hooks/auto-clear-ledger.d.ts +0 -11
  63. package/dist/hooks/auto-compact.d.ts +0 -9
  64. package/dist/hooks/comment-checker.d.ts +0 -9
  65. package/dist/hooks/context-injector.d.ts +0 -15
  66. package/dist/hooks/context-window-monitor.d.ts +0 -15
  67. package/dist/hooks/file-ops-tracker.d.ts +0 -26
  68. package/dist/hooks/ledger-loader.d.ts +0 -16
  69. package/dist/hooks/preemptive-compaction.d.ts +0 -9
  70. package/dist/hooks/session-recovery.d.ts +0 -9
  71. package/dist/hooks/token-aware-truncation.d.ts +0 -15
  72. package/dist/index.d.ts +0 -3
  73. package/dist/index.js +0 -17089
  74. package/dist/tools/artifact-index/index.d.ts +0 -38
  75. package/dist/tools/artifact-search.d.ts +0 -17
  76. package/dist/tools/ast-grep/index.d.ts +0 -88
  77. package/dist/tools/background-task/manager.d.ts +0 -27
  78. package/dist/tools/background-task/tools.d.ts +0 -41
  79. package/dist/tools/background-task/types.d.ts +0 -53
  80. package/dist/tools/btca/index.d.ts +0 -19
  81. package/dist/tools/look-at.d.ts +0 -11
  82. package/dist/tools/pty/buffer.d.ts +0 -11
  83. package/dist/tools/pty/index.d.ts +0 -74
  84. package/dist/tools/pty/manager.d.ts +0 -14
  85. package/dist/tools/pty/tools/kill.d.ts +0 -12
  86. package/dist/tools/pty/tools/list.d.ts +0 -6
  87. package/dist/tools/pty/tools/read.d.ts +0 -18
  88. package/dist/tools/pty/tools/spawn.d.ts +0 -20
  89. package/dist/tools/pty/tools/write.d.ts +0 -12
  90. package/dist/tools/pty/types.d.ts +0 -54
  91. package/dist/utils/model-limits.d.ts +0 -7
  92. /package/{dist/tools/background-task/index.d.ts → src/tools/background-task/index.ts} +0 -0
@@ -0,0 +1,36 @@
1
+ // Shared model context limits (tokens)
2
+ // Used by context-window-monitor and auto-clear-ledger hooks
3
+
4
+ export const MODEL_CONTEXT_LIMITS: Record<string, number> = {
5
+ // Claude models
6
+ "claude-opus": 200_000,
7
+ "claude-sonnet": 200_000,
8
+ "claude-haiku": 200_000,
9
+ "claude-3": 200_000,
10
+ "claude-4": 200_000,
11
+ // OpenAI models
12
+ "gpt-4o": 128_000,
13
+ "gpt-4-turbo": 128_000,
14
+ "gpt-4": 128_000,
15
+ "gpt-5": 200_000,
16
+ o1: 200_000,
17
+ o3: 200_000,
18
+ // Google models
19
+ gemini: 1_000_000,
20
+ };
21
+
22
+ export const DEFAULT_CONTEXT_LIMIT = 200_000;
23
+
24
+ /**
25
+ * Get the context window limit for a given model ID.
26
+ * Matches against known patterns and falls back to default.
27
+ */
28
+ export function getContextLimit(modelID: string): number {
29
+ const modelLower = modelID.toLowerCase();
30
+ for (const [pattern, limit] of Object.entries(MODEL_CONTEXT_LIMITS)) {
31
+ if (modelLower.includes(pattern)) {
32
+ return limit;
33
+ }
34
+ }
35
+ return DEFAULT_CONTEXT_LIMIT;
36
+ }
@@ -1,2 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const artifactSearcherAgent: AgentConfig;
@@ -1,2 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const brainstormerAgent: AgentConfig;
@@ -1,2 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const codebaseAnalyzerAgent: AgentConfig;
@@ -1,2 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const codebaseLocatorAgent: AgentConfig;
@@ -1,3 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const primaryAgent: AgentConfig;
3
- export declare const PRIMARY_AGENT_NAME: string;
@@ -1,2 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const executorAgent: AgentConfig;
@@ -1,2 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const implementerAgent: AgentConfig;
@@ -1,15 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- import { brainstormerAgent } from "./brainstormer";
3
- import { codebaseLocatorAgent } from "./codebase-locator";
4
- import { codebaseAnalyzerAgent } from "./codebase-analyzer";
5
- import { patternFinderAgent } from "./pattern-finder";
6
- import { plannerAgent } from "./planner";
7
- import { implementerAgent } from "./implementer";
8
- import { reviewerAgent } from "./reviewer";
9
- import { executorAgent } from "./executor";
10
- import { primaryAgent, PRIMARY_AGENT_NAME } from "./commander";
11
- import { projectInitializerAgent } from "./project-initializer";
12
- import { ledgerCreatorAgent } from "./ledger-creator";
13
- import { artifactSearcherAgent } from "./artifact-searcher";
14
- export declare const agents: Record<string, AgentConfig>;
15
- export { primaryAgent, PRIMARY_AGENT_NAME, brainstormerAgent, codebaseLocatorAgent, codebaseAnalyzerAgent, patternFinderAgent, plannerAgent, implementerAgent, reviewerAgent, executorAgent, projectInitializerAgent, ledgerCreatorAgent, artifactSearcherAgent, };
@@ -1,2 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const ledgerCreatorAgent: AgentConfig;
@@ -1,2 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const patternFinderAgent: AgentConfig;
@@ -1,2 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const plannerAgent: AgentConfig;
@@ -1,2 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const projectInitializerAgent: AgentConfig;
@@ -1,2 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export declare const reviewerAgent: AgentConfig;
@@ -1,20 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- export interface AgentOverride {
3
- model?: string;
4
- temperature?: number;
5
- maxTokens?: number;
6
- }
7
- export interface MicodeConfig {
8
- agents?: Record<string, AgentOverride>;
9
- }
10
- /**
11
- * Load micode.json from ~/.config/opencode/micode.json
12
- * Returns null if file doesn't exist or is invalid JSON
13
- * @param configDir - Optional override for config directory (for testing)
14
- */
15
- export declare function loadMicodeConfig(configDir?: string): Promise<MicodeConfig | null>;
16
- /**
17
- * Merge user config overrides into plugin agent configs
18
- * User overrides take precedence for safe properties only
19
- */
20
- export declare function mergeAgentConfigs(pluginAgents: Record<string, AgentConfig>, userConfig: MicodeConfig | null): Record<string, AgentConfig>;
@@ -1,19 +0,0 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
- export declare function parseLedger(content: string, filePath: string, sessionName: string): {
3
- id: string;
4
- sessionName: string;
5
- filePath: string;
6
- goal: string;
7
- stateNow: string;
8
- keyDecisions: string;
9
- filesRead: string;
10
- filesModified: string;
11
- };
12
- export declare function createArtifactAutoIndexHook(_ctx: PluginInput): {
13
- "tool.execute.after": (input: {
14
- tool: string;
15
- args?: Record<string, unknown>;
16
- }, _output: {
17
- output?: string;
18
- }) => Promise<void>;
19
- };
@@ -1,11 +0,0 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
- export declare const DEFAULT_THRESHOLD = 0.6;
3
- export declare const CLEAR_COOLDOWN_MS = 60000;
4
- export declare function createAutoClearLedgerHook(ctx: PluginInput): {
5
- event: ({ event }: {
6
- event: {
7
- type: string;
8
- properties?: unknown;
9
- };
10
- }) => Promise<void>;
11
- };
@@ -1,9 +0,0 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
- export declare function createAutoCompactHook(ctx: PluginInput): {
3
- event: ({ event }: {
4
- event: {
5
- type: string;
6
- properties?: unknown;
7
- };
8
- }) => Promise<void>;
9
- };
@@ -1,9 +0,0 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
- export declare function createCommentCheckerHook(_ctx: PluginInput): {
3
- "tool.execute.after": (input: {
4
- tool: string;
5
- args?: Record<string, unknown>;
6
- }, output: {
7
- output?: string;
8
- }) => Promise<void>;
9
- };
@@ -1,15 +0,0 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
- export declare function createContextInjectorHook(ctx: PluginInput): {
3
- "chat.params": (_input: {
4
- sessionID: string;
5
- }, output: {
6
- options?: Record<string, unknown>;
7
- system?: string;
8
- }) => Promise<void>;
9
- "tool.execute.after": (input: {
10
- tool: string;
11
- args?: Record<string, unknown>;
12
- }, output: {
13
- output?: string;
14
- }) => Promise<void>;
15
- };
@@ -1,15 +0,0 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
- export declare function createContextWindowMonitorHook(ctx: PluginInput): {
3
- "chat.params": (input: {
4
- sessionID: string;
5
- }, output: {
6
- system?: string;
7
- options?: Record<string, unknown>;
8
- }) => Promise<void>;
9
- event: ({ event }: {
10
- event: {
11
- type: string;
12
- properties?: unknown;
13
- };
14
- }) => Promise<void>;
15
- };
@@ -1,26 +0,0 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
- interface FileOps {
3
- read: Set<string>;
4
- modified: Set<string>;
5
- }
6
- export declare function trackFileOp(sessionID: string, operation: "read" | "write" | "edit", filePath: string): void;
7
- export declare function getFileOps(sessionID: string): FileOps;
8
- export declare function clearFileOps(sessionID: string): void;
9
- export declare function getAndClearFileOps(sessionID: string): FileOps;
10
- export declare function formatFileOpsForPrompt(ops: FileOps): string;
11
- export declare function createFileOpsTrackerHook(_ctx: PluginInput): {
12
- "tool.execute.after": (input: {
13
- tool: string;
14
- sessionID: string;
15
- args?: Record<string, unknown>;
16
- }, _output: {
17
- output?: string;
18
- }) => Promise<void>;
19
- event: ({ event }: {
20
- event: {
21
- type: string;
22
- properties?: unknown;
23
- };
24
- }) => Promise<void>;
25
- };
26
- export {};
@@ -1,16 +0,0 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
- export interface LedgerInfo {
3
- sessionName: string;
4
- filePath: string;
5
- content: string;
6
- }
7
- export declare function findCurrentLedger(directory: string): Promise<LedgerInfo | null>;
8
- export declare function formatLedgerInjection(ledger: LedgerInfo): string;
9
- export declare function createLedgerLoaderHook(ctx: PluginInput): {
10
- "chat.params": (_input: {
11
- sessionID: string;
12
- }, output: {
13
- options?: Record<string, unknown>;
14
- system?: string;
15
- }) => Promise<void>;
16
- };
@@ -1,9 +0,0 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
- export declare function createPreemptiveCompactionHook(ctx: PluginInput): {
3
- event: ({ event }: {
4
- event: {
5
- type: string;
6
- properties?: unknown;
7
- };
8
- }) => Promise<void>;
9
- };
@@ -1,9 +0,0 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
- export declare function createSessionRecoveryHook(ctx: PluginInput): {
3
- event: ({ event }: {
4
- event: {
5
- type: string;
6
- properties?: unknown;
7
- };
8
- }) => Promise<void>;
9
- };
@@ -1,15 +0,0 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
- export declare function createTokenAwareTruncationHook(ctx: PluginInput): {
3
- event: ({ event }: {
4
- event: {
5
- type: string;
6
- properties?: unknown;
7
- };
8
- }) => Promise<void>;
9
- "tool.execute.after": (input: {
10
- name: string;
11
- sessionID: string;
12
- }, output: {
13
- output?: string;
14
- }) => Promise<void>;
15
- };
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Plugin } from "@opencode-ai/plugin";
2
- declare const OpenCodeConfigPlugin: Plugin;
3
- export default OpenCodeConfigPlugin;