@routinecrew/routinecode 2.31.85 → 2.31.87
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/bin/cli.sh +10 -0
- package/bin/prompt-vault.dat +1 -1
- package/bin/rc-board.js +58 -0
- package/bin/rc-skills.js +31 -0
- package/bin/setup.js +1 -1
- package/hooks/hooks-config.json +10 -1
- package/hooks/lib/agent_telemetry.py +143 -0
- package/hooks/lib/attest_reader.py +16 -1
- package/hooks/lib/board-golden.json +268 -0
- package/hooks/lib/board.py +503 -0
- package/hooks/lib/board_sync.py +535 -0
- package/hooks/lib/completion_log.py +12 -5
- package/hooks/lib/config_bash_track.py +14 -26
- package/hooks/lib/config_guard.py +133 -4
- package/hooks/lib/design_pick_nudge.py +86 -0
- package/hooks/lib/edit_tracker.py +182 -0
- package/hooks/lib/i18n.py +62 -20
- package/hooks/lib/knowledge_items.py +74 -8
- package/hooks/lib/usage_v2.py +12 -0
- package/hooks/post-agent-return.sh +5 -0
- package/hooks/post-edit-track.sh +19 -28
- package/hooks/post-orch-decision.sh +17 -0
- package/hooks/pre-account-guard.sh +1 -1
- package/hooks/pre-agent-spawn.mjs +1 -1
- package/hooks/pre-agent-spawn.sh +12 -0
- package/hooks/pre-credit-guard.sh +1 -1
- package/hooks/pre-edit-board.sh +44 -0
- package/hooks/pre-edit-check.sh +27 -3
- package/hooks/pre-mark-complete.sh +71 -15
- package/hooks/session-start.sh +62 -3
- package/hooks/skill-knowledge.sh +6 -0
- package/hooks/user-prompt-submit.sh +9 -0
- package/mcp-plan-manager/dist/file-ops.js +1 -1
- package/mcp-routinecode/dist/board.js +1 -0
- package/mcp-routinecode/dist/build-id.js +1 -0
- package/mcp-routinecode/dist/changeset.js +1 -1
- package/mcp-routinecode/dist/config-auth.js +1 -1
- package/mcp-routinecode/dist/config-map/applied.js +1 -0
- package/mcp-routinecode/dist/config-map/arch-graph.js +1 -1
- package/mcp-routinecode/dist/config-map/architect-store.js +1 -7
- package/mcp-routinecode/dist/config-map/audit-cli.js +1 -1
- package/mcp-routinecode/dist/config-map/audit.js +1 -1
- package/mcp-routinecode/dist/config-map/blocks.js +1 -1
- package/mcp-routinecode/dist/config-map/convention-candidates.js +1 -1
- package/mcp-routinecode/dist/config-map/decisions.js +1 -1
- package/mcp-routinecode/dist/config-map/dup-safety.js +1 -1
- package/mcp-routinecode/dist/config-map/field-contract.js +1 -1
- package/mcp-routinecode/dist/config-map/hash.js +1 -1
- package/mcp-routinecode/dist/config-map/index-store.js +62 -5
- package/mcp-routinecode/dist/config-map/link.js +1 -1
- package/mcp-routinecode/dist/config-map/linked-repos.js +1 -1
- package/mcp-routinecode/dist/config-map/maintenance-cli.js +1 -1
- package/mcp-routinecode/dist/config-map/proposals.js +1 -1
- package/mcp-routinecode/dist/config-map/repo-id.js +1 -1
- package/mcp-routinecode/dist/config-map/route-security.js +1 -1
- package/mcp-routinecode/dist/config-map/rule-import.js +1 -1
- package/mcp-routinecode/dist/config-map/shape-eval.js +1 -1
- package/mcp-routinecode/dist/config-map/shape.js +1 -1
- package/mcp-routinecode/dist/config-map/snapshot.js +1 -1
- package/mcp-routinecode/dist/config-map/sole-impl.js +1 -1
- package/mcp-routinecode/dist/config-map/stable-id.js +1 -1
- package/mcp-routinecode/dist/config-map/store.js +1 -1
- package/mcp-routinecode/dist/config-map/swagger-check.js +1 -1
- package/mcp-routinecode/dist/config-map/templates.js +1 -1
- package/mcp-routinecode/dist/contracts.generated.js +1 -1
- package/mcp-routinecode/dist/coverage.js +1 -1
- package/mcp-routinecode/dist/criteria-card.js +1 -0
- package/mcp-routinecode/dist/design-judge.js +1 -0
- package/mcp-routinecode/dist/edit-tracker.js +1 -0
- package/mcp-routinecode/dist/explorer-advisor.js +1 -1
- package/mcp-routinecode/dist/failure-tracker.js +1 -1
- package/mcp-routinecode/dist/file-lock-registry.js +1 -1
- package/mcp-routinecode/dist/file-risk-scorer.js +1 -1
- package/mcp-routinecode/dist/index.js +1 -1
- package/mcp-routinecode/dist/known-solutions.js +1 -1
- package/mcp-routinecode/dist/ledger-miner.js +1 -1
- package/mcp-routinecode/dist/normalize-sig.js +1 -1
- package/mcp-routinecode/dist/observed-draft.js +1 -1
- package/mcp-routinecode/dist/observed-escalation.js +1 -0
- package/mcp-routinecode/dist/pattern-matcher.js +1 -1
- package/mcp-routinecode/dist/route-match.js +1 -1
- package/mcp-routinecode/dist/routines.js +1 -1
- package/mcp-routinecode/dist/rule-engine.js +1 -1
- package/mcp-routinecode/dist/rule-promoter.js +1 -1
- package/mcp-routinecode/dist/session-registry.js +1 -0
- package/mcp-routinecode/dist/skill-pack/sync.js +655 -0
- package/mcp-routinecode/dist/skill-pack/validate.js +278 -0
- package/mcp-routinecode/dist/test-runner.js +1 -1
- package/mcp-routinecode/dist/thinking-judge.js +1 -0
- package/mcp-routinecode/dist/verification.js +1 -1
- package/mcp-routinecode/package.json +1 -1
- package/package.json +2 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/agents/analyzer.md.sealed +1 -1
- package/plugin/agents/architect.md.sealed +1 -1
- package/plugin/agents/crawler.md.sealed +1 -1
- package/plugin/agents/explorer.md.sealed +1 -1
- package/plugin/agents/implementor.md.sealed +1 -1
- package/plugin/agents/looker.md.sealed +1 -1
- package/plugin/agents/planner.md.sealed +1 -1
- package/plugin/agents/recorder.md.sealed +1 -1
- package/plugin/agents/reviewer.md.sealed +1 -1
- package/plugin/agents/verifier.md.sealed +1 -1
- package/plugin/commands/analyze.md.sealed +1 -1
- package/plugin/commands/plan.md.sealed +1 -1
- package/plugin/commands/rc.md.sealed +1 -1
- package/plugin/commands/receipt.md.sealed +1 -1
- package/plugin/commands/recharge.md.sealed +1 -1
- package/plugin/commands/routines.md.sealed +1 -1
- package/plugin/commands/share.md.sealed +1 -1
- package/plugin/routinecode-prompt.md.sealed +1 -1
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* skill-pack/sync — 디자인 스킬 팩 내려받기·검증·설치 (설계 23 §5, 2 단계).
|
|
3
|
+
*
|
|
4
|
+
* routinecode skills status | on | off | sync (bin/rc-skills.js → main)
|
|
5
|
+
*
|
|
6
|
+
* - 기본 켜짐(설계 23 v11): `off` 를 고른 사용자(state.choice='off')만 내려받지 않는다. 처음 설치되면 한 번 안내(state.onNoticeShown).
|
|
7
|
+
* choice 가 없는 예전 state(enabled:false 포함)는 켜짐으로 본다 — 2.31.86 까지의 '기본 꺼짐'은 사용자 선택이 아니었으므로.
|
|
8
|
+
* - 서버: GET {serverUrl}/api/v1/skill-pack/current?clientVersion=V[&have=<sha>] (per-user apiKey), 24시간에 한 번(lastCheckAt).
|
|
9
|
+
* fetch 는 AbortSignal.timeout(4000). 전체 5초 예산이 지나면 쓰기 전 단계는 중단, 교체 중이면 마치고 끝낸다.
|
|
10
|
+
* - 검증: 서명(index-store.verifySkillPackSig, 임베드 레코드 공개키) → 다이제스트 → §3.1 규칙 → format·minClientVersion → 재전송 규칙.
|
|
11
|
+
* 실패하면 아무것도 바꾸지 않고 state.lastError 에 이유.
|
|
12
|
+
* - 로컬 보관: 검증된 팩(서명 포함)을 ~/.routinecode/skill-packs/<sha>.json(0600)에 두고 설치는 항상 보관본에서. 현재 팩 하나만 남긴다.
|
|
13
|
+
* 보관본이 있고 재검증을 통과할 때만 have=<sha>.
|
|
14
|
+
* - 재전송 방지: state.highest[line]={serial,sha}. serial 이 낮거나, 같은 serial 에 다른 sha, revoked sha 면 서명이 맞아도 거부.
|
|
15
|
+
* 같은 (serial, sha) 는 다시 설치할 수 있다(off→on, 폴더 삭제, CLAUDE_CONFIG_DIR 변경, 만료 후 복귀).
|
|
16
|
+
* - 설치: ${CLAUDE_CONFIG_DIR:-~/.claude}/.rc-skillpack/staging-<sha>/ 에 모두 쓴 뒤 스킬마다 기존 → old-<sha>-x, staging → skills/x, old 삭제.
|
|
17
|
+
* state.pending 으로 진행을 남기고 다음 실행이 남은 staging·old 를 정리(되돌림)한 뒤 보관본에서 다시 맞춘다.
|
|
18
|
+
* 각 디렉터리에 .routinecode-managed 표식. 표식 있는 rc-* 만 만들고 바꾸고 지운다(표식 없는 같은 이름은 건너뜀).
|
|
19
|
+
* - 동시 세션: state.json.lock(O_EXCL), 10분 넘은 잠금은 제거. 회수: 응답 revoked 에 설치 sha → 삭제.
|
|
20
|
+
* 만료: 서버 확인에 마지막으로 성공한 지 90일 → 표식 디렉터리·보관본 삭제(apiKey 없어도 로컬 판정).
|
|
21
|
+
* - env: ROUTINECODE_SKILL_PACKS=0 은 동기화만 멈춘다(설치본 유지). 백그라운드 세션(ROUTINECODE_RECORDER·ARCHITECT·MAINTENANCE=1)은 건너뛴다.
|
|
22
|
+
* 하위 프로세스 실행 없음, 글(.md/.txt)만 쓴다. npm 배포본에서 평문 유지(obfuscate.js PLAIN_DIST, §8).
|
|
23
|
+
*/
|
|
24
|
+
import * as fs from 'fs';
|
|
25
|
+
import * as path from 'path';
|
|
26
|
+
import * as crypto from 'crypto';
|
|
27
|
+
import { PKG_ROOT } from '../config-map/cert-lib.js';
|
|
28
|
+
import { homeDir, readSyncConfig, recordPubKeys, verifySkillPackSig } from '../config-map/index-store.js';
|
|
29
|
+
import { packProblem, packDigest, compareVersion, SKILLPACK_FORMAT, SKILL_DIR_RE } from './validate.js';
|
|
30
|
+
const DAY_MS = 86_400_000;
|
|
31
|
+
export const CHECK_INTERVAL_MS = DAY_MS;
|
|
32
|
+
export const EXPIRY_MS = 90 * DAY_MS;
|
|
33
|
+
export const LOCK_STALE_MS = 10 * 60_000;
|
|
34
|
+
export const FETCH_TIMEOUT_MS = 4000;
|
|
35
|
+
export const RUN_BUDGET_MS = 5000;
|
|
36
|
+
export const MARKER = '.routinecode-managed';
|
|
37
|
+
const REVOKED_KEEP = 500;
|
|
38
|
+
const SHA_RE = /^[0-9a-f]{64}$/;
|
|
39
|
+
export const NOTICE_TEXT = 'RoutineCode design skills installed: 28 commercial web styles + a template picker shown when you ask for a homepage or screen design. Turn off: routinecode skills off';
|
|
40
|
+
/** ~/.routinecode/skill-packs(ROUTINECODE_DIR 존중) · ${CLAUDE_CONFIG_DIR:-~/.claude}/skills · …/.rc-skillpack(감시 폴더 밖, 같은 파일시스템) */
|
|
41
|
+
export function skillPackPaths(env = process.env) {
|
|
42
|
+
const home = env.HOME || env.USERPROFILE || homeDir();
|
|
43
|
+
const stateDir = path.join(env.ROUTINECODE_DIR || path.join(home, '.routinecode'), 'skill-packs');
|
|
44
|
+
const configDir = env.CLAUDE_CONFIG_DIR || path.join(home, '.claude');
|
|
45
|
+
const statePath = path.join(stateDir, 'state.json');
|
|
46
|
+
return { stateDir, statePath, lockPath: `${statePath}.lock`, configDir, skillsDir: path.join(configDir, 'skills'), workDir: path.join(configDir, '.rc-skillpack') };
|
|
47
|
+
}
|
|
48
|
+
export function defaultState() {
|
|
49
|
+
return { enabled: true, choice: null, noticeShown: false, onNoticeShown: false, lastCheckAt: null, lastSuccessAt: null, highest: {}, installed: {}, revoked: [], pending: null, lastError: null };
|
|
50
|
+
}
|
|
51
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
52
|
+
const numOrNull = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : null);
|
|
53
|
+
export function readState(P) {
|
|
54
|
+
const d = defaultState();
|
|
55
|
+
let raw;
|
|
56
|
+
try {
|
|
57
|
+
raw = JSON.parse(fs.readFileSync(P.statePath, 'utf-8'));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return d;
|
|
61
|
+
}
|
|
62
|
+
if (!isObj(raw))
|
|
63
|
+
return d;
|
|
64
|
+
const choice = raw.choice === 'on' || raw.choice === 'off' ? raw.choice : null;
|
|
65
|
+
const st = {
|
|
66
|
+
enabled: choice !== 'off',
|
|
67
|
+
choice,
|
|
68
|
+
noticeShown: raw.noticeShown === true,
|
|
69
|
+
onNoticeShown: raw.onNoticeShown === true,
|
|
70
|
+
lastCheckAt: numOrNull(raw.lastCheckAt),
|
|
71
|
+
lastSuccessAt: numOrNull(raw.lastSuccessAt),
|
|
72
|
+
highest: {},
|
|
73
|
+
installed: {},
|
|
74
|
+
revoked: Array.isArray(raw.revoked) ? raw.revoked.filter((s) => typeof s === 'string' && SHA_RE.test(s)) : [],
|
|
75
|
+
pending: null,
|
|
76
|
+
lastError: typeof raw.lastError === 'string' ? raw.lastError : null,
|
|
77
|
+
};
|
|
78
|
+
if (isObj(raw.highest))
|
|
79
|
+
for (const [k, v] of Object.entries(raw.highest))
|
|
80
|
+
if (isObj(v) && Number.isSafeInteger(v.serial) && typeof v.sha === 'string' && SHA_RE.test(v.sha))
|
|
81
|
+
st.highest[k] = { serial: v.serial, sha: v.sha };
|
|
82
|
+
if (isObj(raw.installed))
|
|
83
|
+
for (const [k, v] of Object.entries(raw.installed))
|
|
84
|
+
if (isObj(v) && Number.isSafeInteger(v.serial) && typeof v.sha === 'string' && Array.isArray(v.dirs))
|
|
85
|
+
st.installed[k] = { serial: v.serial, sha: v.sha, dirs: v.dirs.filter((x) => typeof x === 'string' && SKILL_DIR_RE.test(x)) };
|
|
86
|
+
if (isObj(raw.pending) && typeof raw.pending.sha === 'string' && SHA_RE.test(raw.pending.sha))
|
|
87
|
+
st.pending = { op: 'install', sha: raw.pending.sha, done: Array.isArray(raw.pending.done) ? raw.pending.done.filter((x) => typeof x === 'string') : [] };
|
|
88
|
+
return st;
|
|
89
|
+
}
|
|
90
|
+
function writeFileAtomic(p, data, mode = 0o600) {
|
|
91
|
+
const tmp = `${p}.${process.pid}.${crypto.randomBytes(4).toString('hex')}.tmp`;
|
|
92
|
+
fs.writeFileSync(tmp, data, { mode });
|
|
93
|
+
fs.renameSync(tmp, p);
|
|
94
|
+
}
|
|
95
|
+
/** 공백 없는 JSON — session-start.sh 가 `"enabled":false` 를 grep 해 node 를 띄우지 않고 건너뛴다 */
|
|
96
|
+
export function writeState(P, st) {
|
|
97
|
+
fs.mkdirSync(P.stateDir, { recursive: true, mode: 0o700 });
|
|
98
|
+
writeFileAtomic(P.statePath, JSON.stringify(st));
|
|
99
|
+
}
|
|
100
|
+
// ── 잠금 ─────────────────────────────────────────────────────────────
|
|
101
|
+
/** 오래된 잠금 판정은 파일 mtime 과 같은 실제 시계로 한다(주입 시계 아님) */
|
|
102
|
+
export function acquireLock(P, now = Date.now()) {
|
|
103
|
+
fs.mkdirSync(P.stateDir, { recursive: true, mode: 0o700 });
|
|
104
|
+
for (let i = 0; i < 2; i++) {
|
|
105
|
+
try {
|
|
106
|
+
const fd = fs.openSync(P.lockPath, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_WRONLY, 0o600);
|
|
107
|
+
fs.writeSync(fd, String(process.pid));
|
|
108
|
+
fs.closeSync(fd);
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
try {
|
|
113
|
+
if (now - fs.statSync(P.lockPath).mtimeMs > LOCK_STALE_MS) {
|
|
114
|
+
fs.unlinkSync(P.lockPath);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
export function releaseLock(P) {
|
|
127
|
+
try {
|
|
128
|
+
fs.unlinkSync(P.lockPath);
|
|
129
|
+
}
|
|
130
|
+
catch { /* 이미 없음 */ }
|
|
131
|
+
}
|
|
132
|
+
const archivePath = (P, sha) => path.join(P.stateDir, `${sha}.json`);
|
|
133
|
+
/** 서명·다이제스트·규칙·format 재검증을 통과한 보관본만 */
|
|
134
|
+
export function loadArchive(P, sha, keys) {
|
|
135
|
+
if (!SHA_RE.test(sha))
|
|
136
|
+
return null;
|
|
137
|
+
let a;
|
|
138
|
+
try {
|
|
139
|
+
a = JSON.parse(fs.readFileSync(archivePath(P, sha), 'utf-8'));
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
if (!isObj(a) || a.sha256 !== sha)
|
|
145
|
+
return null;
|
|
146
|
+
if (!verifySkillPackSig(a.sha256, a.kid, a.sig, keys))
|
|
147
|
+
return null;
|
|
148
|
+
if (!isObj(a.bundle) || a.bundle.sha256 !== sha || packProblem(a.bundle) !== null)
|
|
149
|
+
return null;
|
|
150
|
+
return a;
|
|
151
|
+
}
|
|
152
|
+
function saveArchive(P, a) {
|
|
153
|
+
fs.mkdirSync(P.stateDir, { recursive: true, mode: 0o700 });
|
|
154
|
+
writeFileAtomic(archivePath(P, a.sha256), JSON.stringify(a), 0o600);
|
|
155
|
+
for (const n of fs.readdirSync(P.stateDir)) {
|
|
156
|
+
if (/^[0-9a-f]{64}\.json$/.test(n) && n !== `${a.sha256}.json`) {
|
|
157
|
+
try {
|
|
158
|
+
fs.unlinkSync(path.join(P.stateDir, n));
|
|
159
|
+
}
|
|
160
|
+
catch { /* 무시 */ }
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function deleteArchives(P, only) {
|
|
165
|
+
let names = [];
|
|
166
|
+
try {
|
|
167
|
+
names = fs.readdirSync(P.stateDir);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
for (const n of names) {
|
|
173
|
+
if (!/^[0-9a-f]{64}\.json$/.test(n))
|
|
174
|
+
continue;
|
|
175
|
+
if (only && n !== `${only}.json`)
|
|
176
|
+
continue;
|
|
177
|
+
try {
|
|
178
|
+
fs.unlinkSync(path.join(P.stateDir, n));
|
|
179
|
+
}
|
|
180
|
+
catch { /* 무시 */ }
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/** 실제 디렉터리(심볼릭 링크 아님) 안의 표식 — 없거나 형식이 틀리면 null(= 관리 대상 아님) */
|
|
184
|
+
export function readMarker(dir) {
|
|
185
|
+
try {
|
|
186
|
+
if (!fs.lstatSync(dir).isDirectory())
|
|
187
|
+
return null;
|
|
188
|
+
const m = JSON.parse(fs.readFileSync(path.join(dir, MARKER), 'utf-8'));
|
|
189
|
+
return isObj(m) && typeof m.sha256 === 'string' && typeof m.line === 'string' ? m : null;
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const exists = (p) => { try {
|
|
196
|
+
fs.lstatSync(p);
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return false;
|
|
201
|
+
} };
|
|
202
|
+
/** skills 안 표식 있는 rc-* 디렉터리 삭제(filter 로 범위 제한). 반환 = 지운 것이 있는지 */
|
|
203
|
+
function removeManaged(P, filter = () => true) {
|
|
204
|
+
let names = [];
|
|
205
|
+
try {
|
|
206
|
+
names = fs.readdirSync(P.skillsDir);
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
let removed = false;
|
|
212
|
+
for (const n of names) {
|
|
213
|
+
if (!SKILL_DIR_RE.test(n))
|
|
214
|
+
continue;
|
|
215
|
+
const d = path.join(P.skillsDir, n);
|
|
216
|
+
const m = readMarker(d);
|
|
217
|
+
if (!m || !filter(m, n))
|
|
218
|
+
continue;
|
|
219
|
+
fs.rmSync(d, { recursive: true, force: true });
|
|
220
|
+
removed = true;
|
|
221
|
+
}
|
|
222
|
+
return removed;
|
|
223
|
+
}
|
|
224
|
+
/** 표식 없는 같은 이름(사용자 소유) — 건너뛴 디렉터리 */
|
|
225
|
+
function unmanagedClashes(P, pack) {
|
|
226
|
+
return pack.skills.map((s) => s.dir).filter((d) => exists(path.join(P.skillsDir, d)) && !readMarker(path.join(P.skillsDir, d)));
|
|
227
|
+
}
|
|
228
|
+
function installedMatches(P, st, pack) {
|
|
229
|
+
const cur = st.installed[pack.line];
|
|
230
|
+
if (!cur || cur.sha !== pack.sha256)
|
|
231
|
+
return false;
|
|
232
|
+
for (const s of pack.skills) {
|
|
233
|
+
const d = path.join(P.skillsDir, s.dir);
|
|
234
|
+
if (!exists(d))
|
|
235
|
+
return false;
|
|
236
|
+
const m = readMarker(d);
|
|
237
|
+
if (m && m.sha256 !== pack.sha256)
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
function installPack(P, st, pack, hooks) {
|
|
243
|
+
const sha = pack.sha256;
|
|
244
|
+
fs.mkdirSync(P.workDir, { recursive: true, mode: 0o700 });
|
|
245
|
+
fs.mkdirSync(P.skillsDir, { recursive: true });
|
|
246
|
+
const staging = path.join(P.workDir, `staging-${sha}`);
|
|
247
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
248
|
+
fs.mkdirSync(staging, { recursive: true, mode: 0o700 });
|
|
249
|
+
const marker = { packId: pack.packId, sha256: sha, line: pack.line, serial: pack.serial };
|
|
250
|
+
for (const s of pack.skills) {
|
|
251
|
+
const root = path.join(staging, s.dir);
|
|
252
|
+
for (const [rel, content] of Object.entries(s.files)) {
|
|
253
|
+
const f = path.join(root, rel);
|
|
254
|
+
fs.mkdirSync(path.dirname(f), { recursive: true });
|
|
255
|
+
fs.writeFileSync(f, content, { mode: 0o644 });
|
|
256
|
+
}
|
|
257
|
+
fs.writeFileSync(path.join(root, MARKER), JSON.stringify(marker) + '\n', { mode: 0o644 });
|
|
258
|
+
}
|
|
259
|
+
hooks.onStep?.('staged', '');
|
|
260
|
+
st.pending = { op: 'install', sha, done: [] };
|
|
261
|
+
writeState(P, st);
|
|
262
|
+
const placed = [];
|
|
263
|
+
for (const s of [...pack.skills].sort((a, b) => (a.dir < b.dir ? -1 : 1))) {
|
|
264
|
+
const target = path.join(P.skillsDir, s.dir);
|
|
265
|
+
if (exists(target) && !readMarker(target))
|
|
266
|
+
continue; // 사용자 소유 같은 이름 — 건너뜀
|
|
267
|
+
const old = path.join(P.workDir, `old-${sha}-${s.dir}`);
|
|
268
|
+
if (exists(target)) {
|
|
269
|
+
fs.rmSync(old, { recursive: true, force: true });
|
|
270
|
+
fs.renameSync(target, old);
|
|
271
|
+
hooks.onStep?.('moved-old', s.dir);
|
|
272
|
+
}
|
|
273
|
+
fs.renameSync(path.join(staging, s.dir), target);
|
|
274
|
+
hooks.onStep?.('placed', s.dir);
|
|
275
|
+
fs.rmSync(old, { recursive: true, force: true });
|
|
276
|
+
st.pending.done.push(s.dir);
|
|
277
|
+
placed.push(s.dir);
|
|
278
|
+
writeState(P, st);
|
|
279
|
+
}
|
|
280
|
+
// 같은 line 의 이전 팩에만 있던 관리 디렉터리 정리
|
|
281
|
+
const keep = new Set(pack.skills.map((s) => s.dir));
|
|
282
|
+
removeManaged(P, (m, dir) => m.line === pack.line && !keep.has(dir));
|
|
283
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
284
|
+
st.installed[pack.line] = { serial: pack.serial, sha, dirs: placed };
|
|
285
|
+
st.pending = null;
|
|
286
|
+
writeState(P, st);
|
|
287
|
+
return placed;
|
|
288
|
+
}
|
|
289
|
+
/** 중단된 설치 정리 — old-* 는 자리가 비었으면 되돌리고 아니면 삭제, staging-* 삭제. 이후 reconcile 이 보관본에서 다시 맞춘다 */
|
|
290
|
+
function recoverPending(P, st) {
|
|
291
|
+
let changed = false;
|
|
292
|
+
let names = [];
|
|
293
|
+
try {
|
|
294
|
+
names = fs.readdirSync(P.workDir);
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
names = [];
|
|
298
|
+
}
|
|
299
|
+
for (const n of names) {
|
|
300
|
+
const full = path.join(P.workDir, n);
|
|
301
|
+
const m = /^old-[0-9a-f]{64}-(rc-[a-z0-9-]{1,61})$/.exec(n);
|
|
302
|
+
if (m) {
|
|
303
|
+
const target = path.join(P.skillsDir, m[1]);
|
|
304
|
+
if (!exists(target)) {
|
|
305
|
+
fs.mkdirSync(P.skillsDir, { recursive: true });
|
|
306
|
+
fs.renameSync(full, target);
|
|
307
|
+
changed = true;
|
|
308
|
+
}
|
|
309
|
+
else
|
|
310
|
+
fs.rmSync(full, { recursive: true, force: true });
|
|
311
|
+
}
|
|
312
|
+
else if (/^staging-[0-9a-f]{64}$/.test(n)) {
|
|
313
|
+
fs.rmSync(full, { recursive: true, force: true });
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
for (const line of Object.keys(st.installed))
|
|
317
|
+
if (st.installed[line].sha === st.pending?.sha)
|
|
318
|
+
delete st.installed[line];
|
|
319
|
+
st.pending = null;
|
|
320
|
+
writeState(P, st);
|
|
321
|
+
return changed;
|
|
322
|
+
}
|
|
323
|
+
function clientVersionOf(o) {
|
|
324
|
+
if (o.clientVersion)
|
|
325
|
+
return o.clientVersion;
|
|
326
|
+
try {
|
|
327
|
+
return String(JSON.parse(fs.readFileSync(path.join(PKG_ROOT, 'package.json'), 'utf-8')).version || '0.0.0');
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
return '0.0.0';
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
async function fetchCurrent(cfg, version, have, o) {
|
|
334
|
+
const f = o.fetchImpl ?? globalThis.fetch;
|
|
335
|
+
if (typeof f !== 'function')
|
|
336
|
+
return { status: 0, data: null };
|
|
337
|
+
try {
|
|
338
|
+
const q = `?clientVersion=${encodeURIComponent(version)}${have ? `&have=${have}` : ''}`;
|
|
339
|
+
const r = await f(`${cfg.serverUrl}/api/v1/skill-pack/current${q}`, {
|
|
340
|
+
method: 'GET', headers: { Authorization: 'Bearer ' + cfg.apiKey, Accept: 'application/json' }, signal: AbortSignal.timeout(o.fetchTimeoutMs ?? FETCH_TIMEOUT_MS),
|
|
341
|
+
});
|
|
342
|
+
let parsed = null;
|
|
343
|
+
try {
|
|
344
|
+
parsed = JSON.parse(await r.text());
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
parsed = null;
|
|
348
|
+
}
|
|
349
|
+
return { status: r.status, data: isObj(parsed) && 'data' in parsed ? parsed.data : parsed };
|
|
350
|
+
}
|
|
351
|
+
catch {
|
|
352
|
+
return { status: 0, data: null };
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/** 받은 팩 검증 — 서명 → 다이제스트 → 규칙 → format·minClientVersion → 재전송. 실패 = 사유 문자열 */
|
|
356
|
+
export function verifyIncoming(d, keys, st, clientVersion) {
|
|
357
|
+
const { sha256, kid, sig, bundle } = d;
|
|
358
|
+
if (!verifySkillPackSig(sha256, kid, sig, keys))
|
|
359
|
+
return keys ? 'bad-signature' : 'no-pubkeys';
|
|
360
|
+
if (!isObj(bundle) || bundle.sha256 !== sha256)
|
|
361
|
+
return 'digest-mismatch';
|
|
362
|
+
if (bundle.format !== SKILLPACK_FORMAT)
|
|
363
|
+
return `update-needed:format-${String(bundle.format)}`;
|
|
364
|
+
let digest = '';
|
|
365
|
+
try {
|
|
366
|
+
digest = packDigest(bundle);
|
|
367
|
+
}
|
|
368
|
+
catch {
|
|
369
|
+
return 'invalid:malformed';
|
|
370
|
+
}
|
|
371
|
+
if (digest !== sha256)
|
|
372
|
+
return 'digest-mismatch';
|
|
373
|
+
const problem = packProblem(bundle);
|
|
374
|
+
if (problem)
|
|
375
|
+
return `invalid:${problem}`;
|
|
376
|
+
const pack = bundle;
|
|
377
|
+
if (compareVersion(clientVersion, pack.minClientVersion) < 0)
|
|
378
|
+
return `update-needed:client-${pack.minClientVersion}`;
|
|
379
|
+
if (st.revoked.includes(pack.sha256))
|
|
380
|
+
return 'replay:revoked';
|
|
381
|
+
const hi = st.highest[pack.line];
|
|
382
|
+
if (hi && pack.serial < hi.serial)
|
|
383
|
+
return 'replay:lower-serial';
|
|
384
|
+
if (hi && pack.serial === hi.serial && pack.sha256 !== hi.sha)
|
|
385
|
+
return 'replay:serial-sha-mismatch';
|
|
386
|
+
return { sha256: pack.sha256, kid: kid, sig: sig, bundle: pack };
|
|
387
|
+
}
|
|
388
|
+
export const isBackgroundSession = (env) => env.ROUTINECODE_RECORDER === '1' || env.ROUTINECODE_ARCHITECT === '1' || env.ROUTINECODE_MAINTENANCE === '1';
|
|
389
|
+
/** 동기화 1회 — 절대 throw 하지 않는다. 기본 켜짐으로 처음 설치됐으면 안내 한 줄을 붙인다 */
|
|
390
|
+
export async function runSync(o = {}) {
|
|
391
|
+
const r = await runSyncOnce(o);
|
|
392
|
+
if (r.code !== 'changed')
|
|
393
|
+
return r;
|
|
394
|
+
try {
|
|
395
|
+
const P = o.paths ?? skillPackPaths(o.env ?? process.env);
|
|
396
|
+
if (!acquireLock(P))
|
|
397
|
+
return r;
|
|
398
|
+
try {
|
|
399
|
+
const st = readState(P);
|
|
400
|
+
if (st.onNoticeShown || !Object.keys(st.installed).length)
|
|
401
|
+
return r;
|
|
402
|
+
st.onNoticeShown = true;
|
|
403
|
+
st.noticeShown = true;
|
|
404
|
+
writeState(P, st);
|
|
405
|
+
return { code: 'changed', message: NOTICE_TEXT };
|
|
406
|
+
}
|
|
407
|
+
finally {
|
|
408
|
+
releaseLock(P);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
catch {
|
|
412
|
+
return r;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
async function runSyncOnce(o = {}) {
|
|
416
|
+
const env = o.env ?? process.env;
|
|
417
|
+
if (isBackgroundSession(env))
|
|
418
|
+
return { code: 'skipped' };
|
|
419
|
+
const P = o.paths ?? skillPackPaths(env);
|
|
420
|
+
const nowFn = o.now ?? Date.now;
|
|
421
|
+
const deadline = Date.now() + (o.budgetMs ?? RUN_BUDGET_MS);
|
|
422
|
+
let st;
|
|
423
|
+
try {
|
|
424
|
+
st = readState(P);
|
|
425
|
+
if (!st.enabled)
|
|
426
|
+
return { code: 'disabled' };
|
|
427
|
+
if (env.ROUTINECODE_SKILL_PACKS === '0')
|
|
428
|
+
return { code: 'paused' };
|
|
429
|
+
if (!acquireLock(P))
|
|
430
|
+
return { code: 'locked' };
|
|
431
|
+
}
|
|
432
|
+
catch (e) {
|
|
433
|
+
return { code: 'error', message: String(e?.message ?? e).slice(0, 120) };
|
|
434
|
+
}
|
|
435
|
+
let changed = false;
|
|
436
|
+
try {
|
|
437
|
+
st = readState(P); // 잠금 안에서 다시 읽는다
|
|
438
|
+
const now = nowFn();
|
|
439
|
+
const keys = o.pubKeys ?? recordPubKeys();
|
|
440
|
+
if (st.pending)
|
|
441
|
+
changed = recoverPending(P, st) || changed;
|
|
442
|
+
// 만료 — 로컬만으로 판정(apiKey 없어도)
|
|
443
|
+
if (st.lastSuccessAt !== null && now - st.lastSuccessAt > EXPIRY_MS) {
|
|
444
|
+
const hadAny = Object.keys(st.installed).length > 0;
|
|
445
|
+
changed = removeManaged(P) || changed;
|
|
446
|
+
deleteArchives(P);
|
|
447
|
+
st.installed = {};
|
|
448
|
+
if (hadAny)
|
|
449
|
+
st.lastError = 'expired';
|
|
450
|
+
}
|
|
451
|
+
// 서버 확인(24시간 주기)
|
|
452
|
+
const cfg = o.syncConfig !== undefined ? o.syncConfig : readSyncConfig();
|
|
453
|
+
const due = o.force === true || st.lastCheckAt === null || now - st.lastCheckAt >= CHECK_INTERVAL_MS || now < st.lastCheckAt;
|
|
454
|
+
if (cfg && due) {
|
|
455
|
+
if (!keys) {
|
|
456
|
+
st.lastError = 'no-pubkeys';
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
let have = null;
|
|
460
|
+
for (const h of Object.values(st.highest))
|
|
461
|
+
if (loadArchive(P, h.sha, keys)) {
|
|
462
|
+
have = h.sha;
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
st.lastCheckAt = now;
|
|
466
|
+
const r = await fetchCurrent(cfg, clientVersionOf(o), have, o);
|
|
467
|
+
const d = r.data;
|
|
468
|
+
if (r.status !== 200 || !isObj(d)) {
|
|
469
|
+
st.lastError = r.status === 0 ? 'offline' : `http-${r.status}`;
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
if (Array.isArray(d.revoked)) {
|
|
473
|
+
const add = d.revoked.filter((s) => typeof s === 'string' && SHA_RE.test(s));
|
|
474
|
+
st.revoked = Array.from(new Set([...st.revoked, ...add])).slice(-REVOKED_KEEP);
|
|
475
|
+
}
|
|
476
|
+
if (d.status === 'pack') {
|
|
477
|
+
const v = verifyIncoming(d, keys, st, clientVersionOf(o));
|
|
478
|
+
if (typeof v === 'string') {
|
|
479
|
+
st.lastError = v;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
saveArchive(P, v);
|
|
483
|
+
st.highest[v.bundle.line] = { serial: v.bundle.serial, sha: v.sha256 };
|
|
484
|
+
st.lastSuccessAt = now;
|
|
485
|
+
st.lastError = null;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
else if (d.status === 'unchanged') {
|
|
489
|
+
if (have && (d.sha256 === undefined || d.sha256 === have)) {
|
|
490
|
+
st.lastSuccessAt = now;
|
|
491
|
+
st.lastError = null;
|
|
492
|
+
}
|
|
493
|
+
else
|
|
494
|
+
st.lastError = 'unchanged-without-have';
|
|
495
|
+
}
|
|
496
|
+
else if (d.status === 'none') {
|
|
497
|
+
st.lastError = null; // 설치본 유지 — 만료 시계는 갱신하지 않는다(§5.2 표)
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
st.lastError = 'malformed';
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
// 회수
|
|
506
|
+
for (const sha of st.revoked) {
|
|
507
|
+
for (const line of Object.keys(st.installed))
|
|
508
|
+
if (st.installed[line].sha === sha)
|
|
509
|
+
delete st.installed[line];
|
|
510
|
+
if (removeManaged(P, (m) => m.sha256 === sha))
|
|
511
|
+
changed = true;
|
|
512
|
+
deleteArchives(P, sha);
|
|
513
|
+
}
|
|
514
|
+
// 보관본과 설치본 맞추기(폴더 삭제·CLAUDE_CONFIG_DIR 변경·off→on·중단 복구)
|
|
515
|
+
for (const h of Object.values(st.highest)) {
|
|
516
|
+
if (st.revoked.includes(h.sha))
|
|
517
|
+
continue;
|
|
518
|
+
const a = loadArchive(P, h.sha, keys);
|
|
519
|
+
if (!a)
|
|
520
|
+
continue;
|
|
521
|
+
if (installedMatches(P, st, a.bundle))
|
|
522
|
+
continue;
|
|
523
|
+
if (Date.now() > deadline) {
|
|
524
|
+
st.lastError = 'budget-exceeded';
|
|
525
|
+
break;
|
|
526
|
+
} // 쓰기 전 단계 — 다음 실행이 이어 한다
|
|
527
|
+
installPack(P, st, a.bundle, o);
|
|
528
|
+
changed = true;
|
|
529
|
+
}
|
|
530
|
+
writeState(P, st);
|
|
531
|
+
return { code: changed ? 'changed' : 'unchanged' };
|
|
532
|
+
}
|
|
533
|
+
catch (e) {
|
|
534
|
+
try {
|
|
535
|
+
st = readState(P);
|
|
536
|
+
st.lastError = 'error:' + String(e?.message ?? e).slice(0, 120);
|
|
537
|
+
writeState(P, st);
|
|
538
|
+
}
|
|
539
|
+
catch { /* 무시 */ }
|
|
540
|
+
return { code: changed ? 'changed' : 'error', message: String(e?.message ?? e).slice(0, 120) };
|
|
541
|
+
}
|
|
542
|
+
finally {
|
|
543
|
+
releaseLock(P);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
// ── 사용자 제어 ─────────────────────────────────────────────────────
|
|
547
|
+
export async function turnOn(o = {}) {
|
|
548
|
+
const env = o.env ?? process.env;
|
|
549
|
+
const P = o.paths ?? skillPackPaths(env);
|
|
550
|
+
const st = readState(P);
|
|
551
|
+
st.enabled = true;
|
|
552
|
+
st.choice = 'on';
|
|
553
|
+
st.noticeShown = true;
|
|
554
|
+
st.onNoticeShown = true; // 직접 켰으면 안내가 필요 없다
|
|
555
|
+
writeState(P, st);
|
|
556
|
+
fs.mkdirSync(P.skillsDir, { recursive: true }); // 세션 시작 때 없던 skills 폴더는 감시되지 않는다(F9) — 먼저 만든다
|
|
557
|
+
return runSync({ ...o, paths: P, env, force: true });
|
|
558
|
+
}
|
|
559
|
+
export function turnOff(o = {}) {
|
|
560
|
+
const env = o.env ?? process.env;
|
|
561
|
+
const P = o.paths ?? skillPackPaths(env);
|
|
562
|
+
if (!acquireLock(P))
|
|
563
|
+
return { removed: false, locked: true };
|
|
564
|
+
try {
|
|
565
|
+
const st = readState(P);
|
|
566
|
+
const removed = removeManaged(P);
|
|
567
|
+
st.installed = {};
|
|
568
|
+
st.enabled = false;
|
|
569
|
+
st.choice = 'off';
|
|
570
|
+
st.noticeShown = true;
|
|
571
|
+
writeState(P, st);
|
|
572
|
+
return { removed, locked: false };
|
|
573
|
+
}
|
|
574
|
+
finally {
|
|
575
|
+
releaseLock(P);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
export function statusLines(o = {}) {
|
|
579
|
+
const env = o.env ?? process.env;
|
|
580
|
+
const P = o.paths ?? skillPackPaths(env);
|
|
581
|
+
const st = readState(P);
|
|
582
|
+
const iso = (t) => (t === null ? '-' : new Date(t).toISOString());
|
|
583
|
+
const out = [
|
|
584
|
+
`design skills: ${st.enabled ? 'on' : 'off'}${env.ROUTINECODE_SKILL_PACKS === '0' ? ' (sync paused: ROUTINECODE_SKILL_PACKS=0)' : ''}`,
|
|
585
|
+
`skills folder: ${P.skillsDir}`,
|
|
586
|
+
];
|
|
587
|
+
const lines = Object.keys(st.installed);
|
|
588
|
+
if (!lines.length)
|
|
589
|
+
out.push('installed: none');
|
|
590
|
+
for (const line of lines) {
|
|
591
|
+
const i = st.installed[line];
|
|
592
|
+
out.push(`installed [${line}]: serial ${i.serial}, sha ${i.sha.slice(0, 12)}…, ${i.dirs.join(', ') || '(no dirs)'}`);
|
|
593
|
+
}
|
|
594
|
+
for (const [line, h] of Object.entries(st.highest)) {
|
|
595
|
+
try {
|
|
596
|
+
const a = JSON.parse(fs.readFileSync(path.join(P.stateDir, `${h.sha}.json`), 'utf-8'));
|
|
597
|
+
out.push(`pack [${line}]: ${a.bundle.packId} v${a.bundle.version} (valid ${a.bundle.validFrom} ~ ${a.bundle.validTo})`);
|
|
598
|
+
const clash = unmanagedClashes(P, a.bundle);
|
|
599
|
+
if (clash.length)
|
|
600
|
+
out.push(`skipped (your own folders with the same name): ${clash.join(', ')}`);
|
|
601
|
+
}
|
|
602
|
+
catch { /* 보관본 없음 */ }
|
|
603
|
+
}
|
|
604
|
+
out.push(`last check: ${iso(st.lastCheckAt)}, last success: ${iso(st.lastSuccessAt)}`);
|
|
605
|
+
if (st.lastSuccessAt !== null && lines.length)
|
|
606
|
+
out.push(`expires if offline until: ${iso(st.lastSuccessAt + EXPIRY_MS)}`);
|
|
607
|
+
if (st.lastError)
|
|
608
|
+
out.push(`last error: ${st.lastError}`);
|
|
609
|
+
if (st.lastError?.startsWith('update-needed'))
|
|
610
|
+
out.push('update needed: a newer RoutineCode is required for the latest design skills (npm i -g @routinecrew/routinecode)');
|
|
611
|
+
return out;
|
|
612
|
+
}
|
|
613
|
+
const USAGE = 'usage: routinecode skills status | on | off | sync\n';
|
|
614
|
+
export async function main(argv, o = {}) {
|
|
615
|
+
const out = (s) => process.stdout.write(s + '\n');
|
|
616
|
+
switch (argv[0] ?? 'status') {
|
|
617
|
+
case 'status':
|
|
618
|
+
for (const l of statusLines(o))
|
|
619
|
+
out(l);
|
|
620
|
+
return 0;
|
|
621
|
+
case 'on': {
|
|
622
|
+
const r = await turnOn(o);
|
|
623
|
+
out(r.code === 'changed' ? 'Design skills installed.' : 'Design skills turned on.');
|
|
624
|
+
if (r.code === 'error' || r.code === 'locked')
|
|
625
|
+
out(`(sync: ${r.code}${r.message ? ' ' + r.message : ''} — will retry at the next session start)`);
|
|
626
|
+
for (const l of statusLines(o))
|
|
627
|
+
out(' ' + l);
|
|
628
|
+
if ((o.env ?? process.env).CLAUDECODE === '1' || r.code === 'changed')
|
|
629
|
+
out('If a Claude Code session is already open, run /reload-skills in it to load the skills.');
|
|
630
|
+
return 0;
|
|
631
|
+
}
|
|
632
|
+
case 'off': {
|
|
633
|
+
const r = turnOff(o);
|
|
634
|
+
out(r.locked ? 'Another session is updating the skills — try again in a moment.' : `Design skills turned off${r.removed ? ' and removed' : ''}.`);
|
|
635
|
+
return r.locked ? 1 : 0;
|
|
636
|
+
}
|
|
637
|
+
case 'sync': {
|
|
638
|
+
// session-start.sh 가 첫 줄을 읽는다: changed → reloadSkills(+처음 설치면 둘째 줄 안내), notice → 둘째 줄 안내
|
|
639
|
+
const r = await runSync(o);
|
|
640
|
+
out(r.code);
|
|
641
|
+
if ((r.code === 'notice' || r.code === 'changed') && r.message)
|
|
642
|
+
out(r.message);
|
|
643
|
+
return 0;
|
|
644
|
+
}
|
|
645
|
+
default:
|
|
646
|
+
process.stderr.write(USAGE);
|
|
647
|
+
return 2;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (process.argv[1] && /skill-pack[\\/]sync\.js$/.test(process.argv[1])) {
|
|
651
|
+
main(process.argv.slice(2)).then((code) => { process.exitCode = code; }).catch((e) => {
|
|
652
|
+
process.stderr.write(`skill-pack: ${e?.message ?? e}\n`);
|
|
653
|
+
process.exitCode = 0;
|
|
654
|
+
});
|
|
655
|
+
}
|