rlhf-feedback-loop 0.6.10 → 0.6.12

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 (53) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +120 -74
  3. package/adapters/README.md +3 -3
  4. package/adapters/amp/skills/rlhf-feedback/SKILL.md +2 -0
  5. package/adapters/chatgpt/INSTALL.md +6 -3
  6. package/adapters/chatgpt/openapi.yaml +5 -2
  7. package/adapters/claude/.mcp.json +3 -3
  8. package/adapters/codex/config.toml +3 -3
  9. package/adapters/gemini/function-declarations.json +2 -2
  10. package/adapters/mcp/server-stdio.js +19 -5
  11. package/bin/cli.js +295 -25
  12. package/openapi/openapi.yaml +5 -2
  13. package/package.json +25 -9
  14. package/scripts/a2ui-engine.js +73 -0
  15. package/scripts/adk-consolidator.js +267 -0
  16. package/scripts/billing.js +192 -681
  17. package/scripts/code-reasoning.js +26 -1
  18. package/scripts/context-engine.js +86 -4
  19. package/scripts/contextfs.js +130 -0
  20. package/scripts/disagreement-mining.js +315 -0
  21. package/scripts/export-kto-pairs.js +310 -0
  22. package/scripts/feedback-ingest-watcher.js +290 -0
  23. package/scripts/feedback-loop.js +153 -8
  24. package/scripts/feedback-quality.js +139 -0
  25. package/scripts/feedback-schema.js +31 -5
  26. package/scripts/feedback-to-memory.js +13 -1
  27. package/scripts/hook-auto-capture.sh +6 -0
  28. package/scripts/hook-stop-self-score.sh +51 -0
  29. package/scripts/install-mcp.js +168 -0
  30. package/scripts/intent-router.js +88 -0
  31. package/scripts/jsonl-watcher.js +151 -0
  32. package/scripts/local-model-profile.js +207 -0
  33. package/scripts/pr-manager.js +112 -0
  34. package/scripts/prove-adapters.js +137 -15
  35. package/scripts/prove-attribution.js +6 -6
  36. package/scripts/prove-automation.js +41 -8
  37. package/scripts/prove-data-quality.js +16 -8
  38. package/scripts/prove-intelligence.js +7 -4
  39. package/scripts/prove-lancedb.js +7 -7
  40. package/scripts/prove-local-intelligence.js +244 -0
  41. package/scripts/prove-loop-closure.js +16 -8
  42. package/scripts/prove-training-export.js +7 -4
  43. package/scripts/prove-workflow-contract.js +116 -0
  44. package/scripts/reminder-engine.js +132 -0
  45. package/scripts/risk-scorer.js +458 -0
  46. package/scripts/rlaif-self-audit.js +7 -1
  47. package/scripts/self-heal.js +24 -4
  48. package/scripts/status-dashboard.js +155 -0
  49. package/scripts/sync-version.js +159 -0
  50. package/scripts/test-coverage.js +76 -0
  51. package/scripts/validate-workflow-contract.js +287 -0
  52. package/scripts/vector-store.js +115 -17
  53. package/src/api/server.js +372 -25
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.11 - 2026-03-10
4
+
5
+ - Added Inverse Sink Weighting and Anchor-Memory management to prevent runaway negative memory accumulation and stabilize agent behavior over long sessions.
6
+ - Hardened MCP startup reliability: retry logic, process health checks, and graceful degradation on server init failures.
7
+ - North Star Phase 1: KTO export pipeline, MCP install workflow, and FDD (Feedback-Driven Development) rebrand replacing RLHF-loop branding.
8
+ - System hygiene: documented session directives in CLAUDE.md and fixed environment-dependent billing test failures causing flaky CI.
9
+ - A2UI model for dynamic agent-to-user interaction: agents can now emit structured UI events that surface inline prompts, confirmation dialogs, and progress updates.
10
+ - ADK memory consolidator with Gemini integration: deduplicates and ranks cross-session memories using Gemini embeddings for relevance scoring.
11
+ - OpenDev patterns: adaptive context compaction (auto-prune low-signal context items), event-driven reminder injection (surface forgotten constraints mid-session), and model role router (dispatch sub-tasks to appropriately-sized models based on complexity).
12
+
3
13
  ## 0.5.0 - 2026-03-03
4
14
 
5
15
  - Added autonomous GitOps workflows: agent auto-merge, Dependabot auto-merge, self-healing monitor, and merge-branch fallback.
package/README.md CHANGED
@@ -1,107 +1,153 @@
1
- # RLHF-Ready Feedback Loop — Agentic Control Plane & Context Engineering Studio
1
+ # MCP Memory Gateway
2
2
 
3
3
  [![CI](https://github.com/IgorGanapolsky/rlhf-feedback-loop/actions/workflows/ci.yml/badge.svg)](https://github.com/IgorGanapolsky/rlhf-feedback-loop/actions/workflows/ci.yml)
4
- [![Marketplace Ready](https://img.shields.io/badge/Anthropic_Marketplace-Ready-blue)](docs/ANTHROPIC_MARKETPLACE_STRATEGY.md)
5
- [![GEO Optimized](https://img.shields.io/badge/GEO-optimized-orange)](docs/geo-strategy-for-ai-agents.md)
4
+ [![Self-Healing](https://github.com/IgorGanapolsky/rlhf-feedback-loop/actions/workflows/self-healing-monitor.yml/badge.svg)](https://github.com/IgorGanapolsky/rlhf-feedback-loop/actions/workflows/self-healing-monitor.yml)
5
+ [![npm](https://img.shields.io/npm/v/rlhf-feedback-loop)](https://www.npmjs.com/package/rlhf-feedback-loop)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
7
+ [![Node](https://img.shields.io/badge/node-%3E%3D18.18.0-brightgreen)](package.json)
6
8
 
7
- **Stop Vibe Coding. Start Context Engineering.** The RLHF-Ready Feedback Loop is the enterprise-grade **Agentic Control Plane** for AI workflows. We provide the operational layer to capture human preference signals, engineer high-density context packs, and enforce machine-readable guardrails to stop your agents from going "off-script."
9
+ **Local-first memory and feedback pipeline for AI agents.** Captures thumbs-up/down signals, promotes reusable memories, generates prevention rules from repeated failures, and exports KTO/DPO pairs for fine-tuning.
8
10
 
9
- This product captures and structures human feedback data for optimization workflows. It is **RLHF-ready data infrastructure** (not an end-to-end reward-model + RL fine-tuning trainer by itself).
11
+ Works with any MCP-compatible agent: Claude, Codex, Gemini, Amp, Cursor.
10
12
 
11
- ## True Plug-and-Play: Zero-Config Integration
13
+ ## What It Does
12
14
 
13
- The RLHF Feedback Loop is now a **Universal Agent Skill**. You can drop it into any repository without manual setup.
15
+ ```
16
+ thumbs up/down → validate → promote to memory → vector index → prevention rules → DPO export
17
+ ```
14
18
 
15
- - **Zero-Config Discovery:** Automatically detects project context. If no local `.rlhf/` directory exists, it safely fallbacks to a project-scoped global store in `~/.rlhf/`.
16
- - **Global Skill Installation (Optional):** One-command installer is available if you want auto-detection.
17
- - **Vibe-to-Verification (V2V):** Directly converts subjective "vibes" (thumbs up/down) into verifiable repository rules (`CLAUDE.md`).
19
+ 1. **Capture** `capture_feedback` MCP tool accepts signals with context
20
+ 2. **Validate** Rubric engine gates promotion (vague feedback is rejected with clarification prompts)
21
+ 3. **Remember** Promoted memories stored in JSONL + LanceDB vectors
22
+ 4. **Prevent** — Repeated failures auto-generate prevention rules
23
+ 5. **Export** — KTO/DPO pairs for downstream fine-tuning
24
+ 6. **Bridge** — JSONL file watcher auto-ingests signals from external sources (Amp plugins, hooks, scripts)
18
25
 
19
- ### Quick Start (Stable MCP Commands)
26
+ ## Quick Start
20
27
 
21
- Add the MCP server directly in your client config:
28
+ ```bash
29
+ # Add to any MCP-compatible agent
30
+ claude mcp add rlhf -- npx -y rlhf-feedback-loop serve
31
+ codex mcp add rlhf -- npx -y rlhf-feedback-loop serve
32
+ amp mcp add rlhf -- npx -y rlhf-feedback-loop serve
33
+ gemini mcp add rlhf "npx -y rlhf-feedback-loop serve"
34
+
35
+ # Or auto-detect all installed platforms
36
+ npx rlhf-feedback-loop init
37
+ ```
22
38
 
23
- | Platform | Command |
24
- |----------|---------|
25
- | **Claude** | `claude mcp add rlhf -- npx -y rlhf-feedback-loop serve` |
26
- | **Codex** | `codex mcp add rlhf -- npx -y rlhf-feedback-loop serve` |
27
- | **Gemini** | `gemini mcp add rlhf "npx -y rlhf-feedback-loop serve"` |
28
- | **Amp** | `amp mcp add rlhf -- npx -y rlhf-feedback-loop serve` |
29
- | **Cursor** | `cursor mcp add rlhf -- npx -y rlhf-feedback-loop serve` |
39
+ ## MCP Tools
30
40
 
31
- Optional auto-installer:
41
+ | Tool | Description |
42
+ |------|-------------|
43
+ | `capture_feedback` | Accept up/down signal + context, validate, promote to memory |
44
+ | `recall` | Vector-search past feedback and prevention rules for current task |
45
+ | `feedback_stats` | Approval rate, per-skill/tag breakdown, trend analysis |
46
+ | `feedback_summary` | Human-readable recent feedback summary |
47
+ | `prevention_rules` | Generate prevention rules from repeated mistakes |
48
+ | `export_dpo_pairs` | Build DPO preference pairs from promoted memories |
49
+ | `construct_context_pack` | Bounded context pack from contextfs |
50
+ | `evaluate_context_pack` | Record context pack outcome (closes learning loop) |
51
+ | `list_intents` | Available action plan templates |
52
+ | `plan_intent` | Generate execution plan with policy checkpoints |
53
+ | `context_provenance` | Audit trail of context decisions |
54
+
55
+ ## CLI
32
56
 
33
57
  ```bash
34
- npx add-mcp rlhf-feedback-loop
58
+ npx rlhf-feedback-loop init # Scaffold .rlhf/ + configure MCP
59
+ npx rlhf-feedback-loop serve # Start MCP server (stdio) + watcher
60
+ npx rlhf-feedback-loop status # Learning curve dashboard
61
+ npx rlhf-feedback-loop watch # Watch .rlhf/ for external signals
62
+ npx rlhf-feedback-loop watch --once # Process pending signals and exit
63
+ npx rlhf-feedback-loop capture # Capture feedback via CLI
64
+ npx rlhf-feedback-loop stats # Analytics + Revenue-at-Risk
65
+ npx rlhf-feedback-loop rules # Generate prevention rules
66
+ npx rlhf-feedback-loop export-dpo # Export DPO training pairs
67
+ npx rlhf-feedback-loop risk # Train/query boosted risk scorer
68
+ npx rlhf-feedback-loop self-heal # Run self-healing diagnostics
35
69
  ```
36
70
 
37
- - **Stop Regressions:** Automatically convert negative feedback into `CLAUDE.md` / `AGENTS.md` prevention rules.
38
- - **Preference Data Engineering:** Capture high-density context (rubrics, guardrails, metadata) for DPO training.
39
- - **Bayesian Scoring:** Use Thompson Sampling to handle evolving user preferences over time.
71
+ ## JSONL File Watcher
40
72
 
41
- ## Use Cases
73
+ The `serve` command automatically starts a background watcher that monitors `feedback-log.jsonl` for entries written by external sources (Amp plugins, shell hooks, CI scripts). These entries are routed through the full `captureFeedback()` pipeline — validation, memory promotion, vector indexing, and DPO eligibility.
42
74
 
43
- - **Automated Code Reviews:** Capture PR feedback to enforce team-specific style guides autonomously.
44
- - **Self-Healing Multi-Agent Systems:** Share prevention rules across a swarm of agents to avoid systemic bottlenecks.
45
- - **Custom LLM Fine-tuning:** Collect proprietary preference data to train smaller, faster models that perform like GPT-4 on your specific codebase.
75
+ ```bash
76
+ # Standalone watcher
77
+ npx rlhf-feedback-loop watch --source amp-plugin-bridge
46
78
 
47
- ## Generative Engine Optimization (GEO)
79
+ # Process pending entries once and exit
80
+ npx rlhf-feedback-loop watch --once
81
+ ```
48
82
 
49
- We are optimized for discovery by next-gen AI tools (Claude Code, Gemini CLI, Perplexity). See our [GEO Strategy](docs/geo-strategy-for-ai-agents.md) for how we use **Context-First Publishing** to remain the first-choice recommendation for agent reliability.
83
+ External sources write entries with a `source` field:
84
+ ```json
85
+ {"signal":"positive","context":"Agent fixed bug on first try","source":"amp-plugin-bridge","tags":["amp-ui-bridge"]}
86
+ ```
50
87
 
51
- ## Get Started
88
+ The watcher tracks its position via `.rlhf/.watcher-offset` for crash-safe, idempotent processing.
52
89
 
53
- Run one `mcp add` command for your client. The server starts on each session and can capture feedback, recall past learnings, and block repeated mistakes.
90
+ ## Learning Curve Dashboard
54
91
 
55
- ## How It Works
92
+ ```bash
93
+ npx rlhf-feedback-loop status
94
+ ```
56
95
 
57
96
  ```
58
- Thumbs up/down
59
- |
60
- v
61
- Capture JSONL log
62
- |
63
- v
64
- Rubric engine (block false positives)
65
- |
66
- +---+---+
67
- | |
68
- Good Bad
69
- | |
70
- v v
71
- Learn Prevention rule
72
- | |
73
- v v
74
- LanceDB ShieldCortex
75
- vectors context packs
76
- |
77
- v
78
- DPO export → fine-tune your model
97
+ ╔══════════════════════════════════════╗
98
+ ║ RLHF Learning Curve Dashboard ║
99
+ ╠══════════════════════════════════════╣
100
+ Total signals: 148 ║
101
+ ║ Positive: 45 (30%) ║
102
+ ║ Negative: 103 (70%) ║
103
+ Recent (last 20): 20% ║
104
+ ║ Trend: 📉 declining ║
105
+ ║ Memories: 17 ║
106
+ ║ Prevention rules: 9 ║
107
+ ╠══════════════════════════════════════╣
108
+ ║ Top failure domains: ║
109
+ ║ execution-gap 4 ║
110
+ asked-not-doing 2 ║
111
+ ║ speed 2 ║
112
+ ╠══════════════════════════════════════╣
113
+ ║ Learning curve (approval % by window)║
114
+ [1-10] 10% ██ ║
115
+ ║ [11-20] 20% ████ ║
116
+ ║ [21-30] 35% ███████ ║
117
+ ║ [31-40] 30% ██████ ║
118
+ ╚══════════════════════════════════════╝
79
119
  ```
80
120
 
81
- All data stored locally as **JSONL** files — fully transparent, fully portable, no vendor lock-in. **LanceDB** indexes memories as vector embeddings for semantic search. **ShieldCortex** assembles context packs so your agent starts each task informed.
82
-
83
- ## Free vs. Cloud Pro
121
+ ## Architecture
84
122
 
85
- The open-source package is fully functional and free forever. Cloud Pro is for teams that don't want to self-host.
123
+ Five-phase pipeline: **Capture** **Validate** **Remember** **Prevent** **Export**
86
124
 
87
- | | Open Source | Cloud Pro ($49/mo) |
88
- |---|---|---|
89
- | Feedback capture | Local MCP server | Hosted HTTPS API |
90
- | Storage | Your machine | Managed cloud |
91
- | DPO export | CLI command | API endpoint |
92
- | Setup | `mcp add` one-liner | Provisioned API key |
93
- | Team sharing | Manual (share JSONL) | Built-in (shared API) |
94
- | Support | GitHub Issues | Email |
95
- | Uptime | You manage | We manage (99.9% SLA) |
96
-
97
- [Get Cloud Pro](https://buy.stripe.com/bJe14neyU4r4f0leOD3sI02) | [Live API](https://rlhf-feedback-loop-710216278770.us-central1.run.app) | [Verification Evidence](docs/VERIFICATION_EVIDENCE.md)
125
+ ```
126
+ Agent (Claude/Codex/Amp/Gemini)
127
+
128
+ ├── MCP tool call ──→ captureFeedback()
129
+ ├── REST API ────────→ captureFeedback()
130
+ ├── CLI ─────────────→ captureFeedback()
131
+ └── External write ──→ JSONL ──→ Watcher ──→ captureFeedback()
132
+
133
+
134
+ ┌─────────────────┐
135
+ │ Full Pipeline │
136
+ │ • Schema valid │
137
+ │ • Rubric gate │
138
+ │ • Memory promo │
139
+ │ • Vector index │
140
+ │ • Risk scoring │
141
+ │ • RLAIF audit │
142
+ │ • DPO eligible │
143
+ └─────────────────┘
144
+ ```
98
145
 
99
- ## Deep Dive
146
+ ## Agent Runner Contract
100
147
 
101
- - [API Reference](openapi/openapi.yaml) full OpenAPI spec
102
- - [Context Engine](docs/CONTEXTFS.md) multi-agent memory orchestration
103
- - [Autonomous GitOps](docs/AUTONOMOUS_GITOPS.md) — self-healing CI/CD
104
- - [Contributing](CONTRIBUTING.md)
148
+ - [WORKFLOW.md](WORKFLOW.md): scope, proof-of-work, hard stops, and done criteria for isolated agent runs
149
+ - [.github/ISSUE_TEMPLATE/ready-for-agent.yml](.github/ISSUE_TEMPLATE/ready-for-agent.yml): bounded intake template for "Ready for Agent" tickets
150
+ - [.github/pull_request_template.md](.github/pull_request_template.md): proof-first handoff format for PRs
105
151
 
106
152
  ## License
107
153
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  - `chatgpt/openapi.yaml`: import into GPT Actions.
4
4
  - `gemini/function-declarations.json`: Gemini function-calling definitions.
5
- - `mcp/server-stdio.js`: local MCP server for Claude/Codex.
6
- - `claude/.mcp.json`: example Claude Code MCP config.
7
- - `codex/config.toml`: example Codex MCP profile section.
5
+ - `mcp/server-stdio.js`: underlying local MCP stdio server implementation.
6
+ - `claude/.mcp.json`: example Claude Code MCP config using `npx -y rlhf-feedback-loop@0.6.12 serve`.
7
+ - `codex/config.toml`: example Codex MCP profile section using the same version-pinned portable launcher.
8
8
  - `amp/skills/rlhf-feedback/SKILL.md`: Amp skill template.
@@ -12,6 +12,8 @@ node .claude/scripts/feedback/capture-feedback.js --feedback=up --context="..."
12
12
  node .claude/scripts/feedback/capture-feedback.js --feedback=down --context="..." --tags="..."
13
13
  ```
14
14
 
15
+ Do not claim promotion from a bare `thumbs up/down`. Ask for one sentence describing what worked or failed first.
16
+
15
17
  Before major implementation:
16
18
 
17
19
  ```bash
@@ -52,17 +52,20 @@ Click **Test** on the `captureFeedback` action:
52
52
  ```json
53
53
  {
54
54
  "signal": "up",
55
- "context": "GPT Actions install verified"
55
+ "context": "GPT Actions install verified with a successful test call",
56
+ "whatWorked": "The hosted action returned accepted=true and a promoted status"
56
57
  }
57
58
  ```
58
59
 
59
- Expected response: `200 OK` with `{ "id": "fb-...", "status": "captured" }`.
60
+ Expected response: `200 OK` with `{ "accepted": true, "status": "promoted" }`.
61
+
62
+ If you only send a bare `thumbs up/down` style payload, expect `422` with `status: "clarification_required"` and a follow-up `prompt`.
60
63
 
61
64
  ## Available Actions
62
65
 
63
66
  | Action | Method | Path | Description |
64
67
  |---|---|---|---|
65
- | `captureFeedback` | POST | `/v1/feedback/capture` | Capture thumbs up/down signal |
68
+ | `captureFeedback` | POST | `/v1/feedback/capture` | Capture up/down signal plus one-line why |
66
69
  | `getFeedbackStats` | GET | `/v1/feedback/stats` | Aggregated feedback statistics |
67
70
  | `getFeedbackSummary` | GET | `/v1/feedback/summary` | Recent feedback summary |
68
71
  | `generatePreventionRules` | POST | `/v1/feedback/rules` | Generate prevention rules |
@@ -5,6 +5,8 @@ info:
5
5
  description: |
6
6
  Production API for feedback capture, schema-validated memory promotion,
7
7
  prevention rule generation, and DPO export.
8
+ Bare up/down signals are logged immediately, but the API returns
9
+ clarification_required until one sentence explains what worked or failed.
8
10
  servers:
9
11
  - url: https://rlhf-feedback-loop-710216278770.us-central1.run.app
10
12
  security:
@@ -32,13 +34,14 @@ components:
32
34
  type: string
33
35
  CaptureFeedbackRequest:
34
36
  type: object
35
- required: [signal, context]
37
+ required: [signal]
36
38
  properties:
37
39
  signal:
38
40
  type: string
39
41
  enum: [up, down, positive, negative]
40
42
  context:
41
43
  type: string
44
+ description: One-sentence reason describing what worked or failed
42
45
  whatWentWrong:
43
46
  type: string
44
47
  whatToChange:
@@ -155,7 +158,7 @@ paths:
155
158
  '200':
156
159
  description: Feedback accepted and promoted to memory
157
160
  '422':
158
- description: Feedback recorded but rejected for memory promotion
161
+ description: Feedback logged only; clarification required or promotion rejected
159
162
  '401':
160
163
  description: Unauthorized
161
164
  /v1/feedback/stats:
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "mcpServers": {
3
- "rlhf-feedback-loop": {
4
- "command": "node",
5
- "args": ["adapters/mcp/server-stdio.js"]
3
+ "rlhf": {
4
+ "command": "npx",
5
+ "args": ["-y", "rlhf-feedback-loop@0.6.12", "serve"]
6
6
  }
7
7
  }
8
8
  }
@@ -1,4 +1,4 @@
1
1
  # Codex MCP profile (copy into ~/.codex/config.toml or merge section)
2
- [mcp_servers.rlhf_feedback_loop]
3
- command = "node"
4
- args = ["adapters/mcp/server-stdio.js"]
2
+ [mcp_servers.rlhf]
3
+ command = "npx"
4
+ args = ["-y", "rlhf-feedback-loop@0.6.12", "serve"]
@@ -2,7 +2,7 @@
2
2
  "tools": [
3
3
  {
4
4
  "name": "capture_feedback",
5
- "description": "Capture thumbs-up/down feedback and promote actionable memories",
5
+ "description": "Capture an up/down signal plus one line of why. Vague feedback is logged and returned with a clarification prompt instead of memory promotion.",
6
6
  "parameters": {
7
7
  "type": "object",
8
8
  "properties": {
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "skill": { "type": "string" }
39
39
  },
40
- "required": ["signal", "context"]
40
+ "required": ["signal"]
41
41
  },
42
42
  "http": {
43
43
  "method": "POST",
@@ -58,13 +58,13 @@ function resolveSafePath(inputPath, { mustExist = false } = {}) {
58
58
  const TOOLS = [
59
59
  {
60
60
  name: 'capture_feedback',
61
- description: 'Capture thumbs up/down feedback and promote actionable memory',
61
+ description: 'Capture an up/down signal plus one line of why. Vague feedback is logged, then returned with a clarification prompt instead of memory promotion.',
62
62
  inputSchema: {
63
63
  type: 'object',
64
- required: ['signal', 'context'],
64
+ required: ['signal'],
65
65
  properties: {
66
66
  signal: { type: 'string', enum: ['up', 'down'] },
67
- context: { type: 'string' },
67
+ context: { type: 'string', description: 'One-sentence reason describing what worked or failed' },
68
68
  whatWentWrong: { type: 'string' },
69
69
  whatToChange: { type: 'string' },
70
70
  whatWorked: { type: 'string' },
@@ -234,6 +234,15 @@ function toText(result) {
234
234
  return JSON.stringify(result, null, 2);
235
235
  }
236
236
 
237
+ function formatCaptureFeedbackResult(result) {
238
+ const message = result.accepted
239
+ ? 'Feedback promoted to reusable memory.'
240
+ : result.needsClarification
241
+ ? result.message
242
+ : 'Signal logged, but reusable memory was not created.';
243
+ return toText({ ...result, message });
244
+ }
245
+
237
246
  function parseOptionalObject(input, name) {
238
247
  if (input == null) return {};
239
248
  if (typeof input === 'object' && !Array.isArray(input)) return input;
@@ -328,6 +337,11 @@ async function callTool(name, args = {}) {
328
337
  tags: ['auto-capture', 'mcp'],
329
338
  });
330
339
  const ev = autoResult.feedbackEvent || {};
340
+ const promotionLine = autoResult.accepted
341
+ ? `yes (Memory ID: ${(autoResult.memoryRecord || {}).id})`
342
+ : autoResult.needsClarification
343
+ ? `no — clarification required: ${autoResult.prompt}`
344
+ : `no — ${autoResult.reason || ''}`;
331
345
  const autoReport = [
332
346
  '',
333
347
  `## Auto-Captured Feedback [${autoSignal.toUpperCase()}]`,
@@ -335,7 +349,7 @@ async function callTool(name, args = {}) {
335
349
  ` Signal : ${ev.signal || autoSignal} (${ev.actionType || 'unknown'})`,
336
350
  ` Context : ${(ev.context || textToCheck).slice(0, 80)}`,
337
351
  ` Timestamp : ${ev.timestamp || new Date().toISOString()}`,
338
- ` Promoted : ${autoResult.accepted ? 'yes (Memory ID: ' + (autoResult.memoryRecord || {}).id + ')' : 'no — ' + (autoResult.reason || '')}`,
352
+ ` Promoted : ${promotionLine}`,
339
353
  '',
340
354
  formatStats(),
341
355
  ].join('\n');
@@ -433,7 +447,7 @@ async function callToolInner(name, args = {}) {
433
447
  }
434
448
  } catch (_) {}
435
449
 
436
- return { content: [{ type: 'text', text: toText(result) + recallText }] };
450
+ return { content: [{ type: 'text', text: formatCaptureFeedbackResult(result) + recallText }] };
437
451
  }
438
452
 
439
453
  if (name === 'feedback_summary') {