opencodekit 0.17.12 → 0.18.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 (36) hide show
  1. package/dist/{index.mjs → index.js} +50 -15
  2. package/dist/template/.opencode/dcp.jsonc +81 -81
  3. package/dist/template/.opencode/memory/memory.db +0 -0
  4. package/dist/template/.opencode/memory.db +0 -0
  5. package/dist/template/.opencode/memory.db-shm +0 -0
  6. package/dist/template/.opencode/memory.db-wal +0 -0
  7. package/dist/template/.opencode/opencode.json +199 -23
  8. package/dist/template/.opencode/opencode.json.tui-migration.bak +1380 -0
  9. package/dist/template/.opencode/package.json +1 -1
  10. package/dist/template/.opencode/plugin/lib/capture.ts +177 -0
  11. package/dist/template/.opencode/plugin/lib/context.ts +194 -0
  12. package/dist/template/.opencode/plugin/lib/curator.ts +234 -0
  13. package/dist/template/.opencode/plugin/lib/db/maintenance.ts +312 -0
  14. package/dist/template/.opencode/plugin/lib/db/observations.ts +299 -0
  15. package/dist/template/.opencode/plugin/lib/db/pipeline.ts +520 -0
  16. package/dist/template/.opencode/plugin/lib/db/schema.ts +356 -0
  17. package/dist/template/.opencode/plugin/lib/db/types.ts +211 -0
  18. package/dist/template/.opencode/plugin/lib/distill.ts +376 -0
  19. package/dist/template/.opencode/plugin/lib/inject.ts +126 -0
  20. package/dist/template/.opencode/plugin/lib/memory-admin-tools.ts +188 -0
  21. package/dist/template/.opencode/plugin/lib/memory-db.ts +54 -936
  22. package/dist/template/.opencode/plugin/lib/memory-helpers.ts +202 -0
  23. package/dist/template/.opencode/plugin/lib/memory-hooks.ts +240 -0
  24. package/dist/template/.opencode/plugin/lib/memory-tools.ts +341 -0
  25. package/dist/template/.opencode/plugin/memory.ts +56 -60
  26. package/dist/template/.opencode/plugin/sessions.ts +372 -93
  27. package/dist/template/.opencode/tui.json +15 -0
  28. package/package.json +1 -1
  29. package/dist/template/.opencode/tool/action-queue.ts +0 -313
  30. package/dist/template/.opencode/tool/memory-admin.ts +0 -445
  31. package/dist/template/.opencode/tool/memory-get.ts +0 -143
  32. package/dist/template/.opencode/tool/memory-read.ts +0 -45
  33. package/dist/template/.opencode/tool/memory-search.ts +0 -264
  34. package/dist/template/.opencode/tool/memory-timeline.ts +0 -105
  35. package/dist/template/.opencode/tool/memory-update.ts +0 -63
  36. package/dist/template/.opencode/tool/observation.ts +0 -357
@@ -18,7 +18,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
18
18
 
19
19
  //#endregion
20
20
  //#region package.json
21
- var version = "0.17.12";
21
+ var version = "0.18.0";
22
22
 
23
23
  //#endregion
24
24
  //#region src/utils/errors.ts
@@ -2578,6 +2578,7 @@ const EXCLUDED_FILES = [
2578
2578
  "yarn.lock",
2579
2579
  "pnpm-lock.yaml"
2580
2580
  ];
2581
+ const PRESERVE_USER_DIRS = ["memory/project"];
2581
2582
  /**
2582
2583
  * Get the global OpenCode config directory based on OS.
2583
2584
  * - macOS/Linux: ~/.config/opencode/ (respects XDG_CONFIG_HOME)
@@ -2628,7 +2629,6 @@ const MODEL_PRESETS = {
2628
2629
  review: "opencode/minimax-m2.5-free",
2629
2630
  explore: "opencode/glm-5-free",
2630
2631
  general: "opencode/glm-5-free",
2631
- looker: "opencode/minimax-m2.5-free",
2632
2632
  vision: "opencode/minimax-m2.5-free",
2633
2633
  scout: "opencode/glm-5-free",
2634
2634
  painter: "opencode/minimax-m2.5-free"
@@ -2640,12 +2640,11 @@ const MODEL_PRESETS = {
2640
2640
  build: "github-copilot/claude-opus-4.6",
2641
2641
  plan: "openai/gpt-5.3-codex",
2642
2642
  review: "openai/gpt-5.3-codex",
2643
- explore: "proxypal/gemini-3-flash",
2644
- general: "github-copilot/gpt-5.2-codex",
2645
- looker: "proxypal/gemini-3-flash",
2643
+ explore: "opencode/minimax-m2.5-free",
2644
+ general: "github-copilot/claude-sonnet-4.6",
2646
2645
  vision: "proxypal/gemini-3.1-pro-high",
2647
2646
  scout: "proxypal/claude-sonnet-4-6",
2648
- painter: "proxypal/gemini-3-pro-image"
2647
+ painter: "proxypal/gemini-3.1-flash-image"
2649
2648
  }
2650
2649
  }
2651
2650
  };
@@ -2772,6 +2771,36 @@ async function autoSavePatchesForOrphans(targetDir, templateRoot, orphans) {
2772
2771
  trueOrphans
2773
2772
  };
2774
2773
  }
2774
+ /**
2775
+ * Save existing user files from preserve directories before reinit.
2776
+ * Returns a map of relative paths to file contents.
2777
+ */
2778
+ function preserveUserFiles(targetDir) {
2779
+ const opencodeDir = join(targetDir, ".opencode");
2780
+ const preserved = /* @__PURE__ */ new Map();
2781
+ for (const relDir of PRESERVE_USER_DIRS) {
2782
+ const dirPath = join(opencodeDir, relDir);
2783
+ if (!existsSync(dirPath)) continue;
2784
+ for (const entry of readdirSync(dirPath, { withFileTypes: true })) {
2785
+ if (!entry.isFile()) continue;
2786
+ const filePath = join(dirPath, entry.name);
2787
+ const relativePath = join(relDir, entry.name);
2788
+ preserved.set(relativePath, readFileSync(filePath, "utf-8"));
2789
+ }
2790
+ }
2791
+ return preserved;
2792
+ }
2793
+ /**
2794
+ * Restore preserved user files after fresh template copy.
2795
+ */
2796
+ function restoreUserFiles(targetDir, preserved) {
2797
+ const opencodeDir = join(targetDir, ".opencode");
2798
+ for (const [relativePath, content] of preserved) {
2799
+ const filePath = join(opencodeDir, relativePath);
2800
+ mkdirSync(dirname(filePath), { recursive: true });
2801
+ writeFileSync(filePath, content);
2802
+ }
2803
+ }
2775
2804
  async function initCommand(rawOptions = {}) {
2776
2805
  const options = parseOptions(InitOptionsSchema, rawOptions);
2777
2806
  if (process.argv.includes("--quiet")) return;
@@ -2817,6 +2846,7 @@ async function initCommand(rawOptions = {}) {
2817
2846
  p.outro("Nothing to do");
2818
2847
  return;
2819
2848
  }
2849
+ let preservedFiles;
2820
2850
  if (mode === "already-initialized" && options.force) {
2821
2851
  const affected = getAffectedFiles(join(targetDir, ".opencode"));
2822
2852
  if (affected.length > 0 && !options.yes) {
@@ -2845,9 +2875,10 @@ async function initCommand(rawOptions = {}) {
2845
2875
  }
2846
2876
  }
2847
2877
  if (options.backup) {
2878
+ preservedFiles = preserveUserFiles(targetDir);
2848
2879
  const backupPath = backupOpenCode(targetDir);
2849
2880
  if (backupPath) p.log.info(`Backed up to ${color.cyan(basename(backupPath))}`);
2850
- }
2881
+ } else preservedFiles = preserveUserFiles(targetDir);
2851
2882
  }
2852
2883
  const templateRoot = getTemplateRoot$1();
2853
2884
  if (!templateRoot) {
@@ -2880,6 +2911,10 @@ async function initCommand(rawOptions = {}) {
2880
2911
  process.exit(1);
2881
2912
  }
2882
2913
  s.stop("Done");
2914
+ if (preservedFiles && preservedFiles.size > 0) {
2915
+ restoreUserFiles(targetDir, preservedFiles);
2916
+ p.log.info(`Preserved ${preservedFiles.size} user memory files (memory/project/)`);
2917
+ }
2883
2918
  if (options.free) {
2884
2919
  applyModelPreset(targetDir, "free");
2885
2920
  p.log.info("Applied free model preset");
@@ -2950,13 +2985,13 @@ async function initCommand(rawOptions = {}) {
2950
2985
  const installSpinner = p.spinner();
2951
2986
  installSpinner.start("Installing dependencies");
2952
2987
  try {
2953
- execSync("bun install", {
2988
+ execSync("npm install --no-fund --no-audit", {
2954
2989
  cwd: opencodeDir,
2955
2990
  stdio: "ignore"
2956
2991
  });
2957
2992
  installSpinner.stop("Dependencies installed");
2958
2993
  } catch {
2959
- installSpinner.stop("Failed to install (run manually: cd .opencode && bun install)");
2994
+ installSpinner.stop("Failed to install (run manually: cd .opencode && npm install)");
2960
2995
  }
2961
2996
  }
2962
2997
  if (mode === "already-initialized" && options.force && !options.backup) {
@@ -3389,12 +3424,12 @@ function copyDirPreserveExisting(src, dest) {
3389
3424
  for (const entry of entries) {
3390
3425
  const srcPath = join(src, entry.name);
3391
3426
  const destPath = join(dest, entry.name);
3392
- if (entry.isDirectory()) if (!existsSync(destPath)) {
3393
- mkdirSync(destPath, { recursive: true });
3427
+ if (entry.isDirectory()) {
3428
+ if (!existsSync(destPath)) mkdirSync(destPath, { recursive: true });
3394
3429
  const subResult = copyDirPreserveExisting(srcPath, destPath);
3395
3430
  updated.push(...subResult.updated);
3396
- } else preserved.push(`${entry.name}/`);
3397
- else if (!existsSync(destPath)) {
3431
+ preserved.push(...subResult.preserved);
3432
+ } else if (!existsSync(destPath)) {
3398
3433
  copyFileSync(srcPath, destPath);
3399
3434
  updated.push(entry.name);
3400
3435
  } else preserved.push(entry.name);
@@ -3520,13 +3555,13 @@ async function upgradeCommand(rawOptions = {}) {
3520
3555
  installSpinner.start("Installing dependencies");
3521
3556
  try {
3522
3557
  const { execSync } = await import("node:child_process");
3523
- execSync("bun install", {
3558
+ execSync("npm install --no-fund --no-audit", {
3524
3559
  cwd: opencodeDir,
3525
3560
  stdio: "ignore"
3526
3561
  });
3527
3562
  installSpinner.stop("Dependencies installed");
3528
3563
  } catch {
3529
- installSpinner.stop("Failed to install (run manually: cd .opencode && bun install)");
3564
+ installSpinner.stop("Failed to install (run manually: cd .opencode && npm install)");
3530
3565
  }
3531
3566
  }
3532
3567
  p.outro(color.green(`Upgraded to ${versionInfo.latest}`));
@@ -1,83 +1,83 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/master/dcp.schema.json",
3
- "enabled": true,
4
- "debug": false,
5
- // "minimal" shows prune activity without noise; "detailed" shows token counts
6
- "pruneNotification": "detailed",
7
- // "chat" (in-conversation) or "toast" (system notification)
8
- "pruneNotificationType": "toast",
9
- // Commands: /dcp context, /dcp stats, /dcp sweep
10
- "commands": {
11
- "enabled": true,
12
- // Protect these from /dcp sweep
13
- "protectedTools": ["observation", "memory-update", "memory-search"]
14
- },
15
- "turnProtection": {
16
- "enabled": true,
17
- "turns": 4
18
- },
19
- // Protected file patterns - never auto-prune reads of these files
20
- "protectedFilePatterns": [
21
- "**/.env*",
22
- "**/AGENTS.md",
23
- "**/.opencode/**",
24
- "**/.beads/**",
25
- "**/package.json",
26
- "**/tsconfig.json",
27
- "**/biome.json"
28
- ],
29
- "tools": {
30
- "settings": {
31
- "nudgeEnabled": true,
32
- "nudgeFrequency": 10,
33
- // v2.0.1: percentage support - 80% of model's context (most models = 128k)
34
- "contextLimit": "80%",
35
- // Protect state-modifying and critical workflow tools
36
- // LSP excluded: ephemeral exploration, prune after understanding
37
- "protectedTools": [
38
- "write",
39
- "edit",
40
- "memory-update",
41
- "observation",
42
- "skill",
43
- "skill_mcp",
44
- "task",
45
- "batch",
46
- "todowrite",
47
- "todoread"
48
- ]
49
- },
50
- // v2.0.0: permission model - "allow", "ask", or "deny"
51
- "prune": {
52
- "permission": "allow"
53
- },
54
- "distill": {
55
- "permission": "allow",
56
- "showDistillation": false
57
- },
58
- "compress": {
59
- // v2.1.1: compress can have boundary matching issues - use ask for safety
60
- "permission": "ask",
61
- "showCompression": false
62
- }
63
- },
64
- // Auto strategies - TOP LEVEL, not under tools
65
- "strategies": {
66
- // Dedup = zero LLM cost, high impact - always enable
67
- "deduplication": {
68
- "enabled": true,
69
- "protectedTools": []
70
- },
71
- // Supersede writes = zero cost, removes redundant write inputs after read
72
- // Note: default changed to false in beta, we explicitly enable
73
- "supersedeWrites": {
74
- "enabled": true
75
- },
76
- // Purge error inputs after N turns
77
- "purgeErrors": {
78
- "enabled": true,
79
- "turns": 4,
80
- "protectedTools": []
81
- }
82
- }
2
+ "$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/master/dcp.schema.json",
3
+ "enabled": true,
4
+ "debug": false,
5
+ // "minimal" shows prune activity without noise; "detailed" shows token counts
6
+ "pruneNotification": "detailed",
7
+ // "chat" (in-conversation) or "toast" (system notification)
8
+ "pruneNotificationType": "toast",
9
+ // Commands: /dcp context, /dcp stats, /dcp sweep
10
+ "commands": {
11
+ "enabled": true,
12
+ // Protect these from /dcp sweep
13
+ "protectedTools": ["observation", "memory-update", "memory-search"],
14
+ },
15
+ "turnProtection": {
16
+ "enabled": true,
17
+ "turns": 4,
18
+ },
19
+ // Protected file patterns - never auto-prune reads of these files
20
+ "protectedFilePatterns": [
21
+ "**/.env*",
22
+ "**/AGENTS.md",
23
+ "**/.opencode/**",
24
+ "**/.beads/**",
25
+ "**/package.json",
26
+ "**/tsconfig.json",
27
+ "**/biome.json",
28
+ ],
29
+ "tools": {
30
+ "settings": {
31
+ "nudgeEnabled": true,
32
+ "nudgeFrequency": 10,
33
+ // v2.0.1: percentage support - 80% of model's context (most models = 128k)
34
+ "contextLimit": "80%",
35
+ // Protect state-modifying and critical workflow tools
36
+ // LSP excluded: ephemeral exploration, prune after understanding
37
+ "protectedTools": [
38
+ "write",
39
+ "edit",
40
+ "memory-update",
41
+ "observation",
42
+ "skill",
43
+ "skill_mcp",
44
+ "task",
45
+ "batch",
46
+ "todowrite",
47
+ "todoread",
48
+ ],
49
+ },
50
+ // v2.0.0: permission model - "allow", "ask", or "deny"
51
+ "prune": {
52
+ "permission": "allow",
53
+ },
54
+ "distill": {
55
+ "permission": "allow",
56
+ "showDistillation": false,
57
+ },
58
+ "compress": {
59
+ // v2.1.1: compress can have boundary matching issues - use ask for safety
60
+ "permission": "allow",
61
+ "showCompression": false,
62
+ },
63
+ },
64
+ // Auto strategies - TOP LEVEL, not under tools
65
+ "strategies": {
66
+ // Dedup = zero LLM cost, high impact - always enable
67
+ "deduplication": {
68
+ "enabled": true,
69
+ "protectedTools": [],
70
+ },
71
+ // Supersede writes = zero cost, removes redundant write inputs after read
72
+ // Note: default changed to false in beta, we explicitly enable
73
+ "supersedeWrites": {
74
+ "enabled": true,
75
+ },
76
+ // Purge error inputs after N turns
77
+ "purgeErrors": {
78
+ "enabled": true,
79
+ "turns": 4,
80
+ "protectedTools": [],
81
+ },
82
+ },
83
83
  }
File without changes
Binary file