diff --git a/.claude/skills/development-workflow/SKILL.md b/.claude/skills/development-workflow/SKILL.md index 39c9e485..ca1c7814 100644 --- a/.claude/skills/development-workflow/SKILL.md +++ b/.claude/skills/development-workflow/SKILL.md @@ -19,8 +19,7 @@ This skill provides all commands and best practices for building, developing, an ## Testing - `pnpm test` - Run all tests (unit, examples, scripts) -- `pnpm test:unit` - Run only unit tests -- `pnpm vitest src/path/to/file.spec.ts` - Run a specific test file +- `pnpm vitest src/path/to/file.test.ts` - Run a specific test file - `pnpm vitest -t "test name"` - Run tests matching a pattern ## Code Quality diff --git a/.claude/skills/typescript-testing/SKILL.md b/.claude/skills/typescript-testing/SKILL.md index 05e4ae74..b13b7087 100644 --- a/.claude/skills/typescript-testing/SKILL.md +++ b/.claude/skills/typescript-testing/SKILL.md @@ -1,7 +1,7 @@ --- name: typescript-testing description: Use when writing or running tests. Covers Vitest commands, MSW HTTP mocking, fs-fixture for file system tests. (project) -globs: "*.spec.ts" +globs: "*.test.ts" alwaysApply: false --- @@ -13,8 +13,7 @@ This skill guides testing practices for the StackOne SDK using Vitest test runne The project uses **Vitest** as the test runner. Run tests with: - `pnpm test` - Run all tests (unit, examples, scripts) -- `pnpm test:unit` - Run only unit tests -- `pnpm vitest src/path/to/file.spec.ts` - Run a specific test file +- `pnpm vitest src/path/to/file.test.ts` - Run a specific test file - `pnpm vitest -t "test name"` - Run tests matching a pattern ### Vitest Globals diff --git a/src/tests/exports.spec.ts b/src/index.test.ts similarity index 94% rename from src/tests/exports.spec.ts rename to src/index.test.ts index ab1676da..a329197f 100644 --- a/src/tests/exports.spec.ts +++ b/src/index.test.ts @@ -1,4 +1,4 @@ -import * as StackOneAI from '../index'; +import * as StackOneAI from './index'; describe('Module Exports', () => { it('should export main classes and utilities', () => { diff --git a/src/tests/requestBuilder.spec.ts b/src/modules/requestBuilder.test.ts similarity index 99% rename from src/tests/requestBuilder.spec.ts rename to src/modules/requestBuilder.test.ts index 848a7b37..d6be823b 100644 --- a/src/tests/requestBuilder.spec.ts +++ b/src/modules/requestBuilder.test.ts @@ -1,8 +1,8 @@ import { http, HttpResponse } from 'msw'; import { server } from '../../mocks/node'; -import { RequestBuilder } from '../modules/requestBuilder'; import { type HttpExecuteConfig, ParameterLocation } from '../types'; import { StackOneAPIError } from '../utils/errors'; +import { RequestBuilder } from './requestBuilder'; describe('RequestBuilder', () => { let builder: RequestBuilder; diff --git a/src/rpc-client.spec.ts b/src/rpc-client.test.ts similarity index 100% rename from src/rpc-client.spec.ts rename to src/rpc-client.test.ts diff --git a/src/tests/json-schema.spec.ts b/src/tool.json-schema.test.ts similarity index 99% rename from src/tests/json-schema.spec.ts rename to src/tool.json-schema.test.ts index d8c0cf56..751d6a08 100644 --- a/src/tests/json-schema.spec.ts +++ b/src/tool.json-schema.test.ts @@ -1,6 +1,6 @@ import { jsonSchema } from 'ai'; import type { JSONSchema7 } from 'json-schema'; -import { StackOneTool } from '../tool'; +import { StackOneTool } from './tool'; describe('Schema Validation', () => { describe('Array Items in Schema', () => { diff --git a/src/tests/meta-tools.spec.ts b/src/tool.meta-tools.test.ts similarity index 99% rename from src/tests/meta-tools.spec.ts rename to src/tool.meta-tools.test.ts index 4156402f..09530f2b 100644 --- a/src/tests/meta-tools.spec.ts +++ b/src/tool.meta-tools.test.ts @@ -1,6 +1,6 @@ import { assert } from 'vitest'; -import { BaseTool, type MetaToolSearchResult, Tools } from '../tool'; -import { ParameterLocation } from '../types'; +import { BaseTool, type MetaToolSearchResult, Tools } from './tool'; +import { ParameterLocation } from './types'; // Create mock tools for testing const createMockTools = (): BaseTool[] => { diff --git a/src/tests/tool.test-d.ts b/src/tool.test-d.ts similarity index 94% rename from src/tests/tool.test-d.ts rename to src/tool.test-d.ts index b2cce361..e894bf34 100644 --- a/src/tests/tool.test-d.ts +++ b/src/tool.test-d.ts @@ -1,7 +1,7 @@ import type { ChatCompletionFunctionTool } from 'openai/resources/chat/completions'; import { assertType, test } from 'vitest'; -import { BaseTool, Tools } from '../tool'; -import type { AISDKToolResult } from '../types'; +import { BaseTool, Tools } from './tool'; +import type { AISDKToolResult } from './types'; const tool = new BaseTool( 'test_tool', diff --git a/src/tests/tool.spec.ts b/src/tool.test.ts similarity index 99% rename from src/tests/tool.spec.ts rename to src/tool.test.ts index 04e49367..5078f4e6 100644 --- a/src/tests/tool.spec.ts +++ b/src/tool.test.ts @@ -1,6 +1,6 @@ -import { BaseTool, StackOneTool, Tools } from '../tool'; -import { type ExecuteConfig, ParameterLocation, type ToolParameters } from '../types'; -import { StackOneAPIError } from '../utils/errors'; +import { BaseTool, StackOneTool, Tools } from './tool'; +import { type ExecuteConfig, ParameterLocation, type ToolParameters } from './types'; +import { StackOneAPIError } from './utils/errors'; // Create a mock tool for testing const createMockTool = (headers?: Record): BaseTool => { diff --git a/src/tests/feedback.spec.ts b/src/tools/feedback.test.ts similarity index 99% rename from src/tests/feedback.spec.ts rename to src/tools/feedback.test.ts index 6249ae75..b584c4aa 100644 --- a/src/tests/feedback.spec.ts +++ b/src/tools/feedback.test.ts @@ -1,7 +1,7 @@ import { http, HttpResponse } from 'msw'; import { server } from '../../mocks/node'; -import { createFeedbackTool } from '../tools/feedback'; import { StackOneError } from '../utils/errors'; +import { createFeedbackTool } from './feedback'; interface FeedbackResultItem { account_id: string; diff --git a/src/tests/base.spec.ts b/src/toolsets/base.test.ts similarity index 98% rename from src/tests/base.spec.ts rename to src/toolsets/base.test.ts index 3130339e..e300d715 100644 --- a/src/tests/base.spec.ts +++ b/src/toolsets/base.test.ts @@ -1,4 +1,4 @@ -import { ToolSet } from '../toolsets/base'; +import { ToolSet } from './base'; // Create a concrete implementation of the abstract ToolSet class for testing class TestToolSet extends ToolSet { diff --git a/src/tests/stackone.mcp-fetch.spec.ts b/src/toolsets/stackone.mcp-fetch.test.ts similarity index 99% rename from src/tests/stackone.mcp-fetch.spec.ts rename to src/toolsets/stackone.mcp-fetch.test.ts index 5a31d074..f0130186 100644 --- a/src/tests/stackone.mcp-fetch.spec.ts +++ b/src/toolsets/stackone.mcp-fetch.test.ts @@ -5,8 +5,8 @@ import { http } from 'msw'; import { type McpToolDefinition, createMcpApp } from '../../mocks/mcp-server'; import { server } from '../../mocks/node'; -import { ToolSet } from '../toolsets/base'; -import { StackOneToolSet } from '../toolsets/stackone'; +import { ToolSet } from './base'; +import { StackOneToolSet } from './stackone'; describe('ToolSet.fetchTools (MCP + RPC integration)', () => { it('creates tools from MCP catalog and wires RPC execution', async () => { diff --git a/src/tests/stackone.spec.ts b/src/toolsets/stackone.test.ts similarity index 97% rename from src/tests/stackone.spec.ts rename to src/toolsets/stackone.test.ts index 92794a5d..21770f7c 100644 --- a/src/tests/stackone.spec.ts +++ b/src/toolsets/stackone.test.ts @@ -1,5 +1,5 @@ -import { ToolSetConfigError } from '../toolsets/base'; -import { StackOneToolSet } from '../toolsets/stackone'; +import { ToolSetConfigError } from './base'; +import { StackOneToolSet } from './stackone'; describe('StackOneToolSet', () => { beforeEach(() => { diff --git a/src/tests/array.spec.ts b/src/utils/array.test.ts similarity index 87% rename from src/tests/array.spec.ts rename to src/utils/array.test.ts index 5da3c051..9c42ba76 100644 --- a/src/tests/array.spec.ts +++ b/src/utils/array.test.ts @@ -1,4 +1,4 @@ -import { toArray } from '../utils/array'; +import { toArray } from './array'; describe('toArray', () => { it.each([ diff --git a/src/tests/tfidf-index.spec.ts b/src/utils/tfidf-index.test.ts similarity index 99% rename from src/tests/tfidf-index.spec.ts rename to src/utils/tfidf-index.test.ts index df4d06a3..f6d22de7 100644 --- a/src/tests/tfidf-index.spec.ts +++ b/src/utils/tfidf-index.test.ts @@ -1,4 +1,4 @@ -import { TfidfIndex } from '../utils/tfidf-index'; +import { TfidfIndex } from './tfidf-index'; describe('TF-IDF Index - Core Functionality', () => { test('ranks documents by cosine similarity with tf-idf weighting', () => { diff --git a/vitest.config.ts b/vitest.config.ts index 13599329..d9448320 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -9,7 +9,7 @@ export default defineConfig({ provider: 'v8', reporter: ['text', 'json', 'json-summary', 'html'], include: ['src/**/*.ts', 'examples/**/*.ts'], - exclude: ['**/*.spec.ts', '**/*.test.ts', '**/*.test-d.ts', '**/tests/**'], + exclude: ['**/*.test.ts', '**/*.test-d.ts'], }, projects: [ { @@ -17,12 +17,12 @@ export default defineConfig({ test: { name: 'root', root: '.', - include: ['src/**/*.spec.ts', 'scripts/**/*.spec.ts'], + include: ['src/**/*.test.ts', 'scripts/**/*.test.ts'], exclude: ['node_modules', 'dist', 'examples'], setupFiles: ['./vitest.setup.ts'], typecheck: { enabled: true, - include: ['src/**/*.spec.ts', 'src/**/*.test-d.ts'], + include: ['src/**/*.test.ts', 'src/**/*.test-d.ts'], }, }, },