stellavault 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +12 -0
- package/CLAUDE.md +39 -0
- package/CONTRIBUTING.md +65 -0
- package/LICENSE +21 -0
- package/README.md +182 -0
- package/memory/MEMORY.md +25 -0
- package/package.json +33 -0
- package/packages/cli/bin/ekh.js +2 -0
- package/packages/cli/bin/stellavault.js +2 -0
- package/packages/cli/dist/commands/brief-cmd.d.ts +2 -0
- package/packages/cli/dist/commands/brief-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/brief-cmd.js +82 -0
- package/packages/cli/dist/commands/brief-cmd.js.map +1 -0
- package/packages/cli/dist/commands/capture-cmd.d.ts +7 -0
- package/packages/cli/dist/commands/capture-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/capture-cmd.js +31 -0
- package/packages/cli/dist/commands/capture-cmd.js.map +1 -0
- package/packages/cli/dist/commands/card-cmd.d.ts +4 -0
- package/packages/cli/dist/commands/card-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/card-cmd.js +26 -0
- package/packages/cli/dist/commands/card-cmd.js.map +1 -0
- package/packages/cli/dist/commands/clip-cmd.d.ts +4 -0
- package/packages/cli/dist/commands/clip-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/clip-cmd.js +151 -0
- package/packages/cli/dist/commands/clip-cmd.js.map +1 -0
- package/packages/cli/dist/commands/cloud-cmd.d.ts +4 -0
- package/packages/cli/dist/commands/cloud-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/cloud-cmd.js +64 -0
- package/packages/cli/dist/commands/cloud-cmd.js.map +1 -0
- package/packages/cli/dist/commands/contradictions-cmd.d.ts +2 -0
- package/packages/cli/dist/commands/contradictions-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/contradictions-cmd.js +34 -0
- package/packages/cli/dist/commands/contradictions-cmd.js.map +1 -0
- package/packages/cli/dist/commands/decay-cmd.d.ts +2 -0
- package/packages/cli/dist/commands/decay-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/decay-cmd.js +48 -0
- package/packages/cli/dist/commands/decay-cmd.js.map +1 -0
- package/packages/cli/dist/commands/digest-cmd.d.ts +4 -0
- package/packages/cli/dist/commands/digest-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/digest-cmd.js +79 -0
- package/packages/cli/dist/commands/digest-cmd.js.map +1 -0
- package/packages/cli/dist/commands/duplicates-cmd.d.ts +4 -0
- package/packages/cli/dist/commands/duplicates-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/duplicates-cmd.js +30 -0
- package/packages/cli/dist/commands/duplicates-cmd.js.map +1 -0
- package/packages/cli/dist/commands/federate-cmd.d.ts +5 -0
- package/packages/cli/dist/commands/federate-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/federate-cmd.js +217 -0
- package/packages/cli/dist/commands/federate-cmd.js.map +1 -0
- package/packages/cli/dist/commands/gaps-cmd.d.ts +2 -0
- package/packages/cli/dist/commands/gaps-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/gaps-cmd.js +33 -0
- package/packages/cli/dist/commands/gaps-cmd.js.map +1 -0
- package/packages/cli/dist/commands/graph-cmd.d.ts +2 -0
- package/packages/cli/dist/commands/graph-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/graph-cmd.js +77 -0
- package/packages/cli/dist/commands/graph-cmd.js.map +1 -0
- package/packages/cli/dist/commands/index-cmd.d.ts +2 -0
- package/packages/cli/dist/commands/index-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/index-cmd.js +57 -0
- package/packages/cli/dist/commands/index-cmd.js.map +1 -0
- package/packages/cli/dist/commands/init-cmd.d.ts +2 -0
- package/packages/cli/dist/commands/init-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/init-cmd.js +123 -0
- package/packages/cli/dist/commands/init-cmd.js.map +1 -0
- package/packages/cli/dist/commands/learn-cmd.d.ts +2 -0
- package/packages/cli/dist/commands/learn-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/learn-cmd.js +48 -0
- package/packages/cli/dist/commands/learn-cmd.js.map +1 -0
- package/packages/cli/dist/commands/pack-cmd.d.ts +15 -0
- package/packages/cli/dist/commands/pack-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/pack-cmd.js +93 -0
- package/packages/cli/dist/commands/pack-cmd.js.map +1 -0
- package/packages/cli/dist/commands/review-cmd.d.ts +4 -0
- package/packages/cli/dist/commands/review-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/review-cmd.js +107 -0
- package/packages/cli/dist/commands/review-cmd.js.map +1 -0
- package/packages/cli/dist/commands/search-cmd.d.ts +4 -0
- package/packages/cli/dist/commands/search-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/search-cmd.js +38 -0
- package/packages/cli/dist/commands/search-cmd.js.map +1 -0
- package/packages/cli/dist/commands/serve-cmd.d.ts +2 -0
- package/packages/cli/dist/commands/serve-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/serve-cmd.js +14 -0
- package/packages/cli/dist/commands/serve-cmd.js.map +1 -0
- package/packages/cli/dist/commands/status-cmd.d.ts +2 -0
- package/packages/cli/dist/commands/status-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/status-cmd.js +33 -0
- package/packages/cli/dist/commands/status-cmd.js.map +1 -0
- package/packages/cli/dist/commands/sync-cmd.d.ts +5 -0
- package/packages/cli/dist/commands/sync-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/sync-cmd.js +62 -0
- package/packages/cli/dist/commands/sync-cmd.js.map +1 -0
- package/packages/cli/dist/commands/vault-cmd.d.ts +10 -0
- package/packages/cli/dist/commands/vault-cmd.d.ts.map +1 -0
- package/packages/cli/dist/commands/vault-cmd.js +54 -0
- package/packages/cli/dist/commands/vault-cmd.js.map +1 -0
- package/packages/cli/dist/index.d.ts +2 -0
- package/packages/cli/dist/index.d.ts.map +1 -0
- package/packages/cli/dist/index.js +156 -0
- package/packages/cli/dist/index.js.map +1 -0
- package/packages/cli/package.json +24 -0
- package/packages/cli/src/commands/brief-cmd.ts +87 -0
- package/packages/cli/src/commands/capture-cmd.ts +34 -0
- package/packages/cli/src/commands/card-cmd.ts +29 -0
- package/packages/cli/src/commands/clip-cmd.ts +172 -0
- package/packages/cli/src/commands/cloud-cmd.ts +75 -0
- package/packages/cli/src/commands/contradictions-cmd.ts +41 -0
- package/packages/cli/src/commands/decay-cmd.ts +57 -0
- package/packages/cli/src/commands/digest-cmd.ts +89 -0
- package/packages/cli/src/commands/duplicates-cmd.ts +38 -0
- package/packages/cli/src/commands/federate-cmd.ts +236 -0
- package/packages/cli/src/commands/gaps-cmd.ts +40 -0
- package/packages/cli/src/commands/graph-cmd.ts +88 -0
- package/packages/cli/src/commands/index-cmd.ts +65 -0
- package/packages/cli/src/commands/init-cmd.ts +145 -0
- package/packages/cli/src/commands/learn-cmd.ts +56 -0
- package/packages/cli/src/commands/pack-cmd.ts +121 -0
- package/packages/cli/src/commands/review-cmd.ts +125 -0
- package/packages/cli/src/commands/search-cmd.ts +45 -0
- package/packages/cli/src/commands/serve-cmd.ts +17 -0
- package/packages/cli/src/commands/status-cmd.ts +37 -0
- package/packages/cli/src/commands/sync-cmd.ts +68 -0
- package/packages/cli/src/commands/vault-cmd.ts +64 -0
- package/packages/cli/src/index.ts +187 -0
- package/packages/core/package.json +40 -0
- package/packages/core/src/api/dashboard.ts +138 -0
- package/packages/core/src/api/graph-data.ts +286 -0
- package/packages/core/src/api/pwa.ts +82 -0
- package/packages/core/src/api/server.ts +660 -0
- package/packages/core/src/capture/voice.ts +168 -0
- package/packages/core/src/cloud/index.ts +2 -0
- package/packages/core/src/cloud/sync.ts +167 -0
- package/packages/core/src/config.ts +82 -0
- package/packages/core/src/federation/credits.ts +80 -0
- package/packages/core/src/federation/hyperswarm.d.ts +19 -0
- package/packages/core/src/federation/identity.ts +90 -0
- package/packages/core/src/federation/index.ts +8 -0
- package/packages/core/src/federation/node.ts +235 -0
- package/packages/core/src/federation/privacy.ts +52 -0
- package/packages/core/src/federation/reputation.ts +202 -0
- package/packages/core/src/federation/search.ts +129 -0
- package/packages/core/src/federation/sharing.ts +165 -0
- package/packages/core/src/federation/trust.ts +76 -0
- package/packages/core/src/federation/types.ts +25 -0
- package/packages/core/src/i18n/index.ts +85 -0
- package/packages/core/src/index.ts +133 -0
- package/packages/core/src/indexer/chunker.ts +180 -0
- package/packages/core/src/indexer/embedder.ts +9 -0
- package/packages/core/src/indexer/index.ts +113 -0
- package/packages/core/src/indexer/local-embedder.ts +35 -0
- package/packages/core/src/indexer/scanner.ts +142 -0
- package/packages/core/src/indexer/watcher.ts +62 -0
- package/packages/core/src/intelligence/contradiction-detector.ts +134 -0
- package/packages/core/src/intelligence/decay-engine.ts +229 -0
- package/packages/core/src/intelligence/duplicate-detector.ts +71 -0
- package/packages/core/src/intelligence/fsrs.ts +79 -0
- package/packages/core/src/intelligence/gap-detector.ts +109 -0
- package/packages/core/src/intelligence/learning-path.ts +86 -0
- package/packages/core/src/intelligence/notifications.ts +106 -0
- package/packages/core/src/intelligence/predictive-gaps.ts +94 -0
- package/packages/core/src/intelligence/semantic-versioning.ts +97 -0
- package/packages/core/src/intelligence/types.ts +28 -0
- package/packages/core/src/mcp/custom-tools.ts +97 -0
- package/packages/core/src/mcp/index.ts +1 -0
- package/packages/core/src/mcp/server.ts +142 -0
- package/packages/core/src/mcp/tools/agentic-graph.ts +96 -0
- package/packages/core/src/mcp/tools/brief.ts +49 -0
- package/packages/core/src/mcp/tools/decay.ts +40 -0
- package/packages/core/src/mcp/tools/decision-journal.ts +95 -0
- package/packages/core/src/mcp/tools/export.ts +72 -0
- package/packages/core/src/mcp/tools/federated-search.ts +43 -0
- package/packages/core/src/mcp/tools/generate-claude-md.ts +130 -0
- package/packages/core/src/mcp/tools/get-document.ts +26 -0
- package/packages/core/src/mcp/tools/get-related.ts +41 -0
- package/packages/core/src/mcp/tools/learning-path.ts +52 -0
- package/packages/core/src/mcp/tools/list-topics.ts +20 -0
- package/packages/core/src/mcp/tools/search.ts +35 -0
- package/packages/core/src/mcp/tools/snapshot.ts +98 -0
- package/packages/core/src/multi-vault/index.ts +118 -0
- package/packages/core/src/pack/creator.ts +127 -0
- package/packages/core/src/pack/exporter.ts +21 -0
- package/packages/core/src/pack/importer.ts +82 -0
- package/packages/core/src/pack/index.ts +5 -0
- package/packages/core/src/pack/marketplace.ts +103 -0
- package/packages/core/src/pack/pii-masker.ts +38 -0
- package/packages/core/src/pack/types.ts +39 -0
- package/packages/core/src/plugins/index.ts +100 -0
- package/packages/core/src/plugins/webhooks.ts +110 -0
- package/packages/core/src/search/bm25.ts +16 -0
- package/packages/core/src/search/index.ts +83 -0
- package/packages/core/src/search/rrf.ts +31 -0
- package/packages/core/src/search/semantic.ts +15 -0
- package/packages/core/src/store/index.ts +2 -0
- package/packages/core/src/store/sqlite-vec.ts +290 -0
- package/packages/core/src/store/types.ts +22 -0
- package/packages/core/src/team/index.ts +126 -0
- package/packages/core/src/types/chunk.ts +25 -0
- package/packages/core/src/types/document.ts +24 -0
- package/packages/core/src/types/graph.ts +44 -0
- package/packages/core/src/types/index.ts +15 -0
- package/packages/core/src/types/search.ts +38 -0
- package/packages/core/src/utils/retry.ts +85 -0
- package/packages/core/tests/api-card.test.ts +60 -0
- package/packages/core/tests/api-routes.test.ts +98 -0
- package/packages/core/tests/bm25.test.ts +87 -0
- package/packages/core/tests/chunker.test.ts +48 -0
- package/packages/core/tests/cluster.test.ts +75 -0
- package/packages/core/tests/constellation.test.ts +77 -0
- package/packages/core/tests/export-utils.test.ts +97 -0
- package/packages/core/tests/fsrs.test.ts +96 -0
- package/packages/core/tests/gesture-detector.test.ts +45 -0
- package/packages/core/tests/graph-data.test.ts +87 -0
- package/packages/core/tests/layout.test.ts +83 -0
- package/packages/core/tests/mcp.test.ts +148 -0
- package/packages/core/tests/pack.test.ts +127 -0
- package/packages/core/tests/pii-masker.test.ts +42 -0
- package/packages/core/tests/profile-card.test.ts +62 -0
- package/packages/core/tests/rrf.test.ts +29 -0
- package/packages/core/tests/search-integration.test.ts +139 -0
- package/packages/core/tests/store.test.ts +80 -0
- package/packages/graph/click-result.png +0 -0
- package/packages/graph/index.html +17 -0
- package/packages/graph/package.json +32 -0
- package/packages/graph/src/App.tsx +7 -0
- package/packages/graph/src/api/client.ts +39 -0
- package/packages/graph/src/components/ClusterFilter.tsx +73 -0
- package/packages/graph/src/components/ConstellationView.tsx +232 -0
- package/packages/graph/src/components/ExportPanel.tsx +177 -0
- package/packages/graph/src/components/Graph3D.tsx +230 -0
- package/packages/graph/src/components/GraphEdges.tsx +100 -0
- package/packages/graph/src/components/GraphNodes.tsx +386 -0
- package/packages/graph/src/components/HealthDashboard.tsx +173 -0
- package/packages/graph/src/components/Layout.tsx +214 -0
- package/packages/graph/src/components/MotionOverlay.tsx +81 -0
- package/packages/graph/src/components/MotionToggle.tsx +33 -0
- package/packages/graph/src/components/MultiverseView.tsx +286 -0
- package/packages/graph/src/components/NodeDetail.tsx +232 -0
- package/packages/graph/src/components/PulseParticle.tsx +232 -0
- package/packages/graph/src/components/SearchBar.tsx +107 -0
- package/packages/graph/src/components/StarField.tsx +197 -0
- package/packages/graph/src/components/StatusBar.tsx +53 -0
- package/packages/graph/src/components/Timeline.tsx +148 -0
- package/packages/graph/src/components/ToolsPanel.tsx +512 -0
- package/packages/graph/src/components/Tooltip.tsx +100 -0
- package/packages/graph/src/components/TypeFilter.tsx +131 -0
- package/packages/graph/src/embed/EmbedGraph.tsx +144 -0
- package/packages/graph/src/hooks/useConstellationLOD.ts +76 -0
- package/packages/graph/src/hooks/useDecay.ts +37 -0
- package/packages/graph/src/hooks/useExport.ts +165 -0
- package/packages/graph/src/hooks/useGraph.ts +69 -0
- package/packages/graph/src/hooks/useKeyboardNav.ts +122 -0
- package/packages/graph/src/hooks/useLayout.ts +45 -0
- package/packages/graph/src/hooks/useMotion.ts +120 -0
- package/packages/graph/src/hooks/usePulse.ts +58 -0
- package/packages/graph/src/hooks/useSearch.ts +71 -0
- package/packages/graph/src/lib/constellation.ts +107 -0
- package/packages/graph/src/lib/export-utils.ts +48 -0
- package/packages/graph/src/lib/gesture-detector.ts +123 -0
- package/packages/graph/src/lib/layout.worker.ts +153 -0
- package/packages/graph/src/lib/motion-controller.ts +83 -0
- package/packages/graph/src/lib/profile-card.ts +122 -0
- package/packages/graph/src/main.tsx +4 -0
- package/packages/graph/src/stores/graph-store.ts +155 -0
- package/packages/graph/success.png +0 -0
- package/packages/graph/test-click.mjs +49 -0
- package/packages/graph/test-explore.mjs +102 -0
- package/packages/graph/test-final.mjs +61 -0
- package/packages/graph/test-graph.mjs +139 -0
- package/packages/graph/test-hover.mjs +48 -0
- package/packages/graph/test-pulse.mjs +68 -0
- package/packages/graph/test-screenshot.mjs +56 -0
- package/packages/graph/test-v2.mjs +97 -0
- package/packages/graph/vite.config.ts +15 -0
- package/packages/sync/.env.example +11 -0
- package/packages/sync/.sync-state.json +317 -0
- package/packages/sync/.upload-state.json +1009 -0
- package/packages/sync/create-stella-network-notion.mjs +151 -0
- package/packages/sync/create-stellavault-project-notion.mjs +322 -0
- package/packages/sync/logs/sync-2026-03-28.log +6 -0
- package/packages/sync/logs/sync-2026-03-29.log +12 -0
- package/packages/sync/logs/sync-2026-03-30.log +6 -0
- package/packages/sync/logs/sync-2026-03-31.log +6 -0
- package/packages/sync/logs/sync-2026-04-01.log +6 -0
- package/packages/sync/logs/sync-2026-04-02.log +6 -0
- package/packages/sync/package-lock.json +373 -0
- package/packages/sync/package.json +16 -0
- package/packages/sync/run-sync.bat +18 -0
- package/packages/sync/run-sync.mjs +46 -0
- package/packages/sync/setup-scheduler.mjs +119 -0
- package/packages/sync/structured-sync.mjs +187 -0
- package/packages/sync/sync-to-obsidian.mjs +264 -0
- package/packages/sync/upload-pdca-to-notion.mjs +495 -0
- package/tsconfig.base.json +18 -0
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 로컬 PDCA 문서 → 노션 자동 업로드 스크립트
|
|
3
|
+
*
|
|
4
|
+
* 기능:
|
|
5
|
+
* - 각 프로젝트의 docs/ 폴더를 스캔
|
|
6
|
+
* - .md 파일을 Notion API로 업로드
|
|
7
|
+
* - 프로젝트별 "📄 PDCA 원본" 하위 페이지에 정리
|
|
8
|
+
* - 이미 업로드된 문서는 파일 수정일 비교 후 변경 시 업데이트
|
|
9
|
+
* - 업로드 상태를 .upload-state.json에 저장 (증분 업로드)
|
|
10
|
+
*
|
|
11
|
+
* 사용법: node upload-pdca-to-notion.mjs
|
|
12
|
+
* 환경변수: .env 파일 참조
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Client } from '@notionhq/client';
|
|
16
|
+
import fs from 'fs';
|
|
17
|
+
import path from 'path';
|
|
18
|
+
import { fileURLToPath } from 'url';
|
|
19
|
+
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = path.dirname(__filename);
|
|
22
|
+
|
|
23
|
+
// ─── 환경변수 로드 ───
|
|
24
|
+
function loadEnv() {
|
|
25
|
+
const envPath = path.join(__dirname, '.env');
|
|
26
|
+
if (!fs.existsSync(envPath)) {
|
|
27
|
+
console.error('❌ .env 파일이 없습니다. .env.example을 복사하여 .env를 만들어주세요.');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
const lines = fs.readFileSync(envPath, 'utf-8').split('\n');
|
|
31
|
+
for (const line of lines) {
|
|
32
|
+
const trimmed = line.trim();
|
|
33
|
+
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
34
|
+
const eqIdx = trimmed.indexOf('=');
|
|
35
|
+
if (eqIdx === -1) continue;
|
|
36
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
37
|
+
const value = trimmed.slice(eqIdx + 1).trim();
|
|
38
|
+
if (!process.env[key]) process.env[key] = value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
loadEnv();
|
|
42
|
+
|
|
43
|
+
// ─── 설정 ───
|
|
44
|
+
const NOTION_API_KEY = process.env.NOTION_API_KEY;
|
|
45
|
+
const ROOT_PAGE_ID = process.env.NOTION_ROOT_PAGE_ID;
|
|
46
|
+
const PROJECT_PATHS = (process.env.PROJECT_PATHS || '').split(',').map(p => p.trim()).filter(Boolean);
|
|
47
|
+
const STATE_FILE = path.join(__dirname, '.upload-state.json');
|
|
48
|
+
|
|
49
|
+
if (!NOTION_API_KEY || !ROOT_PAGE_ID) {
|
|
50
|
+
console.error('❌ NOTION_API_KEY와 NOTION_ROOT_PAGE_ID가 필요합니다.');
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
if (PROJECT_PATHS.length === 0) {
|
|
54
|
+
console.error('❌ PROJECT_PATHS가 설정되지 않았습니다.');
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const notion = new Client({ auth: NOTION_API_KEY });
|
|
59
|
+
|
|
60
|
+
// ─── 업로드 상태 관리 (증분 업로드용) ───
|
|
61
|
+
function loadUploadState() {
|
|
62
|
+
if (fs.existsSync(STATE_FILE)) {
|
|
63
|
+
return JSON.parse(fs.readFileSync(STATE_FILE, 'utf-8'));
|
|
64
|
+
}
|
|
65
|
+
return { lastUpload: null, files: {} };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function saveUploadState(state) {
|
|
69
|
+
state.lastUpload = new Date().toISOString();
|
|
70
|
+
fs.writeFileSync(STATE_FILE, JSON.stringify(state, null, 2), 'utf-8');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ─── 프로젝트 이름 → 노션 페이지 매핑 ───
|
|
74
|
+
const PROJECT_NAME_MAP = {
|
|
75
|
+
'ai_destiny': 'AI Destiny',
|
|
76
|
+
'project-manager': 'Project Manager',
|
|
77
|
+
'stock_analist_beta': 'Stokova',
|
|
78
|
+
'stock-autotrade': 'Quantrism',
|
|
79
|
+
'vibevonweb': 'Vibevonweb',
|
|
80
|
+
'TEST': '클로드 코드 마스터 가이드',
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// PDCA 폴더 구조 → 노션 카테고리 매핑
|
|
84
|
+
const PHASE_MAP = {
|
|
85
|
+
'00-pm': '📋 PM 분석',
|
|
86
|
+
'01-plan': '📝 Plan (계획)',
|
|
87
|
+
'02-design': '📐 Design (설계)',
|
|
88
|
+
'03-analysis': '🔍 Analysis (검증)',
|
|
89
|
+
'04-report': '📊 Report (보고)',
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// ─── 노션에서 프로젝트 하위 페이지 ID 찾기 ───
|
|
93
|
+
async function findProjectPages(rootPageId) {
|
|
94
|
+
const pageMap = {};
|
|
95
|
+
let cursor = undefined;
|
|
96
|
+
|
|
97
|
+
while (true) {
|
|
98
|
+
const response = await notion.blocks.children.list({
|
|
99
|
+
block_id: rootPageId,
|
|
100
|
+
start_cursor: cursor,
|
|
101
|
+
page_size: 100,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
for (const block of response.results) {
|
|
105
|
+
if (block.type === 'child_page') {
|
|
106
|
+
pageMap[block.child_page.title] = block.id;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!response.has_more) break;
|
|
111
|
+
cursor = response.next_cursor;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return pageMap;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ─── "PDCA 원본" 컨테이너 페이지 찾기 또는 생성 ───
|
|
118
|
+
async function findOrCreateContainer(parentPageId, title) {
|
|
119
|
+
let cursor = undefined;
|
|
120
|
+
while (true) {
|
|
121
|
+
const response = await notion.blocks.children.list({
|
|
122
|
+
block_id: parentPageId,
|
|
123
|
+
start_cursor: cursor,
|
|
124
|
+
page_size: 100,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
for (const block of response.results) {
|
|
128
|
+
if (block.type === 'child_page' && block.child_page.title === title) {
|
|
129
|
+
return block.id;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (!response.has_more) break;
|
|
134
|
+
cursor = response.next_cursor;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 없으면 생성
|
|
138
|
+
const page = await notion.pages.create({
|
|
139
|
+
parent: { page_id: parentPageId },
|
|
140
|
+
icon: { emoji: '📂' },
|
|
141
|
+
properties: {
|
|
142
|
+
title: [{ text: { content: title } }],
|
|
143
|
+
},
|
|
144
|
+
children: [
|
|
145
|
+
{
|
|
146
|
+
object: 'block',
|
|
147
|
+
type: 'callout',
|
|
148
|
+
callout: {
|
|
149
|
+
icon: { emoji: '📄' },
|
|
150
|
+
color: 'blue_background',
|
|
151
|
+
rich_text: [{ text: { content: `${title} — 로컬 PDCA 문서 원본이 자동 업로드됩니다.` } }],
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
return page.id;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ─── Phase 컨테이너 찾기 또는 생성 ───
|
|
161
|
+
async function findOrCreatePhaseContainer(parentPageId, phaseDir) {
|
|
162
|
+
const phaseName = PHASE_MAP[phaseDir] || phaseDir;
|
|
163
|
+
return findOrCreateContainer(parentPageId, phaseName);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ─── 마크다운을 Notion 블록으로 변환 ───
|
|
167
|
+
function markdownToNotionBlocks(markdown, fileName) {
|
|
168
|
+
const blocks = [];
|
|
169
|
+
|
|
170
|
+
// 파일 정보 callout
|
|
171
|
+
blocks.push({
|
|
172
|
+
object: 'block',
|
|
173
|
+
type: 'callout',
|
|
174
|
+
callout: {
|
|
175
|
+
icon: { emoji: '📄' },
|
|
176
|
+
color: 'gray_background',
|
|
177
|
+
rich_text: [{ text: { content: `원본 파일: ${fileName}\n마지막 업로드: ${new Date().toISOString().slice(0, 10)}` } }],
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// 구분선
|
|
182
|
+
blocks.push({ object: 'block', type: 'divider', divider: {} });
|
|
183
|
+
|
|
184
|
+
// 마크다운 내용을 2000자 단위로 분할 (Notion API rich_text 제한)
|
|
185
|
+
const MAX_LEN = 2000;
|
|
186
|
+
const chunks = [];
|
|
187
|
+
let remaining = markdown;
|
|
188
|
+
|
|
189
|
+
while (remaining.length > 0) {
|
|
190
|
+
if (remaining.length <= MAX_LEN) {
|
|
191
|
+
chunks.push(remaining);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
let splitIdx = remaining.lastIndexOf('\n', MAX_LEN);
|
|
195
|
+
if (splitIdx === -1 || splitIdx < MAX_LEN * 0.5) splitIdx = MAX_LEN;
|
|
196
|
+
chunks.push(remaining.slice(0, splitIdx));
|
|
197
|
+
remaining = remaining.slice(splitIdx);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
for (const chunk of chunks) {
|
|
201
|
+
blocks.push({
|
|
202
|
+
object: 'block',
|
|
203
|
+
type: 'code',
|
|
204
|
+
code: {
|
|
205
|
+
language: 'markdown',
|
|
206
|
+
rich_text: [{ text: { content: chunk } }],
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return blocks;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// ─── 기존 페이지 찾기 (ID 반환, 없으면 null) ───
|
|
215
|
+
async function findExistingPage(parentPageId, title) {
|
|
216
|
+
let cursor = undefined;
|
|
217
|
+
while (true) {
|
|
218
|
+
const response = await notion.blocks.children.list({
|
|
219
|
+
block_id: parentPageId,
|
|
220
|
+
start_cursor: cursor,
|
|
221
|
+
page_size: 100,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
for (const block of response.results) {
|
|
225
|
+
if (block.type === 'child_page' && block.child_page.title === title) {
|
|
226
|
+
return block.id;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (!response.has_more) break;
|
|
231
|
+
cursor = response.next_cursor;
|
|
232
|
+
}
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// ─── 기존 페이지의 모든 블록 삭제 ───
|
|
237
|
+
async function clearPageContent(pageId) {
|
|
238
|
+
let cursor = undefined;
|
|
239
|
+
const blockIds = [];
|
|
240
|
+
|
|
241
|
+
while (true) {
|
|
242
|
+
const response = await notion.blocks.children.list({
|
|
243
|
+
block_id: pageId,
|
|
244
|
+
start_cursor: cursor,
|
|
245
|
+
page_size: 100,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
for (const block of response.results) {
|
|
249
|
+
blockIds.push(block.id);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!response.has_more) break;
|
|
253
|
+
cursor = response.next_cursor;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 각 블록 삭제
|
|
257
|
+
for (const blockId of blockIds) {
|
|
258
|
+
try {
|
|
259
|
+
await notion.blocks.delete({ block_id: blockId });
|
|
260
|
+
await new Promise(r => setTimeout(r, 400));
|
|
261
|
+
} catch {
|
|
262
|
+
// 이미 삭제된 블록은 무시
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// ─── API 호출 재시도 래퍼 (rate limit 대응) ───
|
|
268
|
+
async function withRetry(fn, maxRetries = 3) {
|
|
269
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
270
|
+
try {
|
|
271
|
+
return await fn();
|
|
272
|
+
} catch (err) {
|
|
273
|
+
if (err.status === 429 && attempt < maxRetries) {
|
|
274
|
+
const waitSec = Math.pow(2, attempt) * 2;
|
|
275
|
+
console.log(` ⏳ Rate limit — ${waitSec}초 대기 후 재시도 (${attempt}/${maxRetries})`);
|
|
276
|
+
await new Promise(r => setTimeout(r, waitSec * 1000));
|
|
277
|
+
} else if (attempt < maxRetries && err.status >= 500) {
|
|
278
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
279
|
+
} else {
|
|
280
|
+
throw err;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// ─── 단일 문서 업로드 또는 업데이트 ───
|
|
287
|
+
async function uploadDocument(parentPageId, filePath, fileName, state) {
|
|
288
|
+
const title = fileName.replace(/\.md$/, '');
|
|
289
|
+
const fileStat = fs.statSync(filePath);
|
|
290
|
+
const fileModified = fileStat.mtimeMs;
|
|
291
|
+
const stateKey = filePath.replace(/\\/g, '/');
|
|
292
|
+
|
|
293
|
+
// 파일 수정일 비교 — 변경 없으면 스킵
|
|
294
|
+
if (state.files[stateKey] && state.files[stateKey].modified >= fileModified) {
|
|
295
|
+
return 'skip';
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const markdown = fs.readFileSync(filePath, 'utf-8');
|
|
299
|
+
const blocks = markdownToNotionBlocks(markdown, fileName);
|
|
300
|
+
|
|
301
|
+
const existingPageId = await findExistingPage(parentPageId, title);
|
|
302
|
+
|
|
303
|
+
if (existingPageId) {
|
|
304
|
+
// 기존 페이지 업데이트: 내용 삭제 후 다시 추가
|
|
305
|
+
await clearPageContent(existingPageId);
|
|
306
|
+
await new Promise(r => setTimeout(r, 500));
|
|
307
|
+
|
|
308
|
+
// 블록 추가 (100개 단위, 재시도 포함)
|
|
309
|
+
for (let i = 0; i < blocks.length; i += 100) {
|
|
310
|
+
const batch = blocks.slice(i, i + 100);
|
|
311
|
+
await withRetry(() => notion.blocks.children.append({
|
|
312
|
+
block_id: existingPageId,
|
|
313
|
+
children: batch,
|
|
314
|
+
}));
|
|
315
|
+
await new Promise(r => setTimeout(r, 500));
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// 상태 저장
|
|
319
|
+
state.files[stateKey] = { modified: fileModified, pageId: existingPageId };
|
|
320
|
+
return 'updated';
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// 새 페이지 생성
|
|
324
|
+
const firstBatch = blocks.slice(0, 100);
|
|
325
|
+
const page = await withRetry(() => notion.pages.create({
|
|
326
|
+
parent: { page_id: parentPageId },
|
|
327
|
+
icon: { emoji: '📄' },
|
|
328
|
+
properties: {
|
|
329
|
+
title: [{ text: { content: title } }],
|
|
330
|
+
},
|
|
331
|
+
children: firstBatch,
|
|
332
|
+
}));
|
|
333
|
+
|
|
334
|
+
// 나머지 블록 추가
|
|
335
|
+
for (let i = 100; i < blocks.length; i += 100) {
|
|
336
|
+
const batch = blocks.slice(i, i + 100);
|
|
337
|
+
await withRetry(() => notion.blocks.children.append({
|
|
338
|
+
block_id: page.id,
|
|
339
|
+
children: batch,
|
|
340
|
+
}));
|
|
341
|
+
await new Promise(r => setTimeout(r, 500));
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// 상태 저장
|
|
345
|
+
state.files[stateKey] = { modified: fileModified, pageId: page.id };
|
|
346
|
+
return 'uploaded';
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// ─── 프로젝트 하나 처리 ───
|
|
350
|
+
async function processProject(projectPath, projectPageId, state) {
|
|
351
|
+
const docsDir = path.join(projectPath, 'docs');
|
|
352
|
+
|
|
353
|
+
if (!fs.existsSync(docsDir)) {
|
|
354
|
+
console.log(` ⚠️ docs/ 폴더 없음 — 스킵`);
|
|
355
|
+
return { uploaded: 0, updated: 0, skipped: 0 };
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// "PDCA 원본" 컨테이너 찾기/생성
|
|
359
|
+
const containerPageId = await findOrCreateContainer(projectPageId, '📄 PDCA 원본');
|
|
360
|
+
await new Promise(r => setTimeout(r, 500));
|
|
361
|
+
|
|
362
|
+
let uploaded = 0;
|
|
363
|
+
let updated = 0;
|
|
364
|
+
let skipped = 0;
|
|
365
|
+
|
|
366
|
+
// docs/ 하위 디렉토리 순회
|
|
367
|
+
const entries = fs.readdirSync(docsDir, { withFileTypes: true });
|
|
368
|
+
|
|
369
|
+
for (const entry of entries) {
|
|
370
|
+
if (!entry.isDirectory()) {
|
|
371
|
+
// docs/ 루트의 .md 파일
|
|
372
|
+
if (entry.name.endsWith('.md')) {
|
|
373
|
+
const filePath = path.join(docsDir, entry.name);
|
|
374
|
+
const result = await uploadDocument(containerPageId, filePath, entry.name, state);
|
|
375
|
+
if (result === 'uploaded') { console.log(` ✅ ${entry.name}`); uploaded++; }
|
|
376
|
+
else if (result === 'updated') { console.log(` 🔄 ${entry.name}`); updated++; }
|
|
377
|
+
else { skipped++; }
|
|
378
|
+
await new Promise(r => setTimeout(r, 500));
|
|
379
|
+
}
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Phase 디렉토리 (01-plan, 02-design, etc.)
|
|
384
|
+
const phaseDir = entry.name;
|
|
385
|
+
if (!PHASE_MAP[phaseDir] && phaseDir === 'archive') continue;
|
|
386
|
+
|
|
387
|
+
const phaseDirPath = path.join(docsDir, phaseDir);
|
|
388
|
+
const phasePageId = await findOrCreatePhaseContainer(containerPageId, phaseDir);
|
|
389
|
+
await new Promise(r => setTimeout(r, 500));
|
|
390
|
+
|
|
391
|
+
// Phase 디렉토리 내 파일/폴더 순회
|
|
392
|
+
const phaseEntries = fs.readdirSync(phaseDirPath, { withFileTypes: true });
|
|
393
|
+
|
|
394
|
+
for (const phaseEntry of phaseEntries) {
|
|
395
|
+
if (phaseEntry.isFile() && phaseEntry.name.endsWith('.md')) {
|
|
396
|
+
const filePath = path.join(phaseDirPath, phaseEntry.name);
|
|
397
|
+
const result = await uploadDocument(phasePageId, filePath, phaseEntry.name, state);
|
|
398
|
+
if (result === 'uploaded') { console.log(` ✅ ${phaseDir}/${phaseEntry.name}`); uploaded++; }
|
|
399
|
+
else if (result === 'updated') { console.log(` 🔄 ${phaseDir}/${phaseEntry.name}`); updated++; }
|
|
400
|
+
else { skipped++; }
|
|
401
|
+
await new Promise(r => setTimeout(r, 500));
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// features/ 하위 디렉토리
|
|
405
|
+
if (phaseEntry.isDirectory() && phaseEntry.name === 'features') {
|
|
406
|
+
const featuresDir = path.join(phaseDirPath, 'features');
|
|
407
|
+
const featureFiles = fs.readdirSync(featuresDir).filter(f => f.endsWith('.md'));
|
|
408
|
+
|
|
409
|
+
for (const featureFile of featureFiles) {
|
|
410
|
+
const filePath = path.join(featuresDir, featureFile);
|
|
411
|
+
const result = await uploadDocument(phasePageId, filePath, featureFile, state);
|
|
412
|
+
if (result === 'uploaded') { console.log(` ✅ ${phaseDir}/features/${featureFile}`); uploaded++; }
|
|
413
|
+
else if (result === 'updated') { console.log(` 🔄 ${phaseDir}/features/${featureFile}`); updated++; }
|
|
414
|
+
else { skipped++; }
|
|
415
|
+
await new Promise(r => setTimeout(r, 500));
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return { uploaded, updated, skipped };
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// ─── 메인 실행 ───
|
|
425
|
+
async function main() {
|
|
426
|
+
console.log('');
|
|
427
|
+
console.log('╔══════════════════════════════════════════════╗');
|
|
428
|
+
console.log('║ 📤 로컬 PDCA → 노션 업로드 시작 ║');
|
|
429
|
+
console.log('╚══════════════════════════════════════════════╝');
|
|
430
|
+
console.log('');
|
|
431
|
+
|
|
432
|
+
// 상태 로드
|
|
433
|
+
const state = loadUploadState();
|
|
434
|
+
if (state.lastUpload) {
|
|
435
|
+
console.log(`🕐 마지막 업로드: ${state.lastUpload}`);
|
|
436
|
+
} else {
|
|
437
|
+
console.log('🆕 첫 업로드 실행');
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// 프로젝트 페이지 매핑
|
|
441
|
+
console.log('🔍 노션 프로젝트 페이지 검색 중...');
|
|
442
|
+
const projectPages = await findProjectPages(ROOT_PAGE_ID);
|
|
443
|
+
console.log(` ${Object.keys(projectPages).length}개 프로젝트 발견\n`);
|
|
444
|
+
|
|
445
|
+
let totalUploaded = 0;
|
|
446
|
+
let totalUpdated = 0;
|
|
447
|
+
let totalSkipped = 0;
|
|
448
|
+
|
|
449
|
+
for (const projectPath of PROJECT_PATHS) {
|
|
450
|
+
const dirName = path.basename(projectPath);
|
|
451
|
+
const searchName = PROJECT_NAME_MAP[dirName];
|
|
452
|
+
|
|
453
|
+
if (!searchName) {
|
|
454
|
+
console.log(`⚠️ ${dirName} — 매핑 없음, 스킵`);
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
const matchedTitle = Object.keys(projectPages).find(title =>
|
|
459
|
+
title.includes(searchName)
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
if (!matchedTitle) {
|
|
463
|
+
console.log(`⚠️ ${searchName} — 노션 페이지 못 찾음, 스킵`);
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const pageId = projectPages[matchedTitle];
|
|
468
|
+
console.log(`📁 ${matchedTitle}`);
|
|
469
|
+
console.log(` 경로: ${projectPath}`);
|
|
470
|
+
|
|
471
|
+
const result = await processProject(projectPath, pageId, state);
|
|
472
|
+
totalUploaded += result.uploaded;
|
|
473
|
+
totalUpdated += result.updated;
|
|
474
|
+
totalSkipped += result.skipped;
|
|
475
|
+
|
|
476
|
+
console.log(` 📊 신규: ${result.uploaded}건, 업데이트: ${result.updated}건, 스킵: ${result.skipped}건\n`);
|
|
477
|
+
|
|
478
|
+
// 프로젝트별 중간 상태 저장 (중단 시에도 진행분 보존)
|
|
479
|
+
saveUploadState(state);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// 최종 상태 저장
|
|
483
|
+
saveUploadState(state);
|
|
484
|
+
|
|
485
|
+
console.log('╔══════════════════════════════════════════════╗');
|
|
486
|
+
console.log(`║ ✅ 업로드 완료 ║`);
|
|
487
|
+
console.log(`║ 📤 신규: ${totalUploaded} | 🔄 업데이트: ${totalUpdated} | ⏭️ 스킵: ${totalSkipped} ║`);
|
|
488
|
+
console.log('╚══════════════════════════════════════════════╝');
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
main().catch(err => {
|
|
492
|
+
console.error('❌ 업로드 실패:', err.message);
|
|
493
|
+
if (err.body) console.error(' 상세:', err.body);
|
|
494
|
+
process.exit(1);
|
|
495
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "Node16",
|
|
5
|
+
"moduleResolution": "Node16",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"outDir": "./dist",
|
|
16
|
+
"rootDir": "./src"
|
|
17
|
+
}
|
|
18
|
+
}
|