Skip to content

feat: add /acp-rule human command to list and record session rules - #528

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-24_acp-rule-command
Sep 24, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-24_acp-rule-command

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #527

What

Ports the /acp-rule human command from billion-context #1259 (issue #1251) to this pi-native repo, mirroring the /acp-cache human-command pattern:

  • /acp-rule (bare) — lists every rule recorded in the current session (id + text) via kernel listRules/formatRulesList, sent to the transcript as an acp-rule custom message. Friendly No rules recorded. when the list is empty.
  • /acp-rule <text> — records a rule directly through the same kernel API the model-facing acp_rule tool uses (addRule + resolveRuleLimits, feat(#433): wire acp_rule record tool behind opt-in rules config #490): persisted in the session sidecar, injected via system prompt on the next round, and echoed with the same Recorded ruleN: <text> confirmation as the model path.
  • Feature-off gate — when rules is not enabled, both paths show a warning pointing at "rules": true in acp.json instead of an empty list or a silent record.
  • Zero model-context pollution — the output is a UI-only custom message excluded by entriesToCoreMessages (same exclusion set as acp-status/acp-export); rules reach the model once per round via system-prompt injection, never duplicated. Falls back to raw-text ui.notify on hosts without sendMessage (issue Show /acp-status as persistent output instead of a notification #255).
  • delete/clear subcommands are intentionally out of scope, matching bili #1259 (upstream kernel wiring PR not merged).

Files

  • src/messages.ts — ACP_RULE_CUSTOM_TYPE const + added to the UI-only exclusion set in entriesToCoreMessages
  • src/commands.ts — /acp-rule registration next to /acp-cache
  • src/config.ts, src/user-config.ts — expose rules (and coreOverrides.rules) on AdapterConfig/ConfigOverrides via asRules() guard
  • tests/rule-command.test.ts — list / record / restart-persistence / validation-error-verbatim / feature-off hint / notify-fallback
  • tests/messages.test.ts — strip-path: acp-rule custom messages never project to the model
  • tests/integration.test.ts — command registry updated (9 flat commands)

Differences vs bili PR #1259

  • bili routes through its proxy tool-forward; here the command calls kernel addRule/listRules directly (same APIs its forward resolves to) and persists via runtime.save.
  • Feature-off is detected from runtime.adapter.rules instead of a proxy reply; validation errors are surfaced as an error toast (repo command convention) rather than a transcript message.

Gates

Rebased on current master (post-#525):

npm run typecheck  # clean
npm test           # 932 pass, 0 fail (3 pre-existing skips; delegate tests must run without PI_ACP_DELEGATE_* env)
npm run build      # success

No package.json version bump; no auto-merge — leaving review/merge to humans.

Mirrors the /acp-cache human-command pattern for the acp_rule feature
(#490): bare /acp-rule lists all rules recorded in the current session,
/acp-rule <text> records one via the same kernel API the model path
uses (persisted in the session sidecar, injected next round). Output is
transcript-only and stripped from model context via the same custom-type
exclusion in entriesToCoreMessages; falls back to ui.notify on hosts
without sendMessage. Ported from billion-context #1259 (issue #1251).

Fixes #527
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Extension Artifact

Branch: 2026-09-24_acp-rule-command (f9e752f)

Option A — Install from npm PR tag (recommended)

pi install npm:billion-context-pi@pr-528

Each push to this PR publishes a new version under the pr-528 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pi-pr528.tgz
pi install ./package

This comment is automatically updated on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到,正在按 PR Review 规范审查本 PR(方向关 → 回归 → 代码 → 测试有效性 → diff 整洁度)。分支已拉取(f9e752f,base = 当前 master 91dc629,无 stale-base)。初步确认:单 commit、7 文件 +203/-10,范围收敛。详细结论稍后回帖。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] port /acp-rule human command from billion-context#1259

1 participant