@restforgejs/mcp-server 1.2.2 → 1.2.4
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/dist/server.js +71 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/codegen/create-kafka-consumer.d.ts +2 -0
- package/dist/tools/codegen/create-kafka-consumer.js +140 -0
- package/dist/tools/codegen/create-kafka-consumer.js.map +1 -0
- package/dist/tools/codegen/create-processor.d.ts +2 -0
- package/dist/tools/codegen/create-processor.js +157 -0
- package/dist/tools/codegen/create-processor.js.map +1 -0
- package/dist/tools/codegen/generate-test.d.ts +2 -0
- package/dist/tools/codegen/generate-test.js +149 -0
- package/dist/tools/codegen/generate-test.js.map +1 -0
- package/dist/tools/codegen/index.js +8 -0
- package/dist/tools/codegen/index.js.map +1 -1
- package/dist/tools/codegen/migrate-payload.d.ts +2 -0
- package/dist/tools/codegen/migrate-payload.js +210 -0
- package/dist/tools/codegen/migrate-payload.js.map +1 -0
- package/dist/tools/data/index.d.ts +2 -0
- package/dist/tools/data/index.js +7 -0
- package/dist/tools/data/index.js.map +1 -0
- package/dist/tools/data/pull.d.ts +2 -0
- package/dist/tools/data/pull.js +202 -0
- package/dist/tools/data/pull.js.map +1 -0
- package/dist/tools/data/push.d.ts +2 -0
- package/dist/tools/data/push.js +190 -0
- package/dist/tools/data/push.js.map +1 -0
- package/dist/tools/designer/generate.js +86 -81
- package/dist/tools/designer/generate.js.map +1 -1
- package/dist/tools/designer/get-udf-catalog.d.ts +2 -0
- package/dist/tools/designer/get-udf-catalog.js +225 -0
- package/dist/tools/designer/get-udf-catalog.js.map +1 -0
- package/dist/tools/designer/index.js +2 -0
- package/dist/tools/designer/index.js.map +1 -1
- package/dist/tools/designer/init-project.js +73 -73
- package/dist/tools/designer/inspect-plugin.js +70 -65
- package/dist/tools/designer/inspect-plugin.js.map +1 -1
- package/dist/tools/designer/list-plugins.js +62 -62
- package/dist/tools/designer/preview-files.js +72 -67
- package/dist/tools/designer/preview-files.js.map +1 -1
- package/dist/tools/designer/scaffold-plugin.js +72 -72
- package/dist/tools/designer/validate-payload.js +74 -69
- package/dist/tools/designer/validate-payload.js.map +1 -1
- package/dist/tools/key/generate.d.ts +2 -0
- package/dist/tools/key/generate.js +130 -0
- package/dist/tools/key/generate.js.map +1 -0
- package/dist/tools/key/index.d.ts +2 -0
- package/dist/tools/key/index.js +9 -0
- package/dist/tools/key/index.js.map +1 -0
- package/dist/tools/key/list.d.ts +2 -0
- package/dist/tools/key/list.js +126 -0
- package/dist/tools/key/list.js.map +1 -0
- package/dist/tools/key/revoke.d.ts +2 -0
- package/dist/tools/key/revoke.js +117 -0
- package/dist/tools/key/revoke.js.map +1 -0
- package/dist/tools/project/delete.d.ts +2 -0
- package/dist/tools/project/delete.js +116 -0
- package/dist/tools/project/delete.js.map +1 -0
- package/dist/tools/project/index.d.ts +2 -0
- package/dist/tools/project/index.js +7 -0
- package/dist/tools/project/index.js.map +1 -0
- package/dist/tools/project/list.d.ts +2 -0
- package/dist/tools/project/list.js +107 -0
- package/dist/tools/project/list.js.map +1 -0
- package/dist/tools/runtime/generate-launcher.js +3 -3
- package/dist/tools/setup/clear-default-config.d.ts +2 -0
- package/dist/tools/setup/clear-default-config.js +104 -0
- package/dist/tools/setup/clear-default-config.js.map +1 -0
- package/dist/tools/setup/get-default-config.d.ts +2 -0
- package/dist/tools/setup/get-default-config.js +104 -0
- package/dist/tools/setup/get-default-config.js.map +1 -0
- package/dist/tools/setup/index.js +8 -0
- package/dist/tools/setup/index.js.map +1 -1
- package/dist/tools/setup/init-config.js +3 -5
- package/dist/tools/setup/init-config.js.map +1 -1
- package/dist/tools/setup/list-configs.d.ts +2 -0
- package/dist/tools/setup/list-configs.js +104 -0
- package/dist/tools/setup/list-configs.js.map +1 -0
- package/dist/tools/setup/set-default-config.d.ts +2 -0
- package/dist/tools/setup/set-default-config.js +109 -0
- package/dist/tools/setup/set-default-config.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { access } from 'node:fs/promises';
|
|
3
|
+
import { resolve, join } from 'node:path';
|
|
4
|
+
import { execProcess } from '../../lib/exec.js';
|
|
5
|
+
export function registerProjectList(server) {
|
|
6
|
+
server.registerTool('project_list', {
|
|
7
|
+
title: 'List Projects',
|
|
8
|
+
description: `List the projects registered in the RESTForge registry (with endpoint count, database type, and creation date), by wrapping restforge project list.
|
|
9
|
+
|
|
10
|
+
USE WHEN:
|
|
11
|
+
- The user wants to see which projects exist, e.g. "lihat daftar project", "list project", "project apa saja yang ada"
|
|
12
|
+
- Before deleting a project, to confirm the exact project name
|
|
13
|
+
|
|
14
|
+
DO NOT USE FOR:
|
|
15
|
+
- Deleting a project -> use 'project_delete'
|
|
16
|
+
- Listing database tables -> use 'codegen_list_tables'
|
|
17
|
+
|
|
18
|
+
This tool runs: npx restforge project list in the given cwd (the verb takes no other flags).
|
|
19
|
+
|
|
20
|
+
Preconditions:
|
|
21
|
+
- The project must have @restforgejs/platform installed in node_modules.
|
|
22
|
+
|
|
23
|
+
PRESENTATION GUIDANCE:
|
|
24
|
+
- Match the user's language. Never mention internal tool names; describe the action (e.g. "list the projects").
|
|
25
|
+
- Summarise the projects (names, endpoint counts, database types). Do not paste raw output unless the user explicitly asks.
|
|
26
|
+
- When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
|
|
27
|
+
inputSchema: {
|
|
28
|
+
cwd: z
|
|
29
|
+
.string()
|
|
30
|
+
.min(1)
|
|
31
|
+
.describe('Absolute path of the project folder (must contain node_modules/@restforgejs/platform)'),
|
|
32
|
+
},
|
|
33
|
+
annotations: {
|
|
34
|
+
title: 'List Projects',
|
|
35
|
+
readOnlyHint: true,
|
|
36
|
+
idempotentHint: true,
|
|
37
|
+
},
|
|
38
|
+
}, async ({ cwd }) => {
|
|
39
|
+
const projectCwd = resolve(cwd);
|
|
40
|
+
try {
|
|
41
|
+
await access(join(projectCwd, 'node_modules', '@restforgejs', 'platform'));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: 'text',
|
|
48
|
+
text: `Precondition not met: the RESTForge package is not installed in this project.
|
|
49
|
+
|
|
50
|
+
Project path: ${projectCwd}
|
|
51
|
+
Expected location: node_modules/@restforgejs/platform
|
|
52
|
+
|
|
53
|
+
For the assistant:
|
|
54
|
+
- The user needs to install the RESTForge package before projects can be listed. Suggest installing it first, then retry. Do not mention internal tool names.`,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
isError: false,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const result = await execProcess('npx', ['restforge', 'project', 'list'], { cwd: projectCwd, timeout: 30_000 });
|
|
61
|
+
if (!result.success) {
|
|
62
|
+
return {
|
|
63
|
+
content: [
|
|
64
|
+
{
|
|
65
|
+
type: 'text',
|
|
66
|
+
text: `Failed to list projects.
|
|
67
|
+
|
|
68
|
+
Project path: ${projectCwd}
|
|
69
|
+
Command: ${result.command}
|
|
70
|
+
Exit code: ${result.exitCode}
|
|
71
|
+
|
|
72
|
+
--- CLI output ---
|
|
73
|
+
stdout:
|
|
74
|
+
${result.stdout}
|
|
75
|
+
|
|
76
|
+
stderr:
|
|
77
|
+
${result.stderr}
|
|
78
|
+
--- end CLI output ---
|
|
79
|
+
|
|
80
|
+
For the assistant:
|
|
81
|
+
- Tell the user the project list could not be retrieved; summarise the likely cause from the output. Do not paste raw output unless asked. Do not mention internal tool names.`,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
isError: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
content: [
|
|
89
|
+
{
|
|
90
|
+
type: 'text',
|
|
91
|
+
text: `Projects listed.
|
|
92
|
+
|
|
93
|
+
Project path: ${projectCwd}
|
|
94
|
+
Command: ${result.command}
|
|
95
|
+
|
|
96
|
+
--- CLI output ---
|
|
97
|
+
${result.stdout}
|
|
98
|
+
--- end CLI output ---
|
|
99
|
+
|
|
100
|
+
For the assistant:
|
|
101
|
+
- Read the output and summarise the registered projects (names, endpoint counts, database types, creation dates). Keep it concise. Do not mention internal tool names.`,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/tools/project/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;QACE,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE;;;;;;;;;;;;;;;;;;uGAkBoF;QACjG,WAAW,EAAE;YACX,GAAG,EAAE,CAAC;iBACH,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CAAC,uFAAuF,CAAC;SACrG;QACD,WAAW,EAAE;YACX,KAAK,EAAE,eAAe;YACtB,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,IAAI;SACrB;KACF,EACD,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QAChB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;QAC7E,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;gBAEJ,UAAU;;;;8JAIoI;qBACjJ;iBACF;gBACD,OAAO,EAAE,KAAK;aACf,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAEhH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;gBAEJ,UAAU;WACf,MAAM,CAAC,OAAO;aACZ,MAAM,CAAC,QAAQ;;;;EAI1B,MAAM,CAAC,MAAM;;;EAGb,MAAM,CAAC,MAAM;;;;+KAIgK;qBAClK;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;WACf,MAAM,CAAC,OAAO;;;EAGvB,MAAM,CAAC,MAAM;;;;uKAIwJ;iBAC5J;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -27,7 +27,7 @@ echo.
|
|
|
27
27
|
echo To stop: press Ctrl+C in this window, or run server-stop.bat in another terminal.
|
|
28
28
|
echo.
|
|
29
29
|
|
|
30
|
-
npx restforge --project={{PROJECT}} --port={{PORT}} --config={{CONFIG}}{{EXTRA_ARGS_SH}}
|
|
30
|
+
npx restforge serve --project={{PROJECT}} --port={{PORT}} --config={{CONFIG}}{{EXTRA_ARGS_SH}}
|
|
31
31
|
`;
|
|
32
32
|
const TEMPLATE_WINDOWS_HOST_STOP = `@echo off
|
|
33
33
|
REM RESTForge Server Stopper
|
|
@@ -65,7 +65,7 @@ echo ""
|
|
|
65
65
|
echo "To stop: press Ctrl+C, or run ./server-stop.sh in another terminal."
|
|
66
66
|
echo ""
|
|
67
67
|
|
|
68
|
-
exec npx restforge --project={{PROJECT}} --port={{PORT}} --config={{CONFIG}}{{EXTRA_ARGS_SH}}
|
|
68
|
+
exec npx restforge serve --project={{PROJECT}} --port={{PORT}} --config={{CONFIG}}{{EXTRA_ARGS_SH}}
|
|
69
69
|
`;
|
|
70
70
|
const TEMPLATE_LINUX_HOST_STOP = `#!/bin/bash
|
|
71
71
|
# RESTForge Server Stopper
|
|
@@ -111,7 +111,7 @@ module.exports = {
|
|
|
111
111
|
{
|
|
112
112
|
name: '{{PROJECT}}',
|
|
113
113
|
script: './node_modules/@restforgejs/platform/server.js',
|
|
114
|
-
args: '--project={{PROJECT}} --port={{PORT}} --config={{CONFIG}}{{EXTRA_ARGS_SH}}',
|
|
114
|
+
args: 'serve --project={{PROJECT}} --port={{PORT}} --config={{CONFIG}}{{EXTRA_ARGS_SH}}',
|
|
115
115
|
cwd: __dirname,
|
|
116
116
|
|
|
117
117
|
// Process
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { access } from 'node:fs/promises';
|
|
3
|
+
import { resolve, join } from 'node:path';
|
|
4
|
+
import { execProcess } from '../../lib/exec.js';
|
|
5
|
+
export function registerSetupClearDefaultConfig(server) {
|
|
6
|
+
server.registerTool('setup_clear_default_config', {
|
|
7
|
+
title: 'Clear Default Config',
|
|
8
|
+
description: `Remove the default config for the current working directory, by wrapping restforge config clear-default. After clearing, commands no longer fall back to a default and require --config explicitly.
|
|
9
|
+
|
|
10
|
+
USE WHEN:
|
|
11
|
+
- The user wants to unset/clear the default config, e.g. "hapus default config", "clear default config", "reset default config"
|
|
12
|
+
|
|
13
|
+
DO NOT USE FOR:
|
|
14
|
+
- Setting the default -> use 'setup_set_default_config'
|
|
15
|
+
- Showing the default -> use 'setup_get_default_config'
|
|
16
|
+
|
|
17
|
+
This tool runs: npx restforge config clear-default in the given cwd (no other flags).
|
|
18
|
+
|
|
19
|
+
Preconditions:
|
|
20
|
+
- The project must have @restforgejs/platform installed in node_modules.
|
|
21
|
+
|
|
22
|
+
PRESENTATION GUIDANCE:
|
|
23
|
+
- Match the user's language. Never mention internal tool names; describe the action.
|
|
24
|
+
- Confirm the default was cleared. Note this is reversible by setting a default again. Keep it concise.
|
|
25
|
+
- When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
|
|
26
|
+
inputSchema: {
|
|
27
|
+
cwd: z.string().min(1).describe('Absolute path of the project folder (must have @restforgejs/platform installed)'),
|
|
28
|
+
},
|
|
29
|
+
annotations: {
|
|
30
|
+
title: 'Clear Default Config',
|
|
31
|
+
readOnlyHint: false,
|
|
32
|
+
idempotentHint: true,
|
|
33
|
+
destructiveHint: false,
|
|
34
|
+
},
|
|
35
|
+
}, async ({ cwd }) => {
|
|
36
|
+
const projectCwd = resolve(cwd);
|
|
37
|
+
try {
|
|
38
|
+
await access(join(projectCwd, 'node_modules', '@restforgejs', 'platform'));
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: 'text',
|
|
45
|
+
text: `Precondition not met: the RESTForge package is not installed in this project.
|
|
46
|
+
|
|
47
|
+
Project path: ${projectCwd}
|
|
48
|
+
Expected location: node_modules/@restforgejs/platform
|
|
49
|
+
|
|
50
|
+
For the assistant:
|
|
51
|
+
- The user needs to install the RESTForge package first, then retry. Do not mention internal tool names.`,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
isError: false,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const result = await execProcess('npx', ['restforge', 'config', 'clear-default'], { cwd: projectCwd, timeout: 30_000 });
|
|
58
|
+
if (!result.success) {
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'text',
|
|
63
|
+
text: `Failed to clear the default config.
|
|
64
|
+
|
|
65
|
+
Project path: ${projectCwd}
|
|
66
|
+
Command: ${result.command}
|
|
67
|
+
Exit code: ${result.exitCode}
|
|
68
|
+
|
|
69
|
+
--- CLI output ---
|
|
70
|
+
stdout:
|
|
71
|
+
${result.stdout}
|
|
72
|
+
|
|
73
|
+
stderr:
|
|
74
|
+
${result.stderr}
|
|
75
|
+
--- end CLI output ---
|
|
76
|
+
|
|
77
|
+
For the assistant:
|
|
78
|
+
- Tell the user the default config could not be cleared; summarise the likely cause (e.g. no default was set). Do not paste raw output unless asked. Do not mention internal tool names.`,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
isError: true,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
content: [
|
|
86
|
+
{
|
|
87
|
+
type: 'text',
|
|
88
|
+
text: `Default config cleared.
|
|
89
|
+
|
|
90
|
+
Project path: ${projectCwd}
|
|
91
|
+
Command: ${result.command}
|
|
92
|
+
|
|
93
|
+
--- CLI output ---
|
|
94
|
+
${result.stdout}
|
|
95
|
+
--- end CLI output ---
|
|
96
|
+
|
|
97
|
+
For the assistant:
|
|
98
|
+
- Confirm the working-directory default config was removed; commands will now require an explicit config. This is reversible by setting a default again. Keep it concise. Do not mention internal tool names.`,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=clear-default-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear-default-config.js","sourceRoot":"","sources":["../../../src/tools/setup/clear-default-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAA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;;;;yLAI0K;qBAC5K;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;WACf,MAAM,CAAC,OAAO;;;EAGvB,MAAM,CAAC,MAAM;;;;8MAI+L;iBACnM;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { access } from 'node:fs/promises';
|
|
3
|
+
import { resolve, join } from 'node:path';
|
|
4
|
+
import { execProcess } from '../../lib/exec.js';
|
|
5
|
+
export function registerSetupGetDefaultConfig(server) {
|
|
6
|
+
server.registerTool('setup_get_default_config', {
|
|
7
|
+
title: 'Get Default Config',
|
|
8
|
+
description: `Show the active default config file for the current working directory, by wrapping restforge config get-default.
|
|
9
|
+
|
|
10
|
+
USE WHEN:
|
|
11
|
+
- The user asks which config is the default, e.g. "config default-nya apa", "show default config", "lihat default config aktif"
|
|
12
|
+
|
|
13
|
+
DO NOT USE FOR:
|
|
14
|
+
- Setting the default -> use 'setup_set_default_config'
|
|
15
|
+
- Clearing the default -> use 'setup_clear_default_config'
|
|
16
|
+
- Listing all .env files -> use 'setup_list_configs'
|
|
17
|
+
|
|
18
|
+
This tool runs: npx restforge config get-default in the given cwd (outputs JSON).
|
|
19
|
+
|
|
20
|
+
Preconditions:
|
|
21
|
+
- The project must have @restforgejs/platform installed in node_modules.
|
|
22
|
+
|
|
23
|
+
PRESENTATION GUIDANCE:
|
|
24
|
+
- Match the user's language. Never mention internal tool names; describe the action.
|
|
25
|
+
- Tell the user which file is the default (or that none is set). Keep it concise.
|
|
26
|
+
- When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
|
|
27
|
+
inputSchema: {
|
|
28
|
+
cwd: z.string().min(1).describe('Absolute path of the project folder (must have @restforgejs/platform installed)'),
|
|
29
|
+
},
|
|
30
|
+
annotations: {
|
|
31
|
+
title: 'Get Default Config',
|
|
32
|
+
readOnlyHint: true,
|
|
33
|
+
idempotentHint: true,
|
|
34
|
+
},
|
|
35
|
+
}, async ({ cwd }) => {
|
|
36
|
+
const projectCwd = resolve(cwd);
|
|
37
|
+
try {
|
|
38
|
+
await access(join(projectCwd, 'node_modules', '@restforgejs', 'platform'));
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: 'text',
|
|
45
|
+
text: `Precondition not met: the RESTForge package is not installed in this project.
|
|
46
|
+
|
|
47
|
+
Project path: ${projectCwd}
|
|
48
|
+
Expected location: node_modules/@restforgejs/platform
|
|
49
|
+
|
|
50
|
+
For the assistant:
|
|
51
|
+
- The user needs to install the RESTForge package first, then retry. Do not mention internal tool names.`,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
isError: false,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const result = await execProcess('npx', ['restforge', 'config', 'get-default'], { cwd: projectCwd, timeout: 30_000 });
|
|
58
|
+
if (!result.success) {
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'text',
|
|
63
|
+
text: `Failed to get the default config.
|
|
64
|
+
|
|
65
|
+
Project path: ${projectCwd}
|
|
66
|
+
Command: ${result.command}
|
|
67
|
+
Exit code: ${result.exitCode}
|
|
68
|
+
|
|
69
|
+
--- CLI output ---
|
|
70
|
+
stdout:
|
|
71
|
+
${result.stdout}
|
|
72
|
+
|
|
73
|
+
stderr:
|
|
74
|
+
${result.stderr}
|
|
75
|
+
--- end CLI output ---
|
|
76
|
+
|
|
77
|
+
For the assistant:
|
|
78
|
+
- Tell the user the default config could not be read; summarise the likely cause. Do not paste raw output unless asked. Do not mention internal tool names.`,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
isError: true,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
content: [
|
|
86
|
+
{
|
|
87
|
+
type: 'text',
|
|
88
|
+
text: `Default config retrieved.
|
|
89
|
+
|
|
90
|
+
Project path: ${projectCwd}
|
|
91
|
+
Command: ${result.command}
|
|
92
|
+
|
|
93
|
+
--- CLI output ---
|
|
94
|
+
${result.stdout}
|
|
95
|
+
--- end CLI output ---
|
|
96
|
+
|
|
97
|
+
For the assistant:
|
|
98
|
+
- Read the JSON and tell the user which file is the active default for this directory, or that none is set. Keep it concise. Do not mention internal tool names.`,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=get-default-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-default-config.js","sourceRoot":"","sources":["../../../src/tools/setup/get-default-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,6BAA6B,CAAC,MAAiB;IAC7D,MAAM,CAAC,YAAY,CACjB,0BAA0B,EAC1B;QACE,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EAAE;;;;;;;;;;;;;;;;;;uGAkBoF;QACjG,WAAW,EAAE;YACX,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,iFAAiF,CAAC;SACnH;QACD,WAAW,EAAE;YACX,KAAK,EAAE,oBAAoB;YAC3B,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,IAAI;SACrB;KACF,EACD,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QAChB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;QAC7E,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;gBAEJ,UAAU;;;;yGAI+E;qBAC5F;iBACF;gBACD,OAAO,EAAE,KAAK;aACf,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAEtH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;gBAEJ,UAAU;WACf,MAAM,CAAC,OAAO;aACZ,MAAM,CAAC,QAAQ;;;;EAI1B,MAAM,CAAC,MAAM;;;EAGb,MAAM,CAAC,MAAM;;;;4JAI6I;qBAC/I;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;WACf,MAAM,CAAC,OAAO;;;EAGvB,MAAM,CAAC,MAAM;;;;iKAIkJ;iBACtJ;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -7,6 +7,10 @@ import { registerSetupUpdateEnv } from './update-env.js';
|
|
|
7
7
|
import { registerSetupValidateConfig } from './validate-config.js';
|
|
8
8
|
import { registerSetupGetConfigSchema } from './get-config-schema.js';
|
|
9
9
|
import { registerSetupGetInitTemplate } from './get-init-template.js';
|
|
10
|
+
import { registerSetupSetDefaultConfig } from './set-default-config.js';
|
|
11
|
+
import { registerSetupGetDefaultConfig } from './get-default-config.js';
|
|
12
|
+
import { registerSetupClearDefaultConfig } from './clear-default-config.js';
|
|
13
|
+
import { registerSetupListConfigs } from './list-configs.js';
|
|
10
14
|
export function registerSetupTools(server) {
|
|
11
15
|
registerSetupCreateFolder(server);
|
|
12
16
|
registerSetupInstallPackage(server);
|
|
@@ -17,5 +21,9 @@ export function registerSetupTools(server) {
|
|
|
17
21
|
registerSetupValidateConfig(server);
|
|
18
22
|
registerSetupGetConfigSchema(server);
|
|
19
23
|
registerSetupGetInitTemplate(server);
|
|
24
|
+
registerSetupSetDefaultConfig(server);
|
|
25
|
+
registerSetupGetDefaultConfig(server);
|
|
26
|
+
registerSetupClearDefaultConfig(server);
|
|
27
|
+
registerSetupListConfigs(server);
|
|
20
28
|
}
|
|
21
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/setup/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../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wBAAwB,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -5,11 +5,11 @@ import { execProcess } from '../../lib/exec.js';
|
|
|
5
5
|
export function registerSetupInitConfig(server) {
|
|
6
6
|
server.registerTool('setup_init_config', {
|
|
7
7
|
title: 'Init RESTForge Config',
|
|
8
|
-
description: `Generate skeleton config
|
|
8
|
+
description: `Generate a skeleton config file in the project folder via restforge.
|
|
9
9
|
|
|
10
10
|
USE WHEN:
|
|
11
11
|
- The project has @restforgejs/platform installed in node_modules
|
|
12
|
-
- The config/
|
|
12
|
+
- The config/ folder does not exist yet, or you want to reset it to the default template
|
|
13
13
|
- Starting RESTForge project configuration from scratch
|
|
14
14
|
|
|
15
15
|
DO NOT USE FOR:
|
|
@@ -17,7 +17,7 @@ DO NOT USE FOR:
|
|
|
17
17
|
- Filling in credentials in db-connection.env -> use 'setup_write_env'
|
|
18
18
|
|
|
19
19
|
This tool runs: npx restforge init in the given cwd.
|
|
20
|
-
Output: config/db-connection.env (empty template)
|
|
20
|
+
Output: config/db-connection.env (empty template).
|
|
21
21
|
|
|
22
22
|
PRESENTATION GUIDANCE:
|
|
23
23
|
- Match the user's language. If the user writes in Indonesian, respond in Indonesian.
|
|
@@ -101,8 +101,6 @@ For the assistant:
|
|
|
101
101
|
Project path: ${projectCwd}
|
|
102
102
|
Files created:
|
|
103
103
|
- config/db-connection.env (empty template, awaiting credentials)
|
|
104
|
-
- payload/samples.json
|
|
105
|
-
- payload/query/samples-datatables.sql
|
|
106
104
|
|
|
107
105
|
--- CLI output ---
|
|
108
106
|
${result.stdout}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-config.js","sourceRoot":"","sources":["../../../src/tools/setup/init-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,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P,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;gBAEJ,UAAU;;;;;;gKAMsI;qBACnJ;iBACF;gBACD,OAAO,EAAE,KAAK;aACf,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAC9B,KAAK,EACL,CAAC,WAAW,EAAE,MAAM,CAAC,EACrB,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,CACrC,CAAC;QAEF,yDAAyD;QACzD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;gBAEJ,UAAU;WACf,MAAM,CAAC,OAAO;aACZ,MAAM,CAAC,QAAQ;;;;EAI1B,MAAM,CAAC,MAAM;;;EAGb,MAAM,CAAC,MAAM;;;;;;4FAM6E;qBAC/E;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,0EAA0E;QAC1E,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;;;;;EAKxB,MAAM,CAAC,MAAM;;;;;;+HAMgH;iBACpH;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { access } from 'node:fs/promises';
|
|
3
|
+
import { resolve, join } from 'node:path';
|
|
4
|
+
import { execProcess } from '../../lib/exec.js';
|
|
5
|
+
export function registerSetupListConfigs(server) {
|
|
6
|
+
server.registerTool('setup_list_configs', {
|
|
7
|
+
title: 'List Config Files',
|
|
8
|
+
description: `List the .env config files available in the working directory and the config/ folder, by wrapping restforge config list.
|
|
9
|
+
|
|
10
|
+
USE WHEN:
|
|
11
|
+
- The user asks which config files exist, e.g. "config apa saja yang ada", "list .env files", "daftar config", "lihat file config"
|
|
12
|
+
- Before choosing a config to set as default or to pass to a command
|
|
13
|
+
|
|
14
|
+
DO NOT USE FOR:
|
|
15
|
+
- Showing/setting the DEFAULT config -> use 'setup_get_default_config' / 'setup_set_default_config'
|
|
16
|
+
- Reading the values inside a config -> use 'setup_read_env'
|
|
17
|
+
|
|
18
|
+
This tool runs: npx restforge config list in the given cwd (outputs JSON).
|
|
19
|
+
|
|
20
|
+
Preconditions:
|
|
21
|
+
- The project must have @restforgejs/platform installed in node_modules.
|
|
22
|
+
|
|
23
|
+
PRESENTATION GUIDANCE:
|
|
24
|
+
- Match the user's language. Never mention internal tool names; describe the action.
|
|
25
|
+
- Summarise the available .env files and where they are. Keep it concise.
|
|
26
|
+
- When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
|
|
27
|
+
inputSchema: {
|
|
28
|
+
cwd: z.string().min(1).describe('Absolute path of the project folder (must have @restforgejs/platform installed)'),
|
|
29
|
+
},
|
|
30
|
+
annotations: {
|
|
31
|
+
title: 'List Config Files',
|
|
32
|
+
readOnlyHint: true,
|
|
33
|
+
idempotentHint: true,
|
|
34
|
+
},
|
|
35
|
+
}, async ({ cwd }) => {
|
|
36
|
+
const projectCwd = resolve(cwd);
|
|
37
|
+
try {
|
|
38
|
+
await access(join(projectCwd, 'node_modules', '@restforgejs', 'platform'));
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: 'text',
|
|
45
|
+
text: `Precondition not met: the RESTForge package is not installed in this project.
|
|
46
|
+
|
|
47
|
+
Project path: ${projectCwd}
|
|
48
|
+
Expected location: node_modules/@restforgejs/platform
|
|
49
|
+
|
|
50
|
+
For the assistant:
|
|
51
|
+
- The user needs to install the RESTForge package first, then retry. Do not mention internal tool names.`,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
isError: false,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const result = await execProcess('npx', ['restforge', 'config', 'list'], { cwd: projectCwd, timeout: 30_000 });
|
|
58
|
+
if (!result.success) {
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'text',
|
|
63
|
+
text: `Failed to list config files.
|
|
64
|
+
|
|
65
|
+
Project path: ${projectCwd}
|
|
66
|
+
Command: ${result.command}
|
|
67
|
+
Exit code: ${result.exitCode}
|
|
68
|
+
|
|
69
|
+
--- CLI output ---
|
|
70
|
+
stdout:
|
|
71
|
+
${result.stdout}
|
|
72
|
+
|
|
73
|
+
stderr:
|
|
74
|
+
${result.stderr}
|
|
75
|
+
--- end CLI output ---
|
|
76
|
+
|
|
77
|
+
For the assistant:
|
|
78
|
+
- Tell the user the config files could not be listed; summarise the likely cause. Do not paste raw output unless asked. Do not mention internal tool names.`,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
isError: true,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
content: [
|
|
86
|
+
{
|
|
87
|
+
type: 'text',
|
|
88
|
+
text: `Config files listed.
|
|
89
|
+
|
|
90
|
+
Project path: ${projectCwd}
|
|
91
|
+
Command: ${result.command}
|
|
92
|
+
|
|
93
|
+
--- CLI output ---
|
|
94
|
+
${result.stdout}
|
|
95
|
+
--- end CLI output ---
|
|
96
|
+
|
|
97
|
+
For the assistant:
|
|
98
|
+
- Read the JSON and tell the user which .env files are available (in cwd and config/). Keep it concise. Do not mention internal tool names.`,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=list-configs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-configs.js","sourceRoot":"","sources":["../../../src/tools/setup/list-configs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,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;wBACZ,IAAI,EAAE;;gBAEJ,UAAU;WACf,MAAM,CAAC,OAAO;aACZ,MAAM,CAAC,QAAQ;;;;EAI1B,MAAM,CAAC,MAAM;;;EAGb,MAAM,CAAC,MAAM;;;;4JAI6I;qBAC/I;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;WACf,MAAM,CAAC,OAAO;;;EAGvB,MAAM,CAAC,MAAM;;;;4IAI6H;iBACjI;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { access } from 'node:fs/promises';
|
|
3
|
+
import { resolve, join } from 'node:path';
|
|
4
|
+
import { execProcess } from '../../lib/exec.js';
|
|
5
|
+
export function registerSetupSetDefaultConfig(server) {
|
|
6
|
+
server.registerTool('setup_set_default_config', {
|
|
7
|
+
title: 'Set Default Config',
|
|
8
|
+
description: `Set a config file as the default for the current working directory (stored in .restforge/defaults.json), by wrapping restforge config set-default. Other commands then fall back to this config when --config is not given.
|
|
9
|
+
|
|
10
|
+
USE WHEN:
|
|
11
|
+
- The user wants to pin/set a default config for a project, e.g. "set default config", "jadikan db.env sebagai default", "pakai config ini sebagai default"
|
|
12
|
+
- To avoid passing --config on every command
|
|
13
|
+
|
|
14
|
+
DO NOT USE FOR:
|
|
15
|
+
- Showing the current default -> use 'setup_get_default_config'
|
|
16
|
+
- Removing the default -> use 'setup_clear_default_config'
|
|
17
|
+
- Writing credentials into the .env -> use 'setup_write_env'
|
|
18
|
+
|
|
19
|
+
This tool runs: npx restforge config set-default --config=<config> in the given cwd. The config is looked up as: cwd -> config/ folder -> with +.env extension.
|
|
20
|
+
|
|
21
|
+
Preconditions:
|
|
22
|
+
- The project must have @restforgejs/platform installed in node_modules.
|
|
23
|
+
|
|
24
|
+
PRESENTATION GUIDANCE:
|
|
25
|
+
- Match the user's language. Never mention internal tool names; describe the action (e.g. "set the default config").
|
|
26
|
+
- Confirm which file is now the default. Keep the reply concise.
|
|
27
|
+
- When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
|
|
28
|
+
inputSchema: {
|
|
29
|
+
cwd: z.string().min(1).describe('Absolute path of the project folder (must have @restforgejs/platform installed)'),
|
|
30
|
+
config: z.string().min(1).describe('Config file to set as default. REQUIRED. Looked up: cwd -> config/ -> +.env.'),
|
|
31
|
+
},
|
|
32
|
+
annotations: {
|
|
33
|
+
title: 'Set Default Config',
|
|
34
|
+
readOnlyHint: false,
|
|
35
|
+
idempotentHint: true,
|
|
36
|
+
destructiveHint: false,
|
|
37
|
+
},
|
|
38
|
+
}, async ({ cwd, config }) => {
|
|
39
|
+
const projectCwd = resolve(cwd);
|
|
40
|
+
try {
|
|
41
|
+
await access(join(projectCwd, 'node_modules', '@restforgejs', 'platform'));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: 'text',
|
|
48
|
+
text: `Precondition not met: the RESTForge package is not installed in this project.
|
|
49
|
+
|
|
50
|
+
Project path: ${projectCwd}
|
|
51
|
+
Expected location: node_modules/@restforgejs/platform
|
|
52
|
+
|
|
53
|
+
For the assistant:
|
|
54
|
+
- The user needs to install the RESTForge package first, then retry. Do not mention internal tool names.`,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
isError: false,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const result = await execProcess('npx', ['restforge', 'config', 'set-default', `--config=${config}`], { cwd: projectCwd, timeout: 30_000 });
|
|
61
|
+
if (!result.success) {
|
|
62
|
+
return {
|
|
63
|
+
content: [
|
|
64
|
+
{
|
|
65
|
+
type: 'text',
|
|
66
|
+
text: `Failed to set the default config.
|
|
67
|
+
|
|
68
|
+
Project path: ${projectCwd}
|
|
69
|
+
Config: ${config}
|
|
70
|
+
Command: ${result.command}
|
|
71
|
+
Exit code: ${result.exitCode}
|
|
72
|
+
|
|
73
|
+
--- CLI output ---
|
|
74
|
+
stdout:
|
|
75
|
+
${result.stdout}
|
|
76
|
+
|
|
77
|
+
stderr:
|
|
78
|
+
${result.stderr}
|
|
79
|
+
--- end CLI output ---
|
|
80
|
+
|
|
81
|
+
For the assistant:
|
|
82
|
+
- Tell the user the default config was not set; summarise the likely cause (e.g. the config file was not found in cwd or config/). Do not paste raw output unless asked. Do not mention internal tool names.`,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
isError: true,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
content: [
|
|
90
|
+
{
|
|
91
|
+
type: 'text',
|
|
92
|
+
text: `Default config set.
|
|
93
|
+
|
|
94
|
+
Project path: ${projectCwd}
|
|
95
|
+
Config: ${config}
|
|
96
|
+
Command: ${result.command}
|
|
97
|
+
|
|
98
|
+
--- CLI output ---
|
|
99
|
+
${result.stdout}
|
|
100
|
+
--- end CLI output ---
|
|
101
|
+
|
|
102
|
+
For the assistant:
|
|
103
|
+
- Confirm the named file is now the default config for this working directory (stored in .restforge/defaults.json). Other commands will use it when no config is specified. Keep the reply concise. Do not mention internal tool names.`,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=set-default-config.js.map
|