mirror of
https://github.com/johndoe6345789/AutoMetabuilder.git
synced 2026-04-24 22:04:58 +00:00
Introduce AutoMetabuilder core components and workflow packages:
- Implement core components: CLI argument parsing, environment loading, GitHub service creation, and logging configuration. - Add support for OpenAI client setup and model resolution. - Develop SDLC context loader from GitHub and repository files. - Implement workflow context and engine builders. - Introduce major workflow packages: `game_tick_loop` and `contextual_iterative_loop`. - Update localization files with new package descriptions and labels. - Streamline web navigation by loading items from a dedicated JSON file.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
window.AMBWorkflowState?.setPlugins?.(pluginDefinitions);
|
||||
window.AMBWorkflowState?.loadFromTextarea?.();
|
||||
rerender();
|
||||
window.AMBWorkflowPalette?.init?.();
|
||||
},
|
||||
|
||||
toggleRaw() {
|
||||
|
||||
@@ -1,52 +1,53 @@
|
||||
/**
|
||||
* AutoMetabuilder - Workflow Palette
|
||||
*/
|
||||
(() => {
|
||||
const state = {
|
||||
container: null,
|
||||
searchInput: null,
|
||||
list: null,
|
||||
filter: ''
|
||||
filter: '',
|
||||
ready: false,
|
||||
loading: false
|
||||
};
|
||||
|
||||
const getGroupKey = (type) => (type || '').split('.')[0] || 'other';
|
||||
|
||||
const buildEntries = (definitions, t) => Object.entries(definitions || {}).map(([key, def]) => {
|
||||
const label = t?.(def.label || '', def.label || key) || key;
|
||||
return {
|
||||
key,
|
||||
label,
|
||||
group: getGroupKey(key),
|
||||
search: `${key} ${label}`.toLowerCase()
|
||||
};
|
||||
});
|
||||
|
||||
const buildEntries = (definitions, t) => Object.entries(definitions || {}).map(([key, def]) => ({ key, label: t?.(def.label || '', def.label || key) || key, group: getGroupKey(key), search: `${key} ${t?.(def.label || '', def.label || key) || key}`.toLowerCase() }));
|
||||
const loadDefinitions = async () => {
|
||||
if (state.loading) return;
|
||||
state.loading = true;
|
||||
try {
|
||||
const response = await fetch('/api/workflow/plugins', { credentials: 'include', headers: window.AMBContext?.authHeaders || {} });
|
||||
if (response.ok) {
|
||||
window.AMBWorkflowState?.setPlugins?.(await response.json());
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Workflow palette fetch failed', error);
|
||||
}
|
||||
state.loading = false;
|
||||
render();
|
||||
};
|
||||
const render = () => {
|
||||
const { t, escapeHtml } = window.AMBWorkflowUtils || {};
|
||||
const definitions = window.AMBWorkflowState?.state?.pluginDefinitions || {};
|
||||
if (!state.list) return;
|
||||
if (!Object.keys(definitions).length) {
|
||||
if (!state.loading) {
|
||||
loadDefinitions();
|
||||
}
|
||||
const loadingText = t?.('ui.workflow.palette.loading', 'Loading nodes...');
|
||||
state.list.innerHTML = `<p class="text-muted small mb-0">${escapeHtml ? escapeHtml(loadingText) : loadingText}</p>`;
|
||||
return;
|
||||
}
|
||||
const term = state.filter.toLowerCase();
|
||||
const entries = buildEntries(definitions, t).filter(entry => !term || entry.search.includes(term));
|
||||
if (!entries.length) {
|
||||
state.list.innerHTML = `<p class="text-muted small mb-0">${escapeHtml ? escapeHtml(t?.('ui.workflow.palette.empty', 'No matching nodes.')) : t?.('ui.workflow.palette.empty', 'No matching nodes.')}</p>`;
|
||||
return;
|
||||
}
|
||||
|
||||
const grouped = entries.reduce((acc, entry) => {
|
||||
const group = entry.group || 'other';
|
||||
acc[group] = acc[group] || [];
|
||||
acc[group].push(entry);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const groupNames = Object.keys(grouped).sort((a, b) => {
|
||||
const aOther = a === 'other';
|
||||
const bOther = b === 'other';
|
||||
if (aOther && !bOther) return 1;
|
||||
if (!aOther && bOther) return -1;
|
||||
return a.localeCompare(b);
|
||||
});
|
||||
|
||||
const groupNames = Object.keys(grouped).sort((a, b) => (a === 'other') - (b === 'other') || a.localeCompare(b));
|
||||
const groupsHtml = groupNames.map(group => {
|
||||
const groupLabelKey = `ui.workflow.palette.group.${group}`;
|
||||
const groupLabel = t?.(groupLabelKey, group) || group;
|
||||
@@ -67,21 +68,21 @@
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
state.list.innerHTML = groupsHtml;
|
||||
};
|
||||
|
||||
const init = () => {
|
||||
if (state.ready) {
|
||||
render();
|
||||
return;
|
||||
}
|
||||
state.container = document.getElementById('workflow-palette');
|
||||
state.searchInput = document.getElementById('workflow-palette-search');
|
||||
state.list = document.getElementById('workflow-palette-list');
|
||||
if (!state.container || !state.searchInput || !state.list) return;
|
||||
|
||||
state.searchInput.addEventListener('input', (event) => {
|
||||
state.filter = event.target.value || '';
|
||||
render();
|
||||
});
|
||||
|
||||
state.list.addEventListener('click', (event) => {
|
||||
const target = event.target.closest('.amb-workflow-palette-item');
|
||||
if (!target) return;
|
||||
@@ -91,9 +92,8 @@
|
||||
window.AMBWorkflowMutations?.addNode(workflowState.workflow.nodes, workflowState.pluginDefinitions, nodeType);
|
||||
window.AMBWorkflowCanvasRenderer?.render?.();
|
||||
});
|
||||
|
||||
state.ready = true;
|
||||
render();
|
||||
};
|
||||
|
||||
window.AMBWorkflowPalette = { init, render };
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user