一键导入
standardize-knowledge
Analyse and normalise heading structure across knowledge corpus documents to consistent H2/H3/H4 Markdown hierarchy for reliable RAG chunking.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Analyse and normalise heading structure across knowledge corpus documents to consistent H2/H3/H4 Markdown hierarchy for reliable RAG chunking.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Build UI for opencosmos apps using @opencosmos/ui components exclusively. Provides the component API reference, import patterns, and rules needed to build correctly without grepping source or dist files.
View and edit which Claude model each Cosmo/Inception surface runs on. Single entry point for OpenCosmos's inference-cost knobs — reads and edits apps/web/lib/ai-models.ts so model choices never have to be hunted down across route files.
The Companion path's wellbeing check-in — "how am I, really?" The opposite of a task list: attunes across the whole person (body, heart, mind, spirit, relationships, creativity), gently surfaces drift from purpose, names the current season of life and meets it, and ends by bridging to the body. Presence first; offers one small thing, not ten. Grounded in Cosmo's Attune rhythm. Triggers: /attune, "attune", "how am I", "where am I at", "check in with me", "how am I doing really".
The Companion path's discernment loop — clarity for a decision or a crossroads, Socratic in spirit. Surfaces untested assumptions, contingent beliefs ("what has to be true for this to make sense?"), and blind spots (who or what isn't in the room?). Checks options against the person's living values, and notices when a value itself is up for revision. Doesn't decide — clarifies so the person can. Ends by bridging to the felt sense of the choice. Triggers: /discern, "help me discern", "I have a decision", "I'm at a crossroads", "what's true here", "help me see clearly", "should I".
The Companion path's core loop — being with what's present, not fixing it. Attune to the moment, inquire gently, offer in the person's wisdom language, and always bridge insight back to the body. Makes room for resistance (what is it protecting?), polarities (hold both poles, don't collapse the tension), and perspective shifts. Guards against spiritual bypassing. Witnesses; doesn't fix. Grounded in Cosmo's constitution. Triggers: /reflect, "reflect with me", "I'm sitting with something", "help me process", "I'm stuck in my head", "I need to be with this".
The Companion path's teacher-synthesis loop — reconciles the many coaches, teachers, traditions, and sources a person draws from into one coherent through-line, and names the contradictions honestly rather than smoothing them. Renders the synthesis in the person's own wisdom language. Faithful attribution; says so when weaving across sources. Reads brain/teachers.md. Triggers: /synthesize, "synthesize my teachers", "what's the through-line", "where do my teachers disagree", "reconcile my teachers", "weave this together".
基于 SOC 职业分类
| name | standardize-knowledge |
| description | Analyse and normalise heading structure across knowledge corpus documents to consistent H2/H3/H4 Markdown hierarchy for reliable RAG chunking. |
| argument-hint | [path/to/file.md | all] |
| disable-model-invocation | true |
| user-invocable | true |
Convert non-standard heading formats in the knowledge corpus to a consistent Markdown hierarchy, enabling reliable H2/H3 chunking by the embed pipeline.
Document (frontmatter title — never a heading in the body)
│
├── ## Major Division H2 — primary chunk boundary
│ (Book / Part / Play / Volume / essay section)
│ │
│ ├── ### Sub-division H3 — secondary chunk boundary
│ │ (Chapter / Act / Scene group / named section within a division)
│ │ │
│ │ └── #### Minor break H4 — in-chunk organisation, no embed split
│ │ (Scene / subsection / verse group)
│ │
│ └── ### Sub-division
│
└── ## Major Division
Mapping by doc type:
| Doc type | Depth | Maps to |
|---|---|---|
| Short essay / wiki article | 1 | ## only |
| Journal / autobiography (Fox) | 1 | ## Chapter I. |
| Long philosophical work | 1–2 | ## + ### |
| Play collection (Shakespeare) | 2–3 | ## Play, ### Act, #### Scene |
| Scripture / annotated verse | 1–2 | ## Chapter, #### Verse group |
Read $ARGUMENTS:
all or empty → corpus mode: process all files in knowledge/sources/ and knowledge/collections/Before modifying any headings, verify each target file's frontmatter declares work_type. This field is required by the graph layer (@opencosmos/constellation) and by the /split-collection routing logic.
Inference rules when work_type is missing:
| Path prefix | Inferred work_type |
|---|---|
knowledge/sources/ | work |
knowledge/collections/ | collection |
knowledge/references/ | reference |
knowledge/wiki/ | wiki |
For unambiguous files, insert work_type: <inferred> into the frontmatter directly beneath title:.
Ambiguous cases — do not auto-backfill; flag for manual review:
sources/ whose frontmatter already declares role: collection (or vice versa)./split-collection pass (Shakespeare collected works, Khayyám + Salámán, Walden + Civil Disobedience).title does not match the apparent content (e.g. a collection file titled after a single work).List every ambiguous file under Files Requiring Manual Review in the Step 6 report and skip the rest of this pipeline for them.
Run a grep to find files with non-standard heading patterns:
grep -rln "^CHAPTER\|^BOOK\|^PART\|^ACT\|^SCENE\|^PROLOGUE\|^EPILOGUE\|^[A-Z][A-Z ]\{5,\}" \
knowledge/sources/ knowledge/collections/ knowledge/references/
For each matched file, note which pattern dominates.
Common non-standard patterns and their standard equivalents:
| Pattern found | Context | Standard form |
|---|---|---|
CHAPTER I. Title | top-level chapter | ## Chapter I. Title |
CHAPTER I. (no title) | top-level chapter | ## Chapter I |
CHAPTER I. inside a BOOK | nested chapter | ### Chapter I |
BOOK I / PART I | major division | ## Book I / ## Part I |
ACT I / ACT II | division within play | ### Act I |
SCENE I / SCENE II | subdivision within act | #### Scene I |
PROLOGUE / EPILOGUE | major section | ## Prologue / ## Epilogue |
ALL-CAPS TITLE (full title line) | determine from context | ## or ### |
Before editing, read each flagged file to understand its nesting depth:
CHAPTER X) → map all to #### for BOOK, ### for CHAPTER## for Play, ### for Act, #### for SceneMulti-work monolith special case. If a file contains ≥2 works that a reader would cite separately (e.g. knowledge/sources/literature-the-complete-works-of-william-shakespeare.md, literature-rub-iy-t-of-omar-khayy-m-and-sal-m-n-and-abs-l.md, philosophy-walden-and-on-the-duty-of-civil-disobedience.md):
/split-collection <path> first, then re-run /standardize-knowledge on each per-work output. Proceed with split now? [yes/no]"yes, delegate to /split-collection; skip further steps on the original file in this run (it will be rewritten as a slim collection index by /split-collection).no, list the file under Files Requiring Manual Review in the Step 6 report and continue with remaining files.Frontmatter title is the document's authoritative heading. Any ^# line appearing in the body before the first ^## is H1-title-drift and must be removed.
Rule:
--- of frontmatter.^# , delete the line. If the immediately following line is blank, delete that blank line too.# Title + # Subtitle) before the first ^## .Example — before:
---
title: The Prophet
work_type: work
---
# The Prophet
*By Kahlil Gibran*
## The Coming of the Ship
Example — after:
---
title: The Prophet
work_type: work
---
*By Kahlil Gibran*
## The Coming of the Ship
For each file (after structure analysis):
THE CONCLUSION → ## The Conclusion)CHAPTER IV → ## Chapter IV)##, leave it aloneLine-by-line transform examples:
# Before → After
CHAPTER I. → ## Chapter I
CHAPTER I. The Vision → ## Chapter I. The Vision
BOOK II → ## Book II
PART THREE → ## Part Three
ACT I → ### Act I
SCENE II → #### Scene II
THE CONCLUSION → ## The Conclusion
(blank lines — untouched)
Some paragraph text. (body text — untouched)
After editing each file:
## headings: grep -c "^## " <file>### headings: grep -c "^### " <file><filename>"After editing, check for any YAML sequence items that may break the embed parser:
grep -n "^ - .*:.*[^\"']$" <file>
If found, quote the offending items (e.g. - targeted: resist injustices → - "targeted: resist injustices").
After Steps 2b, 3, and 5, verify each modified file's frontmatter contains:
title — non-empty stringwork_type — one of work | collection | reference | wikiIf either field is missing or empty, do not consider the file standardized. List it under Files Failing Verification in the Step 6 report with the specific missing field, and leave it for manual cleanup.
Output a summary:
## /standardize-knowledge Report
**Date:** YYYY-MM-DD
**Mode:** single-file | corpus
### Files Modified
- knowledge/sources/foo.md — converted 23 CHAPTER headings to H2
- knowledge/sources/bar.md — converted 4 BOOK (H2) + 18 CHAPTER (H3) headings
### Files Skipped
- knowledge/sources/baz.md — already uses standard Markdown headings
### Files Requiring Manual Review
- knowledge/collections/literature-shakespeare-collected-works.md — needs splitting first
### Next Steps
1. Review the diffs above for any unintended changes
2. Run `pnpm embed` to re-index the updated files in Upstash Vector
3. Verify chunk counts improved (more granular chunks = better RAG retrieval)
### Required environment for `pnpm embed`
The embed script exits silently if these are unset. Before invoking, confirm
both are present in `apps/web/.env.local` (and in Vercel for production):
- `UPSTASH_VECTOR_REST_URL`
- `UPSTASH_VECTOR_REST_TOKEN`
Upstash handles embedding generation natively, so no OpenAI key is required.