feat(rules): acp_rule persistent rules — state field, helpers, hard protection - #283
ranxianglei wants to merge 2 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)In your adapter project: npm install acp-kernel@pr-283Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf acp-kernel-pr283.tgz
npm install ./packageThis comment is automatically updated on each push. |
PR #283 reviewed — the acp_rule contribution is clean and green. Why the GitHub "Files changed" view looks bigger than the description (stacking, not scope creep):
It does not touch
Confirmed neither is in master yet: master head Verification (ran locally on head
Code quality: solid. Immutable updates, legacy-state tolerance ( Recommendation — land the base first, no rebase:
Once #280 + #279 are in master, GitHub will show #283 as acp_rule-only with zero extra work. Do not rebase #283 onto master — that would strip the release stacking and is the wrong move for a feature slated to ride on top of v0.0.69. Minor, non-blocking: I can't merge PRs — agent rule forbids it. Please merge yourself, in the order above. 中文摘要:已核对——本 PR 的 acp_rule 提交( |
…g.rules Per owner feedback on billion-context-pi#433: acp_rule stays an ordinary tool with a single optional 'rule' argument — value records a rule, omitted lists them. No remove/clear in the tool surface, no system prompt injection: usage guidance lives only in the tool description. Rules are hard-protected from compression by default (call/result pairs stay in context as the durable record). - rules.ts: drop RULES_USAGE_PROMPT/formatRulesForPrompt; add RULE_TOOL, RULE_TOOL_OPENAI, RULE_TOOL_RESPONSES schemas, rulesEnabled(), resolveRuleLimits(); rename formatRulesForPrompt -> formatRulesList - types.ts: RuleFeatureConfig + Config.rules (absent/disabled = off) - config.ts: validateConfig checks for rules.maxRules/maxRuleChars
|
This PR is superseded by #332 (branch What survived from this PR into #332: the What #332 took from #284 instead: monotonic Recommend closing in favor of #332. Pre-flight there: typecheck PASS · 861/861 tests · build PASS. |
Verified every claim in the supersession note against branch What I checked
Result: #283 closed unmerged, superseded by #332. Note #284 is still open and needs the same close treatment when you get to it. 中文摘要:已逐条核实 #332( |
Closes #282 (跨仓功能 billion-context-pi#433 的内核侧实现)
变更
src/types.ts:RuleRecord {id, text}+CompressionState.rules?(可选字段,旧状态向后兼容)src/rules.ts(新):RULE_TOOL_NAME、DEFAULT_RULE_LIMITS {maxRules:50, maxRuleChars:300}、listRules、allocateRuleId、addRule(非空/超长/去重/条数上限校验)、removeRule、clearRules、formatRulesForPrompt(系统提示词注入渲染)、RULES_USAGE_PROMPT(模型使用说明:用户反复强调的教训/要求记住的行为/自己撞到的大坑,简短原则性记录)src/protected.ts:ALWAYS_PROTECTED_TOOLS增加"acp_rule"—— 调用+结果默认永久受保护,压缩范围硬排除(#433 第 1 点)src/state.ts:createInitialState初始化rules: []src/index.ts: barrel 导出tests/rules.test.ts(新): 10 个测试,含压缩排除保护集成测试(仿 protected-content.test.ts)设计说明
验证
npm run typecheck✅npm test:748/748 通过