@agentforge/cli 0.11.6 → 0.11.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/index.cjs +0 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/api/package.json +2 -2
- package/templates/cli/package.json +2 -2
- package/templates/full/package.json +2 -2
- package/templates/minimal/package.json +2 -2
- package/templates/reusable-agent/index.ts +20 -6
- package/templates/reusable-agent/prompt-loader.ts +0 -43
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"format": "prettier --write ."
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agentforge/core": "^0.11.
|
|
24
|
-
"@agentforge/patterns": "^0.11.
|
|
23
|
+
"@agentforge/core": "^0.11.8",
|
|
24
|
+
"@agentforge/patterns": "^0.11.8",
|
|
25
25
|
"@langchain/core": "^1.1.17",
|
|
26
26
|
"@langchain/langgraph": "^1.1.2",
|
|
27
27
|
"@langchain/openai": "^1.2.3",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"clean": "rm -rf dist"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@agentforge/core": "^0.11.
|
|
23
|
-
"@agentforge/patterns": "^0.11.
|
|
22
|
+
"@agentforge/core": "^0.11.8",
|
|
23
|
+
"@agentforge/patterns": "^0.11.8",
|
|
24
24
|
"@langchain/core": "^1.1.17",
|
|
25
25
|
"@langchain/langgraph": "^1.1.2",
|
|
26
26
|
"@langchain/openai": "^1.2.3",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"format": "prettier --write ."
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@agentforge/core": "^0.11.
|
|
20
|
-
"@agentforge/patterns": "^0.11.
|
|
19
|
+
"@agentforge/core": "^0.11.8",
|
|
20
|
+
"@agentforge/patterns": "^0.11.8",
|
|
21
21
|
"@langchain/core": "^1.1.17",
|
|
22
22
|
"@langchain/langgraph": "^1.1.2",
|
|
23
23
|
"@langchain/openai": "^1.2.3",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createReActAgent } from '@agentforge/patterns';
|
|
3
|
-
import { toolBuilder, ToolCategory, ToolRegistry } from '@agentforge/core';
|
|
3
|
+
import { toolBuilder, ToolCategory, ToolRegistry, loadPrompt } from '@agentforge/core';
|
|
4
4
|
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
|
5
5
|
import { ChatOpenAI } from '@langchain/openai';
|
|
6
|
-
import {
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { dirname, join } from 'path';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Configuration schema for {{AGENT_NAME_PASCAL}}Agent
|
|
@@ -91,12 +92,25 @@ function buildSystemPrompt(config: {{AGENT_NAME_PASCAL}}Config): string {
|
|
|
91
92
|
return config.systemPrompt;
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
// Resolve prompts directory relative to this module (not cwd)
|
|
96
|
+
// This ensures prompts are found when the package is published
|
|
97
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
98
|
+
const __dirname = dirname(__filename);
|
|
99
|
+
const promptsDir = join(__dirname, '../prompts');
|
|
100
|
+
|
|
94
101
|
// Load prompt from external file with variable substitution
|
|
102
|
+
// SECURITY: Distinguish between trusted (config) and untrusted (user-supplied) variables
|
|
95
103
|
return loadPrompt('system', {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
// Trusted variables: from config/hardcoded values (NOT sanitized)
|
|
105
|
+
trustedVariables: {
|
|
106
|
+
enableExampleFeature: config.enableExampleFeature,
|
|
107
|
+
},
|
|
108
|
+
// Untrusted variables: potentially user-supplied (WILL be sanitized)
|
|
109
|
+
untrustedVariables: {
|
|
110
|
+
organizationName: config.organizationName || 'your organization',
|
|
111
|
+
description: config.description || '{{AGENT_DESCRIPTION}}',
|
|
112
|
+
},
|
|
113
|
+
}, promptsDir);
|
|
100
114
|
}
|
|
101
115
|
|
|
102
116
|
/**
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'fs';
|
|
2
|
-
import { join, dirname } from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = dirname(__filename);
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Simple template variable substitution
|
|
10
|
-
* Supports: {{variable}} and {{#if variable}}...{{/if}}
|
|
11
|
-
*/
|
|
12
|
-
export function renderTemplate(template: string, variables: Record<string, any>): string {
|
|
13
|
-
let result = template;
|
|
14
|
-
|
|
15
|
-
// Replace simple variables: {{variableName}}
|
|
16
|
-
result = result.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
|
|
17
|
-
return variables[varName] !== undefined ? String(variables[varName]) : match;
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Handle conditional blocks: {{#if variableName}}...{{/if}}
|
|
21
|
-
result = result.replace(/\{\{#if (\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g, (match, varName, content) => {
|
|
22
|
-
return variables[varName] ? content : '';
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Load a prompt template from the prompts directory
|
|
30
|
-
*/
|
|
31
|
-
export function loadPromptTemplate(name: string): string {
|
|
32
|
-
const promptPath = join(__dirname, '..', 'prompts', `${name}.md`);
|
|
33
|
-
return readFileSync(promptPath, 'utf-8');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Load and render a prompt with variables
|
|
38
|
-
*/
|
|
39
|
-
export function loadPrompt(name: string, variables: Record<string, any> = {}): string {
|
|
40
|
-
const template = loadPromptTemplate(name);
|
|
41
|
-
return renderTemplate(template, variables);
|
|
42
|
-
}
|
|
43
|
-
|