@cydm/pie 1.0.6 → 1.0.8

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 (59) hide show
  1. package/README.md +156 -9
  2. package/dist/builtin/extensions/ask-user/index.js +2 -3
  3. package/dist/builtin/extensions/init/index.js +70 -68
  4. package/dist/builtin/extensions/kimi-attachments/index.js +3 -3
  5. package/dist/builtin/extensions/plan-mode/index.js +85 -87
  6. package/dist/builtin/extensions/subagent/index.js +17 -7
  7. package/dist/builtin/extensions/todo/index.js +51 -22
  8. package/dist/builtin/skills/browser-tools/CHANGELOG.md +2 -44
  9. package/dist/builtin/skills/browser-tools/README.md +10 -99
  10. package/dist/builtin/skills/browser-tools/SKILL.md +21 -174
  11. package/dist/builtin/skills/browser-tools/package.json +6 -13
  12. package/dist/builtin/skills/browser-tools/playwright-cli.js +24 -0
  13. package/dist/builtin/skills/skill-creator/SKILL.md +17 -17
  14. package/dist/builtin/skills/skill-creator/eval-viewer/generate_review.mjs +285 -0
  15. package/dist/builtin/skills/skill-creator/eval-viewer/viewer.html +1 -1
  16. package/dist/builtin/skills/skill-creator/scripts/aggregate_benchmark.mjs +271 -0
  17. package/dist/builtin/skills/skill-creator/scripts/claude_cli.mjs +115 -0
  18. package/dist/builtin/skills/skill-creator/scripts/generate_report.mjs +224 -0
  19. package/dist/builtin/skills/skill-creator/scripts/improve_description.mjs +198 -0
  20. package/dist/builtin/skills/skill-creator/scripts/package_skill.mjs +132 -0
  21. package/dist/builtin/skills/skill-creator/scripts/pie_runner.mjs +115 -0
  22. package/dist/builtin/skills/skill-creator/scripts/quick_validate.mjs +44 -0
  23. package/dist/builtin/skills/skill-creator/scripts/run_eval.mjs +169 -0
  24. package/dist/builtin/skills/skill-creator/scripts/run_loop.mjs +297 -0
  25. package/dist/builtin/skills/skill-creator/scripts/skill_metadata.mjs +134 -0
  26. package/dist/chunks/chunk-6WD2NFIC.js +8383 -0
  27. package/dist/chunks/{chunk-MWFBYJOI.js → chunk-A5JSJAPK.js} +3973 -1313
  28. package/dist/chunks/chunk-NTYHFBUA.js +36 -0
  29. package/dist/chunks/chunk-ZRONUKTW.js +989 -0
  30. package/dist/chunks/{src-EGWRDMLB.js → src-3X3HBT2G.js} +1 -2
  31. package/dist/chunks/typescript-GSKWJIO4.js +210747 -0
  32. package/dist/cli.js +15261 -12502
  33. package/models.schema.json +238 -0
  34. package/package.json +34 -8
  35. package/dist/builtin/skills/browser-tools/browser-content.js +0 -103
  36. package/dist/builtin/skills/browser-tools/browser-cookies.js +0 -35
  37. package/dist/builtin/skills/browser-tools/browser-eval.js +0 -49
  38. package/dist/builtin/skills/browser-tools/browser-hn-scraper.js +0 -108
  39. package/dist/builtin/skills/browser-tools/browser-nav.js +0 -44
  40. package/dist/builtin/skills/browser-tools/browser-pick.js +0 -162
  41. package/dist/builtin/skills/browser-tools/browser-screenshot.js +0 -34
  42. package/dist/builtin/skills/browser-tools/browser-start.js +0 -86
  43. package/dist/builtin/skills/skill-creator/eval-viewer/generate_review.py +0 -471
  44. package/dist/builtin/skills/skill-creator/scripts/__init__.py +0 -0
  45. package/dist/builtin/skills/skill-creator/scripts/aggregate_benchmark.py +0 -401
  46. package/dist/builtin/skills/skill-creator/scripts/generate_report.py +0 -326
  47. package/dist/builtin/skills/skill-creator/scripts/improve_description.py +0 -247
  48. package/dist/builtin/skills/skill-creator/scripts/package_skill.py +0 -136
  49. package/dist/builtin/skills/skill-creator/scripts/quick_validate.py +0 -103
  50. package/dist/builtin/skills/skill-creator/scripts/run_eval.py +0 -310
  51. package/dist/builtin/skills/skill-creator/scripts/run_loop.py +0 -328
  52. package/dist/builtin/skills/skill-creator/scripts/utils.py +0 -47
  53. package/dist/chunks/capabilities-FENCOHVA.js +0 -9
  54. package/dist/chunks/chunk-JYBXCEJJ.js +0 -315
  55. package/dist/chunks/chunk-RID3574D.js +0 -2718
  56. package/dist/chunks/chunk-TBJ25UWB.js +0 -3657
  57. package/dist/chunks/chunk-XZXLO7YB.js +0 -322
  58. package/dist/chunks/file-logger-AL5VVZHH.js +0 -22
  59. package/dist/chunks/src-WRUACRN2.js +0 -132
package/README.md CHANGED
@@ -4,8 +4,6 @@
4
4
 
5
5
  It gives you a terminal-first agent experience out of the box, while staying modular enough to embed into other runtimes and products. Pie is designed for teams that want a small surface area, strong defaults, persistent sessions, tool use, and a clean path from CLI usage to deeper integration.
6
6
 
7
- Pie is heavily inspired by `pi`, while evolving in its own direction around modularity, embeddability, and a compact developer-facing workflow.
8
-
9
7
  Pie is developed by [cydream](https://cydream.tech).
10
8
 
11
9
  ## Why Pie
@@ -22,6 +20,8 @@ Pie is developed by [cydream](https://cydream.tech).
22
20
  npm install -g @cydm/pie
23
21
  ```
24
22
 
23
+ Pie supports Node.js 20 and newer. Release builds are validated with npm's lockfile workflow (`npm ci`) so dependency resolution is reproducible.
24
+
25
25
  ## Quick Start
26
26
 
27
27
  Set an API key for the provider you want to use:
@@ -38,6 +38,72 @@ You can also configure defaults in:
38
38
  - `~/.pie/models.json`
39
39
  - `~/.pie/config.json` for legacy-compatible defaults
40
40
 
41
+ Minimal `~/.pie/models.json`:
42
+
43
+ ```json
44
+ {
45
+ "profiles": {
46
+ "cy-gpt": {
47
+ "api": "openai-completions",
48
+ "baseUrl": "https://token.magicshell.ai/v1",
49
+ "apiKey": "YOUR_API_KEY",
50
+ "models": [
51
+ {
52
+ "id": "gpt-5.4",
53
+ "name": "GPT 5.4",
54
+ "reasoning": true,
55
+ "input": ["text", "image"],
56
+ "contextWindow": 128000,
57
+ "maxTokens": 16384,
58
+ "cost": {
59
+ "input": 0,
60
+ "output": 0,
61
+ "cacheRead": 0,
62
+ "cacheWrite": 0
63
+ }
64
+ }
65
+ ]
66
+ }
67
+ },
68
+ "defaults": {
69
+ "provider": "cy-gpt",
70
+ "modelId": "gpt-5.4"
71
+ }
72
+ }
73
+ ```
74
+
75
+ Required profile fields:
76
+
77
+ - `api`
78
+ - `baseUrl`
79
+ - `apiKey` or `apiKeyEnv`
80
+ - `models`
81
+
82
+ Required model fields:
83
+
84
+ - `id`
85
+ - `input`
86
+ - `cost`
87
+ - `contextWindow`
88
+ - `maxTokens`
89
+
90
+ Validate the file explicitly:
91
+
92
+ ```bash
93
+ pie models validate
94
+ pie models validate --path /abs/path/to/models.json
95
+ pie models validate --probe web_search
96
+ ```
97
+
98
+ Generate a starter template:
99
+
100
+ ```bash
101
+ pie models init
102
+ pie models init --stdout
103
+ ```
104
+
105
+ For editor auto-complete and validation, you can also point the optional `"$schema"` field in your local `models.json` at your installed `@cydm/pie/models.schema.json` file.
106
+
41
107
  Start Pie in interactive mode:
42
108
 
43
109
  ```bash
@@ -113,6 +179,10 @@ Pie uses a hierarchical slash-command menu. The current built-in commands includ
113
179
 
114
180
  | Command | Description |
115
181
  | --- | --- |
182
+ | `pie doctor [--json]` | Diagnose local config, model setup, writable paths, browser automation, and Unity bridge hints |
183
+ | `pie models init` | Create a starter `~/.pie/models.json` |
184
+ | `pie models validate` | Validate `~/.pie/models.json` |
185
+ | `pie permissions` | Explain tool and shell safety defaults |
116
186
  | `/sessions/compact` | Summarize history and create a compact checkpoint |
117
187
  | `/sessions/new` | Start a new session |
118
188
  | `/sessions/resume` | Resume a different session |
@@ -130,9 +200,9 @@ Pie uses a hierarchical slash-command menu. The current built-in commands includ
130
200
  | `/skills/use` | Use a skill |
131
201
  | `/skills/reload` | Reload skills from disk |
132
202
  | `/tools/subagent` | Spawn a subagent for a task |
133
- | `/debugs/cache-test` | Test context caching |
134
- | `/debugs/context` | Dump raw context for debugging |
135
- | `/debugs/package` | Dump raw request and response payloads |
203
+ | `/debugs/cache-test` | Run provider cache diagnostics with a dedicated 2-request probe |
204
+ | `/debugs/context` | Append a context summary to `~/.pie/logs/pie-cli.log` |
205
+ | `/debugs/package` | Append a package summary to `~/.pie/logs/pie-cli.log` |
136
206
 
137
207
  Pie can also load extension-provided commands at runtime.
138
208
 
@@ -158,6 +228,57 @@ Pie supports Markdown-based skills and built-in extensions.
158
228
 
159
229
  That is part of what makes Pie embeddable: the CLI is only one interface on top of a broader agent toolkit.
160
230
 
231
+ ## Browser Tools
232
+
233
+ The built-in `browser-tools` skill uses Microsoft's Playwright CLI for visible browser automation. Its runtime dependencies ship with the CLI; do not run `npm install` inside the skill directory.
234
+
235
+ Resolve the skill resource and run Playwright commands:
236
+
237
+ ```bash
238
+ node <resolvedPath for browser-tools/playwright-cli.js> open https://example.com
239
+ node <resolvedPath for browser-tools/playwright-cli.js> snapshot
240
+ node <resolvedPath for browser-tools/playwright-cli.js> screenshot
241
+ node <resolvedPath for browser-tools/playwright-cli.js> console
242
+ node <resolvedPath for browser-tools/playwright-cli.js> network
243
+ ```
244
+
245
+ If Playwright's Chromium browser is not installed, run:
246
+
247
+ ```bash
248
+ node <resolvedPath for browser-tools/playwright-cli.js> install-browser chromium
249
+ ```
250
+
251
+ Run `pie doctor` to check whether Playwright CLI and its browser runtime are discoverable.
252
+
253
+ ## Web Research
254
+
255
+ Pie exposes a canonical `web_research` tool for public web research, current information, online documentation, and internet inspiration. It plans search variants, uses provider-native search, fetches credible sources, and returns citations. Workspace search remains separate: use `grep_text`, `find_files`, and `list_dir` for local repository content.
256
+
257
+ `web_search` remains available as the lower-level provider-native search tool. It does not scrape DuckDuckGo or fall back to `bash` with `curl` or Python HTTP scripts. If the configured provider/model cannot perform native web search, the tool returns a clear unavailable result with provider/configuration details.
258
+
259
+ Use `web_fetch` directly when the agent needs to read a specific URL, documentation page, changelog, issue, or PDF. `web_fetch` follows redirects, extracts readable text/markdown, returns citation anchors and extraction diagnostics, and reports `requires_browser` for JavaScript-heavy pages instead of pretending the content was read. In the CLI, `web_research` can use browser-tools for browser-rendered sources when the Playwright runtime is available; Unity reports those pages as `requires_browser`.
260
+
261
+ `web_research` records route health and latency in Pie's state directory so later runs can prefer providers with better source quality, fewer timeouts, and lower rate-limit pressure. `pie doctor --json` reports the recorded provider health, and `verify:web` writes web metrics including p50/p95 latency, failure categories, and citation quality artifacts.
262
+
263
+ ## Permissions
264
+
265
+ Pie's default tools operate from the current workspace. File tools are workspace-scoped, `~/.pie` is allowlisted for Pie configuration/session support, and shell commands return structured timeout/truncation/error details. The canonical shell tool is still named `bash` for compatibility; on Windows `shell:auto` uses PowerShell, and callers can explicitly request `bash`, `powershell`, or `cmd`. High-risk shell commands require confirmation outside YOLO mode. `/settings/yolo` relaxes filesystem sandbox directory restrictions and should only be used in trusted workspaces. `pie permissions` prints the current policy-derived safety summary.
266
+
267
+ ## Code Intelligence
268
+
269
+ `code_intel` provides read-only JS/TS diagnostics, definition, references, symbols, and hover. CLI uses the TypeScript language service by default and falls back to lightweight text analysis only when the TypeScript service cannot start. Unity uses a Node sidecar contract for TypeScript intelligence so the PuerTS bundle does not import Node-only parser dependencies.
270
+
271
+ ## Diagnostics
272
+
273
+ Use:
274
+
275
+ ```bash
276
+ pie doctor
277
+ pie doctor --json
278
+ ```
279
+
280
+ Doctor checks Node/npm, model configuration, API key availability, writable Pie data paths, Playwright browser readiness, Unity bridge hints, and runtime log location. User-facing errors stay concise; detailed debugging goes to `~/.pie/logs/pie-cli.log` and session trace artifacts.
281
+
161
282
  ## Output Modes
162
283
 
163
284
  For non-interactive usage, Pie supports structured output options:
@@ -179,12 +300,38 @@ For the best multiline editing experience, use a terminal with good modified-key
179
300
  ## Development
180
301
 
181
302
  ```bash
182
- cd products/cli
183
- npm install
184
- npm run build
185
- npm run test:offline
303
+ npm ci
304
+ npm run verify:quality
305
+ npm run verify:release
306
+ npm run verify:browser
307
+ npm run verify:terminal:matrix
186
308
  ```
187
309
 
310
+ Use `npm run verify:agent` when model credentials are available and you want the real daily agent gate.
311
+ Use `npm run verify:agent:nightly` before release candidates that claim real-provider reliability.
312
+ Use `UNITY_EDITOR="/path/to/Unity" npm run verify:unity:reliability` before Unity release candidates. For live Unity Dev RPC coverage, run `PIE_UNITY_REAL_RPC=1 UNITY_EDITOR="/path/to/Unity" npm run verify:unity:reliability`.
313
+ Set `PIE_REAL_BROWSER=1` when you want `verify:browser` to open a real browser session instead of only checking the Playwright CLI contract.
314
+ Set `PIE_REAL_WEB=1` when you want `verify:web` to run real provider web research smoke with fetched or browser-read citations.
315
+
316
+ ## Publishing
317
+
318
+ Publish `@cydm/pie` from the monorepo root.
319
+
320
+ Set the npm token first:
321
+
322
+ ```bash
323
+ npm config set //registry.npmjs.org/:_authToken <YOUR_TOKEN>
324
+ ```
325
+
326
+ Then publish:
327
+
328
+ ```bash
329
+ npm run verify:release
330
+ npm publish --workspace products/cli --access public
331
+ ```
332
+
333
+ If the package version already exists on npm, bump `products/cli/package.json` first.
334
+
188
335
  ## License
189
336
 
190
337
  MIT
@@ -1,9 +1,8 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createAskUserCapability
4
- } from "../../../chunks/chunk-TBJ25UWB.js";
5
- import "../../../chunks/chunk-MWFBYJOI.js";
6
- import "../../../chunks/chunk-RID3574D.js";
4
+ } from "../../../chunks/chunk-6WD2NFIC.js";
5
+ import "../../../chunks/chunk-A5JSJAPK.js";
7
6
  import "../../../chunks/chunk-TG2EQLX2.js";
8
7
 
9
8
  // builtin/extensions/ask-user/index.ts
@@ -1,136 +1,138 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ resolveCliProjectRoot
4
+ } from "../../../chunks/chunk-NTYHFBUA.js";
2
5
  import "../../../chunks/chunk-TG2EQLX2.js";
3
6
 
4
7
  // builtin/extensions/init/index.ts
8
+ import fs from "node:fs";
9
+ import path from "node:path";
10
+ function resolveProjectAgentsTarget(cwd) {
11
+ const projectRoot = resolveCliProjectRoot(cwd);
12
+ return {
13
+ projectRoot,
14
+ agentsPath: path.join(projectRoot, "AGENTS.md")
15
+ };
16
+ }
5
17
  async function loadExistingKnowledge(cwd) {
18
+ const target = resolveProjectAgentsTarget(cwd);
6
19
  try {
7
- const fs = await import("fs");
8
- const path = await import("path");
9
- const agentsPath = path.join(cwd, ".pie", "agents.md");
10
- if (fs.existsSync(agentsPath)) {
11
- return fs.readFileSync(agentsPath, "utf-8");
20
+ if (fs.existsSync(target.agentsPath)) {
21
+ return { target, content: fs.readFileSync(target.agentsPath, "utf-8") };
12
22
  }
13
23
  } catch {
14
24
  }
15
- return null;
16
- }
17
- async function ensurePieDir(cwd) {
18
- const fs = await import("fs");
19
- const path = await import("path");
20
- const pieDir = path.join(cwd, ".pie");
21
- if (!fs.existsSync(pieDir)) {
22
- fs.mkdirSync(pieDir, { recursive: true });
23
- }
25
+ return { target, content: null };
24
26
  }
25
27
  function buildResearchPrompt(params) {
26
- const { isUpdate, existingContent, userIntent, cwd } = params;
28
+ const { isUpdate, existingContent, userIntent, cwd, projectRoot, agentsPath } = params;
27
29
  if (isUpdate && existingContent) {
28
30
  const truncatedContent = existingContent.length > 4e3 ? existingContent.slice(0, 4e3) + "\n... (truncated)" : existingContent;
29
- return `\u{1F4DD} \u66F4\u65B0\u9879\u76EE\u77E5\u8BC6\u6587\u6863
31
+ return `\u{1F4DD} \u66F4\u65B0 root AGENTS.md \u9879\u76EE\u4E0A\u4E0B\u6587
32
+
33
+ \u76EE\u6807\u6587\u4EF6\uFF1A${agentsPath}
34
+ \u9879\u76EE\u6839\u76EE\u5F55\uFF1A${projectRoot}
35
+ \u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF1A${cwd}
30
36
 
31
- \u5F53\u524D .pie/agents.md \u5185\u5BB9\uFF1A
37
+ \u5F53\u524D root AGENTS.md \u5185\u5BB9\uFF1A
32
38
  \`\`\`
33
39
  ${truncatedContent}
34
40
  \`\`\`
35
41
 
36
42
  ${userIntent ? `\u{1F4CC} \u7528\u6237\u66F4\u65B0\u610F\u56FE\uFF1A${userIntent}
37
43
 
38
- ` : ""}\u8BF7\u91CD\u65B0\u7814\u7A76\u9879\u76EE\u5E76\u66F4\u65B0\u77E5\u8BC6\u6587\u6863\uFF1A
44
+ ` : ""}\u8BF7\u91CD\u65B0\u7814\u7A76\u9879\u76EE\u5E76\u66F4\u65B0 root AGENTS.md\uFF1A
39
45
 
40
- 1. \u63A2\u7D22\u5F53\u524D\u4EE3\u7801\u7ED3\u6784\uFF0C\u5BF9\u6BD4\u73B0\u6709\u6587\u6863
41
- 2. \u8BC6\u522B\u65B0\u589E/\u53D8\u66F4/\u79FB\u9664\u7684\u6A21\u5757\u548C\u6587\u4EF6
42
- 3. ${userIntent ? `\u91CD\u70B9\u5173\u6CE8\uFF1A${userIntent}` : "\u8865\u5145\u7F3A\u5931\u7684\u7EC6\u8282\u548C\u67B6\u6784\u8BF4\u660E\uFF0C\u66F4\u65B0\u8FC7\u65F6\u7684\u4FE1\u606F"}
43
- 4. \u4FDD\u6301\u6587\u6863\u7ED3\u6784\u6E05\u6670\uFF0C\u7EF4\u62A4\u7AE0\u8282\u5B8C\u6574\u6027
44
- 5. \u66F4\u65B0\u540E\u786E\u4FDD agents.md \u4ECD\u7136\u6709\u7528\u4E14\u51C6\u786E
46
+ 1. \u4FDD\u6301 AGENTS.md \u662F progressive disclosure index\uFF0C\u4E0D\u8981\u5199\u6210\u957F\u7BC7\u9879\u76EE\u767E\u79D1
47
+ 2. \u4FDD\u7559\u7B80\u77ED root instructions\uFF0C\u7136\u540E\u7EF4\u62A4 Repo Map
48
+ 3. Repo Map \u91CC\u7684\u6BCF\u4E2A\u91CD\u8981\u76EE\u5F55\u90FD\u8981\u6709 desc\uFF0C\u8BF4\u660E\u4EC0\u4E48\u65F6\u5019\u9700\u8981\u8BFB\u8BE5\u76EE\u5F55\u6216\u76F8\u5173\u6587\u6863
49
+ 4. \u53EA\u8865\u5145\u7A33\u5B9A\u89C4\u5219\u3001\u76EE\u5F55\u8DEF\u7531\u3001\u9A8C\u8BC1\u95E8\u7981\u548C\u751F\u6210\u7269\u89C4\u5219
50
+ 5. \u5220\u9664\u8FC7\u65F6\u6216\u91CD\u590D README/ARCHITECTURE \u7684\u5927\u6BB5\u5185\u5BB9
45
51
 
46
- \u8BF7\u4F7F\u7528 write \u5DE5\u5177\u66F4\u65B0 \`.pie/agents.md\` \u6587\u4EF6\u3002
47
-
48
- \u5DE5\u4F5C\u76EE\u5F55\uFF1A${cwd}`;
52
+ \u8BF7\u4F7F\u7528 write_file \u5DE5\u5177\u66F4\u65B0\u76EE\u6807\u6587\u4EF6\uFF1A${agentsPath}
53
+ CLI \u6587\u4EF6\u5DE5\u5177\u4F1A\u4EE5\u9879\u76EE\u6839\u76EE\u5F55\u4F5C\u4E3A\u8BBF\u95EE\u8FB9\u754C\uFF1B\u4E0D\u8981\u4F7F\u7528\u989D\u5916\u7684 root \u53C2\u6570\u3002`;
49
54
  }
50
- return `\u{1F50D} \u521D\u59CB\u5316\u9879\u76EE\u7814\u7A76
55
+ return `\u{1F50D} \u521D\u59CB\u5316 root AGENTS.md \u9879\u76EE\u4E0A\u4E0B\u6587
56
+
57
+ \u76EE\u6807\u6587\u4EF6\uFF1A${agentsPath}
58
+ \u9879\u76EE\u6839\u76EE\u5F55\uFF1A${projectRoot}
59
+ \u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF1A${cwd}
51
60
 
52
61
  ${userIntent ? `\u{1F4CC} \u7528\u6237\u7814\u7A76\u610F\u56FE\uFF1A${userIntent}
53
62
 
54
- ` : ""}\u8BF7\u5E2E\u6211\u5168\u9762\u7814\u7A76\u5F53\u524D\u9879\u76EE\u5E76\u521B\u5EFA \`.pie/agents.md\` \u77E5\u8BC6\u6587\u6863\u3002
63
+ ` : ""}\u8BF7\u7814\u7A76\u5F53\u524D\u9879\u76EE\u5E76\u521B\u5EFA root \`AGENTS.md\`\u3002\u8FD9\u4E2A\u6587\u4EF6\u5E94\u8BE5\u662F progressive disclosure index\uFF0C\u7528\u6765\u6307\u5BFC\u540E\u7EED agent \u6309\u9700\u8BFB\u53D6\u76F8\u5173\u6587\u6863\uFF0C\u800C\u4E0D\u662F\u4E00\u6B21\u6027\u603B\u7ED3\u6574\u4E2A\u4ED3\u5E93\u3002
55
64
 
56
65
  \u7814\u7A76\u4EFB\u52A1\uFF1A
57
66
  1. \u8BC6\u522B\u9879\u76EE\u7C7B\u578B\u548C\u6280\u672F\u6808\uFF08\u67E5\u770B package.json, Cargo.toml, go.mod, requirements.txt, pyproject.toml \u7B49\uFF09
58
- 2. \u63A2\u7D22\u6E90\u4EE3\u7801\u76EE\u5F55\u7ED3\u6784\uFF08src/, lib/, app/ \u7B49\u5E38\u89C1\u76EE\u5F55\uFF09
59
- 3. \u8BFB\u53D6\u5173\u952E\u914D\u7F6E\u6587\u4EF6\u7406\u89E3\u9879\u76EE\u8BBE\u7F6E
60
- 4. \u8BC6\u522B\u4E3B\u8981\u6A21\u5757\u3001\u5165\u53E3\u70B9\u3001\u6838\u5FC3\u7C7B/\u51FD\u6570
61
- 5. \u5206\u6790\u67B6\u6784\u6A21\u5F0F\u548C\u8BBE\u8BA1\u51B3\u7B56
62
- 6. \u63A8\u65AD\u5F00\u53D1\u89C4\u8303\uFF08\u4EE3\u7801\u98CE\u683C\u3001\u6D4B\u8BD5\u3001\u6784\u5EFA\u6D41\u7A0B\uFF09
67
+ 2. \u63A2\u7D22\u9876\u5C42\u76EE\u5F55\u7ED3\u6784\u548C\u5173\u952E package/product \u8FB9\u754C
68
+ 3. \u8BFB\u53D6 README\u3001ARCHITECTURE\u3001docs/public-api \u7B49\u5DF2\u6709\u6587\u6863\uFF0C\u907F\u514D\u91CD\u590D\u7C98\u8D34
69
+ 4. \u8BC6\u522B\u751F\u6210\u7269\u89C4\u5219\u3001\u6D4B\u8BD5\u95E8\u7981\u3001\u4EE3\u7801\u5206\u5C42\u548C\u9AD8\u98CE\u9669\u6539\u52A8\u8FB9\u754C
70
+ 5. \u751F\u6210\u7B80\u77ED\u3001\u7A33\u5B9A\u3001\u53EF\u7EF4\u62A4\u7684\u76EE\u5F55\u8DEF\u7531\u8BF4\u660E
63
71
 
64
- \u8BF7\u751F\u6210\u5305\u542B\u4EE5\u4E0B\u7AE0\u8282\u7684 agents.md\uFF1A
72
+ \u8BF7\u751F\u6210\u5305\u542B\u4EE5\u4E0B\u7AE0\u8282\u7684 AGENTS.md\uFF1A
65
73
 
66
74
  \`\`\`
67
- # Project: <\u9879\u76EE\u540D\u79F0>
75
+ # AGENTS.md
68
76
 
69
- ## \u6982\u89C8
70
- - \u7C7B\u578B\uFF1A<\u9879\u76EE\u7C7B\u578B>
71
- - \u6280\u672F\u6808\uFF1A<\u4E3B\u8981\u6280\u672F>
72
- - \u4E00\u53E5\u8BDD\u63CF\u8FF0\uFF1A<\u9879\u76EE\u7528\u9014>
77
+ ## How To Use This File
78
+ Briefly explain that this file is an index/router. Agents should read linked docs on demand.
73
79
 
74
- ## \u67B6\u6784\u5206\u6790
75
- - \u6A21\u5757\u5212\u5206
76
- - \u5173\u952E\u7EC4\u4EF6\u8BF4\u660E
77
- - \u4F9D\u8D56\u5173\u7CFB
80
+ ## Repo Map
81
+ - \`path\`
82
+ desc: When to read this directory and what it owns.
78
83
 
79
- ## \u6838\u5FC3\u6587\u4EF6
80
- | \u7528\u9014 | \u8DEF\u5F84 | \u8BF4\u660E |
81
- |------|------|------|
84
+ ## Architecture Rules
85
+ Stable cross-package boundaries only.
82
86
 
83
- ## \u5F00\u53D1\u89C4\u8303
84
- - \u4EE3\u7801\u98CE\u683C
85
- - \u6D4B\u8BD5\u6A21\u5F0F
86
- - \u6784\u5EFA/\u8FD0\u884C\u65B9\u5F0F
87
+ ## Context And Generated Artifacts
88
+ Rules for AGENTS.md, generated bundles, and source-of-truth files.
87
89
 
88
- ## \u63A2\u7D22\u6E05\u5355\uFF08\u5F85\u6DF1\u5165\u7814\u7A76\uFF09
89
- - [ ]
90
+ ## Verification Map
91
+ Which focused tests/checks to run by touched area.
90
92
  \`\`\`
91
93
 
92
- \u8BF7\u4F7F\u7528 write \u5DE5\u5177\u521B\u5EFA \`.pie/agents.md\` \u6587\u4EF6\u3002
93
-
94
- \u5DE5\u4F5C\u76EE\u5F55\uFF1A${cwd}`;
94
+ \u8BF7\u4F7F\u7528 write_file \u5DE5\u5177\u521B\u5EFA\u76EE\u6807\u6587\u4EF6\uFF1A${agentsPath}
95
+ CLI \u6587\u4EF6\u5DE5\u5177\u4F1A\u4EE5\u9879\u76EE\u6839\u76EE\u5F55\u4F5C\u4E3A\u8BBF\u95EE\u8FB9\u754C\uFF1B\u4E0D\u8981\u4F7F\u7528\u989D\u5916\u7684 root \u53C2\u6570\u3002`;
95
96
  }
96
97
  async function initExtension(ctx) {
97
98
  ctx.log("Init extension loaded");
98
99
  let cachedKnowledge = null;
99
100
  try {
100
- cachedKnowledge = await loadExistingKnowledge(ctx.cwd);
101
+ const existing = await loadExistingKnowledge(ctx.cwd);
102
+ cachedKnowledge = existing.content;
101
103
  if (cachedKnowledge) {
102
- const firstLine = cachedKnowledge.split("\n")[0] || "";
103
- const projectName = firstLine.replace(/^#\s*/, "").trim() || "\u9879\u76EE";
104
- ctx.log(`Pre-loaded agents.md (${cachedKnowledge.length} chars)`);
104
+ ctx.log(`Pre-loaded root AGENTS.md (${cachedKnowledge.length} chars) from ${existing.target.agentsPath}`);
105
105
  } else {
106
- ctx.log("No existing agents.md found");
106
+ ctx.log(`No existing root AGENTS.md found at ${existing.target.agentsPath}`);
107
107
  }
108
108
  } catch (err) {
109
- ctx.log(`Failed to pre-load agents.md: ${err}`);
109
+ ctx.log(`Failed to pre-load root AGENTS.md: ${err}`);
110
110
  }
111
111
  ctx.registerCommand({
112
112
  path: ["tools", "init"],
113
- description: "\u7814\u7A76\u9879\u76EE\u5E76\u751F\u6210/\u66F4\u65B0 agents.md \u77E5\u8BC6\u6587\u6863",
113
+ description: "\u7814\u7A76\u9879\u76EE\u5E76\u751F\u6210/\u66F4\u65B0 root AGENTS.md \u9879\u76EE\u4E0A\u4E0B\u6587\u7D22\u5F15",
114
114
  handler: async (ctx2, args) => {
115
- await ensurePieDir(ctx2.cwd);
116
- const existingContent = await loadExistingKnowledge(ctx2.cwd);
117
- const isUpdate = !!existingContent;
115
+ const existing = await loadExistingKnowledge(ctx2.cwd);
116
+ const existingContent = existing.content;
117
+ const isUpdate = !!existing.content;
118
118
  const userIntent = args?.trim();
119
119
  cachedKnowledge = existingContent;
120
120
  if (isUpdate) {
121
121
  if (userIntent) {
122
122
  ctx2.ui.notify(`\u{1F4DD} \u6B63\u5728\u66F4\u65B0\u9879\u76EE\u77E5\u8BC6\uFF08${userIntent}\uFF09...`, "info");
123
123
  } else {
124
- ctx2.ui.notify("\u{1F4DD} \u6B63\u5728\u66F4\u65B0\u9879\u76EE\u77E5\u8BC6...", "info");
124
+ ctx2.ui.notify("\u{1F4DD} \u6B63\u5728\u66F4\u65B0 root AGENTS.md...", "info");
125
125
  }
126
126
  } else {
127
- ctx2.ui.notify("\u{1F50D} \u6B63\u5728\u521D\u59CB\u5316\u9879\u76EE\u7814\u7A76...", "info");
127
+ ctx2.ui.notify("\u{1F50D} \u6B63\u5728\u521D\u59CB\u5316 root AGENTS.md...", "info");
128
128
  }
129
129
  const researchPrompt = buildResearchPrompt({
130
130
  isUpdate,
131
131
  existingContent,
132
132
  userIntent,
133
- cwd: ctx2.cwd
133
+ cwd: ctx2.cwd,
134
+ projectRoot: existing.target.projectRoot,
135
+ agentsPath: existing.target.agentsPath
134
136
  });
135
137
  return researchPrompt;
136
138
  }
@@ -2,8 +2,8 @@ import { createRequire as __createRequire } from "node:module"; const require =
2
2
  import "../../../chunks/chunk-TG2EQLX2.js";
3
3
 
4
4
  // builtin/extensions/kimi-attachments/index.ts
5
- function isKimiProvider(provider) {
6
- return provider === "kimi-cn" || provider === "kimi-api" || provider === "kimi";
5
+ function isKimiAttachmentPlatform(model) {
6
+ return model.attachmentPlatform === "kimi" || model.filePlatform === "kimi";
7
7
  }
8
8
  function getModality(mimeType) {
9
9
  if (mimeType.startsWith("image/")) return "image";
@@ -16,7 +16,7 @@ function kimiAttachmentsExtension(ctx) {
16
16
  name: "kimi-native-attachments",
17
17
  priority: 100,
18
18
  matches(model, attachment) {
19
- return isKimiProvider(model.provider) && Boolean(attachment.fileId) && getModality(attachment.mimeType) !== "file";
19
+ return isKimiAttachmentPlatform(model) && Boolean(attachment.fileId) && getModality(attachment.mimeType) !== "file";
20
20
  },
21
21
  async prepare(_model, attachment, prepareCtx) {
22
22
  const fileId = attachment.fileId;