@saltcorn/copilot 0.8.1 → 0.8.3
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/actions/generate-page.js +6 -2
- package/actions/generate-tables.js +70 -6
- package/actions/generate-workflow.js +54 -3
- package/agent-skills/pagegen.js +171 -59
- package/agent-skills/registry-editor.js +30 -2
- package/agent-skills/triggergen.js +1 -5
- package/agent-skills/viewgen.js +49 -7
- package/app-constructor/common.js +7 -1
- package/app-constructor/errors.js +749 -61
- package/app-constructor/feedback-action.js +62 -60
- package/app-constructor/feedback.js +1294 -67
- package/app-constructor/fixed-prompts.js +829 -0
- package/app-constructor/phases.js +1485 -0
- package/app-constructor/prompt-generator.js +587 -0
- package/app-constructor/requirements.js +171 -50
- package/app-constructor/research.js +350 -0
- package/app-constructor/run_task.js +234 -73
- package/app-constructor/schema.js +173 -169
- package/app-constructor/tasks.js +96 -537
- package/app-constructor/tools.js +17 -4
- package/app-constructor/view.js +314 -54
- package/builder-gen.js +90 -41
- package/builder-schema.js +6 -0
- package/copilot-as-agent.js +1 -0
- package/index.js +0 -1
- package/js-code-gen.js +1 -0
- package/package.json +1 -1
- package/relation-paths.js +73 -40
- package/standard-prompt.js +1 -0
- package/user-copilot.js +2 -0
- package/workflow-gen.js +1 -0
- package/app-constructor/prompts.js +0 -120
- package/chat-copilot.js +0 -770
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const { eval_expression } = require("@saltcorn/data/models/expression");
|
|
2
1
|
const MetaData = require("@saltcorn/data/models/metadata");
|
|
3
2
|
const { interpolate } = require("@saltcorn/data/utils");
|
|
4
3
|
const { getState } = require("@saltcorn/data/db/state");
|
|
5
4
|
const { requirements_tool, task_tool } = require("./tools");
|
|
6
5
|
const { tool_choice } = require("./common");
|
|
6
|
+
const { PromptGenerator } = require("./prompt-generator");
|
|
7
7
|
|
|
8
8
|
module.exports = {
|
|
9
9
|
description: "Provide user feedback to the AppConstructor",
|
|
@@ -71,6 +71,7 @@ module.exports = {
|
|
|
71
71
|
title_field,
|
|
72
72
|
description_field,
|
|
73
73
|
url_field,
|
|
74
|
+
research_context,
|
|
74
75
|
},
|
|
75
76
|
}) => {
|
|
76
77
|
const use_title =
|
|
@@ -81,85 +82,72 @@ module.exports = {
|
|
|
81
82
|
: row[description_field];
|
|
82
83
|
const use_url =
|
|
83
84
|
mode === "workflow" ? interpolate(url, row, user) : row[url_field];
|
|
84
|
-
await MetaData.create({
|
|
85
|
-
type: "CopilotConstructMgr",
|
|
86
|
-
name: "feedback",
|
|
87
|
-
body: { title: use_title, description: use_description, url: use_url },
|
|
88
|
-
user_id: user?.id,
|
|
89
|
-
});
|
|
90
|
-
const spec = await MetaData.findOne({
|
|
91
|
-
type: "CopilotConstructMgr",
|
|
92
|
-
name: "spec",
|
|
93
|
-
});
|
|
94
|
-
if (!spec) return;
|
|
95
|
-
const reqAnswer = await getState().functions.llm_generate.run(
|
|
96
|
-
`The following application is being built:
|
|
97
85
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
86
|
+
const generator = await PromptGenerator.createInstance();
|
|
87
|
+
if (!generator.spec) return;
|
|
88
|
+
|
|
89
|
+
const feedbackResearchSection = research_context
|
|
90
|
+
? `\nThe user also answered clarifying questions about this feedback:\n\n${research_context}\n`
|
|
91
|
+
: "";
|
|
92
|
+
|
|
93
|
+
let urlSection = "";
|
|
94
|
+
if (use_url) {
|
|
95
|
+
const mView = use_url.match(/\/view\/([^/?#]+)/);
|
|
96
|
+
const mPage = use_url.match(/\/page\/([^/?#]+)/);
|
|
97
|
+
if (mView)
|
|
98
|
+
urlSection =
|
|
99
|
+
`\nThe feedback was submitted from the Saltcorn view named "${mView[1]}"` +
|
|
100
|
+
` (URL: ${use_url}).\n`;
|
|
101
|
+
else if (mPage)
|
|
102
|
+
urlSection =
|
|
103
|
+
`\nThe feedback was submitted from the Saltcorn page named "${mPage[1]}"` +
|
|
104
|
+
` (URL: ${use_url}).\n`;
|
|
105
|
+
else urlSection = `\nThe feedback was submitted from: ${use_url}\n`;
|
|
106
|
+
}
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
// plan requirements for a feedback
|
|
109
|
+
const reqAnswer = await getState().functions.llm_generate.run(
|
|
110
|
+
generator.feedbackReqPrompt({
|
|
111
|
+
title: use_title,
|
|
112
|
+
description: use_description,
|
|
113
|
+
urlSection,
|
|
114
|
+
feedbackResearchSection,
|
|
115
|
+
}),
|
|
111
116
|
{
|
|
112
117
|
tools: [requirements_tool],
|
|
113
118
|
...tool_choice("make_requirements"),
|
|
114
119
|
systemPrompt:
|
|
115
|
-
"You are a project manager. The user wants to build an application, and you
|
|
116
|
-
|
|
120
|
+
"You are a project manager. The user wants to build an application, and you\n" +
|
|
121
|
+
"must analyse their application description and any feedback available.",
|
|
122
|
+
}
|
|
117
123
|
);
|
|
118
124
|
const tc = reqAnswer.getToolCalls()[0];
|
|
119
|
-
console.log("
|
|
125
|
+
console.log("got new requiremenrts", tc.input.requirements);
|
|
120
126
|
|
|
121
127
|
for (const reqm of tc.input.requirements)
|
|
122
128
|
await MetaData.create({
|
|
123
129
|
type: "CopilotConstructMgr",
|
|
124
130
|
name: "requirement",
|
|
125
|
-
body: reqm,
|
|
131
|
+
body: { ...reqm, source: "feedback", feedback_title: use_title },
|
|
126
132
|
user_id: req.user?.id,
|
|
127
133
|
});
|
|
128
134
|
|
|
135
|
+
// plan tasks for the new requirements
|
|
129
136
|
const taskAnswer = await getState().functions.llm_generate.run(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
This application will be implemented in Saltcorn, a database application development
|
|
139
|
-
environment.
|
|
140
|
-
|
|
141
|
-
A new piece of feedback has come in from a user:
|
|
142
|
-
|
|
143
|
-
Title: ${use_title}
|
|
144
|
-
Description: ${use_description}
|
|
145
|
-
|
|
146
|
-
A product manager has determined that the following requirements should be added to the list of application requirements:
|
|
147
|
-
|
|
148
|
-
${tc.input.requirements.map((r) => " * " + r.requirement).join("\n")}
|
|
149
|
-
|
|
150
|
-
Your plan for implementing this new fedback and requirements should not include any clarification or questions to the product owner. The
|
|
151
|
-
information you have been given so far is all that is available. Every step in the plan
|
|
152
|
-
should be immediately implementable in Saltcorn. You are writing the steps in the plan
|
|
153
|
-
for a person who is competent in using saltcorn but has no other business knowledge.
|
|
154
|
-
|
|
155
|
-
Now use the plan_tasks tool to create the tasks to implement this new feedback
|
|
156
|
-
`,
|
|
137
|
+
generator.feedbackPrompt({
|
|
138
|
+
title: use_title,
|
|
139
|
+
description: use_description,
|
|
140
|
+
urlSection,
|
|
141
|
+
feedbackResearchSection,
|
|
142
|
+
newRequirements: tc.input.requirements,
|
|
143
|
+
}),
|
|
157
144
|
{
|
|
158
145
|
tools: [task_tool],
|
|
159
146
|
...tool_choice("plan_tasks"),
|
|
160
147
|
systemPrompt:
|
|
161
|
-
"You are a project manager. The user wants to build an application, and you
|
|
162
|
-
|
|
148
|
+
"You are a project manager. The user wants to build an application, and you\n" +
|
|
149
|
+
"must analyse their application description and any feedback available.",
|
|
150
|
+
}
|
|
163
151
|
);
|
|
164
152
|
const tcTasks = taskAnswer.getToolCalls()[0];
|
|
165
153
|
console.log("got new tasks", tcTasks.input.tasks);
|
|
@@ -168,8 +156,22 @@ Now use the plan_tasks tool to create the tasks to implement this new feedback
|
|
|
168
156
|
await MetaData.create({
|
|
169
157
|
type: "CopilotConstructMgr",
|
|
170
158
|
name: "task",
|
|
171
|
-
body: task,
|
|
159
|
+
body: { ...task, source: "feedback", feedback_title: use_title },
|
|
172
160
|
user_id: req.user?.id,
|
|
173
161
|
});
|
|
162
|
+
|
|
163
|
+
await MetaData.create({
|
|
164
|
+
type: "CopilotConstructMgr",
|
|
165
|
+
name: "feedback",
|
|
166
|
+
body: {
|
|
167
|
+
title: use_title,
|
|
168
|
+
description: use_description,
|
|
169
|
+
url: use_url,
|
|
170
|
+
research_context,
|
|
171
|
+
scope: row.scope || "overall",
|
|
172
|
+
phase_idx: row.phase_idx ?? null,
|
|
173
|
+
},
|
|
174
|
+
user_id: user?.id,
|
|
175
|
+
});
|
|
174
176
|
},
|
|
175
177
|
};
|