@giwonn/claude-daily-review 0.2.0 → 0.2.2
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.
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// src/core/config.ts
|
|
2
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
3
|
+
import { dirname, join } from "path";
|
|
4
|
+
function getConfigPath() {
|
|
5
|
+
const dataDir = process.env.CLAUDE_PLUGIN_DATA;
|
|
6
|
+
if (!dataDir) {
|
|
7
|
+
throw new Error("CLAUDE_PLUGIN_DATA environment variable is not set");
|
|
8
|
+
}
|
|
9
|
+
return join(dataDir, "config.json");
|
|
10
|
+
}
|
|
11
|
+
function isOldConfig(raw) {
|
|
12
|
+
if (!raw || typeof raw !== "object") return false;
|
|
13
|
+
return "vaultPath" in raw && "reviewFolder" in raw;
|
|
14
|
+
}
|
|
15
|
+
function migrateOldConfig(old) {
|
|
16
|
+
return {
|
|
17
|
+
storage: {
|
|
18
|
+
type: "local",
|
|
19
|
+
local: {
|
|
20
|
+
basePath: join(old.vaultPath, old.reviewFolder)
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
language: old.language,
|
|
24
|
+
periods: old.periods,
|
|
25
|
+
profile: old.profile
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function loadConfig() {
|
|
29
|
+
const configPath = getConfigPath();
|
|
30
|
+
if (!existsSync(configPath)) return null;
|
|
31
|
+
const raw = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
32
|
+
if (isOldConfig(raw)) {
|
|
33
|
+
const migrated = migrateOldConfig(raw);
|
|
34
|
+
saveConfig(migrated);
|
|
35
|
+
return migrated;
|
|
36
|
+
}
|
|
37
|
+
return raw;
|
|
38
|
+
}
|
|
39
|
+
function saveConfig(config2) {
|
|
40
|
+
const configPath = getConfigPath();
|
|
41
|
+
mkdirSync(dirname(configPath), { recursive: true });
|
|
42
|
+
writeFileSync(configPath, JSON.stringify(config2, null, 2), "utf-8");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/hooks/on-session-start-check.ts
|
|
46
|
+
var config = loadConfig();
|
|
47
|
+
if (!config) {
|
|
48
|
+
process.stderr.write("daily-review: \uC124\uC815\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. /daily-review-setup \uC744 \uC2E4\uD589\uD574\uC8FC\uC138\uC694.\n");
|
|
49
|
+
process.exit(2);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=on-session-start-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/config.ts","../src/hooks/on-session-start-check.ts"],"sourcesContent":["import { readFileSync, writeFileSync, existsSync, mkdirSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport type { StorageAdapter } from \"./storage.js\";\nimport { LocalStorageAdapter } from \"./local-storage.js\";\n\nexport interface Profile {\n company: string;\n role: string;\n team: string;\n context: string;\n}\n\nexport interface Periods {\n daily: true;\n weekly: boolean;\n monthly: boolean;\n quarterly: boolean;\n yearly: boolean;\n}\n\nexport interface LocalStorageConfig {\n basePath: string;\n}\n\nexport interface GitHubStorageConfig {\n owner: string;\n repo: string;\n token: string;\n basePath: string;\n}\n\nexport interface StorageConfig {\n type: \"local\" | \"github\";\n local?: LocalStorageConfig;\n github?: GitHubStorageConfig;\n}\n\nexport interface Config {\n storage: StorageConfig;\n language: string;\n periods: Periods;\n profile: Profile;\n}\n\ninterface OldConfig {\n vaultPath: string;\n reviewFolder: string;\n language: string;\n periods: Periods;\n profile: Profile;\n}\n\nconst DEFAULT_PERIODS: Periods = {\n daily: true,\n weekly: true,\n monthly: true,\n quarterly: true,\n yearly: false,\n};\n\nconst DEFAULT_PROFILE: Profile = {\n company: \"\",\n role: \"\",\n team: \"\",\n context: \"\",\n};\n\nexport function getConfigPath(): string {\n const dataDir = process.env.CLAUDE_PLUGIN_DATA;\n if (!dataDir) {\n throw new Error(\"CLAUDE_PLUGIN_DATA environment variable is not set\");\n }\n return join(dataDir, \"config.json\");\n}\n\nfunction isOldConfig(raw: unknown): raw is OldConfig {\n if (!raw || typeof raw !== \"object\") return false;\n return \"vaultPath\" in raw && \"reviewFolder\" in raw;\n}\n\nfunction migrateOldConfig(old: OldConfig): Config {\n return {\n storage: {\n type: \"local\",\n local: {\n basePath: join(old.vaultPath, old.reviewFolder),\n },\n },\n language: old.language,\n periods: old.periods,\n profile: old.profile,\n };\n}\n\nexport function loadConfig(): Config | null {\n const configPath = getConfigPath();\n if (!existsSync(configPath)) return null;\n const raw = JSON.parse(readFileSync(configPath, \"utf-8\"));\n if (isOldConfig(raw)) {\n const migrated = migrateOldConfig(raw);\n saveConfig(migrated);\n return migrated;\n }\n return raw as Config;\n}\n\nexport function saveConfig(config: Config): void {\n const configPath = getConfigPath();\n mkdirSync(dirname(configPath), { recursive: true });\n writeFileSync(configPath, JSON.stringify(config, null, 2), \"utf-8\");\n}\n\nexport function validateConfig(config: unknown): config is Config {\n if (!config || typeof config !== \"object\") return false;\n const c = config as Record<string, unknown>;\n if (!c.storage || typeof c.storage !== \"object\") return false;\n const s = c.storage as Record<string, unknown>;\n if (s.type !== \"local\" && s.type !== \"github\") return false;\n if (s.type === \"local\") {\n if (!s.local || typeof s.local !== \"object\") return false;\n const l = s.local as Record<string, unknown>;\n if (typeof l.basePath !== \"string\" || l.basePath === \"\") return false;\n }\n if (s.type === \"github\") {\n if (!s.github || typeof s.github !== \"object\") return false;\n const g = s.github as Record<string, unknown>;\n if (typeof g.owner !== \"string\" || !g.owner) return false;\n if (typeof g.repo !== \"string\" || !g.repo) return false;\n if (typeof g.token !== \"string\" || !g.token) return false;\n }\n return true;\n}\n\nexport function createDefaultLocalConfig(basePath: string): Config {\n return {\n storage: { type: \"local\", local: { basePath } },\n language: \"ko\",\n periods: { ...DEFAULT_PERIODS },\n profile: { ...DEFAULT_PROFILE },\n };\n}\n\nexport function createDefaultGitHubConfig(owner: string, repo: string, token: string): Config {\n return {\n storage: { type: \"github\", github: { owner, repo, token, basePath: \"daily-review\" } },\n language: \"ko\",\n periods: { ...DEFAULT_PERIODS },\n profile: { ...DEFAULT_PROFILE },\n };\n}\n\nexport async function createStorageAdapter(config: Config): Promise<StorageAdapter> {\n if (config.storage.type === \"local\") {\n return new LocalStorageAdapter(config.storage.local!.basePath);\n }\n if (config.storage.type === \"github\") {\n const { GitHubStorageAdapter } = await import(\"./github-storage.js\");\n const g = config.storage.github!;\n return new GitHubStorageAdapter(g.owner, g.repo, g.token, g.basePath);\n }\n throw new Error(`Unknown storage type: ${(config.storage as any).type}`);\n}\n","import { loadConfig } from \"../core/config.js\";\n\nconst config = loadConfig();\nif (!config) {\n process.stderr.write(\"daily-review: 설정이 없습니다. /daily-review-setup 을 실행해주세요.\\n\");\n process.exit(2);\n}\n"],"mappings":";AAAA,SAAS,cAAc,eAAe,YAAY,iBAAiB;AACnE,SAAS,SAAS,YAAY;AAkEvB,SAAS,gBAAwB;AACtC,QAAM,UAAU,QAAQ,IAAI;AAC5B,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,SAAO,KAAK,SAAS,aAAa;AACpC;AAEA,SAAS,YAAY,KAAgC;AACnD,MAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,SAAO,eAAe,OAAO,kBAAkB;AACjD;AAEA,SAAS,iBAAiB,KAAwB;AAChD,SAAO;AAAA,IACL,SAAS;AAAA,MACP,MAAM;AAAA,MACN,OAAO;AAAA,QACL,UAAU,KAAK,IAAI,WAAW,IAAI,YAAY;AAAA,MAChD;AAAA,IACF;AAAA,IACA,UAAU,IAAI;AAAA,IACd,SAAS,IAAI;AAAA,IACb,SAAS,IAAI;AAAA,EACf;AACF;AAEO,SAAS,aAA4B;AAC1C,QAAM,aAAa,cAAc;AACjC,MAAI,CAAC,WAAW,UAAU,EAAG,QAAO;AACpC,QAAM,MAAM,KAAK,MAAM,aAAa,YAAY,OAAO,CAAC;AACxD,MAAI,YAAY,GAAG,GAAG;AACpB,UAAM,WAAW,iBAAiB,GAAG;AACrC,eAAW,QAAQ;AACnB,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,SAAS,WAAWA,SAAsB;AAC/C,QAAM,aAAa,cAAc;AACjC,YAAU,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;AAClD,gBAAc,YAAY,KAAK,UAAUA,SAAQ,MAAM,CAAC,GAAG,OAAO;AACpE;;;AC5GA,IAAM,SAAS,WAAW;AAC1B,IAAI,CAAC,QAAQ;AACX,UAAQ,OAAO,MAAM,+HAAyD;AAC9E,UAAQ,KAAK,CAAC;AAChB;","names":["config"]}
|
package/hooks/hooks.json
CHANGED
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
{
|
|
28
28
|
"hooks": [
|
|
29
29
|
{
|
|
30
|
-
"type": "
|
|
31
|
-
"
|
|
32
|
-
"timeout":
|
|
30
|
+
"type": "command",
|
|
31
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/on-session-start-check.js\"",
|
|
32
|
+
"timeout": 5
|
|
33
33
|
}
|
|
34
34
|
]
|
|
35
35
|
}
|
package/package.json
CHANGED