feat: update Makelore modules and conversations
This commit is contained in:
@@ -1,77 +1,21 @@
|
||||
import type { BuiltInRoleSubagentId } from '@/lib/role-subagents';
|
||||
import type { CreatedPartnerSubagent, PartnerTemplateRoleId } from '@/stores/partner-profiles';
|
||||
import {
|
||||
getProjectTemplateRequiredSkillIds,
|
||||
type ProjectTemplateSnapshot,
|
||||
} from '../../shared/project-template';
|
||||
import type { CreatedPartnerSubagent } from '@/stores/partner-profiles';
|
||||
|
||||
type CourseStageId = string;
|
||||
type CourseRoleBindings = Record<string, string | undefined>;
|
||||
|
||||
const DEFAULT_TEMPLATE_SKILL_IDS: Record<BuiltInRoleSubagentId, string[]> = {
|
||||
pm: ['youth-ai-product-course', 'pm-project-plan'],
|
||||
product: ['youth-ai-product-course', 'product-demo-prototype', 'ui-ux-course-quality'],
|
||||
designer: ['youth-ai-product-course', 'designer-design-spec', 'ui-ux-course-quality'],
|
||||
dev: ['youth-ai-product-course', 'dev-build-test', 'ui-ux-course-quality'],
|
||||
marketing: ['youth-ai-product-course', 'marketing-launch-story', 'ui-ux-course-quality'],
|
||||
deploy: ['youth-ai-product-course', 'deploy-publish-check'],
|
||||
gameplay: [],
|
||||
assets: ['designer-design-spec', 'ui-ux-course-quality', 'game-assets'],
|
||||
'game-dev': ['dev-build-test', 'ui-ux-course-quality'],
|
||||
'game-release': ['deploy-publish-check'],
|
||||
'game-showcase': ['marketing-launch-story', 'ui-ux-course-quality'],
|
||||
};
|
||||
const BASE_REQUIRED_SKILL_IDS = ['youth-plain-language'] as const;
|
||||
|
||||
function mergeSkillIds(...skillLists: Array<readonly string[]>): string[] {
|
||||
const result: string[] = [];
|
||||
const seen = new Set<string>();
|
||||
for (const skillList of skillLists) {
|
||||
for (const skillId of skillList) {
|
||||
if (!seen.has(skillId)) {
|
||||
seen.add(skillId);
|
||||
result.push(skillId);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function createLocalSubagentId(templateRoleId: PartnerTemplateRoleId): string {
|
||||
const timestamp = new Date().toISOString()
|
||||
.replace(/\D/g, '')
|
||||
.slice(0, 14);
|
||||
function createLocalSubagentId(): string {
|
||||
const timestamp = new Date().toISOString().replace(/\D/g, '').slice(0, 14);
|
||||
const randomPart = typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'
|
||||
? crypto.randomUUID().replace(/-/g, '').slice(0, 6)
|
||||
: Math.random().toString(16).slice(2, 8).padEnd(6, '0');
|
||||
return `nitu-${templateRoleId}-${timestamp}-${randomPart}`;
|
||||
}
|
||||
|
||||
export function getDefaultSubagentSkillIds(templateRoleId: PartnerTemplateRoleId): string[] {
|
||||
return templateRoleId === 'custom'
|
||||
? [...BASE_REQUIRED_SKILL_IDS]
|
||||
: [...new Set([...BASE_REQUIRED_SKILL_IDS, ...DEFAULT_TEMPLATE_SKILL_IDS[templateRoleId]])];
|
||||
return `makelore-custom-${timestamp}-${randomPart}`;
|
||||
}
|
||||
|
||||
export function getSubagentManualSkillIds(subagent: CreatedPartnerSubagent): string[] {
|
||||
return subagent.skillIds ?? getDefaultSubagentSkillIds(subagent.templateRoleId);
|
||||
return [...new Set((subagent.skillIds ?? []).map((skillId) => skillId.trim()).filter(Boolean))];
|
||||
}
|
||||
|
||||
export function getSubagentRuntimeSkillIds(subagent: CreatedPartnerSubagent): string[] {
|
||||
return getSubagentManualSkillIds(subagent);
|
||||
}
|
||||
|
||||
export function getEffectiveSubagentRuntimeSkillIds(
|
||||
subagent: CreatedPartnerSubagent,
|
||||
snapshot: ProjectTemplateSnapshot | null | undefined,
|
||||
courseRoleId: string | null | undefined = subagent.templateRoleId,
|
||||
): string[] {
|
||||
return mergeSkillIds(
|
||||
getSubagentManualSkillIds(subagent),
|
||||
getProjectTemplateRequiredSkillIds(snapshot, courseRoleId),
|
||||
);
|
||||
}
|
||||
|
||||
export function hasAllSkillIds(actualSkillIds: readonly string[] | undefined, requiredSkillIds: readonly string[]): boolean {
|
||||
const actual = new Set(actualSkillIds ?? []);
|
||||
return requiredSkillIds.every((skillId) => actual.has(skillId));
|
||||
@@ -79,36 +23,18 @@ export function hasAllSkillIds(actualSkillIds: readonly string[] | undefined, re
|
||||
|
||||
export function createLocalPartnerSubagent(input: {
|
||||
displayName: string;
|
||||
templateRoleId: PartnerTemplateRoleId;
|
||||
prompt?: string;
|
||||
skillIds?: string[];
|
||||
}): CreatedPartnerSubagent {
|
||||
const now = new Date().toISOString();
|
||||
const prompt = input.prompt?.trim();
|
||||
return {
|
||||
id: createLocalSubagentId(input.templateRoleId),
|
||||
id: createLocalSubagentId(),
|
||||
displayName: input.displayName.trim(),
|
||||
templateRoleId: input.templateRoleId,
|
||||
skillIds: getDefaultSubagentSkillIds(input.templateRoleId),
|
||||
...(input.templateRoleId === 'custom' && prompt ? { prompt } : {}),
|
||||
templateRoleId: 'custom',
|
||||
skillIds: [...new Set((input.skillIds ?? []).map((skillId) => skillId.trim()).filter(Boolean))],
|
||||
...(prompt ? { prompt } : {}),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
};
|
||||
}
|
||||
|
||||
export function getBoundSubagentForCourseRole(
|
||||
subagents: CreatedPartnerSubagent[],
|
||||
roleBindings: CourseRoleBindings | undefined,
|
||||
courseRoleId: CourseStageId,
|
||||
): CreatedPartnerSubagent | undefined {
|
||||
const boundSubagentId = roleBindings?.[courseRoleId]?.trim();
|
||||
if (!boundSubagentId) return undefined;
|
||||
return subagents.find((subagent) => subagent.id === boundSubagentId);
|
||||
}
|
||||
|
||||
export function resolveCourseRuntimeAgentId(
|
||||
courseRoleId: CourseStageId,
|
||||
subagents: CreatedPartnerSubagent[],
|
||||
roleBindings: CourseRoleBindings | undefined,
|
||||
): string | undefined {
|
||||
return getBoundSubagentForCourseRole(subagents, roleBindings, courseRoleId)?.id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user