MCPcopy
hub / github.com/github/awesome-copilot / applyTemplatePack

Function applyTemplatePack

extensions/site-studio/extension.mjs:506–535  ·  view source on GitHub ↗
(packId, author = "agent")

Source from the content-addressed store, hash-verified

504}
505
506function applyTemplatePack(packId, author = "agent") {
507 const { id, pack } = getTemplatePackOrThrow(packId);
508 const ts = nowIso();
509 stateCache.templatePackId = id;
510 stateCache.fieldSuggestions = cloneJson(pack.fieldSuggestions || {});
511 stateCache.sectionSchemas = cloneJson(pack.sectionSchemas || {});
512 stateCache.sections = (pack.sections || []).map((section) => ({
513 ...section,
514 status: "Not Started",
515 notes: [],
516 content: cloneJson(pack.defaultContent?.[section.id] || {}),
517 filesChanged: [],
518 lastModified: ts,
519 }));
520 stateCache.changeLog = [];
521 stateCache.contentProposals = [];
522 stateCache.milestones = [];
523 stateCache.lastUpdated = ts;
524 addChange({
525 type: "status_change",
526 summary: `Template pack applied: ${pack.label}.`,
527 timestamp: ts,
528 });
529 addNote(
530 stateCache.sections[0]?.id || "hero",
531 `Applied template pack "${pack.label}".`,
532 author === "human" ? "human" : "agent",
533 );
534 return { templatePackId: id, label: pack.label, sections: stateCache.sections };
535}
536
537function createInitialState() {
538 const ts = nowIso();

Callers 2

handleApiFunction · 0.85
extension.mjsFile · 0.85

Calls 5

getTemplatePackOrThrowFunction · 0.85
nowIsoFunction · 0.85
cloneJsonFunction · 0.85
addChangeFunction · 0.85
addNoteFunction · 0.85

Tested by

no test coverage detected