Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 31, 2025

Migration Plan: hide_comment to JavaScript Handler Architecture ✅ COMPLETE

Understanding

  • Explored repository structure
  • Analyzed create_issue.cjs pattern (reads config object)
  • Analyzed hide_comment.cjs current implementation (reads env vars)
  • Identified hide_comment.go parser
  • Identified schema with github-token field
  • Identified compiler_safe_outputs_shared.go step builder

Migration Tasks

  • Modify hide_comment.cjs to read from config object instead of env vars
    • Change allowed_reasons to read from config.allowed_reasons
  • Remove env var generation in compiler_safe_outputs_shared.go
  • Add hide_comment config generation in safe_outputs_config_generation.go
  • Remove github-token field from hide-comment schema
  • Update hide_comment.cjs tests to use config object
  • Run tests to validate changes
    • JavaScript tests: All 12 tests passing ✅
    • Go unit tests: All passing ✅
    • Linting: All passing ✅
    • Formatting: All passing ✅
  • Merged main branch ✅
  • Validation complete ✅

Changes Made

1. JavaScript Handler (hide_comment.cjs)

  • Changed main() to accept config parameter
  • Reads allowed_reasons from config.allowed_reasons instead of process.env.GH_AW_HIDE_COMMENT_ALLOWED_REASONS
  • Simplified error handling by removing JSON parsing
  • Config object follows same pattern as create_issue.cjs

2. Go Compiler (safe_outputs_config_generation.go)

  • Added hide_comment configuration object generation
  • Config includes max and allowed_reasons fields
  • Follows same pattern as other safe outputs (create_issue, add_comment, etc.)
  • Default max value: 5 (matching default in hide_comment.go)

3. Schema (main_workflow_schema.json)

  • Removed github-token field from hide-comment properties
  • Token is now handled at the safe-outputs level (via GitHubToken in BaseSafeOutputConfig)
  • Only max, target-repo, and allowed-reasons remain in schema

4. Tests (hide_comment.test.cjs)

  • Updated all test cases to pass config object to main({})
  • Changed allowed-reasons tests to use { allowed_reasons: [...] } instead of env vars
  • Removed GH_AW_HIDE_COMMENT_ALLOWED_REASONS cleanup from beforeEach
  • All 12 tests passing

Architecture Alignment

This migration aligns hide_comment with the modern JavaScript handler architecture used by create_issue and other safe outputs:

Before (Environment Variables):

// Go: Generate environment variable
customEnvVars = append(customEnvVars, fmt.Sprintf("GH_AW_HIDE_COMMENT_ALLOWED_REASONS: %s\n", jsonValue))

// JavaScript: Parse from env var
let allowedReasons = JSON.parse(process.env.GH_AW_HIDE_COMMENT_ALLOWED_REASONS);

After (Config Object):

// Go: Generate config object
hideCommentConfig["allowed_reasons"] = data.SafeOutputs.HideComment.AllowedReasons

// JavaScript: Read from config
const allowedReasons = config.allowed_reasons || null;

Benefits

  • ✅ Consistent architecture across all safe outputs
  • ✅ Simplified configuration passing (no JSON parsing)
  • ✅ Better type safety (config objects vs string parsing)
  • ✅ Easier testing (config objects vs env vars)
  • ✅ Follows established patterns in codebase
Original prompt

Migrate hide_comment safe output that JavaScript handler architecture.

  • refactor main to read options from config
  • remove step and custom env var generation in .go compiler
  • remove GitHub-token in json schema
  • update JavaScript tests

Docs: https://githubnext.github.io/gh-aw/reference/safe-outputs/#hide-comment-hide-comment
See also: create_issue.cjs


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Modified hide_comment.cjs to read options from config object instead of env vars
- Removed custom env var generation in compiler_safe_outputs_shared.go
- Added hide_comment config generation in safe_outputs_config_generation.go
- Removed github-token field from hide-comment JSON schema
- Updated hide_comment.test.cjs to pass config object to main()
- All JavaScript and Go tests passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
Copy link
Contributor

@copilot merge main, format, lint

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate hide_comment safe output in JavaScript handler architecture Migrate hide_comment safe output to JavaScript handler architecture Dec 31, 2025
Copilot AI requested a review from pelikhan December 31, 2025 01:52
Copy link
Contributor Author

Copilot AI commented Dec 31, 2025

@copilot merge main, format, lint

Merged main branch, ran format and lint. All checks passed. Commit: 2c8793c

@pelikhan pelikhan marked this pull request as ready for review December 31, 2025 02:06
@pelikhan pelikhan merged commit 6c2c4ba into main Dec 31, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/migrate-hide-comment-output branch December 31, 2025 02:06
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