Skip to content

Implement scene file syntax checker (チェッカーの実装)#198

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/implement-syntax-checker
Draft

Implement scene file syntax checker (チェッカーの実装)#198
Copilot wants to merge 4 commits intomainfrom
copilot/implement-syntax-checker

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

Scene files had no parse-time validation — structural violations like <item> outside <choice> or duplicate <scenario> sections were silently accepted, only failing at runtime.

New: parser/checker.js

Recursive validator that enforces parent-child constraints on the parsed scenario tree using a TOP_LEVEL_COMMANDS constant (derived from Core.commandList in core/index.js) and an ALLOWED_PARENTS map:

Node Required parent
<item> <choice>
<action> <actions>
<then> <if> or any top-level command (HTTP response context)
<else> <if>
<prompt> / <actions> <dialog>
<color> / <ruby> / <b> / <i> / <br> <text> or <say>
<header> / <data> / <error> / <progress> any top-level command

Inline text decoration tags (color, ruby, b, i, br) are sourced from drawer.ts's createDecoratedElement and textHandler. HTTP sub-tags (header, data, error, progress) are sourced from httpHandler and are valid inside any top-level command since HTTP is a global feature.

Returns an array of { type, node, parent, message } error objects.

Updated: parser/parser.js

  • Detects multiple <scenario> sections per file
  • Runs the checker post-parse; includes errors in return value

Updated: parser/cli.js

  • Prints errors to stderr with filename context; exits 1 on any error
Syntax Error in choice.scene: <item> must be inside <choice>, but found inside scenario root

New: parser/checker.test.ts

24 unit tests covering valid structures (no false positives) and all enforced parent-child violations, including inline text decoration and HTTP sub-tag rules.

Original prompt

This section details on the original issue you should resolve

<issue_title>チェッカーの実装</issue_title>
<issue_description>Scenarioが二つある。

itemは、choiceの中だけなど、構文チェッカーを実装する


Trelloから移行 (todo): https://trello.com/c/5vlGqqjj</issue_description>

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


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

@vercel
Copy link

vercel bot commented Mar 20, 2026

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

Project Deployment Actions Updated (UTC)
webtalekit-demo Error Error Mar 20, 2026 1:04pm

Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement syntax checker for the scenarios Implement scene file syntax checker (チェッカーの実装) Mar 20, 2026
Copilot AI requested a review from EndoHizumi March 20, 2026 12:48
@EndoHizumi
Copy link
Owner

@copilot 他のタグのバリエーションもcore.jsを参照して、追加して

Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 20, 2026

@copilot 他のタグのバリエーションもcore.jsを参照して、追加して

Added all tag variations from core/index.js and drawer.ts in commit ff1a4fc:

  • Inline text decoration (color, ruby, b, i, br) — must be inside <text> or <say> (from createDecoratedElement in drawer.ts and textHandler)
  • HTTP sub-tags (header, data, error, progress) — must be inside any top-level command; cannot appear at scenario root (HTTP is a global feature usable on all commands)
  • then — expanded to allow both <if> children and HTTP response children inside any top-level command

A TOP_LEVEL_COMMANDS constant was extracted from Core.commandList to keep the definitions DRY. 10 new tests were added covering all the new rules (24 total).

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.

チェッカーの実装

2 participants