Skip to content

feat(api): add standalone profile and rules routes - #185

Merged
modusensus merged 1 commit into
slow-stack:mainfrom
z2Ace0107:codex/issue-180-profile-rules
Sep 15, 2026
Merged

modusensus merged 1 commit into
slow-stack:mainfrom
z2Ace0107:codex/issue-180-profile-rules

Conversation

@z2Ace0107

@z2Ace0107 z2Ace0107 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add authenticated GET /profile and GET /rules routes to the standalone API.
  • Reuse the existing profile and rules settings semantics, including empty-value responses.
  • Add authentication, saved-value, and unset-value regression tests.
  • Document the new routes in the external API README section.

Validation

  • npm run sync
  • npm test (1029 passed)

Fixes #180

Summary by CodeRabbit

  • 新功能
    • 新增受认证保护的 GET /profile 接口,返回用户画像;未设置时返回空字符串。
    • 新增受认证保护的 GET /rules 接口,返回行为规则列表;未设置时返回空数组。
    • 两个接口均返回 HTTP 200,并继续要求 Bearer Token 认证。

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 6f020d80-6729-46d3-81de-e7999bb5c38c

📥 Commits

Reviewing files that changed from the base of the PR and between c95019a and c4dc1c4.

📒 Files selected for processing (4)
  • dsh-mneme/README.md
  • dsh-mneme/lib/api-standalone.js
  • dsh-mneme/src/api-standalone.js
  • dsh-mneme/test/standalone-api.test.js

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

独立 API 新增经过 Bearer token 认证的 GET /profile 和 GET /rules 路由。路由分别返回用户画像和规则列表,未设置时返回空字符串和空数组。文档与测试同步更新。

Changes

独立 API 读取路由

Layer / File(s) Summary
路由契约与实现
dsh-mneme/src/api-standalone.js, dsh-mneme/lib/api-standalone.js, dsh-mneme/README.md
新增 GET /profile 和 GET /rules。接口分别返回用户画像和规则列表,未设置时返回 "" 和 [],状态码为 200。文档记录两个响应格式。
认证与接口验证
dsh-mneme/test/standalone-api.test.js
认证测试验证新增路由需要 token。接口测试覆盖已保存设置和未设置时的返回值及状态码。

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature · Severity of issue fixed: Medium

Suggested reviewers: modusensus

Merge Risk: ⚪ Minimal · up to c4dc1

The new authenticated read-only routes provide the requested profile and rules values, including safe empty defaults, with no remaining merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更,即为独立 API 新增 profile 和 rules 路由。标题简洁、明确,并与代码、测试和文档变更一致。
Linked Issues check ✅ Passed 针对 #180 的编码要求,PR 在 src/api-standalone.js 和 lib/api-standalone.js 增加了已认证的 GET /profile 与 GET /rules。/profile 调用 settings.getProfile(),未设置时返回 { profile: "" }。/rules 调用 `settings.getRules…
Out of Scope Changes check ✅ Passed 变更仅涉及 standalone API 的两个只读路由、对应构建产物、路由测试和外部 API README 文档。这些变更直接支持 #180 的功能、鉴权、空值处理和测试要求。未发现与该 issue 无关的功能变更。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (1 skipped: 1 …
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@modusensus modusensus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本地全量复验通过:1029 项(1028 pass + 1 环境 skip)、零失败,与声明的 1029 一致。

实现与 #180 拍板的契约逐项吻合:根路径 GET /profile / GET /rules、Bearer 圈内、{profile}/{rules} 形状、未设置 200 空值、settings?.getProfile?.() 的防御式取值与现有代码风格一致,README 路由表两行、lib 同步随 PR 附带,还主动把两条新路由挂进了 401 负向测试。

首单贡献质量很高,感谢!已批准合并。🎉

@modusensus
modusensus merged commit 596348f into slow-stack:main Sep 15, 2026
6 checks passed
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.

[Feature] standalone API 补 profile / rules 只读路由(外部工具可读用户画像)

2 participants