oh-pi 0.1.66 → 0.1.67

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.
package/dist/index.js CHANGED
@@ -70,7 +70,7 @@ async function customFlow(env) {
70
70
  const keybindings = await selectKeybindings();
71
71
  const extensions = await selectExtensions();
72
72
  const agents = await selectAgents();
73
- // Advanced: auto-compaction threshold
73
+ // Advanced: auto-compaction is now automatic based on model context window
74
74
  const wantAdvanced = await p.confirm({
75
75
  message: t("advanced.configure"),
76
76
  initialValue: false,
@@ -79,25 +79,6 @@ async function customFlow(env) {
79
79
  p.cancel(t("cancelled"));
80
80
  process.exit(0);
81
81
  }
82
- let compactThreshold = 0.80;
83
- if (wantAdvanced) {
84
- const threshold = await p.text({
85
- message: t("advanced.compactThreshold"),
86
- placeholder: "75",
87
- initialValue: "75",
88
- validate: (v) => {
89
- const n = Number(v);
90
- if (isNaN(n) || n < 10 || n > 100)
91
- return t("advanced.compactValidation");
92
- return undefined;
93
- },
94
- });
95
- if (p.isCancel(threshold)) {
96
- p.cancel(t("cancelled"));
97
- process.exit(0);
98
- }
99
- compactThreshold = Number(threshold) / 100;
100
- }
101
82
  return {
102
83
  providers,
103
84
  theme,
@@ -106,6 +87,5 @@ async function customFlow(env) {
106
87
  prompts: ["review", "fix", "explain", "commit", "test", "refactor", "optimize", "security", "document", "pr"],
107
88
  agents,
108
89
  thinking: "medium",
109
- compactThreshold,
110
90
  };
111
91
  }
@@ -24,7 +24,7 @@ export async function confirmApply(config, env) {
24
24
  `${t("confirm.theme")} ${chalk.cyan(config.theme)}`,
25
25
  `${t("confirm.keybindings")}${chalk.cyan(config.keybindings)}`,
26
26
  `${t("confirm.thinking")} ${chalk.cyan(config.thinking)}`,
27
- `${t("confirm.compaction")} ${chalk.cyan(t("confirm.compactionValue", { pct: Math.round((config.compactThreshold ?? 0.75) * 100) }))}`,
27
+ `${t("confirm.compaction")} ${chalk.cyan("auto")}`,
28
28
  `${t("confirm.extensions")} ${chalk.cyan(config.extensions.join(", ") || t("confirm.none"))}`,
29
29
  `${t("confirm.prompts")} ${chalk.cyan(t("confirm.promptsValue", { count: config.prompts.length }))}`,
30
30
  `${t("confirm.agents")} ${chalk.cyan(config.agents)}`,
@@ -87,14 +87,19 @@ export function applyConfig(config) {
87
87
  const primary = config.providers.find(p => p.baseUrl && p.defaultModel) ?? config.providers[0];
88
88
  const providerInfo = primary ? PROVIDERS[primary.name] : undefined;
89
89
  const compactThreshold = config.compactThreshold ?? 0.75;
90
- const reserveTokens = 32000;
90
+ // 根据主模型的 contextWindow 自动计算压缩参数
91
+ const primaryModelId = primary?.defaultModel ?? providerInfo?.models[0];
92
+ const caps = primaryModelId ? MODEL_CAPABILITIES[primaryModelId] : undefined;
93
+ const ctxWindow = caps?.contextWindow ?? primary?.contextWindow ?? 128000;
94
+ const reserveTokens = Math.max(16384, Math.round(ctxWindow * 0.15));
95
+ const keepRecentTokens = Math.max(16384, Math.round(ctxWindow * 0.15));
91
96
  const primaryModel = primary?.defaultModel ?? providerInfo?.models[0];
92
97
  const settings = {
93
98
  ...(primary ? { defaultProvider: primary.name, defaultModel: primaryModel } : {}),
94
99
  defaultThinkingLevel: config.thinking,
95
100
  theme: config.theme,
96
101
  enableSkillCommands: true,
97
- compaction: { enabled: true, reserveTokens, keepRecentTokens: 20000 },
102
+ compaction: { enabled: true, reserveTokens, keepRecentTokens },
98
103
  retry: { enabled: true, maxRetries: 3 },
99
104
  quietStartup: true,
100
105
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-pi",
3
- "version": "0.1.66",
3
+ "version": "0.1.67",
4
4
  "description": "One-click setup for pi-coding-agent. Like oh-my-zsh for pi.",
5
5
  "type": "module",
6
6
  "bin": {