Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI

on:
pull_request:
branches:
- '**'
push:
branches:
- main

jobs:
test:
name: Test & Lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run linting
run: pnpm run lint

- name: Check formatting
run: pnpm run format:check

- name: Build packages
run: pnpm run build

- name: Run tests
run: pnpm run test

4 changes: 2 additions & 2 deletions examples/basic-usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const p = prompt("You are a helpful customer service agent")

// Compile for different providers
console.log("=== Generic Format ===");
console.log(p["systemPrompt"]);
console.log(p.systemPrompt);

console.log("\n=== OpenAI Format ===");
const openaiResult = p.toOpenAI();
Expand All @@ -26,4 +26,4 @@ const conversationMessages = [

const messagesWithSystem = p.toVercelAI(conversationMessages);
console.log("\n=== Prepared Messages ===");
console.log(JSON.stringify(messagesWithSystem, null, 2));
console.log(JSON.stringify(messagesWithSystem, null, 2));
1 change: 0 additions & 1 deletion examples/eval-example.prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,3 @@ export const emailWriter = prompt(
},
],
});

2 changes: 1 addition & 1 deletion examples/tool-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ console.log(' model: "gpt-4",');
console.log(" messages: openaiResult.messages,");
console.log(" tools: openaiResult.tools,");
console.log(' tool_choice: "auto"');
console.log("});");
console.log("});");
2 changes: 1 addition & 1 deletion examples/vercel-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ export async function POSTAnthropic(req: Request) {
console.error("Chat API error:", error);
return new Response("Internal Server Error", { status: 500 });
}
}
}
54 changes: 27 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"name": "marrakesh",
"private": true,
"version": "0.1.0-alpha.2",
"description": "A structured, testable, and data-driven context engineering SDK",
"license": "Apache-2.0",
"scripts": {
"build": "turbo build",
"dev": "turbo dev",
"test": "turbo test",
"lint": "biome lint .",
"format": "biome format --write .",
"format:check": "biome format .",
"clean": "turbo clean"
},
"devDependencies": {
"turbo": "^2.0.0",
"typescript": "^5.0.0",
"tsup": "^8.0.0",
"vitest": "^1.0.0",
"@types/node": "^20.0.0",
"@biomejs/biome": "^1.8.0"
},
"packageManager": "pnpm@8.0.0",
"engines": {
"node": ">=18.0.0"
}
}
"name": "marrakesh",
"private": true,
"version": "0.1.0-alpha.2",
"description": "A structured, testable, and data-driven context engineering SDK",
"license": "Apache-2.0",
"scripts": {
"build": "turbo build",
"dev": "turbo dev",
"test": "turbo test",
"lint": "biome lint .",
"format": "biome format --write .",
"format:check": "biome format .",
"clean": "turbo clean"
},
"devDependencies": {
"turbo": "^2.0.0",
"typescript": "^5.0.0",
"tsup": "^8.0.0",
"vitest": "^1.0.0",
"@types/node": "^20.0.0",
"@biomejs/biome": "^1.8.0"
},
"packageManager": "pnpm@9.0.0",
"engines": {
"node": ">=18.0.0"
}
}
14 changes: 5 additions & 9 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@marrakesh/cli",
"version": "0.1.0-alpha.2",
"description": "CLI for testing Marrakesh prompts",
"license": "Apache-2.0",
"name": "@marrakesh/cli",
"version": "0.1.0-alpha.2",
"description": "CLI for testing Marrakesh prompts",
"license": "Apache-2.0",
"type": "module",
"bin": {
"marrakesh": "./dist/index.js"
Expand All @@ -15,10 +15,7 @@
"import": "./dist/index.js"
}
},
"files": [
"dist",
"README.md"
],
"files": ["dist", "README.md"],
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
Expand All @@ -41,4 +38,3 @@
"@types/node": "^20.0.0"
}
}

1 change: 0 additions & 1 deletion packages/cli/src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,3 @@ export const testCommand = new Command("test")
process.exit(1);
}
});

1 change: 0 additions & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ program
program.addCommand(testCommand);

program.parse();

1 change: 0 additions & 1 deletion packages/cli/src/output/Reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,3 @@ export class Reporter {
console.log(); // blank line
}
}

1 change: 0 additions & 1 deletion packages/cli/src/output/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@ export function formatError(error: Error): string {

return output;
}

1 change: 0 additions & 1 deletion packages/cli/src/runner/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,3 @@ export class TestRunner {
return finalResults;
}
}

9 changes: 4 additions & 5 deletions packages/cli/src/watch/Watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export class Watcher {
/**
* Start watching files and running tests
*/
async start(
onResults: (results: RunnerResults) => void,
): Promise<void> {
async start(onResults: (results: RunnerResults) => void): Promise<void> {
// Initial run
await this.runTests(onResults);

Expand All @@ -52,7 +50,9 @@ export class Watcher {
// Handle keyboard input
this.setupKeyboardHandlers(onResults);

console.log("\n👁️ Watching for changes... (Press Ctrl+C to exit, 'a' to run all tests)\n");
console.log(
"\n👁️ Watching for changes... (Press Ctrl+C to exit, 'a' to run all tests)\n",
);

// Keep process alive
return new Promise(() => {
Expand Down Expand Up @@ -133,4 +133,3 @@ export class Watcher {
}
}
}

1 change: 0 additions & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}

1 change: 0 additions & 1 deletion packages/cli/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ export default defineConfig({
js: "#!/usr/bin/env node",
},
});

16 changes: 8 additions & 8 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@marrakesh/core",
"version": "0.1.0-alpha.2",
"description": "Minimal, type-safe tool integration for LLMs",
"license": "Apache-2.0",
"name": "@marrakesh/core",
"version": "0.1.0-alpha.2",
"description": "Minimal, type-safe tool integration for LLMs",
"license": "Apache-2.0",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand All @@ -11,17 +11,17 @@
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
"require": "./dist/index.cjs"
}
},
"files": ["dist", "README.md"],
"peerDependencies": {
"zod": "^3.0.0",
"ai": "^3.0.0 || ^4.0.0 || ^5.0.0"
},
"peerDependenciesMeta": {
},
"peerDependenciesMeta": {
"ai": {
"optional": true
"optional": true
}
},
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/PromptBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,4 +502,4 @@ ${JSON.stringify(jsonSchema, null, 2)}
*/
export function prompt(systemPrompt?: string): PromptBuilder {
return new PromptBuilder(systemPrompt);
}
}
14 changes: 7 additions & 7 deletions packages/core/src/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* Analytics module exports
*/

export { AnalyticsClient } from './AnalyticsClient.js';
export type {
ToolCall,
PromptMetadata,
PromptExecution,
IngestionRequest
} from './types.js';
export { AnalyticsClient } from "./AnalyticsClient.js";
export type {
ToolCall,
PromptMetadata,
PromptExecution,
IngestionRequest,
} from "./types.js";
export {
generatePromptId,
generateExecutionId,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/compilers/AnthropicCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ ${JSON.stringify(jsonSchema, null, 2)}
system: systemPrompt,
tools: tools.length > 0 ? tools : undefined,
};
}
}
2 changes: 1 addition & 1 deletion packages/core/src/compilers/GenericCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ export function toGeneric(promptBuilder: PromptBuilder): string {
}

return parts.join("\n");
}
}
2 changes: 1 addition & 1 deletion packages/core/src/compilers/OpenAICompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ export function toOpenAI(
tools: tools.length > 0 ? tools : undefined,
response_format,
};
}
}
5 changes: 3 additions & 2 deletions packages/core/src/executors/VercelAIExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export function createVercelAIExecutor(config: ExecutorConfig): Executor {

// Get the tool descriptions from the tools object
const toolDescriptions = tools
? Object.values(tools).map((t: any) => t.description)
? Object.values(tools).map(
(t: { description: string }) => t.description,
)
: [];

// Execute with tool calling loop using Promise.race for timeout
Expand Down Expand Up @@ -187,4 +189,3 @@ export function createVercelAIExecutor(config: ExecutorConfig): Executor {
}
};
}

1 change: 0 additions & 1 deletion packages/core/src/executors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ export type {

// Convenience export for the most common case
export { createVercelAIExecutor as createExecutor } from "./VercelAIExecutor.js";

1 change: 0 additions & 1 deletion packages/core/src/executors/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ export type Executor = (
prompt: PromptBuilder,
input: string,
) => Promise<ExecutionResult>;

9 changes: 8 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ export type {
ExecutorMetadata,
} from "./testing/types.js";

// Internal testing utilities - NOT part of public API
// Only use these in internal unit tests, not in production code
export {
runWithMockExecutor,
createMockExecutorConfig,
} from "./testing/testHelpers.js";

// Executor utilities
export {
createVercelAIExecutor,
Expand Down Expand Up @@ -73,4 +80,4 @@ export type {
ReasoningPart,
JSONValue,
LanguageModelV3ToolResultOutput,
} from "./types.js";
} from "./types.js";
Loading