-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(validation): Add tasks.md validation with checkbox and content checks (#354) #576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
atman-33
wants to merge
3
commits into
Fission-AI:main
Choose a base branch
from
atman-33:feature/validate-tasks-md-checkboxes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+346
−4
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
openspec/changes/archive/2026-01-25-add-tasks-validation/proposal.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Change: Add tasks.md Validation | ||
|
|
||
| ## Why | ||
|
|
||
| AI agents generate OpenSpec change proposals including `tasks.md` as implementation checklists. Currently, `openspec validate` checks `proposal.md` and spec deltas, but does not validate `tasks.md`. This can lead to: | ||
| - Missing or empty tasks.md files | ||
| - Tasks without checkboxes (making progress tracking impossible) | ||
| - Empty task descriptions that provide no implementation guidance | ||
|
|
||
| Adding basic tasks.md validation ensures AI-generated proposals include properly formatted implementation checklists before approval. | ||
|
|
||
| ## What Changes | ||
|
|
||
| - Add tasks.md validation to the `Validator` class | ||
| - Validate tasks.md when running `openspec validate <change-id>` | ||
| - Check three essential requirements: | ||
| 1. File exists | ||
| 2. At least one checkboxed task is present | ||
| 3. No empty task descriptions | ||
| - Use the same checkbox pattern as existing `task-progress.ts` (`/^[-*]\s+\[[xX\s]\]/`) | ||
| - Report validation errors with line numbers for easy fixing | ||
|
|
||
| ## Impact | ||
|
|
||
| - **Affected specs**: cli-validate | ||
| - **Affected code**: `src/core/validation/validator.ts`, `src/commands/validate.ts` | ||
| - **Breaking changes**: None (only adds new validation checks) | ||
| - **Backward compatibility**: Existing changes may fail validation if tasks.md is missing or improperly formatted |
49 changes: 49 additions & 0 deletions
49
...spec/changes/archive/2026-01-25-add-tasks-validation/specs/cli-validate/spec.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # cli-validate Spec Delta | ||
|
|
||
| ## ADDED Requirements | ||
|
|
||
| ### Requirement: Validator SHALL validate tasks.md format in changes | ||
|
|
||
| When validating changes, the validator SHALL check that tasks.md exists, contains at least one checkboxed task, and has no empty task descriptions. | ||
|
|
||
| #### Scenario: Missing tasks.md file | ||
|
|
||
| - **WHEN** validating a change that does not have tasks.md | ||
| - **THEN** report ERROR with message "tasks.md is required for OpenSpec changes" | ||
| - **AND** include path "tasks.md" in the issue | ||
|
|
||
| #### Scenario: No checkboxed tasks found | ||
|
|
||
| - **WHEN** validating a tasks.md file with no items matching pattern `/^[-*]\s+\[[xX\s]\]/` | ||
| - **THEN** report ERROR with message "tasks.md must contain at least one checkboxed task" | ||
| - **AND** include path "tasks.md" in the issue | ||
|
|
||
| #### Scenario: Empty task description detected | ||
|
|
||
| - **WHEN** validating a tasks.md file containing a line matching `/^[-*]\s+\[[xX\s]\]\s*$/` | ||
| - **THEN** report ERROR with message "Empty task description" | ||
| - **AND** include path "tasks.md:N" where N is the line number (1-indexed) | ||
|
|
||
| #### Scenario: Valid tasks.md with checkboxed tasks | ||
|
|
||
| - **WHEN** validating a tasks.md file with one or more properly formatted checkboxed tasks | ||
| - **THEN** report no errors for tasks.md | ||
| - **AND** include tasks.md in the validation summary | ||
|
|
||
| #### Scenario: Tasks.md validation integrated with change validation | ||
|
|
||
| - **WHEN** running `openspec validate <change-id>` | ||
| - **THEN** validate proposal.md, spec deltas, and tasks.md | ||
| - **AND** display results for all validated files | ||
| - **AND** exit with code 1 if any validation fails | ||
|
|
||
| ### Requirement: Checkbox pattern SHALL match task-progress utility | ||
|
|
||
| The tasks.md validator SHALL use the same checkbox detection pattern as `src/utils/task-progress.ts` to ensure consistency across the codebase. | ||
|
|
||
| #### Scenario: Checkbox pattern consistency | ||
|
|
||
| - **WHEN** detecting checkboxed tasks in tasks.md | ||
| - **THEN** use pattern `/^[-*]\s+\[[xX\s]\]/` for checkbox detection | ||
| - **AND** accept both lowercase and uppercase X for completed tasks | ||
| - **AND** accept both `-` and `*` as list markers |
33 changes: 33 additions & 0 deletions
33
openspec/changes/archive/2026-01-25-add-tasks-validation/tasks.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Tasks: Add tasks.md Validation | ||
|
|
||
| ## 1. Add Validation Method to Validator Class | ||
|
|
||
| - [x] 1.1 Add `validateTasksFile(changeDir: string): Promise<ValidationReport>` method to Validator class | ||
| - [x] 1.2 Implement file existence check (ERROR if missing) | ||
| - [x] 1.3 Add `validateTasksContent(content: string): ValidationIssue[]` private method | ||
| - [x] 1.4 Implement checkbox task detection using pattern `/^[-*]\s+\[[xX\s]\]/` | ||
| - [x] 1.5 Check for at least one checkboxed task (ERROR if none found) | ||
| - [x] 1.6 Detect empty task descriptions with pattern `/^[-*]\s+\[[xX\s]\]\s*$/` (ERROR) | ||
| - [x] 1.7 Include line numbers in error messages for empty tasks | ||
|
|
||
| ## 2. Integrate with Validate Command | ||
|
|
||
| - [x] 2.1 Update `validateDirectItem()` in ValidateCommand to call tasks.md validation for changes | ||
| - [x] 2.2 Update `validateByType()` to include tasks.md validation when type is 'change' | ||
| - [x] 2.3 Update `runBulkValidation()` to validate tasks.md for each change | ||
| - [x] 2.4 Ensure tasks.md validation results are displayed alongside proposal.md and spec results | ||
|
|
||
| ## 3. Testing | ||
|
|
||
| - [x] 3.1 Add unit tests for `validateTasksContent()` with various checkbox formats | ||
| - [x] 3.2 Test error case: tasks.md file missing | ||
| - [x] 3.3 Test error case: no checkboxed tasks found | ||
| - [x] 3.4 Test error case: empty task descriptions | ||
| - [x] 3.5 Test valid case: properly formatted tasks.md with multiple tasks | ||
| - [x] 3.6 Test pattern compatibility with existing task-progress.ts regex | ||
| - [x] 3.7 Add integration test for `openspec validate <change>` including tasks.md | ||
|
|
||
| ## 4. Documentation | ||
|
|
||
| - [x] 4.1 Update error messages to be clear and actionable | ||
| - [x] 4.2 Ensure validation output shows tasks.md status alongside other files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Fission-AI/OpenSpec
Length of output: 392
🏁 Script executed:
Repository: Fission-AI/OpenSpec
Length of output: 1443
🏁 Script executed:
Repository: Fission-AI/OpenSpec
Length of output: 7348
🏁 Script executed:
Repository: Fission-AI/OpenSpec
Length of output: 45
🏁 Script executed:
Repository: Fission-AI/OpenSpec
Length of output: 45
🏁 Script executed:
Repository: Fission-AI/OpenSpec
Length of output: 233
🏁 Script executed:
Repository: Fission-AI/OpenSpec
Length of output: 91
🏁 Script executed:
Repository: Fission-AI/OpenSpec
Length of output: 1020
🏁 Script executed:
Repository: Fission-AI/OpenSpec
Length of output: 17346
🏁 Script executed:
Repository: Fission-AI/OpenSpec
Length of output: 91
🏁 Script executed:
Repository: Fission-AI/OpenSpec
Length of output: 793
Support nested checkbox tasks in validation patterns.
The current patterns (
/^[-*]\s+\[[\sx]\]/iand/^[-*]\s+\[[xX\s]\]\s*$/) only match checkboxes at the line start. Nested tasks with leading whitespace (e.g.,- [ ] Subtask) are actively used in the repository (e.g.,openspec/changes/archive/2025-08-13-add-archive-command/tasks.md) but will not be detected or validated.Update both patterns to allow optional leading whitespace:
Suggested changes
And in
validator.ts:🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this regular expression is already used in existing code, the change will be put on hold for now. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atman-33, understood! SinceTASK_PATTERNis shared across the codebase (includingtask-progress.ts), changing it would have broader implications. It makes sense to evaluate the impact on all consumers before making that adjustment.Feel free to revisit this when you're ready to handle nested tasks uniformly across the validation and progress tracking features.