@bstage-sdk/ai-toolkit 0.5.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/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/index.cjs +1212 -0
- package/dist/index.d.cts +217 -0
- package/dist/index.d.ts +217 -0
- package/dist/index.js +1162 -0
- package/package.json +44 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/** 번들에 심긴 ai-toolkit 버전. */
|
|
2
|
+
declare const VERSION: string;
|
|
3
|
+
|
|
4
|
+
/** 스킬이 설치되는 프로젝트 종류 — sdk 템플릿 프로젝트 / liquid 테마 프로젝트 */
|
|
5
|
+
type ProjectKind = 'sdk' | 'liquid';
|
|
6
|
+
/** 디자인 토큰 타깃 — 유저(유저 플랫폼) / 어드민(어드민 플랫폼) */
|
|
7
|
+
type DesignTarget = 'user' | 'admin';
|
|
8
|
+
/** 스킬 본문을 렌더링할 때 넘기는 프로젝트 맥락 */
|
|
9
|
+
interface SkillContext {
|
|
10
|
+
kind: ProjectKind;
|
|
11
|
+
target: DesignTarget;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 에이전트용 스킬 자산. `bstage init`(새 프로젝트 스캐폴드)과
|
|
15
|
+
* `bstage ai install`(기존 프로젝트 동기화)이 공유하는 단일 소스.
|
|
16
|
+
*
|
|
17
|
+
* 스킬을 추가하려면 여기에 한 줄 등록하면 두 경로 모두 자동 반영된다.
|
|
18
|
+
*/
|
|
19
|
+
interface BstageSkill {
|
|
20
|
+
/** `.claude/skills/<name>/SKILL.md` 디렉토리명 */
|
|
21
|
+
name: string;
|
|
22
|
+
/** 이 스킬이 설치되는 프로젝트 종류 */
|
|
23
|
+
kinds: ProjectKind[];
|
|
24
|
+
/** SKILL.md 본문 */
|
|
25
|
+
content: (ctx: SkillContext) => string;
|
|
26
|
+
}
|
|
27
|
+
declare const BSTAGE_SKILLS: BstageSkill[];
|
|
28
|
+
/** 해당 프로젝트 종류에 설치할 스킬만 골라낸다. */
|
|
29
|
+
declare function skillsFor(kind: ProjectKind): BstageSkill[];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 버전 문자열 비교 — a가 크면 1, 같으면 0, 작으면 -1. `major.minor.patch`의 숫자 자리만 보고
|
|
33
|
+
* 프리릴리즈 꼬리(`-beta.1`)는 무시한다. 숫자로 읽히지 않는 자리는 0으로 본다.
|
|
34
|
+
*/
|
|
35
|
+
declare function compareVersions(a: string, b: string): number;
|
|
36
|
+
/** 스탬프 한 줄. */
|
|
37
|
+
declare function skillStamp(version?: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* 스킬 본문의 frontmatter 바로 다음 줄에 버전 스탬프를 끼워 넣는다.
|
|
40
|
+
* frontmatter가 없으면 넣을 자리가 정해지지 않으므로 던진다(조용히 앞에 붙이면 frontmatter가 깨진다).
|
|
41
|
+
*/
|
|
42
|
+
declare function withStamp(body: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* 설치된 SKILL.md에서 스탬프 버전을 읽는다. 스탬프가 없으면 null(스탬프 도입 전 설치본).
|
|
45
|
+
*
|
|
46
|
+
* **자리를 고정해서 본다** — frontmatter를 닫는 `---` 다음의 첫 비어 있지 않은 줄만 후보로 삼고,
|
|
47
|
+
* 그 줄 전체가 스탬프일 때만 인정한다. 본문 어디서든 찾으면 스킬이 스탬프 형식을 예시로 인용하거나
|
|
48
|
+
* 사용자가 아래쪽에 옛 스탬프를 남겨 둔 것을 설치 버전으로 오독해, stale한 설치본이 최신으로 보인다.
|
|
49
|
+
*/
|
|
50
|
+
declare function readSkillStamp(content: string): string | null;
|
|
51
|
+
|
|
52
|
+
interface AgentsMdOptions {
|
|
53
|
+
space: string;
|
|
54
|
+
projectName: string;
|
|
55
|
+
/** 디자인 토큰 타깃(user/admin). 미지정 시 user. */
|
|
56
|
+
target?: DesignTarget;
|
|
57
|
+
/** 프로젝트 종류(sdk/liquid). 미지정 시 sdk. */
|
|
58
|
+
kind?: ProjectKind;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* SDK가 관리하는 AGENTS.md 본문(마커 미포함).
|
|
62
|
+
* 이 본문이 바뀌면 `agentsMdRegion.ts`의 `AGENTS_MANAGED_VERSION`을 올린다(doctor가 갱신 필요를 감지).
|
|
63
|
+
*
|
|
64
|
+
* `kind`로 프로젝트 종류를 가른다 — 기본은 `sdk`라 기존 호출부는 바뀌지 않는다.
|
|
65
|
+
*/
|
|
66
|
+
declare function agentsManagedBody({ space, projectName, target, kind, }: AgentsMdOptions): string;
|
|
67
|
+
/** SDK 관리 영역(마커 포함) 블록만 렌더링한다. ai install|update/migrate의 결정론적 치환에 쓴다. */
|
|
68
|
+
declare function renderManagedBlock(opts: AgentsMdOptions): string;
|
|
69
|
+
/**
|
|
70
|
+
* init이 생성하는 전체 AGENTS.md = 관리 영역(마커 포함) + 자유 영역 스캐폴드.
|
|
71
|
+
* 시그니처는 기존과 동일하므로 init.ts는 변경 불필요.
|
|
72
|
+
*/
|
|
73
|
+
declare function agentsMd(opts: AgentsMdOptions): string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* AGENTS.md의 "SDK 관리 영역(managed region)" 마커와 조작 유틸.
|
|
77
|
+
*
|
|
78
|
+
* AGENTS.md는 두 부분으로 나뉜다.
|
|
79
|
+
* - **관리 영역**: 마커(`BSTAGE:MANAGED:START`~`END`)로 감싼 SDK 저작 보일러플레이트.
|
|
80
|
+
* `bstage ai install|update` / `bstage-migrate` 스킬이 최신 템플릿으로 재생성하므로 직접 편집하면 안 된다.
|
|
81
|
+
* - **자유 영역**: 마커 바깥(주로 END 이후). 프로젝트 고유 규칙을 적는 곳으로, 갱신이 건드리지 않는다.
|
|
82
|
+
*
|
|
83
|
+
* 이 분리 덕에 마이그레이션은 "관리 영역만 결정론적으로 치환"하면 되고, 사용자 내용은 보존된다.
|
|
84
|
+
*/
|
|
85
|
+
/**
|
|
86
|
+
* 관리 영역 본문이 바뀔 때마다 올린다. doctor가 "마커는 있는데 버전이 낮다 → 갱신 필요"를
|
|
87
|
+
* 결정론적으로 판단하는 근거. (본문은 space/projectName로 파라미터화되므로 내용 직접 비교 대신
|
|
88
|
+
* 버전 토큰으로 staleness를 본다.)
|
|
89
|
+
*/
|
|
90
|
+
declare const AGENTS_MANAGED_VERSION = 13;
|
|
91
|
+
/** 본문을 관리 영역 마커로 감싼다. */
|
|
92
|
+
declare function wrapManaged(body: string): string;
|
|
93
|
+
/** init이 새 프로젝트에 까는 기본 자유 영역 스캐폴드(빈 섹션). */
|
|
94
|
+
declare function freeRegionScaffold(): string;
|
|
95
|
+
type AgentsMdStatus = 'missing' | 'legacy' | 'stale' | 'ok';
|
|
96
|
+
/**
|
|
97
|
+
* 관리 영역의 버전을 읽는다.
|
|
98
|
+
* - 마커 없음 → null (레거시: 마커 도입 전 파일)
|
|
99
|
+
* - 마커 있는데 v= 없음 → 0
|
|
100
|
+
* - v=N → N
|
|
101
|
+
*/
|
|
102
|
+
declare function readManagedVersion(content: string): number | null;
|
|
103
|
+
/** AGENTS.md 내용으로 갱신 상태를 판정한다. */
|
|
104
|
+
declare function agentsMdStatus(content: string): Exclude<AgentsMdStatus, 'missing'>;
|
|
105
|
+
/**
|
|
106
|
+
* 기존 파일의 관리 영역(START~END)을 새 블록으로 치환한다. START/END 바깥(자유 영역 등)은
|
|
107
|
+
* 그대로 보존한다. 마커가 없으면(레거시) null을 반환 — 호출부가 reconcile 경로로 분기한다.
|
|
108
|
+
*/
|
|
109
|
+
declare function swapManagedBlock(existing: string, newWrappedBlock: string): string | null;
|
|
110
|
+
/**
|
|
111
|
+
* 기존 AGENTS.md에서 프로젝트 정체성(space/projectName)을 파싱한다.
|
|
112
|
+
* 관리 영역을 새로 렌더링할 때 프로젝트 고유 값을 보존하기 위해 사용한다.
|
|
113
|
+
*/
|
|
114
|
+
declare function parseAgentsIdentity(content: string): {
|
|
115
|
+
space?: string;
|
|
116
|
+
projectName?: string;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
declare function claudeMd(): string;
|
|
120
|
+
|
|
121
|
+
/** 규칙에 맞으면 그대로, 아니면 null. */
|
|
122
|
+
declare function sanitizeIdentity(value: string | null | undefined): string | null;
|
|
123
|
+
|
|
124
|
+
/** 설치 계획을 세우는 데 필요한 프로젝트 상태 스냅샷. 파일 I/O는 호출부(CLI)가 한다. */
|
|
125
|
+
interface InstallInput {
|
|
126
|
+
kind: ProjectKind;
|
|
127
|
+
target: DesignTarget;
|
|
128
|
+
space: string;
|
|
129
|
+
projectName: string;
|
|
130
|
+
/** 스킬 디렉터리 기준 경로(기본 '.claude/skills') */
|
|
131
|
+
skillsDir: string;
|
|
132
|
+
existing: {
|
|
133
|
+
/**
|
|
134
|
+
* 스킬명 → 설치된 `SKILL.md`의 **파일 전체 내용**(파일이 없으면 키를 넣지 않는다).
|
|
135
|
+
* 스탬프만 받으면 손으로 고친 본문이 최신 스탬프를 달고 keep으로 새어 나간다.
|
|
136
|
+
*/
|
|
137
|
+
skills: Record<string, string>;
|
|
138
|
+
/** AGENTS.md 파일 내용, 없으면 null */
|
|
139
|
+
agentsMd: string | null;
|
|
140
|
+
/** CLAUDE.md 파일 내용, 없으면 null */
|
|
141
|
+
claudeMd: string | null;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 액션의 이유.
|
|
146
|
+
* - `create` 없던 파일을 만든다 · `update` 기존 파일의 일부를 치환한다
|
|
147
|
+
* - `stale` 설치본이 현재 본문과 달라 통째로 다시 쓴다(옛 버전 또는 손수정) · `keep` 손대지 않는다
|
|
148
|
+
* - `legacy` 판단이 필요해 자동으로 건드리지 않는다(안내만)
|
|
149
|
+
*/
|
|
150
|
+
type ActionReason = 'create' | 'update' | 'stale' | 'keep' | 'legacy';
|
|
151
|
+
interface InstallAction {
|
|
152
|
+
/** 프로젝트 루트 기준 상대 경로 */
|
|
153
|
+
path: string;
|
|
154
|
+
/** 쓸 내용. null이면 쓰지 않는다(keep·legacy). */
|
|
155
|
+
content: string | null;
|
|
156
|
+
reason: ActionReason;
|
|
157
|
+
/** 사용자에게 알릴 한 줄(있을 때만) */
|
|
158
|
+
note?: string;
|
|
159
|
+
/** 덮기 전에 기존 파일을 `.bak`으로 남긴다 — 손수정 본문이 흔적 없이 사라지지 않게. */
|
|
160
|
+
backup?: boolean;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 설치·갱신할 파일 목록을 정한다. 순수 함수 — 파일을 읽지도 쓰지도 않는다.
|
|
164
|
+
*
|
|
165
|
+
* 이 함수가 유일한 판단 지점이다. `bstage ai install`·`update`·`doctor`가 모두 같은 계획을
|
|
166
|
+
* 만들고 소비만 다르게 하므로, "doctor는 ok인데 install은 덮어쓴다" 같은 어긋남이 생기지 않는다.
|
|
167
|
+
*/
|
|
168
|
+
declare function planInstall(input: InstallInput): InstallAction[];
|
|
169
|
+
/** `${skillsDir}/${name}/SKILL.md` — 경로 규약은 여기 한 곳. */
|
|
170
|
+
declare function skillFilePath(skillsDir: string, name: string): string;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* bstage 디자인 토큰 가이드 생성기.
|
|
174
|
+
*
|
|
175
|
+
* `bstage init` / `bstage ai install`이 생성하는 에이전트 문서(AGENTS.md 관리 영역,
|
|
176
|
+
* bstage-template 스킬)에 삽입할 "디자인 토큰 사용 규칙"을 타깃별(user/admin)로 렌더링한다.
|
|
177
|
+
*
|
|
178
|
+
* 목적: 바이브코딩 에이전트가 색·타이포·그림자를 임의 값으로 하드코딩하지 않고
|
|
179
|
+
* `@bstage-sdk/design`의 토큰만 쓰도록("이 토큰만·이 스케일만") 유도한다.
|
|
180
|
+
*
|
|
181
|
+
* - 값은 플랫폼이 런타임에 `:root`로 주입하고, 로컬은 `bstage dev`가 fallback을 주입한다.
|
|
182
|
+
* - 정확한 토큰 키 목록은 설치된 `.d.ts`를 SSOT로 두고 여기엔 규칙·카테고리·예시만 담는다(drift 방지).
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/** @internal 테스트에서 예시 키를 실제 design 토큰과 대조하기 위해 노출. public API 아님. */
|
|
186
|
+
interface TargetMeta {
|
|
187
|
+
/** 서브패스 import 경로 */
|
|
188
|
+
pkg: string;
|
|
189
|
+
/** CSS 변수 접두사 (var(--<prefix>-...)) */
|
|
190
|
+
prefix: string;
|
|
191
|
+
/** 색 토큰 예시 (중첩 트리 접근) */
|
|
192
|
+
colorExample: string;
|
|
193
|
+
/** cssVar() 예시 slug */
|
|
194
|
+
cssVarExample: string;
|
|
195
|
+
/** textStyle() 예시 토큰 */
|
|
196
|
+
textStyleExample: string;
|
|
197
|
+
/** shadow 예시 키 */
|
|
198
|
+
shadowExample: string;
|
|
199
|
+
/** 테마(다크모드) 안내 */
|
|
200
|
+
themeNote: string;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* @internal 타깃별 예시 값 표. 여기 적은 키가 실제 `@bstage-sdk/design` 토큰에
|
|
204
|
+
* 존재하지 않으면 에이전트가 문서를 그대로 베껴 쓰는 순간 조용히 깨지므로, 테스트가 대조한다.
|
|
205
|
+
*/
|
|
206
|
+
declare function meta(target: DesignTarget): TargetMeta;
|
|
207
|
+
/**
|
|
208
|
+
* AGENTS.md 관리 영역용 — 항상 켜져 있는 간결한 규칙 블록.
|
|
209
|
+
* (상세 코드 예시는 bstage-template 스킬의 `designGuideSection`에 둔다)
|
|
210
|
+
*/
|
|
211
|
+
declare function designRulesBrief(target: DesignTarget): string;
|
|
212
|
+
/**
|
|
213
|
+
* bstage-template 스킬용 — 코드 예시 포함 상세 절차 본문(헤딩은 호출부가 붙인다).
|
|
214
|
+
*/
|
|
215
|
+
declare function designGuideSection(target: DesignTarget): string;
|
|
216
|
+
|
|
217
|
+
export { AGENTS_MANAGED_VERSION, type ActionReason, type AgentsMdStatus, BSTAGE_SKILLS, type BstageSkill, type DesignTarget, type InstallAction, type InstallInput, type ProjectKind, type SkillContext, VERSION, agentsManagedBody, agentsMd, agentsMdStatus, claudeMd, compareVersions, designGuideSection, meta as designMeta, designRulesBrief, freeRegionScaffold, parseAgentsIdentity, planInstall, readManagedVersion, readSkillStamp, renderManagedBlock, sanitizeIdentity, skillFilePath, skillStamp, skillsFor, swapManagedBlock, withStamp, wrapManaged };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/** 번들에 심긴 ai-toolkit 버전. */
|
|
2
|
+
declare const VERSION: string;
|
|
3
|
+
|
|
4
|
+
/** 스킬이 설치되는 프로젝트 종류 — sdk 템플릿 프로젝트 / liquid 테마 프로젝트 */
|
|
5
|
+
type ProjectKind = 'sdk' | 'liquid';
|
|
6
|
+
/** 디자인 토큰 타깃 — 유저(유저 플랫폼) / 어드민(어드민 플랫폼) */
|
|
7
|
+
type DesignTarget = 'user' | 'admin';
|
|
8
|
+
/** 스킬 본문을 렌더링할 때 넘기는 프로젝트 맥락 */
|
|
9
|
+
interface SkillContext {
|
|
10
|
+
kind: ProjectKind;
|
|
11
|
+
target: DesignTarget;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 에이전트용 스킬 자산. `bstage init`(새 프로젝트 스캐폴드)과
|
|
15
|
+
* `bstage ai install`(기존 프로젝트 동기화)이 공유하는 단일 소스.
|
|
16
|
+
*
|
|
17
|
+
* 스킬을 추가하려면 여기에 한 줄 등록하면 두 경로 모두 자동 반영된다.
|
|
18
|
+
*/
|
|
19
|
+
interface BstageSkill {
|
|
20
|
+
/** `.claude/skills/<name>/SKILL.md` 디렉토리명 */
|
|
21
|
+
name: string;
|
|
22
|
+
/** 이 스킬이 설치되는 프로젝트 종류 */
|
|
23
|
+
kinds: ProjectKind[];
|
|
24
|
+
/** SKILL.md 본문 */
|
|
25
|
+
content: (ctx: SkillContext) => string;
|
|
26
|
+
}
|
|
27
|
+
declare const BSTAGE_SKILLS: BstageSkill[];
|
|
28
|
+
/** 해당 프로젝트 종류에 설치할 스킬만 골라낸다. */
|
|
29
|
+
declare function skillsFor(kind: ProjectKind): BstageSkill[];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 버전 문자열 비교 — a가 크면 1, 같으면 0, 작으면 -1. `major.minor.patch`의 숫자 자리만 보고
|
|
33
|
+
* 프리릴리즈 꼬리(`-beta.1`)는 무시한다. 숫자로 읽히지 않는 자리는 0으로 본다.
|
|
34
|
+
*/
|
|
35
|
+
declare function compareVersions(a: string, b: string): number;
|
|
36
|
+
/** 스탬프 한 줄. */
|
|
37
|
+
declare function skillStamp(version?: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* 스킬 본문의 frontmatter 바로 다음 줄에 버전 스탬프를 끼워 넣는다.
|
|
40
|
+
* frontmatter가 없으면 넣을 자리가 정해지지 않으므로 던진다(조용히 앞에 붙이면 frontmatter가 깨진다).
|
|
41
|
+
*/
|
|
42
|
+
declare function withStamp(body: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* 설치된 SKILL.md에서 스탬프 버전을 읽는다. 스탬프가 없으면 null(스탬프 도입 전 설치본).
|
|
45
|
+
*
|
|
46
|
+
* **자리를 고정해서 본다** — frontmatter를 닫는 `---` 다음의 첫 비어 있지 않은 줄만 후보로 삼고,
|
|
47
|
+
* 그 줄 전체가 스탬프일 때만 인정한다. 본문 어디서든 찾으면 스킬이 스탬프 형식을 예시로 인용하거나
|
|
48
|
+
* 사용자가 아래쪽에 옛 스탬프를 남겨 둔 것을 설치 버전으로 오독해, stale한 설치본이 최신으로 보인다.
|
|
49
|
+
*/
|
|
50
|
+
declare function readSkillStamp(content: string): string | null;
|
|
51
|
+
|
|
52
|
+
interface AgentsMdOptions {
|
|
53
|
+
space: string;
|
|
54
|
+
projectName: string;
|
|
55
|
+
/** 디자인 토큰 타깃(user/admin). 미지정 시 user. */
|
|
56
|
+
target?: DesignTarget;
|
|
57
|
+
/** 프로젝트 종류(sdk/liquid). 미지정 시 sdk. */
|
|
58
|
+
kind?: ProjectKind;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* SDK가 관리하는 AGENTS.md 본문(마커 미포함).
|
|
62
|
+
* 이 본문이 바뀌면 `agentsMdRegion.ts`의 `AGENTS_MANAGED_VERSION`을 올린다(doctor가 갱신 필요를 감지).
|
|
63
|
+
*
|
|
64
|
+
* `kind`로 프로젝트 종류를 가른다 — 기본은 `sdk`라 기존 호출부는 바뀌지 않는다.
|
|
65
|
+
*/
|
|
66
|
+
declare function agentsManagedBody({ space, projectName, target, kind, }: AgentsMdOptions): string;
|
|
67
|
+
/** SDK 관리 영역(마커 포함) 블록만 렌더링한다. ai install|update/migrate의 결정론적 치환에 쓴다. */
|
|
68
|
+
declare function renderManagedBlock(opts: AgentsMdOptions): string;
|
|
69
|
+
/**
|
|
70
|
+
* init이 생성하는 전체 AGENTS.md = 관리 영역(마커 포함) + 자유 영역 스캐폴드.
|
|
71
|
+
* 시그니처는 기존과 동일하므로 init.ts는 변경 불필요.
|
|
72
|
+
*/
|
|
73
|
+
declare function agentsMd(opts: AgentsMdOptions): string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* AGENTS.md의 "SDK 관리 영역(managed region)" 마커와 조작 유틸.
|
|
77
|
+
*
|
|
78
|
+
* AGENTS.md는 두 부분으로 나뉜다.
|
|
79
|
+
* - **관리 영역**: 마커(`BSTAGE:MANAGED:START`~`END`)로 감싼 SDK 저작 보일러플레이트.
|
|
80
|
+
* `bstage ai install|update` / `bstage-migrate` 스킬이 최신 템플릿으로 재생성하므로 직접 편집하면 안 된다.
|
|
81
|
+
* - **자유 영역**: 마커 바깥(주로 END 이후). 프로젝트 고유 규칙을 적는 곳으로, 갱신이 건드리지 않는다.
|
|
82
|
+
*
|
|
83
|
+
* 이 분리 덕에 마이그레이션은 "관리 영역만 결정론적으로 치환"하면 되고, 사용자 내용은 보존된다.
|
|
84
|
+
*/
|
|
85
|
+
/**
|
|
86
|
+
* 관리 영역 본문이 바뀔 때마다 올린다. doctor가 "마커는 있는데 버전이 낮다 → 갱신 필요"를
|
|
87
|
+
* 결정론적으로 판단하는 근거. (본문은 space/projectName로 파라미터화되므로 내용 직접 비교 대신
|
|
88
|
+
* 버전 토큰으로 staleness를 본다.)
|
|
89
|
+
*/
|
|
90
|
+
declare const AGENTS_MANAGED_VERSION = 13;
|
|
91
|
+
/** 본문을 관리 영역 마커로 감싼다. */
|
|
92
|
+
declare function wrapManaged(body: string): string;
|
|
93
|
+
/** init이 새 프로젝트에 까는 기본 자유 영역 스캐폴드(빈 섹션). */
|
|
94
|
+
declare function freeRegionScaffold(): string;
|
|
95
|
+
type AgentsMdStatus = 'missing' | 'legacy' | 'stale' | 'ok';
|
|
96
|
+
/**
|
|
97
|
+
* 관리 영역의 버전을 읽는다.
|
|
98
|
+
* - 마커 없음 → null (레거시: 마커 도입 전 파일)
|
|
99
|
+
* - 마커 있는데 v= 없음 → 0
|
|
100
|
+
* - v=N → N
|
|
101
|
+
*/
|
|
102
|
+
declare function readManagedVersion(content: string): number | null;
|
|
103
|
+
/** AGENTS.md 내용으로 갱신 상태를 판정한다. */
|
|
104
|
+
declare function agentsMdStatus(content: string): Exclude<AgentsMdStatus, 'missing'>;
|
|
105
|
+
/**
|
|
106
|
+
* 기존 파일의 관리 영역(START~END)을 새 블록으로 치환한다. START/END 바깥(자유 영역 등)은
|
|
107
|
+
* 그대로 보존한다. 마커가 없으면(레거시) null을 반환 — 호출부가 reconcile 경로로 분기한다.
|
|
108
|
+
*/
|
|
109
|
+
declare function swapManagedBlock(existing: string, newWrappedBlock: string): string | null;
|
|
110
|
+
/**
|
|
111
|
+
* 기존 AGENTS.md에서 프로젝트 정체성(space/projectName)을 파싱한다.
|
|
112
|
+
* 관리 영역을 새로 렌더링할 때 프로젝트 고유 값을 보존하기 위해 사용한다.
|
|
113
|
+
*/
|
|
114
|
+
declare function parseAgentsIdentity(content: string): {
|
|
115
|
+
space?: string;
|
|
116
|
+
projectName?: string;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
declare function claudeMd(): string;
|
|
120
|
+
|
|
121
|
+
/** 규칙에 맞으면 그대로, 아니면 null. */
|
|
122
|
+
declare function sanitizeIdentity(value: string | null | undefined): string | null;
|
|
123
|
+
|
|
124
|
+
/** 설치 계획을 세우는 데 필요한 프로젝트 상태 스냅샷. 파일 I/O는 호출부(CLI)가 한다. */
|
|
125
|
+
interface InstallInput {
|
|
126
|
+
kind: ProjectKind;
|
|
127
|
+
target: DesignTarget;
|
|
128
|
+
space: string;
|
|
129
|
+
projectName: string;
|
|
130
|
+
/** 스킬 디렉터리 기준 경로(기본 '.claude/skills') */
|
|
131
|
+
skillsDir: string;
|
|
132
|
+
existing: {
|
|
133
|
+
/**
|
|
134
|
+
* 스킬명 → 설치된 `SKILL.md`의 **파일 전체 내용**(파일이 없으면 키를 넣지 않는다).
|
|
135
|
+
* 스탬프만 받으면 손으로 고친 본문이 최신 스탬프를 달고 keep으로 새어 나간다.
|
|
136
|
+
*/
|
|
137
|
+
skills: Record<string, string>;
|
|
138
|
+
/** AGENTS.md 파일 내용, 없으면 null */
|
|
139
|
+
agentsMd: string | null;
|
|
140
|
+
/** CLAUDE.md 파일 내용, 없으면 null */
|
|
141
|
+
claudeMd: string | null;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 액션의 이유.
|
|
146
|
+
* - `create` 없던 파일을 만든다 · `update` 기존 파일의 일부를 치환한다
|
|
147
|
+
* - `stale` 설치본이 현재 본문과 달라 통째로 다시 쓴다(옛 버전 또는 손수정) · `keep` 손대지 않는다
|
|
148
|
+
* - `legacy` 판단이 필요해 자동으로 건드리지 않는다(안내만)
|
|
149
|
+
*/
|
|
150
|
+
type ActionReason = 'create' | 'update' | 'stale' | 'keep' | 'legacy';
|
|
151
|
+
interface InstallAction {
|
|
152
|
+
/** 프로젝트 루트 기준 상대 경로 */
|
|
153
|
+
path: string;
|
|
154
|
+
/** 쓸 내용. null이면 쓰지 않는다(keep·legacy). */
|
|
155
|
+
content: string | null;
|
|
156
|
+
reason: ActionReason;
|
|
157
|
+
/** 사용자에게 알릴 한 줄(있을 때만) */
|
|
158
|
+
note?: string;
|
|
159
|
+
/** 덮기 전에 기존 파일을 `.bak`으로 남긴다 — 손수정 본문이 흔적 없이 사라지지 않게. */
|
|
160
|
+
backup?: boolean;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 설치·갱신할 파일 목록을 정한다. 순수 함수 — 파일을 읽지도 쓰지도 않는다.
|
|
164
|
+
*
|
|
165
|
+
* 이 함수가 유일한 판단 지점이다. `bstage ai install`·`update`·`doctor`가 모두 같은 계획을
|
|
166
|
+
* 만들고 소비만 다르게 하므로, "doctor는 ok인데 install은 덮어쓴다" 같은 어긋남이 생기지 않는다.
|
|
167
|
+
*/
|
|
168
|
+
declare function planInstall(input: InstallInput): InstallAction[];
|
|
169
|
+
/** `${skillsDir}/${name}/SKILL.md` — 경로 규약은 여기 한 곳. */
|
|
170
|
+
declare function skillFilePath(skillsDir: string, name: string): string;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* bstage 디자인 토큰 가이드 생성기.
|
|
174
|
+
*
|
|
175
|
+
* `bstage init` / `bstage ai install`이 생성하는 에이전트 문서(AGENTS.md 관리 영역,
|
|
176
|
+
* bstage-template 스킬)에 삽입할 "디자인 토큰 사용 규칙"을 타깃별(user/admin)로 렌더링한다.
|
|
177
|
+
*
|
|
178
|
+
* 목적: 바이브코딩 에이전트가 색·타이포·그림자를 임의 값으로 하드코딩하지 않고
|
|
179
|
+
* `@bstage-sdk/design`의 토큰만 쓰도록("이 토큰만·이 스케일만") 유도한다.
|
|
180
|
+
*
|
|
181
|
+
* - 값은 플랫폼이 런타임에 `:root`로 주입하고, 로컬은 `bstage dev`가 fallback을 주입한다.
|
|
182
|
+
* - 정확한 토큰 키 목록은 설치된 `.d.ts`를 SSOT로 두고 여기엔 규칙·카테고리·예시만 담는다(drift 방지).
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/** @internal 테스트에서 예시 키를 실제 design 토큰과 대조하기 위해 노출. public API 아님. */
|
|
186
|
+
interface TargetMeta {
|
|
187
|
+
/** 서브패스 import 경로 */
|
|
188
|
+
pkg: string;
|
|
189
|
+
/** CSS 변수 접두사 (var(--<prefix>-...)) */
|
|
190
|
+
prefix: string;
|
|
191
|
+
/** 색 토큰 예시 (중첩 트리 접근) */
|
|
192
|
+
colorExample: string;
|
|
193
|
+
/** cssVar() 예시 slug */
|
|
194
|
+
cssVarExample: string;
|
|
195
|
+
/** textStyle() 예시 토큰 */
|
|
196
|
+
textStyleExample: string;
|
|
197
|
+
/** shadow 예시 키 */
|
|
198
|
+
shadowExample: string;
|
|
199
|
+
/** 테마(다크모드) 안내 */
|
|
200
|
+
themeNote: string;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* @internal 타깃별 예시 값 표. 여기 적은 키가 실제 `@bstage-sdk/design` 토큰에
|
|
204
|
+
* 존재하지 않으면 에이전트가 문서를 그대로 베껴 쓰는 순간 조용히 깨지므로, 테스트가 대조한다.
|
|
205
|
+
*/
|
|
206
|
+
declare function meta(target: DesignTarget): TargetMeta;
|
|
207
|
+
/**
|
|
208
|
+
* AGENTS.md 관리 영역용 — 항상 켜져 있는 간결한 규칙 블록.
|
|
209
|
+
* (상세 코드 예시는 bstage-template 스킬의 `designGuideSection`에 둔다)
|
|
210
|
+
*/
|
|
211
|
+
declare function designRulesBrief(target: DesignTarget): string;
|
|
212
|
+
/**
|
|
213
|
+
* bstage-template 스킬용 — 코드 예시 포함 상세 절차 본문(헤딩은 호출부가 붙인다).
|
|
214
|
+
*/
|
|
215
|
+
declare function designGuideSection(target: DesignTarget): string;
|
|
216
|
+
|
|
217
|
+
export { AGENTS_MANAGED_VERSION, type ActionReason, type AgentsMdStatus, BSTAGE_SKILLS, type BstageSkill, type DesignTarget, type InstallAction, type InstallInput, type ProjectKind, type SkillContext, VERSION, agentsManagedBody, agentsMd, agentsMdStatus, claudeMd, compareVersions, designGuideSection, meta as designMeta, designRulesBrief, freeRegionScaffold, parseAgentsIdentity, planInstall, readManagedVersion, readSkillStamp, renderManagedBlock, sanitizeIdentity, skillFilePath, skillStamp, skillsFor, swapManagedBlock, withStamp, wrapManaged };
|