Skip to content

test: Add subcommand documentation verification#1597

Merged
Crunchyman-ralph merged 5 commits intoeyaltoledano:nextfrom
bjcoombs:1596-enhanced-help-test
Feb 6, 2026
Merged

test: Add subcommand documentation verification#1597
Crunchyman-ralph merged 5 commits intoeyaltoledano:nextfrom
bjcoombs:1596-enhanced-help-test

Conversation

@bjcoombs
Copy link
Contributor

@bjcoombs bjcoombs commented Jan 17, 2026

Summary

Enhances the help documentation sync test to verify that subcommand documentation stays in sync with CLI implementations.

Changes

  • Adds tests to verify tags subcommands use the new unified structure (tags add, tags use, etc.)
  • Verifies deprecated standalone tag commands (add-tag, use-tag) are not documented
  • Verifies list command options are documented (--watch, --ready, --blocking)
  • Verifies list format options are documented (--json, -f, -c)

Test Plan

  • All 10 tests pass locally
  • Tests correctly detect when subcommands are missing from help

Dependencies

⚠️ This PR depends on #1593 (help docs update) and should be merged after it.

This PR includes the help documentation updates from #1593 so it can verify against them. If #1593 changes, this PR will need to be rebased.

Closes #1596

Summary by CodeRabbit

  • New Features

    • Unified "tags" commands (add/use/remove/rename/copy) and added a new optional --from-branch flag for tags add.
    • Extended list command options and output formatting controls.
  • Documentation

    • Updated CLI help text to reflect new tag command usages and remove deprecated standalone tag entries.
  • Tests

    • Added comprehensive help-vs-CLI synchronization tests covering subcommands, tag mappings, list options, and extraction robustness.

Note

Low Risk
Test- and help-text-only changes; main risk is increased CI strictness causing failures if command/help strings drift or parsing heuristics miss edge cases.

Overview
Adds a new help-documentation-sync.spec.ts unit test that parses legacy commands.js, modern *.command.ts, and ui.js help entries to fail CI when commands are missing from help or when help documents commands that no longer exist, with explicit allowlists/mappings for intentionally-undocumented and migrating commands.

Extends coverage to subcommand correctness: asserts help documents the unified tags add/use/remove/rename/copy structure, ensures deprecated standalone tag commands aren’t documented as primary entries, and verifies list help includes key option variants (watch/ready/blocking and format flags).

Updates the help text for tags add in ui.js to include the missing --from-branch argument, and adds a patch changeset describing the test/documentation improvements.

Written by Cursor Bugbot for commit 37a3000. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link

changeset-bot bot commented Jan 17, 2026

🦋 Changeset detected

Latest commit: 37a3000

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Adds a new unit test suite that verifies legacy and modern CLI commands are represented in generated help text; updates help output in scripts/modules/ui.js to add --from-branch to tags add. Adds a changeset documenting the test and help adjustments. (34 words)

Changes

Cohort / File(s) Summary
Help documentation sync test
apps/cli/tests/unit/help-documentation-sync.spec.ts
New ~420-line Vitest suite with helpers to extract legacy (scripts/modules/commands.js) and modern (apps/cli/src/commands/*.ts) command names, mappings/exclusions for migrated tag commands, and tests ensuring help/documentation parity, absence of obsolete help entries, and checks for subcommands/options (tags, list).
Help text update
scripts/modules/ui.js
Help/usage text change: tags add usage now includes optional --from-branch flag. No runtime logic or API changes.
Changeset / Docs
.changeset/help-sync-test-enhancements.md
New changeset describing the added help-sync tests and noted help-text clarifications (tags subcommands, list options) and the --from-branch addition.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • #1596 — Adds verification of tags subcommand structure and list options in help sync tests; aligns with new tests verifying subcommand/option documentation.
  • #1594 — Prior help-vs-CLI synchronization tests and objectives overlap with this comprehensive help sync test.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'test: Add subcommand documentation verification' clearly and concisely summarizes the main change—adding tests to verify subcommand documentation sync.
Linked Issues check ✅ Passed The PR fully addresses all coding requirements from #1596: tests verify tags subcommands structure, deprecated commands absence, and list command options documentation.
Out of Scope Changes check ✅ Passed All changes directly support the PR objectives—test file additions, help text documentation updates, and changeset addition are all in-scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@apps/cli/tests/unit/help-documentation-sync.spec.ts`:
- Around line 119-141: The INTENTIONALLY_UNDOCUMENTED array includes 'generate'
but the CLI help actually documents the generate command under "Task
Generation"; remove 'generate' from the INTENTIONALLY_UNDOCUMENTED constant so
the help sync test will validate it (edit the INTENTIONALLY_UNDOCUMENTED
declaration to delete the 'generate' entry).
- Around line 147-156: COMMAND_NAME_MAPPINGS currently keeps legacy tag commands
(add-tag, use-tag, delete-tag, rename-tag, copy-tag) out of validation, which
can mask whether they should be removed; either delete those legacy entries from
COMMAND_NAME_MAPPINGS when the old commands in scripts/modules/commands.js are
fully deprecated, or add a clear explanatory comment above COMMAND_NAME_MAPPINGS
stating it's "temporary during tag-migration to exempt legacy commands from help
validation" and include the list of legacy command names and a TODO with the
deprecation milestone; ensure related tests that reference COMMAND_NAME_MAPPINGS
still explicitly assert that these legacy commands are not present as primary
documented commands so intent remains clear.

In `@scripts/modules/ui.js`:
- Around line 757-761: Update the args string for the command object with name
'tags add' so it accurately reflects supported flags: change the 'args' property
to include the --from-branch option (e.g., '<name> [--description <desc>]
[--copy-from <tag>] [--from-branch <branch>]'). Locate the 'tags add' command
object in scripts/modules/ui.js and update its args value accordingly so it
matches the description.
🧹 Nitpick comments (2)
apps/cli/tests/unit/help-documentation-sync.spec.ts (2)

55-80: Error handling could be more specific.

The catch block logs a warning but continues execution. While this is reasonable for optional directories, consider distinguishing between "directory doesn't exist" (expected in some configs) versus actual read errors (unexpected).

♻️ Optional: More specific error handling
 	} catch (error) {
-		// Directory might not exist in some configurations
-		console.warn('Could not read modern commands directory:', error);
+		// Directory might not exist in some configurations
+		if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
+			// Expected - directory doesn't exist
+		} else {
+			console.warn('Could not read modern commands directory:', error);
+		}
 	}

326-349: Tag section regex may be fragile.

The regex /Tag Management.*?(?=\n\s*\n\s*[A-Z]|\n\s*\])/s relies on specific formatting (double newline followed by uppercase or closing bracket). This could break if:

  • The section heading format changes
  • There's additional whitespace
  • The next section starts differently

Consider a more robust approach or add a fallback with a helpful error message.

♻️ Suggested improvement
 		// Check within the Tag Management section specifically
 		const tagSectionMatch = helpContent.match(
 			/Tag Management.*?(?=\n\s*\n\s*[A-Z]|\n\s*\])/s
 		);

-		if (tagSectionMatch) {
+		if (!tagSectionMatch) {
+			console.warn(
+				'Could not isolate Tag Management section - checking entire help content instead'
+			);
+		}
+
+		const sectionToCheck = tagSectionMatch ? tagSectionMatch[0] : helpContent;
+		{
-			const tagSection = tagSectionMatch[0];
+			const tagSection = sectionToCheck;
 			const foundDeprecated = deprecatedCommands.filter((pattern) =>
 				pattern.test(tagSection)
 			);

@bjcoombs
Copy link
Contributor Author

Merge Order Note

This PR is branched from #1593 and includes its commits. Please merge in this order:

  1. docs: Update help command with current tags and list options #1593 first (help docs update)
  2. test: Add subcommand documentation verification #1597 second (this PR - enhanced tests)

Alternatively, merging this PR alone will include #1593's changes, but merging #1593 first keeps the history cleaner.

Copy link
Collaborator

@Crunchyman-ralph Crunchyman-ralph left a comment

Choose a reason for hiding this comment

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

love this! I think it needs a changeset, don't you ?

@Crunchyman-ralph Crunchyman-ralph changed the base branch from main to next February 6, 2026 16:25
Enhances help sync test to verify:
- tags subcommands use new unified structure (tags add, tags use, etc.)
- deprecated standalone tag commands are not documented
- list command options are documented (--watch, --ready, --blocking, etc.)
- list format options are documented (--json, -f, -c)

Closes eyaltoledano#1596
- Add clarifying comment for COMMAND_NAME_MAPPINGS to explain legacy command exemption during migration
- Update 'tags add' command args to include missing --from-branch option
- Add changeset documenting test enhancements and minor fixes
Changeset validation only allows public package names (task-master-ai, extension).
Changed from internal package name @tm/cli to public package name task-master-ai.
Addresses Cursor Bugbot feedback: The test "should not document deprecated
standalone tag commands" now falls back to checking the entire help content
if the Tag Management section regex doesn't match, instead of silently
passing without making any assertions.

This ensures the test always validates that deprecated commands are not
documented, even if the help formatting changes.
Copy link
Collaborator

@Crunchyman-ralph Crunchyman-ralph left a comment

Choose a reason for hiding this comment

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

lgtm

@Crunchyman-ralph Crunchyman-ralph merged commit 0c1e969 into eyaltoledano:next Feb 6, 2026
7 of 8 checks passed
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

while ((match = superRegex.exec(content)) !== null) {
commands.add(match[1]);
}
}
Copy link

Choose a reason for hiding this comment

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

Non-recursive scan silently misses subdirectory commands

Medium Severity

extractCommandsFromModernTs uses readdirSync (non-recursive) and only matches *.command.ts files, so it silently misses commands defined in subdirectories like autopilot/index.ts. The AutopilotCommand is registered in CommandRegistry and is a real user-facing CLI command, but it's neither found by this extraction function nor listed in INTENTIONALLY_UNDOCUMENTED. This creates a blind spot where the test gives false confidence that all CLI commands are accounted for — autopilot could lose or gain documentation without the sync test catching it.

Fix in Cursor Fix in Web

const allListSections = listMatches.join('\n');
const missingOptions = expectedListOptions.filter(
(opt) => !allListSections.includes(opt)
);
Copy link

Choose a reason for hiding this comment

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

Substring match makes -w watch option check ineffective

Medium Severity

The check for '-w' (short for --watch) using allListSections.includes('-w') is unreliable because '-w' is a substring of '--with-subtasks', which appears in a different list entry. If the -w watch option were removed from the help documentation, the test would still pass due to the accidental substring match against --with-subtasks, silently defeating the test's purpose.

Fix in Cursor Fix in Web

@bjcoombs bjcoombs deleted the 1596-enhanced-help-test branch February 7, 2026 06:40
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.

Enhance help sync test to verify subcommand documentation

2 participants