Skip to content

chore: track pnpm lockfile, add workspace; fix MDX env; adjust tests and tsconfig - #15

Merged
PaulJPhilp merged 27 commits into
mainfrom
feat/chatgpt-app
Oct 18, 2025
Merged

chore: track pnpm lockfile, add workspace; fix MDX env; adjust tests and tsconfig#15
PaulJPhilp merged 27 commits into
mainfrom
feat/chatgpt-app

Conversation

@PaulJPhilp

Copy link
Copy Markdown
Owner

This PR standardizes installs with pnpm, fixes effect-mdx env provision, and adjusts tests/tsconfig.\n\nChanges:\n- Track pnpm-lock.yaml; add pnpm-workspace.yaml; remove bun.lock & package-lock.json\n- Provide NodeFileSystem.layer and reorder Effect.provide for effect-mdx in scripts:\n - scripts/ingest/ingest-pipeline-improved.ts\n - scripts/publish/rules.ts\n - scripts/publish/validate-improved.ts\n- Exclude content/new/** from typecheck; skip runtime tests for content/new/src/** while keeping tsc\n\nVerification:\n- pnpm install --frozen-lockfile: up to date\n- pnpm run typecheck: passes\n- pnpm run test: passes (runtime excluded for content/new/src/**)\n\nFollow-ups:\n- Add CI steps: install --frozen-lockfile, typecheck, test\n- Optional: make runtime exclusion toggleable via env flag

PaulJPhilp and others added 25 commits October 9, 2025 21:52
- Add workspaces configuration for packages/* and services/*
- Create @effect-patterns/toolkit package with TypeScript, Vitest
- Create @effect-patterns/mcp-server package with Next.js App Router
- Configure strict TypeScript with Effect language service
- Add Prettier config (printWidth=80) and workspace scripts
- Set up OpenTelemetry dependencies for OTLP tracing
- Create basic Next.js app structure and environment template

Packages created:
- packages/toolkit: Core domain types and utilities
- services/mcp-server: API server with Next.js

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Core functionality:
- Effect schemas using @effect/schema for Pattern, PatternSummary,
  GenerateRequest, SearchPatternsRequest with full type safety
- Effect-based file IO (loadPatternsFromJson) with schema validation
- Fuzzy search implementation with relevance scoring
- Deterministic snippet generator with input sanitization
- JSON Schema emitter for LLM tool-call specifications
- Pure functions throughout, no side effects in business logic

Files implemented:
- src/schemas/pattern.ts: Domain types with Effect schemas
- src/schemas/generate.ts: API request/response schemas
- src/io.ts: Effect-based file operations
- src/search.ts: Fuzzy matching and filtering
- src/template.ts: Code snippet generation with sanitization
- src/emit-schemas.ts: Build-time JSON Schema emitter
- src/index.ts: Public API exports

Package builds successfully with TypeScript strict mode.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
OpenTelemetry OTLP Integration:
- TracingLayer as proper Effect Layer with acquire/release pattern
- Thin wrapper around @opentelemetry/sdk-node for OTLP HTTP export
- Environment-based configuration (OTLP_ENDPOINT, OTLP_HEADERS)
- Effect helpers: getTraceId(), startSpan(), withSpan()
- Graceful shutdown on process exit

Server Initialization:
- Layer composition: ConfigLayer -> TracingLayer -> PatternsLayer
- PatternsService with in-memory Ref cache loaded at cold-start
- Runtime singleton for executing Effects in Next.js handlers
- ConfigService for environment variables

Authentication:
- API key validation middleware using Effect
- Supports x-api-key header and ?key query parameter
- AuthenticationError for 401 responses
- Development mode fallback when key not configured

All business logic implemented as Effects, Next.js integration
uses Effect.runPromise only at route handler boundary.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implemented 5 REST API endpoints with full Effect integration:

1. GET /api/health
   - Service health check with version info
   - Returns traceId for request correlation

2. GET /api/patterns?q=&category=&difficulty=&limit=
   - Search patterns with fuzzy matching
   - Filter by category, difficulty
   - Requires API key authentication
   - Returns PatternSummary array with traceId

3. GET /api/patterns/:id
   - Get full pattern details by ID
   - Requires API key authentication
   - Returns Pattern with traceId
   - Returns 404 if pattern not found

4. POST /api/generate
   - Generate code snippet from pattern
   - Request body: {patternId, name?, input?, moduleType?, effectVersion?}
   - Requires API key authentication
   - Deterministic snippet generation with sanitization
   - Returns {patternId, title, snippet, traceId, timestamp}

5. GET /api/trace-wiring
   - Returns example code for trace ID propagation
   - Effect + OTLP and LangGraph Python examples
   - Best practices for distributed tracing
   - Requires API key authentication

All endpoints:
- Use Effect.gen for business logic
- Call runWithRuntime() only at Next.js boundary
- Include traceId in response body and x-trace-id header
- Handle AuthenticationError with 401 responses
- Proper error handling with appropriate status codes

Sample patterns.json included with 2 example patterns.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Created Claude plugin integration files:

.claude-plugin/marketplace.json:
- Plugin metadata for marketplace listing
- API endpoint configuration (Vercel deployment)
- API key authentication requirement

.claude-plugin/plugins/effect-patterns/plugin.json:
- 5 command definitions matching API endpoints
- search-patterns, get-pattern, generate-snippet, trace-wiring, health-check
- Parameter schemas for each command
- Effect Pattern Assistant agent with specialized system prompt

Plugin enables Claude Code users to:
- Search Effect patterns with fuzzy matching
- Generate customized code snippets
- Get trace wiring examples
- Access patterns directly in their editor

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Complete documentation of MVP implementation including:
- All implemented components and file listings
- Architecture decisions and trade-offs
- Local development setup instructions
- Environment variable configuration
- API endpoint testing examples
- Known limitations and next steps
- Deployment notes for Vercel
- Acceptance criteria status matrix

Report serves as definitive reference for PR reviewers
and team members continuing the implementation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implemented 145 unit tests with 100% pass rate covering:

1. Search Functionality (38 tests):
   - Fuzzy search algorithm with relevance scoring
   - Title, description, tag, and category matching
   - Case-insensitive search
   - Category and difficulty filters
   - Limit parameter handling
   - Edge cases (empty arrays, special characters, whitespace)
   - Pattern lookup by ID
   - PatternSummary conversion

2. Template/Snippet Generation (45 tests):
   - Input sanitization (removes <>, backticks, $, newlines)
   - Length limiting (100 chars)
   - ESM vs CJS module type generation
   - Custom name and input parameter substitution
   - Effect version header inclusion
   - Patterns without examples (placeholder generation)
   - Combined parameter handling
   - Edge cases (empty inputs, long strings, multiple examples)

3. IO Operations (19 tests):
   - Effect-based file loading with schema validation
   - Valid patterns.json parsing
   - Multiple patterns support
   - Optional field handling
   - Error cases (missing files, invalid JSON, schema violations)
   - UTF-8 character handling
   - Category and difficulty enum validation

4. Schema Validation (43 tests):
   - Effect schema validation for all domain types
   - Pattern, PatternSummary, PatternsIndex schemas
   - GenerateRequest, GenerateResponse schemas
   - SearchPatternsRequest with NumberFromString conversion
   - Category and difficulty enum validation
   - Required vs optional fields
   - Array type validation
   - Edge cases (null values, extra fields)

Test Infrastructure:
- Uses Vitest for fast, modern testing
- Effect.runPromise for async Effect testing
- Temp file creation/cleanup for IO tests
- Comprehensive test fixtures and mocks

All tests pass successfully, validating core toolkit functionality
before integration with MCP server.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implemented 60+ integration tests for MCP server:

Mock OTLP Collector (tests/mock-otlp-server.ts):
- Lightweight HTTP server mimicking OTLP collector
- Receives trace exports on POST /v1/traces
- Stores traces in memory for verification
- Helper methods to query spans by name, trace ID
- Automatic start/stop for test lifecycle

API Integration Tests (tests/integration/api.test.ts):
- All 5 endpoints comprehensively tested
- Authentication validation (header and query param)
- Trace ID propagation (body + x-trace-id header)
- OTLP export verification
- Request/response validation
- Error scenarios (401, 404, 400)

Endpoints Tested:
1. GET /api/health
   - No auth required
   - Returns version, service name, timestamp
   - Includes trace ID

2. GET /api/patterns
   - Requires authentication
   - Search with query parameter
   - Filter by category and difficulty
   - Limit results
   - Returns pattern summaries

3. GET /api/patterns/:id
   - Requires authentication
   - Returns full pattern with examples
   - 404 for non-existent patterns

4. POST /api/generate
   - Requires authentication
   - Generate snippets with custom name, input
   - Module type support (ESM/CJS)
   - 400 for invalid requests
   - 404 for non-existent patterns

5. GET /api/trace-wiring
   - Requires authentication
   - Returns Effect and Python examples
   - Integration best practices

Authentication Tests:
- Valid API key in header (x-api-key)
- Valid API key in query (?key=)
- Invalid/missing key rejection (401)
- Header preference over query

OTLP Tracing Tests:
- Traces exported to collector
- Service name in trace metadata
- Span creation for requests
- Trace ID consistency

Test Infrastructure:
- Uses Vitest for testing
- Fetch API for HTTP requests
- Mock OTLP server on port 4318
- Async trace export handling
- Comprehensive README with setup instructions

Tests designed to run against live Next.js dev server,
verifying full end-to-end integration including Effect
runtime, tracing layer, and API endpoints.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add GitHub Actions CI workflow with Bun support
  - Lint job with Prettier and Biome checks
  - TypeScript type checking
  - Unit tests with coverage reporting to Codecov
  - Toolkit and MCP server build jobs
  - Integration tests with mock OTLP collector
  - ci-success meta-job for branch protection

- Add generate-patterns workflow
  - Clones EffectPatterns source repository
  - Generates patterns.json from source
  - Auto-commits changes when patterns update
  - Runs on schedule (daily) and manual trigger

- Add CI and coverage badges to README
  - GitHub Actions workflow status badge
  - Codecov coverage badge

- Document branch protection configuration
  - Required status checks for main branch
  - GitHub UI, API, and Terraform examples
  - Local testing instructions
  - Troubleshooting guide

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add Vercel configuration for MCP server deployment
  - Next.js framework with Bun build support
  - Environment variable setup for staging
  - Function memory and timeout configuration
  - IAD1 region for optimal performance

- Create comprehensive deployment documentation
  - Environment variable setup guide
  - Vercel CLI and dashboard configuration
  - GitHub Actions integration examples
  - Monitoring and rollback procedures
  - Security checklist and best practices

- Implement dual smoke test suite
  - TypeScript version using native fetch API
  - Bash version using curl and jq
  - 21+ tests covering all API endpoints
  - Authentication and authorization tests
  - Pattern search and retrieval tests
  - Snippet generation tests
  - Trace wiring tests
  - Performance and error handling tests

- Add GitHub Actions staging deployment workflow
  - Automatic deployment on push to feat/effect-mcp
  - Wait for deployment readiness
  - Run smoke tests against deployment
  - Comment deployment URL on PRs
  - Set deployment status

- Add npm scripts for smoke testing
  - smoke-test: TypeScript version with Bun
  - smoke-test:bash: Bash version with curl

Features:
- Both smoke test implementations provide identical coverage
- Colorized output for better readability
- Detailed error messages and assertions
- Response time benchmarks
- Trace ID consistency verification
- Full documentation in SMOKE_TESTS.md

Usage:
  bun run smoke-test https://staging.vercel.app staging-key
  ./smoke-test.sh https://staging.vercel.app staging-key

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Step-by-step deployment instructions
- Environment variable configuration
- OpenTelemetry setup options (Honeycomb, Jaeger, none)
- GitHub Actions integration guide
- Monitoring and debugging procedures
- Cost optimization tips
- Troubleshooting common issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
feat: add live analyzer test and document agent workflows
- **refactor**: relocate analyzer to `agents/analyzer/` and update configs
- **test**: drop legacy `MdxService` imports from publish/rules tests
- **fix**: ensure [extractGeminiText()](cci:1://file:///Users/paul/Projects/Effect-Patterns/scripts/autofix/prepublish-autofix.ts:521:0-538:1) always returns a string for typecheck
- Implement Model Context Protocol server with stdio transport
- Add 3 tools: search_patterns, get_pattern, generate_snippet
- Full TypeScript with strict mode and comprehensive tests
- Integration with @effect-patterns/toolkit
- Documentation: README, INSTALLATION, SUMMARY
- Sample patterns data file for testing
- Claude Desktop configuration example

All tests passing (5/5)
@github-advanced-security

Copy link
Copy Markdown
Contributor

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@vercel

vercel Bot commented Oct 17, 2025

Copy link
Copy Markdown

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

Project Deployment Preview Comments Updated (UTC)
effect-patterns Error Error Oct 17, 2025 9:51pm
effect-patterns-mcp-server Ready Ready Preview Comment Oct 17, 2025 9:51pm

💡 Enable Vercel Agent with $100 free credit for automated AI reviews


// Unlike buildSnippet, this doesn't add imports
const codeLines = example.split('\n');
const commentLines = codeLines.filter((line) => line.startsWith('//'));

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused variable commentLines.

Copilot Autofix

AI 11 months ago

To resolve this issue, simply remove the declaration of the unused variable commentLines from line 452 within the file packages/toolkit/tests/template.test.ts. Nothing else in the snippet refers to this variable, so its removal will not alter existing functionality. Only a single line needs to be deleted; no changes to imports, function parameters, or other code sections are necessary.

Suggested changeset 1
packages/toolkit/tests/template.test.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/toolkit/tests/template.test.ts b/packages/toolkit/tests/template.test.ts
--- a/packages/toolkit/tests/template.test.ts
+++ b/packages/toolkit/tests/template.test.ts
@@ -449,7 +449,6 @@
 
     // Unlike buildSnippet, this doesn't add imports
     const codeLines = example.split('\n');
-    const commentLines = codeLines.filter((line) => line.startsWith('//'));
     const exampleCode = pattern.examples[0].code;
 
     expect(example).not.toContain('import { Effect, pipe } from "effect"');
EOF
@@ -449,7 +449,6 @@

// Unlike buildSnippet, this doesn't add imports
const codeLines = example.split('\n');
const commentLines = codeLines.filter((line) => line.startsWith('//'));
const exampleCode = pattern.examples[0].code;

expect(example).not.toContain('import { Effect, pipe } from "effect"');
Copilot is powered by AI and may make mistakes. Always verify output.
const TEST_DIR = ".cursor-test";
const TEST_FILE = path.join(TEST_DIR, "rules.md");
const TEST_DIR = '.cursor-test';
const TEST_FILE = path.join(TEST_DIR, 'rules.md');

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable TEST_FILE.

Copilot Autofix

AI 11 months ago

The best way to fix the problem is to remove the unused TEST_FILE variable declaration from the script. Specifically, in the file scripts/ep-rules-add.test.ts, remove the line:

55: const TEST_FILE = path.join(TEST_DIR, 'rules.md');

No additional code, imports, or variable definitions are needed. The rest of the script remains unchanged.

Suggested changeset 1
scripts/ep-rules-add.test.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/ep-rules-add.test.ts b/scripts/ep-rules-add.test.ts
--- a/scripts/ep-rules-add.test.ts
+++ b/scripts/ep-rules-add.test.ts
@@ -52,7 +52,6 @@
   });
 
 const TEST_DIR = '.cursor-test';
-const TEST_FILE = path.join(TEST_DIR, 'rules.md');
 
 // --- TESTS ---
 
EOF
@@ -52,7 +52,6 @@
});

const TEST_DIR = '.cursor-test';
const TEST_FILE = path.join(TEST_DIR, 'rules.md');

// --- TESTS ---

Copilot is powered by AI and may make mistakes. Always verify output.
let actualStdout = '';
let actualStderr = '';
let actualErrorDetail = '';
let executionStatus: 'success' | 'failure' = 'success';

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

The initial value of executionStatus is unused, since it is always overwritten.

Copilot Autofix

AI 11 months ago

To fix the issue, remove the initial assignment of 'success' to executionStatus in its declaration. Instead, declare the variable with its type but without assigning a value (let executionStatus: 'success' | 'failure';). This ensures that the variable is only given a value in the relevant execution branches, eliminating the useless assignment. Only edit the line in scripts/ingest/populate-expectations.ts that declares executionStatus. No other code, imports, or definitions are needed for implementing the change.

Suggested changeset 1
scripts/ingest/populate-expectations.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/ingest/populate-expectations.ts b/scripts/ingest/populate-expectations.ts
--- a/scripts/ingest/populate-expectations.ts
+++ b/scripts/ingest/populate-expectations.ts
@@ -166,7 +166,7 @@
     let actualStdout = '';
     let actualStderr = '';
     let actualErrorDetail = '';
-    let executionStatus: 'success' | 'failure' = 'success';
+    let executionStatus: 'success' | 'failure';
 
     // 3. Execute the TypeScript file (if TS content was found)
     if (tsCodeContent.trim().length > 0) {
EOF
@@ -166,7 +166,7 @@
let actualStdout = '';
let actualStderr = '';
let actualErrorDetail = '';
let executionStatus: 'success' | 'failure' = 'success';
let executionStatus: 'success' | 'failure';

// 3. Execute the TypeScript file (if TS content was found)
if (tsCodeContent.trim().length > 0) {
Copilot is powered by AI and may make mistakes. Always verify output.
break
nextLines += lines[j];
if (lines[j].includes('))')) {
endFound = true;

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

The value assigned to endFound here is unused.

Copilot Autofix

AI 11 months ago

To fix the problem, simply remove the unnecessary assignment to endFound = true; on line 82. Only the break; statement is needed to terminate the inner loop when the condition is met. You do not need any additional imports, methods, or definitions. No other changes are required, as endFound is neither read nor otherwise used in the function. Make sure to only remove the line with the assignment that is never used. The definition of let endFound = false; can technically also be removed, since endFound has no effect, but since we're operating only on visible code blocks and it's harmless, it can be left unless explicitly required by a further lint rule.

Suggested changeset 1
scripts/publish/lint-effect-patterns.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/publish/lint-effect-patterns.ts b/scripts/publish/lint-effect-patterns.ts
--- a/scripts/publish/lint-effect-patterns.ts
+++ b/scripts/publish/lint-effect-patterns.ts
@@ -79,7 +79,6 @@
       for (let j = i + 1; j < Math.min(i + 10, lines.length); j++) {
         nextLines += lines[j];
         if (lines[j].includes('))')) {
-          endFound = true;
           break;
         }
       }
EOF
@@ -79,7 +79,6 @@
for (let j = i + 1; j < Math.min(i + 10, lines.length); j++) {
nextLines += lines[j];
if (lines[j].includes('))')) {
endFound = true;
break;
}
}
Copilot is powered by AI and may make mistakes. Always verify output.

const result = await execAsync(
`node --expose-gc -e "${testCode.replace(/\n/g, " ").replace(/"/g, '\\"')}"`,
`node --expose-gc -e "${testCode.replace(/\n/g, ' ').replace(/"/g, '\\"')}"`,

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High test

This does not escape backslash characters in the input.

Copilot Autofix

AI 11 months ago

To correctly escape the string for use as a shell argument to node -e "...code...", all meta-characters that could affect shell or JavaScript parsing must be safely handled. Currently, only double quotes and newlines are escaped. The fix is to also escape backslashes (\), since if one appears before a double quote or another escape sequence, it could result in syntactically invalid code or broken escaping within the string.

The single best way is to replace every backslash (\) with a double backslash (\\), before replacing double quotes, to avoid a double-escaping problem. Specifically:

  • Escape backslashes: .replace(/\\/g, '\\\\')
  • Then escape double quotes: .replace(/"/g, '\\"')
  • Then replace newlines (optional, but you may want to preserve formatting): .replace(/\n/g, ' ')

Thus, in file scripts/publish/test-behavioral.ts, line 145 should be updated so that the .replace chain first escapes backslashes, then double quotes, then newlines.

No external libraries are needed — use native .replace with regular expressions.

Suggested changeset 1
scripts/publish/test-behavioral.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/publish/test-behavioral.ts b/scripts/publish/test-behavioral.ts
--- a/scripts/publish/test-behavioral.ts
+++ b/scripts/publish/test-behavioral.ts
@@ -142,7 +142,7 @@
     `;
 
     const result = await execAsync(
-      `node --expose-gc -e "${testCode.replace(/\n/g, ' ').replace(/"/g, '\\"')}"`,
+      `node --expose-gc -e "${testCode.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, ' ')}"`,
       {
         timeout: 30_000,
         maxBuffer: 10 * 1024 * 1024,
EOF
@@ -142,7 +142,7 @@
`;

const result = await execAsync(
`node --expose-gc -e "${testCode.replace(/\n/g, ' ').replace(/"/g, '\\"')}"`,
`node --expose-gc -e "${testCode.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, ' ')}"`,
{
timeout: 30_000,
maxBuffer: 10 * 1024 * 1024,
Copilot is powered by AI and may make mistakes. Always verify output.

const execAsync = promisify(exec)
const execAsync = promisify(exec);

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused variable execAsync.

Copilot Autofix

AI 11 months ago

The best way to resolve this issue is to remove the unused variable definition for execAsync on line 13. This improves code clarity, avoids confusion for future maintainers, and eliminates the possibility of mistakenly thinking this variable is used by the code. The change should only remove the definition line, and no other region or code needs to be updated since execAsync is never used elsewhere in the snippet.


Suggested changeset 1
scripts/qa/test-enhanced-qa.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/qa/test-enhanced-qa.ts b/scripts/qa/test-enhanced-qa.ts
--- a/scripts/qa/test-enhanced-qa.ts
+++ b/scripts/qa/test-enhanced-qa.ts
@@ -10,7 +10,6 @@
 import * as path from 'path';
 import { promisify } from 'util';
 
-const execAsync = promisify(exec);
 
 const PROJECT_ROOT = process.cwd();
 const PATTERNS_DIR = path.join(PROJECT_ROOT, 'content/new/processed');
EOF
@@ -10,7 +10,6 @@
import * as path from 'path';
import { promisify } from 'util';

const execAsync = promisify(exec);

const PROJECT_ROOT = process.cwd();
const PATTERNS_DIR = path.join(PROJECT_ROOT, 'content/new/processed');
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread server/index.ts
@@ -39,23 +43,23 @@
/**
* Tagged error for server-related failures
*/
class ServerError extends Data.TaggedError("ServerError")<{
class ServerError extends Data.TaggedError('ServerError')<{

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused class ServerError.

Copilot Autofix

AI 11 months ago

To resolve this issue, we should remove the unused class ServerError from the code. This means deleting lines 46 to 50, corresponding to the entirety of the ServerError class definition. No additional changes (such as changes to imports or other variable definitions) are required, as the class is not referenced elsewhere in the shown code. Care should be taken to preserve surrounding comments and whitespace for readability.

Suggested changeset 1
server/index.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/server/index.ts b/server/index.ts
--- a/server/index.ts
+++ b/server/index.ts
@@ -43,11 +43,6 @@
 /**
  * Tagged error for server-related failures
  */
-class ServerError extends Data.TaggedError('ServerError')<{
-  readonly message: string;
-  readonly cause?: unknown;
-}> {}
-
 /**
  * Tagged error for rule loading failures
  */
EOF
@@ -43,11 +43,6 @@
/**
* Tagged error for server-related failures
*/
class ServerError extends Data.TaggedError('ServerError')<{
readonly message: string;
readonly cause?: unknown;
}> {}

/**
* Tagged error for rule loading failures
*/
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +17 to +23
import {
buildSnippet,
getPatternById,
loadPatternsFromJsonRunnable,
searchPatterns,
type Pattern,
} from '@effect-patterns/toolkit';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import loadPatternsFromJsonRunnable.

Copilot Autofix

AI 11 months ago

To fix the problem, we should remove the unused loadPatternsFromJsonRunnable from the import list from '@effect-patterns/toolkit' on line 20 in services/mcp-server-stdio/src/index.ts. It does not affect current functionality since the identifier is not used anywhere else in the provided code. Simply deleting this specific entry from the multiline import will make the code cleaner and easier to maintain. No other code changes, imports, or definitions are necessary.

Suggested changeset 1
services/mcp-server-stdio/src/index.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/services/mcp-server-stdio/src/index.ts b/services/mcp-server-stdio/src/index.ts
--- a/services/mcp-server-stdio/src/index.ts
+++ b/services/mcp-server-stdio/src/index.ts
@@ -17,7 +17,6 @@
 import {
   buildSnippet,
   getPatternById,
-  loadPatternsFromJsonRunnable,
   searchPatterns,
   type Pattern,
 } from '@effect-patterns/toolkit';
EOF
@@ -17,7 +17,6 @@
import {
buildSnippet,
getPatternById,
loadPatternsFromJsonRunnable,
searchPatterns,
type Pattern,
} from '@effect-patterns/toolkit';
Copilot is powered by AI and may make mistakes. Always verify output.
searchPatterns,
type Pattern,
} from '@effect-patterns/toolkit';
import { Effect } from 'effect';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import Effect.

Copilot Autofix

AI 11 months ago

To fix this error, the unused import should be removed entirely. Specifically, delete the line import { Effect } from 'effect'; (line 24 in services/mcp-server-stdio/src/index.ts). This change will not affect any functionality since Effect is never utilized in the provided snippet.


Suggested changeset 1
services/mcp-server-stdio/src/index.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/services/mcp-server-stdio/src/index.ts b/services/mcp-server-stdio/src/index.ts
--- a/services/mcp-server-stdio/src/index.ts
+++ b/services/mcp-server-stdio/src/index.ts
@@ -21,7 +21,7 @@
   searchPatterns,
   type Pattern,
 } from '@effect-patterns/toolkit';
-import { Effect } from 'effect';
+
 import { readFileSync } from 'node:fs';
 import { fileURLToPath } from 'node:url';
 import { dirname, join } from 'node:path';
EOF
@@ -21,7 +21,7 @@
searchPatterns,
type Pattern,
} from '@effect-patterns/toolkit';
import { Effect } from 'effect';

import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
Copilot is powered by AI and may make mistakes. Always verify output.
}

function printInfo(text: string) {
console.log(`${colors.blue}ℹ ${text}${colors.reset}`);

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This logs sensitive data returned by
an access to API_KEY
as clear text.

Copilot Autofix

AI 11 months ago

To eliminate the risk, do not log the API key or any portion of it to the console (or logs), even in informational messages.

  • The best way is to remove or redact the log statement on line 108:
    • Option 1 (recommended): Delete the line that logs the API key entirely so it's not written to logs.
    • Option 2: If logging is required for debugging (NOT recommended for general use), print a redacted string such as "API Key: [REDACTED]" or "[hidden]" so the presence of a key is shown, but the value is never revealed.
  • Changes required:
    • Edit services/mcp-server/smoke-test.ts: remove or replace line 108.
    • No extra imports, as no external libraries are needed for redaction.
    • If replacing rather than deleting, retain formatting and color, but change the string to "[REDACTED]".

Suggested changeset 1
services/mcp-server/smoke-test.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/services/mcp-server/smoke-test.ts b/services/mcp-server/smoke-test.ts
--- a/services/mcp-server/smoke-test.ts
+++ b/services/mcp-server/smoke-test.ts
@@ -105,7 +105,7 @@
 async function runSmokeTests() {
   printHeader('Effect Patterns MCP Server - Smoke Tests');
   printInfo(`Base URL: ${baseUrl}`);
-  printInfo(`API Key: ${API_KEY.substring(0, 10)}...`);
+  printInfo(`API Key: [REDACTED]`);
 
   // Test 1: Health Check (No Auth)
   await runTest('Health check endpoint (no auth required)', async () => {
EOF
@@ -105,7 +105,7 @@
async function runSmokeTests() {
printHeader('Effect Patterns MCP Server - Smoke Tests');
printInfo(`Base URL: ${baseUrl}`);
printInfo(`API Key: ${API_KEY.substring(0, 10)}...`);
printInfo(`API Key: [REDACTED]`);

// Test 1: Health Check (No Auth)
await runTest('Health check endpoint (no auth required)', async () => {
Copilot is powered by AI and may make mistakes. Always verify output.
@@ -0,0 +1,3 @@
import { Effect } from "effect"

const program = Effect.succeed("test")

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused variable program.

Copilot Autofix

AI 11 months ago

The best fix is to remove the declaration of the unused variable program. Specifically:

  • In file content/new/src/test-pattern-1.ts, remove the line that declares program (line 3).
  • No further changes or imports are required, as the variable is not used in any fashion in the shown code.
Suggested changeset 1
content/new/src/test-pattern-1.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/content/new/src/test-pattern-1.ts b/content/new/src/test-pattern-1.ts
--- a/content/new/src/test-pattern-1.ts
+++ b/content/new/src/test-pattern-1.ts
@@ -1,3 +1 @@
-import { Effect } from "effect"
-
-const program = Effect.succeed("test")
\ No newline at end of file
+import { Effect } from "effect"
\ No newline at end of file
EOF
@@ -1,3 +1 @@
import { Effect } from "effect"

const program = Effect.succeed("test")
import { Effect } from "effect"
Copilot is powered by AI and may make mistakes. Always verify output.
@@ -0,0 +1,3 @@
import { Effect } from "effect"

const program = Effect.all([task1, task2])

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused variable program.

Copilot Autofix

AI 11 months ago

To fix this problem, it is best to remove the unused variable program from the code. This involves deleting the declaration and initialization statement for program. Only lines within the provided snippet should be changed, and no other logic should be altered, as nothing else references or uses program. No additional methods, imports, or variable definitions are needed.

Suggested changeset 1
content/new/src/test-pattern-2.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/content/new/src/test-pattern-2.ts b/content/new/src/test-pattern-2.ts
--- a/content/new/src/test-pattern-2.ts
+++ b/content/new/src/test-pattern-2.ts
@@ -1,3 +1 @@
-import { Effect } from "effect"
-
-const program = Effect.all([task1, task2])
\ No newline at end of file
+import { Effect } from "effect"
\ No newline at end of file
EOF
@@ -1,3 +1 @@
import { Effect } from "effect"

const program = Effect.all([task1, task2])
import { Effect } from "effect"
Copilot is powered by AI and may make mistakes. Always verify output.
@@ -0,0 +1,3 @@
import { Effect } from "effect"

const program = Effect.retry(task, { times: 3 })

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused variable program.

Copilot Autofix

AI 11 months ago

The best way to fix the problem is to remove the declaration of the unused variable program. Specifically, delete line 3 which declares and initializes program. No other changes are necessary, as there are no usages, exports, or references to the variable in the provided code. No imports or additional definitions are required; the rest of the code can remain untouched.

Suggested changeset 1
content/new/src/test-pattern-3.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/content/new/src/test-pattern-3.ts b/content/new/src/test-pattern-3.ts
--- a/content/new/src/test-pattern-3.ts
+++ b/content/new/src/test-pattern-3.ts
@@ -1,3 +1 @@
-import { Effect } from "effect"
-
-const program = Effect.retry(task, { times: 3 })
\ No newline at end of file
+import { Effect } from "effect"
\ No newline at end of file
EOF
@@ -1,3 +1 @@
import { Effect } from "effect"

const program = Effect.retry(task, { times: 3 })
import { Effect } from "effect"
Copilot is powered by AI and may make mistakes. Always verify output.
@PaulJPhilp
PaulJPhilp merged commit 57441bd into main Oct 18, 2025
17 of 37 checks passed
@PaulJPhilp
PaulJPhilp deleted the feat/chatgpt-app branch October 18, 2025 17:08
PaulJPhilp added a commit that referenced this pull request Jan 18, 2026
chore: track pnpm lockfile, add workspace; fix MDX env; adjust tests and tsconfig
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