@trikhub/cli 0.6.0 → 0.13.0
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 +102 -200
- package/dist/commands/info.d.ts.map +1 -1
- package/dist/commands/info.js +35 -0
- package/dist/commands/info.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +104 -27
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +13 -84
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +20 -1
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +18 -1
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +2 -8
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +5 -122
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/lib/registry.d.ts.map +1 -1
- package/dist/lib/registry.js +4 -14
- package/dist/lib/registry.js.map +1 -1
- package/dist/templates/python.d.ts +1 -24
- package/dist/templates/python.d.ts.map +1 -1
- package/dist/templates/python.js +2 -262
- package/dist/templates/python.js.map +1 -1
- package/dist/templates/typescript.d.ts +13 -11
- package/dist/templates/typescript.d.ts.map +1 -1
- package/dist/templates/typescript.js +219 -173
- package/dist/templates/typescript.js.map +1 -1
- package/package.json +7 -9
- package/dist/lib/validator.d.ts +0 -33
- package/dist/lib/validator.d.ts.map +0 -1
- package/dist/lib/validator.js +0 -133
- package/dist/lib/validator.js.map +0 -1
package/dist/templates/python.js
CHANGED
|
@@ -1,263 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Generates all files needed for a Python trik project.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Convert trik name to Python package name (dashes to underscores)
|
|
8
|
-
*/
|
|
9
|
-
function toPackageName(name) {
|
|
10
|
-
return name.replace(/-/g, '_');
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Generate all files for a Python trik project
|
|
14
|
-
*/
|
|
15
|
-
export function generatePythonProject(config) {
|
|
16
|
-
const files = [];
|
|
17
|
-
const pkgName = toPackageName(config.name);
|
|
18
|
-
files.push({ path: 'trikhub.json', content: generateTrikhubJson(config) });
|
|
19
|
-
files.push({ path: 'pyproject.toml', content: generatePyproject(config, pkgName) });
|
|
20
|
-
files.push({ path: 'test.py', content: generateTestPy(pkgName) });
|
|
21
|
-
files.push({ path: 'README.md', content: generateReadme(config) });
|
|
22
|
-
files.push({ path: '.gitignore', content: generateGitignore() });
|
|
23
|
-
files.push({ path: `${pkgName}/__init__.py`, content: generateInitPy() });
|
|
24
|
-
files.push({ path: `${pkgName}/manifest.json`, content: generateManifest(config) });
|
|
25
|
-
files.push({ path: `${pkgName}/graph.py`, content: generateGraphPy(config) });
|
|
26
|
-
return files;
|
|
27
|
-
}
|
|
28
|
-
function generateManifest(config) {
|
|
29
|
-
const manifest = {
|
|
30
|
-
schemaVersion: 1,
|
|
31
|
-
id: config.name,
|
|
32
|
-
name: config.displayName,
|
|
33
|
-
description: config.description,
|
|
34
|
-
version: '0.1.0',
|
|
35
|
-
actions: {
|
|
36
|
-
hello: {
|
|
37
|
-
description: 'Say hello to someone',
|
|
38
|
-
inputSchema: {
|
|
39
|
-
type: 'object',
|
|
40
|
-
properties: {
|
|
41
|
-
name: { type: 'string', description: 'Name to greet' },
|
|
42
|
-
},
|
|
43
|
-
required: ['name'],
|
|
44
|
-
},
|
|
45
|
-
responseMode: 'template',
|
|
46
|
-
agentDataSchema: {
|
|
47
|
-
type: 'object',
|
|
48
|
-
properties: {
|
|
49
|
-
template: { type: 'string', enum: ['success'] },
|
|
50
|
-
greeting: { type: 'string', maxLength: 200, pattern: '^.{1,200}$' },
|
|
51
|
-
},
|
|
52
|
-
required: ['template', 'greeting'],
|
|
53
|
-
},
|
|
54
|
-
responseTemplates: {
|
|
55
|
-
success: { text: '{{greeting}}' },
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
capabilities: {
|
|
60
|
-
tools: [],
|
|
61
|
-
},
|
|
62
|
-
limits: {
|
|
63
|
-
maxExecutionTimeMs: 5000,
|
|
64
|
-
},
|
|
65
|
-
entry: {
|
|
66
|
-
module: './graph.py',
|
|
67
|
-
export: 'graph',
|
|
68
|
-
runtime: 'python',
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
// Add storage capability if enabled
|
|
72
|
-
if (config.enableStorage) {
|
|
73
|
-
manifest.capabilities.storage = {
|
|
74
|
-
enabled: true,
|
|
75
|
-
maxSizeBytes: 1048576,
|
|
76
|
-
persistent: true,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
// Add config if enabled
|
|
80
|
-
if (config.enableConfig) {
|
|
81
|
-
manifest.config = {
|
|
82
|
-
required: [
|
|
83
|
-
{ key: 'API_KEY', description: 'Your API key' },
|
|
84
|
-
],
|
|
85
|
-
optional: [],
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return JSON.stringify(manifest, null, 2) + '\n';
|
|
89
|
-
}
|
|
90
|
-
function generateTrikhubJson(config) {
|
|
91
|
-
const trikhub = {
|
|
92
|
-
displayName: config.displayName,
|
|
93
|
-
shortDescription: config.description,
|
|
94
|
-
categories: [config.category],
|
|
95
|
-
keywords: [config.name],
|
|
96
|
-
author: {
|
|
97
|
-
name: config.authorName,
|
|
98
|
-
github: config.authorGithub,
|
|
99
|
-
},
|
|
100
|
-
repository: `https://github.com/${config.authorGithub}/${config.name}`,
|
|
101
|
-
};
|
|
102
|
-
return JSON.stringify(trikhub, null, 2) + '\n';
|
|
103
|
-
}
|
|
104
|
-
function generatePyproject(config, pkgName) {
|
|
105
|
-
return `[build-system]
|
|
106
|
-
requires = ["hatchling"]
|
|
107
|
-
build-backend = "hatchling.build"
|
|
108
|
-
|
|
109
|
-
[project]
|
|
110
|
-
name = "${config.name}"
|
|
111
|
-
version = "0.1.0"
|
|
112
|
-
description = "${config.description}"
|
|
113
|
-
readme = "README.md"
|
|
114
|
-
requires-python = ">=3.10"
|
|
115
|
-
license = {text = "MIT"}
|
|
116
|
-
authors = [
|
|
117
|
-
{ name = "${config.authorName}" }
|
|
118
|
-
]
|
|
119
|
-
dependencies = []
|
|
120
|
-
|
|
121
|
-
[project.urls]
|
|
122
|
-
Repository = "https://github.com/${config.authorGithub}/${config.name}"
|
|
123
|
-
|
|
124
|
-
[tool.hatch.build.targets.wheel]
|
|
125
|
-
packages = ["${pkgName}"]
|
|
126
|
-
|
|
127
|
-
[tool.hatch.build.targets.sdist]
|
|
128
|
-
include = [
|
|
129
|
-
"${pkgName}/**",
|
|
130
|
-
"README.md",
|
|
131
|
-
]
|
|
132
|
-
`;
|
|
133
|
-
}
|
|
134
|
-
function generateGraphPy(config) {
|
|
135
|
-
const storageType = config.enableStorage ? ', storage: dict | None = None' : '';
|
|
136
|
-
const configType = config.enableConfig ? ', config: dict | None = None' : '';
|
|
137
|
-
return `"""
|
|
138
|
-
${config.displayName}
|
|
139
|
-
|
|
140
|
-
${config.description}
|
|
141
|
-
"""
|
|
142
|
-
|
|
143
|
-
from __future__ import annotations
|
|
144
|
-
|
|
145
|
-
from typing import Any
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
class ${toPascalCase(config.name)}Graph:
|
|
149
|
-
"""Main graph for the ${config.displayName} trik."""
|
|
150
|
-
|
|
151
|
-
async def invoke(self, input_data: dict[str, Any]) -> dict[str, Any]:
|
|
152
|
-
"""
|
|
153
|
-
Main entry point called by the TrikHub gateway.
|
|
154
|
-
|
|
155
|
-
Args:
|
|
156
|
-
input_data: Contains action, input${config.enableStorage ? ', storage' : ''}${config.enableConfig ? ', config' : ''}
|
|
157
|
-
|
|
158
|
-
Returns:
|
|
159
|
-
Response with responseMode and agentData/userContent
|
|
160
|
-
"""
|
|
161
|
-
action = input_data.get("action")
|
|
162
|
-
action_input = input_data.get("input", {})${config.enableStorage ? '\n storage = input_data.get("storage")' : ''}${config.enableConfig ? '\n config = input_data.get("config")' : ''}
|
|
163
|
-
|
|
164
|
-
if action == "hello":
|
|
165
|
-
name = action_input.get("name", "World")
|
|
166
|
-
return {
|
|
167
|
-
"responseMode": "template",
|
|
168
|
-
"agentData": {
|
|
169
|
-
"template": "success",
|
|
170
|
-
"greeting": f"Hello, {name}!",
|
|
171
|
-
},
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return {
|
|
175
|
-
"responseMode": "template",
|
|
176
|
-
"agentData": {
|
|
177
|
-
"template": "error",
|
|
178
|
-
"message": f"Unknown action: {action}",
|
|
179
|
-
},
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
# Export the graph instance
|
|
184
|
-
graph = ${toPascalCase(config.name)}Graph()
|
|
185
|
-
`;
|
|
186
|
-
}
|
|
187
|
-
function generateInitPy() {
|
|
188
|
-
return `"""${''} Package init """
|
|
189
|
-
`;
|
|
190
|
-
}
|
|
191
|
-
function generateTestPy(pkgName) {
|
|
192
|
-
return `"""
|
|
193
|
-
Local test script
|
|
194
|
-
|
|
195
|
-
Run with: python test.py
|
|
196
|
-
"""
|
|
197
|
-
|
|
198
|
-
import asyncio
|
|
199
|
-
from ${pkgName}.graph import graph
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
async def main():
|
|
203
|
-
result = await graph.invoke({
|
|
204
|
-
"action": "hello",
|
|
205
|
-
"input": {"name": "World"},
|
|
206
|
-
})
|
|
207
|
-
print(result)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if __name__ == "__main__":
|
|
211
|
-
asyncio.run(main())
|
|
212
|
-
`;
|
|
213
|
-
}
|
|
214
|
-
function generateReadme(config) {
|
|
215
|
-
return `# ${config.displayName}
|
|
216
|
-
|
|
217
|
-
${config.description}
|
|
218
|
-
|
|
219
|
-
## Development
|
|
220
|
-
|
|
221
|
-
\`\`\`bash
|
|
222
|
-
python test.py
|
|
223
|
-
\`\`\`
|
|
224
|
-
|
|
225
|
-
## Actions
|
|
226
|
-
|
|
227
|
-
### hello
|
|
228
|
-
|
|
229
|
-
Say hello to someone.
|
|
230
|
-
|
|
231
|
-
**Input:**
|
|
232
|
-
- \`name\` (string, required): Name to greet
|
|
233
|
-
|
|
234
|
-
## Publishing
|
|
235
|
-
|
|
236
|
-
\`\`\`bash
|
|
237
|
-
trik publish
|
|
238
|
-
\`\`\`
|
|
239
|
-
`;
|
|
240
|
-
}
|
|
241
|
-
function generateGitignore() {
|
|
242
|
-
return `__pycache__/
|
|
243
|
-
*.py[cod]
|
|
244
|
-
*$py.class
|
|
245
|
-
*.so
|
|
246
|
-
.Python
|
|
247
|
-
build/
|
|
248
|
-
dist/
|
|
249
|
-
*.egg-info/
|
|
250
|
-
.eggs/
|
|
251
|
-
*.egg
|
|
252
|
-
.venv/
|
|
253
|
-
venv/
|
|
254
|
-
.DS_Store
|
|
255
|
-
`;
|
|
256
|
-
}
|
|
257
|
-
function toPascalCase(str) {
|
|
258
|
-
return str
|
|
259
|
-
.split('-')
|
|
260
|
-
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
261
|
-
.join('');
|
|
262
|
-
}
|
|
1
|
+
export {};
|
|
2
|
+
// Stub — Python scaffold template not yet implemented
|
|
263
3
|
//# sourceMappingURL=python.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../src/templates/python.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../src/templates/python.ts"],"names":[],"mappings":";AAAA,sDAAsD"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TypeScript
|
|
2
|
+
* v2 TypeScript scaffold template.
|
|
3
3
|
*
|
|
4
|
-
* Generates
|
|
4
|
+
* Generates a complete v2 trik project structure using the
|
|
5
|
+
* agent-based handoff architecture with wrapAgent() from @trikhub/sdk.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
export interface TsTemplateConfig {
|
|
7
|
+
export interface InitConfig {
|
|
8
8
|
name: string;
|
|
9
9
|
displayName: string;
|
|
10
10
|
description: string;
|
|
11
11
|
authorName: string;
|
|
12
12
|
authorGithub: string;
|
|
13
|
-
category:
|
|
13
|
+
category: string;
|
|
14
14
|
enableStorage: boolean;
|
|
15
15
|
enableConfig: boolean;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
agentMode: 'conversational' | 'tool';
|
|
17
|
+
handoffDescription: string;
|
|
18
|
+
domainTags: string[];
|
|
19
|
+
toolNames: string[];
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Generate
|
|
22
|
+
* Generate a complete v2 TypeScript trik project.
|
|
23
|
+
*
|
|
24
|
+
* @returns Map of { relativePath: fileContent } for all project files.
|
|
23
25
|
*/
|
|
24
|
-
export declare function generateTypescriptProject(config:
|
|
26
|
+
export declare function generateTypescriptProject(config: InitConfig): Record<string, string>;
|
|
25
27
|
//# sourceMappingURL=typescript.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/templates/typescript.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/templates/typescript.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IAEtB,SAAS,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACrC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAiUD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAsBpF"}
|