分享一份自己的agents.md,配合pi+trellis用起来很舒服

土豆教主 2026-06-05 11:44 1

原始版本也是从某位佬的评论获取到的,然后找ds4修修补补,做做加减法,目前用的挺舒畅,遵循指令强的模型,基本都会按照流程走,token消耗也挺好的,pi有一说一,确实用起来非常之香。



## Global Agent Rules
**These rules are MANDATORY. Violation invalidates output.**

### System env
Windows 11, MSYS2 bash(run in Terminal), node v24.11.1, npm v11.14.1, go v1.26.2

### Language
Keep replies concise, always use Chinese.

### Working Style
Senior engineer mode: conclusion → short context → stop. State assumptions openly. No feature creep. Only refactor to fix root cause. Launch-ready = passes targeted tests.

### Coding Standards
Complexity ≤6, nesting ≤2. Early returns, guard clauses, no else after return. No implicit state changes. Reuse ≥2 for new abstraction. APIs ≤3 params, explicit returns. Comments = why, not what.
- **Concurrency readiness**: Non-obviously safe functions must be documented with their concurrency semantics (e.g., `// safe for concurrent calls` or `// caller must hold lock`).

### Debug Policy
Root cause fix only, no symptom patches. Explicit errors: no silent catch/default/??/panic; return errors. Structural: dedup, single source, redesign shared state, encode invariants. Verify with failing test.

### Performance & Concurrency
Assume concurrent calls. Guard shared state. No unbounded blocking. Bound goroutines/queues. Avoid per-op allocations in hot paths. Document concurrency semantics.

### Skill & Plugin Invocation (Conditional Gate)
**Before writing any code, you MUST output a decision line:**

`// DECISION: skill_needed=<true/false> reason=<short reason>`

**Then follow these rules:**

- If `SKILL.md` exists **and** its instructions cover the current task (e.g., build, test, deploy):
`skill_needed = true` → you MUST invoke `skill` as specified. Do NOT write code that bypasses it.

- If `SKILL.md` does not exist, is incomplete, or its content is irrelevant to the current request:
`skill_needed = false` → skip invocation. Do NOT invent a call.

- For plugins: only call `plugin.install(<name>)` if the task **explicitly requires** a capability that only that plugin provides (e.g., language-specific formatter, linter). Otherwise, no call.

**If uncertain whether SKILL.md applies:** default to `skill_needed = false` and note uncertainty in reason.

**Violation:** calling skill/plugin when not needed, or failing to call when needed → invalid output.

### Execution Rules
**Before any action, classify task complexity:**
- **Trivial** (single line/function fix, obvious syntax/typo/copy-paste error): respond directly with fix. No sub-agent, no extra tool, no Trellis command.
- **Simple** (affects ≤3 files, no new architecture): state fix then minimal changes. Sub-agent forbidden.
- **Complex** (requires research, multi-file coordination, design decision): then follow multi-step: state goal + first action.

Then: Read first. Minimal changes only (dead code, duplicates, branches). Follow `SKILL.md` if exists and complete; else note gap.

### Sub-agent Restriction
**Never spawn sub-agents for trivial or simple fixes. Direct response only.** If you cannot solve directly, state what you need rather than delegating.

### Validation
Targeted test first (red→green) → type/lint/build must pass → minimal smoke. Run runtime if possible; if not, state blocker explicitly. Static checks ≠ runtime verification.

### Stop Rule
After each output: if request satisfied, stop immediately. Evidence = requested item exists, not "enough". No extra search or polish.
最新回复 (16)
  • eman 06-05 13:05
    1

    感谢佬友分享,我也来试试好不好用

  • 吴昊 06-05 13:20
    2

    我让gpt5.5 和sonnet4.6 给看了看 结论如下



  • 我张三 06-05 13:24
    3

    Sonnet4.6就拉倒吧,什么go1.26不存在,Node24不存在

  • 凌风神舞 06-05 15:26
    4

    这个是否因为没有开联网造成的, 基于自身数据库造成的错误

  • Okamitimo233 06-05 15:40
    5

    佬能分享一下自己在用哪些插件吗,最近刚开始用pi

  • 土豆教主 楼主 06-05 16:02
    6

    “packages”: [

    “npm:pi-smart-fetch”,

    “npm:@juicesharp/rpiv-ask-user-question”,

    “npm:pi-mcp-adapter”,

    “npm:@sherif-fanous/pi-rtk”,

    “npm:pi-blackhole”,

    “npm:pi-until-done”,

    “npm:@ff-labs/pi-fff”,

    “npm:pi-markdown-preview”,

    “npm:pi-nano-context”,

    “npm:pi-tool-display”,

    “npm:pi-workspace-history”,

    “npm:pi-simplify”

    ]

  • 倒挂的梦 06-06 17:53
    7

    这个blackhole是真的好用。除了判定阈值是agent_end压缩,而不是turn_end压缩。我开codex-goal模式,goal没完成不可能agent_end。所以超出设定的180k也不压缩,只有api超限报错了才会压缩,不过也还是好用。

  • 土豆教主 楼主 06-06 18:06
    8

    欸,是嘛,那还是挺不错的,不过其实可以考虑直接用pi,然后把模型的上下文改为80%,这样就可以直接触发自动压缩了,并且一定有余额

  • hhnnjjcc 06-06 18:08
    9

    我有一个疑问,我是github copilot的订阅,我发现用pi比opencode消耗的token要多很多,问了一下AI,说pi是把上下文完整发送导致占用很多token,opencode就相对要聪明一些,也不知道你们有没有这个感觉?

  • 土豆教主 楼主 06-06 18:10
    10

    暂时没遇到欸,我每次的请求都很少的token,codex可能是0.6左右,pi在0.4这种,或者更好

  • 倒挂的梦 06-06 18:11
    11

    嗯嗯,我用的是pi + gpt5.5,装了一个codex goal extension,发现goal的过程中,blackhole里面设置180k token的阈值被超过后是不会自动压缩的,因为没有处于agent_end后的idle状态,但是超过272k肯定能压缩,这是5.5层面的报错,我还没试过把最大上下文减小,现在用着也还行。

  • hhnnjjcc 06-06 18:11
    12

    也不知道是不是我的错觉,反正现在不太敢用pi了。其实还是很喜欢的。如果不太计较token的话

  • 土豆教主 楼主 06-06 18:12
    13

    我用的不是codex那个,我用的是pi-until-done,这个目前给我的感觉还行?但是有点跟trellis冲突的感觉吧

  • 土豆教主 楼主 06-06 18:18
    14

    你是装了什么插件吗,原生pi提示词只有1k,不可能占用那么多上下文的。

  • hhnnjjcc 06-06 19:24
    15

    没有,就是开盒即用。我用的copilot,看token刷刷的掉 :(

  • 123456 07-02 07:56
    16

    感谢佬友分享,我也来试试好不好用

* 帖子来源Linux.do
返回