@phi-code-admin/phi-code 0.84.2 → 0.86.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 (75) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/README.md +95 -126
  3. package/agents/code.md +1 -0
  4. package/agents/explore.md +11 -5
  5. package/agents/plan.md +18 -3
  6. package/agents/review.md +18 -7
  7. package/agents/test.md +1 -0
  8. package/config/routing.example.json +129 -0
  9. package/config/routing.schema.json +58 -0
  10. package/dist/cli/args.d.ts.map +1 -1
  11. package/dist/cli/args.js +1 -1
  12. package/dist/cli/args.js.map +1 -1
  13. package/dist/config.d.ts.map +1 -1
  14. package/dist/config.js +1 -1
  15. package/dist/config.js.map +1 -1
  16. package/dist/core/sdk.d.ts.map +1 -1
  17. package/dist/core/sdk.js +3 -3
  18. package/dist/core/sdk.js.map +1 -1
  19. package/dist/core/system-prompt.d.ts.map +1 -1
  20. package/dist/core/system-prompt.js +6 -6
  21. package/dist/core/system-prompt.js.map +1 -1
  22. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  23. package/dist/modes/interactive/components/config-selector.js +1 -1
  24. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  25. package/dist/modes/interactive/interactive-mode.d.ts +2 -2
  26. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  27. package/dist/modes/interactive/interactive-mode.js +32 -30
  28. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  29. package/dist/package-manager-cli.d.ts.map +1 -1
  30. package/dist/package-manager-cli.js +9 -8
  31. package/dist/package-manager-cli.js.map +1 -1
  32. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  33. package/dist/utils/pi-user-agent.js +4 -1
  34. package/dist/utils/pi-user-agent.js.map +1 -1
  35. package/dist/utils/version-check.d.ts +5 -5
  36. package/dist/utils/version-check.d.ts.map +1 -1
  37. package/dist/utils/version-check.js +13 -8
  38. package/dist/utils/version-check.js.map +1 -1
  39. package/docs/compaction.md +11 -11
  40. package/docs/custom-provider.md +4 -4
  41. package/docs/development.md +2 -2
  42. package/docs/extensions.md +47 -47
  43. package/docs/fork-policy.md +63 -0
  44. package/docs/index.md +7 -7
  45. package/docs/json.md +3 -3
  46. package/docs/keybindings.md +5 -5
  47. package/docs/models.md +6 -6
  48. package/docs/packages.md +37 -37
  49. package/docs/prompt-templates.md +4 -4
  50. package/docs/providers.md +9 -9
  51. package/docs/quickstart.md +25 -25
  52. package/docs/rpc.md +3 -3
  53. package/docs/sdk.md +34 -34
  54. package/docs/session-format.md +4 -4
  55. package/docs/sessions.md +11 -11
  56. package/docs/settings.md +11 -11
  57. package/docs/shell-aliases.md +2 -2
  58. package/docs/skills.md +9 -9
  59. package/docs/terminal-setup.md +7 -7
  60. package/docs/termux.md +6 -6
  61. package/docs/themes.md +9 -9
  62. package/docs/tmux.md +3 -3
  63. package/docs/tui.md +8 -8
  64. package/docs/usage.md +40 -40
  65. package/docs/windows.md +2 -2
  66. package/examples/sdk/12-full-control.ts +1 -1
  67. package/extensions/phi/agents.ts +5 -113
  68. package/extensions/phi/models.ts +170 -49
  69. package/extensions/phi/orchestrator.ts +44 -37
  70. package/extensions/phi/providers/agent-def.ts +128 -0
  71. package/extensions/phi/providers/live-models.ts +31 -1
  72. package/extensions/phi/providers/opencode-go.ts +7 -3
  73. package/extensions/phi/setup.ts +9 -0
  74. package/extensions/phi/skill-loader.ts +46 -25
  75. package/package.json +2 -1
@@ -49,27 +49,31 @@ interface OpenCodeGoModelsResponse {
49
49
 
50
50
  /**
51
51
  * Fallback static list of OpenCode Go models.
52
- * Last verified: 2026-05-15 (15 models, sourced from the live /v1/models endpoint).
52
+ * Last verified: 2026-07-10 (20 models, sourced from the live /v1/models endpoint).
53
53
  * Used when network unreachable or auth fails before configuration.
54
54
  *
55
55
  * Refresh with: `curl -s https://opencode.ai/zen/go/v1/models | jq '.data[].id'`
56
56
  */
57
57
  export const OPENCODE_GO_FALLBACK_MODELS: readonly OpenCodeGoModel[] = [
58
+ { id: "minimax-m3", name: "MiniMax M3", contextWindow: 1_000_000, maxTokens: 16_384 },
58
59
  { id: "minimax-m2.7", name: "MiniMax M2.7", contextWindow: 1_000_000, maxTokens: 16_384 },
59
60
  { id: "minimax-m2.5", name: "MiniMax M2.5", contextWindow: 1_000_000, maxTokens: 16_384 },
61
+ { id: "kimi-k2.7-code", name: "Kimi K2.7 Code", contextWindow: 256_000, maxTokens: 16_384 },
60
62
  { id: "kimi-k2.6", name: "Kimi K2.6", contextWindow: 256_000, maxTokens: 16_384 },
61
63
  { id: "kimi-k2.5", name: "Kimi K2.5", contextWindow: 256_000, maxTokens: 16_384 },
64
+ { id: "glm-5.2", name: "GLM 5.2", contextWindow: 200_000, maxTokens: 128_000 },
62
65
  { id: "glm-5.1", name: "GLM 5.1", contextWindow: 200_000, maxTokens: 128_000 },
63
66
  { id: "glm-5", name: "GLM 5", contextWindow: 200_000, maxTokens: 128_000 },
64
67
  { id: "deepseek-v4-pro", name: "DeepSeek V4 Pro", contextWindow: 128_000, maxTokens: 8_192 },
65
68
  { id: "deepseek-v4-flash", name: "DeepSeek V4 Flash", contextWindow: 128_000, maxTokens: 8_192 },
69
+ { id: "qwen3.7-max", name: "Qwen 3.7 Max", contextWindow: 1_000_000, maxTokens: 16_384 },
66
70
  { id: "qwen3.7-plus", name: "Qwen 3.7 Plus", contextWindow: 1_000_000, maxTokens: 16_384 },
67
71
  { id: "qwen3.6-plus", name: "Qwen 3.6 Plus", contextWindow: 1_000_000, maxTokens: 16_384 },
68
72
  { id: "qwen3.5-plus", name: "Qwen 3.5 Plus", contextWindow: 1_000_000, maxTokens: 16_384 },
69
- { id: "mimo-v2-pro", name: "MiMo V2 Pro", contextWindow: 200_000, maxTokens: 16_384 },
70
- { id: "mimo-v2-omni", name: "MiMo V2 Omni", contextWindow: 200_000, maxTokens: 16_384 },
71
73
  { id: "mimo-v2.5-pro", name: "MiMo V2.5 Pro", contextWindow: 200_000, maxTokens: 16_384 },
72
74
  { id: "mimo-v2.5", name: "MiMo V2.5", contextWindow: 200_000, maxTokens: 16_384 },
75
+ { id: "mimo-v2-pro", name: "MiMo V2 Pro", contextWindow: 200_000, maxTokens: 16_384 },
76
+ { id: "mimo-v2-omni", name: "MiMo V2 Omni", contextWindow: 200_000, maxTokens: 16_384 },
73
77
  { id: "hy3-preview", name: "Hy3 Preview", contextWindow: 128_000, maxTokens: 16_384 },
74
78
  ] as const;
75
79
 
@@ -109,6 +109,15 @@ function getProviderCatalog(): ProviderEntry[] {
109
109
  staticModels: [],
110
110
  docUrl: OPENCODE_GO_AUTH_URL,
111
111
  },
112
+ {
113
+ id: "opencode",
114
+ displayName: "OpenCode Zen",
115
+ envVar: "OPENCODE_API_KEY",
116
+ baseUrl: "https://opencode.ai/zen/v1",
117
+ api: "openai-completions",
118
+ staticModels: [],
119
+ docUrl: OPENCODE_GO_AUTH_URL,
120
+ },
112
121
  {
113
122
  id: "openai",
114
123
  displayName: "OpenAI",
@@ -3,8 +3,10 @@
3
3
  *
4
4
  * Uses sigma-skills SkillScanner and SkillLoader for skill discovery and matching.
5
5
  * Skills are folders containing SKILL.md files with specialized knowledge.
6
- * When skill-related keywords are detected in user input, the model is notified
7
- * and can load the full skill content via the `read` tool.
6
+ * When skill-related keywords are detected in user input, a compact skill hint
7
+ * (name, description, SKILL.md path) is appended to the message so the model
8
+ * actually SEES it and can load the full content via the `read` tool. A UI
9
+ * notification alone never reaches the model.
8
10
  *
9
11
  * Discovery locations (in priority order):
10
12
  * 1. .phi/skills/ (project-local, highest priority)
@@ -13,52 +15,78 @@
13
15
  *
14
16
  * Features:
15
17
  * - Automatic skill discovery at startup
16
- * - Keyword-based skill detection and loading
18
+ * - Keyword-based skill detection with an injection threshold
19
+ * - Auto-injection of skill hints into the model context (autoInject)
17
20
  * - /skills command to list available skills
18
- * - Contextual skill notification via ui.notify
19
21
  */
20
22
 
21
- import type { ExtensionAPI, ExtensionContext } from "phi-code";
23
+ import type { ExtensionAPI } from "phi-code";
22
24
  import { SkillScanner, SkillLoader } from "sigma-skills";
23
25
  import type { SkillsConfig } from "sigma-skills";
26
+ import { existsSync } from "node:fs";
24
27
  import { join } from "node:path";
25
28
  import { homedir } from "node:os";
26
29
 
27
30
  export default function skillLoaderExtension(pi: ExtensionAPI) {
31
+ // Bundled skills live at <package>/skills in the repo layout (two hops up
32
+ // from extensions/phi/); postinstall copies them to ~/.phi/agent/skills
33
+ // (== globalDir) in the installed layout. Probe both (the scanner dedupes
34
+ // by skill name).
35
+ const bundledCandidates = [
36
+ join(__dirname, "..", "..", "skills"),
37
+ join(homedir(), ".phi", "agent", "skills"),
38
+ ];
28
39
  const config: SkillsConfig = {
29
40
  globalDir: join(homedir(), ".phi", "agent", "skills"),
30
41
  projectDir: join(process.cwd(), ".phi", "skills"),
31
- bundledDir: join(__dirname, "..", "..", "..", "skills"),
42
+ bundledDir: bundledCandidates.find((dir) => existsSync(dir)) ?? bundledCandidates[0],
32
43
  autoInject: true,
33
44
  };
34
45
 
35
46
  const scanner = new SkillScanner(config);
36
47
  const loader = new SkillLoader(scanner);
37
48
 
49
+ // Skills already hinted this session — hint each skill once, not on every
50
+ // message of a long conversation about the same topic.
51
+ const hintedSkills = new Set<string>();
52
+
38
53
  // ─── Input Event: Match skills to user input ─────────────────────
39
54
 
40
55
  pi.on("input", async (event, ctx) => {
41
56
  if (event.source === "extension") {
42
57
  return { action: "continue" };
43
58
  }
59
+ // Slash commands and skill blocks are not prose — nothing to match.
60
+ if (event.text.trimStart().startsWith("/")) {
61
+ return { action: "continue" };
62
+ }
44
63
 
45
64
  const matches = loader.findRelevantSkills(event.text);
65
+ // findRelevantSkills scores any shared word; require a clear signal
66
+ // (name match or several keywords) before surfacing a skill.
67
+ const strong = matches.filter((m) => m.score >= 3 && !hintedSkills.has(m.skill.name)).slice(0, 2);
68
+ if (strong.length === 0) {
69
+ return { action: "continue" };
70
+ }
71
+ for (const match of strong) {
72
+ hintedSkills.add(match.skill.name);
73
+ }
46
74
 
47
- if (matches.length > 0) {
48
- // Notify about top matches (max 3)
49
- const topMatches = matches.slice(0, 3);
50
- for (const match of topMatches) {
51
- ctx.ui.notify(
52
- `📚 Relevant skill: **${match.skill.name}** — ${match.skill.description}\nUse \`read ${match.skill.path}/SKILL.md\` for full content.`,
53
- "info"
54
- );
55
- }
75
+ const names = strong.map((m) => m.skill.name).join(", ");
76
+ ctx.ui.notify(`📚 Skill hint: ${names} (injected into context)`, "info");
56
77
 
57
- const skillNames = topMatches.map(m => m.skill.name).join(", ");
58
- ctx.ui.notify(`🧠 Loaded ${topMatches.length} skill(s): ${skillNames}`, "info");
78
+ if (!config.autoInject) {
79
+ return { action: "continue" };
59
80
  }
60
81
 
61
- return { action: "continue" };
82
+ const hints = strong
83
+ .map((m) => `- ${m.skill.name}: ${m.skill.description} — full content: read ${join(m.skill.path, "SKILL.md")}`)
84
+ .join("\n");
85
+ return {
86
+ action: "transform",
87
+ text: `${event.text}\n\n[Skill hints — relevant local skills detected for this request. Read the SKILL.md before applying:\n${hints}]`,
88
+ images: event.images,
89
+ };
62
90
  });
63
91
 
64
92
  // ─── /skills Command ─────────────────────────────────────────────
@@ -108,11 +136,4 @@ export default function skillLoaderExtension(pi: ExtensionAPI) {
108
136
  }
109
137
  },
110
138
  });
111
-
112
- // ─── Session Start: Load skills ──────────────────────────────────
113
-
114
- pi.on("session_start", async (_event, _ctx) => {
115
- const skills = loader.listSkills();
116
- console.log(`[skill-loader] Loaded ${skills.length} skills from 3 locations`);
117
- });
118
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phi-code-admin/phi-code",
3
- "version": "0.84.2",
3
+ "version": "0.86.0",
4
4
  "description": "Coding agent CLI with persistent memory, sub-agents, intelligent routing, and orchestration",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -29,6 +29,7 @@
29
29
  "skills",
30
30
  "agents",
31
31
  "extensions",
32
+ "config",
32
33
  "README.md",
33
34
  "LICENSE",
34
35
  "CHANGELOG.md",