Implement AST-based dependency extraction in FormulaVisitor.calculateDependencies (markdown-template)
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
Start by reading packages/markdown-template/src/FormulaVisitor.ts and trace how calculateDependencies is called from templatemarkutil.ts and how dependencies is serialized and read back. The issue leaves the runtime parser and which identifiers count unresolved, so first settle those decisions in the discussion before implementing. Done means extracting the agreed dependencies from formula TypeScript while respecting the agreed handling of bindings and parse failures.
由索引模型根据 Issue 内容生成。
描述
Summary
FormulaVisitor.calculateDependencies(tsCode) in packages/markdown-template/src/FormulaVisitor.ts is a stub (// TODO!!) that always returns []. It's invoked during TemplateMark typing (templatemarkutil.ts → templateMarkTypingGen), which sets dependencies on every FormulaDefinition / ConditionalDefinition, and the value is serialized through markdown-html (ToHtmlStringVisitor.ts writes the dependencies attribute, rules.ts reads it back). Today that attribute is always an empty array.
Continuing the working discussion with @mttrbrts
Current state / safety
Traced consumers of the field across the org:
markdown-transform: only written (HTML attr), read back (rules.ts), or stripped (markdown-cicero/ToCommonMarkVisitor.tsdeletes it).template-engine: onlyTemplateMarkInterpreter.tsdoesdelete context.dependencies.
No code branches on the values, so implementing real extraction is self-contained with no regression surface — it only populates a field that is currently always empty.
Proposed approach
Extract root identifiers from the formula's TypeScript source (the param is named tsCode) via the AST rather than regex:
- Collect root identifiers that reference template variables / model, excluding locally-bound names, function params, and built-ins.
- Handle optional chaining (
a?.b?.c→ roota). - Return
[]on parse failure or unrecognized constructs (note: this changes the currentcatch, which throws — flagging so it's an explicit decision).
Open questions to scope before implementation
- Runtime parser:
typescriptis currently a devDependency of markdown-template. Preference for promoting the TS compiler API to a runtime dep vs. a lighter parser (e.g.@typescript-eslint/typescript-estree)? - Dependency definition: which identifier classes count — model/variable refs only, and are locally-declared bindings and function params always excluded?
- Cross-formula references: Devanshi noted formulas lack stable user-facing names, so these look out-of-scope for v1 — agreed to defer?
I can't make the Wednesday call, so opening this for async discussion per your
suggestion. Once (1) the runtime parser and (2) the dependency-definition
question are settled here, I'll scope the PR to those decisions.
- 主要语言
- TypeScript
- 星标
- 86
- 派生
- 69
- 平均合并
- 6 分钟
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
accordproject/markdown-transform 的其他 Issue
-
@accordproject/markdown-it-template has a Nerq Trust Score of 68.0/100 — verified badge available未关闭Stale
难度 1/5 1 小时以内 新手友好度 20/100
accordproject/markdown-transform#664 · 1 条评论 ·
-
Stale
难度 3/5 1-2 天 新手友好度 48/100
accordproject/markdown-transform#582 · 2 条评论 ·
-
Rename CiceroMark to AgreementMark可能重新可做 @anablaz 于 980 天前认领,目前没有进行中的 PR。 未关闭Stale
难度 5/5 一周以上 新手友好度 20/100
accordproject/markdown-transform#536 · 4 条评论 ·
-
Difficulty: Challenging maintainer-engaged Priority: High ⚠️ Type: Bug 🐛
难度 5/5 一周以上 新手友好度 25/100
accordproject/markdown-transform#371 · 3 条评论 ·
-
Help Wanted 🆘 maintainer-engaged Type: Discussion 🗣 Type: Feature Request 🛍️ Type: Need Investigation 🔬
难度 5/5 一周以上 新手友好度 25/100
accordproject/markdown-transform#368 · 7 条评论 ·
查看 accordproject/markdown-transform 的全部 Issue
相似的 Issue
-
Mend: dependency security vulnerability
难度 1/5 1-3 小时 新手友好度 65/100
fdm-monster/fdm-monster#5563 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
be-BOP-io-SA/be-BOP#2849 ·
-
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 1 天内回复
-
1️⃣ phase/under-investigation flaky/confirmed flaky/needs-decision type/bug
难度 2/5 1-3 小时 新手友好度 65/100
growilabs/growi#12246 · 3 条评论 ·
维护者通常 1 天内回复
-
🐛 The Rulekeeper - An index run that gives up on the lock ends Succeeded可能已有人在做 @github-actions 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
SSWConsulting/SSW.Rules#2809 · 1 条评论 ·
维护者通常 1 天内回复