Knowledge > Processes > Nightly Google Drive Sync
Nightly Google Drive Sync
How knowledge/ canonical files sync to Google Drive so the CEO can browse them at C:\Users\johnm\ChurchWiseAI\ via Google Drive for Desktop.
Overview
The knowledge system uses a derive pipeline (pnpm derive) that reads canonical YAML data and markdown narratives, then propagates them to downstream targets. One target type is gdrive:, which converts source files to Google Docs-compatible HTML and uploads them to the corresponding Google Drive folder.
Manifest Configuration
knowledge/manifest.yaml declares which sources have Google Drive targets. Each gdrive: target specifies a destination folder path.
manifest.yaml entries with type: nightly
data/pricing.yaml → gdrive:03-Strategy/Pricing/
data/features.yaml → gdrive:02-Products/
data/products.yaml → gdrive:02-Products/
data/policies.yaml → gdrive:01-Business/Legal/
narrative/vision.md → gdrive:01-Business/Company/
narrative/competitive.md → gdrive:03-Strategy/Competitive/
narrative/sales-playbook.md → gdrive:05-Sales/
narrative/brand.md → gdrive:04-Marketing/Brand/
narrative/strategy.md → gdrive:03-Strategy/Roadmap/
narrative/customer-journey.md → gdrive:05-Sales/
narrative/operations.md → gdrive:06-Operations/SOPs/
Pipeline Steps
1. READ SOURCE FILE
source = read knowledge/data/*.yaml or knowledge/narrative/*.md
2. DETECT FORMAT
IF source ends with .yaml:
data = parse YAML
SWITCH on source filename:
pricing.yaml → html = pricingYamlToHtml(data, metadata)
features.yaml → html = featuresYamlToHtml(data, metadata)
products.yaml → html = productsYamlToHtml(data, metadata)
policies.yaml → html = policiesYamlToHtml(data, metadata)
ELSE IF source ends with .md:
html = markdownToGDocHtml(markdown_content, metadata)
3. CONVERT TO GOOGLE DOCS HTML
All converters produce clean HTML suitable for Google Docs import:
- Headings: <h1>, <h2>, <h3>
- Tables: <table> with <th>/<td>
- Lists: <ul>/<ol> with <li>
- Inline: <strong>, <em>, <code>, <a>
- Code blocks: <pre>
- Links preserved as clickable <a href>
4. ADD METADATA FOOTER
metadataFooter(metadata) appends:
<hr>
<p style="color: #999; font-size: 0.8em;">
Generated from {source_file} · {date} · Commit: {hash}
</p>
5. UPLOAD TO GOOGLE DRIVE
target folder = gdrive:{folder_path}
Maps to: Google Drive > ChurchWiseAI > {folder_path}
Synced to local via Drive for Desktop:
C:\Users\johnm\ChurchWiseAI\{folder_path}
Converter Functions (derive-gdrive.ts)
markdownToGDocHtml(markdown, metadata?)
Converts markdown narratives (vision, brand, strategy, etc.) to HTML.
HANDLES:
# H1, ## H2, ### H3 headings
**bold**, *italic*, `code`
[link text](url)
- unordered lists, 1. ordered lists
| table | rows |
``` code blocks ```
Blank lines → paragraph breaks
INLINE PROCESSING ORDER:
1. Code spans: `text` → <code>text</code>
2. Links: [text](url) → <a href="url">text</a>
3. Bold: **text** → <strong>text</strong> (before italic)
4. Italic: *text* → <em>text</em>
STATE MACHINE tracks:
inCodeBlock, inTable, inUl, inOl, paragraphLines[]
Flushes accumulated state on context switches
pricingYamlToHtml(pricing, metadata?)
Converts data/pricing.yaml to a formatted pricing guide.
OUTPUT:
<h1>ChurchWiseAI Pricing Guide</h1>
<h2>Products & Pricing</h2>
<table> product | monthly | annual | one-time </table>
<h2>Billing Rules</h2>
<ul> key-value list from billing_rules </ul>
<h2>Free Trials</h2>
<p> list of trial-enabled products with durations </p>
featuresYamlToHtml(features, metadata?)
Converts data/features.yaml to a feature matrix.
OUTPUT:
<h1>ChurchWiseAI Feature Matrix</h1>
<h2>Tier Overview</h2>
<table> feature | starter | pro | suite </table>
<h2>Features by Tier</h2>
Per-tier bulleted feature lists
<h2>Add-Ons</h2>
Named add-ons with descriptions and feature bullets
productsYamlToHtml(products, metadata?)
Converts data/products.yaml to product portfolio docs.
OUTPUT:
Company info, brand info
Products summary table: name | tagline | URL | status
Product detail sections: description, what_it_sells, codebase
policiesYamlToHtml(policies, metadata?)
Converts data/policies.yaml to formatted policy summary.
OUTPUT:
Cancellation policy, billing rules, refund policy
Price change policy, trial policy (chat vs voice)
Data handling section (nested key-value lists)
Drive Folder Structure
C:\Users\johnm\ChurchWiseAI\ (Google Drive for Desktop sync)
├── 01-Business/
│ ├── Company/ ← narrative/vision.md
│ └── Legal/ ← data/policies.yaml
├── 02-Products/ ← data/features.yaml, data/products.yaml
├── 03-Strategy/
│ ├── Competitive/ ← narrative/competitive.md
│ ├── Pricing/ ← data/pricing.yaml
│ └── Roadmap/ ← narrative/strategy.md
├── 04-Marketing/
│ └── Brand/ ← narrative/brand.md
├── 05-Sales/ ← narrative/sales-playbook.md, narrative/customer-journey.md
└── 06-Operations/
└── SOPs/ ← narrative/operations.md
Running the Sync
FULL PIPELINE (all sources):
cd C:\dev\knowledge && pnpm derive --all
SINGLE SOURCE:
cd C:\dev\knowledge && pnpm derive narrative/vision.md
DRY RUN (preview only):
cd C:\dev\knowledge && pnpm derive data/pricing.yaml --dry-run
DRIFT CHECK (CI gate):
cd C:\dev\knowledge && pnpm derive --check
EXIT 0 = clean, EXIT 1 = drift detected
The derive pipeline also handles non-gdrive targets (regenerate pricing.ts, verify marketing pages, upsert product_knowledge), but those are documented in processes/system/derive-pipeline.md.