Skip to content

fix: CI typecheck, hook type safety, ESLint alignment, and documentation accuracy#222

Merged
hotlong merged 6 commits intomainfrom
copilot/improve-repo-scan-suggestions
Feb 21, 2026
Merged

fix: CI typecheck, hook type safety, ESLint alignment, and documentation accuracy#222
hotlong merged 6 commits intomainfrom
copilot/improve-repo-scan-suggestions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 21, 2026

Description

Addresses repository-wide quality improvements identified by a full codebase scan: CI gaps, any type proliferation in hook helpers, mismatched ESLint versions, stale docs, and broken workflow paths.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • CI/CD update

Related Issues

Related to #221

Changes Made

CI/CD

  • Add pnpm typecheck step to ci.yml — was missing entirely
  • Fix code-quality.yml: replace non-existent src/ paths with packages/, swap pnpm build for pnpm typecheck

Type Safety — Hook Helpers

  • Replace ctx: anyctx: HookContext in helper functions across 18 hook files (CRM, HR, Marketing, Products, Support)
  • Replace bare campaign: any, employee: any etc. → Record<string, any> for data record params
  • HookContext was already imported in every file but unused in helpers:
// Before
async function handleClosedWon(ctx: any): Promise<void> { ... }

// After
async function handleClosedWon(ctx: HookContext): Promise<void> { ... }

ESLint

  • Align @typescript-eslint/parser ^6.21.0^7.18.0 to match @typescript-eslint/eslint-plugin ^7.18.0
  • Regenerate pnpm-lock.yaml to reflect the parser version bump (fixes Vercel ERR_PNPM_OUTDATED_LOCKFILE build failure)

Documentation

  • DEVELOPMENT_WORKFLOW.md: remove hardcoded "1,759 tests" count; update hook examples to use HookContext
  • CONTRIBUTING.md: add pnpm typecheck and ROADMAP update to pre-submission checklist
  • pnpm-workspace.yaml: document why core/server are excluded (tsconfig path aliases, not workspace protocol)
  • ROADMAP.md: fix stale date, add Phase 15 tracking section, add version history entry

Testing

  • Unit tests pass (pnpm test) — 192 files, 3,799 tests
  • Linting passes (npm run lint)
  • Build succeeds (npm run build)
  • Manual testing completed
  • New tests added (if applicable)

Screenshots

N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Pre-existing typecheck error (@hotcrm/ai module not found in enhanced_lead_scoring.action.ts) is unchanged and unrelated.

Original prompt

This section details on the original issue you should resolve

<issue_title>HotCRM 仓库改进建议开发清单</issue_title>
<issue_description>## 🚩 仓库全面扫描改进建议

本 Issue 基于代码结构、文档、测试、配置和 CI/CD 工作流扫描,列出了建议的详细开发清单。开发任务完成后应运行测试,并同步更新 ROADMAP。


🔴 高优先级改进项

  1. ROADMAP.md 日期与版本标注统一

    • 检查所有日期标注,确保与实际更新时间一致。
    • Version Upgrade History 的阶段时间线与当前代码同步。
  2. DEVELOPMENT_WORKFLOW.md 测试数与实际一致

    • 用动态语言取代硬编码的测试数量。
    • ���保文档同步实际测试覆盖。
  3. Hook 文件和核心逻辑避免使用 any 类型

    • 为 HookContext 和 QL broker 定义专用 TypeScript 接口。
    • 制作类型迁移计划,逐步替换 anyRecord<string, any>
  4. pnpm-workspace.yaml 与 package.json workspaces 配置一致

    • 明确 core/server 排除原因,保证依赖解析和构建一致。
  5. 补充/完善 .github/workflows CI 工作流文件

    • 至少提供 CI(typecheck+test)、release、CodeQL 等工作流。
    • 确认自动化测试与 lint 校验覆盖所有包。

🟡 中优先级改进项

  1. 统一日志输出使用结构化日志(pino)

    • 移除 console.log,改用 logger 工具。
    • 日志级别分层控制。
  2. 清理遗留 API(如 db.ts)并全量迁移到 broker

    • 使用 CI 检查遗留 API 引用,制定迁移计划。
  3. ESLint 插件与 parser 版本一致,采用最新配置

    • 升级 eslint 相关依赖,改用 flat config。
  4. 补充 E2E / 集成测试环境与用例

    • 构建 API 层的端到端测试,覆盖 Feed API / MCP API / 各业务流程。
  5. 改善 CacheManager 单例模式测试隔离能力

  • 支持测试下 resetInstance 或采用依赖注入模式。

🟢 低优先级/细节优化

  1. FormView / 配置文件避免 as any 类型断言
  • 明确类型,传递正确的参数类型。
  1. 升级 Vitest 至最新版本,提升测试速度与功能
  • 优化测试体验,利用新特性。
  1. 根目录统一 eslint 配置,确保所有 lint 脚本可用

  2. 补充提交前开发检查清单,纳入 CI 与 CONRIBUTING.md

  • 检查 typecheck、test、ROADMAP、文档等必要环节。

📝 开发流程建议

  • 每完成一项改进,运行 pnpm testpnpm typecheck
  • 更新 ROADMAP.md、DEVELOPMENT_WORKFLOW.md 等相关文档。
  • 在 PR/Issue 后同步 Roadmap 里新增/完成的任务。

请根据优先级分批推进,并标记/指派对应开发负责人。</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hotcrm Error Error Feb 21, 2026 0:05am
hotcrm-demo Ready Ready Preview, Comment Feb 21, 2026 0:05am

Request Review

Copilot AI and others added 3 commits February 21, 2026 11:41
After changing ctx: any to ctx: HookContext in helper functions,
TypeScript errors occurred because HookContext.result is unknown,
HookContext.ql is unknown, and HookContext.input/previous use
Record<string, unknown>.

Added minimal type casts at variable assignment points:
- ctx.result → ctx.result as Record<string, any>
- ctx.input?.doc || ctx.result → (...) as Record<string, any>
- ctx.ql.find/doc.create/etc → (ctx.ql as any).find/doc.create/etc
- ctx.previous.Field → (ctx.previous as Record<string, any>).Field

Files fixed: quote.hook.ts, pricebook.hook.ts, product.hook.ts,
opportunity.hook.ts, offer.hook.ts, performance_review.hook.ts,
roi.hook.ts, knowledge.hook.ts, campaign.hook.ts, employee.hook.ts

Reduces TypeScript errors from 300 to 1 (pre-existing unrelated error).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…cord<string, any> in hook helper functions

Update type annotations across 18 hook files:
- ctx: any → ctx: HookContext in helper functions
- campaign: any, employee: any, etc. → Record<string, any> for data record params
- Keep db: any and ql: any as-is for non-HookContext parameters

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- ROADMAP.md: fix last-updated date, add Phase 15 section, add version entry
- CONTRIBUTING.md: add typecheck/ROADMAP to pre-submission checklist
- DEVELOPMENT_WORKFLOW.md: update hook examples to use HookContext

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…ns, document workspace exclusions

- CI workflow: add pnpm typecheck step
- code-quality workflow: fix src/ → packages/ references, use typecheck instead of build
- package.json: align @typescript-eslint/parser ^6.21.0 → ^7.18.0 with plugin
- pnpm-workspace.yaml: add comment explaining core/server exclusion

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Update repository improvement recommendations fix: CI typecheck, hook type safety, ESLint alignment, and documentation accuracy Feb 21, 2026
Copilot AI requested a review from hotlong February 21, 2026 11:58
@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Feb 21, 2026

@copilot 19:54:41.517 Running build in Washington, D.C., USA (East) – iad1 (Turbo Build Machine)
19:54:41.517 Build machine configuration: 30 cores, 60 GB
19:54:41.620 Cloning github.com/objectstack-ai/hotcrm (Branch: copilot/improve-repo-scan-suggestions, Commit: b033afc)
19:54:42.107 Cloning completed: 486.000ms
19:54:42.409 Restored build cache from previous deployment (7hdewYZncu9hvCbz4qP4PUwPDxBJ)
19:54:43.282 Warning: Detected "engines": { "node": ">=20" } in your package.json that will automatically upgrade when a new major Node.js Version is released. Learn More: https://vercel.link/node-version
19:54:43.283 Running "vercel build"
19:54:43.787 Vercel CLI 50.22.0
19:54:44.476 Warning: Detected "engines": { "node": ">=20" } in your package.json that will automatically upgrade when a new major Node.js Version is released. Learn More: https://vercel.link/node-version
19:54:44.506 Detected pnpm-lock.yaml 9 which may be generated by pnpm@9.x or pnpm@10.x
19:54:44.506 Using pnpm@10.x based on project creation date
19:54:44.506 To use pnpm@9.x, manually opt in using corepack (https://vercel.com/docs/deployments/configure-a-build#corepack)
19:54:44.506 Running "install" command: pnpm install --ignore-scripts...
19:54:45.032 Scope: all 16 workspace projects
19:54:45.126  ERR_PNPM_OUTDATED_LOCKFILE  Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with /package.json
19:54:45.126
19:54:45.126 Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"
19:54:45.126
19:54:45.126 Failure reason:
19:54:45.126 specifiers in the lockfile don't match specifiers in package.json:
19:54:45.126 * 1 dependencies are mismatched:
19:54:45.126 - @typescript-eslint/parser (lockfile: ^6.21.0, manifest: ^7.18.0)
19:54:45.126
19:54:45.140 Error: Command "pnpm install --ignore-scripts" exited with 1

Regenerate lockfile to match @typescript-eslint/parser ^7.18.0 in package.json.
Fixes Vercel build failure: ERR_PNPM_OUTDATED_LOCKFILE.

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 21, 2026

@copilot 19:54:41.517 Running build in Washington, D.C., USA (East) – iad1 (Turbo Build Machine)
19:54:41.517 Build machine configuration: 30 cores, 60 GB
19:54:41.620 Cloning github.com/objectstack...

Fixed in 2bd0e99. The pnpm-lock.yaml was out of sync after the @typescript-eslint/parser version bump (^6.21.0^7.18.0). Regenerated the lockfile with pnpm install --no-frozen-lockfile.

@hotlong hotlong marked this pull request as ready for review February 21, 2026 12:38
Copilot AI review requested due to automatic review settings February 21, 2026 12:38
@hotlong hotlong merged commit e498128 into main Feb 21, 2026
3 of 4 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request addresses repository-wide quality improvements focused on CI/CD gaps, type safety in hook helpers, ESLint version alignment, and documentation accuracy. The changes systematically improve code quality and developer experience across multiple dimensions.

Changes:

  • Added missing pnpm typecheck step to CI workflow and fixed code-quality.yml paths from non-existent src/ to correct packages/ directory
  • Migrated 18 hook files from ctx: any to ctx: HookContext in helper functions, improving type safety while maintaining compatibility with ObjectQL broker
  • Aligned @typescript-eslint/parser version from ^6.21.0 to ^7.18.0 to match @typescript-eslint/eslint-plugin ^7.18.0, eliminating version mismatch

Reviewed changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
.github/workflows/ci.yml Added TypeScript type checking step to CI pipeline
.github/workflows/code-quality.yml Fixed all grep paths from src/ to packages/ and replaced build with typecheck
package.json Bumped @typescript-eslint/parser from ^6.21.0 to ^7.18.0 for version alignment
pnpm-lock.yaml Regenerated lockfile to reflect parser version upgrade and remove obsolete v6 dependencies
pnpm-workspace.yaml Added explanatory comments for core/server package exclusions
ROADMAP.md Updated header date, added Phase 15 tracking section, added version history entry
DEVELOPMENT_WORKFLOW.md Updated hook example code to use HookContext instead of any
CONTRIBUTING.md Added typecheck and ROADMAP update steps to pre-submission checklist
18 hook files (crm, hr, marketing, products, support) Changed helper function signatures from ctx: any to ctx: HookContext and data params to Record<string, any>
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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.

HotCRM 仓库改进建议开发清单

3 participants