shelfready 0.1.1 → 0.2.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/README.md +44 -2
- package/dist/cli.js +62 -37
- package/dist/core/agents.d.ts +10 -0
- package/dist/core/agents.js +32 -0
- package/dist/core/checklist.d.ts +4 -1
- package/dist/core/checklist.js +10 -4
- package/dist/core/facts.d.ts +15 -0
- package/dist/core/facts.js +28 -0
- package/dist/core/pages.d.ts +7 -0
- package/dist/core/pages.js +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mcp.d.ts +27 -0
- package/dist/mcp.js +371 -0
- package/package.json +17 -4
package/README.md
CHANGED
|
@@ -4,7 +4,13 @@ Get an iOS app ready for the App Store shelf. ShelfReady reads your repo and kee
|
|
|
4
4
|
|
|
5
5
|
It does not upload builds or fill in App Store Connect; use [`asc`](https://github.com/rudrankriyam/App-Store-Connect-CLI) or fastlane for that. ShelfReady covers the legal, privacy and web layer around them, with the EU steps most tools skip.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Try it in your app's repo, nothing to install:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx -y shelfready check
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Website, the full checklist and what common SDKs collect: **[shelfready.dev](https://shelfready.dev)**
|
|
8
14
|
|
|
9
15
|
## Quick start
|
|
10
16
|
|
|
@@ -31,6 +37,41 @@ shelf checklist --online # what's left before you submit
|
|
|
31
37
|
| `shelf check` | Drift between `shelfready.yaml` and the repo, missing manifests, placeholder permission texts, unknown SDKs, trader details, in-app Impressum. `--ci` exits 1 on errors, `--online` checks the published pages, `--format github` annotates pull requests |
|
|
32
38
|
| `shelf checklist` | The go-live checklist: automatic items from `check`, manual ones you tick with `--done <id>`; `--markdown` writes it as a file |
|
|
33
39
|
| `shelf migrate` | Updates `shelfready.yaml` to the current schema, keeping your comments and style |
|
|
40
|
+
| `shelf agents` | Adds a short note to `AGENTS.md` (or `CLAUDE.md`) so coding agents in the repo run the checks before a release; `shelf init` offers it |
|
|
41
|
+
| `shelf mcp` | Runs the MCP server on stdio, so Claude and other agents can use all of the above |
|
|
42
|
+
|
|
43
|
+
## Use with your coding agent
|
|
44
|
+
|
|
45
|
+
ShelfReady includes an MCP server (`shelf mcp`) and a skill, so the agent you build your app with can run the whole go-live flow: scan the repo, ask you for the publisher details it can't know, write the pages and App Privacy answers, and work through the checklist.
|
|
46
|
+
|
|
47
|
+
**Claude Code** (terminal, VS Code, JetBrains, desktop): install the plugin, which adds the skill and starts the server.
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
claude plugin marketplace add halfbatch-studio/shelfready
|
|
51
|
+
claude plugin install shelfready@shelfready
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then ask: "get this app ready for the App Store".
|
|
55
|
+
|
|
56
|
+
**Codex CLI:**
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
codex mcp add shelfready -- npx -y shelfready mcp
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Cursor, Claude Desktop, Windsurf and other MCP clients:** add this to the client's MCP config (for Cursor, `.cursor/mcp.json` in your app repo).
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcpServers": {
|
|
67
|
+
"shelfready": { "command": "npx", "args": ["-y", "shelfready", "mcp"] }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Tools: `scan`, `init`, `check`, `checklist`, `tick`, `pages`, `app_privacy`, `sdk_info`, `migrate`. Each takes `path`, the app repo, and only ever writes inside it. The server is listed in the [MCP Registry](https://registry.modelcontextprotocol.io) as `io.github.halfbatch-studio/shelfready`.
|
|
73
|
+
|
|
74
|
+
The skill, [`plugin/skills/shelfready/SKILL.md`](plugin/skills/shelfready/SKILL.md), follows the open Agent Skills format: copy the folder into any agent that reads skills, or upload it to claude.ai.
|
|
34
75
|
|
|
35
76
|
## GitHub Action
|
|
36
77
|
|
|
@@ -60,7 +101,7 @@ One file in your app repo holds the facts behind your pages: app, publisher (`vo
|
|
|
60
101
|
|
|
61
102
|
## Status and limits
|
|
62
103
|
|
|
63
|
-
- Version 0.
|
|
104
|
+
- Version 0.2. Used to ship [kipple](https://halfbatch.studio/kipple/); expect rough edges.
|
|
64
105
|
- **Not legal advice.** Page templates are drafts based on § 5 DDG, the GDPR and Apple's rules, not yet reviewed by a lawyer. You're responsible for what your pages say.
|
|
65
106
|
- iOS only for now.
|
|
66
107
|
|
|
@@ -71,6 +112,7 @@ cli/ the `shelf` CLI and its core library (TypeScript), tests, SDK knowle
|
|
|
71
112
|
site/ shelfready.dev, generated from the same checklist items as the CLI
|
|
72
113
|
examples/ real configs and output
|
|
73
114
|
action.yml the GitHub Action
|
|
115
|
+
plugin/ the Claude Code plugin: skill and MCP server config
|
|
74
116
|
```
|
|
75
117
|
|
|
76
118
|
## License
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { appendFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
2
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join, relative, resolve } from "node:path";
|
|
4
|
+
import { createInterface } from "node:readline/promises";
|
|
4
5
|
import { createRequire } from "node:module";
|
|
5
6
|
import { Command, Option } from "commander";
|
|
6
|
-
import { appPrivacy, check, checklist, checklistMarkdown, checkOnline, CURRENT_VERSION, setTicks,
|
|
7
|
+
import { addAgentsNote, agentsNoteFile, appPrivacy, check, checklist, checklistMarkdown, checklistSummary, checkOnline, CURRENT_VERSION, setTicks, factsToYAML, initFacts, legalView, migrateFile, pageFiles, readFacts, scan } from "./index.js";
|
|
7
8
|
const program = new Command()
|
|
8
9
|
.name("shelf")
|
|
9
10
|
.description("Get an iOS app ready for the App Store shelf: legal pages, privacy truth, preflight.")
|
|
@@ -63,39 +64,62 @@ program
|
|
|
63
64
|
.addOption(new Option("--voice <voice>", "how pages speak: I (solo) or we (team)").choices(["I", "we"]).default("we"))
|
|
64
65
|
.option("--base-url <url>", "where the pages will live, e.g. https://example.com/myapp/")
|
|
65
66
|
.option("--force", "overwrite an existing shelfready.yaml")
|
|
66
|
-
.
|
|
67
|
+
.option("--agents-note", "add a ShelfReady note to AGENTS.md (or CLAUDE.md) without asking")
|
|
68
|
+
.option("--no-agents-note", "don't add the note and don't ask")
|
|
69
|
+
.action(async (path, o) => {
|
|
67
70
|
const out = factsPath(path);
|
|
68
71
|
if (existsSync(out) && !o.force) {
|
|
69
72
|
console.error(`${out} exists. Use --force to overwrite.`);
|
|
70
73
|
process.exit(1);
|
|
71
74
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
let result;
|
|
76
|
+
try {
|
|
77
|
+
result = initFacts(scan(path), o);
|
|
75
78
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
...(o.brand ? { brand: o.brand } : {}),
|
|
80
|
-
...(o.publisher ? { name: o.publisher } : {}),
|
|
81
|
-
trader: !!o.trader,
|
|
82
|
-
voice: o.voice,
|
|
83
|
-
});
|
|
84
|
-
if (o.baseUrl)
|
|
85
|
-
facts.pages.baseURL = o.baseUrl;
|
|
86
|
-
if (facts.publisher.trader && needsImpressum(facts)) {
|
|
87
|
-
Object.assign(facts.publisher, { phone: o.phone ?? "", contactURL: "", vatId: "", legalForm: "", representative: "", register: { court: "", number: "" } });
|
|
79
|
+
catch (e) {
|
|
80
|
+
console.error(String(e instanceof Error ? e.message : e));
|
|
81
|
+
process.exit(1);
|
|
88
82
|
}
|
|
89
|
-
writeFileSync(out, factsToYAML(facts));
|
|
83
|
+
writeFileSync(out, factsToYAML(result.facts));
|
|
90
84
|
console.log(`Wrote ${out}`);
|
|
91
|
-
|
|
92
|
-
console.log(
|
|
93
|
-
|
|
94
|
-
console.log("Traders: add a business address under publisher.address (never a home address).");
|
|
95
|
-
if (facts.publisher.trader && needsImpressum(facts))
|
|
96
|
-
console.log("DE/AT traders: fill phone or contactURL, vatId, and for companies legalForm, representative and register. Then show LegalView in the app.");
|
|
97
|
-
console.log("Next: add privacyNotes and support.faq, then run `shelf pages`.");
|
|
85
|
+
for (const n of result.notes)
|
|
86
|
+
console.log(n.replace("generate the pages", "run `shelf pages`"));
|
|
87
|
+
await offerAgentsNote(path, o.agentsNote);
|
|
98
88
|
});
|
|
89
|
+
program
|
|
90
|
+
.command("agents")
|
|
91
|
+
.description("Add a short ShelfReady note to AGENTS.md (or CLAUDE.md), so coding agents in this repo run the checks before a release.")
|
|
92
|
+
.argument("[path]", "app repository", ".")
|
|
93
|
+
.action((path) => reportAgentsNote(addAgentsNote(path)));
|
|
94
|
+
/** A path to show: relative to where you are, unless that climbs out of it. */
|
|
95
|
+
const shown = (file) => {
|
|
96
|
+
const rel = relative(process.cwd(), file);
|
|
97
|
+
return rel && !rel.startsWith("..") ? rel : file;
|
|
98
|
+
};
|
|
99
|
+
function reportAgentsNote(r) {
|
|
100
|
+
const name = shown(r.file);
|
|
101
|
+
console.log(r.action === "present" ? `${name} already has the ShelfReady note.` : `${r.action === "created" ? "Created" : "Added the ShelfReady note to"} ${name}.`);
|
|
102
|
+
}
|
|
103
|
+
async function offerAgentsNote(path, choice) {
|
|
104
|
+
if (choice === false)
|
|
105
|
+
return;
|
|
106
|
+
const target = agentsNoteFile(path);
|
|
107
|
+
if (existsSync(target) && readFileSync(target, "utf8").includes("<!-- shelfready -->"))
|
|
108
|
+
return;
|
|
109
|
+
const file = shown(target);
|
|
110
|
+
if (choice === undefined) {
|
|
111
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
112
|
+
console.log(`Tip: \`shelf agents\` adds a note to ${file} so coding agents in this repo run \`shelf check\` before a release.`);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
116
|
+
const answer = await rl.question(`Add a ShelfReady note to ${file}, so coding agents (Claude Code, Codex, Cursor, Xcode) run the checks before a release? [Y/n] `);
|
|
117
|
+
rl.close();
|
|
118
|
+
if (/^n/i.test(answer.trim()))
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
reportAgentsNote(addAgentsNote(path));
|
|
122
|
+
}
|
|
99
123
|
program
|
|
100
124
|
.command("pages")
|
|
101
125
|
.description("Generate privacy policy, support page and Impressum (DE/AT) as Markdown; --swiftui adds LegalView.swift.")
|
|
@@ -107,13 +131,8 @@ program
|
|
|
107
131
|
const facts = requireFacts(path);
|
|
108
132
|
const dir = resolve(path, o.out);
|
|
109
133
|
mkdirSync(dir, { recursive: true });
|
|
110
|
-
for (const page of
|
|
111
|
-
|
|
112
|
-
const front = o.frontMatter === "jekyll"
|
|
113
|
-
? `---\nlayout: default\ntitle: ${JSON.stringify(page.title)}\n${permalink ? `permalink: ${permalink}\n` : ""}---\n\n`
|
|
114
|
-
: "";
|
|
115
|
-
const banner = "<!-- Generated by ShelfReady (`shelf pages`) from shelfready.yaml. Edit that file, not this page. -->\n\n";
|
|
116
|
-
writeFileSync(join(dir, page.file), front + banner + page.markdown);
|
|
134
|
+
for (const page of pageFiles(facts, o.frontMatter)) {
|
|
135
|
+
writeFileSync(join(dir, page.file), page.content);
|
|
117
136
|
console.log(`Wrote ${join(o.out, page.file)}`);
|
|
118
137
|
}
|
|
119
138
|
if (o.swiftui) {
|
|
@@ -215,7 +234,7 @@ program
|
|
|
215
234
|
console.log(md);
|
|
216
235
|
return;
|
|
217
236
|
}
|
|
218
|
-
const icon = { done: "✓", todo: "○", fail: "✗" };
|
|
237
|
+
const icon = { done: "✓", todo: "○", fail: "✗", unchecked: "?" };
|
|
219
238
|
for (const group of [...new Set(rows.map((r) => r.group))]) {
|
|
220
239
|
console.log(`\n${group}`);
|
|
221
240
|
for (const r of rows.filter((x) => x.group === group)) {
|
|
@@ -225,8 +244,7 @@ program
|
|
|
225
244
|
console.log(` ${r.how}`);
|
|
226
245
|
}
|
|
227
246
|
}
|
|
228
|
-
|
|
229
|
-
console.log(`\n${done} of ${rows.length} done.${rows.some((r) => !r.automatic && r.status !== "done") ? " Tick manual items with: shelf checklist --done <id>" : ""}`);
|
|
247
|
+
console.log(`\n${checklistSummary(rows)}${rows.some((r) => !r.automatic && r.status !== "done") ? " Tick manual items with: shelf checklist --done <id>" : ""}`);
|
|
230
248
|
});
|
|
231
249
|
program
|
|
232
250
|
.command("migrate")
|
|
@@ -257,6 +275,13 @@ program
|
|
|
257
275
|
writeFileSync(file, result.text);
|
|
258
276
|
console.log(`Wrote ${file}. Review the new fields, then run \`shelf check\`.`);
|
|
259
277
|
});
|
|
278
|
+
program
|
|
279
|
+
.command("mcp")
|
|
280
|
+
.description("Run the MCP server on stdio, for Claude and other agents: npx -y shelfready mcp")
|
|
281
|
+
.action(async () => {
|
|
282
|
+
const { serveStdio } = await import("./mcp.js");
|
|
283
|
+
await serveStdio();
|
|
284
|
+
});
|
|
260
285
|
for (const [name, what] of [
|
|
261
286
|
["publish", "Publish pages to GitHub Pages or shelfready.dev."],
|
|
262
287
|
["login", "Sign in to shelfready.dev (device flow)."],
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The note every coding agent in the repo reads (AGENTS.md, or CLAUDE.md when that's what the repo uses). */
|
|
2
|
+
export declare const AGENTS_NOTE = "<!-- shelfready -->\n## App Store release (ShelfReady)\n\nThe privacy policy, support page, Impressum and App Privacy answers are generated by [ShelfReady](https://shelfready.dev) from `shelfready.yaml`.\n\n- Before a release, or after adding an SDK, a permission or a privacy manifest: run `npx -y shelfready check` and fix what it reports.\n- Edit `shelfready.yaml`, never the generated pages; regenerate them with `npx -y shelfready pages`.\n- What's left before submitting: `npx -y shelfready checklist --online`.\n";
|
|
3
|
+
export interface AgentsNoteResult {
|
|
4
|
+
file: string;
|
|
5
|
+
action: "created" | "appended" | "present";
|
|
6
|
+
}
|
|
7
|
+
/** Which file gets the note: AGENTS.md if present, else CLAUDE.md if present, else a new AGENTS.md. */
|
|
8
|
+
export declare function agentsNoteFile(root: string): string;
|
|
9
|
+
/** Add the ShelfReady note once. Idempotent: does nothing if the note is already there. */
|
|
10
|
+
export declare function addAgentsNote(root: string): AgentsNoteResult;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
const MARKER = "<!-- shelfready -->";
|
|
4
|
+
/** The note every coding agent in the repo reads (AGENTS.md, or CLAUDE.md when that's what the repo uses). */
|
|
5
|
+
export const AGENTS_NOTE = `${MARKER}
|
|
6
|
+
## App Store release (ShelfReady)
|
|
7
|
+
|
|
8
|
+
The privacy policy, support page, Impressum and App Privacy answers are generated by [ShelfReady](https://shelfready.dev) from \`shelfready.yaml\`.
|
|
9
|
+
|
|
10
|
+
- Before a release, or after adding an SDK, a permission or a privacy manifest: run \`npx -y shelfready check\` and fix what it reports.
|
|
11
|
+
- Edit \`shelfready.yaml\`, never the generated pages; regenerate them with \`npx -y shelfready pages\`.
|
|
12
|
+
- What's left before submitting: \`npx -y shelfready checklist --online\`.
|
|
13
|
+
`;
|
|
14
|
+
/** Which file gets the note: AGENTS.md if present, else CLAUDE.md if present, else a new AGENTS.md. */
|
|
15
|
+
export function agentsNoteFile(root) {
|
|
16
|
+
const agents = join(root, "AGENTS.md");
|
|
17
|
+
const claude = join(root, "CLAUDE.md");
|
|
18
|
+
return existsSync(agents) || !existsSync(claude) ? agents : claude;
|
|
19
|
+
}
|
|
20
|
+
/** Add the ShelfReady note once. Idempotent: does nothing if the note is already there. */
|
|
21
|
+
export function addAgentsNote(root) {
|
|
22
|
+
const file = agentsNoteFile(root);
|
|
23
|
+
if (!existsSync(file)) {
|
|
24
|
+
writeFileSync(file, `# Agent notes\n\n${AGENTS_NOTE}`);
|
|
25
|
+
return { file, action: "created" };
|
|
26
|
+
}
|
|
27
|
+
const text = readFileSync(file, "utf8");
|
|
28
|
+
if (text.includes(MARKER) || text.includes("npx -y shelfready check"))
|
|
29
|
+
return { file, action: "present" };
|
|
30
|
+
writeFileSync(file, `${text.replace(/\s*$/, "")}\n\n${AGENTS_NOTE}`);
|
|
31
|
+
return { file, action: "appended" };
|
|
32
|
+
}
|
package/dist/core/checklist.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ import type { ScanResult } from "./scan.js";
|
|
|
6
6
|
* from `check` (and `check --online`); the rest are manual and ticked with `shelf checklist --done <id>`,
|
|
7
7
|
* which stores the date in shelfready.yaml.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
/** `unchecked`: an automatic item that needs `--online` and wasn't verified this run. */
|
|
10
|
+
export type Status = "done" | "todo" | "fail" | "unchecked";
|
|
10
11
|
export interface Context {
|
|
11
12
|
facts: Facts;
|
|
12
13
|
scan: ScanResult;
|
|
@@ -41,4 +42,6 @@ export declare function checklist(c: Context): ChecklistRow[];
|
|
|
41
42
|
export declare function checklistMarkdown(rows: ChecklistRow[], appName: string): string;
|
|
42
43
|
/** Tick or untick manual items in shelfready.yaml, keeping comments and style. Returns the new file text. */
|
|
43
44
|
export declare function setTicks(path: string, ids: string[], done: boolean, date?: string): string;
|
|
45
|
+
/** "15 of 18 done." plus how many live-page items weren't checked. */
|
|
46
|
+
export declare function checklistSummary(rows: ChecklistRow[]): string;
|
|
44
47
|
export {};
|
package/dist/core/checklist.js
CHANGED
|
@@ -8,7 +8,7 @@ const de = (f) => needsImpressum(f);
|
|
|
8
8
|
function onlineItem(page) {
|
|
9
9
|
return (c) => {
|
|
10
10
|
if (!c.online)
|
|
11
|
-
return { status: "
|
|
11
|
+
return { status: "unchecked", detail: "not checked; run with --online" };
|
|
12
12
|
const f = c.online.filter((x) => x.rule.startsWith(`online.${page}`));
|
|
13
13
|
if (f.some((x) => x.level === "error"))
|
|
14
14
|
return { status: "fail", detail: f.find((x) => x.level === "error").message };
|
|
@@ -134,7 +134,7 @@ export function checklist(c) {
|
|
|
134
134
|
return ITEMS.filter((i) => !i.applies || i.applies(c.facts)).map((i) => {
|
|
135
135
|
if (i.auto) {
|
|
136
136
|
const r = i.auto(c);
|
|
137
|
-
return { id: i.id, group: i.group, title: i.title, status: r.status, automatic: true, ...(r.detail ? { detail: r.detail } : {}), ...(r.status !== "done" ? { how: i.how(c) } : {}) };
|
|
137
|
+
return { id: i.id, group: i.group, title: i.title, status: r.status, automatic: true, ...(r.detail ? { detail: r.detail } : {}), ...(r.status !== "done" && r.status !== "unchecked" ? { how: i.how(c) } : {}) };
|
|
138
138
|
}
|
|
139
139
|
const date = ticks[i.id];
|
|
140
140
|
return date
|
|
@@ -143,11 +143,11 @@ export function checklist(c) {
|
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
export function checklistMarkdown(rows, appName) {
|
|
146
|
-
const out = [`# ${appName} go-live checklist`, "", `_${rows
|
|
146
|
+
const out = [`# ${appName} go-live checklist`, "", `_${checklistSummary(rows)} Generated by \`shelf checklist --markdown\`._`, ""];
|
|
147
147
|
for (const group of [...new Set(rows.map((r) => r.group))]) {
|
|
148
148
|
out.push(`## ${group}`, "");
|
|
149
149
|
for (const r of rows.filter((x) => x.group === group)) {
|
|
150
|
-
const note = r.status === "done" ? (r.detail ? ` (${r.detail})` : "") : r.how ? `: ${r.how}` : "";
|
|
150
|
+
const note = r.status === "done" || r.status === "unchecked" ? (r.detail ? ` (${r.detail})` : "") : r.how ? `: ${r.how}` : "";
|
|
151
151
|
out.push(`- [${r.status === "done" ? "x" : " "}] **${r.title}**${note}${r.automatic ? "" : ` \`${r.id}\``}`);
|
|
152
152
|
}
|
|
153
153
|
out.push("");
|
|
@@ -174,3 +174,9 @@ export function setTicks(path, ids, done, date = new Date().toISOString().slice(
|
|
|
174
174
|
}
|
|
175
175
|
return doc.toString({ lineWidth: 100, indentSeq: usesIndentedLists(text) });
|
|
176
176
|
}
|
|
177
|
+
/** "15 of 18 done." plus how many live-page items weren't checked. */
|
|
178
|
+
export function checklistSummary(rows) {
|
|
179
|
+
const done = rows.filter((r) => r.status === "done").length;
|
|
180
|
+
const unchecked = rows.filter((r) => r.status === "unchecked").length;
|
|
181
|
+
return `${done} of ${rows.length} done.${unchecked ? ` ${unchecked} not checked: live pages are only verified with --online.` : ""}`;
|
|
182
|
+
}
|
package/dist/core/facts.d.ts
CHANGED
|
@@ -90,6 +90,21 @@ export declare function impressumLines(facts: Facts): {
|
|
|
90
90
|
value: string;
|
|
91
91
|
}[];
|
|
92
92
|
export declare function factsFromScan(scan: ScanResult, publisher: Partial<Facts["publisher"]> & Pick<Facts["publisher"], "country" | "email">): Facts;
|
|
93
|
+
export interface InitOptions {
|
|
94
|
+
country: string;
|
|
95
|
+
email: string;
|
|
96
|
+
brand?: string;
|
|
97
|
+
publisher?: string;
|
|
98
|
+
trader?: boolean;
|
|
99
|
+
phone?: string;
|
|
100
|
+
voice?: "I" | "we";
|
|
101
|
+
baseUrl?: string;
|
|
102
|
+
}
|
|
103
|
+
/** What `shelf init` writes: facts from the scan plus publisher details, with empty DE/AT trader fields to fill. */
|
|
104
|
+
export declare function initFacts(scan: ScanResult, o: InitOptions): {
|
|
105
|
+
facts: Facts;
|
|
106
|
+
notes: string[];
|
|
107
|
+
};
|
|
93
108
|
export declare const FACTS_HEADER = "# shelfready.yaml: facts behind your privacy policy, support page and Impressum.\n# Generated by `shelf init`. Check every line; you are responsible for what it says.\n";
|
|
94
109
|
export declare function factsToYAML(facts: Facts): string;
|
|
95
110
|
export interface LoadedFacts {
|
package/dist/core/facts.js
CHANGED
|
@@ -77,6 +77,34 @@ export function factsFromScan(scan, publisher) {
|
|
|
77
77
|
pages: { baseURL: "", policyUpdated: new Date().toISOString().slice(0, 10) },
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
+
/** What `shelf init` writes: facts from the scan plus publisher details, with empty DE/AT trader fields to fill. */
|
|
81
|
+
export function initFacts(scan, o) {
|
|
82
|
+
if (o.trader && !o.publisher)
|
|
83
|
+
throw new Error("Traders must give a legal name (publisher).");
|
|
84
|
+
const facts = factsFromScan(scan, {
|
|
85
|
+
country: o.country,
|
|
86
|
+
email: o.email,
|
|
87
|
+
...(o.brand ? { brand: o.brand } : {}),
|
|
88
|
+
...(o.publisher ? { name: o.publisher } : {}),
|
|
89
|
+
trader: !!o.trader,
|
|
90
|
+
voice: o.voice ?? "we",
|
|
91
|
+
});
|
|
92
|
+
if (o.baseUrl)
|
|
93
|
+
facts.pages.baseURL = o.baseUrl;
|
|
94
|
+
const de = needsImpressum(facts);
|
|
95
|
+
if (facts.publisher.trader && de) {
|
|
96
|
+
Object.assign(facts.publisher, { phone: o.phone ?? "", contactURL: "", vatId: "", legalForm: "", representative: "", register: { court: "", number: "" } });
|
|
97
|
+
}
|
|
98
|
+
const notes = [];
|
|
99
|
+
if (de)
|
|
100
|
+
notes.push(`Country ${facts.publisher.country} needs an Impressum on the web and inside the app.`);
|
|
101
|
+
if (facts.publisher.trader)
|
|
102
|
+
notes.push("Traders: add a business address under publisher.address (never a home address).");
|
|
103
|
+
if (facts.publisher.trader && de)
|
|
104
|
+
notes.push("DE/AT traders: fill phone or contactURL, vatId, and for companies legalForm, representative and register. Then show LegalView in the app.");
|
|
105
|
+
notes.push("Next: add privacyNotes and support.faq, then generate the pages.");
|
|
106
|
+
return { facts, notes };
|
|
107
|
+
}
|
|
80
108
|
export const FACTS_HEADER = `# shelfready.yaml: facts behind your privacy policy, support page and Impressum.
|
|
81
109
|
# Generated by \`shelf init\`. Check every line; you are responsible for what it says.
|
|
82
110
|
`;
|
package/dist/core/pages.d.ts
CHANGED
|
@@ -15,3 +15,10 @@ export declare function privacyPolicy(facts: Facts): Page;
|
|
|
15
15
|
export declare function supportPage(facts: Facts): Page;
|
|
16
16
|
/** German-language Impressum (§ 5 DDG for DE, § 5 ECG for AT), with an English notice. */
|
|
17
17
|
export declare function impressum(facts: Facts): Page;
|
|
18
|
+
export interface PageFile {
|
|
19
|
+
file: string;
|
|
20
|
+
title: string;
|
|
21
|
+
content: string;
|
|
22
|
+
}
|
|
23
|
+
/** Pages as files to write: optional Jekyll front matter (with a permalink when baseURL is set) and a "generated" banner. */
|
|
24
|
+
export declare function pageFiles(facts: Facts, frontMatter?: "none" | "jekyll"): PageFile[];
|
package/dist/core/pages.js
CHANGED
|
@@ -122,3 +122,14 @@ export function impressum(facts) {
|
|
|
122
122
|
}
|
|
123
123
|
return { file: "impressum.md", title: "Impressum", path: "impressum/", markdown: lines.join("\n") };
|
|
124
124
|
}
|
|
125
|
+
/** Pages as files to write: optional Jekyll front matter (with a permalink when baseURL is set) and a "generated" banner. */
|
|
126
|
+
export function pageFiles(facts, frontMatter = "jekyll") {
|
|
127
|
+
return renderPages(facts).map((page) => {
|
|
128
|
+
const permalink = facts.pages.baseURL ? new URL(page.path, facts.pages.baseURL.replace(/\/?$/, "/")).pathname : "";
|
|
129
|
+
const front = frontMatter === "jekyll"
|
|
130
|
+
? `---\nlayout: default\ntitle: ${JSON.stringify(page.title)}\n${permalink ? `permalink: ${permalink}\n` : ""}---\n\n`
|
|
131
|
+
: "";
|
|
132
|
+
const banner = "<!-- Generated by ShelfReady (`shelf pages`) from shelfready.yaml. Edit that file, not this page. -->\n\n";
|
|
133
|
+
return { file: page.file, title: page.title, content: front + banner + page.markdown };
|
|
134
|
+
});
|
|
135
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type Json = Record<string, unknown>;
|
|
2
|
+
interface Tool {
|
|
3
|
+
name: string;
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: Json;
|
|
7
|
+
annotations: Json;
|
|
8
|
+
run: (args: Json) => Promise<{
|
|
9
|
+
text: string;
|
|
10
|
+
data: Json;
|
|
11
|
+
}> | {
|
|
12
|
+
text: string;
|
|
13
|
+
data: Json;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare const TOOLS: Tool[];
|
|
17
|
+
interface Request {
|
|
18
|
+
jsonrpc: "2.0";
|
|
19
|
+
id?: string | number | null;
|
|
20
|
+
method?: string;
|
|
21
|
+
params?: Json;
|
|
22
|
+
}
|
|
23
|
+
/** Handle one JSON-RPC message. Returns the response, or undefined for notifications. */
|
|
24
|
+
export declare function handle(msg: Request): Promise<Json | undefined>;
|
|
25
|
+
/** Serve MCP over stdio: one JSON-RPC message per line. Only protocol messages go to stdout. */
|
|
26
|
+
export declare function serveStdio(input?: NodeJS.ReadableStream, output?: NodeJS.WritableStream): Promise<void>;
|
|
27
|
+
export {};
|
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
// ShelfReady MCP server: the CLI's commands as MCP tools over stdio (`shelf mcp`).
|
|
2
|
+
// Hand-rolled JSON-RPC instead of @modelcontextprotocol/sdk to keep the package dependency-free;
|
|
3
|
+
// test/mcp.test.ts checks it against the official SDK client.
|
|
4
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
7
|
+
import { createInterface } from "node:readline";
|
|
8
|
+
import { addAgentsNote, appPrivacy, check, checklist, checklistSummary, checkOnline, CURRENT_VERSION, factsToYAML, initFacts, knowledgeBase, legalView, lookup, migrateFile, pageFiles, readFacts, scan, sdkCollects, sdkTracks, setTicks, } from "./index.js";
|
|
9
|
+
const VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
10
|
+
const PROTOCOL_VERSIONS = ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"];
|
|
11
|
+
const INSTRUCTIONS = `ShelfReady gets an iOS app ready for the App Store: privacy policy, support page, Impressum (DE/AT), App Privacy answers and a go-live checklist, all generated from one file, shelfready.yaml, in the app's repo.
|
|
12
|
+
Every tool takes \`path\`, the app repository (default: the server's working directory).
|
|
13
|
+
Typical flow: scan → init (if there's no shelfready.yaml) → fill privacyNotes and support.faq in the YAML with the developer → check → pages → app_privacy → checklist (tick manual items only when the developer confirms they did them).
|
|
14
|
+
Never invent publisher facts (legal name, address, VAT ID, register): ask the developer. Generated pages are drafts, not legal advice.`;
|
|
15
|
+
class ToolError extends Error {
|
|
16
|
+
}
|
|
17
|
+
const pathProp = { path: { type: "string", description: "App repository folder. Default: the server's working directory." } };
|
|
18
|
+
const str = (description) => ({ type: "string", description });
|
|
19
|
+
const bool = (description) => ({ type: "boolean", description });
|
|
20
|
+
function repo(args) {
|
|
21
|
+
return resolve(typeof args.path === "string" && args.path ? args.path : process.cwd());
|
|
22
|
+
}
|
|
23
|
+
/** Resolve a file the tool will write, refusing anything outside the repo. */
|
|
24
|
+
function inside(root, file) {
|
|
25
|
+
const full = resolve(root, file);
|
|
26
|
+
const rel = relative(root, full);
|
|
27
|
+
if (rel.startsWith("..") || isAbsolute(rel))
|
|
28
|
+
throw new ToolError(`${file} is outside the repository ${root}; refusing to write there.`);
|
|
29
|
+
return full;
|
|
30
|
+
}
|
|
31
|
+
function load(root) {
|
|
32
|
+
const file = join(root, "shelfready.yaml");
|
|
33
|
+
if (!existsSync(file))
|
|
34
|
+
throw new ToolError(`No shelfready.yaml in ${root}. Run the init tool first.`);
|
|
35
|
+
try {
|
|
36
|
+
return { file, ...readFacts(file) };
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
throw new ToolError(e instanceof Error ? e.message : String(e));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** "NSPrivacyCollectedDataTypePurchaseHistory" → "PurchaseHistory". */
|
|
43
|
+
const short = (s) => s.replace(/^NSPrivacyCollectedDataType(Purpose)?/, "");
|
|
44
|
+
const icon = (level) => (level === "error" ? "✗" : level === "warn" ? "!" : "✓");
|
|
45
|
+
const findingLines = (findings) => findings.map((f) => `${icon(f.level)} ${f.rule}: ${f.message}`).join("\n");
|
|
46
|
+
const counts = (findings) => ({
|
|
47
|
+
errors: findings.filter((f) => f.level === "error").length,
|
|
48
|
+
warnings: findings.filter((f) => f.level === "warn").length,
|
|
49
|
+
});
|
|
50
|
+
async function findingsFor(root, online) {
|
|
51
|
+
const { facts, fileVersion } = load(root);
|
|
52
|
+
const s = scan(root);
|
|
53
|
+
let findings = check(facts, s, { fileVersion });
|
|
54
|
+
let onlineFindings;
|
|
55
|
+
if (online) {
|
|
56
|
+
onlineFindings = await checkOnline(facts);
|
|
57
|
+
findings = [...findings.filter((f) => f.level !== "ok"), ...onlineFindings];
|
|
58
|
+
if (!findings.some((f) => f.level !== "ok"))
|
|
59
|
+
findings.unshift({ level: "ok", rule: "all", message: "shelfready.yaml matches the repo." });
|
|
60
|
+
}
|
|
61
|
+
return { facts, fileVersion, scan: s, findings, onlineFindings };
|
|
62
|
+
}
|
|
63
|
+
export const TOOLS = [
|
|
64
|
+
{
|
|
65
|
+
name: "scan",
|
|
66
|
+
title: "Scan an iOS repo",
|
|
67
|
+
description: "Read the app repository without changing it: Xcode projects, bundle IDs, display names, permission texts (NS…UsageDescription), privacy manifests (PrivacyInfo.xcprivacy) and third-party packages (SwiftPM, CocoaPods, Carthage).",
|
|
68
|
+
inputSchema: { type: "object", properties: { ...pathProp } },
|
|
69
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
70
|
+
run: (a) => {
|
|
71
|
+
const r = scan(repo(a));
|
|
72
|
+
const text = [
|
|
73
|
+
`Bundle IDs: ${r.bundleIdentifiers.join(", ") || "none"}`,
|
|
74
|
+
`Display names: ${r.displayNames.join(", ") || "none"}`,
|
|
75
|
+
`Permission texts: ${Object.keys(r.purposeStrings).sort().join(", ") || "none"}`,
|
|
76
|
+
`Packages: ${r.packages.map((p) => p.identity).join(", ") || "none"}`,
|
|
77
|
+
`Privacy manifests: ${r.privacyManifests.length}`,
|
|
78
|
+
].join("\n");
|
|
79
|
+
return { text, data: r };
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "init",
|
|
84
|
+
title: "Create shelfready.yaml",
|
|
85
|
+
description: "Scan the repo and write shelfready.yaml, the single source of truth for the pages. Ask the developer for country, email, brand, legal name and trader status first; don't guess them. Refuses to overwrite an existing file unless force is true.",
|
|
86
|
+
inputSchema: {
|
|
87
|
+
type: "object",
|
|
88
|
+
properties: {
|
|
89
|
+
...pathProp,
|
|
90
|
+
country: str("Publisher country, ISO 3166-1 alpha-2 (e.g. DE). Decides which pages are required."),
|
|
91
|
+
email: str("Public contact email shown on the pages."),
|
|
92
|
+
brand: str("Brand or studio name shown on the pages."),
|
|
93
|
+
publisher: str("Legal name. Required for traders."),
|
|
94
|
+
trader: bool("EU trader status: true if the app or in-app purchases cost money."),
|
|
95
|
+
phone: str("Second contact channel for DE/AT traders."),
|
|
96
|
+
voice: { type: "string", enum: ["I", "we"], description: "How pages speak: I (solo developer) or we (team)." },
|
|
97
|
+
baseUrl: str("Where the pages will live, e.g. https://example.com/myapp/"),
|
|
98
|
+
force: bool("Overwrite an existing shelfready.yaml."),
|
|
99
|
+
agentsNote: bool("Also add a short ShelfReady note to AGENTS.md (or CLAUDE.md, if the repo uses that) so coding agents run the checks before a release. Ask the developer first."),
|
|
100
|
+
},
|
|
101
|
+
required: ["country", "email"],
|
|
102
|
+
},
|
|
103
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
|
|
104
|
+
run: (a) => {
|
|
105
|
+
const root = repo(a);
|
|
106
|
+
const out = join(root, "shelfready.yaml");
|
|
107
|
+
if (existsSync(out) && a.force !== true)
|
|
108
|
+
throw new ToolError(`${out} exists. Pass force: true to overwrite it (the developer's edits would be lost).`);
|
|
109
|
+
let result;
|
|
110
|
+
try {
|
|
111
|
+
result = initFacts(scan(root), a);
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
throw new ToolError(e instanceof Error ? e.message : String(e));
|
|
115
|
+
}
|
|
116
|
+
const yaml = factsToYAML(result.facts);
|
|
117
|
+
writeFileSync(out, yaml);
|
|
118
|
+
const lines = [`Wrote ${out}`, ...result.notes];
|
|
119
|
+
let agents;
|
|
120
|
+
if (a.agentsNote === true) {
|
|
121
|
+
agents = addAgentsNote(root);
|
|
122
|
+
lines.push(agents.action === "present" ? `${relative(root, agents.file)} already has the ShelfReady note.` : `${agents.action === "created" ? "Created" : "Added the ShelfReady note to"} ${relative(root, agents.file)}.`);
|
|
123
|
+
}
|
|
124
|
+
return { text: lines.join("\n"), data: { file: out, notes: result.notes, yaml, ...(agents ? { agentsNote: agents } : {}) } };
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "check",
|
|
129
|
+
title: "Preflight check",
|
|
130
|
+
description: "Compare shelfready.yaml with the repo: new SDKs or data types the pages don't mention, missing privacy manifests, placeholder permission texts, missing trader or Impressum details, outdated schema. online: true also fetches the live pages and checks they show the YAML's date, email and FAQ.",
|
|
131
|
+
inputSchema: { type: "object", properties: { ...pathProp, online: bool("Also check the live pages over the network.") } },
|
|
132
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
133
|
+
run: async (a) => {
|
|
134
|
+
const { findings } = await findingsFor(repo(a), a.online === true);
|
|
135
|
+
const c = counts(findings);
|
|
136
|
+
return { text: `${findingLines(findings)}\n\n${c.errors} errors, ${c.warnings} warnings.`, data: { ...c, findings } };
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "checklist",
|
|
141
|
+
title: "Go-live checklist",
|
|
142
|
+
description: "The go-live checklist: automatic items computed from check, and manual items (trademark search, App Store Connect steps…) the developer ticks with the tick tool. Each open item says how to do it.",
|
|
143
|
+
inputSchema: { type: "object", properties: { ...pathProp, online: bool("Also verify the live pages over the network.") } },
|
|
144
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
145
|
+
run: async (a) => {
|
|
146
|
+
const r = await findingsFor(repo(a), a.online === true);
|
|
147
|
+
const rows = checklist({ facts: r.facts, scan: r.scan, findings: check(r.facts, r.scan, { fileVersion: r.fileVersion }), ...(r.onlineFindings ? { online: r.onlineFindings } : {}) });
|
|
148
|
+
const mark = { done: "✓", todo: "○", fail: "✗", unchecked: "?" };
|
|
149
|
+
const lines = rows.map((x) => `${mark[x.status]} ${x.title}${x.detail ? ` (${x.detail})` : ""}${x.automatic ? "" : ` [${x.id}]`}${x.status !== "done" && x.how ? `\n ${x.how}` : ""}`);
|
|
150
|
+
const done = rows.filter((x) => x.status === "done").length;
|
|
151
|
+
const unchecked = rows.filter((x) => x.status === "unchecked").length;
|
|
152
|
+
return { text: `${lines.join("\n")}\n\n${checklistSummary(rows).replace("--online", "online: true")}`, data: { done, unchecked, total: rows.length, items: rows } };
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "tick",
|
|
157
|
+
title: "Tick checklist items",
|
|
158
|
+
description: "Mark manual checklist items as done (or undo them) in shelfready.yaml, keeping its comments. Only tick an item when the developer says they did it. Automatic items can't be ticked; fix the repo instead.",
|
|
159
|
+
inputSchema: {
|
|
160
|
+
type: "object",
|
|
161
|
+
properties: { ...pathProp, ids: { type: "array", items: { type: "string" }, description: "Manual item IDs, e.g. [\"trademark\", \"testflight\"]." }, done: bool("false to untick. Default true.") },
|
|
162
|
+
required: ["ids"],
|
|
163
|
+
},
|
|
164
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
165
|
+
run: (a) => {
|
|
166
|
+
const { file } = load(repo(a));
|
|
167
|
+
const ids = Array.isArray(a.ids) ? a.ids.map(String) : [];
|
|
168
|
+
if (!ids.length)
|
|
169
|
+
throw new ToolError("Pass at least one checklist item ID in ids.");
|
|
170
|
+
const done = a.done !== false;
|
|
171
|
+
try {
|
|
172
|
+
writeFileSync(file, setTicks(file, ids, done));
|
|
173
|
+
}
|
|
174
|
+
catch (e) {
|
|
175
|
+
throw new ToolError(e instanceof Error ? e.message : String(e));
|
|
176
|
+
}
|
|
177
|
+
return { text: `${done ? "Ticked" : "Unticked"} ${ids.join(", ")} in ${file}.`, data: { file, ids, done } };
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "pages",
|
|
182
|
+
title: "Generate legal pages",
|
|
183
|
+
description: "Generate the privacy policy, support page and (for DE/AT) Impressum as Markdown from shelfready.yaml. write: false returns the pages without writing files. swiftui writes a SwiftUI LegalView with the Impressum for the in-app requirement. The pages are drafts, not legal advice.",
|
|
184
|
+
inputSchema: {
|
|
185
|
+
type: "object",
|
|
186
|
+
properties: {
|
|
187
|
+
...pathProp,
|
|
188
|
+
out: str("Output folder inside the repo. Default shelfready/pages."),
|
|
189
|
+
frontMatter: { type: "string", enum: ["jekyll", "none"], description: "Front matter for static site generators. Default jekyll." },
|
|
190
|
+
swiftui: str("Also write LegalView.swift to this path inside the repo."),
|
|
191
|
+
write: bool("false to only return the pages. Default true."),
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
195
|
+
run: (a) => {
|
|
196
|
+
const root = repo(a);
|
|
197
|
+
const { facts } = load(root);
|
|
198
|
+
const files = pageFiles(facts, a.frontMatter === "none" ? "none" : "jekyll");
|
|
199
|
+
if (a.write === false) {
|
|
200
|
+
return { text: files.map((f) => `=== ${f.file} ===\n${f.content}`).join("\n\n"), data: { written: [], pages: files } };
|
|
201
|
+
}
|
|
202
|
+
const dir = inside(root, typeof a.out === "string" && a.out ? a.out : "shelfready/pages");
|
|
203
|
+
mkdirSync(dir, { recursive: true });
|
|
204
|
+
const written = files.map((f) => {
|
|
205
|
+
writeFileSync(join(dir, f.file), f.content);
|
|
206
|
+
return join(dir, f.file);
|
|
207
|
+
});
|
|
208
|
+
const notes = [];
|
|
209
|
+
if (typeof a.swiftui === "string" && a.swiftui) {
|
|
210
|
+
const swift = inside(root, a.swiftui);
|
|
211
|
+
mkdirSync(dirname(swift), { recursive: true });
|
|
212
|
+
writeFileSync(swift, legalView(facts));
|
|
213
|
+
written.push(swift);
|
|
214
|
+
if (!facts.pages.baseURL)
|
|
215
|
+
notes.push("pages.baseURL is empty; the LegalView links will be relative and won't open.");
|
|
216
|
+
}
|
|
217
|
+
return { text: [`Wrote:`, ...written.map((w) => ` ${relative(root, w)}`), ...notes].join("\n"), data: { written, notes } };
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: "app_privacy",
|
|
222
|
+
title: "App Privacy answers",
|
|
223
|
+
description: "Derive the App Store Connect App Privacy answers from shelfready.yaml, in fastlane's app_privacy_details.json format. Lists data types that can't be mapped automatically; those must be answered by hand, never guessed. Pass write to save the JSON.",
|
|
224
|
+
inputSchema: { type: "object", properties: { ...pathProp, write: str("Save the JSON to this path inside the repo, e.g. fastlane/app_privacy_details.json.") } },
|
|
225
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
226
|
+
run: (a) => {
|
|
227
|
+
const root = repo(a);
|
|
228
|
+
const { facts } = load(root);
|
|
229
|
+
const { entries, unmapped } = appPrivacy(facts);
|
|
230
|
+
const json = JSON.stringify(entries, null, 2) + "\n";
|
|
231
|
+
const notCollected = entries.every((e) => e.data_protections?.includes("DATA_NOT_COLLECTED"));
|
|
232
|
+
const lines = [notCollected ? "No data collected: answer \"Data Not Collected\" in App Store Connect." : `${entries.length} data types to declare in App Store Connect.`];
|
|
233
|
+
let file;
|
|
234
|
+
if (typeof a.write === "string" && a.write) {
|
|
235
|
+
file = inside(root, a.write);
|
|
236
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
237
|
+
writeFileSync(file, json);
|
|
238
|
+
lines.push(`Wrote ${relative(root, file)}. Upload with: fastlane run upload_app_privacy_details_to_app_store json_path:${relative(root, file)}`);
|
|
239
|
+
}
|
|
240
|
+
if (unmapped.length)
|
|
241
|
+
lines.push(`Answer by hand in App Store Connect: ${unmapped.join(", ")}`);
|
|
242
|
+
return { text: `${lines.join("\n")}\n\n${json}`, data: { entries, unmapped, ...(file ? { file } : {}) } };
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "sdk_info",
|
|
247
|
+
title: "What an SDK collects",
|
|
248
|
+
description: "Look up a third-party iOS SDK in ShelfReady's knowledge base, built from each SDK's own privacy manifest: what it collects, whether it tracks, and where that's declared. Without name, lists the SDKs covered.",
|
|
249
|
+
inputSchema: { type: "object", properties: { name: str("Swift package identity, CocoaPods or Carthage name, e.g. sentry-cocoa, firebase-ios-sdk, Alamofire.") } },
|
|
250
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
251
|
+
run: (a) => {
|
|
252
|
+
if (typeof a.name !== "string" || !a.name) {
|
|
253
|
+
const sdks = knowledgeBase().map((e) => ({ identity: e.identity, name: e.name, vendor: e.vendor }));
|
|
254
|
+
return { text: sdks.map((s) => `${s.identity}: ${s.name} (${s.vendor})`).join("\n"), data: { sdks } };
|
|
255
|
+
}
|
|
256
|
+
const e = lookup(a.name);
|
|
257
|
+
if (!e)
|
|
258
|
+
return { text: `${a.name} isn't in the knowledge base yet. Read its PrivacyInfo.xcprivacy, or the vendor's privacy docs, and add what it collects to shelfready.yaml by hand.`, data: { found: false } };
|
|
259
|
+
const collects = sdkCollects(e);
|
|
260
|
+
const text = [
|
|
261
|
+
`${e.name} (${e.vendor}), checked ${e.checked} at ${e.repository} ${e.commit.slice(0, 7)}`,
|
|
262
|
+
`Tracking: ${sdkTracks(e) ? "yes" : "no"}`,
|
|
263
|
+
`Collects:${collects.length ? "" : " nothing declared"}`,
|
|
264
|
+
...collects.map((c) => ` - ${short(c.type)}${c.linked ? ", linked to the user" : ""}${c.tracking ? ", used for tracking" : ""}${c.purposes?.length ? `, for ${c.purposes.map(short).join(", ")}` : ""}`),
|
|
265
|
+
...(e.notes ? [`Notes: ${e.notes}`] : []),
|
|
266
|
+
].join("\n");
|
|
267
|
+
return { text, data: { found: true, entry: e, collects, tracking: sdkTracks(e) } };
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: "migrate",
|
|
272
|
+
title: "Migrate shelfready.yaml",
|
|
273
|
+
description: `Update shelfready.yaml to the current schema (v${CURRENT_VERSION}), keeping comments and wording. dryRun: true shows the changes without writing.`,
|
|
274
|
+
inputSchema: { type: "object", properties: { ...pathProp, dryRun: bool("Show what would change without writing.") } },
|
|
275
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
276
|
+
run: (a) => {
|
|
277
|
+
const file = join(repo(a), "shelfready.yaml");
|
|
278
|
+
if (!existsSync(file))
|
|
279
|
+
throw new ToolError(`No shelfready.yaml in ${repo(a)}.`);
|
|
280
|
+
let r;
|
|
281
|
+
try {
|
|
282
|
+
r = migrateFile(file);
|
|
283
|
+
}
|
|
284
|
+
catch (e) {
|
|
285
|
+
throw new ToolError(e instanceof Error ? e.message : String(e));
|
|
286
|
+
}
|
|
287
|
+
if (r.from === r.to)
|
|
288
|
+
return { text: `shelfready.yaml is already schema v${r.to}.`, data: { from: r.from, to: r.to, notes: [], written: false } };
|
|
289
|
+
const write = a.dryRun !== true;
|
|
290
|
+
if (write)
|
|
291
|
+
writeFileSync(file, r.text);
|
|
292
|
+
return { text: [`v${r.from} → v${r.to}`, ...r.notes, write ? `Wrote ${file}.` : "(dry run, nothing written)"].join("\n"), data: { from: r.from, to: r.to, notes: r.notes, written: write } };
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
];
|
|
296
|
+
/** Handle one JSON-RPC message. Returns the response, or undefined for notifications. */
|
|
297
|
+
export async function handle(msg) {
|
|
298
|
+
const isRequest = msg.id !== undefined && msg.id !== null;
|
|
299
|
+
const reply = (result) => ({ jsonrpc: "2.0", id: msg.id, result });
|
|
300
|
+
const fail = (code, message) => ({ jsonrpc: "2.0", id: msg.id ?? null, error: { code, message } });
|
|
301
|
+
if (msg?.jsonrpc !== "2.0" || typeof msg.method !== "string")
|
|
302
|
+
return isRequest ? fail(-32600, "Invalid request") : undefined;
|
|
303
|
+
if (!isRequest)
|
|
304
|
+
return undefined; // notifications/initialized, notifications/cancelled, …
|
|
305
|
+
switch (msg.method) {
|
|
306
|
+
case "initialize": {
|
|
307
|
+
const asked = String(msg.params?.protocolVersion ?? "");
|
|
308
|
+
return reply({
|
|
309
|
+
protocolVersion: PROTOCOL_VERSIONS.includes(asked) ? asked : PROTOCOL_VERSIONS[0],
|
|
310
|
+
capabilities: { tools: { listChanged: false } },
|
|
311
|
+
serverInfo: { name: "shelfready", title: "ShelfReady", version: VERSION },
|
|
312
|
+
instructions: INSTRUCTIONS,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
case "ping":
|
|
316
|
+
return reply({});
|
|
317
|
+
case "tools/list":
|
|
318
|
+
return reply({ tools: TOOLS.map(({ run: _run, ...t }) => t) });
|
|
319
|
+
case "tools/call": {
|
|
320
|
+
const tool = TOOLS.find((t) => t.name === msg.params?.name);
|
|
321
|
+
if (!tool)
|
|
322
|
+
return fail(-32602, `Unknown tool: ${String(msg.params?.name)}`);
|
|
323
|
+
const args = (msg.params?.arguments ?? {});
|
|
324
|
+
try {
|
|
325
|
+
const { text, data } = await tool.run(args);
|
|
326
|
+
return reply({ content: [{ type: "text", text }], structuredContent: data });
|
|
327
|
+
}
|
|
328
|
+
catch (e) {
|
|
329
|
+
const message = e instanceof ToolError || e instanceof Error ? e.message : String(e);
|
|
330
|
+
return reply({ content: [{ type: "text", text: message }], isError: true });
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
default:
|
|
334
|
+
return fail(-32601, `Method not found: ${msg.method}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/** Serve MCP over stdio: one JSON-RPC message per line. Only protocol messages go to stdout. */
|
|
338
|
+
export async function serveStdio(input = process.stdin, output = process.stdout) {
|
|
339
|
+
// Anything a dependency logs must not corrupt the protocol stream.
|
|
340
|
+
console.log = console.info = (...args) => console.error(...args);
|
|
341
|
+
const send = (m) => output.write(JSON.stringify(m) + "\n");
|
|
342
|
+
const rl = createInterface({ input, crlfDelay: Infinity });
|
|
343
|
+
const pending = new Set();
|
|
344
|
+
for await (const line of rl) {
|
|
345
|
+
if (!line.trim())
|
|
346
|
+
continue;
|
|
347
|
+
let parsed;
|
|
348
|
+
try {
|
|
349
|
+
parsed = JSON.parse(line);
|
|
350
|
+
}
|
|
351
|
+
catch {
|
|
352
|
+
send({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "Parse error" } });
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
const p = (async () => {
|
|
356
|
+
if (Array.isArray(parsed)) {
|
|
357
|
+
const out = (await Promise.all(parsed.map((m) => handle(m)))).filter(Boolean);
|
|
358
|
+
if (out.length)
|
|
359
|
+
send(out);
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
const out = await handle(parsed);
|
|
363
|
+
if (out)
|
|
364
|
+
send(out);
|
|
365
|
+
}
|
|
366
|
+
})();
|
|
367
|
+
pending.add(p);
|
|
368
|
+
void p.finally(() => pending.delete(p));
|
|
369
|
+
}
|
|
370
|
+
await Promise.all(pending);
|
|
371
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shelfready",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Get an iOS app ready for the App Store
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Get an iOS app ready for the App Store: legal pages, App Privacy answers, privacy manifests and a go-live checklist. CLI and MCP server for coding agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"shelf": "dist/cli.js",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"yaml": "^2.9.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
39
40
|
"@types/node": "^22.20.5",
|
|
40
41
|
"tsx": "^4.23.15",
|
|
41
42
|
"typescript": "^5.9.3"
|
|
@@ -57,6 +58,18 @@
|
|
|
57
58
|
"gdpr",
|
|
58
59
|
"app-privacy",
|
|
59
60
|
"cli",
|
|
60
|
-
"fastlane"
|
|
61
|
-
|
|
61
|
+
"fastlane",
|
|
62
|
+
"mcp",
|
|
63
|
+
"mcp-server",
|
|
64
|
+
"model-context-protocol",
|
|
65
|
+
"claude",
|
|
66
|
+
"claude-code",
|
|
67
|
+
"codex",
|
|
68
|
+
"cursor",
|
|
69
|
+
"ai-agents",
|
|
70
|
+
"swift",
|
|
71
|
+
"xcode",
|
|
72
|
+
"app-store-connect"
|
|
73
|
+
],
|
|
74
|
+
"mcpName": "io.github.halfbatch-studio/shelfready"
|
|
62
75
|
}
|