Skip to content

✨ 未定义元数据标签在编辑器中显示警告#1608

Open
cyfung1031 wants to merge 1 commit into
scriptscat:mainfrom
cyfung1031:claude/undefined-prompt-warning-e01600
Open

✨ 未定义元数据标签在编辑器中显示警告#1608
cyfung1031 wants to merge 1 commit into
scriptscat:mainfrom
cyfung1031:claude/undefined-prompt-warning-e01600

Conversation

@cyfung1031

Copy link
Copy Markdown
Collaborator

Checklist / 检查清单

  • Fixes: unrecognized @tag metadata lines only surfaced as a hover tooltip; they now also show as an editor warning marker
  • Code reviewed by human / 代码通过人工检查
  • Changes tested / 已完成测试

背景

编辑器悬浮提示已能识别不在 ScriptCat 元数据提示表中的 @tag(显示 "Undefined Prompt"),但这些标签在编辑器中没有任何可见的警告标记,用户只有主动悬浮才能发现该标签暂不受支持。

本次改动

  • 新增 getUndefinedMetadataTagMarkerssrc/pkg/utils/monaco-editor/index.ts),扫描 ==UserScript== 元数据块内的每一行,复用悬浮提示已用的 metadataHoverPattern 提取标签
  • 若标签(小写化后)不在 promptByMetadataTag 中,则在编辑器中生成一个 MarkerSeverity.Warning 标记(rule id scriptcat/undefined-metadata-tag),消息复用既有的 currentEditorLang.undefinedPrompt 文案(已支持所有语言),提示用户暂不受支持
  • 未提供快速修复(quick fix)动作,仅作提示

已知限制

  • 不提供自动修复或建议;仅提示该标签尚不受支持
  • 沿用已有的 undefinedPrompt 文案,未新增专门的“不支持”措辞

建议审查重点

  • 已知/受支持的元数据标签(如 namegrantrun-at 等)不应被误标记为警告
  • 布尔型标签(无值,如 @noframes)也应被正确识别,不受 metadataAlignmentPattern 需要尾随空格+值的限制

验证

  • pnpm run typecheck — 通过
  • pnpm exec eslint src/pkg/utils/monaco-editor/index.ts — 无报错
  • 独立 Node 脚本验证正则对已知/未知/布尔型标签的匹配与列号计算正确
  • 提交前 husky pre-commit(prettier + typecheck)通过
  • 由用户在浏览器中加载扩展手动验证生效

@tag 若不在已知元数据提示列表中,现在会在编辑器中以警告标记显示(沿用悬浮提示的 undefinedPrompt 文案),提示用户该标签暂未被 ScriptCat 支持。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@cyfung1031

Copy link
Copy Markdown
Collaborator Author

i have checked the code and confirmed with browser testing.

// ==UserScript==
// @name        A Script 1234
// @namespace   http://tampermonkey.net/
// @version     2025-02-28
// @description try to take over the world!
// @author      You
// @match       https://*/*
// @icon        https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant       none
// @sandbox     JavaScript
// @run-at      document-start
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    console.error("history length: " + history.length);
})();
Screenshot 2026-07-18 at 4 55 28 Screenshot 2026-07-18 at 4 55 44

@cyfung1031 cyfung1031 added the P1 🔥 重要但是不紧急的内容 label Jul 18, 2026
@cyfung1031 cyfung1031 added this to the 2026七月 Milestone milestone Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 🔥 重要但是不紧急的内容

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant