@bstage-sdk/ai-toolkit 0.6.0 → 0.6.1

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/dist/index.cjs CHANGED
@@ -31,6 +31,7 @@ __export(index_exports, {
31
31
  designGuideSection: () => designGuideSection,
32
32
  designMeta: () => meta,
33
33
  designRulesBrief: () => designRulesBrief,
34
+ extractManagedBlock: () => extractManagedBlock,
34
35
  freeRegionScaffold: () => freeRegionScaffold,
35
36
  parseAgentsIdentity: () => parseAgentsIdentity,
36
37
  planInstall: () => planInstall,
@@ -48,7 +49,7 @@ __export(index_exports, {
48
49
  module.exports = __toCommonJS(index_exports);
49
50
 
50
51
  // src/version.ts
51
- var VERSION = "0.6.0";
52
+ var VERSION = "0.6.1";
52
53
 
53
54
  // src/skills/deploy.ts
54
55
  function deploySkillMd() {
@@ -834,6 +835,12 @@ function agentsMdStatus(content) {
834
835
  if (v === null) return "legacy";
835
836
  return v < AGENTS_MANAGED_VERSION ? "stale" : "ok";
836
837
  }
838
+ function extractManagedBlock(content) {
839
+ const s = findMarker(content, START_TOKEN);
840
+ const e = findMarker(content, END_TOKEN);
841
+ if (!s || !e || e.end <= s.start) return null;
842
+ return content.slice(s.start, e.end);
843
+ }
837
844
  function swapManagedBlock(existing, newWrappedBlock) {
838
845
  const s = findMarker(existing, START_TOKEN);
839
846
  const e = findMarker(existing, END_TOKEN);
@@ -1195,6 +1202,8 @@ var CLAUDE_FILE = "CLAUDE.md";
1195
1202
  var LEGACY_NOTE = "\uAD00\uB9AC \uC601\uC5ED \uB9C8\uCEE4 \uC5C6\uC74C \u2014 bstage-migrate \uC2A4\uD0AC\uB85C reconcile";
1196
1203
  var HAND_EDIT_NOTE = "\uBC84\uC804\uC740 \uAC19\uC740\uB370 \uBCF8\uBB38\uC774 \uB2E4\uB985\uB2C8\uB2E4(\uC190\uC218\uC815) \u2014 SDK \uBCF8\uBB38\uC73C\uB85C \uB418\uB3CC\uB9AC\uACE0 \uAE30\uC874 \uBCF8\uBB38\uC740 SKILL.md.bak \uC73C\uB85C \uB0A8\uAE41\uB2C8\uB2E4. \uD504\uB85C\uC81D\uD2B8 \uACE0\uC720 \uADDC\uCE59\uC740 AGENTS.md \uC790\uC720 \uC601\uC5ED\uC5D0 \uC801\uC73C\uC138\uC694.";
1197
1204
  var NEWER_NOTE = "\uC124\uCE58\uBCF8\uC774 \uC774 toolkit\uBCF4\uB2E4 \uC0C8 \uBC84\uC804\uC785\uB2C8\uB2E4 \u2014 \uC774 CLI\uAC00 \uC624\uB798\uB3FC \uC61B \uBCF8\uBB38\uC73C\uB85C \uB418\uB3CC\uB9BD\uB2C8\uB2E4(\uD558\uD5A5). \uCD5C\uC2E0 CLI(npx @bstage-sdk/cli@latest ai update)\uB85C \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.";
1205
+ var KIND_DRIFT_NOTE = "\uAD00\uB9AC \uC601\uC5ED \uBC84\uC804\uC740 \uCD5C\uC2E0\uC778\uB370 \uBCF8\uBB38\uC774 \uC774 \uD504\uB85C\uC81D\uD2B8 \uC885\uB958\uC758 \uAC83\uACFC \uB2E4\uB985\uB2C8\uB2E4(\uC885\uB958\uAC00 \uBC14\uB00C\uC5C8\uAC70\uB098 \uAD00\uB9AC \uC601\uC5ED\uC744 \uC190\uC73C\uB85C \uACE0\uCE68) \u2014 \uD604\uC7AC \uC885\uB958\uC758 \uBCF8\uBB38\uC73C\uB85C \uAC31\uC2E0\uD569\uB2C8\uB2E4. \uC790\uC720 \uC601\uC5ED\uC740 \uBCF4\uC874\uB429\uB2C8\uB2E4.";
1206
+ var AGENTS_NEWER_NOTE = "AGENTS.md \uAD00\uB9AC \uC601\uC5ED\uC774 \uC774 toolkit\uBCF4\uB2E4 \uC0C8 \uBC84\uC804\uC785\uB2C8\uB2E4 \u2014 \uC774 CLI\uAC00 \uC624\uB798\uB3FC \uC61B \uBCF8\uBB38\uC73C\uB85C \uB418\uB3CC\uB9BD\uB2C8\uB2E4(\uD558\uD5A5). \uCD5C\uC2E0 CLI(npx @bstage-sdk/cli@latest ai update)\uB85C \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.";
1198
1207
  function planInstall(input) {
1199
1208
  const actions = [...planSkills(input), planAgentsMd(input), planClaudeMd(input.existing.claudeMd)];
1200
1209
  return [...actions].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
@@ -1247,7 +1256,6 @@ function planAgentsMd(input) {
1247
1256
  if (status === "legacy") {
1248
1257
  return { path: AGENTS_FILE, content: null, reason: "legacy", note: LEGACY_NOTE };
1249
1258
  }
1250
- if (status === "ok") return { path: AGENTS_FILE, content: null, reason: "keep" };
1251
1259
  const identity = parseAgentsIdentity(current);
1252
1260
  const block = renderManagedBlock({
1253
1261
  space: sanitizeIdentity(identity.space) ?? space,
@@ -1255,10 +1263,23 @@ function planAgentsMd(input) {
1255
1263
  target,
1256
1264
  kind
1257
1265
  });
1266
+ if (status === "ok" && extractManagedBlock(current) === block) {
1267
+ return { path: AGENTS_FILE, content: null, reason: "keep" };
1268
+ }
1258
1269
  const swapped = swapManagedBlock(current, block);
1259
1270
  if (swapped === null) {
1260
1271
  return { path: AGENTS_FILE, content: null, reason: "legacy", note: LEGACY_NOTE };
1261
1272
  }
1273
+ if (status === "ok") {
1274
+ const fileVersion = readManagedVersion(current);
1275
+ const newer = fileVersion !== null && fileVersion > AGENTS_MANAGED_VERSION;
1276
+ return {
1277
+ path: AGENTS_FILE,
1278
+ content: swapped,
1279
+ reason: "update",
1280
+ note: newer ? AGENTS_NEWER_NOTE : KIND_DRIFT_NOTE
1281
+ };
1282
+ }
1262
1283
  return { path: AGENTS_FILE, content: swapped, reason: "update" };
1263
1284
  }
1264
1285
  function planClaudeMd(current) {
@@ -1278,6 +1299,7 @@ function planClaudeMd(current) {
1278
1299
  designGuideSection,
1279
1300
  designMeta,
1280
1301
  designRulesBrief,
1302
+ extractManagedBlock,
1281
1303
  freeRegionScaffold,
1282
1304
  parseAgentsIdentity,
1283
1305
  planInstall,
package/dist/index.d.cts CHANGED
@@ -111,6 +111,12 @@ type AgentsMdStatus = 'missing' | 'legacy' | 'stale' | 'ok';
111
111
  declare function readManagedVersion(content: string): number | null;
112
112
  /** AGENTS.md 내용으로 갱신 상태를 판정한다. */
113
113
  declare function agentsMdStatus(content: string): Exclude<AgentsMdStatus, 'missing'>;
114
+ /**
115
+ * 기존 파일의 관리 영역(마커 포함, START~END)을 그대로 돌려준다. 마커가 없거나 순서가 어긋나면 null.
116
+ * `renderManagedBlock` 결과와 문자열로 비교해 "버전은 같은데 본문이 다른" 상태(레포 종류가 바뀐 뒤의
117
+ * 옛 kind 본문, 관리 영역 안 손수정)를 잡는 데 쓴다 — 버전 마커만 보면 이 둘은 `ok`로 보인다.
118
+ */
119
+ declare function extractManagedBlock(content: string): string | null;
114
120
  /**
115
121
  * 기존 파일의 관리 영역(START~END)을 새 블록으로 치환한다. START/END 바깥(자유 영역 등)은
116
122
  * 그대로 보존한다. 마커가 없으면(레거시) null을 반환 — 호출부가 reconcile 경로로 분기한다.
@@ -223,4 +229,4 @@ declare function designRulesBrief(target: DesignTarget): string;
223
229
  */
224
230
  declare function designGuideSection(target: DesignTarget): string;
225
231
 
226
- 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 };
232
+ 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, extractManagedBlock, freeRegionScaffold, parseAgentsIdentity, planInstall, readManagedVersion, readSkillStamp, renderManagedBlock, sanitizeIdentity, skillFilePath, skillStamp, skillsFor, swapManagedBlock, withStamp, wrapManaged };
package/dist/index.d.ts CHANGED
@@ -111,6 +111,12 @@ type AgentsMdStatus = 'missing' | 'legacy' | 'stale' | 'ok';
111
111
  declare function readManagedVersion(content: string): number | null;
112
112
  /** AGENTS.md 내용으로 갱신 상태를 판정한다. */
113
113
  declare function agentsMdStatus(content: string): Exclude<AgentsMdStatus, 'missing'>;
114
+ /**
115
+ * 기존 파일의 관리 영역(마커 포함, START~END)을 그대로 돌려준다. 마커가 없거나 순서가 어긋나면 null.
116
+ * `renderManagedBlock` 결과와 문자열로 비교해 "버전은 같은데 본문이 다른" 상태(레포 종류가 바뀐 뒤의
117
+ * 옛 kind 본문, 관리 영역 안 손수정)를 잡는 데 쓴다 — 버전 마커만 보면 이 둘은 `ok`로 보인다.
118
+ */
119
+ declare function extractManagedBlock(content: string): string | null;
114
120
  /**
115
121
  * 기존 파일의 관리 영역(START~END)을 새 블록으로 치환한다. START/END 바깥(자유 영역 등)은
116
122
  * 그대로 보존한다. 마커가 없으면(레거시) null을 반환 — 호출부가 reconcile 경로로 분기한다.
@@ -223,4 +229,4 @@ declare function designRulesBrief(target: DesignTarget): string;
223
229
  */
224
230
  declare function designGuideSection(target: DesignTarget): string;
225
231
 
226
- 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 };
232
+ 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, extractManagedBlock, freeRegionScaffold, parseAgentsIdentity, planInstall, readManagedVersion, readSkillStamp, renderManagedBlock, sanitizeIdentity, skillFilePath, skillStamp, skillsFor, swapManagedBlock, withStamp, wrapManaged };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.6.0";
2
+ var VERSION = "0.6.1";
3
3
 
4
4
  // src/skills/deploy.ts
5
5
  function deploySkillMd() {
@@ -785,6 +785,12 @@ function agentsMdStatus(content) {
785
785
  if (v === null) return "legacy";
786
786
  return v < AGENTS_MANAGED_VERSION ? "stale" : "ok";
787
787
  }
788
+ function extractManagedBlock(content) {
789
+ const s = findMarker(content, START_TOKEN);
790
+ const e = findMarker(content, END_TOKEN);
791
+ if (!s || !e || e.end <= s.start) return null;
792
+ return content.slice(s.start, e.end);
793
+ }
788
794
  function swapManagedBlock(existing, newWrappedBlock) {
789
795
  const s = findMarker(existing, START_TOKEN);
790
796
  const e = findMarker(existing, END_TOKEN);
@@ -1146,6 +1152,8 @@ var CLAUDE_FILE = "CLAUDE.md";
1146
1152
  var LEGACY_NOTE = "\uAD00\uB9AC \uC601\uC5ED \uB9C8\uCEE4 \uC5C6\uC74C \u2014 bstage-migrate \uC2A4\uD0AC\uB85C reconcile";
1147
1153
  var HAND_EDIT_NOTE = "\uBC84\uC804\uC740 \uAC19\uC740\uB370 \uBCF8\uBB38\uC774 \uB2E4\uB985\uB2C8\uB2E4(\uC190\uC218\uC815) \u2014 SDK \uBCF8\uBB38\uC73C\uB85C \uB418\uB3CC\uB9AC\uACE0 \uAE30\uC874 \uBCF8\uBB38\uC740 SKILL.md.bak \uC73C\uB85C \uB0A8\uAE41\uB2C8\uB2E4. \uD504\uB85C\uC81D\uD2B8 \uACE0\uC720 \uADDC\uCE59\uC740 AGENTS.md \uC790\uC720 \uC601\uC5ED\uC5D0 \uC801\uC73C\uC138\uC694.";
1148
1154
  var NEWER_NOTE = "\uC124\uCE58\uBCF8\uC774 \uC774 toolkit\uBCF4\uB2E4 \uC0C8 \uBC84\uC804\uC785\uB2C8\uB2E4 \u2014 \uC774 CLI\uAC00 \uC624\uB798\uB3FC \uC61B \uBCF8\uBB38\uC73C\uB85C \uB418\uB3CC\uB9BD\uB2C8\uB2E4(\uD558\uD5A5). \uCD5C\uC2E0 CLI(npx @bstage-sdk/cli@latest ai update)\uB85C \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.";
1155
+ var KIND_DRIFT_NOTE = "\uAD00\uB9AC \uC601\uC5ED \uBC84\uC804\uC740 \uCD5C\uC2E0\uC778\uB370 \uBCF8\uBB38\uC774 \uC774 \uD504\uB85C\uC81D\uD2B8 \uC885\uB958\uC758 \uAC83\uACFC \uB2E4\uB985\uB2C8\uB2E4(\uC885\uB958\uAC00 \uBC14\uB00C\uC5C8\uAC70\uB098 \uAD00\uB9AC \uC601\uC5ED\uC744 \uC190\uC73C\uB85C \uACE0\uCE68) \u2014 \uD604\uC7AC \uC885\uB958\uC758 \uBCF8\uBB38\uC73C\uB85C \uAC31\uC2E0\uD569\uB2C8\uB2E4. \uC790\uC720 \uC601\uC5ED\uC740 \uBCF4\uC874\uB429\uB2C8\uB2E4.";
1156
+ var AGENTS_NEWER_NOTE = "AGENTS.md \uAD00\uB9AC \uC601\uC5ED\uC774 \uC774 toolkit\uBCF4\uB2E4 \uC0C8 \uBC84\uC804\uC785\uB2C8\uB2E4 \u2014 \uC774 CLI\uAC00 \uC624\uB798\uB3FC \uC61B \uBCF8\uBB38\uC73C\uB85C \uB418\uB3CC\uB9BD\uB2C8\uB2E4(\uD558\uD5A5). \uCD5C\uC2E0 CLI(npx @bstage-sdk/cli@latest ai update)\uB85C \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.";
1149
1157
  function planInstall(input) {
1150
1158
  const actions = [...planSkills(input), planAgentsMd(input), planClaudeMd(input.existing.claudeMd)];
1151
1159
  return [...actions].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
@@ -1198,7 +1206,6 @@ function planAgentsMd(input) {
1198
1206
  if (status === "legacy") {
1199
1207
  return { path: AGENTS_FILE, content: null, reason: "legacy", note: LEGACY_NOTE };
1200
1208
  }
1201
- if (status === "ok") return { path: AGENTS_FILE, content: null, reason: "keep" };
1202
1209
  const identity = parseAgentsIdentity(current);
1203
1210
  const block = renderManagedBlock({
1204
1211
  space: sanitizeIdentity(identity.space) ?? space,
@@ -1206,10 +1213,23 @@ function planAgentsMd(input) {
1206
1213
  target,
1207
1214
  kind
1208
1215
  });
1216
+ if (status === "ok" && extractManagedBlock(current) === block) {
1217
+ return { path: AGENTS_FILE, content: null, reason: "keep" };
1218
+ }
1209
1219
  const swapped = swapManagedBlock(current, block);
1210
1220
  if (swapped === null) {
1211
1221
  return { path: AGENTS_FILE, content: null, reason: "legacy", note: LEGACY_NOTE };
1212
1222
  }
1223
+ if (status === "ok") {
1224
+ const fileVersion = readManagedVersion(current);
1225
+ const newer = fileVersion !== null && fileVersion > AGENTS_MANAGED_VERSION;
1226
+ return {
1227
+ path: AGENTS_FILE,
1228
+ content: swapped,
1229
+ reason: "update",
1230
+ note: newer ? AGENTS_NEWER_NOTE : KIND_DRIFT_NOTE
1231
+ };
1232
+ }
1213
1233
  return { path: AGENTS_FILE, content: swapped, reason: "update" };
1214
1234
  }
1215
1235
  function planClaudeMd(current) {
@@ -1228,6 +1248,7 @@ export {
1228
1248
  designGuideSection,
1229
1249
  meta as designMeta,
1230
1250
  designRulesBrief,
1251
+ extractManagedBlock,
1231
1252
  freeRegionScaffold,
1232
1253
  parseAgentsIdentity,
1233
1254
  planInstall,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bstage-sdk/ai-toolkit",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "bstage SDK ai-toolkit — 에이전트용 스킬·AGENTS.md 콘텐츠(cli가 소비)",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -34,7 +34,7 @@
34
34
  "@types/node": "^25.5.0",
35
35
  "tsup": "^8.0.0",
36
36
  "typescript": "^5.5.0",
37
- "@bstage-sdk/design": "0.6.0"
37
+ "@bstage-sdk/design": "0.6.1"
38
38
  },
39
39
  "license": "MIT",
40
40
  "scripts": {