Skip to content

Conversation

@github-actions
Copy link
Contributor

Summary

Cleaned and modernized validate_memory_files.cjs from the actions/setup/js/ directory following jsweep best practices.

Context

This file runs in github-script context and validates that all files in a memory directory have allowed file extensions.

Changes Made

Code Improvements

  1. Added ValidationResult typedef - Created a proper type definition for the return value instead of inline object type
  2. Used optional chaining (?.) - Simplified allowAll check from !allowedExtensions || allowedExtensions.length === 0 to !allowedExtensions?.length
  3. Converted to arrow function - Changed scanDirectory from function declaration to arrow function for consistency
  4. Improved error message handling - Simplified the error message construction for extension display using logical OR
  5. Removed unnecessary comments - Removed redundant inline comments that just repeated what the code does
  6. Improved parameter documentation - Added default value notation to JSDoc parameters
  7. Reordered logic - Moved directory existence check before extensions normalization for earlier return

Line Count

  • Before: 85 lines
  • After: 83 lines
  • Reduction: 2% (2 lines)

Test Coverage

The file already has comprehensive test coverage with 21 test cases covering:

  • ✅ Empty directories
  • ✅ Non-existent directories
  • ✅ Multiple file types (.json, .jsonl, .txt, .md, .csv, .log, .yaml, .xml)
  • ✅ Files without extensions
  • ✅ Subdirectory validation
  • ✅ Deeply nested directories
  • ✅ Case-insensitive extension matching
  • ✅ Custom allowed extensions
  • ✅ Empty allowed extensions array

All tests pass successfully.

Validation Results

Formatting: npm run format:cjs - Passed
Linting: npm run lint:cjs - Passed
Type checking: npm run typecheck - Passed (2 pre-existing errors in other files, not in this file)
Tests: npm run test:js -- --no-file-parallelism validate_memory_files - 21/21 tests passed

Before & After Example

Before:

// If allowedExtensions is not provided, undefined, or empty array, allow all files
const allowAll = !allowedExtensions || allowedExtensions.length === 0;

// Check if directory exists
if (!fs.existsSync(memoryDir)) {
  core.info(`Memory directory does not exist: ${memoryDir}`);
  return { valid: true, invalidFiles: [] };
}

// Normalize extensions to lowercase and trim whitespace
const extensions = allowedExtensions.map(ext => ext.trim().toLowerCase());

function scanDirectory(dirPath, relativePath = "") {
  // Implementation...
}

After:

const allowAll = !allowedExtensions?.length;

if (!fs.existsSync(memoryDir)) {
  core.info(`Memory directory does not exist: ${memoryDir}`);
  return { valid: true, invalidFiles: [] };
}

const extensions = allowedExtensions.map(ext => ext.trim().toLowerCase());

const scanDirectory = (dirPath, relativePath = "") => {
  // Implementation...
};

Impact

  • ✅ No logic changes - behavior remains identical
  • ✅ Improved code readability with modern JavaScript
  • ✅ Better type safety with typedef
  • ✅ All tests passing
  • ✅ No breaking changes

AI generated by jsweep - JavaScript Unbloater

  • expires on Feb 15, 2026, 6:53 AM UTC

@pelikhan
Copy link
Contributor

@copilot lint, fix tests

Copy link
Contributor

Copilot AI commented Feb 13, 2026

@pelikhan I've opened a new pull request, #15316, to work on those changes. Once the pull request is ready, I'll request review from you.

@pelikhan
Copy link
Contributor

@copilot merge main and fix lint js

Copy link
Contributor

Copilot AI commented Feb 13, 2026

@pelikhan I've opened a new pull request, #15319, to work on those changes. Once the pull request is ready, I'll request review from you.

…15319)

* Add refiner workflow for automated code style and security analysis (#15307)

* test: avoid flaky readonly dir assertion in extractZipFile (#15312)

* docs: add unassign-from-user safe output documentation (#15310)

* Fix TypeScript type errors in error handling for unknown types (#15308)

* Initial plan

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Mark L <73659136+liuxiaopai-ai@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review February 13, 2026 07:29
Copilot AI review requested due to automatic review settings February 13, 2026 07:29
@pelikhan pelikhan merged commit 8dbf507 into main Feb 13, 2026
52 of 53 checks passed
@pelikhan pelikhan deleted the main-4e38aad7759d2e5d branch February 13, 2026 07:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the GitHub-script-side memory validation utility while also introducing/refining several workflow, docs, and test behaviors across the repo.

Changes:

  • Modernize actions/setup/js/validate_memory_files.cjs (typedefs, optional chaining, simplified error formatting).
  • Improve robustness/consistency in error handling and tests (JS instanceof Error guards; Go test avoids flakiness under elevated permissions).
  • Add/adjust workflow and documentation pieces (new refiner workflow + lock, safe-outputs docs addition, smoke schedule cron adjustment).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
actions/setup/js/validate_memory_files.cjs Refactors memory file extension validation logic for readability/typing.
actions/setup/js/safe_output_handler_manager.cjs Hardens error-to-string conversion in PR review submission path.
actions/setup/js/safe_output_unified_handler_manager.cjs Same error handling hardening as the non-unified manager.
actions/setup/js/merge_remote_agent_github_folder.cjs String-quote normalization and whitespace cleanup.
pkg/cli/logs_extract_zip_test.go Makes extraction error test non-flaky when running with elevated permissions.
docs/src/content/docs/reference/safe-outputs.md Documents unassign-from-user safe output type with example config.
.github/workflows/refiner.md Adds a new “Code Refiner” agentic workflow manifest.
.github/workflows/refiner.lock.yml Adds compiled lock workflow for refiner.md.
.github/workflows/smoke-copilot.lock.yml Adjusts the compiled cron minute for the every-12h schedule.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +4
---
description: Aligns code style with repository conventions, detects security issues, and improves tests
on: pull_request labeled refine
permissions:
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The PR description focuses on cleaning actions/setup/js/validate_memory_files.cjs, but this PR also adds a new refiner workflow (and its generated lock), updates safe-outputs docs, tweaks a Go test, and changes a scheduled cron in an existing lock file. Please either update the PR description to cover these additional changes (and their motivation), or split the workflow/doc/test updates into separate PRs to keep scope reviewable.

Copilot uses AI. Check for mistakes.
create-pull-request:
title-prefix: "[refiner] "
labels: [automation, refine-improvements]
reviewers: [copilot]
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

safe-outputs.create-pull-request.reviewers is configured here, but the generated .github/workflows/refiner.lock.yml doesn’t appear to include any reviewer-assignment steps/config (no reviewer-related entries in the safe-outputs handler config). If this workflow needs to automatically request reviewers, wire this through in the compiled workflow (or enable/use the add-reviewer safe output instead); otherwise consider removing reviewers: to avoid implying behavior that won’t happen.

Suggested change
reviewers: [copilot]

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants