create-ailk 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/export-content.js +5 -3
- package/dist/lib/env-catalog.js +4 -0
- package/dist/lib/import-mdx.d.ts +69 -0
- package/dist/lib/import-mdx.js +119 -3
- package/dist/migrate-content.d.ts +3 -1
- package/dist/migrate-content.js +52 -1
- package/package.json +3 -3
- package/templates/apps/api/.env.example +11 -0
- package/templates/apps/mcp/CLAUDE.md +4 -2
- package/templates/apps/web/CLAUDE.md +4 -1
- package/templates/apps/web/lib/mcp-oauth.ts +49 -6
- package/versions.json +47 -47
package/README.md
CHANGED
|
@@ -704,6 +704,18 @@ AILK_AGENT_KEY=<agent key> create-ailk migrate-content ./my-site --apply --api-u
|
|
|
704
704
|
and then saved with the errors the editor shows, not `failed`.
|
|
705
705
|
- The site's dependencies must be installed (`pnpm install`): the pages are
|
|
706
706
|
read through the site's own `@working-theory/content-adapters`.
|
|
707
|
+
- Every page is written with a live-source mark (#10898): its words already
|
|
708
|
+
ship on the live site, so a heading its page type's template asks for and
|
|
709
|
+
the page lacks is listed as advisory, and publish takes the page. Editing
|
|
710
|
+
the page's words in the hub drops the mark, and the page is then gated as
|
|
711
|
+
any other. A dry run prints a line after each page —
|
|
712
|
+
`<path>: publish — publishable`, `publishable · advisory: missing "<heading>", …`
|
|
713
|
+
or `not publishable · <status> · <code>:<where> "<what>"` — and then
|
|
714
|
+
`publish: publishable <N> (<K> with advisory headings) · not publishable <M>`.
|
|
715
|
+
The verdict is the site's installed `@working-theory/validation`'s, not the
|
|
716
|
+
hub's: it sees no library-file finding, and no layout the hub repairs
|
|
717
|
+
differently. A site whose validation package predates the live-source
|
|
718
|
+
report prints one `publish: not checked` line instead.
|
|
707
719
|
- Exit 0 when no page failed, 1 when any did (in a dry run, when any would), 2
|
|
708
720
|
on a refusal (a missing key, workspace id or origin, no `content/`, the
|
|
709
721
|
adapter not installed), which sends nothing.
|
package/dist/export-content.js
CHANGED
|
@@ -52,11 +52,13 @@ const EDITORIAL_DIRS = {
|
|
|
52
52
|
const EDITORIAL_RENAMES = { publishedAt: "date", updatedAt: "updated" };
|
|
53
53
|
/** Keys an editorial file does not carry: its path decides both. */
|
|
54
54
|
const EDITORIAL_DROPPED = new Set(["type", "slug"]);
|
|
55
|
+
/** The hub's live-source mark (#10898 D7): evidence about the draft's words, never a file's key. */
|
|
56
|
+
const LIVE_SOURCE_KEY = "liveSource";
|
|
55
57
|
/**
|
|
56
58
|
* Never written from `siteFields` (#10806 D6): a mapped fumadocs key, an
|
|
57
|
-
* address key, the strip marker, or a prototype name.
|
|
59
|
+
* address key, the strip marker, the live-source mark, or a prototype name.
|
|
58
60
|
*/
|
|
59
|
-
const NOT_SITE_FIELDS = new Set(["date", "updated", "type", "slug", "oss", "siteFields", "__proto__"]);
|
|
61
|
+
const NOT_SITE_FIELDS = new Set(["date", "updated", "type", "slug", "oss", "siteFields", LIVE_SOURCE_KEY, "__proto__"]);
|
|
60
62
|
const INDEX_SLUG = "index";
|
|
61
63
|
/** The store's address shapes, restated (create-ailk has no runtime dep): a path built from them stays in the site. */
|
|
62
64
|
const TYPE_SHAPE = /^[A-Z][A-Za-z]*$/;
|
|
@@ -101,7 +103,7 @@ export function recombine(content, sections, codec, editorial, pinned) {
|
|
|
101
103
|
const frontmatter = {};
|
|
102
104
|
const { siteFields, ...stored } = rest;
|
|
103
105
|
for (const [key, value] of Object.entries(editorial ? stored : rest)) {
|
|
104
|
-
if (editorial && EDITORIAL_DROPPED.has(key))
|
|
106
|
+
if (key === LIVE_SOURCE_KEY || (editorial && EDITORIAL_DROPPED.has(key)))
|
|
105
107
|
continue;
|
|
106
108
|
frontmatter[editorial ? (EDITORIAL_RENAMES[key] ?? key) : key] = value;
|
|
107
109
|
}
|
package/dist/lib/env-catalog.js
CHANGED
|
@@ -163,6 +163,10 @@ export const ENV_CATALOG = {
|
|
|
163
163
|
description: 'Set to "true" or "1" for an MCP HTTP transport with no sessions, which any instance can answer; "false" or "0" keeps sessions in one process. Unset means stateless on Vercel (src/app.ts) and stateful on a port (src/index.ts).',
|
|
164
164
|
secret: false,
|
|
165
165
|
},
|
|
166
|
+
MCP_OAUTH_ISSUER: {
|
|
167
|
+
description: 'Which MCP authorization server\'s OAuth tokens the API honours: unset for the site\'s own apps/web, "admin" on a hub whose MCP server names the Admin (#10912). A malformed value refuses every OAuth token.',
|
|
168
|
+
secret: false,
|
|
169
|
+
},
|
|
166
170
|
MCP_PUBLIC_HTTP_URL: {
|
|
167
171
|
description: "The public URL of the MCP HTTP transport (apps/mcp's `/mcp`), advertised by /.well-known/mcp.json; with BETTER_AUTH_URL it turns on the OAuth metadata. Set by create-ailk provision-env.",
|
|
168
172
|
secret: false,
|
package/dist/lib/import-mdx.d.ts
CHANGED
|
@@ -38,7 +38,34 @@ export interface MdxAdapterModule {
|
|
|
38
38
|
* names the keys it would have sent.
|
|
39
39
|
*/
|
|
40
40
|
siteFields?: SiteFieldRules;
|
|
41
|
+
/**
|
|
42
|
+
* The verdict the hub's publish gate will give a live-source page (#10898
|
|
43
|
+
* D6), from the site's own contract; `undefined` for a type with no
|
|
44
|
+
* registry entry. Absent when the site's validation package predates the
|
|
45
|
+
* live-source report.
|
|
46
|
+
*/
|
|
47
|
+
publishCheck?: (type: string, content: Record<string, unknown>, layout: Layout | undefined) => PublishVerdict | undefined;
|
|
48
|
+
}
|
|
49
|
+
/** One issue of the hub's content report, typed structurally. */
|
|
50
|
+
export interface ContentIssueLike {
|
|
51
|
+
code: string;
|
|
52
|
+
location: {
|
|
53
|
+
kind: string;
|
|
54
|
+
heading?: string;
|
|
55
|
+
key?: string;
|
|
56
|
+
setting?: string;
|
|
57
|
+
};
|
|
58
|
+
fixer: string;
|
|
41
59
|
}
|
|
60
|
+
/** Whether publish will take a live-source page, and what its report lists (#10898 D6). */
|
|
61
|
+
export type PublishVerdict = {
|
|
62
|
+
publishable: true;
|
|
63
|
+
advisory: ContentIssueLike[];
|
|
64
|
+
} | {
|
|
65
|
+
publishable: false;
|
|
66
|
+
status: string;
|
|
67
|
+
blocking: ContentIssueLike[];
|
|
68
|
+
};
|
|
42
69
|
/** The validation package's site-field rule, typed structurally. */
|
|
43
70
|
export interface SiteFieldRules {
|
|
44
71
|
refusal: (key: string, value: unknown) => string | null;
|
|
@@ -67,6 +94,8 @@ export interface ImportMdxOptions {
|
|
|
67
94
|
onLine?: (line: string) => void;
|
|
68
95
|
/** Set Live each written page that has no Live version (#10659 D2); off by default. */
|
|
69
96
|
publish?: boolean;
|
|
97
|
+
/** Send the live-source mark on each page (#10898 D5): migrate-content's import only. */
|
|
98
|
+
liveSource?: boolean;
|
|
70
99
|
}
|
|
71
100
|
/** The tree a page came from: `content/` or the site's `apps/web/content`. */
|
|
72
101
|
export type ImportMdxRoot = "content" | "editorial";
|
|
@@ -76,6 +105,8 @@ export type ImportMdxOutcome = {
|
|
|
76
105
|
result: "created" | "updated" | "unchanged";
|
|
77
106
|
type: string;
|
|
78
107
|
slug: string;
|
|
108
|
+
/** With `liveSource` and `publishCheck`: what the hub's publish gate will answer (#10898 D6). */
|
|
109
|
+
publishVerdict?: PublishVerdict;
|
|
79
110
|
} | {
|
|
80
111
|
root: ImportMdxRoot;
|
|
81
112
|
path: string;
|
|
@@ -97,6 +128,11 @@ interface At {
|
|
|
97
128
|
root: ImportMdxRoot;
|
|
98
129
|
path: string;
|
|
99
130
|
}
|
|
131
|
+
/** The layout a converted page stores in its structure layer (#10643). */
|
|
132
|
+
export interface Layout {
|
|
133
|
+
kind: "sections";
|
|
134
|
+
sections: unknown[];
|
|
135
|
+
}
|
|
100
136
|
/** An outcome's printed path: an editorial one says so (#10701 D6). */
|
|
101
137
|
export declare function outcomePath(at: At): string;
|
|
102
138
|
/** The whole report, one line per page and a final count line. */
|
|
@@ -131,6 +167,39 @@ export declare function layoutRefusal(layout: {
|
|
|
131
167
|
sections: readonly unknown[];
|
|
132
168
|
}): string | undefined;
|
|
133
169
|
export declare function importMdx(opts: ImportMdxOptions): Promise<ImportMdxResult>;
|
|
170
|
+
/** A content report, typed structurally. */
|
|
171
|
+
interface ContentReportLike {
|
|
172
|
+
status: string;
|
|
173
|
+
issues: ContentIssueLike[];
|
|
174
|
+
advisory?: ContentIssueLike[];
|
|
175
|
+
}
|
|
176
|
+
/** The four contract members a publish verdict is computed from, typed structurally. */
|
|
177
|
+
export interface PublishCheckMembers {
|
|
178
|
+
checkPage: (words: {
|
|
179
|
+
template: string;
|
|
180
|
+
title: string;
|
|
181
|
+
description: string;
|
|
182
|
+
slug: string;
|
|
183
|
+
body: string;
|
|
184
|
+
}, structure: unknown) => ContentReportLike;
|
|
185
|
+
liveSourceReport: (report: ContentReportLike) => ContentReportLike;
|
|
186
|
+
templates: Readonly<Record<string, {
|
|
187
|
+
kind: string;
|
|
188
|
+
}>>;
|
|
189
|
+
registry: readonly {
|
|
190
|
+
key: string;
|
|
191
|
+
template: string;
|
|
192
|
+
}[];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The hub's publish gate over a live-source page, as the site's contract
|
|
196
|
+
* reads it: the page's words checked against its type's template and the
|
|
197
|
+
* structure publish's repair would build — the layout when the page converts,
|
|
198
|
+
* an editorial template's frontmatter quartet, else none — with the
|
|
199
|
+
* required-heading findings advisory. Publish repairs every `script` finding,
|
|
200
|
+
* so only the rest block.
|
|
201
|
+
*/
|
|
202
|
+
export declare function publishCheckOf(members: PublishCheckMembers): NonNullable<MdxAdapterModule["publishCheck"]>;
|
|
134
203
|
/**
|
|
135
204
|
* The site's installed adapter package, resolved from its `apps/web` — never
|
|
136
205
|
* create-ailk's own `node_modules`.
|
package/dist/lib/import-mdx.js
CHANGED
|
@@ -41,6 +41,12 @@
|
|
|
41
41
|
* vocabulary does not name rides in `siteFields`, and a blog post's tags are
|
|
42
42
|
* sent (#10806); a key the store cannot keep is named with its reason.
|
|
43
43
|
*
|
|
44
|
+
* Given `liveSource` (#10898 D5), each page carries the hub's live-source
|
|
45
|
+
* mark — the SHA-256 of the body it sends — so the hub lists the template's
|
|
46
|
+
* missing headings as advisory, not blocking; a file never supplies one. With
|
|
47
|
+
* the site's contract members (`publishCheck`), each written page's outcome
|
|
48
|
+
* carries the verdict the hub's publish gate will give it (D6).
|
|
49
|
+
*
|
|
44
50
|
* Given `publish` (#10659 D2), each page with no Live version is set Live
|
|
45
51
|
* after it is written (`POST …/publish`, the draft tip); a page already Live
|
|
46
52
|
* is never published over. The first refused publish stops the publishes
|
|
@@ -54,6 +60,7 @@
|
|
|
54
60
|
* walk docs/specs/10701-import-mdx-walks-the-editorial-spec.md; its site
|
|
55
61
|
* fields docs/specs/10806-the-editorial-import-drops-blog-spec.md.
|
|
56
62
|
*/
|
|
63
|
+
import { createHash } from "node:crypto";
|
|
57
64
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
58
65
|
import { createRequire } from "node:module";
|
|
59
66
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -68,6 +75,12 @@ const CONTENT_ADAPTERS_PACKAGE = "@working-theory/content-adapters";
|
|
|
68
75
|
const VALIDATION_PACKAGE = "@working-theory/validation";
|
|
69
76
|
/** The adapter package's frontmatter parser, resolved from its entry. */
|
|
70
77
|
const FRONTMATTER_PACKAGE = "gray-matter";
|
|
78
|
+
/** The page-type registry: a dependency of the adapter package (#10898 D6). */
|
|
79
|
+
const PAGE_TYPES_PACKAGE = "@working-theory/schema/page-types";
|
|
80
|
+
/** The hub's live-source content key (`LIVE_SOURCE_KEY`, api-content-write `content.ts`), restated: no runtime dep. */
|
|
81
|
+
const LIVE_SOURCE_KEY = "liveSource";
|
|
82
|
+
/** `EDITORIAL_FIELDS` (api-content-write `derive-publish.ts`): the editorial structure publish's repair builds. */
|
|
83
|
+
const EDITORIAL_STRUCTURE_FIELDS = ["author", "tags", "order", "parent"];
|
|
71
84
|
/** The adapter's locale shape (`BCP47_RE` in its `mdx/adapter.ts`). */
|
|
72
85
|
const LOCALE = /^[a-z]{2}(-[A-Z]{2})?$/;
|
|
73
86
|
/** `SLUG_PATTERN` in the adapter's `errors.ts`, restated: no runtime dep. */
|
|
@@ -104,7 +117,7 @@ const EDITORIAL_FIELDS = {
|
|
|
104
117
|
sections: "sections",
|
|
105
118
|
};
|
|
106
119
|
/** Keys not sent and not reported: the path decides both, and a strip marker. */
|
|
107
|
-
const EDITORIAL_IGNORED = new Set(["type", "slug", "oss"]);
|
|
120
|
+
const EDITORIAL_IGNORED = new Set(["type", "slug", "oss", LIVE_SOURCE_KEY]);
|
|
108
121
|
/** Why a key is not sent (#10806 D4); `siteFieldRefusal`'s own reasons are the rest. */
|
|
109
122
|
const NOT_SENT = {
|
|
110
123
|
parent: "the path decides a blog post's parent",
|
|
@@ -588,6 +601,13 @@ function wrongLocale(at, answer, locale) {
|
|
|
588
601
|
}
|
|
589
602
|
return failed(at, `the API does not serve locale ${locale}`, `not sent: the API does not serve locale ${locale}`);
|
|
590
603
|
}
|
|
604
|
+
/** `value` without the live-source mark. */
|
|
605
|
+
function withoutLiveSource(value) {
|
|
606
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
607
|
+
return value;
|
|
608
|
+
const { [LIVE_SOURCE_KEY]: _mark, ...rest } = value;
|
|
609
|
+
return rest;
|
|
610
|
+
}
|
|
591
611
|
async function writePage(t, page, locale, content, layout, publicTags) {
|
|
592
612
|
const { root, path, type, slug } = page;
|
|
593
613
|
const pagePath = `${t.base}/content/${encodeURIComponent(type)}/${encodeURIComponent(slug)}`;
|
|
@@ -596,10 +616,12 @@ async function writePage(t, page, locale, content, layout, publicTags) {
|
|
|
596
616
|
// The route's `statusOf`: anything but `draft` has a Live version.
|
|
597
617
|
let live = false;
|
|
598
618
|
let stored;
|
|
619
|
+
let sent = false;
|
|
599
620
|
const outcome = (result) => ({
|
|
600
621
|
outcome: { root, path, result, type, slug },
|
|
601
622
|
live,
|
|
602
623
|
stored,
|
|
624
|
+
sent,
|
|
603
625
|
});
|
|
604
626
|
// The words are written; now the layout, under the token the draft holds
|
|
605
627
|
// (`null` for a page that has none yet).
|
|
@@ -636,8 +658,10 @@ async function writePage(t, page, locale, content, layout, publicTags) {
|
|
|
636
658
|
const token = read.data["structureToken"];
|
|
637
659
|
const structureToken = typeof token === "string" ? token : null;
|
|
638
660
|
stored = read.data["content"];
|
|
639
|
-
|
|
640
|
-
|
|
661
|
+
// #10898 D5 — a live tip is never re-drafted for the mark alone.
|
|
662
|
+
const liveTip = read.data["status"] === "published";
|
|
663
|
+
if (canonical(compared(liveTip ? withoutLiveSource(stored) : stored, content, publicTags)) ===
|
|
664
|
+
canonical(compared(liveTip ? withoutLiveSource(content) : content, content, publicTags))) {
|
|
641
665
|
return done("unchanged", structureToken);
|
|
642
666
|
}
|
|
643
667
|
// The token is the version just compared against, so a draft saved
|
|
@@ -646,6 +670,7 @@ async function writePage(t, page, locale, content, layout, publicTags) {
|
|
|
646
670
|
if ("network" in saved || saved.status !== 200)
|
|
647
671
|
return refusedAnswer(page, saved);
|
|
648
672
|
stored = saved.data["content"];
|
|
673
|
+
sent = true;
|
|
649
674
|
// A save carries the structure token forward (#10330 D5).
|
|
650
675
|
return (wrongLocale(page, saved, locale) ?? done("updated", structureToken));
|
|
651
676
|
}
|
|
@@ -659,6 +684,7 @@ async function writePage(t, page, locale, content, layout, publicTags) {
|
|
|
659
684
|
return refusedAnswer(page, created);
|
|
660
685
|
if (created.status === 201) {
|
|
661
686
|
stored = created.data["content"];
|
|
687
|
+
sent = true;
|
|
662
688
|
return wrongLocale(page, created, locale) ?? done("created");
|
|
663
689
|
}
|
|
664
690
|
// 409 slug_taken: another page holds this page's registry link (#10268
|
|
@@ -1160,6 +1186,18 @@ export async function importMdx(opts) {
|
|
|
1160
1186
|
fail(converted.reason);
|
|
1161
1187
|
continue;
|
|
1162
1188
|
}
|
|
1189
|
+
// #10898 D5 — a file never supplies the mark; the importer computes it.
|
|
1190
|
+
const { [LIVE_SOURCE_KEY]: _fileMark, ...words } = converted.content;
|
|
1191
|
+
const body = words["body"];
|
|
1192
|
+
converted.content =
|
|
1193
|
+
opts.liveSource === true && typeof body === "string"
|
|
1194
|
+
? {
|
|
1195
|
+
...words,
|
|
1196
|
+
[LIVE_SOURCE_KEY]: {
|
|
1197
|
+
bodySha256: createHash("sha256").update(body, "utf8").digest("hex"),
|
|
1198
|
+
},
|
|
1199
|
+
}
|
|
1200
|
+
: words;
|
|
1163
1201
|
if (converted.notCarried.length > 0) {
|
|
1164
1202
|
onLine(`${outcomePath(page)}: inline HTML not carried — ${converted.notCarried.join(", ")} (the layout holds no HTML; their text is kept)`);
|
|
1165
1203
|
}
|
|
@@ -1179,6 +1217,23 @@ export async function importMdx(opts) {
|
|
|
1179
1217
|
}
|
|
1180
1218
|
const result = await writePage(t, page, defaultLocale, converted.content, converted.layout, rules?.publicPageTags);
|
|
1181
1219
|
halt = result.halt;
|
|
1220
|
+
// #10898 D5 — a hub that predates the mark strips it, so every re-run
|
|
1221
|
+
// would save the page again; say so. An answer that carries no content
|
|
1222
|
+
// says nothing about what was kept.
|
|
1223
|
+
if (opts.liveSource === true &&
|
|
1224
|
+
result.sent === true &&
|
|
1225
|
+
result.stored !== null &&
|
|
1226
|
+
typeof result.stored === "object" &&
|
|
1227
|
+
!Object.hasOwn(result.stored, LIVE_SOURCE_KEY)) {
|
|
1228
|
+
onLine(`${outcomePath(page)}: not kept by the hub: ${LIVE_SOURCE_KEY} (the hub predates the live-source mark; update it and re-run)`);
|
|
1229
|
+
}
|
|
1230
|
+
// #10898 D6 — what the hub's publish gate will answer for these words.
|
|
1231
|
+
const check = opts.liveSource === true ? opts.adapters.publishCheck : undefined;
|
|
1232
|
+
if (check !== undefined && !("reason" in result.outcome)) {
|
|
1233
|
+
const verdict = check(page.type, converted.content, converted.layout);
|
|
1234
|
+
if (verdict !== undefined)
|
|
1235
|
+
result.outcome = { ...result.outcome, publishVerdict: verdict };
|
|
1236
|
+
}
|
|
1182
1237
|
// #10806 D4 — an older hub strips what it has no member for; say so.
|
|
1183
1238
|
// An answer that carries no content says nothing about what was kept.
|
|
1184
1239
|
const dropped = rules === undefined ||
|
|
@@ -1234,6 +1289,43 @@ export async function importMdx(opts) {
|
|
|
1234
1289
|
...(opts.publish === true && { live, published }),
|
|
1235
1290
|
};
|
|
1236
1291
|
}
|
|
1292
|
+
/**
|
|
1293
|
+
* The hub's publish gate over a live-source page, as the site's contract
|
|
1294
|
+
* reads it: the page's words checked against its type's template and the
|
|
1295
|
+
* structure publish's repair would build — the layout when the page converts,
|
|
1296
|
+
* an editorial template's frontmatter quartet, else none — with the
|
|
1297
|
+
* required-heading findings advisory. Publish repairs every `script` finding,
|
|
1298
|
+
* so only the rest block.
|
|
1299
|
+
*/
|
|
1300
|
+
export function publishCheckOf(members) {
|
|
1301
|
+
return (type, content, layout) => {
|
|
1302
|
+
const template = members.registry.find((entry) => entry.key === type)?.template;
|
|
1303
|
+
if (template === undefined)
|
|
1304
|
+
return undefined;
|
|
1305
|
+
const text = (key) => {
|
|
1306
|
+
const value = content[key];
|
|
1307
|
+
return typeof value === "string" ? value : "";
|
|
1308
|
+
};
|
|
1309
|
+
const structure = layout ??
|
|
1310
|
+
(members.templates[template]?.kind === "editorial"
|
|
1311
|
+
? {
|
|
1312
|
+
kind: "editorial",
|
|
1313
|
+
frontmatter: Object.fromEntries(EDITORIAL_STRUCTURE_FIELDS.filter((field) => content[field] !== undefined).map((field) => [field, content[field]])),
|
|
1314
|
+
}
|
|
1315
|
+
: null);
|
|
1316
|
+
const report = members.liveSourceReport(members.checkPage({
|
|
1317
|
+
template,
|
|
1318
|
+
title: text("title"),
|
|
1319
|
+
description: text("description"),
|
|
1320
|
+
slug: text("slug"),
|
|
1321
|
+
body: text("body"),
|
|
1322
|
+
}, structure));
|
|
1323
|
+
const blocking = report.issues.filter((issue) => issue.fixer !== "script");
|
|
1324
|
+
return blocking.length === 0
|
|
1325
|
+
? { publishable: true, advisory: report.advisory ?? [] }
|
|
1326
|
+
: { publishable: false, status: report.status, blocking };
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1237
1329
|
// ── The site's own adapter (D1) ─────────────────────────────────────────────
|
|
1238
1330
|
/** Whether a `node_modules` at or above `dir` holds the adapter package. */
|
|
1239
1331
|
function installedAbove(dir) {
|
|
@@ -1301,6 +1393,18 @@ export async function loadSiteMdxAdapter(siteRoot) {
|
|
|
1301
1393
|
catch {
|
|
1302
1394
|
// Not resolvable from the adapter: no parser.
|
|
1303
1395
|
}
|
|
1396
|
+
// #10898 D6 — the site's own page-type registry, beside its contract; a
|
|
1397
|
+
// validation package that predates the live-source report, or no registry,
|
|
1398
|
+
// leaves the dry run's publish verdict unchecked, and the run says so.
|
|
1399
|
+
let registry;
|
|
1400
|
+
try {
|
|
1401
|
+
const path = createRequire(entry).resolve(PAGE_TYPES_PACKAGE);
|
|
1402
|
+
registry = (await import(pathToFileURL(path).href))["pageTypeRegistry"];
|
|
1403
|
+
}
|
|
1404
|
+
catch {
|
|
1405
|
+
// Not resolvable from the adapter: no registry.
|
|
1406
|
+
}
|
|
1407
|
+
const { checkPage, liveSourceReport, PAGE_TEMPLATES: templates } = validation;
|
|
1304
1408
|
return {
|
|
1305
1409
|
...mod,
|
|
1306
1410
|
...(typeof codec === "function" && {
|
|
@@ -1317,6 +1421,18 @@ export async function loadSiteMdxAdapter(siteRoot) {
|
|
|
1317
1421
|
maxBytes,
|
|
1318
1422
|
},
|
|
1319
1423
|
}),
|
|
1424
|
+
...(typeof checkPage === "function" &&
|
|
1425
|
+
typeof liveSourceReport === "function" &&
|
|
1426
|
+
templates !== null &&
|
|
1427
|
+
typeof templates === "object" &&
|
|
1428
|
+
Array.isArray(registry) && {
|
|
1429
|
+
publishCheck: publishCheckOf({
|
|
1430
|
+
checkPage: checkPage,
|
|
1431
|
+
liveSourceReport: liveSourceReport,
|
|
1432
|
+
templates: templates,
|
|
1433
|
+
registry: registry,
|
|
1434
|
+
}),
|
|
1435
|
+
}),
|
|
1320
1436
|
...(typeof matter === "function" && {
|
|
1321
1437
|
parseFrontmatter: (raw) => {
|
|
1322
1438
|
const { data, content } = matter(raw);
|
|
@@ -33,6 +33,8 @@ export interface MigrateContentOptions {
|
|
|
33
33
|
* other method throws.
|
|
34
34
|
*/
|
|
35
35
|
export declare function readOnlyFetch(inner: typeof globalThis.fetch, locale: string): typeof globalThis.fetch;
|
|
36
|
+
/** What a dry run prints when the site's contract cannot give a verdict. */
|
|
37
|
+
export declare const PUBLISH_NOT_CHECKED = "publish: not checked \u2014 the site's @working-theory/validation has no live-source report; update the site's dependencies and re-run";
|
|
36
38
|
export declare function migrateContent(opts: MigrateContentOptions): Promise<{
|
|
37
39
|
result: ImportMdxResult;
|
|
38
40
|
exitCode: 0 | 1;
|
|
@@ -45,5 +47,5 @@ export interface MigrateContentArgs {
|
|
|
45
47
|
workspaceId: string | undefined;
|
|
46
48
|
help: boolean;
|
|
47
49
|
}
|
|
48
|
-
export declare const MIGRATE_CONTENT_HELP = "create-ailk migrate-content \u2014 import an existing site's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk migrate-content [<dir>] [--apply] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --apply Write the pages. Without it the command reads the\n workspace, prints what it would do, and writes\n nothing.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL. https: only\n (http: on localhost or 127.0.0.1).\n --workspace <wksp_id> The workspace the pages are written to. Else\n AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page (and each legacy\ncontent/<Type>/<slug>.mdx) is written to the workspace as a draft through\nthe API's content routes, with the agent key, which is read from\nAILK_AGENT_KEY only and needs the content-edit grant. Nothing is published,\nso the live site does not change. The site needs no .ailk-site-manifest.json\nand may be a spoke; its dependencies must be installed. A page whose\nfrontmatter carries sections is converted: its words are written to the\npage's Markdown and its sections to its layout.\n\nEach FAQ item and glossary-index term becomes one Language item of its kind,\nset Live when the run creates it, and its section pins the items in the\norder the file lists them. A question on several pages is one item, with\nthe FAQ page's words (the glossary page's, for a term). Lines prefixed\nlanguage: report each item, and each page the database read will not show\nas its file does. An API with no Language collection leaves them inline.\n\nWhen the site has apps/web/content, each blog post and docs page in it is\nwritten too: apps/web/content/en/blog/<slug>.mdx (or <slug>/index.mdx) as a\nBlogPosting, or one series down, blog/<series>/<post>.mdx, as a BlogPosting\nwhose parent is the series; the same under docs as a DocsDetail, and each\ndirectory's own index.mdx as its BlogList or DocsList index. A file the walk\nskips is listed with the rule it failed. Their lines are prefixed\neditorial: \u2014 each outcome's root is content or editorial.\n\nA dry run prints create, update, unchanged, skipped or failed per page. It\ncannot see a write the API would refuse at --apply (a conflict or a server\nerror), nor a layout change on a page whose words did not change, and a\npage whose content fails its page type is planned and saved\nwith errors the editor shows, not failed. --apply prints created, updated,\nunchanged, skipped or failed per page, so a re-run is safe. Exit 0 when no\npage failed, 1 when any did, 2 on a refusal (nothing is sent).\n";
|
|
50
|
+
export declare const MIGRATE_CONTENT_HELP = "create-ailk migrate-content \u2014 import an existing site's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk migrate-content [<dir>] [--apply] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --apply Write the pages. Without it the command reads the\n workspace, prints what it would do, and writes\n nothing.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL. https: only\n (http: on localhost or 127.0.0.1).\n --workspace <wksp_id> The workspace the pages are written to. Else\n AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page (and each legacy\ncontent/<Type>/<slug>.mdx) is written to the workspace as a draft through\nthe API's content routes, with the agent key, which is read from\nAILK_AGENT_KEY only and needs the content-edit grant. Nothing is published,\nso the live site does not change. The site needs no .ailk-site-manifest.json\nand may be a spoke; its dependencies must be installed. A page whose\nfrontmatter carries sections is converted: its words are written to the\npage's Markdown and its sections to its layout.\n\nEach FAQ item and glossary-index term becomes one Language item of its kind,\nset Live when the run creates it, and its section pins the items in the\norder the file lists them. A question on several pages is one item, with\nthe FAQ page's words (the glossary page's, for a term). Lines prefixed\nlanguage: report each item, and each page the database read will not show\nas its file does. An API with no Language collection leaves them inline.\n\nWhen the site has apps/web/content, each blog post and docs page in it is\nwritten too: apps/web/content/en/blog/<slug>.mdx (or <slug>/index.mdx) as a\nBlogPosting, or one series down, blog/<series>/<post>.mdx, as a BlogPosting\nwhose parent is the series; the same under docs as a DocsDetail, and each\ndirectory's own index.mdx as its BlogList or DocsList index. A file the walk\nskips is listed with the rule it failed. Their lines are prefixed\neditorial: \u2014 each outcome's root is content or editorial.\n\nA dry run prints create, update, unchanged, skipped or failed per page. It\ncannot see a write the API would refuse at --apply (a conflict or a server\nerror), nor a layout change on a page whose words did not change, and a\npage whose content fails its page type is planned and saved\nwith errors the editor shows, not failed. --apply prints created, updated,\nunchanged, skipped or failed per page, so a re-run is safe. Exit 0 when no\npage failed, 1 when any did, 2 on a refusal (nothing is sent).\n\nEvery page is written with a live-source mark: its words already ship on the\nlive site, so the hub lists a heading the page type's template asks for and\nthe page lacks as advisory, and publish takes the page. Editing the page's\nwords in the hub drops the mark. A dry run prints a publish line after each\npage: publishable, the advisory headings the hub will list, or the status and\nfindings that will stop the publish. The verdict is the site's installed\n@working-theory/validation's, not the hub's; it sees no library-file finding\nand no layout the hub repairs differently. A site whose validation predates\nthe live-source report prints one \"publish: not checked\" line instead.\n";
|
|
49
51
|
export declare function parseMigrateContentArgs(argv: string[]): MigrateContentArgs;
|
package/dist/migrate-content.js
CHANGED
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
* leave the process. `--apply` writes; a second `--apply` reports every page
|
|
18
18
|
* `unchanged`.
|
|
19
19
|
*
|
|
20
|
+
* Every page carries the hub's live-source mark (#10898 D5): its words already
|
|
21
|
+
* ship on a live site, so the template's missing headings are advisory, not a
|
|
22
|
+
* reason publish refuses it. The dry run prints, per planned page, whether
|
|
23
|
+
* publish will take it and which headings the hub will list (D6).
|
|
24
|
+
*
|
|
20
25
|
* Credentials follow `seed-workspace` (#10204 D2): the origin from
|
|
21
26
|
* `--api-url`, else `AILK_API_URL`; the workspace id from `--workspace`, else
|
|
22
27
|
* `AILK_WORKSPACE_ID`; the agent key from `AILK_AGENT_KEY` and nowhere else.
|
|
@@ -89,6 +94,26 @@ function planLine(outcome) {
|
|
|
89
94
|
? `${outcomePath(outcome)}: ${verb} — ${outcome.reason}`
|
|
90
95
|
: `${outcomePath(outcome)}: ${verb}`;
|
|
91
96
|
}
|
|
97
|
+
// ── The publish verdict (#10898 D6) ─────────────────────────────────────────
|
|
98
|
+
/** `missing "Contact"` for an advisory finding; `placeholder:section "hero"` for a blocking one. */
|
|
99
|
+
function issueText(issue, advisory) {
|
|
100
|
+
const { heading, setting, key } = issue.location;
|
|
101
|
+
const subject = heading ?? setting ?? key;
|
|
102
|
+
const quoted = subject === undefined ? "" : ` "${subject}"`;
|
|
103
|
+
if (advisory)
|
|
104
|
+
return `${issue.code === "empty-section" ? "empty" : "missing"}${quoted}`;
|
|
105
|
+
return `${issue.code}:${issue.location.kind}${quoted}`;
|
|
106
|
+
}
|
|
107
|
+
function verdictText(verdict) {
|
|
108
|
+
if (!verdict.publishable) {
|
|
109
|
+
return `not publishable · ${verdict.status} · ${verdict.blocking.map((issue) => issueText(issue, false)).join(", ")}`;
|
|
110
|
+
}
|
|
111
|
+
return verdict.advisory.length === 0
|
|
112
|
+
? "publishable"
|
|
113
|
+
: `publishable · advisory: ${verdict.advisory.map((issue) => issueText(issue, true)).join(", ")}`;
|
|
114
|
+
}
|
|
115
|
+
/** What a dry run prints when the site's contract cannot give a verdict. */
|
|
116
|
+
export const PUBLISH_NOT_CHECKED = "publish: not checked — the site's @working-theory/validation has no live-source report; update the site's dependencies and re-run";
|
|
92
117
|
// ── The command (D1–D4) ─────────────────────────────────────────────────────
|
|
93
118
|
export async function migrateContent(opts) {
|
|
94
119
|
const targetDir = resolve(opts.targetDir);
|
|
@@ -148,6 +173,7 @@ export async function migrateContent(opts) {
|
|
|
148
173
|
defaultLocale: LOCALE,
|
|
149
174
|
fetch: transport,
|
|
150
175
|
...(opts.sleep !== undefined && { sleep: opts.sleep }),
|
|
176
|
+
liveSource: true,
|
|
151
177
|
// A dry run's importer lines say `created`/`updated`, which nothing was.
|
|
152
178
|
...(apply && { onLine }),
|
|
153
179
|
});
|
|
@@ -160,9 +186,24 @@ export async function migrateContent(opts) {
|
|
|
160
186
|
}
|
|
161
187
|
else {
|
|
162
188
|
const { created, updated, unchanged, skipped } = result.counts;
|
|
163
|
-
|
|
189
|
+
const checked = pass.adapters.publishCheck !== undefined;
|
|
190
|
+
const verdicts = [];
|
|
191
|
+
for (const outcome of result.pages) {
|
|
164
192
|
onLine(planLine(outcome));
|
|
193
|
+
if (!("reason" in outcome) && outcome.publishVerdict !== undefined) {
|
|
194
|
+
verdicts.push(outcome.publishVerdict);
|
|
195
|
+
onLine(`${outcomePath(outcome)}: publish — ${verdictText(outcome.publishVerdict)}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
165
198
|
onLine(`create ${created} · update ${updated} · unchanged ${unchanged} · skipped ${skipped} · failed ${failed}`);
|
|
199
|
+
if (checked) {
|
|
200
|
+
const publishable = verdicts.filter((verdict) => verdict.publishable);
|
|
201
|
+
const advised = publishable.filter((verdict) => verdict.advisory.length > 0);
|
|
202
|
+
onLine(`publish: publishable ${publishable.length} (${advised.length} with advisory headings) · not publishable ${verdicts.length - publishable.length}`);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
onLine(PUBLISH_NOT_CHECKED);
|
|
206
|
+
}
|
|
166
207
|
onLine("Dry run: nothing was written. Re-run with --apply to write these pages.");
|
|
167
208
|
if (failed > 0) {
|
|
168
209
|
onLine(`${failed} page(s) would fail. Fix them before --apply.`);
|
|
@@ -230,6 +271,16 @@ page whose content fails its page type is planned and saved
|
|
|
230
271
|
with errors the editor shows, not failed. --apply prints created, updated,
|
|
231
272
|
unchanged, skipped or failed per page, so a re-run is safe. Exit 0 when no
|
|
232
273
|
page failed, 1 when any did, 2 on a refusal (nothing is sent).
|
|
274
|
+
|
|
275
|
+
Every page is written with a live-source mark: its words already ship on the
|
|
276
|
+
live site, so the hub lists a heading the page type's template asks for and
|
|
277
|
+
the page lacks as advisory, and publish takes the page. Editing the page's
|
|
278
|
+
words in the hub drops the mark. A dry run prints a publish line after each
|
|
279
|
+
page: publishable, the advisory headings the hub will list, or the status and
|
|
280
|
+
findings that will stop the publish. The verdict is the site's installed
|
|
281
|
+
@working-theory/validation's, not the hub's; it sees no library-file finding
|
|
282
|
+
and no layout the hub repairs differently. A site whose validation predates
|
|
283
|
+
the live-source report prints one "publish: not checked" line instead.
|
|
233
284
|
`;
|
|
234
285
|
export function parseMigrateContentArgs(argv) {
|
|
235
286
|
let parsed;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ailk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Scaffolder for AI Launch Kit — `pnpm create ailk@latest <dir>` produces a starter repo consuming @working-theory/* from npm (per ADR 0007).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"tar": "^7.5.21"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@working-theory/schema": "0.
|
|
32
|
-
"@working-theory/templates": "0.
|
|
31
|
+
"@working-theory/schema": "0.57.0",
|
|
32
|
+
"@working-theory/templates": "0.57.0"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
@@ -21,6 +21,17 @@ FRONTEND_URL=http://localhost:3000
|
|
|
21
21
|
# trust — list only origins the deployment owner operates.
|
|
22
22
|
# AILK_TRUSTED_ORIGINS=https://admin.your-domain.com,https://spoke.example
|
|
23
23
|
|
|
24
|
+
# =============================================================================
|
|
25
|
+
# MCP OAuth issuer (#10912)
|
|
26
|
+
# =============================================================================
|
|
27
|
+
# Which authorization server's OAuth tokens the API honours on its MCP twin
|
|
28
|
+
# routes and in Connected clients — set it in the same change as apps/mcp's
|
|
29
|
+
# BETTER_AUTH_URL:
|
|
30
|
+
# unset — the site's own apps/web signs MCP clients in (the default);
|
|
31
|
+
# admin — a hub whose workspace MCP server names the Admin origin;
|
|
32
|
+
# any other value fails closed: every OAuth token is refused.
|
|
33
|
+
# MCP_OAUTH_ISSUER=admin
|
|
34
|
+
|
|
24
35
|
# =============================================================================
|
|
25
36
|
# Local Database (required in production)
|
|
26
37
|
# =============================================================================
|
|
@@ -209,7 +209,7 @@ here. Spec: `docs/specs/3591-tenant-scoped-agent-auth-secure-spec.md` D13–D16.
|
|
|
209
209
|
tools, `list_proposals` and `create_proposal`, twinning `GET`/`POST
|
|
210
210
|
/v1/workspaces/:workspaceId/people/:personId/proposals` with the same grant: a proposal is
|
|
211
211
|
private to one client, `payments` says whether approval leads to a Stripe page, and an agent's
|
|
212
|
-
price is refused `proposal_needs_person` (a person prices) — and (#9681) the four person-thread tools, `get_person_thread`, `set_person_thread_state`, `list_external_threads` and `add_external_thread`, twinning `GET`/`PATCH …/people/:personId/thread` and `GET`/`POST …/people/:personId/external-threads`: a client's whole thread page by page with its read/archived/resolved state, and pointers to email and Slack threads (never message text); reading needs the `people-read` grant, writing also `inbox-act`, and the client erasure route has no tool, by decision — and (#9682) the three person-memory tools, `list_person_memories`, `get_person_memory` and `propose_person_memory`, twinning `GET …/people/:personId/memories`, `GET …/memories/:path` and `POST …/memories`: an agent reads only live, unexpired memories (confirmed by a person, read within 180 days) and its proposal is never live — a new path is a draft, a confirmed one gets a pending version — needing the `people-read` or `people-memory-propose` grant to read and `people-memory-propose` to propose; the six person-only memory routes (edit, delete, confirm, redact, the versions list, restore) have no tool, by decision — and (#9749) `get_slack_connection_status`, twin of `GET /v1/workspaces/:workspaceId/slack-connection` (registered with `workspace`/`multi-tenant`, its route's `TENANCY` row: whether the Organization's Slack is connected, its team name and the date, never a credential; connect and disconnect are a person's act and have no tool, by decision), and `get_prospect_channel_settings` / `set_prospect_channel_settings`, twins of `GET`/`PUT …/prospect-channel` (registered with `scheduling`, their routes' module): the update replaces every field, needs the `meeting-types-manage` grant, is refused `slack_not_connected` while the Organization has no Slack connection, and an agent may change only `enabled`, `channelPrefix` and `archiveDays` — a change to `memberIds` or `welcomeTemplate` is refused `prospect_channel_needs_person` — and (#10218) the content-suggestion pair, `draft_page_suggestions` and `decide_page_suggestion` — and (#10336) the draft pair, `save_draft` and `read_report`, twinning `PATCH`/`GET …/content/:type/:slug` with the `content-edit` grant: `save_draft` takes the page's `content` whole as the PATCH body and its `version` as `X-Draft-Version`, writes a draft version that never goes live, and answers 409 `conflict` with `currentVersion` when the draft moved; `read_report` returns the draft tip, the version a save must send, its open suggestions and the route's check report (`ready`, `needs repair` or `needs your words`), computed by the route and never by the tool — and (#10661) `publish_draft`, twinning `POST …/content/:type/:slug/publish` with the `content-publish` grant: it publishes the draft tip (or a named version) exactly as a person holding that permission does, an agent without the grant is refused 403 `agent_refused` before anything is read, and it never widens Audience or re-enables a doc — and (#10345) the knowledge-base pair, `read_knowledge` and `read_knowledge_doc`, twinning `GET …/knowledge-base` and `GET …/knowledge-base/:type/:slug` with no grant (`docs-read` is every role's): the docs a named member may read (`userId`, by default the agent's own person), at the lower of the agent's person's role and that member's, so naming someone only narrows; Live does not gate them and a disabled doc never appears; `filter: "workspace-memory"` answers the always-loaded set with its `totalTokens` and an 8000-token `warning` — and (#10733) the
|
|
212
|
+
price is refused `proposal_needs_person` (a person prices) — and (#9681) the four person-thread tools, `get_person_thread`, `set_person_thread_state`, `list_external_threads` and `add_external_thread`, twinning `GET`/`PATCH …/people/:personId/thread` and `GET`/`POST …/people/:personId/external-threads`: a client's whole thread page by page with its read/archived/resolved state, and pointers to email and Slack threads (never message text); reading needs the `people-read` grant, writing also `inbox-act`, and the client erasure route has no tool, by decision — and (#9682) the three person-memory tools, `list_person_memories`, `get_person_memory` and `propose_person_memory`, twinning `GET …/people/:personId/memories`, `GET …/memories/:path` and `POST …/memories`: an agent reads only live, unexpired memories (confirmed by a person, read within 180 days) and its proposal is never live — a new path is a draft, a confirmed one gets a pending version — needing the `people-read` or `people-memory-propose` grant to read and `people-memory-propose` to propose; the six person-only memory routes (edit, delete, confirm, redact, the versions list, restore) have no tool, by decision — and (#9749) `get_slack_connection_status`, twin of `GET /v1/workspaces/:workspaceId/slack-connection` (registered with `workspace`/`multi-tenant`, its route's `TENANCY` row: whether the Organization's Slack is connected, its team name and the date, never a credential; connect and disconnect are a person's act and have no tool, by decision), and `get_prospect_channel_settings` / `set_prospect_channel_settings`, twins of `GET`/`PUT …/prospect-channel` (registered with `scheduling`, their routes' module): the update replaces every field, needs the `meeting-types-manage` grant, is refused `slack_not_connected` while the Organization has no Slack connection, and an agent may change only `enabled`, `channelPrefix` and `archiveDays` — a change to `memberIds` or `welcomeTemplate` is refused `prospect_channel_needs_person` — and (#10218) the content-suggestion pair, `draft_page_suggestions` and `decide_page_suggestion` — and (#10336) the draft pair, `save_draft` and `read_report`, twinning `PATCH`/`GET …/content/:type/:slug` with the `content-edit` grant: `save_draft` takes the page's `content` whole as the PATCH body and its `version` as `X-Draft-Version`, writes a draft version that never goes live, and answers 409 `conflict` with `currentVersion` when the draft moved; `read_report` returns the draft tip, the version a save must send, its open suggestions and the route's check report (`ready`, `needs repair` or `needs your words`), computed by the route and never by the tool — and (#10661) `publish_draft`, twinning `POST …/content/:type/:slug/publish` with the `content-publish` grant: it publishes the draft tip (or a named version) exactly as a person holding that permission does, an agent without the grant is refused 403 `agent_refused` before anything is read, and it never widens Audience or re-enables a doc — and (#10345) the knowledge-base pair, `read_knowledge` and `read_knowledge_doc`, twinning `GET …/knowledge-base` and `GET …/knowledge-base/:type/:slug` with no grant (`docs-read` is every role's): the docs a named member may read (`userId`, by default the agent's own person), at the lower of the agent's person's role and that member's, so naming someone only narrows; Live does not gate them and a disabled doc never appears; `filter: "workspace-memory"` answers the always-loaded set with its `totalTokens` and an 8000-token `warning` — and (#10733, issue 10905) the six Language tools, `list_language_items`, `get_language_item`, `save_language_item`, `set_language_item_live`, `list_language_item_pages` and `get_topic_brief`, twinning `GET …/language`, `GET`/`PUT …/language/:kind/:slug`, `POST …/language/:kind/:slug/live`, `GET …/language/:kind/:slug/appears-on` and `GET …/language/topic/:slug/brief` (`mcp-workspace`'s `language.ts`): a workspace's glossary terms, FAQs and topics; reading needs no grant, saving the `content-edit` grant (`version: null` creates, a tip id updates, 409 `slug_taken` / `stale` otherwise) and the Live switch `content-publish` with the `version` the person reviewed; tags are the hub's and never written by a tool; a topic is a keyword cluster for agents and is never shown to visitors, and `get_topic_brief` reads it as a writing brief — its kept rows scored best bets first, from the Live version when Live; the delete route, the Topic's Keyword Planner import and the value-thresholds pair are a person's and have no tool, by decision. No workspace tool widens Audience or re-enables a doc, and only `publish_draft` and `set_language_item_live`, with the `content-publish` grant, set Live — the access and Language delete routes answer every agent 403 `agent_refused`, and the publish and Live routes an agent without the grant, which reaches a tool as the code and status. Each takes its route's params, query and body and returns the route's
|
|
213
213
|
`data`. They are in the parity guard like every other tool, and never in
|
|
214
214
|
`/.well-known/mcp.json`.
|
|
215
215
|
- **The OAuth bearer branch (#10391).** When `BETTER_AUTH_URL` (the site's origin, its OAuth
|
|
@@ -313,7 +313,9 @@ Example (lead routing):
|
|
|
313
313
|
- Don't add a tool without the matching `apps/api` endpoint.
|
|
314
314
|
- Don't put business logic in tool handlers — they're adapters.
|
|
315
315
|
|
|
316
|
-
Last updated: 2026-11-
|
|
316
|
+
Last updated: 2026-11-05 — issue 10905 (D12): `get_topic_brief` (`mcp-workspace`'s `language.ts`) twins `GET …/language/topic/:slug/brief`, and the Language kinds are term, faq and topic — the signed-in workspace surface gains one tool; the import route and the settings pair have no tool — verified against `packages/metadata/src/mcp-tool-catalog.ts`, `packages-paid/mcp-workspace/src/index.ts`, `packages-paid/api-workspace/src/routes/workspaces/language.ts` and `tests/parity/api-parity/kinds/site.ts`.
|
|
317
|
+
|
|
318
|
+
Prior: 2026-11-02 — #10733 (D7, D8): the five Language twins (`mcp-workspace`'s `language.ts`) twin the Language collection's list, read, save, Live and appears-on routes; the person-only delete has no tool — the signed-in workspace surface gains five tools — verified against `packages/metadata/src/mcp-tool-catalog.ts`, `packages-paid/mcp-workspace/src/index.ts`, `packages-paid/api-workspace/src/routes/workspaces/language.ts` and `tests/parity/api-parity/kinds/site.ts`.
|
|
317
319
|
|
|
318
320
|
Prior: 2026-11-02 — #10661 (D1, D5–D8): `publish_draft` (`mcp-workspace`'s `content_publish.ts`) twins the publish route for an agent holding `content-publish`, whose blanket agent refusal narrows to agents without the grant — the signed-in workspace surface is thirty-nine tools — verified against `packages/metadata/src/mcp-tool-catalog.ts`, `packages-paid/mcp-workspace/src/index.ts`, `packages-paid/api-content-write/src/routes/workspaces/content.ts` and `tests/parity/api-parity/kinds/site.ts`.
|
|
319
321
|
|
|
@@ -172,6 +172,7 @@ grant, so the next sign-in asks again. `ref` is in both telemetry scrub lists.
|
|
|
172
172
|
- **Every authorization asks** (decision (b)): a before-hook forces `prompt=consent`, so the plugin always redirects to `/consent` (an `(auth)` page, `AUTH_SEGMENTS`). The page reads only `consent_code` and asks `GET /mcp/consent-details`; Allow posts `POST /mcp/consent`, which binds one `ailk:workspace:<id>` and only role-held `ailk:*` scopes. `/mcp/token` refuses any code that did not pass it or whose approving session has ended, any `code` not shaped like one (so no AILK verification row can be named and consumed), and any non-string body field. The plugin's own `/oauth2/consent`, `/mcp/get-session` and discovery copy are `disabledPaths`; the site serves `/.well-known/oauth-authorization-server` at its root.
|
|
173
173
|
- **Rotation and revocation**: a refresh deletes the used pair and leaves a tombstone, so a replayed refresh token ends the person's line for that client. `POST /mcp/revoke` (RFC 7009) and the person's own `POST /mcp/revoke-client` delete tokens.
|
|
174
174
|
- **A password reset or change deletes every MCP token** of the person: `onPasswordReset`'s guarded blocks, which end the person's sessions first (so none can mint a token in between) and then their tokens (`reason: "session_revocation_failed"` / `"mcp_token_revocation_failed"` on failure, never a rejection) and an after-hook on `/change-password`.
|
|
175
|
+
- **One issuer per token (#10912)**: the plugin takes an optional `issuerTag` and `signInLocation`; this site passes neither, so its tokens carry no `ailk:issuer:` entry and its code exchange, refresh and token-info refuse any token or code that carries one. On a hub the Admin runs a byte-identical copy (`packages-paid/admin/lib/mcp-oauth.ts`, a parity test holds it equal) with `issuerTag: "admin"`, so an edit here is an edit there.
|
|
175
176
|
- Two plugin facts AILK works around: `/mcp/register` answers a raw `Response`, so no after-hook runs on it (the sweep runs before), and the plugin's `/mcp/token` treats any `oauthApplication.type` but `public` as confidential, so `POST /mcp/consent` re-derives it from the stored secret (`public` for a client with no secret, the column defaulting to `web`).
|
|
176
177
|
|
|
177
178
|
## Contact page
|
|
@@ -644,7 +645,9 @@ A list page whose frontmatter sets `navOnly: true` (valid on a registry list typ
|
|
|
644
645
|
- Don't reach into `apps/api` or `apps/mcp` from `apps/web`. They're peer apps — talk via HTTP/MCP.
|
|
645
646
|
- Don't commit images to `screenshots/` — only the `.gitkeep` is tracked.
|
|
646
647
|
|
|
647
|
-
Last updated: 2026-11-
|
|
648
|
+
Last updated: 2026-11-05 — § The MCP authorization server: one issuer per token — the plugin's optional `issuerTag` and `signInLocation`, the refusal of another issuer's token, refresh and code, and the Admin's byte-identical copy (#10912) — verified against `lib/mcp-oauth.ts` and `auth.ts`.
|
|
649
|
+
|
|
650
|
+
Prior: 2026-11-02 — § Theme & styling: `consent.appearance` named beside the other `_site.mdx` chrome keys, and the minimal deck home's hold-back is the band's alone, so a minimal site that picks the card sees it on load there too (#10721) — verified against `app/[locale]/layout.tsx`.
|
|
648
651
|
|
|
649
652
|
Prior: 2026-11-02 — § The same-origin relay: a bot-check refusal names its cause (`classificationReason`, `bypassed`, `isVerifiedBot`, both hosts, `proxied`), `AILK_BOT_CHECK=observe` logs and never refuses, and a BotID-protected site must be reached directly, Cloudflare DNS-only (#10715) — verified against `lib/bot-check.ts`.
|
|
650
653
|
|
|
@@ -16,7 +16,11 @@
|
|
|
16
16
|
* stored-token self-check (`/mcp/token-info`, decision (a): lookup, never
|
|
17
17
|
* JWKS — D1);
|
|
18
18
|
* - registration refuses unsafe redirect URIs and metadata and normalises the
|
|
19
|
-
* self-claimed client name
|
|
19
|
+
* self-claimed client name;
|
|
20
|
+
* - one issuer per token (#10912 D4): a server given an `issuerTag` binds
|
|
21
|
+
* `ailk:issuer:<tag>` beside the workspace, and every server's code
|
|
22
|
+
* exchange, refresh and token-info accept only their own tokens — none
|
|
23
|
+
* for a server with no tag, as a site's apps/web has.
|
|
20
24
|
*
|
|
21
25
|
* Every refusal is code-shaped: no English string reaches a client. No answer
|
|
22
26
|
* or log line carries a token, code, verifier or client secret.
|
|
@@ -24,6 +28,7 @@
|
|
|
24
28
|
import { createHash, timingSafeEqual } from "node:crypto";
|
|
25
29
|
|
|
26
30
|
import {
|
|
31
|
+
ISSUER_SCOPE_PREFIX,
|
|
27
32
|
lowerRole,
|
|
28
33
|
MCP_SCOPES,
|
|
29
34
|
type McpScope,
|
|
@@ -31,6 +36,7 @@ import {
|
|
|
31
36
|
grantsForWorkspace,
|
|
32
37
|
parseGrantedScopes,
|
|
33
38
|
scopesForRole,
|
|
39
|
+
tokenIssuedBy,
|
|
34
40
|
WORKSPACE_SCOPE_PREFIX,
|
|
35
41
|
} from "@working-theory/validation";
|
|
36
42
|
import type { BetterAuthPlugin } from "better-auth";
|
|
@@ -58,6 +64,18 @@ export interface McpOAuthDeps {
|
|
|
58
64
|
* organization they hold a membership in, with that membership's role.
|
|
59
65
|
*/
|
|
60
66
|
readMemberships(userId: string): Promise<McpMembership[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Where `/mcp/sign-in` sends the person: the sign-in page URL, given the
|
|
69
|
+
* authorize query (no leading `?`) and the auth secret. Default: the site's
|
|
70
|
+
* `/sign-in?next=` + the encoded `/api/auth/mcp/authorize?<query>` — today's
|
|
71
|
+
* redirect, byte for byte.
|
|
72
|
+
*/
|
|
73
|
+
signInLocation?(authorizeQuery: string, secret: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* This server's issuer tag (#10912 D4). Absent: the token carries no issuer
|
|
76
|
+
* entry, and only such tokens are this server's.
|
|
77
|
+
*/
|
|
78
|
+
issuerTag?: string;
|
|
61
79
|
}
|
|
62
80
|
|
|
63
81
|
/** The scopes `/mcp/authorize` accepts a request for. */
|
|
@@ -315,6 +333,11 @@ export function mcpOAuthPlugin(deps: McpOAuthDeps) {
|
|
|
315
333
|
}
|
|
316
334
|
}
|
|
317
335
|
|
|
336
|
+
/** Whether a token or code's scopes are this server's own (#10912 D4). */
|
|
337
|
+
function ownsScopes(scopes: string | readonly string[]): boolean {
|
|
338
|
+
return tokenIssuedBy(typeof scopes === "string" ? scopes : scopes.join(" "), deps.issuerTag);
|
|
339
|
+
}
|
|
340
|
+
|
|
318
341
|
async function deleteTokensOf(ctx: Ctx, where: Array<{ field: string; value: string }>): Promise<number> {
|
|
319
342
|
return ctx.context.adapter.deleteMany({ model: "oauthAccessToken", where });
|
|
320
343
|
}
|
|
@@ -398,16 +421,24 @@ export function mcpOAuthPlugin(deps: McpOAuthDeps) {
|
|
|
398
421
|
where: [{ field: "id", value: value.sessionId }],
|
|
399
422
|
})
|
|
400
423
|
: null;
|
|
401
|
-
|
|
424
|
+
// And only a code this server's consent minted: another
|
|
425
|
+
// issuer's code is burnt too (#10912 D4).
|
|
426
|
+
if (
|
|
427
|
+
!approver ||
|
|
428
|
+
new Date(approver.expiresAt) <= new Date() ||
|
|
429
|
+
!ownsScopes(value?.scope ?? [])
|
|
430
|
+
) {
|
|
402
431
|
if (row) await ctx.context.internalAdapter.deleteVerificationByIdentifier(body.code);
|
|
403
432
|
throw refuse("BAD_REQUEST", "invalid_grant");
|
|
404
433
|
}
|
|
405
434
|
}
|
|
406
435
|
if (body.grant_type === "refresh_token" && typeof body.refresh_token === "string") {
|
|
407
|
-
const live = await ctx.context.adapter.findOne({
|
|
436
|
+
const live = await ctx.context.adapter.findOne<OAuthAccessTokenRow>({
|
|
408
437
|
model: "oauthAccessToken",
|
|
409
438
|
where: [{ field: "refreshToken", value: body.refresh_token }],
|
|
410
439
|
});
|
|
440
|
+
// Another issuer's live line: refused and left alone (#10912 D4).
|
|
441
|
+
if (live && !ownsScopes(live.scopes)) throw refuse("BAD_REQUEST", "invalid_grant");
|
|
411
442
|
if (!live) {
|
|
412
443
|
// A rotated refresh token presented again: end the whole line
|
|
413
444
|
// (RFC 9700 §4.14.2, SEC-10357-04).
|
|
@@ -499,8 +530,12 @@ export function mcpOAuthPlugin(deps: McpOAuthDeps) {
|
|
|
499
530
|
for (const [key, value] of Object.entries(ctx.query ?? {})) {
|
|
500
531
|
if (typeof value === "string") params.set(key, value);
|
|
501
532
|
}
|
|
502
|
-
const
|
|
503
|
-
throw ctx.redirect(
|
|
533
|
+
const query = params.toString();
|
|
534
|
+
throw ctx.redirect(
|
|
535
|
+
deps.signInLocation
|
|
536
|
+
? deps.signInLocation(query, ctx.context.secret)
|
|
537
|
+
: `/sign-in?next=${encodeURIComponent(`/api/auth/mcp/authorize?${query}`)}`,
|
|
538
|
+
);
|
|
504
539
|
},
|
|
505
540
|
),
|
|
506
541
|
|
|
@@ -575,7 +610,13 @@ export function mcpOAuthPlugin(deps: McpOAuthDeps) {
|
|
|
575
610
|
}
|
|
576
611
|
|
|
577
612
|
// `openid`, `profile` and `email` are never bound: no id_token.
|
|
578
|
-
const scope = [
|
|
613
|
+
const scope = [
|
|
614
|
+
"offline_access",
|
|
615
|
+
...new Set(chosen),
|
|
616
|
+
WORKSPACE_SCOPE_PREFIX + workspace.id,
|
|
617
|
+
// The issuer entry, only on a server that has a tag (#10912 D4).
|
|
618
|
+
...(deps.issuerTag ? [ISSUER_SCOPE_PREFIX + deps.issuerTag] : []),
|
|
619
|
+
];
|
|
579
620
|
const code = generateRandomString(32, "a-z", "A-Z", "0-9");
|
|
580
621
|
await ctx.context.internalAdapter.updateVerificationByIdentifier(consentCode, {
|
|
581
622
|
value: JSON.stringify({
|
|
@@ -681,6 +722,8 @@ export function mcpOAuthPlugin(deps: McpOAuthDeps) {
|
|
|
681
722
|
where: [{ field: "accessToken", value: accessToken }],
|
|
682
723
|
});
|
|
683
724
|
if (!row || new Date(row.accessTokenExpiresAt) < new Date() || !row.userId) throw invalid();
|
|
725
|
+
// Another issuer's token answers as an unknown one (#10912 D4).
|
|
726
|
+
if (!ownsScopes(row.scopes)) throw invalid();
|
|
684
727
|
const { workspaceId } = parseGrantedScopes(row.scopes);
|
|
685
728
|
if (!workspaceId) throw invalid();
|
|
686
729
|
const membership = (await deps.readMemberships(row.userId)).find((m) => m.workspaceId === workspaceId);
|
package/versions.json
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@working-theory/admin-ui": "0.
|
|
3
|
-
"@working-theory/aeo": "0.
|
|
4
|
-
"@working-theory/agent-context": "0.
|
|
2
|
+
"@working-theory/admin-ui": "0.57.0",
|
|
3
|
+
"@working-theory/aeo": "0.57.0",
|
|
4
|
+
"@working-theory/agent-context": "0.57.0",
|
|
5
5
|
"@working-theory/agent-contract": "0.1.0",
|
|
6
6
|
"@working-theory/agent-memory": "0.0.0",
|
|
7
7
|
"@working-theory/ai": "0.1.0",
|
|
8
|
-
"@working-theory/analytics": "0.
|
|
9
|
-
"@working-theory/api": "0.
|
|
10
|
-
"@working-theory/api-client": "0.
|
|
8
|
+
"@working-theory/analytics": "0.57.0",
|
|
9
|
+
"@working-theory/api": "0.57.0",
|
|
10
|
+
"@working-theory/api-client": "0.57.0",
|
|
11
11
|
"@working-theory/cda-filesystem": "0.0.0",
|
|
12
|
-
"@working-theory/cli": "0.
|
|
13
|
-
"@working-theory/common": "0.
|
|
12
|
+
"@working-theory/cli": "0.57.0",
|
|
13
|
+
"@working-theory/common": "0.57.0",
|
|
14
14
|
"@working-theory/consent": "0.1.0",
|
|
15
|
-
"@working-theory/content-adapters": "0.
|
|
16
|
-
"@working-theory/content-projection": "0.
|
|
17
|
-
"@working-theory/email": "0.
|
|
15
|
+
"@working-theory/content-adapters": "0.57.0",
|
|
16
|
+
"@working-theory/content-projection": "0.57.0",
|
|
17
|
+
"@working-theory/email": "0.57.0",
|
|
18
18
|
"@working-theory/env": "0.0.0",
|
|
19
|
-
"@working-theory/eslint-config": "0.
|
|
20
|
-
"@working-theory/fumadocs-schema": "0.
|
|
19
|
+
"@working-theory/eslint-config": "0.57.0",
|
|
20
|
+
"@working-theory/fumadocs-schema": "0.57.0",
|
|
21
21
|
"@working-theory/ids": "0.20.0",
|
|
22
|
-
"@working-theory/jsonld": "0.
|
|
23
|
-
"@working-theory/license": "0.
|
|
24
|
-
"@working-theory/mcp-server": "0.
|
|
25
|
-
"@working-theory/metadata": "0.
|
|
26
|
-
"@working-theory/observability": "0.
|
|
27
|
-
"@working-theory/page-renderer": "0.
|
|
22
|
+
"@working-theory/jsonld": "0.57.0",
|
|
23
|
+
"@working-theory/license": "0.57.0",
|
|
24
|
+
"@working-theory/mcp-server": "0.57.0",
|
|
25
|
+
"@working-theory/metadata": "0.57.0",
|
|
26
|
+
"@working-theory/observability": "0.57.0",
|
|
27
|
+
"@working-theory/page-renderer": "0.57.0",
|
|
28
28
|
"@working-theory/plugin-mcp": "0.1.3",
|
|
29
|
-
"@working-theory/schema": "0.
|
|
30
|
-
"@working-theory/schema-pack-registry": "0.
|
|
31
|
-
"@working-theory/schema-validator": "0.
|
|
32
|
-
"@working-theory/sections-registry": "0.
|
|
33
|
-
"@working-theory/site-config": "0.
|
|
34
|
-
"@working-theory/spoke-checkout": "0.7.
|
|
35
|
-
"@working-theory/stripe-client": "0.
|
|
36
|
-
"@working-theory/templates": "0.
|
|
37
|
-
"@working-theory/theme": "0.
|
|
38
|
-
"@working-theory/ui": "0.
|
|
39
|
-
"@working-theory/validation": "0.
|
|
40
|
-
"@working-theory/web-i18n": "0.
|
|
41
|
-
"@working-theory/admin": "0.
|
|
42
|
-
"@working-theory/api-commerce": "0.1.
|
|
43
|
-
"@working-theory/api-content-write": "0.
|
|
44
|
-
"@working-theory/api-hub": "0.4.
|
|
45
|
-
"@working-theory/api-multi-tenant": "0.2.
|
|
46
|
-
"@working-theory/api-scheduling": "0.4.
|
|
47
|
-
"@working-theory/api-signal-collectors": "0.4.
|
|
48
|
-
"@working-theory/api-workspace": "0.
|
|
29
|
+
"@working-theory/schema": "0.57.0",
|
|
30
|
+
"@working-theory/schema-pack-registry": "0.57.0",
|
|
31
|
+
"@working-theory/schema-validator": "0.57.0",
|
|
32
|
+
"@working-theory/sections-registry": "0.57.0",
|
|
33
|
+
"@working-theory/site-config": "0.57.0",
|
|
34
|
+
"@working-theory/spoke-checkout": "0.7.13",
|
|
35
|
+
"@working-theory/stripe-client": "0.57.0",
|
|
36
|
+
"@working-theory/templates": "0.57.0",
|
|
37
|
+
"@working-theory/theme": "0.57.0",
|
|
38
|
+
"@working-theory/ui": "0.57.0",
|
|
39
|
+
"@working-theory/validation": "0.57.0",
|
|
40
|
+
"@working-theory/web-i18n": "0.57.0",
|
|
41
|
+
"@working-theory/admin": "0.12.0",
|
|
42
|
+
"@working-theory/api-commerce": "0.1.11",
|
|
43
|
+
"@working-theory/api-content-write": "0.7.0",
|
|
44
|
+
"@working-theory/api-hub": "0.4.3",
|
|
45
|
+
"@working-theory/api-multi-tenant": "0.2.6",
|
|
46
|
+
"@working-theory/api-scheduling": "0.4.8",
|
|
47
|
+
"@working-theory/api-signal-collectors": "0.4.1",
|
|
48
|
+
"@working-theory/api-workspace": "0.7.0",
|
|
49
49
|
"@working-theory/billing-client": "0.0.0",
|
|
50
50
|
"@working-theory/branding": "0.0.0",
|
|
51
51
|
"@working-theory/license-client": "0.0.0",
|
|
52
52
|
"@working-theory/license-manifest": "0.0.0",
|
|
53
|
-
"@working-theory/mcp-scheduling": "0.3.
|
|
54
|
-
"@working-theory/mcp-signal-collectors": "0.2.
|
|
55
|
-
"@working-theory/mcp-workspace": "0.
|
|
53
|
+
"@working-theory/mcp-scheduling": "0.3.10",
|
|
54
|
+
"@working-theory/mcp-signal-collectors": "0.2.11",
|
|
55
|
+
"@working-theory/mcp-workspace": "0.7.0",
|
|
56
56
|
"@working-theory/partner-session": "0.0.0",
|
|
57
57
|
"@working-theory/preview-protocol": "0.0.0",
|
|
58
|
-
"@working-theory/ui-commerce": "0.23.
|
|
59
|
-
"@working-theory/ui-docs-blog": "0.23.
|
|
60
|
-
"@working-theory/ui-scheduling": "0.25.
|
|
61
|
-
"@working-theory/ui-signal-collectors": "0.28.
|
|
58
|
+
"@working-theory/ui-commerce": "0.23.35",
|
|
59
|
+
"@working-theory/ui-docs-blog": "0.23.35",
|
|
60
|
+
"@working-theory/ui-scheduling": "0.25.9",
|
|
61
|
+
"@working-theory/ui-signal-collectors": "0.28.1",
|
|
62
62
|
"@working-theory/web": "0.0.0",
|
|
63
63
|
"@working-theory/app-api": "1.0.0",
|
|
64
64
|
"@working-theory/mcp": "0.0.0",
|
|
65
|
-
"@working-theory/database": "0.
|
|
65
|
+
"@working-theory/database": "0.57.0"
|
|
66
66
|
}
|