@aion0/forge 0.5.23 → 0.5.25

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/RELEASE_NOTES.md CHANGED
@@ -1,12 +1,11 @@
1
- # Forge v0.5.23
1
+ # Forge v0.5.25
2
2
 
3
- Released: 2026-04-03
3
+ Released: 2026-04-05
4
4
 
5
- ## Changes since v0.5.22
5
+ ## Changes since v0.5.24
6
6
 
7
7
  ### Bug Fixes
8
- - fix: agent deletion now removes from settings (was only removing from local state)
9
- - fix: fallback to default agent when configured agentId is deleted from Settings
8
+ - fix: replace @/src path alias with relative import in project-sessions.ts
10
9
 
11
10
 
12
- **Full Changelog**: https://github.com/aiwatching/forge/compare/v0.5.22...v0.5.23
11
+ **Full Changelog**: https://github.com/aiwatching/forge/compare/v0.5.24...v0.5.25
@@ -0,0 +1,81 @@
1
+ import { NextResponse } from 'next/server';
2
+ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, unlinkSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { getDataDir } from '@/lib/dirs';
5
+
6
+ function getTemplatesDir(): string {
7
+ const dir = join(getDataDir(), 'smith-templates');
8
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
9
+ return dir;
10
+ }
11
+
12
+ export interface SmithTemplate {
13
+ id: string;
14
+ name: string;
15
+ icon: string;
16
+ description?: string;
17
+ config: Record<string, any>; // agent config without id/dependsOn/boundSessionId
18
+ createdAt: number;
19
+ updatedAt: number;
20
+ }
21
+
22
+ // List all smith templates
23
+ export async function GET() {
24
+ const dir = getTemplatesDir();
25
+ const files = readdirSync(dir).filter(f => f.endsWith('.json'));
26
+ const templates: SmithTemplate[] = [];
27
+ for (const f of files) {
28
+ try {
29
+ const data = JSON.parse(readFileSync(join(dir, f), 'utf-8'));
30
+ templates.push(data);
31
+ } catch {}
32
+ }
33
+ templates.sort((a, b) => (b.updatedAt || 0) - (a.updatedAt || 0));
34
+ return NextResponse.json({ templates });
35
+ }
36
+
37
+ // Save or delete a smith template
38
+ export async function POST(req: Request) {
39
+ const body = await req.json();
40
+ const { action } = body;
41
+
42
+ if (action === 'delete') {
43
+ const { id } = body;
44
+ if (!id) return NextResponse.json({ error: 'id required' }, { status: 400 });
45
+ const fp = join(getTemplatesDir(), `${id}.json`);
46
+ if (existsSync(fp)) unlinkSync(fp);
47
+ return NextResponse.json({ ok: true });
48
+ }
49
+
50
+ // Save (create or update)
51
+ const { config, name, icon, description } = body;
52
+ if (!config || !name) {
53
+ return NextResponse.json({ error: 'config and name required' }, { status: 400 });
54
+ }
55
+
56
+ // Strip runtime/instance-specific fields
57
+ const cleanConfig = { ...config };
58
+ delete cleanConfig.id;
59
+ delete cleanConfig.dependsOn;
60
+ delete cleanConfig.boundSessionId;
61
+ delete cleanConfig.tmuxSession;
62
+ delete cleanConfig.content;
63
+ delete cleanConfig.entries;
64
+ delete cleanConfig.type;
65
+
66
+ const id = body.id || `smith-${Date.now()}-${Math.random().toString(36).slice(2, 5)}`;
67
+ const now = Date.now();
68
+
69
+ const template: SmithTemplate = {
70
+ id,
71
+ name: name.trim(),
72
+ icon: icon || cleanConfig.icon || '🤖',
73
+ description: description?.trim() || '',
74
+ config: cleanConfig,
75
+ createdAt: body.id ? (body.createdAt || now) : now,
76
+ updatedAt: now,
77
+ };
78
+
79
+ writeFileSync(join(getTemplatesDir(), `${id}.json`), JSON.stringify(template, null, 2));
80
+ return NextResponse.json({ ok: true, template });
81
+ }