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

Function write_page

skills/mini-context-graph/scripts/tools/wiki_store.py:123–176  ·  view source on GitHub ↗

Write (or overwrite) a wiki page. The agent provides the full markdown content. This method handles: - Writes the .md file to the appropriate category subfolder. - Updates index.md with a one-line entry. - Appends an entry to log.md. Args: category: One of "entity"

(
    category: str,
    title: str,
    content: str,
    summary: str = "",
)

Source from the content-addressed store, hash-verified

121# ---------------------------------------------------------------------------
122
123def write_page(
124 category: str,
125 title: str,
126 content: str,
127 summary: str = "",
128) -> str:
129 """
130 Write (or overwrite) a wiki page.
131
132 The agent provides the full markdown content. This method handles:
133 - Writes the .md file to the appropriate category subfolder.
134 - Updates index.md with a one-line entry.
135 - Appends an entry to log.md.
136
137 Args:
138 category: One of "entity", "summary", "topic".
139 title: Human-readable page title (used for slug + index).
140 content: Full markdown content the agent wrote.
141 summary: One-line summary for the index (optional; auto-extracted if empty).
142
143 Returns:
144 Relative path from wiki root (e.g. "entities/memory-leak.md").
145 """
146 _ensure_dirs()
147 slug = _slug(title)
148 path = _page_path(category, slug)
149
150 # Auto-extract first non-heading, non-empty line as summary if not provided
151 if not summary:
152 for line in content.splitlines():
153 stripped = line.strip()
154 if stripped and not stripped.startswith("#"):
155 summary = stripped[:100]
156 break
157
158 path.write_text(content)
159
160 # Update index
161 entries = _load_index()
162 existing = next((e for e in entries if e["slug"] == slug), None)
163 if existing:
164 existing["summary"] = summary
165 existing["date"] = _now_iso()
166 else:
167 entries.append({
168 "slug": slug,
169 "category": category,
170 "summary": summary,
171 "date": _now_iso(),
172 })
173 _save_index(entries)
174 _append_log("write", title)
175
176 return str(path.relative_to(_WIKI_DIR))
177
178
179def read_page(category: str, title: str) -> str | None:

Callers

nothing calls this directly

Calls 7

_ensure_dirsFunction · 0.85
_slugFunction · 0.85
_page_pathFunction · 0.85
_load_indexFunction · 0.85
_now_isoFunction · 0.85
_save_indexFunction · 0.85
_append_logFunction · 0.85

Tested by

no test coverage detected