@yoonion/mimi-seed-mcp 0.23.2 → 0.23.3

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,72 @@
1
+ import { resolveAppStoreVersionBuild, selectAppStoreVersionForStatus } from '../appstore/release-target.js';
2
+ import { requirePlayStoreAuth } from '../helpers.js';
3
+ import { listTracks } from '../playstore/tools.js';
4
+ async function readAppStoreStatus(appId, version, platform) {
5
+ const selection = await selectAppStoreVersionForStatus(appId, version, platform);
6
+ if (selection.status === 'missing')
7
+ return { found: false };
8
+ if (selection.status === 'ambiguous') {
9
+ return { error: '일치하는 App Store 버전이 여러 개입니다. appStorePlatform을 지정하거나 버전 ID로 appstore_release_status를 호출하세요.' };
10
+ }
11
+ if (selection.status === 'incomplete') {
12
+ return { error: 'App Store 버전 목록이 불완전하여 대상을 확인할 수 없습니다.' };
13
+ }
14
+ const selected = selection.version;
15
+ const attachedBuild = await resolveAppStoreVersionBuild(selected);
16
+ return {
17
+ versionId: selected.id,
18
+ version: selected.versionString,
19
+ platform: selected.platform,
20
+ state: selected.appStoreState ?? selected.state,
21
+ releaseType: selected.releaseType,
22
+ createdDate: selected.createdDate,
23
+ attachedBuild,
24
+ // Keep the legacy array shape for clients reading build details from its first entry.
25
+ recentBuilds: 'id' in attachedBuild ? [{
26
+ id: attachedBuild.id,
27
+ buildNumber: attachedBuild.buildNumber,
28
+ processingState: attachedBuild.processingState,
29
+ }] : [],
30
+ };
31
+ }
32
+ async function readPlayStoreStatus(packageName, version, versionCode) {
33
+ const auth = await requirePlayStoreAuth(packageName);
34
+ const tracks = await listTracks(auth, packageName);
35
+ const code = versionCode ?? version;
36
+ const byTrack = Object.fromEntries(tracks.flatMap(({ track, releases }) => {
37
+ const byCode = releases.filter((release) => code !== undefined && release.versionCodes?.includes(code));
38
+ const byName = version === undefined ? [] : releases.filter((release) => release.name === version);
39
+ const matches = versionCode ? byCode
40
+ : byName.length > 0 ? byName
41
+ : byCode.length > 0 ? byCode
42
+ : releases.filter((release) => version !== undefined && release.name?.startsWith(`${version} `));
43
+ const matchingReleases = matches.map((match) => ({
44
+ releaseName: match.name,
45
+ status: match.status,
46
+ versionCodes: match.versionCodes,
47
+ }));
48
+ if (matchingReleases.length === 0)
49
+ return [];
50
+ const result = matchingReleases.length === 1
51
+ ? matchingReleases[0]
52
+ : { ambiguous: true, matches: matchingReleases };
53
+ return [[track ?? 'unknown', result]];
54
+ }));
55
+ return Object.keys(byTrack).length > 0 ? byTrack : {
56
+ found: false,
57
+ available: tracks.map(({ track, releases }) => ({
58
+ track,
59
+ releases: releases.map(({ name, status }) => ({ name, status })),
60
+ })),
61
+ };
62
+ }
63
+ function storeError(error) {
64
+ return { error: error instanceof Error ? error.message : String(error) };
65
+ }
66
+ export async function getReleaseStatus({ version, appId, appStorePlatform, packageName, versionCode }) {
67
+ const [appStore, playStore] = await Promise.all([
68
+ appId && version ? readAppStoreStatus(appId, version, appStorePlatform).catch(storeError) : null,
69
+ packageName ? readPlayStoreStatus(packageName, version, versionCode).catch(storeError) : null,
70
+ ]);
71
+ return { version, versionCode, appStore, playStore };
72
+ }
@@ -1,31 +1,47 @@
1
1
  import type { OAuth2Client } from 'google-auth-library';
2
2
  import type { androidpublisher_v3 } from '@googleapis/androidpublisher';
3
- import { type AppStoreBuildReadiness, type AppStoreVersionCandidate } from '../appstore/release-target.js';
4
- export type RiskLevel = 'blocker' | 'warning' | 'info';
5
- export interface SubmissionRisk {
6
- level: RiskLevel;
7
- code: string;
8
- title: string;
9
- detail: string;
10
- fixUrl?: string;
11
- }
12
- export declare function isRiskCheckIncomplete(risk: SubmissionRisk): boolean;
3
+ import type { AppStoreBuildReadiness, AppStoreVersionCandidate } from '../appstore/release-target.js';
4
+ import { type SubmissionRisk } from './release-readiness.js';
5
+ export declare function findPlayTargetReleases(tracks: readonly androidpublisher_v3.Schema$Track[], target: {
6
+ track: string;
7
+ versionCode: string;
8
+ }): androidpublisher_v3.Schema$TrackRelease[];
13
9
  export declare function checkPlayStoreRisks(auth: OAuth2Client, packageName: string, language?: string, target?: {
14
10
  track: string;
15
11
  versionCode: string;
16
- }): Promise<SubmissionRisk[]>;
12
+ }): Promise<{
13
+ target: {
14
+ store: "playstore";
15
+ packageName: string;
16
+ track?: string | undefined;
17
+ versionCode?: string | undefined;
18
+ } | {
19
+ store: "appstore";
20
+ appId: string;
21
+ versionId?: string | undefined;
22
+ versionString?: string | undefined;
23
+ platform?: "IOS" | "MAC_OS" | "TV_OS" | "VISION_OS" | undefined;
24
+ };
25
+ targetVerified: boolean;
26
+ checkStatus: "incomplete" | "complete";
27
+ canSubmit: boolean;
28
+ blockingCodes: string[];
29
+ risks: {
30
+ level: "warning" | "blocker" | "info";
31
+ code: string;
32
+ title: string;
33
+ detail: string;
34
+ fixUrl?: string | undefined;
35
+ }[];
36
+ }>;
17
37
  export declare function checkPlayStoreRisksInEdit(auth: OAuth2Client, packageName: string, editId: string, language: string, target?: {
18
38
  track: string;
19
39
  versionCode: string;
20
40
  }, tracksSnapshot?: readonly androidpublisher_v3.Schema$Track[]): Promise<SubmissionRisk[]>;
21
- type AppStorePolicy = {
41
+ export type AppStorePolicy = {
22
42
  socialMedia?: boolean;
23
43
  socialMediaAgeRestricted?: boolean;
24
44
  };
25
45
  export declare function appStoreBuildRisk(build: AppStoreBuildReadiness): SubmissionRisk | undefined;
26
- export declare function checkAppStoreRisks(appId: string, expected?: AppStorePolicy & {
27
- versionId?: string;
28
- }): Promise<SubmissionRisk[]>;
29
46
  export declare function checkAppStoreVersionRisks(appId: string, { id: selectedVersionId, platform }: Pick<AppStoreVersionCandidate, 'id' | 'platform'>, expected?: AppStorePolicy): Promise<SubmissionRisk[]>;
30
47
  export declare function formatRisks(risks: SubmissionRisk[], platform: string): string;
31
- export {};
@@ -2,17 +2,31 @@ import { z } from 'zod';
2
2
  import { publisher, withEdit } from '../playstore/tools.js';
3
3
  import { appStorePagination as pagination, getAppStoreResponse, pageIsIncomplete } from '../appstore/read-response.js';
4
4
  import { selectAppInfo } from '../appstore/app-info.js';
5
- import { selectEditableAppStoreVersion, resolveAppStoreVersionBuild } from '../appstore/release-target.js';
6
5
  import { includedScreenshotReadiness, indexIncludedPlacements, listMediaPlacements, screenshotPlacementReadiness } from '../appstore/asset-library.js';
7
6
  import { checkLegacyScreenshotReadiness } from '../appstore/screenshots.js';
8
7
  import { readAppInfoAgeRatingForRelease, readAppInfoPrivacy } from '../appstore/app-info-policy.js';
9
8
  import { encodePathSegment } from '../lib/url-path.js';
10
9
  import { extractHttpStatus } from '../lib/google-errors.js';
11
- export function isRiskCheckIncomplete(risk) {
12
- return risk.code.startsWith('API_ERROR_');
10
+ import { isRiskCheckIncomplete, releaseReadiness } from './release-readiness.js';
11
+ export function findPlayTargetReleases(tracks, target) {
12
+ return tracks.filter(({ track }) => track === target.track)
13
+ .flatMap(({ releases }) => releases?.filter((release) => release.versionCodes?.includes(target.versionCode)) ?? []);
13
14
  }
14
15
  export async function checkPlayStoreRisks(auth, packageName, language = 'ko-KR', target) {
15
- return withEdit(auth, packageName, (editId) => checkPlayStoreRisksInEdit(auth, packageName, editId, language, target));
16
+ const releaseTarget = { store: 'playstore', packageName, ...target };
17
+ try {
18
+ const risks = await withEdit(auth, packageName, (editId) => checkPlayStoreRisksInEdit(auth, packageName, editId, language, target));
19
+ const targetVerified = target !== undefined && !risks.some(({ code }) => code === 'API_ERROR_TRACKS' || code === 'TARGET_BUILD_NOT_FOUND' || code === 'API_ERROR_TARGET_BUILD_AMBIGUOUS');
20
+ return releaseReadiness(releaseTarget, risks, targetVerified);
21
+ }
22
+ catch (error) {
23
+ return releaseReadiness(releaseTarget, [{
24
+ level: 'warning',
25
+ code: 'API_ERROR_PLAY_EDIT',
26
+ title: 'Google Play edit 조회 실패',
27
+ detail: error instanceof Error ? error.message : String(error),
28
+ }], false, false);
29
+ }
16
30
  }
17
31
  export async function checkPlayStoreRisksInEdit(auth, packageName, editId, language, target, tracksSnapshot) {
18
32
  const risks = [];
@@ -68,8 +82,16 @@ export async function checkPlayStoreRisksInEdit(auth, packageName, editId, langu
68
82
  }
69
83
  if (tracks) {
70
84
  if (target) {
71
- const targetTrack = tracks.find((track) => track.track === target.track);
72
- if (!targetTrack?.releases?.some((release) => release.versionCodes?.includes(target.versionCode))) {
85
+ const matches = findPlayTargetReleases(tracks, target);
86
+ if (matches.length > 1) {
87
+ risks.push({
88
+ level: 'warning',
89
+ code: 'API_ERROR_TARGET_BUILD_AMBIGUOUS',
90
+ title: '대상 트랙에 일치하는 릴리스가 여러 개 있음',
91
+ detail: `${target.track} 트랙에서 versionCode ${target.versionCode}가 포함된 릴리스 상태를 확인하세요.`,
92
+ });
93
+ }
94
+ else if (matches.length === 0) {
73
95
  risks.push({
74
96
  level: 'blocker',
75
97
  code: 'TARGET_BUILD_NOT_FOUND',
@@ -141,58 +163,28 @@ export function appStoreBuildRisk(build) {
141
163
  return { level: 'warning', code: 'API_ERROR_BUILD', title: '연결된 빌드 점검 미완료', detail: build.detail };
142
164
  }
143
165
  }
144
- export async function checkAppStoreRisks(appId, expected = {}) {
145
- const risks = [];
146
- const selection = await safeGet(() => selectEditableAppStoreVersion(appId, { versionId: expected.versionId }), risks, 'VERSIONS', '편집 가능한 버전 목록');
147
- if (!selection)
148
- return risks;
149
- if (selection.status === 'incomplete' || selection.status === 'ambiguous') {
150
- risks.push({
151
- level: 'warning',
152
- code: selection.status === 'incomplete' ? 'API_ERROR_VERSIONS_INCOMPLETE' : 'API_ERROR_VERSIONS_AMBIGUOUS',
153
- title: '편집 가능한 버전을 하나로 확인할 수 없음',
154
- detail: 'App Store Connect에서 대상 플랫폼과 편집 상태를 확인한 뒤 해당 versionId로 다시 점검하세요.',
155
- });
156
- return risks;
157
- }
158
- if (selection.status === 'missing') {
159
- if (expected.versionId) {
160
- risks.push({
161
- level: 'blocker',
162
- code: 'TARGET_VERSION_UNVERIFIED',
163
- title: '대상 버전을 점검할 수 없음',
164
- detail: '대상 앱의 편집 가능한 버전 목록에서 요청한 버전을 확인하세요.',
165
- });
166
- }
167
- else {
168
- risks.push({ level: 'blocker', code: 'NO_EDITABLE_VERSION', title: '편집 가능한 버전 없음', detail: 'App Store Connect에서 새 버전을 만드세요.', fixUrl: 'https://appstoreconnect.apple.com' });
169
- }
170
- return risks;
171
- }
172
- const { version } = selection;
173
- const [build, otherRisks] = await Promise.all([
174
- resolveAppStoreVersionBuild(version),
175
- checkAppStoreVersionRisks(appId, version, expected),
166
+ export async function checkAppStoreVersionRisks(appId, { id: selectedVersionId, platform }, expected = {}) {
167
+ const [localizations, policy] = await Promise.all([
168
+ checkAppStoreLocalizationRisks(selectedVersionId),
169
+ checkAppStorePolicyRisks(appId, platform, expected),
176
170
  ]);
177
- const buildRisk = appStoreBuildRisk(build);
178
- return buildRisk ? [buildRisk, ...otherRisks] : otherRisks;
171
+ return [...localizations, ...policy];
179
172
  }
180
- export async function checkAppStoreVersionRisks(appId, { id: selectedVersionId, platform }, expected = {}) {
173
+ const MAX_SCREENSHOT_LOOKUPS = 4;
174
+ async function checkAppStoreLocalizationRisks(selectedVersionId) {
181
175
  const risks = [];
182
176
  const versionId = encodePathSegment(selectedVersionId);
183
- // 버전 메타데이터·스크린샷과 앱 단위 개인정보처리방침을 병행 조회한다.
184
- const [locs, appInfo] = await Promise.all([
185
- safeGet(() => getAppStoreResponse(versionLocalizationPage, `/appStoreVersions/${versionId}/appStoreVersionLocalizations`, {
186
- limit: '200',
187
- include: 'placements,appScreenshotSets',
188
- 'limit[placements]': '50',
189
- 'limit[appScreenshotSets]': '1',
190
- 'fields[appStoreVersionLocalizations]': 'locale,description,whatsNew,keywords,placements,appScreenshotSets',
191
- 'fields[appAssetLibraryPlacements]': 'placementType,state,image',
192
- }), risks, 'LOCALIZATIONS', '버전 로컬라이제이션'),
193
- safeGet(() => selectAppInfo(appId, { privacyPlatform: platform }), risks, 'APP_INFO', '앱 정보'),
194
- ]);
195
- if (locs && pageIsIncomplete(locs, locs.data.length)) {
177
+ const locs = await safeGet(() => getAppStoreResponse(versionLocalizationPage, `/appStoreVersions/${versionId}/appStoreVersionLocalizations`, {
178
+ limit: '200',
179
+ include: 'placements,appScreenshotSets',
180
+ 'limit[placements]': '50',
181
+ 'limit[appScreenshotSets]': '1',
182
+ 'fields[appStoreVersionLocalizations]': 'locale,description,whatsNew,keywords,placements,appScreenshotSets',
183
+ 'fields[appAssetLibraryPlacements]': 'placementType,state,image',
184
+ }), risks, 'LOCALIZATIONS', '버전 로컬라이제이션');
185
+ if (!locs)
186
+ return risks;
187
+ if (pageIsIncomplete(locs, locs.data.length)) {
196
188
  risks.push({
197
189
  level: 'warning',
198
190
  code: 'API_ERROR_LOCALIZATIONS_INCOMPLETE',
@@ -200,51 +192,65 @@ export async function checkAppStoreVersionRisks(appId, { id: selectedVersionId,
200
192
  detail: 'App Store Connect에서 대상 버전의 전체 로컬라이제이션을 확인하세요.',
201
193
  });
202
194
  }
203
- else if (locs?.data.length === 0) {
195
+ else if (locs.data.length === 0) {
204
196
  risks.push({ level: 'blocker', code: 'NO_LOCALIZATIONS', title: '로컬라이제이션 없음', detail: '메타데이터를 입력하세요.' });
205
197
  }
206
- if (locs) {
207
- const placementsById = indexIncludedPlacements(locs.included ?? []);
208
- for (const loc of locs.data) {
209
- const { locale: rawLocale, description, whatsNew, keywords } = loc.attributes ?? {};
210
- const locale = rawLocale ?? loc.id;
211
- if (!description)
212
- risks.push({ level: 'blocker', code: `NO_DESC_${locale}`, title: `${locale} 설명 없음`, detail: '앱 설명은 필수 항목입니다.' });
213
- if (!whatsNew)
214
- risks.push({ level: 'warning', code: `NO_WHATS_NEW_${locale}`, title: `${locale} 새로운 기능 없음`, detail: '릴리즈 노트를 입력하면 다운로드 전환율이 높아집니다.' });
215
- if (!keywords)
216
- risks.push({ level: 'warning', code: `NO_KEYWORDS_${locale}`, title: `${locale} 키워드 없음`, detail: '키워드는 검색 노출에 직접 영향을 줍니다.' });
217
- const screenshots = await safeGet(async () => {
218
- let readiness = includedScreenshotReadiness(loc.relationships?.placements, placementsById);
219
- if (readiness === 'unknown') {
220
- const placements = await listMediaPlacements(loc.id, 'screenshots');
221
- readiness = placements ? screenshotPlacementReadiness(placements) : 'missing';
222
- }
223
- if (readiness === 'missing' && screenshotSetPresence(loc.relationships?.appScreenshotSets) !== false) {
224
- readiness = await checkLegacyScreenshotReadiness(loc.id);
225
- }
226
- if (readiness === 'unknown')
227
- throw new Error('App Store Connect의 스크린샷 상태를 확인할 수 없습니다.');
228
- return readiness;
229
- }, risks, `SCREENSHOTS_${locale}`, `${locale} 스크린샷`);
230
- if (screenshots === 'missing') {
231
- risks.push({
232
- level: 'blocker',
233
- code: `NO_SCREENSHOTS_${locale}`,
234
- title: `${locale} 스크린샷 없음`,
235
- detail: '대상 플랫폼에서 허용하는 스크린샷을 로케일에 배치하세요.',
236
- });
237
- }
238
- else if (screenshots === 'not-ready') {
239
- risks.push({
240
- level: 'blocker',
241
- code: `SCREENSHOTS_NOT_READY_${locale}`,
242
- title: `${locale} 스크린샷 준비 미완료`,
243
- detail: '배치된 스크린샷이 처리 중이거나 처리에 실패했습니다. App Store Connect에서 상태를 확인하세요.',
244
- });
245
- }
198
+ const placementsById = indexIncludedPlacements(locs.included ?? []);
199
+ const localeRisks = new Array(locs.data.length);
200
+ let nextLocale = 0;
201
+ // Each worker finishes one locale's placement and legacy fallbacks before taking the next.
202
+ await Promise.all(Array.from({ length: Math.min(MAX_SCREENSHOT_LOOKUPS, locs.data.length) }, async () => {
203
+ while (nextLocale < locs.data.length) {
204
+ const index = nextLocale++;
205
+ localeRisks[index] = await checkAppStoreLocale(locs.data[index], placementsById);
206
+ }
207
+ }));
208
+ return risks.concat(...localeRisks);
209
+ }
210
+ async function checkAppStoreLocale(loc, placementsById) {
211
+ const risks = [];
212
+ const { locale: rawLocale, description, whatsNew, keywords } = loc.attributes ?? {};
213
+ const locale = rawLocale ?? loc.id;
214
+ if (!description)
215
+ risks.push({ level: 'blocker', code: `NO_DESC_${locale}`, title: `${locale} 설명 없음`, detail: '앱 설명은 필수 항목입니다.' });
216
+ if (!whatsNew)
217
+ risks.push({ level: 'warning', code: `NO_WHATS_NEW_${locale}`, title: `${locale} 새로운 기능 없음`, detail: '릴리즈 노트를 입력하면 다운로드 전환율이 높아집니다.' });
218
+ if (!keywords)
219
+ risks.push({ level: 'warning', code: `NO_KEYWORDS_${locale}`, title: `${locale} 키워드 없음`, detail: '키워드는 검색 노출에 직접 영향을 줍니다.' });
220
+ const screenshots = await safeGet(async () => {
221
+ let readiness = includedScreenshotReadiness(loc.relationships?.placements, placementsById);
222
+ if (readiness === 'unknown') {
223
+ const placements = await listMediaPlacements(loc.id, 'screenshots');
224
+ readiness = placements ? screenshotPlacementReadiness(placements) : 'missing';
225
+ }
226
+ if (readiness === 'missing' && screenshotSetPresence(loc.relationships?.appScreenshotSets) !== false) {
227
+ readiness = await checkLegacyScreenshotReadiness(loc.id);
246
228
  }
229
+ if (readiness === 'unknown')
230
+ throw new Error('App Store Connect의 스크린샷 상태를 확인할 수 없습니다.');
231
+ return readiness;
232
+ }, risks, `SCREENSHOTS_${locale}`, `${locale} 스크린샷`);
233
+ if (screenshots === 'missing') {
234
+ risks.push({
235
+ level: 'blocker',
236
+ code: `NO_SCREENSHOTS_${locale}`,
237
+ title: `${locale} 스크린샷 없음`,
238
+ detail: '대상 플랫폼에서 허용하는 스크린샷을 로케일에 배치하세요.',
239
+ });
247
240
  }
241
+ else if (screenshots === 'not-ready') {
242
+ risks.push({
243
+ level: 'blocker',
244
+ code: `SCREENSHOTS_NOT_READY_${locale}`,
245
+ title: `${locale} 스크린샷 준비 미완료`,
246
+ detail: '배치된 스크린샷이 처리 중이거나 처리에 실패했습니다. App Store Connect에서 상태를 확인하세요.',
247
+ });
248
+ }
249
+ return risks;
250
+ }
251
+ async function checkAppStorePolicyRisks(appId, platform, expected) {
252
+ const risks = [];
253
+ const appInfo = await safeGet(() => selectAppInfo(appId, { privacyPlatform: platform }), risks, 'APP_INFO', '앱 정보');
248
254
  if (!appInfo)
249
255
  return risks;
250
256
  if ('reason' in appInfo) {
@@ -257,10 +263,13 @@ export async function checkAppStoreVersionRisks(appId, { id: selectedVersionId,
257
263
  return risks;
258
264
  }
259
265
  const { target, policy } = appInfo;
266
+ const privacyRisks = [];
267
+ const ageRatingRisks = [];
260
268
  const [hasPrivacy, ageRating] = await Promise.all([
261
- policy.hasPrivacy ?? safeGet(() => readAppInfoPrivacy(target.id, platform), risks, 'PRIVACY', '개인정보 로컬라이제이션'),
262
- policy.ageRating ?? safeGet(() => readAppInfoAgeRatingForRelease(target.id), risks, 'AGE_RATING_SOCIAL', '연령등급 소셜 미디어 응답'),
269
+ policy.hasPrivacy ?? safeGet(() => readAppInfoPrivacy(target.id, platform), privacyRisks, 'PRIVACY', '개인정보 로컬라이제이션'),
270
+ policy.ageRating ?? safeGet(() => readAppInfoAgeRatingForRelease(target.id), ageRatingRisks, 'AGE_RATING_SOCIAL', '연령등급 소셜 미디어 응답'),
263
271
  ]);
272
+ risks.push(...privacyRisks, ...ageRatingRisks);
264
273
  if (hasPrivacy === false) {
265
274
  risks.push({ level: 'blocker', code: 'NO_PRIVACY', title: '개인정보처리방침 없음', detail: platform === 'TV_OS' ? '대상 tvOS 앱의 개인정보처리방침 텍스트를 입력하세요.' : '대상 앱의 개인정보처리방침 URL을 입력하세요.' });
266
275
  }
@@ -54,7 +54,7 @@ export declare function previewValue(key: string, value: unknown): string;
54
54
  export declare function confirmPreview(name: string, args: Record<string, unknown>): CallToolResult;
55
55
  export interface ToolRegistrar {
56
56
  /** `McpServer.tool(name, description, shape, handler)` 와 같은 모양 — register 파일 호출부는 그대로다. */
57
- tool<Args extends ZodRawShapeCompat>(name: string, description: string, shape: Args, handler: ToolCallback<Args>): void;
57
+ tool<Args extends ZodRawShapeCompat>(name: string, description: string, shape: Args, handler: ToolCallback<Args>, outputSchema?: ZodRawShapeCompat): void;
58
58
  /** 이 서버에서 켜진 toolset (mimi_seed_status 가 보고한다). */
59
59
  readonly toolsets: ToolsetSelection;
60
60
  readonly manifest: ToolManifest;
@@ -123,15 +123,15 @@ export function createToolRegistrar(server, options) {
123
123
  }
124
124
  return meta;
125
125
  };
126
- const register = (meta, description, shape, handler) => {
126
+ const register = (meta, description, shape, handler, outputSchema) => {
127
127
  if (!toolsets.isToolEnabled(meta.name))
128
128
  return;
129
- server.registerTool(meta.name, { title: annotationsFor(meta).title, description, inputSchema: shape, annotations: annotationsFor(meta) }, handler);
129
+ server.registerTool(meta.name, { title: annotationsFor(meta).title, description, inputSchema: shape, outputSchema, annotations: annotationsFor(meta) }, handler);
130
130
  };
131
131
  return {
132
132
  toolsets,
133
133
  manifest,
134
- tool(name, description, shape, handler) {
134
+ tool(name, description, shape, handler, outputSchema) {
135
135
  const meta = metaOf(name);
136
136
  if (meta.deprecatedFor) {
137
137
  throw new Error(`"${name}" 은(는) ${meta.deprecatedFor} 의 폐기 예정 별칭이라 레지스트라가 자동 등록한다 — register 파일에서 직접 등록하지 마세요.`);
@@ -166,10 +166,10 @@ export function createToolRegistrar(server, options) {
166
166
  return run(args, extra);
167
167
  };
168
168
  }
169
- register(meta, finalDescription, finalShape, finalHandler);
169
+ register(meta, finalDescription, finalShape, finalHandler, outputSchema);
170
170
  for (const alias of meta.aliases) {
171
171
  const aliasMeta = metaOf(alias);
172
- register(aliasMeta, `[DEPRECATED — use ${name}; removed in the next minor release] ${finalDescription}`, finalShape, finalHandler);
172
+ register(aliasMeta, `[DEPRECATED — use ${name}; removed in the next minor release] ${finalDescription}`, finalShape, finalHandler, outputSchema);
173
173
  }
174
174
  },
175
175
  };
@@ -9,6 +9,7 @@ import { GOOGLEAPIS_COMMIT_OPTIONS } from '../lib/google-timeouts.js';
9
9
  */
10
10
  // 모든 호출에서 경로 파라미터가 정확히 '.'/'..' 이면 요청 전에 거부 (lib/resource-id.ts).
11
11
  export const publisher = () => guardDotSegmentParams(google.androidpublisher('v3'));
12
+ const pendingEdits = new Map();
12
13
  // Play 는 앱/계정 상태에 따라 "커밋과 동시에 심사 전송"을 거부한다:
13
14
  // Changes cannot be sent for review automatically.
14
15
  // Please set the query parameter changesNotSentForReview to true.
@@ -29,10 +30,25 @@ async function commitEdit(auth, packageName, editId) {
29
30
  }
30
31
  }
31
32
  export async function withEdit(auth, packageName, fn, commit = false, onCommit) {
33
+ // A new edit can invalidate an active edit for the same app, including when the new edit only reads.
34
+ const previous = pendingEdits.get(packageName);
35
+ const edit = (previous?.catch(() => undefined) ?? Promise.resolve())
36
+ .then(() => runEdit(auth, packageName, fn, commit, onCommit));
37
+ pendingEdits.set(packageName, edit);
38
+ try {
39
+ return await edit;
40
+ }
41
+ finally {
42
+ if (pendingEdits.get(packageName) === edit)
43
+ pendingEdits.delete(packageName);
44
+ }
45
+ }
46
+ async function runEdit(auth, packageName, fn, commit, onCommit) {
32
47
  const res = await publisher().edits.insert({ auth, packageName });
33
48
  const editId = res.data.id;
34
49
  if (!editId)
35
50
  throw new Error('Failed to create edit session');
51
+ let commitStarted = false;
36
52
  try {
37
53
  const result = await fn(editId);
38
54
  if (commit) {
@@ -40,14 +56,21 @@ export async function withEdit(auth, packageName, fn, commit = false, onCommit)
40
56
  // onCommit?.(await commitEdit(...)) 로 쓰면 안 된다 — 옵셔널 호출은 수신자가
41
57
  // nullish 일 때 인자 자체를 평가하지 않아서, onCommit 을 안 넘긴 호출자(대부분)에서
42
58
  // 커밋이 통째로 사라진다. playstore-listing 테스트가 이걸 잡아냈다.
59
+ commitStarted = true;
43
60
  const info = await commitEdit(auth, packageName, editId);
44
61
  onCommit?.(info);
45
62
  }
46
63
  return result;
47
64
  }
48
65
  finally {
49
- if (!commit) {
50
- await publisher().edits.delete({ auth, packageName, editId }).catch(() => { });
66
+ // Once a commit has been attempted, a transport failure can leave its outcome uncertain.
67
+ if (!commitStarted) {
68
+ try {
69
+ await publisher().edits.delete({ auth, packageName, editId });
70
+ }
71
+ catch {
72
+ // Cleanup is best effort. Preserve the outcome of the edit callback.
73
+ }
51
74
  }
52
75
  }
53
76
  }
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import * as appstore from '../../appstore/tools.js';
3
3
  import { buildAppStoreReleasePlan } from '../../checks/plan.js';
4
+ import { appStoreRiskPolicyShape, releaseReadinessResult, releaseReadinessShape } from '../../checks/release-readiness.js';
4
5
  import { textResult } from '../../lib/mcp-response.js';
5
6
  import { reviewSubmissionsText, submitForReviewDryRunText } from '../../appstore/messages.js';
6
7
  /** appstore_list_review_submissions · appstore_remove_review_submission_item · appstore_add_version_to_review_submission */
@@ -67,10 +68,13 @@ export function registerSubmitForReviewTools(server) {
67
68
  appId: z.string().describe('App Store 앱 ID (appstore_list_apps 결과의 id)'),
68
69
  versionString: z.string().trim().min(1).optional().describe('대상 버전 문자열 (예: 1.3.0)'),
69
70
  versionId: z.string().trim().min(1).optional().describe('정확한 버전 ID (appstore_list_versions 결과)'),
70
- }, async ({ appId, versionString, versionId }) => {
71
- const text = await buildAppStoreReleasePlan({ appId, versionString, versionId });
72
- return textResult(text);
73
- });
71
+ ...appStoreRiskPolicyShape,
72
+ }, async ({ appId, versionString, versionId, socialMediaCapability, socialMediaAgeRestricted }) => {
73
+ const { text, readiness } = await buildAppStoreReleasePlan({
74
+ appId, versionString, versionId, policy: { socialMedia: socialMediaCapability, socialMediaAgeRestricted },
75
+ });
76
+ return releaseReadinessResult(text, readiness);
77
+ }, releaseReadinessShape);
74
78
  server.tool('appstore_submit_for_review', [
75
79
  'App Store 버전을 심사에 제출 — 새 reviewSubmissions API 사용 (옛 /appStoreVersionSubmissions는 2024-01 deprecated).',
76
80
  '내부 흐름: POST /reviewSubmissions(또는 CREATED 상태 재사용) → POST /reviewSubmissionItems(version attach) → PATCH submitted=true.',