mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 04:44:28 +00:00
feat(agent): propagate autofill context from chat to autofill workflow
Add an optional 'context' parameter to the create_file and create_version agent tools so the chat agent can pass generation/source context (e.g. 'Generated using gemini') to the AI metadata autofill workflow. - Add Asset.autofillContext column, persisted in the same transaction as asset creation when context is provided - Add new list_autofill_fields agent tool exposing autofillable metadata fields (name, type, description, options) per project - Autofill workflow reads the stored context and includes it in the autofill AI prompt - Add short chat system-prompt guidance to use list_autofill_fields and pass <=50 word context when creating files/versions
This commit is contained in:
@@ -70,6 +70,33 @@ describe('createCreateFileTool', () => {
|
||||
expect(result.details).toEqual({ id: 'file-1', name: 'test', type: 'file' })
|
||||
})
|
||||
|
||||
it('should forward the optional context to the agent tool workflow when provided', async () => {
|
||||
const filePath = createTempFile('# Hello from disk', 'create-file-context.md')
|
||||
|
||||
const tool = createCreateFileTool('user-1')
|
||||
await tool.execute('call-1', {
|
||||
parent: 'folder-1',
|
||||
path: filePath,
|
||||
context: 'Generated using gemini',
|
||||
})
|
||||
|
||||
expect(executeAgentToolWorkflow).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
args: expect.objectContaining({ context: 'Generated using gemini' }),
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('should not include context in args when not provided', async () => {
|
||||
const filePath = createTempFile('# Hello from disk', 'create-file-no-context.md')
|
||||
|
||||
const tool = createCreateFileTool('user-1')
|
||||
await tool.execute('call-1', { parent: 'folder-1', path: filePath })
|
||||
|
||||
const callArgs = vi.mocked(executeAgentToolWorkflow).mock.calls[0][0].args
|
||||
expect(callArgs).not.toHaveProperty('context')
|
||||
})
|
||||
|
||||
it('should throw when the local file does not exist', async () => {
|
||||
const tool = createCreateFileTool('user-1')
|
||||
await expect(
|
||||
|
||||
Reference in New Issue
Block a user